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