@aiquants/period-slider 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/VirtualDateDropdown.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -1
- package/package.json +5 -5
- package/src/VirtualDateDropdown.tsx +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,15 @@ All notable changes to `@aiquants/period-slider` are documented here.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.11.1
|
|
11
|
+
|
|
12
|
+
### 修正
|
|
13
|
+
|
|
14
|
+
- **日付ドロップダウンに親指送りのタップサークルを描きません**。仮想スクロールの既定は有効で、直径 40px の円が
|
|
15
|
+
操作要素の幅に合わせた 1 列のリストの上へ重なっていました (行を覆うだけで、ネイティブのポップアップにも
|
|
16
|
+
無い部品です)。
|
|
17
|
+
|
|
18
|
+
|
|
10
19
|
## 0.11.0
|
|
11
20
|
|
|
12
21
|
### 利用側の契約が変わる点
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualDateDropdown.d.ts","sourceRoot":"","sources":["../src/VirtualDateDropdown.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,4GAA4G;AAC5G,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAQxC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAA;AA4BnC;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACrC,gFAAgF;IAChF,MAAM,EAAE,gBAAgB,CAAA;IACxB,mKAAmK;IACnK,aAAa,EAAE,MAAM,CAAA;IACrB,0HAA0H;IAC1H,YAAY,EAAE,MAAM,CAAA;IACpB;;;;;;;;;;OAUG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,6BAA6B;IAC7B,QAAQ,EAAE,OAAO,CAAA;IACjB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAA;IACjB,yEAAyE;IACzE,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAA;CAC3B;AAiBD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,QAAQ,gBAAgB,KAAG,MAwBhF,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAA;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,cAKnD,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAA;IACX,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,yGAAyG;IACzG,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,eAAe,MAAM,EAAE,gBAAgB,MAAM,EAAE,eAAe,MAAM,KAAG,aAUjL,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"VirtualDateDropdown.d.ts","sourceRoot":"","sources":["../src/VirtualDateDropdown.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,4GAA4G;AAC5G,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAQxC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAA;AA4BnC;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACrC,gFAAgF;IAChF,MAAM,EAAE,gBAAgB,CAAA;IACxB,mKAAmK;IACnK,aAAa,EAAE,MAAM,CAAA;IACrB,0HAA0H;IAC1H,YAAY,EAAE,MAAM,CAAA;IACpB;;;;;;;;;;OAUG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,6BAA6B;IAC7B,QAAQ,EAAE,OAAO,CAAA;IACjB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAA;IACjB,yEAAyE;IACzE,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAA;CAC3B;AAiBD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,QAAQ,gBAAgB,KAAG,MAwBhF,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAA;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,cAKnD,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAA;IACX,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,yGAAyG;IACzG,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,eAAe,MAAM,EAAE,gBAAgB,MAAM,EAAE,eAAe,MAAM,KAAG,aAUjL,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA2TlE,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),$t=require("date-fns"),a=require("react"),rs=require("@aiquants/virtualscroll"),ns=require("react-dom"),Da=120,Qn="data-drag-snap",eo="--ps-drag-snap-duration",Hr={flat:["--ps-drag-low","--ps-drag-high"],macro:["--ps-drag-macro-low","--ps-drag-macro-high"],micro:["--ps-drag-micro-low","--ps-drag-micro-high"]},Ua=["low","high"],Ba=["tx","ty","rot"],Sn={flat:{low:"--ps-drag-label-low",high:"--ps-drag-label-high"},macro:{low:"--ps-drag-macro-label-low",high:"--ps-drag-macro-label-high"},micro:{low:"--ps-drag-micro-label-low",high:"--ps-drag-micro-label-high"}},po=(e,t)=>`${e}-${t}`,to=(e,t,r)=>`var(${po(e,t)}, ${r})`,os=(e,t,r)=>{const n=Sn[t];for(const o of Ua)for(const s of Ba)e.style.setProperty(po(n[o],s),r[o][s])},Wa=e=>Math.max(0,Math.min(1,e)),wn=(e,t,r,n)=>{const o=Wa(t);if(e==="point")return[o,o];const s=e==="low"?n:r;return[Math.min(o,s),Math.max(o,s)]},Mo=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},Ln=(e,t,r,n)=>{const o=Wa(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ro=(e,t,r,n)=>{if(r){const l=(1-e)*100,c=(1-t)*100;return n?`M 12 ${c} L 12 ${l} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${l} L 20 ${c} Z`}const o=e*100,s=t*100;return n?`M ${o} 12 L ${s} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${s} 20 L ${o} 20 Z`},Et=(e,t)=>`var(${e}, ${t}%)`,as=(e,t,r,n)=>{const[o,s]=Hr[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(s,`${n*100}%`)},is=e=>{for(const[t,r]of Object.values(Hr))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Sn))for(const r of Ua)for(const n of Ba)e.style.removeProperty(po(t[r],n))},no=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),va=new Set(["hidden","clip","scroll","auto","overlay"]),xa=["paint","strict","content"],ss=["layout","paint","strict","content"],ls=["transform","perspective","filter"],Ir=e=>e!==void 0&&e!==""&&e!=="none",cs=e=>e!==void 0&&e!==""&&e!=="normal",sn=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},us=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,ds=(e,t)=>t==="absolute"&&Ir(e.position)&&e.position!=="static"||Ir(e.transform)||Ir(e.perspective)||Ir(e.filter)||Ir(e.backdropFilter)||cs(e.containerType)||ss.some(r=>e.contain.includes(r))?!0:ls.some(r=>e.willChange.includes(r)),ms=(e,t,r,n,o,s)=>{const l=t.ownerDocument.defaultView;if(l===null)return!1;const c=e.getBoundingClientRect();if(c.width===0||c.height===0)return!1;const f=n?0:r,g=n?r:0;if(o<c.left-f||o>=c.right+f||s<c.top-g||s>=c.bottom+g)return!1;const M=l.getComputedStyle(t);if(M.visibility!=="visible")return!1;let b=null;for(let u=t;u!==null;u=u.parentElement){const D=u===t?M:l.getComputedStyle(u);if(b!==null&&!ds(D,b))continue;const K=va.has(D.overflowX)||xa.some(y=>D.contain.includes(y)),Q=va.has(D.overflowY)||xa.some(y=>D.contain.includes(y));if(K||Q){const y=u.getBoundingClientRect();if(K&&(o<y.left+sn(D.borderLeftWidth)||o>=y.right-sn(D.borderRightWidth))||Q&&(s<y.top+sn(D.borderTopWidth)||s>=y.bottom-sn(D.borderBottomWidth)))return!1}b=us(D)}return!0},oo=new Map,fs=(e,t)=>{if(!(t.shiftKey&&t.cancelable))return;for(const o of e)if(o.ownsHit(t.target)){o.step(t);return}let r=null,n=Number.POSITIVE_INFINITY;for(const o of e){const s=o.distanceToRailPx(t.clientX,t.clientY);s===null||s>=n||(r=o,n=s)}r?.step(t)},gs=(e,t)=>{let r=oo.get(e);if(r===void 0){const s=new Set,l=c=>fs(s,c);r={participants:s,listener:l},oo.set(e,r),e.addEventListener("wheel",l,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(oo.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Fr="gap-[11px]",ut=6,dt=ut*2,Ct=ut*4/3,hs={left:`0,${dt/2} ${ut},0 ${ut},${dt}`,right:`${Ct},${dt/2} ${Ct-ut},0 ${Ct-ut},${dt}`,up:`${dt/2},0 0,${ut} ${dt},${ut}`,down:`${dt/2},${Ct} 0,${Ct-ut} ${dt},${Ct-ut}`},ao=e=>{e.preventDefault(),e.stopPropagation()},bs={onMouseDownCapture:ao,onMouseUpCapture:ao,onClickCapture:ao},ws="period-slider-step",ps=`${ws} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Ms="transition-colors motion-reduce:transition-none not-aria-disabled:cursor-pointer aria-disabled:cursor-not-allowed focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 dark:focus-visible:ring-blue-400 forced-colors:not-aria-disabled:hover:text-[Highlight] forced-colors:aria-disabled:text-[GrayText]",Ds={control:"text-slate-500 not-aria-disabled:hover:bg-slate-500/15 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-500/25 aria-disabled:text-slate-500/40 dark:text-slate-400 dark:not-aria-disabled:hover:text-slate-50 dark:aria-disabled:text-slate-400/40",rail:"border border-slate-300 bg-white text-slate-700 shadow-2xs not-aria-disabled:hover:border-slate-400 not-aria-disabled:hover:bg-slate-100 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-200 aria-disabled:border-slate-300/40 aria-disabled:bg-white/40 aria-disabled:text-slate-700/40 aria-disabled:shadow-none dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:not-aria-disabled:hover:border-slate-500 dark:not-aria-disabled:hover:bg-slate-700 dark:not-aria-disabled:hover:text-white dark:not-aria-disabled:active:bg-slate-600 dark:aria-disabled:border-slate-700/40 dark:aria-disabled:bg-slate-800/40 dark:aria-disabled:text-slate-200/40"},ln="after:inset-[calc((100%-var(--ps-target-size))/2)]",Ra={horizontal:"px-[19px]",vertical:"py-[19px]"},vs={control:{left:ln,right:ln,up:ln,down:ln},rail:{left:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:left-[calc(100%-var(--ps-target-size)+4px)] after:-right-[4px]",right:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-left-[4px] after:right-[calc(100%-var(--ps-target-size)+4px)]",up:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-[calc(100%-var(--ps-target-size)+4px)] after:-bottom-[4px]",down:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-[4px] after:bottom-[calc(100%-var(--ps-target-size)+4px)]"}},Wt=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:s,className:l,ref:c})=>{const f=e==="up"||e==="down",g=f?dt:Ct,M=f?Ct:dt,b=r||!n;return p.jsx("button",{ref:c,type:"button","aria-label":s,disabled:r,"aria-disabled":b?!0:void 0,...b?bs:null,onClick:b?void 0:o,className:`${l===void 0?"":`${l} `}${ps} ${Ms} ${Ds[t]} ${vs[t][e]}`,children:p.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:g,height:M,viewBox:`0 0 ${g} ${M}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:p.jsx("polygon",{points:hs[e]})})})},Ga={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},et=e=>e instanceof Date&&!Number.isNaN(e.getTime()),pe=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),qe=(e,t)=>{if(!et(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${pe(t)})`);const r=new Date(t.getTime());return e==="year"?(r.setMonth(0,1),r.setHours(0,0,0,0)):(e==="month"&&r.setDate(1),r.setHours(0,0,0,0)),r},J=(e,t)=>{const r=qe(e,t),n=r.getFullYear(),o=r.getMonth()+1,s=r.getDate();if(e==="year")return n;if(e==="month")return n*12+(o-1);const l=new Date(0);return l.setUTCFullYear(n,o-1,s),l.setUTCHours(0,0,0,0),Math.floor(l.getTime()/(1440*60*1e3))},ce=(e,t)=>{const r=new Date(0);if(r.setHours(0,0,0,0),e==="year")return r.setFullYear(t,0,1),r;if(e==="month"){const o=Math.floor(t/12),s=t-o*12;return r.setFullYear(o,s,1),r}const n=new Date(t*24*60*60*1e3);return r.setFullYear(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),r},Ve=(e,t,r)=>{if(!et(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${pe(t)})`);return e==="year"?$t.addYears(t,r):e==="month"?$t.addMonths(t,r):$t.addDays(t,r)},Xa=(e,t,r)=>{if(!et(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${pe(r)})`);return qe(t,qe(e,r))},Ka=(e,t,r)=>{if(!et(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${pe(r)})`);if(e===t)return qe(t,r);const n=r.getFullYear(),o=r.getMonth();if(e==="year"){if(t==="month")return new Date(n,11,1);if(t==="day")return new Date(n,11,31)}return e==="month"&&t==="day"?new Date(n,o+1,0):qe(t,r)},Sa=(e,t,r)=>e<t?t:e>r?r:e,mt=(e,t,r,n,o)=>{if(_r("macroRange",r,"resolveMacroWindow"),!et(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${pe(n)})`);if(!et(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${pe(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${pe(n)}, maxDate: ${pe(o)})`);return[qe(t,Sa(Xa(e,t,r[0]),n,o)),qe(t,Sa(Ka(e,t,r[1]),n,o))]},xs={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},La=new Map,Rs=(e,t)=>{const r=`${e}\0${t}`,n=La.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,xs[e]);return La.set(r,o),o},Ss=(e,t)=>{const r=String(t.getFullYear()).padStart(4,"0");if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const o=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${o}`},Ue=(e,t,r,n)=>et(t)?r?r(t):n===void 0?Ss(e,t):Rs(e,n).format(t):"",Ft=(e,t,r,n)=>Ue(e,t,r,n),fe=(e,t,r)=>{if(!e||e.length===0||e.length===1)return 0;const n=J(r,t);let o=0,s=e.length-1;if(n<=J(r,e[o]))return 0;if(n>=J(r,e[s]))return s;for(;o<=s;){const f=o+s>>1,g=J(r,e[f]);if(g===n)return f;g<n?o=f+1:s=f-1}const l=Math.abs(J(r,e[o])-n),c=Math.abs(J(r,e[s])-n);return l<c?o:s},Mt=(e,t,r,n)=>{if(!Array.isArray(e)||e.length===0)return[];const o=J(t,r),s=J(t,n),l=new Map;for(const c of e){const f=qe(t,c),g=J(t,f);g<o||g>s||l.has(g)||l.set(g,f)}if(l.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${pe(r)}, maxDate: ${pe(n)}, entries: ${e.length})`);return Array.from(l.keys()).sort((c,f)=>c-f).map(c=>l.get(c))},cn=(e,t,r,n)=>{const o=e.length-1;if(o<=0)return 0;const s=fe(e,n,t);if(r==="time"){const l=e[0].getTime(),c=e[o].getTime()-l;return c<=0?0:Math.max(0,Math.min(1,(e[s].getTime()-l)/c))}return s/o},un=(e,t,r,n)=>{const o=e.length-1;if(o<=0)return 0;const s=Math.max(0,Math.min(1,n));if(r==="time"){const l=e[0].getTime(),c=e[o].getTime()-l;return c<=0?0:fe(e,new Date(l+s*c),t)}return Math.max(0,Math.min(o,Math.round(s*o)))},ho=(e,t,r,n,o,s,l)=>{let c=r,f=n;return l?(c=t,f=t):e==="low"?t>n?(c=n,f=t):c=t:t<r?(f=r,c=t):f=t,[Math.max(o,Math.min(s,c)),Math.max(o,Math.min(s,f))]},qa=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:s,sortedAllowedDates:l,snapMode:c,unit:f})=>{if(s){const K=l.length-1;if(K<=0)return[0,0];const Q=Math.max(0,Math.min(K,Math.round(t))),y=Math.max(Q,Math.min(K,Math.round(r)));if(c==="time"){const Y=l[0].getTime(),H=l[K].getTime(),ie=l[Q].getTime(),X=l[y].getTime()-ie;let U=ie+e*(H-Y),A=U+X;U<Y&&(U=Y,A=Y+X),A>H&&(A=H,U=H-X);const v=fe(l,new Date(U),f),E=fe(l,new Date(A),f);return[v,Math.max(v,E)]}const ae=Math.round(e*K);let ne=Q+ae,$=y+ae;return ne<0&&($+=-ne,ne=0),$>K&&(ne-=$-K,$=K),[Math.max(0,Math.min(K,ne)),Math.max(0,Math.min(K,$))]}const g=K=>Math.max(n,Math.min(o,K)),M=o-n;if(M<=0)return[g(t),g(r)];const b=Math.round(e*M);let u=t+b,D=r+b;return u<n&&(D+=n-u,u=n),D>o&&(u-=D-o,D=o),[g(u),g(D)]},Za=(e,t,r,n,o,s,l,c)=>{let f=0,g=!1,M=!1;switch(e){case"ArrowRight":case"ArrowUp":f=c;break;case"ArrowLeft":case"ArrowDown":f=-c;break;case"PageUp":f=c*5;break;case"PageDown":f=-c*5;break;case"Home":g=!0;break;case"End":M=!0;break;default:return null}if(l){let D=r;return g?D=o:M?D=s:D=Math.max(o,Math.min(s,r+f)),[D,D]}let b=r,u=n;return t==="low"?g?b=o:M?b=n:b=Math.max(o,Math.min(n,r+f)):g?u=r:M?u=s:u=Math.max(r,Math.min(s,n+f)),[b,u]},Ja=8,Qa=2,ei=16,Ls=12,Ts=90,ti=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),s=Math.abs(Math.cos(n));return{alongPx:(e*s+t*o)/2,acrossPx:(e*o+t*s)/2}},Do=(e,t)=>{const r=t?.estimatedHeightPx??ei,o=Ja+(t?.anchorGapY??Qa)+r/2,s=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:s,highOffsetY:s,isSlanted:!1,proximity:0}},vo=(e,t,r,n="top",o)=>{const s=o?.estimatedWidthPx,l=o?.estimatedHeightPx??ei,c=o?.paddingPx??Ls,f=o?.maxAngleDeg??Ts,g=Ja+(o?.anchorGapY??Qa),M=Do(n,o);if(!(Number.isFinite(r)&&r>0)||s===void 0||!Number.isFinite(s)||s<=0)return M;const b=Math.max(0,t-e)/100*r,u=s+c;if(b>=u)return M;const D=Math.max(0,Math.min(1,(u-b)/u)),Q=D*D*D*(D*(D*6-15)+10)*f,y=n==="top"?-Q:Q,ae=ti(s,l,Q),ne=g+ae.acrossPx,$=n==="top"?-ne:+ne,Y=2*ae.alongPx,H=Math.max(0,(Y+c-b)/2);return{lowAngleDeg:y,highAngleDeg:y,lowOffsetX:-H,highOffsetX:H,lowOffsetY:$,highOffsetY:$,isSlanted:D>.001,proximity:D}},ri=e=>({...e,lowOffsetX:0,highOffsetX:0}),xo=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},ni=(e,t,r)=>{const n=Math.abs(e)>Math.abs(t)?e:t;return!Number.isFinite(n)||n===0?0:(r?n<0:n>0)?1:-1};function oi(e,t,r,n,o,s,l="macro-top",c=.05,f=!0,g="range"){if(xo(t,l)==="macro"){const u=Math.abs(e-r),D=Math.abs(e-n);return u<=c&&u<=D?"macro-low":D<=c&&D<u?"macro-high":f&&e>=r&&e<=n?"macro-connect":u<D?"macro-low":"macro-high"}if(g==="point")return"micro-point";const M=Math.abs(e-o),b=Math.abs(e-s);return M<=c&&M<=b?"micro-low":b<=c&&b<M?"micro-high":f&&e>=o&&e<=s?"micro-connect":M<b?"micro-low":"micro-high"}function ai(e,t,r,n,o){if(e==="macro-connect"){const[g,M]=Mo(t-r,n,o);return[g,M,"macro-connect"]}const s=e==="macro-low"?"low":"high",[l,c]=wn(s,t,n,o),f=Ln(s,t,n,o);return[l,c,f==="low"?"macro-low":"macro-high"]}function ii(e,t,r,n,o){if(e==="micro-point"){const[g]=wn("point",t,n,o);return[g,g,"micro-point"]}if(e==="micro-connect"){const[g,M]=Mo(t-r,n,o);return[g,M,"micro-connect"]}const s=e==="micro-low"?"low":"high",[l,c]=wn(s,t,n,o),f=Ln(s,t,n,o);return[l,c,f==="low"?"micro-low":"micro-high"]}const Yr=a.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,s;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",s=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",s=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const l=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return p.jsx("svg",{className:s,width:r?"8":"16",height:r?"16":"8",viewBox:r?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:p.jsx("path",{d:o,className:l,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});Yr.displayName="VernierKnobSvg";const ys=(e,t)=>{if(!et(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${pe(e)})`);if(!et(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${pe(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${pe(e)}, maxDate: ${pe(t)})`)},_r=(e,t,r="PeriodSlider")=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`${r}: ${e} is required and must be a [start, end] Date tuple (received: ${pe(t)})`);const[n,o]=t;if(!et(n))throw new RangeError(`${r}: ${e}[0] must be a valid Date (received: ${pe(n)})`);if(!et(o))throw new RangeError(`${r}: ${e}[1] must be a valid Date (received: ${pe(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`${r}: ${e} must not be inverted (start: ${pe(n)}, end: ${pe(o)})`)},bo=(e,t)=>{if(!et(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${pe(t)})`)},pt=(e,t,r,n,o)=>{const s=J(r,t);if(s<J(r,n)||s>J(r,o))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${pe(t)}, minDate: ${pe(n)}, maxDate: ${pe(o)})`)},Ps=(e,t,r)=>{if(e.mode==="range"){for(const n of["range","defaultRange"]){const o=e[n];o!==void 0&&(_r(n,o),pt(`${n}[0]`,o[0],e.unit,t,r),pt(`${n}[1]`,o[1],e.unit,t,r))}return}if(e.mode==="point")for(const n of["value","defaultValue"]){const o=e[n];o!==void 0&&(bo(n,o),pt(n,o,e.unit,t,r))}},As=(e,t,r)=>{_r("macroRange",e.macroRange);const n=e.microUnit??e.unit,o=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,s=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(o&&s)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(s){if(e.microValue!==void 0)return bo("microValue",e.microValue),pt("microValue",e.microValue,n,t,r),{shape:"point",selection:[e.microValue,e.microValue]};if(e.defaultMicroValue!==void 0)return bo("defaultMicroValue",e.defaultMicroValue),pt("defaultMicroValue",e.defaultMicroValue,n,t,r),{shape:"point",selection:[e.defaultMicroValue,e.defaultMicroValue]};throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)")}if(e.microRange!==void 0)return _r("microRange",e.microRange),pt("microRange[0]",e.microRange[0],n,t,r),pt("microRange[1]",e.microRange[1],n,t,r),{shape:"range",selection:e.microRange};if(e.defaultMicroRange!==void 0)return _r("defaultMicroRange",e.defaultMicroRange),pt("defaultMicroRange[0]",e.defaultMicroRange[0],n,t,r),pt("defaultMicroRange[1]",e.defaultMicroRange[1],n,t,r),{shape:"range",selection:e.defaultMicroRange};throw o?new RangeError("PeriodSlider: vernier range mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)"):new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange / defaultMicroRange for a period, or microValue / defaultMicroValue for a point")},kr=(e,t,r,n,o,s,l,c)=>{const f=fe(e,n,t),g=fe(e,o,t);return l?f:c?g:Math.max(f,Math.min(g,fe(e,r,t)+s))},io=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Ta=()=>{const[e,t]=a.useState(null),r=a.useRef(null),n=a.useCallback((s,l)=>{const c=r.current;if(c!==null&&c[0].getTime()===s.getTime()&&c[1].getTime()===l.getTime())return;const f=[s,l];r.current=f,t(f)},[]),o=a.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Es=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`)}},fr=()=>{const[e,t]=a.useState(null),r=a.useRef(null),n=a.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const s=new ResizeObserver(l=>{for(const c of l){const f=c.borderBoxSize?.[0];f!==void 0&&t(g=>g!==null&&Math.abs(g.widthPx-f.inlineSize)<.5&&Math.abs(g.heightPx-f.blockSize)<.5?g:{widthPx:f.inlineSize,heightPx:f.blockSize})}});s.observe(o),r.current=s},[]);return a.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},so=(e,t)=>{const r=gn(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},gn=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},Cs=e=>{const t={};let r=0;for(const o of e){const{side:s,box:l}=o;if(l===null)continue;let c;if(o.reach==="inline-size")c=l.widthPx,r=Math.max(r,l.heightPx/2);else{const f=ti(l.widthPx,l.heightPx,o.angleDeg);c=o.centreOffsetPx===null?2*f.acrossPx:Math.abs(o.centreOffsetPx)+f.acrossPx,r=Math.max(r,f.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${s}`]=`${Math.ceil(c)}px`}if(Object.keys(t).length===0)return;const n=Math.ceil(r);return t["--ps-label-reach-main"]=`${n}px`,{style:t,mainPx:n}},ya=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),Pa=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),pn=(e,t)=>({"--ps-tooltip-tx":to(e,"tx",t.tx),"--ps-tooltip-ty":to(e,"ty",t.ty),"--ps-tooltip-rot":to(e,"rot",t.rot)}),lo=(e,t,r,n)=>{const o=Do(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const s=vo(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),l=n.isMerged?ri(s):s,c=Sn[e],f={low:ya(l.lowOffsetX,l.lowOffsetY-o.lowOffsetY,l.lowAngleDeg),high:ya(l.highOffsetX,l.highOffsetY-o.highOffsetY,l.highAngleDeg)};return{slant:l,lowStyle:pn(c.low,f.low),highStyle:pn(c.high,f.high),placements:f}},Aa={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Ea=(e,t,r)=>{const n=Do(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Aa,highStyle:Aa,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let s=n;if(o){const f=vo(e,t,r.trackLengthPx,r.labelPosition,r.config);s=r.isMerged?ri(f):f}const l=Sn.flat,c={low:Pa(s.lowOffsetX,s.lowOffsetY,s.lowAngleDeg),high:Pa(s.highOffsetX,s.highOffsetY,s.highAngleDeg)};return{slant:s,lowStyle:{"--ps-tooltip-origin":"50% 50%",...pn(l.low,c.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...pn(l.high,c.high)},placements:o?c:null}},$s={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Is={horizontal:{decrease:"period-slider-stepper-prev",increase:"period-slider-stepper-next"},vertical:{decrease:"period-slider-stepper-prev period-slider-stepper-down",increase:"period-slider-stepper-next period-slider-stepper-up"}},Ca={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},ks={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Fr} ${Ra.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Ca.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Fr} ${Ra.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Ca.vertical}`}},$a={horizontal:{leading:"col-start-1 row-start-1",rail:"col-start-2 row-start-1",railOnly:"col-start-1 row-start-1",trailing:"col-start-3 row-start-1"},vertical:{leading:"col-start-1 row-start-1",rail:"col-start-1 row-start-2",railOnly:"col-start-1 row-start-1",trailing:"col-start-1 row-start-3"}},Ia=(e,t)=>{e.setPointerCapture(t)},Ns=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:s="index",disabled:l=!1,className:c="",showStepper:f=!0,tooltipStyle:g="always",labelPosition:M="top",autoSlantLabels:b=!0,isVertical:u=!1,hideConnectBar:D=!1,showTicks:K=!1,colorScheme:Q="blue-rose",locale:y,decreaseAriaLabel:ae="Decrease",increaseAriaLabel:ne="Increase"}=e;ys(r,n),Ps(e,r,n),y!==void 0&&Es("locale",y);const $=e.mode==="vernier"?As(e,r,n):null,Y=$!==null&&$.shape==="point",H=Ga[Q],ie=a.useId(),X=a.useRef(e),U=r.getTime(),A=n.getTime(),v=a.useMemo(()=>Mt(o,t,r,n),[o,t,U,A]),E=v.length>0,{rangeMin:V,rangeMax:C}=a.useMemo(()=>E?{rangeMin:0,rangeMax:v.length-1}:{rangeMin:J(t,r),rangeMax:J(t,n)},[E,v,t,U,A]),q=e.mode==="point",se=a.useCallback(i=>{if(E){const d=Math.max(0,Math.min(v.length-1,Math.round(i)));return v[d]}return ce(t,Math.round(i))},[E,v,t]),W=a.useCallback(i=>{if(i===void 0)return V;const d=qe(t,i);return E?fe(v,d,t):J(t,d)},[E,v,t,V]),[G,_]=a.useState(()=>$===null?null:$.selection);let F=G??($===null?null:$.selection);if(Y&&F!==null&&F[0].getTime()!==F[1].getTime()){const i=[F[0],F[0]];F=i,_(i)}const me=e.mode==="vernier"?e.microValue?.getTime():void 0,ye=a.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,me]),le=Ta(),Pe=Ta(),R=e.mode!=="vernier"?null:Y?ye??F:e.microRange!==void 0?e.microRange:F,ee=R===null?null:Pe.shown??R,he=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ee?.[0]:void 0,De=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ee?.[1]:void 0,Me=e.mode==="point"?e.value??e.defaultValue:void 0,Oe=e.mode==="point"?Me?.getTime():he?.getTime(),We=e.mode==="range"?De?.getTime():Oe,[Ge,Z]=a.useMemo(()=>{if(e.mode==="point"){const m=W(Me);return[m,m]}const i=W(he),d=W(De);return[Math.min(i,d),Math.max(i,d)]},[e.mode,Oe,We,W,Me,he,De]),te=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:Y?e.microValue!==void 0:e.microRange!==void 0,[re,L]=a.useState(()=>[Ge,Z]),[N,T]=a.useState(null),[j,be]=a.useState(null),we=a.useRef(null),[Ee,$e]=a.useState("high"),[_e,Dt]=a.useState(null),[ft,jr]=a.useState(null),Se=N?N[0]:te?Ge:re[0],Le=N?N[1]:te?Z:re[1],Gt=a.useRef([Se,Le]),de=e.mode==="vernier",x=e.mode==="vernier"?e.vernierOrientation??(u?"macro-left":"macro-top"):"macro-top",w=x==="macro-top"||x==="macro-left",tt=e.mode==="vernier"?e.showVernierProjection??!0:!1,wr=e.mode==="vernier"?e.showVernierTicks??!0:!1,at=e.mode==="vernier"?e.showHairline??!0:!1,z=de?e.macroUnit??t:t,P=de?e.microUnit??t:t,Pn=de?e.macroIsDiscrete??!1:E,pr=de?e.microIsDiscrete??!1:E,Ro=de?e.macroAllowedDates??o:o,So=de?e.microAllowedDates??o:o,zr=de?e.formatMacroLabel??e.formatLabel:e.formatLabel,Ur=de?e.formatMicroLabel??e.formatLabel:e.formatLabel,bi=he?.getTime(),wi=De?.getTime(),[Xe,Br]=a.useState(null),vt=a.useRef(null),[Mr,Xt]=a.useState(()=>Y?"micro-point":"micro-high");let Ne=Mr;const An=Y?Mr==="micro-low"||Mr==="micro-high"||Mr==="micro-connect"?"micro-point":null:Mr==="micro-point"?"micro-high":null;An!==null&&(Ne=An,Xt(An));const Ye=a.useMemo(()=>J(z,r),[U,z]),it=a.useMemo(()=>{const i=J(z,n);if(de&&i<=Ye)throw new RangeError(`PeriodSlider: macroUnit "${z}" cannot distinguish minDate from maxDate (minDate: ${pe(r)}, maxDate: ${pe(n)})`);return i},[de,U,A,Ye,z]),Te=a.useMemo(()=>de&&Pn?Mt(Ro,z,r,n):[],[de,Pn,Ro,z,U,A]),Lo=i=>[Math.max(Ye,Math.min(it,J(z,i[0]))),Math.max(Ye,Math.min(it,J(z,i[1])))],[To,yo]=e.mode!=="vernier"?[Ye,it]:Lo(e.macroRange),[Fe,je]=le.shown===null?[To,yo]:Lo(le.shown),gt=a.useMemo(()=>ce(z,Fe),[z,Fe]),It=a.useMemo(()=>ce(z,je),[z,je]),Wr=a.useMemo(()=>e.mode!=="vernier"?[r,n]:mt(z,P,[gt,It],r,n),[e.mode,gt,It,z,P,U,A]),ve=a.useMemo(()=>J(P,Wr[0]),[P,Wr]),Ce=a.useMemo(()=>J(P,Wr[1]),[P,Wr]),Po=a.useMemo(()=>de&&pr?Mt(So,P,r,n):[],[de,pr,So,P,U,A]),En=(i,d)=>Po.filter(m=>{const h=J(P,m);return h>=i&&h<=d}),ue=a.useMemo(()=>En(ve,Ce),[Po,P,ve,Ce]),Kt=Pn&&Te.length>0,rt=pr&&ue.length>0,xt=(i,d,m,h)=>d.length>0?J(P,d[fe(d,i,P)]):Math.max(m,Math.min(h,J(P,i))),qt=rt?ue:[],Ie=a.useMemo(()=>ee===null?ve:xt(ee[0],qt,ve,Ce),[bi,ve,Ce,P,ee,qt]),ze=a.useMemo(()=>ee===null?Ce:xt(ee[1],qt,ve,Ce),[wi,ve,Ce,P,ee,qt]),Rt=a.useMemo(()=>ce(P,Ie),[P,Ie]),St=a.useMemo(()=>ce(P,ze),[P,ze]),Ao=!de||R===null?null:{macroUnit:z,macroLowEnc:To,macroHighEnc:yo,microUnit:P,microLowEnc:J(P,R[0]),microHighEnc:J(P,R[1])},Cn=a.useRef(Ao),Gr=Math.max(1,it-Ye),nt=Kt?cn(Te,z,s,gt):Math.max(0,Math.min(1,(Fe-Ye)/Gr)),st=Math.max(nt,Kt?cn(Te,z,s,It):Math.min(1,(je-Ye)/Gr)),Xr=Math.max(1,Ce-ve),Zt=rt?cn(ue,P,s,Rt):Math.max(0,Math.min(1,(Ie-ve)/Xr)),Dr=Math.max(Zt,rt?cn(ue,P,s,St):Math.min(1,(ze-ve)/Xr)),$n=a.useRef({timerId:null,emit:null}),Kr=a.useRef({timerId:null,emit:null}),qr=a.useRef({timerId:null,emit:null});a.useEffect(()=>{const i=[$n,Kr,qr];return()=>{for(const d of i)io(d.current)}},[]);const Jt=a.useCallback((i,d,m)=>{io(i);const{debounceMs:h}=X.current;if(m||!h||h<=0){d();return}i.emit=d,i.timerId=setTimeout(()=>{i.timerId=null,i.emit=null,d()},h)},[]),Eo=a.useCallback(i=>{const d=i.emit;io(i),d?.()},[]),Qt=a.useCallback(i=>new Date(Math.min(Math.max(i.getTime(),U),A)),[U,A]),Lt=a.useCallback((i,d,m=!1)=>{const[h,S]=Gt.current;if((X.current.mode==="point"?i===h:i===h&&d===S)&&$n.current.timerId===null)return;const O=se(i),k=se(d),oe=()=>{const ge=X.current;ge.mode==="point"?ge.onChangePoint?.(O):ge.mode==="range"&&ge.onChangeRange?.(O,k)};Jt($n.current,oe,m)},[se,Jt]),kt=a.useCallback((i,d,m=!1)=>{const h=Cn.current;if(X.current.mode!=="vernier"||h===null)return;const S=Qt(i),I=Qt(d);J(h.macroUnit,S)===h.macroLowEnc&&J(h.macroUnit,I)===h.macroHighEnc&&Kr.current.timerId===null||Jt(Kr.current,()=>{const O=X.current;O.mode==="vernier"&&O.onChangeMacroRange?.(S,I)},m)},[Qt,Jt]),Ze=a.useCallback((i,d,m=!1)=>{const h=X.current,S=Cn.current;if(h.mode!=="vernier"||S===null)return;const I=Qt(i),O=Qt(d);J(S.microUnit,I)===S.microLowEnc&&J(S.microUnit,O)===S.microHighEnc&&qr.current.timerId===null||((Y?h.microValue===void 0:h.microRange===void 0)&&_([I,O]),Jt(qr.current,()=>{const k=X.current;if(k.mode==="vernier"){if(Y){k.onChangeMicroPoint?.(I);return}k.onChangeMicroRange?.(I,O)}},m))},[Qt,Jt,Y]),Co=a.useCallback((i,d=!1)=>{Ze(i,i,d)},[Ze]),Nt=a.useCallback(i=>{if(E&&s==="time"&&v.length>1){const h=Math.max(0,Math.min(v.length-1,Math.round(i))),S=v[0].getTime(),O=v[v.length-1].getTime()-S;if(O<=0)return 0;const k=v[h].getTime();return Math.max(0,Math.min(100,(k-S)/O*100))}const d=C-V;if(d<=0)return 0;const m=(i-V)/d*100;return Math.max(0,Math.min(100,m))},[E,s,v,V,C]),In=a.useCallback(i=>{const d=Math.max(0,Math.min(100,i));if(E){if(s==="time"&&v.length>1){const S=v[0].getTime(),O=v[v.length-1].getTime()-S,k=S+d/100*O;return fe(v,new Date(k),t)}const h=Math.round(d/100*(v.length-1));return Math.max(0,Math.min(v.length-1,h))}const m=V+d/100*(C-V);return Math.round(m)},[E,s,v,V,C,t]),vr=a.useRef(null),$o=a.useRef(null),Io=a.useRef(0),Ke=a.useRef(null),kn=a.useRef(null),ko=a.useRef(null),No=a.useRef(null),[Nn,Vo]=a.useState(0),[pi,er]=fr(),[Mi,Oo]=fr(),[Di,Yo]=fr(),[vi,Ho]=fr(),[xi,Vn]=fr(),[Ri,_o]=fr(),Si=q?er===null?void 0:{estimatedWidthPx:er.widthPx,estimatedHeightPx:er.heightPx}:so(er,Oo),On=!q&&Se===Le,Yn=Fe===je,Hn=!Y&&Ie===ze,Li=w?"top":"bottom",Ti=w?"bottom":"top",Fo=b&&!u,yi=Fo&&!Y,_n={isPointMode:q,isVertical:u,autoSlantLabels:b,isMerged:On,trackLengthPx:Nn,labelPosition:M,config:Si},Fn={trackLengthPx:Nn,labelPosition:Li,config:so(Yo,Ho),isMerged:Yn,isSlantable:Fo},jn={trackLengthPx:Nn,labelPosition:Ti,config:so(Vn,_o),isMerged:Hn,isSlantable:yi};a.useEffect(()=>{const i=Ke.current;if(!i)return;const d=()=>{const h=i.getBoundingClientRect(),S=u?h.height:h.width;S>0&&Vo(I=>Math.abs(I-S)<.5?I:S)};if(d(),typeof ResizeObserver<"u"){const h=new ResizeObserver(S=>{for(const I of S){const O=u?I.contentRect.height:I.contentRect.width;O>0&&Vo(k=>Math.abs(k-O)<.5?k:O)}});return h.observe(i),()=>h.disconnect()}const m=i.ownerDocument.defaultView;if(m)return m.addEventListener("resize",d),()=>m.removeEventListener("resize",d)},[u]);const tr=a.useCallback((i,d,m)=>{const h=u?m.height:m.width;if(!(Number.isFinite(h)&&h>0))return null;const S=u?m.bottom-d:i-m.left;return Number.isFinite(S)?Math.max(0,Math.min(1,S/h)):null},[u]),jo=a.useCallback((i,d)=>{const m=Ke.current;if(!m)return null;const h=tr(i,d,m.getBoundingClientRect());return h===null?null:h*100},[tr]),xr=a.useRef(null),ht=a.useRef(null),Zr=a.useRef({macroLowRatio:nt,macroHighRatio:st,isVertical:u,isMacroFirstRail:w}),zo=a.useRef({flat:_n,macro:Fn,micro:jn});a.useLayoutEffect(()=>{Zr.current={macroLowRatio:nt,macroHighRatio:st,isVertical:u,isMacroFirstRail:w},zo.current={flat:_n,macro:Fn,micro:jn},X.current=e,Gt.current=[Se,Le],Cn.current=Ao,we.current=j,vt.current=Xe});const Uo=(i,d)=>{const m=Zr.current;kn.current?.setAttribute("d",ro(i,d,m.isVertical,m.isMacroFirstRail))},Pi=(i,d,m)=>{const h=zo.current;return i==="flat"?Ea(d*100,m*100,h.flat).placements:lo(i,d,m,i==="macro"?h.macro:h.micro).placements},Rr=(i,d,m)=>{const h=Ke.current;if(!h)return;xr.current={rail:i,lowRatio:d,highRatio:m},as(h,i,d,m);const S=Pi(i,d,m);S!==null&&os(h,i,S),i==="macro"&&Uo(d,m)},Vt=a.useCallback(()=>{ht.current!==null&&(clearTimeout(ht.current),ht.current=null);const i=Ke.current;i&&(i.removeAttribute(Qn),i.style.removeProperty(eo))},[]),Bo=()=>{const i=Ke.current;if(xr.current===null||!i){xr.current=null;return}xr.current=null,ht.current!==null&&clearTimeout(ht.current),i.style.setProperty(eo,`${Da}ms`),i.setAttribute(Qn,"true"),is(i),Uo(Zr.current.macroLowRatio,Zr.current.macroHighRatio),ht.current=setTimeout(()=>{ht.current=null,i.removeAttribute(Qn),i.style.removeProperty(eo)},Da)};a.useLayoutEffect(()=>{const i=xr.current;i!==null&&Rr(i.rail,i.lowRatio,i.highRatio)}),a.useEffect(()=>()=>{ht.current!==null&&clearTimeout(ht.current)},[]);const rr=a.useRef(null),nr=a.useRef(null),lt=a.useRef(null),zn=a.useRef(null),Sr=a.useRef(null),Tt=a.useCallback(()=>rr.current!==null||nr.current!==null,[]),Wo=i=>{if(l)return;if(de){const B=nr.current;if(!B||i.pointerId!==B.pointerId||!Ke.current)return;const ot=tr(i.clientX,i.clientY,Ke.current.getBoundingClientRect());if(ot===null)return;if(B.handle==="macro-low"||B.handle==="macro-high"||B.handle==="macro-connect"){const[ke,Ae,bt]=ai(B.handle,ot,B.startPointerRatio,B.startMacroLowRatio,B.startMacroHighRatio);Rr("macro",ke,Ae),bt!==vt.current&&(vt.current=bt,Br(bt),Xt(bt));let He,Je;if(Kt){const yt=un(Te,z,s,ke),Pt=Math.max(yt,un(Te,z,s,Ae));He=Te[yt],Je=Te[Pt]}else{const yt=Math.round(Ye+ke*Gr),Pt=Math.round(Ye+Ae*Gr);He=ce(z,yt),Je=ce(z,Pt)}le.show(He,Je);const Ar=`${He.getTime()}_${Je.getTime()}`;Ar!==zn.current&&(zn.current=Ar,kt(He,Je));const[wt,Yt]=mt(z,P,[He,Je],r,n),Zn=J(P,wt),Jn=J(P,Yt),ba=pr?En(Zn,Jn):[];let Ht,_t;if(B.handle==="macro-connect"){const yt=wt,Pt=Yt;let ur,dr;if(z==="year"){const At=He.getFullYear()-B.startMacroLowDate.getFullYear();ur=Ve("year",B.initialMicroLowDate,At),dr=Ve("year",B.initialMicroHighDate,At)}else if(z==="month"){const At=(He.getFullYear()-B.startMacroLowDate.getFullYear())*12+(He.getMonth()-B.startMacroLowDate.getMonth());ur=Ve("month",B.initialMicroLowDate,At),dr=Ve("month",B.initialMicroHighDate,At)}else{const At=Math.round((He.getTime()-B.startMacroLowDate.getTime())/864e5);ur=Ve("day",B.initialMicroLowDate,At),dr=Ve("day",B.initialMicroHighDate,At)}const mr=yt.getTime(),Er=Pt.getTime(),Ma=B.initialMicroHighDate.getTime()-B.initialMicroLowDate.getTime();let Cr=ur.getTime(),$r=dr.getTime();Cr<mr&&(Cr=mr,$r=Math.min(Er,Cr+Ma)),$r>Er&&($r=Er,Cr=Math.max(mr,$r-Ma)),Ht=qe(P,new Date(Cr)),_t=qe(P,new Date($r))}else{const yt=wt.getTime(),Pt=Yt.getTime(),ur=B.initialMicroLowDate.getTime(),dr=B.initialMicroHighDate.getTime(),mr=Math.max(yt,Math.min(Pt,ur)),Er=Math.max(mr,Math.min(Pt,dr));Ht=qe(P,new Date(mr)),_t=qe(P,new Date(Er))}const wa=xt(Ht,ba,Zn,Jn),ts=Math.max(wa,xt(_t,ba,Zn,Jn));Ht=ce(P,wa),_t=ce(P,ts),Pe.show(Ht,_t);const pa=`${Ht.getTime()}_${_t.getTime()}`;pa!==Sr.current&&(Sr.current=pa,Ze(Ht,_t))}else if(B.handle==="micro-low"||B.handle==="micro-high"||B.handle==="micro-connect"||B.handle==="micro-point"){const[ke,Ae,bt]=ii(B.handle,ot,B.startPointerRatio,B.startMicroLowRatio,B.startMicroHighRatio);Rr("micro",ke,Ae),bt!==vt.current&&(vt.current=bt,Br(bt),Xt(bt));let He,Je;if(rt){const wt=un(ue,P,s,ke),Yt=Math.max(wt,un(ue,P,s,Ae));He=ue[wt],Je=ue[Yt]}else{const wt=xt(ce(P,Math.round(ve+ke*Xr)),qt,ve,Ce),Yt=Math.max(wt,xt(ce(P,Math.round(ve+Ae*Xr)),qt,ve,Ce));He=ce(P,wt),Je=ce(P,Yt)}Pe.show(He,Je);const Ar=`${He.getTime()}_${Je.getTime()}`;Ar!==Sr.current&&(Sr.current=Ar,Ze(He,Je))}return}const d=rr.current;if(!d||i.pointerId!==d.pointerId||!Ke.current)return;const m=Ke.current.getBoundingClientRect(),h=u?i.clientY:i.clientX,S=u?m.height:m.width;if(!(Number.isFinite(S)&&S>0))return;if(d.handle==="connect"){const B=u?(d.startPointerPos-h)/S:(h-d.startPointerPos)/S,[ot,ke]=Mo(B,d.startLowRatio,d.startHighRatio);Rr("flat",ot,ke);const Ae=qa({posDiffPct:B,startLowVal:d.startLowVal,startHighVal:d.startHighVal,rangeMin:V,rangeMax:C,isDiscrete:E,sortedAllowedDates:v,snapMode:s,unit:t});if(lt.current&<.current[0]===Ae[0]&<.current[1]===Ae[1])return;lt.current=Ae,T(Ae),Lt(Ae[0],Ae[1],!1);return}const I=tr(i.clientX,i.clientY,m);if(I===null)return;const[O,k]=wn(q?"point":d.handle,I,d.startLowRatio,d.startHighRatio);Rr("flat",O,k);const oe=In(I*100),[ge,xe]=ho(d.handle,oe,d.startLowVal,d.startHighVal,V,C,q);if((!lt.current||lt.current[0]!==ge||lt.current[1]!==xe)&&(lt.current=[ge,xe],T([ge,xe]),Lt(ge,xe,!1)),!q&&(d.handle==="low"||d.handle==="high")){const B=Ln(d.handle,I,d.startLowRatio,d.startHighRatio);we.current!==B&&(we.current=B,be(B),$e(B))}},Go=()=>{Bo(),zn.current=null,Sr.current=null,nr.current=null,vt.current=null,Br(null),le.release(),Pe.release(),Eo(Kr.current),Eo(qr.current)},Xo=()=>{Bo();const i=lt.current??N;i&&(Lt(i[0],i[1],!0),L(i)),lt.current=null,T(null),rr.current=null,we.current=null,be(null)},Ko=i=>{if(de){const m=nr.current;if(!m||i.pointerId!==m.pointerId)return;Go();return}const d=rr.current;!d||i.pointerId!==d.pointerId||Xo()},qo=()=>{nr.current!==null&&Go(),rr.current!==null&&Xo()},Un=a.useRef(Wo),Zo=a.useRef(Ko),Jo=a.useRef(qo);a.useLayoutEffect(()=>{Un.current=Wo,Zo.current=Ko,Jo.current=qo});const Qo=a.useRef(de);a.useEffect(()=>{Qo.current!==de&&(Qo.current=de,Jo.current())},[de]);const ea=j!==null||Xe!==null;a.useEffect(()=>{if(!ea)return;const i=vr.current?.ownerDocument.defaultView;if(!i)return;const d=h=>Un.current(h),m=h=>Zo.current(h);return i.addEventListener("pointermove",d),i.addEventListener("pointerup",m),i.addEventListener("pointercancel",m),i.addEventListener("lostpointercapture",m),()=>{i.removeEventListener("pointermove",d),i.removeEventListener("pointerup",m),i.removeEventListener("pointercancel",m),i.removeEventListener("lostpointercapture",m)}},[ea]);const Bn=a.useCallback((i,d,m,h)=>{Vt(),Ia(i,d),rr.current={pointerId:d,handle:m,startPointerPos:h,startLowVal:Se,startHighVal:Le,startLowRatio:Nt(Se)/100,startHighRatio:Nt(Le)/100},we.current=m,be(m),m!=="connect"&&$e(m)},[Se,Le,Nt]),ta=a.useCallback((i,d,m,h)=>{X.current.mode==="vernier"&&(Vt(),Ia(i,d),nr.current={pointerId:d,handle:m,startPointerRatio:h,startMacroLowRatio:nt,startMacroHighRatio:st,startMicroLowRatio:Zt,startMicroHighRatio:Dr,startMacroLowDate:gt,initialMicroLowDate:Rt,initialMicroHighDate:St},vt.current=m,Br(m),Xt(m))},[nt,st,Zt,Dr,gt,Rt,St]),ra=i=>d=>{if(l||Tt())return;d.stopPropagation(),d.preventDefault(),$e(i);const m=u?d.clientY:d.clientX;Bn(d.currentTarget,d.pointerId,i,m)},na=i=>()=>{l||we.current!==null||$e(i)},Jr=i=>()=>{l||vt.current!==null||Xt(i)},or=i=>d=>{if(l||Tt())return;d.stopPropagation(),d.preventDefault();const m=Ke.current;if(!m)return;const h=tr(d.clientX,d.clientY,m.getBoundingClientRect());h!==null&&ta(d.currentTarget,d.pointerId,i,h)},Ai=i=>{if(l||D||Tt())return;i.stopPropagation(),i.preventDefault();const d=u?i.clientY:i.clientX;Bn(i.currentTarget,i.pointerId,"connect",d)},Ei=i=>{if(l||Tt())return;if(de){const k=Ke.current;if(!k)return;const oe=k.getBoundingClientRect(),ge=tr(i.clientX,i.clientY,oe);if(ge===null)return;const xe=u?i.clientX-(oe.left+oe.width/2):i.clientY-(oe.top+oe.height/2),B=oi(ge,xe,nt,st,Zt,Dr,x,void 0,!D,Y?"point":"range");ta(i.currentTarget,i.pointerId,B,ge),Un.current(i.nativeEvent);return}const d=jo(i.clientX,i.clientY);if(d===null)return;const m=In(d);let h="low";if(!q){const k=Math.abs(m-Se),oe=Math.abs(m-Le);k<oe?h="low":oe<k?h="high":h=m>Le?"high":"low"}$e(h);const[S,I]=ho(h,m,Se,Le,V,C,q);T([S,I]),Lt(S,I,!0);const O=u?i.clientY:i.clientX;Bn(i.currentTarget,i.pointerId,h,O)},Ci=i=>{if(l||de||j!==null)return;const d=jo(i.clientX,i.clientY);if(d===null)return;const m=In(d);Dt(m),jr(Nt(m))},$i=()=>{Dt(null),jr(null)},oa=i=>d=>{if(l||Tt())return;$e(i);const m=Za(d.key,i,Se,Le,V,C,q,1);m&&(d.preventDefault(),Vt(),te||L(m),Lt(m[0],m[1],!0))},ar=(i,d)=>{if(R===null)return;const[m,h]=mt(z,P,[i,d],r,n),S=J(P,m),I=J(P,h),O=pr?En(S,I):[],k=xt(R[0],O,S,I),oe=Math.max(k,xt(R[1],O,S,I));Ze(ce(P,k),ce(P,oe),!0)},Qr=i=>d=>{if(l||!de||e.mode!=="vernier"||Tt())return;Xt(i);let m=0,h=!1,S=!1;switch(d.key){case"ArrowRight":case"ArrowUp":m=1;break;case"ArrowLeft":case"ArrowDown":m=-1;break;case"PageUp":m=5;break;case"PageDown":m=-5;break;case"Home":h=!0;break;case"End":S=!0;break;default:return}if(d.preventDefault(),Vt(),i==="macro-low"){const I=ce(z,Fe),O=ce(z,je);if(Kt){const ge=kr(Te,z,I,Te[0],O,m,h,S);if(ge===fe(Te,I,z))return;const xe=Te[ge];kt(xe,O,!0),ar(xe,O);return}let k;if(h?k=Ye:S?k=je:k=Math.max(Ye,Math.min(je,Fe+m)),k===Fe)return;const oe=ce(z,k);kt(oe,O,!0),ar(oe,O)}else if(i==="macro-high"){const I=ce(z,Fe),O=ce(z,je);if(Kt){const ge=kr(Te,z,O,I,Te[Te.length-1],m,h,S);if(ge===fe(Te,O,z))return;const xe=Te[ge];kt(I,xe,!0),ar(I,xe);return}let k;if(h?k=Fe:S?k=it:k=Math.max(Fe,Math.min(it,je+m)),k===je)return;const oe=ce(z,k);kt(I,oe,!0),ar(I,oe)}else if(i==="micro-low"){const I=ce(P,Ie),O=ce(P,ze);if(rt){const oe=kr(ue,P,I,ue[0],O,m,h,S);if(oe===fe(ue,I,P))return;Ze(ue[oe],O,!0);return}let k;if(h?k=ve:S?k=ze:k=Math.max(ve,Math.min(ze,Ie+m)),k===Ie)return;Ze(ce(P,k),O,!0)}else if(i==="micro-high"){const I=ce(P,Ie),O=ce(P,ze);if(rt){const oe=kr(ue,P,O,I,ue[ue.length-1],m,h,S);if(oe===fe(ue,O,P))return;Ze(I,ue[oe],!0);return}let k;if(h?k=Ie:S?k=Ce:k=Math.max(Ie,Math.min(Ce,ze+m)),k===ze)return;Ze(I,ce(P,k),!0)}else if(i==="micro-point"){const I=ce(P,Ie);if(rt){const k=kr(ue,P,I,ue[0],ue[ue.length-1],m,h,S);if(k===fe(ue,I,P))return;Co(ue[k],!0);return}let O;if(h?O=ve:S?O=Ce:O=Math.max(ve,Math.min(Ce,Ie+m)),O===Ie)return;Co(ce(P,O),!0)}},Ii=i=>{if(e.mode!=="vernier")return;if(Vt(),Kt){const O=Te.length-1,k=fe(Te,gt,z),oe=fe(Te,It,z),ge=oe-k;let xe=k+i,B=oe+i;if(i<0&&xe<0?(xe=0,B=Math.min(O,ge)):i>0&&B>O&&(B=O,xe=Math.max(0,O-ge)),xe===k&&B===oe)return;const ot=Te[xe],ke=Te[B];kt(ot,ke,!0),ar(ot,ke);return}const d=je-Fe;let m=Fe+i,h=je+i;if(i<0&&m<Ye?(m=Ye,h=Math.min(it,m+d)):i>0&&h>it&&(h=it,m=Math.max(Ye,h-d)),m===Fe&&h===je)return;const S=ce(z,m),I=ce(z,h);kt(S,I,!0),ar(S,I)},Wn=a.useCallback(i=>{const d=X.current;if(!(d.disabled||Tt()))if(Vt(),d.mode==="point"){const m=Math.max(V,Math.min(C,Se+i));te||L([m,m]),Lt(m,m,!0)}else if(d.mode==="vernier"){if(rt){const ge=ue.length-1,xe=fe(ue,Rt,P),B=fe(ue,St,P),ot=B-xe;let ke=xe+i,Ae=B+i;i<0&&ke<0?(ke=0,Ae=Math.min(ge,ot)):i>0&&Ae>ge&&(Ae=ge,ke=Math.max(0,ge-ot)),(ke!==xe||Ae!==B)&&Ze(ue[ke],ue[Ae],!0);return}const m=Ie,h=ze,S=ve,I=Ce,O=h-m;let k=m+i,oe=h+i;i<0&&k<S?(k=S,oe=Math.min(I,k+O)):i>0&&oe>I&&(oe=I,k=Math.max(S,oe-O)),(k!==m||oe!==h)&&Ze(ce(P,k),ce(P,oe),!0)}else{const m=Le-Se;let h=Se+i,S=Le+i;i<0&&h<V?(h=V,S=Math.min(C,h+m)):i>0&&S>C&&(S=C,h=Math.max(V,S-m)),h<=S&&(te||L([h,S]),Lt(h,S,!0))}},[Se,Le,V,C,te,Lt,Ze,Ie,ze,ve,Ce,P,rt,ue,Rt,St,Vt]),aa=i=>!l&&no(vr.current,i),ia=(i,d)=>{const m=$o.current,h=Ke.current,S=vr.current;if(l||m===null||h===null||S===null||!ms(m,S,Io.current,u,i,d))return null;const I=h.getBoundingClientRect();return Math.abs(u?i-(I.left+I.width/2):d-(I.top+I.height/2))},sa=i=>{if(l||Tt())return;const d=ni(i.deltaX,i.deltaY,u);if(d===0)return;i.preventDefault();const m=i.target,h=no(ko.current,m)||no(No.current,m);if(!de||h){Wn(d);return}const S=Ke.current;if(!S)return;const I=S.getBoundingClientRect(),O=u?i.clientX-(I.left+I.width/2):i.clientY-(I.top+I.height/2);if(xo(O,x)==="macro"){Ii(d);return}Wn(d)},en=a.useRef({ownsWheelHit:aa,distanceToRailPx:ia,stepFromRangeAreaWheel:sa});a.useLayoutEffect(()=>{en.current={ownsWheelHit:aa,distanceToRailPx:ia,stepFromRangeAreaWheel:sa}});const Lr=a.useRef(null);a.useEffect(()=>{const i=vr.current?.ownerDocument.defaultView??null,d=Lr.current;if(d!==null&&d.view===i)return;if(d?.unregister(),i===null){Lr.current=null;return}const m=gs(i,{ownsHit:h=>en.current.ownsWheelHit(h),distanceToRailPx:(h,S)=>en.current.distanceToRailPx(h,S),step:h=>en.current.stepFromRangeAreaWheel(h)});Lr.current={view:i,unregister:m}}),a.useEffect(()=>()=>{Lr.current?.unregister(),Lr.current=null},[]);const tn=Nt(Se),rn=Nt(Le),Gn=se(Se),Xn=se(Le),Kn=Ea(tn,rn,_n),Tr=Kn.slant,yr=j==="low"||j!=="high"&&Ee==="low",Pr=!q&&(j==="high"||j!=="low"&&Ee==="high"),ki=Yn&&Ne!=="macro-low",Ni=Yn&&Ne==="macro-low",Vi=Hn&&Ne!=="micro-low",Oi=Hn&&Ne==="micro-low",ir=lo("macro",nt,st,Fn),sr=lo("micro",Zt,Dr,jn),Yi=Math.min(tn,rn),Hi=Math.max(tn,rn),[la,ca]=Hr.flat,[_i,Fi]=Hr.macro,[ji,zi]=Hr.micro,ua=Et(la,tn),da=Et(ca,rn),qn=Et(la,Yi),ma=`calc(${Et(ca,Hi)} - ${qn})`,lr=Et(_i,nt*100),nn=Et(Fi,st*100),cr=Et(ji,Zt*100),on=Et(zi,Dr*100),Ui=u?{bottom:qn,height:ma,top:"auto",left:"0",right:"0"}:{left:qn,width:ma,top:"0",bottom:"0"},Bi=Math.max(.01,st-nt),fa=Math.max(.06,Math.min(.25,.28*Math.sqrt(Bi))),Wi=u?{bottom:ua,left:"50%",transform:"translate(-50%, 50%)",zIndex:yr?40:30}:{left:ua,top:"50%",transform:"translate(-50%, -50%)",zIndex:yr?40:30},Gi=u?{bottom:da,left:"50%",transform:"translate(-50%, 50%)",zIndex:Pr?40:30}:{left:da,top:"50%",transform:"translate(-50%, -50%)",zIndex:Pr?40:30},Xi=u?{bottom:`${ft}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${ft}%`,top:"50%",transform:"translate(-50%, -50%)"},ga=_e!==null?se(_e):null,Ki=g!=="hover"&&_e!==null&&(_e===Se||!q&&_e===Le),qi=rt?J(P,ue[0]):ve,Zi=rt?J(P,ue[ue.length-1]):Ce,Ji=de?Ie>qi:Se>V,Qi=de?ze<Zi:Le<C,an=Cs(de?[{side:w?"before":"after",box:gn(Yo,Ho),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:ir.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:ir.slant.lowOffsetX}},{side:w?"after":"before",box:Y?Vn:gn(Vn,_o),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:sr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:sr.slant.lowOffsetX}}]:[{side:u||M==="top"?"before":"after",box:q?er:gn(er,Oo),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:Tr.lowAngleDeg,centreOffsetPx:Tr.lowOffsetY,alongPushPx:Tr.lowOffsetX}}]),es=an===void 0?e.style:{...e.style,...an.style};a.useLayoutEffect(()=>{Io.current=an===void 0?0:an.mainPx});const ct=Y?"micro-point":"micro-low",Ot=l?"cursor-not-allowed opacity-50":"cursor-pointer",ha=i=>{const d=u?"vertical":"horizontal",m=i==="decrease",h=u?!m:m;return p.jsx(Wt,{ref:m?ko:No,neighbour:"rail",direction:$s[d][i],disabled:l,canStep:m?Ji:Qi,onStep:()=>Wn(m?-1:1),ariaLabel:m?ae:ne,className:`period-slider-stepper-btn ${Is[d][i]} ${$a[d][h?"leading":"trailing"]}`})};return p.jsxs("div",{ref:vr,style:es,className:`period-slider grid select-none place-items-center ${ks[u?"vertical":"horizontal"][f?"withSteppers":"railOnly"]} ${c}`,"data-disabled":l?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":u?"vertical":"horizontal","data-label-position":M,"data-color-scheme":Q,children:[p.jsx("div",{ref:$o,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),f&&ha(u?"increase":"decrease"),p.jsx("div",{ref:Ke,"data-testid":"period-slider-track","data-orientation":u?"vertical":"horizontal","data-vernier-orientation":de?x:void 0,className:`period-slider-track relative touch-none rounded-full ${$a[u?"vertical":"horizontal"][f?"rail":"railOnly"]} ${Ot}`,onPointerDown:Ei,onPointerMove:Ci,onPointerLeave:$i,children:de?p.jsxs(p.Fragment,{children:[tt&&(u?p.jsxs("svg",{className:"period-slider-vernier-projection is-vertical",role:"presentation","aria-hidden":"true",width:"32",height:"100%",viewBox:"0 0 32 100",preserveAspectRatio:"none",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"1",y2:"0",children:[p.jsx("stop",{offset:"0%",stopColor:w?H.macro:H.micro,stopOpacity:"0.28"}),p.jsx("stop",{offset:"100%",stopColor:w?H.micro:H.macro,stopOpacity:fa})]})}),p.jsx("path",{ref:kn,"data-testid":"period-slider-vernier-projection",d:ro(nt,st,u,w),fill:`url(#${ie})`})]}):p.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"0",y2:"1",children:[p.jsx("stop",{offset:"0%",stopColor:w?H.macro:H.micro,stopOpacity:"0.28"}),p.jsx("stop",{offset:"100%",stopColor:w?H.micro:H.macro,stopOpacity:fa})]})}),p.jsx("path",{ref:kn,"data-testid":"period-slider-vernier-projection",d:ro(nt,st,u,w),fill:`url(#${ie})`})]})),!D&&p.jsxs(p.Fragment,{children:[p.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:u?{bottom:`calc(${lr} - 8px)`,height:`calc(${nn} - ${lr} + 16px)`}:{left:`calc(${lr} - 8px)`,width:`calc(${nn} - ${lr} + 16px)`},onPointerDown:or("macro-connect")}),!Y&&p.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:u?{bottom:`calc(${cr} - 8px)`,height:`calc(${on} - ${cr} + 16px)`}:{left:`calc(${cr} - 8px)`,width:`calc(${on} - ${cr} + 16px)`},onPointerDown:or("micro-connect")})]}),wr&&p.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(i=>p.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:u?{bottom:`${i*100}%`}:{left:`${i*100}%`}},`macro-tick-${i}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(i=>p.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:u?{bottom:`${i*100}%`}:{left:`${i*100}%`}},`micro-tick-${i}`))]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":l?"true":void 0,"aria-valuemin":Ye,"aria-valuemax":je,"aria-valuenow":Fe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(gt,z):Ft(z,gt,zr,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:lr,left:w?0:"auto",right:w?"auto":0,transform:w?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Xe==="macro-low"||Ne==="macro-low"?30:15}:{left:lr,top:w?0:"auto",bottom:w?"auto":0,transform:w?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Xe==="macro-low"||Ne==="macro-low"?30:15},onPointerDown:or("macro-low"),onKeyDown:Qr("macro-low"),onFocus:Jr("macro-low"),"data-active":Xe==="macro-low"?"true":void 0,"data-front":Ne==="macro-low"?"true":void 0,"data-vernier-pos":u?w?"left":"right":w?"top":"bottom","data-handle-type":"macro-low",children:[p.jsx(Yr,{type:"macro",isTop:w,isVertical:u,isLeft:w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":ki?"true":void 0,"data-slanted":ir.slant.isSlanted?"true":void 0,ref:Di,style:ir.lowStyle,children:Ue(z,gt,zr,y)})]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":l?"true":void 0,"aria-valuemin":Fe,"aria-valuemax":it,"aria-valuenow":je,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(It,z):Ft(z,It,zr,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:nn,left:w?0:"auto",right:w?"auto":0,transform:w?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Xe==="macro-high"||Ne==="macro-high"?30:15}:{left:nn,top:w?0:"auto",bottom:w?"auto":0,transform:w?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Xe==="macro-high"||Ne==="macro-high"?30:15},onPointerDown:or("macro-high"),onKeyDown:Qr("macro-high"),onFocus:Jr("macro-high"),"data-active":Xe==="macro-high"?"true":void 0,"data-front":Ne==="macro-high"?"true":void 0,"data-vernier-pos":u?w?"left":"right":w?"top":"bottom","data-handle-type":"macro-high",children:[p.jsx(Yr,{type:"macro",isTop:w,isVertical:u,isLeft:w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Ni?"true":void 0,"data-slanted":ir.slant.isSlanted?"true":void 0,ref:vi,style:ir.highStyle,children:Ue(z,It,zr,y)})]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":Y?e.pointAriaLabel??"Micro selected date":e.lowerAriaLabel??"Micro range start","aria-disabled":l?"true":void 0,"aria-valuemin":ve,"aria-valuemax":Y?Ce:ze,"aria-valuenow":Ie,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Rt,P):Ft(P,Rt,Ur,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:cr,left:w?"auto":0,right:w?0:"auto",transform:w?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Xe===ct||Ne===ct?30:20}:{left:cr,top:w?"auto":0,bottom:w?0:"auto",transform:w?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Xe===ct||Ne===ct?30:20},onPointerDown:or(ct),onKeyDown:Qr(ct),onFocus:Jr(ct),"data-active":Xe===ct?"true":void 0,"data-front":Ne===ct?"true":void 0,"data-vernier-pos":u?w?"right":"left":w?"bottom":"top","data-handle-type":ct,children:[p.jsx(Yr,{type:"micro",isTop:!w,isVertical:u,isLeft:!w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Vi?"true":void 0,"data-slanted":sr.slant.isSlanted?"true":void 0,ref:xi,style:sr.lowStyle,children:Ue(P,Rt,Ur,y)})]}),!Y&&p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":l?"true":void 0,"aria-valuemin":Ie,"aria-valuemax":Ce,"aria-valuenow":ze,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(St,P):Ft(P,St,Ur,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:on,left:w?"auto":0,right:w?0:"auto",transform:w?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Xe==="micro-high"||Ne==="micro-high"?30:20}:{left:on,top:w?"auto":0,bottom:w?0:"auto",transform:w?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Xe==="micro-high"||Ne==="micro-high"?30:20},onPointerDown:or("micro-high"),onKeyDown:Qr("micro-high"),onFocus:Jr("micro-high"),"data-active":Xe==="micro-high"?"true":void 0,"data-front":Ne==="micro-high"?"true":void 0,"data-vernier-pos":u?w?"right":"left":w?"bottom":"top","data-handle-type":"micro-high",children:[p.jsx(Yr,{type:"micro",isTop:!w,isVertical:u,isLeft:!w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Oi?"true":void 0,"data-slanted":sr.slant.isSlanted?"true":void 0,ref:Ri,style:sr.highStyle,children:Ue(P,St,Ur,y)})]})]}):p.jsxs(p.Fragment,{children:[!D&&p.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Ui,onPointerDown:Ai}),K&&E&&v.length>1&&p.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:v.map((i,d)=>{const m=J(t,i),h=Nt(d),S=u?{bottom:`${h}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${h}%`,top:"50%",transform:"translate(-50%, -50%)"};return p.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:S},`tick-${m}`)})}),!l&&_e!==null&&ft!==null&&j===null&&ga&&p.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Xi,children:[p.jsx("div",{"data-testid":"period-slider-hover-dot",className:"period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-[var(--aqps-accent-light)] shadow-[0_0_6px_var(--aqps-accent-glow)] dark:border-slate-800"}),p.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Ki?"true":void 0,className:`period-slider-hover-tooltip ${M==="bottom"&&!u?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:Ue(t,ga,e.formatLabel,y)})]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":q?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":l?"true":void 0,"aria-valuemin":V,"aria-valuemax":q?C:Le,"aria-valuenow":Se,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Gn,t):Ft(t,Gn,e.formatLabel,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Ot}`,style:Wi,onPointerDown:ra("low"),onKeyDown:oa("low"),onFocus:na("low"),"data-active":j==="low"?"true":void 0,"data-front":yr?"true":void 0,children:[p.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${j==="low"?"":"shadow-md"}`}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":M,"data-slanted":Tr.isSlanted?"true":void 0,"data-front":yr?"true":void 0,"data-duplicate":On&&!yr?"true":void 0,ref:pi,style:Kn.lowStyle,children:Ue(t,Gn,e.formatLabel,y)})]}),!q&&p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":l?"true":void 0,"aria-valuemin":Se,"aria-valuemax":C,"aria-valuenow":Le,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Xn,t):Ft(t,Xn,e.formatLabel,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Ot}`,style:Gi,onPointerDown:ra("high"),onKeyDown:oa("high"),onFocus:na("high"),"data-active":j==="high"?"true":void 0,"data-front":Pr?"true":void 0,children:[p.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${j==="high"?"":"shadow-md"}`}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":M,"data-slanted":Tr.isSlanted?"true":void 0,"data-front":Pr?"true":void 0,"data-duplicate":On&&!Pr?"true":void 0,ref:Mi,style:Kn.highStyle,children:Ue(t,Xn,e.formatLabel,y)})]})]})}),f&&ha(u?"decrease":"increase")]})},co=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r].getTime()!==t[r].getTime())return!1;return!0},si=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(e[o]!==t[o])return!1;return!0},Vs=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.minDate.getTime()!==t.minDate.getTime()||e.maxDate.getTime()!==t.maxDate.getTime()||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.isVertical!==t.isVertical||e.hideConnectBar!==t.hideConnectBar||e.showTicks!==t.showTicks||e.disabled!==t.disabled||e.showStepper!==t.showStepper||e.debounceMs!==t.debounceMs||e.tooltipStyle!==t.tooltipStyle||e.colorScheme!==t.colorScheme||e.className!==t.className||!si(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.locale!==t.locale||e.lowerAriaLabel!==t.lowerAriaLabel||e.upperAriaLabel!==t.upperAriaLabel||e.pointAriaLabel!==t.pointAriaLabel||e.macroLowerAriaLabel!==t.macroLowerAriaLabel||e.macroUpperAriaLabel!==t.macroUpperAriaLabel||e.decreaseAriaLabel!==t.decreaseAriaLabel||e.increaseAriaLabel!==t.increaseAriaLabel||e.formatAriaValueText!==t.formatAriaValueText||!co(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!((e.value?.getTime()??null)!==(t.value?.getTime()??null)||(e.defaultValue?.getTime()??null)!==(t.defaultValue?.getTime()??null)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!((e.range?.[0]?.getTime()??null)!==(t.range?.[0]?.getTime()??null)||(e.range?.[1]?.getTime()??null)!==(t.range?.[1]?.getTime()??null)||(e.defaultRange?.[0]?.getTime()??null)!==(t.defaultRange?.[0]?.getTime()??null)||(e.defaultRange?.[1]?.getTime()??null)!==(t.defaultRange?.[1]?.getTime()??null)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!((e.microRange?.[0]?.getTime()??null)!==(t.microRange?.[0]?.getTime()??null)||(e.microRange?.[1]?.getTime()??null)!==(t.microRange?.[1]?.getTime()??null)||(e.defaultMicroRange?.[0]?.getTime()??null)!==(t.defaultMicroRange?.[0]?.getTime()??null)||(e.defaultMicroRange?.[1]?.getTime()??null)!==(t.defaultMicroRange?.[1]?.getTime()??null)||(e.microValue?.getTime()??null)!==(t.microValue?.getTime()??null)||(e.defaultMicroValue?.getTime()??null)!==(t.defaultMicroValue?.getTime()??null)||e.macroRange[0].getTime()!==t.macroRange[0].getTime()||e.macroRange[1].getTime()!==t.macroRange[1].getTime()||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.macroUnit!==t.macroUnit||e.microUnit!==t.microUnit||e.macroIsDiscrete!==t.macroIsDiscrete||e.microIsDiscrete!==t.microIsDiscrete||e.formatMacroLabel!==t.formatMacroLabel||e.formatMicroLabel!==t.formatMicroLabel||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMicroPoint!==t.onChangeMicroPoint||e.onChangeMacroRange!==t.onChangeMacroRange||!co(e.macroAllowedDates,t.macroAllowedDates)||!co(e.microAllowedDates,t.microAllowedDates)):!1,li=a.memo(Ns,Vs);li.displayName="PeriodSlider";const ci=864e5,Os=4,Ys=6,ka=2,Re=-1,hn=e=>{const t=e.getFullYear(),r=new Date(Date.UTC(t,e.getMonth(),e.getDate()));return r.setUTCFullYear(t),Math.floor(r.getTime()/ci)},ui=e=>{const t=new Date(e*ci),r=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return r.setFullYear(t.getUTCFullYear()),r.setHours(0,0,0,0),r},Ut=e=>{const t=e.getFullYear();return`${t>=0?String(t).padStart(Os,"0"):`-${String(-t).padStart(Ys,"0")}`}-${String(e.getMonth()+1).padStart(ka,"0")}-${String(e.getDate()).padStart(ka,"0")}`},Hs=(e,t,r)=>{const n=hn(e),o=hn(t),s=o>=n?o-n+1:0,l=c=>ui(o-c);return{count:s,dateAt:l,valueAt:c=>Ut(l(c)),labelAt:c=>Ue("day",l(c),void 0,r),indexOf:c=>{const f=hn(c);return f<n||f>o?Re:o-f}}},_s=(e,t,r,n)=>{const o=r>=t?r-t+1:0,s=l=>e[r-l];return{count:o,dateAt:s,valueAt:l=>Ut(s(l)),labelAt:l=>Ue("day",s(l),void 0,n),indexOf:l=>{const c=l.getTime();let f=t,g=r;for(;f<=g;){const M=f+g>>1,b=e[M].getTime();if(b===c)return r-M;b<c?f=M+1:g=M-1}return Re}}},Fs={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},valueAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},indexOf:()=>Re},js=(e,t,r)=>{const n=c=>{let f=0,g=e.length;for(;f<g;){const M=f+g>>1;e[M].getTime()<c?f=M+1:g=M}return f},o=c=>{let f=0,g=e.length;for(;f<g;){const M=f+g>>1;e[M].getTime()<=c?f=M+1:g=M}return f},s=t===null?0:n(t.getTime()),l=(r===null?e.length:o(r.getTime()))-1;return{loIndex:s,hiIndex:l}},Na=(e,t,r,n,o)=>{let s=t,l=r,c=null;for(;s<=l;){const f=s+l>>1,g=e[f].getTime();o===-1?g<n?(c=e[f],s=f+1):l=f-1:g>n?(c=e[f],l=f-1):s=f+1}return c},zs=(e,t)=>{const r=new Map;return e.forEach((n,o)=>{t(o,n);const s=new Date(n);s.setHours(0,0,0,0);const l=s.getTime();r.has(l)||r.set(l,s)}),Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},bn=44,Va=7,dn=8,Us=2,di=10,Bs=1e3,wo=8,uo=6,mo=4,fo=12,Nr=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),hn(r)},Ws=(e,t)=>{if(e.length<mo||t.count===0)return Re;const r=Number(e.slice(0,mo));if(!Number.isInteger(r))return Re;const n=e.length>=uo,o=n?Number(e.slice(mo,uo)):fo;if(o<1||o>fo)return Re;const s=e.length>=wo,l=s?Number(e.slice(uo,wo)):0,c=Nr(r,o),f=(o===fo?Nr(r+1,1):Nr(r,o+1))-1,g=s?c+l-1:n?c:Nr(r,1),M=s?g:n?f:Nr(r+1,1)-1;if(s&&(l<1||g>f))return Re;for(let b=M;b>=g;b--){const u=t.indexOf(ui(b));if(u!==Re)return u}return Re},Gs=e=>e.closest(".dark")===null?"light":"dark",Xs=(e,t,r,n)=>{const o=r-e.bottom-dn,s=e.top-dn,l=o>=t||o>=s,f=Math.max(bn,Math.min(t,l?o:s)),g=l?e.bottom:e.top-f,M=e.width+di,b=Math.max(dn,Math.min(e.left,n-M-dn));return{top:g,left:b,width:M,height:f}},mi=({domain:e,selectedIndex:t,displayLabel:r,machineValue:n,disabled:o,ariaLabel:s,onCommitIndex:l,controlClassName:c})=>{const f=a.useId(),g=`period-slider-date-listbox-${f}`,M=R=>`period-slider-date-option-${f}-${R}`,[b,u]=a.useState(!1),[D,K]=a.useState(Re),[Q,y]=a.useState(!0),[ae,ne]=a.useState(null),[$,Y]=a.useState(null),H=a.useRef(null),ie=a.useRef(null),X=a.useRef(null),U=a.useRef({buffer:"",at:0}),A=a.useRef(e);A.current=e;const v=e.count,E=Math.min(v,Va)*bn,V=Math.max(1,Math.min(v,Va)),C=a.useCallback(()=>{const R=H.current;if(R===null)return;const ee=R.getBoundingClientRect();ne(Xs(ee,E,window.innerHeight,window.innerWidth))},[E]),q=a.useCallback(()=>{u(!1),K(Re),U.current={buffer:"",at:0}},[]),se=a.useCallback(R=>{o||v===0||(K(R),u(!0))},[o,v]);a.useLayoutEffect(()=>{if(!b){ne(null),Y(null);return}const R=H.current;return R!==null&&Y(Gs(R)),C(),window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[b,C]),a.useEffect(()=>{if(!b)return;const R=ee=>{const he=ee.target;he!==null&&ie.current?.contains(he)!==!0&&H.current?.contains(he)!==!0&&q()};return document.addEventListener("pointerdown",R,!0),()=>document.removeEventListener("pointerdown",R,!0)},[b,q]);const W=a.useRef(D);W.current=D,a.useEffect(()=>{if(!b)return;const R=W.current;R!==Re&&X.current?.scrollToIndex(Math.min(R,v-1),{align:"center"})},[v,b]);const G=R=>{if(v===0)return;const ee=Math.max(0,Math.min(R,v-1));K(ee),X.current?.scrollToIndex(ee,{align:"center"})},_=R=>{R<0||R>=v||(l(R),q(),H.current?.focus())},F=R=>{if(o)return;const ee=D!==Re?D:t!==Re?t:0;switch(R.key){case"ArrowDown":if(R.preventDefault(),!b){se(ee);return}G(ee+1);return;case"ArrowUp":if(R.preventDefault(),!b){se(ee);return}G(ee-1);return;case"Home":if(!b)return;R.preventDefault(),G(0);return;case"End":if(!b)return;R.preventDefault(),G(v-1);return;case"PageDown":if(!b)return;R.preventDefault(),G(ee+V);return;case"PageUp":if(!b)return;R.preventDefault(),G(ee-V);return;case"Enter":if(R.preventDefault(),!b){se(ee);return}_(D!==Re?D:ee);return;case"Escape":if(!b)return;R.preventDefault(),q();return;case"Tab":b&&q();return}if(R.key.length!==1)return;const he=R.key>="0"&&R.key<="9",De=R.key==="-"||R.key==="/"||R.key===".";if(!(he||De))return;R.preventDefault();const Me=Date.now(),Oe=Me-U.current.at>Bs?"":U.current.buffer,We=he?`${Oe}${R.key}`.slice(0,wo):Oe;U.current={buffer:We,at:Me};const Ge=Ws(We,A.current);if(Ge!==Re){if(!b){se(Ge);return}G(Ge)}},me=a.useCallback(R=>R,[]),ye=a.useCallback(()=>bn,[]),le=a.useCallback(R=>{const ee=W.current;y(ee===Re||ee>=R.renderingStartIndex&&ee<=R.renderingEndIndex)},[]),Pe=b&&ae!==null&&$!==null&&v>0?p.jsx("div",{ref:ie,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":$,style:{top:ae.top,left:ae.left,width:ae.width,height:ae.height},onMouseDown:R=>{R.preventDefault()},children:p.jsx(rs.VirtualScroll,{ref:X,itemCount:v,getItem:me,getItemHeight:ye,viewportSize:ae.height-Us,initialScrollIndex:D!==Re?D:void 0,onRangeChange:le,className:"h-full w-full",testId:"period-slider-date-listbox-pane",contentProps:{id:g,role:"listbox","aria-label":s},scrollBarOptions:{width:di,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:R=>{const ee=R===t,he=R===D;return p.jsx("div",{id:M(R),role:"option","aria-selected":ee,"aria-posinset":R+1,"aria-setsize":v,"data-testid":"period-slider-date-option","data-active":he?"true":void 0,className:"period-slider-date-option",style:{height:bn},onClick:()=>_(R),children:A.current.labelAt(R)})}})}):null;return p.jsxs(p.Fragment,{children:[p.jsx("input",{ref:H,type:"text",role:"combobox",readOnly:!0,"aria-label":s,"aria-expanded":b,"aria-controls":b?g:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":b&&D!==Re&&Q?M(D):void 0,disabled:o,value:r,className:c,"data-testid":"period-slider-date-combobox","data-value":n,onKeyDown:F,onMouseDown:R=>{o||(R.preventDefault(),H.current?.focus(),b?q():se(t!==Re?t:0))},onBlur:()=>{b&&q()}}),Pe===null?null:ns.createPortal(Pe,document.body)]})};mi.displayName="VirtualDateDropdown";const jt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Vr=(e,t)=>{if(Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},Ks=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "locale" must be a valid BCP 47 language tag (received ${JSON.stringify(e)})`)}},Bt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Oa=e=>Bt(e,1,1),qs=e=>Bt(e,12,31),Zs={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},Js={year:4,month:2,day:2},Qs={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Ya=new Map,el=(e,t)=>{const r=`${e}\0${t}`,n=Ya.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Zs[e]);return Ya.set(r,o),o},go=(e,t,r)=>r===void 0?String(Qs[e](t)).padStart(Js[e],"0"):el(e,r).format(t),tl=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:s,maxYear:l,minDate:c,maxDate:f,allowedDates:g,variant:M="date",className:b="",style:u,disabled:D=!1,prevDateAriaLabel:K="Previous day",nextDateAriaLabel:Q="Next day",selectAriaLabel:y="Date",yearAriaLabel:ae="Year",monthAriaLabel:ne="Month",dayAriaLabel:$="Day",locale:Y,formatYearOption:H,formatMonthOption:ie,formatDayOption:X}=e;if(Ks(Y),t!==void 0&&Vr("value",t),r!==void 0&&Vr("initialDate",r),c!==void 0&&Vr("minDate",c),f!==void 0&&Vr("maxDate",f),s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(s)})`);if(l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(l)})`);if(M==="split-dropdown"&&g!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const U=t??r;if(U===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");const[A,v]=a.useState(()=>jt(U)),E=t!==void 0,V=t?.getTime(),C=a.useMemo(()=>t!==void 0?jt(t):A,[V,A]),q=c?.getTime(),se=f?.getTime(),W=a.useMemo(()=>{const x=c?jt(c):null,w=s!==void 0?Oa(s):null;return x===null?w:w===null||x.getTime()>=w.getTime()?x:w},[q,s]),G=a.useMemo(()=>{const x=f?jt(f):null,w=l!==void 0?qs(l):null;return x===null?w:w===null||x.getTime()<=w.getTime()?x:w},[se,l]),_=W?.getTime()??null,F=G?.getTime()??null;if(W!==null&&G!==null&&W.getTime()>G.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Ut(W)} is after max ${Ut(G)})`);if(M!=="date"&&g===void 0&&(W===null||G===null))throw new RangeError(`DateSelector: variant="${M}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${M==="dropdown"?' or supply "allowedDates"':""}`);const me=g===void 0?null:g.map(x=>x.getTime()).join(","),ye=a.useMemo(()=>g===void 0?null:zs(g,(x,w)=>Vr(`allowedDates[${x}]`,w)),[me]),le=a.useMemo(()=>ye===null?null:{ascending:ye,...js(ye,W,G)},[ye,_,F]),Pe=a.useMemo(()=>le!==null?_s(le.ascending,le.loIndex,le.hiIndex,Y):W===null||G===null?Fs:Hs(W,G,Y),[le,_,F,Y]),R=x=>{if(le!==null)return Pe.indexOf(x)!==Re;const w=x.getTime();return!(_!==null&&w<_||F!==null&&w>F)},ee=U.getTime();a.useEffect(()=>{E||v(jt(U))},[E,ee]);const he=x=>{if(D)return;const w=jt(x);R(w)&&(E||v(w),n?.(w))},De=C.getTime(),Me=R(C),Oe=a.useMemo(()=>{if(le!==null)return Na(le.ascending,le.loIndex,le.hiIndex,De,-1);const x=$t.addDays(new Date(De),-1);return R(x)?x:null},[le,De,_,F]),We=a.useMemo(()=>{if(le!==null)return Na(le.ascending,le.loIndex,le.hiIndex,De,1);const x=$t.addDays(new Date(De),1);return R(x)?x:null},[le,De,_,F]),Ge=()=>{Oe!==null&&he(Oe)},Z=()=>{We!==null&&he(We)},te=x=>{if(x.target.value){const w=$t.parseISO(x.target.value);Number.isNaN(w.getTime())||he(w)}},re=C.getFullYear(),L=C.getMonth()+1,N=C.getDate(),T=a.useMemo(()=>{if(M!=="split-dropdown"||W===null||G===null)return[];const x=[];for(let w=G.getFullYear();w>=W.getFullYear();w--)x.push(w);return x},[M,_,F]),j=a.useMemo(()=>{if(M!=="split-dropdown"||W===null||G===null)return[];const x=W,w=G,tt=re===x.getFullYear()?x.getMonth()+1:1,wr=re===w.getFullYear()?w.getMonth()+1:12,at=[];for(let z=tt;z<=wr;z++)at.push(z);return at},[M,_,F,re]),be=a.useMemo(()=>{if(M!=="split-dropdown"||W===null||G===null)return[];const x=W,w=G,tt=re===x.getFullYear()&&L===x.getMonth()+1?x.getDate():1,wr=re===w.getFullYear()&&L===w.getMonth()+1?w.getDate():$t.getDaysInMonth(new Date(De)),at=[];for(let z=tt;z<=wr;z++)at.push(z);return at},[M,_,F,De,re,L]),we=(x,w,tt)=>tt>$t.getDaysInMonth(Bt(x,w,1))?!1:R(Bt(x,w,tt)),Ee=(x,w,tt)=>{we(x,w,tt)&&he(Bt(x,w,tt))},$e=x=>H?H(x):go("year",Oa(x),Y),_e=x=>ie?ie(x):go("month",Bt(re,x,1),Y),Dt=x=>X?X(x):go("day",Bt(re,L,x),Y),ft=Ut(C),jr=Ue("day",C,void 0,Y),Se=W?Ut(W):void 0,Le=G?Ut(G):void 0,Gt="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400";return p.jsxs("div",{className:`inline-flex items-center ${Fr} ${b}`,style:u,"data-variant":M,"data-out-of-range":Me?void 0:"true",children:[p.jsx(Wt,{neighbour:"control",direction:"left",disabled:D,canStep:Oe!==null,onStep:Ge,ariaLabel:K}),M==="dropdown"?p.jsx(mi,{domain:Pe,selectedIndex:Me?Pe.indexOf(C):Re,displayLabel:jr,machineValue:ft,disabled:D,ariaLabel:y,onCommitIndex:x=>he(Pe.dateAt(x)),controlClassName:"period-slider-date-combobox-field w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"}):M==="split-dropdown"?p.jsxs("div",{className:"inline-flex items-center gap-1",children:[p.jsxs("select",{"aria-label":ae,disabled:D,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Me?re:"",onChange:x=>Ee(Number(x.target.value),L,N),children:[Me?null:p.jsx("option",{value:"",disabled:!0,className:Gt,children:$e(re)}),T.map(x=>p.jsx("option",{value:x,disabled:!we(x,L,N),className:"dark:bg-slate-700 dark:text-slate-100",children:$e(x)},x))]}),p.jsxs("select",{"aria-label":ne,disabled:D,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Me?L:"",onChange:x=>Ee(re,Number(x.target.value),N),children:[Me?null:p.jsx("option",{value:"",disabled:!0,className:Gt,children:_e(L)}),j.map(x=>p.jsx("option",{value:x,disabled:!we(re,x,N),className:"dark:bg-slate-700 dark:text-slate-100",children:_e(x)},x))]}),p.jsxs("select",{"aria-label":$,disabled:D,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Me?N:"",onChange:x=>Ee(re,L,Number(x.target.value)),children:[Me?null:p.jsx("option",{value:"",disabled:!0,className:Gt,children:Dt(N)}),be.map(x=>p.jsx("option",{value:x,className:"dark:bg-slate-700 dark:text-slate-100",children:Dt(x)},x))]})]}):p.jsx("input",{"aria-label":y,disabled:D,className:"period-slider-native-date-field w-28 rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400",value:ft,min:Se,max:Le,onChange:te,type:"date"}),p.jsx(Wt,{neighbour:"control",direction:"right",disabled:D,canStep:We!==null,onStep:Z,ariaLabel:Q}),o]})},gr=e=>e===void 0?null:jt(e).getTime(),fi=a.memo(tl,(e,t)=>!(gr(e.value??e.initialDate)!==gr(t.value??t.initialDate)||gr(e.minDate)!==gr(t.minDate)||gr(e.maxDate)!==gr(t.maxDate)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.onChange!==t.onChange||e.allowedDates!==t.allowedDates||e.children!==t.children||e.prevDateAriaLabel!==t.prevDateAriaLabel||e.nextDateAriaLabel!==t.nextDateAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.yearAriaLabel!==t.yearAriaLabel||e.monthAriaLabel!==t.monthAriaLabel||e.dayAriaLabel!==t.dayAriaLabel||e.locale!==t.locale||e.formatYearOption!==t.formatYearOption||e.formatMonthOption!==t.formatMonthOption||e.formatDayOption!==t.formatDayOption));fi.displayName="DateSelector";function Qe(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(r,n,1);return o.setFullYear(r),o}function zt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function Or(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function Ha(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function rl(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function nl(e,t){const r=e===void 0?null:Qe(e,0),n=t===void 0?null:Qe(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function ol(e,t){const r=e===void 0?null:Qe(e,11),n=t===void 0?null:Qe(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function al(e,t,r){const n=new Map;for(const o of e){const s=Qe(o.getFullYear(),o.getMonth());t!==null&&s<t||r!==null&&s>r||n.has(s.getTime())||n.set(s.getTime(),s)}return Array.from(n.values()).sort((o,s)=>o.getTime()-s.getTime())}function il(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),o=[];for(let s=r;s<=n;s++)o.push(Qe(Math.floor(s/12),s%12));return o}function _a(e,t){const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Ue("month",e[n],void 0,t),value:zt(e[n])});return r}const sl=e=>{const{value:t,initialDate:r,onChange:n,children:o,variant:s="date",minYear:l,maxYear:c,minDate:f,maxDate:g,allowedMonths:M,isWarning:b=!1,className:u="",style:D,disabled:K=!1,prevMonthAriaLabel:Q="Previous month",nextMonthAriaLabel:y="Next month",selectAriaLabel:ae="Month",locale:ne}=e;rl(ne),Or(t,"value"),Or(r,"initialDate"),Or(f,"minDate"),Or(g,"maxDate"),Ha(l,"minYear"),Ha(c,"maxYear"),M?.forEach((T,j)=>{Or(T,`allowedMonths[${j}]`)});const $=t??r;if($===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const[Y,H]=a.useState(()=>Qe($.getFullYear(),$.getMonth())),ie=t!==void 0,X=a.useMemo(()=>t!==void 0?Qe(t.getFullYear(),t.getMonth()):Y,[t?.getTime(),Y]),U=f?.getTime(),A=g?.getTime(),v=a.useMemo(()=>nl(l,f),[l,U]),E=a.useMemo(()=>ol(c,g),[c,A]),V=v?.getTime()??null,C=E?.getTime()??null;if(v!==null&&E!==null&&v>E)throw new RangeError(`MonthSelector: the resolved lower bound ${zt(v)} is after the resolved upper bound ${zt(E)}.`);if(s==="dropdown"&&M===void 0&&(v===null||E===null))throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedMonths`; the option window is never invented.');const q=M===void 0?null:M.map(T=>T.getTime()).join(","),se=a.useMemo(()=>M===void 0?null:al(M,v,E),[q,V,C]),W=T=>{const j=T.getTime();return se!==null?se.some(be=>be.getTime()===j):!(V!==null&&j<V||C!==null&&j>C)},G=$.getTime();a.useEffect(()=>{if(ie)return;const T=Qe($.getFullYear(),$.getMonth());H(j=>j.getTime()===T.getTime()?j:T)},[ie,G]);const _=T=>{if(K)return;if(!W(T))throw new RangeError(`MonthSelector: refusing to emit ${zt(T)}, which lies outside the selectable months.`);ie||H(T);const j=T.getFullYear()*100+(T.getMonth()+1);n?.(T,j)},F=X.getTime(),me=W(X),ye=a.useMemo(()=>{if(se!==null){for(let j=se.length-1;j>=0;j--)if(se[j].getTime()<F)return se[j];return null}const T=Qe(X.getFullYear(),X.getMonth()-1);return W(T)?T:null},[se,F,V,C]),le=a.useMemo(()=>{if(se!==null){for(const j of se)if(j.getTime()>F)return j;return null}const T=Qe(X.getFullYear(),X.getMonth()+1);return W(T)?T:null},[se,F,V,C]),Pe=()=>{ye!==null&&_(ye)},R=()=>{le!==null&&_(le)},ee=T=>{if(!T)return;const[j,be]=T.split("-"),we=Number(j),Ee=Number(be)-1;if(!(Number.isInteger(we)&&Number.isInteger(Ee)))return;const $e=Qe(we,Ee);W($e)&&_($e)},he=T=>{ee(T.target.value)},De=T=>{ee(T.target.value)},Me=zt(X),Oe=Ue("month",X,void 0,ne),We=v?zt(v):void 0,Ge=E?zt(E):void 0,Z=a.useMemo(()=>s!=="dropdown"?[]:se!==null?_a(se,ne):v===null||E===null?[]:_a(il(v,E),ne),[s,se,V,C,ne]),te=me?Me:"",re=b?"border-amber-300 bg-amber-50 text-amber-900 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200":"border-gray-300 bg-gray-100 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",L=`period-slider-native-date-field w-28 rounded-md border py-0.5 px-1 text-center font-mono text-xs tabular-nums dark:placeholder:text-gray-400 disabled:opacity-50 ${re}`,N=`w-28 appearance-none rounded-md border px-1 py-0.5 text-center font-mono text-xs tabular-nums [text-align-last:center] [text-align:center] disabled:opacity-50 ${re}`;return p.jsxs("div",{className:`inline-flex items-center ${Fr} ${u}`,style:D,"data-out-of-range":me?void 0:"true",children:[p.jsx(Wt,{neighbour:"control",direction:"left",disabled:K,canStep:ye!==null,onStep:Pe,ariaLabel:Q}),s==="dropdown"?p.jsxs("select",{"aria-label":ae,disabled:K,className:N,value:te,onChange:De,children:[me?null:p.jsx("option",{value:"",disabled:!0,className:"text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",children:Oe}),Z.map(T=>p.jsx("option",{value:T.value,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]}):p.jsx("input",{"aria-label":ae,disabled:K,className:L,value:Me,min:We,max:Ge,onChange:he,type:"month"}),p.jsx(Wt,{neighbour:"control",direction:"right",disabled:K,canStep:le!==null,onStep:R,ariaLabel:y}),o]})},gi=a.memo(sl,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,s=n?n.getFullYear()*12+n.getMonth():null;if(o!==s||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear)return!1;const l=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,c=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(l!==c)return!1;const f=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,g=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(f!==g||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.children!==t.children||e.prevMonthAriaLabel!==t.prevMonthAriaLabel||e.nextMonthAriaLabel!==t.nextMonthAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});gi.displayName="MonthSelector";function br(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`)}function Tn(e,t,r){if(br(e,"minDate",t),br(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`)}function Mn(e,t,r){if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${String(r)})`);if(br(e,`${t}[0]`,r[0]),br(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`)}function Dn(e,t,r,n,o,s,l){const c=J(r,n);if(c<J(r,o)||c>J(r,s))throw new RangeError(`${e}: ${t} must lie within ${l} (value: ${n.toISOString()}, lower: ${o.toISOString()}, upper: ${s.toISOString()})`)}function vn(e,t,r,n,o,s,l){Dn(e,`${t}[0]`,r,n[0],o,s,l),Dn(e,`${t}[1]`,r,n[1],o,s,l)}function Be(e,t,r){return e<t?t:e>r?r:e}function xn(e,t,r,n,o,s){if(r!==!0)return[];const l=e[0].getTime(),c=e[1].getTime();return Mt(n,t,o,s).filter(f=>f.getTime()>=l&&f.getTime()<=c)}function hr(e,t,r,n){if(n.length===0)return Be(e,r[0],r[1]);const o=n[fe(n,e,t)];return o.getTime()===e.getTime()?e:o}function mn(e,t,r,n){const o=hr(e[0],t,r,n),s=hr(e[1],t,r,n);return[o,s<o?o:s]}function Rn(e,t,r,n){const o=fe(e,r,t)+n;return e[Math.max(0,Math.min(e.length-1,o))]}function yn(e){const t=a.useRef(e),r=t.current,n=e,o=Object.keys(r),s=Object.keys(n);return o.length===s.length&&s.every(c=>Object.is(r[c],n[c]))||(t.current=e),t.current}function ll(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:s,...l}=e;Tn("usePeriodSliderRange",r,n),Mn("usePeriodSliderRange","initialRange",o),vn("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]");const c=yn(l),f=a.useRef(o),[g,M]=a.useState(o);let b=g;const u=[Be(g[0],r,n),Be(g[1],r,n)];(u[0]!==g[0]||u[1]!==g[1])&&(b=u,M(u));const D=a.useRef(b);D.current=b;const K=a.useRef({minDate:r,maxDate:n,allowedDates:c.allowedDates});K.current={minDate:r,maxDate:n,allowedDates:c.allowedDates};const Q=a.useRef(s);Q.current=s;const y=a.useCallback(A=>{const{minDate:v,maxDate:E}=K.current,V=Be(A[0],v,E),C=Be(A[1],v,E),q=D.current;V.getTime()===q[0].getTime()&&C.getTime()===q[1].getTime()||(D.current=[V,C],M([V,C]),Q.current?.(V,C))},[]),ae=a.useCallback(A=>{const v=D.current,E=A.getTime()>v[1].getTime()?A:v[1];y([A,E])},[y]),ne=a.useCallback(A=>{const v=D.current,E=A.getTime()<v[0].getTime()?A:v[0];y([E,A])},[y]),$=a.useCallback((A,v)=>{y([A,v])},[y]),Y=a.useCallback(A=>{const{minDate:v,maxDate:E,allowedDates:V}=K.current,C=D.current,q=Mt(V,t,v,E);if(q.length>0){y([Rn(q,t,C[0],A),Rn(q,t,C[1],A)]);return}y([Ve(t,C[0],A),Ve(t,C[1],A)])},[t,y]),H=a.useCallback(()=>{y(f.current)},[y]),ie=a.useMemo(()=>({value:b[0],onChange:ae,minDate:r,maxDate:b[1],unit:t}),[b[0],b[1],ae,r,t]),X=a.useMemo(()=>({value:b[1],onChange:ne,minDate:b[0],maxDate:n,unit:t}),[b[0],b[1],ne,n,t]),U=a.useMemo(()=>({...c,mode:"range",unit:t,range:b,minDate:r,maxDate:n,onChangeRange:$}),[c,t,b,r,n,$]);return{range:b,lowerDate:b[0],upperDate:b[1],setRange:M,setLowerDate:ae,setUpperDate:ne,shiftRange:Y,resetRange:H,startSelectorProps:ie,endSelectorProps:X,sliderProps:U}}function cl(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:s,...l}=e;Tn("usePeriodSliderPoint",r,n),br("usePeriodSliderPoint","initialValue",o),Dn("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]");const c=yn(l),f=a.useRef(o),[g,M]=a.useState(o);let b=g;const u=Be(g,r,n);u!==g&&(b=u,M(u));const D=a.useRef(b);D.current=b;const K=a.useRef({minDate:r,maxDate:n,allowedDates:c.allowedDates});K.current={minDate:r,maxDate:n,allowedDates:c.allowedDates};const Q=a.useRef(s);Q.current=s;const y=a.useCallback(H=>{const{minDate:ie,maxDate:X}=K.current,U=Be(H,ie,X);U.getTime()!==D.current.getTime()&&(D.current=U,M(U),Q.current?.(U))},[]),ae=a.useCallback(H=>{const{minDate:ie,maxDate:X,allowedDates:U}=K.current,A=Mt(U,t,ie,X);if(A.length>0){y(Rn(A,t,D.current,H));return}y(Ve(t,D.current,H))},[t,y]),ne=a.useCallback(()=>{y(f.current)},[y]),$=a.useMemo(()=>({value:b,onChange:y,minDate:r,maxDate:n,unit:t}),[b,y,r,n,t]),Y=a.useMemo(()=>({...c,mode:"point",unit:t,value:b,minDate:r,maxDate:n,onChangePoint:y}),[c,t,b,r,n,y]);return{value:b,setValue:M,shiftValue:ae,resetValue:ne,selectorProps:$,sliderProps:Y}}function ul(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:s,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroRange:g,...M}=e;Tn("useVernierSliderRange",r,n),Mn("useVernierSliderRange","initialMacroRange",o),Mn("useVernierSliderRange","initialMicroRange",s),vn("useVernierSliderRange","initialMacroRange",l,o,r,n,"[minDate, maxDate]");const b=mt(l,c,o,r,n);vn("useVernierSliderRange","initialMicroRange",c,s,b[0],b[1],"the initial macro window");const u=yn(M),D=a.useRef(o),K=a.useRef(s),[Q,y]=a.useState(o),[ae,ne]=a.useState(s);let $=Q;const Y=[Be(Q[0],r,n),Be(Q[1],r,n)];(Y[0]!==Q[0]||Y[1]!==Q[1])&&($=Y,y(Y));const H=a.useMemo(()=>mt(l,c,$,r,n),[l,c,$,r,n]),ie=a.useMemo(()=>xn(H,c,u.microIsDiscrete,u.microAllowedDates??u.allowedDates,r,n),[H,c,u.microIsDiscrete,u.microAllowedDates,u.allowedDates,r,n]),X=a.useMemo(()=>u.macroIsDiscrete===!0?Mt(u.macroAllowedDates??u.allowedDates,l,r,n):[],[u.macroIsDiscrete,u.macroAllowedDates,u.allowedDates,l,r,n]),U=a.useRef(X);U.current=X;let A=ae;const v=mn(ae,c,H,ie);(v[0]!==ae[0]||v[1]!==ae[1])&&(A=v,ne(v));const E=a.useRef($);E.current=$;const V=a.useRef(A);V.current=A;const C=a.useRef({minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates});C.current={minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates};const q=a.useRef(f);q.current=f;const se=a.useRef(g);se.current=g;const W=a.useCallback(L=>{const{minDate:N,maxDate:T}=C.current;return mt(l,c,L,N,T)},[l,c]),G=a.useCallback(L=>{const{microIsDiscrete:N,microAllowedDates:T,allowedDates:j,minDate:be,maxDate:we}=C.current;return xn(L,c,N,T??j,be,we)},[c]),_=a.useCallback((L,N)=>{const T=E.current,j=V.current;(L[0].getTime()!==T[0].getTime()||L[1].getTime()!==T[1].getTime())&&(E.current=L,y(L),q.current?.(L[0],L[1])),(N[0].getTime()!==j[0].getTime()||N[1].getTime()!==j[1].getTime())&&(V.current=N,ne(N),se.current?.(N[0],N[1]))},[]),F=a.useCallback((L,N)=>{const{minDate:T,maxDate:j}=C.current,be=[Be(L,T,j),Be(N,T,j)],we=W(be);_(be,mn(V.current,c,we,G(we)))},[c,W,G,_]),me=a.useCallback((L,N)=>{const T=W(E.current);_(E.current,mn([L,N],c,T,G(T)))},[c,W,G,_]),ye=a.useCallback(L=>{const N=E.current[1],T=L>N?L:N;F(L,T)},[F]),le=a.useCallback(L=>{const N=E.current[0],T=L<N?L:N;F(T,L)},[F]),Pe=a.useCallback(L=>{const N=V.current[1],T=L>N?L:N;me(L,T)},[me]),R=a.useCallback(L=>{const N=V.current[0],T=L<N?L:N;me(T,L)},[me]),ee=a.useCallback(L=>{const{minDate:N,maxDate:T}=C.current,j=E.current,be=U.current;if(be.length>0){const $e=fe(be,j[0],l)+L,_e=fe(be,j[1],l)+L;if($e<0||_e>be.length-1)return;F(be[$e],be[_e]);return}const we=Ve(l,j[0],L),Ee=Ve(l,j[1],L);we<N||Ee>T||F(we,Ee)},[l,F]),he=a.useCallback(L=>{const N=E.current,T=V.current,j=W(N),[be,we]=j,Ee=G(j);if(Ee.length>0){const Dt=fe(Ee,T[0],c)+L,ft=fe(Ee,T[1],c)+L;if(Dt<0||ft>Ee.length-1)return;me(Ee[Dt],Ee[ft]);return}const $e=Ve(c,T[0],L),_e=Ve(c,T[1],L);$e<be||_e>we||me($e,_e)},[c,W,G,me]),De=a.useCallback(()=>{const L=D.current,N=W(L);_(L,mn(K.current,c,N,G(N)))},[c,W,G,_]),[Me,Oe]=H,We=a.useMemo(()=>({value:$[0],onChange:ye,minDate:r,maxDate:$[1],unit:l}),[$,ye,r,l]),Ge=a.useMemo(()=>({value:$[1],onChange:le,minDate:$[0],maxDate:n,unit:l}),[$,le,n,l]),Z=a.useMemo(()=>({value:A[0],onChange:Pe,minDate:Me,maxDate:A[1],unit:c}),[A,Pe,Me,c]),te=a.useMemo(()=>({value:A[1],onChange:R,minDate:A[0],maxDate:Oe,unit:c}),[A,R,Oe,c]),re=a.useMemo(()=>({...u,mode:"vernier",unit:t,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:$,microRange:A,onChangeMacroRange:F,onChangeMicroRange:me}),[u,t,l,c,r,n,$,A,F,me]);return{macroRange:$,setMacroRange:y,microRange:A,setMicroRange:ne,setMacroLowerDate:ye,setMacroUpperDate:le,setMicroLowerDate:Pe,setMicroUpperDate:R,shiftMacroRange:ee,shiftMicroRange:he,resetVernier:De,macroStartSelectorProps:We,macroEndSelectorProps:Ge,microStartSelectorProps:Z,microEndSelectorProps:te,sliderProps:re}}function dl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:s,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroPoint:g,...M}=e;Tn("useVernierSliderPoint",r,n),Mn("useVernierSliderPoint","initialMacroRange",o),br("useVernierSliderPoint","initialMicroValue",s),vn("useVernierSliderPoint","initialMacroRange",l,o,r,n,"[minDate, maxDate]");const b=mt(l,c,o,r,n);Dn("useVernierSliderPoint","initialMicroValue",c,s,b[0],b[1],"the initial macro window");const u=yn(M),D=a.useRef(o),K=a.useRef(s),[Q,y]=a.useState(o),[ae,ne]=a.useState(s);let $=Q;const Y=[Be(Q[0],r,n),Be(Q[1],r,n)];(Y[0]!==Q[0]||Y[1]!==Q[1])&&($=Y,y(Y));const H=a.useMemo(()=>mt(l,c,$,r,n),[l,c,$,r,n]),ie=a.useMemo(()=>xn(H,c,u.microIsDiscrete,u.microAllowedDates??u.allowedDates,r,n),[H,c,u.microIsDiscrete,u.microAllowedDates,u.allowedDates,r,n]),X=a.useMemo(()=>u.macroIsDiscrete===!0?Mt(u.macroAllowedDates??u.allowedDates,l,r,n):[],[u.macroIsDiscrete,u.macroAllowedDates,u.allowedDates,l,r,n]),U=a.useRef(X);U.current=X;let A=ae;const v=hr(ae,c,H,ie);v!==ae&&(A=v,ne(v));const E=a.useRef($);E.current=$;const V=a.useRef(A);V.current=A;const C=a.useRef({minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates});C.current={minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates};const q=a.useRef(f);q.current=f;const se=a.useRef(g);se.current=g;const W=a.useCallback(Z=>{const{minDate:te,maxDate:re}=C.current;return mt(l,c,Z,te,re)},[l,c]),G=a.useCallback(Z=>{const{microIsDiscrete:te,microAllowedDates:re,allowedDates:L,minDate:N,maxDate:T}=C.current;return xn(Z,c,te,re??L,N,T)},[c]),_=a.useCallback((Z,te)=>{const re=E.current,L=V.current;(Z[0].getTime()!==re[0].getTime()||Z[1].getTime()!==re[1].getTime())&&(E.current=Z,y(Z),q.current?.(Z[0],Z[1])),te.getTime()!==L.getTime()&&(V.current=te,ne(te),se.current?.(te))},[]),F=a.useCallback((Z,te)=>{const{minDate:re,maxDate:L}=C.current,N=[Be(Z,re,L),Be(te,re,L)],T=W(N);_(N,hr(V.current,c,T,G(T)))},[c,W,G,_]),me=a.useCallback(Z=>{const te=W(E.current);_(E.current,hr(Z,c,te,G(te)))},[c,W,G,_]),ye=a.useCallback(Z=>{const te=E.current[1],re=Z>te?Z:te;F(Z,re)},[F]),le=a.useCallback(Z=>{const te=E.current[0],re=Z<te?Z:te;F(re,Z)},[F]),Pe=a.useCallback(Z=>{const{minDate:te,maxDate:re}=C.current,L=E.current,N=U.current;if(N.length>0){const be=fe(N,L[0],l)+Z,we=fe(N,L[1],l)+Z;if(be<0||we>N.length-1)return;F(N[be],N[we]);return}const T=Ve(l,L[0],Z),j=Ve(l,L[1],Z);T<te||j>re||F(T,j)},[l,F]),R=a.useCallback(Z=>{const te=E.current,re=W(te),L=G(re);if(L.length>0){me(Rn(L,c,V.current,Z));return}me(Ve(c,V.current,Z))},[c,W,G,me]),ee=a.useCallback(()=>{const Z=D.current,te=W(Z);_(Z,hr(K.current,c,te,G(te)))},[c,W,G,_]),[he,De]=H,Me=a.useMemo(()=>({value:$[0],onChange:ye,minDate:r,maxDate:$[1],unit:l}),[$,ye,r,l]),Oe=a.useMemo(()=>({value:$[1],onChange:le,minDate:$[0],maxDate:n,unit:l}),[$,le,n,l]),We=a.useMemo(()=>({value:A,onChange:me,minDate:he,maxDate:De,unit:c}),[A,me,he,De,c]),Ge=a.useMemo(()=>({...u,mode:"vernier",unit:t,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:$,microValue:A,onChangeMacroRange:F,onChangeMicroPoint:me}),[u,t,l,c,r,n,$,A,F,me]);return{macroRange:$,setMacroRange:y,microValue:A,setMicroValue:ne,setMacroLowerDate:ye,setMacroUpperDate:le,setMicroDate:me,shiftMacroRange:Pe,shiftMicroValue:R,resetVernier:ee,macroStartSelectorProps:Me,macroEndSelectorProps:Oe,microSelectorProps:We,sliderProps:Ge}}function Fa(e){const t=new Date(e,0,1);return t.setFullYear(e),t}function fn(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function ja(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function ml(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function za(e,t,r){const n=e===void 0?null:e,o=t===void 0?null:t.getFullYear();return n!==null&&o!==null?r(n,o):n!==null?n:o}const fl=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:s,maxYear:l,minDate:c,maxDate:f,className:g="",style:M,disabled:b=!1,prevYearAriaLabel:u="Previous year",nextYearAriaLabel:D="Next year",selectAriaLabel:K="Year",locale:Q}=e;fn(t,"value"),fn(r,"initialDate"),fn(c,"minDate"),fn(f,"maxDate"),ja(s,"minYear"),ja(l,"maxYear"),ml(Q);const y=t??r;if(y===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const[ae,ne]=a.useState(()=>y.getFullYear()),$=c?.getTime(),Y=f?.getTime(),H=a.useMemo(()=>za(s,c,Math.max),[s,$]),ie=a.useMemo(()=>za(l,f,Math.min),[l,Y]);if(H===null||ie===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`) are both required; the year option list is never invented.");if(H>ie)throw new RangeError(`YearSelector: the resolved lower bound ${H} is after the resolved upper bound ${ie}.`);const X=t!==void 0,U=t!==void 0?t.getFullYear():ae,A=U<H||U>ie,v=y.getTime();a.useEffect(()=>{X||ne(y.getFullYear())},[X,v]);const E=_=>_>=H&&_<=ie,V=_=>{if(!b){if(!E(_))throw new RangeError(`YearSelector: refusing to emit ${_}, which lies outside the declared bounds ${H}-${ie}.`);X||ne(_),n?.(Fa(_),_)}},C=E(U-1)?U-1:null,q=E(U+1)?U+1:null,se=()=>{C!==null&&V(C)},W=()=>{q!==null&&V(q)},G=a.useMemo(()=>{const _=[];for(let F=ie;F>=H;F--)_.push(F);return A&&(_.push(U),_.sort((F,me)=>me-F)),_},[H,ie,A,U]);return p.jsxs("div",{className:`inline-flex items-center ${Fr} ${g}`,style:M,children:[p.jsx(Wt,{neighbour:"control",direction:"left",disabled:b,canStep:C!==null,onStep:se,ariaLabel:u}),p.jsx("select",{"aria-label":K,disabled:b,className:"w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",value:U,onChange:_=>{if(!_.target.value)return;const F=Number(_.target.value);Number.isInteger(F)&&V(F)},children:G.map(_=>p.jsx("option",{value:_,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:Ue("year",Fa(_),void 0,Q)},_))}),p.jsx(Wt,{neighbour:"control",direction:"right",disabled:b,canStep:q!==null,onStep:W,ariaLabel:D}),o]})},hi=a.memo(fl,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear():null,s=n?n.getFullYear():null;return!(o!==s||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.minDate?.getFullYear()!==t.minDate?.getFullYear()||e.maxDate?.getFullYear()!==t.maxDate?.getFullYear()||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});hi.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Ga;exports.DateSelector=fi;exports.MonthSelector=gi;exports.PeriodSlider=li;exports.YearSelector=hi;exports.addUnit=Ve;exports.areStylesEqual=si;exports.calculateConnectDragValues=qa;exports.calculateHandleDragValues=ho;exports.calculateKeyboardActionValues=Za;exports.calculateLabelSlant=vo;exports.calculateVernierMacroDrag=ai;exports.calculateVernierMicroDrag=ii;exports.decode=ce;exports.encode=J;exports.findNearestDateIndex=fe;exports.formatLabel=Ue;exports.formatScreenReaderLabel=Ft;exports.getMacroWindowEndDate=Ka;exports.getMacroWindowStartDate=Xa;exports.getSortedAllowedDates=Mt;exports.normalizeDateByUnit=qe;exports.resolveDraggedEdge=Ln;exports.resolveMacroWindow=mt;exports.resolveVernierRailZone=xo;exports.resolveVernierTargetHandle=oi;exports.resolveWheelStep=ni;exports.usePeriodSliderPoint=cl;exports.usePeriodSliderRange=ll;exports.useVernierSliderPoint=dl;exports.useVernierSliderRange=ul;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),$t=require("date-fns"),a=require("react"),rs=require("@aiquants/virtualscroll"),ns=require("react-dom"),Da=120,Qn="data-drag-snap",eo="--ps-drag-snap-duration",Hr={flat:["--ps-drag-low","--ps-drag-high"],macro:["--ps-drag-macro-low","--ps-drag-macro-high"],micro:["--ps-drag-micro-low","--ps-drag-micro-high"]},Ua=["low","high"],Ba=["tx","ty","rot"],Sn={flat:{low:"--ps-drag-label-low",high:"--ps-drag-label-high"},macro:{low:"--ps-drag-macro-label-low",high:"--ps-drag-macro-label-high"},micro:{low:"--ps-drag-micro-label-low",high:"--ps-drag-micro-label-high"}},po=(e,t)=>`${e}-${t}`,to=(e,t,r)=>`var(${po(e,t)}, ${r})`,os=(e,t,r)=>{const n=Sn[t];for(const o of Ua)for(const s of Ba)e.style.setProperty(po(n[o],s),r[o][s])},Wa=e=>Math.max(0,Math.min(1,e)),wn=(e,t,r,n)=>{const o=Wa(t);if(e==="point")return[o,o];const s=e==="low"?n:r;return[Math.min(o,s),Math.max(o,s)]},Mo=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},Ln=(e,t,r,n)=>{const o=Wa(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ro=(e,t,r,n)=>{if(r){const l=(1-e)*100,c=(1-t)*100;return n?`M 12 ${c} L 12 ${l} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${l} L 20 ${c} Z`}const o=e*100,s=t*100;return n?`M ${o} 12 L ${s} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${s} 20 L ${o} 20 Z`},Et=(e,t)=>`var(${e}, ${t}%)`,as=(e,t,r,n)=>{const[o,s]=Hr[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(s,`${n*100}%`)},is=e=>{for(const[t,r]of Object.values(Hr))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Sn))for(const r of Ua)for(const n of Ba)e.style.removeProperty(po(t[r],n))},no=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),va=new Set(["hidden","clip","scroll","auto","overlay"]),xa=["paint","strict","content"],ss=["layout","paint","strict","content"],ls=["transform","perspective","filter"],Ir=e=>e!==void 0&&e!==""&&e!=="none",cs=e=>e!==void 0&&e!==""&&e!=="normal",sn=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},us=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,ds=(e,t)=>t==="absolute"&&Ir(e.position)&&e.position!=="static"||Ir(e.transform)||Ir(e.perspective)||Ir(e.filter)||Ir(e.backdropFilter)||cs(e.containerType)||ss.some(r=>e.contain.includes(r))?!0:ls.some(r=>e.willChange.includes(r)),ms=(e,t,r,n,o,s)=>{const l=t.ownerDocument.defaultView;if(l===null)return!1;const c=e.getBoundingClientRect();if(c.width===0||c.height===0)return!1;const f=n?0:r,g=n?r:0;if(o<c.left-f||o>=c.right+f||s<c.top-g||s>=c.bottom+g)return!1;const M=l.getComputedStyle(t);if(M.visibility!=="visible")return!1;let b=null;for(let u=t;u!==null;u=u.parentElement){const D=u===t?M:l.getComputedStyle(u);if(b!==null&&!ds(D,b))continue;const K=va.has(D.overflowX)||xa.some(y=>D.contain.includes(y)),Q=va.has(D.overflowY)||xa.some(y=>D.contain.includes(y));if(K||Q){const y=u.getBoundingClientRect();if(K&&(o<y.left+sn(D.borderLeftWidth)||o>=y.right-sn(D.borderRightWidth))||Q&&(s<y.top+sn(D.borderTopWidth)||s>=y.bottom-sn(D.borderBottomWidth)))return!1}b=us(D)}return!0},oo=new Map,fs=(e,t)=>{if(!(t.shiftKey&&t.cancelable))return;for(const o of e)if(o.ownsHit(t.target)){o.step(t);return}let r=null,n=Number.POSITIVE_INFINITY;for(const o of e){const s=o.distanceToRailPx(t.clientX,t.clientY);s===null||s>=n||(r=o,n=s)}r?.step(t)},gs=(e,t)=>{let r=oo.get(e);if(r===void 0){const s=new Set,l=c=>fs(s,c);r={participants:s,listener:l},oo.set(e,r),e.addEventListener("wheel",l,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(oo.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Fr="gap-[11px]",ut=6,dt=ut*2,Ct=ut*4/3,hs={left:`0,${dt/2} ${ut},0 ${ut},${dt}`,right:`${Ct},${dt/2} ${Ct-ut},0 ${Ct-ut},${dt}`,up:`${dt/2},0 0,${ut} ${dt},${ut}`,down:`${dt/2},${Ct} 0,${Ct-ut} ${dt},${Ct-ut}`},ao=e=>{e.preventDefault(),e.stopPropagation()},bs={onMouseDownCapture:ao,onMouseUpCapture:ao,onClickCapture:ao},ws="period-slider-step",ps=`${ws} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Ms="transition-colors motion-reduce:transition-none not-aria-disabled:cursor-pointer aria-disabled:cursor-not-allowed focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 dark:focus-visible:ring-blue-400 forced-colors:not-aria-disabled:hover:text-[Highlight] forced-colors:aria-disabled:text-[GrayText]",Ds={control:"text-slate-500 not-aria-disabled:hover:bg-slate-500/15 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-500/25 aria-disabled:text-slate-500/40 dark:text-slate-400 dark:not-aria-disabled:hover:text-slate-50 dark:aria-disabled:text-slate-400/40",rail:"border border-slate-300 bg-white text-slate-700 shadow-2xs not-aria-disabled:hover:border-slate-400 not-aria-disabled:hover:bg-slate-100 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-200 aria-disabled:border-slate-300/40 aria-disabled:bg-white/40 aria-disabled:text-slate-700/40 aria-disabled:shadow-none dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:not-aria-disabled:hover:border-slate-500 dark:not-aria-disabled:hover:bg-slate-700 dark:not-aria-disabled:hover:text-white dark:not-aria-disabled:active:bg-slate-600 dark:aria-disabled:border-slate-700/40 dark:aria-disabled:bg-slate-800/40 dark:aria-disabled:text-slate-200/40"},ln="after:inset-[calc((100%-var(--ps-target-size))/2)]",Ra={horizontal:"px-[19px]",vertical:"py-[19px]"},vs={control:{left:ln,right:ln,up:ln,down:ln},rail:{left:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:left-[calc(100%-var(--ps-target-size)+4px)] after:-right-[4px]",right:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-left-[4px] after:right-[calc(100%-var(--ps-target-size)+4px)]",up:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-[calc(100%-var(--ps-target-size)+4px)] after:-bottom-[4px]",down:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-[4px] after:bottom-[calc(100%-var(--ps-target-size)+4px)]"}},Wt=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:s,className:l,ref:c})=>{const f=e==="up"||e==="down",g=f?dt:Ct,M=f?Ct:dt,b=r||!n;return p.jsx("button",{ref:c,type:"button","aria-label":s,disabled:r,"aria-disabled":b?!0:void 0,...b?bs:null,onClick:b?void 0:o,className:`${l===void 0?"":`${l} `}${ps} ${Ms} ${Ds[t]} ${vs[t][e]}`,children:p.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:g,height:M,viewBox:`0 0 ${g} ${M}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:p.jsx("polygon",{points:hs[e]})})})},Ga={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},et=e=>e instanceof Date&&!Number.isNaN(e.getTime()),pe=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),qe=(e,t)=>{if(!et(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${pe(t)})`);const r=new Date(t.getTime());return e==="year"?(r.setMonth(0,1),r.setHours(0,0,0,0)):(e==="month"&&r.setDate(1),r.setHours(0,0,0,0)),r},J=(e,t)=>{const r=qe(e,t),n=r.getFullYear(),o=r.getMonth()+1,s=r.getDate();if(e==="year")return n;if(e==="month")return n*12+(o-1);const l=new Date(0);return l.setUTCFullYear(n,o-1,s),l.setUTCHours(0,0,0,0),Math.floor(l.getTime()/(1440*60*1e3))},ce=(e,t)=>{const r=new Date(0);if(r.setHours(0,0,0,0),e==="year")return r.setFullYear(t,0,1),r;if(e==="month"){const o=Math.floor(t/12),s=t-o*12;return r.setFullYear(o,s,1),r}const n=new Date(t*24*60*60*1e3);return r.setFullYear(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),r},Ve=(e,t,r)=>{if(!et(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${pe(t)})`);return e==="year"?$t.addYears(t,r):e==="month"?$t.addMonths(t,r):$t.addDays(t,r)},Xa=(e,t,r)=>{if(!et(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${pe(r)})`);return qe(t,qe(e,r))},Ka=(e,t,r)=>{if(!et(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${pe(r)})`);if(e===t)return qe(t,r);const n=r.getFullYear(),o=r.getMonth();if(e==="year"){if(t==="month")return new Date(n,11,1);if(t==="day")return new Date(n,11,31)}return e==="month"&&t==="day"?new Date(n,o+1,0):qe(t,r)},Sa=(e,t,r)=>e<t?t:e>r?r:e,mt=(e,t,r,n,o)=>{if(_r("macroRange",r,"resolveMacroWindow"),!et(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${pe(n)})`);if(!et(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${pe(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${pe(n)}, maxDate: ${pe(o)})`);return[qe(t,Sa(Xa(e,t,r[0]),n,o)),qe(t,Sa(Ka(e,t,r[1]),n,o))]},xs={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},La=new Map,Rs=(e,t)=>{const r=`${e}\0${t}`,n=La.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,xs[e]);return La.set(r,o),o},Ss=(e,t)=>{const r=String(t.getFullYear()).padStart(4,"0");if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const o=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${o}`},Ue=(e,t,r,n)=>et(t)?r?r(t):n===void 0?Ss(e,t):Rs(e,n).format(t):"",Ft=(e,t,r,n)=>Ue(e,t,r,n),fe=(e,t,r)=>{if(!e||e.length===0||e.length===1)return 0;const n=J(r,t);let o=0,s=e.length-1;if(n<=J(r,e[o]))return 0;if(n>=J(r,e[s]))return s;for(;o<=s;){const f=o+s>>1,g=J(r,e[f]);if(g===n)return f;g<n?o=f+1:s=f-1}const l=Math.abs(J(r,e[o])-n),c=Math.abs(J(r,e[s])-n);return l<c?o:s},Mt=(e,t,r,n)=>{if(!Array.isArray(e)||e.length===0)return[];const o=J(t,r),s=J(t,n),l=new Map;for(const c of e){const f=qe(t,c),g=J(t,f);g<o||g>s||l.has(g)||l.set(g,f)}if(l.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${pe(r)}, maxDate: ${pe(n)}, entries: ${e.length})`);return Array.from(l.keys()).sort((c,f)=>c-f).map(c=>l.get(c))},cn=(e,t,r,n)=>{const o=e.length-1;if(o<=0)return 0;const s=fe(e,n,t);if(r==="time"){const l=e[0].getTime(),c=e[o].getTime()-l;return c<=0?0:Math.max(0,Math.min(1,(e[s].getTime()-l)/c))}return s/o},un=(e,t,r,n)=>{const o=e.length-1;if(o<=0)return 0;const s=Math.max(0,Math.min(1,n));if(r==="time"){const l=e[0].getTime(),c=e[o].getTime()-l;return c<=0?0:fe(e,new Date(l+s*c),t)}return Math.max(0,Math.min(o,Math.round(s*o)))},ho=(e,t,r,n,o,s,l)=>{let c=r,f=n;return l?(c=t,f=t):e==="low"?t>n?(c=n,f=t):c=t:t<r?(f=r,c=t):f=t,[Math.max(o,Math.min(s,c)),Math.max(o,Math.min(s,f))]},qa=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:s,sortedAllowedDates:l,snapMode:c,unit:f})=>{if(s){const K=l.length-1;if(K<=0)return[0,0];const Q=Math.max(0,Math.min(K,Math.round(t))),y=Math.max(Q,Math.min(K,Math.round(r)));if(c==="time"){const Y=l[0].getTime(),H=l[K].getTime(),ie=l[Q].getTime(),X=l[y].getTime()-ie;let U=ie+e*(H-Y),A=U+X;U<Y&&(U=Y,A=Y+X),A>H&&(A=H,U=H-X);const v=fe(l,new Date(U),f),E=fe(l,new Date(A),f);return[v,Math.max(v,E)]}const ae=Math.round(e*K);let ne=Q+ae,$=y+ae;return ne<0&&($+=-ne,ne=0),$>K&&(ne-=$-K,$=K),[Math.max(0,Math.min(K,ne)),Math.max(0,Math.min(K,$))]}const g=K=>Math.max(n,Math.min(o,K)),M=o-n;if(M<=0)return[g(t),g(r)];const b=Math.round(e*M);let u=t+b,D=r+b;return u<n&&(D+=n-u,u=n),D>o&&(u-=D-o,D=o),[g(u),g(D)]},Za=(e,t,r,n,o,s,l,c)=>{let f=0,g=!1,M=!1;switch(e){case"ArrowRight":case"ArrowUp":f=c;break;case"ArrowLeft":case"ArrowDown":f=-c;break;case"PageUp":f=c*5;break;case"PageDown":f=-c*5;break;case"Home":g=!0;break;case"End":M=!0;break;default:return null}if(l){let D=r;return g?D=o:M?D=s:D=Math.max(o,Math.min(s,r+f)),[D,D]}let b=r,u=n;return t==="low"?g?b=o:M?b=n:b=Math.max(o,Math.min(n,r+f)):g?u=r:M?u=s:u=Math.max(r,Math.min(s,n+f)),[b,u]},Ja=8,Qa=2,ei=16,Ls=12,Ts=90,ti=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),s=Math.abs(Math.cos(n));return{alongPx:(e*s+t*o)/2,acrossPx:(e*o+t*s)/2}},Do=(e,t)=>{const r=t?.estimatedHeightPx??ei,o=Ja+(t?.anchorGapY??Qa)+r/2,s=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:s,highOffsetY:s,isSlanted:!1,proximity:0}},vo=(e,t,r,n="top",o)=>{const s=o?.estimatedWidthPx,l=o?.estimatedHeightPx??ei,c=o?.paddingPx??Ls,f=o?.maxAngleDeg??Ts,g=Ja+(o?.anchorGapY??Qa),M=Do(n,o);if(!(Number.isFinite(r)&&r>0)||s===void 0||!Number.isFinite(s)||s<=0)return M;const b=Math.max(0,t-e)/100*r,u=s+c;if(b>=u)return M;const D=Math.max(0,Math.min(1,(u-b)/u)),Q=D*D*D*(D*(D*6-15)+10)*f,y=n==="top"?-Q:Q,ae=ti(s,l,Q),ne=g+ae.acrossPx,$=n==="top"?-ne:+ne,Y=2*ae.alongPx,H=Math.max(0,(Y+c-b)/2);return{lowAngleDeg:y,highAngleDeg:y,lowOffsetX:-H,highOffsetX:H,lowOffsetY:$,highOffsetY:$,isSlanted:D>.001,proximity:D}},ri=e=>({...e,lowOffsetX:0,highOffsetX:0}),xo=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},ni=(e,t,r)=>{const n=Math.abs(e)>Math.abs(t)?e:t;return!Number.isFinite(n)||n===0?0:(r?n<0:n>0)?1:-1};function oi(e,t,r,n,o,s,l="macro-top",c=.05,f=!0,g="range"){if(xo(t,l)==="macro"){const u=Math.abs(e-r),D=Math.abs(e-n);return u<=c&&u<=D?"macro-low":D<=c&&D<u?"macro-high":f&&e>=r&&e<=n?"macro-connect":u<D?"macro-low":"macro-high"}if(g==="point")return"micro-point";const M=Math.abs(e-o),b=Math.abs(e-s);return M<=c&&M<=b?"micro-low":b<=c&&b<M?"micro-high":f&&e>=o&&e<=s?"micro-connect":M<b?"micro-low":"micro-high"}function ai(e,t,r,n,o){if(e==="macro-connect"){const[g,M]=Mo(t-r,n,o);return[g,M,"macro-connect"]}const s=e==="macro-low"?"low":"high",[l,c]=wn(s,t,n,o),f=Ln(s,t,n,o);return[l,c,f==="low"?"macro-low":"macro-high"]}function ii(e,t,r,n,o){if(e==="micro-point"){const[g]=wn("point",t,n,o);return[g,g,"micro-point"]}if(e==="micro-connect"){const[g,M]=Mo(t-r,n,o);return[g,M,"micro-connect"]}const s=e==="micro-low"?"low":"high",[l,c]=wn(s,t,n,o),f=Ln(s,t,n,o);return[l,c,f==="low"?"micro-low":"micro-high"]}const Yr=a.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,s;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",s=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",s=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const l=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return p.jsx("svg",{className:s,width:r?"8":"16",height:r?"16":"8",viewBox:r?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:p.jsx("path",{d:o,className:l,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});Yr.displayName="VernierKnobSvg";const ys=(e,t)=>{if(!et(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${pe(e)})`);if(!et(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${pe(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${pe(e)}, maxDate: ${pe(t)})`)},_r=(e,t,r="PeriodSlider")=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`${r}: ${e} is required and must be a [start, end] Date tuple (received: ${pe(t)})`);const[n,o]=t;if(!et(n))throw new RangeError(`${r}: ${e}[0] must be a valid Date (received: ${pe(n)})`);if(!et(o))throw new RangeError(`${r}: ${e}[1] must be a valid Date (received: ${pe(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`${r}: ${e} must not be inverted (start: ${pe(n)}, end: ${pe(o)})`)},bo=(e,t)=>{if(!et(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${pe(t)})`)},pt=(e,t,r,n,o)=>{const s=J(r,t);if(s<J(r,n)||s>J(r,o))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${pe(t)}, minDate: ${pe(n)}, maxDate: ${pe(o)})`)},Ps=(e,t,r)=>{if(e.mode==="range"){for(const n of["range","defaultRange"]){const o=e[n];o!==void 0&&(_r(n,o),pt(`${n}[0]`,o[0],e.unit,t,r),pt(`${n}[1]`,o[1],e.unit,t,r))}return}if(e.mode==="point")for(const n of["value","defaultValue"]){const o=e[n];o!==void 0&&(bo(n,o),pt(n,o,e.unit,t,r))}},As=(e,t,r)=>{_r("macroRange",e.macroRange);const n=e.microUnit??e.unit,o=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,s=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(o&&s)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(s){if(e.microValue!==void 0)return bo("microValue",e.microValue),pt("microValue",e.microValue,n,t,r),{shape:"point",selection:[e.microValue,e.microValue]};if(e.defaultMicroValue!==void 0)return bo("defaultMicroValue",e.defaultMicroValue),pt("defaultMicroValue",e.defaultMicroValue,n,t,r),{shape:"point",selection:[e.defaultMicroValue,e.defaultMicroValue]};throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)")}if(e.microRange!==void 0)return _r("microRange",e.microRange),pt("microRange[0]",e.microRange[0],n,t,r),pt("microRange[1]",e.microRange[1],n,t,r),{shape:"range",selection:e.microRange};if(e.defaultMicroRange!==void 0)return _r("defaultMicroRange",e.defaultMicroRange),pt("defaultMicroRange[0]",e.defaultMicroRange[0],n,t,r),pt("defaultMicroRange[1]",e.defaultMicroRange[1],n,t,r),{shape:"range",selection:e.defaultMicroRange};throw o?new RangeError("PeriodSlider: vernier range mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)"):new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange / defaultMicroRange for a period, or microValue / defaultMicroValue for a point")},kr=(e,t,r,n,o,s,l,c)=>{const f=fe(e,n,t),g=fe(e,o,t);return l?f:c?g:Math.max(f,Math.min(g,fe(e,r,t)+s))},io=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Ta=()=>{const[e,t]=a.useState(null),r=a.useRef(null),n=a.useCallback((s,l)=>{const c=r.current;if(c!==null&&c[0].getTime()===s.getTime()&&c[1].getTime()===l.getTime())return;const f=[s,l];r.current=f,t(f)},[]),o=a.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Es=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`)}},fr=()=>{const[e,t]=a.useState(null),r=a.useRef(null),n=a.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const s=new ResizeObserver(l=>{for(const c of l){const f=c.borderBoxSize?.[0];f!==void 0&&t(g=>g!==null&&Math.abs(g.widthPx-f.inlineSize)<.5&&Math.abs(g.heightPx-f.blockSize)<.5?g:{widthPx:f.inlineSize,heightPx:f.blockSize})}});s.observe(o),r.current=s},[]);return a.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},so=(e,t)=>{const r=gn(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},gn=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},Cs=e=>{const t={};let r=0;for(const o of e){const{side:s,box:l}=o;if(l===null)continue;let c;if(o.reach==="inline-size")c=l.widthPx,r=Math.max(r,l.heightPx/2);else{const f=ti(l.widthPx,l.heightPx,o.angleDeg);c=o.centreOffsetPx===null?2*f.acrossPx:Math.abs(o.centreOffsetPx)+f.acrossPx,r=Math.max(r,f.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${s}`]=`${Math.ceil(c)}px`}if(Object.keys(t).length===0)return;const n=Math.ceil(r);return t["--ps-label-reach-main"]=`${n}px`,{style:t,mainPx:n}},ya=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),Pa=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),pn=(e,t)=>({"--ps-tooltip-tx":to(e,"tx",t.tx),"--ps-tooltip-ty":to(e,"ty",t.ty),"--ps-tooltip-rot":to(e,"rot",t.rot)}),lo=(e,t,r,n)=>{const o=Do(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const s=vo(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),l=n.isMerged?ri(s):s,c=Sn[e],f={low:ya(l.lowOffsetX,l.lowOffsetY-o.lowOffsetY,l.lowAngleDeg),high:ya(l.highOffsetX,l.highOffsetY-o.highOffsetY,l.highAngleDeg)};return{slant:l,lowStyle:pn(c.low,f.low),highStyle:pn(c.high,f.high),placements:f}},Aa={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Ea=(e,t,r)=>{const n=Do(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Aa,highStyle:Aa,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let s=n;if(o){const f=vo(e,t,r.trackLengthPx,r.labelPosition,r.config);s=r.isMerged?ri(f):f}const l=Sn.flat,c={low:Pa(s.lowOffsetX,s.lowOffsetY,s.lowAngleDeg),high:Pa(s.highOffsetX,s.highOffsetY,s.highAngleDeg)};return{slant:s,lowStyle:{"--ps-tooltip-origin":"50% 50%",...pn(l.low,c.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...pn(l.high,c.high)},placements:o?c:null}},$s={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Is={horizontal:{decrease:"period-slider-stepper-prev",increase:"period-slider-stepper-next"},vertical:{decrease:"period-slider-stepper-prev period-slider-stepper-down",increase:"period-slider-stepper-next period-slider-stepper-up"}},Ca={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},ks={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Fr} ${Ra.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Ca.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Fr} ${Ra.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Ca.vertical}`}},$a={horizontal:{leading:"col-start-1 row-start-1",rail:"col-start-2 row-start-1",railOnly:"col-start-1 row-start-1",trailing:"col-start-3 row-start-1"},vertical:{leading:"col-start-1 row-start-1",rail:"col-start-1 row-start-2",railOnly:"col-start-1 row-start-1",trailing:"col-start-1 row-start-3"}},Ia=(e,t)=>{e.setPointerCapture(t)},Ns=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:s="index",disabled:l=!1,className:c="",showStepper:f=!0,tooltipStyle:g="always",labelPosition:M="top",autoSlantLabels:b=!0,isVertical:u=!1,hideConnectBar:D=!1,showTicks:K=!1,colorScheme:Q="blue-rose",locale:y,decreaseAriaLabel:ae="Decrease",increaseAriaLabel:ne="Increase"}=e;ys(r,n),Ps(e,r,n),y!==void 0&&Es("locale",y);const $=e.mode==="vernier"?As(e,r,n):null,Y=$!==null&&$.shape==="point",H=Ga[Q],ie=a.useId(),X=a.useRef(e),U=r.getTime(),A=n.getTime(),v=a.useMemo(()=>Mt(o,t,r,n),[o,t,U,A]),E=v.length>0,{rangeMin:V,rangeMax:C}=a.useMemo(()=>E?{rangeMin:0,rangeMax:v.length-1}:{rangeMin:J(t,r),rangeMax:J(t,n)},[E,v,t,U,A]),q=e.mode==="point",se=a.useCallback(i=>{if(E){const d=Math.max(0,Math.min(v.length-1,Math.round(i)));return v[d]}return ce(t,Math.round(i))},[E,v,t]),W=a.useCallback(i=>{if(i===void 0)return V;const d=qe(t,i);return E?fe(v,d,t):J(t,d)},[E,v,t,V]),[G,_]=a.useState(()=>$===null?null:$.selection);let F=G??($===null?null:$.selection);if(Y&&F!==null&&F[0].getTime()!==F[1].getTime()){const i=[F[0],F[0]];F=i,_(i)}const me=e.mode==="vernier"?e.microValue?.getTime():void 0,ye=a.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,me]),le=Ta(),Pe=Ta(),R=e.mode!=="vernier"?null:Y?ye??F:e.microRange!==void 0?e.microRange:F,ee=R===null?null:Pe.shown??R,he=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ee?.[0]:void 0,De=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ee?.[1]:void 0,Me=e.mode==="point"?e.value??e.defaultValue:void 0,Oe=e.mode==="point"?Me?.getTime():he?.getTime(),We=e.mode==="range"?De?.getTime():Oe,[Ge,Z]=a.useMemo(()=>{if(e.mode==="point"){const m=W(Me);return[m,m]}const i=W(he),d=W(De);return[Math.min(i,d),Math.max(i,d)]},[e.mode,Oe,We,W,Me,he,De]),te=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:Y?e.microValue!==void 0:e.microRange!==void 0,[re,L]=a.useState(()=>[Ge,Z]),[N,T]=a.useState(null),[j,be]=a.useState(null),we=a.useRef(null),[Ee,$e]=a.useState("high"),[_e,Dt]=a.useState(null),[ft,jr]=a.useState(null),Se=N?N[0]:te?Ge:re[0],Le=N?N[1]:te?Z:re[1],Gt=a.useRef([Se,Le]),de=e.mode==="vernier",x=e.mode==="vernier"?e.vernierOrientation??(u?"macro-left":"macro-top"):"macro-top",w=x==="macro-top"||x==="macro-left",tt=e.mode==="vernier"?e.showVernierProjection??!0:!1,wr=e.mode==="vernier"?e.showVernierTicks??!0:!1,at=e.mode==="vernier"?e.showHairline??!0:!1,z=de?e.macroUnit??t:t,P=de?e.microUnit??t:t,Pn=de?e.macroIsDiscrete??!1:E,pr=de?e.microIsDiscrete??!1:E,Ro=de?e.macroAllowedDates??o:o,So=de?e.microAllowedDates??o:o,zr=de?e.formatMacroLabel??e.formatLabel:e.formatLabel,Ur=de?e.formatMicroLabel??e.formatLabel:e.formatLabel,bi=he?.getTime(),wi=De?.getTime(),[Xe,Br]=a.useState(null),vt=a.useRef(null),[Mr,Xt]=a.useState(()=>Y?"micro-point":"micro-high");let Ne=Mr;const An=Y?Mr==="micro-low"||Mr==="micro-high"||Mr==="micro-connect"?"micro-point":null:Mr==="micro-point"?"micro-high":null;An!==null&&(Ne=An,Xt(An));const Ye=a.useMemo(()=>J(z,r),[U,z]),it=a.useMemo(()=>{const i=J(z,n);if(de&&i<=Ye)throw new RangeError(`PeriodSlider: macroUnit "${z}" cannot distinguish minDate from maxDate (minDate: ${pe(r)}, maxDate: ${pe(n)})`);return i},[de,U,A,Ye,z]),Te=a.useMemo(()=>de&&Pn?Mt(Ro,z,r,n):[],[de,Pn,Ro,z,U,A]),Lo=i=>[Math.max(Ye,Math.min(it,J(z,i[0]))),Math.max(Ye,Math.min(it,J(z,i[1])))],[To,yo]=e.mode!=="vernier"?[Ye,it]:Lo(e.macroRange),[Fe,je]=le.shown===null?[To,yo]:Lo(le.shown),gt=a.useMemo(()=>ce(z,Fe),[z,Fe]),It=a.useMemo(()=>ce(z,je),[z,je]),Wr=a.useMemo(()=>e.mode!=="vernier"?[r,n]:mt(z,P,[gt,It],r,n),[e.mode,gt,It,z,P,U,A]),ve=a.useMemo(()=>J(P,Wr[0]),[P,Wr]),Ce=a.useMemo(()=>J(P,Wr[1]),[P,Wr]),Po=a.useMemo(()=>de&&pr?Mt(So,P,r,n):[],[de,pr,So,P,U,A]),En=(i,d)=>Po.filter(m=>{const h=J(P,m);return h>=i&&h<=d}),ue=a.useMemo(()=>En(ve,Ce),[Po,P,ve,Ce]),Kt=Pn&&Te.length>0,rt=pr&&ue.length>0,xt=(i,d,m,h)=>d.length>0?J(P,d[fe(d,i,P)]):Math.max(m,Math.min(h,J(P,i))),qt=rt?ue:[],Ie=a.useMemo(()=>ee===null?ve:xt(ee[0],qt,ve,Ce),[bi,ve,Ce,P,ee,qt]),ze=a.useMemo(()=>ee===null?Ce:xt(ee[1],qt,ve,Ce),[wi,ve,Ce,P,ee,qt]),Rt=a.useMemo(()=>ce(P,Ie),[P,Ie]),St=a.useMemo(()=>ce(P,ze),[P,ze]),Ao=!de||R===null?null:{macroUnit:z,macroLowEnc:To,macroHighEnc:yo,microUnit:P,microLowEnc:J(P,R[0]),microHighEnc:J(P,R[1])},Cn=a.useRef(Ao),Gr=Math.max(1,it-Ye),nt=Kt?cn(Te,z,s,gt):Math.max(0,Math.min(1,(Fe-Ye)/Gr)),st=Math.max(nt,Kt?cn(Te,z,s,It):Math.min(1,(je-Ye)/Gr)),Xr=Math.max(1,Ce-ve),Zt=rt?cn(ue,P,s,Rt):Math.max(0,Math.min(1,(Ie-ve)/Xr)),Dr=Math.max(Zt,rt?cn(ue,P,s,St):Math.min(1,(ze-ve)/Xr)),$n=a.useRef({timerId:null,emit:null}),Kr=a.useRef({timerId:null,emit:null}),qr=a.useRef({timerId:null,emit:null});a.useEffect(()=>{const i=[$n,Kr,qr];return()=>{for(const d of i)io(d.current)}},[]);const Jt=a.useCallback((i,d,m)=>{io(i);const{debounceMs:h}=X.current;if(m||!h||h<=0){d();return}i.emit=d,i.timerId=setTimeout(()=>{i.timerId=null,i.emit=null,d()},h)},[]),Eo=a.useCallback(i=>{const d=i.emit;io(i),d?.()},[]),Qt=a.useCallback(i=>new Date(Math.min(Math.max(i.getTime(),U),A)),[U,A]),Lt=a.useCallback((i,d,m=!1)=>{const[h,S]=Gt.current;if((X.current.mode==="point"?i===h:i===h&&d===S)&&$n.current.timerId===null)return;const O=se(i),k=se(d),oe=()=>{const ge=X.current;ge.mode==="point"?ge.onChangePoint?.(O):ge.mode==="range"&&ge.onChangeRange?.(O,k)};Jt($n.current,oe,m)},[se,Jt]),kt=a.useCallback((i,d,m=!1)=>{const h=Cn.current;if(X.current.mode!=="vernier"||h===null)return;const S=Qt(i),I=Qt(d);J(h.macroUnit,S)===h.macroLowEnc&&J(h.macroUnit,I)===h.macroHighEnc&&Kr.current.timerId===null||Jt(Kr.current,()=>{const O=X.current;O.mode==="vernier"&&O.onChangeMacroRange?.(S,I)},m)},[Qt,Jt]),Ze=a.useCallback((i,d,m=!1)=>{const h=X.current,S=Cn.current;if(h.mode!=="vernier"||S===null)return;const I=Qt(i),O=Qt(d);J(S.microUnit,I)===S.microLowEnc&&J(S.microUnit,O)===S.microHighEnc&&qr.current.timerId===null||((Y?h.microValue===void 0:h.microRange===void 0)&&_([I,O]),Jt(qr.current,()=>{const k=X.current;if(k.mode==="vernier"){if(Y){k.onChangeMicroPoint?.(I);return}k.onChangeMicroRange?.(I,O)}},m))},[Qt,Jt,Y]),Co=a.useCallback((i,d=!1)=>{Ze(i,i,d)},[Ze]),Nt=a.useCallback(i=>{if(E&&s==="time"&&v.length>1){const h=Math.max(0,Math.min(v.length-1,Math.round(i))),S=v[0].getTime(),O=v[v.length-1].getTime()-S;if(O<=0)return 0;const k=v[h].getTime();return Math.max(0,Math.min(100,(k-S)/O*100))}const d=C-V;if(d<=0)return 0;const m=(i-V)/d*100;return Math.max(0,Math.min(100,m))},[E,s,v,V,C]),In=a.useCallback(i=>{const d=Math.max(0,Math.min(100,i));if(E){if(s==="time"&&v.length>1){const S=v[0].getTime(),O=v[v.length-1].getTime()-S,k=S+d/100*O;return fe(v,new Date(k),t)}const h=Math.round(d/100*(v.length-1));return Math.max(0,Math.min(v.length-1,h))}const m=V+d/100*(C-V);return Math.round(m)},[E,s,v,V,C,t]),vr=a.useRef(null),$o=a.useRef(null),Io=a.useRef(0),Ke=a.useRef(null),kn=a.useRef(null),ko=a.useRef(null),No=a.useRef(null),[Nn,Vo]=a.useState(0),[pi,er]=fr(),[Mi,Oo]=fr(),[Di,Yo]=fr(),[vi,Ho]=fr(),[xi,Vn]=fr(),[Ri,_o]=fr(),Si=q?er===null?void 0:{estimatedWidthPx:er.widthPx,estimatedHeightPx:er.heightPx}:so(er,Oo),On=!q&&Se===Le,Yn=Fe===je,Hn=!Y&&Ie===ze,Li=w?"top":"bottom",Ti=w?"bottom":"top",Fo=b&&!u,yi=Fo&&!Y,_n={isPointMode:q,isVertical:u,autoSlantLabels:b,isMerged:On,trackLengthPx:Nn,labelPosition:M,config:Si},Fn={trackLengthPx:Nn,labelPosition:Li,config:so(Yo,Ho),isMerged:Yn,isSlantable:Fo},jn={trackLengthPx:Nn,labelPosition:Ti,config:so(Vn,_o),isMerged:Hn,isSlantable:yi};a.useEffect(()=>{const i=Ke.current;if(!i)return;const d=()=>{const h=i.getBoundingClientRect(),S=u?h.height:h.width;S>0&&Vo(I=>Math.abs(I-S)<.5?I:S)};if(d(),typeof ResizeObserver<"u"){const h=new ResizeObserver(S=>{for(const I of S){const O=u?I.contentRect.height:I.contentRect.width;O>0&&Vo(k=>Math.abs(k-O)<.5?k:O)}});return h.observe(i),()=>h.disconnect()}const m=i.ownerDocument.defaultView;if(m)return m.addEventListener("resize",d),()=>m.removeEventListener("resize",d)},[u]);const tr=a.useCallback((i,d,m)=>{const h=u?m.height:m.width;if(!(Number.isFinite(h)&&h>0))return null;const S=u?m.bottom-d:i-m.left;return Number.isFinite(S)?Math.max(0,Math.min(1,S/h)):null},[u]),jo=a.useCallback((i,d)=>{const m=Ke.current;if(!m)return null;const h=tr(i,d,m.getBoundingClientRect());return h===null?null:h*100},[tr]),xr=a.useRef(null),ht=a.useRef(null),Zr=a.useRef({macroLowRatio:nt,macroHighRatio:st,isVertical:u,isMacroFirstRail:w}),zo=a.useRef({flat:_n,macro:Fn,micro:jn});a.useLayoutEffect(()=>{Zr.current={macroLowRatio:nt,macroHighRatio:st,isVertical:u,isMacroFirstRail:w},zo.current={flat:_n,macro:Fn,micro:jn},X.current=e,Gt.current=[Se,Le],Cn.current=Ao,we.current=j,vt.current=Xe});const Uo=(i,d)=>{const m=Zr.current;kn.current?.setAttribute("d",ro(i,d,m.isVertical,m.isMacroFirstRail))},Pi=(i,d,m)=>{const h=zo.current;return i==="flat"?Ea(d*100,m*100,h.flat).placements:lo(i,d,m,i==="macro"?h.macro:h.micro).placements},Rr=(i,d,m)=>{const h=Ke.current;if(!h)return;xr.current={rail:i,lowRatio:d,highRatio:m},as(h,i,d,m);const S=Pi(i,d,m);S!==null&&os(h,i,S),i==="macro"&&Uo(d,m)},Vt=a.useCallback(()=>{ht.current!==null&&(clearTimeout(ht.current),ht.current=null);const i=Ke.current;i&&(i.removeAttribute(Qn),i.style.removeProperty(eo))},[]),Bo=()=>{const i=Ke.current;if(xr.current===null||!i){xr.current=null;return}xr.current=null,ht.current!==null&&clearTimeout(ht.current),i.style.setProperty(eo,`${Da}ms`),i.setAttribute(Qn,"true"),is(i),Uo(Zr.current.macroLowRatio,Zr.current.macroHighRatio),ht.current=setTimeout(()=>{ht.current=null,i.removeAttribute(Qn),i.style.removeProperty(eo)},Da)};a.useLayoutEffect(()=>{const i=xr.current;i!==null&&Rr(i.rail,i.lowRatio,i.highRatio)}),a.useEffect(()=>()=>{ht.current!==null&&clearTimeout(ht.current)},[]);const rr=a.useRef(null),nr=a.useRef(null),lt=a.useRef(null),zn=a.useRef(null),Sr=a.useRef(null),Tt=a.useCallback(()=>rr.current!==null||nr.current!==null,[]),Wo=i=>{if(l)return;if(de){const B=nr.current;if(!B||i.pointerId!==B.pointerId||!Ke.current)return;const ot=tr(i.clientX,i.clientY,Ke.current.getBoundingClientRect());if(ot===null)return;if(B.handle==="macro-low"||B.handle==="macro-high"||B.handle==="macro-connect"){const[ke,Ae,bt]=ai(B.handle,ot,B.startPointerRatio,B.startMacroLowRatio,B.startMacroHighRatio);Rr("macro",ke,Ae),bt!==vt.current&&(vt.current=bt,Br(bt),Xt(bt));let He,Je;if(Kt){const yt=un(Te,z,s,ke),Pt=Math.max(yt,un(Te,z,s,Ae));He=Te[yt],Je=Te[Pt]}else{const yt=Math.round(Ye+ke*Gr),Pt=Math.round(Ye+Ae*Gr);He=ce(z,yt),Je=ce(z,Pt)}le.show(He,Je);const Ar=`${He.getTime()}_${Je.getTime()}`;Ar!==zn.current&&(zn.current=Ar,kt(He,Je));const[wt,Yt]=mt(z,P,[He,Je],r,n),Zn=J(P,wt),Jn=J(P,Yt),ba=pr?En(Zn,Jn):[];let Ht,_t;if(B.handle==="macro-connect"){const yt=wt,Pt=Yt;let ur,dr;if(z==="year"){const At=He.getFullYear()-B.startMacroLowDate.getFullYear();ur=Ve("year",B.initialMicroLowDate,At),dr=Ve("year",B.initialMicroHighDate,At)}else if(z==="month"){const At=(He.getFullYear()-B.startMacroLowDate.getFullYear())*12+(He.getMonth()-B.startMacroLowDate.getMonth());ur=Ve("month",B.initialMicroLowDate,At),dr=Ve("month",B.initialMicroHighDate,At)}else{const At=Math.round((He.getTime()-B.startMacroLowDate.getTime())/864e5);ur=Ve("day",B.initialMicroLowDate,At),dr=Ve("day",B.initialMicroHighDate,At)}const mr=yt.getTime(),Er=Pt.getTime(),Ma=B.initialMicroHighDate.getTime()-B.initialMicroLowDate.getTime();let Cr=ur.getTime(),$r=dr.getTime();Cr<mr&&(Cr=mr,$r=Math.min(Er,Cr+Ma)),$r>Er&&($r=Er,Cr=Math.max(mr,$r-Ma)),Ht=qe(P,new Date(Cr)),_t=qe(P,new Date($r))}else{const yt=wt.getTime(),Pt=Yt.getTime(),ur=B.initialMicroLowDate.getTime(),dr=B.initialMicroHighDate.getTime(),mr=Math.max(yt,Math.min(Pt,ur)),Er=Math.max(mr,Math.min(Pt,dr));Ht=qe(P,new Date(mr)),_t=qe(P,new Date(Er))}const wa=xt(Ht,ba,Zn,Jn),ts=Math.max(wa,xt(_t,ba,Zn,Jn));Ht=ce(P,wa),_t=ce(P,ts),Pe.show(Ht,_t);const pa=`${Ht.getTime()}_${_t.getTime()}`;pa!==Sr.current&&(Sr.current=pa,Ze(Ht,_t))}else if(B.handle==="micro-low"||B.handle==="micro-high"||B.handle==="micro-connect"||B.handle==="micro-point"){const[ke,Ae,bt]=ii(B.handle,ot,B.startPointerRatio,B.startMicroLowRatio,B.startMicroHighRatio);Rr("micro",ke,Ae),bt!==vt.current&&(vt.current=bt,Br(bt),Xt(bt));let He,Je;if(rt){const wt=un(ue,P,s,ke),Yt=Math.max(wt,un(ue,P,s,Ae));He=ue[wt],Je=ue[Yt]}else{const wt=xt(ce(P,Math.round(ve+ke*Xr)),qt,ve,Ce),Yt=Math.max(wt,xt(ce(P,Math.round(ve+Ae*Xr)),qt,ve,Ce));He=ce(P,wt),Je=ce(P,Yt)}Pe.show(He,Je);const Ar=`${He.getTime()}_${Je.getTime()}`;Ar!==Sr.current&&(Sr.current=Ar,Ze(He,Je))}return}const d=rr.current;if(!d||i.pointerId!==d.pointerId||!Ke.current)return;const m=Ke.current.getBoundingClientRect(),h=u?i.clientY:i.clientX,S=u?m.height:m.width;if(!(Number.isFinite(S)&&S>0))return;if(d.handle==="connect"){const B=u?(d.startPointerPos-h)/S:(h-d.startPointerPos)/S,[ot,ke]=Mo(B,d.startLowRatio,d.startHighRatio);Rr("flat",ot,ke);const Ae=qa({posDiffPct:B,startLowVal:d.startLowVal,startHighVal:d.startHighVal,rangeMin:V,rangeMax:C,isDiscrete:E,sortedAllowedDates:v,snapMode:s,unit:t});if(lt.current&<.current[0]===Ae[0]&<.current[1]===Ae[1])return;lt.current=Ae,T(Ae),Lt(Ae[0],Ae[1],!1);return}const I=tr(i.clientX,i.clientY,m);if(I===null)return;const[O,k]=wn(q?"point":d.handle,I,d.startLowRatio,d.startHighRatio);Rr("flat",O,k);const oe=In(I*100),[ge,xe]=ho(d.handle,oe,d.startLowVal,d.startHighVal,V,C,q);if((!lt.current||lt.current[0]!==ge||lt.current[1]!==xe)&&(lt.current=[ge,xe],T([ge,xe]),Lt(ge,xe,!1)),!q&&(d.handle==="low"||d.handle==="high")){const B=Ln(d.handle,I,d.startLowRatio,d.startHighRatio);we.current!==B&&(we.current=B,be(B),$e(B))}},Go=()=>{Bo(),zn.current=null,Sr.current=null,nr.current=null,vt.current=null,Br(null),le.release(),Pe.release(),Eo(Kr.current),Eo(qr.current)},Xo=()=>{Bo();const i=lt.current??N;i&&(Lt(i[0],i[1],!0),L(i)),lt.current=null,T(null),rr.current=null,we.current=null,be(null)},Ko=i=>{if(de){const m=nr.current;if(!m||i.pointerId!==m.pointerId)return;Go();return}const d=rr.current;!d||i.pointerId!==d.pointerId||Xo()},qo=()=>{nr.current!==null&&Go(),rr.current!==null&&Xo()},Un=a.useRef(Wo),Zo=a.useRef(Ko),Jo=a.useRef(qo);a.useLayoutEffect(()=>{Un.current=Wo,Zo.current=Ko,Jo.current=qo});const Qo=a.useRef(de);a.useEffect(()=>{Qo.current!==de&&(Qo.current=de,Jo.current())},[de]);const ea=j!==null||Xe!==null;a.useEffect(()=>{if(!ea)return;const i=vr.current?.ownerDocument.defaultView;if(!i)return;const d=h=>Un.current(h),m=h=>Zo.current(h);return i.addEventListener("pointermove",d),i.addEventListener("pointerup",m),i.addEventListener("pointercancel",m),i.addEventListener("lostpointercapture",m),()=>{i.removeEventListener("pointermove",d),i.removeEventListener("pointerup",m),i.removeEventListener("pointercancel",m),i.removeEventListener("lostpointercapture",m)}},[ea]);const Bn=a.useCallback((i,d,m,h)=>{Vt(),Ia(i,d),rr.current={pointerId:d,handle:m,startPointerPos:h,startLowVal:Se,startHighVal:Le,startLowRatio:Nt(Se)/100,startHighRatio:Nt(Le)/100},we.current=m,be(m),m!=="connect"&&$e(m)},[Se,Le,Nt]),ta=a.useCallback((i,d,m,h)=>{X.current.mode==="vernier"&&(Vt(),Ia(i,d),nr.current={pointerId:d,handle:m,startPointerRatio:h,startMacroLowRatio:nt,startMacroHighRatio:st,startMicroLowRatio:Zt,startMicroHighRatio:Dr,startMacroLowDate:gt,initialMicroLowDate:Rt,initialMicroHighDate:St},vt.current=m,Br(m),Xt(m))},[nt,st,Zt,Dr,gt,Rt,St]),ra=i=>d=>{if(l||Tt())return;d.stopPropagation(),d.preventDefault(),$e(i);const m=u?d.clientY:d.clientX;Bn(d.currentTarget,d.pointerId,i,m)},na=i=>()=>{l||we.current!==null||$e(i)},Jr=i=>()=>{l||vt.current!==null||Xt(i)},or=i=>d=>{if(l||Tt())return;d.stopPropagation(),d.preventDefault();const m=Ke.current;if(!m)return;const h=tr(d.clientX,d.clientY,m.getBoundingClientRect());h!==null&&ta(d.currentTarget,d.pointerId,i,h)},Ai=i=>{if(l||D||Tt())return;i.stopPropagation(),i.preventDefault();const d=u?i.clientY:i.clientX;Bn(i.currentTarget,i.pointerId,"connect",d)},Ei=i=>{if(l||Tt())return;if(de){const k=Ke.current;if(!k)return;const oe=k.getBoundingClientRect(),ge=tr(i.clientX,i.clientY,oe);if(ge===null)return;const xe=u?i.clientX-(oe.left+oe.width/2):i.clientY-(oe.top+oe.height/2),B=oi(ge,xe,nt,st,Zt,Dr,x,void 0,!D,Y?"point":"range");ta(i.currentTarget,i.pointerId,B,ge),Un.current(i.nativeEvent);return}const d=jo(i.clientX,i.clientY);if(d===null)return;const m=In(d);let h="low";if(!q){const k=Math.abs(m-Se),oe=Math.abs(m-Le);k<oe?h="low":oe<k?h="high":h=m>Le?"high":"low"}$e(h);const[S,I]=ho(h,m,Se,Le,V,C,q);T([S,I]),Lt(S,I,!0);const O=u?i.clientY:i.clientX;Bn(i.currentTarget,i.pointerId,h,O)},Ci=i=>{if(l||de||j!==null)return;const d=jo(i.clientX,i.clientY);if(d===null)return;const m=In(d);Dt(m),jr(Nt(m))},$i=()=>{Dt(null),jr(null)},oa=i=>d=>{if(l||Tt())return;$e(i);const m=Za(d.key,i,Se,Le,V,C,q,1);m&&(d.preventDefault(),Vt(),te||L(m),Lt(m[0],m[1],!0))},ar=(i,d)=>{if(R===null)return;const[m,h]=mt(z,P,[i,d],r,n),S=J(P,m),I=J(P,h),O=pr?En(S,I):[],k=xt(R[0],O,S,I),oe=Math.max(k,xt(R[1],O,S,I));Ze(ce(P,k),ce(P,oe),!0)},Qr=i=>d=>{if(l||!de||e.mode!=="vernier"||Tt())return;Xt(i);let m=0,h=!1,S=!1;switch(d.key){case"ArrowRight":case"ArrowUp":m=1;break;case"ArrowLeft":case"ArrowDown":m=-1;break;case"PageUp":m=5;break;case"PageDown":m=-5;break;case"Home":h=!0;break;case"End":S=!0;break;default:return}if(d.preventDefault(),Vt(),i==="macro-low"){const I=ce(z,Fe),O=ce(z,je);if(Kt){const ge=kr(Te,z,I,Te[0],O,m,h,S);if(ge===fe(Te,I,z))return;const xe=Te[ge];kt(xe,O,!0),ar(xe,O);return}let k;if(h?k=Ye:S?k=je:k=Math.max(Ye,Math.min(je,Fe+m)),k===Fe)return;const oe=ce(z,k);kt(oe,O,!0),ar(oe,O)}else if(i==="macro-high"){const I=ce(z,Fe),O=ce(z,je);if(Kt){const ge=kr(Te,z,O,I,Te[Te.length-1],m,h,S);if(ge===fe(Te,O,z))return;const xe=Te[ge];kt(I,xe,!0),ar(I,xe);return}let k;if(h?k=Fe:S?k=it:k=Math.max(Fe,Math.min(it,je+m)),k===je)return;const oe=ce(z,k);kt(I,oe,!0),ar(I,oe)}else if(i==="micro-low"){const I=ce(P,Ie),O=ce(P,ze);if(rt){const oe=kr(ue,P,I,ue[0],O,m,h,S);if(oe===fe(ue,I,P))return;Ze(ue[oe],O,!0);return}let k;if(h?k=ve:S?k=ze:k=Math.max(ve,Math.min(ze,Ie+m)),k===Ie)return;Ze(ce(P,k),O,!0)}else if(i==="micro-high"){const I=ce(P,Ie),O=ce(P,ze);if(rt){const oe=kr(ue,P,O,I,ue[ue.length-1],m,h,S);if(oe===fe(ue,O,P))return;Ze(I,ue[oe],!0);return}let k;if(h?k=Ie:S?k=Ce:k=Math.max(Ie,Math.min(Ce,ze+m)),k===ze)return;Ze(I,ce(P,k),!0)}else if(i==="micro-point"){const I=ce(P,Ie);if(rt){const k=kr(ue,P,I,ue[0],ue[ue.length-1],m,h,S);if(k===fe(ue,I,P))return;Co(ue[k],!0);return}let O;if(h?O=ve:S?O=Ce:O=Math.max(ve,Math.min(Ce,Ie+m)),O===Ie)return;Co(ce(P,O),!0)}},Ii=i=>{if(e.mode!=="vernier")return;if(Vt(),Kt){const O=Te.length-1,k=fe(Te,gt,z),oe=fe(Te,It,z),ge=oe-k;let xe=k+i,B=oe+i;if(i<0&&xe<0?(xe=0,B=Math.min(O,ge)):i>0&&B>O&&(B=O,xe=Math.max(0,O-ge)),xe===k&&B===oe)return;const ot=Te[xe],ke=Te[B];kt(ot,ke,!0),ar(ot,ke);return}const d=je-Fe;let m=Fe+i,h=je+i;if(i<0&&m<Ye?(m=Ye,h=Math.min(it,m+d)):i>0&&h>it&&(h=it,m=Math.max(Ye,h-d)),m===Fe&&h===je)return;const S=ce(z,m),I=ce(z,h);kt(S,I,!0),ar(S,I)},Wn=a.useCallback(i=>{const d=X.current;if(!(d.disabled||Tt()))if(Vt(),d.mode==="point"){const m=Math.max(V,Math.min(C,Se+i));te||L([m,m]),Lt(m,m,!0)}else if(d.mode==="vernier"){if(rt){const ge=ue.length-1,xe=fe(ue,Rt,P),B=fe(ue,St,P),ot=B-xe;let ke=xe+i,Ae=B+i;i<0&&ke<0?(ke=0,Ae=Math.min(ge,ot)):i>0&&Ae>ge&&(Ae=ge,ke=Math.max(0,ge-ot)),(ke!==xe||Ae!==B)&&Ze(ue[ke],ue[Ae],!0);return}const m=Ie,h=ze,S=ve,I=Ce,O=h-m;let k=m+i,oe=h+i;i<0&&k<S?(k=S,oe=Math.min(I,k+O)):i>0&&oe>I&&(oe=I,k=Math.max(S,oe-O)),(k!==m||oe!==h)&&Ze(ce(P,k),ce(P,oe),!0)}else{const m=Le-Se;let h=Se+i,S=Le+i;i<0&&h<V?(h=V,S=Math.min(C,h+m)):i>0&&S>C&&(S=C,h=Math.max(V,S-m)),h<=S&&(te||L([h,S]),Lt(h,S,!0))}},[Se,Le,V,C,te,Lt,Ze,Ie,ze,ve,Ce,P,rt,ue,Rt,St,Vt]),aa=i=>!l&&no(vr.current,i),ia=(i,d)=>{const m=$o.current,h=Ke.current,S=vr.current;if(l||m===null||h===null||S===null||!ms(m,S,Io.current,u,i,d))return null;const I=h.getBoundingClientRect();return Math.abs(u?i-(I.left+I.width/2):d-(I.top+I.height/2))},sa=i=>{if(l||Tt())return;const d=ni(i.deltaX,i.deltaY,u);if(d===0)return;i.preventDefault();const m=i.target,h=no(ko.current,m)||no(No.current,m);if(!de||h){Wn(d);return}const S=Ke.current;if(!S)return;const I=S.getBoundingClientRect(),O=u?i.clientX-(I.left+I.width/2):i.clientY-(I.top+I.height/2);if(xo(O,x)==="macro"){Ii(d);return}Wn(d)},en=a.useRef({ownsWheelHit:aa,distanceToRailPx:ia,stepFromRangeAreaWheel:sa});a.useLayoutEffect(()=>{en.current={ownsWheelHit:aa,distanceToRailPx:ia,stepFromRangeAreaWheel:sa}});const Lr=a.useRef(null);a.useEffect(()=>{const i=vr.current?.ownerDocument.defaultView??null,d=Lr.current;if(d!==null&&d.view===i)return;if(d?.unregister(),i===null){Lr.current=null;return}const m=gs(i,{ownsHit:h=>en.current.ownsWheelHit(h),distanceToRailPx:(h,S)=>en.current.distanceToRailPx(h,S),step:h=>en.current.stepFromRangeAreaWheel(h)});Lr.current={view:i,unregister:m}}),a.useEffect(()=>()=>{Lr.current?.unregister(),Lr.current=null},[]);const tn=Nt(Se),rn=Nt(Le),Gn=se(Se),Xn=se(Le),Kn=Ea(tn,rn,_n),Tr=Kn.slant,yr=j==="low"||j!=="high"&&Ee==="low",Pr=!q&&(j==="high"||j!=="low"&&Ee==="high"),ki=Yn&&Ne!=="macro-low",Ni=Yn&&Ne==="macro-low",Vi=Hn&&Ne!=="micro-low",Oi=Hn&&Ne==="micro-low",ir=lo("macro",nt,st,Fn),sr=lo("micro",Zt,Dr,jn),Yi=Math.min(tn,rn),Hi=Math.max(tn,rn),[la,ca]=Hr.flat,[_i,Fi]=Hr.macro,[ji,zi]=Hr.micro,ua=Et(la,tn),da=Et(ca,rn),qn=Et(la,Yi),ma=`calc(${Et(ca,Hi)} - ${qn})`,lr=Et(_i,nt*100),nn=Et(Fi,st*100),cr=Et(ji,Zt*100),on=Et(zi,Dr*100),Ui=u?{bottom:qn,height:ma,top:"auto",left:"0",right:"0"}:{left:qn,width:ma,top:"0",bottom:"0"},Bi=Math.max(.01,st-nt),fa=Math.max(.06,Math.min(.25,.28*Math.sqrt(Bi))),Wi=u?{bottom:ua,left:"50%",transform:"translate(-50%, 50%)",zIndex:yr?40:30}:{left:ua,top:"50%",transform:"translate(-50%, -50%)",zIndex:yr?40:30},Gi=u?{bottom:da,left:"50%",transform:"translate(-50%, 50%)",zIndex:Pr?40:30}:{left:da,top:"50%",transform:"translate(-50%, -50%)",zIndex:Pr?40:30},Xi=u?{bottom:`${ft}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${ft}%`,top:"50%",transform:"translate(-50%, -50%)"},ga=_e!==null?se(_e):null,Ki=g!=="hover"&&_e!==null&&(_e===Se||!q&&_e===Le),qi=rt?J(P,ue[0]):ve,Zi=rt?J(P,ue[ue.length-1]):Ce,Ji=de?Ie>qi:Se>V,Qi=de?ze<Zi:Le<C,an=Cs(de?[{side:w?"before":"after",box:gn(Yo,Ho),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:ir.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:ir.slant.lowOffsetX}},{side:w?"after":"before",box:Y?Vn:gn(Vn,_o),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:sr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:sr.slant.lowOffsetX}}]:[{side:u||M==="top"?"before":"after",box:q?er:gn(er,Oo),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:Tr.lowAngleDeg,centreOffsetPx:Tr.lowOffsetY,alongPushPx:Tr.lowOffsetX}}]),es=an===void 0?e.style:{...e.style,...an.style};a.useLayoutEffect(()=>{Io.current=an===void 0?0:an.mainPx});const ct=Y?"micro-point":"micro-low",Ot=l?"cursor-not-allowed opacity-50":"cursor-pointer",ha=i=>{const d=u?"vertical":"horizontal",m=i==="decrease",h=u?!m:m;return p.jsx(Wt,{ref:m?ko:No,neighbour:"rail",direction:$s[d][i],disabled:l,canStep:m?Ji:Qi,onStep:()=>Wn(m?-1:1),ariaLabel:m?ae:ne,className:`period-slider-stepper-btn ${Is[d][i]} ${$a[d][h?"leading":"trailing"]}`})};return p.jsxs("div",{ref:vr,style:es,className:`period-slider grid select-none place-items-center ${ks[u?"vertical":"horizontal"][f?"withSteppers":"railOnly"]} ${c}`,"data-disabled":l?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":u?"vertical":"horizontal","data-label-position":M,"data-color-scheme":Q,children:[p.jsx("div",{ref:$o,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),f&&ha(u?"increase":"decrease"),p.jsx("div",{ref:Ke,"data-testid":"period-slider-track","data-orientation":u?"vertical":"horizontal","data-vernier-orientation":de?x:void 0,className:`period-slider-track relative touch-none rounded-full ${$a[u?"vertical":"horizontal"][f?"rail":"railOnly"]} ${Ot}`,onPointerDown:Ei,onPointerMove:Ci,onPointerLeave:$i,children:de?p.jsxs(p.Fragment,{children:[tt&&(u?p.jsxs("svg",{className:"period-slider-vernier-projection is-vertical",role:"presentation","aria-hidden":"true",width:"32",height:"100%",viewBox:"0 0 32 100",preserveAspectRatio:"none",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"1",y2:"0",children:[p.jsx("stop",{offset:"0%",stopColor:w?H.macro:H.micro,stopOpacity:"0.28"}),p.jsx("stop",{offset:"100%",stopColor:w?H.micro:H.macro,stopOpacity:fa})]})}),p.jsx("path",{ref:kn,"data-testid":"period-slider-vernier-projection",d:ro(nt,st,u,w),fill:`url(#${ie})`})]}):p.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"0",y2:"1",children:[p.jsx("stop",{offset:"0%",stopColor:w?H.macro:H.micro,stopOpacity:"0.28"}),p.jsx("stop",{offset:"100%",stopColor:w?H.micro:H.macro,stopOpacity:fa})]})}),p.jsx("path",{ref:kn,"data-testid":"period-slider-vernier-projection",d:ro(nt,st,u,w),fill:`url(#${ie})`})]})),!D&&p.jsxs(p.Fragment,{children:[p.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:u?{bottom:`calc(${lr} - 8px)`,height:`calc(${nn} - ${lr} + 16px)`}:{left:`calc(${lr} - 8px)`,width:`calc(${nn} - ${lr} + 16px)`},onPointerDown:or("macro-connect")}),!Y&&p.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:u?{bottom:`calc(${cr} - 8px)`,height:`calc(${on} - ${cr} + 16px)`}:{left:`calc(${cr} - 8px)`,width:`calc(${on} - ${cr} + 16px)`},onPointerDown:or("micro-connect")})]}),wr&&p.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(i=>p.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:u?{bottom:`${i*100}%`}:{left:`${i*100}%`}},`macro-tick-${i}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(i=>p.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:u?{bottom:`${i*100}%`}:{left:`${i*100}%`}},`micro-tick-${i}`))]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":l?"true":void 0,"aria-valuemin":Ye,"aria-valuemax":je,"aria-valuenow":Fe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(gt,z):Ft(z,gt,zr,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:lr,left:w?0:"auto",right:w?"auto":0,transform:w?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Xe==="macro-low"||Ne==="macro-low"?30:15}:{left:lr,top:w?0:"auto",bottom:w?"auto":0,transform:w?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Xe==="macro-low"||Ne==="macro-low"?30:15},onPointerDown:or("macro-low"),onKeyDown:Qr("macro-low"),onFocus:Jr("macro-low"),"data-active":Xe==="macro-low"?"true":void 0,"data-front":Ne==="macro-low"?"true":void 0,"data-vernier-pos":u?w?"left":"right":w?"top":"bottom","data-handle-type":"macro-low",children:[p.jsx(Yr,{type:"macro",isTop:w,isVertical:u,isLeft:w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":ki?"true":void 0,"data-slanted":ir.slant.isSlanted?"true":void 0,ref:Di,style:ir.lowStyle,children:Ue(z,gt,zr,y)})]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":l?"true":void 0,"aria-valuemin":Fe,"aria-valuemax":it,"aria-valuenow":je,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(It,z):Ft(z,It,zr,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:nn,left:w?0:"auto",right:w?"auto":0,transform:w?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Xe==="macro-high"||Ne==="macro-high"?30:15}:{left:nn,top:w?0:"auto",bottom:w?"auto":0,transform:w?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Xe==="macro-high"||Ne==="macro-high"?30:15},onPointerDown:or("macro-high"),onKeyDown:Qr("macro-high"),onFocus:Jr("macro-high"),"data-active":Xe==="macro-high"?"true":void 0,"data-front":Ne==="macro-high"?"true":void 0,"data-vernier-pos":u?w?"left":"right":w?"top":"bottom","data-handle-type":"macro-high",children:[p.jsx(Yr,{type:"macro",isTop:w,isVertical:u,isLeft:w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Ni?"true":void 0,"data-slanted":ir.slant.isSlanted?"true":void 0,ref:vi,style:ir.highStyle,children:Ue(z,It,zr,y)})]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":Y?e.pointAriaLabel??"Micro selected date":e.lowerAriaLabel??"Micro range start","aria-disabled":l?"true":void 0,"aria-valuemin":ve,"aria-valuemax":Y?Ce:ze,"aria-valuenow":Ie,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Rt,P):Ft(P,Rt,Ur,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:cr,left:w?"auto":0,right:w?0:"auto",transform:w?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Xe===ct||Ne===ct?30:20}:{left:cr,top:w?"auto":0,bottom:w?0:"auto",transform:w?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Xe===ct||Ne===ct?30:20},onPointerDown:or(ct),onKeyDown:Qr(ct),onFocus:Jr(ct),"data-active":Xe===ct?"true":void 0,"data-front":Ne===ct?"true":void 0,"data-vernier-pos":u?w?"right":"left":w?"bottom":"top","data-handle-type":ct,children:[p.jsx(Yr,{type:"micro",isTop:!w,isVertical:u,isLeft:!w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Vi?"true":void 0,"data-slanted":sr.slant.isSlanted?"true":void 0,ref:xi,style:sr.lowStyle,children:Ue(P,Rt,Ur,y)})]}),!Y&&p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":l?"true":void 0,"aria-valuemin":Ie,"aria-valuemax":Ce,"aria-valuenow":ze,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(St,P):Ft(P,St,Ur,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?w?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":w?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${Ot}`,style:u?{bottom:on,left:w?"auto":0,right:w?0:"auto",transform:w?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Xe==="micro-high"||Ne==="micro-high"?30:20}:{left:on,top:w?"auto":0,bottom:w?0:"auto",transform:w?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Xe==="micro-high"||Ne==="micro-high"?30:20},onPointerDown:or("micro-high"),onKeyDown:Qr("micro-high"),onFocus:Jr("micro-high"),"data-active":Xe==="micro-high"?"true":void 0,"data-front":Ne==="micro-high"?"true":void 0,"data-vernier-pos":u?w?"right":"left":w?"bottom":"top","data-handle-type":"micro-high",children:[p.jsx(Yr,{type:"micro",isTop:!w,isVertical:u,isLeft:!w}),at&&p.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Oi?"true":void 0,"data-slanted":sr.slant.isSlanted?"true":void 0,ref:Ri,style:sr.highStyle,children:Ue(P,St,Ur,y)})]})]}):p.jsxs(p.Fragment,{children:[!D&&p.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Ui,onPointerDown:Ai}),K&&E&&v.length>1&&p.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:v.map((i,d)=>{const m=J(t,i),h=Nt(d),S=u?{bottom:`${h}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${h}%`,top:"50%",transform:"translate(-50%, -50%)"};return p.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:S},`tick-${m}`)})}),!l&&_e!==null&&ft!==null&&j===null&&ga&&p.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Xi,children:[p.jsx("div",{"data-testid":"period-slider-hover-dot",className:"period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-[var(--aqps-accent-light)] shadow-[0_0_6px_var(--aqps-accent-glow)] dark:border-slate-800"}),p.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Ki?"true":void 0,className:`period-slider-hover-tooltip ${M==="bottom"&&!u?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:Ue(t,ga,e.formatLabel,y)})]}),p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":q?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":l?"true":void 0,"aria-valuemin":V,"aria-valuemax":q?C:Le,"aria-valuenow":Se,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Gn,t):Ft(t,Gn,e.formatLabel,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Ot}`,style:Wi,onPointerDown:ra("low"),onKeyDown:oa("low"),onFocus:na("low"),"data-active":j==="low"?"true":void 0,"data-front":yr?"true":void 0,children:[p.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${j==="low"?"":"shadow-md"}`}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":M,"data-slanted":Tr.isSlanted?"true":void 0,"data-front":yr?"true":void 0,"data-duplicate":On&&!yr?"true":void 0,ref:pi,style:Kn.lowStyle,children:Ue(t,Gn,e.formatLabel,y)})]}),!q&&p.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":l?"true":void 0,"aria-valuemin":Se,"aria-valuemax":C,"aria-valuenow":Le,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Xn,t):Ft(t,Xn,e.formatLabel,y),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Ot}`,style:Gi,onPointerDown:ra("high"),onKeyDown:oa("high"),onFocus:na("high"),"data-active":j==="high"?"true":void 0,"data-front":Pr?"true":void 0,children:[p.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${j==="high"?"":"shadow-md"}`}),g!=="hover"&&p.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":M,"data-slanted":Tr.isSlanted?"true":void 0,"data-front":Pr?"true":void 0,"data-duplicate":On&&!Pr?"true":void 0,ref:Mi,style:Kn.highStyle,children:Ue(t,Xn,e.formatLabel,y)})]})]})}),f&&ha(u?"decrease":"increase")]})},co=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r].getTime()!==t[r].getTime())return!1;return!0},si=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(e[o]!==t[o])return!1;return!0},Vs=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.minDate.getTime()!==t.minDate.getTime()||e.maxDate.getTime()!==t.maxDate.getTime()||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.isVertical!==t.isVertical||e.hideConnectBar!==t.hideConnectBar||e.showTicks!==t.showTicks||e.disabled!==t.disabled||e.showStepper!==t.showStepper||e.debounceMs!==t.debounceMs||e.tooltipStyle!==t.tooltipStyle||e.colorScheme!==t.colorScheme||e.className!==t.className||!si(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.locale!==t.locale||e.lowerAriaLabel!==t.lowerAriaLabel||e.upperAriaLabel!==t.upperAriaLabel||e.pointAriaLabel!==t.pointAriaLabel||e.macroLowerAriaLabel!==t.macroLowerAriaLabel||e.macroUpperAriaLabel!==t.macroUpperAriaLabel||e.decreaseAriaLabel!==t.decreaseAriaLabel||e.increaseAriaLabel!==t.increaseAriaLabel||e.formatAriaValueText!==t.formatAriaValueText||!co(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!((e.value?.getTime()??null)!==(t.value?.getTime()??null)||(e.defaultValue?.getTime()??null)!==(t.defaultValue?.getTime()??null)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!((e.range?.[0]?.getTime()??null)!==(t.range?.[0]?.getTime()??null)||(e.range?.[1]?.getTime()??null)!==(t.range?.[1]?.getTime()??null)||(e.defaultRange?.[0]?.getTime()??null)!==(t.defaultRange?.[0]?.getTime()??null)||(e.defaultRange?.[1]?.getTime()??null)!==(t.defaultRange?.[1]?.getTime()??null)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!((e.microRange?.[0]?.getTime()??null)!==(t.microRange?.[0]?.getTime()??null)||(e.microRange?.[1]?.getTime()??null)!==(t.microRange?.[1]?.getTime()??null)||(e.defaultMicroRange?.[0]?.getTime()??null)!==(t.defaultMicroRange?.[0]?.getTime()??null)||(e.defaultMicroRange?.[1]?.getTime()??null)!==(t.defaultMicroRange?.[1]?.getTime()??null)||(e.microValue?.getTime()??null)!==(t.microValue?.getTime()??null)||(e.defaultMicroValue?.getTime()??null)!==(t.defaultMicroValue?.getTime()??null)||e.macroRange[0].getTime()!==t.macroRange[0].getTime()||e.macroRange[1].getTime()!==t.macroRange[1].getTime()||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.macroUnit!==t.macroUnit||e.microUnit!==t.microUnit||e.macroIsDiscrete!==t.macroIsDiscrete||e.microIsDiscrete!==t.microIsDiscrete||e.formatMacroLabel!==t.formatMacroLabel||e.formatMicroLabel!==t.formatMicroLabel||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMicroPoint!==t.onChangeMicroPoint||e.onChangeMacroRange!==t.onChangeMacroRange||!co(e.macroAllowedDates,t.macroAllowedDates)||!co(e.microAllowedDates,t.microAllowedDates)):!1,li=a.memo(Ns,Vs);li.displayName="PeriodSlider";const ci=864e5,Os=4,Ys=6,ka=2,Re=-1,hn=e=>{const t=e.getFullYear(),r=new Date(Date.UTC(t,e.getMonth(),e.getDate()));return r.setUTCFullYear(t),Math.floor(r.getTime()/ci)},ui=e=>{const t=new Date(e*ci),r=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return r.setFullYear(t.getUTCFullYear()),r.setHours(0,0,0,0),r},Ut=e=>{const t=e.getFullYear();return`${t>=0?String(t).padStart(Os,"0"):`-${String(-t).padStart(Ys,"0")}`}-${String(e.getMonth()+1).padStart(ka,"0")}-${String(e.getDate()).padStart(ka,"0")}`},Hs=(e,t,r)=>{const n=hn(e),o=hn(t),s=o>=n?o-n+1:0,l=c=>ui(o-c);return{count:s,dateAt:l,valueAt:c=>Ut(l(c)),labelAt:c=>Ue("day",l(c),void 0,r),indexOf:c=>{const f=hn(c);return f<n||f>o?Re:o-f}}},_s=(e,t,r,n)=>{const o=r>=t?r-t+1:0,s=l=>e[r-l];return{count:o,dateAt:s,valueAt:l=>Ut(s(l)),labelAt:l=>Ue("day",s(l),void 0,n),indexOf:l=>{const c=l.getTime();let f=t,g=r;for(;f<=g;){const M=f+g>>1,b=e[M].getTime();if(b===c)return r-M;b<c?f=M+1:g=M-1}return Re}}},Fs={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},valueAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},indexOf:()=>Re},js=(e,t,r)=>{const n=c=>{let f=0,g=e.length;for(;f<g;){const M=f+g>>1;e[M].getTime()<c?f=M+1:g=M}return f},o=c=>{let f=0,g=e.length;for(;f<g;){const M=f+g>>1;e[M].getTime()<=c?f=M+1:g=M}return f},s=t===null?0:n(t.getTime()),l=(r===null?e.length:o(r.getTime()))-1;return{loIndex:s,hiIndex:l}},Na=(e,t,r,n,o)=>{let s=t,l=r,c=null;for(;s<=l;){const f=s+l>>1,g=e[f].getTime();o===-1?g<n?(c=e[f],s=f+1):l=f-1:g>n?(c=e[f],l=f-1):s=f+1}return c},zs=(e,t)=>{const r=new Map;return e.forEach((n,o)=>{t(o,n);const s=new Date(n);s.setHours(0,0,0,0);const l=s.getTime();r.has(l)||r.set(l,s)}),Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},bn=44,Va=7,dn=8,Us=2,di=10,Bs=1e3,wo=8,uo=6,mo=4,fo=12,Nr=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),hn(r)},Ws=(e,t)=>{if(e.length<mo||t.count===0)return Re;const r=Number(e.slice(0,mo));if(!Number.isInteger(r))return Re;const n=e.length>=uo,o=n?Number(e.slice(mo,uo)):fo;if(o<1||o>fo)return Re;const s=e.length>=wo,l=s?Number(e.slice(uo,wo)):0,c=Nr(r,o),f=(o===fo?Nr(r+1,1):Nr(r,o+1))-1,g=s?c+l-1:n?c:Nr(r,1),M=s?g:n?f:Nr(r+1,1)-1;if(s&&(l<1||g>f))return Re;for(let b=M;b>=g;b--){const u=t.indexOf(ui(b));if(u!==Re)return u}return Re},Gs=e=>e.closest(".dark")===null?"light":"dark",Xs=(e,t,r,n)=>{const o=r-e.bottom-dn,s=e.top-dn,l=o>=t||o>=s,f=Math.max(bn,Math.min(t,l?o:s)),g=l?e.bottom:e.top-f,M=e.width+di,b=Math.max(dn,Math.min(e.left,n-M-dn));return{top:g,left:b,width:M,height:f}},mi=({domain:e,selectedIndex:t,displayLabel:r,machineValue:n,disabled:o,ariaLabel:s,onCommitIndex:l,controlClassName:c})=>{const f=a.useId(),g=`period-slider-date-listbox-${f}`,M=R=>`period-slider-date-option-${f}-${R}`,[b,u]=a.useState(!1),[D,K]=a.useState(Re),[Q,y]=a.useState(!0),[ae,ne]=a.useState(null),[$,Y]=a.useState(null),H=a.useRef(null),ie=a.useRef(null),X=a.useRef(null),U=a.useRef({buffer:"",at:0}),A=a.useRef(e);A.current=e;const v=e.count,E=Math.min(v,Va)*bn,V=Math.max(1,Math.min(v,Va)),C=a.useCallback(()=>{const R=H.current;if(R===null)return;const ee=R.getBoundingClientRect();ne(Xs(ee,E,window.innerHeight,window.innerWidth))},[E]),q=a.useCallback(()=>{u(!1),K(Re),U.current={buffer:"",at:0}},[]),se=a.useCallback(R=>{o||v===0||(K(R),u(!0))},[o,v]);a.useLayoutEffect(()=>{if(!b){ne(null),Y(null);return}const R=H.current;return R!==null&&Y(Gs(R)),C(),window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[b,C]),a.useEffect(()=>{if(!b)return;const R=ee=>{const he=ee.target;he!==null&&ie.current?.contains(he)!==!0&&H.current?.contains(he)!==!0&&q()};return document.addEventListener("pointerdown",R,!0),()=>document.removeEventListener("pointerdown",R,!0)},[b,q]);const W=a.useRef(D);W.current=D,a.useEffect(()=>{if(!b)return;const R=W.current;R!==Re&&X.current?.scrollToIndex(Math.min(R,v-1),{align:"center"})},[v,b]);const G=R=>{if(v===0)return;const ee=Math.max(0,Math.min(R,v-1));K(ee),X.current?.scrollToIndex(ee,{align:"center"})},_=R=>{R<0||R>=v||(l(R),q(),H.current?.focus())},F=R=>{if(o)return;const ee=D!==Re?D:t!==Re?t:0;switch(R.key){case"ArrowDown":if(R.preventDefault(),!b){se(ee);return}G(ee+1);return;case"ArrowUp":if(R.preventDefault(),!b){se(ee);return}G(ee-1);return;case"Home":if(!b)return;R.preventDefault(),G(0);return;case"End":if(!b)return;R.preventDefault(),G(v-1);return;case"PageDown":if(!b)return;R.preventDefault(),G(ee+V);return;case"PageUp":if(!b)return;R.preventDefault(),G(ee-V);return;case"Enter":if(R.preventDefault(),!b){se(ee);return}_(D!==Re?D:ee);return;case"Escape":if(!b)return;R.preventDefault(),q();return;case"Tab":b&&q();return}if(R.key.length!==1)return;const he=R.key>="0"&&R.key<="9",De=R.key==="-"||R.key==="/"||R.key===".";if(!(he||De))return;R.preventDefault();const Me=Date.now(),Oe=Me-U.current.at>Bs?"":U.current.buffer,We=he?`${Oe}${R.key}`.slice(0,wo):Oe;U.current={buffer:We,at:Me};const Ge=Ws(We,A.current);if(Ge!==Re){if(!b){se(Ge);return}G(Ge)}},me=a.useCallback(R=>R,[]),ye=a.useCallback(()=>bn,[]),le=a.useCallback(R=>{const ee=W.current;y(ee===Re||ee>=R.renderingStartIndex&&ee<=R.renderingEndIndex)},[]),Pe=b&&ae!==null&&$!==null&&v>0?p.jsx("div",{ref:ie,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":$,style:{top:ae.top,left:ae.left,width:ae.width,height:ae.height},onMouseDown:R=>{R.preventDefault()},children:p.jsx(rs.VirtualScroll,{ref:X,itemCount:v,getItem:me,getItemHeight:ye,viewportSize:ae.height-Us,initialScrollIndex:D!==Re?D:void 0,onRangeChange:le,className:"h-full w-full",testId:"period-slider-date-listbox-pane",contentProps:{id:g,role:"listbox","aria-label":s},scrollBarOptions:{width:di,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:R=>{const ee=R===t,he=R===D;return p.jsx("div",{id:M(R),role:"option","aria-selected":ee,"aria-posinset":R+1,"aria-setsize":v,"data-testid":"period-slider-date-option","data-active":he?"true":void 0,className:"period-slider-date-option",style:{height:bn},onClick:()=>_(R),children:A.current.labelAt(R)})}})}):null;return p.jsxs(p.Fragment,{children:[p.jsx("input",{ref:H,type:"text",role:"combobox",readOnly:!0,"aria-label":s,"aria-expanded":b,"aria-controls":b?g:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":b&&D!==Re&&Q?M(D):void 0,disabled:o,value:r,className:c,"data-testid":"period-slider-date-combobox","data-value":n,onKeyDown:F,onMouseDown:R=>{o||(R.preventDefault(),H.current?.focus(),b?q():se(t!==Re?t:0))},onBlur:()=>{b&&q()}}),Pe===null?null:ns.createPortal(Pe,document.body)]})};mi.displayName="VirtualDateDropdown";const jt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Vr=(e,t)=>{if(Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},Ks=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "locale" must be a valid BCP 47 language tag (received ${JSON.stringify(e)})`)}},Bt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Oa=e=>Bt(e,1,1),qs=e=>Bt(e,12,31),Zs={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},Js={year:4,month:2,day:2},Qs={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Ya=new Map,el=(e,t)=>{const r=`${e}\0${t}`,n=Ya.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Zs[e]);return Ya.set(r,o),o},go=(e,t,r)=>r===void 0?String(Qs[e](t)).padStart(Js[e],"0"):el(e,r).format(t),tl=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:s,maxYear:l,minDate:c,maxDate:f,allowedDates:g,variant:M="date",className:b="",style:u,disabled:D=!1,prevDateAriaLabel:K="Previous day",nextDateAriaLabel:Q="Next day",selectAriaLabel:y="Date",yearAriaLabel:ae="Year",monthAriaLabel:ne="Month",dayAriaLabel:$="Day",locale:Y,formatYearOption:H,formatMonthOption:ie,formatDayOption:X}=e;if(Ks(Y),t!==void 0&&Vr("value",t),r!==void 0&&Vr("initialDate",r),c!==void 0&&Vr("minDate",c),f!==void 0&&Vr("maxDate",f),s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(s)})`);if(l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(l)})`);if(M==="split-dropdown"&&g!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const U=t??r;if(U===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");const[A,v]=a.useState(()=>jt(U)),E=t!==void 0,V=t?.getTime(),C=a.useMemo(()=>t!==void 0?jt(t):A,[V,A]),q=c?.getTime(),se=f?.getTime(),W=a.useMemo(()=>{const x=c?jt(c):null,w=s!==void 0?Oa(s):null;return x===null?w:w===null||x.getTime()>=w.getTime()?x:w},[q,s]),G=a.useMemo(()=>{const x=f?jt(f):null,w=l!==void 0?qs(l):null;return x===null?w:w===null||x.getTime()<=w.getTime()?x:w},[se,l]),_=W?.getTime()??null,F=G?.getTime()??null;if(W!==null&&G!==null&&W.getTime()>G.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Ut(W)} is after max ${Ut(G)})`);if(M!=="date"&&g===void 0&&(W===null||G===null))throw new RangeError(`DateSelector: variant="${M}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${M==="dropdown"?' or supply "allowedDates"':""}`);const me=g===void 0?null:g.map(x=>x.getTime()).join(","),ye=a.useMemo(()=>g===void 0?null:zs(g,(x,w)=>Vr(`allowedDates[${x}]`,w)),[me]),le=a.useMemo(()=>ye===null?null:{ascending:ye,...js(ye,W,G)},[ye,_,F]),Pe=a.useMemo(()=>le!==null?_s(le.ascending,le.loIndex,le.hiIndex,Y):W===null||G===null?Fs:Hs(W,G,Y),[le,_,F,Y]),R=x=>{if(le!==null)return Pe.indexOf(x)!==Re;const w=x.getTime();return!(_!==null&&w<_||F!==null&&w>F)},ee=U.getTime();a.useEffect(()=>{E||v(jt(U))},[E,ee]);const he=x=>{if(D)return;const w=jt(x);R(w)&&(E||v(w),n?.(w))},De=C.getTime(),Me=R(C),Oe=a.useMemo(()=>{if(le!==null)return Na(le.ascending,le.loIndex,le.hiIndex,De,-1);const x=$t.addDays(new Date(De),-1);return R(x)?x:null},[le,De,_,F]),We=a.useMemo(()=>{if(le!==null)return Na(le.ascending,le.loIndex,le.hiIndex,De,1);const x=$t.addDays(new Date(De),1);return R(x)?x:null},[le,De,_,F]),Ge=()=>{Oe!==null&&he(Oe)},Z=()=>{We!==null&&he(We)},te=x=>{if(x.target.value){const w=$t.parseISO(x.target.value);Number.isNaN(w.getTime())||he(w)}},re=C.getFullYear(),L=C.getMonth()+1,N=C.getDate(),T=a.useMemo(()=>{if(M!=="split-dropdown"||W===null||G===null)return[];const x=[];for(let w=G.getFullYear();w>=W.getFullYear();w--)x.push(w);return x},[M,_,F]),j=a.useMemo(()=>{if(M!=="split-dropdown"||W===null||G===null)return[];const x=W,w=G,tt=re===x.getFullYear()?x.getMonth()+1:1,wr=re===w.getFullYear()?w.getMonth()+1:12,at=[];for(let z=tt;z<=wr;z++)at.push(z);return at},[M,_,F,re]),be=a.useMemo(()=>{if(M!=="split-dropdown"||W===null||G===null)return[];const x=W,w=G,tt=re===x.getFullYear()&&L===x.getMonth()+1?x.getDate():1,wr=re===w.getFullYear()&&L===w.getMonth()+1?w.getDate():$t.getDaysInMonth(new Date(De)),at=[];for(let z=tt;z<=wr;z++)at.push(z);return at},[M,_,F,De,re,L]),we=(x,w,tt)=>tt>$t.getDaysInMonth(Bt(x,w,1))?!1:R(Bt(x,w,tt)),Ee=(x,w,tt)=>{we(x,w,tt)&&he(Bt(x,w,tt))},$e=x=>H?H(x):go("year",Oa(x),Y),_e=x=>ie?ie(x):go("month",Bt(re,x,1),Y),Dt=x=>X?X(x):go("day",Bt(re,L,x),Y),ft=Ut(C),jr=Ue("day",C,void 0,Y),Se=W?Ut(W):void 0,Le=G?Ut(G):void 0,Gt="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400";return p.jsxs("div",{className:`inline-flex items-center ${Fr} ${b}`,style:u,"data-variant":M,"data-out-of-range":Me?void 0:"true",children:[p.jsx(Wt,{neighbour:"control",direction:"left",disabled:D,canStep:Oe!==null,onStep:Ge,ariaLabel:K}),M==="dropdown"?p.jsx(mi,{domain:Pe,selectedIndex:Me?Pe.indexOf(C):Re,displayLabel:jr,machineValue:ft,disabled:D,ariaLabel:y,onCommitIndex:x=>he(Pe.dateAt(x)),controlClassName:"period-slider-date-combobox-field w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"}):M==="split-dropdown"?p.jsxs("div",{className:"inline-flex items-center gap-1",children:[p.jsxs("select",{"aria-label":ae,disabled:D,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Me?re:"",onChange:x=>Ee(Number(x.target.value),L,N),children:[Me?null:p.jsx("option",{value:"",disabled:!0,className:Gt,children:$e(re)}),T.map(x=>p.jsx("option",{value:x,disabled:!we(x,L,N),className:"dark:bg-slate-700 dark:text-slate-100",children:$e(x)},x))]}),p.jsxs("select",{"aria-label":ne,disabled:D,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Me?L:"",onChange:x=>Ee(re,Number(x.target.value),N),children:[Me?null:p.jsx("option",{value:"",disabled:!0,className:Gt,children:_e(L)}),j.map(x=>p.jsx("option",{value:x,disabled:!we(re,x,N),className:"dark:bg-slate-700 dark:text-slate-100",children:_e(x)},x))]}),p.jsxs("select",{"aria-label":$,disabled:D,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Me?N:"",onChange:x=>Ee(re,L,Number(x.target.value)),children:[Me?null:p.jsx("option",{value:"",disabled:!0,className:Gt,children:Dt(N)}),be.map(x=>p.jsx("option",{value:x,className:"dark:bg-slate-700 dark:text-slate-100",children:Dt(x)},x))]})]}):p.jsx("input",{"aria-label":y,disabled:D,className:"period-slider-native-date-field w-28 rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400",value:ft,min:Se,max:Le,onChange:te,type:"date"}),p.jsx(Wt,{neighbour:"control",direction:"right",disabled:D,canStep:We!==null,onStep:Z,ariaLabel:Q}),o]})},gr=e=>e===void 0?null:jt(e).getTime(),fi=a.memo(tl,(e,t)=>!(gr(e.value??e.initialDate)!==gr(t.value??t.initialDate)||gr(e.minDate)!==gr(t.minDate)||gr(e.maxDate)!==gr(t.maxDate)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.onChange!==t.onChange||e.allowedDates!==t.allowedDates||e.children!==t.children||e.prevDateAriaLabel!==t.prevDateAriaLabel||e.nextDateAriaLabel!==t.nextDateAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.yearAriaLabel!==t.yearAriaLabel||e.monthAriaLabel!==t.monthAriaLabel||e.dayAriaLabel!==t.dayAriaLabel||e.locale!==t.locale||e.formatYearOption!==t.formatYearOption||e.formatMonthOption!==t.formatMonthOption||e.formatDayOption!==t.formatDayOption));fi.displayName="DateSelector";function Qe(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(r,n,1);return o.setFullYear(r),o}function zt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function Or(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function Ha(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function rl(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function nl(e,t){const r=e===void 0?null:Qe(e,0),n=t===void 0?null:Qe(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function ol(e,t){const r=e===void 0?null:Qe(e,11),n=t===void 0?null:Qe(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function al(e,t,r){const n=new Map;for(const o of e){const s=Qe(o.getFullYear(),o.getMonth());t!==null&&s<t||r!==null&&s>r||n.has(s.getTime())||n.set(s.getTime(),s)}return Array.from(n.values()).sort((o,s)=>o.getTime()-s.getTime())}function il(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),o=[];for(let s=r;s<=n;s++)o.push(Qe(Math.floor(s/12),s%12));return o}function _a(e,t){const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Ue("month",e[n],void 0,t),value:zt(e[n])});return r}const sl=e=>{const{value:t,initialDate:r,onChange:n,children:o,variant:s="date",minYear:l,maxYear:c,minDate:f,maxDate:g,allowedMonths:M,isWarning:b=!1,className:u="",style:D,disabled:K=!1,prevMonthAriaLabel:Q="Previous month",nextMonthAriaLabel:y="Next month",selectAriaLabel:ae="Month",locale:ne}=e;rl(ne),Or(t,"value"),Or(r,"initialDate"),Or(f,"minDate"),Or(g,"maxDate"),Ha(l,"minYear"),Ha(c,"maxYear"),M?.forEach((T,j)=>{Or(T,`allowedMonths[${j}]`)});const $=t??r;if($===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const[Y,H]=a.useState(()=>Qe($.getFullYear(),$.getMonth())),ie=t!==void 0,X=a.useMemo(()=>t!==void 0?Qe(t.getFullYear(),t.getMonth()):Y,[t?.getTime(),Y]),U=f?.getTime(),A=g?.getTime(),v=a.useMemo(()=>nl(l,f),[l,U]),E=a.useMemo(()=>ol(c,g),[c,A]),V=v?.getTime()??null,C=E?.getTime()??null;if(v!==null&&E!==null&&v>E)throw new RangeError(`MonthSelector: the resolved lower bound ${zt(v)} is after the resolved upper bound ${zt(E)}.`);if(s==="dropdown"&&M===void 0&&(v===null||E===null))throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedMonths`; the option window is never invented.');const q=M===void 0?null:M.map(T=>T.getTime()).join(","),se=a.useMemo(()=>M===void 0?null:al(M,v,E),[q,V,C]),W=T=>{const j=T.getTime();return se!==null?se.some(be=>be.getTime()===j):!(V!==null&&j<V||C!==null&&j>C)},G=$.getTime();a.useEffect(()=>{if(ie)return;const T=Qe($.getFullYear(),$.getMonth());H(j=>j.getTime()===T.getTime()?j:T)},[ie,G]);const _=T=>{if(K)return;if(!W(T))throw new RangeError(`MonthSelector: refusing to emit ${zt(T)}, which lies outside the selectable months.`);ie||H(T);const j=T.getFullYear()*100+(T.getMonth()+1);n?.(T,j)},F=X.getTime(),me=W(X),ye=a.useMemo(()=>{if(se!==null){for(let j=se.length-1;j>=0;j--)if(se[j].getTime()<F)return se[j];return null}const T=Qe(X.getFullYear(),X.getMonth()-1);return W(T)?T:null},[se,F,V,C]),le=a.useMemo(()=>{if(se!==null){for(const j of se)if(j.getTime()>F)return j;return null}const T=Qe(X.getFullYear(),X.getMonth()+1);return W(T)?T:null},[se,F,V,C]),Pe=()=>{ye!==null&&_(ye)},R=()=>{le!==null&&_(le)},ee=T=>{if(!T)return;const[j,be]=T.split("-"),we=Number(j),Ee=Number(be)-1;if(!(Number.isInteger(we)&&Number.isInteger(Ee)))return;const $e=Qe(we,Ee);W($e)&&_($e)},he=T=>{ee(T.target.value)},De=T=>{ee(T.target.value)},Me=zt(X),Oe=Ue("month",X,void 0,ne),We=v?zt(v):void 0,Ge=E?zt(E):void 0,Z=a.useMemo(()=>s!=="dropdown"?[]:se!==null?_a(se,ne):v===null||E===null?[]:_a(il(v,E),ne),[s,se,V,C,ne]),te=me?Me:"",re=b?"border-amber-300 bg-amber-50 text-amber-900 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200":"border-gray-300 bg-gray-100 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",L=`period-slider-native-date-field w-28 rounded-md border py-0.5 px-1 text-center font-mono text-xs tabular-nums dark:placeholder:text-gray-400 disabled:opacity-50 ${re}`,N=`w-28 appearance-none rounded-md border px-1 py-0.5 text-center font-mono text-xs tabular-nums [text-align-last:center] [text-align:center] disabled:opacity-50 ${re}`;return p.jsxs("div",{className:`inline-flex items-center ${Fr} ${u}`,style:D,"data-out-of-range":me?void 0:"true",children:[p.jsx(Wt,{neighbour:"control",direction:"left",disabled:K,canStep:ye!==null,onStep:Pe,ariaLabel:Q}),s==="dropdown"?p.jsxs("select",{"aria-label":ae,disabled:K,className:N,value:te,onChange:De,children:[me?null:p.jsx("option",{value:"",disabled:!0,className:"text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",children:Oe}),Z.map(T=>p.jsx("option",{value:T.value,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]}):p.jsx("input",{"aria-label":ae,disabled:K,className:L,value:Me,min:We,max:Ge,onChange:he,type:"month"}),p.jsx(Wt,{neighbour:"control",direction:"right",disabled:K,canStep:le!==null,onStep:R,ariaLabel:y}),o]})},gi=a.memo(sl,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,s=n?n.getFullYear()*12+n.getMonth():null;if(o!==s||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear)return!1;const l=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,c=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(l!==c)return!1;const f=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,g=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(f!==g||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.children!==t.children||e.prevMonthAriaLabel!==t.prevMonthAriaLabel||e.nextMonthAriaLabel!==t.nextMonthAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});gi.displayName="MonthSelector";function br(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`)}function Tn(e,t,r){if(br(e,"minDate",t),br(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`)}function Mn(e,t,r){if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${String(r)})`);if(br(e,`${t}[0]`,r[0]),br(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`)}function Dn(e,t,r,n,o,s,l){const c=J(r,n);if(c<J(r,o)||c>J(r,s))throw new RangeError(`${e}: ${t} must lie within ${l} (value: ${n.toISOString()}, lower: ${o.toISOString()}, upper: ${s.toISOString()})`)}function vn(e,t,r,n,o,s,l){Dn(e,`${t}[0]`,r,n[0],o,s,l),Dn(e,`${t}[1]`,r,n[1],o,s,l)}function Be(e,t,r){return e<t?t:e>r?r:e}function xn(e,t,r,n,o,s){if(r!==!0)return[];const l=e[0].getTime(),c=e[1].getTime();return Mt(n,t,o,s).filter(f=>f.getTime()>=l&&f.getTime()<=c)}function hr(e,t,r,n){if(n.length===0)return Be(e,r[0],r[1]);const o=n[fe(n,e,t)];return o.getTime()===e.getTime()?e:o}function mn(e,t,r,n){const o=hr(e[0],t,r,n),s=hr(e[1],t,r,n);return[o,s<o?o:s]}function Rn(e,t,r,n){const o=fe(e,r,t)+n;return e[Math.max(0,Math.min(e.length-1,o))]}function yn(e){const t=a.useRef(e),r=t.current,n=e,o=Object.keys(r),s=Object.keys(n);return o.length===s.length&&s.every(c=>Object.is(r[c],n[c]))||(t.current=e),t.current}function ll(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:s,...l}=e;Tn("usePeriodSliderRange",r,n),Mn("usePeriodSliderRange","initialRange",o),vn("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]");const c=yn(l),f=a.useRef(o),[g,M]=a.useState(o);let b=g;const u=[Be(g[0],r,n),Be(g[1],r,n)];(u[0]!==g[0]||u[1]!==g[1])&&(b=u,M(u));const D=a.useRef(b);D.current=b;const K=a.useRef({minDate:r,maxDate:n,allowedDates:c.allowedDates});K.current={minDate:r,maxDate:n,allowedDates:c.allowedDates};const Q=a.useRef(s);Q.current=s;const y=a.useCallback(A=>{const{minDate:v,maxDate:E}=K.current,V=Be(A[0],v,E),C=Be(A[1],v,E),q=D.current;V.getTime()===q[0].getTime()&&C.getTime()===q[1].getTime()||(D.current=[V,C],M([V,C]),Q.current?.(V,C))},[]),ae=a.useCallback(A=>{const v=D.current,E=A.getTime()>v[1].getTime()?A:v[1];y([A,E])},[y]),ne=a.useCallback(A=>{const v=D.current,E=A.getTime()<v[0].getTime()?A:v[0];y([E,A])},[y]),$=a.useCallback((A,v)=>{y([A,v])},[y]),Y=a.useCallback(A=>{const{minDate:v,maxDate:E,allowedDates:V}=K.current,C=D.current,q=Mt(V,t,v,E);if(q.length>0){y([Rn(q,t,C[0],A),Rn(q,t,C[1],A)]);return}y([Ve(t,C[0],A),Ve(t,C[1],A)])},[t,y]),H=a.useCallback(()=>{y(f.current)},[y]),ie=a.useMemo(()=>({value:b[0],onChange:ae,minDate:r,maxDate:b[1],unit:t}),[b[0],b[1],ae,r,t]),X=a.useMemo(()=>({value:b[1],onChange:ne,minDate:b[0],maxDate:n,unit:t}),[b[0],b[1],ne,n,t]),U=a.useMemo(()=>({...c,mode:"range",unit:t,range:b,minDate:r,maxDate:n,onChangeRange:$}),[c,t,b,r,n,$]);return{range:b,lowerDate:b[0],upperDate:b[1],setRange:M,setLowerDate:ae,setUpperDate:ne,shiftRange:Y,resetRange:H,startSelectorProps:ie,endSelectorProps:X,sliderProps:U}}function cl(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:s,...l}=e;Tn("usePeriodSliderPoint",r,n),br("usePeriodSliderPoint","initialValue",o),Dn("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]");const c=yn(l),f=a.useRef(o),[g,M]=a.useState(o);let b=g;const u=Be(g,r,n);u!==g&&(b=u,M(u));const D=a.useRef(b);D.current=b;const K=a.useRef({minDate:r,maxDate:n,allowedDates:c.allowedDates});K.current={minDate:r,maxDate:n,allowedDates:c.allowedDates};const Q=a.useRef(s);Q.current=s;const y=a.useCallback(H=>{const{minDate:ie,maxDate:X}=K.current,U=Be(H,ie,X);U.getTime()!==D.current.getTime()&&(D.current=U,M(U),Q.current?.(U))},[]),ae=a.useCallback(H=>{const{minDate:ie,maxDate:X,allowedDates:U}=K.current,A=Mt(U,t,ie,X);if(A.length>0){y(Rn(A,t,D.current,H));return}y(Ve(t,D.current,H))},[t,y]),ne=a.useCallback(()=>{y(f.current)},[y]),$=a.useMemo(()=>({value:b,onChange:y,minDate:r,maxDate:n,unit:t}),[b,y,r,n,t]),Y=a.useMemo(()=>({...c,mode:"point",unit:t,value:b,minDate:r,maxDate:n,onChangePoint:y}),[c,t,b,r,n,y]);return{value:b,setValue:M,shiftValue:ae,resetValue:ne,selectorProps:$,sliderProps:Y}}function ul(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:s,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroRange:g,...M}=e;Tn("useVernierSliderRange",r,n),Mn("useVernierSliderRange","initialMacroRange",o),Mn("useVernierSliderRange","initialMicroRange",s),vn("useVernierSliderRange","initialMacroRange",l,o,r,n,"[minDate, maxDate]");const b=mt(l,c,o,r,n);vn("useVernierSliderRange","initialMicroRange",c,s,b[0],b[1],"the initial macro window");const u=yn(M),D=a.useRef(o),K=a.useRef(s),[Q,y]=a.useState(o),[ae,ne]=a.useState(s);let $=Q;const Y=[Be(Q[0],r,n),Be(Q[1],r,n)];(Y[0]!==Q[0]||Y[1]!==Q[1])&&($=Y,y(Y));const H=a.useMemo(()=>mt(l,c,$,r,n),[l,c,$,r,n]),ie=a.useMemo(()=>xn(H,c,u.microIsDiscrete,u.microAllowedDates??u.allowedDates,r,n),[H,c,u.microIsDiscrete,u.microAllowedDates,u.allowedDates,r,n]),X=a.useMemo(()=>u.macroIsDiscrete===!0?Mt(u.macroAllowedDates??u.allowedDates,l,r,n):[],[u.macroIsDiscrete,u.macroAllowedDates,u.allowedDates,l,r,n]),U=a.useRef(X);U.current=X;let A=ae;const v=mn(ae,c,H,ie);(v[0]!==ae[0]||v[1]!==ae[1])&&(A=v,ne(v));const E=a.useRef($);E.current=$;const V=a.useRef(A);V.current=A;const C=a.useRef({minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates});C.current={minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates};const q=a.useRef(f);q.current=f;const se=a.useRef(g);se.current=g;const W=a.useCallback(L=>{const{minDate:N,maxDate:T}=C.current;return mt(l,c,L,N,T)},[l,c]),G=a.useCallback(L=>{const{microIsDiscrete:N,microAllowedDates:T,allowedDates:j,minDate:be,maxDate:we}=C.current;return xn(L,c,N,T??j,be,we)},[c]),_=a.useCallback((L,N)=>{const T=E.current,j=V.current;(L[0].getTime()!==T[0].getTime()||L[1].getTime()!==T[1].getTime())&&(E.current=L,y(L),q.current?.(L[0],L[1])),(N[0].getTime()!==j[0].getTime()||N[1].getTime()!==j[1].getTime())&&(V.current=N,ne(N),se.current?.(N[0],N[1]))},[]),F=a.useCallback((L,N)=>{const{minDate:T,maxDate:j}=C.current,be=[Be(L,T,j),Be(N,T,j)],we=W(be);_(be,mn(V.current,c,we,G(we)))},[c,W,G,_]),me=a.useCallback((L,N)=>{const T=W(E.current);_(E.current,mn([L,N],c,T,G(T)))},[c,W,G,_]),ye=a.useCallback(L=>{const N=E.current[1],T=L>N?L:N;F(L,T)},[F]),le=a.useCallback(L=>{const N=E.current[0],T=L<N?L:N;F(T,L)},[F]),Pe=a.useCallback(L=>{const N=V.current[1],T=L>N?L:N;me(L,T)},[me]),R=a.useCallback(L=>{const N=V.current[0],T=L<N?L:N;me(T,L)},[me]),ee=a.useCallback(L=>{const{minDate:N,maxDate:T}=C.current,j=E.current,be=U.current;if(be.length>0){const $e=fe(be,j[0],l)+L,_e=fe(be,j[1],l)+L;if($e<0||_e>be.length-1)return;F(be[$e],be[_e]);return}const we=Ve(l,j[0],L),Ee=Ve(l,j[1],L);we<N||Ee>T||F(we,Ee)},[l,F]),he=a.useCallback(L=>{const N=E.current,T=V.current,j=W(N),[be,we]=j,Ee=G(j);if(Ee.length>0){const Dt=fe(Ee,T[0],c)+L,ft=fe(Ee,T[1],c)+L;if(Dt<0||ft>Ee.length-1)return;me(Ee[Dt],Ee[ft]);return}const $e=Ve(c,T[0],L),_e=Ve(c,T[1],L);$e<be||_e>we||me($e,_e)},[c,W,G,me]),De=a.useCallback(()=>{const L=D.current,N=W(L);_(L,mn(K.current,c,N,G(N)))},[c,W,G,_]),[Me,Oe]=H,We=a.useMemo(()=>({value:$[0],onChange:ye,minDate:r,maxDate:$[1],unit:l}),[$,ye,r,l]),Ge=a.useMemo(()=>({value:$[1],onChange:le,minDate:$[0],maxDate:n,unit:l}),[$,le,n,l]),Z=a.useMemo(()=>({value:A[0],onChange:Pe,minDate:Me,maxDate:A[1],unit:c}),[A,Pe,Me,c]),te=a.useMemo(()=>({value:A[1],onChange:R,minDate:A[0],maxDate:Oe,unit:c}),[A,R,Oe,c]),re=a.useMemo(()=>({...u,mode:"vernier",unit:t,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:$,microRange:A,onChangeMacroRange:F,onChangeMicroRange:me}),[u,t,l,c,r,n,$,A,F,me]);return{macroRange:$,setMacroRange:y,microRange:A,setMicroRange:ne,setMacroLowerDate:ye,setMacroUpperDate:le,setMicroLowerDate:Pe,setMicroUpperDate:R,shiftMacroRange:ee,shiftMicroRange:he,resetVernier:De,macroStartSelectorProps:We,macroEndSelectorProps:Ge,microStartSelectorProps:Z,microEndSelectorProps:te,sliderProps:re}}function dl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:s,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroPoint:g,...M}=e;Tn("useVernierSliderPoint",r,n),Mn("useVernierSliderPoint","initialMacroRange",o),br("useVernierSliderPoint","initialMicroValue",s),vn("useVernierSliderPoint","initialMacroRange",l,o,r,n,"[minDate, maxDate]");const b=mt(l,c,o,r,n);Dn("useVernierSliderPoint","initialMicroValue",c,s,b[0],b[1],"the initial macro window");const u=yn(M),D=a.useRef(o),K=a.useRef(s),[Q,y]=a.useState(o),[ae,ne]=a.useState(s);let $=Q;const Y=[Be(Q[0],r,n),Be(Q[1],r,n)];(Y[0]!==Q[0]||Y[1]!==Q[1])&&($=Y,y(Y));const H=a.useMemo(()=>mt(l,c,$,r,n),[l,c,$,r,n]),ie=a.useMemo(()=>xn(H,c,u.microIsDiscrete,u.microAllowedDates??u.allowedDates,r,n),[H,c,u.microIsDiscrete,u.microAllowedDates,u.allowedDates,r,n]),X=a.useMemo(()=>u.macroIsDiscrete===!0?Mt(u.macroAllowedDates??u.allowedDates,l,r,n):[],[u.macroIsDiscrete,u.macroAllowedDates,u.allowedDates,l,r,n]),U=a.useRef(X);U.current=X;let A=ae;const v=hr(ae,c,H,ie);v!==ae&&(A=v,ne(v));const E=a.useRef($);E.current=$;const V=a.useRef(A);V.current=A;const C=a.useRef({minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates});C.current={minDate:r,maxDate:n,macroIsDiscrete:u.macroIsDiscrete,macroAllowedDates:u.macroAllowedDates,microIsDiscrete:u.microIsDiscrete,microAllowedDates:u.microAllowedDates,allowedDates:u.allowedDates};const q=a.useRef(f);q.current=f;const se=a.useRef(g);se.current=g;const W=a.useCallback(Z=>{const{minDate:te,maxDate:re}=C.current;return mt(l,c,Z,te,re)},[l,c]),G=a.useCallback(Z=>{const{microIsDiscrete:te,microAllowedDates:re,allowedDates:L,minDate:N,maxDate:T}=C.current;return xn(Z,c,te,re??L,N,T)},[c]),_=a.useCallback((Z,te)=>{const re=E.current,L=V.current;(Z[0].getTime()!==re[0].getTime()||Z[1].getTime()!==re[1].getTime())&&(E.current=Z,y(Z),q.current?.(Z[0],Z[1])),te.getTime()!==L.getTime()&&(V.current=te,ne(te),se.current?.(te))},[]),F=a.useCallback((Z,te)=>{const{minDate:re,maxDate:L}=C.current,N=[Be(Z,re,L),Be(te,re,L)],T=W(N);_(N,hr(V.current,c,T,G(T)))},[c,W,G,_]),me=a.useCallback(Z=>{const te=W(E.current);_(E.current,hr(Z,c,te,G(te)))},[c,W,G,_]),ye=a.useCallback(Z=>{const te=E.current[1],re=Z>te?Z:te;F(Z,re)},[F]),le=a.useCallback(Z=>{const te=E.current[0],re=Z<te?Z:te;F(re,Z)},[F]),Pe=a.useCallback(Z=>{const{minDate:te,maxDate:re}=C.current,L=E.current,N=U.current;if(N.length>0){const be=fe(N,L[0],l)+Z,we=fe(N,L[1],l)+Z;if(be<0||we>N.length-1)return;F(N[be],N[we]);return}const T=Ve(l,L[0],Z),j=Ve(l,L[1],Z);T<te||j>re||F(T,j)},[l,F]),R=a.useCallback(Z=>{const te=E.current,re=W(te),L=G(re);if(L.length>0){me(Rn(L,c,V.current,Z));return}me(Ve(c,V.current,Z))},[c,W,G,me]),ee=a.useCallback(()=>{const Z=D.current,te=W(Z);_(Z,hr(K.current,c,te,G(te)))},[c,W,G,_]),[he,De]=H,Me=a.useMemo(()=>({value:$[0],onChange:ye,minDate:r,maxDate:$[1],unit:l}),[$,ye,r,l]),Oe=a.useMemo(()=>({value:$[1],onChange:le,minDate:$[0],maxDate:n,unit:l}),[$,le,n,l]),We=a.useMemo(()=>({value:A,onChange:me,minDate:he,maxDate:De,unit:c}),[A,me,he,De,c]),Ge=a.useMemo(()=>({...u,mode:"vernier",unit:t,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:$,microValue:A,onChangeMacroRange:F,onChangeMicroPoint:me}),[u,t,l,c,r,n,$,A,F,me]);return{macroRange:$,setMacroRange:y,microValue:A,setMicroValue:ne,setMacroLowerDate:ye,setMacroUpperDate:le,setMicroDate:me,shiftMacroRange:Pe,shiftMicroValue:R,resetVernier:ee,macroStartSelectorProps:Me,macroEndSelectorProps:Oe,microSelectorProps:We,sliderProps:Ge}}function Fa(e){const t=new Date(e,0,1);return t.setFullYear(e),t}function fn(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function ja(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function ml(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function za(e,t,r){const n=e===void 0?null:e,o=t===void 0?null:t.getFullYear();return n!==null&&o!==null?r(n,o):n!==null?n:o}const fl=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:s,maxYear:l,minDate:c,maxDate:f,className:g="",style:M,disabled:b=!1,prevYearAriaLabel:u="Previous year",nextYearAriaLabel:D="Next year",selectAriaLabel:K="Year",locale:Q}=e;fn(t,"value"),fn(r,"initialDate"),fn(c,"minDate"),fn(f,"maxDate"),ja(s,"minYear"),ja(l,"maxYear"),ml(Q);const y=t??r;if(y===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const[ae,ne]=a.useState(()=>y.getFullYear()),$=c?.getTime(),Y=f?.getTime(),H=a.useMemo(()=>za(s,c,Math.max),[s,$]),ie=a.useMemo(()=>za(l,f,Math.min),[l,Y]);if(H===null||ie===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`) are both required; the year option list is never invented.");if(H>ie)throw new RangeError(`YearSelector: the resolved lower bound ${H} is after the resolved upper bound ${ie}.`);const X=t!==void 0,U=t!==void 0?t.getFullYear():ae,A=U<H||U>ie,v=y.getTime();a.useEffect(()=>{X||ne(y.getFullYear())},[X,v]);const E=_=>_>=H&&_<=ie,V=_=>{if(!b){if(!E(_))throw new RangeError(`YearSelector: refusing to emit ${_}, which lies outside the declared bounds ${H}-${ie}.`);X||ne(_),n?.(Fa(_),_)}},C=E(U-1)?U-1:null,q=E(U+1)?U+1:null,se=()=>{C!==null&&V(C)},W=()=>{q!==null&&V(q)},G=a.useMemo(()=>{const _=[];for(let F=ie;F>=H;F--)_.push(F);return A&&(_.push(U),_.sort((F,me)=>me-F)),_},[H,ie,A,U]);return p.jsxs("div",{className:`inline-flex items-center ${Fr} ${g}`,style:M,children:[p.jsx(Wt,{neighbour:"control",direction:"left",disabled:b,canStep:C!==null,onStep:se,ariaLabel:u}),p.jsx("select",{"aria-label":K,disabled:b,className:"w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",value:U,onChange:_=>{if(!_.target.value)return;const F=Number(_.target.value);Number.isInteger(F)&&V(F)},children:G.map(_=>p.jsx("option",{value:_,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:Ue("year",Fa(_),void 0,Q)},_))}),p.jsx(Wt,{neighbour:"control",direction:"right",disabled:b,canStep:q!==null,onStep:W,ariaLabel:D}),o]})},hi=a.memo(fl,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear():null,s=n?n.getFullYear():null;return!(o!==s||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.minDate?.getFullYear()!==t.minDate?.getFullYear()||e.maxDate?.getFullYear()!==t.maxDate?.getFullYear()||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});hi.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Ga;exports.DateSelector=fi;exports.MonthSelector=gi;exports.PeriodSlider=li;exports.YearSelector=hi;exports.addUnit=Ve;exports.areStylesEqual=si;exports.calculateConnectDragValues=qa;exports.calculateHandleDragValues=ho;exports.calculateKeyboardActionValues=Za;exports.calculateLabelSlant=vo;exports.calculateVernierMacroDrag=ai;exports.calculateVernierMicroDrag=ii;exports.decode=ce;exports.encode=J;exports.findNearestDateIndex=fe;exports.formatLabel=Ue;exports.formatScreenReaderLabel=Ft;exports.getMacroWindowEndDate=Ka;exports.getMacroWindowStartDate=Xa;exports.getSortedAllowedDates=Mt;exports.normalizeDateByUnit=qe;exports.resolveDraggedEdge=Ln;exports.resolveMacroWindow=mt;exports.resolveVernierRailZone=xo;exports.resolveVernierTargetHandle=oi;exports.resolveWheelStep=ni;exports.usePeriodSliderPoint=cl;exports.usePeriodSliderRange=ll;exports.useVernierSliderPoint=dl;exports.useVernierSliderRange=ul;
|
package/dist/index.js
CHANGED
|
@@ -1950,7 +1950,11 @@ const si = 864e5, Xl = 4, Kl = 6, Fa = 2, ye = -1, xn = (e) => {
|
|
|
1950
1950
|
// 未指定だと矢印ボタンが tabIndex=0 のままポップアップのタブ順へ露出する
|
|
1951
1951
|
enableArrowButtons: !1,
|
|
1952
1952
|
enableThumbDrag: !0,
|
|
1953
|
-
enableTrackClick: !0
|
|
1953
|
+
enableTrackClick: !0,
|
|
1954
|
+
// 必ず false。スクローラの既定は有効で、直径 40px の円がポップアップの上へ重なる。
|
|
1955
|
+
// 大きなスクロール面を親指で送るための部品であり、操作要素の幅に合わせた
|
|
1956
|
+
// 1 列のリストでは行を覆うだけで、ネイティブのポップアップにも無い
|
|
1957
|
+
tapScrollCircleOptions: { enabled: !1 }
|
|
1954
1958
|
},
|
|
1955
1959
|
behaviorOptions: {
|
|
1956
1960
|
// 必ず false。true だと各行ラッパーに tabIndex=-1 が付いてポップアップが
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/period-slider",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Customizable period slider and year/month/date selectors for React",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -32,14 +32,15 @@
|
|
|
32
32
|
"LICENSE"
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
|
+
"@aiquants/virtualscroll": "^3.6.1",
|
|
35
36
|
"react": "^19.2.7",
|
|
36
|
-
"react-dom": "^19.2.7"
|
|
37
|
-
"@aiquants/virtualscroll": "^3.5.0"
|
|
37
|
+
"react-dom": "^19.2.7"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"date-fns": "^4.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@aiquants/virtualscroll": "^3.6.1",
|
|
43
44
|
"@playwright/test": "^1.59.1",
|
|
44
45
|
"@tailwindcss/cli": "^4.1.18",
|
|
45
46
|
"@tailwindcss/vite": "^4.1.18",
|
|
@@ -56,8 +57,7 @@
|
|
|
56
57
|
"typescript": "^5.9.3",
|
|
57
58
|
"vite": "^7.3.0",
|
|
58
59
|
"vite-plugin-dts": "^4.5.4",
|
|
59
|
-
"vitest": "^3.2.4"
|
|
60
|
-
"@aiquants/virtualscroll": "^3.5.0"
|
|
60
|
+
"vitest": "^3.2.4"
|
|
61
61
|
},
|
|
62
62
|
"keywords": [
|
|
63
63
|
"react",
|
|
@@ -487,6 +487,10 @@ export const VirtualDateDropdown: React.FC<VirtualDateDropdownProps> = ({ domain
|
|
|
487
487
|
enableArrowButtons: false,
|
|
488
488
|
enableThumbDrag: true,
|
|
489
489
|
enableTrackClick: true,
|
|
490
|
+
// 必ず false。スクローラの既定は有効で、直径 40px の円がポップアップの上へ重なる。
|
|
491
|
+
// 大きなスクロール面を親指で送るための部品であり、操作要素の幅に合わせた
|
|
492
|
+
// 1 列のリストでは行を覆うだけで、ネイティブのポップアップにも無い
|
|
493
|
+
tapScrollCircleOptions: { enabled: false },
|
|
490
494
|
}}
|
|
491
495
|
behaviorOptions={{
|
|
492
496
|
// 必ず false。true だと各行ラッパーに tabIndex=-1 が付いてポップアップが
|