@forcecalendar/interface 1.0.11 → 1.0.12
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var B = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
2
|
+
var P = (m, e, t) => e in m ? B(m, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[e] = t;
|
|
3
|
+
var S = (m, e, t) => P(m, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
class E extends HTMLElement {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(), this.attachShadow({ mode: "open" }), this._listeners = [], this._state = null, this._props = /* @__PURE__ */ new Map(), this._initialized = !1;
|
|
7
7
|
}
|
|
@@ -108,7 +108,7 @@ class T extends HTMLElement {
|
|
|
108
108
|
this.setProp(e, s), this._initialized && this.render();
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
class
|
|
111
|
+
class U {
|
|
112
112
|
constructor() {
|
|
113
113
|
this.timezones = {
|
|
114
114
|
// UTC
|
|
@@ -370,9 +370,9 @@ class P {
|
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
class
|
|
373
|
+
class A {
|
|
374
374
|
constructor() {
|
|
375
|
-
this.database = new
|
|
375
|
+
this.database = new U(), this.offsetCache = /* @__PURE__ */ new Map(), this.dstCache = /* @__PURE__ */ new Map(), this.maxCacheSize = 1e3, this.cacheHits = 0, this.cacheMisses = 0;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
378
378
|
* Convert date from one timezone to another
|
|
@@ -384,8 +384,8 @@ class S {
|
|
|
384
384
|
convertTimezone(e, t, s) {
|
|
385
385
|
if (!e) return null;
|
|
386
386
|
if (t === s) return new Date(e);
|
|
387
|
-
const i = this.getTimezoneOffset(e, t),
|
|
388
|
-
return new Date(e.getTime() +
|
|
387
|
+
const i = this.getTimezoneOffset(e, t), a = (this.getTimezoneOffset(e, s) - i) * 60 * 1e3;
|
|
388
|
+
return new Date(e.getTime() + a);
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
391
391
|
* Convert date to UTC
|
|
@@ -424,7 +424,7 @@ class S {
|
|
|
424
424
|
return this.cacheHits++, this._manageCacheSize(), this.offsetCache.get(s);
|
|
425
425
|
if (this.cacheMisses++, typeof Intl < "u" && Intl.DateTimeFormat)
|
|
426
426
|
try {
|
|
427
|
-
const
|
|
427
|
+
const n = new Intl.DateTimeFormat("en-US", {
|
|
428
428
|
timeZone: t,
|
|
429
429
|
year: "numeric",
|
|
430
430
|
month: "2-digit",
|
|
@@ -434,12 +434,12 @@ class S {
|
|
|
434
434
|
second: "2-digit",
|
|
435
435
|
hour12: !1
|
|
436
436
|
}).formatToParts(e), c = (new Date(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
437
|
+
n.find((l) => l.type === "year").value,
|
|
438
|
+
n.find((l) => l.type === "month").value - 1,
|
|
439
|
+
n.find((l) => l.type === "day").value,
|
|
440
|
+
n.find((l) => l.type === "hour").value,
|
|
441
|
+
n.find((l) => l.type === "minute").value,
|
|
442
|
+
n.find((l) => l.type === "second").value
|
|
443
443
|
).getTime() - e.getTime()) / (1e3 * 60);
|
|
444
444
|
return this.offsetCache.set(s, -c), this._manageCacheSize(), -c;
|
|
445
445
|
} catch {
|
|
@@ -447,8 +447,8 @@ class S {
|
|
|
447
447
|
const i = this.database.getTimezone(t);
|
|
448
448
|
if (!i)
|
|
449
449
|
throw new Error(`Unknown timezone: ${t}`);
|
|
450
|
-
let
|
|
451
|
-
return i.dst && this.isDST(e, t, i.dst) && (
|
|
450
|
+
let r = i.offset;
|
|
451
|
+
return i.dst && this.isDST(e, t, i.dst) && (r += i.dst.offset), this.offsetCache.set(s, r), this._manageCacheSize(), r;
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
454
454
|
* Check if date is in DST for given timezone
|
|
@@ -459,29 +459,29 @@ class S {
|
|
|
459
459
|
*/
|
|
460
460
|
isDST(e, t, s = null) {
|
|
461
461
|
if (!s) {
|
|
462
|
-
const
|
|
463
|
-
if (!
|
|
464
|
-
s =
|
|
462
|
+
const n = this.database.getTimezone(t);
|
|
463
|
+
if (!n || !n.dst) return !1;
|
|
464
|
+
s = n.dst;
|
|
465
465
|
}
|
|
466
|
-
const i = e.getFullYear(),
|
|
467
|
-
return
|
|
466
|
+
const i = e.getFullYear(), r = this.getNthWeekdayOfMonth(i, s.start.month, s.start.week, s.start.day), a = this.getNthWeekdayOfMonth(i, s.end.month, s.end.week, s.end.day);
|
|
467
|
+
return r > a ? e >= r || e < a : e >= r && e < a;
|
|
468
468
|
}
|
|
469
469
|
/**
|
|
470
470
|
* Get nth weekday of month
|
|
471
471
|
* @private
|
|
472
472
|
*/
|
|
473
473
|
getNthWeekdayOfMonth(e, t, s, i) {
|
|
474
|
-
const
|
|
475
|
-
let
|
|
476
|
-
if (
|
|
477
|
-
|
|
474
|
+
const r = new Date(e, t, 1), a = r.getDay();
|
|
475
|
+
let n = i - a;
|
|
476
|
+
if (n < 0 && (n += 7), s > 0)
|
|
477
|
+
r.setDate(1 + n + (s - 1) * 7);
|
|
478
478
|
else {
|
|
479
479
|
const o = new Date(e, t + 1, 0).getDate();
|
|
480
|
-
|
|
481
|
-
let l =
|
|
482
|
-
l < 0 && (l += 7),
|
|
480
|
+
r.setDate(o);
|
|
481
|
+
let l = r.getDay() - i;
|
|
482
|
+
l < 0 && (l += 7), r.setDate(o - l + (s + 1) * 7);
|
|
483
483
|
}
|
|
484
|
-
return
|
|
484
|
+
return r;
|
|
485
485
|
}
|
|
486
486
|
/**
|
|
487
487
|
* Get list of common timezones
|
|
@@ -516,7 +516,7 @@ class S {
|
|
|
516
516
|
{ value: "Pacific/Auckland", label: "New Zealand Time (Auckland)", region: "Oceania" },
|
|
517
517
|
{ value: "UTC", label: "UTC", region: "UTC" }
|
|
518
518
|
].map((s) => {
|
|
519
|
-
const i = this.getTimezoneOffset(e, s.value),
|
|
519
|
+
const i = this.getTimezoneOffset(e, s.value), r = -i / 60, a = Math.floor(Math.abs(r)), n = Math.round(Math.abs(r % 1) * 60), c = `UTC${r >= 0 ? "+" : "-"}${a.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}`;
|
|
520
520
|
return {
|
|
521
521
|
...s,
|
|
522
522
|
offset: c,
|
|
@@ -534,7 +534,7 @@ class S {
|
|
|
534
534
|
*/
|
|
535
535
|
formatInTimezone(e, t, s = {}) {
|
|
536
536
|
if (!e) return "";
|
|
537
|
-
const
|
|
537
|
+
const r = { ...{
|
|
538
538
|
year: "numeric",
|
|
539
539
|
month: "2-digit",
|
|
540
540
|
day: "2-digit",
|
|
@@ -544,7 +544,7 @@ class S {
|
|
|
544
544
|
timeZone: t
|
|
545
545
|
}, ...s };
|
|
546
546
|
try {
|
|
547
|
-
return new Intl.DateTimeFormat("en-US",
|
|
547
|
+
return new Intl.DateTimeFormat("en-US", r).format(e);
|
|
548
548
|
} catch {
|
|
549
549
|
return this.fromUTC(this.toUTC(e, "UTC"), t).toLocaleString("en-US", s);
|
|
550
550
|
}
|
|
@@ -579,9 +579,9 @@ class S {
|
|
|
579
579
|
return this.database.abbreviations[t];
|
|
580
580
|
const s = e.match(/^([+-])(\d{2}):?(\d{2})$/);
|
|
581
581
|
if (s) {
|
|
582
|
-
const i = s[1] === "+" ? 1 : -1,
|
|
582
|
+
const i = s[1] === "+" ? 1 : -1, r = parseInt(s[2], 10), a = parseInt(s[3], 10), n = i * (r + a / 60);
|
|
583
583
|
for (const [o, c] of Object.entries(this.database.timezones))
|
|
584
|
-
if (c.offset / 60 ===
|
|
584
|
+
if (c.offset / 60 === n)
|
|
585
585
|
return o;
|
|
586
586
|
}
|
|
587
587
|
return "UTC";
|
|
@@ -643,7 +643,7 @@ class S {
|
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
|
-
class
|
|
646
|
+
class T {
|
|
647
647
|
/**
|
|
648
648
|
* Normalize event data
|
|
649
649
|
* @param {import('../../types.js').EventData} data - Raw event data
|
|
@@ -700,21 +700,21 @@ class E {
|
|
|
700
700
|
title: t,
|
|
701
701
|
start: s,
|
|
702
702
|
end: i,
|
|
703
|
-
allDay:
|
|
704
|
-
description:
|
|
705
|
-
location:
|
|
703
|
+
allDay: r = !1,
|
|
704
|
+
description: a = "",
|
|
705
|
+
location: n = "",
|
|
706
706
|
color: o = null,
|
|
707
707
|
backgroundColor: c = null,
|
|
708
708
|
borderColor: l = null,
|
|
709
709
|
textColor: d = null,
|
|
710
710
|
recurring: h = !1,
|
|
711
|
-
recurrenceRule:
|
|
712
|
-
timeZone:
|
|
713
|
-
endTimeZone:
|
|
714
|
-
status:
|
|
715
|
-
visibility:
|
|
716
|
-
organizer:
|
|
717
|
-
attendees:
|
|
711
|
+
recurrenceRule: g = null,
|
|
712
|
+
timeZone: b = null,
|
|
713
|
+
endTimeZone: f = null,
|
|
714
|
+
status: D = "confirmed",
|
|
715
|
+
visibility: x = "public",
|
|
716
|
+
organizer: M = null,
|
|
717
|
+
attendees: I = [],
|
|
718
718
|
reminders: z = [],
|
|
719
719
|
category: _,
|
|
720
720
|
// Support singular category (no default)
|
|
@@ -726,26 +726,26 @@ class E {
|
|
|
726
726
|
...H
|
|
727
727
|
// Capture any extra properties
|
|
728
728
|
}) {
|
|
729
|
-
const
|
|
729
|
+
const p = T.normalize({
|
|
730
730
|
id: e,
|
|
731
731
|
title: t,
|
|
732
732
|
start: s,
|
|
733
733
|
end: i,
|
|
734
|
-
allDay:
|
|
735
|
-
description:
|
|
736
|
-
location:
|
|
734
|
+
allDay: r,
|
|
735
|
+
description: a,
|
|
736
|
+
location: n,
|
|
737
737
|
color: o,
|
|
738
738
|
backgroundColor: c,
|
|
739
739
|
borderColor: l,
|
|
740
740
|
textColor: d,
|
|
741
741
|
recurring: h,
|
|
742
|
-
recurrenceRule:
|
|
743
|
-
timeZone:
|
|
744
|
-
endTimeZone:
|
|
745
|
-
status:
|
|
746
|
-
visibility:
|
|
747
|
-
organizer:
|
|
748
|
-
attendees:
|
|
742
|
+
recurrenceRule: g,
|
|
743
|
+
timeZone: b,
|
|
744
|
+
endTimeZone: f,
|
|
745
|
+
status: D,
|
|
746
|
+
visibility: x,
|
|
747
|
+
organizer: M,
|
|
748
|
+
attendees: I,
|
|
749
749
|
reminders: z,
|
|
750
750
|
category: _,
|
|
751
751
|
// Pass category to normalize
|
|
@@ -757,7 +757,7 @@ class E {
|
|
|
757
757
|
...H
|
|
758
758
|
// Pass any extra properties
|
|
759
759
|
});
|
|
760
|
-
|
|
760
|
+
T.validate(p), this.id = p.id, this.title = p.title, this._timezoneManager = new A(), this.timeZone = p.timeZone || this._timezoneManager.getSystemTimezone(), this.endTimeZone = p.endTimeZone || this.timeZone, this.start = p.start, this.end = p.end, this.startUTC = this._timezoneManager.toUTC(this.start, this.timeZone), this.endUTC = this._timezoneManager.toUTC(this.end, this.endTimeZone), this.allDay = p.allDay, this.description = p.description, this.location = p.location, this.color = p.color, this.backgroundColor = p.backgroundColor, this.borderColor = p.borderColor, this.textColor = p.textColor, this.recurring = p.recurring, this.recurrenceRule = p.recurrenceRule, this._originalTimeZone = p.timeZone || null, this.status = p.status, this.visibility = p.visibility, this.organizer = p.organizer, this.attendees = [...p.attendees], this.reminders = [...p.reminders], this.categories = p.categories ? [...p.categories] : [], this.attachments = [...p.attachments], this.conferenceData = p.conferenceData, this.metadata = { ...p.metadata }, this._cache = {}, this._validateAttendees(), this._validateReminders();
|
|
761
761
|
}
|
|
762
762
|
/**
|
|
763
763
|
* Get event duration in milliseconds
|
|
@@ -835,8 +835,8 @@ class E {
|
|
|
835
835
|
if (this.allDay)
|
|
836
836
|
return e >= new Date(s) && e <= new Date(i);
|
|
837
837
|
if (this.isMultiDay) {
|
|
838
|
-
const
|
|
839
|
-
return
|
|
838
|
+
const r = new Date(t), a = new Date(t);
|
|
839
|
+
return a.setHours(23, 59, 59, 999), this.start <= a && this.end >= r;
|
|
840
840
|
} else
|
|
841
841
|
return s === t;
|
|
842
842
|
}
|
|
@@ -847,7 +847,7 @@ class E {
|
|
|
847
847
|
* @throws {Error} If otherEvent is not an Event instance or doesn't have start/end
|
|
848
848
|
*/
|
|
849
849
|
overlaps(e) {
|
|
850
|
-
if (e instanceof
|
|
850
|
+
if (e instanceof T)
|
|
851
851
|
return !(this.end <= e.start || this.start >= e.end);
|
|
852
852
|
if (e && e.start && e.end)
|
|
853
853
|
return !(this.end <= e.start || this.start >= e.end);
|
|
@@ -867,7 +867,7 @@ class E {
|
|
|
867
867
|
* @returns {Event} New Event instance with updated properties
|
|
868
868
|
*/
|
|
869
869
|
clone(e = {}) {
|
|
870
|
-
return new
|
|
870
|
+
return new T({
|
|
871
871
|
id: this.id,
|
|
872
872
|
title: this.title,
|
|
873
873
|
start: new Date(this.start),
|
|
@@ -931,7 +931,7 @@ class E {
|
|
|
931
931
|
* @returns {Event} New Event instance
|
|
932
932
|
*/
|
|
933
933
|
static fromObject(e) {
|
|
934
|
-
return new
|
|
934
|
+
return new T(e);
|
|
935
935
|
}
|
|
936
936
|
/**
|
|
937
937
|
* Compare events for equality
|
|
@@ -939,7 +939,7 @@ class E {
|
|
|
939
939
|
* @returns {boolean} True if events are equal
|
|
940
940
|
*/
|
|
941
941
|
equals(e) {
|
|
942
|
-
return e instanceof
|
|
942
|
+
return e instanceof T ? this.id === e.id && this.title === e.title && this.start.getTime() === e.start.getTime() && this.end.getTime() === e.end.getTime() && this.allDay === e.allDay && this.description === e.description && this.location === e.location && this.recurring === e.recurring && this.recurrenceRule === e.recurrenceRule && this.status === e.status : !1;
|
|
943
943
|
}
|
|
944
944
|
// ============ Attendee Management Methods ============
|
|
945
945
|
/**
|
|
@@ -1202,7 +1202,7 @@ class E {
|
|
|
1202
1202
|
return this.conferenceData !== null;
|
|
1203
1203
|
}
|
|
1204
1204
|
}
|
|
1205
|
-
let
|
|
1205
|
+
let u = class k {
|
|
1206
1206
|
/**
|
|
1207
1207
|
* Get the start of a day
|
|
1208
1208
|
* @param {Date} date - The date
|
|
@@ -1228,8 +1228,8 @@ let f = class D {
|
|
|
1228
1228
|
* @returns {Date} Start of the week
|
|
1229
1229
|
*/
|
|
1230
1230
|
static startOfWeek(e, t = 0) {
|
|
1231
|
-
const s = new Date(e), i = s.getDay(),
|
|
1232
|
-
return s.setTime(s.getTime() -
|
|
1231
|
+
const s = new Date(e), i = s.getDay(), r = (i < t ? 7 : 0) + i - t;
|
|
1232
|
+
return s.setTime(s.getTime() - r * 24 * 60 * 60 * 1e3), s.setHours(0, 0, 0, 0), s;
|
|
1233
1233
|
}
|
|
1234
1234
|
/**
|
|
1235
1235
|
* Get the end of a week
|
|
@@ -1238,7 +1238,7 @@ let f = class D {
|
|
|
1238
1238
|
* @returns {Date}
|
|
1239
1239
|
*/
|
|
1240
1240
|
static endOfWeek(e, t = 0) {
|
|
1241
|
-
const s =
|
|
1241
|
+
const s = k.startOfWeek(e, t);
|
|
1242
1242
|
return s.setTime(s.getTime() + 6 * 24 * 60 * 60 * 1e3), s.setHours(23, 59, 59, 999), s;
|
|
1243
1243
|
}
|
|
1244
1244
|
/**
|
|
@@ -1290,7 +1290,7 @@ let f = class D {
|
|
|
1290
1290
|
* @returns {Date}
|
|
1291
1291
|
*/
|
|
1292
1292
|
static addWeeks(e, t) {
|
|
1293
|
-
return
|
|
1293
|
+
return k.addDays(e, t * 7);
|
|
1294
1294
|
}
|
|
1295
1295
|
/**
|
|
1296
1296
|
* Add months to a date
|
|
@@ -1372,8 +1372,8 @@ let f = class D {
|
|
|
1372
1372
|
* @returns {boolean}
|
|
1373
1373
|
*/
|
|
1374
1374
|
static isSameWeek(e, t, s = 0) {
|
|
1375
|
-
const i =
|
|
1376
|
-
return i.toDateString() ===
|
|
1375
|
+
const i = k.startOfWeek(e, s), r = k.startOfWeek(t, s);
|
|
1376
|
+
return i.toDateString() === r.toDateString();
|
|
1377
1377
|
}
|
|
1378
1378
|
/**
|
|
1379
1379
|
* Check if two dates are in the same month
|
|
@@ -1410,7 +1410,7 @@ let f = class D {
|
|
|
1410
1410
|
* @returns {number}
|
|
1411
1411
|
*/
|
|
1412
1412
|
static differenceInWeeks(e, t) {
|
|
1413
|
-
return Math.floor(
|
|
1413
|
+
return Math.floor(k.differenceInDays(e, t) / 7);
|
|
1414
1414
|
}
|
|
1415
1415
|
/**
|
|
1416
1416
|
* Get the difference in months between two dates
|
|
@@ -1466,7 +1466,7 @@ let f = class D {
|
|
|
1466
1466
|
* @returns {string}
|
|
1467
1467
|
*/
|
|
1468
1468
|
static getMonthName(e, t = "en-US", s = "long") {
|
|
1469
|
-
return
|
|
1469
|
+
return k.format(e, t, { month: s });
|
|
1470
1470
|
}
|
|
1471
1471
|
/**
|
|
1472
1472
|
* Get day name
|
|
@@ -1476,7 +1476,7 @@ let f = class D {
|
|
|
1476
1476
|
* @returns {string}
|
|
1477
1477
|
*/
|
|
1478
1478
|
static getDayName(e, t = "en-US", s = "long") {
|
|
1479
|
-
return
|
|
1479
|
+
return k.format(e, t, { weekday: s });
|
|
1480
1480
|
}
|
|
1481
1481
|
/**
|
|
1482
1482
|
* Format time
|
|
@@ -1486,7 +1486,7 @@ let f = class D {
|
|
|
1486
1486
|
* @returns {string}
|
|
1487
1487
|
*/
|
|
1488
1488
|
static formatTime(e, t = "en-US", s = !1) {
|
|
1489
|
-
return
|
|
1489
|
+
return k.format(e, t, {
|
|
1490
1490
|
hour: "numeric",
|
|
1491
1491
|
minute: "2-digit",
|
|
1492
1492
|
hour12: !s
|
|
@@ -1508,8 +1508,8 @@ let f = class D {
|
|
|
1508
1508
|
* @returns {Date}
|
|
1509
1509
|
*/
|
|
1510
1510
|
static setTime(e, t) {
|
|
1511
|
-
const s = new Date(e), { hours: i, minutes:
|
|
1512
|
-
return s.setHours(i,
|
|
1511
|
+
const s = new Date(e), { hours: i, minutes: r } = k.parseTime(t);
|
|
1512
|
+
return s.setHours(i, r, 0, 0), s;
|
|
1513
1513
|
}
|
|
1514
1514
|
/**
|
|
1515
1515
|
* Check if a year is a leap year
|
|
@@ -1526,8 +1526,8 @@ let f = class D {
|
|
|
1526
1526
|
* @returns {Date[]}
|
|
1527
1527
|
*/
|
|
1528
1528
|
static getDateRange(e, t) {
|
|
1529
|
-
const s = [], i = new Date(e),
|
|
1530
|
-
for (; i.getTime() <=
|
|
1529
|
+
const s = [], i = new Date(e), r = t.getTime();
|
|
1530
|
+
for (; i.getTime() <= r; )
|
|
1531
1531
|
s.push(new Date(i)), i.setTime(i.getTime() + 24 * 60 * 60 * 1e3);
|
|
1532
1532
|
return s;
|
|
1533
1533
|
}
|
|
@@ -1563,11 +1563,11 @@ let f = class D {
|
|
|
1563
1563
|
minute: "2-digit",
|
|
1564
1564
|
second: "2-digit",
|
|
1565
1565
|
hour12: !1
|
|
1566
|
-
}).formatToParts(e),
|
|
1567
|
-
return i.forEach((
|
|
1568
|
-
|
|
1566
|
+
}).formatToParts(e), r = {};
|
|
1567
|
+
return i.forEach((a) => {
|
|
1568
|
+
a.type !== "literal" && (r[a.type] = a.value);
|
|
1569
1569
|
}), /* @__PURE__ */ new Date(
|
|
1570
|
-
`${
|
|
1570
|
+
`${r.year}-${r.month}-${r.day}T${r.hour}:${r.minute}:${r.second}`
|
|
1571
1571
|
);
|
|
1572
1572
|
}
|
|
1573
1573
|
/**
|
|
@@ -1587,8 +1587,8 @@ let f = class D {
|
|
|
1587
1587
|
* @returns {boolean}
|
|
1588
1588
|
*/
|
|
1589
1589
|
static isDST(e, t) {
|
|
1590
|
-
const s = new Date(e.getFullYear(), 0, 1), i = new Date(e.getFullYear(), 6, 1),
|
|
1591
|
-
return Math.max(
|
|
1590
|
+
const s = new Date(e.getFullYear(), 0, 1), i = new Date(e.getFullYear(), 6, 1), r = k.getTimezoneOffset(s, t), a = k.getTimezoneOffset(i, t), n = k.getTimezoneOffset(e, t);
|
|
1591
|
+
return Math.max(r, a) === n;
|
|
1592
1592
|
}
|
|
1593
1593
|
/**
|
|
1594
1594
|
* Add time accounting for DST transitions
|
|
@@ -1598,12 +1598,12 @@ let f = class D {
|
|
|
1598
1598
|
* @returns {Date}
|
|
1599
1599
|
*/
|
|
1600
1600
|
static addHoursWithDST(e, t, s) {
|
|
1601
|
-
const i = new Date(e),
|
|
1601
|
+
const i = new Date(e), r = k.getTimezoneOffset(e, s);
|
|
1602
1602
|
i.setTime(i.getTime() + t * 60 * 60 * 1e3);
|
|
1603
|
-
const
|
|
1604
|
-
if (
|
|
1605
|
-
const
|
|
1606
|
-
i.setTime(i.getTime() +
|
|
1603
|
+
const a = k.getTimezoneOffset(i, s);
|
|
1604
|
+
if (r !== a) {
|
|
1605
|
+
const n = (a - r) * 6e4;
|
|
1606
|
+
i.setTime(i.getTime() + n);
|
|
1607
1607
|
}
|
|
1608
1608
|
return i;
|
|
1609
1609
|
}
|
|
@@ -1618,8 +1618,8 @@ let f = class D {
|
|
|
1618
1618
|
* @param {string} timeZone - IANA timezone string
|
|
1619
1619
|
* @returns {Date}
|
|
1620
1620
|
*/
|
|
1621
|
-
static createInTimeZone(e, t, s, i = 0,
|
|
1622
|
-
const o = `${e}-${String(t + 1).padStart(2, "0")}-${String(s).padStart(2, "0")}`, c = `${String(i).padStart(2, "0")}:${String(
|
|
1621
|
+
static createInTimeZone(e, t, s, i = 0, r = 0, a = 0, n) {
|
|
1622
|
+
const o = `${e}-${String(t + 1).padStart(2, "0")}-${String(s).padStart(2, "0")}`, c = `${String(i).padStart(2, "0")}:${String(r).padStart(2, "0")}:${String(a).padStart(2, "0")}`, l = /* @__PURE__ */ new Date(`${o}T${c}`), d = k.getTimezoneOffset(l, n), h = l.getTime() + d * 6e4;
|
|
1623
1623
|
return new Date(h);
|
|
1624
1624
|
}
|
|
1625
1625
|
};
|
|
@@ -1652,55 +1652,55 @@ class V {
|
|
|
1652
1652
|
tzid: null
|
|
1653
1653
|
}, s = e.toUpperCase().split(";");
|
|
1654
1654
|
for (const i of s) {
|
|
1655
|
-
const [
|
|
1656
|
-
switch (
|
|
1655
|
+
const [r, a] = i.split("=");
|
|
1656
|
+
switch (r) {
|
|
1657
1657
|
case "FREQ":
|
|
1658
|
-
t.freq = this.parseFrequency(
|
|
1658
|
+
t.freq = this.parseFrequency(a);
|
|
1659
1659
|
break;
|
|
1660
1660
|
case "INTERVAL":
|
|
1661
|
-
t.interval = parseInt(
|
|
1661
|
+
t.interval = parseInt(a, 10), t.interval < 1 && (t.interval = 1);
|
|
1662
1662
|
break;
|
|
1663
1663
|
case "COUNT":
|
|
1664
|
-
t.count = parseInt(
|
|
1664
|
+
t.count = parseInt(a, 10);
|
|
1665
1665
|
break;
|
|
1666
1666
|
case "UNTIL":
|
|
1667
|
-
t.until = this.parseDateTime(
|
|
1667
|
+
t.until = this.parseDateTime(a);
|
|
1668
1668
|
break;
|
|
1669
1669
|
case "BYDAY":
|
|
1670
|
-
t.byDay = this.parseByDay(
|
|
1670
|
+
t.byDay = this.parseByDay(a);
|
|
1671
1671
|
break;
|
|
1672
1672
|
case "BYWEEKNO":
|
|
1673
|
-
t.byWeekNo = this.parseIntList(
|
|
1673
|
+
t.byWeekNo = this.parseIntList(a);
|
|
1674
1674
|
break;
|
|
1675
1675
|
case "BYMONTH":
|
|
1676
|
-
t.byMonth = this.parseIntList(
|
|
1676
|
+
t.byMonth = this.parseIntList(a);
|
|
1677
1677
|
break;
|
|
1678
1678
|
case "BYMONTHDAY":
|
|
1679
|
-
t.byMonthDay = this.parseIntList(
|
|
1679
|
+
t.byMonthDay = this.parseIntList(a);
|
|
1680
1680
|
break;
|
|
1681
1681
|
case "BYYEARDAY":
|
|
1682
|
-
t.byYearDay = this.parseIntList(
|
|
1682
|
+
t.byYearDay = this.parseIntList(a);
|
|
1683
1683
|
break;
|
|
1684
1684
|
case "BYSETPOS":
|
|
1685
|
-
t.bySetPos = this.parseIntList(
|
|
1685
|
+
t.bySetPos = this.parseIntList(a);
|
|
1686
1686
|
break;
|
|
1687
1687
|
case "BYHOUR":
|
|
1688
|
-
t.byHour = this.parseIntList(
|
|
1688
|
+
t.byHour = this.parseIntList(a);
|
|
1689
1689
|
break;
|
|
1690
1690
|
case "BYMINUTE":
|
|
1691
|
-
t.byMinute = this.parseIntList(
|
|
1691
|
+
t.byMinute = this.parseIntList(a);
|
|
1692
1692
|
break;
|
|
1693
1693
|
case "BYSECOND":
|
|
1694
|
-
t.bySecond = this.parseIntList(
|
|
1694
|
+
t.bySecond = this.parseIntList(a);
|
|
1695
1695
|
break;
|
|
1696
1696
|
case "WKST":
|
|
1697
|
-
t.wkst =
|
|
1697
|
+
t.wkst = a;
|
|
1698
1698
|
break;
|
|
1699
1699
|
case "EXDATE":
|
|
1700
|
-
t.exceptions = this.parseExceptionDates(
|
|
1700
|
+
t.exceptions = this.parseExceptionDates(a);
|
|
1701
1701
|
break;
|
|
1702
1702
|
case "TZID":
|
|
1703
|
-
t.tzid =
|
|
1703
|
+
t.tzid = a;
|
|
1704
1704
|
break;
|
|
1705
1705
|
}
|
|
1706
1706
|
}
|
|
@@ -1720,10 +1720,10 @@ class V {
|
|
|
1720
1720
|
*/
|
|
1721
1721
|
static parseByDay(e) {
|
|
1722
1722
|
const t = e.split(","), s = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"], i = [];
|
|
1723
|
-
for (const
|
|
1724
|
-
const
|
|
1725
|
-
if (
|
|
1726
|
-
const [o, c, l] =
|
|
1723
|
+
for (const r of t) {
|
|
1724
|
+
const n = r.trim().toUpperCase().match(/^([+-]?\d*)([A-Z]{2})$/);
|
|
1725
|
+
if (n) {
|
|
1726
|
+
const [o, c, l] = n;
|
|
1727
1727
|
s.includes(l) && i.push(c ? `${c}${l}` : l);
|
|
1728
1728
|
}
|
|
1729
1729
|
}
|
|
@@ -1746,12 +1746,12 @@ class V {
|
|
|
1746
1746
|
return new Date(t, s, i);
|
|
1747
1747
|
}
|
|
1748
1748
|
if (e.length === 15 && e[8] === "T") {
|
|
1749
|
-
const t = parseInt(e.substr(0, 4), 10), s = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10),
|
|
1750
|
-
return new Date(t, s, i, a, n
|
|
1749
|
+
const t = parseInt(e.substr(0, 4), 10), s = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10), r = parseInt(e.substr(9, 2), 10), a = parseInt(e.substr(11, 2), 10), n = parseInt(e.substr(13, 2), 10);
|
|
1750
|
+
return new Date(t, s, i, r, a, n);
|
|
1751
1751
|
}
|
|
1752
1752
|
if (e.length === 16 && e[8] === "T" && e[15] === "Z") {
|
|
1753
|
-
const t = parseInt(e.substr(0, 4), 10), s = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10),
|
|
1754
|
-
return new Date(Date.UTC(t, s, i, a, n
|
|
1753
|
+
const t = parseInt(e.substr(0, 4), 10), s = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10), r = parseInt(e.substr(9, 2), 10), a = parseInt(e.substr(11, 2), 10), n = parseInt(e.substr(13, 2), 10);
|
|
1754
|
+
return new Date(Date.UTC(t, s, i, r, a, n));
|
|
1755
1755
|
}
|
|
1756
1756
|
return new Date(e);
|
|
1757
1757
|
}
|
|
@@ -1770,7 +1770,7 @@ class V {
|
|
|
1770
1770
|
if (e.freq || (e.freq = "DAILY"), e.count && e.until)
|
|
1771
1771
|
throw new Error("RRULE cannot have both COUNT and UNTIL");
|
|
1772
1772
|
e.interval < 1 && (e.interval = 1);
|
|
1773
|
-
const t = (s, i,
|
|
1773
|
+
const t = (s, i, r) => s.filter((a) => a >= i && a <= r);
|
|
1774
1774
|
return e.byMonth = t(e.byMonth || [], 1, 12), e.byMonthDay = t(e.byMonthDay || [], -31, 31).filter((s) => s !== 0), e.byYearDay = t(e.byYearDay || [], -366, 366).filter((s) => s !== 0), e.byWeekNo = t(e.byWeekNo || [], -53, 53).filter((s) => s !== 0), e.byHour = t(e.byHour || [], 0, 23), e.byMinute = t(e.byMinute || [], 0, 59), e.bySecond = t(e.bySecond || [], 0, 59), e;
|
|
1775
1775
|
}
|
|
1776
1776
|
/**
|
|
@@ -1791,8 +1791,8 @@ class V {
|
|
|
1791
1791
|
* @private
|
|
1792
1792
|
*/
|
|
1793
1793
|
static formatDateTime(e) {
|
|
1794
|
-
const t = e.getUTCFullYear(), s = String(e.getUTCMonth() + 1).padStart(2, "0"), i = String(e.getUTCDate()).padStart(2, "0"),
|
|
1795
|
-
return `${t}${s}${i}T${
|
|
1794
|
+
const t = e.getUTCFullYear(), s = String(e.getUTCMonth() + 1).padStart(2, "0"), i = String(e.getUTCDate()).padStart(2, "0"), r = String(e.getUTCHours()).padStart(2, "0"), a = String(e.getUTCMinutes()).padStart(2, "0"), n = String(e.getUTCSeconds()).padStart(2, "0");
|
|
1795
|
+
return `${t}${s}${i}T${r}${a}${n}Z`;
|
|
1796
1796
|
}
|
|
1797
1797
|
/**
|
|
1798
1798
|
* Get human-readable description of rule
|
|
@@ -1825,22 +1825,22 @@ class V {
|
|
|
1825
1825
|
"-1": "last",
|
|
1826
1826
|
"-2": "second to last"
|
|
1827
1827
|
};
|
|
1828
|
-
let
|
|
1829
|
-
if (e.interval > 1 && (
|
|
1828
|
+
let r = "Every";
|
|
1829
|
+
if (e.interval > 1 && (r += ` ${e.interval}`), r += ` ${t[e.freq]}`, e.interval > 1 && (r += "s"), e.byDay && e.byDay.length > 0) {
|
|
1830
1830
|
if (e.freq === "WEEKLY") {
|
|
1831
|
-
const
|
|
1832
|
-
|
|
1831
|
+
const a = e.byDay.map((n) => s[n.weekday]).join(", ");
|
|
1832
|
+
r += ` on ${a}`;
|
|
1833
1833
|
} else if (e.freq === "MONTHLY" || e.freq === "YEARLY") {
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1834
|
+
const a = e.byDay.map((n) => n.nth ? `the ${i[n.nth] || n.nth} ${s[n.weekday]}` : s[n.weekday]).join(", ");
|
|
1835
|
+
r += ` on ${a}`;
|
|
1836
1836
|
}
|
|
1837
1837
|
}
|
|
1838
1838
|
if (e.byMonthDay && e.byMonthDay.length > 0) {
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1839
|
+
const a = e.byMonthDay.map((n) => n < 0 ? `${Math.abs(n)} day(s) from the end` : `day ${n}`).join(", ");
|
|
1840
|
+
r += ` on ${a}`;
|
|
1841
1841
|
}
|
|
1842
1842
|
if (e.byMonth && e.byMonth.length > 0) {
|
|
1843
|
-
const
|
|
1843
|
+
const a = [
|
|
1844
1844
|
"January",
|
|
1845
1845
|
"February",
|
|
1846
1846
|
"March",
|
|
@@ -1853,10 +1853,10 @@ class V {
|
|
|
1853
1853
|
"October",
|
|
1854
1854
|
"November",
|
|
1855
1855
|
"December"
|
|
1856
|
-
],
|
|
1857
|
-
|
|
1856
|
+
], n = e.byMonth.map((o) => a[o - 1]).join(", ");
|
|
1857
|
+
r += ` in ${n}`;
|
|
1858
1858
|
}
|
|
1859
|
-
return e.count ?
|
|
1859
|
+
return e.count ? r += `, ${e.count} time${e.count > 1 ? "s" : ""}` : e.until && (r += `, until ${e.until.toLocaleDateString()}`), r;
|
|
1860
1860
|
}
|
|
1861
1861
|
}
|
|
1862
1862
|
class Y {
|
|
@@ -1869,32 +1869,32 @@ class Y {
|
|
|
1869
1869
|
* @param {string} [timezone] - Timezone for expansion (important for DST)
|
|
1870
1870
|
* @returns {import('../../types.js').EventOccurrence[]} Array of occurrence objects with start/end dates
|
|
1871
1871
|
*/
|
|
1872
|
-
static expandEvent(e, t, s, i = 365,
|
|
1872
|
+
static expandEvent(e, t, s, i = 365, r = null) {
|
|
1873
1873
|
if (!e.recurring || !e.recurrenceRule)
|
|
1874
1874
|
return [{ start: e.start, end: e.end, timezone: e.timeZone }];
|
|
1875
|
-
const
|
|
1875
|
+
const a = this.parseRule(e.recurrenceRule), n = [], o = e.end - e.start, c = r || e.timeZone || "UTC", l = new A();
|
|
1876
1876
|
let d = new Date(e.start), h = 0;
|
|
1877
|
-
|
|
1878
|
-
let
|
|
1877
|
+
a.until && a.until < s && (s = a.until);
|
|
1878
|
+
let g = l.getTimezoneOffset(d, c);
|
|
1879
1879
|
for (; d <= s && h < i; ) {
|
|
1880
1880
|
if (d >= t) {
|
|
1881
|
-
const
|
|
1882
|
-
if (
|
|
1883
|
-
const
|
|
1884
|
-
|
|
1881
|
+
const b = new Date(d), f = new Date(d.getTime() + o), D = l.getTimezoneOffset(b, c);
|
|
1882
|
+
if (D !== g) {
|
|
1883
|
+
const x = g - D;
|
|
1884
|
+
b.setMinutes(b.getMinutes() + x), f.setMinutes(f.getMinutes() + x);
|
|
1885
1885
|
}
|
|
1886
|
-
|
|
1887
|
-
start:
|
|
1888
|
-
end:
|
|
1886
|
+
g = D, this.isException(b, a, e.id) || n.push({
|
|
1887
|
+
start: b,
|
|
1888
|
+
end: f,
|
|
1889
1889
|
recurringEventId: e.id,
|
|
1890
1890
|
timezone: c,
|
|
1891
1891
|
originalStart: e.start
|
|
1892
1892
|
});
|
|
1893
1893
|
}
|
|
1894
|
-
if (d = this.getNextOccurrence(d,
|
|
1894
|
+
if (d = this.getNextOccurrence(d, a, c), h++, a.count && h >= a.count)
|
|
1895
1895
|
break;
|
|
1896
1896
|
}
|
|
1897
|
-
return
|
|
1897
|
+
return n;
|
|
1898
1898
|
}
|
|
1899
1899
|
/**
|
|
1900
1900
|
* Parse an RRULE string into a rule object
|
|
@@ -1919,17 +1919,17 @@ class Y {
|
|
|
1919
1919
|
break;
|
|
1920
1920
|
case "WEEKLY":
|
|
1921
1921
|
if (t.byDay && t.byDay.length > 0) {
|
|
1922
|
-
let
|
|
1923
|
-
for (i.setDate(i.getDate() + 1); !this.matchesByDay(i, t.byDay) &&
|
|
1924
|
-
i.setDate(i.getDate() + 1),
|
|
1925
|
-
|
|
1922
|
+
let a = 0;
|
|
1923
|
+
for (i.setDate(i.getDate() + 1); !this.matchesByDay(i, t.byDay) && a < 8; )
|
|
1924
|
+
i.setDate(i.getDate() + 1), a++;
|
|
1925
|
+
a >= 8 && (console.warn("RecurrenceEngine: Invalid byDay rule, falling back to weekly interval"), i.setDate(i.getDate() + 7 * t.interval - 8));
|
|
1926
1926
|
} else
|
|
1927
1927
|
i.setDate(i.getDate() + 7 * t.interval);
|
|
1928
1928
|
break;
|
|
1929
1929
|
case "MONTHLY":
|
|
1930
1930
|
if (t.byMonthDay && t.byMonthDay.length > 0) {
|
|
1931
|
-
const
|
|
1932
|
-
i.setMonth(
|
|
1931
|
+
const r = i.getMonth();
|
|
1932
|
+
i.setMonth(r + t.interval), i.setDate(t.byMonthDay[0]);
|
|
1933
1933
|
} else t.byDay && t.byDay.length > 0 ? (i.setMonth(i.getMonth() + t.interval), this.setToWeekdayOfMonth(i, t.byDay[0], t.bySetPos[0] || 1)) : i.setMonth(i.getMonth() + t.interval);
|
|
1934
1934
|
break;
|
|
1935
1935
|
case "YEARLY":
|
|
@@ -1956,11 +1956,11 @@ class Y {
|
|
|
1956
1956
|
FR: 5,
|
|
1957
1957
|
SA: 6
|
|
1958
1958
|
}, i = e.getDay();
|
|
1959
|
-
return t.some((
|
|
1960
|
-
const
|
|
1961
|
-
if (
|
|
1962
|
-
const
|
|
1963
|
-
return s[
|
|
1959
|
+
return t.some((r) => {
|
|
1960
|
+
const a = r.match(/^(-?\d+)?([A-Z]{2})$/);
|
|
1961
|
+
if (a) {
|
|
1962
|
+
const n = a[2];
|
|
1963
|
+
return s[n] === i;
|
|
1964
1964
|
}
|
|
1965
1965
|
return !1;
|
|
1966
1966
|
});
|
|
@@ -1980,14 +1980,14 @@ class Y {
|
|
|
1980
1980
|
TH: 4,
|
|
1981
1981
|
FR: 5,
|
|
1982
1982
|
SA: 6
|
|
1983
|
-
},
|
|
1984
|
-
for (e.setDate(1); e.getDay() !==
|
|
1983
|
+
}, r = t.match(/^(-?\d+)?([A-Z]{2})$/), a = r ? r[2] : t, n = i[a];
|
|
1984
|
+
for (e.setDate(1); e.getDay() !== n; )
|
|
1985
1985
|
e.setDate(e.getDate() + 1);
|
|
1986
1986
|
if (s > 1)
|
|
1987
1987
|
e.setDate(e.getDate() + 7 * (s - 1));
|
|
1988
1988
|
else if (s === -1) {
|
|
1989
1989
|
const o = new Date(e);
|
|
1990
|
-
for (o.setMonth(o.getMonth() + 1), o.setDate(0); o.getDay() !==
|
|
1990
|
+
for (o.setMonth(o.getMonth() + 1), o.setDate(0); o.getDay() !== n; )
|
|
1991
1991
|
o.setDate(o.getDate() - 1);
|
|
1992
1992
|
e.setTime(o.getTime());
|
|
1993
1993
|
}
|
|
@@ -2002,13 +2002,13 @@ class Y {
|
|
|
2002
2002
|
static isException(e, t, s = null) {
|
|
2003
2003
|
if (!t.exceptions || t.exceptions.length === 0)
|
|
2004
2004
|
return !1;
|
|
2005
|
-
const i = e.toDateString(),
|
|
2006
|
-
return t.exceptions.some((
|
|
2007
|
-
if (typeof
|
|
2008
|
-
const
|
|
2009
|
-
return
|
|
2005
|
+
const i = e.toDateString(), r = e.getTime();
|
|
2006
|
+
return t.exceptions.some((a) => {
|
|
2007
|
+
if (typeof a == "object" && a.date) {
|
|
2008
|
+
const n = a.date instanceof Date ? a.date : new Date(a.date);
|
|
2009
|
+
return a.matchTime ? Math.abs(n.getTime() - r) < 1e3 : n.toDateString() === i;
|
|
2010
2010
|
} else
|
|
2011
|
-
return (
|
|
2011
|
+
return (a instanceof Date ? a : new Date(a)).toDateString() === i;
|
|
2012
2012
|
});
|
|
2013
2013
|
}
|
|
2014
2014
|
/**
|
|
@@ -2019,12 +2019,12 @@ class Y {
|
|
|
2019
2019
|
* @returns {Object} Updated rule
|
|
2020
2020
|
*/
|
|
2021
2021
|
static addExceptions(e, t, s = {}) {
|
|
2022
|
-
return e.exceptions || (e.exceptions = []), (Array.isArray(t) ? t : [t]).forEach((
|
|
2022
|
+
return e.exceptions || (e.exceptions = []), (Array.isArray(t) ? t : [t]).forEach((r) => {
|
|
2023
2023
|
s.reason || s.matchTime ? e.exceptions.push({
|
|
2024
|
-
date:
|
|
2024
|
+
date: r,
|
|
2025
2025
|
reason: s.reason,
|
|
2026
2026
|
matchTime: s.matchTime || !1
|
|
2027
|
-
}) : e.exceptions.push(
|
|
2027
|
+
}) : e.exceptions.push(r);
|
|
2028
2028
|
}), e;
|
|
2029
2029
|
}
|
|
2030
2030
|
/**
|
|
@@ -2037,8 +2037,8 @@ class Y {
|
|
|
2037
2037
|
const t = parseInt(e.substr(0, 4), 10), s = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10);
|
|
2038
2038
|
return new Date(t, s, i);
|
|
2039
2039
|
} else if (e.length === 15 || e.length === 16) {
|
|
2040
|
-
const t = parseInt(e.substr(0, 4), 10), s = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10),
|
|
2041
|
-
return e.endsWith("Z") ? new Date(Date.UTC(t, s, i, a, n
|
|
2040
|
+
const t = parseInt(e.substr(0, 4), 10), s = parseInt(e.substr(4, 2), 10) - 1, i = parseInt(e.substr(6, 2), 10), r = parseInt(e.substr(9, 2), 10), a = parseInt(e.substr(11, 2), 10), n = parseInt(e.substr(13, 2), 10);
|
|
2041
|
+
return e.endsWith("Z") ? new Date(Date.UTC(t, s, i, r, a, n)) : new Date(t, s, i, r, a, n);
|
|
2042
2042
|
}
|
|
2043
2043
|
return new Date(e);
|
|
2044
2044
|
}
|
|
@@ -2057,7 +2057,7 @@ class Y {
|
|
|
2057
2057
|
break;
|
|
2058
2058
|
case "WEEKLY":
|
|
2059
2059
|
if (t = s === 1 ? "Weekly" : `Every ${s} weeks`, e.byDay && e.byDay.length > 0) {
|
|
2060
|
-
const i = e.byDay.map((
|
|
2060
|
+
const i = e.byDay.map((r) => this.getDayName(r)).join(", ");
|
|
2061
2061
|
t += ` on ${i}`;
|
|
2062
2062
|
}
|
|
2063
2063
|
break;
|
|
@@ -2084,12 +2084,12 @@ class Y {
|
|
|
2084
2084
|
TH: "Thursday",
|
|
2085
2085
|
FR: "Friday",
|
|
2086
2086
|
SA: "Saturday"
|
|
2087
|
-
}, s = e.match(/^(-?\d+)?([A-Z]{2})$/), i = s ? s[2] : e,
|
|
2088
|
-
let
|
|
2089
|
-
return
|
|
2087
|
+
}, s = e.match(/^(-?\d+)?([A-Z]{2})$/), i = s ? s[2] : e, r = s && s[1] ? parseInt(s[1], 10) : null;
|
|
2088
|
+
let a = t[i] || e;
|
|
2089
|
+
return r && (a = `${r === -1 ? "Last" : ["", "1st", "2nd", "3rd", "4th", "5th"][r] || `${r}th`} ${a}`), a;
|
|
2090
2090
|
}
|
|
2091
2091
|
}
|
|
2092
|
-
class
|
|
2092
|
+
class $ {
|
|
2093
2093
|
/**
|
|
2094
2094
|
* Create a new LRU Cache
|
|
2095
2095
|
* @param {number} capacity - Maximum number of items in cache
|
|
@@ -2285,13 +2285,13 @@ class N {
|
|
|
2285
2285
|
* @param {number} memoryUsage - Current memory usage percentage
|
|
2286
2286
|
*/
|
|
2287
2287
|
reduceCacheSizes(e) {
|
|
2288
|
-
const t = (e - this.config.memoryThreshold) / (this.config.criticalThreshold - this.config.memoryThreshold), s = Array.from(this.caches.entries()).sort((i,
|
|
2289
|
-
for (const [i,
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
|
|
2288
|
+
const t = (e - this.config.memoryThreshold) / (this.config.criticalThreshold - this.config.memoryThreshold), s = Array.from(this.caches.entries()).sort((i, r) => i[1].priority - r[1].priority);
|
|
2289
|
+
for (const [i, r] of s) {
|
|
2290
|
+
const a = Math.floor(r.currentCapacity * r.scaleFactor * t), n = Math.max(
|
|
2291
|
+
r.minCapacity,
|
|
2292
|
+
r.currentCapacity - a
|
|
2293
2293
|
);
|
|
2294
|
-
|
|
2294
|
+
n < r.currentCapacity && this.resizeCache(i, r, n);
|
|
2295
2295
|
}
|
|
2296
2296
|
this.stats.adjustments++;
|
|
2297
2297
|
}
|
|
@@ -2301,11 +2301,11 @@ class N {
|
|
|
2301
2301
|
increaseCacheSizes() {
|
|
2302
2302
|
for (const [e, t] of this.caches)
|
|
2303
2303
|
if (Date.now() - t.lastAccess < 6e4) {
|
|
2304
|
-
const i = Math.floor(t.currentCapacity * 0.2),
|
|
2304
|
+
const i = Math.floor(t.currentCapacity * 0.2), r = Math.min(
|
|
2305
2305
|
t.maxCapacity,
|
|
2306
2306
|
t.currentCapacity + i
|
|
2307
2307
|
);
|
|
2308
|
-
|
|
2308
|
+
r > t.currentCapacity && this.resizeCache(e, t, r);
|
|
2309
2309
|
}
|
|
2310
2310
|
}
|
|
2311
2311
|
/**
|
|
@@ -2332,8 +2332,8 @@ class N {
|
|
|
2332
2332
|
const s = e.size - t;
|
|
2333
2333
|
if (e.keys) {
|
|
2334
2334
|
const i = Array.from(e.keys());
|
|
2335
|
-
for (let
|
|
2336
|
-
e.delete(i[
|
|
2335
|
+
for (let r = 0; r < s; r++)
|
|
2336
|
+
e.delete(i[r]);
|
|
2337
2337
|
} else e.clear && e.clear();
|
|
2338
2338
|
}
|
|
2339
2339
|
/**
|
|
@@ -2393,7 +2393,7 @@ class N {
|
|
|
2393
2393
|
this.stopMonitoring(), this.caches.clear();
|
|
2394
2394
|
}
|
|
2395
2395
|
}
|
|
2396
|
-
class
|
|
2396
|
+
class j {
|
|
2397
2397
|
constructor(e = {}) {
|
|
2398
2398
|
this.config = {
|
|
2399
2399
|
enableCache: !0,
|
|
@@ -2408,7 +2408,7 @@ class W {
|
|
|
2408
2408
|
enableAdaptiveMemory: !0,
|
|
2409
2409
|
// Enable adaptive memory management
|
|
2410
2410
|
...e
|
|
2411
|
-
}, this.eventCache = new
|
|
2411
|
+
}, this.eventCache = new $(this.config.cacheCapacity), this.queryCache = new $(Math.floor(this.config.cacheCapacity / 2)), this.dateRangeCache = new $(Math.floor(this.config.cacheCapacity / 4)), this.config.enableAdaptiveMemory && (this.memoryManager = new N({
|
|
2412
2412
|
checkInterval: 3e4,
|
|
2413
2413
|
memoryThreshold: 0.75,
|
|
2414
2414
|
criticalThreshold: 0.9
|
|
@@ -2445,11 +2445,11 @@ class W {
|
|
|
2445
2445
|
return t();
|
|
2446
2446
|
const s = performance.now();
|
|
2447
2447
|
try {
|
|
2448
|
-
const i = t(),
|
|
2449
|
-
return this.recordMetric(e,
|
|
2448
|
+
const i = t(), r = performance.now() - s;
|
|
2449
|
+
return this.recordMetric(e, r), i;
|
|
2450
2450
|
} catch (i) {
|
|
2451
|
-
const
|
|
2452
|
-
throw this.recordMetric(e,
|
|
2451
|
+
const r = performance.now() - s;
|
|
2452
|
+
throw this.recordMetric(e, r, !0), i;
|
|
2453
2453
|
}
|
|
2454
2454
|
}
|
|
2455
2455
|
/**
|
|
@@ -2463,11 +2463,11 @@ class W {
|
|
|
2463
2463
|
return await t();
|
|
2464
2464
|
const s = performance.now();
|
|
2465
2465
|
try {
|
|
2466
|
-
const i = await t(),
|
|
2467
|
-
return this.recordMetric(e,
|
|
2466
|
+
const i = await t(), r = performance.now() - s;
|
|
2467
|
+
return this.recordMetric(e, r), i;
|
|
2468
2468
|
} catch (i) {
|
|
2469
|
-
const
|
|
2470
|
-
throw this.recordMetric(e,
|
|
2469
|
+
const r = performance.now() - s;
|
|
2470
|
+
throw this.recordMetric(e, r, !0), i;
|
|
2471
2471
|
}
|
|
2472
2472
|
}
|
|
2473
2473
|
/**
|
|
@@ -2560,17 +2560,17 @@ class W {
|
|
|
2560
2560
|
if (i.pending)
|
|
2561
2561
|
return this.pendingIndexes.get(e);
|
|
2562
2562
|
i.pending = !0;
|
|
2563
|
-
const
|
|
2563
|
+
const r = new Promise((a) => {
|
|
2564
2564
|
setTimeout(() => {
|
|
2565
|
-
const
|
|
2565
|
+
const n = /* @__PURE__ */ new Set(), o = new Date(t);
|
|
2566
2566
|
for (; o <= s; ) {
|
|
2567
2567
|
const c = o.toDateString();
|
|
2568
|
-
i.indexed.has(c) || (
|
|
2568
|
+
i.indexed.has(c) || (n.add(c), i.indexed.add(c)), o.setDate(o.getDate() + 1);
|
|
2569
2569
|
}
|
|
2570
|
-
i.pending = !1, this.pendingIndexes.delete(e), n
|
|
2570
|
+
i.pending = !1, this.pendingIndexes.delete(e), a(n);
|
|
2571
2571
|
}, 0);
|
|
2572
2572
|
});
|
|
2573
|
-
return this.pendingIndexes.set(e,
|
|
2573
|
+
return this.pendingIndexes.set(e, r), r;
|
|
2574
2574
|
}
|
|
2575
2575
|
/**
|
|
2576
2576
|
* Get month key for date
|
|
@@ -2587,21 +2587,21 @@ class W {
|
|
|
2587
2587
|
*/
|
|
2588
2588
|
cache(e, t, s = "event") {
|
|
2589
2589
|
if (!this.config.enableCache) return;
|
|
2590
|
-
let i,
|
|
2590
|
+
let i, r;
|
|
2591
2591
|
switch (s) {
|
|
2592
2592
|
case "event":
|
|
2593
|
-
i = this.eventCache,
|
|
2593
|
+
i = this.eventCache, r = "events";
|
|
2594
2594
|
break;
|
|
2595
2595
|
case "query":
|
|
2596
|
-
i = this.queryCache,
|
|
2596
|
+
i = this.queryCache, r = "queries";
|
|
2597
2597
|
break;
|
|
2598
2598
|
case "dateRange":
|
|
2599
|
-
i = this.dateRangeCache,
|
|
2599
|
+
i = this.dateRangeCache, r = "dateRanges";
|
|
2600
2600
|
break;
|
|
2601
2601
|
default:
|
|
2602
2602
|
return;
|
|
2603
2603
|
}
|
|
2604
|
-
i.put(e, t), this.memoryManager && this.memoryManager.touchCache(
|
|
2604
|
+
i.put(e, t), this.memoryManager && this.memoryManager.touchCache(r);
|
|
2605
2605
|
}
|
|
2606
2606
|
/**
|
|
2607
2607
|
* Get from cache
|
|
@@ -2651,14 +2651,14 @@ class W {
|
|
|
2651
2651
|
processBatch() {
|
|
2652
2652
|
if (this.batchTimer && (clearTimeout(this.batchTimer), this.batchTimer = null), this.batchQueue.length === 0) return;
|
|
2653
2653
|
const e = this.batchQueue.splice(0), t = this.batchCallbacks.splice(0), s = [], i = [];
|
|
2654
|
-
e.forEach((
|
|
2654
|
+
e.forEach((r, a) => {
|
|
2655
2655
|
try {
|
|
2656
|
-
s[
|
|
2657
|
-
} catch (
|
|
2658
|
-
i[
|
|
2656
|
+
s[a] = r();
|
|
2657
|
+
} catch (n) {
|
|
2658
|
+
i[a] = n;
|
|
2659
2659
|
}
|
|
2660
|
-
}), t.forEach((
|
|
2661
|
-
i[
|
|
2660
|
+
}), t.forEach((r, a) => {
|
|
2661
|
+
i[a] ? r.reject(i[a]) : r.resolve(s[a]);
|
|
2662
2662
|
});
|
|
2663
2663
|
}
|
|
2664
2664
|
/**
|
|
@@ -2700,7 +2700,7 @@ class W {
|
|
|
2700
2700
|
this.cleanupTimer && (clearInterval(this.cleanupTimer), this.cleanupTimer = null), this.batchTimer && (clearTimeout(this.batchTimer), this.batchTimer = null), this.eventCache.clear(), this.queryCache.clear(), this.dateRangeCache.clear(), this.lazyIndexes.clear(), this.pendingIndexes.clear();
|
|
2701
2701
|
}
|
|
2702
2702
|
}
|
|
2703
|
-
class
|
|
2703
|
+
class W {
|
|
2704
2704
|
/**
|
|
2705
2705
|
* Create a new ConflictDetector
|
|
2706
2706
|
* @param {import('../events/EventStore.js').EventStore} eventStore - Event store instance
|
|
@@ -2727,16 +2727,16 @@ class j {
|
|
|
2727
2727
|
};
|
|
2728
2728
|
if (!e.start || !e.end)
|
|
2729
2729
|
throw new Error("Event must have start and end dates");
|
|
2730
|
-
const i = [],
|
|
2730
|
+
const i = [], r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), n = new Date(e.start.getTime() - s.bufferMinutes * 6e4), o = new Date(e.end.getTime() + s.bufferMinutes * 6e4), c = this.eventStore.getEventsInRange(n, o, !1).filter((l) => !(l.id === e.id || s.excludeEventIds.includes(l.id) || !s.includeStatuses.includes(l.status) || s.ignoreAllDay && (l.allDay || e.allDay) || l.status === "cancelled"));
|
|
2731
2731
|
for (const l of c) {
|
|
2732
2732
|
const d = this._detectEventConflicts(
|
|
2733
2733
|
e,
|
|
2734
2734
|
l,
|
|
2735
2735
|
s
|
|
2736
2736
|
);
|
|
2737
|
-
d.length > 0 && (i.push(...d),
|
|
2737
|
+
d.length > 0 && (i.push(...d), r.add(e.id), r.add(l.id), e.attendees && e.attendees.forEach((h) => a.add(h.email)), l.attendees && l.attendees.forEach((h) => a.add(h.email)));
|
|
2738
2738
|
}
|
|
2739
|
-
return this._buildConflictSummary(i,
|
|
2739
|
+
return this._buildConflictSummary(i, r, a);
|
|
2740
2740
|
}
|
|
2741
2741
|
/**
|
|
2742
2742
|
* Check for conflicts between two specific events
|
|
@@ -2764,20 +2764,20 @@ class j {
|
|
|
2764
2764
|
* @returns {Array<{start: Date, end: Date, eventIds: string[]}>} Busy periods
|
|
2765
2765
|
*/
|
|
2766
2766
|
getBusyPeriods(e, t, s, i = {}) {
|
|
2767
|
-
const
|
|
2767
|
+
const r = {
|
|
2768
2768
|
includeStatuses: ["confirmed", "tentative"],
|
|
2769
2769
|
mergePeriods: !0,
|
|
2770
2770
|
...i
|
|
2771
|
-
},
|
|
2772
|
-
return this.eventStore.getEventsInRange(t, s, !1).filter((c) => !
|
|
2771
|
+
}, a = [];
|
|
2772
|
+
return this.eventStore.getEventsInRange(t, s, !1).filter((c) => !r.includeStatuses.includes(c.status) || c.status === "cancelled" ? !1 : c.attendees && c.attendees.some(
|
|
2773
2773
|
(l) => e.includes(l.email)
|
|
2774
2774
|
)).forEach((c) => {
|
|
2775
|
-
|
|
2775
|
+
a.push({
|
|
2776
2776
|
start: c.start,
|
|
2777
2777
|
end: c.end,
|
|
2778
2778
|
eventIds: [c.id]
|
|
2779
2779
|
});
|
|
2780
|
-
}),
|
|
2780
|
+
}), r.mergePeriods && a.length > 1 ? this._mergeBusyPeriods(a) : a.sort((c, l) => c.start - l.start);
|
|
2781
2781
|
}
|
|
2782
2782
|
/**
|
|
2783
2783
|
* Get free time slots
|
|
@@ -2788,23 +2788,23 @@ class j {
|
|
|
2788
2788
|
* @returns {Array<{start: Date, end: Date}>} Free time slots
|
|
2789
2789
|
*/
|
|
2790
2790
|
getFreePeriods(e, t, s, i = {}) {
|
|
2791
|
-
const
|
|
2791
|
+
const r = {
|
|
2792
2792
|
attendeeEmails: [],
|
|
2793
2793
|
businessHoursOnly: !1,
|
|
2794
2794
|
businessHours: { start: "09:00", end: "17:00" },
|
|
2795
2795
|
excludeWeekends: !1,
|
|
2796
2796
|
...i
|
|
2797
|
-
},
|
|
2797
|
+
}, a = [], n = r.attendeeEmails.length > 0 ? this.getBusyPeriods(r.attendeeEmails, e, t) : this._getAllBusyPeriods(e, t);
|
|
2798
2798
|
let o = new Date(e);
|
|
2799
|
-
for (const c of
|
|
2800
|
-
o < c.start && (c.start - o) / 6e4 >= s && (!
|
|
2799
|
+
for (const c of n)
|
|
2800
|
+
o < c.start && (c.start - o) / 6e4 >= s && (!r.businessHoursOnly || this._isWithinBusinessHours(o, c.start, r)) && a.push({
|
|
2801
2801
|
start: new Date(o),
|
|
2802
2802
|
end: new Date(c.start)
|
|
2803
2803
|
}), o = new Date(Math.max(o.getTime(), c.end.getTime()));
|
|
2804
|
-
return o < t && (t - o) / 6e4 >= s && (!
|
|
2804
|
+
return o < t && (t - o) / 6e4 >= s && (!r.businessHoursOnly || this._isWithinBusinessHours(o, t, r)) && a.push({
|
|
2805
2805
|
start: new Date(o),
|
|
2806
2806
|
end: new Date(t)
|
|
2807
|
-
}),
|
|
2807
|
+
}), a;
|
|
2808
2808
|
}
|
|
2809
2809
|
/**
|
|
2810
2810
|
* Detect conflicts between two events
|
|
@@ -2817,18 +2817,18 @@ class j {
|
|
|
2817
2817
|
t,
|
|
2818
2818
|
s.bufferMinutes
|
|
2819
2819
|
)) {
|
|
2820
|
-
const
|
|
2821
|
-
if (i.push(
|
|
2822
|
-
const
|
|
2823
|
-
i.push(...
|
|
2820
|
+
const a = this._createTimeConflict(e, t);
|
|
2821
|
+
if (i.push(a), s.checkAttendees) {
|
|
2822
|
+
const n = this._checkAttendeeConflicts(e, t);
|
|
2823
|
+
i.push(...n);
|
|
2824
2824
|
}
|
|
2825
2825
|
if (s.checkResources) {
|
|
2826
|
-
const
|
|
2827
|
-
i.push(...
|
|
2826
|
+
const n = this._checkResourceConflicts(e, t);
|
|
2827
|
+
i.push(...n);
|
|
2828
2828
|
}
|
|
2829
2829
|
if (s.checkLocation) {
|
|
2830
|
-
const
|
|
2831
|
-
|
|
2830
|
+
const n = this._checkLocationConflict(e, t);
|
|
2831
|
+
n && i.push(n);
|
|
2832
2832
|
}
|
|
2833
2833
|
}
|
|
2834
2834
|
return i;
|
|
@@ -2838,26 +2838,26 @@ class j {
|
|
|
2838
2838
|
* @private
|
|
2839
2839
|
*/
|
|
2840
2840
|
_checkTimeOverlap(e, t, s = 0) {
|
|
2841
|
-
const i = s * 6e4,
|
|
2842
|
-
return !(
|
|
2841
|
+
const i = s * 6e4, r = e.start.getTime() - i, a = e.end.getTime() + i, n = t.start.getTime(), o = t.end.getTime();
|
|
2842
|
+
return !(a <= n || o <= r);
|
|
2843
2843
|
}
|
|
2844
2844
|
/**
|
|
2845
2845
|
* Create time conflict details
|
|
2846
2846
|
* @private
|
|
2847
2847
|
*/
|
|
2848
2848
|
_createTimeConflict(e, t) {
|
|
2849
|
-
const s = new Date(Math.max(e.start.getTime(), t.start.getTime())), i = new Date(Math.min(e.end.getTime(), t.end.getTime())),
|
|
2850
|
-
let
|
|
2851
|
-
return
|
|
2849
|
+
const s = new Date(Math.max(e.start.getTime(), t.start.getTime())), i = new Date(Math.min(e.end.getTime(), t.end.getTime())), r = (i - s) / 6e4;
|
|
2850
|
+
let a = "low";
|
|
2851
|
+
return r >= 60 ? a = "high" : r >= 30 && (a = "medium"), e.status === "confirmed" && t.status === "confirmed" && (a = a === "low" ? "medium" : a === "medium" ? "high" : "critical"), {
|
|
2852
2852
|
id: `conflict_${++this.conflictIdCounter}`,
|
|
2853
2853
|
type: "time",
|
|
2854
|
-
severity:
|
|
2854
|
+
severity: a,
|
|
2855
2855
|
eventId: e.id,
|
|
2856
2856
|
conflictingEventId: t.id,
|
|
2857
2857
|
description: `Time overlap: ${e.title} conflicts with ${t.title}`,
|
|
2858
2858
|
overlapStart: s,
|
|
2859
2859
|
overlapEnd: i,
|
|
2860
|
-
overlapMinutes:
|
|
2860
|
+
overlapMinutes: r,
|
|
2861
2861
|
metadata: {
|
|
2862
2862
|
event1Title: e.title,
|
|
2863
2863
|
event2Title: t.title,
|
|
@@ -2875,18 +2875,18 @@ class j {
|
|
|
2875
2875
|
if (!e.attendees || !t.attendees)
|
|
2876
2876
|
return s;
|
|
2877
2877
|
const i = [];
|
|
2878
|
-
for (const
|
|
2879
|
-
for (const
|
|
2880
|
-
|
|
2878
|
+
for (const r of e.attendees)
|
|
2879
|
+
for (const a of t.attendees)
|
|
2880
|
+
r.email === a.email && i.push(r.email);
|
|
2881
2881
|
if (i.length > 0) {
|
|
2882
|
-
let
|
|
2883
|
-
i.some((
|
|
2884
|
-
const o = e.attendees.find((l) => l.email ===
|
|
2882
|
+
let r = "medium";
|
|
2883
|
+
i.some((n) => {
|
|
2884
|
+
const o = e.attendees.find((l) => l.email === n), c = t.attendees.find((l) => l.email === n);
|
|
2885
2885
|
return (o == null ? void 0 : o.responseStatus) === "accepted" && (c == null ? void 0 : c.responseStatus) === "accepted";
|
|
2886
|
-
}) && (
|
|
2886
|
+
}) && (r = "critical"), s.push({
|
|
2887
2887
|
id: `conflict_${++this.conflictIdCounter}`,
|
|
2888
2888
|
type: "attendee",
|
|
2889
|
-
severity:
|
|
2889
|
+
severity: r,
|
|
2890
2890
|
eventId: e.id,
|
|
2891
2891
|
conflictingEventId: t.id,
|
|
2892
2892
|
description: `Attendee conflict: ${i.length} attendee(s) double-booked`,
|
|
@@ -2904,10 +2904,10 @@ class j {
|
|
|
2904
2904
|
* @private
|
|
2905
2905
|
*/
|
|
2906
2906
|
_checkResourceConflicts(e, t) {
|
|
2907
|
-
var
|
|
2908
|
-
const s = [], i = ((
|
|
2907
|
+
var a, n;
|
|
2908
|
+
const s = [], i = ((a = e.attendees) == null ? void 0 : a.filter((o) => o.resource)) || [], r = ((n = t.attendees) == null ? void 0 : n.filter((o) => o.resource)) || [];
|
|
2909
2909
|
for (const o of i)
|
|
2910
|
-
for (const c of
|
|
2910
|
+
for (const c of r)
|
|
2911
2911
|
o.email === c.email && s.push({
|
|
2912
2912
|
id: `conflict_${++this.conflictIdCounter}`,
|
|
2913
2913
|
type: "resource",
|
|
@@ -2950,15 +2950,15 @@ class j {
|
|
|
2950
2950
|
* @private
|
|
2951
2951
|
*/
|
|
2952
2952
|
_buildConflictSummary(e, t, s) {
|
|
2953
|
-
const i = {},
|
|
2954
|
-
for (const
|
|
2955
|
-
i[
|
|
2953
|
+
const i = {}, r = {};
|
|
2954
|
+
for (const a of e)
|
|
2955
|
+
i[a.type] = (i[a.type] || 0) + 1, r[a.severity] = (r[a.severity] || 0) + 1;
|
|
2956
2956
|
return {
|
|
2957
2957
|
hasConflicts: e.length > 0,
|
|
2958
2958
|
totalConflicts: e.length,
|
|
2959
2959
|
conflicts: e,
|
|
2960
2960
|
conflictsByType: i,
|
|
2961
|
-
conflictsBySeverity:
|
|
2961
|
+
conflictsBySeverity: r,
|
|
2962
2962
|
affectedEventIds: Array.from(t),
|
|
2963
2963
|
affectedAttendees: Array.from(s)
|
|
2964
2964
|
};
|
|
@@ -2972,8 +2972,8 @@ class j {
|
|
|
2972
2972
|
e.sort((s, i) => s.start - i.start);
|
|
2973
2973
|
const t = [e[0]];
|
|
2974
2974
|
for (let s = 1; s < e.length; s++) {
|
|
2975
|
-
const i = e[s],
|
|
2976
|
-
i.start <=
|
|
2975
|
+
const i = e[s], r = t[t.length - 1];
|
|
2976
|
+
i.start <= r.end ? (r.end = new Date(Math.max(r.end.getTime(), i.end.getTime())), r.eventIds.push(...i.eventIds)) : t.push(i);
|
|
2977
2977
|
}
|
|
2978
2978
|
return t;
|
|
2979
2979
|
}
|
|
@@ -2986,15 +2986,15 @@ class j {
|
|
|
2986
2986
|
start: i.start,
|
|
2987
2987
|
end: i.end,
|
|
2988
2988
|
eventIds: [i.id]
|
|
2989
|
-
})).sort((i,
|
|
2989
|
+
})).sort((i, r) => i.start - r.start);
|
|
2990
2990
|
}
|
|
2991
2991
|
/**
|
|
2992
2992
|
* Check if time period is within business hours
|
|
2993
2993
|
* @private
|
|
2994
2994
|
*/
|
|
2995
2995
|
_isWithinBusinessHours(e, t, s) {
|
|
2996
|
-
const i = e.getHours(),
|
|
2997
|
-
return i >=
|
|
2996
|
+
const i = e.getHours(), r = t.getHours(), a = parseInt(s.businessHours.start.split(":")[0]), n = parseInt(s.businessHours.end.split(":")[0]);
|
|
2997
|
+
return i >= a && r <= n;
|
|
2998
2998
|
}
|
|
2999
2999
|
}
|
|
3000
3000
|
class Z {
|
|
@@ -3010,7 +3010,7 @@ class Z {
|
|
|
3010
3010
|
byCategory: /* @__PURE__ */ new Map(),
|
|
3011
3011
|
/** @type {Map<string, Set<string>>} Status -> Set of event IDs */
|
|
3012
3012
|
byStatus: /* @__PURE__ */ new Map()
|
|
3013
|
-
}, this.timezoneManager = new
|
|
3013
|
+
}, this.timezoneManager = new A(), this.defaultTimezone = e.timezone || this.timezoneManager.getSystemTimezone(), this.optimizer = new j(e.performance), this.conflictDetector = new W(this), this.isBatchMode = !1, this.batchNotifications = [], this.batchBackup = null, this.version = 0, this.listeners = /* @__PURE__ */ new Set();
|
|
3014
3014
|
}
|
|
3015
3015
|
/**
|
|
3016
3016
|
* Add an event to the store
|
|
@@ -3020,7 +3020,7 @@ class Z {
|
|
|
3020
3020
|
*/
|
|
3021
3021
|
addEvent(e) {
|
|
3022
3022
|
return this.optimizer.measure("addEvent", () => {
|
|
3023
|
-
if (e instanceof
|
|
3023
|
+
if (e instanceof T || (e = new T(e)), this.events.has(e.id))
|
|
3024
3024
|
throw new Error(`Event with id ${e.id} already exists`);
|
|
3025
3025
|
return this.events.set(e.id, e), this.optimizer.cache(e.id, e, "event"), this._indexEvent(e), this.isBatchMode ? this.batchNotifications.push({
|
|
3026
3026
|
type: "add",
|
|
@@ -3094,7 +3094,7 @@ class Z {
|
|
|
3094
3094
|
let t = Array.from(this.events.values());
|
|
3095
3095
|
if (e.start || e.end) {
|
|
3096
3096
|
const s = e.start ? new Date(e.start) : null, i = e.end ? new Date(e.end) : null;
|
|
3097
|
-
t = t.filter((
|
|
3097
|
+
t = t.filter((r) => !(s && r.end < s || i && r.start > i));
|
|
3098
3098
|
}
|
|
3099
3099
|
if (e.date) {
|
|
3100
3100
|
const s = new Date(e.date);
|
|
@@ -3102,7 +3102,7 @@ class Z {
|
|
|
3102
3102
|
}
|
|
3103
3103
|
if (e.month && e.year) {
|
|
3104
3104
|
const s = `${e.year}-${String(e.month).padStart(2, "0")}`, i = this.indices.byMonth.get(s) || /* @__PURE__ */ new Set();
|
|
3105
|
-
t = t.filter((
|
|
3105
|
+
t = t.filter((r) => i.has(r.id));
|
|
3106
3106
|
}
|
|
3107
3107
|
return e.hasOwnProperty("allDay") && (t = t.filter((s) => s.allDay === e.allDay)), e.hasOwnProperty("recurring") && (t = t.filter((s) => s.recurring === e.recurring)), e.status && (t = t.filter((s) => s.status === e.status)), e.categories && e.categories.length > 0 && (t = t.filter(
|
|
3108
3108
|
(s) => e.matchAllCategories ? s.hasAllCategories(e.categories) : s.hasAnyCategory(e.categories)
|
|
@@ -3130,30 +3130,30 @@ class Z {
|
|
|
3130
3130
|
* @returns {Event[]} Events occurring on the date, sorted by start time
|
|
3131
3131
|
*/
|
|
3132
3132
|
getEventsForDate(e, t = null) {
|
|
3133
|
-
t = t || this.defaultTimezone,
|
|
3133
|
+
t = t || this.defaultTimezone, u.getLocalDateString(e);
|
|
3134
3134
|
const s = /* @__PURE__ */ new Set(), i = new Date(e);
|
|
3135
3135
|
for (let l = -1; l <= 1; l++) {
|
|
3136
3136
|
const d = new Date(i);
|
|
3137
3137
|
d.setDate(d.getDate() + l);
|
|
3138
|
-
const h =
|
|
3139
|
-
|
|
3138
|
+
const h = u.getLocalDateString(d), g = this.indices.byDate.get(h);
|
|
3139
|
+
g && g.forEach((b) => s.add(b));
|
|
3140
3140
|
}
|
|
3141
|
-
const
|
|
3142
|
-
|
|
3143
|
-
const
|
|
3141
|
+
const r = `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`, a = this.indices.byMonth.get(r);
|
|
3142
|
+
a && a.forEach((l) => s.add(l));
|
|
3143
|
+
const n = [], o = new Date(e);
|
|
3144
3144
|
o.setHours(0, 0, 0, 0);
|
|
3145
3145
|
const c = new Date(e);
|
|
3146
3146
|
c.setHours(23, 59, 59, 999);
|
|
3147
3147
|
for (const l of s) {
|
|
3148
3148
|
const d = this.events.get(l);
|
|
3149
3149
|
if (d) {
|
|
3150
|
-
const h = d.getStartInTimezone(t),
|
|
3151
|
-
h <= c &&
|
|
3150
|
+
const h = d.getStartInTimezone(t), g = d.getEndInTimezone(t);
|
|
3151
|
+
h <= c && g >= o && n.push(d);
|
|
3152
3152
|
}
|
|
3153
3153
|
}
|
|
3154
|
-
return
|
|
3155
|
-
const h = l.getStartInTimezone(t),
|
|
3156
|
-
return
|
|
3154
|
+
return n.sort((l, d) => {
|
|
3155
|
+
const h = l.getStartInTimezone(t), g = d.getStartInTimezone(t), b = h - g;
|
|
3156
|
+
return b !== 0 ? b : d.duration - l.duration;
|
|
3157
3157
|
});
|
|
3158
3158
|
}
|
|
3159
3159
|
/**
|
|
@@ -3164,14 +3164,14 @@ class Z {
|
|
|
3164
3164
|
* @returns {Event[]} Array of overlapping events
|
|
3165
3165
|
*/
|
|
3166
3166
|
getOverlappingEvents(e, t, s = null) {
|
|
3167
|
-
const i = [],
|
|
3168
|
-
return
|
|
3167
|
+
const i = [], r = u.startOfDay(e), a = u.endOfDay(t), n = u.getDateRange(r, a), o = /* @__PURE__ */ new Set();
|
|
3168
|
+
return n.forEach((c) => {
|
|
3169
3169
|
const l = c.toDateString();
|
|
3170
3170
|
(this.indices.byDate.get(l) || /* @__PURE__ */ new Set()).forEach((h) => {
|
|
3171
3171
|
if (!o.has(h) && h !== s) {
|
|
3172
3172
|
o.add(h);
|
|
3173
|
-
const
|
|
3174
|
-
|
|
3173
|
+
const g = this.events.get(h);
|
|
3174
|
+
g && g.overlaps({ start: e, end: t }) && i.push(g);
|
|
3175
3175
|
}
|
|
3176
3176
|
});
|
|
3177
3177
|
}), i.sort((c, l) => c.start - l.start);
|
|
@@ -3195,20 +3195,20 @@ class Z {
|
|
|
3195
3195
|
*/
|
|
3196
3196
|
getOverlapGroups(e, t = !0) {
|
|
3197
3197
|
let s = this.getEventsForDate(e);
|
|
3198
|
-
t && (s = s.filter((
|
|
3199
|
-
const i = [],
|
|
3200
|
-
return s.forEach((
|
|
3201
|
-
if (
|
|
3202
|
-
const
|
|
3203
|
-
|
|
3198
|
+
t && (s = s.filter((a) => !a.allDay));
|
|
3199
|
+
const i = [], r = /* @__PURE__ */ new Set();
|
|
3200
|
+
return s.forEach((a) => {
|
|
3201
|
+
if (r.has(a.id)) return;
|
|
3202
|
+
const n = [a];
|
|
3203
|
+
r.add(a.id);
|
|
3204
3204
|
let o = 0;
|
|
3205
|
-
for (; o <
|
|
3206
|
-
const c =
|
|
3205
|
+
for (; o < n.length; ) {
|
|
3206
|
+
const c = n[o];
|
|
3207
3207
|
s.forEach((l) => {
|
|
3208
|
-
!
|
|
3208
|
+
!r.has(l.id) && c.overlaps(l) && (n.push(l), r.add(l.id));
|
|
3209
3209
|
}), o++;
|
|
3210
3210
|
}
|
|
3211
|
-
i.push(
|
|
3211
|
+
i.push(n);
|
|
3212
3212
|
}), i;
|
|
3213
3213
|
}
|
|
3214
3214
|
/**
|
|
@@ -3219,24 +3219,24 @@ class Z {
|
|
|
3219
3219
|
calculateEventPositions(e) {
|
|
3220
3220
|
const t = /* @__PURE__ */ new Map();
|
|
3221
3221
|
if (e.length === 0) return t;
|
|
3222
|
-
e.sort((
|
|
3223
|
-
const
|
|
3224
|
-
return
|
|
3222
|
+
e.sort((r, a) => {
|
|
3223
|
+
const n = r.start - a.start;
|
|
3224
|
+
return n !== 0 ? n : a.end - a.start - (r.end - r.start);
|
|
3225
3225
|
});
|
|
3226
3226
|
const s = [];
|
|
3227
|
-
e.forEach((
|
|
3228
|
-
let
|
|
3229
|
-
for (;
|
|
3230
|
-
|
|
3231
|
-
s[
|
|
3232
|
-
column:
|
|
3227
|
+
e.forEach((r) => {
|
|
3228
|
+
let a = 0;
|
|
3229
|
+
for (; a < s.length && s[a].some((c) => c.overlaps(r)); )
|
|
3230
|
+
a++;
|
|
3231
|
+
s[a] || (s[a] = []), s[a].push(r), t.set(r.id, {
|
|
3232
|
+
column: a,
|
|
3233
3233
|
totalColumns: 0
|
|
3234
3234
|
// Will be updated after all events are placed
|
|
3235
3235
|
});
|
|
3236
3236
|
});
|
|
3237
3237
|
const i = s.length;
|
|
3238
|
-
return t.forEach((
|
|
3239
|
-
|
|
3238
|
+
return t.forEach((r) => {
|
|
3239
|
+
r.totalColumns = i;
|
|
3240
3240
|
}), t;
|
|
3241
3241
|
}
|
|
3242
3242
|
/**
|
|
@@ -3249,15 +3249,15 @@ class Z {
|
|
|
3249
3249
|
*/
|
|
3250
3250
|
getEventsInRange(e, t, s = !0, i = null) {
|
|
3251
3251
|
typeof s == "string" && (i = s, s = !0), i = i || this.defaultTimezone;
|
|
3252
|
-
const
|
|
3253
|
-
start:
|
|
3254
|
-
end:
|
|
3252
|
+
const r = this.timezoneManager.toUTC(e, i), a = this.timezoneManager.toUTC(t, i), n = this.queryEvents({
|
|
3253
|
+
start: r,
|
|
3254
|
+
end: a,
|
|
3255
3255
|
sort: "start"
|
|
3256
3256
|
});
|
|
3257
3257
|
if (!s)
|
|
3258
|
-
return
|
|
3258
|
+
return n;
|
|
3259
3259
|
const o = [];
|
|
3260
|
-
return
|
|
3260
|
+
return n.forEach((c) => {
|
|
3261
3261
|
if (c.recurring && c.recurrenceRule) {
|
|
3262
3262
|
const l = this.expandRecurringEvent(c, e, t, i);
|
|
3263
3263
|
o.push(...l);
|
|
@@ -3280,12 +3280,12 @@ class Z {
|
|
|
3280
3280
|
if (!e.recurring || !e.recurrenceRule)
|
|
3281
3281
|
return [e];
|
|
3282
3282
|
i = i || this.defaultTimezone;
|
|
3283
|
-
const
|
|
3284
|
-
return Y.expandEvent(e, t, s).map((
|
|
3283
|
+
const r = e.timeZone || i;
|
|
3284
|
+
return Y.expandEvent(e, t, s).map((n, o) => e.clone({
|
|
3285
3285
|
id: `${e.id}_occurrence_${o}`,
|
|
3286
|
-
start:
|
|
3287
|
-
end:
|
|
3288
|
-
timeZone:
|
|
3286
|
+
start: n.start,
|
|
3287
|
+
end: n.end,
|
|
3288
|
+
timeZone: r,
|
|
3289
3289
|
metadata: {
|
|
3290
3290
|
...e.metadata,
|
|
3291
3291
|
recurringEventId: e.id,
|
|
@@ -3332,15 +3332,15 @@ class Z {
|
|
|
3332
3332
|
this._indexEventLazy(e);
|
|
3333
3333
|
return;
|
|
3334
3334
|
}
|
|
3335
|
-
const t = e.getStartInTimezone(e.timeZone), s = e.getEndInTimezone(e.endTimeZone || e.timeZone), i =
|
|
3336
|
-
|
|
3337
|
-
const c =
|
|
3335
|
+
const t = e.getStartInTimezone(e.timeZone), s = e.getEndInTimezone(e.endTimeZone || e.timeZone), i = u.startOfDay(t), r = u.endOfDay(s);
|
|
3336
|
+
u.getDateRange(i, r).forEach((o) => {
|
|
3337
|
+
const c = u.getLocalDateString(o);
|
|
3338
3338
|
this.indices.byDate.has(c) || this.indices.byDate.set(c, /* @__PURE__ */ new Set()), this.indices.byDate.get(c).add(e.id);
|
|
3339
|
-
}), `${i.getFullYear()}${String(i.getMonth() + 1).padStart(2, "0")}`, `${
|
|
3340
|
-
const
|
|
3341
|
-
for (;
|
|
3342
|
-
const o = `${
|
|
3343
|
-
this.indices.byMonth.has(o) || this.indices.byMonth.set(o, /* @__PURE__ */ new Set()), this.indices.byMonth.get(o).add(e.id),
|
|
3339
|
+
}), `${i.getFullYear()}${String(i.getMonth() + 1).padStart(2, "0")}`, `${r.getFullYear()}${String(r.getMonth() + 1).padStart(2, "0")}`;
|
|
3340
|
+
const n = new Date(i.getFullYear(), i.getMonth(), 1);
|
|
3341
|
+
for (; n <= r; ) {
|
|
3342
|
+
const o = `${n.getFullYear()}-${String(n.getMonth() + 1).padStart(2, "0")}`;
|
|
3343
|
+
this.indices.byMonth.has(o) || this.indices.byMonth.set(o, /* @__PURE__ */ new Set()), this.indices.byMonth.get(o).add(e.id), n.setMonth(n.getMonth() + 1);
|
|
3344
3344
|
}
|
|
3345
3345
|
e.categories && e.categories.length > 0 && e.categories.forEach((o) => {
|
|
3346
3346
|
this.indices.byCategory.has(o) || this.indices.byCategory.set(o, /* @__PURE__ */ new Set()), this.indices.byCategory.get(o).add(e.id);
|
|
@@ -3352,25 +3352,25 @@ class Z {
|
|
|
3352
3352
|
*/
|
|
3353
3353
|
_indexEventLazy(e) {
|
|
3354
3354
|
this.optimizer.createLazyIndexMarkers(e);
|
|
3355
|
-
const t = e.getStartInTimezone(e.timeZone), s = e.getEndInTimezone(e.endTimeZone || e.timeZone), i =
|
|
3356
|
-
if (
|
|
3355
|
+
const t = e.getStartInTimezone(e.timeZone), s = e.getEndInTimezone(e.endTimeZone || e.timeZone), i = u.startOfDay(t), r = u.endOfDay(s), a = new Date(i);
|
|
3356
|
+
if (a.setDate(a.getDate() + 7), u.getDateRange(
|
|
3357
3357
|
i,
|
|
3358
|
-
|
|
3358
|
+
a < r ? a : r
|
|
3359
3359
|
).forEach((c) => {
|
|
3360
|
-
const l =
|
|
3360
|
+
const l = u.getLocalDateString(c);
|
|
3361
3361
|
this.indices.byDate.has(l) || this.indices.byDate.set(l, /* @__PURE__ */ new Set()), this.indices.byDate.get(l).add(e.id);
|
|
3362
|
-
}),
|
|
3363
|
-
const c = new Date(
|
|
3364
|
-
c.setDate(c.getDate() - 7),
|
|
3362
|
+
}), r > a) {
|
|
3363
|
+
const c = new Date(r);
|
|
3364
|
+
c.setDate(c.getDate() - 7), u.getDateRange(
|
|
3365
3365
|
c > i ? c : i,
|
|
3366
|
-
|
|
3366
|
+
r
|
|
3367
3367
|
).forEach((d) => {
|
|
3368
|
-
const h =
|
|
3368
|
+
const h = u.getLocalDateString(d);
|
|
3369
3369
|
this.indices.byDate.has(h) || this.indices.byDate.set(h, /* @__PURE__ */ new Set()), this.indices.byDate.get(h).add(e.id);
|
|
3370
3370
|
});
|
|
3371
3371
|
}
|
|
3372
3372
|
const o = new Date(i.getFullYear(), i.getMonth(), 1);
|
|
3373
|
-
for (; o <=
|
|
3373
|
+
for (; o <= r; ) {
|
|
3374
3374
|
const c = `${o.getFullYear()}-${String(o.getMonth() + 1).padStart(2, "0")}`;
|
|
3375
3375
|
this.indices.byMonth.has(c) || this.indices.byMonth.set(c, /* @__PURE__ */ new Set()), this.indices.byMonth.get(c).add(e.id), o.setMonth(o.getMonth() + 1);
|
|
3376
3376
|
}
|
|
@@ -3483,8 +3483,8 @@ class Z {
|
|
|
3483
3483
|
for (const i of e)
|
|
3484
3484
|
try {
|
|
3485
3485
|
t.push(this.addEvent(i));
|
|
3486
|
-
} catch (
|
|
3487
|
-
s.push({ event: i, error:
|
|
3486
|
+
} catch (r) {
|
|
3487
|
+
s.push({ event: i, error: r.message });
|
|
3488
3488
|
}
|
|
3489
3489
|
return this.commitBatch(), s.length > 0 && console.warn(`Failed to add ${s.length} events:`, s), t;
|
|
3490
3490
|
});
|
|
@@ -3498,11 +3498,11 @@ class Z {
|
|
|
3498
3498
|
return this.optimizer.measure("updateEvents", () => {
|
|
3499
3499
|
this.startBatch();
|
|
3500
3500
|
const t = [], s = [];
|
|
3501
|
-
for (const { id: i, updates:
|
|
3501
|
+
for (const { id: i, updates: r } of e)
|
|
3502
3502
|
try {
|
|
3503
|
-
t.push(this.updateEvent(i,
|
|
3504
|
-
} catch (
|
|
3505
|
-
s.push({ id: i, error:
|
|
3503
|
+
t.push(this.updateEvent(i, r));
|
|
3504
|
+
} catch (a) {
|
|
3505
|
+
s.push({ id: i, error: a.message });
|
|
3506
3506
|
}
|
|
3507
3507
|
return this.commitBatch(), s.length > 0 && console.warn(`Failed to update ${s.length} events:`, s), t;
|
|
3508
3508
|
});
|
|
@@ -3544,15 +3544,15 @@ class Z {
|
|
|
3544
3544
|
let t = 0;
|
|
3545
3545
|
for (const [s, i] of this.indices.byDate)
|
|
3546
3546
|
if (new Date(s) < e) {
|
|
3547
|
-
let
|
|
3548
|
-
for (const
|
|
3549
|
-
const o = this.events.get(
|
|
3547
|
+
let a = !1;
|
|
3548
|
+
for (const n of i) {
|
|
3549
|
+
const o = this.events.get(n);
|
|
3550
3550
|
if (o && o.end >= e) {
|
|
3551
|
-
|
|
3551
|
+
a = !0;
|
|
3552
3552
|
break;
|
|
3553
3553
|
}
|
|
3554
3554
|
}
|
|
3555
|
-
|
|
3555
|
+
a || (this.indices.byDate.delete(s), t++);
|
|
3556
3556
|
}
|
|
3557
3557
|
return console.log(`Optimized indices: removed ${t} old date entries`), t;
|
|
3558
3558
|
}
|
|
@@ -3580,10 +3580,10 @@ class Z {
|
|
|
3580
3580
|
* @returns {import('../../types.js').ConflictDetails[]} Conflicts between events
|
|
3581
3581
|
*/
|
|
3582
3582
|
checkEventPairConflicts(e, t, s = {}) {
|
|
3583
|
-
const i = this.getEvent(e),
|
|
3584
|
-
if (!i || !
|
|
3583
|
+
const i = this.getEvent(e), r = this.getEvent(t);
|
|
3584
|
+
if (!i || !r)
|
|
3585
3585
|
throw new Error("One or both events not found");
|
|
3586
|
-
return this.conflictDetector.checkEventPairConflicts(i,
|
|
3586
|
+
return this.conflictDetector.checkEventPairConflicts(i, r, s);
|
|
3587
3587
|
}
|
|
3588
3588
|
/**
|
|
3589
3589
|
* Get all conflicts in a date range
|
|
@@ -3593,23 +3593,23 @@ class Z {
|
|
|
3593
3593
|
* @returns {import('../../types.js').ConflictSummary} All conflicts in range
|
|
3594
3594
|
*/
|
|
3595
3595
|
getAllConflicts(e, t, s = {}) {
|
|
3596
|
-
const i = this.getEventsInRange(e, t, !1),
|
|
3597
|
-
for (let
|
|
3598
|
-
for (let o =
|
|
3599
|
-
const c = `${i[
|
|
3600
|
-
if (!
|
|
3601
|
-
|
|
3596
|
+
const i = this.getEventsInRange(e, t, !1), r = [], a = /* @__PURE__ */ new Set();
|
|
3597
|
+
for (let n = 0; n < i.length; n++)
|
|
3598
|
+
for (let o = n + 1; o < i.length; o++) {
|
|
3599
|
+
const c = `${i[n].id}-${i[o].id}`;
|
|
3600
|
+
if (!a.has(c)) {
|
|
3601
|
+
a.add(c);
|
|
3602
3602
|
const l = this.conflictDetector.checkEventPairConflicts(
|
|
3603
|
-
i[
|
|
3603
|
+
i[n],
|
|
3604
3604
|
i[o],
|
|
3605
3605
|
s
|
|
3606
3606
|
);
|
|
3607
|
-
|
|
3607
|
+
r.push(...l);
|
|
3608
3608
|
}
|
|
3609
3609
|
}
|
|
3610
3610
|
return this.conflictDetector._buildConflictSummary(
|
|
3611
|
-
|
|
3612
|
-
new Set(i.map((
|
|
3611
|
+
r,
|
|
3612
|
+
new Set(i.map((n) => n.id)),
|
|
3613
3613
|
/* @__PURE__ */ new Set()
|
|
3614
3614
|
);
|
|
3615
3615
|
}
|
|
@@ -3658,10 +3658,10 @@ class Z {
|
|
|
3658
3658
|
findEventsWithConflicts(e = {}) {
|
|
3659
3659
|
const t = [], s = this.getAllEvents();
|
|
3660
3660
|
for (const i of s) {
|
|
3661
|
-
const
|
|
3662
|
-
|
|
3661
|
+
const r = this.checkConflicts(i, e);
|
|
3662
|
+
r.hasConflicts && t.push({
|
|
3663
3663
|
event: i,
|
|
3664
|
-
conflicts:
|
|
3664
|
+
conflicts: r.conflicts
|
|
3665
3665
|
});
|
|
3666
3666
|
}
|
|
3667
3667
|
return t;
|
|
@@ -3895,8 +3895,8 @@ let q = class {
|
|
|
3895
3895
|
this.listeners.has(i) || this.listeners.set(i, /* @__PURE__ */ new Set()), this.listeners.get(i).add(t);
|
|
3896
3896
|
}), () => {
|
|
3897
3897
|
s.forEach((i) => {
|
|
3898
|
-
const
|
|
3899
|
-
|
|
3898
|
+
const r = this.listeners.get(i);
|
|
3899
|
+
r && (r.delete(t), r.size === 0 && this.listeners.delete(i));
|
|
3900
3900
|
});
|
|
3901
3901
|
};
|
|
3902
3902
|
}
|
|
@@ -3981,24 +3981,24 @@ let q = class {
|
|
|
3981
3981
|
if (s.add(e), s.add(t), Array.isArray(e)) {
|
|
3982
3982
|
if (!Array.isArray(t) || e.length !== t.length)
|
|
3983
3983
|
return s.delete(e), s.delete(t), !1;
|
|
3984
|
-
for (let
|
|
3985
|
-
if (!this._deepEqual(e[
|
|
3984
|
+
for (let a = 0; a < e.length; a++)
|
|
3985
|
+
if (!this._deepEqual(e[a], t[a], s))
|
|
3986
3986
|
return s.delete(e), s.delete(t), !1;
|
|
3987
3987
|
return s.delete(e), s.delete(t), !0;
|
|
3988
3988
|
}
|
|
3989
3989
|
if (e instanceof Date && t instanceof Date) {
|
|
3990
|
-
const
|
|
3991
|
-
return s.delete(e), s.delete(t),
|
|
3990
|
+
const a = e.getTime() === t.getTime();
|
|
3991
|
+
return s.delete(e), s.delete(t), a;
|
|
3992
3992
|
}
|
|
3993
|
-
const i = Object.keys(e),
|
|
3994
|
-
if (i.length !==
|
|
3993
|
+
const i = Object.keys(e), r = Object.keys(t);
|
|
3994
|
+
if (i.length !== r.length)
|
|
3995
3995
|
return s.delete(e), s.delete(t), !1;
|
|
3996
|
-
i.sort(),
|
|
3997
|
-
for (let
|
|
3998
|
-
if (i[
|
|
3996
|
+
i.sort(), r.sort();
|
|
3997
|
+
for (let a = 0; a < i.length; a++)
|
|
3998
|
+
if (i[a] !== r[a])
|
|
3999
3999
|
return s.delete(e), s.delete(t), !1;
|
|
4000
|
-
for (const
|
|
4001
|
-
if (!this._deepEqual(e[
|
|
4000
|
+
for (const a of i)
|
|
4001
|
+
if (!this._deepEqual(e[a], t[a], s))
|
|
4002
4002
|
return s.delete(e), s.delete(t), !1;
|
|
4003
4003
|
return s.delete(e), s.delete(t), !0;
|
|
4004
4004
|
}
|
|
@@ -4022,11 +4022,11 @@ let q = class {
|
|
|
4022
4022
|
}
|
|
4023
4023
|
for (const [s, i] of this.listeners)
|
|
4024
4024
|
if (e[s] !== t[s])
|
|
4025
|
-
for (const
|
|
4025
|
+
for (const r of i)
|
|
4026
4026
|
try {
|
|
4027
|
-
|
|
4028
|
-
} catch (
|
|
4029
|
-
console.error(`Error in state listener for key "${s}":`,
|
|
4027
|
+
r(t[s], e[s], t, e);
|
|
4028
|
+
} catch (a) {
|
|
4029
|
+
console.error(`Error in state listener for key "${s}":`, a);
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
4032
|
};
|
|
@@ -4036,7 +4036,7 @@ class K {
|
|
|
4036
4036
|
* @param {import('../../types.js').CalendarConfig} [config={}] - Configuration options
|
|
4037
4037
|
*/
|
|
4038
4038
|
constructor(e = {}) {
|
|
4039
|
-
this.timezoneManager = new
|
|
4039
|
+
this.timezoneManager = new A(), this.config = {
|
|
4040
4040
|
view: "month",
|
|
4041
4041
|
date: /* @__PURE__ */ new Date(),
|
|
4042
4042
|
weekStartsOn: 0,
|
|
@@ -4142,7 +4142,7 @@ class K {
|
|
|
4142
4142
|
* @returns {import('../events/Event.js').Event} The added event
|
|
4143
4143
|
*/
|
|
4144
4144
|
addEvent(e) {
|
|
4145
|
-
!(e instanceof
|
|
4145
|
+
!(e instanceof T) && !e.timeZone && (e = { ...e, timeZone: this.config.timeZone });
|
|
4146
4146
|
const t = this.eventStore.addEvent(e);
|
|
4147
4147
|
return this._emit("eventAdd", { event: t }), t;
|
|
4148
4148
|
}
|
|
@@ -4344,32 +4344,32 @@ class K {
|
|
|
4344
4344
|
* @private
|
|
4345
4345
|
*/
|
|
4346
4346
|
_getMonthViewData(e) {
|
|
4347
|
-
const t = e.getFullYear(), s = e.getMonth(), i = this.state.get("weekStartsOn"),
|
|
4347
|
+
const t = e.getFullYear(), s = e.getMonth(), i = this.state.get("weekStartsOn"), r = this.state.get("fixedWeekCount"), a = new Date(t, s, 1), n = new Date(t, s + 1, 0), o = u.startOfWeek(a, i), c = [];
|
|
4348
4348
|
let l = new Date(o);
|
|
4349
|
-
const d =
|
|
4349
|
+
const d = r ? 6 : Math.ceil((n.getDate() + u.getDayOfWeek(a, i)) / 7);
|
|
4350
4350
|
for (let h = 0; h < d; h++) {
|
|
4351
|
-
const
|
|
4352
|
-
weekNumber:
|
|
4351
|
+
const g = {
|
|
4352
|
+
weekNumber: u.getWeekNumber(l),
|
|
4353
4353
|
days: []
|
|
4354
4354
|
};
|
|
4355
|
-
for (let
|
|
4356
|
-
const
|
|
4357
|
-
|
|
4358
|
-
date:
|
|
4359
|
-
dayOfMonth:
|
|
4360
|
-
isCurrentMonth:
|
|
4361
|
-
isToday:
|
|
4362
|
-
isWeekend:
|
|
4363
|
-
events: this.getEventsForDate(
|
|
4364
|
-
}), l =
|
|
4355
|
+
for (let b = 0; b < 7; b++) {
|
|
4356
|
+
const f = new Date(l), D = f.getMonth() === s, x = u.isToday(f), M = f.getDay() === 0 || f.getDay() === 6;
|
|
4357
|
+
g.days.push({
|
|
4358
|
+
date: f,
|
|
4359
|
+
dayOfMonth: f.getDate(),
|
|
4360
|
+
isCurrentMonth: D,
|
|
4361
|
+
isToday: x,
|
|
4362
|
+
isWeekend: M,
|
|
4363
|
+
events: this.getEventsForDate(f)
|
|
4364
|
+
}), l = u.addDays(l, 1);
|
|
4365
4365
|
}
|
|
4366
|
-
c.push(
|
|
4366
|
+
c.push(g);
|
|
4367
4367
|
}
|
|
4368
4368
|
return {
|
|
4369
4369
|
type: "month",
|
|
4370
4370
|
year: t,
|
|
4371
4371
|
month: s,
|
|
4372
|
-
monthName:
|
|
4372
|
+
monthName: u.getMonthName(e, this.state.get("locale")),
|
|
4373
4373
|
weeks: c,
|
|
4374
4374
|
startDate: o,
|
|
4375
4375
|
endDate: new Date(l.getTime() - 1)
|
|
@@ -4381,28 +4381,28 @@ class K {
|
|
|
4381
4381
|
* @private
|
|
4382
4382
|
*/
|
|
4383
4383
|
_getWeekViewData(e) {
|
|
4384
|
-
const t = this.state.get("weekStartsOn"), s =
|
|
4385
|
-
for (let
|
|
4386
|
-
const o = new Date(
|
|
4387
|
-
|
|
4384
|
+
const t = this.state.get("weekStartsOn"), s = u.startOfWeek(e, t), i = u.endOfWeek(e, t), r = [], a = new Date(s);
|
|
4385
|
+
for (let n = 0; n < 7; n++) {
|
|
4386
|
+
const o = new Date(a);
|
|
4387
|
+
r.push({
|
|
4388
4388
|
date: o,
|
|
4389
4389
|
dayOfMonth: o.getDate(),
|
|
4390
4390
|
dayOfWeek: o.getDay(),
|
|
4391
|
-
dayName:
|
|
4392
|
-
isToday:
|
|
4391
|
+
dayName: u.getDayName(o, this.state.get("locale")),
|
|
4392
|
+
isToday: u.isToday(o),
|
|
4393
4393
|
isWeekend: o.getDay() === 0 || o.getDay() === 6,
|
|
4394
4394
|
events: this.getEventsForDate(o),
|
|
4395
4395
|
// Add overlap groups for positioning overlapping events
|
|
4396
4396
|
overlapGroups: this.eventStore.getOverlapGroups(o, !0),
|
|
4397
4397
|
getEventPositions: (c) => this.eventStore.calculateEventPositions(c)
|
|
4398
|
-
}),
|
|
4398
|
+
}), a.setDate(a.getDate() + 1);
|
|
4399
4399
|
}
|
|
4400
4400
|
return {
|
|
4401
4401
|
type: "week",
|
|
4402
|
-
weekNumber:
|
|
4402
|
+
weekNumber: u.getWeekNumber(s),
|
|
4403
4403
|
startDate: s,
|
|
4404
4404
|
endDate: i,
|
|
4405
|
-
days:
|
|
4405
|
+
days: r
|
|
4406
4406
|
};
|
|
4407
4407
|
}
|
|
4408
4408
|
/**
|
|
@@ -4410,24 +4410,24 @@ class K {
|
|
|
4410
4410
|
* @private
|
|
4411
4411
|
*/
|
|
4412
4412
|
_getDayViewData(e) {
|
|
4413
|
-
const t = this.getEventsForDate(e), s = t.filter((
|
|
4414
|
-
for (let
|
|
4415
|
-
const
|
|
4416
|
-
|
|
4413
|
+
const t = this.getEventsForDate(e), s = t.filter((a) => a.allDay), i = t.filter((a) => !a.allDay), r = [];
|
|
4414
|
+
for (let a = 0; a < 24; a++) {
|
|
4415
|
+
const n = new Date(e);
|
|
4416
|
+
n.setHours(a, 0, 0, 0);
|
|
4417
4417
|
const o = new Date(e);
|
|
4418
|
-
o.setHours(
|
|
4419
|
-
hour:
|
|
4420
|
-
time:
|
|
4421
|
-
events: i.filter((c) => c.start < o && c.end >
|
|
4418
|
+
o.setHours(a + 1, 0, 0, 0), r.push({
|
|
4419
|
+
hour: a,
|
|
4420
|
+
time: u.formatTime(n, this.state.get("locale")),
|
|
4421
|
+
events: i.filter((c) => c.start < o && c.end > n)
|
|
4422
4422
|
});
|
|
4423
4423
|
}
|
|
4424
4424
|
return {
|
|
4425
4425
|
type: "day",
|
|
4426
4426
|
date: e,
|
|
4427
|
-
dayName:
|
|
4428
|
-
isToday:
|
|
4427
|
+
dayName: u.getDayName(e, this.state.get("locale")),
|
|
4428
|
+
isToday: u.isToday(e),
|
|
4429
4429
|
allDayEvents: s,
|
|
4430
|
-
hours:
|
|
4430
|
+
hours: r
|
|
4431
4431
|
};
|
|
4432
4432
|
}
|
|
4433
4433
|
/**
|
|
@@ -4439,24 +4439,24 @@ class K {
|
|
|
4439
4439
|
t.setHours(0, 0, 0, 0);
|
|
4440
4440
|
const s = new Date(t);
|
|
4441
4441
|
s.setDate(s.getDate() + 30);
|
|
4442
|
-
const i = this.getEventsInRange(t, s),
|
|
4443
|
-
i.forEach((
|
|
4444
|
-
const o =
|
|
4445
|
-
|
|
4446
|
-
date: new Date(
|
|
4442
|
+
const i = this.getEventsInRange(t, s), r = /* @__PURE__ */ new Map();
|
|
4443
|
+
i.forEach((n) => {
|
|
4444
|
+
const o = n.start.toDateString();
|
|
4445
|
+
r.has(o) || r.set(o, {
|
|
4446
|
+
date: new Date(n.start),
|
|
4447
4447
|
events: []
|
|
4448
|
-
}),
|
|
4448
|
+
}), r.get(o).events.push(n);
|
|
4449
4449
|
});
|
|
4450
|
-
const
|
|
4451
|
-
...
|
|
4452
|
-
dayName:
|
|
4453
|
-
isToday:
|
|
4450
|
+
const a = Array.from(r.values()).sort((n, o) => n.date - o.date).map((n) => ({
|
|
4451
|
+
...n,
|
|
4452
|
+
dayName: u.getDayName(n.date, this.state.get("locale")),
|
|
4453
|
+
isToday: u.isToday(n.date)
|
|
4454
4454
|
}));
|
|
4455
4455
|
return {
|
|
4456
4456
|
type: "list",
|
|
4457
4457
|
startDate: t,
|
|
4458
4458
|
endDate: s,
|
|
4459
|
-
days:
|
|
4459
|
+
days: a,
|
|
4460
4460
|
totalEvents: i.length
|
|
4461
4461
|
};
|
|
4462
4462
|
}
|
|
@@ -4516,8 +4516,8 @@ class K {
|
|
|
4516
4516
|
s && s.forEach((i) => {
|
|
4517
4517
|
try {
|
|
4518
4518
|
i(t);
|
|
4519
|
-
} catch (
|
|
4520
|
-
console.error(`Error in event listener for "${e}":`,
|
|
4519
|
+
} catch (r) {
|
|
4520
|
+
console.error(`Error in event listener for "${e}":`, r);
|
|
4521
4521
|
}
|
|
4522
4522
|
});
|
|
4523
4523
|
}
|
|
@@ -4567,16 +4567,16 @@ class G {
|
|
|
4567
4567
|
* @returns {Function} Unsubscribe function
|
|
4568
4568
|
*/
|
|
4569
4569
|
on(e, t, s = {}) {
|
|
4570
|
-
const { once: i = !1, priority:
|
|
4570
|
+
const { once: i = !1, priority: r = 0 } = s;
|
|
4571
4571
|
if (e.includes("*")) {
|
|
4572
|
-
const o = { pattern: e, handler: t, once: i, priority:
|
|
4572
|
+
const o = { pattern: e, handler: t, once: i, priority: r };
|
|
4573
4573
|
return this.wildcardHandlers.add(o), () => this.wildcardHandlers.delete(o);
|
|
4574
4574
|
}
|
|
4575
4575
|
this.events.has(e) || this.events.set(e, []);
|
|
4576
|
-
const
|
|
4577
|
-
return
|
|
4578
|
-
const o =
|
|
4579
|
-
o > -1 &&
|
|
4576
|
+
const a = { handler: t, once: i, priority: r }, n = this.events.get(e);
|
|
4577
|
+
return n.push(a), n.sort((o, c) => c.priority - o.priority), () => {
|
|
4578
|
+
const o = n.indexOf(a);
|
|
4579
|
+
o > -1 && n.splice(o, 1);
|
|
4580
4580
|
};
|
|
4581
4581
|
}
|
|
4582
4582
|
/**
|
|
@@ -4590,7 +4590,7 @@ class G {
|
|
|
4590
4590
|
*/
|
|
4591
4591
|
off(e, t) {
|
|
4592
4592
|
if (!this.events.has(e)) return;
|
|
4593
|
-
const s = this.events.get(e), i = s.findIndex((
|
|
4593
|
+
const s = this.events.get(e), i = s.findIndex((r) => r.handler === t);
|
|
4594
4594
|
i > -1 && s.splice(i, 1), s.length === 0 && this.events.delete(e);
|
|
4595
4595
|
}
|
|
4596
4596
|
/**
|
|
@@ -4602,12 +4602,12 @@ class G {
|
|
|
4602
4602
|
async emit(e, t) {
|
|
4603
4603
|
const s = [];
|
|
4604
4604
|
if (this.events.has(e)) {
|
|
4605
|
-
const
|
|
4606
|
-
for (const
|
|
4607
|
-
const { handler:
|
|
4608
|
-
o && this.off(e,
|
|
4605
|
+
const r = [...this.events.get(e)];
|
|
4606
|
+
for (const a of r) {
|
|
4607
|
+
const { handler: n, once: o } = a;
|
|
4608
|
+
o && this.off(e, n);
|
|
4609
4609
|
try {
|
|
4610
|
-
const c =
|
|
4610
|
+
const c = n(t, e);
|
|
4611
4611
|
c instanceof Promise && s.push(c);
|
|
4612
4612
|
} catch (c) {
|
|
4613
4613
|
console.error(`Error in event handler for ${e}:`, c);
|
|
@@ -4615,18 +4615,18 @@ class G {
|
|
|
4615
4615
|
}
|
|
4616
4616
|
}
|
|
4617
4617
|
const i = [];
|
|
4618
|
-
for (const
|
|
4619
|
-
if (this.matchesPattern(e,
|
|
4620
|
-
const { handler:
|
|
4621
|
-
|
|
4618
|
+
for (const r of [...this.wildcardHandlers])
|
|
4619
|
+
if (this.matchesPattern(e, r.pattern)) {
|
|
4620
|
+
const { handler: a, once: n } = r;
|
|
4621
|
+
n && i.push(r);
|
|
4622
4622
|
try {
|
|
4623
|
-
const o =
|
|
4623
|
+
const o = a(t, e);
|
|
4624
4624
|
o instanceof Promise && s.push(o);
|
|
4625
4625
|
} catch (o) {
|
|
4626
4626
|
console.error(`Error in wildcard handler for ${e}:`, o);
|
|
4627
4627
|
}
|
|
4628
4628
|
}
|
|
4629
|
-
return i.forEach((
|
|
4629
|
+
return i.forEach((r) => this.wildcardHandlers.delete(r)), Promise.all(s);
|
|
4630
4630
|
}
|
|
4631
4631
|
/**
|
|
4632
4632
|
* Check if event name matches a pattern
|
|
@@ -4653,7 +4653,7 @@ class G {
|
|
|
4653
4653
|
return this.events.has(e) ? this.events.get(e).length : 0;
|
|
4654
4654
|
}
|
|
4655
4655
|
}
|
|
4656
|
-
const
|
|
4656
|
+
const y = new G();
|
|
4657
4657
|
class Q {
|
|
4658
4658
|
constructor(e = {}) {
|
|
4659
4659
|
this.calendar = new K({
|
|
@@ -4702,62 +4702,62 @@ class Q {
|
|
|
4702
4702
|
(i) => e[i] !== t[i]
|
|
4703
4703
|
);
|
|
4704
4704
|
s.forEach((i) => {
|
|
4705
|
-
|
|
4705
|
+
y.emit(`state:${i}:changed`, {
|
|
4706
4706
|
oldValue: e[i],
|
|
4707
4707
|
newValue: t[i],
|
|
4708
4708
|
state: t
|
|
4709
4709
|
});
|
|
4710
|
-
}), s.length > 0 &&
|
|
4710
|
+
}), s.length > 0 && y.emit("state:changed", { oldState: e, newState: t, changedKeys: s });
|
|
4711
4711
|
}
|
|
4712
4712
|
// Calendar operations
|
|
4713
4713
|
setView(e) {
|
|
4714
|
-
this.calendar.setView(e), this.setState({ view: e }),
|
|
4714
|
+
this.calendar.setView(e), this.setState({ view: e }), y.emit("view:changed", { view: e });
|
|
4715
4715
|
}
|
|
4716
4716
|
getView() {
|
|
4717
4717
|
return this.state.view;
|
|
4718
4718
|
}
|
|
4719
4719
|
setDate(e) {
|
|
4720
|
-
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
4720
|
+
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), y.emit("date:changed", { date: this.state.currentDate });
|
|
4721
4721
|
}
|
|
4722
4722
|
getCurrentDate() {
|
|
4723
4723
|
return this.state.currentDate;
|
|
4724
4724
|
}
|
|
4725
4725
|
// Navigation
|
|
4726
4726
|
next() {
|
|
4727
|
-
this.calendar.next(), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
4727
|
+
this.calendar.next(), this.setState({ currentDate: this.calendar.getCurrentDate() }), y.emit("navigation:next", { date: this.state.currentDate });
|
|
4728
4728
|
}
|
|
4729
4729
|
previous() {
|
|
4730
|
-
this.calendar.previous(), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
4730
|
+
this.calendar.previous(), this.setState({ currentDate: this.calendar.getCurrentDate() }), y.emit("navigation:previous", { date: this.state.currentDate });
|
|
4731
4731
|
}
|
|
4732
4732
|
today() {
|
|
4733
|
-
this.calendar.today(), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
4733
|
+
this.calendar.today(), this.setState({ currentDate: this.calendar.getCurrentDate() }), y.emit("navigation:today", { date: this.state.currentDate });
|
|
4734
4734
|
}
|
|
4735
4735
|
goToDate(e) {
|
|
4736
|
-
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
4736
|
+
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), y.emit("navigation:goto", { date: this.state.currentDate });
|
|
4737
4737
|
}
|
|
4738
4738
|
// Event management
|
|
4739
4739
|
addEvent(e) {
|
|
4740
4740
|
const t = this.calendar.addEvent(e);
|
|
4741
4741
|
if (!t)
|
|
4742
|
-
return console.error("Failed to add event to calendar"),
|
|
4742
|
+
return console.error("Failed to add event to calendar"), y.emit("event:error", { action: "add", event: e, error: "Failed to add event" }), null;
|
|
4743
4743
|
const s = [...this.state.events, t];
|
|
4744
|
-
return this.setState({ events: s }),
|
|
4744
|
+
return this.setState({ events: s }), y.emit("event:added", { event: t }), t;
|
|
4745
4745
|
}
|
|
4746
4746
|
updateEvent(e, t) {
|
|
4747
4747
|
const s = this.calendar.updateEvent(e, t);
|
|
4748
4748
|
if (!s)
|
|
4749
|
-
return console.error(`Failed to update event: ${e}`),
|
|
4750
|
-
const i = this.state.events.findIndex((
|
|
4749
|
+
return console.error(`Failed to update event: ${e}`), y.emit("event:error", { action: "update", eventId: e, updates: t, error: "Event not found in calendar" }), null;
|
|
4750
|
+
const i = this.state.events.findIndex((a) => a.id === e);
|
|
4751
4751
|
if (i === -1)
|
|
4752
|
-
return console.error(`Event ${e} not found in state`),
|
|
4753
|
-
const
|
|
4754
|
-
return
|
|
4752
|
+
return console.error(`Event ${e} not found in state`), y.emit("event:error", { action: "update", eventId: e, error: "Event not found in state" }), null;
|
|
4753
|
+
const r = [...this.state.events];
|
|
4754
|
+
return r[i] = s, this.setState({ events: r }), y.emit("event:updated", { event: s }), s;
|
|
4755
4755
|
}
|
|
4756
4756
|
deleteEvent(e) {
|
|
4757
4757
|
if (!this.calendar.removeEvent(e))
|
|
4758
|
-
return console.error(`Failed to delete event: ${e}`),
|
|
4758
|
+
return console.error(`Failed to delete event: ${e}`), y.emit("event:error", { action: "delete", eventId: e, error: "Event not found" }), !1;
|
|
4759
4759
|
const s = this.state.events.filter((i) => i.id !== e);
|
|
4760
|
-
return this.setState({ events: s }),
|
|
4760
|
+
return this.setState({ events: s }), y.emit("event:deleted", { eventId: e }), !0;
|
|
4761
4761
|
}
|
|
4762
4762
|
getEvents() {
|
|
4763
4763
|
return this.calendar.getEvents();
|
|
@@ -4778,20 +4778,20 @@ class Q {
|
|
|
4778
4778
|
const t = (s = this.state.selectedDate) == null ? void 0 : s.toDateString();
|
|
4779
4779
|
if (e.weeks && (e.weeks = e.weeks.map((i) => ({
|
|
4780
4780
|
...i,
|
|
4781
|
-
days: i.days.map((
|
|
4782
|
-
const
|
|
4781
|
+
days: i.days.map((r) => {
|
|
4782
|
+
const a = new Date(r.date);
|
|
4783
4783
|
return {
|
|
4784
|
-
...
|
|
4785
|
-
isSelected:
|
|
4786
|
-
events:
|
|
4784
|
+
...r,
|
|
4785
|
+
isSelected: a.toDateString() === t,
|
|
4786
|
+
events: r.events || this.getEventsForDate(a)
|
|
4787
4787
|
};
|
|
4788
4788
|
})
|
|
4789
4789
|
}))), e.days && (e.days = e.days.map((i) => {
|
|
4790
|
-
const
|
|
4790
|
+
const r = new Date(i.date);
|
|
4791
4791
|
return {
|
|
4792
4792
|
...i,
|
|
4793
|
-
isSelected:
|
|
4794
|
-
events: i.events || this.getEventsForDate(
|
|
4793
|
+
isSelected: r.toDateString() === t,
|
|
4794
|
+
events: i.events || this.getEventsForDate(r)
|
|
4795
4795
|
};
|
|
4796
4796
|
})), e.date && !e.days && !e.weeks) {
|
|
4797
4797
|
const i = new Date(e.date);
|
|
@@ -4801,20 +4801,20 @@ class Q {
|
|
|
4801
4801
|
}
|
|
4802
4802
|
// Selection management
|
|
4803
4803
|
selectEvent(e) {
|
|
4804
|
-
this.setState({ selectedEvent: e }),
|
|
4804
|
+
this.setState({ selectedEvent: e }), y.emit("event:selected", { event: e });
|
|
4805
4805
|
}
|
|
4806
4806
|
selectEventById(e) {
|
|
4807
4807
|
const t = this.state.events.find((s) => s.id === e);
|
|
4808
4808
|
t && this.selectEvent(t);
|
|
4809
4809
|
}
|
|
4810
4810
|
deselectEvent() {
|
|
4811
|
-
this.setState({ selectedEvent: null }),
|
|
4811
|
+
this.setState({ selectedEvent: null }), y.emit("event:deselected", {});
|
|
4812
4812
|
}
|
|
4813
4813
|
selectDate(e) {
|
|
4814
|
-
this.setState({ selectedDate: e }),
|
|
4814
|
+
this.setState({ selectedDate: e }), y.emit("date:selected", { date: e });
|
|
4815
4815
|
}
|
|
4816
4816
|
deselectDate() {
|
|
4817
|
-
this.setState({ selectedDate: null }),
|
|
4817
|
+
this.setState({ selectedDate: null }), y.emit("date:deselected", {});
|
|
4818
4818
|
}
|
|
4819
4819
|
// Utility methods
|
|
4820
4820
|
isToday(e) {
|
|
@@ -4834,7 +4834,7 @@ class Q {
|
|
|
4834
4834
|
}
|
|
4835
4835
|
// Error handling
|
|
4836
4836
|
setError(e) {
|
|
4837
|
-
this.setState({ error: e }), e &&
|
|
4837
|
+
this.setState({ error: e }), e && y.emit("error", { error: e });
|
|
4838
4838
|
}
|
|
4839
4839
|
clearError() {
|
|
4840
4840
|
this.setState({ error: null });
|
|
@@ -4848,7 +4848,7 @@ class Q {
|
|
|
4848
4848
|
this.subscribers.clear(), this.state = null, this.calendar = null;
|
|
4849
4849
|
}
|
|
4850
4850
|
}
|
|
4851
|
-
class
|
|
4851
|
+
class w extends u {
|
|
4852
4852
|
/**
|
|
4853
4853
|
* Format date for display
|
|
4854
4854
|
*/
|
|
@@ -4871,20 +4871,20 @@ class b extends f {
|
|
|
4871
4871
|
hour: "numeric",
|
|
4872
4872
|
minute: "2-digit"
|
|
4873
4873
|
}
|
|
4874
|
-
},
|
|
4875
|
-
return new Intl.DateTimeFormat(s,
|
|
4874
|
+
}, r = i[t] || i.default;
|
|
4875
|
+
return new Intl.DateTimeFormat(s, r).format(e);
|
|
4876
4876
|
}
|
|
4877
4877
|
/**
|
|
4878
4878
|
* Format time for display
|
|
4879
4879
|
*/
|
|
4880
4880
|
static formatTime(e, t = !0, s = !1, i = "en-US") {
|
|
4881
4881
|
if (!e) return "";
|
|
4882
|
-
const
|
|
4882
|
+
const r = {
|
|
4883
4883
|
hour: "numeric",
|
|
4884
4884
|
minute: t ? "2-digit" : void 0,
|
|
4885
4885
|
hour12: !s
|
|
4886
4886
|
};
|
|
4887
|
-
return new Intl.DateTimeFormat(i,
|
|
4887
|
+
return new Intl.DateTimeFormat(i, r).format(e);
|
|
4888
4888
|
}
|
|
4889
4889
|
/**
|
|
4890
4890
|
* Format date range for display
|
|
@@ -4903,15 +4903,15 @@ class b extends f {
|
|
|
4903
4903
|
if (!e) return "";
|
|
4904
4904
|
const i = this.formatTime(e, !0, !1, s);
|
|
4905
4905
|
if (!t) return i;
|
|
4906
|
-
const
|
|
4907
|
-
return `${i} - ${
|
|
4906
|
+
const r = this.formatTime(t, !0, !1, s);
|
|
4907
|
+
return `${i} - ${r}`;
|
|
4908
4908
|
}
|
|
4909
4909
|
/**
|
|
4910
4910
|
* Get relative time string (e.g., "2 hours ago", "in 3 days")
|
|
4911
4911
|
*/
|
|
4912
4912
|
static getRelativeTime(e, t = /* @__PURE__ */ new Date(), s = "en-US") {
|
|
4913
|
-
const i = new Intl.RelativeTimeFormat(s, { numeric: "auto" }),
|
|
4914
|
-
return Math.abs(
|
|
4913
|
+
const i = new Intl.RelativeTimeFormat(s, { numeric: "auto" }), r = e - t, a = Math.floor(r / 1e3), n = Math.floor(a / 60), o = Math.floor(n / 60), c = Math.floor(o / 24), l = Math.floor(c / 7), d = Math.floor(c / 30), h = Math.floor(c / 365);
|
|
4914
|
+
return Math.abs(a) < 60 ? i.format(a, "second") : Math.abs(n) < 60 ? i.format(n, "minute") : Math.abs(o) < 24 ? i.format(o, "hour") : Math.abs(c) < 7 ? i.format(c, "day") : Math.abs(l) < 4 ? i.format(l, "week") : Math.abs(d) < 12 ? i.format(d, "month") : i.format(h, "year");
|
|
4915
4915
|
}
|
|
4916
4916
|
/**
|
|
4917
4917
|
* Check if date is today
|
|
@@ -4957,9 +4957,9 @@ class b extends f {
|
|
|
4957
4957
|
* Parse time string (e.g., "14:30" or "2:30 PM")
|
|
4958
4958
|
*/
|
|
4959
4959
|
static parseTimeString(e, t = /* @__PURE__ */ new Date()) {
|
|
4960
|
-
const s = new Date(t), [i,
|
|
4961
|
-
let o =
|
|
4962
|
-
return
|
|
4960
|
+
const s = new Date(t), [i, r] = e.split(/\s+/), [a, n] = i.split(":").map(Number);
|
|
4961
|
+
let o = a;
|
|
4962
|
+
return r && (r.toLowerCase() === "pm" && a < 12 ? o = a + 12 : r.toLowerCase() === "am" && a === 12 && (o = 0)), s.setHours(o, n || 0, 0, 0), s;
|
|
4963
4963
|
}
|
|
4964
4964
|
}
|
|
4965
4965
|
class C {
|
|
@@ -4968,20 +4968,20 @@ class C {
|
|
|
4968
4968
|
*/
|
|
4969
4969
|
static createElement(e, t = {}, s = []) {
|
|
4970
4970
|
const i = document.createElement(e);
|
|
4971
|
-
return Object.entries(t).forEach(([
|
|
4972
|
-
if (
|
|
4973
|
-
i.className =
|
|
4974
|
-
else if (
|
|
4975
|
-
Object.assign(i.style,
|
|
4976
|
-
else if (
|
|
4977
|
-
i.setAttribute(
|
|
4978
|
-
else if (
|
|
4979
|
-
const
|
|
4980
|
-
i.addEventListener(
|
|
4971
|
+
return Object.entries(t).forEach(([r, a]) => {
|
|
4972
|
+
if (r === "className")
|
|
4973
|
+
i.className = a;
|
|
4974
|
+
else if (r === "style" && typeof a == "object")
|
|
4975
|
+
Object.assign(i.style, a);
|
|
4976
|
+
else if (r.startsWith("data-"))
|
|
4977
|
+
i.setAttribute(r, a);
|
|
4978
|
+
else if (r.startsWith("on") && typeof a == "function") {
|
|
4979
|
+
const n = r.slice(2).toLowerCase();
|
|
4980
|
+
i.addEventListener(n, a);
|
|
4981
4981
|
} else
|
|
4982
|
-
i[
|
|
4983
|
-
}), s.forEach((
|
|
4984
|
-
typeof
|
|
4982
|
+
i[r] = a;
|
|
4983
|
+
}), s.forEach((r) => {
|
|
4984
|
+
typeof r == "string" ? i.appendChild(document.createTextNode(r)) : r instanceof Node && i.appendChild(r);
|
|
4985
4985
|
}), i;
|
|
4986
4986
|
}
|
|
4987
4987
|
/**
|
|
@@ -5000,11 +5000,11 @@ class C {
|
|
|
5000
5000
|
* Delegate event handling
|
|
5001
5001
|
*/
|
|
5002
5002
|
static delegate(e, t, s, i) {
|
|
5003
|
-
const
|
|
5004
|
-
const
|
|
5005
|
-
|
|
5003
|
+
const r = (a) => {
|
|
5004
|
+
const n = a.target.closest(t);
|
|
5005
|
+
n && e.contains(n) && i.call(n, a);
|
|
5006
5006
|
};
|
|
5007
|
-
return e.addEventListener(s,
|
|
5007
|
+
return e.addEventListener(s, r), () => e.removeEventListener(s, r);
|
|
5008
5008
|
}
|
|
5009
5009
|
/**
|
|
5010
5010
|
* Get element position relative to viewport
|
|
@@ -5031,8 +5031,8 @@ class C {
|
|
|
5031
5031
|
* Smooth scroll to element
|
|
5032
5032
|
*/
|
|
5033
5033
|
static scrollToElement(e, t = {}) {
|
|
5034
|
-
const { behavior: s = "smooth", block: i = "start", inline:
|
|
5035
|
-
e.scrollIntoView({ behavior: s, block: i, inline:
|
|
5034
|
+
const { behavior: s = "smooth", block: i = "start", inline: r = "nearest" } = t;
|
|
5035
|
+
e.scrollIntoView({ behavior: s, block: i, inline: r });
|
|
5036
5036
|
}
|
|
5037
5037
|
/**
|
|
5038
5038
|
* Get computed style value
|
|
@@ -5088,11 +5088,11 @@ class C {
|
|
|
5088
5088
|
*/
|
|
5089
5089
|
static debounce(e, t = 250) {
|
|
5090
5090
|
let s;
|
|
5091
|
-
return function(...
|
|
5092
|
-
const
|
|
5093
|
-
clearTimeout(s), e(...
|
|
5091
|
+
return function(...r) {
|
|
5092
|
+
const a = () => {
|
|
5093
|
+
clearTimeout(s), e(...r);
|
|
5094
5094
|
};
|
|
5095
|
-
clearTimeout(s), s = setTimeout(
|
|
5095
|
+
clearTimeout(s), s = setTimeout(a, t);
|
|
5096
5096
|
};
|
|
5097
5097
|
}
|
|
5098
5098
|
/**
|
|
@@ -5151,13 +5151,13 @@ class C {
|
|
|
5151
5151
|
);
|
|
5152
5152
|
if (t.length === 0)
|
|
5153
5153
|
return e.setAttribute("tabindex", "-1"), e.focus(), () => e.removeAttribute("tabindex");
|
|
5154
|
-
const s = t[0], i = t[t.length - 1],
|
|
5155
|
-
|
|
5154
|
+
const s = t[0], i = t[t.length - 1], r = (a) => {
|
|
5155
|
+
a.key === "Tab" && (a.shiftKey ? document.activeElement === s && (i == null || i.focus(), a.preventDefault()) : document.activeElement === i && (s == null || s.focus(), a.preventDefault()));
|
|
5156
5156
|
};
|
|
5157
|
-
return e.addEventListener("keydown",
|
|
5157
|
+
return e.addEventListener("keydown", r), s == null || s.focus(), () => e.removeEventListener("keydown", r);
|
|
5158
5158
|
}
|
|
5159
5159
|
}
|
|
5160
|
-
class
|
|
5160
|
+
class v {
|
|
5161
5161
|
/**
|
|
5162
5162
|
* Get CSS variable value
|
|
5163
5163
|
*/
|
|
@@ -5325,22 +5325,22 @@ class y {
|
|
|
5325
5325
|
* Darken color by percentage
|
|
5326
5326
|
*/
|
|
5327
5327
|
static darken(e, t) {
|
|
5328
|
-
const s = parseInt(e.replace("#", ""), 16), i = Math.round(2.55 * t),
|
|
5329
|
-
return "#" + (16777216 + (
|
|
5328
|
+
const s = parseInt(e.replace("#", ""), 16), i = Math.round(2.55 * t), r = (s >> 16) - i, a = (s >> 8 & 255) - i, n = (s & 255) - i;
|
|
5329
|
+
return "#" + (16777216 + (r < 255 ? r < 1 ? 0 : r : 255) * 65536 + (a < 255 ? a < 1 ? 0 : a : 255) * 256 + (n < 255 ? n < 1 ? 0 : n : 255)).toString(16).slice(1);
|
|
5330
5330
|
}
|
|
5331
5331
|
/**
|
|
5332
5332
|
* Lighten color by percentage
|
|
5333
5333
|
*/
|
|
5334
5334
|
static lighten(e, t) {
|
|
5335
|
-
const s = parseInt(e.replace("#", ""), 16), i = Math.round(2.55 * t),
|
|
5336
|
-
return "#" + (16777216 + (
|
|
5335
|
+
const s = parseInt(e.replace("#", ""), 16), i = Math.round(2.55 * t), r = (s >> 16) + i, a = (s >> 8 & 255) + i, n = (s & 255) + i;
|
|
5336
|
+
return "#" + (16777216 + (r < 255 ? r < 1 ? 0 : r : 255) * 65536 + (a < 255 ? a < 1 ? 0 : a : 255) * 256 + (n < 255 ? n < 1 ? 0 : n : 255)).toString(16).slice(1);
|
|
5337
5337
|
}
|
|
5338
5338
|
/**
|
|
5339
5339
|
* Get contrast color (black or white) for background
|
|
5340
5340
|
*/
|
|
5341
5341
|
static getContrastColor(e) {
|
|
5342
|
-
const t = e.replace("#", ""), s = parseInt(t.substr(0, 2), 16), i = parseInt(t.substr(2, 2), 16),
|
|
5343
|
-
return (s * 299 + i * 587 +
|
|
5342
|
+
const t = e.replace("#", ""), s = parseInt(t.substr(0, 2), 16), i = parseInt(t.substr(2, 2), 16), r = parseInt(t.substr(4, 2), 16);
|
|
5343
|
+
return (s * 299 + i * 587 + r * 114) / 1e3 >= 128 ? "#000000" : "#FFFFFF";
|
|
5344
5344
|
}
|
|
5345
5345
|
/**
|
|
5346
5346
|
* Sanitize color value to prevent CSS injection
|
|
@@ -5382,8 +5382,8 @@ class y {
|
|
|
5382
5382
|
* Convert hex to rgba
|
|
5383
5383
|
*/
|
|
5384
5384
|
static hexToRgba(e, t = 1) {
|
|
5385
|
-
const s = e.replace("#", ""), i = parseInt(s.substr(0, 2), 16),
|
|
5386
|
-
return `rgba(${i}, ${
|
|
5385
|
+
const s = e.replace("#", ""), i = parseInt(s.substr(0, 2), 16), r = parseInt(s.substr(2, 2), 16), a = parseInt(s.substr(4, 2), 16);
|
|
5386
|
+
return `rgba(${i}, ${r}, ${a}, ${t})`;
|
|
5387
5387
|
}
|
|
5388
5388
|
/**
|
|
5389
5389
|
* Generate grid styles
|
|
@@ -5494,7 +5494,7 @@ class y {
|
|
|
5494
5494
|
/**
|
|
5495
5495
|
* Default theme colors
|
|
5496
5496
|
*/
|
|
5497
|
-
|
|
5497
|
+
S(v, "colors", {
|
|
5498
5498
|
primary: "#3B82F6",
|
|
5499
5499
|
// Modern Blue
|
|
5500
5500
|
secondary: "#64748B",
|
|
@@ -5527,7 +5527,7 @@ M(y, "colors", {
|
|
|
5527
5527
|
}), /**
|
|
5528
5528
|
* Common CSS variables
|
|
5529
5529
|
*/
|
|
5530
|
-
|
|
5530
|
+
S(v, "cssVariables", {
|
|
5531
5531
|
// "Pro" Palette - Functional & Sharp
|
|
5532
5532
|
"--fc-primary-color": "#2563EB",
|
|
5533
5533
|
// International Blue (Focus)
|
|
@@ -5595,7 +5595,7 @@ M(y, "cssVariables", {
|
|
|
5595
5595
|
}), /**
|
|
5596
5596
|
* Get responsive breakpoints
|
|
5597
5597
|
*/
|
|
5598
|
-
|
|
5598
|
+
S(v, "breakpoints", {
|
|
5599
5599
|
xs: "320px",
|
|
5600
5600
|
sm: "576px",
|
|
5601
5601
|
md: "768px",
|
|
@@ -5603,7 +5603,7 @@ M(y, "breakpoints", {
|
|
|
5603
5603
|
xl: "1200px",
|
|
5604
5604
|
"2xl": "1400px"
|
|
5605
5605
|
});
|
|
5606
|
-
class J extends
|
|
5606
|
+
class J extends E {
|
|
5607
5607
|
constructor() {
|
|
5608
5608
|
super(), this._stateManager = null, this.viewData = null, this.config = {
|
|
5609
5609
|
maxEventsToShow: 3
|
|
@@ -5676,17 +5676,17 @@ class J extends T {
|
|
|
5676
5676
|
console.log("[MonthView] viewData from stateManager:", e), this.viewData = this.processViewData(e), console.log("[MonthView] processed viewData:", this.viewData), this.render(), console.log("[MonthView] render completed");
|
|
5677
5677
|
}
|
|
5678
5678
|
processViewData(e) {
|
|
5679
|
-
var i,
|
|
5679
|
+
var i, r;
|
|
5680
5680
|
if (!e || !e.weeks) return null;
|
|
5681
|
-
const t = (
|
|
5682
|
-
const o = new Date(
|
|
5681
|
+
const t = (r = (i = this.stateManager) == null ? void 0 : i.getState()) == null ? void 0 : r.selectedDate, s = e.weeks.map((a) => a.days.map((n) => {
|
|
5682
|
+
const o = new Date(n.date), c = t && o.toDateString() === t.toDateString(), l = n.events.map((d) => ({
|
|
5683
5683
|
...d,
|
|
5684
5684
|
textColor: this.getContrastingTextColor(d.backgroundColor)
|
|
5685
5685
|
}));
|
|
5686
5686
|
return {
|
|
5687
|
-
...
|
|
5687
|
+
...n,
|
|
5688
5688
|
date: o,
|
|
5689
|
-
isOtherMonth: !
|
|
5689
|
+
isOtherMonth: !n.isCurrentMonth,
|
|
5690
5690
|
isSelected: c,
|
|
5691
5691
|
events: l
|
|
5692
5692
|
};
|
|
@@ -5703,10 +5703,10 @@ class J extends T {
|
|
|
5703
5703
|
const t = e.charAt(0) === "#" ? e.substring(1) : e;
|
|
5704
5704
|
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(t))
|
|
5705
5705
|
return "white";
|
|
5706
|
-
const s = t.length === 3 ? t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, i = parseInt(s.substring(0, 2), 16),
|
|
5707
|
-
if (isNaN(i) || isNaN(
|
|
5706
|
+
const s = t.length === 3 ? t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, i = parseInt(s.substring(0, 2), 16), r = parseInt(s.substring(2, 4), 16), a = parseInt(s.substring(4, 6), 16);
|
|
5707
|
+
if (isNaN(i) || isNaN(r) || isNaN(a))
|
|
5708
5708
|
return "white";
|
|
5709
|
-
const o = [i / 255,
|
|
5709
|
+
const o = [i / 255, r / 255, a / 255].map((l) => l <= 0.03928 ? l / 12.92 : Math.pow((l + 0.055) / 1.055, 2.4));
|
|
5710
5710
|
return 0.2126 * o[0] + 0.7152 * o[1] + 0.0722 * o[2] > 0.179 ? "black" : "white";
|
|
5711
5711
|
}
|
|
5712
5712
|
isSelectedDate(e) {
|
|
@@ -5948,8 +5948,8 @@ class J extends T {
|
|
|
5948
5948
|
renderHeader() {
|
|
5949
5949
|
const { config: e } = this.stateManager.getState(), t = [], s = e.weekStartsOn || 0;
|
|
5950
5950
|
for (let i = 0; i < 7; i++) {
|
|
5951
|
-
const
|
|
5952
|
-
t.push(`<div class="month-header-cell">${
|
|
5951
|
+
const r = (s + i) % 7, a = w.getDayAbbreviation(r, e.locale);
|
|
5952
|
+
t.push(`<div class="month-header-cell">${a}</div>`);
|
|
5953
5953
|
}
|
|
5954
5954
|
return `
|
|
5955
5955
|
<div class="month-header">
|
|
@@ -5981,9 +5981,9 @@ class J extends T {
|
|
|
5981
5981
|
`;
|
|
5982
5982
|
}
|
|
5983
5983
|
renderDay(e) {
|
|
5984
|
-
const { date: t, dayOfMonth: s, isOtherMonth: i, isToday:
|
|
5985
|
-
i && l.push("other-month"),
|
|
5986
|
-
const d = o.slice(0, this.config.maxEventsToShow), h = o.length - this.config.maxEventsToShow,
|
|
5984
|
+
const { date: t, dayOfMonth: s, isOtherMonth: i, isToday: r, isSelected: a, isWeekend: n, events: o = [] } = e, c = s, l = ["month-day"];
|
|
5985
|
+
i && l.push("other-month"), r && l.push("today"), a && l.push("selected"), n && l.push("weekend");
|
|
5986
|
+
const d = o.slice(0, this.config.maxEventsToShow), h = o.length - this.config.maxEventsToShow, g = d.map((f) => this.renderEvent(f)).join(""), b = h > 0 ? `<div class="more-events">+${h} more</div>` : "";
|
|
5987
5987
|
return `
|
|
5988
5988
|
<div class="${l.join(" ")}"
|
|
5989
5989
|
data-date="${t.toISOString()}"
|
|
@@ -5992,25 +5992,25 @@ class J extends T {
|
|
|
5992
5992
|
<span class="day-number">${c}</span>
|
|
5993
5993
|
</div>
|
|
5994
5994
|
<div class="day-events">
|
|
5995
|
-
${
|
|
5996
|
-
${
|
|
5995
|
+
${g}
|
|
5996
|
+
${b}
|
|
5997
5997
|
</div>
|
|
5998
5998
|
</div>
|
|
5999
5999
|
`;
|
|
6000
6000
|
}
|
|
6001
6001
|
renderEvent(e) {
|
|
6002
|
-
const { title: t, start: s, allDay: i, backgroundColor:
|
|
6003
|
-
let
|
|
6004
|
-
if (
|
|
6005
|
-
const l =
|
|
6006
|
-
|
|
6002
|
+
const { title: t, start: s, allDay: i, backgroundColor: r, textColor: a } = e;
|
|
6003
|
+
let n = "";
|
|
6004
|
+
if (r) {
|
|
6005
|
+
const l = v.sanitizeColor(r), d = v.sanitizeColor(a, "white");
|
|
6006
|
+
n += `background-color: ${l}; color: ${d};`;
|
|
6007
6007
|
}
|
|
6008
6008
|
let o = "";
|
|
6009
|
-
!i && s && (o =
|
|
6009
|
+
!i && s && (o = w.formatTime(new Date(s), !1, !1));
|
|
6010
6010
|
const c = ["event-item"];
|
|
6011
6011
|
return i && c.push("all-day"), `
|
|
6012
6012
|
<div class="${c.join(" ")}"
|
|
6013
|
-
style="${
|
|
6013
|
+
style="${n}"
|
|
6014
6014
|
data-event-id="${e.id}"
|
|
6015
6015
|
title="${C.escapeHTML(t)}">
|
|
6016
6016
|
${o ? `<span class="event-time">${o}</span>` : ""}
|
|
@@ -6034,7 +6034,7 @@ class J extends T {
|
|
|
6034
6034
|
}
|
|
6035
6035
|
handleEventClick(e) {
|
|
6036
6036
|
e.stopPropagation();
|
|
6037
|
-
const s = e.currentTarget.dataset.eventId, i = this.stateManager.getEvents().find((
|
|
6037
|
+
const s = e.currentTarget.dataset.eventId, i = this.stateManager.getEvents().find((r) => r.id === s);
|
|
6038
6038
|
i && (this.stateManager.selectEvent(i), this.emit("event-click", { event: i }));
|
|
6039
6039
|
}
|
|
6040
6040
|
handleMoreClick(e) {
|
|
@@ -6046,7 +6046,7 @@ class J extends T {
|
|
|
6046
6046
|
this.unsubscribe && this.unsubscribe();
|
|
6047
6047
|
}
|
|
6048
6048
|
}
|
|
6049
|
-
class X extends
|
|
6049
|
+
class X extends E {
|
|
6050
6050
|
constructor() {
|
|
6051
6051
|
super(), this._stateManager = null, this.viewData = null, this.hours = Array.from({ length: 24 }, (e, t) => t), this._registryCheckInterval = null;
|
|
6052
6052
|
}
|
|
@@ -6112,9 +6112,9 @@ class X extends T {
|
|
|
6112
6112
|
return {
|
|
6113
6113
|
...s,
|
|
6114
6114
|
date: i,
|
|
6115
|
-
isToday:
|
|
6116
|
-
timedEvents: (s.events || []).filter((
|
|
6117
|
-
allDayEvents: (s.events || []).filter((
|
|
6115
|
+
isToday: w.isToday(i),
|
|
6116
|
+
timedEvents: (s.events || []).filter((r) => !r.allDay),
|
|
6117
|
+
allDayEvents: (s.events || []).filter((r) => r.allDay)
|
|
6118
6118
|
};
|
|
6119
6119
|
})
|
|
6120
6120
|
};
|
|
@@ -6309,7 +6309,7 @@ class X extends T {
|
|
|
6309
6309
|
<div class="time-gutter-header"></div>
|
|
6310
6310
|
${this.viewData.days.map((e) => `
|
|
6311
6311
|
<div class="day-column-header ${e.isToday ? "is-today" : ""}">
|
|
6312
|
-
<span class="day-name">${
|
|
6312
|
+
<span class="day-name">${w.getDayAbbreviation(e.date.getDay())}</span>
|
|
6313
6313
|
<span class="day-number">${e.date.getDate()}</span>
|
|
6314
6314
|
</div>
|
|
6315
6315
|
`).join("")}
|
|
@@ -6332,7 +6332,7 @@ class X extends T {
|
|
|
6332
6332
|
<div class="time-gutter">
|
|
6333
6333
|
${this.hours.map((e) => `
|
|
6334
6334
|
<div class="time-slot-label">
|
|
6335
|
-
${e === 0 ? "" :
|
|
6335
|
+
${e === 0 ? "" : w.formatTime((/* @__PURE__ */ new Date()).setHours(e, 0), !1)}
|
|
6336
6336
|
</div>
|
|
6337
6337
|
`).join("")}
|
|
6338
6338
|
</div>
|
|
@@ -6348,18 +6348,18 @@ class X extends T {
|
|
|
6348
6348
|
` : '<div class="week-view">Loading...</div>';
|
|
6349
6349
|
}
|
|
6350
6350
|
renderTimedEvent(e) {
|
|
6351
|
-
const t = new Date(e.start), s = new Date(e.end), i = t.getHours() * 60 + t.getMinutes(),
|
|
6351
|
+
const t = new Date(e.start), s = new Date(e.end), i = t.getHours() * 60 + t.getMinutes(), r = (s - t) / (1e3 * 60), a = i, n = Math.max(r, 20), o = v.sanitizeColor(e.backgroundColor), c = v.sanitizeColor(v.getContrastColor(o), "white");
|
|
6352
6352
|
return `
|
|
6353
6353
|
<div class="event-container"
|
|
6354
|
-
style="top: ${
|
|
6354
|
+
style="top: ${a}px; height: ${n}px; background-color: ${o}; color: ${c};"
|
|
6355
6355
|
data-event-id="${e.id}">
|
|
6356
6356
|
<span class="event-title">${C.escapeHTML(e.title)}</span>
|
|
6357
|
-
<span class="event-time">${
|
|
6357
|
+
<span class="event-time">${w.formatTime(t)}</span>
|
|
6358
6358
|
</div>
|
|
6359
6359
|
`;
|
|
6360
6360
|
}
|
|
6361
6361
|
renderAllDayEvent(e) {
|
|
6362
|
-
const t =
|
|
6362
|
+
const t = v.sanitizeColor(e.backgroundColor), s = v.sanitizeColor(v.getContrastColor(t), "white");
|
|
6363
6363
|
return `
|
|
6364
6364
|
<div class="event-item"
|
|
6365
6365
|
style="background-color: ${t}; color: ${s}; font-size: 10px; padding: 2px 4px; border-radius: 2px; cursor: pointer; margin-bottom: 2px;"
|
|
@@ -6377,13 +6377,13 @@ class X extends T {
|
|
|
6377
6377
|
e && !this._scrolled && (e.scrollTop = 8 * 60 - 50, this._scrolled = !0), this.$$("[data-event-id]").forEach((t) => {
|
|
6378
6378
|
this.addListener(t, "click", (s) => {
|
|
6379
6379
|
s.stopPropagation();
|
|
6380
|
-
const i = s.currentTarget.dataset.eventId,
|
|
6381
|
-
|
|
6380
|
+
const i = s.currentTarget.dataset.eventId, r = this.stateManager.getEvents().find((a) => a.id === i);
|
|
6381
|
+
r && this.emit("event-click", { event: r });
|
|
6382
6382
|
});
|
|
6383
6383
|
}), this.$$(".day-column").forEach((t) => {
|
|
6384
6384
|
this.addListener(t, "click", (s) => {
|
|
6385
|
-
const i = s.currentTarget,
|
|
6386
|
-
o.setHours(Math.floor(
|
|
6385
|
+
const i = s.currentTarget, r = this.$("#scroll-container"), a = i.getBoundingClientRect(), n = s.clientY - a.top + (r ? r.scrollTop : 0), o = new Date(i.dataset.date);
|
|
6386
|
+
o.setHours(Math.floor(n / 60), Math.floor(n % 60), 0, 0), this.stateManager.selectDate(o), this.emit("day-click", { date: o });
|
|
6387
6387
|
});
|
|
6388
6388
|
});
|
|
6389
6389
|
}
|
|
@@ -6391,7 +6391,7 @@ class X extends T {
|
|
|
6391
6391
|
this.unsubscribe && this.unsubscribe();
|
|
6392
6392
|
}
|
|
6393
6393
|
}
|
|
6394
|
-
class ee extends
|
|
6394
|
+
class ee extends E {
|
|
6395
6395
|
constructor() {
|
|
6396
6396
|
super(), this._stateManager = null, this.viewData = null, this.hours = Array.from({ length: 24 }, (e, t) => t), this._registryCheckInterval = null;
|
|
6397
6397
|
}
|
|
@@ -6435,7 +6435,7 @@ class ee extends T {
|
|
|
6435
6435
|
updateSelection(e, t) {
|
|
6436
6436
|
const s = this.shadowRoot.querySelector(".day-column");
|
|
6437
6437
|
if (!s) return;
|
|
6438
|
-
((
|
|
6438
|
+
((r) => r && w.isSameDay(r, new Date(s.dataset.date)))(e) ? s.classList.add("selected") : s.classList.remove("selected");
|
|
6439
6439
|
}
|
|
6440
6440
|
loadViewData() {
|
|
6441
6441
|
if (!this.stateManager) return;
|
|
@@ -6443,26 +6443,26 @@ class ee extends T {
|
|
|
6443
6443
|
this.viewData = this.processViewData(e), this.render();
|
|
6444
6444
|
}
|
|
6445
6445
|
processViewData(e) {
|
|
6446
|
-
var
|
|
6446
|
+
var a;
|
|
6447
6447
|
if (!e) return null;
|
|
6448
6448
|
let t = null;
|
|
6449
|
-
const s = (
|
|
6449
|
+
const s = (a = this.stateManager) == null ? void 0 : a.getState(), i = (s == null ? void 0 : s.currentDate) || /* @__PURE__ */ new Date();
|
|
6450
6450
|
if (e.days && Array.isArray(e.days) && e.days.length > 0)
|
|
6451
|
-
t = e.days.find((
|
|
6451
|
+
t = e.days.find((n) => w.isSameDay(new Date(n.date), i)) || e.days[0];
|
|
6452
6452
|
else if (e.weeks && Array.isArray(e.weeks) && e.weeks.length > 0) {
|
|
6453
|
-
const
|
|
6454
|
-
t =
|
|
6453
|
+
const n = e.weeks.flatMap((o) => o.days || []);
|
|
6454
|
+
t = n.find((o) => w.isSameDay(new Date(o.date), i)) || n[0];
|
|
6455
6455
|
} else e.date && (t = e);
|
|
6456
6456
|
if (!t) return null;
|
|
6457
|
-
const
|
|
6457
|
+
const r = new Date(t.date);
|
|
6458
6458
|
return {
|
|
6459
6459
|
...e,
|
|
6460
6460
|
day: {
|
|
6461
6461
|
...t,
|
|
6462
|
-
date:
|
|
6463
|
-
isToday:
|
|
6464
|
-
timedEvents: (t.events || []).filter((
|
|
6465
|
-
allDayEvents: (t.events || []).filter((
|
|
6462
|
+
date: r,
|
|
6463
|
+
isToday: w.isToday(r),
|
|
6464
|
+
timedEvents: (t.events || []).filter((n) => !n.allDay),
|
|
6465
|
+
allDayEvents: (t.events || []).filter((n) => n.allDay)
|
|
6466
6466
|
}
|
|
6467
6467
|
};
|
|
6468
6468
|
}
|
|
@@ -6635,10 +6635,10 @@ class ee extends T {
|
|
|
6635
6635
|
`;
|
|
6636
6636
|
}
|
|
6637
6637
|
template() {
|
|
6638
|
-
var i,
|
|
6638
|
+
var i, r, a;
|
|
6639
6639
|
if (!this.viewData || !this.viewData.day)
|
|
6640
6640
|
return '<div class="day-view" style="padding: 20px; color: var(--fc-text-light);">No data available.</div>';
|
|
6641
|
-
const { day: e } = this.viewData, t = ((
|
|
6641
|
+
const { day: e } = this.viewData, t = ((a = (r = (i = this.stateManager) == null ? void 0 : i.state) == null ? void 0 : r.config) == null ? void 0 : a.locale) || "en-US", s = w.formatDate(e.date, "day", t).split(" ")[0];
|
|
6642
6642
|
return `
|
|
6643
6643
|
<div class="day-view">
|
|
6644
6644
|
<div class="day-header">
|
|
@@ -6652,7 +6652,7 @@ class ee extends T {
|
|
|
6652
6652
|
<div class="all-day-row">
|
|
6653
6653
|
<div class="all-day-label">All day</div>
|
|
6654
6654
|
<div class="all-day-cell">
|
|
6655
|
-
${e.allDayEvents.map((
|
|
6655
|
+
${e.allDayEvents.map((n) => this.renderAllDayEvent(n)).join("")}
|
|
6656
6656
|
</div>
|
|
6657
6657
|
</div>
|
|
6658
6658
|
|
|
@@ -6662,34 +6662,34 @@ class ee extends T {
|
|
|
6662
6662
|
</div>
|
|
6663
6663
|
|
|
6664
6664
|
<div class="time-gutter">
|
|
6665
|
-
${this.hours.map((
|
|
6665
|
+
${this.hours.map((n) => `
|
|
6666
6666
|
<div class="time-slot-label">
|
|
6667
|
-
${
|
|
6667
|
+
${n === 0 ? "" : w.formatTime((/* @__PURE__ */ new Date()).setHours(n, 0), !1)}
|
|
6668
6668
|
</div>
|
|
6669
6669
|
`).join("")}
|
|
6670
6670
|
</div>
|
|
6671
6671
|
|
|
6672
6672
|
<div class="day-column" data-date="${e.date.toISOString()}">
|
|
6673
6673
|
${e.isToday ? this.renderNowIndicator() : ""}
|
|
6674
|
-
${e.timedEvents.map((
|
|
6674
|
+
${e.timedEvents.map((n) => this.renderTimedEvent(n)).join("")}
|
|
6675
6675
|
</div>
|
|
6676
6676
|
</div>
|
|
6677
6677
|
</div>
|
|
6678
6678
|
`;
|
|
6679
6679
|
}
|
|
6680
6680
|
renderTimedEvent(e) {
|
|
6681
|
-
const t = new Date(e.start), s = new Date(e.end), i = t.getHours() * 60 + t.getMinutes(),
|
|
6681
|
+
const t = new Date(e.start), s = new Date(e.end), i = t.getHours() * 60 + t.getMinutes(), r = (s - t) / (1e3 * 60), a = i, n = Math.max(r, 30), o = v.sanitizeColor(e.backgroundColor), c = v.sanitizeColor(v.getContrastColor(o), "white");
|
|
6682
6682
|
return `
|
|
6683
6683
|
<div class="event-container"
|
|
6684
|
-
style="top: ${
|
|
6684
|
+
style="top: ${a}px; height: ${n}px; background-color: ${o}; color: ${c};"
|
|
6685
6685
|
data-event-id="${e.id}">
|
|
6686
6686
|
<span class="event-title">${C.escapeHTML(e.title)}</span>
|
|
6687
|
-
<span class="event-time">${
|
|
6687
|
+
<span class="event-time">${w.formatTime(t)} - ${w.formatTime(s)}</span>
|
|
6688
6688
|
</div>
|
|
6689
6689
|
`;
|
|
6690
6690
|
}
|
|
6691
6691
|
renderAllDayEvent(e) {
|
|
6692
|
-
const t =
|
|
6692
|
+
const t = v.sanitizeColor(e.backgroundColor), s = v.sanitizeColor(v.getContrastColor(t), "white");
|
|
6693
6693
|
return `
|
|
6694
6694
|
<div class="event-item"
|
|
6695
6695
|
style="background-color: ${t}; color: ${s}; font-size: 12px; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-weight: 500; margin-bottom: 2px;"
|
|
@@ -6707,21 +6707,21 @@ class ee extends T {
|
|
|
6707
6707
|
e && !this._scrolled && (e.scrollTop = 8 * 60 - 50, this._scrolled = !0), this.$$("[data-event-id]").forEach((s) => {
|
|
6708
6708
|
this.addListener(s, "click", (i) => {
|
|
6709
6709
|
i.stopPropagation();
|
|
6710
|
-
const
|
|
6711
|
-
|
|
6710
|
+
const r = i.currentTarget.dataset.eventId, a = this.stateManager.getEvents().find((n) => n.id === r);
|
|
6711
|
+
a && this.emit("event-click", { event: a });
|
|
6712
6712
|
});
|
|
6713
6713
|
});
|
|
6714
6714
|
const t = this.$(".day-column");
|
|
6715
6715
|
t && this.addListener(t, "click", (s) => {
|
|
6716
|
-
const i = s.currentTarget,
|
|
6717
|
-
o.setHours(Math.floor(
|
|
6716
|
+
const i = s.currentTarget, r = this.$("#scroll-container"), a = i.getBoundingClientRect(), n = s.clientY - a.top + (r ? r.scrollTop : 0), o = new Date(i.dataset.date);
|
|
6717
|
+
o.setHours(Math.floor(n / 60), Math.floor(n % 60), 0, 0), this.stateManager.selectDate(o), this.emit("day-click", { date: o });
|
|
6718
6718
|
});
|
|
6719
6719
|
}
|
|
6720
6720
|
unmount() {
|
|
6721
6721
|
this.unsubscribe && this.unsubscribe();
|
|
6722
6722
|
}
|
|
6723
6723
|
}
|
|
6724
|
-
class te extends
|
|
6724
|
+
class te extends E {
|
|
6725
6725
|
constructor() {
|
|
6726
6726
|
super(), this._isVisible = !1, this._cleanupFocusTrap = null, this.config = {
|
|
6727
6727
|
title: "New Event",
|
|
@@ -6751,8 +6751,8 @@ class te extends T {
|
|
|
6751
6751
|
}
|
|
6752
6752
|
getStyles() {
|
|
6753
6753
|
return `
|
|
6754
|
-
${
|
|
6755
|
-
${
|
|
6754
|
+
${v.getBaseStyles()}
|
|
6755
|
+
${v.getButtonStyles()}
|
|
6756
6756
|
|
|
6757
6757
|
:host {
|
|
6758
6758
|
display: none;
|
|
@@ -7017,8 +7017,8 @@ class te extends T {
|
|
|
7017
7017
|
this.emit("save", e), this.close();
|
|
7018
7018
|
}
|
|
7019
7019
|
formatDateForInput(e) {
|
|
7020
|
-
const t = (o) => String(o).padStart(2, "0"), s = e.getFullYear(), i = t(e.getMonth() + 1),
|
|
7021
|
-
return `${s}-${i}-${
|
|
7020
|
+
const t = (o) => String(o).padStart(2, "0"), s = e.getFullYear(), i = t(e.getMonth() + 1), r = t(e.getDate()), a = t(e.getHours()), n = t(e.getMinutes());
|
|
7021
|
+
return `${s}-${i}-${r}T${a}:${n}`;
|
|
7022
7022
|
}
|
|
7023
7023
|
unmount() {
|
|
7024
7024
|
this._cleanupFocusTrap && this._cleanupFocusTrap(), window.removeEventListener("keydown", this._handleKeyDown);
|
|
@@ -7028,7 +7028,7 @@ customElements.get("forcecal-event-form") || customElements.define("forcecal-eve
|
|
|
7028
7028
|
customElements.get("forcecal-month") || customElements.define("forcecal-month", J);
|
|
7029
7029
|
customElements.get("forcecal-week") || customElements.define("forcecal-week", X);
|
|
7030
7030
|
customElements.get("forcecal-day") || customElements.define("forcecal-day", ee);
|
|
7031
|
-
class se extends
|
|
7031
|
+
class se extends E {
|
|
7032
7032
|
static get observedAttributes() {
|
|
7033
7033
|
return ["view", "date", "locale", "timezone", "week-starts-on", "height"];
|
|
7034
7034
|
}
|
|
@@ -7046,13 +7046,13 @@ class se extends T {
|
|
|
7046
7046
|
this.stateManager = new Q(e), this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners();
|
|
7047
7047
|
}
|
|
7048
7048
|
setupEventListeners() {
|
|
7049
|
-
|
|
7049
|
+
y.on("navigation:*", (e, t) => {
|
|
7050
7050
|
this.emit("calendar-navigate", { action: t.split(":")[1], ...e });
|
|
7051
|
-
}),
|
|
7051
|
+
}), y.on("view:changed", (e) => {
|
|
7052
7052
|
this.emit("calendar-view-change", e);
|
|
7053
|
-
}),
|
|
7053
|
+
}), y.on("event:*", (e, t) => {
|
|
7054
7054
|
this.emit(`calendar-event-${t.split(":")[1]}`, e);
|
|
7055
|
-
}),
|
|
7055
|
+
}), y.on("date:selected", (e) => {
|
|
7056
7056
|
this.emit("calendar-date-select", e);
|
|
7057
7057
|
});
|
|
7058
7058
|
}
|
|
@@ -7068,10 +7068,10 @@ class se extends T {
|
|
|
7068
7068
|
getStyles() {
|
|
7069
7069
|
const e = this.getAttribute("height") || "800px";
|
|
7070
7070
|
return `
|
|
7071
|
-
${
|
|
7072
|
-
${
|
|
7073
|
-
${
|
|
7074
|
-
${
|
|
7071
|
+
${v.getBaseStyles()}
|
|
7072
|
+
${v.getButtonStyles()}
|
|
7073
|
+
${v.getGridStyles()}
|
|
7074
|
+
${v.getAnimations()}
|
|
7075
7075
|
|
|
7076
7076
|
:host {
|
|
7077
7077
|
--calendar-height: ${e};
|
|
@@ -7455,16 +7455,16 @@ class se extends T {
|
|
|
7455
7455
|
`;
|
|
7456
7456
|
}
|
|
7457
7457
|
template() {
|
|
7458
|
-
const e = this.stateManager.getState(), { currentDate: t, view: s, loading: i, error:
|
|
7459
|
-
if (
|
|
7458
|
+
const e = this.stateManager.getState(), { currentDate: t, view: s, loading: i, error: r } = e;
|
|
7459
|
+
if (r)
|
|
7460
7460
|
return `
|
|
7461
7461
|
<div class="force-calendar">
|
|
7462
7462
|
<div class="fc-error">
|
|
7463
|
-
<p><strong>Error:</strong> ${
|
|
7463
|
+
<p><strong>Error:</strong> ${r.message || "An error occurred"}</p>
|
|
7464
7464
|
</div>
|
|
7465
7465
|
</div>
|
|
7466
7466
|
`;
|
|
7467
|
-
const
|
|
7467
|
+
const a = this.getTitle(t, s);
|
|
7468
7468
|
return `
|
|
7469
7469
|
<div class="force-calendar">
|
|
7470
7470
|
<header class="fc-header">
|
|
@@ -7478,7 +7478,7 @@ class se extends T {
|
|
|
7478
7478
|
<button class="fc-nav-arrow" data-action="previous" title="Previous">
|
|
7479
7479
|
${this.getIcon("chevron-left")}
|
|
7480
7480
|
</button>
|
|
7481
|
-
<h2 class="fc-title">${
|
|
7481
|
+
<h2 class="fc-title">${a}</h2>
|
|
7482
7482
|
<button class="fc-nav-arrow" data-action="next" title="Next">
|
|
7483
7483
|
${this.getIcon("chevron-right")}
|
|
7484
7484
|
</button>
|
|
@@ -7529,8 +7529,8 @@ class se extends T {
|
|
|
7529
7529
|
this._currentViewInstance && (this._currentViewInstance.cleanup && this._currentViewInstance.cleanup(), this._viewUnsubscribe && (this._viewUnsubscribe(), this._viewUnsubscribe = null)), console.log("[ForceCalendar] Creating view for:", this.currentView);
|
|
7530
7530
|
try {
|
|
7531
7531
|
const i = this._createViewRenderer(this.currentView);
|
|
7532
|
-
i && (i._viewType = this.currentView, this._currentViewInstance = i, i.stateManager = this.stateManager, i.container = e, console.log("[ForceCalendar] Calling viewRenderer.render()"), i.render(), console.log("[ForceCalendar] viewRenderer.render() completed"), this._viewUnsubscribe = this.stateManager.subscribe((
|
|
7533
|
-
(
|
|
7532
|
+
i && (i._viewType = this.currentView, this._currentViewInstance = i, i.stateManager = this.stateManager, i.container = e, console.log("[ForceCalendar] Calling viewRenderer.render()"), i.render(), console.log("[ForceCalendar] viewRenderer.render() completed"), this._viewUnsubscribe = this.stateManager.subscribe((r, a) => {
|
|
7533
|
+
(r.events !== (a == null ? void 0 : a.events) || r.currentDate !== (a == null ? void 0 : a.currentDate)) && i && i.render && i.render();
|
|
7534
7534
|
}));
|
|
7535
7535
|
} catch (i) {
|
|
7536
7536
|
console.error("[ForceCalendar] Error creating/rendering view:", i);
|
|
@@ -7547,62 +7547,79 @@ class se extends T {
|
|
|
7547
7547
|
}), this.addListener(this.shadowRoot, "day-click", (i) => {
|
|
7548
7548
|
t && t.open(i.detail.date);
|
|
7549
7549
|
}), t && this.addListener(t, "save", (i) => {
|
|
7550
|
-
const
|
|
7550
|
+
const r = i.detail, a = window.crypto && typeof window.crypto.randomUUID == "function" ? window.crypto.randomUUID() : Math.random().toString(36).substring(2, 15);
|
|
7551
7551
|
this.stateManager.addEvent({
|
|
7552
|
-
id:
|
|
7553
|
-
...
|
|
7552
|
+
id: a,
|
|
7553
|
+
...r
|
|
7554
7554
|
});
|
|
7555
7555
|
});
|
|
7556
7556
|
}
|
|
7557
7557
|
_createViewRenderer(e) {
|
|
7558
|
+
const t = e;
|
|
7558
7559
|
return {
|
|
7559
7560
|
stateManager: null,
|
|
7560
7561
|
container: null,
|
|
7561
7562
|
_listeners: [],
|
|
7563
|
+
_scrolled: !1,
|
|
7562
7564
|
cleanup() {
|
|
7563
|
-
this._listeners.forEach(({ element:
|
|
7564
|
-
|
|
7565
|
+
this._listeners.forEach(({ element: s, event: i, handler: r }) => {
|
|
7566
|
+
s.removeEventListener(i, r);
|
|
7565
7567
|
}), this._listeners = [];
|
|
7566
7568
|
},
|
|
7567
|
-
addListener(
|
|
7568
|
-
|
|
7569
|
+
addListener(s, i, r) {
|
|
7570
|
+
s.addEventListener(i, r), this._listeners.push({ element: s, event: i, handler: r });
|
|
7569
7571
|
},
|
|
7570
7572
|
render() {
|
|
7571
|
-
if (
|
|
7572
|
-
const
|
|
7573
|
-
if (
|
|
7574
|
-
this.container.innerHTML = '<div style="padding: 20px; text-align: center;
|
|
7573
|
+
if (!this.container || !this.stateManager) return;
|
|
7574
|
+
const s = this.stateManager.getViewData();
|
|
7575
|
+
if (!s) {
|
|
7576
|
+
this.container.innerHTML = '<div style="padding: 20px; text-align: center; color: #666;">Loading...</div>';
|
|
7575
7577
|
return;
|
|
7576
7578
|
}
|
|
7577
7579
|
this.cleanup();
|
|
7578
|
-
const
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7580
|
+
const i = this.stateManager.getState().config;
|
|
7581
|
+
let r = "";
|
|
7582
|
+
switch (t) {
|
|
7583
|
+
case "week":
|
|
7584
|
+
r = this._renderWeekView(s, i);
|
|
7585
|
+
break;
|
|
7586
|
+
case "day":
|
|
7587
|
+
r = this._renderDayView(s, i);
|
|
7588
|
+
break;
|
|
7589
|
+
case "month":
|
|
7590
|
+
default:
|
|
7591
|
+
if (!s.weeks) {
|
|
7592
|
+
this.container.innerHTML = '<div style="padding: 20px; text-align: center; color: #666;">No data available for month view.</div>';
|
|
7593
|
+
return;
|
|
7594
|
+
}
|
|
7595
|
+
r = this._renderMonthView(s, i);
|
|
7596
|
+
break;
|
|
7597
|
+
}
|
|
7598
|
+
this.container.innerHTML = r, this._attachEventHandlers(t);
|
|
7582
7599
|
},
|
|
7583
|
-
_renderMonthView(
|
|
7584
|
-
const
|
|
7585
|
-
for (let
|
|
7586
|
-
const
|
|
7587
|
-
a.push(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][
|
|
7600
|
+
_renderMonthView(s, i) {
|
|
7601
|
+
const r = i.weekStartsOn || 0, a = [];
|
|
7602
|
+
for (let o = 0; o < 7; o++) {
|
|
7603
|
+
const c = (r + o) % 7;
|
|
7604
|
+
a.push(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][c]);
|
|
7588
7605
|
}
|
|
7589
7606
|
let n = `
|
|
7590
7607
|
<div class="fc-month-view" style="display: flex; flex-direction: column; height: 100%; min-height: 400px; background: #fff; border: 1px solid #e5e7eb;">
|
|
7591
7608
|
<div class="fc-month-header" style="display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid #e5e7eb; background: #f9fafb;">
|
|
7592
|
-
${a.map((
|
|
7609
|
+
${a.map((o) => `<div class="fc-month-header-cell" style="padding: 12px 8px; text-align: center; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase;">${o}</div>`).join("")}
|
|
7593
7610
|
</div>
|
|
7594
7611
|
<div class="fc-month-body" style="display: flex; flex-direction: column; flex: 1;">
|
|
7595
7612
|
`;
|
|
7596
|
-
return
|
|
7597
|
-
n += '<div class="fc-month-week" style="display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; min-height: 80px;">',
|
|
7598
|
-
const
|
|
7613
|
+
return s.weeks.forEach((o) => {
|
|
7614
|
+
n += '<div class="fc-month-week" style="display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; min-height: 80px;">', o.days.forEach((c) => {
|
|
7615
|
+
const l = !c.isCurrentMonth, d = c.isToday, h = l ? "#f3f4f6" : "#fff", g = l ? "#9ca3af" : "#111827", b = d ? "background: #2563eb; color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;" : "", f = c.events || [], D = f.slice(0, 3), x = f.length - 3;
|
|
7599
7616
|
n += `
|
|
7600
|
-
<div class="fc-month-day" data-date="${
|
|
7601
|
-
<div class="fc-day-number" style="font-size: 13px; font-weight: 500; color: ${
|
|
7617
|
+
<div class="fc-month-day" data-date="${c.date}" style="background: ${h}; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; padding: 4px; min-height: 80px; cursor: pointer;">
|
|
7618
|
+
<div class="fc-day-number" style="font-size: 13px; font-weight: 500; color: ${g}; padding: 2px 4px; margin-bottom: 4px; ${b}">${c.dayOfMonth}</div>
|
|
7602
7619
|
<div class="fc-day-events" style="display: flex; flex-direction: column; gap: 2px;">
|
|
7603
|
-
${
|
|
7604
|
-
<div class="fc-event" data-event-id="${
|
|
7605
|
-
${
|
|
7620
|
+
${D.map((M) => `
|
|
7621
|
+
<div class="fc-event" data-event-id="${M.id}" style="background-color: ${M.backgroundColor || "#2563eb"}; font-size: 11px; padding: 2px 6px; border-radius: 3px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;">
|
|
7622
|
+
${M.title}
|
|
7606
7623
|
</div>
|
|
7607
7624
|
`).join("")}
|
|
7608
7625
|
${x > 0 ? `<div class="fc-more-events" style="font-size: 10px; color: #6b7280; padding: 2px 4px; font-weight: 500;">+${x} more</div>` : ""}
|
|
@@ -7612,20 +7629,227 @@ class se extends T {
|
|
|
7612
7629
|
}), n += "</div>";
|
|
7613
7630
|
}), n += "</div></div>", n;
|
|
7614
7631
|
},
|
|
7615
|
-
|
|
7616
|
-
const
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7632
|
+
_renderWeekView(s, i) {
|
|
7633
|
+
const r = s.days || [];
|
|
7634
|
+
if (r.length === 0)
|
|
7635
|
+
return '<div style="padding: 20px; text-align: center; color: #666;">No data available for week view.</div>';
|
|
7636
|
+
i.weekStartsOn;
|
|
7637
|
+
const a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], n = Array.from({ length: 24 }, (l, d) => d), o = r.map((l) => {
|
|
7638
|
+
const d = new Date(l.date), h = l.events || [];
|
|
7639
|
+
return {
|
|
7640
|
+
...l,
|
|
7641
|
+
date: d,
|
|
7642
|
+
dayName: a[d.getDay()],
|
|
7643
|
+
dayOfMonth: d.getDate(),
|
|
7644
|
+
isToday: this._isToday(d),
|
|
7645
|
+
timedEvents: h.filter((g) => !g.allDay),
|
|
7646
|
+
allDayEvents: h.filter((g) => g.allDay)
|
|
7647
|
+
};
|
|
7648
|
+
});
|
|
7649
|
+
return `
|
|
7650
|
+
<div class="fc-week-view" style="display: flex; flex-direction: column; height: 100%; background: #fff; overflow: hidden;">
|
|
7651
|
+
<!-- Header -->
|
|
7652
|
+
<div style="display: grid; grid-template-columns: 60px repeat(7, 1fr); border-bottom: 1px solid #e5e7eb; background: #f9fafb; flex-shrink: 0;">
|
|
7653
|
+
<div style="border-right: 1px solid #e5e7eb;"></div>
|
|
7654
|
+
${o.map((l) => `
|
|
7655
|
+
<div style="padding: 12px 8px; text-align: center; border-right: 1px solid #e5e7eb;">
|
|
7656
|
+
<div style="font-size: 10px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.1em;">${l.dayName}</div>
|
|
7657
|
+
<div style="font-size: 16px; font-weight: 500; margin-top: 4px; ${l.isToday ? "background: #dc2626; color: white; border-radius: 50%; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;" : "color: #111827;"}">${l.dayOfMonth}</div>
|
|
7658
|
+
</div>
|
|
7659
|
+
`).join("")}
|
|
7660
|
+
</div>
|
|
7661
|
+
|
|
7662
|
+
<!-- All Day Row -->
|
|
7663
|
+
<div style="display: grid; grid-template-columns: 60px repeat(7, 1fr); border-bottom: 1px solid #e5e7eb; background: #fafafa; min-height: 32px; flex-shrink: 0;">
|
|
7664
|
+
<div style="font-size: 9px; color: #6b7280; display: flex; align-items: center; justify-content: center; border-right: 1px solid #e5e7eb; text-transform: uppercase; font-weight: 700;">All day</div>
|
|
7665
|
+
${o.map((l) => `
|
|
7666
|
+
<div style="border-right: 1px solid #e5e7eb; padding: 4px; display: flex; flex-direction: column; gap: 2px;">
|
|
7667
|
+
${l.allDayEvents.map((d) => `
|
|
7668
|
+
<div class="fc-event" data-event-id="${d.id}" style="background-color: ${d.backgroundColor || "#2563eb"}; font-size: 10px; padding: 2px 4px; border-radius: 2px; color: white; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
|
7669
|
+
${d.title}
|
|
7670
|
+
</div>
|
|
7671
|
+
`).join("")}
|
|
7672
|
+
</div>
|
|
7673
|
+
`).join("")}
|
|
7674
|
+
</div>
|
|
7675
|
+
|
|
7676
|
+
<!-- Time Grid Body -->
|
|
7677
|
+
<div id="week-scroll-container" style="flex: 1; overflow-y: auto; overflow-x: hidden; position: relative;">
|
|
7678
|
+
<div style="display: grid; grid-template-columns: 60px repeat(7, 1fr); position: relative; height: 1440px;">
|
|
7679
|
+
<!-- Time Gutter -->
|
|
7680
|
+
<div style="border-right: 1px solid #e5e7eb; background: #fafafa;">
|
|
7681
|
+
${n.map((l) => `
|
|
7682
|
+
<div style="height: 60px; font-size: 10px; color: #6b7280; text-align: right; padding-right: 8px; font-weight: 500;">
|
|
7683
|
+
${l === 0 ? "" : this._formatHour(l)}
|
|
7684
|
+
</div>
|
|
7685
|
+
`).join("")}
|
|
7686
|
+
</div>
|
|
7687
|
+
|
|
7688
|
+
<!-- Day Columns -->
|
|
7689
|
+
${o.map((l) => `
|
|
7690
|
+
<div class="fc-week-day-column" data-date="${l.date.toISOString()}" style="border-right: 1px solid #e5e7eb; position: relative; cursor: pointer;">
|
|
7691
|
+
<!-- Hour grid lines -->
|
|
7692
|
+
${n.map(() => '<div style="height: 60px; border-bottom: 1px solid #f3f4f6;"></div>').join("")}
|
|
7693
|
+
|
|
7694
|
+
<!-- Now indicator for today -->
|
|
7695
|
+
${l.isToday ? this._renderNowIndicator() : ""}
|
|
7696
|
+
|
|
7697
|
+
<!-- Timed events -->
|
|
7698
|
+
${l.timedEvents.map((d) => this._renderTimedEvent(d)).join("")}
|
|
7699
|
+
</div>
|
|
7700
|
+
`).join("")}
|
|
7701
|
+
</div>
|
|
7702
|
+
</div>
|
|
7703
|
+
</div>
|
|
7704
|
+
`;
|
|
7705
|
+
},
|
|
7706
|
+
_renderDayView(s, i) {
|
|
7707
|
+
var g, b;
|
|
7708
|
+
const r = ((b = (g = this.stateManager) == null ? void 0 : g.getState()) == null ? void 0 : b.currentDate) || /* @__PURE__ */ new Date();
|
|
7709
|
+
let a, n, o, c, l;
|
|
7710
|
+
if (s.type === "day" && s.date)
|
|
7711
|
+
if (a = new Date(s.date), n = s.dayName || ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][a.getDay()], o = s.isToday !== void 0 ? s.isToday : this._isToday(a), c = s.allDayEvents || [], s.hours && Array.isArray(s.hours)) {
|
|
7712
|
+
const f = /* @__PURE__ */ new Map();
|
|
7713
|
+
s.hours.forEach((D) => {
|
|
7714
|
+
(D.events || []).forEach((x) => {
|
|
7715
|
+
f.has(x.id) || f.set(x.id, x);
|
|
7716
|
+
});
|
|
7717
|
+
}), l = Array.from(f.values());
|
|
7718
|
+
} else
|
|
7719
|
+
l = [];
|
|
7720
|
+
else if (s.days && s.days.length > 0) {
|
|
7721
|
+
const f = s.days.find((x) => this._isSameDay(new Date(x.date), r)) || s.days[0];
|
|
7722
|
+
a = new Date(f.date), n = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][a.getDay()], o = this._isToday(a);
|
|
7723
|
+
const D = f.events || [];
|
|
7724
|
+
c = D.filter((x) => x.allDay), l = D.filter((x) => !x.allDay);
|
|
7725
|
+
} else
|
|
7726
|
+
return '<div style="padding: 20px; text-align: center; color: #666;">No data available for day view.</div>';
|
|
7727
|
+
const d = Array.from({ length: 24 }, (f, D) => D);
|
|
7728
|
+
return `
|
|
7729
|
+
<div class="fc-day-view" style="display: flex; flex-direction: column; height: 100%; background: #fff; overflow: hidden;">
|
|
7730
|
+
<!-- Header -->
|
|
7731
|
+
<div style="display: grid; grid-template-columns: 60px 1fr; border-bottom: 1px solid #e5e7eb; background: #f9fafb; flex-shrink: 0;">
|
|
7732
|
+
<div style="border-right: 1px solid #e5e7eb;"></div>
|
|
7733
|
+
<div style="padding: 16px 24px;">
|
|
7734
|
+
<div style="font-size: 12px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.1em;">${n}</div>
|
|
7735
|
+
<div style="font-size: 24px; font-weight: 600; margin-top: 4px; ${o ? "color: #dc2626;" : "color: #111827;"}">${a.getDate()}</div>
|
|
7736
|
+
</div>
|
|
7737
|
+
</div>
|
|
7738
|
+
|
|
7739
|
+
<!-- All Day Row -->
|
|
7740
|
+
<div style="display: grid; grid-template-columns: 60px 1fr; border-bottom: 1px solid #e5e7eb; background: #fafafa; min-height: 36px; flex-shrink: 0;">
|
|
7741
|
+
<div style="font-size: 9px; color: #6b7280; display: flex; align-items: center; justify-content: center; border-right: 1px solid #e5e7eb; text-transform: uppercase; font-weight: 700;">All day</div>
|
|
7742
|
+
<div style="padding: 6px 12px; display: flex; flex-wrap: wrap; gap: 4px;">
|
|
7743
|
+
${c.map((f) => `
|
|
7744
|
+
<div class="fc-event" data-event-id="${f.id}" style="background-color: ${f.backgroundColor || "#2563eb"}; font-size: 12px; padding: 4px 8px; border-radius: 4px; color: white; cursor: pointer; font-weight: 500;">
|
|
7745
|
+
${f.title}
|
|
7746
|
+
</div>
|
|
7747
|
+
`).join("")}
|
|
7748
|
+
</div>
|
|
7749
|
+
</div>
|
|
7750
|
+
|
|
7751
|
+
<!-- Time Grid Body -->
|
|
7752
|
+
<div id="day-scroll-container" style="flex: 1; overflow-y: auto; overflow-x: hidden; position: relative;">
|
|
7753
|
+
<div style="display: grid; grid-template-columns: 60px 1fr; position: relative; height: 1440px;">
|
|
7754
|
+
<!-- Time Gutter -->
|
|
7755
|
+
<div style="border-right: 1px solid #e5e7eb; background: #fafafa;">
|
|
7756
|
+
${d.map((f) => `
|
|
7757
|
+
<div style="height: 60px; font-size: 11px; color: #6b7280; text-align: right; padding-right: 12px; font-weight: 500;">
|
|
7758
|
+
${f === 0 ? "" : this._formatHour(f)}
|
|
7759
|
+
</div>
|
|
7760
|
+
`).join("")}
|
|
7761
|
+
</div>
|
|
7762
|
+
|
|
7763
|
+
<!-- Day Column -->
|
|
7764
|
+
<div class="fc-day-column" data-date="${a.toISOString()}" style="position: relative; cursor: pointer;">
|
|
7765
|
+
<!-- Hour grid lines -->
|
|
7766
|
+
${d.map(() => '<div style="height: 60px; border-bottom: 1px solid #f3f4f6;"></div>').join("")}
|
|
7767
|
+
|
|
7768
|
+
<!-- Now indicator for today -->
|
|
7769
|
+
${o ? this._renderNowIndicator() : ""}
|
|
7770
|
+
|
|
7771
|
+
<!-- Timed events -->
|
|
7772
|
+
${l.map((f) => this._renderTimedEventDay(f)).join("")}
|
|
7773
|
+
</div>
|
|
7774
|
+
</div>
|
|
7775
|
+
</div>
|
|
7776
|
+
</div>
|
|
7777
|
+
`;
|
|
7778
|
+
},
|
|
7779
|
+
_renderTimedEvent(s) {
|
|
7780
|
+
const i = new Date(s.start), r = new Date(s.end), a = i.getHours() * 60 + i.getMinutes(), n = Math.max((r - i) / (1e3 * 60), 20), o = s.backgroundColor || "#2563eb";
|
|
7781
|
+
return `
|
|
7782
|
+
<div class="fc-event" data-event-id="${s.id}"
|
|
7783
|
+
style="position: absolute; top: ${a}px; height: ${n}px; left: 2px; right: 2px;
|
|
7784
|
+
background-color: ${o}; border-radius: 4px; padding: 4px 8px; font-size: 11px;
|
|
7785
|
+
font-weight: 500; color: white; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
|
7786
|
+
cursor: pointer; z-index: 5;">
|
|
7787
|
+
<div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${s.title}</div>
|
|
7788
|
+
<div style="font-size: 10px; opacity: 0.9;">${this._formatTime(i)}</div>
|
|
7789
|
+
</div>
|
|
7790
|
+
`;
|
|
7791
|
+
},
|
|
7792
|
+
_renderTimedEventDay(s) {
|
|
7793
|
+
const i = new Date(s.start), r = new Date(s.end), a = i.getHours() * 60 + i.getMinutes(), n = Math.max((r - i) / (1e3 * 60), 30), o = s.backgroundColor || "#2563eb";
|
|
7794
|
+
return `
|
|
7795
|
+
<div class="fc-event" data-event-id="${s.id}"
|
|
7796
|
+
style="position: absolute; top: ${a}px; height: ${n}px; left: 12px; right: 24px;
|
|
7797
|
+
background-color: ${o}; border-radius: 6px; padding: 8px 12px; font-size: 13px;
|
|
7798
|
+
font-weight: 500; color: white; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
7799
|
+
cursor: pointer; z-index: 5;">
|
|
7800
|
+
<div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${s.title}</div>
|
|
7801
|
+
<div style="font-size: 11px; opacity: 0.9;">${this._formatTime(i)} - ${this._formatTime(r)}</div>
|
|
7802
|
+
</div>
|
|
7803
|
+
`;
|
|
7804
|
+
},
|
|
7805
|
+
_renderNowIndicator() {
|
|
7806
|
+
const s = /* @__PURE__ */ new Date();
|
|
7807
|
+
return `<div style="position: absolute; left: 0; right: 0; top: ${s.getHours() * 60 + s.getMinutes()}px; height: 2px; background: #dc2626; z-index: 15; pointer-events: none;"></div>`;
|
|
7808
|
+
},
|
|
7809
|
+
_formatHour(s) {
|
|
7810
|
+
const i = s >= 12 ? "PM" : "AM";
|
|
7811
|
+
return `${s % 12 || 12} ${i}`;
|
|
7812
|
+
},
|
|
7813
|
+
_formatTime(s) {
|
|
7814
|
+
const i = s.getHours(), r = s.getMinutes(), a = i >= 12 ? "PM" : "AM", n = i % 12 || 12;
|
|
7815
|
+
return r === 0 ? `${n} ${a}` : `${n}:${r.toString().padStart(2, "0")} ${a}`;
|
|
7816
|
+
},
|
|
7817
|
+
_isToday(s) {
|
|
7818
|
+
const i = /* @__PURE__ */ new Date();
|
|
7819
|
+
return s.getDate() === i.getDate() && s.getMonth() === i.getMonth() && s.getFullYear() === i.getFullYear();
|
|
7820
|
+
},
|
|
7821
|
+
_isSameDay(s, i) {
|
|
7822
|
+
return s.getDate() === i.getDate() && s.getMonth() === i.getMonth() && s.getFullYear() === i.getFullYear();
|
|
7823
|
+
},
|
|
7824
|
+
_attachEventHandlers(s) {
|
|
7825
|
+
const i = this.stateManager;
|
|
7826
|
+
if (this.container.querySelectorAll(".fc-month-day").forEach((r) => {
|
|
7827
|
+
this.addListener(r, "click", (a) => {
|
|
7828
|
+
const n = new Date(r.dataset.date);
|
|
7829
|
+
i.selectDate(n);
|
|
7621
7830
|
});
|
|
7622
|
-
}), this.container.querySelectorAll(".fc-
|
|
7623
|
-
this.addListener(
|
|
7624
|
-
|
|
7625
|
-
const
|
|
7626
|
-
n
|
|
7831
|
+
}), this.container.querySelectorAll(".fc-week-day-column").forEach((r) => {
|
|
7832
|
+
this.addListener(r, "click", (a) => {
|
|
7833
|
+
if (a.target.closest(".fc-event")) return;
|
|
7834
|
+
const n = new Date(r.dataset.date), o = r.getBoundingClientRect(), c = this.container.querySelector("#week-scroll-container"), l = a.clientY - o.top + (c ? c.scrollTop : 0);
|
|
7835
|
+
n.setHours(Math.floor(l / 60), Math.floor(l % 60), 0, 0), i.selectDate(n);
|
|
7627
7836
|
});
|
|
7628
|
-
})
|
|
7837
|
+
}), this.container.querySelectorAll(".fc-day-column").forEach((r) => {
|
|
7838
|
+
this.addListener(r, "click", (a) => {
|
|
7839
|
+
if (a.target.closest(".fc-event")) return;
|
|
7840
|
+
const n = new Date(r.dataset.date), o = r.getBoundingClientRect(), c = this.container.querySelector("#day-scroll-container"), l = a.clientY - o.top + (c ? c.scrollTop : 0);
|
|
7841
|
+
n.setHours(Math.floor(l / 60), Math.floor(l % 60), 0, 0), i.selectDate(n);
|
|
7842
|
+
});
|
|
7843
|
+
}), this.container.querySelectorAll(".fc-event").forEach((r) => {
|
|
7844
|
+
this.addListener(r, "click", (a) => {
|
|
7845
|
+
a.stopPropagation();
|
|
7846
|
+
const n = r.dataset.eventId, o = i.getEvents().find((c) => c.id === n);
|
|
7847
|
+
o && i.selectEvent(o);
|
|
7848
|
+
});
|
|
7849
|
+
}), s === "week" || s === "day") {
|
|
7850
|
+
const r = s === "week" ? "#week-scroll-container" : "#day-scroll-container", a = this.container.querySelector(r);
|
|
7851
|
+
a && !this._scrolled && (a.scrollTop = 8 * 60 - 50, this._scrolled = !0);
|
|
7852
|
+
}
|
|
7629
7853
|
}
|
|
7630
7854
|
};
|
|
7631
7855
|
}
|
|
@@ -7650,14 +7874,14 @@ class se extends T {
|
|
|
7650
7874
|
const s = this.stateManager.state.config.locale;
|
|
7651
7875
|
switch (t) {
|
|
7652
7876
|
case "month":
|
|
7653
|
-
return
|
|
7877
|
+
return w.formatDate(e, "month", s);
|
|
7654
7878
|
case "week":
|
|
7655
|
-
const i =
|
|
7656
|
-
return
|
|
7879
|
+
const i = w.startOfWeek(e), r = w.endOfWeek(e);
|
|
7880
|
+
return w.formatDateRange(i, r, s);
|
|
7657
7881
|
case "day":
|
|
7658
|
-
return
|
|
7882
|
+
return w.formatDate(e, "long", s);
|
|
7659
7883
|
default:
|
|
7660
|
-
return
|
|
7884
|
+
return w.formatDate(e, "month", s);
|
|
7661
7885
|
}
|
|
7662
7886
|
}
|
|
7663
7887
|
getIcon(e) {
|
|
@@ -7708,22 +7932,22 @@ class se extends T {
|
|
|
7708
7932
|
this.stateManager.today();
|
|
7709
7933
|
}
|
|
7710
7934
|
destroy() {
|
|
7711
|
-
this.stateManager && this.stateManager.destroy(),
|
|
7935
|
+
this.stateManager && this.stateManager.destroy(), y.clear(), super.cleanup();
|
|
7712
7936
|
}
|
|
7713
7937
|
}
|
|
7714
7938
|
customElements.get("forcecal-main") || customElements.define("forcecal-main", se);
|
|
7715
7939
|
typeof window < "u" && typeof customElements < "u" && console.log("Force Calendar Interface loading...");
|
|
7716
7940
|
export {
|
|
7717
|
-
|
|
7941
|
+
E as BaseComponent,
|
|
7718
7942
|
C as DOMUtils,
|
|
7719
|
-
|
|
7943
|
+
w as DateUtils,
|
|
7720
7944
|
ee as DayView,
|
|
7721
7945
|
G as EventBus,
|
|
7722
7946
|
se as ForceCalendar,
|
|
7723
7947
|
J as MonthView,
|
|
7724
7948
|
Q as StateManager,
|
|
7725
|
-
|
|
7949
|
+
v as StyleUtils,
|
|
7726
7950
|
X as WeekView,
|
|
7727
|
-
|
|
7951
|
+
y as eventBus
|
|
7728
7952
|
};
|
|
7729
7953
|
//# sourceMappingURL=force-calendar-interface.esm.js.map
|