courthive-components 6.10.2 → 6.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3374 @@
1
+ //#region node_modules/.pnpm/timepicker-ui@4.5.0/node_modules/timepicker-ui/dist/index.js
2
+ var e = () => typeof window > "u", t = () => typeof document < "u", n = () => new Intl.DateTimeFormat(void 0, { hour: "numeric" }).resolvedOptions().hour12 ? "12h" : "24h", r = [
3
+ [
4
+ "ui",
5
+ "viewSwitch",
6
+ "ui",
7
+ "enableSwitchIcon"
8
+ ],
9
+ [
10
+ "ui",
11
+ "allowPageScroll",
12
+ "ui",
13
+ "enableScrollbar"
14
+ ],
15
+ [
16
+ "ui",
17
+ "keyboardIcon",
18
+ "ui",
19
+ "iconTemplate"
20
+ ],
21
+ [
22
+ "ui",
23
+ "clockIcon",
24
+ "ui",
25
+ "iconTemplateMobile"
26
+ ],
27
+ [
28
+ "behavior",
29
+ "returnFocus",
30
+ "behavior",
31
+ "focusInputAfterClose"
32
+ ],
33
+ [
34
+ "timezone",
35
+ "list",
36
+ "timezone",
37
+ "whitelist"
38
+ ],
39
+ [
40
+ "labels",
41
+ "clockTitle",
42
+ "labels",
43
+ "time"
44
+ ],
45
+ [
46
+ "labels",
47
+ "keyboardTitle",
48
+ "labels",
49
+ "mobileTime"
50
+ ],
51
+ [
52
+ "labels",
53
+ "clock",
54
+ "labels",
55
+ "clockLabel"
56
+ ],
57
+ [
58
+ "labels",
59
+ "period",
60
+ "labels",
61
+ "periodLabel"
62
+ ],
63
+ [
64
+ "labels",
65
+ "timeFields",
66
+ "labels",
67
+ "timeLabel"
68
+ ],
69
+ [
70
+ "labels",
71
+ "range",
72
+ "labels",
73
+ "rangeSelectionLabel"
74
+ ],
75
+ [
76
+ "labels",
77
+ "switchToKeyboard",
78
+ "labels",
79
+ "switchToKeyboardLabel"
80
+ ],
81
+ [
82
+ "labels",
83
+ "switchToClock",
84
+ "labels",
85
+ "switchToClockLabel"
86
+ ],
87
+ [
88
+ "labels",
89
+ "rangeFrom",
90
+ "range",
91
+ "fromLabel"
92
+ ],
93
+ [
94
+ "labels",
95
+ "rangeTo",
96
+ "range",
97
+ "toLabel"
98
+ ],
99
+ [
100
+ "labels",
101
+ "timezone",
102
+ "timezone",
103
+ "label"
104
+ ]
105
+ ], i = [
106
+ [
107
+ "labels",
108
+ "hour",
109
+ "labels",
110
+ "mobileHour"
111
+ ],
112
+ [
113
+ "labels",
114
+ "hour",
115
+ "labels",
116
+ "hourLabel"
117
+ ],
118
+ [
119
+ "labels",
120
+ "hour",
121
+ "labels",
122
+ "announceHour"
123
+ ],
124
+ [
125
+ "labels",
126
+ "minute",
127
+ "labels",
128
+ "mobileMinute"
129
+ ],
130
+ [
131
+ "labels",
132
+ "minute",
133
+ "labels",
134
+ "minuteLabel"
135
+ ],
136
+ [
137
+ "labels",
138
+ "minute",
139
+ "labels",
140
+ "announceMinute"
141
+ ],
142
+ [
143
+ "ui",
144
+ "appendModalSelector",
145
+ "ui",
146
+ "appendTo"
147
+ ]
148
+ ], a = (e, t, n) => {
149
+ let [r, i, a, o] = e, s = t[r];
150
+ if (!s || !(i in s)) return;
151
+ let c = t[a] ??= {};
152
+ n && o in c || (c[o] = s[i]);
153
+ }, o = (e) => {
154
+ if (e === "now") return !0;
155
+ if (e) return {
156
+ time: e.time === "now" ? void 0 : e.time,
157
+ updateInput: e.updateInput
158
+ };
159
+ }, s = (e) => {
160
+ "defaultTime" in e && (e.currentTime = o(e.defaultTime), delete e.defaultTime), "discreteHourJump" in e && (e.smoothHourSnap = !e.discreteHourJump, delete e.discreteHourJump), e.type === "auto" && (e.type = n());
161
+ let t = e.disabledTime;
162
+ if (t && "ranges" in t) {
163
+ let { ranges: n, ...r } = t;
164
+ e.disabledTime = {
165
+ ...r,
166
+ interval: n
167
+ };
168
+ }
169
+ }, c = (e, t) => {
170
+ if ("initialView" in e && (e.mobile = e.initialView === "keyboard", delete e.initialView), !e.clearButton || typeof e.clearButton != "object") return;
171
+ let { clearInput: n } = e.clearButton;
172
+ e.clearButton = !0, n !== void 0 && ((t.clearBehavior ??= {}).clearInput = n);
173
+ };
174
+ function l(e) {
175
+ let t = {};
176
+ return Object.entries(e).forEach(([e, n]) => {
177
+ t[e] = n ? { ...n } : void 0;
178
+ }), r.forEach((e) => a(e, t, !1)), i.forEach((e) => a(e, t, !0)), [...r, ...i].forEach(([e, n]) => delete t[e]?.[n]), t.clock && s(t.clock), t.ui && c(t.ui, t), t;
179
+ }
180
+ var u = {
181
+ clock: {
182
+ type: "12h",
183
+ incrementHours: 1,
184
+ incrementMinutes: 1,
185
+ autoSwitchToMinutes: !0,
186
+ showSeconds: !1,
187
+ incrementSeconds: 1,
188
+ autoSwitchToSeconds: !0,
189
+ disabledTime: void 0,
190
+ currentTime: void 0
191
+ },
192
+ ui: {
193
+ mode: "clock",
194
+ theme: "basic",
195
+ animation: !0,
196
+ backdrop: !0,
197
+ mobile: !1,
198
+ enableSwitchIcon: !1,
199
+ editable: !1,
200
+ enableScrollbar: !1,
201
+ cssClass: void 0,
202
+ appendTo: "",
203
+ iconTemplate: "",
204
+ iconTemplateMobile: "",
205
+ inline: void 0,
206
+ clearButton: !1
207
+ },
208
+ labels: {
209
+ am: "AM",
210
+ pm: "PM",
211
+ ok: "OK",
212
+ cancel: "Cancel",
213
+ time: "Select time",
214
+ mobileTime: "Enter Time",
215
+ mobileHour: "Hour",
216
+ mobileMinute: "Minute",
217
+ second: "Second",
218
+ clear: "Clear",
219
+ hourLabel: "Hour",
220
+ minuteLabel: "Minute",
221
+ clockLabel: "Clock",
222
+ periodLabel: "Period",
223
+ timeLabel: "Time",
224
+ format24Label: "24-hour",
225
+ rangeSelectionLabel: "Range selection",
226
+ switchToKeyboardLabel: "Switch to keyboard input",
227
+ switchToClockLabel: "Switch to clock",
228
+ toggleLabel: "Toggle",
229
+ timezoneSelectorLabel: "Timezone",
230
+ announceHour: "Hour",
231
+ announceMinute: "Minutes",
232
+ announceAmSelected: "AM selected",
233
+ announcePmSelected: "PM selected",
234
+ invalidTimeFormat: "Invalid time format",
235
+ announceCleared: "Time cleared"
236
+ },
237
+ behavior: {
238
+ focusInputAfterClose: !1,
239
+ focusTrap: !0,
240
+ delayHandler: 0,
241
+ id: void 0
242
+ },
243
+ callbacks: {
244
+ onOpen: void 0,
245
+ onShow: void 0,
246
+ onCancel: void 0,
247
+ onConfirm: void 0,
248
+ onUpdate: void 0,
249
+ onSelectHour: void 0,
250
+ onSelectMinute: void 0,
251
+ onSelectSecond: void 0,
252
+ onSelectAM: void 0,
253
+ onSelectPM: void 0,
254
+ onSelectPeriod: void 0,
255
+ onSwitchView: void 0,
256
+ onSwitchFace: void 0,
257
+ onError: void 0,
258
+ onTimezoneChange: void 0,
259
+ onRangeConfirm: void 0,
260
+ onRangeSwitch: void 0,
261
+ onRangeValidation: void 0,
262
+ onWheelScrollStart: void 0,
263
+ onWheelScrollEnd: void 0,
264
+ onClear: void 0
265
+ },
266
+ timezone: {
267
+ enabled: !1,
268
+ default: void 0,
269
+ whitelist: void 0,
270
+ label: "Timezone"
271
+ },
272
+ range: {
273
+ enabled: !1,
274
+ minDuration: void 0,
275
+ maxDuration: void 0,
276
+ fromLabel: "From",
277
+ toLabel: "To"
278
+ },
279
+ wheel: {
280
+ placement: void 0,
281
+ hideFooter: void 0,
282
+ commitOnScroll: void 0,
283
+ hideDisabled: void 0,
284
+ ignoreOutsideClick: void 0
285
+ },
286
+ clearBehavior: { clearInput: !0 }
287
+ };
288
+ function d(e, t = {}) {
289
+ let n = l(t);
290
+ return {
291
+ ...e,
292
+ clock: {
293
+ ...e.clock,
294
+ ...n.clock
295
+ },
296
+ ui: {
297
+ ...e.ui,
298
+ ...n.ui
299
+ },
300
+ labels: {
301
+ ...e.labels,
302
+ ...n.labels
303
+ },
304
+ behavior: {
305
+ ...e.behavior,
306
+ ...n.behavior
307
+ },
308
+ callbacks: {
309
+ ...e.callbacks,
310
+ ...n.callbacks
311
+ },
312
+ timezone: {
313
+ ...e.timezone,
314
+ ...n.timezone
315
+ },
316
+ range: {
317
+ ...e.range,
318
+ ...n.range
319
+ },
320
+ wheel: {
321
+ ...e.wheel,
322
+ ...n.wheel
323
+ },
324
+ clearBehavior: {
325
+ ...e.clearBehavior,
326
+ ...n.clearBehavior
327
+ }
328
+ };
329
+ }
330
+ function f(e = {}) {
331
+ return d(u, e);
332
+ }
333
+ var p = class {
334
+ _degreesHours = null;
335
+ _degreesMinutes = null;
336
+ _degreesSeconds = null;
337
+ _options;
338
+ _isMobileView = !1;
339
+ _isTouchMouseMove = !1;
340
+ _disabledTime = null;
341
+ _cloned = null;
342
+ _isModalRemove = !0;
343
+ _isOpen = !1;
344
+ _isInitialized = !1;
345
+ _eventHandlersRegistered = !1;
346
+ _isDestroyed = !1;
347
+ _modalElement = null;
348
+ element;
349
+ instanceId;
350
+ customId;
351
+ constructor(e, t, n, r) {
352
+ this.element = e, this.instanceId = n, this.customId = r, this._options = t;
353
+ }
354
+ get degreesHours() {
355
+ return this._degreesHours;
356
+ }
357
+ get degreesMinutes() {
358
+ return this._degreesMinutes;
359
+ }
360
+ get degreesSeconds() {
361
+ return this._degreesSeconds;
362
+ }
363
+ get options() {
364
+ return this._options;
365
+ }
366
+ get isMobileView() {
367
+ return this._isMobileView;
368
+ }
369
+ get isTouchMouseMove() {
370
+ return this._isTouchMouseMove;
371
+ }
372
+ get disabledTime() {
373
+ return this._disabledTime;
374
+ }
375
+ get cloned() {
376
+ return this._cloned;
377
+ }
378
+ get isModalRemove() {
379
+ return this._isModalRemove;
380
+ }
381
+ get isOpen() {
382
+ return this._isOpen;
383
+ }
384
+ get isInitialized() {
385
+ return this._isInitialized;
386
+ }
387
+ get eventHandlersRegistered() {
388
+ return this._eventHandlersRegistered;
389
+ }
390
+ get isDestroyed() {
391
+ return this._isDestroyed;
392
+ }
393
+ setDegreesHours(e) {
394
+ this._degreesHours = e;
395
+ }
396
+ setDegreesMinutes(e) {
397
+ this._degreesMinutes = e;
398
+ }
399
+ setDegreesSeconds(e) {
400
+ this._degreesSeconds = e;
401
+ }
402
+ setOptions(e) {
403
+ this._options = e;
404
+ }
405
+ setIsMobileView(e) {
406
+ this._isMobileView = e;
407
+ }
408
+ setIsTouchMouseMove(e) {
409
+ this._isTouchMouseMove = e;
410
+ }
411
+ setDisabledTime(e) {
412
+ this._disabledTime = e;
413
+ }
414
+ setCloned(e) {
415
+ this._cloned = e;
416
+ }
417
+ setIsModalRemove(e) {
418
+ this._isModalRemove = e;
419
+ }
420
+ setIsOpen(e) {
421
+ this._isOpen = e;
422
+ }
423
+ setIsInitialized(e) {
424
+ this._isInitialized = e;
425
+ }
426
+ setEventHandlersRegistered(e) {
427
+ this._eventHandlersRegistered = e;
428
+ }
429
+ setIsDestroyed(e) {
430
+ this._isDestroyed = e;
431
+ }
432
+ updateOptions(e) {
433
+ this._options = d(this._options, e);
434
+ }
435
+ reset() {
436
+ this._degreesHours = null, this._degreesMinutes = null, this._degreesSeconds = null, this._isTouchMouseMove = !1, this._disabledTime = null, this._cloned = null, this._isModalRemove = !0, this._isOpen = !1, this._isInitialized = !1, this._isDestroyed = !0, this._eventHandlersRegistered = !1, this._modalElement = null;
437
+ }
438
+ q(e) {
439
+ return this.getModalElement()?.querySelector(e) ?? null;
440
+ }
441
+ qMobile(e, t) {
442
+ return this._isMobileView ? this.q(e) : this.q(t);
443
+ }
444
+ getModalElement() {
445
+ if (t() === !1) return null;
446
+ let e = this._modalElement;
447
+ if (e?.isConnected && e.dataset.ownerId === this.instanceId) return e;
448
+ let n = document.querySelectorAll("[data-owner-id]");
449
+ for (let e = 0; e < n.length; e++) if (n[e].dataset.ownerId === this.instanceId) return this._modalElement = n[e], this._modalElement;
450
+ return this._modalElement = null, null;
451
+ }
452
+ getInput() {
453
+ return this.element?.querySelector("input");
454
+ }
455
+ getClockFace() {
456
+ return this.qMobile(".tp-ui-clock-face.mobile", ".tp-ui-clock-face:not(.mobile)") ?? this.q(".tp-ui-clock-face");
457
+ }
458
+ getClockHand() {
459
+ return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-clock-hand", ".tp-ui-clock-hand:not(.mobile)");
460
+ }
461
+ getCircle() {
462
+ return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-circle-hand", ".tp-ui-circle-hand:not(.mobile)");
463
+ }
464
+ getTipsWrapper() {
465
+ return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper", ".tp-ui-tips-wrapper:not(.mobile)");
466
+ }
467
+ getTipsWrapperFor24h() {
468
+ return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper-24h", ".tp-ui-tips-wrapper-24h:not(.mobile)");
469
+ }
470
+ getMinutes() {
471
+ return this.q(".tp-ui-minutes");
472
+ }
473
+ getSeconds() {
474
+ return this.q(".tp-ui-seconds");
475
+ }
476
+ getHour() {
477
+ return this.q(".tp-ui-hour");
478
+ }
479
+ getAM() {
480
+ return this.q(".tp-ui-am");
481
+ }
482
+ getPM() {
483
+ return this.q(".tp-ui-pm");
484
+ }
485
+ getHourText() {
486
+ return this.q(".tp-ui-hour-text");
487
+ }
488
+ getMinutesText() {
489
+ return this.q(".tp-ui-minute-text");
490
+ }
491
+ getSecondsText() {
492
+ return this.q(".tp-ui-second-text");
493
+ }
494
+ getHeader() {
495
+ return this.q(".tp-ui-header");
496
+ }
497
+ getInputWrappers() {
498
+ return this.getModalElement()?.querySelectorAll(".tp-ui-input-wrapper") || null;
499
+ }
500
+ getDots() {
501
+ return this.q(".tp-ui-dots");
502
+ }
503
+ getMinutesTips() {
504
+ return this.q(".tp-ui-minutes-time");
505
+ }
506
+ getHourTips() {
507
+ return this.q(".tp-ui-hour-time-12");
508
+ }
509
+ getAllValueTips() {
510
+ let e = this.getModalElement();
511
+ return e ? [...e.querySelectorAll(".tp-ui-value-tips"), ...e.querySelectorAll(".tp-ui-value-tips-24h")] : [];
512
+ }
513
+ getOpenElementData() {
514
+ let e = this.element?.querySelectorAll("[data-open]");
515
+ if (e?.length > 0) {
516
+ let t = [];
517
+ return e.forEach(({ dataset: e }) => t.push(e.open ?? "")), [...new Set(t)];
518
+ }
519
+ return null;
520
+ }
521
+ getOpenElement() {
522
+ let e = Array.from(this.element.querySelectorAll("[data-open]"));
523
+ if (e.length === 0) {
524
+ let e = this.getInput();
525
+ return e?.setAttribute("data-open", "tp-ui-input"), [e];
526
+ }
527
+ let t = e[0].dataset.open;
528
+ return e.filter((e) => e.dataset.open === t);
529
+ }
530
+ getCancelButton() {
531
+ return this.q(".tp-ui-cancel-btn");
532
+ }
533
+ getOkButton() {
534
+ return this.q(".tp-ui-ok-btn");
535
+ }
536
+ getActiveTypeMode() {
537
+ return this.q(".tp-ui-type-mode.active");
538
+ }
539
+ getActiveType() {
540
+ let e = this.getActiveTypeMode()?.dataset.type;
541
+ return e === "AM" || e === "PM" ? e : void 0;
542
+ }
543
+ getKeyboardClockIcon() {
544
+ return this.q(".tp-ui-keyboard-icon");
545
+ }
546
+ getFooter() {
547
+ return this.q(".tp-ui-footer");
548
+ }
549
+ getWrapper() {
550
+ return this.q(".tp-ui-wrapper");
551
+ }
552
+ }, m = {
553
+ MODAL_EXIT: 150,
554
+ TIPS_ANIMATION: 401,
555
+ MOBILE_TOGGLE: 450,
556
+ CLOCK_SCALE_DELAY: 150,
557
+ WRAPPER_TRANSITION: 400,
558
+ DROPDOWN_CLICK_DELAY: 10,
559
+ ANNOUNCE_DELAY: 100,
560
+ COMMIT_ON_SCROLL_DELAY: 400
561
+ }, h = (e, t) => {
562
+ if (!e) return;
563
+ let n = e.querySelector(".timepicker-announcer");
564
+ n && (n.textContent = "", setTimeout(() => {
565
+ n.textContent = t;
566
+ }, m.ANNOUNCE_DELAY));
567
+ }, g = (e, t, n) => {
568
+ e?.classList.toggle(t, n);
569
+ }, _ = (e, t, n) => {
570
+ n ? e.getAttribute(t) !== n && e.setAttribute(t, n) : e.removeAttribute(t);
571
+ }, v = (e, t) => {
572
+ e && _(e, "aria-pressed", String(t));
573
+ }, y = (e, t) => {
574
+ g(e, "active", t), v(e, t);
575
+ }, b = (e, t, n) => {
576
+ y(e, n === "AM"), y(t, n === "PM");
577
+ }, ee = [
578
+ "aria-label",
579
+ "aria-valuemin",
580
+ "aria-valuemax",
581
+ "aria-valuenow",
582
+ "aria-valuetext"
583
+ ], x = (e) => {
584
+ if (!e) return;
585
+ let t = e.querySelector(".tp-ui-clock-face");
586
+ if (!t) return;
587
+ let n = e.querySelector("input.active") ?? e.querySelector(".tp-ui-hour");
588
+ ee.forEach((e) => _(t, e, n?.getAttribute(e)));
589
+ }, S = (e, t) => {
590
+ if (!e) return;
591
+ e.value = t;
592
+ let n = parseInt(t, 10), r = !Number.isNaN(n);
593
+ _(e, "aria-valuenow", r && String(n)), _(e, "aria-valuetext", r && t), x(e.closest(".tp-ui-modal"));
594
+ }, te = (e) => e.getAttribute("aria-disabled") === "true" || e.classList.contains("disabled"), C = (e, t) => {
595
+ e && (g(e, "disabled", t), _(e, "aria-disabled", String(t)));
596
+ }, ne = "[role=\"button\"], [tabindex], input, select, textarea", re = "button, a[href], summary, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], input[type=\"image\"]", ie = (e) => e.matches(ne) && !e.matches(re), ae = (e) => e === "Enter" || e === " ", w = (e, t) => {
597
+ if (!e) return () => {};
598
+ let n = (n) => {
599
+ te(e) || t(n);
600
+ }, r = (n) => {
601
+ ae(n.key) && ie(e) && (n.key !== "Enter" && n.preventDefault(), !te(e) && t(n));
602
+ };
603
+ return e.addEventListener("click", n), e.addEventListener("keydown", r), () => {
604
+ e.removeEventListener("click", n), e.removeEventListener("keydown", r);
605
+ };
606
+ }, oe = "tp-ui-pointer", se = [
607
+ "Shift",
608
+ "Control",
609
+ "Alt",
610
+ "Meta"
611
+ ], ce = (e) => {
612
+ let t = e.ownerDocument, n = () => g(e, oe, !0), r = (t) => {
613
+ se.includes(t.key) || g(e, oe, !1);
614
+ };
615
+ return e.addEventListener("pointerdown", n, !0), t.addEventListener("keydown", r, !0), () => {
616
+ e.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown", r, !0);
617
+ };
618
+ }, T = () => typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches, le = class {
619
+ core;
620
+ emitter;
621
+ timeouts = [];
622
+ constructor(e, t) {
623
+ this.core = e, this.emitter = t, this.setupEventListeners();
624
+ }
625
+ setupEventListeners() {
626
+ this.emitter.on("animation:clock", () => {
627
+ this.handleAnimationSwitchTipsMode();
628
+ });
629
+ }
630
+ clearAllTimeouts() {
631
+ this.timeouts.forEach(clearTimeout), this.timeouts = [];
632
+ }
633
+ setAnimationToOpen(e = !1) {
634
+ let t = this.core.getModalElement();
635
+ t && (!e && this.core.options.ui.animation && t.offsetHeight, t.classList.add("show"));
636
+ }
637
+ removeAnimationToClose() {
638
+ return this.clearAllTimeouts(), this.core.getModalElement()?.classList.remove("show"), this.core.options.ui.animation && !T() ? m.MODAL_EXIT : 0;
639
+ }
640
+ handleAnimationSwitchTipsMode() {
641
+ let e = this.core.getClockHand();
642
+ if (!e || !this.core.options.ui.animation || T()) return;
643
+ this.emitter.emit("animation:start", {}), e.classList.add("tp-ui-tips-animation");
644
+ let t = setTimeout(() => {
645
+ this.core.getClockHand()?.classList.remove("tp-ui-tips-animation"), this.emitter.emit("animation:end", {});
646
+ }, m.TIPS_ANIMATION);
647
+ this.timeouts.push(t);
648
+ }
649
+ destroy() {
650
+ this.clearAllTimeouts();
651
+ }
652
+ }, ue = "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e3e3e3\"><path d=\"M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z\"/></svg>", de = "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e3e3e3\"><path d=\"m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z\"/></svg>", E = new class {
653
+ plugins = /* @__PURE__ */ new Map();
654
+ register(e) {
655
+ this.plugins.has(e.name) || this.plugins.set(e.name, e);
656
+ }
657
+ getAll() {
658
+ return Array.from(this.plugins.values());
659
+ }
660
+ has(e) {
661
+ return this.plugins.has(e);
662
+ }
663
+ get(e) {
664
+ return this.plugins.get(e);
665
+ }
666
+ getTemplateProvider(e) {
667
+ return this.plugins.get(e)?.templateProvider;
668
+ }
669
+ getClearHandler(e) {
670
+ return this.plugins.get(e)?.clearHandler;
671
+ }
672
+ }(), fe = {
673
+ "&": "&amp;",
674
+ "<": "&lt;",
675
+ ">": "&gt;",
676
+ "\"": "&quot;",
677
+ "'": "&#39;"
678
+ }, D = (e) => String(e ?? "").replace(/[&<>"']/g, (e) => fe[e]), pe = [
679
+ "00",
680
+ "13",
681
+ "14",
682
+ "15",
683
+ "16",
684
+ "17",
685
+ "18",
686
+ "19",
687
+ "20",
688
+ "21",
689
+ "22",
690
+ "23"
691
+ ], me = [
692
+ "12",
693
+ "1",
694
+ "2",
695
+ "3",
696
+ "4",
697
+ "5",
698
+ "6",
699
+ "7",
700
+ "8",
701
+ "9",
702
+ "10",
703
+ "11"
704
+ ], he = [
705
+ "00",
706
+ "05",
707
+ "10",
708
+ "15",
709
+ "20",
710
+ "25",
711
+ "30",
712
+ "35",
713
+ "40",
714
+ "45",
715
+ "50",
716
+ "55"
717
+ ], ge = (e, t, n) => {
718
+ let { timezone: { enabled: r, label: i } } = e;
719
+ if (!r || !E.has("timezone")) return "";
720
+ let a = D(i ?? u.timezone.label), o = D(n);
721
+ return `<div class="tp-ui-timezone ${t}">
722
+ <span class="tp-ui-timezone-label" id="tp-tz-label-${o}">${a}</span>
723
+ <div class="tp-ui-timezone-dropdown" role="combobox" aria-expanded="false" aria-haspopup="listbox" aria-labelledby="tp-tz-label-${o}" tabindex="0" data-tz-id="${o}">
724
+ <div class="tp-ui-timezone-selected" data-md3-ripple data-placeholder="${a}...">${a}...</div>
725
+ <svg class="tp-ui-timezone-arrow" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
726
+ <div class="tp-ui-timezone-menu" role="listbox" aria-labelledby="tp-tz-label-${o}"></div>
727
+ </div>
728
+ </div>`;
729
+ }, _e = (e) => {
730
+ let { range: { enabled: t, fromLabel: n, toLabel: r }, labels: { rangeSelectionLabel: i } } = e;
731
+ return !t || !E.has("range") ? "" : `<div class="tp-ui-range-header" role="tablist" aria-label="${D(i)}"><button type="button" class="tp-ui-range-tab tp-ui-range-from active" data-md3-ripple role="tab" tabindex="0" aria-selected="true"><span class="tp-ui-range-tab-label">${D(n)}</span><span class="tp-ui-range-tab-value tp-ui-range-from-time" aria-hidden="true">--:--</span></button><button type="button" class="tp-ui-range-tab tp-ui-range-to" data-md3-ripple role="tab" tabindex="-1" aria-selected="false"><span class="tp-ui-range-tab-label">${D(r)}</span><span class="tp-ui-range-tab-value tp-ui-range-to-time" aria-hidden="true">--:--</span></button></div>`;
732
+ }, ve = (e, t) => {
733
+ let { ui: { clearButton: n }, labels: { clear: r } } = e;
734
+ if (!n) return "";
735
+ let i = D(r);
736
+ return `<div class="tp-ui-clear-btn ${t} disabled" data-md3-ripple tabindex="0" role="button" aria-label="${i}" aria-disabled="true">${i}</div>`;
737
+ }, ye = (e, t, n) => {
738
+ if (e.isWheelMode) {
739
+ let t = E.getTemplateProvider("wheel");
740
+ return t ? `<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}">${t(n, e.instanceId)}</div>` : `<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"></div>`;
741
+ }
742
+ let { clockLabel: r } = n.labels;
743
+ return `<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"><div class="tp-ui-body ${e.mobileClass}" role="group" aria-label="${D(r)}"><div class="tp-ui-clock-face ${e.mobileClass}" role="slider" tabindex="0"><div class="tp-ui-dot ${e.mobileClass}" aria-hidden="true"></div><div class="tp-ui-clock-hand ${e.mobileClass}" aria-hidden="true"><div class="tp-ui-circle-hand ${e.mobileClass}"></div></div><div class="tp-ui-tips-wrapper ${e.mobileClass}" aria-hidden="true"></div>${e.clockType === "24h" ? `<div class="tp-ui-tips-wrapper-24h ${e.mobileClass}" aria-hidden="true"></div>` : ""}</div></div></div>`;
744
+ }, be = {
745
+ min: "0",
746
+ max: "59",
747
+ valueNow: "0",
748
+ valueText: "00"
749
+ }, xe = (e) => `<div class="tp-ui-dots ${e}" aria-hidden="true"><span></span><span></span></div>`, Se = (e, t, n) => {
750
+ let r = D(e.mobileLabel), i = t ? r : D(e.label);
751
+ return `<div class="tp-ui-input-wrapper ${t}"><div class="tp-ui-input-ripple-wrapper ${t}" data-md3-ripple><input name="${e.name}" ${n ? "readonly" : ""} class="${e.inputClass} ${t}" tabindex="0" type="number" min="${e.min}" max="${e.max}" aria-label="${i}" role="spinbutton" aria-valuemin="${e.min}" aria-valuemax="${e.max}" aria-valuenow="${e.valueNow}" aria-valuetext="${e.valueText}"></div><div class="${e.textClass} ${t}">${r}</div></div>`;
752
+ }, Ce = (e, t) => {
753
+ let { labels: n, ui: { editable: r }, clock: { showSeconds: i } } = e, { mobileClass: a, clockType: o, instanceId: s } = t, c = D(a ? n.mobileTime : n.time), l = D(n.timeLabel), u = D(n.am), d = D(n.pm), f = D(n.periodLabel), p = o === "12h", m = p ? "12" : "0", h = [{
754
+ name: "hour",
755
+ inputClass: "tp-ui-hour",
756
+ textClass: "tp-ui-hour-text",
757
+ min: p ? "1" : "0",
758
+ max: p ? "12" : "23",
759
+ valueNow: m,
760
+ valueText: m,
761
+ label: n.hourLabel,
762
+ mobileLabel: n.mobileHour
763
+ }, {
764
+ name: "minutes",
765
+ inputClass: "tp-ui-minutes",
766
+ textClass: "tp-ui-minute-text",
767
+ ...be,
768
+ label: n.minuteLabel,
769
+ mobileLabel: n.mobileMinute
770
+ }];
771
+ i && h.push({
772
+ name: "seconds",
773
+ inputClass: "tp-ui-seconds",
774
+ textClass: "tp-ui-second-text",
775
+ ...be,
776
+ label: n.second,
777
+ mobileLabel: n.second
778
+ });
779
+ let g = !r && !a, _ = h.map((e) => Se(e, a, g)).join(xe(a)), v = o === "24h" ? "" : `<div class="tp-ui-wrapper-type-time ${a}" role="group" aria-label="${f}"><div class="tp-ui-type-mode tp-ui-am ${a}" data-md3-ripple tabindex="0" role="button" aria-label="${u}" aria-pressed="false" data-type="AM">${u}</div><div class="tp-ui-type-mode tp-ui-pm ${a}" data-md3-ripple tabindex="0" role="button" aria-label="${d}" aria-pressed="false" data-type="PM">${d}</div></div>`;
780
+ return `<div class="tp-ui-select-time ${a}" id="tp-ui-label-${D(s)}">${c}</div><div class="tp-ui-header ${a}"><div class="tp-ui-wrapper-time ${a} ${o === "24h" ? "tp-ui-wrapper-time-24h" : ""}" role="group" aria-label="${l}">${_}</div>${v}</div>`;
781
+ }, we = (e, t) => `<button aria-label="${D(e)}" type="button" class="tp-ui-keyboard-icon">${t}</button>`, Te = (e, t) => {
782
+ let { ui: { enableSwitchIcon: n, iconTemplate: r, iconTemplateMobile: i }, labels: a } = e, o = D(a.cancel), s = D(a.ok), c = t ? we(a.switchToClockLabel, i || de) : we(a.switchToKeyboardLabel, r || ue), l = n ? `<div class="tp-ui-keyboard-icon-wrapper ${t}" data-md3-ripple data-view="desktop">${c}</div>` : "", u = ve(e, t);
783
+ return `<div class="tp-ui-footer ${t}" ${t ? "data-view=\"mobile\"" : ""}>${l}<div class="tp-ui-wrapper-btn ${t}">${u}<div class="tp-ui-cancel-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-label="${o}">${o}</div><div class="tp-ui-ok-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-label="${s}">${s}</div></div></div>`;
784
+ }, Ee = (e, t) => {
785
+ let { ui: { mode: n, animation: r, theme: i, mobile: a }, clock: { incrementMinutes: o, showSeconds: s } } = e, c = a ? "mobile" : "", l = n === "compact-wheel" && E.has("wheel"), u = (n === "wheel" || l) && E.has("wheel"), d = !!e.range?.enabled && E.has("range"), f = !!e.timezone?.enabled && E.has("timezone"), p = {
786
+ mobileClass: c,
787
+ clockType: e.clock.type || "12h",
788
+ instanceId: t,
789
+ isWheelMode: u,
790
+ isCompactWheel: l,
791
+ isRangeMode: d
792
+ }, m = _e(e), h = ge(e, c, t), g = l ? "" : Ce(e, p), _ = ye(p, o ?? 1, e), v = l && e.wheel?.hideFooter === !0 ? "" : Te(e, c), y;
793
+ y = l ? " tp-ui-compact-wheel-mode" : u ? " tp-ui-wheel-mode" : "";
794
+ let b = D(t);
795
+ return `<div class="tp-ui-modal normalize ${c}${d ? " tp-ui-range-mode" : ""}${f ? " tp-ui-tz-mode" : ""}${y}${s ? " tp-ui-has-seconds" : ""}" data-theme="${D(i)}" role="dialog" aria-modal="true" aria-labelledby="tp-ui-label-${b}" data-owner-id="${b}"${r ? "" : " style=\"transition:none\""}><div class="tp-ui-wrapper ${c}" tabindex="0">${m}${g}${h}${_}${v}</div><div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div></div>`;
796
+ };
797
+ function O(e) {
798
+ return e.clock.type === "24h" ? "24h" : "12h";
799
+ }
800
+ function k(e) {
801
+ return {
802
+ clockType: O(e),
803
+ showSeconds: !!e.clock.showSeconds
804
+ };
805
+ }
806
+ function De(e) {
807
+ let t = e.ui.mode;
808
+ return t === "wheel" || t === "compact-wheel";
809
+ }
810
+ function Oe(e) {
811
+ return e.ui.mode === "compact-wheel";
812
+ }
813
+ function A(e) {
814
+ return Oe(e) && !!e.wheel?.placement;
815
+ }
816
+ function j(e) {
817
+ return !!e.ui.inline?.enabled;
818
+ }
819
+ var ke = (e) => !e || !t() ? null : typeof e == "string" ? document.querySelector(e) : e, Ae = (e) => e ? e.container ? ke(e.container) : !e.containerId || !t() ? null : document.getElementById(e.containerId) : null, je = "--tp-scrollbar-gap", Me = ["auto", "scroll"], Ne = /^tp-ui-[\w-]+$/, M = 0, Pe = [], N = "";
820
+ function Fe(e) {
821
+ return Me.includes(window.getComputedStyle(e).overflowY);
822
+ }
823
+ function Ie(e) {
824
+ let { style: t } = e, n = e.clientWidth, r = parseFloat(window.getComputedStyle(e).paddingRight) || 0;
825
+ Pe.push({
826
+ element: e,
827
+ overflowY: t.overflowY,
828
+ paddingRight: t.paddingRight
829
+ }), t.overflowY = "hidden";
830
+ let i = Math.max(0, e.clientWidth - n);
831
+ return i > 0 && (t.paddingRight = `${r + i}px`), i;
832
+ }
833
+ function Le() {
834
+ if (M === 0) {
835
+ let { body: e, documentElement: t } = document, n = Fe(e) ? Ie(e) : 0, r = Ie(t);
836
+ N = t.style.getPropertyValue(je), t.style.setProperty(je, `${Math.max(n, r)}px`);
837
+ }
838
+ M += 1;
839
+ }
840
+ function Re() {
841
+ if (M !== 0 && (--M, M === 0)) {
842
+ Pe.forEach(({ element: e, overflowY: t, paddingRight: n }) => {
843
+ e.style.overflowY = t, e.style.paddingRight = n;
844
+ });
845
+ let e = document.documentElement;
846
+ N ? e.style.setProperty(je, N) : e.style.removeProperty(je), Pe = [], N = "";
847
+ }
848
+ }
849
+ var ze = class {
850
+ core;
851
+ scrollLocked = !1;
852
+ constructor(e, t) {
853
+ this.core = e;
854
+ }
855
+ clearExistingModal() {
856
+ if (t() === !1) return;
857
+ let e = this.core.getModalElement();
858
+ e && e.remove();
859
+ }
860
+ setModalTemplate() {
861
+ if (t() === !1) return;
862
+ this.clearExistingModal();
863
+ let e = Ee(this.core.options, this.core.instanceId);
864
+ if (this.core.options.ui.inline?.enabled) {
865
+ let t = Ae(this.core.options.ui.inline);
866
+ if (!t) return;
867
+ t.innerHTML = "", t.insertAdjacentHTML("beforeend", e);
868
+ let n = t.querySelector(".tp-ui-modal");
869
+ if (n) {
870
+ n.classList.add("tp-ui--inline");
871
+ let { showButtons: e } = this.core.options.ui.inline;
872
+ (e === !1 || e === void 0) && (n.querySelectorAll(".tp-ui-wrapper-btn, .tp-ui-wrapper-btn.mobile").forEach((e) => e.style.display = "none"), n.querySelectorAll(".tp-ui-footer").forEach((e) => {
873
+ e.querySelector(".tp-ui-keyboard-icon-wrapper") || (e.style.display = "none");
874
+ }));
875
+ }
876
+ return;
877
+ }
878
+ let { appendTo: n } = this.core.options.ui;
879
+ (n ? ke(n) : document.body)?.insertAdjacentHTML("beforeend", e);
880
+ }
881
+ lockScroll() {
882
+ t() !== !1 && (this.core.options.ui.inline?.enabled || A(this.core.options) || this.core.options.ui.enableScrollbar || this.scrollLocked || (this.scrollLocked = !0, Le()));
883
+ }
884
+ unlockScroll() {
885
+ t() !== !1 && this.scrollLocked && (this.scrollLocked = !1, Re());
886
+ }
887
+ setScrollbarOrNot() {
888
+ this.core.options.ui.enableScrollbar ? this.unlockScroll() : this.lockScroll();
889
+ }
890
+ removeBackdrop() {
891
+ if (this.core.options.ui.inline?.enabled || this.core.options.ui.backdrop) return;
892
+ let e = this.core.getModalElement(), t = this.core.getOpenElement();
893
+ e?.classList.add("removed"), t.forEach((e) => e?.classList.add("disabled"));
894
+ }
895
+ setNormalizeClass() {
896
+ let e = this.core.getModalElement();
897
+ e && (e.classList.add("tp-ui-normalize"), e.querySelectorAll(":scope > div").forEach((e) => e.classList.add("tp-ui-normalize")));
898
+ }
899
+ setInitialFocus() {
900
+ let { options: e } = this.core;
901
+ !e.behavior.focusTrap || typeof requestAnimationFrame > "u" || !e.ui.backdrop && !e.ui.inline?.enabled && !A(e) || requestAnimationFrame(() => this.focusWrapperUnlessInside());
902
+ }
903
+ focusWrapperUnlessInside() {
904
+ let e = this.core.getWrapper();
905
+ e && !e.contains(e.ownerDocument.activeElement) && e.focus();
906
+ }
907
+ getFocusedControlSelector() {
908
+ let e = this.core.getModalElement(), t = e?.ownerDocument.activeElement;
909
+ return !e || !t || !e.contains(t) ? null : Array.from(t.classList).filter((e) => Ne.test(e)).map((e) => `.${e}`).join("");
910
+ }
911
+ restoreFocus(e) {
912
+ e && this.core.getWrapper()?.querySelector(e)?.focus(), this.focusWrapperUnlessInside();
913
+ }
914
+ setFlexEndToFooterIfNoKeyboardIcon() {
915
+ let e = this.core.getFooter();
916
+ !this.core.options.ui.enableSwitchIcon && e && (e.style.justifyContent = "flex-end");
917
+ }
918
+ destroy() {
919
+ this.unlockScroll(), this.clearExistingModal();
920
+ }
921
+ }, Be = /^(0?[1-9]|1[0-2]):([0-5]?\d)(?::([0-5]?\d))?\s*(AM|PM)$/i, Ve = /^([01]?\d|2[0-3]):([0-5]?\d)(?::([0-5]?\d))?$/, He = /^\s*\d{1,2}:\d{1,2}:\d{1,2}/, P = (e) => String(e).padStart(2, "0");
922
+ function F(e, t) {
923
+ let n = e.trim().match(t.clockType === "12h" ? Be : Ve);
924
+ if (!n) return null;
925
+ let r = {
926
+ hour: P(n[1]),
927
+ minutes: P(n[2])
928
+ };
929
+ return t.showSeconds && (r.seconds = P(n[3] ?? "0")), t.clockType === "12h" && (r.type = n[4].toUpperCase()), r;
930
+ }
931
+ function Ue(e) {
932
+ return He.test(e);
933
+ }
934
+ function I(e, t) {
935
+ let n = `${P(e.hour)}:${P(e.minutes)}`, r = t.showSeconds ? `${n}:${P(e.seconds ?? "0")}` : n;
936
+ return t.clockType === "12h" && e.type ? `${r} ${e.type}` : r;
937
+ }
938
+ var We = (e, t, n) => {
939
+ if (n !== "12h" || !t) return e;
940
+ let r = t.toUpperCase();
941
+ return r === "PM" && e !== 12 ? e + 12 : r === "AM" && e === 12 ? 0 : e;
942
+ };
943
+ function Ge(e, t, n) {
944
+ return n === "24h" ? {
945
+ hour: P(e),
946
+ ...t,
947
+ type: void 0
948
+ } : {
949
+ hour: P(e % 12 || 12),
950
+ ...t,
951
+ type: e >= 12 ? "PM" : "AM"
952
+ };
953
+ }
954
+ function Ke(e, t, n) {
955
+ let r = We(parseInt(e.hour, 10), e.type, t), i = n.showSeconds ? P(e.seconds ?? "0") : void 0;
956
+ return Ge(r, {
957
+ minutes: e.minutes,
958
+ seconds: i
959
+ }, n.clockType);
960
+ }
961
+ function qe(e, t) {
962
+ let n = parseInt(e.hour, 10);
963
+ return Number.isNaN(n) ? 0 : We(n, e.type, t) * 3600;
964
+ }
965
+ function L(e, t) {
966
+ let n = parseInt(e.hour, 10), r = parseInt(e.minutes, 10), i = parseInt(e.seconds ?? "0", 10);
967
+ return Number.isNaN(n) || Number.isNaN(r) || Number.isNaN(i) ? 0 : We(n, e.type, t) * 3600 + r * 60 + i;
968
+ }
969
+ function Je(e) {
970
+ return {
971
+ degreesHours: Number(e.hour) * 30,
972
+ degreesMinutes: Number(e.minutes) * 6
973
+ };
974
+ }
975
+ var Ye = 8, Xe = 11, Ze = ({ hour: e, minutes: t, seconds: n, type: r }) => n === void 0 ? {
976
+ hour: e,
977
+ minutes: t,
978
+ type: r
979
+ } : {
980
+ hour: e,
981
+ minutes: t,
982
+ seconds: n,
983
+ type: r
984
+ }, Qe = (e, t, n) => {
985
+ let r = P(e.getMinutes()), i = n ? P(e.getSeconds()) : void 0;
986
+ return Ze(Ge(e.getHours(), {
987
+ minutes: r,
988
+ seconds: i
989
+ }, t === "24h" ? "24h" : "12h"));
990
+ }, R = (e, t, r, i, a = !1) => {
991
+ let o = Ze({
992
+ hour: "12",
993
+ minutes: "00",
994
+ seconds: a ? "00" : void 0,
995
+ type: t === "24h" ? void 0 : "PM"
996
+ });
997
+ if (!e) return o;
998
+ let s = e.value.trim();
999
+ if (!r && !s) return o;
1000
+ if (typeof r == "boolean" && r) return Qe(/* @__PURE__ */ new Date(), t, a);
1001
+ if (typeof r == "object") {
1002
+ let { time: e, preventClockType: o } = r, s = new Date(e ?? /* @__PURE__ */ new Date());
1003
+ return o && i ? Qe(s, n(), a) : Qe(s, t, a);
1004
+ }
1005
+ let c = F(s, {
1006
+ clockType: t === "24h" ? "24h" : "12h",
1007
+ showSeconds: a
1008
+ });
1009
+ if (c) return Ze(c);
1010
+ let [l, u] = s.split(" "), [d = "", f = "", p = ""] = l.split(":"), m = d.replace(/\D/g, ""), h = f.replace(/\D/g, ""), g = a ? p.replace(/\D/g, "") : "", _ = {
1011
+ hour: m.padStart(2, "0"),
1012
+ minutes: h.padStart(2, "0"),
1013
+ type: t === "12h" ? u : void 0
1014
+ };
1015
+ if (a && (_.seconds = g.padStart(2, "0")), m.length > 2 || h.length > 2 || g.length > 2) return {
1016
+ ..._,
1017
+ error: "Invalid input: too many digits.",
1018
+ currentHour: d,
1019
+ currentMin: f,
1020
+ ...a ? { currentSec: p } : {}
1021
+ };
1022
+ if (/[a-z]/i.test(l)) return {
1023
+ ..._,
1024
+ error: "Input contains invalid letters."
1025
+ };
1026
+ if (s.includes(" ")) {
1027
+ let e = a ? Xe : Ye;
1028
+ if (!u || s.length > e || u !== "AM" && u !== "PM") return {
1029
+ ..._,
1030
+ error: "Invalid AM/PM format or length.",
1031
+ currentLength: s.length,
1032
+ currentType: u
1033
+ };
1034
+ }
1035
+ let v = Number(m), y = Number(h), b = Number(g), ee = y >= 0 && y <= 59 && b >= 0 && b <= 59, x = a ? { currentSec: b } : {};
1036
+ if (t === "12h") {
1037
+ if (v < 1 || v > 12 || !ee || u !== "AM" && u !== "PM") return {
1038
+ ..._,
1039
+ error: "Invalid 12h time.",
1040
+ currentHour: v,
1041
+ currentMin: y,
1042
+ ...x,
1043
+ currentType: u
1044
+ };
1045
+ } else if (v < 0 || v > 23 || !ee) return {
1046
+ ..._,
1047
+ error: "Invalid 24h time.",
1048
+ currentHour: v,
1049
+ currentMin: y,
1050
+ ...x
1051
+ };
1052
+ return _;
1053
+ }, $e = (e, t, n) => {
1054
+ let r = Number(e);
1055
+ if (Number.isNaN(r)) return !1;
1056
+ switch (t) {
1057
+ case "hour": return n === "24h" ? r >= 0 && r <= 23 : r > 0 && r <= 12;
1058
+ case "minutes": return r >= 0 && r <= 59;
1059
+ default: return;
1060
+ }
1061
+ }, et = 256, z = /* @__PURE__ */ new Map(), tt = (e, t) => (z.size >= et && z.clear(), z.set(e, t), t);
1062
+ function nt(e, t) {
1063
+ let n = `${t}|${e}`, r = z.get(n);
1064
+ if (r !== void 0) return r;
1065
+ let i = e.split("-").map((e) => e.trim()), a = null;
1066
+ if (i.length === 2) {
1067
+ let n = F(i[0], {
1068
+ clockType: t,
1069
+ showSeconds: !0
1070
+ }), r = F(i[1], {
1071
+ clockType: t,
1072
+ showSeconds: !0
1073
+ });
1074
+ if (n && r) {
1075
+ let o = Ue(i[1]) ? 0 : 59;
1076
+ a = {
1077
+ start: L(n, t),
1078
+ end: L(r, t) + o,
1079
+ source: e
1080
+ };
1081
+ }
1082
+ }
1083
+ return tt(n, a);
1084
+ }
1085
+ var rt = [], it = /* @__PURE__ */ new WeakMap(), at = (e, t, n) => {
1086
+ if (e.clockType !== n || e.sources.length !== t.length) return !1;
1087
+ for (let n = 0; n < t.length; n++) if (e.sources[n] !== t[n]) return !1;
1088
+ return !0;
1089
+ }, B = (e, t) => {
1090
+ if (!e?.length) return rt;
1091
+ let n = it.get(e);
1092
+ if (n && at(n, e, t)) return n.ranges;
1093
+ let r = e.map((e) => nt(e, t)).filter((e) => e !== null);
1094
+ return it.set(e, {
1095
+ clockType: t,
1096
+ sources: [...e],
1097
+ ranges: r
1098
+ }), r;
1099
+ }, ot = (e, t) => {
1100
+ for (let n = 0; n < e.length; n++) if (t >= e[n].start && t <= e[n].end) return !0;
1101
+ return !1;
1102
+ };
1103
+ function st(e, t) {
1104
+ let n = B(e, t);
1105
+ for (let e = 0; e < n.length; e++) for (let t = e + 1; t < n.length; t++) if (n[e].start <= n[t].end && n[t].start <= n[e].end) return [n[e].source, n[t].source];
1106
+ return null;
1107
+ }
1108
+ var V = (e, t) => {
1109
+ if (!e || t === void 0) return !1;
1110
+ let n = Number(t);
1111
+ for (let t = 0; t < e.length; t++) if (Number(e[t]) === n) return !0;
1112
+ return !1;
1113
+ }, ct = (e, t, n, r) => {
1114
+ if (!r) return ot(t, n);
1115
+ for (let r = 0; r < 60; r++) if (!V(e.seconds, r) && !ot(t, n + r)) return !1;
1116
+ return !0;
1117
+ };
1118
+ function lt(e, t) {
1119
+ return e ? V(e.hours, t.hour) || V(e.minutes, t.minutes) || V(e.seconds, t.seconds) ? !0 : e.intervals?.length ? ot(B(e.intervals, e.clockType), L(t, e.clockType)) : !1 : !1;
1120
+ }
1121
+ function ut(e, t, n) {
1122
+ if (!e) return !1;
1123
+ if (V(e.hours, t.hour) || V(e.minutes, t.minutes)) return !0;
1124
+ let r = L(t, e.clockType), i = r - r % 60;
1125
+ return ct(e, B(e.intervals, e.clockType), i, n);
1126
+ }
1127
+ function dt(e, t, n) {
1128
+ if (!e) return !1;
1129
+ if (V(e.hours, t.hour)) return !0;
1130
+ if (!e.intervals?.length) return !1;
1131
+ let r = B(e.intervals, e.clockType), i = qe(t, e.clockType);
1132
+ for (let t = 0; t < 60; t++) {
1133
+ let a = i + t * 60;
1134
+ if (!V(e.minutes, t) && !ct(e, r, a, n)) return !1;
1135
+ }
1136
+ return !0;
1137
+ }
1138
+ function ft(e, t, n, r) {
1139
+ return t === "hour" ? dt(e, n, r) : t === "minutes" ? ut(e, n, r) : lt(e, n);
1140
+ }
1141
+ function pt(e, t, n, r) {
1142
+ let i = n - t + 1;
1143
+ for (let n = 0; n <= i / 2; n++) for (let a of [e + n, e - n]) {
1144
+ let e = t + ((a - t) % i + i) % i;
1145
+ if (!r(e)) return e;
1146
+ }
1147
+ return e;
1148
+ }
1149
+ var mt = (e, t) => e % 12 % t == 0, H = {
1150
+ hour: {
1151
+ input: "getHour",
1152
+ event: "select:hour",
1153
+ announce: "announceHour"
1154
+ },
1155
+ minutes: {
1156
+ input: "getMinutes",
1157
+ event: "select:minute",
1158
+ announce: "announceMinute"
1159
+ },
1160
+ seconds: {
1161
+ input: "getSeconds",
1162
+ event: "select:second",
1163
+ announce: "second"
1164
+ }
1165
+ }, U = [
1166
+ "hour",
1167
+ "minutes",
1168
+ "seconds"
1169
+ ], W = (e, t) => e[H[t].input](), G = (e, t, n) => {
1170
+ e.emit(H[t].event, { [t]: n });
1171
+ }, ht = (e) => U.find((t) => W(e, t)?.classList.contains("active")) ?? "hour", gt = (e, t) => {
1172
+ U.forEach((n) => g(W(e, n), "active", n === t)), x(e.getModalElement());
1173
+ }, _t = (e, t) => {
1174
+ let n = W(e, t);
1175
+ if (!n) return;
1176
+ let r = e.options.labels[H[t].announce];
1177
+ h(e.getModalElement(), `${r}: ${n.value}`);
1178
+ };
1179
+ function K(e) {
1180
+ let t = {
1181
+ hour: e.getHour()?.value,
1182
+ minutes: e.getMinutes()?.value,
1183
+ type: e.getActiveType()
1184
+ };
1185
+ return e.options.clock.showSeconds && (t.seconds = e.getSeconds()?.value ?? "00"), t;
1186
+ }
1187
+ var vt = (e, t) => t === "hour" ? e.options.clock.type === "12h" ? [1, 12] : [0, 23] : [0, 59], yt = (e, t, n) => {
1188
+ let r = e.disabledTime?.value;
1189
+ return ft(r ? {
1190
+ ...r,
1191
+ clockType: O(e.options)
1192
+ } : null, t, n, !!e.options.clock.showSeconds);
1193
+ }, bt = (e, t) => {
1194
+ let n = K(e);
1195
+ return (r) => yt(e, t, {
1196
+ ...n,
1197
+ [t]: P(r)
1198
+ });
1199
+ }, xt = (e) => {
1200
+ let t = K(e), n = e.options.clock.showSeconds ? "seconds" : "minutes";
1201
+ return !!t.hour && !!t.minutes && yt(e, n, t);
1202
+ }, St = " - ", Ct = 2, wt = (e) => e !== null, Tt = class {
1203
+ core;
1204
+ emitter;
1205
+ constructor(e, t) {
1206
+ this.core = e, this.emitter = t;
1207
+ }
1208
+ isCurrentTimeEnabled(e) {
1209
+ let t = this.core.options.clock.currentTime;
1210
+ return typeof t == "boolean" ? t : !!t?.[e];
1211
+ }
1212
+ preventClockTypeByCurrentTime() {
1213
+ if (!this.isCurrentTimeEnabled("preventClockType")) return;
1214
+ let e = this.core.getInput();
1215
+ if (!e) return;
1216
+ let { currentTime: t, type: n } = this.core.options.clock, { type: r } = R(e, n, t, !0);
1217
+ this.core.updateOptions({ clock: { type: r ? "12h" : "24h" } });
1218
+ }
1219
+ updateInputValueWithCurrentTimeOnStart() {
1220
+ if (!this.isCurrentTimeEnabled("updateInput")) return;
1221
+ let e = this.core.getInput();
1222
+ if (!e) return;
1223
+ let { clock: t } = this.core.options, n = k(this.core.options);
1224
+ e.value = I(R(e, t.type, t.currentTime, void 0, n.showSeconds), n);
1225
+ }
1226
+ syncInputFormat(e) {
1227
+ let t = k(e), n = k(this.core.options);
1228
+ if (t.clockType === n.clockType && t.showSeconds === n.showSeconds) return;
1229
+ let r = this.core.getInput();
1230
+ if (!r) return;
1231
+ let i = r.value.split(St).map((e) => F(e, t));
1232
+ i.length > Ct || !i.every(wt) || (r.value = i.map((e) => I(Ke(e, t.clockType, n), n)).join(St));
1233
+ }
1234
+ getInputValueOnOpenAndSet(e = !0) {
1235
+ let t = this.core.getInput();
1236
+ if (!t) return;
1237
+ let { clock: n } = this.core.options, r = k(this.core.options), i = t.value.trim() ? void 0 : n.currentTime, a = R(t, n.type, i, void 0, r.showSeconds);
1238
+ U.forEach((e) => {
1239
+ let t = a[e];
1240
+ t !== void 0 && S(W(this.core, e), t);
1241
+ }), r.clockType === "12h" && this.activatePeriod(a.type ?? "AM"), e && this.emitter.emit("open", {
1242
+ ...a,
1243
+ type: this.core.getActiveType(),
1244
+ ...Je(a)
1245
+ });
1246
+ }
1247
+ activatePeriod(e) {
1248
+ if (e !== "AM" && e !== "PM") return;
1249
+ let t = this.core.getModalElement(), n = (e) => t?.querySelector(`[data-type='${e}']`);
1250
+ b(n("AM"), n("PM"), e);
1251
+ }
1252
+ destroy() {}
1253
+ }, Et = "(orientation: landscape) and (max-height: 480px)", Dt = "tp-ui-view-switching", Ot = [
1254
+ "select-time",
1255
+ "keyboard-icon-wrapper",
1256
+ "hour",
1257
+ "minutes",
1258
+ "seconds",
1259
+ "hour-text",
1260
+ "minute-text",
1261
+ "second-text",
1262
+ "header",
1263
+ "wrapper-type-time",
1264
+ "am",
1265
+ "pm",
1266
+ "input-wrapper",
1267
+ "input-ripple-wrapper"
1268
+ ].map((e) => `.tp-ui-${e}`).join(","), kt = [
1269
+ [
1270
+ ".tp-ui-hour",
1271
+ "hourLabel",
1272
+ "mobileHour"
1273
+ ],
1274
+ [
1275
+ ".tp-ui-minutes",
1276
+ "minuteLabel",
1277
+ "mobileMinute"
1278
+ ],
1279
+ [
1280
+ ".tp-ui-seconds",
1281
+ "second",
1282
+ "second"
1283
+ ]
1284
+ ], At = (e) => {
1285
+ if (typeof requestAnimationFrame > "u") {
1286
+ e();
1287
+ return;
1288
+ }
1289
+ requestAnimationFrame(() => e());
1290
+ }, q = (e) => {
1291
+ e?.classList.remove("mobile"), e?.classList.add("expanded");
1292
+ }, jt = class {
1293
+ core;
1294
+ emitter;
1295
+ animatingModal = null;
1296
+ constructor(e, t) {
1297
+ this.core = e, this.emitter = t, this.setupEventListeners();
1298
+ }
1299
+ setupEventListeners() {
1300
+ this.emitter.on("switch:view", () => {
1301
+ this.toggleMobileClockFace();
1302
+ });
1303
+ }
1304
+ checkMobileOption() {
1305
+ this.core.setIsMobileView(!!this.core.options.ui.mobile);
1306
+ }
1307
+ toggleMobileClockFace() {
1308
+ let e = this.core.getModalElement();
1309
+ if (!e || this.animatingModal === e) return;
1310
+ let t = e.querySelector(".tp-ui-wrapper");
1311
+ if (!t) return;
1312
+ let n = {
1313
+ modal: e,
1314
+ wrapper: t,
1315
+ clockWrapper: e.querySelector(".tp-ui-mobile-clock-wrapper"),
1316
+ heading: e.querySelector(".tp-ui-select-time"),
1317
+ clockFace: this.core.getClockFace(),
1318
+ switchButton: this.core.getKeyboardClockIcon(),
1319
+ allElements: e.querySelectorAll("*"),
1320
+ isOriginallyMobile: this.core.isMobileView
1321
+ };
1322
+ this.animatingModal = e;
1323
+ let r = t.classList.contains("expanded");
1324
+ this.isLandscape() ? this.switchLandscape(n, r) : r ? At(() => this.collapsePortrait(n)) : this.expandPortrait(n);
1325
+ }
1326
+ switchLandscape(e, t) {
1327
+ let { modal: n, wrapper: r, clockWrapper: i, clockFace: a } = e, o = this.core.options.ui.animation && !T();
1328
+ if (o && n.classList.add(Dt), t ? (a?.classList.remove("scale-in"), i?.classList.add("mobile"), this.finishCollapse(e)) : (this.showClockView(e), q(r), q(i), a?.classList.add("scale-in")), !o) {
1329
+ this.release(e);
1330
+ return;
1331
+ }
1332
+ setTimeout(() => {
1333
+ n.classList.remove(Dt), this.release(e);
1334
+ }, m.WRAPPER_TRANSITION);
1335
+ }
1336
+ collapsePortrait(e) {
1337
+ e.clockFace?.classList.toggle("scale-in", !e.isOriginallyMobile), e.clockWrapper?.classList.remove("expanded"), e.isOriginallyMobile && e.clockWrapper?.classList.add("mobile"), At(() => {
1338
+ this.finishCollapse(e), setTimeout(() => this.release(e), m.MOBILE_TOGGLE);
1339
+ });
1340
+ }
1341
+ finishCollapse(e) {
1342
+ let { wrapper: t, clockWrapper: n, isOriginallyMobile: r } = e;
1343
+ t.classList.remove("expanded"), t.classList.add("mobile"), n?.classList.remove("expanded"), r && n?.classList.add("mobile"), e.allElements.forEach((e) => {
1344
+ e === t || e === n || (e.classList.remove("expanded"), r && e.classList.add("mobile"));
1345
+ }), this.switchView(e, !0);
1346
+ }
1347
+ showClockView(e) {
1348
+ let { wrapper: t, clockWrapper: n } = e;
1349
+ this.selectActiveField(), e.allElements.forEach((e) => {
1350
+ e !== t && e !== n && q(e);
1351
+ }), this.switchView(e, !1);
1352
+ }
1353
+ expandPortrait(e) {
1354
+ let { wrapper: t, clockWrapper: n, clockFace: r } = e;
1355
+ this.showClockView(e), At(() => {
1356
+ q(t), At(() => {
1357
+ q(n), r?.classList.remove("scale-in"), setTimeout(() => r?.classList.add("scale-in"), m.CLOCK_SCALE_DELAY), setTimeout(() => this.release(e), m.MOBILE_TOGGLE);
1358
+ });
1359
+ });
1360
+ }
1361
+ selectActiveField() {
1362
+ let e = ht(this.core), t = W(this.core, e);
1363
+ t && G(this.emitter, e, t.value);
1364
+ }
1365
+ switchView(e, t) {
1366
+ let { modal: n, heading: r } = e, { labels: i, ui: a } = this.core.options, o = !t && !a.editable;
1367
+ n.querySelectorAll(Ot).forEach((e) => e.classList.toggle("mobile", t)), kt.forEach(([e, r, a]) => {
1368
+ let s = n.querySelector(e);
1369
+ s && (s.toggleAttribute("readonly", o), _(s, "aria-label", i[t ? a : r]));
1370
+ }), x(n);
1371
+ let s = t ? i.mobileTime : i.time;
1372
+ r && s && (r.textContent = s), this.setClockFaceHidden(e.clockFace, t), this.renderSwitchButton(e.switchButton, t);
1373
+ }
1374
+ renderSwitchButton(e, t) {
1375
+ if (!e) return;
1376
+ let { iconTemplate: n, iconTemplateMobile: r } = this.core.options.ui, { switchToKeyboardLabel: i, switchToClockLabel: a } = this.core.options.labels;
1377
+ t ? (e.innerHTML = r || de, e.setAttribute("aria-label", a ?? "")) : (e.innerHTML = n || ue, e.setAttribute("aria-label", i ?? ""));
1378
+ }
1379
+ updateClockFaceAccessibility(e) {
1380
+ this.setClockFaceHidden(this.core.getClockFace(), e);
1381
+ }
1382
+ setClockFaceHidden(e, t) {
1383
+ e && (e.tabIndex = t ? -1 : 0, _(e, "aria-hidden", t && "true"));
1384
+ }
1385
+ isLandscape() {
1386
+ return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(Et).matches;
1387
+ }
1388
+ release(e) {
1389
+ this.animatingModal === e.modal && (this.animatingModal = null);
1390
+ }
1391
+ destroy() {
1392
+ this.animatingModal = null;
1393
+ }
1394
+ }, Mt = (e, t) => e ? e.classList.contains(t) : !1, Nt = (e, t) => {
1395
+ e.forEach((e) => {
1396
+ if (!nt(e, t)) throw Error(`Invalid ${t} format: "${e}"`);
1397
+ });
1398
+ let n = st(e, t);
1399
+ if (n) throw Error(`Overlapping intervals: "${n[0]}" and "${n[1]}"`);
1400
+ return !1;
1401
+ }, Pt = () => typeof window < "u" && window.crypto && typeof window.crypto.randomUUID == "function" ? window.crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
1402
+ let t = Math.random() * 16 | 0;
1403
+ return (e === "x" ? t : t & 3 | 8).toString(16);
1404
+ }), Ft = (e, t) => (e?.forEach((e) => {
1405
+ if (Number(e) > 59) throw Error(`The disabled ${t} value has to be less than 60`);
1406
+ }), e?.map((e) => P(Number(e)))), It = (e) => {
1407
+ if (!e) return;
1408
+ let { disabledTime: t, type: n } = e.clock;
1409
+ if (!t || !Object.keys(t).length) return;
1410
+ let { hours: r, minutes: i, seconds: a, interval: o } = t;
1411
+ if (o) {
1412
+ let t = Array.isArray(o) ? o : [o];
1413
+ if (!n) throw Error("clockType required for interval");
1414
+ return Nt(t, O(e)), { value: {
1415
+ isInterval: !0,
1416
+ clockType: n,
1417
+ intervals: t
1418
+ } };
1419
+ }
1420
+ r?.forEach((e) => {
1421
+ if (n === "12h" && Number(e) > 12) throw Error("The disabled hours value has to be less than 13");
1422
+ if (n === "24h" && Number(e) > 23) throw Error("The disabled hours value has to be less than 24");
1423
+ });
1424
+ let s = Ft(i, "minutes"), c = Ft(a, "seconds");
1425
+ return { value: {
1426
+ hours: r?.map((e) => e === "00" || Number(e) === 0 ? `0${Number(e)}` : `${Number(e)}`),
1427
+ minutes: s,
1428
+ seconds: c
1429
+ } };
1430
+ }, Lt = (e, t, n, r) => {
1431
+ if (e) {
1432
+ if (Array.isArray(e)) return !e.map((e) => $e(e, t, n)).some((e) => e === !1);
1433
+ if (typeof e == "string" || typeof e == "number") {
1434
+ let i = $e(e, t, n), a = r?.map(Number).includes(Number(e));
1435
+ return !(!i || a);
1436
+ }
1437
+ }
1438
+ }, Rt = class {
1439
+ core;
1440
+ constructor(e) {
1441
+ this.core = e;
1442
+ }
1443
+ getDisableTime() {
1444
+ let e = It(this.core.options);
1445
+ this.core.setDisabledTime(e || null);
1446
+ }
1447
+ destroy() {}
1448
+ }, zt = class {
1449
+ inputValueHandler;
1450
+ mobileViewHandler;
1451
+ disabledTimeHandler;
1452
+ constructor(e, t) {
1453
+ this.inputValueHandler = new Tt(e, t), this.mobileViewHandler = new jt(e, t), this.disabledTimeHandler = new Rt(e);
1454
+ }
1455
+ preventClockTypeByCurrentTime() {
1456
+ this.inputValueHandler.preventClockTypeByCurrentTime();
1457
+ }
1458
+ updateInputValueWithCurrentTimeOnStart() {
1459
+ this.inputValueHandler.updateInputValueWithCurrentTimeOnStart();
1460
+ }
1461
+ getInputValueOnOpenAndSet(e = !0) {
1462
+ this.inputValueHandler.getInputValueOnOpenAndSet(e);
1463
+ }
1464
+ syncInputFormat(e) {
1465
+ this.inputValueHandler.syncInputFormat(e);
1466
+ }
1467
+ checkMobileOption() {
1468
+ this.mobileViewHandler.checkMobileOption();
1469
+ }
1470
+ updateClockFaceAccessibility(e) {
1471
+ this.mobileViewHandler.updateClockFaceAccessibility(e);
1472
+ }
1473
+ getDisableTime() {
1474
+ this.disabledTimeHandler.getDisableTime();
1475
+ }
1476
+ destroy() {
1477
+ this.inputValueHandler.destroy(), this.mobileViewHandler.destroy(), this.disabledTimeHandler.destroy();
1478
+ }
1479
+ }, Bt = "tp-ui", Vt = "active", Ht = class {
1480
+ core;
1481
+ constructor(e, t) {
1482
+ this.core = e;
1483
+ }
1484
+ setInputClassToInputElement() {
1485
+ let e = this.core.getInput();
1486
+ e && (Mt(e, "tp-ui-input") || e.classList.add("tp-ui-input"));
1487
+ }
1488
+ setDataOpenToInputIfDoesntExistInWrapper() {
1489
+ let e = this.core.getOpenElementData(), t = this.core.getInput();
1490
+ e === null && t && t.setAttribute("data-open", "tp-ui-input");
1491
+ }
1492
+ setClassTopOpenElement() {
1493
+ let e = this.core.getOpenElement();
1494
+ for (let t of e) t && t.classList.add("tp-ui-open-element");
1495
+ }
1496
+ setTimepickerClassToElement() {
1497
+ let e = this.core.element;
1498
+ if (!e) return;
1499
+ e.classList.add(Bt);
1500
+ let t = this.core.options.ui.cssClass;
1501
+ t && t !== Bt && e.classList.add(t);
1502
+ }
1503
+ destroy() {
1504
+ let e = this.core.getModalElement();
1505
+ e && e.removeAttribute("data-theme");
1506
+ }
1507
+ }, Ut = class e extends Error {
1508
+ constructor(t, n) {
1509
+ super(`[TimepickerUI] ${t}`), this.code = n, this.name = "TimepickerError", Object.setPrototypeOf(this, e.prototype);
1510
+ }
1511
+ code;
1512
+ }, Wt = { INVALID_PARAMETER: "INVALID_PARAMETER" }, Gt = class {
1513
+ core;
1514
+ emitter;
1515
+ constructor(e, t) {
1516
+ this.core = e, this.emitter = t;
1517
+ }
1518
+ setErrorHandler() {
1519
+ let e = this.core.getInput();
1520
+ if (!e || (this.removeErrorHandler(), this.core.options.range?.enabled)) return !0;
1521
+ let { clock: n } = this.core.options, { error: r, currentHour: i, currentMin: a, currentSec: o, currentType: s, currentLength: c } = R(e, n.type, void 0, void 0, !!n.showSeconds);
1522
+ if (r) {
1523
+ if (t() === !1) return !1;
1524
+ let n = this.core.options.labels.invalidTimeFormat, l = this.getErrorId(), u = document.createElement("div");
1525
+ u.id = l, u.classList.add("tp-ui-invalid-text"), u.setAttribute("role", "alert");
1526
+ let d = document.createElement("b");
1527
+ d.textContent = n, u.appendChild(d), e.classList.add("tp-ui-invalid-format"), e.nextElementSibling?.classList.contains("tp-ui-invalid-text") || e.after(u), this.linkErrorMessage(e, l), this.announceInModal(n);
1528
+ let f = {
1529
+ error: r,
1530
+ rejectedHour: void 0,
1531
+ rejectedMinute: void 0,
1532
+ inputHour: i,
1533
+ inputMinute: a,
1534
+ inputType: s,
1535
+ inputLength: c
1536
+ };
1537
+ return o !== void 0 && (f.inputSecond = o), this.emitter.emit("error", f), !1;
1538
+ }
1539
+ return !0;
1540
+ }
1541
+ removeErrorHandler() {
1542
+ let e = this.core.getInput();
1543
+ if (!e) return;
1544
+ g(e, "tp-ui-invalid-format", !1), this.unlinkErrorMessage(e);
1545
+ let t = e.nextElementSibling;
1546
+ t?.classList.contains("tp-ui-invalid-text") && t.remove();
1547
+ }
1548
+ getErrorId() {
1549
+ return `tp-ui-invalid-text-${this.core.instanceId}`;
1550
+ }
1551
+ getDescribedByIds(e) {
1552
+ return (e.getAttribute("aria-describedby") ?? "").split(/\s+/).filter(Boolean);
1553
+ }
1554
+ linkErrorMessage(e, t) {
1555
+ let n = this.getDescribedByIds(e).filter((e) => e !== t);
1556
+ e.setAttribute("aria-describedby", [...n, t].join(" ")), e.setAttribute("aria-invalid", "true");
1557
+ }
1558
+ unlinkErrorMessage(e) {
1559
+ let t = this.getErrorId(), n = this.getDescribedByIds(e);
1560
+ n.includes(t) && (_(e, "aria-describedby", n.filter((e) => e !== t).join(" ")), e.removeAttribute("aria-invalid"));
1561
+ }
1562
+ announceInModal(e) {
1563
+ let t = this.core.getModalElement();
1564
+ if (t) {
1565
+ if (!this.core.options.behavior.focusTrap) {
1566
+ h(t, e);
1567
+ return;
1568
+ }
1569
+ t.addEventListener("focusin", () => h(t, e), { once: !0 });
1570
+ }
1571
+ }
1572
+ checkDisabledValuesOnStart() {
1573
+ if (!this.core.options.clock.disabledTime) return;
1574
+ let { disabledTime: e, type: t } = this.core.options.clock, n = O(this.core.options);
1575
+ if (e.interval) {
1576
+ if (!t) throw new Ut("clockType is required when using disabledTime.interval", Wt.INVALID_PARAMETER);
1577
+ let r = Array.isArray(e.interval) ? e.interval : [e.interval];
1578
+ try {
1579
+ Nt(r, n);
1580
+ } catch (e) {
1581
+ throw new Ut(`Invalid disabledTime.interval: ${e.message}`, Wt.INVALID_PARAMETER);
1582
+ }
1583
+ return;
1584
+ }
1585
+ let { hours: r, minutes: i, seconds: a } = e, o = !r || Lt(r, "hour", n), s = !i || Lt(i, "minutes", n), c = !a || Lt(a, "minutes", n);
1586
+ if (!o || !s) throw new Ut("Invalid hours or minutes in disabledTime option", Wt.INVALID_PARAMETER);
1587
+ if (!c) throw new Ut("Invalid seconds in disabledTime option", Wt.INVALID_PARAMETER);
1588
+ }
1589
+ destroy() {
1590
+ this.removeErrorHandler();
1591
+ }
1592
+ };
1593
+ function Kt(e, t, n, r) {
1594
+ e.on(n, r), t.push(() => e.off(n, r));
1595
+ }
1596
+ function J(e) {
1597
+ e.splice(0).forEach((e) => e());
1598
+ }
1599
+ function qt(e) {
1600
+ try {
1601
+ e.emit("show", {});
1602
+ } finally {
1603
+ e.emit("open:request", {});
1604
+ }
1605
+ }
1606
+ var Jt = class {
1607
+ core;
1608
+ emitter;
1609
+ cleanupHandlers = [];
1610
+ persistentCleanups = [];
1611
+ okBlocked = !1;
1612
+ constructor(e, t) {
1613
+ this.core = e, this.emitter = t;
1614
+ }
1615
+ handleOpenOnClick() {
1616
+ let e = this.core.getOpenElement();
1617
+ if (!e) return;
1618
+ let t = () => {
1619
+ this.core.isDestroyed || qt(this.emitter);
1620
+ };
1621
+ e.forEach((e) => {
1622
+ this.persistentCleanups.push(w(e, t));
1623
+ });
1624
+ }
1625
+ handleCancelButton() {
1626
+ let e = this.core.getCancelButton();
1627
+ e && this.cleanupHandlers.push(w(e, () => {
1628
+ this.core.isDestroyed || this.emitter.emit("cancel", {});
1629
+ }));
1630
+ }
1631
+ handleOkButton() {
1632
+ let e = this.core.getOkButton();
1633
+ e && (this.cleanupHandlers.push(w(e, () => {
1634
+ if (this.core.isDestroyed || e.getAttribute("aria-disabled") === "true") return;
1635
+ if (this.core.getHour() && this.core.getMinutes()) {
1636
+ this.emitter.emit("confirm", K(this.core));
1637
+ return;
1638
+ }
1639
+ let t = this.core.getModalElement();
1640
+ t && this.emitter.emit("confirm", this.readWheelCenter(t));
1641
+ })), this.blockOkOnDisabledTime(e));
1642
+ }
1643
+ blockOkOnDisabledTime(e) {
1644
+ if (this.core.options.range?.enabled) return;
1645
+ let t = () => {
1646
+ let t = xt(this.core);
1647
+ !t && !this.okBlocked || (this.okBlocked = t, C(e, t));
1648
+ };
1649
+ t(), Kt(this.emitter, this.cleanupHandlers, "update", ({ hour: e }) => {
1650
+ e && t();
1651
+ });
1652
+ }
1653
+ readWheelCenter(e) {
1654
+ let t = (t) => e.querySelector(`.tp-ui-wheel-${t} .tp-ui-wheel-item.is-center`)?.getAttribute("data-value") ?? void 0, n = {
1655
+ hour: t("hours"),
1656
+ minutes: t("minutes"),
1657
+ type: t("ampm")
1658
+ };
1659
+ return this.core.options.clock.showSeconds && (n.seconds = t("seconds")), n;
1660
+ }
1661
+ handleAmClick() {
1662
+ let e = this.core.getAM();
1663
+ e && this.cleanupHandlers.push(w(e, () => {
1664
+ this.core.isDestroyed || (b(e, this.core.getPM(), "AM"), h(this.core.getModalElement(), this.core.options.labels.announceAmSelected), this.emitter.emit("select:am", {}), this.emitter.emit("update", {
1665
+ ...K(this.core),
1666
+ type: "AM"
1667
+ }));
1668
+ }));
1669
+ }
1670
+ handlePmClick() {
1671
+ let e = this.core.getPM();
1672
+ e && this.cleanupHandlers.push(w(e, () => {
1673
+ this.core.isDestroyed || (b(this.core.getAM(), e, "PM"), h(this.core.getModalElement(), this.core.options.labels.announcePmSelected), this.emitter.emit("select:pm", {}), this.emitter.emit("update", {
1674
+ ...K(this.core),
1675
+ type: "PM"
1676
+ }));
1677
+ }));
1678
+ }
1679
+ handleSwitchViewButton() {
1680
+ let e = this.core.getKeyboardClockIcon();
1681
+ e && this.cleanupHandlers.push(w(e, () => {
1682
+ this.core.isDestroyed || this.emitter.emit("switch:view", {});
1683
+ }));
1684
+ }
1685
+ detach() {
1686
+ J(this.cleanupHandlers);
1687
+ }
1688
+ destroy() {
1689
+ this.detach(), J(this.persistentCleanups);
1690
+ }
1691
+ }, Yt = (e, t, n) => Math.max(t, Math.min(n, e)), Xt = (e, t) => {
1692
+ if (e === "") return "";
1693
+ let n = parseInt(e, 10);
1694
+ return Number.isNaN(n) ? "" : Yt(n, +!!t, t ? 12 : 23).toString().padStart(2, "0");
1695
+ }, Zt = (e) => {
1696
+ if (e === "") return "";
1697
+ let t = parseInt(e, 10);
1698
+ return Number.isNaN(t) ? "" : Yt(t, 0, 59).toString().padStart(2, "0");
1699
+ }, Qt = {
1700
+ hour: Xt,
1701
+ minutes: Zt,
1702
+ seconds: Zt
1703
+ }, $t = class {
1704
+ core;
1705
+ emitter;
1706
+ cleanupHandlers = [];
1707
+ constructor(e, t) {
1708
+ this.core = e, this.emitter = t;
1709
+ }
1710
+ handleHourEvents() {
1711
+ this.bindTimeField("hour");
1712
+ }
1713
+ handleMinutesEvents() {
1714
+ this.bindTimeField("minutes");
1715
+ }
1716
+ handleSecondsEvents() {
1717
+ this.bindTimeField("seconds");
1718
+ }
1719
+ bindTimeField(e) {
1720
+ let t = W(this.core, e);
1721
+ if (!t) return;
1722
+ let n = () => {
1723
+ this.core.isDestroyed || (gt(this.core, e), G(this.emitter, e, t.value), this.emitter.emit("update", K(this.core)));
1724
+ };
1725
+ t.addEventListener("click", n), this.cleanupHandlers.push(() => t.removeEventListener("click", n));
1726
+ let r = t.value, i = () => {
1727
+ if (this.core.isDestroyed || t.hasAttribute("readonly")) return;
1728
+ let n = Qt[e](t.value, this.core.options.clock.type === "12h");
1729
+ S(t, n && this.nearestEnabled(e, Number(n))), t.value !== r && (r = t.value, this.emitter.emit("animation:clock", {}), G(this.emitter, e, t.value), this.emitter.emit("update", K(this.core)));
1730
+ };
1731
+ t.addEventListener("blur", i), this.cleanupHandlers.push(() => t.removeEventListener("blur", i));
1732
+ }
1733
+ nearestEnabled(e, t) {
1734
+ let [n, r] = vt(this.core, e);
1735
+ return P(pt(t, n, r, bt(this.core, e)));
1736
+ }
1737
+ detach() {
1738
+ J(this.cleanupHandlers);
1739
+ }
1740
+ destroy() {
1741
+ this.detach();
1742
+ }
1743
+ }, en = [
1744
+ 1,
1745
+ !0,
1746
+ (e, { step: t }) => Math.floor(e / t) * t + t
1747
+ ], tn = [
1748
+ -1,
1749
+ !0,
1750
+ (e, { step: t }) => Math.ceil(e / t) * t - t
1751
+ ], nn = {
1752
+ ArrowUp: en,
1753
+ ArrowDown: tn,
1754
+ Home: [
1755
+ 1,
1756
+ !1,
1757
+ (e, { min: t }) => t
1758
+ ],
1759
+ End: [
1760
+ -1,
1761
+ !1,
1762
+ (e, { last: t }) => t
1763
+ ],
1764
+ PageUp: [
1765
+ 1,
1766
+ !1,
1767
+ (e, { last: t, step: n, pageSteps: r }) => Math.min(t, Math.floor(e / n) * n + n * r)
1768
+ ],
1769
+ PageDown: [
1770
+ -1,
1771
+ !1,
1772
+ (e, { min: t, step: n, pageSteps: r }) => Math.max(t, Math.ceil(e / n) * n - n * r)
1773
+ ]
1774
+ }, rn = {
1775
+ ...nn,
1776
+ ArrowRight: en,
1777
+ ArrowLeft: tn
1778
+ }, an = ([e, t, n], r, i, a) => {
1779
+ let { min: o, last: s, step: c } = i, l = n(r, i);
1780
+ for (let n = (s - o) / c; n >= 0; n--) {
1781
+ if (l < o || l > s) {
1782
+ if (!t) return null;
1783
+ l = l < o ? s : o;
1784
+ }
1785
+ if (!a(l)) return l;
1786
+ l += e * c;
1787
+ }
1788
+ return null;
1789
+ }, on = class {
1790
+ core;
1791
+ emitter;
1792
+ cleanupHandlers = [];
1793
+ persistentCleanups = [];
1794
+ constructor(e, t) {
1795
+ this.core = e, this.emitter = t;
1796
+ }
1797
+ handleOpenOnEnterFocus() {
1798
+ this.onKeydown(this.core.getInput(), (e) => {
1799
+ e.key === "Enter" && !this.core.isOpen && this.core.isModalRemove && qt(this.emitter);
1800
+ }, this.persistentCleanups);
1801
+ }
1802
+ handleEscClick() {
1803
+ t() !== !1 && this.onKeydown(document, (e) => {
1804
+ this.core.isOpen && e.key === "Escape" && this.emitter.emit("cancel", {});
1805
+ });
1806
+ }
1807
+ handleKeyboardInput() {
1808
+ U.forEach((e) => this.onKeydown(W(this.core, e), (t) => this.stepField(e, nn[t.key], t, !0))), this.onKeydown(this.core.getClockFace(), (e) => {
1809
+ let t = ht(this.core);
1810
+ ae(e.key) ? (e.preventDefault(), this.advanceFace(t)) : this.stepField(t, rn[e.key], e, !1);
1811
+ }), x(this.core.getModalElement());
1812
+ }
1813
+ advanceFace(e) {
1814
+ let t = U[U.indexOf(e) + 1], n = t === "minutes" ? "autoSwitchToMinutes" : "autoSwitchToSeconds";
1815
+ !t || this.core.options.clock[n] === !1 || (W(this.core, t)?.click(), _t(this.core, t));
1816
+ }
1817
+ onKeydown(e, t, n = this.cleanupHandlers) {
1818
+ if (!e) return;
1819
+ let r = (e) => {
1820
+ this.core.isDestroyed || t(e);
1821
+ };
1822
+ e.addEventListener("keydown", r), n.push(() => e.removeEventListener("keydown", r));
1823
+ }
1824
+ spinRange(e) {
1825
+ let [t, n] = vt(this.core, e), { incrementHours: r, incrementMinutes: i, incrementSeconds: a } = this.core.options.clock, o = {
1826
+ hour: r,
1827
+ minutes: i,
1828
+ seconds: a
1829
+ }[e] || 1;
1830
+ return {
1831
+ min: Math.ceil(t / o) * o,
1832
+ last: Math.floor(n / o) * o,
1833
+ step: o,
1834
+ pageSteps: e === "hour" ? 3 : 5
1835
+ };
1836
+ }
1837
+ stepField(e, t, n, r) {
1838
+ let i = W(this.core, e);
1839
+ if (!t || !i) return;
1840
+ n.preventDefault();
1841
+ let a = an(t, parseInt(i.value) || 0, this.spinRange(e), bt(this.core, e));
1842
+ if (a === null) return;
1843
+ let o = P(a);
1844
+ gt(this.core, e), S(i, o), r && _t(this.core, e), G(this.emitter, e, o), this.emitter.emit("update", K(this.core));
1845
+ }
1846
+ focusTrapHandler() {
1847
+ let e = this.core.getWrapper();
1848
+ e && this.onKeydown(e, (t) => {
1849
+ if (t.key !== "Tab") return;
1850
+ let n = e.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])"), r = [];
1851
+ if (n.forEach((e) => {
1852
+ e.getAttribute("aria-disabled") !== "true" && (e.hasAttribute("disabled") || e.hidden || e.getAttribute("aria-hidden") !== "true" && (e.offsetParent === null && e.getClientRects().length === 0 || r.push(e)));
1853
+ }), r.length === 0) return;
1854
+ let i = r[0], a = r[r.length - 1];
1855
+ t.shiftKey && document.activeElement === i ? (a?.focus(), t.preventDefault()) : !t.shiftKey && document.activeElement === a && (i?.focus(), t.preventDefault());
1856
+ });
1857
+ }
1858
+ detach() {
1859
+ J(this.cleanupHandlers);
1860
+ }
1861
+ destroy() {
1862
+ this.detach(), J(this.persistentCleanups);
1863
+ }
1864
+ }, sn = class {
1865
+ core;
1866
+ emitter;
1867
+ cleanupHandlers = [];
1868
+ constructor(e, t) {
1869
+ this.core = e, this.emitter = t;
1870
+ }
1871
+ handleBackdropClick() {
1872
+ let e = this.core.getModalElement();
1873
+ if (!e) return;
1874
+ let t = !1, n = (n) => {
1875
+ t = n.target !== e;
1876
+ }, r = (n) => {
1877
+ t ||= n.target !== e;
1878
+ }, i = (n) => {
1879
+ !this.core.isDestroyed && n.target === e && !t && this.emitter.emit("cancel", {});
1880
+ };
1881
+ e.addEventListener("pointerdown", n), e.addEventListener("pointerup", r), e.addEventListener("click", i), this.cleanupHandlers.push(() => {
1882
+ e.removeEventListener("pointerdown", n), e.removeEventListener("pointerup", r), e.removeEventListener("click", i);
1883
+ });
1884
+ }
1885
+ handlePointerModality() {
1886
+ let e = this.core.getModalElement();
1887
+ e && this.cleanupHandlers.push(ce(e));
1888
+ }
1889
+ detach() {
1890
+ J(this.cleanupHandlers);
1891
+ }
1892
+ destroy() {
1893
+ this.detach();
1894
+ }
1895
+ }, cn = class {
1896
+ buttonHandlers;
1897
+ inputHandlers;
1898
+ keyboardHandlers;
1899
+ modalHandlers;
1900
+ constructor(e, t) {
1901
+ this.buttonHandlers = new Jt(e, t), this.inputHandlers = new $t(e, t), this.keyboardHandlers = new on(e, t), this.modalHandlers = new sn(e, t);
1902
+ }
1903
+ handleOpenOnClick() {
1904
+ this.buttonHandlers.handleOpenOnClick();
1905
+ }
1906
+ handleOpenOnEnterFocus() {
1907
+ this.keyboardHandlers.handleOpenOnEnterFocus();
1908
+ }
1909
+ handleCancelButton() {
1910
+ this.buttonHandlers.handleCancelButton();
1911
+ }
1912
+ handleOkButton() {
1913
+ this.buttonHandlers.handleOkButton();
1914
+ }
1915
+ handleBackdropClick() {
1916
+ this.modalHandlers.handleBackdropClick();
1917
+ }
1918
+ handlePointerModality() {
1919
+ this.modalHandlers.handlePointerModality();
1920
+ }
1921
+ handleEscClick() {
1922
+ this.keyboardHandlers.handleEscClick();
1923
+ }
1924
+ handleAmClick() {
1925
+ this.buttonHandlers.handleAmClick();
1926
+ }
1927
+ handlePmClick() {
1928
+ this.buttonHandlers.handlePmClick();
1929
+ }
1930
+ handleHourEvents() {
1931
+ this.inputHandlers.handleHourEvents();
1932
+ }
1933
+ handleMinutesEvents() {
1934
+ this.inputHandlers.handleMinutesEvents();
1935
+ }
1936
+ handleSecondsEvents() {
1937
+ this.inputHandlers.handleSecondsEvents();
1938
+ }
1939
+ handleKeyboardInput() {
1940
+ this.keyboardHandlers.handleKeyboardInput();
1941
+ }
1942
+ focusTrapHandler() {
1943
+ this.keyboardHandlers.focusTrapHandler();
1944
+ }
1945
+ handleSwitchViewButton() {
1946
+ this.buttonHandlers.handleSwitchViewButton();
1947
+ }
1948
+ detach() {
1949
+ this.buttonHandlers.detach(), this.inputHandlers.detach(), this.keyboardHandlers.detach(), this.modalHandlers.detach();
1950
+ }
1951
+ destroy() {
1952
+ this.buttonHandlers.destroy(), this.inputHandlers.destroy(), this.keyboardHandlers.destroy(), this.modalHandlers.destroy();
1953
+ }
1954
+ }, ln = (e = []) => {
1955
+ let t = e[e.length - 1];
1956
+ return t === void 0 ? void 0 : parseInt(t, 10) + 1;
1957
+ }, un = class {
1958
+ emitter;
1959
+ getClockSystem;
1960
+ setHoursToClock;
1961
+ setMinutesToClock;
1962
+ setSecondsToClock;
1963
+ updateAmPm;
1964
+ convertDisabledTime;
1965
+ constructor(e, t, n, r, i, a, o) {
1966
+ this.emitter = e, this.getClockSystem = t, this.setHoursToClock = n, this.setMinutesToClock = r, this.setSecondsToClock = o, this.updateAmPm = i, this.convertDisabledTime = a;
1967
+ }
1968
+ setup() {
1969
+ this.emitter.on("select:hour", ({ hour: e }) => {
1970
+ this.showFace("hours", e, this.setHoursToClock);
1971
+ }), this.emitter.on("select:minute", ({ minutes: e }) => {
1972
+ this.showFace("minutes", e, this.setMinutesToClock);
1973
+ }), this.emitter.on("select:second", ({ seconds: e }) => {
1974
+ this.showFace("seconds", e, this.setSecondsToClock);
1975
+ }), this.emitter.on("select:am", () => {
1976
+ this.updateAmPm();
1977
+ }), this.emitter.on("select:pm", () => {
1978
+ this.updateAmPm();
1979
+ }), this.emitter.on("animation:start", () => {
1980
+ this.getClockSystem()?.blockInteractions();
1981
+ }), this.emitter.on("animation:end", () => {
1982
+ this.getClockSystem()?.unblockInteractions();
1983
+ }), this.emitter.on("range:switch", (e) => {
1984
+ this.refreshDisabledTimeForRange(e.disabledTime);
1985
+ });
1986
+ }
1987
+ showFace(e, t, n) {
1988
+ t && this.getClockSystem()?.setValueIfShown(e, t) || (this.emitter.emit("animation:clock", {}), n?.(t || null), this.emitter.emit("switch:face", { face: e }));
1989
+ }
1990
+ refreshDisabledTimeForRange(e) {
1991
+ let t = this.getClockSystem();
1992
+ if (!t) return;
1993
+ let n = this.convertDisabledTime();
1994
+ if (!e) {
1995
+ t.updateDisabledTime(n);
1996
+ return;
1997
+ }
1998
+ t.updateDisabledTime({
1999
+ ...n,
2000
+ rangeFromType: e.fromType,
2001
+ rangeFromHour: e.fromHour,
2002
+ rangeFromMinute: e.fromMinute ?? ln(e.minutes),
2003
+ rangeFromSecond: ln(e.seconds)
2004
+ });
2005
+ }
2006
+ }, dn = /* @__PURE__ */ new WeakMap(), fn = (e, t) => {
2007
+ let n = e.clockType ?? t, r = dn.get(e);
2008
+ if (r && r.clockType === n) return r;
2009
+ let i = {
2010
+ hours: e.hours,
2011
+ minutes: e.minutes,
2012
+ seconds: e.seconds,
2013
+ intervals: e.isInterval ? e.intervals : void 0,
2014
+ clockType: n
2015
+ };
2016
+ return dn.set(e, i), i;
2017
+ }, pn = 12, mn = 59, hn = 59, gn = (e, t, n) => n === "24h" ? e : t === "AM" ? e % pn : t === "PM" ? e % pn + pn : null, _n = (e, t, n, r, i) => {
2018
+ let a = gn(e, r, i);
2019
+ return a === null ? null : (a * 60 + t) * 60 + n;
2020
+ }, vn = (e, t, n, r, i, a) => {
2021
+ let { rangeFromHour: o, rangeFromMinute: s = 0, rangeFromSecond: c = 0, rangeFromType: l } = i;
2022
+ if (o === void 0) return !1;
2023
+ let u = _n(o, s, c, l, a), d = _n(e, t, n, r, a);
2024
+ return u !== null && d !== null && d < u;
2025
+ }, yn = (e, t, n, r) => vn(parseInt(e, 10), mn, hn, t, n, r), bn = (e, t, n, r, i) => vn(parseInt(t, 10), parseInt(e, 10), hn, n, r, i), xn = (e, t, n, r, i, a) => vn(parseInt(n, 10), parseInt(t, 10), parseInt(e, 10), r, i, a), Y = class {
2026
+ static angleToIndex(e, t, n) {
2027
+ let r = Math.round(e / 30) % 12;
2028
+ if (t === "24h") {
2029
+ if (n) {
2030
+ let e = r + 12;
2031
+ return e === 12 ? 0 : e;
2032
+ }
2033
+ return r === 0 ? 12 : r;
2034
+ }
2035
+ return r === 0 ? 12 : r;
2036
+ }
2037
+ static indexToValue(e, t) {
2038
+ if (t === "24h") return e.toString().padStart(2, "0");
2039
+ let n = e;
2040
+ return n === 0 && (n = 12), n > 12 && (n -= 12), n.toString().padStart(2, "0");
2041
+ }
2042
+ static indexToAngle(e, t) {
2043
+ return t === "24h" ? e >= 12 ? (e - 12) % 12 * 30 : e % 12 * 30 : (e === 0 ? 12 : e) % 12 * 30;
2044
+ }
2045
+ static isDisabled(e, t, n, r, i = !1) {
2046
+ return n ? yn(e, t, n, r) || dt(fn(n, r), {
2047
+ hour: e,
2048
+ type: t || void 0
2049
+ }, i) : !1;
2050
+ }
2051
+ static findNearestValid(e, t, n, r, i = !1, a = 1) {
2052
+ let o = t === "24h" ? 23 : 12;
2053
+ for (let s = 0; s <= o; s++) {
2054
+ let c = s === 0 ? [e] : [e + s, e - s];
2055
+ for (let e of c) {
2056
+ let s = e;
2057
+ s < 0 && (s += o + 1), s > o && (s %= o + 1);
2058
+ let c = this.indexToValue(s, t);
2059
+ if (mt(s, a) && !this.isDisabled(c, n, r, t, i)) return s;
2060
+ }
2061
+ }
2062
+ return e;
2063
+ }
2064
+ }, X = class {
2065
+ static angleToIndex(e) {
2066
+ return Math.round(e / 6) % 60;
2067
+ }
2068
+ static indexToValue(e) {
2069
+ return e.toString().padStart(2, "0");
2070
+ }
2071
+ static indexToAngle(e) {
2072
+ return e % 60 * 6;
2073
+ }
2074
+ static isDisabled(e, t, n, r, i, a = !1) {
2075
+ return r ? bn(e, t, n, r, i) || ut(fn(r, i), {
2076
+ hour: t,
2077
+ minutes: e,
2078
+ type: n || void 0
2079
+ }, a) : !1;
2080
+ }
2081
+ static isUnitDisabled(e, t, n) {
2082
+ let { hour: r, minute: i, amPm: a, disabledTime: o, clockType: s, showSeconds: c } = n;
2083
+ return e === "minutes" ? this.isDisabled(t, r, a, o, s, c) : o ? xn(t, i, r, a, o, s) || lt(fn(o, s), {
2084
+ hour: r,
2085
+ minutes: i,
2086
+ seconds: t,
2087
+ type: a || void 0
2088
+ }) : !1;
2089
+ }
2090
+ static findNearestValidIndex(e, t, n) {
2091
+ for (let r = 0; r < 60; r++) {
2092
+ let i = r === 0 ? [e] : [e + r, e - r];
2093
+ for (let e of i) {
2094
+ let r = e;
2095
+ if (r < 0 && (r += 60), r >= 60 && (r %= 60), !this.isUnitDisabled(t, this.indexToValue(r), n)) return r;
2096
+ }
2097
+ }
2098
+ return e;
2099
+ }
2100
+ }, Z = class {
2101
+ static normalizeAngle(e) {
2102
+ let t = e % 360;
2103
+ return t < 0 && (t += 360), t;
2104
+ }
2105
+ static calculateRawAngle(e, t) {
2106
+ let n = e.x - t.x, r = e.y - t.y, i = Math.atan2(r, n) * 180 / Math.PI + 90;
2107
+ return this.normalizeAngle(i);
2108
+ }
2109
+ static snapToIncrement(e, t) {
2110
+ let n = Math.round(e / t) * t;
2111
+ return this.normalizeAngle(n);
2112
+ }
2113
+ static calculateDistance(e, t) {
2114
+ let n = e.x - t.x, r = e.y - t.y;
2115
+ return Math.sqrt(n * n + r * r);
2116
+ }
2117
+ static isInnerCircle(e, t) {
2118
+ return e < t * .75;
2119
+ }
2120
+ static calculateShortestPath(e, t) {
2121
+ let n = this.normalizeAngle(e), r = this.normalizeAngle(t) - n, i = r >= 0 ? r : r + 360, a = r <= 0 ? r : r - 360;
2122
+ return e + (Math.abs(i) < Math.abs(a) ? i : a);
2123
+ }
2124
+ }, Sn = class {
2125
+ config;
2126
+ currentAngle = 0;
2127
+ tipsCache = /* @__PURE__ */ new Map();
2128
+ cachedDimensions = /* @__PURE__ */ new Map();
2129
+ snapTimeout = null;
2130
+ sweep = null;
2131
+ constructor(e) {
2132
+ this.config = e;
2133
+ }
2134
+ getCachedDimensions(e) {
2135
+ let t = this.cachedDimensions.get(e);
2136
+ if (!t) {
2137
+ let n = (e.offsetWidth - 32) / 2;
2138
+ t = {
2139
+ width: n,
2140
+ height: (e.offsetHeight - 32) / 2,
2141
+ radius: n - 9
2142
+ }, this.cachedDimensions.set(e, t);
2143
+ }
2144
+ return t;
2145
+ }
2146
+ setHandAngle(e) {
2147
+ this.cancelSweep();
2148
+ let t = Z.calculateShortestPath(this.currentAngle, e);
2149
+ Math.abs(this.currentAngle - t) < .01 || (this.currentAngle = t, this.config.clockHand.style.transform = `rotateZ(${t}deg)`);
2150
+ }
2151
+ animateToAngle(e) {
2152
+ let t = Z.calculateShortestPath(this.currentAngle, e);
2153
+ if (this.currentAngle = t, T()) {
2154
+ this.config.clockHand.style.transform = `rotateZ(${t}deg)`;
2155
+ return;
2156
+ }
2157
+ this.clearSnapTimeout(), this.config.clockHand.classList.add("tp-ui-tips-animation"), this.config.clockHand.style.transform = `rotateZ(${t}deg)`, this.snapTimeout = setTimeout(() => {
2158
+ this.snapTimeout = null, this.config.clockHand.classList.remove("tp-ui-tips-animation");
2159
+ }, m.TIPS_ANIMATION);
2160
+ }
2161
+ clearSnapTimeout() {
2162
+ this.snapTimeout !== null && (clearTimeout(this.snapTimeout), this.snapTimeout = null);
2163
+ }
2164
+ setActiveValue(e) {
2165
+ let t = Number(e);
2166
+ [this.config.tipsWrapper, this.config.tipsWrapperFor24h].forEach((n) => {
2167
+ n?.querySelectorAll(".tp-ui-value-tips, .tp-ui-value-tips-24h").forEach((n) => {
2168
+ g(n, "active", n.textContent === e || Number(n.textContent) === t);
2169
+ });
2170
+ });
2171
+ }
2172
+ followHand(e, t) {
2173
+ this.cancelSweep();
2174
+ let n = this.config.clockHand;
2175
+ if (T() || !n.classList.contains("tp-ui-tips-animation")) {
2176
+ this.setActiveValue(t);
2177
+ return;
2178
+ }
2179
+ let r = 0, i = () => {
2180
+ let { a: t, b: a } = new DOMMatrix(getComputedStyle(n).transform);
2181
+ this.setActiveValue(e(Math.atan2(a, t) * 180 / Math.PI)), r = requestAnimationFrame(i);
2182
+ }, a = setTimeout(() => {
2183
+ this.cancelSweep(), this.setActiveValue(t);
2184
+ }, m.TIPS_ANIMATION);
2185
+ this.sweep = () => {
2186
+ cancelAnimationFrame(r), clearTimeout(a);
2187
+ }, r = requestAnimationFrame(i);
2188
+ }
2189
+ cancelSweep() {
2190
+ this.sweep?.(), this.sweep = null;
2191
+ }
2192
+ renderTips(e, n, r, i, a, o = !0, s, c = "", l = "12", u = "00") {
2193
+ if (t() === !1) return;
2194
+ let d = s || this.config.tipsWrapper, f = {
2195
+ hour: l,
2196
+ minute: u,
2197
+ amPm: c,
2198
+ disabledTime: i,
2199
+ clockType: a,
2200
+ showSeconds: this.config.showSeconds
2201
+ };
2202
+ o && (d.innerHTML = "", this.tipsCache.clear());
2203
+ let { width: p, height: m, radius: h } = this.getCachedDimensions(d), g = document.createDocumentFragment(), _ = `${n}-${this.config.theme || "default"}`;
2204
+ e.forEach((t, i) => {
2205
+ let o = `${_}-${t}`, s = this.tipsCache.get(o);
2206
+ s || (s = this.createTip(t, n, a), this.tipsCache.set(o, s));
2207
+ let { wrapper: c, tip: l } = s;
2208
+ this.updateTipState(c, l, t, r, f);
2209
+ let u = i * (360 / e.length) * (Math.PI / 180);
2210
+ c.style.left = `${p + Math.sin(u) * h}px`, c.style.bottom = `${m + Math.cos(u) * h}px`, g.appendChild(c);
2211
+ }), d.appendChild(g);
2212
+ }
2213
+ createTip(e, n, r) {
2214
+ if (t() === !1) {
2215
+ let e = {};
2216
+ return {
2217
+ wrapper: e,
2218
+ tip: e
2219
+ };
2220
+ }
2221
+ let i = document.createElement("span"), a = document.createElement("span");
2222
+ a.textContent = e, a.tabIndex = -1;
2223
+ let o = r === "24h" && n.includes("24") ? "tp-ui-value-tips-24h" : "tp-ui-value-tips";
2224
+ return a.classList.add(o), i.classList.add(n), i.appendChild(a), {
2225
+ wrapper: i,
2226
+ tip: a
2227
+ };
2228
+ }
2229
+ updateTipState(e, t, n, r, i) {
2230
+ let a = this.checkIfDisabled(n, r, i);
2231
+ g(e, "tp-ui-tips-disabled", a), g(t, "tp-ui-tips-disabled", a);
2232
+ }
2233
+ checkIfDisabled(e, t, n) {
2234
+ let { amPm: r, disabledTime: i, clockType: a, showSeconds: o } = n;
2235
+ return i ? t === "hours" ? Y.isDisabled(e, r, i, a, o) : X.isUnitDisabled(t, e, n) : !1;
2236
+ }
2237
+ setCircle24hMode(e) {
2238
+ g(this.config.circle, "tp-ui-circle-hand-24h", e), g(this.config.clockHand, "tp-ui-clock-hand-24h", e);
2239
+ }
2240
+ destroy() {
2241
+ this.cancelSweep(), this.clearSnapTimeout(), this.tipsCache.clear(), this.cachedDimensions.clear();
2242
+ }
2243
+ }, Q = class {
2244
+ static processPointerInput(e) {
2245
+ let t = Z.calculateRawAngle(e.pointerPosition, e.clockCenter);
2246
+ return e.mode === "hours" ? this.processHours(t, e) : this.processSixty(t, e, e.mode);
2247
+ }
2248
+ static processHours(e, t) {
2249
+ let n = Z.snapToIncrement(e, t.incrementHours * 30), r = Z.calculateDistance(t.pointerPosition, t.clockCenter), i = t.clockType === "24h" && Z.isInnerCircle(r, t.clockRadius), a = Y.angleToIndex(n, t.clockType, i), o = Y.indexToValue(a, t.clockType), s = Y.isDisabled(o, t.amPm, t.disabledTime, t.clockType, t.showSeconds);
2250
+ return s && (a = Y.findNearestValid(a, t.clockType, t.amPm, t.disabledTime, t.showSeconds, t.incrementHours)), {
2251
+ angle: t.smoothHourSnap === !1 ? Y.indexToAngle(a, t.clockType) : e,
2252
+ value: Y.indexToValue(a, t.clockType),
2253
+ index: a,
2254
+ isValid: !s,
2255
+ isInnerCircle: t.clockType === "24h" ? i : void 0
2256
+ };
2257
+ }
2258
+ static processSixty(e, t, n) {
2259
+ let r = n === "seconds" ? t.incrementSeconds ?? 1 : t.incrementMinutes, i = Z.snapToIncrement(e, r * 6), a = X.angleToIndex(i), o = {
2260
+ hour: t.currentHour || "00",
2261
+ minute: t.currentMinute || "00",
2262
+ amPm: t.amPm,
2263
+ disabledTime: t.disabledTime,
2264
+ clockType: t.clockType,
2265
+ showSeconds: t.showSeconds
2266
+ }, s = X.isUnitDisabled(n, X.indexToValue(a), o);
2267
+ return s && (a = X.findNearestValidIndex(a, n, o)), {
2268
+ angle: X.indexToAngle(a),
2269
+ value: X.indexToValue(a),
2270
+ index: a,
2271
+ isValid: !s
2272
+ };
2273
+ }
2274
+ static valueToAngle(e, t, n) {
2275
+ let r = parseInt(e, 10);
2276
+ return t === "hours" ? Y.indexToAngle(r, n) : X.indexToAngle(r);
2277
+ }
2278
+ }, Cn = class {
2279
+ state;
2280
+ renderer;
2281
+ clockType;
2282
+ disabledTime;
2283
+ incrementHours;
2284
+ incrementMinutes;
2285
+ incrementSeconds;
2286
+ smoothHourSnap;
2287
+ showSeconds;
2288
+ isDragging = !1;
2289
+ callbacks;
2290
+ lastProcessedX = null;
2291
+ lastProcessedY = null;
2292
+ appliedInDrag = !1;
2293
+ sixtyUnits = {
2294
+ minutes: {
2295
+ value: "minute",
2296
+ angle: "minuteAngle",
2297
+ notify: () => this.callbacks.onMinuteChange
2298
+ },
2299
+ seconds: {
2300
+ value: "second",
2301
+ angle: "secondAngle",
2302
+ notify: () => this.callbacks.onSecondChange
2303
+ }
2304
+ };
2305
+ constructor(e, t, n, r, i = 1, a = 1, o = !0, s = {}, c = 1, l = !1) {
2306
+ this.renderer = e, this.state = { ...t }, this.clockType = n, this.disabledTime = r, this.incrementHours = i, this.incrementMinutes = a, this.incrementSeconds = c, this.smoothHourSnap = o, this.showSeconds = l, this.callbacks = s;
2307
+ }
2308
+ handlePointerMove(e, t, n) {
2309
+ if (this.isDragging = !0, this.lastProcessedX === e.x && this.lastProcessedY === e.y) return this.appliedInDrag;
2310
+ this.lastProcessedX = e.x, this.lastProcessedY = e.y;
2311
+ let r = this.state.mode, i = {
2312
+ pointerPosition: e,
2313
+ clockCenter: t,
2314
+ clockRadius: n,
2315
+ mode: r,
2316
+ clockType: this.clockType,
2317
+ amPm: this.state.amPm,
2318
+ disabledTime: this.disabledTime,
2319
+ incrementHours: this.incrementHours,
2320
+ incrementMinutes: this.incrementMinutes,
2321
+ incrementSeconds: this.incrementSeconds,
2322
+ smoothHourSnap: this.smoothHourSnap,
2323
+ currentHour: this.state.hour,
2324
+ currentMinute: this.state.minute,
2325
+ showSeconds: this.showSeconds
2326
+ }, a = Q.processPointerInput(i);
2327
+ if (!a.isValid) return !1;
2328
+ if (r === "hours") {
2329
+ let e = this.state.hour;
2330
+ this.state.hour = a.value, this.state.hourAngle = a.angle, this.clockType === "24h" && a.isInnerCircle !== void 0 && this.renderer.setCircle24hMode(a.isInnerCircle), this.callbacks.onHourChange && e !== a.value && this.callbacks.onHourChange(a.value);
2331
+ } else {
2332
+ let e = this.writeSixty(r, a.value, a.angle), t = this.sixtyUnits[r].notify();
2333
+ t && e !== a.value && t(a.value);
2334
+ }
2335
+ return this.renderer.setHandAngle(a.angle), this.renderer.setActiveValue(a.value), this.appliedInDrag = !0, !0;
2336
+ }
2337
+ handlePointerUp() {
2338
+ this.isDragging = !1, this.appliedInDrag = !1, this.lastProcessedX = null, this.lastProcessedY = null;
2339
+ }
2340
+ snapToNearestHour() {
2341
+ if (this.state.mode !== "hours") return;
2342
+ let e = Q.valueToAngle(this.state.hour, "hours", this.clockType);
2343
+ this.state.hourAngle = e, this.renderer.animateToAngle(e);
2344
+ }
2345
+ switchMode(e) {
2346
+ this.state.mode = e, this.renderer.setCircle24hMode(this.isInnerFace(e, this.getValue(e))), this.renderer.setHandAngle(this.getAngle(e));
2347
+ }
2348
+ followHand(e) {
2349
+ let t = this.getValue(e), n = this.isInnerFace(e, t);
2350
+ this.renderer.followHand((t) => {
2351
+ let r = Z.snapToIncrement(t, 30);
2352
+ return e === "hours" ? Y.indexToValue(Y.angleToIndex(r, this.clockType, n), this.clockType) : X.indexToValue(X.angleToIndex(r));
2353
+ }, t);
2354
+ }
2355
+ setValue(e, t) {
2356
+ let n = Q.valueToAngle(t, e, this.clockType);
2357
+ e === "hours" ? (this.state.hour = t, this.state.hourAngle = n) : this.writeSixty(e, t, n), this.state.mode === e && (this.renderer.setCircle24hMode(this.isInnerFace(e, t)), this.renderer.setHandAngle(n), this.renderer.setActiveValue(t));
2358
+ }
2359
+ setAmPm(e) {
2360
+ this.state.amPm = e;
2361
+ }
2362
+ getState() {
2363
+ return { ...this.state };
2364
+ }
2365
+ getValue(e) {
2366
+ return e === "hours" ? this.state.hour : this.state[this.sixtyUnits[e].value];
2367
+ }
2368
+ getHour() {
2369
+ return this.state.hour;
2370
+ }
2371
+ getMinute() {
2372
+ return this.state.minute;
2373
+ }
2374
+ getSecond() {
2375
+ return this.state.second;
2376
+ }
2377
+ getAmPm() {
2378
+ return this.state.amPm;
2379
+ }
2380
+ updateDisabledTime(e) {
2381
+ this.disabledTime = e;
2382
+ }
2383
+ destroy() {
2384
+ this.renderer.destroy();
2385
+ }
2386
+ getAngle(e) {
2387
+ return e === "hours" ? this.state.hourAngle : this.state[this.sixtyUnits[e].angle];
2388
+ }
2389
+ writeSixty(e, t, n) {
2390
+ let r = this.sixtyUnits[e], i = this.state[r.value];
2391
+ return this.state[r.value] = t, this.state[r.angle] = n, i;
2392
+ }
2393
+ isInnerFace(e, t) {
2394
+ if (e !== "hours" || this.clockType !== "24h") return !1;
2395
+ let n = parseInt(t, 10);
2396
+ return n === 0 || n >= 13;
2397
+ }
2398
+ }, wn = class {
2399
+ controller;
2400
+ clockFace;
2401
+ isActive = !1;
2402
+ isBlocked = !1;
2403
+ config;
2404
+ cachedRect = null;
2405
+ cachedCenter = null;
2406
+ cachedRadius = null;
2407
+ rafId = null;
2408
+ hadValidSelection = !1;
2409
+ constructor(e, t, n = {}) {
2410
+ this.controller = e, this.clockFace = t, this.config = n;
2411
+ }
2412
+ attach() {
2413
+ this.clockFace.addEventListener("mousedown", this.handlePointerDown), this.clockFace.addEventListener("touchstart", this.handlePointerDown, { passive: !1 });
2414
+ }
2415
+ detach() {
2416
+ this.clockFace.removeEventListener("mousedown", this.handlePointerDown), this.clockFace.removeEventListener("touchstart", this.handlePointerDown), this.removeGlobalListeners(), this.cancelPendingFrame(), this.isActive = !1;
2417
+ }
2418
+ block() {
2419
+ this.isBlocked = !0;
2420
+ }
2421
+ unblock() {
2422
+ this.isBlocked = !1;
2423
+ }
2424
+ handlePointerDown = (t) => {
2425
+ e() || this.isBlocked || this.isDisabledTarget(t.target) || (t.preventDefault(), this.isActive = !0, this.hadValidSelection = !1, this.cachedRect = this.clockFace.getBoundingClientRect(), this.cachedCenter = this.getClockCenter(), this.cachedRadius = this.getClockRadius(), this.processPointerEvent(t), document.addEventListener("mousemove", this.handlePointerMove), document.addEventListener("touchmove", this.handlePointerMove, { passive: !1 }), document.addEventListener("mouseup", this.handlePointerUp), document.addEventListener("touchend", this.handlePointerUp));
2426
+ };
2427
+ handlePointerMove = (e) => {
2428
+ !this.isActive || this.isBlocked || this.isDisabledTarget(this.getTargetElement(e)) || (e.preventDefault(), this.rafId === null && (this.rafId = requestAnimationFrame(() => {
2429
+ this.rafId = null, this.processPointerEvent(e);
2430
+ })));
2431
+ };
2432
+ handlePointerUp = () => {
2433
+ if (!this.isActive) return;
2434
+ this.cancelPendingFrame(), this.isActive = !1, this.cachedRect = null, this.cachedCenter = null, this.cachedRadius = null, this.controller.handlePointerUp();
2435
+ let { autoSwitchToMinutes: e, autoSwitchToSeconds: t, isMobileView: n, smoothHourSnap: r, hourElement: i, minutesElement: a, secondsElement: o } = this.config;
2436
+ r && i?.classList.contains("active") && this.controller.snapToNearestHour(), this.removeGlobalListeners(), this.hadValidSelection && (e && i?.classList.contains("active") && !n ? this.activate(i, a) : a?.classList.contains("active") && o ? t !== !1 && !n && this.activate(a, o) : this.isLastUnitActive() && this.config.onMinuteCommit && this.config.onMinuteCommit());
2437
+ };
2438
+ activate(e, t) {
2439
+ t?.click(), t?.focus(), e.blur();
2440
+ }
2441
+ isLastUnitActive() {
2442
+ let { minutesElement: e, secondsElement: t } = this.config;
2443
+ return !!(t ?? e)?.classList.contains("active");
2444
+ }
2445
+ processPointerEvent(e) {
2446
+ let t = this.getPointerPosition(e), n = this.cachedCenter || this.getClockCenter(), r = this.cachedRadius || this.getClockRadius();
2447
+ this.controller.handlePointerMove(t, n, r) !== !1 && (this.hadValidSelection = !0);
2448
+ }
2449
+ isDisabledTarget(e) {
2450
+ return !!e?.closest?.(".tp-ui-tips-disabled");
2451
+ }
2452
+ getPointerPosition(e) {
2453
+ let t = this.cachedRect || this.clockFace.getBoundingClientRect();
2454
+ if ("touches" in e) {
2455
+ let n = e.touches[0] || e.changedTouches[0];
2456
+ return {
2457
+ x: n.clientX - t.left,
2458
+ y: n.clientY - t.top
2459
+ };
2460
+ }
2461
+ return {
2462
+ x: e.clientX - t.left,
2463
+ y: e.clientY - t.top
2464
+ };
2465
+ }
2466
+ getTargetElement(t) {
2467
+ if ("touches" in t) {
2468
+ let n = t.touches[0] || t.changedTouches[0];
2469
+ if (n && !e()) return document.elementFromPoint(n.clientX, n.clientY);
2470
+ }
2471
+ return t.target;
2472
+ }
2473
+ getClockCenter() {
2474
+ let e = this.clockFace.offsetWidth, t = this.clockFace.offsetHeight;
2475
+ return {
2476
+ x: e / 2,
2477
+ y: t / 2
2478
+ };
2479
+ }
2480
+ getClockRadius() {
2481
+ return this.clockFace.offsetWidth / 2;
2482
+ }
2483
+ cancelPendingFrame() {
2484
+ this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
2485
+ }
2486
+ removeGlobalListeners() {
2487
+ t() !== !1 && (document.removeEventListener("mousemove", this.handlePointerMove), document.removeEventListener("touchmove", this.handlePointerMove), document.removeEventListener("mouseup", this.handlePointerUp), document.removeEventListener("touchend", this.handlePointerUp));
2488
+ }
2489
+ }, Tn = class {
2490
+ renderer;
2491
+ controller;
2492
+ dragHandlers;
2493
+ clockType;
2494
+ disabledTime;
2495
+ tipsWrapper;
2496
+ tipsWrapperFor24h;
2497
+ constructor(e) {
2498
+ this.clockType = e.clockType, this.disabledTime = e.disabledTime, this.tipsWrapper = e.tipsWrapper, this.tipsWrapperFor24h = e.tipsWrapperFor24h;
2499
+ let t = {
2500
+ clockFace: e.clockFace,
2501
+ tipsWrapper: e.tipsWrapper,
2502
+ tipsWrapperFor24h: e.tipsWrapperFor24h,
2503
+ clockHand: e.clockHand,
2504
+ circle: e.circle,
2505
+ theme: e.theme,
2506
+ showSeconds: e.showSeconds
2507
+ };
2508
+ this.renderer = new Sn(t);
2509
+ let n = e.initialSecond || "00", r = {
2510
+ hour: e.initialHour,
2511
+ minute: e.initialMinute,
2512
+ second: n,
2513
+ amPm: e.initialAmPm,
2514
+ hourAngle: Q.valueToAngle(e.initialHour, "hours", e.clockType),
2515
+ minuteAngle: Q.valueToAngle(e.initialMinute, "minutes", e.clockType),
2516
+ secondAngle: Q.valueToAngle(n, "seconds", e.clockType),
2517
+ mode: "hours"
2518
+ }, i = {
2519
+ onHourChange: e.onHourChange,
2520
+ onMinuteChange: e.onMinuteChange,
2521
+ onSecondChange: e.onSecondChange
2522
+ };
2523
+ this.controller = new Cn(this.renderer, r, e.clockType, e.disabledTime, e.incrementHours || 1, e.incrementMinutes || 1, e.smoothHourSnap ?? !0, i, e.incrementSeconds || 1, e.showSeconds ?? !1), this.dragHandlers = new wn(this.controller, e.clockFace, e.dragConfig || {});
2524
+ }
2525
+ initialize() {
2526
+ this.dragHandlers.attach(), this.switchToHours();
2527
+ }
2528
+ switchToHours() {
2529
+ this.controller.switchMode("hours"), this.clockType === "24h" && this.tipsWrapperFor24h && this.tipsWrapperFor24h.classList.remove("none"), this.renderHourTips(), this.controller.followHand("hours");
2530
+ }
2531
+ switchToMinutes() {
2532
+ this.switchToSixty("minutes");
2533
+ }
2534
+ switchToSeconds() {
2535
+ this.switchToSixty("seconds");
2536
+ }
2537
+ setHour(e) {
2538
+ this.controller.setValue("hours", e);
2539
+ }
2540
+ setMinute(e) {
2541
+ this.controller.setValue("minutes", e);
2542
+ }
2543
+ setSecond(e) {
2544
+ this.controller.setValue("seconds", e);
2545
+ }
2546
+ setValueIfShown(e, t) {
2547
+ let n = this.controller.getState().mode === e;
2548
+ return n && this.controller.setValue(e, t), n;
2549
+ }
2550
+ setAmPm(e) {
2551
+ this.controller.setAmPm(e), this.refreshFace();
2552
+ }
2553
+ syncValue(e) {
2554
+ this.controller.setValue("hours", e.hour), this.controller.setValue("minutes", e.minute), e.second && this.controller.setValue("seconds", e.second), e.amPm && this.clockType === "12h" && this.controller.setAmPm(e.amPm), this.refreshFace();
2555
+ }
2556
+ refreshFace() {
2557
+ let { mode: e } = this.controller.getState();
2558
+ e === "hours" ? this.switchToHours() : this.switchToSixty(e);
2559
+ }
2560
+ getHour() {
2561
+ return this.controller.getHour();
2562
+ }
2563
+ getMinute() {
2564
+ return this.controller.getMinute();
2565
+ }
2566
+ getSecond() {
2567
+ return this.controller.getSecond();
2568
+ }
2569
+ getAmPm() {
2570
+ return this.controller.getAmPm();
2571
+ }
2572
+ updateDisabledTime(e) {
2573
+ this.disabledTime = e, this.controller.updateDisabledTime(e);
2574
+ let { mode: t } = this.controller.getState();
2575
+ t === "hours" ? this.renderHourTips() : this.renderSixtyTips(t);
2576
+ }
2577
+ switchToSixty(e) {
2578
+ this.controller.switchMode(e), this.tipsWrapperFor24h && this.tipsWrapperFor24h.classList.add("none"), this.renderSixtyTips(e), this.controller.followHand(e);
2579
+ }
2580
+ renderHourTips() {
2581
+ let e = this.controller.getState().amPm;
2582
+ this.clockType === "24h" ? (this.renderer.renderTips(me, "tp-ui-hour-time-12", "hours", this.disabledTime, this.clockType, !0, this.tipsWrapper, e), this.tipsWrapperFor24h && this.renderer.renderTips(pe, "tp-ui-hour-time-24", "hours", this.disabledTime, this.clockType, !0, this.tipsWrapperFor24h, e)) : this.renderer.renderTips(me, "tp-ui-hour-time-12", "hours", this.disabledTime, this.clockType, !0, void 0, e);
2583
+ }
2584
+ renderSixtyTips(e) {
2585
+ let { amPm: t, hour: n, minute: r } = this.controller.getState();
2586
+ this.renderer.renderTips(he, "tp-ui-minutes-time", e, this.disabledTime, this.clockType, !0, void 0, t, n, r);
2587
+ }
2588
+ destroy() {
2589
+ this.dragHandlers.detach(), this.controller.destroy();
2590
+ }
2591
+ blockInteractions() {
2592
+ this.dragHandlers.block();
2593
+ }
2594
+ unblockInteractions() {
2595
+ this.dragHandlers.unblock();
2596
+ }
2597
+ }, En = class {
2598
+ core;
2599
+ emitter;
2600
+ clockSystem = null;
2601
+ constructor(e, t) {
2602
+ this.core = e, this.emitter = t;
2603
+ }
2604
+ getClockSystem() {
2605
+ return this.clockSystem;
2606
+ }
2607
+ initialize() {
2608
+ this.destroy();
2609
+ let e = this.core.getClockFace(), t = this.core.getClockHand(), n = this.core.getCircle();
2610
+ if (!e || !t || !n) return;
2611
+ let { clock: r } = this.core.options, i = r.type === "24h", a = this.core.getTipsWrapper();
2612
+ if (!a) return;
2613
+ let o = r.showSeconds === !0, s = this.core.getHour(), c = this.core.getMinutes(), l = o ? this.core.getSeconds() : null, u = {
2614
+ clockFace: e,
2615
+ tipsWrapper: a,
2616
+ tipsWrapperFor24h: i && this.core.getTipsWrapperFor24h() || void 0,
2617
+ clockHand: t,
2618
+ circle: n,
2619
+ clockType: r.type || "12h",
2620
+ disabledTime: this.convertDisabledTime(),
2621
+ initialHour: s?.value || "12",
2622
+ initialMinute: c?.value || "00",
2623
+ initialSecond: l?.value || "00",
2624
+ initialAmPm: this.getAmPmValue(),
2625
+ theme: this.core.options.ui.theme,
2626
+ incrementHours: r.incrementHours || 1,
2627
+ incrementMinutes: r.incrementMinutes || 1,
2628
+ incrementSeconds: r.incrementSeconds || 1,
2629
+ smoothHourSnap: r.smoothHourSnap ?? !0,
2630
+ showSeconds: o,
2631
+ timepicker: null,
2632
+ dragConfig: {
2633
+ autoSwitchToMinutes: r.autoSwitchToMinutes,
2634
+ autoSwitchToSeconds: r.autoSwitchToSeconds,
2635
+ isMobileView: this.core.isMobileView,
2636
+ smoothHourSnap: r.smoothHourSnap ?? !0,
2637
+ hourElement: s,
2638
+ minutesElement: c,
2639
+ secondsElement: l,
2640
+ onMinuteCommit: () => {
2641
+ let e = K(this.core);
2642
+ this.emitter.emit("range:minute:commit", {
2643
+ ...e,
2644
+ hour: e.hour ?? "12",
2645
+ minutes: e.minutes ?? "00"
2646
+ });
2647
+ }
2648
+ },
2649
+ onHourChange: (e) => this.reflectClockValue("hour", e),
2650
+ onMinuteChange: (e) => this.reflectClockValue("minutes", e),
2651
+ onSecondChange: (e) => this.reflectClockValue("seconds", e)
2652
+ };
2653
+ this.clockSystem = new Tn(u), this.clockSystem.initialize();
2654
+ }
2655
+ convertDisabledTime() {
2656
+ let e = this.core.disabledTime?.value;
2657
+ if (!e) return null;
2658
+ let t;
2659
+ return e.intervals && (t = Array.isArray(e.intervals) ? e.intervals : [e.intervals]), {
2660
+ hours: e.hours,
2661
+ minutes: e.minutes,
2662
+ seconds: e.seconds,
2663
+ isInterval: e.isInterval,
2664
+ intervals: t,
2665
+ clockType: e.clockType
2666
+ };
2667
+ }
2668
+ getAmPmValue() {
2669
+ if (this.core.options.clock.type === "24h") return "";
2670
+ let e = this.core.getActiveType();
2671
+ if (e) return e;
2672
+ let t = this.core.getAM();
2673
+ return this.core.options.range?.enabled === !0 ? t?.classList.contains("active") ? "AM" : "" : t?.classList.contains("active") ? "AM" : "PM";
2674
+ }
2675
+ reflectClockValue(e, t) {
2676
+ S(W(this.core, e), t), _t(this.core, e), this.emitter.emit("update", K(this.core));
2677
+ }
2678
+ destroy() {
2679
+ this.clockSystem &&= (this.clockSystem.destroy(), null);
2680
+ }
2681
+ }, Dn = class {
2682
+ core;
2683
+ constructor(e) {
2684
+ this.core = e;
2685
+ }
2686
+ setOnStartCSSClassesIfClockType24h() {
2687
+ if (this.core.options.clock.type !== "24h") return;
2688
+ let e = this.core.getInput()?.value.split(":")[0];
2689
+ if (!e) return;
2690
+ let t = Number(e);
2691
+ (t > 12 || t === 0) && (this.core.getCircle()?.classList.add("tp-ui-circle-hand-24h"), this.core.getClockHand()?.classList.add("tp-ui-clock-hand-24h"));
2692
+ }
2693
+ setClassActiveToHourOnOpen() {
2694
+ this.core.options.ui.mobile || this.core.isMobileView || this.core.getHour()?.classList.add(Vt);
2695
+ }
2696
+ }, On = {
2697
+ minutes: {
2698
+ set: "setMinute",
2699
+ show: "switchToMinutes"
2700
+ },
2701
+ seconds: {
2702
+ set: "setSecond",
2703
+ show: "switchToSeconds"
2704
+ }
2705
+ }, kn = class {
2706
+ getClockSystem;
2707
+ getAmPmValue;
2708
+ getClockType;
2709
+ constructor(e, t, n) {
2710
+ this.getClockSystem = e, this.getAmPmValue = t, this.getClockType = n;
2711
+ }
2712
+ setMinutesToClock(e) {
2713
+ this.setSixtyToClock("minutes", e);
2714
+ }
2715
+ setSecondsToClock(e) {
2716
+ this.setSixtyToClock("seconds", e);
2717
+ }
2718
+ setHoursToClock(e) {
2719
+ let t = this.getClockSystem();
2720
+ t && (e && t.setHour(e), t.switchToHours());
2721
+ }
2722
+ updateAmPm() {
2723
+ let e = this.getClockSystem();
2724
+ if (!e || this.getClockType() === "24h") return;
2725
+ let t = this.getAmPmValue();
2726
+ t !== "" && e.setAmPm(t);
2727
+ }
2728
+ setSixtyToClock(e, t) {
2729
+ let n = this.getClockSystem();
2730
+ if (!n) return;
2731
+ let r = On[e];
2732
+ t && n[r.set](t), n[r.show]();
2733
+ }
2734
+ }, An = class {
2735
+ systemInitializer;
2736
+ styleHandler;
2737
+ timeHandler;
2738
+ eventHandler;
2739
+ constructor(e, t) {
2740
+ this.systemInitializer = new En(e, t), this.styleHandler = new Dn(e), this.timeHandler = new kn(() => this.systemInitializer.getClockSystem(), () => this.systemInitializer.getAmPmValue(), () => e.options.clock.type || "12h"), this.eventHandler = new un(t, () => this.systemInitializer.getClockSystem(), (e) => this.timeHandler.setHoursToClock(e), (e) => this.timeHandler.setMinutesToClock(e), () => this.timeHandler.updateAmPm(), () => this.systemInitializer.convertDisabledTime(), (e) => this.timeHandler.setSecondsToClock(e)), this.eventHandler.setup();
2741
+ }
2742
+ initializeClockSystem() {
2743
+ this.systemInitializer.initialize();
2744
+ }
2745
+ destroyClockSystem() {
2746
+ this.systemInitializer.destroy();
2747
+ }
2748
+ setOnStartCSSClassesIfClockType24h() {
2749
+ this.styleHandler.setOnStartCSSClassesIfClockType24h();
2750
+ }
2751
+ setClassActiveToHourOnOpen = () => {
2752
+ this.styleHandler.setClassActiveToHourOnOpen();
2753
+ };
2754
+ syncClockValue(e, t, n, r) {
2755
+ let i = this.systemInitializer.getClockSystem();
2756
+ if (!i) return !1;
2757
+ let a = n === "AM" || n === "PM" ? n : "";
2758
+ return i.syncValue({
2759
+ hour: e,
2760
+ minute: t,
2761
+ second: r,
2762
+ amPm: a
2763
+ }), !0;
2764
+ }
2765
+ destroy() {
2766
+ this.destroyClockSystem();
2767
+ }
2768
+ }, jn = {
2769
+ hour: "12",
2770
+ minutes: "00",
2771
+ seconds: "00"
2772
+ }, Mn = class {
2773
+ core;
2774
+ emitter;
2775
+ cleanupHandlers = [];
2776
+ wasCleared = !1;
2777
+ constructor(e, t) {
2778
+ this.core = e, this.emitter = t;
2779
+ }
2780
+ init() {
2781
+ if (!this.core.options.ui.clearButton) return;
2782
+ let e = this.getClearButton();
2783
+ e && (this.cleanupHandlers.push(w(e, () => {
2784
+ this.core.isDestroyed || this.handleClearClick();
2785
+ })), this.setupInternalEventListeners(), this.updateClearButtonState());
2786
+ }
2787
+ setupInternalEventListeners() {
2788
+ let e = () => this.updateClearButtonState();
2789
+ Kt(this.emitter, this.cleanupHandlers, "update", e), Kt(this.emitter, this.cleanupHandlers, "open", e), U.forEach((t) => {
2790
+ Kt(this.emitter, this.cleanupHandlers, H[t].event, () => {
2791
+ e(), this.reenableConfirmIfCleared();
2792
+ });
2793
+ });
2794
+ }
2795
+ handleClearClick() {
2796
+ let e = this.core.getInput()?.value || null;
2797
+ this.clearTimeValue(), this.resetClockToNeutral(), C(this.core.getOkButton(), !0), this.wasCleared = !0, h(this.core.getModalElement(), this.core.options.labels.announceCleared), this.emitter.emit("clear", { previousValue: e }), this.emitter.emit("update", {
2798
+ hour: void 0,
2799
+ minutes: void 0,
2800
+ type: void 0
2801
+ });
2802
+ }
2803
+ clearTimeValue() {
2804
+ let e = this.core.options.clearBehavior?.clearInput !== !1, t = this.core.getInput();
2805
+ t && e && (t.value = ""), this.core.setDegreesHours(null), this.core.setDegreesMinutes(null), this.core.setDegreesSeconds(null);
2806
+ }
2807
+ resetClockToNeutral() {
2808
+ let e = this.core.options.clock.type === "12h" ? "PM" : void 0;
2809
+ U.forEach((e) => {
2810
+ S(W(this.core, e), jn[e]);
2811
+ });
2812
+ let t = this.core.getClockHand();
2813
+ if (t) {
2814
+ let e = t.style.transition;
2815
+ t.style.transition = "none", t.style.transform = "rotateZ(0deg)", t.offsetHeight, requestAnimationFrame(() => {
2816
+ t.style.transition = e;
2817
+ });
2818
+ }
2819
+ this.removeActiveStates(), this.core.getHour()?.click(), e && b(this.core.getAM(), this.core.getPM(), e), this.emitter.emit("animation:clock", {});
2820
+ }
2821
+ removeActiveStates() {
2822
+ this.core.getAllValueTips().forEach((e) => g(e, "active", !1));
2823
+ }
2824
+ updateClearButtonState() {
2825
+ let e = this.getClearButton();
2826
+ if (!e) return;
2827
+ let t = !!this.core.getInput()?.value.trim(), n = this.core.options.clock.type, r = this.core.getHour()?.value || "", i = this.core.getMinutes()?.value || "", a = this.core.getSeconds()?.value || "", o = this.core.getActiveType() ?? "", s = r !== "" || i !== "" || a !== "", c = r === jn.hour && i === jn.minutes && (a === "" || a === jn.seconds) && (n !== "12h" || o === "PM");
2828
+ C(e, !(t || s && !c));
2829
+ }
2830
+ reenableConfirmIfCleared() {
2831
+ if (!this.wasCleared) return;
2832
+ let e = this.core.getOkButton();
2833
+ e && (C(e, !1), this.wasCleared = !1);
2834
+ }
2835
+ getClearButton() {
2836
+ return this.core.getModalElement()?.querySelector(".tp-ui-clear-btn") || null;
2837
+ }
2838
+ detach() {
2839
+ J(this.cleanupHandlers);
2840
+ }
2841
+ destroy() {
2842
+ this.detach();
2843
+ }
2844
+ }, Nn = class {
2845
+ animation;
2846
+ modal;
2847
+ config;
2848
+ theme;
2849
+ validation;
2850
+ events;
2851
+ clock;
2852
+ clearButton;
2853
+ plugins = /* @__PURE__ */ new Map();
2854
+ constructor(e, t) {
2855
+ this.animation = new le(e, t), this.modal = new ze(e, t), this.config = new zt(e, t), this.theme = new Ht(e, t), this.validation = new Gt(e, t), this.events = new cn(e, t), this.clock = new An(e, t), this.clearButton = new Mn(e, t), E.getAll().forEach((n) => {
2856
+ let r = n.factory(e, t);
2857
+ this.plugins.set(n.name, r);
2858
+ });
2859
+ }
2860
+ getPlugin(e) {
2861
+ return this.plugins.get(e);
2862
+ }
2863
+ destroy() {
2864
+ this.animation.destroy(), this.modal.destroy(), this.config.destroy(), this.theme.destroy(), this.validation.destroy(), this.events.destroy(), this.clock.destroy(), this.clearButton.destroy(), this.plugins.forEach((e) => e.destroy()), this.plugins.clear();
2865
+ }
2866
+ }, Pn = "is-pressed", Fn = "is-rippling", In = /* @__PURE__ */ new WeakSet(), Ln = (e) => e instanceof Element ? e.closest("[data-md3-ripple]") : null, Rn = (e) => {
2867
+ Ln(e.target)?.classList.remove(Pn);
2868
+ }, zn = [
2869
+ ["pointerdown", (e) => {
2870
+ let { pointerType: t, button: n, clientX: r, clientY: i } = e, a = Ln(e.target);
2871
+ if (!a || te(a) || t === "mouse" && n !== 0) return;
2872
+ a.classList.remove(Fn);
2873
+ let { left: o, top: s, width: c, height: l } = a.getBoundingClientRect();
2874
+ a.style.setProperty("--ripple-x", `${r - o}px`), a.style.setProperty("--ripple-y", `${i - s}px`), a.style.setProperty("--ripple-size", `${Math.max(c, l) * 2}px`), a.classList.add(Pn), a.addEventListener("pointerleave", Rn, { once: !0 }), T() || requestAnimationFrame(() => a.classList.add(Fn));
2875
+ }],
2876
+ ["pointerup", Rn],
2877
+ ["pointercancel", Rn],
2878
+ ["animationend", (e) => {
2879
+ e.animationName === "tp-ripple-fade" && Ln(e.target)?.classList.remove(Fn);
2880
+ }]
2881
+ ], Bn = (e) => {
2882
+ if (In.has(e)) return () => {};
2883
+ In.add(e), zn.forEach(([t, n]) => e.addEventListener(t, n));
2884
+ let t = !0;
2885
+ return () => {
2886
+ t && (t = !1, In.delete(e), zn.forEach(([t, n]) => e.removeEventListener(t, n)));
2887
+ };
2888
+ }, Vn = [
2889
+ ["onOpen", "open"],
2890
+ ["onShow", "show"],
2891
+ ["onCancel", "cancel"],
2892
+ ["onConfirm", "confirm"],
2893
+ ["onUpdate", "update"],
2894
+ ["onSelectHour", "select:hour"],
2895
+ ["onSelectMinute", "select:minute"],
2896
+ ["onSelectSecond", "select:second"],
2897
+ ["onSelectAM", "select:am"],
2898
+ ["onSelectPM", "select:pm"],
2899
+ ["onSelectPeriod", "select:period"],
2900
+ ["onSwitchView", "switch:view"],
2901
+ ["onSwitchFace", "switch:face"],
2902
+ ["onError", "error"],
2903
+ ["onTimezoneChange", "timezone:change"],
2904
+ ["onRangeConfirm", "range:confirm"],
2905
+ ["onRangeSwitch", "range:switch"],
2906
+ ["onRangeValidation", "range:validation"],
2907
+ ["onWheelScrollStart", "wheel:scroll:start"],
2908
+ ["onWheelScrollEnd", "wheel:scroll:end"],
2909
+ ["onClear", "clear"]
2910
+ ], Hn = [
2911
+ {
2912
+ needed: De,
2913
+ name: "wheel",
2914
+ plugin: "WheelPlugin"
2915
+ },
2916
+ {
2917
+ needed: (e) => !!e.range?.enabled,
2918
+ name: "range",
2919
+ plugin: "RangePlugin"
2920
+ },
2921
+ {
2922
+ needed: (e) => !!e.timezone?.enabled,
2923
+ name: "timezone",
2924
+ plugin: "TimezonePlugin"
2925
+ }
2926
+ ];
2927
+ function Un(e, t) {
2928
+ for (let [n, r] of Vn) t.on(r, (t) => {
2929
+ let r = e.options.callbacks[n];
2930
+ typeof r == "function" && r(t);
2931
+ });
2932
+ }
2933
+ function Wn(e, t) {
2934
+ for (let n of Hn) n.needed(e.options) && !E.has(n.name) && t.emit("error", { error: `${n.plugin} is not registered. Import and register it: PluginRegistry.register(${n.plugin})` });
2935
+ }
2936
+ var Gn = class {
2937
+ core;
2938
+ managers;
2939
+ emitter;
2940
+ unmountTimeouts = [];
2941
+ rippleCleanup = () => {};
2942
+ isCommitting = !1;
2943
+ isRendering = !1;
2944
+ isRerenderPending = !1;
2945
+ constructor(e, t, n) {
2946
+ this.core = e, this.managers = t, this.emitter = n;
2947
+ }
2948
+ init() {
2949
+ if (!this.core.isDestroyed && !this.core.isInitialized) {
2950
+ Un(this.core, this.emitter);
2951
+ try {
2952
+ this.managers.config.updateInputValueWithCurrentTimeOnStart(), this.managers.validation.checkDisabledValuesOnStart();
2953
+ } catch (e) {
2954
+ this.core.setIsDestroyed(!0), this.reportError(e);
2955
+ return;
2956
+ }
2957
+ this.managers.theme.setTimepickerClassToElement(), this.managers.theme.setInputClassToInputElement(), this.managers.theme.setDataOpenToInputIfDoesntExistInWrapper(), this.managers.theme.setClassTopOpenElement(), this.managers.config.getDisableTime(), j(this.core.options) || this.managers.events.handleOpenOnClick(), this.managers.events.handleOpenOnEnterFocus(), this.core.setIsInitialized(!0);
2958
+ }
2959
+ }
2960
+ applyOptions(e) {
2961
+ let t = this.core.options;
2962
+ this.core.updateOptions(e);
2963
+ try {
2964
+ this.managers.validation.checkDisabledValuesOnStart(), this.managers.config.getDisableTime();
2965
+ } catch (e) {
2966
+ return this.core.setOptions(t), this.reportError(e), !1;
2967
+ }
2968
+ return this.managers.config.checkMobileOption(), this.managers.config.syncInputFormat(t), !0;
2969
+ }
2970
+ reportError(e) {
2971
+ this.emitter.emit("error", { error: e instanceof Error ? e.message : String(e) });
2972
+ }
2973
+ mount() {
2974
+ this.core.isDestroyed || this.core.isOpen || (this.core.isInitialized || this.init(), this.eventsBundle());
2975
+ }
2976
+ rerender() {
2977
+ if (this.isRendering) {
2978
+ this.isRerenderPending = !0;
2979
+ return;
2980
+ }
2981
+ let e = this.managers.modal.getFocusedControlSelector();
2982
+ this.core.setIsOpen(!1), this.releaseOpenView(), this.core.setIsModalRemove(!0), this.eventsBundle(!0), e !== null && this.managers.modal.restoreFocus(e);
2983
+ }
2984
+ discardSelection() {
2985
+ if (j(this.core.options)) {
2986
+ this.rerender(), this.core.getCancelButton()?.focus();
2987
+ return;
2988
+ }
2989
+ this.unmount();
2990
+ }
2991
+ closeUnlessInline() {
2992
+ j(this.core.options) || this.unmount();
2993
+ }
2994
+ unmount(e, t = !1) {
2995
+ if (this.isCommitting) return;
2996
+ t && this.commitSelection(), this.deactivate();
2997
+ let n = () => {
2998
+ this.closeModal(), e && e();
2999
+ }, { delayHandler: r } = this.core.options.behavior;
3000
+ r ? this.unmountTimeouts.push(setTimeout(n, r)) : n();
3001
+ }
3002
+ deactivate() {
3003
+ this.core.setIsOpen(!1), this.releaseOpenView();
3004
+ }
3005
+ releaseOpenView() {
3006
+ this.detachOpenHandlers(), this.managers.clock.destroyClockSystem(), this.managers.getPlugin("wheel")?.detachPopover?.();
3007
+ }
3008
+ commitSelection() {
3009
+ this.core.isOpen && (this.isCommitting = !0, this.core.getOkButton()?.click(), this.isCommitting = !1);
3010
+ }
3011
+ closeModal() {
3012
+ this.core.setIsMobileView(!!this.core.options.ui.mobile), this.core.setIsTouchMouseMove(!1), this.unmountTimeouts.push(setTimeout(() => {
3013
+ this.managers.modal.unlockScroll(), this.core.options.behavior.focusInputAfterClose && this.core.getInput()?.focus(), this.releaseRipple(), this.core.getModalElement()?.remove(), this.core.setIsModalRemove(!0), this.core.getOpenElement().forEach((e) => e?.classList.remove("disabled"));
3014
+ }, this.managers.animation.removeAnimationToClose()));
3015
+ }
3016
+ destroy(e) {
3017
+ if (this.core.isDestroyed) return;
3018
+ this.clearUnmountTimeouts();
3019
+ let { keepInputValue: t = !1, callback: n } = typeof e == "function" ? { callback: e } : e || {}, r = this.core.getInput(), i = t ? r?.value : null;
3020
+ this.releaseRipple(), this.core.getModalElement()?.remove(), this.core.getOpenElement()?.forEach((e) => {
3021
+ e && e.classList.remove("disabled", "tp-ui-open-element");
3022
+ }), r && (r.classList.remove("tp-ui-invalid-format", "tp-ui-input"), r.removeAttribute("data-open"), r.removeAttribute("data-owner-id"), t && i && (r.value = i));
3023
+ let a = this.core.element;
3024
+ a && (a.removeAttribute("data-owner-id"), a.removeAttribute("data-open"), this.core.options.ui.cssClass && a.classList.remove(this.core.options.ui.cssClass)), a?.querySelectorAll(".tp-ui-invalid-text")?.forEach((e) => e.remove()), this.core.reset(), this.managers.destroy(), this.emitter.clear(), this.managers.modal.unlockScroll(), n && n();
3025
+ }
3026
+ eventsBundle(e = !1) {
3027
+ if (this.core.isDestroyed || !this.core.isModalRemove) return;
3028
+ this.isRendering = !0, this.clearUnmountTimeouts(), this.detachOpenHandlers(), this.core.setIsOpen(!0), this.core.setIsModalRemove(!1), this.disableOpenElements(), this.setupModal(), this.setupValidation(), this.applyExpandedState(), this.managers.modal.setFlexEndToFooterIfNoKeyboardIcon(), this.applyWrapperCssClass(), e && this.managers.animation.setAnimationToOpen(!0), this.managers.config.getInputValueOnOpenAndSet(!e);
3029
+ let t = De(this.core.options) && E.has("wheel");
3030
+ Wn(this.core, this.emitter), this.revealClockFace(t, e), this.initClockOrWheel(t), this.initOptionalPlugins(t), this.bindEventHandlers(t), this.initRipple(), A(this.core.options) && this.managers.getPlugin("wheel")?.attachPopover?.(), e || (this.managers.animation.setAnimationToOpen(), this.managers.modal.setInitialFocus()), this.isRendering = !1, this.runPendingRerender(e);
3031
+ }
3032
+ runPendingRerender(e) {
3033
+ let t = this.isRerenderPending;
3034
+ this.isRerenderPending = !1, t && !e && this.core.isOpen && this.rerender();
3035
+ }
3036
+ setupValidation() {
3037
+ this.managers.validation.setErrorHandler();
3038
+ }
3039
+ detachOpenHandlers() {
3040
+ this.managers.events.detach(), this.managers.clearButton.detach();
3041
+ }
3042
+ disableOpenElements() {
3043
+ j(this.core.options) || (this.core.getOpenElement().forEach((e) => e?.classList.add("disabled")), A(this.core.options) || this.core.getInput()?.blur());
3044
+ }
3045
+ setupModal() {
3046
+ this.managers.modal.setScrollbarOrNot(), this.managers.modal.setModalTemplate(), this.managers.modal.setNormalizeClass(), this.managers.modal.removeBackdrop();
3047
+ }
3048
+ applyExpandedState() {
3049
+ if (this.core.isMobileView) {
3050
+ this.managers.config.updateClockFaceAccessibility(!0);
3051
+ return;
3052
+ }
3053
+ this.core.getModalElement()?.querySelectorAll("*").forEach((e) => {
3054
+ e.classList.contains("tp-ui-select-time") || e.classList.add("expanded");
3055
+ });
3056
+ }
3057
+ applyWrapperCssClass() {
3058
+ let { cssClass: e } = this.core.options.ui;
3059
+ e && this.core.getWrapper()?.classList.add(e);
3060
+ }
3061
+ initClockOrWheel(e) {
3062
+ if (e) {
3063
+ let e = this.managers.getPlugin("wheel");
3064
+ e && e.init();
3065
+ } else this.managers.clock.initializeClockSystem(), this.managers.clock.setOnStartCSSClassesIfClockType24h(), this.managers.clock.setClassActiveToHourOnOpen();
3066
+ }
3067
+ initOptionalPlugins(e) {
3068
+ let t = this.managers.getPlugin("timezone");
3069
+ t && t.init();
3070
+ let n = this.managers.getPlugin("range");
3071
+ n && !e && n.init();
3072
+ }
3073
+ bindEventHandlers(e) {
3074
+ this.managers.events.handleCancelButton(), this.managers.events.handleOkButton(), this.managers.clearButton.init(), e || (this.managers.events.handleHourEvents(), this.managers.events.handleMinutesEvents(), this.core.options.clock.showSeconds && this.managers.events.handleSecondsEvents()), this.managers.events.handleKeyboardInput(), this.managers.events.handlePointerModality(), this.core.options.ui.enableSwitchIcon && !e && this.managers.events.handleSwitchViewButton(), this.core.options.clock.type !== "24h" && !Oe(this.core.options) && (this.managers.events.handleAmClick(), this.managers.events.handlePmClick()), this.core.options.behavior.focusTrap && this.managers.events.focusTrapHandler(), j(this.core.options) || (this.managers.events.handleEscClick(), A(this.core.options) || e && this.core.options.wheel?.ignoreOutsideClick || this.managers.events.handleBackdropClick());
3075
+ }
3076
+ initRipple() {
3077
+ let e = this.core.getModalElement();
3078
+ e && (this.rippleCleanup(), this.rippleCleanup = Bn(e));
3079
+ }
3080
+ revealClockFace(e, t) {
3081
+ let n = e ? null : this.core.getClockFace();
3082
+ n && (t ? n.classList.add("scale-in") : typeof requestAnimationFrame < "u" && requestAnimationFrame(() => {
3083
+ requestAnimationFrame(() => {
3084
+ n.classList.add("scale-in");
3085
+ });
3086
+ }));
3087
+ }
3088
+ releaseRipple() {
3089
+ this.rippleCleanup(), this.rippleCleanup = () => {};
3090
+ }
3091
+ clearUnmountTimeouts() {
3092
+ this.unmountTimeouts.forEach(clearTimeout), this.unmountTimeouts = [];
3093
+ }
3094
+ }, Kn = class {
3095
+ events = /* @__PURE__ */ new Map();
3096
+ on(e, t) {
3097
+ this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
3098
+ }
3099
+ once(e, t) {
3100
+ let n = ((r) => {
3101
+ t(r), this.events.get(e)?.delete(n);
3102
+ });
3103
+ n.__originalHandler = t, this.on(e, n);
3104
+ }
3105
+ off(e, t) {
3106
+ if (!t) {
3107
+ this.events.delete(e);
3108
+ return;
3109
+ }
3110
+ let n = this.events.get(e);
3111
+ n && n.forEach((e) => {
3112
+ (e === t || e.__originalHandler === t) && n.delete(e);
3113
+ });
3114
+ }
3115
+ emit(e, t) {
3116
+ let n = this.events.get(e);
3117
+ n && [...n].forEach((e) => {
3118
+ e(t);
3119
+ });
3120
+ }
3121
+ clear() {
3122
+ this.events.clear();
3123
+ }
3124
+ hasListeners(e) {
3125
+ return (this.events.get(e)?.size ?? 0) > 0;
3126
+ }
3127
+ }, qn = (e) => e.replace(/[^0-9:APMapm\s]/g, ""), Jn = {
3128
+ "12h": "Invalid 12h format. Expected HH:MM AM/PM",
3129
+ "24h": "Invalid 24h format. Expected HH:MM"
3130
+ }, Yn = {
3131
+ "12h": "24h",
3132
+ "24h": "12h"
3133
+ }, Xn = (e) => ({
3134
+ ...e,
3135
+ type: e.type ?? "AM"
3136
+ });
3137
+ function Zn(e, t) {
3138
+ let n = k(e.options), r = F(t, n);
3139
+ if (r) {
3140
+ let e = n.showSeconds || Ue(t) ? I(r, n) : t;
3141
+ return {
3142
+ parsed: Xn(r),
3143
+ inputText: e
3144
+ };
3145
+ }
3146
+ let i = Yn[n.clockType], a = F(t, {
3147
+ ...n,
3148
+ clockType: i
3149
+ });
3150
+ if (!a) return null;
3151
+ let o = Ke(a, i, n);
3152
+ return {
3153
+ parsed: Xn(o),
3154
+ inputText: I(o, n)
3155
+ };
3156
+ }
3157
+ function Qn(e) {
3158
+ return { error: Jn[O(e.options)] };
3159
+ }
3160
+ var $n = (e, t) => !e || t === void 0 ? !1 : (S(e, t), !0);
3161
+ function er(e, t) {
3162
+ $n(e.getHour(), t.hour) && e.setDegreesHours(Number(t.hour) * 30), $n(e.getMinutes(), t.minutes) && e.setDegreesMinutes(Number(t.minutes) * 6), $n(e.getSeconds(), t.seconds) && e.setDegreesSeconds(Number(t.seconds) * 6);
3163
+ }
3164
+ function tr(e, t) {
3165
+ e.setDegreesHours(Number(t.hour) * 30), e.setDegreesMinutes(Number(t.minutes) * 6), t.seconds !== void 0 && e.setDegreesSeconds(Number(t.seconds) * 6);
3166
+ }
3167
+ function nr(e, t) {
3168
+ e.options.clock.type !== "24h" && b(e.getAM(), e.getPM(), t === "AM" ? "AM" : "PM");
3169
+ }
3170
+ function rr(e, t, n) {
3171
+ if (De(e.options)) {
3172
+ t.getPlugin("wheel")?.scrollToValue?.(n.hour, n.minutes, n.type, n.seconds);
3173
+ return;
3174
+ }
3175
+ let r = O(e.options) === "24h" ? void 0 : n.type;
3176
+ if (t.clock.syncClockValue(n.hour, n.minutes, r, n.seconds)) return;
3177
+ let i = e.getClockHand();
3178
+ i && (i.style.transform = `rotateZ(${e.degreesHours || 0}deg)`);
3179
+ }
3180
+ var $ = /* @__PURE__ */ new Map(), ir = class {
3181
+ core;
3182
+ managers;
3183
+ lifecycle;
3184
+ emitter;
3185
+ constructor(t, n) {
3186
+ if (e()) throw Error("TimepickerUI requires browser environment");
3187
+ let r = this.resolveRootElement(t);
3188
+ if (!r) throw Error("Input element not found");
3189
+ let i = n?.behavior?.id, a = i || `tp-ui-${Pt()}`, o = f(n || {});
3190
+ if (o.ui.inline?.enabled && typeof n?.behavior?.focusTrap > "u" && (o.behavior.focusTrap = !1), o.ui.inline?.enabled) {
3191
+ let { container: e, containerId: t } = o.ui.inline;
3192
+ if (!e && !t) throw Error("inline.container is required when inline mode is enabled");
3193
+ if (!Ae(o.ui.inline)) throw Error("Inline container not found");
3194
+ }
3195
+ this.emitter = new Kn(), this.core = new p(r, o, a, i);
3196
+ let s = this.core.getInput();
3197
+ if (s) {
3198
+ let { type: e, showSeconds: t } = o.clock;
3199
+ tr(this.core, R(s, e, void 0, void 0, !!t));
3200
+ }
3201
+ this.managers = new Nn(this.core, this.emitter), this.lifecycle = new Gn(this.core, this.managers, this.emitter), this.managers.config.checkMobileOption(), this.managers.config.preventClockTypeByCurrentTime(), this.setupInternalEventListeners(), $.set(this.core.instanceId, this);
3202
+ }
3203
+ setupInternalEventListeners() {
3204
+ this.emitter.on("open:request", () => {
3205
+ this.core.isDestroyed || this.lifecycle.mount();
3206
+ }), this.emitter.on("cancel", () => {
3207
+ this.core.isDestroyed || this.lifecycle.discardSelection();
3208
+ }), this.emitter.on("confirm", (e) => {
3209
+ if (!this.core.isDestroyed) {
3210
+ if (this.core.options.range?.enabled) return;
3211
+ this.writeInputValue(e), e.autoCommit || this.lifecycle.closeUnlessInline();
3212
+ }
3213
+ }), this.emitter.on("update", (e) => {
3214
+ if (this.core.isDestroyed || this.core.options.range?.enabled) return;
3215
+ let { inline: t } = this.core.options.ui;
3216
+ !t?.enabled || !t.autoUpdate || this.writeInputValue(e);
3217
+ }), this.emitter.on("range:confirm", (e) => {
3218
+ if (this.core.isDestroyed) return;
3219
+ let t = this.core.getInput();
3220
+ t && (t.value = `${e.from} - ${e.to}`), this.lifecycle.closeUnlessInline();
3221
+ }), this.emitter.on("select:am", () => this.emitter.emit("select:period", { type: "AM" })), this.emitter.on("select:pm", () => this.emitter.emit("select:period", { type: "PM" }));
3222
+ }
3223
+ writeInputValue(e) {
3224
+ !e.hour || !e.minutes || this.setInputText(I(e, k(this.core.options)));
3225
+ }
3226
+ setInputText(e) {
3227
+ let t = this.core.getInput();
3228
+ t && (t.value = e, this.managers.validation.removeErrorHandler());
3229
+ }
3230
+ create() {
3231
+ this.lifecycle.init(), this.core.options.ui.inline?.enabled && this.lifecycle.mount();
3232
+ }
3233
+ open(e) {
3234
+ this.lifecycle.mount(), e && e();
3235
+ }
3236
+ close(e, t) {
3237
+ if (e) {
3238
+ this.lifecycle.unmount(t, !0);
3239
+ return;
3240
+ }
3241
+ this.lifecycle.unmount(), t && t();
3242
+ }
3243
+ destroy(e) {
3244
+ $.delete(this.core.instanceId), this.lifecycle.destroy(e);
3245
+ }
3246
+ update(e, t) {
3247
+ this.core.isDestroyed || this.lifecycle.applyOptions(e.options) && (this.core.isOpen && this.lifecycle.rerender(), e.create && this.create(), t && t());
3248
+ }
3249
+ setOptions(e) {
3250
+ this.update({ options: e });
3251
+ }
3252
+ getValue() {
3253
+ if (this.core.isDestroyed) return {
3254
+ hour: "",
3255
+ minutes: "",
3256
+ type: void 0,
3257
+ time: "",
3258
+ degreesHours: null,
3259
+ degreesMinutes: null
3260
+ };
3261
+ let e = k(this.core.options), t = {
3262
+ hour: "12",
3263
+ minutes: "00",
3264
+ seconds: e.showSeconds ? "00" : void 0,
3265
+ type: e.clockType === "24h" ? void 0 : "AM"
3266
+ }, n = this.core.getModalElement(), r = this.core.getInput(), i = t;
3267
+ n && this.core.isOpen ? i = this.readOpenValue(e.clockType, t) : r && (i = R(r, this.core.options.clock.type, void 0, void 0, e.showSeconds));
3268
+ let { degreesHours: a, degreesMinutes: o } = n || r ? Je(i) : {
3269
+ degreesHours: null,
3270
+ degreesMinutes: null
3271
+ }, s = {
3272
+ hour: i.hour,
3273
+ minutes: i.minutes,
3274
+ type: i.type,
3275
+ time: I(i, e),
3276
+ degreesHours: a,
3277
+ degreesMinutes: o
3278
+ };
3279
+ return e.showSeconds && (s.seconds = i.seconds ?? t.seconds), s;
3280
+ }
3281
+ readOpenValue(e, t) {
3282
+ let n = (t) => {
3283
+ if (e !== "24h") return t ?? "AM";
3284
+ };
3285
+ if (Oe(this.core.options)) {
3286
+ let e = this.managers.getPlugin("wheel")?.getSelection?.();
3287
+ return e ? {
3288
+ hour: e.hour,
3289
+ minutes: e.minutes,
3290
+ seconds: e.seconds ?? t.seconds,
3291
+ type: n(e.type)
3292
+ } : t;
3293
+ }
3294
+ return {
3295
+ hour: this.core.getHour()?.value || t.hour,
3296
+ minutes: this.core.getMinutes()?.value || t.minutes,
3297
+ seconds: this.core.getSeconds()?.value || t.seconds,
3298
+ type: n(this.core.getActiveType())
3299
+ };
3300
+ }
3301
+ setValue(e, t = !0) {
3302
+ if (this.core.isDestroyed || typeof e != "string" || !e.trim() || !this.core.isInitialized && (this.create(), this.core.isDestroyed)) return;
3303
+ let n = Zn(this.core, qn(e.trim()));
3304
+ if (!n) {
3305
+ this.emitter.emit("error", Qn(this.core));
3306
+ return;
3307
+ }
3308
+ let { parsed: r, inputText: i } = n;
3309
+ er(this.core, r), nr(this.core, r.type), t && this.setInputText(i), rr(this.core, this.managers, r);
3310
+ }
3311
+ getElement() {
3312
+ return this.core.element;
3313
+ }
3314
+ get instanceId() {
3315
+ return this.core.instanceId;
3316
+ }
3317
+ get options() {
3318
+ return this.core.options;
3319
+ }
3320
+ get isInitialized() {
3321
+ return this.core.isInitialized;
3322
+ }
3323
+ get isDestroyed() {
3324
+ return this.core.isDestroyed;
3325
+ }
3326
+ get hour() {
3327
+ return this.core.getHour();
3328
+ }
3329
+ get minutes() {
3330
+ return this.core.getMinutes();
3331
+ }
3332
+ get okButton() {
3333
+ return this.core.getOkButton();
3334
+ }
3335
+ get cancelButton() {
3336
+ return this.core.getCancelButton();
3337
+ }
3338
+ get clockHand() {
3339
+ return this.core.getClockHand();
3340
+ }
3341
+ on(e, t) {
3342
+ this.core.isDestroyed || this.emitter.on(e, t);
3343
+ }
3344
+ once(e, t) {
3345
+ this.core.isDestroyed || this.emitter.once(e, t);
3346
+ }
3347
+ off(e, t) {
3348
+ this.core.isDestroyed || this.emitter.off(e, t);
3349
+ }
3350
+ resolveRootElement(e) {
3351
+ if (t() === !1) return null;
3352
+ let n = typeof e == "string" ? document.querySelector(e) : e;
3353
+ if (!(n instanceof HTMLElement)) return null;
3354
+ if (n.tagName !== "INPUT") return n.querySelector("input") ? (n.classList.add("tp-ui"), n) : null;
3355
+ let r = n.parentElement;
3356
+ if (r?.classList.contains("tp-ui")) return r;
3357
+ let i = document.createElement("div");
3358
+ return i.className = "tp-ui", n.before(i), i.appendChild(n), i;
3359
+ }
3360
+ static getById(e) {
3361
+ return $.get(e);
3362
+ }
3363
+ static getAllInstances() {
3364
+ return Array.from($.values());
3365
+ }
3366
+ static isAvailable(t) {
3367
+ return e() ? !1 : typeof t == "string" ? document.querySelector(t) !== null : t instanceof HTMLElement && document.contains(t);
3368
+ }
3369
+ static destroyAll() {
3370
+ Array.from($.values()).forEach((e) => e.destroy()), $.clear();
3371
+ }
3372
+ };
3373
+ //#endregion
3374
+ export { E as PluginRegistry, ir as TimepickerUI };