@aiquants/period-slider 0.10.1 → 0.10.2

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