@pglejzer/datepicker-ui 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./shared.cjs");function t(e){queueMicrotask(()=>{throw e})}var n=class{store={};on(e,t,n){let r=this.listenersOf(e),i={handler:t},a=()=>{r.delete(i),n?.removeEventListener(`abort`,a)};return n?.aborted||(r.add(i),n?.addEventListener(`abort`,a,{once:!0})),a}once(e,t){let n=this.on(e,e=>{n(),t(e)});return n}off(e,t){let n=this.store[e];if(n){if(!t)n.clear();else for(let e of n)e.handler===t&&n.delete(e)}}emit(e,n){let r=this.store[e];if(!r)return;let i=[];for(let e of[...r])if(r.has(e))try{e.handler(n)}catch(e){i.push(e)}i.length>0&&t(i[0])}listenerCount(e){return this.store[e]?.size??0}clear(){this.store={}}listenersOf(e){let t=this.store[e];if(t)return t;let n=/* @__PURE__ */ new Set;return this.store[e]=n,n}};function r(t){let n=[...t].sort(e.N);return n.filter((t,r)=>r===0||e.N(n[r-1],t)!==0)}function i(e){switch(e){case`single`:return{mode:e,date:null};case`range`:return{mode:e,start:null,end:null};default:return{mode:e,dates:[]}}}function a(e){switch(e.mode){case`single`:return e.date?[e.date]:[];case`range`:return[e.start,e.end].filter(e=>e!==null);default:return e.dates}}function o(e){return a(e).length===0}function s(e){return e.mode!==`range`||e.start===null==(e.end===null)}function c(t,n){return t===null||n===null?t===n:e.N(t,n)===0}function l(t,n){if(t.mode!==n.mode)return!1;let r=a(t),i=a(n);return r.length===i.length?t.mode===`range`&&n.mode===`range`?c(t.start,n.start)&&c(t.end,n.end):r.every((t,n)=>e.N(t,i[n])===0):!1}function u(t,n){return a(t).some(t=>e.z(t,n))}function d(t,n){return t.mode!==`range`||t.start===null||t.end===null||e.N(t.start,t.end)>=0?null:e.z(t.start,n)?`start`:e.z(t.end,n)?`end`:e.N(n,t.start)>0&&e.N(n,t.end)<0?`in-range`:null}function f(e){return a(e).at(0)??null}function p(e,t){let n={};if((e.calendar||t.calendar)&&(n.calendar={...e.calendar,...t.calendar}),e.ui||t.ui){let r={...e.ui,...t.ui};(e.ui?.inline||t.ui?.inline)&&(r.inline={...e.ui?.inline,...t.ui?.inline}),(e.ui?.yearRange||t.ui?.yearRange)&&(r.yearRange={...e.ui?.yearRange,...t.ui?.yearRange}),n.ui=r}return(e.labels||t.labels)&&(n.labels={...e.labels,...t.labels}),(e.behavior||t.behavior)&&(n.behavior={...e.behavior,...t.behavior}),(e.callbacks||t.callbacks)&&(n.callbacks={...e.callbacks,...t.callbacks}),n}const m=new Set(`AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN IS JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW`.split(` `)),h=new Set(`AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY`.split(` `)),g=/* @__PURE__ */ new Set([`MV`]),_=/* @__PURE__ */ new Map,v=/* @__PURE__ */ new Map;function y(e,t){let n=v.get(t);if(n)return n.format(e);let r=new Intl.NumberFormat(t,{useGrouping:!1});return v.set(t,r),r.format(e)}function b(e,t){let n=`${e}|${JSON.stringify(t)}`,r=_.get(n);if(r)return r;let i=new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`});return _.set(n,i),i}function x(e,t,n){let r=new Date(Date.UTC(2e3,0,1,12));return r.setUTCFullYear(e,t-1,n),r}function S(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 5:return 5;case 6:return 6;default:return null}}function C(e){if(!(`getWeekInfo`in e))return null;let t=Reflect.get(e,`getWeekInfo`);if(typeof t!=`function`)return null;let n=Reflect.apply(t,e,[]);if(typeof n!=`object`||!n||!(`firstDay`in n))return null;let r=n.firstDay;return typeof r==`number`?S(r===7?0:r):null}function w(e){return e===void 0?1:m.has(e)?0:h.has(e)?6:g.has(e)?5:1}function T(e){try{let t=new Intl.Locale(e),n=C(t);return n===null?w(t.maximize().region):n}catch{return 1}}function E(e){try{return Intl.getCanonicalLocales(e).length>0}catch{return!1}}const D=e=>{let t=e?.trim();return!t||!E(t)?null:t};function ee(t){let n=D(t);if(n!==null)return n;if(e.v()){let e=D(document.documentElement.lang);if(e!==null)return e}if(typeof navigator<`u`){let e=D(navigator.language);if(e!==null)return e}return`en-US`}function O(e,t){let n=b(e,{month:t});return Array.from({length:12},(e,t)=>n.format(x(2024,t+1,1)))}function te(e,t){let n=b(e,{weekday:t});return Array.from({length:7},(e,t)=>n.format(x(2024,1,7+t)))}function ne(e,t){return b(t,{weekday:`short`,month:`short`,day:`numeric`}).format(x(e.year,e.month,e.day))}function re(e,t){return b(t,{month:`short`,day:`numeric`}).format(x(e.year,e.month,e.day))}function ie(e,t,n){return b(n,{month:`short`,day:`numeric`}).formatRange(x(e.year,e.month,e.day),x(t.year,t.month,t.day))}function ae(e,t){return b(t,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`}).format(x(e.year,e.month,e.day))}function k(e,t){return b(t,{month:`long`,year:`numeric`}).format(x(e.year,e.month,1))}function oe(e,t,n){return e.year===t.year&&e.month===t.month?k(e,n):b(n,{month:`long`,year:`numeric`}).formatRange(x(e.year,e.month,1),x(t.year,t.month,1))}function se(e,t,n,r){switch(t){case`day`:return r===`headline`?ne(e,n):ae(e,n);case`month`:return k(e,n);default:return y(e.year,n)}}function ce(e,t){switch(t){case`sunday`:return 0;case`monday`:return 1;case`saturday`:return 6;default:return T(e)}}const A={title:`Select date`,monthTitle:`Select month`,yearTitle:`Select year`,noDate:`No date selected`,confirm:`OK`,cancel:`Cancel`,today:`Today`,clear:`Clear`,openCalendar:`Choose date`,previousMonth:`Previous month`,nextMonth:`Next month`,previousYear:`Previous year`,nextYear:`Next year`,chooseMonth:`Choose month`,chooseYear:`Choose year`,weekNumber:`Week`,invalidDate:`Enter a valid date`,unavailableDate:`This date is not available`,rangeTitle:`Select dates`,rangeStart:`Start`,rangeEnd:`End`,multipleSelected:`{count} selected`,save:`Save`,close:`Close`,switchToInput:`Switch to text input`,switchToCalendar:`Switch to calendar`,dateField:`Date`,startDateField:`Start date`,endDateField:`End date`,invalidRange:`End date must be on or after the start date`,beforeMinDate:`Enter a date on or after {date}`,afterMaxDate:`Enter a date on or before {date}`,presets:`Presets`,pageUpKey:`Page Up`,pageDownKey:`Page Down`,shiftKey:`Shift`,hintDay:`dd`,hintMonth:`mm`,hintYear:`yyyy`},j={calendar:{weekStart:`auto`,mode:`single`,precision:`day`,months:1,pageBy:`view`,presets:[]},ui:{displayMode:`auto`,inline:{enabled:!1},format:`auto`,theme:`basic`,colorScheme:`auto`,weekNumbers:!1,outsideDays:!1,fixedWeeks:!1,yearRange:{before:100,after:20},todayButton:!1,clearButton:!1,animation:!0,allowPageScroll:!1,fullscreen:!0,cssClass:``,swipe:!0,viewSwitch:!0,initialView:`calendar`,mask:!1,startView:`day`},labels:A,behavior:{closeOnSelect:!1,closeOnCancel:!0,commitOnChange:!1,ignoreOutsideClick:!1,returnFocus:!0}};function le(e,t){return e instanceof Date?e:typeof e!=`string`||e===`today`&&!t?null:e}function ue(t,n,r,i){if(t===void 0)return null;let a=le(t,n),o=a===null?null:e.W(a);return o===null&&i.push({option:r,value:t}),o}function de(e,t,n){return e===void 0?null:Array.isArray(e)?e.map(e=>ue(e,!1,t,n)).filter(e=>e!==null):(n.push({option:t,value:e}),null)}function M(e,t,n,r,i){if(e===void 0)return n;let a=t(e);return a===void 0?(i.push({option:r,value:e}),n):a}const N=e=>typeof e==`boolean`?e:void 0,fe=e=>typeof e==`string`?e:void 0,pe=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,P=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1?e:void 0,me=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},he=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},ge=e=>{if(typeof e==`string`)return e;if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Object.entries(e),n={};for(let[e,r]of t){if(typeof r!=`string`)return;n[e]=r}return t.length>0?n:void 0},_e=e=>typeof HTMLElement<`u`&&e instanceof HTMLElement||typeof e==`string`&&e.length>0?e:void 0;function F(e){return t=>e.find(e=>e===t)}function ve(t){return n=>typeof n==`string`&&e.C(n,t)?n:void 0}const ye=F([`auto`,`docked`,`modal`]),be=F([`auto`,`light`,`dark`]),xe=F([`auto`,`sunday`,`monday`,`saturday`]),Se=F([`single`,`range`,`multiple`]),Ce=F([`calendar`,`input`]),we=F([`day`,`month`,`year`]),Te=F([`month`,`view`]),Ee=F([`day`,`month`,`year`]),De=F([`basic`,`m3-green`,`crane`,`crane-straight`,`m2`,`glassmorphic`,`pastel`,`ai`,`cyberpunk`,`blueprint`]);function Oe(e){return e in A}function ke(e,t){let n={...A};for(let r of Object.keys(A))Oe(r)&&r!==`multipleSelected`&&(n[r]=M(e?.[r],fe,A[r],`labels.${r}`,t));return n.multipleSelected=M(e?.multipleSelected,ge,A.multipleSelected,`labels.multipleSelected`,t),n}function Ae(e,t){return e===void 0||e===!0?600:e===!1?0:M(e,P,600,`ui.fullscreen`,t)}function je(e,t){return e===void 0||e===!1?!1:e===!0?{selectable:!0}:typeof e==`object`&&e?{selectable:M(Reflect.get(e,`selectable`),N,!0,`ui.outsideDays.selectable`,t)}:(t.push({option:`ui.outsideDays`,value:e}),!1)}function Me(e,t){return e===void 0||e===!1?!1:e===!0?{clearInput:!0}:typeof e==`object`&&e?{clearInput:M(Reflect.get(e,`clearInput`),N,!0,`ui.clearButton.clearInput`,t)}:(t.push({option:`ui.clearButton`,value:e}),!1)}const Ne=`calendar.range.presets`;function Pe(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`label`),n=Reflect.get(e,`value`);return typeof t!=`string`||t===``?null:typeof n==`function`?{label:t,value:()=>Reflect.apply(n,void 0,[])}:typeof n==`object`&&n?{label:t,value:()=>n}:null}function Fe(e,t){if(e===void 0)return j.calendar.presets;if(!Array.isArray(e))return t.push({option:Ne,value:e}),j.calendar.presets;let n=e,r=[];for(let e of n){let n=Pe(e);n===null?t.push({option:Ne,value:e}):r.push(n)}return r}function Ie(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6}function Le(e,t){let n=e?.trim();n&&!E(n)&&t.push({option:`calendar.locale`,value:e})}function Re(e,t){if(e===void 0)return[];if(!Array.isArray(e))return t.push({option:`calendar.disabledWeekdays`,value:e}),[];let n=e,r=[];for(let e of n)Ie(e)?r.includes(e)||r.push(e):t.push({option:`calendar.disabledWeekdays`,value:e});return r}function ze(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`className`),n=Reflect.get(e,`badge`),r=Reflect.get(e,`label`);return{...typeof t==`string`?{className:t}:{},...typeof n==`boolean`?{badge:n}:{},...typeof r==`string`?{label:r}:{}}}function Be(e){return typeof e==`string`||typeof Node<`u`&&e instanceof Node?e:null}function Ve(e){return e===null?null:n=>{try{return Be(e(n))}catch(e){return t(e),null}}}function He(e){return e===null?null:n=>{try{let t=e(n);return typeof t!=`string`||t.length===0?null:t}catch(e){return t(e),null}}}function Ue(e,t,n){let r=j.calendar,i=M(e,we,r.precision,`calendar.precision`,n);return i!==`day`&&t!==`single`?(n.push({option:`calendar.precision`,value:e}),r.precision):i}function We(e,t){let n=M(e?.range?.minLength,P,null,`calendar.range.minLength`,t),r=M(e?.range?.maxLength,P,null,`calendar.range.maxLength`,t),i=M(e?.multiple?.max,P,null,`calendar.multiple.max`,t);return n!==null&&r!==null&&n>r?(t.push({option:`calendar.range`,value:e?.range}),{minLength:n,maxLength:null,multipleMax:i}):{minLength:n,maxLength:r,multipleMax:i}}function Ge(e,t){let n=j.calendar;Le(e?.locale,t);let r=ee(e?.locale),i=M(e?.weekStart,xe,n.weekStart,`calendar.weekStart`,t),a=M(e?.isDateDisabled,me,null,`calendar.isDateDisabled`,t),o=M(e?.decorateDate,me,null,`calendar.decorateDate`,t),s=M(e?.renderDate,me,null,`calendar.renderDate`,t),c=M(e?.validate,he,null,`calendar.validate`,t),l=M(e?.mode,Se,n.mode,`calendar.mode`,t);return{locale:r,weekStart:ce(r,i),minDate:ue(e?.minDate,!0,`calendar.minDate`,t),maxDate:ue(e?.maxDate,!0,`calendar.maxDate`,t),disabledDates:de(e?.disabledDates,`calendar.disabledDates`,t)??[],enabledDates:de(e?.enabledDates,`calendar.enabledDates`,t),mode:l,precision:Ue(e?.precision,l,t),months:M(e?.months,P,n.months,`calendar.months`,t),pageBy:M(e?.pageBy,Te,n.pageBy,`calendar.pageBy`,t),limits:We(e,t),presets:Fe(e?.range?.presets,t),isDateDisabled:a===null?null:e=>!!a(e),disabledWeekdays:Re(e?.disabledWeekdays,t),decorateDate:o===null?null:e=>ze(o(e)),renderDate:Ve(s),validate:He(c)}}function Ke(t){let n=[],r=j,i=t?.calendar,a=t?.ui,o=t?.behavior,s=(e,t,r,i)=>M(e,t,r,i,n),c=Ge(i,n),{locale:l,precision:u}=c,d=s(a?.format,ve(u),r.ui.format,`ui.format`),f=s(a?.footer,N,!1,`ui.footer`),p=o?.id;return{...c,displayMode:s(a?.displayMode,ye,r.ui.displayMode,`ui.displayMode`),inline:{enabled:s(a?.inline?.enabled,N,r.ui.inline.enabled,`ui.inline.enabled`),container:s(a?.inline?.container,_e,null,`ui.inline.container`)},pattern:e.w(d,l,u),theme:s(a?.theme,De,r.ui.theme,`ui.theme`),colorScheme:s(a?.colorScheme,be,r.ui.colorScheme,`ui.colorScheme`),toggleButton:s(a?.toggleButton,_e,null,`ui.toggleButton`),endInput:s(a?.endInput,_e,null,`ui.endInput`),weekNumbers:s(a?.weekNumbers,N,r.ui.weekNumbers,`ui.weekNumbers`),outsideDays:je(a?.outsideDays,n),fixedWeeks:s(a?.fixedWeeks,N,r.ui.fixedWeeks,`ui.fixedWeeks`),yearRange:{before:s(a?.yearRange?.before,pe,r.ui.yearRange.before,`ui.yearRange.before`),after:s(a?.yearRange?.after,pe,r.ui.yearRange.after,`ui.yearRange.after`)},todayButton:s(a?.todayButton,N,r.ui.todayButton,`ui.todayButton`),clearButton:Me(a?.clearButton,n),footerExplicit:typeof a?.footer==`boolean`?f:null,animation:s(a?.animation,N,r.ui.animation,`ui.animation`),allowPageScroll:s(a?.allowPageScroll,N,r.ui.allowPageScroll,`ui.allowPageScroll`),fullscreenBelow:Ae(a?.fullscreen,n),cssClass:s(a?.cssClass,fe,r.ui.cssClass,`ui.cssClass`),appendTo:s(a?.appendTo,_e,null,`ui.appendTo`),swipe:s(a?.swipe,N,r.ui.swipe,`ui.swipe`),viewSwitch:s(a?.viewSwitch,N,r.ui.viewSwitch,`ui.viewSwitch`),initialView:s(a?.initialView,Ce,r.ui.initialView,`ui.initialView`),mask:s(a?.mask,N,r.ui.mask,`ui.mask`),startView:s(a?.startView,Ee,r.ui.startView,`ui.startView`),labels:ke(t?.labels,n),behavior:{closeOnSelect:s(o?.closeOnSelect,N,r.behavior.closeOnSelect,`behavior.closeOnSelect`),closeOnCancel:s(o?.closeOnCancel,N,r.behavior.closeOnCancel,`behavior.closeOnCancel`),commitOnChange:s(o?.commitOnChange,N,r.behavior.commitOnChange,`behavior.commitOnChange`),ignoreOutsideClick:s(o?.ignoreOutsideClick,N,r.behavior.ignoreOutsideClick,`behavior.ignoreOutsideClick`),returnFocus:s(o?.returnFocus,N,r.behavior.returnFocus,`behavior.returnFocus`),id:typeof p==`string`&&p.length>0?p:null},callbacks:{...t?.callbacks},issues:n}}const qe=/[^\w-]/g;let Je=0;function Ye(e){return e.replace(qe,`-`)}function Xe(e){return{year:e.year,month:e.month}}var Ze=class{input;host;createdHost;instanceId;events=new n;raw;resolved;currentValue;currentDraft;currentView;currentFocus;currentPanel;currentMode=null;currentLayout={months:1,presets:`none`};currentActiveEnd=`start`;currentEndInput=null;activeEndControlled=!1;constructor(t,n,r,a){this.input=t,this.host=n,this.createdHost=r,this.raw=p({},a??{}),this.resolved=Ke(this.raw),Je+=1;let o=this.resolved.behavior.id;this.instanceId=o===null?`${e.K}${String(Je)}`:Ye(o),this.currentPanel=e.T(this.resolved.precision),this.currentValue=i(this.resolved.mode),this.currentDraft=this.currentValue;let s=e.G();this.currentFocus=s,this.currentView=Xe(s)}get options(){return this.resolved}get rawOptions(){return this.raw}setOptions(e){this.raw=p(this.raw,e),this.resolved=Ke(this.raw),this.events.emit(`change:options`,{})}get value(){return this.currentValue}setValue(e){this.currentValue=e,this.events.emit(`change:value`,{value:e})}get draft(){return this.currentDraft}setDraft(e){this.currentDraft=e,this.events.emit(`change:draft`,{draft:e})}get view(){return this.currentView}setView(e,t,n){let r=Xe(e);this.currentView=r,this.events.emit(`change:view`,{view:r,delta:t,source:n})}get focus(){return this.currentFocus}setFocus(e){this.currentFocus=e,this.events.emit(`change:focus`,{focus:e})}get panel(){return this.currentPanel}setPanel(e){e!==this.currentPanel&&(this.currentPanel=e,this.events.emit(`change:panel`,{panel:e}))}get mode(){return this.currentMode}setMode(e){this.currentMode=e}get layout(){return this.currentLayout}setLayout(e){this.currentLayout=e}get activeEnd(){return this.currentActiveEnd}setActiveEnd(e){e!==this.currentActiveEnd&&(this.currentActiveEnd=e,this.events.emit(`change:active-end`,{end:e}))}controlActiveEnd(){this.activeEndControlled=!0}get followsActiveEnd(){return this.currentEndInput!==null||this.activeEndControlled}get endInput(){return this.currentEndInput}setEndInput(e){this.currentEndInput=e}resetSession(){let t=f(this.currentValue)??e.G(),n=Xe(t);this.setPanel(e.T(this.resolved.precision)),this.setDraft(this.currentValue),this.setView(n,e.V(this.currentView,n),`api`),this.setFocus(t)}};const I=`dp-ui`,Qe=[`class`,`name`,`aria-invalid`,`aria-describedby`];function $e(e){return typeof e==`string`?document.querySelector(e):e}function et(e){return e instanceof HTMLInputElement?e:e?.querySelector(`input`)??null}function tt(e){let t=document.createElement(`div`);return t.className=I,e.before(t),t.append(e),t}function nt(t){if(!e.v())throw Error(`DatepickerUI needs a document`);let n=$e(t),r=et(n);if(r===null)throw Error(`DatepickerUI could not find an input element`);let i=r.parentElement;return i!==null&&(n!==r||i.classList.contains(I))?{input:r,host:i,createdHost:!1}:{input:r,host:tt(r),createdHost:!0}}function rt(e){let{input:t,host:n,createdHost:r}=e,i=/* @__PURE__ */ new Map;for(let e of Qe)i.set(e,t.getAttribute(e));let a=n.classList.contains(I);return n.classList.add(I),{target:{input:t,host:n,createdHost:r},hostHadClass:a,inputAttributes:i}}function it(e){let{input:t,host:n,createdHost:r}=e.target;for(let[n,r]of e.inputAttributes)r===null?t.removeAttribute(n):t.setAttribute(n,r);r?t.parentNode===n?n.replaceWith(t):n.remove():e.hostHadClass||n.classList.remove(I)}function at(t,n,r,i){let a=e.V(t,n);return a>=0&&a<r?t:i===`month`?a<0?n:e.M(n,-(r-1)):e.M(t,Math.floor(a/r)*r)}function ot(t,n,r){let i={year:n.year,month:n.month,day:Math.min(r,e.L(n))},{minDate:a,maxDate:o}=t.core.options;return a!==null&&e.N(i,a)<0?a:o!==null&&e.N(i,o)>0?o:i}function st(t,n,r){let{core:i,managers:a}=t,o=a.validation.clampView(n),s=e.V(i.view,o);return s!==0&&(i.setView(o,s,r),i.setFocus(ot(t,o,i.focus.day))),o}function L(t,n,r){let{core:i,managers:a}=t,o={year:n.year,month:n.month},{months:s}=i.layout,c=a.validation.clampView(at(i.view,o,s,i.options.pageBy)),l=e.V(c,o);if(l<0||l>=s)return;let u=e.V(i.view,c);u!==0&&i.setView(c,u,r),i.setFocus(n)}const ct=/^(\d{4})-(\d{2})$/,lt=/^\d{4}$/;function ut(e,t){switch(t){case`day`:return e;case`month`:return{year:e.year,month:e.month,day:1};default:return{year:e.year,month:1,day:1}}}function R(t,n){let r=e.U(t);switch(n){case`day`:return r;case`month`:return r.slice(0,7);default:return r.slice(0,4)}}function dt(t,n){let r=e.R(t);if(r!==null||n===`day`)return r===null?null:ut(r,n);if(n===`month`){let n=ct.exec(t);return n?e.P(Number(n[1]),Number(n[2]),1):null}return lt.test(t)?e.P(Number(t),1,1):null}function ft(e,t){return{...e,order:e.order.filter(e=>e===`year`||t===`month`&&e===`month`)}}function z(t,n,r){return r===`day`?e.b(t,n):e.b(t,ft(n,r))}function pt(t,n,r){return n===`day`?e.x(t,r):e.x(ft(t,n),r)}function mt(t,n,r){if(r===`day`)return e._(t,n);let{order:i}=ft(n,r),a=e.h(t);if(a?.length!==i.length)return null;let o=1,s=null;for(let[t,n]of i.entries()){let r=a[t]??``;if(n===`year`)s=e.g(r);else if(r.length>2)return null;else o=Number(r)}return s===null?null:e.P(s,o,1)}function ht(t,n,r){let i=e.I(t,n)+1;return r.minLength!==null&&i<r.minLength?!1:r.maxLength===null||i<=r.maxLength}function gt(t,n,r,i){let a=i;if(n.maxLength!==null){let r=e.j(t,n.maxLength-1);a=e.N(r,i)<0?r:i}for(let n=e.j(t,1);e.N(n,a)<=0;n=e.j(n,1))if(r(n))return n;return null}function _t(t,n,r,i){if(t.mode===`multiple`){let{multipleMax:e}=n,{dates:r}=t;return n=>e!==null&&r.length>=e&&!u(t,n)}if(t.mode!==`range`||t.start===null||t.end!==null)return()=>!1;let{start:a}=t,o=null,s=!1;return t=>e.N(t,a)<0?!1:e.N(t,i)>0||!ht(a,t,n)||(s||=(o=gt(a,n,r,i),!0),o!==null&&e.N(t,o)>=0)}function vt(t,n,r,i){if(!ht(t,n,r))return`range-length`;for(let r=t;e.N(r,n)<=0;r=e.j(r,1)){let e=i(r);if(e!==null)return e}return null}function yt(e,t){for(let n of e){let e=t(n);if(e!==null)return e}return null}function B(e,t,n){switch(e.mode){case`single`:return e.date===null?null:n(e.date);case`range`:return e.start!==null&&e.end!==null?vt(e.start,e.end,t,n):e.start===null?null:n(e.start);default:return t.multipleMax!==null&&e.dates.length>t.multipleMax?`multiple-max`:yt(e.dates,n)}}function bt(e,t,n){return B(e,t,e=>n(e)?`disabled`:null)===null}function xt(t,n,i){return t.some(t=>e.N(t,n)===0)?t.filter(t=>e.N(t,n)!==0):i.multipleMax!==null&&t.length>=i.multipleMax?null:r([...t,n])}function St(e){return e.mode===`range`&&e.start!==null&&e.end===null?`end`:`start`}function Ct(e,t){return e.mode===`range`?t===`start`?{mode:`range`,start:null,end:null}:{mode:`range`,start:e.start,end:null}:e}function wt(t,n,r,i){switch(t.mode){case`single`:return{mode:`single`,date:n};case`range`:return i===`start`||t.start===null||e.N(n,t.start)<0?{mode:`range`,start:n,end:null}:{mode:`range`,start:t.start,end:n};default:{let e=xt(t.dates,n,r);return e===null?t:{mode:`multiple`,dates:e}}}}var Tt=class{context;session;values;constructor(e,t,n){this.context=e,this.session=t,this.values=n}isOpen(){return this.session.active}select(e){let{core:t,managers:n}=this.context,r=ut(e,t.options.precision),i=t.followsActiveEnd?t.activeEnd:St(t.draft);if(!this.session.active||!n.validation.isSelectable(r,Ct(t.draft,i)))return;L(this.context,r,`button`);let a=wt(t.draft,r,t.options.limits,i);t.setDraft(a),t.setActiveEnd(St(a)),this.announce(a,r),this.isOpen()&&this.autoCommit(a)}selectRange(e,t){let{core:n,managers:r}=this.context,{mode:i,limits:a}=n.options;if(!this.session.active||i!==`range`)return;let o={mode:`range`,start:e,end:t};B(o,a,e=>r.validation.unavailableReason(e))===null&&(n.setDraft(o),n.setActiveEnd(`start`),L(this.context,e,`api`),this.emitRangeEnd(e,t),this.isOpen()&&this.autoCommit(o))}typeDraft(e){let{core:t,managers:n}=this.context,{mode:r,limits:i}=t.options,a=e.mode===r&&bt(e,i,e=>n.validation.isDisabled(e));if(!this.session.active||!a)return;t.setDraft(e);let o=f(e);o!==null&&L(this.context,o,`api`)}announce(e,t){let{emitter:n}=this.context,{describe:r}=this.values;n.emit(`select:day`,{value:r(t),selected:u(e,t)}),e.mode===`range`&&(e.start===null||e.end===null?n.emit(`range:start`,{value:r(t)}):this.emitRangeEnd(e.start,e.end))}emitRangeEnd(e,t){let{describe:n}=this.values;this.context.emitter.emit(`range:end`,{start:n(e),end:n(t)})}autoCommit(e){if(e.mode===`range`&&e.end===null)return;let{closeOnSelect:t,commitOnChange:n}=this.context.core.options.behavior,r=t&&e.mode!==`multiple`;(r||n)&&this.values.commit(!0),r&&this.session.close()}},Et=class{context;session;values;selector;constructor(e,t,n){this.context=e,this.session=t,this.values=n,this.selector=new Tt(e,t,n)}isOpen(){return this.session.active}select(e){this.selector.select(e)}selectRange(e,t){this.selector.selectRange(e,t)}typeDraft(e){this.selector.typeDraft(e)}focusDate(e){this.session.active&&L(this.context,e,`keyboard`)}navigate(t,n){this.session.active&&st(this.context,e.M(this.context.core.view,t),n)}page(e,t){let{core:n}=this.context,r=n.options.pageBy===`view`?n.layout.months:1;this.navigate(e*r,t)}jumpTo(t,n){if(!this.session.active)return;let{core:r}=this.context,i=r.panel,a=st(this.context,t,n);n===`menu`&&(r.setPanel(e.T(r.options.precision)),this.announcePick(i,a))}showPanel(e){this.session.active&&this.context.core.setPanel(e)}confirm(){this.session.active&&s(this.context.core.draft)&&(this.values.commit(!1),this.session.close())}cancel(e){if(!this.session.active)return;let{core:t,emitter:n}=this.context;n.emit(`cancel`,{reason:e}),this.isOpen()&&((t.options.behavior.closeOnCancel||e!==`button`)&&t.mode!==`inline`?this.session.close():t.setDraft(t.value))}today(){if(!this.session.active)return;let{core:t,managers:n}=this.context,r=e.G();n.validation.isSelectable(r,t.draft)?this.select(r):L(this.context,r,`button`)}clear(){if(!this.session.active)return;let{core:e}=this.context;e.setDraft(i(e.options.mode));let{clearButton:t}=e.options;t!==!1&&t.clearInput&&(this.values.commit(!1),this.session.close())}announcePick(e,t){let{emitter:n}=this.context;e===`month-menu`||e===`month-grid`?n.emit(`select:month`,{year:t.year,month:t.month}):(e===`year-menu`||e===`year-grid`)&&n.emit(`select:year`,{year:t.year})}},Dt=class{context;subscriptions=[];constructor(e){this.context=e}bind(){for(let e of this.subscriptions)e();this.subscriptions=[];let{callbacks:e}=this.context.core.options;this.add(`open`,e.onOpen),this.add(`close`,e.onClose),this.add(`cancel`,e.onCancel),this.add(`confirm`,e.onConfirm),this.add(`update`,e.onUpdate),this.add(`error`,e.onError),this.add(`select:day`,e.onSelectDay),this.add(`select:month`,e.onSelectMonth),this.add(`select:year`,e.onSelectYear),this.add(`range:start`,e.onRangeStart),this.add(`range:end`,e.onRangeEnd),this.add(`navigate`,e.onNavigate)}add(e,t){t!==void 0&&this.subscriptions.push(this.context.emitter.on(e,t))}};const Ot=[`class`,`name`,`aria-invalid`];function kt(t){let{core:n,emitter:r}=t,{endInput:i,mode:a}=n.options;if(a!==`range`||i===null)return null;let o=e.p(i,n.host);return o instanceof HTMLInputElement&&o!==n.input?o:(r.emit(`error`,{code:`invalid-option`,message:`ui.endInput does not match an input element`,option:`ui.endInput`}),null)}function At(e){let t=/* @__PURE__ */ new Map;for(let n of Ot)t.set(n,e.getAttribute(n));return()=>{for(let[n,r]of t)r===null?e.removeAttribute(n):e.setAttribute(n,r)}}const jt=[`calendar`,`ui`,`labels`,`behavior`,`callbacks`];function Mt(e){let t=[];for(let n of jt){let r=e[n];if(r!==void 0)for(let e of Object.keys(r))t.push(`${n}.${e}`)}return t}function Nt(e,t){return e.some(e=>t.option===e||t.option.startsWith(`${e}.`))}function Pt(e,t){for(let n of t)e.emitter.emit(`error`,{code:`invalid-option`,message:`Invalid value for option ${n.option}`,option:n.option})}var Ft=class{context;session;callbacks;triggers;constructor(e,t,n,r){this.context=e,this.session=t,this.callbacks=n,this.triggers=r}apply(e){let{core:t,emitter:n,status:r}=this.context;if(r.destroyed)return;let i=t.options;t.setOptions(e),t.options.mode!==i.mode&&this.resetSelection(),r.created&&this.reapply(i,e),n.emit(`update`,{options:e})}resetSelection(){let{core:e,managers:t,status:n}=this.context,r=i(e.options.mode);e.setValue(r),e.setDraft(r),n.created&&(t.input.write(r),t.form.sync())}reapply(e,t){let{core:n,managers:r}=this.context;this.callbacks.bind(),r.theme.applyHost(),this.triggers.bind(),o(n.value)||r.input.write(n.value),r.triggers.updateLabel(),this.refreshSurface(e);let i=Mt(t);Pt(this.context,n.options.issues.filter(e=>Nt(i,e)))}refreshSurface(e){let{core:t,managers:n}=this.context,r=t.options;if(r.inline.enabled!==e.inline.enabled||r.inline.enabled&&r.inline.container!==e.inline.container){this.session.end(),r.inline.enabled&&this.session.mountInline();return}let i=t.mode;if(!this.session.active||i===null)return;let a=i===`inline`||r.displayMode===e.displayMode?i:this.session.pickMode();this.session.syncLayout(a),this.session.clampView(),a===i&&r.mode===e.mode?n.display.update():this.session.remount(a)}},It=class{context;session;callbacks;triggers;controller=new AbortController;hostSnapshot;restoreEndInput=null;constructor(e,t,n,r){this.context=e,this.session=t,this.callbacks=n,this.triggers=r,this.hostSnapshot=rt(e.core)}create(){let{core:e,managers:t,status:n}=this.context;if(n.created||n.destroyed)return;n.created=!0;let r=this.controller.signal;this.callbacks.bind(),t.theme.applyHost();let i=kt(this.context);e.setEndInput(i),i!==null&&(this.restoreEndInput=At(i));let a=o(e.value)?t.input.readInitial():e.value;e.setValue(a),o(a)||t.input.write(a),t.form.bind(r),t.form.sync(),t.input.bind(r),this.triggers.bind(),t.triggers.updateLabel(),e.events.on(`change:value`,()=>{t.triggers.updateLabel()},r),e.options.inline.enabled&&this.session.mountInline(),Pt(this.context,e.options.issues)}destroy(e){let{core:t,emitter:n,managers:r,status:i}=this.context;i.destroyed||(i.destroyed=!0,this.session.teardown(),this.triggers.release(),this.controller.abort(),r.destroy(),e||(t.input.value=``,t.endInput!==null&&(t.endInput.value=``)),this.restoreEndInput?.(),this.restoreEndInput=null,t.setEndInput(null),it(this.hostSnapshot),t.events.clear(),n.clear())}},Lt=class{tail=Promise.resolve();pending=0;stopped=!1;run(e){let n=async()=>{this.stopped||await e()},r=this.pending===0?n():this.tail.then(n);this.pending+=1;let i=r.catch(t).finally(()=>{--this.pending});return this.tail=i,i}stop(){this.stopped=!0}};function Rt(e){return e<0?-1:+(e>0)}var zt=class{context;queue=new Lt;controller=null;phase=`closed`;sessionId=0;closing=Promise.resolve();openedFrom=`start`;constructor(e){this.context=e}get active(){return this.phase===`open`}open(e,t=`start`){let{core:n,emitter:r,managers:i,status:a}=this.context;if(!a.created||a.destroyed||n.options.inline.enabled)return;if(this.phase===`open`){n.setActiveEnd(t);return}if(e!==`api`&&n.input.disabled)return;let o=this.pickMode();this.openedFrom=t,n.setActiveEnd(t),this.begin(o),i.triggers.setExpanded(!0),r.emit(`open`,{mode:o})}mountInline(){let{core:t,emitter:n}=this.context;e.p(t.options.inline.container)===null?n.emit(`error`,{code:`invalid-option`,message:`ui.inline.container does not match an element`,option:`ui.inline.container`}):(this.begin(`inline`),n.emit(`open`,{mode:`inline`}))}close(){return this.context.core.mode===`inline`?Promise.resolve():this.end()}end(){if(this.phase===`closing`)return this.closing;if(this.phase!==`open`)return Promise.resolve();let{core:e,emitter:t,managers:n}=this.context,r=e.mode,i=this.sessionId;this.phase=`closing`,this.stopListening(),n.triggers.setExpanded(!1);let a=this.queue.run(()=>n.display.unmount()).then(()=>{this.finish(i,r)});return this.closing=a,t.emit(`close`,{}),a}syncLayout(t){let{core:n}=this.context,r=n.options,i=window.innerWidth;if(t===`inline`){let t=e.p(r.inline.container)?.clientWidth??0;i=t>0?t:i}n.setLayout(e.O({months:r.months,precision:r.precision,mode:r.mode,surface:t,fullscreen:e.E(r.mode,t,window.innerWidth,r.fullscreenBelow),width:i,weekNumbers:r.weekNumbers,presets:r.presets.length}))}remount(t){let{core:n,managers:r}=this.context;this.syncLayout(t),n.setMode(t);let{mode:i,precision:a}=n.options;n.panel===`input`&&!e.A(i,t,a)&&n.setPanel(e.T(a)),this.queue.run(()=>r.display.unmount()),this.queue.run(()=>r.display.mount(t))}pickMode(){let{displayMode:t}=this.context.core.options;return e.D(t,!1,window.innerWidth,window.innerHeight)}clampView(){st(this.context,this.context.core.view,`api`)}teardown(){this.phase=`closed`,this.stopListening(),this.queue.stop()}begin(t){let{core:n,managers:r}=this.context;this.stopListening();let i=new AbortController;this.controller=i,this.sessionId+=1,this.phase=`open`,n.resetSession();let{initialView:a,mode:o,precision:s,startView:c}=n.options;a===`input`&&e.A(o,t,s)?n.setPanel(`input`):s===`day`&&o!==`range`&&c!==`day`&&n.setPanel(e.k(c,t)),this.syncLayout(t),this.clampView(),n.setMode(t),n.events.on(`change:view`,e=>{this.forwardNavigation(e)},i.signal),this.queue.run(()=>r.display.mount(t))}stopListening(){this.controller?.abort(),this.controller=null}finish(e,t){this.sessionId===e&&this.phase===`closing`&&(this.phase=`closed`,this.context.core.setMode(null),this.returnFocus(t))}returnFocus(e){let{core:t}=this.context;if(!t.options.behavior.returnFocus)return;let n=document.activeElement;(e===`modal`||n===null||n===document.body)&&((this.openedFrom===`end`?t.endInput:null)??t.input).focus({preventScroll:!0})}forwardNavigation(e){e.source!==`api`&&this.context.emitter.emit(`navigate`,{year:e.view.year,month:e.view.month,direction:Rt(e.delta),source:e.source})}},Bt=class{context;scope=null;constructor(e){this.context=e}bind(){this.release();let{core:e,managers:t}=this.context;if(e.options.inline.enabled)return;let n=new AbortController;this.scope=n,t.triggers.bind(n.signal)}release(){this.scope?.abort(),this.scope=null}};function Vt(e,t){if(o(e))return null;switch(e.mode){case`single`:return e.date?t(e.date):null;case`range`:return e.start===null||e.end===null?null:{start:t(e.start),end:t(e.end)};default:return a(e).map(t)}}function V(t,n){if(typeof t==`string`)return dt(t,n);if(t instanceof Date){let r=e.W(t);return r===null?null:ut(r,n)}return null}function Ht(t){if(!(`start`in t&&`end`in t))return null;let n=V(t.start,`day`),r=V(t.end,`day`);return n===null||r===null||e.N(n,r)>0?null:{mode:`range`,start:n,end:r}}function Ut(e){let t=[];for(let n of e){let e=V(n,`day`);if(e===null)return null;t.push(e)}return{mode:`multiple`,dates:r(t)}}function Wt(e,t,n){if(e===null)return i(t);if(t===`multiple`)return Array.isArray(e)?Ut(e):null;if(t===`single`){let r=V(e,n);return r===null?null:{mode:t,date:r}}return typeof e==`object`&&!Array.isArray(e)&&!(e instanceof Date)?Ht(e):null}const Gt=[`start`,`end`];var Kt=class{context;session;constructor(e,t){this.context=e,this.session=t}describe=t=>{let{pattern:n,precision:r}=this.context.core.options;return{value:R(t,r),date:e.H(t),formatted:z(t,n,r)}};get(){return this.present(this.context.core.value)}set(e){let{core:t,emitter:n,managers:r,status:i}=this.context;if(i.destroyed)return;let a=Wt(e,t.options.mode,t.options.precision);a===null?n.emit(`error`,{code:`invalid-date`,message:`setValue() received a value that is not a valid date for calendar.mode`,input:typeof e==`string`?e:void 0}):(t.setValue(a),r.input.write(a),i.created&&r.form.sync(),this.follow(),this.validate(a))}setActiveEnd(e){let{core:t,status:n}=this.context,r=Gt;!n.destroyed&&t.options.mode===`range`&&r.includes(e)&&(t.controlActiveEnd(),t.setActiveEnd(e))}applyTyped(e){let{core:t,emitter:n,managers:r}=this.context,i=!l(t.value,e);t.setValue(e),r.form.sync(),this.follow(),i&&n.emit(`confirm`,{value:this.present(e),autoCommit:!0}),this.validate(e)}commit(e){let{core:t,emitter:n,managers:r}=this.context,i=t.draft;t.setValue(i),r.input.write(i),r.form.sync(),r.form.dispatchCommit(),n.emit(`confirm`,{value:this.present(i),autoCommit:e}),this.validate(i)}validate(e){let{core:t,managers:n}=this.context,{validate:r}=t.options;if(r===null)return;let i=r(this.present(e));i!==null&&n.input.markInvalid(i)}present(e){return Vt(e,this.describe)}follow(){if(!this.session.active)return;let{core:e}=this.context,t=e.value;e.setDraft(t);let n=f(t);n!==null&&L(this.context,n,`api`)}},qt=class{status={created:!1,destroyed:!1};session;values;actions;instance;updates;constructor(e,t,n){let r={core:e,emitter:t,managers:n,status:this.status},i=new Dt(r),a=new Bt(r);this.session=new zt(r),this.values=new Kt(r,this.session),this.actions=new Et(r,this.session,this.values),this.instance=new It(r,this.session,i,a),this.updates=new Ft(r,this.session,i,a),n.connect(this)}get created(){return this.status.created}get destroyed(){return this.status.destroyed}create(){this.instance.create()}open(e,t){this.session.open(e,t)}close(){return this.session.close()}destroy(e){this.instance.destroy(e)}setOptions(e){this.updates.apply(e)}getValue(){return this.values.get()}setValue(e){this.values.set(e)}setActiveEnd(e){this.values.setActiveEnd(e)}applyTyped(e){this.values.applyTyped(e)}select(e){this.actions.select(e)}selectRange(e,t){this.actions.selectRange(e,t)}typeDraft(e){this.actions.typeDraft(e)}focusDate(e){this.actions.focusDate(e)}navigate(e,t){this.actions.navigate(e,t)}page(e,t){this.actions.page(e,t)}jumpTo(e,t){this.actions.jumpTo(e,t)}showPanel(e){this.actions.showPanel(e)}confirm(){this.actions.confirm()}cancel(e){this.actions.cancel(e)}today(){this.actions.today()}clear(){this.actions.clear()}};const Jt=`dp-ui--pointer`,Yt=[`Shift`,`Control`,`Alt`,`Meta`];function Xt(){return e.y()||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function H(e){return e?Xt()?`reduced`:`full`:`none`}function Zt(e,t){e.textContent=``,e.textContent=t}function Qt(e){let t=e.ownerDocument,n=()=>{e.classList.add(Jt)},r=t=>{Yt.includes(t.key)||e.classList.remove(Jt)};return e.addEventListener(`pointerdown`,n,!0),t.addEventListener(`keydown`,r,!0),()=>{e.removeEventListener(`pointerdown`,n,!0),t.removeEventListener(`keydown`,r,!0)}}const $t=e=>e.toLowerCase().replace(/_/g,`-`);function en(t,n){Object.entries(e.c).forEach(([e,r])=>{t.style.setProperty(`--dp-ui-motion-${$t(e)}`,`${String(n?r:0)}ms`)}),Object.entries(e.o).forEach(([e,n])=>{t.style.setProperty(`--dp-ui-easing-${$t(e)}`,n)})}const tn=` – `,nn=/\s*[–—]\s*|\s+-\s+/,rn=/[,;]/;function an(e,t,n){return a(e).map(e=>z(e,t,n)).join(e.mode===`range`?tn:`, `)}function on(e,t){let n=[];for(let r of e){let e=t(r);if(e===null)return null;n.push(e)}return n}function sn(t){if(t?.length!==2)return null;let[n,r]=t;return e.N(n,r)>0?null:{mode:`range`,start:n,end:r}}function cn(e,t,n,i,a){switch(t){case`single`:{let r=n(e);return r===null?null:{mode:t,date:r}}case`range`:return sn(on(e.split(i),n));default:{let i=on(e.split(a).filter(e=>e.trim()!==``),n);return i===null?null:{mode:t,dates:r(i)}}}}function ln(e,t,n,r){let a=e.trim();return a===``?i(t):cn(a,t,e=>mt(e.trim(),n,r),nn,rn)}function un(e,t){return e.mode===`range`?e.start===null||e.end===null?``:`${R(e.start,t)}/${R(e.end,t)}`:a(e).map(e=>R(e,t)).join(`,`)}function dn(e,t,n){let r=e.trim();return r===``?i(t):cn(r,t,e=>dt(e.trim(),n),/\//,/,/)}function fn(e,t,n){if(t===`range`)return e.rangeTitle;switch(n){case`month`:return e.monthTitle;case`year`:return e.yearTitle;case`day`:return e.title}}const pn=/* @__PURE__ */ new Map,mn=/* @__PURE__ */ new Map;function hn(e){let t=pn.get(e);if(t)return t;let n=new Intl.PluralRules(e);return pn.set(e,n),n}function gn(e){let t=mn.get(e);if(t)return t;let n=new Intl.NumberFormat(e);return mn.set(e,n),n}function _n(e,t,n){return(typeof e==`string`?e:e[hn(n).select(t)]??e.other??Object.values(e).at(0)??``).replaceAll(`{count}`,gn(n).format(t))}function vn(e,t,n,r,i){switch(e.mode){case`single`:return e.date?se(e.date,i,n,`headline`):r.noDate;case`range`:{if(t===`input`&&e.start&&e.end)return ie(e.start,e.end,n);let i=e.start?re(e.start,n):r.rangeStart,a=e.end?re(e.end,n):r.rangeEnd;return`${i}${tn}${a}`}default:return e.dates.length===0?r.noDate:_n(r.multipleSelected,e.dates.length,n)}}const yn=`dp-ui--ripple-pressed`,bn=`dp-ui--ripple-active`,xn=e=>e.getAttribute(`aria-disabled`)===`true`||e instanceof HTMLButtonElement&&e.disabled;function Sn(t,n,r){let i=e=>e instanceof Element?e.closest(n):null,a=e=>{i(e.target)?.classList.remove(yn)};t.addEventListener(`pointerdown`,n=>{let o=i(n.target);if(!o||!t.contains(o)||xn(o)||n.pointerType===`mouse`&&n.button!==0)return;o.classList.remove(bn);let{left:s,top:c,width:l,height:u}=o.getBoundingClientRect();o.style.setProperty(`--dp-ui-ripple-x`,`${String(n.clientX-s)}px`),o.style.setProperty(`--dp-ui-ripple-y`,`${String(n.clientY-c)}px`),o.style.setProperty(`--dp-ui-ripple-size`,`${String(Math.max(l,u)*2)}px`),o.style.setProperty(`--dp-ui-ripple-duration`,`${String(e.c.RIPPLE)}ms`),o.classList.add(yn),o.addEventListener(`pointerleave`,a,{once:!0,signal:r}),Xt()||(requestAnimationFrame(()=>{o.classList.add(bn)}),window.setTimeout(()=>{o.classList.remove(bn)},e.c.RIPPLE))},{signal:r}),t.addEventListener(`pointerup`,a,{signal:r}),t.addEventListener(`pointercancel`,a,{signal:r})}const U={calendar:`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z"/></svg>`,pencil:`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"/></svg>`,arrowDropDown:`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M480-360 280-560h400L480-360Z"/></svg>`,keyboardArrowLeft:`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"/></svg>`,keyboardArrowRight:`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"/></svg>`,close:`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg>`,check:`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/></svg>`},Cn=e=>{let t=t=>`${e.shiftKey}+${t}`;return{previousMonth:{keys:`PageUp`,display:e.pageUpKey},nextMonth:{keys:`PageDown`,display:e.pageDownKey},previousYear:{keys:`Shift+PageUp`,display:t(e.pageUpKey)},nextYear:{keys:`Shift+PageDown`,display:t(e.pageDownKey)},chooseMonth:{keys:`Shift+M`,display:t(`M`)},chooseYear:{keys:`Shift+Y`,display:t(`Y`)}}},W=(e,t)=>`dp-ui-${e.replace(/[^\w-]/g,`-`)}-${t}`,wn=(e,t,n)=>{n!==void 0&&(e.setAttribute(`title`,`${t} (${n.display})`),e.setAttribute(`aria-keyshortcuts`,n.keys))},Tn=(t,n)=>{let r=e.f(`span`);r.innerHTML=t;let i=r.firstElementChild;return i===null?null:(i.setAttribute(`class`,n),i.setAttribute(`aria-hidden`,`true`),i)},G=(t,n,r,i)=>{let a=e.d(`dp-ui__icon-button dp-ui__icon-button--${t}`,n,r);return a.firstElementChild?.setAttribute(`aria-hidden`,`true`),wn(a,n,i),a},K=(t,n,r)=>{let i=e.f(`button`,`dp-ui__menu-button dp-ui__menu-button--${t}`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":r.controls});wn(i,r.name,r.shortcut);let a=e.f(`span`,`dp-ui__menu-button-label`);i.append(a);let o=Tn(U.arrowDropDown,`dp-ui__menu-button-icon`);o!==null&&i.append(o);let s=(e,t=e)=>{a.textContent=e,i.setAttribute(`aria-label`,`${r.name}, ${t}`)};return s(n),{button:i,label:a,setText:s}},q=(t,n)=>e.d(`dp-ui__text-button dp-ui__text-button--${t}`,n),En=(e,t)=>{let n=G(`switch-view`,e.switchToInput,U.pencil);return{button:n,setInputView:r=>{n.innerHTML=r?U.calendar:U.pencil,n.firstElementChild?.setAttribute(`aria-hidden`,`true`),r?n.setAttribute(`aria-controls`,t):n.removeAttribute(`aria-controls`),n.setAttribute(`aria-label`,r?e.switchToCalendar:e.switchToInput)}}},Dn=(e,t)=>{e.querySelectorAll(`.dp-ui__text-button--confirm, .dp-ui__text-button--save`).forEach(e=>{e.disabled=!t})},On=t=>{let{labels:n}=t,r=e.f(`div`,`dp-ui__actions`);r.hidden=!t.visible;let i=e.f(`div`,`dp-ui__actions-start`);t.todayButton&&i.append(q(`today`,n.today)),t.clearButton&&i.append(q(`clear`,n.clear));let a=e.f(`div`,`dp-ui__actions-end`);return a.append(q(`cancel`,n.cancel),q(`confirm`,n.confirm)),r.append(i,a),r},kn=[[`dp-ui__icon-button--prev-month`,{kind:`page`,direction:-1}],[`dp-ui__icon-button--next-month`,{kind:`page`,direction:1}],[`dp-ui__icon-button--prev-year`,{kind:`navigate`,delta:-12}],[`dp-ui__icon-button--next-year`,{kind:`navigate`,delta:12}],[`dp-ui__menu-button--month`,{kind:`panel`,panel:`month-menu`}],[`dp-ui__menu-button--year`,{kind:`panel`,panel:`year-menu`}],[`dp-ui__menu-button--year-grid`,{kind:`panel`,panel:`year-grid`}],[`dp-ui__text-button--today`,{kind:`today`}],[`dp-ui__text-button--clear`,{kind:`clear`}],[`dp-ui__text-button--cancel`,{kind:`cancel`}],[`dp-ui__text-button--confirm`,{kind:`confirm`}],[`dp-ui__text-button--save`,{kind:`confirm`}],[`dp-ui__icon-button--close`,{kind:`cancel`}],[`dp-ui__icon-button--switch-view`,{kind:`switch`}]],An=e=>kn.find(([t])=>e.classList.contains(t)),jn=e=>An(e)?.[0]??null,Mn=(e,t)=>{let{actions:n}=t;switch(e.kind){case`navigate`:n.navigate(e.delta,`button`);return;case`page`:n.page(e.direction,`button`);return;case`panel`:n.showPanel(t.panel()===e.panel?t.home:e.panel);return;case`switch`:n.showPanel(t.panel()===`input`?t.home:`input`);return;case`today`:n.today();return;case`clear`:n.clear();return;case`cancel`:n.cancel(`button`);return;case`confirm`:n.confirm()}},Nn=(e,t,n)=>{e.addEventListener(`click`,e=>{let{target:t}=e,r=t instanceof Element?t.closest(`button`):null;if(r!==null){let e=An(r);e&&Mn(e[1],n);return}let i=n.cellAt(t);i!==null&&n.actions.select(i.date)},{signal:t})},Pn=`dp-ui__container--menu-open`,Fn=`dp-ui__container--input`,In=`--dp-ui-visible-months`,J=e=>e.closest(`.dp-ui__container`),Ln=(e,t)=>e!==t&&e!==`days`&&e!==`input`,Rn=(e,t)=>{let n=t>1;e.classList.toggle(`dp-ui__container--multi-month`,n),n?e.style.setProperty(In,String(t)):e.style.removeProperty(In)},zn=(e,t,n)=>{let r=t===`input`;e.classList.toggle(Fn,r),Rn(e,r?1:n)},Bn=(t,n)=>{let r=e.f(`div`,`dp-ui__navigation-group dp-ui__navigation-group--${t}`);return r.append(...n),r},Vn=t=>{let{labels:n}=t,r=Cn(n),i=O(t.locale,`short`),a=O(t.locale,`long`),o=K(`month`,``,{name:n.chooseMonth,controls:W(t.instanceId,`month-menu`),shortcut:r.chooseMonth}),s=K(`year`,``,{name:n.chooseYear,controls:W(t.instanceId,`year-menu`),shortcut:r.chooseYear}),c=e.f(`div`,`dp-ui__header dp-ui__header--docked`),l=Bn(`month`,[G(`prev-month`,n.previousMonth,U.keyboardArrowLeft,r.previousMonth),o.button,G(`next-month`,n.nextMonth,U.keyboardArrowRight,r.nextMonth)]);l.hidden=t.groups!==`both`,c.hidden=t.groups===`none`,c.append(l,Bn(`year`,[G(`prev-year`,n.previousYear,U.keyboardArrowLeft,r.previousYear),s.button,G(`next-year`,n.nextYear,U.keyboardArrowRight,r.nextYear)]));let u=e=>{o.setText(i[e.month-1]??``,a[e.month-1]??``),s.setText(y(e.year,t.locale))},d=e=>{o.button.setAttribute(`aria-expanded`,String(e===`month-menu`)),s.button.setAttribute(`aria-expanded`,String(e===`year-menu`)),o.button.disabled=e===`year-menu`,s.button.disabled=e===`month-menu`};return u(t.view),d(t.home),{element:c,setView:u,setPanel:d}},Hn=`dp-ui__headline--fading-out`,Un=(t,n)=>{let r=e.f(`div`,`dp-ui__headline`);r.textContent=t;let i=null,a=null,o=()=>{a!==null&&clearTimeout(a),a=null,i=null,r.classList.remove(Hn)},s=()=>{let e=i;o(),e!==null&&(r.textContent=e)};return{element:r,setText:t=>{t!==(i??r.textContent)&&(n?(i=t,r.classList.add(Hn),a??=setTimeout(s,e.c.HEADLINE_FADE)):(o(),r.textContent=t))},destroy:o}},Wn=t=>{let{labels:n,switchView:r}=t,i=e.f(`div`,`dp-ui__header dp-ui__header--modal`),a=e.f(`div`,`dp-ui__supporting-text`);a.textContent=t.title;let o=Un(t.text,t.animate);i.append(a,o.element);let s=r===null?null:En(n,r.panelId);return s!==null&&i.append(s.button),{element:i,setText:e=>{o.setText(e)},setInputView:e=>{s?.setInputView(e)},destroy:()=>{o.destroy()}}},Gn=(t,n,r,i)=>{let a=Cn(r),o=e.f(`div`,`dp-ui__navigation`);return o.append(K(`year-grid`,k(t,n),{name:r.chooseYear,controls:W(i,`year-grid`),shortcut:a.chooseYear}).button,G(`prev-month`,r.previousMonth,U.keyboardArrowLeft,a.previousMonth),G(`next-month`,r.nextMonth,U.keyboardArrowRight,a.nextMonth)),o},Kn=(t,n,r,i)=>{let a=e.f(`div`,`dp-ui__navigation dp-ui__navigation--month-grid`),o=Cn(r);return a.append(K(`year-grid`,y(t.year,n),{name:r.chooseYear,controls:W(i,`year-grid`),shortcut:o.chooseYear}).button,G(`prev-year`,r.previousYear,U.keyboardArrowLeft,o.previousYear),G(`next-year`,r.nextYear,U.keyboardArrowRight,o.nextYear)),a},qn=(t,n,r,i)=>{let a=e.f(`div`,`dp-ui__navigation dp-ui__navigation--year-grid`),{button:o}=K(`year-grid`,k(t,n),{name:r.chooseYear,controls:W(i,`year-grid`)});return o.setAttribute(`aria-expanded`,`true`),a.append(o),a},Jn=n=>{let{decorateDate:r}=n.options;return r===null?()=>null:n=>{try{return r(e.H(n))??null}catch(e){return t(e),null}}},Yn=t=>{let{renderDate:n}=t.options;return n===null?()=>null:t=>n(e.H(t))},Xn=(t,n,r)=>{let{options:i}=t;return{locale:i.locale,weekStart:i.weekStart,weekNumbers:i.weekNumbers,showOutside:r,outsideSelectable:i.outsideDays!==!1&&i.outsideDays.selectable,labels:{weekNumber:i.labels.weekNumber},rangeLabels:{start:i.labels.rangeStart,end:i.labels.rangeEnd},headingVisible:!1,weekdaysVisible:!0,multiselectable:t.draft.mode!==`single`,rangeRole:()=>null,decorate:Jn(t),content:Yn(t),isSelected:e=>u(t.draft,e),isDisabled:e=>!n.isSelectable(e,t.followsActiveEnd?Ct(t.draft,t.activeEnd):t.draft),today:e.G(),focus:t.focus}},Zn=(e,t,n)=>{let r=e.layout.months>1,i=n===`docked`&&!r&&e.options.outsideDays!==!1,a=Xn(e,t,i);return r?{...a,headingVisible:!0}:a},Qn=(t,n)=>oe(n,e.M(n,t.layout.months-1),t.options.locale),Y=e=>vn(e.draft,e.panel===`input`?`input`:`calendar`,e.options.locale,e.options.labels,e.options.precision),$n={days:null,input:null,"month-menu":`.dp-ui__menu-button--month`,"year-menu":`.dp-ui__menu-button--year`,"year-grid":`.dp-ui__menu-button--year-grid`,"month-grid":null},er=e=>{switch(e){case`day`:return`both`;case`month`:return`year`;case`year`:return`none`}},tr=e=>$n[e],nr=(t,n,r)=>{let{locale:i,labels:a,animation:o,viewSwitch:s,mode:c,precision:l}=t.options;if(n===`modal`){let n=s&&e.A(c,r,l),i=Wn({labels:a,title:fn(a,c,l),animate:o,text:Y(t),switchView:n?{panelId:W(t.instanceId,`input`)}:null});return i.setInputView(t.panel===`input`),{element:i.element,docked:null,modal:i}}let u=Vn({instanceId:t.instanceId,locale:i,labels:a,view:t.view,groups:er(l),home:e.T(l)});return{element:u.element,docked:u,modal:null}},rr=(t,n)=>{let r=e.M(t,n);return{year:r.year,month:r.month,day:Math.min(t.day,e.L(r))}},ir=(t,n,r,i)=>{let a=n?12:1;switch(t){case`ArrowLeft`:return e.j(r,i?1:-1);case`ArrowRight`:return e.j(r,i?-1:1);case`ArrowUp`:return e.j(r,-7);case`ArrowDown`:return e.j(r,7);case`Home`:return{year:r.year,month:r.month,day:1};case`End`:return{...r,day:e.L(r)};case`PageUp`:return rr(r,-a);case`PageDown`:return rr(r,a);default:return null}},ar=e=>e.ctrlKey||e.altKey||e.metaKey,or=(e,t)=>{let n=e.toLowerCase();return t===`modal`?n===`y`?`year-grid`:null:n===`m`?`month-menu`:n===`y`?`year-menu`:null},sr=e=>{let{panel:t}=e.core;return e.layout===`docked`?e.home===`days`&&t===`days`:e.layout===`modal`&&t===e.home&&e.home!==`year-grid`},cr=(e,t)=>{let{panel:n}=t.core;n!==t.home&&n!==`input`&&(e.preventDefault(),e.stopPropagation(),t.actions.showPanel(t.home))},lr=(e,t)=>{if(!e.shiftKey||!sr(t))return!1;let n=or(e.key,t.layout);return n!==null&&(e.preventDefault(),t.actions.showPanel(n),!0)},ur=(e,t,n)=>{e.preventDefault(),e.key===`Enter`&&n.layout===`modal`&&n.core.options.mode===`single`&&u(n.core.draft,t.date)?n.actions.confirm():n.actions.select(t.date)},dr=(e,t,n)=>{if(e.key===`Enter`||e.key===` `){ur(e,t,n);return}let r=ir(e.key,e.shiftKey,t.date,n.isRtl());r!==null&&(e.preventDefault(),n.actions.focusDate(r))},fr=(e,t,n)=>{e.addEventListener(`keydown`,e=>{if(e.defaultPrevented)return;if(e.key===`Escape`){cr(e,n);return}if(ar(e)||lr(e,n))return;let t=n.cellAt(e.target);t!==null&&dr(e,t,n)},{signal:t})},pr=`dp-ui__ghost`,mr=e=>Array.from(e.querySelectorAll(`*`)).filter(e=>e.closest(`.${pr}`)===null),hr=(e,t,n)=>{e.querySelectorAll(`.${pr}`).forEach(e=>{e.remove()}),e.removeAttribute(`popover`),e.removeAttribute(`style`),e.classList.remove(`dp-ui__container--morphing`),e.classList.add(pr),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``),e.removeAttribute(`id`),e.removeAttribute(`name`),e.querySelectorAll(`[id], [name]`).forEach(e=>{e.removeAttribute(`id`),e.removeAttribute(`name`)}),e.style.setProperty(`inline-size`,`${String(t)}px`),e.style.setProperty(`block-size`,`${String(n)}px`)},gr=(e,t)=>{let n=Array.from(t.querySelectorAll(`*`));return mr(e).flatMap((e,t)=>{let r=n.at(t);return r===void 0||e.scrollTop===0&&e.scrollLeft===0?[]:[{live:e,copy:r,top:e.scrollTop,left:e.scrollLeft}]})},_r=({live:e,copy:t})=>{let n=e.getBoundingClientRect(),r=Array.from(t.children);Array.from(e.children).forEach((e,t)=>{let i=r.at(t),a=e.getBoundingClientRect();i===void 0||a.bottom>n.top&&a.top<n.bottom||(i.replaceChildren(),i instanceof HTMLElement&&i.style.setProperty(`block-size`,`${String(a.height)}px`))})},vr=(t,n,r)=>{let i=t.cloneNode(!0);if(!(i instanceof HTMLElement))return null;hr(i,n,r);let a=gr(t,i);a.forEach(_r);let o=null,s=()=>{if(o!==null){let e=o;o=null,e.cancel()}i.remove()};return{show:()=>{t.append(i),a.forEach(({copy:e,top:t,left:n})=>{e.scrollTop=t,e.scrollLeft=n}),typeof i.animate==`function`?(o=i.animate([{opacity:1},{opacity:0}],{duration:e.c.VIEW_SWITCH_FADE_OUT,easing:`linear`,fill:`forwards`}),o.finished.then(s,s)):s()},remove:s}},yr=`dp-ui__container--morphing`,br=/* @__PURE__ */ new WeakMap,xr=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height,radius:getComputedStyle(e).borderRadius}},Sr=(e,t)=>{if(t===null)return null;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:getComputedStyle(t).direction===`rtl`?n.right-r.right:r.left-n.left,y:r.top-n.top,height:r.height}},Cr=e=>({width:`${String(e.width)}px`,height:`${String(e.height)}px`,borderRadius:e.radius}),wr=(t,n,r)=>{if(r.height===0)return;let i=getComputedStyle(t).direction===`rtl`,a=(n.x-r.x)*(i?-1:1),o=n.y-r.y,s=n.height/r.height;if(a===0&&o===0&&s===1)return;let c=i?`top right`:`top left`;t.animate([{transform:`translate(${String(a)}px, ${String(o)}px) scale(${String(s)})`,transformOrigin:c},{transform:`none`,transformOrigin:c}],{duration:e.c.VIEW_SWITCH,easing:e.o.EMPHASIZED})},Tr=(t,n,r)=>{if(r===`none`||typeof t.animate!=`function`)return n(),null;if(r===`reduced`){let e=xr(t),r=vr(t,e.width,e.height);return n(),r?.show(),null}let i=t.querySelector(`.dp-ui__headline`),a=xr(t),o=Sr(t,i),s=vr(t,a.width,a.height);n();let c=xr(t),l=Sr(t,i);t.classList.add(yr);let u=t.animate([Cr(a),Cr(c)],{duration:e.c.VIEW_SWITCH,easing:e.o.EMPHASIZED});br.set(t,u),s?.show(),i!==null&&o!==null&&l!==null&&wr(i,o,l);let d=()=>{s?.remove(),br.get(t)===u&&(br.delete(t),t.classList.remove(yr))};return u.finished.then(d,d),u};function Er(t){let n=t.describedById??`${t.id}-supporting`,r=e.f(`div`,`dp-ui__text-field`),i=e.f(`input`,`dp-ui__text-field-input`,{id:t.id,type:`text`,inputmode:`numeric`,autocomplete:`off`,placeholder:t.placeholder,tabindex:`0`,"aria-invalid":`false`,"aria-describedby":n});i.value=t.value;let a=e.f(`label`,`dp-ui__text-field-label`,{for:t.id});a.textContent=t.label;let o=e.f(`div`,`dp-ui__text-field-supporting`,{id:n,"aria-live":`polite`});return o.textContent=t.hint,r.append(i,a,o),{element:r,input:i,getValue:()=>i.value,setValue:e=>{i.value=e},setError:e=>{let n=e!==null;r.classList.toggle(`dp-ui__text-field--error`,n),i.setAttribute(`aria-invalid`,n?`true`:`false`);let a=e??t.hint;o.textContent!==a&&(o.textContent=a)}}}function Dr(e){return e.mode===`single`?e.date:null}function Or(e){return e.mode===`single`?e.date===null:e.mode===`range`?e.start===null:e.dates.length===0}function kr(t){let{instanceId:n,draft:r,pattern:i,labels:a,rules:o}=t,c=e.f(`div`,`dp-ui__input-panel`,{"data-panel":`input`,id:W(n,`input`)}),l=e.x(i,e.S(a)),u=(t,r,a)=>Er({id:`${n}-input-${t}`,label:r,placeholder:l,hint:l,value:a?e.b(a,i):``}),d=r.mode===`range`,f=u(d?`start`:`date`,d?a.startDateField:a.dateField,r.mode===`range`?r.start:Dr(r)),p=d?u(`end`,a.endDateField,r.end):null,m=p?[f,p]:[f],h=n=>{let r=n.getValue().trim();if(r===``)return n.setError(null),{date:null,failed:!1};let s=e._(r,i);if(s===null)return n.setError(a.invalidDate),{date:null,failed:!0};let c=o.unavailableReason(s);return c===null?(n.setError(null),n.setValue(e.b(s,i)),{date:s,failed:!1}):(n.setError(t.messageFor(c)),{date:null,failed:!0})},g=()=>{let t=h(f);if(!p)return t.failed?null:{mode:`single`,date:t.date};let n=h(p),r=n.date,i=t.failed||n.failed;return t.date&&r&&e.N(r,t.date)<0&&(p.setError(a.invalidRange),r=null,i=!0),i?null:{mode:`range`,start:t.date,end:r}},_=e=>{let n=B(e,t.limits,e=>o.unavailableReason(e));return n===null||((p??f).setError(t.messageFor(n)),!1)};return m.forEach(e=>{e.input.addEventListener(`change`,()=>{let e=g();e&&_(e)&&t.onDraft(e)}),e.input.addEventListener(`keydown`,e=>{if(e.key!==`Enter`)return;e.preventDefault();let n=g();n&&_(n)&&s(n)&&!Or(n)&&(t.onDraft(n),t.onSubmit())})}),c.append(...m.map(e=>e.element)),c}function Ar(e,t){let{labels:n,minDate:r,maxDate:i,pattern:a,precision:o}=t;return e===`min`&&r!==null?n.beforeMinDate.replace(`{date}`,z(r,a,o)):e===`max`&&i!==null?n.afterMaxDate.replace(`{date}`,z(i,a,o)):e===`range-length`?n.invalidRange:n.unavailableDate}const jr=e=>{let{core:t,actions:n,rules:r}=e,{pattern:i,labels:a,limits:o}=t.options;return[kr({instanceId:t.instanceId,draft:t.draft,pattern:i,labels:a,rules:r,limits:o,messageFor:e=>Ar(e,t.options),onDraft:e=>{n.typeDraft(e)},onSubmit:()=>{n.confirm()}})]},Mr=`dp-ui__pager--dragging`,Nr=e=>e instanceof Element&&e.closest(`button`)!==null,Pr=(t,n)=>{t.push(n),t.length>e.s.VELOCITY_SAMPLES&&t.shift()},Fr=t=>{let n=t.at(0),r=t.at(-1);return!n||!r?0:(r.x-n.x)/Math.max(e.s.MIN_SAMPLE_SPAN_MS,r.t-n.t)},Ir=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},Lr=(e,t)=>{e.hasPointerCapture(t)&&e.releasePointerCapture(t)},Rr=(t,n,r)=>{let i=null,a=null,o=e=>{e.controller.abort(),i===e&&(i=null),e.dragging&&(t.classList.remove(Mr),Lr(t,e.pointerId))},s=()=>{a?.abort();let e=new AbortController;a=e,t.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),e.abort()},{capture:!0,signal:e.signal}),requestAnimationFrame(()=>{e.abort()})},c=e=>{r.onBegin(),e.dragging=!0,e.width=r.pageWidth(),Ir(t,e.pointerId),t.classList.add(Mr)},l=(t,n)=>{if(n.pointerId!==t.pointerId)return;let i=n.clientX-t.startX;if(!t.dragging){if(Math.abs(i)<=e.s.DRAG_START_PX)return;c(t)}t.lastX=n.clientX,Pr(t.samples,{x:n.clientX,t:n.timeStamp}),r.onMove(i,t.width)},u=(e,t,n)=>{t.pointerId===e.pointerId&&(o(e),e.dragging&&(n?r.onAbort():(s(),Pr(e.samples,{x:e.lastX,t:t.timeStamp}),r.onRelease({dx:e.lastX-e.startX,velocity:Fr(e.samples),width:e.width}))))};t.addEventListener(`pointerdown`,e=>{if(e.button!==0||!e.isPrimary||Nr(e.target))return;let n=i;n&&(o(n),n.dragging&&r.onAbort());let a=new AbortController,s={pointerId:e.pointerId,startX:e.clientX,samples:[{x:e.clientX,t:e.timeStamp}],controller:a,lastX:e.clientX,width:0,dragging:!1};i=s;let c=t.ownerDocument,d={signal:a.signal};c.addEventListener(`pointermove`,e=>{l(s,e)},d),c.addEventListener(`pointerup`,e=>{u(s,e,!1)},d),c.addEventListener(`pointercancel`,e=>{u(s,e,!0)},d)},{signal:n});let d=()=>{i&&o(i)};return{isDragging:()=>i?.dragging===!0,cancel:d,dispose:()=>{d(),a?.abort(),a=null}}},zr=(e,t)=>e.year===t.year&&e.month===t.month,Br=(t,n,r)=>{let i=null,a=e=>{let t=n(e);return t.classList.add(`dp-ui__page`),{view:e,element:t}},o=e=>{i?.forEach((t,n)=>{t.element.toggleAttribute(`inert`,n!==e)})},s=(e,t,n)=>{let r=e[t];if(zr(r.view,n))return e;let i=a(n);return r.element.replaceWith(i.element),t===0?[i,e[1],e[2]]:[e[0],e[1],i]};return{show:n=>{let s=[a(e.M(n,-r)),a(n),a(e.M(n,r))];t.replaceChildren(...s.map(e=>e.element)),i=s,o(1)},centerView:()=>i?.[1].view??null,reveal:(e,t)=>{i&&(i=s(i,e,t),o(e))},recenter:t=>{if(!i)return;let n=i[t],s=a(e.M(n.view,-r)),c=a(e.M(n.view,r));i.forEach((e,n)=>{n!==t&&e.element.remove()}),n.element.before(s.element),n.element.after(c.element),i=[s,n,c],o(1)},clear:()=>{i=null}}},Vr=(t,n,r)=>{if(n<-e.s.FLICK_VELOCITY)return 1;if(n>e.s.FLICK_VELOCITY)return-1;let i=r*e.s.COMMIT_FRACTION;return t<-i?1:t>i?-1:0},Hr=(e,t,n,r)=>{let i=Vr(e,t,n);return!r||i===0?i:i===1?-1:1},Ur=(t,n)=>{let r=null,i=null,a=()=>typeof t.animate==`function`,o=()=>{let e=i;i=null,e?.cancel()},s=()=>{o();let e=r;e&&(r=null,e.complete(),e.animation.cancel())},c=()=>{o();let e=r;r=null,e?.animation.cancel()},l=()=>{let n=t.animate([{opacity:0},{opacity:1}],{duration:e.c.REDUCED_FADE,easing:`linear`});i=n;let r=()=>{i===n&&(i=null)};n.finished.then(r,r)};return{run:(i,c,u)=>{o();let d=H(n);if(i===c||d===`none`||!a()){u();return}if(d===`reduced`){u(),l();return}let f=t.animate([{transform:i},{transform:c}],{duration:e.c.PAGER_SETTLE,easing:e.o.EMPHASIZED,fill:`forwards`}),p={animation:f,complete:u};r=p,f.finished.then(()=>{r===p&&s()},()=>void 0)},finish:s,cancel:c}},Wr=(e,t)=>Math.min(t,Math.max(-t,e)),Gr=(e,t)=>e.deltaMode===0?e.deltaX:Math.sign(e.deltaX)*t,Kr=(t,n,r)=>{let i=null,a=0,o=()=>{i=null;let e=a;a=0,r.onSettle(e,r.pageWidth())};return t.addEventListener(`wheel`,t=>{if(Math.abs(t.deltaX)<=Math.abs(t.deltaY)||r.isBlocked())return;t.preventDefault();let n=r.pageWidth();i===null?r.onBegin():clearTimeout(i),a-=Gr(t,n),r.onMove(Wr(a,n),n),i=setTimeout(o,e.c.WHEEL_SETTLE)},{passive:!1,signal:n}),{cancel:()=>{i!==null&&clearTimeout(i),i=null,a=0}}},qr=`dp-ui__pager--swipe`,Jr=`--dp-ui-pager-height`;var Yr=class{viewport;options;track;controller=new AbortController;previousTouchAction;strip;animator;drag=null;wheel=null;offset=0;revision=0;constructor(t,n){this.viewport=t,this.options=n,this.previousTouchAction=t.style.touchAction,this.track=e.f(`div`,`dp-ui__pager-track`),this.strip=Br(this.track,e=>n.renderPage(e),n.step??1),this.animator=Ur(this.track,n.animate),t.classList.add(`dp-ui__pager`),t.append(this.track),n.swipe&&this.enableSwipe()}show(e){this.destroyed||(this.revision+=1,this.animator.cancel(),this.cancelGestures(),this.strip.show(e),this.rest(),this.fitHeight(e))}slide(e,t){if(this.destroyed)return;this.finish(),this.cancelGestures();let n=this.strip.centerView();if(!n){this.show(e);return}if(this.revision+=1,zr(n,e)){this.settle();return}let r=t===1?2:0;this.strip.reveal(r,e),this.fitHeight(e);let i=this.pageWidth(),a=this.transformFor(1,this.offset,i);this.offset=0,this.animator.run(a,this.transformFor(r,0,i),()=>{this.strip.recenter(r),this.rest()})}finish(){this.animator.finish()}destroy(){this.destroyed||(this.controller.abort(),this.cancelGestures(),this.drag?.dispose(),this.animator.cancel(),this.track.remove(),this.strip.clear(),this.viewport.style.removeProperty(Jr),this.viewport.classList.remove(qr,Mr),this.options.swipe&&(this.viewport.style.touchAction=this.previousTouchAction))}get destroyed(){return this.controller.signal.aborted}enableSwipe(){let{signal:e}=this.controller;this.viewport.style.touchAction=`pan-y`,this.viewport.classList.add(qr),this.drag=Rr(this.viewport,e,{pageWidth:()=>this.pageWidth(),onBegin:()=>{this.finish(),this.wheel?.cancel()},onMove:(e,t)=>{this.setOffset(e,t)},onRelease:({dx:e,velocity:t,width:n})=>{this.release(Hr(e,t,n,this.options.rtl),`drag`)},onAbort:()=>{this.settle()}}),this.wheel=Kr(this.viewport,e,{pageWidth:()=>this.pageWidth(),isBlocked:()=>this.drag?.isDragging()===!0,onBegin:()=>{this.finish()},onMove:(e,t)=>{this.setOffset(e,t)},onSettle:(e,t)=>{this.release(Hr(e,0,t,this.options.rtl),`wheel`)}})}cancelGestures(){this.drag?.cancel(),this.wheel?.cancel()}release(e,t){if(e===0){this.settle();return}let n=this.revision;this.options.onCommit(e,t),this.revision===n&&!this.destroyed&&this.settle()}settle(){this.finish();let e=this.pageWidth(),t=this.transformFor(1,this.offset,e);this.offset=0,this.animator.run(t,this.transformFor(1,0,e),()=>{this.rest()})}fitHeight(e){this.options.fitHeight&&!this.viewport.hidden&&this.viewport.style.setProperty(Jr,`${String(this.options.pageHeight(e))}px`)}rest(){this.offset=0,this.track.style.removeProperty(`transform`),this.viewport.scrollLeft!==0&&(this.viewport.scrollLeft=0)}setOffset(e,t){this.offset=e,this.track.style.transform=this.transformFor(1,e,t)}transformFor(e,t,n){let r=this.options.rtl?1:-1;return`translateX(${String(r*e*n+t)}px)`}pageWidth(){let e=this.viewport.clientWidth;return e>0?e:360}};const Xr=`dp-ui__date`,Zr=`dp-ui__date--outside-month`,Qr=`data-decoration-label`,$r=`data-content-label`,ei=`dp-ui__date-content`,ti=`dp-ui__date--has-content`,ni=`:scope > .${ei}`,ri=(e,t,n)=>n.isDisabled(e)||t&&!n.outsideSelectable,ii=(t,n,r,i)=>[[`dp-ui__date--selected`,i.isSelected(t)],[`dp-ui__date--range-start`,r===`start`],[`dp-ui__date--range-end`,r===`end`],[`dp-ui__date--in-range`,r===`in-range`],[`dp-ui__date--today`,e.z(t,i.today)],[`dp-ui__date--disabled`,ri(t,n,i)],[Zr,n]],ai=e=>{e.querySelector(ni)?.remove(),e.classList.remove(ti),e.removeAttribute($r)},oi=(t,n,r)=>{let i=r.content(n);if(i===null){ai(t);return}let a=t.querySelector(ni),o=(typeof i==`string`?i:i.textContent??``).trim();if(typeof i!=`string`||a===null||a.childElementCount!==0||a.textContent!==i){let n=e.f(`span`,ei);typeof i==`string`?n.textContent=i:n.appendChild(i),a===null?t.querySelector(`.dp-ui__date-indicator`)?.after(n):a.replaceWith(n)}t.classList.add(ti),o===``?t.removeAttribute($r):t.setAttribute($r,o)},si=(e,t)=>e===`start`?t.rangeLabels.start:e===`end`?t.rangeLabels.end:null,ci=(e,t,n,r,i)=>[ae(e,i.locale),si(t,i),n,r].filter(e=>e!==null&&e!==``).join(`, `),li=(t,n,r,i)=>{let a=i.rangeRole(n);oi(t,n,i),ii(n,r,a,i).forEach(([e,n])=>t.classList.toggle(e,n)),t.setAttribute(`aria-selected`,String(i.isSelected(n)||a!==null)),t.setAttribute(`aria-label`,ci(n,a,t.getAttribute(Qr),t.getAttribute($r),i)),e.z(n,i.today)?t.setAttribute(`aria-current`,`date`):t.removeAttribute(`aria-current`),ri(n,r,i)?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);let o=!r&&e.z(n,i.focus);t.setAttribute(`tabindex`,o?`0`:`-1`)},ui=(t,n)=>{if(n===null)return;let r=(n.className??``).split(/\s+/).filter(Boolean);t.classList.add(...r),n.label&&t.setAttribute(Qr,n.label),n.badge===!0&&t.appendChild(e.f(`span`,`dp-ui__date-badge`,{"aria-hidden":`true`}))},di=(t,n)=>{if(!t.inMonth&&!n.showOutside)return e.f(`td`,`${Xr} dp-ui__date--empty`);let r=e.f(`td`,Xr,{role:`gridcell`,"data-date":e.U(t.date)}),i=e.f(`span`,`dp-ui__date-indicator`);return i.textContent=y(t.date.day,n.locale),r.appendChild(i),ui(r,n.decorate(t.date)),li(r,t.date,!t.inMonth,n),r},fi=`dp-ui__visually-hidden`,pi=t=>{let n=e.f(`thead`),r=e.f(`tr`,t.weekdaysVisible?`dp-ui__weekdays`:`dp-ui__weekdays ${fi}`);if(t.weekNumbers){let n=e.f(`th`,`dp-ui__week-number-header`,{scope:`col`});n.textContent=t.labels.weekNumber,r.appendChild(n)}let i=te(t.locale,`narrow`),a=te(t.locale,`long`);for(let n=0;n<7;n++){let o=(t.weekStart+n)%7,s=a[o]??``,c=e.f(`th`,`dp-ui__weekday`,{role:`columnheader`,scope:`col`,abbr:s,title:s});c.textContent=i[o]??``,r.appendChild(c)}return n.appendChild(r),n},mi=(t,n)=>{let r=e.f(`table`,`dp-ui__month-grid`,{role:`grid`});n.multiselectable===!0&&r.setAttribute(`aria-multiselectable`,`true`);let i=e.f(`caption`,n.headingVisible?`dp-ui__month-subhead`:`dp-ui__month-heading ${fi}`);i.textContent=k(t.view,n.locale),r.appendChild(i),r.appendChild(pi(n));let a=e.f(`tbody`);return t.weeks.forEach((r,i)=>{let o=e.f(`tr`,`dp-ui__week`);if(n.weekNumbers){let r=e.f(`th`,`dp-ui__week-number`,{scope:`row`}),a=t.weekNumbers.at(i);r.textContent=a===void 0?``:y(a,n.locale),o.appendChild(r)}r.forEach(e=>o.appendChild(di(e,n))),a.appendChild(o)}),r.appendChild(a),r},hi=(t,n)=>{t.querySelectorAll(`td[data-date]`).forEach(t=>{let r=e.R(t.dataset.date??``);r!==null&&li(t,r,t.classList.contains(Zr),n)})},gi=(t,n,r)=>{let i={year:t.year,month:t.month,day:1},a=(e.F(i)-n+7)%7,o=r?6:Math.ceil((a+e.L(t))/7),s=e.j(i,-a),c=(4-n+7)%7,l=[],u=[];for(let n=0;n<o;n++){let r=e.j(s,n*7),i=[];for(let n=0;n<7;n++){let a=e.j(r,n);i.push({date:a,inMonth:a.year===t.year&&a.month===t.month})}l.push(i),u.push(e.B(e.j(r,c)))}return{view:t,weeks:l,weekNumbers:u}},_i=`table.dp-ui__month-grid`,vi=t=>{let{core:n,layout:r,gridContext:i}=t,{months:a}=n.layout,{showOutside:o,outsideSelectable:s,headingVisible:c}=i(),l=r===`modal`||o||n.options.fixedWeeks,u=r===`docked`,d=e.f(`div`,void 0,{"data-panel":`days`}),f=e=>gi(e,n.options.weekStart,l),p=t=>Array.from({length:a},(n,r)=>e.M(t,r)),m=t=>{let n=i();if(a===1)return mi(f(t),n);let r=e.f(`div`,`dp-ui__months`);return r.append(...p(t).map(e=>mi(f(e),n))),r},h=t=>{let i=e.f(`div`);if(r===`modal`){let{locale:e,labels:r}=n.options;i.append(Gn(t,e,r,n.instanceId))}return i.append(m(t)),i},g=e=>Math.max(...p(e).map(e=>f(e).weeks.length)),_=e=>{let t=g(e),n=d.querySelector(_i),r=n?.tHead?.getBoundingClientRect().height??0,i=(n?.tBodies.item(0)?.rows.item(0))?.getBoundingClientRect().height??0,a=c?n?.caption?.getBoundingClientRect().height??0:0;return r>0&&i>0?a+r+i*t:(t+(c?2:1))*48},v=new Yr(d,{rtl:t.rtl,swipe:n.options.swipe,animate:n.options.animation,fitHeight:u,step:n.options.pageBy===`view`?a:1,renderPage:h,pageHeight:_,onCommit:(e,n)=>{t.onCommit(e,n)}}),y=()=>d.ownerDocument.activeElement,b=t=>{if(!(t instanceof Element))return null;let n=t.closest(`td.dp-ui__date[data-date]`);if(n===null||!d.contains(n)||n.classList.contains(`dp-ui__date--outside-month`)&&!s)return null;let r=e.R(n.getAttribute(`data-date`)??``);return r===null?null:{element:n,date:r}},x=()=>b(y())!==null,S=e=>d.querySelector(`.dp-ui__page:not([inert])`)?.querySelector(e)??null,C=e=>{let t=S(`td.dp-ui__date[tabindex="0"]`);return t!==null||!e?t:S(`td.dp-ui__date[data-date]:not(.dp-ui__date--outside-month)`)},w=e=>{C(e)?.focus({preventScroll:!0})},T=()=>{let e=y();return e===null||!d.contains(e)?null:{buttonClass:jn(e)}},E=e=>{let{buttonClass:t}=e;((t===null?null:S(`.${t}`))??C(!0))?.focus({preventScroll:!0})},D=e=>{let t=T();e(),t!==null&&E(t)};return{element:d,present:(e,t)=>{D(()=>{t===0?v.show(e):v.slide(e,t>0?1:-1)})},finish:()=>{v.finish()},refresh:()=>{let e=i();d.querySelectorAll(_i).forEach(t=>{hi(t,e)})},refit:()=>{if(!u||d.hidden)return;let e=`${String(_(n.view))}px`;d.style.getPropertyValue(`--dp-ui-pager-height`)!==e&&D(()=>{v.show(n.view)})},cellAt:b,focusCell:w,cellHasFocus:x,find:S,destroy:()=>{v.destroy()}}},yi=t=>{let n=document.createElement(`div`);n.className=t.className,n.setAttribute(`role`,`listbox`),n.setAttribute(`aria-label`,t.label);let r=[],i=t.focused>=0&&t.focused<t.items.length?t.focused:0,a=(t,i)=>{let a=r.at(Math.max(0,Math.min(r.length-1,i)));a&&(r.at(t)?.setAttribute(`tabindex`,`-1`),a.setAttribute(`tabindex`,`0`),a.focus({preventScroll:!0}),e.m(n,a,`nearest`))},o=e=>{let t=getComputedStyle(n).direction===`rtl`?-1:1;switch(e){case`ArrowRight`:return t;case`ArrowLeft`:return-t;case`ArrowDown`:return 3;case`ArrowUp`:return-3;default:return null}};return t.items.forEach((e,s)=>{let c=document.createElement(`button`);c.type=`button`,c.className=t.itemClass,c.setAttribute(`role`,`option`),c.setAttribute(`aria-selected`,e.selected?`true`:`false`),c.setAttribute(`aria-label`,e.name),c.setAttribute(`tabindex`,s===i?`0`:`-1`),e.selected&&c.classList.add(`${t.itemClass}--selected`),e.current&&c.classList.add(`${t.itemClass}--current`),e.disabled&&c.setAttribute(`aria-disabled`,`true`),c.textContent=e.label;let l=()=>{e.disabled||e.onPick()};c.addEventListener(`click`,l),c.addEventListener(`keydown`,e=>{let t=o(e.key);t===null?e.key===`Home`?(e.preventDefault(),a(s,0)):e.key===`End`?(e.preventDefault(),a(s,r.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l()):(e.preventDefault(),a(s,s+t))}),r.push(c),n.appendChild(c)}),requestAnimationFrame(()=>{let a=n.querySelector(`.${t.itemClass}--selected`)??r.at(i);a&&e.m(n,a,`center`)}),n},bi=e=>{let t=O(e.locale,`short`),n=O(e.locale,`long`),r=y(e.year,e.locale);return yi({className:`dp-ui__month-selection`,itemClass:`dp-ui__month-selection-item`,label:e.label,focused:e.focused-1,items:t.map((t,i)=>{let a=i+1;return{label:t,name:`${n[i]??t} ${r}`,selected:a===e.selected,current:e.current.year===e.year&&e.current.month===a,disabled:e.isDisabled(a),onPick:()=>{e.onPick(a)}}})})},xi=t=>{let n=t.querySelector(`.dp-ui__menu-item--selected`);n&&e.m(t,n,`center`)},Si=(t,n,r)=>{let i=t.at(Math.max(0,Math.min(t.length-1,r))),a=t.at(n);i&&(a?.setAttribute(`tabindex`,`-1`),i.setAttribute(`tabindex`,`0`),i.focus({preventScroll:!0}),i.parentElement&&e.m(i.parentElement,i,`nearest`))},Ci=(e,t,n)=>{let r=document.createElement(`ul`);r.className=`dp-ui__menu dp-ui__menu--${e}`,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-label`,t);let i=n.some(e=>e.selected),a=n.map((e,t)=>{let n=document.createElement(`li`);n.className=`dp-ui__menu-item`,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,e.selected?`true`:`false`);let r=e.selected||!i&&t===0;if(n.setAttribute(`tabindex`,r?`0`:`-1`),e.selected){n.classList.add(`dp-ui__menu-item--selected`);let e=document.createElement(`span`);e.innerHTML=U.check;let t=e.firstElementChild;t&&(t.setAttribute(`class`,`dp-ui__menu-item-icon`),t.setAttribute(`aria-hidden`,`true`),n.appendChild(t))}e.disabled&&n.setAttribute(`aria-disabled`,`true`);let a=document.createElement(`span`);a.className=`dp-ui__menu-item-label`,a.textContent=e.label,n.appendChild(a);let s=()=>{e.disabled||e.onPick()};return n.addEventListener(`click`,s),n.addEventListener(`keydown`,e=>{e.key===`ArrowDown`?(e.preventDefault(),Si(o,t,t+1)):e.key===`ArrowUp`?(e.preventDefault(),Si(o,t,t-1)):e.key===`Home`?(e.preventDefault(),Si(o,t,0)):e.key===`End`?(e.preventDefault(),Si(o,t,o.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())}),n}),o=a;return a.forEach(e=>r.appendChild(e)),requestAnimationFrame(()=>{xi(r)}),r},wi=e=>{let t=O(e.locale,`long`);return Ci(`month`,e.label,t.map((t,n)=>{let r=n+1;return{label:t,selected:r===e.view.month,disabled:e.isMonthDisabled({year:e.view.year,month:r}),onPick:()=>{e.onPick(r)}}}))},Ti=e=>yi({className:`dp-ui__year-selection`,itemClass:`dp-ui__year-selection-item`,label:e.label,focused:e.years.indexOf(e.focused),items:e.years.map(t=>{let n=y(t,e.locale);return{label:n,name:n,selected:t===e.selected,current:t===e.currentYear,disabled:!1,onPick:()=>{e.onPick(t)}}})}),Ei=e=>Ci(`year`,e.label,e.years.map(t=>({label:y(t,e.locale),selected:t===e.view.year,disabled:!1,onPick:()=>{e.onPick(t)}}))),Di=e=>{let{min:t,max:n}=e.yearBounds(),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Oi=(e,t)=>{let n=f(e.draft);return n?.year===t?n.month:null},ki=(e,t,n)=>(e.setAttribute(`data-panel`,t),e.id=W(n,t),e),Ai=(t,n)=>{let{core:r,rules:i}=n,{labels:a,locale:o}=r.options,s=r.view,{precision:c}=r.options,l=e=>{n.actions.jumpTo(e,`menu`)},u=e=>{l({year:e,month:r.view.month})};switch(t){case`month-menu`:return[ki(wi({locale:o,view:s,label:a.chooseMonth,isMonthDisabled:e=>i.isMonthDisabled(e),onPick:e=>{l({year:r.view.year,month:e})}}),t,r.instanceId)];case`year-menu`:return[ki(Ei({view:s,years:Di(i),label:a.chooseYear,locale:o,onPick:u}),t,r.instanceId)];case`month-grid`:{let u=c===`month`,d=u?Oi(r,s.year):s.month,f=ki(bi({year:s.year,selected:d,focused:d??s.month,current:e.G(),locale:o,label:a.chooseMonth,isDisabled:e=>i.isMonthDisabled({year:r.view.year,month:e}),onPick:e=>{u?n.actions.select({year:r.view.year,month:e,day:1}):l({year:r.view.year,month:e})}}),t,r.instanceId);return n.layout===`docked`?[f]:[Kn(s,o,a,r.instanceId),f]}case`year-grid`:{let l=c===`year`,d=l?f(r.draft)?.year??null:s.year,p=ki(Ti({selected:d,focused:d??s.year,years:Di(i),currentYear:e.G().year,label:a.chooseYear,locale:o,onPick:l?e=>{n.actions.select({year:e,month:1,day:1})}:u}),t,r.instanceId);return n.layout===`docked`||l?[p]:[qn(s,o,a,r.instanceId),p]}}},ji=`[role="option"]`,Mi=t=>{let{root:n,content:r,days:i}=t,a=`days`,o=[],s=null,c=()=>n.ownerDocument.activeElement,l=e=>{e===`days`?i.hidden=!0:(o.forEach(e=>{e.remove()}),o=[])},u=e=>{e===`days`?i.hidden=!1:(o=t.createParts(e),i.after(...o))},d=()=>{let e=s;e!==null&&(s=null,e.complete(),e.animations.forEach(e=>{e.cancel()}))},f=()=>{let e=s;s=null,e?.animations.forEach(e=>{e.cancel()})},p=(e,n,r)=>{let i=t.motion()===`none`?[]:e.filter(e=>!e.hidden&&typeof e.animate==`function`);if(i.length===0){r();return}let a=i.map(e=>e.animate([{opacity:1},{opacity:0}],{duration:n,easing:`linear`,fill:`forwards`})),o={animations:a,complete:r};s=o,Promise.all(a.map(e=>e.finished)).then(()=>{s===o&&d()},()=>void 0)},m=()=>{let e=i.getBoundingClientRect().height;e>0&&r.style.setProperty(`--dp-ui-panel-height`,`${String(e)}px`)},h=r=>{d();let s=a;if(r===s)return;s===`days`&&m();let f=n.contains(c()),h=r===`input`||s===`input`;a=r;let g=()=>{let e=()=>{l(s),u(r),t.onSwitched(r,s,f)};t.swap===void 0?e():t.swap(e,r,s)};h?g():p(s===`days`?[i]:o,e.c.PANEL_FADE_OUT,g)},g=e=>{f(),e!==a&&(l(a),a=e,u(e))},_=e=>{let t=e.closest(`[role="listbox"]`);return t===null?-1:Array.from(t.querySelectorAll(ji)).indexOf(e)},v=e=>{for(let t of o){let n=e(t);if(n)return n}return null},y=(e,t)=>t>=0?v(e=>Array.from(e.querySelectorAll(ji)).at(t)):e===null?null:v(t=>t.querySelector(`.${e}`));return{current:()=>a,settled:()=>s===null,mount:g,switchTo:h,rebuild:()=>{if(a===`days`||a===`input`||s!==null)return;let e=c(),t=e!==null&&o.some(t=>t.contains(e))?e:null,n=t===null?null:jn(t),r=t===null?-1:_(t),i=o.map(e=>e.scrollTop);l(a),u(a),o.forEach(e=>{e.setAttribute(`data-rebuilt`,``)}),requestAnimationFrame(()=>{o.forEach((e,t)=>{e.scrollTop=i.at(t)??e.scrollTop})}),t!==null&&y(n,r)?.focus({preventScroll:!0})},entry:()=>{for(let e of o){let t=e.querySelector(`[tabindex="0"]`);if(t!==null)return t}return null},destroy:f}},Ni=t=>{let{root:n,core:r,actions:i,rules:a,mode:o,layout:s}=t,c=r.options,l=nr(r,s,o),u=vi({core:r,layout:s,rtl:t.rtl,gridContext:()=>Zn(r,a,s),onCommit:(e,t)=>{i.page(e,t)}}),d=e.f(`div`,`dp-ui__content`);d.append(u.element);let f=Mi({root:n,content:d,days:u.element,motion:t.motion,createParts:e=>e===`input`?jr({core:r,actions:i,rules:a}):Ai(e,{core:r,actions:i,rules:a,layout:s}),swap:(e,i,a)=>{let o=J(n);o===null||i!==`input`&&a!==`input`?e():Tr(o,()=>{e(),zn(o,i,r.layout.months)},t.motion())},onSwitched:t.onSwitched}),p=On({labels:c.labels,visible:c.footerExplicit??o!==`inline`,todayButton:c.todayButton,clearButton:c.clearButton!==!1}),m=e.f(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`});return n.replaceChildren(l.element,d,p,m),{header:l,pages:u,panels:f,liveRegion:m}},Pi=[`.dp-ui__icon-button`,`.dp-ui__menu-button`,`.dp-ui__text-button`,`.dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator`,`.dp-ui__menu-item`,`.dp-ui__year-selection-item`,`.dp-ui__month-selection-item`].join(`, `),Fi=t=>{let{core:n,actions:r,rules:i,mode:a}=t,o=a===`modal`?`modal`:`docked`,c=new AbortController,l=e.f(`div`,`dp-ui__calendar`),u,d=0,f=()=>l.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(n.input).direction===`rtl`,p=()=>J(l),m=()=>e.T(n.options.precision),h=e=>u.pages.cellAt(e),g=(e,t=!0)=>{u.header.docked?.setPanel(e);let r=p();r!==null&&(r.classList.toggle(Pn,Ln(e,m())),t&&zn(r,e,n.layout.months))},_=e=>{e===null?u.pages.focusCell(!0):e.focus({preventScroll:!0})},v=e=>{let t=tr(e);return t===null?null:u.header.element.querySelector(t)??u.pages.find(t)},y=(e,t,n)=>{e===`days`&&u.pages.refit(),n&&_(e===`days`?t===`input`?null:v(t):u.panels.entry())},b=()=>{u=Ni({root:l,core:n,actions:r,rules:i,mode:a,layout:o,rtl:f(),motion:()=>H(n.options.animation),onSwitched:y}),u.pages.present(n.view,0),u.panels.mount(n.panel),g(n.panel),u.header.modal?.setInputView(n.panel===`input`),Dn(l,s(n.draft)),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=0,g(u.panels.current()),u.pages.refit()})},x=()=>{u.panels.destroy(),u.pages.destroy(),u.header.modal?.destroy()},S=()=>{c.signal.aborted||(g(u.panels.current()),u.pages.refit(),_(u.panels.entry()))},C=(e,t,r)=>{u.header.docked?.setView(e);let i=r!==`api`&&u.panels.current()===`days`&&u.panels.settled();u.pages.present(e,i?t:0),u.panels.rebuild(),r!==`api`&&Zt(u.liveRegion,Qn(n,e))},w=()=>{let e=u.pages.cellHasFocus();u.pages.refresh(),e&&u.pages.focusCell(!1)},T=e=>{u.pages.finish(),g(e,!1),u.header.modal?.setInputView(e===`input`),u.header.modal?.setText(Y(n)),u.panels.switchTo(e)},E=()=>{u.pages.refresh(),u.panels.rebuild(),u.header.modal?.setText(Y(n)),Dn(l,s(n.draft)),u.panels.current()===m()&&Zt(u.liveRegion,Y(n))};return b(),(e=>{let{events:t}=n;t.on(`change:view`,e=>{C(e.view,e.delta,e.source)},e),t.on(`change:draft`,E,e),t.on(`change:focus`,w,e),t.on(`change:panel`,e=>{T(e.panel)},e),Nn(l,e,{actions:r,panel:()=>n.panel,home:m(),cellAt:h}),fr(l,e,{core:n,actions:r,layout:o,home:m(),cellAt:h,isRtl:f}),Sn(l,Pi,e)})(c.signal),{element:l,focusInitial:S,update:()=>{if(c.signal.aborted)return;let e=l.contains(l.ownerDocument.activeElement);x(),b(),e&&S()},destroy:()=>{if(c.signal.aborted)return;c.abort(),cancelAnimationFrame(d),x();let e=p();e!==null&&(e.classList.remove(Pn,Fn),Rn(e,1)),l.remove()}}},Ii=e=>({year:e.year,month:e.month}),Li=e=>{let t=f(e.draft);return t===null?e.view:Ii(t)},Ri=(t,n)=>{let{minDate:r,maxDate:i}=t.options,a=n.yearBounds(),o={year:a.min,month:1},s={year:a.max,month:12},c=r!==null&&e.V(o,r)>0,l=i!==null&&e.V(i,s)>0;return{first:c?Ii(r):o,last:l?Ii(i):s}},X=(t,n)=>e.V(n.first,t)<0?n.first:e.V(t,n.last)<0?n.last:t,zi=t=>{let n=e.f(`div`,`dp-ui__top-bar`);return n.append(G(`close`,t.close,U.close),q(`save`,t.save)),n},Bi=t=>{let{labels:n,switchView:r}=t,i=e.f(`div`,`dp-ui__header dp-ui__header--range`),a=t.fullscreen?zi(n):null;a!==null&&i.append(a);let o=e.f(`div`,`dp-ui__header-text`),s=e.f(`div`,`dp-ui__supporting-text`);s.textContent=n.rangeTitle;let c=Un(t.text,t.animate);o.append(s,c.element),i.append(o);let l=r===null?null:En(n,r.panelId);return l!==null&&i.append(l.button),{element:i,setText:e=>{c.setText(e)},setInputView:e=>{a!==null&&(a.hidden=e),l?.setInputView(e)},destroy:()=>{c.destroy()}}},Vi=(t,n)=>{let r=e.f(`div`,`dp-ui__weekdays-bar`,{"aria-hidden":`true`}),i=te(t,`narrow`);for(let t=0;t<7;t++){let a=e.f(`span`,`dp-ui__weekday`);a.textContent=i.at((n+t)%7)??``,r.append(a)}return r},Hi=(e,t)=>t===`x`?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight,Ui=(e,t)=>t===`x`?e.clientX:e.clientY,Wi=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},Gi=(e,t,n)=>{t===`x`?e.scrollLeft+=n:e.scrollTop+=n},Ki=(t,n,r=`x`,i={})=>{let a=null,o=0,s=0,c=0,l=!1;r===`x`&&t.addEventListener(`wheel`,e=>{Hi(t,r)&&(Math.abs(e.deltaY)<=Math.abs(e.deltaX)||(e.preventDefault(),t.scrollLeft+=e.deltaY))},{signal:n,passive:!1}),t.addEventListener(`pointerdown`,e=>{e.pointerType===`mouse`&&e.button===0&&Hi(t,r)&&(a=e.pointerId,o=Ui(e,r),s=o,c=0,l=!1)},{signal:n}),t.addEventListener(`pointermove`,n=>{if(n.pointerId!==a)return;let i=Ui(n,r);c=i-o,!(!l&&Math.abs(c)<e.s.DRAG_START_PX)&&(l||(l=!0,Wi(t,n.pointerId)),Gi(t,r,s-i),s=i)},{signal:n}),t.addEventListener(`selectstart`,e=>{a!==null&&e.preventDefault()},{signal:n});let u=e=>{e.pointerId===a&&(a=null,t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),l&&e.type===`pointerup`&&c!==0&&i.onDragEnd?.(c<0?1:-1))};t.addEventListener(`pointerup`,u,{signal:n}),t.addEventListener(`pointercancel`,u,{signal:n}),t.addEventListener(`click`,e=>{l&&(l=!1,e.stopPropagation(),e.preventDefault())},{signal:n,capture:!0})},qi=(e,t,n)=>({...Xn(e,t,!1),outsideSelectable:!1,weekNumbers:!1,headingVisible:!0,weekdaysVisible:n,rangeRole:t=>d(e.draft,t)}),Ji=(e,t,n)=>mi(gi(n,e.options.weekStart,!1),qi(e,t,!1)),Yi=`td.dp-ui__date[data-date]`,Xi=t=>{let{core:n,rules:r}=t,i=new AbortController,a=e.f(`div`,`dp-ui__month-list`),o=[],s=null,c=0,l=!1,u=0,d=(n,r)=>Array.from({length:r},(r,i)=>t.render(e.M(n,i))),f=n=>{if(s===null)return;let r=e.M(s,o.length),i=e.V(r,t.bounds().last)+1,c=Math.min(n,i);if(c<=0)return;let l=d(r,c);o.push(...l),a.append(...l)},p=n=>{if(s===null)return;let r=e.V(t.bounds().first,s),i=Math.min(n,r);if(i<=0)return;let c=e.M(s,-i),l=d(c,i),u=a.scrollTop,f=a.scrollHeight;s=c,o.unshift(...l),a.prepend(...l),a.scrollTop=u+a.scrollHeight-f},m=n=>{if(s===null)return;let r=X(n,t.bounds());p(e.V(r,s)),f(e.V(e.M(s,o.length-1),r))},h=t=>{if(s===null)return null;let n=e.V(s,t);return n<0?null:o.at(n)??null},g=e=>{let n=X(e,t.bounds());m(n);let r=h(n);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;a.scrollTop+=i},_=()=>{a.scrollTop<a.clientHeight&&p(6),a.scrollHeight-a.scrollTop-a.clientHeight<a.clientHeight&&f(6)},v=t=>{let n=a.getBoundingClientRect().top,r=o.map(e=>({table:e,top:e.getBoundingClientRect().top-n,height:e.getBoundingClientRect().height})),i=Math.max(r.reduce((e,t,n)=>t.top<=1?n:e,0),0),s=r.at(i);if(s===void 0)return null;let c=s.height>0?Math.max(-s.top,0)/s.height:0,l=r.at(i+1)?.table??s.table;return t===1?c>e.s.COMMIT_FRACTION?l:s.table:c<1-e.s.COMMIT_FRACTION?s.table:l},y=()=>{l&&(window.clearTimeout(u),l=!1,_())},b=t=>{y(),_();let r=v(t);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;H(n.options.animation)===`full`?(l=!0,u=window.setTimeout(y,e.c.SNAP_SCROLL_FALLBACK),a.scrollTo({top:a.scrollTop+i,behavior:`smooth`})):a.scrollTop+=i},x=e=>{if(!(e instanceof Element))return null;let t=e.closest(Yi);return t!==null&&a.contains(t)?t:null},S=t=>{m(Ii(t));let n=a.querySelector(`${Yi}[data-date="${e.U(t)}"]`);n!==null&&(n.focus({preventScroll:!0}),e.m(a,n,`nearest`))},C=()=>{let e=qi(n,r,!1);o.forEach(t=>{hi(t,e)})},w=t.bounds(),T=X(Li(n),w),E=X(e.M(T,-2),w),D=X(e.M(T,9),w),ee=e.V(E,D)+1;return ee>0&&(s=E,o.push(...d(E,ee)),a.append(...o)),a.addEventListener(`scroll`,()=>{c===0&&(c=requestAnimationFrame(()=>{c=0,l||_()}))},{passive:!0,signal:i.signal}),a.addEventListener(`scrollend`,y,{signal:i.signal}),Ki(a,i.signal,`y`,{onDragEnd:b}),{element:a,scrollToMonth:g,refresh:C,cellAt:x,focusCell:S,ensureMonth:m,reveal:g,present:(e,t,n)=>{n===`api`?g(e):m(e)},destroy:()=>{i.abort(),cancelAnimationFrame(c),c=0,window.clearTimeout(u),l=!1}}},Zi=t=>{let n=e.f(`div`,`dp-ui__navigation dp-ui__navigation--months`),r=Cn(t);return n.append(G(`prev-month`,t.previousMonth,U.keyboardArrowLeft,r.previousMonth),G(`next-month`,t.nextMonth,U.keyboardArrowRight,r.nextMonth)),n},Qi=t=>{let{core:n,actions:r,rules:i}=t,a=vi({core:n,layout:`docked`,rtl:t.rtl,gridContext:()=>qi(n,i,!0),onCommit:(e,t)=>{r.page(e,t)}});return{element:a.element,cellAt:e=>a.cellAt(e)?.element??null,focusCell:t=>{let n=a.find(`td.dp-ui__date[data-date][data-date="${e.U(t)}"]`);n===null?a.focusCell(!0):n.focus({preventScroll:!0})},refresh:()=>{a.refresh()},reveal:()=>{a.refit()},present:(e,t,n)=>{a.present(e,n===`api`?0:t)},destroy:()=>{a.destroy()}}};function $i(e){let n;try{n=e.value()}catch(e){return t(e),null}let r=Wt(n,`range`,`day`);if(r?.mode!==`range`)return null;let{start:i,end:a}=r;return i===null||a===null?null:{start:i,end:a}}const ea=t=>{let{core:n,actions:r,rules:i,signal:a}=t,{presets:o,labels:s,limits:c}=n.options,u=e.f(`div`,`dp-ui__presets`,{role:`group`,"aria-label":s.presets}),d=o.map(t=>{let n=e.f(`button`,`dp-ui__preset`,{type:`button`});return n.textContent=t.label,n}),f=d.map(()=>null);u.append(...d);let p=()=>{o.forEach((e,t)=>{let r=d[t],a=$i(e);f[t]=a;let o=!1,s=!1;if(a!==null){let e={mode:`range`,...a};o=bt(e,c,e=>i.isDisabled(e)),s=l(n.draft,e)}r.disabled=!o,r.setAttribute(`aria-pressed`,s?`true`:`false`)})};return u.addEventListener(`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button.dp-ui__preset`),n=d.findIndex(e=>e===t);if(n<0)return;let i=f[n];i!==null&&r.selectRange(i.start,i.end)},{signal:a}),Ki(u,a),p(),{element:u,refresh:p,setHidden:e=>{u.hidden=e}}},ta=`dp-ui__container--range`,na=`dp-ui__container--fullscreen`,ra=`dp-ui__container--presets`,ia=[ta,ra,na,Fn],aa=(e,t)=>e.options.footerExplicit??t!==`inline`,oa=(e,t)=>{let{core:n,actions:r,rules:i,rtl:a}=e,{labels:o,locale:s,weekStart:c}=n.options;if(n.layout.months>1){let e=Qi({core:n,actions:r,rules:i,rtl:a});return t.append(Zi(o),e.element),e}let l=Xi({core:n,rules:i,render:e=>Ji(n,i,e),bounds:()=>Ri(n,i)});return t.append(Vi(s,c),l.element),l},sa=t=>{let{root:n,core:r,actions:i,rules:a,mode:o,fullscreen:s,signal:c}=t,l=r.options,u=Bi({labels:l.labels,animate:l.animation,text:Y(r),fullscreen:s,switchView:l.viewSwitch?{panelId:W(r.instanceId,`input`)}:null}),d=e.f(`div`,`dp-ui__range`,{"data-panel":`days`}),f=oa(t,d),p=Mi({root:n,content:n,days:d,motion:t.motion,createParts:e=>e===`input`?jr({core:r,actions:i,rules:a}):[],swap:t.swap,onSwitched:t.onSwitched}),m=On({labels:l.labels,visible:aa(r,o),todayButton:l.todayButton,clearButton:l.clearButton!==!1}),h=e.f(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`}),g=r.layout.presets===`none`?null:ea({core:r,actions:i,rules:a,signal:c}),_=r.layout.presets===`column`;return n.replaceChildren(u.element,...g===null?[]:[g.element],d,m,h),{header:u,days:f,panels:p,liveRegion:h,applyChrome:e=>{let t=e===`input`;u.setInputView(t),u.setText(Y(r)),g?.setHidden(t);let i=J(n);i!==null&&(i.classList.add(ta),i.classList.toggle(ra,_),i.classList.toggle(na,s&&!t),zn(i,e,r.layout.months))},refreshPresets:()=>{g?.refresh()}}},ca=[`.dp-ui__icon-button`,`.dp-ui__text-button`,`.dp-ui__preset`,`.dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator`].join(`, `),la=e=>e===`input`?`input`:`days`,ua=t=>{let{core:n,actions:r,rules:i,mode:a,fullscreen:c}=t,l=new AbortController,u=e.f(`div`,`dp-ui__calendar`),d,f=0,p=null,m=()=>H(n.options.animation),h=()=>u.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(n.input).direction===`rtl`,g=t=>{let n=d.days.cellAt(t),r=e.R(n?.dataset.date??``);return n===null||r===null?null:{element:n,date:r}},_=()=>{let{draft:e,value:t}=n,r=o(e)&&o(t);Dn(u,s(e)&&!r)},v=()=>{d.days.reveal(Li(n))},y=(e,t,r)=>{e===`days`&&v(),r&&(e===`input`?d.panels.entry()?.focus({preventScroll:!0}):d.days.focusCell(n.focus))},b=(e,t)=>{let n=()=>{d.applyChrome(t),e()};p?.cancel(),p=null;let r=J(u);r===null?n():p=Tr(r,n,m())},x=()=>{d=sa({root:u,core:n,actions:r,rules:i,mode:a,fullscreen:c,rtl:h(),signal:l.signal,motion:m,swap:b,onSwitched:y}),d.days.present(n.view,0,`api`),d.panels.mount(la(n.panel)),d.applyChrome(d.panels.current()),_(),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=0,d.applyChrome(d.panels.current()),d.panels.current()===`days`&&v()})},S=()=>{p?.cancel(),p=null,d.panels.destroy(),d.days.destroy(),d.header.destroy()},C=()=>{if(l.signal.aborted)return;cancelAnimationFrame(f),f=0;let e=d.panels.current();d.applyChrome(e),e===`input`?d.panels.entry()?.focus({preventScroll:!0}):(v(),d.days.focusCell(n.focus))},w=()=>{d.days.refresh(),d.refreshPresets(),d.header.setText(Y(n)),_(),d.panels.current()===`days`&&Zt(d.liveRegion,Y(n))},T=()=>{let e=g(u.ownerDocument.activeElement)!==null;d.days.refresh(),e&&d.days.focusCell(n.focus)},E=(e,t,r)=>{let i=d.panels.current()===`days`&&d.panels.settled();d.days.present(e,i?t:0,r),r!==`api`&&n.layout.months>1&&Zt(d.liveRegion,Qn(n,e))};return x(),(e=>{let{events:t}=n;t.on(`change:view`,e=>{E(e.view,e.delta,e.source)},e),t.on(`change:draft`,w,e),t.on(`change:active-end`,()=>{d.days.refresh()},e),t.on(`change:value`,_,e),t.on(`change:focus`,T,e),t.on(`change:panel`,e=>{d.panels.switchTo(la(e.panel))},e),Nn(u,e,{actions:r,panel:()=>n.panel,home:`days`,cellAt:g}),fr(u,e,{core:n,actions:r,layout:`range`,home:`days`,cellAt:g,isRtl:h}),Sn(u,ca,e)})(l.signal),{element:u,focusInitial:C,update:()=>{if(l.signal.aborted)return;let e=u.contains(u.ownerDocument.activeElement);S(),x(),e&&C()},destroy:()=>{if(l.signal.aborted)return;l.abort(),cancelAnimationFrame(f),S();let e=J(u);e!==null&&(e.classList.remove(...ia),Rn(e,1)),u.remove()}}};var da=class{core;deps;mounted=null;generation=0;constructor(e,t,n){this.core=e,this.deps=n}get surface(){return this.mounted?.host.root??null}async mount(t){this.release();let n=this.createHost(t);if(n===null)return;let{core:r}=this,{options:i}=r,{actions:a,rules:o,theme:s}=this.deps,c=++this.generation;s.applyTo(n.root),en(n.root,i.animation);let l=e.y()?1/0:window.innerWidth,u={core:r,actions:a,rules:o,mode:t,fullscreen:e.E(i.mode,t,l,i.fullscreenBelow)},d=i.mode===`range`?ua(u):Fi(u);this.mounted={mode:t,host:n,view:d,stopModality:Qt(n.root),stopSchemeWatch:t===`inline`?e.u(()=>{s.applyTo(n.root)}):()=>void 0},n.body.append(d.element),await n.open(),c===this.generation&&t!==`inline`&&d.focusInitial()}async unmount(){let e=this.mounted;if(e===null)return;let t=++this.generation;await e.host.close(),t===this.generation&&this.mounted===e&&this.release()}update(){let e=this.mounted;e!==null&&(this.deps.theme.applyTo(e.host.root),en(e.host.root,this.core.options.animation),e.view.update())}destroy(){this.generation+=1,this.release()}release(){let e=this.mounted;e!==null&&(this.mounted=null,e.view.destroy(),e.host.destroy(),e.stopModality(),e.stopSchemeWatch())}createHost(t){let{core:n}=this,{options:r}=n,{actions:i}=this.deps,a=fn(r.labels,r.mode,r.precision);if(t===`inline`){let t=e.p(r.inline.container);return t===null?null:new e.r({container:t,label:a})}return t===`modal`?new e.i({parent:e.p(r.appendTo)??n.host,label:a,allowPageScroll:r.allowPageScroll,onCancel:e=>{i.cancel(e)}}):new e.n({host:n.host,anchor:n.input,instanceId:n.instanceId,rtl:getComputedStyle(n.input).direction===`rtl`,label:a,ignoreOutsideClick:r.behavior.ignoreOutsideClick,inside:n.endInput===null?[]:[n.endInput],onOutside:()=>{i.cancel(`outside`)},onEscape:()=>{i.cancel(`escape`)}})}},fa=class{core;fields=[];initial;constructor(e){this.core=e,this.initial=e.value}bind(e){let{input:t}=this.core;this.initial=this.core.value;let n=this.splitEnd();this.bindField(t,n===null?null:`start`),n!==null&&this.bindField(n,`end`),this.fields.length!==0&&t.form?.addEventListener(`reset`,()=>{setTimeout(()=>{this.handleReset()},0)},{signal:e})}sync(){for(let e of this.fields)e.hidden.value=this.valueOf(e.end)}dispatchCommit(){let{input:e}=this.core;e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}restore(){for(let e of this.fields)e.hidden.remove(),e.input.setAttribute(`name`,e.name);this.fields=[]}splitEnd(){return this.core.options.mode===`range`?this.core.endInput:null}bindField(e,t){let n=e.getAttribute(`name`);n!==null&&n!==``&&(e.removeAttribute(`name`),this.fields.push({input:e,name:n,hidden:this.createHidden(e,n),end:t}))}valueOf(e){let{value:t,options:n}=this.core;if(e===null||t.mode!==`range`)return un(t,n.precision);let r=e===`start`?t.start:t.end;return r===null?``:R(r,`day`)}createHidden(e,t){let n=e.ownerDocument.createElement(`input`);return n.type=`hidden`,n.name=t,n.classList.add(`dp-ui__form-value`),e.insertAdjacentElement(`afterend`,n),n}writeFields(e){let{core:t}=this,{pattern:n,precision:r}=t.options,i=this.splitEnd();if(i===null||e.mode!==`range`){t.input.value=an(e,n,r);return}let a=e=>e===null?``:z(e,n,`day`);t.input.value=a(e.start),i.value=a(e.end)}handleReset(){let{core:e}=this,{mode:t}=e.options,n=this.initial.mode===t?this.initial:i(t);e.setValue(n),this.writeFields(n),this.sync()}};const pa=`aria-describedby`,ma=e=>(e.getAttribute(pa)??``).split(/\s+/).filter(e=>e!==``);function ha(t,n,r,i){let a=e.f(`span`,`dp-ui__visually-hidden`,{id:r}),o=e.f(`span`,void 0,{"aria-live":`polite`}),s=e.f(`span`);return s.textContent=i,a.append(o,` `,s),n.append(a),t.setAttribute(pa,[...ma(t),r].join(` `)),{setHint:e=>{s.textContent!==e&&(s.textContent=e)},setError:e=>{let t=e??``;o.textContent!==t&&(o.textContent=t)},destroy:()=>{a.remove();let e=ma(t).filter(e=>e!==r);e.length===0?t.removeAttribute(pa):t.setAttribute(pa,e.join(` `))}}}const ga=`dp-ui--error`;function _a(e,t,n){e.setAttribute(`aria-invalid`,`true`),t.classList.add(ga),e.setCustomValidity(n)}function va(e,t){e.removeAttribute(`aria-invalid`),t.classList.remove(ga),e.setCustomValidity(``)}function ya(t,n,r){let i=t.trim(),a=n.trim();if(i===``&&a===``)return{kind:`empty`};let o=i===``?null:e._(i,r);if(i!==``&&o===null)return{kind:`invalid`,field:`start`};let s=a===``?null:e._(a,r);return a!==``&&s===null?{kind:`invalid`,field:`end`}:o===null||s===null?{kind:`partial`}:e.N(o,s)>0?{kind:`reversed`}:{kind:`range`,start:o,end:s}}var ba=class{core;emitter;deps;dirty=!1;constructor(e,t,n){this.core=e,this.emitter=t,this.deps=n}get end(){return this.core.options.mode===`range`?this.core.endInput:null}bind(e){let{end:t}=this;if(t!==null)for(let n of[this.core.input,t])n.addEventListener(`blur`,()=>{this.commit()},{signal:e}),n.addEventListener(`input`,()=>{this.dirty=!0,this.applyMask(n)},{signal:e}),n.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.commit())},{signal:e})}write(e){let{end:t}=this;if(t===null)return;let n=e.mode===`range`?e:null;this.core.input.value=this.format(n?.start??null),t.value=this.format(n?.end??null),this.dirty=!1,this.clearError()}readInitial(){let{end:t}=this,n=i(`range`);if(t===null)return n;let r=this.readDate(this.core.input.value),a=this.readDate(t.value);return r===null||a===null||e.N(r,a)>0?n:{mode:`range`,start:r,end:a}}markInvalid(e){let{end:t}=this;if(t===null)return;let{input:n,host:r}=this.core;_a(n,r,e),_a(t,r,e),this.deps.describe(n,e),this.deps.describe(t,e),this.emitter.emit(`error`,{code:`invalid-value`,message:e})}clearError(){let{end:e}=this;if(e===null)return;let{input:t,host:n}=this.core;va(t,n),va(e,n),this.deps.describe(t,null),this.deps.describe(e,null)}format(e){return e===null?``:z(e,this.core.options.pattern,`day`)}readDate(e){let{pattern:t}=this.core.options,n=dn(e,`single`,`day`)??ln(e,`single`,t,`day`);return n?.mode===`single`?n.date:null}applyMask(t){let{options:n}=this.core;if(!n.mask)return;let r=e.t(t.value,n.pattern);r!==t.value&&(t.value=r,t.setSelectionRange(r.length,r.length))}commit(){let{end:e}=this;if(e===null||!this.dirty)return;let{options:t,input:n}=this.core,r=ya(n.value,e.value,t.pattern);r.kind!==`partial`&&(r.kind===`empty`?this.settle(i(`range`)):r.kind===`invalid`?this.fail(r.field,`invalid-date`,t.labels.invalidDate):r.kind===`reversed`?this.fail(`end`,`invalid-date`,t.labels.invalidRange):this.commitRange(r.start,r.end))}commitRange(e,t){let{options:n}=this.core,r={mode:`range`,start:e,end:t},i=e=>this.deps.rules.unavailableReason(e),a=B(r,n.limits,i);if(a===null){this.settle(r);return}let o=i(e)===null?`end`:`start`;this.fail(o,`unavailable-date`,Ar(a,n),a)}settle(e){this.write(e),this.deps.onTyped(e)}fail(e,t,n,r){let i=e===`start`?this.core.input:this.end;if(i===null)return;this.clearError(),_a(i,this.core.host,n),this.deps.describe(i,n);let a=i.value;r===void 0?this.emitter.emit(`error`,{code:t,message:n,input:a}):this.emitter.emit(`error`,{code:t,message:n,input:a,reason:r})}},xa=class{core;emitter;deps;split;descriptions=/* @__PURE__ */ new Map;constructor(e,t,n){this.core=e,this.emitter=t,this.deps=n,this.split=new ba(e,t,{rules:n.rules,onTyped:e=>{n.onTyped(e)},describe:(e,t)=>{this.describe(e,t)}})}bind(e){if(this.describeFields(e),this.split.end!==null){this.split.bind(e);return}let{input:t}=this.core;t.addEventListener(`blur`,()=>{this.commit()},{signal:e}),t.addEventListener(`input`,()=>{this.applyMask()},{signal:e}),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.commit())},{signal:e})}write(e){this.split.end===null?(this.core.input.value=an(e,this.core.options.pattern,this.core.options.precision),this.clearError()):this.split.write(e)}readInitial(){if(this.split.end!==null)return this.split.readInitial();let{mode:e,pattern:t,precision:n}=this.core.options,r=this.core.input.value;return dn(r,e,n)??ln(r,e,t,n)??i(e)}evaluate(e){let{mode:t,pattern:n,limits:r,precision:i}=this.core.options,a=ln(e,t,n,i);if(a===null)return{kind:`invalid`};if(o(a))return{kind:`empty`};let s=B(a,r,e=>this.deps.rules.unavailableReason(e));return s===null?{kind:`valid`,selection:a}:{kind:`unavailable`,selection:a,reason:s}}markInvalid(e){this.split.end===null?(this.showError(e),this.emitter.emit(`error`,{code:`invalid-value`,message:e})):this.split.markInvalid(e)}destroy(){this.clearError(),this.split.clearError(),this.descriptions.forEach(e=>{e.destroy()}),this.descriptions.clear()}describeFields(t){let{input:n,host:r,instanceId:i}=this.core,{end:a}=this.split,o=()=>{let{pattern:t,precision:n,labels:r}=this.core.options;return pt(t,n,e.S(r))},s=[[n,`input-description`]];a!==null&&s.push([a,`end-input-description`]);for(let[e,t]of s){let n=W(i,t);this.descriptions.set(e,ha(e,r,n,o()))}this.core.events.on(`change:options`,()=>{let e=o();this.descriptions.forEach(t=>{t.setHint(e)})},t)}describe(e,t){this.descriptions.get(e)?.setError(t)}applyMask(){let{input:t,options:n}=this.core;if(!n.mask||n.mode!==`single`||n.precision!==`day`)return;let r=e.t(t.value,n.pattern);r!==t.value&&(t.value=r,t.setSelectionRange(r.length,r.length))}commit(){let e=this.core.input.value,t=this.evaluate(e);if(t.kind===`empty`)this.clearError(),this.deps.onTyped(i(this.core.options.mode));else if(t.kind===`valid`)this.write(t.selection),this.deps.onTyped(t.selection);else if(t.kind===`invalid`){let t=this.core.options.labels.invalidDate;this.showError(t),this.emitter.emit(`error`,{code:`invalid-date`,message:t,input:e})}else{let{reason:n}=t,r=Ar(n,this.core.options);this.showError(r),this.emitter.emit(`error`,{code:`unavailable-date`,message:r,input:e,reason:n})}}showError(e){_a(this.core.input,this.core.host,e),this.describe(this.core.input,e)}clearError(){va(this.core.input,this.core.host),this.describe(this.core.input,null)}};const Sa=`dp-ui__container`,Ca=/\s+/;function wa(e){return e.split(Ca).filter(e=>e!==``)}var Ta=class{core;tokens=[];constructor(e){this.core=e}applyHost(){this.core.host.setAttribute(`data-theme`,this.core.options.theme)}applyTo(t){let{options:n,input:r}=this.core;t.setAttribute(`data-theme`,n.theme),t.setAttribute(`data-color-scheme`,n.colorScheme===`auto`?e.l(this.core.host):n.colorScheme),t.classList.remove(...this.tokens),this.tokens=wa(n.cssClass),t.classList.add(...this.tokens),(t.classList.contains(Sa)?t:t.querySelector(`.${Sa}`))?.classList.toggle(`dp-ui__container--rtl`,getComputedStyle(r).direction===`rtl`)}destroy(){this.core.host.removeAttribute(`data-theme`),this.tokens=[]}};const Ea=(e,t,n,r)=>{let i=a(e);return i.length===0?``:e.mode===`multiple`?_n(n,i.length,t):i.map(e=>se(e,r,t,`long`)).join(tn)},Z=`dp-ui__input--active`;var Da=class{core;deps;toggle=null;expanded=!1;release=null;constructor(e,t,n){this.core=e,this.deps=n}bind(e){if(this.releaseToggle(),this.core.options.inline.enabled||e.aborted)return;let{input:t}=this.core;this.bindField(t,`start`,e);let n=this.splitEnd();n!==null&&(this.bindField(n,`end`,e),this.core.events.on(`change:active-end`,()=>{this.markActive()},e)),this.bindToggle(e)}setExpanded(e){this.expanded=e,this.toggle?.setAttribute(`aria-expanded`,String(e)),this.markActive()}updateLabel(){if(this.toggle===null)return;let{labels:e,locale:t,precision:n}=this.core.options,r=Ea(this.core.value,t,e.multipleSelected,n),i=r===``?e.openCalendar:`${e.openCalendar}, ${r}`;this.toggle.setAttribute(`aria-label`,i)}destroy(){this.releaseToggle(),this.core.input.classList.remove(Z),this.core.endInput?.classList.remove(Z)}splitEnd(){return this.core.options.mode===`range`?this.core.endInput:null}bindField(e,t,n){let r=!1;e.addEventListener(`pointerdown`,()=>{r=!0},{signal:n}),e.addEventListener(`click`,()=>{let n=r;r=!1,(!this.expanded||n)&&this.request(`pointer`,t,e)},{signal:n}),e.addEventListener(`keydown`,n=>{n.altKey&&n.key===`ArrowDown`&&(n.preventDefault(),this.request(`keyboard`,t,e))},{signal:n})}markActive(){let e=this.splitEnd(),{input:t}=this.core;if(e===null){t.classList.remove(Z);return}let n=this.expanded?this.core.activeEnd:null;t.classList.toggle(Z,n===`start`),e.classList.toggle(Z,n===`end`)}request(e,t,n=this.core.input){n.disabled||this.deps.open(e,t)}bindToggle(t){let n=e.p(this.core.options.toggleButton,this.core.host);if(n===null)return;let r=/* @__PURE__ */ new Map,i=(e,t)=>{r.has(e)||r.set(e,n.getAttribute(e)),n.setAttribute(e,t)};i(`aria-haspopup`,`dialog`),n.tagName!==`BUTTON`&&(i(`role`,`button`),i(`tabindex`,`0`),n.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.request(`toggle`,`start`))},{signal:t})),n.addEventListener(`click`,()=>{this.request(`toggle`,`start`)},{signal:t}),this.toggle=n,i(`aria-expanded`,String(this.expanded)),i(`aria-label`,this.core.options.labels.openCalendar),this.updateLabel();let a=()=>{t.removeEventListener(`abort`,a),r.forEach((e,t)=>{e===null?n.removeAttribute(t):n.setAttribute(t,e)}),this.toggle===n&&(this.toggle=null),this.release===a&&(this.release=null)};this.release=a,t.addEventListener(`abort`,a,{once:!0})}releaseToggle(){this.release?.()}};function Q(e){return e.year*12+e.month-1}var Oa=class{core;emitter;lists=null;constructor(e,t){this.core=e,this.emitter=t}isDisabled(e){return this.unavailableReason(e)!==null}unavailableReason(e){switch(this.core.options.precision){case`day`:return this.dayReason(e);case`month`:return this.monthReason(e);case`year`:return this.yearReason(e.year)}}isSelectable(e,t){return!this.isDisabled(e)&&!this.guardFor(t)(e)}isMonthDisabled(t){let n=e.L(t),r=e.P(t.year,t.month,1),i=e.P(t.year,t.month,n);if(r===null||i===null)return!0;let{minDate:a,maxDate:o}=this.core.options,s=this.yearBounds();if(t.year<s.min||t.year>s.max||a!==null&&e.N(i,a)<0||o!==null&&e.N(r,o)>0)return!0;for(let e=1;e<=n;e+=1)if(this.dayReason({year:t.year,month:t.month,day:e})===null)return!1;return!0}yearBounds(){let{minDate:t,maxDate:n,yearRange:r}=this.core.options,i=e.G(),a=i.year-r.before,o=i.year+r.after;return{min:t===null?a:Math.max(a,t.year),max:n===null?o:Math.min(o,n.year)}}clampView(e){let{minDate:t,maxDate:n}=this.core.options,r=this.yearBounds(),i=r.min*12,a=r.max*12+11;t!==null&&(i=Math.max(i,Q(t))),n!==null&&(a=Math.min(a,Q(n)));let o=this.core.layout.months-1;o>0&&(a=Math.max(i,a-o));let s=Math.min(Math.max(Q(e),i),a),c=Math.floor(s/12);return{year:c,month:s-c*12+1}}destroy(){this.lists=null}monthReason(e){if(!this.isMonthDisabled(e))return null;let{minDate:t,maxDate:n}=this.core.options,r=this.yearBounds(),i=Q(e),a=r.min*12,o=r.max*12+11;return t!==null&&(a=Math.max(a,Q(t))),n!==null&&(o=Math.min(o,Q(n))),i<a?`min`:i>o?`max`:`disabled`}yearReason(e){let t=this.yearBounds();return e<t.min?`min`:e>t.max?`max`:null}dayReason(t){let{minDate:n,maxDate:r}=this.core.options,i=this.yearBounds();if(n!==null&&e.N(t,n)<0||t.year<i.min)return`min`;if(r!==null&&e.N(t,r)>0||t.year>i.max)return`max`;let a=this.getLists(),o=e.U(t);return a.disabled.has(o)||a.enabled!==null&&!a.enabled.has(o)?`disabled`:a.source.disabledWeekdays.includes(e.F(t))?`weekday`:this.isCallbackDisabled(t,a)?`disabled`:null}isCallbackDisabled(n,r){let{isDateDisabled:i}=r.source;if(i===null)return!1;let a=e.U(n),o=r.callbackResults.get(a);if(o!==void 0)return o;let s=!1;try{s=i(e.H(n))}catch(e){t(e)}return r.callbackResults.set(a,s),s}guardFor(t){let n=this.getLists(),r=n.guardDraft;if(n.guard!==null&&r!==null&&l(r,t))return n.guard;let{maxDate:i,limits:a}=n.source,o={year:this.yearBounds().max,month:12,day:31};i!==null&&e.N(i,o)<0&&(o=i);let s=_t(t,a,e=>this.isDisabled(e),o);return n.guardDraft=t,n.guard=s,s}getLists(){let t=this.core.options;if(this.lists?.source===t)return this.lists;let n={source:t,disabled:new Set(t.disabledDates.map(e.U)),enabled:t.enabledDates===null?null:new Set(t.enabledDates.map(e.U)),callbackResults:/* @__PURE__ */ new Map,guardDraft:null,guard:null};return this.lists=n,n}},ka=class{target=null;select=e=>{this.target?.select(e)};selectRange=(e,t)=>{this.target?.selectRange(e,t)};typeDraft=e=>{this.target?.typeDraft(e)};focusDate=e=>{this.target?.focusDate(e)};navigate=(e,t)=>{this.target?.navigate(e,t)};page=(e,t)=>{this.target?.page(e,t)};jumpTo=(e,t)=>{this.target?.jumpTo(e,t)};showPanel=e=>{this.target?.showPanel(e)};confirm=()=>{this.target?.confirm()};cancel=e=>{this.target?.cancel(e)};today=()=>{this.target?.today()};clear=()=>{this.target?.clear()};open=(e,t)=>{this.target?.open(e,t)};typed=e=>{this.target?.applyTyped(e)};connect(e){this.target=e}},Aa=class{validation;theme;display;input;triggers;form;relay=new ka;constructor(e,t){this.validation=new Oa(e,t),this.theme=new Ta(e),this.display=new da(e,t,{actions:this.relay,rules:this.validation,theme:this.theme}),this.input=new xa(e,t,{rules:this.validation,onTyped:this.relay.typed}),this.triggers=new Da(e,t,{open:this.relay.open}),this.form=new fa(e)}connect(e){this.relay.connect(e)}destroy(){this.relay.connect(null),this.display.destroy(),this.triggers.destroy(),this.input.destroy(),this.form.restore(),this.theme.destroy(),this.validation.destroy()}};const $=/* @__PURE__ */ new Map,ja=()=>void 0;var Ma=class{core;emitter;lifecycle;constructor(e,t){let r=nt(e);this.emitter=new n,this.core=new Ze(r.input,r.host,r.createdHost,t),this.lifecycle=new qt(this.core,this.emitter,new Aa(this.core,this.emitter)),$.set(this.core.instanceId,this)}create(){this.lifecycle.create()}open(){this.lifecycle.open(`api`)}close(){this.lifecycle.close()}destroy(e){this.lifecycle.destroy(e?.keepInputValue??!1),$.get(this.core.instanceId)===this&&$.delete(this.core.instanceId)}getValue(){return this.lifecycle.getValue()}setValue(e){this.lifecycle.setValue(e)}setActiveEnd(e){this.lifecycle.setActiveEnd(e)}setOptions(e){this.lifecycle.setOptions(e)}getElement(){return this.core.host}on(e,t){return this.lifecycle.destroyed?ja:this.emitter.on(e,t)}once(e,t){return this.lifecycle.destroyed?ja:this.emitter.once(e,t)}off(e,t){this.emitter.off(e,t)}get instanceId(){return this.core.instanceId}get options(){return this.core.rawOptions}get isInitialized(){return this.lifecycle.created}get isDestroyed(){return this.lifecycle.destroyed}static getById(e){return $.get(Ye(e))}static getAllInstances(){return[...$.values()]}static destroyAll(){for(let e of[...$.values()])e.destroy()}},Na=Ma;exports.DEFAULT_DATEPICKER_OPTIONS=j,exports.DatepickerUI=Ma,exports.EventEmitter=n,exports.default=Na;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./shared.cjs");function t(e){queueMicrotask(()=>{throw e})}var n=class{store={};on(e,t,n){let r=this.listenersOf(e),i={handler:t},a=()=>{r.delete(i),n?.removeEventListener(`abort`,a)};return n?.aborted||(r.add(i),n?.addEventListener(`abort`,a,{once:!0})),a}once(e,t){let n=this.on(e,e=>{n(),t(e)});return n}off(e,t){let n=this.store[e];if(n){if(!t)n.clear();else for(let e of n)e.handler===t&&n.delete(e)}}emit(e,n){let r=this.store[e];if(!r)return;let i=[];for(let e of[...r])if(r.has(e))try{e.handler(n)}catch(e){i.push(e)}i.length>0&&t(i[0])}listenerCount(e){return this.store[e]?.size??0}clear(){this.store={}}listenersOf(e){let t=this.store[e];if(t)return t;let n=/* @__PURE__ */ new Set;return this.store[e]=n,n}};function r(e,t){let n={};if((e.calendar||t.calendar)&&(n.calendar={...e.calendar,...t.calendar}),e.ui||t.ui){let r={...e.ui,...t.ui};(e.ui?.inline||t.ui?.inline)&&(r.inline={...e.ui?.inline,...t.ui?.inline}),(e.ui?.yearRange||t.ui?.yearRange)&&(r.yearRange={...e.ui?.yearRange,...t.ui?.yearRange}),n.ui=r}return(e.labels||t.labels)&&(n.labels={...e.labels,...t.labels}),(e.behavior||t.behavior)&&(n.behavior={...e.behavior,...t.behavior}),(e.callbacks||t.callbacks)&&(n.callbacks={...e.callbacks,...t.callbacks}),n}const i={title:`Select date`,monthTitle:`Select month`,yearTitle:`Select year`,noDate:`No date selected`,confirm:`OK`,cancel:`Cancel`,today:`Today`,clear:`Clear`,openCalendar:`Choose date`,previousMonth:`Previous month`,nextMonth:`Next month`,previousYear:`Previous year`,nextYear:`Next year`,chooseMonth:`Choose month`,chooseYear:`Choose year`,weekNumber:`Week`,invalidDate:`Enter a valid date`,unavailableDate:`This date is not available`,rangeTitle:`Select dates`,rangeStart:`Start`,rangeEnd:`End`,inRange:`In range`,multipleSelected:`{count} selected`,save:`Save`,close:`Close`,switchToInput:`Switch to text input`,switchToCalendar:`Switch to calendar`,dateField:`Date`,startDateField:`Start date`,endDateField:`End date`,invalidRange:`End date must be on or after the start date`,beforeMinDate:`Enter a date on or after {date}`,afterMaxDate:`Enter a date on or before {date}`,presets:`Presets`,pageUpKey:`Page Up`,pageDownKey:`Page Down`,shiftKey:`Shift`,hintDay:`dd`,hintMonth:`mm`,hintYear:`yyyy`},a={calendar:{weekStart:`auto`,mode:`single`,precision:`day`,months:1,pageBy:`view`,presets:[]},ui:{displayMode:`auto`,layout:`auto`,inline:{enabled:!1,headline:!0,navigation:`menus`,announceSelection:!0},format:`auto`,theme:`basic`,colorScheme:`auto`,weekNumbers:!1,outsideDays:!1,fixedWeeks:!1,yearRange:{before:100,after:20},todayButton:!1,clearButton:!1,animation:!0,allowPageScroll:!1,fullscreen:!0,cssClass:``,swipe:!0,viewSwitch:!0,initialView:`calendar`,mask:!1,startView:`day`},labels:i,behavior:{closeOnSelect:!1,closeOnCancel:!0,commitOnChange:!1,ignoreOutsideClick:!1,returnFocus:!0}};function o(t,n){if(e.pt(t))return null;switch(t.mode){case`single`:return t.date?n(t.date):null;case`range`:return t.start===null||t.end===null?null:{start:n(t.start),end:n(t.end)};default:return e._t(t).map(n)}}function s(t,n){if(t===`today`)return e.z(e.Ht(),n);if(typeof t==`string`)return e.B(t,n);if(t instanceof Date){let r=e.Vt(t);return r===null?null:e.z(r,n)}return null}function c(t){if(!(`start`in t&&`end`in t))return null;let n=s(t.start,`day`),r=s(t.end,`day`);return n===null||r===null||e.At(n,r)>0?null:{mode:`range`,start:n,end:r}}function l(t){let n=[];for(let e of t){let t=s(e,`day`);if(t===null)return null;n.push(t)}return{mode:`multiple`,dates:e.vt(n)}}function u(t,n,r){if(t===null)return e.ut(n);if(n===`multiple`)return Array.isArray(t)?l(t):null;if(n===`single`){let e=s(t,r);return e===null?null:{mode:n,date:e}}return typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)?c(t):null}function d(e,t){return e instanceof Date?e:typeof e!=`string`||e===`today`&&!t?null:e}function f(t,n,r,i){if(t===void 0)return null;let a=d(t,n),o=a===null?null:e.Vt(a);return o===null&&i.push({option:r,value:t}),o}function p(e,t,n,r){return e==null?null:u(e,t,n)===null?(r.push({option:`calendar.defaultValue`,value:e}),null):()=>u(e,t,n)}function m(e,t,n){return e===void 0?null:Array.isArray(e)?e.map(e=>f(e,!1,t,n)).filter(e=>e!==null):(n.push({option:t,value:e}),null)}function h(e,t,n,r,i){if(e===void 0)return n;let a=t(e);return a===void 0?(i.push({option:r,value:e}),n):a}const g=e=>typeof e==`boolean`?e:void 0,_=e=>typeof e==`string`?e:void 0,v=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,y=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1?e:void 0,b=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},x=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},S=e=>{if(typeof e==`string`)return e;if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Object.entries(e),n={};for(let[e,r]of t){if(typeof r!=`string`)return;n[e]=r}return t.length>0?n:void 0},C=e=>typeof HTMLElement<`u`&&e instanceof HTMLElement||typeof e==`string`&&e.length>0?e:void 0;function w(e){return t=>e.find(e=>e===t)}function T(t){return n=>typeof n==`string`&&e.st(n,t)?n:void 0}const E=w([`auto`,`docked`,`modal`]),D=w([`auto`,`light`,`dark`]),O=w([`auto`,`sunday`,`monday`,`saturday`]),k=w([`single`,`range`,`multiple`]),A=w([`calendar`,`input`]),ee=w([`day`,`month`,`year`]),te=w([`month`,`view`]),ne=w([`day`,`month`,`year`]),re=w([`auto`,`docked`,`modal`,`fullscreen`]),ie=w([`menus`,`caption`]),ae=w([`basic`,`m3-green`,`crane`,`crane-straight`,`m2`,`glassmorphic`,`pastel`,`ai`,`cyberpunk`,`blueprint`]);function oe(e){return e in i}function se(e,t){let n={...i};for(let r of Object.keys(i))oe(r)&&r!==`multipleSelected`&&(n[r]=h(e?.[r],_,i[r],`labels.${r}`,t));return n.multipleSelected=h(e?.multipleSelected,S,i.multipleSelected,`labels.multipleSelected`,t),n}function ce(e,t){return e===void 0||e===!0?600:e===!1?0:h(e,y,600,`ui.fullscreen`,t)}function le(e,t){return e===void 0||e===!1?!1:e===!0?{selectable:!0}:typeof e==`object`&&e?{selectable:h(Reflect.get(e,`selectable`),g,!0,`ui.outsideDays.selectable`,t)}:(t.push({option:`ui.outsideDays`,value:e}),!1)}function ue(e,t){return e===void 0||e===!1?!1:e===!0?{clearInput:!0}:typeof e==`object`&&e?{clearInput:h(Reflect.get(e,`clearInput`),g,!0,`ui.clearButton.clearInput`,t)}:(t.push({option:`ui.clearButton`,value:e}),!1)}const de=`calendar.range.presets`;function fe(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`label`),n=Reflect.get(e,`value`);return typeof t!=`string`||t===``?null:typeof n==`function`?{label:t,value:()=>Reflect.apply(n,void 0,[])}:typeof n==`object`&&n?{label:t,value:()=>n}:null}function pe(e,t){if(e===void 0)return a.calendar.presets;if(!Array.isArray(e))return t.push({option:de,value:e}),a.calendar.presets;let n=e,r=[];for(let e of n){let n=fe(e);n===null?t.push({option:de,value:e}):r.push(n)}return r}function me(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6}function he(t,n){let r=t?.trim();r&&!e.Q(r)&&n.push({option:`calendar.locale`,value:t})}function ge(e,t){if(e===void 0)return[];if(!Array.isArray(e))return t.push({option:`calendar.disabledWeekdays`,value:e}),[];let n=e,r=[];for(let e of n)me(e)?r.includes(e)||r.push(e):t.push({option:`calendar.disabledWeekdays`,value:e});return r}function _e(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`className`),n=Reflect.get(e,`badge`),r=Reflect.get(e,`label`);return{...typeof t==`string`?{className:t}:{},...typeof n==`boolean`?{badge:n}:{},...typeof r==`string`?{label:r}:{}}}function ve(e){return typeof e==`string`||typeof Node<`u`&&e instanceof Node?e:null}function ye(e){return e===null?null:n=>{try{return ve(e(n))}catch(e){return t(e),null}}}function be(e){return e===null?null:n=>{try{let t=e(n);return typeof t!=`string`||t.length===0?null:t}catch(e){return t(e),null}}}function xe(e,t,n){let r=a.calendar,i=h(e,ee,r.precision,`calendar.precision`,n);return i!==`day`&&t!==`single`?(n.push({option:`calendar.precision`,value:e}),r.precision):i}function Se(e,t){let n=h(e?.range?.minLength,y,null,`calendar.range.minLength`,t),r=h(e?.range?.maxLength,y,null,`calendar.range.maxLength`,t),i=h(e?.multiple?.max,y,null,`calendar.multiple.max`,t);return n!==null&&r!==null&&n>r?(t.push({option:`calendar.range`,value:e?.range}),{minLength:n,maxLength:null,multipleMax:i}):{minLength:n,maxLength:r,multipleMax:i}}function Ce(t,n){let r=a.calendar;he(t?.locale,n);let i=e.et(t?.locale),o=h(t?.weekStart,O,r.weekStart,`calendar.weekStart`,n),s=h(t?.isDateDisabled,b,null,`calendar.isDateDisabled`,n),c=h(t?.decorateDate,b,null,`calendar.decorateDate`,n),l=h(t?.renderDate,b,null,`calendar.renderDate`,n),u=h(t?.validate,x,null,`calendar.validate`,n),d=h(t?.mode,k,r.mode,`calendar.mode`,n),g=xe(t?.precision,d,n);return{locale:i,weekStart:e.tt(i,o),minDate:f(t?.minDate,!0,`calendar.minDate`,n),maxDate:f(t?.maxDate,!0,`calendar.maxDate`,n),disabledDates:m(t?.disabledDates,`calendar.disabledDates`,n)??[],enabledDates:m(t?.enabledDates,`calendar.enabledDates`,n),mode:d,precision:g,defaultValue:p(t?.defaultValue,d,g,n),months:h(t?.months,y,r.months,`calendar.months`,n),pageBy:h(t?.pageBy,te,r.pageBy,`calendar.pageBy`,n),limits:Se(t,n),presets:pe(t?.range?.presets,n),isDateDisabled:s===null?null:e=>!!s(e),disabledWeekdays:ge(t?.disabledWeekdays,n),decorateDate:c===null?null:e=>_e(c(e)),renderDate:ye(l),validate:be(u)}}function we(t){let n=[],r=a,i=t?.calendar,o=t?.ui,s=t?.behavior,c=(e,t,r,i)=>h(e,t,r,i,n),l=Ce(i,n),{locale:u,precision:d}=l,f=c(o?.format,T(d),r.ui.format,`ui.format`),p=c(o?.footer,g,!1,`ui.footer`),m=s?.id;return{...l,displayMode:c(o?.displayMode,E,r.ui.displayMode,`ui.displayMode`),layout:c(o?.layout,re,r.ui.layout,`ui.layout`),inline:{enabled:c(o?.inline?.enabled,g,r.ui.inline.enabled,`ui.inline.enabled`),container:c(o?.inline?.container,C,null,`ui.inline.container`),headline:c(o?.inline?.headline,g,r.ui.inline.headline,`ui.inline.headline`),navigation:c(o?.inline?.navigation,ie,r.ui.inline.navigation,`ui.inline.navigation`),announceSelection:c(o?.inline?.announceSelection,g,r.ui.inline.announceSelection,`ui.inline.announceSelection`)},pattern:e.ct(f,u,d),theme:c(o?.theme,ae,r.ui.theme,`ui.theme`),colorScheme:c(o?.colorScheme,D,r.ui.colorScheme,`ui.colorScheme`),toggleButton:c(o?.toggleButton,C,null,`ui.toggleButton`),endInput:c(o?.endInput,C,null,`ui.endInput`),weekNumbers:c(o?.weekNumbers,g,r.ui.weekNumbers,`ui.weekNumbers`),outsideDays:le(o?.outsideDays,n),fixedWeeks:c(o?.fixedWeeks,g,r.ui.fixedWeeks,`ui.fixedWeeks`),yearRange:{before:c(o?.yearRange?.before,v,r.ui.yearRange.before,`ui.yearRange.before`),after:c(o?.yearRange?.after,v,r.ui.yearRange.after,`ui.yearRange.after`)},todayButton:c(o?.todayButton,g,r.ui.todayButton,`ui.todayButton`),clearButton:ue(o?.clearButton,n),footerExplicit:typeof o?.footer==`boolean`?p:null,animation:c(o?.animation,g,r.ui.animation,`ui.animation`),allowPageScroll:c(o?.allowPageScroll,g,r.ui.allowPageScroll,`ui.allowPageScroll`),fullscreenBelow:ce(o?.fullscreen,n),cssClass:c(o?.cssClass,_,r.ui.cssClass,`ui.cssClass`),appendTo:c(o?.appendTo,C,null,`ui.appendTo`),swipe:c(o?.swipe,g,r.ui.swipe,`ui.swipe`),viewSwitch:c(o?.viewSwitch,g,r.ui.viewSwitch,`ui.viewSwitch`),initialView:c(o?.initialView,A,r.ui.initialView,`ui.initialView`),mask:c(o?.mask,g,r.ui.mask,`ui.mask`),startView:c(o?.startView,ne,r.ui.startView,`ui.startView`),labels:se(t?.labels,n),behavior:{closeOnSelect:c(s?.closeOnSelect,g,r.behavior.closeOnSelect,`behavior.closeOnSelect`),closeOnCancel:c(s?.closeOnCancel,g,r.behavior.closeOnCancel,`behavior.closeOnCancel`),commitOnChange:c(s?.commitOnChange,g,r.behavior.commitOnChange,`behavior.commitOnChange`),ignoreOutsideClick:c(s?.ignoreOutsideClick,g,r.behavior.ignoreOutsideClick,`behavior.ignoreOutsideClick`),returnFocus:c(s?.returnFocus,g,r.behavior.returnFocus,`behavior.returnFocus`),id:typeof m==`string`&&m.length>0?m:null},callbacks:{...t?.callbacks},issues:n}}const Te=/[^\w-]/g;let Ee=0;function De(e){return e.replace(Te,`-`)}function Oe(e){return{year:e.year,month:e.month}}var ke=class{input;host;createdHost;instanceId;events=new n;raw;resolved;currentValue;currentDraft;currentView;currentFocus;currentPanel;currentMode=null;currentCalendarLayout=`docked`;currentLayout={months:1,presets:`none`};currentListSpan=null;currentActiveEnd=`start`;currentEndInput=null;activeEndControlled=!1;constructor(t,n,i,a){this.input=t,this.host=n,this.createdHost=i,this.raw=r({},a??{}),this.resolved=we(this.raw),Ee+=1;let o=this.resolved.behavior.id;this.instanceId=o===null?`${e.Ut}${String(Ee)}`:De(o),this.currentPanel=e.bt(this.resolved.precision),this.currentValue=e.ut(this.resolved.mode),this.currentDraft=this.currentValue;let s=e.Ht();this.currentFocus=s,this.currentView=Oe(s)}get options(){return this.resolved}get rawOptions(){return this.raw}setOptions(e){this.raw=r(this.raw,e),this.resolved=we(this.raw),this.events.emit(`change:options`,{})}get value(){return this.currentValue}setValue(e){this.currentValue=e,this.events.emit(`change:value`,{value:e})}get draft(){return this.currentDraft}setDraft(e){this.currentDraft=e,this.events.emit(`change:draft`,{draft:e})}get view(){return this.currentView}setView(e,t,n){let r=Oe(e);this.currentView=r,this.events.emit(`change:view`,{view:r,delta:t,source:n})}get focus(){return this.currentFocus}setFocus(e){this.currentFocus=e,this.events.emit(`change:focus`,{focus:e})}get panel(){return this.currentPanel}setPanel(e){e!==this.currentPanel&&(this.currentPanel=e,this.events.emit(`change:panel`,{panel:e}))}get mode(){return this.currentMode}setMode(e){this.currentMode=e}get calendarLayout(){return this.currentCalendarLayout}setCalendarLayout(e){this.currentCalendarLayout=e}get layout(){return this.currentLayout}setLayout(e){this.currentLayout=e}get listSpan(){return this.currentListSpan}setListSpan(e){this.currentListSpan=e}get activeEnd(){return this.currentActiveEnd}setActiveEnd(e){e!==this.currentActiveEnd&&(this.currentActiveEnd=e,this.events.emit(`change:active-end`,{end:e}))}controlActiveEnd(){this.activeEndControlled=!0}get followsActiveEnd(){return this.currentEndInput!==null||this.activeEndControlled}get endInput(){return this.currentEndInput}setEndInput(e){this.currentEndInput=e}resetSession(){let t=e.lt(this.currentValue)??e.Ht(),n=Oe(t);this.currentListSpan=null,this.setPanel(e.bt(this.resolved.precision)),this.setDraft(this.currentValue),this.setView(n,e.Rt(this.currentView,n),`api`),this.setFocus(t)}};const j=`dp-ui`,Ae=[`class`,`name`,`aria-invalid`,`aria-describedby`];function je(e){return typeof e==`string`?document.querySelector(e):e}function Me(e){return e instanceof HTMLInputElement?e:e?.querySelector(`input`)??null}function Ne(e){let t=document.createElement(`div`);return t.className=j,e.before(t),t.append(e),t}function Pe(t){if(!e.rt())throw Error(`DatepickerUI needs a document`);let n=je(t),r=Me(n);if(r===null)throw Error(`DatepickerUI could not find an input element`);let i=r.parentElement;return i!==null&&(n!==r||i.classList.contains(j))?{input:r,host:i,createdHost:!1}:{input:r,host:Ne(r),createdHost:!0}}function Fe(e){let{input:t,host:n,createdHost:r}=e,i=/* @__PURE__ */ new Map;for(let e of Ae)i.set(e,t.getAttribute(e));let a=n.classList.contains(j);return n.classList.add(j),{target:{input:t,host:n,createdHost:r},hostHadClass:a,inputAttributes:i}}function Ie(e){let{input:t,host:n,createdHost:r}=e.target;for(let[n,r]of e.inputAttributes)r===null?t.removeAttribute(n):t.setAttribute(n,r);r?t.parentNode===n?n.replaceWith(t):n.remove():e.hostHadClass||n.classList.remove(j)}function Le(t,n,r,i){let a=e.Rt(t,n);return a>=0&&a<r?t:i===`month`?a<0?n:e.kt(n,-(r-1)):e.kt(t,Math.floor(a/r)*r)}function Re(t,n){let{core:r,managers:i}=t,{minDate:a,maxDate:o}=r.options,s=i.validation.yearBounds(),c={year:s.min,month:1,day:1},l={year:s.max,month:12,day:31},u=a!==null&&e.At(a,c)>0?a:c,d=o!==null&&e.At(o,l)<0?o:l;return e.At(n,u)<0?u:e.At(n,d)>0?d:n}function ze(t,n,r){return Re(t,{year:n.year,month:n.month,day:Math.min(r,e.Pt(n))})}function M(t,n,r){let{core:i,managers:a}=t,o=a.validation.clampView(n),s=e.Rt(i.view,o);return s!==0&&(i.setView(o,s,r),i.setFocus(ze(t,o,i.focus.day))),o}function N(t,n,r){let{core:i,managers:a}=t,o={year:n.year,month:n.month},{months:s}=i.layout,c=a.validation.clampView(Le(i.view,o,s,i.options.pageBy)),l=e.Rt(c,o);if(l<0||l>=s)return;let u=e.Rt(i.view,c);u!==0&&i.setView(c,u,r),i.setFocus(n)}function Be(t,n,r){let i=e.Nt(t,n)+1;return r.minLength!==null&&i<r.minLength?!1:r.maxLength===null||i<=r.maxLength}function Ve(t,n,r,i){let a=i;if(n.maxLength!==null){let r=e.Ot(t,n.maxLength-1);a=e.At(r,i)<0?r:i}for(let n=e.Ot(t,1);e.At(n,a)<=0;n=e.Ot(n,1))if(r(n))return n;return null}function He(t,n,r,i){if(t.mode===`multiple`){let{multipleMax:r}=n,{dates:i}=t;return n=>r!==null&&i.length>=r&&!e.ft(t,n)}if(t.mode!==`range`||t.start===null||t.end!==null)return()=>!1;let{start:a}=t,o=null,s=!1;return t=>e.At(t,a)<0?!1:e.At(t,i)>0||!Be(a,t,n)||(s||=(o=Ve(a,n,r,i),!0),o!==null&&e.At(t,o)>=0)}function Ue(t,n,r,i){if(!Be(t,n,r))return`range-length`;for(let r=t;e.At(r,n)<=0;r=e.Ot(r,1)){let e=i(r);if(e!==null)return e}return null}function We(e,t){for(let n of e){let e=t(n);if(e!==null)return e}return null}function P(e,t,n){switch(e.mode){case`single`:return e.date===null?null:n(e.date);case`range`:return e.start!==null&&e.end!==null?Ue(e.start,e.end,t,n):e.start===null?null:n(e.start);default:return t.multipleMax!==null&&e.dates.length>t.multipleMax?`multiple-max`:We(e.dates,n)}}function Ge(e,t,n){return P(e,t,e=>n(e)?`disabled`:null)===null}function Ke(t,n,r){return t.some(t=>e.At(t,n)===0)?t.filter(t=>e.At(t,n)!==0):r.multipleMax!==null&&t.length>=r.multipleMax?null:e.vt([...t,n])}function qe(e){return e.mode===`range`&&e.start!==null&&e.end===null?`end`:`start`}function Je(e,t){return e.mode===`range`?t===`start`?{mode:`range`,start:null,end:null}:{mode:`range`,start:e.start,end:null}:e}function Ye(t,n,r,i){switch(t.mode){case`single`:return{mode:`single`,date:n};case`range`:return i===`start`||t.start===null||e.At(n,t.start)<0?{mode:`range`,start:n,end:null}:{mode:`range`,start:t.start,end:n};default:{let e=Ke(t.dates,n,r);return e===null?t:{mode:`multiple`,dates:e}}}}var Xe=class{context;session;values;constructor(e,t,n){this.context=e,this.session=t,this.values=n}isOpen(){return this.session.active}select(t){let{core:n,managers:r}=this.context,i=e.z(t,n.options.precision),a=n.followsActiveEnd?n.activeEnd:qe(n.draft);if(!this.session.active||!r.validation.isSelectable(i,Je(n.draft,a)))return;N(this.context,i,`button`);let o=Ye(n.draft,i,n.options.limits,a);n.setDraft(o),n.setActiveEnd(qe(o)),this.announce(o,i),this.isOpen()&&this.autoCommit(o)}selectRange(e,t){let{core:n,managers:r}=this.context,{mode:i,limits:a}=n.options;if(!this.session.active||i!==`range`)return;let o={mode:`range`,start:e,end:t};P(o,a,e=>r.validation.unavailableReason(e))===null&&(n.setDraft(o),n.setActiveEnd(`start`),N(this.context,e,`api`),this.emitRangeEnd(e,t),this.isOpen()&&this.autoCommit(o))}typeDraft(t){if(!this.acceptTyped(t))return;let{commitOnChange:n}=this.context.core.options.behavior;n&&e.dt(t)&&this.values.commit(!0)}submitDraft(){let{core:t}=this.context,n=t.draft,r=t.options.behavior.closeOnSelect&&n.mode!==`multiple`;this.session.active&&r&&e.dt(n)&&(e.gt(t.value,n)||this.values.commit(!0),this.session.close())}acceptTyped(t){let{core:n,managers:r}=this.context,{mode:i,limits:a}=n.options,o=t.mode===i&&Ge(t,a,e=>r.validation.isDisabled(e));if(!this.session.active||!o||e.gt(n.draft,t))return!1;n.setDraft(t);let s=e.lt(t);return s!==null&&N(this.context,s,`api`),this.announceTyped(t),!0}announceTyped(e){let{emitter:t}=this.context,{describe:n}=this.values;e.mode===`single`?e.date!==null&&t.emit(`select:day`,{value:n(e.date),selected:!0}):e.mode===`range`&&e.start!==null&&(e.end===null?t.emit(`range:start`,{value:n(e.start)}):this.emitRangeEnd(e.start,e.end))}announce(t,n){let{emitter:r}=this.context,{describe:i}=this.values;r.emit(`select:day`,{value:i(n),selected:e.ft(t,n)}),t.mode===`range`&&(t.start===null||t.end===null?r.emit(`range:start`,{value:i(n)}):this.emitRangeEnd(t.start,t.end))}emitRangeEnd(e,t){let{describe:n}=this.values;this.context.emitter.emit(`range:end`,{start:n(e),end:n(t)})}autoCommit(e){if(e.mode===`range`&&e.end===null)return;let{closeOnSelect:t,commitOnChange:n}=this.context.core.options.behavior,r=t&&e.mode!==`multiple`;(r||n)&&this.values.commit(!0),r&&this.session.close()}},Ze=class{context;session;values;selector;constructor(e,t,n){this.context=e,this.session=t,this.values=n,this.selector=new Xe(e,t,n)}isOpen(){return this.session.active}select(e){this.selector.select(e)}selectRange(e,t){this.selector.selectRange(e,t)}typeDraft(e){this.selector.typeDraft(e)}submitDraft(){this.selector.submitDraft()}focusDate(e){this.session.active&&N(this.context,e,`keyboard`)}navigate(t,n){this.session.active&&M(this.context,e.kt(this.context.core.view,t),n)}page(e,t){let{core:n}=this.context,r=n.options.pageBy===`view`?n.layout.months:1;this.navigate(e*r,t)}jumpTo(t,n){if(!this.session.active)return;let{core:r}=this.context,i=r.panel,a=M(this.context,t,n);n===`menu`&&(r.setPanel(e.bt(r.options.precision)),this.announcePick(i,a))}showPanel(e){this.session.active&&this.context.core.setPanel(e)}confirm(){this.session.active&&e.dt(this.context.core.draft)&&(this.values.commit(!1),this.session.close())}cancel(e){if(!this.session.active)return;let{core:t,emitter:n}=this.context;n.emit(`cancel`,{reason:e}),this.isOpen()&&((t.options.behavior.closeOnCancel||e!==`button`)&&t.mode!==`inline`?this.session.close():t.setDraft(t.value))}today(){if(!this.session.active)return;let{core:t,managers:n}=this.context,r=e.Ht();n.validation.isSelectable(r,t.draft)?this.select(r):N(this.context,r,`button`)}clear(){if(!this.session.active)return;let{core:t}=this.context,{clearButton:n}=t.options,r=n!==!1&&n.clearInput,i=this.values.clearedSelection(r);i!==null&&(this.values.emitClear(i),!this.isOpen())||(t.setDraft(e.ut(t.options.mode)),r&&(this.values.commit(!1),this.session.close()))}announcePick(e,t){let{emitter:n}=this.context;e===`month-menu`||e===`month-grid`?n.emit(`select:month`,{year:t.year,month:t.month}):(e===`year-menu`||e===`year-grid`)&&n.emit(`select:year`,{year:t.year})}},Qe=class{context;subscriptions=[];constructor(e){this.context=e}bind(){for(let e of this.subscriptions)e();this.subscriptions=[];let{callbacks:e}=this.context.core.options;this.add(`open`,e.onOpen),this.add(`close`,e.onClose),this.add(`cancel`,e.onCancel),this.add(`confirm`,e.onConfirm),this.add(`update`,e.onUpdate),this.add(`error`,e.onError),this.add(`select:day`,e.onSelectDay),this.add(`select:month`,e.onSelectMonth),this.add(`select:year`,e.onSelectYear),this.add(`range:start`,e.onRangeStart),this.add(`range:end`,e.onRangeEnd),this.add(`navigate`,e.onNavigate),this.add(`switch:view`,e.onSwitchView),this.add(`clear`,e.onClear)}add(e,t){t!==void 0&&this.subscriptions.push(this.context.emitter.on(e,t))}};const $e=[`class`,`name`,`aria-invalid`];function et(t){let{core:n,emitter:r}=t,{endInput:i,mode:a}=n.options;if(a!==`range`||i===null)return null;let o=e.I(i,n.host);return o instanceof HTMLInputElement&&o!==n.input?o:(r.emit(`error`,{code:`invalid-option`,message:`ui.endInput does not match an input element`,option:`ui.endInput`}),null)}function tt(e){let t=/* @__PURE__ */ new Map;for(let n of $e)t.set(n,e.getAttribute(n));return()=>{for(let[n,r]of t)r===null?e.removeAttribute(n):e.setAttribute(n,r)}}const nt=[`calendar`,`ui`,`labels`,`behavior`,`callbacks`];function rt(e){let t=[];for(let n of nt){let r=e[n];if(r!==void 0)for(let e of Object.keys(r))t.push(`${n}.${e}`)}return t}function it(e,t){return e.some(e=>t.option===e||t.option.startsWith(`${e}.`))}function at(e,t){for(let n of t)e.emitter.emit(`error`,{code:`invalid-option`,message:`Invalid value for option ${n.option}`,option:n.option})}var ot=class{context;session;callbacks;triggers;constructor(e,t,n,r){this.context=e,this.session=t,this.callbacks=n,this.triggers=r}apply(e){let{core:t,emitter:n,status:r}=this.context;if(r.destroyed)return;let i=t.options;t.setOptions(e),t.options.mode!==i.mode&&this.resetSelection(),r.created&&this.reapply(i,e),n.emit(`update`,{options:e})}resetSelection(){let{core:t,managers:n,status:r}=this.context,i=e.ut(t.options.mode);t.setValue(i),t.setDraft(i),r.created&&(n.input.write(i),n.form.sync())}reapply(t,n){let{core:r,managers:i}=this.context;this.callbacks.bind(),i.theme.applyHost(),this.triggers.bind(),e.pt(r.value)||i.input.write(r.value),i.triggers.updateLabel(),this.refreshSurface(t);let a=rt(n);at(this.context,r.options.issues.filter(e=>it(a,e)))}refreshSurface(e){let{core:t}=this.context,n=t.options;if(n.inline.enabled!==e.inline.enabled||n.inline.enabled&&n.inline.container!==e.inline.container){this.session.end(),n.inline.enabled&&this.session.mountInline();return}let r=t.mode;if(!this.session.active||r===null)return;let i=r===`inline`||n.displayMode===e.displayMode?r:this.session.pickMode();i!==r||n.mode!==e.mode||n.layout!==e.layout?this.session.remount(i):this.session.refresh(i,`api`)}},st=class{context;session;callbacks;triggers;controller=new AbortController;hostSnapshot;restoreEndInput=null;constructor(e,t,n,r){this.context=e,this.session=t,this.callbacks=n,this.triggers=r,this.hostSnapshot=Fe(e.core)}create(){let{core:t,managers:n,status:r}=this.context;if(r.created||r.destroyed)return;r.created=!0;let i=this.controller.signal;this.callbacks.bind(),n.theme.applyHost();let a=et(this.context);t.setEndInput(a),a!==null&&(this.restoreEndInput=tt(a));let o=this.initialSelection();t.setValue(o),e.pt(o)||n.input.write(o),n.form.bind(i),n.form.sync(),n.input.bind(i),this.triggers.bind(),n.triggers.updateLabel(),t.events.on(`change:value`,()=>{n.triggers.updateLabel()},i),t.options.inline.enabled&&this.session.mountInline(),at(this.context,t.options.issues)}initialSelection(){let{core:t,managers:n}=this.context;if(!e.pt(t.value))return t.value;let r=n.input.readInitial();return e.pt(r)?t.options.defaultValue?.()??r:r}destroy(e){let{core:t,emitter:n,managers:r,status:i}=this.context;i.destroyed||(i.destroyed=!0,this.session.teardown(),this.triggers.release(),this.controller.abort(),r.destroy(),e||(t.input.value=``,t.endInput!==null&&(t.endInput.value=``)),this.restoreEndInput?.(),this.restoreEndInput=null,t.setEndInput(null),Ie(this.hostSnapshot),t.events.clear(),n.clear())}},ct=class{tail=Promise.resolve();pending=0;stopped=!1;run(e){let n=async()=>{this.stopped||await e()},r=this.pending===0?n():this.tail.then(n);this.pending+=1;let i=r.catch(t).finally(()=>{--this.pending});return this.tail=i,i}stop(){this.stopped=!0}},lt=class{context;views;visible;queue=new ct;controller=null;phase=`closed`;sessionId=0;mounts=0;closing=Promise.resolve();openedFrom=`start`;mountSource=`open`;constructor(e,t,n){this.context=e,this.views=t,this.visible=n}get active(){return this.phase===`open`}open(e,t=`start`){let{core:n,emitter:r,managers:i,status:a}=this.context;if(!a.created||a.destroyed||n.options.inline.enabled)return;if(this.phase===`open`){n.setActiveEnd(t);return}if(e!==`api`&&n.input.disabled)return;let o=this.pickMode();this.openedFrom=t,n.setActiveEnd(t),this.begin(o),i.triggers.setExpanded(!0),r.emit(`open`,{mode:n.mode??o})}fallBackToModal(){this.active&&this.context.core.mode===`docked`&&(this.stopListening(),this.adoptMode(`modal`),this.listen(),this.mount(`modal`,this.mountSource))}mountInline(){let{core:t,emitter:n}=this.context;e.I(t.options.inline.container)===null?n.emit(`error`,{code:`invalid-option`,message:`ui.inline.container does not match an element`,option:`ui.inline.container`}):(this.begin(`inline`),n.emit(`open`,{mode:`inline`}))}close(){return this.context.core.mode===`inline`?Promise.resolve():this.end()}end(){if(this.phase===`closing`)return this.closing;if(this.phase!==`open`)return Promise.resolve();let{core:e,emitter:t,managers:n}=this.context,r=e.mode,i=this.sessionId;this.phase=`closing`,this.stopListening(),this.visible.reset(),n.triggers.setExpanded(!1);let a=this.queue.run(()=>n.display.unmount()).then(()=>{this.finish(i,r)});return this.closing=a,t.emit(`close`,{}),a}syncLayout(t){let{core:n}=this.context,r=n.options,i=window.innerWidth;if(t===`inline`){let t=e.I(r.inline.container)?.clientWidth??0;i=t>0?t:i}n.setLayout(e.wt({months:r.months,precision:r.precision,mode:r.mode,layout:n.calendarLayout,width:i,weekNumbers:r.weekNumbers,presets:r.presets.length}))}remount(e){let{core:t,managers:n}=this.context;this.visible.pause(),this.decideLayout(e),this.syncLayout(e),this.clampView(),t.setMode(e),this.views.dropUnsupported(),this.queue.run(()=>n.display.unmount()),this.mount(e,`api`)}refresh(e,t){let{core:n,managers:r}=this.context;this.visible.hold(t,()=>{this.syncLayout(e),this.clampView(),n.setListSpan(null),r.display.update()})}pickMode(){let{displayMode:t}=this.context.core.options;return e.Ct(t,!1,window.innerWidth,window.innerHeight)}clampView(){M(this.context,this.context.core.view,`api`)}teardown(){this.phase=`closed`,this.stopListening(),this.visible.reset(),this.queue.stop()}begin(e){this.stopListening(),this.sessionId+=1,this.phase=`open`,this.visible.reset(),this.context.core.resetSession(),this.adoptMode(e),this.listen(),this.mount(e,`open`)}adoptMode(e){let{core:t}=this.context;this.decideLayout(e),t.setPanel(this.views.opening(e)),this.syncLayout(e),this.clampView(),t.setMode(e)}listen(){let e=new AbortController;this.controller=e,this.views.bind(e.signal),this.visible.bind(e.signal),window.addEventListener(`resize`,()=>{this.relayout()},{signal:e.signal})}mount(e,t){let{core:n,managers:r}=this.context;this.mounts+=1,this.mountSource=t;let i=this.mounts;this.queue.run(()=>(n.setListSpan(null),r.display.mount(e))).then(()=>{i===this.mounts&&this.active&&this.visible.resume(t)})}decideLayout(t){let{core:n}=this.context;n.setCalendarLayout(e.yt(t,n.options,window.innerWidth))}relayout(){let{core:e}=this.context,t=e.mode;if(t===null)return;let n=e.layout;this.syncLayout(t);let r=e.layout;(r.months!==n.months||r.presets!==n.presets)&&this.refresh(t,`resize`)}stopListening(){this.controller?.abort(),this.controller=null}finish(e,t){this.sessionId===e&&this.phase===`closing`&&(this.phase=`closed`,this.context.core.setMode(null),this.returnFocus(t))}returnFocus(e){let{core:t}=this.context;if(!t.options.behavior.returnFocus)return;let n=document.activeElement;(e===`modal`||n===null||n===document.body)&&((this.openedFrom===`end`?t.endInput:null)??t.input).focus({preventScroll:!0})}},ut=class{context;scope=null;constructor(e){this.context=e}bind(){this.release();let{core:e,managers:t}=this.context;if(e.options.inline.enabled)return;let n=new AbortController;this.scope=n,t.triggers.bind(n.signal)}release(){this.scope?.abort(),this.scope=null}};const dt=[`start`,`end`];var ft=class{context;session;visible;constructor(e,t,n){this.context=e,this.session=t,this.visible=n}describe=t=>{let{pattern:n,precision:r}=this.context.core.options;return{value:e.H(t,r),date:e.zt(t),formatted:e.R(t,n,r)}};get(){return this.present(this.context.core.value)}set(e){let{core:t,emitter:n,managers:r,status:i}=this.context;if(i.destroyed)return;let a=u(e,t.options.mode,t.options.precision);a===null?n.emit(`error`,{code:`invalid-date`,message:`setValue() received a value that is not a valid date for calendar.mode`,input:typeof e==`string`?e:void 0}):(t.setValue(a),r.input.write(a),i.created&&r.form.sync(),this.follow(),this.validate(a))}isSelectable(t){let{core:n,managers:r}=this.context,{mode:i,precision:a,limits:o}=n.options,s=u(t,i===`single`||typeof t==`string`||t instanceof Date?`single`:i,a);return s===null||e.pt(s)?!1:Ge(s,o,e=>r.validation.isDisabled(e))}clear(){let{core:t,managers:n,status:r}=this.context,i=this.clearedSelection(!0);if(r.destroyed||i===null)return;let a=e.ut(t.options.mode);t.setValue(a),this.session.active&&t.setDraft(a),n.input.write(a),r.created&&(n.form.sync(),n.form.dispatchCommit()),this.emitClear(i),this.validate(a)}clearedSelection(t){let{core:n}=this.context;return t&&!e.pt(n.value)?n.value:this.session.active&&!e.pt(n.draft)?n.draft:null}emitClear(e){this.context.emitter.emit(`clear`,{previousValue:this.present(e)})}setActiveEnd(e){let{core:t,status:n}=this.context,r=dt;!n.destroyed&&t.options.mode===`range`&&r.includes(e)&&(t.controlActiveEnd(),t.setActiveEnd(e))}applyTyped(t){let{core:n,emitter:r,managers:i}=this.context,a=!e.gt(n.value,t),o=e.gt(n.draft,t);n.setValue(t),i.form.sync(),(a||!o)&&this.follow(),a&&r.emit(`confirm`,{value:this.present(t),autoCommit:!0}),this.validate(t)}commit(e){let{core:t,emitter:n,managers:r}=this.context,i=t.draft;t.setValue(i),r.input.write(i),r.form.sync(),r.form.dispatchCommit(),n.emit(`confirm`,{value:this.present(i),autoCommit:e}),this.validate(i)}validate(e){let{core:t,managers:n}=this.context,{validate:r}=t.options;if(r===null)return;let i=r(this.present(e));i!==null&&n.input.markInvalid(i)}present(e){return o(e,this.describe)}follow(){if(!this.session.active)return;let{core:t}=this.context,n=t.value;t.setDraft(n);let r=e.lt(n);r!==null&&this.visible.hold(`api`,()=>{N(this.context,r,`api`)})}};const pt=e=>e===`input`?`input`:`calendar`;var mt=class{context;isShown;visible;constructor(e,t,n){this.context=e,this.isShown=t,this.visible=n}get(){return this.isShown()?pt(this.context.core.panel):`calendar`}set(t){let{core:n}=this.context;this.isShown()&&this.hasInputView()&&n.setPanel(t===`input`?`input`:e.bt(n.options.precision))}goTo(t){let n=u(t,`single`,`day`),r=n===null?null:e.lt(n);r===null?this.context.emitter.emit(`error`,{code:`invalid-date`,message:`goTo() received a value that is not a valid date`,input:typeof t==`string`?t:void 0}):this.isShown()&&this.visible.hold(`api`,()=>{N(this.context,Re(this.context,r),`api`)})}bind(e){let{core:t,emitter:n}=this.context,r=pt(t.panel);t.events.on(`change:panel`,({panel:e})=>{let t=pt(e);t!==r&&(r=t,n.emit(`switch:view`,{view:t}))},e)}opening(t){let{core:n}=this.context,{initialView:r,inline:i,mode:a,precision:o,startView:s}=n.options;if(r===`input`&&this.hasInputView())return`input`;let c=e.xt(t,i).navigation===`caption`;return o!==`day`||a===`range`||c?e.bt(o):e.Et(s,n.calendarLayout)}dropUnsupported(){let{core:t}=this.context;t.panel===`input`&&!this.hasInputView()&&t.setPanel(e.bt(t.options.precision))}hasInputView(){let{core:t}=this.context,{mode:n,precision:r}=t.options;return e.Dt(n,t.calendarLayout,r)}};const F=(t,n)=>({from:{year:t.year,month:t.month,day:1},to:{year:n.year,month:n.month,day:e.Pt(n)}}),ht=(t,n,r)=>{let i={year:t.year,month:t.month,day:1},a=(e.Mt(i)-n+7)%7,o=r?6:Math.ceil((a+e.Pt(t))/7),s=e.Ot(i,-a);return{from:s,to:e.Ot(s,o*7-1)}},gt=e=>{let t=e.layout===`docked`&&e.months<=1&&e.outsideDays;return{outsideDays:t,fixedWeeks:e.layout!==`docked`&&!e.inline||t||e.fixedWeeks}},_t=t=>{let{view:n,listSpan:r,yearBounds:i}=t;return r===null?t.precision===`year`?F({year:i.min,month:1},{year:i.max,month:12}):t.precision===`month`?F({year:n.year,month:1},{year:n.year,month:12}):t.months>1?F(n,e.kt(n,t.months-1)):t.outsideDays?ht(n,t.weekStart,t.fixedWeeks):F(n,n):F(r.first,r.last)};function vt(e){return e<0?-1:+(e>0)}var yt=class{context;isShown;last=null;live=!1;constructor(e,t){this.context=e,this.isShown=t}current(){if(!this.isShown())return null;let{from:e,to:t}=this.compute();return{from:this.describe(e),to:this.describe(t)}}bind(e){this.context.core.events.on(`change:view`,({source:e})=>{this.report(e)},e)}hold(e,t){let n=this.live;this.live=!1;try{t()}finally{this.live=n}this.report(e)}pause(){this.live=!1}resume(e){this.live=!0,this.report(this.last===null?`open`:e)}reset(){this.last=null,this.live=!1}renderedMonths(e,t){this.context.core.setListSpan({first:e,last:t}),this.report(`scroll`)}report(t){if(!this.live)return;let{core:n,emitter:r}=this.context,{from:i,to:a}=this.compute(),o={view:n.view,from:e.Bt(i),to:e.Bt(a)},s=this.last;if(s?.from===o.from&&s.to===o.to)return;this.last=o;let c=s===null?0:e.Rt(s.view,o.view);r.emit(`navigate`,{year:o.view.year,month:o.view.month,direction:vt(c),source:t,from:this.describe(i),to:this.describe(a)})}compute(){let{core:e,managers:t}=this.context,{options:n,layout:r}=e,i=gt({layout:e.calendarLayout,inline:e.mode===`inline`,months:r.months,outsideDays:n.mode!==`range`&&n.outsideDays!==!1,fixedWeeks:n.fixedWeeks});return _t({view:e.view,months:r.months,precision:n.precision,weekStart:n.weekStart,fixedWeeks:i.fixedWeeks,outsideDays:i.outsideDays,yearBounds:t.validation.yearBounds(),listSpan:e.listSpan})}describe(t){return{value:e.Bt(t),date:e.zt(t),formatted:e.R(t,this.context.core.options.pattern,`day`)}}},bt=class{status={created:!1,destroyed:!1};visible;views;session;values;actions;instance;updates;constructor(e,t,n){let r={core:e,emitter:t,managers:n,status:this.status},i=new Qe(r),a=new ut(r),o=()=>this.session.active;this.visible=new yt(r,o),this.views=new mt(r,o,this.visible),this.session=new lt(r,this.views,this.visible),this.values=new ft(r,this.session,this.visible),this.actions=new Ze(r,this.session,this.values),this.instance=new st(r,this.session,i,a),this.updates=new ot(r,this.session,i,a),n.connect(this)}get created(){return this.status.created}get destroyed(){return this.status.destroyed}create(){this.instance.create()}open(e,t){this.session.open(e,t)}close(){return this.session.close()}destroy(e){this.instance.destroy(e)}setOptions(e){this.updates.apply(e)}getValue(){return this.values.get()}setValue(e){this.values.set(e)}setActiveEnd(e){this.values.setActiveEnd(e)}setView(e){this.views.set(e)}getView(){return this.views.get()}getVisibleRange(){return this.visible.current()}goTo(e){this.views.goTo(e)}isSelectable(e){return this.values.isSelectable(e)}clearValue(){this.values.clear()}applyTyped(e){this.values.applyTyped(e)}fallBackToModal(){this.session.fallBackToModal()}select(e){this.actions.select(e)}selectRange(e,t){this.actions.selectRange(e,t)}typeDraft(e){this.actions.typeDraft(e)}submitDraft(){this.actions.submitDraft()}focusDate(e){this.actions.focusDate(e)}navigate(e,t){this.actions.navigate(e,t)}page(e,t){this.actions.page(e,t)}jumpTo(e,t){this.actions.jumpTo(e,t)}showPanel(e){this.actions.showPanel(e)}confirm(){this.actions.confirm()}cancel(e){this.actions.cancel(e)}today(){this.actions.today()}clear(){this.actions.clear()}renderedMonths(e,t){this.visible.renderedMonths(e,t)}};const xt=e=>e.toLowerCase().replace(/_/g,`-`);function St(t,n){Object.entries(e.O).forEach(([e,r])=>{t.style.setProperty(`--dp-ui-motion-${xt(e)}`,`${String(n?r:0)}ms`)}),Object.entries(e.E).forEach(([e,n])=>{t.style.setProperty(`--dp-ui-easing-${xt(e)}`,n)})}function Ct(e,t,n){if(t===`range`)return e.rangeTitle;switch(n){case`month`:return e.monthTitle;case`year`:return e.yearTitle;case`day`:return e.title}}const wt=/* @__PURE__ */ new Map,Tt=/* @__PURE__ */ new Map;function Et(e){let t=wt.get(e);if(t)return t;let n=new Intl.PluralRules(e);return wt.set(e,n),n}function Dt(e){let t=Tt.get(e);if(t)return t;let n=new Intl.NumberFormat(e);return Tt.set(e,n),n}function Ot(e,t,n){return(typeof e==`string`?e:e[Et(n).select(t)]??e.other??Object.values(e).at(0)??``).replaceAll(`{count}`,Dt(n).format(t))}function kt(t,n,r,i,a){switch(t.mode){case`single`:return t.date?e.Y(t.date,a,r,`headline`):i.noDate;case`range`:{if(n===`input`&&t.start&&t.end)return e.Z(t.start,t.end,r);let a=t.start?e.X(t.start,r):i.rangeStart,o=t.end?e.X(t.end,r):i.rangeEnd;return`${a}${e.b}${o}`}default:return t.dates.length===0?i.noDate:Ot(i.multipleSelected,t.dates.length,r)}}const At=`dp-ui--ripple-pressed`,jt=`dp-ui--ripple-active`,Mt=e=>e.getAttribute(`aria-disabled`)===`true`||e instanceof HTMLButtonElement&&e.disabled;function Nt(t,n,r){let i=e=>e instanceof Element?e.closest(n):null,a=e=>{i(e.target)?.classList.remove(At)};t.addEventListener(`pointerdown`,n=>{let o=i(n.target);if(!o||!t.contains(o)||Mt(o)||n.pointerType===`mouse`&&n.button!==0)return;o.classList.remove(jt);let{left:s,top:c,width:l,height:u}=o.getBoundingClientRect();o.style.setProperty(`--dp-ui-ripple-x`,`${String(n.clientX-s)}px`),o.style.setProperty(`--dp-ui-ripple-y`,`${String(n.clientY-c)}px`),o.style.setProperty(`--dp-ui-ripple-size`,`${String(Math.max(l,u)*2)}px`),o.style.setProperty(`--dp-ui-ripple-duration`,`${String(e.O.RIPPLE)}ms`),o.classList.add(At),o.addEventListener(`pointerleave`,a,{once:!0,signal:r}),e.N()||(requestAnimationFrame(()=>{o.classList.add(jt)}),window.setTimeout(()=>{o.classList.remove(jt)},e.O.RIPPLE))},{signal:r}),t.addEventListener(`pointerup`,a,{signal:r}),t.addEventListener(`pointercancel`,a,{signal:r})}const Pt=(e,t)=>{e.querySelectorAll(`.dp-ui__text-button--confirm, .dp-ui__text-button--save`).forEach(e=>{e.disabled=!t})},Ft=t=>{let{labels:n}=t,r=e.F(`div`,`dp-ui__actions`);r.hidden=!t.visible;let i=e.F(`div`,`dp-ui__actions-start`);t.todayButton&&i.append(e.h(`today`,n.today)),t.clearButton&&i.append(e.h(`clear`,n.clear));let a=e.F(`div`,`dp-ui__actions-end`);return a.append(e.h(`cancel`,n.cancel),e.h(`confirm`,n.confirm)),r.append(i,a),r},It=[[`dp-ui__icon-button--prev-month`,{kind:`page`,direction:-1}],[`dp-ui__icon-button--next-month`,{kind:`page`,direction:1}],[`dp-ui__icon-button--prev-year`,{kind:`navigate`,delta:-12}],[`dp-ui__icon-button--next-year`,{kind:`navigate`,delta:12}],[`dp-ui__menu-button--month`,{kind:`panel`,panel:`month-menu`}],[`dp-ui__menu-button--year`,{kind:`panel`,panel:`year-menu`}],[`dp-ui__menu-button--year-grid`,{kind:`panel`,panel:`year-grid`}],[`dp-ui__text-button--today`,{kind:`today`}],[`dp-ui__text-button--clear`,{kind:`clear`}],[`dp-ui__text-button--cancel`,{kind:`cancel`}],[`dp-ui__text-button--confirm`,{kind:`confirm`}],[`dp-ui__text-button--save`,{kind:`confirm`}],[`dp-ui__icon-button--close`,{kind:`cancel`}],[`dp-ui__icon-button--switch-view`,{kind:`switch`}]],Lt=e=>It.find(([t])=>e.classList.contains(t)),Rt=e=>Lt(e)?.[0]??null,zt=(e,t)=>{let{actions:n}=t;switch(e.kind){case`navigate`:n.navigate(e.delta,`button`);return;case`page`:n.page(e.direction,`button`);return;case`panel`:n.showPanel(t.panel()===e.panel?t.home:e.panel);return;case`switch`:n.showPanel(t.panel()===`input`?t.home:`input`);return;case`today`:n.today();return;case`clear`:n.clear();return;case`cancel`:n.cancel(`button`);return;case`confirm`:n.confirm()}},Bt=(e,t,n)=>{e.addEventListener(`click`,e=>{let{target:t}=e,r=t instanceof Element?t.closest(`button`):null;if(r!==null){let e=Lt(r);e&&zt(e[1],n);return}let i=n.cellAt(t);i!==null&&n.actions.select(i.date)},{signal:t})},Vt=`dp-ui__container--menu-open`,I=`dp-ui__container--input`,Ht=`--dp-ui-visible-months`,L=e=>e.closest(`.dp-ui__container`),Ut=(e,t)=>e!==t&&e!==`days`&&e!==`input`,R=(e,t)=>{let n=t>1;e.classList.toggle(`dp-ui__container--multi-month`,n),n?e.style.setProperty(Ht,String(t)):e.style.removeProperty(Ht)},z=(e,t,n)=>{let r=t===`input`;e.classList.toggle(I,r),R(e,r?1:n)},Wt=t=>{let{locale:n,labels:r}=t,i=e._(r),a=e.F(`div`,`dp-ui__navigation dp-ui__navigation--caption`),o=e.F(`span`,`dp-ui__caption`);o.hidden=t.arrowsOnly,a.append(o,e.f(`prev-month`,r.previousMonth,e.v.keyboardArrowLeft,i.previousMonth),e.f(`next-month`,r.nextMonth,e.v.keyboardArrowRight,i.nextMonth));let s=t=>{o.textContent=e.q(t,n)};return s(t.view),{element:a,setView:s}},Gt=(t,n)=>{let r=e.F(`div`,`dp-ui__navigation-group dp-ui__navigation-group--${t}`);return r.append(...n),r},Kt=t=>{let{labels:n}=t,r=e._(n),i=e.$(t.locale,`short`),a=e.$(t.locale,`long`),o=e.p(`month`,``,{name:n.chooseMonth,controls:e.g(t.instanceId,`month-menu`),shortcut:r.chooseMonth}),s=e.p(`year`,``,{name:n.chooseYear,controls:e.g(t.instanceId,`year-menu`),shortcut:r.chooseYear}),c=e.F(`div`,`dp-ui__header dp-ui__header--docked`),l=Gt(`month`,[e.f(`prev-month`,n.previousMonth,e.v.keyboardArrowLeft,r.previousMonth),o.button,e.f(`next-month`,n.nextMonth,e.v.keyboardArrowRight,r.nextMonth)]);l.hidden=t.groups!==`both`,c.hidden=t.groups===`none`,c.append(l,Gt(`year`,[e.f(`prev-year`,n.previousYear,e.v.keyboardArrowLeft,r.previousYear),s.button,e.f(`next-year`,n.nextYear,e.v.keyboardArrowRight,r.nextYear)]));let u=n=>{o.setText(i[n.month-1]??``,a[n.month-1]??``),s.setText(e.J(n.year,t.locale))},d=e=>{o.button.setAttribute(`aria-expanded`,String(e===`month-menu`)),s.button.setAttribute(`aria-expanded`,String(e===`year-menu`)),o.button.disabled=e===`year-menu`,s.button.disabled=e===`month-menu`};return u(t.view),d(t.home),{element:c,setView:u,setPanel:d}},qt=`dp-ui__headline--fading-out`,Jt=(t,n)=>{let r=e.F(`div`,`dp-ui__headline`);r.textContent=t;let i=null,a=null,o=()=>{a!==null&&clearTimeout(a),a=null,i=null,r.classList.remove(qt)},s=()=>{let e=i;o(),e!==null&&(r.textContent=e)};return{element:r,setText:t=>{t!==(i??r.textContent)&&(n?(i=t,r.classList.add(qt),a??=setTimeout(s,e.O.HEADLINE_FADE)):(o(),r.textContent=t))},destroy:o}},Yt=t=>{let{labels:n,switchView:r}=t,i=e.F(`div`,`dp-ui__header dp-ui__header--modal`),a=e.F(`div`,`dp-ui__supporting-text`);a.textContent=t.title;let o=Jt(t.text,t.animate);i.append(a,o.element);let s=r===null?null:e.m(n,r.panelId);return s!==null&&i.append(s.button),{element:i,setText:e=>{o.setText(e)},setInputView:e=>{s?.setInputView(e)},destroy:()=>{o.destroy()}}},Xt=(t,n,r,i,a)=>{if(a)return Wt({locale:n,labels:r,view:t,arrowsOnly:!1}).element;let o=e._(r),s=e.F(`div`,`dp-ui__navigation`);return s.append(e.p(`year-grid`,e.q(t,n),{name:r.chooseYear,controls:e.g(i,`year-grid`),shortcut:o.chooseYear}).button,e.f(`prev-month`,r.previousMonth,e.v.keyboardArrowLeft,o.previousMonth),e.f(`next-month`,r.nextMonth,e.v.keyboardArrowRight,o.nextMonth)),s},Zt=(t,n,r,i)=>{let a=e.F(`div`,`dp-ui__navigation dp-ui__navigation--month-grid`),o=e._(r);return a.append(e.p(`year-grid`,e.J(t.year,n),{name:r.chooseYear,controls:e.g(i,`year-grid`),shortcut:o.chooseYear}).button,e.f(`prev-year`,r.previousYear,e.v.keyboardArrowLeft,o.previousYear),e.f(`next-year`,r.nextYear,e.v.keyboardArrowRight,o.nextYear)),a},Qt=(t,n,r,i)=>{let a=e.F(`div`,`dp-ui__navigation dp-ui__navigation--year-grid`),{button:o}=e.p(`year-grid`,e.q(t,n),{name:r.chooseYear,controls:e.g(i,`year-grid`)});return o.setAttribute(`aria-expanded`,`true`),a.append(o),a},$t=n=>{let{decorateDate:r}=n.options;return r===null?()=>null:n=>{try{return r(e.zt(n))??null}catch(e){return t(e),null}}},en=t=>{let{renderDate:n}=t.options;return n===null?()=>null:t=>n(e.zt(t))},tn=(t,n,r)=>{let{options:i}=t;return{locale:i.locale,weekStart:i.weekStart,weekNumbers:i.weekNumbers,showOutside:r,outsideSelectable:i.outsideDays!==!1&&i.outsideDays.selectable,labels:{weekNumber:i.labels.weekNumber},rangeLabels:{start:i.labels.rangeStart,end:i.labels.rangeEnd,inRange:i.labels.inRange},headingVisible:!1,weekdaysVisible:!0,multiselectable:t.draft.mode!==`single`,rangeRole:()=>null,labelRole:()=>null,decorate:$t(t),content:en(t),isSelected:n=>e.ft(t.draft,n),isDisabled:e=>!n.isSelectable(e,t.followsActiveEnd?Je(t.draft,t.activeEnd):t.draft),today:e.Ht(),focus:t.focus}},nn=(e,t,n)=>{let r=e.layout.months>1,i=n===`docked`&&!r&&e.options.outsideDays!==!1,a=tn(e,t,i);return r?{...a,headingVisible:!0}:a},rn=(t,n)=>e.K(n,e.kt(n,t.layout.months-1),t.options.locale),B=e=>kt(e.draft,e.panel===`input`?`input`:`calendar`,e.options.locale,e.options.labels,e.options.precision),an={element:null,docked:null,modal:null,caption:null},on={days:null,input:null,"month-menu":`.dp-ui__menu-button--month`,"year-menu":`.dp-ui__menu-button--year`,"year-grid":`.dp-ui__menu-button--year-grid`,"month-grid":null},sn=e=>{switch(e){case`day`:return`both`;case`month`:return`year`;case`year`:return`none`}},cn=e=>on[e],V=(t,n)=>t.options.precision===`day`&&e.xt(n,t.options.inline).navigation===`caption`,ln=(t,n,r)=>{let{locale:i,labels:a,animation:o,viewSwitch:s,mode:c,precision:l}=t.options;if(n===`modal`){if(!e.xt(r,t.options.inline).headline)return an;let n=s&&e.Dt(c,t.calendarLayout,l),i=Yt({labels:a,title:Ct(a,c,l),animate:o,text:B(t),switchView:n?{panelId:e.g(t.instanceId,`input`)}:null});return i.setInputView(t.panel===`input`),{element:i.element,docked:null,modal:i,caption:null}}if(V(t,r)){let e=Wt({locale:i,labels:a,view:t.view,arrowsOnly:t.layout.months>1});return{element:e.element,docked:null,modal:null,caption:e}}let u=Kt({instanceId:t.instanceId,locale:i,labels:a,view:t.view,groups:sn(l),home:e.bt(l)});return{element:u.element,docked:u,modal:null,caption:null}},un=(t,n)=>{let r=e.kt(t,n);return{year:r.year,month:r.month,day:Math.min(t.day,e.Pt(r))}},dn=(t,n,r,i)=>{let a=n?12:1;switch(t){case`ArrowLeft`:return e.Ot(r,i?1:-1);case`ArrowRight`:return e.Ot(r,i?-1:1);case`ArrowUp`:return e.Ot(r,-7);case`ArrowDown`:return e.Ot(r,7);case`Home`:return{year:r.year,month:r.month,day:1};case`End`:return{...r,day:e.Pt(r)};case`PageUp`:return un(r,-a);case`PageDown`:return un(r,a);default:return null}},fn=e=>e.ctrlKey||e.altKey||e.metaKey,pn=(e,t)=>{let n=e.toLowerCase();return t===`modal`?n===`y`?`year-grid`:null:n===`m`?`month-menu`:n===`y`?`year-menu`:null},mn=e=>{let{panel:t}=e.core;return e.caption()?!1:e.layout===`docked`?e.home===`days`&&t===`days`:e.layout===`modal`&&t===e.home&&e.home!==`year-grid`},hn=(e,t)=>{let{panel:n}=t.core;n!==t.home&&n!==`input`&&(e.preventDefault(),e.stopPropagation(),t.actions.showPanel(t.home))},gn=(e,t)=>{if(!e.shiftKey||!mn(t))return!1;let n=pn(e.key,t.layout);return n!==null&&(e.preventDefault(),t.actions.showPanel(n),!0)},_n=(t,n,r)=>{t.preventDefault(),t.key===`Enter`&&r.layout===`modal`&&r.core.options.mode===`single`&&e.Tt(r.core.options.footerExplicit,r.core.mode)&&e.ft(r.core.draft,n.date)?r.actions.confirm():r.actions.select(n.date)},vn=(e,t,n)=>{if(e.key===`Enter`||e.key===` `){_n(e,t,n);return}let r=dn(e.key,e.shiftKey,t.date,n.isRtl());r!==null&&(e.preventDefault(),n.actions.focusDate(r))},yn=(e,t,n)=>{e.addEventListener(`keydown`,e=>{if(e.defaultPrevented)return;if(e.key===`Escape`){hn(e,n);return}if(fn(e)||gn(e,n))return;let t=n.cellAt(e.target);t!==null&&vn(e,t,n)},{signal:t})},H=`dp-ui__ghost`,bn=e=>Array.from(e.querySelectorAll(`*`)).filter(e=>e.closest(`.${H}`)===null),xn=(e,t,n)=>{e.querySelectorAll(`.${H}`).forEach(e=>{e.remove()}),e.removeAttribute(`popover`),e.removeAttribute(`style`),e.classList.remove(`dp-ui__container--morphing`),e.classList.add(H),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``),e.removeAttribute(`id`),e.removeAttribute(`name`),e.querySelectorAll(`[id], [name]`).forEach(e=>{e.removeAttribute(`id`),e.removeAttribute(`name`)}),e.style.setProperty(`inline-size`,`${String(t)}px`),e.style.setProperty(`block-size`,`${String(n)}px`)},Sn=(e,t)=>{let n=Array.from(t.querySelectorAll(`*`));return bn(e).flatMap((e,t)=>{let r=n.at(t);return r===void 0||e.scrollTop===0&&e.scrollLeft===0?[]:[{live:e,copy:r,top:e.scrollTop,left:e.scrollLeft}]})},Cn=({live:e,copy:t})=>{let n=e.getBoundingClientRect(),r=Array.from(t.children);Array.from(e.children).forEach((e,t)=>{let i=r.at(t),a=e.getBoundingClientRect();i===void 0||a.bottom>n.top&&a.top<n.bottom||(i.replaceChildren(),i instanceof HTMLElement&&i.style.setProperty(`block-size`,`${String(a.height)}px`))})},wn=(t,n,r)=>{let i=t.cloneNode(!0);if(!(i instanceof HTMLElement))return null;xn(i,n,r);let a=Sn(t,i);a.forEach(Cn);let o=null,s=()=>{if(o!==null){let e=o;o=null,e.cancel()}i.remove()};return{show:()=>{t.append(i),a.forEach(({copy:e,top:t,left:n})=>{e.scrollTop=t,e.scrollLeft=n}),typeof i.animate==`function`?(o=i.animate([{opacity:1},{opacity:0}],{duration:e.O.VIEW_SWITCH_FADE_OUT,easing:`linear`,fill:`forwards`}),o.finished.then(s,s)):s()},remove:s}},Tn=`dp-ui__container--morphing`,U=/* @__PURE__ */ new WeakMap,En=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height,radius:getComputedStyle(e).borderRadius}},Dn=(e,t)=>{if(t===null)return null;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:getComputedStyle(t).direction===`rtl`?n.right-r.right:r.left-n.left,y:r.top-n.top,height:r.height}},On=e=>({width:`${String(e.width)}px`,height:`${String(e.height)}px`,borderRadius:e.radius}),kn=(t,n,r)=>{if(r.height===0)return;let i=getComputedStyle(t).direction===`rtl`,a=(n.x-r.x)*(i?-1:1),o=n.y-r.y,s=n.height/r.height;if(a===0&&o===0&&s===1)return;let c=i?`top right`:`top left`;t.animate([{transform:`translate(${String(a)}px, ${String(o)}px) scale(${String(s)})`,transformOrigin:c},{transform:`none`,transformOrigin:c}],{duration:e.O.VIEW_SWITCH,easing:e.E.EMPHASIZED})},An=(t,n,r)=>{if(r===`none`||typeof t.animate!=`function`)return n(),null;if(r===`reduced`){let e=En(t),r=wn(t,e.width,e.height);return n(),r?.show(),null}let i=t.querySelector(`.dp-ui__headline`),a=En(t),o=Dn(t,i),s=wn(t,a.width,a.height);n();let c=En(t),l=Dn(t,i);t.classList.add(Tn);let u=t.animate([On(a),On(c)],{duration:e.O.VIEW_SWITCH,easing:e.E.EMPHASIZED});U.set(t,u),s?.show(),i!==null&&o!==null&&l!==null&&kn(i,o,l);let d=()=>{s?.remove(),U.get(t)===u&&(U.delete(t),t.classList.remove(Tn))};return u.finished.then(d,d),u};function jn(t){let n=t.describedById??`${t.id}-supporting`,r=e.F(`div`,`dp-ui__text-field`),i=e.F(`input`,`dp-ui__text-field-input`,{id:t.id,type:`text`,inputmode:`numeric`,autocomplete:`off`,placeholder:t.placeholder,tabindex:`0`,"aria-invalid":`false`,"aria-describedby":n});i.value=t.value;let a=e.F(`label`,`dp-ui__text-field-label`,{for:t.id});a.textContent=t.label;let o=e.F(`div`,`dp-ui__text-field-supporting`,{id:n,"aria-live":`polite`});return o.textContent=t.hint,r.append(i,a,o),{element:r,input:i,getValue:()=>i.value,setValue:e=>{i.value=e},setError:e=>{let n=e!==null;r.classList.toggle(`dp-ui__text-field--error`,n),i.setAttribute(`aria-invalid`,n?`true`:`false`);let a=e??t.hint;o.textContent!==a&&(o.textContent=a)}}}function Mn(e){return e.mode===`single`?e.date:null}function Nn(e){return e.mode===`single`?e.date===null:e.mode===`range`?e.start===null:e.dates.length===0}function Pn(t){let{instanceId:n,draft:r,pattern:i,labels:a,rules:o}=t,s=e.F(`div`,`dp-ui__input-panel`,{"data-panel":`input`,id:e.g(n,`input`)}),c=e.at(i,e.ot(a)),l=(t,r,a)=>jn({id:`${n}-input-${t}`,label:r,placeholder:c,hint:c,value:a?e.it(a,i):``}),u=r.mode===`range`,d=l(u?`start`:`date`,u?a.startDateField:a.dateField,r.mode===`range`?r.start:Mn(r)),f=u?l(`end`,a.endDateField,r.end):null,p=f?[d,f]:[d],m=n=>{let r=n.getValue().trim();if(r===``)return n.setError(null),{date:null,failed:!1};let s=e.W(r,i);if(s===null)return n.setError(a.invalidDate),{date:null,failed:!0};let c=o.unavailableReason(s);return c===null?(n.setError(null),n.setValue(e.it(s,i)),{date:s,failed:!1}):(n.setError(t.messageFor(c)),{date:null,failed:!0})},h=()=>{let t=m(d);if(!f)return t.failed?null:{mode:`single`,date:t.date};let n=m(f),r=n.date,i=t.failed||n.failed;return t.date&&r&&e.At(r,t.date)<0&&(f.setError(a.invalidRange),r=null,i=!0),i?null:{mode:`range`,start:t.date,end:r}},g=e=>{let n=P(e,t.limits,e=>o.unavailableReason(e));return n===null||((f??d).setError(t.messageFor(n)),!1)};return p.forEach(n=>{n.input.addEventListener(`input`,()=>{e.d(n.input,i)}),n.input.addEventListener(`change`,()=>{let e=h();e&&g(e)&&t.onDraft(e)}),n.input.addEventListener(`keydown`,n=>{if(n.key!==`Enter`)return;n.preventDefault();let r=h();r&&g(r)&&e.dt(r)&&!Nn(r)&&(t.onDraft(r),t.onSubmit())})}),s.append(...p.map(e=>e.element)),s}function Fn(t,n){let{labels:r,minDate:i,maxDate:a,pattern:o,precision:s}=n;return t===`min`&&i!==null?r.beforeMinDate.replace(`{date}`,e.R(i,o,s)):t===`max`&&a!==null?r.afterMaxDate.replace(`{date}`,e.R(a,o,s)):t===`range-length`?r.invalidRange:r.unavailableDate}const In=t=>{let{core:n,actions:r,rules:i}=t,{pattern:a,labels:o,limits:s}=n.options;return[Pn({instanceId:n.instanceId,draft:n.draft,pattern:a,labels:o,rules:i,limits:s,messageFor:e=>Fn(e,n.options),onDraft:e=>{r.typeDraft(e)},onSubmit:()=>{e.Tt(n.options.footerExplicit,n.mode)?r.confirm():r.submitDraft()}})]},Ln=`dp-ui__date`,Rn=`dp-ui__date--outside-month`,zn=`data-decoration-label`,W=`data-content-label`,Bn=`dp-ui__date-content`,Vn=`dp-ui__date--has-content`,Hn=`:scope > .${Bn}`,Un=(e,t,n)=>n.isDisabled(e)||t&&!n.outsideSelectable,Wn=(t,n,r,i)=>[[`dp-ui__date--selected`,i.isSelected(t)],[`dp-ui__date--range-start`,r===`start`],[`dp-ui__date--range-end`,r===`end`],[`dp-ui__date--in-range`,r===`in-range`],[`dp-ui__date--today`,e.It(t,i.today)],[`dp-ui__date--disabled`,Un(t,n,i)],[Rn,n]],Gn=e=>{e.querySelector(Hn)?.remove(),e.classList.remove(Vn),e.removeAttribute(W)},Kn=(t,n,r)=>{let i=r.content(n);if(i===null){Gn(t);return}let a=t.querySelector(Hn),o=(typeof i==`string`?i:i.textContent??``).trim();if(typeof i!=`string`||a===null||a.childElementCount!==0||a.textContent!==i){let n=e.F(`span`,Bn);typeof i==`string`?n.textContent=i:n.appendChild(i),a===null?t.querySelector(`.dp-ui__date-indicator`)?.after(n):a.replaceWith(n)}t.classList.add(Vn),o===``?t.removeAttribute(W):t.setAttribute(W,o)},qn=(e,t)=>e===`start`?t.rangeLabels.start:e===`end`?t.rangeLabels.end:e===`in-range`?t.rangeLabels.inRange:null,Jn=(t,n,r,i,a)=>[e.G(t,a.locale),qn(n,a),r,i].filter(e=>e!==null&&e!==``).join(`, `),Yn=(t,n,r,i)=>{let a=i.rangeRole(n);Kn(t,n,i),Wn(n,r,a,i).forEach(([e,n])=>t.classList.toggle(e,n)),t.setAttribute(`aria-selected`,String(i.isSelected(n)||a!==null)),t.setAttribute(`aria-label`,Jn(n,i.labelRole(n),t.getAttribute(zn),t.getAttribute(W),i)),e.It(n,i.today)?t.setAttribute(`aria-current`,`date`):t.removeAttribute(`aria-current`),Un(n,r,i)?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);let o=!r&&e.It(n,i.focus);t.setAttribute(`tabindex`,o?`0`:`-1`)},Xn=(t,n)=>{if(n===null)return;let r=(n.className??``).split(/\s+/).filter(Boolean);t.classList.add(...r),n.label&&t.setAttribute(zn,n.label),n.badge===!0&&t.appendChild(e.F(`span`,`dp-ui__date-badge`,{"aria-hidden":`true`}))},Zn=(t,n)=>{if(!t.inMonth&&!n.showOutside)return e.F(`td`,`${Ln} dp-ui__date--empty`);let r=e.F(`td`,Ln,{role:`gridcell`,"data-date":e.Bt(t.date)}),i=e.F(`span`,`dp-ui__date-indicator`);return i.textContent=e.J(t.date.day,n.locale),r.appendChild(i),Xn(r,n.decorate(t.date)),Yn(r,t.date,!t.inMonth,n),r},Qn=`dp-ui__visually-hidden`,$n=t=>{let n=e.F(`thead`),r=e.F(`tr`,t.weekdaysVisible?`dp-ui__weekdays`:`dp-ui__weekdays ${Qn}`);if(t.weekNumbers){let n=e.F(`th`,`dp-ui__week-number-header`,{scope:`col`});n.textContent=t.labels.weekNumber,r.appendChild(n)}let i=e.nt(t.locale,`narrow`),a=e.nt(t.locale,`long`);for(let n=0;n<7;n++){let o=(t.weekStart+n)%7,s=a[o]??``,c=e.F(`th`,`dp-ui__weekday`,{role:`columnheader`,scope:`col`,abbr:s,title:s});c.textContent=i[o]??``,r.appendChild(c)}return n.appendChild(r),n},er=(t,n)=>{let r=e.F(`table`,`dp-ui__month-grid`,{role:`grid`});n.multiselectable===!0&&r.setAttribute(`aria-multiselectable`,`true`);let i=e.F(`caption`,n.headingVisible?`dp-ui__month-subhead`:`dp-ui__month-heading ${Qn}`);i.textContent=e.q(t.view,n.locale),r.appendChild(i),r.appendChild($n(n));let a=e.F(`tbody`);return t.weeks.forEach((r,i)=>{let o=e.F(`tr`,`dp-ui__week`);if(n.weekNumbers){let r=e.F(`th`,`dp-ui__week-number`,{scope:`row`}),a=t.weekNumbers.at(i);r.textContent=a===void 0?``:e.J(a,n.locale),o.appendChild(r)}r.forEach(e=>o.appendChild(Zn(e,n))),a.appendChild(o)}),r.appendChild(a),r},tr=(t,n)=>{t.querySelectorAll(`td[data-date]`).forEach(t=>{let r=e.Ft(t.dataset.date??``);r!==null&&Yn(t,r,t.classList.contains(Rn),n)})},nr=(t,n,r)=>{let i={year:t.year,month:t.month,day:1},a=(e.Mt(i)-n+7)%7,o=r?6:Math.ceil((a+e.Pt(t))/7),s=e.Ot(i,-a),c=(4-n+7)%7,l=[],u=[];for(let n=0;n<o;n++){let r=e.Ot(s,n*7),i=[];for(let n=0;n<7;n++){let a=e.Ot(r,n);i.push({date:a,inMonth:a.year===t.year&&a.month===t.month})}l.push(i),u.push(e.Lt(e.Ot(r,c)))}return{view:t,weeks:l,weekNumbers:u}},rr=`table.dp-ui__month-grid`,ir=(e,t)=>{e.style.setProperty(`transition`,`none`),t(),e.getBoundingClientRect(),e.style.removeProperty(`transition`)},ar=t=>{let{core:n,layout:r,surface:i,gridContext:a}=t,{months:o}=n.layout,{outsideSelectable:s,headingVisible:c}=a(),l=i===`inline`,{fixedWeeks:u}=gt({layout:r===`modal`?`modal`:`docked`,inline:l,months:o,outsideDays:n.options.outsideDays!==!1,fixedWeeks:n.options.fixedWeeks}),d=r===`docked`||l,f=i!==void 0&&V(n,i),p=e.F(`div`,void 0,{"data-panel":`days`}),m=e=>p.querySelector(`.dp-ui__page:not([inert])`)?.querySelector(e)??null,h=e=>nr(e,n.options.weekStart,u),g=t=>Array.from({length:o},(n,r)=>e.kt(t,r)),_=t=>{let n=a();if(o===1)return er(h(t),n);let r=e.F(`div`,`dp-ui__months`);return r.append(...g(t).map(e=>er(h(e),n))),r},v=t=>{let i=e.F(`div`);if(r===`modal`){let{locale:e,labels:r}=n.options;i.append(Xt(t,e,r,n.instanceId,f))}return i.append(_(t)),i},y=e=>Math.max(...g(e).map(e=>h(e).weeks.length)),b=e=>{let t=y(e),n=m(`.dp-ui__navigation`)?.getBoundingClientRect().height??0,r=p.querySelector(rr),i=r?.tHead?.getBoundingClientRect().height??0,a=(r?.tBodies.item(0)?.rows.item(0))?.getBoundingClientRect().height??0,o=c?r?.caption?.getBoundingClientRect().height??0:0;return i>0&&a>0?n+o+i+a*t:n+(t+(c?2:1))*48},x=n.options.pageBy===`view`?o:1,S=new e.o(p,{rtl:t.rtl,swipe:n.options.swipe,animate:n.options.animation,fitHeight:d,step:(t,n)=>e.kt(t,n*x),isSame:e.s,renderPage:v,pageHeight:b,onCommit:(e,n)=>{t.onCommit(e,n)}}),C=()=>p.ownerDocument.activeElement,w=t=>{if(!(t instanceof Element))return null;let n=t.closest(`td.dp-ui__date[data-date]`);if(n===null||!p.contains(n)||n.classList.contains(`dp-ui__date--outside-month`)&&!s)return null;let r=e.Ft(n.getAttribute(`data-date`)??``);return r===null?null:{element:n,date:r}},T=()=>w(C())!==null,E=e=>{let t=m(`td.dp-ui__date[tabindex="0"]`);return t!==null||!e?t:m(`td.dp-ui__date[data-date]:not(.dp-ui__date--outside-month)`)},D=e=>{E(e)?.focus({preventScroll:!0})},O=()=>{let e=C();return e===null||!p.contains(e)?null:{buttonClass:Rt(e)}},k=e=>{let{buttonClass:t}=e;((t===null?null:m(`.${t}`))??E(!0))?.focus({preventScroll:!0})},A=e=>{let t=O();e(),t!==null&&k(t)};return{element:p,present:(e,t)=>{A(()=>{t===0?S.show(e):S.slide(e,t>0?1:-1)})},finish:()=>{S.finish()},refresh:()=>{let e=a();p.querySelectorAll(rr).forEach(t=>{tr(t,e)})},refit:()=>{if(!d||p.hidden)return;let e=`${String(b(n.view))}px`;p.style.getPropertyValue(`--dp-ui-pager-height`)!==e&&A(()=>{ir(p,()=>{S.show(n.view)})})},cellAt:w,focusCell:D,cellHasFocus:T,find:m,destroy:()=>{S.destroy()}}},or=t=>{let n=document.createElement(`div`);n.className=t.className,n.setAttribute(`role`,`listbox`),n.setAttribute(`aria-label`,t.label);let r=[],i=t.focused>=0&&t.focused<t.items.length?t.focused:0,a=(t,i)=>{let a=r.at(Math.max(0,Math.min(r.length-1,i)));a&&(r.at(t)?.setAttribute(`tabindex`,`-1`),a.setAttribute(`tabindex`,`0`),a.focus({preventScroll:!0}),e.L(n,a,`nearest`))},o=e=>{let t=getComputedStyle(n).direction===`rtl`?-1:1;switch(e){case`ArrowRight`:return t;case`ArrowLeft`:return-t;case`ArrowDown`:return 3;case`ArrowUp`:return-3;default:return null}};return t.items.forEach((e,s)=>{let c=document.createElement(`button`);c.type=`button`,c.className=t.itemClass,c.setAttribute(`role`,`option`),c.setAttribute(`aria-selected`,e.selected?`true`:`false`),c.setAttribute(`aria-label`,e.name),c.setAttribute(`tabindex`,s===i?`0`:`-1`),e.selected&&c.classList.add(`${t.itemClass}--selected`),e.current&&c.classList.add(`${t.itemClass}--current`),e.disabled&&c.setAttribute(`aria-disabled`,`true`),c.textContent=e.label;let l=()=>{e.disabled||e.onPick()};c.addEventListener(`click`,l),c.addEventListener(`keydown`,e=>{let t=o(e.key);t===null?e.key===`Home`?(e.preventDefault(),a(s,0)):e.key===`End`?(e.preventDefault(),a(s,r.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l()):(e.preventDefault(),a(s,s+t))}),r.push(c),n.appendChild(c)}),requestAnimationFrame(()=>{let a=n.querySelector(`.${t.itemClass}--selected`)??r.at(i);a&&e.L(n,a,`center`)}),n},sr=t=>{let n=e.$(t.locale,`short`),r=e.$(t.locale,`long`),i=e.J(t.year,t.locale);return or({className:`dp-ui__month-selection`,itemClass:`dp-ui__month-selection-item`,label:t.label,focused:t.focused-1,items:n.map((e,n)=>{let a=n+1;return{label:e,name:`${r[n]??e} ${i}`,selected:a===t.selected,current:t.current.year===t.year&&t.current.month===a,disabled:t.isDisabled(a),onPick:()=>{t.onPick(a)}}})})},cr=t=>{let n=t.querySelector(`.dp-ui__menu-item--selected`);n&&e.L(t,n,`center`)},G=(t,n,r)=>{let i=t.at(Math.max(0,Math.min(t.length-1,r))),a=t.at(n);i&&(a?.setAttribute(`tabindex`,`-1`),i.setAttribute(`tabindex`,`0`),i.focus({preventScroll:!0}),i.parentElement&&e.L(i.parentElement,i,`nearest`))},lr=(t,n,r)=>{let i=document.createElement(`ul`);i.className=`dp-ui__menu dp-ui__menu--${t}`,i.setAttribute(`role`,`listbox`),i.setAttribute(`aria-label`,n);let a=r.some(e=>e.selected),o=r.map((t,n)=>{let r=document.createElement(`li`);r.className=`dp-ui__menu-item`,r.setAttribute(`role`,`option`),r.setAttribute(`aria-selected`,t.selected?`true`:`false`);let i=t.selected||!a&&n===0;if(r.setAttribute(`tabindex`,i?`0`:`-1`),t.selected){r.classList.add(`dp-ui__menu-item--selected`);let t=document.createElement(`span`);t.innerHTML=e.v.check;let n=t.firstElementChild;n&&(n.setAttribute(`class`,`dp-ui__menu-item-icon`),n.setAttribute(`aria-hidden`,`true`),r.appendChild(n))}t.disabled&&r.setAttribute(`aria-disabled`,`true`);let o=document.createElement(`span`);o.className=`dp-ui__menu-item-label`,o.textContent=t.label,r.appendChild(o);let c=()=>{t.disabled||t.onPick()};return r.addEventListener(`click`,c),r.addEventListener(`keydown`,e=>{e.key===`ArrowDown`?(e.preventDefault(),G(s,n,n+1)):e.key===`ArrowUp`?(e.preventDefault(),G(s,n,n-1)):e.key===`Home`?(e.preventDefault(),G(s,n,0)):e.key===`End`?(e.preventDefault(),G(s,n,s.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())}),r}),s=o;return o.forEach(e=>i.appendChild(e)),requestAnimationFrame(()=>{cr(i)}),i},ur=t=>{let n=e.$(t.locale,`long`);return lr(`month`,t.label,n.map((e,n)=>{let r=n+1;return{label:e,selected:r===t.view.month,disabled:t.isMonthDisabled({year:t.view.year,month:r}),onPick:()=>{t.onPick(r)}}}))},dr=t=>or({className:`dp-ui__year-selection`,itemClass:`dp-ui__year-selection-item`,label:t.label,focused:t.years.indexOf(t.focused),items:t.years.map(n=>{let r=e.J(n,t.locale);return{label:r,name:r,selected:n===t.selected,current:n===t.currentYear,disabled:!1,onPick:()=>{t.onPick(n)}}})}),fr=t=>lr(`year`,t.label,t.years.map(n=>({label:e.J(n,t.locale),selected:n===t.view.year,disabled:!1,onPick:()=>{t.onPick(n)}}))),pr=e=>{let{min:t,max:n}=e.yearBounds(),r=[];for(let e=t;e<=n;e++)r.push(e);return r},mr=(t,n)=>{let r=e.lt(t.draft);return r?.year===n?r.month:null},K=(t,n,r)=>(t.setAttribute(`data-panel`,n),t.id=e.g(r,n),t),hr=(t,n)=>{let{core:r,rules:i}=n,{labels:a,locale:o}=r.options,s=r.view,{precision:c}=r.options,l=e=>{n.actions.jumpTo(e,`menu`)},u=e=>{l({year:e,month:r.view.month})};switch(t){case`month-menu`:return[K(ur({locale:o,view:s,label:a.chooseMonth,isMonthDisabled:e=>i.isMonthDisabled(e),onPick:e=>{l({year:r.view.year,month:e})}}),t,r.instanceId)];case`year-menu`:return[K(fr({view:s,years:pr(i),label:a.chooseYear,locale:o,onPick:u}),t,r.instanceId)];case`month-grid`:{let u=c===`month`,d=u?mr(r,s.year):s.month,f=K(sr({year:s.year,selected:d,focused:d??s.month,current:e.Ht(),locale:o,label:a.chooseMonth,isDisabled:e=>i.isMonthDisabled({year:r.view.year,month:e}),onPick:e=>{u?n.actions.select({year:r.view.year,month:e,day:1}):l({year:r.view.year,month:e})}}),t,r.instanceId);return n.layout===`docked`?[f]:[Zt(s,o,a,r.instanceId),f]}case`year-grid`:{let l=c===`year`,d=l?e.lt(r.draft)?.year??null:s.year,f=K(dr({selected:d,focused:d??s.year,years:pr(i),currentYear:e.Ht().year,label:a.chooseYear,locale:o,onPick:l?e=>{n.actions.select({year:e,month:1,day:1})}:u}),t,r.instanceId);return n.layout===`docked`||l?[f]:[Qt(s,o,a,r.instanceId),f]}}},gr=`[role="option"]`,_r=`data-rebuilt`,vr=t=>{let{root:n,content:r,days:i}=t,a=`days`,o=[],s=null,c=()=>n.ownerDocument.activeElement,l=e=>{e===`days`?i.hidden=!0:(o.forEach(e=>{e.remove()}),o=[])},u=e=>{e===`days`?(i.hidden=!1,i.removeAttribute(_r)):(o=t.createParts(e),i.after(...o))},d=()=>{let e=s;e!==null&&(s=null,e.complete(),e.animations.forEach(e=>{e.cancel()}))},f=()=>{let e=s;s=null,e?.animations.forEach(e=>{e.cancel()})},p=(e,n,r)=>{let i=t.motion()===`none`?[]:e.filter(e=>!e.hidden&&typeof e.animate==`function`);if(i.length===0){r();return}let a=i.map(e=>e.animate([{opacity:1},{opacity:0}],{duration:n,easing:`linear`,fill:`forwards`})),o={animations:a,complete:r};s=o,Promise.all(a.map(e=>e.finished)).then(()=>{s===o&&d()},()=>void 0)},m=()=>{let e=i.getBoundingClientRect().height;e>0&&r.style.setProperty(`--dp-ui-panel-height`,`${String(e)}px`)},h=r=>{d();let s=a;if(r===s)return;s===`days`&&m();let f=n.contains(c()),h=r===`input`||s===`input`;a=r;let g=()=>{let e=()=>{l(s),u(r),t.onSwitched(r,s,f)};t.swap===void 0?e():t.swap(e,r,s)};h?g():p(s===`days`?[i]:o,e.O.PANEL_FADE_OUT,g)},g=(e,t)=>{f(),e!==a&&(l(a),a=e,u(e),t?.rebuilt===!0&&o.forEach(e=>{e.setAttribute(_r,``)}))},_=e=>{let t=e.closest(`[role="listbox"]`);return t===null?-1:Array.from(t.querySelectorAll(gr)).indexOf(e)},v=e=>{for(let t of o){let n=e(t);if(n)return n}return null},y=(e,t)=>t>=0?v(e=>Array.from(e.querySelectorAll(gr)).at(t)):e===null?null:v(t=>t.querySelector(`.${e}`));return{current:()=>a,settled:()=>s===null,mount:g,switchTo:h,rebuild:()=>{if(a===`days`||a===`input`||s!==null)return;let e=c(),t=e!==null&&o.some(t=>t.contains(e))?e:null,n=t===null?null:Rt(t),r=t===null?-1:_(t),i=o.map(e=>e.scrollTop);l(a),u(a),o.forEach(e=>{e.setAttribute(_r,``)}),requestAnimationFrame(()=>{o.forEach((e,t)=>{e.scrollTop=i.at(t)??e.scrollTop})}),t!==null&&y(n,r)?.focus({preventScroll:!0})},entry:()=>{for(let e of o){let t=e.querySelector(`[tabindex="0"]`);if(t!==null)return t}return null},destroy:f}},yr=t=>{let{root:n,core:r,actions:i,rules:a,mode:o,layout:s}=t,c=r.options,l=ln(r,s,o),u=ar({core:r,layout:s,surface:o,rtl:t.rtl,gridContext:()=>nn(r,a,s),onCommit:(e,t)=>{i.page(e,t)}}),d=e.F(`div`,`dp-ui__content`);d.append(u.element);let f=vr({root:n,content:d,days:u.element,motion:t.motion,createParts:e=>e===`input`?In({core:r,actions:i,rules:a}):hr(e,{core:r,actions:i,rules:a,layout:s}),swap:(e,i,a)=>{let o=L(n);o===null||i!==`input`&&a!==`input`?e():An(o,()=>{e(),z(o,i,r.layout.months)},t.motion())},onSwitched:t.onSwitched}),p=Ft({labels:c.labels,visible:e.Tt(c.footerExplicit,o),todayButton:c.todayButton,clearButton:c.clearButton!==!1}),m=e.F(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`});return n.replaceChildren(...l.element===null?[]:[l.element],d,p,m),{header:l,pages:u,panels:f,liveRegion:m}},br=[`drag`,`wheel`,`button`,`keyboard`,`menu`],xr=e=>br.includes(e),Sr=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t===`modal`)},Cr=t=>{let{core:n,actions:r,rules:i,mode:a}=t,o=n.calendarLayout===`docked`?`docked`:`modal`,s=new AbortController,c=e.F(`div`,`dp-ui__calendar`),l,u=0,d=()=>c.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(n.input).direction===`rtl`,f=()=>L(c),p=()=>e.bt(n.options.precision),m=e=>l.pages.cellAt(e),h=(e,t=!0)=>{l.header.docked?.setPanel(e);let r=f();r!==null&&(r.classList.toggle(Vt,Ut(e,p())),t&&z(r,e,n.layout.months))},g=e=>{e===null?l.pages.focusCell(!0):e.focus({preventScroll:!0})},_=e=>{let t=cn(e);return t===null?null:l.header.element?.querySelector(t)??l.pages.find(t)},v=(e,t,n)=>{e===`days`&&l.pages.refit(),n&&g(e===`days`?t===`input`?null:_(t):l.panels.entry())},y=(t=!1)=>{Sr(c,o),l=yr({root:c,core:n,actions:r,rules:i,mode:a,layout:o,rtl:d(),motion:()=>e.M(n.options.animation),onSwitched:v}),l.pages.present(n.view,0),l.panels.mount(n.panel,{rebuilt:t}),t&&l.pages.element.setAttribute(`data-rebuilt`,``),h(n.panel),l.header.modal?.setInputView(n.panel===`input`),Pt(c,e.dt(n.draft)),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=0,h(l.panels.current()),l.pages.refit()})},b=()=>{l.panels.destroy(),l.pages.destroy(),l.header.modal?.destroy()},x=()=>{s.signal.aborted||(h(l.panels.current()),l.pages.refit())},S=()=>{s.signal.aborted||(x(),g(l.panels.entry()))},C=(t,r,i)=>{l.header.docked?.setView(t),l.header.caption?.setView(t);let a=xr(i),o=a&&l.panels.current()===`days`&&l.panels.settled();l.pages.present(t,o?r:0),l.panels.rebuild(),a&&e.j(l.liveRegion,rn(n,t))},w=()=>{let e=l.pages.cellHasFocus();l.pages.refresh(),e&&l.pages.focusCell(!1)},T=e=>{l.pages.finish(),h(e,!1),l.header.modal?.setInputView(e===`input`),l.header.modal?.setText(B(n)),l.panels.switchTo(e)},E=()=>{l.pages.refresh(),l.panels.rebuild(),l.header.modal?.setText(B(n)),Pt(c,e.dt(n.draft));let{announceSelection:t}=e.xt(a,n.options.inline);t&&l.panels.current()===p()&&e.j(l.liveRegion,B(n))};return y(),(e=>{let{events:t}=n;t.on(`change:view`,e=>{C(e.view,e.delta,e.source)},e),t.on(`change:draft`,E,e),t.on(`change:focus`,w,e),t.on(`change:panel`,e=>{T(e.panel)},e),Bt(c,e,{actions:r,panel:()=>n.panel,home:p(),cellAt:m}),yn(c,e,{core:n,actions:r,layout:o,home:p(),caption:()=>V(n,a),cellAt:m,isRtl:d}),Nt(c,`.dp-ui__icon-button, .dp-ui__menu-button, .dp-ui__text-button, .dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator, .dp-ui__menu-item, .dp-ui__year-selection-item, .dp-ui__month-selection-item`,e)})(s.signal),{element:c,focusInitial:S,fit:x,update:()=>{if(s.signal.aborted)return;let e=c.contains(c.ownerDocument.activeElement);b(),y(!0),e&&S()},destroy:()=>{if(s.signal.aborted)return;s.abort(),cancelAnimationFrame(u),b();let e=f();e!==null&&(e.classList.remove(Vt,I),R(e,1)),c.remove()}}},q=e=>({year:e.year,month:e.month}),wr=t=>{let n=e.lt(t.draft);return n===null?t.view:q(n)},Tr=(t,n)=>{let{minDate:r,maxDate:i}=t.options,a=n.yearBounds(),o={year:a.min,month:1},s={year:a.max,month:12},c=r!==null&&e.Rt(o,r)>0,l=i!==null&&e.Rt(i,s)>0;return{first:c?q(r):o,last:l?q(i):s}},J=(t,n)=>e.Rt(n.first,t)<0?n.first:e.Rt(t,n.last)<0?n.last:t,Er=t=>{let n=e.F(`div`,`dp-ui__top-bar`);return n.append(e.f(`close`,t.close,e.v.close),e.h(`save`,t.save)),n},Dr=t=>{let{labels:n,switchView:r}=t,i=e.F(`div`,`dp-ui__header-text`),a=e.F(`div`,`dp-ui__supporting-text`);a.textContent=n.rangeTitle;let o=Jt(t.text,t.animate);i.append(a,o.element);let s=r===null?null:e.m(n,r.panelId);return{nodes:s===null?[i]:[i,s.button],headline:o,switchButton:s}},Or=t=>{if(t.length===0)return null;let n=e.F(`div`,`dp-ui__header dp-ui__header--range`);return n.append(...t),n},kr=e=>{let t=e.fullscreen?Er(e.labels):null,n=e.headline?Dr(e):null,r=Or([...t===null?[]:[t],...n===null?[]:n.nodes]);return{element:r,setText:e=>{n?.headline.setText(e)},setInputView:e=>{t!==null&&(t.hidden=e),r!==null&&n===null&&(r.hidden=e),n?.switchButton?.setInputView(e)},destroy:()=>{n?.headline.destroy()}}},Ar=(t,n)=>{let r=e.F(`div`,`dp-ui__weekdays-bar`,{"aria-hidden":`true`}),i=e.nt(t,`narrow`);for(let t=0;t<7;t++){let a=e.F(`span`,`dp-ui__weekday`);a.textContent=i.at((n+t)%7)??``,r.append(a)}return r},jr=(e,t)=>t===`x`?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight,Mr=(e,t)=>t===`x`?e.clientX:e.clientY,Nr=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},Pr=(e,t,n)=>{t===`x`?e.scrollLeft+=n:e.scrollTop+=n},Fr=(t,n,r=`x`,i={})=>{let a=null,o=0,s=0,c=0,l=!1;r===`x`&&t.addEventListener(`wheel`,e=>{jr(t,r)&&(Math.abs(e.deltaY)<=Math.abs(e.deltaX)||(e.preventDefault(),t.scrollLeft+=e.deltaY))},{signal:n,passive:!1}),t.addEventListener(`pointerdown`,e=>{e.pointerType===`mouse`&&e.button===0&&jr(t,r)&&(a=e.pointerId,o=Mr(e,r),s=o,c=0,l=!1)},{signal:n}),t.addEventListener(`pointermove`,n=>{if(n.pointerId!==a)return;let i=Mr(n,r);c=i-o,!l&&Math.abs(c)<e.D.DRAG_START_PX||(l||(l=!0,Nr(t,n.pointerId)),Pr(t,r,s-i),s=i)},{signal:n}),t.addEventListener(`selectstart`,e=>{a!==null&&e.preventDefault()},{signal:n});let u=e=>{e.pointerId===a&&(a=null,t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),l&&e.type===`pointerup`&&c!==0&&i.onDragEnd?.(c<0?1:-1))};t.addEventListener(`pointerup`,u,{signal:n}),t.addEventListener(`pointercancel`,u,{signal:n}),t.addEventListener(`click`,e=>{l&&(l=!1,e.stopPropagation(),e.preventDefault())},{signal:n,capture:!0})},Ir=(t,n,r)=>({...tn(t,n,!1),outsideSelectable:!1,weekNumbers:!1,headingVisible:!0,weekdaysVisible:r,rangeRole:n=>e.ht(t.draft,n),labelRole:n=>e.mt(t.draft,n)}),Lr=(e,t,n)=>er(nr(n,e.options.weekStart,!1),Ir(e,t,!1)),Rr=`td.dp-ui__date[data-date]`,zr=t=>{let{core:n,rules:r}=t,i=new AbortController,a=e.F(`div`,`dp-ui__month-list`),o=[],s=null,c=0,l=!1,u=0,d=(n,r)=>Array.from({length:r},(r,i)=>t.render(e.kt(n,i))),f=()=>{s!==null&&t.onRendered(s,e.kt(s,o.length-1))},p=n=>{if(s===null)return;let r=e.kt(s,o.length),i=e.Rt(r,t.bounds().last)+1,c=Math.min(n,i);if(c<=0)return;let l=d(r,c);o.push(...l),a.append(...l),f()},m=n=>{if(s===null)return;let r=e.Rt(t.bounds().first,s),i=Math.min(n,r);if(i<=0)return;let c=e.kt(s,-i),l=d(c,i),u=a.scrollTop,p=a.scrollHeight;s=c,o.unshift(...l),a.prepend(...l),a.scrollTop=u+a.scrollHeight-p,f()},h=n=>{if(s===null)return;let r=J(n,t.bounds());m(e.Rt(r,s)),p(e.Rt(e.kt(s,o.length-1),r))},g=t=>{if(s===null)return null;let n=e.Rt(s,t);return n<0?null:o.at(n)??null},_=e=>{let n=J(e,t.bounds());h(n);let r=g(n);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;a.scrollTop+=i},v=()=>{a.scrollTop<a.clientHeight&&m(6),a.scrollHeight-a.scrollTop-a.clientHeight<a.clientHeight&&p(6)},y=t=>{let n=a.getBoundingClientRect().top,r=o.map(e=>({table:e,top:e.getBoundingClientRect().top-n,height:e.getBoundingClientRect().height})),i=Math.max(r.reduce((e,t,n)=>t.top<=1?n:e,0),0),s=r.at(i);if(s===void 0)return null;let c=s.height>0?Math.max(-s.top,0)/s.height:0,l=r.at(i+1)?.table??s.table;return t===1?c>e.D.COMMIT_FRACTION?l:s.table:c<1-e.D.COMMIT_FRACTION?s.table:l},b=()=>{l&&(window.clearTimeout(u),l=!1,v())},x=t=>{b(),v();let r=y(t);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;e.M(n.options.animation)===`full`?(l=!0,u=window.setTimeout(b,e.O.SNAP_SCROLL_FALLBACK),a.scrollTo({top:a.scrollTop+i,behavior:`smooth`})):a.scrollTop+=i},S=e=>{if(!(e instanceof Element))return null;let t=e.closest(Rr);return t!==null&&a.contains(t)?t:null},C=t=>{h(q(t));let n=a.querySelector(`${Rr}[data-date="${e.Bt(t)}"]`);n!==null&&(n.focus({preventScroll:!0}),e.L(a,n,`nearest`))},w=()=>{let e=Ir(n,r,!1);o.forEach(t=>{tr(t,e)})},T=t.bounds(),E=J(wr(n),T),D=J(e.kt(E,-2),T),O=J(e.kt(E,9),T),k=e.Rt(D,O)+1;k>0&&(s=D,o.push(...d(D,k)),a.append(...o),f()),a.addEventListener(`scroll`,()=>{c===0&&(c=requestAnimationFrame(()=>{c=0,l||v()}))},{passive:!0,signal:i.signal}),a.addEventListener(`scrollend`,b,{signal:i.signal}),Fr(a,i.signal,`y`,{onDragEnd:x});let A=null;if(typeof ResizeObserver<`u`){let e=0;A=new ResizeObserver(n=>{let r=n.at(-1);if(r===void 0||i.signal.aborted)return;let a=r.contentRect.height,o=e===0;e=a,o&&a>0&&t.onShown()}),A.observe(a)}return{element:a,scrollToMonth:_,refresh:w,cellAt:S,focusCell:C,ensureMonth:h,reveal:_,present:(e,t,n)=>{xr(n)?h(e):_(e)},destroy:()=>{i.abort(),A?.disconnect(),cancelAnimationFrame(c),c=0,window.clearTimeout(u),l=!1}}},Br=t=>{let n=e.F(`div`,`dp-ui__navigation dp-ui__navigation--months`),r=e._(t);return n.append(e.f(`prev-month`,t.previousMonth,e.v.keyboardArrowLeft,r.previousMonth),e.f(`next-month`,t.nextMonth,e.v.keyboardArrowRight,r.nextMonth)),n},Vr=t=>{let{core:n,actions:r,rules:i}=t,a=ar({core:n,layout:`docked`,rtl:t.rtl,gridContext:()=>Ir(n,i,!0),onCommit:(e,t)=>{r.page(e,t)}});return{element:a.element,cellAt:e=>a.cellAt(e)?.element??null,focusCell:t=>{let n=a.find(`td.dp-ui__date[data-date][data-date="${e.Bt(t)}"]`);n===null?a.focusCell(!0):n.focus({preventScroll:!0})},refresh:()=>{a.refresh()},reveal:()=>{a.refit()},present:(e,t,n)=>{a.present(e,n===`api`?0:t)},destroy:()=>{a.destroy()}}};function Hr(e){let n;try{n=e.value()}catch(e){return t(e),null}let r=u(n,`range`,`day`);if(r?.mode!==`range`)return null;let{start:i,end:a}=r;return i===null||a===null?null:{start:i,end:a}}const Ur=t=>{let{core:n,actions:r,rules:i,signal:a,column:o}=t,{presets:s,labels:c,limits:l}=n.options,u=e.F(`div`,o?`dp-ui__presets dp-ui__presets--column`:`dp-ui__presets`,{role:`group`,"aria-label":c.presets}),d=s.map(t=>{let n=e.F(`button`,`dp-ui__preset`,{type:`button`});return n.textContent=t.label,n}),f=d.map(()=>null);u.append(...d);let p=()=>{s.forEach((t,r)=>{let a=d[r],o=Hr(t);f[r]=o;let s=!1,c=!1;if(o!==null){let t={mode:`range`,...o};s=Ge(t,l,e=>i.isDisabled(e)),c=e.gt(n.draft,t)}a.disabled=!s,a.setAttribute(`aria-pressed`,c?`true`:`false`)})};return u.addEventListener(`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button.dp-ui__preset`),n=d.findIndex(e=>e===t);if(n<0)return;let i=f[n];i!==null&&r.selectRange(i.start,i.end)},{signal:a}),Fr(u,a),p(),{element:u,refresh:p,setHidden:e=>{u.hidden=e}}},Wr=`dp-ui__container--range`,Gr=`dp-ui__container--fullscreen`,Kr=`dp-ui__container--presets`,qr=[Wr,Kr,Gr,I],Jr=(e,t)=>{let{core:n,actions:r,rules:i,rtl:a}=e,{labels:o,locale:s,weekStart:c}=n.options;if(n.layout.months>1){let e=Vr({core:n,actions:r,rules:i,rtl:a});return t.append(Br(o),e.element),e}let l=zr({core:n,rules:i,render:e=>Lr(n,i,e),bounds:()=>Tr(n,i),onRendered:(e,t)=>{r.renderedMonths(e,t)},onShown:e.reveal});return t.append(Ar(s,c),l.element),l},Yr=t=>{let{root:n,core:r,actions:i,rules:a,mode:o,fullscreen:s,signal:c}=t,l=r.options,u=kr({labels:l.labels,animate:l.animation,text:B(r),fullscreen:s,headline:e.xt(o,l.inline).headline,switchView:l.viewSwitch?{panelId:e.g(r.instanceId,`input`)}:null}),d=e.F(`div`,`dp-ui__range`,{"data-panel":`days`}),f=Jr(t,d),p=vr({root:n,content:n,days:d,motion:t.motion,createParts:e=>e===`input`?In({core:r,actions:i,rules:a}):[],swap:t.swap,onSwitched:t.onSwitched}),m=Ft({labels:l.labels,visible:e.Tt(r.options.footerExplicit,o),todayButton:l.todayButton,clearButton:l.clearButton!==!1}),h=e.F(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`}),g=r.layout.presets===`column`,_=r.layout.presets===`none`?null:Ur({core:r,actions:i,rules:a,signal:c,column:g});return n.replaceChildren(...u.element===null?[]:[u.element],..._===null?[]:[_.element],d,m,h),{header:u,days:f,panels:p,liveRegion:h,applyChrome:e=>{let t=e===`input`;u.setInputView(t),u.setText(B(r)),_?.setHidden(t);let i=L(n);i!==null&&(i.classList.add(Wr),i.classList.toggle(Kr,g),i.classList.toggle(Gr,s&&!t),z(i,e,r.layout.months))},refreshPresets:()=>{_?.refresh()}}},Xr=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t)},Zr=e=>e===`input`?`input`:`days`,Qr=t=>{let{core:n,actions:r,rules:i,mode:a,fullscreen:o}=t,s=n.calendarLayout!==`docked`,c=new AbortController,l=e.F(`div`,`dp-ui__calendar`),u,d=0,f=null,p=()=>e.M(n.options.animation),m=()=>l.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(n.input).direction===`rtl`,h=t=>{let n=u.days.cellAt(t),r=e.Ft(n?.dataset.date??``);return n===null||r===null?null:{element:n,date:r}},g=()=>{let{draft:t,value:r}=n,i=e.pt(t)&&e.pt(r);Pt(l,e.dt(t)&&!i)},_=()=>{u.days.reveal(wr(n))},v=(e,t,r)=>{e===`days`&&_(),r&&(e===`input`?u.panels.entry()?.focus({preventScroll:!0}):u.days.focusCell(n.focus))},y=(e,t)=>{let n=()=>{u.applyChrome(t),e()};f?.cancel(),f=null;let r=L(l);r===null?n():f=An(r,n,p())},b=()=>{Xr(l,s),u=Yr({root:l,core:n,actions:r,rules:i,mode:a,fullscreen:o,rtl:m(),signal:c.signal,motion:p,reveal:_,swap:y,onSwitched:v}),u.days.present(n.view,0,`api`),u.panels.mount(Zr(n.panel)),u.applyChrome(u.panels.current()),g(),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=0,u.applyChrome(u.panels.current()),u.panels.current()===`days`&&_()})},x=()=>{f?.cancel(),f=null,u.panels.destroy(),u.days.destroy(),u.header.destroy()},S=()=>{if(c.signal.aborted)return;let e=u.panels.current();u.applyChrome(e),e===`days`&&_()},C=()=>{c.signal.aborted||(cancelAnimationFrame(d),d=0,S(),u.panels.current()===`input`?u.panels.entry()?.focus({preventScroll:!0}):u.days.focusCell(n.focus))},w=()=>{u.days.refresh(),u.refreshPresets(),u.header.setText(B(n)),g();let{announceSelection:t}=e.xt(a,n.options.inline);t&&u.panels.current()===`days`&&e.j(u.liveRegion,B(n))},T=()=>{let e=h(l.ownerDocument.activeElement)!==null;u.days.refresh(),e&&u.days.focusCell(n.focus)},E=(t,r,i)=>{let a=u.panels.current()===`days`&&u.panels.settled();u.days.present(t,a?r:0,i),xr(i)&&n.layout.months>1&&e.j(u.liveRegion,rn(n,t))};return b(),(e=>{let{events:t}=n;t.on(`change:view`,e=>{E(e.view,e.delta,e.source)},e),t.on(`change:draft`,w,e),t.on(`change:active-end`,()=>{u.days.refresh()},e),t.on(`change:value`,g,e),t.on(`change:focus`,T,e),t.on(`change:panel`,e=>{u.panels.switchTo(Zr(e.panel))},e),Bt(l,e,{actions:r,panel:()=>n.panel,home:`days`,cellAt:h}),yn(l,e,{core:n,actions:r,layout:`range`,home:`days`,caption:()=>!1,cellAt:h,isRtl:m}),Nt(l,`.dp-ui__icon-button, .dp-ui__text-button, .dp-ui__preset, .dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator`,e)})(c.signal),{element:l,focusInitial:C,fit:S,update:()=>{if(c.signal.aborted)return;let e=l.contains(l.ownerDocument.activeElement);x(),b(),e&&C()},destroy:()=>{if(c.signal.aborted)return;c.abort(),cancelAnimationFrame(d),x();let e=L(l);e!==null&&(e.classList.remove(...qr),R(e,1)),l.remove()}}};var $r=class{core;deps;mounted=null;generation=0;constructor(e,t,n){this.core=e,this.deps=n}get surface(){return this.mounted?.host.root??null}async mount(t){this.release();let n=this.createHost(t);if(n===null)return;let{core:r}=this,{options:i}=r,{actions:a,rules:o,theme:s}=this.deps,c=++this.generation;s.applyTo(n.root),St(n.root,i.animation);let l={core:r,actions:a,rules:o,mode:t,fullscreen:r.calendarLayout===`fullscreen`},u=i.mode===`range`?Qr(l):Cr(l);this.mounted={mode:t,host:n,view:u,stopModality:e.P(n.root),stopSchemeWatch:t===`inline`?e.A(()=>{s.applyTo(n.root)}):()=>void 0},n.body.append(u.element);let d=n.open();u.fit(),this.overflows(t,n)?(this.release(),this.deps.overflow()):(await d,c===this.generation&&t!==`inline`&&u.focusInitial())}async unmount(){let e=this.mounted;if(e===null)return;let t=++this.generation;await e.host.close(),t===this.generation&&this.mounted===e&&this.release()}update(){let e=this.mounted;e!==null&&(this.deps.theme.applyTo(e.host.root),e.host.setLabel(this.label()),St(e.host.root,this.core.options.animation),e.view.update())}label(){let{labels:e,mode:t,precision:n}=this.core.options;return Ct(e,t,n)}destroy(){this.generation+=1,this.release()}overflows(t,n){return t===`docked`&&this.core.options.displayMode===`auto`&&!e.y(n.root,this.core.input)}release(){let e=this.mounted;e!==null&&(this.mounted=null,e.view.destroy(),e.host.destroy(),e.stopModality(),e.stopSchemeWatch())}createHost(t){let{core:n}=this,{options:r}=n,{actions:i}=this.deps,a=this.label();if(t===`inline`){let t=e.I(r.inline.container);return t===null?null:new e.r({container:t,label:a})}return t===`modal`?new e.i({parent:e.I(r.appendTo)??n.host,label:a,allowPageScroll:r.allowPageScroll,onCancel:e=>{i.cancel(e)}}):new e.n({host:n.host,anchor:n.input,instanceId:n.instanceId,rtl:getComputedStyle(n.input).direction===`rtl`,label:a,ignoreOutsideClick:r.behavior.ignoreOutsideClick,inside:[...n.endInput===null?[]:[n.endInput],...this.deps.inside()],onOutside:()=>{i.cancel(`outside`)},onEscape:()=>{i.cancel(`escape`)}})}},ei=class{core;fields=[];initial;constructor(e){this.core=e,this.initial=e.value}bind(e){let{input:t}=this.core;this.initial=this.core.value;let n=this.splitEnd();this.bindField(t,n===null?null:`start`),n!==null&&this.bindField(n,`end`),this.fields.length!==0&&t.form?.addEventListener(`reset`,()=>{setTimeout(()=>{this.handleReset()},0)},{signal:e})}sync(){for(let e of this.fields)e.hidden.value=this.valueOf(e.end)}dispatchCommit(){let{input:e}=this.core;e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}restore(){for(let e of this.fields)e.hidden.remove(),e.input.setAttribute(`name`,e.name);this.fields=[]}splitEnd(){return this.core.options.mode===`range`?this.core.endInput:null}bindField(e,t){let n=e.getAttribute(`name`);n!==null&&n!==``&&(e.removeAttribute(`name`),this.fields.push({input:e,name:n,hidden:this.createHidden(e,n),end:t}))}valueOf(t){let{value:n,options:r}=this.core;if(t===null||n.mode!==`range`)return e.w(n,r.precision);let i=t===`start`?n.start:n.end;return i===null?``:e.H(i,`day`)}createHidden(e,t){let n=e.ownerDocument.createElement(`input`);return n.type=`hidden`,n.name=t,n.classList.add(`dp-ui__form-value`),e.insertAdjacentElement(`afterend`,n),n}writeFields(t){let{core:n}=this,{pattern:r,precision:i}=n.options,a=this.splitEnd();if(a===null||t.mode!==`range`){n.input.value=e.x(t,r,i);return}let o=t=>t===null?``:e.R(t,r,`day`);n.input.value=o(t.start),a.value=o(t.end)}handleReset(){let{core:t}=this,{mode:n}=t.options,r=this.initial.mode===n?this.initial:e.ut(n);t.setValue(r),this.writeFields(r),this.sync()}};const Y=`aria-describedby`,ti=e=>(e.getAttribute(Y)??``).split(/\s+/).filter(e=>e!==``);function ni(t,n,r,i){let a=e.F(`span`,`dp-ui__visually-hidden`,{id:r}),o=e.F(`span`,void 0,{"aria-live":`polite`}),s=e.F(`span`);return s.textContent=i,a.append(o,` `,s),n.append(a),t.setAttribute(Y,[...ti(t),r].join(` `)),{setHint:e=>{s.textContent!==e&&(s.textContent=e)},setError:e=>{let t=e??``;o.textContent!==t&&(o.textContent=t)},destroy:()=>{a.remove();let e=ti(t).filter(e=>e!==r);e.length===0?t.removeAttribute(Y):t.setAttribute(Y,e.join(` `))}}}const ri=`dp-ui--error`;function X(e,t,n){e.setAttribute(`aria-invalid`,`true`),t.classList.add(ri),e.setCustomValidity(n)}function ii(e,t){e.removeAttribute(`aria-invalid`),t.classList.remove(ri),e.setCustomValidity(``)}function ai(t,n,r){let i=t.trim(),a=n.trim();if(i===``&&a===``)return{kind:`empty`};let o=i===``?null:e.W(i,r);if(i!==``&&o===null)return{kind:`invalid`,field:`start`};let s=a===``?null:e.W(a,r);return a!==``&&s===null?{kind:`invalid`,field:`end`}:o===null||s===null?{kind:`partial`}:e.At(o,s)>0?{kind:`reversed`}:{kind:`range`,start:o,end:s}}var oi=class{core;emitter;deps;dirty=!1;constructor(e,t,n){this.core=e,this.emitter=t,this.deps=n}get end(){return this.core.options.mode===`range`?this.core.endInput:null}bind(e){let{end:t}=this;if(t!==null)for(let n of[this.core.input,t])n.addEventListener(`blur`,()=>{this.commit()},{signal:e}),n.addEventListener(`input`,()=>{this.dirty=!0,this.applyMask(n)},{signal:e}),n.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.commit())},{signal:e})}write(e){let{end:t}=this;if(t===null)return;let n=e.mode===`range`?e:null;this.core.input.value=this.format(n?.start??null),t.value=this.format(n?.end??null),this.dirty=!1,this.clearError()}readInitial(){let{end:t}=this,n=e.ut(`range`);if(t===null)return n;let r=this.readDate(this.core.input.value),i=this.readDate(t.value);return r===null||i===null||e.At(r,i)>0?n:{mode:`range`,start:r,end:i}}markInvalid(e){let{end:t}=this;if(t===null)return;let{input:n,host:r}=this.core;X(n,r,e),X(t,r,e),this.deps.describe(n,e),this.deps.describe(t,e),this.emitter.emit(`error`,{code:`invalid-value`,message:e})}clearError(){let{end:e}=this;if(e===null)return;let{input:t,host:n}=this.core;ii(t,n),ii(e,n),this.deps.describe(t,null),this.deps.describe(e,null)}format(t){return t===null?``:e.R(t,this.core.options.pattern,`day`)}readDate(t){let{pattern:n}=this.core.options,r=e.C(t,`single`,`day`)??e.S(t,`single`,n,`day`);return r?.mode===`single`?r.date:null}applyMask(t){let{options:n}=this.core;n.mask&&e.d(t,n.pattern)}commit(){let{end:t}=this;if(t===null||!this.dirty)return;let{options:n,input:r}=this.core,i=ai(r.value,t.value,n.pattern);i.kind!==`partial`&&(i.kind===`empty`?this.settle(e.ut(`range`)):i.kind===`invalid`?this.fail(i.field,`invalid-date`,n.labels.invalidDate):i.kind===`reversed`?this.fail(`end`,`invalid-date`,n.labels.invalidRange):this.commitRange(i.start,i.end))}commitRange(e,t){let{options:n}=this.core,r={mode:`range`,start:e,end:t},i=e=>this.deps.rules.unavailableReason(e),a=P(r,n.limits,i);if(a===null){this.settle(r);return}let o=i(e)===null?`end`:`start`;this.fail(o,`unavailable-date`,Fn(a,n),a)}settle(e){this.write(e),this.deps.onTyped(e)}fail(e,t,n,r){let i=e===`start`?this.core.input:this.end;if(i===null)return;this.clearError(),X(i,this.core.host,n),this.deps.describe(i,n);let a=i.value;r===void 0?this.emitter.emit(`error`,{code:t,message:n,input:a}):this.emitter.emit(`error`,{code:t,message:n,input:a,reason:r})}},si=class{core;emitter;deps;split;descriptions=/* @__PURE__ */ new Map;constructor(e,t,n){this.core=e,this.emitter=t,this.deps=n,this.split=new oi(e,t,{rules:n.rules,onTyped:e=>{n.onTyped(e)},describe:(e,t)=>{this.describe(e,t)}})}bind(e){if(this.describeFields(e),this.split.end!==null){this.split.bind(e);return}let{input:t}=this.core;t.addEventListener(`blur`,()=>{this.commit()},{signal:e}),t.addEventListener(`input`,()=>{this.applyMask()},{signal:e}),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.commit())},{signal:e})}write(t){this.split.end===null?(this.core.input.value=e.x(t,this.core.options.pattern,this.core.options.precision),this.clearError()):this.split.write(t)}readInitial(){if(this.split.end!==null)return this.split.readInitial();let{mode:t,pattern:n,precision:r}=this.core.options,i=this.core.input.value;return e.C(i,t,r)??e.S(i,t,n,r)??e.ut(t)}evaluate(t){let{mode:n,pattern:r,limits:i,precision:a}=this.core.options,o=e.S(t,n,r,a);if(o===null)return{kind:`invalid`};if(e.pt(o))return{kind:`empty`};let s=P(o,i,e=>this.deps.rules.unavailableReason(e));return s===null?{kind:`valid`,selection:o}:{kind:`unavailable`,selection:o,reason:s}}markInvalid(e){this.split.end===null?(this.showError(e),this.emitter.emit(`error`,{code:`invalid-value`,message:e})):this.split.markInvalid(e)}destroy(){this.clearError(),this.split.clearError(),this.descriptions.forEach(e=>{e.destroy()}),this.descriptions.clear()}describeFields(t){let{input:n,host:r,instanceId:i}=this.core,{end:a}=this.split,o=()=>{let{pattern:t,precision:n,labels:r}=this.core.options;return e.V(t,n,e.ot(r))},s=[[n,`input-description`]];a!==null&&s.push([a,`end-input-description`]);for(let[t,n]of s){let a=e.g(i,n);this.descriptions.set(t,ni(t,r,a,o()))}this.core.events.on(`change:options`,()=>{let e=o();this.descriptions.forEach(t=>{t.setHint(e)})},t)}describe(e,t){this.descriptions.get(e)?.setError(t)}applyMask(){let{input:t,options:n}=this.core;n.mask&&n.mode===`single`&&n.precision===`day`&&e.d(t,n.pattern)}commit(){let t=this.core.input.value,n=this.evaluate(t);if(n.kind===`empty`)this.clearError(),this.deps.onTyped(e.ut(this.core.options.mode));else if(n.kind===`valid`)this.write(n.selection),this.deps.onTyped(n.selection);else if(n.kind===`invalid`){let e=this.core.options.labels.invalidDate;this.showError(e),this.emitter.emit(`error`,{code:`invalid-date`,message:e,input:t})}else{let{reason:e}=n,r=Fn(e,this.core.options);this.showError(r),this.emitter.emit(`error`,{code:`unavailable-date`,message:r,input:t,reason:e})}}showError(e){X(this.core.input,this.core.host,e),this.describe(this.core.input,e)}clearError(){ii(this.core.input,this.core.host),this.describe(this.core.input,null)}},ci=class{core;constructor(e){this.core=e}applyHost(){this.core.host.setAttribute(`data-theme`,this.core.options.theme)}applyTo(t){let{options:n,input:r,host:i}=this.core;e.t(t,{theme:n.theme,colorScheme:n.colorScheme===`auto`?e.k(i):n.colorScheme,className:n.cssClass,rtl:getComputedStyle(r).direction===`rtl`})}destroy(){this.core.host.removeAttribute(`data-theme`)}};const li=(t,n,r,i)=>{let a=e._t(t);return a.length===0?``:t.mode===`multiple`?Ot(r,a.length,n):a.map(t=>e.Y(t,i,n,`long`)).join(e.b)},Z=`dp-ui__input--active`;var ui=class{core;deps;toggle=null;expanded=!1;release=null;constructor(e,t,n){this.core=e,this.deps=n}get toggleElement(){return this.toggle}bind(e){if(this.releaseToggle(),this.core.options.inline.enabled||e.aborted)return;let{input:t}=this.core;this.bindField(t,`start`,e);let n=this.splitEnd();n!==null&&(this.bindField(n,`end`,e),this.core.events.on(`change:active-end`,()=>{this.markActive()},e)),this.bindToggle(e)}setExpanded(e){this.expanded=e,this.toggle?.setAttribute(`aria-expanded`,String(e)),this.markActive()}updateLabel(){if(this.toggle===null)return;let{labels:e,locale:t,precision:n}=this.core.options,r=li(this.core.value,t,e.multipleSelected,n),i=r===``?e.openCalendar:`${e.openCalendar}, ${r}`;this.toggle.setAttribute(`aria-label`,i)}destroy(){this.releaseToggle(),this.core.input.classList.remove(Z),this.core.endInput?.classList.remove(Z)}splitEnd(){return this.core.options.mode===`range`?this.core.endInput:null}bindField(e,t,n){let r=!1;e.addEventListener(`pointerdown`,()=>{r=!0},{signal:n}),e.addEventListener(`click`,()=>{let n=r;r=!1,(!this.expanded||n)&&this.request(`pointer`,t,e)},{signal:n}),e.addEventListener(`keydown`,n=>{n.altKey&&n.key===`ArrowDown`&&(n.preventDefault(),this.request(`keyboard`,t,e))},{signal:n})}markActive(){let e=this.splitEnd(),{input:t}=this.core;if(e===null){t.classList.remove(Z);return}let n=this.expanded?this.core.activeEnd:null;t.classList.toggle(Z,n===`start`),e.classList.toggle(Z,n===`end`)}request(e,t,n=this.core.input){n.disabled||this.deps.open(e,t)}activateToggle(){this.expanded?this.deps.dismiss():this.request(`toggle`,`start`)}bindToggle(t){let n=e.I(this.core.options.toggleButton,this.core.host);if(n===null)return;let r=/* @__PURE__ */ new Map,i=(e,t)=>{r.has(e)||r.set(e,n.getAttribute(e)),n.setAttribute(e,t)};i(`aria-haspopup`,`dialog`),n.tagName!==`BUTTON`&&(i(`role`,`button`),i(`tabindex`,`0`),n.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.activateToggle())},{signal:t})),n.addEventListener(`click`,()=>{this.activateToggle()},{signal:t}),this.toggle=n,i(`aria-expanded`,String(this.expanded)),i(`aria-label`,this.core.options.labels.openCalendar),this.updateLabel();let a=()=>{t.removeEventListener(`abort`,a),r.forEach((e,t)=>{e===null?n.removeAttribute(t):n.setAttribute(t,e)}),this.toggle===n&&(this.toggle=null),this.release===a&&(this.release=null)};this.release=a,t.addEventListener(`abort`,a,{once:!0})}releaseToggle(){this.release?.()}};function Q(e){return e.year*12+e.month-1}var di=class{core;emitter;lists=null;constructor(e,t){this.core=e,this.emitter=t}isDisabled(e){return this.unavailableReason(e)!==null}unavailableReason(e){switch(this.core.options.precision){case`day`:return this.dayReason(e);case`month`:return this.monthReason(e);case`year`:return this.yearReason(e.year)}}isSelectable(e,t){return!this.isDisabled(e)&&!this.guardFor(t)(e)}isMonthDisabled(t){let n=e.Pt(t),r=e.jt(t.year,t.month,1),i=e.jt(t.year,t.month,n);if(r===null||i===null)return!0;let{minDate:a,maxDate:o}=this.core.options,s=this.yearBounds();if(t.year<s.min||t.year>s.max||a!==null&&e.At(i,a)<0||o!==null&&e.At(r,o)>0)return!0;for(let e=1;e<=n;e+=1)if(this.dayReason({year:t.year,month:t.month,day:e})===null)return!1;return!0}yearBounds(){let{minDate:t,maxDate:n,yearRange:r}=this.core.options,i=e.Ht(),a=i.year-r.before,o=i.year+r.after;return{min:t===null?a:Math.max(a,t.year),max:n===null?o:Math.min(o,n.year)}}clampView(e){let{minDate:t,maxDate:n}=this.core.options,r=this.yearBounds(),i=r.min*12,a=r.max*12+11;t!==null&&(i=Math.max(i,Q(t))),n!==null&&(a=Math.min(a,Q(n)));let o=this.core.layout.months-1;o>0&&(a=Math.max(i,a-o));let s=Math.min(Math.max(Q(e),i),a),c=Math.floor(s/12);return{year:c,month:s-c*12+1}}destroy(){this.lists=null}monthReason(e){if(!this.isMonthDisabled(e))return null;let{minDate:t,maxDate:n}=this.core.options,r=this.yearBounds(),i=Q(e),a=r.min*12,o=r.max*12+11;return t!==null&&(a=Math.max(a,Q(t))),n!==null&&(o=Math.min(o,Q(n))),i<a?`min`:i>o?`max`:`disabled`}yearReason(e){let t=this.yearBounds();return e<t.min?`min`:e>t.max?`max`:null}dayReason(t){let{minDate:n,maxDate:r}=this.core.options,i=this.yearBounds();if(n!==null&&e.At(t,n)<0||t.year<i.min)return`min`;if(r!==null&&e.At(t,r)>0||t.year>i.max)return`max`;let a=this.getLists(),o=e.Bt(t);return a.disabled.has(o)||a.enabled!==null&&!a.enabled.has(o)?`disabled`:a.source.disabledWeekdays.includes(e.Mt(t))?`weekday`:this.isCallbackDisabled(t,a)?`disabled`:null}isCallbackDisabled(n,r){let{isDateDisabled:i}=r.source;if(i===null)return!1;let a=e.Bt(n),o=r.callbackResults.get(a);if(o!==void 0)return o;let s=!1;try{s=i(e.zt(n))}catch(e){t(e)}return r.callbackResults.set(a,s),s}guardFor(t){let n=this.getLists(),r=n.guardDraft;if(n.guard!==null&&r!==null&&e.gt(r,t))return n.guard;let{maxDate:i,limits:a}=n.source,o={year:this.yearBounds().max,month:12,day:31};i!==null&&e.At(i,o)<0&&(o=i);let s=He(t,a,e=>this.isDisabled(e),o);return n.guardDraft=t,n.guard=s,s}getLists(){let t=this.core.options;if(this.lists?.source===t)return this.lists;let n={source:t,disabled:new Set(t.disabledDates.map(e.Bt)),enabled:t.enabledDates===null?null:new Set(t.enabledDates.map(e.Bt)),callbackResults:/* @__PURE__ */ new Map,guardDraft:null,guard:null};return this.lists=n,n}},fi=class{target=null;select=e=>{this.target?.select(e)};selectRange=(e,t)=>{this.target?.selectRange(e,t)};typeDraft=e=>{this.target?.typeDraft(e)};submitDraft=()=>{this.target?.submitDraft()};focusDate=e=>{this.target?.focusDate(e)};navigate=(e,t)=>{this.target?.navigate(e,t)};page=(e,t)=>{this.target?.page(e,t)};jumpTo=(e,t)=>{this.target?.jumpTo(e,t)};showPanel=e=>{this.target?.showPanel(e)};confirm=()=>{this.target?.confirm()};cancel=e=>{this.target?.cancel(e)};today=()=>{this.target?.today()};clear=()=>{this.target?.clear()};renderedMonths=(e,t)=>{this.target?.renderedMonths(e,t)};open=(e,t)=>{this.target?.open(e,t)};typed=e=>{this.target?.applyTyped(e)};overflow=()=>{this.target?.fallBackToModal()};connect(e){this.target=e}},pi=class{validation;theme;display;input;triggers;form;relay=new fi;constructor(e,t){this.validation=new di(e,t),this.theme=new ci(e),this.display=new $r(e,t,{actions:this.relay,rules:this.validation,theme:this.theme,inside:()=>{let e=this.triggers.toggleElement;return e===null?[]:[e]},overflow:this.relay.overflow}),this.input=new si(e,t,{rules:this.validation,onTyped:this.relay.typed}),this.triggers=new ui(e,t,{open:this.relay.open,dismiss:()=>{this.relay.cancel(`toggle`)}}),this.form=new ei(e)}connect(e){this.relay.connect(e)}destroy(){this.relay.connect(null),this.display.destroy(),this.triggers.destroy(),this.input.destroy(),this.form.restore(),this.theme.destroy(),this.validation.destroy()}};const $=/* @__PURE__ */ new Map,mi=()=>void 0;var hi=class{core;emitter;lifecycle;constructor(e,t){let r=Pe(e);this.emitter=new n,this.core=new ke(r.input,r.host,r.createdHost,t),this.lifecycle=new bt(this.core,this.emitter,new pi(this.core,this.emitter)),$.set(this.core.instanceId,this)}create(){this.lifecycle.create()}open(){this.lifecycle.open(`api`)}close(){this.lifecycle.close()}destroy(e){this.lifecycle.destroy(e?.keepInputValue??!1),$.get(this.core.instanceId)===this&&$.delete(this.core.instanceId)}getValue(){return this.lifecycle.getValue()}setValue(e){this.lifecycle.setValue(e)}setActiveEnd(e){this.lifecycle.setActiveEnd(e)}setView(e){this.lifecycle.setView(e)}getView(){return this.lifecycle.getView()}getVisibleRange(){return this.lifecycle.getVisibleRange()}goTo(e){this.lifecycle.goTo(e)}isSelectable(e){return this.lifecycle.isSelectable(e)}clear(){this.lifecycle.clearValue()}setOptions(e){this.lifecycle.setOptions(e)}getElement(){return this.core.host}on(e,t){return this.lifecycle.destroyed?mi:this.emitter.on(e,t)}once(e,t){return this.lifecycle.destroyed?mi:this.emitter.once(e,t)}off(e,t){this.emitter.off(e,t)}get instanceId(){return this.core.instanceId}get options(){return this.core.rawOptions}get isInitialized(){return this.lifecycle.created}get isDestroyed(){return this.lifecycle.destroyed}static getById(e){return $.get(De(e))}static getAllInstances(){return[...$.values()]}static destroyAll(){for(let e of[...$.values()])e.destroy()}},gi=hi;exports.DEFAULT_DATEPICKER_OPTIONS=a,exports.DatepickerUI=hi,exports.EventEmitter=n,exports.default=gi;
@@ -1,5 +1,4 @@
1
- import { B as PageBy, C as RangeStartEventData, D as SelectYearEventData, E as SelectMonthEventData, H as RangeEnd, O as UnavailableReason, R as WeekStartOption, S as RangeEndEventData, T as SelectDayEventData, U as PlainDate, V as Precision, _ as ErrorEventData, a as DatepickerOptions, b as PickerValue, c as RangePreset, d as UIOptions, f as CancelEventData, g as DatepickerEventMap, h as DateValue, i as DateDecoration, k as UpdateEventData, l as RangePresetValue, m as ConfirmEventData, n as CalendarOptions, o as LabelsOptions, p as CloseEventData, r as CallbacksOptions, s as PluralLabel, t as BehaviorOptions, u as ThemeName, v as NavigateEventData, w as RangeValue, x as PickerValueInput, y as OpenEventData, z as CalendarMode } from "./shared.cjs";
2
- //#region src/utils/EventEmitter.d.ts
1
+ import { $ as Precision, A as RangeValue, C as NavigateSource, D as PickerView, E as PickerValueInput, F as UnavailableReason, I as UpdateEventData, K as WeekStartOption, L as VisibleRange, M as SelectMonthEventData, N as SelectYearEventData, O as RangeEndEventData, P as SwitchViewEventData, Q as PageBy, S as NavigateEventData, T as PickerValue, Z as CalendarMode, _ as CloseEventData, a as CallbacksOptions, b as DatepickerEventMap, c as LabelsOptions, d as RangePresetValue, et as RangeEnd, f as ThemeName, g as ClearEventData, h as CancelReason, i as CalendarOptions, j as SelectDayEventData, k as RangeStartEventData, l as PluralLabel, m as CancelEventData, o as DateDecoration, p as UIOptions, r as BehaviorOptions, s as DatepickerOptions, t as ResolvedPreset, tt as PlainDate, u as RangePreset, v as ConfirmEventData, w as OpenEventData, x as ErrorEventData, y as DateValue } from "./shared.cjs";
3
2
  type Handler<Data> = (data: Data) => void;
4
3
  export declare class EventEmitter<Events extends object> {
5
4
  private store;
@@ -11,8 +10,6 @@ export declare class EventEmitter<Events extends object> {
11
10
  clear(): void;
12
11
  private listenersOf;
13
12
  }
14
- //#endregion
15
- //#region src/datepicker/DatepickerUI.d.ts
16
13
  export default class DatepickerUI {
17
14
  private readonly core;
18
15
  private readonly emitter;
@@ -27,6 +24,12 @@ export default class DatepickerUI {
27
24
  getValue(): PickerValue | null;
28
25
  setValue(value: PickerValueInput | null): void;
29
26
  setActiveEnd(end: RangeEnd): void;
27
+ setView(view: PickerView): void;
28
+ getView(): PickerView;
29
+ getVisibleRange(): VisibleRange | null;
30
+ goTo(date: Date | string): void;
31
+ isSelectable(value: PickerValueInput): boolean;
32
+ clear(): void;
30
33
  setOptions(options: DatepickerOptions): void;
31
34
  getElement(): HTMLElement;
32
35
  on<K extends keyof DatepickerEventMap>(event: K, handler: Handler<DatepickerEventMap[K]>): () => void;
@@ -40,14 +43,6 @@ export default class DatepickerUI {
40
43
  static getAllInstances(): DatepickerUI[];
41
44
  static destroyAll(): void;
42
45
  }
43
- //#endregion
44
- //#region src/datepicker/options/types.d.ts
45
- interface ResolvedPreset {
46
- readonly label: string;
47
- readonly value: () => unknown;
48
- }
49
- //#endregion
50
- //#region src/datepicker/options/defaults.d.ts
51
46
  interface DefaultOptions {
52
47
  readonly calendar: {
53
48
  readonly weekStart: WeekStartOption;
@@ -57,10 +52,8 @@ interface DefaultOptions {
57
52
  readonly pageBy: PageBy;
58
53
  readonly presets: readonly ResolvedPreset[];
59
54
  };
60
- readonly ui: Required<Pick<UIOptions, "displayMode" | "format" | "theme" | "colorScheme" | "weekNumbers" | "outsideDays" | "fixedWeeks" | "todayButton" | "clearButton" | "animation" | "allowPageScroll" | "fullscreen" | "cssClass" | "swipe" | "viewSwitch" | "initialView" | "mask" | "startView">> & {
61
- readonly inline: {
62
- readonly enabled: boolean;
63
- };
55
+ readonly ui: Required<Pick<UIOptions, "displayMode" | "layout" | "format" | "theme" | "colorScheme" | "weekNumbers" | "outsideDays" | "fixedWeeks" | "todayButton" | "clearButton" | "animation" | "allowPageScroll" | "fullscreen" | "cssClass" | "swipe" | "viewSwitch" | "initialView" | "mask" | "startView">> & {
56
+ readonly inline: Required<Omit<NonNullable<UIOptions["inline"]>, "container">>;
64
57
  readonly yearRange: {
65
58
  readonly before: number;
66
59
  readonly after: number;
@@ -70,5 +63,4 @@ interface DefaultOptions {
70
63
  readonly behavior: Required<Omit<BehaviorOptions, "id">>;
71
64
  }
72
65
  export declare const DEFAULT_DATEPICKER_OPTIONS: DefaultOptions;
73
- //#endregion
74
- export { type BehaviorOptions, type CalendarMode, type CalendarOptions, type CallbacksOptions, type CancelEventData, type CloseEventData, type ConfirmEventData, type DateDecoration, type DateValue, type DatepickerEventMap, type DatepickerOptions, DatepickerUI, type ErrorEventData, type LabelsOptions, type NavigateEventData, type OpenEventData, type PageBy, type PickerValue, type PickerValueInput, type PlainDate, type PluralLabel, type Precision, type RangeEnd, type RangeEndEventData, type RangePreset, type RangePresetValue, type RangeStartEventData, type RangeValue, type SelectDayEventData, type SelectMonthEventData, type SelectYearEventData, type ThemeName, type UIOptions, type UnavailableReason, type UpdateEventData };
66
+ export { type BehaviorOptions, type CalendarMode, type CalendarOptions, type CallbacksOptions, type CancelEventData, type CancelReason, type ClearEventData, type CloseEventData, type ConfirmEventData, type DateDecoration, type DateValue, type DatepickerEventMap, type DatepickerOptions, DatepickerUI, type ErrorEventData, type LabelsOptions, type NavigateEventData, type NavigateSource, type OpenEventData, type PageBy, type PickerValue, type PickerValueInput, type PickerView, type PlainDate, type PluralLabel, type Precision, type RangeEnd, type RangeEndEventData, type RangePreset, type RangePresetValue, type RangeStartEventData, type RangeValue, type SelectDayEventData, type SelectMonthEventData, type SelectYearEventData, type SwitchViewEventData, type ThemeName, type UIOptions, type UnavailableReason, type UpdateEventData, type VisibleRange };
package/dist/cjs/kit.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./shared.cjs");exports.DialogHost=e.i,exports.InlineHost=e.r,exports.PopoverHost=e.n,exports.detectColorScheme=e.l,exports.formatDate=e.b,exports.formatHint=e.x,exports.isFullscreenRange=e.E,exports.maskDateText=e.t,exports.parseDate=e._,exports.resolvePattern=e.w,exports.resolveSurfaceMode=e.D,exports.waitForExit=e.a,exports.watchColorScheme=e.u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./shared.cjs");exports.DialogHost=e.i,exports.InlineHost=e.r,exports.Pager=e.o,exports.PopoverHost=e.n,exports.RANGE_SEPARATOR=e.b,exports.applyTheme=e.t,exports.createTextButton=e.h,exports.detectColorScheme=e.k,exports.fitsViewport=e.y,exports.formatDate=e.it,exports.formatFullDate=e.G,exports.formatHint=e.at,exports.formatMonthYear=e.q,exports.isDateTextComplete=e.c,exports.isFullscreenRange=e.St,exports.leadingDateLength=e.l,exports.maskDateText=e.u,exports.normalizeDigits=e.U,exports.parseDate=e.W,exports.resolvePattern=e.ct,exports.resolveSurfaceMode=e.Ct,exports.resolveWeekStart=e.tt,exports.splitRangeText=e.T,exports.waitForExit=e.a,exports.watchColorScheme=e.A,exports.weekdayNames=e.nt;