@oslokommune/punkt-elements 16.7.3 → 16.7.4

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 (248) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/accordion-BB1JrONI.cjs +34 -0
  3. package/dist/accordion-nNH87Y60.js +130 -0
  4. package/dist/alert-BEEnTiCb.cjs +33 -0
  5. package/dist/alert-ePJuDtmm.js +171 -0
  6. package/dist/async-directive-B9P1Qa0k.cjs +1 -0
  7. package/dist/async-directive-CaQiqjyV.js +55 -0
  8. package/dist/backlink-Ba03LlbB.cjs +13 -0
  9. package/dist/backlink-CiwXrQYD.js +38 -0
  10. package/dist/booleanish-BmcOU-43.js +11 -0
  11. package/dist/booleanish-jJLlnr6-.cjs +1 -0
  12. package/dist/breadcrumbs-CD1zib3s.cjs +43 -0
  13. package/dist/breadcrumbs-CpuVqWhF.js +76 -0
  14. package/dist/button-BIpd1xJh.js +95 -0
  15. package/dist/button-D-TOBaJB.cjs +27 -0
  16. package/dist/calendar-BzEtOJla.js +2031 -0
  17. package/dist/calendar-E5jJLt8D.cjs +90 -0
  18. package/dist/card-BYJu1MYm.js +339 -0
  19. package/dist/card-CUFhMVim.cjs +87 -0
  20. package/dist/checkbox-BARDb9iV.cjs +31 -0
  21. package/dist/checkbox-Cspxcvt_.js +111 -0
  22. package/dist/class-map-C8HuhNzZ.js +27 -0
  23. package/dist/class-map-CJ-msbHs.cjs +1 -0
  24. package/dist/classutils-DEL164Ur.js +7 -0
  25. package/dist/classutils-z8YsPlOf.cjs +1 -0
  26. package/dist/combobox-BcdLZRDU.js +984 -0
  27. package/dist/combobox-CGbFTWq_.cjs +135 -0
  28. package/dist/consent-DeB_5sWH.js +197 -0
  29. package/dist/consent-hwu7pp3S.cjs +11 -0
  30. package/dist/datepicker-DpmlsnH_.cjs +273 -0
  31. package/dist/datepicker-OVd8pmnZ.js +1125 -0
  32. package/dist/dialog-polyfill.esm-1hPr0gl9.js +280 -0
  33. package/dist/dialog-polyfill.esm-D3Oinvk0.cjs +1 -0
  34. package/dist/directive-3THFsVew.js +28 -0
  35. package/dist/directive-CJ2giQBZ.cjs +1 -0
  36. package/dist/directive-helpers-D1QSxY17.cjs +1 -0
  37. package/dist/directive-helpers-Dkv2gKgs.js +25 -0
  38. package/dist/element-DjtxO-1r.cjs +2 -0
  39. package/dist/element-cZ85T_aa.js +693 -0
  40. package/dist/element-with-slot-4J2o3SeU.js +166 -0
  41. package/dist/element-with-slot-CWoTGA1B.cjs +1 -0
  42. package/dist/header-DWgPgGfS.cjs +304 -0
  43. package/dist/header-a6ztVNp3.js +782 -0
  44. package/dist/heading-BgSWIRii.cjs +1 -0
  45. package/dist/heading-DiQLPxdf.js +73 -0
  46. package/dist/helptext-CCBKKLus.js +65 -0
  47. package/dist/helptext-D-3QfZv5.cjs +24 -0
  48. package/dist/icon-Co72KtgF.js +86 -0
  49. package/dist/icon-Dr8sfT2X.cjs +1 -0
  50. package/dist/if-defined-Cjj8qN-Z.js +5 -0
  51. package/dist/if-defined-XKOD_t_V.cjs +1 -0
  52. package/dist/index.d.ts +1 -2
  53. package/dist/input-element-B1yxcfz4.cjs +1 -0
  54. package/dist/input-element-Bw1s6NlF.js +643 -0
  55. package/dist/input-wrapper-BRuVELpK.cjs +54 -0
  56. package/dist/input-wrapper-CDyHTR1V.js +164 -0
  57. package/dist/input-wrapper-Dwd-_sKm.cjs +1 -0
  58. package/dist/input-wrapper-YfTmpSSY.js +117 -0
  59. package/dist/link-CKAFMz9j.js +89 -0
  60. package/dist/link-CyTCpI0k.cjs +7 -0
  61. package/dist/linkcard-B0KOGaGj.js +55 -0
  62. package/dist/linkcard-BE4-FewK.cjs +13 -0
  63. package/dist/listbox-DCA2JoPV.cjs +106 -0
  64. package/dist/listbox-DuBgTFvH.js +397 -0
  65. package/dist/loader-6kFZUErT.js +66 -0
  66. package/dist/loader-CX2rsC01.cjs +16 -0
  67. package/dist/messagebox-Cwlg5sOr.js +110 -0
  68. package/dist/messagebox-Din9X53b.cjs +13 -0
  69. package/dist/modal-C_wtsh9m.js +209 -0
  70. package/dist/modal-DS_wUOIv.cjs +36 -0
  71. package/dist/pkt-accordion.cjs +1 -1
  72. package/dist/pkt-accordion.js +2 -7
  73. package/dist/pkt-alert.cjs +1 -1
  74. package/dist/pkt-alert.js +2 -5
  75. package/dist/pkt-backlink.cjs +1 -1
  76. package/dist/pkt-backlink.js +2 -5
  77. package/dist/pkt-breadcrumbs.cjs +1 -43
  78. package/dist/pkt-breadcrumbs.js +2 -81
  79. package/dist/pkt-button.cjs +1 -1
  80. package/dist/pkt-button.js +2 -5
  81. package/dist/pkt-calendar.cjs +1 -1
  82. package/dist/pkt-calendar.js +2 -5
  83. package/dist/pkt-card.cjs +1 -1
  84. package/dist/pkt-card.js +2 -5
  85. package/dist/pkt-checkbox.cjs +1 -1
  86. package/dist/pkt-checkbox.js +2 -5
  87. package/dist/pkt-combobox.cjs +1 -1
  88. package/dist/pkt-combobox.js +2 -5
  89. package/dist/pkt-consent.cjs +1 -1
  90. package/dist/pkt-consent.js +2 -5
  91. package/dist/pkt-datepicker.cjs +1 -1
  92. package/dist/pkt-datepicker.js +5 -9
  93. package/dist/pkt-header.cjs +1 -304
  94. package/dist/pkt-header.js +2 -861
  95. package/dist/pkt-heading.cjs +1 -1
  96. package/dist/pkt-heading.js +2 -5
  97. package/dist/pkt-helptext.cjs +1 -1
  98. package/dist/pkt-helptext.js +2 -5
  99. package/dist/pkt-icon.cjs +1 -1
  100. package/dist/pkt-icon.js +2 -5
  101. package/dist/pkt-index.cjs +1 -1
  102. package/dist/pkt-index.js +30 -66
  103. package/dist/pkt-input-wrapper.cjs +1 -1
  104. package/dist/pkt-input-wrapper.js +2 -5
  105. package/dist/pkt-link.cjs +1 -1
  106. package/dist/pkt-link.js +2 -5
  107. package/dist/pkt-linkcard.cjs +1 -1
  108. package/dist/pkt-linkcard.js +2 -5
  109. package/dist/pkt-listbox.cjs +1 -1
  110. package/dist/pkt-listbox.js +2 -5
  111. package/dist/pkt-loader.cjs +1 -1
  112. package/dist/pkt-loader.js +2 -5
  113. package/dist/pkt-messagebox.cjs +1 -1
  114. package/dist/pkt-messagebox.js +2 -5
  115. package/dist/pkt-modal.cjs +1 -1
  116. package/dist/pkt-modal.js +2 -5
  117. package/dist/pkt-options-controller-CRrI6WMk.js +43 -0
  118. package/dist/pkt-options-controller-CXUGx134.cjs +1 -0
  119. package/dist/pkt-progressbar.cjs +1 -1
  120. package/dist/pkt-progressbar.js +2 -5
  121. package/dist/pkt-radiobutton.cjs +1 -1
  122. package/dist/pkt-radiobutton.js +2 -5
  123. package/dist/pkt-select.cjs +1 -1
  124. package/dist/pkt-select.js +2 -5
  125. package/dist/pkt-tabs.cjs +1 -1
  126. package/dist/pkt-tabs.js +2 -7
  127. package/dist/pkt-tag.cjs +1 -1
  128. package/dist/pkt-tag.js +2 -5
  129. package/dist/pkt-textarea.cjs +1 -1
  130. package/dist/pkt-textarea.js +2 -5
  131. package/dist/pkt-textinput.cjs +1 -1
  132. package/dist/pkt-textinput.js +2 -5
  133. package/dist/pkt-timepicker.cjs +1 -191
  134. package/dist/pkt-timepicker.js +2 -560
  135. package/dist/progressbar-CdXtmOBb.cjs +17 -0
  136. package/dist/progressbar-Dy9AiYQz.js +113 -0
  137. package/dist/radiobutton-GOnpUbCW.cjs +31 -0
  138. package/dist/radiobutton-V_KPbup_.js +84 -0
  139. package/dist/ref-BaJ0mBT_.cjs +1 -0
  140. package/dist/ref-RS8Uv6uC.js +30 -0
  141. package/dist/repeat-Cepr3469.js +57 -0
  142. package/dist/repeat-CqcDYBxr.cjs +1 -0
  143. package/dist/select-BSAFd8Wa.js +164 -0
  144. package/dist/select-C2i8sOk5.cjs +49 -0
  145. package/dist/tabs-D8nL9rWx.cjs +37 -0
  146. package/dist/tabs-Y7utmJi9.js +318 -0
  147. package/dist/tag-DLthw5b4.cjs +27 -0
  148. package/dist/tag-VwykmuQR.js +179 -0
  149. package/dist/textarea-D7aGOyDf.cjs +46 -0
  150. package/dist/textarea-DYOBhJrN.js +115 -0
  151. package/dist/textinput-BUgntXnM.js +124 -0
  152. package/dist/textinput-DFh8_9cx.cjs +70 -0
  153. package/dist/timepicker-BIfE7KKJ.cjs +191 -0
  154. package/dist/timepicker-DaSwn1FA.js +503 -0
  155. package/dist/utils-CUqCKGvp.js +7 -0
  156. package/dist/utils-CjAbIttF.cjs +1 -0
  157. package/package.json +6 -6
  158. package/src/components/alert/alert.test.ts +1 -1
  159. package/src/components/alert/alert.ts +6 -6
  160. package/src/components/datepicker/datepicker-utils.test.ts +16 -23
  161. package/dist/accordionitem-_9AiCIvd.cjs +0 -34
  162. package/dist/accordionitem-dCfSrxh5.js +0 -140
  163. package/dist/alert-BtOk8yRH.cjs +0 -33
  164. package/dist/alert-DlY2_grU.js +0 -117
  165. package/dist/async-directive-CMzWMlZ5.js +0 -65
  166. package/dist/async-directive-DoMuclel.cjs +0 -5
  167. package/dist/backlink-Ce5Vldop.js +0 -49
  168. package/dist/backlink-y3dwjKPC.cjs +0 -13
  169. package/dist/booleanish-BKVonob4.cjs +0 -1
  170. package/dist/booleanish-C9R0tdXH.js +0 -11
  171. package/dist/button-B_TXwNzt.cjs +0 -27
  172. package/dist/button-BiY-wlKF.js +0 -139
  173. package/dist/calendar-B2pji2zn.cjs +0 -90
  174. package/dist/calendar-DhjQDC4C.js +0 -2140
  175. package/dist/card-BwMNB5Bb.cjs +0 -87
  176. package/dist/card-CGlmcMSR.js +0 -233
  177. package/dist/checkbox-BsJZYA26.js +0 -147
  178. package/dist/checkbox-CTY8f_qn.cjs +0 -31
  179. package/dist/class-map-CEnykyO_.js +0 -34
  180. package/dist/class-map-CsENJXf1.cjs +0 -5
  181. package/dist/classutils-BwNK82ZQ.cjs +0 -1
  182. package/dist/classutils-RQs1k6D9.js +0 -7
  183. package/dist/combobox-DSB5WOxg.js +0 -815
  184. package/dist/combobox-DbICIgKG.cjs +0 -135
  185. package/dist/consent-DkOQpbsg.cjs +0 -11
  186. package/dist/consent-SNWV_mMU.js +0 -175
  187. package/dist/datepicker-BEWl9iz3.cjs +0 -273
  188. package/dist/datepicker-euHyzXnb.js +0 -1170
  189. package/dist/dialog-polyfill.esm-CPKZe7AL.cjs +0 -1
  190. package/dist/dialog-polyfill.esm-CbjBMXAG.js +0 -395
  191. package/dist/directive-C7oCP5Bh.cjs +0 -5
  192. package/dist/directive-helpers-BP2WOx60.cjs +0 -5
  193. package/dist/directive-helpers-rm-28gIj.js +0 -38
  194. package/dist/directive-oAbCiebi.js +0 -27
  195. package/dist/element-CPpT3rFQ.js +0 -638
  196. package/dist/element-gR_VtSiD.cjs +0 -27
  197. package/dist/element-with-slot-Dqk6-TRR.js +0 -240
  198. package/dist/element-with-slot-ZX-up7jO.cjs +0 -1
  199. package/dist/heading-D2tVS6lS.js +0 -103
  200. package/dist/heading-DrzbgDb6.cjs +0 -1
  201. package/dist/helptext-BKtU4mas.js +0 -82
  202. package/dist/helptext-DcRC7wW2.cjs +0 -24
  203. package/dist/icon-CxQcIa5F.js +0 -105
  204. package/dist/icon-q81vqPK_.cjs +0 -9
  205. package/dist/if-defined-B0krMLad.js +0 -10
  206. package/dist/if-defined-BOW3ODSj.cjs +0 -5
  207. package/dist/input-element-8nLwuQS4.js +0 -837
  208. package/dist/input-element-DdVhUvva.cjs +0 -1
  209. package/dist/input-wrapper-Bs4CRNst.js +0 -181
  210. package/dist/input-wrapper-Bv9aqqVq.cjs +0 -54
  211. package/dist/input-wrapper-CDgenrYA.js +0 -6
  212. package/dist/input-wrapper-EoSAbU-U.cjs +0 -1
  213. package/dist/link-C0rl-86s.cjs +0 -7
  214. package/dist/link-Cdqgl60z.js +0 -55
  215. package/dist/linkcard-Dimu7Rlx.cjs +0 -13
  216. package/dist/linkcard-Lbq_UhjZ.js +0 -56
  217. package/dist/listbox-Bia4_tvN.js +0 -440
  218. package/dist/listbox-La2GZQei.cjs +0 -106
  219. package/dist/loader-D1ugDXGV.cjs +0 -16
  220. package/dist/loader-DyN6RGC5.js +0 -95
  221. package/dist/messagebox-BGMVm2t9.js +0 -71
  222. package/dist/messagebox-M0yIgCz9.cjs +0 -13
  223. package/dist/modal-CMO1RtIi.cjs +0 -36
  224. package/dist/modal-DjPQDE-Z.js +0 -156
  225. package/dist/pkt-options-controller-5LXbEzuk.cjs +0 -1
  226. package/dist/pkt-options-controller-B5YalfCb.js +0 -39
  227. package/dist/progressbar-BqlMzkM_.cjs +0 -21
  228. package/dist/progressbar-sbHDFC12.js +0 -162
  229. package/dist/radiobutton-5ZqVVtTT.cjs +0 -31
  230. package/dist/radiobutton-D8Ai8ETa.js +0 -113
  231. package/dist/ref-Bg_Swj5w.js +0 -42
  232. package/dist/ref-CL-Xk9Xm.cjs +0 -5
  233. package/dist/repeat-BD8TKgJb.js +0 -61
  234. package/dist/repeat-Cfq8CDlf.cjs +0 -5
  235. package/dist/select-De-n8on9.js +0 -230
  236. package/dist/select-dTWibR6_.cjs +0 -49
  237. package/dist/state-C_1EOo3D.js +0 -12
  238. package/dist/state-Dg-53wQ8.cjs +0 -5
  239. package/dist/tabitem-B9-jeV97.js +0 -334
  240. package/dist/tabitem-BnhzqfW3.cjs +0 -65
  241. package/dist/tag-CbwO8yvD.cjs +0 -27
  242. package/dist/tag-D4FI5t3y.js +0 -117
  243. package/dist/textarea-BmLaKzsc.cjs +0 -50
  244. package/dist/textarea-CMiSJaYL.js +0 -133
  245. package/dist/textinput-em9y4yrL.cjs +0 -70
  246. package/dist/textinput-r8udK0IX.js +0 -152
  247. package/dist/utils-DznhwRXm.js +0 -8
  248. package/dist/utils-byXsEz1u.cjs +0 -1
@@ -1,2140 +0,0 @@
1
- import { e as rt } from "./class-map-CEnykyO_.js";
2
- import { t as Pt, P as Nt, b as k, A as at, n as f } from "./element-CPpT3rFQ.js";
3
- import { r as Z } from "./state-C_1EOo3D.js";
4
- import "./icon-CxQcIa5F.js";
5
- const yt = 6048e5, Ct = 864e5, st = Symbol.for("constructDateFrom");
6
- function v(e, t) {
7
- return typeof e == "function" ? e(t) : e && typeof e == "object" && st in e ? e[st](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
8
- }
9
- function D(e, t) {
10
- return v(t || e, e);
11
- }
12
- function it(e, t, n) {
13
- const r = D(e, n == null ? void 0 : n.in);
14
- return isNaN(t) ? v(e, NaN) : (t && r.setDate(r.getDate() + t), r);
15
- }
16
- let $t = {};
17
- function q() {
18
- return $t;
19
- }
20
- function R(e, t) {
21
- var o, c, h, m;
22
- const n = q(), r = (t == null ? void 0 : t.weekStartsOn) ?? ((c = (o = t == null ? void 0 : t.locale) == null ? void 0 : o.options) == null ? void 0 : c.weekStartsOn) ?? n.weekStartsOn ?? ((m = (h = n.locale) == null ? void 0 : h.options) == null ? void 0 : m.weekStartsOn) ?? 0, a = D(e, t == null ? void 0 : t.in), s = a.getDay(), i = (s < r ? 7 : 0) + s - r;
23
- return a.setDate(a.getDate() - i), a.setHours(0, 0, 0, 0), a;
24
- }
25
- function B(e, t) {
26
- return R(e, { ...t, weekStartsOn: 1 });
27
- }
28
- function pt(e, t) {
29
- const n = D(e, t == null ? void 0 : t.in), r = n.getFullYear(), a = v(n, 0);
30
- a.setFullYear(r + 1, 0, 4), a.setHours(0, 0, 0, 0);
31
- const s = B(a), i = v(n, 0);
32
- i.setFullYear(r, 0, 4), i.setHours(0, 0, 0, 0);
33
- const o = B(i);
34
- return n.getTime() >= s.getTime() ? r + 1 : n.getTime() >= o.getTime() ? r : r - 1;
35
- }
36
- function ot(e) {
37
- const t = D(e), n = new Date(
38
- Date.UTC(
39
- t.getFullYear(),
40
- t.getMonth(),
41
- t.getDate(),
42
- t.getHours(),
43
- t.getMinutes(),
44
- t.getSeconds(),
45
- t.getMilliseconds()
46
- )
47
- );
48
- return n.setUTCFullYear(t.getFullYear()), +e - +n;
49
- }
50
- function wt(e, ...t) {
51
- const n = v.bind(
52
- null,
53
- t.find((r) => typeof r == "object")
54
- );
55
- return t.map(n);
56
- }
57
- function J(e, t) {
58
- const n = D(e, t == null ? void 0 : t.in);
59
- return n.setHours(0, 0, 0, 0), n;
60
- }
61
- function Et(e, t, n) {
62
- const [r, a] = wt(
63
- n == null ? void 0 : n.in,
64
- e,
65
- t
66
- ), s = J(r), i = J(a), o = +s - ot(s), c = +i - ot(i);
67
- return Math.round((o - c) / Ct);
68
- }
69
- function Wt(e, t) {
70
- const n = pt(e, t), r = v(e, 0);
71
- return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), B(r);
72
- }
73
- function _t(e) {
74
- return e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]";
75
- }
76
- function Yt(e) {
77
- return !(!_t(e) && typeof e != "number" || isNaN(+D(e)));
78
- }
79
- function Ft(e, t) {
80
- const n = D(e, t == null ? void 0 : t.in);
81
- return n.setHours(23, 59, 59, 999), n;
82
- }
83
- function It(e, t) {
84
- const [n, r] = wt(e, t.start, t.end);
85
- return { start: n, end: r };
86
- }
87
- function bt(e, t) {
88
- const { start: n, end: r } = It(t == null ? void 0 : t.in, e);
89
- let a = +n > +r;
90
- const s = a ? +n : +r, i = a ? r : n;
91
- i.setHours(0, 0, 0, 0);
92
- let o = 1;
93
- const c = [];
94
- for (; +i <= s; )
95
- c.push(v(n, i)), i.setDate(i.getDate() + o), i.setHours(0, 0, 0, 0);
96
- return a ? c.reverse() : c;
97
- }
98
- function At(e, t) {
99
- const n = D(e, t == null ? void 0 : t.in);
100
- return n.setFullYear(n.getFullYear(), 0, 1), n.setHours(0, 0, 0, 0), n;
101
- }
102
- const Ht = {
103
- lessThanXSeconds: {
104
- one: "less than a second",
105
- other: "less than {{count}} seconds"
106
- },
107
- xSeconds: {
108
- one: "1 second",
109
- other: "{{count}} seconds"
110
- },
111
- halfAMinute: "half a minute",
112
- lessThanXMinutes: {
113
- one: "less than a minute",
114
- other: "less than {{count}} minutes"
115
- },
116
- xMinutes: {
117
- one: "1 minute",
118
- other: "{{count}} minutes"
119
- },
120
- aboutXHours: {
121
- one: "about 1 hour",
122
- other: "about {{count}} hours"
123
- },
124
- xHours: {
125
- one: "1 hour",
126
- other: "{{count}} hours"
127
- },
128
- xDays: {
129
- one: "1 day",
130
- other: "{{count}} days"
131
- },
132
- aboutXWeeks: {
133
- one: "about 1 week",
134
- other: "about {{count}} weeks"
135
- },
136
- xWeeks: {
137
- one: "1 week",
138
- other: "{{count}} weeks"
139
- },
140
- aboutXMonths: {
141
- one: "about 1 month",
142
- other: "about {{count}} months"
143
- },
144
- xMonths: {
145
- one: "1 month",
146
- other: "{{count}} months"
147
- },
148
- aboutXYears: {
149
- one: "about 1 year",
150
- other: "about {{count}} years"
151
- },
152
- xYears: {
153
- one: "1 year",
154
- other: "{{count}} years"
155
- },
156
- overXYears: {
157
- one: "over 1 year",
158
- other: "over {{count}} years"
159
- },
160
- almostXYears: {
161
- one: "almost 1 year",
162
- other: "almost {{count}} years"
163
- }
164
- }, Rt = (e, t, n) => {
165
- let r;
166
- const a = Ht[e];
167
- return typeof a == "string" ? r = a : t === 1 ? r = a.one : r = a.other.replace("{{count}}", t.toString()), n != null && n.addSuffix ? n.comparison && n.comparison > 0 ? "in " + r : r + " ago" : r;
168
- };
169
- function X(e) {
170
- return (t = {}) => {
171
- const n = t.width ? String(t.width) : e.defaultWidth;
172
- return e.formats[n] || e.formats[e.defaultWidth];
173
- };
174
- }
175
- const Ut = {
176
- full: "EEEE, MMMM do, y",
177
- long: "MMMM do, y",
178
- medium: "MMM d, y",
179
- short: "MM/dd/yyyy"
180
- }, Lt = {
181
- full: "h:mm:ss a zzzz",
182
- long: "h:mm:ss a z",
183
- medium: "h:mm:ss a",
184
- short: "h:mm a"
185
- }, Bt = {
186
- full: "{{date}} 'at' {{time}}",
187
- long: "{{date}} 'at' {{time}}",
188
- medium: "{{date}}, {{time}}",
189
- short: "{{date}}, {{time}}"
190
- }, qt = {
191
- date: X({
192
- formats: Ut,
193
- defaultWidth: "full"
194
- }),
195
- time: X({
196
- formats: Lt,
197
- defaultWidth: "full"
198
- }),
199
- dateTime: X({
200
- formats: Bt,
201
- defaultWidth: "full"
202
- })
203
- }, zt = {
204
- lastWeek: "'last' eeee 'at' p",
205
- yesterday: "'yesterday at' p",
206
- today: "'today at' p",
207
- tomorrow: "'tomorrow at' p",
208
- nextWeek: "eeee 'at' p",
209
- other: "P"
210
- }, jt = (e, t, n, r) => zt[e];
211
- function F(e) {
212
- return (t, n) => {
213
- const r = n != null && n.context ? String(n.context) : "standalone";
214
- let a;
215
- if (r === "formatting" && e.formattingValues) {
216
- const i = e.defaultFormattingWidth || e.defaultWidth, o = n != null && n.width ? String(n.width) : i;
217
- a = e.formattingValues[o] || e.formattingValues[i];
218
- } else {
219
- const i = e.defaultWidth, o = n != null && n.width ? String(n.width) : e.defaultWidth;
220
- a = e.values[o] || e.values[i];
221
- }
222
- const s = e.argumentCallback ? e.argumentCallback(t) : t;
223
- return a[s];
224
- };
225
- }
226
- const Qt = {
227
- narrow: ["B", "A"],
228
- abbreviated: ["BC", "AD"],
229
- wide: ["Before Christ", "Anno Domini"]
230
- }, Xt = {
231
- narrow: ["1", "2", "3", "4"],
232
- abbreviated: ["Q1", "Q2", "Q3", "Q4"],
233
- wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
234
- }, Gt = {
235
- narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
236
- abbreviated: [
237
- "Jan",
238
- "Feb",
239
- "Mar",
240
- "Apr",
241
- "May",
242
- "Jun",
243
- "Jul",
244
- "Aug",
245
- "Sep",
246
- "Oct",
247
- "Nov",
248
- "Dec"
249
- ],
250
- wide: [
251
- "January",
252
- "February",
253
- "March",
254
- "April",
255
- "May",
256
- "June",
257
- "July",
258
- "August",
259
- "September",
260
- "October",
261
- "November",
262
- "December"
263
- ]
264
- }, Vt = {
265
- narrow: ["S", "M", "T", "W", "T", "F", "S"],
266
- short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
267
- abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
268
- wide: [
269
- "Sunday",
270
- "Monday",
271
- "Tuesday",
272
- "Wednesday",
273
- "Thursday",
274
- "Friday",
275
- "Saturday"
276
- ]
277
- }, Jt = {
278
- narrow: {
279
- am: "a",
280
- pm: "p",
281
- midnight: "mi",
282
- noon: "n",
283
- morning: "morning",
284
- afternoon: "afternoon",
285
- evening: "evening",
286
- night: "night"
287
- },
288
- abbreviated: {
289
- am: "AM",
290
- pm: "PM",
291
- midnight: "midnight",
292
- noon: "noon",
293
- morning: "morning",
294
- afternoon: "afternoon",
295
- evening: "evening",
296
- night: "night"
297
- },
298
- wide: {
299
- am: "a.m.",
300
- pm: "p.m.",
301
- midnight: "midnight",
302
- noon: "noon",
303
- morning: "morning",
304
- afternoon: "afternoon",
305
- evening: "evening",
306
- night: "night"
307
- }
308
- }, Kt = {
309
- narrow: {
310
- am: "a",
311
- pm: "p",
312
- midnight: "mi",
313
- noon: "n",
314
- morning: "in the morning",
315
- afternoon: "in the afternoon",
316
- evening: "in the evening",
317
- night: "at night"
318
- },
319
- abbreviated: {
320
- am: "AM",
321
- pm: "PM",
322
- midnight: "midnight",
323
- noon: "noon",
324
- morning: "in the morning",
325
- afternoon: "in the afternoon",
326
- evening: "in the evening",
327
- night: "at night"
328
- },
329
- wide: {
330
- am: "a.m.",
331
- pm: "p.m.",
332
- midnight: "midnight",
333
- noon: "noon",
334
- morning: "in the morning",
335
- afternoon: "in the afternoon",
336
- evening: "in the evening",
337
- night: "at night"
338
- }
339
- }, Zt = (e, t) => {
340
- const n = Number(e), r = n % 100;
341
- if (r > 20 || r < 10)
342
- switch (r % 10) {
343
- case 1:
344
- return n + "st";
345
- case 2:
346
- return n + "nd";
347
- case 3:
348
- return n + "rd";
349
- }
350
- return n + "th";
351
- }, te = {
352
- ordinalNumber: Zt,
353
- era: F({
354
- values: Qt,
355
- defaultWidth: "wide"
356
- }),
357
- quarter: F({
358
- values: Xt,
359
- defaultWidth: "wide",
360
- argumentCallback: (e) => e - 1
361
- }),
362
- month: F({
363
- values: Gt,
364
- defaultWidth: "wide"
365
- }),
366
- day: F({
367
- values: Vt,
368
- defaultWidth: "wide"
369
- }),
370
- dayPeriod: F({
371
- values: Jt,
372
- defaultWidth: "wide",
373
- formattingValues: Kt,
374
- defaultFormattingWidth: "wide"
375
- })
376
- };
377
- function I(e) {
378
- return (t, n = {}) => {
379
- const r = n.width, a = r && e.matchPatterns[r] || e.matchPatterns[e.defaultMatchWidth], s = t.match(a);
380
- if (!s)
381
- return null;
382
- const i = s[0], o = r && e.parsePatterns[r] || e.parsePatterns[e.defaultParseWidth], c = Array.isArray(o) ? ne(o, (p) => p.test(i)) : (
383
- // [TODO] -- I challenge you to fix the type
384
- ee(o, (p) => p.test(i))
385
- );
386
- let h;
387
- h = e.valueCallback ? e.valueCallback(c) : c, h = n.valueCallback ? (
388
- // [TODO] -- I challenge you to fix the type
389
- n.valueCallback(h)
390
- ) : h;
391
- const m = t.slice(i.length);
392
- return { value: h, rest: m };
393
- };
394
- }
395
- function ee(e, t) {
396
- for (const n in e)
397
- if (Object.prototype.hasOwnProperty.call(e, n) && t(e[n]))
398
- return n;
399
- }
400
- function ne(e, t) {
401
- for (let n = 0; n < e.length; n++)
402
- if (t(e[n]))
403
- return n;
404
- }
405
- function re(e) {
406
- return (t, n = {}) => {
407
- const r = t.match(e.matchPattern);
408
- if (!r) return null;
409
- const a = r[0], s = t.match(e.parsePattern);
410
- if (!s) return null;
411
- let i = e.valueCallback ? e.valueCallback(s[0]) : s[0];
412
- i = n.valueCallback ? n.valueCallback(i) : i;
413
- const o = t.slice(a.length);
414
- return { value: i, rest: o };
415
- };
416
- }
417
- const ae = /^(\d+)(th|st|nd|rd)?/i, se = /\d+/i, ie = {
418
- narrow: /^(b|a)/i,
419
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
420
- wide: /^(before christ|before common era|anno domini|common era)/i
421
- }, oe = {
422
- any: [/^b/i, /^(a|c)/i]
423
- }, ce = {
424
- narrow: /^[1234]/i,
425
- abbreviated: /^q[1234]/i,
426
- wide: /^[1234](th|st|nd|rd)? quarter/i
427
- }, ue = {
428
- any: [/1/i, /2/i, /3/i, /4/i]
429
- }, le = {
430
- narrow: /^[jfmasond]/i,
431
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
432
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
433
- }, he = {
434
- narrow: [
435
- /^j/i,
436
- /^f/i,
437
- /^m/i,
438
- /^a/i,
439
- /^m/i,
440
- /^j/i,
441
- /^j/i,
442
- /^a/i,
443
- /^s/i,
444
- /^o/i,
445
- /^n/i,
446
- /^d/i
447
- ],
448
- any: [
449
- /^ja/i,
450
- /^f/i,
451
- /^mar/i,
452
- /^ap/i,
453
- /^may/i,
454
- /^jun/i,
455
- /^jul/i,
456
- /^au/i,
457
- /^s/i,
458
- /^o/i,
459
- /^n/i,
460
- /^d/i
461
- ]
462
- }, de = {
463
- narrow: /^[smtwf]/i,
464
- short: /^(su|mo|tu|we|th|fr|sa)/i,
465
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
466
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
467
- }, fe = {
468
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
469
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
470
- }, me = {
471
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
472
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
473
- }, ge = {
474
- any: {
475
- am: /^a/i,
476
- pm: /^p/i,
477
- midnight: /^mi/i,
478
- noon: /^no/i,
479
- morning: /morning/i,
480
- afternoon: /afternoon/i,
481
- evening: /evening/i,
482
- night: /night/i
483
- }
484
- }, ye = {
485
- ordinalNumber: re({
486
- matchPattern: ae,
487
- parsePattern: se,
488
- valueCallback: (e) => parseInt(e, 10)
489
- }),
490
- era: I({
491
- matchPatterns: ie,
492
- defaultMatchWidth: "wide",
493
- parsePatterns: oe,
494
- defaultParseWidth: "any"
495
- }),
496
- quarter: I({
497
- matchPatterns: ce,
498
- defaultMatchWidth: "wide",
499
- parsePatterns: ue,
500
- defaultParseWidth: "any",
501
- valueCallback: (e) => e + 1
502
- }),
503
- month: I({
504
- matchPatterns: le,
505
- defaultMatchWidth: "wide",
506
- parsePatterns: he,
507
- defaultParseWidth: "any"
508
- }),
509
- day: I({
510
- matchPatterns: de,
511
- defaultMatchWidth: "wide",
512
- parsePatterns: fe,
513
- defaultParseWidth: "any"
514
- }),
515
- dayPeriod: I({
516
- matchPatterns: me,
517
- defaultMatchWidth: "any",
518
- parsePatterns: ge,
519
- defaultParseWidth: "any"
520
- })
521
- }, pe = {
522
- code: "en-US",
523
- formatDistance: Rt,
524
- formatLong: qt,
525
- formatRelative: jt,
526
- localize: te,
527
- match: ye,
528
- options: {
529
- weekStartsOn: 0,
530
- firstWeekContainsDate: 1
531
- }
532
- };
533
- function we(e, t) {
534
- const n = D(e, t == null ? void 0 : t.in);
535
- return Et(n, At(n)) + 1;
536
- }
537
- function be(e, t) {
538
- const n = D(e, t == null ? void 0 : t.in), r = +B(n) - +Wt(n);
539
- return Math.round(r / yt) + 1;
540
- }
541
- function Dt(e, t) {
542
- var m, p, w, M;
543
- const n = D(e, t == null ? void 0 : t.in), r = n.getFullYear(), a = q(), s = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((p = (m = t == null ? void 0 : t.locale) == null ? void 0 : m.options) == null ? void 0 : p.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((M = (w = a.locale) == null ? void 0 : w.options) == null ? void 0 : M.firstWeekContainsDate) ?? 1, i = v((t == null ? void 0 : t.in) || e, 0);
544
- i.setFullYear(r + 1, 0, s), i.setHours(0, 0, 0, 0);
545
- const o = R(i, t), c = v((t == null ? void 0 : t.in) || e, 0);
546
- c.setFullYear(r, 0, s), c.setHours(0, 0, 0, 0);
547
- const h = R(c, t);
548
- return +n >= +o ? r + 1 : +n >= +h ? r : r - 1;
549
- }
550
- function De(e, t) {
551
- var o, c, h, m;
552
- const n = q(), r = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((c = (o = t == null ? void 0 : t.locale) == null ? void 0 : o.options) == null ? void 0 : c.firstWeekContainsDate) ?? n.firstWeekContainsDate ?? ((m = (h = n.locale) == null ? void 0 : h.options) == null ? void 0 : m.firstWeekContainsDate) ?? 1, a = Dt(e, t), s = v((t == null ? void 0 : t.in) || e, 0);
553
- return s.setFullYear(a, 0, r), s.setHours(0, 0, 0, 0), R(s, t);
554
- }
555
- function kt(e, t) {
556
- const n = D(e, t == null ? void 0 : t.in), r = +R(n, t) - +De(n, t);
557
- return Math.round(r / yt) + 1;
558
- }
559
- function u(e, t) {
560
- const n = e < 0 ? "-" : "", r = Math.abs(e).toString().padStart(t, "0");
561
- return n + r;
562
- }
563
- const T = {
564
- // Year
565
- y(e, t) {
566
- const n = e.getFullYear(), r = n > 0 ? n : 1 - n;
567
- return u(t === "yy" ? r % 100 : r, t.length);
568
- },
569
- // Month
570
- M(e, t) {
571
- const n = e.getMonth();
572
- return t === "M" ? String(n + 1) : u(n + 1, 2);
573
- },
574
- // Day of the month
575
- d(e, t) {
576
- return u(e.getDate(), t.length);
577
- },
578
- // AM or PM
579
- a(e, t) {
580
- const n = e.getHours() / 12 >= 1 ? "pm" : "am";
581
- switch (t) {
582
- case "a":
583
- case "aa":
584
- return n.toUpperCase();
585
- case "aaa":
586
- return n;
587
- case "aaaaa":
588
- return n[0];
589
- case "aaaa":
590
- default:
591
- return n === "am" ? "a.m." : "p.m.";
592
- }
593
- },
594
- // Hour [1-12]
595
- h(e, t) {
596
- return u(e.getHours() % 12 || 12, t.length);
597
- },
598
- // Hour [0-23]
599
- H(e, t) {
600
- return u(e.getHours(), t.length);
601
- },
602
- // Minute
603
- m(e, t) {
604
- return u(e.getMinutes(), t.length);
605
- },
606
- // Second
607
- s(e, t) {
608
- return u(e.getSeconds(), t.length);
609
- },
610
- // Fraction of second
611
- S(e, t) {
612
- const n = t.length, r = e.getMilliseconds(), a = Math.trunc(
613
- r * Math.pow(10, n - 3)
614
- );
615
- return u(a, t.length);
616
- }
617
- }, E = {
618
- midnight: "midnight",
619
- noon: "noon",
620
- morning: "morning",
621
- afternoon: "afternoon",
622
- evening: "evening",
623
- night: "night"
624
- }, ct = {
625
- // Era
626
- G: function(e, t, n) {
627
- const r = e.getFullYear() > 0 ? 1 : 0;
628
- switch (t) {
629
- // AD, BC
630
- case "G":
631
- case "GG":
632
- case "GGG":
633
- return n.era(r, { width: "abbreviated" });
634
- // A, B
635
- case "GGGGG":
636
- return n.era(r, { width: "narrow" });
637
- // Anno Domini, Before Christ
638
- case "GGGG":
639
- default:
640
- return n.era(r, { width: "wide" });
641
- }
642
- },
643
- // Year
644
- y: function(e, t, n) {
645
- if (t === "yo") {
646
- const r = e.getFullYear(), a = r > 0 ? r : 1 - r;
647
- return n.ordinalNumber(a, { unit: "year" });
648
- }
649
- return T.y(e, t);
650
- },
651
- // Local week-numbering year
652
- Y: function(e, t, n, r) {
653
- const a = Dt(e, r), s = a > 0 ? a : 1 - a;
654
- if (t === "YY") {
655
- const i = s % 100;
656
- return u(i, 2);
657
- }
658
- return t === "Yo" ? n.ordinalNumber(s, { unit: "year" }) : u(s, t.length);
659
- },
660
- // ISO week-numbering year
661
- R: function(e, t) {
662
- const n = pt(e);
663
- return u(n, t.length);
664
- },
665
- // Extended year. This is a single number designating the year of this calendar system.
666
- // The main difference between `y` and `u` localizers are B.C. years:
667
- // | Year | `y` | `u` |
668
- // |------|-----|-----|
669
- // | AC 1 | 1 | 1 |
670
- // | BC 1 | 1 | 0 |
671
- // | BC 2 | 2 | -1 |
672
- // Also `yy` always returns the last two digits of a year,
673
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
674
- u: function(e, t) {
675
- const n = e.getFullYear();
676
- return u(n, t.length);
677
- },
678
- // Quarter
679
- Q: function(e, t, n) {
680
- const r = Math.ceil((e.getMonth() + 1) / 3);
681
- switch (t) {
682
- // 1, 2, 3, 4
683
- case "Q":
684
- return String(r);
685
- // 01, 02, 03, 04
686
- case "QQ":
687
- return u(r, 2);
688
- // 1st, 2nd, 3rd, 4th
689
- case "Qo":
690
- return n.ordinalNumber(r, { unit: "quarter" });
691
- // Q1, Q2, Q3, Q4
692
- case "QQQ":
693
- return n.quarter(r, {
694
- width: "abbreviated",
695
- context: "formatting"
696
- });
697
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
698
- case "QQQQQ":
699
- return n.quarter(r, {
700
- width: "narrow",
701
- context: "formatting"
702
- });
703
- // 1st quarter, 2nd quarter, ...
704
- case "QQQQ":
705
- default:
706
- return n.quarter(r, {
707
- width: "wide",
708
- context: "formatting"
709
- });
710
- }
711
- },
712
- // Stand-alone quarter
713
- q: function(e, t, n) {
714
- const r = Math.ceil((e.getMonth() + 1) / 3);
715
- switch (t) {
716
- // 1, 2, 3, 4
717
- case "q":
718
- return String(r);
719
- // 01, 02, 03, 04
720
- case "qq":
721
- return u(r, 2);
722
- // 1st, 2nd, 3rd, 4th
723
- case "qo":
724
- return n.ordinalNumber(r, { unit: "quarter" });
725
- // Q1, Q2, Q3, Q4
726
- case "qqq":
727
- return n.quarter(r, {
728
- width: "abbreviated",
729
- context: "standalone"
730
- });
731
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
732
- case "qqqqq":
733
- return n.quarter(r, {
734
- width: "narrow",
735
- context: "standalone"
736
- });
737
- // 1st quarter, 2nd quarter, ...
738
- case "qqqq":
739
- default:
740
- return n.quarter(r, {
741
- width: "wide",
742
- context: "standalone"
743
- });
744
- }
745
- },
746
- // Month
747
- M: function(e, t, n) {
748
- const r = e.getMonth();
749
- switch (t) {
750
- case "M":
751
- case "MM":
752
- return T.M(e, t);
753
- // 1st, 2nd, ..., 12th
754
- case "Mo":
755
- return n.ordinalNumber(r + 1, { unit: "month" });
756
- // Jan, Feb, ..., Dec
757
- case "MMM":
758
- return n.month(r, {
759
- width: "abbreviated",
760
- context: "formatting"
761
- });
762
- // J, F, ..., D
763
- case "MMMMM":
764
- return n.month(r, {
765
- width: "narrow",
766
- context: "formatting"
767
- });
768
- // January, February, ..., December
769
- case "MMMM":
770
- default:
771
- return n.month(r, { width: "wide", context: "formatting" });
772
- }
773
- },
774
- // Stand-alone month
775
- L: function(e, t, n) {
776
- const r = e.getMonth();
777
- switch (t) {
778
- // 1, 2, ..., 12
779
- case "L":
780
- return String(r + 1);
781
- // 01, 02, ..., 12
782
- case "LL":
783
- return u(r + 1, 2);
784
- // 1st, 2nd, ..., 12th
785
- case "Lo":
786
- return n.ordinalNumber(r + 1, { unit: "month" });
787
- // Jan, Feb, ..., Dec
788
- case "LLL":
789
- return n.month(r, {
790
- width: "abbreviated",
791
- context: "standalone"
792
- });
793
- // J, F, ..., D
794
- case "LLLLL":
795
- return n.month(r, {
796
- width: "narrow",
797
- context: "standalone"
798
- });
799
- // January, February, ..., December
800
- case "LLLL":
801
- default:
802
- return n.month(r, { width: "wide", context: "standalone" });
803
- }
804
- },
805
- // Local week of year
806
- w: function(e, t, n, r) {
807
- const a = kt(e, r);
808
- return t === "wo" ? n.ordinalNumber(a, { unit: "week" }) : u(a, t.length);
809
- },
810
- // ISO week of year
811
- I: function(e, t, n) {
812
- const r = be(e);
813
- return t === "Io" ? n.ordinalNumber(r, { unit: "week" }) : u(r, t.length);
814
- },
815
- // Day of the month
816
- d: function(e, t, n) {
817
- return t === "do" ? n.ordinalNumber(e.getDate(), { unit: "date" }) : T.d(e, t);
818
- },
819
- // Day of year
820
- D: function(e, t, n) {
821
- const r = we(e);
822
- return t === "Do" ? n.ordinalNumber(r, { unit: "dayOfYear" }) : u(r, t.length);
823
- },
824
- // Day of week
825
- E: function(e, t, n) {
826
- const r = e.getDay();
827
- switch (t) {
828
- // Tue
829
- case "E":
830
- case "EE":
831
- case "EEE":
832
- return n.day(r, {
833
- width: "abbreviated",
834
- context: "formatting"
835
- });
836
- // T
837
- case "EEEEE":
838
- return n.day(r, {
839
- width: "narrow",
840
- context: "formatting"
841
- });
842
- // Tu
843
- case "EEEEEE":
844
- return n.day(r, {
845
- width: "short",
846
- context: "formatting"
847
- });
848
- // Tuesday
849
- case "EEEE":
850
- default:
851
- return n.day(r, {
852
- width: "wide",
853
- context: "formatting"
854
- });
855
- }
856
- },
857
- // Local day of week
858
- e: function(e, t, n, r) {
859
- const a = e.getDay(), s = (a - r.weekStartsOn + 8) % 7 || 7;
860
- switch (t) {
861
- // Numerical value (Nth day of week with current locale or weekStartsOn)
862
- case "e":
863
- return String(s);
864
- // Padded numerical value
865
- case "ee":
866
- return u(s, 2);
867
- // 1st, 2nd, ..., 7th
868
- case "eo":
869
- return n.ordinalNumber(s, { unit: "day" });
870
- case "eee":
871
- return n.day(a, {
872
- width: "abbreviated",
873
- context: "formatting"
874
- });
875
- // T
876
- case "eeeee":
877
- return n.day(a, {
878
- width: "narrow",
879
- context: "formatting"
880
- });
881
- // Tu
882
- case "eeeeee":
883
- return n.day(a, {
884
- width: "short",
885
- context: "formatting"
886
- });
887
- // Tuesday
888
- case "eeee":
889
- default:
890
- return n.day(a, {
891
- width: "wide",
892
- context: "formatting"
893
- });
894
- }
895
- },
896
- // Stand-alone local day of week
897
- c: function(e, t, n, r) {
898
- const a = e.getDay(), s = (a - r.weekStartsOn + 8) % 7 || 7;
899
- switch (t) {
900
- // Numerical value (same as in `e`)
901
- case "c":
902
- return String(s);
903
- // Padded numerical value
904
- case "cc":
905
- return u(s, t.length);
906
- // 1st, 2nd, ..., 7th
907
- case "co":
908
- return n.ordinalNumber(s, { unit: "day" });
909
- case "ccc":
910
- return n.day(a, {
911
- width: "abbreviated",
912
- context: "standalone"
913
- });
914
- // T
915
- case "ccccc":
916
- return n.day(a, {
917
- width: "narrow",
918
- context: "standalone"
919
- });
920
- // Tu
921
- case "cccccc":
922
- return n.day(a, {
923
- width: "short",
924
- context: "standalone"
925
- });
926
- // Tuesday
927
- case "cccc":
928
- default:
929
- return n.day(a, {
930
- width: "wide",
931
- context: "standalone"
932
- });
933
- }
934
- },
935
- // ISO day of week
936
- i: function(e, t, n) {
937
- const r = e.getDay(), a = r === 0 ? 7 : r;
938
- switch (t) {
939
- // 2
940
- case "i":
941
- return String(a);
942
- // 02
943
- case "ii":
944
- return u(a, t.length);
945
- // 2nd
946
- case "io":
947
- return n.ordinalNumber(a, { unit: "day" });
948
- // Tue
949
- case "iii":
950
- return n.day(r, {
951
- width: "abbreviated",
952
- context: "formatting"
953
- });
954
- // T
955
- case "iiiii":
956
- return n.day(r, {
957
- width: "narrow",
958
- context: "formatting"
959
- });
960
- // Tu
961
- case "iiiiii":
962
- return n.day(r, {
963
- width: "short",
964
- context: "formatting"
965
- });
966
- // Tuesday
967
- case "iiii":
968
- default:
969
- return n.day(r, {
970
- width: "wide",
971
- context: "formatting"
972
- });
973
- }
974
- },
975
- // AM or PM
976
- a: function(e, t, n) {
977
- const a = e.getHours() / 12 >= 1 ? "pm" : "am";
978
- switch (t) {
979
- case "a":
980
- case "aa":
981
- return n.dayPeriod(a, {
982
- width: "abbreviated",
983
- context: "formatting"
984
- });
985
- case "aaa":
986
- return n.dayPeriod(a, {
987
- width: "abbreviated",
988
- context: "formatting"
989
- }).toLowerCase();
990
- case "aaaaa":
991
- return n.dayPeriod(a, {
992
- width: "narrow",
993
- context: "formatting"
994
- });
995
- case "aaaa":
996
- default:
997
- return n.dayPeriod(a, {
998
- width: "wide",
999
- context: "formatting"
1000
- });
1001
- }
1002
- },
1003
- // AM, PM, midnight, noon
1004
- b: function(e, t, n) {
1005
- const r = e.getHours();
1006
- let a;
1007
- switch (r === 12 ? a = E.noon : r === 0 ? a = E.midnight : a = r / 12 >= 1 ? "pm" : "am", t) {
1008
- case "b":
1009
- case "bb":
1010
- return n.dayPeriod(a, {
1011
- width: "abbreviated",
1012
- context: "formatting"
1013
- });
1014
- case "bbb":
1015
- return n.dayPeriod(a, {
1016
- width: "abbreviated",
1017
- context: "formatting"
1018
- }).toLowerCase();
1019
- case "bbbbb":
1020
- return n.dayPeriod(a, {
1021
- width: "narrow",
1022
- context: "formatting"
1023
- });
1024
- case "bbbb":
1025
- default:
1026
- return n.dayPeriod(a, {
1027
- width: "wide",
1028
- context: "formatting"
1029
- });
1030
- }
1031
- },
1032
- // in the morning, in the afternoon, in the evening, at night
1033
- B: function(e, t, n) {
1034
- const r = e.getHours();
1035
- let a;
1036
- switch (r >= 17 ? a = E.evening : r >= 12 ? a = E.afternoon : r >= 4 ? a = E.morning : a = E.night, t) {
1037
- case "B":
1038
- case "BB":
1039
- case "BBB":
1040
- return n.dayPeriod(a, {
1041
- width: "abbreviated",
1042
- context: "formatting"
1043
- });
1044
- case "BBBBB":
1045
- return n.dayPeriod(a, {
1046
- width: "narrow",
1047
- context: "formatting"
1048
- });
1049
- case "BBBB":
1050
- default:
1051
- return n.dayPeriod(a, {
1052
- width: "wide",
1053
- context: "formatting"
1054
- });
1055
- }
1056
- },
1057
- // Hour [1-12]
1058
- h: function(e, t, n) {
1059
- if (t === "ho") {
1060
- let r = e.getHours() % 12;
1061
- return r === 0 && (r = 12), n.ordinalNumber(r, { unit: "hour" });
1062
- }
1063
- return T.h(e, t);
1064
- },
1065
- // Hour [0-23]
1066
- H: function(e, t, n) {
1067
- return t === "Ho" ? n.ordinalNumber(e.getHours(), { unit: "hour" }) : T.H(e, t);
1068
- },
1069
- // Hour [0-11]
1070
- K: function(e, t, n) {
1071
- const r = e.getHours() % 12;
1072
- return t === "Ko" ? n.ordinalNumber(r, { unit: "hour" }) : u(r, t.length);
1073
- },
1074
- // Hour [1-24]
1075
- k: function(e, t, n) {
1076
- let r = e.getHours();
1077
- return r === 0 && (r = 24), t === "ko" ? n.ordinalNumber(r, { unit: "hour" }) : u(r, t.length);
1078
- },
1079
- // Minute
1080
- m: function(e, t, n) {
1081
- return t === "mo" ? n.ordinalNumber(e.getMinutes(), { unit: "minute" }) : T.m(e, t);
1082
- },
1083
- // Second
1084
- s: function(e, t, n) {
1085
- return t === "so" ? n.ordinalNumber(e.getSeconds(), { unit: "second" }) : T.s(e, t);
1086
- },
1087
- // Fraction of second
1088
- S: function(e, t) {
1089
- return T.S(e, t);
1090
- },
1091
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1092
- X: function(e, t, n) {
1093
- const r = e.getTimezoneOffset();
1094
- if (r === 0)
1095
- return "Z";
1096
- switch (t) {
1097
- // Hours and optional minutes
1098
- case "X":
1099
- return lt(r);
1100
- // Hours, minutes and optional seconds without `:` delimiter
1101
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1102
- // so this token always has the same output as `XX`
1103
- case "XXXX":
1104
- case "XX":
1105
- return N(r);
1106
- // Hours, minutes and optional seconds with `:` delimiter
1107
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1108
- // so this token always has the same output as `XXX`
1109
- case "XXXXX":
1110
- case "XXX":
1111
- // Hours and minutes with `:` delimiter
1112
- default:
1113
- return N(r, ":");
1114
- }
1115
- },
1116
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1117
- x: function(e, t, n) {
1118
- const r = e.getTimezoneOffset();
1119
- switch (t) {
1120
- // Hours and optional minutes
1121
- case "x":
1122
- return lt(r);
1123
- // Hours, minutes and optional seconds without `:` delimiter
1124
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1125
- // so this token always has the same output as `xx`
1126
- case "xxxx":
1127
- case "xx":
1128
- return N(r);
1129
- // Hours, minutes and optional seconds with `:` delimiter
1130
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1131
- // so this token always has the same output as `xxx`
1132
- case "xxxxx":
1133
- case "xxx":
1134
- // Hours and minutes with `:` delimiter
1135
- default:
1136
- return N(r, ":");
1137
- }
1138
- },
1139
- // Timezone (GMT)
1140
- O: function(e, t, n) {
1141
- const r = e.getTimezoneOffset();
1142
- switch (t) {
1143
- // Short
1144
- case "O":
1145
- case "OO":
1146
- case "OOO":
1147
- return "GMT" + ut(r, ":");
1148
- // Long
1149
- case "OOOO":
1150
- default:
1151
- return "GMT" + N(r, ":");
1152
- }
1153
- },
1154
- // Timezone (specific non-location)
1155
- z: function(e, t, n) {
1156
- const r = e.getTimezoneOffset();
1157
- switch (t) {
1158
- // Short
1159
- case "z":
1160
- case "zz":
1161
- case "zzz":
1162
- return "GMT" + ut(r, ":");
1163
- // Long
1164
- case "zzzz":
1165
- default:
1166
- return "GMT" + N(r, ":");
1167
- }
1168
- },
1169
- // Seconds timestamp
1170
- t: function(e, t, n) {
1171
- const r = Math.trunc(+e / 1e3);
1172
- return u(r, t.length);
1173
- },
1174
- // Milliseconds timestamp
1175
- T: function(e, t, n) {
1176
- return u(+e, t.length);
1177
- }
1178
- };
1179
- function ut(e, t = "") {
1180
- const n = e > 0 ? "-" : "+", r = Math.abs(e), a = Math.trunc(r / 60), s = r % 60;
1181
- return s === 0 ? n + String(a) : n + String(a) + t + u(s, 2);
1182
- }
1183
- function lt(e, t) {
1184
- return e % 60 === 0 ? (e > 0 ? "-" : "+") + u(Math.abs(e) / 60, 2) : N(e, t);
1185
- }
1186
- function N(e, t = "") {
1187
- const n = e > 0 ? "-" : "+", r = Math.abs(e), a = u(Math.trunc(r / 60), 2), s = u(r % 60, 2);
1188
- return n + a + t + s;
1189
- }
1190
- const ht = (e, t) => {
1191
- switch (e) {
1192
- case "P":
1193
- return t.date({ width: "short" });
1194
- case "PP":
1195
- return t.date({ width: "medium" });
1196
- case "PPP":
1197
- return t.date({ width: "long" });
1198
- case "PPPP":
1199
- default:
1200
- return t.date({ width: "full" });
1201
- }
1202
- }, St = (e, t) => {
1203
- switch (e) {
1204
- case "p":
1205
- return t.time({ width: "short" });
1206
- case "pp":
1207
- return t.time({ width: "medium" });
1208
- case "ppp":
1209
- return t.time({ width: "long" });
1210
- case "pppp":
1211
- default:
1212
- return t.time({ width: "full" });
1213
- }
1214
- }, ke = (e, t) => {
1215
- const n = e.match(/(P+)(p+)?/) || [], r = n[1], a = n[2];
1216
- if (!a)
1217
- return ht(e, t);
1218
- let s;
1219
- switch (r) {
1220
- case "P":
1221
- s = t.dateTime({ width: "short" });
1222
- break;
1223
- case "PP":
1224
- s = t.dateTime({ width: "medium" });
1225
- break;
1226
- case "PPP":
1227
- s = t.dateTime({ width: "long" });
1228
- break;
1229
- case "PPPP":
1230
- default:
1231
- s = t.dateTime({ width: "full" });
1232
- break;
1233
- }
1234
- return s.replace("{{date}}", ht(r, t)).replace("{{time}}", St(a, t));
1235
- }, Se = {
1236
- p: St,
1237
- P: ke
1238
- }, ve = /^D+$/, Me = /^Y+$/, Te = ["D", "DD", "YY", "YYYY"];
1239
- function xe(e) {
1240
- return ve.test(e);
1241
- }
1242
- function Oe(e) {
1243
- return Me.test(e);
1244
- }
1245
- function Pe(e, t, n) {
1246
- const r = Ne(e, t, n);
1247
- if (console.warn(r), Te.includes(e)) throw new RangeError(r);
1248
- }
1249
- function Ne(e, t, n) {
1250
- const r = e[0] === "Y" ? "years" : "days of the month";
1251
- return `Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
1252
- }
1253
- const Ce = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, $e = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Ee = /^'([^]*?)'?$/, We = /''/g, _e = /[a-zA-Z]/;
1254
- function Ye(e, t, n) {
1255
- var m, p, w, M;
1256
- const r = q(), a = r.locale ?? pe, s = r.firstWeekContainsDate ?? ((p = (m = r.locale) == null ? void 0 : m.options) == null ? void 0 : p.firstWeekContainsDate) ?? 1, i = r.weekStartsOn ?? ((M = (w = r.locale) == null ? void 0 : w.options) == null ? void 0 : M.weekStartsOn) ?? 0, o = D(e, n == null ? void 0 : n.in);
1257
- if (!Yt(o))
1258
- throw new RangeError("Invalid time value");
1259
- let c = t.match($e).map((b) => {
1260
- const y = b[0];
1261
- if (y === "p" || y === "P") {
1262
- const Y = Se[y];
1263
- return Y(b, a.formatLong);
1264
- }
1265
- return b;
1266
- }).join("").match(Ce).map((b) => {
1267
- if (b === "''")
1268
- return { isToken: !1, value: "'" };
1269
- const y = b[0];
1270
- if (y === "'")
1271
- return { isToken: !1, value: Fe(b) };
1272
- if (ct[y])
1273
- return { isToken: !0, value: b };
1274
- if (y.match(_e))
1275
- throw new RangeError(
1276
- "Format string contains an unescaped latin alphabet character `" + y + "`"
1277
- );
1278
- return { isToken: !1, value: b };
1279
- });
1280
- a.localize.preprocessor && (c = a.localize.preprocessor(o, c));
1281
- const h = {
1282
- firstWeekContainsDate: s,
1283
- weekStartsOn: i,
1284
- locale: a
1285
- };
1286
- return c.map((b) => {
1287
- if (!b.isToken) return b.value;
1288
- const y = b.value;
1289
- (Oe(y) || xe(y)) && Pe(y, t, String(e));
1290
- const Y = ct[y[0]];
1291
- return Y(o, y, a.localize, h);
1292
- }).join("");
1293
- }
1294
- function Fe(e) {
1295
- const t = e.match(Ee);
1296
- return t ? t[1].replace(We, "'") : e;
1297
- }
1298
- function Ie(e, t) {
1299
- const n = D(e, t == null ? void 0 : t.in).getDay();
1300
- return n === 0 ? 7 : n;
1301
- }
1302
- function Ae(e, t, n = "long") {
1303
- return new Intl.DateTimeFormat("en-US", {
1304
- // Enforces engine to render the time. Without the option JavaScriptCore omits it.
1305
- hour: "numeric",
1306
- timeZone: e,
1307
- timeZoneName: n
1308
- }).format(t).split(/\s/g).slice(2).join(" ");
1309
- }
1310
- const G = {}, H = {};
1311
- function C(e, t) {
1312
- try {
1313
- const r = (G[e] || (G[e] = new Intl.DateTimeFormat("en-US", {
1314
- timeZone: e,
1315
- timeZoneName: "longOffset"
1316
- }).format))(t).split("GMT")[1];
1317
- return r in H ? H[r] : dt(r, r.split(":"));
1318
- } catch {
1319
- if (e in H) return H[e];
1320
- const n = e == null ? void 0 : e.match(He);
1321
- return n ? dt(e, n.slice(1)) : NaN;
1322
- }
1323
- }
1324
- const He = /([+-]\d\d):?(\d\d)?/;
1325
- function dt(e, t) {
1326
- const n = +(t[0] || 0), r = +(t[1] || 0), a = +(t[2] || 0) / 60;
1327
- return H[e] = n * 60 + r > 0 ? n * 60 + r + a : n * 60 - r - a;
1328
- }
1329
- class S extends Date {
1330
- //#region static
1331
- constructor(...t) {
1332
- super(), t.length > 1 && typeof t[t.length - 1] == "string" && (this.timeZone = t.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(C(this.timeZone, this)) ? this.setTime(NaN) : t.length ? typeof t[0] == "number" && (t.length === 1 || t.length === 2 && typeof t[1] != "number") ? this.setTime(t[0]) : typeof t[0] == "string" ? this.setTime(+new Date(t[0])) : t[0] instanceof Date ? this.setTime(+t[0]) : (this.setTime(+new Date(...t)), vt(this), K(this)) : this.setTime(Date.now());
1333
- }
1334
- static tz(t, ...n) {
1335
- return n.length ? new S(...n, t) : new S(Date.now(), t);
1336
- }
1337
- //#endregion
1338
- //#region time zone
1339
- withTimeZone(t) {
1340
- return new S(+this, t);
1341
- }
1342
- getTimezoneOffset() {
1343
- const t = -C(this.timeZone, this);
1344
- return t > 0 ? Math.floor(t) : Math.ceil(t);
1345
- }
1346
- //#endregion
1347
- //#region time
1348
- setTime(t) {
1349
- return Date.prototype.setTime.apply(this, arguments), K(this), +this;
1350
- }
1351
- //#endregion
1352
- //#region date-fns integration
1353
- [Symbol.for("constructDateFrom")](t) {
1354
- return new S(+new Date(t), this.timeZone);
1355
- }
1356
- //#endregion
1357
- }
1358
- const ft = /^(get|set)(?!UTC)/;
1359
- Object.getOwnPropertyNames(Date.prototype).forEach((e) => {
1360
- if (!ft.test(e)) return;
1361
- const t = e.replace(ft, "$1UTC");
1362
- S.prototype[t] && (e.startsWith("get") ? S.prototype[e] = function() {
1363
- return this.internal[t]();
1364
- } : (S.prototype[e] = function() {
1365
- return Date.prototype[t].apply(this.internal, arguments), Re(this), +this;
1366
- }, S.prototype[t] = function() {
1367
- return Date.prototype[t].apply(this, arguments), K(this), +this;
1368
- }));
1369
- });
1370
- function K(e) {
1371
- e.internal.setTime(+e), e.internal.setUTCSeconds(e.internal.getUTCSeconds() - Math.round(-C(e.timeZone, e) * 60));
1372
- }
1373
- function Re(e) {
1374
- Date.prototype.setFullYear.call(e, e.internal.getUTCFullYear(), e.internal.getUTCMonth(), e.internal.getUTCDate()), Date.prototype.setHours.call(e, e.internal.getUTCHours(), e.internal.getUTCMinutes(), e.internal.getUTCSeconds(), e.internal.getUTCMilliseconds()), vt(e);
1375
- }
1376
- function vt(e) {
1377
- const t = C(e.timeZone, e), n = t > 0 ? Math.floor(t) : Math.ceil(t), r = /* @__PURE__ */ new Date(+e);
1378
- r.setUTCHours(r.getUTCHours() - 1);
1379
- const a = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset(), s = -(/* @__PURE__ */ new Date(+r)).getTimezoneOffset(), i = a - s, o = Date.prototype.getHours.apply(e) !== e.internal.getUTCHours();
1380
- i && o && e.internal.setUTCMinutes(e.internal.getUTCMinutes() + i);
1381
- const c = a - n;
1382
- c && Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + c);
1383
- const h = /* @__PURE__ */ new Date(+e);
1384
- h.setUTCSeconds(0);
1385
- const m = a > 0 ? h.getSeconds() : (h.getSeconds() - 60) % 60, p = Math.round(-(C(e.timeZone, e) * 60)) % 60;
1386
- (p || m) && (e.internal.setUTCSeconds(e.internal.getUTCSeconds() + p), Date.prototype.setUTCSeconds.call(e, Date.prototype.getUTCSeconds.call(e) + p + m));
1387
- const w = C(e.timeZone, e), M = w > 0 ? Math.floor(w) : Math.ceil(w), y = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset() - M, Y = M !== n, nt = y - c;
1388
- if (Y && nt) {
1389
- Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + nt);
1390
- const j = C(e.timeZone, e), Ot = j > 0 ? Math.floor(j) : Math.ceil(j), Q = M - Ot;
1391
- Q && (e.internal.setUTCMinutes(e.internal.getUTCMinutes() + Q), Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + Q));
1392
- }
1393
- }
1394
- class x extends S {
1395
- //#region static
1396
- static tz(t, ...n) {
1397
- return n.length ? new x(...n, t) : new x(Date.now(), t);
1398
- }
1399
- //#endregion
1400
- //#region representation
1401
- toISOString() {
1402
- const [t, n, r] = this.tzComponents(), a = `${t}${n}:${r}`;
1403
- return this.internal.toISOString().slice(0, -1) + a;
1404
- }
1405
- toString() {
1406
- return `${this.toDateString()} ${this.toTimeString()}`;
1407
- }
1408
- toDateString() {
1409
- const [t, n, r, a] = this.internal.toUTCString().split(" ");
1410
- return `${t == null ? void 0 : t.slice(0, -1)} ${r} ${n} ${a}`;
1411
- }
1412
- toTimeString() {
1413
- const t = this.internal.toUTCString().split(" ")[4], [n, r, a] = this.tzComponents();
1414
- return `${t} GMT${n}${r}${a} (${Ae(this.timeZone, this)})`;
1415
- }
1416
- toLocaleString(t, n) {
1417
- return Date.prototype.toLocaleString.call(this, t, {
1418
- ...n,
1419
- timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
1420
- });
1421
- }
1422
- toLocaleDateString(t, n) {
1423
- return Date.prototype.toLocaleDateString.call(this, t, {
1424
- ...n,
1425
- timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
1426
- });
1427
- }
1428
- toLocaleTimeString(t, n) {
1429
- return Date.prototype.toLocaleTimeString.call(this, t, {
1430
- ...n,
1431
- timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
1432
- });
1433
- }
1434
- //#endregion
1435
- //#region private
1436
- tzComponents() {
1437
- const t = this.getTimezoneOffset(), n = t > 0 ? "-" : "+", r = String(Math.floor(Math.abs(t) / 60)).padStart(2, "0"), a = String(Math.abs(t) % 60).padStart(2, "0");
1438
- return [n, r, a];
1439
- }
1440
- //#endregion
1441
- withTimeZone(t) {
1442
- return new x(+this, t);
1443
- }
1444
- //#region date-fns integration
1445
- [Symbol.for("constructDateFrom")](t) {
1446
- return new x(+new Date(t), this.timeZone);
1447
- }
1448
- //#endregion
1449
- }
1450
- window.pktTz = window.pktTz === void 0 ? "Europe/Oslo" : window.pktTz;
1451
- const Ue = (e = window.pktTz) => {
1452
- const t = new x((/* @__PURE__ */ new Date()).toISOString(), e);
1453
- return t.setHours(0, 0, 0, 0), isNaN(t.getTime()) ? /* @__PURE__ */ new Date() : new Date(t.getFullYear(), t.getMonth(), t.getDate());
1454
- };
1455
- function O(e) {
1456
- if (!e || e === "") return /* @__PURE__ */ new Date();
1457
- if (/^\d{4}-\d{2}-\d{2}$/.test(e)) {
1458
- const [t, n, r] = e.split("-").map(Number);
1459
- return new Date(t, n - 1, r);
1460
- }
1461
- if (/^\d{4}-\d{2}$/.test(e)) {
1462
- const [t, n] = e.split("-").map(Number);
1463
- return new Date(t, n - 1, 1);
1464
- }
1465
- return /^\d{4}$/.test(e) ? new Date(Number(e), 0, 1) : new Date(e);
1466
- }
1467
- const g = (e) => {
1468
- if (!e || isNaN(e.getTime())) return "";
1469
- const t = e.getFullYear(), n = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0");
1470
- return `${t}-${n}-${r}`;
1471
- }, U = (e) => {
1472
- if (!e)
1473
- return null;
1474
- const t = O(e);
1475
- return isNaN(t.getTime()) ? null : t;
1476
- }, yn = (e, t) => {
1477
- const n = _(e);
1478
- return isNaN(n.getTime()) ? "" : Ye(n, t);
1479
- }, _ = (e = "", t) => {
1480
- const n = typeof e == "string" ? O(e) : e;
1481
- return !n || isNaN(n.getTime()) ? /* @__PURE__ */ new Date() : t ? t === "end" ? Ft(n) : J(n) : n;
1482
- }, $ = (e, t, n = 1) => {
1483
- if (typeof e != "number" || typeof t != "number" || typeof n != "number" || isNaN(e) || isNaN(t) || isNaN(n))
1484
- return /* @__PURE__ */ new Date();
1485
- const r = new Date(e, t, n);
1486
- return isNaN(r.getTime()) ? /* @__PURE__ */ new Date() : r;
1487
- }, A = (e) => {
1488
- let t;
1489
- return typeof e == "number" ? t = new x(e, window.pktTz) : t = new x(e, window.pktTz), t.setHours(12, 0, 0, 0), t;
1490
- };
1491
- let V = null, mt;
1492
- const Le = (e) => {
1493
- if (!e || isNaN(e.getTime())) return "";
1494
- const t = typeof window < "u" ? window.pktTz : void 0;
1495
- return (!V || mt !== t) && (V = new Intl.DateTimeFormat("no", { dateStyle: "full", timeZone: t }), mt = t), V.format(e);
1496
- }, Be = (e, t, n) => {
1497
- if (!e || isNaN(e.getTime())) return !1;
1498
- const r = t ? _(t) : null, a = n ? _(n) : null;
1499
- return !(r && e < r || a && e > a);
1500
- }, qe = (e, t) => {
1501
- if (!e || isNaN(e.getTime()) || !Array.isArray(t)) return !1;
1502
- const n = g(e);
1503
- return t.includes(n);
1504
- }, ze = (e, t) => {
1505
- if (!e || isNaN(e.getTime()) || !Array.isArray(t)) return !1;
1506
- const n = e.getDay().toString();
1507
- return t.includes(n);
1508
- }, Mt = (e, t, n, r, a) => !(!e || isNaN(e.getTime()) || !Be(e, t, n) || r && qe(e, r) || a && ze(e, a)), pn = (e, t, n, r, a) => e.filter((s) => {
1509
- const i = U(s);
1510
- return i && Mt(i, t, n, r, a);
1511
- }), wn = (e) => e.slice().sort((t, n) => {
1512
- const r = U(t), a = U(n);
1513
- return !r || !a ? 0 : r.getTime() - a.getTime();
1514
- }), bn = (e, t) => {
1515
- const n = U(e), r = U(t);
1516
- return !n || !r ? !1 : n <= r;
1517
- }, je = (e) => {
1518
- if (!e) return [];
1519
- if (Array.isArray(e)) return e.filter(Boolean);
1520
- if (typeof e == "string" && e.trimStart().startsWith("["))
1521
- try {
1522
- const t = JSON.parse(e);
1523
- if (Array.isArray(t))
1524
- return t.filter(Boolean);
1525
- } catch {
1526
- }
1527
- return String(e).split(",").map((t) => t.trim()).filter(Boolean);
1528
- }, Dn = (e) => e.join(","), Qe = (e) => je(e), Xe = (e) => e ? O(e) : null, Ge = (e) => {
1529
- if (typeof e == "string")
1530
- return e.split(",").map((t) => O(t));
1531
- if (Array.isArray(e))
1532
- return e.map((t) => O(t));
1533
- }, z = {
1534
- csvToArray: Qe,
1535
- stringToDate: Xe,
1536
- stringsToDate: Ge
1537
- }, Ve = { earliest: { default: null }, latest: { default: null }, weeknumbers: { default: !1 }, withcontrols: { default: !1 }, multiple: { default: !1 }, maxMultiple: { default: 4 }, range: { default: !1 } }, P = {
1538
- props: Ve
1539
- };
1540
- function Tt(e, t) {
1541
- const n = (t.excludedates ?? []).map(
1542
- (r) => typeof r == "string" ? r : g(r)
1543
- );
1544
- return !Mt(
1545
- e,
1546
- t.earliest,
1547
- t.latest,
1548
- n,
1549
- t.excludeweekdays ?? []
1550
- );
1551
- }
1552
- function Je(e, t, n, r) {
1553
- return !!(Tt(e, n) || !t && r.multiple && r.maxMultiple > 0 && r.selectedCount >= r.maxMultiple);
1554
- }
1555
- function Ke(e, t, n) {
1556
- const r = $(e, t, 0);
1557
- return !(n && _(n) > r);
1558
- }
1559
- function Ze(e, t, n) {
1560
- const r = $(
1561
- t === 11 ? e + 1 : e,
1562
- t === 11 ? 0 : t + 1,
1563
- 1
1564
- );
1565
- return !(n && _(n) < r);
1566
- }
1567
- const L = 7, tn = 6;
1568
- function en(e, t) {
1569
- const n = $(e, t, 1), r = $(e, t + 1, 0), a = (n.getDay() + tn) % L, s = r.getDate(), i = Math.ceil((s + a) / L), c = $(e, t, 0).getDate(), h = kt(n);
1570
- return {
1571
- firstDayOfMonth: n,
1572
- lastDayOfMonth: r,
1573
- startingDay: a,
1574
- numDays: s,
1575
- numRows: i,
1576
- numDaysPrevMonth: c,
1577
- initialWeek: h
1578
- };
1579
- }
1580
- function nn(e, t, n, r) {
1581
- const { startingDay: a, numDays: s } = r;
1582
- return e === 0 && t < a ? "prev-month" : n > s ? "next-month" : "current-month";
1583
- }
1584
- function rn(e, t, n, r) {
1585
- const { startingDay: a, numDaysPrevMonth: s, numDays: i } = r;
1586
- return e === "prev-month" ? s - (a - t - 1) : e === "next-month" ? n - i : n;
1587
- }
1588
- function W(e) {
1589
- return typeof e == "string" && (e = e.split(",")), e.length === 1 && e[0] === "" ? [] : e.map((t) => O(t));
1590
- }
1591
- function gt(e, t) {
1592
- const n = bt({ start: e, end: t }), r = {};
1593
- if (Array.isArray(n) && n.length)
1594
- for (let a = 0; a < n.length; a++) {
1595
- const s = n[a], i = s > e && s < t;
1596
- r[g(s)] = i;
1597
- }
1598
- return r;
1599
- }
1600
- function xt(e, t, n, r) {
1601
- if (t.length !== 1) return !0;
1602
- const a = bt({
1603
- start: t[0],
1604
- end: e
1605
- });
1606
- if (!Array.isArray(a) || !a.length) return !0;
1607
- for (let s = 0; s < a.length; s++) {
1608
- for (const i of n ?? [])
1609
- if (i > t[0] && i < e)
1610
- return !1;
1611
- if ((r ?? []).includes(Ie(a[s]).toString()))
1612
- return !1;
1613
- }
1614
- return !0;
1615
- }
1616
- function tt(e, t) {
1617
- const n = g(e);
1618
- return t.includes(n) ? t : [...t, n];
1619
- }
1620
- function et(e, t) {
1621
- const n = g(e), r = t.indexOf(n);
1622
- if (r === -1) return t;
1623
- if (t.length === 1) return [];
1624
- const a = [...t];
1625
- return a.splice(r, 1), a;
1626
- }
1627
- function an(e, t, n) {
1628
- const r = g(e);
1629
- return t.includes(r) ? et(e, t) : n > 0 && t.length >= n ? t : tt(e, t);
1630
- }
1631
- function sn(e, t, n) {
1632
- const r = g(e), a = W(t);
1633
- if (t.includes(r))
1634
- return t.indexOf(r) === 0 ? [] : et(e, t);
1635
- if (t.length > 1)
1636
- return [r];
1637
- if (t.length === 1) {
1638
- if (!xt(e, a, n.excludedates, n.excludeweekdays))
1639
- return [r];
1640
- if (a[0] > e)
1641
- return [r];
1642
- }
1643
- return tt(e, t);
1644
- }
1645
- const on = {
1646
- ArrowLeft: -1,
1647
- ArrowRight: 1,
1648
- ArrowUp: -L,
1649
- ArrowDown: L
1650
- };
1651
- function cn(e) {
1652
- var n;
1653
- const t = e.nodeName;
1654
- return t === "INPUT" || t === "SELECT" || t === "BUTTON" && !((n = e.dataset) != null && n.date);
1655
- }
1656
- function un(e, t, n) {
1657
- let r = it(e, t);
1658
- if (!r) return null;
1659
- let a = n(`button[data-date="${g(r)}"]`);
1660
- for (; a instanceof HTMLButtonElement && a.dataset.disabled; )
1661
- if (r = it(r, t), a = n(`button[data-date="${g(r)}"]`), !a) return null;
1662
- return r;
1663
- }
1664
- function ln(e) {
1665
- return on[e] ?? null;
1666
- }
1667
- var hn = Object.defineProperty, d = (e, t, n, r) => {
1668
- for (var a = void 0, s = e.length - 1, i; s >= 0; s--)
1669
- (i = e[s]) && (a = i(t, n, a) || a);
1670
- return a && hn(t, n, a), a;
1671
- };
1672
- class l extends Nt {
1673
- constructor() {
1674
- super(...arguments), this.selected = [], this.multiple = P.props.multiple.default, this.maxMultiple = P.props.maxMultiple.default, this.range = P.props.range.default, this.earliest = P.props.earliest.default, this.latest = P.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.weeknumbers = P.props.weeknumbers.default, this.withcontrols = P.props.withcontrols.default, this.currentmonth = null, this.today = 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;
1675
- }
1676
- get todayDate() {
1677
- return this.today ? O(this.today) : Ue();
1678
- }
1679
- /**
1680
- * Lifecycle methods
1681
- */
1682
- firstUpdated(t) {
1683
- this.addEventListener("keydown", this.handleKeydown);
1684
- }
1685
- disconnectedCallback() {
1686
- this.removeEventListener("keydown", this.handleKeydown), super.disconnectedCallback();
1687
- }
1688
- updated(t) {
1689
- super.updated(t), t.has("selected") && this.convertSelected();
1690
- }
1691
- /**
1692
- * Date and selection management
1693
- */
1694
- convertSelected() {
1695
- 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 = gt(this._selected[0], this._selected[1])), this.setCurrentMonth();
1696
- }
1697
- setCurrentMonth() {
1698
- if (this.currentmonth === null && !this.currentmonthtouched && (this.currentmonthtouched = !0), this.selected.length && this.selected[0] !== "") {
1699
- const t = O(this.selected[this.selected.length - 1]);
1700
- this.currentmonth = isNaN(t.getTime()) ? A(this.todayDate) : t;
1701
- } else this.currentmonth === null && (this.currentmonth = A(this.todayDate));
1702
- (!this.currentmonth || isNaN(this.currentmonth.getTime())) && (this.currentmonth = A(this.todayDate)), this.year = this.currentmonth.getFullYear(), this.month = this.currentmonth.getMonth();
1703
- }
1704
- /**
1705
- * Keyboard navigation
1706
- */
1707
- handleKeydown(t) {
1708
- const n = ln(t.key);
1709
- n !== null && this.handleArrowKey(t, n);
1710
- }
1711
- handleArrowKey(t, n) {
1712
- const r = t.target;
1713
- if (cn(r)) return;
1714
- if (t.preventDefault(), !this.focusedDate) {
1715
- this.focusOnCurrentDate();
1716
- return;
1717
- }
1718
- const a = this.focusedDate ? _(this.focusedDate) : $(this.year, this.month, 1), s = un(a, n, this.querySelector.bind(this));
1719
- if (s) {
1720
- const i = this.querySelector(`button[data-date="${g(s)}"]`);
1721
- i instanceof HTMLButtonElement && !i.dataset.disabled && (this.focusedDate = g(s), i.focus());
1722
- }
1723
- }
1724
- /**
1725
- * Rendering methods
1726
- */
1727
- render() {
1728
- return k`
1729
- <div
1730
- class="pkt-calendar ${this.weeknumbers ? "pkt-cal-weeknumbers" : ""}"
1731
- @focusout=${this.closeEvent}
1732
- @keydown=${(t) => {
1733
- t.key === "Escape" && (t.preventDefault(), this.close());
1734
- }}
1735
- >
1736
- <nav class="pkt-cal-month-nav">
1737
- ${this.renderMonthNavButton("prev")}
1738
- ${this.renderMonthNav()}
1739
- ${this.renderMonthNavButton("next")}
1740
- </nav>
1741
- <table
1742
- class="pkt-cal-days pkt-txt-12-medium pkt-calendar__body"
1743
- role="grid"
1744
- ?aria-multiselectable=${this.range || this.multiple}
1745
- >
1746
- <thead>
1747
- ${this.renderDayNames()}
1748
- </thead>
1749
- <tbody>
1750
- ${this.renderCalendarBody()}
1751
- </tbody>
1752
- </table>
1753
- </div>
1754
- `;
1755
- }
1756
- renderMonthNavButton(t) {
1757
- const n = t === "prev", r = n ? this.isPrevMonthAllowed() : this.isNextMonthAllowed(), a = n ? this.prevMonthString : this.nextMonthString, s = n ? "chevron-thin-left" : "chevron-thin-right", i = n ? "pkt-calendar__prev-month" : "pkt-calendar__next-month", o = n ? () => this.prevMonth() : () => this.nextMonth();
1758
- return k`<div>
1759
- <button
1760
- type="button"
1761
- aria-label="${a}"
1762
- @click=${() => r && o()}
1763
- @keydown=${(c) => {
1764
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), r && o());
1765
- }}
1766
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${i} ${r ? "" : "pkt-invisible"}"
1767
- .data-disabled=${r ? at : "disabled"}
1768
- ?aria-disabled=${!r}
1769
- tabindex=${r ? "0" : "-1"}
1770
- >
1771
- <pkt-icon class="pkt-btn__icon" name="${s}"></pkt-icon>
1772
- <span class="pkt-btn__text">${a}</span>
1773
- </button>
1774
- </div>`;
1775
- }
1776
- renderDayNames() {
1777
- const t = [];
1778
- this.weeknumbers && t.push(k`<th><div class="pkt-calendar__week-number">${this.weekString}</div></th>`);
1779
- for (let n = 0; n < this.dayStrings.length; n++)
1780
- t.push(
1781
- k`<th>
1782
- <div class="pkt-calendar__day-name" aria-label="${this.dayStringsLong[n]}">
1783
- ${this.dayStrings[n]}
1784
- </div>
1785
- </th>`
1786
- );
1787
- return k`<tr class="pkt-cal-week-row">${t}</tr>`;
1788
- }
1789
- renderMonthNav() {
1790
- return this.withcontrols ? k`<div class="pkt-cal-month-picker">
1791
- <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
1792
- <select
1793
- aria-label="${this.strings.dates.month}"
1794
- class="pkt-input pkt-input-compact"
1795
- id="${this.id}-monthnav"
1796
- @change=${(t) => {
1797
- t.stopImmediatePropagation();
1798
- const n = t.target;
1799
- this.changeMonth(this.year, parseInt(n.value));
1800
- }}
1801
- >
1802
- ${this.monthStrings.map(
1803
- (t, n) => k`<option value=${n} ?selected=${this.month === n}>${t}</option>`
1804
- )}
1805
- </select>
1806
- <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
1807
- <input
1808
- aria-label="${this.strings.dates.year}"
1809
- class="pkt-input pkt-cal-input-year pkt-input-compact"
1810
- id="${this.id}-yearnav"
1811
- type="number"
1812
- size="4"
1813
- placeholder="0000"
1814
- @change=${(t) => {
1815
- t.stopImmediatePropagation();
1816
- const n = t.target;
1817
- this.changeMonth(parseInt(n.value), this.month);
1818
- }}
1819
- .value=${this.year}
1820
- />
1821
- </div>` : k`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
1822
- ${this.monthStrings[this.month]} ${this.year}
1823
- </div>`;
1824
- }
1825
- getDayViewData(t, n) {
1826
- const r = $(this.year, this.month, t), a = g(r), s = a === g(n), i = this.selected.includes(a), o = this.isDayDisabled(r, i), c = this.calculateTabIndex(a, o, t);
1827
- return {
1828
- currentDate: r,
1829
- currentDateISO: a,
1830
- isToday: s,
1831
- isSelected: i,
1832
- isDisabled: o,
1833
- ariaLabel: Le(r),
1834
- tabindex: c
1835
- };
1836
- }
1837
- getDateConstraints() {
1838
- return {
1839
- earliest: this.earliest,
1840
- latest: this.latest,
1841
- excludedates: this.excludedates,
1842
- excludeweekdays: this.excludeweekdays
1843
- };
1844
- }
1845
- isDayDisabled(t, n) {
1846
- return Je(t, n, this.getDateConstraints(), {
1847
- multiple: this.multiple,
1848
- maxMultiple: this.maxMultiple,
1849
- selectedCount: this.selected.length
1850
- });
1851
- }
1852
- calculateTabIndex(t, n, r) {
1853
- return this.focusedDate ? this.focusedDate === t && !n ? "0" : "-1" : !n && this.tabIndexSet === 0 ? (this.tabIndexSet = r, "0") : this.tabIndexSet === r ? "0" : "-1";
1854
- }
1855
- getDayCellClasses(t) {
1856
- const { currentDateISO: n, isToday: r, isSelected: a } = t, s = this.range && (this.selected.length === 2 || this.rangeHovered !== null) && n === this.selected[0], i = this.range && this.selected.length === 2 && n === this.selected[1];
1857
- return {
1858
- "pkt-cal-today": r,
1859
- "pkt-cal-selected": a,
1860
- "pkt-cal-in-range": this.inRange[n],
1861
- "pkt-cal-excluded": this.isExcluded(t.currentDate),
1862
- "pkt-cal-in-range-first": s,
1863
- "pkt-cal-in-range-last": i,
1864
- "pkt-cal-range-hover": this.rangeHovered !== null && n === g(this.rangeHovered)
1865
- };
1866
- }
1867
- getDayButtonClasses(t) {
1868
- const { currentDateISO: n, isToday: r, isSelected: a, isDisabled: s } = t, i = this.range && (this.selected.length === 2 || this.rangeHovered !== null) && n === this.selected[0], o = this.range && this.selected.length === 2 && n === this.selected[1];
1869
- return {
1870
- "pkt-calendar__date": !0,
1871
- "pkt-calendar__date--today": r,
1872
- "pkt-calendar__date--selected": a,
1873
- "pkt-calendar__date--disabled": s,
1874
- "pkt-calendar__date--in-range": this.inRange[n],
1875
- "pkt-calendar__date--in-range-hover": this.rangeHovered !== null && n === g(this.rangeHovered),
1876
- "pkt-calendar__date--range-start": i,
1877
- "pkt-calendar__date--range-end": o
1878
- };
1879
- }
1880
- handleDayFocus(t, n) {
1881
- this.range && !this.isExcluded(t) && this.handleRangeHover(t), this.focusedDate = n;
1882
- }
1883
- renderDayView(t, n) {
1884
- const r = this.getDayViewData(t, n), { currentDate: a, currentDateISO: s, isSelected: i, isDisabled: o, ariaLabel: c, tabindex: h } = r;
1885
- this.selectableDates.push({ currentDateISO: s, isDisabled: o, tabindex: h });
1886
- const m = this.getDayCellClasses(r), p = this.getDayButtonClasses(r);
1887
- return k`<td class=${rt(m)}>
1888
- <button
1889
- type="button"
1890
- aria-pressed=${i ? "true" : "false"}
1891
- ?disabled=${o}
1892
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only ${rt(p)}"
1893
- @mouseover=${() => this.range && !this.isExcluded(a) && this.handleRangeHover(a)}
1894
- @focus=${() => this.handleDayFocus(a, s)}
1895
- aria-label="${c}"
1896
- tabindex=${h}
1897
- data-disabled=${o ? "disabled" : at}
1898
- data-date=${s}
1899
- @keydown=${(w) => {
1900
- (w.key === "Enter" || w.key === " ") && (w.preventDefault(), this.handleDateSelect(a));
1901
- }}
1902
- @click=${(w) => {
1903
- o || (w.preventDefault(), this.handleDateSelect(a));
1904
- }}
1905
- >
1906
- <span class="pkt-btn__text pkt-txt-14-light">${t}</span>
1907
- </button>
1908
- </td>`;
1909
- }
1910
- renderEmptyDayCell(t) {
1911
- return k`<td class="pkt-cal-other">
1912
- <div
1913
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
1914
- data-disabled="disabled"
1915
- >
1916
- <span class="pkt-btn__text pkt-txt-14-light">${t}</span>
1917
- </div>
1918
- </td>`;
1919
- }
1920
- renderWeekRow(t) {
1921
- return k`<tr class="pkt-cal-week-row" role="row">${t}</tr>`;
1922
- }
1923
- renderCalendarBody() {
1924
- const t = this.todayDate, n = en(this.year, this.month);
1925
- this.selectableDates = [], this.tabIndexSet = 0;
1926
- let r = 1;
1927
- this.week = n.initialWeek;
1928
- const a = [];
1929
- for (let s = 0; s < n.numRows; s++) {
1930
- const i = [];
1931
- this.weeknumbers && i.push(k`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
1932
- for (let o = 0; o < L; o++) {
1933
- const c = nn(s, o, r, n);
1934
- if (c === "current-month")
1935
- i.push(this.renderDayView(r, t)), r++;
1936
- else {
1937
- const h = rn(c, o, r, n);
1938
- i.push(this.renderEmptyDayCell(h)), c === "next-month" && r++;
1939
- }
1940
- }
1941
- a.push(this.renderWeekRow(i));
1942
- }
1943
- return a;
1944
- }
1945
- /**
1946
- * Date validation
1947
- */
1948
- isExcluded(t) {
1949
- return Tt(t, this.getDateConstraints());
1950
- }
1951
- /**
1952
- * Month navigation
1953
- */
1954
- isPrevMonthAllowed() {
1955
- return Ke(this.year, this.month, this.earliest);
1956
- }
1957
- prevMonth() {
1958
- const t = this.month === 0 ? 11 : this.month - 1, n = this.month === 0 ? this.year - 1 : this.year;
1959
- this.changeMonth(n, t);
1960
- }
1961
- isNextMonthAllowed() {
1962
- return Ze(this.year, this.month, this.latest);
1963
- }
1964
- nextMonth() {
1965
- const t = this.month === 11 ? 0 : this.month + 1, n = this.month === 11 ? this.year + 1 : this.year;
1966
- this.changeMonth(n, t);
1967
- }
1968
- changeMonth(t, n) {
1969
- this.year = typeof t == "string" ? parseInt(t) : t, this.month = typeof n == "string" ? parseInt(n) : n, this.currentmonth = A(new Date(this.year, this.month, 1)), this.tabIndexSet = 0, this.focusedDate = null, this.selectableDates = [];
1970
- }
1971
- /**
1972
- * Date selection logic
1973
- */
1974
- emptySelected() {
1975
- this.selected = [], this._selected = [], this.inRange = {};
1976
- }
1977
- normalizeSelected() {
1978
- return typeof this.selected == "string" ? this.selected.split(",") : this.selected;
1979
- }
1980
- addToSelected(t) {
1981
- this.selected = tt(t, this.normalizeSelected()), this._selected = W(this.selected), this.range && this.selected.length === 2 && (this.convertSelected(), this.close());
1982
- }
1983
- removeFromSelected(t) {
1984
- this.selected = et(t, this.normalizeSelected()), this._selected = W(this.selected);
1985
- }
1986
- toggleSelected(t) {
1987
- this.selected = an(t, this.normalizeSelected(), this.maxMultiple), this._selected = W(this.selected);
1988
- }
1989
- isRangeAllowed(t) {
1990
- return xt(t, this._selected, this.excludedates, this.excludeweekdays);
1991
- }
1992
- handleRangeSelect(t) {
1993
- return this.selected = sn(t, this.normalizeSelected(), {
1994
- excludedates: this.excludedates,
1995
- excludeweekdays: this.excludeweekdays
1996
- }), this._selected = W(this.selected), this.selected.length === 2 ? (this.convertSelected(), this.close()) : this.selected.length === 1 && (this.inRange = {}), Promise.resolve();
1997
- }
1998
- handleRangeHover(t) {
1999
- if (!this.range || this._selected.length !== 1 || !this.isRangeAllowed(t) || this._selected[0] >= t) {
2000
- this.rangeHovered = null;
2001
- return;
2002
- }
2003
- this.rangeHovered = t, this.inRange = gt(this._selected[0], t);
2004
- }
2005
- handleDateSelect(t) {
2006
- return t && (this.range ? this.handleRangeSelect(t) : this.multiple ? this.toggleSelected(t) : (this.selected.includes(g(t)) ? this.emptySelected() : (this.emptySelected(), this.addToSelected(t)), this.close()), this.dispatchEvent(
2007
- new CustomEvent("date-selected", {
2008
- detail: this.selected,
2009
- bubbles: !0,
2010
- composed: !0
2011
- })
2012
- )), Promise.resolve();
2013
- }
2014
- /**
2015
- * Focus management and event handlers
2016
- */
2017
- focusOnCurrentDate() {
2018
- const t = g(A(this.todayDate)), n = this.querySelector(`button[data-date="${t}"]`);
2019
- if (n instanceof HTMLButtonElement) {
2020
- this.focusedDate = t, n.focus();
2021
- return;
2022
- }
2023
- const r = this.selectableDates.find((a) => !a.isDisabled);
2024
- if (r) {
2025
- const a = this.querySelector(
2026
- `button[data-date="${r.currentDateISO}"]`
2027
- );
2028
- a instanceof HTMLButtonElement && (this.focusedDate = r.currentDateISO, a.focus());
2029
- }
2030
- }
2031
- closeEvent(t) {
2032
- !this.contains(t.relatedTarget) && !t.target.classList.contains("pkt-invisible") && this.close();
2033
- }
2034
- close() {
2035
- this.dispatchEvent(
2036
- new CustomEvent("close", {
2037
- detail: !0,
2038
- bubbles: !0,
2039
- composed: !0
2040
- })
2041
- );
2042
- }
2043
- }
2044
- d([
2045
- f({ converter: z.csvToArray })
2046
- ], l.prototype, "selected");
2047
- d([
2048
- f({ type: Boolean })
2049
- ], l.prototype, "multiple");
2050
- d([
2051
- f({ type: Number, attribute: "max-multiple" })
2052
- ], l.prototype, "maxMultiple");
2053
- d([
2054
- f({ type: Boolean })
2055
- ], l.prototype, "range");
2056
- d([
2057
- f({ type: String })
2058
- ], l.prototype, "earliest");
2059
- d([
2060
- f({ type: String })
2061
- ], l.prototype, "latest");
2062
- d([
2063
- f({ converter: z.stringsToDate })
2064
- ], l.prototype, "excludedates");
2065
- d([
2066
- f({ converter: z.csvToArray })
2067
- ], l.prototype, "excludeweekdays");
2068
- d([
2069
- f({ type: Boolean })
2070
- ], l.prototype, "weeknumbers");
2071
- d([
2072
- f({ type: Boolean })
2073
- ], l.prototype, "withcontrols");
2074
- d([
2075
- f({ converter: z.stringToDate })
2076
- ], l.prototype, "currentmonth");
2077
- d([
2078
- f({ type: String })
2079
- ], l.prototype, "today");
2080
- d([
2081
- f({ type: Array, attribute: "day-strings" })
2082
- ], l.prototype, "dayStrings");
2083
- d([
2084
- f({ type: Array, attribute: "day-strings-long" })
2085
- ], l.prototype, "dayStringsLong");
2086
- d([
2087
- f({ type: Array, attribute: "month-strings" })
2088
- ], l.prototype, "monthStrings");
2089
- d([
2090
- f({ type: String, attribute: "week-string" })
2091
- ], l.prototype, "weekString");
2092
- d([
2093
- f({ type: String, attribute: "prev-month-string" })
2094
- ], l.prototype, "prevMonthString");
2095
- d([
2096
- f({ type: String, attribute: "next-month-string" })
2097
- ], l.prototype, "nextMonthString");
2098
- d([
2099
- f({ type: Array })
2100
- ], l.prototype, "_selected");
2101
- d([
2102
- Z()
2103
- ], l.prototype, "inRange");
2104
- d([
2105
- f({ type: Date })
2106
- ], l.prototype, "rangeHovered");
2107
- d([
2108
- f({ type: Number })
2109
- ], l.prototype, "year");
2110
- d([
2111
- f({ type: Number })
2112
- ], l.prototype, "month");
2113
- d([
2114
- f({ type: Number })
2115
- ], l.prototype, "week");
2116
- d([
2117
- Z()
2118
- ], l.prototype, "currentmonthtouched");
2119
- d([
2120
- Z()
2121
- ], l.prototype, "focusedDate");
2122
- try {
2123
- Pt("pkt-calendar")(l);
2124
- } catch {
2125
- console.warn("Forsøker å definere <pkt-calendar>, men den er allerede definert");
2126
- }
2127
- export {
2128
- l as P,
2129
- pn as a,
2130
- U as b,
2131
- g as c,
2132
- Dn as d,
2133
- z as e,
2134
- yn as f,
2135
- bn as i,
2136
- _ as n,
2137
- O as p,
2138
- wn as s,
2139
- je as v
2140
- };