@featherk/composables 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,119 +1,127 @@
1
- import { ref as _, onBeforeUnmount as Ie, nextTick as N, computed as h, watch as ve, onMounted as xe, readonly as K, getCurrentScope as Le, onScopeDispose as Pe, toValue as ce, unref as Te, shallowRef as Re } from "vue";
1
+ import { ref as _, onBeforeUnmount as Te, nextTick as j, computed as h, watch as ve, onMounted as xe, readonly as N, getCurrentScope as Le, onScopeDispose as Pe, toValue as ce, unref as Fe, shallowRef as Re } from "vue";
2
2
  import { useFocusTrap as qe } from "@vueuse/integrations/useFocusTrap";
3
- const We = (e) => {
4
- const t = _(null);
5
- let c = !1, P = null, T = null;
6
- const V = [], W = ".k-table-row[data-grid-row-index] [tabindex]", k = () => e?.value?.columns, b = (o) => {
7
- const m = o.key || o.code;
8
- [" ", "Spacebar", "Space", "Enter"].includes(m) && (o.preventDefault(), o.stopPropagation(), t.value = o.target, o.target.click());
9
- }, y = (o) => {
10
- if (!t.value) return;
3
+ const _e = (e, t) => {
4
+ const u = _(null);
5
+ let q = !1, I = null, L = null;
6
+ const V = [], A = ".k-table-row[data-grid-row-index] [tabindex]", k = () => e?.value?.columns, S = (o) => {
7
+ const p = o.key || o.code;
8
+ [" ", "Spacebar", "Space", "Enter"].includes(p) && (o.preventDefault(), o.stopPropagation(), u.value = o.target, o.target.click());
9
+ }, g = (o) => {
10
+ if (!u.value) return;
11
11
  if (o.code === "Escape") {
12
- o.preventDefault(), o.stopPropagation(), t.value && t.value.focus();
12
+ o.stopPropagation(), u.value && u.value.focus();
13
13
  return;
14
14
  }
15
- const m = Array.from(
15
+ const p = Array.from(
16
16
  document.querySelectorAll(
17
17
  ".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"
18
18
  )
19
- ), l = document.querySelector(".k-filter-menu-container");
19
+ ), l = document.querySelector(
20
+ ".k-animation-container .k-popup .k-column-menu .k-filter-menu-container"
21
+ );
20
22
  if (l) {
21
23
  if (o.code === "Tab") {
22
- const i = [
24
+ const s = [
23
25
  ".k-filter-menu-container .k-dropdownlist[tabindex='0']",
24
26
  ".k-filter-menu-container input.k-input-inner:not([tabindex='-1']):not([disabled])",
25
- ".k-filter-menu-container button:not([tabindex='-1']):not([disabled])"
26
- ], p = Array.from(
27
- l.querySelectorAll(i.join(","))
27
+ ".k-filter-menu-container button:not([tabindex='-1']):not([disabled])",
28
+ ".k-checkbox"
29
+ ], v = t?.focusableMenuSelectors ?? s, b = Array.from(
30
+ l.querySelectorAll(v.join(","))
28
31
  );
29
- if (p.length === 0) return;
30
- const A = p.findIndex(
31
- (I) => I === document.activeElement
32
+ if (b.length === 0) return;
33
+ const D = b.findIndex(
34
+ (H) => H === document.activeElement
32
35
  );
33
- let S;
34
- A === -1 ? S = 0 : o.shiftKey ? S = (A - 1 + p.length) % p.length : S = (A + 1) % p.length, o.preventDefault(), o.stopPropagation(), p[S]?.focus();
35
- return;
36
+ let $;
37
+ D === -1 ? $ = 0 : o.shiftKey ? $ = (D - 1 + b.length) % b.length : $ = (D + 1) % b.length, o.preventDefault(), o.stopPropagation(), b[$]?.focus();
36
38
  }
37
39
  } else if (o.code === "ArrowUp" || o.code === "ArrowDown") {
38
40
  o.preventDefault(), o.stopPropagation();
39
- const i = m.findIndex(
40
- (A) => A === document.activeElement
41
+ const s = p.findIndex(
42
+ (b) => b === document.activeElement
41
43
  );
42
- let p = i;
43
- o.code === "ArrowUp" ? p = i > 0 ? i - 1 : m.length - 1 : o.code === "ArrowDown" && (p = i < m.length - 1 ? i + 1 : 0), m[p]?.focus();
44
+ let v = s;
45
+ o.code === "ArrowUp" ? v = s > 0 ? s - 1 : p.length - 1 : o.code === "ArrowDown" && (v = s < p.length - 1 ? s + 1 : 0), p[v]?.focus();
44
46
  return;
45
47
  }
46
- o.code === "Tab" && (o.preventDefault(), o.stopPropagation(), o.shiftKey ? (t.value?.previousElementSibling).focus() : (t.value?.nextElementSibling).focus());
47
- }, w = () => {
48
- P = new MutationObserver((o) => {
49
- o.forEach((m) => {
50
- m.addedNodes.forEach((l) => {
48
+ if (o.code === "Tab") {
49
+ o.preventDefault(), o.stopPropagation();
50
+ const s = u.value?.parentElement;
51
+ (o.shiftKey ? s?.previousElementSibling : s?.nextElementSibling)?.querySelector(
52
+ "button, [role='button'], .k-link"
53
+ )?.focus();
54
+ }
55
+ }, P = () => {
56
+ I = new MutationObserver((o) => {
57
+ o.forEach((p) => {
58
+ p.addedNodes.forEach((l) => {
51
59
  if (l.nodeType === Node.ELEMENT_NODE) {
52
- const i = l;
53
- if (i.classList.contains("k-animation-container")) {
54
- const A = t.value;
55
- A && (A.dataset.featherKSortable === "true" || N(() => {
56
- i.querySelectorAll(
60
+ const s = l;
61
+ if (s.classList.contains("k-animation-container")) {
62
+ const b = u.value;
63
+ b && (b.dataset.featherKSortable === "true" || j(() => {
64
+ s.querySelectorAll(
57
65
  ".k-columnmenu-item-wrapper"
58
- ).forEach((G) => {
59
- G.textContent?.toLowerCase().includes("sort") && G.remove();
66
+ ).forEach((H) => {
67
+ H.textContent?.toLowerCase().includes("sort") && H.remove();
60
68
  });
61
- })), i.addEventListener(
69
+ })), s.addEventListener(
62
70
  "keydown",
63
- y
64
- ), N(() => {
65
- const S = () => {
66
- const I = Array.from(
67
- i.querySelectorAll(
71
+ g
72
+ ), j(() => {
73
+ const D = () => {
74
+ const $ = Array.from(
75
+ s.querySelectorAll(
68
76
  ".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"
69
77
  )
70
78
  );
71
- if (I.length === 1)
72
- I[0].focus(), I[0].click(), S.attempts = 0;
73
- else if (I.length > 1) {
74
- S.attempts = 0;
79
+ if ($.length === 1)
80
+ $[0].focus(), $[0].click(), D.attempts = 0;
81
+ else if ($.length > 1) {
82
+ D.attempts = 0;
75
83
  return;
76
84
  } else
77
- S.attempts === void 0 && (S.attempts = 0), S.attempts++ < 3 && setTimeout(S, 200);
85
+ D.attempts === void 0 && (D.attempts = 0), D.attempts++ < 3 && setTimeout(D, 200);
78
86
  };
79
- S();
87
+ D();
80
88
  });
81
89
  }
82
- i.querySelectorAll(
90
+ s.querySelectorAll(
83
91
  ".k-animation-container"
84
- ).forEach((A) => {
85
- A.addEventListener(
92
+ ).forEach((b) => {
93
+ b.addEventListener(
86
94
  "keydown",
87
- y
95
+ g
88
96
  );
89
97
  });
90
98
  }
91
- }), m.removedNodes.forEach((l) => {
99
+ }), p.removedNodes.forEach((l) => {
92
100
  if (l.nodeType === Node.ELEMENT_NODE) {
93
- const i = l;
94
- i.classList.contains("k-animation-container") && i.removeEventListener(
101
+ const s = l;
102
+ s.classList.contains("k-animation-container") && s.removeEventListener(
95
103
  "keydown",
96
- y
97
- ), i.querySelectorAll(
104
+ g
105
+ ), s.querySelectorAll(
98
106
  ".k-animation-container"
99
- ).forEach((A) => {
100
- A.removeEventListener(
107
+ ).forEach((b) => {
108
+ b.removeEventListener(
101
109
  "keydown",
102
- y
110
+ g
103
111
  );
104
112
  });
105
113
  }
106
114
  });
107
115
  });
108
- }), P.observe(document.body, {
116
+ }), I.observe(document.body, {
109
117
  childList: !0,
110
118
  subtree: !0
111
119
  });
112
- }, L = (o) => {
120
+ }, E = (o) => {
113
121
  if (!o.type || !o)
114
122
  return;
115
- const m = o.target;
116
- if (m) {
123
+ const p = o.target;
124
+ if (p) {
117
125
  if (o.code === "Escape") {
118
126
  const l = document.activeElement?.closest(".k-table-row[data-grid-row-index]");
119
127
  if (l) {
@@ -123,7 +131,7 @@ const We = (e) => {
123
131
  e?.value.$el.querySelectorAll(
124
132
  ".k-table-row[data-grid-row-index]"
125
133
  )
126
- ).forEach((p) => p.setAttribute("tabindex", "-1"));
134
+ ).forEach((v) => v.setAttribute("tabindex", "-1"));
127
135
  } catch {
128
136
  }
129
137
  l.setAttribute("tabindex", "0"), l.focus();
@@ -138,141 +146,141 @@ const We = (e) => {
138
146
  "Enter",
139
147
  "Space"
140
148
  ].includes(o.code)) {
141
- if (o.preventDefault(), m.classList.contains("k-grid-header-menu") && m.classList.contains("k-grid-column-menu")) {
142
- t.value = m;
149
+ if (o.preventDefault(), p.classList.contains("k-grid-header-menu") && p.classList.contains("k-grid-column-menu")) {
150
+ u.value = p;
143
151
  return;
144
152
  }
145
- const l = m.closest(
153
+ const l = p.closest(
146
154
  ".k-table-row[data-grid-row-index]"
147
155
  );
148
156
  if (l) {
149
157
  if (["ArrowDown", "ArrowUp"].includes(o.code)) {
150
- const i = (A, S) => {
151
- let I = S === "next" ? A.nextElementSibling : A.previousElementSibling;
152
- for (; I; ) {
153
- const G = I;
158
+ const s = (b, D) => {
159
+ let $ = D === "next" ? b.nextElementSibling : b.previousElementSibling;
160
+ for (; $; ) {
161
+ const H = $;
154
162
  try {
155
- if (G.hasAttribute && G.classList.contains("k-table-row"))
156
- return G;
163
+ if (H.hasAttribute && H.classList.contains("k-table-row"))
164
+ return H;
157
165
  } catch {
158
166
  }
159
- I = S === "next" ? I.nextElementSibling : I.previousElementSibling;
167
+ $ = D === "next" ? $.nextElementSibling : $.previousElementSibling;
160
168
  }
161
169
  return null;
162
- }, p = o.code === "ArrowDown" ? i(l, "next") : i(l, "previous");
163
- p && (l.setAttribute("tabindex", "-1"), p.setAttribute("tabindex", "0"), p.focus());
170
+ }, v = o.code === "ArrowDown" ? s(l, "next") : s(l, "previous");
171
+ v && (l.setAttribute("tabindex", "-1"), v.setAttribute("tabindex", "0"), v.focus());
164
172
  return;
165
173
  }
166
174
  if (["ArrowLeft", "ArrowRight"].includes(o.code)) {
167
175
  o.preventDefault();
168
- const i = l.querySelectorAll(
169
- W
176
+ const s = l.querySelectorAll(
177
+ A
170
178
  );
171
- if (i.length === 0) return;
172
- let p = Array.from(i).findIndex(
173
- (A) => A === document.activeElement
179
+ if (s.length === 0) return;
180
+ let v = Array.from(s).findIndex(
181
+ (b) => b === document.activeElement
174
182
  );
175
- if (p === -1 && document.activeElement === l) {
176
- i[0].focus();
183
+ if (v === -1 && document.activeElement === l) {
184
+ s[0].focus();
177
185
  return;
178
186
  }
179
- o.code === "ArrowRight" ? p = p === i.length - 1 ? 0 : p + 1 : o.code === "ArrowLeft" && (p = p === i.length - 1 ? p - 1 : i.length - 1), i[p].focus();
187
+ o.code === "ArrowRight" ? v = v === s.length - 1 ? 0 : v + 1 : o.code === "ArrowLeft" && (v = v === s.length - 1 ? v - 1 : s.length - 1), s[v].focus();
180
188
  return;
181
189
  }
182
190
  }
183
191
  }
184
192
  }
185
- }, D = () => {
186
- N(() => {
193
+ }, C = () => {
194
+ j(() => {
187
195
  const o = e.value.$el.closest(".k-grid");
188
196
  o && o.classList.add("fk-grid");
189
197
  });
190
- }, x = () => {
191
- if (!T)
198
+ }, T = () => {
199
+ if (!L)
192
200
  try {
193
201
  const o = () => {
194
202
  try {
195
- const i = Array.from(
203
+ const s = Array.from(
196
204
  e.value.$el.querySelectorAll(
197
205
  ".k-table-row[data-grid-row-index]"
198
206
  )
199
207
  );
200
- if (!i || i.length === 0 || i.filter(
201
- (S) => S.getAttribute("tabindex") === "0"
208
+ if (!s || s.length === 0 || s.filter(
209
+ (D) => D.getAttribute("tabindex") === "0"
202
210
  ).length === 1) return;
203
- const A = i.find(
204
- (S) => S === document.activeElement || S.contains(document.activeElement)
211
+ const b = s.find(
212
+ (D) => D === document.activeElement || D.contains(document.activeElement)
205
213
  );
206
- if (i.forEach((S) => S.setAttribute("tabindex", "-1")), A) {
207
- A.setAttribute("tabindex", "0");
214
+ if (s.forEach((D) => D.setAttribute("tabindex", "-1")), b) {
215
+ b.setAttribute("tabindex", "0");
208
216
  return;
209
217
  }
210
- i[0].setAttribute("tabindex", "0");
211
- } catch (i) {
212
- console.error("ensureSingleTabindex error:", i);
218
+ s[0].setAttribute("tabindex", "0");
219
+ } catch (s) {
220
+ console.error("ensureSingleTabindex error:", s);
213
221
  }
214
- }, m = Array.from(
222
+ }, p = Array.from(
215
223
  e.value.$el.querySelectorAll(
216
224
  ".k-table-row[data-grid-row-index]"
217
225
  )
218
226
  );
219
- m.length > 0 && m.forEach((i, p) => {
220
- i.setAttribute("tabindex", p === 0 ? "0" : "-1");
227
+ p.length > 0 && p.forEach((s, v) => {
228
+ s.setAttribute("tabindex", v === 0 ? "0" : "-1");
221
229
  });
222
230
  const l = e.value.$el.querySelector(".k-table-tbody");
223
- l && (T = new MutationObserver(() => {
231
+ l && (L = new MutationObserver(() => {
224
232
  o();
225
- }), T.observe(l, { childList: !0, subtree: !0 }));
233
+ }), L.observe(l, { childList: !0, subtree: !0 }));
226
234
  } catch (o) {
227
235
  console.error("Error setting up row navigation:", o);
228
236
  }
229
- }, C = () => {
230
- N(() => {
231
- const m = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
232
- m && m.forEach((l) => {
237
+ }, U = () => {
238
+ j(() => {
239
+ const p = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
240
+ p && p.forEach((l) => {
233
241
  l.setAttribute("role", "button"), l.addEventListener(
234
242
  "keydown",
235
- b
243
+ S
236
244
  );
237
- }), w(), f();
245
+ }), P(), y();
238
246
  });
239
- }, R = () => {
240
- const m = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
241
- m && m.forEach((l) => {
247
+ }, f = () => {
248
+ const p = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
249
+ p && p.forEach((l) => {
242
250
  l.removeEventListener(
243
251
  "keydown",
244
- b
252
+ S
245
253
  );
246
- }), P && (P.disconnect(), P = null), T && (T.disconnect(), T = null), V.forEach((l) => l()), V.length = 0;
247
- }, f = () => {
254
+ }), I && (I.disconnect(), I = null), L && (L.disconnect(), L = null), V.forEach((l) => l()), V.length = 0;
255
+ }, y = () => {
248
256
  document.querySelectorAll(
249
257
  ".k-grid-header .k-table-thead th"
250
- ).forEach((l, i) => {
251
- const p = l.querySelector(
258
+ ).forEach((l, s) => {
259
+ const v = l.querySelector(
252
260
  ".k-grid-header-menu.k-grid-column-menu"
253
261
  );
254
- if (!p) return;
255
- const A = k();
256
- if (A && A[i]) {
257
- const H = A[i].field ?? "";
258
- l.setAttribute("data-feather-k-field", H), l.setAttribute(
262
+ if (!v) return;
263
+ const b = k();
264
+ if (b && b[s]) {
265
+ const F = b[s].field ?? "";
266
+ l.setAttribute("data-feather-k-field", F), l.setAttribute(
259
267
  "data-feather-k-filterable",
260
- A[i].filterable === !1 ? "false" : "true"
268
+ b[s].filterable === !1 ? "false" : "true"
261
269
  ), l.setAttribute(
262
270
  "data-feather-k-sortable",
263
- A[i].sortable === !1 ? "false" : "true"
271
+ b[s].sortable === !1 ? "false" : "true"
264
272
  );
265
273
  }
266
- const S = l.dataset.featherKFilterable !== "false", I = l.dataset.featherKSortable !== "false";
267
- p.setAttribute("tabindex", "-1"), S || I ? l.style.cursor = "pointer" : l.style.cursor = "default", S ? (l.setAttribute("tabindex", "0"), l.setAttribute("role", "button"), l.setAttribute("aria-haspopup", "menu")) : (l.setAttribute("tabindex", "0"), l.setAttribute("role", "columnheader"), l.removeAttribute("aria-haspopup"));
268
- const G = (H) => {
269
- H.target?.closest(".k-column-resizer") || (t.value = l, p.click());
270
- }, oe = (H) => {
271
- if (S)
272
- t.value = l, H.preventDefault(), H.stopPropagation(), G(H);
273
- else if (I) {
274
- t.value = l;
275
- const j = new KeyboardEvent("keydown", {
274
+ const D = l.dataset.featherKFilterable !== "false", $ = l.dataset.featherKSortable !== "false";
275
+ v.setAttribute("tabindex", "-1"), D || $ ? l.style.cursor = "pointer" : l.style.cursor = "default", D ? (l.setAttribute("tabindex", "0"), l.setAttribute("role", "button"), l.setAttribute("aria-haspopup", "menu")) : (l.setAttribute("tabindex", "0"), l.setAttribute("role", "columnheader"), l.removeAttribute("aria-haspopup"));
276
+ const H = (F) => {
277
+ F.target?.closest(".k-column-resizer") || (u.value = l, v.click());
278
+ }, J = (F) => {
279
+ if (D)
280
+ u.value = l, F.preventDefault(), F.stopPropagation(), H(F);
281
+ else if ($) {
282
+ u.value = l;
283
+ const ne = new KeyboardEvent("keydown", {
276
284
  key: "Enter",
277
285
  code: "Enter",
278
286
  keyCode: 13,
@@ -280,193 +288,206 @@ const We = (e) => {
280
288
  bubbles: !0,
281
289
  cancelable: !0
282
290
  });
283
- l.dispatchEvent(j);
291
+ l.dispatchEvent(ne);
284
292
  }
285
293
  };
286
- l.addEventListener("click", oe), V.push(() => {
287
- l.removeEventListener("click", oe);
294
+ l.addEventListener("click", J), V.push(() => {
295
+ l.removeEventListener("click", J);
288
296
  });
289
- const Q = (H) => {
290
- if ((H.code === "Enter" || H.code === "Space") && (S || I)) {
291
- if (t.value = l, t.value.focus(), S)
292
- H.preventDefault(), H.stopPropagation(), G(H);
293
- else if (I) {
294
- const j = l.querySelector(".k-link");
295
- j && j.click();
297
+ const oe = (F) => {
298
+ if ((F.code === "Enter" || F.code === "Space") && (D || $)) {
299
+ if (u.value = l, u.value.focus(), D)
300
+ F.preventDefault(), F.stopPropagation(), H(F);
301
+ else if ($) {
302
+ const ne = l.querySelector(".k-link");
303
+ ne && ne.click();
296
304
  }
297
305
  }
298
306
  };
299
- l.addEventListener("keydown", Q, !0), V.push(() => {
300
- l.removeEventListener("keydown", Q, !0);
307
+ l.addEventListener("keydown", oe, !0), V.push(() => {
308
+ l.removeEventListener("keydown", oe, !0);
301
309
  });
302
310
  });
303
- const m = document.querySelector(".k-grid-header .k-table-thead");
304
- if (m) {
305
- const l = (i) => {
306
- const p = i.target.closest("th");
307
- p && (i.code === "Enter" || i.code === "Space") && p.dataset.featherKFilterable === "false" && p.dataset.featherKSortable === "false" && (i.preventDefault(), i.stopImmediatePropagation());
311
+ const p = document.querySelector(".k-grid-header .k-table-thead");
312
+ if (p) {
313
+ const l = (s) => {
314
+ const v = s.target.closest("th");
315
+ v && (s.code === "Enter" || s.code === "Space") && v.dataset.featherKFilterable === "false" && v.dataset.featherKSortable === "false" && (s.preventDefault(), s.stopImmediatePropagation());
308
316
  };
309
- m.addEventListener(
317
+ p.addEventListener(
310
318
  "keydown",
311
319
  l,
312
320
  !0
313
321
  // NOTE: capture phase
314
322
  ), V.push(() => {
315
- m.removeEventListener(
323
+ p.removeEventListener(
316
324
  "keydown",
317
325
  l,
318
326
  !0
319
327
  );
320
328
  });
321
329
  }
322
- }, g = function(o, m) {
323
- const l = o?.event.event.target, i = k();
324
- if (!l || !i) return;
325
- const p = l.classList.contains("k-link"), A = l.classList.contains("k-columnmenu-item"), S = i.find((I) => I.field === o.event.field)?.sortable && !0;
326
- if (!p) {
327
- if (A && !S) {
330
+ }, O = function(o, p) {
331
+ const l = o?.event.event.target, s = k();
332
+ if (!l || !s) return;
333
+ const v = l.classList.contains("k-link"), b = l.classList.contains("k-columnmenu-item"), D = s.find(($) => $.field === o.event.field)?.sortable && !0;
334
+ if (!v) {
335
+ if (b && !D) {
328
336
  (o.event.sort && void 0)?.filter(
329
- (G) => G.field !== o.event.field
337
+ (H) => H.field !== o.event.field
330
338
  );
331
339
  return;
332
340
  }
333
- typeof m == "function" && N(() => {
334
- t.value && t.value.focus(), m(o);
341
+ typeof p == "function" && j(() => {
342
+ u.value && u.value.focus(), p(o);
335
343
  });
336
344
  }
337
- }, F = () => {
338
- if (!c)
345
+ }, G = () => {
346
+ if (!q)
339
347
  try {
340
- D(), x(), C(), c = !0;
348
+ C(), T(), U(), q = !0;
341
349
  } catch (o) {
342
- console.error("initA11y failed:", o), R();
350
+ console.error("initA11y failed:", o), f();
343
351
  }
344
352
  };
345
- return Ie(() => {
346
- R();
353
+ return Te(() => {
354
+ f();
347
355
  }), {
348
- activeFilterButton: t,
349
- handleGridKeyDown: L,
350
- handleSortChange: g,
351
- initA11y: F
356
+ activeFilterButton: u,
357
+ handleGridKeyDown: E,
358
+ handleSortChange: O,
359
+ initA11y: G
352
360
  };
353
361
  };
354
- function _e(e) {
355
- const t = _(""), c = _(void 0), P = _(!!e.debug), T = _(e.dateFormat ?? "mm/dd/yyyy"), V = h(() => !!e.required), W = _(!1), k = ["ArrowUp", "ArrowDown"], b = ["ArrowLeft", "ArrowRight"], y = h(() => (t.value ?? "").replace(/\D/g, "")), w = (a) => a <= 2 ? "mm" : a <= 5 ? "dd" : y.value.length <= 10 ? "yyyy" : "mm", L = h(() => {
362
+ function ze(e) {
363
+ const t = _(""), u = _(void 0), q = _(!!e.debug), I = _(e.dateFormat ?? "mm/dd/yyyy"), L = h(() => !!e.required), V = _(!1), A = ["ArrowUp", "ArrowDown"], k = ["ArrowLeft", "ArrowRight"], S = h(() => (t.value ?? "").replace(/\D/g, "")), g = (a) => a <= 2 ? "mm" : a <= 5 ? "dd" : S.value.length <= 10 ? "yyyy" : "mm", P = h(() => {
356
364
  const a = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0";
357
365
  return parseInt(a).toString().padStart(2, "0");
358
- }), D = h(() => {
366
+ }), E = h(() => {
359
367
  const a = t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0";
360
368
  return parseInt(a).toString().padStart(2, "0");
361
- }), x = h(() => {
369
+ }), C = h(() => {
362
370
  const a = t.value && t.value.substring(6, 10).replace(/\D/g, "0") || "0";
363
371
  return parseInt(a).toString().padStart(4, "0");
364
- }), C = (a) => {
365
- if (y.value.length === 0) {
372
+ }), T = (a) => {
373
+ if (S.value.length === 0) {
366
374
  e.onChange({ value: null, event: a });
367
375
  return;
368
376
  }
369
- if (y.value.length < 8) {
377
+ if (S.value.length < 8) {
370
378
  e.onChange({ value: null, event: a });
371
379
  return;
372
380
  }
373
- if ((t.value ?? "").length === 10 && y.value.length === 8) {
374
- const [d, M, ee] = t.value.split("/"), r = parseInt(d), u = parseInt(M), v = parseInt(ee);
375
- if (o(v, r, u)) {
376
- const $ = new Date(v, r - 1, u);
377
- R($) ? e.onChange({ value: $, event: a }) : e.onChange({ value: null, event: a });
381
+ if ((t.value ?? "").length === 10 && S.value.length === 8) {
382
+ const [d, M, r] = t.value.split("/"), i = parseInt(d), m = parseInt(M), w = parseInt(r);
383
+ if (G(w, i, m)) {
384
+ const B = new Date(w, i - 1, m);
385
+ U(B) ? e.onChange({ value: B, event: a }) : e.onChange({ value: null, event: a });
378
386
  } else
379
387
  e.onChange({ value: null, event: a });
380
388
  }
381
- }, R = (a) => {
389
+ }, U = (a) => {
382
390
  const d = e.min ?? void 0, M = e.max ?? void 0;
383
391
  return !(d && a < d || M && a > M);
384
392
  }, f = h(() => {
385
- if ((t.value ?? "").length === 10 && y.value.length === 8) {
386
- const [a, d, M] = (t.value ?? "").split("/"), ee = parseInt(a), r = parseInt(d), u = parseInt(M);
387
- if (o(u, ee, r))
388
- return new Date(u, ee - 1, r);
393
+ if ((t.value ?? "").length === 10 && S.value.length === 8) {
394
+ const [a, d, M] = (t.value ?? "").split("/"), r = parseInt(a), i = parseInt(d), m = parseInt(M);
395
+ if (G(m, r, i))
396
+ return new Date(m, r - 1, i);
389
397
  }
390
398
  return null;
391
- }), g = h(() => (t.value ?? "").length === 10 && y.value.length === 8), F = (a, d) => new Date(a, d, 0).getDate(), o = (a, d, M) => d >= 1 && d <= 12 && a >= 1900 && M >= 1 && M <= F(a, d), m = (a) => {
399
+ }), y = h(() => (t.value ?? "").length === 10 && S.value.length === 8), O = (a, d) => new Date(a, d, 0).getDate(), G = (a, d, M) => d >= 1 && d <= 12 && a >= 1900 && M >= 1 && M <= O(a, d), o = (a) => {
392
400
  t.value = a.value;
393
401
  const d = a.event?.target;
394
- c.value = d?.selectionStart ?? 0, C(a);
395
- }, l = (a) => {
396
- c.value = a.target.selectionStart ?? 0;
397
- }, i = (a, d, M) => {
398
- const ee = d?.selectionStart ?? c.value ?? 0;
399
- c.value = ee;
400
- let r = parseInt(L.value), u = parseInt(D.value), v = parseInt(x.value);
401
- if (!(y.value.length >= 8) || !o(v, r, u)) {
402
- const X = e.defaultValue ?? /* @__PURE__ */ new Date();
403
- r = X.getMonth() + 1, u = X.getDate(), v = X.getFullYear(), t.value = `${String(r).padStart(2, "0")}/${String(u).padStart(
402
+ u.value = d?.selectionStart ?? 0, T(a);
403
+ }, p = (a) => {
404
+ u.value = a.target.selectionStart ?? 0;
405
+ }, l = (a, d, M) => {
406
+ const r = d?.selectionStart ?? u.value ?? 0;
407
+ u.value = r;
408
+ let i = parseInt(P.value), m = parseInt(E.value), w = parseInt(C.value);
409
+ if (!(S.value.length >= 8) || !G(w, i, m)) {
410
+ const K = e.defaultValue ?? /* @__PURE__ */ new Date();
411
+ i = K.getMonth() + 1, m = K.getDate(), w = K.getFullYear(), t.value = `${String(i).padStart(2, "0")}/${String(m).padStart(
404
412
  2,
405
413
  "0"
406
- )}/${String(v)}`;
407
- const O = new Date(v, r - 1, u);
408
- e.onChange({ value: R(O) ? O : null, event: M }), N(() => {
409
- requestAnimationFrame(() => {
410
- const J = document.getElementById(
411
- e.id
412
- ), Z = c.value ?? 0;
413
- J && (J.focus(), J.setSelectionRange(Z, Z));
414
- });
415
- });
414
+ )}/${String(w)}`;
415
+ const X = new Date(w, i - 1, m);
416
+ e.onChange({ value: U(X) ? X : null, event: M }), $({ useRAF: !0 });
416
417
  return;
417
418
  }
418
- const U = w(ee);
419
- if (U === "mm")
420
- r = a === "ArrowUp" ? r < 12 ? r + 1 : 1 : r > 1 ? r - 1 : 12;
421
- else if (U === "dd") {
422
- const X = new Date(v, r, 0).getDate();
423
- u = a === "ArrowUp" ? u < X ? u + 1 : 1 : u > 1 ? u - 1 : X;
424
- } else U === "yyyy" && (v = a === "ArrowUp" ? v + 1 : Math.max(1, v - 1));
425
- t.value = `${String(r).padStart(2, "0")}/${String(u).padStart(
419
+ const Q = g(r);
420
+ if (Q === "mm")
421
+ i = a === "ArrowUp" ? i < 12 ? i + 1 : 1 : i > 1 ? i - 1 : 12;
422
+ else if (Q === "dd") {
423
+ const K = new Date(w, i, 0).getDate();
424
+ m = a === "ArrowUp" ? m < K ? m + 1 : 1 : m > 1 ? m - 1 : K;
425
+ } else Q === "yyyy" && (w = a === "ArrowUp" ? w + 1 : Math.max(1, w - 1));
426
+ t.value = `${String(i).padStart(2, "0")}/${String(m).padStart(
426
427
  2,
427
428
  "0"
428
- )}/${String(v)}`;
429
- const [ae, z, Y] = t.value.split("/"), ie = new Date(
430
- parseInt(Y),
431
- parseInt(ae) - 1,
432
- parseInt(z)
429
+ )}/${String(w)}`;
430
+ const [z, W, ie] = t.value.split("/"), le = new Date(
431
+ parseInt(ie),
432
+ parseInt(z) - 1,
433
+ parseInt(W)
433
434
  );
434
- ie.toString() !== "Invalid Date" && parseInt(Y) >= 1e3 ? e.onChange({
435
- value: R(ie) ? ie : null,
435
+ le.toString() !== "Invalid Date" && parseInt(ie) >= 1e3 ? e.onChange({
436
+ value: U(le) ? le : null,
436
437
  event: M
437
- }) : e.onChange({ value: null, event: M }), N(() => {
438
- requestAnimationFrame(() => {
439
- const X = document.getElementById(
440
- e.id
441
- ), O = c.value ?? 0;
442
- X && (X.focus(), X.setSelectionRange(O, O));
443
- });
444
- });
445
- }, p = (a) => {
438
+ }) : e.onChange({ value: null, event: M }), $({ useRAF: !0 });
439
+ }, s = (a) => {
446
440
  if (a.code === "Space" || a.key === " ") {
447
441
  e.onShowCalendar(a);
448
442
  return;
449
443
  }
450
- if (k.includes(a.key)) {
444
+ if (A.includes(a.key)) {
445
+ if (a.altKey) return;
451
446
  a.preventDefault();
452
447
  const d = a.target;
453
- i(a.key, d, a);
448
+ l(a.key, d, a);
454
449
  }
455
- }, A = (a) => {
450
+ }, v = (a) => {
456
451
  a.preventDefault();
457
452
  const d = a.deltaY < 0 ? "ArrowUp" : "ArrowDown";
458
- i(d, a.target, a);
459
- }, S = (a) => {
453
+ l(d, a.target, a);
454
+ }, b = (a) => {
460
455
  const d = a.target;
461
- if (b.includes(a.key)) {
462
- c.value = d?.selectionStart ?? 0;
456
+ if (k.includes(a.key)) {
457
+ u.value = d?.selectionStart ?? 0;
463
458
  return;
464
459
  }
465
- k.includes(a.key) && (a.preventDefault(), c.value = d?.selectionStart ?? 0);
466
- }, I = (a) => {
467
- W.value = !0, V.value && !e.defaultValue && e.externalValue && e.externalValue.value === void 0 && y.value.length === 0 && (e.externalValue.value = "");
460
+ if (A.includes(a.key)) {
461
+ if (a.altKey) return;
462
+ a.preventDefault(), u.value = d?.selectionStart ?? 0;
463
+ }
464
+ }, D = (a) => {
465
+ V.value = !0, L.value && !e.defaultValue && e.externalValue && e.externalValue.value === void 0 && S.value.length === 0 && (e.externalValue.value = "");
468
466
  const d = a.target;
469
- d && (c.value = d.selectionStart ?? 0);
467
+ d && (u.value = d.selectionStart ?? 0);
468
+ }, $ = (a) => {
469
+ const d = () => {
470
+ const M = document.getElementById(
471
+ e.id
472
+ );
473
+ if (!M) return;
474
+ const r = a?.pos ?? u.value ?? M.value.length;
475
+ try {
476
+ M.focus(), M.setSelectionRange(r, r);
477
+ } catch {
478
+ }
479
+ };
480
+ j(() => {
481
+ if (a?.delay && a.delay > 0) {
482
+ setTimeout(d, a.delay);
483
+ return;
484
+ }
485
+ if (a?.useRAF) {
486
+ requestAnimationFrame(d);
487
+ return;
488
+ }
489
+ d();
490
+ });
470
491
  };
471
492
  e.externalValue && ve(
472
493
  e.externalValue,
@@ -474,17 +495,17 @@ function _e(e) {
474
495
  if (a) {
475
496
  const d = new Date(a);
476
497
  if (d.toString() !== "Invalid Date") {
477
- const M = (d.getMonth() + 1).toString().padStart(2, "0"), ee = d.getDate().toString().padStart(2, "0"), r = d.getFullYear().toString();
478
- t.value = `${M}/${ee}/${r}`;
498
+ const M = (d.getMonth() + 1).toString().padStart(2, "0"), r = d.getDate().toString().padStart(2, "0"), i = d.getFullYear().toString();
499
+ t.value = `${M}/${r}/${i}`, $({ delay: 50 });
479
500
  return;
480
501
  }
481
502
  }
482
503
  },
483
504
  { immediate: !0 }
484
505
  );
485
- const G = h(() => [
486
- ["Date", `${L.value} / ${D.value} / ${x.value}`],
487
- ["Digits only", y.value],
506
+ const H = h(() => [
507
+ ["Date", `${P.value} / ${E.value} / ${C.value}`],
508
+ ["Digits only", S.value],
488
509
  [
489
510
  "min",
490
511
  e.min?.toLocaleDateString("en-US", {
@@ -501,33 +522,33 @@ function _e(e) {
501
522
  day: "2-digit"
502
523
  }) ?? null
503
524
  ]
504
- ]), oe = h(() => {
505
- if (!V.value) {
506
- if (!g.value) return !0;
525
+ ]), J = h(() => {
526
+ if (!L.value) {
527
+ if (!y.value) return !0;
507
528
  const d = f.value;
508
- return d ? R(d) : !1;
529
+ return d ? U(d) : !1;
509
530
  }
510
- if (!W.value) return !0;
531
+ if (!V.value) return !0;
511
532
  const a = f.value;
512
- return !g.value || !a ? !1 : R(a);
513
- }), Q = h(() => {
514
- if (!V.value) {
515
- if (!g.value) return;
533
+ return !y.value || !a ? !1 : U(a);
534
+ }), oe = h(() => {
535
+ if (!L.value) {
536
+ if (!y.value) return;
516
537
  const d = f.value;
517
- return d ? R(d) ? "valid" : "out-of-bounds" : "invalid-date";
538
+ return d ? U(d) ? "valid" : "out-of-bounds" : "invalid-date";
518
539
  }
519
- if (!W.value) return;
520
- if (y.value.length === 0 || !g.value)
540
+ if (!V.value) return;
541
+ if (S.value.length === 0 || !y.value)
521
542
  return "incomplete";
522
543
  const a = f.value;
523
- return a ? R(a) ? "valid" : "out-of-bounds" : "invalid-date";
524
- }), H = h(() => {
525
- const a = Q.value;
544
+ return a ? U(a) ? "valid" : "out-of-bounds" : "invalid-date";
545
+ }), F = h(() => {
546
+ const a = oe.value;
526
547
  if (!a || a === "valid") return "";
527
548
  if (a === "incomplete")
528
549
  return "Required";
529
550
  if (a === "invalid-date")
530
- return `Must be in ${T.value} format.`;
551
+ return `Must be in ${I.value} format.`;
531
552
  const d = e.min ? e.min.toLocaleDateString("en-US", {
532
553
  year: "numeric",
533
554
  month: "2-digit",
@@ -543,8 +564,8 @@ function _e(e) {
543
564
  if (M) return `Must be on or before ${M}.`;
544
565
  }
545
566
  return "";
546
- }), j = () => {
547
- N(() => {
567
+ }), ne = () => {
568
+ j(() => {
548
569
  const a = document.getElementById(
549
570
  e.id
550
571
  );
@@ -569,70 +590,70 @@ function _e(e) {
569
590
  });
570
591
  };
571
592
  return xe(() => {
572
- j();
593
+ ne();
573
594
  }), {
574
595
  raw: t,
575
- cursorPos: c,
576
- debugEnabled: P,
577
- debugLines: G,
578
- placeholder: T,
579
- isValid: oe,
580
- reason: K(Q),
581
- validationMessage: H,
582
- digitsOnly: y,
583
- month: K(L),
584
- day: K(D),
585
- year: K(x),
586
- datePart: w,
587
- handleChange: m,
588
- handleKeyDown: p,
589
- handleWheel: A,
590
- handleKeyUp: S,
591
- handleClick: l,
592
- handleBlur: I,
596
+ cursorPos: u,
597
+ debugEnabled: q,
598
+ debugLines: H,
599
+ placeholder: I,
600
+ isValid: J,
601
+ reason: N(oe),
602
+ validationMessage: F,
603
+ digitsOnly: S,
604
+ month: N(P),
605
+ day: N(E),
606
+ year: N(C),
607
+ datePart: g,
608
+ handleChange: o,
609
+ handleKeyDown: s,
610
+ handleWheel: v,
611
+ handleKeyUp: b,
612
+ handleClick: p,
613
+ handleBlur: D,
593
614
  // Expose so consumers can re-run styling when needed
594
- initStyling: j
615
+ initStyling: ne
595
616
  };
596
617
  }
597
- function Ge(e) {
598
- const t = _(""), c = _(void 0), P = _(!!e.debug), T = _(!1), W = 365 * (1440 * 60 * 1e3), k = /* @__PURE__ */ new Date(), b = new Date(k.getTime() - W), y = new Date(k.getTime() + W);
599
- e.min = e.min ?? b, e.max = e.max ?? y;
600
- const w = h(() => (t.value ?? "").replace(/\D/g, "")), L = (n, s) => new Date(n, s, 0).getDate(), D = (n, s, E) => s >= 1 && s <= 12 && n >= 1e3 && E >= 1 && E <= L(n, s), x = (n) => Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()), C = (n) => {
618
+ function Xe(e) {
619
+ const t = _(""), u = _(void 0), q = _(!!e.debug), I = _(!1), V = 365 * (1440 * 60 * 1e3), A = /* @__PURE__ */ new Date(), k = new Date(A.getTime() - V), S = new Date(A.getTime() + V);
620
+ e.min = e.min ?? k, e.max = e.max ?? S;
621
+ const g = h(() => (t.value ?? "").replace(/\D/g, "")), P = (n, c) => new Date(n, c, 0).getDate(), E = (n, c, x) => c >= 1 && c <= 12 && n >= 1e3 && x >= 1 && x <= P(n, c), C = (n) => Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()), T = (n) => {
601
622
  if (!n) return null;
602
- const s = e.min, E = e.max, q = x(n);
603
- return q < x(s) || q > x(E) ? null : n;
604
- }, R = (n, s) => e.allowReverse ?? !1 ? !0 : n <= s, f = h(() => (t.value?.length ?? 0) >= 23 && w.value.length >= 16), g = (n) => {
605
- if ((n ?? "").length < 23 || w.value.length < 16)
623
+ const c = e.min, x = e.max, R = C(n);
624
+ return R < C(c) || R > C(x) ? null : n;
625
+ }, U = (n, c) => e.allowReverse ?? !1 ? !0 : n <= c, f = h(() => (t.value?.length ?? 0) >= 23 && g.value.length >= 16), y = (n) => {
626
+ if ((n ?? "").length < 23 || g.value.length < 16)
606
627
  return { start: null, end: null };
607
- const s = n.substring(0, 10), E = n.substring(13, 23), [q, ne, le] = s.split("/").map((se) => parseInt(se || "0", 10)), [ye, de, fe] = E.split("/").map((se) => parseInt(se || "0", 10)), me = new Date(le, q - 1, ne), he = new Date(fe, ye - 1, de), we = D(le, q, ne) && me.toString() !== "Invalid Date", ke = D(fe, ye, de) && he.toString() !== "Invalid Date";
628
+ const c = n.substring(0, 10), x = n.substring(13, 23), [R, ee, ae] = c.split("/").map((se) => parseInt(se || "0", 10)), [ge, de, fe] = x.split("/").map((se) => parseInt(se || "0", 10)), me = new Date(ae, R - 1, ee), he = new Date(fe, ge - 1, de), we = E(ae, R, ee) && me.toString() !== "Invalid Date", ke = E(fe, ge, de) && he.toString() !== "Invalid Date";
608
629
  return { start: we ? me : null, end: ke ? he : null };
609
- }, F = e.externalValid ?? _(!0), o = h(() => g(t.value)), m = h(() => {
610
- const n = C(o.value.start), s = C(o.value.end);
611
- return { start: n, end: s };
612
- }), l = h(() => {
630
+ }, O = e.externalValid ?? _(!0), G = h(() => y(t.value)), o = h(() => {
631
+ const n = T(G.value.start), c = T(G.value.end);
632
+ return { start: n, end: c };
633
+ }), p = h(() => {
613
634
  if (!f.value) return;
614
- const n = m.value.start, s = m.value.end;
615
- if (!n || !s) return;
616
- const E = Math.abs(x(s) - x(n));
617
- return Math.round(E / 864e5 + 1);
618
- }), i = h(() => {
635
+ const n = o.value.start, c = o.value.end;
636
+ if (!n || !c) return;
637
+ const x = Math.abs(C(c) - C(n));
638
+ return Math.round(x / 864e5 + 1);
639
+ }), l = h(() => {
619
640
  if (!f.value) return !1;
620
- const { start: n, end: s } = o.value;
621
- if (!n || !s || !m.value.start || !m.value.end) return !1;
622
- const E = m.value.start, q = m.value.end;
623
- return !(!R(E, q) || typeof e.maxSpanDays == "number" && l.value !== void 0 && l.value > e.maxSpanDays);
624
- }), p = h(() => {
625
- const { start: n, end: s } = o.value;
641
+ const { start: n, end: c } = G.value;
642
+ if (!n || !c || !o.value.start || !o.value.end) return !1;
643
+ const x = o.value.start, R = o.value.end;
644
+ return !(!U(x, R) || typeof e.maxSpanDays == "number" && p.value !== void 0 && p.value > e.maxSpanDays);
645
+ }), s = h(() => {
646
+ const { start: n, end: c } = G.value;
626
647
  if (!f.value) return "incomplete";
627
- if (!n || !s) return "invalid-date";
628
- if (!m.value.start || !m.value.end) return "out-of-bounds";
629
- const E = m.value.start, q = m.value.end;
630
- return R(E, q) ? typeof e.maxSpanDays == "number" && l.value !== void 0 && l.value > e.maxSpanDays ? "span-exceeds-limit" : "valid" : "reversed-range";
631
- }), A = _(void 0), S = h(() => {
632
- if (F.value !== !1) return "";
633
- const { min: n, max: s } = e, E = A.value;
634
- if (!E) return "";
635
- switch (E) {
648
+ if (!n || !c) return "invalid-date";
649
+ if (!o.value.start || !o.value.end) return "out-of-bounds";
650
+ const x = o.value.start, R = o.value.end;
651
+ return U(x, R) ? typeof e.maxSpanDays == "number" && p.value !== void 0 && p.value > e.maxSpanDays ? "span-exceeds-limit" : "valid" : "reversed-range";
652
+ }), v = _(void 0), b = h(() => {
653
+ if (O.value !== !1) return "";
654
+ const { min: n, max: c } = e, x = v.value;
655
+ if (!x) return "";
656
+ switch (x) {
636
657
  case "incomplete":
637
658
  return "Required";
638
659
  case "invalid-date":
@@ -640,90 +661,90 @@ function Ge(e) {
640
661
  case "reversed-range":
641
662
  return "End Date must be on or after Start Date.";
642
663
  case "out-of-bounds":
643
- return n && s ? `Dates must be between ${Q(n)} and ${Q(s)}.` : "Dates must be within the allowed range.";
664
+ return n && c ? `Dates must be between ${J(n)} and ${J(c)}.` : "Dates must be within the allowed range.";
644
665
  case "span-exceeds-limit":
645
666
  return typeof e.maxSpanDays == "number" ? `Date range exceeds ${e.maxSpanDays} days.` : "Date range exceeds maximum allowed span.";
646
667
  case "valid":
647
668
  default:
648
669
  return "";
649
670
  }
650
- }), I = ["ArrowUp", "ArrowDown"], G = ["ArrowLeft", "ArrowRight"], oe = (n, s) => String(n).padStart(s, "0"), Q = (n) => `${oe(n.getMonth() + 1, 2)}/${oe(n.getDate(), 2)}/${oe(
671
+ }), D = ["ArrowUp", "ArrowDown"], $ = ["ArrowLeft", "ArrowRight"], H = (n, c) => String(n).padStart(c, "0"), J = (n) => `${H(n.getMonth() + 1, 2)}/${H(n.getDate(), 2)}/${H(
651
672
  n.getFullYear(),
652
673
  4
653
- )}`, H = (n) => n <= 2 ? { side: "start", part: "mm" } : n <= 5 ? { side: "start", part: (n <= 3, "dd") } : n <= 11 ? { side: "start", part: "yyyy" } : n <= 15 ? { side: "end", part: "mm" } : n <= 18 ? { side: "end", part: "dd" } : { side: "end", part: "yyyy" }, j = (n, s, E) => {
654
- const q = s?.selectionStart ?? c.value ?? 0;
655
- c.value = q;
656
- const { start: ne, end: le } = g(t.value);
657
- if (!ne && !le) {
658
- const B = /* @__PURE__ */ new Date(), ue = Q(B);
659
- t.value = `${ue} - ${ue}`, e.onChange({ value: { start: B, end: B }, event: E }), N(() => {
674
+ )}`, oe = (n) => n <= 2 ? { side: "start", part: "mm" } : n <= 5 ? { side: "start", part: (n <= 3, "dd") } : n <= 11 ? { side: "start", part: "yyyy" } : n <= 15 ? { side: "end", part: "mm" } : n <= 18 ? { side: "end", part: "dd" } : { side: "end", part: "yyyy" }, F = (n, c, x) => {
675
+ const R = c?.selectionStart ?? u.value ?? 0;
676
+ u.value = R;
677
+ const { start: ee, end: ae } = y(t.value);
678
+ if (!ee && !ae) {
679
+ const Y = /* @__PURE__ */ new Date(), ue = J(Y);
680
+ t.value = `${ue} - ${ue}`, e.onChange({ value: { start: Y, end: Y }, event: x }), j(() => {
660
681
  requestAnimationFrame(() => {
661
- const te = document.getElementById(
682
+ const Z = document.getElementById(
662
683
  e.id
663
- ), re = c.value ?? 0;
664
- te && (te.focus(), te.setSelectionRange(re, re));
684
+ ), te = u.value ?? 0;
685
+ Z && (Z.focus(), Z.setSelectionRange(te, te));
665
686
  });
666
687
  });
667
688
  return;
668
689
  }
669
- const ye = /* @__PURE__ */ new Date(), de = H(q);
670
- let fe = ne ? new Date(ne) : new Date(ye), me = le ? new Date(le) : new Date(ye);
671
- const he = (B, ue) => {
690
+ const ge = /* @__PURE__ */ new Date(), de = oe(R);
691
+ let fe = ee ? new Date(ee) : new Date(ge), me = ae ? new Date(ae) : new Date(ge);
692
+ const he = (Y, ue) => {
672
693
  if (ue === "mm") {
673
- const te = B.getMonth() + 1, re = n === "ArrowUp" ? te < 12 ? te + 1 : 1 : te > 1 ? te - 1 : 12;
674
- B.setMonth(re - 1);
675
- const be = L(B.getFullYear(), re);
676
- B.getDate() > be && B.setDate(be);
694
+ const Z = Y.getMonth() + 1, te = n === "ArrowUp" ? Z < 12 ? Z + 1 : 1 : Z > 1 ? Z - 1 : 12;
695
+ Y.setMonth(te - 1);
696
+ const Se = P(Y.getFullYear(), te);
697
+ Y.getDate() > Se && Y.setDate(Se);
677
698
  } else if (ue === "dd") {
678
- const te = L(B.getFullYear(), B.getMonth() + 1), re = B.getDate(), be = n === "ArrowUp" ? re < te ? re + 1 : 1 : re > 1 ? re - 1 : te;
679
- B.setDate(be);
699
+ const Z = P(Y.getFullYear(), Y.getMonth() + 1), te = Y.getDate(), Se = n === "ArrowUp" ? te < Z ? te + 1 : 1 : te > 1 ? te - 1 : Z;
700
+ Y.setDate(Se);
680
701
  } else if (ue === "yyyy") {
681
- const te = B.getFullYear();
682
- B.setFullYear(n === "ArrowUp" ? te + 1 : Math.max(1, te - 1));
683
- const re = L(B.getFullYear(), B.getMonth() + 1);
684
- B.getDate() > re && B.setDate(re);
702
+ const Z = Y.getFullYear();
703
+ Y.setFullYear(n === "ArrowUp" ? Z + 1 : Math.max(1, Z - 1));
704
+ const te = P(Y.getFullYear(), Y.getMonth() + 1);
705
+ Y.getDate() > te && Y.setDate(te);
685
706
  }
686
707
  };
687
708
  de.side === "start" ? he(fe, de.part) : he(me, de.part);
688
- const we = Q(fe), ke = Q(me);
709
+ const we = J(fe), ke = J(me);
689
710
  t.value = `${we} - ${ke}`;
690
- const se = C(fe), De = C(me);
691
- se && De && R(se, De) ? e.onChange({ value: { start: se, end: De }, event: E }) : e.onChange({ value: null, event: E }), N(() => {
711
+ const se = T(fe), De = T(me);
712
+ se && De && U(se, De) ? e.onChange({ value: { start: se, end: De }, event: x }) : e.onChange({ value: null, event: x }), j(() => {
692
713
  requestAnimationFrame(() => {
693
- const B = document.getElementById(
714
+ const Y = document.getElementById(
694
715
  e.id
695
- ), ue = c.value ?? 0;
696
- B && (B.focus(), B.setSelectionRange(ue, ue));
716
+ ), ue = u.value ?? 0;
717
+ Y && (Y.focus(), Y.setSelectionRange(ue, ue));
697
718
  });
698
719
  });
699
- }, a = (n) => {
700
- const { start: s, end: E } = g(t.value);
701
- if (!s || !E) {
720
+ }, ne = (n) => {
721
+ const { start: c, end: x } = y(t.value);
722
+ if (!c || !x) {
702
723
  e.onChange({ value: null, event: n });
703
724
  return;
704
725
  }
705
- const q = C(s), ne = C(E);
706
- if (!q || !ne) {
726
+ const R = T(c), ee = T(x);
727
+ if (!R || !ee) {
707
728
  e.onChange({ value: null, event: n });
708
729
  return;
709
730
  }
710
- if (!R(q, ne)) {
731
+ if (!U(R, ee)) {
711
732
  e.onChange({ value: null, event: n });
712
733
  return;
713
734
  }
714
- e.onChange({ value: { start: q, end: ne }, event: n });
715
- }, d = (n) => {
716
- const s = n.value ?? "", E = n.event;
717
- if (!s && E && E.type === "click") {
718
- U(E);
735
+ e.onChange({ value: { start: R, end: ee }, event: n });
736
+ }, a = (n) => {
737
+ const c = n.value ?? "", x = n.event;
738
+ if (!c && x && x.type === "click") {
739
+ B(x);
719
740
  return;
720
741
  }
721
- t.value = s;
722
- const q = E?.target;
723
- c.value = q?.selectionStart ?? 0, a(n);
742
+ t.value = c;
743
+ const R = x?.target;
744
+ u.value = R?.selectionStart ?? 0, ne(n);
745
+ }, d = (n) => {
746
+ u.value = n.target.selectionStart ?? 0;
724
747
  }, M = (n) => {
725
- c.value = n.target.selectionStart ?? 0;
726
- }, ee = (n) => {
727
748
  if (n.code === "Space" || n.key === " ") {
728
749
  n.preventDefault(), e.onShowCalendar(n);
729
750
  return;
@@ -732,63 +753,63 @@ function Ge(e) {
732
753
  n.preventDefault(), e.onShowCalendar(n);
733
754
  return;
734
755
  }
735
- if (I.includes(n.key)) {
756
+ if (D.includes(n.key)) {
736
757
  n.preventDefault();
737
- const s = n.target;
738
- j(n.key, s, n);
758
+ const c = n.target;
759
+ F(n.key, c, n);
739
760
  }
740
761
  }, r = (n) => {
741
762
  n.preventDefault();
742
- const s = n.deltaY < 0 ? "ArrowUp" : "ArrowDown";
743
- j(s, n.target, n);
744
- }, u = (n) => {
745
- if (G.includes(n.key) || I.includes(n.key)) {
763
+ const c = n.deltaY < 0 ? "ArrowUp" : "ArrowDown";
764
+ F(c, n.target, n);
765
+ }, i = (n) => {
766
+ if ($.includes(n.key) || D.includes(n.key)) {
746
767
  n.preventDefault();
747
- const s = n.target;
748
- c.value = s?.selectionStart ?? 0;
768
+ const c = n.target;
769
+ u.value = c?.selectionStart ?? 0;
749
770
  }
750
- }, v = () => {
751
- A.value = p.value, (e.manageValid ?? !0) && (F.value = i.value);
752
- }, $ = (n) => {
753
- v();
754
- }, U = (n) => {
755
- console.log("Clear event:", n), t.value = "", c.value = 0, e.onChange({ value: null, event: n }), v(), N(() => {
756
- const s = document.getElementById(
771
+ }, m = () => {
772
+ v.value = s.value, (e.manageValid ?? !0) && (O.value = l.value);
773
+ }, w = (n) => {
774
+ m();
775
+ }, B = (n) => {
776
+ console.log("Clear event:", n), t.value = "", u.value = 0, e.onChange({ value: null, event: n }), m(), j(() => {
777
+ const c = document.getElementById(
757
778
  e.id
758
779
  );
759
- s && (s.focus(), s.setSelectionRange(0, 0));
780
+ c && (c.focus(), c.setSelectionRange(0, 0));
760
781
  });
761
782
  };
762
783
  e.externalValue && ve(
763
784
  e.externalValue,
764
785
  (n) => {
765
- const s = n?.start ?? null, E = n?.end ?? null;
766
- if (s && E) {
767
- if (t.value = `${Q(s)} - ${Q(E)}`, e.isOpen?.value && T.value && e.onRequestClose) {
768
- const q = typeof e.closeDelay == "number" ? e.closeDelay : e.closeDelay?.value ?? 0;
786
+ const c = n?.start ?? null, x = n?.end ?? null;
787
+ if (c && x) {
788
+ if (t.value = `${J(c)} - ${J(x)}`, e.isOpen?.value && I.value && e.onRequestClose) {
789
+ const R = typeof e.closeDelay == "number" ? e.closeDelay : e.closeDelay?.value ?? 0;
769
790
  setTimeout(() => {
770
- e.onRequestClose?.(), T.value = !1, v();
771
- }, q);
791
+ e.onRequestClose?.(), I.value = !1, m();
792
+ }, R);
772
793
  }
773
794
  return;
774
795
  }
775
796
  },
776
797
  { immediate: !0 }
777
798
  );
778
- const ae = h(
799
+ const Q = h(
779
800
  () => t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0"
780
801
  ), z = h(
781
802
  () => t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0"
782
- ), Y = h(
803
+ ), W = h(
783
804
  () => t.value && t.value.substring(6, 10).replace(/\D/g, "0") || "0"
784
805
  ), ie = h(
785
806
  () => t.value && t.value.substring(13, 15).replace(/\D/g, "0") || "0"
786
- ), X = h(
807
+ ), le = h(
787
808
  () => t.value && t.value.substring(16, 18).replace(/\D/g, "0") || "0"
788
- ), O = h(
809
+ ), K = h(
789
810
  () => t.value && t.value.substring(19, 23).replace(/\D/g, "0") || "0"
790
- ), J = h(() => {
791
- const { start: n, end: s } = g(t.value);
811
+ ), X = h(() => {
812
+ const { start: n, end: c } = y(t.value);
792
813
  return [
793
814
  {
794
815
  label: "Raw",
@@ -804,74 +825,74 @@ function Ge(e) {
804
825
  },
805
826
  {
806
827
  label: "Start",
807
- value: `${String(ae.value).padStart(2, "0")} / ${String(
828
+ value: `${String(Q.value).padStart(2, "0")} / ${String(
808
829
  z.value
809
- ).padStart(2, "0")} / ${String(Y.value).padStart(4, "0")}`
830
+ ).padStart(2, "0")} / ${String(W.value).padStart(4, "0")}`
810
831
  },
811
832
  {
812
833
  label: "End",
813
834
  value: `${String(ie.value).padStart(2, "0")} / ${String(
814
- X.value
815
- ).padStart(2, "0")} / ${String(O.value).padStart(4, "0")}`
835
+ le.value
836
+ ).padStart(2, "0")} / ${String(K.value).padStart(4, "0")}`
816
837
  },
817
- { label: "Digits only", value: w.value },
838
+ { label: "Digits only", value: g.value },
818
839
  { label: "Mask complete", value: `${f.value}` },
819
840
  {
820
841
  label: "Parsed",
821
- value: `${n ? n.toDateString() : "-"} | ${s ? s.toDateString() : "-"}`
842
+ value: `${n ? n.toDateString() : "-"} | ${c ? c.toDateString() : "-"}`
822
843
  },
823
844
  {
824
845
  label: "Valid (managed)",
825
- value: `${F.value ?? "-"}`
846
+ value: `${O.value ?? "-"}`
826
847
  },
827
- { label: "Span (days)", value: `${l.value ?? "-"}` },
848
+ { label: "Span (days)", value: `${p.value ?? "-"}` },
828
849
  {
829
850
  label: "Reason",
830
- value: `${p.value ?? "-"}`
851
+ value: `${s.value ?? "-"}`
831
852
  },
832
853
  {
833
854
  label: "Cursor in",
834
- value: `${c.value ?? "-"} (${(() => {
835
- const E = c.value ?? 0, q = H(E);
836
- return `${q.side}.${q.part}`;
855
+ value: `${u.value ?? "-"} (${(() => {
856
+ const x = u.value ?? 0, R = oe(x);
857
+ return `${R.side}.${R.part}`;
837
858
  })()})`
838
859
  }
839
860
  ];
840
- }), Z = () => {
841
- N(() => {
861
+ }), re = () => {
862
+ j(() => {
842
863
  const n = document.getElementById(e.id);
843
864
  if (!n) {
844
865
  console.warn(`#${e.id} not found for styling.`);
845
866
  return;
846
867
  }
847
- const s = n.closest("div");
848
- if (!s) {
868
+ const c = n.closest("div");
869
+ if (!c) {
849
870
  console.warn(`Parent div of #${e.id} not found for styling.`);
850
871
  return;
851
872
  }
852
- s.classList.contains("fk-daterangepicker") || s.classList.add("fk-daterangepicker");
873
+ c.classList.contains("fk-daterangepicker") || c.classList.add("fk-daterangepicker");
853
874
  });
854
875
  };
855
876
  xe(() => {
856
- Z();
877
+ re();
857
878
  });
858
- const ge = () => {
859
- N(() => {
879
+ const ye = () => {
880
+ j(() => {
860
881
  try {
861
882
  const n = Array.from(
862
883
  document.querySelectorAll(".k-animation-container")
863
884
  );
864
885
  if (!n.length) return;
865
- const E = [...n].reverse().find((le) => le.querySelector(".k-calendar"))?.querySelector(
886
+ const x = [...n].reverse().find((ae) => ae.querySelector(".k-calendar"))?.querySelector(
866
887
  ".k-calendar"
867
888
  );
868
- if (!E) return;
869
- const q = E.querySelectorAll(
889
+ if (!x) return;
890
+ const R = x.querySelectorAll(
870
891
  ".k-calendar-table"
871
892
  );
872
- let ne = !1;
873
- q.forEach((le) => {
874
- le.tabIndex === 0 && (ne ? le.tabIndex = -1 : ne = !0);
893
+ let ee = !1;
894
+ R.forEach((ae) => {
895
+ ae.tabIndex === 0 && (ee ? ae.tabIndex = -1 : ee = !0);
875
896
  });
876
897
  } catch (n) {
877
898
  console.warn(n);
@@ -881,225 +902,225 @@ function Ge(e) {
881
902
  return e.isOpen && ve(
882
903
  e.isOpen,
883
904
  (n) => {
884
- n && setTimeout(() => ge(), 0);
905
+ n && setTimeout(() => ye(), 0);
885
906
  },
886
907
  { immediate: !1 }
887
908
  ), {
888
909
  raw: t,
889
- cursorPos: c,
890
- debugEnabled: P,
891
- debugLines: J,
892
- digitsOnly: w,
893
- valid: F,
894
- validComputed: K(i),
895
- reason: K(p),
896
- validationMessage: K(S),
897
- spanDays: K(l),
898
- month1: K(ae),
899
- day1: K(z),
900
- year1: K(Y),
901
- month2: K(ie),
902
- day2: K(X),
903
- year2: K(O),
904
- handleChange: d,
905
- handleKeyDown: ee,
910
+ cursorPos: u,
911
+ debugEnabled: q,
912
+ debugLines: X,
913
+ digitsOnly: g,
914
+ valid: O,
915
+ validComputed: N(l),
916
+ reason: N(s),
917
+ validationMessage: N(b),
918
+ spanDays: N(p),
919
+ month1: N(Q),
920
+ day1: N(z),
921
+ year1: N(W),
922
+ month2: N(ie),
923
+ day2: N(le),
924
+ year2: N(K),
925
+ handleChange: a,
926
+ handleKeyDown: M,
906
927
  handleWheel: r,
907
- handleKeyUp: u,
908
- handleClick: M,
909
- handleBlur: $,
910
- handleClear: U,
928
+ handleKeyUp: i,
929
+ handleClick: d,
930
+ handleBlur: w,
931
+ handleClear: B,
911
932
  onCalendarChange: () => {
912
- T.value = !0;
933
+ I.value = !0;
913
934
  },
914
- initStyling: Z
935
+ initStyling: re
915
936
  };
916
937
  }
917
- function je(e) {
918
- const t = _(""), c = _(void 0), P = _(!!e.debug), T = _(e.timeFormat ?? "hh:mm AM"), V = h(() => !!e.required), W = _(!1), k = ["ArrowUp", "ArrowDown"], b = ["ArrowLeft", "ArrowRight"], y = h(() => (t.value ?? "").replace(/\D/g, "")), w = {
938
+ function Je(e) {
939
+ const t = _(""), u = _(void 0), q = _(!!e.debug), I = _(e.timeFormat ?? "hh:mm AM"), L = h(() => !!e.required), V = _(!1), A = ["ArrowUp", "ArrowDown"], k = ["ArrowLeft", "ArrowRight"], S = h(() => (t.value ?? "").replace(/\D/g, "")), g = {
919
940
  H: /[0-9]/,
920
941
  h: /[0-9]/,
921
942
  M: /[0-9]/,
922
943
  m: /[0-9]/,
923
944
  A: /[AaPp]/,
924
945
  a: /[Mm]/
925
- }, L = (r) => r <= 2 ? "hh" : r <= 5 ? "mm" : "ampm", D = h(() => {
926
- const r = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0", u = parseInt(r);
927
- return Math.min(Math.max(u, 0), 23);
928
- }), x = h(() => {
929
- const r = t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0", u = parseInt(r);
930
- return Math.min(Math.max(u, 0), 59);
931
- }), C = h(() => (t.value?.substring(6, 8) || "AM").toUpperCase().startsWith("P") ? "PM" : "AM"), R = h(() => {
932
- const r = parseInt(t.value?.substring(0, 2).replace(/\D/g, "0") || "0"), u = C.value;
933
- return r === 12 ? u === "AM" ? 0 : 12 : u === "PM" ? r + 12 : r;
934
- }), f = h(() => g.value ? `${String(R.value).padStart(2, "0")}:${String(x.value).padStart(2, "0")}:00` : null), g = h(
946
+ }, P = (r) => r <= 2 ? "hh" : r <= 5 ? "mm" : "ampm", E = h(() => {
947
+ const r = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0", i = parseInt(r);
948
+ return Math.min(Math.max(i, 0), 23);
949
+ }), C = h(() => {
950
+ const r = t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0", i = parseInt(r);
951
+ return Math.min(Math.max(i, 0), 59);
952
+ }), T = h(() => (t.value?.substring(6, 8) || "AM").toUpperCase().startsWith("P") ? "PM" : "AM"), U = h(() => {
953
+ const r = parseInt(t.value?.substring(0, 2).replace(/\D/g, "0") || "0"), i = T.value;
954
+ return r === 12 ? i === "AM" ? 0 : 12 : i === "PM" ? r + 12 : r;
955
+ }), f = h(() => y.value ? `${String(U.value).padStart(2, "0")}:${String(C.value).padStart(2, "0")}:00` : null), y = h(
935
956
  () => /^(\d{2}):(\d{2})\s([AP]M)$/i.test(t.value ?? "")
936
- ), F = (r, u, v) => {
937
- let $ = r % 12;
938
- return $ === 0 && ($ = 12), `${String($).padStart(2, "0")}:${String(u).padStart(
957
+ ), O = (r, i, m) => {
958
+ let w = r % 12;
959
+ return w === 0 && (w = 12), `${String(w).padStart(2, "0")}:${String(i).padStart(
939
960
  2,
940
961
  "0"
941
- )} ${v}`;
942
- }, o = (r) => {
943
- const u = r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
944
- if (!u) return null;
945
- const v = parseInt(u[1]), $ = parseInt(u[2]), U = u[3].toUpperCase();
946
- if (v < 1 || v > 12 || $ < 0 || $ > 59) return null;
947
- let ae = v % 12;
948
- U === "PM" && (ae += 12);
962
+ )} ${m}`;
963
+ }, G = (r) => {
964
+ const i = r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
965
+ if (!i) return null;
966
+ const m = parseInt(i[1]), w = parseInt(i[2]), B = i[3].toUpperCase();
967
+ if (m < 1 || m > 12 || w < 0 || w > 59) return null;
968
+ let Q = m % 12;
969
+ B === "PM" && (Q += 12);
949
970
  const z = /* @__PURE__ */ new Date();
950
- return z.setSeconds(0, 0), z.setHours(ae), z.setMinutes($), z;
951
- }, m = (r) => {
952
- if (y.value.length === 0) {
971
+ return z.setSeconds(0, 0), z.setHours(Q), z.setMinutes(w), z;
972
+ }, o = (r) => {
973
+ if (S.value.length === 0) {
953
974
  e.onChange({ value: null, event: r });
954
975
  return;
955
976
  }
956
- if (!g.value) {
977
+ if (!y.value) {
957
978
  e.onChange({ value: null, event: r });
958
979
  return;
959
980
  }
960
- const u = o(t.value);
961
- u && i(u) ? e.onChange({ value: u, event: r }) : e.onChange({ value: null, event: r });
962
- }, l = (r) => r.getHours() * 60 + r.getMinutes(), i = (r) => {
963
- const u = e.min ?? void 0, v = e.max ?? void 0, $ = l(r);
964
- if (u) {
965
- const U = l(u);
966
- if ($ < U) return !1;
981
+ const i = G(t.value);
982
+ i && l(i) ? e.onChange({ value: i, event: r }) : e.onChange({ value: null, event: r });
983
+ }, p = (r) => r.getHours() * 60 + r.getMinutes(), l = (r) => {
984
+ const i = e.min ?? void 0, m = e.max ?? void 0, w = p(r);
985
+ if (i) {
986
+ const B = p(i);
987
+ if (w < B) return !1;
967
988
  }
968
- if (v) {
969
- const U = l(v);
970
- if ($ > U) return !1;
989
+ if (m) {
990
+ const B = p(m);
991
+ if (w > B) return !1;
971
992
  }
972
993
  return !0;
973
- }, p = (r) => {
994
+ }, s = (r) => {
974
995
  t.value = r.value;
975
- const u = r.event?.target;
976
- c.value = u?.selectionStart ?? 0;
996
+ const i = r.event?.target;
997
+ u.value = i?.selectionStart ?? 0;
977
998
  try {
978
- const v = c.value ?? 0;
979
- if (L(v) === "ampm" && (t.value ?? "").length >= 8) {
980
- const $ = t.value.charAt(6);
981
- /[Aa]/.test($) ? (t.value = `${t.value.slice(0, 6)}AM${t.value.slice(8)}`, N(() => {
999
+ const m = u.value ?? 0;
1000
+ if (P(m) === "ampm" && (t.value ?? "").length >= 8) {
1001
+ const w = t.value.charAt(6);
1002
+ /[Aa]/.test(w) ? (t.value = `${t.value.slice(0, 6)}AM${t.value.slice(8)}`, j(() => {
982
1003
  requestAnimationFrame(() => {
983
- const U = document.getElementById(
1004
+ const B = document.getElementById(
984
1005
  e.id
985
1006
  );
986
- U && (U.focus(), U.setSelectionRange(8, 8));
1007
+ B && (B.focus(), B.setSelectionRange(8, 8));
987
1008
  });
988
- })) : /[Pp]/.test($) && (t.value = `${t.value.slice(0, 6)}PM${t.value.slice(8)}`, N(() => {
1009
+ })) : /[Pp]/.test(w) && (t.value = `${t.value.slice(0, 6)}PM${t.value.slice(8)}`, j(() => {
989
1010
  requestAnimationFrame(() => {
990
- const U = document.getElementById(
1011
+ const B = document.getElementById(
991
1012
  e.id
992
1013
  );
993
- U && (U.focus(), U.setSelectionRange(8, 8));
1014
+ B && (B.focus(), B.setSelectionRange(8, 8));
994
1015
  });
995
1016
  }));
996
1017
  }
997
1018
  } catch {
998
1019
  }
999
- m(r);
1000
- }, A = (r) => {
1001
- c.value = r.target.selectionStart ?? 0;
1002
- }, S = (r, u, v) => {
1003
- const $ = u?.selectionStart ?? c.value ?? 0;
1004
- c.value = $;
1005
- const U = L($), ae = (t.value ?? "").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
1006
- if (!ae) {
1007
- if ((t.value ?? "").length === 0 || y.value.length === 0) {
1008
- const O = /* @__PURE__ */ new Date(), J = O.getHours(), Z = J >= 12 ? "PM" : "AM";
1009
- t.value = F(J, O.getMinutes(), Z);
1010
- const ge = o(t.value);
1011
- ge && i(ge) ? e.onChange({ value: ge, event: v }) : e.onChange({ value: null, event: v }), N(() => {
1020
+ o(r);
1021
+ }, v = (r) => {
1022
+ u.value = r.target.selectionStart ?? 0;
1023
+ }, b = (r, i, m) => {
1024
+ const w = i?.selectionStart ?? u.value ?? 0;
1025
+ u.value = w;
1026
+ const B = P(w), Q = (t.value ?? "").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
1027
+ if (!Q) {
1028
+ if ((t.value ?? "").length === 0 || S.value.length === 0) {
1029
+ const K = /* @__PURE__ */ new Date(), X = K.getHours(), re = X >= 12 ? "PM" : "AM";
1030
+ t.value = O(X, K.getMinutes(), re);
1031
+ const ye = G(t.value);
1032
+ ye && l(ye) ? e.onChange({ value: ye, event: m }) : e.onChange({ value: null, event: m }), j(() => {
1012
1033
  requestAnimationFrame(() => {
1013
1034
  const n = document.getElementById(
1014
1035
  e.id
1015
- ), s = c.value ?? 0;
1016
- n && (n.focus(), n.setSelectionRange(s, s));
1036
+ ), c = u.value ?? 0;
1037
+ n && (n.focus(), n.setSelectionRange(c, c));
1017
1038
  });
1018
1039
  });
1019
1040
  }
1020
1041
  return;
1021
1042
  }
1022
- let z = parseInt(ae[1]), Y = parseInt(ae[2]), ie = ae[3].toUpperCase();
1023
- if (U === "hh")
1043
+ let z = parseInt(Q[1]), W = parseInt(Q[2]), ie = Q[3].toUpperCase();
1044
+ if (B === "hh")
1024
1045
  r === "ArrowUp" ? z = z < 12 ? z + 1 : 1 : z = z > 1 ? z - 1 : 12;
1025
- else if (U === "mm") {
1026
- const O = e.minuteStepRef?.value ?? e.minuteStep ?? 1;
1027
- if (O === 1)
1028
- r === "ArrowUp" ? Y = Y < 59 ? Y + 1 : 0 : Y = Y > 0 ? Y - 1 : 59;
1046
+ else if (B === "mm") {
1047
+ const K = e.minuteStepRef?.value ?? e.minuteStep ?? 1;
1048
+ if (K === 1)
1049
+ r === "ArrowUp" ? W = W < 59 ? W + 1 : 0 : W = W > 0 ? W - 1 : 59;
1029
1050
  else if (r === "ArrowUp") {
1030
- const J = Y % O;
1031
- let Z = J === 0 ? Y + O : Y + (O - J);
1032
- Z >= 60 && (Z = 0), Y = Z;
1051
+ const X = W % K;
1052
+ let re = X === 0 ? W + K : W + (K - X);
1053
+ re >= 60 && (re = 0), W = re;
1033
1054
  } else {
1034
- const J = Y % O;
1035
- let Z = J === 0 ? Y - O : Y - J;
1036
- Z < 0 && (Z = 60 - O), Y = Z;
1055
+ const X = W % K;
1056
+ let re = X === 0 ? W - K : W - X;
1057
+ re < 0 && (re = 60 - K), W = re;
1037
1058
  }
1038
- } else U === "ampm" && (ie = ie === "AM" ? "PM" : "AM");
1039
- t.value = `${String(z).padStart(2, "0")}:${String(Y).padStart(
1059
+ } else B === "ampm" && (ie = ie === "AM" ? "PM" : "AM");
1060
+ t.value = `${String(z).padStart(2, "0")}:${String(W).padStart(
1040
1061
  2,
1041
1062
  "0"
1042
1063
  )} ${ie}`;
1043
- const X = o(t.value);
1044
- X && i(X) ? e.onChange({ value: X, event: v }) : e.onChange({ value: null, event: v }), N(() => {
1064
+ const le = G(t.value);
1065
+ le && l(le) ? e.onChange({ value: le, event: m }) : e.onChange({ value: null, event: m }), j(() => {
1045
1066
  requestAnimationFrame(() => {
1046
- const O = document.getElementById(
1067
+ const K = document.getElementById(
1047
1068
  e.id
1048
- ), J = c.value ?? 0;
1049
- O && (O.focus(), O.setSelectionRange(J, J));
1069
+ ), X = u.value ?? 0;
1070
+ K && (K.focus(), K.setSelectionRange(X, X));
1050
1071
  });
1051
1072
  });
1052
- }, I = (r) => {
1073
+ }, D = (r) => {
1053
1074
  if (r.code === "Space" || r.key === " ") {
1054
1075
  e.onShowPicker(r);
1055
1076
  return;
1056
1077
  }
1057
- if (k.includes(r.key)) {
1078
+ if (A.includes(r.key)) {
1058
1079
  r.preventDefault();
1059
- const u = r.target;
1060
- S(r.key, u, r);
1080
+ const i = r.target;
1081
+ b(r.key, i, r);
1061
1082
  }
1062
- }, G = (r) => {
1083
+ }, $ = (r) => {
1063
1084
  r.preventDefault();
1064
- const u = r.deltaY < 0 ? "ArrowUp" : "ArrowDown";
1065
- S(u, r.target, r);
1066
- }, oe = (r) => {
1067
- const u = r.target;
1068
- if (b.includes(r.key)) {
1069
- c.value = u?.selectionStart ?? 0;
1085
+ const i = r.deltaY < 0 ? "ArrowUp" : "ArrowDown";
1086
+ b(i, r.target, r);
1087
+ }, H = (r) => {
1088
+ const i = r.target;
1089
+ if (k.includes(r.key)) {
1090
+ u.value = i?.selectionStart ?? 0;
1070
1091
  return;
1071
1092
  }
1072
- k.includes(r.key) && (r.preventDefault(), c.value = u?.selectionStart ?? 0);
1073
- }, Q = (r) => {
1074
- W.value = !0, V.value && e.externalValue && e.externalValue.value === void 0 && y.value.length === 0 && (e.externalValue.value = "");
1075
- const u = r.target;
1076
- u && (c.value = u.selectionStart ?? 0);
1093
+ A.includes(r.key) && (r.preventDefault(), u.value = i?.selectionStart ?? 0);
1094
+ }, J = (r) => {
1095
+ V.value = !0, L.value && e.externalValue && e.externalValue.value === void 0 && S.value.length === 0 && (e.externalValue.value = "");
1096
+ const i = r.target;
1097
+ i && (u.value = i.selectionStart ?? 0);
1077
1098
  };
1078
1099
  e.externalValue && ve(
1079
1100
  e.externalValue,
1080
1101
  (r) => {
1081
1102
  if (r) {
1082
- const u = new Date(r);
1083
- if (u.toString() !== "Invalid Date") {
1084
- const v = u.getHours(), $ = v >= 12 ? "PM" : "AM";
1085
- t.value = F(v, u.getMinutes(), $);
1103
+ const i = new Date(r);
1104
+ if (i.toString() !== "Invalid Date") {
1105
+ const m = i.getHours(), w = m >= 12 ? "PM" : "AM";
1106
+ t.value = O(m, i.getMinutes(), w);
1086
1107
  return;
1087
1108
  }
1088
1109
  }
1089
1110
  },
1090
1111
  { immediate: !0 }
1091
1112
  );
1092
- const H = h(() => [
1113
+ const oe = h(() => [
1093
1114
  ["Time", t.value || "--:-- --"],
1094
- ["Hour (12h)", D.value],
1095
- ["Hour (24h)", R.value],
1096
- ["Minute", x.value],
1097
- ["Period", C.value],
1115
+ ["Hour (12h)", E.value],
1116
+ ["Hour (24h)", U.value],
1117
+ ["Minute", C.value],
1118
+ ["Period", T.value],
1098
1119
  ["Time (24h)", f.value ?? "--:--:--"],
1099
- ["Digits only", y.value],
1120
+ ["Digits only", S.value],
1100
1121
  [
1101
1122
  "Parsed Date",
1102
- j.value?.toLocaleDateString("en-US", {
1123
+ F.value?.toLocaleDateString("en-US", {
1103
1124
  hour: "2-digit",
1104
1125
  minute: "2-digit"
1105
1126
  }) ?? null
@@ -1118,309 +1139,325 @@ function je(e) {
1118
1139
  minute: "2-digit"
1119
1140
  }) ?? null
1120
1141
  ],
1121
- ["valid", a.value],
1122
- ["reason", d.value],
1123
- ["validationMessage", M.value]
1124
- ]), j = h(
1125
- () => o(t.value) ?? null
1126
- ), a = h(() => {
1127
- if (!V.value) {
1128
- if (!g.value) return !0;
1129
- const u = j.value;
1130
- return u ? i(u) : !1;
1142
+ ["valid", ne.value],
1143
+ ["reason", a.value],
1144
+ ["validationMessage", d.value]
1145
+ ]), F = h(
1146
+ () => G(t.value) ?? null
1147
+ ), ne = h(() => {
1148
+ if (!L.value) {
1149
+ if (!y.value) return !0;
1150
+ const i = F.value;
1151
+ return i ? l(i) : !1;
1131
1152
  }
1132
- if (!W.value) return !0;
1133
- const r = j.value;
1134
- return !g.value || !r ? !1 : i(r);
1135
- }), d = h(() => {
1136
- if (!V.value) {
1137
- if (!g.value) return;
1138
- const u = j.value;
1139
- return u ? i(u) ? "valid" : "out-of-bounds" : "invalid-time";
1153
+ if (!V.value) return !0;
1154
+ const r = F.value;
1155
+ return !y.value || !r ? !1 : l(r);
1156
+ }), a = h(() => {
1157
+ if (!L.value) {
1158
+ if (!y.value) return;
1159
+ const i = F.value;
1160
+ return i ? l(i) ? "valid" : "out-of-bounds" : "invalid-time";
1140
1161
  }
1141
- if (!W.value) return;
1142
- if (y.value.length === 0 || !g.value)
1162
+ if (!V.value) return;
1163
+ if (S.value.length === 0 || !y.value)
1143
1164
  return "incomplete";
1144
- const r = j.value;
1145
- return r ? i(r) ? "valid" : "out-of-bounds" : "invalid-time";
1146
- }), M = h(() => {
1147
- const r = d.value;
1165
+ const r = F.value;
1166
+ return r ? l(r) ? "valid" : "out-of-bounds" : "invalid-time";
1167
+ }), d = h(() => {
1168
+ const r = a.value;
1148
1169
  if (!r || r === "valid") return "";
1149
1170
  if (r === "incomplete")
1150
1171
  return "Required";
1151
1172
  if (r === "invalid-time")
1152
- return `Must be in ${T.value} format.`;
1153
- const u = {
1173
+ return `Must be in ${I.value} format.`;
1174
+ const i = {
1154
1175
  hour: "2-digit",
1155
1176
  minute: "2-digit"
1156
- }, v = e.min ? e.min.toLocaleTimeString("en-US", u) : null, $ = e.max ? e.max.toLocaleTimeString("en-US", u) : null;
1177
+ }, m = e.min ? e.min.toLocaleTimeString("en-US", i) : null, w = e.max ? e.max.toLocaleTimeString("en-US", i) : null;
1157
1178
  if (r === "out-of-bounds") {
1158
- if (v && $) return `Must be between ${v} and ${$}.`;
1159
- if (v) return `Must be ${v} or later.`;
1160
- if ($) return `Must be ${$} or earlier.`;
1179
+ if (m && w) return `Must be between ${m} and ${w}.`;
1180
+ if (m) return `Must be ${m} or later.`;
1181
+ if (w) return `Must be ${w} or earlier.`;
1161
1182
  }
1162
1183
  return "";
1163
- }), ee = () => {
1164
- N(() => {
1184
+ }), M = () => {
1185
+ j(() => {
1165
1186
  const r = document.getElementById(e.id);
1166
1187
  if (!r) {
1167
1188
  console.warn(`#${e.id} not found for styling.`);
1168
1189
  return;
1169
1190
  }
1170
- const u = r.closest(".k-timepicker");
1171
- if (!u) {
1191
+ const i = r.closest(".k-timepicker");
1192
+ if (!i) {
1172
1193
  console.warn(
1173
1194
  `.k-timepicker parent of #${e.id} not found for styling.`
1174
1195
  );
1175
1196
  return;
1176
1197
  }
1177
- const v = u.parentElement;
1178
- if (!v) {
1198
+ const m = i.parentElement;
1199
+ if (!m) {
1179
1200
  console.warn(
1180
1201
  `Parent of .k-timepicker not found for #${e.id} styling.`
1181
1202
  );
1182
1203
  return;
1183
1204
  }
1184
- v.classList.contains("fk-timepicker") || v.classList.add("fk-timepicker");
1205
+ m.classList.contains("fk-timepicker") || m.classList.add("fk-timepicker");
1185
1206
  });
1186
1207
  };
1187
1208
  return xe(() => {
1188
- ee();
1209
+ M();
1189
1210
  }), {
1190
1211
  raw: t,
1191
- rules: w,
1192
- debugEnabled: P,
1193
- debugLines: H,
1194
- placeholder: T,
1195
- isValid: a,
1196
- reason: K(d),
1197
- validationMessage: M,
1198
- isComplete: g,
1199
- inRangeTime: i,
1200
- cursorPos: c,
1201
- hour: K(D),
1202
- hour24: K(R),
1203
- minute: K(x),
1204
- period: K(C),
1205
- time24: K(f),
1206
- parsedRawTime: K(j),
1207
- handleChange: p,
1208
- handleKeyDown: I,
1209
- handleKeyUp: oe,
1210
- handleClick: A,
1211
- handleWheel: G,
1212
- handleBlur: Q,
1212
+ rules: g,
1213
+ debugEnabled: q,
1214
+ debugLines: oe,
1215
+ placeholder: I,
1216
+ isValid: ne,
1217
+ reason: N(a),
1218
+ validationMessage: d,
1219
+ isComplete: y,
1220
+ inRangeTime: l,
1221
+ cursorPos: u,
1222
+ hour: N(E),
1223
+ hour24: N(U),
1224
+ minute: N(C),
1225
+ period: N(T),
1226
+ time24: N(f),
1227
+ parsedRawTime: N(F),
1228
+ handleChange: s,
1229
+ handleKeyDown: D,
1230
+ handleKeyUp: H,
1231
+ handleClick: v,
1232
+ handleWheel: $,
1233
+ handleBlur: J,
1213
1234
  // Expose so consumers can reapply theming when Kendo updates DOM
1214
- initStyling: ee
1235
+ initStyling: M
1215
1236
  };
1216
1237
  }
1217
- function Fe(e) {
1238
+ function Ue(e) {
1218
1239
  return Le() ? (Pe(e), !0) : !1;
1219
1240
  }
1220
- const $e = typeof window < "u" && typeof document < "u";
1241
+ const Ce = typeof window < "u" && typeof document < "u";
1221
1242
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
1222
- const Ue = Object.prototype.toString, Oe = (e) => Ue.call(e) === "[object Object]", pe = () => {
1223
- }, Be = /* @__PURE__ */ Ke();
1224
- function Ke() {
1243
+ const Oe = Object.prototype.toString, Be = (e) => Oe.call(e) === "[object Object]", pe = () => {
1244
+ }, Ke = /* @__PURE__ */ Ve();
1245
+ function Ve() {
1225
1246
  var e, t;
1226
- return $e && ((e = window?.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
1247
+ return Ce && ((e = window?.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
1227
1248
  }
1228
1249
  function Ae(e) {
1229
1250
  return Array.isArray(e) ? e : [e];
1230
1251
  }
1231
- function Ve(e, t, c) {
1252
+ function Ye(e, t, u) {
1232
1253
  return ve(
1233
1254
  e,
1234
1255
  t,
1235
1256
  {
1236
- ...c,
1257
+ ...u,
1237
1258
  immediate: !0
1238
1259
  }
1239
1260
  );
1240
1261
  }
1241
- const Ce = $e ? window : void 0;
1242
- function Se(e) {
1262
+ const $e = Ce ? window : void 0;
1263
+ function be(e) {
1243
1264
  var t;
1244
- const c = ce(e);
1245
- return (t = c?.$el) != null ? t : c;
1265
+ const u = ce(e);
1266
+ return (t = u?.$el) != null ? t : u;
1246
1267
  }
1247
1268
  function Ee(...e) {
1248
- const t = [], c = () => {
1249
- t.forEach((k) => k()), t.length = 0;
1250
- }, P = (k, b, y, w) => (k.addEventListener(b, y, w), () => k.removeEventListener(b, y, w)), T = h(() => {
1251
- const k = Ae(ce(e[0])).filter((b) => b != null);
1252
- return k.every((b) => typeof b != "string") ? k : void 0;
1253
- }), V = Ve(
1269
+ const t = [], u = () => {
1270
+ t.forEach((A) => A()), t.length = 0;
1271
+ }, q = (A, k, S, g) => (A.addEventListener(k, S, g), () => A.removeEventListener(k, S, g)), I = h(() => {
1272
+ const A = Ae(ce(e[0])).filter((k) => k != null);
1273
+ return A.every((k) => typeof k != "string") ? A : void 0;
1274
+ }), L = Ye(
1254
1275
  () => {
1255
- var k, b;
1276
+ var A, k;
1256
1277
  return [
1257
- (b = (k = T.value) == null ? void 0 : k.map((y) => Se(y))) != null ? b : [Ce].filter((y) => y != null),
1258
- Ae(ce(T.value ? e[1] : e[0])),
1259
- Ae(Te(T.value ? e[2] : e[1])),
1278
+ (k = (A = I.value) == null ? void 0 : A.map((S) => be(S))) != null ? k : [$e].filter((S) => S != null),
1279
+ Ae(ce(I.value ? e[1] : e[0])),
1280
+ Ae(Fe(I.value ? e[2] : e[1])),
1260
1281
  // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
1261
- ce(T.value ? e[3] : e[2])
1282
+ ce(I.value ? e[3] : e[2])
1262
1283
  ];
1263
1284
  },
1264
- ([k, b, y, w]) => {
1265
- if (c(), !k?.length || !b?.length || !y?.length)
1285
+ ([A, k, S, g]) => {
1286
+ if (u(), !A?.length || !k?.length || !S?.length)
1266
1287
  return;
1267
- const L = Oe(w) ? { ...w } : w;
1288
+ const P = Be(g) ? { ...g } : g;
1268
1289
  t.push(
1269
- ...k.flatMap(
1270
- (D) => b.flatMap(
1271
- (x) => y.map((C) => P(D, x, C, L))
1290
+ ...A.flatMap(
1291
+ (E) => k.flatMap(
1292
+ (C) => S.map((T) => q(E, C, T, P))
1272
1293
  )
1273
1294
  )
1274
1295
  );
1275
1296
  },
1276
1297
  { flush: "post" }
1277
- ), W = () => {
1278
- V(), c();
1298
+ ), V = () => {
1299
+ L(), u();
1279
1300
  };
1280
- return Fe(c), W;
1301
+ return Ue(u), V;
1281
1302
  }
1282
1303
  let Me = !1;
1283
- function Ye(e, t, c = {}) {
1284
- const { window: P = Ce, ignore: T = [], capture: V = !0, detectIframe: W = !1, controls: k = !1 } = c;
1285
- if (!P)
1286
- return k ? { stop: pe, cancel: pe, trigger: pe } : pe;
1287
- if (Be && !Me) {
1304
+ function Ne(e, t, u = {}) {
1305
+ const { window: q = $e, ignore: I = [], capture: L = !0, detectIframe: V = !1, controls: A = !1 } = u;
1306
+ if (!q)
1307
+ return A ? { stop: pe, cancel: pe, trigger: pe } : pe;
1308
+ if (Ke && !Me) {
1288
1309
  Me = !0;
1289
1310
  const f = { passive: !0 };
1290
- Array.from(P.document.body.children).forEach((g) => g.addEventListener("click", pe, f)), P.document.documentElement.addEventListener("click", pe, f);
1311
+ Array.from(q.document.body.children).forEach((y) => y.addEventListener("click", pe, f)), q.document.documentElement.addEventListener("click", pe, f);
1291
1312
  }
1292
- let b = !0;
1293
- const y = (f) => ce(T).some((g) => {
1294
- if (typeof g == "string")
1295
- return Array.from(P.document.querySelectorAll(g)).some((F) => F === f.target || f.composedPath().includes(F));
1313
+ let k = !0;
1314
+ const S = (f) => ce(I).some((y) => {
1315
+ if (typeof y == "string")
1316
+ return Array.from(q.document.querySelectorAll(y)).some((O) => O === f.target || f.composedPath().includes(O));
1296
1317
  {
1297
- const F = Se(g);
1298
- return F && (f.target === F || f.composedPath().includes(F));
1318
+ const O = be(y);
1319
+ return O && (f.target === O || f.composedPath().includes(O));
1299
1320
  }
1300
1321
  });
1301
- function w(f) {
1302
- const g = ce(f);
1303
- return g && g.$.subTree.shapeFlag === 16;
1322
+ function g(f) {
1323
+ const y = ce(f);
1324
+ return y && y.$.subTree.shapeFlag === 16;
1304
1325
  }
1305
- function L(f, g) {
1306
- const F = ce(f), o = F.$.subTree && F.$.subTree.children;
1307
- return o == null || !Array.isArray(o) ? !1 : o.some((m) => m.el === g.target || g.composedPath().includes(m.el));
1326
+ function P(f, y) {
1327
+ const O = ce(f), G = O.$.subTree && O.$.subTree.children;
1328
+ return G == null || !Array.isArray(G) ? !1 : G.some((o) => o.el === y.target || y.composedPath().includes(o.el));
1308
1329
  }
1309
- const D = (f) => {
1310
- const g = Se(e);
1311
- if (f.target != null && !(!(g instanceof Element) && w(e) && L(e, f)) && !(!g || g === f.target || f.composedPath().includes(g))) {
1312
- if ("detail" in f && f.detail === 0 && (b = !y(f)), !b) {
1313
- b = !0;
1330
+ const E = (f) => {
1331
+ const y = be(e);
1332
+ if (f.target != null && !(!(y instanceof Element) && g(e) && P(e, f)) && !(!y || y === f.target || f.composedPath().includes(y))) {
1333
+ if ("detail" in f && f.detail === 0 && (k = !S(f)), !k) {
1334
+ k = !0;
1314
1335
  return;
1315
1336
  }
1316
1337
  t(f);
1317
1338
  }
1318
1339
  };
1319
- let x = !1;
1320
- const C = [
1321
- Ee(P, "click", (f) => {
1322
- x || (x = !0, setTimeout(() => {
1323
- x = !1;
1324
- }, 0), D(f));
1325
- }, { passive: !0, capture: V }),
1326
- Ee(P, "pointerdown", (f) => {
1327
- const g = Se(e);
1328
- b = !y(f) && !!(g && !f.composedPath().includes(g));
1340
+ let C = !1;
1341
+ const T = [
1342
+ Ee(q, "click", (f) => {
1343
+ C || (C = !0, setTimeout(() => {
1344
+ C = !1;
1345
+ }, 0), E(f));
1346
+ }, { passive: !0, capture: L }),
1347
+ Ee(q, "pointerdown", (f) => {
1348
+ const y = be(e);
1349
+ k = !S(f) && !!(y && !f.composedPath().includes(y));
1329
1350
  }, { passive: !0 }),
1330
- W && Ee(P, "blur", (f) => {
1351
+ V && Ee(q, "blur", (f) => {
1331
1352
  setTimeout(() => {
1332
- var g;
1333
- const F = Se(e);
1334
- ((g = P.document.activeElement) == null ? void 0 : g.tagName) === "IFRAME" && !F?.contains(P.document.activeElement) && t(f);
1353
+ var y;
1354
+ const O = be(e);
1355
+ ((y = q.document.activeElement) == null ? void 0 : y.tagName) === "IFRAME" && !O?.contains(q.document.activeElement) && t(f);
1335
1356
  }, 0);
1336
1357
  }, { passive: !0 })
1337
- ].filter(Boolean), R = () => C.forEach((f) => f());
1338
- return k ? {
1339
- stop: R,
1358
+ ].filter(Boolean), U = () => T.forEach((f) => f());
1359
+ return A ? {
1360
+ stop: U,
1340
1361
  cancel: () => {
1341
- b = !1;
1362
+ k = !1;
1342
1363
  },
1343
1364
  trigger: (f) => {
1344
- b = !0, D(f), b = !1;
1365
+ k = !0, E(f), k = !1;
1345
1366
  }
1346
- } : R;
1367
+ } : U;
1347
1368
  }
1348
- function ze(e) {
1349
- const t = Re(null), c = [
1369
+ function Qe(e) {
1370
+ const t = Re(null), u = [
1350
1371
  ".k-animation-container .k-popup",
1351
1372
  ".k-popup",
1352
1373
  ".k-timepicker-popup",
1353
1374
  ".k-menu-popup"
1354
- ], P = Array.isArray(e.popupSelector) ? e.popupSelector : [e.popupSelector ?? c].flat(), T = (w) => w ? typeof e.initialFocus == "string" ? w.querySelector(e.initialFocus) ?? w : typeof e.initialFocus == "function" ? e.initialFocus(w) ?? w : w.querySelector(
1375
+ ], q = Array.isArray(e.popupSelector) ? e.popupSelector : [e.popupSelector ?? u].flat(), I = (g) => g ? typeof e.initialFocus == "string" ? g.querySelector(e.initialFocus) ?? g : typeof e.initialFocus == "function" ? e.initialFocus(g) ?? g : g.querySelector(
1355
1376
  'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
1356
- ) ?? w : null, { activate: V, deactivate: W } = qe(t, {
1377
+ ) ?? g : null, { activate: L, deactivate: V } = qe(t, {
1357
1378
  escapeDeactivates: !1,
1358
1379
  clickOutsideDeactivates: !1,
1359
1380
  fallbackFocus: () => t.value,
1360
- initialFocus: () => T(t.value),
1381
+ initialFocus: () => I(t.value),
1361
1382
  ...e.focusTrapOptions ?? {}
1362
1383
  });
1363
- let k = null, b = _(null);
1364
- const y = () => {
1384
+ let A = null, k = _(null);
1385
+ const S = () => {
1365
1386
  if (e.resolvePopupEl) return e.resolvePopupEl();
1366
- const w = (D, x) => {
1367
- const C = Array.from(D.querySelectorAll(x));
1368
- if (!C.length) return null;
1369
- const R = C.filter(
1387
+ const g = (E, C) => {
1388
+ const T = Array.from(E.querySelectorAll(C));
1389
+ if (!T.length) return null;
1390
+ const U = T.filter(
1370
1391
  (f) => f.offsetParent !== null || f.getClientRects().length > 0
1371
1392
  );
1372
- return R[R.length - 1] ?? C[C.length - 1] ?? null;
1373
- }, L = e.triggerEl?.value?.closest?.(".k-animation-container") ?? document.body;
1374
- for (const D of P) {
1375
- const x = w(L, D);
1376
- if (x) return x;
1393
+ return U[U.length - 1] ?? T[T.length - 1] ?? null;
1394
+ }, P = e.triggerEl?.value?.closest?.(".k-animation-container") ?? document.body;
1395
+ for (const E of q) {
1396
+ const C = g(P, E);
1397
+ if (C) return C;
1377
1398
  }
1378
- for (const D of P) {
1379
- const x = w(document, D);
1380
- if (x) return x;
1399
+ for (const E of q) {
1400
+ const C = g(document, E);
1401
+ if (C) return C;
1381
1402
  }
1382
1403
  return null;
1383
1404
  };
1384
- return Ye(t, (w) => {
1385
- b.value = "outside", e.isOpen.value && e.onRequestClose?.("outside", w);
1405
+ return Ne(t, (g) => {
1406
+ k.value = "outside", e.isOpen.value && e.onRequestClose?.("outside", g);
1386
1407
  }), ve(
1387
1408
  () => e.isOpen.value,
1388
- (w) => {
1389
- w ? (b.value = null, N(() => {
1390
- const L = y();
1391
- L && (t.value = L, setTimeout(() => V(), 0), k || (k = (D) => {
1392
- D.key === "Escape" && (b.value = "escape", e.isOpen.value && e.onRequestClose?.("escape", D));
1393
- }, document.addEventListener("keydown", k, !0)));
1394
- })) : (W(), k && (document.removeEventListener("keydown", k, !0), k = null), t.value = null, b.value === "outside" && N(() => {
1395
- const L = () => {
1396
- const D = e.triggerEl?.value, x = D?.querySelector("input"), C = document.activeElement;
1397
- C && (C === x || D && D.contains(C)) && (x ?? D)?.blur?.();
1409
+ (g) => {
1410
+ g ? (k.value = null, j(() => {
1411
+ const P = S();
1412
+ P && (t.value = P, setTimeout(() => L(), 0), A || (A = (E) => {
1413
+ E.key === "Escape" && (k.value = "escape", e.isOpen.value && e.onRequestClose?.("escape", E));
1414
+ }, document.addEventListener("keydown", A, !0)));
1415
+ })) : (V(), A && (document.removeEventListener("keydown", A, !0), A = null), t.value = null, k.value === "outside" && j(() => {
1416
+ const P = () => {
1417
+ const E = e.triggerEl?.value, C = E?.querySelector("input"), T = document.activeElement;
1418
+ T && (T === C || E && E.contains(T)) && (C ?? E)?.blur?.();
1398
1419
  };
1399
- requestAnimationFrame(() => setTimeout(L, 0));
1400
- }), e.returnFocusToTrigger !== !1 && b.value === "escape" && e.triggerEl?.value && (console.log(
1420
+ requestAnimationFrame(() => setTimeout(P, 0));
1421
+ }), e.returnFocusToTrigger !== !1 && k.value === "escape" && e.triggerEl?.value && (console.log(
1401
1422
  "Returning focus to trigger element:",
1402
1423
  e.triggerEl.value
1403
- ), N(() => {
1404
- const L = () => {
1405
- const D = e.triggerEl?.value;
1406
- if (!D) return;
1407
- (D.querySelector("input") ?? D)?.focus?.();
1424
+ ), j(() => {
1425
+ const P = () => {
1426
+ const E = e.triggerEl?.value;
1427
+ if (!E) return;
1428
+ (E.querySelector("input") ?? E)?.focus?.();
1408
1429
  };
1409
- requestAnimationFrame(() => setTimeout(L, 0));
1430
+ requestAnimationFrame(() => setTimeout(P, 0));
1410
1431
  })));
1411
1432
  }
1412
1433
  ), {
1413
1434
  popupRef: t,
1414
- activate: V,
1415
- deactivate: W,
1416
- lastCloseReason: K(b),
1417
- setPopupEl: (w) => t.value = w
1435
+ activate: L,
1436
+ deactivate: V,
1437
+ lastCloseReason: N(k),
1438
+ setPopupEl: (g) => t.value = g
1418
1439
  };
1419
1440
  }
1441
+ const He = (e) => !!e && typeof e == "object" && "filters" in e && Array.isArray(e.filters), We = (e) => !!e && typeof e == "object" && "field" in e, Ie = (e, t) => !e || typeof e != "object" ? !1 : He(e) ? e.filters.some(
1442
+ (u) => Ie(u, t)
1443
+ ) : We(e) ? e.field === t : !1, Ze = (e) => {
1444
+ const t = _({}), u = (I) => !e.value || !e.value.filters ? !1 : e.value.filters.some(
1445
+ (L) => Ie(L, I)
1446
+ );
1447
+ return {
1448
+ activeClasses: t,
1449
+ hasFieldFilter: u,
1450
+ updateActiveClass: (I) => {
1451
+ const L = u(I);
1452
+ console.log("updateActiveClass for", I, "hasFilter:", L), t.value[I] = L ? "active" : "", console.log("activeClasses after update", t.value);
1453
+ }
1454
+ };
1455
+ };
1420
1456
  export {
1421
- We as useGridA11y,
1422
- _e as useMaskedDateInput,
1423
- Ge as useMaskedDateRangeInput,
1424
- je as useMaskedTimeInput,
1425
- ze as usePopupTrap
1457
+ _e as useGridA11y,
1458
+ Ze as useGridFilter,
1459
+ ze as useMaskedDateInput,
1460
+ Xe as useMaskedDateRangeInput,
1461
+ Je as useMaskedTimeInput,
1462
+ Qe as usePopupTrap
1426
1463
  };