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