@lekoala/date-picker 0.2.0 → 0.4.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,18 +1,21 @@
1
- /*** @lekoala/date-picker v0.2.0 - https://github.com/lekoala/date-picker ***/
2
- (()=>{var fe=`: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.4.0 - https://github.com/lekoala/date-picker ***/
2
+ (()=>{var be=`: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
+ --dp-focus: var(--dp-accent);
11
+ --dp-focus-width: 2px;
10
12
  --dp-radius: 0.5rem;
11
13
  --dp-day-size: 2.75rem;
12
- --dp-gap: 0.25rem;
14
+ --dp-gap: 0.375rem;
13
15
  --dp-header-control-size: 2.25rem;
14
- --dp-header-block-gap: 0.4rem;
15
- --dp-nav-gap: calc(var(--dp-gap) * 2.5);
16
+ --dp-header-block-gap: 0.75rem;
17
+ --dp-row-gap: 0.375rem;
18
+ --dp-picker-button-size: 2.5rem;
16
19
  --dp-year-inline-size: 5.5rem;
17
20
  --dp-day-radius: calc(var(--dp-radius) * 0.75);
18
21
  color: var(--dp-fg);
@@ -49,6 +52,9 @@ date-calendar {
49
52
  --dp-header-control-size, the row grows to the tallest control and the
50
53
  others stretch to match, so month/year/nav stay equal. */
51
54
  align-items: stretch;
55
+ /* Uniform horizontal rhythm: the four header controls are self-evident from
56
+ their kind and position, so no group gets an extra semantic gap. The air
57
+ belongs to the vertical zones (header -> weekdays -> dates). */
52
58
  gap: var(--dp-gap);
53
59
  margin-block-end: var(--dp-header-block-gap);
54
60
  }
@@ -60,10 +66,6 @@ date-calendar[data-year-first] .dp-calendar-header {
60
66
  grid-template-columns: auto minmax(0, 1fr) auto auto;
61
67
  }
62
68
 
63
- .dp-calendar-header .dp-prev {
64
- margin-inline-start: var(--dp-nav-gap);
65
- }
66
-
67
69
  .dp-calendar-header :where(button, select, input) {
68
70
  min-block-size: var(--dp-header-control-size);
69
71
  box-sizing: border-box;
@@ -79,26 +81,42 @@ date-calendar[data-year-first] .dp-calendar-header {
79
81
  line-height: 1.2;
80
82
  }
81
83
 
82
- /* The select menulist carries UA-internal leading that author padding only
83
- adds to (and it ignores line-height), so it gets zero author padding.
84
- Equal outer heights come from the header grid's stretch alignment: the row
85
- sizes to the tallest control and the others stretch to match. */
86
- .dp-calendar-header select {
87
- padding-block: 0;
88
- }
89
-
90
- .dp-calendar-header select,
91
84
  .dp-calendar-header input {
92
85
  min-inline-size: 0;
93
86
  padding-inline: 0.45rem;
94
87
  }
95
88
 
89
+ /* Author-drawn caret so the month select matches the nav controls without a
90
+ hardcoded SVG color (currentColor keeps theming). Equal outer heights come
91
+ from the header grid's stretch alignment: the row sizes to the tallest
92
+ control and the others stretch to match. */
96
93
  .dp-month-select {
97
94
  inline-size: 100%;
95
+ min-inline-size: 0;
98
96
  /* Long month names in a narrow track (compact consumers, long locales)
99
- would paint under the native caret: truncate with an ellipsis instead. */
97
+ would paint under the caret: truncate with an ellipsis instead. */
100
98
  overflow: hidden;
101
99
  text-overflow: ellipsis;
100
+ appearance: none;
101
+ padding-inline: 0.45rem 2rem;
102
+ background-image:
103
+ linear-gradient(45deg, transparent 50%, currentColor 50%),
104
+ linear-gradient(135deg, currentColor 50%, transparent 50%);
105
+ background-position:
106
+ calc(100% - 0.9rem) 50%,
107
+ calc(100% - 0.65rem) 50%;
108
+ background-size: 0.3rem 0.3rem;
109
+ background-repeat: no-repeat;
110
+ }
111
+
112
+ /* Inherited RTL mirrors the header layout via the grid. The logical
113
+ \`padding-inline\` already flips, so only the physically-positioned caret has
114
+ to follow it to the other side. */
115
+ [dir="rtl"] .dp-month-select,
116
+ html[dir="rtl"] .dp-month-select {
117
+ background-position:
118
+ 0.9rem 50%,
119
+ 0.65rem 50%;
102
120
  }
103
121
 
104
122
  .dp-year-input {
@@ -122,14 +140,6 @@ date-calendar[data-year-first] .dp-calendar-header {
122
140
  pointer-events: none;
123
141
  }
124
142
 
125
- /* Inherited RTL mirrors the header layout via the grid; mirror the nav glyphs
126
- so previous/next keep their visual sense. Actions stay chronological: no
127
- button swap, no keyboard remapping. */
128
- [dir="rtl"] .dp-nav svg,
129
- html[dir="rtl"] .dp-nav svg {
130
- transform: scaleX(-1);
131
- }
132
-
133
143
  .dp-calendar-header :where(button, select, input):disabled,
134
144
  .dp-picker-button:disabled {
135
145
  cursor: not-allowed;
@@ -140,6 +150,15 @@ html[dir="rtl"] .dp-nav svg {
140
150
  background: var(--dp-hover);
141
151
  }
142
152
 
153
+ /* Inner outlines survive forced colors and keep focus inside each control.
154
+ The picker trigger uses a tighter inset around its icon below. */
155
+ .dp-calendar-header :where(button, select, input):focus-visible,
156
+ date-picker > input:not([type="hidden"]):focus-visible,
157
+ .dp-day:focus-visible {
158
+ outline: var(--dp-focus-width) solid var(--dp-focus);
159
+ outline-offset: calc(var(--dp-focus-width) * -1);
160
+ }
161
+
143
162
  .dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not(
144
163
  [data-range-end="true"]
145
164
  ) {
@@ -152,8 +171,8 @@ html[dir="rtl"] .dp-nav svg {
152
171
 
153
172
  .dp-grid {
154
173
  border-collapse: separate;
155
- /* --dp-gap scopes to the header grid; day-cell spacing stays fixed. */
156
- border-spacing: 0 0.25rem;
174
+ /* --dp-gap scopes to the header grid; vertical week rhythm is --dp-row-gap. */
175
+ border-spacing: 0 var(--dp-row-gap);
157
176
  table-layout: fixed;
158
177
  }
159
178
 
@@ -166,10 +185,10 @@ html[dir="rtl"] .dp-nav svg {
166
185
  }
167
186
 
168
187
  .dp-grid thead th {
169
- block-size: 1.6rem;
188
+ block-size: 1.5rem;
170
189
  color: var(--dp-muted);
171
190
  font-size: 0.72rem;
172
- font-weight: 600;
191
+ font-weight: 500;
173
192
  }
174
193
 
175
194
  .dp-day {
@@ -182,14 +201,9 @@ html[dir="rtl"] .dp-nav svg {
182
201
  font-size: 0.875rem;
183
202
  }
184
203
 
185
- .dp-day:focus-visible {
186
- outline: 2px solid var(--dp-accent);
187
- outline-offset: 2px;
188
- /* Separation gap between the cell fill and the ring: invisible on plain
189
- days, but keeps the ring readable on accent-filled days (selected, range
190
- endpoints) where an accent-on-accent outline would disappear. */
191
- box-shadow: 0 0 0 2px var(--dp-bg);
192
- z-index: 1;
204
+ /* On an accent-filled cell the ring inverts so it stays readable. */
205
+ .dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]):focus-visible {
206
+ outline-color: var(--dp-accent-fg);
193
207
  }
194
208
 
195
209
  /* Base tint for days outside the displayed month. It stays before the
@@ -204,7 +218,10 @@ html[dir="rtl"] .dp-nav svg {
204
218
  color: var(--dp-accent-fg);
205
219
  }
206
220
 
207
- .dp-day[data-today="true"]:not([data-selected="true"]) {
221
+ /* Today never competes with a stronger state: a selected day or a range
222
+ endpoint keeps its own treatment, in normal rendering and in
223
+ forced-colors alike. */
224
+ .dp-day[data-today="true"]:not([data-selected="true"], [data-range-start="true"], [data-range-end="true"]) {
208
225
  border-color: var(--dp-accent);
209
226
  }
210
227
 
@@ -236,13 +253,35 @@ html[dir="rtl"] .dp-nav svg {
236
253
  }
237
254
 
238
255
  .dp-day[data-in-range="true"]:first-of-type {
239
- border-start-start-radius: var(--dp-radius);
240
- border-end-start-radius: var(--dp-radius);
256
+ border-start-start-radius: var(--dp-day-radius);
257
+ border-end-start-radius: var(--dp-day-radius);
241
258
  }
242
259
 
243
260
  .dp-day[data-in-range="true"]:last-of-type {
244
- border-start-end-radius: var(--dp-radius);
245
- border-end-end-radius: var(--dp-radius);
261
+ border-start-end-radius: var(--dp-day-radius);
262
+ border-end-end-radius: var(--dp-day-radius);
263
+ }
264
+
265
+ /* Projected band: the range the next commit would produce. It reads as one
266
+ step short of the committed band, so a hovered, keyboard or dragged preview
267
+ is never mistaken for the selection itself. */
268
+ [data-range-preview] .dp-day:is([data-range-start="true"], [data-range-end="true"]) {
269
+ background: color-mix(in srgb, var(--dp-accent) 58%, var(--dp-bg));
270
+ }
271
+
272
+ [data-range-preview] .dp-day[data-in-range="true"] {
273
+ background: color-mix(in srgb, var(--dp-accent) 11%, var(--dp-bg));
274
+ }
275
+
276
+ /* Endpoint handles are draggable only while the committed range is complete
277
+ and its two ends sit on different days. */
278
+ [data-range-drag] .dp-day:is([data-range-start="true"], [data-range-end="true"]) {
279
+ cursor: grab;
280
+ }
281
+
282
+ [data-range-drag="active"],
283
+ [data-range-drag="active"] .dp-day {
284
+ cursor: grabbing;
246
285
  }
247
286
 
248
287
  .dp-day-number {
@@ -285,97 +324,117 @@ html[dir="rtl"] .dp-nav svg {
285
324
  date-picker {
286
325
  position: relative;
287
326
  display: inline-grid;
288
- grid-template-columns: minmax(0, 1fr) auto;
327
+ grid-template-columns: minmax(0, 1fr);
289
328
  align-items: stretch;
290
329
  max-inline-size: 100%;
291
330
  }
292
331
 
332
+ /* Every authored control is a grid item. */
293
333
  date-picker > input:not([type="hidden"]) {
334
+ min-inline-size: 0;
335
+ }
336
+
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"]) {
294
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);
295
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: var(--dp-focus-width) solid var(--dp-focus);
373
+ outline-offset: -5px;
374
+ border-radius: var(--dp-radius);
296
375
  }
297
376
 
298
377
  /* Optional native time companions share the date row; authored inputs stay
299
378
  consumer-styled, the picker only reserves their grid cells. Time tracks are
300
- flexible (never \`auto\`) so a wide UA time control cannot squeeze the date. */
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. */
301
382
  date-picker:has(> [data-time-start], > [data-time-end]) {
302
- grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
383
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
384
+ column-gap: var(--dp-gap);
303
385
  }
304
386
 
305
387
  date-picker:has(> [data-time-start]):has(> [data-time-end]) {
306
- grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr);
388
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
307
389
  }
308
390
 
309
391
  date-picker > input[data-time-start] {
310
- grid-column: 3;
392
+ grid-column: 2;
311
393
  grid-row: 1;
312
394
  min-inline-size: 0;
313
- inline-size: 100%;
314
- margin-inline-start: var(--dp-gap);
315
395
  }
316
396
 
317
397
  date-picker > input[data-time-end] {
318
- grid-column: 4;
398
+ grid-column: 3;
319
399
  grid-row: 1;
320
400
  min-inline-size: 0;
321
- inline-size: 100%;
322
401
  }
323
402
 
324
- /* From/to read as one joined control: square the inner corners, but only
325
- when both companions are present so a lone time keeps its own radius. */
326
- date-picker:has(> [data-time-start]):has(> [data-time-end]) > input[data-time-start] {
327
- border-start-end-radius: 0;
328
- border-end-end-radius: 0;
329
- }
330
-
331
- date-picker:has(> [data-time-start]):has(> [data-time-end]) > input[data-time-end] {
332
- border-start-start-radius: 0;
333
- border-end-start-radius: 0;
334
- }
335
-
336
- date-picker[range] > input:not([type="hidden"]) {
337
- grid-column: 1;
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);
338
408
  }
339
409
 
340
410
  date-picker[range] > input[data-range-start] {
341
411
  grid-row: 1;
342
- border-end-start-radius: 0;
343
412
  }
344
413
 
345
414
  date-picker[range] > input[data-range-end] {
346
415
  grid-row: 2;
347
- border-start-start-radius: 0;
348
416
  }
349
417
 
350
- .dp-picker-button {
351
- grid-column: 2;
352
- min-inline-size: 2.5rem;
353
- border: 1px solid var(--dp-border);
354
- border-inline-start: 0;
355
- border-start-start-radius: 0;
356
- border-end-start-radius: 0;
357
- border-start-end-radius: var(--dp-radius);
358
- border-end-end-radius: var(--dp-radius);
359
- background: var(--dp-bg);
360
- color: var(--dp-fg);
361
- font: inherit;
362
- cursor: pointer;
418
+ date-picker[range] > .dp-picker-button[data-endpoint="start"] {
419
+ grid-row: 1;
363
420
  }
364
421
 
365
- date-picker[range] > .dp-picker-button {
366
- grid-row: 1 / span 2;
422
+ date-picker[range] > .dp-picker-button[data-endpoint="end"] {
423
+ grid-row: 2;
367
424
  }
368
425
 
369
426
  .dp-picker-panel[popover] {
427
+ /* Safe baseline. show() switches to absolute only when the consumer
428
+ * explicitly selects document coordinate space. */
370
429
  position: fixed;
371
430
  inset: auto;
372
431
  margin: 0;
373
- padding: 0.65rem;
432
+ padding: 0.875rem 1rem;
374
433
  border: 1px solid var(--dp-border);
375
434
  border-radius: var(--dp-radius);
376
435
  background: var(--dp-bg);
377
436
  color: var(--dp-fg);
378
- 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);
379
438
  max-block-size: var(--available-height, 90svh);
380
439
  max-inline-size: calc(100vi - 1rem);
381
440
  overflow: auto;
@@ -386,19 +445,22 @@ date-picker[range] > .dp-picker-button {
386
445
  }
387
446
 
388
447
  @media (forced-colors: active) {
389
- .dp-day[data-selected="true"] {
390
- border: 2px solid Highlight;
391
- background-color: Canvas;
392
- color: CanvasText;
393
- 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;
394
455
  }
395
456
 
396
- .dp-day[data-range-start="true"],
397
- .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"]) {
398
461
  border: 2px solid Highlight;
399
462
  background-color: Canvas;
400
463
  color: CanvasText;
401
- font-weight: 700;
402
464
  }
403
465
 
404
466
  .dp-day[data-in-range="true"] {
@@ -414,15 +476,8 @@ date-picker[range] > .dp-picker-button {
414
476
  background-color: Highlight;
415
477
  }
416
478
 
417
- .dp-day[data-selected="true"]::before {
418
- content: "";
419
- position: absolute;
420
- inset: 3px;
421
- border: 1px solid CanvasText;
422
- border-radius: calc(var(--dp-radius) * 0.5);
423
- pointer-events: none;
424
- }
425
-
479
+ /* Pin the today marker: the deterministic accent is a non-system color
480
+ and would otherwise remap unpredictably here. */
426
481
  .dp-day[data-today="true"] {
427
482
  border-color: Highlight;
428
483
  }
@@ -431,27 +486,20 @@ date-picker[range] > .dp-picker-button {
431
486
  color: CanvasText;
432
487
  forced-color-adjust: none;
433
488
  }
434
-
435
- .dp-day[data-disabled="true"],
436
- .dp-calendar-header :where(button, select, input):disabled,
437
- .dp-picker-button:disabled {
438
- opacity: 1;
439
- color: GrayText;
440
- }
441
489
  }
442
- `;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 X(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>X(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 P(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 J(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 P(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}function V(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return J(t)}function D(e,t){if(!c(e)||!c(t))throw TypeError("compareDates() expects YYYY-MM-DD values");return e===t?0:e<t?-1:1}function F(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let s=J(i);return s.setUTCDate(s.getUTCDate()+t),qe(s)}function Q(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,X(n,a));return P(n,a,o)}function pe(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,X(s,i.month));return P(s,i.month,n)}function B(e,t){let i=`${f(e)}-01`;return f(Q(i,t))}function je(e){return`${f(e)}-01`}function Ke(e){let t=I(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return P(t.year,t.month,X(t.year,t.month))}function Ge(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return J(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 ee(e,t=1){let i=(Ge(e)-j(t)+7)%7;return F(e,-i)}function ie(e,t=1){return F(ee(e,t),6)}function me(e,t={}){let i=t.firstDay??1,s=ee(je(e),i),n=ie(Ke(e),i),r=[],a=s;while(D(a,n)<=0){let o=[];for(let l=0;l<7;l++)o.push(F(a,l));r.push(o),a=F(a,7)}return r}function ge(e,t="",i=""){if(!c(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&D(e,t)<0)return t;if(i&&D(e,i)>0)return i;return e}function L(){let e=new Date;return P(e.getFullYear(),e.getMonth()+1,e.getDate())}function _e(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let i=J(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 se{constructor(e={}){let t=L();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=Q(`${t}-01`,0),n=F(s,Math.max(0,i-1));return this.focused=f(n)===t?n:F(`${B(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(F(this.focused,e))}moveFocusMonths(e){return this.setFocused(Q(this.focused,e))}moveFocusYears(e){return this.setFocused(pe(this.focused,e))}focusWeekStart(){return this.setFocused(ee(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(ie(this.focused,this.firstDay))}navigateMonth(e){let t=B(this.display,e);return this.setDisplay(t),this.display}}function te(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&&D(i,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:i}}function ye(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&&D(e,i)>=0&&D(e,s)<=0)return"in";return""}class ne{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&D(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&&(D(e,this.start)<0||D(e,this.end)>0)){let i=D(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&&D(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 ve=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function O(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 Ze(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 be(e,t){let i=String(e||"").replace(ve,"").trim();for(let[s,n]of Ze(t))i=i.split(s).join(n);return i}function U(e,t=""){let i=O(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(V(e))}function we(e,t=""){let i=O(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(V(`${e.slice(0,7)}-15`))}function xe(e=""){let t=O(e);try{let i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(V("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 De(e="",t="long"){let i=O(e),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(V(`2026-${String(r+1).padStart(2,"0")}-15`)))}function re(e="",t=1,i="short"){let s=O(e),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=j(t),a=V("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 Xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(e=""){let t=O(e),i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=V("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(ve,"")}).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=be(d.value,t).replace(/\s+/g," ");return Xe(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(V(d))},parse(d){let u=be(d,t);if(c(u))return u;let k=l.exec(u);if(!k)return"";let g={};if(r.forEach((b,C)=>{g[b]=Number(k[C+1])}),!g.year||!g.month||!g.day)return"";try{return P(g.year,g.month,g.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 Y(){return{...Qe}}function Ee(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 T(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 G 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 se,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=Y(),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 O(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=te(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={...Y(),...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 ge(e,this.min,this.max)}_weeks(e=this.display){let t=me(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(F(i,n));t.push(s),i=s[6]}return t}_focusTargetKey(e){if(e.matches(".dp-month-select, .dp-year-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&&D(e,this.min)<0||this.max&&D(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 Ee(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(B(this.display,-1))}nextMonth(){return this._setDisplay(B(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 HTMLSelectElement&&t.matches(".dp-year-select")){this._setDisplay(`${t.value}-${this.display.slice(5,7)}`);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=De(t,this.monthFormat),a=re(t,this.firstDay,"short"),o=re(t,this.firstDay,"long"),l=this._weeks(),d=L(),u=`${this._id}-heading`,k=`${this._id}-grid`,g=this.min?f(this.min):"",b=this.max?f(this.max):"",C=Boolean(g&&B(i,-1)<g),S=Boolean(b&&B(i,1)>b),E=this.min?` min="${Number(this.min.slice(0,4))}"`:"",y=this.max?` max="${Number(this.max.slice(0,4))}"`:"",_=this.showWeekNumbers&&this.firstDay===1,A=_?`<th scope="col" class="dp-week-heading" abbr="${T(this._messages.week)}">#</th>`:"",w=r.map((h,m)=>{let x=m+1,p=`${String(s).padStart(4,"0")}-${String(x).padStart(2,"0")}`,M=g&&p<g||b&&p>b;return`<option value="${String(x).padStart(2,"0")}"${x===n?" selected":""}${M?" disabled":""}>${T(h)}</option>`}).join(""),H=a.map((h,m)=>`<th scope="col" abbr="${T(o[m])}">${T(h.replace(".",""))}</th>`).join(""),N=l.map((h)=>{let m=_?`<th scope="row" class="dp-week-number">${_e(h[0])}</th>`:"",x=h.map((p)=>{let M=this.getDateState(p),ce=f(p)!==i,ze=this.value===p,He=this.focusedDate===p,Ve=p===d,ue=ye(p,this._highlightedRange),he=nt(ue),Be=typeof M.description==="string"?M.description:"",Pe=[U(p,t),Be,he?this._messages[he]:"",M.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${p}"${ce?' data-outside-month="true"':""}${Ve?' data-today="true" aria-current="date"':""}${ze?' data-selected="true" aria-selected="true"':""}${st(ue)}${M.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${He?"0":"-1"}" aria-label="${T(Pe)}"><span class="dp-day-number" aria-hidden="true">${Number(p.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${m}${x}</tr>`}).join(""),R=document.activeElement,z=R instanceof HTMLElement&&this.contains(R)?this._focusTargetKey(R):"",W=xe(t)[0]==="year";this.toggleAttribute("data-year-first",W);let q=`<label class="dp-visually-hidden" for="${this._id}-month">${T(this._messages.month)}</label>
443
- <select id="${this._id}-month" class="dp-month-select" aria-label="${T(this._messages.month)}">${w}</select>`,v=`<label class="dp-visually-hidden" for="${this._id}-year">${T(this._messages.year)}</label>
444
- <input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${s}"${E}${y} aria-label="${T(this._messages.year)}">`;if(this._rendering=!0,this.innerHTML=`
490
+ `;var qe=/^(\d{4})-(\d{2})-(\d{2})$/,Xe=/^(\d{4})-(\d{2})$/;function Ze(e){return e%4===0&&(e%100!==0||e%400===0)}function X(e,t){if(t===2)return Ze(e)?29:28;return[4,6,9,11].includes(t)?30:31}function F(e){let t=qe.exec(String(e||""));if(!t)return null;let i=Number(t[1]),n=Number(t[2]),s=Number(t[3]);if(i<1||i>9999||n<1||n>12)return null;if(s<1||s>X(i,n))return null;return{year:i,month:n,day:s}}function c(e){return F(e)!==null}function f(e){let t=String(e||""),i=Xe.exec(t);if(i){let s=Number(i[2]);if(s>=1&&s<=12)return`${i[1]}-${String(s).padStart(2,"0")}`}let n=F(t);if(!n)throw TypeError(`Invalid civil date/month: ${e}`);return`${String(n.year).padStart(4,"0")}-${String(n.month).padStart(2,"0")}`}function B(e,t,i){let n=`${String(e).padStart(4,"0")}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!c(n))throw TypeError(`Invalid civil date: ${n}`);return n}function z(e){let t=new Date(0);return t.setUTCHours(12,0,0,0),t.setUTCFullYear(e.year,e.month-1,e.day),t}function Je(e){return B(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}function P(e){let t=F(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return z(t)}function _(e,t){if(!c(e)||!c(t))throw TypeError("compareDates() expects YYYY-MM-DD values");return e===t?0:e<t?-1:1}function M(e,t){let i=F(e);if(!i||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let n=z(i);return n.setUTCDate(n.getUTCDate()+t),Je(n)}function ne(e,t){let i=F(e);if(!i||!Number.isInteger(t))throw TypeError("addMonths() expects a date and integer amount");let n=i.year*12+(i.month-1)+t,s=Math.floor(n/12),a=(n%12+12)%12+1,o=Math.min(i.day,X(s,a));return B(s,a,o)}function we(e,t){let i=F(e);if(!i||!Number.isInteger(t))throw TypeError("addYears() expects a date and integer amount");let n=i.year+t,s=Math.min(i.day,X(n,i.month));return B(n,i.month,s)}function q(e,t){let i=`${f(e)}-01`;return f(ne(i,t))}function Qe(e){return`${f(e)}-01`}function oe(e){let t=F(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return B(t.year,t.month,X(t.year,t.month))}function et(e){let t=F(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return z(t).getUTCDay()}function U(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=(et(e)-U(t)+7)%7;return M(e,-i)}function de(e,t=1){return M(se(e,t),6)}function De(e,t={}){let i=t.firstDay??1,n=se(Qe(e),i),s=de(oe(e),i),r=[],a=n;for(;;){let o=[];for(let l=0;l<7;l++)o.push(M(a,l));if(r.push(o),_(o[6],s)>=0)break;a=M(a,7)}return r}function ve(e,t,i){let n=z({year:1,month:1,day:1});return Math.round((z({year:e,month:t,day:i}).getTime()-n.getTime())/86400000)}function Z(e,t=1){let i=U(t),n=ve(9999,12,31),s=f(e);for(;;){let r=F(`${s}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${e}`);let a=ve(r.year,r.month,1),o=(z(r).getUTCDay()-i+7)%7;if(a-o<0){s=q(s,1);continue}let l=X(r.year,r.month),d={year:r.year,month:r.month,day:l},h=a+l-1,E=(z(d).getUTCDay()-i+7)%7;if(h-E+6>n){s=q(s,-1);continue}return s}}function xe(e,t="",i=""){if(!c(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&_(e,t)<0)return t;if(i&&_(e,i)>0)return i;return e}function L(){let e=new Date;return B(e.getFullYear(),e.getMonth()+1,e.getDate())}function Ee(e){let t=F(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let i=z(t),n=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-n);let s=new Date(0);return s.setUTCHours(12,0,0,0),s.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-s.getTime())/86400000+1)/7)}class le{constructor(e={}){let t=L();this.firstDay=U(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,n=ne(`${t}-01`,0),s=M(n,Math.max(0,i-1));return this.focused=f(s)===t?s:M(`${q(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(M(this.focused,e))}moveFocusMonths(e){return this.setFocused(ne(this.focused,e))}moveFocusYears(e){return this.setFocused(we(this.focused,e))}focusWeekStart(){return this.setFocused(se(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(de(this.focused,this.firstDay))}navigateMonth(e){let t=q(this.display,e);return this.setDisplay(t),this.display}}function re(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&&_(i,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:i}}function ce(e,t){if(!t||!c(e))return"";let{start:i,end:n}=t;if(!i||!c(i))return"";if(i===e)return n?n===e?"single":"start":"start";if(n&&n===e)return"end";if(n&&_(e,i)>=0&&_(e,n)<=0)return"in";return""}class he{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&_(this.end,this.start)>=0)}focus(e){this.activeEndpoint=e}_refuse(e){return{status:"refused",endpoint:e,changedEndpoints:[],range:this.range,activeEndpoint:this.activeEndpoint}}project(e,t=()=>!0){if(!c(e))throw TypeError(`Invalid range activation: ${e}`);let{start:i,end:n}=this;if(this.complete&&(_(e,i)<0||_(e,n)>0)){let r=_(e,i)<0?"start":"end";if(!t(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:e,end:n}:{start:i,end:e},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(i&&!n&&_(e,i)<0){if(!t("start"))return this._refuse("start");if(!t("end"))return this._refuse("end");return{status:"complete",endpoint:"end",changedEndpoints:["start","end"],range:{start:e,end:i},activeEndpoint:"end"}}if(i&&_(e,i)<0)return this._refuse("end");if(!t("end"))return this._refuse("end");return{status:i?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:i,end:e},activeEndpoint:"end"}}if(n&&!i&&_(e,n)>0){if(!t("start"))return this._refuse("start");if(!t("end"))return this._refuse("end");return{status:"complete",endpoint:"start",changedEndpoints:["start","end"],range:{start:n,end:e},activeEndpoint:"start"}}if(!t("start"))return this._refuse("start");let s=t("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:e,end:n},activeEndpoint:s?"end":this.activeEndpoint,...s?{}:{close:!0}}}projectEndpoint(e,t,i=()=>!0){if(!c(e))throw TypeError(`Invalid range activation: ${e}`);if(!this.complete||!i(t))return this._refuse(t);let{start:n,end:s}=this,r=t==="start"?n:s,a=t==="start"?it(e,s):tt(e,n);return{status:"complete",endpoint:t,changedEndpoints:a===r?[]:[t],range:t==="start"?{start:a,end:s}:{start:n,end:a},activeEndpoint:t}}previewRange(e,t="",i=()=>!0){if(!c(e))return null;if(!t&&Boolean(this.start)===Boolean(this.end))return null;let n=t?this.projectEndpoint(e,t,i):this.project(e,i);if(n.status==="refused")return null;let{start:s,end:r}=n.range;if(!s||r&&_(r,s)<0)return null;return{start:s,end:r}}_apply(e){if(e.status==="refused")return e;return this.start=e.range.start,this.end=e.range.end,this.activeEndpoint=e.activeEndpoint,e}activate(e,t=()=>!0){return this._apply(this.project(e,t))}moveEndpoint(e,t,i=()=>!0){return this._apply(this.projectEndpoint(e,t,i))}}function tt(e,t){if(!e)return t;if(!t)return e;return _(e,t)>=0?e:t}function it(e,t){if(!e)return t;if(!t)return e;return _(e,t)<=0?e:t}var Ce=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function I(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 nt(e){let t=new Intl.NumberFormat(e,{useGrouping:!1}),i=new Map;for(let n=0;n<=9;n++)i.set(t.format(n),String(n));return i}function ke(e,t,i={}){let n=String(e||"").replace(Ce,"");if(i.trim!==!1)n=n.trim();for(let[s,r]of nt(t))n=n.split(s).join(r);return n}function J(e,t=""){let i=I(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(P(e))}function Ae(e,t=""){let i=I(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(P(`${e.slice(0,7)}-15`))}function Te(e=""){let t=I(e);try{let i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(P("2026-09-15")),n=-1,s=-1;if(i.forEach((r,a)=>{let o=r.type;if(o==="month"){if(n<0)n=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(s<0)s=a}}),n>=0&&s>=0)return s<n?["year","month"]:["month","year"]}catch{}return["month","year"]}function Se(e="",t="long"){let i=I(e),n=new Intl.DateTimeFormat(i,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(s,r)=>n.format(P(`2026-${String(r+1).padStart(2,"0")}-15`)))}function ue(e="",t=1,i="short"){let n=I(e),s=new Intl.DateTimeFormat(n,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=U(t),a=P("2026-01-04");return Array.from({length:7},(o,l)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+l)%7),s.format(d)})}function st(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q(e=""){let t=I(e),i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),n=P("2006-11-22"),s=i.formatToParts(n).filter((d)=>d.type!=="literal"||d.value),r=s.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=s.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(Ce,"")}).join(""),o=s.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let h=ke(d.value,t,{trim:!1});return st(h).replace(/\s+/g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:t,placeholder:a,format(d){if(!c(d))return"";return i.format(P(d))},parse(d){let h=ke(d,t);if(c(h))return h;let E=l.exec(h);if(!E)return"";let y={};if(r.forEach((w,k)=>{y[w]=Number(E[k+1])}),!y.year||!y.month||!y.day)return"";try{return B(y.year,y.month,y.day)}catch{return""}}}}var rt={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"},at={...rt};function Y(){return{...at}}function Me(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 n of t){if(!n||typeof n!=="object"||!("date"in n))continue;let{date:s,...r}=n;i.set(String(s),r)}return i}if(t&&typeof t==="object")for(let[n,s]of Object.entries(t))i.set(n,s&&typeof s==="object"?s:{});return i}var ot=0;function S(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function dt(e){let t=Number(e);if(t===7)return 0;return Number.isInteger(t)&&t>=0&&t<=6?t:1}function lt(e){return Number(e.slice(0,4))}function ae(e,t){let[i,n]=e.split("-").map(Number),s=i*12+(n-1)+t,r=Math.floor(s/12),a=(s%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function Fe(e){return{"data-range-start":e==="start"||e==="single","data-range-end":e==="end"||e==="single","data-in-range":e==="in"}}function ct(e){return Object.entries(Fe(e)).filter(([,t])=>t).map(([t])=>` ${t}="true"`).join("")}function ht(e){if(e==="single")return"rangeSingle";if(e==="start")return"rangeStart";if(e==="end")return"rangeEnd";if(e==="in")return"rangeInRange";return""}class ee 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-${++ot}`,this._model=new le,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._paintedRange={start:"",end:""},this._paintedPreview=!1,this._messages=Y(),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 I(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 dt(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=re(e),i=this.hasAttribute("data-range-preview");if(t.start===this._paintedRange.start&&t.end===this._paintedRange.end&&i===this._paintedPreview)return;if(this._highlightedRange=t,this._connected)this._updateRangeDom()}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={...Y(),...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(Z(i,e))}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){let t=xe(e,this.min,this.max),i=f(t),n=Z(i,this.firstDay);if(n===i)return t;let s=Number(t.slice(8,10))||1,r=M(`${n}-01`,s-1),a=oe(n);return _(r,a)>0?a:r}_weeks(e=this.display){let t=De(Z(e,this.firstDay),{firstDay:this.firstDay});if(!this.fixedWeeks||t.length>=6)return t;let i=t[t.length-1]?.[6]||"";while(t.length<6&&i){let n=[];for(let s=1;s<=7;s++)n.push(M(i,s));t.push(n),i=n[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],n=t[t.length-1];if(!i||!n)throw Error("Calendar month produced no weeks");return{start:i[0],end:n[6]}}getDateState(e){let t=this._sourceStates.get(e)||{},i=this._dateState?.(e,{...t})||{},n={...t,...i},s=this.min&&_(e,this.min)<0||this.max&&_(e,this.max)>0,a=n.enabled===!0?!1:Boolean(this._isDateDisabled?.(e)),o=Boolean(s)||Boolean(n.disabled)||a;return{...n,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),n=`${i.start}/${i.end}`;if(this._loadedRanges.has(n))return"loaded";if(n===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let s=new AbortController;this._loadController=s,this._loadingKey=n;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:s.signal});if(s.signal.aborted)return"cancelled";for(let[d,h]of Me(l))this._sourceStates.set(d,h);if(this._loadedRanges.add(n),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(s.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===s)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===n)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(e,t={}){let i=this._model.display;if(this._model.setDisplay(Z(e,this.firstDay)),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(ae(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(ae(this.display,1)??this.display)}focusDate(e,t={}){if(!c(e))throw TypeError(`Invalid date: ${e}`);let i=this._clamp(e),n=this.display,s=this._model.focused,r=t.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),n!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&s!==this._model.focused)this._moveFocusDom(s,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(e,t,i=!0){let n=e?this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`):null,s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(n instanceof HTMLElement)n.tabIndex=-1;if(s instanceof HTMLElement){if(s.tabIndex=0,i)s.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}_dayLabel(e,t,i){let n=this.hasAttribute("data-range-preview")?"":ht(i),s=typeof t.description==="string"?t.description:"";return[J(e,this.locale),s,n?this._messages[n]:"",t.disabled?this._messages.unavailable:""].filter(Boolean).join(". ")}_updateRangeDom(){this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview");for(let e of this.querySelectorAll(".dp-day[data-date]")){if(!(e instanceof HTMLTableCellElement))continue;let t=e.dataset.date||"",i=ce(t,this._highlightedRange);for(let[n,s]of Object.entries(Fe(i)))if(s)e.setAttribute(n,"true");else e.removeAttribute(n);e.setAttribute("aria-label",this._dayLabel(t,this.getDateState(t),i))}}focusGrid(){let e=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(e instanceof HTMLElement)e.focus()}async activateDate(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 s=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(s,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 n=t.closest(".dp-day[data-date]");if(!(n instanceof HTMLTableCellElement))return;let s=n.dataset.date||"";if(!c(s))return;let r=this.display;if(this._model.setFocused(this._clamp(s)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this.activateDate(s)}_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>9998){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))return;this._model.focused=i,this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:i,state:this.getDateState(i)},bubbles:!0}))}_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.activateDate(i);return}let n=this._model.focused,s=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=n,this._model.display=s,!r)return;e.preventDefault(),this.focusDate(this._clamp(r))}render(e=!0){if(!this._connected)return;let t=this.locale,i=this.display,n=lt(i),s=Number(i.slice(5,7)),r=Se(t,this.monthFormat),a=ue(t,this.firstDay,"short"),o=ue(t,this.firstDay,"long"),l=this._weeks(),d=L(),h=`${this._id}-heading`,E=`${this._id}-grid`,y=this.min?f(this.min):"",w=this.max?f(this.max):"",k=ae(i,-1),T=ae(i,1),x=Boolean(y&&k!==null&&k<y),b=Boolean(w&&T!==null&&T>w),v=this.min?` min="${Number(this.min.slice(0,4))}"`:"",A=this.max?` max="${Number(this.max.slice(0,4))}"`:"",D=this.showWeekNumbers&&this.firstDay===1,R=D?`<th scope="col" class="dp-week-heading" abbr="${S(this._messages.week)}">#</th>`:"",N=r.map((u,p)=>{let g=p+1,m=`${String(n).padStart(4,"0")}-${String(g).padStart(2,"0")}`,C=y&&m<y||w&&m>w;return`<option value="${String(g).padStart(2,"0")}"${g===s?" selected":""}${C?" disabled":""}>${S(u)}</option>`}).join(""),H=a.map((u,p)=>`<th scope="col" abbr="${S(o[p])}">${S(u.replace(".",""))}</th>`).join(""),O=l.map((u)=>{let p=D?`<th scope="row" class="dp-week-number">${Ee(u[0])}</th>`:"",g=u.map((m)=>{let C=this.getDateState(m),W=f(m)!==i,_e=this.value===m,je=this.focusedDate===m,Ge=m===d,ye=ce(m,this._highlightedRange),Ke=this._dayLabel(m,C,ye);return`<td class="dp-day" data-date="${m}"${W?' data-outside-month="true"':""}${Ge?' data-today="true" aria-current="date"':""}${_e?' data-selected="true" aria-selected="true"':""}${ct(ye)}${C.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${je?"0":"-1"}" aria-label="${S(Ke)}"><span class="dp-day-number" aria-hidden="true">${Number(m.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${p}${g}</tr>`}).join(""),j=document.activeElement,V=j instanceof HTMLElement&&this.contains(j)?this._focusTargetKey(j):"",G=Te(t)[0]==="year";this.toggleAttribute("data-year-first",G);let ie=`<label class="dp-visually-hidden" for="${this._id}-month">${S(this._messages.month)}</label>
491
+ <select id="${this._id}-month" class="dp-month-select" aria-label="${S(this._messages.month)}">${N}</select>`,K=`<label class="dp-visually-hidden" for="${this._id}-year">${S(this._messages.year)}</label>
492
+ <input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${n}"${v}${A} aria-label="${S(this._messages.year)}">`;if(this._rendering=!0,this.innerHTML=`
445
493
  <div class="dp-calendar-shell">
446
494
  <div class="dp-calendar-header">
447
- ${W?v:q}
448
- ${W?q:v}
449
- <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${T(this._messages.previousMonth)}"${C?" 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>
450
- <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${T(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>
495
+ ${G?K:ie}
496
+ ${G?ie:K}
497
+ <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${S(this._messages.previousMonth)}"${x?" 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="m4 10 4-4 4 4"/></svg></button>
498
+ <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${S(this._messages.nextMonth)}"${b?" 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="m4 6 4 4 4-4"/></svg></button>
451
499
  </div>
452
- <h2 id="${u}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${T(we(`${i}-15`,t))}</h2>
453
- <table id="${k}" class="dp-grid" role="grid" aria-labelledby="${u}">
454
- <thead><tr>${A}${H}</tr></thead>
455
- <tbody>${N}</tbody>
500
+ <h2 id="${h}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${S(Ae(`${i}-15`,t))}</h2>
501
+ <table id="${E}" class="dp-grid" role="grid" aria-labelledby="${h}">
502
+ <thead><tr>${R}${H}</tr></thead>
503
+ <tbody>${O}</tbody>
456
504
  </table>
457
- </div>`,this._rendering=!1,z)queueMicrotask(()=>{let h=z;if(h.startsWith(".dp-day[data-date="))h=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let m=this.querySelector(h);if(m instanceof HTMLElement)m.focus()});if(this._renderDay)for(let h of this.querySelectorAll(".dp-day[data-date]")){if(!(h instanceof HTMLTableCellElement))continue;let m=h.dataset.date||"",x=h.querySelector(".dp-day-extra");if(!(x instanceof HTMLElement))continue;let p=this._renderDay(m,this.getDateState(m));if(p instanceof Node)x.append(p);else if(p!==void 0&&p!==null)x.textContent=String(p)}if(e)this._loadDisplay(i)}}function Me(e){return e==="top"||e==="bottom"?"x":"y"}function rt(e){let[t,i=null]=e.split("-");return{side:t,align:i,crossAxis:Me(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=Me(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 k=(n&&a==="x"?-1:1)*(s==="end"?1:-1);u[a]+=d*k}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 ke(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 Ce(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 $e(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 Ae=new WeakMap,Te={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(E,y){let _=s.get(E);if(_===void 0||Te[y]>Te[_])s.set(E,y)}function d(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let E=[...s];s.clear(),r=!1;for(let[y,_]of E){if(!i.has(y)||!y.floating.isConnected)continue;y.callback({type:_})}})}function u(E){for(let y of i)l(y,E);d()}function k(E){if(!n)return null;let y=new Set,_=new n((H)=>{let N=!1;for(let R of H)if(y.has(R.target))N=!0;else y.add(R.target);if(!N)return;l(E,"element-resize"),d()}),{reference:A,floating:w}=E;if(A)_.observe(A);if(w!==A)_.observe(w);return _}let g=()=>u("scroll"),b=()=>u("resize");function C(){if(a)return;e.addEventListener("scroll",g,{passive:!0,capture:!0}),t.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",g,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function S(){if(!a)return;e.removeEventListener("scroll",g,{capture:!0}),t.removeEventListener("resize",b),o?.removeEventListener("scroll",g),o?.removeEventListener("resize",b),a=!1}return{add(E,y,_){let A={reference:E,floating:y,callback:_};i.add(A),C();let w=k(A),H=!1;return()=>{if(H)return;if(H=!0,i.delete(A),s.delete(A),w?.disconnect(),i.size===0)S()}}}}function _t(e){let t=e.ownerDocument,i=Ae.get(t);if(!i)i=gt(t),Ae.set(t,i);return i}function Fe(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 Se(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),k=d?lt(e):!1,g=e.getClientRects(),b=l==="bottom"?g[g.length-1]:g[0];if(!b)return null;let C=ht(e,i);if(!C||ft(b,C))return null;let S=$e(t),E={x:{size:S.width,start:C.x,end:C.right},y:{size:S.height,start:C.y,end:C.bottom}},y=(v,h)=>ot(b,S,v,h,k,n),_=(v,h)=>{let{size:m,start:x,end:p}=E[h];return dt(v,m,x+o,p-o)},A=(v,h)=>{let{size:m,start:x,end:p}=E[h];return _(a?ke(v,m,x,p,o):v,h)},w=y(l,d);if(r){let v=u==="x"?"y":"x",h=_(w[v],v);if(h>0){let m=at(l),x=y(m,d),p=_(x[v],v);if(p<h)l=m,w=x,h=p}if(v==="x"&&h>0){let m=y("top",d),x=y("bottom",d),p=_(x.y,"y")<_(m.y,"y"),M=p?x:m;if(_(M.y,"y")+A(M.x,"x")<h+A(w.y,"y"))l=p?"bottom":"top",u="x",w=M}}if(u==="x"&&a&&d){let v=_(w.x,"x");if(v>0){let h=d==="end"?"start":"end",m=y(l,h);if(_(m.x,"x")<v)d=h,w=m}}if(a){let{size:v,start:h,end:m}=E[u];w[u]=ke(w[u],v,h,m,o)}let H=Ce(b.x+b.width/2,w.x,S.width),N=Ce(b.y+b.height/2,w.y,S.height),R=`${pt(b,l,C,n,o)}px`,{style:z}=t,W=z.getPropertyValue("--available-height")!==R;z.left=`${w.x}px`,z.top=`${w.y}px`,z.setProperty("--arrow-x",`${H}%`),z.setProperty("--arrow-y",`${N}%`),z.setProperty("--available-height",R);let q=d?`${l}-${d}`:l;return t.dataset.placement=q,{width:S.width,height:S.height,roomChanged:W,placement:q}}function Ie(e,t,i={}){let s=Se(e,t,i);if(!s)return!1;if(s.roomChanged){let n=$e(t);if(n.width!==s.width||n.height!==s.height)Se(e,t,{...i,placement:s.placement,flip:!1})}return!0}class Z{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=K(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=K(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;if(this._dirty=!0,this.dirty(),this.hidden)this.hidden.value="";let t=e.value.trim();if(!t){e.setCustomValidity("");return}let i=this.canonical?this.adapter.format(this.canonical):"";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 ae(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 oe(e){return ae(e)!==null}function Le(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function Oe(e,t){let i=ae(e),s=ae(t);if(!i||!s)throw TypeError("compareTimes() expects HH:MM values");let n=Le(i)-Le(s);return n===0?0:n<0?-1:1}var bt=0;class de 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._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=Y(),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 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 Z(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 Z(e,{messages:this._messages,locale:this.locale}),new Z(t,{messages:this._messages,locale:this.locale})],this._range=new ne,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(t),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,this._button?.remove(),this._panel?.remove(),this._formatHint?.remove(),this._button=null,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}=te(e);this._setRange(t,i)}get locale(){return O(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={...Y(),...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()}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??K(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let e=this._input;if(!e)return;if(this._field?.syncInputState(),this._button)this._button.disabled=e.disabled||e.readOnly;if(this._open&&(e.disabled||e.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let i of this._fields)i.syncInputState();let e=this._range?.activeEndpoint==="end"?1:0,t=this._fields.every((i)=>i.input.disabled||i.input.readOnly);if(this._button)this._button.disabled=t;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)}}_build(e){let t=e||this._input;if(!t)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",t.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=t.getAttribute("aria-describedby")||"";let l=[this._originalDescribedBy,s].filter(Boolean).join(" ");t.setAttribute("aria-describedby",l),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let e=this._input,t=this._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()},{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._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 e=this._button,t=this._calendar;if(!this._fields||!e||!t)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})}e.addEventListener("click",(n)=>{if(this._open){if(n.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:s}),t.addEventListener("click",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),t.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),t.addEventListener("dateactivate",(n)=>{let r=n,a=r.detail?.date;if(!c(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 l=this._range.activate(a,(d)=>{let u=d==="end"?1:0,k=this._fields?.[u];return k!=null&&!k.input.disabled&&!k.input.readOnly});if(l.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:a,state:this._calendar.getDateState(a)},bubbles:!0}));return}if(this._setBound(l.endpoint,a,{emit:!0,user:!0}),l.close||l.status==="complete")this.hide(!1),this._focusField(l.endpoint)})},{signal:s}),t.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(e,t){if(t.key==="ArrowDown"||t.altKey&&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.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(){if(!this._button)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let e=this._value?this._messages.changeDate:this._messages.chooseDate,t=this._value?`, ${U(this._value,this.locale)}`:"";this._button.setAttribute("aria-label",`${e}${t}`)}_refreshRangeButtonLabel(){if(!this._button||!this._range)return;let{start:e,end:t}=this._range,i=Boolean(e&&t),s=i?this._messages.changeDate:this._messages.chooseDate,n=i?`, ${U(e,this.locale)} – ${U(t,this.locale)}`:"";this._button.setAttribute("aria-label",`${s}${n}`)}_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:!0,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&&D(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&&D(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)&&oe(r)&&oe(a)&&Oe(a,r)<0;for(let[l,d]of s.entries()){let u=n[l];if(!u)continue;let k=d==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(o&&d===e)u.setCustomValidity(k),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(L()),this._calendar.focusedDate=L();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||L();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)}_focusInput(){this._suppressFocusOpen=!0,setTimeout(()=>{this._input?.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,s=this._button;if(!t||!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)||L();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)||L();i.display=f(a),i.focusedDate=a}t.showPopover(),this._open=!0,this._setExpanded(!0);let n=()=>Ie(this,t,{placement:"bottom-start",distance:4,shiftPadding:8});if(n(),this._stopTracking=Fe(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),this._button?.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._focusInput();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 le(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",G);if(!customElements.get("date-picker"))customElements.define("date-picker",de)}le();var Re="lekoala-date-picker-styles";if(!document.getElementById(Re)){let e=document.createElement("style");e.id=Re,e.textContent=fe,document.head.append(e)}le();})();
505
+ </div>`,this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),V)queueMicrotask(()=>{let u=V;if(u.startsWith(".dp-day[data-date="))u=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let p=this.querySelector(u);if(p instanceof HTMLElement)p.focus()});if(this._renderDay)for(let u of this.querySelectorAll(".dp-day[data-date]")){if(!(u instanceof HTMLTableCellElement))continue;let p=u.dataset.date||"",g=u.querySelector(".dp-day-extra");if(!(g instanceof HTMLElement))continue;let m=this._renderDay(p,this.getDateState(p));if(m instanceof Node)g.append(m);else if(m!==void 0&&m!==null)g.textContent=String(m)}if(e)this._loadDisplay(i)}}function ze(e){return e==="top"||e==="bottom"?"x":"y"}function ut(e){let[t,i=null]=e.split("-");return{side:t,align:i,crossAxis:ze(t)}}function ft(e){return{top:"bottom",bottom:"top",left:"right",right:"left"}[e]||e}function pt(e,t,i,n,s,r){let a=ze(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,h;switch(i){case"top":h={x:o,y:e.y-t.height-r};break;case"bottom":h={x:o,y:e.y+e.height+r};break;case"right":h={x:e.x+e.width+r,y:l};break;case"left":h={x:e.x-t.width-r,y:l};break;default:h={x:e.x,y:e.y}}if(n==="start"||n==="end"){let E=(s&&a==="x"?-1:1)*(n==="end"?1:-1);h[a]+=d*E}return h}function mt(e,t,i,n){return Math.max(i-e,0)+Math.max(e+t-n,0)}function gt(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 _t=25;function yt(e){let t=e.defaultView;if(!t)return null;let i=e.documentElement,n=t.visualViewport,s=n?.offsetLeft||0,r=n?.offsetTop||0,a=n?.width||i.clientWidth||t.innerWidth,o=n?.height||i.clientHeight||t.innerHeight,l=e.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(l>0&&l<=_t){let d=t.getComputedStyle?.(i).scrollbarGutter;if(d&&d!=="auto")a-=l}return{x:s,y:r,width:a,height:o,right:s+a,bottom:r+o}}function bt(e,t){return t.scope?t.scope.getBoundingClientRect():yt(e.ownerDocument)}function $e(e,t,i,n,s){let r=i+s,a=n-t-s,o=a>=r,l=o?r:i,d=o?a:n-t;return Math.max(l,Math.min(e,d))}function Le(e,t,i){if(!i)return 50;let n=(e-t)/i*100;return Math.round(Math.min(100,Math.max(0,n))*1000)/1000}function vt(e,t){return e.right<t.x||e.left>t.right||e.bottom<t.y||e.top>t.bottom}function wt(e,t,i,n,s){if(t==="top")return Math.max(0,e.top-i.y-n-s);if(t==="bottom")return Math.max(0,i.bottom-e.bottom-n-s);return Math.max(0,i.height-s*2)}function Dt(e){if(e.hidden)return!1;if(typeof e.checkVisibility==="function")return e.checkVisibility();return e.getClientRects().length>0}function Pe(e){let{offsetWidth:t,offsetHeight:i}=e;if(t&&i)return{width:t,height:i};let n=e.getBoundingClientRect();return{width:t||n.width,height:i||n.height}}var Ie=new WeakMap,Re={scroll:0,resize:1,"element-resize":2};function xt(e){let t=e.defaultView;if(!t)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,n=new Map,s=t.ResizeObserver,r=!1,a=!1,o=t.visualViewport;function l(x,b){let v=n.get(x);if(v===void 0||Re[b]>Re[v])n.set(x,b)}function d(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let x=[...n];n.clear(),r=!1;for(let[b,v]of x){if(!i.has(b)||!b.floating.isConnected)continue;b.callback({type:v})}})}function h(x){for(let b of i)l(b,x);d()}function E(x){if(!s)return null;let b=new Set,v=new s((R)=>{let N=!1;for(let H of R)if(b.has(H.target))N=!0;else b.add(H.target);if(!N)return;l(x,"element-resize"),d()}),{reference:A,floating:D}=x;if(A)v.observe(A);if(D!==A)v.observe(D);return v}let y=()=>h("scroll"),w=()=>h("resize");function k(){if(a)return;e.addEventListener("scroll",y,{passive:!0,capture:!0}),t.addEventListener("resize",w,{passive:!0}),o?.addEventListener("scroll",y,{passive:!0}),o?.addEventListener("resize",w,{passive:!0}),a=!0}function T(){if(!a)return;e.removeEventListener("scroll",y,{capture:!0}),t.removeEventListener("resize",w),o?.removeEventListener("scroll",y),o?.removeEventListener("resize",w),a=!1}return{add(x,b,v){let A={reference:x,floating:b,callback:v};i.add(A),k();let D=E(A),R=!1;return()=>{if(R)return;if(R=!0,i.delete(A),n.delete(A),D?.disconnect(),i.size===0)T()}}}}function Et(e){let t=e.ownerDocument,i=Ie.get(t);if(!i)i=xt(t),Ie.set(t,i);return i}function He(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 Et(t).add(e,t,i)}function Oe(e,t,i){if(!Dt(t))return null;let n=i.placement||"bottom-start",s=i.distance||0,r=i.flip!==!1,a=i.shift!==!1,o=i.shiftPadding??4,{side:l,align:d,crossAxis:h}=ut(n),E=d?gt(e):!1,y=e.getClientRects(),w=l==="bottom"?y[y.length-1]:y[0];if(!w)return null;let k=bt(e,i);if(!k||vt(w,k))return null;let T=Pe(t),x={x:{size:T.width,start:k.x,end:k.right},y:{size:T.height,start:k.y,end:k.bottom}},b=(u,p)=>pt(w,T,u,p,E,s),v=(u,p)=>{let{size:g,start:m,end:C}=x[p];return mt(u,g,m+o,C-o)},A=(u,p)=>{let{size:g,start:m,end:C}=x[p];return v(a?$e(u,g,m,C,o):u,p)},D=b(l,d);if(r){let u=h==="x"?"y":"x",p=v(D[u],u);if(p>0){let g=ft(l),m=b(g,d),C=v(m[u],u);if(C<p)l=g,D=m,p=C}if(u==="x"&&p>0){let g=b("top",d),m=b("bottom",d),C=v(m.y,"y")<v(g.y,"y"),W=C?m:g;if(v(W.y,"y")+A(W.x,"x")<p+A(D.y,"y"))l=C?"bottom":"top",h="x",D=W}}if(h==="x"&&a&&d){let u=v(D.x,"x");if(u>0){let p=d==="end"?"start":"end",g=b(l,p);if(v(g.x,"x")<u)d=p,D=g}}if(a){let{size:u,start:p,end:g}=x[h];D[h]=$e(D[h],u,p,g,o)}let R=Le(w.x+w.width/2,D.x,T.width),N=Le(w.y+w.height/2,D.y,T.height),H=`${wt(w,l,k,s,o)}px`,{style:O}=t,j=O.getPropertyValue("--available-height")!==H,V=i.coordinateSpace==="document"?e.ownerDocument.defaultView:null,G=V?V.scrollX:0,ie=V?V.scrollY:0;O.left=`${D.x+G}px`,O.top=`${D.y+ie}px`,O.setProperty("--arrow-x",`${R}%`),O.setProperty("--arrow-y",`${N}%`),O.setProperty("--available-height",H);let K=d?`${l}-${d}`:l;return t.dataset.placement=K,{width:T.width,height:T.height,roomChanged:j,placement:K}}function Ve(e,t,i={}){let n=Oe(e,t,i);if(!n)return!1;if(n.roomChanged){let s=Pe(t);if(s.width!==n.width||s.height!==n.height)Oe(e,t,{...i,placement:n.placement,flip:!1})}return!0}class te{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=Q(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=Q(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(e={}){let t=this.input,i=++this._commitId,n=t.value.trim();if(!n){if(i!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(n);if(!s){if(i!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return t.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let r=await this.confirm(s,e);if(i!==this._commitId)return{status:"stale"};if(!r?.ok){if(this.hidden)this.hidden.value="";return t.setCustomValidity(r?.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 kt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function fe(e){let t=kt.exec(String(e||""));if(!t)return null;let i=Number(t[1]),n=Number(t[2]),s=t[3]===void 0?0:Number(t[3]),r=t[4]===void 0?0:Number(t[4].padEnd(3,"0"));if(i>23||n>59||s>59||r>999)return null;return{hour:i,minute:n,second:s,millisecond:r}}function pe(e){return fe(e)!==null}function Be(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function Ne(e,t){let i=fe(e),n=fe(t);if(!i||!n)throw TypeError("compareTimes() expects HH:MM values");let s=Be(i)-Be(n);return s===0?0:s<0?-1:1}var Ct=0,Ue=4;class me extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];constructor(){super();this._id=`date-picker-${++Ct}`,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._previewDate="",this._drag=null,this._suppressGridClick=!1,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=Y(),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 te(e,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(n,s)=>this._confirmDate(n,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 n=this.querySelectorAll(`:scope > input[${i}]`);if(n.length>1)console.warn(`<date-picker> expects at most one direct child input[${i}]; ignoring extras`);let s=n[0];if(s==null)continue;if(!(s instanceof HTMLInputElement)||s.type!=="time"){console.warn(`<date-picker> input[${i}] must be an <input type="time">; ignoring it`);continue}this._timeFields[t]=s}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 te(e,{messages:this._messages,locale:this.locale}),new te(t,{messages:this._messages,locale:this.locale})],this._range=new he,this._rangeOriginalDescribedBy=[e.getAttribute("aria-describedby")||"",t.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a,o)=>this._confirmDate(a,o),r.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),n=c(e.value)?e.value:i.parse(e.value),s=c(t.value)?t.value:i.parse(t.value);if(this._setRange(n||"",s||"",{emit:!1}),e.value.trim()&&!c(n))e.setCustomValidity(this._messages.invalidDate);if(t.value.trim()&&!c(s))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}=re(e);this._setRange(t,i)}get locale(){return I(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={...Y(),...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??Q(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 n=i==="end"?1:0,s=this._fields[n];t.disabled=Boolean(s?.input.disabled||s?.input.readOnly)}this._syncDragAffordance();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`,n=`${this._id}-format`;this._buttons=t.map(([o,l])=>{let d=this._createTrigger(l);return o.insertAdjacentElement("afterend",d),{button:d,endpoint:l}});let s=document.createElement("div");s.id=i,s.className="dp-picker-panel",s.setAttribute("popover","manual"),s.setAttribute("role","dialog"),s.setAttribute("aria-label",this._messages.calendar);let r=new ee;r.selection="none",r.fixedWeeks=!0,s.append(r);let a=document.createElement("span");if(a.id=n,a.className="dp-visually-hidden",this.append(s,a),this._panel=s,this._calendar=r,this._formatHint=a,!e&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,n].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 n=new AbortController;this._controller=n;let{signal:s}=n;e.addEventListener("input",()=>{this._field?.handleInput()},{signal:s}),e.addEventListener("change",()=>void this._commitText(!1),{signal:s}),e.addEventListener("blur",()=>void this._commitText(!1),{signal:s}),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:s}),e.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:s});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:s}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:s})}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:s}),t.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:s}),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:s}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:s}),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:s}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:s})}_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[n,s]of this._fields.entries()){let r=n===1?"end":"start";s.input.addEventListener("input",()=>s.handleInput(),{signal:i}),s.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:i}),s.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:i}),s.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:i}),s.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:i})}for(let n of this._buttons){let s=n.endpoint;if(s==="")continue;n.button.addEventListener("click",(r)=>this._onRangeTriggerClick(s,r),{signal:i}),n.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(s,r),{signal:i})}e.addEventListener("click",(n)=>{if(this._suppressGridClick){this._suppressGridClick=!1,n.preventDefault(),n.stopImmediatePropagation();return}this._captureGridIntent(n)},{capture:!0,signal:i}),e.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:i}),e.addEventListener("dateactivate",(n)=>{let s=n,r=s.detail?.date;if(!c(r))return;queueMicrotask(()=>{if(s.defaultPrevented||!this._connected||!this._range)return;let a=this._pendingIntents.get(r);if(a===void 0||a.id!==this._rangeCommitId)return;this._pendingIntents.delete(r);let o=(d)=>this._boundEditable(d),l=a.endpoint?this._range.moveEndpoint(r,a.endpoint,o):this._range.activate(r,o);if(l.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._applyRangeTransition(l),a.endpoint)return;if(l.close||l.status==="complete")this.hide(!1),this._focusField(l.endpoint)})},{signal:i}),e.addEventListener("datefocus",(n)=>this._onGridDateFocus(n),{signal:i}),e.addEventListener("pointerover",(n)=>this._onGridPointerOver(n),{signal:i}),e.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:i}),e.addEventListener("pointerdown",(n)=>this._onGridPointerDown(n),{signal:i}),e.addEventListener("pointermove",(n)=>this._onGridPointerMove(n),{signal:i}),e.addEventListener("pointerup",(n)=>this._onGridPointerUp(n),{signal:i}),e.addEventListener("pointercancel",(n)=>this._onGridPointerCancel(n),{signal:i}),e.addEventListener("lostpointercapture",(n)=>this._onGridPointerCancel(n),{signal:i}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:i}),this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:i}),this.ownerDocument.addEventListener("reset",(n)=>{let s=n.target;if(s instanceof HTMLFormElement&&this._fields&&s===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!n.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:i}),this.addEventListener("keydown",(n)=>this._onEscape(n),{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)||L();t.display=f(i),t.focusedDate=i,this._clearPreview()}_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 n=t.relatedTarget;if(n instanceof Node&&this.contains(n))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(e){if(!this._rangeMode()||!this._range)return;if(e.type==="keydown"){let n=e.key;if(n!=="Enter"&&n!==" ")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,{id:++this._rangeCommitId,endpoint:""})}_boundEditable(e){let t=this._fields?.[e==="end"?1:0];return t!=null&&!t.input.disabled&&!t.input.readOnly}_applyRangeTransition(e){let t=this._fields;if(!t||!this._range||e.status==="refused")return;let i=[];for(let n of e.changedEndpoints){let s=t[n==="end"?1:0],r=n==="end"?e.range.end:e.range.start;if(!s||s.canonical===r)continue;s.setCanonical(r,{format:!0}),i.push(s)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(e.endpoint),!i.length)return;this._emitRangeChange();for(let n of i)n.input.dispatchEvent(new Event("input",{bubbles:!0})),n.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(e,t=""){let i=this._calendar;if(!i||!this._range||!this._open)return;let n=c(e)&&!i.getDateState(e).disabled?e:"",s=n?this._range.previewRange(n,t,(r)=>this._boundEditable(r)):null;if(!s){this._clearPreview();return}this._previewDate=n,i.toggleAttribute("data-range-preview",!0),i.highlightedRange=s}_clearPreview(){if(!this._previewDate)return;this._syncHighlight()}_onGridDateFocus(e){if(this._drag)return;let t=e.detail?.date;if(c(t))this._setPreview(t)}_onGridPointerOver(e){let t=e;if(this._drag||t.pointerType==="touch")return;this._setPreview(this._cellDate(t.target))}_onGridPointerLeave(){if(this._drag?.active===!1)this._drag=null;if(this._drag)return;this._clearPreview()}_cellDate(e){let i=(e instanceof Element?e.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return c(i)?i:""}_dateAtPoint(e,t){let i=this.ownerDocument.elementFromPoint(e,t);if(!(i instanceof Element)||!this._calendar?.contains(i))return"";return this._cellDate(i)}_onGridPointerDown(e){let t=e;if(this._suppressGridClick=!1,this._drag?.active===!1)this._drag=null;if(!this._open||!this._range||this._drag)return;if(!t.isPrimary||t.button!==0)return;if(t.pointerType!=="mouse"&&t.pointerType!=="pen")return;if(!this._range.complete)return;let i=t.target instanceof Element?t.target.closest(".dp-day[data-date]"):null;if(!(i instanceof HTMLElement))return;let n=i.hasAttribute("data-range-start"),s=i.hasAttribute("data-range-end");if(n===s)return;let r=n?"start":"end",a=this._cellDate(i);if(!a||!this._boundEditable(r))return;this._drag={pointerId:t.pointerId,endpoint:r,x:t.clientX,y:t.clientY,date:a,active:!1}}_onGridPointerMove(e){let t=e,i=this._drag;if(!i||t.pointerId!==i.pointerId)return;if(!i.active){if(!(Math.abs(t.clientX-i.x)>Ue||Math.abs(t.clientY-i.y)>Ue))return;i.active=!0;try{this._calendar?.setPointerCapture(i.pointerId)}catch{}this._syncDragAffordance()}let n=this._dateAtPoint(t.clientX,t.clientY);if(!n||this._calendar?.getDateState(n).disabled)return;i.date=n,this._setPreview(n,i.endpoint)}_onGridPointerUp(e){let t=e,i=this._drag;if(!i||t.pointerId!==i.pointerId)return;if(this._drag=null,this._releaseDragCapture(i.pointerId),!i.active){this._syncDragAffordance();return}this._suppressGridClick=!0;let n=this._range?.projectEndpoint(i.date,i.endpoint,(r)=>this._boundEditable(r));if(!n||n.status==="refused"||!n.changedEndpoints.length){this._syncHighlight();return}let s=i.endpoint==="start"?n.range.start:n.range.end;this._pendingIntents.clear(),this._pendingIntents.set(s,{id:++this._rangeCommitId,endpoint:i.endpoint}),this._calendar?.activateDate(s)}_onGridPointerCancel(e){let t=e,i=this._drag;if(!i||t.pointerId!==i.pointerId)return;this._drag=null,this._releaseDragCapture(i.pointerId),this._syncHighlight()}_releaseDragCapture(e){let t=this._calendar;if(t?.hasPointerCapture(e))t.releasePointerCapture(e)}_syncDragAffordance(){let e=this._calendar;if(!e||!this._range)return;if(this._drag?.active){e.setAttribute("data-range-drag","active");return}let{start:t,end:i}=this._range;if(this._range.complete&&t!==i&&(this._boundEditable("start")||this._boundEditable("end")))e.setAttribute("data-range-drag","ready");else e.removeAttribute("data-range-drag")}_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,n]of this._fields.entries()){if(!n.input.hasAttribute("placeholder")||this._generatedPlaceholder)n.input.placeholder=n.placeholder,this._generatedPlaceholder=!0;let s=i===1?this._range?.end||"":this._range?.start||"";if(s)n.input.value=n.format(s)}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?`, ${J(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:n}of this._buttons){let s=n==="end"?t:e,r=s?this._messages.changeDate:this._messages.chooseDate,a=s?`, ${J(s,this.locale)}`:"",o=n==="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&&t.moveDisplay!==!1)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 n=this._field.input;n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(e,t={}){let i=this._calendar;if(!i)return{ok:!0};if(t.moveDisplay!==!1){let r=f(e);if(i.display!==r)i.display=r}let n=await i.ensureDate(e),s=i.getDateState(e);if(!n||s.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 n=await i.commit(t);if(n.status==="stale"||n.status==="invalid")return!1;return this._setValue(n.value||"",{emit:e,format:n.status==="ok",moveDisplay:t.moveDisplay}),!0}async _commitFieldText(e){let t=this._fields;if(!t)return!1;let i=e==="end"?1:0,n=t[i];if(!n?.isDirty)return!1;let s=await n.commit();if(s.status==="stale")return!1;if(s.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(e,s.value||"",{emit:!1,user:!0,format:s.status==="ok"}),!0}_setBound(e,t,i={}){if(!this._range)return!1;let n=this._fields;if(!n)return!1;let r=n[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}))}_displayRange(){let{start:e,end:t}=this._range?.range??{start:"",end:""};if(!e)return{start:"",end:""};if(t&&_(t,e)<0)return{start:e,end:""};return{start:e,end:t}}_syncHighlight(){if(!this._calendar||!this._range)return;this._previewDate="",this._calendar.removeAttribute("data-range-preview"),this._calendar.highlightedRange=this._displayRange(),this._syncDragAffordance()}_revalidateRange(e){if(!this._fields||!this._range)return;let{start:t,end:i}=this._range,n=Boolean(t&&i&&_(i,t)<0),s=["start","end"];for(let r of s){let a=r==="end"?1:0,o=this._fields[a].input,l=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(n&&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,n=["start","end"],s=[t,i],r=t&&!t.disabled?t.value.trim():"",a=i&&!i.disabled?i.value.trim():"",o=Boolean(t&&i&&r&&a)&&pe(r)&&pe(a)&&Ne(a,r)<0;for(let[l,d]of n.entries()){let h=s[l];if(!h)continue;let E=d==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(o&&d===e)h.setCustomValidity(E),this._timeOrderOwned.add(h);else if(this._timeOrderOwned.has(h))h.setCustomValidity(""),this._timeOrderOwned.delete(h)}}_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(L()),this._calendar.focusedDate=L();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||L();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",n=i==="end"?1:0;if(!this._fields[n].input.disabled&&!this._fields[n].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[n,s]of i.entries()){let r=await s.commit({moveDisplay:!1});if(r.status==="ok"||r.status==="clear"){let a=n===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((n)=>n.input.checkValidity())}let e=this._field?.input;if(!e)return!0;if(!e.value.trim())e.setCustomValidity("");else await this._commitText(!1,{force:!0,moveDisplay:!1});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)||L();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 n=this.coordinateSpace;t.style.position=n==="document"?"absolute":"fixed";let s=()=>Ve(this,t,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:n});if(s(),this._stopTracking=He(this,t,s),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(),this._suppressGridClick=!1,this._drag)this._releaseDragCapture(this._drag.pointerId),this._drag=null;if(this._syncHighlight(),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 ge(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",ee);if(!customElements.get("date-picker"))customElements.define("date-picker",me)}ge();var Ye="lekoala-date-picker-styles";if(!document.getElementById(Ye)){let e=document.createElement("style");e.id=Ye,e.textContent=be,document.head.append(e)}ge();})();