@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.
- package/README.md +47 -13
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.cts +10 -18
- package/dist/cjs/kit.cjs +1 -1
- package/dist/cjs/kit.d.cts +111 -19
- package/dist/cjs/shared.cjs +1 -1
- package/dist/cjs/shared.d.cts +145 -41
- package/dist/css/index.css +1 -1
- package/dist/css/main.css +1 -1
- package/dist/css/themes/theme-ai.css +1 -1
- package/dist/css/themes/theme-crane-straight.css +1 -1
- package/dist/css/themes/theme-crane.css +1 -1
- package/dist/css/themes/theme-cyberpunk.css +1 -1
- package/dist/css/themes/theme-glassmorphic.css +1 -1
- package/dist/css/themes/theme-m2.css +1 -1
- package/dist/css/themes/theme-m3-green.css +1 -1
- package/dist/css/themes/theme-pastel.css +1 -1
- package/dist/esm/index.d.ts +10 -14
- package/dist/esm/index.js +1 -1
- package/dist/esm/kit.d.ts +112 -19
- package/dist/esm/kit.js +1 -1
- package/dist/esm/shared.d.ts +140 -41
- package/dist/esm/shared.js +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/kit.js +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,K as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,_ as x,b as S,c as C,d as w,f as T,g as ee,h as te,i as ne,j as E,k as re,l as ie,m as D,n as ae,o as oe,p as O,r as se,s as k,t as ce,u as le,v as ue,w as de,x as fe,y as pe,z as A}from"./shared.js";function j(e){queueMicrotask(()=>{throw e})}var me=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,t){let n=this.store[e];if(!n)return;let r=[];for(let e of[...n])if(n.has(e))try{e.handler(t)}catch(e){r.push(e)}r.length>0&&j(r[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 he(e){let t=[...e].sort(f);return t.filter((e,n)=>n===0||f(t[n-1],e)!==0)}function M(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 N(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 P(e){return N(e).length===0}function ge(e){return e.mode!==`range`||e.start===null==(e.end===null)}function _e(e,t){return e===null||t===null?e===t:f(e,t)===0}function ve(e,t){if(e.mode!==t.mode)return!1;let n=N(e),r=N(t);return n.length===r.length?e.mode===`range`&&t.mode===`range`?_e(e.start,t.start)&&_e(e.end,t.end):n.every((e,t)=>f(e,r[t])===0):!1}function ye(e,t){return N(e).some(e=>A(e,t))}function be(e,t){return e.mode!==`range`||e.start===null||e.end===null||f(e.start,e.end)>=0?null:A(e.start,t)?`start`:A(e.end,t)?`end`:f(t,e.start)>0&&f(t,e.end)<0?`in-range`:null}function F(e){return N(e).at(0)??null}function xe(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 Se=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(` `)),Ce=new Set(`AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY`.split(` `)),we=/* @__PURE__ */ new Set([`MV`]),Te=/* @__PURE__ */ new Map,Ee=/* @__PURE__ */ new Map;function I(e,t){let n=Ee.get(t);if(n)return n.format(e);let r=new Intl.NumberFormat(t,{useGrouping:!1});return Ee.set(t,r),r.format(e)}function L(e,t){let n=`${e}|${JSON.stringify(t)}`,r=Te.get(n);if(r)return r;let i=new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`});return Te.set(n,i),i}function R(e,t,n){let r=new Date(Date.UTC(2e3,0,1,12));return r.setUTCFullYear(e,t-1,n),r}function De(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 Oe(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`?De(r===7?0:r):null}function ke(e){return e===void 0?1:Se.has(e)?0:Ce.has(e)?6:we.has(e)?5:1}function Ae(e){try{let t=new Intl.Locale(e),n=Oe(t);return n===null?ke(t.maximize().region):n}catch{return 1}}function je(e){try{return Intl.getCanonicalLocales(e).length>0}catch{return!1}}const Me=e=>{let t=e?.trim();return!t||!je(t)?null:t};function Ne(e){let t=Me(e);if(t!==null)return t;if(ue()){let e=Me(document.documentElement.lang);if(e!==null)return e}if(typeof navigator<`u`){let e=Me(navigator.language);if(e!==null)return e}return`en-US`}function z(e,t){let n=L(e,{month:t});return Array.from({length:12},(e,t)=>n.format(R(2024,t+1,1)))}function Pe(e,t){let n=L(e,{weekday:t});return Array.from({length:7},(e,t)=>n.format(R(2024,1,7+t)))}function Fe(e,t){return L(t,{weekday:`short`,month:`short`,day:`numeric`}).format(R(e.year,e.month,e.day))}function Ie(e,t){return L(t,{month:`short`,day:`numeric`}).format(R(e.year,e.month,e.day))}function Le(e,t,n){return L(n,{month:`short`,day:`numeric`}).formatRange(R(e.year,e.month,e.day),R(t.year,t.month,t.day))}function Re(e,t){return L(t,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`}).format(R(e.year,e.month,e.day))}function B(e,t){return L(t,{month:`long`,year:`numeric`}).format(R(e.year,e.month,1))}function ze(e,t,n){return e.year===t.year&&e.month===t.month?B(e,n):L(n,{month:`long`,year:`numeric`}).formatRange(R(e.year,e.month,1),R(t.year,t.month,1))}function Be(e,t,n,r){switch(t){case`day`:return r===`headline`?Fe(e,n):Re(e,n);case`month`:return B(e,n);default:return I(e.year,n)}}function Ve(e,t){switch(t){case`sunday`:return 0;case`monday`:return 1;case`saturday`:return 6;default:return Ae(e)}}const V={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`},H={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:V,behavior:{closeOnSelect:!1,closeOnCancel:!0,commitOnChange:!1,ignoreOutsideClick:!1,returnFocus:!0}};function He(e,t){return e instanceof Date?e:typeof e!=`string`||e===`today`&&!t?null:e}function Ue(e,t,n,r){if(e===void 0)return null;let i=He(e,t),a=i===null?null:b(i);return a===null&&r.push({option:n,value:e}),a}function We(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 U(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 W=e=>typeof e==`boolean`?e:void 0,Ge=e=>typeof e==`string`?e:void 0,Ke=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,qe=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1?e:void 0,Je=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},Ye=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},Xe=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},Ze=e=>typeof HTMLElement<`u`&&e instanceof HTMLElement||typeof e==`string`&&e.length>0?e:void 0;function G(e){return t=>e.find(e=>e===t)}function Qe(e){return t=>typeof t==`string`&&n(t,e)?t:void 0}const $e=G([`auto`,`docked`,`modal`]),et=G([`auto`,`light`,`dark`]),tt=G([`auto`,`sunday`,`monday`,`saturday`]),nt=G([`single`,`range`,`multiple`]),rt=G([`calendar`,`input`]),it=G([`day`,`month`,`year`]),at=G([`month`,`view`]),ot=G([`day`,`month`,`year`]),st=G([`basic`,`m3-green`,`crane`,`crane-straight`,`m2`,`glassmorphic`,`pastel`,`ai`,`cyberpunk`,`blueprint`]);function ct(e){return e in V}function lt(e,t){let n={...V};for(let r of Object.keys(V))ct(r)&&r!==`multipleSelected`&&(n[r]=U(e?.[r],Ge,V[r],`labels.${r}`,t));return n.multipleSelected=U(e?.multipleSelected,Xe,V.multipleSelected,`labels.multipleSelected`,t),n}function ut(e,t){return e===void 0||e===!0?600:e===!1?0:U(e,qe,600,`ui.fullscreen`,t)}function dt(e,t){return e===void 0||e===!1?!1:e===!0?{selectable:!0}:typeof e==`object`&&e?{selectable:U(Reflect.get(e,`selectable`),W,!0,`ui.outsideDays.selectable`,t)}:(t.push({option:`ui.outsideDays`,value:e}),!1)}function ft(e,t){return e===void 0||e===!1?!1:e===!0?{clearInput:!0}:typeof e==`object`&&e?{clearInput:U(Reflect.get(e,`clearInput`),W,!0,`ui.clearButton.clearInput`,t)}:(t.push({option:`ui.clearButton`,value:e}),!1)}const pt=`calendar.range.presets`;function mt(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 ht(e,t){if(e===void 0)return H.calendar.presets;if(!Array.isArray(e))return t.push({option:pt,value:e}),H.calendar.presets;let n=e,r=[];for(let e of n){let n=mt(e);n===null?t.push({option:pt,value:e}):r.push(n)}return r}function gt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6}function _t(e,t){let n=e?.trim();n&&!je(n)&&t.push({option:`calendar.locale`,value:e})}function vt(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)gt(e)?r.includes(e)||r.push(e):t.push({option:`calendar.disabledWeekdays`,value:e});return r}function yt(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 bt(e){return typeof e==`string`||typeof Node<`u`&&e instanceof Node?e:null}function xt(e){return e===null?null:t=>{try{return bt(e(t))}catch(e){return j(e),null}}}function St(e){return e===null?null:t=>{try{let n=e(t);return typeof n!=`string`||n.length===0?null:n}catch(e){return j(e),null}}}function Ct(e,t,n){let r=H.calendar,i=U(e,it,r.precision,`calendar.precision`,n);return i!==`day`&&t!==`single`?(n.push({option:`calendar.precision`,value:e}),r.precision):i}function wt(e,t){let n=U(e?.range?.minLength,qe,null,`calendar.range.minLength`,t),r=U(e?.range?.maxLength,qe,null,`calendar.range.maxLength`,t),i=U(e?.multiple?.max,qe,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 Tt(e,t){let n=H.calendar;_t(e?.locale,t);let r=Ne(e?.locale),i=U(e?.weekStart,tt,n.weekStart,`calendar.weekStart`,t),a=U(e?.isDateDisabled,Je,null,`calendar.isDateDisabled`,t),o=U(e?.decorateDate,Je,null,`calendar.decorateDate`,t),s=U(e?.renderDate,Je,null,`calendar.renderDate`,t),c=U(e?.validate,Ye,null,`calendar.validate`,t),l=U(e?.mode,nt,n.mode,`calendar.mode`,t);return{locale:r,weekStart:Ve(r,i),minDate:Ue(e?.minDate,!0,`calendar.minDate`,t),maxDate:Ue(e?.maxDate,!0,`calendar.maxDate`,t),disabledDates:We(e?.disabledDates,`calendar.disabledDates`,t)??[],enabledDates:We(e?.enabledDates,`calendar.enabledDates`,t),mode:l,precision:Ct(e?.precision,l,t),months:U(e?.months,qe,n.months,`calendar.months`,t),pageBy:U(e?.pageBy,at,n.pageBy,`calendar.pageBy`,t),limits:wt(e,t),presets:ht(e?.range?.presets,t),isDateDisabled:a===null?null:e=>!!a(e),disabledWeekdays:vt(e?.disabledWeekdays,t),decorateDate:o===null?null:e=>yt(o(e)),renderDate:xt(s),validate:St(c)}}function Et(e){let t=[],n=H,r=e?.calendar,i=e?.ui,a=e?.behavior,o=(e,n,r,i)=>U(e,n,r,i,t),s=Tt(r,t),{locale:c,precision:l}=s,u=o(i?.format,Qe(l),n.ui.format,`ui.format`),d=o(i?.footer,W,!1,`ui.footer`),f=a?.id;return{...s,displayMode:o(i?.displayMode,$e,n.ui.displayMode,`ui.displayMode`),inline:{enabled:o(i?.inline?.enabled,W,n.ui.inline.enabled,`ui.inline.enabled`),container:o(i?.inline?.container,Ze,null,`ui.inline.container`)},pattern:de(u,c,l),theme:o(i?.theme,st,n.ui.theme,`ui.theme`),colorScheme:o(i?.colorScheme,et,n.ui.colorScheme,`ui.colorScheme`),toggleButton:o(i?.toggleButton,Ze,null,`ui.toggleButton`),endInput:o(i?.endInput,Ze,null,`ui.endInput`),weekNumbers:o(i?.weekNumbers,W,n.ui.weekNumbers,`ui.weekNumbers`),outsideDays:dt(i?.outsideDays,t),fixedWeeks:o(i?.fixedWeeks,W,n.ui.fixedWeeks,`ui.fixedWeeks`),yearRange:{before:o(i?.yearRange?.before,Ke,n.ui.yearRange.before,`ui.yearRange.before`),after:o(i?.yearRange?.after,Ke,n.ui.yearRange.after,`ui.yearRange.after`)},todayButton:o(i?.todayButton,W,n.ui.todayButton,`ui.todayButton`),clearButton:ft(i?.clearButton,t),footerExplicit:typeof i?.footer==`boolean`?d:null,animation:o(i?.animation,W,n.ui.animation,`ui.animation`),allowPageScroll:o(i?.allowPageScroll,W,n.ui.allowPageScroll,`ui.allowPageScroll`),fullscreenBelow:ut(i?.fullscreen,t),cssClass:o(i?.cssClass,Ge,n.ui.cssClass,`ui.cssClass`),appendTo:o(i?.appendTo,Ze,null,`ui.appendTo`),swipe:o(i?.swipe,W,n.ui.swipe,`ui.swipe`),viewSwitch:o(i?.viewSwitch,W,n.ui.viewSwitch,`ui.viewSwitch`),initialView:o(i?.initialView,rt,n.ui.initialView,`ui.initialView`),mask:o(i?.mask,W,n.ui.mask,`ui.mask`),startView:o(i?.startView,ot,n.ui.startView,`ui.startView`),labels:lt(e?.labels,t),behavior:{closeOnSelect:o(a?.closeOnSelect,W,n.behavior.closeOnSelect,`behavior.closeOnSelect`),closeOnCancel:o(a?.closeOnCancel,W,n.behavior.closeOnCancel,`behavior.closeOnCancel`),commitOnChange:o(a?.commitOnChange,W,n.behavior.commitOnChange,`behavior.commitOnChange`),ignoreOutsideClick:o(a?.ignoreOutsideClick,W,n.behavior.ignoreOutsideClick,`behavior.ignoreOutsideClick`),returnFocus:o(a?.returnFocus,W,n.behavior.returnFocus,`behavior.returnFocus`),id:typeof f==`string`&&f.length>0?f:null},callbacks:{...e?.callbacks},issues:t}}const Dt=/[^\w-]/g;let Ot=0;function kt(e){return e.replace(Dt,`-`)}function At(e){return{year:e.year,month:e.month}}var jt=class{input;host;createdHost;instanceId;events=new me;raw;resolved;currentValue;currentDraft;currentView;currentFocus;currentPanel;currentMode=null;currentLayout={months:1,presets:`none`};currentActiveEnd=`start`;currentEndInput=null;activeEndControlled=!1;constructor(e,t,n,r){this.input=e,this.host=t,this.createdHost=n,this.raw=xe({},r??{}),this.resolved=Et(this.raw),Ot+=1;let i=this.resolved.behavior.id;this.instanceId=i===null?`${l}${String(Ot)}`:kt(i),this.currentPanel=_(this.resolved.precision),this.currentValue=M(this.resolved.mode),this.currentDraft=this.currentValue;let a=o();this.currentFocus=a,this.currentView=At(a)}get options(){return this.resolved}get rawOptions(){return this.raw}setOptions(e){this.raw=xe(this.raw,e),this.resolved=Et(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=At(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 e=F(this.currentValue)??o(),t=At(e);this.setPanel(_(this.resolved.precision)),this.setDraft(this.currentValue),this.setView(t,y(this.currentView,t),`api`),this.setFocus(e)}};const Mt=`dp-ui`,Nt=[`class`,`name`,`aria-invalid`,`aria-describedby`];function Pt(e){return typeof e==`string`?document.querySelector(e):e}function Ft(e){return e instanceof HTMLInputElement?e:e?.querySelector(`input`)??null}function It(e){let t=document.createElement(`div`);return t.className=Mt,e.before(t),t.append(e),t}function Lt(e){if(!ue())throw Error(`DatepickerUI needs a document`);let t=Pt(e),n=Ft(t);if(n===null)throw Error(`DatepickerUI could not find an input element`);let r=n.parentElement;return r!==null&&(t!==n||r.classList.contains(Mt))?{input:n,host:r,createdHost:!1}:{input:n,host:It(n),createdHost:!0}}function Rt(e){let{input:t,host:n,createdHost:r}=e,i=/* @__PURE__ */ new Map;for(let e of Nt)i.set(e,t.getAttribute(e));let a=n.classList.contains(Mt);return n.classList.add(Mt),{target:{input:t,host:n,createdHost:r},hostHadClass:a,inputAttributes:i}}function zt(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(Mt)}function Bt(e,t,n,r){let i=y(e,t);return i>=0&&i<n?e:r===`month`?i<0?t:d(t,-(n-1)):d(e,Math.floor(i/n)*n)}function Vt(e,t,n){let r={year:t.year,month:t.month,day:Math.min(n,u(t))},{minDate:i,maxDate:a}=e.core.options;return i!==null&&f(r,i)<0?i:a!==null&&f(r,a)>0?a:r}function Ht(e,t,n){let{core:r,managers:i}=e,a=i.validation.clampView(t),o=y(r.view,a);return o!==0&&(r.setView(a,o,n),r.setFocus(Vt(e,a,r.focus.day))),a}function K(e,t,n){let{core:r,managers:i}=e,a={year:t.year,month:t.month},{months:o}=r.layout,s=i.validation.clampView(Bt(r.view,a,o,r.options.pageBy)),c=y(s,a);if(c<0||c>=o)return;let l=y(r.view,s);l!==0&&r.setView(s,l,n),r.setFocus(t)}const Ut=/^(\d{4})-(\d{2})$/,Wt=/^\d{4}$/;function Gt(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 Kt(e,t){let n=v(e);switch(t){case`day`:return n;case`month`:return n.slice(0,7);default:return n.slice(0,4)}}function qt(e,t){let n=h(e);if(n!==null||t===`day`)return n===null?null:Gt(n,t);if(t===`month`){let t=Ut.exec(e);return t?m(Number(t[1]),Number(t[2]),1):null}return Wt.test(e)?m(Number(e),1,1):null}function Jt(e,t){return{...e,order:e.order.filter(e=>e===`year`||t===`month`&&e===`month`)}}function q(e,t,n){return n===`day`?S(e,t):S(e,Jt(t,n))}function Yt(e,t,n){return fe(t===`day`?e:Jt(e,t),n)}function Xt(e,t,n){if(n===`day`)return x(e,t);let{order:r}=Jt(t,n),i=te(e);if(i?.length!==r.length)return null;let a=1,o=null;for(let[e,t]of r.entries()){let n=i[e]??``;if(t===`year`)o=ee(n);else if(n.length>2)return null;else a=Number(n)}return o===null?null:m(o,a,1)}function Zt(e,t,n){let r=c(e,t)+1;return n.minLength!==null&&r<n.minLength?!1:n.maxLength===null||r<=n.maxLength}function Qt(e,t,n,r){let i=r;if(t.maxLength!==null){let n=E(e,t.maxLength-1);i=f(n,r)<0?n:r}for(let t=E(e,1);f(t,i)<=0;t=E(t,1))if(n(t))return t;return null}function $t(e,t,n,r){if(e.mode===`multiple`){let{multipleMax:n}=t,{dates:r}=e;return t=>n!==null&&r.length>=n&&!ye(e,t)}if(e.mode!==`range`||e.start===null||e.end!==null)return()=>!1;let{start:i}=e,a=null,o=!1;return e=>f(e,i)<0?!1:f(e,r)>0||!Zt(i,e,t)||(o||=(a=Qt(i,t,n,r),!0),a!==null&&f(e,a)>=0)}function en(e,t,n,r){if(!Zt(e,t,n))return`range-length`;for(let n=e;f(n,t)<=0;n=E(n,1)){let e=r(n);if(e!==null)return e}return null}function tn(e,t){for(let n of e){let e=t(n);if(e!==null)return e}return null}function nn(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?en(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`:tn(e.dates,n)}}function rn(e,t,n){return nn(e,t,e=>n(e)?`disabled`:null)===null}function an(e,t,n){return e.some(e=>f(e,t)===0)?e.filter(e=>f(e,t)!==0):n.multipleMax!==null&&e.length>=n.multipleMax?null:he([...e,t])}function on(e){return e.mode===`range`&&e.start!==null&&e.end===null?`end`:`start`}function sn(e,t){return e.mode===`range`?t===`start`?{mode:`range`,start:null,end:null}:{mode:`range`,start:e.start,end:null}:e}function cn(e,t,n,r){switch(e.mode){case`single`:return{mode:`single`,date:t};case`range`:return r===`start`||e.start===null||f(t,e.start)<0?{mode:`range`,start:t,end:null}:{mode:`range`,start:e.start,end:t};default:{let r=an(e.dates,t,n);return r===null?e:{mode:`multiple`,dates:r}}}}var ln=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=Gt(e,t.options.precision),i=t.followsActiveEnd?t.activeEnd:on(t.draft);if(!this.session.active||!n.validation.isSelectable(r,sn(t.draft,i)))return;K(this.context,r,`button`);let a=cn(t.draft,r,t.options.limits,i);t.setDraft(a),t.setActiveEnd(on(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};nn(o,a,e=>r.validation.unavailableReason(e))===null&&(n.setDraft(o),n.setActiveEnd(`start`),K(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&&rn(e,i,e=>n.validation.isDisabled(e));if(!this.session.active||!a)return;t.setDraft(e);let o=F(e);o!==null&&K(this.context,o,`api`)}announce(e,t){let{emitter:n}=this.context,{describe:r}=this.values;n.emit(`select:day`,{value:r(t),selected:ye(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()}},un=class{context;session;values;selector;constructor(e,t,n){this.context=e,this.session=t,this.values=n,this.selector=new ln(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&&K(this.context,e,`keyboard`)}navigate(e,t){this.session.active&&Ht(this.context,d(this.context.core.view,e),t)}page(e,t){let{core:n}=this.context,r=n.options.pageBy===`view`?n.layout.months:1;this.navigate(e*r,t)}jumpTo(e,t){if(!this.session.active)return;let{core:n}=this.context,r=n.panel,i=Ht(this.context,e,t);t===`menu`&&(n.setPanel(_(n.options.precision)),this.announcePick(r,i))}showPanel(e){this.session.active&&this.context.core.setPanel(e)}confirm(){this.session.active&&ge(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:e,managers:t}=this.context,n=o();t.validation.isSelectable(n,e.draft)?this.select(n):K(this.context,n,`button`)}clear(){if(!this.session.active)return;let{core:e}=this.context;e.setDraft(M(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})}},dn=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 fn=[`class`,`name`,`aria-invalid`];function pn(e){let{core:t,emitter:n}=e,{endInput:r,mode:i}=t.options;if(i!==`range`||r===null)return null;let a=O(r,t.host);return a instanceof HTMLInputElement&&a!==t.input?a:(n.emit(`error`,{code:`invalid-option`,message:`ui.endInput does not match an input element`,option:`ui.endInput`}),null)}function mn(e){let t=/* @__PURE__ */ new Map;for(let n of fn)t.set(n,e.getAttribute(n));return()=>{for(let[n,r]of t)r===null?e.removeAttribute(n):e.setAttribute(n,r)}}const hn=[`calendar`,`ui`,`labels`,`behavior`,`callbacks`];function gn(e){let t=[];for(let n of hn){let r=e[n];if(r!==void 0)for(let e of Object.keys(r))t.push(`${n}.${e}`)}return t}function _n(e,t){return e.some(e=>t.option===e||t.option.startsWith(`${e}.`))}function vn(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 yn=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=M(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(),P(n.value)||r.input.write(n.value),r.triggers.updateLabel(),this.refreshSurface(e);let i=gn(t);vn(this.context,n.options.issues.filter(e=>_n(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)}},bn=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=pn(this.context);e.setEndInput(i),i!==null&&(this.restoreEndInput=mn(i));let a=P(e.value)?t.input.readInitial():e.value;e.setValue(a),P(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(),vn(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),zt(this.hostSnapshot),t.events.clear(),n.clear())}},xn=class{tail=Promise.resolve();pending=0;stopped=!1;run(e){let t=async()=>{this.stopped||await e()},n=this.pending===0?t():this.tail.then(t);this.pending+=1;let r=n.catch(j).finally(()=>{--this.pending});return this.tail=r,r}stop(){this.stopped=!0}};function Sn(e){return e<0?-1:+(e>0)}var Cn=class{context;queue=new xn;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:e,emitter:t}=this.context;O(e.options.inline.container)===null?t.emit(`error`,{code:`invalid-option`,message:`ui.inline.container does not match an element`,option:`ui.inline.container`}):(this.begin(`inline`),t.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(e){let{core:t}=this.context,n=t.options,r=window.innerWidth;if(e===`inline`){let e=O(n.inline.container)?.clientWidth??0;r=e>0?e:r}t.setLayout(p({months:n.months,precision:n.precision,mode:n.mode,surface:e,fullscreen:i(n.mode,e,window.innerWidth,n.fullscreenBelow),width:r,weekNumbers:n.weekNumbers,presets:n.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(i,t,a)&&n.setPanel(_(a)),this.queue.run(()=>r.display.unmount()),this.queue.run(()=>r.display.mount(t))}pickMode(){let{displayMode:e}=this.context.core.options;return r(e,!1,window.innerWidth,window.innerHeight)}clampView(){Ht(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(o,t,s)?n.setPanel(`input`):s===`day`&&o!==`range`&&c!==`day`&&n.setPanel(re(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:Sn(e.delta),source:e.source})}},wn=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 Tn(e,t){if(P(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 N(e).map(t)}}function En(e,t){if(typeof e==`string`)return qt(e,t);if(e instanceof Date){let n=b(e);return n===null?null:Gt(n,t)}return null}function Dn(e){if(!(`start`in e&&`end`in e))return null;let t=En(e.start,`day`),n=En(e.end,`day`);return t===null||n===null||f(t,n)>0?null:{mode:`range`,start:t,end:n}}function On(e){let t=[];for(let n of e){let e=En(n,`day`);if(e===null)return null;t.push(e)}return{mode:`multiple`,dates:he(t)}}function kn(e,t,n){if(e===null)return M(t);if(t===`multiple`)return Array.isArray(e)?On(e):null;if(t===`single`){let r=En(e,n);return r===null?null:{mode:t,date:r}}return typeof e==`object`&&!Array.isArray(e)&&!(e instanceof Date)?Dn(e):null}const An=[`start`,`end`];var jn=class{context;session;constructor(e,t){this.context=e,this.session=t}describe=e=>{let{pattern:t,precision:n}=this.context.core.options;return{value:Kt(e,n),date:s(e),formatted:q(e,t,n)}};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=kn(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=An;!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=!ve(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 Tn(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&&K(this.context,n,`api`)}},Mn=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 dn(r),a=new wn(r);this.session=new Cn(r),this.values=new jn(r,this.session),this.actions=new un(r,this.session,this.values),this.instance=new bn(r,this.session,i,a),this.updates=new yn(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 Nn=`dp-ui--pointer`,Pn=[`Shift`,`Control`,`Alt`,`Meta`];function Fn(){return pe()||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function In(e){return e?Fn()?`reduced`:`full`:`none`}function Ln(e,t){e.textContent=``,e.textContent=t}function Rn(e){let t=e.ownerDocument,n=()=>{e.classList.add(Nn)},r=t=>{Pn.includes(t.key)||e.classList.remove(Nn)};return e.addEventListener(`pointerdown`,n,!0),t.addEventListener(`keydown`,r,!0),()=>{e.removeEventListener(`pointerdown`,n,!0),t.removeEventListener(`keydown`,r,!0)}}const zn=e=>e.toLowerCase().replace(/_/g,`-`);function Bn(e,t){Object.entries(C).forEach(([n,r])=>{e.style.setProperty(`--dp-ui-motion-${zn(n)}`,`${String(t?r:0)}ms`)}),Object.entries(oe).forEach(([t,n])=>{e.style.setProperty(`--dp-ui-easing-${zn(t)}`,n)})}const Vn=` – `,Hn=/\s*[–—]\s*|\s+-\s+/,Un=/[,;]/;function Wn(e,t,n){return N(e).map(e=>q(e,t,n)).join(e.mode===`range`?Vn:`, `)}function Gn(e,t){let n=[];for(let r of e){let e=t(r);if(e===null)return null;n.push(e)}return n}function Kn(e){if(e?.length!==2)return null;let[t,n]=e;return f(t,n)>0?null:{mode:`range`,start:t,end:n}}function qn(e,t,n,r,i){switch(t){case`single`:{let r=n(e);return r===null?null:{mode:t,date:r}}case`range`:return Kn(Gn(e.split(r),n));default:{let r=Gn(e.split(i).filter(e=>e.trim()!==``),n);return r===null?null:{mode:t,dates:he(r)}}}}function Jn(e,t,n,r){let i=e.trim();return i===``?M(t):qn(i,t,e=>Xt(e.trim(),n,r),Hn,Un)}function Yn(e,t){return e.mode===`range`?e.start===null||e.end===null?``:`${Kt(e.start,t)}/${Kt(e.end,t)}`:N(e).map(e=>Kt(e,t)).join(`,`)}function Xn(e,t,n){let r=e.trim();return r===``?M(t):qn(r,t,e=>qt(e.trim(),n),/\//,/,/)}function Zn(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 Qn=/* @__PURE__ */ new Map,$n=/* @__PURE__ */ new Map;function er(e){let t=Qn.get(e);if(t)return t;let n=new Intl.PluralRules(e);return Qn.set(e,n),n}function tr(e){let t=$n.get(e);if(t)return t;let n=new Intl.NumberFormat(e);return $n.set(e,n),n}function nr(e,t,n){return(typeof e==`string`?e:e[er(n).select(t)]??e.other??Object.values(e).at(0)??``).replaceAll(`{count}`,tr(n).format(t))}function rr(e,t,n,r,i){switch(e.mode){case`single`:return e.date?Be(e.date,i,n,`headline`):r.noDate;case`range`:{if(t===`input`&&e.start&&e.end)return Le(e.start,e.end,n);let i=e.start?Ie(e.start,n):r.rangeStart,a=e.end?Ie(e.end,n):r.rangeEnd;return`${i}${Vn}${a}`}default:return e.dates.length===0?r.noDate:nr(r.multipleSelected,e.dates.length,n)}}const ir=`dp-ui--ripple-pressed`,ar=`dp-ui--ripple-active`,or=e=>e.getAttribute(`aria-disabled`)===`true`||e instanceof HTMLButtonElement&&e.disabled;function sr(e,t,n){let r=e=>e instanceof Element?e.closest(t):null,i=e=>{r(e.target)?.classList.remove(ir)};e.addEventListener(`pointerdown`,t=>{let a=r(t.target);if(!a||!e.contains(a)||or(a)||t.pointerType===`mouse`&&t.button!==0)return;a.classList.remove(ar);let{left:o,top:s,width:c,height:l}=a.getBoundingClientRect();a.style.setProperty(`--dp-ui-ripple-x`,`${String(t.clientX-o)}px`),a.style.setProperty(`--dp-ui-ripple-y`,`${String(t.clientY-s)}px`),a.style.setProperty(`--dp-ui-ripple-size`,`${String(Math.max(c,l)*2)}px`),a.style.setProperty(`--dp-ui-ripple-duration`,`${String(C.RIPPLE)}ms`),a.classList.add(ir),a.addEventListener(`pointerleave`,i,{once:!0,signal:n}),Fn()||(requestAnimationFrame(()=>{a.classList.add(ar)}),window.setTimeout(()=>{a.classList.remove(ar)},C.RIPPLE))},{signal:n}),e.addEventListener(`pointerup`,i,{signal:n}),e.addEventListener(`pointercancel`,i,{signal:n})}const J={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>`},cr=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`)}}},Y=(e,t)=>`dp-ui-${e.replace(/[^\w-]/g,`-`)}-${t}`,lr=(e,t,n)=>{n!==void 0&&(e.setAttribute(`title`,`${t} (${n.display})`),e.setAttribute(`aria-keyshortcuts`,n.keys))},ur=(e,t)=>{let n=T(`span`);n.innerHTML=e;let r=n.firstElementChild;return r===null?null:(r.setAttribute(`class`,t),r.setAttribute(`aria-hidden`,`true`),r)},X=(e,t,n,r)=>{let i=w(`dp-ui__icon-button dp-ui__icon-button--${e}`,t,n);return i.firstElementChild?.setAttribute(`aria-hidden`,`true`),lr(i,t,r),i},dr=(e,t,n)=>{let r=T(`button`,`dp-ui__menu-button dp-ui__menu-button--${e}`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":n.controls});lr(r,n.name,n.shortcut);let i=T(`span`,`dp-ui__menu-button-label`);r.append(i);let a=ur(J.arrowDropDown,`dp-ui__menu-button-icon`);a!==null&&r.append(a);let o=(e,t=e)=>{i.textContent=e,r.setAttribute(`aria-label`,`${n.name}, ${t}`)};return o(t),{button:r,label:i,setText:o}},fr=(e,t)=>w(`dp-ui__text-button dp-ui__text-button--${e}`,t),pr=(e,t)=>{let n=X(`switch-view`,e.switchToInput,J.pencil);return{button:n,setInputView:r=>{n.innerHTML=r?J.calendar:J.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)}}},mr=(e,t)=>{e.querySelectorAll(`.dp-ui__text-button--confirm, .dp-ui__text-button--save`).forEach(e=>{e.disabled=!t})},hr=e=>{let{labels:t}=e,n=T(`div`,`dp-ui__actions`);n.hidden=!e.visible;let r=T(`div`,`dp-ui__actions-start`);e.todayButton&&r.append(fr(`today`,t.today)),e.clearButton&&r.append(fr(`clear`,t.clear));let i=T(`div`,`dp-ui__actions-end`);return i.append(fr(`cancel`,t.cancel),fr(`confirm`,t.confirm)),n.append(r,i),n},gr=[[`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`}]],_r=e=>gr.find(([t])=>e.classList.contains(t)),vr=e=>_r(e)?.[0]??null,yr=(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()}},br=(e,t,n)=>{e.addEventListener(`click`,e=>{let{target:t}=e,r=t instanceof Element?t.closest(`button`):null;if(r!==null){let e=_r(r);e&&yr(e[1],n);return}let i=n.cellAt(t);i!==null&&n.actions.select(i.date)},{signal:t})},xr=`dp-ui__container--menu-open`,Sr=`dp-ui__container--input`,Cr=`--dp-ui-visible-months`,wr=e=>e.closest(`.dp-ui__container`),Tr=(e,t)=>e!==t&&e!==`days`&&e!==`input`,Er=(e,t)=>{let n=t>1;e.classList.toggle(`dp-ui__container--multi-month`,n),n?e.style.setProperty(Cr,String(t)):e.style.removeProperty(Cr)},Dr=(e,t,n)=>{let r=t===`input`;e.classList.toggle(Sr,r),Er(e,r?1:n)},Or=(e,t)=>{let n=T(`div`,`dp-ui__navigation-group dp-ui__navigation-group--${e}`);return n.append(...t),n},kr=e=>{let{labels:t}=e,n=cr(t),r=z(e.locale,`short`),i=z(e.locale,`long`),a=dr(`month`,``,{name:t.chooseMonth,controls:Y(e.instanceId,`month-menu`),shortcut:n.chooseMonth}),o=dr(`year`,``,{name:t.chooseYear,controls:Y(e.instanceId,`year-menu`),shortcut:n.chooseYear}),s=T(`div`,`dp-ui__header dp-ui__header--docked`),c=Or(`month`,[X(`prev-month`,t.previousMonth,J.keyboardArrowLeft,n.previousMonth),a.button,X(`next-month`,t.nextMonth,J.keyboardArrowRight,n.nextMonth)]);c.hidden=e.groups!==`both`,s.hidden=e.groups===`none`,s.append(c,Or(`year`,[X(`prev-year`,t.previousYear,J.keyboardArrowLeft,n.previousYear),o.button,X(`next-year`,t.nextYear,J.keyboardArrowRight,n.nextYear)]));let l=t=>{a.setText(r[t.month-1]??``,i[t.month-1]??``),o.setText(I(t.year,e.locale))},u=e=>{a.button.setAttribute(`aria-expanded`,String(e===`month-menu`)),o.button.setAttribute(`aria-expanded`,String(e===`year-menu`)),a.button.disabled=e===`year-menu`,o.button.disabled=e===`month-menu`};return l(e.view),u(e.home),{element:s,setView:l,setPanel:u}},Ar=`dp-ui__headline--fading-out`,jr=(e,t)=>{let n=T(`div`,`dp-ui__headline`);n.textContent=e;let r=null,i=null,a=()=>{i!==null&&clearTimeout(i),i=null,r=null,n.classList.remove(Ar)},o=()=>{let e=r;a(),e!==null&&(n.textContent=e)};return{element:n,setText:e=>{e!==(r??n.textContent)&&(t?(r=e,n.classList.add(Ar),i??=setTimeout(o,C.HEADLINE_FADE)):(a(),n.textContent=e))},destroy:a}},Mr=e=>{let{labels:t,switchView:n}=e,r=T(`div`,`dp-ui__header dp-ui__header--modal`),i=T(`div`,`dp-ui__supporting-text`);i.textContent=e.title;let a=jr(e.text,e.animate);r.append(i,a.element);let o=n===null?null:pr(t,n.panelId);return o!==null&&r.append(o.button),{element:r,setText:e=>{a.setText(e)},setInputView:e=>{o?.setInputView(e)},destroy:()=>{a.destroy()}}},Nr=(e,t,n,r)=>{let i=cr(n),a=T(`div`,`dp-ui__navigation`);return a.append(dr(`year-grid`,B(e,t),{name:n.chooseYear,controls:Y(r,`year-grid`),shortcut:i.chooseYear}).button,X(`prev-month`,n.previousMonth,J.keyboardArrowLeft,i.previousMonth),X(`next-month`,n.nextMonth,J.keyboardArrowRight,i.nextMonth)),a},Pr=(e,t,n,r)=>{let i=T(`div`,`dp-ui__navigation dp-ui__navigation--month-grid`),a=cr(n);return i.append(dr(`year-grid`,I(e.year,t),{name:n.chooseYear,controls:Y(r,`year-grid`),shortcut:a.chooseYear}).button,X(`prev-year`,n.previousYear,J.keyboardArrowLeft,a.previousYear),X(`next-year`,n.nextYear,J.keyboardArrowRight,a.nextYear)),i},Fr=(e,t,n,r)=>{let i=T(`div`,`dp-ui__navigation dp-ui__navigation--year-grid`),{button:a}=dr(`year-grid`,B(e,t),{name:n.chooseYear,controls:Y(r,`year-grid`)});return a.setAttribute(`aria-expanded`,`true`),i.append(a),i},Ir=e=>{let{decorateDate:t}=e.options;return t===null?()=>null:e=>{try{return t(s(e))??null}catch(e){return j(e),null}}},Lr=e=>{let{renderDate:t}=e.options;return t===null?()=>null:e=>t(s(e))},Rr=(e,t,n)=>{let{options:r}=e;return{locale:r.locale,weekStart:r.weekStart,weekNumbers:r.weekNumbers,showOutside:n,outsideSelectable:r.outsideDays!==!1&&r.outsideDays.selectable,labels:{weekNumber:r.labels.weekNumber},rangeLabels:{start:r.labels.rangeStart,end:r.labels.rangeEnd},headingVisible:!1,weekdaysVisible:!0,multiselectable:e.draft.mode!==`single`,rangeRole:()=>null,decorate:Ir(e),content:Lr(e),isSelected:t=>ye(e.draft,t),isDisabled:n=>!t.isSelectable(n,e.followsActiveEnd?sn(e.draft,e.activeEnd):e.draft),today:o(),focus:e.focus}},zr=(e,t,n)=>{let r=e.layout.months>1,i=n===`docked`&&!r&&e.options.outsideDays!==!1,a=Rr(e,t,i);return r?{...a,headingVisible:!0}:a},Br=(e,t)=>ze(t,d(t,e.layout.months-1),e.options.locale),Z=e=>rr(e.draft,e.panel===`input`?`input`:`calendar`,e.options.locale,e.options.labels,e.options.precision),Vr={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},Hr=e=>{switch(e){case`day`:return`both`;case`month`:return`year`;case`year`:return`none`}},Ur=e=>Vr[e],Wr=(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(c,r,l),i=Mr({labels:a,title:Zn(a,c,l),animate:o,text:Z(t),switchView:n?{panelId:Y(t.instanceId,`input`)}:null});return i.setInputView(t.panel===`input`),{element:i.element,docked:null,modal:i}}let u=kr({instanceId:t.instanceId,locale:i,labels:a,view:t.view,groups:Hr(l),home:_(l)});return{element:u.element,docked:u,modal:null}},Gr=(e,t)=>{let n=d(e,t);return{year:n.year,month:n.month,day:Math.min(e.day,u(n))}},Kr=(e,t,n,r)=>{let i=t?12:1;switch(e){case`ArrowLeft`:return E(n,r?1:-1);case`ArrowRight`:return E(n,r?-1:1);case`ArrowUp`:return E(n,-7);case`ArrowDown`:return E(n,7);case`Home`:return{year:n.year,month:n.month,day:1};case`End`:return{...n,day:u(n)};case`PageUp`:return Gr(n,-i);case`PageDown`:return Gr(n,i);default:return null}},qr=e=>e.ctrlKey||e.altKey||e.metaKey,Jr=(e,t)=>{let n=e.toLowerCase();return t===`modal`?n===`y`?`year-grid`:null:n===`m`?`month-menu`:n===`y`?`year-menu`:null},Yr=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`},Xr=(e,t)=>{let{panel:n}=t.core;n!==t.home&&n!==`input`&&(e.preventDefault(),e.stopPropagation(),t.actions.showPanel(t.home))},Zr=(e,t)=>{if(!e.shiftKey||!Yr(t))return!1;let n=Jr(e.key,t.layout);return n!==null&&(e.preventDefault(),t.actions.showPanel(n),!0)},Qr=(e,t,n)=>{e.preventDefault(),e.key===`Enter`&&n.layout===`modal`&&n.core.options.mode===`single`&&ye(n.core.draft,t.date)?n.actions.confirm():n.actions.select(t.date)},$r=(e,t,n)=>{if(e.key===`Enter`||e.key===` `){Qr(e,t,n);return}let r=Kr(e.key,e.shiftKey,t.date,n.isRtl());r!==null&&(e.preventDefault(),n.actions.focusDate(r))},ei=(e,t,n)=>{e.addEventListener(`keydown`,e=>{if(e.defaultPrevented)return;if(e.key===`Escape`){Xr(e,n);return}if(qr(e)||Zr(e,n))return;let t=n.cellAt(e.target);t!==null&&$r(e,t,n)},{signal:t})},ti=`dp-ui__ghost`,ni=e=>Array.from(e.querySelectorAll(`*`)).filter(e=>e.closest(`.${ti}`)===null),ri=(e,t,n)=>{e.querySelectorAll(`.${ti}`).forEach(e=>{e.remove()}),e.removeAttribute(`popover`),e.removeAttribute(`style`),e.classList.remove(`dp-ui__container--morphing`),e.classList.add(ti),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`)},ii=(e,t)=>{let n=Array.from(t.querySelectorAll(`*`));return ni(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}]})},ai=({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`))})},oi=(e,t,n)=>{let r=e.cloneNode(!0);if(!(r instanceof HTMLElement))return null;ri(r,t,n);let i=ii(e,r);i.forEach(ai);let a=null,o=()=>{if(a!==null){let e=a;a=null,e.cancel()}r.remove()};return{show:()=>{e.append(r),i.forEach(({copy:e,top:t,left:n})=>{e.scrollTop=t,e.scrollLeft=n}),typeof r.animate==`function`?(a=r.animate([{opacity:1},{opacity:0}],{duration:C.VIEW_SWITCH_FADE_OUT,easing:`linear`,fill:`forwards`}),a.finished.then(o,o)):o()},remove:o}},si=`dp-ui__container--morphing`,ci=/* @__PURE__ */ new WeakMap,li=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height,radius:getComputedStyle(e).borderRadius}},ui=(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}},di=e=>({width:`${String(e.width)}px`,height:`${String(e.height)}px`,borderRadius:e.radius}),fi=(e,t,n)=>{if(n.height===0)return;let r=getComputedStyle(e).direction===`rtl`,i=(t.x-n.x)*(r?-1:1),a=t.y-n.y,o=t.height/n.height;if(i===0&&a===0&&o===1)return;let s=r?`top right`:`top left`;e.animate([{transform:`translate(${String(i)}px, ${String(a)}px) scale(${String(o)})`,transformOrigin:s},{transform:`none`,transformOrigin:s}],{duration:C.VIEW_SWITCH,easing:oe.EMPHASIZED})},pi=(e,t,n)=>{if(n===`none`||typeof e.animate!=`function`)return t(),null;if(n===`reduced`){let n=li(e),r=oi(e,n.width,n.height);return t(),r?.show(),null}let r=e.querySelector(`.dp-ui__headline`),i=li(e),a=ui(e,r),o=oi(e,i.width,i.height);t();let s=li(e),c=ui(e,r);e.classList.add(si);let l=e.animate([di(i),di(s)],{duration:C.VIEW_SWITCH,easing:oe.EMPHASIZED});ci.set(e,l),o?.show(),r!==null&&a!==null&&c!==null&&fi(r,a,c);let u=()=>{o?.remove(),ci.get(e)===l&&(ci.delete(e),e.classList.remove(si))};return l.finished.then(u,u),l};function mi(e){let t=e.describedById??`${e.id}-supporting`,n=T(`div`,`dp-ui__text-field`),r=T(`input`,`dp-ui__text-field-input`,{id:e.id,type:`text`,inputmode:`numeric`,autocomplete:`off`,placeholder:e.placeholder,tabindex:`0`,"aria-invalid":`false`,"aria-describedby":t});r.value=e.value;let i=T(`label`,`dp-ui__text-field-label`,{for:e.id});i.textContent=e.label;let a=T(`div`,`dp-ui__text-field-supporting`,{id:t,"aria-live":`polite`});return a.textContent=e.hint,n.append(r,i,a),{element:n,input:r,getValue:()=>r.value,setValue:e=>{r.value=e},setError:t=>{let i=t!==null;n.classList.toggle(`dp-ui__text-field--error`,i),r.setAttribute(`aria-invalid`,i?`true`:`false`);let o=t??e.hint;a.textContent!==o&&(a.textContent=o)}}}function hi(e){return e.mode===`single`?e.date:null}function gi(e){return e.mode===`single`?e.date===null:e.mode===`range`?e.start===null:e.dates.length===0}function _i(e){let{instanceId:t,draft:n,pattern:r,labels:i,rules:a}=e,o=T(`div`,`dp-ui__input-panel`,{"data-panel":`input`,id:Y(t,`input`)}),s=fe(r,g(i)),c=(e,n,i)=>mi({id:`${t}-input-${e}`,label:n,placeholder:s,hint:s,value:i?S(i,r):``}),l=n.mode===`range`,u=c(l?`start`:`date`,l?i.startDateField:i.dateField,n.mode===`range`?n.start:hi(n)),d=l?c(`end`,i.endDateField,n.end):null,p=d?[u,d]:[u],m=t=>{let n=t.getValue().trim();if(n===``)return t.setError(null),{date:null,failed:!1};let o=x(n,r);if(o===null)return t.setError(i.invalidDate),{date:null,failed:!0};let s=a.unavailableReason(o);return s===null?(t.setError(null),t.setValue(S(o,r)),{date:o,failed:!1}):(t.setError(e.messageFor(s)),{date:null,failed:!0})},h=()=>{let e=m(u);if(!d)return e.failed?null:{mode:`single`,date:e.date};let t=m(d),n=t.date,r=e.failed||t.failed;return e.date&&n&&f(n,e.date)<0&&(d.setError(i.invalidRange),n=null,r=!0),r?null:{mode:`range`,start:e.date,end:n}},_=t=>{let n=nn(t,e.limits,e=>a.unavailableReason(e));return n===null||((d??u).setError(e.messageFor(n)),!1)};return p.forEach(t=>{t.input.addEventListener(`change`,()=>{let t=h();t&&_(t)&&e.onDraft(t)}),t.input.addEventListener(`keydown`,t=>{if(t.key!==`Enter`)return;t.preventDefault();let n=h();n&&_(n)&&ge(n)&&!gi(n)&&(e.onDraft(n),e.onSubmit())})}),o.append(...p.map(e=>e.element)),o}function vi(e,t){let{labels:n,minDate:r,maxDate:i,pattern:a,precision:o}=t;return e===`min`&&r!==null?n.beforeMinDate.replace(`{date}`,q(r,a,o)):e===`max`&&i!==null?n.afterMaxDate.replace(`{date}`,q(i,a,o)):e===`range-length`?n.invalidRange:n.unavailableDate}const yi=e=>{let{core:t,actions:n,rules:r}=e,{pattern:i,labels:a,limits:o}=t.options;return[_i({instanceId:t.instanceId,draft:t.draft,pattern:i,labels:a,rules:r,limits:o,messageFor:e=>vi(e,t.options),onDraft:e=>{n.typeDraft(e)},onSubmit:()=>{n.confirm()}})]},bi=`dp-ui__pager--dragging`,xi=e=>e instanceof Element&&e.closest(`button`)!==null,Si=(e,t)=>{e.push(t),e.length>k.VELOCITY_SAMPLES&&e.shift()},Ci=e=>{let t=e.at(0),n=e.at(-1);return!t||!n?0:(n.x-t.x)/Math.max(k.MIN_SAMPLE_SPAN_MS,n.t-t.t)},wi=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},Ti=(e,t)=>{e.hasPointerCapture(t)&&e.releasePointerCapture(t)},Ei=(e,t,n)=>{let r=null,i=null,a=t=>{t.controller.abort(),r===t&&(r=null),t.dragging&&(e.classList.remove(bi),Ti(e,t.pointerId))},o=()=>{i?.abort();let t=new AbortController;i=t,e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),t.abort()},{capture:!0,signal:t.signal}),requestAnimationFrame(()=>{t.abort()})},s=t=>{n.onBegin(),t.dragging=!0,t.width=n.pageWidth(),wi(e,t.pointerId),e.classList.add(bi)},c=(e,t)=>{if(t.pointerId!==e.pointerId)return;let r=t.clientX-e.startX;if(!e.dragging){if(Math.abs(r)<=k.DRAG_START_PX)return;s(e)}e.lastX=t.clientX,Si(e.samples,{x:t.clientX,t:t.timeStamp}),n.onMove(r,e.width)},l=(e,t,r)=>{t.pointerId===e.pointerId&&(a(e),e.dragging&&(r?n.onAbort():(o(),Si(e.samples,{x:e.lastX,t:t.timeStamp}),n.onRelease({dx:e.lastX-e.startX,velocity:Ci(e.samples),width:e.width}))))};e.addEventListener(`pointerdown`,t=>{if(t.button!==0||!t.isPrimary||xi(t.target))return;let i=r;i&&(a(i),i.dragging&&n.onAbort());let o=new AbortController,s={pointerId:t.pointerId,startX:t.clientX,samples:[{x:t.clientX,t:t.timeStamp}],controller:o,lastX:t.clientX,width:0,dragging:!1};r=s;let u=e.ownerDocument,d={signal:o.signal};u.addEventListener(`pointermove`,e=>{c(s,e)},d),u.addEventListener(`pointerup`,e=>{l(s,e,!1)},d),u.addEventListener(`pointercancel`,e=>{l(s,e,!0)},d)},{signal:t});let u=()=>{r&&a(r)};return{isDragging:()=>r?.dragging===!0,cancel:u,dispose:()=>{u(),i?.abort(),i=null}}},Di=(e,t)=>e.year===t.year&&e.month===t.month,Oi=(e,t,n)=>{let r=null,i=e=>{let n=t(e);return n.classList.add(`dp-ui__page`),{view:e,element:n}},a=e=>{r?.forEach((t,n)=>{t.element.toggleAttribute(`inert`,n!==e)})},o=(e,t,n)=>{let r=e[t];if(Di(r.view,n))return e;let a=i(n);return r.element.replaceWith(a.element),t===0?[a,e[1],e[2]]:[e[0],e[1],a]};return{show:t=>{let o=[i(d(t,-n)),i(t),i(d(t,n))];e.replaceChildren(...o.map(e=>e.element)),r=o,a(1)},centerView:()=>r?.[1].view??null,reveal:(e,t)=>{r&&(r=o(r,e,t),a(e))},recenter:e=>{if(!r)return;let t=r[e],o=i(d(t.view,-n)),s=i(d(t.view,n));r.forEach((t,n)=>{n!==e&&t.element.remove()}),t.element.before(o.element),t.element.after(s.element),r=[o,t,s],a(1)},clear:()=>{r=null}}},ki=(e,t,n)=>{if(t<-k.FLICK_VELOCITY)return 1;if(t>k.FLICK_VELOCITY)return-1;let r=n*k.COMMIT_FRACTION;return e<-r?1:e>r?-1:0},Ai=(e,t,n,r)=>{let i=ki(e,t,n);return!r||i===0?i:i===1?-1:1},ji=(e,t)=>{let n=null,r=null,i=()=>typeof e.animate==`function`,a=()=>{let e=r;r=null,e?.cancel()},o=()=>{a();let e=n;e&&(n=null,e.complete(),e.animation.cancel())},s=()=>{a();let e=n;n=null,e?.animation.cancel()},c=()=>{let t=e.animate([{opacity:0},{opacity:1}],{duration:C.REDUCED_FADE,easing:`linear`});r=t;let n=()=>{r===t&&(r=null)};t.finished.then(n,n)};return{run:(r,s,l)=>{a();let u=In(t);if(r===s||u===`none`||!i()){l();return}if(u===`reduced`){l(),c();return}let d=e.animate([{transform:r},{transform:s}],{duration:C.PAGER_SETTLE,easing:oe.EMPHASIZED,fill:`forwards`}),f={animation:d,complete:l};n=f,d.finished.then(()=>{n===f&&o()},()=>void 0)},finish:o,cancel:s}},Mi=(e,t)=>Math.min(t,Math.max(-t,e)),Ni=(e,t)=>e.deltaMode===0?e.deltaX:Math.sign(e.deltaX)*t,Pi=(e,t,n)=>{let r=null,i=0,a=()=>{r=null;let e=i;i=0,n.onSettle(e,n.pageWidth())};return e.addEventListener(`wheel`,e=>{if(Math.abs(e.deltaX)<=Math.abs(e.deltaY)||n.isBlocked())return;e.preventDefault();let t=n.pageWidth();r===null?n.onBegin():clearTimeout(r),i-=Ni(e,t),n.onMove(Mi(i,t),t),r=setTimeout(a,C.WHEEL_SETTLE)},{passive:!1,signal:t}),{cancel:()=>{r!==null&&clearTimeout(r),r=null,i=0}}},Fi=`dp-ui__pager--swipe`,Ii=`--dp-ui-pager-height`;var Li=class{viewport;options;track;controller=new AbortController;previousTouchAction;strip;animator;drag=null;wheel=null;offset=0;revision=0;constructor(e,t){this.viewport=e,this.options=t,this.previousTouchAction=e.style.touchAction,this.track=T(`div`,`dp-ui__pager-track`),this.strip=Oi(this.track,e=>t.renderPage(e),t.step??1),this.animator=ji(this.track,t.animate),e.classList.add(`dp-ui__pager`),e.append(this.track),t.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,Di(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(Ii),this.viewport.classList.remove(Fi,bi),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(Fi),this.drag=Ei(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(Ai(e,t,n,this.options.rtl),`drag`)},onAbort:()=>{this.settle()}}),this.wheel=Pi(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(Ai(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(Ii,`${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 Ri=`dp-ui__date`,zi=`dp-ui__date--outside-month`,Bi=`data-decoration-label`,Vi=`data-content-label`,Hi=`dp-ui__date-content`,Ui=`dp-ui__date--has-content`,Wi=`:scope > .${Hi}`,Gi=(e,t,n)=>n.isDisabled(e)||t&&!n.outsideSelectable,Ki=(e,t,n,r)=>[[`dp-ui__date--selected`,r.isSelected(e)],[`dp-ui__date--range-start`,n===`start`],[`dp-ui__date--range-end`,n===`end`],[`dp-ui__date--in-range`,n===`in-range`],[`dp-ui__date--today`,A(e,r.today)],[`dp-ui__date--disabled`,Gi(e,t,r)],[zi,t]],qi=e=>{e.querySelector(Wi)?.remove(),e.classList.remove(Ui),e.removeAttribute(Vi)},Ji=(e,t,n)=>{let r=n.content(t);if(r===null){qi(e);return}let i=e.querySelector(Wi),a=(typeof r==`string`?r:r.textContent??``).trim();if(typeof r!=`string`||i===null||i.childElementCount!==0||i.textContent!==r){let t=T(`span`,Hi);typeof r==`string`?t.textContent=r:t.appendChild(r),i===null?e.querySelector(`.dp-ui__date-indicator`)?.after(t):i.replaceWith(t)}e.classList.add(Ui),a===``?e.removeAttribute(Vi):e.setAttribute(Vi,a)},Yi=(e,t)=>e===`start`?t.rangeLabels.start:e===`end`?t.rangeLabels.end:null,Xi=(e,t,n,r,i)=>[Re(e,i.locale),Yi(t,i),n,r].filter(e=>e!==null&&e!==``).join(`, `),Zi=(e,t,n,r)=>{let i=r.rangeRole(t);Ji(e,t,r),Ki(t,n,i,r).forEach(([t,n])=>e.classList.toggle(t,n)),e.setAttribute(`aria-selected`,String(r.isSelected(t)||i!==null)),e.setAttribute(`aria-label`,Xi(t,i,e.getAttribute(Bi),e.getAttribute(Vi),r)),A(t,r.today)?e.setAttribute(`aria-current`,`date`):e.removeAttribute(`aria-current`),Gi(t,n,r)?e.setAttribute(`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`);let a=!n&&A(t,r.focus);e.setAttribute(`tabindex`,a?`0`:`-1`)},Qi=(e,t)=>{if(t===null)return;let n=(t.className??``).split(/\s+/).filter(Boolean);e.classList.add(...n),t.label&&e.setAttribute(Bi,t.label),t.badge===!0&&e.appendChild(T(`span`,`dp-ui__date-badge`,{"aria-hidden":`true`}))},$i=(e,t)=>{if(!e.inMonth&&!t.showOutside)return T(`td`,`${Ri} dp-ui__date--empty`);let n=T(`td`,Ri,{role:`gridcell`,"data-date":v(e.date)}),r=T(`span`,`dp-ui__date-indicator`);return r.textContent=I(e.date.day,t.locale),n.appendChild(r),Qi(n,t.decorate(e.date)),Zi(n,e.date,!e.inMonth,t),n},ea=`dp-ui__visually-hidden`,ta=e=>{let t=T(`thead`),n=T(`tr`,e.weekdaysVisible?`dp-ui__weekdays`:`dp-ui__weekdays ${ea}`);if(e.weekNumbers){let t=T(`th`,`dp-ui__week-number-header`,{scope:`col`});t.textContent=e.labels.weekNumber,n.appendChild(t)}let r=Pe(e.locale,`narrow`),i=Pe(e.locale,`long`);for(let t=0;t<7;t++){let a=(e.weekStart+t)%7,o=i[a]??``,s=T(`th`,`dp-ui__weekday`,{role:`columnheader`,scope:`col`,abbr:o,title:o});s.textContent=r[a]??``,n.appendChild(s)}return t.appendChild(n),t},na=(e,t)=>{let n=T(`table`,`dp-ui__month-grid`,{role:`grid`});t.multiselectable===!0&&n.setAttribute(`aria-multiselectable`,`true`);let r=T(`caption`,t.headingVisible?`dp-ui__month-subhead`:`dp-ui__month-heading ${ea}`);r.textContent=B(e.view,t.locale),n.appendChild(r),n.appendChild(ta(t));let i=T(`tbody`);return e.weeks.forEach((n,r)=>{let a=T(`tr`,`dp-ui__week`);if(t.weekNumbers){let n=T(`th`,`dp-ui__week-number`,{scope:`row`}),i=e.weekNumbers.at(r);n.textContent=i===void 0?``:I(i,t.locale),a.appendChild(n)}n.forEach(e=>a.appendChild($i(e,t))),i.appendChild(a)}),n.appendChild(i),n},ra=(e,t)=>{e.querySelectorAll(`td[data-date]`).forEach(e=>{let n=h(e.dataset.date??``);n!==null&&Zi(e,n,e.classList.contains(zi),t)})},ia=(e,n,r)=>{let i={year:e.year,month:e.month,day:1},o=(a(i)-n+7)%7,s=r?6:Math.ceil((o+u(e))/7),c=E(i,-o),l=(4-n+7)%7,d=[],f=[];for(let n=0;n<s;n++){let r=E(c,n*7),i=[];for(let t=0;t<7;t++){let n=E(r,t);i.push({date:n,inMonth:n.year===e.year&&n.month===e.month})}d.push(i),f.push(t(E(r,l)))}return{view:e,weeks:d,weekNumbers:f}},aa=`table.dp-ui__month-grid`,oa=e=>{let{core:t,layout:n,gridContext:r}=e,{months:i}=t.layout,{showOutside:a,outsideSelectable:o,headingVisible:s}=r(),c=n===`modal`||a||t.options.fixedWeeks,l=n===`docked`,u=T(`div`,void 0,{"data-panel":`days`}),f=e=>ia(e,t.options.weekStart,c),p=e=>Array.from({length:i},(t,n)=>d(e,n)),m=e=>{let t=r();if(i===1)return na(f(e),t);let n=T(`div`,`dp-ui__months`);return n.append(...p(e).map(e=>na(f(e),t))),n},g=e=>{let r=T(`div`);if(n===`modal`){let{locale:n,labels:i}=t.options;r.append(Nr(e,n,i,t.instanceId))}return r.append(m(e)),r},_=e=>Math.max(...p(e).map(e=>f(e).weeks.length)),v=e=>{let t=_(e),n=u.querySelector(aa),r=n?.tHead?.getBoundingClientRect().height??0,i=(n?.tBodies.item(0)?.rows.item(0))?.getBoundingClientRect().height??0,a=s?n?.caption?.getBoundingClientRect().height??0:0;return r>0&&i>0?a+r+i*t:(t+(s?2:1))*48},y=new Li(u,{rtl:e.rtl,swipe:t.options.swipe,animate:t.options.animation,fitHeight:l,step:t.options.pageBy===`view`?i:1,renderPage:g,pageHeight:v,onCommit:(t,n)=>{e.onCommit(t,n)}}),b=()=>u.ownerDocument.activeElement,x=e=>{if(!(e instanceof Element))return null;let t=e.closest(`td.dp-ui__date[data-date]`);if(t===null||!u.contains(t)||t.classList.contains(`dp-ui__date--outside-month`)&&!o)return null;let n=h(t.getAttribute(`data-date`)??``);return n===null?null:{element:t,date:n}},S=()=>x(b())!==null,C=e=>u.querySelector(`.dp-ui__page:not([inert])`)?.querySelector(e)??null,w=e=>{let t=C(`td.dp-ui__date[tabindex="0"]`);return t!==null||!e?t:C(`td.dp-ui__date[data-date]:not(.dp-ui__date--outside-month)`)},ee=e=>{w(e)?.focus({preventScroll:!0})},te=()=>{let e=b();return e===null||!u.contains(e)?null:{buttonClass:vr(e)}},ne=e=>{let{buttonClass:t}=e;((t===null?null:C(`.${t}`))??w(!0))?.focus({preventScroll:!0})},E=e=>{let t=te();e(),t!==null&&ne(t)};return{element:u,present:(e,t)=>{E(()=>{t===0?y.show(e):y.slide(e,t>0?1:-1)})},finish:()=>{y.finish()},refresh:()=>{let e=r();u.querySelectorAll(aa).forEach(t=>{ra(t,e)})},refit:()=>{if(!l||u.hidden)return;let e=`${String(v(t.view))}px`;u.style.getPropertyValue(`--dp-ui-pager-height`)!==e&&E(()=>{y.show(t.view)})},cellAt:x,focusCell:ee,cellHasFocus:S,find:C,destroy:()=>{y.destroy()}}},sa=e=>{let t=document.createElement(`div`);t.className=e.className,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label);let n=[],r=e.focused>=0&&e.focused<e.items.length?e.focused:0,i=(e,r)=>{let i=n.at(Math.max(0,Math.min(n.length-1,r)));i&&(n.at(e)?.setAttribute(`tabindex`,`-1`),i.setAttribute(`tabindex`,`0`),i.focus({preventScroll:!0}),D(t,i,`nearest`))},a=e=>{let n=getComputedStyle(t).direction===`rtl`?-1:1;switch(e){case`ArrowRight`:return n;case`ArrowLeft`:return-n;case`ArrowDown`:return 3;case`ArrowUp`:return-3;default:return null}};return e.items.forEach((o,s)=>{let c=document.createElement(`button`);c.type=`button`,c.className=e.itemClass,c.setAttribute(`role`,`option`),c.setAttribute(`aria-selected`,o.selected?`true`:`false`),c.setAttribute(`aria-label`,o.name),c.setAttribute(`tabindex`,s===r?`0`:`-1`),o.selected&&c.classList.add(`${e.itemClass}--selected`),o.current&&c.classList.add(`${e.itemClass}--current`),o.disabled&&c.setAttribute(`aria-disabled`,`true`),c.textContent=o.label;let l=()=>{o.disabled||o.onPick()};c.addEventListener(`click`,l),c.addEventListener(`keydown`,e=>{let t=a(e.key);t===null?e.key===`Home`?(e.preventDefault(),i(s,0)):e.key===`End`?(e.preventDefault(),i(s,n.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l()):(e.preventDefault(),i(s,s+t))}),n.push(c),t.appendChild(c)}),requestAnimationFrame(()=>{let i=t.querySelector(`.${e.itemClass}--selected`)??n.at(r);i&&D(t,i,`center`)}),t},ca=e=>{let t=z(e.locale,`short`),n=z(e.locale,`long`),r=I(e.year,e.locale);return sa({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)}}})})},la=e=>{let t=e.querySelector(`.dp-ui__menu-item--selected`);t&&D(e,t,`center`)},ua=(e,t,n)=>{let r=e.at(Math.max(0,Math.min(e.length-1,n))),i=e.at(t);r&&(i?.setAttribute(`tabindex`,`-1`),r.setAttribute(`tabindex`,`0`),r.focus({preventScroll:!0}),r.parentElement&&D(r.parentElement,r,`nearest`))},da=(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=J.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(),ua(o,t,t+1)):e.key===`ArrowUp`?(e.preventDefault(),ua(o,t,t-1)):e.key===`Home`?(e.preventDefault(),ua(o,t,0)):e.key===`End`?(e.preventDefault(),ua(o,t,o.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())}),n}),o=a;return a.forEach(e=>r.appendChild(e)),requestAnimationFrame(()=>{la(r)}),r},fa=e=>{let t=z(e.locale,`long`);return da(`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)}}}))},pa=e=>sa({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=I(t,e.locale);return{label:n,name:n,selected:t===e.selected,current:t===e.currentYear,disabled:!1,onPick:()=>{e.onPick(t)}}})}),ma=e=>da(`year`,e.label,e.years.map(t=>({label:I(t,e.locale),selected:t===e.view.year,disabled:!1,onPick:()=>{e.onPick(t)}}))),ha=e=>{let{min:t,max:n}=e.yearBounds(),r=[];for(let e=t;e<=n;e++)r.push(e);return r},ga=(e,t)=>{let n=F(e.draft);return n?.year===t?n.month:null},_a=(e,t,n)=>(e.setAttribute(`data-panel`,t),e.id=Y(n,t),e),va=(e,t)=>{let{core:n,rules:r}=t,{labels:i,locale:a}=n.options,s=n.view,{precision:c}=n.options,l=e=>{t.actions.jumpTo(e,`menu`)},u=e=>{l({year:e,month:n.view.month})};switch(e){case`month-menu`:return[_a(fa({locale:a,view:s,label:i.chooseMonth,isMonthDisabled:e=>r.isMonthDisabled(e),onPick:e=>{l({year:n.view.year,month:e})}}),e,n.instanceId)];case`year-menu`:return[_a(ma({view:s,years:ha(r),label:i.chooseYear,locale:a,onPick:u}),e,n.instanceId)];case`month-grid`:{let u=c===`month`,d=u?ga(n,s.year):s.month,f=_a(ca({year:s.year,selected:d,focused:d??s.month,current:o(),locale:a,label:i.chooseMonth,isDisabled:e=>r.isMonthDisabled({year:n.view.year,month:e}),onPick:e=>{u?t.actions.select({year:n.view.year,month:e,day:1}):l({year:n.view.year,month:e})}}),e,n.instanceId);return t.layout===`docked`?[f]:[Pr(s,a,i,n.instanceId),f]}case`year-grid`:{let l=c===`year`,d=l?F(n.draft)?.year??null:s.year,f=_a(pa({selected:d,focused:d??s.year,years:ha(r),currentYear:o().year,label:i.chooseYear,locale:a,onPick:l?e=>{t.actions.select({year:e,month:1,day:1})}:u}),e,n.instanceId);return t.layout===`docked`||l?[f]:[Fr(s,a,i,n.instanceId),f]}}},ya=`[role="option"]`,ba=e=>{let{root:t,content:n,days:r}=e,i=`days`,a=[],o=null,s=()=>t.ownerDocument.activeElement,c=e=>{e===`days`?r.hidden=!0:(a.forEach(e=>{e.remove()}),a=[])},l=t=>{t===`days`?r.hidden=!1:(a=e.createParts(t),r.after(...a))},u=()=>{let e=o;e!==null&&(o=null,e.complete(),e.animations.forEach(e=>{e.cancel()}))},d=()=>{let e=o;o=null,e?.animations.forEach(e=>{e.cancel()})},f=(t,n,r)=>{let i=e.motion()===`none`?[]:t.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`})),s={animations:a,complete:r};o=s,Promise.all(a.map(e=>e.finished)).then(()=>{o===s&&u()},()=>void 0)},p=()=>{let e=r.getBoundingClientRect().height;e>0&&n.style.setProperty(`--dp-ui-panel-height`,`${String(e)}px`)},m=n=>{u();let o=i;if(n===o)return;o===`days`&&p();let d=t.contains(s()),m=n===`input`||o===`input`;i=n;let h=()=>{let t=()=>{c(o),l(n),e.onSwitched(n,o,d)};e.swap===void 0?t():e.swap(t,n,o)};m?h():f(o===`days`?[r]:a,C.PANEL_FADE_OUT,h)},h=e=>{d(),e!==i&&(c(i),i=e,l(e))},g=e=>{let t=e.closest(`[role="listbox"]`);return t===null?-1:Array.from(t.querySelectorAll(ya)).indexOf(e)},_=e=>{for(let t of a){let n=e(t);if(n)return n}return null},v=(e,t)=>t>=0?_(e=>Array.from(e.querySelectorAll(ya)).at(t)):e===null?null:_(t=>t.querySelector(`.${e}`));return{current:()=>i,settled:()=>o===null,mount:h,switchTo:m,rebuild:()=>{if(i===`days`||i===`input`||o!==null)return;let e=s(),t=e!==null&&a.some(t=>t.contains(e))?e:null,n=t===null?null:vr(t),r=t===null?-1:g(t),u=a.map(e=>e.scrollTop);c(i),l(i),a.forEach(e=>{e.setAttribute(`data-rebuilt`,``)}),requestAnimationFrame(()=>{a.forEach((e,t)=>{e.scrollTop=u.at(t)??e.scrollTop})}),t!==null&&v(n,r)?.focus({preventScroll:!0})},entry:()=>{for(let e of a){let t=e.querySelector(`[tabindex="0"]`);if(t!==null)return t}return null},destroy:d}},xa=e=>{let{root:t,core:n,actions:r,rules:i,mode:a,layout:o}=e,s=n.options,c=Wr(n,o,a),l=oa({core:n,layout:o,rtl:e.rtl,gridContext:()=>zr(n,i,o),onCommit:(e,t)=>{r.page(e,t)}}),u=T(`div`,`dp-ui__content`);u.append(l.element);let d=ba({root:t,content:u,days:l.element,motion:e.motion,createParts:e=>e===`input`?yi({core:n,actions:r,rules:i}):va(e,{core:n,actions:r,rules:i,layout:o}),swap:(r,i,a)=>{let o=wr(t);o===null||i!==`input`&&a!==`input`?r():pi(o,()=>{r(),Dr(o,i,n.layout.months)},e.motion())},onSwitched:e.onSwitched}),f=hr({labels:s.labels,visible:s.footerExplicit??a!==`inline`,todayButton:s.todayButton,clearButton:s.clearButton!==!1}),p=T(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`});return t.replaceChildren(c.element,u,f,p),{header:c,pages:l,panels:d,liveRegion:p}},Sa=[`.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(`, `),Ca=e=>{let{core:t,actions:n,rules:r,mode:i}=e,a=i===`modal`?`modal`:`docked`,o=new AbortController,s=T(`div`,`dp-ui__calendar`),c,l=0,u=()=>s.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(t.input).direction===`rtl`,d=()=>wr(s),f=()=>_(t.options.precision),p=e=>c.pages.cellAt(e),m=(e,n=!0)=>{c.header.docked?.setPanel(e);let r=d();r!==null&&(r.classList.toggle(xr,Tr(e,f())),n&&Dr(r,e,t.layout.months))},h=e=>{e===null?c.pages.focusCell(!0):e.focus({preventScroll:!0})},g=e=>{let t=Ur(e);return t===null?null:c.header.element.querySelector(t)??c.pages.find(t)},v=(e,t,n)=>{e===`days`&&c.pages.refit(),n&&h(e===`days`?t===`input`?null:g(t):c.panels.entry())},y=()=>{c=xa({root:s,core:t,actions:n,rules:r,mode:i,layout:a,rtl:u(),motion:()=>In(t.options.animation),onSwitched:v}),c.pages.present(t.view,0),c.panels.mount(t.panel),m(t.panel),c.header.modal?.setInputView(t.panel===`input`),mr(s,ge(t.draft)),cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,m(c.panels.current()),c.pages.refit()})},b=()=>{c.panels.destroy(),c.pages.destroy(),c.header.modal?.destroy()},x=()=>{o.signal.aborted||(m(c.panels.current()),c.pages.refit(),h(c.panels.entry()))},S=(e,n,r)=>{c.header.docked?.setView(e);let i=r!==`api`&&c.panels.current()===`days`&&c.panels.settled();c.pages.present(e,i?n:0),c.panels.rebuild(),r!==`api`&&Ln(c.liveRegion,Br(t,e))},C=()=>{let e=c.pages.cellHasFocus();c.pages.refresh(),e&&c.pages.focusCell(!1)},w=e=>{c.pages.finish(),m(e,!1),c.header.modal?.setInputView(e===`input`),c.header.modal?.setText(Z(t)),c.panels.switchTo(e)},ee=()=>{c.pages.refresh(),c.panels.rebuild(),c.header.modal?.setText(Z(t)),mr(s,ge(t.draft)),c.panels.current()===f()&&Ln(c.liveRegion,Z(t))};return y(),(e=>{let{events:r}=t;r.on(`change:view`,e=>{S(e.view,e.delta,e.source)},e),r.on(`change:draft`,ee,e),r.on(`change:focus`,C,e),r.on(`change:panel`,e=>{w(e.panel)},e),br(s,e,{actions:n,panel:()=>t.panel,home:f(),cellAt:p}),ei(s,e,{core:t,actions:n,layout:a,home:f(),cellAt:p,isRtl:u}),sr(s,Sa,e)})(o.signal),{element:s,focusInitial:x,update:()=>{if(o.signal.aborted)return;let e=s.contains(s.ownerDocument.activeElement);b(),y(),e&&x()},destroy:()=>{if(o.signal.aborted)return;o.abort(),cancelAnimationFrame(l),b();let e=d();e!==null&&(e.classList.remove(xr,Sr),Er(e,1)),s.remove()}}},wa=e=>({year:e.year,month:e.month}),Ta=e=>{let t=F(e.draft);return t===null?e.view:wa(t)},Ea=(e,t)=>{let{minDate:n,maxDate:r}=e.options,i=t.yearBounds(),a={year:i.min,month:1},o={year:i.max,month:12},s=n!==null&&y(a,n)>0,c=r!==null&&y(r,o)>0;return{first:s?wa(n):a,last:c?wa(r):o}},Da=(e,t)=>y(t.first,e)<0?t.first:y(e,t.last)<0?t.last:e,Oa=e=>{let t=T(`div`,`dp-ui__top-bar`);return t.append(X(`close`,e.close,J.close),fr(`save`,e.save)),t},ka=e=>{let{labels:t,switchView:n}=e,r=T(`div`,`dp-ui__header dp-ui__header--range`),i=e.fullscreen?Oa(t):null;i!==null&&r.append(i);let a=T(`div`,`dp-ui__header-text`),o=T(`div`,`dp-ui__supporting-text`);o.textContent=t.rangeTitle;let s=jr(e.text,e.animate);a.append(o,s.element),r.append(a);let c=n===null?null:pr(t,n.panelId);return c!==null&&r.append(c.button),{element:r,setText:e=>{s.setText(e)},setInputView:e=>{i!==null&&(i.hidden=e),c?.setInputView(e)},destroy:()=>{s.destroy()}}},Aa=(e,t)=>{let n=T(`div`,`dp-ui__weekdays-bar`,{"aria-hidden":`true`}),r=Pe(e,`narrow`);for(let e=0;e<7;e++){let i=T(`span`,`dp-ui__weekday`);i.textContent=r.at((t+e)%7)??``,n.append(i)}return n},ja=(e,t)=>t===`x`?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight,Ma=(e,t)=>t===`x`?e.clientX:e.clientY,Na=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},Pa=(e,t,n)=>{t===`x`?e.scrollLeft+=n:e.scrollTop+=n},Fa=(e,t,n=`x`,r={})=>{let i=null,a=0,o=0,s=0,c=!1;n===`x`&&e.addEventListener(`wheel`,t=>{ja(e,n)&&(Math.abs(t.deltaY)<=Math.abs(t.deltaX)||(t.preventDefault(),e.scrollLeft+=t.deltaY))},{signal:t,passive:!1}),e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button===0&&ja(e,n)&&(i=t.pointerId,a=Ma(t,n),o=a,s=0,c=!1)},{signal:t}),e.addEventListener(`pointermove`,t=>{if(t.pointerId!==i)return;let r=Ma(t,n);s=r-a,!(!c&&Math.abs(s)<k.DRAG_START_PX)&&(c||(c=!0,Na(e,t.pointerId)),Pa(e,n,o-r),o=r)},{signal:t}),e.addEventListener(`selectstart`,e=>{i!==null&&e.preventDefault()},{signal:t});let l=t=>{t.pointerId===i&&(i=null,e.hasPointerCapture(t.pointerId)&&e.releasePointerCapture(t.pointerId),c&&t.type===`pointerup`&&s!==0&&r.onDragEnd?.(s<0?1:-1))};e.addEventListener(`pointerup`,l,{signal:t}),e.addEventListener(`pointercancel`,l,{signal:t}),e.addEventListener(`click`,e=>{c&&(c=!1,e.stopPropagation(),e.preventDefault())},{signal:t,capture:!0})},Ia=(e,t,n)=>({...Rr(e,t,!1),outsideSelectable:!1,weekNumbers:!1,headingVisible:!0,weekdaysVisible:n,rangeRole:t=>be(e.draft,t)}),La=(e,t,n)=>na(ia(n,e.options.weekStart,!1),Ia(e,t,!1)),Ra=`td.dp-ui__date[data-date]`,za=e=>{let{core:t,rules:n}=e,r=new AbortController,i=T(`div`,`dp-ui__month-list`),a=[],o=null,s=0,c=!1,l=0,u=(t,n)=>Array.from({length:n},(n,r)=>e.render(d(t,r))),f=t=>{if(o===null)return;let n=d(o,a.length),r=y(n,e.bounds().last)+1,s=Math.min(t,r);if(s<=0)return;let c=u(n,s);a.push(...c),i.append(...c)},p=t=>{if(o===null)return;let n=y(e.bounds().first,o),r=Math.min(t,n);if(r<=0)return;let s=d(o,-r),c=u(s,r),l=i.scrollTop,f=i.scrollHeight;o=s,a.unshift(...c),i.prepend(...c),i.scrollTop=l+i.scrollHeight-f},m=t=>{if(o===null)return;let n=Da(t,e.bounds());p(y(n,o)),f(y(d(o,a.length-1),n))},h=e=>{if(o===null)return null;let t=y(o,e);return t<0?null:a.at(t)??null},g=t=>{let n=Da(t,e.bounds());m(n);let r=h(n);if(r===null)return;let a=r.getBoundingClientRect().top-i.getBoundingClientRect().top;i.scrollTop+=a},_=()=>{i.scrollTop<i.clientHeight&&p(6),i.scrollHeight-i.scrollTop-i.clientHeight<i.clientHeight&&f(6)},b=e=>{let t=i.getBoundingClientRect().top,n=a.map(e=>({table:e,top:e.getBoundingClientRect().top-t,height:e.getBoundingClientRect().height})),r=Math.max(n.reduce((e,t,n)=>t.top<=1?n:e,0),0),o=n.at(r);if(o===void 0)return null;let s=o.height>0?Math.max(-o.top,0)/o.height:0,c=n.at(r+1)?.table??o.table;return e===1?s>k.COMMIT_FRACTION?c:o.table:s<1-k.COMMIT_FRACTION?o.table:c},x=()=>{c&&(window.clearTimeout(l),c=!1,_())},S=e=>{x(),_();let n=b(e);if(n===null)return;let r=n.getBoundingClientRect().top-i.getBoundingClientRect().top;In(t.options.animation)===`full`?(c=!0,l=window.setTimeout(x,C.SNAP_SCROLL_FALLBACK),i.scrollTo({top:i.scrollTop+r,behavior:`smooth`})):i.scrollTop+=r},w=e=>{if(!(e instanceof Element))return null;let t=e.closest(Ra);return t!==null&&i.contains(t)?t:null},ee=e=>{m(wa(e));let t=i.querySelector(`${Ra}[data-date="${v(e)}"]`);t!==null&&(t.focus({preventScroll:!0}),D(i,t,`nearest`))},te=()=>{let e=Ia(t,n,!1);a.forEach(t=>{ra(t,e)})},ne=e.bounds(),E=Da(Ta(t),ne),re=Da(d(E,-2),ne),ie=Da(d(E,9),ne),ae=y(re,ie)+1;return ae>0&&(o=re,a.push(...u(re,ae)),i.append(...a)),i.addEventListener(`scroll`,()=>{s===0&&(s=requestAnimationFrame(()=>{s=0,c||_()}))},{passive:!0,signal:r.signal}),i.addEventListener(`scrollend`,x,{signal:r.signal}),Fa(i,r.signal,`y`,{onDragEnd:S}),{element:i,scrollToMonth:g,refresh:te,cellAt:w,focusCell:ee,ensureMonth:m,reveal:g,present:(e,t,n)=>{n===`api`?g(e):m(e)},destroy:()=>{r.abort(),cancelAnimationFrame(s),s=0,window.clearTimeout(l),c=!1}}},Ba=e=>{let t=T(`div`,`dp-ui__navigation dp-ui__navigation--months`),n=cr(e);return t.append(X(`prev-month`,e.previousMonth,J.keyboardArrowLeft,n.previousMonth),X(`next-month`,e.nextMonth,J.keyboardArrowRight,n.nextMonth)),t},Va=e=>{let{core:t,actions:n,rules:r}=e,i=oa({core:t,layout:`docked`,rtl:e.rtl,gridContext:()=>Ia(t,r,!0),onCommit:(e,t)=>{n.page(e,t)}});return{element:i.element,cellAt:e=>i.cellAt(e)?.element??null,focusCell:e=>{let t=i.find(`td.dp-ui__date[data-date][data-date="${v(e)}"]`);t===null?i.focusCell(!0):t.focus({preventScroll:!0})},refresh:()=>{i.refresh()},reveal:()=>{i.refit()},present:(e,t,n)=>{i.present(e,n===`api`?0:t)},destroy:()=>{i.destroy()}}};function Ha(e){let t;try{t=e.value()}catch(e){return j(e),null}let n=kn(t,`range`,`day`);if(n?.mode!==`range`)return null;let{start:r,end:i}=n;return r===null||i===null?null:{start:r,end:i}}const Ua=e=>{let{core:t,actions:n,rules:r,signal:i}=e,{presets:a,labels:o,limits:s}=t.options,c=T(`div`,`dp-ui__presets`,{role:`group`,"aria-label":o.presets}),l=a.map(e=>{let t=T(`button`,`dp-ui__preset`,{type:`button`});return t.textContent=e.label,t}),u=l.map(()=>null);c.append(...l);let d=()=>{a.forEach((e,n)=>{let i=l[n],a=Ha(e);u[n]=a;let o=!1,c=!1;if(a!==null){let e={mode:`range`,...a};o=rn(e,s,e=>r.isDisabled(e)),c=ve(t.draft,e)}i.disabled=!o,i.setAttribute(`aria-pressed`,c?`true`:`false`)})};return c.addEventListener(`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button.dp-ui__preset`),r=l.findIndex(e=>e===t);if(r<0)return;let i=u[r];i!==null&&n.selectRange(i.start,i.end)},{signal:i}),Fa(c,i),d(),{element:c,refresh:d,setHidden:e=>{c.hidden=e}}},Wa=`dp-ui__container--range`,Ga=`dp-ui__container--fullscreen`,Ka=`dp-ui__container--presets`,qa=[Wa,Ka,Ga,Sr],Ja=(e,t)=>e.options.footerExplicit??t!==`inline`,Ya=(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=Va({core:n,actions:r,rules:i,rtl:a});return t.append(Ba(o),e.element),e}let l=za({core:n,rules:i,render:e=>La(n,i,e),bounds:()=>Ea(n,i)});return t.append(Aa(s,c),l.element),l},Xa=e=>{let{root:t,core:n,actions:r,rules:i,mode:a,fullscreen:o,signal:s}=e,c=n.options,l=ka({labels:c.labels,animate:c.animation,text:Z(n),fullscreen:o,switchView:c.viewSwitch?{panelId:Y(n.instanceId,`input`)}:null}),u=T(`div`,`dp-ui__range`,{"data-panel":`days`}),d=Ya(e,u),f=ba({root:t,content:t,days:u,motion:e.motion,createParts:e=>e===`input`?yi({core:n,actions:r,rules:i}):[],swap:e.swap,onSwitched:e.onSwitched}),p=hr({labels:c.labels,visible:Ja(n,a),todayButton:c.todayButton,clearButton:c.clearButton!==!1}),m=T(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`}),h=n.layout.presets===`none`?null:Ua({core:n,actions:r,rules:i,signal:s}),g=n.layout.presets===`column`;return t.replaceChildren(l.element,...h===null?[]:[h.element],u,p,m),{header:l,days:d,panels:f,liveRegion:m,applyChrome:e=>{let r=e===`input`;l.setInputView(r),l.setText(Z(n)),h?.setHidden(r);let i=wr(t);i!==null&&(i.classList.add(Wa),i.classList.toggle(Ka,g),i.classList.toggle(Ga,o&&!r),Dr(i,e,n.layout.months))},refreshPresets:()=>{h?.refresh()}}},Za=[`.dp-ui__icon-button`,`.dp-ui__text-button`,`.dp-ui__preset`,`.dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator`].join(`, `),Qa=e=>e===`input`?`input`:`days`,$a=e=>{let{core:t,actions:n,rules:r,mode:i,fullscreen:a}=e,o=new AbortController,s=T(`div`,`dp-ui__calendar`),c,l=0,u=null,d=()=>In(t.options.animation),f=()=>s.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(t.input).direction===`rtl`,p=e=>{let t=c.days.cellAt(e),n=h(t?.dataset.date??``);return t===null||n===null?null:{element:t,date:n}},m=()=>{let{draft:e,value:n}=t,r=P(e)&&P(n);mr(s,ge(e)&&!r)},g=()=>{c.days.reveal(Ta(t))},_=(e,n,r)=>{e===`days`&&g(),r&&(e===`input`?c.panels.entry()?.focus({preventScroll:!0}):c.days.focusCell(t.focus))},v=(e,t)=>{let n=()=>{c.applyChrome(t),e()};u?.cancel(),u=null;let r=wr(s);r===null?n():u=pi(r,n,d())},y=()=>{c=Xa({root:s,core:t,actions:n,rules:r,mode:i,fullscreen:a,rtl:f(),signal:o.signal,motion:d,swap:v,onSwitched:_}),c.days.present(t.view,0,`api`),c.panels.mount(Qa(t.panel)),c.applyChrome(c.panels.current()),m(),cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,c.applyChrome(c.panels.current()),c.panels.current()===`days`&&g()})},b=()=>{u?.cancel(),u=null,c.panels.destroy(),c.days.destroy(),c.header.destroy()},x=()=>{if(o.signal.aborted)return;cancelAnimationFrame(l),l=0;let e=c.panels.current();c.applyChrome(e),e===`input`?c.panels.entry()?.focus({preventScroll:!0}):(g(),c.days.focusCell(t.focus))},S=()=>{c.days.refresh(),c.refreshPresets(),c.header.setText(Z(t)),m(),c.panels.current()===`days`&&Ln(c.liveRegion,Z(t))},C=()=>{let e=p(s.ownerDocument.activeElement)!==null;c.days.refresh(),e&&c.days.focusCell(t.focus)},w=(e,n,r)=>{let i=c.panels.current()===`days`&&c.panels.settled();c.days.present(e,i?n:0,r),r!==`api`&&t.layout.months>1&&Ln(c.liveRegion,Br(t,e))};return y(),(e=>{let{events:r}=t;r.on(`change:view`,e=>{w(e.view,e.delta,e.source)},e),r.on(`change:draft`,S,e),r.on(`change:active-end`,()=>{c.days.refresh()},e),r.on(`change:value`,m,e),r.on(`change:focus`,C,e),r.on(`change:panel`,e=>{c.panels.switchTo(Qa(e.panel))},e),br(s,e,{actions:n,panel:()=>t.panel,home:`days`,cellAt:p}),ei(s,e,{core:t,actions:n,layout:`range`,home:`days`,cellAt:p,isRtl:f}),sr(s,Za,e)})(o.signal),{element:s,focusInitial:x,update:()=>{if(o.signal.aborted)return;let e=s.contains(s.ownerDocument.activeElement);b(),y(),e&&x()},destroy:()=>{if(o.signal.aborted)return;o.abort(),cancelAnimationFrame(l),b();let e=wr(s);e!==null&&(e.classList.remove(...qa),Er(e,1)),s.remove()}}};var eo=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(e){this.release();let t=this.createHost(e);if(t===null)return;let{core:n}=this,{options:r}=n,{actions:a,rules:o,theme:s}=this.deps,c=++this.generation;s.applyTo(t.root),Bn(t.root,r.animation);let l=pe()?1/0:window.innerWidth,u={core:n,actions:a,rules:o,mode:e,fullscreen:i(r.mode,e,l,r.fullscreenBelow)},d=r.mode===`range`?$a(u):Ca(u);this.mounted={mode:e,host:t,view:d,stopModality:Rn(t.root),stopSchemeWatch:e===`inline`?le(()=>{s.applyTo(t.root)}):()=>void 0},t.body.append(d.element),await t.open(),c===this.generation&&e!==`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),Bn(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(e){let{core:t}=this,{options:n}=t,{actions:r}=this.deps,i=Zn(n.labels,n.mode,n.precision);if(e===`inline`){let e=O(n.inline.container);return e===null?null:new se({container:e,label:i})}return e===`modal`?new ne({parent:O(n.appendTo)??t.host,label:i,allowPageScroll:n.allowPageScroll,onCancel:e=>{r.cancel(e)}}):new ae({host:t.host,anchor:t.input,instanceId:t.instanceId,rtl:getComputedStyle(t.input).direction===`rtl`,label:i,ignoreOutsideClick:n.behavior.ignoreOutsideClick,inside:t.endInput===null?[]:[t.endInput],onOutside:()=>{r.cancel(`outside`)},onEscape:()=>{r.cancel(`escape`)}})}},to=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 Yn(t,n.precision);let r=e===`start`?t.start:t.end;return r===null?``:Kt(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=Wn(e,n,r);return}let a=e=>e===null?``:q(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:M(t);e.setValue(n),this.writeFields(n),this.sync()}};const no=`aria-describedby`,ro=e=>(e.getAttribute(no)??``).split(/\s+/).filter(e=>e!==``);function io(e,t,n,r){let i=T(`span`,`dp-ui__visually-hidden`,{id:n}),a=T(`span`,void 0,{"aria-live":`polite`}),o=T(`span`);return o.textContent=r,i.append(a,` `,o),t.append(i),e.setAttribute(no,[...ro(e),n].join(` `)),{setHint:e=>{o.textContent!==e&&(o.textContent=e)},setError:e=>{let t=e??``;a.textContent!==t&&(a.textContent=t)},destroy:()=>{i.remove();let t=ro(e).filter(e=>e!==n);t.length===0?e.removeAttribute(no):e.setAttribute(no,t.join(` `))}}}const ao=`dp-ui--error`;function oo(e,t,n){e.setAttribute(`aria-invalid`,`true`),t.classList.add(ao),e.setCustomValidity(n)}function so(e,t){e.removeAttribute(`aria-invalid`),t.classList.remove(ao),e.setCustomValidity(``)}function co(e,t,n){let r=e.trim(),i=t.trim();if(r===``&&i===``)return{kind:`empty`};let a=r===``?null:x(r,n);if(r!==``&&a===null)return{kind:`invalid`,field:`start`};let o=i===``?null:x(i,n);return i!==``&&o===null?{kind:`invalid`,field:`end`}:a===null||o===null?{kind:`partial`}:f(a,o)>0?{kind:`reversed`}:{kind:`range`,start:a,end:o}}var lo=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:e}=this,t=M(`range`);if(e===null)return t;let n=this.readDate(this.core.input.value),r=this.readDate(e.value);return n===null||r===null||f(n,r)>0?t:{mode:`range`,start:n,end:r}}markInvalid(e){let{end:t}=this;if(t===null)return;let{input:n,host:r}=this.core;oo(n,r,e),oo(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;so(t,n),so(e,n),this.deps.describe(t,null),this.deps.describe(e,null)}format(e){return e===null?``:q(e,this.core.options.pattern,`day`)}readDate(e){let{pattern:t}=this.core.options,n=Xn(e,`single`,`day`)??Jn(e,`single`,t,`day`);return n?.mode===`single`?n.date:null}applyMask(e){let{options:t}=this.core;if(!t.mask)return;let n=ce(e.value,t.pattern);n!==e.value&&(e.value=n,e.setSelectionRange(n.length,n.length))}commit(){let{end:e}=this;if(e===null||!this.dirty)return;let{options:t,input:n}=this.core,r=co(n.value,e.value,t.pattern);r.kind!==`partial`&&(r.kind===`empty`?this.settle(M(`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=nn(r,n.limits,i);if(a===null){this.settle(r);return}let o=i(e)===null?`end`:`start`;this.fail(o,`unavailable-date`,vi(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(),oo(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})}},uo=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 lo(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=Wn(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 Xn(r,e,n)??Jn(r,e,t,n)??M(e)}evaluate(e){let{mode:t,pattern:n,limits:r,precision:i}=this.core.options,a=Jn(e,t,n,i);if(a===null)return{kind:`invalid`};if(P(a))return{kind:`empty`};let o=nn(a,r,e=>this.deps.rules.unavailableReason(e));return o===null?{kind:`valid`,selection:a}:{kind:`unavailable`,selection:a,reason:o}}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(e){let{input:t,host:n,instanceId:r}=this.core,{end:i}=this.split,a=()=>{let{pattern:e,precision:t,labels:n}=this.core.options;return Yt(e,t,g(n))},o=[[t,`input-description`]];i!==null&&o.push([i,`end-input-description`]);for(let[e,t]of o){let i=Y(r,t);this.descriptions.set(e,io(e,n,i,a()))}this.core.events.on(`change:options`,()=>{let e=a();this.descriptions.forEach(t=>{t.setHint(e)})},e)}describe(e,t){this.descriptions.get(e)?.setError(t)}applyMask(){let{input:e,options:t}=this.core;if(!t.mask||t.mode!==`single`||t.precision!==`day`)return;let n=ce(e.value,t.pattern);n!==e.value&&(e.value=n,e.setSelectionRange(n.length,n.length))}commit(){let e=this.core.input.value,t=this.evaluate(e);if(t.kind===`empty`)this.clearError(),this.deps.onTyped(M(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=vi(n,this.core.options);this.showError(r),this.emitter.emit(`error`,{code:`unavailable-date`,message:r,input:e,reason:n})}}showError(e){oo(this.core.input,this.core.host,e),this.describe(this.core.input,e)}clearError(){so(this.core.input,this.core.host),this.describe(this.core.input,null)}};const fo=`dp-ui__container`,po=/\s+/;function mo(e){return e.split(po).filter(e=>e!==``)}var ho=class{core;tokens=[];constructor(e){this.core=e}applyHost(){this.core.host.setAttribute(`data-theme`,this.core.options.theme)}applyTo(e){let{options:t,input:n}=this.core;e.setAttribute(`data-theme`,t.theme),e.setAttribute(`data-color-scheme`,t.colorScheme===`auto`?ie(this.core.host):t.colorScheme),e.classList.remove(...this.tokens),this.tokens=mo(t.cssClass),e.classList.add(...this.tokens),(e.classList.contains(fo)?e:e.querySelector(`.${fo}`))?.classList.toggle(`dp-ui__container--rtl`,getComputedStyle(n).direction===`rtl`)}destroy(){this.core.host.removeAttribute(`data-theme`),this.tokens=[]}};const go=(e,t,n,r)=>{let i=N(e);return i.length===0?``:e.mode===`multiple`?nr(n,i.length,t):i.map(e=>Be(e,r,t,`long`)).join(Vn)},_o=`dp-ui__input--active`;var vo=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=go(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(_o),this.core.endInput?.classList.remove(_o)}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(_o);return}let n=this.expanded?this.core.activeEnd:null;t.classList.toggle(_o,n===`start`),e.classList.toggle(_o,n===`end`)}request(e,t,n=this.core.input){n.disabled||this.deps.open(e,t)}bindToggle(e){let t=O(this.core.options.toggleButton,this.core.host);if(t===null)return;let n=/* @__PURE__ */ new Map,r=(e,r)=>{n.has(e)||n.set(e,t.getAttribute(e)),t.setAttribute(e,r)};r(`aria-haspopup`,`dialog`),t.tagName!==`BUTTON`&&(r(`role`,`button`),r(`tabindex`,`0`),t.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.request(`toggle`,`start`))},{signal:e})),t.addEventListener(`click`,()=>{this.request(`toggle`,`start`)},{signal:e}),this.toggle=t,r(`aria-expanded`,String(this.expanded)),r(`aria-label`,this.core.options.labels.openCalendar),this.updateLabel();let i=()=>{e.removeEventListener(`abort`,i),n.forEach((e,n)=>{e===null?t.removeAttribute(n):t.setAttribute(n,e)}),this.toggle===t&&(this.toggle=null),this.release===i&&(this.release=null)};this.release=i,e.addEventListener(`abort`,i,{once:!0})}releaseToggle(){this.release?.()}};function Q(e){return e.year*12+e.month-1}var yo=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(e){let t=u(e),n=m(e.year,e.month,1),r=m(e.year,e.month,t);if(n===null||r===null)return!0;let{minDate:i,maxDate:a}=this.core.options,o=this.yearBounds();if(e.year<o.min||e.year>o.max||i!==null&&f(r,i)<0||a!==null&&f(n,a)>0)return!0;for(let n=1;n<=t;n+=1)if(this.dayReason({year:e.year,month:e.month,day:n})===null)return!1;return!0}yearBounds(){let{minDate:e,maxDate:t,yearRange:n}=this.core.options,r=o(),i=r.year-n.before,a=r.year+n.after;return{min:e===null?i:Math.max(i,e.year),max:t===null?a:Math.min(a,t.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(e){let{minDate:t,maxDate:n}=this.core.options,r=this.yearBounds();if(t!==null&&f(e,t)<0||e.year<r.min)return`min`;if(n!==null&&f(e,n)>0||e.year>r.max)return`max`;let i=this.getLists(),o=v(e);return i.disabled.has(o)||i.enabled!==null&&!i.enabled.has(o)?`disabled`:i.source.disabledWeekdays.includes(a(e))?`weekday`:this.isCallbackDisabled(e,i)?`disabled`:null}isCallbackDisabled(e,t){let{isDateDisabled:n}=t.source;if(n===null)return!1;let r=v(e),i=t.callbackResults.get(r);if(i!==void 0)return i;let a=!1;try{a=n(s(e))}catch(e){j(e)}return t.callbackResults.set(r,a),a}guardFor(e){let t=this.getLists(),n=t.guardDraft;if(t.guard!==null&&n!==null&&ve(n,e))return t.guard;let{maxDate:r,limits:i}=t.source,a={year:this.yearBounds().max,month:12,day:31};r!==null&&f(r,a)<0&&(a=r);let o=$t(e,i,e=>this.isDisabled(e),a);return t.guardDraft=e,t.guard=o,o}getLists(){let e=this.core.options;if(this.lists?.source===e)return this.lists;let t={source:e,disabled:new Set(e.disabledDates.map(v)),enabled:e.enabledDates===null?null:new Set(e.enabledDates.map(v)),callbackResults:/* @__PURE__ */ new Map,guardDraft:null,guard:null};return this.lists=t,t}},bo=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}},xo=class{validation;theme;display;input;triggers;form;relay=new bo;constructor(e,t){this.validation=new yo(e,t),this.theme=new ho(e),this.display=new eo(e,t,{actions:this.relay,rules:this.validation,theme:this.theme}),this.input=new uo(e,t,{rules:this.validation,onTyped:this.relay.typed}),this.triggers=new vo(e,t,{open:this.relay.open}),this.form=new to(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,So=()=>void 0;var Co=class{core;emitter;lifecycle;constructor(e,t){let n=Lt(e);this.emitter=new me,this.core=new jt(n.input,n.host,n.createdHost,t),this.lifecycle=new Mn(this.core,this.emitter,new xo(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?So:this.emitter.on(e,t)}once(e,t){return this.lifecycle.destroyed?So: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(kt(e))}static getAllInstances(){return[...$.values()]}static destroyAll(){for(let e of[...$.values()])e.destroy()}},wo=Co;export{H as DEFAULT_DATEPICKER_OPTIONS,Co as DatepickerUI,me as EventEmitter,wo as default};
|
|
1
|
+
import{$ as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,Ft as f,G as p,H as m,Ht as h,I as g,It as _,J as v,K as y,L as b,Lt as x,M as ee,Mt as S,N as C,Nt as w,O as T,Ot as E,P as te,Pt as D,Q as O,R as k,Rt as A,S as j,Tt as ne,Ut as re,V as ie,Vt as ae,W as oe,X as se,Y as ce,Z as le,_ as ue,_t as de,at as fe,b as pe,bt as M,ct as me,d as he,dt as N,et as ge,f as P,ft as _e,g as F,gt as I,h as ve,ht as ye,i as be,it as xe,j as Se,jt as Ce,k as we,kt as L,lt as R,m as Te,mt as Ee,n as De,nt as Oe,o as ke,ot as Ae,p as je,pt as z,q as Me,r as Ne,rt as Pe,s as Fe,st as Ie,t as Le,tt as Re,ut as B,v as V,vt as ze,w as Be,wt as Ve,x as He,xt as H,y as Ue,yt as We,z as Ge,zt as Ke}from"./shared.js";function U(e){queueMicrotask(()=>{throw e})}var qe=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,t){let n=this.store[e];if(!n)return;let r=[];for(let e of[...n])if(n.has(e))try{e.handler(t)}catch(e){r.push(e)}r.length>0&&U(r[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 Je(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 W={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`},G={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:W,behavior:{closeOnSelect:!1,closeOnCancel:!0,commitOnChange:!1,ignoreOutsideClick:!1,returnFocus:!0}};function Ye(e,t){if(z(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 de(e).map(t)}}function Xe(e,t){if(e===`today`)return Ge(h(),t);if(typeof e==`string`)return r(e,t);if(e instanceof Date){let n=ae(e);return n===null?null:Ge(n,t)}return null}function Ze(e){if(!(`start`in e&&`end`in e))return null;let t=Xe(e.start,`day`),r=Xe(e.end,`day`);return t===null||r===null||n(t,r)>0?null:{mode:`range`,start:t,end:r}}function Qe(e){let t=[];for(let n of e){let e=Xe(n,`day`);if(e===null)return null;t.push(e)}return{mode:`multiple`,dates:ze(t)}}function K(e,t,n){if(e===null)return B(t);if(t===`multiple`)return Array.isArray(e)?Qe(e):null;if(t===`single`){let r=Xe(e,n);return r===null?null:{mode:t,date:r}}return typeof e==`object`&&!Array.isArray(e)&&!(e instanceof Date)?Ze(e):null}function $e(e,t){return e instanceof Date?e:typeof e!=`string`||e===`today`&&!t?null:e}function et(e,t,n,r){if(e===void 0)return null;let i=$e(e,t),a=i===null?null:ae(i);return a===null&&r.push({option:n,value:e}),a}function tt(e,t,n,r){return e==null?null:K(e,t,n)===null?(r.push({option:`calendar.defaultValue`,value:e}),null):()=>K(e,t,n)}function nt(e,t,n){return e===void 0?null:Array.isArray(e)?e.map(e=>et(e,!1,t,n)).filter(e=>e!==null):(n.push({option:t,value:e}),null)}function q(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 J=e=>typeof e==`boolean`?e:void 0,rt=e=>typeof e==`string`?e:void 0,it=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,at=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1?e:void 0,ot=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},st=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},ct=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},lt=e=>typeof HTMLElement<`u`&&e instanceof HTMLElement||typeof e==`string`&&e.length>0?e:void 0;function Y(e){return t=>e.find(e=>e===t)}function ut(e){return t=>typeof t==`string`&&Ie(t,e)?t:void 0}const dt=Y([`auto`,`docked`,`modal`]),ft=Y([`auto`,`light`,`dark`]),pt=Y([`auto`,`sunday`,`monday`,`saturday`]),mt=Y([`single`,`range`,`multiple`]),ht=Y([`calendar`,`input`]),gt=Y([`day`,`month`,`year`]),_t=Y([`month`,`view`]),vt=Y([`day`,`month`,`year`]),yt=Y([`auto`,`docked`,`modal`,`fullscreen`]),bt=Y([`menus`,`caption`]),xt=Y([`basic`,`m3-green`,`crane`,`crane-straight`,`m2`,`glassmorphic`,`pastel`,`ai`,`cyberpunk`,`blueprint`]);function St(e){return e in W}function Ct(e,t){let n={...W};for(let r of Object.keys(W))St(r)&&r!==`multipleSelected`&&(n[r]=q(e?.[r],rt,W[r],`labels.${r}`,t));return n.multipleSelected=q(e?.multipleSelected,ct,W.multipleSelected,`labels.multipleSelected`,t),n}function wt(e,t){return e===void 0||e===!0?600:e===!1?0:q(e,at,600,`ui.fullscreen`,t)}function Tt(e,t){return e===void 0||e===!1?!1:e===!0?{selectable:!0}:typeof e==`object`&&e?{selectable:q(Reflect.get(e,`selectable`),J,!0,`ui.outsideDays.selectable`,t)}:(t.push({option:`ui.outsideDays`,value:e}),!1)}function Et(e,t){return e===void 0||e===!1?!1:e===!0?{clearInput:!0}:typeof e==`object`&&e?{clearInput:q(Reflect.get(e,`clearInput`),J,!0,`ui.clearButton.clearInput`,t)}:(t.push({option:`ui.clearButton`,value:e}),!1)}const Dt=`calendar.range.presets`;function Ot(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 kt(e,t){if(e===void 0)return G.calendar.presets;if(!Array.isArray(e))return t.push({option:Dt,value:e}),G.calendar.presets;let n=e,r=[];for(let e of n){let n=Ot(e);n===null?t.push({option:Dt,value:e}):r.push(n)}return r}function At(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6}function jt(e,t){let n=e?.trim();n&&!O(n)&&t.push({option:`calendar.locale`,value:e})}function Mt(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)At(e)?r.includes(e)||r.push(e):t.push({option:`calendar.disabledWeekdays`,value:e});return r}function Nt(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 Pt(e){return typeof e==`string`||typeof Node<`u`&&e instanceof Node?e:null}function Ft(e){return e===null?null:t=>{try{return Pt(e(t))}catch(e){return U(e),null}}}function It(e){return e===null?null:t=>{try{let n=e(t);return typeof n!=`string`||n.length===0?null:n}catch(e){return U(e),null}}}function Lt(e,t,n){let r=G.calendar,i=q(e,gt,r.precision,`calendar.precision`,n);return i!==`day`&&t!==`single`?(n.push({option:`calendar.precision`,value:e}),r.precision):i}function Rt(e,t){let n=q(e?.range?.minLength,at,null,`calendar.range.minLength`,t),r=q(e?.range?.maxLength,at,null,`calendar.range.maxLength`,t),i=q(e?.multiple?.max,at,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 zt(e,t){let n=G.calendar;jt(e?.locale,t);let r=ge(e?.locale),i=q(e?.weekStart,pt,n.weekStart,`calendar.weekStart`,t),a=q(e?.isDateDisabled,ot,null,`calendar.isDateDisabled`,t),o=q(e?.decorateDate,ot,null,`calendar.decorateDate`,t),s=q(e?.renderDate,ot,null,`calendar.renderDate`,t),c=q(e?.validate,st,null,`calendar.validate`,t),l=q(e?.mode,mt,n.mode,`calendar.mode`,t),u=Lt(e?.precision,l,t);return{locale:r,weekStart:Re(r,i),minDate:et(e?.minDate,!0,`calendar.minDate`,t),maxDate:et(e?.maxDate,!0,`calendar.maxDate`,t),disabledDates:nt(e?.disabledDates,`calendar.disabledDates`,t)??[],enabledDates:nt(e?.enabledDates,`calendar.enabledDates`,t),mode:l,precision:u,defaultValue:tt(e?.defaultValue,l,u,t),months:q(e?.months,at,n.months,`calendar.months`,t),pageBy:q(e?.pageBy,_t,n.pageBy,`calendar.pageBy`,t),limits:Rt(e,t),presets:kt(e?.range?.presets,t),isDateDisabled:a===null?null:e=>!!a(e),disabledWeekdays:Mt(e?.disabledWeekdays,t),decorateDate:o===null?null:e=>Nt(o(e)),renderDate:Ft(s),validate:It(c)}}function Bt(e){let t=[],n=G,r=e?.calendar,i=e?.ui,a=e?.behavior,o=(e,n,r,i)=>q(e,n,r,i,t),s=zt(r,t),{locale:c,precision:l}=s,u=o(i?.format,ut(l),n.ui.format,`ui.format`),d=o(i?.footer,J,!1,`ui.footer`),f=a?.id;return{...s,displayMode:o(i?.displayMode,dt,n.ui.displayMode,`ui.displayMode`),layout:o(i?.layout,yt,n.ui.layout,`ui.layout`),inline:{enabled:o(i?.inline?.enabled,J,n.ui.inline.enabled,`ui.inline.enabled`),container:o(i?.inline?.container,lt,null,`ui.inline.container`),headline:o(i?.inline?.headline,J,n.ui.inline.headline,`ui.inline.headline`),navigation:o(i?.inline?.navigation,bt,n.ui.inline.navigation,`ui.inline.navigation`),announceSelection:o(i?.inline?.announceSelection,J,n.ui.inline.announceSelection,`ui.inline.announceSelection`)},pattern:me(u,c,l),theme:o(i?.theme,xt,n.ui.theme,`ui.theme`),colorScheme:o(i?.colorScheme,ft,n.ui.colorScheme,`ui.colorScheme`),toggleButton:o(i?.toggleButton,lt,null,`ui.toggleButton`),endInput:o(i?.endInput,lt,null,`ui.endInput`),weekNumbers:o(i?.weekNumbers,J,n.ui.weekNumbers,`ui.weekNumbers`),outsideDays:Tt(i?.outsideDays,t),fixedWeeks:o(i?.fixedWeeks,J,n.ui.fixedWeeks,`ui.fixedWeeks`),yearRange:{before:o(i?.yearRange?.before,it,n.ui.yearRange.before,`ui.yearRange.before`),after:o(i?.yearRange?.after,it,n.ui.yearRange.after,`ui.yearRange.after`)},todayButton:o(i?.todayButton,J,n.ui.todayButton,`ui.todayButton`),clearButton:Et(i?.clearButton,t),footerExplicit:typeof i?.footer==`boolean`?d:null,animation:o(i?.animation,J,n.ui.animation,`ui.animation`),allowPageScroll:o(i?.allowPageScroll,J,n.ui.allowPageScroll,`ui.allowPageScroll`),fullscreenBelow:wt(i?.fullscreen,t),cssClass:o(i?.cssClass,rt,n.ui.cssClass,`ui.cssClass`),appendTo:o(i?.appendTo,lt,null,`ui.appendTo`),swipe:o(i?.swipe,J,n.ui.swipe,`ui.swipe`),viewSwitch:o(i?.viewSwitch,J,n.ui.viewSwitch,`ui.viewSwitch`),initialView:o(i?.initialView,ht,n.ui.initialView,`ui.initialView`),mask:o(i?.mask,J,n.ui.mask,`ui.mask`),startView:o(i?.startView,vt,n.ui.startView,`ui.startView`),labels:Ct(e?.labels,t),behavior:{closeOnSelect:o(a?.closeOnSelect,J,n.behavior.closeOnSelect,`behavior.closeOnSelect`),closeOnCancel:o(a?.closeOnCancel,J,n.behavior.closeOnCancel,`behavior.closeOnCancel`),commitOnChange:o(a?.commitOnChange,J,n.behavior.commitOnChange,`behavior.commitOnChange`),ignoreOutsideClick:o(a?.ignoreOutsideClick,J,n.behavior.ignoreOutsideClick,`behavior.ignoreOutsideClick`),returnFocus:o(a?.returnFocus,J,n.behavior.returnFocus,`behavior.returnFocus`),id:typeof f==`string`&&f.length>0?f:null},callbacks:{...e?.callbacks},issues:t}}const Vt=/[^\w-]/g;let Ht=0;function Ut(e){return e.replace(Vt,`-`)}function Wt(e){return{year:e.year,month:e.month}}var Gt=class{input;host;createdHost;instanceId;events=new qe;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(e,t,n,r){this.input=e,this.host=t,this.createdHost=n,this.raw=Je({},r??{}),this.resolved=Bt(this.raw),Ht+=1;let i=this.resolved.behavior.id;this.instanceId=i===null?`${re}${String(Ht)}`:Ut(i),this.currentPanel=M(this.resolved.precision),this.currentValue=B(this.resolved.mode),this.currentDraft=this.currentValue;let a=h();this.currentFocus=a,this.currentView=Wt(a)}get options(){return this.resolved}get rawOptions(){return this.raw}setOptions(e){this.raw=Je(this.raw,e),this.resolved=Bt(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=Wt(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 e=R(this.currentValue)??h(),t=Wt(e);this.currentListSpan=null,this.setPanel(M(this.resolved.precision)),this.setDraft(this.currentValue),this.setView(t,A(this.currentView,t),`api`),this.setFocus(e)}};const Kt=`dp-ui`,qt=[`class`,`name`,`aria-invalid`,`aria-describedby`];function Jt(e){return typeof e==`string`?document.querySelector(e):e}function Yt(e){return e instanceof HTMLInputElement?e:e?.querySelector(`input`)??null}function Xt(e){let t=document.createElement(`div`);return t.className=Kt,e.before(t),t.append(e),t}function Zt(e){if(!Pe())throw Error(`DatepickerUI needs a document`);let t=Jt(e),n=Yt(t);if(n===null)throw Error(`DatepickerUI could not find an input element`);let r=n.parentElement;return r!==null&&(t!==n||r.classList.contains(Kt))?{input:n,host:r,createdHost:!1}:{input:n,host:Xt(n),createdHost:!0}}function Qt(e){let{input:t,host:n,createdHost:r}=e,i=/* @__PURE__ */ new Map;for(let e of qt)i.set(e,t.getAttribute(e));let a=n.classList.contains(Kt);return n.classList.add(Kt),{target:{input:t,host:n,createdHost:r},hostHadClass:a,inputAttributes:i}}function $t(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(Kt)}function en(e,t,n,r){let i=A(e,t);return i>=0&&i<n?e:r===`month`?i<0?t:L(t,-(n-1)):L(e,Math.floor(i/n)*n)}function tn(e,t){let{core:r,managers:i}=e,{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&&n(a,c)>0?a:c,d=o!==null&&n(o,l)<0?o:l;return n(t,u)<0?u:n(t,d)>0?d:t}function nn(e,t,n){return tn(e,{year:t.year,month:t.month,day:Math.min(n,D(t))})}function rn(e,t,n){let{core:r,managers:i}=e,a=i.validation.clampView(t),o=A(r.view,a);return o!==0&&(r.setView(a,o,n),r.setFocus(nn(e,a,r.focus.day))),a}function X(e,t,n){let{core:r,managers:i}=e,a={year:t.year,month:t.month},{months:o}=r.layout,s=i.validation.clampView(en(r.view,a,o,r.options.pageBy)),c=A(s,a);if(c<0||c>=o)return;let l=A(r.view,s);l!==0&&r.setView(s,l,n),r.setFocus(t)}function an(e,t,n){let r=w(e,t)+1;return n.minLength!==null&&r<n.minLength?!1:n.maxLength===null||r<=n.maxLength}function on(e,t,r,i){let a=i;if(t.maxLength!==null){let r=E(e,t.maxLength-1);a=n(r,i)<0?r:i}for(let t=E(e,1);n(t,a)<=0;t=E(t,1))if(r(t))return t;return null}function sn(e,t,r,i){if(e.mode===`multiple`){let{multipleMax:n}=t,{dates:r}=e;return t=>n!==null&&r.length>=n&&!_e(e,t)}if(e.mode!==`range`||e.start===null||e.end!==null)return()=>!1;let{start:a}=e,o=null,s=!1;return e=>n(e,a)<0?!1:n(e,i)>0||!an(a,e,t)||(s||=(o=on(a,t,r,i),!0),o!==null&&n(e,o)>=0)}function cn(e,t,r,i){if(!an(e,t,r))return`range-length`;for(let r=e;n(r,t)<=0;r=E(r,1)){let e=i(r);if(e!==null)return e}return null}function ln(e,t){for(let n of e){let e=t(n);if(e!==null)return e}return null}function un(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?cn(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`:ln(e.dates,n)}}function dn(e,t,n){return un(e,t,e=>n(e)?`disabled`:null)===null}function fn(e,t,r){return e.some(e=>n(e,t)===0)?e.filter(e=>n(e,t)!==0):r.multipleMax!==null&&e.length>=r.multipleMax?null:ze([...e,t])}function pn(e){return e.mode===`range`&&e.start!==null&&e.end===null?`end`:`start`}function mn(e,t){return e.mode===`range`?t===`start`?{mode:`range`,start:null,end:null}:{mode:`range`,start:e.start,end:null}:e}function hn(e,t,r,i){switch(e.mode){case`single`:return{mode:`single`,date:t};case`range`:return i===`start`||e.start===null||n(t,e.start)<0?{mode:`range`,start:t,end:null}:{mode:`range`,start:e.start,end:t};default:{let n=fn(e.dates,t,r);return n===null?e:{mode:`multiple`,dates:n}}}}var gn=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=Ge(e,t.options.precision),i=t.followsActiveEnd?t.activeEnd:pn(t.draft);if(!this.session.active||!n.validation.isSelectable(r,mn(t.draft,i)))return;X(this.context,r,`button`);let a=hn(t.draft,r,t.options.limits,i);t.setDraft(a),t.setActiveEnd(pn(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};un(o,a,e=>r.validation.unavailableReason(e))===null&&(n.setDraft(o),n.setActiveEnd(`start`),X(this.context,e,`api`),this.emitRangeEnd(e,t),this.isOpen()&&this.autoCommit(o))}typeDraft(e){if(!this.acceptTyped(e))return;let{commitOnChange:t}=this.context.core.options.behavior;t&&N(e)&&this.values.commit(!0)}submitDraft(){let{core:e}=this.context,t=e.draft,n=e.options.behavior.closeOnSelect&&t.mode!==`multiple`;this.session.active&&n&&N(t)&&(I(e.value,t)||this.values.commit(!0),this.session.close())}acceptTyped(e){let{core:t,managers:n}=this.context,{mode:r,limits:i}=t.options,a=e.mode===r&&dn(e,i,e=>n.validation.isDisabled(e));if(!this.session.active||!a||I(t.draft,e))return!1;t.setDraft(e);let o=R(e);return o!==null&&X(this.context,o,`api`),this.announceTyped(e),!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(e,t){let{emitter:n}=this.context,{describe:r}=this.values;n.emit(`select:day`,{value:r(t),selected:_e(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()}},_n=class{context;session;values;selector;constructor(e,t,n){this.context=e,this.session=t,this.values=n,this.selector=new gn(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&&X(this.context,e,`keyboard`)}navigate(e,t){this.session.active&&rn(this.context,L(this.context.core.view,e),t)}page(e,t){let{core:n}=this.context,r=n.options.pageBy===`view`?n.layout.months:1;this.navigate(e*r,t)}jumpTo(e,t){if(!this.session.active)return;let{core:n}=this.context,r=n.panel,i=rn(this.context,e,t);t===`menu`&&(n.setPanel(M(n.options.precision)),this.announcePick(r,i))}showPanel(e){this.session.active&&this.context.core.setPanel(e)}confirm(){this.session.active&&N(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:e,managers:t}=this.context,n=h();t.validation.isSelectable(n,e.draft)?this.select(n):X(this.context,n,`button`)}clear(){if(!this.session.active)return;let{core:e}=this.context,{clearButton:t}=e.options,n=t!==!1&&t.clearInput,r=this.values.clearedSelection(n);r!==null&&(this.values.emitClear(r),!this.isOpen())||(e.setDraft(B(e.options.mode)),n&&(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})}},vn=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 yn=[`class`,`name`,`aria-invalid`];function bn(e){let{core:t,emitter:n}=e,{endInput:r,mode:i}=t.options;if(i!==`range`||r===null)return null;let a=g(r,t.host);return a instanceof HTMLInputElement&&a!==t.input?a:(n.emit(`error`,{code:`invalid-option`,message:`ui.endInput does not match an input element`,option:`ui.endInput`}),null)}function xn(e){let t=/* @__PURE__ */ new Map;for(let n of yn)t.set(n,e.getAttribute(n));return()=>{for(let[n,r]of t)r===null?e.removeAttribute(n):e.setAttribute(n,r)}}const Sn=[`calendar`,`ui`,`labels`,`behavior`,`callbacks`];function Cn(e){let t=[];for(let n of Sn){let r=e[n];if(r!==void 0)for(let e of Object.keys(r))t.push(`${n}.${e}`)}return t}function wn(e,t){return e.some(e=>t.option===e||t.option.startsWith(`${e}.`))}function Tn(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 En=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=B(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(),z(n.value)||r.input.write(n.value),r.triggers.updateLabel(),this.refreshSurface(e);let i=Cn(t);Tn(this.context,n.options.issues.filter(e=>wn(i,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`)}},Dn=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=Qt(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=bn(this.context);e.setEndInput(i),i!==null&&(this.restoreEndInput=xn(i));let a=this.initialSelection();e.setValue(a),z(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(),Tn(this.context,e.options.issues)}initialSelection(){let{core:e,managers:t}=this.context;if(!z(e.value))return e.value;let n=t.input.readInitial();return z(n)?e.options.defaultValue?.()??n:n}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),$t(this.hostSnapshot),t.events.clear(),n.clear())}},On=class{tail=Promise.resolve();pending=0;stopped=!1;run(e){let t=async()=>{this.stopped||await e()},n=this.pending===0?t():this.tail.then(t);this.pending+=1;let r=n.catch(U).finally(()=>{--this.pending});return this.tail=r,r}stop(){this.stopped=!0}},kn=class{context;views;visible;queue=new On;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:e,emitter:t}=this.context;g(e.options.inline.container)===null?t.emit(`error`,{code:`invalid-option`,message:`ui.inline.container does not match an element`,option:`ui.inline.container`}):(this.begin(`inline`),t.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(e){let{core:t}=this.context,n=t.options,r=window.innerWidth;if(e===`inline`){let e=g(n.inline.container)?.clientWidth??0;r=e>0?e:r}t.setLayout(Ve({months:n.months,precision:n.precision,mode:n.mode,layout:t.calendarLayout,width:r,weekNumbers:n.weekNumbers,presets:n.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:e}=this.context.core.options;return o(e,!1,window.innerWidth,window.innerHeight)}clampView(){rn(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(e){let{core:t}=this.context;t.setCalendarLayout(We(e,t.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})}},An=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 jn=[`start`,`end`];var Mn=class{context;session;visible;constructor(e,t,n){this.context=e,this.session=t,this.visible=n}describe=e=>{let{pattern:t,precision:n}=this.context.core.options;return{value:m(e,n),date:Ke(e),formatted:k(e,t,n)}};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=K(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(e){let{core:t,managers:n}=this.context,{mode:r,precision:i,limits:a}=t.options,o=K(e,r===`single`||typeof e==`string`||e instanceof Date?`single`:r,i);return o===null||z(o)?!1:dn(o,a,e=>n.validation.isDisabled(e))}clear(){let{core:e,managers:t,status:n}=this.context,r=this.clearedSelection(!0);if(n.destroyed||r===null)return;let i=B(e.options.mode);e.setValue(i),this.session.active&&e.setDraft(i),t.input.write(i),n.created&&(t.form.sync(),t.form.dispatchCommit()),this.emitClear(r),this.validate(i)}clearedSelection(e){let{core:t}=this.context;return e&&!z(t.value)?t.value:this.session.active&&!z(t.draft)?t.draft:null}emitClear(e){this.context.emitter.emit(`clear`,{previousValue:this.present(e)})}setActiveEnd(e){let{core:t,status:n}=this.context,r=jn;!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=!I(t.value,e),a=I(t.draft,e);t.setValue(e),r.form.sync(),(i||!a)&&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 Ye(e,this.describe)}follow(){if(!this.session.active)return;let{core:e}=this.context,t=e.value;e.setDraft(t);let n=R(t);n!==null&&this.visible.hold(`api`,()=>{X(this.context,n,`api`)})}};const Nn=e=>e===`input`?`input`:`calendar`;var Pn=class{context;isShown;visible;constructor(e,t,n){this.context=e,this.isShown=t,this.visible=n}get(){return this.isShown()?Nn(this.context.core.panel):`calendar`}set(e){let{core:t}=this.context;this.isShown()&&this.hasInputView()&&t.setPanel(e===`input`?`input`:M(t.options.precision))}goTo(e){let t=K(e,`single`,`day`),n=t===null?null:R(t);n===null?this.context.emitter.emit(`error`,{code:`invalid-date`,message:`goTo() received a value that is not a valid date`,input:typeof e==`string`?e:void 0}):this.isShown()&&this.visible.hold(`api`,()=>{X(this.context,tn(this.context,n),`api`)})}bind(e){let{core:t,emitter:n}=this.context,r=Nn(t.panel);t.events.on(`change:panel`,({panel:e})=>{let t=Nn(e);t!==r&&(r=t,n.emit(`switch:view`,{view:t}))},e)}opening(e){let{core:t}=this.context,{initialView:n,inline:r,mode:i,precision:a,startView:o}=t.options;if(n===`input`&&this.hasInputView())return`input`;let s=H(e,r).navigation===`caption`;return a!==`day`||i===`range`||s?M(a):u(o,t.calendarLayout)}dropUnsupported(){let{core:e}=this.context;e.panel===`input`&&!this.hasInputView()&&e.setPanel(M(e.options.precision))}hasInputView(){let{core:e}=this.context,{mode:t,precision:n}=e.options;return c(t,e.calendarLayout,n)}};const Fn=(e,t)=>({from:{year:e.year,month:e.month,day:1},to:{year:t.year,month:t.month,day:D(t)}}),In=(e,t,n)=>{let r={year:e.year,month:e.month,day:1},i=(S(r)-t+7)%7,a=n?6:Math.ceil((i+D(e))/7),o=E(r,-i);return{from:o,to:E(o,a*7-1)}},Ln=e=>{let t=e.layout===`docked`&&e.months<=1&&e.outsideDays;return{outsideDays:t,fixedWeeks:e.layout!==`docked`&&!e.inline||t||e.fixedWeeks}},Rn=e=>{let{view:t,listSpan:n,yearBounds:r}=e;return n===null?e.precision===`year`?Fn({year:r.min,month:1},{year:r.max,month:12}):e.precision===`month`?Fn({year:t.year,month:1},{year:t.year,month:12}):e.months>1?Fn(t,L(t,e.months-1)):e.outsideDays?In(t,e.weekStart,e.fixedWeeks):Fn(t,t):Fn(n.first,n.last)};function zn(e){return e<0?-1:+(e>0)}var Bn=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(e){if(!this.live)return;let{core:t,emitter:n}=this.context,{from:r,to:a}=this.compute(),o={view:t.view,from:i(r),to:i(a)},s=this.last;if(s?.from===o.from&&s.to===o.to)return;this.last=o;let c=s===null?0:A(s.view,o.view);n.emit(`navigate`,{year:o.view.year,month:o.view.month,direction:zn(c),source:e,from:this.describe(r),to:this.describe(a)})}compute(){let{core:e,managers:t}=this.context,{options:n,layout:r}=e,i=Ln({layout:e.calendarLayout,inline:e.mode===`inline`,months:r.months,outsideDays:n.mode!==`range`&&n.outsideDays!==!1,fixedWeeks:n.fixedWeeks});return Rn({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(e){return{value:i(e),date:Ke(e),formatted:k(e,this.context.core.options.pattern,`day`)}}},Vn=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 vn(r),a=new An(r),o=()=>this.session.active;this.visible=new Bn(r,o),this.views=new Pn(r,o,this.visible),this.session=new kn(r,this.views,this.visible),this.values=new Mn(r,this.session,this.visible),this.actions=new _n(r,this.session,this.values),this.instance=new Dn(r,this.session,i,a),this.updates=new En(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 Hn=e=>e.toLowerCase().replace(/_/g,`-`);function Un(e,t){Object.entries(T).forEach(([n,r])=>{e.style.setProperty(`--dp-ui-motion-${Hn(n)}`,`${String(t?r:0)}ms`)}),Object.entries(l).forEach(([t,n])=>{e.style.setProperty(`--dp-ui-easing-${Hn(t)}`,n)})}function Wn(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 Gn=/* @__PURE__ */ new Map,Kn=/* @__PURE__ */ new Map;function qn(e){let t=Gn.get(e);if(t)return t;let n=new Intl.PluralRules(e);return Gn.set(e,n),n}function Jn(e){let t=Kn.get(e);if(t)return t;let n=new Intl.NumberFormat(e);return Kn.set(e,n),n}function Yn(e,t,n){return(typeof e==`string`?e:e[qn(n).select(t)]??e.other??Object.values(e).at(0)??``).replaceAll(`{count}`,Jn(n).format(t))}function Xn(e,t,n,r,i){switch(e.mode){case`single`:return e.date?ce(e.date,i,n,`headline`):r.noDate;case`range`:{if(t===`input`&&e.start&&e.end)return le(e.start,e.end,n);let i=e.start?se(e.start,n):r.rangeStart,a=e.end?se(e.end,n):r.rangeEnd;return`${i}${pe}${a}`}default:return e.dates.length===0?r.noDate:Yn(r.multipleSelected,e.dates.length,n)}}const Zn=`dp-ui--ripple-pressed`,Qn=`dp-ui--ripple-active`,$n=e=>e.getAttribute(`aria-disabled`)===`true`||e instanceof HTMLButtonElement&&e.disabled;function er(e,t,n){let r=e=>e instanceof Element?e.closest(t):null,i=e=>{r(e.target)?.classList.remove(Zn)};e.addEventListener(`pointerdown`,t=>{let a=r(t.target);if(!a||!e.contains(a)||$n(a)||t.pointerType===`mouse`&&t.button!==0)return;a.classList.remove(Qn);let{left:o,top:s,width:c,height:l}=a.getBoundingClientRect();a.style.setProperty(`--dp-ui-ripple-x`,`${String(t.clientX-o)}px`),a.style.setProperty(`--dp-ui-ripple-y`,`${String(t.clientY-s)}px`),a.style.setProperty(`--dp-ui-ripple-size`,`${String(Math.max(c,l)*2)}px`),a.style.setProperty(`--dp-ui-ripple-duration`,`${String(T.RIPPLE)}ms`),a.classList.add(Zn),a.addEventListener(`pointerleave`,i,{once:!0,signal:n}),C()||(requestAnimationFrame(()=>{a.classList.add(Qn)}),window.setTimeout(()=>{a.classList.remove(Qn)},T.RIPPLE))},{signal:n}),e.addEventListener(`pointerup`,i,{signal:n}),e.addEventListener(`pointercancel`,i,{signal:n})}const tr=(e,t)=>{e.querySelectorAll(`.dp-ui__text-button--confirm, .dp-ui__text-button--save`).forEach(e=>{e.disabled=!t})},nr=e=>{let{labels:t}=e,n=d(`div`,`dp-ui__actions`);n.hidden=!e.visible;let r=d(`div`,`dp-ui__actions-start`);e.todayButton&&r.append(ve(`today`,t.today)),e.clearButton&&r.append(ve(`clear`,t.clear));let i=d(`div`,`dp-ui__actions-end`);return i.append(ve(`cancel`,t.cancel),ve(`confirm`,t.confirm)),n.append(r,i),n},rr=[[`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`}]],ir=e=>rr.find(([t])=>e.classList.contains(t)),ar=e=>ir(e)?.[0]??null,or=(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()}},sr=(e,t,n)=>{e.addEventListener(`click`,e=>{let{target:t}=e,r=t instanceof Element?t.closest(`button`):null;if(r!==null){let e=ir(r);e&&or(e[1],n);return}let i=n.cellAt(t);i!==null&&n.actions.select(i.date)},{signal:t})},cr=`dp-ui__container--menu-open`,lr=`dp-ui__container--input`,ur=`--dp-ui-visible-months`,dr=e=>e.closest(`.dp-ui__container`),fr=(e,t)=>e!==t&&e!==`days`&&e!==`input`,pr=(e,t)=>{let n=t>1;e.classList.toggle(`dp-ui__container--multi-month`,n),n?e.style.setProperty(ur,String(t)):e.style.removeProperty(ur)},mr=(e,t,n)=>{let r=t===`input`;e.classList.toggle(lr,r),pr(e,r?1:n)},hr=e=>{let{locale:t,labels:n}=e,r=ue(n),i=d(`div`,`dp-ui__navigation dp-ui__navigation--caption`),a=d(`span`,`dp-ui__caption`);a.hidden=e.arrowsOnly,i.append(a,P(`prev-month`,n.previousMonth,V.keyboardArrowLeft,r.previousMonth),P(`next-month`,n.nextMonth,V.keyboardArrowRight,r.nextMonth));let o=e=>{a.textContent=Me(e,t)};return o(e.view),{element:i,setView:o}},gr=(e,t)=>{let n=d(`div`,`dp-ui__navigation-group dp-ui__navigation-group--${e}`);return n.append(...t),n},_r=t=>{let{labels:n}=t,r=ue(n),i=e(t.locale,`short`),a=e(t.locale,`long`),o=je(`month`,``,{name:n.chooseMonth,controls:F(t.instanceId,`month-menu`),shortcut:r.chooseMonth}),s=je(`year`,``,{name:n.chooseYear,controls:F(t.instanceId,`year-menu`),shortcut:r.chooseYear}),c=d(`div`,`dp-ui__header dp-ui__header--docked`),l=gr(`month`,[P(`prev-month`,n.previousMonth,V.keyboardArrowLeft,r.previousMonth),o.button,P(`next-month`,n.nextMonth,V.keyboardArrowRight,r.nextMonth)]);l.hidden=t.groups!==`both`,c.hidden=t.groups===`none`,c.append(l,gr(`year`,[P(`prev-year`,n.previousYear,V.keyboardArrowLeft,r.previousYear),s.button,P(`next-year`,n.nextYear,V.keyboardArrowRight,r.nextYear)]));let u=e=>{o.setText(i[e.month-1]??``,a[e.month-1]??``),s.setText(v(e.year,t.locale))},f=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),f(t.home),{element:c,setView:u,setPanel:f}},vr=`dp-ui__headline--fading-out`,yr=(e,t)=>{let n=d(`div`,`dp-ui__headline`);n.textContent=e;let r=null,i=null,a=()=>{i!==null&&clearTimeout(i),i=null,r=null,n.classList.remove(vr)},o=()=>{let e=r;a(),e!==null&&(n.textContent=e)};return{element:n,setText:e=>{e!==(r??n.textContent)&&(t?(r=e,n.classList.add(vr),i??=setTimeout(o,T.HEADLINE_FADE)):(a(),n.textContent=e))},destroy:a}},br=e=>{let{labels:t,switchView:n}=e,r=d(`div`,`dp-ui__header dp-ui__header--modal`),i=d(`div`,`dp-ui__supporting-text`);i.textContent=e.title;let a=yr(e.text,e.animate);r.append(i,a.element);let o=n===null?null:Te(t,n.panelId);return o!==null&&r.append(o.button),{element:r,setText:e=>{a.setText(e)},setInputView:e=>{o?.setInputView(e)},destroy:()=>{a.destroy()}}},xr=(e,t,n,r,i)=>{if(i)return hr({locale:t,labels:n,view:e,arrowsOnly:!1}).element;let a=ue(n),o=d(`div`,`dp-ui__navigation`);return o.append(je(`year-grid`,Me(e,t),{name:n.chooseYear,controls:F(r,`year-grid`),shortcut:a.chooseYear}).button,P(`prev-month`,n.previousMonth,V.keyboardArrowLeft,a.previousMonth),P(`next-month`,n.nextMonth,V.keyboardArrowRight,a.nextMonth)),o},Sr=(e,t,n,r)=>{let i=d(`div`,`dp-ui__navigation dp-ui__navigation--month-grid`),a=ue(n);return i.append(je(`year-grid`,v(e.year,t),{name:n.chooseYear,controls:F(r,`year-grid`),shortcut:a.chooseYear}).button,P(`prev-year`,n.previousYear,V.keyboardArrowLeft,a.previousYear),P(`next-year`,n.nextYear,V.keyboardArrowRight,a.nextYear)),i},Cr=(e,t,n,r)=>{let i=d(`div`,`dp-ui__navigation dp-ui__navigation--year-grid`),{button:a}=je(`year-grid`,Me(e,t),{name:n.chooseYear,controls:F(r,`year-grid`)});return a.setAttribute(`aria-expanded`,`true`),i.append(a),i},wr=e=>{let{decorateDate:t}=e.options;return t===null?()=>null:e=>{try{return t(Ke(e))??null}catch(e){return U(e),null}}},Tr=e=>{let{renderDate:t}=e.options;return t===null?()=>null:e=>t(Ke(e))},Er=(e,t,n)=>{let{options:r}=e;return{locale:r.locale,weekStart:r.weekStart,weekNumbers:r.weekNumbers,showOutside:n,outsideSelectable:r.outsideDays!==!1&&r.outsideDays.selectable,labels:{weekNumber:r.labels.weekNumber},rangeLabels:{start:r.labels.rangeStart,end:r.labels.rangeEnd,inRange:r.labels.inRange},headingVisible:!1,weekdaysVisible:!0,multiselectable:e.draft.mode!==`single`,rangeRole:()=>null,labelRole:()=>null,decorate:wr(e),content:Tr(e),isSelected:t=>_e(e.draft,t),isDisabled:n=>!t.isSelectable(n,e.followsActiveEnd?mn(e.draft,e.activeEnd):e.draft),today:h(),focus:e.focus}},Dr=(e,t,n)=>{let r=e.layout.months>1,i=n===`docked`&&!r&&e.options.outsideDays!==!1,a=Er(e,t,i);return r?{...a,headingVisible:!0}:a},Or=(e,t)=>y(t,L(t,e.layout.months-1),e.options.locale),Z=e=>Xn(e.draft,e.panel===`input`?`input`:`calendar`,e.options.locale,e.options.labels,e.options.precision),kr={element:null,docked:null,modal:null,caption:null},Ar={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},jr=e=>{switch(e){case`day`:return`both`;case`month`:return`year`;case`year`:return`none`}},Mr=e=>Ar[e],Nr=(e,t)=>e.options.precision===`day`&&H(t,e.options.inline).navigation===`caption`,Pr=(e,t,n)=>{let{locale:r,labels:i,animation:a,viewSwitch:o,mode:s,precision:l}=e.options;if(t===`modal`){if(!H(n,e.options.inline).headline)return kr;let t=o&&c(s,e.calendarLayout,l),r=br({labels:i,title:Wn(i,s,l),animate:a,text:Z(e),switchView:t?{panelId:F(e.instanceId,`input`)}:null});return r.setInputView(e.panel===`input`),{element:r.element,docked:null,modal:r,caption:null}}if(Nr(e,n)){let t=hr({locale:r,labels:i,view:e.view,arrowsOnly:e.layout.months>1});return{element:t.element,docked:null,modal:null,caption:t}}let u=_r({instanceId:e.instanceId,locale:r,labels:i,view:e.view,groups:jr(l),home:M(l)});return{element:u.element,docked:u,modal:null,caption:null}},Fr=(e,t)=>{let n=L(e,t);return{year:n.year,month:n.month,day:Math.min(e.day,D(n))}},Ir=(e,t,n,r)=>{let i=t?12:1;switch(e){case`ArrowLeft`:return E(n,r?1:-1);case`ArrowRight`:return E(n,r?-1:1);case`ArrowUp`:return E(n,-7);case`ArrowDown`:return E(n,7);case`Home`:return{year:n.year,month:n.month,day:1};case`End`:return{...n,day:D(n)};case`PageUp`:return Fr(n,-i);case`PageDown`:return Fr(n,i);default:return null}},Lr=e=>e.ctrlKey||e.altKey||e.metaKey,Rr=(e,t)=>{let n=e.toLowerCase();return t===`modal`?n===`y`?`year-grid`:null:n===`m`?`month-menu`:n===`y`?`year-menu`:null},zr=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`},Br=(e,t)=>{let{panel:n}=t.core;n!==t.home&&n!==`input`&&(e.preventDefault(),e.stopPropagation(),t.actions.showPanel(t.home))},Vr=(e,t)=>{if(!e.shiftKey||!zr(t))return!1;let n=Rr(e.key,t.layout);return n!==null&&(e.preventDefault(),t.actions.showPanel(n),!0)},Hr=(e,t,n)=>{e.preventDefault(),e.key===`Enter`&&n.layout===`modal`&&n.core.options.mode===`single`&&ne(n.core.options.footerExplicit,n.core.mode)&&_e(n.core.draft,t.date)?n.actions.confirm():n.actions.select(t.date)},Ur=(e,t,n)=>{if(e.key===`Enter`||e.key===` `){Hr(e,t,n);return}let r=Ir(e.key,e.shiftKey,t.date,n.isRtl());r!==null&&(e.preventDefault(),n.actions.focusDate(r))},Wr=(e,t,n)=>{e.addEventListener(`keydown`,e=>{if(e.defaultPrevented)return;if(e.key===`Escape`){Br(e,n);return}if(Lr(e)||Vr(e,n))return;let t=n.cellAt(e.target);t!==null&&Ur(e,t,n)},{signal:t})},Gr=`dp-ui__ghost`,Kr=e=>Array.from(e.querySelectorAll(`*`)).filter(e=>e.closest(`.${Gr}`)===null),qr=(e,t,n)=>{e.querySelectorAll(`.${Gr}`).forEach(e=>{e.remove()}),e.removeAttribute(`popover`),e.removeAttribute(`style`),e.classList.remove(`dp-ui__container--morphing`),e.classList.add(Gr),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`)},Jr=(e,t)=>{let n=Array.from(t.querySelectorAll(`*`));return Kr(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}]})},Yr=({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`))})},Xr=(e,t,n)=>{let r=e.cloneNode(!0);if(!(r instanceof HTMLElement))return null;qr(r,t,n);let i=Jr(e,r);i.forEach(Yr);let a=null,o=()=>{if(a!==null){let e=a;a=null,e.cancel()}r.remove()};return{show:()=>{e.append(r),i.forEach(({copy:e,top:t,left:n})=>{e.scrollTop=t,e.scrollLeft=n}),typeof r.animate==`function`?(a=r.animate([{opacity:1},{opacity:0}],{duration:T.VIEW_SWITCH_FADE_OUT,easing:`linear`,fill:`forwards`}),a.finished.then(o,o)):o()},remove:o}},Zr=`dp-ui__container--morphing`,Qr=/* @__PURE__ */ new WeakMap,$r=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height,radius:getComputedStyle(e).borderRadius}},ei=(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}},ti=e=>({width:`${String(e.width)}px`,height:`${String(e.height)}px`,borderRadius:e.radius}),ni=(e,t,n)=>{if(n.height===0)return;let r=getComputedStyle(e).direction===`rtl`,i=(t.x-n.x)*(r?-1:1),a=t.y-n.y,o=t.height/n.height;if(i===0&&a===0&&o===1)return;let s=r?`top right`:`top left`;e.animate([{transform:`translate(${String(i)}px, ${String(a)}px) scale(${String(o)})`,transformOrigin:s},{transform:`none`,transformOrigin:s}],{duration:T.VIEW_SWITCH,easing:l.EMPHASIZED})},ri=(e,t,n)=>{if(n===`none`||typeof e.animate!=`function`)return t(),null;if(n===`reduced`){let n=$r(e),r=Xr(e,n.width,n.height);return t(),r?.show(),null}let r=e.querySelector(`.dp-ui__headline`),i=$r(e),a=ei(e,r),o=Xr(e,i.width,i.height);t();let s=$r(e),c=ei(e,r);e.classList.add(Zr);let u=e.animate([ti(i),ti(s)],{duration:T.VIEW_SWITCH,easing:l.EMPHASIZED});Qr.set(e,u),o?.show(),r!==null&&a!==null&&c!==null&&ni(r,a,c);let d=()=>{o?.remove(),Qr.get(e)===u&&(Qr.delete(e),e.classList.remove(Zr))};return u.finished.then(d,d),u};function ii(e){let t=e.describedById??`${e.id}-supporting`,n=d(`div`,`dp-ui__text-field`),r=d(`input`,`dp-ui__text-field-input`,{id:e.id,type:`text`,inputmode:`numeric`,autocomplete:`off`,placeholder:e.placeholder,tabindex:`0`,"aria-invalid":`false`,"aria-describedby":t});r.value=e.value;let i=d(`label`,`dp-ui__text-field-label`,{for:e.id});i.textContent=e.label;let a=d(`div`,`dp-ui__text-field-supporting`,{id:t,"aria-live":`polite`});return a.textContent=e.hint,n.append(r,i,a),{element:n,input:r,getValue:()=>r.value,setValue:e=>{r.value=e},setError:t=>{let i=t!==null;n.classList.toggle(`dp-ui__text-field--error`,i),r.setAttribute(`aria-invalid`,i?`true`:`false`);let o=t??e.hint;a.textContent!==o&&(a.textContent=o)}}}function ai(e){return e.mode===`single`?e.date:null}function oi(e){return e.mode===`single`?e.date===null:e.mode===`range`?e.start===null:e.dates.length===0}function si(e){let{instanceId:t,draft:r,pattern:i,labels:a,rules:o}=e,s=d(`div`,`dp-ui__input-panel`,{"data-panel":`input`,id:F(t,`input`)}),c=fe(i,Ae(a)),l=(e,n,r)=>ii({id:`${t}-input-${e}`,label:n,placeholder:c,hint:c,value:r?xe(r,i):``}),u=r.mode===`range`,f=l(u?`start`:`date`,u?a.startDateField:a.dateField,r.mode===`range`?r.start:ai(r)),p=u?l(`end`,a.endDateField,r.end):null,m=p?[f,p]:[f],h=t=>{let n=t.getValue().trim();if(n===``)return t.setError(null),{date:null,failed:!1};let r=oe(n,i);if(r===null)return t.setError(a.invalidDate),{date:null,failed:!0};let s=o.unavailableReason(r);return s===null?(t.setError(null),t.setValue(xe(r,i)),{date:r,failed:!1}):(t.setError(e.messageFor(s)),{date:null,failed:!0})},g=()=>{let e=h(f);if(!p)return e.failed?null:{mode:`single`,date:e.date};let t=h(p),r=t.date,i=e.failed||t.failed;return e.date&&r&&n(r,e.date)<0&&(p.setError(a.invalidRange),r=null,i=!0),i?null:{mode:`range`,start:e.date,end:r}},_=t=>{let n=un(t,e.limits,e=>o.unavailableReason(e));return n===null||((p??f).setError(e.messageFor(n)),!1)};return m.forEach(t=>{t.input.addEventListener(`input`,()=>{he(t.input,i)}),t.input.addEventListener(`change`,()=>{let t=g();t&&_(t)&&e.onDraft(t)}),t.input.addEventListener(`keydown`,t=>{if(t.key!==`Enter`)return;t.preventDefault();let n=g();n&&_(n)&&N(n)&&!oi(n)&&(e.onDraft(n),e.onSubmit())})}),s.append(...m.map(e=>e.element)),s}function ci(e,t){let{labels:n,minDate:r,maxDate:i,pattern:a,precision:o}=t;return e===`min`&&r!==null?n.beforeMinDate.replace(`{date}`,k(r,a,o)):e===`max`&&i!==null?n.afterMaxDate.replace(`{date}`,k(i,a,o)):e===`range-length`?n.invalidRange:n.unavailableDate}const li=e=>{let{core:t,actions:n,rules:r}=e,{pattern:i,labels:a,limits:o}=t.options;return[si({instanceId:t.instanceId,draft:t.draft,pattern:i,labels:a,rules:r,limits:o,messageFor:e=>ci(e,t.options),onDraft:e=>{n.typeDraft(e)},onSubmit:()=>{ne(t.options.footerExplicit,t.mode)?n.confirm():n.submitDraft()}})]},ui=`dp-ui__date`,di=`dp-ui__date--outside-month`,fi=`data-decoration-label`,pi=`data-content-label`,mi=`dp-ui__date-content`,hi=`dp-ui__date--has-content`,gi=`:scope > .${mi}`,_i=(e,t,n)=>n.isDisabled(e)||t&&!n.outsideSelectable,vi=(e,t,n,r)=>[[`dp-ui__date--selected`,r.isSelected(e)],[`dp-ui__date--range-start`,n===`start`],[`dp-ui__date--range-end`,n===`end`],[`dp-ui__date--in-range`,n===`in-range`],[`dp-ui__date--today`,_(e,r.today)],[`dp-ui__date--disabled`,_i(e,t,r)],[di,t]],yi=e=>{e.querySelector(gi)?.remove(),e.classList.remove(hi),e.removeAttribute(pi)},bi=(e,t,n)=>{let r=n.content(t);if(r===null){yi(e);return}let i=e.querySelector(gi),a=(typeof r==`string`?r:r.textContent??``).trim();if(typeof r!=`string`||i===null||i.childElementCount!==0||i.textContent!==r){let t=d(`span`,mi);typeof r==`string`?t.textContent=r:t.appendChild(r),i===null?e.querySelector(`.dp-ui__date-indicator`)?.after(t):i.replaceWith(t)}e.classList.add(hi),a===``?e.removeAttribute(pi):e.setAttribute(pi,a)},xi=(e,t)=>e===`start`?t.rangeLabels.start:e===`end`?t.rangeLabels.end:e===`in-range`?t.rangeLabels.inRange:null,Si=(e,t,n,r,i)=>[p(e,i.locale),xi(t,i),n,r].filter(e=>e!==null&&e!==``).join(`, `),Ci=(e,t,n,r)=>{let i=r.rangeRole(t);bi(e,t,r),vi(t,n,i,r).forEach(([t,n])=>e.classList.toggle(t,n)),e.setAttribute(`aria-selected`,String(r.isSelected(t)||i!==null)),e.setAttribute(`aria-label`,Si(t,r.labelRole(t),e.getAttribute(fi),e.getAttribute(pi),r)),_(t,r.today)?e.setAttribute(`aria-current`,`date`):e.removeAttribute(`aria-current`),_i(t,n,r)?e.setAttribute(`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`);let a=!n&&_(t,r.focus);e.setAttribute(`tabindex`,a?`0`:`-1`)},wi=(e,t)=>{if(t===null)return;let n=(t.className??``).split(/\s+/).filter(Boolean);e.classList.add(...n),t.label&&e.setAttribute(fi,t.label),t.badge===!0&&e.appendChild(d(`span`,`dp-ui__date-badge`,{"aria-hidden":`true`}))},Ti=(e,t)=>{if(!e.inMonth&&!t.showOutside)return d(`td`,`${ui} dp-ui__date--empty`);let n=d(`td`,ui,{role:`gridcell`,"data-date":i(e.date)}),r=d(`span`,`dp-ui__date-indicator`);return r.textContent=v(e.date.day,t.locale),n.appendChild(r),wi(n,t.decorate(e.date)),Ci(n,e.date,!e.inMonth,t),n},Ei=`dp-ui__visually-hidden`,Di=e=>{let t=d(`thead`),n=d(`tr`,e.weekdaysVisible?`dp-ui__weekdays`:`dp-ui__weekdays ${Ei}`);if(e.weekNumbers){let t=d(`th`,`dp-ui__week-number-header`,{scope:`col`});t.textContent=e.labels.weekNumber,n.appendChild(t)}let r=Oe(e.locale,`narrow`),i=Oe(e.locale,`long`);for(let t=0;t<7;t++){let a=(e.weekStart+t)%7,o=i[a]??``,s=d(`th`,`dp-ui__weekday`,{role:`columnheader`,scope:`col`,abbr:o,title:o});s.textContent=r[a]??``,n.appendChild(s)}return t.appendChild(n),t},Oi=(e,t)=>{let n=d(`table`,`dp-ui__month-grid`,{role:`grid`});t.multiselectable===!0&&n.setAttribute(`aria-multiselectable`,`true`);let r=d(`caption`,t.headingVisible?`dp-ui__month-subhead`:`dp-ui__month-heading ${Ei}`);r.textContent=Me(e.view,t.locale),n.appendChild(r),n.appendChild(Di(t));let i=d(`tbody`);return e.weeks.forEach((n,r)=>{let a=d(`tr`,`dp-ui__week`);if(t.weekNumbers){let n=d(`th`,`dp-ui__week-number`,{scope:`row`}),i=e.weekNumbers.at(r);n.textContent=i===void 0?``:v(i,t.locale),a.appendChild(n)}n.forEach(e=>a.appendChild(Ti(e,t))),i.appendChild(a)}),n.appendChild(i),n},ki=(e,t)=>{e.querySelectorAll(`td[data-date]`).forEach(e=>{let n=f(e.dataset.date??``);n!==null&&Ci(e,n,e.classList.contains(di),t)})},Ai=(e,t,n)=>{let r={year:e.year,month:e.month,day:1},i=(S(r)-t+7)%7,a=n?6:Math.ceil((i+D(e))/7),o=E(r,-i),s=(4-t+7)%7,c=[],l=[];for(let t=0;t<a;t++){let n=E(o,t*7),r=[];for(let t=0;t<7;t++){let i=E(n,t);r.push({date:i,inMonth:i.year===e.year&&i.month===e.month})}c.push(r),l.push(x(E(n,s)))}return{view:e,weeks:c,weekNumbers:l}},ji=`table.dp-ui__month-grid`,Mi=(e,t)=>{e.style.setProperty(`transition`,`none`),t(),e.getBoundingClientRect(),e.style.removeProperty(`transition`)},Ni=e=>{let{core:t,layout:n,surface:r,gridContext:i}=e,{months:a}=t.layout,{outsideSelectable:o,headingVisible:s}=i(),c=r===`inline`,{fixedWeeks:l}=Ln({layout:n===`modal`?`modal`:`docked`,inline:c,months:a,outsideDays:t.options.outsideDays!==!1,fixedWeeks:t.options.fixedWeeks}),u=n===`docked`||c,p=r!==void 0&&Nr(t,r),m=d(`div`,void 0,{"data-panel":`days`}),h=e=>m.querySelector(`.dp-ui__page:not([inert])`)?.querySelector(e)??null,g=e=>Ai(e,t.options.weekStart,l),_=e=>Array.from({length:a},(t,n)=>L(e,n)),v=e=>{let t=i();if(a===1)return Oi(g(e),t);let n=d(`div`,`dp-ui__months`);return n.append(..._(e).map(e=>Oi(g(e),t))),n},y=e=>{let r=d(`div`);if(n===`modal`){let{locale:n,labels:i}=t.options;r.append(xr(e,n,i,t.instanceId,p))}return r.append(v(e)),r},b=e=>Math.max(..._(e).map(e=>g(e).weeks.length)),x=e=>{let t=b(e),n=h(`.dp-ui__navigation`)?.getBoundingClientRect().height??0,r=m.querySelector(ji),i=r?.tHead?.getBoundingClientRect().height??0,a=(r?.tBodies.item(0)?.rows.item(0))?.getBoundingClientRect().height??0,o=s?r?.caption?.getBoundingClientRect().height??0:0;return i>0&&a>0?n+o+i+a*t:n+(t+(s?2:1))*48},ee=t.options.pageBy===`view`?a:1,S=new ke(m,{rtl:e.rtl,swipe:t.options.swipe,animate:t.options.animation,fitHeight:u,step:(e,t)=>L(e,t*ee),isSame:Fe,renderPage:y,pageHeight:x,onCommit:(t,n)=>{e.onCommit(t,n)}}),C=()=>m.ownerDocument.activeElement,w=e=>{if(!(e instanceof Element))return null;let t=e.closest(`td.dp-ui__date[data-date]`);if(t===null||!m.contains(t)||t.classList.contains(`dp-ui__date--outside-month`)&&!o)return null;let n=f(t.getAttribute(`data-date`)??``);return n===null?null:{element:t,date:n}},T=()=>w(C())!==null,E=e=>{let t=h(`td.dp-ui__date[tabindex="0"]`);return t!==null||!e?t:h(`td.dp-ui__date[data-date]:not(.dp-ui__date--outside-month)`)},te=e=>{E(e)?.focus({preventScroll:!0})},D=()=>{let e=C();return e===null||!m.contains(e)?null:{buttonClass:ar(e)}},O=e=>{let{buttonClass:t}=e;((t===null?null:h(`.${t}`))??E(!0))?.focus({preventScroll:!0})},k=e=>{let t=D();e(),t!==null&&O(t)};return{element:m,present:(e,t)=>{k(()=>{t===0?S.show(e):S.slide(e,t>0?1:-1)})},finish:()=>{S.finish()},refresh:()=>{let e=i();m.querySelectorAll(ji).forEach(t=>{ki(t,e)})},refit:()=>{if(!u||m.hidden)return;let e=`${String(x(t.view))}px`;m.style.getPropertyValue(`--dp-ui-pager-height`)!==e&&k(()=>{Mi(m,()=>{S.show(t.view)})})},cellAt:w,focusCell:te,cellHasFocus:T,find:h,destroy:()=>{S.destroy()}}},Pi=e=>{let t=document.createElement(`div`);t.className=e.className,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label);let n=[],r=e.focused>=0&&e.focused<e.items.length?e.focused:0,i=(e,r)=>{let i=n.at(Math.max(0,Math.min(n.length-1,r)));i&&(n.at(e)?.setAttribute(`tabindex`,`-1`),i.setAttribute(`tabindex`,`0`),i.focus({preventScroll:!0}),b(t,i,`nearest`))},a=e=>{let n=getComputedStyle(t).direction===`rtl`?-1:1;switch(e){case`ArrowRight`:return n;case`ArrowLeft`:return-n;case`ArrowDown`:return 3;case`ArrowUp`:return-3;default:return null}};return e.items.forEach((o,s)=>{let c=document.createElement(`button`);c.type=`button`,c.className=e.itemClass,c.setAttribute(`role`,`option`),c.setAttribute(`aria-selected`,o.selected?`true`:`false`),c.setAttribute(`aria-label`,o.name),c.setAttribute(`tabindex`,s===r?`0`:`-1`),o.selected&&c.classList.add(`${e.itemClass}--selected`),o.current&&c.classList.add(`${e.itemClass}--current`),o.disabled&&c.setAttribute(`aria-disabled`,`true`),c.textContent=o.label;let l=()=>{o.disabled||o.onPick()};c.addEventListener(`click`,l),c.addEventListener(`keydown`,e=>{let t=a(e.key);t===null?e.key===`Home`?(e.preventDefault(),i(s,0)):e.key===`End`?(e.preventDefault(),i(s,n.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l()):(e.preventDefault(),i(s,s+t))}),n.push(c),t.appendChild(c)}),requestAnimationFrame(()=>{let i=t.querySelector(`.${e.itemClass}--selected`)??n.at(r);i&&b(t,i,`center`)}),t},Fi=t=>{let n=e(t.locale,`short`),r=e(t.locale,`long`),i=v(t.year,t.locale);return Pi({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)}}})})},Ii=e=>{let t=e.querySelector(`.dp-ui__menu-item--selected`);t&&b(e,t,`center`)},Li=(e,t,n)=>{let r=e.at(Math.max(0,Math.min(e.length-1,n))),i=e.at(t);r&&(i?.setAttribute(`tabindex`,`-1`),r.setAttribute(`tabindex`,`0`),r.focus({preventScroll:!0}),r.parentElement&&b(r.parentElement,r,`nearest`))},Ri=(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=V.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(),Li(o,t,t+1)):e.key===`ArrowUp`?(e.preventDefault(),Li(o,t,t-1)):e.key===`Home`?(e.preventDefault(),Li(o,t,0)):e.key===`End`?(e.preventDefault(),Li(o,t,o.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())}),n}),o=a;return a.forEach(e=>r.appendChild(e)),requestAnimationFrame(()=>{Ii(r)}),r},zi=t=>{let n=e(t.locale,`long`);return Ri(`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)}}}))},Bi=e=>Pi({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=v(t,e.locale);return{label:n,name:n,selected:t===e.selected,current:t===e.currentYear,disabled:!1,onPick:()=>{e.onPick(t)}}})}),Vi=e=>Ri(`year`,e.label,e.years.map(t=>({label:v(t,e.locale),selected:t===e.view.year,disabled:!1,onPick:()=>{e.onPick(t)}}))),Hi=e=>{let{min:t,max:n}=e.yearBounds(),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Ui=(e,t)=>{let n=R(e.draft);return n?.year===t?n.month:null},Wi=(e,t,n)=>(e.setAttribute(`data-panel`,t),e.id=F(n,t),e),Gi=(e,t)=>{let{core:n,rules:r}=t,{labels:i,locale:a}=n.options,o=n.view,{precision:s}=n.options,c=e=>{t.actions.jumpTo(e,`menu`)},l=e=>{c({year:e,month:n.view.month})};switch(e){case`month-menu`:return[Wi(zi({locale:a,view:o,label:i.chooseMonth,isMonthDisabled:e=>r.isMonthDisabled(e),onPick:e=>{c({year:n.view.year,month:e})}}),e,n.instanceId)];case`year-menu`:return[Wi(Vi({view:o,years:Hi(r),label:i.chooseYear,locale:a,onPick:l}),e,n.instanceId)];case`month-grid`:{let l=s===`month`,u=l?Ui(n,o.year):o.month,d=Wi(Fi({year:o.year,selected:u,focused:u??o.month,current:h(),locale:a,label:i.chooseMonth,isDisabled:e=>r.isMonthDisabled({year:n.view.year,month:e}),onPick:e=>{l?t.actions.select({year:n.view.year,month:e,day:1}):c({year:n.view.year,month:e})}}),e,n.instanceId);return t.layout===`docked`?[d]:[Sr(o,a,i,n.instanceId),d]}case`year-grid`:{let c=s===`year`,u=c?R(n.draft)?.year??null:o.year,d=Wi(Bi({selected:u,focused:u??o.year,years:Hi(r),currentYear:h().year,label:i.chooseYear,locale:a,onPick:c?e=>{t.actions.select({year:e,month:1,day:1})}:l}),e,n.instanceId);return t.layout===`docked`||c?[d]:[Cr(o,a,i,n.instanceId),d]}}},Ki=`[role="option"]`,qi=`data-rebuilt`,Ji=e=>{let{root:t,content:n,days:r}=e,i=`days`,a=[],o=null,s=()=>t.ownerDocument.activeElement,c=e=>{e===`days`?r.hidden=!0:(a.forEach(e=>{e.remove()}),a=[])},l=t=>{t===`days`?(r.hidden=!1,r.removeAttribute(qi)):(a=e.createParts(t),r.after(...a))},u=()=>{let e=o;e!==null&&(o=null,e.complete(),e.animations.forEach(e=>{e.cancel()}))},d=()=>{let e=o;o=null,e?.animations.forEach(e=>{e.cancel()})},f=(t,n,r)=>{let i=e.motion()===`none`?[]:t.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`})),s={animations:a,complete:r};o=s,Promise.all(a.map(e=>e.finished)).then(()=>{o===s&&u()},()=>void 0)},p=()=>{let e=r.getBoundingClientRect().height;e>0&&n.style.setProperty(`--dp-ui-panel-height`,`${String(e)}px`)},m=n=>{u();let o=i;if(n===o)return;o===`days`&&p();let d=t.contains(s()),m=n===`input`||o===`input`;i=n;let h=()=>{let t=()=>{c(o),l(n),e.onSwitched(n,o,d)};e.swap===void 0?t():e.swap(t,n,o)};m?h():f(o===`days`?[r]:a,T.PANEL_FADE_OUT,h)},h=(e,t)=>{d(),e!==i&&(c(i),i=e,l(e),t?.rebuilt===!0&&a.forEach(e=>{e.setAttribute(qi,``)}))},g=e=>{let t=e.closest(`[role="listbox"]`);return t===null?-1:Array.from(t.querySelectorAll(Ki)).indexOf(e)},_=e=>{for(let t of a){let n=e(t);if(n)return n}return null},v=(e,t)=>t>=0?_(e=>Array.from(e.querySelectorAll(Ki)).at(t)):e===null?null:_(t=>t.querySelector(`.${e}`));return{current:()=>i,settled:()=>o===null,mount:h,switchTo:m,rebuild:()=>{if(i===`days`||i===`input`||o!==null)return;let e=s(),t=e!==null&&a.some(t=>t.contains(e))?e:null,n=t===null?null:ar(t),r=t===null?-1:g(t),u=a.map(e=>e.scrollTop);c(i),l(i),a.forEach(e=>{e.setAttribute(qi,``)}),requestAnimationFrame(()=>{a.forEach((e,t)=>{e.scrollTop=u.at(t)??e.scrollTop})}),t!==null&&v(n,r)?.focus({preventScroll:!0})},entry:()=>{for(let e of a){let t=e.querySelector(`[tabindex="0"]`);if(t!==null)return t}return null},destroy:d}},Yi=e=>{let{root:t,core:n,actions:r,rules:i,mode:a,layout:o}=e,s=n.options,c=Pr(n,o,a),l=Ni({core:n,layout:o,surface:a,rtl:e.rtl,gridContext:()=>Dr(n,i,o),onCommit:(e,t)=>{r.page(e,t)}}),u=d(`div`,`dp-ui__content`);u.append(l.element);let f=Ji({root:t,content:u,days:l.element,motion:e.motion,createParts:e=>e===`input`?li({core:n,actions:r,rules:i}):Gi(e,{core:n,actions:r,rules:i,layout:o}),swap:(r,i,a)=>{let o=dr(t);o===null||i!==`input`&&a!==`input`?r():ri(o,()=>{r(),mr(o,i,n.layout.months)},e.motion())},onSwitched:e.onSwitched}),p=nr({labels:s.labels,visible:ne(s.footerExplicit,a),todayButton:s.todayButton,clearButton:s.clearButton!==!1}),m=d(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`});return t.replaceChildren(...c.element===null?[]:[c.element],u,p,m),{header:c,pages:l,panels:f,liveRegion:m}},Xi=[`drag`,`wheel`,`button`,`keyboard`,`menu`],Zi=e=>Xi.includes(e),Qi=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t===`modal`)},$i=e=>{let{core:t,actions:n,rules:r,mode:i}=e,a=t.calendarLayout===`docked`?`docked`:`modal`,o=new AbortController,s=d(`div`,`dp-ui__calendar`),c,l=0,u=()=>s.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(t.input).direction===`rtl`,f=()=>dr(s),p=()=>M(t.options.precision),m=e=>c.pages.cellAt(e),h=(e,n=!0)=>{c.header.docked?.setPanel(e);let r=f();r!==null&&(r.classList.toggle(cr,fr(e,p())),n&&mr(r,e,t.layout.months))},g=e=>{e===null?c.pages.focusCell(!0):e.focus({preventScroll:!0})},_=e=>{let t=Mr(e);return t===null?null:c.header.element?.querySelector(t)??c.pages.find(t)},v=(e,t,n)=>{e===`days`&&c.pages.refit(),n&&g(e===`days`?t===`input`?null:_(t):c.panels.entry())},y=(e=!1)=>{Qi(s,a),c=Yi({root:s,core:t,actions:n,rules:r,mode:i,layout:a,rtl:u(),motion:()=>ee(t.options.animation),onSwitched:v}),c.pages.present(t.view,0),c.panels.mount(t.panel,{rebuilt:e}),e&&c.pages.element.setAttribute(`data-rebuilt`,``),h(t.panel),c.header.modal?.setInputView(t.panel===`input`),tr(s,N(t.draft)),cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,h(c.panels.current()),c.pages.refit()})},b=()=>{c.panels.destroy(),c.pages.destroy(),c.header.modal?.destroy()},x=()=>{o.signal.aborted||(h(c.panels.current()),c.pages.refit())},S=()=>{o.signal.aborted||(x(),g(c.panels.entry()))},C=(e,n,r)=>{c.header.docked?.setView(e),c.header.caption?.setView(e);let i=Zi(r),a=i&&c.panels.current()===`days`&&c.panels.settled();c.pages.present(e,a?n:0),c.panels.rebuild(),i&&Se(c.liveRegion,Or(t,e))},w=()=>{let e=c.pages.cellHasFocus();c.pages.refresh(),e&&c.pages.focusCell(!1)},T=e=>{c.pages.finish(),h(e,!1),c.header.modal?.setInputView(e===`input`),c.header.modal?.setText(Z(t)),c.panels.switchTo(e)},E=()=>{c.pages.refresh(),c.panels.rebuild(),c.header.modal?.setText(Z(t)),tr(s,N(t.draft));let{announceSelection:e}=H(i,t.options.inline);e&&c.panels.current()===p()&&Se(c.liveRegion,Z(t))};return y(),(e=>{let{events:r}=t;r.on(`change:view`,e=>{C(e.view,e.delta,e.source)},e),r.on(`change:draft`,E,e),r.on(`change:focus`,w,e),r.on(`change:panel`,e=>{T(e.panel)},e),sr(s,e,{actions:n,panel:()=>t.panel,home:p(),cellAt:m}),Wr(s,e,{core:t,actions:n,layout:a,home:p(),caption:()=>Nr(t,i),cellAt:m,isRtl:u}),er(s,`.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)})(o.signal),{element:s,focusInitial:S,fit:x,update:()=>{if(o.signal.aborted)return;let e=s.contains(s.ownerDocument.activeElement);b(),y(!0),e&&S()},destroy:()=>{if(o.signal.aborted)return;o.abort(),cancelAnimationFrame(l),b();let e=f();e!==null&&(e.classList.remove(cr,lr),pr(e,1)),s.remove()}}},ea=e=>({year:e.year,month:e.month}),ta=e=>{let t=R(e.draft);return t===null?e.view:ea(t)},na=(e,t)=>{let{minDate:n,maxDate:r}=e.options,i=t.yearBounds(),a={year:i.min,month:1},o={year:i.max,month:12},s=n!==null&&A(a,n)>0,c=r!==null&&A(r,o)>0;return{first:s?ea(n):a,last:c?ea(r):o}},ra=(e,t)=>A(t.first,e)<0?t.first:A(e,t.last)<0?t.last:e,ia=e=>{let t=d(`div`,`dp-ui__top-bar`);return t.append(P(`close`,e.close,V.close),ve(`save`,e.save)),t},aa=e=>{let{labels:t,switchView:n}=e,r=d(`div`,`dp-ui__header-text`),i=d(`div`,`dp-ui__supporting-text`);i.textContent=t.rangeTitle;let a=yr(e.text,e.animate);r.append(i,a.element);let o=n===null?null:Te(t,n.panelId);return{nodes:o===null?[r]:[r,o.button],headline:a,switchButton:o}},oa=e=>{if(e.length===0)return null;let t=d(`div`,`dp-ui__header dp-ui__header--range`);return t.append(...e),t},sa=e=>{let t=e.fullscreen?ia(e.labels):null,n=e.headline?aa(e):null,r=oa([...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()}}},ca=(e,t)=>{let n=d(`div`,`dp-ui__weekdays-bar`,{"aria-hidden":`true`}),r=Oe(e,`narrow`);for(let e=0;e<7;e++){let i=d(`span`,`dp-ui__weekday`);i.textContent=r.at((t+e)%7)??``,n.append(i)}return n},la=(e,t)=>t===`x`?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight,ua=(e,t)=>t===`x`?e.clientX:e.clientY,da=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},fa=(e,t,n)=>{t===`x`?e.scrollLeft+=n:e.scrollTop+=n},pa=(e,t,n=`x`,r={})=>{let i=null,a=0,o=0,c=0,l=!1;n===`x`&&e.addEventListener(`wheel`,t=>{la(e,n)&&(Math.abs(t.deltaY)<=Math.abs(t.deltaX)||(t.preventDefault(),e.scrollLeft+=t.deltaY))},{signal:t,passive:!1}),e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button===0&&la(e,n)&&(i=t.pointerId,a=ua(t,n),o=a,c=0,l=!1)},{signal:t}),e.addEventListener(`pointermove`,t=>{if(t.pointerId!==i)return;let r=ua(t,n);c=r-a,!l&&Math.abs(c)<s.DRAG_START_PX||(l||(l=!0,da(e,t.pointerId)),fa(e,n,o-r),o=r)},{signal:t}),e.addEventListener(`selectstart`,e=>{i!==null&&e.preventDefault()},{signal:t});let u=t=>{t.pointerId===i&&(i=null,e.hasPointerCapture(t.pointerId)&&e.releasePointerCapture(t.pointerId),l&&t.type===`pointerup`&&c!==0&&r.onDragEnd?.(c<0?1:-1))};e.addEventListener(`pointerup`,u,{signal:t}),e.addEventListener(`pointercancel`,u,{signal:t}),e.addEventListener(`click`,e=>{l&&(l=!1,e.stopPropagation(),e.preventDefault())},{signal:t,capture:!0})},ma=(e,t,n)=>({...Er(e,t,!1),outsideSelectable:!1,weekNumbers:!1,headingVisible:!0,weekdaysVisible:n,rangeRole:t=>ye(e.draft,t),labelRole:t=>Ee(e.draft,t)}),ha=(e,t,n)=>Oi(Ai(n,e.options.weekStart,!1),ma(e,t,!1)),ga=`td.dp-ui__date[data-date]`,_a=e=>{let{core:t,rules:n}=e,r=new AbortController,a=d(`div`,`dp-ui__month-list`),o=[],c=null,l=0,u=!1,f=0,p=(t,n)=>Array.from({length:n},(n,r)=>e.render(L(t,r))),m=()=>{c!==null&&e.onRendered(c,L(c,o.length-1))},h=t=>{if(c===null)return;let n=L(c,o.length),r=A(n,e.bounds().last)+1,i=Math.min(t,r);if(i<=0)return;let s=p(n,i);o.push(...s),a.append(...s),m()},g=t=>{if(c===null)return;let n=A(e.bounds().first,c),r=Math.min(t,n);if(r<=0)return;let i=L(c,-r),s=p(i,r),l=a.scrollTop,u=a.scrollHeight;c=i,o.unshift(...s),a.prepend(...s),a.scrollTop=l+a.scrollHeight-u,m()},_=t=>{if(c===null)return;let n=ra(t,e.bounds());g(A(n,c)),h(A(L(c,o.length-1),n))},v=e=>{if(c===null)return null;let t=A(c,e);return t<0?null:o.at(t)??null},y=t=>{let n=ra(t,e.bounds());_(n);let r=v(n);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;a.scrollTop+=i},x=()=>{a.scrollTop<a.clientHeight&&g(6),a.scrollHeight-a.scrollTop-a.clientHeight<a.clientHeight&&h(6)},S=e=>{let t=a.getBoundingClientRect().top,n=o.map(e=>({table:e,top:e.getBoundingClientRect().top-t,height:e.getBoundingClientRect().height})),r=Math.max(n.reduce((e,t,n)=>t.top<=1?n:e,0),0),i=n.at(r);if(i===void 0)return null;let c=i.height>0?Math.max(-i.top,0)/i.height:0,l=n.at(r+1)?.table??i.table;return e===1?c>s.COMMIT_FRACTION?l:i.table:c<1-s.COMMIT_FRACTION?i.table:l},C=()=>{u&&(window.clearTimeout(f),u=!1,x())},w=e=>{C(),x();let n=S(e);if(n===null)return;let r=n.getBoundingClientRect().top-a.getBoundingClientRect().top;ee(t.options.animation)===`full`?(u=!0,f=window.setTimeout(C,T.SNAP_SCROLL_FALLBACK),a.scrollTo({top:a.scrollTop+r,behavior:`smooth`})):a.scrollTop+=r},E=e=>{if(!(e instanceof Element))return null;let t=e.closest(ga);return t!==null&&a.contains(t)?t:null},te=e=>{_(ea(e));let t=a.querySelector(`${ga}[data-date="${i(e)}"]`);t!==null&&(t.focus({preventScroll:!0}),b(a,t,`nearest`))},D=()=>{let e=ma(t,n,!1);o.forEach(t=>{ki(t,e)})},O=e.bounds(),k=ra(ta(t),O),j=ra(L(k,-2),O),ne=ra(L(k,9),O),re=A(j,ne)+1;re>0&&(c=j,o.push(...p(j,re)),a.append(...o),m()),a.addEventListener(`scroll`,()=>{l===0&&(l=requestAnimationFrame(()=>{l=0,u||x()}))},{passive:!0,signal:r.signal}),a.addEventListener(`scrollend`,C,{signal:r.signal}),pa(a,r.signal,`y`,{onDragEnd:w});let ie=null;if(typeof ResizeObserver<`u`){let t=0;ie=new ResizeObserver(n=>{let i=n.at(-1);if(i===void 0||r.signal.aborted)return;let a=i.contentRect.height,o=t===0;t=a,o&&a>0&&e.onShown()}),ie.observe(a)}return{element:a,scrollToMonth:y,refresh:D,cellAt:E,focusCell:te,ensureMonth:_,reveal:y,present:(e,t,n)=>{Zi(n)?_(e):y(e)},destroy:()=>{r.abort(),ie?.disconnect(),cancelAnimationFrame(l),l=0,window.clearTimeout(f),u=!1}}},va=e=>{let t=d(`div`,`dp-ui__navigation dp-ui__navigation--months`),n=ue(e);return t.append(P(`prev-month`,e.previousMonth,V.keyboardArrowLeft,n.previousMonth),P(`next-month`,e.nextMonth,V.keyboardArrowRight,n.nextMonth)),t},ya=e=>{let{core:t,actions:n,rules:r}=e,a=Ni({core:t,layout:`docked`,rtl:e.rtl,gridContext:()=>ma(t,r,!0),onCommit:(e,t)=>{n.page(e,t)}});return{element:a.element,cellAt:e=>a.cellAt(e)?.element??null,focusCell:e=>{let t=a.find(`td.dp-ui__date[data-date][data-date="${i(e)}"]`);t===null?a.focusCell(!0):t.focus({preventScroll:!0})},refresh:()=>{a.refresh()},reveal:()=>{a.refit()},present:(e,t,n)=>{a.present(e,n===`api`?0:t)},destroy:()=>{a.destroy()}}};function ba(e){let t;try{t=e.value()}catch(e){return U(e),null}let n=K(t,`range`,`day`);if(n?.mode!==`range`)return null;let{start:r,end:i}=n;return r===null||i===null?null:{start:r,end:i}}const xa=e=>{let{core:t,actions:n,rules:r,signal:i,column:a}=e,{presets:o,labels:s,limits:c}=t.options,l=d(`div`,a?`dp-ui__presets dp-ui__presets--column`:`dp-ui__presets`,{role:`group`,"aria-label":s.presets}),u=o.map(e=>{let t=d(`button`,`dp-ui__preset`,{type:`button`});return t.textContent=e.label,t}),f=u.map(()=>null);l.append(...u);let p=()=>{o.forEach((e,n)=>{let i=u[n],a=ba(e);f[n]=a;let o=!1,s=!1;if(a!==null){let e={mode:`range`,...a};o=dn(e,c,e=>r.isDisabled(e)),s=I(t.draft,e)}i.disabled=!o,i.setAttribute(`aria-pressed`,s?`true`:`false`)})};return l.addEventListener(`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button.dp-ui__preset`),r=u.findIndex(e=>e===t);if(r<0)return;let i=f[r];i!==null&&n.selectRange(i.start,i.end)},{signal:i}),pa(l,i),p(),{element:l,refresh:p,setHidden:e=>{l.hidden=e}}},Sa=`dp-ui__container--range`,Ca=`dp-ui__container--fullscreen`,wa=`dp-ui__container--presets`,Ta=[Sa,wa,Ca,lr],Ea=(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=ya({core:n,actions:r,rules:i,rtl:a});return t.append(va(o),e.element),e}let l=_a({core:n,rules:i,render:e=>ha(n,i,e),bounds:()=>na(n,i),onRendered:(e,t)=>{r.renderedMonths(e,t)},onShown:e.reveal});return t.append(ca(s,c),l.element),l},Da=e=>{let{root:t,core:n,actions:r,rules:i,mode:a,fullscreen:o,signal:s}=e,c=n.options,l=sa({labels:c.labels,animate:c.animation,text:Z(n),fullscreen:o,headline:H(a,c.inline).headline,switchView:c.viewSwitch?{panelId:F(n.instanceId,`input`)}:null}),u=d(`div`,`dp-ui__range`,{"data-panel":`days`}),f=Ea(e,u),p=Ji({root:t,content:t,days:u,motion:e.motion,createParts:e=>e===`input`?li({core:n,actions:r,rules:i}):[],swap:e.swap,onSwitched:e.onSwitched}),m=nr({labels:c.labels,visible:ne(n.options.footerExplicit,a),todayButton:c.todayButton,clearButton:c.clearButton!==!1}),h=d(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`}),g=n.layout.presets===`column`,_=n.layout.presets===`none`?null:xa({core:n,actions:r,rules:i,signal:s,column:g});return t.replaceChildren(...l.element===null?[]:[l.element],..._===null?[]:[_.element],u,m,h),{header:l,days:f,panels:p,liveRegion:h,applyChrome:e=>{let r=e===`input`;l.setInputView(r),l.setText(Z(n)),_?.setHidden(r);let i=dr(t);i!==null&&(i.classList.add(Sa),i.classList.toggle(wa,g),i.classList.toggle(Ca,o&&!r),mr(i,e,n.layout.months))},refreshPresets:()=>{_?.refresh()}}},Oa=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t)},ka=e=>e===`input`?`input`:`days`,Aa=e=>{let{core:t,actions:n,rules:r,mode:i,fullscreen:a}=e,o=t.calendarLayout!==`docked`,s=new AbortController,c=d(`div`,`dp-ui__calendar`),l,u=0,p=null,m=()=>ee(t.options.animation),h=()=>c.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(t.input).direction===`rtl`,g=e=>{let t=l.days.cellAt(e),n=f(t?.dataset.date??``);return t===null||n===null?null:{element:t,date:n}},_=()=>{let{draft:e,value:n}=t,r=z(e)&&z(n);tr(c,N(e)&&!r)},v=()=>{l.days.reveal(ta(t))},y=(e,n,r)=>{e===`days`&&v(),r&&(e===`input`?l.panels.entry()?.focus({preventScroll:!0}):l.days.focusCell(t.focus))},b=(e,t)=>{let n=()=>{l.applyChrome(t),e()};p?.cancel(),p=null;let r=dr(c);r===null?n():p=ri(r,n,m())},x=()=>{Oa(c,o),l=Da({root:c,core:t,actions:n,rules:r,mode:i,fullscreen:a,rtl:h(),signal:s.signal,motion:m,reveal:v,swap:b,onSwitched:y}),l.days.present(t.view,0,`api`),l.panels.mount(ka(t.panel)),l.applyChrome(l.panels.current()),_(),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=0,l.applyChrome(l.panels.current()),l.panels.current()===`days`&&v()})},S=()=>{p?.cancel(),p=null,l.panels.destroy(),l.days.destroy(),l.header.destroy()},C=()=>{if(s.signal.aborted)return;let e=l.panels.current();l.applyChrome(e),e===`days`&&v()},w=()=>{s.signal.aborted||(cancelAnimationFrame(u),u=0,C(),l.panels.current()===`input`?l.panels.entry()?.focus({preventScroll:!0}):l.days.focusCell(t.focus))},T=()=>{l.days.refresh(),l.refreshPresets(),l.header.setText(Z(t)),_();let{announceSelection:e}=H(i,t.options.inline);e&&l.panels.current()===`days`&&Se(l.liveRegion,Z(t))},E=()=>{let e=g(c.ownerDocument.activeElement)!==null;l.days.refresh(),e&&l.days.focusCell(t.focus)},te=(e,n,r)=>{let i=l.panels.current()===`days`&&l.panels.settled();l.days.present(e,i?n:0,r),Zi(r)&&t.layout.months>1&&Se(l.liveRegion,Or(t,e))};return x(),(e=>{let{events:r}=t;r.on(`change:view`,e=>{te(e.view,e.delta,e.source)},e),r.on(`change:draft`,T,e),r.on(`change:active-end`,()=>{l.days.refresh()},e),r.on(`change:value`,_,e),r.on(`change:focus`,E,e),r.on(`change:panel`,e=>{l.panels.switchTo(ka(e.panel))},e),sr(c,e,{actions:n,panel:()=>t.panel,home:`days`,cellAt:g}),Wr(c,e,{core:t,actions:n,layout:`range`,home:`days`,caption:()=>!1,cellAt:g,isRtl:h}),er(c,`.dp-ui__icon-button, .dp-ui__text-button, .dp-ui__preset, .dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator`,e)})(s.signal),{element:c,focusInitial:w,fit:C,update:()=>{if(s.signal.aborted)return;let e=c.contains(c.ownerDocument.activeElement);S(),x(),e&&w()},destroy:()=>{if(s.signal.aborted)return;s.abort(),cancelAnimationFrame(u),S();let e=dr(c);e!==null&&(e.classList.remove(...Ta),pr(e,1)),c.remove()}}};var ja=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(e){this.release();let n=this.createHost(e);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),Un(n.root,i.animation);let l={core:r,actions:a,rules:o,mode:e,fullscreen:r.calendarLayout===`fullscreen`},u=i.mode===`range`?Aa(l):$i(l);this.mounted={mode:e,host:n,view:u,stopModality:te(n.root),stopSchemeWatch:e===`inline`?t(()=>{s.applyTo(n.root)}):()=>void 0},n.body.append(u.element);let d=n.open();u.fit(),this.overflows(e,n)?(this.release(),this.deps.overflow()):(await d,c===this.generation&&e!==`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()),Un(e.host.root,this.core.options.animation),e.view.update())}label(){let{labels:e,mode:t,precision:n}=this.core.options;return Wn(e,t,n)}destroy(){this.generation+=1,this.release()}overflows(e,t){return e===`docked`&&this.core.options.displayMode===`auto`&&!Ue(t.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(e){let{core:t}=this,{options:n}=t,{actions:r}=this.deps,i=this.label();if(e===`inline`){let e=g(n.inline.container);return e===null?null:new Ne({container:e,label:i})}return e===`modal`?new be({parent:g(n.appendTo)??t.host,label:i,allowPageScroll:n.allowPageScroll,onCancel:e=>{r.cancel(e)}}):new De({host:t.host,anchor:t.input,instanceId:t.instanceId,rtl:getComputedStyle(t.input).direction===`rtl`,label:i,ignoreOutsideClick:n.behavior.ignoreOutsideClick,inside:[...t.endInput===null?[]:[t.endInput],...this.deps.inside()],onOutside:()=>{r.cancel(`outside`)},onEscape:()=>{r.cancel(`escape`)}})}},Ma=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 Be(t,n.precision);let r=e===`start`?t.start:t.end;return r===null?``:m(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=He(e,n,r);return}let a=e=>e===null?``:k(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:B(t);e.setValue(n),this.writeFields(n),this.sync()}};const Na=`aria-describedby`,Pa=e=>(e.getAttribute(Na)??``).split(/\s+/).filter(e=>e!==``);function Fa(e,t,n,r){let i=d(`span`,`dp-ui__visually-hidden`,{id:n}),a=d(`span`,void 0,{"aria-live":`polite`}),o=d(`span`);return o.textContent=r,i.append(a,` `,o),t.append(i),e.setAttribute(Na,[...Pa(e),n].join(` `)),{setHint:e=>{o.textContent!==e&&(o.textContent=e)},setError:e=>{let t=e??``;a.textContent!==t&&(a.textContent=t)},destroy:()=>{i.remove();let t=Pa(e).filter(e=>e!==n);t.length===0?e.removeAttribute(Na):e.setAttribute(Na,t.join(` `))}}}const Ia=`dp-ui--error`;function La(e,t,n){e.setAttribute(`aria-invalid`,`true`),t.classList.add(Ia),e.setCustomValidity(n)}function Ra(e,t){e.removeAttribute(`aria-invalid`),t.classList.remove(Ia),e.setCustomValidity(``)}function za(e,t,r){let i=e.trim(),a=t.trim();if(i===``&&a===``)return{kind:`empty`};let o=i===``?null:oe(i,r);if(i!==``&&o===null)return{kind:`invalid`,field:`start`};let s=a===``?null:oe(a,r);return a!==``&&s===null?{kind:`invalid`,field:`end`}:o===null||s===null?{kind:`partial`}: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:e}=this,t=B(`range`);if(e===null)return t;let r=this.readDate(this.core.input.value),i=this.readDate(e.value);return r===null||i===null||n(r,i)>0?t:{mode:`range`,start:r,end:i}}markInvalid(e){let{end:t}=this;if(t===null)return;let{input:n,host:r}=this.core;La(n,r,e),La(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;Ra(t,n),Ra(e,n),this.deps.describe(t,null),this.deps.describe(e,null)}format(e){return e===null?``:k(e,this.core.options.pattern,`day`)}readDate(e){let{pattern:t}=this.core.options,n=a(e,`single`,`day`)??j(e,`single`,t,`day`);return n?.mode===`single`?n.date:null}applyMask(e){let{options:t}=this.core;t.mask&&he(e,t.pattern)}commit(){let{end:e}=this;if(e===null||!this.dirty)return;let{options:t,input:n}=this.core,r=za(n.value,e.value,t.pattern);r.kind!==`partial`&&(r.kind===`empty`?this.settle(B(`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=un(r,n.limits,i);if(a===null){this.settle(r);return}let o=i(e)===null?`end`:`start`;this.fail(o,`unavailable-date`,ci(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(),La(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})}},Va=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=He(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 a(r,e,n)??j(r,e,t,n)??B(e)}evaluate(e){let{mode:t,pattern:n,limits:r,precision:i}=this.core.options,a=j(e,t,n,i);if(a===null)return{kind:`invalid`};if(z(a))return{kind:`empty`};let o=un(a,r,e=>this.deps.rules.unavailableReason(e));return o===null?{kind:`valid`,selection:a}:{kind:`unavailable`,selection:a,reason:o}}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(e){let{input:t,host:n,instanceId:r}=this.core,{end:i}=this.split,a=()=>{let{pattern:e,precision:t,labels:n}=this.core.options;return ie(e,t,Ae(n))},o=[[t,`input-description`]];i!==null&&o.push([i,`end-input-description`]);for(let[e,t]of o){let i=F(r,t);this.descriptions.set(e,Fa(e,n,i,a()))}this.core.events.on(`change:options`,()=>{let e=a();this.descriptions.forEach(t=>{t.setHint(e)})},e)}describe(e,t){this.descriptions.get(e)?.setError(t)}applyMask(){let{input:e,options:t}=this.core;t.mask&&t.mode===`single`&&t.precision===`day`&&he(e,t.pattern)}commit(){let e=this.core.input.value,t=this.evaluate(e);if(t.kind===`empty`)this.clearError(),this.deps.onTyped(B(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=ci(n,this.core.options);this.showError(r),this.emitter.emit(`error`,{code:`unavailable-date`,message:r,input:e,reason:n})}}showError(e){La(this.core.input,this.core.host,e),this.describe(this.core.input,e)}clearError(){Ra(this.core.input,this.core.host),this.describe(this.core.input,null)}},Ha=class{core;constructor(e){this.core=e}applyHost(){this.core.host.setAttribute(`data-theme`,this.core.options.theme)}applyTo(e){let{options:t,input:n,host:r}=this.core;Le(e,{theme:t.theme,colorScheme:t.colorScheme===`auto`?we(r):t.colorScheme,className:t.cssClass,rtl:getComputedStyle(n).direction===`rtl`})}destroy(){this.core.host.removeAttribute(`data-theme`)}};const Ua=(e,t,n,r)=>{let i=de(e);return i.length===0?``:e.mode===`multiple`?Yn(n,i.length,t):i.map(e=>ce(e,r,t,`long`)).join(pe)},Wa=`dp-ui__input--active`;var Ga=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=Ua(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(Wa),this.core.endInput?.classList.remove(Wa)}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(Wa);return}let n=this.expanded?this.core.activeEnd:null;t.classList.toggle(Wa,n===`start`),e.classList.toggle(Wa,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(e){let t=g(this.core.options.toggleButton,this.core.host);if(t===null)return;let n=/* @__PURE__ */ new Map,r=(e,r)=>{n.has(e)||n.set(e,t.getAttribute(e)),t.setAttribute(e,r)};r(`aria-haspopup`,`dialog`),t.tagName!==`BUTTON`&&(r(`role`,`button`),r(`tabindex`,`0`),t.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.activateToggle())},{signal:e})),t.addEventListener(`click`,()=>{this.activateToggle()},{signal:e}),this.toggle=t,r(`aria-expanded`,String(this.expanded)),r(`aria-label`,this.core.options.labels.openCalendar),this.updateLabel();let i=()=>{e.removeEventListener(`abort`,i),n.forEach((e,n)=>{e===null?t.removeAttribute(n):t.setAttribute(n,e)}),this.toggle===t&&(this.toggle=null),this.release===i&&(this.release=null)};this.release=i,e.addEventListener(`abort`,i,{once:!0})}releaseToggle(){this.release?.()}};function Q(e){return e.year*12+e.month-1}var Ka=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(e){let t=D(e),r=Ce(e.year,e.month,1),i=Ce(e.year,e.month,t);if(r===null||i===null)return!0;let{minDate:a,maxDate:o}=this.core.options,s=this.yearBounds();if(e.year<s.min||e.year>s.max||a!==null&&n(i,a)<0||o!==null&&n(r,o)>0)return!0;for(let n=1;n<=t;n+=1)if(this.dayReason({year:e.year,month:e.month,day:n})===null)return!1;return!0}yearBounds(){let{minDate:e,maxDate:t,yearRange:n}=this.core.options,r=h(),i=r.year-n.before,a=r.year+n.after;return{min:e===null?i:Math.max(i,e.year),max:t===null?a:Math.min(a,t.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(e){let{minDate:t,maxDate:r}=this.core.options,a=this.yearBounds();if(t!==null&&n(e,t)<0||e.year<a.min)return`min`;if(r!==null&&n(e,r)>0||e.year>a.max)return`max`;let o=this.getLists(),s=i(e);return o.disabled.has(s)||o.enabled!==null&&!o.enabled.has(s)?`disabled`:o.source.disabledWeekdays.includes(S(e))?`weekday`:this.isCallbackDisabled(e,o)?`disabled`:null}isCallbackDisabled(e,t){let{isDateDisabled:n}=t.source;if(n===null)return!1;let r=i(e),a=t.callbackResults.get(r);if(a!==void 0)return a;let o=!1;try{o=n(Ke(e))}catch(e){U(e)}return t.callbackResults.set(r,o),o}guardFor(e){let t=this.getLists(),r=t.guardDraft;if(t.guard!==null&&r!==null&&I(r,e))return t.guard;let{maxDate:i,limits:a}=t.source,o={year:this.yearBounds().max,month:12,day:31};i!==null&&n(i,o)<0&&(o=i);let s=sn(e,a,e=>this.isDisabled(e),o);return t.guardDraft=e,t.guard=s,s}getLists(){let e=this.core.options;if(this.lists?.source===e)return this.lists;let t={source:e,disabled:new Set(e.disabledDates.map(i)),enabled:e.enabledDates===null?null:new Set(e.enabledDates.map(i)),callbackResults:/* @__PURE__ */ new Map,guardDraft:null,guard:null};return this.lists=t,t}},qa=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}},Ja=class{validation;theme;display;input;triggers;form;relay=new qa;constructor(e,t){this.validation=new Ka(e,t),this.theme=new Ha(e),this.display=new ja(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 Va(e,t,{rules:this.validation,onTyped:this.relay.typed}),this.triggers=new Ga(e,t,{open:this.relay.open,dismiss:()=>{this.relay.cancel(`toggle`)}}),this.form=new Ma(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,Ya=()=>void 0;var Xa=class{core;emitter;lifecycle;constructor(e,t){let n=Zt(e);this.emitter=new qe,this.core=new Gt(n.input,n.host,n.createdHost,t),this.lifecycle=new Vn(this.core,this.emitter,new Ja(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?Ya:this.emitter.on(e,t)}once(e,t){return this.lifecycle.destroyed?Ya: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(Ut(e))}static getAllInstances(){return[...$.values()]}static destroyAll(){for(let e of[...$.values()])e.destroy()}},Za=Xa;export{G as DEFAULT_DATEPICKER_OPTIONS,Xa as DatepickerUI,qe as EventEmitter,Za as default};
|