@janus-scheduler/core 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +94 -0
- package/dist/api/EventBus.d.ts +20 -0
- package/dist/api/EventBus.d.ts.map +1 -0
- package/dist/api/api.init.d.ts +3 -0
- package/dist/api/api.init.d.ts.map +1 -0
- package/dist/api/api.types.d.ts +309 -0
- package/dist/api/api.types.d.ts.map +1 -0
- package/dist/index.d.ts +16 -464
- package/dist/index.d.ts.map +1 -0
- package/dist/interactions/interactions.init.d.ts +1 -0
- package/dist/interactions/interactions.init.d.ts.map +1 -0
- package/dist/janus-scheduler.cjs +8 -0
- package/dist/janus-scheduler.cjs.map +1 -0
- package/dist/janus-scheduler.es.js +2426 -208
- package/dist/janus-scheduler.es.js.map +1 -1
- package/dist/models/assignments/assignments.d.ts +15 -0
- package/dist/models/assignments/assignments.d.ts.map +1 -0
- package/dist/models/events/event.d.ts +19 -0
- package/dist/models/events/event.d.ts.map +1 -0
- package/dist/models/resources/resources.d.ts +19 -0
- package/dist/models/resources/resources.d.ts.map +1 -0
- package/dist/rendering/rendering.init.d.ts +1 -0
- package/dist/rendering/rendering.init.d.ts.map +1 -0
- package/dist/services/SchedulerManager.service.d.ts +284 -0
- package/dist/services/SchedulerManager.service.d.ts.map +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/scheduler.store.d.ts +45 -0
- package/dist/store/scheduler.store.d.ts.map +1 -0
- package/dist/types/event.types.d.ts +15 -0
- package/dist/types/event.types.d.ts.map +1 -0
- package/dist/utils/conflict.d.ts +54 -0
- package/dist/utils/conflict.d.ts.map +1 -0
- package/dist/utils/recurrence.d.ts +9 -0
- package/dist/utils/recurrence.d.ts.map +1 -0
- package/dist/utils/time.d.ts +42 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/package.json +45 -14
- package/dist/janus-scheduler.cjs.js +0 -2
- package/dist/janus-scheduler.cjs.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,464 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare class Event_2 {
|
|
20
|
-
id: string;
|
|
21
|
-
title: string;
|
|
22
|
-
startTime: string;
|
|
23
|
-
endTime: string;
|
|
24
|
-
resourceId: string;
|
|
25
|
-
status: "draft" | "confirmed" | "cancelled";
|
|
26
|
-
description: string;
|
|
27
|
-
constructor(data: EventData);
|
|
28
|
-
isValid(): boolean;
|
|
29
|
-
getDuration(): number;
|
|
30
|
-
}
|
|
31
|
-
export { Event_2 as Event }
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Color options for scheduler events.
|
|
35
|
-
* Used in both TimelineEvent and MonthEvent.
|
|
36
|
-
*/
|
|
37
|
-
export declare type EventColor = "orange" | "blue" | "yellow" | "purple" | "green";
|
|
38
|
-
|
|
39
|
-
export declare interface EventCreateDetail {
|
|
40
|
-
resourceId: string;
|
|
41
|
-
startTime: string;
|
|
42
|
-
endTime: string;
|
|
43
|
-
date: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export declare interface EventData {
|
|
47
|
-
id: string;
|
|
48
|
-
title: string;
|
|
49
|
-
startTime: string;
|
|
50
|
-
endTime: string;
|
|
51
|
-
resourceId: string;
|
|
52
|
-
status?: "draft" | "confirmed" | "cancelled";
|
|
53
|
-
description?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
declare type EventHandler<K extends keyof JanusEventMap> = (payload: JanusEventMap[K]) => void;
|
|
57
|
-
|
|
58
|
-
export declare interface EventMoveDetail {
|
|
59
|
-
event: TimelineEvent;
|
|
60
|
-
oldResourceId: string;
|
|
61
|
-
newResourceId: string;
|
|
62
|
-
newStartTime: string;
|
|
63
|
-
newEndTime: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export declare interface EventResizeDetail {
|
|
67
|
-
event: TimelineEvent;
|
|
68
|
-
resourceId: string;
|
|
69
|
-
newStartTime: string;
|
|
70
|
-
newEndTime: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Human-readable label for a timezone including its UTC offset.
|
|
75
|
-
* e.g. "Asia/Kolkata (UTC+5:30)"
|
|
76
|
-
*/
|
|
77
|
-
export declare function formatTimezoneLabel(tz: string): string;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* All IANA timezone strings supported by the browser.
|
|
81
|
-
* Falls back to a curated list when Intl.supportedValuesOf is unavailable.
|
|
82
|
-
*/
|
|
83
|
-
export declare function getAllTimezones(): string[];
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* time.ts
|
|
87
|
-
*
|
|
88
|
-
* Timezone-aware date/time utilities for the Janus Scheduler.
|
|
89
|
-
* All functions use the native Intl API — no external dependencies.
|
|
90
|
-
*/
|
|
91
|
-
/** Get the browser's IANA timezone string (e.g. "Asia/Kolkata"). */
|
|
92
|
-
export declare function getBrowserTimezone(): string;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get the UTC milliseconds for a date+time string interpreted in the given IANA timezone.
|
|
96
|
-
* date: "YYYY-MM-DD" | time: "HH:MM"
|
|
97
|
-
*/
|
|
98
|
-
export declare function getUtcMsForZonedDatetime(date: string, time: string, timezone: string): number;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Convert a UTC ISO string → { date, time } displayed in the given IANA timezone.
|
|
102
|
-
* date: "YYYY-MM-DD" | time: "HH:MM" (24-hour)
|
|
103
|
-
*/
|
|
104
|
-
export declare function isoToZonedDisplay(iso: string, timezone: string): {
|
|
105
|
-
date: string;
|
|
106
|
-
time: string;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export declare class JanusEventBus {
|
|
110
|
-
private listeners;
|
|
111
|
-
/**
|
|
112
|
-
* Subscribe to a Janus Scheduler event.
|
|
113
|
-
*/
|
|
114
|
-
on<K extends keyof JanusEventMap>(event: K, handler: EventHandler<K>): void;
|
|
115
|
-
/**
|
|
116
|
-
* Unsubscribe from a Janus Scheduler event.
|
|
117
|
-
*/
|
|
118
|
-
off<K extends keyof JanusEventMap>(event: K, handler: EventHandler<K>): void;
|
|
119
|
-
/**
|
|
120
|
-
* Emit an event to all subscribers.
|
|
121
|
-
*/
|
|
122
|
-
emit<K extends keyof JanusEventMap>(event: K, payload: JanusEventMap[K]): void;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export declare const janusEventBus: JanusEventBus;
|
|
126
|
-
|
|
127
|
-
export declare interface JanusEventMap {
|
|
128
|
-
"event-click": TimelineEvent;
|
|
129
|
-
"add-event": void;
|
|
130
|
-
"day-click": {
|
|
131
|
-
date: string;
|
|
132
|
-
};
|
|
133
|
-
"view-change": {
|
|
134
|
-
view: ViewType;
|
|
135
|
-
};
|
|
136
|
-
"allow-create-change": {
|
|
137
|
-
allowCreate: boolean;
|
|
138
|
-
};
|
|
139
|
-
"event-move": EventMoveDetail;
|
|
140
|
-
"event-resize": EventResizeDetail;
|
|
141
|
-
"event-create": EventCreateDetail;
|
|
142
|
-
save: SchedulerSaveData;
|
|
143
|
-
delete: SchedulerDeleteData;
|
|
144
|
-
close: void;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export declare interface MonthEvent {
|
|
148
|
-
id: string;
|
|
149
|
-
title: string;
|
|
150
|
-
color: EventColor;
|
|
151
|
-
date: string;
|
|
152
|
-
startTime?: string;
|
|
153
|
-
endTime?: string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export declare class Resource {
|
|
157
|
-
id: string;
|
|
158
|
-
name: string;
|
|
159
|
-
type: "person" | "room" | "equipment";
|
|
160
|
-
email: string;
|
|
161
|
-
constructor(data: ResourceData);
|
|
162
|
-
isValid(): boolean;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export declare interface ResourceData {
|
|
166
|
-
id: string;
|
|
167
|
-
name: string;
|
|
168
|
-
type?: "person" | "room" | "equipment";
|
|
169
|
-
email?: string;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export declare interface SchedulerActions {
|
|
173
|
-
addEvent: (data: EventData) => Event_2;
|
|
174
|
-
updateEvent: (id: string, updates: Partial<EventData>) => Event_2;
|
|
175
|
-
deleteEvent: (id: string) => boolean;
|
|
176
|
-
addResource: (data: ResourceData) => Resource;
|
|
177
|
-
updateResource: (id: string, updates: Partial<ResourceData>) => Resource;
|
|
178
|
-
deleteResource: (id: string) => boolean;
|
|
179
|
-
addAssignment: (data: AssignmentData) => Assignment;
|
|
180
|
-
deleteAssignment: (id: string) => boolean;
|
|
181
|
-
clearAll: () => void;
|
|
182
|
-
/** Change the display timezone for all scheduler components. */
|
|
183
|
-
setTimezone: (timezone: string) => void;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export declare interface SchedulerDeleteData {
|
|
187
|
-
id: string | null;
|
|
188
|
-
title: string;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export declare interface SchedulerHooks {
|
|
192
|
-
onEventAdd?: (event: Event_2) => void | Promise<void>;
|
|
193
|
-
onEventUpdate?: (event: Event_2) => void | Promise<void>;
|
|
194
|
-
onEventDelete?: (id: string) => void | Promise<void>;
|
|
195
|
-
onResourceAdd?: (resource: Resource) => void | Promise<void>;
|
|
196
|
-
onResourceUpdate?: (resource: Resource) => void | Promise<void>;
|
|
197
|
-
onResourceDelete?: (id: string) => void | Promise<void>;
|
|
198
|
-
onAssignmentAdd?: (assignment: Assignment) => void | Promise<void>;
|
|
199
|
-
onAssignmentDelete?: (id: string) => void | Promise<void>;
|
|
200
|
-
/**
|
|
201
|
-
* Called whenever any hook fails — either throws synchronously or returns a
|
|
202
|
-
* rejected Promise (e.g. a failed fetch()). The store change that triggered
|
|
203
|
-
* the hook has already been rolled back by the time this fires, so the UI
|
|
204
|
-
* has reverted to the previous state.
|
|
205
|
-
*
|
|
206
|
-
* Use this hook to show an error notification to your user, e.g.:
|
|
207
|
-
* onError: ({ operation, error }) => toast.error(`${operation} failed: ${error.message}`)
|
|
208
|
-
*
|
|
209
|
-
* @param ctx.operation - Name of the method that failed, e.g. "addEvent"
|
|
210
|
-
* @param ctx.error - The raw thrown/rejected value from your hook
|
|
211
|
-
* @param ctx.reverted - Always true — the store was rolled back automatically
|
|
212
|
-
*/
|
|
213
|
-
onError?: (ctx: {
|
|
214
|
-
operation: string;
|
|
215
|
-
error: unknown;
|
|
216
|
-
reverted: boolean;
|
|
217
|
-
}) => void;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* SchedulerManager
|
|
222
|
-
*
|
|
223
|
-
* The single public API surface for reading and writing scheduler data.
|
|
224
|
-
* Internally it writes to the Zustand vanilla store (which drives UI reactivity)
|
|
225
|
-
* and then fires the matching lifecycle hook so the host application can persist
|
|
226
|
-
* the change to its own backend.
|
|
227
|
-
*
|
|
228
|
-
* If the async hook rejects (e.g. a network error), the store is automatically
|
|
229
|
-
* rolled back and `onError` is called — the host only needs to display a message.
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```ts
|
|
233
|
-
* const manager = new SchedulerManager({
|
|
234
|
-
* onEventAdd: async (event) => {
|
|
235
|
-
* await fetch('/api/events', { method: 'POST', body: JSON.stringify(event) });
|
|
236
|
-
* },
|
|
237
|
-
* onEventUpdate: async (event) => {
|
|
238
|
-
* await fetch(`/api/events/${event.id}`, { method: 'PATCH', body: JSON.stringify(event) });
|
|
239
|
-
* },
|
|
240
|
-
* onEventDelete: async (id) => {
|
|
241
|
-
* await fetch(`/api/events/${id}`, { method: 'DELETE' });
|
|
242
|
-
* },
|
|
243
|
-
* onError: ({ operation, error }) => {
|
|
244
|
-
* // The UI has already reverted — just show a notification
|
|
245
|
-
* toast.error(`"${operation}" failed. Your change has been undone.`);
|
|
246
|
-
* console.error(error);
|
|
247
|
-
* },
|
|
248
|
-
* });
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
export declare class SchedulerManager {
|
|
252
|
-
private readonly _hooks;
|
|
253
|
-
constructor(hooks?: SchedulerHooks);
|
|
254
|
-
/**
|
|
255
|
-
* Invokes an optional lifecycle hook inside a try/catch and, if it fails
|
|
256
|
-
* (synchronous throw OR async rejection), runs the rollback then calls onError.
|
|
257
|
-
*
|
|
258
|
-
* The hook is passed as a **thunk** (`() => hook?.()`) so that invocation
|
|
259
|
-
* happens inside the try block. Without this, a synchronous throw would
|
|
260
|
-
* escape at the call site before _fireHook was entered, bypassing rollback.
|
|
261
|
-
*
|
|
262
|
-
* @param operation - Method name shown in the error context, e.g. "addEvent"
|
|
263
|
-
* @param invokeHook - Zero-arg function that calls the hook and returns its result
|
|
264
|
-
* @param rollback - Undoes the optimistic store write
|
|
265
|
-
*/
|
|
266
|
-
private _fireHook;
|
|
267
|
-
/**
|
|
268
|
-
* Optimistically adds an event to the store, then fires `onEventAdd`.
|
|
269
|
-
* If the hook rejects, the event is removed from the store and `onError` fires.
|
|
270
|
-
*
|
|
271
|
-
* @param data - Raw event data
|
|
272
|
-
* @returns The created Event instance (already visible in the UI)
|
|
273
|
-
*/
|
|
274
|
-
addEvent(data: EventData): Event_2;
|
|
275
|
-
/**
|
|
276
|
-
* Get a single event by ID.
|
|
277
|
-
* @param id - Event ID
|
|
278
|
-
* @returns Event if found, undefined otherwise
|
|
279
|
-
*/
|
|
280
|
-
getEvent(id: string): Event_2 | undefined;
|
|
281
|
-
/**
|
|
282
|
-
* Get all events currently in the store.
|
|
283
|
-
* @returns Array of all Event instances
|
|
284
|
-
*/
|
|
285
|
-
getAllEvents(): Event_2[];
|
|
286
|
-
/**
|
|
287
|
-
* Optimistically updates an event in the store, then fires `onEventUpdate`.
|
|
288
|
-
* If the hook rejects, the event is restored to its previous state and `onError` fires.
|
|
289
|
-
*
|
|
290
|
-
* @param id - Event ID
|
|
291
|
-
* @param updates - Partial event fields to update
|
|
292
|
-
* @returns The updated Event instance (already visible in the UI)
|
|
293
|
-
*/
|
|
294
|
-
updateEvent(id: string, updates: Partial<EventData>): Event_2;
|
|
295
|
-
/**
|
|
296
|
-
* Optimistically deletes an event from the store, then fires `onEventDelete`.
|
|
297
|
-
* If the hook rejects, the event is re-added to the store and `onError` fires.
|
|
298
|
-
*
|
|
299
|
-
* @param id - Event ID
|
|
300
|
-
* @returns true if the event was found and deleted, false otherwise
|
|
301
|
-
*/
|
|
302
|
-
deleteEvent(id: string): boolean;
|
|
303
|
-
/**
|
|
304
|
-
* Get all events assigned to a specific resource.
|
|
305
|
-
* @param resourceId - Resource ID
|
|
306
|
-
* @returns Filtered array of Event instances
|
|
307
|
-
*/
|
|
308
|
-
getEventsByResource(resourceId: string): Event_2[];
|
|
309
|
-
/**
|
|
310
|
-
* Get all events that start on a specific calendar date.
|
|
311
|
-
* @param date - Date string in YYYY-MM-DD format
|
|
312
|
-
* @returns Filtered array of Event instances
|
|
313
|
-
*/
|
|
314
|
-
getEventsByDate(date: string): Event_2[];
|
|
315
|
-
/**
|
|
316
|
-
* Optimistically adds a resource to the store, then fires `onResourceAdd`.
|
|
317
|
-
* If the hook rejects, the resource is removed from the store and `onError` fires.
|
|
318
|
-
*
|
|
319
|
-
* @param data - Raw resource data
|
|
320
|
-
* @returns The created Resource instance (already visible in the UI)
|
|
321
|
-
*/
|
|
322
|
-
addResource(data: ResourceData): Resource;
|
|
323
|
-
/**
|
|
324
|
-
* Get a single resource by ID.
|
|
325
|
-
* @param id - Resource ID
|
|
326
|
-
* @returns Resource if found, undefined otherwise
|
|
327
|
-
*/
|
|
328
|
-
getResource(id: string): Resource | undefined;
|
|
329
|
-
/**
|
|
330
|
-
* Get all resources currently in the store.
|
|
331
|
-
* @returns Array of all Resource instances
|
|
332
|
-
*/
|
|
333
|
-
getAllResources(): Resource[];
|
|
334
|
-
/**
|
|
335
|
-
* Optimistically updates a resource in the store, then fires `onResourceUpdate`.
|
|
336
|
-
* If the hook rejects, the resource is restored to its previous state and `onError` fires.
|
|
337
|
-
*
|
|
338
|
-
* @param id - Resource ID
|
|
339
|
-
* @param updates - Partial resource fields to update
|
|
340
|
-
* @returns The updated Resource instance (already visible in the UI)
|
|
341
|
-
*/
|
|
342
|
-
updateResource(id: string, updates: Partial<ResourceData>): Resource;
|
|
343
|
-
/**
|
|
344
|
-
* Optimistically deletes a resource from the store, then fires `onResourceDelete`.
|
|
345
|
-
* If the hook rejects, the resource is re-added to the store and `onError` fires.
|
|
346
|
-
* Will throw synchronously if the resource has assigned events (store-level guard).
|
|
347
|
-
*
|
|
348
|
-
* @param id - Resource ID
|
|
349
|
-
* @returns true if the resource was found and deleted
|
|
350
|
-
*/
|
|
351
|
-
deleteResource(id: string): boolean;
|
|
352
|
-
/**
|
|
353
|
-
* Optimistically creates an assignment, then fires `onAssignmentAdd`.
|
|
354
|
-
* If the hook rejects, the assignment is deleted from the store and `onError` fires.
|
|
355
|
-
*
|
|
356
|
-
* @param data - Assignment data
|
|
357
|
-
* @returns The created Assignment instance (already visible in the UI)
|
|
358
|
-
*/
|
|
359
|
-
addAssignment(data: AssignmentData): Assignment;
|
|
360
|
-
/**
|
|
361
|
-
* Get all assignments for a specific event.
|
|
362
|
-
* @param eventId - Event ID
|
|
363
|
-
* @returns Array of Assignment instances
|
|
364
|
-
*/
|
|
365
|
-
getAssignmentsByEvent(eventId: string): Assignment[];
|
|
366
|
-
/**
|
|
367
|
-
* Get all assignments for a specific resource.
|
|
368
|
-
* @param resourceId - Resource ID
|
|
369
|
-
* @returns Array of Assignment instances
|
|
370
|
-
*/
|
|
371
|
-
getAssignmentsByResource(resourceId: string): Assignment[];
|
|
372
|
-
/**
|
|
373
|
-
* Optimistically deletes an assignment, then fires `onAssignmentDelete`.
|
|
374
|
-
* If the hook rejects, the assignment is re-added to the store and `onError` fires.
|
|
375
|
-
*
|
|
376
|
-
* @param id - Assignment ID
|
|
377
|
-
* @returns true if deleted, false if not found
|
|
378
|
-
*/
|
|
379
|
-
deleteAssignment(id: string): boolean;
|
|
380
|
-
/**
|
|
381
|
-
* Total number of events currently in the store.
|
|
382
|
-
*/
|
|
383
|
-
getEventCount(): number;
|
|
384
|
-
/**
|
|
385
|
-
* Total number of resources currently in the store.
|
|
386
|
-
*/
|
|
387
|
-
getResourceCount(): number;
|
|
388
|
-
/**
|
|
389
|
-
* Remove all events, resources, and assignments from the store.
|
|
390
|
-
* Does NOT fire individual delete hooks — use this only for full resets
|
|
391
|
-
* (e.g. on logout or when switching tenants).
|
|
392
|
-
*/
|
|
393
|
-
clearAll(): void;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
export declare interface SchedulerSaveData {
|
|
397
|
-
/** Present when editing an existing event; null/undefined when creating a new one. */
|
|
398
|
-
id: string | null;
|
|
399
|
-
title: string;
|
|
400
|
-
startDate: string;
|
|
401
|
-
startTime: string;
|
|
402
|
-
endDate: string;
|
|
403
|
-
endTime: string;
|
|
404
|
-
participants: string[];
|
|
405
|
-
description: string;
|
|
406
|
-
activeColor: string;
|
|
407
|
-
/** IANA timezone the user was viewing when they entered the times. */
|
|
408
|
-
timezone: string;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
export declare interface SchedulerState {
|
|
412
|
-
events: Record<string, Event_2>;
|
|
413
|
-
resources: Record<string, Resource>;
|
|
414
|
-
assignments: Record<string, Assignment>;
|
|
415
|
-
/** IANA timezone string used for all display conversions. Defaults to the browser's local timezone. */
|
|
416
|
-
timezone: string;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
export declare type SchedulerStore = SchedulerState & SchedulerActions;
|
|
420
|
-
|
|
421
|
-
export declare const schedulerStore: StoreApi<SchedulerStore>;
|
|
422
|
-
|
|
423
|
-
export declare interface TimelineEvent {
|
|
424
|
-
id: string;
|
|
425
|
-
title: string;
|
|
426
|
-
resourceId?: string;
|
|
427
|
-
startTime: string;
|
|
428
|
-
endTime: string;
|
|
429
|
-
/** Unix timestamp in ms — used for absolute positioning */
|
|
430
|
-
startMs: number;
|
|
431
|
-
/** Unix timestamp in ms — used for absolute positioning */
|
|
432
|
-
endMs: number;
|
|
433
|
-
color: EventColor;
|
|
434
|
-
date?: string;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export declare interface TimelineResource {
|
|
438
|
-
id: string;
|
|
439
|
-
name: string;
|
|
440
|
-
subtitle: string;
|
|
441
|
-
avatarType: "initials" | "icon";
|
|
442
|
-
avatarIcon?: "room" | "equipment";
|
|
443
|
-
groupLabel?: string;
|
|
444
|
-
events: TimelineEvent[];
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Return a "fake" local Date whose local-time getters reflect the given timezone.
|
|
449
|
-
* Used to pass to existing formatter functions that call getHours(), getDay(), etc.
|
|
450
|
-
*/
|
|
451
|
-
export declare function toFakeLocalDate(tsMs: number, timezone: string): Date;
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* The two supported calendar views.
|
|
455
|
-
*/
|
|
456
|
-
export declare type ViewType = "Timeline" | "Month";
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Convert a user-entered date+time (in the given timezone) → UTC ISO string.
|
|
460
|
-
* date: "YYYY-MM-DD" | time: "HH:MM"
|
|
461
|
-
*/
|
|
462
|
-
export declare function zonedInputToISO(date: string, time: string, timezone: string): string;
|
|
463
|
-
|
|
464
|
-
export { }
|
|
1
|
+
export { SchedulerManager } from './services/SchedulerManager.service';
|
|
2
|
+
export type { SchedulerHooks, SchedulerConfig, UndoAction, } from './services/SchedulerManager.service';
|
|
3
|
+
export * from './store';
|
|
4
|
+
export * from './api/api.init';
|
|
5
|
+
export type { SchedulerState, SchedulerActions, SchedulerStore, EventDraft, } from './store/scheduler.store';
|
|
6
|
+
export { Event } from './models/events/event';
|
|
7
|
+
export { Resource } from './models/resources/resources';
|
|
8
|
+
export { Assignment } from './models/assignments/assignments';
|
|
9
|
+
export type { EventData } from './types/event.types';
|
|
10
|
+
export type { ResourceData } from './models/resources/resources';
|
|
11
|
+
export type { AssignmentData } from './models/assignments/assignments';
|
|
12
|
+
export { getBrowserTimezone, isoToZonedDisplay, zonedInputToISO, getUtcMsForZonedDatetime, toFakeLocalDate, formatTimezoneLabel, getAllTimezones, } from './utils/time';
|
|
13
|
+
export { expandEvents } from './utils/recurrence';
|
|
14
|
+
export { computeTimelineConflicts, computeSingleResourceConflicts, checkSlotConflict, checkDraftConflict, } from './utils/conflict';
|
|
15
|
+
export type { ConflictEvent, ConflictResource } from './utils/conflict';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,YAAY,EACV,cAAc,EACd,eAAe,EACf,UAAU,GACX,MAAM,qCAAqC,CAAC;AAC7C,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,UAAU,GACX,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAG9D,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGvE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=interactions.init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactions.init.d.ts","sourceRoot":"","sources":["../../src/interactions/interactions.init.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const st=require("zustand/vanilla");class ee{id;title;startTime;endTime;resourceId;resourceIds;status;description;color;allDay;recurrenceRule;timezone;constructor(e){this.id=e.id,this.title=e.title,this.startTime=e.startTime,this.endTime=e.endTime,this.resourceIds=e.resourceIds&&e.resourceIds.length>0?e.resourceIds:e.resourceId?[e.resourceId]:[],this.resourceId=this.resourceIds[0]||e.resourceId||"",this.status=e.status||"draft",this.description=e.description||"",this.color=e.color,this.allDay=e.allDay,this.recurrenceRule=e.recurrenceRule,this.timezone=e.timezone}isValid(){if(!this.id||!this.title||this.resourceIds.length===0)return!1;const e=new Date(this.startTime),t=new Date(this.endTime);return!(e>=t)}getDuration(){const e=new Date(this.startTime).getTime();return(new Date(this.endTime).getTime()-e)/(1e3*60)}}class oe{id;name;type;email;avatar;subtitle;constructor(e){this.id=e.id,this.name=e.name,this.type=e.type||"person",this.email=e.email||"",this.avatar=e.avatar||"",this.subtitle=e.subtitle||""}isValid(){return!(!this.id||!this.name||this.type==="person"&&!this.email.trim())}}class $e{id;eventId;resourceId;role;constructor(e){this.id=e.id,this.eventId=e.eventId,this.resourceId=e.resourceId,this.role=e.role||"attendee"}isValid(){return!!(this.id&&this.eventId&&this.resourceId)}}function Fe(){return Intl.DateTimeFormat().resolvedOptions().timeZone}const at=new Map,ot=new Map,Be=new Map,ut=new Map;function X(r,e,t){let n=r.get(e);return n===void 0&&(n=t(),r.size>512&&r.clear(),r.set(e,n)),n}function ue(r,e){const t=new Date(r),n=X(at,e,()=>new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"})).formatToParts(t),i=n.find(d=>d.type==="year")?.value??"",s=n.find(d=>d.type==="month")?.value??"",a=n.find(d=>d.type==="day")?.value??"",o=X(ot,e,()=>new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"2-digit",minute:"2-digit",hour12:!1})).formatToParts(t);let u=o.find(d=>d.type==="hour")?.value??"00";const c=o.find(d=>d.type==="minute")?.value??"00";return u==="24"&&(u="00"),{date:`${i}-${s}-${a}`,time:`${u}:${c}`}}function Ke(r,e,t){const[n,i,s]=r.split("-").map(Number),[a,o]=e.split(":").map(Number),u=y=>{const m=X(Be,t,()=>new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})).formatToParts(new Date(y)),p=Number(m.find(I=>I.type==="year")?.value),b=Number(m.find(I=>I.type==="month")?.value),E=Number(m.find(I=>I.type==="day")?.value);let D=Number(m.find(I=>I.type==="hour")?.value);const Y=Number(m.find(I=>I.type==="minute")?.value),z=Number(m.find(I=>I.type==="second")?.value);return D===24&&(D=0),Date.UTC(p,b-1,E,D,Y,z)-y},c=Date.UTC(n,i-1,s,a,o,0),d=u(c),h=c-d,l=u(h);return l===d?h:c-l}function ce(r,e,t){return new Date(Ke(r,e,t)).toISOString()}function ct(r,e){const t=X(Be,e,()=>new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})).formatToParts(new Date(r)),n=Number(t.find(c=>c.type==="year")?.value),i=Number(t.find(c=>c.type==="month")?.value)-1,s=Number(t.find(c=>c.type==="day")?.value);let a=Number(t.find(c=>c.type==="hour")?.value);const o=Number(t.find(c=>c.type==="minute")?.value),u=Number(t.find(c=>c.type==="second")?.value);return a===24&&(a=0),new Date(n,i,s,a,o,u)}function lt(r){try{const e=X(ut,r,()=>new Intl.DateTimeFormat("en",{timeZone:r,timeZoneName:"shortOffset"})).formatToParts(new Date).find(t=>t.type==="timeZoneName")?.value??"";return`${r} (${e})`}catch{return r}}function dt(){try{return Intl.supportedValuesOf("timeZone")??De}catch{return De}}const De=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Sao_Paulo","Europe/London","Europe/Paris","Europe/Berlin","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Colombo","Asia/Singapore","Asia/Tokyo","Asia/Shanghai","Australia/Sydney","Pacific/Auckland"],be="janus-scheduler:new-event-draft",ge=typeof window<"u"&&typeof window.localStorage<"u",ht=()=>{if(!ge)return null;try{const r=localStorage.getItem(be);return r?JSON.parse(r):null}catch(r){return console.error("Failed to load draft from local storage",r),null}},ft=r=>{if(ge)try{localStorage.setItem(be,JSON.stringify(r))}catch(e){console.error(e)}},yt=()=>{if(ge)try{localStorage.removeItem(be)}catch(r){console.error(r)}},g=st.createStore((r,e)=>({events:{},resources:{},assignments:{},timezone:Fe(),eventDraft:null,addEvent:t=>{const n=new ee(t);if(!n.isValid())throw new Error("Invalid event data");return r(i=>({events:{...i.events,[n.id]:n}})),n},updateEvent:(t,n)=>{const s=e().events[t];if(!s)throw new Error(`Event ${t} not found`);let a=s.resourceIds,o=s.resourceId;n.resourceIds?(a=n.resourceIds,o=n.resourceIds[0]||""):n.resourceId&&(o=n.resourceId,a=[n.resourceId]);const u=new ee({id:s.id,title:n.title!==void 0?n.title:s.title,startTime:n.startTime!==void 0?n.startTime:s.startTime,endTime:n.endTime!==void 0?n.endTime:s.endTime,resourceId:o,resourceIds:a,status:n.status!==void 0?n.status:s.status,description:n.description!==void 0?n.description:s.description,color:n.color!==void 0?n.color:s.color,allDay:n.allDay!==void 0?n.allDay:s.allDay,recurrenceRule:n.recurrenceRule!==void 0?n.recurrenceRule:s.recurrenceRule,timezone:n.timezone!==void 0?n.timezone:s.timezone});return r(c=>({events:{...c.events,[t]:u}})),u},deleteEvent:t=>{let n=!1;return r(i=>{if(i.events[t]){const s={...i.events};return delete s[t],n=!0,{events:s}}return i}),n},addResource:t=>{const n=new oe(t);if(!n.isValid())throw new Error("Invalid resource data");return r(i=>({resources:{...i.resources,[n.id]:n}})),n},updateResource:(t,n)=>{const s=e().resources[t];if(!s)throw new Error(`Resource ${t} not found`);const a=new oe({id:s.id,name:n.name!==void 0?n.name:s.name,type:n.type!==void 0?n.type:s.type,email:n.email!==void 0?n.email:s.email,avatar:n.avatar!==void 0?n.avatar:s.avatar});if(!a.isValid())throw new Error("Invalid resource data");return r(o=>({resources:{...o.resources,[t]:a}})),a},deleteResource:t=>{const n=e();if(Object.values(n.events).some(a=>a.resourceIds&&a.resourceIds.includes(t)||a.resourceId===t))throw new Error(`Cannot delete resource ${t} - has assigned events`);let s=!1;return r(a=>{if(a.resources[t]){const o={...a.resources};return delete o[t],s=!0,{resources:o}}return a}),s},addAssignment:t=>{const n=e(),i=new $e(t);if(!i.isValid())throw new Error("Invalid assignment data");if(!n.events[i.eventId])throw new Error(`Event ${i.eventId} not found`);if(!n.resources[i.resourceId])throw new Error(`Resource ${i.resourceId} not found`);return r(s=>({assignments:{...s.assignments,[i.id]:i}})),i},deleteAssignment:t=>{let n=!1;return r(i=>{if(i.assignments[t]){const s={...i.assignments};return delete s[t],n=!0,{assignments:s}}return i}),n},clearAll:()=>{r({events:{},resources:{},assignments:{}})},setTimezone:t=>{r({timezone:t})},startDraft:(t,n)=>{let i={id:t,title:n.title??"",startDate:n.startDate??"",startTime:n.startTime??"",endDate:n.endDate??"",endTime:n.endTime??"",participants:n.participants??[],description:n.description??"",activeColor:n.activeColor??"orange",timezone:n.timezone??e().timezone,allDay:n.allDay??!1,recurrenceRule:n.recurrenceRule??""};if(t===null){const s=ht();s&&(i={...i,...s,id:null})}r({eventDraft:i})},updateDraft:t=>{const{eventDraft:n}=e();if(!n)return;const i={...n,...t};r({eventDraft:i}),i.id===null&&ft(i)},clearDraft:(t=!1)=>{const{eventDraft:n}=e();n&&n.id===null&&t&&yt(),r({eventDraft:null})}})),mt={maxUndoStackSize:20};class vt{_hooks;_config;_undoStack=[];_isUndoing=!1;_isBatchOperation=!1;_undoListeners=new Set;constructor(e={},t={}){this._hooks=e,this._config={...mt,...t}}canUndo(){return this._undoStack.length>0}peekUndo(){return this._undoStack.at(-1)}subscribeUndo(e){return this._undoListeners.add(e),()=>{this._undoListeners.delete(e)}}_notifyUndoChanged(){this._hooks.onUndoStateChange?.(this.canUndo());for(const e of this._undoListeners)e()}undo(){if(!this.canUndo())return;this._isUndoing=!0;const e=this._undoStack.pop();try{switch(e.type){case"addEvent":this.deleteEvent(e.id);break;case"updateEvent":this.updateEvent(e.id,e.previous);break;case"deleteEvent":this.addEvent(e.previous);break;case"batchAddEvents":for(const t of e.ids)this.deleteEvent(t);break}}catch{}finally{this._isUndoing=!1,this._notifyUndoChanged()}}_pushUndo(e){this._isUndoing||this._isBatchOperation||(this._undoStack.push(e),this._undoStack.length>this._config.maxUndoStackSize&&this._undoStack.shift(),this._notifyUndoChanged())}_fireHook(e,t,n){let i;try{i=t()}catch(s){n(),this._hooks.onError?.({operation:e,error:s,reverted:!0});return}i?.catch(s=>{n(),this._hooks.onError?.({operation:e,error:s,reverted:!0})})}addEvent(e){const t=g.getState().addEvent(e);return this._pushUndo({type:"addEvent",id:t.id}),this._isBatchOperation||this._fireHook("addEvent",()=>this._hooks.onEventAdd?.(t),()=>g.getState().deleteEvent(t.id)),t}batchAddEvents(e){this._isBatchOperation=!0;const t=[],n=[];try{for(const s of e){const a=this.addEvent(s);t.push(a),n.push(a.id)}}finally{this._isBatchOperation=!1}n.length>0&&(this._undoStack.push({type:"batchAddEvents",ids:n}),this._undoStack.length>this._config.maxUndoStackSize&&this._undoStack.shift(),this._notifyUndoChanged());const i=()=>{for(const s of n)g.getState().deleteEvent(s)};return this._hooks.onBulkEventAdd?this._fireHook("batchAddEvents",()=>this._hooks.onBulkEventAdd(t),i):this._hooks.onEventAdd&&this._fireHook("batchAddEvents",()=>{const a=t.map(o=>this._hooks.onEventAdd(o)).filter(o=>o instanceof Promise);return a.length>0?Promise.all(a).then(()=>{}):void 0},i),t}getEvent(e){const t=e.replace(/_occ_\d+$/,"");return g.getState().events[t]}getAllEvents(){return Object.values(g.getState().events)}getTimezone(){return g.getState().timezone}_shiftParentEventTimes(e,t,n){const i=g.getState().events[e];if(!i)return;const s=Number(n[2]),a=new Date(i.startTime).getTime(),o=new Date(i.endTime).getTime();if(t.startTime&&t.endTime){const u=new Date(t.startTime).getTime(),c=new Date(t.endTime).getTime(),d=u-s,h=c-u;t.startTime=new Date(a+d).toISOString(),t.endTime=new Date(a+d+h).toISOString()}else if(t.startTime){const c=new Date(t.startTime).getTime()-s;t.startTime=new Date(a+c).toISOString(),t.endTime=new Date(o+c).toISOString()}else if(t.endTime){const c=new Date(t.endTime).getTime()-s;t.startTime=i.startTime,t.endTime=new Date(a+c).toISOString()}}_computeEventDelta(e,t){const n={};for(const i of Object.keys(e)){if(i==="id")continue;const s=t[i],a=e[i];i==="resourceIds"?JSON.stringify(s)!==JSON.stringify(a)&&(n.resourceIds=s):s!==a&&(n[i]=s)}return n}updateEvent(e,t){const n=/^(.+)_occ_(\d+)$/.exec(e),i=n?n[1]:e;n&&this._shiftParentEventTimes(i,t,n);const s=g.getState().events[i],a=s?{...s,resourceIds:s.resourceIds?[...s.resourceIds]:void 0}:null,o=g.getState().updateEvent(i,t);if(a){const u=this._computeEventDelta(t,a);Object.keys(u).length>0&&this._pushUndo({type:"updateEvent",id:i,previous:u})}return this._fireHook("updateEvent",()=>this._hooks.onEventUpdate?.(o),()=>{a&&g.getState().updateEvent(i,{title:a.title,startTime:a.startTime,endTime:a.endTime,status:a.status,description:a.description,resourceId:a.resourceId,resourceIds:a.resourceIds,color:a.color,allDay:a.allDay,recurrenceRule:a.recurrenceRule})}),o}deleteEvent(e){const t=e.replace(/_occ_\d+$/,""),n=g.getState().events[t],i=g.getState().deleteEvent(t);return i&&n&&(this._pushUndo({type:"deleteEvent",previous:{id:n.id,title:n.title,startTime:n.startTime,endTime:n.endTime,status:n.status,description:n.description,resourceId:n.resourceId,resourceIds:n.resourceIds,color:n.color,allDay:n.allDay,recurrenceRule:n.recurrenceRule}}),this._fireHook("deleteEvent",()=>this._hooks.onEventDelete?.(t),()=>{g.getState().addEvent(n)})),i}getEventsByResource(e){return this.getAllEvents().filter(t=>t.resourceIds?.includes(e)||t.resourceId===e)}getEventsByDate(e){const t=new Date(e).toISOString().split("T")[0];return this.getAllEvents().filter(n=>new Date(n.startTime).toISOString().split("T")[0]===t)}addResource(e){const t=g.getState().addResource(e);return this._fireHook("addResource",()=>this._hooks.onResourceAdd?.(t),()=>g.getState().deleteResource(t.id)),t}getResource(e){return g.getState().resources[e]}getAllResources(){return Object.values(g.getState().resources)}updateResource(e,t){const n=g.getState().resources[e],i=n?{...n}:null,s=g.getState().updateResource(e,t);return this._fireHook("updateResource",()=>this._hooks.onResourceUpdate?.(s),()=>{i&&g.getState().updateResource(e,{name:i.name,type:i.type,email:i.email,avatar:i.avatar})}),s}deleteResource(e){const t=g.getState().resources[e],n=g.getState().deleteResource(e);return n&&this._fireHook("deleteResource",()=>this._hooks.onResourceDelete?.(e),()=>{t&&g.getState().addResource(t)}),n}addAssignment(e){const t=g.getState().addAssignment(e);return this._fireHook("addAssignment",()=>this._hooks.onAssignmentAdd?.(t),()=>g.getState().deleteAssignment(t.id)),t}getAssignmentsByEvent(e){return Object.values(g.getState().assignments).filter(t=>t.eventId===e)}getAssignmentsByResource(e){return Object.values(g.getState().assignments).filter(t=>t.resourceId===e)}deleteAssignment(e){const t=g.getState().assignments[e],n=g.getState().deleteAssignment(e);return n&&this._fireHook("deleteAssignment",()=>this._hooks.onAssignmentDelete?.(e),()=>{t&&g.getState().addAssignment(t)}),n}getEventCount(){return Object.keys(g.getState().events).length}getResourceCount(){return Object.keys(g.getState().resources).length}clearAll(){g.getState().clearAll(),this._undoStack=[],this._hooks.onUndoStateChange?.(this.canUndo())}}class Ze{listeners={};on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}off(e,t){if(!this.listeners[e])return;const n=this.listeners[e];this.listeners[e]=n.filter(i=>i!==t)}emit(e,t){this.listeners[e]&&this.listeners[e].forEach(n=>{try{n(t)}catch(i){console.error(`Error in event handler for ${e}:`,i)}})}}const pt=new Ze;var le=["MO","TU","WE","TH","FR","SA","SU"],M=(function(){function r(e,t){if(t===0)throw new Error("Can't create weekday with n == 0");this.weekday=e,this.n=t}return r.fromStr=function(e){return new r(le.indexOf(e))},r.prototype.nth=function(e){return this.n===e?this:new r(this.weekday,e)},r.prototype.equals=function(e){return this.weekday===e.weekday&&this.n===e.n},r.prototype.toString=function(){var e=le[this.weekday];return this.n&&(e=(this.n>0?"+":"")+String(this.n)+e),e},r.prototype.getJsWeekday=function(){return this.weekday===6?0:this.weekday+1},r})(),S=function(r){return r!=null},N=function(r){return typeof r=="number"},Ie=function(r){return typeof r=="string"&&le.includes(r)},A=Array.isArray,W=function(r,e){e===void 0&&(e=r),arguments.length===1&&(e=r,r=0);for(var t=[],n=r;n<e;n++)t.push(n);return t},w=function(r,e){var t=0,n=[];if(A(r))for(;t<e;t++)n[t]=[].concat(r);else for(;t<e;t++)n[t]=r;return n},bt=function(r){return A(r)?r:[r]};function B(r,e,t){t===void 0&&(t=" ");var n=String(r);return e=e>>0,n.length>e?String(n):(e=e-n.length,e>t.length&&(t+=w(t,e/t.length)),t.slice(0,e)+String(n))}var gt=function(r,e,t){var n=r.split(e);return t?n.slice(0,t).concat([n.slice(t).join(e)]):n},R=function(r,e){var t=r%e;return t*e<0?t+e:t},se=function(r,e){return{div:Math.floor(r/e),mod:R(r,e)}},C=function(r){return!S(r)||r.length===0},_=function(r){return!C(r)},k=function(r,e){return _(r)&&r.indexOf(e)!==-1},F=function(r,e,t,n,i,s){return n===void 0&&(n=0),i===void 0&&(i=0),s===void 0&&(s=0),new Date(Date.UTC(r,e-1,t,n,i,s))},wt=[31,28,31,30,31,30,31,31,30,31,30,31],qe=1e3*60*60*24,Je=9999,Ge=F(1970,1,1),Tt=[6,0,1,2,3,4,5],G=function(r){return r%4===0&&r%100!==0||r%400===0},Xe=function(r){return r instanceof Date},J=function(r){return Xe(r)&&!isNaN(r.getTime())},Et=function(r,e){var t=r.getTime(),n=e.getTime(),i=t-n;return Math.round(i/qe)},de=function(r){return Et(r,Ge)},Ve=function(r){return new Date(Ge.getTime()+r*qe)},kt=function(r){var e=r.getUTCMonth();return e===1&&G(r.getUTCFullYear())?29:wt[e]},Z=function(r){return Tt[r.getUTCDay()]},_e=function(r,e){var t=F(r,e+1,1);return[Z(t),kt(t)]},Qe=function(r,e){return e=e||r,new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))},he=function(r){var e=new Date(r.getTime());return e},Oe=function(r){for(var e=[],t=0;t<r.length;t++)e.push(he(r[t]));return e},V=function(r){r.sort(function(e,t){return e.getTime()-t.getTime()})},we=function(r,e){e===void 0&&(e=!0);var t=new Date(r);return[B(t.getUTCFullYear().toString(),4,"0"),B(t.getUTCMonth()+1,2,"0"),B(t.getUTCDate(),2,"0"),"T",B(t.getUTCHours(),2,"0"),B(t.getUTCMinutes(),2,"0"),B(t.getUTCSeconds(),2,"0"),e?"Z":""].join("")},Te=function(r){var e=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$/,t=e.exec(r);if(!t)throw new Error("Invalid UNTIL value: ".concat(r));return new Date(Date.UTC(parseInt(t[1],10),parseInt(t[2],10)-1,parseInt(t[3],10),parseInt(t[5],10)||0,parseInt(t[6],10)||0,parseInt(t[7],10)||0))},xe=function(r,e){var t=r.toLocaleString("sv-SE",{timeZone:e});return t.replace(" ","T")+"Z"},St=function(r,e){var t=Intl.DateTimeFormat().resolvedOptions().timeZone,n=new Date(xe(r,t)),i=new Date(xe(r,e??"UTC")),s=i.getTime()-n.getTime();return new Date(r.getTime()-s)},K=(function(){function r(e,t){this.minDate=null,this.maxDate=null,this._result=[],this.total=0,this.method=e,this.args=t,e==="between"?(this.maxDate=t.inc?t.before:new Date(t.before.getTime()-1),this.minDate=t.inc?t.after:new Date(t.after.getTime()+1)):e==="before"?this.maxDate=t.inc?t.dt:new Date(t.dt.getTime()-1):e==="after"&&(this.minDate=t.inc?t.dt:new Date(t.dt.getTime()+1))}return r.prototype.accept=function(e){++this.total;var t=this.minDate&&e<this.minDate,n=this.maxDate&&e>this.maxDate;if(this.method==="between"){if(t)return!0;if(n)return!1}else if(this.method==="before"){if(n)return!1}else if(this.method==="after")return t?!0:(this.add(e),!1);return this.add(e)},r.prototype.add=function(e){return this._result.push(e),!0},r.prototype.getValue=function(){var e=this._result;switch(this.method){case"all":case"between":return e;default:return e.length?e[e.length-1]:null}},r.prototype.clone=function(){return new r(this.method,this.args)},r})(),fe=function(r,e){return fe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},fe(r,e)};function Ee(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");fe(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var U=function(){return U=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},U.apply(this,arguments)};function f(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))}var Me=(function(r){Ee(e,r);function e(t,n,i){var s=r.call(this,t,n)||this;return s.iterator=i,s}return e.prototype.add=function(t){return this.iterator(t,this._result.length)?(this._result.push(t),!0):!1},e})(K),te={dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],tokens:{SKIP:/^[ \r\n\t]+|^\.$/,number:/^[1-9][0-9]*/,numberAsText:/^(one|two|three)/i,every:/^every/i,"day(s)":/^days?/i,"weekday(s)":/^weekdays?/i,"week(s)":/^weeks?/i,"hour(s)":/^hours?/i,"minute(s)":/^minutes?/i,"month(s)":/^months?/i,"year(s)":/^years?/i,on:/^(on|in)/i,at:/^(at)/i,the:/^the/i,first:/^first/i,second:/^second/i,third:/^third/i,nth:/^([1-9][0-9]*)(\.|th|nd|rd|st)/i,last:/^last/i,for:/^for/i,"time(s)":/^times?/i,until:/^(un)?til/i,monday:/^mo(n(day)?)?/i,tuesday:/^tu(e(s(day)?)?)?/i,wednesday:/^we(d(n(esday)?)?)?/i,thursday:/^th(u(r(sday)?)?)?/i,friday:/^fr(i(day)?)?/i,saturday:/^sa(t(urday)?)?/i,sunday:/^su(n(day)?)?/i,january:/^jan(uary)?/i,february:/^feb(ruary)?/i,march:/^mar(ch)?/i,april:/^apr(il)?/i,may:/^may/i,june:/^june?/i,july:/^july?/i,august:/^aug(ust)?/i,september:/^sep(t(ember)?)?/i,october:/^oct(ober)?/i,november:/^nov(ember)?/i,december:/^dec(ember)?/i,comma:/^(,\s*|(and|or)\s*)+/i}},Ae=function(r,e){return r.indexOf(e)!==-1},Dt=function(r){return r.toString()},It=function(r,e,t){return"".concat(e," ").concat(t,", ").concat(r)},P=(function(){function r(e,t,n,i){if(t===void 0&&(t=Dt),n===void 0&&(n=te),i===void 0&&(i=It),this.text=[],this.language=n||te,this.gettext=t,this.dateFormatter=i,this.rrule=e,this.options=e.options,this.origOptions=e.origOptions,this.origOptions.bymonthday){var s=[].concat(this.options.bymonthday),a=[].concat(this.options.bynmonthday);s.sort(function(d,h){return d-h}),a.sort(function(d,h){return h-d}),this.bymonthday=s.concat(a),this.bymonthday.length||(this.bymonthday=null)}if(S(this.origOptions.byweekday)){var o=A(this.origOptions.byweekday)?this.origOptions.byweekday:[this.origOptions.byweekday],u=String(o);this.byweekday={allWeeks:o.filter(function(d){return!d.n}),someWeeks:o.filter(function(d){return!!d.n}),isWeekdays:u.indexOf("MO")!==-1&&u.indexOf("TU")!==-1&&u.indexOf("WE")!==-1&&u.indexOf("TH")!==-1&&u.indexOf("FR")!==-1&&u.indexOf("SA")===-1&&u.indexOf("SU")===-1,isEveryDay:u.indexOf("MO")!==-1&&u.indexOf("TU")!==-1&&u.indexOf("WE")!==-1&&u.indexOf("TH")!==-1&&u.indexOf("FR")!==-1&&u.indexOf("SA")!==-1&&u.indexOf("SU")!==-1};var c=function(d,h){return d.weekday-h.weekday};this.byweekday.allWeeks.sort(c),this.byweekday.someWeeks.sort(c),this.byweekday.allWeeks.length||(this.byweekday.allWeeks=null),this.byweekday.someWeeks.length||(this.byweekday.someWeeks=null)}else this.byweekday=null}return r.isFullyConvertible=function(e){var t=!0;if(!(e.options.freq in r.IMPLEMENTED)||e.origOptions.until&&e.origOptions.count)return!1;for(var n in e.origOptions){if(Ae(["dtstart","tzid","wkst","freq"],n))return!0;if(!Ae(r.IMPLEMENTED[e.options.freq],n))return!1}return t},r.prototype.isFullyConvertible=function(){return r.isFullyConvertible(this.rrule)},r.prototype.toString=function(){var e=this.gettext;if(!(this.options.freq in r.IMPLEMENTED))return e("RRule error: Unable to fully convert this rrule to text");if(this.text=[e("every")],this[v.FREQUENCIES[this.options.freq]](),this.options.until){this.add(e("until"));var t=this.options.until;this.add(this.dateFormatter(t.getUTCFullYear(),this.language.monthNames[t.getUTCMonth()],t.getUTCDate()))}else this.options.count&&this.add(e("for")).add(this.options.count.toString()).add(this.plural(this.options.count)?e("times"):e("time"));return this.isFullyConvertible()||this.add(e("(~ approximate)")),this.text.join("")},r.prototype.HOURLY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("hours"):e("hour"))},r.prototype.MINUTELY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("minutes"):e("minute"))},r.prototype.DAILY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.byweekday&&this.byweekday.isWeekdays?this.add(this.plural(this.options.interval)?e("weekdays"):e("weekday")):this.add(this.plural(this.options.interval)?e("days"):e("day")),this.origOptions.bymonth&&(this.add(e("in")),this._bymonth()),this.bymonthday?this._bymonthday():this.byweekday?this._byweekday():this.origOptions.byhour&&this._byhour()},r.prototype.WEEKLY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()).add(this.plural(this.options.interval)?e("weeks"):e("week")),this.byweekday&&this.byweekday.isWeekdays?this.options.interval===1?this.add(this.plural(this.options.interval)?e("weekdays"):e("weekday")):this.add(e("on")).add(e("weekdays")):this.byweekday&&this.byweekday.isEveryDay?this.add(this.plural(this.options.interval)?e("days"):e("day")):(this.options.interval===1&&this.add(e("week")),this.origOptions.bymonth&&(this.add(e("in")),this._bymonth()),this.bymonthday?this._bymonthday():this.byweekday&&this._byweekday(),this.origOptions.byhour&&this._byhour())},r.prototype.MONTHLY=function(){var e=this.gettext;this.origOptions.bymonth?(this.options.interval!==1&&(this.add(this.options.interval.toString()).add(e("months")),this.plural(this.options.interval)&&this.add(e("in"))),this._bymonth()):(this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("months"):e("month"))),this.bymonthday?this._bymonthday():this.byweekday&&this.byweekday.isWeekdays?this.add(e("on")).add(e("weekdays")):this.byweekday&&this._byweekday()},r.prototype.YEARLY=function(){var e=this.gettext;this.origOptions.bymonth?(this.options.interval!==1&&(this.add(this.options.interval.toString()),this.add(e("years"))),this._bymonth()):(this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("years"):e("year"))),this.bymonthday?this._bymonthday():this.byweekday&&this._byweekday(),this.options.byyearday&&this.add(e("on the")).add(this.list(this.options.byyearday,this.nth,e("and"))).add(e("day")),this.options.byweekno&&this.add(e("in")).add(this.plural(this.options.byweekno.length)?e("weeks"):e("week")).add(this.list(this.options.byweekno,void 0,e("and")))},r.prototype._bymonthday=function(){var e=this.gettext;this.byweekday&&this.byweekday.allWeeks?this.add(e("on")).add(this.list(this.byweekday.allWeeks,this.weekdaytext,e("or"))).add(e("the")).add(this.list(this.bymonthday,this.nth,e("or"))):this.add(e("on the")).add(this.list(this.bymonthday,this.nth,e("and")))},r.prototype._byweekday=function(){var e=this.gettext;this.byweekday.allWeeks&&!this.byweekday.isWeekdays&&this.add(e("on")).add(this.list(this.byweekday.allWeeks,this.weekdaytext)),this.byweekday.someWeeks&&(this.byweekday.allWeeks&&this.add(e("and")),this.add(e("on the")).add(this.list(this.byweekday.someWeeks,this.weekdaytext,e("and"))))},r.prototype._byhour=function(){var e=this.gettext;this.add(e("at")).add(this.list(this.origOptions.byhour,void 0,e("and")))},r.prototype._bymonth=function(){this.add(this.list(this.options.bymonth,this.monthtext,this.gettext("and")))},r.prototype.nth=function(e){e=parseInt(e.toString(),10);var t,n=this.gettext;if(e===-1)return n("last");var i=Math.abs(e);switch(i){case 1:case 21:case 31:t=i+n("st");break;case 2:case 22:t=i+n("nd");break;case 3:case 23:t=i+n("rd");break;default:t=i+n("th")}return e<0?t+" "+n("last"):t},r.prototype.monthtext=function(e){return this.language.monthNames[e-1]},r.prototype.weekdaytext=function(e){var t=N(e)?(e+1)%7:e.getJsWeekday();return(e.n?this.nth(e.n)+" ":"")+this.language.dayNames[t]},r.prototype.plural=function(e){return e%100!==1},r.prototype.add=function(e){return this.text.push(" "),this.text.push(e),this},r.prototype.list=function(e,t,n,i){var s=this;i===void 0&&(i=","),A(e)||(e=[e]);var a=function(u,c,d){for(var h="",l=0;l<u.length;l++)l!==0&&(l===u.length-1?h+=" "+d+" ":h+=c+" "),h+=u[l];return h};t=t||function(u){return u.toString()};var o=function(u){return t&&t.call(s,u)};return n?a(e.map(o),i,n):e.map(o).join(i+" ")},r})(),_t=(function(){function r(e){this.done=!0,this.rules=e}return r.prototype.start=function(e){return this.text=e,this.done=!1,this.nextSymbol()},r.prototype.isDone=function(){return this.done&&this.symbol===null},r.prototype.nextSymbol=function(){var e,t;this.symbol=null,this.value=null;do{if(this.done)return!1;var n=void 0;e=null;for(var i in this.rules){n=this.rules[i];var s=n.exec(this.text);s&&(e===null||s[0].length>e[0].length)&&(e=s,t=i)}if(e!=null&&(this.text=this.text.substr(e[0].length),this.text===""&&(this.done=!0)),e==null){this.done=!0,this.symbol=null,this.value=null;return}}while(t==="SKIP");return this.symbol=t,this.value=e,!0},r.prototype.accept=function(e){if(this.symbol===e){if(this.value){var t=this.value;return this.nextSymbol(),t}return this.nextSymbol(),!0}return!1},r.prototype.acceptNumber=function(){return this.accept("number")},r.prototype.expect=function(e){if(this.accept(e))return!0;throw new Error("expected "+e+" but found "+this.symbol)},r})();function et(r,e){e===void 0&&(e=te);var t={},n=new _t(e.tokens);if(!n.start(r))return null;return i(),t;function i(){n.expect("every");var l=n.acceptNumber();if(l&&(t.interval=parseInt(l[0],10)),n.isDone())throw new Error("Unexpected end");switch(n.symbol){case"day(s)":t.freq=v.DAILY,n.nextSymbol()&&(a(),h());break;case"weekday(s)":t.freq=v.WEEKLY,t.byweekday=[v.MO,v.TU,v.WE,v.TH,v.FR],n.nextSymbol(),a(),h();break;case"week(s)":t.freq=v.WEEKLY,n.nextSymbol()&&(s(),a(),h());break;case"hour(s)":t.freq=v.HOURLY,n.nextSymbol()&&(s(),h());break;case"minute(s)":t.freq=v.MINUTELY,n.nextSymbol()&&(s(),h());break;case"month(s)":t.freq=v.MONTHLY,n.nextSymbol()&&(s(),h());break;case"year(s)":t.freq=v.YEARLY,n.nextSymbol()&&(s(),h());break;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":t.freq=v.WEEKLY;var y=n.symbol.substr(0,2).toUpperCase();if(t.byweekday=[v[y]],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var m=u();if(!m)throw new Error("Unexpected symbol "+n.symbol+", expected weekday");t.byweekday.push(v[m]),n.nextSymbol()}a(),d(),h();break;case"january":case"february":case"march":case"april":case"may":case"june":case"july":case"august":case"september":case"october":case"november":case"december":if(t.freq=v.YEARLY,t.bymonth=[o()],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var p=o();if(!p)throw new Error("Unexpected symbol "+n.symbol+", expected month");t.bymonth.push(p),n.nextSymbol()}s(),h();break;default:throw new Error("Unknown symbol")}}function s(){var l=n.accept("on"),y=n.accept("the");if(l||y)do{var m=c(),p=u(),b=o();if(m)p?(n.nextSymbol(),t.byweekday||(t.byweekday=[]),t.byweekday.push(v[p].nth(m))):(t.bymonthday||(t.bymonthday=[]),t.bymonthday.push(m),n.accept("day(s)"));else if(p)n.nextSymbol(),t.byweekday||(t.byweekday=[]),t.byweekday.push(v[p]);else if(n.symbol==="weekday(s)")n.nextSymbol(),t.byweekday||(t.byweekday=[v.MO,v.TU,v.WE,v.TH,v.FR]);else if(n.symbol==="week(s)"){n.nextSymbol();var E=n.acceptNumber();if(!E)throw new Error("Unexpected symbol "+n.symbol+", expected week number");for(t.byweekno=[parseInt(E[0],10)];n.accept("comma");){if(E=n.acceptNumber(),!E)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");t.byweekno.push(parseInt(E[0],10))}}else if(b)n.nextSymbol(),t.bymonth||(t.bymonth=[]),t.bymonth.push(b);else return}while(n.accept("comma")||n.accept("the")||n.accept("on"))}function a(){var l=n.accept("at");if(l)do{var y=n.acceptNumber();if(!y)throw new Error("Unexpected symbol "+n.symbol+", expected hour");for(t.byhour=[parseInt(y[0],10)];n.accept("comma");){if(y=n.acceptNumber(),!y)throw new Error("Unexpected symbol "+n.symbol+"; expected hour");t.byhour.push(parseInt(y[0],10))}}while(n.accept("comma")||n.accept("at"))}function o(){switch(n.symbol){case"january":return 1;case"february":return 2;case"march":return 3;case"april":return 4;case"may":return 5;case"june":return 6;case"july":return 7;case"august":return 8;case"september":return 9;case"october":return 10;case"november":return 11;case"december":return 12;default:return!1}}function u(){switch(n.symbol){case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return n.symbol.substr(0,2).toUpperCase();default:return!1}}function c(){switch(n.symbol){case"last":return n.nextSymbol(),-1;case"first":return n.nextSymbol(),1;case"second":return n.nextSymbol(),n.accept("last")?-2:2;case"third":return n.nextSymbol(),n.accept("last")?-3:3;case"nth":var l=parseInt(n.value[1],10);if(l<-366||l>366)throw new Error("Nth out of range: "+l);return n.nextSymbol(),n.accept("last")?-l:l;default:return!1}}function d(){n.accept("on"),n.accept("the");var l=c();if(l)for(t.bymonthday=[l],n.nextSymbol();n.accept("comma");){if(l=c(),!l)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");t.bymonthday.push(l),n.nextSymbol()}}function h(){if(n.symbol==="until"){var l=Date.parse(n.text);if(!l)throw new Error("Cannot parse until date:"+n.text);t.until=new Date(l)}else n.accept("for")&&(t.count=parseInt(n.value[0],10),n.expect("number"))}}var T;(function(r){r[r.YEARLY=0]="YEARLY",r[r.MONTHLY=1]="MONTHLY",r[r.WEEKLY=2]="WEEKLY",r[r.DAILY=3]="DAILY",r[r.HOURLY=4]="HOURLY",r[r.MINUTELY=5]="MINUTELY",r[r.SECONDLY=6]="SECONDLY"})(T||(T={}));function ke(r){return r<T.HOURLY}var Ot=function(r,e){return e===void 0&&(e=te),new v(et(r,e)||void 0)},q=["count","until","interval","byweekday","bymonthday","bymonth"];P.IMPLEMENTED=[];P.IMPLEMENTED[T.HOURLY]=q;P.IMPLEMENTED[T.MINUTELY]=q;P.IMPLEMENTED[T.DAILY]=["byhour"].concat(q);P.IMPLEMENTED[T.WEEKLY]=q;P.IMPLEMENTED[T.MONTHLY]=q;P.IMPLEMENTED[T.YEARLY]=["byweekno","byyearday"].concat(q);var xt=function(r,e,t,n){return new P(r,e,t,n).toString()},Mt=P.isFullyConvertible,re=(function(){function r(e,t,n,i){this.hour=e,this.minute=t,this.second=n,this.millisecond=i||0}return r.prototype.getHours=function(){return this.hour},r.prototype.getMinutes=function(){return this.minute},r.prototype.getSeconds=function(){return this.second},r.prototype.getMilliseconds=function(){return this.millisecond},r.prototype.getTime=function(){return(this.hour*60*60+this.minute*60+this.second)*1e3+this.millisecond},r})(),At=(function(r){Ee(e,r);function e(t,n,i,s,a,o,u){var c=r.call(this,s,a,o,u)||this;return c.year=t,c.month=n,c.day=i,c}return e.fromDate=function(t){return new this(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.valueOf()%1e3)},e.prototype.getWeekday=function(){return Z(new Date(this.getTime()))},e.prototype.getTime=function(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond)).getTime()},e.prototype.getDay=function(){return this.day},e.prototype.getMonth=function(){return this.month},e.prototype.getYear=function(){return this.year},e.prototype.addYears=function(t){this.year+=t},e.prototype.addMonths=function(t){if(this.month+=t,this.month>12){var n=Math.floor(this.month/12),i=R(this.month,12);this.month=i,this.year+=n,this.month===0&&(this.month=12,--this.year)}},e.prototype.addWeekly=function(t,n){n>this.getWeekday()?this.day+=-(this.getWeekday()+1+(6-n))+t*7:this.day+=-(this.getWeekday()-n)+t*7,this.fixDay()},e.prototype.addDaily=function(t){this.day+=t,this.fixDay()},e.prototype.addHours=function(t,n,i){for(n&&(this.hour+=Math.floor((23-this.hour)/t)*t);;){this.hour+=t;var s=se(this.hour,24),a=s.div,o=s.mod;if(a&&(this.hour=o,this.addDaily(a)),C(i)||k(i,this.hour))break}},e.prototype.addMinutes=function(t,n,i,s){for(n&&(this.minute+=Math.floor((1439-(this.hour*60+this.minute))/t)*t);;){this.minute+=t;var a=se(this.minute,60),o=a.div,u=a.mod;if(o&&(this.minute=u,this.addHours(o,!1,i)),(C(i)||k(i,this.hour))&&(C(s)||k(s,this.minute)))break}},e.prototype.addSeconds=function(t,n,i,s,a){for(n&&(this.second+=Math.floor((86399-(this.hour*3600+this.minute*60+this.second))/t)*t);;){this.second+=t;var o=se(this.second,60),u=o.div,c=o.mod;if(u&&(this.second=c,this.addMinutes(u,!1,i,s)),(C(i)||k(i,this.hour))&&(C(s)||k(s,this.minute))&&(C(a)||k(a,this.second)))break}},e.prototype.fixDay=function(){if(!(this.day<=28)){var t=_e(this.year,this.month-1)[1];if(!(this.day<=t))for(;this.day>t;){if(this.day-=t,++this.month,this.month===13&&(this.month=1,++this.year,this.year>Je))return;t=_e(this.year,this.month-1)[1]}}},e.prototype.add=function(t,n){var i=t.freq,s=t.interval,a=t.wkst,o=t.byhour,u=t.byminute,c=t.bysecond;switch(i){case T.YEARLY:return this.addYears(s);case T.MONTHLY:return this.addMonths(s);case T.WEEKLY:return this.addWeekly(s,a);case T.DAILY:return this.addDaily(s);case T.HOURLY:return this.addHours(s,n,o);case T.MINUTELY:return this.addMinutes(s,n,o,u);case T.SECONDLY:return this.addSeconds(s,n,o,u,c)}},e})(re);function tt(r){for(var e=[],t=Object.keys(r),n=0,i=t;n<i.length;n++){var s=i[n];k(or,s)||e.push(s),Xe(r[s])&&!J(r[s])&&e.push(s)}if(e.length)throw new Error("Invalid options: "+e.join(", "));return U({},r)}function Ut(r){var e=U(U({},Se),tt(r));if(S(e.byeaster)&&(e.freq=v.YEARLY),!(S(e.freq)&&v.FREQUENCIES[e.freq]))throw new Error("Invalid frequency: ".concat(e.freq," ").concat(r.freq));if(e.dtstart||(e.dtstart=new Date(new Date().setMilliseconds(0))),S(e.wkst)?N(e.wkst)||(e.wkst=e.wkst.weekday):e.wkst=v.MO.weekday,S(e.bysetpos)){N(e.bysetpos)&&(e.bysetpos=[e.bysetpos]);for(var t=0;t<e.bysetpos.length;t++){var n=e.bysetpos[t];if(n===0||!(n>=-366&&n<=366))throw new Error("bysetpos must be between 1 and 366, or between -366 and -1")}}if(!(e.byweekno||_(e.byweekno)||_(e.byyearday)||e.bymonthday||_(e.bymonthday)||S(e.byweekday)||S(e.byeaster)))switch(e.freq){case v.YEARLY:e.bymonth||(e.bymonth=e.dtstart.getUTCMonth()+1),e.bymonthday=e.dtstart.getUTCDate();break;case v.MONTHLY:e.bymonthday=e.dtstart.getUTCDate();break;case v.WEEKLY:e.byweekday=[Z(e.dtstart)];break}if(S(e.bymonth)&&!A(e.bymonth)&&(e.bymonth=[e.bymonth]),S(e.byyearday)&&!A(e.byyearday)&&N(e.byyearday)&&(e.byyearday=[e.byyearday]),!S(e.bymonthday))e.bymonthday=[],e.bynmonthday=[];else if(A(e.bymonthday)){for(var i=[],s=[],t=0;t<e.bymonthday.length;t++){var n=e.bymonthday[t];n>0?i.push(n):n<0&&s.push(n)}e.bymonthday=i,e.bynmonthday=s}else e.bymonthday<0?(e.bynmonthday=[e.bymonthday],e.bymonthday=[]):(e.bynmonthday=[],e.bymonthday=[e.bymonthday]);if(S(e.byweekno)&&!A(e.byweekno)&&(e.byweekno=[e.byweekno]),!S(e.byweekday))e.bynweekday=null;else if(N(e.byweekday))e.byweekday=[e.byweekday],e.bynweekday=null;else if(Ie(e.byweekday))e.byweekday=[M.fromStr(e.byweekday).weekday],e.bynweekday=null;else if(e.byweekday instanceof M)!e.byweekday.n||e.freq>v.MONTHLY?(e.byweekday=[e.byweekday.weekday],e.bynweekday=null):(e.bynweekday=[[e.byweekday.weekday,e.byweekday.n]],e.byweekday=null);else{for(var a=[],o=[],t=0;t<e.byweekday.length;t++){var u=e.byweekday[t];if(N(u)){a.push(u);continue}else if(Ie(u)){a.push(M.fromStr(u).weekday);continue}!u.n||e.freq>v.MONTHLY?a.push(u.weekday):o.push([u.weekday,u.n])}e.byweekday=_(a)?a:null,e.bynweekday=_(o)?o:null}return S(e.byhour)?N(e.byhour)&&(e.byhour=[e.byhour]):e.byhour=e.freq<v.HOURLY?[e.dtstart.getUTCHours()]:null,S(e.byminute)?N(e.byminute)&&(e.byminute=[e.byminute]):e.byminute=e.freq<v.MINUTELY?[e.dtstart.getUTCMinutes()]:null,S(e.bysecond)?N(e.bysecond)&&(e.bysecond=[e.bysecond]):e.bysecond=e.freq<v.SECONDLY?[e.dtstart.getUTCSeconds()]:null,{parsedOptions:e}}function Rt(r){var e=r.dtstart.getTime()%1e3;if(!ke(r.freq))return[];var t=[];return r.byhour.forEach(function(n){r.byminute.forEach(function(i){r.bysecond.forEach(function(s){t.push(new re(n,i,s,e))})})}),t}function ye(r){var e=r.split(`
|
|
2
|
+
`).map(Lt).filter(function(t){return t!==null});return U(U({},e[0]),e[1])}function ne(r){var e={},t=/DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)/i.exec(r);if(!t)return e;var n=t[1],i=t[2];return n&&(e.tzid=n),e.dtstart=Te(i),e}function Lt(r){if(r=r.replace(/^\s+|\s+$/,""),!r.length)return null;var e=/^([A-Z]+?)[:;]/.exec(r.toUpperCase());if(!e)return Ue(r);var t=e[1];switch(t.toUpperCase()){case"RRULE":case"EXRULE":return Ue(r);case"DTSTART":return ne(r);default:throw new Error("Unsupported RFC prop ".concat(t," in ").concat(r))}}function Ue(r){var e=r.replace(/^RRULE:/i,""),t=ne(e),n=r.replace(/^(?:RRULE|EXRULE):/i,"").split(";");return n.forEach(function(i){var s=i.split("="),a=s[0],o=s[1];switch(a.toUpperCase()){case"FREQ":t.freq=T[o.toUpperCase()];break;case"WKST":t.wkst=L[o.toUpperCase()];break;case"COUNT":case"INTERVAL":case"BYSETPOS":case"BYMONTH":case"BYMONTHDAY":case"BYYEARDAY":case"BYWEEKNO":case"BYHOUR":case"BYMINUTE":case"BYSECOND":var u=Yt(o),c=a.toLowerCase();t[c]=u;break;case"BYWEEKDAY":case"BYDAY":t.byweekday=Nt(o);break;case"DTSTART":case"TZID":var d=ne(r);t.tzid=d.tzid,t.dtstart=d.dtstart;break;case"UNTIL":t.until=Te(o);break;case"BYEASTER":t.byeaster=Number(o);break;default:throw new Error("Unknown RRULE property '"+a+"'")}}),t}function Yt(r){if(r.indexOf(",")!==-1){var e=r.split(",");return e.map(Re)}return Re(r)}function Re(r){return/^[+-]?\d+$/.test(r)?Number(r):r}function Nt(r){var e=r.split(",");return e.map(function(t){if(t.length===2)return L[t];var n=t.match(/^([+-]?\d{1,2})([A-Z]{2})$/);if(!n||n.length<3)throw new SyntaxError("Invalid weekday string: ".concat(t));var i=Number(n[1]),s=n[2],a=L[s].weekday;return new M(a,i)})}var ie=(function(){function r(e,t){if(isNaN(e.getTime()))throw new RangeError("Invalid date passed to DateWithZone");this.date=e,this.tzid=t}return Object.defineProperty(r.prototype,"isUTC",{get:function(){return!this.tzid||this.tzid.toUpperCase()==="UTC"},enumerable:!1,configurable:!0}),r.prototype.toString=function(){var e=we(this.date.getTime(),this.isUTC);return this.isUTC?":".concat(e):";TZID=".concat(this.tzid,":").concat(e)},r.prototype.getTime=function(){return this.date.getTime()},r.prototype.rezonedDate=function(){return this.isUTC?this.date:St(this.date,this.tzid)},r})();function me(r){for(var e=[],t="",n=Object.keys(r),i=Object.keys(Se),s=0;s<n.length;s++)if(n[s]!=="tzid"&&k(i,n[s])){var a=n[s].toUpperCase(),o=r[n[s]],u="";if(!(!S(o)||A(o)&&!o.length)){switch(a){case"FREQ":u=v.FREQUENCIES[r.freq];break;case"WKST":N(o)?u=new M(o).toString():u=o.toString();break;case"BYWEEKDAY":a="BYDAY",u=bt(o).map(function(y){return y instanceof M?y:A(y)?new M(y[0],y[1]):new M(y)}).toString();break;case"DTSTART":t=Ct(o,r.tzid);break;case"UNTIL":u=we(o,!r.tzid);break;default:if(A(o)){for(var c=[],d=0;d<o.length;d++)c[d]=String(o[d]);u=c.toString()}else u=String(o)}u&&e.push([a,u])}}var h=e.map(function(y){var m=y[0],p=y[1];return"".concat(m,"=").concat(p.toString())}).join(";"),l="";return h!==""&&(l="RRULE:".concat(h)),[t,l].filter(function(y){return!!y}).join(`
|
|
3
|
+
`)}function Ct(r,e){return r?"DTSTART"+new ie(new Date(r),e).toString():""}function Wt(r,e){return Array.isArray(r)?!Array.isArray(e)||r.length!==e.length?!1:r.every(function(t,n){return t.getTime()===e[n].getTime()}):r instanceof Date?e instanceof Date&&r.getTime()===e.getTime():r===e}var zt=(function(){function r(){this.all=!1,this.before=[],this.after=[],this.between=[]}return r.prototype._cacheAdd=function(e,t,n){t&&(t=t instanceof Date?he(t):Oe(t)),e==="all"?this.all=t:(n._value=t,this[e].push(n))},r.prototype._cacheGet=function(e,t){var n=!1,i=t?Object.keys(t):[],s=function(d){for(var h=0;h<i.length;h++){var l=i[h];if(!Wt(t[l],d[l]))return!0}return!1},a=this[e];if(e==="all")n=this.all;else if(A(a))for(var o=0;o<a.length;o++){var u=a[o];if(!(i.length&&s(u))){n=u._value;break}}if(!n&&this.all){for(var c=new K(e,t),o=0;o<this.all.length&&c.accept(this.all[o]);o++);n=c.getValue(),this._cacheAdd(e,n,t)}return A(n)?Oe(n):n instanceof Date?he(n):n},r})(),Ht=f(f(f(f(f(f(f(f(f(f(f(f(f([],w(1,31),!0),w(2,28),!0),w(3,31),!0),w(4,30),!0),w(5,31),!0),w(6,30),!0),w(7,31),!0),w(8,31),!0),w(9,30),!0),w(10,31),!0),w(11,30),!0),w(12,31),!0),w(1,7),!0),Pt=f(f(f(f(f(f(f(f(f(f(f(f(f([],w(1,31),!0),w(2,29),!0),w(3,31),!0),w(4,30),!0),w(5,31),!0),w(6,30),!0),w(7,31),!0),w(8,31),!0),w(9,30),!0),w(10,31),!0),w(11,30),!0),w(12,31),!0),w(1,7),!0),jt=W(1,29),$t=W(1,30),j=W(1,31),O=W(1,32),Ft=f(f(f(f(f(f(f(f(f(f(f(f(f([],O,!0),$t,!0),O,!0),j,!0),O,!0),j,!0),O,!0),O,!0),j,!0),O,!0),j,!0),O,!0),O.slice(0,7),!0),Bt=f(f(f(f(f(f(f(f(f(f(f(f(f([],O,!0),jt,!0),O,!0),j,!0),O,!0),j,!0),O,!0),O,!0),j,!0),O,!0),j,!0),O,!0),O.slice(0,7),!0),Kt=W(-28,0),Zt=W(-29,0),$=W(-30,0),x=W(-31,0),qt=f(f(f(f(f(f(f(f(f(f(f(f(f([],x,!0),Zt,!0),x,!0),$,!0),x,!0),$,!0),x,!0),x,!0),$,!0),x,!0),$,!0),x,!0),x.slice(0,7),!0),Jt=f(f(f(f(f(f(f(f(f(f(f(f(f([],x,!0),Kt,!0),x,!0),$,!0),x,!0),$,!0),x,!0),x,!0),$,!0),x,!0),$,!0),x,!0),x.slice(0,7),!0),Gt=[0,31,60,91,121,152,182,213,244,274,305,335,366],Xt=[0,31,59,90,120,151,181,212,243,273,304,334,365],Le=(function(){for(var r=[],e=0;e<55;e++)r=r.concat(W(7));return r})();function Vt(r,e){var t=F(r,1,1),n=G(r)?366:365,i=G(r+1)?366:365,s=de(t),a=Z(t),o=U(U({yearlen:n,nextyearlen:i,yearordinal:s,yearweekday:a},Qt(r)),{wnomask:null});if(C(e.byweekno))return o;o.wnomask=w(0,n+7);var u,c,d=u=R(7-a+e.wkst,7);d>=4?(d=0,c=o.yearlen+R(a-e.wkst,7)):c=n-d;for(var h=Math.floor(c/7),l=R(c,7),y=Math.floor(h+l/4),m=0;m<e.byweekno.length;m++){var p=e.byweekno[m];if(p<0&&(p+=y+1),p>0&&p<=y){var b=void 0;p>1?(b=d+(p-1)*7,d!==u&&(b-=7-u)):b=d;for(var E=0;E<7&&(o.wnomask[b]=1,b++,o.wdaymask[b]!==e.wkst);E++);}}if(k(e.byweekno,1)){var b=d+y*7;if(d!==u&&(b-=7-u),b<n)for(var m=0;m<7&&(o.wnomask[b]=1,b+=1,o.wdaymask[b]!==e.wkst);m++);}if(d){var D=void 0;if(k(e.byweekno,-1))D=-1;else{var Y=Z(F(r-1,1,1)),z=R(7-Y.valueOf()+e.wkst,7),Q=G(r-1)?366:365,I=void 0;z>=4?(z=0,I=Q+R(Y-e.wkst,7)):I=n-d,D=Math.floor(52+R(I,7)/4)}if(k(e.byweekno,D))for(var b=0;b<d;b++)o.wnomask[b]=1}return o}function Qt(r){var e=G(r)?366:365,t=F(r,1,1),n=Z(t);return e===365?{mmask:Ht,mdaymask:Bt,nmdaymask:Jt,wdaymask:Le.slice(n),mrange:Xt}:{mmask:Pt,mdaymask:Ft,nmdaymask:qt,wdaymask:Le.slice(n),mrange:Gt}}function er(r,e,t,n,i,s){var a={lastyear:r,lastmonth:e,nwdaymask:[]},o=[];if(s.freq===v.YEARLY)if(C(s.bymonth))o=[[0,t]];else for(var u=0;u<s.bymonth.length;u++)e=s.bymonth[u],o.push(n.slice(e-1,e+1));else s.freq===v.MONTHLY&&(o=[n.slice(e-1,e+1)]);if(C(o))return a;a.nwdaymask=w(0,t);for(var u=0;u<o.length;u++)for(var c=o[u],d=c[0],h=c[1]-1,l=0;l<s.bynweekday.length;l++){var y=void 0,m=s.bynweekday[l],p=m[0],b=m[1];b<0?(y=h+(b+1)*7,y-=R(i[y]-p,7)):(y=d+(b-1)*7,y+=R(7-i[y]+p,7)),d<=y&&y<=h&&(a.nwdaymask[y]=1)}return a}function tr(r,e){e===void 0&&(e=0);var t=r%19,n=Math.floor(r/100),i=r%100,s=Math.floor(n/4),a=n%4,o=Math.floor((n+8)/25),u=Math.floor((n-o+1)/3),c=Math.floor(19*t+n-s-u+15)%30,d=Math.floor(i/4),h=i%4,l=Math.floor(32+2*a+2*d-c-h)%7,y=Math.floor((t+11*c+22*l)/451),m=Math.floor((c+l-7*y+114)/31),p=(c+l-7*y+114)%31+1,b=Date.UTC(r,m-1,p+e),E=Date.UTC(r,0,1);return[Math.ceil((b-E)/(1e3*60*60*24))]}var rr=(function(){function r(e){this.options=e}return r.prototype.rebuild=function(e,t){var n=this.options;if(e!==this.lastyear&&(this.yearinfo=Vt(e,n)),_(n.bynweekday)&&(t!==this.lastmonth||e!==this.lastyear)){var i=this.yearinfo,s=i.yearlen,a=i.mrange,o=i.wdaymask;this.monthinfo=er(e,t,s,a,o,n)}S(n.byeaster)&&(this.eastermask=tr(e,n.byeaster))},Object.defineProperty(r.prototype,"lastyear",{get:function(){return this.monthinfo?this.monthinfo.lastyear:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"lastmonth",{get:function(){return this.monthinfo?this.monthinfo.lastmonth:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"yearlen",{get:function(){return this.yearinfo.yearlen},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"yearordinal",{get:function(){return this.yearinfo.yearordinal},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mrange",{get:function(){return this.yearinfo.mrange},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"wdaymask",{get:function(){return this.yearinfo.wdaymask},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mmask",{get:function(){return this.yearinfo.mmask},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"wnomask",{get:function(){return this.yearinfo.wnomask},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"nwdaymask",{get:function(){return this.monthinfo?this.monthinfo.nwdaymask:[]},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"nextyearlen",{get:function(){return this.yearinfo.nextyearlen},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mdaymask",{get:function(){return this.yearinfo.mdaymask},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"nmdaymask",{get:function(){return this.yearinfo.nmdaymask},enumerable:!1,configurable:!0}),r.prototype.ydayset=function(){return[W(this.yearlen),0,this.yearlen]},r.prototype.mdayset=function(e,t){for(var n=this.mrange[t-1],i=this.mrange[t],s=w(null,this.yearlen),a=n;a<i;a++)s[a]=a;return[s,n,i]},r.prototype.wdayset=function(e,t,n){for(var i=w(null,this.yearlen+7),s=de(F(e,t,n))-this.yearordinal,a=s,o=0;o<7&&(i[s]=s,++s,this.wdaymask[s]!==this.options.wkst);o++);return[i,a,s]},r.prototype.ddayset=function(e,t,n){var i=w(null,this.yearlen),s=de(F(e,t,n))-this.yearordinal;return i[s]=s,[i,s,s+1]},r.prototype.htimeset=function(e,t,n,i){var s=this,a=[];return this.options.byminute.forEach(function(o){a=a.concat(s.mtimeset(e,o,n,i))}),V(a),a},r.prototype.mtimeset=function(e,t,n,i){var s=this.options.bysecond.map(function(a){return new re(e,t,a,i)});return V(s),s},r.prototype.stimeset=function(e,t,n,i){return[new re(e,t,n,i)]},r.prototype.getdayset=function(e){switch(e){case T.YEARLY:return this.ydayset.bind(this);case T.MONTHLY:return this.mdayset.bind(this);case T.WEEKLY:return this.wdayset.bind(this);case T.DAILY:return this.ddayset.bind(this);default:return this.ddayset.bind(this)}},r.prototype.gettimeset=function(e){switch(e){case T.HOURLY:return this.htimeset.bind(this);case T.MINUTELY:return this.mtimeset.bind(this);case T.SECONDLY:return this.stimeset.bind(this)}},r})();function nr(r,e,t,n,i,s){for(var a=[],o=0;o<r.length;o++){var u=void 0,c=void 0,d=r[o];d<0?(u=Math.floor(d/e.length),c=R(d,e.length)):(u=Math.floor((d-1)/e.length),c=R(d-1,e.length));for(var h=[],l=t;l<n;l++){var y=s[l];S(y)&&h.push(y)}var m=void 0;u<0?m=h.slice(u)[0]:m=h[u];var p=e[c],b=Ve(i.yearordinal+m),E=Qe(b,p);k(a,E)||a.push(E)}return V(a),a}function rt(r,e){var t=e.dtstart,n=e.freq,i=e.interval,s=e.until,a=e.bysetpos,o=e.count;if(o===0||i===0)return H(r);var u=At.fromDate(t),c=new rr(e);c.rebuild(u.year,u.month);for(var d=ar(c,u,e);;){var h=c.getdayset(n)(u.year,u.month,u.day),l=h[0],y=h[1],m=h[2],p=sr(l,y,m,c,e);if(_(a))for(var b=nr(a,d,y,m,c,l),E=0;E<b.length;E++){var D=b[E];if(s&&D>s)return H(r);if(D>=t){var Y=Ye(D,e);if(!r.accept(Y)||o&&(--o,!o))return H(r)}}else for(var E=y;E<m;E++){var z=l[E];if(S(z))for(var Q=Ve(c.yearordinal+z),I=0;I<d.length;I++){var it=d[I],D=Qe(Q,it);if(s&&D>s)return H(r);if(D>=t){var Y=Ye(D,e);if(!r.accept(Y)||o&&(--o,!o))return H(r)}}}if(e.interval===0||(u.add(e,p),u.year>Je))return H(r);ke(n)||(d=c.gettimeset(n)(u.hour,u.minute,u.second,0)),c.rebuild(u.year,u.month)}}function ir(r,e,t){var n=t.bymonth,i=t.byweekno,s=t.byweekday,a=t.byeaster,o=t.bymonthday,u=t.bynmonthday,c=t.byyearday;return _(n)&&!k(n,r.mmask[e])||_(i)&&!r.wnomask[e]||_(s)&&!k(s,r.wdaymask[e])||_(r.nwdaymask)&&!r.nwdaymask[e]||a!==null&&!k(r.eastermask,e)||(_(o)||_(u))&&!k(o,r.mdaymask[e])&&!k(u,r.nmdaymask[e])||_(c)&&(e<r.yearlen&&!k(c,e+1)&&!k(c,-r.yearlen+e)||e>=r.yearlen&&!k(c,e+1-r.yearlen)&&!k(c,-r.nextyearlen+e-r.yearlen))}function Ye(r,e){return new ie(r,e.tzid).rezonedDate()}function H(r){return r.getValue()}function sr(r,e,t,n,i){for(var s=!1,a=e;a<t;a++){var o=r[a];s=ir(n,o,i),s&&(r[o]=null)}return s}function ar(r,e,t){var n=t.freq,i=t.byhour,s=t.byminute,a=t.bysecond;return ke(n)?Rt(t):n>=v.HOURLY&&_(i)&&!k(i,e.hour)||n>=v.MINUTELY&&_(s)&&!k(s,e.minute)||n>=v.SECONDLY&&_(a)&&!k(a,e.second)?[]:r.gettimeset(n)(e.hour,e.minute,e.second,e.millisecond)}var L={MO:new M(0),TU:new M(1),WE:new M(2),TH:new M(3),FR:new M(4),SA:new M(5),SU:new M(6)},Se={freq:T.YEARLY,dtstart:null,interval:1,wkst:L.MO,count:null,until:null,tzid:null,bysetpos:null,bymonth:null,bymonthday:null,bynmonthday:null,byyearday:null,byweekno:null,byweekday:null,bynweekday:null,byhour:null,byminute:null,bysecond:null,byeaster:null},or=Object.keys(Se),v=(function(){function r(e,t){e===void 0&&(e={}),t===void 0&&(t=!1),this._cache=t?null:new zt,this.origOptions=tt(e);var n=Ut(e).parsedOptions;this.options=n}return r.parseText=function(e,t){return et(e,t)},r.fromText=function(e,t){return Ot(e,t)},r.fromString=function(e){return new r(r.parseString(e)||void 0)},r.prototype._iter=function(e){return rt(e,this.options)},r.prototype._cacheGet=function(e,t){return this._cache?this._cache._cacheGet(e,t):!1},r.prototype._cacheAdd=function(e,t,n){if(this._cache)return this._cache._cacheAdd(e,t,n)},r.prototype.all=function(e){if(e)return this._iter(new Me("all",{},e));var t=this._cacheGet("all");return t===!1&&(t=this._iter(new K("all",{})),this._cacheAdd("all",t)),t},r.prototype.between=function(e,t,n,i){if(n===void 0&&(n=!1),!J(e)||!J(t))throw new Error("Invalid date passed in to RRule.between");var s={before:t,after:e,inc:n};if(i)return this._iter(new Me("between",s,i));var a=this._cacheGet("between",s);return a===!1&&(a=this._iter(new K("between",s)),this._cacheAdd("between",a,s)),a},r.prototype.before=function(e,t){if(t===void 0&&(t=!1),!J(e))throw new Error("Invalid date passed in to RRule.before");var n={dt:e,inc:t},i=this._cacheGet("before",n);return i===!1&&(i=this._iter(new K("before",n)),this._cacheAdd("before",i,n)),i},r.prototype.after=function(e,t){if(t===void 0&&(t=!1),!J(e))throw new Error("Invalid date passed in to RRule.after");var n={dt:e,inc:t},i=this._cacheGet("after",n);return i===!1&&(i=this._iter(new K("after",n)),this._cacheAdd("after",i,n)),i},r.prototype.count=function(){return this.all().length},r.prototype.toString=function(){return me(this.origOptions)},r.prototype.toText=function(e,t,n){return xt(this,e,t,n)},r.prototype.isFullyConvertibleToText=function(){return Mt(this)},r.prototype.clone=function(){return new r(this.origOptions)},r.FREQUENCIES=["YEARLY","MONTHLY","WEEKLY","DAILY","HOURLY","MINUTELY","SECONDLY"],r.YEARLY=T.YEARLY,r.MONTHLY=T.MONTHLY,r.WEEKLY=T.WEEKLY,r.DAILY=T.DAILY,r.HOURLY=T.HOURLY,r.MINUTELY=T.MINUTELY,r.SECONDLY=T.SECONDLY,r.MO=L.MO,r.TU=L.TU,r.WE=L.WE,r.TH=L.TH,r.FR=L.FR,r.SA=L.SA,r.SU=L.SU,r.parseString=ye,r.optionsToString=me,r})();function ur(r,e,t,n,i,s){var a={},o=r.accept;function u(l,y){t.forEach(function(m){m.between(l,y,!0).forEach(function(p){a[Number(p)]=!0})})}i.forEach(function(l){var y=new ie(l,s).rezonedDate();a[Number(y)]=!0}),r.accept=function(l){var y=Number(l);return isNaN(y)?o.call(this,l):!a[y]&&(u(new Date(y-1),new Date(y+1)),!a[y])?(a[y]=!0,o.call(this,l)):!0},r.method==="between"&&(u(r.args.after,r.args.before),r.accept=function(l){var y=Number(l);return a[y]?!0:(a[y]=!0,o.call(this,l))});for(var c=0;c<n.length;c++){var d=new ie(n[c],s).rezonedDate();if(!r.accept(new Date(d.getTime())))break}e.forEach(function(l){rt(r,l.options)});var h=r._result;switch(V(h),r.method){case"all":case"between":return h;case"before":return h.length&&h[h.length-1]||null;default:return h.length&&h[0]||null}}var Ne={dtstart:null,cache:!1,unfold:!1,forceset:!1,compatible:!1,tzid:null};function cr(r,e){var t=[],n=[],i=[],s=[],a=ne(r),o=a.dtstart,u=a.tzid,c=yr(r,e.unfold);return c.forEach(function(d){var h;if(d){var l=fr(d),y=l.name,m=l.parms,p=l.value;switch(y.toUpperCase()){case"RRULE":if(m.length)throw new Error("unsupported RRULE parm: ".concat(m.join(",")));t.push(ye(d));break;case"RDATE":var b=(h=/RDATE(?:;TZID=([^:=]+))?/i.exec(d))!==null&&h!==void 0?h:[],E=b[1];E&&!u&&(u=E),n=n.concat(We(p,m));break;case"EXRULE":if(m.length)throw new Error("unsupported EXRULE parm: ".concat(m.join(",")));i.push(ye(p));break;case"EXDATE":s=s.concat(We(p,m));break;case"DTSTART":break;default:throw new Error("unsupported property: "+y)}}}),{dtstart:o,tzid:u,rrulevals:t,rdatevals:n,exrulevals:i,exdatevals:s}}function lr(r,e){var t=cr(r,e),n=t.rrulevals,i=t.rdatevals,s=t.exrulevals,a=t.exdatevals,o=t.dtstart,u=t.tzid,c=e.cache===!1;if(e.compatible&&(e.forceset=!0,e.unfold=!0),e.forceset||n.length>1||i.length||s.length||a.length){var d=new vr(c);return d.dtstart(o),d.tzid(u||void 0),n.forEach(function(l){d.rrule(new v(ae(l,o,u),c))}),i.forEach(function(l){d.rdate(l)}),s.forEach(function(l){d.exrule(new v(ae(l,o,u),c))}),a.forEach(function(l){d.exdate(l)}),e.compatible&&e.dtstart&&d.rdate(o),d}var h=n[0]||{};return new v(ae(h,h.dtstart||e.dtstart||o,h.tzid||e.tzid||u),c)}function Ce(r,e){return e===void 0&&(e={}),lr(r,dr(e))}function ae(r,e,t){return U(U({},r),{dtstart:e,tzid:t})}function dr(r){var e=[],t=Object.keys(r),n=Object.keys(Ne);if(t.forEach(function(i){k(n,i)||e.push(i)}),e.length)throw new Error("Invalid options: "+e.join(", "));return U(U({},Ne),r)}function hr(r){if(r.indexOf(":")===-1)return{name:"RRULE",value:r};var e=gt(r,":",1),t=e[0],n=e[1];return{name:t,value:n}}function fr(r){var e=hr(r),t=e.name,n=e.value,i=t.split(";");if(!i)throw new Error("empty property name");return{name:i[0].toUpperCase(),parms:i.slice(1),value:n}}function yr(r,e){if(e===void 0&&(e=!1),r=r&&r.trim(),!r)throw new Error("Invalid empty string");if(!e)return r.split(/\s/);for(var t=r.split(`
|
|
4
|
+
`),n=0;n<t.length;){var i=t[n]=t[n].replace(/\s+$/g,"");i?n>0&&i[0]===" "?(t[n-1]+=i.slice(1),t.splice(n,1)):n+=1:t.splice(n,1)}return t}function mr(r){r.forEach(function(e){if(!/(VALUE=DATE(-TIME)?)|(TZID=)/.test(e))throw new Error("unsupported RDATE/EXDATE parm: "+e)})}function We(r,e){return mr(e),r.split(",").map(function(t){return Te(t)})}function ze(r){var e=this;return function(t){if(t!==void 0&&(e["_".concat(r)]=t),e["_".concat(r)]!==void 0)return e["_".concat(r)];for(var n=0;n<e._rrule.length;n++){var i=e._rrule[n].origOptions[r];if(i)return i}}}var vr=(function(r){Ee(e,r);function e(t){t===void 0&&(t=!1);var n=r.call(this,{},t)||this;return n.dtstart=ze.apply(n,["dtstart"]),n.tzid=ze.apply(n,["tzid"]),n._rrule=[],n._rdate=[],n._exrule=[],n._exdate=[],n}return e.prototype._iter=function(t){return ur(t,this._rrule,this._exrule,this._rdate,this._exdate,this.tzid())},e.prototype.rrule=function(t){He(t,this._rrule)},e.prototype.exrule=function(t){He(t,this._exrule)},e.prototype.rdate=function(t){Pe(t,this._rdate)},e.prototype.exdate=function(t){Pe(t,this._exdate)},e.prototype.rrules=function(){return this._rrule.map(function(t){return Ce(t.toString())})},e.prototype.exrules=function(){return this._exrule.map(function(t){return Ce(t.toString())})},e.prototype.rdates=function(){return this._rdate.map(function(t){return new Date(t.getTime())})},e.prototype.exdates=function(){return this._exdate.map(function(t){return new Date(t.getTime())})},e.prototype.valueOf=function(){var t=[];return!this._rrule.length&&this._dtstart&&(t=t.concat(me({dtstart:this._dtstart}))),this._rrule.forEach(function(n){t=t.concat(n.toString().split(`
|
|
5
|
+
`))}),this._exrule.forEach(function(n){t=t.concat(n.toString().split(`
|
|
6
|
+
`).map(function(i){return i.replace(/^RRULE:/,"EXRULE:")}).filter(function(i){return!/^DTSTART/.test(i)}))}),this._rdate.length&&t.push(je("RDATE",this._rdate,this.tzid())),this._exdate.length&&t.push(je("EXDATE",this._exdate,this.tzid())),t},e.prototype.toString=function(){return this.valueOf().join(`
|
|
7
|
+
`)},e.prototype.clone=function(){var t=new e(!!this._cache);return this._rrule.forEach(function(n){return t.rrule(n.clone())}),this._exrule.forEach(function(n){return t.exrule(n.clone())}),this._rdate.forEach(function(n){return t.rdate(new Date(n.getTime()))}),this._exdate.forEach(function(n){return t.exdate(new Date(n.getTime()))}),t},e})(v);function He(r,e){if(!(r instanceof v))throw new TypeError(String(r)+" is not RRule instance");k(e.map(String),String(r))||e.push(r)}function Pe(r,e){if(!(r instanceof Date))throw new TypeError(String(r)+" is not Date instance");k(e.map(Number),Number(r))||(e.push(r),V(e))}function je(r,e,t){var n=!t||t.toUpperCase()==="UTC",i=n?"".concat(r,":"):"".concat(r,";TZID=").concat(t,":"),s=e.map(function(a){return we(a.valueOf(),n)}).join(",");return"".concat(i).concat(s)}function ve(r,e,t){const n=[];for(const i of r){if(!i.recurrenceRule){n.push({id:i.id,title:i.title,startTime:i.startTime,endTime:i.endTime,resourceId:i.resourceId,resourceIds:i.resourceIds,status:i.status,description:i.description,color:i.color,allDay:i.allDay});continue}try{const s=new Date(e),a=new Date(t),o=v.parseString(i.recurrenceRule);o.dtstart=new Date(i.startTime);const c=new v(o).between(s,a,!0),d=new Date(i.endTime).getTime()-new Date(i.startTime).getTime();for(const h of c){const l=h.getTime(),y=l+d;n.push({id:`${i.id}_occ_${l}`,title:i.title,startTime:new Date(l).toISOString(),endTime:new Date(y).toISOString(),resourceId:i.resourceId,resourceIds:i.resourceIds,status:i.status,description:i.description,color:i.color,allDay:i.allDay,recurrenceRule:i.recurrenceRule})}}catch(s){console.error(`Failed to expand recurrence rule for event ${i.id}:`,s),n.push({id:i.id,title:i.title,startTime:i.startTime,endTime:i.endTime,resourceId:i.resourceId,resourceIds:i.resourceIds,status:i.status,description:i.description,color:i.color,allDay:i.allDay})}}return n}function pe(r,e,t=50){const n=new Set,i=new Set;if(!r.events||r.events.length<=1)return{conflictingEventIds:n,messages:[]};const s=[...r.events].sort((a,o)=>a.startMs-o.startMs);for(let a=0;a<s.length;a++){const o=s[a];for(let u=a+1;u<s.length;u++){const c=s[u];if(c.startMs>=o.endMs)break;if(n.add(o.id),n.add(c.id),i.size<t){const d=Math.max(o.startMs,c.startMs),h=Math.min(o.endMs,c.endMs),{dateLabel:l,startTimeLabel:y,endTimeLabel:m}=nt(new Date(d).toISOString(),new Date(h).toISOString(),e),p=`Conflict: ${r.name} has overlapping events "${o.title}" and "${c.title}" on ${l} between ${y} and ${m}.`;i.add(p)}}}return{conflictingEventIds:n,messages:Array.from(i)}}function pr(r,e){const t=new Set,n=new Set;for(const i of r)if(n.size>=50&&t.size>0){const s=pe(i,e,0);for(const a of s.conflictingEventIds)t.add(a)}else{const s=pe(i,e,Math.max(0,50-n.size));for(const a of s.conflictingEventIds)t.add(a);for(const a of s.messages)n.size<50&&n.add(a)}return{hasConflict:t.size>0,messages:Array.from(n),conflictingEventIds:t}}function br(r,e,t,n){const i=n?n.replace(/_occ_\d+$/,""):null;for(const s of r)if(!(i&&s.id.replace(/_occ_\d+$/,"")===i)&&e<s.endMs&&t>s.startMs)return!0;return!1}function gr(r,e,t){if(!r.title||r.participants.length===0)return{hasConflict:!1,message:"",resourceIds:[]};const n=new Date(r.startDate+"T00:00:00").getTime();let i=new Date(r.endDate+"T23:59:59").getTime();if(r.recurrenceRule){let c=n+31536e6;const d=r.recurrenceRule.match(/UNTIL=([0-9T]+)/);if(d){const h=d[1],l=h.slice(0,4),y=h.slice(4,6),m=h.slice(6,8),p=new Date(`${l}-${y}-${m}T23:59:59`).getTime();isNaN(p)||(c=p)}i=c}let s;try{const c=ce(r.startDate,r.startTime,t),d=ce(r.endDate,r.endTime,t),h=new ee({id:"draft",title:r.title,startTime:c,endTime:d,resourceIds:r.participants,allDay:r.allDay,recurrenceRule:r.recurrenceRule});s=ve([h],n,i)}catch{return{hasConflict:!1,message:"",resourceIds:[]}}if(s.length===0)return{hasConflict:!1,message:"",resourceIds:[]};const a=r.id?r.id.replace(/_occ_\d+$/,""):null,o=e.filter(c=>c.id.replace(/_occ_\d+$/,"")!==a),u=ve(o,n,i);for(const c of s){const d=new Date(c.startTime).getTime(),h=new Date(c.endTime).getTime();for(const l of u){const y=new Date(l.startTime).getTime(),m=new Date(l.endTime).getTime();if(d<m&&h>y){const p=c.resourceIds||(c.resourceId?[c.resourceId]:[]),b=l.resourceIds||(l.resourceId?[l.resourceId]:[]),E=p.filter(D=>b.includes(D));if(E.length>0){const{dateLabel:D,startTimeLabel:Y,endTimeLabel:z}=nt(l.startTime,l.endTime,t);return{hasConflict:!0,message:`Conflict: [REPLACE_RESOURCES] already scheduled on ${D} between ${Y} and ${z} in "${l.title}".`,resourceIds:E}}}}}return{hasConflict:!1,message:"",resourceIds:[]}}function nt(r,e,t){const{date:n,time:i}=ue(r,t),{time:s}=ue(e,t),[,a,o]=n.split("-"),u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=parseInt(a,10)-1,d=c>=0&&c<12?`${u[c]} ${parseInt(o,10)}`:n,h=l=>{if(!l)return"";const[y,m]=l.split(":").map(Number);return`${y%12||12}:${String(m).padStart(2,"0")} ${y>=12?"PM":"AM"}`};return{dateLabel:d,startTimeLabel:h(i),endTimeLabel:h(s)}}exports.Assignment=$e;exports.Event=ee;exports.JanusEventBus=Ze;exports.Resource=oe;exports.SchedulerManager=vt;exports.checkDraftConflict=gr;exports.checkSlotConflict=br;exports.computeSingleResourceConflicts=pe;exports.computeTimelineConflicts=pr;exports.expandEvents=ve;exports.formatTimezoneLabel=lt;exports.getAllTimezones=dt;exports.getBrowserTimezone=Fe;exports.getUtcMsForZonedDatetime=Ke;exports.isoToZonedDisplay=ue;exports.janusEventBus=pt;exports.schedulerStore=g;exports.toFakeLocalDate=ct;exports.zonedInputToISO=ce;
|
|
8
|
+
//# sourceMappingURL=janus-scheduler.cjs.map
|