@lekoala/date-picker 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/date-picker.css +2 -13
- package/dist/date-picker.js +222 -252
- package/dist/date-picker.min.css +1 -1
- package/dist/date-picker.min.js +12 -13
- package/dist/date-picker.standalone.min.js +11 -12
- package/dist/types/date-calendar.d.ts +2 -98
- package/dist/types/date-picker.d.ts +0 -316
- package/dist/types/date-range.d.ts +10 -33
- package/dist/types/date-range.d.ts.map +1 -1
- package/dist/types/date.d.ts.map +1 -1
- package/dist/types/session.d.ts +17 -0
- package/dist/types/session.d.ts.map +1 -0
- package/docs/ACCESSIBILITY.md +1 -1
- package/docs/API.md +14 -25
- package/docs/ARCHITECTURE.md +74 -0
- package/docs/CALENDAR-INTEGRATION.md +97 -0
- package/docs/DECISIONS.md +30 -3
- package/docs/TESTING.md +8 -0
- package/docs/USE_CASES.md +1 -2
- package/package.json +2 -2
- package/src/date-calendar.js +90 -18
- package/src/date-field.js +32 -9
- package/src/date-picker.css +2 -13
- package/src/date-picker.js +134 -228
- package/src/date-range.js +12 -54
- package/src/date.js +4 -1
- package/src/session.js +23 -0
- package/dist/types/activation-intents.d.ts +0 -10
- package/dist/types/activation-intents.d.ts.map +0 -1
- package/dist/types/date-calendar.d.ts.map +0 -1
- package/dist/types/date-field.d.ts +0 -118
- package/dist/types/date-field.d.ts.map +0 -1
- package/dist/types/date-picker.d.ts.map +0 -1
- package/dist/types/time.d.ts +0 -8
- package/dist/types/time.d.ts.map +0 -1
- package/dist/types/upgrade-properties.d.ts +0 -8
- package/dist/types/upgrade-properties.d.ts.map +0 -1
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
/*** @lekoala/date-picker v0.
|
|
2
|
-
(()=>{var Pt=":where(date-calendar,date-picker){--dp-bg: #ffffff;--dp-fg: #1f2328;--dp-muted: color-mix(in srgb,var(--dp-fg) 58%,var(--dp-bg));--dp-border: color-mix(in srgb,var(--dp-fg) 16%,var(--dp-bg));--dp-hover: color-mix(in srgb,var(--dp-fg) 5%,var(--dp-bg));--dp-accent: #2563eb;--dp-accent-fg: #fff;--dp-focus: var(--dp-accent);--dp-focus-width: 2px;--dp-radius: 0.5rem;--dp-day-size: 2.75rem;--dp-gap: 0.375rem;--dp-header-control-size: 2.25rem;--dp-header-block-gap: 0.75rem;--dp-row-gap: 0.375rem;--dp-picker-button-size: 2.5rem;--dp-year-inline-size: 5.5rem;--dp-day-radius: calc(var(--dp-radius) * 0.75);color: var(--dp-fg);font: inherit}.dp-visually-hidden{position: absolute !important;inline-size: 1px !important;block-size: 1px !important;padding: 0 !important;margin: -1px !important;overflow: hidden !important;clip: rect(0 0 0 0) !important;white-space: nowrap !important;border: 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) var(--dp-year-inline-size) auto auto;align-items: stretch;gap: var(--dp-gap);margin-block-end: var(--dp-header-block-gap)}date-calendar[data-year-first] .dp-calendar-header{grid-template-columns: var(--dp-year-inline-size) minmax(0,1fr) auto auto}.dp-calendar-header :where(button,select,input){box-sizing: border-box;min-inline-size: 0}.dp-calendar-header .dp-skin{min-block-size: var(--dp-header-control-size);padding-block: 0.15rem;border: 1px solid var(--dp-border);border-radius: calc(var(--dp-radius) * 0.75);background: var(--dp-bg);color: var(--dp-fg);font: inherit;line-height: 1.2}.dp-calendar-header input.dp-skin{padding-inline: 0.45rem}.dp-month-select{inline-size: 100%;overflow: hidden;text-overflow: ellipsis}.dp-month-select.dp-skin{appearance: none;padding-inline: 0.45rem 2rem;background-image: linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%);background-position: calc(100% - 0.9rem) 50%,calc(100% - 0.65rem) 50%;background-size: 0.3rem 0.3rem;background-repeat: no-repeat}[dir=\"rtl\"] .dp-month-select.dp-skin,html[dir=\"rtl\"] .dp-month-select.dp-skin{background-position: 0.9rem 50%,0.65rem 50%}.dp-year-input{inline-size: 100%}.dp-nav.dp-skin{display: grid;place-items: center;inline-size: var(--dp-header-control-size);padding: 0;font-size: 1.35rem;line-height: 1;cursor: pointer}.dp-nav svg{display: block;inline-size: 1rem;block-size: 1rem;pointer-events: none}.dp-calendar-header .dp-skin:disabled,.dp-picker-button:disabled{cursor: not-allowed;opacity: 0.45}.dp-nav.dp-skin:hover:not(:disabled){background: var(--dp-hover)}.dp-calendar-header .dp-skin:focus-visible,date-picker>input:not([type=\"hidden\"]):focus-visible,.dp-day:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: calc(var(--dp-focus-width) * -1)}.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 var(--dp-row-gap);table-layout: fixed}.dp-grid :where(th,td){box-sizing: border-box;inline-size: var(--dp-day-size);block-size: var(--dp-day-size);padding: 0;text-align: center}.dp-grid thead th{block-size: 1.5rem;color: var(--dp-muted);font-size: 0.72rem;font-weight: 500}.dp-day{position: relative;border: 1px solid transparent;border-radius: var(--dp-day-radius);cursor: pointer;outline: none;vertical-align: middle;font-size: 0.875rem}.dp-day:is([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]):focus-visible{outline-color: var(--dp-accent-fg)}.dp-day[data-outside-month=\"true\"]{color: var(--dp-muted)}.dp-day[data-selected=\"true\"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-today=\"true\"]:not([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]){border-color: var(--dp-accent)}.dp-day[data-disabled=\"true\"]{cursor: not-allowed;opacity: 0.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\"]{border-radius: 0;background: color-mix(in srgb,var(--dp-accent) 18%,var(--dp-bg))}.dp-day[data-range-start=\"true\"]:has(+ [data-in-range=\"true\"],+ [data-range-end=\"true\"]){border-start-end-radius: 0;border-end-end-radius: 0}.dp-day:is([data-in-range=\"true\"],[data-range-start=\"true\"]) + .dp-day[data-range-end=\"true\"]{border-start-start-radius: 0;border-end-start-radius: 0}.dp-day[data-in-range=\"true\"]:first-of-type{border-start-start-radius: var(--dp-day-radius);border-end-start-radius: var(--dp-day-radius)}.dp-day[data-in-range=\"true\"]:last-of-type{border-start-end-radius: var(--dp-day-radius);border-end-end-radius: var(--dp-day-radius)}[data-range-preview] .dp-day:is([data-range-start=\"true\"],[data-range-end=\"true\"]){background: color-mix(in srgb,var(--dp-accent) 58%,var(--dp-bg))}[data-range-preview] .dp-day[data-in-range=\"true\"]{background: color-mix(in srgb,var(--dp-accent) 11%,var(--dp-bg))}[data-range-drag] .dp-day:is([data-range-start=\"true\"],[data-range-end=\"true\"]){cursor: grab}[data-range-drag=\"active\"],[data-range-drag=\"active\"] .dp-day{cursor: grabbing}.dp-day-number{display: block;font-variant-numeric: tabular-nums}.dp-day[data-disabled=\"true\"]:focus-visible{opacity: 1}.dp-day[data-disabled=\"true\"]:focus-visible .dp-day-number{color: var(--dp-muted)}.dp-day-extra{position: absolute;inset-inline: 2px;inset-block-end: 1px;display: flex;justify-content: center;gap: 2px;min-block-size: 0.35rem;font-size: 0.55rem;line-height: 1;pointer-events: none}.dp-week-number,.dp-week-heading{inline-size: 1.6rem !important;color: var(--dp-muted);font-size: 0.65rem;font-weight: 500}date-picker{position: relative;display: inline-grid;grid-template-columns: minmax(0,1fr);align-items: stretch;max-inline-size: 100%}date-picker>input:not([type=\"hidden\"]){min-inline-size: 0}date-picker>input:not([type=\"hidden\"]):not([type=\"time\"]){grid-column: 1;grid-row: 1;box-sizing: border-box;inline-size: 100%;padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem)}.dp-picker-button{display: grid;place-items: center;grid-column: 1;grid-row: 1;justify-self: end;align-self: stretch;inline-size: var(--dp-picker-button-size);min-inline-size: 0;border: 0;background: transparent;color: var(--dp-fg);font: inherit;cursor: pointer}.dp-picker-button:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: -5px;border-radius: var(--dp-radius)}date-picker:has(>[data-time-start],>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr);column-gap: var(--dp-gap)}date-picker:has(>[data-time-start]):has(>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr)}date-picker>input[data-time-start]{grid-column: 2;grid-row: 1;min-inline-size: 0}date-picker>input[data-time-end]{grid-column: 3;grid-row: 1;min-inline-size: 0}date-picker[range]{row-gap: var(--dp-gap)}date-picker[range]>input[data-range-start]{grid-row: 1}date-picker[range]>input[data-range-end]{grid-row: 2}date-picker[range]>.dp-picker-button[data-endpoint=\"start\"]{grid-row: 1}date-picker[range]>.dp-picker-button[data-endpoint=\"end\"]{grid-row: 2}.dp-picker-panel[popover]{position: fixed;inset: auto;margin: 0;padding: 0.875rem 1rem;border: 1px solid var(--dp-border);border-radius: var(--dp-radius);background: var(--dp-bg);color: var(--dp-fg);box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);max-block-size: var(--available-height,90svh);max-inline-size: calc(100vi - 1rem);overflow: auto}.dp-picker-panel:not(:popover-open){display: none}@media (forced-colors: active){.dp-month-select.dp-skin,[dir=\"rtl\"] .dp-month-select.dp-skin{appearance: auto;background-image: none;padding-inline: 0.45rem}.dp-day:is([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]){border: 2px solid Highlight;background-color: Canvas;color: CanvasText}.dp-day[data-in-range=\"true\"]{color: CanvasText}.dp-day[data-in-range=\"true\"]::after{content: \"\";position: absolute;inset-inline: 3px;inset-block-end: 4px;block-size: 1px;background-color: Highlight}.dp-day[data-today=\"true\"]{border-color: Highlight}.dp-day-extra{color: CanvasText;forced-color-adjust: none}}";var tt=new WeakMap;var _e=/^(\d{4})-(\d{2})-(\d{2})$/,ye=/^(\d{4})-(\d{2})$/;function be(t){return t%4===0&&(t%100!==0||t%400===0)}function st(t,e){if(e===2)return be(t)?29:28;return[4,6,9,11].includes(e)?30:31}function L(t){let e=_e.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>st(s,i))return null;return{year:s,month:i,day:n}}function c(t){return L(t)!==null}function f(t){let e=String(t||""),s=ye.exec(e);if(s){let n=Number(s[2]);if(n>=1&&n<=12)return`${s[1]}-${String(n).padStart(2,"0")}`}let i=L(e);if(!i)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function U(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 V(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function ve(t){return U(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function B(t){let e=L(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return V(e)}function g(t,e){if(!c(t)||!c(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function F(t,e){let s=L(t);if(!s||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let i=V(s);return i.setUTCDate(i.getUTCDate()+e),ve(i)}function ht(t,e){let s=L(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,st(n,a));return U(n,a,o)}function Ht(t,e){let s=L(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,st(i,s.month));return U(i,s.month,n)}function et(t,e){let s=`${f(t)}-01`;return f(ht(s,e))}function we(t){return`${f(t)}-01`}function Dt(t){let e=L(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return U(e.year,e.month,st(e.year,e.month))}function De(t){let e=L(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return V(e).getUTCDay()}function Y(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 ft(t,e=1){let s=(De(t)-Y(e)+7)%7;return F(t,-s)}function xt(t,e=1){return F(ft(t,e),6)}function Vt(t,e={}){let s=e.firstDay??1,i=ft(we(t),s),n=xt(Dt(t),s),r=[],a=i;for(;;){let o=[];for(let d=0;d<7;d++)o.push(F(a,d));if(r.push(o),g(o[6],n)>=0){if(!e.fixedWeeks||r.length>=6||g(o[6],F("9999-12-31",-7))>0)break}a=F(a,7)}return r}function zt(t,e,s){let i=V({year:1,month:1,day:1});return Math.round((V({year:t,month:e,day:s}).getTime()-i.getTime())/86400000)}function it(t,e=1){let s=Y(e),i=zt(9999,12,31),n=f(t);for(;;){let r=L(`${n}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${t}`);let a=zt(r.year,r.month,1),o=(V(r).getUTCDay()-s+7)%7;if(a-o<0){n=et(n,1);continue}let d=st(r.year,r.month),l={year:r.year,month:r.month,day:d},u=a+d-1,b=(V(l).getUTCDay()-s+7)%7;if(u-b+6>i){n=et(n,-1);continue}return n}}function Bt(t,e="",s=""){if(!c(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&g(t,e)<0)return e;if(s&&g(t,s)>0)return s;return t}function O(){let t=new Date;return U(t.getFullYear(),t.getMonth()+1,t.getDate())}function Nt(t){let e=L(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let s=V(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 Et{constructor(t={}){let e=O();this.firstDay=Y(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=ht(`${e}-01`,0),n=F(i,Math.max(0,s-1));return this.focused=f(n)===e?n:F(`${et(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(F(this.focused,t))}moveFocusMonths(t){return this.setFocused(ht(this.focused,t))}moveFocusYears(t){return this.setFocused(Ht(this.focused,t))}focusWeekStart(){return this.setFocused(ft(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(xt(this.focused,this.firstDay))}navigateMonth(t){let e=et(this.display,t);return this.setDisplay(e),this.display}}function xe(t){if(typeof t!=="string")return"";return[...new Set(t.split(/\s+/).filter((e)=>e&&!e.startsWith("dp-")&&![...e].some((s)=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)))].join(" ")}function At(t,e){return t.month===e.month&&t.year===e.year&&t.nav===e.nav}var Ct={month:"",year:"",nav:""};function nt(){return{...Ct}}function rt(t){if(t==null)return null;let e={};for(let s of["month","year","nav"])if(Object.hasOwn(t,s))e[s]=xe(t[s]);return e}function Ut(t){return t==null||["month","year","nav"].some((e)=>!Object.hasOwn(t,e))}function at(t){return{...nt(),...rt(t)}}function pt(t){let e=at(t);if(At(Ct,e))return;Ct=e;for(let s of kt)s()}var kt=new Set;function jt(t){return kt.add(t),()=>{kt.delete(t)}}function mt(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&&g(s,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:s}}function gt(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&&g(t,s)>=0&&g(t,i)<=0)return"in";return""}class Tt{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&g(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}_refuse(t){return{status:"refused",endpoint:t,changedEndpoints:[],range:this.range,activeEndpoint:this.activeEndpoint}}project(t,e=()=>!0){if(!c(t))throw TypeError(`Invalid range activation: ${t}`);let{start:s,end:i}=this;if(this.complete&&(g(t,s)<0||g(t,i)>0)){let r=g(t,s)<0?"start":"end";if(!e(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:t,end:i}:{start:s,end:t},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(s&&!i&&g(t,s)<0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"end",changedEndpoints:["start","end"],range:{start:t,end:s},activeEndpoint:"end"}}if(s&&g(t,s)<0)return this._refuse("end");if(!e("end"))return this._refuse("end");return{status:s?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:s,end:t},activeEndpoint:"end"}}if(i&&!s&&g(t,i)>0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"start",changedEndpoints:["start","end"],range:{start:i,end:t},activeEndpoint:"start"}}if(!e("start"))return this._refuse("start");let n=e("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:t,end:i},activeEndpoint:n?"end":this.activeEndpoint,...n?{}:{close:!0}}}projectEndpoint(t,e,s=()=>!0){if(!c(t))throw TypeError(`Invalid range activation: ${t}`);if(!this.complete||!s(e))return this._refuse(e);let{start:i,end:n}=this,r=e==="start"?i:n,a=e==="start"?Ce(t,n):Ee(t,i);return{status:"complete",endpoint:e,changedEndpoints:a===r?[]:[e],range:e==="start"?{start:a,end:n}:{start:i,end:a},activeEndpoint:e}}previewRange(t,e="",s=()=>!0){if(!c(t))return null;if(!e&&Boolean(this.start)===Boolean(this.end))return null;let i=e?this.projectEndpoint(t,e,s):this.project(t,s);if(i.status==="refused")return null;let{start:n,end:r}=i.range;if(!n||r&&g(r,n)<0)return null;return{start:n,end:r}}_apply(t){if(t.status==="refused")return t;return this.start=t.range.start,this.end=t.range.end,this.activeEndpoint=t.activeEndpoint,t}activate(t,e=()=>!0){return this._apply(this.project(t,e))}moveEndpoint(t,e,s=()=>!0){return this._apply(this.projectEndpoint(t,e,s))}}function Ee(t,e){if(!t)return e;if(!e)return t;return g(t,e)>=0?t:e}function Ce(t,e){if(!t)return e;if(!e)return t;return g(t,e)<=0?t:e}var Yt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g,ke=new Map,Ae=new Map;function Wt(t,e,s){let i=t.get(e);if(i!==void 0)return i;let n=s(),r=t.keys().next().value;if(t.size>=64&&r!==void 0)t.delete(r);return t.set(e,n),n}function W(t,e){let s=JSON.stringify([t,e]);return Wt(ke,s,()=>new Intl.DateTimeFormat(t,e))}function P(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 Te(t){return Wt(Ae,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,s={}){let i=String(t||"").replace(Yt,"");if(s.trim!==!1)i=i.trim();for(let[n,r]of Te(e))i=i.split(n).join(r);return i}function ot(t,e=""){let s=P(e);return W(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(B(t))}function Kt(t,e=""){let s=P(e);return W(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(B(`${t.slice(0,7)}-15`))}function qt(t=""){let e=P(t);try{let s=W(e,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(B("2026-09-15")),i=-1,n=-1;if(s.forEach((r,a)=>{let o=r.type;if(o==="month"){if(i<0)i=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),i>=0&&n>=0)return n<i?["year","month"]:["month","year"]}catch{}return["month","year"]}function Xt(t="",e="long"){let s=P(t),i=W(s,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(B(`2026-${String(r+1).padStart(2,"0")}-15`)))}function St(t="",e=1,s="short"){let i=P(t),n=W(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=Y(e),a=B("2026-01-04");return Array.from({length:7},(o,d)=>{let l=new Date(a);return l.setUTCDate(a.getUTCDate()+(r+d)%7),n.format(l)})}function Se(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dt(t=""){let e=P(t),s=W(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=B("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 u=Gt(l.value,e,{trim:!1});return Se(u).replace(/\s+/g,"\\s*")}).join(""),d=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(l){if(!c(l))return"";return s.format(B(l))},parse(l){let u=Gt(l,e);if(c(u))return u;let b=d.exec(u);if(!b)return"";let D={};if(r.forEach((x,T)=>{D[x]=Number(b[T+1])}),!D.year||!D.month||!D.day)return"";try{return U(D.year,D.month,D.day)}catch{return""}}}}var Me={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"},Mt={...Me};function N(){return{...Mt}}function _t(t){Mt={...Mt,...t};for(let e of $t)e()}var $t=new Set;function yt(t){return $t.add(t),()=>{$t.delete(t)}}function Zt(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}function K(t,e){for(let s of e){if(!Object.hasOwn(t,s))continue;let i=Reflect.get(t,s);Reflect.deleteProperty(t,s),Reflect.set(t,s,i)}}var $e=0;function A(t){return String(t).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Fe(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function Le(t){return Number(t.slice(0,4))}function bt(t,e){let[s,i]=t.split("-").map(Number),n=s*12+(i-1)+e,r=Math.floor(n/12),a=(n%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function Jt(t){return{"data-range-start":t==="start"||t==="single","data-range-end":t==="end"||t==="single","data-in-range":t==="in"}}function Ie(t){return Object.entries(Jt(t)).filter(([,e])=>e).map(([e])=>` ${e}="true"`).join("")}function Re(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class lt extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];static setDefaultControlClasses(t){pt(t)}static getDefaultControlClasses(){return nt()}static setDefaultMessages(t){_t(t)}static getDefaultMessages(){return N()}constructor(){super();this._id=`date-calendar-${++$e}`,this._model=new Et,this._connected=!1,this._rendering=!1,this._source=null,this._hostIntent=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._paintedRange={start:"",end:""},this._paintedPreview=!1,this._renderedStates=new Map,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._stopDefaultControlClasses=null,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;K(this,["locale","min","max","firstDay","selection","monthFormat","fixedWeeks","showWeekNumbers","controlClasses","messages","source","dateState","renderDay","isDateDisabled","highlightedRange","value","display"]),this._syncModel(),K(this,["focusedDate"]),this._stopDefaultControlClasses=jt(()=>{if(Ut(this._controlClasses))this.render()}),this._stopDefaultMessages=yt(()=>{if(this._messages===null)this.render()}),this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this.render()}disconnectedCallback(){this._stopDefaultControlClasses?.(),this._stopDefaultControlClasses=null,this._stopDefaultMessages?.(),this._stopDefaultMessages=null,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 P(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 Fe(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 monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=mt(t),s=this.hasAttribute("data-range-preview");if(e.start===this._paintedRange.start&&e.end===this._paintedRange.end&&s===this._paintedPreview)return;if(this._highlightedRange=e,this._connected)this._updateRangeDom()}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 controlClasses(){return at(this._controlClasses)}set controlClasses(t){let e=this.controlClasses;if(this._controlClasses=rt(t),At(e,this.controlClasses))return;if(this._connected)this.render()}get messages(){return this._messages??N()}set messages(t){if(this._messages=t==null?null:{...N(),...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(it(s,t))}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){let e=Bt(t,this.min,this.max),s=f(e),i=it(s,this.firstDay);if(i===s)return e;let n=Number(e.slice(8,10))||1,r=F(`${i}-01`,n-1),a=Dt(i);return g(r,a)>0?a:r}_weeks(t=this.display){return Vt(it(t,this.firstDay),{firstDay:this.firstDay,fixedWeeks:this.fixedWeeks})}_focusTargetKey(t){if(t.matches(".dp-month-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&&g(t,this.min)<0||this.max&&g(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,u]of Zt(d))this._sourceStates.set(l,u);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(it(t,this.firstDay)),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(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(bt(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(bt(this.display,1)??this.display)}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()}_syncRovingDom(t){for(let s of this.querySelectorAll('.dp-day[tabindex="0"]'))if(s instanceof HTMLElement&&s.dataset.date!==t)s.tabIndex=-1;let e=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(e instanceof HTMLElement)e.tabIndex=0}_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}_dayLabel(t,e,s){let i=this.hasAttribute("data-range-preview")?"":Re(s),n=typeof e.description==="string"?e.description:"";return[ot(t,this.locale),n,i?this.messages[i]:"",e.disabled?this.messages.unavailable:""].filter(Boolean).join(". ")}_updateRangeDom(){let t=this._paintedRange,e=this._paintedPreview;this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview");for(let s of this.querySelectorAll(".dp-day[data-date]")){if(!(s instanceof HTMLTableCellElement))continue;let i=s.dataset.date||"",n=gt(i,this._highlightedRange);if(n===gt(i,t)&&e===this._paintedPreview)continue;for(let[r,a]of Object.entries(Jt(n)))if(a)s.setAttribute(r,"true");else s.removeAttribute(r);if(!e||!this._paintedPreview){let r=this._renderedStates.get(i)||{},a=this._dayLabel(i,r,n);if(s.getAttribute("aria-label")!==a)s.setAttribute("aria-label",a)}}}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async activateDate(t){let e=this._hostIntent?.date===t?this._hostIntent.intent:void 0;this._hostIntent=null;let s=(a)=>{if(e!==void 0)tt.set(a,e);return a},i=await this.ensureDate(t),n=this.getDateState(t);if(!i||n.disabled)return this.dispatchEvent(s(new CustomEvent("dateinvalid",{detail:{date:t,state:n},bubbles:!0}))),!1;if(!this.dispatchEvent(s(new CustomEvent("dateactivate",{detail:{date:t,state:n},bubbles:!0,cancelable:!0}))))return!1;if(this.selection==="single"){let a=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(a,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();else this._syncRovingDom(this._model.focused);this.activateDate(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 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))return;this._model.focused=s,this._syncRovingDom(s),this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:s,state:this.getDateState(s)},bubbles:!0}))}_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.activateDate(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=Le(s),n=Number(s.slice(5,7)),r=Xt(e,this.monthFormat),a=St(e,this.firstDay,"short"),o=St(e,this.firstDay,"long"),d=this._weeks(),l=O(),u=`${this._id}-heading`,b=`${this._id}-grid`,D=this.min?f(this.min):"",x=this.max?f(this.max):"",T=bt(s,-1),S=bt(s,1),M=Boolean(D&&T!==null&&T<D),y=Boolean(x&&S!==null&&S>x),v=` min="${this.min?Number(this.min.slice(0,4)):1}"`,E=` max="${this.max?Number(this.max.slice(0,4)):9999}"`,k=this.showWeekNumbers&&this.firstDay===1,C=k?`<th scope="col" class="dp-week-heading" abbr="${A(this.messages.week)}">#</th>`:"",H=r.map((h,m)=>{let w=m+1,p=`${String(i).padStart(4,"0")}-${String(w).padStart(2,"0")}`,Q=D&&p<D||x&&p>x;return`<option value="${String(w).padStart(2,"0")}"${w===n?" selected":""}${Q?" disabled":""}>${A(h)}</option>`}).join(""),I=a.map((h,m)=>`<th scope="col" abbr="${A(o[m])}">${A(h.replace(".",""))}</th>`).join("");this._renderedStates.clear();let j=d.map((h)=>{let m=k?`<th scope="row" class="dp-week-number">${Nt(h[0])}</th>`:"",w=h.map((p)=>{let Q=this.getDateState(p);this._renderedStates.set(p,Q);let he=f(p)!==s,fe=this.value===p,pe=this.focusedDate===p,me=p===l,Ot=gt(p,this._highlightedRange),ge=this._dayLabel(p,Q,Ot);return`<td class="dp-day" data-date="${p}"${he?' data-outside-month="true"':""}${me?' data-today="true" aria-current="date"':""}${fe?' data-selected="true" aria-selected="true"':""}${Ie(Ot)}${Q.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${pe?"0":"-1"}" aria-label="${A(ge)}"><span class="dp-day-number" aria-hidden="true">${Number(p.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${m}${w}</tr>`}).join(""),q=document.activeElement,X=q instanceof HTMLElement&&this.contains(q)?this._focusTargetKey(q):"",R=qt(e)[0]==="year";this.toggleAttribute("data-year-first",R);let Z=this.controlClasses,G=A(Z.month||"dp-skin"),wt=A(Z.year||"dp-skin"),ut=A(Z.nav||"dp-skin"),J=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this.messages.month)}</label>
|
|
3
|
-
<select id="${this._id}-month" class="dp-month-select ${
|
|
4
|
-
<input id="${this._id}-year" class="dp-year-input ${
|
|
1
|
+
/*** @lekoala/date-picker v0.6.0 - https://github.com/lekoala/date-picker ***/
|
|
2
|
+
(()=>{var Ht=":where(date-calendar,date-picker){--dp-bg: #ffffff;--dp-fg: #1f2328;--dp-muted: color-mix(in srgb,var(--dp-fg) 58%,var(--dp-bg));--dp-border: color-mix(in srgb,var(--dp-fg) 16%,var(--dp-bg));--dp-hover: color-mix(in srgb,var(--dp-fg) 5%,var(--dp-bg));--dp-accent: #2563eb;--dp-accent-fg: #fff;--dp-focus: var(--dp-accent);--dp-focus-width: 2px;--dp-radius: 0.5rem;--dp-day-size: 2.75rem;--dp-gap: 0.375rem;--dp-header-control-size: 2.25rem;--dp-header-block-gap: 0.75rem;--dp-row-gap: 0.375rem;--dp-picker-button-size: 2.5rem;--dp-year-inline-size: 5.5rem;--dp-day-radius: calc(var(--dp-radius) * 0.75);color: var(--dp-fg);font: inherit}.dp-visually-hidden{position: absolute !important;inline-size: 1px !important;block-size: 1px !important;padding: 0 !important;margin: -1px !important;overflow: hidden !important;clip: rect(0 0 0 0) !important;white-space: nowrap !important;border: 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) var(--dp-year-inline-size) auto auto;align-items: stretch;gap: var(--dp-gap);margin-block-end: var(--dp-header-block-gap)}date-calendar[data-year-first] .dp-calendar-header{grid-template-columns: var(--dp-year-inline-size) minmax(0,1fr) auto auto}.dp-calendar-header :where(button,select,input){box-sizing: border-box;min-inline-size: 0}.dp-calendar-header .dp-skin{min-block-size: var(--dp-header-control-size);padding-block: 0.15rem;border: 1px solid var(--dp-border);border-radius: calc(var(--dp-radius) * 0.75);background: var(--dp-bg);color: var(--dp-fg);font: inherit;line-height: 1.2}.dp-calendar-header input.dp-skin{padding-inline: 0.45rem}.dp-month-select{inline-size: 100%;overflow: hidden;text-overflow: ellipsis}.dp-month-select.dp-skin{appearance: none;padding-inline: 0.45rem 2rem;background-image: linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%);background-position: calc(100% - 0.9rem) 50%,calc(100% - 0.65rem) 50%;background-size: 0.3rem 0.3rem;background-repeat: no-repeat}[dir=\"rtl\"] .dp-month-select.dp-skin,html[dir=\"rtl\"] .dp-month-select.dp-skin{background-position: 0.9rem 50%,0.65rem 50%}.dp-year-input{inline-size: 100%}.dp-nav.dp-skin{display: grid;place-items: center;inline-size: var(--dp-header-control-size);padding: 0;font-size: 1.35rem;line-height: 1;cursor: pointer}.dp-nav svg{display: block;inline-size: 1rem;block-size: 1rem;pointer-events: none}.dp-calendar-header .dp-skin:disabled,.dp-picker-button:disabled{cursor: not-allowed;opacity: 0.45}.dp-nav.dp-skin:hover:not(:disabled){background: var(--dp-hover)}.dp-calendar-header .dp-skin:focus-visible,date-picker>input:not([type=\"hidden\"]):focus-visible,.dp-day:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: calc(var(--dp-focus-width) * -1)}.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 var(--dp-row-gap);table-layout: fixed}.dp-grid :where(th,td){box-sizing: border-box;inline-size: var(--dp-day-size);block-size: var(--dp-day-size);padding: 0;text-align: center}.dp-grid thead th{block-size: 1.5rem;color: var(--dp-muted);font-size: 0.72rem;font-weight: 500}.dp-day{position: relative;border: 1px solid transparent;border-radius: var(--dp-day-radius);cursor: pointer;outline: none;vertical-align: middle;font-size: 0.875rem}.dp-day:is([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]):focus-visible{outline-color: var(--dp-accent-fg)}.dp-day[data-outside-month=\"true\"]{color: var(--dp-muted)}.dp-day[data-selected=\"true\"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-today=\"true\"]:not([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]){border-color: var(--dp-accent)}.dp-day[data-disabled=\"true\"]{cursor: not-allowed;opacity: 0.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\"]{border-radius: 0;background: color-mix(in srgb,var(--dp-accent) 18%,var(--dp-bg))}.dp-day[data-range-start=\"true\"]:has(+ [data-in-range=\"true\"],+ [data-range-end=\"true\"]){border-start-end-radius: 0;border-end-end-radius: 0}.dp-day:is([data-in-range=\"true\"],[data-range-start=\"true\"]) + .dp-day[data-range-end=\"true\"]{border-start-start-radius: 0;border-end-start-radius: 0}.dp-day[data-in-range=\"true\"]:first-of-type{border-start-start-radius: var(--dp-day-radius);border-end-start-radius: var(--dp-day-radius)}.dp-day[data-in-range=\"true\"]:last-of-type{border-start-end-radius: var(--dp-day-radius);border-end-end-radius: var(--dp-day-radius)}[data-range-preview] .dp-day:is([data-range-start=\"true\"],[data-range-end=\"true\"]){background: color-mix(in srgb,var(--dp-accent) 58%,var(--dp-bg))}[data-range-preview] .dp-day[data-in-range=\"true\"]{background: color-mix(in srgb,var(--dp-accent) 11%,var(--dp-bg))}.dp-day-number{display: block;font-variant-numeric: tabular-nums}.dp-day[data-disabled=\"true\"]:focus-visible{opacity: 1}.dp-day[data-disabled=\"true\"]:focus-visible .dp-day-number{color: var(--dp-muted)}.dp-day-extra{position: absolute;inset-inline: 2px;inset-block-end: 1px;display: flex;justify-content: center;gap: 2px;min-block-size: 0.35rem;font-size: 0.55rem;line-height: 1;pointer-events: none}.dp-week-number,.dp-week-heading{inline-size: 1.6rem !important;color: var(--dp-muted);font-size: 0.65rem;font-weight: 500}date-picker{position: relative;display: inline-grid;grid-template-columns: minmax(0,1fr);align-items: stretch;max-inline-size: 100%}date-picker>input:not([type=\"hidden\"]){min-inline-size: 0}date-picker>input:not([type=\"hidden\"]):not([type=\"time\"]){grid-column: 1;grid-row: 1;box-sizing: border-box;inline-size: 100%;padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem)}.dp-picker-button{display: grid;place-items: center;grid-column: 1;grid-row: 1;justify-self: end;align-self: stretch;inline-size: var(--dp-picker-button-size);min-inline-size: 0;border: 0;background: transparent;color: var(--dp-fg);font: inherit;cursor: pointer}.dp-picker-button:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: -5px;border-radius: var(--dp-radius)}date-picker:has(>[data-time-start],>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr);column-gap: var(--dp-gap)}date-picker:has(>[data-time-start]):has(>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr)}date-picker>input[data-time-start]{grid-column: 2;grid-row: 1;min-inline-size: 0}date-picker>input[data-time-end]{grid-column: 3;grid-row: 1;min-inline-size: 0}date-picker[range]{row-gap: var(--dp-gap)}date-picker[range]>input[data-range-start]{grid-row: 1}date-picker[range]>input[data-range-end]{grid-row: 2}date-picker[range]>.dp-picker-button[data-endpoint=\"start\"]{grid-row: 1}date-picker[range]>.dp-picker-button[data-endpoint=\"end\"]{grid-row: 2}.dp-picker-panel[popover]{position: fixed;inset: auto;margin: 0;padding: 0.875rem 1rem;border: 1px solid var(--dp-border);border-radius: var(--dp-radius);background: var(--dp-bg);color: var(--dp-fg);box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);max-block-size: var(--available-height,90svh);max-inline-size: calc(100vi - 1rem);overflow: auto}.dp-picker-panel:not(:popover-open){display: none}@media (forced-colors: active){.dp-month-select.dp-skin,[dir=\"rtl\"] .dp-month-select.dp-skin{appearance: auto;background-image: none;padding-inline: 0.45rem}.dp-day:is([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]){border: 2px solid Highlight;background-color: Canvas;color: CanvasText}.dp-day[data-in-range=\"true\"]{color: CanvasText}.dp-day[data-in-range=\"true\"]::after{content: \"\";position: absolute;inset-inline: 3px;inset-block-end: 4px;block-size: 1px;background-color: Highlight}.dp-day[data-today=\"true\"]{border-color: Highlight}.dp-day-extra{color: CanvasText;forced-color-adjust: none}}";var st=new WeakMap;var be=/^(\d{4})-(\d{2})-(\d{2})$/,ye=/^(\d{4})-(\d{2})$/;function ve(t){return t%4===0&&(t%100!==0||t%400===0)}function nt(t,e){if(e===2)return ve(t)?29:28;return[4,6,9,11].includes(e)?30:31}function R(t){let e=be.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>nt(s,i))return null;return{year:s,month:i,day:n}}function d(t){return R(t)!==null}function p(t){let e=String(t||""),s=ye.exec(e);if(s){let n=Number(s[1]),r=Number(s[2]);if(n>=1&&n<=9999&&r>=1&&r<=12)return`${s[1]}-${String(r).padStart(2,"0")}`}let i=R(e);if(!i)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function U(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 B(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function we(t){return U(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function N(t){let e=R(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return B(e)}function _(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=R(t);if(!s||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let i=B(s);return i.setUTCDate(i.getUTCDate()+e),we(i)}function pt(t,e){let s=R(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,nt(n,a));return U(n,a,o)}function Nt(t,e){let s=R(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,nt(i,s.month));return U(i,s.month,n)}function it(t,e){let s=`${p(t)}-01`;return p(pt(s,e))}function De(t){return`${p(t)}-01`}function Et(t){let e=R(`${p(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return U(e.year,e.month,nt(e.year,e.month))}function xe(t){let e=R(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return B(e).getUTCDay()}function Y(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 mt(t,e=1){let s=(xe(t)-Y(e)+7)%7;return F(t,-s)}function Ct(t,e=1){return F(mt(t,e),6)}function Vt(t,e={}){let s=e.firstDay??1,i=mt(De(t),s),n=Ct(Et(t),s),r=[],a=i;for(;;){let o=[];for(let l=0;l<7;l++)o.push(F(a,l));if(r.push(o),_(o[6],n)>=0){if(!e.fixedWeeks||r.length>=6||_(o[6],F("9999-12-31",-7))>0)break}a=F(a,7)}return r}function Bt(t,e,s){let i=B({year:1,month:1,day:1});return Math.round((B({year:t,month:e,day:s}).getTime()-i.getTime())/86400000)}function rt(t,e=1){let s=Y(e),i=Bt(9999,12,31),n=p(t);for(;;){let r=R(`${n}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${t}`);let a=Bt(r.year,r.month,1),o=(B(r).getUTCDay()-s+7)%7;if(a-o<0){n=it(n,1);continue}let l=nt(r.year,r.month),c={year:r.year,month:r.month,day:l},h=a+l-1,y=(B(c).getUTCDay()-s+7)%7;if(h-y+6>i){n=it(n,-1);continue}return n}}function Ut(t,e="",s=""){if(!d(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&_(t,e)<0)return e;if(s&&_(t,s)>0)return s;return t}function O(){let t=new Date;return U(t.getFullYear(),t.getMonth()+1,t.getDate())}function Wt(t){let e=R(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let s=B(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 kt{constructor(t={}){let e=O();this.firstDay=Y(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?p(t.display):p(this.focused)}setValue(t){if(t&&!d(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=p(t),s=Number(this.focused.slice(8,10))||1,i=pt(`${e}-01`,0),n=F(i,Math.max(0,s-1));return this.focused=p(n)===e?n:F(`${it(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=p(t);return this.focused}moveFocusDays(t){return this.setFocused(F(this.focused,t))}moveFocusMonths(t){return this.setFocused(pt(this.focused,t))}moveFocusYears(t){return this.setFocused(Nt(this.focused,t))}focusWeekStart(){return this.setFocused(mt(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(Ct(this.focused,this.firstDay))}navigateMonth(t){let e=it(this.display,t);return this.setDisplay(e),this.display}}function Ee(t){if(typeof t!=="string")return"";return[...new Set(t.split(/\s+/).filter((e)=>e&&!e.startsWith("dp-")&&![...e].some((s)=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)))].join(" ")}function Tt(t,e){return t.month===e.month&&t.year===e.year&&t.nav===e.nav}var At={month:"",year:"",nav:""};function at(){return{...At}}function ot(t){if(t==null)return null;let e={};for(let s of["month","year","nav"])if(Object.hasOwn(t,s))e[s]=Ee(t[s]);return e}function jt(t){return t==null||["month","year","nav"].some((e)=>!Object.hasOwn(t,e))}function dt(t){return{...at(),...ot(t)}}function gt(t){let e=dt(t);if(Tt(At,e))return;At=e;for(let s of St)s()}var St=new Set;function Yt(t){return St.add(t),()=>{St.delete(t)}}function _t(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&&_(s,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:s}}function bt(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&&_(t,s)>=0&&_(t,i)<=0)return"in";return""}class Mt{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&_(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}_refuse(t){return{status:"refused",endpoint:t,changedEndpoints:[],range:this.range,activeEndpoint:this.activeEndpoint}}project(t,e=()=>!0){if(!d(t))throw TypeError(`Invalid range activation: ${t}`);let{start:s,end:i}=this;if(this.complete&&(_(t,s)<0||_(t,i)>0)){let r=_(t,s)<0?"start":"end";if(!e(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:t,end:i}:{start:s,end:t},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(s&&!i&&_(t,s)<0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"end",changedEndpoints:["start","end"],range:{start:t,end:s},activeEndpoint:"end"}}if(s&&_(t,s)<0)return this._refuse("end");if(!e("end"))return this._refuse("end");return{status:s?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:s,end:t},activeEndpoint:"end"}}if(i&&!s&&_(t,i)>0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"start",changedEndpoints:["start","end"],range:{start:i,end:t},activeEndpoint:"start"}}if(!e("start"))return this._refuse("start");let n=e("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:t,end:i},activeEndpoint:n?"end":this.activeEndpoint,...n?{}:{close:!0}}}previewRange(t,e=()=>!0){if(!d(t))return null;if(Boolean(this.start)===Boolean(this.end))return null;let s=this.project(t,e);if(s.status==="refused")return null;let{start:i,end:n}=s.range;if(!i||n&&_(n,i)<0)return null;return{start:i,end:n}}_apply(t){if(t.status==="refused")return t;return this.start=t.range.start,this.end=t.range.end,this.activeEndpoint=t.activeEndpoint,t}activate(t,e=()=>!0){return this._apply(this.project(t,e))}}var Kt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g,Ce=new Map,ke=new Map;function Gt(t,e,s){let i=t.get(e);if(i!==void 0)return i;let n=s(),r=t.keys().next().value;if(t.size>=64&&r!==void 0)t.delete(r);return t.set(e,n),n}function q(t,e){let s=JSON.stringify([t,e]);return Gt(Ce,s,()=>new Intl.DateTimeFormat(t,e))}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 Ae(t){return Gt(ke,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 qt(t,e,s={}){let i=String(t||"").replace(Kt,"");if(s.trim!==!1)i=i.trim();for(let[n,r]of Ae(e))i=i.split(n).join(r);return i}function lt(t,e=""){let s=z(e);return q(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(N(t))}function Zt(t,e=""){let s=z(e);return q(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(N(`${t.slice(0,7)}-15`))}function Xt(t=""){let e=z(t);try{let s=q(e,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(N("2026-09-15")),i=-1,n=-1;if(s.forEach((r,a)=>{let o=r.type;if(o==="month"){if(i<0)i=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),i>=0&&n>=0)return n<i?["year","month"]:["month","year"]}catch{}return["month","year"]}function Jt(t="",e="long"){let s=z(t),i=q(s,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(N(`2026-${String(r+1).padStart(2,"0")}-15`)))}function $t(t="",e=1,s="short"){let i=z(t),n=q(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=Y(e),a=N("2026-01-04");return Array.from({length:7},(o,l)=>{let c=new Date(a);return c.setUTCDate(a.getUTCDate()+(r+l)%7),n.format(c)})}function Se(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ct(t=""){let e=z(t),s=q(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=N("2006-11-22"),n=s.formatToParts(i).filter((c)=>c.type!=="literal"||c.value),r=n.filter((c)=>["day","month","year"].includes(c.type)).map((c)=>c.type),a=n.map((c)=>{if(c.type==="day")return"DD";if(c.type==="month")return"MM";if(c.type==="year")return"YYYY";return c.value.replace(Kt,"")}).join(""),o=n.map((c)=>{if(c.type==="day"||c.type==="month")return"(\\d{1,2})";if(c.type==="year")return"(\\d{4})";let h=qt(c.value,e,{trim:!1});return Se(h).replace(/\s+/g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(c){if(!d(c))return"";return s.format(N(c))},parse(c){let h=qt(c,e);if(d(h))return h;let y=l.exec(h);if(!y)return"";let D={};if(r.forEach((x,S)=>{D[x]=Number(y[S+1])}),!D.year||!D.month||!D.day)return"";try{return U(D.year,D.month,D.day)}catch{return""}}}}var Te={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"},Ft={...Te};function V(){return{...Ft}}function yt(t){Ft={...Ft,...t};for(let e of Rt)e()}var Rt=new Set;function vt(t){return Rt.add(t),()=>{Rt.delete(t)}}function K(){return new AbortController}function G(t,e){return()=>{if(!t.aborted)e()}}function Qt(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}function Z(t,e){for(let s of e){if(!Object.hasOwn(t,s))continue;let i=Reflect.get(t,s);Reflect.deleteProperty(t,s),Reflect.set(t,s,i)}}var Me=0;function A(t){return String(t).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function $e(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function Fe(t){return Number(t.slice(0,4))}function wt(t,e){let[s,i]=t.split("-").map(Number),n=s*12+(i-1)+e,r=Math.floor(n/12),a=(n%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function te(t){return{"data-range-start":t==="start"||t==="single","data-range-end":t==="end"||t==="single","data-in-range":t==="in"}}function Re(t){return Object.entries(te(t)).filter(([,e])=>e).map(([e])=>` ${e}="true"`).join("")}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 ut extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];static setDefaultControlClasses(t){gt(t)}static getDefaultControlClasses(){return at()}static setDefaultMessages(t){yt(t)}static getDefaultMessages(){return V()}constructor(){super();this._id=`date-calendar-${++Me}`,this._model=new kt,this._connected=!1,this._session=null,this._rendering=!1,this._heading=null,this._renderRoot=null,this._source=null,this._hostIntent=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._paintedRange={start:"",end:""},this._paintedPreview=!1,this._renderedStates=new Map,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._stopDefaultControlClasses=null,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;if(this._session=K(),Z(this,["locale","min","max","firstDay","selection","monthFormat","fixedWeeks","showWeekNumbers","controlClasses","messages","source","dateState","renderDay","isDateDisabled","highlightedRange","value","display"]),this._normalizeAttributes(),this._syncModel(),this.hasAttribute("display"))this._reflect("display",this._model.display);Z(this,["focusedDate"]),this._stopDefaultControlClasses=Yt(()=>{if(jt(this._controlClasses))this.render()}),this._stopDefaultMessages=vt(()=>{if(this._messages===null)this.render()}),this._connected=!0;let{signal:t}=this._session;this.addEventListener("click",this._onClick,{signal:t}),this.addEventListener("change",this._onChange,{signal:t}),this.addEventListener("keydown",this._onKeyDown,{signal:t}),this.addEventListener("focusin",this._onFocusIn,{signal:t}),this.render()}disconnectedCallback(){this._stopDefaultControlClasses?.(),this._stopDefaultControlClasses=null,this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeAttribute("data-loading"),this._session?.abort(),this._session=null}_normalizeAttributes(){let t=this.getAttribute("value");if(t&&!d(t))this.removeAttribute("value");for(let e of["min","max"]){let s=this.getAttribute(e);if(s&&!d(s))this.removeAttribute(e)}}attributeChangedCallback(t,e,s){if(this._rendering)return;if(!this._connected)return;if(t==="value"&&s&&!d(s)){this._reflect("value",this._model.value);return}if((t==="min"||t==="max")&&s&&!d(s)){if(this._reflect(t,""),this._connected)this._syncModel(),this.render();return}if(t==="display"&&s)try{if(p(s)!==s)throw TypeError("Non-canonical month")}catch{this._reflect("display",this._model.display);return}this._syncModel(),this.render()}_queueFocus(t){let e=this._session;if(!e)return;queueMicrotask(G(e.signal,t))}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&&!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 $e(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 monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=_t(t),s=this.hasAttribute("data-range-preview");if(e.start===this._paintedRange.start&&e.end===this._paintedRange.end&&s===this._paintedPreview)return;if(this._highlightedRange=e,this._connected)this._updateRangeDom()}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 controlClasses(){return dt(this._controlClasses)}set controlClasses(t){let e=this.controlClasses;if(this._controlClasses=ot(t),Tt(e,this.controlClasses))return;if(this._connected)this.render()}get messages(){return this._messages??V()}set messages(t){if(this._messages=t==null?null:{...V(),...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(rt(s,t))}catch{}else if(this._model.value)this._model.display=p(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=p(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){let e=Ut(t,this.min,this.max),s=p(e),i=rt(s,this.firstDay);if(i===s)return e;let n=Number(e.slice(8,10))||1,r=F(`${i}-01`,n-1),a=Et(i);return _(r,a)>0?a:r}_weeks(t=this.display){return Vt(rt(t,this.firstDay),{firstDay:this.firstDay,fixedWeeks:this.fixedWeeks})}_focusTargetKey(t){if(t.matches(".dp-month-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&&_(t,this.min)<0||this.max&&_(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(p(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 l=await o(s,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[c,h]of Qt(l))this._sourceStates.set(c,h);if(this._loadedRanges.add(i),this.dispatchEvent(new CustomEvent("dateloadend",{detail:s,bubbles:!0})),e&&this._connected&&p(this.display)===p(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._loadingKey="",this._loadingPromise=null,this.removeAttribute("data-loading")}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let s=this._model.display;if(this._model.setDisplay(rt(t,this.firstDay)),this._model.focused=this._clamp(this._model.focused),this._model.display=p(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(wt(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(wt(this.display,1)??this.display)}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)this._queueFocus(()=>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()}_syncRovingDom(t){for(let s of this.querySelectorAll('.dp-day[tabindex="0"]'))if(s instanceof HTMLElement&&s.dataset.date!==t)s.tabIndex=-1;let e=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(e instanceof HTMLElement)e.tabIndex=0}_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}_dayLabel(t,e,s){let i=this.hasAttribute("data-range-preview")?"":Ie(s),n=typeof e.description==="string"?e.description:"";return[lt(t,this.locale),n,i?this.messages[i]:"",e.disabled?this.messages.unavailable:""].filter(Boolean).join(". ")}_updateRangeDom(){let t=this._paintedRange,e=this._paintedPreview;this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview");for(let s of this.querySelectorAll(".dp-day[data-date]")){if(!(s instanceof HTMLTableCellElement))continue;let i=s.dataset.date||"",n=bt(i,this._highlightedRange);if(n===bt(i,t)&&e===this._paintedPreview)continue;for(let[r,a]of Object.entries(te(n)))if(a)s.setAttribute(r,"true");else s.removeAttribute(r);if(!e||!this._paintedPreview){let r=this._renderedStates.get(i)||{},a=this._dayLabel(i,r,n);if(s.getAttribute("aria-label")!==a)s.setAttribute("aria-label",a)}}}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async activateDate(t){if(!this._connected)return!1;let e=this._session,s=this._hostIntent?.date===t?this._hostIntent.intent:void 0;this._hostIntent=null;let i=(o)=>{if(s!==void 0)st.set(o,s);return o},n=await this.ensureDate(t);if(!e||e.signal.aborted)return!1;let r=this.getDateState(t);if(!n||r.disabled)return this.dispatchEvent(i(new CustomEvent("dateinvalid",{detail:{date:t,state:r},bubbles:!0}))),!1;if(!this.dispatchEvent(i(new CustomEvent("dateactivate",{detail:{date:t,state:r},bubbles:!0,cancelable:!0})))||e.signal.aborted)return!1;if(this.selection==="single"){let o=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(p(t)===this.display)this._moveSelectionDom(o,t);else this.render()}else if(this._connected){if(p(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();else this._syncRovingDom(this._model.focused);this.activateDate(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 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))return;this._model.focused=s,this._syncRovingDom(s),this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:s,state:this.getDateState(s)},bubbles:!0}))}_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.activateDate(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=Fe(s),n=Number(s.slice(5,7)),r=Jt(e,this.monthFormat),a=$t(e,this.firstDay,"short"),o=$t(e,this.firstDay,"long"),l=this._weeks(),c=O(),h=`${this._id}-heading`,y=`${this._id}-grid`,D=this.min?p(this.min):"",x=this.max?p(this.max):"",S=wt(s,-1),T=wt(s,1),M=Boolean(D&&S!==null&&S<D),b=Boolean(x&&T!==null&&T>x),v=` min="${this.min?Number(this.min.slice(0,4)):1}"`,E=` max="${this.max?Number(this.max.slice(0,4)):9999}"`,k=this.showWeekNumbers&&this.firstDay===1,C=k?`<th scope="col" class="dp-week-heading" abbr="${A(this.messages.week)}">#</th>`:"",H=r.map((u,f)=>{let w=f+1,m=`${String(i).padStart(4,"0")}-${String(w).padStart(2,"0")}`,et=D&&m<D||x&&m>x;return`<option value="${String(w).padStart(2,"0")}"${w===n?" selected":""}${et?" disabled":""}>${A(u)}</option>`}).join(""),I=a.map((u,f)=>`<th scope="col" abbr="${A(o[f])}">${A(u.replace(".",""))}</th>`).join("");this._renderedStates.clear();let W=l.map((u)=>{let f=k?`<th scope="row" class="dp-week-number">${Wt(u[0])}</th>`:"",w=u.map((m)=>{let et=this.getDateState(m);this._renderedStates.set(m,et);let fe=p(m)!==s,pe=this.value===m,me=this.focusedDate===m,ge=m===c,Pt=bt(m,this._highlightedRange),_e=this._dayLabel(m,et,Pt);return`<td class="dp-day" data-date="${m}"${fe?' data-outside-month="true"':""}${ge?' data-today="true" aria-current="date"':""}${pe?' data-selected="true" aria-selected="true"':""}${Re(Pt)}${et.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${me?"0":"-1"}" aria-label="${A(_e)}"><span class="dp-day-number" aria-hidden="true">${Number(m.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${f}${w}</tr>`}).join(""),X=document.activeElement,J=X instanceof HTMLElement&&this.contains(X)?this._focusTargetKey(X):"",L=Xt(e)[0]==="year";this.toggleAttribute("data-year-first",L);let Q=this.controlClasses,j=A(Q.month||"dp-skin"),xt=A(Q.year||"dp-skin"),ft=A(Q.nav||"dp-skin"),tt=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this.messages.month)}</label>
|
|
3
|
+
<select id="${this._id}-month" class="dp-month-select ${j}" aria-label="${A(this.messages.month)}">${H}</select>`,g=`<label class="dp-visually-hidden" for="${this._id}-year">${A(this.messages.year)}</label>
|
|
4
|
+
<input id="${this._id}-year" class="dp-year-input ${xt}" type="number" inputmode="numeric" value="${i}"${v}${E} aria-label="${A(this.messages.year)}">`;if(!this._heading?.isConnected||!this._renderRoot?.isConnected){this.replaceChildren();let u=document.createElement("h2");u.id=h,u.className="dp-calendar-heading dp-visually-hidden",u.setAttribute("aria-live","polite");let f=document.createElement("div");f.className="dp-calendar-render",this.append(u,f),this._heading=u,this._renderRoot=f}if(this._rendering=!0,this._renderRoot.innerHTML=`
|
|
5
5
|
<div class="dp-calendar-shell">
|
|
6
6
|
<div class="dp-calendar-header">
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
<button type="button" class="dp-nav dp-prev ${
|
|
10
|
-
<button type="button" class="dp-nav dp-next ${
|
|
7
|
+
${L?g:tt}
|
|
8
|
+
${L?tt:g}
|
|
9
|
+
<button type="button" class="dp-nav dp-prev ${ft}" data-calendar-action="previous" aria-label="${A(this.messages.previousMonth)}"${M?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m4 10 4-4 4 4"/></svg></button>
|
|
10
|
+
<button type="button" class="dp-nav dp-next ${ft}" data-calendar-action="next" aria-label="${A(this.messages.nextMonth)}"${b?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m4 6 4 4 4-4"/></svg></button>
|
|
11
11
|
</div>
|
|
12
|
-
<
|
|
13
|
-
<table id="${b}" class="dp-grid" role="grid" aria-labelledby="${u}">
|
|
12
|
+
<table id="${y}" class="dp-grid" role="grid" aria-labelledby="${h}">
|
|
14
13
|
<thead><tr>${C}${I}</tr></thead>
|
|
15
|
-
<tbody>${
|
|
14
|
+
<tbody>${W}</tbody>
|
|
16
15
|
</table>
|
|
17
|
-
</div>`,this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),X)queueMicrotask(()=>{let h=X;if(h.startsWith(".dp-day[data-date="))h=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let m=this.querySelector(h);if(m instanceof HTMLElement)m.focus()});if(this._renderDay)for(let h of this.querySelectorAll(".dp-day[data-date]")){if(!(h instanceof HTMLTableCellElement))continue;let m=h.dataset.date||"",w=h.querySelector(".dp-day-extra");if(!(w instanceof HTMLElement))continue;let p=this._renderDay(m,this._renderedStates.get(m)||{});if(p instanceof Node)w.append(p);else if(p!==void 0&&p!==null)w.textContent=String(p)}if(t)this._loadDisplay(s)}}function vt(t){return t==="top"||t==="bottom"?"x":"y"}var ne={top:"bottom",bottom:"top",left:"right",right:"left"},Oe=new Set(Object.keys(ne).flatMap((t)=>[t,`${t}-start`,`${t}-end`])),Pe=new Set(["viewport","document"]);function ze(t){if(!Oe.has(t))throw TypeError(`Unknown placement: ${t}`);let[e,s=null]=t.split("-");return{side:e,align:s,crossAxis:vt(e)}}function He(t,e,s,i,n,r){let a=vt(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,u;switch(s){case"top":u={x:o,y:t.y-e.height-r};break;case"bottom":u={x:o,y:t.y+t.height+r};break;case"right":u={x:t.x+t.width+r,y:d};break;case"left":u={x:t.x-e.width-r,y:d};break;default:u={x:t.x,y:t.y}}if(i==="start"||i==="end"){let b=(n&&a==="x"?-1:1)*(i==="end"?1:-1);u[a]+=l*b}return u}function Ve(t,e,s,i){return Math.max(s-t,0)+Math.max(t+e-i,0)}function Be(t){let e=t.ownerDocument?.defaultView;if(e&&t instanceof e.Element)return e.getComputedStyle(t).direction==="rtl";return"dir"in t&&t.dir==="rtl"}var Ne=25;function Ue(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<=Ne){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 je(t,e){return e.scope?e.scope.getBoundingClientRect():Ue(t.ownerDocument)}function Qt(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 te(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 Ge(t,e){for(let s=0;s<t.length;s++){let i=t[s];if(i.right>=e.x&&i.left<=e.right&&i.bottom>=e.y&&i.top<=e.bottom)return!1}return!0}function Ye(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 We(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function re(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 ee=new WeakMap,se={scroll:0,resize:1,"element-resize":2};function Ke(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(y,v){let E=i.get(y);if(E===void 0||se[v]>se[E])i.set(y,v)}function l(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let y=[...i];i.clear(),r=!1;for(let[v,E]of y){if(!s.has(v)||!v.floating.isConnected)continue;try{v.callback({type:E})}catch(k){u(k)}}})}function u(y){if(typeof e.reportError==="function")e.reportError(y);else e.setTimeout(()=>{throw y})}function b(y){for(let v of s)d(v,y);l()}function D(y){if(!n)return null;let v=new Set,E=new n((H)=>{let I=!1;for(let j of H)if(v.has(j.target))I=!0;else v.add(j.target);if(!I)return;d(y,"element-resize"),l()}),{reference:k,floating:C}=y;if(k)E.observe(k);if(C!==k)E.observe(C);return E}let x=()=>b("scroll"),T=()=>b("resize");function S(){if(a)return;t.addEventListener("scroll",x,{passive:!0,capture:!0}),e.addEventListener("resize",T,{passive:!0}),o?.addEventListener("scroll",x,{passive:!0}),o?.addEventListener("resize",T,{passive:!0}),a=!0}function M(){if(!a)return;t.removeEventListener("scroll",x,{capture:!0}),e.removeEventListener("resize",T),o?.removeEventListener("scroll",x),o?.removeEventListener("resize",T),a=!1}return{add(y,v,E){let k={reference:y,floating:v,callback:E};s.add(k),S();let C=D(k),H=!1;return()=>{if(H)return;if(H=!0,s.delete(k),i.delete(k),C?.disconnect(),s.size===0)M()}}}}function qe(t){let e=t.ownerDocument,s=ee.get(e);if(!s)s=Ke(e),ee.set(e,s);return s}function ae(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 qe(e).add(t,e,s)}function ie(t,e,s){let i=s.placement===void 0?"bottom-start":s.placement,{side:n,align:r,crossAxis:a}=ze(i),o=s.coordinateSpace===void 0?"viewport":s.coordinateSpace;if(!Pe.has(o))throw TypeError(`Unknown coordinateSpace: ${o}`);if(!We(e))return null;let d=s.distance||0,l=s.flip!==!1,u=s.shift!==!1,b=s.shiftPadding??4,D=r?Be(t):!1,x=t.getClientRects();if(!x.length)return null;let T=(_)=>_==="bottom"?x[x.length-1]:x[0],S=je(t,s);if(!S||Ge(x,S))return null;let M=re(e),y={x:{size:M.width,start:S.x,end:S.right},y:{size:M.height,start:S.y,end:S.bottom}},v=(_,h)=>He(T(_),M,_,h,D,d),E=(_,h)=>{let{size:m,start:w,end:p}=y[h];return Ve(_,m,w+b,p-b)},k=(_,h)=>{let{size:m,start:w,end:p}=y[h];return E(u?Qt(_,m,w,p,b):_,h)},C=v(n,r),H=(_,h)=>{let m=vt(_),w=m==="x"?"y":"x",p=E(h[w],w);return{main:p,total:p+k(h[m],m)}};if(l){let _=H(n,C),h=(m)=>{let w=v(m,r),p=H(m,w);if(p.total<_.total)n=m,C=w,_=p};if(_.main>0)h(ne[n]);if(a==="y"&&_.main>0)h("top"),h("bottom");a=vt(n)}if(a==="x"&&u&&r){let _=E(C.x,"x");if(_>0){let h=r==="end"?"start":"end",m=v(n,h);if(E(m.x,"x")<_)r=h,C=m}}if(u){let{size:_,start:h,end:m}=y[a];C[a]=Qt(C[a],_,h,m,b)}let I=T(n),j=te(I.x+I.width/2,C.x,M.width),q=te(I.y+I.height/2,C.y,M.height),X=`${Ye(I,n,S,d,b)}px`,{style:R}=e,Z=R.getPropertyValue("--available-height")!==X,G=o==="document"?t.ownerDocument.defaultView:null,wt=G?G.scrollX:0,ut=G?G.scrollY:0;R.left=`${C.x+wt}px`,R.top=`${C.y+ut}px`,R.setProperty("--arrow-x",`${j}%`),R.setProperty("--arrow-y",`${q}%`),R.setProperty("--available-height",X);let J=r?`${n}-${r}`:n;return e.dataset.placement=J,{width:M.width,height:M.height,roomChanged:Z,placement:J}}function oe(t,e,s={}){let i=ie(t,e,s);if(!i)return!1;if(i.roomChanged){let n=re(e);if(n.width!==i.width||n.height!==i.height)ie(t,e,{...s,placement:i.placement,flip:!1})}return!0}function z(t){return!t.matches(":disabled")&&!t.readOnly}class ct{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=dt(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,this._generatedDefault=null}setLocale(t){let e=this._generatedDefault,s=e?this.adapter.format(e):null;if(this.adapter=dt(t||""),e&&this.input.defaultValue===s)this.input.defaultValue=this.adapter.format(e)}adoptDefault(){let t=this.input;if(t.getAttribute("value")!=null||t.defaultValue!=="")return;t.defaultValue=t.value,this._generatedDefault=this.canonical&&t.value?this.canonical:null}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.matches(":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,e=t.value.trim(),s=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),e===s){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;t.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!e){t.setCustomValidity("");return}t.setCustomValidity(this.messages.invalidDate)}async commit(t={}){let e=this.input,s=++this._commitId,i=e.value.trim();if(!i){if(s!==this._commitId)return{status:"stale"};return e.setCustomValidity(""),{status:"clear",value:""}}let n=this.adapter.parse(i);if(!n){if(s!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let r=await this.confirm(n,t);if(s!==this._commitId)return{status:"stale"};if(!r?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(r?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:n}}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 Xe=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function Ft(t){let e=Xe.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=e[3]===void 0?0:Number(e[3]),r=e[4]===void 0?0:Number(e[4].padEnd(3,"0"));if(s>23||i>59||n>59||r>999)return null;return{hour:s,minute:i,second:n,millisecond:r}}function Lt(t){return Ft(t)!==null}function de(t){return((t.hour*60+t.minute)*60+t.second)*1000+t.millisecond}function le(t,e){let s=Ft(t),i=Ft(e);if(!s||!i)throw TypeError("compareTimes() expects HH:MM values");let n=de(s)-de(i);return n===0?0:n<0?-1:1}var Ze=0,ce=4;class It extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];static setDefaultControlClasses(t){pt(t)}static getDefaultControlClasses(){return nt()}static setDefaultMessages(t){_t(t)}static getDefaultMessages(){return N()}constructor(){super();this._id=`date-picker-${++Ze}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._activationId=0,this._previewDate="",this._drag=null,this._suppressGridClick=!1,this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(K(this,["locale","min","max","monthFormat","openOnFocus","coordinateSpace","controlClasses","messages","source","dateState","renderDay","isDateDisabled"]),this.hasAttribute("range"))this._connectRange();else this._connectSingle();if(this._connected)K(this,["value","range"]),this._stopDefaultMessages=yt(()=>{if(this._messages===null)this._refreshMessages()}),this.validate()}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._discoverTimeFields(),this._field=new ct(t,{messages:this.messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(i,n)=>this._confirmDate(i,n),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;this._field.adoptDefault()}_discoverTimeFields(){this._timeFields=[null,null];let t=["data-time-start","data-time-end"];for(let[e,s]of t.entries()){let i=this.querySelectorAll(`:scope > input[${s}]`);if(i.length>1)console.warn(`<date-picker> expects at most one direct child input[${s}]; ignoring extras`);let n=i[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${s}] must be an <input type="time">; ignoring it`);continue}this._timeFields[e]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let 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 ct(t,{messages:this.messages,locale:this.locale}),new ct(e,{messages:this.messages,locale:this.locale})],this._range=new Tt,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let o of this._fields)o.onAttributesChanged=()=>this._syncRangeFields(),o.confirm=(d,l)=>this._confirmDate(d,l),o.setupFormValue();this._build(),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),r=t.value,a=e.value;this._setRange(i||"",n||"",{emit:!1});for(let[o,d,l]of[[t,r,i],[e,a,n]]){if(!d.trim()||c(l))continue;o.value=d,o.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;for(let o of this._fields)o.adoptDefault()}disconnectedCallback(){if(this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,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;for(let{button:t}of this._buttons)t.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),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._supersedeActivations(),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._supersedeActivations(),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}=mt(t);this._supersedeActivations(),this._setRange(e,s)}get locale(){return P(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}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 controlClasses(){return at(this._controlClasses)}set controlClasses(t){if(this._controlClasses=rt(t),this._calendar)this._calendar.controlClasses=this._controlClasses}get messages(){return this._messages??N()}set messages(t){if(this._messages=t==null?null:{...N(),...t},this._calendar)this._calendar.messages=this._messages;this._refreshMessages()}_refreshMessages(){let t=this.messages;for(let s of this._fields||[])s.setMessages(t);this._field?.setMessages(t),this._panel?.setAttribute("aria-label",t.calendar);let e=this._field??this._fields?.[0];if(this._formatHint&&e)this._formatHint.textContent=`${t.formatHint}: ${e.placeholder}`;if(this._refreshButtonLabel(),this._connected)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()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(t){this._coordinateSpace=t==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??dt(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;this._field?.syncInputState();let e=this._buttons[0]?.button;if(e)e.disabled=t.disabled||t.readOnly;if(this._open&&!z(t))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let s of this._fields)s.syncInputState();for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?1:0,r=this._fields[n];s.disabled=Boolean(r?.input.disabled||r?.input.readOnly)}this._syncDragAffordance();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields[t]?.input;if(this._open&&e&&!z(e))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)}}_createTrigger(t){let e=document.createElement("button");if(e.type="button",e.className="dp-picker-button",e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",`${this._id}-panel`),t)e.dataset.endpoint=t;return e.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>',e}_build(){let t=this._rangeMode(),e=[];if(t)for(let[o,d]of(this._fields||[]).entries())e.push([d.input,o===1?"end":"start"]);else if(this._input)e.push([this._input,""]);if(!e.length)return;let s=`${this._id}-panel`,i=`${this._id}-format`;this._buttons=e.map(([o,d])=>{let l=this._createTrigger(d);return o.insertAdjacentElement("afterend",l),{button:l,endpoint:d}});let n=document.createElement("div");n.id=s,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this.messages.calendar);let r=new lt;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=i,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!t&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,i].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",s)}this._refreshLocale(),this._refreshButtonLabel()}_bindPopup(t,e,s){this.ownerDocument.addEventListener("pointerdown",(i)=>{if(!this._open||i.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:t}),this.ownerDocument.addEventListener("reset",(i)=>{if(!(i.target instanceof HTMLFormElement)||!e||i.target!==e.form)return;this.hide(!1),queueMicrotask(()=>{if(!i.defaultPrevented)s()})},{capture:!0,signal:t}),this.addEventListener("keydown",(i)=>this._onEscape(i),{signal:t})}_bind(){let t=this._input,e=this._buttons[0]?.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});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show({returnFocus:e})},{signal:n}),e.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),s.addEventListener("click",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("keydown",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;let d=tt.get(a);queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(d&&d.id!==this._activationId)return;if(!this._input||!z(this._input))return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),s.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this._bindPopup(n,this._input,()=>this._restoreDefault())}_bindRange(){let t=this._calendar;if(!this._fields||!this._buttons.length||!t)return;let e=new AbortController;this._controller=e;let{signal:s}=e;for(let[i,n]of this._fields.entries()){let r=i===1?"end":"start";n.input.addEventListener("input",()=>{if(n.handleInput(),this._orderTags.delete(i),!n.isDirty)this._revalidateRange(r)},{signal:s}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:s}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:s})}for(let i of this._buttons){let n=i.endpoint;if(n==="")continue;i.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:s}),i.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:s})}t.addEventListener("click",(i)=>{if(this._suppressGridClick){this._suppressGridClick=!1,i.preventDefault(),i.stopImmediatePropagation();return}this._captureGridIntent(i)},{capture:!0,signal:s}),t.addEventListener("keydown",(i)=>this._captureGridIntent(i),{capture:!0,signal:s}),t.addEventListener("dateactivate",(i)=>{let n=i,r=n.detail?.date;if(!c(r))return;queueMicrotask(()=>{if(n.defaultPrevented||!this._connected||!this._range)return;let a=tt.get(n);if(a===void 0||a.id!==this._activationId)return;let o=(l)=>this._boundEditable(l),d=a.endpoint?this._range.moveEndpoint(r,a.endpoint,o):this._range.activate(r,o);if(d.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._applyRangeTransition(d),a.endpoint)return;if(d.close||d.status==="complete")this.hide(!1),this._focusField(d.endpoint)})},{signal:s}),t.addEventListener("datefocus",(i)=>this._onGridDateFocus(i),{signal:s}),t.addEventListener("pointerover",(i)=>this._onGridPointerOver(i),{signal:s}),t.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:s}),t.addEventListener("pointerdown",(i)=>this._onGridPointerDown(i),{signal:s}),t.addEventListener("pointermove",(i)=>this._onGridPointerMove(i),{signal:s}),t.addEventListener("pointerup",(i)=>this._onGridPointerUp(i),{signal:s}),t.addEventListener("pointercancel",(i)=>this._onGridPointerCancel(i),{signal:s}),t.addEventListener("lostpointercapture",(i)=>this._onGridPointerCancel(i),{signal:s}),t.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this._bindPopup(s,this._fields?.[0]?.input,()=>this._restoreRangeDefault())}_activateRangeEndpoint(t){let e=this._calendar;if(!this._range||!e)return;this._range.focus(t),this._activationId++,this._lastFocusEndpoint=t;let s=this._boundCanonical(t)||O();e.display=f(s),e.focusedDate=s,this._clearPreview()}_onRangeTriggerClick(t,e){if(!this._open){this.show({endpoint:t});return}if(e.detail===0){this._activateRangeEndpoint(t),setTimeout(()=>this._calendar?.focusGrid(),0);return}if(t!==this._range?.activeEndpoint){this._activateRangeEndpoint(t);return}this.hide(!1)}_onTriggerKeyDown(t,e){if(e.key!=="ArrowDown")return;if(e.preventDefault(),this._open){if(this._rangeMode()&&t)this._activateRangeEndpoint(t);setTimeout(()=>this._calendar?.focusGrid(),0);return}if(this._rangeMode())this.show({endpoint:t||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(t,e){if(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._activationId++;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:!this._field)return;if(t.type==="keydown"){let i=t.key;if(i!=="Enter"&&i!==" ")return}if(t.type==="click"&&this._suppressGridClick)return;if(!(t.target instanceof Element))return;let s=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(s))return;this._attachIntent(s,"")}_attachIntent(t,e){if(!this._calendar)return;this._calendar._hostIntent={date:t,intent:{id:++this._activationId,endpoint:e}}}_supersedeActivations(){this._activationId++}_boundEditable(t){let e=this._fields?.[t==="end"?1:0];return e!=null&&z(e.input)}_applyRangeTransition(t){let e=this._fields;if(!e||!this._range||t.status==="refused")return;let s=[];for(let i of t.changedEndpoints){let n=e[i==="end"?1:0],r=i==="end"?t.range.end:t.range.start;if(!n||n.canonical===r)continue;n.setCanonical(r,{format:!0}),s.push(n)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(t.endpoint),!s.length)return;this._emitRangeChange();for(let i of s)i.input.dispatchEvent(new Event("input",{bubbles:!0})),i.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(t,e=""){let s=this._calendar;if(!s||!this._range||!this._open)return;let i=c(t)&&!s.getDateState(t).disabled?t:"",n=i?this._range.previewRange(i,e,(r)=>this._boundEditable(r)):null;if(!n){this._clearPreview();return}this._previewDate=i,s.toggleAttribute("data-range-preview",!0),s.highlightedRange=n}_clearPreview(){if(!this._previewDate)return;this._syncHighlight()}_onGridDateFocus(t){if(this._drag)return;let e=t.detail?.date;if(c(e))this._setPreview(e)}_onGridPointerOver(t){let e=t;if(this._drag||e.pointerType==="touch")return;this._setPreview(this._cellDate(e.target))}_onGridPointerLeave(){if(this._drag?.active===!1)this._drag=null;if(this._drag)return;this._clearPreview()}_cellDate(t){let s=(t instanceof Element?t.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return c(s)?s:""}_dateAtPoint(t,e){let s=this.ownerDocument.elementFromPoint(t,e);if(!(s instanceof Element)||!this._calendar?.contains(s))return"";return this._cellDate(s)}_onGridPointerDown(t){let e=t;if(this._suppressGridClick=!1,this._drag?.active===!1)this._drag=null;if(!this._open||!this._range||this._drag)return;if(!e.isPrimary||e.button!==0)return;if(e.pointerType!=="mouse"&&e.pointerType!=="pen")return;if(!this._range.complete)return;let s=e.target instanceof Element?e.target.closest(".dp-day[data-date]"):null;if(!(s instanceof HTMLElement))return;let i=s.hasAttribute("data-range-start"),n=s.hasAttribute("data-range-end");if(i===n)return;let r=i?"start":"end",a=this._cellDate(s);if(!a||!this._boundEditable(r))return;this._drag={pointerId:e.pointerId,endpoint:r,x:e.clientX,y:e.clientY,date:a,active:!1}}_onGridPointerMove(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;if(!s.active){if(!(Math.abs(e.clientX-s.x)>ce||Math.abs(e.clientY-s.y)>ce))return;s.active=!0;try{this._calendar?.setPointerCapture(s.pointerId)}catch{}this._syncDragAffordance()}let i=this._dateAtPoint(e.clientX,e.clientY);if(!i||this._calendar?.getDateState(i).disabled)return;s.date=i,this._setPreview(i,s.endpoint)}_onGridPointerUp(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;if(this._drag=null,this._releaseDragCapture(s.pointerId),!s.active){this._syncDragAffordance();return}this._suppressGridClick=!0;let i=this._range?.projectEndpoint(s.date,s.endpoint,(r)=>this._boundEditable(r));if(!i||i.status==="refused"||!i.changedEndpoints.length){this._syncHighlight();return}let n=s.endpoint==="start"?i.range.start:i.range.end;this._attachIntent(n,s.endpoint),this._calendar?.activateDate(n)}_onGridPointerCancel(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;this._drag=null,this._releaseDragCapture(s.pointerId),this._syncHighlight()}_releaseDragCapture(t){let e=this._calendar;if(e?.hasPointerCapture(t))e.releasePointerCapture(t)}_syncDragAffordance(){let t=this._calendar;if(!t||!this._range)return;if(this._drag?.active){t.setAttribute("data-range-drag","active");return}let{start:e,end:s}=this._range;if(this._range.complete&&e!==s&&(this._boundEditable("start")||this._boundEditable("end")))t.setAttribute("data-range-drag","ready");else t.removeAttribute("data-range-drag")}_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.monthFormat=this.monthFormat,t.controlClasses=this._controlClasses,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(){let t=this._buttons[0]?.button;if(!t)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let e=this._value?this.messages.changeDate:this.messages.chooseDate,s=this._value?`, ${ot(this._value,this.locale)}`:"";t.setAttribute("aria-label",`${e}${s}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:t,end:e}=this._range;for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?e:t,r=n?this.messages.changeDate:this.messages.chooseDate,a=n?`, ${ot(n,this.locale)}`:"",o=i==="end"?this.messages.rangeEnd:this.messages.rangeStart;s.setAttribute("aria-label",`${r}${a}, ${o}`)}}_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&&e.moveDisplay!==!1)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,e={}){let s=this._calendar;if(!s)return{ok:!0};if(e.moveDisplay!==!1){let r=f(t);if(s.display!==r)s.display=r}let i=await s.ensureDate(t),n=s.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(e);if(i.status==="stale"||i.status==="invalid")return!1;return this._setValue(i.value||"",{emit:t,format:i.status==="ok",moveDisplay:e.moveDisplay}),!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:!1,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&&!z(r.input))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}))}_displayRange(){let{start:t,end:e}=this._range?.range??{start:"",end:""};if(!t)return{start:"",end:""};if(e&&g(e,t)<0)return{start:t,end:""};return{start:t,end:e}}_syncHighlight(){if(!this._calendar||!this._range)return;this._previewDate="",this._calendar.removeAttribute("data-range-preview"),this._calendar.highlightedRange=this._displayRange(),this._syncDragAffordance()}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:s}=this._range,i=Boolean(e&&s&&g(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)}}_revalidateTimeOrder(t){let[e,s]=this._timeFields,i=["start","end"],n=[e,s],r=e&&!e.matches(":disabled")?e.value.trim():"",a=s&&!s.matches(":disabled")?s.value.trim():"",o=Boolean(e&&s&&r&&a)&&Lt(r)&&Lt(a)&&le(a,r)<0;for(let[d,l]of i.entries()){let u=n[d];if(!u)continue;let b=l==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(o&&l===t)u.setCustomValidity(b),this._timeOrderOwned.add(u);else if(this._timeOrderOwned.has(u))u.setCustomValidity(""),this._timeOrderOwned.delete(u)}}_clearTimeOrderValidity(){for(let t of this._timeOrderOwned)t.setCustomValidity("");this._timeOrderOwned.clear()}_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(O()),this._calendar.focusedDate=O();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||O();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)}_restoreFocus(){let t=this._returnFocus;if(this._returnFocus=null,!(t instanceof HTMLElement)||!t.isConnected||t.matches(":disabled"))return;this._suppressFocusOpen=!0,setTimeout(()=>{t.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(z(this._fields[e].input))return t;let s=t==="end"?"start":"end",i=s==="end"?1:0;if(z(this._fields[i].input))return s;return""}async validate(){if(this._rangeMode()){let s=this._fields;if(!s)return!0;for(let[i,n]of s.entries()){let r=await n.commit({moveDisplay:!1});if(r.status==="invalid")this._orderTags.delete(i);if(r.status==="ok"||r.status==="clear"){let a=i===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),s.every((i)=>i.input.checkValidity())}let t=this._field?.input;if(!t)return!0;await this._commitText(!1,{force:!0,moveDisplay:!1}),this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let e=this._timeFields.every((s)=>s?.checkValidity()??!0);return t.checkValidity()&&e}show(t={}){let e=this._panel,s=this._calendar;if(!e||!s||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=t.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||!z(r))return;let a=this._value||this._adapter().parse(r.value)||O();s.display=f(a),s.focusedDate=a,this._returnFocus=t.returnFocus instanceof HTMLElement?t.returnFocus:r}e.showPopover(),this._open=!0,this._setExpanded(!0);let i=this.coordinateSpace;e.style.position=i==="document"?"absolute":"fixed";let n=()=>oe(this,e,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:i});if(n(),this._stopTracking=ae(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);for(let{button:s}of this._buttons)s.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._supersedeActivations(),this._suppressGridClick=!1,this._drag)this._releaseDragCapture(this._drag.pointerId),this._drag=null;if(this._syncHighlight(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._restoreFocus();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&&z(s.input))return t}return this._resolveRangeEndpoint()}}function Rt(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",lt);if(!customElements.get("date-picker"))customElements.define("date-picker",It)}Rt();var ue="lekoala-date-picker-styles";if(!document.getElementById(ue)){let t=document.createElement("style");t.id=ue,t.textContent=Pt;let e=document.currentScript?.nonce;if(e)t.nonce=e;document.head.append(t)}Rt();})();
|
|
16
|
+
</div>`,this._heading.textContent=Zt(`${s}-15`,e),this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),J)this._queueFocus(()=>{let u=J;if(u.startsWith(".dp-day[data-date="))u=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let f=this.querySelector(u);if(f instanceof HTMLElement)f.focus()});if(this._renderDay)for(let u of this.querySelectorAll(".dp-day[data-date]")){if(!(u instanceof HTMLTableCellElement))continue;let f=u.dataset.date||"",w=u.querySelector(".dp-day-extra");if(!(w instanceof HTMLElement))continue;let m=this._renderDay(f,this._renderedStates.get(f)||{});if(m instanceof Node)w.append(m);else if(m!==void 0&&m!==null)w.textContent=String(m)}if(t)this._loadDisplay(s)}}function Dt(t){return t==="top"||t==="bottom"?"x":"y"}var ae={top:"bottom",bottom:"top",left:"right",right:"left"},Le=new Set(Object.keys(ae).flatMap((t)=>[t,`${t}-start`,`${t}-end`])),Oe=new Set(["viewport","document"]);function ze(t){if(!Le.has(t))throw TypeError(`Unknown placement: ${t}`);let[e,s=null]=t.split("-");return{side:e,align:s,crossAxis:Dt(e)}}function Pe(t,e,s,i,n,r){let a=Dt(s),o=t.x+t.width/2-e.width/2,l=t.y+t.height/2-e.height/2,c=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:l};break;case"left":h={x:t.x-e.width-r,y:l};break;default:h={x:t.x,y:t.y}}if(i==="start"||i==="end"){let y=(n&&a==="x"?-1:1)*(i==="end"?1:-1);h[a]+=c*y}return h}function He(t,e,s,i){return Math.max(s-t,0)+Math.max(t+e-i,0)}function Be(t){let e=t.ownerDocument?.defaultView;if(e&&t instanceof e.Element)return e.getComputedStyle(t).direction==="rtl";return"dir"in t&&t.dir==="rtl"}var Ne=25;function Ve(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,l=t.compatMode==="BackCompat"?a-s.clientWidth:s.clientWidth-s.getBoundingClientRect().width;if(l>0&&l<=Ne){let c=e.getComputedStyle?.(s).scrollbarGutter;if(c&&c!=="auto")a-=l}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():Ve(t.ownerDocument)}function ee(t,e,s,i,n){let r=s+n,a=i-e-n,o=a>=r,l=o?r:s,c=o?a:i-e;return Math.max(l,Math.min(t,c))}function se(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 We(t,e){for(let s=0;s<t.length;s++){let i=t[s];if(i.right>=e.x&&i.left<=e.right&&i.bottom>=e.y&&i.top<=e.bottom)return!1}return!0}function je(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 Ye(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function oe(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 ie=new WeakMap,ne={scroll:0,resize:1,"element-resize":2};function qe(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 l(b,v){let E=i.get(b);if(E===void 0||ne[v]>ne[E])i.set(b,v)}function c(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let b=[...i];i.clear(),r=!1;for(let[v,E]of b){if(!s.has(v)||!v.floating.isConnected)continue;try{v.callback({type:E})}catch(k){h(k)}}})}function h(b){if(typeof e.reportError==="function")e.reportError(b);else e.setTimeout(()=>{throw b})}function y(b){for(let v of s)l(v,b);c()}function D(b){if(!n)return null;let v=new Set,E=new n((H)=>{let I=!1;for(let W of H)if(v.has(W.target))I=!0;else v.add(W.target);if(!I)return;l(b,"element-resize"),c()}),{reference:k,floating:C}=b;if(k)E.observe(k);if(C!==k)E.observe(C);return E}let x=()=>y("scroll"),S=()=>y("resize");function T(){if(a)return;t.addEventListener("scroll",x,{passive:!0,capture:!0}),e.addEventListener("resize",S,{passive:!0}),o?.addEventListener("scroll",x,{passive:!0}),o?.addEventListener("resize",S,{passive:!0}),a=!0}function M(){if(!a)return;t.removeEventListener("scroll",x,{capture:!0}),e.removeEventListener("resize",S),o?.removeEventListener("scroll",x),o?.removeEventListener("resize",S),a=!1}return{add(b,v,E){let k={reference:b,floating:v,callback:E};s.add(k),T();let C=D(k),H=!1;return()=>{if(H)return;if(H=!0,s.delete(k),i.delete(k),C?.disconnect(),s.size===0)M()}}}}function Ke(t){let e=t.ownerDocument,s=ie.get(e);if(!s)s=qe(e),ie.set(e,s);return s}function de(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 Ke(e).add(t,e,s)}function re(t,e,s){let i=s.placement===void 0?"bottom-start":s.placement,{side:n,align:r,crossAxis:a}=ze(i),o=s.coordinateSpace===void 0?"viewport":s.coordinateSpace;if(!Oe.has(o))throw TypeError(`Unknown coordinateSpace: ${o}`);if(!Ye(e))return null;let l=s.distance||0,c=s.flip!==!1,h=s.shift!==!1,y=s.shiftPadding??4,D=r?Be(t):!1,x=t.getClientRects();if(!x.length)return null;let S=(g)=>g==="bottom"?x[x.length-1]:x[0],T=Ue(t,s);if(!T||We(x,T))return null;let M=oe(e),b={x:{size:M.width,start:T.x,end:T.right},y:{size:M.height,start:T.y,end:T.bottom}},v=(g,u)=>Pe(S(g),M,g,u,D,l),E=(g,u)=>{let{size:f,start:w,end:m}=b[u];return He(g,f,w+y,m-y)},k=(g,u)=>{let{size:f,start:w,end:m}=b[u];return E(h?ee(g,f,w,m,y):g,u)},C=v(n,r),H=(g,u)=>{let f=Dt(g),w=f==="x"?"y":"x",m=E(u[w],w);return{main:m,total:m+k(u[f],f)}};if(c){let g=H(n,C),u=(f)=>{let w=v(f,r),m=H(f,w);if(m.total<g.total)n=f,C=w,g=m};if(g.main>0)u(ae[n]);if(a==="y"&&g.main>0)u("top"),u("bottom");a=Dt(n)}if(a==="x"&&h&&r){let g=E(C.x,"x");if(g>0){let u=r==="end"?"start":"end",f=v(n,u);if(E(f.x,"x")<g)r=u,C=f}}if(h){let{size:g,start:u,end:f}=b[a];C[a]=ee(C[a],g,u,f,y)}let I=S(n),W=se(I.x+I.width/2,C.x,M.width),X=se(I.y+I.height/2,C.y,M.height),J=`${je(I,n,T,l,y)}px`,{style:L}=e,Q=L.getPropertyValue("--available-height")!==J,j=o==="document"?t.ownerDocument.defaultView:null,xt=j?j.scrollX:0,ft=j?j.scrollY:0;L.left=`${C.x+xt}px`,L.top=`${C.y+ft}px`,L.setProperty("--arrow-x",`${W}%`),L.setProperty("--arrow-y",`${X}%`),L.setProperty("--available-height",J);let tt=r?`${n}-${r}`:n;return e.dataset.placement=tt,{width:M.width,height:M.height,roomChanged:Q,placement:tt}}function le(t,e,s={}){let i=re(t,e,s);if(!i)return!1;if(i.roomChanged){let n=oe(e);if(n.width!==i.width||n.height!==i.height)re(t,e,{...s,placement:i.placement,flip:!1})}return!0}function P(t){return!t.matches(":disabled")&&!t.readOnly}class ht{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=ct(e.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._session=K(),this._originalName=t.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null,this._generatedDefault=null}setLocale(t){let e=this._generatedDefault,s=e?this.adapter.format(e):null;if(this.adapter=ct(t||""),e&&this.input.defaultValue===s)this.input.defaultValue=this.adapter.format(e)}adoptDefault(){let t=this.input;if(t.getAttribute("value")!=null||t.defaultValue!=="")return;t.defaultValue=t.value,this._generatedDefault=this.canonical&&t.value?this.canonical:null}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.matches(":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,e=t.value.trim(),s=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),e===s){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;t.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!e){t.setCustomValidity("");return}t.setCustomValidity(this.messages.invalidDate)}async commit(t={}){let e=this.input,s=++this._commitId,i=this._session;if(i.signal.aborted)return{status:"stale",commitId:s};let n=e.value.trim();if(!n){if(s!==this._commitId)return{status:"stale",commitId:s};return e.setCustomValidity(""),{status:"clear",value:"",commitId:s}}let r=this.adapter.parse(n);if(!r){if(s!==this._commitId)return{status:"stale",commitId:s};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid",commitId:s}}if(this.confirm){let a=await this.confirm(r,t);if(i.signal.aborted||s!==this._commitId)return{status:"stale",commitId:s};if(!a?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(a?.message||this.messages.unavailableDate),{status:"invalid",commitId:s}}}return{status:"ok",value:r,commitId:s}}isCommitCurrent(t){return t===this._commitId}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.dirty(),this._session.abort(),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=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function It(t){let e=Ge.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=e[3]===void 0?0:Number(e[3]),r=e[4]===void 0?0:Number(e[4].padEnd(3,"0"));if(s>23||i>59||n>59||r>999)return null;return{hour:s,minute:i,second:n,millisecond:r}}function Lt(t){return It(t)!==null}function ce(t){return((t.hour*60+t.minute)*60+t.second)*1000+t.millisecond}function ue(t,e){let s=It(t),i=It(e);if(!s||!i)throw TypeError("compareTimes() expects HH:MM values");let n=ce(s)-ce(i);return n===0?0:n<0?-1:1}var Ze=0;class Ot extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];static setDefaultControlClasses(t){gt(t)}static getDefaultControlClasses(){return at()}static setDefaultMessages(t){yt(t)}static getDefaultMessages(){return V()}constructor(){super();this._id=`date-picker-${++Ze}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._activationId=0,this._previewDate="",this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholders=new WeakSet,this._session=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this._session=K(),Z(this,["locale","min","max","monthFormat","openOnFocus","coordinateSpace","controlClasses","messages","source","dateState","renderDay","isDateDisabled"]),this._normalizeAttributes(),this.hasAttribute("range"))this._connectRange();else this._connectSingle();if(!this._connected){this._session.abort(),this._session=null;return}Z(this,["value","range"]),this._stopDefaultMessages=vt(()=>{if(this._messages===null)this._refreshMessages()}),this.validate()}_normalizeAttributes(){let t=this.getAttribute("value");if(t&&!d(t))this.removeAttribute("value");for(let e of["min","max"]){let s=this.getAttribute(e);if(s&&!d(s))this.removeAttribute(e)}}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._discoverTimeFields(),this._field=new ht(t,{messages:this.messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(i,n)=>this._confirmDate(i,n),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;this._field.adoptDefault()}_discoverTimeFields(){this._timeFields=[null,null];let t=["data-time-start","data-time-end"];for(let[e,s]of t.entries()){let i=this.querySelectorAll(`:scope > input[${s}]`);if(i.length>1)console.warn(`<date-picker> expects at most one direct child input[${s}]; ignoring extras`);let n=i[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${s}] must be an <input type="time">; ignoring it`);continue}this._timeFields[e]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let 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 ht(t,{messages:this.messages,locale:this.locale}),new ht(e,{messages:this.messages,locale:this.locale})],this._range=new Mt,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let o of this._fields)o.onAttributesChanged=()=>this._syncRangeFields(),o.confirm=(l,c)=>this._confirmDate(l,c),o.setupFormValue();this._build(),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),r=t.value,a=e.value;this._setRange(i||"",n||"",{emit:!1});for(let[o,l,c]of[[t,r,i],[e,a,n]]){if(!l.trim()||d(c))continue;o.value=l,o.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;for(let o of this._fields)o.adoptDefault()}disconnectedCallback(){if(this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._suppressFocusOpen=!1,this.hide(!1),this._session?.abort(),this._session=null,this._clearTimeOrderValidity(),this._timeFields=[null,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;for(let{button:t}of this._buttons)t.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),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._reflecting||e===s)return;if(!this._connected)return;if(t==="value"&&s&&!d(s)){this._reflectValue(this._value);return}if((t==="min"||t==="max")&&s&&!d(s)){if(this.removeAttribute(t),this._connected)this._syncCalendarOptions(),this.validate();return}if(t==="value"){if(this._rangeMode())return;if(!s||d(s))this._supersedeActivations(),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._supersedeActivations(),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}=_t(t);this._supersedeActivations(),this._setRange(e,s)}get locale(){return z(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}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 controlClasses(){return dt(this._controlClasses)}set controlClasses(t){if(this._controlClasses=ot(t),this._calendar)this._calendar.controlClasses=this._controlClasses}get messages(){return this._messages??V()}set messages(t){if(this._messages=t==null?null:{...V(),...t},this._calendar)this._calendar.messages=this._messages;this._refreshMessages()}_refreshMessages(){let t=this.messages;for(let s of this._fields||[])s.setMessages(t);this._field?.setMessages(t),this._panel?.setAttribute("aria-label",t.calendar);let e=this._field??this._fields?.[0];if(this._formatHint&&e)this._formatHint.textContent=`${t.formatHint}: ${e.placeholder}`;if(this._refreshButtonLabel(),this._connected)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()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(t){this._coordinateSpace=t==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??ct(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;this._field?.syncInputState();let e=this._buttons[0]?.button;if(e)e.disabled=t.disabled||t.readOnly;if(this._open&&!P(t))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let s of this._fields)s.syncInputState();for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?1:0,r=this._fields[n];s.disabled=Boolean(r?.input.disabled||r?.input.readOnly)}let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields[t]?.input;if(this._open&&e&&!P(e))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)}}_createTrigger(t){let e=document.createElement("button");if(e.type="button",e.className="dp-picker-button",e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",`${this._id}-panel`),t)e.dataset.endpoint=t;return e.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>',e}_build(){let t=this._rangeMode(),e=[];if(t)for(let[o,l]of(this._fields||[]).entries())e.push([l.input,o===1?"end":"start"]);else if(this._input)e.push([this._input,""]);if(!e.length)return;let s=`${this._id}-panel`,i=`${this._id}-format`;this._buttons=e.map(([o,l])=>{let c=this._createTrigger(l);return o.insertAdjacentElement("afterend",c),{button:c,endpoint:l}});let n=document.createElement("div");n.id=s,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this.messages.calendar);let r=new ut;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=i,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!t&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,i].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",s)}this._refreshLocale(),this._refreshButtonLabel()}_bindPopup(t,e,s){this.ownerDocument.addEventListener("pointerdown",(i)=>{if(!this._open||i.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:t}),this.ownerDocument.addEventListener("reset",(i)=>{if(!(i.target instanceof HTMLFormElement)||!e||i.target!==e.form)return;this.hide(!1),queueMicrotask(G(t,()=>{if(!i.defaultPrevented)s()}))},{capture:!0,signal:t}),this.addEventListener("keydown",(i)=>this._onEscape(i),{signal:t})}_bind(){let t=this._input,e=this._buttons[0]?.button,s=this._calendar;if(!t||!e||!s)return;let i=this._session;if(!i)return;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});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){this._defer(()=>this._calendar?.focusGrid());return}this.hide(!1);return}this.show({returnFocus:e})},{signal:n}),e.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),s.addEventListener("click",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("keydown",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!d(o))return;let l=st.get(a);queueMicrotask(()=>{if(n.aborted||a.defaultPrevented)return;if(l&&l.id!==this._activationId)return;if(!this._input||!P(this._input))return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),s.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this._bindPopup(n,this._input,()=>this._restoreDefault())}_bindRange(){let t=this._calendar;if(!this._fields||!this._buttons.length||!t)return;let e=this._session;if(!e)return;let{signal:s}=e;for(let[i,n]of this._fields.entries()){let r=i===1?"end":"start";n.input.addEventListener("input",()=>{if(n.handleInput(),this._orderTags.delete(i),!n.isDirty)this._revalidateRange(r)},{signal:s}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:s}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:s})}for(let i of this._buttons){let n=i.endpoint;if(n==="")continue;i.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:s}),i.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:s})}t.addEventListener("click",(i)=>{this._captureGridIntent(i)},{capture:!0,signal:s}),t.addEventListener("keydown",(i)=>this._captureGridIntent(i),{capture:!0,signal:s}),t.addEventListener("dateactivate",(i)=>{let n=i,r=n.detail?.date;if(!d(r))return;queueMicrotask(()=>{if(s.aborted||n.defaultPrevented||!this._range)return;let a=st.get(n);if(a===void 0||a.id!==this._activationId)return;let o=(c)=>this._boundEditable(c),l=this._range.activate(r,o);if(l.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._applyRangeTransition(l),l.close||l.status==="complete")this.hide(!1),this._focusField(l.endpoint)})},{signal:s}),t.addEventListener("datefocus",(i)=>this._onGridDateFocus(i),{signal:s}),t.addEventListener("pointerover",(i)=>this._onGridPointerOver(i),{signal:s}),t.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:s}),t.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this._bindPopup(s,this._fields?.[0]?.input,()=>this._restoreRangeDefault())}_activateRangeEndpoint(t){let e=this._calendar;if(!this._range||!e)return;this._range.focus(t),this._activationId++,this._lastFocusEndpoint=t;let s=this._boundCanonical(t)||O();e.display=p(s),e.focusedDate=s,this._clearPreview()}_onRangeTriggerClick(t,e){if(!this._open){this.show({endpoint:t});return}if(e.detail===0){this._activateRangeEndpoint(t),this._defer(()=>this._calendar?.focusGrid());return}if(t!==this._range?.activeEndpoint){this._activateRangeEndpoint(t);return}this.hide(!1)}_onTriggerKeyDown(t,e){if(e.key!=="ArrowDown")return;if(e.preventDefault(),this._open){if(this._rangeMode()&&t)this._activateRangeEndpoint(t);this._defer(()=>this._calendar?.focusGrid());return}if(this._rangeMode())this.show({endpoint:t||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(t,e){if(e.key==="ArrowDown"){if(e.preventDefault(),this._rangeMode()&&t)this._lastFocusEndpoint=t,this._range?.focus(t);if(this._open)this._defer(()=>this._calendar?.focusGrid());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._activationId++;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:!this._field)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._attachIntent(s)}_attachIntent(t){if(!this._calendar)return;this._calendar._hostIntent={date:t,intent:{id:++this._activationId}}}_supersedeActivations(){this._activationId++}_boundEditable(t){let e=this._fields?.[t==="end"?1:0];return e!=null&&P(e.input)}_applyRangeTransition(t){let e=this._fields;if(!e||!this._range||t.status==="refused")return;let s=[];for(let i of t.changedEndpoints){let n=e[i==="end"?1:0],r=i==="end"?t.range.end:t.range.start;if(!n||n.canonical===r)continue;n.setCanonical(r,{format:!0}),s.push(n)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(t.endpoint),!s.length)return;this._emitRangeChange();for(let i of s)i.input.dispatchEvent(new Event("input",{bubbles:!0})),i.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(t){let e=this._calendar;if(!e||!this._range||!this._open)return;let s=d(t)&&!e.getDateState(t).disabled?t:"",i=s?this._range.previewRange(s,(n)=>this._boundEditable(n)):null;if(!i){this._clearPreview();return}this._previewDate=s,e.toggleAttribute("data-range-preview",!0),e.highlightedRange=i}_clearPreview(){if(!this._previewDate)return;this._syncHighlight()}_onGridDateFocus(t){let e=t.detail?.date;if(d(e))this._setPreview(e)}_onGridPointerOver(t){let e=t;if(e.pointerType==="touch")return;this._setPreview(this._cellDate(e.target))}_onGridPointerLeave(){this._clearPreview()}_cellDate(t){let s=(t instanceof Element?t.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return d(s)?s:""}_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.monthFormat=this.monthFormat,t.controlClasses=this._controlClasses,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._generatedPlaceholders.has(i.input))i.input.placeholder=i.placeholder,this._generatedPlaceholders.add(i.input);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._generatedPlaceholders.has(e.input))e.input.placeholder=e.placeholder,this._generatedPlaceholders.add(e.input);if(this._value)e.input.value=e.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let t=this._buttons[0]?.button;if(!t)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let e=this._value?this.messages.changeDate:this.messages.chooseDate,s=this._value?`, ${lt(this._value,this.locale)}`:"";t.setAttribute("aria-label",`${e}${s}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:t,end:e}=this._range;for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?e:t,r=n?this.messages.changeDate:this.messages.chooseDate,a=n?`, ${lt(n,this.locale)}`:"",o=i==="end"?this.messages.rangeEnd:this.messages.rangeStart;s.setAttribute("aria-label",`${r}${a}, ${o}`)}}_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&&e.moveDisplay!==!1)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,e={}){let s=this._calendar;if(!s)return{ok:!0};if(e.moveDisplay!==!1){let r=p(t);if(s.display!==r)s.display=r}let i=await s.ensureDate(t),n=s.getDateState(t);if(!i||n.disabled)return{ok:!1,message:this.messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let s=this._field,i=this._session;if(!s||!i)return!1;if(!e.force&&!s.isDirty)return!1;let n=await s.commit(e);if(i.signal.aborted||!s.isCommitCurrent(n.commitId))return!1;if(n.status==="stale"||n.status==="invalid")return!1;return this._setValue(n.value||"",{emit:t,format:n.status==="ok",moveDisplay:e.moveDisplay}),!0}async _commitFieldText(t){let e=this._fields,s=this._session;if(!e||!s)return!1;let i=t==="end"?1:0,n=e[i];if(!n?.isDirty)return!1;let r=await n.commit();if(s.signal.aborted||!n.isCommitCurrent(r.commitId))return!1;if(r.status==="stale")return!1;if(r.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(t,r.value||"",{emit:!1,user:!0,format:r.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&&!P(r.input))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 l=o!==a;if(l){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),l}_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}))}_displayRange(){let{start:t,end:e}=this._range?.range??{start:"",end:""};if(!t)return{start:"",end:""};if(e&&_(e,t)<0)return{start:t,end:""};return{start:t,end:e}}_syncHighlight(){if(!this._calendar||!this._range)return;this._previewDate="",this._calendar.removeAttribute("data-range-preview"),this._calendar.highlightedRange=this._displayRange()}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:s}=this._range,i=Boolean(e&&s&&_(s,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(i&&r===t)o.setCustomValidity(l),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(t){let[e,s]=this._timeFields,i=["start","end"],n=[e,s],r=e&&!e.matches(":disabled")?e.value.trim():"",a=s&&!s.matches(":disabled")?s.value.trim():"",o=Boolean(e&&s&&r&&a)&&Lt(r)&&Lt(a)&&ue(a,r)<0;for(let[l,c]of i.entries()){let h=n[l];if(!h)continue;let y=c==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(o&&c===t)h.setCustomValidity(y),this._timeOrderOwned.add(h);else if(this._timeOrderOwned.has(h))h.setCustomValidity(""),this._timeOrderOwned.delete(h)}}_clearTimeOrderValidity(){for(let t of this._timeOrderOwned)t.setCustomValidity("");this._timeOrderOwned.clear()}_defer(t){let e=this._session;if(!e)return;setTimeout(G(e.signal,t),0)}_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=p(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=p(O()),this._calendar.focusedDate=O();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||O();this._calendar.display=p(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,this._defer(()=>{s.focus(),this._suppressFocusOpen=!1})}_restoreFocus(){let t=this._returnFocus;if(this._returnFocus=null,!(t instanceof HTMLElement)||!t.isConnected||t.matches(":disabled"))return;this._suppressFocusOpen=!0,this._defer(()=>{t.focus(),this._suppressFocusOpen=!1})}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(P(this._fields[e].input))return t;let s=t==="end"?"start":"end",i=s==="end"?1:0;if(P(this._fields[i].input))return s;return""}async validate(){let t=this._session;if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[n,r]of i.entries()){let a=await r.commit({moveDisplay:!1});if(!t||t.signal.aborted)return i.every((o)=>o.input.checkValidity());if(!r.isCommitCurrent(a.commitId))continue;if(a.status==="invalid")this._orderTags.delete(n);if(a.status==="ok"||a.status==="clear"){let o=n===1?"end":"start";this._setBound(o,a.value||"",{format:a.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((n)=>n.input.checkValidity())}let e=this._field?.input;if(!e){let i=this.hasAttribute("range")?this.querySelectorAll(":scope > input[data-range-start], :scope > input[data-range-end]"):this._input?[this._input]:[],n=this.querySelectorAll(":scope > input[type=time][data-time-start], :scope > input[type=time][data-time-end]");return[...i,...n].every((r)=>r instanceof HTMLInputElement&&r.checkValidity())}if(await this._commitText(!1,{force:!0,moveDisplay:!1}),!t||t.signal.aborted)return e.checkValidity()&&this._timeFields.every((i)=>i?.checkValidity()??!0);this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let s=this._timeFields.every((i)=>i?.checkValidity()??!0);return e.checkValidity()&&s}show(t={}){let e=this._panel,s=this._calendar;if(!e||!s||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=t.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||!P(r))return;let a=this._value||this._adapter().parse(r.value)||O();s.display=p(a),s.focusedDate=a,this._returnFocus=t.returnFocus instanceof HTMLElement?t.returnFocus:r}e.showPopover(),this._open=!0,this._setExpanded(!0);let i=this.coordinateSpace;e.style.position=i==="document"?"absolute":"fixed";let n=()=>le(this,e,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:i});if(n(),this._stopTracking=de(this,e,n),t.moveFocus!==!1){let r=this._session;if(r)queueMicrotask(G(r.signal,()=>s.focusGrid()))}this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(t){let e=t?"true":"false";this._input?.setAttribute("aria-expanded",e);for(let{button:s}of this._buttons)s.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._supersedeActivations(),this._syncHighlight(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._restoreFocus();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&&P(s.input))return t}return this._resolveRangeEndpoint()}}function zt(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",ut);if(!customElements.get("date-picker"))customElements.define("date-picker",Ot)}zt();var he="lekoala-date-picker-styles";if(!document.getElementById(he)){let t=document.createElement("style");t.id=he,t.textContent=Ht;let e=document.currentScript?.nonce;if(e)t.nonce=e;document.head.append(t)}zt();})();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CalendarModel } from "./calendar-model.js";
|
|
2
1
|
export type DateRange = {
|
|
3
2
|
start: string;
|
|
4
3
|
end: string;
|
|
@@ -34,45 +33,6 @@ export type DateDisabledPredicate = (date: string) => boolean;
|
|
|
34
33
|
/** @typedef {(date:string, state:DateState) => Node | string | null | undefined} DayRenderer */
|
|
35
34
|
/** @typedef {(date:string) => boolean} DateDisabledPredicate */
|
|
36
35
|
export declare class DateCalendarElement extends HTMLElement {
|
|
37
|
-
_id: string;
|
|
38
|
-
_model: CalendarModel;
|
|
39
|
-
_connected: boolean;
|
|
40
|
-
_rendering: boolean;
|
|
41
|
-
/** @type {DateSource | null} */
|
|
42
|
-
_source: DateSource | null;
|
|
43
|
-
/** Intent the host attached to the next activation of `date`.
|
|
44
|
-
* @type {{date: string, intent: unknown} | null} */
|
|
45
|
-
_hostIntent: {
|
|
46
|
-
date: string;
|
|
47
|
-
intent: unknown;
|
|
48
|
-
} | null;
|
|
49
|
-
_sourceStates: Map<any, any>;
|
|
50
|
-
_loadedRanges: Set<any>;
|
|
51
|
-
_loadController: AbortController | null;
|
|
52
|
-
_loadingKey: string;
|
|
53
|
-
/** @type {Promise<"loaded" | "cancelled" | "failed"> | null} */
|
|
54
|
-
_loadingPromise: Promise<"loaded" | "cancelled" | "failed"> | null;
|
|
55
|
-
/** @type {DateStateResolver | null} */
|
|
56
|
-
_dateState: DateStateResolver | null;
|
|
57
|
-
/** @type {DayRenderer | null} */
|
|
58
|
-
_renderDay: DayRenderer | null;
|
|
59
|
-
/** @type {DateDisabledPredicate | null} */
|
|
60
|
-
_isDateDisabled: DateDisabledPredicate | null;
|
|
61
|
-
/** @type {DateRange} */
|
|
62
|
-
_highlightedRange: DateRange;
|
|
63
|
-
/** @type {DateRange} */
|
|
64
|
-
_paintedRange: DateRange;
|
|
65
|
-
_paintedPreview: boolean;
|
|
66
|
-
/** @type {Map<string, DateState>} States of the current rendered grid. */
|
|
67
|
-
_renderedStates: Map<string, DateState>;
|
|
68
|
-
/** @type {typeof import("./messages.js").DEFAULT_MESSAGES | null} */
|
|
69
|
-
_messages: typeof import("./messages.js").DEFAULT_MESSAGES | null;
|
|
70
|
-
/** @type {Partial<import("./control-classes.js").ControlClasses> | null} */
|
|
71
|
-
_controlClasses: Partial<import("./control-classes.js").ControlClasses> | null;
|
|
72
|
-
/** @type {(() => void) | null} */
|
|
73
|
-
_stopDefaultMessages: (() => void) | null;
|
|
74
|
-
/** @type {(() => void) | null} */
|
|
75
|
-
_stopDefaultControlClasses: (() => void) | null;
|
|
76
36
|
static observedAttributes: string[];
|
|
77
37
|
/** @public @param {Partial<import("./control-classes.js").ControlClasses>} classes */
|
|
78
38
|
static setDefaultControlClasses(classes: Partial<import("./control-classes.js").ControlClasses>): void;
|
|
@@ -108,7 +68,8 @@ export declare class DateCalendarElement extends HTMLElement {
|
|
|
108
68
|
constructor();
|
|
109
69
|
connectedCallback(): void;
|
|
110
70
|
disconnectedCallback(): void;
|
|
111
|
-
|
|
71
|
+
/** @param {string} name @param {string|null} _oldValue @param {string|null} newValue */
|
|
72
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
112
73
|
/** @public */
|
|
113
74
|
get locale(): string;
|
|
114
75
|
set locale(value: string);
|
|
@@ -175,19 +136,6 @@ export declare class DateCalendarElement extends HTMLElement {
|
|
|
175
136
|
/** @public @returns {DateDisabledPredicate | null} */
|
|
176
137
|
get isDateDisabled(): DateDisabledPredicate | null;
|
|
177
138
|
set isDateDisabled(value: DateDisabledPredicate | null);
|
|
178
|
-
_syncModel(): void;
|
|
179
|
-
/** @param {string} name @param {string} value */
|
|
180
|
-
_reflect(name: string, value: string): void;
|
|
181
|
-
/** @param {string} value */
|
|
182
|
-
_clamp(value: string): string;
|
|
183
|
-
_weeks(display?: string): string[][];
|
|
184
|
-
/** @param {HTMLElement} element @returns {string} */
|
|
185
|
-
_focusTargetKey(element: HTMLElement): string;
|
|
186
|
-
/** @param {string} [display] */
|
|
187
|
-
_range(display?: string): {
|
|
188
|
-
start: string;
|
|
189
|
-
end: string;
|
|
190
|
-
};
|
|
191
139
|
/** @public @param {string} date @returns {DateState & {disabled: boolean}} */
|
|
192
140
|
getDateState(date: string): DateState & {
|
|
193
141
|
disabled: boolean;
|
|
@@ -197,13 +145,6 @@ export declare class DateCalendarElement extends HTMLElement {
|
|
|
197
145
|
/** @public Ensure source state exists for the month containing a typed/selected date.
|
|
198
146
|
* @param {string} date @returns {Promise<boolean>} */
|
|
199
147
|
ensureDate(date: string): Promise<boolean>;
|
|
200
|
-
/** @param {string} display @param {boolean} [rerender] @returns {Promise<"loaded" | "cancelled" | "failed">} */
|
|
201
|
-
_loadDisplay(display: string, rerender?: boolean): Promise<"loaded" | "cancelled" | "failed">;
|
|
202
|
-
/** @param {string} display @param {{emit?:boolean}} [options] */
|
|
203
|
-
_setDisplay(display: string, options?: {
|
|
204
|
-
emit?: boolean;
|
|
205
|
-
}): string;
|
|
206
|
-
_emitDisplayChange(): void;
|
|
207
148
|
/** @public */
|
|
208
149
|
previousMonth(): string;
|
|
209
150
|
/** @public */
|
|
@@ -212,28 +153,6 @@ export declare class DateCalendarElement extends HTMLElement {
|
|
|
212
153
|
focusDate(date: string, options?: {
|
|
213
154
|
moveFocus?: boolean;
|
|
214
155
|
}): void;
|
|
215
|
-
/** @param {string} previous @param {string} next @param {boolean} [moveFocus] */
|
|
216
|
-
_moveFocusDom(previous: string, next: string, moveFocus?: boolean): void;
|
|
217
|
-
/** Leave exactly one roving tab stop, on `date`'s cell when rendered.
|
|
218
|
-
* @param {string} date */
|
|
219
|
-
_syncRovingDom(date: string): void;
|
|
220
|
-
/** @param {string} previousValue @param {string} nextValue */
|
|
221
|
-
_moveSelectionDom(previousValue: string, nextValue: string): boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Accessible name of one day cell. The band contribution is dropped while a
|
|
224
|
-
* preview is projected onto `highlightedRange`: a proposal must not be
|
|
225
|
-
* announced as a committed range start/end.
|
|
226
|
-
* @param {string} date @param {DateState} state
|
|
227
|
-
* @param {"" | "start" | "in" | "end" | "single"} position
|
|
228
|
-
*/
|
|
229
|
-
_dayLabel(date: string, state: DateState, position: "" | "start" | "in" | "end" | "single"): string;
|
|
230
|
-
/**
|
|
231
|
-
* Repaint the range band over the cells already rendered. The band is
|
|
232
|
-
* presentation on top of the same grid, so it must never rebuild it: a full
|
|
233
|
-
* render would drop `renderDay()` nodes and fight the roving focus on every
|
|
234
|
-
* hover of a live range preview.
|
|
235
|
-
*/
|
|
236
|
-
_updateRangeDom(): void;
|
|
237
156
|
/** @public */
|
|
238
157
|
focusGrid(): void;
|
|
239
158
|
/**
|
|
@@ -245,21 +164,6 @@ export declare class DateCalendarElement extends HTMLElement {
|
|
|
245
164
|
* @param {string} date @returns {Promise<boolean>}
|
|
246
165
|
*/
|
|
247
166
|
activateDate(date: string): Promise<boolean>;
|
|
248
|
-
/** @param {MouseEvent} event */
|
|
249
|
-
_onClick(event: MouseEvent): void;
|
|
250
|
-
/** @param {Event} event */
|
|
251
|
-
_onChange(event: Event): void;
|
|
252
|
-
/**
|
|
253
|
-
* Real DOM focus is the single source of truth for `datefocus`: the model is
|
|
254
|
-
* synced here and the event is announced from here, so the temporary focus
|
|
255
|
-
* arithmetic in `_onKeyDown` cannot emit phantom events, and setting
|
|
256
|
-
* `focusedDate` without moving focus stays silent.
|
|
257
|
-
* @param {FocusEvent} event
|
|
258
|
-
*/
|
|
259
|
-
_onFocusIn(event: FocusEvent): void;
|
|
260
|
-
/** @param {KeyboardEvent} event */
|
|
261
|
-
_onKeyDown(event: KeyboardEvent): void;
|
|
262
167
|
/** @public @param {boolean} [load] */
|
|
263
168
|
render(load?: boolean): void;
|
|
264
169
|
}
|
|
265
|
-
//# sourceMappingURL=date-calendar.d.ts.map
|