@aiquants/period-slider 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/README.md +85 -40
- package/dist/DateSelector.d.ts +2 -2
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +2 -2
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +203 -15
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/StepperButton.d.ts +58 -0
- package/dist/StepperButton.d.ts.map +1 -0
- package/dist/YearSelector.d.ts +2 -2
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/dragPresentation.d.ts +191 -0
- package/dist/dragPresentation.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1964 -1683
- package/dist/rangeAreaWheel.d.ts +111 -0
- package/dist/rangeAreaWheel.d.ts.map +1 -0
- package/dist/styles/period-slider.css +1 -1
- package/dist/styles/period-slider.standalone.css +1 -1
- package/dist/usePeriodSlider.d.ts +15 -11
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/DateSelector.tsx +12 -28
- package/src/MonthSelector.tsx +13 -26
- package/src/PeriodSlider.tsx +1545 -572
- package/src/StepperButton.tsx +251 -0
- package/src/YearSelector.tsx +9 -23
- package/src/dragPresentation.ts +273 -0
- package/src/index.ts +8 -4
- package/src/rangeAreaWheel.ts +285 -0
- package/src/styles/period-slider.css +332 -108
- package/src/usePeriodSlider.ts +243 -90
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),Ne=require("date-fns"),a=require("react"),Wn={"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"}},gt=e=>e instanceof Date&&!Number.isNaN(e.getTime()),De=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),tt=(e,t)=>{if(!gt(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${De(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},ee=(e,t)=>{const r=tt(e,t),n=r.getFullYear(),o=r.getMonth()+1,s=r.getDate();if(e==="year")return n;if(e==="month")return n*12+(o-1);const i=new Date(0);return i.setUTCFullYear(n,o-1,s),i.setUTCHours(0,0,0,0),Math.floor(i.getTime()/(1440*60*1e3))},de=(e,t)=>{const r=new Date(0);if(r.setHours(0,0,0,0),e==="year")return r.setFullYear(t,0,1),r;if(e==="month"){const o=Math.floor(t/12),s=t-o*12;return r.setFullYear(o,s,1),r}const n=new Date(t*24*60*60*1e3);return r.setFullYear(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),r},ke=(e,t,r)=>{if(!gt(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${De(t)})`);return e==="year"?Ne.addYears(t,r):e==="month"?Ne.addMonths(t,r):Ne.addDays(t,r)},qe=(e,t,r)=>{if(!gt(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${De(r)})`);if(e===t)return tt(t,r);const n=r.getFullYear(),o=r.getMonth();if(e==="year"){if(t==="month")return new Date(n,11,1);if(t==="day")return new Date(n,11,31)}return e==="month"&&t==="day"?new Date(n,o+1,0):tt(t,r)},Oa={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Hn=new Map,Fa=(e,t)=>{const r=`${e}\0${t}`,n=Hn.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Oa[e]);return Hn.set(r,o),o},Ua=(e,t)=>{const r=String(t.getFullYear()).padStart(4,"0");if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const o=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${o}`},Ue=(e,t,r,n)=>gt(t)?r?r(t):n===void 0?Ua(e,t):Fa(e,n).format(t):"",St=(e,t,r,n)=>Ue(e,t,r,n),Te=(e,t,r)=>{if(!e||e.length===0||e.length===1)return 0;const n=ee(r,t);let o=0,s=e.length-1;if(n<=ee(r,e[o]))return 0;if(n>=ee(r,e[s]))return s;for(;o<=s;){const h=o+s>>1,f=ee(r,e[h]);if(f===n)return h;f<n?o=h+1:s=h-1}const i=Math.abs(ee(r,e[o])-n),c=Math.abs(ee(r,e[s])-n);return i<c?o:s},$t=(e,t,r,n)=>{if(!Array.isArray(e)||e.length===0)return[];const o=ee(t,r),s=ee(t,n),i=new Map;for(const c of e){const h=tt(t,c),f=ee(t,h);f<o||f>s||i.has(f)||i.set(f,h)}if(i.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${De(r)}, maxDate: ${De(n)}, entries: ${e.length})`);return Array.from(i.keys()).sort((c,h)=>c-h).map(c=>i.get(c))},Sr=(e,t,r,n)=>{const o=e.length-1;if(o<=0)return 0;const s=Te(e,n,t);if(r==="time"){const i=e[0].getTime(),c=e[o].getTime()-i;return c<=0?0:Math.max(0,Math.min(1,(e[s].getTime()-i)/c))}return s/o},Lr=(e,t,r,n)=>{const o=e.length-1;if(o<=0)return 0;const s=Math.max(0,Math.min(1,n));if(r==="time"){const i=e[0].getTime(),c=e[o].getTime()-i;return c<=0?0:Te(e,new Date(i+s*c),t)}return Math.max(0,Math.min(o,Math.round(s*o)))},nn=(e,t,r,n,o,s,i)=>{let c=r,h=n;return i?(c=t,h=t):e==="low"?t>n?(c=n,h=t):c=t:t<r?(h=r,c=t):h=t,[Math.max(o,Math.min(s,c)),Math.max(o,Math.min(s,h))]},Gn=(e,t,r,n,o)=>o?"low":e==="low"?t>n?"high":"low":t<r?"low":"high",Jn=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:s,sortedAllowedDates:i,snapMode:c,unit:h})=>{if(s){const E=i.length-1;if(E<=0)return[0,0];const W=Math.max(0,Math.min(E,Math.round(t))),y=Math.max(W,Math.min(E,Math.round(r)));if(c==="time"){const p=i[0].getTime(),F=i[E].getTime(),Y=i[W].getTime(),A=i[y].getTime()-Y;let V=Y+e*(F-p),j=V+A;V<p&&(V=p,j=p+A),j>F&&(j=F,V=F-A);const D=Te(i,new Date(V),h),$=Te(i,new Date(j),h);return[D,Math.max(D,$)]}const oe=Math.round(e*E);let R=W+oe,X=y+oe;return R<0&&(X+=-R,R=0),X>E&&(R-=X-E,X=E),[Math.max(0,Math.min(E,R)),Math.max(0,Math.min(E,X))]}const f=E=>Math.max(n,Math.min(o,E)),T=o-n;if(T<=0)return[f(t),f(r)];const v=Math.round(e*T);let d=t+v,P=r+v;return d<n&&(P+=n-d,d=n),P>o&&(d-=P-o,P=o),[f(d),f(P)]},Zn=(e,t,r,n,o,s,i,c)=>{let h=0,f=!1,T=!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":f=!0;break;case"End":T=!0;break;default:return null}if(i){let P=r;return f?P=o:T?P=s:P=Math.max(o,Math.min(s,r+h)),[P,P]}let v=r,d=n;return t==="low"?f?v=o:T?v=n:v=Math.max(o,Math.min(n,r+h)):f?d=r:T?d=s:d=Math.max(r,Math.min(s,n+h)),[v,d]},Qn=8,ea=2,ta=16,Ba=12,za=90,on=(e,t)=>{const r=t?.estimatedHeightPx??ta,o=Qn+(t?.anchorGapY??ea)+r/2,s=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:s,highOffsetY:s,isSlanted:!1,proximity:0}},ln=(e,t,r,n="top",o)=>{const s=o?.estimatedWidthPx,i=o?.estimatedHeightPx??ta,c=o?.paddingPx??Ba,h=o?.maxAngleDeg??za,f=Qn+(o?.anchorGapY??ea),T=on(n,o);if(!(Number.isFinite(r)&&r>0)||s===void 0||!Number.isFinite(s)||s<=0)return T;const v=Math.max(0,t-e)/100*r,d=s+c;if(v>=d)return T;const P=Math.max(0,Math.min(1,(d-v)/d)),W=P*P*P*(P*(P*6-15)+10)*h,y=n==="top"?-W:W,oe=W*Math.PI/180,R=s/2*Math.abs(Math.sin(oe))+i/2*Math.abs(Math.cos(oe)),X=f+R,p=n==="top"?-X:+X,F=s*Math.abs(Math.cos(oe))+i*Math.abs(Math.sin(oe)),Y=Math.max(0,(F+c-v)/2);return{lowAngleDeg:y,highAngleDeg:y,lowOffsetX:-Y,highOffsetX:Y,lowOffsetY:p,highOffsetY:p,isSlanted:P>.001,proximity:P}},ra=e=>({...e,lowOffsetX:0,highOffsetX:0});function na(e,t,r,n,o,s,i="macro-top",c=.05,h=!0,f="range"){const T=i==="macro-top"||i==="macro-left",v=t<=0;if(T&&v||!(T||v)){const E=Math.abs(e-r),W=Math.abs(e-n);return E<=c&&E<=W?"macro-low":W<=c&&W<E?"macro-high":h&&e>=r&&e<=n?"macro-connect":E<W?"macro-low":"macro-high"}if(f==="point")return"micro-point";const d=Math.abs(e-o),P=Math.abs(e-s);return d<=c&&d<=P?"micro-low":P<=c&&P<d?"micro-high":h&&e>=o&&e<=s?"micro-connect":d<P?"micro-low":"micro-high"}function aa(e,t,r,n,o){if(e==="macro-connect"){const i=t-r,c=o-n,h=Math.max(0,Math.min(1-c,n+i)),f=h+c;return[h,f,"macro-connect"]}if(e==="macro-low"){const i=Math.max(0,Math.min(1,t));return i>o?[o,i,"macro-high"]:[i,o,"macro-low"]}const s=Math.max(0,Math.min(1,t));return s<n?[s,n,"macro-low"]:[n,s,"macro-high"]}function oa(e,t,r,n,o){if(e==="micro-point"){const i=Math.max(0,Math.min(1,t));return[i,i,"micro-point"]}if(e==="micro-connect"){const i=t-r,c=o-n,h=Math.max(0,Math.min(1-c,n+i)),f=h+c;return[h,f,"micro-connect"]}if(e==="micro-low"){const i=Math.max(0,Math.min(1,t));return i>o?[o,i,"micro-high"]:[i,o,"micro-low"]}const s=Math.max(0,Math.min(1,t));return s<n?[s,n,"micro-low"]:[n,s,"micro-high"]}const cr=a.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,s;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",s=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",s=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return g.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:g.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});cr.displayName="VernierKnobSvg";const _a=(e,t)=>{if(!gt(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${De(e)})`);if(!gt(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${De(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${De(e)}, maxDate: ${De(t)})`)},Cr=(e,t)=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`PeriodSlider: ${e} is required and must be a [start, end] Date tuple (received: ${De(t)})`);const[r,n]=t;if(!gt(r))throw new RangeError(`PeriodSlider: ${e}[0] must be a valid Date (received: ${De(r)})`);if(!gt(n))throw new RangeError(`PeriodSlider: ${e}[1] must be a valid Date (received: ${De(n)})`);if(n.getTime()<r.getTime())throw new RangeError(`PeriodSlider: ${e} must not be inverted (start: ${De(r)}, end: ${De(n)})`)},an=(e,t)=>{if(!gt(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${De(t)})`)},Zr=(e,t,r,n)=>{if(t.getTime()<r.getTime()||t.getTime()>n.getTime())throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${De(t)}, minDate: ${De(r)}, maxDate: ${De(n)})`)},qa=(e,t,r)=>{if(e.mode==="range"){for(const n of["range","defaultRange"]){const o=e[n];o!==void 0&&(Cr(n,o),Zr(`${n}[0]`,o[0],t,r),Zr(`${n}[1]`,o[1],t,r))}return}if(e.mode==="point")for(const n of["value","defaultValue"]){const o=e[n];o!==void 0&&(an(n,o),Zr(n,o,t,r))}},Xa=e=>{Cr("macroRange",e.macroRange);const t=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,r=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(t&&r)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(r){if(e.microValue!==void 0)return an("microValue",e.microValue),{shape:"point",selection:[e.microValue,e.microValue]};if(e.defaultMicroValue!==void 0)return an("defaultMicroValue",e.defaultMicroValue),{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 Cr("microRange",e.microRange),{shape:"range",selection:e.microRange};if(e.defaultMicroRange!==void 0)return Cr("defaultMicroRange",e.defaultMicroRange),{shape:"range",selection:e.defaultMicroRange};throw t?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")},lr=(e,t,r,n,o,s,i,c)=>{const h=Te(e,n,t),f=Te(e,o,t);return i?h:c?f:Math.max(h,Math.min(f,Te(e,r,t)+s))},Qr=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Ka=(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)})`)}},qt=()=>{const[e,t]=a.useState(null),r=a.useRef(null),n=a.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const s=new ResizeObserver(i=>{for(const c of i){const h=c.borderBoxSize?.[0];h!==void 0&&t(f=>f!==null&&Math.abs(f.widthPx-h.inlineSize)<.5&&Math.abs(f.heightPx-h.blockSize)<.5?f:{widthPx:h.inlineSize,heightPx:h.blockSize})}});s.observe(o),r.current=s},[]);return a.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},en=(e,t)=>{if(!(e===null||t===null))return{estimatedWidthPx:Math.max(e.widthPx,t.widthPx),estimatedHeightPx:Math.max(e.heightPx,t.heightPx)}},jn=(e,t,r)=>({"--ps-tooltip-tx":`calc(-50% + ${e}px)`,"--ps-tooltip-ty":`${t}px`,"--ps-tooltip-rot":`${r}deg`}),On=(e,t,r,n,o,s,i)=>{const c=on(n,o);if(!i)return{slant:c,lowStyle:void 0,highStyle:void 0};const h=ln(e*100,t*100,r,n,o),f=s?ra(h):h;return{slant:f,lowStyle:jn(f.lowOffsetX,f.lowOffsetY-c.lowOffsetY,f.lowAngleDeg),highStyle:jn(f.highOffsetX,f.highOffsetY-c.highOffsetY,f.highAngleDeg)}},Wa={horizontal:{decrease:"◀",increase:"▶"},vertical:{decrease:"▼",increase:"▲"}},Ga={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"}},Ja=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:s="index",disabled:i=!1,className:c="",showStepper:h=!0,tooltipStyle:f="always",labelPosition:T="top",autoSlantLabels:v=!0,isVertical:d=!1,hideConnectBar:P=!1,showTicks:E=!1,colorScheme:W="blue-rose",locale:y,decreaseAriaLabel:oe="Decrease",increaseAriaLabel:R="Increase"}=e;_a(r,n),qa(e,r,n),y!==void 0&&Ka("locale",y);const X=e.mode==="vernier"?Xa(e):null,p=X!==null&&X.shape==="point",F=Wn[W],Y=a.useId(),A=a.useRef(e);A.current=e;const V=r.getTime(),j=n.getTime(),D=a.useMemo(()=>$t(o,t,r,n),[o,t,V,j]),$=D.length>0,{rangeMin:S,rangeMax:x}=a.useMemo(()=>$?{rangeMin:0,rangeMax:D.length-1}:{rangeMin:ee(t,r),rangeMax:ee(t,n)},[$,D,t,V,j]),_=e.mode==="point",te=a.useCallback(l=>{if($){const u=Math.max(0,Math.min(D.length-1,Math.round(l)));return D[u]}return de(t,Math.round(l))},[$,D,t]),G=a.useCallback(l=>{if(l===void 0)return S;const u=tt(t,l);return $?Te(D,u,t):ee(t,u)},[$,D,t,S]),[ue,Me]=a.useState(()=>X===null?null:X.selection);let ie=ue??(X===null?null:X.selection);if(p&&ie!==null&&ie[0].getTime()!==ie[1].getTime()){const l=[ie[0],ie[0]];ie=l,Me(l)}const re=e.mode==="vernier"?e.microValue?.getTime():void 0,Q=a.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,re]),he=e.mode!=="vernier"?null:p?Q??ie:e.microRange!==void 0?e.microRange:ie,Xe=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?he?.[0]:void 0,q=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?he?.[1]:void 0,J=e.mode==="point"?e.value??e.defaultValue:void 0,le=e.mode==="point"?J?.getTime():Xe?.getTime(),N=e.mode==="range"?q?.getTime():le,[U,se]=a.useMemo(()=>{if(e.mode==="point"){const m=G(J);return[m,m]}const l=G(Xe),u=G(q);return[Math.min(l,u),Math.max(l,u)]},[e.mode,le,N,G,J,Xe,q]),ge=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:p?e.microValue!==void 0:e.microRange!==void 0,[Se,Be]=a.useState(()=>[U,se]),[Ke,rt]=a.useState(null),[ae,pe]=a.useState(null),Ye=a.useRef(null);Ye.current=ae;const[kt,K]=a.useState("high"),[ce,ht]=a.useState(null),[nt,ct]=a.useState(null),fe=Ke?Ke[0]:ge?U:Se[0],be=Ke?Ke[1]:ge?se:Se[1],Wt=a.useRef([fe,be]);Wt.current=[fe,be];const me=e.mode==="vernier",Ct=e.mode==="vernier"?e.vernierOrientation??(d?"macro-left":"macro-top"):"macro-top",C=Ct==="macro-top"||Ct==="macro-left",Hr=e.mode==="vernier"?e.showVernierProjection??!0:!1,jr=e.mode==="vernier"?e.showVernierTicks??!0:!1,ut=e.mode==="vernier"?e.showHairline??!0:!1,O=me?e.macroUnit??t:t,w=me?e.microUnit??t:t,b=me?e.macroIsDiscrete??!1:$,I=me?e.microIsDiscrete??!1:$,Ee=me?e.macroAllowedDates??o:o,Nt=me?e.microAllowedDates??o:o,at=me?e.formatMacroLabel??e.formatLabel:e.formatLabel,We=me?e.formatMicroLabel??e.formatLabel:e.formatLabel,sn=e.mode==="vernier"?e.macroRange[0].getTime():void 0,cn=e.mode==="vernier"?e.macroRange[1].getTime():void 0,da=Xe?.getTime(),ma=q?.getTime(),[Ve,dr]=a.useState(null),bt=a.useRef(null);bt.current=Ve;const[Gt,Yt]=a.useState(()=>p?"micro-point":"micro-high");let Le=Gt;const Or=p?Gt==="micro-low"||Gt==="micro-high"||Gt==="micro-connect"?"micro-point":null:Gt==="micro-point"?"micro-high":null;Or!==null&&(Le=Or,Yt(Or));const ze=a.useMemo(()=>ee(O,r),[V,O]),At=a.useMemo(()=>{const l=ee(O,n);if(me&&l<=ze)throw new RangeError(`PeriodSlider: macroUnit "${O}" cannot distinguish minDate from maxDate (minDate: ${De(r)}, maxDate: ${De(n)})`);return l},[me,V,j,ze,O]),Pe=a.useMemo(()=>me?$t(Ee,O,r,n):[],[me,Ee,O,V,j]),Ie=a.useMemo(()=>e.mode!=="vernier"?ze:ee(O,e.macroRange[0]),[e.mode,sn,ze,O]),He=a.useMemo(()=>e.mode!=="vernier"?At:ee(O,e.macroRange[1]),[e.mode,cn,At,O]),mr=a.useMemo(()=>de(O,Ie),[O,Ie]),fr=a.useMemo(()=>de(O,He),[O,He]),Re=a.useMemo(()=>e.mode!=="vernier"?ee(w,r):Math.max(ee(w,e.macroRange[0]),ee(w,r)),[e.mode,sn,w,V]),je=a.useMemo(()=>e.mode!=="vernier"?ee(w,n):Math.min(ee(w,qe(O,w,e.macroRange[1])),ee(w,n)),[e.mode,cn,O,w,j]),ne=a.useMemo(()=>me?$t(Nt,w,r,n).filter(u=>{const m=ee(w,u);return m>=Re&&m<=je}):[],[me,Nt,w,V,j,Re,je]),Et=b&&Pe.length>0,Ze=I&&ne.length>0,we=a.useMemo(()=>he===null?Re:ee(w,he[0]),[da,Re,w,he]),ye=a.useMemo(()=>he===null?je:ee(w,he[1]),[ma,je,w,he]),Mt=a.useMemo(()=>de(w,we),[w,we]),wt=a.useMemo(()=>de(w,ye),[w,ye]),Jt=Math.max(1,At-ze),$e=Et?Sr(Pe,O,s,mr):Math.max(0,Math.min(1,(Ie-ze)/Jt)),Oe=Math.max($e,Et?Sr(Pe,O,s,fr):Math.min(1,(He-ze)/Jt)),Zt=Math.max(1,je-Re),Ge=Ze?Sr(ne,w,s,Mt):Math.max(0,Math.min(1,(we-Re)/Zt)),dt=Math.max(Ge,Ze?Sr(ne,w,s,wt):Math.min(1,(ye-Re)/Zt)),Fr=a.useRef({timerId:null,emit:null}),Ur=a.useRef({timerId:null,emit:null}),Br=a.useRef({timerId:null,emit:null});a.useEffect(()=>{const l=[Fr,Ur,Br];return()=>{for(const u of l)Qr(u.current)}},[]);const Vt=a.useCallback((l,u,m)=>{Qr(l);const{debounceMs:M}=A.current;if(m||!M||M<=0){u();return}l.emit=u,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,u()},M)},[]),zr=a.useCallback(l=>{const u=l.emit;Qr(l),u?.()},[]),It=a.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),V),j)),[V,j]),ot=a.useCallback((l,u,m=!1)=>{const[M,L]=Wt.current;if((A.current.mode==="point"?l===M:l===M&&u===L)&&Fr.current.timerId===null)return;const z=te(l),H=te(u),Z=()=>{const k=A.current;k.mode==="point"?k.onChangePoint?.(z):k.mode==="range"&&k.onChangeRange?.(z,H)};Vt(Fr.current,Z,m)},[te,Vt]),Ht=a.useCallback((l,u,m=!1)=>{if(A.current.mode!=="vernier")return;const M=It(l),L=It(u);Vt(Ur.current,()=>{const B=A.current;B.mode==="vernier"&&B.onChangeMacroRange?.(M,L)},m)},[It,Vt]),_e=a.useCallback((l,u,m=!1)=>{const M=A.current;if(M.mode!=="vernier")return;const L=It(l),B=It(u);(p?M.microValue===void 0:M.microRange===void 0)&&Me([L,B]),Vt(Br.current,()=>{const z=A.current;if(z.mode==="vernier"){if(p){z.onChangeMicroPoint?.(L);return}z.onChangeMicroRange?.(L,B)}},m)},[It,Vt,p]),un=a.useCallback((l,u=!1)=>{_e(l,l,u)},[_e]),gr=a.useCallback(l=>{if($&&s==="time"&&D.length>1){const M=Math.max(0,Math.min(D.length-1,Math.round(l))),L=D[0].getTime(),z=D[D.length-1].getTime()-L;if(z<=0)return 0;const H=D[M].getTime();return Math.max(0,Math.min(100,(H-L)/z*100))}const u=x-S;if(u<=0)return 0;const m=(l-S)/u*100;return Math.max(0,Math.min(100,m))},[$,s,D,S,x]),hr=a.useCallback(l=>{const u=Math.max(0,Math.min(100,l));if($){if(s==="time"&&D.length>1){const L=D[0].getTime(),z=D[D.length-1].getTime()-L,H=L+u/100*z;return Te(D,new Date(H),t)}const M=Math.round(u/100*(D.length-1));return Math.max(0,Math.min(D.length-1,M))}const m=S+u/100*(x-S);return Math.round(m)},[$,s,D,S,x,t]),mt=a.useRef(null),[jt,dn]=a.useState(0),[fa,Qt]=qt(),[ga,mn]=qt(),[ha,fn]=qt(),[ba,gn]=qt(),[Ma,hn]=qt(),[wa,bn]=qt();a.useEffect(()=>{const l=mt.current;if(!l)return;const u=()=>{const m=l.getBoundingClientRect(),M=d?m.height:m.width;M>0&&dn(L=>Math.abs(L-M)<.5?L:M)};if(u(),typeof ResizeObserver<"u"){const m=new ResizeObserver(M=>{for(const L of M){const B=d?L.contentRect.height:L.contentRect.width;B>0&&dn(z=>Math.abs(z-B)<.5?z:B)}});return m.observe(l),()=>m.disconnect()}return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[d]);const Tt=a.useCallback((l,u,m)=>{const M=d?m.height:m.width;if(!(Number.isFinite(M)&&M>0))return null;const L=d?m.bottom-u:l-m.left;return Number.isFinite(L)?Math.max(0,Math.min(1,L/M)):null},[d]),Mn=a.useCallback((l,u)=>{const m=mt.current;if(!m)return null;const M=Tt(l,u,m.getBoundingClientRect());return M===null?null:M*100},[Tt]),br=a.useRef(null),_r=a.useRef(null),it=a.useRef(null),qr=a.useRef(null),er=a.useRef(null),wn=a.useCallback(l=>{if(i)return;if(me){const k=_r.current;if(!k||l.pointerId!==0&&l.pointerId!==k.pointerId||!mt.current)return;const xe=Tt(l.clientX,l.clientY,mt.current.getBoundingClientRect());if(xe===null)return;if(k.handle==="macro-low"||k.handle==="macro-high"||k.handle==="macro-connect"){const[Qe,vt,Ae]=aa(k.handle,xe,k.startPointerRatio,k.startMacroLowRatio,k.startMacroHighRatio);Ae!==bt.current&&(bt.current=Ae,dr(Ae),Yt(Ae));let ve,et;if(Et){const pt=Lr(Pe,O,s,Qe),yt=Math.max(pt,Lr(Pe,O,s,vt));ve=Pe[pt],et=Pe[yt]}else{const pt=Math.round(ze+Qe*Jt),yt=Math.round(ze+vt*Jt);ve=de(O,pt),et=de(O,yt)}const nr=`${ve.getTime()}_${et.getTime()}`;nr!==qr.current&&(qr.current=nr,Ht(ve,et));let ft,Dt;if(k.handle==="macro-connect"){const pt=tt(w,ve),yt=qe(O,w,et);let Bt,zt;if(O==="year"){const Rt=ve.getFullYear()-k.startMacroLowDate.getFullYear();Bt=ke("year",k.initialMicroLowDate,Rt),zt=ke("year",k.initialMicroHighDate,Rt)}else if(O==="month"){const Rt=(ve.getFullYear()-k.startMacroLowDate.getFullYear())*12+(ve.getMonth()-k.startMacroLowDate.getMonth());Bt=ke("month",k.initialMicroLowDate,Rt),zt=ke("month",k.initialMicroHighDate,Rt)}else{const Rt=Math.round((ve.getTime()-k.startMacroLowDate.getTime())/864e5);Bt=ke("day",k.initialMicroLowDate,Rt),zt=ke("day",k.initialMicroHighDate,Rt)}const _t=pt.getTime(),ar=yt.getTime(),In=k.initialMicroHighDate.getTime()-k.initialMicroLowDate.getTime();let or=Bt.getTime(),ir=zt.getTime();or<_t&&(or=_t,ir=Math.min(ar,or+In)),ir>ar&&(ir=ar,or=Math.max(_t,ir-In)),ft=tt(w,new Date(or)),Dt=tt(w,new Date(ir))}else{const pt=ve.getTime(),yt=qe(O,w,et).getTime(),Bt=k.initialMicroLowDate.getTime(),zt=k.initialMicroHighDate.getTime(),_t=Math.max(pt,Math.min(yt,Bt)),ar=Math.max(_t,Math.min(yt,zt));ft=tt(w,new Date(_t)),Dt=tt(w,new Date(ar))}const Vn=`${ft.getTime()}_${Dt.getTime()}`;Vn!==er.current&&(er.current=Vn,_e(ft,Dt))}else if(k.handle==="micro-low"||k.handle==="micro-high"||k.handle==="micro-connect"||k.handle==="micro-point"){const[Qe,vt,Ae]=oa(k.handle,xe,k.startPointerRatio,k.startMicroLowRatio,k.startMicroHighRatio);Ae!==bt.current&&(bt.current=Ae,dr(Ae),Yt(Ae));let ve,et;if(Ze){const ft=Lr(ne,w,s,Qe),Dt=Math.max(ft,Lr(ne,w,s,vt));ve=ne[ft],et=ne[Dt]}else{const ft=Math.round(Re+Qe*Zt),Dt=Math.round(Re+vt*Zt);ve=de(w,ft),et=de(w,Dt)}const nr=`${ve.getTime()}_${et.getTime()}`;nr!==er.current&&(er.current=nr,_e(ve,et))}return}const u=br.current;if(!u||l.pointerId!==0&&l.pointerId!==u.pointerId||!mt.current)return;const m=mt.current.getBoundingClientRect(),M=d?l.clientY:l.clientX,L=d?m.height:m.width;if(!(Number.isFinite(L)&&L>0))return;if(u.handle==="connect"){const k=d?(u.startPointerPos-M)/L:(M-u.startPointerPos)/L,xe=Jn({posDiffPct:k,startLowVal:u.startLowVal,startHighVal:u.startHighVal,rangeMin:S,rangeMax:x,isDiscrete:$,sortedAllowedDates:D,snapMode:s,unit:t});if(it.current&&it.current[0]===xe[0]&&it.current[1]===xe[1])return;it.current=xe,rt(xe),ot(xe[0],xe[1],!1);return}const B=Tt(l.clientX,l.clientY,m);if(B===null)return;const z=hr(B*100),[H,Z]=nn(u.handle,z,u.startLowVal,u.startHighVal,S,x,_);if((!it.current||it.current[0]!==H||it.current[1]!==Z)&&(it.current=[H,Z],rt([H,Z]),ot(H,Z,!1)),!_&&(u.handle==="low"||u.handle==="high")){const k=Gn(u.handle,z,u.startLowVal,u.startHighVal,_);Ye.current!==k&&(Ye.current=k,pe(k),K(k))}},[i,me,d,O,w,Et,Ze,Pe,ne,ze,Jt,Re,Zt,S,x,$,D,s,t,Tt,hr,ot,Ht,_e,_]),xn=a.useCallback(l=>{if(me){qr.current=null,er.current=null,_r.current=null,bt.current=null,dr(null),zr(Ur.current),zr(Br.current);return}const u=br.current;if(!u||l.pointerId!==0&&l.pointerId!==u.pointerId)return;const m=it.current??Ke;m&&(ot(m[0],m[1],!0),Be(m)),it.current=null,rt(null),br.current=null,Ye.current=null,pe(null)},[me,Ke,ot,zr]),vn=a.useRef(wn);vn.current=wn;const Dn=a.useRef(xn);Dn.current=xn;const pn=ae!==null||Ve!==null;a.useEffect(()=>{if(!pn)return;const l=m=>vn.current(m),u=m=>Dn.current(m);return window.addEventListener("pointermove",l),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[pn]);const Xr=a.useCallback((l,u,m)=>{br.current={pointerId:l,handle:u,startPointerPos:m,startLowVal:fe,startHighVal:be},Ye.current=u,pe(u),u!=="connect"&&K(u)},[fe,be]),yn=a.useCallback((l,u,m)=>{const M=A.current;M.mode==="vernier"&&(_r.current={pointerId:l,handle:u,startPointerRatio:m,startMacroLowRatio:$e,startMacroHighRatio:Oe,startMicroLowRatio:Ge,startMicroHighRatio:dt,startMacroLowEnc:Ie,startMacroHighEnc:He,startMicroLowEnc:we,startMicroHighEnc:ye,startMacroLowDate:M.macroRange[0],startMacroHighDate:M.macroRange[1],initialMicroLowDate:Mt,initialMicroHighDate:wt},bt.current=u,dr(u),Yt(u))},[$e,Oe,Ge,dt,Ie,He,we,ye,Mt,wt]),Rn=l=>u=>{if(i)return;u.stopPropagation(),u.preventDefault(),K(l);const m=d?u.clientY:u.clientX;Xr(u.pointerId,l,m)},Tn=l=>()=>{i||Ye.current!==null||K(l)},Mr=l=>()=>{i||bt.current!==null||Yt(l)},Ot=l=>u=>{if(i)return;u.stopPropagation(),u.preventDefault();const m=mt.current;if(!m)return;const M=Tt(u.clientX,u.clientY,m.getBoundingClientRect());M!==null&&yn(u.pointerId,l,M)},xa=l=>{if(i||P)return;l.stopPropagation(),l.preventDefault();const u=d?l.clientY:l.clientX;Xr(l.pointerId,"connect",u)},va=l=>{if(i)return;if(me){const H=mt.current;if(!H)return;const Z=H.getBoundingClientRect(),k=Tt(l.clientX,l.clientY,Z);if(k===null)return;const xe=d?l.clientX-(Z.left+Z.width/2):l.clientY-(Z.top+Z.height/2),Qe=na(k,xe,$e,Oe,Ge,dt,Ct,void 0,!P,p?"point":"range");yn(l.pointerId,Qe,k);return}const u=Mn(l.clientX,l.clientY);if(u===null)return;const m=hr(u);let M="low";if(!_){const H=Math.abs(m-fe),Z=Math.abs(m-be);H<Z?M="low":Z<H?M="high":M=m>be?"high":"low"}K(M);const[L,B]=nn(M,m,fe,be,S,x,_);rt([L,B]),ot(L,B,!0);const z=d?l.clientY:l.clientX;Xr(l.pointerId,M,z)},Da=l=>{if(i||ae!==null)return;const u=Mn(l.clientX,l.clientY);if(u===null)return;const m=hr(u);ht(m),ct(gr(m))},pa=()=>{ht(null),ct(null)},Sn=l=>u=>{if(i)return;K(l);const m=Zn(u.key,l,fe,be,S,x,_,1);m&&(u.preventDefault(),ge||Be(m),ot(m[0],m[1],!0))},wr=(l,u)=>{const m=Math.max(ee(w,l),ee(w,r)),M=Math.min(ee(w,qe(O,w,u)),ee(w,n)),L=Math.max(m,Math.min(M,we)),B=Math.max(L,Math.min(M,ye));L===we&&B===ye||_e(de(w,L),de(w,B),!0)},xr=l=>u=>{if(i||!me||e.mode!=="vernier")return;Yt(l);let m=0,M=!1,L=!1;switch(u.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":M=!0;break;case"End":L=!0;break;default:return}if(u.preventDefault(),l==="macro-low"){const B=de(O,Ie),z=de(O,He);if(Et){const k=lr(Pe,O,B,Pe[0],z,m,M,L);if(k===Te(Pe,B,O))return;const xe=Pe[k];Ht(xe,z,!0),wr(xe,z);return}let H;if(M?H=ze:L?H=He:H=Math.max(ze,Math.min(He,Ie+m)),H===Ie)return;const Z=de(O,H);Ht(Z,z,!0),wr(Z,z)}else if(l==="macro-high"){const B=de(O,Ie),z=de(O,He);if(Et){const k=lr(Pe,O,z,B,Pe[Pe.length-1],m,M,L);if(k===Te(Pe,z,O))return;const xe=Pe[k];Ht(B,xe,!0),wr(B,xe);return}let H;if(M?H=Ie:L?H=At:H=Math.max(Ie,Math.min(At,He+m)),H===He)return;const Z=de(O,H);Ht(B,Z,!0),wr(B,Z)}else if(l==="micro-low"){const B=de(w,we),z=de(w,ye);if(Ze){const Z=lr(ne,w,B,ne[0],z,m,M,L);if(Z===Te(ne,B,w))return;_e(ne[Z],z,!0);return}let H;if(M?H=Re:L?H=ye:H=Math.max(Re,Math.min(ye,we+m)),H===we)return;_e(de(w,H),z,!0)}else if(l==="micro-high"){const B=de(w,we),z=de(w,ye);if(Ze){const Z=lr(ne,w,z,B,ne[ne.length-1],m,M,L);if(Z===Te(ne,z,w))return;_e(B,ne[Z],!0);return}let H;if(M?H=we:L?H=je:H=Math.max(we,Math.min(je,ye+m)),H===ye)return;_e(B,de(w,H),!0)}else if(l==="micro-point"){const B=de(w,we);if(Ze){const H=lr(ne,w,B,ne[0],ne[ne.length-1],m,M,L);if(H===Te(ne,B,w))return;un(ne[H],!0);return}let z;if(M?z=Re:L?z=je:z=Math.max(Re,Math.min(je,we+m)),z===we)return;un(de(w,z),!0)}},ya=a.useCallback(l=>{const u=A.current;if(!u.disabled)if(u.mode==="point"){const m=Math.max(S,Math.min(x,fe+l));ge||Be([m,m]),ot(m,m,!0)}else if(u.mode==="vernier"){if(Ze){const k=ne.length-1,xe=Te(ne,Mt,w),Qe=Te(ne,wt,w),vt=Qe-xe;let Ae=xe+l,ve=Qe+l;l<0&&Ae<0?(Ae=0,ve=Math.min(k,vt)):l>0&&ve>k&&(ve=k,Ae=Math.max(0,k-vt)),(Ae!==xe||ve!==Qe)&&_e(ne[Ae],ne[ve],!0);return}const m=we,M=ye,L=Re,B=je,z=M-m;let H=m+l,Z=M+l;l<0&&H<L?(H=L,Z=Math.min(B,H+z)):l>0&&Z>B&&(Z=B,H=Math.max(L,Z-z)),(H!==m||Z!==M)&&_e(de(w,H),de(w,Z),!0)}else{const m=be-fe;let M=fe+l,L=be+l;l<0&&M<S?(M=S,L=Math.min(x,M+m)):l>0&&L>x&&(L=x,M=Math.max(S,L-m)),M<=L&&(ge||Be([M,L]),ot(M,L,!0))}},[fe,be,S,x,ge,ot,_e,we,ye,Re,je,w,Ze,ne,Mt,wt]),Ft=gr(fe),Ut=gr(be),Kr=te(fe),Wr=te(be),Gr=a.useMemo(()=>_?Qt===null?void 0:{estimatedWidthPx:Qt.widthPx,estimatedHeightPx:Qt.heightPx}:en(Qt,mn),[_,Qt,mn]),vr=!_&&fe===be,Fe=a.useMemo(()=>{if(_||!v||d)return on(T,Gr);const l=ln(Ft,Ut,jt,T,Gr);return vr?ra(l):l},[_,vr,v,d,Ft,Ut,jt,T,Gr]),tr=ae==="low"||ae!=="high"&&kt==="low",rr=!_&&(ae==="high"||ae!=="low"&&kt==="high"),Dr=Ie===He,pr=!p&&we===ye,Ra=Dr&&Le!=="macro-low",Ta=Dr&&Le==="macro-low",Sa=pr&&Le!=="micro-low",La=pr&&Le==="micro-low",Ln=C?"top":"bottom",Pn=C?"bottom":"top",$n=a.useMemo(()=>en(fn,gn),[fn,gn]),kn=a.useMemo(()=>en(hn,bn),[hn,bn]),Jr=v&&!d,yr=a.useMemo(()=>On($e,Oe,jt,Ln,$n,Dr,Jr),[$e,Oe,jt,Ln,$n,Dr,Jr]),Cn=Jr&&!p,Rr=a.useMemo(()=>On(Ge,dt,jt,Pn,kn,pr,Cn),[Ge,dt,jt,Pn,kn,pr,Cn]),Pa=a.useMemo(()=>d?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${Fe.lowOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${Fe.lowOffsetY}px)`,"--ps-tooltip-rot":`${Fe.lowAngleDeg}deg`},[d,Fe.lowOffsetX,Fe.lowOffsetY,Fe.lowAngleDeg]),$a=a.useMemo(()=>d?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${Fe.highOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${Fe.highOffsetY}px)`,"--ps-tooltip-rot":`${Fe.highAngleDeg}deg`},[d,Fe.highOffsetX,Fe.highOffsetY,Fe.highAngleDeg]),Tr=Math.min(Ft,Ut),Nn=Math.max(Ft,Ut),ka=d?{bottom:`${Tr}%`,height:`${Nn-Tr}%`,top:"auto",left:"0",right:"0"}:{left:`${Tr}%`,width:`${Nn-Tr}%`,top:"0",bottom:"0"},Ca=Math.max(.01,Oe-$e),Yn=Math.max(.06,Math.min(.25,.28*Math.sqrt(Ca))),Na=d?{bottom:`${Ft}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:tr?40:30}:{left:`${Ft}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:tr?40:30},Ya=d?{bottom:`${Ut}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:rr?40:30}:{left:`${Ut}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:rr?40:30},Aa=d?{bottom:`${nt}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${nt}%`,top:"50%",transform:"translate(-50%, -50%)"},An=ce!==null?te(ce):null,Ea=f!=="hover"&&ce!==null&&(ce===fe||!_&&ce===be),Va=Ze?ee(w,ne[0]):Re,Ia=Ze?ee(w,ne[ne.length-1]):je,Ha=i||(me?we<=Va:_?fe<=S:fe<=S&&be<=S),ja=i||(me?ye>=Ia:(_||fe>=x)&&be>=x),lt=p?"micro-point":"micro-low",xt=i?"cursor-not-allowed opacity-50":"cursor-pointer",En=l=>{const u=d?"vertical":"horizontal",m=l==="decrease",M=Ga[u][l];return g.jsx("button",{type:"button",className:`period-slider-stepper-btn relative after:absolute after:inset-[-11px] after:content-[''] ${M} flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-300 bg-white font-bold text-[10px] text-slate-700 leading-none shadow-2xs transition-all hover:bg-slate-100 hover:text-indigo-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 ${xt}`,onClick:()=>ya(m?-1:1),disabled:m?Ha:ja,"aria-label":m?oe:R,children:Wa[u][l]})};return g.jsxs("div",{style:e.style,className:`period-slider flex select-none items-center gap-2 ${d?"flex-col":"flex-row"} ${c}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":d?"vertical":"horizontal","data-label-position":T,"data-color-scheme":W,children:[h&&En(d?"increase":"decrease"),g.jsx("div",{ref:mt,"data-testid":"period-slider-track","data-orientation":d?"vertical":"horizontal","data-vernier-orientation":me?Ct:void 0,className:`period-slider-track relative flex-1 touch-none rounded-full bg-slate-200 dark:bg-slate-700 ${d?"h-48 w-2":"h-2 w-full"} ${xt}`,onPointerDown:va,onPointerMove:Da,onPointerLeave:pa,children:me?g.jsxs(g.Fragment,{children:[Hr&&(d?g.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:[g.jsx("defs",{children:g.jsxs("linearGradient",{id:Y,x1:"0",y1:"0",x2:"1",y2:"0",children:[g.jsx("stop",{offset:"0%",stopColor:C?F.macro:F.micro,stopOpacity:"0.28"}),g.jsx("stop",{offset:"100%",stopColor:C?F.micro:F.macro,stopOpacity:Yn})]})}),g.jsx("polygon",{points:C?`12,${(1-Oe)*100} 12,${(1-$e)*100} 20,100 20,0`:`12,0 12,100 20,${(1-$e)*100} 20,${(1-Oe)*100}`,fill:`url(#${Y})`})]}):g.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[g.jsx("defs",{children:g.jsxs("linearGradient",{id:Y,x1:"0",y1:"0",x2:"0",y2:"1",children:[g.jsx("stop",{offset:"0%",stopColor:C?F.macro:F.micro,stopOpacity:"0.28"}),g.jsx("stop",{offset:"100%",stopColor:C?F.micro:F.macro,stopOpacity:Yn})]})}),g.jsx("polygon",{points:C?`${$e*100},12 ${Oe*100},12 100,20 0,20`:`0,12 100,12 ${Oe*100},20 ${$e*100},20`,fill:`url(#${Y})`})]})),!P&&g.jsxs(g.Fragment,{children:[g.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:d?{bottom:`calc(${$e*100}% - 8px)`,height:`calc(${Math.max(0,(Oe-$e)*100)}% + 16px)`}:{left:`calc(${$e*100}% - 8px)`,width:`calc(${Math.max(0,(Oe-$e)*100)}% + 16px)`},onPointerDown:Ot("macro-connect")}),!p&&g.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:d?{bottom:`calc(${Ge*100}% - 8px)`,height:`calc(${Math.max(0,(dt-Ge)*100)}% + 16px)`}:{left:`calc(${Ge*100}% - 8px)`,width:`calc(${Math.max(0,(dt-Ge)*100)}% + 16px)`},onPointerDown:Ot("micro-connect")})]}),jr&&g.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(l=>g.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:d?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`macro-tick-${l}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(l=>g.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:d?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`micro-tick-${l}`))]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":i?"true":void 0,"aria-valuemin":ze,"aria-valuemax":He,"aria-valuenow":Ie,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(mr,O):St(O,mr,at,y),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?C?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":C?"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0":"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${xt}`,style:d?{bottom:`${$e*100}%`,left:C?0:"auto",right:C?"auto":0,transform:C?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Ve==="macro-low"||Le==="macro-low"?30:15}:{left:`${$e*100}%`,top:C?0:"auto",bottom:C?"auto":0,transform:C?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Ve==="macro-low"||Le==="macro-low"?30:15},onPointerDown:Ot("macro-low"),onKeyDown:xr("macro-low"),onFocus:Mr("macro-low"),"data-active":Ve==="macro-low"?"true":void 0,"data-front":Le==="macro-low"?"true":void 0,"data-vernier-pos":d?C?"left":"right":C?"top":"bottom","data-handle-type":"macro-low",children:[g.jsx(cr,{type:"macro",isTop:C,isVertical:d,isLeft:C}),ut&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":Ra?"true":void 0,"data-slanted":yr.slant.isSlanted?"true":void 0,ref:ha,style:yr.lowStyle,children:Ue(O,mr,at,y)})]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":i?"true":void 0,"aria-valuemin":Ie,"aria-valuemax":At,"aria-valuenow":He,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(fr,O):St(O,fr,at,y),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?C?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":C?"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0":"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${xt}`,style:d?{bottom:`${Oe*100}%`,left:C?0:"auto",right:C?"auto":0,transform:C?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Ve==="macro-high"||Le==="macro-high"?30:15}:{left:`${Oe*100}%`,top:C?0:"auto",bottom:C?"auto":0,transform:C?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Ve==="macro-high"||Le==="macro-high"?30:15},onPointerDown:Ot("macro-high"),onKeyDown:xr("macro-high"),onFocus:Mr("macro-high"),"data-active":Ve==="macro-high"?"true":void 0,"data-front":Le==="macro-high"?"true":void 0,"data-vernier-pos":d?C?"left":"right":C?"top":"bottom","data-handle-type":"macro-high",children:[g.jsx(cr,{type:"macro",isTop:C,isVertical:d,isLeft:C}),ut&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":Ta?"true":void 0,"data-slanted":yr.slant.isSlanted?"true":void 0,ref:ba,style:yr.highStyle,children:Ue(O,fr,at,y)})]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":p?e.pointAriaLabel??"Micro selected date":e.lowerAriaLabel??"Micro range start","aria-disabled":i?"true":void 0,"aria-valuemin":Re,"aria-valuemax":p?je:ye,"aria-valuenow":we,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Mt,w):St(w,Mt,We,y),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?C?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":C?"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4":"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${xt}`,style:d?{bottom:`${Ge*100}%`,left:C?"auto":0,right:C?0:"auto",transform:C?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Ve===lt||Le===lt?30:20}:{left:`${Ge*100}%`,top:C?"auto":0,bottom:C?0:"auto",transform:C?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Ve===lt||Le===lt?30:20},onPointerDown:Ot(lt),onKeyDown:xr(lt),onFocus:Mr(lt),"data-active":Ve===lt?"true":void 0,"data-front":Le===lt?"true":void 0,"data-vernier-pos":d?C?"right":"left":C?"bottom":"top","data-handle-type":lt,children:[g.jsx(cr,{type:"micro",isTop:!C,isVertical:d,isLeft:!C}),ut&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":Sa?"true":void 0,"data-slanted":Rr.slant.isSlanted?"true":void 0,ref:Ma,style:Rr.lowStyle,children:Ue(w,Mt,We,y)})]}),!p&&g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":i?"true":void 0,"aria-valuemin":we,"aria-valuemax":je,"aria-valuenow":ye,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(wt,w):St(w,wt,We,y),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${d?"is-vertical":""} group absolute touch-none ${d?C?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":C?"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4":"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${xt}`,style:d?{bottom:`${dt*100}%`,left:C?"auto":0,right:C?0:"auto",transform:C?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Ve==="micro-high"||Le==="micro-high"?30:20}:{left:`${dt*100}%`,top:C?"auto":0,bottom:C?0:"auto",transform:C?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Ve==="micro-high"||Le==="micro-high"?30:20},onPointerDown:Ot("micro-high"),onKeyDown:xr("micro-high"),onFocus:Mr("micro-high"),"data-active":Ve==="micro-high"?"true":void 0,"data-front":Le==="micro-high"?"true":void 0,"data-vernier-pos":d?C?"right":"left":C?"bottom":"top","data-handle-type":"micro-high",children:[g.jsx(cr,{type:"micro",isTop:!C,isVertical:d,isLeft:!C}),ut&&g.jsx("div",{className:"period-slider-hairline"}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":La?"true":void 0,"data-slanted":Rr.slant.isSlanted?"true":void 0,ref:wa,style:Rr.highStyle,children:Ue(w,wt,We,y)})]})]}):g.jsxs(g.Fragment,{children:[!P&&g.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:ka,onPointerDown:xa}),E&&$&&D.length>1&&g.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:D.map((l,u)=>{const m=ee(t,l),M=gr(u),L=d?{bottom:`${M}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${M}%`,top:"50%",transform:"translate(-50%, -50%)"};return g.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full bg-slate-400/60 dark:bg-slate-500/60",style:L},`tick-${m}`)})}),!i&&ce!==null&&nt!==null&&ae===null&&An&&g.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Aa,children:[g.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"}),g.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Ea?"true":void 0,className:`period-slider-hover-tooltip ${T==="bottom"&&!d?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:Ue(t,An,e.formatLabel,y)})]}),g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":_?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":i?"true":void 0,"aria-valuemin":S,"aria-valuemax":_?x:be,"aria-valuenow":fe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Kr,t):St(t,Kr,e.formatLabel,y),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${xt}`,style:Na,onPointerDown:Rn("low"),onKeyDown:Sn("low"),onFocus:Tn("low"),"data-active":ae==="low"?"true":void 0,"data-front":tr?"true":void 0,children:[g.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)] ${ae==="low"?"":"shadow-md"}`}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":T,"data-slanted":Fe.isSlanted?"true":void 0,"data-front":tr?"true":void 0,"data-duplicate":vr&&!tr?"true":void 0,ref:fa,style:Pa,children:Ue(t,Kr,e.formatLabel,y)})]}),!_&&g.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":i?"true":void 0,"aria-valuemin":fe,"aria-valuemax":x,"aria-valuenow":be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Wr,t):St(t,Wr,e.formatLabel,y),"aria-orientation":d?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${xt}`,style:Ya,onPointerDown:Rn("high"),onKeyDown:Sn("high"),onFocus:Tn("high"),"data-active":ae==="high"?"true":void 0,"data-front":rr?"true":void 0,children:[g.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)] ${ae==="high"?"":"shadow-md"}`}),f!=="hover"&&g.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":T,"data-slanted":Fe.isSlanted?"true":void 0,"data-front":rr?"true":void 0,"data-duplicate":vr&&!rr?"true":void 0,ref:ga,style:$a,children:Ue(t,Wr,e.formatLabel,y)})]})]})}),h&&En(d?"decrease":"increase")]})},tn=(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},ia=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(e[o]!==t[o])return!1;return!0},Za=(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||!ia(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||!tn(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||!tn(e.macroAllowedDates,t.macroAllowedDates)||!tn(e.microAllowedDates,t.microAllowedDates)):!1,la=a.memo(Ja,Za);la.displayName="PeriodSlider";const st=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},ur=(e,t)=>{if(Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},Qa=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)})`)}},Pt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Fn=e=>Pt(e,1,1),eo=e=>Pt(e,12,31),to={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},ro={year:4,month:2,day:2},no={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Un=new Map,ao=(e,t)=>{const r=`${e}\0${t}`,n=Un.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,to[e]);return Un.set(r,o),o},rn=(e,t,r)=>r===void 0?String(no[e](t)).padStart(ro[e],"0"):ao(e,r).format(t),oo=(e,t,r)=>{const n=t?.getTime()??null,o=r?.getTime()??null,s=new Map;return e.forEach((i,c)=>{ur(`allowedDates[${c}]`,i);const h=st(i),f=h.getTime();n!==null&&f<n||o!==null&&f>o||s.has(f)||s.set(f,h)}),Array.from(s.keys()).sort((i,c)=>i-c).map(i=>s.get(i))},io=(e,t)=>{const r=[];let n=st(e);const o=st(t).getTime();for(;n.getTime()<=o;)r.push(n),n=Ne.addDays(n,1);return r},Bn=(e,t)=>{const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Ue("day",e[n],void 0,t),value:Ne.format(e[n],"yyyy-MM-dd")});return r},lo=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:s,maxYear:i,minDate:c,maxDate:h,allowedDates:f,variant:T="date",className:v="",style:d,disabled:P=!1,prevDateAriaLabel:E="Previous day",nextDateAriaLabel:W="Next day",selectAriaLabel:y="Date",yearAriaLabel:oe="Year",monthAriaLabel:R="Month",dayAriaLabel:X="Day",locale:p,formatYearOption:F,formatMonthOption:Y,formatDayOption:A}=e;if(Qa(p),t!==void 0&&ur("value",t),r!==void 0&&ur("initialDate",r),c!==void 0&&ur("minDate",c),h!==void 0&&ur("maxDate",h),s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(s)})`);if(i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(i)})`);if(T==="split-dropdown"&&f!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const V=t??r;if(V===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[j,D]=a.useState(()=>st(V)),$=t!==void 0,S=t?.getTime(),x=a.useMemo(()=>t!==void 0?st(t):j,[S,j]),_=c?.getTime(),te=h?.getTime(),G=a.useMemo(()=>{const b=c?st(c):null,I=s!==void 0?Fn(s):null;return b===null?I:I===null||b.getTime()>=I.getTime()?b:I},[_,s]),ue=a.useMemo(()=>{const b=h?st(h):null,I=i!==void 0?eo(i):null;return b===null?I:I===null||b.getTime()<=I.getTime()?b:I},[te,i]),Me=G?.getTime()??null,ie=ue?.getTime()??null;if(G!==null&&ue!==null&&G.getTime()>ue.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Ne.format(G,"yyyy-MM-dd")} is after max ${Ne.format(ue,"yyyy-MM-dd")})`);if(T!=="date"&&f===void 0&&(G===null||ue===null))throw new RangeError(`DateSelector: variant="${T}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${T==="dropdown"?' or supply "allowedDates"':""}`);const re=f===void 0?null:f.map(b=>b.getTime()).join(","),Q=a.useMemo(()=>f===void 0?null:oo(f,G,ue),[re,Me,ie]),he=b=>{const I=b.getTime();return Q!==null?Q.some(Ee=>Ee.getTime()===I):!(Me!==null&&I<Me||ie!==null&&I>ie)},Xe=V.getTime();a.useEffect(()=>{$||D(st(V))},[$,Xe]);const q=b=>{if(P)return;const I=st(b);he(I)&&($||D(I),n?.(I))},J=x.getTime(),le=he(x),N=a.useMemo(()=>{if(Q!==null){for(let I=Q.length-1;I>=0;I--)if(Q[I].getTime()<J)return Q[I];return null}const b=Ne.addDays(new Date(J),-1);return he(b)?b:null},[Q,J,Me,ie]),U=a.useMemo(()=>{if(Q!==null){for(const I of Q)if(I.getTime()>J)return I;return null}const b=Ne.addDays(new Date(J),1);return he(b)?b:null},[Q,J,Me,ie]),se=P||N===null,ge=P||U===null,Se=()=>{N!==null&&q(N)},Be=()=>{U!==null&&q(U)},Ke=b=>{if(b.target.value){const I=Ne.parseISO(b.target.value);Number.isNaN(I.getTime())||q(I)}},rt=b=>{if(b.target.value){const I=Ne.parseISO(b.target.value);Number.isNaN(I.getTime())||q(I)}},ae=x.getFullYear(),pe=x.getMonth()+1,Ye=x.getDate(),kt=a.useMemo(()=>T!=="dropdown"?[]:Q!==null?Bn(Q,p):G===null||ue===null?[]:Bn(io(G,ue),p),[T,Q,Me,ie,p]),K=a.useMemo(()=>{if(T!=="split-dropdown"||G===null||ue===null)return[];const b=[];for(let I=ue.getFullYear();I>=G.getFullYear();I--)b.push(I);return b},[T,Me,ie]),ce=a.useMemo(()=>{if(T!=="split-dropdown"||G===null||ue===null)return[];const b=G,I=ue,Ee=ae===b.getFullYear()?b.getMonth()+1:1,Nt=ae===I.getFullYear()?I.getMonth()+1:12,at=[];for(let We=Ee;We<=Nt;We++)at.push(We);return at},[T,Me,ie,ae]),ht=a.useMemo(()=>{if(T!=="split-dropdown"||G===null||ue===null)return[];const b=G,I=ue,Ee=ae===b.getFullYear()&&pe===b.getMonth()+1?b.getDate():1,Nt=ae===I.getFullYear()&&pe===I.getMonth()+1?I.getDate():Ne.getDaysInMonth(new Date(J)),at=[];for(let We=Ee;We<=Nt;We++)at.push(We);return at},[T,Me,ie,J,ae,pe]),nt=(b,I,Ee)=>Ee>Ne.getDaysInMonth(Pt(b,I,1))?!1:he(Pt(b,I,Ee)),ct=(b,I,Ee)=>{nt(b,I,Ee)&&q(Pt(b,I,Ee))},fe=b=>F?F(b):rn("year",Fn(b),p),be=b=>Y?Y(b):rn("month",Pt(ae,b,1),p),Wt=b=>A?A(b):rn("day",Pt(ae,pe,b),p),me=Ne.format(x,"yyyy-MM-dd"),Ct=Ue("day",x,void 0,p),C=G?Ne.format(G,"yyyy-MM-dd"):void 0,Hr=ue?Ne.format(ue,"yyyy-MM-dd"):void 0,jr=le?me:"",ut="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",O=T==="split-dropdown"?"w-auto":"w-38";return g.jsxs("div",{className:`inline-flex items-center ${O} ${v}`,style:d,"data-variant":T,"data-out-of-range":le?void 0:"true",children:[g.jsx("button",{type:"button","aria-label":E,disabled:se,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:Se,children:g.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),T==="dropdown"?g.jsxs("select",{"aria-label":y,disabled:P,className:"mx-1 my-auto 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:jr,onChange:rt,children:[le?null:g.jsx("option",{value:"",disabled:!0,className:ut,children:Ct}),kt.map(b=>g.jsx("option",{value:b.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:b.label},b.value))]}):T==="split-dropdown"?g.jsxs("div",{className:"mx-1 my-auto inline-flex items-center gap-1",children:[g.jsxs("select",{"aria-label":oe,disabled:P,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:le?ae:"",onChange:b=>ct(Number(b.target.value),pe,Ye),children:[le?null:g.jsx("option",{value:"",disabled:!0,className:ut,children:fe(ae)}),K.map(b=>g.jsx("option",{value:b,disabled:!nt(b,pe,Ye),className:"dark:bg-slate-700 dark:text-slate-100",children:fe(b)},b))]}),g.jsxs("select",{"aria-label":R,disabled:P,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:le?pe:"",onChange:b=>ct(ae,Number(b.target.value),Ye),children:[le?null:g.jsx("option",{value:"",disabled:!0,className:ut,children:be(pe)}),ce.map(b=>g.jsx("option",{value:b,disabled:!nt(ae,b,Ye),className:"dark:bg-slate-700 dark:text-slate-100",children:be(b)},b))]}),g.jsxs("select",{"aria-label":X,disabled:P,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:le?Ye:"",onChange:b=>ct(ae,pe,Number(b.target.value)),children:[le?null:g.jsx("option",{value:"",disabled:!0,className:ut,children:Wt(Ye)}),ht.map(b=>g.jsx("option",{value:b,className:"dark:bg-slate-700 dark:text-slate-100",children:Wt(b)},b))]})]}):g.jsx("input",{"aria-label":y,disabled:P,className:"mx-1 my-auto w-28 rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-gray-900 text-xs 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:me,min:C,max:Hr,onChange:Ke,type:"date"}),g.jsx("button",{type:"button","aria-label":W,disabled:ge,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:Be,children:g.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),o]})},Xt=e=>e===void 0?null:st(e).getTime(),sa=a.memo(lo,(e,t)=>!(Xt(e.value??e.initialDate)!==Xt(t.value??t.initialDate)||Xt(e.minDate)!==Xt(t.minDate)||Xt(e.maxDate)!==Xt(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));sa.displayName="DateSelector";function Je(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(r,n,1);return o.setFullYear(r),o}function Lt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function sr(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 zn(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function so(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 co(e,t){const r=e===void 0?null:Je(e,0),n=t===void 0?null:Je(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function uo(e,t){const r=e===void 0?null:Je(e,11),n=t===void 0?null:Je(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function mo(e,t,r){const n=new Map;for(const o of e){const s=Je(o.getFullYear(),o.getMonth());t!==null&&s<t||r!==null&&s>r||n.has(s.getTime())||n.set(s.getTime(),s)}return Array.from(n.values()).sort((o,s)=>o.getTime()-s.getTime())}function fo(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),o=[];for(let s=r;s<=n;s++)o.push(Je(Math.floor(s/12),s%12));return o}function _n(e,t){const r=[];for(let n=e.length-1;n>=0;n--)r.push({label:Ue("month",e[n],void 0,t),value:Lt(e[n])});return r}const go=e=>{const{value:t,initialDate:r,onChange:n,children:o,variant:s="date",minYear:i,maxYear:c,minDate:h,maxDate:f,allowedMonths:T,isWarning:v=!1,className:d="",style:P,disabled:E=!1,prevMonthAriaLabel:W="Previous month",nextMonthAriaLabel:y="Next month",selectAriaLabel:oe="Month",locale:R}=e;so(R),sr(t,"value"),sr(r,"initialDate"),sr(h,"minDate"),sr(f,"maxDate"),zn(i,"minYear"),zn(c,"maxYear"),T?.forEach((K,ce)=>{sr(K,`allowedMonths[${ce}]`)});const X=t??r;if(X===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const[p,F]=a.useState(()=>Je(X.getFullYear(),X.getMonth())),Y=t!==void 0,A=a.useMemo(()=>t!==void 0?Je(t.getFullYear(),t.getMonth()):p,[t?.getTime(),p]),V=h?.getTime(),j=f?.getTime(),D=a.useMemo(()=>co(i,h),[i,V]),$=a.useMemo(()=>uo(c,f),[c,j]),S=D?.getTime()??null,x=$?.getTime()??null;if(D!==null&&$!==null&&D>$)throw new RangeError(`MonthSelector: the resolved lower bound ${Lt(D)} is after the resolved upper bound ${Lt($)}.`);if(s==="dropdown"&&T===void 0&&(D===null||$===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 _=T===void 0?null:T.map(K=>K.getTime()).join(","),te=a.useMemo(()=>T===void 0?null:mo(T,D,$),[_,S,x]),G=K=>{const ce=K.getTime();return te!==null?te.some(ht=>ht.getTime()===ce):!(S!==null&&ce<S||x!==null&&ce>x)},ue=X.getTime();a.useEffect(()=>{if(Y)return;const K=Je(X.getFullYear(),X.getMonth());F(ce=>ce.getTime()===K.getTime()?ce:K)},[Y,ue]);const Me=K=>{if(E)return;if(!G(K))throw new RangeError(`MonthSelector: refusing to emit ${Lt(K)}, which lies outside the selectable months.`);Y||F(K);const ce=K.getFullYear()*100+(K.getMonth()+1);n?.(K,ce)},ie=A.getTime(),re=G(A),Q=a.useMemo(()=>{if(te!==null){for(let ce=te.length-1;ce>=0;ce--)if(te[ce].getTime()<ie)return te[ce];return null}const K=Je(A.getFullYear(),A.getMonth()-1);return G(K)?K:null},[te,ie,S,x]),he=a.useMemo(()=>{if(te!==null){for(const ce of te)if(ce.getTime()>ie)return ce;return null}const K=Je(A.getFullYear(),A.getMonth()+1);return G(K)?K:null},[te,ie,S,x]),Xe=E||Q===null,q=E||he===null,J=()=>{Q!==null&&Me(Q)},le=()=>{he!==null&&Me(he)},N=K=>{if(!K)return;const[ce,ht]=K.split("-"),nt=Number(ce),ct=Number(ht)-1;if(!(Number.isInteger(nt)&&Number.isInteger(ct)))return;const fe=Je(nt,ct);G(fe)&&Me(fe)},U=K=>{N(K.target.value)},se=K=>{N(K.target.value)},ge=Lt(A),Se=Ue("month",A,void 0,R),Be=D?Lt(D):void 0,Ke=$?Lt($):void 0,rt=a.useMemo(()=>s!=="dropdown"?[]:te!==null?_n(te,R):D===null||$===null?[]:_n(fo(D,$),R),[s,te,S,x,R]),ae=re?ge:"",pe=v?"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",Ye=`mx-1 my-auto w-28 rounded-md border py-0.5 px-1 text-xs dark:placeholder:text-gray-400 disabled:opacity-50 ${pe}`,kt=`mx-1 my-auto 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 ${pe}`;return g.jsxs("div",{className:`inline-flex w-38 items-center ${d}`,style:P,"data-out-of-range":re?void 0:"true",children:[g.jsx("button",{type:"button","aria-label":W,disabled:Xe,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:J,children:g.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),s==="dropdown"?g.jsxs("select",{"aria-label":oe,disabled:E,className:kt,value:ae,onChange:se,children:[re?null:g.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:Se}),rt.map(K=>g.jsx("option",{value:K.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:K.label},K.value))]}):g.jsx("input",{"aria-label":oe,disabled:E,className:Ye,value:ge,min:Be,max:Ke,onChange:U,type:"month"}),g.jsx("button",{type:"button","aria-label":y,disabled:q,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:le,children:g.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),o]})},ca=a.memo(go,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,s=n?n.getFullYear()*12+n.getMonth():null;if(o!==s||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear)return!1;const i=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,c=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(i!==c)return!1;const h=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,f=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(h!==f||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)});ca.displayName="MonthSelector";function Kt(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 Vr(e,t,r){if(Kt(e,"minDate",t),Kt(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 Nr(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(Kt(e,`${t}[0]`,r[0]),Kt(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 Yr(e,t,r,n,o,s){if(r.getTime()<n.getTime()||r.getTime()>o.getTime())throw new RangeError(`${e}: ${t} must lie within ${s} (value: ${r.toISOString()}, lower: ${n.toISOString()}, upper: ${o.toISOString()})`)}function Ar(e,t,r,n,o,s){Yr(e,`${t}[0]`,r[0],n,o,s),Yr(e,`${t}[1]`,r[1],n,o,s)}function Ce(e,t,r){return e<t?t:e>r?r:e}function Pr(e,t,r,n){const o=qe(t,r,n[1]);return[Ce(e[0],n[0],o),Ce(e[1],n[0],o)]}function $r(e,t,r,n){return Ce(e,n[0],qe(t,r,n[1]))}function Er(e,t,r,n){const o=Te(e,r,t)+n;return e[Math.max(0,Math.min(e.length-1,o))]}function Ir(e){const t=a.useRef(e),r=t.current,n=e,o=Object.keys(r),s=Object.keys(n);return o.length===s.length&&s.every(c=>Object.is(r[c],n[c]))||(t.current=e),t.current}function ho(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:s,...i}=e;Vr("usePeriodSliderRange",r,n),Nr("usePeriodSliderRange","initialRange",o),Ar("usePeriodSliderRange","initialRange",o,r,n,"[minDate, maxDate]");const c=Ir(i),h=a.useRef(o),[f,T]=a.useState(o);let v=f;const d=[Ce(f[0],r,n),Ce(f[1],r,n)];(d[0]!==f[0]||d[1]!==f[1])&&(v=d,T(d));const P=a.useRef(v);P.current=v;const E=a.useRef({minDate:r,maxDate:n,allowedDates:c.allowedDates});E.current={minDate:r,maxDate:n,allowedDates:c.allowedDates};const W=a.useRef(s);W.current=s;const y=a.useCallback(j=>{const{minDate:D,maxDate:$}=E.current,S=Ce(j[0],D,$),x=Ce(j[1],D,$),_=P.current;S.getTime()===_[0].getTime()&&x.getTime()===_[1].getTime()||(P.current=[S,x],T([S,x]),W.current?.(S,x))},[]),oe=a.useCallback(j=>{const D=P.current,$=j.getTime()>D[1].getTime()?j:D[1];y([j,$])},[y]),R=a.useCallback(j=>{const D=P.current,$=j.getTime()<D[0].getTime()?j:D[0];y([$,j])},[y]),X=a.useCallback((j,D)=>{y([j,D])},[y]),p=a.useCallback(j=>{const{minDate:D,maxDate:$,allowedDates:S}=E.current,x=P.current,_=$t(S,t,D,$);if(_.length>0){y([Er(_,t,x[0],j),Er(_,t,x[1],j)]);return}y([ke(t,x[0],j),ke(t,x[1],j)])},[t,y]),F=a.useCallback(()=>{y(h.current)},[y]),Y=a.useMemo(()=>({value:v[0],onChange:oe,minDate:r,maxDate:v[1],unit:t}),[v[0],v[1],oe,r,t]),A=a.useMemo(()=>({value:v[1],onChange:R,minDate:v[0],maxDate:n,unit:t}),[v[0],v[1],R,n,t]),V=a.useMemo(()=>({...c,mode:"range",unit:t,range:v,minDate:r,maxDate:n,onChangeRange:X}),[c,t,v,r,n,X]);return{range:v,lowerDate:v[0],upperDate:v[1],setRange:T,setLowerDate:oe,setUpperDate:R,shiftRange:p,resetRange:F,startSelectorProps:Y,endSelectorProps:A,sliderProps:V}}function bo(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:s,...i}=e;Vr("usePeriodSliderPoint",r,n),Kt("usePeriodSliderPoint","initialValue",o),Yr("usePeriodSliderPoint","initialValue",o,r,n,"[minDate, maxDate]");const c=Ir(i),h=a.useRef(o),[f,T]=a.useState(o);let v=f;const d=Ce(f,r,n);d!==f&&(v=d,T(d));const P=a.useRef(v);P.current=v;const E=a.useRef({minDate:r,maxDate:n,allowedDates:c.allowedDates});E.current={minDate:r,maxDate:n,allowedDates:c.allowedDates};const W=a.useRef(s);W.current=s;const y=a.useCallback(F=>{const{minDate:Y,maxDate:A}=E.current,V=Ce(F,Y,A);V.getTime()!==P.current.getTime()&&(P.current=V,T(V),W.current?.(V))},[]),oe=a.useCallback(F=>{const{minDate:Y,maxDate:A,allowedDates:V}=E.current,j=$t(V,t,Y,A);if(j.length>0){y(Er(j,t,P.current,F));return}y(ke(t,P.current,F))},[t,y]),R=a.useCallback(()=>{y(h.current)},[y]),X=a.useMemo(()=>({value:v,onChange:y,minDate:r,maxDate:n,unit:t}),[v,y,r,n,t]),p=a.useMemo(()=>({...c,mode:"point",unit:t,value:v,minDate:r,maxDate:n,onChangePoint:y}),[c,t,v,r,n,y]);return{value:v,setValue:T,shiftValue:oe,resetValue:R,selectorProps:X,sliderProps:p}}function Mo(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:s,macroUnit:i=t,microUnit:c=t,onChangeMacroRange:h,onChangeMicroRange:f,...T}=e;Vr("useVernierSlider",r,n),Nr("useVernierSlider","initialMacroRange",o),Nr("useVernierSlider","initialMicroRange",s),Ar("useVernierSlider","initialMacroRange",o,r,n,"[minDate, maxDate]"),Ar("useVernierSlider","initialMicroRange",s,o[0],qe(i,c,o[1]),"the initial macro window");const v=Ir(T),d=a.useRef(o),P=a.useRef(s),[E,W]=a.useState(o),[y,oe]=a.useState(s);let R=E;const X=[Ce(E[0],r,n),Ce(E[1],r,n)];(X[0]!==E[0]||X[1]!==E[1])&&(R=X,W(X));let p=y;const F=Pr(y,i,c,R);(F[0]!==y[0]||F[1]!==y[1])&&(p=F,oe(F));const Y=a.useRef(R);Y.current=R;const A=a.useRef(p);A.current=p;const V=a.useRef({minDate:r,maxDate:n});V.current={minDate:r,maxDate:n};const j=a.useRef(h);j.current=h;const D=a.useRef(f);D.current=f;const $=a.useCallback((N,U)=>{const se=Y.current,ge=A.current;(N[0].getTime()!==se[0].getTime()||N[1].getTime()!==se[1].getTime())&&(Y.current=N,W(N),j.current?.(N[0],N[1])),(U[0].getTime()!==ge[0].getTime()||U[1].getTime()!==ge[1].getTime())&&(A.current=U,oe(U),D.current?.(U[0],U[1]))},[]),S=a.useCallback((N,U)=>{const{minDate:se,maxDate:ge}=V.current,Se=[Ce(N,se,ge),Ce(U,se,ge)];$(Se,Pr(A.current,i,c,Se))},[i,c,$]),x=a.useCallback((N,U)=>{$(Y.current,Pr([N,U],i,c,Y.current))},[i,c,$]),_=a.useCallback(N=>{const U=Y.current[1],se=N>U?N:U;S(N,se)},[S]),te=a.useCallback(N=>{const U=Y.current[0],se=N<U?N:U;S(se,N)},[S]),G=a.useCallback(N=>{const U=A.current[1],se=N>U?N:U;x(N,se)},[x]),ue=a.useCallback(N=>{const U=A.current[0],se=N<U?N:U;x(se,N)},[x]),Me=a.useCallback(N=>{const{minDate:U,maxDate:se}=V.current,ge=Y.current,Se=ke(i,ge[0],N),Be=ke(i,ge[1],N);Se<U||Be>se||S(Se,Be)},[i,S]),ie=a.useCallback(N=>{const U=Y.current,se=A.current,ge=ke(c,se[0],N),Se=ke(c,se[1],N);ge<U[0]||Se>qe(i,c,U[1])||x(ge,Se)},[i,c,x]),re=a.useCallback(()=>{const N=d.current;$(N,Pr(P.current,i,c,N))},[i,c,$]),Q=a.useMemo(()=>qe(i,c,R[1]),[i,c,R[1]]),he=a.useMemo(()=>({value:R[0],onChange:_,minDate:r,maxDate:R[1],unit:i}),[R,_,r,i]),Xe=a.useMemo(()=>({value:R[1],onChange:te,minDate:R[0],maxDate:n,unit:i}),[R,te,n,i]),q=a.useMemo(()=>({value:p[0],onChange:G,minDate:R[0],maxDate:p[1],unit:c}),[p,G,R,c]),J=a.useMemo(()=>({value:p[1],onChange:ue,minDate:p[0],maxDate:Q,unit:c}),[p,ue,Q,c]),le=a.useMemo(()=>({...v,mode:"vernier",unit:t,macroUnit:i,microUnit:c,minDate:r,maxDate:n,macroRange:R,microRange:p,onChangeMacroRange:S,onChangeMicroRange:x}),[v,t,i,c,r,n,R,p,S,x]);return{macroRange:R,setMacroRange:W,microRange:p,setMicroRange:oe,setMacroLowerDate:_,setMacroUpperDate:te,setMicroLowerDate:G,setMicroUpperDate:ue,shiftMacroRange:Me,shiftMicroRange:ie,resetVernier:re,macroStartSelectorProps:he,macroEndSelectorProps:Xe,microStartSelectorProps:q,microEndSelectorProps:J,sliderProps:le}}function wo(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:s,macroUnit:i=t,microUnit:c=t,onChangeMacroRange:h,onChangeMicroPoint:f,...T}=e;Vr("useVernierSliderPoint",r,n),Nr("useVernierSliderPoint","initialMacroRange",o),Kt("useVernierSliderPoint","initialMicroValue",s),Ar("useVernierSliderPoint","initialMacroRange",o,r,n,"[minDate, maxDate]"),Yr("useVernierSliderPoint","initialMicroValue",s,o[0],qe(i,c,o[1]),"the initial macro window");const v=Ir(T),d=a.useRef(o),P=a.useRef(s),[E,W]=a.useState(o),[y,oe]=a.useState(s);let R=E;const X=[Ce(E[0],r,n),Ce(E[1],r,n)];(X[0]!==E[0]||X[1]!==E[1])&&(R=X,W(X));let p=y;const F=$r(y,i,c,R);F!==y&&(p=F,oe(F));const Y=a.useRef(R);Y.current=R;const A=a.useRef(p);A.current=p;const V=a.useRef({minDate:r,maxDate:n,microIsDiscrete:v.microIsDiscrete,microAllowedDates:v.microAllowedDates,allowedDates:v.allowedDates});V.current={minDate:r,maxDate:n,microIsDiscrete:v.microIsDiscrete,microAllowedDates:v.microAllowedDates,allowedDates:v.allowedDates};const j=a.useRef(h);j.current=h;const D=a.useRef(f);D.current=f;const $=a.useCallback((q,J)=>{const le=Y.current,N=A.current;(q[0].getTime()!==le[0].getTime()||q[1].getTime()!==le[1].getTime())&&(Y.current=q,W(q),j.current?.(q[0],q[1])),J.getTime()!==N.getTime()&&(A.current=J,oe(J),D.current?.(J))},[]),S=a.useCallback((q,J)=>{const{minDate:le,maxDate:N}=V.current,U=[Ce(q,le,N),Ce(J,le,N)];$(U,$r(A.current,i,c,U))},[i,c,$]),x=a.useCallback(q=>{$(Y.current,$r(q,i,c,Y.current))},[i,c,$]),_=a.useCallback(q=>{const J=Y.current[1],le=q>J?q:J;S(q,le)},[S]),te=a.useCallback(q=>{const J=Y.current[0],le=q<J?q:J;S(le,q)},[S]),G=a.useCallback(q=>{const{minDate:J,maxDate:le}=V.current,N=Y.current,U=ke(i,N[0],q),se=ke(i,N[1],q);U<J||se>le||S(U,se)},[i,S]),ue=a.useCallback(q=>{const J=Y.current,le=qe(i,c,J[1]),{microIsDiscrete:N,microAllowedDates:U,allowedDates:se,minDate:ge,maxDate:Se}=V.current,Be=N===!0?$t(U??se,c,ge,Se):[],Ke=J[0].getTime(),rt=le.getTime(),ae=Be.filter(pe=>pe.getTime()>=Ke&&pe.getTime()<=rt);if(ae.length>0){x(Er(ae,c,A.current,q));return}x(ke(c,A.current,q))},[i,c,x]),Me=a.useCallback(()=>{const q=d.current;$(q,$r(P.current,i,c,q))},[i,c,$]),ie=a.useMemo(()=>qe(i,c,R[1]),[i,c,R[1]]),re=a.useMemo(()=>({value:R[0],onChange:_,minDate:r,maxDate:R[1],unit:i}),[R,_,r,i]),Q=a.useMemo(()=>({value:R[1],onChange:te,minDate:R[0],maxDate:n,unit:i}),[R,te,n,i]),he=a.useMemo(()=>({value:p,onChange:x,minDate:R[0],maxDate:ie,unit:c}),[p,x,R,ie,c]),Xe=a.useMemo(()=>({...v,mode:"vernier",unit:t,macroUnit:i,microUnit:c,minDate:r,maxDate:n,macroRange:R,microValue:p,onChangeMacroRange:S,onChangeMicroPoint:x}),[v,t,i,c,r,n,R,p,S,x]);return{macroRange:R,setMacroRange:W,microValue:p,setMicroValue:oe,setMacroLowerDate:_,setMacroUpperDate:te,setMicroDate:x,shiftMacroRange:G,shiftMicroValue:ue,resetVernier:Me,macroStartSelectorProps:re,macroEndSelectorProps:Q,microSelectorProps:he,sliderProps:Xe}}function qn(e){const t=new Date(e,0,1);return t.setFullYear(e),t}function kr(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 Xn(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function xo(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 Kn(e,t,r){const n=e===void 0?null:e,o=t===void 0?null:t.getFullYear();return n!==null&&o!==null?r(n,o):n!==null?n:o}const vo=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:s,maxYear:i,minDate:c,maxDate:h,className:f="",style:T,disabled:v=!1,prevYearAriaLabel:d="Previous year",nextYearAriaLabel:P="Next year",selectAriaLabel:E="Year",locale:W}=e;kr(t,"value"),kr(r,"initialDate"),kr(c,"minDate"),kr(h,"maxDate"),Xn(s,"minYear"),Xn(i,"maxYear"),xo(W);const y=t??r;if(y===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const[oe,R]=a.useState(()=>y.getFullYear()),X=c?.getTime(),p=h?.getTime(),F=a.useMemo(()=>Kn(s,c,Math.max),[s,X]),Y=a.useMemo(()=>Kn(i,h,Math.min),[i,p]);if(F===null||Y===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(F>Y)throw new RangeError(`YearSelector: the resolved lower bound ${F} is after the resolved upper bound ${Y}.`);const A=t!==void 0,V=t!==void 0?t.getFullYear():oe,j=V<F||V>Y,D=y.getTime();a.useEffect(()=>{A||R(y.getFullYear())},[A,D]);const $=re=>re>=F&&re<=Y,S=re=>{if(!v){if(!$(re))throw new RangeError(`YearSelector: refusing to emit ${re}, which lies outside the declared bounds ${F}-${Y}.`);A||R(re),n?.(qn(re),re)}},x=$(V-1)?V-1:null,_=$(V+1)?V+1:null,te=v||x===null,G=v||_===null,ue=()=>{x!==null&&S(x)},Me=()=>{_!==null&&S(_)},ie=a.useMemo(()=>{const re=[];for(let Q=Y;Q>=F;Q--)re.push(Q);return j&&(re.push(V),re.sort((Q,he)=>he-Q)),re},[F,Y,j,V]);return g.jsxs("div",{className:`inline-flex w-32 items-center ${f}`,style:T,children:[g.jsx("button",{type:"button","aria-label":d,disabled:te,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:ue,children:g.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),g.jsx("select",{"aria-label":E,disabled:v,className:"mx-1 my-auto 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:V,onChange:re=>{if(!re.target.value)return;const Q=Number(re.target.value);Number.isInteger(Q)&&S(Q)},children:ie.map(re=>g.jsx("option",{value:re,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:Ue("year",qn(re),void 0,W)},re))}),g.jsx("button",{type:"button","aria-label":P,disabled:G,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:Me,children:g.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),o]})},ua=a.memo(vo,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear():null,s=n?n.getFullYear():null;return!(o!==s||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.minDate?.getFullYear()!==t.minDate?.getFullYear()||e.maxDate?.getFullYear()!==t.maxDate?.getFullYear()||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});ua.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Wn;exports.DateSelector=sa;exports.MonthSelector=ca;exports.PeriodSlider=la;exports.YearSelector=ua;exports.addUnit=ke;exports.areStylesEqual=ia;exports.calculateConnectDragValues=Jn;exports.calculateHandleDragValues=nn;exports.calculateKeyboardActionValues=Zn;exports.calculateLabelSlant=ln;exports.calculateVernierMacroDrag=aa;exports.calculateVernierMicroDrag=oa;exports.decode=de;exports.encode=ee;exports.findNearestDateIndex=Te;exports.formatLabel=Ue;exports.formatScreenReaderLabel=St;exports.getActiveDragHandle=Gn;exports.getMacroWindowEndDate=qe;exports.getSortedAllowedDates=$t;exports.normalizeDateByUnit=tt;exports.resolveVernierTargetHandle=na;exports.usePeriodSliderPoint=bo;exports.usePeriodSliderRange=ho;exports.useVernierSlider=Mo;exports.useVernierSliderPoint=wo;
|
|
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;
|
package/dist/index.d.cts
CHANGED
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export type { DateSelectorProps } from './DateSelector.js';
|
|
19
19
|
export { DateSelector } from './DateSelector.js';
|
|
20
|
+
export { resolveDraggedEdge } from './dragPresentation.js';
|
|
20
21
|
export type { MonthSelectorProps } from './MonthSelector.js';
|
|
21
22
|
export { MonthSelector } from './MonthSelector.js';
|
|
22
23
|
export type { AccessibleSliderLabels, BasePeriodSliderProps, BasePeriodSliderVernierProps, ColorSchemePalette, ConnectDragValueOptions, LabelSlantConfig, LabelSlantResult, PeriodSliderColorScheme, PeriodSliderLabelPosition, PeriodSliderPointProps, PeriodSliderProps, PeriodSliderRangeProps, PeriodSliderSnapMode, PeriodSliderUnit, PeriodSliderVernierPointProps, PeriodSliderVernierProps, PeriodSliderVernierRangeProps, VernierHandle, VernierMicroShape, } from './PeriodSlider.js';
|
|
23
|
-
export { addUnit, areStylesEqual, COLOR_SCHEME_PALETTES, calculateConnectDragValues, calculateHandleDragValues, calculateKeyboardActionValues, calculateLabelSlant, calculateVernierMacroDrag, calculateVernierMicroDrag, decode, encode, findNearestDateIndex, formatLabel, formatScreenReaderLabel,
|
|
24
|
-
export type { SelectorProps, UsePeriodSliderPointOptions, UsePeriodSliderPointReturn, UsePeriodSliderRangeOptions, UsePeriodSliderRangeReturn,
|
|
25
|
-
export { usePeriodSliderPoint, usePeriodSliderRange,
|
|
24
|
+
export { addUnit, areStylesEqual, COLOR_SCHEME_PALETTES, calculateConnectDragValues, calculateHandleDragValues, calculateKeyboardActionValues, calculateLabelSlant, calculateVernierMacroDrag, calculateVernierMicroDrag, decode, encode, findNearestDateIndex, formatLabel, formatScreenReaderLabel, getMacroWindowEndDate, getMacroWindowStartDate, getSortedAllowedDates, normalizeDateByUnit, PeriodSlider, resolveMacroWindow, resolveVernierRailZone, resolveVernierTargetHandle, resolveWheelStep, } from './PeriodSlider.js';
|
|
25
|
+
export type { SelectorProps, UsePeriodSliderPointOptions, UsePeriodSliderPointReturn, UsePeriodSliderRangeOptions, UsePeriodSliderRangeReturn, UseVernierSliderPointOptions, UseVernierSliderPointReturn, UseVernierSliderRangeOptions, UseVernierSliderRangeReturn, } from './usePeriodSlider.js';
|
|
26
|
+
export { usePeriodSliderPoint, usePeriodSliderRange, useVernierSliderPoint, useVernierSliderRange, } from './usePeriodSlider.js';
|
|
26
27
|
export type { YearSelectorProps } from './YearSelector.js';
|
|
27
28
|
export { YearSelector } from './YearSelector.js';
|
|
28
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export type { DateSelectorProps } from './DateSelector.js';
|
|
19
19
|
export { DateSelector } from './DateSelector.js';
|
|
20
|
+
export { resolveDraggedEdge } from './dragPresentation.js';
|
|
20
21
|
export type { MonthSelectorProps } from './MonthSelector.js';
|
|
21
22
|
export { MonthSelector } from './MonthSelector.js';
|
|
22
23
|
export type { AccessibleSliderLabels, BasePeriodSliderProps, BasePeriodSliderVernierProps, ColorSchemePalette, ConnectDragValueOptions, LabelSlantConfig, LabelSlantResult, PeriodSliderColorScheme, PeriodSliderLabelPosition, PeriodSliderPointProps, PeriodSliderProps, PeriodSliderRangeProps, PeriodSliderSnapMode, PeriodSliderUnit, PeriodSliderVernierPointProps, PeriodSliderVernierProps, PeriodSliderVernierRangeProps, VernierHandle, VernierMicroShape, } from './PeriodSlider.js';
|
|
23
|
-
export { addUnit, areStylesEqual, COLOR_SCHEME_PALETTES, calculateConnectDragValues, calculateHandleDragValues, calculateKeyboardActionValues, calculateLabelSlant, calculateVernierMacroDrag, calculateVernierMicroDrag, decode, encode, findNearestDateIndex, formatLabel, formatScreenReaderLabel,
|
|
24
|
-
export type { SelectorProps, UsePeriodSliderPointOptions, UsePeriodSliderPointReturn, UsePeriodSliderRangeOptions, UsePeriodSliderRangeReturn,
|
|
25
|
-
export { usePeriodSliderPoint, usePeriodSliderRange,
|
|
24
|
+
export { addUnit, areStylesEqual, COLOR_SCHEME_PALETTES, calculateConnectDragValues, calculateHandleDragValues, calculateKeyboardActionValues, calculateLabelSlant, calculateVernierMacroDrag, calculateVernierMicroDrag, decode, encode, findNearestDateIndex, formatLabel, formatScreenReaderLabel, getMacroWindowEndDate, getMacroWindowStartDate, getSortedAllowedDates, normalizeDateByUnit, PeriodSlider, resolveMacroWindow, resolveVernierRailZone, resolveVernierTargetHandle, resolveWheelStep, } from './PeriodSlider.js';
|
|
25
|
+
export type { SelectorProps, UsePeriodSliderPointOptions, UsePeriodSliderPointReturn, UsePeriodSliderRangeOptions, UsePeriodSliderRangeReturn, UseVernierSliderPointOptions, UseVernierSliderPointReturn, UseVernierSliderRangeOptions, UseVernierSliderRangeReturn, } from './usePeriodSlider.js';
|
|
26
|
+
export { usePeriodSliderPoint, usePeriodSliderRange, useVernierSliderPoint, useVernierSliderRange, } from './usePeriodSlider.js';
|
|
26
27
|
export type { YearSelectorProps } from './YearSelector.js';
|
|
27
28
|
export { YearSelector } from './YearSelector.js';
|
|
28
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EACR,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,wBAAwB,EACxB,6BAA6B,EAC7B,aAAa,EACb,iBAAiB,GACpB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACH,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,MAAM,EACN,MAAM,EACN,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EACR,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,wBAAwB,EACxB,6BAA6B,EAC7B,aAAa,EACb,iBAAiB,GACpB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACH,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,MAAM,EACN,MAAM,EACN,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB,GACnB,MAAM,gBAAgB,CAAA;AAIvB,YAAY,EACR,aAAa,EACb,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,GAC9B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACxB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
|