@lekoala/date-picker 0.1.0 → 0.1.1

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 CHANGED
@@ -10,12 +10,14 @@ This project fills the gap between a normal editable date field and a full sched
10
10
 
11
11
  ### `<date-calendar>`
12
12
 
13
- An inline calendar with real month/year navigation, keyboard support and three separate pieces of state:
13
+ An inline calendar with real month/year navigation, keyboard support and three distinct pieces of state:
14
14
 
15
15
  - `display` — the month being rendered (`YYYY-MM`);
16
16
  - `focusedDate` — the roving keyboard target (`YYYY-MM-DD`);
17
17
  - `value` — the selected date (`YYYY-MM-DD`, optional).
18
18
 
19
+ `display` and `focusedDate` are coupled during navigation/display: changing the displayed month re-clamps the focused day into that month, because the roving-tabbable grid cell must stay visible. `value` and activation stay independent of both.
20
+
19
21
  User activation is exposed separately as `dateactivate`. This is what makes the same calendar useful as a selector **and** as a mini navigator.
20
22
 
21
23
  ```html
@@ -104,12 +104,9 @@ date-calendar {
104
104
  background: var(--dp-hover);
105
105
  }
106
106
 
107
- .dp-calendar-heading {
108
- margin: 0 0 0.35rem;
109
- font-size: 0.875rem;
110
- font-weight: 600;
111
- text-align: center;
112
- }
107
+ /* .dp-calendar-heading is always visually hidden: it names the grid via
108
+ aria-labelledby and stays the aria-live announcement channel while the
109
+ month/year selects render the same info visually. */
113
110
 
114
111
  .dp-grid {
115
112
  border-collapse: separate;
@@ -1,4 +1,4 @@
1
- /*** @lekoala/date-picker v0.1.0 - https://github.com/lekoala/date-picker ***/
1
+ /*** @lekoala/date-picker v0.1.1 - https://github.com/lekoala/date-picker ***/
2
2
  (() => {
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -156,10 +156,15 @@
156
156
  throw new TypeError(`Invalid civil date: ${value}`);
157
157
  return toUTCDate(parsed).getUTCDay();
158
158
  }
159
- function startOfWeek(value, firstDay = 1) {
159
+ function normalizeFirstDay(firstDay) {
160
+ if (firstDay === 7)
161
+ return 0;
160
162
  if (!Number.isInteger(firstDay) || firstDay < 0 || firstDay > 6)
161
- throw new RangeError("firstDay must be 0..6");
162
- const offset = (dayOfWeek(value) - firstDay + 7) % 7;
163
+ throw new RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");
164
+ return firstDay;
165
+ }
166
+ function startOfWeek(value, firstDay = 1) {
167
+ const offset = (dayOfWeek(value) - normalizeFirstDay(firstDay) + 7) % 7;
163
168
  return addDays(value, -offset);
164
169
  }
165
170
  function endOfWeek(value, firstDay = 1) {
@@ -210,7 +215,7 @@
210
215
  class CalendarModel {
211
216
  constructor(options = {}) {
212
217
  const today = todayISO();
213
- this.firstDay = options.firstDay ?? 1;
218
+ this.firstDay = normalizeFirstDay(options.firstDay ?? 1);
214
219
  this.value = options.value && isDate(options.value) ? options.value : "";
215
220
  this.focused = options.focused && isDate(options.focused) ? options.focused : this.value || today;
216
221
  this.display = options.display ? monthKey(options.display) : monthKey(this.focused);
@@ -394,10 +399,11 @@
394
399
  weekday: style,
395
400
  timeZone: "UTC"
396
401
  });
402
+ const normalized = normalizeFirstDay(firstDay);
397
403
  const sunday = toIntlDate("2026-01-04");
398
404
  return Array.from({ length: 7 }, (_, index) => {
399
405
  const date = new Date(sunday);
400
- date.setUTCDate(sunday.getUTCDate() + (firstDay + index) % 7);
406
+ date.setUTCDate(sunday.getUTCDate() + (normalized + index) % 7);
401
407
  return formatter.format(date);
402
408
  });
403
409
  }
@@ -518,6 +524,8 @@
518
524
  }
519
525
  function parseFirstDay(value) {
520
526
  const parsed = Number(value);
527
+ if (parsed === 7)
528
+ return 0;
521
529
  return Number.isInteger(parsed) && parsed >= 0 && parsed <= 6 ? parsed : 1;
522
530
  }
523
531
  function yearOf(month) {
@@ -1157,7 +1165,7 @@
1157
1165
  <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${escapeHtml(this._messages.previousMonth)}"${prevDisabled ? " 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>
1158
1166
  <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${escapeHtml(this._messages.nextMonth)}"${nextDisabled ? " 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>
1159
1167
  </div>
1160
- <h2 id="${headingId}" class="dp-calendar-heading" aria-live="polite">${escapeHtml(formatMonthYear(`${display}-15`, locale))}</h2>
1168
+ <h2 id="${headingId}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${escapeHtml(formatMonthYear(`${display}-15`, locale))}</h2>
1161
1169
  <table id="${gridId}" class="dp-grid" role="grid" aria-labelledby="${headingId}">
1162
1170
  <thead><tr>${weekHeader}${dayHeaders}</tr></thead>
1163
1171
  <tbody>${rows}</tbody>
@@ -1 +1 @@
1
- :where(date-calendar,date-picker){--dp-bg:Canvas;--dp-fg:CanvasText;--dp-muted:color-mix(in srgb,CanvasText 58%,Canvas);--dp-border:color-mix(in srgb,CanvasText 22%,Canvas);--dp-hover:color-mix(in srgb,CanvasText 7%,Canvas);--dp-accent:Highlight;--dp-accent-fg:HighlightText;--dp-radius:.5rem;--dp-day-size:2.75rem;--dp-gap:.25rem;color:var(--dp-fg);font:inherit}.dp-visually-hidden{position:absolute!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;white-space:nowrap!important;border:0!important;block-size:1px!important;inline-size:1px!important;margin:-1px!important;padding:0!important}date-calendar{display:block;inline-size:max-content;max-inline-size:100%}.dp-calendar-shell{inline-size:max-content;max-inline-size:100%}.dp-calendar-header{display:grid;grid-template-columns:minmax(0,1fr)auto auto auto;align-items: center;gap:var(--dp-gap);margin-block-end:.4rem}.dp-calendar-header .dp-prev{margin-inline-start:calc(var(--dp-gap)*2.5)}.dp-calendar-header :where(button,select,input){border:1px solid var(--dp-border);border-radius:calc(var(--dp-radius)*.75);background:var(--dp-bg);color:var(--dp-fg);font:inherit;min-block-size:2.25rem}.dp-calendar-header select,.dp-calendar-header input{min-inline-size:0;padding-inline-start:.45rem;padding-inline-end:.45rem}.dp-month-select{inline-size:100%}.dp-year-input{inline-size:5.5rem}.dp-nav{display:grid;cursor:pointer;place-items: center;inline-size:2.25rem;padding:0;font-size:1.35rem;line-height:1}.dp-nav svg{display:block;pointer-events:none;block-size:1rem;inline-size:1rem}.dp-picker-button:disabled{cursor:not-allowed;opacity:.45}.dp-calendar-header :where(button,select,input):disabled{cursor:not-allowed;opacity:.45}.dp-nav:hover:not(:disabled),.dp-day:hover:not([data-disabled=true]):not([data-selected=true]):not([data-range-start=true]):not([data-range-end=true]){background:var(--dp-hover)}.dp-calendar-heading{text-align:center;margin:0 0 .35rem;font-size:.875rem;font-weight:600}.dp-grid{border-collapse:separate;border-spacing:0 .25rem;table-layout:fixed}.dp-grid :where(th,td){box-sizing:border-box;inline-size:var(--dp-day-size);block-size:var(--dp-day-size);text-align:center;padding:0}.dp-grid thead th{color:var(--dp-muted);block-size:1.6rem;font-size:.72rem;font-weight:600}.dp-day{position:relative;border-radius:calc(var(--dp-radius)*.75);cursor:pointer;outline:none;vertical-align:middle;border:1px solid #0000;font-size:.875rem}.dp-day:focus-visible{outline:2px solid var(--dp-accent);outline-offset:1px;z-index:1}.dp-day[data-selected=true]{background:var(--dp-accent);color:var(--dp-accent-fg)}.dp-day[data-today=true]:not([data-selected=true]){border-color:var(--dp-accent)}.dp-day[data-outside-month=true]{color:var(--dp-muted)}.dp-day[data-disabled=true]{cursor:not-allowed;opacity:.42}.dp-day[data-range-start=true],.dp-day[data-range-end=true]{background:var(--dp-accent);color:var(--dp-accent-fg)}.dp-day[data-in-range=true]{background:color-mix(in srgb,var(--dp-accent)18%,var(--dp-bg));border-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:-webkit-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:-moz-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:is([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:-webkit-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day:-moz-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day:is([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-in-range=true]:first-of-type:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day-number{display:block;font-variant-numeric:tabular-nums}.dp-day-extra{position:absolute;display:flex;pointer-events:none;justify-content:center;gap:2px;min-block-size:.35rem;font-size:.55rem;line-height:1;bottom:1px;left:2px;right:2px}.dp-week-number,.dp-week-heading{color:var(--dp-muted);font-size:.65rem;font-weight:500;inline-size:1.6rem!important}date-picker{position:relative;display:inline-grid;grid-template-columns:minmax(0,1fr)auto;align-items:stretch;max-inline-size:100%}date-picker>input:not([type=hidden]){grid-column:1;min-inline-size:0}date-picker[range]>input:not([type=hidden]){grid-column:1}date-picker[range]>input[data-range-start]{grid-row:1}date-picker[range]>input[data-range-end]{grid-row:2}.dp-picker-button{grid-column:2;border:1px solid var(--dp-border);background:var(--dp-bg);color:var(--dp-fg);font:inherit;cursor:pointer;border-inline-start:0;min-inline-size:2.5rem}.dp-picker-button:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius);border-bottom-left-radius:0}.dp-picker-button:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius);border-bottom-left-radius:0}.dp-picker-button:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius);border-bottom-left-radius:0}.dp-picker-button:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius);border-bottom-right-radius:0}.dp-picker-button:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius);border-bottom-right-radius:0}.dp-picker-button:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius);border-bottom-right-radius:0}date-picker[range]>.dp-picker-button{grid-row:1/span 2}.dp-picker-panel[popover]{position:fixed;border:1px solid var(--dp-border);border-radius:var(--dp-radius);background:var(--dp-bg);color:var(--dp-fg);max-block-size:var(--available-height,90svh);overflow:auto;max-inline-size:calc(100vi - 1rem);margin:0;padding:.65rem;inset:auto;box-shadow:0 .5rem 1.5rem #00000029}.dp-picker-panel:not(:popover-open){display:none}@media (forced-colors:active){.dp-day[data-selected=true],.dp-day[data-range-start=true],.dp-day[data-range-end=true]{color:canvastext;background-color:canvas;border:2px solid highlight;font-weight:700}.dp-day[data-in-range=true]{color:canvastext}.dp-day[data-in-range=true]:after{content:"";position:absolute;background-color:highlight;block-size:1px;bottom:4px;left:3px;right:3px}.dp-day[data-selected=true]:before{content:"";position:absolute;border-radius:calc(var(--dp-radius)*.5);pointer-events:none;border:1px solid canvastext;inset:3px}.dp-day[data-today=true]{border-color:highlight}.dp-day-extra{color:canvastext;forced-color-adjust:none}.dp-day[data-disabled=true],.dp-picker-button:disabled{opacity:1;color:graytext}.dp-calendar-header :where(button,select,input):disabled{opacity:1;color:graytext}}
1
+ :where(date-calendar,date-picker){--dp-bg:Canvas;--dp-fg:CanvasText;--dp-muted:color-mix(in srgb,CanvasText 58%,Canvas);--dp-border:color-mix(in srgb,CanvasText 22%,Canvas);--dp-hover:color-mix(in srgb,CanvasText 7%,Canvas);--dp-accent:Highlight;--dp-accent-fg:HighlightText;--dp-radius:.5rem;--dp-day-size:2.75rem;--dp-gap:.25rem;color:var(--dp-fg);font:inherit}.dp-visually-hidden{position:absolute!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;white-space:nowrap!important;border:0!important;block-size:1px!important;inline-size:1px!important;margin:-1px!important;padding:0!important}date-calendar{display:block;inline-size:max-content;max-inline-size:100%}.dp-calendar-shell{inline-size:max-content;max-inline-size:100%}.dp-calendar-header{display:grid;grid-template-columns:minmax(0,1fr)auto auto auto;align-items: center;gap:var(--dp-gap);margin-block-end:.4rem}.dp-calendar-header .dp-prev{margin-inline-start:calc(var(--dp-gap)*2.5)}.dp-calendar-header :where(button,select,input){border:1px solid var(--dp-border);border-radius:calc(var(--dp-radius)*.75);background:var(--dp-bg);color:var(--dp-fg);font:inherit;min-block-size:2.25rem}.dp-calendar-header select,.dp-calendar-header input{min-inline-size:0;padding-inline-start:.45rem;padding-inline-end:.45rem}.dp-month-select{inline-size:100%}.dp-year-input{inline-size:5.5rem}.dp-nav{display:grid;cursor:pointer;place-items: center;inline-size:2.25rem;padding:0;font-size:1.35rem;line-height:1}.dp-nav svg{display:block;pointer-events:none;block-size:1rem;inline-size:1rem}.dp-picker-button:disabled{cursor:not-allowed;opacity:.45}.dp-calendar-header :where(button,select,input):disabled{cursor:not-allowed;opacity:.45}.dp-nav:hover:not(:disabled),.dp-day:hover:not([data-disabled=true]):not([data-selected=true]):not([data-range-start=true]):not([data-range-end=true]){background:var(--dp-hover)}.dp-grid{border-collapse:separate;border-spacing:0 .25rem;table-layout:fixed}.dp-grid :where(th,td){box-sizing:border-box;inline-size:var(--dp-day-size);block-size:var(--dp-day-size);text-align:center;padding:0}.dp-grid thead th{color:var(--dp-muted);block-size:1.6rem;font-size:.72rem;font-weight:600}.dp-day{position:relative;border-radius:calc(var(--dp-radius)*.75);cursor:pointer;outline:none;vertical-align:middle;border:1px solid #0000;font-size:.875rem}.dp-day:focus-visible{outline:2px solid var(--dp-accent);outline-offset:1px;z-index:1}.dp-day[data-selected=true]{background:var(--dp-accent);color:var(--dp-accent-fg)}.dp-day[data-today=true]:not([data-selected=true]){border-color:var(--dp-accent)}.dp-day[data-outside-month=true]{color:var(--dp-muted)}.dp-day[data-disabled=true]{cursor:not-allowed;opacity:.42}.dp-day[data-range-start=true],.dp-day[data-range-end=true]{background:var(--dp-accent);color:var(--dp-accent-fg)}.dp-day[data-in-range=true]{background:color-mix(in srgb,var(--dp-accent)18%,var(--dp-bg));border-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day[data-range-start=true]:has(+[data-in-range=true],+[data-range-end=true]):is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:-webkit-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:-moz-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:is([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-bottom-left-radius:0}.dp-day:-webkit-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day:-moz-any([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day:is([data-in-range=true],[data-range-start=true])+.dp-day[data-range-end=true]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-bottom-right-radius:0}.dp-day[data-in-range=true]:first-of-type:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:first-of-type:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day[data-in-range=true]:last-of-type:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius)}.dp-day-number{display:block;font-variant-numeric:tabular-nums}.dp-day-extra{position:absolute;display:flex;pointer-events:none;justify-content:center;gap:2px;min-block-size:.35rem;font-size:.55rem;line-height:1;bottom:1px;left:2px;right:2px}.dp-week-number,.dp-week-heading{color:var(--dp-muted);font-size:.65rem;font-weight:500;inline-size:1.6rem!important}date-picker{position:relative;display:inline-grid;grid-template-columns:minmax(0,1fr)auto;align-items:stretch;max-inline-size:100%}date-picker>input:not([type=hidden]){grid-column:1;min-inline-size:0}date-picker[range]>input:not([type=hidden]){grid-column:1}date-picker[range]>input[data-range-start]{grid-row:1}date-picker[range]>input[data-range-end]{grid-row:2}.dp-picker-button{grid-column:2;border:1px solid var(--dp-border);background:var(--dp-bg);color:var(--dp-fg);font:inherit;cursor:pointer;border-inline-start:0;min-inline-size:2.5rem}.dp-picker-button:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius);border-bottom-left-radius:0}.dp-picker-button:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius);border-bottom-left-radius:0}.dp-picker-button:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:0;border-top-right-radius:var(--dp-radius);border-bottom-right-radius:var(--dp-radius);border-bottom-left-radius:0}.dp-picker-button:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius);border-bottom-right-radius:0}.dp-picker-button:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius);border-bottom-right-radius:0}.dp-picker-button:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:0;border-top-left-radius:var(--dp-radius);border-bottom-left-radius:var(--dp-radius);border-bottom-right-radius:0}date-picker[range]>.dp-picker-button{grid-row:1/span 2}.dp-picker-panel[popover]{position:fixed;border:1px solid var(--dp-border);border-radius:var(--dp-radius);background:var(--dp-bg);color:var(--dp-fg);max-block-size:var(--available-height,90svh);overflow:auto;max-inline-size:calc(100vi - 1rem);margin:0;padding:.65rem;inset:auto;box-shadow:0 .5rem 1.5rem #00000029}.dp-picker-panel:not(:popover-open){display:none}@media (forced-colors:active){.dp-day[data-selected=true],.dp-day[data-range-start=true],.dp-day[data-range-end=true]{color:canvastext;background-color:canvas;border:2px solid highlight;font-weight:700}.dp-day[data-in-range=true]{color:canvastext}.dp-day[data-in-range=true]:after{content:"";position:absolute;background-color:highlight;block-size:1px;bottom:4px;left:3px;right:3px}.dp-day[data-selected=true]:before{content:"";position:absolute;border-radius:calc(var(--dp-radius)*.5);pointer-events:none;border:1px solid canvastext;inset:3px}.dp-day[data-today=true]{border-color:highlight}.dp-day-extra{color:canvastext;forced-color-adjust:none}.dp-day[data-disabled=true],.dp-picker-button:disabled{opacity:1;color:graytext}.dp-calendar-header :where(button,select,input):disabled{opacity:1;color:graytext}}
@@ -1,5 +1,5 @@
1
- /*** @lekoala/date-picker v0.1.0 - https://github.com/lekoala/date-picker ***/
2
- (()=>{var{defineProperty:et,getOwnPropertyNames:It,getOwnPropertyDescriptor:Ft}=Object,Rt=Object.prototype.hasOwnProperty;function Ot(t){return this[t]}var Bt=(t)=>{var e=(ct??=new WeakMap).get(t),s;if(e)return e;if(e=et({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function"){for(var i of It(t))if(!Rt.call(e,i))et(e,i,{get:Ot.bind(t,i),enumerable:!(s=Ft(t,i))||s.enumerable})}return ct.set(t,e),e},ct;var Ht=(t)=>t;function Vt(t,e){this[t]=Ht.bind(null,e)}var Pt=(t,e)=>{for(var s in e)et(t,s,{get:e[s],enumerable:!0,configurable:!0,set:Vt.bind(e,s)})};var ge={};Pt(ge,{defineDatePicker:()=>Tt});var Nt=/^(\d{4})-(\d{2})-(\d{2})$/,Ut=/^(\d{4})-(\d{2})$/;function Yt(t){return t%4===0&&(t%100!==0||t%400===0)}function Z(t,e){if(e===2)return Yt(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=Nt.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=Number(e[3]);if(s<1||s>9999||i<1||i>12)return null;if(n<1||n>Z(s,i))return null;return{year:s,month:i,day:n}}function c(t){return F(t)!==null}function f(t){let e=String(t||""),s=Ut.exec(e);if(s){let n=Number(s[2]);if(n>=1&&n<=12)return`${s[1]}-${String(n).padStart(2,"0")}`}let i=F(e);if(!i)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function N(t,e,s){let i=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(s).padStart(2,"0")}`;if(!c(i))throw TypeError(`Invalid civil date: ${i}`);return i}function X(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function Wt(t){return N(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function U(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return X(e)}function w(t,e){if(!c(t)||!c(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function I(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let i=X(s);return i.setUTCDate(i.getUTCDate()+e),Wt(i)}function J(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let i=s.year*12+(s.month-1)+e,n=Math.floor(i/12),a=(i%12+12)%12+1,o=Math.min(s.day,Z(n,a));return N(n,a,o)}function ut(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let i=s.year+e,n=Math.min(s.day,Z(i,s.month));return N(i,s.month,n)}function P(t,e){let s=`${f(t)}-01`;return f(J(s,e))}function Kt(t){return`${f(t)}-01`}function jt(t){let e=F(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return N(e.year,e.month,Z(e.year,e.month))}function zt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return X(e).getUTCDay()}function Q(t,e=1){if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6");let s=(zt(t)-e+7)%7;return I(t,-s)}function st(t,e=1){return I(Q(t,e),6)}function ht(t,e={}){let s=e.firstDay??1,i=Q(Kt(t),s),n=st(jt(t),s),r=[],a=i;while(w(a,n)<=0){let o=[];for(let d=0;d<7;d++)o.push(I(a,d));r.push(o),a=I(a,7)}return r}function ft(t,e="",s=""){if(!c(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&w(t,e)<0)return e;if(s&&w(t,s)>0)return s;return t}function R(){let t=new Date;return N(t.getFullYear(),t.getMonth()+1,t.getDate())}function pt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let s=X(e),i=s.getUTCDay()||7;s.setUTCDate(s.getUTCDate()+4-i);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(s.getUTCFullYear(),0,1),Math.ceil(((s.getTime()-n.getTime())/86400000+1)/7)}class it{constructor(t={}){let e=R();this.firstDay=t.firstDay??1,this.value=t.value&&c(t.value)?t.value:"",this.focused=t.focused&&c(t.focused)?t.focused:this.value||e,this.display=t.display?f(t.display):f(this.focused)}setValue(t){if(t&&!c(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=f(t),s=Number(this.focused.slice(8,10))||1,i=J(`${e}-01`,0),n=I(i,Math.max(0,s-1));return this.focused=f(n)===e?n:I(`${P(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!c(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(J(this.focused,t))}moveFocusYears(t){return this.setFocused(ut(this.focused,t))}focusWeekStart(){return this.setFocused(Q(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(st(this.focused,this.firstDay))}navigateMonth(t){let e=P(this.display,t);return this.setDisplay(e),this.display}}function tt(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:s=""}=t;if(e&&!c(e))throw TypeError(`Invalid range start: ${e}`);if(s&&!c(s))throw TypeError(`Invalid range end: ${s}`);if(!e&&s)throw TypeError("highlightedRange cannot define an end without a start");if(e&&s&&w(s,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:s}}function mt(t,e){if(!e||!c(t))return"";let{start:s,end:i}=e;if(!s||!c(s))return"";if(s===t)return i?i===t?"single":"start":"start";if(i&&i===t)return"end";if(i&&w(t,s)>=0&&w(t,i)<=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(!c(t))throw TypeError(`Invalid range activation: ${t}`);if(this.complete&&(w(t,this.start)<0||w(t,this.end)>0)){let s=w(t,this.start)<0?"start":"end";if(!e(s))return{status:"refused",endpoint:s};return this[s]=t,this.activeEndpoint=s,{status:"complete",endpoint:s}}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 gt=/[\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 qt(t){let e=new Intl.NumberFormat(t,{useGrouping:!1}),s=new Map;for(let i=0;i<=9;i++)s.set(e.format(i),String(i));return s}function _t(t,e){let s=String(t||"").replace(gt,"").trim();for(let[i,n]of qt(e))s=s.split(i).join(n);return s}function W(t,e=""){let s=H(e);return new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(U(t))}function yt(t,e=""){let s=H(e);return new Intl.DateTimeFormat(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(U(`${t.slice(0,7)}-15`))}function bt(t="",e="long"){let s=H(t),i=new Intl.DateTimeFormat(s,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(U(`2026-${String(r+1).padStart(2,"0")}-15`)))}function rt(t="",e=1,s="short"){let i=H(t),n=new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=U("2026-01-04");return Array.from({length:7},(a,o)=>{let d=new Date(r);return d.setUTCDate(r.getUTCDate()+(e+o)%7),n.format(d)})}function Gt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function z(t=""){let e=H(t),s=new Intl.DateTimeFormat(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=U("2006-11-22"),n=s.formatToParts(i).filter((l)=>l.type!=="literal"||l.value),r=n.filter((l)=>["day","month","year"].includes(l.type)).map((l)=>l.type),a=n.map((l)=>{if(l.type==="day")return"DD";if(l.type==="month")return"MM";if(l.type==="year")return"YYYY";return l.value.replace(gt,"")}).join(""),o=n.map((l)=>{if(l.type==="day"||l.type==="month")return"(\\d{1,2})";if(l.type==="year")return"(\\d{4})";let h=_t(l.value,e).replace(/\s+/g," ");return Gt(h).replace(/\\ /g,"\\s*")}).join(""),d=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(l){if(!c(l))return"";return s.format(U(l))},parse(l){let h=_t(l,e);if(c(h))return h;let E=d.exec(h);if(!E)return"";let _={};if(r.forEach((b,k)=>{_[b]=Number(E[k+1])}),!_.year||!_.month||!_.day)return"";try{return N(_.year,_.month,_.day)}catch{return""}}}}var Zt={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"},Xt={...Zt};function K(){return{...Xt}}function vt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,s=new Map;if(Array.isArray(e)){for(let i of e){if(!i||typeof i!=="object"||!("date"in i))continue;let{date:n,...r}=i;s.set(String(n),r)}return s}if(e&&typeof e==="object")for(let[i,n]of Object.entries(e))s.set(i,n&&typeof n==="object"?n:{});return s}var Jt=0;function C(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function Qt(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&e<=6?e:1}function te(t){return Number(t.slice(0,4))}function ee(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 se(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class q 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 it,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=K(),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&&!c(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 c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return Qt(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=tt(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={...K(),...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||c(e))this._model.value=e;let s=this.getAttribute("display")||"";if(s)try{this._model.setDisplay(s)}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 ft(t,this.min,this.max)}_weeks(t=this.display){let e=ht(t,{firstDay:this.firstDay});if(!this.fixedWeeks||e.length>=6)return e;let s=e[e.length-1]?.[6]||"";while(e.length<6&&s){let i=[];for(let n=1;n<=7;n++)i.push(I(s,n));e.push(i),s=i[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(c(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),s=e[0],i=e[e.length-1];if(!s||!i)throw Error("Calendar month produced no weeks");return{start:s[0],end:i[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},s=this._dateState?.(t,{...e})||{},i={...e,...s},n=this.min&&w(t,this.min)<0||this.max&&w(t,this.max)>0,a=i.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(i.disabled)||a;return{...i,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(!c(t)||!this._source)return!0;return await this._loadDisplay(f(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let s=this._range(t),i=`${s.start}/${s.end}`;if(this._loadedRanges.has(i))return"loaded";if(i===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=i;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:s,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 d=await o(s,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[l,h]of vt(d))this._sourceStates.set(l,h);if(this._loadedRanges.add(i),this.dispatchEvent(new CustomEvent("dateloadend",{detail:s,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:{...s,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===i)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let s=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&&s!==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(P(this.display,-1))}nextMonth(){return this._setDisplay(P(this.display,1))}focusDate(t,e={}){if(!c(t))throw TypeError(`Invalid date: ${t}`);let s=this._clamp(t),i=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(s),this._reflect("display",this._model.display),i!==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,s=!0){let i=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,s)n.focus()}else if(s)this.focusGrid()}_moveSelectionDom(t,e){if(t){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.removeAttribute("data-selected"),s.removeAttribute("aria-selected")}if(e){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)return s.setAttribute("data-selected","true"),s.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),s=this.getDateState(t);if(!e||s.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:t,state:s},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:t,state:s},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 s=e.closest("[data-calendar-action]");if(s instanceof HTMLButtonElement){let a=s.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let i=e.closest(".dp-day[data-date]");if(!(i instanceof HTMLTableCellElement))return;let n=i.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(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 s=Number(e.value);if(!Number.isInteger(s)||s<1||s>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(s).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 s=e.dataset.date||"";if(c(s))this._model.focused=s}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._activate(s);return}let i=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(s,{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=i,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,s=this.display,i=te(s),n=Number(s.slice(5,7)),r=bt(e,"long"),a=rt(e,this.firstDay,"short"),o=rt(e,this.firstDay,"long"),d=this._weeks(),l=R(),h=`${this._id}-heading`,E=`${this._id}-grid`,_=this.min?f(this.min):"",b=this.max?f(this.max):"",k=Boolean(_&&P(s,-1)<_),S=Boolean(b&&P(s,1)>b),D=this.min?` min="${Number(this.min.slice(0,4))}"`:"",g=this.max?` max="${Number(this.max.slice(0,4))}"`:"",m=this.showWeekNumbers&&this.firstDay===1,A=m?`<th scope="col" class="dp-week-heading" abbr="${C(this._messages.week)}">#</th>`:"",v=r.map((x,M)=>{let p=M+1,u=`${String(i).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=_&&u<_||b&&u>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${C(x)}</option>`}).join(""),V=a.map((x,M)=>`<th scope="col" abbr="${C(o[M])}">${C(x.replace(".",""))}</th>`).join(""),Y=d.map((x)=>{let M=m?`<th scope="row" class="dp-week-number">${pt(x[0])}</th>`:"",p=x.map((u)=>{let y=this.getDateState(u),T=f(u)!==s,L=this.value===u,j=this.focusedDate===u,ot=u===l,lt=mt(u,this._highlightedRange),dt=se(lt),$t=typeof y.description==="string"?y.description:"",Lt=[W(u,e),$t,dt?this._messages[dt]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${u}"${T?' data-outside-month="true"':""}${ot?' data-today="true" aria-current="date"':""}${L?' data-selected="true" aria-selected="true"':""}${ee(lt)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${j?"0":"-1"}" aria-label="${C(Lt)}"><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>${M}${p}</tr>`}).join(""),O=document.activeElement,B=O instanceof HTMLElement&&this.contains(O)?this._focusTargetKey(O):"";if(this._rendering=!0,this.innerHTML=`
1
+ /*** @lekoala/date-picker v0.1.1 - https://github.com/lekoala/date-picker ***/
2
+ (()=>{var{defineProperty:st,getOwnPropertyNames:It,getOwnPropertyDescriptor:Rt}=Object,Ot=Object.prototype.hasOwnProperty;function Bt(t){return this[t]}var Ht=(t)=>{var e=(ut??=new WeakMap).get(t),s;if(e)return e;if(e=st({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function"){for(var i of It(t))if(!Ot.call(e,i))st(e,i,{get:Bt.bind(t,i),enumerable:!(s=Rt(t,i))||s.enumerable})}return ut.set(t,e),e},ut;var Vt=(t)=>t;function Pt(t,e){this[t]=Vt.bind(null,e)}var Nt=(t,e)=>{for(var s in e)st(t,s,{get:e[s],enumerable:!0,configurable:!0,set:Pt.bind(e,s)})};var ye={};Nt(ye,{defineDatePicker:()=>$t});var Ut=/^(\d{4})-(\d{2})-(\d{2})$/,Yt=/^(\d{4})-(\d{2})$/;function Wt(t){return t%4===0&&(t%100!==0||t%400===0)}function X(t,e){if(e===2)return Wt(t)?29:28;return[4,6,9,11].includes(e)?30:31}function I(t){let e=Ut.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=Number(e[3]);if(s<1||s>9999||i<1||i>12)return null;if(n<1||n>X(s,i))return null;return{year:s,month:i,day:n}}function d(t){return I(t)!==null}function f(t){let e=String(t||""),s=Yt.exec(e);if(s){let n=Number(s[2]);if(n>=1&&n<=12)return`${s[1]}-${String(n).padStart(2,"0")}`}let i=I(e);if(!i)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function N(t,e,s){let i=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(s).padStart(2,"0")}`;if(!d(i))throw TypeError(`Invalid civil date: ${i}`);return i}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 zt(t){return N(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function U(t){let e=I(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e)}function w(t,e){if(!d(t)||!d(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function F(t,e){let s=I(t);if(!s||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let i=J(s);return i.setUTCDate(i.getUTCDate()+e),zt(i)}function Q(t,e){let s=I(t);if(!s||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let i=s.year*12+(s.month-1)+e,n=Math.floor(i/12),a=(i%12+12)%12+1,o=Math.min(s.day,X(n,a));return N(n,a,o)}function ht(t,e){let s=I(t);if(!s||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let i=s.year+e,n=Math.min(s.day,X(i,s.month));return N(i,s.month,n)}function P(t,e){let s=`${f(t)}-01`;return f(Q(s,e))}function Kt(t){return`${f(t)}-01`}function jt(t){let e=I(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return N(e.year,e.month,X(e.year,e.month))}function qt(t){let e=I(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e).getUTCDay()}function j(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 s=(qt(t)-j(e)+7)%7;return F(t,-s)}function it(t,e=1){return F(tt(t,e),6)}function ft(t,e={}){let s=e.firstDay??1,i=tt(Kt(t),s),n=it(jt(t),s),r=[],a=i;while(w(a,n)<=0){let o=[];for(let c=0;c<7;c++)o.push(F(a,c));r.push(o),a=F(a,7)}return r}function pt(t,e="",s=""){if(!d(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&w(t,e)<0)return e;if(s&&w(t,s)>0)return s;return t}function R(){let t=new Date;return N(t.getFullYear(),t.getMonth()+1,t.getDate())}function mt(t){let e=I(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let s=J(e),i=s.getUTCDay()||7;s.setUTCDate(s.getUTCDate()+4-i);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(s.getUTCFullYear(),0,1),Math.ceil(((s.getTime()-n.getTime())/86400000+1)/7)}class nt{constructor(t={}){let e=R();this.firstDay=j(t.firstDay??1),this.value=t.value&&d(t.value)?t.value:"",this.focused=t.focused&&d(t.focused)?t.focused:this.value||e,this.display=t.display?f(t.display):f(this.focused)}setValue(t){if(t&&!d(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=f(t),s=Number(this.focused.slice(8,10))||1,i=Q(`${e}-01`,0),n=F(i,Math.max(0,s-1));return this.focused=f(n)===e?n:F(`${P(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!d(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(F(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=P(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:s=""}=t;if(e&&!d(e))throw TypeError(`Invalid range start: ${e}`);if(s&&!d(s))throw TypeError(`Invalid range end: ${s}`);if(!e&&s)throw TypeError("highlightedRange cannot define an end without a start");if(e&&s&&w(s,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:s}}function _t(t,e){if(!e||!d(t))return"";let{start:s,end:i}=e;if(!s||!d(s))return"";if(s===t)return i?i===t?"single":"start":"start";if(i&&i===t)return"end";if(i&&w(t,s)>=0&&w(t,i)<=0)return"in";return""}class rt{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(!d(t))throw TypeError(`Invalid range activation: ${t}`);if(this.complete&&(w(t,this.start)<0||w(t,this.end)>0)){let s=w(t,this.start)<0?"start":"end";if(!e(s))return{status:"refused",endpoint:s};return this[s]=t,this.activeEndpoint=s,{status:"complete",endpoint:s}}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 Gt(t){let e=new Intl.NumberFormat(t,{useGrouping:!1}),s=new Map;for(let i=0;i<=9;i++)s.set(e.format(i),String(i));return s}function gt(t,e){let s=String(t||"").replace(yt,"").trim();for(let[i,n]of Gt(e))s=s.split(i).join(n);return s}function W(t,e=""){let s=H(e);return new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(U(t))}function bt(t,e=""){let s=H(e);return new Intl.DateTimeFormat(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(U(`${t.slice(0,7)}-15`))}function vt(t="",e="long"){let s=H(t),i=new Intl.DateTimeFormat(s,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(U(`2026-${String(r+1).padStart(2,"0")}-15`)))}function at(t="",e=1,s="short"){let i=H(t),n=new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=j(e),a=U("2026-01-04");return Array.from({length:7},(o,c)=>{let l=new Date(a);return l.setUTCDate(a.getUTCDate()+(r+c)%7),n.format(l)})}function Zt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(t=""){let e=H(t),s=new Intl.DateTimeFormat(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=U("2006-11-22"),n=s.formatToParts(i).filter((l)=>l.type!=="literal"||l.value),r=n.filter((l)=>["day","month","year"].includes(l.type)).map((l)=>l.type),a=n.map((l)=>{if(l.type==="day")return"DD";if(l.type==="month")return"MM";if(l.type==="year")return"YYYY";return l.value.replace(yt,"")}).join(""),o=n.map((l)=>{if(l.type==="day"||l.type==="month")return"(\\d{1,2})";if(l.type==="year")return"(\\d{4})";let h=gt(l.value,e).replace(/\s+/g," ");return Zt(h).replace(/\\ /g,"\\s*")}).join(""),c=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(l){if(!d(l))return"";return s.format(U(l))},parse(l){let h=gt(l,e);if(d(h))return h;let E=c.exec(h);if(!E)return"";let _={};if(r.forEach((b,k)=>{_[b]=Number(E[k+1])}),!_.year||!_.month||!_.day)return"";try{return N(_.year,_.month,_.day)}catch{return""}}}}var Xt={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"},Jt={...Xt};function z(){return{...Jt}}function wt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,s=new Map;if(Array.isArray(e)){for(let i of e){if(!i||typeof i!=="object"||!("date"in i))continue;let{date:n,...r}=i;s.set(String(n),r)}return s}if(e&&typeof e==="object")for(let[i,n]of Object.entries(e))s.set(i,n&&typeof n==="object"?n:{});return s}var Qt=0;function C(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function te(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function ee(t){return Number(t.slice(0,4))}function se(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 ie(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-${++Qt}`,this._model=new nt,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=z(),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&&!d(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 d(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return d(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return te(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={...z(),...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||d(e))this._model.value=e;let s=this.getAttribute("display")||"";if(s)try{this._model.setDisplay(s)}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 s=e[e.length-1]?.[6]||"";while(e.length<6&&s){let i=[];for(let n=1;n<=7;n++)i.push(F(s,n));e.push(i),s=i[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(d(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),s=e[0],i=e[e.length-1];if(!s||!i)throw Error("Calendar month produced no weeks");return{start:s[0],end:i[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},s=this._dateState?.(t,{...e})||{},i={...e,...s},n=this.min&&w(t,this.min)<0||this.max&&w(t,this.max)>0,a=i.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(i.disabled)||a;return{...i,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(!d(t)||!this._source)return!0;return await this._loadDisplay(f(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let s=this._range(t),i=`${s.start}/${s.end}`;if(this._loadedRanges.has(i))return"loaded";if(i===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=i;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:s,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(s,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[l,h]of wt(c))this._sourceStates.set(l,h);if(this._loadedRanges.add(i),this.dispatchEvent(new CustomEvent("dateloadend",{detail:s,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:{...s,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===i)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let s=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&&s!==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(P(this.display,-1))}nextMonth(){return this._setDisplay(P(this.display,1))}focusDate(t,e={}){if(!d(t))throw TypeError(`Invalid date: ${t}`);let s=this._clamp(t),i=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(s),this._reflect("display",this._model.display),i!==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,s=!0){let i=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,s)n.focus()}else if(s)this.focusGrid()}_moveSelectionDom(t,e){if(t){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.removeAttribute("data-selected"),s.removeAttribute("aria-selected")}if(e){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)return s.setAttribute("data-selected","true"),s.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),s=this.getDateState(t);if(!e||s.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:t,state:s},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:t,state:s},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 s=e.closest("[data-calendar-action]");if(s instanceof HTMLButtonElement){let a=s.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let i=e.closest(".dp-day[data-date]");if(!(i instanceof HTMLTableCellElement))return;let n=i.dataset.date||"";if(!d(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 s=Number(e.value);if(!Number.isInteger(s)||s<1||s>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(s).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 s=e.dataset.date||"";if(d(s))this._model.focused=s}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._activate(s);return}let i=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(s,{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=i,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,s=this.display,i=ee(s),n=Number(s.slice(5,7)),r=vt(e,"long"),a=at(e,this.firstDay,"short"),o=at(e,this.firstDay,"long"),c=this._weeks(),l=R(),h=`${this._id}-heading`,E=`${this._id}-grid`,_=this.min?f(this.min):"",b=this.max?f(this.max):"",k=Boolean(_&&P(s,-1)<_),S=Boolean(b&&P(s,1)>b),D=this.min?` min="${Number(this.min.slice(0,4))}"`:"",g=this.max?` max="${Number(this.max.slice(0,4))}"`:"",m=this.showWeekNumbers&&this.firstDay===1,A=m?`<th scope="col" class="dp-week-heading" abbr="${C(this._messages.week)}">#</th>`:"",v=r.map((x,M)=>{let p=M+1,u=`${String(i).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=_&&u<_||b&&u>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${C(x)}</option>`}).join(""),V=a.map((x,M)=>`<th scope="col" abbr="${C(o[M])}">${C(x.replace(".",""))}</th>`).join(""),Y=c.map((x)=>{let M=m?`<th scope="row" class="dp-week-number">${mt(x[0])}</th>`:"",p=x.map((u)=>{let y=this.getDateState(u),T=f(u)!==s,L=this.value===u,K=this.focusedDate===u,lt=u===l,dt=_t(u,this._highlightedRange),ct=ie(dt),Lt=typeof y.description==="string"?y.description:"",Ft=[W(u,e),Lt,ct?this._messages[ct]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${u}"${T?' data-outside-month="true"':""}${lt?' data-today="true" aria-current="date"':""}${L?' data-selected="true" aria-selected="true"':""}${se(dt)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${K?"0":"-1"}" aria-label="${C(Ft)}"><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>${M}${p}</tr>`}).join(""),O=document.activeElement,B=O instanceof HTMLElement&&this.contains(O)?this._focusTargetKey(O):"";if(this._rendering=!0,this.innerHTML=`
3
3
  <div class="dp-calendar-shell">
4
4
  <div class="dp-calendar-header">
5
5
  <label class="dp-visually-hidden" for="${this._id}-month">${C(this._messages.month)}</label>
@@ -9,9 +9,9 @@
9
9
  <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${C(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>
10
10
  <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${C(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>
11
11
  </div>
12
- <h2 id="${h}" class="dp-calendar-heading" aria-live="polite">${C(yt(`${s}-15`,e))}</h2>
12
+ <h2 id="${h}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${C(bt(`${s}-15`,e))}</h2>
13
13
  <table id="${E}" class="dp-grid" role="grid" aria-labelledby="${h}">
14
14
  <thead><tr>${A}${V}</tr></thead>
15
15
  <tbody>${Y}</tbody>
16
16
  </table>
17
- </div>`,this._rendering=!1,B)queueMicrotask(()=>{let x=this.querySelector(B);if(x instanceof HTMLElement)x.focus()});if(this._renderDay)for(let x of this.querySelectorAll(".dp-day[data-date]")){if(!(x instanceof HTMLTableCellElement))continue;let M=x.dataset.date||"",p=x.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let u=this._renderDay(M,this.getDateState(M));if(u instanceof Node)p.append(u);else if(u!==void 0&&u!==null)p.textContent=String(u)}if(t)this._loadDisplay(s)}}function At(t){return t==="top"||t==="bottom"?"x":"y"}function ie(t){let[e,s=null]=t.split("-");return{side:e,align:s,crossAxis:At(e)}}function ne(t){return{top:"bottom",bottom:"top",left:"right",right:"left"}[t]||t}function re(t,e,s,i,n,r){let a=At(s),o=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,l=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(s){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:d};break;case"left":h={x:t.x-e.width-r,y:d};break;default:h={x:t.x,y:t.y}}if(i==="start"||i==="end"){let E=(n&&a==="x"?-1:1)*(i==="end"?1:-1);h[a]+=l*E}return h}function ae(t,e,s,i){return Math.max(s-t,0)+Math.max(t+e-i,0)}function oe(t){let e="dir"in t?t.dir:"";if(e==="rtl")return!0;if(e==="ltr")return!1;let s=t.ownerDocument?.defaultView;if(s?.CSS?.supports?.("selector(:dir(rtl))")&&typeof t.matches==="function")return t.matches(":dir(rtl)");return Boolean(s?.Element&&t instanceof s.Element&&s.getComputedStyle(t).direction==="rtl")}var le=25;function de(t){let e=t.defaultView;if(!e)return null;let s=t.documentElement,i=e.visualViewport,n=i?.offsetLeft||0,r=i?.offsetTop||0,a=i?.width||s.clientWidth||e.innerWidth,o=i?.height||s.clientHeight||e.innerHeight,d=t.compatMode==="BackCompat"?a-s.clientWidth:s.clientWidth-s.getBoundingClientRect().width;if(d>0&&d<=le){let l=e.getComputedStyle?.(s).scrollbarGutter;if(l&&l!=="auto")a-=d}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ce(t,e){return e.scope?e.scope.getBoundingClientRect():de(t.ownerDocument)}function wt(t,e,s,i,n){let r=s+n,a=i-e-n,o=a>=r,d=o?r:s,l=o?a:i-e;return Math.max(d,Math.min(t,l))}function Dt(t,e,s){if(!s)return 50;let i=(t-e)/s*100;return Math.round(Math.min(100,Math.max(0,i))*1000)/1000}function ue(t,e){return t.right<e.x||t.left>e.right||t.bottom<e.y||t.top>e.bottom}function he(t,e,s,i,n){if(e==="top")return Math.max(0,t.top-s.y-i-n);if(e==="bottom")return Math.max(0,s.bottom-t.bottom-i-n);return Math.max(0,s.height-n*2)}function fe(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function Ct(t){let{offsetWidth:e,offsetHeight:s}=t;if(e&&s)return{width:e,height:s};let i=t.getBoundingClientRect();return{width:e||i.width,height:s||i.height}}var xt=new WeakMap,Et={scroll:0,resize:1,"element-resize":2};function pe(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let s=new Set,i=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function d(D,g){let m=i.get(D);if(m===void 0||Et[g]>Et[m])i.set(D,g)}function l(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let D=[...i];i.clear(),r=!1;for(let[g,m]of D){if(!s.has(g)||!g.floating.isConnected)continue;g.callback({type:m})}})}function h(D){for(let g of s)d(g,D);l()}function E(D){if(!n)return null;let g=new Set,m=new n((V)=>{let Y=!1;for(let O of V)if(g.has(O.target))Y=!0;else g.add(O.target);if(!Y)return;d(D,"element-resize"),l()}),{reference:A,floating:v}=D;if(A)m.observe(A);if(v!==A)m.observe(v);return m}let _=()=>h("scroll"),b=()=>h("resize");function k(){if(a)return;t.addEventListener("scroll",_,{passive:!0,capture:!0}),e.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",_,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function S(){if(!a)return;t.removeEventListener("scroll",_,{capture:!0}),e.removeEventListener("resize",b),o?.removeEventListener("scroll",_),o?.removeEventListener("resize",b),a=!1}return{add(D,g,m){let A={reference:D,floating:g,callback:m};s.add(A),k();let v=E(A),V=!1;return()=>{if(V)return;if(V=!0,s.delete(A),i.delete(A),v?.disconnect(),s.size===0)S()}}}}function me(t){let e=t.ownerDocument,s=xt.get(e);if(!s)s=pe(e),xt.set(e,s);return s}function St(t,e,s){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 s!=="function")throw TypeError("callback must be a function");return me(e).add(t,e,s)}function kt(t,e,s){if(!fe(e))return null;let i=s.placement||"bottom-start",n=s.distance||0,r=s.flip!==!1,a=s.shift!==!1,o=s.shiftPadding??4,{side:d,align:l,crossAxis:h}=ie(i),E=l?oe(t):!1,_=t.getClientRects(),b=d==="bottom"?_[_.length-1]:_[0];if(!b)return null;let k=ce(t,s);if(!k||ue(b,k))return null;let S=Ct(e),D={x:{size:S.width,start:k.x,end:k.right},y:{size:S.height,start:k.y,end:k.bottom}},g=(p,u)=>re(b,S,p,u,E,n),m=(p,u)=>{let{size:y,start:T,end:L}=D[u];return ae(p,y,T+o,L-o)},A=(p,u)=>{let{size:y,start:T,end:L}=D[u];return m(a?wt(p,y,T,L,o):p,u)},v=g(d,l);if(r){let p=h==="x"?"y":"x",u=m(v[p],p);if(u>0){let y=ne(d),T=g(y,l),L=m(T[p],p);if(L<u)d=y,v=T,u=L}if(p==="x"&&u>0){let y=g("top",l),T=g("bottom",l),L=m(T.y,"y")<m(y.y,"y"),j=L?T:y;if(m(j.y,"y")+A(j.x,"x")<u+A(v.y,"y"))d=L?"bottom":"top",h="x",v=j}}if(h==="x"&&a&&l){let p=m(v.x,"x");if(p>0){let u=l==="end"?"start":"end",y=g(d,u);if(m(y.x,"x")<p)l=u,v=y}}if(a){let{size:p,start:u,end:y}=D[h];v[h]=wt(v[h],p,u,y,o)}let V=Dt(b.x+b.width/2,v.x,S.width),Y=Dt(b.y+b.height/2,v.y,S.height),O=`${he(b,d,k,n,o)}px`,{style:B}=e,x=B.getPropertyValue("--available-height")!==O;B.left=`${v.x}px`,B.top=`${v.y}px`,B.setProperty("--arrow-x",`${V}%`),B.setProperty("--arrow-y",`${Y}%`),B.setProperty("--available-height",O);let M=l?`${d}-${l}`:d;return e.dataset.placement=M,{width:S.width,height:S.height,roomChanged:x,placement:M}}function Mt(t,e,s={}){let i=kt(t,e,s);if(!i)return!1;if(i.roomChanged){let n=Ct(e);if(n.width!==i.width||n.height!==i.height)kt(t,e,{...s,placement:i.placement,flip:!1})}return!0}class G{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=z(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=z(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 s=document.createElement("input");s.type="hidden",s.value=this.canonical,t.insertAdjacentElement("afterend",s),this.hidden=s}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 s=this.canonical?this.adapter.format(this.canonical):"";t.setCustomValidity(e===s?"":this.messages.invalidDate)}async commit(){let t=this.input,e=++this._commitId,s=t.value.trim();if(!s){if(e!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let i=this.adapter.parse(s);if(!i){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(i);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:i}}setCanonical(t,e={}){let s=t||"";if(s&&!c(s))throw TypeError(`Invalid date-picker value: ${s}`);if(this.dirty(),this.canonical=s,this._dirty=!1,this.hidden)this.hidden.value=s;if(e.format!==!1)this.input.value=s?this.adapter.format(s):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=c(t)?t:this.adapter.parse(t);return e&&c(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 _e=0;class at extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus"];constructor(){super();this._id=`date-picker-${++_e}`,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=K(),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 G(t,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(i)=>this._confirmDate(i),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let e=this._adapter(),s=this.getAttribute("value")||(c(t.value)?t.value:e.parse(t.value));if(s&&c(s))this._setValue(s,{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 G(t,{messages:this._messages,locale:this.locale}),new G(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 s=this._adapter(),i=c(t.value)?t.value:s.parse(t.value),n=c(e.value)?e.value:s.parse(e.value);if(this._setRange(i||"",n||"",{emit:!1}),t.value.trim()&&!c(i))t.setCustomValidity(this._messages.invalidDate);if(e.value.trim()&&!c(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,s=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),s)e.setAttribute("aria-describedby",s);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,s){if(!this._connected||this._reflecting||e===s)return;if(t==="value"){if(this._rangeMode())return;if(!s||c(s))this._setValue(s||"",{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&&!c(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:s}=tt(t);this._setRange(e,s)}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 c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(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={...K(),...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??z(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 s of this._fields)s.syncInputState();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields.every((s)=>s.input.disabled||s.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,s=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",s),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 s=`${this._id}-panel`,i=`${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",s),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=s,r.className="dp-picker-panel",r.setAttribute("popover","manual"),r.setAttribute("role","dialog"),r.setAttribute("aria-label",this._messages.calendar);let a=new q;a.selection="none",a.fixedWeeks=!0,r.append(a);let o=document.createElement("span");if(o.id=i,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 d=[this._originalDescribedBy,i].filter(Boolean).join(" ");e.setAttribute("aria-describedby",d),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",s)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let t=this._input,e=this._button,s=this._calendar;if(!t||!e||!s)return;let i=new AbortController;this._controller=i;let{signal:n}=i;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}),s.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}),s.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 s=new AbortController;this._controller=s;let{signal:i}=s;for(let[n,r]of this._fields.entries()){let a=n===1?"end":"start";r.input.addEventListener("input",()=>r.handleInput(),{signal:i}),r.input.addEventListener("change",()=>void this._commitFieldText(a),{signal:i}),r.input.addEventListener("blur",()=>void this._commitFieldText(a),{signal:i}),r.input.addEventListener("focus",(o)=>this._onFieldFocus(a,o),{signal:i}),r.input.addEventListener("keydown",(o)=>this._onFieldKeyDown(a,o),{signal:i})}t.addEventListener("click",(n)=>{if(this._open){if(n.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:i}),e.addEventListener("click",(n)=>this._captureGridIntent(n),{capture:!0,signal:i}),e.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:i}),e.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 d=this._range.activate(a,(l)=>{let h=l==="end"?1:0,E=this._fields?.[h];return E!=null&&!E.input.disabled&&!E.input.readOnly});if(d.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:a,state:this._calendar.getDateState(a)},bubbles:!0}));return}if(this._setBound(d.endpoint,a,{emit:!0,user:!0}),d.close||d.status==="complete")this.hide(!1),this._focusField(d.endpoint)})},{signal:i}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:i}),this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:i}),this.ownerDocument.addEventListener("reset",(n)=>{let 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:i}),this.addEventListener("keydown",(n)=>this._onEscape(n),{signal:i})}_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 s=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),s)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let i=e.relatedTarget;if(i instanceof Node&&this.contains(i))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(!this._rangeMode()||!this._range)return;if(t.type==="keydown"){let i=t.key;if(i!=="Enter"&&i!==" ")return}if(!(t.target instanceof Element))return;let s=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(s))return;this._pendingIntents.set(s,++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[s,i]of this._fields.entries()){if(!i.input.hasAttribute("placeholder")||this._generatedPlaceholder)i.input.placeholder=i.placeholder,this._generatedPlaceholder=!0;let n=s===1?this._range?.end||"":this._range?.start||"";if(n)i.input.value=i.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?`, ${W(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,s=Boolean(t&&e),i=s?this._messages.changeDate:this._messages.chooseDate,n=s?`, ${W(t,this.locale)} – ${W(e,this.locale)}`:"";this._button.setAttribute("aria-label",`${i}${n}`)}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!c(t))throw TypeError(`Invalid date-picker value: ${t}`);let s=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(),s!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let i=this._field.input;i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t){let e=this._calendar;if(!e)return{ok:!0};let s=f(t);if(e.display!==s)e.display=s;let i=await e.ensureDate(t),n=e.getDateState(t);if(!i||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let s=this._field;if(!s)return!1;if(!e.force&&!s.isDirty)return!1;let i=await s.commit();if(i.status==="stale"||i.status==="invalid")return!1;return this._setValue(i.value||"",{emit:t,format:i.status==="ok"}),!0}async _commitFieldText(t){let e=this._fields;if(!e)return!1;let s=t==="end"?1:0,i=e[s];if(!i?.isDirty)return!1;let n=await i.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(s),!1;return this._setBound(t,n.value||"",{emit:!0,user:!0,format:n.status==="ok"}),!0}_setBound(t,e,s={}){if(!this._range)return!1;let i=this._fields;if(!i)return!1;let r=i[t==="end"?1:0];if(!r)return!1;if(s.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:s.format!==!1}),t==="end")this._range.end=a;else this._range.start=a;let d=o!==a;if(d){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),s.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(t),d}_setRange(t,e,s={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:s.format!==!1}),this._fields[1].setCanonical(e||"",{format:s.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),s.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:s}=this._range,i=Boolean(e&&s&&w(s,e)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,d=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(i&&r===t)o.setCustomValidity(d),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 s=this._range?.start||R();this._calendar.display=f(s),this._calendar.focusedDate=s}this.validate()}_focusField(t){let e=t==="end"?1:0,s=this._fields?.[e]?.input;if(!s)return;this._suppressFocusOpen=!0,setTimeout(()=>{s.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 s=t==="end"?"start":"end",i=s==="end"?1:0;if(!this._fields[i].input.disabled&&!this._fields[i].input.readOnly)return s;return""}async validate(){if(this._rangeMode()){let e=this._fields;if(!e)return!0;for(let[s,i]of e.entries()){let n=await i.commit();if(n.status==="ok"||n.status==="clear"){let r=s===1?"end":"start";this._setBound(r,n.value||"",{format:n.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),e.every((s)=>s.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,s=this._calendar,i=this._button;if(!e||!s||!i||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();s.display=f(a),s.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();s.display=f(a),s.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(()=>s.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 s of this._fields||[])s.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,s=this._fields?.[e];if(s&&!s.input.disabled&&!s.input.readOnly)return t}return this._resolveRangeEndpoint()}}function Tt(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",q);if(!customElements.get("date-picker"))customElements.define("date-picker",at)}Tt();})();
17
+ </div>`,this._rendering=!1,B)queueMicrotask(()=>{let x=this.querySelector(B);if(x instanceof HTMLElement)x.focus()});if(this._renderDay)for(let x of this.querySelectorAll(".dp-day[data-date]")){if(!(x instanceof HTMLTableCellElement))continue;let M=x.dataset.date||"",p=x.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let u=this._renderDay(M,this.getDateState(M));if(u instanceof Node)p.append(u);else if(u!==void 0&&u!==null)p.textContent=String(u)}if(t)this._loadDisplay(s)}}function Ct(t){return t==="top"||t==="bottom"?"x":"y"}function ne(t){let[e,s=null]=t.split("-");return{side:e,align:s,crossAxis:Ct(e)}}function re(t){return{top:"bottom",bottom:"top",left:"right",right:"left"}[t]||t}function ae(t,e,s,i,n,r){let a=Ct(s),o=t.x+t.width/2-e.width/2,c=t.y+t.height/2-e.height/2,l=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(s){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(i==="start"||i==="end"){let E=(n&&a==="x"?-1:1)*(i==="end"?1:-1);h[a]+=l*E}return h}function oe(t,e,s,i){return Math.max(s-t,0)+Math.max(t+e-i,0)}function le(t){let e="dir"in t?t.dir:"";if(e==="rtl")return!0;if(e==="ltr")return!1;let s=t.ownerDocument?.defaultView;if(s?.CSS?.supports?.("selector(:dir(rtl))")&&typeof t.matches==="function")return t.matches(":dir(rtl)");return Boolean(s?.Element&&t instanceof s.Element&&s.getComputedStyle(t).direction==="rtl")}var de=25;function ce(t){let e=t.defaultView;if(!e)return null;let s=t.documentElement,i=e.visualViewport,n=i?.offsetLeft||0,r=i?.offsetTop||0,a=i?.width||s.clientWidth||e.innerWidth,o=i?.height||s.clientHeight||e.innerHeight,c=t.compatMode==="BackCompat"?a-s.clientWidth:s.clientWidth-s.getBoundingClientRect().width;if(c>0&&c<=de){let l=e.getComputedStyle?.(s).scrollbarGutter;if(l&&l!=="auto")a-=c}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ue(t,e){return e.scope?e.scope.getBoundingClientRect():ce(t.ownerDocument)}function Dt(t,e,s,i,n){let r=s+n,a=i-e-n,o=a>=r,c=o?r:s,l=o?a:i-e;return Math.max(c,Math.min(t,l))}function xt(t,e,s){if(!s)return 50;let i=(t-e)/s*100;return Math.round(Math.min(100,Math.max(0,i))*1000)/1000}function he(t,e){return t.right<e.x||t.left>e.right||t.bottom<e.y||t.top>e.bottom}function fe(t,e,s,i,n){if(e==="top")return Math.max(0,t.top-s.y-i-n);if(e==="bottom")return Math.max(0,s.bottom-t.bottom-i-n);return Math.max(0,s.height-n*2)}function pe(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function St(t){let{offsetWidth:e,offsetHeight:s}=t;if(e&&s)return{width:e,height:s};let i=t.getBoundingClientRect();return{width:e||i.width,height:s||i.height}}var Et=new WeakMap,kt={scroll:0,resize:1,"element-resize":2};function me(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let s=new Set,i=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function c(D,g){let m=i.get(D);if(m===void 0||kt[g]>kt[m])i.set(D,g)}function l(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let D=[...i];i.clear(),r=!1;for(let[g,m]of D){if(!s.has(g)||!g.floating.isConnected)continue;g.callback({type:m})}})}function h(D){for(let g of s)c(g,D);l()}function E(D){if(!n)return null;let g=new Set,m=new n((V)=>{let Y=!1;for(let O of V)if(g.has(O.target))Y=!0;else g.add(O.target);if(!Y)return;c(D,"element-resize"),l()}),{reference:A,floating:v}=D;if(A)m.observe(A);if(v!==A)m.observe(v);return m}let _=()=>h("scroll"),b=()=>h("resize");function k(){if(a)return;t.addEventListener("scroll",_,{passive:!0,capture:!0}),e.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",_,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function S(){if(!a)return;t.removeEventListener("scroll",_,{capture:!0}),e.removeEventListener("resize",b),o?.removeEventListener("scroll",_),o?.removeEventListener("resize",b),a=!1}return{add(D,g,m){let A={reference:D,floating:g,callback:m};s.add(A),k();let v=E(A),V=!1;return()=>{if(V)return;if(V=!0,s.delete(A),i.delete(A),v?.disconnect(),s.size===0)S()}}}}function _e(t){let e=t.ownerDocument,s=Et.get(e);if(!s)s=me(e),Et.set(e,s);return s}function Mt(t,e,s){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 s!=="function")throw TypeError("callback must be a function");return _e(e).add(t,e,s)}function At(t,e,s){if(!pe(e))return null;let i=s.placement||"bottom-start",n=s.distance||0,r=s.flip!==!1,a=s.shift!==!1,o=s.shiftPadding??4,{side:c,align:l,crossAxis:h}=ne(i),E=l?le(t):!1,_=t.getClientRects(),b=c==="bottom"?_[_.length-1]:_[0];if(!b)return null;let k=ue(t,s);if(!k||he(b,k))return null;let S=St(e),D={x:{size:S.width,start:k.x,end:k.right},y:{size:S.height,start:k.y,end:k.bottom}},g=(p,u)=>ae(b,S,p,u,E,n),m=(p,u)=>{let{size:y,start:T,end:L}=D[u];return oe(p,y,T+o,L-o)},A=(p,u)=>{let{size:y,start:T,end:L}=D[u];return m(a?Dt(p,y,T,L,o):p,u)},v=g(c,l);if(r){let p=h==="x"?"y":"x",u=m(v[p],p);if(u>0){let y=re(c),T=g(y,l),L=m(T[p],p);if(L<u)c=y,v=T,u=L}if(p==="x"&&u>0){let y=g("top",l),T=g("bottom",l),L=m(T.y,"y")<m(y.y,"y"),K=L?T:y;if(m(K.y,"y")+A(K.x,"x")<u+A(v.y,"y"))c=L?"bottom":"top",h="x",v=K}}if(h==="x"&&a&&l){let p=m(v.x,"x");if(p>0){let u=l==="end"?"start":"end",y=g(c,u);if(m(y.x,"x")<p)l=u,v=y}}if(a){let{size:p,start:u,end:y}=D[h];v[h]=Dt(v[h],p,u,y,o)}let V=xt(b.x+b.width/2,v.x,S.width),Y=xt(b.y+b.height/2,v.y,S.height),O=`${fe(b,c,k,n,o)}px`,{style:B}=e,x=B.getPropertyValue("--available-height")!==O;B.left=`${v.x}px`,B.top=`${v.y}px`,B.setProperty("--arrow-x",`${V}%`),B.setProperty("--arrow-y",`${Y}%`),B.setProperty("--available-height",O);let M=l?`${c}-${l}`:c;return e.dataset.placement=M,{width:S.width,height:S.height,roomChanged:x,placement:M}}function Tt(t,e,s={}){let i=At(t,e,s);if(!i)return!1;if(i.roomChanged){let n=St(e);if(n.width!==i.width||n.height!==i.height)At(t,e,{...s,placement:i.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 s=document.createElement("input");s.type="hidden",s.value=this.canonical,t.insertAdjacentElement("afterend",s),this.hidden=s}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 s=this.canonical?this.adapter.format(this.canonical):"";t.setCustomValidity(e===s?"":this.messages.invalidDate)}async commit(){let t=this.input,e=++this._commitId,s=t.value.trim();if(!s){if(e!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let i=this.adapter.parse(s);if(!i){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(i);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:i}}setCanonical(t,e={}){let s=t||"";if(s&&!d(s))throw TypeError(`Invalid date-picker value: ${s}`);if(this.dirty(),this.canonical=s,this._dirty=!1,this.hidden)this.hidden.value=s;if(e.format!==!1)this.input.value=s?this.adapter.format(s):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=d(t)?t:this.adapter.parse(t);return e&&d(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 ge=0;class ot extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus"];constructor(){super();this._id=`date-picker-${++ge}`,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=z(),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=(i)=>this._confirmDate(i),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let e=this._adapter(),s=this.getAttribute("value")||(d(t.value)?t.value:e.parse(t.value));if(s&&d(s))this._setValue(s,{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 rt,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 s=this._adapter(),i=d(t.value)?t.value:s.parse(t.value),n=d(e.value)?e.value:s.parse(e.value);if(this._setRange(i||"",n||"",{emit:!1}),t.value.trim()&&!d(i))t.setCustomValidity(this._messages.invalidDate);if(e.value.trim()&&!d(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,s=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),s)e.setAttribute("aria-describedby",s);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,s){if(!this._connected||this._reflecting||e===s)return;if(t==="value"){if(this._rangeMode())return;if(!s||d(s))this._setValue(s||"",{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&&!d(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:s}=et(t);this._setRange(e,s)}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 d(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return d(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={...z(),...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 s of this._fields)s.syncInputState();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields.every((s)=>s.input.disabled||s.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,s=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",s),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 s=`${this._id}-panel`,i=`${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",s),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=s,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=i,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,i].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",s)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let t=this._input,e=this._button,s=this._calendar;if(!t||!e||!s)return;let i=new AbortController;this._controller=i;let{signal:n}=i;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}),s.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!d(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}),s.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 s=new AbortController;this._controller=s;let{signal:i}=s;for(let[n,r]of this._fields.entries()){let a=n===1?"end":"start";r.input.addEventListener("input",()=>r.handleInput(),{signal:i}),r.input.addEventListener("change",()=>void this._commitFieldText(a),{signal:i}),r.input.addEventListener("blur",()=>void this._commitFieldText(a),{signal:i}),r.input.addEventListener("focus",(o)=>this._onFieldFocus(a,o),{signal:i}),r.input.addEventListener("keydown",(o)=>this._onFieldKeyDown(a,o),{signal:i})}t.addEventListener("click",(n)=>{if(this._open){if(n.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:i}),e.addEventListener("click",(n)=>this._captureGridIntent(n),{capture:!0,signal:i}),e.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:i}),e.addEventListener("dateactivate",(n)=>{let r=n,a=r.detail?.date;if(!d(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,(l)=>{let h=l==="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:i}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:i}),this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:i}),this.ownerDocument.addEventListener("reset",(n)=>{let 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:i}),this.addEventListener("keydown",(n)=>this._onEscape(n),{signal:i})}_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 s=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),s)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let i=e.relatedTarget;if(i instanceof Node&&this.contains(i))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(!this._rangeMode()||!this._range)return;if(t.type==="keydown"){let i=t.key;if(i!=="Enter"&&i!==" ")return}if(!(t.target instanceof Element))return;let s=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!d(s))return;this._pendingIntents.set(s,++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[s,i]of this._fields.entries()){if(!i.input.hasAttribute("placeholder")||this._generatedPlaceholder)i.input.placeholder=i.placeholder,this._generatedPlaceholder=!0;let n=s===1?this._range?.end||"":this._range?.start||"";if(n)i.input.value=i.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?`, ${W(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,s=Boolean(t&&e),i=s?this._messages.changeDate:this._messages.chooseDate,n=s?`, ${W(t,this.locale)} – ${W(e,this.locale)}`:"";this._button.setAttribute("aria-label",`${i}${n}`)}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!d(t))throw TypeError(`Invalid date-picker value: ${t}`);let s=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(),s!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let i=this._field.input;i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t){let e=this._calendar;if(!e)return{ok:!0};let s=f(t);if(e.display!==s)e.display=s;let i=await e.ensureDate(t),n=e.getDateState(t);if(!i||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let s=this._field;if(!s)return!1;if(!e.force&&!s.isDirty)return!1;let i=await s.commit();if(i.status==="stale"||i.status==="invalid")return!1;return this._setValue(i.value||"",{emit:t,format:i.status==="ok"}),!0}async _commitFieldText(t){let e=this._fields;if(!e)return!1;let s=t==="end"?1:0,i=e[s];if(!i?.isDirty)return!1;let n=await i.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(s),!1;return this._setBound(t,n.value||"",{emit:!0,user:!0,format:n.status==="ok"}),!0}_setBound(t,e,s={}){if(!this._range)return!1;let i=this._fields;if(!i)return!1;let r=i[t==="end"?1:0];if(!r)return!1;if(s.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:s.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(),s.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,s={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:s.format!==!1}),this._fields[1].setCanonical(e||"",{format:s.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),s.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:s}=this._range,i=Boolean(e&&s&&w(s,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(i&&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 s=this._range?.start||R();this._calendar.display=f(s),this._calendar.focusedDate=s}this.validate()}_focusField(t){let e=t==="end"?1:0,s=this._fields?.[e]?.input;if(!s)return;this._suppressFocusOpen=!0,setTimeout(()=>{s.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 s=t==="end"?"start":"end",i=s==="end"?1:0;if(!this._fields[i].input.disabled&&!this._fields[i].input.readOnly)return s;return""}async validate(){if(this._rangeMode()){let e=this._fields;if(!e)return!0;for(let[s,i]of e.entries()){let n=await i.commit();if(n.status==="ok"||n.status==="clear"){let r=s===1?"end":"start";this._setBound(r,n.value||"",{format:n.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),e.every((s)=>s.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,s=this._calendar,i=this._button;if(!e||!s||!i||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();s.display=f(a),s.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();s.display=f(a),s.focusedDate=a}e.showPopover(),this._open=!0,this._setExpanded(!0);let n=()=>Tt(this,e,{placement:"bottom-start",distance:4,shiftPadding:8});if(n(),this._stopTracking=Mt(this,e,n),t.moveFocus!==!1)queueMicrotask(()=>s.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 s of this._fields||[])s.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,s=this._fields?.[e];if(s&&!s.input.disabled&&!s.input.readOnly)return t}return this._resolveRangeEndpoint()}}function $t(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",G);if(!customElements.get("date-picker"))customElements.define("date-picker",ot)}$t();})();
@@ -1,5 +1,5 @@
1
- /*** @lekoala/date-picker v0.1.0 - https://github.com/lekoala/date-picker ***/
2
- (()=>{var ct=`:where(date-calendar, date-picker) {
1
+ /*** @lekoala/date-picker v0.1.1 - https://github.com/lekoala/date-picker ***/
2
+ (()=>{var ut=`: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);
@@ -105,12 +105,9 @@ date-calendar {
105
105
  background: var(--dp-hover);
106
106
  }
107
107
 
108
- .dp-calendar-heading {
109
- margin: 0 0 0.35rem;
110
- font-size: 0.875rem;
111
- font-weight: 600;
112
- text-align: center;
113
- }
108
+ /* .dp-calendar-heading is always visually hidden: it names the grid via
109
+ aria-labelledby and stays the aria-live announcement channel while the
110
+ month/year selects render the same info visually. */
114
111
 
115
112
  .dp-grid {
116
113
  border-collapse: separate;
@@ -343,7 +340,7 @@ date-picker[range] > .dp-picker-button {
343
340
  color: GrayText;
344
341
  }
345
342
  }
346
- `;var Ft=/^(\d{4})-(\d{2})-(\d{2})$/,Rt=/^(\d{4})-(\d{2})$/;function Ot(t){return t%4===0&&(t%100!==0||t%400===0)}function Z(t,e){if(e===2)return Ot(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=Ft.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>Z(i,s))return null;return{year:i,month:s,day:n}}function c(t){return F(t)!==null}function f(t){let e=String(t||""),i=Rt.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(!c(s))throw TypeError(`Invalid civil date: ${s}`);return s}function X(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 X(e)}function w(t,e){if(!c(t)||!c(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=X(i);return s.setUTCDate(s.getUTCDate()+e),Ht(s)}function J(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,Z(n,a));return P(n,a,o)}function ut(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,Z(s,i.month));return P(s,i.month,n)}function V(t,e){let i=`${f(t)}-01`;return f(J(i,e))}function zt(t){return`${f(t)}-01`}function Bt(t){let e=F(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return P(e.year,e.month,Z(e.year,e.month))}function Vt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return X(e).getUTCDay()}function Q(t,e=1){if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6");let i=(Vt(t)-e+7)%7;return I(t,-i)}function et(t,e=1){return I(Q(t,e),6)}function ht(t,e={}){let i=e.firstDay??1,s=Q(zt(t),i),n=et(Bt(t),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let l=0;l<7;l++)o.push(I(a,l));r.push(o),a=I(a,7)}return r}function ft(t,e="",i=""){if(!c(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 pt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let i=X(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 it{constructor(t={}){let e=R();this.firstDay=t.firstDay??1,this.value=t.value&&c(t.value)?t.value:"",this.focused=t.focused&&c(t.focused)?t.focused:this.value||e,this.display=t.display?f(t.display):f(this.focused)}setValue(t){if(t&&!c(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=J(`${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(!c(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(J(this.focused,t))}moveFocusYears(t){return this.setFocused(ut(this.focused,t))}focusWeekStart(){return this.setFocused(Q(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(et(this.focused,this.firstDay))}navigateMonth(t){let e=V(this.display,t);return this.setDisplay(e),this.display}}function tt(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&&!c(e))throw TypeError(`Invalid range start: ${e}`);if(i&&!c(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 mt(t,e){if(!e||!c(t))return"";let{start:i,end:s}=e;if(!i||!c(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 st{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(!c(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 _t=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function z(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 Pt(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 gt(t,e){let i=String(t||"").replace(_t,"").trim();for(let[s,n]of Pt(e))i=i.split(s).join(n);return i}function Y(t,e=""){let i=z(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(N(t))}function yt(t,e=""){let i=z(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(N(`${t.slice(0,7)}-15`))}function bt(t="",e="long"){let i=z(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 nt(t="",e=1,i="short"){let s=z(t),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=N("2026-01-04");return Array.from({length:7},(a,o)=>{let l=new Date(r);return l.setUTCDate(r.getUTCDate()+(e+o)%7),n.format(l)})}function Nt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(t=""){let e=z(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(_t,"")}).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=gt(d.value,e).replace(/\s+/g," ");return Nt(h).replace(/\\ /g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(d){if(!c(d))return"";return i.format(N(d))},parse(d){let h=gt(d,e);if(c(h))return h;let E=l.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 Ut={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"},Yt={...Ut};function W(){return{...Yt}}function vt(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 Wt=0;function A(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function jt(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&e<=6?e:1}function Kt(t){return Number(t.slice(0,4))}function qt(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 Gt(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class q extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection"];constructor(){super();this._id=`date-calendar-${++Wt}`,this._model=new it,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 z(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&&!c(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 c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return jt(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=tt(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||c(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 ft(t,this.min,this.max)}_weeks(t=this.display){let e=ht(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(c(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(!c(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 l=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,h]of vt(l))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(!c(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(!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(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(c(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=Kt(i),n=Number(i.slice(5,7)),r=bt(e,"long"),a=nt(e,this.firstDay,"short"),o=nt(e,this.firstDay,"long"),l=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=l.map((D)=>{let S=m?`<th scope="row" class="dp-week-number">${pt(D[0])}</th>`:"",p=D.map((u)=>{let y=this.getDateState(u),M=f(u)!==i,L=this.value===u,j=this.focusedDate===u,ot=u===d,dt=mt(u,this._highlightedRange),lt=Gt(dt),$t=typeof y.description==="string"?y.description:"",Lt=[Y(u,e),$t,lt?this._messages[lt]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${u}"${M?' data-outside-month="true"':""}${ot?' data-today="true" aria-current="date"':""}${L?' data-selected="true" aria-selected="true"':""}${qt(dt)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${j?"0":"-1"}" aria-label="${A(Lt)}"><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,H=O instanceof HTMLElement&&this.contains(O)?this._focusTargetKey(O):"";if(this._rendering=!0,this.innerHTML=`
343
+ `;var Rt=/^(\d{4})-(\d{2})-(\d{2})$/,Ot=/^(\d{4})-(\d{2})$/;function zt(t){return t%4===0&&(t%100!==0||t%400===0)}function X(t,e){if(e===2)return zt(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=Rt.exec(String(t||""));if(!e)return null;let i=Number(e[1]),s=Number(e[2]),n=Number(e[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>X(i,s))return null;return{year:i,month:s,day:n}}function l(t){return F(t)!==null}function f(t){let e=String(t||""),i=Ot.exec(e);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=F(e);if(!s)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function P(t,e,i){let s=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!l(s))throw TypeError(`Invalid civil date: ${s}`);return s}function J(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function Ht(t){return P(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function N(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e)}function w(t,e){if(!l(t)||!l(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function I(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let s=J(i);return s.setUTCDate(s.getUTCDate()+e),Ht(s)}function Q(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+e,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,X(n,a));return P(n,a,o)}function ht(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let s=i.year+e,n=Math.min(i.day,X(s,i.month));return P(s,i.month,n)}function V(t,e){let i=`${f(t)}-01`;return f(Q(i,e))}function Bt(t){return`${f(t)}-01`}function Vt(t){let e=F(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return P(e.year,e.month,X(e.year,e.month))}function Pt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return J(e).getUTCDay()}function K(t){if(t===7)return 0;if(!Number.isInteger(t)||t<0||t>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return t}function tt(t,e=1){let i=(Pt(t)-K(e)+7)%7;return I(t,-i)}function it(t,e=1){return I(tt(t,e),6)}function ft(t,e={}){let i=e.firstDay??1,s=tt(Bt(t),i),n=it(Vt(t),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let c=0;c<7;c++)o.push(I(a,c));r.push(o),a=I(a,7)}return r}function pt(t,e="",i=""){if(!l(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&w(t,e)<0)return e;if(i&&w(t,i)>0)return i;return t}function R(){let t=new Date;return P(t.getFullYear(),t.getMonth()+1,t.getDate())}function mt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let i=J(e),s=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-s);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-n.getTime())/86400000+1)/7)}class st{constructor(t={}){let e=R();this.firstDay=K(t.firstDay??1),this.value=t.value&&l(t.value)?t.value:"",this.focused=t.focused&&l(t.focused)?t.focused:this.value||e,this.display=t.display?f(t.display):f(this.focused)}setValue(t){if(t&&!l(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=f(t),i=Number(this.focused.slice(8,10))||1,s=Q(`${e}-01`,0),n=I(s,Math.max(0,i-1));return this.focused=f(n)===e?n:I(`${V(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!l(t))throw TypeError(`Invalid focused date: ${t}`);if(this.focused=t,e.follow!==!1)this.display=f(t);return this.focused}moveFocusDays(t){return this.setFocused(I(this.focused,t))}moveFocusMonths(t){return this.setFocused(Q(this.focused,t))}moveFocusYears(t){return this.setFocused(ht(this.focused,t))}focusWeekStart(){return this.setFocused(tt(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(it(this.focused,this.firstDay))}navigateMonth(t){let e=V(this.display,t);return this.setDisplay(e),this.display}}function et(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:i=""}=t;if(e&&!l(e))throw TypeError(`Invalid range start: ${e}`);if(i&&!l(i))throw TypeError(`Invalid range end: ${i}`);if(!e&&i)throw TypeError("highlightedRange cannot define an end without a start");if(e&&i&&w(i,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:i}}function gt(t,e){if(!e||!l(t))return"";let{start:i,end:s}=e;if(!i||!l(i))return"";if(i===t)return s?s===t?"single":"start":"start";if(s&&s===t)return"end";if(s&&w(t,i)>=0&&w(t,s)<=0)return"in";return""}class nt{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&w(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}activate(t,e=()=>!0){if(!l(t))throw TypeError(`Invalid range activation: ${t}`);if(this.complete&&(w(t,this.start)<0||w(t,this.end)>0)){let i=w(t,this.start)<0?"start":"end";if(!e(i))return{status:"refused",endpoint:i};return this[i]=t,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&w(t,this.start)<0)return{status:"refused",endpoint:"end"};if(!e("end"))return{status:"refused",endpoint:"end"};return this.end=t,{status:this.start?"complete":"pending",endpoint:"end"}}if(!e("start"))return{status:"refused",endpoint:"start"};if(this.start=t,!e("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var yt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function H(t=""){if(t)return t;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Nt(t){let e=new Intl.NumberFormat(t,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(e.format(s),String(s));return i}function _t(t,e){let i=String(t||"").replace(yt,"").trim();for(let[s,n]of Nt(e))i=i.split(s).join(n);return i}function Y(t,e=""){let i=H(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(N(t))}function bt(t,e=""){let i=H(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(N(`${t.slice(0,7)}-15`))}function vt(t="",e="long"){let i=H(t),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(N(`2026-${String(r+1).padStart(2,"0")}-15`)))}function rt(t="",e=1,i="short"){let s=H(t),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=K(e),a=N("2026-01-04");return Array.from({length:7},(o,c)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+c)%7),n.format(d)})}function Ut(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(t=""){let e=H(t),i=new Intl.DateTimeFormat(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=N("2006-11-22"),n=i.formatToParts(s).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(yt,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let h=_t(d.value,e).replace(/\s+/g," ");return Ut(h).replace(/\\ /g,"\\s*")}).join(""),c=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(d){if(!l(d))return"";return i.format(N(d))},parse(d){let h=_t(d,e);if(l(h))return h;let E=c.exec(h);if(!E)return"";let g={};if(r.forEach((b,k)=>{g[b]=Number(E[k+1])}),!g.year||!g.month||!g.day)return"";try{return P(g.year,g.month,g.day)}catch{return""}}}}var Yt={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Wt={...Yt};function W(){return{...Wt}}function wt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,i=new Map;if(Array.isArray(e)){for(let s of e){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(e&&typeof e==="object")for(let[s,n]of Object.entries(e))i.set(s,n&&typeof n==="object"?n:{});return i}var jt=0;function A(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function Kt(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function qt(t){return Number(t.slice(0,4))}function Gt(t){switch(t){case"single":return' data-range-start="true" data-range-end="true"';case"start":return' data-range-start="true"';case"end":return' data-range-end="true"';case"in":return' data-in-range="true"';default:return""}}function Zt(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class G extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection"];constructor(){super();this._id=`date-calendar-${++jt}`,this._model=new st,this._connected=!1,this._rendering=!1,this._source=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._messages=W(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return H(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get value(){return this._model.value}set value(t){let e=t||"";if(e&&!l(e))throw TypeError(`Invalid calendar value: ${e}`);if(e===this._model.value)return;if(this._model.setValue(e),this._reflect("value",e),this._connected)this.render()}get display(){return this._model.display}set display(t){this._setDisplay(t,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(t){let e=t||"";if(e===this._model.focused)return;this.focusDate(e,{moveFocus:!1})}get min(){let t=this.getAttribute("min")||"";return l(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return l(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return Kt(this.getAttribute("first-day")||"1")}set firstDay(t){this.setAttribute("first-day",String(t))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(t){this.setAttribute("selection",t==="none"?"none":"single")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=et(t);if(e.start===this._highlightedRange.start&&e.end===this._highlightedRange.end)return;if(this._highlightedRange=e,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(t){this.toggleAttribute("fixed-weeks",Boolean(t))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(t){this.toggleAttribute("show-week-numbers",Boolean(t))}get messages(){return this._messages}set messages(t){if(this._messages={...W(),...t||{}},this._connected)this.render()}get source(){return this._source}set source(t){this._source=t||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._connected)this.render()}_syncModel(){let t=this.firstDay;this._model.firstDay=t;let e=this.getAttribute("value")||"";if(!e||l(e))this._model.value=e;let i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(i)}catch{}else if(this._model.value)this._model.display=f(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=f(this._model.focused)}_reflect(t,e){if(this._rendering=!0,e){if(this.getAttribute(t)!==e)this.setAttribute(t,e)}else if(this.hasAttribute(t))this.removeAttribute(t);this._rendering=!1}_clamp(t){return pt(t,this.min,this.max)}_weeks(t=this.display){let e=ft(t,{firstDay:this.firstDay});if(!this.fixedWeeks||e.length>=6)return e;let i=e[e.length-1]?.[6]||"";while(e.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(I(i,n));e.push(s),i=s[6]}return e}_focusTargetKey(t){if(t.matches(".dp-month-select, .dp-year-select, .dp-year-input")&&t.id)return`#${CSS.escape(t.id)}`;if(t.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(t.dataset.calendarAction||"")}"]`;if(t.matches(".dp-day[data-date]")){let e=t.getAttribute("data-date")||"";if(l(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),i=e[0],s=e[e.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},i=this._dateState?.(t,{...e})||{},s={...e,...i},n=this.min&&w(t,this.min)<0||this.max&&w(t,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(s.disabled)||a;return{...s,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(t){if(!l(t)||!this._source)return!0;return await this._loadDisplay(f(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let i=this._range(t),s=`${i.start}/${i.end}`;if(this._loadedRanges.has(s))return"loaded";if(s===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=s;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let c=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,h]of wt(c))this._sourceStates.set(d,h);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),e&&this._connected&&f(this.display)===f(t))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===s)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let i=this._model.display;if(this._model.setDisplay(t),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(e.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let t=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...t},bubbles:!0}))}previousMonth(){return this._setDisplay(V(this.display,-1))}nextMonth(){return this._setDisplay(V(this.display,1))}focusDate(t,e={}){if(!l(t))throw TypeError(`Invalid date: ${t}`);let i=this._clamp(t),s=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),s!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(t,e,i=!0){let s=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(t,e){if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async _activate(t){let e=await this.ensureDate(t),i=this.getDateState(t);if(!e||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:t,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:t,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(t),this._reflect("value",t),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:t},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(t)===this.display)this._moveSelectionDom(n,t);else this.render()}else if(this._connected){if(f(t)!==this.display)this.render()}return!0}_onClick(t){let e=t.target;if(!(e instanceof Element))return;let i=e.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let s=e.closest(".dp-day[data-date]");if(!(s instanceof HTMLTableCellElement))return;let n=s.dataset.date||"";if(!l(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this._activate(n)}_onChange(t){let e=t.target;if(e instanceof HTMLSelectElement&&e.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${e.value}`);return}if(e instanceof HTMLSelectElement&&e.matches(".dp-year-select")){this._setDisplay(`${e.value}-${this.display.slice(5,7)}`);return}if(e instanceof HTMLInputElement&&e.matches(".dp-year-input")){let i=Number(e.value);if(!Number.isInteger(i)||i<1||i>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||"";if(l(i))this._model.focused=i}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._activate(i);return}let s=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),t.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(t.key==="ArrowRight")this._model.moveFocusDays(1);else if(t.key==="ArrowUp")this._model.moveFocusDays(-7);else if(t.key==="ArrowDown")this._model.moveFocusDays(7);else if(t.key==="Home")this._model.focusWeekStart();else if(t.key==="End")this._model.focusWeekEnd();else if(t.key==="PageUp")t.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(t.key==="PageDown")t.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,i=this.display,s=qt(i),n=Number(i.slice(5,7)),r=vt(e,"long"),a=rt(e,this.firstDay,"short"),o=rt(e,this.firstDay,"long"),c=this._weeks(),d=R(),h=`${this._id}-heading`,E=`${this._id}-grid`,g=this.min?f(this.min):"",b=this.max?f(this.max):"",k=Boolean(g&&V(i,-1)<g),T=Boolean(b&&V(i,1)>b),x=this.min?` min="${Number(this.min.slice(0,4))}"`:"",_=this.max?` max="${Number(this.max.slice(0,4))}"`:"",m=this.showWeekNumbers&&this.firstDay===1,C=m?`<th scope="col" class="dp-week-heading" abbr="${A(this._messages.week)}">#</th>`:"",v=r.map((D,S)=>{let p=S+1,u=`${String(s).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=g&&u<g||b&&u>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${A(D)}</option>`}).join(""),B=a.map((D,S)=>`<th scope="col" abbr="${A(o[S])}">${A(D.replace(".",""))}</th>`).join(""),U=c.map((D)=>{let S=m?`<th scope="row" class="dp-week-number">${mt(D[0])}</th>`:"",p=D.map((u)=>{let y=this.getDateState(u),M=f(u)!==i,L=this.value===u,j=this.focusedDate===u,dt=u===d,lt=gt(u,this._highlightedRange),ct=Zt(lt),Lt=typeof y.description==="string"?y.description:"",It=[Y(u,e),Lt,ct?this._messages[ct]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${u}"${M?' data-outside-month="true"':""}${dt?' data-today="true" aria-current="date"':""}${L?' data-selected="true" aria-selected="true"':""}${Gt(lt)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${j?"0":"-1"}" aria-label="${A(It)}"><span class="dp-day-number" aria-hidden="true">${Number(u.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${S}${p}</tr>`}).join(""),O=document.activeElement,z=O instanceof HTMLElement&&this.contains(O)?this._focusTargetKey(O):"";if(this._rendering=!0,this.innerHTML=`
347
344
  <div class="dp-calendar-shell">
348
345
  <div class="dp-calendar-header">
349
346
  <label class="dp-visually-hidden" for="${this._id}-month">${A(this._messages.month)}</label>
@@ -353,9 +350,9 @@ date-picker[range] > .dp-picker-button {
353
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>
354
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>
355
352
  </div>
356
- <h2 id="${h}" class="dp-calendar-heading" aria-live="polite">${A(yt(`${i}-15`,e))}</h2>
353
+ <h2 id="${h}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${A(bt(`${i}-15`,e))}</h2>
357
354
  <table id="${E}" class="dp-grid" role="grid" aria-labelledby="${h}">
358
355
  <thead><tr>${C}${B}</tr></thead>
359
356
  <tbody>${U}</tbody>
360
357
  </table>
361
- </div>`,this._rendering=!1,H)queueMicrotask(()=>{let D=this.querySelector(H);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 Ct(t){return t==="top"||t==="bottom"?"x":"y"}function Zt(t){let[e,i=null]=t.split("-");return{side:e,align:i,crossAxis:Ct(e)}}function Xt(t){return{top:"bottom",bottom:"top",left:"right",right:"left"}[t]||t}function Jt(t,e,i,s,n,r){let a=Ct(i),o=t.x+t.width/2-e.width/2,l=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:l};break;case"left":h={x:t.x-e.width-r,y:l};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 Qt(t,e,i,s){return Math.max(i-t,0)+Math.max(t+e-s,0)}function te(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 ee=25;function ie(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,l=t.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(l>0&&l<=ee){let d=e.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 se(t,e){return e.scope?e.scope.getBoundingClientRect():ie(t.ownerDocument)}function wt(t,e,i,s,n){let r=i+n,a=s-e-n,o=a>=r,l=o?r:i,d=o?a:s-e;return Math.max(l,Math.min(t,d))}function xt(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 ne(t,e){return t.right<e.x||t.left>e.right||t.bottom<e.y||t.top>e.bottom}function re(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 ae(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function At(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 Dt=new WeakMap,Et={scroll:0,resize:1,"element-resize":2};function oe(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 l(x,_){let m=s.get(x);if(m===void 0||Et[_]>Et[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)l(_,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;l(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 de(t){let e=t.ownerDocument,i=Dt.get(e);if(!i)i=oe(e),Dt.set(e,i);return i}function Tt(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 de(e).add(t,e,i)}function kt(t,e,i){if(!ae(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:l,align:d,crossAxis:h}=Zt(s),E=d?te(t):!1,g=t.getClientRects(),b=l==="bottom"?g[g.length-1]:g[0];if(!b)return null;let k=se(t,i);if(!k||ne(b,k))return null;let T=At(e),x={x:{size:T.width,start:k.x,end:k.right},y:{size:T.height,start:k.y,end:k.bottom}},_=(p,u)=>Jt(b,T,p,u,E,n),m=(p,u)=>{let{size:y,start:M,end:L}=x[u];return Qt(p,y,M+o,L-o)},C=(p,u)=>{let{size:y,start:M,end:L}=x[u];return m(a?wt(p,y,M,L,o):p,u)},v=_(l,d);if(r){let p=h==="x"?"y":"x",u=m(v[p],p);if(u>0){let y=Xt(l),M=_(y,d),L=m(M[p],p);if(L<u)l=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"))l=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=_(l,u);if(m(y.x,"x")<p)d=u,v=y}}if(a){let{size:p,start:u,end:y}=x[h];v[h]=wt(v[h],p,u,y,o)}let B=xt(b.x+b.width/2,v.x,T.width),U=xt(b.y+b.height/2,v.y,T.height),O=`${re(b,l,k,n,o)}px`,{style:H}=e,D=H.getPropertyValue("--available-height")!==O;H.left=`${v.x}px`,H.top=`${v.y}px`,H.setProperty("--arrow-x",`${B}%`),H.setProperty("--arrow-y",`${U}%`),H.setProperty("--available-height",O);let S=d?`${l}-${d}`:l;return e.dataset.placement=S,{width:T.width,height:T.height,roomChanged:D,placement:S}}function St(t,e,i={}){let s=kt(t,e,i);if(!s)return!1;if(s.roomChanged){let n=At(e);if(n.width!==s.width||n.height!==s.height)kt(t,e,{...i,placement:s.placement,flip:!1})}return!0}class G{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=K(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=K(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&&!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(e.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=c(t)?t:this.adapter.parse(t);return e&&c(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 le=0;class rt extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus"];constructor(){super();this._id=`date-picker-${++le}`,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 G(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")||(c(t.value)?t.value:e.parse(t.value));if(i&&c(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 G(t,{messages:this._messages,locale:this.locale}),new G(e,{messages:this._messages,locale:this.locale})],this._range=new st,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=c(t.value)?t.value:i.parse(t.value),n=c(e.value)?e.value:i.parse(e.value);if(this._setRange(s||"",n||"",{emit:!1}),t.value.trim()&&!c(s))t.setCustomValidity(this._messages.invalidDate);if(e.value.trim()&&!c(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||c(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&&!c(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}=tt(t);this._setRange(e,i)}get locale(){return z(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get min(){let t=this.getAttribute("min")||"";return c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(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??K(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 q;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 l=[this._originalDescribedBy,s].filter(Boolean).join(" ");e.setAttribute("aria-describedby",l),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(!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 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(!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 h=d==="end"?1:0,E=this._fields?.[h];return E!=null&&!E.input.disabled&&!E.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}),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(!c(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&&!c(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 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(t),l}_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,l=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(s&&r===t)o.setCustomValidity(l),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=()=>St(this,e,{placement:"bottom-start",distance:4,shiftPadding:8});if(n(),this._stopTracking=Tt(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 at(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",q);if(!customElements.get("date-picker"))customElements.define("date-picker",rt)}at();var Mt="lekoala-date-picker-styles";if(!document.getElementById(Mt)){let t=document.createElement("style");t.id=Mt,t.textContent=ct,document.head.append(t)}at();})();
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();})();
@@ -1 +1 @@
1
- {"version":3,"file":"calendar-model.d.ts","sourceRoot":"","sources":["../../src/calendar-model.js"],"names":[],"mappings":"AAYA,qBAAa,aAAa;IAMjB,QAAQ;IACR,KAAK;IACL,OAAO;IACP,OAAO;IARd;;OAEG;IACH,YAAY,OAAO,AAFhB,CAAsF,EAA9E;QAAC,KAAK,CAAC,EAAC,MAAM,CAAC;QAAC,OAAO,CAAC,EAAC,MAAM,CAAC;QAAC,OAAO,CAAC,EAAC,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAC,MAAM,CAAA;KAErD,EAMvB;IAED,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EADF,MACE,UAIb;IAED,4BAA4B;IAC5B,UAAU,CAAC,KAAK,EADJ,MACI,UAQf;IAED,iEAAiE;IACjE,UAAU,CAAC,KAAK,EADJ,MACI,EAAE,OAAO,AADC,CAAoC,EAA5B;QAAC,MAAM,CAAC,EAAC,OAAO,CAAA;KACpB,UAK7B;IAED,6BAA6B;IAC7B,aAAa,CAAC,MAAM,EADR,MACQ,UAEnB;IAED,6BAA6B;IAC7B,eAAe,CAAC,MAAM,EADV,MACU,UAErB;IAED,6BAA6B;IAC7B,cAAc,CAAC,MAAM,EADT,MACS,UAEpB;IAED,cAAc,WAEb;IAED,YAAY,WAEX;IAED,+FAA+F;IAC/F,aAAa,CAAC,MAAM,EAD0D,MAC1D,UAInB;CACF"}
1
+ {"version":3,"file":"calendar-model.d.ts","sourceRoot":"","sources":["../../src/calendar-model.js"],"names":[],"mappings":"AAaA,qBAAa,aAAa;IAMjB,QAAQ;IACR,KAAK;IACL,OAAO;IACP,OAAO;IARd;;OAEG;IACH,YAAY,OAAO,AAFhB,CAAsF,EAA9E;QAAC,KAAK,CAAC,EAAC,MAAM,CAAC;QAAC,OAAO,CAAC,EAAC,MAAM,CAAC;QAAC,OAAO,CAAC,EAAC,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAC,MAAM,CAAA;KAErD,EAMvB;IAED,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EADF,MACE,UAIb;IAED,4BAA4B;IAC5B,UAAU,CAAC,KAAK,EADJ,MACI,UAQf;IAED,iEAAiE;IACjE,UAAU,CAAC,KAAK,EADJ,MACI,EAAE,OAAO,AADC,CAAoC,EAA5B;QAAC,MAAM,CAAC,EAAC,OAAO,CAAA;KACpB,UAK7B;IAED,6BAA6B;IAC7B,aAAa,CAAC,MAAM,EADR,MACQ,UAEnB;IAED,6BAA6B;IAC7B,eAAe,CAAC,MAAM,EADV,MACU,UAErB;IAED,6BAA6B;IAC7B,cAAc,CAAC,MAAM,EADT,MACS,UAEpB;IAED,cAAc,WAEb;IAED,YAAY,WAEX;IAED,+FAA+F;IAC/F,aAAa,CAAC,MAAM,EAD0D,MAC1D,UAInB;CACF"}
@@ -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;AA2EhD,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;IAe3C,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;;;;;;;;;;;;;;;;;;;;IAlChB,MAAM,CAAC,kBAAkB,WAUvB;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,cAAc;IACd,IAAI,gBAAgB;eApKD,MAAM;aAAK,MAAM;MAsKnC;IAED,IAAI,gBAAgB,CAAC,KAAK;eAxKP,MAAM;aAAK,MAAM;KAwKV,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,QAmHjB;CACF"}
1
+ {"version":3,"file":"date-calendar.d.ts","sourceRoot":"","sources":["../../src/date-calendar.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA4EhD,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;IAe3C,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;;;;;;;;;;;;;;;;;;;;IAlChB,MAAM,CAAC,kBAAkB,WAUvB;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,cAAc;IACd,IAAI,gBAAgB;eApKD,MAAM;aAAK,MAAM;MAsKnC;IAED,IAAI,gBAAgB,CAAC,KAAK;eAxKP,MAAM;aAAK,MAAM;KAwKV,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,QAmHjB;CACF"}
@@ -40,6 +40,12 @@ export declare function startOfMonth(value: string): string;
40
40
  export declare function endOfMonth(value: string): string;
41
41
  /** 0=Sunday ... 6=Saturday. @param {string} value */
42
42
  export declare function dayOfWeek(value: string): number;
43
+ /**
44
+ * Canonical first weekday. 7 is the ISO-style Sunday alias of 0; values 1..6
45
+ * keep their current meaning. Any other value throws.
46
+ * @param {number} firstDay
47
+ */
48
+ export declare function normalizeFirstDay(firstDay: number): number;
43
49
  /** @param {string} value @param {number} firstDay */
44
50
  export declare function startOfWeek(value: string, firstDay?: number): string;
45
51
  /** @param {string} value @param {number} firstDay */
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/date.js"],"names":[],"mappings":"AAGA,2BAA2B;AAC3B,wBAAgB,UAAU,CAAC,IAAI,EADnB,MACmB,WAE9B;AAED,iDAAiD;AACjD,wBAAgB,WAAW,CAAC,IAAI,EADpB,MACoB,EAAE,KAAK,EADN,MACM,qBAGtC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAHpB,MAGoB,GAFlB;IAAC,IAAI,EAAC,MAAM,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,GAAG,EAAC,MAAM,CAAA;CAAC,GAAG,IAAI,CAW1D;AAED,4BAA4B;AAC5B,wBAAgB,MAAM,CAAC,KAAK,EADhB,MACgB,WAE3B;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAHnB,MAGmB,GAFjB,MAAM,CAYlB;AAED,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,IAAI,EADlB,MACkB,EAAE,KAAK,EADJ,MACI,EAAE,GAAG,EADa,MACb,UAIzC;AAeD,4BAA4B;AAC5B,wBAAgB,UAAU,CAAC,KAAK,EADpB,MACoB,QAI/B;AAED,0CAA0C;AAC1C,wBAAgB,YAAY,CAAC,CAAC,EADlB,MACkB,EAAE,CAAC,EADH,MACG,cAGhC;AAED,mDAAmD;AACnD,wBAAgB,OAAO,CAAC,KAAK,EADjB,MACiB,EAAE,MAAM,EADH,MACG,UAOpC;AAED,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB,EAAE,MAAM,EADL,MACK,UAUtC;AAED,mDAAmD;AACnD,wBAAgB,QAAQ,CAAC,KAAK,EADlB,MACkB,EAAE,MAAM,EADJ,MACI,UAOrC;AAED,mDAAmD;AACnD,wBAAgB,UAAU,CAAC,KAAK,EADpB,MACoB,EAAE,MAAM,EADN,MACM,UAGvC;AAED,4BAA4B;AAC5B,wBAAgB,YAAY,CAAC,KAAK,EADtB,MACsB,UAEjC;AAED,4BAA4B;AAC5B,wBAAgB,UAAU,CAAC,KAAK,EADpB,MACoB,UAI/B;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,KAAK,EADM,MACN,UAI9B;AAED,qDAAqD;AACrD,wBAAgB,WAAW,CAAC,KAAK,EADrB,MACqB,EAAE,QAAQ,GADT,MACa,UAK9C;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB,EAAE,QAAQ,GADP,MACW,UAE5C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAHxB,MAGwB,EAAE,OAAO,AAFzC,CAAsC,EAA9B;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAEoB,cAchD;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB,EAAE,GAAG,AADV,CAAsB,EAAd,MACO,EAAE,GAAG,AADE,CAAqB,EAAb,MACL,UAKlD;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,WAGvB;AAED,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,KAAK,EADD,MACC,UAUlC"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/date.js"],"names":[],"mappings":"AAGA,2BAA2B;AAC3B,wBAAgB,UAAU,CAAC,IAAI,EADnB,MACmB,WAE9B;AAED,iDAAiD;AACjD,wBAAgB,WAAW,CAAC,IAAI,EADpB,MACoB,EAAE,KAAK,EADN,MACM,qBAGtC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAHpB,MAGoB,GAFlB;IAAC,IAAI,EAAC,MAAM,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,GAAG,EAAC,MAAM,CAAA;CAAC,GAAG,IAAI,CAW1D;AAED,4BAA4B;AAC5B,wBAAgB,MAAM,CAAC,KAAK,EADhB,MACgB,WAE3B;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAHnB,MAGmB,GAFjB,MAAM,CAYlB;AAED,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,IAAI,EADlB,MACkB,EAAE,KAAK,EADJ,MACI,EAAE,GAAG,EADa,MACb,UAIzC;AAeD,4BAA4B;AAC5B,wBAAgB,UAAU,CAAC,KAAK,EADpB,MACoB,QAI/B;AAED,0CAA0C;AAC1C,wBAAgB,YAAY,CAAC,CAAC,EADlB,MACkB,EAAE,CAAC,EADH,MACG,cAGhC;AAED,mDAAmD;AACnD,wBAAgB,OAAO,CAAC,KAAK,EADjB,MACiB,EAAE,MAAM,EADH,MACG,UAOpC;AAED,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB,EAAE,MAAM,EADL,MACK,UAUtC;AAED,mDAAmD;AACnD,wBAAgB,QAAQ,CAAC,KAAK,EADlB,MACkB,EAAE,MAAM,EADJ,MACI,UAOrC;AAED,mDAAmD;AACnD,wBAAgB,UAAU,CAAC,KAAK,EADpB,MACoB,EAAE,MAAM,EADN,MACM,UAGvC;AAED,4BAA4B;AAC5B,wBAAgB,YAAY,CAAC,KAAK,EADtB,MACsB,UAEjC;AAED,4BAA4B;AAC5B,wBAAgB,UAAU,CAAC,KAAK,EADpB,MACoB,UAI/B;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,KAAK,EADM,MACN,UAI9B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAF/B,MAE+B,UAKzC;AAED,qDAAqD;AACrD,wBAAgB,WAAW,CAAC,KAAK,EADrB,MACqB,EAAE,QAAQ,GADT,MACa,UAG9C;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB,EAAE,QAAQ,GADP,MACW,UAE5C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAHxB,MAGwB,EAAE,OAAO,AAFzC,CAAsC,EAA9B;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAEoB,cAchD;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB,EAAE,GAAG,AADV,CAAsB,EAAd,MACO,EAAE,GAAG,AADE,CAAqB,EAAb,MACL,UAKlD;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,WAGvB;AAED,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,KAAK,EADD,MACC,UAUlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"intl.d.ts","sourceRoot":"","sources":["../../src/intl.js"],"names":[],"mappings":"AAIA,+BAA+B;AAC/B,wBAAgB,aAAa,CAAC,MAAM,AADhC,CAAwB,EAAhB,MAC6B,UAKxC;AAmBD,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,KAAK,EADxB,MACwB,EAAE,MAAM,AADlB,CAAwB,EAAhB,MACe,UAUhD;AAED,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,KAAK,EADzB,MACyB,EAAE,MAAM,AADnB,CAAwB,EAAhB,MACgB,UAQjD;AAED,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,MAAM,AAD7B,CAAyB,EAAjB,MAC0B,EAAE,KAAK,AADhB,CAA+B,EAAvB,MAAM,GAAC,OACU,YAMrD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,AAJhC,CACA,EADQ,MAI6B,EAAE,QAAQ,AAH/C,CACA,EADQ,MAG2C,EAAE,KAAK,AAF1D,CAAwC,EAAhC,MAAM,GAAC,OAAO,GAAC,QAE6C,YActE;AAOD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,AAFrC,CAAwB,EAAhB,MAEkC;;;IAiCzC,4BAA4B;kBAAhB,MAAM;IAKlB,6CAA6C;gBAAjC,MAAM,GAAiB,MAAM;EAmB5C;AAED,4BAA4B;AAC5B,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB;;;;SAE9B"}
1
+ {"version":3,"file":"intl.d.ts","sourceRoot":"","sources":["../../src/intl.js"],"names":[],"mappings":"AAIA,+BAA+B;AAC/B,wBAAgB,aAAa,CAAC,MAAM,AADhC,CAAwB,EAAhB,MAC6B,UAKxC;AAmBD,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,KAAK,EADxB,MACwB,EAAE,MAAM,AADlB,CAAwB,EAAhB,MACe,UAUhD;AAED,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,KAAK,EADzB,MACyB,EAAE,MAAM,AADnB,CAAwB,EAAhB,MACgB,UAQjD;AAED,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,MAAM,AAD7B,CAAyB,EAAjB,MAC0B,EAAE,KAAK,AADhB,CAA+B,EAAvB,MAAM,GAAC,OACU,YAMrD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,AAJhC,CACA,EADQ,MAI6B,EAAE,QAAQ,AAH/C,CACA,EADQ,MAG2C,EAAE,KAAK,AAF1D,CAAwC,EAAhC,MAAM,GAAC,OAAO,GAAC,QAE6C,YAetE;AAOD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,AAFrC,CAAwB,EAAhB,MAEkC;;;IAiCzC,4BAA4B;kBAAhB,MAAM;IAKlB,6CAA6C;gBAAjC,MAAM,GAAiB,MAAM;EAmB5C;AAED,4BAA4B;AAC5B,wBAAgB,SAAS,CAAC,KAAK,EADnB,MACmB;;;;SAE9B"}
package/docs/API.md CHANGED
@@ -12,11 +12,11 @@ The public surface — flat event names, `selection` values, `--dp-*` styling to
12
12
  | `display` | `YYYY-MM` | value/today month | Month being rendered. |
13
13
  | `min` | `YYYY-MM-DD` | `""` | Earliest activatable date. |
14
14
  | `max` | `YYYY-MM-DD` | `""` | Latest activatable date. |
15
- | `first-day` | `0..6` | `1` | First weekday; Sunday=0, Monday=1. |
15
+ | `first-day` | `0..6` (`7` alias) | `1` | First weekday; Sunday=0, Monday=1. `7` is accepted as an ISO-style alias of Sunday (`@lekoala/calendar` uses 1..7) and never shifts the grid. Other values fall back to Monday. |
16
16
  | `locale` | BCP 47 string | document/navigator | `Intl` locale. |
17
17
  | `selection` | `single \| none` | `single` | Whether accepted activation updates `value`. |
18
18
  | `fixed-weeks` | boolean | false | Render six rows; date math itself stays 4–6. |
19
- | `show-week-numbers` | boolean | false | Show ISO week numbers. |
19
+ | `show-week-numbers` | boolean | false | Show ISO week numbers. The column renders only when `first-day === 1` (Monday-first): the ISO week and the displayed week only coincide then. With Sunday-first (`0`/`7`) the column is silently withheld. |
20
20
 
21
21
  `focusedDate` and `highlightedRange` are properties rather than reflected attributes.
22
22
 
@@ -283,7 +283,10 @@ Public helpers:
283
283
  - `dayOfWeek`
284
284
  - `startOfWeek`
285
285
  - `endOfWeek`
286
+ - `normalizeFirstDay`
286
287
  - `getMonthWeeks`
287
288
  - `clampDate`
288
289
  - `todayISO`
289
290
  - `isoWeekNumber`
291
+
292
+ `normalizeFirstDay(firstDay)` maps `7` to `0` (Sunday) and returns `0..6` unchanged; any other value throws a `RangeError`. It backs `startOfWeek`, `getMonthWeeks` and `weekdayNames`, so those accept `7` as the ISO-style Sunday alias `@lekoala/calendar` uses while `2..6` keep their current meaning.
@@ -25,21 +25,27 @@ A minimal sidebar navigator therefore looks like this:
25
25
  const mini = document.querySelector("#mini");
26
26
  const agenda = document.querySelector("#agenda");
27
27
 
28
- mini.display = agenda.date.toString().slice(0, 7);
29
- mini.focusedDate = agenda.date.toString();
28
+ // The agenda anchor stays application state, not a model property.
29
+ let anchorDate = agenda.getAttribute("date");
30
+
31
+ mini.dateState = (date) => ({
32
+ description: date === anchorDate ? "Shown in the agenda" : "Navigate to this date",
33
+ anchor: date === anchorDate,
34
+ });
30
35
 
31
36
  mini.addEventListener("dateactivate", (event) => {
32
37
  agenda.gotoDate(event.detail.date);
33
38
  });
34
39
 
35
40
  agenda.addEventListener("calendar:datechange", (event) => {
36
- const date = event.detail.date.toString();
37
- mini.display = date.slice(0, 7);
38
- mini.focusedDate = date;
41
+ anchorDate = event.detail.date.toString();
42
+ mini.display = anchorDate.slice(0, 7);
39
43
  });
40
44
  ```
41
45
 
42
- Notice what is missing: the mini calendar does not need a selected value. The agenda anchor is application/calendar state, not form selection state.
46
+ Do not anchor the mini calendar with `mini.focusedDate = date`. `display` and `focusedDate` are deliberately coupled: `setDisplay` re-clamps the focused day into the rendered month (`calendar-model.js`), because the roving-tabbable grid cell must stay visible (ARIA grid contract). So `focusedDate` is the keyboard target, never an application anchor. Keep the anchor in your own state and decorate it through the existing `dateState` / `renderDay` seams.
47
+
48
+ Notice what else is missing: the mini calendar does not need a selected value. The agenda anchor is application/calendar state, not form selection state.
43
49
 
44
50
  ## Active week / availability decoration
45
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lekoala/date-picker",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Native-first date picker and inline calendar primitives",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -5,6 +5,7 @@ import {
5
5
  endOfWeek,
6
6
  isDate,
7
7
  monthKey,
8
+ normalizeFirstDay,
8
9
  shiftMonth,
9
10
  startOfWeek,
10
11
  todayISO,
@@ -16,7 +17,7 @@ export class CalendarModel {
16
17
  */
17
18
  constructor(options = {}) {
18
19
  const today = todayISO();
19
- this.firstDay = options.firstDay ?? 1;
20
+ this.firstDay = normalizeFirstDay(options.firstDay ?? 1);
20
21
  this.value = options.value && isDate(options.value) ? options.value : "";
21
22
  this.focused = options.focused && isDate(options.focused) ? options.focused : this.value || today;
22
23
  this.display = options.display ? monthKey(options.display) : monthKey(this.focused);
@@ -30,6 +30,7 @@ function escapeHtml(value) {
30
30
  /** @param {string} value */
31
31
  function parseFirstDay(value) {
32
32
  const parsed = Number(value);
33
+ if (parsed === 7) return 0;
33
34
  return Number.isInteger(parsed) && parsed >= 0 && parsed <= 6 ? parsed : 1;
34
35
  }
35
36
 
@@ -768,7 +769,7 @@ export class DateCalendarElement extends HTMLElement {
768
769
  <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${escapeHtml(this._messages.previousMonth)}"${prevDisabled ? " 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>
769
770
  <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${escapeHtml(this._messages.nextMonth)}"${nextDisabled ? " 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>
770
771
  </div>
771
- <h2 id="${headingId}" class="dp-calendar-heading" aria-live="polite">${escapeHtml(formatMonthYear(`${display}-15`, locale))}</h2>
772
+ <h2 id="${headingId}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${escapeHtml(formatMonthYear(`${display}-15`, locale))}</h2>
772
773
  <table id="${gridId}" class="dp-grid" role="grid" aria-labelledby="${headingId}">
773
774
  <thead><tr>${weekHeader}${dayHeaders}</tr></thead>
774
775
  <tbody>${rows}</tbody>
@@ -104,12 +104,9 @@ date-calendar {
104
104
  background: var(--dp-hover);
105
105
  }
106
106
 
107
- .dp-calendar-heading {
108
- margin: 0 0 0.35rem;
109
- font-size: 0.875rem;
110
- font-weight: 600;
111
- text-align: center;
112
- }
107
+ /* .dp-calendar-heading is always visually hidden: it names the grid via
108
+ aria-labelledby and stays the aria-live announcement channel while the
109
+ month/year selects render the same info visually. */
113
110
 
114
111
  .dp-grid {
115
112
  border-collapse: separate;
package/src/date.js CHANGED
@@ -141,11 +141,21 @@ export function dayOfWeek(value) {
141
141
  return toUTCDate(parsed).getUTCDay();
142
142
  }
143
143
 
144
+ /**
145
+ * Canonical first weekday. 7 is the ISO-style Sunday alias of 0; values 1..6
146
+ * keep their current meaning. Any other value throws.
147
+ * @param {number} firstDay
148
+ */
149
+ export function normalizeFirstDay(firstDay) {
150
+ if (firstDay === 7) return 0;
151
+ if (!Number.isInteger(firstDay) || firstDay < 0 || firstDay > 6)
152
+ throw new RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");
153
+ return firstDay;
154
+ }
155
+
144
156
  /** @param {string} value @param {number} firstDay */
145
157
  export function startOfWeek(value, firstDay = 1) {
146
- if (!Number.isInteger(firstDay) || firstDay < 0 || firstDay > 6)
147
- throw new RangeError("firstDay must be 0..6");
148
- const offset = (dayOfWeek(value) - firstDay + 7) % 7;
158
+ const offset = (dayOfWeek(value) - normalizeFirstDay(firstDay) + 7) % 7;
149
159
  return addDays(value, -offset);
150
160
  }
151
161
 
package/src/intl.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isDate, parseDate, toIntlDate, toISODate } from "./date.js";
1
+ import { isDate, normalizeFirstDay, parseDate, toIntlDate, toISODate } from "./date.js";
2
2
 
3
3
  const BIDI = /[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;
4
4
 
@@ -72,11 +72,12 @@ export function weekdayNames(locale = "", firstDay = 1, style = "short") {
72
72
  weekday: style,
73
73
  timeZone: "UTC",
74
74
  });
75
+ const normalized = normalizeFirstDay(firstDay);
75
76
  // 2026-01-04 is a Sunday.
76
77
  const sunday = toIntlDate("2026-01-04");
77
78
  return Array.from({ length: 7 }, (_, index) => {
78
79
  const date = new Date(sunday);
79
- date.setUTCDate(sunday.getUTCDate() + ((firstDay + index) % 7));
80
+ date.setUTCDate(sunday.getUTCDate() + ((normalized + index) % 7));
80
81
  return formatter.format(date);
81
82
  });
82
83
  }