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