@lekoala/date-picker 0.1.1 → 0.3.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.
@@ -1,15 +1,21 @@
1
- /*** @lekoala/date-picker v0.1.1 - https://github.com/lekoala/date-picker ***/
2
- (()=>{var ut=`:where(date-calendar, date-picker) {
3
- --dp-bg: Canvas;
4
- --dp-fg: CanvasText;
5
- --dp-muted: color-mix(in srgb, CanvasText 58%, Canvas);
6
- --dp-border: color-mix(in srgb, CanvasText 22%, Canvas);
7
- --dp-hover: color-mix(in srgb, CanvasText 7%, Canvas);
8
- --dp-accent: Highlight;
9
- --dp-accent-fg: HighlightText;
1
+ /*** @lekoala/date-picker v0.3.0 - https://github.com/lekoala/date-picker ***/
2
+ (()=>{var ge=`:where(date-calendar, date-picker) {
3
+ --dp-bg: #ffffff;
4
+ --dp-fg: #1f2328;
5
+ --dp-muted: color-mix(in srgb, var(--dp-fg) 58%, var(--dp-bg));
6
+ --dp-border: color-mix(in srgb, var(--dp-fg) 16%, var(--dp-bg));
7
+ --dp-hover: color-mix(in srgb, var(--dp-fg) 5%, var(--dp-bg));
8
+ --dp-accent: #2563eb;
9
+ --dp-accent-fg: #fff;
10
10
  --dp-radius: 0.5rem;
11
11
  --dp-day-size: 2.75rem;
12
- --dp-gap: 0.25rem;
12
+ --dp-gap: 0.375rem;
13
+ --dp-header-control-size: 2.25rem;
14
+ --dp-header-block-gap: 0.75rem;
15
+ --dp-row-gap: 0.375rem;
16
+ --dp-picker-button-size: 2.5rem;
17
+ --dp-year-inline-size: 5.5rem;
18
+ --dp-day-radius: calc(var(--dp-radius) * 0.75);
13
19
  color: var(--dp-fg);
14
20
  font: inherit;
15
21
  }
@@ -40,42 +46,85 @@ date-calendar {
40
46
  .dp-calendar-header {
41
47
  display: grid;
42
48
  grid-template-columns: minmax(0, 1fr) auto auto auto;
43
- align-items: center;
49
+ /* Stretch (not center): once a UA natural height exceeds
50
+ --dp-header-control-size, the row grows to the tallest control and the
51
+ others stretch to match, so month/year/nav stay equal. */
52
+ align-items: stretch;
53
+ /* Uniform horizontal rhythm: the four header controls are self-evident from
54
+ their kind and position, so no group gets an extra semantic gap. The air
55
+ belongs to the vertical zones (header -> weekdays -> dates). */
44
56
  gap: var(--dp-gap);
45
- margin-block-end: 0.4rem;
57
+ margin-block-end: var(--dp-header-block-gap);
46
58
  }
47
59
 
48
- .dp-calendar-header .dp-prev {
49
- margin-inline-start: calc(var(--dp-gap) * 2.5);
60
+ /* Locale year-first order (Intl-derived, direction-independent): the flexible
61
+ track stays under the month select so the fixed-width year input never
62
+ stretches. Visual mirroring itself is left to the inherited \`dir\`. */
63
+ date-calendar[data-year-first] .dp-calendar-header {
64
+ grid-template-columns: auto minmax(0, 1fr) auto auto;
50
65
  }
51
66
 
52
67
  .dp-calendar-header :where(button, select, input) {
53
- min-block-size: 2.25rem;
68
+ min-block-size: var(--dp-header-control-size);
69
+ box-sizing: border-box;
70
+ /* Shared vertical metrics: UA default padding/line-height differ per control
71
+ (up to ~13px apart), which only shows once --dp-header-control-size drops
72
+ below content size. */
73
+ padding-block: 0.15rem;
54
74
  border: 1px solid var(--dp-border);
55
75
  border-radius: calc(var(--dp-radius) * 0.75);
56
76
  background: var(--dp-bg);
57
77
  color: var(--dp-fg);
58
78
  font: inherit;
79
+ line-height: 1.2;
59
80
  }
60
81
 
61
- .dp-calendar-header select,
62
82
  .dp-calendar-header input {
63
83
  min-inline-size: 0;
64
84
  padding-inline: 0.45rem;
65
85
  }
66
86
 
87
+ /* Author-drawn caret so the month select matches the nav controls without a
88
+ hardcoded SVG color (currentColor keeps theming). Equal outer heights come
89
+ from the header grid's stretch alignment: the row sizes to the tallest
90
+ control and the others stretch to match. */
67
91
  .dp-month-select {
68
92
  inline-size: 100%;
93
+ min-inline-size: 0;
94
+ /* Long month names in a narrow track (compact consumers, long locales)
95
+ would paint under the caret: truncate with an ellipsis instead. */
96
+ overflow: hidden;
97
+ text-overflow: ellipsis;
98
+ appearance: none;
99
+ padding-inline: 0.45rem 2rem;
100
+ background-image:
101
+ linear-gradient(45deg, transparent 50%, currentColor 50%),
102
+ linear-gradient(135deg, currentColor 50%, transparent 50%);
103
+ background-position:
104
+ calc(100% - 0.9rem) 50%,
105
+ calc(100% - 0.65rem) 50%;
106
+ background-size: 0.3rem 0.3rem;
107
+ background-repeat: no-repeat;
108
+ }
109
+
110
+ /* Inherited RTL mirrors the header layout via the grid. The logical
111
+ \`padding-inline\` already flips, so only the physically-positioned caret has
112
+ to follow it to the other side. */
113
+ [dir="rtl"] .dp-month-select,
114
+ html[dir="rtl"] .dp-month-select {
115
+ background-position:
116
+ 0.9rem 50%,
117
+ 0.65rem 50%;
69
118
  }
70
119
 
71
120
  .dp-year-input {
72
- inline-size: 5.5rem;
121
+ inline-size: var(--dp-year-inline-size);
73
122
  }
74
123
 
75
124
  .dp-nav {
76
125
  display: grid;
77
126
  place-items: center;
78
- inline-size: 2.25rem;
127
+ inline-size: var(--dp-header-control-size);
79
128
  padding: 0;
80
129
  font-size: 1.35rem;
81
130
  line-height: 1;
@@ -89,6 +138,14 @@ date-calendar {
89
138
  pointer-events: none;
90
139
  }
91
140
 
141
+ /* Inherited RTL mirrors the header layout via the grid; mirror the nav glyphs
142
+ so previous/next keep their visual sense. Actions stay chronological: no
143
+ button swap, no keyboard remapping. */
144
+ [dir="rtl"] .dp-nav svg,
145
+ html[dir="rtl"] .dp-nav svg {
146
+ transform: scaleX(-1);
147
+ }
148
+
92
149
  .dp-calendar-header :where(button, select, input):disabled,
93
150
  .dp-picker-button:disabled {
94
151
  cursor: not-allowed;
@@ -99,6 +156,14 @@ date-calendar {
99
156
  background: var(--dp-hover);
100
157
  }
101
158
 
159
+ /* Shared control focus: accent border + light halo. Day cells keep their
160
+ dedicated outline ring below; the picker trigger has its own inner ring. */
161
+ .dp-calendar-header :where(button, select, input):focus-visible {
162
+ outline: none;
163
+ border-color: var(--dp-accent);
164
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--dp-accent) 22%, transparent);
165
+ }
166
+
102
167
  .dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not(
103
168
  [data-range-end="true"]
104
169
  ) {
@@ -111,8 +176,8 @@ date-calendar {
111
176
 
112
177
  .dp-grid {
113
178
  border-collapse: separate;
114
- /* --dp-gap scopes to the header grid; day-cell spacing stays fixed. */
115
- border-spacing: 0 0.25rem;
179
+ /* --dp-gap scopes to the header grid; vertical week rhythm is --dp-row-gap. */
180
+ border-spacing: 0 var(--dp-row-gap);
116
181
  table-layout: fixed;
117
182
  }
118
183
 
@@ -125,26 +190,41 @@ date-calendar {
125
190
  }
126
191
 
127
192
  .dp-grid thead th {
128
- block-size: 1.6rem;
193
+ block-size: 1.5rem;
129
194
  color: var(--dp-muted);
130
195
  font-size: 0.72rem;
131
- font-weight: 600;
196
+ font-weight: 500;
132
197
  }
133
198
 
134
199
  .dp-day {
135
200
  position: relative;
136
201
  border: 1px solid transparent;
137
- border-radius: calc(var(--dp-radius) * 0.75);
202
+ border-radius: var(--dp-day-radius);
138
203
  cursor: pointer;
139
204
  outline: none;
140
205
  vertical-align: middle;
141
206
  font-size: 0.875rem;
142
207
  }
143
208
 
209
+ /* Inner ring: keyboard focus stays inside the cell instead of reading as a
210
+ second selected state or bleeding onto a neighbouring range band. It is an
211
+ \`outline\` (not an inset box-shadow) because forced colors computes
212
+ box-shadow to \`none\`, which would erase the keyboard indicator entirely. */
144
213
  .dp-day:focus-visible {
145
214
  outline: 2px solid var(--dp-accent);
146
- outline-offset: 1px;
147
- z-index: 1;
215
+ outline-offset: -2px;
216
+ }
217
+
218
+ /* On an accent-filled cell the ring inverts so it stays readable. */
219
+ .dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]):focus-visible {
220
+ outline-color: var(--dp-accent-fg);
221
+ }
222
+
223
+ /* Base tint for days outside the displayed month. It stays before the
224
+ selection states so selected/range endpoints keep their accent-contrast
225
+ text on the accent fill (equal specificity, source order decides). */
226
+ .dp-day[data-outside-month="true"] {
227
+ color: var(--dp-muted);
148
228
  }
149
229
 
150
230
  .dp-day[data-selected="true"] {
@@ -152,14 +232,13 @@ date-calendar {
152
232
  color: var(--dp-accent-fg);
153
233
  }
154
234
 
155
- .dp-day[data-today="true"]:not([data-selected="true"]) {
235
+ /* Today never competes with a stronger state: a selected day or a range
236
+ endpoint keeps its own treatment, in normal rendering and in
237
+ forced-colors alike. */
238
+ .dp-day[data-today="true"]:not([data-selected="true"], [data-range-start="true"], [data-range-end="true"]) {
156
239
  border-color: var(--dp-accent);
157
240
  }
158
241
 
159
- .dp-day[data-outside-month="true"] {
160
- color: var(--dp-muted);
161
- }
162
-
163
242
  .dp-day[data-disabled="true"] {
164
243
  cursor: not-allowed;
165
244
  opacity: 0.42;
@@ -188,13 +267,13 @@ date-calendar {
188
267
  }
189
268
 
190
269
  .dp-day[data-in-range="true"]:first-of-type {
191
- border-start-start-radius: var(--dp-radius);
192
- border-end-start-radius: var(--dp-radius);
270
+ border-start-start-radius: var(--dp-day-radius);
271
+ border-end-start-radius: var(--dp-day-radius);
193
272
  }
194
273
 
195
274
  .dp-day[data-in-range="true"]:last-of-type {
196
- border-start-end-radius: var(--dp-radius);
197
- border-end-end-radius: var(--dp-radius);
275
+ border-start-end-radius: var(--dp-day-radius);
276
+ border-end-end-radius: var(--dp-day-radius);
198
277
  }
199
278
 
200
279
  .dp-day-number {
@@ -202,6 +281,17 @@ date-calendar {
202
281
  font-variant-numeric: tabular-nums;
203
282
  }
204
283
 
284
+ /* A focused disabled day stays discoverable by keyboard: restore full opacity
285
+ so the focus outline renders at full strength, and mark the number with the
286
+ muted tone (same language as outside-month days) instead of the wash-out. */
287
+ .dp-day[data-disabled="true"]:focus-visible {
288
+ opacity: 1;
289
+ }
290
+
291
+ .dp-day[data-disabled="true"]:focus-visible .dp-day-number {
292
+ color: var(--dp-muted);
293
+ }
294
+
205
295
  .dp-day-extra {
206
296
  position: absolute;
207
297
  inset-inline: 2px;
@@ -226,18 +316,95 @@ date-calendar {
226
316
  date-picker {
227
317
  position: relative;
228
318
  display: inline-grid;
229
- grid-template-columns: minmax(0, 1fr) auto;
319
+ grid-template-columns: minmax(0, 1fr);
230
320
  align-items: stretch;
231
321
  max-inline-size: 100%;
232
322
  }
233
323
 
324
+ /* Visible focus is normalized to --dp-accent so the component holds together
325
+ without a consumer stylesheet; the field's own look stays consumer-owned. */
326
+ date-picker > input:not([type="hidden"]):focus-visible {
327
+ border-color: var(--dp-accent);
328
+ outline: none;
329
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--dp-accent) 20%, transparent);
330
+ }
331
+
332
+ /* Every authored control is a grid item. */
234
333
  date-picker > input:not([type="hidden"]) {
235
- grid-column: 1;
236
334
  min-inline-size: 0;
237
335
  }
238
336
 
239
- date-picker[range] > input:not([type="hidden"]) {
337
+ /* Date fields reserve room for the trigger, which is painted inside the
338
+ field's own box: the field is the real outer box, so its focus ring wraps
339
+ the affordance too. \`grid-row\` must stay explicit, otherwise the trigger
340
+ (placed with a definite row) claims the row and pushes the field down. */
341
+ date-picker > input:not([type="hidden"]):not([type="time"]) {
240
342
  grid-column: 1;
343
+ grid-row: 1;
344
+ box-sizing: border-box;
345
+ inline-size: 100%;
346
+ padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem);
347
+ }
348
+
349
+ /* The trigger is a real button overlaid on the field's inline-end, like the
350
+ native \`input[type=time]\` indicator: no chrome of its own, transparent, so
351
+ the authored field background and border stay visible underneath. */
352
+ .dp-picker-button {
353
+ display: grid;
354
+ place-items: center;
355
+ grid-column: 1;
356
+ grid-row: 1;
357
+ justify-self: end;
358
+ align-self: stretch;
359
+ inline-size: var(--dp-picker-button-size);
360
+ min-inline-size: 0;
361
+ border: 0;
362
+ background: transparent;
363
+ color: var(--dp-fg);
364
+ font: inherit;
365
+ cursor: pointer;
366
+ }
367
+
368
+ /* Like the native time indicator: the ring wraps the icon, not the field (the
369
+ field already shows its own ring through :focus-visible). Same radius as
370
+ everywhere else: no bespoke shape. */
371
+ .dp-picker-button:focus-visible {
372
+ outline: 2px solid var(--dp-accent);
373
+ outline-offset: -5px;
374
+ border-radius: var(--dp-radius);
375
+ }
376
+
377
+ /* Optional native time companions share the date row; authored inputs stay
378
+ consumer-styled, the picker only reserves their grid cells. Time tracks are
379
+ flexible (never \`auto\`) so a wide UA time control cannot squeeze the date.
380
+ Each companion keeps its own box and its own gap: nothing is joined, so
381
+ focus rings never merge and no neighbour swallows another's focus. */
382
+ date-picker:has(> [data-time-start], > [data-time-end]) {
383
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
384
+ column-gap: var(--dp-gap);
385
+ }
386
+
387
+ date-picker:has(> [data-time-start]):has(> [data-time-end]) {
388
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
389
+ }
390
+
391
+ date-picker > input[data-time-start] {
392
+ grid-column: 2;
393
+ grid-row: 1;
394
+ min-inline-size: 0;
395
+ }
396
+
397
+ date-picker > input[data-time-end] {
398
+ grid-column: 3;
399
+ grid-row: 1;
400
+ min-inline-size: 0;
401
+ }
402
+
403
+ /* Range: two stacked fields, each owning its trigger, sharing one popup and
404
+ one calendar. No trigger spans both bounds, so each bound keeps a local
405
+ affordance and a local focus target. */
406
+ date-picker[range] {
407
+ row-gap: var(--dp-gap);
241
408
  }
242
409
 
243
410
  date-picker[range] > input[data-range-start] {
@@ -248,35 +415,26 @@ date-picker[range] > input[data-range-end] {
248
415
  grid-row: 2;
249
416
  }
250
417
 
251
- .dp-picker-button {
252
- grid-column: 2;
253
- min-inline-size: 2.5rem;
254
- border: 1px solid var(--dp-border);
255
- border-inline-start: 0;
256
- border-start-start-radius: 0;
257
- border-end-start-radius: 0;
258
- border-start-end-radius: var(--dp-radius);
259
- border-end-end-radius: var(--dp-radius);
260
- background: var(--dp-bg);
261
- color: var(--dp-fg);
262
- font: inherit;
263
- cursor: pointer;
418
+ date-picker[range] > .dp-picker-button[data-endpoint="start"] {
419
+ grid-row: 1;
264
420
  }
265
421
 
266
- date-picker[range] > .dp-picker-button {
267
- grid-row: 1 / span 2;
422
+ date-picker[range] > .dp-picker-button[data-endpoint="end"] {
423
+ grid-row: 2;
268
424
  }
269
425
 
270
426
  .dp-picker-panel[popover] {
427
+ /* Safe baseline. show() switches to absolute only when the consumer
428
+ * explicitly selects document coordinate space. */
271
429
  position: fixed;
272
430
  inset: auto;
273
431
  margin: 0;
274
- padding: 0.65rem;
432
+ padding: 0.875rem 1rem;
275
433
  border: 1px solid var(--dp-border);
276
434
  border-radius: var(--dp-radius);
277
435
  background: var(--dp-bg);
278
436
  color: var(--dp-fg);
279
- box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.16);
437
+ box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);
280
438
  max-block-size: var(--available-height, 90svh);
281
439
  max-inline-size: calc(100vi - 1rem);
282
440
  overflow: auto;
@@ -287,19 +445,22 @@ date-picker[range] > .dp-picker-button {
287
445
  }
288
446
 
289
447
  @media (forced-colors: active) {
290
- .dp-day[data-selected="true"] {
291
- border: 2px solid Highlight;
292
- background-color: Canvas;
293
- color: CanvasText;
294
- font-weight: 700;
448
+ /* The author-drawn caret is a gradient and disappears here: hand the
449
+ control back to the browser instead of trying to rebuild it. */
450
+ .dp-month-select,
451
+ [dir="rtl"] .dp-month-select {
452
+ appearance: auto;
453
+ background-image: none;
454
+ padding-inline: 0.45rem;
295
455
  }
296
456
 
297
- .dp-day[data-range-start="true"],
298
- .dp-day[data-range-end="true"] {
457
+ /* Fills vanish here, so selection and endpoints fall back to a 2px
458
+ Highlight border. The in-range underline is the only band marker left:
459
+ the range fill is lost and the browser does not know the semantics. */
460
+ .dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]) {
299
461
  border: 2px solid Highlight;
300
462
  background-color: Canvas;
301
463
  color: CanvasText;
302
- font-weight: 700;
303
464
  }
304
465
 
305
466
  .dp-day[data-in-range="true"] {
@@ -315,15 +476,8 @@ date-picker[range] > .dp-picker-button {
315
476
  background-color: Highlight;
316
477
  }
317
478
 
318
- .dp-day[data-selected="true"]::before {
319
- content: "";
320
- position: absolute;
321
- inset: 3px;
322
- border: 1px solid CanvasText;
323
- border-radius: calc(var(--dp-radius) * 0.5);
324
- pointer-events: none;
325
- }
326
-
479
+ /* Pin the today marker: the deterministic accent is a non-system color
480
+ and would otherwise remap unpredictably here. */
327
481
  .dp-day[data-today="true"] {
328
482
  border-color: Highlight;
329
483
  }
@@ -332,27 +486,20 @@ date-picker[range] > .dp-picker-button {
332
486
  color: CanvasText;
333
487
  forced-color-adjust: none;
334
488
  }
335
-
336
- .dp-day[data-disabled="true"],
337
- .dp-calendar-header :where(button, select, input):disabled,
338
- .dp-picker-button:disabled {
339
- opacity: 1;
340
- color: GrayText;
341
- }
342
489
  }
343
- `;var Rt=/^(\d{4})-(\d{2})-(\d{2})$/,Ot=/^(\d{4})-(\d{2})$/;function zt(t){return t%4===0&&(t%100!==0||t%400===0)}function X(t,e){if(e===2)return zt(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=Rt.exec(String(t||""));if(!e)return null;let i=Number(e[1]),s=Number(e[2]),n=Number(e[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>X(i,s))return null;return{year:i,month:s,day:n}}function l(t){return F(t)!==null}function f(t){let e=String(t||""),i=Ot.exec(e);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=F(e);if(!s)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function P(t,e,i){let s=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!l(s))throw TypeError(`Invalid civil date: ${s}`);return s}function J(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function Ht(t){return P(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function N(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e)}function w(t,e){if(!l(t)||!l(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function I(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let s=J(i);return s.setUTCDate(s.getUTCDate()+e),Ht(s)}function Q(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+e,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,X(n,a));return P(n,a,o)}function ht(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let s=i.year+e,n=Math.min(i.day,X(s,i.month));return P(s,i.month,n)}function V(t,e){let i=`${f(t)}-01`;return f(Q(i,e))}function Bt(t){return`${f(t)}-01`}function Vt(t){let e=F(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return P(e.year,e.month,X(e.year,e.month))}function Pt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e).getUTCDay()}function K(t){if(t===7)return 0;if(!Number.isInteger(t)||t<0||t>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return t}function tt(t,e=1){let i=(Pt(t)-K(e)+7)%7;return I(t,-i)}function it(t,e=1){return I(tt(t,e),6)}function ft(t,e={}){let i=e.firstDay??1,s=tt(Bt(t),i),n=it(Vt(t),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let c=0;c<7;c++)o.push(I(a,c));r.push(o),a=I(a,7)}return r}function pt(t,e="",i=""){if(!l(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&w(t,e)<0)return e;if(i&&w(t,i)>0)return i;return t}function R(){let t=new Date;return P(t.getFullYear(),t.getMonth()+1,t.getDate())}function mt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let i=J(e),s=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-s);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-n.getTime())/86400000+1)/7)}class st{constructor(t={}){let e=R();this.firstDay=K(t.firstDay??1),this.value=t.value&&l(t.value)?t.value:"",this.focused=t.focused&&l(t.focused)?t.focused:this.value||e,this.display=t.display?f(t.display):f(this.focused)}setValue(t){if(t&&!l(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=f(t),i=Number(this.focused.slice(8,10))||1,s=Q(`${e}-01`,0),n=I(s,Math.max(0,i-1));return this.focused=f(n)===e?n:I(`${V(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!l(t))throw TypeError(`Invalid focused date: ${t}`);if(this.focused=t,e.follow!==!1)this.display=f(t);return this.focused}moveFocusDays(t){return this.setFocused(I(this.focused,t))}moveFocusMonths(t){return this.setFocused(Q(this.focused,t))}moveFocusYears(t){return this.setFocused(ht(this.focused,t))}focusWeekStart(){return this.setFocused(tt(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(it(this.focused,this.firstDay))}navigateMonth(t){let e=V(this.display,t);return this.setDisplay(e),this.display}}function et(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:i=""}=t;if(e&&!l(e))throw TypeError(`Invalid range start: ${e}`);if(i&&!l(i))throw TypeError(`Invalid range end: ${i}`);if(!e&&i)throw TypeError("highlightedRange cannot define an end without a start");if(e&&i&&w(i,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:i}}function gt(t,e){if(!e||!l(t))return"";let{start:i,end:s}=e;if(!i||!l(i))return"";if(i===t)return s?s===t?"single":"start":"start";if(s&&s===t)return"end";if(s&&w(t,i)>=0&&w(t,s)<=0)return"in";return""}class nt{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&w(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}activate(t,e=()=>!0){if(!l(t))throw TypeError(`Invalid range activation: ${t}`);if(this.complete&&(w(t,this.start)<0||w(t,this.end)>0)){let i=w(t,this.start)<0?"start":"end";if(!e(i))return{status:"refused",endpoint:i};return this[i]=t,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&w(t,this.start)<0)return{status:"refused",endpoint:"end"};if(!e("end"))return{status:"refused",endpoint:"end"};return this.end=t,{status:this.start?"complete":"pending",endpoint:"end"}}if(!e("start"))return{status:"refused",endpoint:"start"};if(this.start=t,!e("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var yt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function H(t=""){if(t)return t;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Nt(t){let e=new Intl.NumberFormat(t,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(e.format(s),String(s));return i}function _t(t,e){let i=String(t||"").replace(yt,"").trim();for(let[s,n]of Nt(e))i=i.split(s).join(n);return i}function Y(t,e=""){let i=H(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(N(t))}function bt(t,e=""){let i=H(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(N(`${t.slice(0,7)}-15`))}function vt(t="",e="long"){let i=H(t),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(N(`2026-${String(r+1).padStart(2,"0")}-15`)))}function rt(t="",e=1,i="short"){let s=H(t),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=K(e),a=N("2026-01-04");return Array.from({length:7},(o,c)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+c)%7),n.format(d)})}function Ut(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(t=""){let e=H(t),i=new Intl.DateTimeFormat(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=N("2006-11-22"),n=i.formatToParts(s).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(yt,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let h=_t(d.value,e).replace(/\s+/g," ");return Ut(h).replace(/\\ /g,"\\s*")}).join(""),c=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(d){if(!l(d))return"";return i.format(N(d))},parse(d){let h=_t(d,e);if(l(h))return h;let E=c.exec(h);if(!E)return"";let g={};if(r.forEach((b,k)=>{g[b]=Number(E[k+1])}),!g.year||!g.month||!g.day)return"";try{return P(g.year,g.month,g.day)}catch{return""}}}}var Yt={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Wt={...Yt};function W(){return{...Wt}}function wt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,i=new Map;if(Array.isArray(e)){for(let s of e){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(e&&typeof e==="object")for(let[s,n]of Object.entries(e))i.set(s,n&&typeof n==="object"?n:{});return i}var jt=0;function A(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function Kt(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function qt(t){return Number(t.slice(0,4))}function Gt(t){switch(t){case"single":return' data-range-start="true" data-range-end="true"';case"start":return' data-range-start="true"';case"end":return' data-range-end="true"';case"in":return' data-in-range="true"';default:return""}}function Zt(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class G extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection"];constructor(){super();this._id=`date-calendar-${++jt}`,this._model=new st,this._connected=!1,this._rendering=!1,this._source=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._messages=W(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return H(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get value(){return this._model.value}set value(t){let e=t||"";if(e&&!l(e))throw TypeError(`Invalid calendar value: ${e}`);if(e===this._model.value)return;if(this._model.setValue(e),this._reflect("value",e),this._connected)this.render()}get display(){return this._model.display}set display(t){this._setDisplay(t,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(t){let e=t||"";if(e===this._model.focused)return;this.focusDate(e,{moveFocus:!1})}get min(){let t=this.getAttribute("min")||"";return l(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return l(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return Kt(this.getAttribute("first-day")||"1")}set firstDay(t){this.setAttribute("first-day",String(t))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(t){this.setAttribute("selection",t==="none"?"none":"single")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=et(t);if(e.start===this._highlightedRange.start&&e.end===this._highlightedRange.end)return;if(this._highlightedRange=e,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(t){this.toggleAttribute("fixed-weeks",Boolean(t))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(t){this.toggleAttribute("show-week-numbers",Boolean(t))}get messages(){return this._messages}set messages(t){if(this._messages={...W(),...t||{}},this._connected)this.render()}get source(){return this._source}set source(t){this._source=t||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._connected)this.render()}_syncModel(){let t=this.firstDay;this._model.firstDay=t;let e=this.getAttribute("value")||"";if(!e||l(e))this._model.value=e;let i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(i)}catch{}else if(this._model.value)this._model.display=f(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=f(this._model.focused)}_reflect(t,e){if(this._rendering=!0,e){if(this.getAttribute(t)!==e)this.setAttribute(t,e)}else if(this.hasAttribute(t))this.removeAttribute(t);this._rendering=!1}_clamp(t){return pt(t,this.min,this.max)}_weeks(t=this.display){let e=ft(t,{firstDay:this.firstDay});if(!this.fixedWeeks||e.length>=6)return e;let i=e[e.length-1]?.[6]||"";while(e.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(I(i,n));e.push(s),i=s[6]}return e}_focusTargetKey(t){if(t.matches(".dp-month-select, .dp-year-select, .dp-year-input")&&t.id)return`#${CSS.escape(t.id)}`;if(t.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(t.dataset.calendarAction||"")}"]`;if(t.matches(".dp-day[data-date]")){let e=t.getAttribute("data-date")||"";if(l(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),i=e[0],s=e[e.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},i=this._dateState?.(t,{...e})||{},s={...e,...i},n=this.min&&w(t,this.min)<0||this.max&&w(t,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(s.disabled)||a;return{...s,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(t){if(!l(t)||!this._source)return!0;return await this._loadDisplay(f(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let i=this._range(t),s=`${i.start}/${i.end}`;if(this._loadedRanges.has(s))return"loaded";if(s===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=s;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let c=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,h]of wt(c))this._sourceStates.set(d,h);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),e&&this._connected&&f(this.display)===f(t))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===s)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let i=this._model.display;if(this._model.setDisplay(t),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(e.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let t=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...t},bubbles:!0}))}previousMonth(){return this._setDisplay(V(this.display,-1))}nextMonth(){return this._setDisplay(V(this.display,1))}focusDate(t,e={}){if(!l(t))throw TypeError(`Invalid date: ${t}`);let i=this._clamp(t),s=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),s!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(t,e,i=!0){let s=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(t,e){if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async _activate(t){let e=await this.ensureDate(t),i=this.getDateState(t);if(!e||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:t,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:t,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(t),this._reflect("value",t),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:t},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(t)===this.display)this._moveSelectionDom(n,t);else this.render()}else if(this._connected){if(f(t)!==this.display)this.render()}return!0}_onClick(t){let e=t.target;if(!(e instanceof Element))return;let i=e.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let s=e.closest(".dp-day[data-date]");if(!(s instanceof HTMLTableCellElement))return;let n=s.dataset.date||"";if(!l(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this._activate(n)}_onChange(t){let e=t.target;if(e instanceof HTMLSelectElement&&e.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${e.value}`);return}if(e instanceof HTMLSelectElement&&e.matches(".dp-year-select")){this._setDisplay(`${e.value}-${this.display.slice(5,7)}`);return}if(e instanceof HTMLInputElement&&e.matches(".dp-year-input")){let i=Number(e.value);if(!Number.isInteger(i)||i<1||i>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||"";if(l(i))this._model.focused=i}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._activate(i);return}let s=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),t.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(t.key==="ArrowRight")this._model.moveFocusDays(1);else if(t.key==="ArrowUp")this._model.moveFocusDays(-7);else if(t.key==="ArrowDown")this._model.moveFocusDays(7);else if(t.key==="Home")this._model.focusWeekStart();else if(t.key==="End")this._model.focusWeekEnd();else if(t.key==="PageUp")t.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(t.key==="PageDown")t.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,i=this.display,s=qt(i),n=Number(i.slice(5,7)),r=vt(e,"long"),a=rt(e,this.firstDay,"short"),o=rt(e,this.firstDay,"long"),c=this._weeks(),d=R(),h=`${this._id}-heading`,E=`${this._id}-grid`,g=this.min?f(this.min):"",b=this.max?f(this.max):"",k=Boolean(g&&V(i,-1)<g),T=Boolean(b&&V(i,1)>b),x=this.min?` min="${Number(this.min.slice(0,4))}"`:"",_=this.max?` max="${Number(this.max.slice(0,4))}"`:"",m=this.showWeekNumbers&&this.firstDay===1,C=m?`<th scope="col" class="dp-week-heading" abbr="${A(this._messages.week)}">#</th>`:"",v=r.map((D,S)=>{let p=S+1,u=`${String(s).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=g&&u<g||b&&u>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${A(D)}</option>`}).join(""),B=a.map((D,S)=>`<th scope="col" abbr="${A(o[S])}">${A(D.replace(".",""))}</th>`).join(""),U=c.map((D)=>{let S=m?`<th scope="row" class="dp-week-number">${mt(D[0])}</th>`:"",p=D.map((u)=>{let y=this.getDateState(u),M=f(u)!==i,L=this.value===u,j=this.focusedDate===u,dt=u===d,lt=gt(u,this._highlightedRange),ct=Zt(lt),Lt=typeof y.description==="string"?y.description:"",It=[Y(u,e),Lt,ct?this._messages[ct]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${u}"${M?' data-outside-month="true"':""}${dt?' data-today="true" aria-current="date"':""}${L?' data-selected="true" aria-selected="true"':""}${Gt(lt)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${j?"0":"-1"}" aria-label="${A(It)}"><span class="dp-day-number" aria-hidden="true">${Number(u.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${S}${p}</tr>`}).join(""),O=document.activeElement,z=O instanceof HTMLElement&&this.contains(O)?this._focusTargetKey(O):"";if(this._rendering=!0,this.innerHTML=`
490
+ `;var Ue=/^(\d{4})-(\d{2})-(\d{2})$/,Ye=/^(\d{4})-(\d{2})$/;function We(e){return e%4===0&&(e%100!==0||e%400===0)}function ee(e,t){if(t===2)return We(e)?29:28;return[4,6,9,11].includes(t)?30:31}function I(e){let t=Ue.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=Number(t[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>ee(i,s))return null;return{year:i,month:s,day:n}}function c(e){return I(e)!==null}function f(e){let t=String(e||""),i=Ye.exec(t);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=I(t);if(!s)throw TypeError(`Invalid civil date/month: ${e}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function U(e,t,i){let s=`${String(e).padStart(4,"0")}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!c(s))throw TypeError(`Invalid civil date: ${s}`);return s}function te(e){let t=new Date(0);return t.setUTCHours(12,0,0,0),t.setUTCFullYear(e.year,e.month-1,e.day),t}function qe(e){return U(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}function B(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return te(t)}function w(e,t){if(!c(e)||!c(t))throw TypeError("compareDates() expects YYYY-MM-DD values");return e===t?0:e<t?-1:1}function L(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let s=te(i);return s.setUTCDate(s.getUTCDate()+t),qe(s)}function ie(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+t,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,ee(n,a));return U(n,a,o)}function _e(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addYears() expects a date and integer amount");let s=i.year+t,n=Math.min(i.day,ee(s,i.month));return U(s,i.month,n)}function P(e,t){let i=`${f(e)}-01`;return f(ie(i,t))}function Ke(e){return`${f(e)}-01`}function je(e){let t=I(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return U(t.year,t.month,ee(t.year,t.month))}function Ge(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return te(t).getUTCDay()}function j(e){if(e===7)return 0;if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return e}function se(e,t=1){let i=(Ge(e)-j(t)+7)%7;return L(e,-i)}function re(e,t=1){return L(se(e,t),6)}function ye(e,t={}){let i=t.firstDay??1,s=se(Ke(e),i),n=re(je(e),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let l=0;l<7;l++)o.push(L(a,l));r.push(o),a=L(a,7)}return r}function be(e,t="",i=""){if(!c(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&w(e,t)<0)return t;if(i&&w(e,i)>0)return i;return e}function O(){let e=new Date;return U(e.getFullYear(),e.getMonth()+1,e.getDate())}function ve(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let i=te(t),s=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-s);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-n.getTime())/86400000+1)/7)}class ae{constructor(e={}){let t=O();this.firstDay=j(e.firstDay??1),this.value=e.value&&c(e.value)?e.value:"",this.focused=e.focused&&c(e.focused)?e.focused:this.value||t,this.display=e.display?f(e.display):f(this.focused)}setValue(e){if(e&&!c(e))throw TypeError(`Invalid value: ${e}`);return this.value=e||"",this.value}setDisplay(e){let t=f(e),i=Number(this.focused.slice(8,10))||1,s=ie(`${t}-01`,0),n=L(s,Math.max(0,i-1));return this.focused=f(n)===t?n:L(`${P(t,1)}-01`,-1),this.display=t,this.display}setFocused(e,t={}){if(!c(e))throw TypeError(`Invalid focused date: ${e}`);if(this.focused=e,t.follow!==!1)this.display=f(e);return this.focused}moveFocusDays(e){return this.setFocused(L(this.focused,e))}moveFocusMonths(e){return this.setFocused(ie(this.focused,e))}moveFocusYears(e){return this.setFocused(_e(this.focused,e))}focusWeekStart(){return this.setFocused(se(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(re(this.focused,this.firstDay))}navigateMonth(e){let t=P(this.display,e);return this.setDisplay(t),this.display}}function ne(e){if(e==null)return{start:"",end:""};if(typeof e!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:t="",end:i=""}=e;if(t&&!c(t))throw TypeError(`Invalid range start: ${t}`);if(i&&!c(i))throw TypeError(`Invalid range end: ${i}`);if(!t&&i)throw TypeError("highlightedRange cannot define an end without a start");if(t&&i&&w(i,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:i}}function we(e,t){if(!t||!c(e))return"";let{start:i,end:s}=t;if(!i||!c(i))return"";if(i===e)return s?s===e?"single":"start":"start";if(s&&s===e)return"end";if(s&&w(e,i)>=0&&w(e,s)<=0)return"in";return""}class oe{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&w(this.end,this.start)>=0)}focus(e){this.activeEndpoint=e}activate(e,t=()=>!0){if(!c(e))throw TypeError(`Invalid range activation: ${e}`);if(this.complete&&(w(e,this.start)<0||w(e,this.end)>0)){let i=w(e,this.start)<0?"start":"end";if(!t(i))return{status:"refused",endpoint:i};return this[i]=e,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&w(e,this.start)<0)return{status:"refused",endpoint:"end"};if(!t("end"))return{status:"refused",endpoint:"end"};return this.end=e,{status:this.start?"complete":"pending",endpoint:"end"}}if(!t("start"))return{status:"refused",endpoint:"start"};if(this.start=e,!t("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var De=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function R(e=""){if(e)return e;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Xe(e){let t=new Intl.NumberFormat(e,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(t.format(s),String(s));return i}function xe(e,t){let i=String(e||"").replace(De,"").trim();for(let[s,n]of Xe(t))i=i.split(s).join(n);return i}function G(e,t=""){let i=R(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(B(e))}function ke(e,t=""){let i=R(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(B(`${e.slice(0,7)}-15`))}function Ee(e=""){let t=R(e);try{let i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(B("2026-09-15")),s=-1,n=-1;if(i.forEach((r,a)=>{let o=r.type;if(o==="month"){if(s<0)s=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),s>=0&&n>=0)return n<s?["year","month"]:["month","year"]}catch{}return["month","year"]}function Te(e="",t="long"){let i=R(e),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(B(`2026-${String(r+1).padStart(2,"0")}-15`)))}function de(e="",t=1,i="short"){let s=R(e),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=j(t),a=B("2026-01-04");return Array.from({length:7},(o,l)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+l)%7),n.format(d)})}function Ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function X(e=""){let t=R(e),i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=B("2006-11-22"),n=i.formatToParts(s).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(De,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let u=xe(d.value,t).replace(/\s+/g," ");return Ze(u).replace(/\\ /g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:t,placeholder:a,format(d){if(!c(d))return"";return i.format(B(d))},parse(d){let u=xe(d,t);if(c(u))return u;let C=l.exec(u);if(!C)return"";let m={};if(r.forEach((b,E)=>{m[b]=Number(C[E+1])}),!m.year||!m.month||!m.day)return"";try{return U(m.year,m.month,m.day)}catch{return""}}}}var Je={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Qe={...Je};function W(){return{...Qe}}function Ce(e){let t=e&&typeof e==="object"&&!Array.isArray(e)&&"dates"in e?e.dates:e,i=new Map;if(Array.isArray(t)){for(let s of t){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(t&&typeof t==="object")for(let[s,n]of Object.entries(t))i.set(s,n&&typeof n==="object"?n:{});return i}var et=0;function A(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function tt(e){let t=Number(e);if(t===7)return 0;return Number.isInteger(t)&&t>=0&&t<=6?t:1}function it(e){return Number(e.slice(0,4))}function st(e){switch(e){case"single":return' data-range-start="true" data-range-end="true"';case"start":return' data-range-start="true"';case"end":return' data-range-end="true"';case"in":return' data-in-range="true"';default:return""}}function nt(e){if(e==="single")return"rangeSingle";if(e==="start")return"rangeStart";if(e==="end")return"rangeEnd";if(e==="in")return"rangeInRange";return""}class Z extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];constructor(){super();this._id=`date-calendar-${++et}`,this._model=new ae,this._connected=!1,this._rendering=!1,this._source=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._messages=W(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return R(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get value(){return this._model.value}set value(e){let t=e||"";if(t&&!c(t))throw TypeError(`Invalid calendar value: ${t}`);if(t===this._model.value)return;if(this._model.setValue(t),this._reflect("value",t),this._connected)this.render()}get display(){return this._model.display}set display(e){this._setDisplay(e,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(e){let t=e||"";if(t===this._model.focused)return;this.focusDate(t,{moveFocus:!1})}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get firstDay(){return tt(this.getAttribute("first-day")||"1")}set firstDay(e){this.setAttribute("first-day",String(e))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(e){this.setAttribute("selection",e==="none"?"none":"single")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(e){let t=ne(e);if(t.start===this._highlightedRange.start&&t.end===this._highlightedRange.end)return;if(this._highlightedRange=t,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(e){this.toggleAttribute("fixed-weeks",Boolean(e))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(e){this.toggleAttribute("show-week-numbers",Boolean(e))}get messages(){return this._messages}set messages(e){if(this._messages={...W(),...e||{}},this._connected)this.render()}get source(){return this._source}set source(e){this._source=e||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._connected)this.render()}_syncModel(){let e=this.firstDay;this._model.firstDay=e;let t=this.getAttribute("value")||"";if(!t||c(t))this._model.value=t;let i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(i)}catch{}else if(this._model.value)this._model.display=f(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=f(this._model.focused)}_reflect(e,t){if(this._rendering=!0,t){if(this.getAttribute(e)!==t)this.setAttribute(e,t)}else if(this.hasAttribute(e))this.removeAttribute(e);this._rendering=!1}_clamp(e){return be(e,this.min,this.max)}_weeks(e=this.display){let t=ye(e,{firstDay:this.firstDay});if(!this.fixedWeeks||t.length>=6)return t;let i=t[t.length-1]?.[6]||"";while(t.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(L(i,n));t.push(s),i=s[6]}return t}_focusTargetKey(e){if(e.matches(".dp-month-select, .dp-year-input")&&e.id)return`#${CSS.escape(e.id)}`;if(e.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(e.dataset.calendarAction||"")}"]`;if(e.matches(".dp-day[data-date]")){let t=e.getAttribute("data-date")||"";if(c(t))return`.dp-day[data-date="${t}"]`}return""}_range(e=this.display){let t=this._weeks(e),i=t[0],s=t[t.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(e){let t=this._sourceStates.get(e)||{},i=this._dateState?.(e,{...t})||{},s={...t,...i},n=this.min&&w(e,this.min)<0||this.max&&w(e,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(e)),o=Boolean(n)||Boolean(s.disabled)||a;return{...s,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(e){if(!c(e)||!this._source)return!0;return await this._loadDisplay(f(e),!1)==="loaded"}async _loadDisplay(e,t=!0){if(!this._source)return"loaded";let i=this._range(e),s=`${i.start}/${i.end}`;if(this._loadedRanges.has(s))return"loaded";if(s===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=s;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let l=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,u]of Ce(l))this._sourceStates.set(d,u);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),t&&this._connected&&f(this.display)===f(e))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===s)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(e,t={}){let i=this._model.display;if(this._model.setDisplay(e),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(t.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let e=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...e},bubbles:!0}))}previousMonth(){return this._setDisplay(P(this.display,-1))}nextMonth(){return this._setDisplay(P(this.display,1))}focusDate(e,t={}){if(!c(e))throw TypeError(`Invalid date: ${e}`);let i=this._clamp(e),s=this.display,n=this._model.focused,r=t.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),s!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(e,t,i=!0){let s=e?this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(e,t){if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let e=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(e instanceof HTMLElement)e.focus()}async _activate(e){let t=await this.ensureDate(e),i=this.getDateState(e);if(!t||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:e,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:e,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(e),this._reflect("value",e),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:e},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(e)===this.display)this._moveSelectionDom(n,e);else this.render()}else if(this._connected){if(f(e)!==this.display)this.render()}return!0}_onClick(e){let t=e.target;if(!(t instanceof Element))return;let i=t.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let s=t.closest(".dp-day[data-date]");if(!(s instanceof HTMLTableCellElement))return;let n=s.dataset.date||"";if(!c(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this._activate(n)}_onChange(e){let t=e.target;if(t instanceof HTMLSelectElement&&t.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${t.value}`);return}if(t instanceof HTMLInputElement&&t.matches(".dp-year-input")){let i=Number(t.value);if(!Number.isInteger(i)||i<1||i>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||"";if(c(i))this._model.focused=i}_onKeyDown(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||this.focusedDate;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._activate(i);return}let s=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),e.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(e.key==="ArrowRight")this._model.moveFocusDays(1);else if(e.key==="ArrowUp")this._model.moveFocusDays(-7);else if(e.key==="ArrowDown")this._model.moveFocusDays(7);else if(e.key==="Home")this._model.focusWeekStart();else if(e.key==="End")this._model.focusWeekEnd();else if(e.key==="PageUp")e.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(e.key==="PageDown")e.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;e.preventDefault(),this.focusDate(this._clamp(r))}render(e=!0){if(!this._connected)return;let t=this.locale,i=this.display,s=it(i),n=Number(i.slice(5,7)),r=Te(t,this.monthFormat),a=de(t,this.firstDay,"short"),o=de(t,this.firstDay,"long"),l=this._weeks(),d=O(),u=`${this._id}-heading`,C=`${this._id}-grid`,m=this.min?f(this.min):"",b=this.max?f(this.max):"",E=Boolean(m&&P(i,-1)<m),S=Boolean(b&&P(i,1)>b),x=this.min?` min="${Number(this.min.slice(0,4))}"`:"",_=this.max?` max="${Number(this.max.slice(0,4))}"`:"",g=this.showWeekNumbers&&this.firstDay===1,T=g?`<th scope="col" class="dp-week-heading" abbr="${A(this._messages.week)}">#</th>`:"",v=r.map((D,k)=>{let p=k+1,h=`${String(s).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=m&&h<m||b&&h>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${A(D)}</option>`}).join(""),H=a.map((D,k)=>`<th scope="col" abbr="${A(o[k])}">${A(D.replace(".",""))}</th>`).join(""),Y=l.map((D)=>{let k=g?`<th scope="row" class="dp-week-number">${ve(D[0])}</th>`:"",p=D.map((h)=>{let y=this.getDateState(h),M=f(h)!==i,F=this.value===h,K=this.focusedDate===h,fe=h===d,pe=we(h,this._highlightedRange),me=nt(pe),Be=typeof y.description==="string"?y.description:"",Pe=[G(h,t),Be,me?this._messages[me]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${h}"${M?' data-outside-month="true"':""}${fe?' data-today="true" aria-current="date"':""}${F?' data-selected="true" aria-selected="true"':""}${st(pe)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${K?"0":"-1"}" aria-label="${A(Pe)}"><span class="dp-day-number" aria-hidden="true">${Number(h.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${k}${p}</tr>`}).join(""),z=document.activeElement,V=z instanceof HTMLElement&&this.contains(z)?this._focusTargetKey(z):"",q=Ee(t)[0]==="year";this.toggleAttribute("data-year-first",q);let N=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this._messages.month)}</label>
491
+ <select id="${this._id}-month" class="dp-month-select" aria-label="${A(this._messages.month)}">${v}</select>`,Q=`<label class="dp-visually-hidden" for="${this._id}-year">${A(this._messages.year)}</label>
492
+ <input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${s}"${x}${_} aria-label="${A(this._messages.year)}">`;if(this._rendering=!0,this.innerHTML=`
344
493
  <div class="dp-calendar-shell">
345
494
  <div class="dp-calendar-header">
346
- <label class="dp-visually-hidden" for="${this._id}-month">${A(this._messages.month)}</label>
347
- <select id="${this._id}-month" class="dp-month-select" aria-label="${A(this._messages.month)}">${v}</select>
348
- <label class="dp-visually-hidden" for="${this._id}-year">${A(this._messages.year)}</label>
349
- <input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${s}"${x}${_} aria-label="${A(this._messages.year)}">
350
- <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${A(this._messages.previousMonth)}"${k?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10 4-4 4 4 4"/></svg></button>
351
- <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${A(this._messages.nextMonth)}"${T?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 4 4 4-4 4"/></svg></button>
495
+ ${q?Q:N}
496
+ ${q?N:Q}
497
+ <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${A(this._messages.previousMonth)}"${E?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10 4-4 4 4 4"/></svg></button>
498
+ <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${A(this._messages.nextMonth)}"${S?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 4 4 4-4 4"/></svg></button>
352
499
  </div>
353
- <h2 id="${h}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${A(bt(`${i}-15`,e))}</h2>
354
- <table id="${E}" class="dp-grid" role="grid" aria-labelledby="${h}">
355
- <thead><tr>${C}${B}</tr></thead>
356
- <tbody>${U}</tbody>
500
+ <h2 id="${u}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${A(ke(`${i}-15`,t))}</h2>
501
+ <table id="${C}" class="dp-grid" role="grid" aria-labelledby="${u}">
502
+ <thead><tr>${T}${H}</tr></thead>
503
+ <tbody>${Y}</tbody>
357
504
  </table>
358
- </div>`,this._rendering=!1,z)queueMicrotask(()=>{let D=this.querySelector(z);if(D instanceof HTMLElement)D.focus()});if(this._renderDay)for(let D of this.querySelectorAll(".dp-day[data-date]")){if(!(D instanceof HTMLTableCellElement))continue;let S=D.dataset.date||"",p=D.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let u=this._renderDay(S,this.getDateState(S));if(u instanceof Node)p.append(u);else if(u!==void 0&&u!==null)p.textContent=String(u)}if(t)this._loadDisplay(i)}}function At(t){return t==="top"||t==="bottom"?"x":"y"}function Xt(t){let[e,i=null]=t.split("-");return{side:e,align:i,crossAxis:At(e)}}function Jt(t){return{top:"bottom",bottom:"top",left:"right",right:"left"}[t]||t}function Qt(t,e,i,s,n,r){let a=At(i),o=t.x+t.width/2-e.width/2,c=t.y+t.height/2-e.height/2,d=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(i){case"top":h={x:o,y:t.y-e.height-r};break;case"bottom":h={x:o,y:t.y+t.height+r};break;case"right":h={x:t.x+t.width+r,y:c};break;case"left":h={x:t.x-e.width-r,y:c};break;default:h={x:t.x,y:t.y}}if(s==="start"||s==="end"){let E=(n&&a==="x"?-1:1)*(s==="end"?1:-1);h[a]+=d*E}return h}function te(t,e,i,s){return Math.max(i-t,0)+Math.max(t+e-s,0)}function ee(t){let e="dir"in t?t.dir:"";if(e==="rtl")return!0;if(e==="ltr")return!1;let i=t.ownerDocument?.defaultView;if(i?.CSS?.supports?.("selector(:dir(rtl))")&&typeof t.matches==="function")return t.matches(":dir(rtl)");return Boolean(i?.Element&&t instanceof i.Element&&i.getComputedStyle(t).direction==="rtl")}var ie=25;function se(t){let e=t.defaultView;if(!e)return null;let i=t.documentElement,s=e.visualViewport,n=s?.offsetLeft||0,r=s?.offsetTop||0,a=s?.width||i.clientWidth||e.innerWidth,o=s?.height||i.clientHeight||e.innerHeight,c=t.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(c>0&&c<=ie){let d=e.getComputedStyle?.(i).scrollbarGutter;if(d&&d!=="auto")a-=c}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ne(t,e){return e.scope?e.scope.getBoundingClientRect():se(t.ownerDocument)}function xt(t,e,i,s,n){let r=i+n,a=s-e-n,o=a>=r,c=o?r:i,d=o?a:s-e;return Math.max(c,Math.min(t,d))}function Dt(t,e,i){if(!i)return 50;let s=(t-e)/i*100;return Math.round(Math.min(100,Math.max(0,s))*1000)/1000}function re(t,e){return t.right<e.x||t.left>e.right||t.bottom<e.y||t.top>e.bottom}function ae(t,e,i,s,n){if(e==="top")return Math.max(0,t.top-i.y-s-n);if(e==="bottom")return Math.max(0,i.bottom-t.bottom-s-n);return Math.max(0,i.height-n*2)}function oe(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function Tt(t){let{offsetWidth:e,offsetHeight:i}=t;if(e&&i)return{width:e,height:i};let s=t.getBoundingClientRect();return{width:e||s.width,height:i||s.height}}var Et=new WeakMap,kt={scroll:0,resize:1,"element-resize":2};function de(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,s=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function c(x,_){let m=s.get(x);if(m===void 0||kt[_]>kt[m])s.set(x,_)}function d(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let x=[...s];s.clear(),r=!1;for(let[_,m]of x){if(!i.has(_)||!_.floating.isConnected)continue;_.callback({type:m})}})}function h(x){for(let _ of i)c(_,x);d()}function E(x){if(!n)return null;let _=new Set,m=new n((B)=>{let U=!1;for(let O of B)if(_.has(O.target))U=!0;else _.add(O.target);if(!U)return;c(x,"element-resize"),d()}),{reference:C,floating:v}=x;if(C)m.observe(C);if(v!==C)m.observe(v);return m}let g=()=>h("scroll"),b=()=>h("resize");function k(){if(a)return;t.addEventListener("scroll",g,{passive:!0,capture:!0}),e.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",g,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function T(){if(!a)return;t.removeEventListener("scroll",g,{capture:!0}),e.removeEventListener("resize",b),o?.removeEventListener("scroll",g),o?.removeEventListener("resize",b),a=!1}return{add(x,_,m){let C={reference:x,floating:_,callback:m};i.add(C),k();let v=E(C),B=!1;return()=>{if(B)return;if(B=!0,i.delete(C),s.delete(C),v?.disconnect(),i.size===0)T()}}}}function le(t){let e=t.ownerDocument,i=Et.get(e);if(!i)i=de(e),Et.set(e,i);return i}function St(t,e,i){if(!e?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(t&&t.ownerDocument!==e.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return le(e).add(t,e,i)}function Ct(t,e,i){if(!oe(e))return null;let s=i.placement||"bottom-start",n=i.distance||0,r=i.flip!==!1,a=i.shift!==!1,o=i.shiftPadding??4,{side:c,align:d,crossAxis:h}=Xt(s),E=d?ee(t):!1,g=t.getClientRects(),b=c==="bottom"?g[g.length-1]:g[0];if(!b)return null;let k=ne(t,i);if(!k||re(b,k))return null;let T=Tt(e),x={x:{size:T.width,start:k.x,end:k.right},y:{size:T.height,start:k.y,end:k.bottom}},_=(p,u)=>Qt(b,T,p,u,E,n),m=(p,u)=>{let{size:y,start:M,end:L}=x[u];return te(p,y,M+o,L-o)},C=(p,u)=>{let{size:y,start:M,end:L}=x[u];return m(a?xt(p,y,M,L,o):p,u)},v=_(c,d);if(r){let p=h==="x"?"y":"x",u=m(v[p],p);if(u>0){let y=Jt(c),M=_(y,d),L=m(M[p],p);if(L<u)c=y,v=M,u=L}if(p==="x"&&u>0){let y=_("top",d),M=_("bottom",d),L=m(M.y,"y")<m(y.y,"y"),j=L?M:y;if(m(j.y,"y")+C(j.x,"x")<u+C(v.y,"y"))c=L?"bottom":"top",h="x",v=j}}if(h==="x"&&a&&d){let p=m(v.x,"x");if(p>0){let u=d==="end"?"start":"end",y=_(c,u);if(m(y.x,"x")<p)d=u,v=y}}if(a){let{size:p,start:u,end:y}=x[h];v[h]=xt(v[h],p,u,y,o)}let B=Dt(b.x+b.width/2,v.x,T.width),U=Dt(b.y+b.height/2,v.y,T.height),O=`${ae(b,c,k,n,o)}px`,{style:z}=e,D=z.getPropertyValue("--available-height")!==O;z.left=`${v.x}px`,z.top=`${v.y}px`,z.setProperty("--arrow-x",`${B}%`),z.setProperty("--arrow-y",`${U}%`),z.setProperty("--available-height",O);let S=d?`${c}-${d}`:c;return e.dataset.placement=S,{width:T.width,height:T.height,roomChanged:D,placement:S}}function Mt(t,e,i={}){let s=Ct(t,e,i);if(!s)return!1;if(s.roomChanged){let n=Tt(e);if(n.width!==s.width||n.height!==s.height)Ct(t,e,{...i,placement:s.placement,flip:!1})}return!0}class Z{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=q(e.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._originalName=t.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null}setLocale(t){this.adapter=q(t||"")}setMessages(t){this.messages=t||{}}format(t){return this.adapter.format(t)}parse(t){return this.adapter.parse(t)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let t=this.input;this._originalName=t.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(t,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let t=this.input,e=t.getAttribute("name")||"";if(e){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,t.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=e;t.removeAttribute("name")}if(this.hidden){if(t.hasAttribute("form"))this.hidden.setAttribute("form",t.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=t.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let t=this.input;if(this._dirty=!0,this.dirty(),this.hidden)this.hidden.value="";let e=t.value.trim();if(!e){t.setCustomValidity("");return}let i=this.canonical?this.adapter.format(this.canonical):"";t.setCustomValidity(e===i?"":this.messages.invalidDate)}async commit(){let t=this.input,e=++this._commitId,i=t.value.trim();if(!i){if(e!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(i);if(!s){if(e!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return t.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let n=await this.confirm(s);if(e!==this._commitId)return{status:"stale"};if(!n?.ok){if(this.hidden)this.hidden.value="";return t.setCustomValidity(n?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:s}}setCanonical(t,e={}){let i=t||"";if(i&&!l(i))throw TypeError(`Invalid date-picker value: ${i}`);if(this.dirty(),this.canonical=i,this._dirty=!1,this.hidden)this.hidden.value=i;if(e.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=l(t)?t:this.adapter.parse(t);return e&&l(e)?e:""}teardown(){this._attributeObserver?.disconnect(),this._attributeObserver=null;let t=this.hidden?.getAttribute("name")||this._originalName;if(t)this.input.setAttribute("name",t);this.hidden?.remove(),this.hidden=null}}var ce=0;class at extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus"];constructor(){super();this._id=`date-picker-${++ce}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._button=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=W(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._field=new Z(t,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(s)=>this._confirmDate(s),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let e=this._adapter(),i=this.getAttribute("value")||(l(t.value)?t.value:e.parse(t.value));if(i&&l(i))this._setValue(i,{emit:!1,format:!0});else if(!t.value)this._setValue("",{emit:!1,format:!1});else t.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}_connectRange(){let t=this.querySelector(":scope > input[data-range-start]"),e=this.querySelector(":scope > input[data-range-end]");if(!(t instanceof HTMLInputElement)||!(e instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new Z(t,{messages:this._messages,locale:this.locale}),new Z(e,{messages:this._messages,locale:this.locale})],this._range=new nt,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a)=>this._confirmDate(a),r.setupFormValue();this._build(e),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),s=l(t.value)?t.value:i.parse(t.value),n=l(e.value)?e.value:i.parse(e.value);if(this._setRange(s||"",n||"",{emit:!1}),t.value.trim()&&!l(s))t.setCustomValidity(this._messages.invalidDate);if(e.value.trim()&&!l(n))e.setCustomValidity(this._messages.invalidDate);if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._rangeMode()){for(let t of this._fields||[])this._teardownField(t);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null,this._button?.remove(),this._panel?.remove(),this._formatHint?.remove(),this._button=null,this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(t){if(!t)return;let e=t.input,i=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),i)e.setAttribute("aria-describedby",i);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,i){if(!this._connected||this._reflecting||e===i)return;if(t==="value"){if(this._rangeMode())return;if(!i||l(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(t==="locale")this._refreshLocale();if(t==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(t){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(t&&!l(t))throw TypeError(`Invalid date-picker value: ${t}`);this._setValue(t||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(t){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:e,end:i}=et(t);this._setRange(e,i)}get locale(){return H(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get min(){let t=this.getAttribute("min")||"";return l(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return l(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(t){if(t===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get messages(){return this._messages}set messages(t){if(this._messages={...W(),...t||{}},this._calendar)this._calendar.messages=this._messages;for(let e of this._fields||[])e.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(t){if(this._source=t||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??q(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;if(this._field?.syncInputState(),this._button)this._button.disabled=t.disabled||t.readOnly;if(this._open&&(t.disabled||t.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let i of this._fields)i.syncInputState();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields.every((i)=>i.input.disabled||i.input.readOnly);if(this._button)this._button.disabled=e;if(this._open&&(this._fields[t]?.input.disabled||this._fields[t]?.input.readOnly))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let t of this._fields){let e=t.input,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",i),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",this._panel.id)}}_build(t){let e=t||this._input;if(!e)return;let i=`${this._id}-panel`,s=`${this._id}-format`,n=document.createElement("button");n.type="button",n.className="dp-picker-button",n.setAttribute("aria-haspopup","dialog"),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-controls",i),n.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>';let r=document.createElement("div");r.id=i,r.className="dp-picker-panel",r.setAttribute("popover","manual"),r.setAttribute("role","dialog"),r.setAttribute("aria-label",this._messages.calendar);let a=new G;a.selection="none",a.fixedWeeks=!0,r.append(a);let o=document.createElement("span");if(o.id=s,o.className="dp-visually-hidden",e.insertAdjacentElement("afterend",n),n.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",o),this._button=n,this._panel=r,this._calendar=a,this._formatHint=o,!this._rangeMode()){this._originalDescribedBy=e.getAttribute("aria-describedby")||"";let c=[this._originalDescribedBy,s].filter(Boolean).join(" ");e.setAttribute("aria-describedby",c),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let t=this._input,e=this._button,i=this._calendar;if(!t||!e||!i)return;let s=new AbortController;this._controller=s;let{signal:n}=s;t.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),t.addEventListener("change",()=>void this._commitText(!1),{signal:n}),t.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),t.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),t.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n}),e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:n}),i.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!l(o))return;queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(this._input?.disabled||this._input?.readOnly)return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._focusInput()})},{signal:n}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:n}),this.ownerDocument.addEventListener("reset",(r)=>{let a=r.target;if(a instanceof HTMLFormElement&&this._input&&a===this._input.form)this.hide(!1),queueMicrotask(()=>{if(!r.defaultPrevented)this._restoreDefault()})},{capture:!0,signal:n}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:n})}_bindRange(){let t=this._button,e=this._calendar;if(!this._fields||!t||!e)return;let i=new AbortController;this._controller=i;let{signal:s}=i;for(let[n,r]of this._fields.entries()){let a=n===1?"end":"start";r.input.addEventListener("input",()=>r.handleInput(),{signal:s}),r.input.addEventListener("change",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("blur",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("focus",(o)=>this._onFieldFocus(a,o),{signal:s}),r.input.addEventListener("keydown",(o)=>this._onFieldKeyDown(a,o),{signal:s})}t.addEventListener("click",(n)=>{if(this._open){if(n.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:s}),e.addEventListener("click",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),e.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),e.addEventListener("dateactivate",(n)=>{let r=n,a=r.detail?.date;if(!l(a))return;queueMicrotask(()=>{if(r.defaultPrevented||!this._connected||!this._range)return;let o=this._pendingIntents.get(a);if(o===void 0||o!==this._rangeCommitId)return;this._pendingIntents.delete(a);let c=this._range.activate(a,(d)=>{let h=d==="end"?1:0,E=this._fields?.[h];return E!=null&&!E.input.disabled&&!E.input.readOnly});if(c.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:a,state:this._calendar.getDateState(a)},bubbles:!0}));return}if(this._setBound(c.endpoint,a,{emit:!0,user:!0}),c.close||c.status==="complete")this.hide(!1),this._focusField(c.endpoint)})},{signal:s}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:s}),this.ownerDocument.addEventListener("reset",(n)=>{let r=n.target;if(r instanceof HTMLFormElement&&this._fields&&r===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!n.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:s}),this.addEventListener("keydown",(n)=>this._onEscape(n),{signal:s})}_onFieldKeyDown(t,e){if(e.key==="ArrowDown"||e.altKey&&e.key==="ArrowDown"){if(e.preventDefault(),this._rangeMode()&&t)this._lastFocusEndpoint=t,this._range?.focus(t);if(this._open)setTimeout(()=>this._calendar?.focusGrid(),0);else this.show()}else if(e.key==="Escape"&&this._open)e.preventDefault(),this.hide(!1)}_onFieldFocus(t,e){if(!this._rangeMode()||!t)return;let i=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let s=e.relatedTarget;if(s instanceof Node&&this.contains(s))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(!this._rangeMode()||!this._range)return;if(t.type==="keydown"){let s=t.key;if(s!=="Enter"&&s!==" ")return}if(!(t.target instanceof Element))return;let i=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!l(i))return;this._pendingIntents.set(i,++this._rangeCommitId)}_onEscape(t){if(t.key==="Escape"&&this._open)t.preventDefault(),t.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let t=this._calendar,e=this._panel;if(!t)return;if(t.locale=this.locale,t.min=this.min,t.max=this.max,t.messages=this._messages,t.source=this._source,t.dateState=this._dateState,t.renderDay=this._renderDay,t.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)t.value=this._value;if(e)e.setAttribute("aria-label",this._messages.calendar)}_refreshLocale(){let t=this._formatHint;if(!t)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),t.textContent=`${this._messages.formatHint}: ${this._fields[0].placeholder}`;for(let[i,s]of this._fields.entries()){if(!s.input.hasAttribute("placeholder")||this._generatedPlaceholder)s.input.placeholder=s.placeholder,this._generatedPlaceholder=!0;let n=i===1?this._range?.end||"":this._range?.start||"";if(n)s.input.value=s.format(n)}this._refreshButtonLabel();return}let e=this._field;if(!e)return;if(e.setLocale(this.locale),t.textContent=`${this._messages.formatHint}: ${e.placeholder}`,!e.input.hasAttribute("placeholder")||this._generatedPlaceholder)e.input.placeholder=e.placeholder,this._generatedPlaceholder=!0;if(this._value)e.input.value=e.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){if(!this._button)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let t=this._value?this._messages.changeDate:this._messages.chooseDate,e=this._value?`, ${Y(this._value,this.locale)}`:"";this._button.setAttribute("aria-label",`${t}${e}`)}_refreshRangeButtonLabel(){if(!this._button||!this._range)return;let{start:t,end:e}=this._range,i=Boolean(t&&e),s=i?this._messages.changeDate:this._messages.chooseDate,n=i?`, ${Y(t,this.locale)} – ${Y(e,this.locale)}`:"";this._button.setAttribute("aria-label",`${s}${n}`)}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!l(t))throw TypeError(`Invalid date-picker value: ${t}`);let i=this._value;if(this._value=t||"",e.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:e.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let s=this._field.input;s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t){let e=this._calendar;if(!e)return{ok:!0};let i=f(t);if(e.display!==i)e.display=i;let s=await e.ensureDate(t),n=e.getDateState(t);if(!s||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let i=this._field;if(!i)return!1;if(!e.force&&!i.isDirty)return!1;let s=await i.commit();if(s.status==="stale"||s.status==="invalid")return!1;return this._setValue(s.value||"",{emit:t,format:s.status==="ok"}),!0}async _commitFieldText(t){let e=this._fields;if(!e)return!1;let i=t==="end"?1:0,s=e[i];if(!s?.isDirty)return!1;let n=await s.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(t,n.value||"",{emit:!0,user:!0,format:n.status==="ok"}),!0}_setBound(t,e,i={}){if(!this._range)return!1;let s=this._fields;if(!s)return!1;let r=s[t==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),t==="end")this._range.end=a;else this._range.start=a;let c=o!==a;if(c){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),i.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(t),c}_setRange(t,e,i={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:i.format!==!1}),this._fields[1].setCanonical(e||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(t){return this._range?t==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_syncHighlight(){if(!this._calendar||!this._range)return;let{start:t,end:e}=this._range;if(!t){this._calendar.highlightedRange={start:"",end:""};return}if(e&&w(e,t)<0)this._calendar.highlightedRange={start:t,end:""};else this._calendar.highlightedRange={start:t,end:e}}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:i}=this._range,s=Boolean(e&&i&&w(i,e)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,c=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(s&&r===t)o.setCustomValidity(c),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_restoreDefault(){let t=this._field;if(!t)return;let e=t.restoreDefault();if(this._setValue(e,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=f(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=f(R()),this._calendar.focusedDate=R();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let t=this._fields[0].restoreDefault(),e=this._fields[1].restoreDefault();if(this._setRange(t,e),this._calendar){let i=this._range?.start||R();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(t){let e=t==="end"?1:0,i=this._fields?.[e]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_focusInput(){this._suppressFocusOpen=!0,setTimeout(()=>{this._input?.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(!this._fields[e].input.disabled&&!this._fields[e].input.readOnly)return t;let i=t==="end"?"start":"end",s=i==="end"?1:0;if(!this._fields[s].input.disabled&&!this._fields[s].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let e=this._fields;if(!e)return!0;for(let[i,s]of e.entries()){let n=await s.commit();if(n.status==="ok"||n.status==="clear"){let r=i===1?"end":"start";this._setBound(r,n.value||"",{format:n.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),e.every((i)=>i.input.checkValidity())}let t=this._field?.input;if(!t)return!0;if(!t.value.trim())return t.setCustomValidity(""),t.checkValidity();return await this._commitText(!1,{force:!0}),t.checkValidity()}show(t={}){let e=this._panel,i=this._calendar,s=this._button;if(!e||!i||!s||this._open)return;if(this._rangeMode()){let r=this._resolveRangeEndpoint();if(!r)return;this._range?.focus(r),this._rangeCommitId++,this._pendingIntents.clear();let a=this._boundCanonical(r)||R();i.display=f(a),i.focusedDate=a,this._lastFocusEndpoint=r}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||R();i.display=f(a),i.focusedDate=a}e.showPopover(),this._open=!0,this._setExpanded(!0);let n=()=>Mt(this,e,{placement:"bottom-start",distance:4,shiftPadding:8});if(n(),this._stopTracking=St(this,e,n),t.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(t){let e=t?"true":"false";this._input?.setAttribute("aria-expanded",e),this._button?.setAttribute("aria-expanded",e);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",e)}hide(t=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._focusInput();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let t=this._range?.activeEndpoint||"";if(t){let e=t==="end"?1:0,i=this._fields?.[e];if(i&&!i.input.disabled&&!i.input.readOnly)return t}return this._resolveRangeEndpoint()}}function ot(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",G);if(!customElements.get("date-picker"))customElements.define("date-picker",at)}ot();var $t="lekoala-date-picker-styles";if(!document.getElementById($t)){let t=document.createElement("style");t.id=$t,t.textContent=ut,document.head.append(t)}ot();})();
505
+ </div>`,this._rendering=!1,V)queueMicrotask(()=>{let D=V;if(D.startsWith(".dp-day[data-date="))D=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let k=this.querySelector(D);if(k instanceof HTMLElement)k.focus()});if(this._renderDay)for(let D of this.querySelectorAll(".dp-day[data-date]")){if(!(D instanceof HTMLTableCellElement))continue;let k=D.dataset.date||"",p=D.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let h=this._renderDay(k,this.getDateState(k));if(h instanceof Node)p.append(h);else if(h!==void 0&&h!==null)p.textContent=String(h)}if(e)this._loadDisplay(i)}}function Le(e){return e==="top"||e==="bottom"?"x":"y"}function rt(e){let[t,i=null]=e.split("-");return{side:t,align:i,crossAxis:Le(t)}}function at(e){return{top:"bottom",bottom:"top",left:"right",right:"left"}[e]||e}function ot(e,t,i,s,n,r){let a=Le(i),o=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,d=e[a==="x"?"width":"height"]/2-t[a==="x"?"width":"height"]/2,u;switch(i){case"top":u={x:o,y:e.y-t.height-r};break;case"bottom":u={x:o,y:e.y+e.height+r};break;case"right":u={x:e.x+e.width+r,y:l};break;case"left":u={x:e.x-t.width-r,y:l};break;default:u={x:e.x,y:e.y}}if(s==="start"||s==="end"){let C=(n&&a==="x"?-1:1)*(s==="end"?1:-1);u[a]+=d*C}return u}function dt(e,t,i,s){return Math.max(i-e,0)+Math.max(e+t-s,0)}function lt(e){let t="dir"in e?e.dir:"";if(t==="rtl")return!0;if(t==="ltr")return!1;let i=e.ownerDocument?.defaultView;if(i?.CSS?.supports?.("selector(:dir(rtl))")&&typeof e.matches==="function")return e.matches(":dir(rtl)");return Boolean(i?.Element&&e instanceof i.Element&&i.getComputedStyle(e).direction==="rtl")}var ct=25;function ut(e){let t=e.defaultView;if(!t)return null;let i=e.documentElement,s=t.visualViewport,n=s?.offsetLeft||0,r=s?.offsetTop||0,a=s?.width||i.clientWidth||t.innerWidth,o=s?.height||i.clientHeight||t.innerHeight,l=e.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(l>0&&l<=ct){let d=t.getComputedStyle?.(i).scrollbarGutter;if(d&&d!=="auto")a-=l}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ht(e,t){return t.scope?t.scope.getBoundingClientRect():ut(e.ownerDocument)}function Ae(e,t,i,s,n){let r=i+n,a=s-t-n,o=a>=r,l=o?r:i,d=o?a:s-t;return Math.max(l,Math.min(e,d))}function Se(e,t,i){if(!i)return 50;let s=(e-t)/i*100;return Math.round(Math.min(100,Math.max(0,s))*1000)/1000}function ft(e,t){return e.right<t.x||e.left>t.right||e.bottom<t.y||e.top>t.bottom}function pt(e,t,i,s,n){if(t==="top")return Math.max(0,e.top-i.y-s-n);if(t==="bottom")return Math.max(0,i.bottom-e.bottom-s-n);return Math.max(0,i.height-n*2)}function mt(e){if(e.hidden)return!1;if(typeof e.checkVisibility==="function")return e.checkVisibility();return e.getClientRects().length>0}function Ie(e){let{offsetWidth:t,offsetHeight:i}=e;if(t&&i)return{width:t,height:i};let s=e.getBoundingClientRect();return{width:t||s.width,height:i||s.height}}var Me=new WeakMap,Fe={scroll:0,resize:1,"element-resize":2};function gt(e){let t=e.defaultView;if(!t)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,s=new Map,n=t.ResizeObserver,r=!1,a=!1,o=t.visualViewport;function l(x,_){let g=s.get(x);if(g===void 0||Fe[_]>Fe[g])s.set(x,_)}function d(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let x=[...s];s.clear(),r=!1;for(let[_,g]of x){if(!i.has(_)||!_.floating.isConnected)continue;_.callback({type:g})}})}function u(x){for(let _ of i)l(_,x);d()}function C(x){if(!n)return null;let _=new Set,g=new n((H)=>{let Y=!1;for(let z of H)if(_.has(z.target))Y=!0;else _.add(z.target);if(!Y)return;l(x,"element-resize"),d()}),{reference:T,floating:v}=x;if(T)g.observe(T);if(v!==T)g.observe(v);return g}let m=()=>u("scroll"),b=()=>u("resize");function E(){if(a)return;e.addEventListener("scroll",m,{passive:!0,capture:!0}),t.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",m,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function S(){if(!a)return;e.removeEventListener("scroll",m,{capture:!0}),t.removeEventListener("resize",b),o?.removeEventListener("scroll",m),o?.removeEventListener("resize",b),a=!1}return{add(x,_,g){let T={reference:x,floating:_,callback:g};i.add(T),E();let v=C(T),H=!1;return()=>{if(H)return;if(H=!0,i.delete(T),s.delete(T),v?.disconnect(),i.size===0)S()}}}}function _t(e){let t=e.ownerDocument,i=Me.get(t);if(!i)i=gt(t),Me.set(t,i);return i}function Oe(e,t,i){if(!t?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(e&&e.ownerDocument!==t.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return _t(t).add(e,t,i)}function $e(e,t,i){if(!mt(t))return null;let s=i.placement||"bottom-start",n=i.distance||0,r=i.flip!==!1,a=i.shift!==!1,o=i.shiftPadding??4,{side:l,align:d,crossAxis:u}=rt(s),C=d?lt(e):!1,m=e.getClientRects(),b=l==="bottom"?m[m.length-1]:m[0];if(!b)return null;let E=ht(e,i);if(!E||ft(b,E))return null;let S=Ie(t),x={x:{size:S.width,start:E.x,end:E.right},y:{size:S.height,start:E.y,end:E.bottom}},_=(p,h)=>ot(b,S,p,h,C,n),g=(p,h)=>{let{size:y,start:M,end:F}=x[h];return dt(p,y,M+o,F-o)},T=(p,h)=>{let{size:y,start:M,end:F}=x[h];return g(a?Ae(p,y,M,F,o):p,h)},v=_(l,d);if(r){let p=u==="x"?"y":"x",h=g(v[p],p);if(h>0){let y=at(l),M=_(y,d),F=g(M[p],p);if(F<h)l=y,v=M,h=F}if(p==="x"&&h>0){let y=_("top",d),M=_("bottom",d),F=g(M.y,"y")<g(y.y,"y"),K=F?M:y;if(g(K.y,"y")+T(K.x,"x")<h+T(v.y,"y"))l=F?"bottom":"top",u="x",v=K}}if(u==="x"&&a&&d){let p=g(v.x,"x");if(p>0){let h=d==="end"?"start":"end",y=_(l,h);if(g(y.x,"x")<p)d=h,v=y}}if(a){let{size:p,start:h,end:y}=x[u];v[u]=Ae(v[u],p,h,y,o)}let H=Se(b.x+b.width/2,v.x,S.width),Y=Se(b.y+b.height/2,v.y,S.height),z=`${pt(b,l,E,n,o)}px`,{style:V}=t,q=V.getPropertyValue("--available-height")!==z,N=i.coordinateSpace==="document"?e.ownerDocument.defaultView:null,Q=N?N.scrollX:0,D=N?N.scrollY:0;V.left=`${v.x+Q}px`,V.top=`${v.y+D}px`,V.setProperty("--arrow-x",`${H}%`),V.setProperty("--arrow-y",`${Y}%`),V.setProperty("--available-height",z);let k=d?`${l}-${d}`:l;return t.dataset.placement=k,{width:S.width,height:S.height,roomChanged:q,placement:k}}function Re(e,t,i={}){let s=$e(e,t,i);if(!s)return!1;if(s.roomChanged){let n=Ie(t);if(n.width!==s.width||n.height!==s.height)$e(e,t,{...i,placement:s.placement,flip:!1})}return!0}class J{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=X(t.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._originalName=e.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null}setLocale(e){this.adapter=X(e||"")}setMessages(e){this.messages=e||{}}format(e){return this.adapter.format(e)}parse(e){return this.adapter.parse(e)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let e=this.input;this._originalName=e.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(e,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let e=this.input,t=e.getAttribute("name")||"";if(t){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,e.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=t;e.removeAttribute("name")}if(this.hidden){if(e.hasAttribute("form"))this.hidden.setAttribute("form",e.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=e.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let e=this.input,t=e.value.trim(),i=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),t===i){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;e.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!t){e.setCustomValidity("");return}e.setCustomValidity(t===i?"":this.messages.invalidDate)}async commit(){let e=this.input,t=++this._commitId,i=e.value.trim();if(!i){if(t!==this._commitId)return{status:"stale"};return e.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(i);if(!s){if(t!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let n=await this.confirm(s);if(t!==this._commitId)return{status:"stale"};if(!n?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(n?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:s}}setCanonical(e,t={}){let i=e||"";if(i&&!c(i))throw TypeError(`Invalid date-picker value: ${i}`);if(this.dirty(),this.canonical=i,this._dirty=!1,this.hidden)this.hidden.value=i;if(t.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let e=String(this.input.defaultValue??"").trim(),t=c(e)?e:this.adapter.parse(e);return t&&c(t)?t:""}teardown(){this._attributeObserver?.disconnect(),this._attributeObserver=null;let e=this.hidden?.getAttribute("name")||this._originalName;if(e)this.input.setAttribute("name",e);this.hidden?.remove(),this.hidden=null}}var yt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function le(e){let t=yt.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=t[3]===void 0?0:Number(t[3]),r=t[4]===void 0?0:Number(t[4].padEnd(3,"0"));if(i>23||s>59||n>59||r>999)return null;return{hour:i,minute:s,second:n,millisecond:r}}function ce(e){return le(e)!==null}function ze(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function Ve(e,t){let i=le(e),s=le(t);if(!i||!s)throw TypeError("compareTimes() expects HH:MM values");let n=ze(i)-ze(s);return n===0?0:n<0?-1:1}var bt=0;class ue extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];constructor(){super();this._id=`date-picker-${++bt}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=W(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let e=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(e instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=e,this._discoverTimeFields(),this._field=new J(e,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(s)=>this._confirmDate(s),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let t=this._adapter(),i=this.getAttribute("value")||(c(e.value)?e.value:t.parse(e.value));if(i&&c(i))this._setValue(i,{emit:!1,format:!0});else if(!e.value)this._setValue("",{emit:!1,format:!1});else e.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}_discoverTimeFields(){this._timeFields=[null,null];let e=["data-time-start","data-time-end"];for(let[t,i]of e.entries()){let s=this.querySelectorAll(`:scope > input[${i}]`);if(s.length>1)console.warn(`<date-picker> expects at most one direct child input[${i}]; ignoring extras`);let n=s[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${i}] must be an <input type="time">; ignoring it`);continue}this._timeFields[t]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let e=this.querySelector(":scope > input[data-range-start]"),t=this.querySelector(":scope > input[data-range-end]");if(!(e instanceof HTMLInputElement)||!(t instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new J(e,{messages:this._messages,locale:this.locale}),new J(t,{messages:this._messages,locale:this.locale})],this._range=new oe,this._rangeOriginalDescribedBy=[e.getAttribute("aria-describedby")||"",t.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a)=>this._confirmDate(a),r.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),s=c(e.value)?e.value:i.parse(e.value),n=c(t.value)?t.value:i.parse(t.value);if(this._setRange(s||"",n||"",{emit:!1}),e.value.trim()&&!c(s))e.setCustomValidity(this._messages.invalidDate);if(t.value.trim()&&!c(n))t.setCustomValidity(this._messages.invalidDate);if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let e of this._fields||[])this._teardownField(e);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null;for(let{button:e}of this._buttons)e.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(e){if(!e)return;let t=e.input,i=this._fields?.includes(e)?this._rangeOriginalDescribedBy[this._fields?.indexOf(e)??0]||"":this._originalDescribedBy;if(e.teardown(),i)t.setAttribute("aria-describedby",i);else t.removeAttribute("aria-describedby");t.removeAttribute("role"),t.removeAttribute("aria-haspopup"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls")}attributeChangedCallback(e,t,i){if(!this._connected||this._reflecting||t===i)return;if(e==="value"){if(this._rangeMode())return;if(!i||c(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(e==="locale")this._refreshLocale();if(e==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(e){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);this._setValue(e||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(e){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:t,end:i}=ne(e);this._setRange(t,i)}get locale(){return R(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(e){if(e===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get messages(){return this._messages}set messages(e){if(this._messages={...W(),...e||{}},this._calendar)this._calendar.messages=this._messages;for(let t of this._fields||[])t.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(e){if(this._source=e||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(e){this._coordinateSpace=e==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??X(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let e=this._input;if(!e)return;this._field?.syncInputState();let t=this._buttons[0]?.button;if(t)t.disabled=e.disabled||e.readOnly;if(this._open&&(e.disabled||e.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let t of this._fields)t.syncInputState();for(let{button:t,endpoint:i}of this._buttons){let s=i==="end"?1:0,n=this._fields[s];t.disabled=Boolean(n?.input.disabled||n?.input.readOnly)}let e=this._range?.activeEndpoint==="end"?1:0;if(this._open&&(this._fields[e]?.input.disabled||this._fields[e]?.input.readOnly))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let e of this._fields){let t=e.input,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(e)],this._formatHint.id].filter(Boolean).join(" ");t.setAttribute("aria-describedby",i),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",this._panel.id)}}_createTrigger(e){let t=document.createElement("button");if(t.type="button",t.className="dp-picker-button",t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",`${this._id}-panel`),e)t.dataset.endpoint=e;return t.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>',t}_build(){let e=this._rangeMode(),t=[];if(e)for(let[o,l]of(this._fields||[]).entries())t.push([l.input,o===1?"end":"start"]);else if(this._input)t.push([this._input,""]);if(!t.length)return;let i=`${this._id}-panel`,s=`${this._id}-format`;this._buttons=t.map(([o,l])=>{let d=this._createTrigger(l);return o.insertAdjacentElement("afterend",d),{button:d,endpoint:l}});let n=document.createElement("div");n.id=i,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this._messages.calendar);let r=new Z;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=s,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!e&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,s].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let e=this._input,t=this._buttons[0]?.button,i=this._calendar;if(!e||!t||!i)return;let s=new AbortController;this._controller=s;let{signal:n}=s;e.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),e.addEventListener("change",()=>void this._commitText(!1),{signal:n}),e.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),e.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),e.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}t.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show({returnFocus:t})},{signal:n}),t.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),i.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(this._input?.disabled||this._input?.readOnly)return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:n}),this.ownerDocument.addEventListener("reset",(r)=>{let a=r.target;if(a instanceof HTMLFormElement&&this._input&&a===this._input.form)this.hide(!1),queueMicrotask(()=>{if(!r.defaultPrevented)this._restoreDefault()})},{capture:!0,signal:n}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:n})}_bindRange(){let e=this._calendar;if(!this._fields||!this._buttons.length||!e)return;let t=new AbortController;this._controller=t;let{signal:i}=t;for(let[s,n]of this._fields.entries()){let r=s===1?"end":"start";n.input.addEventListener("input",()=>n.handleInput(),{signal:i}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:i}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:i}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:i}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:i})}for(let s of this._buttons){let n=s.endpoint;if(n==="")continue;s.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:i}),s.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:i})}e.addEventListener("click",(s)=>this._captureGridIntent(s),{capture:!0,signal:i}),e.addEventListener("keydown",(s)=>this._captureGridIntent(s),{capture:!0,signal:i}),e.addEventListener("dateactivate",(s)=>{let n=s,r=n.detail?.date;if(!c(r))return;queueMicrotask(()=>{if(n.defaultPrevented||!this._connected||!this._range)return;let a=this._pendingIntents.get(r);if(a===void 0||a!==this._rangeCommitId)return;this._pendingIntents.delete(r);let o=this._range.activate(r,(l)=>{let d=l==="end"?1:0,u=this._fields?.[d];return u!=null&&!u.input.disabled&&!u.input.readOnly});if(o.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._setBound(o.endpoint,r,{emit:!0,user:!0}),o.close||o.status==="complete")this.hide(!1),this._focusField(o.endpoint)})},{signal:i}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:i}),this.ownerDocument.addEventListener("pointerdown",(s)=>{if(!this._open||s.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:i}),this.ownerDocument.addEventListener("reset",(s)=>{let n=s.target;if(n instanceof HTMLFormElement&&this._fields&&n===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!s.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:i}),this.addEventListener("keydown",(s)=>this._onEscape(s),{signal:i})}_activateRangeEndpoint(e){let t=this._calendar;if(!this._range||!t)return;this._range.focus(e),this._rangeCommitId++,this._pendingIntents.clear(),this._lastFocusEndpoint=e;let i=this._boundCanonical(e)||O();t.display=f(i),t.focusedDate=i}_onRangeTriggerClick(e,t){if(!this._open){this.show({endpoint:e});return}if(t.detail===0){this._activateRangeEndpoint(e),setTimeout(()=>this._calendar?.focusGrid(),0);return}if(e!==this._range?.activeEndpoint){this._activateRangeEndpoint(e);return}this.hide(!1)}_onTriggerKeyDown(e,t){if(t.key!=="ArrowDown")return;if(t.preventDefault(),this._open){if(this._rangeMode()&&e)this._activateRangeEndpoint(e);setTimeout(()=>this._calendar?.focusGrid(),0);return}if(this._rangeMode())this.show({endpoint:e||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(e,t){if(t.key==="ArrowDown"){if(t.preventDefault(),this._rangeMode()&&e)this._lastFocusEndpoint=e,this._range?.focus(e);if(this._open)setTimeout(()=>this._calendar?.focusGrid(),0);else this.show()}else if(t.key==="Escape"&&this._open)t.preventDefault(),this.hide(!1)}_onFieldFocus(e,t){if(!this._rangeMode()||!e)return;let i=e!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=e,this._range?.focus(e),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let s=t.relatedTarget;if(s instanceof Node&&this.contains(s))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(e){if(!this._rangeMode()||!this._range)return;if(e.type==="keydown"){let s=e.key;if(s!=="Enter"&&s!==" ")return}if(!(e.target instanceof Element))return;let i=e.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(i))return;this._pendingIntents.clear(),this._pendingIntents.set(i,++this._rangeCommitId)}_onEscape(e){if(e.key==="Escape"&&this._open)e.preventDefault(),e.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let e=this._calendar,t=this._panel;if(!e)return;if(e.locale=this.locale,e.min=this.min,e.max=this.max,e.monthFormat=this.monthFormat,e.messages=this._messages,e.source=this._source,e.dateState=this._dateState,e.renderDay=this._renderDay,e.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)e.value=this._value;if(t)t.setAttribute("aria-label",this._messages.calendar)}_refreshLocale(){let e=this._formatHint;if(!e)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${this._fields[0].placeholder}`;for(let[i,s]of this._fields.entries()){if(!s.input.hasAttribute("placeholder")||this._generatedPlaceholder)s.input.placeholder=s.placeholder,this._generatedPlaceholder=!0;let n=i===1?this._range?.end||"":this._range?.start||"";if(n)s.input.value=s.format(n)}this._refreshButtonLabel();return}let t=this._field;if(!t)return;if(t.setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${t.placeholder}`,!t.input.hasAttribute("placeholder")||this._generatedPlaceholder)t.input.placeholder=t.placeholder,this._generatedPlaceholder=!0;if(this._value)t.input.value=t.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let e=this._buttons[0]?.button;if(!e)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let t=this._value?this._messages.changeDate:this._messages.chooseDate,i=this._value?`, ${G(this._value,this.locale)}`:"";e.setAttribute("aria-label",`${t}${i}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:e,end:t}=this._range;for(let{button:i,endpoint:s}of this._buttons){let n=s==="end"?t:e,r=n?this._messages.changeDate:this._messages.chooseDate,a=n?`, ${G(n,this.locale)}`:"",o=s==="end"?this._messages.rangeEnd:this._messages.rangeStart;i.setAttribute("aria-label",`${r}${a}, ${o}`)}}_reflectValue(e){if(this._reflecting=!0,e)this.setAttribute("value",e);else this.removeAttribute("value");this._reflecting=!1}_setValue(e,t={}){if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);let i=this._value;if(this._value=e||"",t.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:t.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),t.emit&&this._field){let s=this._field.input;s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(e){let t=this._calendar;if(!t)return{ok:!0};let i=f(e);if(t.display!==i)t.display=i;let s=await t.ensureDate(e),n=t.getDateState(e);if(!s||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(e,t={}){let i=this._field;if(!i)return!1;if(!t.force&&!i.isDirty)return!1;let s=await i.commit();if(s.status==="stale"||s.status==="invalid")return!1;return this._setValue(s.value||"",{emit:e,format:s.status==="ok"}),!0}async _commitFieldText(e){let t=this._fields;if(!t)return!1;let i=e==="end"?1:0,s=t[i];if(!s?.isDirty)return!1;let n=await s.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(e,n.value||"",{emit:!1,user:!0,format:n.status==="ok"}),!0}_setBound(e,t,i={}){if(!this._range)return!1;let s=this._fields;if(!s)return!1;let r=s[e==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=t||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),e==="end")this._range.end=a;else this._range.start=a;let l=o!==a;if(l){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),i.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(e),l}_setRange(e,t,i={}){if(!this._range||!this._fields)return;if(this._range.start=e||"",this._range.end=t||"",this._fields[0].setCanonical(e||"",{format:i.format!==!1}),this._fields[1].setCanonical(t||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(e){return this._range?e==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_syncHighlight(){if(!this._calendar||!this._range)return;let{start:e,end:t}=this._range;if(!e){this._calendar.highlightedRange={start:"",end:""};return}if(t&&w(t,e)<0)this._calendar.highlightedRange={start:e,end:""};else this._calendar.highlightedRange={start:e,end:t}}_revalidateRange(e){if(!this._fields||!this._range)return;let{start:t,end:i}=this._range,s=Boolean(t&&i&&w(i,t)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,l=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(s&&r===e)o.setCustomValidity(l),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(e){let[t,i]=this._timeFields,s=["start","end"],n=[t,i],r=t&&!t.disabled?t.value.trim():"",a=i&&!i.disabled?i.value.trim():"",o=Boolean(t&&i&&r&&a)&&ce(r)&&ce(a)&&Ve(a,r)<0;for(let[l,d]of s.entries()){let u=n[l];if(!u)continue;let C=d==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(o&&d===e)u.setCustomValidity(C),this._timeOrderOwned.add(u);else if(this._timeOrderOwned.has(u))u.setCustomValidity(""),this._timeOrderOwned.delete(u)}}_clearTimeOrderValidity(){for(let e of this._timeOrderOwned)e.setCustomValidity("");this._timeOrderOwned.clear()}_restoreDefault(){let e=this._field;if(!e)return;let t=e.restoreDefault();if(this._setValue(t,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=f(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=f(O()),this._calendar.focusedDate=O();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let e=this._fields[0].restoreDefault(),t=this._fields[1].restoreDefault();if(this._setRange(e,t),this._calendar){let i=this._range?.start||O();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(e){let t=e==="end"?1:0,i=this._fields?.[t]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_restoreFocus(){let e=this._returnFocus;if(this._returnFocus=null,!(e instanceof HTMLElement)||!e.isConnected||e.matches(":disabled"))return;this._suppressFocusOpen=!0,setTimeout(()=>{e.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let e=this._lastFocusEndpoint||"start",t=e==="end"?1:0;if(!this._fields[t].input.disabled&&!this._fields[t].input.readOnly)return e;let i=e==="end"?"start":"end",s=i==="end"?1:0;if(!this._fields[s].input.disabled&&!this._fields[s].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[s,n]of i.entries()){let r=await n.commit();if(r.status==="ok"||r.status==="clear"){let a=s===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((s)=>s.input.checkValidity())}let e=this._field?.input;if(!e)return!0;if(!e.value.trim())e.setCustomValidity("");else await this._commitText(!1,{force:!0});this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let t=this._timeFields.every((i)=>i?.checkValidity()??!0);return e.checkValidity()&&t}show(e={}){let t=this._panel,i=this._calendar;if(!t||!i||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=e.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||O();i.display=f(a),i.focusedDate=a,this._returnFocus=e.returnFocus instanceof HTMLElement?e.returnFocus:r}t.showPopover(),this._open=!0,this._setExpanded(!0);let s=this.coordinateSpace;t.style.position=s==="document"?"absolute":"fixed";let n=()=>Re(this,t,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:s});if(n(),this._stopTracking=Oe(this,t,n),e.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(e){let t=e?"true":"false";this._input?.setAttribute("aria-expanded",t);for(let{button:i}of this._buttons)i.setAttribute("aria-expanded",t);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",t)}hide(e=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),e)if(this._rangeMode()){let t=this._restoreFocusEndpoint();if(t)this._focusField(t)}else this._restoreFocus();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let e=this._range?.activeEndpoint||"";if(e){let t=e==="end"?1:0,i=this._fields?.[t];if(i&&!i.input.disabled&&!i.input.readOnly)return e}return this._resolveRangeEndpoint()}}function he(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",Z);if(!customElements.get("date-picker"))customElements.define("date-picker",ue)}he();var He="lekoala-date-picker-styles";if(!document.getElementById(He)){let e=document.createElement("style");e.id=He,e.textContent=ge,document.head.append(e)}he();})();