datex-ui 1.0.0

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,1316 @@
1
+ function v(c, t) {
2
+ const e = c.getFullYear(), i = String(c.getMonth() + 1).padStart(2, "0"), a = String(c.getDate()).padStart(2, "0"), n = String(c.getHours()).padStart(2, "0"), o = String(c.getMinutes()).padStart(2, "0"), r = String(c.getSeconds()).padStart(2, "0");
3
+ return t.replace(/YYYY/g, String(e)).replace(/MM/g, i).replace(/DD/g, a).replace(/HH/g, n).replace(/mm/g, o).replace(/ss/g, r);
4
+ }
5
+ function $(c, t) {
6
+ const e = new Date(c);
7
+ return e.setDate(e.getDate() + t), e;
8
+ }
9
+ function y(c, t) {
10
+ const e = new Date(c);
11
+ return e.setMonth(e.getMonth() + t), e;
12
+ }
13
+ function M(c) {
14
+ const t = new Date(c);
15
+ return t.setHours(0, 0, 0, 0), t;
16
+ }
17
+ function E(c) {
18
+ const t = new Date(c);
19
+ return t.setHours(23, 59, 59, 999), t;
20
+ }
21
+ function b(c, t) {
22
+ return c.getTime() > t.getTime();
23
+ }
24
+ function g(c, t) {
25
+ return c.getTime() < t.getTime();
26
+ }
27
+ function C(c, t) {
28
+ if (t === "YYYY-MM-DD")
29
+ return new Date(c);
30
+ if (t === "DD/MM/YYYY") {
31
+ const e = c.split("/");
32
+ if (e.length === 3) {
33
+ const i = parseInt(e[0], 10), a = parseInt(e[1], 10) - 1, n = parseInt(e[2], 10);
34
+ return new Date(n, a, i);
35
+ }
36
+ }
37
+ if (t === "DD/MM/YYYY HH:mm") {
38
+ const [e, i] = c.split(" "), a = e.split("/"), n = i ? i.split(":") : ["0", "0"];
39
+ if (a.length === 3) {
40
+ const o = parseInt(a[0], 10), r = parseInt(a[1], 10) - 1, f = parseInt(a[2], 10), h = parseInt(n[0], 10) || 0, d = parseInt(n[1], 10) || 0;
41
+ return new Date(f, r, o, h, d);
42
+ }
43
+ }
44
+ return new Date(c);
45
+ }
46
+ function x(c, t, e = "day") {
47
+ if (!c || !t) return !1;
48
+ switch (e) {
49
+ case "day":
50
+ return c.getFullYear() === t.getFullYear() && c.getMonth() === t.getMonth() && c.getDate() === t.getDate();
51
+ case "month":
52
+ return c.getFullYear() === t.getFullYear() && c.getMonth() === t.getMonth();
53
+ case "year":
54
+ return c.getFullYear() === t.getFullYear();
55
+ default:
56
+ return !1;
57
+ }
58
+ }
59
+ function S(c) {
60
+ return c instanceof Date && !isNaN(c.getTime());
61
+ }
62
+ const L = {
63
+ primaryColor: "#357ebd",
64
+ secondaryColor: "#ccc",
65
+ backgroundColor: "#ffffff",
66
+ borderColor: "#ddd",
67
+ textColor: "#000000",
68
+ hoverColor: "#eee",
69
+ selectedColor: "#357ebd",
70
+ rangeColor: "#ebf4f8",
71
+ todayColor: "#357ebd",
72
+ disabledColor: "#999",
73
+ applyButtonColor: "#357ebd",
74
+ cancelButtonColor: "#999",
75
+ borderRadius: "4px",
76
+ fontSize: "15px",
77
+ fontFamily: "arial"
78
+ }, I = {
79
+ primaryColor: "#0d6efd",
80
+ secondaryColor: "#6c757d",
81
+ backgroundColor: "#ffffff",
82
+ borderColor: "#dee2e6",
83
+ textColor: "#212529",
84
+ hoverColor: "#e9ecef",
85
+ selectedColor: "#0d6efd",
86
+ rangeColor: "#cfe2ff",
87
+ todayColor: "#0d6efd",
88
+ disabledColor: "#adb5bd",
89
+ applyButtonColor: "#198754",
90
+ cancelButtonColor: "#dc3545",
91
+ borderRadius: "6px",
92
+ fontSize: "14px",
93
+ fontFamily: 'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
94
+ }, T = {
95
+ primaryColor: "#1976d2",
96
+ secondaryColor: "#757575",
97
+ backgroundColor: "#ffffff",
98
+ borderColor: "#e0e0e0",
99
+ textColor: "#212121",
100
+ hoverColor: "#f5f5f5",
101
+ selectedColor: "#1976d2",
102
+ rangeColor: "#e3f2fd",
103
+ todayColor: "#1976d2",
104
+ disabledColor: "#bdbdbd",
105
+ applyButtonColor: "#4caf50",
106
+ cancelButtonColor: "#f44336",
107
+ borderRadius: "4px",
108
+ fontSize: "14px",
109
+ fontFamily: 'Roboto, "Helvetica Neue", Arial, sans-serif'
110
+ }, Y = {
111
+ format: "DD/MM/YYYY",
112
+ separator: " - ",
113
+ applyLabel: "Aplicar",
114
+ cancelLabel: "Cancelar",
115
+ customRangeLabel: "Rango Personalizado",
116
+ daysOfWeek: ["Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
117
+ monthNames: [
118
+ "Enero",
119
+ "Febrero",
120
+ "Marzo",
121
+ "Abril",
122
+ "Mayo",
123
+ "Junio",
124
+ "Julio",
125
+ "Agosto",
126
+ "Septiembre",
127
+ "Octubre",
128
+ "Noviembre",
129
+ "Diciembre"
130
+ ],
131
+ firstDay: 1
132
+ // Monday
133
+ }, A = {
134
+ format: "DD/MM/YYYY HH:mm",
135
+ separator: " - ",
136
+ applyLabel: "Aplicar",
137
+ cancelLabel: "Cancelar",
138
+ customRangeLabel: "Rango Personalizado",
139
+ daysOfWeek: ["Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
140
+ monthNames: [
141
+ "Enero",
142
+ "Febrero",
143
+ "Marzo",
144
+ "Abril",
145
+ "Mayo",
146
+ "Junio",
147
+ "Julio",
148
+ "Agosto",
149
+ "Septiembre",
150
+ "Octubre",
151
+ "Noviembre",
152
+ "Diciembre"
153
+ ],
154
+ firstDay: 1
155
+ // Monday
156
+ };
157
+ class q {
158
+ constructor(t, e = {}, i) {
159
+ if (this.boundHandlers = /* @__PURE__ */ new Map(), this.element = typeof t == "string" ? (t.startsWith("#") ? document.getElementById(t.slice(1)) : document.querySelector(t)) || document.getElementById(t) : t, !this.element)
160
+ throw new Error("Datex: Element not found");
161
+ this.options = this.mergeOptions(e), this.locale = this.options.locale, this.theme = { ...this.options.theme }, this.callback = i || (() => {
162
+ });
163
+ const a = /* @__PURE__ */ new Date();
164
+ this.state = {
165
+ startDate: this.options.timePicker ? this.options.startDate : M(this.options.startDate),
166
+ endDate: this.options.timePicker ? this.options.endDate : E(this.options.endDate),
167
+ oldStartDate: this.options.timePicker ? this.options.startDate : M(this.options.startDate),
168
+ oldEndDate: this.options.timePicker ? this.options.endDate : E(this.options.endDate),
169
+ isShowing: !1,
170
+ leftCalendar: { month: a, calendar: [] },
171
+ rightCalendar: { month: y(a, 1), calendar: [] },
172
+ chosenLabel: null,
173
+ hoverDate: null
174
+ }, this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel(), this.applyTheme();
175
+ }
176
+ applyTheme() {
177
+ if (!this.container)
178
+ return;
179
+ const t = this.container.dataset.themeStyleId;
180
+ if (t) {
181
+ const a = document.getElementById(t);
182
+ a && a.remove();
183
+ }
184
+ const e = "daterangepicker-theme-" + Math.random().toString(36).slice(2, 9), i = document.createElement("style");
185
+ i.id = e, i.textContent = this.generateThemeCSS(), document.head.appendChild(i), this.container.dataset.themeStyleId = e, this.container.offsetHeight;
186
+ }
187
+ generateThemeCSS() {
188
+ const t = this.theme;
189
+ return `
190
+ .datex-picker {
191
+ background-color: ${t.backgroundColor} !important;
192
+ border: 1px solid ${t.borderColor} !important;
193
+ border-radius: ${t.borderRadius} !important;
194
+ font-family: ${t.fontFamily} !important;
195
+ font-size: ${t.fontSize} !important;
196
+ color: ${t.textColor} !important;
197
+ line-height: 1em !important;
198
+ width: 278px !important;
199
+ z-index: 3001 !important;
200
+ }
201
+
202
+ /* IMPORTANTE: Permitir interacción con selectores */
203
+ .datex-picker select,
204
+ .datex-picker select * {
205
+ user-select: auto !important;
206
+ pointer-events: auto !important;
207
+ -webkit-user-select: auto !important;
208
+ -moz-user-select: auto !important;
209
+ -ms-user-select: auto !important;
210
+ }
211
+
212
+ .datex-picker:before {
213
+ border-bottom: 7px solid #ccc !important;
214
+ }
215
+
216
+ .datex-picker:after {
217
+ border-bottom-color: ${t.backgroundColor} !important;
218
+ }
219
+
220
+ .datex-picker.drop-up:before {
221
+ border-top: 7px solid #ccc !important;
222
+ }
223
+
224
+ .datex-picker.drop-up:after {
225
+ border-top-color: ${t.backgroundColor} !important;
226
+ }
227
+
228
+ .datex-picker .calendar-table {
229
+ background-color: ${t.backgroundColor} !important;
230
+ border: 1px solid ${t.backgroundColor} !important;
231
+ border-radius: ${t.borderRadius} !important;
232
+ }
233
+
234
+ .datex-picker .calendar-table th,
235
+ .datex-picker .calendar-table td {
236
+ min-width: 28px !important;
237
+ width: 28px !important;
238
+ height: 22px !important;
239
+ line-height: 20px !important;
240
+ font-size: 11px !important;
241
+ border-radius: 3px !important;
242
+ border: 1px solid transparent !important;
243
+ white-space: nowrap !important;
244
+ cursor: pointer !important;
245
+ text-align: center !important;
246
+ vertical-align: middle !important;
247
+ }
248
+
249
+ .datex-picker .calendar-table th {
250
+ color: ${t.textColor} !important;
251
+ }
252
+
253
+ .datex-picker .calendar-table th.month {
254
+ color: ${t.textColor} !important;
255
+ width: auto !important;
256
+ }
257
+
258
+ .datex-picker .calendar-table .next span,
259
+ .datex-picker .calendar-table .prev span {
260
+ color: #fff !important;
261
+ border: solid black !important;
262
+ border-width: 0 2px 2px 0 !important;
263
+ border-radius: 0 !important;
264
+ display: inline-block !important;
265
+ padding: 3px !important;
266
+ }
267
+
268
+ .datex-picker .calendar-table .next span {
269
+ transform: rotate(-45deg) !important;
270
+ -webkit-transform: rotate(-45deg) !important;
271
+ }
272
+
273
+ .datex-picker .calendar-table .prev span {
274
+ transform: rotate(135deg) !important;
275
+ -webkit-transform: rotate(135deg) !important;
276
+ }
277
+
278
+ .datex-picker .calendar-table .next,
279
+ .datex-picker .calendar-table .prev {
280
+ cursor: pointer !important;
281
+ user-select: none !important;
282
+ width: 32px !important;
283
+ height: 28px !important;
284
+ }
285
+
286
+ .datex-picker .calendar-table .next:hover,
287
+ .datex-picker .calendar-table .prev:hover {
288
+ background-color: #f0f0f0 !important;
289
+ }
290
+
291
+ .datex-picker td.available:hover,
292
+ .datex-picker th.available:hover {
293
+ background-color: #eee !important;
294
+ border-color: transparent !important;
295
+ color: ${t.textColor} !important;
296
+ }
297
+
298
+ .datex-picker td.week,
299
+ .datex-picker th.week {
300
+ font-size: 80% !important;
301
+ color: #ccc !important;
302
+ }
303
+
304
+ .datex-picker td.off,
305
+ .datex-picker td.off.in-range,
306
+ .datex-picker td.off.start-date,
307
+ .datex-picker td.off.end-date {
308
+ background-color: ${t.backgroundColor} !important;
309
+ border-color: transparent !important;
310
+ color: #999 !important;
311
+ }
312
+
313
+ .datex-picker td.in-range {
314
+ background-color: #ebf4f8 !important;
315
+ border-color: transparent !important;
316
+ color: #000 !important;
317
+ border-radius: 0 !important;
318
+ }
319
+
320
+ .datex-picker td.start-date {
321
+ border-radius: 3px 0 0 3px !important;
322
+ background-color: #357ebd !important;
323
+ color: #fff !important;
324
+ }
325
+
326
+ .datex-picker td.end-date {
327
+ border-radius: 0 3px 3px 0 !important;
328
+ background-color: #357ebd !important;
329
+ color: #fff !important;
330
+ }
331
+
332
+ .datex-picker td.start-date.end-date {
333
+ border-radius: 3px !important;
334
+ }
335
+
336
+ .datex-picker td.active,
337
+ .datex-picker td.active:hover {
338
+ background-color: #357ebd !important;
339
+ border-color: transparent !important;
340
+ color: #fff !important;
341
+ }
342
+
343
+ .datex-picker td.disabled,
344
+ .datex-picker option.disabled {
345
+ color: ${t.disabledColor} !important;
346
+ cursor: not-allowed !important;
347
+ text-decoration: line-through !important;
348
+ }
349
+
350
+ .datex-picker .drp-calendar.left {
351
+ padding: 8px 0 8px 8px !important;
352
+ }
353
+
354
+ .datex-picker .drp-calendar.right {
355
+ padding: 8px !important;
356
+ }
357
+
358
+ .datex-picker .ranges {
359
+ float: none !important;
360
+ text-align: left !important;
361
+ margin: 0 !important;
362
+ }
363
+
364
+ .datex-picker .ranges ul {
365
+ list-style: none !important;
366
+ margin: 0 auto !important;
367
+ padding: 0 !important;
368
+ width: 100% !important;
369
+ }
370
+
371
+ .datex-picker .ranges li {
372
+ font-size: 12px !important;
373
+ padding: 8px 12px !important;
374
+ cursor: pointer !important;
375
+ color: ${t.textColor} !important;
376
+ border-radius: ${t.borderRadius} !important;
377
+ margin: 2px 0 !important;
378
+ }
379
+
380
+ .datex-picker .ranges li:hover {
381
+ background-color: ${t.rangeColor} !important;
382
+ color: ${t.textColor} !important;
383
+ }
384
+
385
+ .datex-picker .ranges li.active {
386
+ background-color: ${t.selectedColor} !important;
387
+ color: #fff !important;
388
+ }
389
+
390
+ .datex-picker .ranges li.active:hover {
391
+ background-color: ${t.selectedColor} !important;
392
+ color: #fff !important;
393
+ opacity: 0.9 !important;
394
+ }
395
+
396
+ .datex-picker.show-calendar .drp-buttons {
397
+ display: block !important;
398
+ }
399
+
400
+ .datex-picker.auto-apply .drp-buttons {
401
+ display: none !important;
402
+ }
403
+
404
+ .datex-picker .drp-buttons {
405
+ clear: both !important;
406
+ text-align: right !important;
407
+ padding: 2px !important;
408
+ border-top: 1px solid ${t.borderColor} !important;
409
+ display: none !important;
410
+ line-height: 10px !important;
411
+ vertical-align: middle !important;
412
+ margin: 0px;
413
+ }
414
+
415
+ .datex-picker .drp-selected {
416
+ display: inline-block !important;
417
+ font-size: 12px !important;
418
+ padding-right: 8px !important;
419
+ color: ${t.textColor} !important;
420
+ }
421
+
422
+ .datex-picker .drp-buttons .btn {
423
+ margin-left: 4px !important;
424
+ font-size: 12px !important;
425
+ font-weight: bold !important;
426
+ padding: 7px 8px !important;
427
+ border-radius: 3px !important;
428
+ border: 1px solid transparent !important;
429
+ cursor: pointer !important;
430
+ transition: all 0.15s ease-in-out !important;
431
+ }
432
+
433
+ .datex-picker .drp-buttons .btn.btn-success {
434
+ background-color: ${t.applyButtonColor} !important;
435
+ border-color: ${t.applyButtonColor} !important;
436
+ color: #fff !important;
437
+ }
438
+
439
+ .datex-picker .drp-buttons .btn.btn-success:hover:not(:disabled) {
440
+ background-color: ${t.applyButtonColor} !important;
441
+ border-color: ${t.applyButtonColor} !important;
442
+ opacity: 0.8 !important;
443
+ }
444
+
445
+ .datex-picker .drp-buttons .btn.btn-danger {
446
+ background-color: ${t.cancelButtonColor} !important;
447
+ border-color: ${t.cancelButtonColor} !important;
448
+ color: #fff !important;
449
+ }
450
+
451
+ .datex-picker .drp-buttons .btn.btn-danger:hover:not(:disabled) {
452
+ background-color: ${t.cancelButtonColor} !important;
453
+ border-color: ${t.cancelButtonColor} !important;
454
+ opacity: 0.8 !important;
455
+ }
456
+
457
+ /* Asegurar que el contenedor no bloquee eventos */
458
+ .datex-picker .calendar-table th.month {
459
+ pointer-events: auto !important;
460
+ }
461
+
462
+ .datex-picker .calendar-table th.month * {
463
+ pointer-events: auto !important;
464
+ }
465
+
466
+ .datex-picker select.monthselect,
467
+ .datex-picker select.yearselect {
468
+ font-size: 12px !important;
469
+ padding: 1px 2px !important;
470
+ height: auto !important;
471
+ margin: 0 !important;
472
+ cursor: pointer !important;
473
+ background-color: ${t.backgroundColor} !important;
474
+ border: 1px solid ${t.borderColor} !important;
475
+ color: ${t.textColor} !important;
476
+ outline: none !important;
477
+ /* Asegurar que los dropdowns funcionen nativamente */
478
+ appearance: auto !important;
479
+ -webkit-appearance: menulist !important;
480
+ -moz-appearance: menulist !important;
481
+ /* Permitir interacción */
482
+ pointer-events: auto !important;
483
+ user-select: auto !important;
484
+ -webkit-user-select: auto !important;
485
+ -moz-user-select: auto !important;
486
+ /* Tamaño mínimo para ser clickeable */
487
+ min-height: 20px !important;
488
+ min-width: 50px !important;
489
+ /* Asegurar que estén por encima de otros elementos */
490
+ position: relative !important;
491
+ z-index: 1000000 !important;
492
+ /* Remover cualquier transformación que pueda interferir */
493
+ transform: none !important;
494
+ /* Asegurar que no estén bloqueados por overlay */
495
+ isolation: auto !important;
496
+ }
497
+
498
+ .datex-picker select.monthselect {
499
+ margin-right: 2% !important;
500
+ width: 56% !important;
501
+ }
502
+
503
+ .datex-picker select.yearselect {
504
+ width: 40% !important;
505
+ }
506
+
507
+ .datex-picker select.hourselect,
508
+ .datex-picker select.minuteselect,
509
+ .datex-picker select.secondselect,
510
+ .datex-picker select.ampmselect {
511
+ width: 50px !important;
512
+ margin: 0 auto !important;
513
+ background: ${t.backgroundColor} !important;
514
+ border: 1px solid ${t.borderColor} !important;
515
+ color: ${t.textColor} !important;
516
+ padding: 2px !important;
517
+ outline: 0 !important;
518
+ font-size: 12px !important;
519
+ pointer-events: auto !important;
520
+ user-select: auto !important;
521
+ -webkit-user-select: auto !important;
522
+ -moz-user-select: auto !important;
523
+ appearance: auto !important;
524
+ -webkit-appearance: menulist !important;
525
+ -moz-appearance: menulist !important;
526
+ border-radius: ${t.borderRadius} !important;
527
+ opacity: 1 !important;
528
+ }
529
+
530
+ .datex-picker .calendar-time {
531
+ text-align: center !important;
532
+ margin: 4px auto 0 auto !important;
533
+ line-height: 30px !important;
534
+ position: relative !important;
535
+ display: block !important;
536
+ background: ${t.backgroundColor} !important;
537
+ padding: 8px !important;
538
+ border-top: 1px solid ${t.borderColor} !important;
539
+ }
540
+
541
+ .datex-picker .calendar-time select.disabled {
542
+ color: ${t.secondaryColor} !important;
543
+ cursor: not-allowed !important;
544
+ background: ${t.hoverColor} !important;
545
+ opacity: 0.6 !important;
546
+ }
547
+
548
+ .datex-picker select option {
549
+ background: ${t.backgroundColor} !important;
550
+ color: ${t.textColor} !important;
551
+ }
552
+
553
+ .datex-picker select option:disabled {
554
+ background: ${t.hoverColor} !important;
555
+ color: ${t.disabledColor} !important;
556
+ }
557
+
558
+ .datex-picker select option:hover {
559
+ background: ${t.selectedColor} !important;
560
+ color: #fff !important;
561
+ }
562
+
563
+ /* Media queries para responsive - exactamente como el CSS original */
564
+ @media (min-width: 564px) {
565
+ .datex-picker {
566
+ width: auto !important;
567
+ }
568
+
569
+ .datex-picker .ranges ul {
570
+ width: 140px !important;
571
+ }
572
+
573
+ .datex-picker.single .ranges ul {
574
+ width: 100% !important;
575
+ }
576
+
577
+ .datex-picker .drp-calendar.left {
578
+ clear: left !important;
579
+ margin-right: 0 !important;
580
+ }
581
+
582
+ .datex-picker .drp-calendar.left .calendar-table {
583
+ border-right: none !important;
584
+ border-top-right-radius: 0 !important;
585
+ border-bottom-right-radius: 0 !important;
586
+ padding-right: 8px !important;
587
+ }
588
+
589
+ .datex-picker .drp-calendar.right {
590
+ margin-left: 0 !important;
591
+ }
592
+
593
+ .datex-picker .drp-calendar.right .calendar-table {
594
+ border-left: none !important;
595
+ border-top-left-radius: 0 !important;
596
+ border-bottom-left-radius: 0 !important;
597
+ }
598
+
599
+ .datex-picker .ranges,
600
+ .datex-picker .drp-calendar {
601
+ float: left !important;
602
+ }
603
+ }
604
+
605
+ @media (min-width: 730px) {
606
+ .datex-picker .ranges {
607
+ width: auto !important;
608
+ float: left !important;
609
+ }
610
+
611
+ .datex-picker .drp-calendar.left {
612
+ clear: none !important;
613
+ }
614
+ }
615
+ `;
616
+ }
617
+ // Public method to change theme dynamically
618
+ setTheme(t) {
619
+ this.theme = { ...L, ...t }, this.applyTheme();
620
+ }
621
+ // Public method to force theme reapplication
622
+ refreshTheme() {
623
+ this.applyTheme();
624
+ }
625
+ // Debug method to check current theme
626
+ getCurrentTheme() {
627
+ return this.theme;
628
+ }
629
+ // Debug method to test dropdowns
630
+ testDropdowns() {
631
+ this.container.querySelectorAll("select").forEach((e, i) => {
632
+ e.addEventListener("click", () => {
633
+ }), e.click();
634
+ });
635
+ }
636
+ mergeOptions(t) {
637
+ const e = /* @__PURE__ */ new Date(), i = {
638
+ startDate: t.startDate || e,
639
+ endDate: t.endDate || e,
640
+ minDate: t.minDate ?? null,
641
+ maxDate: t.maxDate ?? null,
642
+ minYear: t.minYear ?? e.getFullYear() - 100,
643
+ maxYear: t.maxYear ?? e.getFullYear() + 100,
644
+ maxSpan: t.maxSpan ?? null,
645
+ autoApply: t.autoApply ?? !1,
646
+ singleDatePicker: t.singleDatePicker ?? !1,
647
+ showDropdowns: t.showDropdowns ?? !0,
648
+ linkedCalendars: t.linkedCalendars ?? !0,
649
+ autoUpdateInput: t.autoUpdateInput ?? !0,
650
+ alwaysShowCalendars: t.alwaysShowCalendars ?? !1,
651
+ showCustomRangeLabel: t.showCustomRangeLabel ?? !0,
652
+ timePicker: t.timePicker ?? !1,
653
+ timePicker24Hour: t.timePicker24Hour ?? !0,
654
+ timePickerIncrement: t.timePickerIncrement ?? 1,
655
+ timePickerSeconds: t.timePickerSeconds ?? !1,
656
+ ranges: t.ranges || {},
657
+ opens: t.opens || "center",
658
+ drops: t.drops || "auto",
659
+ locale: t.locale || Y,
660
+ buttonClasses: t.buttonClasses || "btn btn-sm",
661
+ applyButtonClasses: t.applyButtonClasses || "btn-success",
662
+ cancelButtonClasses: t.cancelButtonClasses || "btn-danger",
663
+ theme: t.theme || L
664
+ };
665
+ return i.timePicker && i.autoApply && (i.autoApply = !1), i;
666
+ }
667
+ createContainer() {
668
+ const t = `
669
+ <div class="datex-picker">
670
+ <div class="ranges"></div>
671
+ <div class="drp-calendar left">
672
+ <div class="calendar-table"></div>
673
+ <div class="calendar-time"></div>
674
+ </div>
675
+ <div class="drp-calendar right">
676
+ <div class="calendar-table"></div>
677
+ <div class="calendar-time"></div>
678
+ </div>
679
+ <div class="drp-buttons">
680
+ <span class="drp-selected"></span>
681
+ <button class="cancelBtn ${this.options.buttonClasses} ${this.options.cancelButtonClasses}" type="button">
682
+ ${this.locale.cancelLabel}
683
+ </button>
684
+ <button class="applyBtn ${this.options.buttonClasses} ${this.options.applyButtonClasses}" type="button">
685
+ ${this.locale.applyLabel}
686
+ </button>
687
+ </div>
688
+ </div>
689
+ `, e = document.createElement("div");
690
+ e.innerHTML = t.trim(), this.container = e.firstElementChild, document.body.appendChild(this.container), this.container.classList.add(`opens${this.options.opens}`), this.options.singleDatePicker && this.container.classList.add("single"), this.options.autoApply && this.container.classList.add("auto-apply"), Object.keys(this.options.ranges).length > 0 && (this.container.classList.add("show-ranges"), this.renderRanges()), (this.options.alwaysShowCalendars || Object.keys(this.options.ranges).length === 0) && this.container.classList.add("show-calendar"), this.options.autoApply || this.container.classList.add("show-calendar"), this.options.timePicker || this.container.querySelectorAll(".calendar-time").forEach((a) => {
691
+ a.style.display = "none";
692
+ }), this.container.style.display = "none";
693
+ }
694
+ renderRanges() {
695
+ const t = this.container.querySelector(".ranges");
696
+ let e = "<ul>";
697
+ for (const [i] of Object.entries(this.options.ranges))
698
+ e += `<li data-range-key="${i}">${i}</li>`;
699
+ this.options.showCustomRangeLabel && (e += `<li data-range-key="${this.locale.customRangeLabel}">${this.locale.customRangeLabel}</li>`), e += "</ul>", t.innerHTML = e;
700
+ }
701
+ setupEventListeners() {
702
+ this.element.tagName === "INPUT" || this.element.tagName === "BUTTON" ? (this.addEventHandler(this.element, "click", this.show.bind(this)), this.addEventHandler(this.element, "focus", this.show.bind(this)), this.addEventHandler(
703
+ this.element,
704
+ "keyup",
705
+ this.elementChanged.bind(this)
706
+ ), this.addEventHandler(
707
+ this.element,
708
+ "keydown",
709
+ this.keydown.bind(this)
710
+ )) : this.addEventHandler(this.element, "click", this.toggle.bind(this)), this.addEventHandler(
711
+ this.container,
712
+ "click",
713
+ this.containerClick.bind(this)
714
+ ), this.addEventHandler(
715
+ this.container,
716
+ "mouseover",
717
+ this.containerMouseOver.bind(this)
718
+ ), this.addEventHandler(
719
+ this.container,
720
+ "mouseleave",
721
+ this.containerMouseLeave.bind(this)
722
+ ), this.addEventHandler(
723
+ this.container,
724
+ "change",
725
+ this.containerChange.bind(this)
726
+ ), setTimeout(() => {
727
+ this.container.querySelectorAll(
728
+ "select.monthselect, select.yearselect"
729
+ ).forEach((e) => {
730
+ this.addEventHandler(
731
+ e,
732
+ "change",
733
+ this.monthOrYearChanged.bind(this)
734
+ );
735
+ });
736
+ }, 100);
737
+ }
738
+ addEventHandler(t, e, i) {
739
+ const a = `${e}_${Math.random()}`;
740
+ this.boundHandlers.set(a, i), t.addEventListener(e, i);
741
+ }
742
+ containerChange(t) {
743
+ if (t.target.matches("select.monthselect, select.yearselect")) {
744
+ this.monthOrYearChanged(t);
745
+ return;
746
+ }
747
+ }
748
+ containerMouseOver(t) {
749
+ if (t.target.matches("td.available")) {
750
+ this.hoverDate(t);
751
+ return;
752
+ }
753
+ }
754
+ containerMouseLeave() {
755
+ this.state.hoverDate && (this.state.hoverDate = null, this.updateDateClasses());
756
+ }
757
+ containerClick(t) {
758
+ const e = t.target;
759
+ if (!(e.tagName === "SELECT" || e.closest("select"))) {
760
+ if (e.matches(".ranges li")) {
761
+ this.clickRange(t);
762
+ return;
763
+ }
764
+ if (e.matches(".applyBtn")) {
765
+ this.clickApply(t);
766
+ return;
767
+ }
768
+ if (e.matches(".cancelBtn")) {
769
+ this.clickCancel(t);
770
+ return;
771
+ }
772
+ if (e.matches(".prev")) {
773
+ this.clickPrev(t);
774
+ return;
775
+ }
776
+ if (e.matches(".next")) {
777
+ this.clickNext(t);
778
+ return;
779
+ }
780
+ if (e.matches("td.available")) {
781
+ this.clickDate(t);
782
+ return;
783
+ }
784
+ }
785
+ }
786
+ preventBlur(t) {
787
+ const e = t.target;
788
+ e.tagName === "SELECT" || e.closest("select") || t.preventDefault();
789
+ }
790
+ show() {
791
+ this.state.isShowing || (this.state.oldStartDate = new Date(this.state.startDate), this.state.oldEndDate = this.state.endDate ? new Date(this.state.endDate) : null, this.applyTheme(), this.documentClickHandler = this.outsideClick.bind(this), this.documentFocusHandler = this.outsideFocus.bind(this), document.addEventListener("mousedown", this.documentClickHandler, !0), document.addEventListener("focusin", this.documentFocusHandler, !0), this.resizeHandler = this.move.bind(this), this.scrollHandler = this.move.bind(this), window.addEventListener("resize", this.resizeHandler), window.addEventListener("scroll", this.scrollHandler, !0), this.updateView(), this.container.style.display = "block", setTimeout(() => {
792
+ this.move();
793
+ }, 0), this.dispatchEvent("show.daterangepicker"), this.state.isShowing = !0);
794
+ }
795
+ hide() {
796
+ this.state.isShowing && (this.state.endDate || (this.state.startDate = new Date(this.state.oldStartDate), this.state.endDate = this.state.oldEndDate ? new Date(this.state.oldEndDate) : null), (!x(this.state.startDate, this.state.oldStartDate, "day") || this.state.endDate && this.state.oldEndDate && !x(this.state.endDate, this.state.oldEndDate, "day")) && this.callback(
797
+ new Date(this.state.startDate),
798
+ this.state.endDate ? new Date(this.state.endDate) : new Date(this.state.startDate),
799
+ this.state.chosenLabel || void 0
800
+ ), this.updateElement(), this.removeDocumentListeners(), this.container.style.display = "none", this.dispatchEvent("hide.daterangepicker"), this.state.isShowing = !1);
801
+ }
802
+ removeDocumentListeners() {
803
+ this.documentClickHandler && (document.removeEventListener(
804
+ "mousedown",
805
+ this.documentClickHandler,
806
+ !0
807
+ ), this.documentClickHandler = void 0), this.documentFocusHandler && (document.removeEventListener("focusin", this.documentFocusHandler, !0), this.documentFocusHandler = void 0), this.resizeHandler && (window.removeEventListener("resize", this.resizeHandler), this.resizeHandler = void 0), this.scrollHandler && (window.removeEventListener("scroll", this.scrollHandler, !0), this.scrollHandler = void 0);
808
+ }
809
+ outsideClick(t) {
810
+ const e = t.target;
811
+ this.element.contains(e) || this.container.contains(e) || e.closest(".datex-picker") || e.tagName === "SELECT" || e.closest("select") || (this.hide(), this.dispatchEvent("outsideClick.daterangepicker"));
812
+ }
813
+ outsideFocus(t) {
814
+ const e = t.target;
815
+ this.element.contains(e) || this.container.contains(e) || e.closest(".datex-picker") || setTimeout(() => {
816
+ const i = document.activeElement;
817
+ i && !this.element.contains(i) && !this.container.contains(i) && !i.closest(".datex-picker") && this.hide();
818
+ }, 50);
819
+ }
820
+ toggle() {
821
+ this.state.isShowing ? this.hide() : this.show();
822
+ }
823
+ updateView() {
824
+ if (this.options.timePicker) {
825
+ this.renderTimePicker("left"), this.renderTimePicker("right");
826
+ const t = this.container.querySelectorAll(
827
+ ".right .calendar-time select"
828
+ );
829
+ this.state.endDate ? t.forEach((e) => {
830
+ e.disabled = !1, e.classList.remove("disabled");
831
+ }) : t.forEach((e) => {
832
+ e.disabled = !0, e.classList.add("disabled");
833
+ });
834
+ }
835
+ this.updateMonthsInView(), this.updateCalendars(), this.updateFormInputs(), this.updateSelectedDisplay(), this.calculateChosenLabel();
836
+ }
837
+ updateMonthsInView() {
838
+ this.state.endDate ? (this.state.leftCalendar.month = this.getStartOfMonth(
839
+ this.state.startDate
840
+ ), !this.options.linkedCalendars && (this.state.endDate.getMonth() !== this.state.startDate.getMonth() || this.state.endDate.getFullYear() !== this.state.startDate.getFullYear()) ? this.state.rightCalendar.month = this.getStartOfMonth(
841
+ this.state.endDate
842
+ ) : this.state.rightCalendar.month = y(
843
+ this.state.leftCalendar.month,
844
+ 1
845
+ )) : (this.state.leftCalendar.month = this.getStartOfMonth(
846
+ this.state.startDate
847
+ ), this.state.rightCalendar.month = y(
848
+ this.state.leftCalendar.month,
849
+ 1
850
+ ));
851
+ }
852
+ getStartOfMonth(t) {
853
+ return new Date(t.getFullYear(), t.getMonth(), 1);
854
+ }
855
+ getEndOfMonth(t) {
856
+ return new Date(t.getFullYear(), t.getMonth() + 1, 0);
857
+ }
858
+ getStartOfWeek(t, e = 1) {
859
+ const a = (t.getDay() - e + 7) % 7, n = new Date(t);
860
+ return n.setDate(t.getDate() - a), n;
861
+ }
862
+ updateCalendars() {
863
+ this.renderCalendar("left"), this.options.singleDatePicker || this.renderCalendar("right"), setTimeout(() => {
864
+ this.container.querySelectorAll(
865
+ "select.monthselect, select.yearselect"
866
+ ).forEach((e) => {
867
+ e.removeEventListener(
868
+ "change",
869
+ this.monthOrYearChanged.bind(this)
870
+ ), e.addEventListener("change", this.monthOrYearChanged.bind(this));
871
+ });
872
+ }, 10);
873
+ }
874
+ renderCalendar(t) {
875
+ const e = t === "left" ? this.state.leftCalendar : this.state.rightCalendar, i = this.container.querySelector(
876
+ `.drp-calendar.${t} .calendar-table`
877
+ ), a = e.month, n = a.getFullYear(), o = a.getMonth(), r = this.getStartOfMonth(a), f = this.getStartOfWeek(r, this.locale.firstDay), h = [];
878
+ let d = [];
879
+ const p = new Date(f);
880
+ for (let D = 0; D < 42; D++) {
881
+ D > 0 && D % 7 === 0 && (h.push(d), d = []);
882
+ const k = new Date(p);
883
+ k.setDate(p.getDate() + D), d.push(k);
884
+ }
885
+ d.length > 0 && h.push(d), e.calendar = h;
886
+ let s = '<table class="table-condensed">';
887
+ s += "<thead>", s += "<tr>";
888
+ const l = !this.options.minDate || b(this.getStartOfMonth(a), this.options.minDate), m = !this.options.maxDate || g(this.getEndOfMonth(a), this.options.maxDate);
889
+ l && (!this.options.linkedCalendars || t === "left") ? s += '<th class="prev available"><span></span></th>' : s += "<th></th>";
890
+ let u = this.locale.monthNames[o] + " " + n;
891
+ this.options.showDropdowns && (u = this.renderDropdowns(o, n, t)), s += `<th colspan="5" class="month">${u}</th>`, m && (!this.options.linkedCalendars || t === "right" || this.options.singleDatePicker) ? s += '<th class="next available"><span></span></th>' : s += "<th></th>", s += "</tr>", s += "<tr>";
892
+ for (const D of this.locale.daysOfWeek)
893
+ s += `<th>${D}</th>`;
894
+ s += "</tr>", s += "</thead>", s += "<tbody>";
895
+ for (const D of h) {
896
+ s += "<tr>";
897
+ for (const k of D) {
898
+ const w = this.getDayClasses(k, a), H = w.includes("disabled"), P = w.join(" ") + (H ? "" : " available");
899
+ s += `<td class="${P}" data-date="${v(
900
+ k,
901
+ "YYYY-MM-DD"
902
+ )}">${k.getDate()}</td>`;
903
+ }
904
+ s += "</tr>";
905
+ }
906
+ s += "</tbody>", s += "</table>", i.innerHTML = s, this.options.timePicker && this.renderTimePicker(t);
907
+ }
908
+ renderDropdowns(t, e, i) {
909
+ let a = this.options.minYear, n = this.options.maxYear;
910
+ this.options.minDate && (a = Math.max(a, this.options.minDate.getFullYear())), this.options.maxDate && (n = Math.min(n, this.options.maxDate.getFullYear()));
911
+ const o = e, r = o === a, f = o === n;
912
+ let h = '<select class="monthselect">';
913
+ for (let p = 0; p < 12; p++) {
914
+ let s = !1;
915
+ r && this.options.minDate && p < this.options.minDate.getMonth() && (s = !0), f && this.options.maxDate && p > this.options.maxDate.getMonth() && (s = !0), h += `<option value="${p}"${p === t ? ' selected="selected"' : ""}${s ? ' disabled="disabled"' : ""}>${this.locale.monthNames[p]}</option>`;
916
+ }
917
+ h += "</select>";
918
+ let d = '<select class="yearselect">';
919
+ for (let p = a; p <= n; p++)
920
+ d += `<option value="${p}"${p === e ? ' selected="selected"' : ""}>${p}</option>`;
921
+ return d += "</select>", h + " " + d;
922
+ }
923
+ getDayClasses(t, e) {
924
+ const i = [];
925
+ return x(t, /* @__PURE__ */ new Date(), "day") && i.push("today"), (t.getDay() === 0 || t.getDay() === 6) && i.push("weekend"), t.getMonth() !== e.getMonth() && i.push("off", "ends"), this.options.minDate && g(t, M(this.options.minDate)) && i.push("off", "disabled"), this.options.maxDate && b(t, E(this.options.maxDate)) && i.push("off", "disabled"), x(t, this.state.startDate, "day") && i.push("active", "start-date"), this.state.endDate && x(t, this.state.endDate, "day") && i.push("active", "end-date"), this.state.endDate && b(t, this.state.startDate) && g(t, this.state.endDate) && i.push("in-range"), i;
926
+ }
927
+ updateFormInputs() {
928
+ const t = this.container.querySelector(
929
+ ".applyBtn"
930
+ ), e = this.options.singleDatePicker || this.state.endDate && (g(this.state.startDate, this.state.endDate) || x(this.state.startDate, this.state.endDate, "day"));
931
+ t.disabled = !e;
932
+ }
933
+ updateSelectedDisplay() {
934
+ const t = this.container.querySelector(".drp-selected");
935
+ let e = v(this.state.startDate, this.locale.format);
936
+ !this.options.singleDatePicker && this.state.endDate && (e += this.locale.separator + v(this.state.endDate, this.locale.format)), t.textContent = e;
937
+ }
938
+ renderTimePicker(t) {
939
+ if (t === "right" && !this.state.endDate) return;
940
+ const e = this.container.querySelector(
941
+ `.drp-calendar.${t}`
942
+ );
943
+ if (!e.querySelector(".calendar-time")) {
944
+ const s = document.createElement("div");
945
+ s.className = "calendar-time", e.appendChild(s);
946
+ }
947
+ let a, n = null, o = this.options.maxDate;
948
+ if (this.options.maxSpan && (!this.options.maxDate || b(
949
+ $(this.state.startDate, this.options.maxSpan.days || 0),
950
+ this.options.maxDate
951
+ )) && (o = $(this.state.startDate, this.options.maxSpan.days || 0)), t === "left")
952
+ a = new Date(this.state.startDate), n = this.options.minDate;
953
+ else {
954
+ a = this.state.endDate ? new Date(this.state.endDate) : new Date(this.state.startDate), n = this.state.startDate;
955
+ const s = this.container.querySelector(
956
+ ".drp-calendar.right .calendar-time"
957
+ );
958
+ if (s && s.innerHTML !== "") {
959
+ const l = s.querySelector(
960
+ ".hourselect"
961
+ ), m = s.querySelector(
962
+ ".minuteselect"
963
+ ), u = s.querySelector(
964
+ ".secondselect"
965
+ ), D = s.querySelector(
966
+ ".ampmselect"
967
+ );
968
+ if (l && l.value) {
969
+ let k = parseInt(l.value, 10);
970
+ if (!this.options.timePicker24Hour && D) {
971
+ const w = D.value;
972
+ w === "PM" && k < 12 && (k += 12), w === "AM" && k === 12 && (k = 0);
973
+ }
974
+ a.setHours(k);
975
+ }
976
+ m && m.value && a.setMinutes(parseInt(m.value, 10)), u && u.value && a.setSeconds(parseInt(u.value, 10));
977
+ }
978
+ g(a, this.state.startDate) && (a = new Date(this.state.startDate)), o && b(a, o) && (a = new Date(o));
979
+ }
980
+ let r = '<select class="hourselect">';
981
+ const f = this.options.timePicker24Hour ? 0 : 1, h = this.options.timePicker24Hour ? 23 : 12;
982
+ for (let s = f; s <= h; s++) {
983
+ let l = s;
984
+ this.options.timePicker24Hour || (l = a.getHours() >= 12 ? s === 12 ? 12 : s + 12 : s === 12 ? 0 : s);
985
+ const m = new Date(a);
986
+ m.setHours(l), m.setMinutes(59);
987
+ let u = !1;
988
+ n && g(m, n) && (u = !0), m.setMinutes(0), o && b(m, o) && (u = !0), l === a.getHours() && !u ? r += `<option value="${s}" selected="selected">${s}</option>` : u ? r += `<option value="${s}" disabled="disabled" class="disabled">${s}</option>` : r += `<option value="${s}">${s}</option>`;
989
+ }
990
+ r += "</select> ", r += ': <select class="minuteselect">';
991
+ for (let s = 0; s < 60; s += this.options.timePickerIncrement) {
992
+ const l = s < 10 ? "0" + s : s.toString(), m = new Date(a);
993
+ m.setMinutes(s), m.setSeconds(59);
994
+ let u = !1;
995
+ n && g(m, n) && (u = !0), m.setSeconds(0), o && b(m, o) && (u = !0), a.getMinutes() === s && !u ? r += `<option value="${s}" selected="selected">${l}</option>` : u ? r += `<option value="${s}" disabled="disabled" class="disabled">${l}</option>` : r += `<option value="${s}">${l}</option>`;
996
+ }
997
+ if (r += "</select> ", this.options.timePickerSeconds) {
998
+ r += ': <select class="secondselect">';
999
+ for (let s = 0; s < 60; s++) {
1000
+ const l = s < 10 ? "0" + s : s.toString(), m = new Date(a);
1001
+ m.setSeconds(s);
1002
+ let u = !1;
1003
+ n && g(m, n) && (u = !0), o && b(m, o) && (u = !0), a.getSeconds() === s && !u ? r += `<option value="${s}" selected="selected">${l}</option>` : u ? r += `<option value="${s}" disabled="disabled" class="disabled">${l}</option>` : r += `<option value="${s}">${l}</option>`;
1004
+ }
1005
+ r += "</select> ";
1006
+ }
1007
+ if (!this.options.timePicker24Hour) {
1008
+ r += '<select class="ampmselect">';
1009
+ const s = new Date(a);
1010
+ s.setHours(12, 0, 0);
1011
+ const l = new Date(a);
1012
+ l.setHours(0, 0, 0);
1013
+ let m = "", u = "";
1014
+ n && g(s, n) && (m = ' disabled="disabled" class="disabled"'), o && b(l, o) && (u = ' disabled="disabled" class="disabled"'), a.getHours() >= 12 ? r += `<option value="AM"${m}>AM</option><option value="PM" selected="selected"${u}>PM</option>` : r += `<option value="AM" selected="selected"${m}>AM</option><option value="PM"${u}>PM</option>`, r += "</select>";
1015
+ }
1016
+ const d = e.querySelector(".calendar-time");
1017
+ d.innerHTML = r, d.querySelectorAll("select").forEach((s) => {
1018
+ s.addEventListener("change", this.timeChanged.bind(this));
1019
+ });
1020
+ }
1021
+ timeChanged(t) {
1022
+ const i = t.target.closest(".drp-calendar");
1023
+ if (!i) return;
1024
+ const a = i.classList.contains("left"), n = i, o = n.querySelector(".hourselect"), r = n.querySelector(
1025
+ ".minuteselect"
1026
+ ), f = n.querySelector(
1027
+ ".secondselect"
1028
+ ), h = n.querySelector(".ampmselect");
1029
+ let d = parseInt(o.value, 10), p = parseInt(r.value, 10);
1030
+ if (isNaN(p)) {
1031
+ const l = r.options[r.options.length - 1];
1032
+ p = parseInt(l.value, 10);
1033
+ }
1034
+ const s = this.options.timePickerSeconds && f ? parseInt(f.value, 10) : 0;
1035
+ if (!this.options.timePicker24Hour && h) {
1036
+ const l = h.value;
1037
+ l === "PM" && d < 12 && (d += 12), l === "AM" && d === 12 && (d = 0);
1038
+ }
1039
+ if (a) {
1040
+ const l = new Date(this.state.startDate);
1041
+ l.setHours(d, p, s), this.setStartDate(l), this.options.singleDatePicker ? this.state.endDate = new Date(l) : this.state.endDate && v(this.state.endDate, "YYYY-MM-DD") === v(l, "YYYY-MM-DD") && g(this.state.endDate, l) && this.setEndDate(new Date(l));
1042
+ } else if (this.state.endDate) {
1043
+ const l = new Date(this.state.endDate);
1044
+ l.setHours(d, p, s), this.setEndDate(l);
1045
+ }
1046
+ this.updateCalendars(), this.updateFormInputs(), this.renderTimePicker("left"), this.renderTimePicker("right");
1047
+ }
1048
+ updateElement() {
1049
+ if (this.element.tagName === "INPUT" && this.options.autoUpdateInput) {
1050
+ const t = this.element;
1051
+ let e = v(this.state.startDate, this.locale.format);
1052
+ !this.options.singleDatePicker && this.state.endDate && (e += this.locale.separator + v(this.state.endDate, this.locale.format)), e !== t.value && (t.value = e, this.dispatchEvent("change"));
1053
+ }
1054
+ }
1055
+ move() {
1056
+ if (!this.state.isShowing || !this.container) return;
1057
+ const t = this.element.getBoundingClientRect();
1058
+ let e, i = this.options.drops;
1059
+ this.container.style.top = "0", this.container.style.left = "0", this.container.style.right = "auto", this.container.style.position = "fixed";
1060
+ const a = this.container.offsetWidth, n = this.container.offsetHeight;
1061
+ switch (i) {
1062
+ case "auto":
1063
+ e = t.bottom + 5, e + n >= window.innerHeight && (e = t.top - n - 5, i = "up");
1064
+ break;
1065
+ case "up":
1066
+ e = t.top - n - 5;
1067
+ break;
1068
+ default:
1069
+ e = t.bottom + 5;
1070
+ break;
1071
+ }
1072
+ i === "up" ? this.container.classList.add("drop-up") : this.container.classList.remove("drop-up");
1073
+ let o;
1074
+ this.options.opens === "left" ? (o = t.right - a, o < 9 && (o = 9)) : this.options.opens === "center" ? (o = t.left + t.width / 2 - a / 2, o < 9 ? o = 9 : o + a > window.innerWidth - 9 && (o = window.innerWidth - a - 9)) : (o = t.left, o + a > window.innerWidth - 9 && (o = window.innerWidth - a - 9)), o < 9 && (o = 9), e < 9 && (e = 9), this.container.style.top = `${e}px`, this.container.style.left = `${o}px`, this.container.style.right = "auto", this.container.style.zIndex = "99999";
1075
+ }
1076
+ // Event handlers
1077
+ clickRange(t) {
1078
+ const e = t.target, i = e.dataset.rangeKey;
1079
+ if (!i) return;
1080
+ if (this.container.querySelectorAll(".ranges li").forEach((n) => n.classList.remove("active")), e.classList.add("active"), this.state.chosenLabel = i, i === this.locale.customRangeLabel)
1081
+ this.showCalendars();
1082
+ else {
1083
+ const n = this.options.ranges[i];
1084
+ if (n) {
1085
+ const [o, r] = n;
1086
+ this.state.startDate = new Date(o), this.state.endDate = new Date(r), !this.options.alwaysShowCalendars && Object.keys(this.options.ranges).length === 0 ? this.hideCalendars() : this.showCalendars(), this.updateView(), this.options.autoApply && this.clickApply(t);
1087
+ }
1088
+ }
1089
+ }
1090
+ clickPrev(t) {
1091
+ const i = t.target.closest(".drp-calendar");
1092
+ i && (i.classList.contains("left") ? (this.state.leftCalendar.month = y(
1093
+ this.state.leftCalendar.month,
1094
+ -1
1095
+ ), this.options.linkedCalendars && (this.state.rightCalendar.month = y(
1096
+ this.state.rightCalendar.month,
1097
+ -1
1098
+ ))) : this.state.rightCalendar.month = y(
1099
+ this.state.rightCalendar.month,
1100
+ -1
1101
+ ), this.updateCalendars());
1102
+ }
1103
+ clickNext(t) {
1104
+ const i = t.target.closest(".drp-calendar");
1105
+ i && (i.classList.contains("left") ? this.state.leftCalendar.month = y(
1106
+ this.state.leftCalendar.month,
1107
+ 1
1108
+ ) : (this.state.rightCalendar.month = y(
1109
+ this.state.rightCalendar.month,
1110
+ 1
1111
+ ), this.options.linkedCalendars && (this.state.leftCalendar.month = y(
1112
+ this.state.leftCalendar.month,
1113
+ 1
1114
+ ))), this.updateCalendars());
1115
+ }
1116
+ clickDate(t) {
1117
+ const e = t.target;
1118
+ if (!e.classList.contains("available")) return;
1119
+ const i = e.dataset.date;
1120
+ if (!i) return;
1121
+ const a = C(i, "YYYY-MM-DD");
1122
+ if (S(a)) {
1123
+ if (this.options.timePicker) {
1124
+ const n = e.closest(".drp-calendar");
1125
+ if (n) {
1126
+ const o = n.querySelector(
1127
+ ".hourselect"
1128
+ ), r = n.querySelector(
1129
+ ".minuteselect"
1130
+ ), f = n.querySelector(
1131
+ ".secondselect"
1132
+ ), h = n.querySelector(
1133
+ ".ampmselect"
1134
+ );
1135
+ if (o) {
1136
+ let d = parseInt(o.value, 10);
1137
+ if (!this.options.timePicker24Hour && h) {
1138
+ const p = h.value;
1139
+ p === "PM" && d < 12 && (d += 12), p === "AM" && d === 12 && (d = 0);
1140
+ }
1141
+ a.setHours(d);
1142
+ }
1143
+ if (r) {
1144
+ let d = parseInt(r.value, 10);
1145
+ if (isNaN(d)) {
1146
+ const p = r.options[r.options.length - 1];
1147
+ d = parseInt(p.value, 10);
1148
+ }
1149
+ a.setMinutes(d);
1150
+ }
1151
+ this.options.timePickerSeconds && f && a.setSeconds(parseInt(f.value, 10));
1152
+ }
1153
+ }
1154
+ this.state.hoverDate = null, this.state.endDate || g(a, this.state.startDate) ? (this.state.endDate = null, this.setStartDate(a)) : (this.setEndDate(a), this.options.autoApply && (this.calculateChosenLabel(), this.clickApply(t))), this.options.singleDatePicker && (this.setEndDate(this.state.startDate), this.options.autoApply && this.clickApply(t)), this.updateDateClasses();
1155
+ }
1156
+ }
1157
+ hoverDate(t) {
1158
+ const e = t.target;
1159
+ if (!e.classList.contains("available")) return;
1160
+ const i = e.dataset.date;
1161
+ if (!i) return;
1162
+ const a = C(i, "YYYY-MM-DD");
1163
+ S(a) && !this.state.endDate && !g(a, this.state.startDate) && (this.state.hoverDate = a, this.updateDateClasses());
1164
+ }
1165
+ updateDateClasses() {
1166
+ this.container.querySelectorAll("td[data-date]").forEach((e) => {
1167
+ const i = e.dataset.date;
1168
+ if (!i) return;
1169
+ const a = C(i, "YYYY-MM-DD");
1170
+ if (!S(a)) return;
1171
+ e.classList.remove("in-range", "end-date", "start-date", "active");
1172
+ const n = this.state.startDate, o = this.state.endDate, r = this.state.hoverDate;
1173
+ if (n && x(a, n, "day") && e.classList.add("active", "start-date"), o && x(a, o, "day") && e.classList.add("active", "end-date"), n && o && b(a, n) && g(a, o) && e.classList.add("in-range"), n && r && !o) {
1174
+ const f = g(r, n) ? r : n, h = g(r, n) ? n : r;
1175
+ x(a, r, "day") ? e.classList.add("end-date") : b(a, f) && g(a, h) && e.classList.add("in-range");
1176
+ }
1177
+ });
1178
+ }
1179
+ clickApply(t) {
1180
+ this.hide(), this.dispatchEvent("apply.daterangepicker");
1181
+ }
1182
+ clickCancel(t) {
1183
+ this.state.startDate = new Date(this.state.oldStartDate), this.state.endDate = this.state.oldEndDate ? new Date(this.state.oldEndDate) : null, this.hide(), this.dispatchEvent("cancel.daterangepicker");
1184
+ }
1185
+ monthOrYearChanged(t) {
1186
+ const i = t.target.closest(".drp-calendar");
1187
+ if (!i)
1188
+ return;
1189
+ const a = i.classList.contains("left"), n = i.querySelector(
1190
+ ".monthselect"
1191
+ ), o = i.querySelector(
1192
+ ".yearselect"
1193
+ );
1194
+ if (!n || !o)
1195
+ return;
1196
+ const r = parseInt(n.value, 10), f = parseInt(o.value, 10), h = new Date(f, r, 1);
1197
+ a ? (this.state.leftCalendar.month = h, this.options.linkedCalendars && (this.state.rightCalendar.month = y(h, 1))) : (this.state.rightCalendar.month = h, this.options.linkedCalendars && (this.state.leftCalendar.month = y(h, -1))), this.updateCalendars();
1198
+ }
1199
+ elementChanged() {
1200
+ if (this.element.tagName !== "INPUT") return;
1201
+ const t = this.element;
1202
+ if (!t.value || !t.value.length) return;
1203
+ const e = t.value.split(this.locale.separator);
1204
+ let i = null, a = null;
1205
+ e.length === 2 ? (i = C(e[0].trim(), this.locale.format), a = C(e[1].trim(), this.locale.format)) : (this.options.singleDatePicker || e.length === 1) && (i = C(e[0].trim(), this.locale.format), a = i), i && S(i) && a && S(a) && (this.setStartDate(i), this.setEndDate(a), this.updateView());
1206
+ }
1207
+ keydown(t) {
1208
+ (t.key === "Tab" || t.key === "Enter") && this.hide(), t.key === "Escape" && (t.preventDefault(), t.stopPropagation(), this.hide());
1209
+ }
1210
+ showCalendars() {
1211
+ this.container.classList.add("show-calendar"), this.move(), this.dispatchEvent("showCalendar.daterangepicker");
1212
+ }
1213
+ hideCalendars() {
1214
+ this.container.classList.remove("show-calendar"), this.dispatchEvent("hideCalendar.daterangepicker");
1215
+ }
1216
+ calculateChosenLabel() {
1217
+ let t = !0, e = null;
1218
+ for (const [a, [n, o]] of Object.entries(
1219
+ this.options.ranges
1220
+ )) {
1221
+ const r = x(this.state.startDate, n, "day");
1222
+ let f = !1;
1223
+ if (this.state.endDate ? f = x(this.state.endDate, o, "day") : f = x(this.state.startDate, o, "day"), r && f) {
1224
+ const h = Math.abs(o.getTime() - n.getTime()) / 864e5 + 1;
1225
+ (!e || h > e.days) && (e = { label: a, days: h });
1226
+ }
1227
+ }
1228
+ if (this.container.querySelectorAll(".ranges li").forEach((a) => a.classList.remove("active")), e) {
1229
+ t = !1, this.state.chosenLabel = e.label;
1230
+ const a = this.container.querySelector(
1231
+ `[data-range-key="${e.label}"]`
1232
+ );
1233
+ a && a.classList.add("active");
1234
+ }
1235
+ if (t)
1236
+ if (this.options.showCustomRangeLabel) {
1237
+ this.state.chosenLabel = this.locale.customRangeLabel;
1238
+ const a = this.container.querySelector(
1239
+ `[data-range-key="${this.locale.customRangeLabel}"]`
1240
+ );
1241
+ a && a.classList.add("active");
1242
+ } else
1243
+ this.state.chosenLabel = null;
1244
+ Object.keys(this.options.ranges).length > 0 && this.showCalendars();
1245
+ }
1246
+ // Public API
1247
+ setStartDate(t) {
1248
+ if (!this.options.timePicker)
1249
+ this.state.startDate = M(t);
1250
+ else if (this.state.startDate = new Date(t), this.options.timePickerIncrement) {
1251
+ const e = Math.round(
1252
+ this.state.startDate.getMinutes() / this.options.timePickerIncrement
1253
+ ) * this.options.timePickerIncrement;
1254
+ this.state.startDate.setMinutes(e);
1255
+ }
1256
+ this.updateView();
1257
+ }
1258
+ setEndDate(t) {
1259
+ if (!this.options.timePicker)
1260
+ this.state.endDate = E(t);
1261
+ else if (this.state.endDate = new Date(t), this.options.timePickerIncrement) {
1262
+ const e = Math.round(
1263
+ this.state.endDate.getMinutes() / this.options.timePickerIncrement
1264
+ ) * this.options.timePickerIncrement;
1265
+ this.state.endDate.setMinutes(e);
1266
+ }
1267
+ this.updateView();
1268
+ }
1269
+ getStartDate() {
1270
+ return new Date(this.state.startDate);
1271
+ }
1272
+ getEndDate() {
1273
+ return this.state.endDate ? new Date(this.state.endDate) : null;
1274
+ }
1275
+ remove() {
1276
+ if (this.removeDocumentListeners(), this.container && this.container.dataset.themeStyleId) {
1277
+ const t = document.getElementById(
1278
+ this.container.dataset.themeStyleId
1279
+ );
1280
+ t && t.remove();
1281
+ }
1282
+ this.boundHandlers.forEach((t, e) => {
1283
+ }), this.boundHandlers.clear(), this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container);
1284
+ }
1285
+ updateRanges(t) {
1286
+ if (typeof t == "object") {
1287
+ this.options.ranges = {};
1288
+ for (const [e, i] of Object.entries(t)) {
1289
+ let a, n;
1290
+ typeof i[0] == "string" ? a = C(i[0], this.locale.format) : a = new Date(i[0]), typeof i[1] == "string" ? n = C(i[1], this.locale.format) : n = new Date(i[1]), this.options.minDate && g(a, this.options.minDate) && (a = new Date(this.options.minDate));
1291
+ let o = this.options.maxDate;
1292
+ if (this.options.maxSpan && o) {
1293
+ const r = $(a, this.options.maxSpan.days || 0);
1294
+ b(r, o) && (o = r);
1295
+ }
1296
+ o && b(n, o) && (n = new Date(o)), !(this.options.minDate && g(n, this.options.minDate) || o && b(a, o)) && (this.options.ranges[e] = [a, n]);
1297
+ }
1298
+ this.renderRanges();
1299
+ }
1300
+ }
1301
+ dispatchEvent(t) {
1302
+ const e = new CustomEvent(t, {
1303
+ bubbles: !0,
1304
+ detail: this
1305
+ });
1306
+ this.element.dispatchEvent(e);
1307
+ }
1308
+ }
1309
+ export {
1310
+ I as BOOTSTRAP_THEME,
1311
+ L as DEFAULT_THEME,
1312
+ q as Datex,
1313
+ T as MATERIAL_THEME,
1314
+ Y as SPANISH_LOCALE,
1315
+ A as SPANISH_LOCALE_WITH_TIME
1316
+ };