@mintplayer/web-components 2.3.0 → 2.4.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.
@@ -0,0 +1,899 @@
1
+ function p(u) {
2
+ return "events" in u || !("children" in u);
3
+ }
4
+ function f(u) {
5
+ return "children" in u;
6
+ }
7
+ const w = {
8
+ navLabel: "Scheduler navigation",
9
+ previousPeriod: "Previous period",
10
+ nextPeriod: "Next period",
11
+ jumpToToday: "Jump to today",
12
+ today: "Today",
13
+ switchView: "Switch view",
14
+ viewYear: "Year",
15
+ viewMonth: "Month",
16
+ viewWeek: "Week",
17
+ viewDay: "Day",
18
+ viewTimeline: "Timeline",
19
+ resourcesHeader: "Resources",
20
+ timelineGridLabel: "Resource timeline for week starting {date}",
21
+ expandGroup: "Expand {title}",
22
+ collapseGroup: "Collapse {title}",
23
+ moreEvents: "+{count} more",
24
+ viewChanged: "View changed to {view}.",
25
+ eventAdded: "Event {title} added.",
26
+ eventUpdated: "Event {title} updated.",
27
+ eventRemoved: "Event {title} removed.",
28
+ loadingEvents: "Loading events.",
29
+ eventsLoaded: "Events loaded.",
30
+ moveModeEntered: "Move mode for {title}. Arrow keys nudge by {minutes} minutes; Shift with arrow keys resizes the end edge; Alt with Shift resizes the start edge; Enter commits, Escape cancels.",
31
+ movedTo: "Moved to {start}–{end}, {day}",
32
+ movedToResource: "Moved to resource {resource}.",
33
+ resizedEdge: "Resized {edge} edge to {start}–{end}",
34
+ startEdge: "start",
35
+ endEdge: "end",
36
+ moveCommitted: "Move committed.",
37
+ moveCancelled: "Move cancelled.",
38
+ selection: "Selection: {start} to {end}, {count} {slots}",
39
+ slotSingular: "slot",
40
+ slotPlural: "slots",
41
+ selectionCommitted: "Selection committed: {start}–{end}.",
42
+ gridInstructions: "Use the arrow keys to move between cells. Hold Shift with the arrow keys to extend the selection, and press Enter to request a new event for the selection. Page Up and Page Down change the period. Alt with T, Y, M, W or D switches to today, year, month, week or day view.",
43
+ eventInstructions: "Press Enter or M to move or resize the event with the arrow keys. Delete removes the event. Left and Right arrows move between events.",
44
+ eventOnResource: "on {resource}"
45
+ };
46
+ function b(u, e) {
47
+ return e ? u.replace(
48
+ /\{(\w+)\}/g,
49
+ (t, n) => n in e ? String(e[n]) : t
50
+ ) : u;
51
+ }
52
+ function I(u) {
53
+ return u ? { ...w, ...u } : w;
54
+ }
55
+ const R = {
56
+ initialView: "week",
57
+ initialDate: /* @__PURE__ */ new Date(),
58
+ locale: "en-US",
59
+ firstDayOfWeek: 1,
60
+ timeZone: "local",
61
+ slotDuration: 1800,
62
+ slotLabelInterval: 3600,
63
+ slotMinTime: "00:00:00",
64
+ slotMaxTime: "24:00:00",
65
+ timeFormat: "24h",
66
+ businessHours: {
67
+ daysOfWeek: [1, 2, 3, 4, 5],
68
+ startTime: "09:00",
69
+ endTime: "17:00"
70
+ },
71
+ height: "auto",
72
+ contentHeight: "auto",
73
+ aspectRatio: 1.35,
74
+ expandRows: !1,
75
+ headerToolbar: {
76
+ start: "prev,next today",
77
+ center: "title",
78
+ end: "year,month,week,day,timeline"
79
+ },
80
+ editable: !0,
81
+ selectable: !0,
82
+ selectMirror: !0,
83
+ eventDurationEditable: !0,
84
+ eventStartEditable: !0,
85
+ dragRevertDuration: 500,
86
+ dragScroll: !0,
87
+ snapDuration: 1800,
88
+ messages: w,
89
+ nowIndicator: !0,
90
+ weekNumbers: !1,
91
+ weekText: "W",
92
+ dayMaxEvents: !0
93
+ };
94
+ class T {
95
+ /**
96
+ * Get the start of the week for a given date
97
+ */
98
+ getWeekStart(e, t = 1) {
99
+ const n = new Date(e), s = n.getDay(), r = (s < t ? 7 : 0) + s - t;
100
+ return n.setDate(n.getDate() - r), n.setHours(0, 0, 0, 0), n;
101
+ }
102
+ /**
103
+ * Get all days in a week starting from a given date
104
+ */
105
+ getWeekDays(e, t = 1) {
106
+ const n = this.getWeekStart(e, t), s = [];
107
+ for (let r = 0; r < 7; r++) {
108
+ const o = new Date(n);
109
+ o.setDate(n.getDate() + r), s.push(o);
110
+ }
111
+ return s;
112
+ }
113
+ /**
114
+ * Get the start of the month for a given date
115
+ */
116
+ getMonthStart(e) {
117
+ return new Date(e.getFullYear(), e.getMonth(), 1, 0, 0, 0, 0);
118
+ }
119
+ /**
120
+ * Get the end of the month for a given date
121
+ */
122
+ getMonthEnd(e) {
123
+ return new Date(e.getFullYear(), e.getMonth() + 1, 0, 23, 59, 59, 999);
124
+ }
125
+ /**
126
+ * Get all days in a month
127
+ */
128
+ getMonthDays(e) {
129
+ const t = this.getMonthStart(e), n = this.getMonthEnd(e), s = [], r = new Date(t);
130
+ for (; r <= n; )
131
+ s.push(new Date(r)), r.setDate(r.getDate() + 1);
132
+ return s;
133
+ }
134
+ /**
135
+ * Get weeks for a month view (includes days from adjacent months)
136
+ */
137
+ getMonthWeeks(e, t = 1) {
138
+ const n = this.getMonthStart(e), s = this.getMonthEnd(e), r = this.getWeekStart(n, t), o = [];
139
+ let a = new Date(r);
140
+ for (let i = 0; i < 6; i++) {
141
+ const c = [];
142
+ for (let d = 0; d < 7; d++)
143
+ c.push(new Date(a)), a.setDate(a.getDate() + 1);
144
+ if (o.push(c), a > s && o.length >= 4)
145
+ break;
146
+ }
147
+ return o;
148
+ }
149
+ /**
150
+ * Get the start of the year for a given date
151
+ */
152
+ getYearStart(e) {
153
+ return new Date(e.getFullYear(), 0, 1, 0, 0, 0, 0);
154
+ }
155
+ /**
156
+ * Get all months in a year
157
+ */
158
+ getYearMonths(e) {
159
+ const t = [];
160
+ for (let n = 0; n < 12; n++)
161
+ t.push(new Date(e.getFullYear(), n, 1));
162
+ return t;
163
+ }
164
+ /**
165
+ * Get time slots for a day
166
+ */
167
+ getTimeSlots(e, t = 1800, n = "00:00:00", s = "24:00:00") {
168
+ const r = [], [o, a] = n.split(":").map(Number), [i, c] = s.split(":").map(Number), d = o * 3600 + a * 60, l = i * 3600 + c * 60;
169
+ for (let h = d; h < l; h += t) {
170
+ const g = new Date(e);
171
+ g.setHours(0, 0, 0, 0), g.setSeconds(h);
172
+ const m = new Date(g);
173
+ m.setSeconds(g.getSeconds() + t), r.push({ start: g, end: m });
174
+ }
175
+ return r;
176
+ }
177
+ /**
178
+ * Generate a scheduler grid for week view
179
+ */
180
+ getWeekGrid(e, t = 1, n = 1800, s = "00:00:00", r = "24:00:00", o = "24h") {
181
+ const a = this.getWeekDays(e, t), i = [], c = [], d = this.getTimeSlots(a[0], n, s, r);
182
+ for (const l of d) {
183
+ const h = [];
184
+ for (const g of a) {
185
+ const m = new Date(g);
186
+ m.setHours(l.start.getHours(), l.start.getMinutes(), 0, 0);
187
+ const D = new Date(g);
188
+ D.setHours(l.end.getHours(), l.end.getMinutes(), 0, 0);
189
+ const S = { start: m, end: D };
190
+ h.push(S), c.push(S);
191
+ }
192
+ i.push({
193
+ time: l.start,
194
+ label: this.formatTime(l.start, o),
195
+ slots: h
196
+ });
197
+ }
198
+ return { columns: a, rows: i, allSlots: c };
199
+ }
200
+ /**
201
+ * Round a date to the nearest slot
202
+ */
203
+ roundToSlot(e, t) {
204
+ const n = e.getTime(), s = t * 1e3, r = Math.round(n / s) * s;
205
+ return new Date(r);
206
+ }
207
+ /**
208
+ * Floor a date to the slot start
209
+ */
210
+ floorToSlot(e, t) {
211
+ const n = e.getTime(), s = t * 1e3, r = Math.floor(n / s) * s;
212
+ return new Date(r);
213
+ }
214
+ /**
215
+ * Ceiling a date to the slot end
216
+ */
217
+ ceilToSlot(e, t) {
218
+ const n = e.getTime(), s = t * 1e3, r = Math.ceil(n / s) * s;
219
+ return new Date(r);
220
+ }
221
+ /**
222
+ * Detect time format preference based on locale
223
+ * Uses the Intl API to determine if the locale uses 12-hour or 24-hour time
224
+ */
225
+ detectTimeFormat(e) {
226
+ const t = e || (typeof navigator < "u" ? navigator.language : "en-US");
227
+ try {
228
+ return new Intl.DateTimeFormat(t, { hour: "numeric" }).resolvedOptions().hour12 ? "12h" : "24h";
229
+ } catch {
230
+ return "24h";
231
+ }
232
+ }
233
+ /**
234
+ * Format time according to format preference
235
+ */
236
+ formatTime(e, t = "24h") {
237
+ const n = e.getHours(), s = e.getMinutes();
238
+ if (t === "12h") {
239
+ const r = n >= 12 ? "PM" : "AM";
240
+ return `${n % 12 || 12}:${s.toString().padStart(2, "0")} ${r}`;
241
+ }
242
+ return `${n.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`;
243
+ }
244
+ /**
245
+ * Format date for display
246
+ */
247
+ formatDate(e, t = "en-US", n) {
248
+ return e.toLocaleDateString(t, n);
249
+ }
250
+ /**
251
+ * Format date with weekday
252
+ */
253
+ formatDateWithWeekday(e, t = "en-US") {
254
+ return this.formatDate(e, t, { weekday: "short", month: "short", day: "numeric" });
255
+ }
256
+ /**
257
+ * Get month name
258
+ */
259
+ getMonthName(e, t = "en-US", n = "long") {
260
+ return e.toLocaleDateString(t, { month: n });
261
+ }
262
+ /**
263
+ * Get day name
264
+ */
265
+ getDayName(e, t = "en-US", n = "short") {
266
+ return e.toLocaleDateString(t, { weekday: n });
267
+ }
268
+ /**
269
+ * Check if two dates are the same day
270
+ */
271
+ isSameDay(e, t) {
272
+ return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
273
+ }
274
+ /**
275
+ * Check if two dates are the same month
276
+ */
277
+ isSameMonth(e, t) {
278
+ return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth();
279
+ }
280
+ /**
281
+ * Check if a date is today
282
+ */
283
+ isToday(e) {
284
+ return this.isSameDay(e, /* @__PURE__ */ new Date());
285
+ }
286
+ /**
287
+ * Check if a date is in the past
288
+ */
289
+ isPast(e) {
290
+ const t = /* @__PURE__ */ new Date();
291
+ t.setHours(0, 0, 0, 0);
292
+ const n = new Date(e);
293
+ return n.setHours(0, 0, 0, 0), n < t;
294
+ }
295
+ /**
296
+ * Check if a date falls within a range
297
+ */
298
+ isInRange(e, t, n) {
299
+ return e >= t && e <= n;
300
+ }
301
+ /**
302
+ * Get the number of days between two dates
303
+ */
304
+ getDaysDifference(e, t) {
305
+ const n = new Date(e);
306
+ n.setHours(0, 0, 0, 0);
307
+ const s = new Date(t);
308
+ return s.setHours(0, 0, 0, 0), Math.round((s.getTime() - n.getTime()) / (1e3 * 60 * 60 * 24));
309
+ }
310
+ /**
311
+ * Add days to a date
312
+ */
313
+ addDays(e, t) {
314
+ const n = new Date(e);
315
+ return n.setDate(n.getDate() + t), n;
316
+ }
317
+ /**
318
+ * Add weeks to a date
319
+ */
320
+ addWeeks(e, t) {
321
+ return this.addDays(e, t * 7);
322
+ }
323
+ /**
324
+ * Add months to a date
325
+ */
326
+ addMonths(e, t) {
327
+ const n = new Date(e);
328
+ return n.setMonth(n.getMonth() + t), n;
329
+ }
330
+ /**
331
+ * Add years to a date
332
+ */
333
+ addYears(e, t) {
334
+ const n = new Date(e);
335
+ return n.setFullYear(n.getFullYear() + t), n;
336
+ }
337
+ /**
338
+ * Get week number of the year
339
+ */
340
+ getWeekNumber(e) {
341
+ const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())), n = t.getUTCDay() || 7;
342
+ t.setUTCDate(t.getUTCDate() + 4 - n);
343
+ const s = new Date(Date.UTC(t.getUTCFullYear(), 0, 1));
344
+ return Math.ceil(((t.getTime() - s.getTime()) / 864e5 + 1) / 7);
345
+ }
346
+ /**
347
+ * Get seconds from midnight for a date
348
+ */
349
+ getSecondsFromMidnight(e) {
350
+ return e.getHours() * 3600 + e.getMinutes() * 60 + e.getSeconds();
351
+ }
352
+ /**
353
+ * Get duration in seconds between two dates
354
+ */
355
+ getDurationInSeconds(e, t) {
356
+ return Math.round((t.getTime() - e.getTime()) / 1e3);
357
+ }
358
+ }
359
+ const y = new T();
360
+ class E {
361
+ /**
362
+ * Split an event into daily parts
363
+ * Each part represents one day of a multi-day event
364
+ */
365
+ splitInParts(e) {
366
+ const t = [];
367
+ let n = new Date(e.start), s = 0;
368
+ const r = this.getTotalDays(e.start, e.end);
369
+ if (y.isSameDay(e.start, e.end)) {
370
+ const o = "id" in e;
371
+ return t.push({
372
+ id: o ? `${e.id}-0` : "preview-0",
373
+ event: o ? e : null,
374
+ start: e.start,
375
+ end: e.end,
376
+ isStart: !0,
377
+ isEnd: !0,
378
+ dayIndex: 0,
379
+ totalDays: 1
380
+ }), {
381
+ event: o ? e : null,
382
+ parts: t
383
+ };
384
+ }
385
+ for (; !y.isSameDay(n, e.end); ) {
386
+ const o = new Date(n);
387
+ o.setDate(o.getDate() + 1), o.setHours(0, 0, 0, 0);
388
+ const a = "id" in e;
389
+ t.push({
390
+ id: a ? `${e.id}-${s}` : `preview-${s}`,
391
+ event: a ? e : null,
392
+ start: new Date(n),
393
+ end: o,
394
+ isStart: s === 0,
395
+ isEnd: !1,
396
+ dayIndex: s,
397
+ totalDays: r
398
+ }), n = o, s++;
399
+ }
400
+ if (e.end.getHours() !== 0 || e.end.getMinutes() !== 0 || e.end.getSeconds() !== 0) {
401
+ const o = "id" in e;
402
+ t.push({
403
+ id: o ? `${e.id}-${s}` : `preview-${s}`,
404
+ event: o ? e : null,
405
+ start: new Date(n),
406
+ end: e.end,
407
+ isStart: !1,
408
+ isEnd: !0,
409
+ dayIndex: s,
410
+ totalDays: r
411
+ });
412
+ }
413
+ return {
414
+ event: "id" in e ? e : null,
415
+ parts: t
416
+ };
417
+ }
418
+ /**
419
+ * Calculate total days an event spans
420
+ */
421
+ getTotalDays(e, t) {
422
+ const n = new Date(e);
423
+ n.setHours(0, 0, 0, 0);
424
+ const s = new Date(t);
425
+ s.setHours(0, 0, 0, 0);
426
+ const r = s.getTime() - n.getTime(), o = Math.ceil(r / (1e3 * 60 * 60 * 24));
427
+ return t.getHours() !== 0 || t.getMinutes() !== 0 || t.getSeconds() !== 0 ? o + 1 : Math.max(1, o);
428
+ }
429
+ /**
430
+ * Assign events to tracks (rails) to minimize overlapping
431
+ * This method should be called when events are updated, NOT during drag operations
432
+ */
433
+ getTimeline(e) {
434
+ if (e.length === 0)
435
+ return [];
436
+ const t = this.getUniqueTimestamps(e), n = [];
437
+ for (const s of t) {
438
+ const r = e.filter((o) => o.start.getTime() === s.getTime());
439
+ for (const o of r) {
440
+ const a = n.find((i) => this.isTrackFreeForEvent(i, o));
441
+ a ? a.events.push(o) : n.push({
442
+ index: n.length,
443
+ events: [o]
444
+ });
445
+ }
446
+ }
447
+ return n;
448
+ }
449
+ /**
450
+ * Get track assignment for event parts using colspan algorithm (for rendering)
451
+ *
452
+ * This uses a colspan-based algorithm similar to Outlook/Google Calendar:
453
+ * 1. Build overlap groups (connected components of overlapping events)
454
+ * 2. Assign columns within each group using a greedy algorithm
455
+ * 3. Compute colspan - how many columns each event can span
456
+ *
457
+ * This ensures events are displayed as wide as possible:
458
+ * - An event with no overlapping events gets 100% width
459
+ * - Events only share space with events they actually overlap with
460
+ * - An event can span multiple columns if there's no blocking event to its right
461
+ */
462
+ getTimelinedParts(e) {
463
+ const t = /* @__PURE__ */ new Map();
464
+ for (const r of e)
465
+ r.event && !t.has(r.event.id) && t.set(r.event.id, r.event);
466
+ const n = Array.from(t.values()), s = this.getColspanLayout(n);
467
+ return e.map((r) => {
468
+ if (!r.event)
469
+ return { part: r, trackIndex: 0, totalTracks: 1, colspan: 1 };
470
+ const o = s.get(r.event.id);
471
+ return o ? {
472
+ part: r,
473
+ trackIndex: o.col,
474
+ totalTracks: o.columnCount,
475
+ colspan: o.colspan
476
+ } : { part: r, trackIndex: 0, totalTracks: 1, colspan: 1 };
477
+ });
478
+ }
479
+ /**
480
+ * Compute colspan-based layout for events (Outlook/Google Calendar algorithm)
481
+ *
482
+ * Phase 1: Build overlap groups (connected components)
483
+ * Phase 2: Assign columns within each group
484
+ * Phase 3: Compute colspan for each event
485
+ */
486
+ getColspanLayout(e) {
487
+ const t = /* @__PURE__ */ new Map();
488
+ if (e.length === 0)
489
+ return t;
490
+ const n = this.buildOverlapGroups(e);
491
+ for (const s of n) {
492
+ const { assignments: r, columnCount: o } = this.assignColumns(s);
493
+ for (const a of s) {
494
+ const i = r.get(a.id) ?? 0, c = this.computeColspan(a, i, s, r, o);
495
+ t.set(a.id, {
496
+ col: i,
497
+ colspan: c,
498
+ columnCount: o
499
+ });
500
+ }
501
+ }
502
+ return t;
503
+ }
504
+ /**
505
+ * Build overlap groups (connected components)
506
+ * Events belong to the same group if they overlap directly or indirectly
507
+ *
508
+ * Optimized to reduce comparisons by pre-sorting events by start time
509
+ * and breaking early when events can no longer overlap
510
+ */
511
+ buildOverlapGroups(e) {
512
+ if (e.length === 0) return [];
513
+ const t = [], n = /* @__PURE__ */ new Set(), s = [...e].sort((r, o) => r.start.getTime() - o.start.getTime());
514
+ for (const r of s) {
515
+ if (n.has(r.id)) continue;
516
+ const o = [], a = [r];
517
+ let i = 0;
518
+ for (; i < a.length; ) {
519
+ const c = a[i++];
520
+ if (n.has(c.id)) continue;
521
+ n.add(c.id), o.push(c);
522
+ const d = c.end.getTime();
523
+ for (const l of s)
524
+ if (!n.has(l.id)) {
525
+ if (l.start.getTime() >= d) break;
526
+ this.eventsOverlap(c, l) && a.push(l);
527
+ }
528
+ }
529
+ t.push(o);
530
+ }
531
+ return t;
532
+ }
533
+ /**
534
+ * Assign columns to events within an overlap group
535
+ * Uses a greedy algorithm: place each event in the first available column
536
+ * Returns the column assignments and total column count
537
+ */
538
+ assignColumns(e) {
539
+ const t = /* @__PURE__ */ new Map(), n = [...e].sort(
540
+ (r, o) => r.start.getTime() - o.start.getTime() || r.end.getTime() - o.end.getTime() || r.id.localeCompare(o.id)
541
+ ), s = [];
542
+ for (const r of n) {
543
+ let o = -1;
544
+ for (let a = 0; a < s.length; a++)
545
+ if (s[a] <= r.start.getTime()) {
546
+ o = a;
547
+ break;
548
+ }
549
+ o === -1 ? (o = s.length, s.push(r.end.getTime())) : s[o] = r.end.getTime(), t.set(r.id, o);
550
+ }
551
+ return { assignments: t, columnCount: s.length };
552
+ }
553
+ /**
554
+ * Compute colspan for an event
555
+ * An event can span multiple columns if there's no overlapping event to its right
556
+ */
557
+ computeColspan(e, t, n, s, r) {
558
+ let o = 1 / 0;
559
+ for (const a of n) {
560
+ if (a.id === e.id || !this.eventsOverlap(e, a)) continue;
561
+ const i = s.get(a.id) ?? 0;
562
+ i > t && (o = Math.min(o, i));
563
+ }
564
+ return o !== 1 / 0 ? o - t : r - t;
565
+ }
566
+ /**
567
+ * Check if two events overlap in time
568
+ */
569
+ eventsOverlap(e, t) {
570
+ return e.start < t.end && t.start < e.end;
571
+ }
572
+ /**
573
+ * Calculate the relative track position for an event part (legacy method)
574
+ * @deprecated Use getColspanLayout instead for better layout
575
+ */
576
+ getRelativeTrackPosition(e, t, n) {
577
+ const s = [];
578
+ for (const o of e)
579
+ o.events.some(
580
+ (i) => i.start < t.end && i.end > t.start
581
+ ) && s.push(o.index);
582
+ s.sort((o, a) => o - a);
583
+ const r = s.indexOf(n);
584
+ return {
585
+ relativeIndex: r >= 0 ? r : 0,
586
+ overlappingCount: Math.max(1, s.length)
587
+ };
588
+ }
589
+ /**
590
+ * Filter events that fall within a date range
591
+ */
592
+ filterByRange(e, t, n) {
593
+ return e.filter((s) => s.start < n && s.end > t);
594
+ }
595
+ /**
596
+ * Filter event parts that fall within a date range
597
+ */
598
+ filterPartsByRange(e, t, n) {
599
+ return e.filter((s) => s.start < n && s.end > t);
600
+ }
601
+ /**
602
+ * Get all unique timestamps from events (both start and end times)
603
+ */
604
+ getUniqueTimestamps(e) {
605
+ const t = /* @__PURE__ */ new Set();
606
+ for (const n of e)
607
+ t.add(n.start.getTime()), t.add(n.end.getTime());
608
+ return Array.from(t).sort((n, s) => n - s).map((n) => new Date(n));
609
+ }
610
+ /**
611
+ * Check if a track has space for an event (no overlapping)
612
+ */
613
+ isTrackFreeForEvent(e, t) {
614
+ return e.events.every((n) => n.end <= t.start || t.end <= n.start);
615
+ }
616
+ /**
617
+ * Get events for a specific day
618
+ */
619
+ getEventsForDay(e, t) {
620
+ const n = new Date(t);
621
+ n.setHours(0, 0, 0, 0);
622
+ const s = new Date(t);
623
+ return s.setHours(23, 59, 59, 999), this.filterByRange(e, n, s);
624
+ }
625
+ /**
626
+ * Get event parts for a specific day
627
+ */
628
+ getPartsForDay(e, t) {
629
+ const n = new Date(t);
630
+ n.setHours(0, 0, 0, 0);
631
+ const s = new Date(t);
632
+ return s.setHours(23, 59, 59, 999), this.filterPartsByRange(e, n, s);
633
+ }
634
+ }
635
+ const x = new E();
636
+ class k {
637
+ /**
638
+ * Flatten a hierarchical resource structure for rendering
639
+ */
640
+ flatten(e, t = /* @__PURE__ */ new Set(), n = 0, s, r = !1) {
641
+ const o = [];
642
+ for (const a of e) {
643
+ const i = !r;
644
+ if (o.push({ item: a, depth: n, visible: i, parentId: s }), f(a)) {
645
+ const c = t.has(a.id), d = this.flatten(
646
+ a.children,
647
+ t,
648
+ n + 1,
649
+ a.id,
650
+ r || c
651
+ );
652
+ o.push(...d);
653
+ }
654
+ }
655
+ return o;
656
+ }
657
+ /**
658
+ * Get all resources (leaf nodes) from a hierarchical structure
659
+ */
660
+ getAllResources(e) {
661
+ const t = [];
662
+ for (const n of e)
663
+ p(n) ? t.push(n) : f(n) && t.push(...this.getAllResources(n.children));
664
+ return t;
665
+ }
666
+ /**
667
+ * Get all events from all resources
668
+ */
669
+ getAllEvents(e) {
670
+ return this.getAllResources(e).flatMap((n) => n.events ?? []);
671
+ }
672
+ /**
673
+ * Find a resource by ID
674
+ */
675
+ findResourceById(e, t) {
676
+ for (const n of e) {
677
+ if (p(n) && n.id === t)
678
+ return n;
679
+ if (f(n)) {
680
+ const s = this.findResourceById(n.children, t);
681
+ if (s) return s;
682
+ }
683
+ }
684
+ }
685
+ /**
686
+ * Find a resource group by ID
687
+ */
688
+ findGroupById(e, t) {
689
+ for (const n of e)
690
+ if (f(n)) {
691
+ if (n.id === t) return n;
692
+ const s = this.findGroupById(n.children, t);
693
+ if (s) return s;
694
+ }
695
+ }
696
+ /**
697
+ * Find any item (resource or group) by ID
698
+ */
699
+ findById(e, t) {
700
+ return this.findResourceById(e, t) ?? this.findGroupById(e, t);
701
+ }
702
+ /**
703
+ * Add an event to a resource
704
+ */
705
+ addEventToResource(e, t, n) {
706
+ return this.mapResources(e, (s) => s.id === t ? {
707
+ ...s,
708
+ events: [...s.events ?? [], n]
709
+ } : s);
710
+ }
711
+ /**
712
+ * Update an event in a resource
713
+ */
714
+ updateEventInResource(e, t) {
715
+ return this.mapResources(e, (n) => {
716
+ const s = n.events?.findIndex((r) => r.id === t.id);
717
+ if (s !== void 0 && s >= 0 && n.events) {
718
+ const r = [...n.events];
719
+ return r[s] = t, { ...n, events: r };
720
+ }
721
+ return n;
722
+ });
723
+ }
724
+ /**
725
+ * Remove an event from all resources
726
+ */
727
+ removeEvent(e, t) {
728
+ return this.mapResources(e, (n) => n.events?.some((s) => s.id === t) ? {
729
+ ...n,
730
+ events: n.events.filter((s) => s.id !== t)
731
+ } : n);
732
+ }
733
+ /**
734
+ * Move an event from one resource to another
735
+ */
736
+ moveEventToResource(e, t, n, s) {
737
+ let r;
738
+ for (const i of this.getAllResources(e))
739
+ if (r = i.events?.find((c) => c.id === t), r) break;
740
+ if (!r) return e;
741
+ const o = {
742
+ ...r,
743
+ ...s,
744
+ resourceId: n
745
+ };
746
+ let a = this.removeEvent(e, t);
747
+ return a = this.addEventToResource(a, n, o), a;
748
+ }
749
+ /**
750
+ * Toggle collapse state of a group
751
+ */
752
+ toggleGroupCollapse(e, t) {
753
+ return this.mapGroups(e, (n) => n.id === t ? { ...n, collapsed: !n.collapsed } : n);
754
+ }
755
+ /**
756
+ * Set collapse state of a group
757
+ */
758
+ setGroupCollapse(e, t, n) {
759
+ return this.mapGroups(e, (s) => s.id === t ? { ...s, collapsed: n } : s);
760
+ }
761
+ /**
762
+ * Collapse all groups
763
+ */
764
+ collapseAll(e) {
765
+ return this.mapGroups(e, (t) => ({ ...t, collapsed: !0 }));
766
+ }
767
+ /**
768
+ * Expand all groups
769
+ */
770
+ expandAll(e) {
771
+ return this.mapGroups(e, (t) => ({ ...t, collapsed: !1 }));
772
+ }
773
+ /**
774
+ * Map over all resources in the hierarchy
775
+ */
776
+ mapResources(e, t) {
777
+ return e.map((n) => p(n) ? t(n) : {
778
+ ...n,
779
+ children: this.mapResources(n.children, t)
780
+ });
781
+ }
782
+ /**
783
+ * Map over all groups in the hierarchy
784
+ */
785
+ mapGroups(e, t) {
786
+ return e.map((n) => {
787
+ if (f(n)) {
788
+ const s = t(n);
789
+ return {
790
+ ...s,
791
+ children: this.mapGroups(s.children, t)
792
+ };
793
+ }
794
+ return n;
795
+ });
796
+ }
797
+ /**
798
+ * Get the total count of visible resources
799
+ */
800
+ getVisibleResourceCount(e, t = /* @__PURE__ */ new Set()) {
801
+ return this.flatten(e, t).filter((s) => s.visible && p(s.item)).length;
802
+ }
803
+ /**
804
+ * Sort resources by order property
805
+ */
806
+ sortByOrder(e) {
807
+ return [...e].sort((n, s) => (n.order ?? 0) - (s.order ?? 0)).map((n) => f(n) ? {
808
+ ...n,
809
+ children: this.sortByOrder(n.children)
810
+ } : n);
811
+ }
812
+ }
813
+ const C = new k();
814
+ function v(u = "evt") {
815
+ const e = Date.now().toString(36), t = Math.random().toString(36).substring(2, 9);
816
+ return `${u}-${e}-${t}`;
817
+ }
818
+ function F() {
819
+ return v("evt");
820
+ }
821
+ function H() {
822
+ return v("res");
823
+ }
824
+ function $() {
825
+ return v("grp");
826
+ }
827
+ const M = [
828
+ "#3788d8",
829
+ // Blue
830
+ "#28a745",
831
+ // Green
832
+ "#dc3545",
833
+ // Red
834
+ "#ffc107",
835
+ // Yellow
836
+ "#17a2b8",
837
+ // Cyan
838
+ "#6f42c1",
839
+ // Purple
840
+ "#fd7e14",
841
+ // Orange
842
+ "#20c997",
843
+ // Teal
844
+ "#e83e8c",
845
+ // Pink
846
+ "#6c757d"
847
+ // Gray
848
+ ];
849
+ function G(u) {
850
+ return M[u % M.length];
851
+ }
852
+ function U(u) {
853
+ let e = u.replace("#", "");
854
+ e.length === 3 && (e = e.split("").map((o) => o + o).join(""));
855
+ const t = parseInt(e.substring(0, 2), 16), n = parseInt(e.substring(2, 4), 16), s = parseInt(e.substring(4, 6), 16);
856
+ return (0.299 * t + 0.587 * n + 0.114 * s) / 255 > 0.5 ? "#000000" : "#ffffff";
857
+ }
858
+ function A(u, e) {
859
+ let t = u.replace("#", "");
860
+ t.length === 3 && (t = t.split("").map((c) => c + c).join(""));
861
+ const n = parseInt(t.substring(0, 2), 16), s = parseInt(t.substring(2, 4), 16), r = parseInt(t.substring(4, 6), 16), o = Math.min(255, Math.round(n + (255 - n) * (e / 100))), a = Math.min(255, Math.round(s + (255 - s) * (e / 100))), i = Math.min(255, Math.round(r + (255 - r) * (e / 100)));
862
+ return `#${o.toString(16).padStart(2, "0")}${a.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`;
863
+ }
864
+ function Y(u, e) {
865
+ let t = u.replace("#", "");
866
+ t.length === 3 && (t = t.split("").map((c) => c + c).join(""));
867
+ const n = parseInt(t.substring(0, 2), 16), s = parseInt(t.substring(2, 4), 16), r = parseInt(t.substring(4, 6), 16), o = Math.max(0, Math.round(n * (1 - e / 100))), a = Math.max(0, Math.round(s * (1 - e / 100))), i = Math.max(0, Math.round(r * (1 - e / 100)));
868
+ return `#${o.toString(16).padStart(2, "0")}${a.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`;
869
+ }
870
+ function O(u, e) {
871
+ let t = u.replace("#", "");
872
+ t.length === 3 && (t = t.split("").map((o) => o + o).join(""));
873
+ const n = parseInt(t.substring(0, 2), 16), s = parseInt(t.substring(2, 4), 16), r = parseInt(t.substring(4, 6), 16);
874
+ return `rgba(${n}, ${s}, ${r}, ${e})`;
875
+ }
876
+ export {
877
+ R as D,
878
+ k as R,
879
+ E as T,
880
+ M as a,
881
+ w as b,
882
+ T as c,
883
+ y as d,
884
+ O as e,
885
+ Y as f,
886
+ b as g,
887
+ F as h,
888
+ $ as i,
889
+ v as j,
890
+ H as k,
891
+ G as l,
892
+ U as m,
893
+ p as n,
894
+ f as o,
895
+ A as p,
896
+ C as q,
897
+ I as r,
898
+ x as t
899
+ };