@lekoala/date-picker 0.1.1 → 0.2.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.
- package/README.md +27 -4
- package/custom-elements.json +44 -0
- package/dist/date-picker.css +111 -12
- package/dist/date-picker.js +162 -13
- package/dist/date-picker.min.css +1 -1
- package/dist/date-picker.min.js +13 -13
- package/dist/date-picker.standalone.min.js +125 -26
- package/dist/types/date-calendar.d.ts +3 -0
- package/dist/types/date-calendar.d.ts.map +1 -1
- package/dist/types/date-picker.d.ts +24 -0
- package/dist/types/date-picker.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/intl.d.ts +9 -0
- package/dist/types/intl.d.ts.map +1 -1
- package/dist/types/time.d.ts +8 -0
- package/dist/types/time.d.ts.map +1 -0
- package/docs/API.md +47 -0
- package/docs/DECISIONS.md +8 -1
- package/docs/ROADMAP.md +3 -2
- package/docs/USE_CASES.md +14 -1
- package/package.json +2 -2
- package/src/date-calendar.js +42 -7
- package/src/date-picker.css +111 -12
- package/src/date-picker.js +108 -5
- package/src/index.js +1 -0
- package/src/intl.js +35 -0
- package/src/time.js +39 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*** @lekoala/date-picker v0.
|
|
2
|
-
(()=>{var
|
|
1
|
+
/*** @lekoala/date-picker v0.2.0 - https://github.com/lekoala/date-picker ***/
|
|
2
|
+
(()=>{var fe=`:where(date-calendar, date-picker) {
|
|
3
3
|
--dp-bg: Canvas;
|
|
4
4
|
--dp-fg: CanvasText;
|
|
5
5
|
--dp-muted: color-mix(in srgb, CanvasText 58%, Canvas);
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
--dp-radius: 0.5rem;
|
|
11
11
|
--dp-day-size: 2.75rem;
|
|
12
12
|
--dp-gap: 0.25rem;
|
|
13
|
+
--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-year-inline-size: 5.5rem;
|
|
17
|
+
--dp-day-radius: calc(var(--dp-radius) * 0.75);
|
|
13
18
|
color: var(--dp-fg);
|
|
14
19
|
font: inherit;
|
|
15
20
|
}
|
|
@@ -40,22 +45,46 @@ date-calendar {
|
|
|
40
45
|
.dp-calendar-header {
|
|
41
46
|
display: grid;
|
|
42
47
|
grid-template-columns: minmax(0, 1fr) auto auto auto;
|
|
43
|
-
|
|
48
|
+
/* Stretch (not center): once a UA natural height exceeds
|
|
49
|
+
--dp-header-control-size, the row grows to the tallest control and the
|
|
50
|
+
others stretch to match, so month/year/nav stay equal. */
|
|
51
|
+
align-items: stretch;
|
|
44
52
|
gap: var(--dp-gap);
|
|
45
|
-
margin-block-end:
|
|
53
|
+
margin-block-end: var(--dp-header-block-gap);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Locale year-first order (Intl-derived, direction-independent): the flexible
|
|
57
|
+
track stays under the month select so the fixed-width year input never
|
|
58
|
+
stretches. Visual mirroring itself is left to the inherited \`dir\`. */
|
|
59
|
+
date-calendar[data-year-first] .dp-calendar-header {
|
|
60
|
+
grid-template-columns: auto minmax(0, 1fr) auto auto;
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
.dp-calendar-header .dp-prev {
|
|
49
|
-
margin-inline-start:
|
|
64
|
+
margin-inline-start: var(--dp-nav-gap);
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
.dp-calendar-header :where(button, select, input) {
|
|
53
|
-
min-block-size:
|
|
68
|
+
min-block-size: var(--dp-header-control-size);
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
/* Shared vertical metrics: UA default padding/line-height differ per control
|
|
71
|
+
(up to ~13px apart), which only shows once --dp-header-control-size drops
|
|
72
|
+
below content size. */
|
|
73
|
+
padding-block: 0.15rem;
|
|
54
74
|
border: 1px solid var(--dp-border);
|
|
55
75
|
border-radius: calc(var(--dp-radius) * 0.75);
|
|
56
76
|
background: var(--dp-bg);
|
|
57
77
|
color: var(--dp-fg);
|
|
58
78
|
font: inherit;
|
|
79
|
+
line-height: 1.2;
|
|
80
|
+
}
|
|
81
|
+
|
|
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;
|
|
59
88
|
}
|
|
60
89
|
|
|
61
90
|
.dp-calendar-header select,
|
|
@@ -66,16 +95,20 @@ date-calendar {
|
|
|
66
95
|
|
|
67
96
|
.dp-month-select {
|
|
68
97
|
inline-size: 100%;
|
|
98
|
+
/* Long month names in a narrow track (compact consumers, long locales)
|
|
99
|
+
would paint under the native caret: truncate with an ellipsis instead. */
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
text-overflow: ellipsis;
|
|
69
102
|
}
|
|
70
103
|
|
|
71
104
|
.dp-year-input {
|
|
72
|
-
inline-size:
|
|
105
|
+
inline-size: var(--dp-year-inline-size);
|
|
73
106
|
}
|
|
74
107
|
|
|
75
108
|
.dp-nav {
|
|
76
109
|
display: grid;
|
|
77
110
|
place-items: center;
|
|
78
|
-
inline-size:
|
|
111
|
+
inline-size: var(--dp-header-control-size);
|
|
79
112
|
padding: 0;
|
|
80
113
|
font-size: 1.35rem;
|
|
81
114
|
line-height: 1;
|
|
@@ -89,6 +122,14 @@ date-calendar {
|
|
|
89
122
|
pointer-events: none;
|
|
90
123
|
}
|
|
91
124
|
|
|
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
|
+
|
|
92
133
|
.dp-calendar-header :where(button, select, input):disabled,
|
|
93
134
|
.dp-picker-button:disabled {
|
|
94
135
|
cursor: not-allowed;
|
|
@@ -134,7 +175,7 @@ date-calendar {
|
|
|
134
175
|
.dp-day {
|
|
135
176
|
position: relative;
|
|
136
177
|
border: 1px solid transparent;
|
|
137
|
-
border-radius:
|
|
178
|
+
border-radius: var(--dp-day-radius);
|
|
138
179
|
cursor: pointer;
|
|
139
180
|
outline: none;
|
|
140
181
|
vertical-align: middle;
|
|
@@ -143,10 +184,21 @@ date-calendar {
|
|
|
143
184
|
|
|
144
185
|
.dp-day:focus-visible {
|
|
145
186
|
outline: 2px solid var(--dp-accent);
|
|
146
|
-
outline-offset:
|
|
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);
|
|
147
192
|
z-index: 1;
|
|
148
193
|
}
|
|
149
194
|
|
|
195
|
+
/* Base tint for days outside the displayed month. It stays before the
|
|
196
|
+
selection states so selected/range endpoints keep their accent-contrast
|
|
197
|
+
text on the accent fill (equal specificity, source order decides). */
|
|
198
|
+
.dp-day[data-outside-month="true"] {
|
|
199
|
+
color: var(--dp-muted);
|
|
200
|
+
}
|
|
201
|
+
|
|
150
202
|
.dp-day[data-selected="true"] {
|
|
151
203
|
background: var(--dp-accent);
|
|
152
204
|
color: var(--dp-accent-fg);
|
|
@@ -156,10 +208,6 @@ date-calendar {
|
|
|
156
208
|
border-color: var(--dp-accent);
|
|
157
209
|
}
|
|
158
210
|
|
|
159
|
-
.dp-day[data-outside-month="true"] {
|
|
160
|
-
color: var(--dp-muted);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
211
|
.dp-day[data-disabled="true"] {
|
|
164
212
|
cursor: not-allowed;
|
|
165
213
|
opacity: 0.42;
|
|
@@ -202,6 +250,17 @@ date-calendar {
|
|
|
202
250
|
font-variant-numeric: tabular-nums;
|
|
203
251
|
}
|
|
204
252
|
|
|
253
|
+
/* A focused disabled day stays discoverable by keyboard: restore full opacity
|
|
254
|
+
so the focus outline renders at full strength, and mark the number with the
|
|
255
|
+
muted tone (same language as outside-month days) instead of the wash-out. */
|
|
256
|
+
.dp-day[data-disabled="true"]:focus-visible {
|
|
257
|
+
opacity: 1;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.dp-day[data-disabled="true"]:focus-visible .dp-day-number {
|
|
261
|
+
color: var(--dp-muted);
|
|
262
|
+
}
|
|
263
|
+
|
|
205
264
|
.dp-day-extra {
|
|
206
265
|
position: absolute;
|
|
207
266
|
inset-inline: 2px;
|
|
@@ -236,16 +295,56 @@ date-picker > input:not([type="hidden"]) {
|
|
|
236
295
|
min-inline-size: 0;
|
|
237
296
|
}
|
|
238
297
|
|
|
298
|
+
/* Optional native time companions share the date row; authored inputs stay
|
|
299
|
+
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. */
|
|
301
|
+
date-picker:has(> [data-time-start], > [data-time-end]) {
|
|
302
|
+
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
date-picker:has(> [data-time-start]):has(> [data-time-end]) {
|
|
306
|
+
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
date-picker > input[data-time-start] {
|
|
310
|
+
grid-column: 3;
|
|
311
|
+
grid-row: 1;
|
|
312
|
+
min-inline-size: 0;
|
|
313
|
+
inline-size: 100%;
|
|
314
|
+
margin-inline-start: var(--dp-gap);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
date-picker > input[data-time-end] {
|
|
318
|
+
grid-column: 4;
|
|
319
|
+
grid-row: 1;
|
|
320
|
+
min-inline-size: 0;
|
|
321
|
+
inline-size: 100%;
|
|
322
|
+
}
|
|
323
|
+
|
|
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
|
+
|
|
239
336
|
date-picker[range] > input:not([type="hidden"]) {
|
|
240
337
|
grid-column: 1;
|
|
241
338
|
}
|
|
242
339
|
|
|
243
340
|
date-picker[range] > input[data-range-start] {
|
|
244
341
|
grid-row: 1;
|
|
342
|
+
border-end-start-radius: 0;
|
|
245
343
|
}
|
|
246
344
|
|
|
247
345
|
date-picker[range] > input[data-range-end] {
|
|
248
346
|
grid-row: 2;
|
|
347
|
+
border-start-start-radius: 0;
|
|
249
348
|
}
|
|
250
349
|
|
|
251
350
|
.dp-picker-button {
|
|
@@ -340,19 +439,19 @@ date-picker[range] > .dp-picker-button {
|
|
|
340
439
|
color: GrayText;
|
|
341
440
|
}
|
|
342
441
|
}
|
|
343
|
-
`;var Rt=/^(\d{4})-(\d{2})-(\d{2})$/,Ot=/^(\d{4})-(\d{2})$/;function zt(t){return t%4===0&&(t%100!==0||t%400===0)}function X(t,e){if(e===2)return zt(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=Rt.exec(String(t||""));if(!e)return null;let i=Number(e[1]),s=Number(e[2]),n=Number(e[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>X(i,s))return null;return{year:i,month:s,day:n}}function l(t){return F(t)!==null}function f(t){let e=String(t||""),i=Ot.exec(e);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=F(e);if(!s)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function P(t,e,i){let s=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!l(s))throw TypeError(`Invalid civil date: ${s}`);return s}function J(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function Ht(t){return P(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function N(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e)}function w(t,e){if(!l(t)||!l(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function I(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let s=J(i);return s.setUTCDate(s.getUTCDate()+e),Ht(s)}function Q(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+e,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,X(n,a));return P(n,a,o)}function ht(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let s=i.year+e,n=Math.min(i.day,X(s,i.month));return P(s,i.month,n)}function V(t,e){let i=`${f(t)}-01`;return f(Q(i,e))}function Bt(t){return`${f(t)}-01`}function Vt(t){let e=F(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return P(e.year,e.month,X(e.year,e.month))}function Pt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e).getUTCDay()}function K(t){if(t===7)return 0;if(!Number.isInteger(t)||t<0||t>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return t}function tt(t,e=1){let i=(Pt(t)-K(e)+7)%7;return I(t,-i)}function it(t,e=1){return I(tt(t,e),6)}function ft(t,e={}){let i=e.firstDay??1,s=tt(Bt(t),i),n=it(Vt(t),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let c=0;c<7;c++)o.push(I(a,c));r.push(o),a=I(a,7)}return r}function pt(t,e="",i=""){if(!l(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&w(t,e)<0)return e;if(i&&w(t,i)>0)return i;return t}function R(){let t=new Date;return P(t.getFullYear(),t.getMonth()+1,t.getDate())}function mt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let i=J(e),s=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-s);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-n.getTime())/86400000+1)/7)}class st{constructor(t={}){let e=R();this.firstDay=K(t.firstDay??1),this.value=t.value&&l(t.value)?t.value:"",this.focused=t.focused&&l(t.focused)?t.focused:this.value||e,this.display=t.display?f(t.display):f(this.focused)}setValue(t){if(t&&!l(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=f(t),i=Number(this.focused.slice(8,10))||1,s=Q(`${e}-01`,0),n=I(s,Math.max(0,i-1));return this.focused=f(n)===e?n:I(`${V(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!l(t))throw TypeError(`Invalid focused date: ${t}`);if(this.focused=t,e.follow!==!1)this.display=f(t);return this.focused}moveFocusDays(t){return this.setFocused(I(this.focused,t))}moveFocusMonths(t){return this.setFocused(Q(this.focused,t))}moveFocusYears(t){return this.setFocused(ht(this.focused,t))}focusWeekStart(){return this.setFocused(tt(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(it(this.focused,this.firstDay))}navigateMonth(t){let e=V(this.display,t);return this.setDisplay(e),this.display}}function et(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:i=""}=t;if(e&&!l(e))throw TypeError(`Invalid range start: ${e}`);if(i&&!l(i))throw TypeError(`Invalid range end: ${i}`);if(!e&&i)throw TypeError("highlightedRange cannot define an end without a start");if(e&&i&&w(i,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:i}}function gt(t,e){if(!e||!l(t))return"";let{start:i,end:s}=e;if(!i||!l(i))return"";if(i===t)return s?s===t?"single":"start":"start";if(s&&s===t)return"end";if(s&&w(t,i)>=0&&w(t,s)<=0)return"in";return""}class nt{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&w(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}activate(t,e=()=>!0){if(!l(t))throw TypeError(`Invalid range activation: ${t}`);if(this.complete&&(w(t,this.start)<0||w(t,this.end)>0)){let i=w(t,this.start)<0?"start":"end";if(!e(i))return{status:"refused",endpoint:i};return this[i]=t,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&w(t,this.start)<0)return{status:"refused",endpoint:"end"};if(!e("end"))return{status:"refused",endpoint:"end"};return this.end=t,{status:this.start?"complete":"pending",endpoint:"end"}}if(!e("start"))return{status:"refused",endpoint:"start"};if(this.start=t,!e("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var yt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function H(t=""){if(t)return t;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Nt(t){let e=new Intl.NumberFormat(t,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(e.format(s),String(s));return i}function _t(t,e){let i=String(t||"").replace(yt,"").trim();for(let[s,n]of Nt(e))i=i.split(s).join(n);return i}function Y(t,e=""){let i=H(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(N(t))}function bt(t,e=""){let i=H(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(N(`${t.slice(0,7)}-15`))}function vt(t="",e="long"){let i=H(t),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(N(`2026-${String(r+1).padStart(2,"0")}-15`)))}function rt(t="",e=1,i="short"){let s=H(t),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=K(e),a=N("2026-01-04");return Array.from({length:7},(o,c)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+c)%7),n.format(d)})}function Ut(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(t=""){let e=H(t),i=new Intl.DateTimeFormat(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=N("2006-11-22"),n=i.formatToParts(s).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(yt,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let h=_t(d.value,e).replace(/\s+/g," ");return Ut(h).replace(/\\ /g,"\\s*")}).join(""),c=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(d){if(!l(d))return"";return i.format(N(d))},parse(d){let h=_t(d,e);if(l(h))return h;let E=c.exec(h);if(!E)return"";let g={};if(r.forEach((b,k)=>{g[b]=Number(E[k+1])}),!g.year||!g.month||!g.day)return"";try{return P(g.year,g.month,g.day)}catch{return""}}}}var Yt={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Wt={...Yt};function W(){return{...Wt}}function wt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,i=new Map;if(Array.isArray(e)){for(let s of e){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(e&&typeof e==="object")for(let[s,n]of Object.entries(e))i.set(s,n&&typeof n==="object"?n:{});return i}var jt=0;function A(t){return String(t).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Kt(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function qt(t){return Number(t.slice(0,4))}function Gt(t){switch(t){case"single":return' data-range-start="true" data-range-end="true"';case"start":return' data-range-start="true"';case"end":return' data-range-end="true"';case"in":return' data-in-range="true"';default:return""}}function Zt(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class G extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection"];constructor(){super();this._id=`date-calendar-${++jt}`,this._model=new st,this._connected=!1,this._rendering=!1,this._source=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._messages=W(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return H(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get value(){return this._model.value}set value(t){let e=t||"";if(e&&!l(e))throw TypeError(`Invalid calendar value: ${e}`);if(e===this._model.value)return;if(this._model.setValue(e),this._reflect("value",e),this._connected)this.render()}get display(){return this._model.display}set display(t){this._setDisplay(t,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(t){let e=t||"";if(e===this._model.focused)return;this.focusDate(e,{moveFocus:!1})}get min(){let t=this.getAttribute("min")||"";return l(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return l(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return Kt(this.getAttribute("first-day")||"1")}set firstDay(t){this.setAttribute("first-day",String(t))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(t){this.setAttribute("selection",t==="none"?"none":"single")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=et(t);if(e.start===this._highlightedRange.start&&e.end===this._highlightedRange.end)return;if(this._highlightedRange=e,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(t){this.toggleAttribute("fixed-weeks",Boolean(t))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(t){this.toggleAttribute("show-week-numbers",Boolean(t))}get messages(){return this._messages}set messages(t){if(this._messages={...W(),...t||{}},this._connected)this.render()}get source(){return this._source}set source(t){this._source=t||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._connected)this.render()}_syncModel(){let t=this.firstDay;this._model.firstDay=t;let e=this.getAttribute("value")||"";if(!e||l(e))this._model.value=e;let i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(i)}catch{}else if(this._model.value)this._model.display=f(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=f(this._model.focused)}_reflect(t,e){if(this._rendering=!0,e){if(this.getAttribute(t)!==e)this.setAttribute(t,e)}else if(this.hasAttribute(t))this.removeAttribute(t);this._rendering=!1}_clamp(t){return pt(t,this.min,this.max)}_weeks(t=this.display){let e=ft(t,{firstDay:this.firstDay});if(!this.fixedWeeks||e.length>=6)return e;let i=e[e.length-1]?.[6]||"";while(e.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(I(i,n));e.push(s),i=s[6]}return e}_focusTargetKey(t){if(t.matches(".dp-month-select, .dp-year-select, .dp-year-input")&&t.id)return`#${CSS.escape(t.id)}`;if(t.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(t.dataset.calendarAction||"")}"]`;if(t.matches(".dp-day[data-date]")){let e=t.getAttribute("data-date")||"";if(l(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),i=e[0],s=e[e.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},i=this._dateState?.(t,{...e})||{},s={...e,...i},n=this.min&&w(t,this.min)<0||this.max&&w(t,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(s.disabled)||a;return{...s,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(t){if(!l(t)||!this._source)return!0;return await this._loadDisplay(f(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let i=this._range(t),s=`${i.start}/${i.end}`;if(this._loadedRanges.has(s))return"loaded";if(s===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=s;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let c=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,h]of wt(c))this._sourceStates.set(d,h);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),e&&this._connected&&f(this.display)===f(t))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===s)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let i=this._model.display;if(this._model.setDisplay(t),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(e.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let t=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...t},bubbles:!0}))}previousMonth(){return this._setDisplay(V(this.display,-1))}nextMonth(){return this._setDisplay(V(this.display,1))}focusDate(t,e={}){if(!l(t))throw TypeError(`Invalid date: ${t}`);let i=this._clamp(t),s=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),s!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(t,e,i=!0){let s=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(t,e){if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async _activate(t){let e=await this.ensureDate(t),i=this.getDateState(t);if(!e||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:t,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:t,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(t),this._reflect("value",t),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:t},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(t)===this.display)this._moveSelectionDom(n,t);else this.render()}else if(this._connected){if(f(t)!==this.display)this.render()}return!0}_onClick(t){let e=t.target;if(!(e instanceof Element))return;let i=e.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let s=e.closest(".dp-day[data-date]");if(!(s instanceof HTMLTableCellElement))return;let n=s.dataset.date||"";if(!l(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this._activate(n)}_onChange(t){let e=t.target;if(e instanceof HTMLSelectElement&&e.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${e.value}`);return}if(e instanceof HTMLSelectElement&&e.matches(".dp-year-select")){this._setDisplay(`${e.value}-${this.display.slice(5,7)}`);return}if(e instanceof HTMLInputElement&&e.matches(".dp-year-input")){let i=Number(e.value);if(!Number.isInteger(i)||i<1||i>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||"";if(l(i))this._model.focused=i}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._activate(i);return}let s=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),t.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(t.key==="ArrowRight")this._model.moveFocusDays(1);else if(t.key==="ArrowUp")this._model.moveFocusDays(-7);else if(t.key==="ArrowDown")this._model.moveFocusDays(7);else if(t.key==="Home")this._model.focusWeekStart();else if(t.key==="End")this._model.focusWeekEnd();else if(t.key==="PageUp")t.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(t.key==="PageDown")t.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,i=this.display,s=qt(i),n=Number(i.slice(5,7)),r=vt(e,"long"),a=rt(e,this.firstDay,"short"),o=rt(e,this.firstDay,"long"),c=this._weeks(),d=R(),h=`${this._id}-heading`,E=`${this._id}-grid`,g=this.min?f(this.min):"",b=this.max?f(this.max):"",k=Boolean(g&&V(i,-1)<g),T=Boolean(b&&V(i,1)>b),x=this.min?` min="${Number(this.min.slice(0,4))}"`:"",_=this.max?` max="${Number(this.max.slice(0,4))}"`:"",m=this.showWeekNumbers&&this.firstDay===1,C=m?`<th scope="col" class="dp-week-heading" abbr="${A(this._messages.week)}">#</th>`:"",v=r.map((D,S)=>{let p=S+1,u=`${String(s).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=g&&u<g||b&&u>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${A(D)}</option>`}).join(""),B=a.map((D,S)=>`<th scope="col" abbr="${A(o[S])}">${A(D.replace(".",""))}</th>`).join(""),U=c.map((D)=>{let S=m?`<th scope="row" class="dp-week-number">${mt(D[0])}</th>`:"",p=D.map((u)=>{let y=this.getDateState(u),M=f(u)!==i,L=this.value===u,j=this.focusedDate===u,dt=u===d,lt=gt(u,this._highlightedRange),ct=Zt(lt),Lt=typeof y.description==="string"?y.description:"",It=[Y(u,e),Lt,ct?this._messages[ct]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${u}"${M?' data-outside-month="true"':""}${dt?' data-today="true" aria-current="date"':""}${L?' data-selected="true" aria-selected="true"':""}${Gt(lt)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${j?"0":"-1"}" aria-label="${A(It)}"><span class="dp-day-number" aria-hidden="true">${Number(u.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${S}${p}</tr>`}).join(""),O=document.activeElement,z=O instanceof HTMLElement&&this.contains(O)?this._focusTargetKey(O):"";if(this._rendering=!0,this.innerHTML=`
|
|
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("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}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=`
|
|
344
445
|
<div class="dp-calendar-shell">
|
|
345
446
|
<div class="dp-calendar-header">
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
<
|
|
349
|
-
<
|
|
350
|
-
<button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${A(this._messages.previousMonth)}"${k?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10 4-4 4 4 4"/></svg></button>
|
|
351
|
-
<button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${A(this._messages.nextMonth)}"${T?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 4 4 4-4 4"/></svg></button>
|
|
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>
|
|
352
451
|
</div>
|
|
353
|
-
<h2 id="${
|
|
354
|
-
<table id="${
|
|
355
|
-
<thead><tr>${
|
|
356
|
-
<tbody>${
|
|
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>
|
|
357
456
|
</table>
|
|
358
|
-
</div>`,this._rendering=!1,z)queueMicrotask(()=>{let D=this.querySelector(z);if(D instanceof HTMLElement)D.focus()});if(this._renderDay)for(let D of this.querySelectorAll(".dp-day[data-date]")){if(!(D instanceof HTMLTableCellElement))continue;let S=D.dataset.date||"",p=D.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let u=this._renderDay(S,this.getDateState(S));if(u instanceof Node)p.append(u);else if(u!==void 0&&u!==null)p.textContent=String(u)}if(t)this._loadDisplay(i)}}function At(t){return t==="top"||t==="bottom"?"x":"y"}function Xt(t){let[e,i=null]=t.split("-");return{side:e,align:i,crossAxis:At(e)}}function Jt(t){return{top:"bottom",bottom:"top",left:"right",right:"left"}[t]||t}function Qt(t,e,i,s,n,r){let a=At(i),o=t.x+t.width/2-e.width/2,c=t.y+t.height/2-e.height/2,d=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(i){case"top":h={x:o,y:t.y-e.height-r};break;case"bottom":h={x:o,y:t.y+t.height+r};break;case"right":h={x:t.x+t.width+r,y:c};break;case"left":h={x:t.x-e.width-r,y:c};break;default:h={x:t.x,y:t.y}}if(s==="start"||s==="end"){let E=(n&&a==="x"?-1:1)*(s==="end"?1:-1);h[a]+=d*E}return h}function te(t,e,i,s){return Math.max(i-t,0)+Math.max(t+e-s,0)}function ee(t){let e="dir"in t?t.dir:"";if(e==="rtl")return!0;if(e==="ltr")return!1;let i=t.ownerDocument?.defaultView;if(i?.CSS?.supports?.("selector(:dir(rtl))")&&typeof t.matches==="function")return t.matches(":dir(rtl)");return Boolean(i?.Element&&t instanceof i.Element&&i.getComputedStyle(t).direction==="rtl")}var ie=25;function se(t){let e=t.defaultView;if(!e)return null;let i=t.documentElement,s=e.visualViewport,n=s?.offsetLeft||0,r=s?.offsetTop||0,a=s?.width||i.clientWidth||e.innerWidth,o=s?.height||i.clientHeight||e.innerHeight,c=t.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(c>0&&c<=ie){let d=e.getComputedStyle?.(i).scrollbarGutter;if(d&&d!=="auto")a-=c}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ne(t,e){return e.scope?e.scope.getBoundingClientRect():se(t.ownerDocument)}function xt(t,e,i,s,n){let r=i+n,a=s-e-n,o=a>=r,c=o?r:i,d=o?a:s-e;return Math.max(c,Math.min(t,d))}function Dt(t,e,i){if(!i)return 50;let s=(t-e)/i*100;return Math.round(Math.min(100,Math.max(0,s))*1000)/1000}function re(t,e){return t.right<e.x||t.left>e.right||t.bottom<e.y||t.top>e.bottom}function ae(t,e,i,s,n){if(e==="top")return Math.max(0,t.top-i.y-s-n);if(e==="bottom")return Math.max(0,i.bottom-t.bottom-s-n);return Math.max(0,i.height-n*2)}function oe(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function Tt(t){let{offsetWidth:e,offsetHeight:i}=t;if(e&&i)return{width:e,height:i};let s=t.getBoundingClientRect();return{width:e||s.width,height:i||s.height}}var Et=new WeakMap,kt={scroll:0,resize:1,"element-resize":2};function de(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,s=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function c(x,_){let m=s.get(x);if(m===void 0||kt[_]>kt[m])s.set(x,_)}function d(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let x=[...s];s.clear(),r=!1;for(let[_,m]of x){if(!i.has(_)||!_.floating.isConnected)continue;_.callback({type:m})}})}function h(x){for(let _ of i)c(_,x);d()}function E(x){if(!n)return null;let _=new Set,m=new n((B)=>{let U=!1;for(let O of B)if(_.has(O.target))U=!0;else _.add(O.target);if(!U)return;c(x,"element-resize"),d()}),{reference:C,floating:v}=x;if(C)m.observe(C);if(v!==C)m.observe(v);return m}let g=()=>h("scroll"),b=()=>h("resize");function k(){if(a)return;t.addEventListener("scroll",g,{passive:!0,capture:!0}),e.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",g,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function T(){if(!a)return;t.removeEventListener("scroll",g,{capture:!0}),e.removeEventListener("resize",b),o?.removeEventListener("scroll",g),o?.removeEventListener("resize",b),a=!1}return{add(x,_,m){let C={reference:x,floating:_,callback:m};i.add(C),k();let v=E(C),B=!1;return()=>{if(B)return;if(B=!0,i.delete(C),s.delete(C),v?.disconnect(),i.size===0)T()}}}}function le(t){let e=t.ownerDocument,i=Et.get(e);if(!i)i=de(e),Et.set(e,i);return i}function St(t,e,i){if(!e?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(t&&t.ownerDocument!==e.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return le(e).add(t,e,i)}function Ct(t,e,i){if(!oe(e))return null;let s=i.placement||"bottom-start",n=i.distance||0,r=i.flip!==!1,a=i.shift!==!1,o=i.shiftPadding??4,{side:c,align:d,crossAxis:h}=Xt(s),E=d?ee(t):!1,g=t.getClientRects(),b=c==="bottom"?g[g.length-1]:g[0];if(!b)return null;let k=ne(t,i);if(!k||re(b,k))return null;let T=Tt(e),x={x:{size:T.width,start:k.x,end:k.right},y:{size:T.height,start:k.y,end:k.bottom}},_=(p,u)=>Qt(b,T,p,u,E,n),m=(p,u)=>{let{size:y,start:M,end:L}=x[u];return te(p,y,M+o,L-o)},C=(p,u)=>{let{size:y,start:M,end:L}=x[u];return m(a?xt(p,y,M,L,o):p,u)},v=_(c,d);if(r){let p=h==="x"?"y":"x",u=m(v[p],p);if(u>0){let y=Jt(c),M=_(y,d),L=m(M[p],p);if(L<u)c=y,v=M,u=L}if(p==="x"&&u>0){let y=_("top",d),M=_("bottom",d),L=m(M.y,"y")<m(y.y,"y"),j=L?M:y;if(m(j.y,"y")+C(j.x,"x")<u+C(v.y,"y"))c=L?"bottom":"top",h="x",v=j}}if(h==="x"&&a&&d){let p=m(v.x,"x");if(p>0){let u=d==="end"?"start":"end",y=_(c,u);if(m(y.x,"x")<p)d=u,v=y}}if(a){let{size:p,start:u,end:y}=x[h];v[h]=xt(v[h],p,u,y,o)}let B=Dt(b.x+b.width/2,v.x,T.width),U=Dt(b.y+b.height/2,v.y,T.height),O=`${ae(b,c,k,n,o)}px`,{style:z}=e,D=z.getPropertyValue("--available-height")!==O;z.left=`${v.x}px`,z.top=`${v.y}px`,z.setProperty("--arrow-x",`${B}%`),z.setProperty("--arrow-y",`${U}%`),z.setProperty("--available-height",O);let S=d?`${c}-${d}`:c;return e.dataset.placement=S,{width:T.width,height:T.height,roomChanged:D,placement:S}}function Mt(t,e,i={}){let s=Ct(t,e,i);if(!s)return!1;if(s.roomChanged){let n=Tt(e);if(n.width!==s.width||n.height!==s.height)Ct(t,e,{...i,placement:s.placement,flip:!1})}return!0}class Z{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=q(e.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._originalName=t.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null}setLocale(t){this.adapter=q(t||"")}setMessages(t){this.messages=t||{}}format(t){return this.adapter.format(t)}parse(t){return this.adapter.parse(t)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let t=this.input;this._originalName=t.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(t,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let t=this.input,e=t.getAttribute("name")||"";if(e){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,t.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=e;t.removeAttribute("name")}if(this.hidden){if(t.hasAttribute("form"))this.hidden.setAttribute("form",t.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=t.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let t=this.input;if(this._dirty=!0,this.dirty(),this.hidden)this.hidden.value="";let e=t.value.trim();if(!e){t.setCustomValidity("");return}let i=this.canonical?this.adapter.format(this.canonical):"";t.setCustomValidity(e===i?"":this.messages.invalidDate)}async commit(){let t=this.input,e=++this._commitId,i=t.value.trim();if(!i){if(e!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(i);if(!s){if(e!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return t.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let n=await this.confirm(s);if(e!==this._commitId)return{status:"stale"};if(!n?.ok){if(this.hidden)this.hidden.value="";return t.setCustomValidity(n?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:s}}setCanonical(t,e={}){let i=t||"";if(i&&!l(i))throw TypeError(`Invalid date-picker value: ${i}`);if(this.dirty(),this.canonical=i,this._dirty=!1,this.hidden)this.hidden.value=i;if(e.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=l(t)?t:this.adapter.parse(t);return e&&l(e)?e:""}teardown(){this._attributeObserver?.disconnect(),this._attributeObserver=null;let t=this.hidden?.getAttribute("name")||this._originalName;if(t)this.input.setAttribute("name",t);this.hidden?.remove(),this.hidden=null}}var ce=0;class at extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus"];constructor(){super();this._id=`date-picker-${++ce}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._button=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=W(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._field=new Z(t,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(s)=>this._confirmDate(s),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let e=this._adapter(),i=this.getAttribute("value")||(l(t.value)?t.value:e.parse(t.value));if(i&&l(i))this._setValue(i,{emit:!1,format:!0});else if(!t.value)this._setValue("",{emit:!1,format:!1});else t.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}_connectRange(){let t=this.querySelector(":scope > input[data-range-start]"),e=this.querySelector(":scope > input[data-range-end]");if(!(t instanceof HTMLInputElement)||!(e instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new Z(t,{messages:this._messages,locale:this.locale}),new Z(e,{messages:this._messages,locale:this.locale})],this._range=new nt,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a)=>this._confirmDate(a),r.setupFormValue();this._build(e),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),s=l(t.value)?t.value:i.parse(t.value),n=l(e.value)?e.value:i.parse(e.value);if(this._setRange(s||"",n||"",{emit:!1}),t.value.trim()&&!l(s))t.setCustomValidity(this._messages.invalidDate);if(e.value.trim()&&!l(n))e.setCustomValidity(this._messages.invalidDate);if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._rangeMode()){for(let t of this._fields||[])this._teardownField(t);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null,this._button?.remove(),this._panel?.remove(),this._formatHint?.remove(),this._button=null,this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(t){if(!t)return;let e=t.input,i=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),i)e.setAttribute("aria-describedby",i);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,i){if(!this._connected||this._reflecting||e===i)return;if(t==="value"){if(this._rangeMode())return;if(!i||l(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(t==="locale")this._refreshLocale();if(t==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(t){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(t&&!l(t))throw TypeError(`Invalid date-picker value: ${t}`);this._setValue(t||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(t){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:e,end:i}=et(t);this._setRange(e,i)}get locale(){return H(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get min(){let t=this.getAttribute("min")||"";return l(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return l(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(t){if(t===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get messages(){return this._messages}set messages(t){if(this._messages={...W(),...t||{}},this._calendar)this._calendar.messages=this._messages;for(let e of this._fields||[])e.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(t){if(this._source=t||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??q(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;if(this._field?.syncInputState(),this._button)this._button.disabled=t.disabled||t.readOnly;if(this._open&&(t.disabled||t.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let i of this._fields)i.syncInputState();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields.every((i)=>i.input.disabled||i.input.readOnly);if(this._button)this._button.disabled=e;if(this._open&&(this._fields[t]?.input.disabled||this._fields[t]?.input.readOnly))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let t of this._fields){let e=t.input,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",i),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",this._panel.id)}}_build(t){let e=t||this._input;if(!e)return;let i=`${this._id}-panel`,s=`${this._id}-format`,n=document.createElement("button");n.type="button",n.className="dp-picker-button",n.setAttribute("aria-haspopup","dialog"),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-controls",i),n.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>';let r=document.createElement("div");r.id=i,r.className="dp-picker-panel",r.setAttribute("popover","manual"),r.setAttribute("role","dialog"),r.setAttribute("aria-label",this._messages.calendar);let a=new G;a.selection="none",a.fixedWeeks=!0,r.append(a);let o=document.createElement("span");if(o.id=s,o.className="dp-visually-hidden",e.insertAdjacentElement("afterend",n),n.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",o),this._button=n,this._panel=r,this._calendar=a,this._formatHint=o,!this._rangeMode()){this._originalDescribedBy=e.getAttribute("aria-describedby")||"";let c=[this._originalDescribedBy,s].filter(Boolean).join(" ");e.setAttribute("aria-describedby",c),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let t=this._input,e=this._button,i=this._calendar;if(!t||!e||!i)return;let s=new AbortController;this._controller=s;let{signal:n}=s;t.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),t.addEventListener("change",()=>void this._commitText(!1),{signal:n}),t.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),t.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),t.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n}),e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:n}),i.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!l(o))return;queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(this._input?.disabled||this._input?.readOnly)return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._focusInput()})},{signal:n}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:n}),this.ownerDocument.addEventListener("reset",(r)=>{let a=r.target;if(a instanceof HTMLFormElement&&this._input&&a===this._input.form)this.hide(!1),queueMicrotask(()=>{if(!r.defaultPrevented)this._restoreDefault()})},{capture:!0,signal:n}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:n})}_bindRange(){let t=this._button,e=this._calendar;if(!this._fields||!t||!e)return;let i=new AbortController;this._controller=i;let{signal:s}=i;for(let[n,r]of this._fields.entries()){let a=n===1?"end":"start";r.input.addEventListener("input",()=>r.handleInput(),{signal:s}),r.input.addEventListener("change",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("blur",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("focus",(o)=>this._onFieldFocus(a,o),{signal:s}),r.input.addEventListener("keydown",(o)=>this._onFieldKeyDown(a,o),{signal:s})}t.addEventListener("click",(n)=>{if(this._open){if(n.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:s}),e.addEventListener("click",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),e.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),e.addEventListener("dateactivate",(n)=>{let r=n,a=r.detail?.date;if(!l(a))return;queueMicrotask(()=>{if(r.defaultPrevented||!this._connected||!this._range)return;let o=this._pendingIntents.get(a);if(o===void 0||o!==this._rangeCommitId)return;this._pendingIntents.delete(a);let c=this._range.activate(a,(d)=>{let h=d==="end"?1:0,E=this._fields?.[h];return E!=null&&!E.input.disabled&&!E.input.readOnly});if(c.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:a,state:this._calendar.getDateState(a)},bubbles:!0}));return}if(this._setBound(c.endpoint,a,{emit:!0,user:!0}),c.close||c.status==="complete")this.hide(!1),this._focusField(c.endpoint)})},{signal:s}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:s}),this.ownerDocument.addEventListener("reset",(n)=>{let r=n.target;if(r instanceof HTMLFormElement&&this._fields&&r===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!n.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:s}),this.addEventListener("keydown",(n)=>this._onEscape(n),{signal:s})}_onFieldKeyDown(t,e){if(e.key==="ArrowDown"||e.altKey&&e.key==="ArrowDown"){if(e.preventDefault(),this._rangeMode()&&t)this._lastFocusEndpoint=t,this._range?.focus(t);if(this._open)setTimeout(()=>this._calendar?.focusGrid(),0);else this.show()}else if(e.key==="Escape"&&this._open)e.preventDefault(),this.hide(!1)}_onFieldFocus(t,e){if(!this._rangeMode()||!t)return;let i=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let s=e.relatedTarget;if(s instanceof Node&&this.contains(s))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(!this._rangeMode()||!this._range)return;if(t.type==="keydown"){let s=t.key;if(s!=="Enter"&&s!==" ")return}if(!(t.target instanceof Element))return;let i=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!l(i))return;this._pendingIntents.set(i,++this._rangeCommitId)}_onEscape(t){if(t.key==="Escape"&&this._open)t.preventDefault(),t.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let t=this._calendar,e=this._panel;if(!t)return;if(t.locale=this.locale,t.min=this.min,t.max=this.max,t.messages=this._messages,t.source=this._source,t.dateState=this._dateState,t.renderDay=this._renderDay,t.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)t.value=this._value;if(e)e.setAttribute("aria-label",this._messages.calendar)}_refreshLocale(){let t=this._formatHint;if(!t)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),t.textContent=`${this._messages.formatHint}: ${this._fields[0].placeholder}`;for(let[i,s]of this._fields.entries()){if(!s.input.hasAttribute("placeholder")||this._generatedPlaceholder)s.input.placeholder=s.placeholder,this._generatedPlaceholder=!0;let n=i===1?this._range?.end||"":this._range?.start||"";if(n)s.input.value=s.format(n)}this._refreshButtonLabel();return}let e=this._field;if(!e)return;if(e.setLocale(this.locale),t.textContent=`${this._messages.formatHint}: ${e.placeholder}`,!e.input.hasAttribute("placeholder")||this._generatedPlaceholder)e.input.placeholder=e.placeholder,this._generatedPlaceholder=!0;if(this._value)e.input.value=e.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){if(!this._button)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let t=this._value?this._messages.changeDate:this._messages.chooseDate,e=this._value?`, ${Y(this._value,this.locale)}`:"";this._button.setAttribute("aria-label",`${t}${e}`)}_refreshRangeButtonLabel(){if(!this._button||!this._range)return;let{start:t,end:e}=this._range,i=Boolean(t&&e),s=i?this._messages.changeDate:this._messages.chooseDate,n=i?`, ${Y(t,this.locale)} – ${Y(e,this.locale)}`:"";this._button.setAttribute("aria-label",`${s}${n}`)}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!l(t))throw TypeError(`Invalid date-picker value: ${t}`);let i=this._value;if(this._value=t||"",e.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:e.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let s=this._field.input;s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t){let e=this._calendar;if(!e)return{ok:!0};let i=f(t);if(e.display!==i)e.display=i;let s=await e.ensureDate(t),n=e.getDateState(t);if(!s||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let i=this._field;if(!i)return!1;if(!e.force&&!i.isDirty)return!1;let s=await i.commit();if(s.status==="stale"||s.status==="invalid")return!1;return this._setValue(s.value||"",{emit:t,format:s.status==="ok"}),!0}async _commitFieldText(t){let e=this._fields;if(!e)return!1;let i=t==="end"?1:0,s=e[i];if(!s?.isDirty)return!1;let n=await s.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(t,n.value||"",{emit:!0,user:!0,format:n.status==="ok"}),!0}_setBound(t,e,i={}){if(!this._range)return!1;let s=this._fields;if(!s)return!1;let r=s[t==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),t==="end")this._range.end=a;else this._range.start=a;let c=o!==a;if(c){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),i.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(t),c}_setRange(t,e,i={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:i.format!==!1}),this._fields[1].setCanonical(e||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(t){return this._range?t==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_syncHighlight(){if(!this._calendar||!this._range)return;let{start:t,end:e}=this._range;if(!t){this._calendar.highlightedRange={start:"",end:""};return}if(e&&w(e,t)<0)this._calendar.highlightedRange={start:t,end:""};else this._calendar.highlightedRange={start:t,end:e}}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:i}=this._range,s=Boolean(e&&i&&w(i,e)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,c=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(s&&r===t)o.setCustomValidity(c),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_restoreDefault(){let t=this._field;if(!t)return;let e=t.restoreDefault();if(this._setValue(e,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=f(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=f(R()),this._calendar.focusedDate=R();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let t=this._fields[0].restoreDefault(),e=this._fields[1].restoreDefault();if(this._setRange(t,e),this._calendar){let i=this._range?.start||R();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(t){let e=t==="end"?1:0,i=this._fields?.[e]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_focusInput(){this._suppressFocusOpen=!0,setTimeout(()=>{this._input?.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(!this._fields[e].input.disabled&&!this._fields[e].input.readOnly)return t;let i=t==="end"?"start":"end",s=i==="end"?1:0;if(!this._fields[s].input.disabled&&!this._fields[s].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let e=this._fields;if(!e)return!0;for(let[i,s]of e.entries()){let n=await s.commit();if(n.status==="ok"||n.status==="clear"){let r=i===1?"end":"start";this._setBound(r,n.value||"",{format:n.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),e.every((i)=>i.input.checkValidity())}let t=this._field?.input;if(!t)return!0;if(!t.value.trim())return t.setCustomValidity(""),t.checkValidity();return await this._commitText(!1,{force:!0}),t.checkValidity()}show(t={}){let e=this._panel,i=this._calendar,s=this._button;if(!e||!i||!s||this._open)return;if(this._rangeMode()){let r=this._resolveRangeEndpoint();if(!r)return;this._range?.focus(r),this._rangeCommitId++,this._pendingIntents.clear();let a=this._boundCanonical(r)||R();i.display=f(a),i.focusedDate=a,this._lastFocusEndpoint=r}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||R();i.display=f(a),i.focusedDate=a}e.showPopover(),this._open=!0,this._setExpanded(!0);let n=()=>Mt(this,e,{placement:"bottom-start",distance:4,shiftPadding:8});if(n(),this._stopTracking=St(this,e,n),t.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(t){let e=t?"true":"false";this._input?.setAttribute("aria-expanded",e),this._button?.setAttribute("aria-expanded",e);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",e)}hide(t=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._focusInput();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let t=this._range?.activeEndpoint||"";if(t){let e=t==="end"?1:0,i=this._fields?.[e];if(i&&!i.input.disabled&&!i.input.readOnly)return t}return this._resolveRangeEndpoint()}}function ot(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",G);if(!customElements.get("date-picker"))customElements.define("date-picker",at)}ot();var $t="lekoala-date-picker-styles";if(!document.getElementById($t)){let t=document.createElement("style");t.id=$t,t.textContent=ut,document.head.append(t)}ot();})();
|
|
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();})();
|
|
@@ -103,6 +103,9 @@ export declare class DateCalendarElement extends HTMLElement {
|
|
|
103
103
|
/** @public */
|
|
104
104
|
get selection(): "none" | "single";
|
|
105
105
|
set selection(value: string);
|
|
106
|
+
/** @public Visible month-name style in the month select (`long` | `short`); anything else falls back to `long`. The accessible grid heading always keeps the long month/year form. */
|
|
107
|
+
get monthFormat(): "long" | "short";
|
|
108
|
+
set monthFormat(value: string);
|
|
106
109
|
/** @public */
|
|
107
110
|
get highlightedRange(): {
|
|
108
111
|
start: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-calendar.d.ts","sourceRoot":"","sources":["../../src/date-calendar.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"date-calendar.d.ts","sourceRoot":"","sources":["../../src/date-calendar.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAmFhD,YAAqC,SAAS,GAApC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAA,GAAG,EAAC,MAAM,CAAA;CAAC,CAAW;AAC9C,YAA8E,SAAS,GAA7E,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAC,QAAQ,CAAC,EAAC,OAAO,CAAC;IAAC,WAAW,CAAC,EAAC,MAAM,CAAA;CAAC,CAAW;AACvF,YAAyF,UAAU,GAAzF,CAAC,KAAK,EAAC,SAAS,EAAE,OAAO,EAAC;IAAC,MAAM,EAAC,WAAW,CAAA;CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAY;AACnG,YAA0C,UAAU,GAA1C,UAAU,GAAG;IAAC,IAAI,EAAC,UAAU,CAAA;CAAC,CAAY;AACpD,YAAgF,iBAAiB,GAAvF,CAAC,IAAI,EAAC,MAAM,EAAE,WAAW,EAAC,SAAS,KAAK,SAAS,GAAG,IAAI,GAAG,SAAS,CAAmB;AACjG,YAA8E,WAAW,GAA/E,CAAC,IAAI,EAAC,MAAM,EAAE,KAAK,EAAC,SAAS,KAAK,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAa;AACzF,YAAoC,qBAAqB,GAA/C,CAAC,IAAI,EAAC,MAAM,KAAK,OAAO,CAAuB;AAhB7D;;;;;;;;;GASG;AACH,qDAAqD;AACrD,8FAA8F;AAC9F,0GAA0G;AAC1G,2DAA2D;AAC3D,wGAAwG;AACxG,gGAAgG;AAChG,gEAAgE;AAEhE,qBAAa,mBAAoB,SAAQ,WAAW;IAgB3C,GAAG;IACH,MAAM;IACN,UAAU;IACV,UAAU;IACf,gCAAgC;IAC3B,OAAO,EADD,UAAU,GAAG,IAAI;IAEvB,aAAa;IACb,aAAa;IACb,eAAe;IACf,WAAW;IAChB,gEAAgE;IAC3D,eAAe,EADT,OAAO,CAAC,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC,GAAG,IAAI;IAE5D,uCAAuC;IAClC,UAAU,EADJ,iBAAiB,GAAG,IAAI;IAEnC,iCAAiC;IAC5B,UAAU,EADJ,WAAW,GAAG,IAAI;IAE7B,2CAA2C;IACtC,eAAe,EADT,qBAAqB,GAAG,IAAI;IAEvC,wBAAwB;IACnB,iBAAiB,EADX,SAAS;IAEf,SAAS;;;;;;;;;;;;;;;;;;;;IAnChB,MAAM,CAAC,kBAAkB,WAWvB;IAEF,cA2BC;IAED,iBAAiB,SAShB;IAED,oBAAoB,SAUnB;IAED,wBAAwB,SAIvB;IAED,cAAc;IACd,IAAI,MAAM,WAET;IAED,IAAI,MAAM,CAAC,KAAK,QAAA,EAGf;IAED,cAAc;IACd,IAAI,KAAK,WAER;IAED,IAAI,KAAK,CAAC,KAAK,QAAA,EAOd;IAED,cAAc;IACd,IAAI,OAAO,WAEV;IAED,IAAI,OAAO,CAAC,KAAK,QAAA,EAEhB;IAED,cAAc;IACd,IAAI,WAAW,WAEd;IAED,IAAI,WAAW,CAAC,KAAK,QAAA,EAIpB;IAED,cAAc;IACd,IAAI,GAAG,WAGN;IAED,IAAI,GAAG,CAAC,KAAK,QAAA,EAGZ;IAED,cAAc;IACd,IAAI,GAAG,WAGN;IAED,IAAI,GAAG,CAAC,KAAK,QAAA,EAGZ;IAED,cAAc;IACd,IAAI,QAAQ,WAEX;IAED,IAAI,QAAQ,CAAC,KAAK,QAAA,EAEjB;IAED,cAAc;IACd,IAAI,SAAS,sBAEZ;IAED,IAAI,SAAS,CAAC,KAAK,QAAA,EAElB;IAED,sLAAsL;IACtL,IAAI,WAAW,qBAEd;IAED,IAAI,WAAW,CAAC,KAAK,QAAA,EAGpB;IAED,cAAc;IACd,IAAI,gBAAgB;eA/KD,MAAM;aAAK,MAAM;MAiLnC;IAED,IAAI,gBAAgB,CAAC,KAAK;eAnLP,MAAM;aAAK,MAAM;KAmLV,EAKzB;IAED,cAAc;IACd,IAAI,UAAU,YAEb;IAED,IAAI,UAAU,CAAC,KAAK,SAAA,EAEnB;IAED,cAAc;IACd,IAAI,eAAe,YAElB;IAED,IAAI,eAAe,CAAC,KAAK,SAAA,EAExB;IAED,cAAc;IACd,IAAI,QAAQ;;;;;;;;;;;;;;;;;;;MAEX;IAED,IAAI,QAAQ,CAAC,KAAK;;;;;;;;;;;;;;;;;;;KAAA,EAGjB;IAED,2CAA2C;IAC3C,IAAI,MAAM,IADY,UAAU,GAAG,IAAI,CAGtC;IAED,IAAI,MAAM,CAAC,KAAK,EALM,UAAU,GAAG,IAKnB,EAGf;IAED,kDAAkD;IAClD,IAAI,SAAS,IADS,iBAAiB,GAAG,IAAI,CAG7C;IAED,IAAI,SAAS,CAAC,KAAK,EALG,iBAAiB,GAAG,IAKvB,EAGlB;IAED,4CAA4C;IAC5C,IAAI,SAAS,IADS,WAAW,GAAG,IAAI,CAGvC;IAED,IAAI,SAAS,CAAC,KAAK,EALG,WAAW,GAAG,IAKjB,EAGlB;IAED,sDAAsD;IACtD,IAAI,cAAc,IADI,qBAAqB,GAAG,IAAI,CAGjD;IAED,IAAI,cAAc,CAAC,KAAK,EALF,qBAAqB,GAAG,IAKtB,EAGvB;IAED,UAAU,SAkBT;IAED,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EADD,MACC,EAAE,KAAK,EADa,MACb,QAQnB;IAED,4BAA4B;IAC5B,MAAM,CAAC,KAAK,EADA,MACA,UAEX;IAED,MAAM,CAAC,OAAO,SAAe,cAW5B;IAED,qDAAqD;IACrD,eAAe,CAAC,OAAO,EADX,WACW,GADoB,MAAM,CAahD;IAED,gCAAgC;IAChC,MAAM,CAAC,OAAO,AADV,CAAyB,EAAjB,MACiB;QAKlB,KAAK;QAAY,GAAG;MAC9B;IAED,mCAAmC;IACnC,YAAY,CAAC,IAAI,EADG,MACH,OAWhB;IAED,cAAc;IACR,aAAa,kBAWlB;IAED;0DACsD;IAChD,UAAU,CAAC,IAAI,EADV,MACU,GADa,OAAO,CAAC,OAAO,CAAC,CAIjD;IAED,gHAAgH;IAC1G,YAAY,CAAC,OAAO,EADd,MACc,EAAE,QAAQ,AADR,CAA4B,EAApB,OACO,GADuB,OAAO,CAAC,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC,CA0C3G;IAED,iEAAiE;IACjE,WAAW,CAAC,OAAO,EADP,MACO,EAAE,OAAO,AADA,CAAkC,EAA1B;QAAC,IAAI,CAAC,EAAC,OAAO,CAAA;KACjB,UAShC;IAED,kBAAkB,SAQjB;IAED,cAAc;IACd,aAAa,WAEZ;IAED,cAAc;IACd,SAAS,WAER;IAED,2EAA2E;IAC3E,SAAS,CAAC,IAAI,EADM,MACN,EAAE,OAAO,AADU,CAAuC,EAA/B;QAAC,SAAS,CAAC,EAAC,OAAO,CAAA;KAChC,QAgB3B;IAED,iFAAiF;IACjF,aAAa,CAAC,QAAQ,EADV,MACU,EAAE,IAAI,EADS,MACT,EAAE,SAAS,AADW,CAA4B,EAApB,OACZ,QAU7C;IAED,8DAA8D;IAC9D,iBAAiB,CAAC,aAAa,EADnB,MACmB,EAAE,SAAS,EADA,MACA,WAiBzC;IAED,cAAc;IACd,SAAS,SAGR;IAED,uDAAuD;IACjD,SAAS,CAAC,IAAI,EADR,MACQ,GADe,OAAO,CAAC,OAAO,CAAC,CAkClD;IAED,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EADF,UACE,QAmBb;IAED,2BAA2B;IAC3B,SAAS,CAAC,KAAK,EADH,KACG,QAkBd;IAED,gCAAgC;IAChC,UAAU,CAAC,KAAK,EADJ,UACI,QAKf;IAED,mCAAmC;IACnC,UAAU,CAAC,KAAK,EADJ,aACI,QAgCf;IAED,sCAAsC;IACtC,MAAM,CAAC,IAAI,AADC,CAAuB,EAAf,OACF,QAoIjB;CACF"}
|