# Specification: Fix `r.replace is not a function` in `expandRecurrences`

## Overview
This track addresses a `TypeError: r.replace is not a function` error occurring in `icalendar.ts` during calendar synchronization. The error suggests that the `rrule` property of an event is not a string when it reaches the `expandRecurrences` function, causing the subsequent `.replace()` call to fail. This is likely due to the `ts-ics` parser returning a non-string value (e.g., an object or `undefined`) for the `rrule` property in certain scenarios (specifically observed with Outlook calendars).

## Functional Requirements
- **Defensive RRULE Handling:** The `expandRecurrences` function in `icalendar.ts` must safely handle cases where `rrule` (or `recurrenceRule`) is not a string.
- **Graceful Fallback:** If `rrule` is not a string:
    - It should be ignored/logged if it cannot be interpreted as a valid RRULE string, preventing the crash.
    - The event should still be processed (treated as a non-recurring event if the rule is invalid), rather than crashing the entire sync for that event.

## Non-Functional Requirements
- **Stability:** The plug should not crash or throw unhandled exceptions during sync due to malformed or unexpected property types in the source ICS data.
- **Logging:** Maintain existing error logging but ensure the error message is descriptive (e.g., "Invalid RRULE type: object").

## Implementation Steps
1.  **Reproduce Issue:** Create a unit test in `icalendar_test.ts` that mocks an `icsEvent` with a non-string `rrule` property (e.g., an object or number) and calls `expandRecurrences`.
2.  **Implement Fix:** Modify `icalendar.ts` to check the type of `rruleStr` before calling `.replace()`.
    - If it's not a string, attempt to convert it or return the original event (as if no recurrence rule exists) with a warning.
3.  **Verify:** Run the new unit test to confirm the fix.

## Acceptance Criteria
- [ ] A new unit test case exists in `icalendar_test.ts` that passes with a non-string `rrule`.
- [ ] The `expandRecurrences` function no longer throws `TypeError: r.replace is not a function` when `rrule` is not a string.
- [ ] The sync process completes successfully even if some events have malformed `rrule` properties.