@aiquants/period-slider 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),at=require("date-fns"),i=require("react"),ls=require("@aiquants/virtualscroll"),cs=require("react-dom"),La=120,oo="data-drag-snap",ao="--ps-drag-snap-duration",zr={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"]},Ka=["low","high"],qa=["tx","ty","rot"],Pn={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"}},Ro=(e,t)=>`${e}-${t}`,io=(e,t,r)=>`var(${Ro(e,t)}, ${r})`,us=(e,t,r)=>{const n=Pn[t];for(const o of Ka)for(const a of qa)e.style.setProperty(Ro(n[o],a),r[o][a])},Za=e=>Math.max(0,Math.min(1,e)),vn=(e,t,r,n)=>{const o=Za(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},So=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},An=(e,t,r,n)=>{const o=Za(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},so=(e,t,r,n)=>{if(r){const s=(1-e)*100,c=(1-t)*100;return n?`M 12 ${c} L 12 ${s} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${s} L 20 ${c} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},$t=(e,t)=>`var(${e}, ${t}%)`,ds=(e,t,r,n)=>{const[o,a]=zr[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},ms=e=>{for(const[t,r]of Object.values(zr))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Pn))for(const r of Ka)for(const n of qa)e.style.removeProperty(Ro(t[r],n))},lo=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Ta=new Set(["hidden","clip","scroll","auto","overlay"]),ya=["paint","strict","content"],fs=["layout","paint","strict","content"],gs=["transform","perspective","filter"],Or=e=>e!==void 0&&e!==""&&e!=="none",hs=e=>e!==void 0&&e!==""&&e!=="normal",un=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},bs=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,ws=(e,t)=>t==="absolute"&&Or(e.position)&&e.position!=="static"||Or(e.transform)||Or(e.perspective)||Or(e.filter)||Or(e.backdropFilter)||hs(e.containerType)||fs.some(r=>e.contain.includes(r))?!0:gs.some(r=>e.willChange.includes(r)),ps=(e,t,r,n,o,a)=>{const s=t.ownerDocument.defaultView;if(s===null)return!1;const c=e.getBoundingClientRect();if(c.width===0||c.height===0)return!1;const d=n?0:r,h=n?r:0;if(o<c.left-d||o>=c.right+d||a<c.top-h||a>=c.bottom+h)return!1;const D=s.getComputedStyle(t);if(D.visibility!=="visible")return!1;let S=null;for(let u=t;u!==null;u=u.parentElement){const M=u===t?D:s.getComputedStyle(u);if(S!==null&&!ws(M,S))continue;const R=Ta.has(M.overflowX)||ya.some(F=>M.contain.includes(F)),G=Ta.has(M.overflowY)||ya.some(F=>M.contain.includes(F));if(R||G){const F=u.getBoundingClientRect();if(R&&(o<F.left+un(M.borderLeftWidth)||o>=F.right-un(M.borderRightWidth))||G&&(a<F.top+un(M.borderTopWidth)||a>=F.bottom-un(M.borderBottomWidth)))return!1}S=bs(M)}return!0},co=new Map,Ds=(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 a=o.distanceToRailPx(t.clientX,t.clientY);a===null||a>=n||(r=o,n=a)}r?.step(t)},Ms=(e,t)=>{let r=co.get(e);if(r===void 0){const a=new Set,s=c=>Ds(a,c);r={participants:a,listener:s},co.set(e,r),e.addEventListener("wheel",s,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(co.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Br="gap-[11px]",ft=6,gt=ft*2,It=ft*4/3,vs={left:`0,${gt/2} ${ft},0 ${ft},${gt}`,right:`${It},${gt/2} ${It-ft},0 ${It-ft},${gt}`,up:`${gt/2},0 0,${ft} ${gt},${ft}`,down:`${gt/2},${It} 0,${It-ft} ${gt},${It-ft}`},uo=e=>{e.preventDefault(),e.stopPropagation()},xs={onMouseDownCapture:uo,onMouseUpCapture:uo,onClickCapture:uo},Rs="period-slider-step",Ss=`${Rs} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Ls="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]",Ts={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"},dn="after:inset-[calc((100%-var(--ps-target-size))/2)]",Pa={horizontal:"px-[19px]",vertical:"py-[19px]"},ys={control:{left:dn,right:dn,up:dn,down:dn},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)]"}},qt=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:s,ref:c})=>{const d=e==="up"||e==="down",h=d?gt:It,D=d?It:gt,S=r||!n;return x.jsx("button",{ref:c,type:"button","aria-label":a,disabled:r,"aria-disabled":S?!0:void 0,...S?xs:null,onClick:S?void 0:o,className:`${s===void 0?"":`${s} `}${Ss} ${Ls} ${Ts[t]} ${ys[t][e]}`,children:x.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:h,height:D,viewBox:`0 0 ${h} ${D}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:x.jsx("polygon",{points:vs[e]})})})},Qa={"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"}},qe=e=>e instanceof Date&&!Number.isNaN(e.getTime()),pe=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),it=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t)||t<0||t>11)throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${pe(t)})`)},Mr=(e,t)=>t===void 0?0:(it(e,t),t),ke=(e,t,r=0)=>{if(!qe(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${pe(t)})`);it("normalizeDateByUnit",r);const n=new Date(t.getTime());if(e==="year"){const o=t.getFullYear()-(t.getMonth()<r?1:0);n.setFullYear(o,r,1),n.setHours(0,0,0,0)}else e==="month"&&n.setDate(1),n.setHours(0,0,0,0);return n},ne=(e,t,r=0)=>{it("encode",r);const n=ke(e,t,r),o=n.getFullYear(),a=n.getMonth()+1,s=n.getDate();if(e==="year")return o;if(e==="month")return o*12+(a-1);const c=new Date(0);return c.setUTCFullYear(o,a-1,s),c.setUTCHours(0,0,0,0),Math.floor(c.getTime()/(1440*60*1e3))},ue=(e,t,r=0)=>{it("decode",r);const n=new Date(0);if(n.setHours(0,0,0,0),e==="year")return n.setFullYear(t,r,1),n;if(e==="month"){const a=Math.floor(t/12),s=t-a*12;return n.setFullYear(a,s,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},Oe=(e,t,r)=>{if(!qe(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${pe(t)})`);return e==="year"?at.addYears(t,r):e==="month"?at.addMonths(t,r):at.addDays(t,r)},Ja=(e,t,r,n=0)=>{if(!qe(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${pe(r)})`);return it("getMacroWindowStartDate",n),ke(t,ke(e,r,n),n)},ei=(e,t,r,n=0)=>{if(!qe(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${pe(r)})`);if(it("getMacroWindowEndDate",n),e===t)return ke(t,r,n);const o=r.getFullYear(),a=r.getMonth();if(e==="year"){const s=ke("year",r,n),c=at.addMonths(s,11);if(t==="month")return c;if(t==="day")return ke("day",at.addDays(at.addMonths(s,12),-1))}return e==="month"&&t==="day"?new Date(o,a+1,0):ke(t,r,n)},Aa=(e,t,r)=>e<t?t:e>r?r:e,ht=(e,t,r,n,o,a=0)=>{if(it("resolveMacroWindow",a),Ur("macroRange",r,"resolveMacroWindow"),!qe(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${pe(n)})`);if(!qe(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[ke(t,Aa(Ja(e,t,r[0],a),n,o),a),ke(t,Aa(ei(e,t,r[1],a),n,o),a)]},ti=(e,t)=>{if(!qe(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${pe(e)})`);it("resolveQuarter",t);const r=ke("year",e,t).getFullYear(),n=((e.getMonth()-t)%12+12)%12,o=Math.floor(n/3)+1,a=new Date(e.getTime());return a.setFullYear(r,t+3*(o-1),1),a.setHours(0,0,0,0),{year:r,quarter:o,startDate:a}},Ps={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Ea=new Map,As=(e,t)=>{const r=`${e}\0${t}`,n=Ea.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Ps[e]);return Ea.set(r,o),o},Es=(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}`},Fe=(e,t,r,n)=>qe(t)?r?r(t):n===void 0?Es(e,t):As(e,n).format(t):"",Ut=(e,t,r,n)=>Fe(e,t,r,n),Cs=(e,t)=>{if(!qe(e))return"";it("formatQuarterLabel",t);const{quarter:r}=ti(e,t);return`${Fe("year",ke("year",e,t))}-Q${r}`},be=(e,t,r,n=0)=>{if(it("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;const o=ne(r,t,n);let a=0,s=e.length-1;if(o<=ne(r,e[a],n))return 0;if(o>=ne(r,e[s],n))return s;for(;a<=s;){const h=a+s>>1,D=ne(r,e[h],n);if(D===o)return h;D<o?a=h+1:s=h-1}const c=Math.abs(ne(r,e[a],n)-o),d=Math.abs(ne(r,e[s],n)-o);return c<d?a:s},vt=(e,t,r,n,o=0)=>{if(it("getSortedAllowedDates",o),!Array.isArray(e)||e.length===0)return[];const a=ne(t,r,o),s=ne(t,n,o),c=new Map;for(const d of e){const h=ke(t,d,o),D=ne(t,h,o);D<a||D>s||c.has(D)||c.set(D,h)}if(c.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(c.keys()).sort((d,h)=>d-h).map(d=>c.get(d))},mn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const s=be(e,n,t,o);if(r==="time"){const c=e[0].getTime(),d=e[a].getTime()-c;return d<=0?0:Math.max(0,Math.min(1,(e[s].getTime()-c)/d))}return s/a},fn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const s=Math.max(0,Math.min(1,n));if(r==="time"){const c=e[0].getTime(),d=e[a].getTime()-c;return d<=0?0:be(e,new Date(c+s*d),t,o)}return Math.max(0,Math.min(a,Math.round(s*a)))},Mo=(e,t,r,n,o,a,s)=>{let c=r,d=n;return s?(c=t,d=t):e==="low"?t>n?(c=n,d=t):c=t:t<r?(d=r,c=t):d=t,[Math.max(o,Math.min(a,c)),Math.max(o,Math.min(a,d))]},ri=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:s,snapMode:c,unit:d,yearStartMonth:h=0})=>{if(a){const G=s.length-1;if(G<=0)return[0,0];const F=Math.max(0,Math.min(G,Math.round(t))),X=Math.max(F,Math.min(G,Math.round(r)));if(c==="time"){const y=s[0].getTime(),ae=s[G].getTime(),W=s[F].getTime(),Z=s[X].getTime()-W;let oe=W+e*(ae-y),$=oe+Z;oe<y&&(oe=y,$=y+Z),$>ae&&($=ae,oe=ae-Z);const v=be(s,new Date(oe),d,h),j=be(s,new Date($),d,h);return[v,Math.max(v,j)]}const _=Math.round(e*G);let m=F+_,K=X+_;return m<0&&(K+=-m,m=0),K>G&&(m-=K-G,K=G),[Math.max(0,Math.min(G,m)),Math.max(0,Math.min(G,K))]}const D=G=>Math.max(n,Math.min(o,G)),S=o-n;if(S<=0)return[D(t),D(r)];const u=Math.round(e*S);let M=t+u,R=r+u;return M<n&&(R+=n-M,M=n),R>o&&(M-=R-o,R=o),[D(M),D(R)]},ni=(e,t,r,n,o,a,s,c)=>{let d=0,h=!1,D=!1;switch(e){case"ArrowRight":case"ArrowUp":d=c;break;case"ArrowLeft":case"ArrowDown":d=-c;break;case"PageUp":d=c*5;break;case"PageDown":d=-c*5;break;case"Home":h=!0;break;case"End":D=!0;break;default:return null}if(s){let M=r;return h?M=o:D?M=a:M=Math.max(o,Math.min(a,r+d)),[M,M]}let S=r,u=n;return t==="low"?h?S=o:D?S=n:S=Math.max(o,Math.min(n,r+d)):h?u=r:D?u=a:u=Math.max(r,Math.min(a,n+d)),[S,u]},oi=8,ai=2,ii=16,$s=12,Is=90,si=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},Lo=(e,t)=>{const r=t?.estimatedHeightPx??ii,o=oi+(t?.anchorGapY??ai)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},To=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,s=o?.estimatedHeightPx??ii,c=o?.paddingPx??$s,d=o?.maxAngleDeg??Is,h=oi+(o?.anchorGapY??ai),D=Lo(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return D;const S=Math.max(0,t-e)/100*r,u=a+c;if(S>=u)return D;const M=Math.max(0,Math.min(1,(u-S)/u)),G=M*M*M*(M*(M*6-15)+10)*d,F=n==="top"?-G:G,X=si(a,s,G),_=h+X.acrossPx,m=n==="top"?-_:+_,K=2*X.alongPx,y=Math.max(0,(K+c-S)/2);return{lowAngleDeg:F,highAngleDeg:F,lowOffsetX:-y,highOffsetX:y,lowOffsetY:m,highOffsetY:m,isSlanted:M>.001,proximity:M}},li=e=>({...e,lowOffsetX:0,highOffsetX:0}),yo=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},ci=(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 ui(e,t,r,n,o,a,s="macro-top",c=.05,d=!0,h="range"){if(yo(t,s)==="macro"){const u=Math.abs(e-r),M=Math.abs(e-n);return u<=c&&u<=M?"macro-low":M<=c&&M<u?"macro-high":d&&e>=r&&e<=n?"macro-connect":u<M?"macro-low":"macro-high"}if(h==="point")return"micro-point";const D=Math.abs(e-o),S=Math.abs(e-a);return D<=c&&D<=S?"micro-low":S<=c&&S<D?"micro-high":d&&e>=o&&e<=a?"micro-connect":D<S?"micro-low":"micro-high"}function di(e,t,r,n,o){if(e==="macro-connect"){const[h,D]=So(t-r,n,o);return[h,D,"macro-connect"]}const a=e==="macro-low"?"low":"high",[s,c]=vn(a,t,n,o),d=An(a,t,n,o);return[s,c,d==="low"?"macro-low":"macro-high"]}function mi(e,t,r,n,o){if(e==="micro-point"){const[h]=vn("point",t,n,o);return[h,h,"micro-point"]}if(e==="micro-connect"){const[h,D]=So(t-r,n,o);return[h,D,"micro-connect"]}const a=e==="micro-low"?"low":"high",[s,c]=vn(a,t,n,o),d=An(a,t,n,o);return[s,c,d==="low"?"micro-low":"micro-high"]}const jr=i.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;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",a=`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",a=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const s=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return x.jsx("svg",{className:a,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:x.jsx("path",{d:o,className:s,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});jr.displayName="VernierKnobSvg";const ks=(e,t)=>{if(!qe(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${pe(e)})`);if(!qe(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)})`)},Ur=(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(!qe(n))throw new RangeError(`${r}: ${e}[0] must be a valid Date (received: ${pe(n)})`);if(!qe(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)})`)},vo=(e,t)=>{if(!qe(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${pe(t)})`)},Mt=(e,t,r,n,o,a)=>{const s=ne(r,t,a);if(s<ne(r,n,a)||s>ne(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${pe(t)}, minDate: ${pe(n)}, maxDate: ${pe(o)})`)},Ns=(e,t,r)=>{const n=e.yearStartMonth??0;if(e.mode==="range"){for(const o of["range","defaultRange"]){const a=e[o];a!==void 0&&(Ur(o,a),Mt(`${o}[0]`,a[0],e.unit,t,r,n),Mt(`${o}[1]`,a[1],e.unit,t,r,n))}return}if(e.mode==="point")for(const o of["value","defaultValue"]){const a=e[o];a!==void 0&&(vo(o,a),Mt(o,a,e.unit,t,r,n))}},Vs=(e,t,r)=>{const n=e.yearStartMonth??0;Ur("macroRange",e.macroRange);const o=e.microUnit??e.unit,a=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(a&&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 vo("microValue",e.microValue),Mt("microValue",e.microValue,o,t,r,n),{shape:"point",selection:[e.microValue,e.microValue]};if(e.defaultMicroValue!==void 0)return vo("defaultMicroValue",e.defaultMicroValue),Mt("defaultMicroValue",e.defaultMicroValue,o,t,r,n),{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 Ur("microRange",e.microRange),Mt("microRange[0]",e.microRange[0],o,t,r,n),Mt("microRange[1]",e.microRange[1],o,t,r,n),{shape:"range",selection:e.microRange};if(e.defaultMicroRange!==void 0)return Ur("defaultMicroRange",e.defaultMicroRange),Mt("defaultMicroRange[0]",e.defaultMicroRange[0],o,t,r,n),Mt("defaultMicroRange[1]",e.defaultMicroRange[1],o,t,r,n),{shape:"range",selection:e.defaultMicroRange};throw a?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")},Yr=(e,t,r,n,o,a,s,c,d)=>{const h=be(e,n,t,d),D=be(e,o,t,d);return s?h:c?D:Math.max(h,Math.min(D,be(e,r,t,d)+a))},mo=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Ca=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback((a,s)=>{const c=r.current;if(c!==null&&c[0].getTime()===a.getTime()&&c[1].getTime()===s.getTime())return;const d=[a,s];r.current=d,t(d)},[]),o=i.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Os=(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)})`)}},br=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(s=>{for(const c of s){const d=c.borderBoxSize?.[0];d!==void 0&&t(h=>h!==null&&Math.abs(h.widthPx-d.inlineSize)<.5&&Math.abs(h.heightPx-d.blockSize)<.5?h:{widthPx:d.inlineSize,heightPx:d.blockSize})}});a.observe(o),r.current=a},[]);return i.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},fo=(e,t)=>{const r=pn(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},pn=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},Ys=e=>{const t={};let r=0;for(const o of e){const{side:a,box:s}=o;if(s===null)continue;let c;if(o.reach==="inline-size")c=s.widthPx,r=Math.max(r,s.heightPx/2);else{const d=si(s.widthPx,s.heightPx,o.angleDeg);c=o.centreOffsetPx===null?2*d.acrossPx:Math.abs(o.centreOffsetPx)+d.acrossPx,r=Math.max(r,d.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${a}`]=`${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}},$a=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),Ia=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),xn=(e,t)=>({"--ps-tooltip-tx":io(e,"tx",t.tx),"--ps-tooltip-ty":io(e,"ty",t.ty),"--ps-tooltip-rot":io(e,"rot",t.rot)}),go=(e,t,r,n)=>{const o=Lo(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=To(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),s=n.isMerged?li(a):a,c=Pn[e],d={low:$a(s.lowOffsetX,s.lowOffsetY-o.lowOffsetY,s.lowAngleDeg),high:$a(s.highOffsetX,s.highOffsetY-o.highOffsetY,s.highAngleDeg)};return{slant:s,lowStyle:xn(c.low,d.low),highStyle:xn(c.high,d.high),placements:d}},ka={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Na=(e,t,r)=>{const n=Lo(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:ka,highStyle:ka,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const d=To(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?li(d):d}const s=Pn.flat,c={low:Ia(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:Ia(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...xn(s.low,c.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...xn(s.high,c.high)},placements:o?c:null}},Hs={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},_s={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"}},Va={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},Fs={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Br} ${Pa.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Va.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Br} ${Pa.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Va.vertical}`}},Oa={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"}},Ya=(e,t)=>{e.setPointerCapture(t)},js=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:s=!1,className:c="",showStepper:d=!0,tooltipStyle:h="always",labelPosition:D="top",autoSlantLabels:S=!0,isVertical:u=!1,hideConnectBar:M=!1,showTicks:R=!1,colorScheme:G="blue-rose",locale:F,decreaseAriaLabel:X="Decrease",increaseAriaLabel:_="Increase"}=e,m=Mr("PeriodSlider",e.yearStartMonth);ks(r,n),Ns(e,r,n),F!==void 0&&Os("locale",F);const K=e.mode==="vernier"?Vs(e,r,n):null,y=K!==null&&K.shape==="point",ae=Qa[G],W=i.useId(),Z=i.useRef(e),oe=r.getTime(),$=n.getTime(),v=i.useMemo(()=>vt(o,t,r,n,m),[o,t,oe,$,m]),j=v.length>0,{rangeMin:P,rangeMax:Y}=i.useMemo(()=>j?{rangeMin:0,rangeMax:v.length-1}:{rangeMin:ne(t,r,m),rangeMax:ne(t,n,m)},[j,v,t,oe,$,m]),k=e.mode==="point",B=i.useCallback(l=>{if(j){const f=Math.max(0,Math.min(v.length-1,Math.round(l)));return v[f]}return ue(t,Math.round(l),m)},[j,v,t,m]),ie=i.useCallback(l=>{if(l===void 0)return P;const f=ke(t,l,m);return j?be(v,f,t,m):ne(t,f,m)},[j,v,t,P,m]),[le,se]=i.useState(()=>K===null?null:K.selection);let U=le??(K===null?null:K.selection);if(y&&U!==null&&U[0].getTime()!==U[1].getTime()){const l=[U[0],U[0]];U=l,se(l)}const te=e.mode==="vernier"?e.microValue?.getTime():void 0,Q=i.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,te]),ve=Ca(),T=Ca(),re=e.mode!=="vernier"?null:y?Q??U:e.microRange!==void 0?e.microRange:U,fe=re===null?null:T.shown??re,Le=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?fe?.[0]:void 0,De=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?fe?.[1]:void 0,Ne=e.mode==="point"?e.value??e.defaultValue:void 0,Ye=e.mode==="point"?Ne?.getTime():Le?.getTime(),Ge=e.mode==="range"?De?.getTime():Ye,[st,lt]=i.useMemo(()=>{if(e.mode==="point"){const g=ie(Ne);return[g,g]}const l=ie(Le),f=ie(De);return[Math.min(l,f),Math.max(l,f)]},[e.mode,Ye,Ge,ie,Ne,Le,De]),V=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:y?e.microValue!==void 0:e.microRange!==void 0,[ee,de]=i.useState(()=>[st,lt]),[p,A]=i.useState(null),[H,he]=i.useState(null),ge=i.useRef(null),[Te,Ee]=i.useState("high"),[je,tt]=i.useState(null),[xt,kt]=i.useState(null),ye=p?p[0]:V?st:ee[0],Me=p?p[1]:V?lt:ee[1],$n=i.useRef([ye,Me]),w=e.mode==="vernier",J=e.mode==="vernier"?e.vernierOrientation??(u?"macro-left":"macro-top"):"macro-top",C=J==="macro-top"||J==="macro-left",vr=e.mode==="vernier"?e.showVernierProjection??!0:!1,Nt=e.mode==="vernier"?e.showVernierTicks??!0:!1,Ze=e.mode==="vernier"?e.showHairline??!0:!1,q=w?e.macroUnit??t:t,E=w?e.microUnit??t:t,In=w?e.macroIsDiscrete??!1:j,xr=w?e.microIsDiscrete??!1:j,Po=w?e.macroAllowedDates??o:o,Ao=w?e.microAllowedDates??o:o,Wr=w?e.formatMacroLabel??e.formatLabel:e.formatLabel,Gr=w?e.formatMicroLabel??e.formatLabel:e.formatLabel,xi=Le?.getTime(),Ri=De?.getTime(),[Xe,Xr]=i.useState(null),Rt=i.useRef(null),[Rr,Zt]=i.useState(()=>y?"micro-point":"micro-high");let Ve=Rr;const kn=y?Rr==="micro-low"||Rr==="micro-high"||Rr==="micro-connect"?"micro-point":null:Rr==="micro-point"?"micro-high":null;kn!==null&&(Ve=kn,Zt(kn));const He=i.useMemo(()=>ne(q,r,m),[oe,q,m]),ct=i.useMemo(()=>{const l=ne(q,n,m);if(w&&l<=He)throw new RangeError(`PeriodSlider: macroUnit "${q}" cannot distinguish minDate from maxDate (minDate: ${pe(r)}, maxDate: ${pe(n)})`);return l},[w,oe,$,He,q,m]),Pe=i.useMemo(()=>w&&In?vt(Po,q,r,n,m):[],[w,In,Po,q,oe,$,m]),Eo=l=>[Math.max(He,Math.min(ct,ne(q,l[0],m))),Math.max(He,Math.min(ct,ne(q,l[1],m)))],[Co,$o]=e.mode!=="vernier"?[He,ct]:Eo(e.macroRange),[ze,Ue]=ve.shown===null?[Co,$o]:Eo(ve.shown),bt=i.useMemo(()=>ue(q,ze,m),[q,ze,m]),Vt=i.useMemo(()=>ue(q,Ue,m),[q,Ue,m]),Kr=i.useMemo(()=>e.mode!=="vernier"?[r,n]:ht(q,E,[bt,Vt],r,n,m),[e.mode,bt,Vt,q,E,oe,$,m]),xe=i.useMemo(()=>ne(E,Kr[0],m),[E,Kr,m]),Ce=i.useMemo(()=>ne(E,Kr[1],m),[E,Kr,m]),Io=i.useMemo(()=>w&&xr?vt(Ao,E,r,n,m):[],[w,xr,Ao,E,oe,$,m]),Nn=(l,f)=>Io.filter(g=>{const b=ne(E,g,m);return b>=l&&b<=f}),me=i.useMemo(()=>Nn(xe,Ce),[Io,E,xe,Ce]),Qt=In&&Pe.length>0,rt=xr&&me.length>0,St=(l,f,g,b)=>f.length>0?ne(E,f[be(f,l,E,m)],m):Math.max(g,Math.min(b,ne(E,l,m))),Jt=rt?me:[],$e=i.useMemo(()=>fe===null?xe:St(fe[0],Jt,xe,Ce),[xi,xe,Ce,E,fe,Jt]),Be=i.useMemo(()=>fe===null?Ce:St(fe[1],Jt,xe,Ce),[Ri,xe,Ce,E,fe,Jt]),Lt=i.useMemo(()=>ue(E,$e,m),[E,$e,m]),Tt=i.useMemo(()=>ue(E,Be,m),[E,Be,m]),ko=!w||re===null?null:{macroUnit:q,macroLowEnc:Co,macroHighEnc:$o,microUnit:E,microLowEnc:ne(E,re[0],m),microHighEnc:ne(E,re[1],m)},Vn=i.useRef(ko),qr=Math.max(1,ct-He),nt=Qt?mn(Pe,q,a,bt,m):Math.max(0,Math.min(1,(ze-He)/qr)),ut=Math.max(nt,Qt?mn(Pe,q,a,Vt,m):Math.min(1,(Ue-He)/qr)),Zr=Math.max(1,Ce-xe),er=rt?mn(me,E,a,Lt,m):Math.max(0,Math.min(1,($e-xe)/Zr)),Sr=Math.max(er,rt?mn(me,E,a,Tt,m):Math.min(1,(Be-xe)/Zr)),On=i.useRef({timerId:null,emit:null}),Qr=i.useRef({timerId:null,emit:null}),Jr=i.useRef({timerId:null,emit:null});i.useEffect(()=>{const l=[On,Qr,Jr];return()=>{for(const f of l)mo(f.current)}},[]);const tr=i.useCallback((l,f,g)=>{mo(l);const{debounceMs:b}=Z.current;if(g||!b||b<=0){f();return}l.emit=f,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,f()},b)},[]),No=i.useCallback(l=>{const f=l.emit;mo(l),f?.()},[]),rr=i.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),oe),$)),[oe,$]),yt=i.useCallback((l,f,g=!1)=>{const[b,L]=$n.current;if((Z.current.mode==="point"?l===b:l===b&&f===L)&&On.current.timerId===null)return;const O=B(l),N=B(f),ce=()=>{const we=Z.current;we.mode==="point"?we.onChangePoint?.(O):we.mode==="range"&&we.onChangeRange?.(O,N)};tr(On.current,ce,g)},[B,tr]),Ot=i.useCallback((l,f,g=!1)=>{const b=Vn.current;if(Z.current.mode!=="vernier"||b===null)return;const L=rr(l),I=rr(f);ne(b.macroUnit,L,m)===b.macroLowEnc&&ne(b.macroUnit,I,m)===b.macroHighEnc&&Qr.current.timerId===null||tr(Qr.current,()=>{const O=Z.current;O.mode==="vernier"&&O.onChangeMacroRange?.(L,I)},g)},[rr,tr,m]),Qe=i.useCallback((l,f,g=!1)=>{const b=Z.current,L=Vn.current;if(b.mode!=="vernier"||L===null)return;const I=rr(l),O=rr(f);ne(L.microUnit,I,m)===L.microLowEnc&&ne(L.microUnit,O,m)===L.microHighEnc&&Jr.current.timerId===null||((y?b.microValue===void 0:b.microRange===void 0)&&se([I,O]),tr(Jr.current,()=>{const N=Z.current;if(N.mode==="vernier"){if(y){N.onChangeMicroPoint?.(I);return}N.onChangeMicroRange?.(I,O)}},g))},[rr,tr,y,m]),Vo=i.useCallback((l,f=!1)=>{Qe(l,l,f)},[Qe]),Yt=i.useCallback(l=>{if(j&&a==="time"&&v.length>1){const b=Math.max(0,Math.min(v.length-1,Math.round(l))),L=v[0].getTime(),O=v[v.length-1].getTime()-L;if(O<=0)return 0;const N=v[b].getTime();return Math.max(0,Math.min(100,(N-L)/O*100))}const f=Y-P;if(f<=0)return 0;const g=(l-P)/f*100;return Math.max(0,Math.min(100,g))},[j,a,v,P,Y]),Yn=i.useCallback(l=>{const f=Math.max(0,Math.min(100,l));if(j){if(a==="time"&&v.length>1){const L=v[0].getTime(),O=v[v.length-1].getTime()-L,N=L+f/100*O;return be(v,new Date(N),t,m)}const b=Math.round(f/100*(v.length-1));return Math.max(0,Math.min(v.length-1,b))}const g=P+f/100*(Y-P);return Math.round(g)},[j,a,v,P,Y,t,m]),Lr=i.useRef(null),Oo=i.useRef(null),Yo=i.useRef(0),Ke=i.useRef(null),Hn=i.useRef(null),Ho=i.useRef(null),_o=i.useRef(null),[_n,Fo]=i.useState(0),[Si,nr]=br(),[Li,jo]=br(),[Ti,zo]=br(),[yi,Uo]=br(),[Pi,Fn]=br(),[Ai,Bo]=br(),Ei=k?nr===null?void 0:{estimatedWidthPx:nr.widthPx,estimatedHeightPx:nr.heightPx}:fo(nr,jo),jn=!k&&ye===Me,zn=ze===Ue,Un=!y&&$e===Be,Ci=C?"top":"bottom",$i=C?"bottom":"top",Wo=S&&!u,Ii=Wo&&!y,Bn={isPointMode:k,isVertical:u,autoSlantLabels:S,isMerged:jn,trackLengthPx:_n,labelPosition:D,config:Ei},Wn={trackLengthPx:_n,labelPosition:Ci,config:fo(zo,Uo),isMerged:zn,isSlantable:Wo},Gn={trackLengthPx:_n,labelPosition:$i,config:fo(Fn,Bo),isMerged:Un,isSlantable:Ii};i.useEffect(()=>{const l=Ke.current;if(!l)return;const f=()=>{const b=l.getBoundingClientRect(),L=u?b.height:b.width;L>0&&Fo(I=>Math.abs(I-L)<.5?I:L)};if(f(),typeof ResizeObserver<"u"){const b=new ResizeObserver(L=>{for(const I of L){const O=u?I.contentRect.height:I.contentRect.width;O>0&&Fo(N=>Math.abs(N-O)<.5?N:O)}});return b.observe(l),()=>b.disconnect()}const g=l.ownerDocument.defaultView;if(g)return g.addEventListener("resize",f),()=>g.removeEventListener("resize",f)},[u]);const or=i.useCallback((l,f,g)=>{const b=u?g.height:g.width;if(!(Number.isFinite(b)&&b>0))return null;const L=u?g.bottom-f:l-g.left;return Number.isFinite(L)?Math.max(0,Math.min(1,L/b)):null},[u]),Go=i.useCallback((l,f)=>{const g=Ke.current;if(!g)return null;const b=or(l,f,g.getBoundingClientRect());return b===null?null:b*100},[or]),Tr=i.useRef(null),wt=i.useRef(null),en=i.useRef({macroLowRatio:nt,macroHighRatio:ut,isVertical:u,isMacroFirstRail:C}),Xo=i.useRef({flat:Bn,macro:Wn,micro:Gn});i.useLayoutEffect(()=>{en.current={macroLowRatio:nt,macroHighRatio:ut,isVertical:u,isMacroFirstRail:C},Xo.current={flat:Bn,macro:Wn,micro:Gn},Z.current=e,$n.current=[ye,Me],Vn.current=ko,ge.current=H,Rt.current=Xe});const Ko=(l,f)=>{const g=en.current;Hn.current?.setAttribute("d",so(l,f,g.isVertical,g.isMacroFirstRail))},ki=(l,f,g)=>{const b=Xo.current;return l==="flat"?Na(f*100,g*100,b.flat).placements:go(l,f,g,l==="macro"?b.macro:b.micro).placements},yr=(l,f,g)=>{const b=Ke.current;if(!b)return;Tr.current={rail:l,lowRatio:f,highRatio:g},ds(b,l,f,g);const L=ki(l,f,g);L!==null&&us(b,l,L),l==="macro"&&Ko(f,g)},Ht=i.useCallback(()=>{wt.current!==null&&(clearTimeout(wt.current),wt.current=null);const l=Ke.current;l&&(l.removeAttribute(oo),l.style.removeProperty(ao))},[]),qo=()=>{const l=Ke.current;if(Tr.current===null||!l){Tr.current=null;return}Tr.current=null,wt.current!==null&&clearTimeout(wt.current),l.style.setProperty(ao,`${La}ms`),l.setAttribute(oo,"true"),ms(l),Ko(en.current.macroLowRatio,en.current.macroHighRatio),wt.current=setTimeout(()=>{wt.current=null,l.removeAttribute(oo),l.style.removeProperty(ao)},La)};i.useLayoutEffect(()=>{const l=Tr.current;l!==null&&yr(l.rail,l.lowRatio,l.highRatio)}),i.useEffect(()=>()=>{wt.current!==null&&clearTimeout(wt.current)},[]);const ar=i.useRef(null),ir=i.useRef(null),dt=i.useRef(null),Xn=i.useRef(null),Pr=i.useRef(null),Pt=i.useCallback(()=>ar.current!==null||ir.current!==null,[]),Zo=l=>{if(s)return;if(w){const z=ir.current;if(!z||l.pointerId!==z.pointerId||!Ke.current)return;const ot=or(l.clientX,l.clientY,Ke.current.getBoundingClientRect());if(ot===null)return;if(z.handle==="macro-low"||z.handle==="macro-high"||z.handle==="macro-connect"){const[Ie,Ae,pt]=di(z.handle,ot,z.startPointerRatio,z.startMacroLowRatio,z.startMacroHighRatio);yr("macro",Ie,Ae),pt!==Rt.current&&(Rt.current=pt,Xr(pt),Zt(pt));let _e,Je;if(Qt){const At=fn(Pe,q,a,Ie,m),Et=Math.max(At,fn(Pe,q,a,Ae,m));_e=Pe[At],Je=Pe[Et]}else{const At=Math.round(He+Ie*qr),Et=Math.round(He+Ae*qr);_e=ue(q,At,m),Je=ue(q,Et,m)}ve.show(_e,Je);const Ir=`${_e.getTime()}_${Je.getTime()}`;Ir!==Xn.current&&(Xn.current=Ir,Ot(_e,Je));const[Dt,Ft]=ht(q,E,[_e,Je],r,n,m),ro=ne(E,Dt,m),no=ne(E,Ft,m),va=xr?Nn(ro,no):[];let jt,zt;if(z.handle==="macro-connect"){const At=Dt,Et=Ft;let fr,gr;if(q==="year"){const Ct=_e.getFullYear()-z.startMacroLowDate.getFullYear();fr=Oe("year",z.initialMicroLowDate,Ct),gr=Oe("year",z.initialMicroHighDate,Ct)}else if(q==="month"){const Ct=(_e.getFullYear()-z.startMacroLowDate.getFullYear())*12+(_e.getMonth()-z.startMacroLowDate.getMonth());fr=Oe("month",z.initialMicroLowDate,Ct),gr=Oe("month",z.initialMicroHighDate,Ct)}else{const Ct=Math.round((_e.getTime()-z.startMacroLowDate.getTime())/864e5);fr=Oe("day",z.initialMicroLowDate,Ct),gr=Oe("day",z.initialMicroHighDate,Ct)}const hr=At.getTime(),kr=Et.getTime(),Sa=z.initialMicroHighDate.getTime()-z.initialMicroLowDate.getTime();let Nr=fr.getTime(),Vr=gr.getTime();Nr<hr&&(Nr=hr,Vr=Math.min(kr,Nr+Sa)),Vr>kr&&(Vr=kr,Nr=Math.max(hr,Vr-Sa)),jt=ke(E,new Date(Nr),m),zt=ke(E,new Date(Vr),m)}else{const At=Dt.getTime(),Et=Ft.getTime(),fr=z.initialMicroLowDate.getTime(),gr=z.initialMicroHighDate.getTime(),hr=Math.max(At,Math.min(Et,fr)),kr=Math.max(hr,Math.min(Et,gr));jt=ke(E,new Date(hr),m),zt=ke(E,new Date(kr),m)}const xa=St(jt,va,ro,no),ss=Math.max(xa,St(zt,va,ro,no));jt=ue(E,xa,m),zt=ue(E,ss,m),T.show(jt,zt);const Ra=`${jt.getTime()}_${zt.getTime()}`;Ra!==Pr.current&&(Pr.current=Ra,Qe(jt,zt))}else if(z.handle==="micro-low"||z.handle==="micro-high"||z.handle==="micro-connect"||z.handle==="micro-point"){const[Ie,Ae,pt]=mi(z.handle,ot,z.startPointerRatio,z.startMicroLowRatio,z.startMicroHighRatio);yr("micro",Ie,Ae),pt!==Rt.current&&(Rt.current=pt,Xr(pt),Zt(pt));let _e,Je;if(rt){const Dt=fn(me,E,a,Ie,m),Ft=Math.max(Dt,fn(me,E,a,Ae,m));_e=me[Dt],Je=me[Ft]}else{const Dt=St(ue(E,Math.round(xe+Ie*Zr),m),Jt,xe,Ce),Ft=Math.max(Dt,St(ue(E,Math.round(xe+Ae*Zr),m),Jt,xe,Ce));_e=ue(E,Dt,m),Je=ue(E,Ft,m)}T.show(_e,Je);const Ir=`${_e.getTime()}_${Je.getTime()}`;Ir!==Pr.current&&(Pr.current=Ir,Qe(_e,Je))}return}const f=ar.current;if(!f||l.pointerId!==f.pointerId||!Ke.current)return;const g=Ke.current.getBoundingClientRect(),b=u?l.clientY:l.clientX,L=u?g.height:g.width;if(!(Number.isFinite(L)&&L>0))return;if(f.handle==="connect"){const z=u?(f.startPointerPos-b)/L:(b-f.startPointerPos)/L,[ot,Ie]=So(z,f.startLowRatio,f.startHighRatio);yr("flat",ot,Ie);const Ae=ri({posDiffPct:z,startLowVal:f.startLowVal,startHighVal:f.startHighVal,rangeMin:P,rangeMax:Y,isDiscrete:j,sortedAllowedDates:v,snapMode:a,unit:t,yearStartMonth:m});if(dt.current&&dt.current[0]===Ae[0]&&dt.current[1]===Ae[1])return;dt.current=Ae,A(Ae),yt(Ae[0],Ae[1],!1);return}const I=or(l.clientX,l.clientY,g);if(I===null)return;const[O,N]=vn(k?"point":f.handle,I,f.startLowRatio,f.startHighRatio);yr("flat",O,N);const ce=Yn(I*100),[we,Re]=Mo(f.handle,ce,f.startLowVal,f.startHighVal,P,Y,k);if((!dt.current||dt.current[0]!==we||dt.current[1]!==Re)&&(dt.current=[we,Re],A([we,Re]),yt(we,Re,!1)),!k&&(f.handle==="low"||f.handle==="high")){const z=An(f.handle,I,f.startLowRatio,f.startHighRatio);ge.current!==z&&(ge.current=z,he(z),Ee(z))}},Qo=()=>{qo(),Xn.current=null,Pr.current=null,ir.current=null,Rt.current=null,Xr(null),ve.release(),T.release(),No(Qr.current),No(Jr.current)},Jo=()=>{qo();const l=dt.current??p;l&&(yt(l[0],l[1],!0),de(l)),dt.current=null,A(null),ar.current=null,ge.current=null,he(null)},ea=l=>{if(w){const g=ir.current;if(!g||l.pointerId!==g.pointerId)return;Qo();return}const f=ar.current;!f||l.pointerId!==f.pointerId||Jo()},ta=()=>{ir.current!==null&&Qo(),ar.current!==null&&Jo()},Kn=i.useRef(Zo),ra=i.useRef(ea),na=i.useRef(ta);i.useLayoutEffect(()=>{Kn.current=Zo,ra.current=ea,na.current=ta});const oa=i.useRef(w);i.useEffect(()=>{oa.current!==w&&(oa.current=w,na.current())},[w]);const aa=H!==null||Xe!==null;i.useEffect(()=>{if(!aa)return;const l=Lr.current?.ownerDocument.defaultView;if(!l)return;const f=b=>Kn.current(b),g=b=>ra.current(b);return l.addEventListener("pointermove",f),l.addEventListener("pointerup",g),l.addEventListener("pointercancel",g),l.addEventListener("lostpointercapture",g),()=>{l.removeEventListener("pointermove",f),l.removeEventListener("pointerup",g),l.removeEventListener("pointercancel",g),l.removeEventListener("lostpointercapture",g)}},[aa]);const qn=i.useCallback((l,f,g,b)=>{Ht(),Ya(l,f),ar.current={pointerId:f,handle:g,startPointerPos:b,startLowVal:ye,startHighVal:Me,startLowRatio:Yt(ye)/100,startHighRatio:Yt(Me)/100},ge.current=g,he(g),g!=="connect"&&Ee(g)},[ye,Me,Yt]),ia=i.useCallback((l,f,g,b)=>{Z.current.mode==="vernier"&&(Ht(),Ya(l,f),ir.current={pointerId:f,handle:g,startPointerRatio:b,startMacroLowRatio:nt,startMacroHighRatio:ut,startMicroLowRatio:er,startMicroHighRatio:Sr,startMacroLowDate:bt,initialMicroLowDate:Lt,initialMicroHighDate:Tt},Rt.current=g,Xr(g),Zt(g))},[nt,ut,er,Sr,bt,Lt,Tt]),sa=l=>f=>{if(s||Pt())return;f.stopPropagation(),f.preventDefault(),Ee(l);const g=u?f.clientY:f.clientX;qn(f.currentTarget,f.pointerId,l,g)},la=l=>()=>{s||ge.current!==null||Ee(l)},tn=l=>()=>{s||Rt.current!==null||Zt(l)},sr=l=>f=>{if(s||Pt())return;f.stopPropagation(),f.preventDefault();const g=Ke.current;if(!g)return;const b=or(f.clientX,f.clientY,g.getBoundingClientRect());b!==null&&ia(f.currentTarget,f.pointerId,l,b)},Ni=l=>{if(s||M||Pt())return;l.stopPropagation(),l.preventDefault();const f=u?l.clientY:l.clientX;qn(l.currentTarget,l.pointerId,"connect",f)},Vi=l=>{if(s||Pt())return;if(w){const N=Ke.current;if(!N)return;const ce=N.getBoundingClientRect(),we=or(l.clientX,l.clientY,ce);if(we===null)return;const Re=u?l.clientX-(ce.left+ce.width/2):l.clientY-(ce.top+ce.height/2),z=ui(we,Re,nt,ut,er,Sr,J,void 0,!M,y?"point":"range");ia(l.currentTarget,l.pointerId,z,we),Kn.current(l.nativeEvent);return}const f=Go(l.clientX,l.clientY);if(f===null)return;const g=Yn(f);let b="low";if(!k){const N=Math.abs(g-ye),ce=Math.abs(g-Me);N<ce?b="low":ce<N?b="high":b=g>Me?"high":"low"}Ee(b);const[L,I]=Mo(b,g,ye,Me,P,Y,k);A([L,I]),yt(L,I,!0);const O=u?l.clientY:l.clientX;qn(l.currentTarget,l.pointerId,b,O)},Oi=l=>{if(s||w||H!==null)return;const f=Go(l.clientX,l.clientY);if(f===null)return;const g=Yn(f);tt(g),kt(Yt(g))},Yi=()=>{tt(null),kt(null)},ca=l=>f=>{if(s||Pt())return;Ee(l);const g=ni(f.key,l,ye,Me,P,Y,k,1);g&&(f.preventDefault(),Ht(),V||de(g),yt(g[0],g[1],!0))},lr=(l,f)=>{if(re===null)return;const[g,b]=ht(q,E,[l,f],r,n,m),L=ne(E,g,m),I=ne(E,b,m),O=xr?Nn(L,I):[],N=St(re[0],O,L,I),ce=Math.max(N,St(re[1],O,L,I));Qe(ue(E,N,m),ue(E,ce,m),!0)},rn=l=>f=>{if(s||!w||e.mode!=="vernier"||Pt())return;Zt(l);let g=0,b=!1,L=!1;switch(f.key){case"ArrowRight":case"ArrowUp":g=1;break;case"ArrowLeft":case"ArrowDown":g=-1;break;case"PageUp":g=5;break;case"PageDown":g=-5;break;case"Home":b=!0;break;case"End":L=!0;break;default:return}if(f.preventDefault(),Ht(),l==="macro-low"){const I=ue(q,ze,m),O=ue(q,Ue,m);if(Qt){const we=Yr(Pe,q,I,Pe[0],O,g,b,L,m);if(we===be(Pe,I,q,m))return;const Re=Pe[we];Ot(Re,O,!0),lr(Re,O);return}let N;if(b?N=He:L?N=Ue:N=Math.max(He,Math.min(Ue,ze+g)),N===ze)return;const ce=ue(q,N,m);Ot(ce,O,!0),lr(ce,O)}else if(l==="macro-high"){const I=ue(q,ze,m),O=ue(q,Ue,m);if(Qt){const we=Yr(Pe,q,O,I,Pe[Pe.length-1],g,b,L,m);if(we===be(Pe,O,q,m))return;const Re=Pe[we];Ot(I,Re,!0),lr(I,Re);return}let N;if(b?N=ze:L?N=ct:N=Math.max(ze,Math.min(ct,Ue+g)),N===Ue)return;const ce=ue(q,N,m);Ot(I,ce,!0),lr(I,ce)}else if(l==="micro-low"){const I=ue(E,$e,m),O=ue(E,Be,m);if(rt){const ce=Yr(me,E,I,me[0],O,g,b,L,m);if(ce===be(me,I,E,m))return;Qe(me[ce],O,!0);return}let N;if(b?N=xe:L?N=Be:N=Math.max(xe,Math.min(Be,$e+g)),N===$e)return;Qe(ue(E,N,m),O,!0)}else if(l==="micro-high"){const I=ue(E,$e,m),O=ue(E,Be,m);if(rt){const ce=Yr(me,E,O,I,me[me.length-1],g,b,L,m);if(ce===be(me,O,E,m))return;Qe(I,me[ce],!0);return}let N;if(b?N=$e:L?N=Ce:N=Math.max($e,Math.min(Ce,Be+g)),N===Be)return;Qe(I,ue(E,N,m),!0)}else if(l==="micro-point"){const I=ue(E,$e,m);if(rt){const N=Yr(me,E,I,me[0],me[me.length-1],g,b,L,m);if(N===be(me,I,E,m))return;Vo(me[N],!0);return}let O;if(b?O=xe:L?O=Ce:O=Math.max(xe,Math.min(Ce,$e+g)),O===$e)return;Vo(ue(E,O,m),!0)}},Hi=l=>{if(e.mode!=="vernier")return;if(Ht(),Qt){const O=Pe.length-1,N=be(Pe,bt,q,m),ce=be(Pe,Vt,q,m),we=ce-N;let Re=N+l,z=ce+l;if(l<0&&Re<0?(Re=0,z=Math.min(O,we)):l>0&&z>O&&(z=O,Re=Math.max(0,O-we)),Re===N&&z===ce)return;const ot=Pe[Re],Ie=Pe[z];Ot(ot,Ie,!0),lr(ot,Ie);return}const f=Ue-ze;let g=ze+l,b=Ue+l;if(l<0&&g<He?(g=He,b=Math.min(ct,g+f)):l>0&&b>ct&&(b=ct,g=Math.max(He,b-f)),g===ze&&b===Ue)return;const L=ue(q,g,m),I=ue(q,b,m);Ot(L,I,!0),lr(L,I)},Zn=i.useCallback(l=>{const f=Z.current;if(!(f.disabled||Pt()))if(Ht(),f.mode==="point"){const g=Math.max(P,Math.min(Y,ye+l));V||de([g,g]),yt(g,g,!0)}else if(f.mode==="vernier"){if(rt){const we=me.length-1,Re=be(me,Lt,E,m),z=be(me,Tt,E,m),ot=z-Re;let Ie=Re+l,Ae=z+l;l<0&&Ie<0?(Ie=0,Ae=Math.min(we,ot)):l>0&&Ae>we&&(Ae=we,Ie=Math.max(0,we-ot)),(Ie!==Re||Ae!==z)&&Qe(me[Ie],me[Ae],!0);return}const g=$e,b=Be,L=xe,I=Ce,O=b-g;let N=g+l,ce=b+l;l<0&&N<L?(N=L,ce=Math.min(I,N+O)):l>0&&ce>I&&(ce=I,N=Math.max(L,ce-O)),(N!==g||ce!==b)&&Qe(ue(E,N,m),ue(E,ce,m),!0)}else{const g=Me-ye;let b=ye+l,L=Me+l;l<0&&b<P?(b=P,L=Math.min(Y,b+g)):l>0&&L>Y&&(L=Y,b=Math.max(P,L-g)),b<=L&&(V||de([b,L]),yt(b,L,!0))}},[ye,Me,P,Y,V,yt,Qe,$e,Be,xe,Ce,E,rt,me,Lt,Tt,Ht,m]),ua=l=>!s&&lo(Lr.current,l),da=(l,f)=>{const g=Oo.current,b=Ke.current,L=Lr.current;if(s||g===null||b===null||L===null||!ps(g,L,Yo.current,u,l,f))return null;const I=b.getBoundingClientRect();return Math.abs(u?l-(I.left+I.width/2):f-(I.top+I.height/2))},ma=l=>{if(s||Pt())return;const f=ci(l.deltaX,l.deltaY,u);if(f===0)return;l.preventDefault();const g=l.target,b=lo(Ho.current,g)||lo(_o.current,g);if(!w||b){Zn(f);return}const L=Ke.current;if(!L)return;const I=L.getBoundingClientRect(),O=u?l.clientX-(I.left+I.width/2):l.clientY-(I.top+I.height/2);if(yo(O,J)==="macro"){Hi(f);return}Zn(f)},nn=i.useRef({ownsWheelHit:ua,distanceToRailPx:da,stepFromRangeAreaWheel:ma});i.useLayoutEffect(()=>{nn.current={ownsWheelHit:ua,distanceToRailPx:da,stepFromRangeAreaWheel:ma}});const Ar=i.useRef(null);i.useEffect(()=>{const l=Lr.current?.ownerDocument.defaultView??null,f=Ar.current;if(f!==null&&f.view===l)return;if(f?.unregister(),l===null){Ar.current=null;return}const g=Ms(l,{ownsHit:b=>nn.current.ownsWheelHit(b),distanceToRailPx:(b,L)=>nn.current.distanceToRailPx(b,L),step:b=>nn.current.stepFromRangeAreaWheel(b)});Ar.current={view:l,unregister:g}}),i.useEffect(()=>()=>{Ar.current?.unregister(),Ar.current=null},[]);const on=Yt(ye),an=Yt(Me),Qn=B(ye),Jn=B(Me),eo=Na(on,an,Bn),Er=eo.slant,Cr=H==="low"||H!=="high"&&Te==="low",$r=!k&&(H==="high"||H!=="low"&&Te==="high"),_i=zn&&Ve!=="macro-low",Fi=zn&&Ve==="macro-low",ji=Un&&Ve!=="micro-low",zi=Un&&Ve==="micro-low",cr=go("macro",nt,ut,Wn),ur=go("micro",er,Sr,Gn),Ui=Math.min(on,an),Bi=Math.max(on,an),[fa,ga]=zr.flat,[Wi,Gi]=zr.macro,[Xi,Ki]=zr.micro,ha=$t(fa,on),ba=$t(ga,an),to=$t(fa,Ui),wa=`calc(${$t(ga,Bi)} - ${to})`,dr=$t(Wi,nt*100),sn=$t(Gi,ut*100),mr=$t(Xi,er*100),ln=$t(Ki,Sr*100),qi=u?{bottom:to,height:wa,top:"auto",left:"0",right:"0"}:{left:to,width:wa,top:"0",bottom:"0"},Zi=Math.max(.01,ut-nt),pa=Math.max(.06,Math.min(.25,.28*Math.sqrt(Zi))),Qi=u?{bottom:ha,left:"50%",transform:"translate(-50%, 50%)",zIndex:Cr?40:30}:{left:ha,top:"50%",transform:"translate(-50%, -50%)",zIndex:Cr?40:30},Ji=u?{bottom:ba,left:"50%",transform:"translate(-50%, 50%)",zIndex:$r?40:30}:{left:ba,top:"50%",transform:"translate(-50%, -50%)",zIndex:$r?40:30},es=u?{bottom:`${xt}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${xt}%`,top:"50%",transform:"translate(-50%, -50%)"},Da=je!==null?B(je):null,ts=h!=="hover"&&je!==null&&(je===ye||!k&&je===Me),rs=rt?ne(E,me[0],m):xe,ns=rt?ne(E,me[me.length-1],m):Ce,os=w?$e>rs:ye>P,as=w?Be<ns:Me<Y,cn=Ys(w?[{side:C?"before":"after",box:pn(zo,Uo),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:cr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:cr.slant.lowOffsetX}},{side:C?"after":"before",box:y?Fn:pn(Fn,Bo),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:ur.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:ur.slant.lowOffsetX}}]:[{side:u||D==="top"?"before":"after",box:k?nr:pn(nr,jo),...u?{reach:"inline-size"}:{reach:"rotated",angleDeg:Er.lowAngleDeg,centreOffsetPx:Er.lowOffsetY,alongPushPx:Er.lowOffsetX}}]),is=cn===void 0?e.style:{...e.style,...cn.style};i.useLayoutEffect(()=>{Yo.current=cn===void 0?0:cn.mainPx});const mt=y?"micro-point":"micro-low",_t=s?"cursor-not-allowed opacity-50":"cursor-pointer",Ma=l=>{const f=u?"vertical":"horizontal",g=l==="decrease",b=u?!g:g;return x.jsx(qt,{ref:g?Ho:_o,neighbour:"rail",direction:Hs[f][l],disabled:s,canStep:g?os:as,onStep:()=>Zn(g?-1:1),ariaLabel:g?X:_,className:`period-slider-stepper-btn ${_s[f][l]} ${Oa[f][b?"leading":"trailing"]}`})};return x.jsxs("div",{ref:Lr,style:is,className:`period-slider grid select-none place-items-center ${Fs[u?"vertical":"horizontal"][d?"withSteppers":"railOnly"]} ${c}`,"data-disabled":s?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":u?"vertical":"horizontal","data-label-position":D,"data-color-scheme":G,children:[x.jsx("div",{ref:Oo,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),d&&Ma(u?"increase":"decrease"),x.jsx("div",{ref:Ke,"data-testid":"period-slider-track","data-orientation":u?"vertical":"horizontal","data-vernier-orientation":w?J:void 0,className:`period-slider-track relative touch-none rounded-full ${Oa[u?"vertical":"horizontal"][d?"rail":"railOnly"]} ${_t}`,onPointerDown:Vi,onPointerMove:Oi,onPointerLeave:Yi,children:w?x.jsxs(x.Fragment,{children:[vr&&(u?x.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:[x.jsx("defs",{children:x.jsxs("linearGradient",{id:W,x1:"0",y1:"0",x2:"1",y2:"0",children:[x.jsx("stop",{offset:"0%",stopColor:C?ae.macro:ae.micro,stopOpacity:"0.28"}),x.jsx("stop",{offset:"100%",stopColor:C?ae.micro:ae.macro,stopOpacity:pa})]})}),x.jsx("path",{ref:Hn,"data-testid":"period-slider-vernier-projection",d:so(nt,ut,u,C),fill:`url(#${W})`})]}):x.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[x.jsx("defs",{children:x.jsxs("linearGradient",{id:W,x1:"0",y1:"0",x2:"0",y2:"1",children:[x.jsx("stop",{offset:"0%",stopColor:C?ae.macro:ae.micro,stopOpacity:"0.28"}),x.jsx("stop",{offset:"100%",stopColor:C?ae.micro:ae.macro,stopOpacity:pa})]})}),x.jsx("path",{ref:Hn,"data-testid":"period-slider-vernier-projection",d:so(nt,ut,u,C),fill:`url(#${W})`})]})),!M&&x.jsxs(x.Fragment,{children:[x.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:u?{bottom:`calc(${dr} - 8px)`,height:`calc(${sn} - ${dr} + 16px)`}:{left:`calc(${dr} - 8px)`,width:`calc(${sn} - ${dr} + 16px)`},onPointerDown:sr("macro-connect")}),!y&&x.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:u?{bottom:`calc(${mr} - 8px)`,height:`calc(${ln} - ${mr} + 16px)`}:{left:`calc(${mr} - 8px)`,width:`calc(${ln} - ${mr} + 16px)`},onPointerDown:sr("micro-connect")})]}),Nt&&x.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(l=>x.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:u?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`macro-tick-${l}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(l=>x.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:u?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`micro-tick-${l}`))]}),x.jsxs("div",{tabIndex:s?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":s?"true":void 0,"aria-valuemin":He,"aria-valuemax":Ue,"aria-valuenow":ze,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(bt,q):Ut(q,bt,Wr,F),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?C?"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":C?"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 ${_t}`,style:u?{bottom:dr,left:C?0:"auto",right:C?"auto":0,transform:C?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Xe==="macro-low"||Ve==="macro-low"?30:15}:{left:dr,top:C?0:"auto",bottom:C?"auto":0,transform:C?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Xe==="macro-low"||Ve==="macro-low"?30:15},onPointerDown:sr("macro-low"),onKeyDown:rn("macro-low"),onFocus:tn("macro-low"),"data-active":Xe==="macro-low"?"true":void 0,"data-front":Ve==="macro-low"?"true":void 0,"data-vernier-pos":u?C?"left":"right":C?"top":"bottom","data-handle-type":"macro-low",children:[x.jsx(jr,{type:"macro",isTop:C,isVertical:u,isLeft:C}),Ze&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&x.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":_i?"true":void 0,"data-slanted":cr.slant.isSlanted?"true":void 0,ref:Ti,style:cr.lowStyle,children:Fe(q,bt,Wr,F)})]}),x.jsxs("div",{tabIndex:s?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":s?"true":void 0,"aria-valuemin":ze,"aria-valuemax":ct,"aria-valuenow":Ue,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Vt,q):Ut(q,Vt,Wr,F),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?C?"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":C?"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 ${_t}`,style:u?{bottom:sn,left:C?0:"auto",right:C?"auto":0,transform:C?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Xe==="macro-high"||Ve==="macro-high"?30:15}:{left:sn,top:C?0:"auto",bottom:C?"auto":0,transform:C?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Xe==="macro-high"||Ve==="macro-high"?30:15},onPointerDown:sr("macro-high"),onKeyDown:rn("macro-high"),onFocus:tn("macro-high"),"data-active":Xe==="macro-high"?"true":void 0,"data-front":Ve==="macro-high"?"true":void 0,"data-vernier-pos":u?C?"left":"right":C?"top":"bottom","data-handle-type":"macro-high",children:[x.jsx(jr,{type:"macro",isTop:C,isVertical:u,isLeft:C}),Ze&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&x.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":Fi?"true":void 0,"data-slanted":cr.slant.isSlanted?"true":void 0,ref:yi,style:cr.highStyle,children:Fe(q,Vt,Wr,F)})]}),x.jsxs("div",{tabIndex:s?-1:0,role:"slider","aria-label":y?e.pointAriaLabel??"Micro selected date":e.lowerAriaLabel??"Micro range start","aria-disabled":s?"true":void 0,"aria-valuemin":xe,"aria-valuemax":y?Ce:Be,"aria-valuenow":$e,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Lt,E):Ut(E,Lt,Gr,F),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?C?"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":C?"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 ${_t}`,style:u?{bottom:mr,left:C?"auto":0,right:C?0:"auto",transform:C?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Xe===mt||Ve===mt?30:20}:{left:mr,top:C?"auto":0,bottom:C?0:"auto",transform:C?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Xe===mt||Ve===mt?30:20},onPointerDown:sr(mt),onKeyDown:rn(mt),onFocus:tn(mt),"data-active":Xe===mt?"true":void 0,"data-front":Ve===mt?"true":void 0,"data-vernier-pos":u?C?"right":"left":C?"bottom":"top","data-handle-type":mt,children:[x.jsx(jr,{type:"micro",isTop:!C,isVertical:u,isLeft:!C}),Ze&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&x.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":ji?"true":void 0,"data-slanted":ur.slant.isSlanted?"true":void 0,ref:Pi,style:ur.lowStyle,children:Fe(E,Lt,Gr,F)})]}),!y&&x.jsxs("div",{tabIndex:s?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":s?"true":void 0,"aria-valuemin":$e,"aria-valuemax":Ce,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Tt,E):Ut(E,Tt,Gr,F),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?C?"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":C?"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 ${_t}`,style:u?{bottom:ln,left:C?"auto":0,right:C?0:"auto",transform:C?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Xe==="micro-high"||Ve==="micro-high"?30:20}:{left:ln,top:C?"auto":0,bottom:C?0:"auto",transform:C?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Xe==="micro-high"||Ve==="micro-high"?30:20},onPointerDown:sr("micro-high"),onKeyDown:rn("micro-high"),onFocus:tn("micro-high"),"data-active":Xe==="micro-high"?"true":void 0,"data-front":Ve==="micro-high"?"true":void 0,"data-vernier-pos":u?C?"right":"left":C?"bottom":"top","data-handle-type":"micro-high",children:[x.jsx(jr,{type:"micro",isTop:!C,isVertical:u,isLeft:!C}),Ze&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&x.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":zi?"true":void 0,"data-slanted":ur.slant.isSlanted?"true":void 0,ref:Ai,style:ur.highStyle,children:Fe(E,Tt,Gr,F)})]})]}):x.jsxs(x.Fragment,{children:[!M&&x.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:qi,onPointerDown:Ni}),R&&j&&v.length>1&&x.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:v.map((l,f)=>{const g=ne(t,l,m),b=Yt(f),L=u?{bottom:`${b}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${b}%`,top:"50%",transform:"translate(-50%, -50%)"};return x.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:L},`tick-${g}`)})}),!s&&je!==null&&xt!==null&&H===null&&Da&&x.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:es,children:[x.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"}),x.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":ts?"true":void 0,className:`period-slider-hover-tooltip ${D==="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:Fe(t,Da,e.formatLabel,F)})]}),x.jsxs("div",{tabIndex:s?-1:0,role:"slider","aria-label":k?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":s?"true":void 0,"aria-valuemin":P,"aria-valuemax":k?Y:Me,"aria-valuenow":ye,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Qn,t):Ut(t,Qn,e.formatLabel,F),"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 ${_t}`,style:Qi,onPointerDown:sa("low"),onKeyDown:ca("low"),onFocus:la("low"),"data-active":H==="low"?"true":void 0,"data-front":Cr?"true":void 0,children:[x.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 ${H==="low"?"":"shadow-md"}`}),h!=="hover"&&x.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-label-position":D,"data-slanted":Er.isSlanted?"true":void 0,"data-front":Cr?"true":void 0,"data-duplicate":jn&&!Cr?"true":void 0,ref:Si,style:eo.lowStyle,children:Fe(t,Qn,e.formatLabel,F)})]}),!k&&x.jsxs("div",{tabIndex:s?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":s?"true":void 0,"aria-valuemin":ye,"aria-valuemax":Y,"aria-valuenow":Me,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Jn,t):Ut(t,Jn,e.formatLabel,F),"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 ${_t}`,style:Ji,onPointerDown:sa("high"),onKeyDown:ca("high"),onFocus:la("high"),"data-active":H==="high"?"true":void 0,"data-front":$r?"true":void 0,children:[x.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 ${H==="high"?"":"shadow-md"}`}),h!=="hover"&&x.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-label-position":D,"data-slanted":Er.isSlanted?"true":void 0,"data-front":$r?"true":void 0,"data-duplicate":jn&&!$r?"true":void 0,ref:Li,style:eo.highStyle,children:Fe(t,Jn,e.formatLabel,F)})]})]})}),d&&Ma(u?"decrease":"increase")]})},ho=(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},fi=(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},zs=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||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||!fi(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||!ho(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||!ho(e.macroAllowedDates,t.macroAllowedDates)||!ho(e.microAllowedDates,t.microAllowedDates)):!1,gi=i.memo(js,zs);gi.displayName="PeriodSlider";const hi=864e5,Us=4,Bs=6,Ha=2,Se=-1,Dn=e=>{const t=e.getFullYear(),r=new Date(Date.UTC(t,e.getMonth(),e.getDate()));return r.setUTCFullYear(t),Math.floor(r.getTime()/hi)},bi=e=>{const t=new Date(e*hi),r=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return r.setFullYear(t.getUTCFullYear()),r.setHours(0,0,0,0),r},Gt=e=>{const t=e.getFullYear();return`${t>=0?String(t).padStart(Us,"0"):`-${String(-t).padStart(Bs,"0")}`}-${String(e.getMonth()+1).padStart(Ha,"0")}-${String(e.getDate()).padStart(Ha,"0")}`},Ws=(e,t,r)=>{const n=Dn(e),o=Dn(t),a=o>=n?o-n+1:0,s=c=>bi(o-c);return{count:a,dateAt:s,valueAt:c=>Gt(s(c)),labelAt:c=>Fe("day",s(c),void 0,r),indexOf:c=>{const d=Dn(c);return d<n||d>o?Se:o-d}}},Gs=(e,t,r,n)=>{const o=r>=t?r-t+1:0,a=s=>e[r-s];return{count:o,dateAt:a,valueAt:s=>Gt(a(s)),labelAt:s=>Fe("day",a(s),void 0,n),indexOf:s=>{const c=s.getTime();let d=t,h=r;for(;d<=h;){const D=d+h>>1,S=e[D].getTime();if(S===c)return r-D;S<c?d=D+1:h=D-1}return Se}}},Xs={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:()=>Se},Ks=(e,t,r)=>{const n=c=>{let d=0,h=e.length;for(;d<h;){const D=d+h>>1;e[D].getTime()<c?d=D+1:h=D}return d},o=c=>{let d=0,h=e.length;for(;d<h;){const D=d+h>>1;e[D].getTime()<=c?d=D+1:h=D}return d},a=t===null?0:n(t.getTime()),s=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:s}},_a=(e,t,r,n,o)=>{let a=t,s=r,c=null;for(;a<=s;){const d=a+s>>1,h=e[d].getTime();o===-1?h<n?(c=e[d],a=d+1):s=d-1:h>n?(c=e[d],s=d-1):a=d+1}return c},qs=(e,t)=>{const r=new Map;return e.forEach((n,o)=>{t(o,n);const a=new Date(n);a.setHours(0,0,0,0);const s=a.getTime();r.has(s)||r.set(s,a)}),Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},Mn=44,Fa=7,gn=8,Zs=2,wi=10,Qs=1e3,xo=8,bo=6,wo=4,po=12,Hr=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),Dn(r)},Js=(e,t)=>{if(e.length<wo||t.count===0)return Se;const r=Number(e.slice(0,wo));if(!Number.isInteger(r))return Se;const n=e.length>=bo,o=n?Number(e.slice(wo,bo)):po;if(o<1||o>po)return Se;const a=e.length>=xo,s=a?Number(e.slice(bo,xo)):0,c=Hr(r,o),d=(o===po?Hr(r+1,1):Hr(r,o+1))-1,h=a?c+s-1:n?c:Hr(r,1),D=a?h:n?d:Hr(r+1,1)-1;if(a&&(s<1||h>d))return Se;for(let S=D;S>=h;S--){const u=t.indexOf(bi(S));if(u!==Se)return u}return Se},el=e=>e.closest(".dark")===null?"light":"dark",tl=(e,t,r,n)=>{const o=r-e.bottom-gn,a=e.top-gn,s=o>=t||o>=a,d=Math.max(Mn,Math.min(t,s?o:a)),h=s?e.bottom:e.top-d,D=e.width+wi,S=Math.max(gn,Math.min(e.left,n-D-gn));return{top:h,left:S,width:D,height:d}},pi=({domain:e,selectedIndex:t,displayLabel:r,machineValue:n,disabled:o,ariaLabel:a,onCommitIndex:s,controlClassName:c})=>{const d=i.useId(),h=`period-slider-date-listbox-${d}`,D=T=>`period-slider-date-option-${d}-${T}`,[S,u]=i.useState(!1),[M,R]=i.useState(Se),[G,F]=i.useState(!0),[X,_]=i.useState(null),[m,K]=i.useState(null),y=i.useRef(null),ae=i.useRef(null),W=i.useRef(null),Z=i.useRef({buffer:"",at:0}),oe=i.useRef(e);oe.current=e;const $=e.count,v=Math.min($,Fa)*Mn,j=Math.max(1,Math.min($,Fa)),P=i.useCallback(()=>{const T=y.current;if(T===null)return;const re=T.getBoundingClientRect();_(tl(re,v,window.innerHeight,window.innerWidth))},[v]),Y=i.useCallback(()=>{u(!1),R(Se),Z.current={buffer:"",at:0}},[]),k=i.useCallback(T=>{o||$===0||(R(T),u(!0))},[o,$]);i.useLayoutEffect(()=>{if(!S){_(null),K(null);return}const T=y.current;return T!==null&&K(el(T)),P(),window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}},[S,P]),i.useEffect(()=>{if(!S)return;const T=re=>{const fe=re.target;fe!==null&&ae.current?.contains(fe)!==!0&&y.current?.contains(fe)!==!0&&Y()};return document.addEventListener("pointerdown",T,!0),()=>document.removeEventListener("pointerdown",T,!0)},[S,Y]);const B=i.useRef(M);B.current=M,i.useEffect(()=>{if(!S)return;const T=B.current;T!==Se&&W.current?.scrollToIndex(Math.min(T,$-1),{align:"center"})},[$,S]);const ie=T=>{if($===0)return;const re=Math.max(0,Math.min(T,$-1));R(re),W.current?.scrollToIndex(re,{align:"center"})},le=T=>{T<0||T>=$||(s(T),Y(),y.current?.focus())},se=T=>{if(o)return;const re=M!==Se?M:t!==Se?t:0;switch(T.key){case"ArrowDown":if(T.preventDefault(),!S){k(re);return}ie(re+1);return;case"ArrowUp":if(T.preventDefault(),!S){k(re);return}ie(re-1);return;case"Home":if(!S)return;T.preventDefault(),ie(0);return;case"End":if(!S)return;T.preventDefault(),ie($-1);return;case"PageDown":if(!S)return;T.preventDefault(),ie(re+j);return;case"PageUp":if(!S)return;T.preventDefault(),ie(re-j);return;case"Enter":if(T.preventDefault(),!S){k(re);return}le(M!==Se?M:re);return;case"Escape":if(!S)return;T.preventDefault(),Y();return;case"Tab":S&&Y();return}if(T.key.length!==1)return;const fe=T.key>="0"&&T.key<="9",Le=T.key==="-"||T.key==="/"||T.key===".";if(!(fe||Le))return;T.preventDefault();const De=Date.now(),Ne=De-Z.current.at>Qs?"":Z.current.buffer,Ye=fe?`${Ne}${T.key}`.slice(0,xo):Ne;Z.current={buffer:Ye,at:De};const Ge=Js(Ye,oe.current);if(Ge!==Se){if(!S){k(Ge);return}ie(Ge)}},U=i.useCallback(T=>T,[]),te=i.useCallback(()=>Mn,[]),Q=i.useCallback(T=>{const re=B.current;F(re===Se||re>=T.renderingStartIndex&&re<=T.renderingEndIndex)},[]),ve=S&&X!==null&&m!==null&&$>0?x.jsx("div",{ref:ae,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":m,style:{top:X.top,left:X.left,width:X.width,height:X.height},onMouseDown:T=>{T.preventDefault()},children:x.jsx(ls.VirtualScroll,{ref:W,itemCount:$,getItem:U,getItemHeight:te,viewportSize:X.height-Zs,initialScrollIndex:M!==Se?M:void 0,onRangeChange:Q,className:"h-full w-full",testId:"period-slider-date-listbox-pane",contentProps:{id:h,role:"listbox","aria-label":a},scrollBarOptions:{width:wi,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:T=>{const re=T===t,fe=T===M;return x.jsx("div",{id:D(T),role:"option","aria-selected":re,"aria-posinset":T+1,"aria-setsize":$,"data-testid":"period-slider-date-option","data-active":fe?"true":void 0,className:"period-slider-date-option",style:{height:Mn},onClick:()=>le(T),children:oe.current.labelAt(T)})}})}):null;return x.jsxs(x.Fragment,{children:[x.jsx("input",{ref:y,type:"text",role:"combobox",readOnly:!0,"aria-label":a,"aria-expanded":S,"aria-controls":S?h:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":S&&M!==Se&&G?D(M):void 0,disabled:o,value:r,className:c,"data-testid":"period-slider-date-combobox","data-value":n,onKeyDown:se,onMouseDown:T=>{o||(T.preventDefault(),y.current?.focus(),S?Y():k(t!==Se?t:0))},onBlur:()=>{S&&Y()}}),ve===null?null:cs.createPortal(ve,document.body)]})};pi.displayName="VirtualDateDropdown";const Bt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},_r=(e,t)=>{if(Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},rl=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)})`)}},Xt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},ja=e=>Xt(e,1,1),nl=e=>Xt(e,12,31),ol={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},al={year:4,month:2,day:2},il={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},za=new Map,sl=(e,t)=>{const r=`${e}\0${t}`,n=za.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,ol[e]);return za.set(r,o),o},Do=(e,t,r)=>r===void 0?String(il[e](t)).padStart(al[e],"0"):sl(e,r).format(t),ll=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:s,minDate:c,maxDate:d,allowedDates:h,variant:D="date",className:S="",style:u,disabled:M=!1,prevDateAriaLabel:R="Previous day",nextDateAriaLabel:G="Next day",selectAriaLabel:F="Date",yearAriaLabel:X="Year",monthAriaLabel:_="Month",dayAriaLabel:m="Day",locale:K,formatYearOption:y,formatMonthOption:ae,formatDayOption:W}=e;if(rl(K),t!==void 0&&_r("value",t),r!==void 0&&_r("initialDate",r),c!==void 0&&_r("minDate",c),d!==void 0&&_r("maxDate",d),a!==void 0&&!Number.isInteger(a))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(a)})`);if(s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(s)})`);if(D==="split-dropdown"&&h!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const Z=t??r;if(Z===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[oe,$]=i.useState(()=>Bt(Z)),v=t!==void 0,j=t?.getTime(),P=i.useMemo(()=>t!==void 0?Bt(t):oe,[j,oe]),Y=c?.getTime(),k=d?.getTime(),B=i.useMemo(()=>{const w=c?Bt(c):null,J=a!==void 0?ja(a):null;return w===null?J:J===null||w.getTime()>=J.getTime()?w:J},[Y,a]),ie=i.useMemo(()=>{const w=d?Bt(d):null,J=s!==void 0?nl(s):null;return w===null?J:J===null||w.getTime()<=J.getTime()?w:J},[k,s]),le=B?.getTime()??null,se=ie?.getTime()??null;if(B!==null&&ie!==null&&B.getTime()>ie.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Gt(B)} is after max ${Gt(ie)})`);if(D!=="date"&&h===void 0&&(B===null||ie===null))throw new RangeError(`DateSelector: variant="${D}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${D==="dropdown"?' or supply "allowedDates"':""}`);const U=h===void 0?null:h.map(w=>w.getTime()).join(","),te=i.useMemo(()=>h===void 0?null:qs(h,(w,J)=>_r(`allowedDates[${w}]`,J)),[U]),Q=i.useMemo(()=>te===null?null:{ascending:te,...Ks(te,B,ie)},[te,le,se]),ve=i.useMemo(()=>Q!==null?Gs(Q.ascending,Q.loIndex,Q.hiIndex,K):B===null||ie===null?Xs:Ws(B,ie,K),[Q,le,se,K]),T=w=>{if(Q!==null)return ve.indexOf(w)!==Se;const J=w.getTime();return!(le!==null&&J<le||se!==null&&J>se)},re=Z.getTime();i.useEffect(()=>{v||$(Bt(Z))},[v,re]);const fe=w=>{if(M)return;const J=Bt(w);T(J)&&(v||$(J),n?.(J))},Le=P.getTime(),De=T(P),Ne=i.useMemo(()=>{if(Q!==null)return _a(Q.ascending,Q.loIndex,Q.hiIndex,Le,-1);const w=at.addDays(new Date(Le),-1);return T(w)?w:null},[Q,Le,le,se]),Ye=i.useMemo(()=>{if(Q!==null)return _a(Q.ascending,Q.loIndex,Q.hiIndex,Le,1);const w=at.addDays(new Date(Le),1);return T(w)?w:null},[Q,Le,le,se]),Ge=()=>{Ne!==null&&fe(Ne)},st=()=>{Ye!==null&&fe(Ye)},lt=w=>{if(w.target.value){const J=at.parseISO(w.target.value);Number.isNaN(J.getTime())||fe(J)}},V=P.getFullYear(),ee=P.getMonth()+1,de=P.getDate(),p=i.useMemo(()=>{if(D!=="split-dropdown"||B===null||ie===null)return[];const w=[];for(let J=ie.getFullYear();J>=B.getFullYear();J--)w.push(J);return w},[D,le,se]),A=i.useMemo(()=>{if(D!=="split-dropdown"||B===null||ie===null)return[];const w=B,J=ie,C=V===w.getFullYear()?w.getMonth()+1:1,vr=V===J.getFullYear()?J.getMonth()+1:12,Nt=[];for(let Ze=C;Ze<=vr;Ze++)Nt.push(Ze);return Nt},[D,le,se,V]),H=i.useMemo(()=>{if(D!=="split-dropdown"||B===null||ie===null)return[];const w=B,J=ie,C=V===w.getFullYear()&&ee===w.getMonth()+1?w.getDate():1,vr=V===J.getFullYear()&&ee===J.getMonth()+1?J.getDate():at.getDaysInMonth(new Date(Le)),Nt=[];for(let Ze=C;Ze<=vr;Ze++)Nt.push(Ze);return Nt},[D,le,se,Le,V,ee]),he=(w,J,C)=>C>at.getDaysInMonth(Xt(w,J,1))?!1:T(Xt(w,J,C)),ge=(w,J,C)=>{he(w,J,C)&&fe(Xt(w,J,C))},Te=w=>y?y(w):Do("year",ja(w),K),Ee=w=>ae?ae(w):Do("month",Xt(V,w,1),K),je=w=>W?W(w):Do("day",Xt(V,ee,w),K),tt=Gt(P),xt=Fe("day",P,void 0,K),kt=B?Gt(B):void 0,ye=ie?Gt(ie):void 0,Me="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 x.jsxs("div",{className:`inline-flex items-center ${Br} ${S}`,style:u,"data-variant":D,"data-out-of-range":De?void 0:"true",children:[x.jsx(qt,{neighbour:"control",direction:"left",disabled:M,canStep:Ne!==null,onStep:Ge,ariaLabel:R}),D==="dropdown"?x.jsx(pi,{domain:ve,selectedIndex:De?ve.indexOf(P):Se,displayLabel:xt,machineValue:tt,disabled:M,ariaLabel:F,onCommitIndex:w=>fe(ve.dateAt(w)),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"}):D==="split-dropdown"?x.jsxs("div",{className:"inline-flex items-center gap-1",children:[x.jsxs("select",{"aria-label":X,disabled:M,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:De?V:"",onChange:w=>ge(Number(w.target.value),ee,de),children:[De?null:x.jsx("option",{value:"",disabled:!0,className:Me,children:Te(V)}),p.map(w=>x.jsx("option",{value:w,disabled:!he(w,ee,de),className:"dark:bg-slate-700 dark:text-slate-100",children:Te(w)},w))]}),x.jsxs("select",{"aria-label":_,disabled:M,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:De?ee:"",onChange:w=>ge(V,Number(w.target.value),de),children:[De?null:x.jsx("option",{value:"",disabled:!0,className:Me,children:Ee(ee)}),A.map(w=>x.jsx("option",{value:w,disabled:!he(V,w,de),className:"dark:bg-slate-700 dark:text-slate-100",children:Ee(w)},w))]}),x.jsxs("select",{"aria-label":m,disabled:M,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:De?de:"",onChange:w=>ge(V,ee,Number(w.target.value)),children:[De?null:x.jsx("option",{value:"",disabled:!0,className:Me,children:je(de)}),H.map(w=>x.jsx("option",{value:w,className:"dark:bg-slate-700 dark:text-slate-100",children:je(w)},w))]})]}):x.jsx("input",{"aria-label":F,disabled:M,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:tt,min:kt,max:ye,onChange:lt,type:"date"}),x.jsx(qt,{neighbour:"control",direction:"right",disabled:M,canStep:Ye!==null,onStep:st,ariaLabel:G}),o]})},wr=e=>e===void 0?null:Bt(e).getTime(),Di=i.memo(ll,(e,t)=>!(wr(e.value??e.initialDate)!==wr(t.value??t.initialDate)||wr(e.minDate)!==wr(t.minDate)||wr(e.maxDate)!==wr(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));Di.displayName="DateSelector";function et(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 Wt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function Fr(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 Ua(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function cl(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 ul(e,t){const r=e===void 0?null:et(e,0),n=t===void 0?null:et(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function dl(e,t){const r=e===void 0?null:et(e,11),n=t===void 0?null:et(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function ml(e,t,r){const n=new Map;for(const o of e){const a=et(o.getFullYear(),o.getMonth());t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function fl(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),o=[];for(let a=r;a<=n;a++)o.push(et(Math.floor(a/12),a%12));return o}function Ba(e,t){const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Fe("month",e[n],void 0,t),value:Wt(e[n])});return r}const gl=e=>{const{value:t,initialDate:r,onChange:n,children:o,variant:a="date",minYear:s,maxYear:c,minDate:d,maxDate:h,allowedMonths:D,isWarning:S=!1,className:u="",style:M,disabled:R=!1,prevMonthAriaLabel:G="Previous month",nextMonthAriaLabel:F="Next month",selectAriaLabel:X="Month",locale:_}=e;cl(_),Fr(t,"value"),Fr(r,"initialDate"),Fr(d,"minDate"),Fr(h,"maxDate"),Ua(s,"minYear"),Ua(c,"maxYear"),D?.forEach((p,A)=>{Fr(p,`allowedMonths[${A}]`)});const m=t??r;if(m===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[K,y]=i.useState(()=>et(m.getFullYear(),m.getMonth())),ae=t!==void 0,W=i.useMemo(()=>t!==void 0?et(t.getFullYear(),t.getMonth()):K,[t?.getTime(),K]),Z=d?.getTime(),oe=h?.getTime(),$=i.useMemo(()=>ul(s,d),[s,Z]),v=i.useMemo(()=>dl(c,h),[c,oe]),j=$?.getTime()??null,P=v?.getTime()??null;if($!==null&&v!==null&&$>v)throw new RangeError(`MonthSelector: the resolved lower bound ${Wt($)} is after the resolved upper bound ${Wt(v)}.`);if(a==="dropdown"&&D===void 0&&($===null||v===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 Y=D===void 0?null:D.map(p=>p.getTime()).join(","),k=i.useMemo(()=>D===void 0?null:ml(D,$,v),[Y,j,P]),B=p=>{const A=p.getTime();return k!==null?k.some(H=>H.getTime()===A):!(j!==null&&A<j||P!==null&&A>P)},ie=m.getTime();i.useEffect(()=>{if(ae)return;const p=et(m.getFullYear(),m.getMonth());y(A=>A.getTime()===p.getTime()?A:p)},[ae,ie]);const le=p=>{if(R)return;if(!B(p))throw new RangeError(`MonthSelector: refusing to emit ${Wt(p)}, which lies outside the selectable months.`);ae||y(p);const A=p.getFullYear()*100+(p.getMonth()+1);n?.(p,A)},se=W.getTime(),U=B(W),te=i.useMemo(()=>{if(k!==null){for(let A=k.length-1;A>=0;A--)if(k[A].getTime()<se)return k[A];return null}const p=et(W.getFullYear(),W.getMonth()-1);return B(p)?p:null},[k,se,j,P]),Q=i.useMemo(()=>{if(k!==null){for(const A of k)if(A.getTime()>se)return A;return null}const p=et(W.getFullYear(),W.getMonth()+1);return B(p)?p:null},[k,se,j,P]),ve=()=>{te!==null&&le(te)},T=()=>{Q!==null&&le(Q)},re=p=>{if(!p)return;const[A,H]=p.split("-"),he=Number(A),ge=Number(H)-1;if(!(Number.isInteger(he)&&Number.isInteger(ge)))return;const Te=et(he,ge);B(Te)&&le(Te)},fe=p=>{re(p.target.value)},Le=p=>{re(p.target.value)},De=Wt(W),Ne=Fe("month",W,void 0,_),Ye=$?Wt($):void 0,Ge=v?Wt(v):void 0,st=i.useMemo(()=>a!=="dropdown"?[]:k!==null?Ba(k,_):$===null||v===null?[]:Ba(fl($,v),_),[a,k,j,P,_]),lt=U?De:"",V=S?"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",ee=`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 ${V}`,de=`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 ${V}`;return x.jsxs("div",{className:`inline-flex items-center ${Br} ${u}`,style:M,"data-out-of-range":U?void 0:"true",children:[x.jsx(qt,{neighbour:"control",direction:"left",disabled:R,canStep:te!==null,onStep:ve,ariaLabel:G}),a==="dropdown"?x.jsxs("select",{"aria-label":X,disabled:R,className:de,value:lt,onChange:Le,children:[U?null:x.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:Ne}),st.map(p=>x.jsx("option",{value:p.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:p.label},p.value))]}):x.jsx("input",{"aria-label":X,disabled:R,className:ee,value:De,min:Ye,max:Ge,onChange:fe,type:"month"}),x.jsx(qt,{neighbour:"control",direction:"right",disabled:R,canStep:Q!==null,onStep:T,ariaLabel:F}),o]})},Mi=i.memo(gl,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,a=n?n.getFullYear()*12+n.getMonth():null;if(o!==a||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 s=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,c=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(s!==c)return!1;const d=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,h=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(d!==h||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)});Mi.displayName="MonthSelector";function Dr(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 En(e,t,r){if(Dr(e,"minDate",t),Dr(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 Rn(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(Dr(e,`${t}[0]`,r[0]),Dr(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 Sn(e,t,r,n,o,a,s,c){const d=ne(r,n,c);if(d<ne(r,o,c)||d>ne(r,a,c))throw new RangeError(`${e}: ${t} must lie within ${s} (value: ${n.toISOString()}, lower: ${o.toISOString()}, upper: ${a.toISOString()})`)}function Ln(e,t,r,n,o,a,s,c){Sn(e,`${t}[0]`,r,n[0],o,a,s,c),Sn(e,`${t}[1]`,r,n[1],o,a,s,c)}function We(e,t,r){return e<t?t:e>r?r:e}function Tn(e,t,r,n,o,a,s){if(r!==!0)return[];const c=e[0].getTime(),d=e[1].getTime();return vt(n,t,o,a,s).filter(h=>h.getTime()>=c&&h.getTime()<=d)}function pr(e,t,r,n,o){if(n.length===0)return We(e,r[0],r[1]);const a=n[be(n,e,t,o)];return a.getTime()===e.getTime()?e:a}function hn(e,t,r,n,o){const a=pr(e[0],t,r,n,o),s=pr(e[1],t,r,n,o);return[a,s<a?a:s]}function yn(e,t,r,n,o){const a=be(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function Cn(e){const t=i.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(c=>Object.is(r[c],n[c]))||(t.current=e),t.current}function hl(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:s,...c}=e,d=Mr("usePeriodSliderRange",s);En("usePeriodSliderRange",r,n),Rn("usePeriodSliderRange","initialRange",o),Ln("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",d);const h=Cn(c),D=i.useRef(o),[S,u]=i.useState(o);let M=S;const R=[We(S[0],r,n),We(S[1],r,n)];(R[0]!==S[0]||R[1]!==S[1])&&(M=R,u(R));const G=i.useRef(M);G.current=M;const F=i.useRef({minDate:r,maxDate:n,allowedDates:h.allowedDates});F.current={minDate:r,maxDate:n,allowedDates:h.allowedDates};const X=i.useRef(a);X.current=a;const _=i.useCallback(v=>{const{minDate:j,maxDate:P}=F.current,Y=We(v[0],j,P),k=We(v[1],j,P),B=G.current;Y.getTime()===B[0].getTime()&&k.getTime()===B[1].getTime()||(G.current=[Y,k],u([Y,k]),X.current?.(Y,k))},[]),m=i.useCallback(v=>{const j=G.current,P=v.getTime()>j[1].getTime()?v:j[1];_([v,P])},[_]),K=i.useCallback(v=>{const j=G.current,P=v.getTime()<j[0].getTime()?v:j[0];_([P,v])},[_]),y=i.useCallback((v,j)=>{_([v,j])},[_]),ae=i.useCallback(v=>{const{minDate:j,maxDate:P,allowedDates:Y}=F.current,k=G.current,B=vt(Y,t,j,P,d);if(B.length>0){_([yn(B,t,k[0],v,d),yn(B,t,k[1],v,d)]);return}_([Oe(t,k[0],v),Oe(t,k[1],v)])},[t,_,d]),W=i.useCallback(()=>{_(D.current)},[_]),Z=i.useMemo(()=>({value:M[0],onChange:m,minDate:r,maxDate:M[1],unit:t,yearStartMonth:d}),[M[0],M[1],m,r,t,d]),oe=i.useMemo(()=>({value:M[1],onChange:K,minDate:M[0],maxDate:n,unit:t,yearStartMonth:d}),[M[0],M[1],K,n,t,d]),$=i.useMemo(()=>({...h,mode:"range",unit:t,yearStartMonth:d,range:M,minDate:r,maxDate:n,onChangeRange:y}),[h,t,M,r,n,y,d]);return{range:M,lowerDate:M[0],upperDate:M[1],setRange:u,setLowerDate:m,setUpperDate:K,shiftRange:ae,resetRange:W,startSelectorProps:Z,endSelectorProps:oe,sliderProps:$}}function bl(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:s,...c}=e,d=Mr("usePeriodSliderPoint",s);En("usePeriodSliderPoint",r,n),Dr("usePeriodSliderPoint","initialValue",o),Sn("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",d);const h=Cn(c),D=i.useRef(o),[S,u]=i.useState(o);let M=S;const R=We(S,r,n);R!==S&&(M=R,u(R));const G=i.useRef(M);G.current=M;const F=i.useRef({minDate:r,maxDate:n,allowedDates:h.allowedDates});F.current={minDate:r,maxDate:n,allowedDates:h.allowedDates};const X=i.useRef(a);X.current=a;const _=i.useCallback(W=>{const{minDate:Z,maxDate:oe}=F.current,$=We(W,Z,oe);$.getTime()!==G.current.getTime()&&(G.current=$,u($),X.current?.($))},[]),m=i.useCallback(W=>{const{minDate:Z,maxDate:oe,allowedDates:$}=F.current,v=vt($,t,Z,oe,d);if(v.length>0){_(yn(v,t,G.current,W,d));return}_(Oe(t,G.current,W))},[t,_,d]),K=i.useCallback(()=>{_(D.current)},[_]),y=i.useMemo(()=>({value:M,onChange:_,minDate:r,maxDate:n,unit:t,yearStartMonth:d}),[M,_,r,n,t,d]),ae=i.useMemo(()=>({...h,mode:"point",unit:t,yearStartMonth:d,value:M,minDate:r,maxDate:n,onChangePoint:_}),[h,t,M,r,n,_,d]);return{value:M,setValue:u,shiftValue:m,resetValue:K,selectorProps:y,sliderProps:ae}}function wl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:s=t,microUnit:c=t,onChangeMacroRange:d,onChangeMicroRange:h,yearStartMonth:D,...S}=e,u=Mr("useVernierSliderRange",D);En("useVernierSliderRange",r,n),Rn("useVernierSliderRange","initialMacroRange",o),Rn("useVernierSliderRange","initialMicroRange",a),Ln("useVernierSliderRange","initialMacroRange",s,o,r,n,"[minDate, maxDate]",u);const M=ht(s,c,o,r,n,u);Ln("useVernierSliderRange","initialMicroRange",c,a,M[0],M[1],"the initial macro window",u);const R=Cn(S),G=i.useRef(o),F=i.useRef(a),[X,_]=i.useState(o),[m,K]=i.useState(a);let y=X;const ae=[We(X[0],r,n),We(X[1],r,n)];(ae[0]!==X[0]||ae[1]!==X[1])&&(y=ae,_(ae));const W=i.useMemo(()=>ht(s,c,y,r,n,u),[s,c,y,r,n,u]),Z=i.useMemo(()=>Tn(W,c,R.microIsDiscrete,R.microAllowedDates??R.allowedDates,r,n,u),[W,c,R.microIsDiscrete,R.microAllowedDates,R.allowedDates,r,n,u]),oe=i.useMemo(()=>R.macroIsDiscrete===!0?vt(R.macroAllowedDates??R.allowedDates,s,r,n,u):[],[R.macroIsDiscrete,R.macroAllowedDates,R.allowedDates,s,r,n,u]),$=i.useRef(oe);$.current=oe;let v=m;const j=hn(m,c,W,Z,u);(j[0]!==m[0]||j[1]!==m[1])&&(v=j,K(j));const P=i.useRef(y);P.current=y;const Y=i.useRef(v);Y.current=v;const k=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates});k.current={minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates};const B=i.useRef(d);B.current=d;const ie=i.useRef(h);ie.current=h;const le=i.useCallback(p=>{const{minDate:A,maxDate:H}=k.current;return ht(s,c,p,A,H,u)},[s,c,u]),se=i.useCallback(p=>{const{microIsDiscrete:A,microAllowedDates:H,allowedDates:he,minDate:ge,maxDate:Te}=k.current;return Tn(p,c,A,H??he,ge,Te,u)},[c,u]),U=i.useCallback((p,A)=>{const H=P.current,he=Y.current;(p[0].getTime()!==H[0].getTime()||p[1].getTime()!==H[1].getTime())&&(P.current=p,_(p),B.current?.(p[0],p[1])),(A[0].getTime()!==he[0].getTime()||A[1].getTime()!==he[1].getTime())&&(Y.current=A,K(A),ie.current?.(A[0],A[1]))},[]),te=i.useCallback((p,A)=>{const{minDate:H,maxDate:he}=k.current,ge=[We(p,H,he),We(A,H,he)],Te=le(ge);U(ge,hn(Y.current,c,Te,se(Te),u))},[c,le,se,U,u]),Q=i.useCallback((p,A)=>{const H=le(P.current);U(P.current,hn([p,A],c,H,se(H),u))},[c,le,se,U,u]),ve=i.useCallback(p=>{const A=P.current[1],H=p>A?p:A;te(p,H)},[te]),T=i.useCallback(p=>{const A=P.current[0],H=p<A?p:A;te(H,p)},[te]),re=i.useCallback(p=>{const A=Y.current[1],H=p>A?p:A;Q(p,H)},[Q]),fe=i.useCallback(p=>{const A=Y.current[0],H=p<A?p:A;Q(H,p)},[Q]),Le=i.useCallback(p=>{const{minDate:A,maxDate:H}=k.current,he=P.current,ge=$.current;if(ge.length>0){const je=be(ge,he[0],s,u)+p,tt=be(ge,he[1],s,u)+p;if(je<0||tt>ge.length-1)return;te(ge[je],ge[tt]);return}const Te=Oe(s,he[0],p),Ee=Oe(s,he[1],p);Te<A||Ee>H||te(Te,Ee)},[s,te,u]),De=i.useCallback(p=>{const A=P.current,H=Y.current,he=le(A),[ge,Te]=he,Ee=se(he);if(Ee.length>0){const xt=be(Ee,H[0],c,u)+p,kt=be(Ee,H[1],c,u)+p;if(xt<0||kt>Ee.length-1)return;Q(Ee[xt],Ee[kt]);return}const je=Oe(c,H[0],p),tt=Oe(c,H[1],p);je<ge||tt>Te||Q(je,tt)},[c,le,se,Q,u]),Ne=i.useCallback(()=>{const p=G.current,A=le(p);U(p,hn(F.current,c,A,se(A),u))},[c,le,se,U,u]),[Ye,Ge]=W,st=i.useMemo(()=>({value:y[0],onChange:ve,minDate:r,maxDate:y[1],unit:s,yearStartMonth:u}),[y,ve,r,s,u]),lt=i.useMemo(()=>({value:y[1],onChange:T,minDate:y[0],maxDate:n,unit:s,yearStartMonth:u}),[y,T,n,s,u]),V=i.useMemo(()=>({value:v[0],onChange:re,minDate:Ye,maxDate:v[1],unit:c,yearStartMonth:u}),[v,re,Ye,c,u]),ee=i.useMemo(()=>({value:v[1],onChange:fe,minDate:v[0],maxDate:Ge,unit:c,yearStartMonth:u}),[v,fe,Ge,c,u]),de=i.useMemo(()=>({...R,mode:"vernier",unit:t,yearStartMonth:u,macroUnit:s,microUnit:c,minDate:r,maxDate:n,macroRange:y,microRange:v,onChangeMacroRange:te,onChangeMicroRange:Q}),[R,t,s,c,r,n,y,v,te,Q,u]);return{macroRange:y,setMacroRange:_,microRange:v,setMicroRange:K,setMacroLowerDate:ve,setMacroUpperDate:T,setMicroLowerDate:re,setMicroUpperDate:fe,shiftMacroRange:Le,shiftMicroRange:De,resetVernier:Ne,macroStartSelectorProps:st,macroEndSelectorProps:lt,microStartSelectorProps:V,microEndSelectorProps:ee,sliderProps:de}}function pl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:s=t,microUnit:c=t,onChangeMacroRange:d,onChangeMicroPoint:h,yearStartMonth:D,...S}=e,u=Mr("useVernierSliderPoint",D);En("useVernierSliderPoint",r,n),Rn("useVernierSliderPoint","initialMacroRange",o),Dr("useVernierSliderPoint","initialMicroValue",a),Ln("useVernierSliderPoint","initialMacroRange",s,o,r,n,"[minDate, maxDate]",u);const M=ht(s,c,o,r,n,u);Sn("useVernierSliderPoint","initialMicroValue",c,a,M[0],M[1],"the initial macro window",u);const R=Cn(S),G=i.useRef(o),F=i.useRef(a),[X,_]=i.useState(o),[m,K]=i.useState(a);let y=X;const ae=[We(X[0],r,n),We(X[1],r,n)];(ae[0]!==X[0]||ae[1]!==X[1])&&(y=ae,_(ae));const W=i.useMemo(()=>ht(s,c,y,r,n,u),[s,c,y,r,n,u]),Z=i.useMemo(()=>Tn(W,c,R.microIsDiscrete,R.microAllowedDates??R.allowedDates,r,n,u),[W,c,R.microIsDiscrete,R.microAllowedDates,R.allowedDates,r,n,u]),oe=i.useMemo(()=>R.macroIsDiscrete===!0?vt(R.macroAllowedDates??R.allowedDates,s,r,n,u):[],[R.macroIsDiscrete,R.macroAllowedDates,R.allowedDates,s,r,n,u]),$=i.useRef(oe);$.current=oe;let v=m;const j=pr(m,c,W,Z,u);j!==m&&(v=j,K(j));const P=i.useRef(y);P.current=y;const Y=i.useRef(v);Y.current=v;const k=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates});k.current={minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates};const B=i.useRef(d);B.current=d;const ie=i.useRef(h);ie.current=h;const le=i.useCallback(V=>{const{minDate:ee,maxDate:de}=k.current;return ht(s,c,V,ee,de,u)},[s,c,u]),se=i.useCallback(V=>{const{microIsDiscrete:ee,microAllowedDates:de,allowedDates:p,minDate:A,maxDate:H}=k.current;return Tn(V,c,ee,de??p,A,H,u)},[c,u]),U=i.useCallback((V,ee)=>{const de=P.current,p=Y.current;(V[0].getTime()!==de[0].getTime()||V[1].getTime()!==de[1].getTime())&&(P.current=V,_(V),B.current?.(V[0],V[1])),ee.getTime()!==p.getTime()&&(Y.current=ee,K(ee),ie.current?.(ee))},[]),te=i.useCallback((V,ee)=>{const{minDate:de,maxDate:p}=k.current,A=[We(V,de,p),We(ee,de,p)],H=le(A);U(A,pr(Y.current,c,H,se(H),u))},[c,le,se,U,u]),Q=i.useCallback(V=>{const ee=le(P.current);U(P.current,pr(V,c,ee,se(ee),u))},[c,le,se,U,u]),ve=i.useCallback(V=>{const ee=P.current[1],de=V>ee?V:ee;te(V,de)},[te]),T=i.useCallback(V=>{const ee=P.current[0],de=V<ee?V:ee;te(de,V)},[te]),re=i.useCallback(V=>{const{minDate:ee,maxDate:de}=k.current,p=P.current,A=$.current;if(A.length>0){const ge=be(A,p[0],s,u)+V,Te=be(A,p[1],s,u)+V;if(ge<0||Te>A.length-1)return;te(A[ge],A[Te]);return}const H=Oe(s,p[0],V),he=Oe(s,p[1],V);H<ee||he>de||te(H,he)},[s,te,u]),fe=i.useCallback(V=>{const ee=P.current,de=le(ee),p=se(de);if(p.length>0){Q(yn(p,c,Y.current,V,u));return}Q(Oe(c,Y.current,V))},[c,le,se,Q,u]),Le=i.useCallback(()=>{const V=G.current,ee=le(V);U(V,pr(F.current,c,ee,se(ee),u))},[c,le,se,U,u]),[De,Ne]=W,Ye=i.useMemo(()=>({value:y[0],onChange:ve,minDate:r,maxDate:y[1],unit:s,yearStartMonth:u}),[y,ve,r,s,u]),Ge=i.useMemo(()=>({value:y[1],onChange:T,minDate:y[0],maxDate:n,unit:s,yearStartMonth:u}),[y,T,n,s,u]),st=i.useMemo(()=>({value:v,onChange:Q,minDate:De,maxDate:Ne,unit:c,yearStartMonth:u}),[v,Q,De,Ne,c,u]),lt=i.useMemo(()=>({...R,mode:"vernier",unit:t,yearStartMonth:u,macroUnit:s,microUnit:c,minDate:r,maxDate:n,macroRange:y,microValue:v,onChangeMacroRange:te,onChangeMicroPoint:Q}),[R,t,s,c,r,n,y,v,te,Q,u]);return{macroRange:y,setMacroRange:_,microValue:v,setMicroValue:K,setMacroLowerDate:ve,setMacroUpperDate:T,setMicroDate:Q,shiftMacroRange:re,shiftMicroValue:fe,resetVernier:Le,macroStartSelectorProps:Ye,macroEndSelectorProps:Ge,microSelectorProps:st,sliderProps:lt}}function Wa(e,t){const r=new Date(e,t,1);return r.setFullYear(e),r}function Kt(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function bn(e,t){return e===void 0?null:Kt(e,t)}function wn(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 Ga(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function Dl(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 Xa(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Kt(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}const Ml=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:s,minDate:c,maxDate:d,className:h="",style:D,disabled:S=!1,prevYearAriaLabel:u="Previous year",nextYearAriaLabel:M="Next year",selectAriaLabel:R="Year",locale:G,yearStartMonth:F}=e,X=Mr("YearSelector",F);wn(t,"value"),wn(r,"initialDate"),wn(c,"minDate"),wn(d,"maxDate"),Ga(a,"minYear"),Ga(s,"maxYear"),Dl(G);const _=t??r;if(_===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[m,K]=i.useState(()=>Kt(_,X)),y=c?.getTime(),ae=d?.getTime(),W=i.useMemo(()=>Xa(a,c,Math.max,X),[a,y,X]),Z=i.useMemo(()=>Xa(s,d,Math.min,X),[s,ae,X]);if(W===null||Z===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(W>Z)throw new RangeError(`YearSelector: the resolved lower bound ${W} is after the resolved upper bound ${Z}.`);const oe=t!==void 0,$=t!==void 0?Kt(t,X):m,v=$<W||$>Z,j=_.getTime();i.useEffect(()=>{oe||K(Kt(_,X))},[oe,j,X]);const P=U=>U>=W&&U<=Z,Y=U=>{if(!S){if(!P(U))throw new RangeError(`YearSelector: refusing to emit ${U}, which lies outside the declared bounds ${W}-${Z}.`);oe||K(U),n?.(Wa(U,X),U)}},k=P($-1)?$-1:null,B=P($+1)?$+1:null,ie=()=>{k!==null&&Y(k)},le=()=>{B!==null&&Y(B)},se=i.useMemo(()=>{const U=[];for(let te=Z;te>=W;te--)U.push(te);return v&&(U.push($),U.sort((te,Q)=>Q-te)),U},[W,Z,v,$]);return x.jsxs("div",{className:`inline-flex items-center ${Br} ${h}`,style:D,children:[x.jsx(qt,{neighbour:"control",direction:"left",disabled:S,canStep:k!==null,onStep:ie,ariaLabel:u}),x.jsx("select",{"aria-label":R,disabled:S,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:$,onChange:U=>{if(!U.target.value)return;const te=Number(U.target.value);Number.isInteger(te)&&Y(te)},children:se.map(U=>x.jsx("option",{value:U,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:Fe("year",Wa(U,X),void 0,G)},U))}),x.jsx(qt,{neighbour:"control",direction:"right",disabled:S,canStep:B!==null,onStep:le,ariaLabel:M}),o]})},vi=i.memo(Ml,(e,t)=>{const r=e.yearStartMonth??0,n=t.yearStartMonth??0;if(r!==n)return!1;const o=e.value??e.initialDate,a=t.value??t.initialDate,s=o?Kt(o,r):null,c=a?Kt(a,n):null;return!(s!==c||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||bn(e.minDate,r)!==bn(t.minDate,n)||bn(e.maxDate,r)!==bn(t.maxDate,n)||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});vi.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Qa;exports.DateSelector=Di;exports.MonthSelector=Mi;exports.PeriodSlider=gi;exports.YearSelector=vi;exports.addUnit=Oe;exports.areStylesEqual=fi;exports.calculateConnectDragValues=ri;exports.calculateHandleDragValues=Mo;exports.calculateKeyboardActionValues=ni;exports.calculateLabelSlant=To;exports.calculateVernierMacroDrag=di;exports.calculateVernierMicroDrag=mi;exports.decode=ue;exports.encode=ne;exports.findNearestDateIndex=be;exports.formatLabel=Fe;exports.formatQuarterLabel=Cs;exports.formatScreenReaderLabel=Ut;exports.getMacroWindowEndDate=ei;exports.getMacroWindowStartDate=Ja;exports.getSortedAllowedDates=vt;exports.normalizeDateByUnit=ke;exports.resolveDraggedEdge=An;exports.resolveMacroWindow=ht;exports.resolveQuarter=ti;exports.resolveVernierRailZone=yo;exports.resolveVernierTargetHandle=ui;exports.resolveWheelStep=ci;exports.usePeriodSliderPoint=bl;exports.usePeriodSliderRange=hl;exports.useVernierSliderPoint=pl;exports.useVernierSliderRange=wl;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react/jsx-runtime"),lt=require("date-fns"),i=require("react"),us=require("@aiquants/virtualscroll"),ds=require("react-dom"),Ta=120,ao="data-drag-snap",io="--ps-drag-snap-duration",zr={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"]},qa=["low","high"],Za=["tx","ty","rot"],En={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"}},So=(e,t)=>`${e}-${t}`,so=(e,t,r)=>`var(${So(e,t)}, ${r})`,ms=(e,t,r)=>{const n=En[t];for(const o of qa)for(const a of Za)e.style.setProperty(So(n[o],a),r[o][a])},Qa=e=>Math.max(0,Math.min(1,e)),xn=(e,t,r,n)=>{const o=Qa(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},Lo=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},An=(e,t,r,n)=>{const o=Qa(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},lo=(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,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},kt=(e,t)=>`var(${e}, ${t}%)`,fs=(e,t,r,n)=>{const[o,a]=zr[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},gs=e=>{for(const[t,r]of Object.values(zr))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(En))for(const r of qa)for(const n of Za)e.style.removeProperty(So(t[r],n))},co=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),ya=new Set(["hidden","clip","scroll","auto","overlay"]),Pa=["paint","strict","content"],hs=["layout","paint","strict","content"],bs=["transform","perspective","filter"],Nr=e=>e!==void 0&&e!==""&&e!=="none",ws=e=>e!==void 0&&e!==""&&e!=="normal",dn=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},ps=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,vs=(e,t)=>t==="absolute"&&Nr(e.position)&&e.position!=="static"||Nr(e.transform)||Nr(e.perspective)||Nr(e.filter)||Nr(e.backdropFilter)||ws(e.containerType)||hs.some(r=>e.contain.includes(r))?!0:bs.some(r=>e.willChange.includes(r)),Ds=(e,t,r,n,o,a)=>{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,h=n?r:0;if(o<c.left-f||o>=c.right+f||a<c.top-h||a>=c.bottom+h)return!1;const p=l.getComputedStyle(t);if(p.visibility!=="visible")return!1;let M=null;for(let b=t;b!==null;b=b.parentElement){const d=b===t?p:l.getComputedStyle(b);if(M!==null&&!vs(d,M))continue;const _=ya.has(d.overflowX)||Pa.some(F=>d.contain.includes(F)),x=ya.has(d.overflowY)||Pa.some(F=>d.contain.includes(F));if(_||x){const F=b.getBoundingClientRect();if(_&&(o<F.left+dn(d.borderLeftWidth)||o>=F.right-dn(d.borderRightWidth))||x&&(a<F.top+dn(d.borderTopWidth)||a>=F.bottom-dn(d.borderBottomWidth)))return!1}M=ps(d)}return!0},uo=new Map,Ms=(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 a=o.distanceToRailPx(t.clientX,t.clientY);a===null||a>=n||(r=o,n=a)}r?.step(t)},xs=(e,t)=>{let r=uo.get(e);if(r===void 0){const a=new Set,l=c=>Ms(a,c);r={participants:a,listener:l},uo.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)&&(uo.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Br="gap-[11px]",ht=6,bt=ht*2,Ot=ht*4/3,Rs={left:`0,${bt/2} ${ht},0 ${ht},${bt}`,right:`${Ot},${bt/2} ${Ot-ht},0 ${Ot-ht},${bt}`,up:`${bt/2},0 0,${ht} ${bt},${ht}`,down:`${bt/2},${Ot} 0,${Ot-ht} ${bt},${Ot-ht}`},mo=e=>{e.preventDefault(),e.stopPropagation()},Ss={onMouseDownCapture:mo,onMouseUpCapture:mo,onClickCapture:mo},Ls="period-slider-step",Ts=`${Ls} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,ys="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]",Ps={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"},mn="after:inset-[calc((100%-var(--ps-target-size))/2)]",Ea={horizontal:"px-[19px]",vertical:"py-[19px]"},Es={control:{left:mn,right:mn,up:mn,down:mn},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)]"}},qt=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:l,ref:c})=>{const f=e==="up"||e==="down",h=f?bt:Ot,p=f?Ot:bt,M=r||!n;return D.jsx("button",{ref:c,type:"button","aria-label":a,disabled:r,"aria-disabled":M?!0:void 0,...M?Ss:null,onClick:M?void 0:o,className:`${l===void 0?"":`${l} `}${Ts} ${ys} ${Ps[t]} ${Es[t][e]}`,children:D.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:h,height:p,viewBox:`0 0 ${h} ${p}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:D.jsx("polygon",{points:Rs[e]})})})},Ja={"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"}},Ke=e=>e instanceof Date&&!Number.isNaN(e.getTime()),pe=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),ct=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t)||t<0||t>11)throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${pe(t)})`)},Dr=(e,t)=>t===void 0?0:(ct(e,t),t),Oe=(e,t,r=0)=>{if(!Ke(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${pe(t)})`);ct("normalizeDateByUnit",r);const n=new Date(t.getTime());if(e==="year"){const o=t.getFullYear()-(t.getMonth()<r?1:0);n.setFullYear(o,r,1),n.setHours(0,0,0,0)}else e==="month"&&n.setDate(1),n.setHours(0,0,0,0);return n},ne=(e,t,r=0)=>{ct("encode",r);const n=Oe(e,t,r),o=n.getFullYear(),a=n.getMonth()+1,l=n.getDate();if(e==="year")return o;if(e==="month")return o*12+(a-1);const c=new Date(0);return c.setUTCFullYear(o,a-1,l),c.setUTCHours(0,0,0,0),Math.floor(c.getTime()/(1440*60*1e3))},le=(e,t,r=0)=>{ct("decode",r);const n=new Date(0);if(n.setHours(0,0,0,0),e==="year")return n.setFullYear(t,r,1),n;if(e==="month"){const a=Math.floor(t/12),l=t-a*12;return n.setFullYear(a,l,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},He=(e,t,r)=>{if(!Ke(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${pe(t)})`);return e==="year"?lt.addYears(t,r):e==="month"?lt.addMonths(t,r):lt.addDays(t,r)},ei=(e,t,r,n=0)=>{if(!Ke(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${pe(r)})`);return ct("getMacroWindowStartDate",n),Oe(t,Oe(e,r,n),n)},ti=(e,t,r,n=0)=>{if(!Ke(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${pe(r)})`);if(ct("getMacroWindowEndDate",n),e===t)return Oe(t,r,n);const o=r.getFullYear(),a=r.getMonth();if(e==="year"){const l=Oe("year",r,n),c=lt.addMonths(l,11);if(t==="month")return c;if(t==="day")return Oe("day",lt.addDays(lt.addMonths(l,12),-1))}return e==="month"&&t==="day"?new Date(o,a+1,0):Oe(t,r,n)},Aa=(e,t,r)=>e<t?t:e>r?r:e,wt=(e,t,r,n,o,a=0)=>{if(ct("resolveMacroWindow",a),Ur("macroRange",r,"resolveMacroWindow"),!Ke(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${pe(n)})`);if(!Ke(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[Oe(t,Aa(ei(e,t,r[0],a),n,o),a),Oe(t,Aa(ti(e,t,r[1],a),n,o),a)]},ri=(e,t)=>{if(!Ke(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${pe(e)})`);ct("resolveQuarter",t);const r=Oe("year",e,t).getFullYear(),n=((e.getMonth()-t)%12+12)%12,o=Math.floor(n/3)+1,a=new Date(e.getTime());return a.setFullYear(r,t+3*(o-1),1),a.setHours(0,0,0,0),{year:r,quarter:o,startDate:a}},As={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Ca=new Map,Cs=(e,t)=>{const r=`${e}\0${t}`,n=Ca.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,As[e]);return Ca.set(r,o),o},Is=4,$s=6,Cn=e=>e>=0?String(e).padStart(Is,"0"):`-${String(-e).padStart($s,"0")}`,ks=(e,t)=>{const r=Cn(t.getFullYear());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}`},Ye=(e,t,r,n)=>Ke(t)?r?r(t,e,"period"):n===void 0?ks(e,t):Cs(e,n).format(t):"",Wt=(e,t,r,n)=>Ye(e,t,r,n),Os=(e,t)=>{if(!Ke(e))return"";ct("formatQuarterLabel",t);const{quarter:r}=ri(e,t);return`${Ye("year",Oe("year",e,t))}-Q${r}`},he=(e,t,r,n=0)=>{if(ct("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;const o=ne(r,t,n);let a=0,l=e.length-1;if(o<=ne(r,e[a],n))return 0;if(o>=ne(r,e[l],n))return l;for(;a<=l;){const h=a+l>>1,p=ne(r,e[h],n);if(p===o)return h;p<o?a=h+1:l=h-1}const c=Math.abs(ne(r,e[a],n)-o),f=Math.abs(ne(r,e[l],n)-o);return c<f?a:l},St=(e,t,r,n,o=0)=>{if(ct("getSortedAllowedDates",o),!Array.isArray(e)||e.length===0)return[];const a=ne(t,r,o),l=ne(t,n,o),c=new Map;for(const f of e){const h=Oe(t,f,o),p=ne(t,h,o);p<a||p>l||c.has(p)||c.set(p,h)}if(c.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(c.keys()).sort((f,h)=>f-h).map(f=>c.get(f))},fn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const l=he(e,n,t,o);if(r==="time"){const c=e[0].getTime(),f=e[a].getTime()-c;return f<=0?0:Math.max(0,Math.min(1,(e[l].getTime()-c)/f))}return l/a},gn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const l=Math.max(0,Math.min(1,n));if(r==="time"){const c=e[0].getTime(),f=e[a].getTime()-c;return f<=0?0:he(e,new Date(c+l*f),t,o)}return Math.max(0,Math.min(a,Math.round(l*a)))},Mo=(e,t,r,n,o,a,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(a,c)),Math.max(o,Math.min(a,f))]},ni=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:l,snapMode:c,unit:f,yearStartMonth:h=0})=>{if(a){const x=l.length-1;if(x<=0)return[0,0];const F=Math.max(0,Math.min(x,Math.round(t))),ce=Math.max(F,Math.min(x,Math.round(r)));if(c==="time"){const V=l[0].getTime(),O=l[x].getTime(),ie=l[F].getTime(),j=l[ce].getTime()-ie;let re=ie+e*(O-V),K=re+j;re<V&&(re=V,K=V+j),K>O&&(K=O,re=O-j);const T=he(l,new Date(re),f,h),L=he(l,new Date(K),f,h);return[T,Math.max(T,L)]}const Z=Math.round(e*x);let u=F+Z,X=ce+Z;return u<0&&(X+=-u,u=0),X>x&&(u-=X-x,X=x),[Math.max(0,Math.min(x,u)),Math.max(0,Math.min(x,X))]}const p=x=>Math.max(n,Math.min(o,x)),M=o-n;if(M<=0)return[p(t),p(r)];const b=Math.round(e*M);let d=t+b,_=r+b;return d<n&&(_+=n-d,d=n),_>o&&(d-=_-o,_=o),[p(d),p(_)]},oi=(e,t,r,n,o,a,l,c)=>{let f=0,h=!1,p=!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":h=!0;break;case"End":p=!0;break;default:return null}if(l){let d=r;return h?d=o:p?d=a:d=Math.max(o,Math.min(a,r+f)),[d,d]}let M=r,b=n;return t==="low"?h?M=o:p?M=n:M=Math.max(o,Math.min(n,r+f)):h?b=r:p?b=a:b=Math.max(r,Math.min(a,n+f)),[M,b]},ai=8,ii=2,si=16,Ns=12,Vs=90,li=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},To=(e,t)=>{const r=t?.estimatedHeightPx??si,o=ai+(t?.anchorGapY??ii)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},yo=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,l=o?.estimatedHeightPx??si,c=o?.paddingPx??Ns,f=o?.maxAngleDeg??Vs,h=ai+(o?.anchorGapY??ii),p=To(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return p;const M=Math.max(0,t-e)/100*r,b=a+c;if(M>=b)return p;const d=Math.max(0,Math.min(1,(b-M)/b)),x=d*d*d*(d*(d*6-15)+10)*f,F=n==="top"?-x:x,ce=li(a,l,x),Z=h+ce.acrossPx,u=n==="top"?-Z:+Z,X=2*ce.alongPx,V=Math.max(0,(X+c-M)/2);return{lowAngleDeg:F,highAngleDeg:F,lowOffsetX:-V,highOffsetX:V,lowOffsetY:u,highOffsetY:u,isSlanted:d>.001,proximity:d}},ci=e=>({...e,lowOffsetX:0,highOffsetX:0}),Po=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},ui=(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 di(e,t,r,n,o,a,l="macro-top",c=.05,f=!0,h="range"){if(Po(t,l)==="macro"){const b=Math.abs(e-r),d=Math.abs(e-n);return b<=c&&b<=d?"macro-low":d<=c&&d<b?"macro-high":f&&e>=r&&e<=n?"macro-connect":b<d?"macro-low":"macro-high"}if(h==="point")return"micro-point";const p=Math.abs(e-o),M=Math.abs(e-a);return p<=c&&p<=M?"micro-low":M<=c&&M<p?"micro-high":f&&e>=o&&e<=a?"micro-connect":p<M?"micro-low":"micro-high"}function mi(e,t,r,n,o){if(e==="macro-connect"){const[h,p]=Lo(t-r,n,o);return[h,p,"macro-connect"]}const a=e==="macro-low"?"low":"high",[l,c]=xn(a,t,n,o),f=An(a,t,n,o);return[l,c,f==="low"?"macro-low":"macro-high"]}function fi(e,t,r,n,o){if(e==="micro-point"){const[h]=xn("point",t,n,o);return[h,h,"micro-point"]}if(e==="micro-connect"){const[h,p]=Lo(t-r,n,o);return[h,p,"micro-connect"]}const a=e==="micro-low"?"low":"high",[l,c]=xn(a,t,n,o),f=An(a,t,n,o);return[l,c,f==="low"?"micro-low":"micro-high"]}const jr=i.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;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",a=`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",a=`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 D.jsx("svg",{className:a,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:D.jsx("path",{d:o,className:l,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});jr.displayName="VernierKnobSvg";const Ys=(e,t)=>{if(!Ke(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${pe(e)})`);if(!Ke(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)})`)},Ur=(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(!Ke(n))throw new RangeError(`${r}: ${e}[0] must be a valid Date (received: ${pe(n)})`);if(!Ke(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)})`)},xo=(e,t)=>{if(!Ke(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${pe(t)})`)},Rt=(e,t,r,n,o,a)=>{const l=ne(r,t,a);if(l<ne(r,n,a)||l>ne(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${pe(t)}, minDate: ${pe(n)}, maxDate: ${pe(o)})`)},Hs=(e,t,r)=>{const n=e.yearStartMonth??0;if(e.mode==="range"){for(const o of["range","defaultRange"]){const a=e[o];a!==void 0&&(Ur(o,a),Rt(`${o}[0]`,a[0],e.unit,t,r,n),Rt(`${o}[1]`,a[1],e.unit,t,r,n))}return}if(e.mode==="point")for(const o of["value","defaultValue"]){const a=e[o];a!==void 0&&(xo(o,a),Rt(o,a,e.unit,t,r,n))}},_s=(e,t,r)=>{const n=e.yearStartMonth??0;Ur("macroRange",e.macroRange);const o=e.microUnit??e.unit,a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,l=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&l)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(l){if(e.microValue!==void 0)return xo("microValue",e.microValue),Rt("microValue",e.microValue,o,t,r,n),{shape:"point",selection:[e.microValue,e.microValue]};if(e.defaultMicroValue!==void 0)return xo("defaultMicroValue",e.defaultMicroValue),Rt("defaultMicroValue",e.defaultMicroValue,o,t,r,n),{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 Ur("microRange",e.microRange),Rt("microRange[0]",e.microRange[0],o,t,r,n),Rt("microRange[1]",e.microRange[1],o,t,r,n),{shape:"range",selection:e.microRange};if(e.defaultMicroRange!==void 0)return Ur("defaultMicroRange",e.defaultMicroRange),Rt("defaultMicroRange[0]",e.defaultMicroRange[0],o,t,r,n),Rt("defaultMicroRange[1]",e.defaultMicroRange[1],o,t,r,n),{shape:"range",selection:e.defaultMicroRange};throw a?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")},Vr=(e,t,r,n,o,a,l,c,f)=>{const h=he(e,n,t,f),p=he(e,o,t,f);return l?h:c?p:Math.max(h,Math.min(p,he(e,r,t,f)+a))},fo=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Ia=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback((a,l)=>{const c=r.current;if(c!==null&&c[0].getTime()===a.getTime()&&c[1].getTime()===l.getTime())return;const f=[a,l];r.current=f,t(f)},[]),o=i.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Fs=(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)})`)}},br=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(l=>{for(const c of l){const f=c.borderBoxSize?.[0];f!==void 0&&t(h=>h!==null&&Math.abs(h.widthPx-f.inlineSize)<.5&&Math.abs(h.heightPx-f.blockSize)<.5?h:{widthPx:f.inlineSize,heightPx:f.blockSize})}});a.observe(o),r.current=a},[]);return i.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},go=(e,t)=>{const r=vn(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},vn=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},js=e=>{const t={};let r=0;for(const o of e){const{side:a,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=li(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-${a}`]=`${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}},$a=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),ka=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),Rn=(e,t)=>({"--ps-tooltip-tx":so(e,"tx",t.tx),"--ps-tooltip-ty":so(e,"ty",t.ty),"--ps-tooltip-rot":so(e,"rot",t.rot)}),ho=(e,t,r,n)=>{const o=To(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=yo(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),l=n.isMerged?ci(a):a,c=En[e],f={low:$a(l.lowOffsetX,l.lowOffsetY-o.lowOffsetY,l.lowAngleDeg),high:$a(l.highOffsetX,l.highOffsetY-o.highOffsetY,l.highAngleDeg)};return{slant:l,lowStyle:Rn(c.low,f.low),highStyle:Rn(c.high,f.high),placements:f}},Oa={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Na=(e,t,r)=>{const n=To(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Oa,highStyle:Oa,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const f=yo(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?ci(f):f}const l=En.flat,c={low:ka(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:ka(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...Rn(l.low,c.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...Rn(l.high,c.high)},placements:o?c:null}},zs={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Us={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"}},Va={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},Bs={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Br} ${Ea.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Va.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Br} ${Ea.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Va.vertical}`}},Ya={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"}},Ha=(e,t)=>{e.setPointerCapture(t)},Ws=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:l=!1,className:c="",showStepper:f=!0,tooltipStyle:h="always",labelPosition:p="top",autoSlantLabels:M=!0,isVertical:b=!1,hideConnectBar:d=!1,showTicks:_=!1,colorScheme:x="blue-rose",locale:F,decreaseAriaLabel:ce="Decrease",increaseAriaLabel:Z="Increase"}=e,u=Dr("PeriodSlider",e.yearStartMonth);Ys(r,n),Hs(e,r,n),F!==void 0&&Fs("locale",F);const X=e.mode==="vernier"?_s(e,r,n):null,V=X!==null&&X.shape==="point",O=Ja[x],ie=i.useId(),j=i.useRef(e),re=r.getTime(),K=n.getTime(),T=i.useMemo(()=>St(o,t,r,n,u),[o,t,re,K,u]),L=T.length>0,{rangeMin:H,rangeMax:S}=i.useMemo(()=>L?{rangeMin:0,rangeMax:T.length-1}:{rangeMin:ne(t,r,u),rangeMax:ne(t,n,u)},[L,T,t,re,K,u]),I=e.mode==="point",Y=i.useCallback(s=>{if(L){const m=Math.max(0,Math.min(T.length-1,Math.round(s)));return T[m]}return le(t,Math.round(s),u)},[L,T,t,u]),ee=i.useCallback(s=>{if(s===void 0)return H;const m=Oe(t,s,u);return L?he(T,m,t,u):ne(t,m,u)},[L,T,t,H,u]),[_e,ue]=i.useState(()=>X===null?null:X.selection);let B=_e??(X===null?null:X.selection);if(V&&B!==null&&B[0].getTime()!==B[1].getTime()){const s=[B[0],B[0]];B=s,ue(s)}const q=e.mode==="vernier"?e.microValue?.getTime():void 0,te=i.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,q]),se=Ia(),E=Ia(),U=e.mode!=="vernier"?null:V?te??B:e.microRange!==void 0?e.microRange:B,ge=U===null?null:E.shown??U,Ie=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ge?.[0]:void 0,Ne=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ge?.[1]:void 0,Fe=e.mode==="point"?e.value??e.defaultValue:void 0,qe=e.mode==="point"?Fe?.getTime():Ie?.getTime(),Ze=e.mode==="range"?Ne?.getTime():qe,[be,Te]=i.useMemo(()=>{if(e.mode==="point"){const g=ee(Fe);return[g,g]}const s=ee(Ie),m=ee(Ne);return[Math.min(s,m),Math.max(s,m)]},[e.mode,qe,Ze,ee,Fe,Ie,Ne]),Pe=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:V?e.microValue!==void 0:e.microRange!==void 0,[G,oe]=i.useState(()=>[be,Te]),[me,v]=i.useState(null),[R,Q]=i.useState(null),fe=i.useRef(null),[De,Me]=i.useState("high"),[xe,ut]=i.useState(null),[nt,Nt]=i.useState(null),ve=me?me[0]:Pe?be:G[0],Ee=me?me[1]:Pe?Te:G[1],y=i.useRef([ve,Ee]),A=e.mode==="vernier",Ue=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",$=Ue==="macro-top"||Ue==="macro-left",Vt=e.mode==="vernier"?e.showVernierProjection??!0:!1,ot=e.mode==="vernier"?e.showVernierTicks??!0:!1,Wr=e.mode==="vernier"?e.showHairline??!0:!1,J=A?e.macroUnit??t:t,C=A?e.microUnit??t:t,kn=A?e.macroIsDiscrete??!1:L,Mr=A?e.microIsDiscrete??!1:L,Eo=A?e.macroAllowedDates??o:o,Ao=A?e.microAllowedDates??o:o,Gr=A?e.formatMacroLabel??e.formatLabel:e.formatLabel,Xr=A?e.formatMicroLabel??e.formatLabel:e.formatLabel,Si=Ie?.getTime(),Li=Ne?.getTime(),[Qe,Kr]=i.useState(null),Lt=i.useRef(null),[xr,Zt]=i.useState(()=>V?"micro-point":"micro-high");let Ve=xr;const On=V?xr==="micro-low"||xr==="micro-high"||xr==="micro-connect"?"micro-point":null:xr==="micro-point"?"micro-high":null;On!==null&&(Ve=On,Zt(On));const je=i.useMemo(()=>ne(J,r,u),[re,J,u]),dt=i.useMemo(()=>{const s=ne(J,n,u);if(A&&s<=je)throw new RangeError(`PeriodSlider: macroUnit "${J}" cannot distinguish minDate from maxDate (minDate: ${pe(r)}, maxDate: ${pe(n)})`);return s},[A,re,K,je,J,u]),ye=i.useMemo(()=>A&&kn?St(Eo,J,r,n,u):[],[A,kn,Eo,J,re,K,u]),Co=s=>[Math.max(je,Math.min(dt,ne(J,s[0],u))),Math.max(je,Math.min(dt,ne(J,s[1],u)))],[Io,$o]=e.mode!=="vernier"?[je,dt]:Co(e.macroRange),[Be,We]=se.shown===null?[Io,$o]:Co(se.shown),pt=i.useMemo(()=>le(J,Be,u),[J,Be,u]),Yt=i.useMemo(()=>le(J,We,u),[J,We,u]),qr=i.useMemo(()=>e.mode!=="vernier"?[r,n]:wt(J,C,[pt,Yt],r,n,u),[e.mode,pt,Yt,J,C,re,K,u]),Re=i.useMemo(()=>ne(C,qr[0],u),[C,qr,u]),Ce=i.useMemo(()=>ne(C,qr[1],u),[C,qr,u]),ko=i.useMemo(()=>A&&Mr?St(Ao,C,r,n,u):[],[A,Mr,Ao,C,re,K,u]),Nn=(s,m)=>ko.filter(g=>{const w=ne(C,g,u);return w>=s&&w<=m}),de=i.useMemo(()=>Nn(Re,Ce),[ko,C,Re,Ce]),Qt=kn&&ye.length>0,at=Mr&&de.length>0,Tt=(s,m,g,w)=>m.length>0?ne(C,m[he(m,s,C,u)],u):Math.max(g,Math.min(w,ne(C,s,u))),Jt=at?de:[],$e=i.useMemo(()=>ge===null?Re:Tt(ge[0],Jt,Re,Ce),[Si,Re,Ce,C,ge,Jt]),Ge=i.useMemo(()=>ge===null?Ce:Tt(ge[1],Jt,Re,Ce),[Li,Re,Ce,C,ge,Jt]),yt=i.useMemo(()=>le(C,$e,u),[C,$e,u]),Pt=i.useMemo(()=>le(C,Ge,u),[C,Ge,u]),Oo=!A||U===null?null:{macroUnit:J,macroLowEnc:Io,macroHighEnc:$o,microUnit:C,microLowEnc:ne(C,U[0],u),microHighEnc:ne(C,U[1],u)},Vn=i.useRef(Oo),Zr=Math.max(1,dt-je),it=Qt?fn(ye,J,a,pt,u):Math.max(0,Math.min(1,(Be-je)/Zr)),mt=Math.max(it,Qt?fn(ye,J,a,Yt,u):Math.min(1,(We-je)/Zr)),Qr=Math.max(1,Ce-Re),er=at?fn(de,C,a,yt,u):Math.max(0,Math.min(1,($e-Re)/Qr)),Rr=Math.max(er,at?fn(de,C,a,Pt,u):Math.min(1,(Ge-Re)/Qr)),Yn=i.useRef({timerId:null,emit:null}),Jr=i.useRef({timerId:null,emit:null}),en=i.useRef({timerId:null,emit:null});i.useEffect(()=>{const s=[Yn,Jr,en];return()=>{for(const m of s)fo(m.current)}},[]);const tr=i.useCallback((s,m,g)=>{fo(s);const{debounceMs:w}=j.current;if(g||!w||w<=0){m();return}s.emit=m,s.timerId=setTimeout(()=>{s.timerId=null,s.emit=null,m()},w)},[]),No=i.useCallback(s=>{const m=s.emit;fo(s),m?.()},[]),rr=i.useCallback(s=>new Date(Math.min(Math.max(s.getTime(),re),K)),[re,K]),Et=i.useCallback((s,m,g=!1)=>{const[w,P]=y.current;if((j.current.mode==="point"?s===w:s===w&&m===P)&&Yn.current.timerId===null)return;const z=Y(s),N=Y(m),ae=()=>{const we=j.current;we.mode==="point"?we.onChangePoint?.(z):we.mode==="range"&&we.onChangeRange?.(z,N)};tr(Yn.current,ae,g)},[Y,tr]),Ht=i.useCallback((s,m,g=!1)=>{const w=Vn.current;if(j.current.mode!=="vernier"||w===null)return;const P=rr(s),k=rr(m);ne(w.macroUnit,P,u)===w.macroLowEnc&&ne(w.macroUnit,k,u)===w.macroHighEnc&&Jr.current.timerId===null||tr(Jr.current,()=>{const z=j.current;z.mode==="vernier"&&z.onChangeMacroRange?.(P,k)},g)},[rr,tr,u]),et=i.useCallback((s,m,g=!1)=>{const w=j.current,P=Vn.current;if(w.mode!=="vernier"||P===null)return;const k=rr(s),z=rr(m);ne(P.microUnit,k,u)===P.microLowEnc&&ne(P.microUnit,z,u)===P.microHighEnc&&en.current.timerId===null||((V?w.microValue===void 0:w.microRange===void 0)&&ue([k,z]),tr(en.current,()=>{const N=j.current;if(N.mode==="vernier"){if(V){N.onChangeMicroPoint?.(k);return}N.onChangeMicroRange?.(k,z)}},g))},[rr,tr,V,u]),Vo=i.useCallback((s,m=!1)=>{et(s,s,m)},[et]),_t=i.useCallback(s=>{if(L&&a==="time"&&T.length>1){const w=Math.max(0,Math.min(T.length-1,Math.round(s))),P=T[0].getTime(),z=T[T.length-1].getTime()-P;if(z<=0)return 0;const N=T[w].getTime();return Math.max(0,Math.min(100,(N-P)/z*100))}const m=S-H;if(m<=0)return 0;const g=(s-H)/m*100;return Math.max(0,Math.min(100,g))},[L,a,T,H,S]),Hn=i.useCallback(s=>{const m=Math.max(0,Math.min(100,s));if(L){if(a==="time"&&T.length>1){const P=T[0].getTime(),z=T[T.length-1].getTime()-P,N=P+m/100*z;return he(T,new Date(N),t,u)}const w=Math.round(m/100*(T.length-1));return Math.max(0,Math.min(T.length-1,w))}const g=H+m/100*(S-H);return Math.round(g)},[L,a,T,H,S,t,u]),Sr=i.useRef(null),Yo=i.useRef(null),Ho=i.useRef(0),Je=i.useRef(null),_n=i.useRef(null),_o=i.useRef(null),Fo=i.useRef(null),[Fn,jo]=i.useState(0),[Ti,nr]=br(),[yi,zo]=br(),[Pi,Uo]=br(),[Ei,Bo]=br(),[Ai,jn]=br(),[Ci,Wo]=br(),Ii=I?nr===null?void 0:{estimatedWidthPx:nr.widthPx,estimatedHeightPx:nr.heightPx}:go(nr,zo),zn=!I&&ve===Ee,Un=Be===We,Bn=!V&&$e===Ge,$i=$?"top":"bottom",ki=$?"bottom":"top",Go=M&&!b,Oi=Go&&!V,Wn={isPointMode:I,isVertical:b,autoSlantLabels:M,isMerged:zn,trackLengthPx:Fn,labelPosition:p,config:Ii},Gn={trackLengthPx:Fn,labelPosition:$i,config:go(Uo,Bo),isMerged:Un,isSlantable:Go},Xn={trackLengthPx:Fn,labelPosition:ki,config:go(jn,Wo),isMerged:Bn,isSlantable:Oi};i.useEffect(()=>{const s=Je.current;if(!s)return;const m=()=>{const w=s.getBoundingClientRect(),P=b?w.height:w.width;P>0&&jo(k=>Math.abs(k-P)<.5?k:P)};if(m(),typeof ResizeObserver<"u"){const w=new ResizeObserver(P=>{for(const k of P){const z=b?k.contentRect.height:k.contentRect.width;z>0&&jo(N=>Math.abs(N-z)<.5?N:z)}});return w.observe(s),()=>w.disconnect()}const g=s.ownerDocument.defaultView;if(g)return g.addEventListener("resize",m),()=>g.removeEventListener("resize",m)},[b]);const or=i.useCallback((s,m,g)=>{const w=b?g.height:g.width;if(!(Number.isFinite(w)&&w>0))return null;const P=b?g.bottom-m:s-g.left;return Number.isFinite(P)?Math.max(0,Math.min(1,P/w)):null},[b]),Xo=i.useCallback((s,m)=>{const g=Je.current;if(!g)return null;const w=or(s,m,g.getBoundingClientRect());return w===null?null:w*100},[or]),Lr=i.useRef(null),vt=i.useRef(null),tn=i.useRef({macroLowRatio:it,macroHighRatio:mt,isVertical:b,isMacroFirstRail:$}),Ko=i.useRef({flat:Wn,macro:Gn,micro:Xn});i.useLayoutEffect(()=>{tn.current={macroLowRatio:it,macroHighRatio:mt,isVertical:b,isMacroFirstRail:$},Ko.current={flat:Wn,macro:Gn,micro:Xn},j.current=e,y.current=[ve,Ee],Vn.current=Oo,fe.current=R,Lt.current=Qe});const qo=(s,m)=>{const g=tn.current;_n.current?.setAttribute("d",lo(s,m,g.isVertical,g.isMacroFirstRail))},Ni=(s,m,g)=>{const w=Ko.current;return s==="flat"?Na(m*100,g*100,w.flat).placements:ho(s,m,g,s==="macro"?w.macro:w.micro).placements},Tr=(s,m,g)=>{const w=Je.current;if(!w)return;Lr.current={rail:s,lowRatio:m,highRatio:g},fs(w,s,m,g);const P=Ni(s,m,g);P!==null&&ms(w,s,P),s==="macro"&&qo(m,g)},Ft=i.useCallback(()=>{vt.current!==null&&(clearTimeout(vt.current),vt.current=null);const s=Je.current;s&&(s.removeAttribute(ao),s.style.removeProperty(io))},[]),Zo=()=>{const s=Je.current;if(Lr.current===null||!s){Lr.current=null;return}Lr.current=null,vt.current!==null&&clearTimeout(vt.current),s.style.setProperty(io,`${Ta}ms`),s.setAttribute(ao,"true"),gs(s),qo(tn.current.macroLowRatio,tn.current.macroHighRatio),vt.current=setTimeout(()=>{vt.current=null,s.removeAttribute(ao),s.style.removeProperty(io)},Ta)};i.useLayoutEffect(()=>{const s=Lr.current;s!==null&&Tr(s.rail,s.lowRatio,s.highRatio)}),i.useEffect(()=>()=>{vt.current!==null&&clearTimeout(vt.current)},[]);const ar=i.useRef(null),ir=i.useRef(null),ft=i.useRef(null),Kn=i.useRef(null),yr=i.useRef(null),At=i.useCallback(()=>ar.current!==null||ir.current!==null,[]),Qo=s=>{if(l)return;if(A){const W=ir.current;if(!W||s.pointerId!==W.pointerId||!Je.current)return;const st=or(s.clientX,s.clientY,Je.current.getBoundingClientRect());if(st===null)return;if(W.handle==="macro-low"||W.handle==="macro-high"||W.handle==="macro-connect"){const[ke,Ae,Dt]=mi(W.handle,st,W.startPointerRatio,W.startMacroLowRatio,W.startMacroHighRatio);Tr("macro",ke,Ae),Dt!==Lt.current&&(Lt.current=Dt,Kr(Dt),Zt(Dt));let ze,tt;if(Qt){const Ct=gn(ye,J,a,ke,u),It=Math.max(Ct,gn(ye,J,a,Ae,u));ze=ye[Ct],tt=ye[It]}else{const Ct=Math.round(je+ke*Zr),It=Math.round(je+Ae*Zr);ze=le(J,Ct,u),tt=le(J,It,u)}se.show(ze,tt);const Ir=`${ze.getTime()}_${tt.getTime()}`;Ir!==Kn.current&&(Kn.current=Ir,Ht(ze,tt));const[Mt,zt]=wt(J,C,[ze,tt],r,n,u),no=ne(C,Mt,u),oo=ne(C,zt,u),xa=Mr?Nn(no,oo):[];let Ut,Bt;if(W.handle==="macro-connect"){const Ct=Mt,It=zt;let fr,gr;if(J==="year"){const $t=ze.getFullYear()-W.startMacroLowDate.getFullYear();fr=He("year",W.initialMicroLowDate,$t),gr=He("year",W.initialMicroHighDate,$t)}else if(J==="month"){const $t=(ze.getFullYear()-W.startMacroLowDate.getFullYear())*12+(ze.getMonth()-W.startMacroLowDate.getMonth());fr=He("month",W.initialMicroLowDate,$t),gr=He("month",W.initialMicroHighDate,$t)}else{const $t=Math.round((ze.getTime()-W.startMacroLowDate.getTime())/864e5);fr=He("day",W.initialMicroLowDate,$t),gr=He("day",W.initialMicroHighDate,$t)}const hr=Ct.getTime(),$r=It.getTime(),La=W.initialMicroHighDate.getTime()-W.initialMicroLowDate.getTime();let kr=fr.getTime(),Or=gr.getTime();kr<hr&&(kr=hr,Or=Math.min($r,kr+La)),Or>$r&&(Or=$r,kr=Math.max(hr,Or-La)),Ut=Oe(C,new Date(kr),u),Bt=Oe(C,new Date(Or),u)}else{const Ct=Mt.getTime(),It=zt.getTime(),fr=W.initialMicroLowDate.getTime(),gr=W.initialMicroHighDate.getTime(),hr=Math.max(Ct,Math.min(It,fr)),$r=Math.max(hr,Math.min(It,gr));Ut=Oe(C,new Date(hr),u),Bt=Oe(C,new Date($r),u)}const Ra=Tt(Ut,xa,no,oo),cs=Math.max(Ra,Tt(Bt,xa,no,oo));Ut=le(C,Ra,u),Bt=le(C,cs,u),E.show(Ut,Bt);const Sa=`${Ut.getTime()}_${Bt.getTime()}`;Sa!==yr.current&&(yr.current=Sa,et(Ut,Bt))}else if(W.handle==="micro-low"||W.handle==="micro-high"||W.handle==="micro-connect"||W.handle==="micro-point"){const[ke,Ae,Dt]=fi(W.handle,st,W.startPointerRatio,W.startMicroLowRatio,W.startMicroHighRatio);Tr("micro",ke,Ae),Dt!==Lt.current&&(Lt.current=Dt,Kr(Dt),Zt(Dt));let ze,tt;if(at){const Mt=gn(de,C,a,ke,u),zt=Math.max(Mt,gn(de,C,a,Ae,u));ze=de[Mt],tt=de[zt]}else{const Mt=Tt(le(C,Math.round(Re+ke*Qr),u),Jt,Re,Ce),zt=Math.max(Mt,Tt(le(C,Math.round(Re+Ae*Qr),u),Jt,Re,Ce));ze=le(C,Mt,u),tt=le(C,zt,u)}E.show(ze,tt);const Ir=`${ze.getTime()}_${tt.getTime()}`;Ir!==yr.current&&(yr.current=Ir,et(ze,tt))}return}const m=ar.current;if(!m||s.pointerId!==m.pointerId||!Je.current)return;const g=Je.current.getBoundingClientRect(),w=b?s.clientY:s.clientX,P=b?g.height:g.width;if(!(Number.isFinite(P)&&P>0))return;if(m.handle==="connect"){const W=b?(m.startPointerPos-w)/P:(w-m.startPointerPos)/P,[st,ke]=Lo(W,m.startLowRatio,m.startHighRatio);Tr("flat",st,ke);const Ae=ni({posDiffPct:W,startLowVal:m.startLowVal,startHighVal:m.startHighVal,rangeMin:H,rangeMax:S,isDiscrete:L,sortedAllowedDates:T,snapMode:a,unit:t,yearStartMonth:u});if(ft.current&&ft.current[0]===Ae[0]&&ft.current[1]===Ae[1])return;ft.current=Ae,v(Ae),Et(Ae[0],Ae[1],!1);return}const k=or(s.clientX,s.clientY,g);if(k===null)return;const[z,N]=xn(I?"point":m.handle,k,m.startLowRatio,m.startHighRatio);Tr("flat",z,N);const ae=Hn(k*100),[we,Se]=Mo(m.handle,ae,m.startLowVal,m.startHighVal,H,S,I);if((!ft.current||ft.current[0]!==we||ft.current[1]!==Se)&&(ft.current=[we,Se],v([we,Se]),Et(we,Se,!1)),!I&&(m.handle==="low"||m.handle==="high")){const W=An(m.handle,k,m.startLowRatio,m.startHighRatio);fe.current!==W&&(fe.current=W,Q(W),Me(W))}},Jo=()=>{Zo(),Kn.current=null,yr.current=null,ir.current=null,Lt.current=null,Kr(null),se.release(),E.release(),No(Jr.current),No(en.current)},ea=()=>{Zo();const s=ft.current??me;s&&(Et(s[0],s[1],!0),oe(s)),ft.current=null,v(null),ar.current=null,fe.current=null,Q(null)},ta=s=>{if(A){const g=ir.current;if(!g||s.pointerId!==g.pointerId)return;Jo();return}const m=ar.current;!m||s.pointerId!==m.pointerId||ea()},ra=()=>{ir.current!==null&&Jo(),ar.current!==null&&ea()},qn=i.useRef(Qo),na=i.useRef(ta),oa=i.useRef(ra);i.useLayoutEffect(()=>{qn.current=Qo,na.current=ta,oa.current=ra});const aa=i.useRef(A);i.useEffect(()=>{aa.current!==A&&(aa.current=A,oa.current())},[A]);const ia=R!==null||Qe!==null;i.useEffect(()=>{if(!ia)return;const s=Sr.current?.ownerDocument.defaultView;if(!s)return;const m=w=>qn.current(w),g=w=>na.current(w);return s.addEventListener("pointermove",m),s.addEventListener("pointerup",g),s.addEventListener("pointercancel",g),s.addEventListener("lostpointercapture",g),()=>{s.removeEventListener("pointermove",m),s.removeEventListener("pointerup",g),s.removeEventListener("pointercancel",g),s.removeEventListener("lostpointercapture",g)}},[ia]);const Zn=i.useCallback((s,m,g,w)=>{Ft(),Ha(s,m),ar.current={pointerId:m,handle:g,startPointerPos:w,startLowVal:ve,startHighVal:Ee,startLowRatio:_t(ve)/100,startHighRatio:_t(Ee)/100},fe.current=g,Q(g),g!=="connect"&&Me(g)},[ve,Ee,_t]),sa=i.useCallback((s,m,g,w)=>{j.current.mode==="vernier"&&(Ft(),Ha(s,m),ir.current={pointerId:m,handle:g,startPointerRatio:w,startMacroLowRatio:it,startMacroHighRatio:mt,startMicroLowRatio:er,startMicroHighRatio:Rr,startMacroLowDate:pt,initialMicroLowDate:yt,initialMicroHighDate:Pt},Lt.current=g,Kr(g),Zt(g))},[it,mt,er,Rr,pt,yt,Pt]),la=s=>m=>{if(l||At())return;m.stopPropagation(),m.preventDefault(),Me(s);const g=b?m.clientY:m.clientX;Zn(m.currentTarget,m.pointerId,s,g)},ca=s=>()=>{l||fe.current!==null||Me(s)},rn=s=>()=>{l||Lt.current!==null||Zt(s)},sr=s=>m=>{if(l||At())return;m.stopPropagation(),m.preventDefault();const g=Je.current;if(!g)return;const w=or(m.clientX,m.clientY,g.getBoundingClientRect());w!==null&&sa(m.currentTarget,m.pointerId,s,w)},Vi=s=>{if(l||d||At())return;s.stopPropagation(),s.preventDefault();const m=b?s.clientY:s.clientX;Zn(s.currentTarget,s.pointerId,"connect",m)},Yi=s=>{if(l||At())return;if(A){const N=Je.current;if(!N)return;const ae=N.getBoundingClientRect(),we=or(s.clientX,s.clientY,ae);if(we===null)return;const Se=b?s.clientX-(ae.left+ae.width/2):s.clientY-(ae.top+ae.height/2),W=di(we,Se,it,mt,er,Rr,Ue,void 0,!d,V?"point":"range");sa(s.currentTarget,s.pointerId,W,we),qn.current(s.nativeEvent);return}const m=Xo(s.clientX,s.clientY);if(m===null)return;const g=Hn(m);let w="low";if(!I){const N=Math.abs(g-ve),ae=Math.abs(g-Ee);N<ae?w="low":ae<N?w="high":w=g>Ee?"high":"low"}Me(w);const[P,k]=Mo(w,g,ve,Ee,H,S,I);v([P,k]),Et(P,k,!0);const z=b?s.clientY:s.clientX;Zn(s.currentTarget,s.pointerId,w,z)},Hi=s=>{if(l||A||R!==null)return;const m=Xo(s.clientX,s.clientY);if(m===null)return;const g=Hn(m);ut(g),Nt(_t(g))},_i=()=>{ut(null),Nt(null)},ua=s=>m=>{if(l||At())return;Me(s);const g=oi(m.key,s,ve,Ee,H,S,I,1);g&&(m.preventDefault(),Ft(),Pe||oe(g),Et(g[0],g[1],!0))},lr=(s,m)=>{if(U===null)return;const[g,w]=wt(J,C,[s,m],r,n,u),P=ne(C,g,u),k=ne(C,w,u),z=Mr?Nn(P,k):[],N=Tt(U[0],z,P,k),ae=Math.max(N,Tt(U[1],z,P,k));et(le(C,N,u),le(C,ae,u),!0)},nn=s=>m=>{if(l||!A||e.mode!=="vernier"||At())return;Zt(s);let g=0,w=!1,P=!1;switch(m.key){case"ArrowRight":case"ArrowUp":g=1;break;case"ArrowLeft":case"ArrowDown":g=-1;break;case"PageUp":g=5;break;case"PageDown":g=-5;break;case"Home":w=!0;break;case"End":P=!0;break;default:return}if(m.preventDefault(),Ft(),s==="macro-low"){const k=le(J,Be,u),z=le(J,We,u);if(Qt){const we=Vr(ye,J,k,ye[0],z,g,w,P,u);if(we===he(ye,k,J,u))return;const Se=ye[we];Ht(Se,z,!0),lr(Se,z);return}let N;if(w?N=je:P?N=We:N=Math.max(je,Math.min(We,Be+g)),N===Be)return;const ae=le(J,N,u);Ht(ae,z,!0),lr(ae,z)}else if(s==="macro-high"){const k=le(J,Be,u),z=le(J,We,u);if(Qt){const we=Vr(ye,J,z,k,ye[ye.length-1],g,w,P,u);if(we===he(ye,z,J,u))return;const Se=ye[we];Ht(k,Se,!0),lr(k,Se);return}let N;if(w?N=Be:P?N=dt:N=Math.max(Be,Math.min(dt,We+g)),N===We)return;const ae=le(J,N,u);Ht(k,ae,!0),lr(k,ae)}else if(s==="micro-low"){const k=le(C,$e,u),z=le(C,Ge,u);if(at){const ae=Vr(de,C,k,de[0],z,g,w,P,u);if(ae===he(de,k,C,u))return;et(de[ae],z,!0);return}let N;if(w?N=Re:P?N=Ge:N=Math.max(Re,Math.min(Ge,$e+g)),N===$e)return;et(le(C,N,u),z,!0)}else if(s==="micro-high"){const k=le(C,$e,u),z=le(C,Ge,u);if(at){const ae=Vr(de,C,z,k,de[de.length-1],g,w,P,u);if(ae===he(de,z,C,u))return;et(k,de[ae],!0);return}let N;if(w?N=$e:P?N=Ce:N=Math.max($e,Math.min(Ce,Ge+g)),N===Ge)return;et(k,le(C,N,u),!0)}else if(s==="micro-point"){const k=le(C,$e,u);if(at){const N=Vr(de,C,k,de[0],de[de.length-1],g,w,P,u);if(N===he(de,k,C,u))return;Vo(de[N],!0);return}let z;if(w?z=Re:P?z=Ce:z=Math.max(Re,Math.min(Ce,$e+g)),z===$e)return;Vo(le(C,z,u),!0)}},Fi=s=>{if(e.mode!=="vernier")return;if(Ft(),Qt){const z=ye.length-1,N=he(ye,pt,J,u),ae=he(ye,Yt,J,u),we=ae-N;let Se=N+s,W=ae+s;if(s<0&&Se<0?(Se=0,W=Math.min(z,we)):s>0&&W>z&&(W=z,Se=Math.max(0,z-we)),Se===N&&W===ae)return;const st=ye[Se],ke=ye[W];Ht(st,ke,!0),lr(st,ke);return}const m=We-Be;let g=Be+s,w=We+s;if(s<0&&g<je?(g=je,w=Math.min(dt,g+m)):s>0&&w>dt&&(w=dt,g=Math.max(je,w-m)),g===Be&&w===We)return;const P=le(J,g,u),k=le(J,w,u);Ht(P,k,!0),lr(P,k)},Qn=i.useCallback(s=>{const m=j.current;if(!(m.disabled||At()))if(Ft(),m.mode==="point"){const g=Math.max(H,Math.min(S,ve+s));Pe||oe([g,g]),Et(g,g,!0)}else if(m.mode==="vernier"){if(at){const we=de.length-1,Se=he(de,yt,C,u),W=he(de,Pt,C,u),st=W-Se;let ke=Se+s,Ae=W+s;s<0&&ke<0?(ke=0,Ae=Math.min(we,st)):s>0&&Ae>we&&(Ae=we,ke=Math.max(0,we-st)),(ke!==Se||Ae!==W)&&et(de[ke],de[Ae],!0);return}const g=$e,w=Ge,P=Re,k=Ce,z=w-g;let N=g+s,ae=w+s;s<0&&N<P?(N=P,ae=Math.min(k,N+z)):s>0&&ae>k&&(ae=k,N=Math.max(P,ae-z)),(N!==g||ae!==w)&&et(le(C,N,u),le(C,ae,u),!0)}else{const g=Ee-ve;let w=ve+s,P=Ee+s;s<0&&w<H?(w=H,P=Math.min(S,w+g)):s>0&&P>S&&(P=S,w=Math.max(H,P-g)),w<=P&&(Pe||oe([w,P]),Et(w,P,!0))}},[ve,Ee,H,S,Pe,Et,et,$e,Ge,Re,Ce,C,at,de,yt,Pt,Ft,u]),da=s=>!l&&co(Sr.current,s),ma=(s,m)=>{const g=Yo.current,w=Je.current,P=Sr.current;if(l||g===null||w===null||P===null||!Ds(g,P,Ho.current,b,s,m))return null;const k=w.getBoundingClientRect();return Math.abs(b?s-(k.left+k.width/2):m-(k.top+k.height/2))},fa=s=>{if(l||At())return;const m=ui(s.deltaX,s.deltaY,b);if(m===0)return;s.preventDefault();const g=s.target,w=co(_o.current,g)||co(Fo.current,g);if(!A||w){Qn(m);return}const P=Je.current;if(!P)return;const k=P.getBoundingClientRect(),z=b?s.clientX-(k.left+k.width/2):s.clientY-(k.top+k.height/2);if(Po(z,Ue)==="macro"){Fi(m);return}Qn(m)},on=i.useRef({ownsWheelHit:da,distanceToRailPx:ma,stepFromRangeAreaWheel:fa});i.useLayoutEffect(()=>{on.current={ownsWheelHit:da,distanceToRailPx:ma,stepFromRangeAreaWheel:fa}});const Pr=i.useRef(null);i.useEffect(()=>{const s=Sr.current?.ownerDocument.defaultView??null,m=Pr.current;if(m!==null&&m.view===s)return;if(m?.unregister(),s===null){Pr.current=null;return}const g=xs(s,{ownsHit:w=>on.current.ownsWheelHit(w),distanceToRailPx:(w,P)=>on.current.distanceToRailPx(w,P),step:w=>on.current.stepFromRangeAreaWheel(w)});Pr.current={view:s,unregister:g}}),i.useEffect(()=>()=>{Pr.current?.unregister(),Pr.current=null},[]);const an=_t(ve),sn=_t(Ee),Jn=Y(ve),eo=Y(Ee),to=Na(an,sn,Wn),Er=to.slant,Ar=R==="low"||R!=="high"&&De==="low",Cr=!I&&(R==="high"||R!=="low"&&De==="high"),ji=Un&&Ve!=="macro-low",zi=Un&&Ve==="macro-low",Ui=Bn&&Ve!=="micro-low",Bi=Bn&&Ve==="micro-low",cr=ho("macro",it,mt,Gn),ur=ho("micro",er,Rr,Xn),Wi=Math.min(an,sn),Gi=Math.max(an,sn),[ga,ha]=zr.flat,[Xi,Ki]=zr.macro,[qi,Zi]=zr.micro,ba=kt(ga,an),wa=kt(ha,sn),ro=kt(ga,Wi),pa=`calc(${kt(ha,Gi)} - ${ro})`,dr=kt(Xi,it*100),ln=kt(Ki,mt*100),mr=kt(qi,er*100),cn=kt(Zi,Rr*100),Qi=b?{bottom:ro,height:pa,top:"auto",left:"0",right:"0"}:{left:ro,width:pa,top:"0",bottom:"0"},Ji=Math.max(.01,mt-it),va=Math.max(.06,Math.min(.25,.28*Math.sqrt(Ji))),es=b?{bottom:ba,left:"50%",transform:"translate(-50%, 50%)",zIndex:Ar?40:30}:{left:ba,top:"50%",transform:"translate(-50%, -50%)",zIndex:Ar?40:30},ts=b?{bottom:wa,left:"50%",transform:"translate(-50%, 50%)",zIndex:Cr?40:30}:{left:wa,top:"50%",transform:"translate(-50%, -50%)",zIndex:Cr?40:30},rs=b?{bottom:`${nt}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${nt}%`,top:"50%",transform:"translate(-50%, -50%)"},Da=xe!==null?Y(xe):null,ns=h!=="hover"&&xe!==null&&(xe===ve||!I&&xe===Ee),os=at?ne(C,de[0],u):Re,as=at?ne(C,de[de.length-1],u):Ce,is=A?$e>os:ve>H,ss=A?Ge<as:Ee<S,un=js(A?[{side:$?"before":"after",box:vn(Uo,Bo),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:cr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:cr.slant.lowOffsetX}},{side:$?"after":"before",box:V?jn:vn(jn,Wo),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:ur.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:ur.slant.lowOffsetX}}]:[{side:b||p==="top"?"before":"after",box:I?nr:vn(nr,zo),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Er.lowAngleDeg,centreOffsetPx:Er.lowOffsetY,alongPushPx:Er.lowOffsetX}}]),ls=un===void 0?e.style:{...e.style,...un.style};i.useLayoutEffect(()=>{Ho.current=un===void 0?0:un.mainPx});const gt=V?"micro-point":"micro-low",jt=l?"cursor-not-allowed opacity-50":"cursor-pointer",Ma=s=>{const m=b?"vertical":"horizontal",g=s==="decrease",w=b?!g:g;return D.jsx(qt,{ref:g?_o:Fo,neighbour:"rail",direction:zs[m][s],disabled:l,canStep:g?is:ss,onStep:()=>Qn(g?-1:1),ariaLabel:g?ce:Z,className:`period-slider-stepper-btn ${Us[m][s]} ${Ya[m][w?"leading":"trailing"]}`})};return D.jsxs("div",{ref:Sr,style:ls,className:`period-slider grid select-none place-items-center ${Bs[b?"vertical":"horizontal"][f?"withSteppers":"railOnly"]} ${c}`,"data-disabled":l?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":p,"data-color-scheme":x,children:[D.jsx("div",{ref:Yo,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),f&&Ma(b?"increase":"decrease"),D.jsx("div",{ref:Je,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":A?Ue:void 0,className:`period-slider-track relative touch-none rounded-full ${Ya[b?"vertical":"horizontal"][f?"rail":"railOnly"]} ${jt}`,onPointerDown:Yi,onPointerMove:Hi,onPointerLeave:_i,children:A?D.jsxs(D.Fragment,{children:[Vt&&(b?D.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:[D.jsx("defs",{children:D.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"1",y2:"0",children:[D.jsx("stop",{offset:"0%",stopColor:$?O.macro:O.micro,stopOpacity:"0.28"}),D.jsx("stop",{offset:"100%",stopColor:$?O.micro:O.macro,stopOpacity:va})]})}),D.jsx("path",{ref:_n,"data-testid":"period-slider-vernier-projection",d:lo(it,mt,b,$),fill:`url(#${ie})`})]}):D.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[D.jsx("defs",{children:D.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"0",y2:"1",children:[D.jsx("stop",{offset:"0%",stopColor:$?O.macro:O.micro,stopOpacity:"0.28"}),D.jsx("stop",{offset:"100%",stopColor:$?O.micro:O.macro,stopOpacity:va})]})}),D.jsx("path",{ref:_n,"data-testid":"period-slider-vernier-projection",d:lo(it,mt,b,$),fill:`url(#${ie})`})]})),!d&&D.jsxs(D.Fragment,{children:[D.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${dr} - 8px)`,height:`calc(${ln} - ${dr} + 16px)`}:{left:`calc(${dr} - 8px)`,width:`calc(${ln} - ${dr} + 16px)`},onPointerDown:sr("macro-connect")}),!V&&D.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${mr} - 8px)`,height:`calc(${cn} - ${mr} + 16px)`}:{left:`calc(${mr} - 8px)`,width:`calc(${cn} - ${mr} + 16px)`},onPointerDown:sr("micro-connect")})]}),ot&&D.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(s=>D.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${s*100}%`}:{left:`${s*100}%`}},`macro-tick-${s}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(s=>D.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${s*100}%`}:{left:`${s*100}%`}},`micro-tick-${s}`))]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":l?"true":void 0,"aria-valuemin":je,"aria-valuemax":We,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(pt,J,"period"):Wt(J,pt,Gr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:dr,left:$?0:"auto",right:$?"auto":0,transform:$?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Qe==="macro-low"||Ve==="macro-low"?30:15}:{left:dr,top:$?0:"auto",bottom:$?"auto":0,transform:$?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Qe==="macro-low"||Ve==="macro-low"?30:15},onPointerDown:sr("macro-low"),onKeyDown:nn("macro-low"),onFocus:rn("macro-low"),"data-active":Qe==="macro-low"?"true":void 0,"data-front":Ve==="macro-low"?"true":void 0,"data-vernier-pos":b?$?"left":"right":$?"top":"bottom","data-handle-type":"macro-low",children:[D.jsx(jr,{type:"macro",isTop:$,isVertical:b,isLeft:$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":ji?"true":void 0,"data-slanted":cr.slant.isSlanted?"true":void 0,ref:Pi,style:cr.lowStyle,children:Ye(J,pt,Gr,F)})]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":l?"true":void 0,"aria-valuemin":Be,"aria-valuemax":dt,"aria-valuenow":We,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Yt,J,"period"):Wt(J,Yt,Gr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:ln,left:$?0:"auto",right:$?"auto":0,transform:$?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Qe==="macro-high"||Ve==="macro-high"?30:15}:{left:ln,top:$?0:"auto",bottom:$?"auto":0,transform:$?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Qe==="macro-high"||Ve==="macro-high"?30:15},onPointerDown:sr("macro-high"),onKeyDown:nn("macro-high"),onFocus:rn("macro-high"),"data-active":Qe==="macro-high"?"true":void 0,"data-front":Ve==="macro-high"?"true":void 0,"data-vernier-pos":b?$?"left":"right":$?"top":"bottom","data-handle-type":"macro-high",children:[D.jsx(jr,{type:"macro",isTop:$,isVertical:b,isLeft:$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":zi?"true":void 0,"data-slanted":cr.slant.isSlanted?"true":void 0,ref:Ei,style:cr.highStyle,children:Ye(J,Yt,Gr,F)})]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":V?e.pointAriaLabel??"Micro selected date":e.lowerAriaLabel??"Micro range start","aria-disabled":l?"true":void 0,"aria-valuemin":Re,"aria-valuemax":V?Ce:Ge,"aria-valuenow":$e,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(yt,C,"period"):Wt(C,yt,Xr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:mr,left:$?"auto":0,right:$?0:"auto",transform:$?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Qe===gt||Ve===gt?30:20}:{left:mr,top:$?"auto":0,bottom:$?0:"auto",transform:$?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Qe===gt||Ve===gt?30:20},onPointerDown:sr(gt),onKeyDown:nn(gt),onFocus:rn(gt),"data-active":Qe===gt?"true":void 0,"data-front":Ve===gt?"true":void 0,"data-vernier-pos":b?$?"right":"left":$?"bottom":"top","data-handle-type":gt,children:[D.jsx(jr,{type:"micro",isTop:!$,isVertical:b,isLeft:!$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":Ui?"true":void 0,"data-slanted":ur.slant.isSlanted?"true":void 0,ref:Ai,style:ur.lowStyle,children:Ye(C,yt,Xr,F)})]}),!V&&D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":l?"true":void 0,"aria-valuemin":$e,"aria-valuemax":Ce,"aria-valuenow":Ge,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Pt,C,"period"):Wt(C,Pt,Xr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:cn,left:$?"auto":0,right:$?0:"auto",transform:$?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Qe==="micro-high"||Ve==="micro-high"?30:20}:{left:cn,top:$?"auto":0,bottom:$?0:"auto",transform:$?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Qe==="micro-high"||Ve==="micro-high"?30:20},onPointerDown:sr("micro-high"),onKeyDown:nn("micro-high"),onFocus:rn("micro-high"),"data-active":Qe==="micro-high"?"true":void 0,"data-front":Ve==="micro-high"?"true":void 0,"data-vernier-pos":b?$?"right":"left":$?"bottom":"top","data-handle-type":"micro-high",children:[D.jsx(jr,{type:"micro",isTop:!$,isVertical:b,isLeft:!$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":Bi?"true":void 0,"data-slanted":ur.slant.isSlanted?"true":void 0,ref:Ci,style:ur.highStyle,children:Ye(C,Pt,Xr,F)})]})]}):D.jsxs(D.Fragment,{children:[!d&&D.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Qi,onPointerDown:Vi}),_&&L&&T.length>1&&D.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:T.map((s,m)=>{const g=ne(t,s,u),w=_t(m),P=b?{bottom:`${w}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${w}%`,top:"50%",transform:"translate(-50%, -50%)"};return D.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:P},`tick-${g}`)})}),!l&&xe!==null&&nt!==null&&R===null&&Da&&D.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:rs,children:[D.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"}),D.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":ns?"true":void 0,className:`period-slider-hover-tooltip ${p==="bottom"&&!b?"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:Ye(t,Da,e.formatLabel,F)})]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":I?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":l?"true":void 0,"aria-valuemin":H,"aria-valuemax":I?S:Ee,"aria-valuenow":ve,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Jn,t,"period"):Wt(t,Jn,e.formatLabel,F),"aria-orientation":b?"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 ${jt}`,style:es,onPointerDown:la("low"),onKeyDown:ua("low"),onFocus:ca("low"),"data-active":R==="low"?"true":void 0,"data-front":Ar?"true":void 0,children:[D.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 ${R==="low"?"":"shadow-md"}`}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-label-position":p,"data-slanted":Er.isSlanted?"true":void 0,"data-front":Ar?"true":void 0,"data-duplicate":zn&&!Ar?"true":void 0,ref:Ti,style:to.lowStyle,children:Ye(t,Jn,e.formatLabel,F)})]}),!I&&D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":l?"true":void 0,"aria-valuemin":ve,"aria-valuemax":S,"aria-valuenow":Ee,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(eo,t,"period"):Wt(t,eo,e.formatLabel,F),"aria-orientation":b?"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 ${jt}`,style:ts,onPointerDown:la("high"),onKeyDown:ua("high"),onFocus:ca("high"),"data-active":R==="high"?"true":void 0,"data-front":Cr?"true":void 0,children:[D.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 ${R==="high"?"":"shadow-md"}`}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-label-position":p,"data-slanted":Er.isSlanted?"true":void 0,"data-front":Cr?"true":void 0,"data-duplicate":zn&&!Cr?"true":void 0,ref:yi,style:to.highStyle,children:Ye(t,eo,e.formatLabel,F)})]})]})}),f&&Ma(b?"decrease":"increase")]})},bo=(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},gi=(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},Gs=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||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||!gi(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||!bo(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||!bo(e.macroAllowedDates,t.macroAllowedDates)||!bo(e.microAllowedDates,t.microAllowedDates)):!1,hi=i.memo(Ws,Gs);hi.displayName="PeriodSlider";const bi=864e5,_a=2,Le=-1,Dn=e=>{const t=e.getFullYear(),r=new Date(Date.UTC(t,e.getMonth(),e.getDate()));return r.setUTCFullYear(t),Math.floor(r.getTime()/bi)},wi=e=>{const t=new Date(e*bi),r=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return r.setFullYear(t.getUTCFullYear()),r.setHours(0,0,0,0),r},Yr=e=>`${Cn(e.getFullYear())}-${String(e.getMonth()+1).padStart(_a,"0")}-${String(e.getDate()).padStart(_a,"0")}`,Xs=(e,t,r,n)=>{const o=Dn(e),a=Dn(t),l=a>=o?a-o+1:0,c=f=>wi(a-f);return{count:l,dateAt:c,labelAt:f=>Ye("day",c(f),n,r),indexOf:f=>{const h=Dn(f);return h<o||h>a?Le:a-h}}},Ks=(e,t,r,n,o)=>{const a=r>=t?r-t+1:0,l=c=>e[r-c];return{count:a,dateAt:l,labelAt:c=>Ye("day",l(c),o,n),indexOf:c=>{const f=c.getTime();let h=t,p=r;for(;h<=p;){const M=h+p>>1,b=e[M].getTime();if(b===f)return r-M;b<f?h=M+1:p=M-1}return Le}}},qs={count:0,dateAt: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:()=>Le},Zs=(e,t,r)=>{const n=c=>{let f=0,h=e.length;for(;f<h;){const p=f+h>>1;e[p].getTime()<c?f=p+1:h=p}return f},o=c=>{let f=0,h=e.length;for(;f<h;){const p=f+h>>1;e[p].getTime()<=c?f=p+1:h=p}return f},a=t===null?0:n(t.getTime()),l=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:l}},Fa=(e,t,r,n,o)=>{let a=t,l=r,c=null;for(;a<=l;){const f=a+l>>1,h=e[f].getTime();o===-1?h<n?(c=e[f],a=f+1):l=f-1:h>n?(c=e[f],l=f-1):a=f+1}return c},Qs=(e,t)=>{const r=new Map;return e.forEach((n,o)=>{t(o,n);const a=new Date(n);a.setHours(0,0,0,0);const l=a.getTime();r.has(l)||r.set(l,a)}),Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},Js={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},el={month:2,day:2},ja={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},za=new Map,tl=(e,t)=>{const r=`${e}\0${t}`,n=za.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Js[e]);return za.set(r,o),o},rl=(e,t,r)=>r!==void 0?tl(e,r).format(t):e==="year"?Cn(ja.year(t)):String(ja[e](t)).padStart(el[e],"0"),pi=(e,t,r,n)=>{if(t!=="year"&&t!=="month"&&t!=="day")throw new RangeError(`formatOptionText: unit must be "year", "month" or "day" (received: ${String(t)})`);if(r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${String(r)})`);return Ke(e)?r==="part"?rl(t,e,n):Ye(t,e,void 0,n):""},Mn=44,Ua=7,hn=8,nl=2,vi=10,ol=1e3,Ro=8,wo=6,po=4,vo=12,Hr=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),Dn(r)},al=(e,t)=>{if(e.length<po||t.count===0)return Le;const r=Number(e.slice(0,po));if(!Number.isInteger(r))return Le;const n=e.length>=wo,o=n?Number(e.slice(po,wo)):vo;if(o<1||o>vo)return Le;const a=e.length>=Ro,l=a?Number(e.slice(wo,Ro)):0,c=Hr(r,o),f=(o===vo?Hr(r+1,1):Hr(r,o+1))-1,h=a?c+l-1:n?c:Hr(r,1),p=a?h:n?f:Hr(r+1,1)-1;if(a&&(l<1||h>f))return Le;for(let M=p;M>=h;M--){const b=t.indexOf(wi(M));if(b!==Le)return b}return Le},il=e=>e.closest(".dark")===null?"light":"dark",sl=(e,t,r,n)=>{const o=r-e.bottom-hn,a=e.top-hn,l=o>=t||o>=a,f=Math.max(Mn,Math.min(t,l?o:a)),h=l?e.bottom:e.top-f,p=e.width+vi,M=Math.max(hn,Math.min(e.left,n-p-hn));return{top:h,left:M,width:p,height:f}},Di=({domain:e,selectedIndex:t,displayLabel:r,machineValue:n,disabled:o,ariaLabel:a,onCommitIndex:l,controlClassName:c})=>{const f=i.useId(),h=`period-slider-date-listbox-${f}`,p=E=>`period-slider-date-option-${f}-${E}`,[M,b]=i.useState(!1),[d,_]=i.useState(Le),[x,F]=i.useState(!0),[ce,Z]=i.useState(null),[u,X]=i.useState(null),V=i.useRef(null),O=i.useRef(null),ie=i.useRef(null),j=i.useRef({buffer:"",at:0}),re=i.useRef(e);re.current=e;const K=e.count,T=Math.min(K,Ua)*Mn,L=Math.max(1,Math.min(K,Ua)),H=i.useCallback(()=>{const E=V.current;if(E===null)return;const U=E.getBoundingClientRect();Z(sl(U,T,window.innerHeight,window.innerWidth))},[T]),S=i.useCallback(()=>{b(!1),_(Le),j.current={buffer:"",at:0}},[]),I=i.useCallback(E=>{o||K===0||(_(E),b(!0))},[o,K]);i.useLayoutEffect(()=>{if(!M){Z(null),X(null);return}const E=V.current;return E!==null&&X(il(E)),H(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[M,H]),i.useEffect(()=>{if(!M)return;const E=U=>{const ge=U.target;ge!==null&&O.current?.contains(ge)!==!0&&V.current?.contains(ge)!==!0&&S()};return document.addEventListener("pointerdown",E,!0),()=>document.removeEventListener("pointerdown",E,!0)},[M,S]);const Y=i.useRef(d);Y.current=d,i.useEffect(()=>{M&&(o||K===0)&&S()},[M,o,K,S]),i.useEffect(()=>{if(!M)return;const E=Y.current;if(E===Le)return;const U=Math.min(E,K-1);U!==E&&_(U),ie.current?.scrollToIndex(U,{align:"center"})},[K,M]);const ee=E=>{if(K===0)return;const U=Math.max(0,Math.min(E,K-1));_(U),ie.current?.scrollToIndex(U,{align:"center"})},_e=E=>{E<0||E>=K||(l(E),S(),V.current?.focus())},ue=E=>{if(o)return;const U=d!==Le?d:t!==Le?t:0;switch(E.key){case"ArrowDown":if(E.preventDefault(),!M){I(U);return}ee(U+1);return;case"ArrowUp":if(E.preventDefault(),!M){I(U);return}ee(U-1);return;case"Home":if(!M)return;E.preventDefault(),ee(0);return;case"End":if(!M)return;E.preventDefault(),ee(K-1);return;case"PageDown":if(!M)return;E.preventDefault(),ee(U+L);return;case"PageUp":if(!M)return;E.preventDefault(),ee(U-L);return;case"Enter":if(E.preventDefault(),!M){I(U);return}_e(d!==Le?d:U);return;case"Escape":if(!M)return;E.preventDefault(),S();return;case"Tab":M&&S();return}if(E.key.length!==1)return;const ge=E.key>="0"&&E.key<="9",Ie=E.key==="-"||E.key==="/"||E.key===".";if(!(ge||Ie))return;E.preventDefault();const Ne=Date.now(),Fe=Ne-j.current.at>ol?"":j.current.buffer,qe=ge?`${Fe}${E.key}`.slice(0,Ro):Fe;j.current={buffer:qe,at:Ne};const Ze=al(qe,re.current);if(Ze!==Le){if(!M){I(Ze);return}ee(Ze)}},B=i.useCallback(E=>E,[]),q=i.useCallback(()=>Mn,[]),te=i.useCallback(E=>{const U=Y.current;F(U===Le||U>=E.renderingStartIndex&&U<=E.renderingEndIndex)},[]),se=M&&ce!==null&&u!==null&&K>0?D.jsx("div",{ref:O,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":u,style:{top:ce.top,left:ce.left,width:ce.width,height:ce.height},onMouseDown:E=>{E.preventDefault()},children:D.jsx(us.VirtualScroll,{ref:ie,itemCount:K,getItem:B,getItemHeight:q,viewportSize:ce.height-nl,initialScrollIndex:d!==Le?d:void 0,onRangeChange:te,className:"h-full w-full",testId:"period-slider-date-listbox-pane",contentProps:{id:h,role:"listbox","aria-label":a},scrollBarOptions:{width:vi,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:E=>{const U=E===t,ge=E===d;return D.jsx("div",{id:p(E),role:"option","aria-selected":U,"aria-posinset":E+1,"aria-setsize":K,"data-testid":"period-slider-date-option","data-active":ge?"true":void 0,className:"period-slider-date-option",style:{height:Mn},onClick:()=>_e(E),children:re.current.labelAt(E)})}})}):null;return D.jsxs(D.Fragment,{children:[D.jsx("input",{ref:V,type:"text",role:"combobox",readOnly:!0,"aria-label":a,"aria-expanded":M,"aria-controls":M?h:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":M&&d!==Le&&x?p(d):void 0,disabled:o,value:r,className:c,"data-testid":"period-slider-date-combobox","data-value":n,onKeyDown:ue,onMouseDown:E=>{o||(E.preventDefault(),V.current?.focus(),M?S():I(t!==Le?t:0))},onBlur:()=>{M&&S()}}),se===null?null:ds.createPortal(se,document.body)]})};Di.displayName="VirtualDateDropdown";const Gt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},_r=(e,t)=>{if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},ll=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)})`)}},xt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Do=e=>xt(e,1,1),cl=e=>xt(e,12,31),ul=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:l,minDate:c,maxDate:f,allowedDates:h,variant:p="date",className:M="",style:b,disabled:d=!1,prevDateAriaLabel:_="Previous day",nextDateAriaLabel:x="Next day",selectAriaLabel:F="Date",yearAriaLabel:ce="Year",monthAriaLabel:Z="Month",dayAriaLabel:u="Day",locale:X,formatOption:V}=e;if(ll(X),t!==void 0&&_r("value",t),r!==void 0&&_r("initialDate",r),c!==void 0&&_r("minDate",c),f!==void 0&&_r("maxDate",f),a!==void 0&&!Number.isInteger(a))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(a)})`);if(l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(l)})`);if(p==="split-dropdown"&&h!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const O=t??r;if(O===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[ie,j]=i.useState(()=>Gt(O)),re=t!==void 0,K=t?.getTime(),T=i.useMemo(()=>t!==void 0?Gt(t):ie,[K,ie]),L=c?.getTime(),H=f?.getTime(),S=i.useMemo(()=>{const y=c?Gt(c):null,A=a!==void 0?Do(a):null;return y===null?A:A===null||y.getTime()>=A.getTime()?y:A},[L,a]),I=i.useMemo(()=>{const y=f?Gt(f):null,A=l!==void 0?cl(l):null;return y===null?A:A===null||y.getTime()<=A.getTime()?y:A},[H,l]),Y=S?.getTime()??null,ee=I?.getTime()??null;if(S!==null&&I!==null&&S.getTime()>I.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Yr(S)} is after max ${Yr(I)})`);if(p!=="date"&&h===void 0&&(S===null||I===null))throw new RangeError(`DateSelector: variant="${p}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${p==="dropdown"?' or supply "allowedDates"':""}`);const _e=i.useMemo(()=>h===void 0?null:h.map(y=>y.getTime()).join(","),[h]),ue=i.useMemo(()=>h===void 0?null:Qs(h,(y,A)=>_r(`allowedDates[${y}]`,A)),[_e]),B=i.useMemo(()=>ue===null?null:{ascending:ue,...Zs(ue,S,I)},[ue,Y,ee]),q=i.useMemo(()=>B!==null?Ks(B.ascending,B.loIndex,B.hiIndex,X,V):S===null||I===null?qs:Xs(S,I,X,V),[B,Y,ee,X,V]),te=y=>{if(B!==null)return q.indexOf(y)!==Le;const A=y.getTime();return!(Y!==null&&A<Y||ee!==null&&A>ee)},se=O.getTime();i.useEffect(()=>{re||j(Gt(O))},[re,se]);const E=y=>{if(d)return;const A=Gt(y);te(A)&&(re||j(A),n?.(A))},U=T.getTime(),ge=te(T),Ie=i.useMemo(()=>{if(B!==null)return Fa(B.ascending,B.loIndex,B.hiIndex,U,-1);const y=lt.addDays(new Date(U),-1);return te(y)?y:null},[B,U,Y,ee]),Ne=i.useMemo(()=>{if(B!==null)return Fa(B.ascending,B.loIndex,B.hiIndex,U,1);const y=lt.addDays(new Date(U),1);return te(y)?y:null},[B,U,Y,ee]),Fe=()=>{Ie!==null&&E(Ie)},qe=()=>{Ne!==null&&E(Ne)},Ze=y=>{if(y.target.value){const A=lt.parseISO(y.target.value);Number.isNaN(A.getTime())||E(A)}},be=T.getFullYear(),Te=T.getMonth()+1,Pe=T.getDate(),G=i.useCallback((y,A)=>V?V(A,y,"part"):pi(A,y,"part",X),[V,X]),oe=i.useMemo(()=>{if(p!=="split-dropdown"||S===null||I===null)return[];const y=[];for(let A=I.getFullYear();A>=S.getFullYear();A--)y.push({value:A,label:G("year",Do(A))});return y},[p,Y,ee,G]),me=i.useMemo(()=>{if(p!=="split-dropdown"||S===null||I===null)return[];const y=S,A=I,Ue=be===y.getFullYear()?y.getMonth()+1:1,$=be===A.getFullYear()?A.getMonth()+1:12,Vt=[];for(let ot=Ue;ot<=$;ot++)Vt.push({value:ot,label:G("month",xt(be,ot,1))});return Vt},[p,Y,ee,be,G]),v=i.useMemo(()=>{if(p!=="split-dropdown"||S===null||I===null)return[];const y=S,A=I,Ue=be===y.getFullYear()&&Te===y.getMonth()+1?y.getDate():1,$=be===A.getFullYear()&&Te===A.getMonth()+1?A.getDate():lt.getDaysInMonth(new Date(U)),Vt=[];for(let ot=Ue;ot<=$;ot++)Vt.push({value:ot,label:G("day",xt(be,Te,ot))});return Vt},[p,Y,ee,U,be,Te,G]),R=(y,A,Ue)=>Ue>lt.getDaysInMonth(xt(y,A,1))?!1:te(xt(y,A,Ue)),Q=(y,A,Ue)=>{R(y,A,Ue)&&E(xt(y,A,Ue))},fe=oe.some(y=>y.value===be),De=me.some(y=>y.value===Te),Me=v.some(y=>y.value===Pe),xe=Yr(T),ut=p==="dropdown"?Ye("day",T,V,X):"",nt=S?Yr(S):void 0,Nt=I?Yr(I):void 0,ve="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 D.jsxs("div",{className:`inline-flex items-center ${Br} ${M}`,style:b,"data-variant":p,"data-out-of-range":ge?void 0:"true",children:[D.jsx(qt,{neighbour:"control",direction:"left",disabled:d,canStep:Ie!==null,onStep:Fe,ariaLabel:_}),p==="dropdown"?D.jsx(Di,{domain:q,selectedIndex:ge?q.indexOf(T):Le,displayLabel:ut,machineValue:xe,disabled:d,ariaLabel:F,onCommitIndex:y=>E(q.dateAt(y)),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"}):p==="split-dropdown"?D.jsxs("div",{className:"inline-flex items-center gap-1",children:[D.jsxs("select",{"aria-label":ce,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:fe?be:"",onChange:y=>Q(Number(y.target.value),Te,Pe),children:[fe?null:D.jsx("option",{value:"",disabled:!0,className:ve,children:G("year",Do(be))}),oe.map(y=>D.jsx("option",{value:y.value,disabled:!R(y.value,Te,Pe),className:"dark:bg-slate-700 dark:text-slate-100",children:y.label},y.value))]}),D.jsxs("select",{"aria-label":Z,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:De?Te:"",onChange:y=>Q(be,Number(y.target.value),Pe),children:[De?null:D.jsx("option",{value:"",disabled:!0,className:ve,children:G("month",xt(be,Te,1))}),me.map(y=>D.jsx("option",{value:y.value,disabled:!R(be,y.value,Pe),className:"dark:bg-slate-700 dark:text-slate-100",children:y.label},y.value))]}),D.jsxs("select",{"aria-label":u,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?Pe:"",onChange:y=>Q(be,Te,Number(y.target.value)),children:[Me?null:D.jsx("option",{value:"",disabled:!0,className:ve,children:G("day",xt(be,Te,Pe))}),v.map(y=>D.jsx("option",{value:y.value,disabled:!R(be,Te,y.value),className:"dark:bg-slate-700 dark:text-slate-100",children:y.label},y.value))]})]}):D.jsx("input",{"aria-label":F,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:xe,min:nt,max:Nt,onChange:Ze,type:"date"}),D.jsx(qt,{neighbour:"control",direction:"right",disabled:d,canStep:Ne!==null,onStep:qe,ariaLabel:x}),o]})},wr=e=>e===void 0?null:Gt(e).getTime(),Mi=i.memo(ul,(e,t)=>!(wr(e.value??e.initialDate)!==wr(t.value??t.initialDate)||wr(e.minDate)!==wr(t.minDate)||wr(e.maxDate)!==wr(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.formatOption!==t.formatOption));Mi.displayName="DateSelector";function rt(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 Xt(e){return`${Cn(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}function Fr(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 Ba(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function dl(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 ml(e,t){const r=e===void 0?null:rt(e,0),n=t===void 0?null:rt(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function fl(e,t){const r=e===void 0?null:rt(e,11),n=t===void 0?null:rt(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function gl(e,t,r){const n=new Map;for(const o of e){const a=rt(o.getFullYear(),o.getMonth());t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function hl(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),o=[];for(let a=r;a<=n;a++)o.push(rt(Math.floor(a/12),(a%12+12)%12));return o}function Wa(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:Ye("month",e[o],r,t),value:Xt(e[o])});return n}const bl=e=>{const{value:t,initialDate:r,onChange:n,children:o,variant:a="date",minYear:l,maxYear:c,minDate:f,maxDate:h,allowedMonths:p,isWarning:M=!1,className:b="",style:d,disabled:_=!1,prevMonthAriaLabel:x="Previous month",nextMonthAriaLabel:F="Next month",selectAriaLabel:ce="Month",locale:Z,formatOption:u}=e;dl(Z),Fr(t,"value"),Fr(r,"initialDate"),Fr(f,"minDate"),Fr(h,"maxDate"),Ba(l,"minYear"),Ba(c,"maxYear"),p?.forEach((v,R)=>{Fr(v,`allowedMonths[${R}]`)});const X=t??r;if(X===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[V,O]=i.useState(()=>rt(X.getFullYear(),X.getMonth())),ie=t!==void 0,j=i.useMemo(()=>t!==void 0?rt(t.getFullYear(),t.getMonth()):V,[t?.getTime(),V]),re=f?.getTime(),K=h?.getTime(),T=i.useMemo(()=>ml(l,f),[l,re]),L=i.useMemo(()=>fl(c,h),[c,K]),H=T?.getTime()??null,S=L?.getTime()??null;if(T!==null&&L!==null&&T>L)throw new RangeError(`MonthSelector: the resolved lower bound ${Xt(T)} is after the resolved upper bound ${Xt(L)}.`);if(a==="dropdown"&&p===void 0&&(T===null||L===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 I=p===void 0?null:p.map(v=>v.getTime()).join(","),Y=i.useMemo(()=>p===void 0?null:gl(p,T,L),[I,H,S]),ee=v=>{const R=v.getTime();return Y!==null?Y.some(Q=>Q.getTime()===R):!(H!==null&&R<H||S!==null&&R>S)},_e=X.getTime();i.useEffect(()=>{if(ie)return;const v=rt(X.getFullYear(),X.getMonth());O(R=>R.getTime()===v.getTime()?R:v)},[ie,_e]);const ue=v=>{if(_)return;if(!ee(v))throw new RangeError(`MonthSelector: refusing to emit ${Xt(v)}, which lies outside the selectable months.`);ie||O(v);const R=v.getFullYear()*100+(v.getMonth()+1);n?.(v,R)},B=j.getTime(),q=ee(j),te=i.useMemo(()=>{if(Y!==null){for(let R=Y.length-1;R>=0;R--)if(Y[R].getTime()<B)return Y[R];return null}const v=rt(j.getFullYear(),j.getMonth()-1);return ee(v)?v:null},[Y,B,H,S]),se=i.useMemo(()=>{if(Y!==null){for(const R of Y)if(R.getTime()>B)return R;return null}const v=rt(j.getFullYear(),j.getMonth()+1);return ee(v)?v:null},[Y,B,H,S]),E=()=>{te!==null&&ue(te)},U=()=>{se!==null&&ue(se)},ge=v=>{if(!v)return;const R=v.lastIndexOf("-");if(R<=0)return;const Q=v.slice(0,R),fe=v.slice(R+1),De=Number(Q),Me=Number(fe)-1;if(!(Number.isInteger(De)&&Number.isInteger(Me)))return;const xe=rt(De,Me);ee(xe)&&ue(xe)},Ie=v=>{ge(v.target.value)},Ne=v=>{ge(v.target.value)},Fe=Xt(j),qe=a==="dropdown"&&!q?Ye("month",j,u,Z):"",Ze=T?Xt(T):void 0,be=L?Xt(L):void 0,Te=i.useMemo(()=>a!=="dropdown"?[]:Y!==null?Wa(Y,Z,u):T===null||L===null?[]:Wa(hl(T,L),Z,u),[a,Y,H,S,Z,u]),Pe=q?Fe:"",G=M?"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",oe=`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 ${G}`,me=`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 ${G}`;return D.jsxs("div",{className:`inline-flex items-center ${Br} ${b}`,style:d,"data-out-of-range":q?void 0:"true",children:[D.jsx(qt,{neighbour:"control",direction:"left",disabled:_,canStep:te!==null,onStep:E,ariaLabel:x}),a==="dropdown"?D.jsxs("select",{"aria-label":ce,disabled:_,className:me,value:Pe,onChange:Ne,children:[q?null:D.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:qe}),Te.map(v=>D.jsx("option",{value:v.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:v.label},v.value))]}):D.jsx("input",{"aria-label":ce,disabled:_,className:oe,value:Fe,min:Ze,max:be,onChange:Ie,type:"month"}),D.jsx(qt,{neighbour:"control",direction:"right",disabled:_,canStep:se!==null,onStep:U,ariaLabel:F}),o]})},xi=i.memo(bl,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,a=n?n.getFullYear()*12+n.getMonth():null;if(o!==a||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,h=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(f!==h||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||e.formatOption!==t.formatOption)});xi.displayName="MonthSelector";function vr(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 In(e,t,r){if(vr(e,"minDate",t),vr(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 Sn(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(vr(e,`${t}[0]`,r[0]),vr(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 Ln(e,t,r,n,o,a,l,c){const f=ne(r,n,c);if(f<ne(r,o,c)||f>ne(r,a,c))throw new RangeError(`${e}: ${t} must lie within ${l} (value: ${n.toISOString()}, lower: ${o.toISOString()}, upper: ${a.toISOString()})`)}function Tn(e,t,r,n,o,a,l,c){Ln(e,`${t}[0]`,r,n[0],o,a,l,c),Ln(e,`${t}[1]`,r,n[1],o,a,l,c)}function Xe(e,t,r){return e<t?t:e>r?r:e}function yn(e,t,r,n,o,a,l){if(r!==!0)return[];const c=e[0].getTime(),f=e[1].getTime();return St(n,t,o,a,l).filter(h=>h.getTime()>=c&&h.getTime()<=f)}function pr(e,t,r,n,o){if(n.length===0)return Xe(e,r[0],r[1]);const a=n[he(n,e,t,o)];return a.getTime()===e.getTime()?e:a}function bn(e,t,r,n,o){const a=pr(e[0],t,r,n,o),l=pr(e[1],t,r,n,o);return[a,l<a?a:l]}function Pn(e,t,r,n,o){const a=he(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function $n(e){const t=i.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(c=>Object.is(r[c],n[c]))||(t.current=e),t.current}function wl(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:l,formatOption:c,...f}=e,h=Dr("usePeriodSliderRange",l);In("usePeriodSliderRange",r,n),Sn("usePeriodSliderRange","initialRange",o),Tn("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",h);const p=$n(f),M=i.useRef(o),[b,d]=i.useState(o);let _=b;const x=[Xe(b[0],r,n),Xe(b[1],r,n)];(x[0]!==b[0]||x[1]!==b[1])&&(_=x,d(x));const F=i.useRef(_);F.current=_;const ce=i.useRef({minDate:r,maxDate:n,allowedDates:p.allowedDates});ce.current={minDate:r,maxDate:n,allowedDates:p.allowedDates};const Z=i.useRef(a);Z.current=a;const u=i.useCallback(L=>{const{minDate:H,maxDate:S}=ce.current,I=Xe(L[0],H,S),Y=Xe(L[1],H,S),ee=F.current;I.getTime()===ee[0].getTime()&&Y.getTime()===ee[1].getTime()||(F.current=[I,Y],d([I,Y]),Z.current?.(I,Y))},[]),X=i.useCallback(L=>{const H=F.current,S=L.getTime()>H[1].getTime()?L:H[1];u([L,S])},[u]),V=i.useCallback(L=>{const H=F.current,S=L.getTime()<H[0].getTime()?L:H[0];u([S,L])},[u]),O=i.useCallback((L,H)=>{u([L,H])},[u]),ie=i.useCallback(L=>{const{minDate:H,maxDate:S,allowedDates:I}=ce.current,Y=F.current,ee=St(I,t,H,S,h);if(ee.length>0){u([Pn(ee,t,Y[0],L,h),Pn(ee,t,Y[1],L,h)]);return}u([He(t,Y[0],L),He(t,Y[1],L)])},[t,u,h]),j=i.useCallback(()=>{u(M.current)},[u]),re=i.useMemo(()=>({value:_[0],onChange:X,minDate:r,maxDate:_[1],unit:t,yearStartMonth:h,locale:e.locale,formatOption:c}),[_[0],_[1],X,r,t,h]),K=i.useMemo(()=>({value:_[1],onChange:V,minDate:_[0],maxDate:n,unit:t,yearStartMonth:h,locale:e.locale,formatOption:c}),[_[0],_[1],V,n,t,h]),T=i.useMemo(()=>({...p,mode:"range",unit:t,yearStartMonth:h,range:_,minDate:r,maxDate:n,onChangeRange:O}),[p,t,_,r,n,O,h]);return{range:_,lowerDate:_[0],upperDate:_[1],setRange:d,setLowerDate:X,setUpperDate:V,shiftRange:ie,resetRange:j,startSelectorProps:re,endSelectorProps:K,sliderProps:T}}function pl(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:l,formatOption:c,...f}=e,h=Dr("usePeriodSliderPoint",l);In("usePeriodSliderPoint",r,n),vr("usePeriodSliderPoint","initialValue",o),Ln("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",h);const p=$n(f),M=i.useRef(o),[b,d]=i.useState(o);let _=b;const x=Xe(b,r,n);x!==b&&(_=x,d(x));const F=i.useRef(_);F.current=_;const ce=i.useRef({minDate:r,maxDate:n,allowedDates:p.allowedDates});ce.current={minDate:r,maxDate:n,allowedDates:p.allowedDates};const Z=i.useRef(a);Z.current=a;const u=i.useCallback(j=>{const{minDate:re,maxDate:K}=ce.current,T=Xe(j,re,K);T.getTime()!==F.current.getTime()&&(F.current=T,d(T),Z.current?.(T))},[]),X=i.useCallback(j=>{const{minDate:re,maxDate:K,allowedDates:T}=ce.current,L=St(T,t,re,K,h);if(L.length>0){u(Pn(L,t,F.current,j,h));return}u(He(t,F.current,j))},[t,u,h]),V=i.useCallback(()=>{u(M.current)},[u]),O=i.useMemo(()=>({value:_,onChange:u,minDate:r,maxDate:n,unit:t,yearStartMonth:h,locale:e.locale,formatOption:c}),[_,u,r,n,t,h,e.locale,c]),ie=i.useMemo(()=>({...p,mode:"point",unit:t,yearStartMonth:h,value:_,minDate:r,maxDate:n,onChangePoint:u}),[p,t,_,r,n,u,h]);return{value:_,setValue:d,shiftValue:X,resetValue:V,selectorProps:O,sliderProps:ie}}function vl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroRange:h,yearStartMonth:p,formatOption:M,...b}=e,d=Dr("useVernierSliderRange",p);In("useVernierSliderRange",r,n),Sn("useVernierSliderRange","initialMacroRange",o),Sn("useVernierSliderRange","initialMicroRange",a),Tn("useVernierSliderRange","initialMacroRange",l,o,r,n,"[minDate, maxDate]",d);const _=wt(l,c,o,r,n,d);Tn("useVernierSliderRange","initialMicroRange",c,a,_[0],_[1],"the initial macro window",d);const x=$n(b),F=i.useRef(o),ce=i.useRef(a),[Z,u]=i.useState(o),[X,V]=i.useState(a);let O=Z;const ie=[Xe(Z[0],r,n),Xe(Z[1],r,n)];(ie[0]!==Z[0]||ie[1]!==Z[1])&&(O=ie,u(ie));const j=i.useMemo(()=>wt(l,c,O,r,n,d),[l,c,O,r,n,d]),re=i.useMemo(()=>yn(j,c,x.microIsDiscrete,x.microAllowedDates??x.allowedDates,r,n,d),[j,c,x.microIsDiscrete,x.microAllowedDates,x.allowedDates,r,n,d]),K=i.useMemo(()=>x.macroIsDiscrete===!0?St(x.macroAllowedDates??x.allowedDates,l,r,n,d):[],[x.macroIsDiscrete,x.macroAllowedDates,x.allowedDates,l,r,n,d]),T=i.useRef(K);T.current=K;let L=X;const H=bn(X,c,j,re,d);(H[0]!==X[0]||H[1]!==X[1])&&(L=H,V(H));const S=i.useRef(O);S.current=O;const I=i.useRef(L);I.current=L;const Y=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates});Y.current={minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates};const ee=i.useRef(f);ee.current=f;const _e=i.useRef(h);_e.current=h;const ue=i.useCallback(v=>{const{minDate:R,maxDate:Q}=Y.current;return wt(l,c,v,R,Q,d)},[l,c,d]),B=i.useCallback(v=>{const{microIsDiscrete:R,microAllowedDates:Q,allowedDates:fe,minDate:De,maxDate:Me}=Y.current;return yn(v,c,R,Q??fe,De,Me,d)},[c,d]),q=i.useCallback((v,R)=>{const Q=S.current,fe=I.current;(v[0].getTime()!==Q[0].getTime()||v[1].getTime()!==Q[1].getTime())&&(S.current=v,u(v),ee.current?.(v[0],v[1])),(R[0].getTime()!==fe[0].getTime()||R[1].getTime()!==fe[1].getTime())&&(I.current=R,V(R),_e.current?.(R[0],R[1]))},[]),te=i.useCallback((v,R)=>{const{minDate:Q,maxDate:fe}=Y.current,De=[Xe(v,Q,fe),Xe(R,Q,fe)],Me=ue(De);q(De,bn(I.current,c,Me,B(Me),d))},[c,ue,B,q,d]),se=i.useCallback((v,R)=>{const Q=ue(S.current);q(S.current,bn([v,R],c,Q,B(Q),d))},[c,ue,B,q,d]),E=i.useCallback(v=>{const R=S.current[1],Q=v>R?v:R;te(v,Q)},[te]),U=i.useCallback(v=>{const R=S.current[0],Q=v<R?v:R;te(Q,v)},[te]),ge=i.useCallback(v=>{const R=I.current[1],Q=v>R?v:R;se(v,Q)},[se]),Ie=i.useCallback(v=>{const R=I.current[0],Q=v<R?v:R;se(Q,v)},[se]),Ne=i.useCallback(v=>{const{minDate:R,maxDate:Q}=Y.current,fe=S.current,De=T.current;if(De.length>0){const ut=he(De,fe[0],l,d)+v,nt=he(De,fe[1],l,d)+v;if(ut<0||nt>De.length-1)return;te(De[ut],De[nt]);return}const Me=He(l,fe[0],v),xe=He(l,fe[1],v);Me<R||xe>Q||te(Me,xe)},[l,te,d]),Fe=i.useCallback(v=>{const R=S.current,Q=I.current,fe=ue(R),[De,Me]=fe,xe=B(fe);if(xe.length>0){const Nt=he(xe,Q[0],c,d)+v,ve=he(xe,Q[1],c,d)+v;if(Nt<0||ve>xe.length-1)return;se(xe[Nt],xe[ve]);return}const ut=He(c,Q[0],v),nt=He(c,Q[1],v);ut<De||nt>Me||se(ut,nt)},[c,ue,B,se,d]),qe=i.useCallback(()=>{const v=F.current,R=ue(v);q(v,bn(ce.current,c,R,B(R),d))},[c,ue,B,q,d]),[Ze,be]=j,Te=i.useMemo(()=>({value:O[0],onChange:E,minDate:r,maxDate:O[1],unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,E,r,l,d,e.locale,M]),Pe=i.useMemo(()=>({value:O[1],onChange:U,minDate:O[0],maxDate:n,unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,U,n,l,d,e.locale,M]),G=i.useMemo(()=>({value:L[0],onChange:ge,minDate:Ze,maxDate:L[1],unit:c,yearStartMonth:d,locale:e.locale,formatOption:M}),[L,ge,Ze,c,d,e.locale,M]),oe=i.useMemo(()=>({value:L[1],onChange:Ie,minDate:L[0],maxDate:be,unit:c,yearStartMonth:d,locale:e.locale,formatOption:M}),[L,Ie,be,c,d,e.locale,M]),me=i.useMemo(()=>({...x,mode:"vernier",unit:t,yearStartMonth:d,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:O,microRange:L,onChangeMacroRange:te,onChangeMicroRange:se}),[x,t,l,c,r,n,O,L,te,se,d]);return{macroRange:O,setMacroRange:u,microRange:L,setMicroRange:V,setMacroLowerDate:E,setMacroUpperDate:U,setMicroLowerDate:ge,setMicroUpperDate:Ie,shiftMacroRange:Ne,shiftMicroRange:Fe,resetVernier:qe,macroStartSelectorProps:Te,macroEndSelectorProps:Pe,microStartSelectorProps:G,microEndSelectorProps:oe,sliderProps:me}}function Dl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroPoint:h,yearStartMonth:p,formatOption:M,...b}=e,d=Dr("useVernierSliderPoint",p);In("useVernierSliderPoint",r,n),Sn("useVernierSliderPoint","initialMacroRange",o),vr("useVernierSliderPoint","initialMicroValue",a),Tn("useVernierSliderPoint","initialMacroRange",l,o,r,n,"[minDate, maxDate]",d);const _=wt(l,c,o,r,n,d);Ln("useVernierSliderPoint","initialMicroValue",c,a,_[0],_[1],"the initial macro window",d);const x=$n(b),F=i.useRef(o),ce=i.useRef(a),[Z,u]=i.useState(o),[X,V]=i.useState(a);let O=Z;const ie=[Xe(Z[0],r,n),Xe(Z[1],r,n)];(ie[0]!==Z[0]||ie[1]!==Z[1])&&(O=ie,u(ie));const j=i.useMemo(()=>wt(l,c,O,r,n,d),[l,c,O,r,n,d]),re=i.useMemo(()=>yn(j,c,x.microIsDiscrete,x.microAllowedDates??x.allowedDates,r,n,d),[j,c,x.microIsDiscrete,x.microAllowedDates,x.allowedDates,r,n,d]),K=i.useMemo(()=>x.macroIsDiscrete===!0?St(x.macroAllowedDates??x.allowedDates,l,r,n,d):[],[x.macroIsDiscrete,x.macroAllowedDates,x.allowedDates,l,r,n,d]),T=i.useRef(K);T.current=K;let L=X;const H=pr(X,c,j,re,d);H!==X&&(L=H,V(H));const S=i.useRef(O);S.current=O;const I=i.useRef(L);I.current=L;const Y=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates});Y.current={minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates};const ee=i.useRef(f);ee.current=f;const _e=i.useRef(h);_e.current=h;const ue=i.useCallback(G=>{const{minDate:oe,maxDate:me}=Y.current;return wt(l,c,G,oe,me,d)},[l,c,d]),B=i.useCallback(G=>{const{microIsDiscrete:oe,microAllowedDates:me,allowedDates:v,minDate:R,maxDate:Q}=Y.current;return yn(G,c,oe,me??v,R,Q,d)},[c,d]),q=i.useCallback((G,oe)=>{const me=S.current,v=I.current;(G[0].getTime()!==me[0].getTime()||G[1].getTime()!==me[1].getTime())&&(S.current=G,u(G),ee.current?.(G[0],G[1])),oe.getTime()!==v.getTime()&&(I.current=oe,V(oe),_e.current?.(oe))},[]),te=i.useCallback((G,oe)=>{const{minDate:me,maxDate:v}=Y.current,R=[Xe(G,me,v),Xe(oe,me,v)],Q=ue(R);q(R,pr(I.current,c,Q,B(Q),d))},[c,ue,B,q,d]),se=i.useCallback(G=>{const oe=ue(S.current);q(S.current,pr(G,c,oe,B(oe),d))},[c,ue,B,q,d]),E=i.useCallback(G=>{const oe=S.current[1],me=G>oe?G:oe;te(G,me)},[te]),U=i.useCallback(G=>{const oe=S.current[0],me=G<oe?G:oe;te(me,G)},[te]),ge=i.useCallback(G=>{const{minDate:oe,maxDate:me}=Y.current,v=S.current,R=T.current;if(R.length>0){const De=he(R,v[0],l,d)+G,Me=he(R,v[1],l,d)+G;if(De<0||Me>R.length-1)return;te(R[De],R[Me]);return}const Q=He(l,v[0],G),fe=He(l,v[1],G);Q<oe||fe>me||te(Q,fe)},[l,te,d]),Ie=i.useCallback(G=>{const oe=S.current,me=ue(oe),v=B(me);if(v.length>0){se(Pn(v,c,I.current,G,d));return}se(He(c,I.current,G))},[c,ue,B,se,d]),Ne=i.useCallback(()=>{const G=F.current,oe=ue(G);q(G,pr(ce.current,c,oe,B(oe),d))},[c,ue,B,q,d]),[Fe,qe]=j,Ze=i.useMemo(()=>({value:O[0],onChange:E,minDate:r,maxDate:O[1],unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,E,r,l,d,e.locale,M]),be=i.useMemo(()=>({value:O[1],onChange:U,minDate:O[0],maxDate:n,unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,U,n,l,d,e.locale,M]),Te=i.useMemo(()=>({value:L,onChange:se,minDate:Fe,maxDate:qe,unit:c,yearStartMonth:d,locale:e.locale,formatOption:M}),[L,se,Fe,qe,c,d,e.locale,M]),Pe=i.useMemo(()=>({...x,mode:"vernier",unit:t,yearStartMonth:d,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:O,microValue:L,onChangeMacroRange:te,onChangeMicroPoint:se}),[x,t,l,c,r,n,O,L,te,se,d]);return{macroRange:O,setMacroRange:u,microValue:L,setMicroValue:V,setMacroLowerDate:E,setMacroUpperDate:U,setMicroDate:se,shiftMacroRange:ge,shiftMicroValue:Ie,resetVernier:Ne,macroStartSelectorProps:Ze,macroEndSelectorProps:be,microSelectorProps:Te,sliderProps:Pe}}function Ga(e,t){const r=new Date(e,t,1);return r.setFullYear(e),r}function Kt(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function wn(e,t){return e===void 0?null:Kt(e,t)}function pn(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 Xa(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 Ka(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Kt(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}const xl=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:l,minDate:c,maxDate:f,className:h="",style:p,disabled:M=!1,prevYearAriaLabel:b="Previous year",nextYearAriaLabel:d="Next year",selectAriaLabel:_="Year",locale:x,formatOption:F,yearStartMonth:ce}=e,Z=Dr("YearSelector",ce);pn(t,"value"),pn(r,"initialDate"),pn(c,"minDate"),pn(f,"maxDate"),Xa(a,"minYear"),Xa(l,"maxYear"),Ml(x);const u=t??r;if(u===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[X,V]=i.useState(()=>Kt(u,Z)),O=c?.getTime(),ie=f?.getTime(),j=i.useMemo(()=>Ka(a,c,Math.max,Z),[a,O,Z]),re=i.useMemo(()=>Ka(l,f,Math.min,Z),[l,ie,Z]);if(j===null||re===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(j>re)throw new RangeError(`YearSelector: the resolved lower bound ${j} is after the resolved upper bound ${re}.`);const K=t!==void 0,T=t!==void 0?Kt(t,Z):X,L=T<j||T>re,H=u.getTime();i.useEffect(()=>{K||V(Kt(u,Z))},[K,H,Z]);const S=q=>q>=j&&q<=re,I=q=>{if(!M){if(!S(q))throw new RangeError(`YearSelector: refusing to emit ${q}, which lies outside the declared bounds ${j}-${re}.`);K||V(q),n?.(Ga(q,Z),q)}},Y=S(T-1)?T-1:null,ee=S(T+1)?T+1:null,_e=()=>{Y!==null&&I(Y)},ue=()=>{ee!==null&&I(ee)},B=i.useMemo(()=>{const q=[];for(let te=re;te>=j;te--)q.push(te);return L&&(q.push(T),q.sort((te,se)=>se-te)),q.map(te=>({value:te,label:Ye("year",Ga(te,Z),F,x)}))},[j,re,L,T,Z,x,F]);return D.jsxs("div",{className:`inline-flex items-center ${Br} ${h}`,style:p,"data-out-of-range":L?"true":void 0,children:[D.jsx(qt,{neighbour:"control",direction:"left",disabled:M,canStep:Y!==null,onStep:_e,ariaLabel:b}),D.jsx("select",{"aria-label":_,disabled:M,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:T,onChange:q=>{if(!q.target.value)return;const te=Number(q.target.value);Number.isInteger(te)&&I(te)},children:B.map(q=>D.jsx("option",{value:q.value,disabled:L&&q.value===T,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:q.label},q.value))}),D.jsx(qt,{neighbour:"control",direction:"right",disabled:M,canStep:ee!==null,onStep:ue,ariaLabel:d}),o]})},Ri=i.memo(xl,(e,t)=>{const r=e.yearStartMonth??0,n=t.yearStartMonth??0;if(r!==n)return!1;const o=e.value??e.initialDate,a=t.value??t.initialDate,l=o?Kt(o,r):null,c=a?Kt(a,n):null;return!(l!==c||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||wn(e.minDate,r)!==wn(t.minDate,n)||wn(e.maxDate,r)!==wn(t.maxDate,n)||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale||e.formatOption!==t.formatOption)});Ri.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Ja;exports.DateSelector=Mi;exports.MonthSelector=xi;exports.PeriodSlider=hi;exports.YearSelector=Ri;exports.addUnit=He;exports.areStylesEqual=gi;exports.calculateConnectDragValues=ni;exports.calculateHandleDragValues=Mo;exports.calculateKeyboardActionValues=oi;exports.calculateLabelSlant=yo;exports.calculateVernierMacroDrag=mi;exports.calculateVernierMicroDrag=fi;exports.decode=le;exports.encode=ne;exports.findNearestDateIndex=he;exports.formatLabel=Ye;exports.formatOptionText=pi;exports.formatQuarterLabel=Os;exports.formatScreenReaderLabel=Wt;exports.getMacroWindowEndDate=ti;exports.getMacroWindowStartDate=ei;exports.getSortedAllowedDates=St;exports.normalizeDateByUnit=Oe;exports.resolveDraggedEdge=An;exports.resolveMacroWindow=wt;exports.resolveQuarter=ri;exports.resolveVernierRailZone=Po;exports.resolveVernierTargetHandle=di;exports.resolveWheelStep=ui;exports.usePeriodSliderPoint=pl;exports.usePeriodSliderRange=wl;exports.useVernierSliderPoint=Dl;exports.useVernierSliderRange=vl;