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