@oslokommune/punkt-elements 14.0.2 → 14.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/calendar-BtShW7ER.cjs +90 -0
  3. package/dist/{calendar-Bz27nuTP.js → calendar-yxjSI4wd.js} +766 -682
  4. package/dist/datepicker-D0q75U1Z.js +1463 -0
  5. package/dist/datepicker-DDV382Uu.cjs +271 -0
  6. package/dist/index.d.ts +118 -83
  7. package/dist/pkt-calendar.cjs +1 -1
  8. package/dist/pkt-calendar.js +1 -1
  9. package/dist/pkt-datepicker.cjs +1 -1
  10. package/dist/pkt-datepicker.js +2 -2
  11. package/dist/pkt-index.cjs +1 -1
  12. package/dist/pkt-index.js +3 -3
  13. package/package.json +2 -2
  14. package/src/components/calendar/calendar.ts +372 -414
  15. package/src/components/calendar/helpers/calendar-grid.ts +93 -0
  16. package/src/components/calendar/helpers/date-validation.ts +86 -0
  17. package/src/components/calendar/helpers/index.ts +49 -0
  18. package/src/components/calendar/helpers/keyboard-navigation.ts +54 -0
  19. package/src/components/calendar/helpers/selection-manager.ts +184 -0
  20. package/src/components/datepicker/datepicker-base.ts +151 -0
  21. package/src/components/datepicker/datepicker-multiple.ts +7 -114
  22. package/src/components/datepicker/datepicker-range.ts +21 -141
  23. package/src/components/datepicker/datepicker-single.ts +7 -115
  24. package/src/components/datepicker/datepicker-types.ts +56 -0
  25. package/src/components/datepicker/datepicker-utils.test.ts +730 -0
  26. package/src/components/datepicker/datepicker-utils.ts +338 -9
  27. package/src/components/datepicker/datepicker.ts +25 -1
  28. package/dist/calendar-Dz1Cnzx5.cjs +0 -115
  29. package/dist/datepicker-CnCOXI2x.cjs +0 -289
  30. package/dist/datepicker-DsqM01iU.js +0 -1355
@@ -1,40 +1,40 @@
1
- import { e as et } from "./class-map-wy7PUk0P.js";
2
- import { P as bt, E as Q, x as D, n as y, a as kt } from "./element-CRDRygXu.js";
3
- import { r as U } from "./state-DS_kr2Fy.js";
1
+ import { e as nt } from "./class-map-wy7PUk0P.js";
2
+ import { P as xt, x as D, E as rt, n as f, a as Ot } from "./element-CRDRygXu.js";
3
+ import { r as q } from "./state-DS_kr2Fy.js";
4
4
  import "./icon-1dy7UZcu.js";
5
- const ut = 6048e5, Dt = 864e5, nt = Symbol.for("constructDateFrom");
6
- function v(t, e) {
7
- return typeof t == "function" ? t(e) : t && typeof t == "object" && nt in t ? t[nt](e) : t instanceof Date ? new t.constructor(e) : new Date(e);
8
- }
5
+ const mt = 6048e5, Pt = 864e5, at = Symbol.for("constructDateFrom");
9
6
  function k(t, e) {
10
- return v(e || t, t);
7
+ return typeof t == "function" ? t(e) : t && typeof t == "object" && at in t ? t[at](e) : t instanceof Date ? new t.constructor(e) : new Date(e);
8
+ }
9
+ function b(t, e) {
10
+ return k(e || t, t);
11
11
  }
12
- function X(t, e, n) {
13
- const r = k(t, n == null ? void 0 : n.in);
14
- return isNaN(e) ? v(t, NaN) : (e && r.setDate(r.getDate() + e), r);
12
+ function st(t, e, n) {
13
+ const r = b(t, n == null ? void 0 : n.in);
14
+ return isNaN(e) ? k(t, NaN) : (e && r.setDate(r.getDate() + e), r);
15
15
  }
16
- let St = {};
17
- function L() {
18
- return St;
16
+ let Nt = {};
17
+ function z() {
18
+ return Nt;
19
19
  }
20
- function I(t, e) {
21
- var o, c, l, d;
22
- const n = L(), r = (e == null ? void 0 : e.weekStartsOn) ?? ((c = (o = e == null ? void 0 : e.locale) == null ? void 0 : o.options) == null ? void 0 : c.weekStartsOn) ?? n.weekStartsOn ?? ((d = (l = n.locale) == null ? void 0 : l.options) == null ? void 0 : d.weekStartsOn) ?? 0, a = k(t, e == null ? void 0 : e.in), s = a.getDay(), i = (s < r ? 7 : 0) + s - r;
20
+ function R(t, e) {
21
+ var o, c, d, g;
22
+ const n = z(), r = (e == null ? void 0 : e.weekStartsOn) ?? ((c = (o = e == null ? void 0 : e.locale) == null ? void 0 : o.options) == null ? void 0 : c.weekStartsOn) ?? n.weekStartsOn ?? ((g = (d = n.locale) == null ? void 0 : d.options) == null ? void 0 : g.weekStartsOn) ?? 0, a = b(t, e == null ? void 0 : e.in), s = a.getDay(), i = (s < r ? 7 : 0) + s - r;
23
23
  return a.setDate(a.getDate() - i), a.setHours(0, 0, 0, 0), a;
24
24
  }
25
- function q(t, e) {
26
- return I(t, { ...e, weekStartsOn: 1 });
25
+ function B(t, e) {
26
+ return R(t, { ...e, weekStartsOn: 1 });
27
27
  }
28
- function ht(t, e) {
29
- const n = k(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = v(n, 0);
28
+ function gt(t, e) {
29
+ const n = b(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = k(n, 0);
30
30
  a.setFullYear(r + 1, 0, 4), a.setHours(0, 0, 0, 0);
31
- const s = q(a), i = v(n, 0);
31
+ const s = B(a), i = k(n, 0);
32
32
  i.setFullYear(r, 0, 4), i.setHours(0, 0, 0, 0);
33
- const o = q(i);
33
+ const o = B(i);
34
34
  return n.getTime() >= s.getTime() ? r + 1 : n.getTime() >= o.getTime() ? r : r - 1;
35
35
  }
36
- function rt(t) {
37
- const e = k(t), n = new Date(
36
+ function it(t) {
37
+ const e = b(t), n = new Date(
38
38
  Date.UTC(
39
39
  e.getFullYear(),
40
40
  e.getMonth(),
@@ -47,59 +47,59 @@ function rt(t) {
47
47
  );
48
48
  return n.setUTCFullYear(e.getFullYear()), +t - +n;
49
49
  }
50
- function dt(t, ...e) {
51
- const n = v.bind(
50
+ function yt(t, ...e) {
51
+ const n = k.bind(
52
52
  null,
53
53
  e.find((r) => typeof r == "object")
54
54
  );
55
55
  return e.map(n);
56
56
  }
57
57
  function K(t, e) {
58
- const n = k(t, e == null ? void 0 : e.in);
58
+ const n = b(t, e == null ? void 0 : e.in);
59
59
  return n.setHours(0, 0, 0, 0), n;
60
60
  }
61
- function Mt(t, e, n) {
62
- const [r, a] = dt(
61
+ function Ct(t, e, n) {
62
+ const [r, a] = yt(
63
63
  n == null ? void 0 : n.in,
64
64
  t,
65
65
  e
66
- ), s = K(r), i = K(a), o = +s - rt(s), c = +i - rt(i);
67
- return Math.round((o - c) / Dt);
66
+ ), s = K(r), i = K(a), o = +s - it(s), c = +i - it(i);
67
+ return Math.round((o - c) / Pt);
68
68
  }
69
- function vt(t, e) {
70
- const n = ht(t, e), r = v(t, 0);
71
- return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), q(r);
69
+ function $t(t, e) {
70
+ const n = gt(t, e), r = k(t, 0);
71
+ return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), B(r);
72
72
  }
73
- function Tt(t) {
73
+ function Et(t) {
74
74
  return t instanceof Date || typeof t == "object" && Object.prototype.toString.call(t) === "[object Date]";
75
75
  }
76
- function xt(t) {
77
- return !(!Tt(t) && typeof t != "number" || isNaN(+k(t)));
76
+ function Wt(t) {
77
+ return !(!Et(t) && typeof t != "number" || isNaN(+b(t)));
78
78
  }
79
- function Ot(t, e) {
80
- const n = k(t, e == null ? void 0 : e.in);
79
+ function _t(t, e) {
80
+ const n = b(t, e == null ? void 0 : e.in);
81
81
  return n.setHours(23, 59, 59, 999), n;
82
82
  }
83
- function Pt(t, e) {
84
- const [n, r] = dt(t, e.start, e.end);
83
+ function Yt(t, e) {
84
+ const [n, r] = yt(t, e.start, e.end);
85
85
  return { start: n, end: r };
86
86
  }
87
- function G(t, e) {
88
- const { start: n, end: r } = Pt(e == null ? void 0 : e.in, t);
87
+ function pt(t, e) {
88
+ const { start: n, end: r } = Yt(e == null ? void 0 : e.in, t);
89
89
  let a = +n > +r;
90
90
  const s = a ? +n : +r, i = a ? r : n;
91
91
  i.setHours(0, 0, 0, 0);
92
92
  let o = 1;
93
93
  const c = [];
94
94
  for (; +i <= s; )
95
- c.push(v(n, i)), i.setDate(i.getDate() + o), i.setHours(0, 0, 0, 0);
95
+ c.push(k(n, i)), i.setDate(i.getDate() + o), i.setHours(0, 0, 0, 0);
96
96
  return a ? c.reverse() : c;
97
97
  }
98
- function Nt(t, e) {
99
- const n = k(t, e == null ? void 0 : e.in);
98
+ function Ft(t, e) {
99
+ const n = b(t, e == null ? void 0 : e.in);
100
100
  return n.setFullYear(n.getFullYear(), 0, 1), n.setHours(0, 0, 0, 0), n;
101
101
  }
102
- const Ct = {
102
+ const It = {
103
103
  lessThanXSeconds: {
104
104
  one: "less than a second",
105
105
  other: "less than {{count}} seconds"
@@ -161,54 +161,54 @@ const Ct = {
161
161
  one: "almost 1 year",
162
162
  other: "almost {{count}} years"
163
163
  }
164
- }, $t = (t, e, n) => {
164
+ }, Ht = (t, e, n) => {
165
165
  let r;
166
- const a = Ct[t];
166
+ const a = It[t];
167
167
  return typeof a == "string" ? r = a : e === 1 ? r = a.one : r = a.other.replace("{{count}}", e.toString()), n != null && n.addSuffix ? n.comparison && n.comparison > 0 ? "in " + r : r + " ago" : r;
168
168
  };
169
- function V(t) {
169
+ function G(t) {
170
170
  return (e = {}) => {
171
171
  const n = e.width ? String(e.width) : t.defaultWidth;
172
172
  return t.formats[n] || t.formats[t.defaultWidth];
173
173
  };
174
174
  }
175
- const _t = {
175
+ const At = {
176
176
  full: "EEEE, MMMM do, y",
177
177
  long: "MMMM do, y",
178
178
  medium: "MMM d, y",
179
179
  short: "MM/dd/yyyy"
180
- }, Et = {
180
+ }, Rt = {
181
181
  full: "h:mm:ss a zzzz",
182
182
  long: "h:mm:ss a z",
183
183
  medium: "h:mm:ss a",
184
184
  short: "h:mm a"
185
- }, Wt = {
185
+ }, Ut = {
186
186
  full: "{{date}} 'at' {{time}}",
187
187
  long: "{{date}} 'at' {{time}}",
188
188
  medium: "{{date}}, {{time}}",
189
189
  short: "{{date}}, {{time}}"
190
- }, Yt = {
191
- date: V({
192
- formats: _t,
190
+ }, Lt = {
191
+ date: G({
192
+ formats: At,
193
193
  defaultWidth: "full"
194
194
  }),
195
- time: V({
196
- formats: Et,
195
+ time: G({
196
+ formats: Rt,
197
197
  defaultWidth: "full"
198
198
  }),
199
- dateTime: V({
200
- formats: Wt,
199
+ dateTime: G({
200
+ formats: Ut,
201
201
  defaultWidth: "full"
202
202
  })
203
- }, At = {
203
+ }, qt = {
204
204
  lastWeek: "'last' eeee 'at' p",
205
205
  yesterday: "'yesterday at' p",
206
206
  today: "'today at' p",
207
207
  tomorrow: "'tomorrow at' p",
208
208
  nextWeek: "eeee 'at' p",
209
209
  other: "P"
210
- }, Ft = (t, e, n, r) => At[t];
211
- function Y(t) {
210
+ }, Bt = (t, e, n, r) => qt[t];
211
+ function F(t) {
212
212
  return (e, n) => {
213
213
  const r = n != null && n.context ? String(n.context) : "standalone";
214
214
  let a;
@@ -223,15 +223,15 @@ function Y(t) {
223
223
  return a[s];
224
224
  };
225
225
  }
226
- const Ht = {
226
+ const zt = {
227
227
  narrow: ["B", "A"],
228
228
  abbreviated: ["BC", "AD"],
229
229
  wide: ["Before Christ", "Anno Domini"]
230
- }, It = {
230
+ }, jt = {
231
231
  narrow: ["1", "2", "3", "4"],
232
232
  abbreviated: ["Q1", "Q2", "Q3", "Q4"],
233
233
  wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
234
- }, Rt = {
234
+ }, Qt = {
235
235
  narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
236
236
  abbreviated: [
237
237
  "Jan",
@@ -261,7 +261,7 @@ const Ht = {
261
261
  "November",
262
262
  "December"
263
263
  ]
264
- }, Ut = {
264
+ }, Xt = {
265
265
  narrow: ["S", "M", "T", "W", "T", "F", "S"],
266
266
  short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
267
267
  abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
@@ -274,7 +274,7 @@ const Ht = {
274
274
  "Friday",
275
275
  "Saturday"
276
276
  ]
277
- }, qt = {
277
+ }, Gt = {
278
278
  narrow: {
279
279
  am: "a",
280
280
  pm: "p",
@@ -305,7 +305,7 @@ const Ht = {
305
305
  evening: "evening",
306
306
  night: "night"
307
307
  }
308
- }, Lt = {
308
+ }, Vt = {
309
309
  narrow: {
310
310
  am: "a",
311
311
  pm: "p",
@@ -336,7 +336,7 @@ const Ht = {
336
336
  evening: "in the evening",
337
337
  night: "at night"
338
338
  }
339
- }, Bt = (t, e) => {
339
+ }, Kt = (t, e) => {
340
340
  const n = Number(t), r = n % 100;
341
341
  if (r > 20 || r < 10)
342
342
  switch (r % 10) {
@@ -348,61 +348,61 @@ const Ht = {
348
348
  return n + "rd";
349
349
  }
350
350
  return n + "th";
351
- }, jt = {
352
- ordinalNumber: Bt,
353
- era: Y({
354
- values: Ht,
351
+ }, Jt = {
352
+ ordinalNumber: Kt,
353
+ era: F({
354
+ values: zt,
355
355
  defaultWidth: "wide"
356
356
  }),
357
- quarter: Y({
358
- values: It,
357
+ quarter: F({
358
+ values: jt,
359
359
  defaultWidth: "wide",
360
360
  argumentCallback: (t) => t - 1
361
361
  }),
362
- month: Y({
363
- values: Rt,
362
+ month: F({
363
+ values: Qt,
364
364
  defaultWidth: "wide"
365
365
  }),
366
- day: Y({
367
- values: Ut,
366
+ day: F({
367
+ values: Xt,
368
368
  defaultWidth: "wide"
369
369
  }),
370
- dayPeriod: Y({
371
- values: qt,
370
+ dayPeriod: F({
371
+ values: Gt,
372
372
  defaultWidth: "wide",
373
- formattingValues: Lt,
373
+ formattingValues: Vt,
374
374
  defaultFormattingWidth: "wide"
375
375
  })
376
376
  };
377
- function A(t) {
377
+ function I(t) {
378
378
  return (e, n = {}) => {
379
379
  const r = n.width, a = r && t.matchPatterns[r] || t.matchPatterns[t.defaultMatchWidth], s = e.match(a);
380
380
  if (!s)
381
381
  return null;
382
- const i = s[0], o = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], c = Array.isArray(o) ? Qt(o, (m) => m.test(i)) : (
382
+ const i = s[0], o = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], c = Array.isArray(o) ? te(o, (m) => m.test(i)) : (
383
383
  // [TODO] -- I challenge you to fix the type
384
- zt(o, (m) => m.test(i))
384
+ Zt(o, (m) => m.test(i))
385
385
  );
386
- let l;
387
- l = t.valueCallback ? t.valueCallback(c) : c, l = n.valueCallback ? (
386
+ let d;
387
+ d = t.valueCallback ? t.valueCallback(c) : c, d = n.valueCallback ? (
388
388
  // [TODO] -- I challenge you to fix the type
389
- n.valueCallback(l)
390
- ) : l;
391
- const d = e.slice(i.length);
392
- return { value: l, rest: d };
389
+ n.valueCallback(d)
390
+ ) : d;
391
+ const g = e.slice(i.length);
392
+ return { value: d, rest: g };
393
393
  };
394
394
  }
395
- function zt(t, e) {
395
+ function Zt(t, e) {
396
396
  for (const n in t)
397
397
  if (Object.prototype.hasOwnProperty.call(t, n) && e(t[n]))
398
398
  return n;
399
399
  }
400
- function Qt(t, e) {
400
+ function te(t, e) {
401
401
  for (let n = 0; n < t.length; n++)
402
402
  if (e(t[n]))
403
403
  return n;
404
404
  }
405
- function Xt(t) {
405
+ function ee(t) {
406
406
  return (e, n = {}) => {
407
407
  const r = e.match(t.matchPattern);
408
408
  if (!r) return null;
@@ -414,23 +414,23 @@ function Xt(t) {
414
414
  return { value: i, rest: o };
415
415
  };
416
416
  }
417
- const Gt = /^(\d+)(th|st|nd|rd)?/i, Vt = /\d+/i, Jt = {
417
+ const ne = /^(\d+)(th|st|nd|rd)?/i, re = /\d+/i, ae = {
418
418
  narrow: /^(b|a)/i,
419
419
  abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
420
420
  wide: /^(before christ|before common era|anno domini|common era)/i
421
- }, Kt = {
421
+ }, se = {
422
422
  any: [/^b/i, /^(a|c)/i]
423
- }, Zt = {
423
+ }, ie = {
424
424
  narrow: /^[1234]/i,
425
425
  abbreviated: /^q[1234]/i,
426
426
  wide: /^[1234](th|st|nd|rd)? quarter/i
427
- }, te = {
427
+ }, oe = {
428
428
  any: [/1/i, /2/i, /3/i, /4/i]
429
- }, ee = {
429
+ }, ce = {
430
430
  narrow: /^[jfmasond]/i,
431
431
  abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
432
432
  wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
433
- }, ne = {
433
+ }, ue = {
434
434
  narrow: [
435
435
  /^j/i,
436
436
  /^f/i,
@@ -459,18 +459,18 @@ const Gt = /^(\d+)(th|st|nd|rd)?/i, Vt = /\d+/i, Jt = {
459
459
  /^n/i,
460
460
  /^d/i
461
461
  ]
462
- }, re = {
462
+ }, le = {
463
463
  narrow: /^[smtwf]/i,
464
464
  short: /^(su|mo|tu|we|th|fr|sa)/i,
465
465
  abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
466
466
  wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
467
- }, ae = {
467
+ }, he = {
468
468
  narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
469
469
  any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
470
- }, se = {
470
+ }, de = {
471
471
  narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
472
472
  any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
473
- }, ie = {
473
+ }, fe = {
474
474
  any: {
475
475
  am: /^a/i,
476
476
  pm: /^p/i,
@@ -481,80 +481,80 @@ const Gt = /^(\d+)(th|st|nd|rd)?/i, Vt = /\d+/i, Jt = {
481
481
  evening: /evening/i,
482
482
  night: /night/i
483
483
  }
484
- }, oe = {
485
- ordinalNumber: Xt({
486
- matchPattern: Gt,
487
- parsePattern: Vt,
484
+ }, me = {
485
+ ordinalNumber: ee({
486
+ matchPattern: ne,
487
+ parsePattern: re,
488
488
  valueCallback: (t) => parseInt(t, 10)
489
489
  }),
490
- era: A({
491
- matchPatterns: Jt,
490
+ era: I({
491
+ matchPatterns: ae,
492
492
  defaultMatchWidth: "wide",
493
- parsePatterns: Kt,
493
+ parsePatterns: se,
494
494
  defaultParseWidth: "any"
495
495
  }),
496
- quarter: A({
497
- matchPatterns: Zt,
496
+ quarter: I({
497
+ matchPatterns: ie,
498
498
  defaultMatchWidth: "wide",
499
- parsePatterns: te,
499
+ parsePatterns: oe,
500
500
  defaultParseWidth: "any",
501
501
  valueCallback: (t) => t + 1
502
502
  }),
503
- month: A({
504
- matchPatterns: ee,
503
+ month: I({
504
+ matchPatterns: ce,
505
505
  defaultMatchWidth: "wide",
506
- parsePatterns: ne,
506
+ parsePatterns: ue,
507
507
  defaultParseWidth: "any"
508
508
  }),
509
- day: A({
510
- matchPatterns: re,
509
+ day: I({
510
+ matchPatterns: le,
511
511
  defaultMatchWidth: "wide",
512
- parsePatterns: ae,
512
+ parsePatterns: he,
513
513
  defaultParseWidth: "any"
514
514
  }),
515
- dayPeriod: A({
516
- matchPatterns: se,
515
+ dayPeriod: I({
516
+ matchPatterns: de,
517
517
  defaultMatchWidth: "any",
518
- parsePatterns: ie,
518
+ parsePatterns: fe,
519
519
  defaultParseWidth: "any"
520
520
  })
521
- }, ce = {
521
+ }, ge = {
522
522
  code: "en-US",
523
- formatDistance: $t,
524
- formatLong: Yt,
525
- formatRelative: Ft,
526
- localize: jt,
527
- match: oe,
523
+ formatDistance: Ht,
524
+ formatLong: Lt,
525
+ formatRelative: Bt,
526
+ localize: Jt,
527
+ match: me,
528
528
  options: {
529
529
  weekStartsOn: 0,
530
530
  firstWeekContainsDate: 1
531
531
  }
532
532
  };
533
- function le(t, e) {
534
- const n = k(t, e == null ? void 0 : e.in);
535
- return Mt(n, Nt(n)) + 1;
533
+ function ye(t, e) {
534
+ const n = b(t, e == null ? void 0 : e.in);
535
+ return Ct(n, Ft(n)) + 1;
536
536
  }
537
- function ue(t, e) {
538
- const n = k(t, e == null ? void 0 : e.in), r = +q(n) - +vt(n);
539
- return Math.round(r / ut) + 1;
537
+ function pe(t, e) {
538
+ const n = b(t, e == null ? void 0 : e.in), r = +B(n) - +$t(n);
539
+ return Math.round(r / mt) + 1;
540
540
  }
541
- function ft(t, e) {
542
- var d, m, g, S;
543
- const n = k(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = L(), s = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((m = (d = e == null ? void 0 : e.locale) == null ? void 0 : d.options) == null ? void 0 : m.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((S = (g = a.locale) == null ? void 0 : g.options) == null ? void 0 : S.firstWeekContainsDate) ?? 1, i = v((e == null ? void 0 : e.in) || t, 0);
541
+ function wt(t, e) {
542
+ var g, m, v, M;
543
+ const n = b(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = z(), s = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((m = (g = e == null ? void 0 : e.locale) == null ? void 0 : g.options) == null ? void 0 : m.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((M = (v = a.locale) == null ? void 0 : v.options) == null ? void 0 : M.firstWeekContainsDate) ?? 1, i = k((e == null ? void 0 : e.in) || t, 0);
544
544
  i.setFullYear(r + 1, 0, s), i.setHours(0, 0, 0, 0);
545
- const o = I(i, e), c = v((e == null ? void 0 : e.in) || t, 0);
545
+ const o = R(i, e), c = k((e == null ? void 0 : e.in) || t, 0);
546
546
  c.setFullYear(r, 0, s), c.setHours(0, 0, 0, 0);
547
- const l = I(c, e);
548
- return +n >= +o ? r + 1 : +n >= +l ? r : r - 1;
547
+ const d = R(c, e);
548
+ return +n >= +o ? r + 1 : +n >= +d ? r : r - 1;
549
549
  }
550
- function he(t, e) {
551
- var o, c, l, d;
552
- const n = L(), r = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((c = (o = e == null ? void 0 : e.locale) == null ? void 0 : o.options) == null ? void 0 : c.firstWeekContainsDate) ?? n.firstWeekContainsDate ?? ((d = (l = n.locale) == null ? void 0 : l.options) == null ? void 0 : d.firstWeekContainsDate) ?? 1, a = ft(t, e), s = v((e == null ? void 0 : e.in) || t, 0);
553
- return s.setFullYear(a, 0, r), s.setHours(0, 0, 0, 0), I(s, e);
550
+ function we(t, e) {
551
+ var o, c, d, g;
552
+ const n = z(), r = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((c = (o = e == null ? void 0 : e.locale) == null ? void 0 : o.options) == null ? void 0 : c.firstWeekContainsDate) ?? n.firstWeekContainsDate ?? ((g = (d = n.locale) == null ? void 0 : d.options) == null ? void 0 : g.firstWeekContainsDate) ?? 1, a = wt(t, e), s = k((e == null ? void 0 : e.in) || t, 0);
553
+ return s.setFullYear(a, 0, r), s.setHours(0, 0, 0, 0), R(s, e);
554
554
  }
555
- function mt(t, e) {
556
- const n = k(t, e == null ? void 0 : e.in), r = +I(n, e) - +he(n, e);
557
- return Math.round(r / ut) + 1;
555
+ function bt(t, e) {
556
+ const n = b(t, e == null ? void 0 : e.in), r = +R(n, e) - +we(n, e);
557
+ return Math.round(r / mt) + 1;
558
558
  }
559
559
  function u(t, e) {
560
560
  const n = t < 0 ? "-" : "", r = Math.abs(t).toString().padStart(e, "0");
@@ -614,14 +614,14 @@ const T = {
614
614
  );
615
615
  return u(a, e.length);
616
616
  }
617
- }, _ = {
617
+ }, E = {
618
618
  midnight: "midnight",
619
619
  noon: "noon",
620
620
  morning: "morning",
621
621
  afternoon: "afternoon",
622
622
  evening: "evening",
623
623
  night: "night"
624
- }, at = {
624
+ }, ot = {
625
625
  // Era
626
626
  G: function(t, e, n) {
627
627
  const r = t.getFullYear() > 0 ? 1 : 0;
@@ -650,7 +650,7 @@ const T = {
650
650
  },
651
651
  // Local week-numbering year
652
652
  Y: function(t, e, n, r) {
653
- const a = ft(t, r), s = a > 0 ? a : 1 - a;
653
+ const a = wt(t, r), s = a > 0 ? a : 1 - a;
654
654
  if (e === "YY") {
655
655
  const i = s % 100;
656
656
  return u(i, 2);
@@ -659,7 +659,7 @@ const T = {
659
659
  },
660
660
  // ISO week-numbering year
661
661
  R: function(t, e) {
662
- const n = ht(t);
662
+ const n = gt(t);
663
663
  return u(n, e.length);
664
664
  },
665
665
  // Extended year. This is a single number designating the year of this calendar system.
@@ -804,12 +804,12 @@ const T = {
804
804
  },
805
805
  // Local week of year
806
806
  w: function(t, e, n, r) {
807
- const a = mt(t, r);
807
+ const a = bt(t, r);
808
808
  return e === "wo" ? n.ordinalNumber(a, { unit: "week" }) : u(a, e.length);
809
809
  },
810
810
  // ISO week of year
811
811
  I: function(t, e, n) {
812
- const r = ue(t);
812
+ const r = pe(t);
813
813
  return e === "Io" ? n.ordinalNumber(r, { unit: "week" }) : u(r, e.length);
814
814
  },
815
815
  // Day of the month
@@ -818,7 +818,7 @@ const T = {
818
818
  },
819
819
  // Day of year
820
820
  D: function(t, e, n) {
821
- const r = le(t);
821
+ const r = ye(t);
822
822
  return e === "Do" ? n.ordinalNumber(r, { unit: "dayOfYear" }) : u(r, e.length);
823
823
  },
824
824
  // Day of week
@@ -1004,7 +1004,7 @@ const T = {
1004
1004
  b: function(t, e, n) {
1005
1005
  const r = t.getHours();
1006
1006
  let a;
1007
- switch (r === 12 ? a = _.noon : r === 0 ? a = _.midnight : a = r / 12 >= 1 ? "pm" : "am", e) {
1007
+ switch (r === 12 ? a = E.noon : r === 0 ? a = E.midnight : a = r / 12 >= 1 ? "pm" : "am", e) {
1008
1008
  case "b":
1009
1009
  case "bb":
1010
1010
  return n.dayPeriod(a, {
@@ -1033,7 +1033,7 @@ const T = {
1033
1033
  B: function(t, e, n) {
1034
1034
  const r = t.getHours();
1035
1035
  let a;
1036
- switch (r >= 17 ? a = _.evening : r >= 12 ? a = _.afternoon : r >= 4 ? a = _.morning : a = _.night, e) {
1036
+ switch (r >= 17 ? a = E.evening : r >= 12 ? a = E.afternoon : r >= 4 ? a = E.morning : a = E.night, e) {
1037
1037
  case "B":
1038
1038
  case "BB":
1039
1039
  case "BBB":
@@ -1096,13 +1096,13 @@ const T = {
1096
1096
  switch (e) {
1097
1097
  // Hours and optional minutes
1098
1098
  case "X":
1099
- return it(r);
1099
+ return ut(r);
1100
1100
  // Hours, minutes and optional seconds without `:` delimiter
1101
1101
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1102
1102
  // so this token always has the same output as `XX`
1103
1103
  case "XXXX":
1104
1104
  case "XX":
1105
- return N(r);
1105
+ return P(r);
1106
1106
  // Hours, minutes and optional seconds with `:` delimiter
1107
1107
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1108
1108
  // so this token always has the same output as `XXX`
@@ -1110,7 +1110,7 @@ const T = {
1110
1110
  case "XXX":
1111
1111
  // Hours and minutes with `:` delimiter
1112
1112
  default:
1113
- return N(r, ":");
1113
+ return P(r, ":");
1114
1114
  }
1115
1115
  },
1116
1116
  // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
@@ -1119,13 +1119,13 @@ const T = {
1119
1119
  switch (e) {
1120
1120
  // Hours and optional minutes
1121
1121
  case "x":
1122
- return it(r);
1122
+ return ut(r);
1123
1123
  // Hours, minutes and optional seconds without `:` delimiter
1124
1124
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1125
1125
  // so this token always has the same output as `xx`
1126
1126
  case "xxxx":
1127
1127
  case "xx":
1128
- return N(r);
1128
+ return P(r);
1129
1129
  // Hours, minutes and optional seconds with `:` delimiter
1130
1130
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1131
1131
  // so this token always has the same output as `xxx`
@@ -1133,7 +1133,7 @@ const T = {
1133
1133
  case "xxx":
1134
1134
  // Hours and minutes with `:` delimiter
1135
1135
  default:
1136
- return N(r, ":");
1136
+ return P(r, ":");
1137
1137
  }
1138
1138
  },
1139
1139
  // Timezone (GMT)
@@ -1144,11 +1144,11 @@ const T = {
1144
1144
  case "O":
1145
1145
  case "OO":
1146
1146
  case "OOO":
1147
- return "GMT" + st(r, ":");
1147
+ return "GMT" + ct(r, ":");
1148
1148
  // Long
1149
1149
  case "OOOO":
1150
1150
  default:
1151
- return "GMT" + N(r, ":");
1151
+ return "GMT" + P(r, ":");
1152
1152
  }
1153
1153
  },
1154
1154
  // Timezone (specific non-location)
@@ -1159,11 +1159,11 @@ const T = {
1159
1159
  case "z":
1160
1160
  case "zz":
1161
1161
  case "zzz":
1162
- return "GMT" + st(r, ":");
1162
+ return "GMT" + ct(r, ":");
1163
1163
  // Long
1164
1164
  case "zzzz":
1165
1165
  default:
1166
- return "GMT" + N(r, ":");
1166
+ return "GMT" + P(r, ":");
1167
1167
  }
1168
1168
  },
1169
1169
  // Seconds timestamp
@@ -1176,18 +1176,18 @@ const T = {
1176
1176
  return u(+t, e.length);
1177
1177
  }
1178
1178
  };
1179
- function st(t, e = "") {
1179
+ function ct(t, e = "") {
1180
1180
  const n = t > 0 ? "-" : "+", r = Math.abs(t), a = Math.trunc(r / 60), s = r % 60;
1181
1181
  return s === 0 ? n + String(a) : n + String(a) + e + u(s, 2);
1182
1182
  }
1183
- function it(t, e) {
1184
- return t % 60 === 0 ? (t > 0 ? "-" : "+") + u(Math.abs(t) / 60, 2) : N(t, e);
1183
+ function ut(t, e) {
1184
+ return t % 60 === 0 ? (t > 0 ? "-" : "+") + u(Math.abs(t) / 60, 2) : P(t, e);
1185
1185
  }
1186
- function N(t, e = "") {
1186
+ function P(t, e = "") {
1187
1187
  const n = t > 0 ? "-" : "+", r = Math.abs(t), a = u(Math.trunc(r / 60), 2), s = u(r % 60, 2);
1188
1188
  return n + a + e + s;
1189
1189
  }
1190
- const ot = (t, e) => {
1190
+ const lt = (t, e) => {
1191
1191
  switch (t) {
1192
1192
  case "P":
1193
1193
  return e.date({ width: "short" });
@@ -1199,7 +1199,7 @@ const ot = (t, e) => {
1199
1199
  default:
1200
1200
  return e.date({ width: "full" });
1201
1201
  }
1202
- }, gt = (t, e) => {
1202
+ }, Dt = (t, e) => {
1203
1203
  switch (t) {
1204
1204
  case "p":
1205
1205
  return e.time({ width: "short" });
@@ -1211,10 +1211,10 @@ const ot = (t, e) => {
1211
1211
  default:
1212
1212
  return e.time({ width: "full" });
1213
1213
  }
1214
- }, de = (t, e) => {
1214
+ }, be = (t, e) => {
1215
1215
  const n = t.match(/(P+)(p+)?/) || [], r = n[1], a = n[2];
1216
1216
  if (!a)
1217
- return ot(t, e);
1217
+ return lt(t, e);
1218
1218
  let s;
1219
1219
  switch (r) {
1220
1220
  case "P":
@@ -1231,75 +1231,75 @@ const ot = (t, e) => {
1231
1231
  s = e.dateTime({ width: "full" });
1232
1232
  break;
1233
1233
  }
1234
- return s.replace("{{date}}", ot(r, e)).replace("{{time}}", gt(a, e));
1235
- }, fe = {
1236
- p: gt,
1237
- P: de
1238
- }, me = /^D+$/, ge = /^Y+$/, ye = ["D", "DD", "YY", "YYYY"];
1239
- function pe(t) {
1240
- return me.test(t);
1234
+ return s.replace("{{date}}", lt(r, e)).replace("{{time}}", Dt(a, e));
1235
+ }, De = {
1236
+ p: Dt,
1237
+ P: be
1238
+ }, Se = /^D+$/, ke = /^Y+$/, ve = ["D", "DD", "YY", "YYYY"];
1239
+ function Me(t) {
1240
+ return Se.test(t);
1241
1241
  }
1242
- function we(t) {
1243
- return ge.test(t);
1242
+ function Te(t) {
1243
+ return ke.test(t);
1244
1244
  }
1245
- function be(t, e, n) {
1246
- const r = ke(t, e, n);
1247
- if (console.warn(r), ye.includes(t)) throw new RangeError(r);
1245
+ function xe(t, e, n) {
1246
+ const r = Oe(t, e, n);
1247
+ if (console.warn(r), ve.includes(t)) throw new RangeError(r);
1248
1248
  }
1249
- function ke(t, e, n) {
1249
+ function Oe(t, e, n) {
1250
1250
  const r = t[0] === "Y" ? "years" : "days of the month";
1251
1251
  return `Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
1252
1252
  }
1253
- const De = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Se = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Me = /^'([^]*?)'?$/, ve = /''/g, Te = /[a-zA-Z]/;
1254
- function xe(t, e, n) {
1255
- var d, m, g, S;
1256
- const r = L(), a = r.locale ?? ce, s = r.firstWeekContainsDate ?? ((m = (d = r.locale) == null ? void 0 : d.options) == null ? void 0 : m.firstWeekContainsDate) ?? 1, i = r.weekStartsOn ?? ((S = (g = r.locale) == null ? void 0 : g.options) == null ? void 0 : S.weekStartsOn) ?? 0, o = k(t, n == null ? void 0 : n.in);
1257
- if (!xt(o))
1253
+ const Pe = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Ne = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Ce = /^'([^]*?)'?$/, $e = /''/g, Ee = /[a-zA-Z]/;
1254
+ function We(t, e, n) {
1255
+ var g, m, v, M;
1256
+ const r = z(), a = r.locale ?? ge, s = r.firstWeekContainsDate ?? ((m = (g = r.locale) == null ? void 0 : g.options) == null ? void 0 : m.firstWeekContainsDate) ?? 1, i = r.weekStartsOn ?? ((M = (v = r.locale) == null ? void 0 : v.options) == null ? void 0 : M.weekStartsOn) ?? 0, o = b(t, n == null ? void 0 : n.in);
1257
+ if (!Wt(o))
1258
1258
  throw new RangeError("Invalid time value");
1259
- let c = e.match(Se).map((b) => {
1260
- const w = b[0];
1261
- if (w === "p" || w === "P") {
1262
- const W = fe[w];
1263
- return W(b, a.formatLong);
1259
+ let c = e.match(Ne).map((w) => {
1260
+ const p = w[0];
1261
+ if (p === "p" || p === "P") {
1262
+ const Y = De[p];
1263
+ return Y(w, a.formatLong);
1264
1264
  }
1265
- return b;
1266
- }).join("").match(De).map((b) => {
1267
- if (b === "''")
1265
+ return w;
1266
+ }).join("").match(Pe).map((w) => {
1267
+ if (w === "''")
1268
1268
  return { isToken: !1, value: "'" };
1269
- const w = b[0];
1270
- if (w === "'")
1271
- return { isToken: !1, value: Oe(b) };
1272
- if (at[w])
1273
- return { isToken: !0, value: b };
1274
- if (w.match(Te))
1269
+ const p = w[0];
1270
+ if (p === "'")
1271
+ return { isToken: !1, value: _e(w) };
1272
+ if (ot[p])
1273
+ return { isToken: !0, value: w };
1274
+ if (p.match(Ee))
1275
1275
  throw new RangeError(
1276
- "Format string contains an unescaped latin alphabet character `" + w + "`"
1276
+ "Format string contains an unescaped latin alphabet character `" + p + "`"
1277
1277
  );
1278
- return { isToken: !1, value: b };
1278
+ return { isToken: !1, value: w };
1279
1279
  });
1280
1280
  a.localize.preprocessor && (c = a.localize.preprocessor(o, c));
1281
- const l = {
1281
+ const d = {
1282
1282
  firstWeekContainsDate: s,
1283
1283
  weekStartsOn: i,
1284
1284
  locale: a
1285
1285
  };
1286
- return c.map((b) => {
1287
- if (!b.isToken) return b.value;
1288
- const w = b.value;
1289
- (we(w) || pe(w)) && be(w, e, String(t));
1290
- const W = at[w[0]];
1291
- return W(o, w, a.localize, l);
1286
+ return c.map((w) => {
1287
+ if (!w.isToken) return w.value;
1288
+ const p = w.value;
1289
+ (Te(p) || Me(p)) && xe(p, e, String(t));
1290
+ const Y = ot[p[0]];
1291
+ return Y(o, p, a.localize, d);
1292
1292
  }).join("");
1293
1293
  }
1294
- function Oe(t) {
1295
- const e = t.match(Me);
1296
- return e ? e[1].replace(ve, "'") : t;
1294
+ function _e(t) {
1295
+ const e = t.match(Ce);
1296
+ return e ? e[1].replace($e, "'") : t;
1297
1297
  }
1298
- function Pe(t, e) {
1299
- const n = k(t, e == null ? void 0 : e.in).getDay();
1298
+ function Ye(t, e) {
1299
+ const n = b(t, e == null ? void 0 : e.in).getDay();
1300
1300
  return n === 0 ? 7 : n;
1301
1301
  }
1302
- function Ne(t, e, n = "long") {
1302
+ function Fe(t, e, n = "long") {
1303
1303
  return new Intl.DateTimeFormat("en-US", {
1304
1304
  // Enforces engine to render the time. Without the option JavaScriptCore omits it.
1305
1305
  hour: "numeric",
@@ -1307,94 +1307,94 @@ function Ne(t, e, n = "long") {
1307
1307
  timeZoneName: n
1308
1308
  }).format(e).split(/\s/g).slice(2).join(" ");
1309
1309
  }
1310
- const J = {}, H = {};
1311
- function C(t, e) {
1310
+ const V = {}, A = {};
1311
+ function N(t, e) {
1312
1312
  try {
1313
- const r = (J[t] || (J[t] = new Intl.DateTimeFormat("en-US", {
1313
+ const r = (V[t] || (V[t] = new Intl.DateTimeFormat("en-US", {
1314
1314
  timeZone: t,
1315
1315
  timeZoneName: "longOffset"
1316
1316
  }).format))(e).split("GMT")[1];
1317
- return r in H ? H[r] : ct(r, r.split(":"));
1317
+ return r in A ? A[r] : ht(r, r.split(":"));
1318
1318
  } catch {
1319
- if (t in H) return H[t];
1320
- const n = t == null ? void 0 : t.match(Ce);
1321
- return n ? ct(t, n.slice(1)) : NaN;
1319
+ if (t in A) return A[t];
1320
+ const n = t == null ? void 0 : t.match(Ie);
1321
+ return n ? ht(t, n.slice(1)) : NaN;
1322
1322
  }
1323
1323
  }
1324
- const Ce = /([+-]\d\d):?(\d\d)?/;
1325
- function ct(t, e) {
1324
+ const Ie = /([+-]\d\d):?(\d\d)?/;
1325
+ function ht(t, e) {
1326
1326
  const n = +(e[0] || 0), r = +(e[1] || 0), a = +(e[2] || 0) / 60;
1327
- return H[t] = n * 60 + r > 0 ? n * 60 + r + a : n * 60 - r - a;
1327
+ return A[t] = n * 60 + r > 0 ? n * 60 + r + a : n * 60 - r - a;
1328
1328
  }
1329
- class M extends Date {
1329
+ class S extends Date {
1330
1330
  //#region static
1331
1331
  constructor(...e) {
1332
- super(), e.length > 1 && typeof e[e.length - 1] == "string" && (this.timeZone = e.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(C(this.timeZone, this)) ? this.setTime(NaN) : e.length ? typeof e[0] == "number" && (e.length === 1 || e.length === 2 && typeof e[1] != "number") ? this.setTime(e[0]) : typeof e[0] == "string" ? this.setTime(+new Date(e[0])) : e[0] instanceof Date ? this.setTime(+e[0]) : (this.setTime(+new Date(...e)), yt(this), Z(this)) : this.setTime(Date.now());
1332
+ super(), e.length > 1 && typeof e[e.length - 1] == "string" && (this.timeZone = e.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(N(this.timeZone, this)) ? this.setTime(NaN) : e.length ? typeof e[0] == "number" && (e.length === 1 || e.length === 2 && typeof e[1] != "number") ? this.setTime(e[0]) : typeof e[0] == "string" ? this.setTime(+new Date(e[0])) : e[0] instanceof Date ? this.setTime(+e[0]) : (this.setTime(+new Date(...e)), St(this), J(this)) : this.setTime(Date.now());
1333
1333
  }
1334
1334
  static tz(e, ...n) {
1335
- return n.length ? new M(...n, e) : new M(Date.now(), e);
1335
+ return n.length ? new S(...n, e) : new S(Date.now(), e);
1336
1336
  }
1337
1337
  //#endregion
1338
1338
  //#region time zone
1339
1339
  withTimeZone(e) {
1340
- return new M(+this, e);
1340
+ return new S(+this, e);
1341
1341
  }
1342
1342
  getTimezoneOffset() {
1343
- const e = -C(this.timeZone, this);
1343
+ const e = -N(this.timeZone, this);
1344
1344
  return e > 0 ? Math.floor(e) : Math.ceil(e);
1345
1345
  }
1346
1346
  //#endregion
1347
1347
  //#region time
1348
1348
  setTime(e) {
1349
- return Date.prototype.setTime.apply(this, arguments), Z(this), +this;
1349
+ return Date.prototype.setTime.apply(this, arguments), J(this), +this;
1350
1350
  }
1351
1351
  //#endregion
1352
1352
  //#region date-fns integration
1353
1353
  [Symbol.for("constructDateFrom")](e) {
1354
- return new M(+new Date(e), this.timeZone);
1354
+ return new S(+new Date(e), this.timeZone);
1355
1355
  }
1356
1356
  //#endregion
1357
1357
  }
1358
- const lt = /^(get|set)(?!UTC)/;
1358
+ const dt = /^(get|set)(?!UTC)/;
1359
1359
  Object.getOwnPropertyNames(Date.prototype).forEach((t) => {
1360
- if (!lt.test(t)) return;
1361
- const e = t.replace(lt, "$1UTC");
1362
- M.prototype[e] && (t.startsWith("get") ? M.prototype[t] = function() {
1360
+ if (!dt.test(t)) return;
1361
+ const e = t.replace(dt, "$1UTC");
1362
+ S.prototype[e] && (t.startsWith("get") ? S.prototype[t] = function() {
1363
1363
  return this.internal[e]();
1364
- } : (M.prototype[t] = function() {
1365
- return Date.prototype[e].apply(this.internal, arguments), $e(this), +this;
1366
- }, M.prototype[e] = function() {
1367
- return Date.prototype[e].apply(this, arguments), Z(this), +this;
1364
+ } : (S.prototype[t] = function() {
1365
+ return Date.prototype[e].apply(this.internal, arguments), He(this), +this;
1366
+ }, S.prototype[e] = function() {
1367
+ return Date.prototype[e].apply(this, arguments), J(this), +this;
1368
1368
  }));
1369
1369
  });
1370
- function Z(t) {
1371
- t.internal.setTime(+t), t.internal.setUTCSeconds(t.internal.getUTCSeconds() - Math.round(-C(t.timeZone, t) * 60));
1370
+ function J(t) {
1371
+ t.internal.setTime(+t), t.internal.setUTCSeconds(t.internal.getUTCSeconds() - Math.round(-N(t.timeZone, t) * 60));
1372
1372
  }
1373
- function $e(t) {
1374
- Date.prototype.setFullYear.call(t, t.internal.getUTCFullYear(), t.internal.getUTCMonth(), t.internal.getUTCDate()), Date.prototype.setHours.call(t, t.internal.getUTCHours(), t.internal.getUTCMinutes(), t.internal.getUTCSeconds(), t.internal.getUTCMilliseconds()), yt(t);
1373
+ function He(t) {
1374
+ Date.prototype.setFullYear.call(t, t.internal.getUTCFullYear(), t.internal.getUTCMonth(), t.internal.getUTCDate()), Date.prototype.setHours.call(t, t.internal.getUTCHours(), t.internal.getUTCMinutes(), t.internal.getUTCSeconds(), t.internal.getUTCMilliseconds()), St(t);
1375
1375
  }
1376
- function yt(t) {
1377
- const e = C(t.timeZone, t), n = e > 0 ? Math.floor(e) : Math.ceil(e), r = /* @__PURE__ */ new Date(+t);
1376
+ function St(t) {
1377
+ const e = N(t.timeZone, t), n = e > 0 ? Math.floor(e) : Math.ceil(e), r = /* @__PURE__ */ new Date(+t);
1378
1378
  r.setUTCHours(r.getUTCHours() - 1);
1379
1379
  const a = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset(), s = -(/* @__PURE__ */ new Date(+r)).getTimezoneOffset(), i = a - s, o = Date.prototype.getHours.apply(t) !== t.internal.getUTCHours();
1380
1380
  i && o && t.internal.setUTCMinutes(t.internal.getUTCMinutes() + i);
1381
1381
  const c = a - n;
1382
1382
  c && Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + c);
1383
- const l = /* @__PURE__ */ new Date(+t);
1384
- l.setUTCSeconds(0);
1385
- const d = a > 0 ? l.getSeconds() : (l.getSeconds() - 60) % 60, m = Math.round(-(C(t.timeZone, t) * 60)) % 60;
1386
- (m || d) && (t.internal.setUTCSeconds(t.internal.getUTCSeconds() + m), Date.prototype.setUTCSeconds.call(t, Date.prototype.getUTCSeconds.call(t) + m + d));
1387
- const g = C(t.timeZone, t), S = g > 0 ? Math.floor(g) : Math.ceil(g), w = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset() - S, W = S !== n, tt = w - c;
1388
- if (W && tt) {
1389
- Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + tt);
1390
- const j = C(t.timeZone, t), wt = j > 0 ? Math.floor(j) : Math.ceil(j), z = S - wt;
1391
- z && (t.internal.setUTCMinutes(t.internal.getUTCMinutes() + z), Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + z));
1392
- }
1393
- }
1394
- class O extends M {
1383
+ const d = /* @__PURE__ */ new Date(+t);
1384
+ d.setUTCSeconds(0);
1385
+ const g = a > 0 ? d.getSeconds() : (d.getSeconds() - 60) % 60, m = Math.round(-(N(t.timeZone, t) * 60)) % 60;
1386
+ (m || g) && (t.internal.setUTCSeconds(t.internal.getUTCSeconds() + m), Date.prototype.setUTCSeconds.call(t, Date.prototype.getUTCSeconds.call(t) + m + g));
1387
+ const v = N(t.timeZone, t), M = v > 0 ? Math.floor(v) : Math.ceil(v), p = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset() - M, Y = M !== n, et = p - c;
1388
+ if (Y && et) {
1389
+ Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + et);
1390
+ const Q = N(t.timeZone, t), Tt = Q > 0 ? Math.floor(Q) : Math.ceil(Q), X = M - Tt;
1391
+ X && (t.internal.setUTCMinutes(t.internal.getUTCMinutes() + X), Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + X));
1392
+ }
1393
+ }
1394
+ class x extends S {
1395
1395
  //#region static
1396
1396
  static tz(e, ...n) {
1397
- return n.length ? new O(...n, e) : new O(Date.now(), e);
1397
+ return n.length ? new x(...n, e) : new x(Date.now(), e);
1398
1398
  }
1399
1399
  //#endregion
1400
1400
  //#region representation
@@ -1411,7 +1411,7 @@ class O extends M {
1411
1411
  }
1412
1412
  toTimeString() {
1413
1413
  const e = this.internal.toUTCString().split(" ")[4], [n, r, a] = this.tzComponents();
1414
- return `${e} GMT${n}${r}${a} (${Ne(this.timeZone, this)})`;
1414
+ return `${e} GMT${n}${r}${a} (${Fe(this.timeZone, this)})`;
1415
1415
  }
1416
1416
  toLocaleString(e, n) {
1417
1417
  return Date.prototype.toLocaleString.call(this, e, {
@@ -1439,17 +1439,17 @@ class O extends M {
1439
1439
  }
1440
1440
  //#endregion
1441
1441
  withTimeZone(e) {
1442
- return new O(+this, e);
1442
+ return new x(+this, e);
1443
1443
  }
1444
1444
  //#region date-fns integration
1445
1445
  [Symbol.for("constructDateFrom")](e) {
1446
- return new O(+new Date(e), this.timeZone);
1446
+ return new x(+new Date(e), this.timeZone);
1447
1447
  }
1448
1448
  //#endregion
1449
1449
  }
1450
1450
  window.pktTz = window.pktTz === void 0 ? "Europe/Oslo" : window.pktTz;
1451
- const _e = (t = window.pktTz) => {
1452
- const e = new O((/* @__PURE__ */ new Date()).toISOString(), t);
1451
+ const Ae = (t = window.pktTz) => {
1452
+ const e = new x((/* @__PURE__ */ new Date()).toISOString(), t);
1453
1453
  return e.setHours(0, 0, 0, 0), isNaN(e.getTime()) ? /* @__PURE__ */ new Date() : new Date(e.getFullYear(), e.getMonth(), e.getDate());
1454
1454
  };
1455
1455
  function $(t) {
@@ -1464,152 +1464,245 @@ function $(t) {
1464
1464
  }
1465
1465
  return /^\d{4}$/.test(t) ? new Date(Number(t), 0, 1) : new Date(t);
1466
1466
  }
1467
- const p = (t) => {
1467
+ const y = (t) => {
1468
1468
  if (!t || isNaN(t.getTime())) return "";
1469
1469
  const e = t.getFullYear(), n = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0");
1470
1470
  return `${e}-${n}-${r}`;
1471
- }, R = (t) => {
1471
+ }, U = (t) => {
1472
1472
  if (!t)
1473
1473
  return null;
1474
1474
  const e = $(t);
1475
1475
  return isNaN(e.getTime()) ? null : e;
1476
- }, Xe = (t, e) => {
1477
- const n = E(t);
1478
- return isNaN(n.getTime()) ? "" : xe(n, e);
1479
- }, E = (t = "", e) => {
1476
+ }, gn = (t, e) => {
1477
+ const n = _(t);
1478
+ return isNaN(n.getTime()) ? "" : We(n, e);
1479
+ }, _ = (t = "", e) => {
1480
1480
  const n = typeof t == "string" ? $(t) : t;
1481
- return !n || isNaN(n.getTime()) ? /* @__PURE__ */ new Date() : e ? e === "end" ? Ot(n) : K(n) : n;
1482
- }, x = (t, e, n = 1) => {
1481
+ return !n || isNaN(n.getTime()) ? /* @__PURE__ */ new Date() : e ? e === "end" ? _t(n) : K(n) : n;
1482
+ }, C = (t, e, n = 1) => {
1483
1483
  if (typeof t != "number" || typeof e != "number" || typeof n != "number" || isNaN(t) || isNaN(e) || isNaN(n))
1484
1484
  return /* @__PURE__ */ new Date();
1485
1485
  const r = new Date(t, e, n);
1486
1486
  return isNaN(r.getTime()) ? /* @__PURE__ */ new Date() : r;
1487
- }, F = (t) => {
1487
+ }, H = (t) => {
1488
1488
  let e;
1489
- return typeof t == "number" ? e = new O(t, window.pktTz) : e = new O(t, window.pktTz), e.setHours(12, 0, 0, 0), e;
1490
- }, Ee = (t) => !t || isNaN(t.getTime()) ? "" : new Intl.DateTimeFormat("no", { dateStyle: "full", timeZone: window.pktTz }).format(t), We = (t, e, n) => {
1489
+ return typeof t == "number" ? e = new x(t, window.pktTz) : e = new x(t, window.pktTz), e.setHours(12, 0, 0, 0), e;
1490
+ }, Re = (t) => !t || isNaN(t.getTime()) ? "" : new Intl.DateTimeFormat("no", { dateStyle: "full", timeZone: window.pktTz }).format(t), Ue = (t, e, n) => {
1491
1491
  if (!t || isNaN(t.getTime())) return !1;
1492
- const r = e ? E(e) : null, a = n ? E(n) : null;
1492
+ const r = e ? _(e) : null, a = n ? _(n) : null;
1493
1493
  return !(r && t < r || a && t > a);
1494
- }, Ye = (t, e) => {
1494
+ }, Le = (t, e) => {
1495
1495
  if (!t || isNaN(t.getTime()) || !Array.isArray(e)) return !1;
1496
- const n = p(t);
1496
+ const n = y(t);
1497
1497
  return e.includes(n);
1498
- }, Ae = (t, e) => {
1498
+ }, qe = (t, e) => {
1499
1499
  if (!t || isNaN(t.getTime()) || !Array.isArray(e)) return !1;
1500
1500
  const n = t.getDay().toString();
1501
1501
  return e.includes(n);
1502
- }, pt = (t, e, n, r, a) => !(!t || isNaN(t.getTime()) || !We(t, e, n) || r && Ye(t, r) || a && Ae(t, a)), Ge = (t, e, n, r, a) => t.filter((s) => {
1503
- const i = R(s);
1504
- return i && pt(i, e, n, r, a);
1505
- }), Ve = (t) => t.slice().sort((e, n) => {
1506
- const r = R(e), a = R(n);
1502
+ }, kt = (t, e, n, r, a) => !(!t || isNaN(t.getTime()) || !Ue(t, e, n) || r && Le(t, r) || a && qe(t, a)), yn = (t, e, n, r, a) => t.filter((s) => {
1503
+ const i = U(s);
1504
+ return i && kt(i, e, n, r, a);
1505
+ }), pn = (t) => t.slice().sort((e, n) => {
1506
+ const r = U(e), a = U(n);
1507
1507
  return !r || !a ? 0 : r.getTime() - a.getTime();
1508
- }), Je = (t, e) => {
1509
- const n = R(t), r = R(e);
1508
+ }), wn = (t, e) => {
1509
+ const n = U(t), r = U(e);
1510
1510
  return !n || !r ? !1 : n <= r;
1511
- }, Fe = (t) => t ? Array.isArray(t) ? t.filter(Boolean) : String(t).split(",").map((e) => e.trim()).filter(Boolean) : [], Ke = (t) => t.join(","), He = (t) => Fe(t), Ie = (t) => t ? $(t) : null, Re = (t) => {
1511
+ }, Be = (t) => t ? Array.isArray(t) ? t.filter(Boolean) : String(t).split(",").map((e) => e.trim()).filter(Boolean) : [], bn = (t) => t.join(","), ze = (t) => Be(t), je = (t) => t ? $(t) : null, Qe = (t) => {
1512
1512
  if (typeof t == "string")
1513
1513
  return t.split(",").map((e) => $(e));
1514
1514
  if (Array.isArray(t))
1515
1515
  return t.map((e) => $(e));
1516
- }, B = {
1517
- csvToArray: He,
1518
- stringToDate: Ie,
1519
- stringsToDate: Re
1520
- }, Ue = { earliest: { default: null }, latest: { default: null }, weeknumbers: { default: !1 }, withcontrols: { default: !1 }, multiple: { default: !1 }, maxMultiple: { default: 4 }, range: { default: !1 } }, P = {
1521
- props: Ue
1516
+ }, j = {
1517
+ csvToArray: ze,
1518
+ stringToDate: je,
1519
+ stringsToDate: Qe
1520
+ }, Xe = { earliest: { default: null }, latest: { default: null }, weeknumbers: { default: !1 }, withcontrols: { default: !1 }, multiple: { default: !1 }, maxMultiple: { default: 4 }, range: { default: !1 } }, O = {
1521
+ props: Xe
1522
1522
  };
1523
- var qe = Object.defineProperty, Le = Object.getOwnPropertyDescriptor, f = (t, e, n, r) => {
1524
- for (var a = r > 1 ? void 0 : r ? Le(e, n) : e, s = t.length - 1, i; s >= 0; s--)
1523
+ function vt(t, e) {
1524
+ const n = e.excludedates.map(
1525
+ (r) => typeof r == "string" ? r : y(r)
1526
+ );
1527
+ return !kt(
1528
+ t,
1529
+ e.earliest,
1530
+ e.latest,
1531
+ n,
1532
+ e.excludeweekdays
1533
+ );
1534
+ }
1535
+ function Ge(t, e, n, r) {
1536
+ return !!(vt(t, n) || !e && r.multiple && r.maxMultiple > 0 && r.selectedCount >= r.maxMultiple);
1537
+ }
1538
+ function Ve(t, e, n) {
1539
+ const r = C(t, e, 0);
1540
+ return !(n && _(n) > r);
1541
+ }
1542
+ function Ke(t, e, n) {
1543
+ const r = C(
1544
+ e === 11 ? t + 1 : t,
1545
+ e === 11 ? 0 : e + 1,
1546
+ 1
1547
+ );
1548
+ return !(n && _(n) < r);
1549
+ }
1550
+ const L = 7, Je = 6;
1551
+ function Ze(t, e) {
1552
+ const n = C(t, e, 1), r = C(t, e + 1, 0), a = (n.getDay() + Je) % L, s = r.getDate(), i = Math.ceil((s + a) / L), c = C(t, e, 0).getDate(), d = bt(n);
1553
+ return {
1554
+ firstDayOfMonth: n,
1555
+ lastDayOfMonth: r,
1556
+ startingDay: a,
1557
+ numDays: s,
1558
+ numRows: i,
1559
+ numDaysPrevMonth: c,
1560
+ initialWeek: d
1561
+ };
1562
+ }
1563
+ function tn(t, e, n, r) {
1564
+ const { startingDay: a, numDays: s } = r;
1565
+ return t === 0 && e < a ? "prev-month" : n > s ? "next-month" : "current-month";
1566
+ }
1567
+ function en(t, e, n, r) {
1568
+ const { startingDay: a, numDaysPrevMonth: s, numDays: i } = r;
1569
+ return t === "prev-month" ? s - (a - e - 1) : t === "next-month" ? n - i : n;
1570
+ }
1571
+ function W(t) {
1572
+ return typeof t == "string" && (t = t.split(",")), t.length === 1 && t[0] === "" ? [] : t.map((e) => $(e));
1573
+ }
1574
+ function ft(t, e) {
1575
+ const n = pt({ start: t, end: e }), r = {};
1576
+ if (Array.isArray(n) && n.length)
1577
+ for (let a = 0; a < n.length; a++) {
1578
+ const s = n[a], i = s > t && s < e;
1579
+ r[y(s)] = i;
1580
+ }
1581
+ return r;
1582
+ }
1583
+ function Mt(t, e, n, r) {
1584
+ if (e.length !== 1) return !0;
1585
+ const a = pt({
1586
+ start: e[0],
1587
+ end: t
1588
+ });
1589
+ if (!Array.isArray(a) || !a.length) return !0;
1590
+ for (let s = 0; s < a.length; s++) {
1591
+ for (const i of n)
1592
+ if (i > e[0] && i < t)
1593
+ return !1;
1594
+ if (r.includes(Ye(a[s]).toString()))
1595
+ return !1;
1596
+ }
1597
+ return !0;
1598
+ }
1599
+ function Z(t, e) {
1600
+ const n = y(t);
1601
+ return e.includes(n) ? e : [...e, n];
1602
+ }
1603
+ function tt(t, e) {
1604
+ const n = y(t), r = e.indexOf(n);
1605
+ if (r === -1) return e;
1606
+ if (e.length === 1) return [];
1607
+ const a = [...e];
1608
+ return a.splice(r, 1), a;
1609
+ }
1610
+ function nn(t, e, n) {
1611
+ const r = y(t);
1612
+ return e.includes(r) ? tt(t, e) : n > 0 && e.length >= n ? e : Z(t, e);
1613
+ }
1614
+ function rn(t, e, n) {
1615
+ const r = y(t), a = W(e);
1616
+ if (e.includes(r))
1617
+ return e.indexOf(r) === 0 ? [] : tt(t, e);
1618
+ if (e.length > 1)
1619
+ return [r];
1620
+ if (e.length === 1) {
1621
+ if (!Mt(t, a, n.excludedates, n.excludeweekdays))
1622
+ return [r];
1623
+ if (a[0] > t)
1624
+ return [r];
1625
+ }
1626
+ return Z(t, e);
1627
+ }
1628
+ const an = {
1629
+ ArrowLeft: -1,
1630
+ ArrowRight: 1,
1631
+ ArrowUp: -L,
1632
+ ArrowDown: L
1633
+ };
1634
+ function sn(t) {
1635
+ var n;
1636
+ const e = t.nodeName;
1637
+ return e === "INPUT" || e === "SELECT" || e === "BUTTON" && !((n = t.dataset) != null && n.date);
1638
+ }
1639
+ function on(t, e, n) {
1640
+ let r = st(t, e);
1641
+ if (!r) return null;
1642
+ let a = n(`button[data-date="${y(r)}"]`);
1643
+ for (; a instanceof HTMLButtonElement && a.dataset.disabled; )
1644
+ if (r = st(r, e), a = n(`button[data-date="${y(r)}"]`), !a) return null;
1645
+ return r;
1646
+ }
1647
+ function cn(t) {
1648
+ return an[t] ?? null;
1649
+ }
1650
+ var un = Object.defineProperty, ln = Object.getOwnPropertyDescriptor, h = (t, e, n, r) => {
1651
+ for (var a = r > 1 ? void 0 : r ? ln(e, n) : e, s = t.length - 1, i; s >= 0; s--)
1525
1652
  (i = t[s]) && (a = (r ? i(e, n, a) : i(a)) || a);
1526
- return r && a && qe(e, n, a), a;
1653
+ return r && a && un(e, n, a), a;
1527
1654
  };
1528
- let h = class extends bt {
1655
+ let l = class extends xt {
1529
1656
  constructor() {
1530
- super(...arguments), this.multiple = P.props.multiple.default, this.maxMultiple = P.props.maxMultiple.default, this.range = P.props.range.default, this.weeknumbers = P.props.weeknumbers.default, this.withcontrols = P.props.withcontrols.default, this.selected = [], this.earliest = P.props.earliest.default, this.latest = P.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.dayStrings = this.strings.dates.daysShort, this.dayStringsLong = this.strings.dates.days, this.monthStrings = this.strings.dates.months, this.weekString = this.strings.dates.week, this.prevMonthString = this.strings.dates.prevMonth, this.nextMonthString = this.strings.dates.nextMonth, this._selected = [], this.year = 0, this.month = 0, this.week = 0, this.rangeHovered = null, this.inRange = {}, this.focusedDate = null, this.selectableDates = [], this.currentmonthtouched = !1, this.tabIndexSet = 0;
1657
+ super(...arguments), this.selected = [], this.multiple = O.props.multiple.default, this.maxMultiple = O.props.maxMultiple.default, this.range = O.props.range.default, this.earliest = O.props.earliest.default, this.latest = O.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.weeknumbers = O.props.weeknumbers.default, this.withcontrols = O.props.withcontrols.default, this.currentmonth = null, this.dayStrings = this.strings.dates.daysShort, this.dayStringsLong = this.strings.dates.days, this.monthStrings = this.strings.dates.months, this.weekString = this.strings.dates.week, this.prevMonthString = this.strings.dates.prevMonth, this.nextMonthString = this.strings.dates.nextMonth, this._selected = [], this.inRange = {}, this.rangeHovered = null, this.year = 0, this.month = 0, this.week = 0, this.currentmonthtouched = !1, this.focusedDate = null, this.selectableDates = [], this.tabIndexSet = 0;
1531
1658
  }
1532
1659
  /**
1533
- * Runs on mount, used to set up various values and whatever you need to run
1660
+ * Lifecycle methods
1534
1661
  */
1535
- connectedCallback() {
1536
- super.connectedCallback();
1662
+ firstUpdated(t) {
1663
+ this.addEventListener("keydown", this.handleKeydown);
1537
1664
  }
1538
1665
  disconnectedCallback() {
1539
1666
  this.removeEventListener("keydown", this.handleKeydown), super.disconnectedCallback();
1540
1667
  }
1541
- attributeChangedCallback(t, e, n) {
1542
- t === "selected" && n && this.convertSelected(), super.attributeChangedCallback(t, e, n);
1543
- }
1544
1668
  updated(t) {
1545
1669
  super.updated(t), t.has("selected") && this.convertSelected();
1546
1670
  }
1547
- firstUpdated(t) {
1548
- this.addEventListener("keydown", this.handleKeydown);
1549
- }
1671
+ /**
1672
+ * Date and selection management
1673
+ */
1550
1674
  convertSelected() {
1551
- if (typeof this.selected == "string" && (this.selected = this.selected.split(",")), this.selected.length === 1 && this.selected[0] === "" && (this.selected = []), this._selected = this.selected.map((t) => $(t)), this.range && this.selected.length === 2) {
1552
- const t = G({
1553
- start: this._selected[0],
1554
- end: this._selected[1]
1555
- });
1556
- if (this.inRange = {}, Array.isArray(t) && t.length) {
1557
- const e = {};
1558
- for (let n = 0; n < t.length; n++) {
1559
- const r = t[n], a = r > this._selected[0] && r < this._selected[1];
1560
- e[p(r)] = a;
1561
- }
1562
- this.inRange = e;
1563
- }
1564
- }
1565
- this.setCurrentMonth();
1675
+ typeof this.selected == "string" && (this.selected = this.selected.split(",")), this.selected.length === 1 && this.selected[0] === "" && (this.selected = []), this._selected = W(this.selected), this.range && this.selected.length === 2 && (this.inRange = ft(this._selected[0], this._selected[1])), this.setCurrentMonth();
1566
1676
  }
1567
1677
  setCurrentMonth() {
1568
1678
  if (this.currentmonth === null && !this.currentmonthtouched && (this.currentmonthtouched = !0), this.selected.length && this.selected[0] !== "") {
1569
1679
  const t = $(this.selected[this.selected.length - 1]);
1570
- this.currentmonth = isNaN(t.getTime()) ? F(/* @__PURE__ */ new Date()) : t;
1571
- } else this.currentmonth === null && (this.currentmonth = F(/* @__PURE__ */ new Date()));
1572
- (!this.currentmonth || isNaN(this.currentmonth.getTime())) && (this.currentmonth = F(/* @__PURE__ */ new Date())), this.year = this.currentmonth.getFullYear(), this.month = this.currentmonth.getMonth();
1680
+ this.currentmonth = isNaN(t.getTime()) ? H(/* @__PURE__ */ new Date()) : t;
1681
+ } else this.currentmonth === null && (this.currentmonth = H(/* @__PURE__ */ new Date()));
1682
+ (!this.currentmonth || isNaN(this.currentmonth.getTime())) && (this.currentmonth = H(/* @__PURE__ */ new Date())), this.year = this.currentmonth.getFullYear(), this.month = this.currentmonth.getMonth();
1573
1683
  }
1684
+ /**
1685
+ * Keyboard navigation
1686
+ */
1574
1687
  handleKeydown(t) {
1575
- switch (t.key) {
1576
- case "ArrowLeft":
1577
- this.handleArrowKey(t, -1);
1578
- break;
1579
- case "ArrowRight":
1580
- this.handleArrowKey(t, 1);
1581
- break;
1582
- case "ArrowUp":
1583
- this.handleArrowKey(t, -7);
1584
- break;
1585
- case "ArrowDown":
1586
- this.handleArrowKey(t, 7);
1587
- break;
1588
- }
1688
+ const e = cn(t.key);
1689
+ e !== null && this.handleArrowKey(t, e);
1589
1690
  }
1590
1691
  handleArrowKey(t, e) {
1591
- var a, s, i, o, c;
1592
- if (((a = t.target) == null ? void 0 : a.nodeName) === "INPUT" || ((s = t.target) == null ? void 0 : s.nodeName) === "SELECT" || ((i = t.target) == null ? void 0 : i.nodeName) === "BUTTON" && !((c = (o = t.target) == null ? void 0 : o.dataset) != null && c.date))
1692
+ const n = t.target;
1693
+ if (sn(n)) return;
1694
+ if (t.preventDefault(), !this.focusedDate) {
1695
+ this.focusOnCurrentDate();
1593
1696
  return;
1594
- t.preventDefault(), this.focusedDate || this.focusOnCurrentDate();
1595
- const n = this.focusedDate ? E(this.focusedDate) : x(this.year, this.month, 1);
1596
- let r = X(n, e);
1597
- if (r) {
1598
- let l = this.querySelector(`button[data-date="${p(r)}"]`);
1599
- if (l instanceof HTMLButtonElement) {
1600
- if (l.dataset.disabled) {
1601
- r = X(r, e);
1602
- let d = this.querySelector(`button[data-date="${p(r)}"]`);
1603
- for (; d && d instanceof HTMLButtonElement && d.dataset.disabled; )
1604
- r = X(r, e), d = this.querySelector(`button[data-date="${p(r)}"]`);
1605
- l = d;
1606
- }
1607
- l instanceof HTMLButtonElement && !l.dataset.disabled && (this.focusedDate = p(r), l.focus());
1608
- }
1697
+ }
1698
+ const r = this.focusedDate ? _(this.focusedDate) : C(this.year, this.month, 1), a = on(r, e, this.querySelector.bind(this));
1699
+ if (a) {
1700
+ const s = this.querySelector(`button[data-date="${y(a)}"]`);
1701
+ s instanceof HTMLButtonElement && !s.dataset.disabled && (this.focusedDate = y(a), s.focus());
1609
1702
  }
1610
1703
  }
1611
1704
  /**
1612
- * Component functionality and render
1705
+ * Rendering methods
1613
1706
  */
1614
1707
  render() {
1615
1708
  return D`
@@ -1621,41 +1714,9 @@ let h = class extends bt {
1621
1714
  }}
1622
1715
  >
1623
1716
  <nav class="pkt-cal-month-nav">
1624
- <div>
1625
- <button
1626
- type="button"
1627
- aria-label="${this.prevMonthString}"
1628
- @click=${() => this.isPrevMonthAllowed() && this.prevMonth()}
1629
- @keydown=${(t) => {
1630
- (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.isPrevMonthAllowed() && this.prevMonth());
1631
- }}
1632
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only pkt-calendar__prev-month ${this.isPrevMonthAllowed() ? "" : "pkt-hide"}"
1633
- .data-disabled=${this.isPrevMonthAllowed() ? Q : "disabled"}
1634
- ?aria-disabled=${!this.isPrevMonthAllowed()}
1635
- tabindex=${this.isPrevMonthAllowed() ? "0" : "-1"}
1636
- >
1637
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
1638
- <span class="pkt-btn__text">${this.prevMonthString}</span>
1639
- </button>
1640
- </div>
1717
+ ${this.renderMonthNavButton("prev")}
1641
1718
  ${this.renderMonthNav()}
1642
- <div>
1643
- <button
1644
- type="button"
1645
- aria-label="${this.nextMonthString}"
1646
- @click=${() => this.isNextMonthAllowed() && this.nextMonth()}
1647
- @keydown=${(t) => {
1648
- (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.isNextMonthAllowed() && this.nextMonth());
1649
- }}
1650
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only pkt-calendar__next-month ${this.isNextMonthAllowed() ? "" : "pkt-hide"}"
1651
- .data-disabled=${this.isNextMonthAllowed() ? Q : "disabled"}
1652
- ?aria-disabled=${!this.isNextMonthAllowed()}
1653
- tabindex=${this.isNextMonthAllowed() ? "0" : "-1"}
1654
- >
1655
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
1656
- <span class="pkt-btn__text">${this.nextMonthString}</span>
1657
- </button>
1658
- </div>
1719
+ ${this.renderMonthNavButton("next")}
1659
1720
  </nav>
1660
1721
  <table
1661
1722
  class="pkt-cal-days pkt-txt-12-medium pkt-calendar__body"
@@ -1672,6 +1733,26 @@ let h = class extends bt {
1672
1733
  </div>
1673
1734
  `;
1674
1735
  }
1736
+ renderMonthNavButton(t) {
1737
+ const e = t === "prev", n = e ? this.isPrevMonthAllowed() : this.isNextMonthAllowed(), r = e ? this.prevMonthString : this.nextMonthString, a = e ? "chevron-thin-left" : "chevron-thin-right", s = e ? "pkt-calendar__prev-month" : "pkt-calendar__next-month", i = e ? () => this.prevMonth() : () => this.nextMonth();
1738
+ return D`<div>
1739
+ <button
1740
+ type="button"
1741
+ aria-label="${r}"
1742
+ @click=${() => n && i()}
1743
+ @keydown=${(o) => {
1744
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), n && i());
1745
+ }}
1746
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${s} ${n ? "" : "pkt-hide"}"
1747
+ .data-disabled=${n ? rt : "disabled"}
1748
+ ?aria-disabled=${!n}
1749
+ tabindex=${n ? "0" : "-1"}
1750
+ >
1751
+ <pkt-icon class="pkt-btn__icon" name="${a}"></pkt-icon>
1752
+ <span class="pkt-btn__text">${r}</span>
1753
+ </button>
1754
+ </div>`;
1755
+ }
1675
1756
  renderDayNames() {
1676
1757
  const t = [];
1677
1758
  this.weeknumbers && t.push(D`<th><div class="pkt-calendar__week-number">${this.weekString}</div></th>`);
@@ -1683,244 +1764,247 @@ let h = class extends bt {
1683
1764
  </div>
1684
1765
  </th>`
1685
1766
  );
1686
- return D`<tr class="pkt-cal-week-row">
1687
- ${t}
1688
- </tr>`;
1767
+ return D`<tr class="pkt-cal-week-row">${t}</tr>`;
1689
1768
  }
1690
1769
  renderMonthNav() {
1691
- let t = [];
1692
- return this.withcontrols ? t.push(
1693
- D`<div class="pkt-cal-month-picker">
1694
- <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
1695
- <select
1696
- aria-label="${this.strings.dates.month}"
1697
- class="pkt-input pkt-input-compact"
1698
- id="${this.id}-monthnav"
1699
- @change=${(e) => {
1700
- e.stopImmediatePropagation(), this.changeMonth(this.year, e.target.value);
1701
- }}
1702
- >
1703
- ${this.monthStrings.map(
1704
- (e, n) => D`<option value=${n} ?selected=${this.month === n}>${e}</option>`
1705
- )}
1706
- </select>
1707
- <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
1708
- <input
1709
- aria-label="${this.strings.dates.year}"
1710
- class="pkt-input pkt-cal-input-year pkt-input-compact"
1711
- id="${this.id}-yearnav"
1712
- type="number"
1713
- size="4"
1714
- placeholder="0000"
1715
- @change=${(e) => {
1716
- e.stopImmediatePropagation(), this.changeMonth(e.target.value, this.month);
1717
- }}
1718
- .value=${this.year}
1719
- />
1720
- </div> `
1721
- ) : t.push(
1722
- D`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
1723
- ${this.monthStrings[this.month]} ${this.year}
1724
- </div>`
1725
- ), t;
1770
+ return this.withcontrols ? D`<div class="pkt-cal-month-picker">
1771
+ <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
1772
+ <select
1773
+ aria-label="${this.strings.dates.month}"
1774
+ class="pkt-input pkt-input-compact"
1775
+ id="${this.id}-monthnav"
1776
+ @change=${(t) => {
1777
+ t.stopImmediatePropagation();
1778
+ const e = t.target;
1779
+ this.changeMonth(this.year, parseInt(e.value));
1780
+ }}
1781
+ >
1782
+ ${this.monthStrings.map(
1783
+ (t, e) => D`<option value=${e} ?selected=${this.month === e}>${t}</option>`
1784
+ )}
1785
+ </select>
1786
+ <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
1787
+ <input
1788
+ aria-label="${this.strings.dates.year}"
1789
+ class="pkt-input pkt-cal-input-year pkt-input-compact"
1790
+ id="${this.id}-yearnav"
1791
+ type="number"
1792
+ size="4"
1793
+ placeholder="0000"
1794
+ @change=${(t) => {
1795
+ t.stopImmediatePropagation();
1796
+ const e = t.target;
1797
+ this.changeMonth(parseInt(e.value), this.month);
1798
+ }}
1799
+ .value=${this.year}
1800
+ />
1801
+ </div>` : D`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
1802
+ ${this.monthStrings[this.month]} ${this.year}
1803
+ </div>`;
1726
1804
  }
1727
- renderDayView(t, e) {
1728
- var m;
1729
- const n = x(this.year, this.month, t), r = p(n), a = r === p(e), s = this.selected.includes(r), i = Ee(n), o = this.isExcluded(n) || !s && this.multiple && this.maxMultiple > 0 && this.selected.length >= this.maxMultiple, c = this.focusedDate ? this.focusedDate === r && !o ? "0" : "-1" : !o && this.tabIndexSet === 0 || this.tabIndexSet === t ? "0" : "-1";
1730
- c === "0" && (this.tabIndexSet = t), this.selectableDates.push({ currentDateISO: r, isDisabled: o, tabindex: c });
1731
- const l = {
1732
- "pkt-cal-today": a,
1733
- "pkt-cal-selected": s,
1734
- "pkt-cal-in-range": this.inRange[r],
1735
- "pkt-cal-excluded": this.isExcluded(n),
1736
- "pkt-cal-in-range-first": this.range && (this.selected.length === 2 || this.rangeHovered !== null) && r === this.selected[0],
1737
- "pkt-cal-in-range-last": this.range && this.selected.length === 2 && r === this.selected[1],
1738
- "pkt-cal-range-hover": this.rangeHovered !== null && r === p(this.rangeHovered)
1739
- }, d = {
1805
+ getDayViewData(t, e) {
1806
+ const n = C(this.year, this.month, t), r = y(n), a = r === y(e), s = this.selected.includes(r), i = this.isDayDisabled(n, s), o = this.calculateTabIndex(r, i, t);
1807
+ return {
1808
+ currentDate: n,
1809
+ currentDateISO: r,
1810
+ isToday: a,
1811
+ isSelected: s,
1812
+ isDisabled: i,
1813
+ ariaLabel: Re(n),
1814
+ tabindex: o
1815
+ };
1816
+ }
1817
+ getDateConstraints() {
1818
+ return {
1819
+ earliest: this.earliest,
1820
+ latest: this.latest,
1821
+ excludedates: this.excludedates,
1822
+ excludeweekdays: this.excludeweekdays
1823
+ };
1824
+ }
1825
+ isDayDisabled(t, e) {
1826
+ return Ge(t, e, this.getDateConstraints(), {
1827
+ multiple: this.multiple,
1828
+ maxMultiple: this.maxMultiple,
1829
+ selectedCount: this.selected.length
1830
+ });
1831
+ }
1832
+ calculateTabIndex(t, e, n) {
1833
+ return this.focusedDate ? this.focusedDate === t && !e ? "0" : "-1" : !e && this.tabIndexSet === 0 ? (this.tabIndexSet = n, "0") : this.tabIndexSet === n ? "0" : "-1";
1834
+ }
1835
+ getDayCellClasses(t) {
1836
+ const { currentDateISO: e, isToday: n, isSelected: r } = t, a = this.range && (this.selected.length === 2 || this.rangeHovered !== null) && e === this.selected[0], s = this.range && this.selected.length === 2 && e === this.selected[1];
1837
+ return {
1838
+ "pkt-cal-today": n,
1839
+ "pkt-cal-selected": r,
1840
+ "pkt-cal-in-range": this.inRange[e],
1841
+ "pkt-cal-excluded": this.isExcluded(t.currentDate),
1842
+ "pkt-cal-in-range-first": a,
1843
+ "pkt-cal-in-range-last": s,
1844
+ "pkt-cal-range-hover": this.rangeHovered !== null && e === y(this.rangeHovered)
1845
+ };
1846
+ }
1847
+ getDayButtonClasses(t) {
1848
+ const { currentDateISO: e, isToday: n, isSelected: r, isDisabled: a } = t, s = this.range && (this.selected.length === 2 || this.rangeHovered !== null) && e === this.selected[0], i = this.range && this.selected.length === 2 && e === this.selected[1];
1849
+ return {
1740
1850
  "pkt-calendar__date": !0,
1741
- "pkt-calendar__date--today": a,
1742
- "pkt-calendar__date--selected": s,
1743
- "pkt-calendar__date--disabled": o,
1744
- "pkt-calendar__date--in-range": this.inRange[r],
1745
- "pkt-calendar__date--in-range-hover": this.rangeHovered !== null && r === p(this.rangeHovered),
1746
- "pkt-calendar__date--range-start": this.range && (this.selected.length === 2 || this.rangeHovered !== null) && r === this.selected[0],
1747
- "pkt-calendar__date--range-end": this.range && this.selected.length === 2 && r === this.selected[1]
1851
+ "pkt-calendar__date--today": n,
1852
+ "pkt-calendar__date--selected": r,
1853
+ "pkt-calendar__date--disabled": a,
1854
+ "pkt-calendar__date--in-range": this.inRange[e],
1855
+ "pkt-calendar__date--in-range-hover": this.rangeHovered !== null && e === y(this.rangeHovered),
1856
+ "pkt-calendar__date--range-start": s,
1857
+ "pkt-calendar__date--range-end": i
1748
1858
  };
1749
- return D`<td class=${et(l)}>
1859
+ }
1860
+ handleDayFocus(t, e) {
1861
+ this.range && !this.isExcluded(t) && this.handleRangeHover(t), this.focusedDate = e;
1862
+ }
1863
+ renderDayView(t, e) {
1864
+ const n = this.getDayViewData(t, e), { currentDate: r, currentDateISO: a, isSelected: s, isDisabled: i, ariaLabel: o, tabindex: c } = n;
1865
+ this.selectableDates.push({ currentDateISO: a, isDisabled: i, tabindex: c });
1866
+ const d = this.getDayCellClasses(n), g = this.getDayButtonClasses(n);
1867
+ return D`<td class=${nt(d)}>
1750
1868
  <button
1751
1869
  type="button"
1752
1870
  aria-pressed=${s ? "true" : "false"}
1753
- ?disabled=${o}
1754
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only ${et(
1755
- d
1756
- )}"
1757
- @mouseover=${() => this.range && !this.isExcluded(n) && this.handleRangeHover(n)}
1758
- @focus=${() => {
1759
- this.range && !this.isExcluded(n) && this.handleRangeHover(n), this.focusedDate = r;
1871
+ ?disabled=${i}
1872
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only ${nt(g)}"
1873
+ @mouseover=${() => this.range && !this.isExcluded(r) && this.handleRangeHover(r)}
1874
+ @focus=${() => this.handleDayFocus(r, a)}
1875
+ aria-label="${o}"
1876
+ tabindex=${c}
1877
+ data-disabled=${i ? "disabled" : rt}
1878
+ data-date=${a}
1879
+ @keydown=${(m) => {
1880
+ (m.key === "Enter" || m.key === " ") && (m.preventDefault(), this.handleDateSelect(r));
1760
1881
  }}
1761
- aria-label="${i}"
1762
- tabindex=${(m = this.selectableDates.find((g) => g.currentDateISO === r)) == null ? void 0 : m.tabindex}
1763
- data-disabled=${o ? "disabled" : Q}
1764
- data-date=${r}
1765
- @keydown=${(g) => {
1766
- (g.key === "Enter" || g.key === " ") && (g.preventDefault(), this.handleDateSelect(n));
1767
- }}
1768
- @click=${(g) => {
1769
- o || (g.preventDefault(), this.handleDateSelect(n));
1882
+ @click=${(m) => {
1883
+ i || (m.preventDefault(), this.handleDateSelect(r));
1770
1884
  }}
1771
1885
  >
1772
1886
  <span class="pkt-btn__text pkt-txt-14-light">${t}</span>
1773
1887
  </button>
1774
1888
  </td>`;
1775
1889
  }
1890
+ renderEmptyDayCell(t) {
1891
+ return D`<td class="pkt-cal-other">
1892
+ <div
1893
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
1894
+ data-disabled="disabled"
1895
+ >
1896
+ <span class="pkt-btn__text pkt-txt-14-light">${t}</span>
1897
+ </div>
1898
+ </td>`;
1899
+ }
1900
+ renderWeekRow(t) {
1901
+ return D`<tr class="pkt-cal-week-row" role="row">${t}</tr>`;
1902
+ }
1776
1903
  renderCalendarBody() {
1777
- const t = _e(), e = x(this.year, this.month, 1), n = x(this.year, this.month + 1, 0), r = (e.getDay() + 6) % 7, a = n.getDate(), s = Math.ceil((a + r) / 7), o = x(this.year, this.month, 0).getDate();
1778
- let c = 1;
1779
- this.week = mt(x(this.year, this.month, 1));
1780
- const l = [];
1781
- for (let d = 0; d < s; d++) {
1782
- const m = [];
1783
- this.weeknumbers && m.push(D`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
1784
- for (let g = 1; g < 8; g++)
1785
- if (d === 0 && g < r + 1) {
1786
- const S = o - (r - g);
1787
- m.push(
1788
- D`<td class="pkt-cal-other">
1789
- <div
1790
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
1791
- data-disabled="disabled"
1792
- >
1793
- <span class="pkt-btn__text pkt-txt-14-light">${S}</span>
1794
- </div>
1795
- </td>`
1796
- );
1797
- } else c > a ? (m.push(
1798
- D`<td class="pkt-cal-other">
1799
- <div
1800
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
1801
- data-disabled="disabled"
1802
- >
1803
- <span class="pkt-btn__text pkt-txt-14-light">${c - a}</span>
1804
- </div>
1805
- </td>`
1806
- ), c++) : (m.push(this.renderDayView(c, t)), c++);
1807
- l.push(
1808
- D`<tr class="pkt-cal-week-row" role="row">
1809
- ${m}
1810
- </tr>`
1811
- );
1904
+ const t = Ae(), e = Ze(this.year, this.month);
1905
+ let n = 1;
1906
+ this.week = e.initialWeek;
1907
+ const r = [];
1908
+ for (let a = 0; a < e.numRows; a++) {
1909
+ const s = [];
1910
+ this.weeknumbers && s.push(D`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
1911
+ for (let i = 0; i < L; i++) {
1912
+ const o = tn(a, i, n, e);
1913
+ if (o === "current-month")
1914
+ s.push(this.renderDayView(n, t)), n++;
1915
+ else {
1916
+ const c = en(o, i, n, e);
1917
+ s.push(this.renderEmptyDayCell(c)), o === "next-month" && n++;
1918
+ }
1919
+ }
1920
+ r.push(this.renderWeekRow(s));
1812
1921
  }
1813
- return l;
1922
+ return r;
1814
1923
  }
1924
+ /**
1925
+ * Date validation
1926
+ */
1815
1927
  isExcluded(t) {
1816
- const e = this.excludedates.map(
1817
- (n) => typeof n == "string" ? n : p(n)
1818
- );
1819
- return !pt(
1820
- t,
1821
- this.earliest,
1822
- this.latest,
1823
- e,
1824
- this.excludeweekdays
1825
- );
1928
+ return vt(t, this.getDateConstraints());
1826
1929
  }
1930
+ /**
1931
+ * Month navigation
1932
+ */
1827
1933
  isPrevMonthAllowed() {
1828
- const t = x(this.year, this.month, 0);
1829
- return !(this.earliest && E(this.earliest) > t);
1934
+ return Ve(this.year, this.month, this.earliest);
1830
1935
  }
1831
1936
  prevMonth() {
1832
1937
  const t = this.month === 0 ? 11 : this.month - 1, e = this.month === 0 ? this.year - 1 : this.year;
1833
1938
  this.changeMonth(e, t);
1834
1939
  }
1835
1940
  isNextMonthAllowed() {
1836
- const t = x(
1837
- this.month === 11 ? this.year + 1 : this.year,
1838
- this.month === 11 ? 0 : this.month + 1,
1839
- 1
1840
- );
1841
- return !(this.latest && E(this.latest) < t);
1941
+ return Ke(this.year, this.month, this.latest);
1842
1942
  }
1843
1943
  nextMonth() {
1844
1944
  const t = this.month === 11 ? 0 : this.month + 1, e = this.month === 11 ? this.year + 1 : this.year;
1845
1945
  this.changeMonth(e, t);
1846
1946
  }
1847
1947
  changeMonth(t, e) {
1848
- this.year = typeof t == "string" ? parseInt(t) : t, this.month = typeof e == "string" ? parseInt(e) : e, this.currentmonth = F(new Date(this.year, this.month, 1)), this.tabIndexSet = 0, this.focusedDate = null, this.selectableDates = [];
1849
- }
1850
- isRangeAllowed(t) {
1851
- let e = !0;
1852
- if (this._selected.length === 1) {
1853
- const n = G({
1854
- start: this._selected[0],
1855
- end: t
1856
- });
1857
- if (Array.isArray(n) && n.length)
1858
- for (let r = 0; r < n.length; r++)
1859
- this.excludedates.forEach((a) => {
1860
- a > this._selected[0] && a < t && (e = !1);
1861
- }), this.excludeweekdays.includes(Pe(n[r]).toString()) && (e = !1);
1862
- }
1863
- return e;
1948
+ this.year = typeof t == "string" ? parseInt(t) : t, this.month = typeof e == "string" ? parseInt(e) : e, this.currentmonth = H(new Date(this.year, this.month, 1)), this.tabIndexSet = 0, this.focusedDate = null, this.selectableDates = [];
1864
1949
  }
1950
+ /**
1951
+ * Date selection logic
1952
+ */
1865
1953
  emptySelected() {
1866
1954
  this.selected = [], this._selected = [], this.inRange = {};
1867
1955
  }
1956
+ normalizeSelected() {
1957
+ return typeof this.selected == "string" ? this.selected.split(",") : this.selected;
1958
+ }
1868
1959
  addToSelected(t) {
1869
- this.selected.includes(p(t)) || (this.selected = [...this.selected, p(t)], this._selected = [...this._selected, t], this.range && this.selected.length === 2 && (this.convertSelected(), this.close()));
1960
+ this.selected = Z(t, this.normalizeSelected()), this._selected = W(this.selected), this.range && this.selected.length === 2 && (this.convertSelected(), this.close());
1870
1961
  }
1871
1962
  removeFromSelected(t) {
1872
- if (this.selected.length === 1)
1873
- this.emptySelected();
1874
- else {
1875
- const e = this.selected.indexOf(p(t)), n = [...this.selected], r = [...this._selected];
1876
- n.splice(e, 1), r.splice(e, 1), this.selected = n, this._selected = r;
1877
- }
1963
+ this.selected = tt(t, this.normalizeSelected()), this._selected = W(this.selected);
1878
1964
  }
1879
1965
  toggleSelected(t) {
1880
- const e = p(t);
1881
- this.selected.includes(e) ? this.removeFromSelected(t) : this.maxMultiple && this.selected.length >= this.maxMultiple || this.addToSelected(t);
1966
+ this.selected = nn(t, this.normalizeSelected(), this.maxMultiple), this._selected = W(this.selected);
1967
+ }
1968
+ isRangeAllowed(t) {
1969
+ return Mt(t, this._selected, this.excludedates, this.excludeweekdays);
1882
1970
  }
1883
1971
  handleRangeSelect(t) {
1884
- const e = p(t);
1885
- return this.selected.includes(e) ? this.selected.indexOf(e) === 0 ? this.emptySelected() : this.removeFromSelected(t) : this.selected.length > 1 ? (this.emptySelected(), this.addToSelected(t)) : (this.selected.length === 1 && !this.isRangeAllowed(t) && this.emptySelected(), this.selected.length === 1 && this._selected[0] > t && this.emptySelected(), this.addToSelected(t)), Promise.resolve();
1972
+ return this.selected = rn(t, this.normalizeSelected(), {
1973
+ excludedates: this.excludedates,
1974
+ excludeweekdays: this.excludeweekdays
1975
+ }), this._selected = W(this.selected), this.selected.length === 2 ? this.convertSelected() : this.selected.length === 1 && (this.inRange = {}), Promise.resolve();
1886
1976
  }
1887
1977
  handleRangeHover(t) {
1888
- if (this.range && this._selected.length === 1 && this.isRangeAllowed(t) && this._selected[0] < t) {
1889
- this.rangeHovered = t, this.inRange = {};
1890
- const e = G({
1891
- start: this._selected[0],
1892
- end: t
1893
- });
1894
- if (Array.isArray(e) && e.length)
1895
- for (let n = 0; n < e.length; n++) {
1896
- const r = e[n], a = r > this._selected[0] && r < t;
1897
- this.inRange[p(r)] = a;
1898
- }
1899
- } else
1978
+ if (!this.range || this._selected.length !== 1 || !this.isRangeAllowed(t) || this._selected[0] >= t) {
1900
1979
  this.rangeHovered = null;
1980
+ return;
1981
+ }
1982
+ this.rangeHovered = t, this.inRange = ft(this._selected[0], t);
1901
1983
  }
1902
1984
  handleDateSelect(t) {
1903
- if (t)
1904
- return this.range ? this.handleRangeSelect(t) : this.multiple ? this.toggleSelected(t) : (this.selected.includes(p(t)) ? this.emptySelected() : (this.emptySelected(), this.addToSelected(t)), this.close()), this.dispatchEvent(
1905
- new CustomEvent("date-selected", {
1906
- detail: this.selected,
1907
- bubbles: !0,
1908
- composed: !0
1909
- })
1910
- ), Promise.resolve();
1985
+ return t && (this.range ? this.handleRangeSelect(t) : this.multiple ? this.toggleSelected(t) : (this.selected.includes(y(t)) ? this.emptySelected() : (this.emptySelected(), this.addToSelected(t)), this.close()), this.dispatchEvent(
1986
+ new CustomEvent("date-selected", {
1987
+ detail: this.selected,
1988
+ bubbles: !0,
1989
+ composed: !0
1990
+ })
1991
+ )), Promise.resolve();
1911
1992
  }
1993
+ /**
1994
+ * Focus management and event handlers
1995
+ */
1912
1996
  focusOnCurrentDate() {
1913
- const t = p(F(/* @__PURE__ */ new Date())), e = this.querySelector(`button[data-date="${t}"]`);
1914
- if (e instanceof HTMLButtonElement)
1997
+ const t = y(H(/* @__PURE__ */ new Date())), e = this.querySelector(`button[data-date="${t}"]`);
1998
+ if (e instanceof HTMLButtonElement) {
1915
1999
  this.focusedDate = t, e.focus();
1916
- else {
1917
- const n = this.selectableDates.find((r) => !r.isDisabled);
1918
- if (n) {
1919
- const r = this.querySelector(
1920
- `button[data-date="${n.currentDateISO}"]`
1921
- );
1922
- r instanceof HTMLButtonElement && (this.focusedDate = n.currentDateISO, r.focus());
1923
- }
2000
+ return;
2001
+ }
2002
+ const n = this.selectableDates.find((r) => !r.isDisabled);
2003
+ if (n) {
2004
+ const r = this.querySelector(
2005
+ `button[data-date="${n.currentDateISO}"]`
2006
+ );
2007
+ r instanceof HTMLButtonElement && (this.focusedDate = n.currentDateISO, r.focus());
1924
2008
  }
1925
2009
  }
1926
2010
  closeEvent(t) {
@@ -1936,102 +2020,102 @@ let h = class extends bt {
1936
2020
  );
1937
2021
  }
1938
2022
  };
1939
- f([
1940
- y({ type: Boolean })
1941
- ], h.prototype, "multiple", 2);
1942
- f([
1943
- y({ type: Number })
1944
- ], h.prototype, "maxMultiple", 2);
1945
- f([
1946
- y({ type: Boolean })
1947
- ], h.prototype, "range", 2);
1948
- f([
1949
- y({ type: Boolean })
1950
- ], h.prototype, "weeknumbers", 2);
1951
- f([
1952
- y({ type: Boolean })
1953
- ], h.prototype, "withcontrols", 2);
1954
- f([
1955
- y({ converter: B.csvToArray })
1956
- ], h.prototype, "selected", 2);
1957
- f([
1958
- y({ type: String })
1959
- ], h.prototype, "earliest", 2);
1960
- f([
1961
- y({ type: String })
1962
- ], h.prototype, "latest", 2);
1963
- f([
1964
- y({ converter: B.stringsToDate })
1965
- ], h.prototype, "excludedates", 2);
1966
- f([
1967
- y({ converter: B.csvToArray })
1968
- ], h.prototype, "excludeweekdays", 2);
1969
- f([
1970
- y({ converter: B.stringToDate })
1971
- ], h.prototype, "currentmonth", 2);
1972
- f([
1973
- y({ type: Array })
1974
- ], h.prototype, "dayStrings", 2);
1975
- f([
1976
- y({ type: Array })
1977
- ], h.prototype, "dayStringsLong", 2);
1978
- f([
1979
- y({ type: Array })
1980
- ], h.prototype, "monthStrings", 2);
1981
- f([
1982
- y({ type: String })
1983
- ], h.prototype, "weekString", 2);
1984
- f([
1985
- y({ type: String })
1986
- ], h.prototype, "prevMonthString", 2);
1987
- f([
1988
- y({ type: String })
1989
- ], h.prototype, "nextMonthString", 2);
1990
- f([
1991
- y({ type: Array })
1992
- ], h.prototype, "_selected", 2);
1993
- f([
1994
- y({ type: Number })
1995
- ], h.prototype, "year", 2);
1996
- f([
1997
- y({ type: Number })
1998
- ], h.prototype, "month", 2);
1999
- f([
2000
- y({ type: Number })
2001
- ], h.prototype, "week", 2);
2002
- f([
2003
- y({ type: Date })
2004
- ], h.prototype, "rangeHovered", 2);
2005
- f([
2006
- U()
2007
- ], h.prototype, "inRange", 2);
2008
- f([
2009
- U()
2010
- ], h.prototype, "focusedDate", 2);
2011
- f([
2012
- U()
2013
- ], h.prototype, "selectableDates", 2);
2014
- f([
2015
- U()
2016
- ], h.prototype, "currentmonthtouched", 2);
2017
- f([
2018
- U()
2019
- ], h.prototype, "tabIndexSet", 2);
2020
- h = f([
2021
- kt("pkt-calendar")
2022
- ], h);
2023
+ h([
2024
+ f({ converter: j.csvToArray })
2025
+ ], l.prototype, "selected", 2);
2026
+ h([
2027
+ f({ type: Boolean })
2028
+ ], l.prototype, "multiple", 2);
2029
+ h([
2030
+ f({ type: Number })
2031
+ ], l.prototype, "maxMultiple", 2);
2032
+ h([
2033
+ f({ type: Boolean })
2034
+ ], l.prototype, "range", 2);
2035
+ h([
2036
+ f({ type: String })
2037
+ ], l.prototype, "earliest", 2);
2038
+ h([
2039
+ f({ type: String })
2040
+ ], l.prototype, "latest", 2);
2041
+ h([
2042
+ f({ converter: j.stringsToDate })
2043
+ ], l.prototype, "excludedates", 2);
2044
+ h([
2045
+ f({ converter: j.csvToArray })
2046
+ ], l.prototype, "excludeweekdays", 2);
2047
+ h([
2048
+ f({ type: Boolean })
2049
+ ], l.prototype, "weeknumbers", 2);
2050
+ h([
2051
+ f({ type: Boolean })
2052
+ ], l.prototype, "withcontrols", 2);
2053
+ h([
2054
+ f({ converter: j.stringToDate })
2055
+ ], l.prototype, "currentmonth", 2);
2056
+ h([
2057
+ f({ type: Array })
2058
+ ], l.prototype, "dayStrings", 2);
2059
+ h([
2060
+ f({ type: Array })
2061
+ ], l.prototype, "dayStringsLong", 2);
2062
+ h([
2063
+ f({ type: Array })
2064
+ ], l.prototype, "monthStrings", 2);
2065
+ h([
2066
+ f({ type: String })
2067
+ ], l.prototype, "weekString", 2);
2068
+ h([
2069
+ f({ type: String })
2070
+ ], l.prototype, "prevMonthString", 2);
2071
+ h([
2072
+ f({ type: String })
2073
+ ], l.prototype, "nextMonthString", 2);
2074
+ h([
2075
+ f({ type: Array })
2076
+ ], l.prototype, "_selected", 2);
2077
+ h([
2078
+ q()
2079
+ ], l.prototype, "inRange", 2);
2080
+ h([
2081
+ f({ type: Date })
2082
+ ], l.prototype, "rangeHovered", 2);
2083
+ h([
2084
+ f({ type: Number })
2085
+ ], l.prototype, "year", 2);
2086
+ h([
2087
+ f({ type: Number })
2088
+ ], l.prototype, "month", 2);
2089
+ h([
2090
+ f({ type: Number })
2091
+ ], l.prototype, "week", 2);
2092
+ h([
2093
+ q()
2094
+ ], l.prototype, "currentmonthtouched", 2);
2095
+ h([
2096
+ q()
2097
+ ], l.prototype, "focusedDate", 2);
2098
+ h([
2099
+ q()
2100
+ ], l.prototype, "selectableDates", 2);
2101
+ h([
2102
+ q()
2103
+ ], l.prototype, "tabIndexSet", 2);
2104
+ l = h([
2105
+ Ot("pkt-calendar")
2106
+ ], l);
2023
2107
  export {
2024
- h as P,
2025
- Ge as a,
2026
- R as b,
2027
- He as c,
2028
- Ke as d,
2029
- p as e,
2030
- Xe as f,
2031
- B as g,
2032
- Je as i,
2033
- E as n,
2108
+ l as P,
2109
+ yn as a,
2110
+ U as b,
2111
+ ze as c,
2112
+ bn as d,
2113
+ y as e,
2114
+ gn as f,
2115
+ j as g,
2116
+ wn as i,
2117
+ _ as n,
2034
2118
  $ as p,
2035
- Ve as s,
2036
- Fe as v
2119
+ pn as s,
2120
+ Be as v
2037
2121
  };