@aiquants/period-slider 0.20.1 → 0.22.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 +84 -0
- package/README.md +24 -10
- package/dist/DateSelector.d.ts +12 -1
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +11 -0
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +40 -4
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/StepperButton.d.ts +27 -2
- package/dist/StepperButton.d.ts.map +1 -1
- package/dist/VirtualDateDropdown.d.ts +2 -2
- package/dist/YearSelector.d.ts +11 -0
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/dragPresentation.d.ts +11 -3
- package/dist/dragPresentation.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2701 -2495
- package/dist/labelRoom.d.ts +101 -0
- package/dist/labelRoom.d.ts.map +1 -0
- package/dist/labels.d.ts +17 -15
- package/dist/labels.d.ts.map +1 -1
- package/dist/styles/period-slider.css +1 -1
- package/dist/styles/period-slider.standalone.css +1 -1
- package/package.json +10 -8
- package/src/DateSelector.tsx +20 -8
- package/src/MonthSelector.tsx +20 -6
- package/src/PeriodSlider.tsx +629 -46
- package/src/StepperButton.tsx +114 -17
- package/src/VirtualDateDropdown.tsx +3 -3
- package/src/YearSelector.tsx +19 -7
- package/src/dragPresentation.ts +11 -3
- package/src/index.ts +2 -0
- package/src/labelRoom.ts +236 -0
- package/src/labels.ts +26 -22
- package/src/styles/period-slider.css +82 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react/jsx-runtime"),cc=require("date-fns"),s=require("react"),ur=require("@aiquants/virtualscroll"),uc=require("react-dom"),Ua="an object that cannot be converted to a string",dc=3,ye=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},$t=e=>{try{return Array.isArray(e)}catch{return!1}},mc=e=>e===void 0||$t(e);function en(e,t,r){if(!mc(r))throw new RangeError(`${e}: ${t} must be an array of Dates (received: ${E(r)})`)}const E=e=>{if(typeof e=="string")return JSON.stringify(e);if(ye(e))return Date.prototype.toISOString.call(e);if($t(e))return fc(e);try{return String(e)}catch{return Ua}},fc=e=>{let t;try{t=e.length}catch{return Ua}const r=Math.min(t,dc),n=[];for(let a=0;a<r;a++)n.push(hc(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},hc=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return $t(r)?`Array(${r.length})`:E(r)}catch{return Ua}},Mt=(e,t)=>ye(e)?t(e):Number.NaN,mt=(e,t)=>e===void 0?null:Mt(e,t),Ji=120,da="data-drag-snap",ma="--ps-drag-snap-duration",Rn={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"]},Ns=["low","high"],Vs=["tx","ty","rot"],Lo={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"}},Wa=(e,t)=>`${e}-${t}`,fa=(e,t,r)=>`var(${Wa(e,t)}, ${r})`,gc=(e,t,r)=>{const n=Lo[t];for(const o of Ns)for(const a of Vs)e.style.setProperty(Wa(n[o],a),r[o][a])},_s=e=>Math.max(0,Math.min(1,e)),So=(e,t,r,n)=>{const o=_s(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},za=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},$o=(e,t,r,n)=>{const o=_s(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ha=(e,t,r,n)=>{if(r){const i=(1-e)*100,u=(1-t)*100;return n?`M 12 ${u} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${u} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},or=(e,t)=>`var(${e}, ${t}%)`,pc=(e,t,r,n)=>{const[o,a]=Rn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},wc=e=>{for(const[t,r]of Object.values(Rn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Lo))for(const r of Ns)for(const n of Vs)e.style.removeProperty(Wa(t[r],n))},Ys=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],To=[...ur.VIRTUAL_SCROLL_LABEL_KEYS,...Ys],Pa=Object.freeze({en:Object.freeze({rangeStart:"Range start",rangeEnd:"Range end",selectedDate:"Selected date",macroRangeStart:"Macro range start",macroRangeEnd:"Macro range end",microRangeStart:"Micro range start",microRangeEnd:"Micro range end",microSelectedDate:"Micro selected date",decrease:"Decrease",increase:"Increase",previousYear:"Previous year",nextYear:"Next year",yearSelect:"Year",previousMonth:"Previous month",nextMonth:"Next month",monthSelect:"Month",previousDay:"Previous day",nextDay:"Next day",dateSelect:"Date",splitYear:"Year",splitMonth:"Month",splitDay:"Day"}),ja:Object.freeze({rangeStart:"期間の開始",rangeEnd:"期間の終了",selectedDate:"選択日",macroRangeStart:"広域期間の開始",macroRangeEnd:"広域期間の終了",microRangeStart:"詳細期間の開始",microRangeEnd:"詳細期間の終了",microSelectedDate:"詳細の選択日",decrease:"前へ",increase:"次へ",previousYear:"前年",nextYear:"翌年",yearSelect:"年",previousMonth:"前月",nextMonth:"翌月",monthSelect:"年月",previousDay:"前日",nextDay:"翌日",dateSelect:"日付",splitYear:"年",splitMonth:"月",splitDay:"日"})}),Hs=Object.freeze({en:Object.freeze({...ur.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Pa.en}),ja:Object.freeze({...ur.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Pa.ja})}),es=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,bc=e=>To.includes(e),vc=(e,t)=>{const r={};let n=!1;for(const o of ur.VIRTUAL_SCROLL_LABEL_KEYS){const a=t.has(o)?e[o]:void 0;a!==void 0&&(r[o]=a,n=!0)}return n?r:void 0},Sc=e=>{try{return ur.resolveVirtualScrollLocale(e)}catch(t){throw t instanceof RangeError?new RangeError(`[period-slider] locale is the UI language, not a BCP 47 tag (date formatting reads formatLocale): ${t.message}`,{cause:t}):t}},js=(e,t)=>{const r=Sc(e);if(t===void 0)return Hs[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${es(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[period-slider] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);const o=new Set(Object.keys(t));for(const u of o)if(!bc(u))throw new RangeError(`[period-slider] labels.${u} is not a known label key; expected one of ${To.join(", ")}`);const i={...ur.resolveVirtualScrollLabels(r,vc(t,o)),...Pa[r]};for(const u of Ys){const m=o.has(u)?t[u]:void 0;if(m!==void 0){if(typeof m!="string"||m.trim()==="")throw new RangeError(`[period-slider] labels.${u} must be a non-blank string; got ${es(m)}`);i[u]=m}}return Object.freeze(i)},xc=e=>{const t={};for(const r of ur.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Rc=(e,t)=>e===t||To.every(r=>e[r]===t[r]),Co=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0||e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const r=new Set(Object.keys(e)),n=Object.keys(t);if(r.size!==n.length)return!1;const o=e,a=t;return n.every(i=>r.has(i)&&Object.is(o[i],a[i]))},ga=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),ts=new Set(["hidden","clip","scroll","auto","overlay"]),rs=["paint","strict","content"],Mc=["layout","paint","strict","content"],Dc=["transform","perspective","filter"],gn=e=>e!==void 0&&e!==""&&e!=="none",yc=e=>e!==void 0&&e!==""&&e!=="normal",to=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},Ec=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,Pc=(e,t)=>t==="absolute"&&gn(e.position)&&e.position!=="static"||gn(e.transform)||gn(e.perspective)||gn(e.filter)||gn(e.backdropFilter)||yc(e.containerType)||Mc.some(r=>e.contain.includes(r))?!0:Dc.some(r=>e.willChange.includes(r)),Lc=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const u=e.getBoundingClientRect();if(u.width===0||u.height===0)return!1;const m=n?0:r,h=n?r:0;if(o<u.left-m||o>=u.right+m||a<u.top-h||a>=u.bottom+h)return!1;const f=i.getComputedStyle(t);if(f.visibility!=="visible")return!1;let x=null;for(let v=t;v!==null;v=v.parentElement){const P=v===t?f:i.getComputedStyle(v);if(x!==null&&!Pc(P,x))continue;const j=ts.has(P.overflowX)||rs.some(w=>P.contain.includes(w)),p=ts.has(P.overflowY)||rs.some(w=>P.contain.includes(w));if(j||p){const w=v.getBoundingClientRect();if(j&&(o<w.left+to(P.borderLeftWidth)||o>=w.right-to(P.borderRightWidth))||p&&(a<w.top+to(P.borderTopWidth)||a>=w.bottom-to(P.borderBottomWidth)))return!1}x=Ec(P)}return!0},pa=new Map,$c=(e,t)=>{if(!(t.shiftKey&&t.cancelable))return;for(const o of e)if(o.ownsHit(t.target)){o.step(t);return}let r=null,n=Number.POSITIVE_INFINITY;for(const o of e){const a=o.distanceToRailPx(t.clientX,t.clientY);a===null||a>=n||(r=o,n=a)}r?.step(t)},Tc=(e,t)=>{let r=pa.get(e);if(r===void 0){const a=new Set,i=u=>$c(a,u);r={participants:a,listener:i},pa.set(e,r),e.addEventListener("wheel",i,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(pa.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Dn="gap-[11px]",_t=6,Yt=_t*2,ar=_t*4/3,Cc={left:`0,${Yt/2} ${_t},0 ${_t},${Yt}`,right:`${ar},${Yt/2} ${ar-_t},0 ${ar-_t},${Yt}`,up:`${Yt/2},0 0,${_t} ${Yt},${_t}`,down:`${Yt/2},${ar} 0,${ar-_t} ${Yt},${ar-_t}`},wa=e=>{e.preventDefault(),e.stopPropagation()},kc={onMouseDownCapture:wa,onMouseUpCapture:wa,onClickCapture:wa},Ic="period-slider-step",Ac=`${Ic} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Oc="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]",Nc={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"},ro="after:inset-[calc((100%-var(--ps-target-size))/2)]",ns={horizontal:"px-[19px]",vertical:"py-[19px]"},Vc={control:{left:ro,right:ro,up:ro,down:ro},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)]"}},yr=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:i,ref:u})=>{const m=e==="up"||e==="down",h=m?Yt:ar,f=m?ar:Yt,x=r||!n;return $.jsx("button",{ref:u,type:"button","aria-label":a,disabled:r,"aria-disabled":x?!0:void 0,...x?kc:null,onClick:x?void 0:o,className:`${i===void 0?"":`${i} `}${Ac} ${Oc} ${Nc[t]} ${Vc[t][e]}`,children:$.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:h,height:f,viewBox:`0 0 ${h} ${f}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:$.jsx("polygon",{points:Cc[e]})})})},ko=(e,t)=>{const r=s.useMemo(()=>js(e,t),[e,t]),n=s.useRef(r);return Rc(n.current,r)||(n.current=r),n.current},ct=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${E(r)})`)},mr=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&ct(e,"values.min",t.min),t.max!==null&&ct(e,"values.max",t.max),t.min!==null&&t.max!==null&&t.max<t.min)throw new RangeError(`${e}: values.max must not precede values.min (min: ${t.min}, max: ${t.max})`);return}ct(e,"values.loIndex",t.loIndex),ct(e,"values.hiIndex",t.hiIndex)},On=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,Io=(e,t)=>{let r=e.loIndex,n=e.hiIndex+1;for(;r<n;){const o=r+n>>1;e.ascending[o]<t?r=o+1:n=o}return r},yn=(e,t)=>(mr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:On(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),En=(e,t)=>{if(mr("drawnValuesHas",e),ct("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(On(e))return!1;const r=Io(e,t);return r<=e.hiIndex&&e.ascending[r]===t},Pn=(e,t)=>{if(mr("drawnValuesNearest",e),ct("drawnValuesNearest","value",t),e.kind==="range")return e.min!==null&&t<e.min?e.min:e.max!==null&&t>e.max?e.max:t;if(On(e))return null;const r=Io(e,t);if(r>e.hiIndex)return e.ascending[e.hiIndex];if(e.ascending[r]===t||r===e.loIndex)return e.ascending[r];const n=e.ascending[r-1],o=e.ascending[r];return t-n<=o-t?n:o},Zt=(e,t,r)=>{if(mr("drawnValuesNeighbour",e),ct("drawnValuesNeighbour","value",t),e.kind==="range"){if(r===-1){const i=e.max===null?t-1:Math.min(t-1,e.max);return e.min!==null&&i<e.min?null:i}const a=e.min===null?t+1:Math.max(t+1,e.min);return e.max!==null&&a>e.max?null:a}if(On(e))return null;const n=Io(e,t);if(r===-1){const a=n-1;return a<e.loIndex?null:e.ascending[a]}const o=n<=e.hiIndex&&e.ascending[n]===t?n+1:n;return o>e.hiIndex?null:e.ascending[o]},mo=(e,t,r)=>{if(mr("clampPairIntoDrawnValues",e),ct("clampPairIntoDrawnValues","low",t),ct("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=Pn(e,t),o=Pn(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},_c=(e,t,r)=>{if(mr("carryPairIntoDrawnValues",e),ct("carryPairIntoDrawnValues","low",t),ct("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(On(e))return null;const n=yn(e,-1),o=yn(e,1),a=r-t;return o!==null&&r>o?mo(e,o-a,o):n!==null&&t<n?mo(e,n,n+a):mo(e,t,r)},fo=(e,t,r)=>(mr("drawnValuesAtOrBeyond",e),ct("drawnValuesAtOrBeyond","target",t),Zt(e,t-r,r)),tn=(e,t,r)=>{if(t!==null&&ct("drawnValuesWithin","min",t),r!==null&&ct("drawnValuesWithin","max",r),t!==null&&r!==null&&r<t)throw new RangeError(`drawnValuesWithin: max must not precede min (min: ${t}, max: ${r})`);const n={ascending:e,loIndex:0,hiIndex:e.length-1};let o=e.length;if(r!==null){let a=0;for(;a<o;){const i=a+o>>1;e[i]<=r?a=i+1:o=i}}return{kind:"candidates",ascending:e,loIndex:t===null?0:Io(n,t),hiIndex:o-1}},ho=e=>(mr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Zt(e,t,r),edge:t=>yn(e,t)}),La=(e,t,r,n,o)=>{if(ct("stepPair","low",t),ct("stepPair","high",r),r<t)throw new RangeError(`stepPair: high must not precede low (low: ${t}, high: ${r})`);if(n!==-1&&n!==1)throw new RangeError(`stepPair: direction must be -1 or 1 (received: ${E(n)})`);switch(o.motion){case"shift":{if(o.edge!=="disable"&&o.edge!=="clamp")throw new RangeError(`stepPair: rule.edge must be "disable" or "clamp" (received: ${E(o.edge)})`);const a=n===1?r:t,i=n===1?t:r,u=e.stepEnd(i,n);if(u===null)return null;let m=e.stepEnd(a,n);if(m===null){const h=e.edge(n);if(o.edge==="disable"||h===null||(n===1?a>h:a<h))return null;m=h}return n===1?[u,m]:[m,u]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${E(o.shows)})`);const a=e.stepEnd(o.shows==="start"?t:r,n);return a===null?null:[a,a]}default:throw new RangeError(`stepPair: rule.motion must be one of "shift", "start", "end", "single" (received: ${E(o.motion)})`)}},Us={"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"}},Ws=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,Tt=(e,t)=>{if(!Ws(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${E(t)})`)},fr=(e,t)=>t===void 0?0:(Tt(e,t),t),Ce=(e,t,r)=>{if(r!=="year"&&r!=="month"&&r!=="day")throw new RangeError(`${e}: ${t} must be one of "year", "month", "day" (received: ${E(r)})`)},Qt=(e,t,r,n)=>r===void 0?n:(Ce(e,t,r),r),Yc=[31,28,31,30,31,30,31,31,30,31,30,31],zs=719468,go=146097,$a=(e,t)=>t!==1?Yc[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,Ba=(e,t,r,n)=>{const o=e*12+t+n,a=Math.floor(o/12),i=o-a*12;return[a,i,Math.min(r,$a(a,i))]},Ln=(e,t,r)=>{const n=t<2?e-1:e,o=Math.floor(n/400),a=n-o*400,i=t<2?t+10:t-2,u=Math.floor((153*i+2)/5)+r-1,m=a*365+Math.floor(a/4)-Math.floor(a/100)+u;return o*go+m-zs},os=e=>{const t=e+zs,r=Math.floor(t/go),n=t-r*go,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(go-1)))/365),a=n-(o*365+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*a+2)/153),u=i<10?i+2:i-10;return[r*400+o+(u<2?1:0),u,a-Math.floor((153*i+2)/5)+1]},Ao=(e,t,r)=>e-(t<r?1:0),bt=(e,t,r=0)=>{if(Ce("normalizeDateByUnit","unit",e),!ye(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${E(t)})`);Tt("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(Ao(n.getFullYear(),n.getMonth(),r),r,1),n.setHours(0,0,0,0)):(e==="month"&&n.setDate(1),n.setHours(0,0,0,0)),n},Y=(e,t,r=0)=>{Ce("encode","unit",e),Tt("encode",r);const n=bt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:Ln(o,a,n.getDate())},oe=(e,t,r=0)=>{Ce("decode","unit",e),Tt("decode",r);const n=new Date(0);if(n.setHours(0,0,0,0),e==="year")return n.setFullYear(t,r,1),n;if(e==="month"){const a=Math.floor(t/12),i=t-a*12;return n.setFullYear(a,i,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},Nn=e=>`; ${e} instead of a sentinel for "no bound"`,Bs=Nn("minDate is required, so pass the earliest date to offer"),qe=(e,t,r,n,o,a)=>{const i=Vn(r,n,o);if(i===null)throw new RangeError(`${e}: ${t} must fall in a ${n} that starts inside the Date range (received: ${E(r)})${a}`);return i},Vn=(e,t,r)=>{const n=Y(t,e,r);return Number.isInteger(n)?n:null},Fs=(e,t,r)=>{if(Ce("addUnit","unit",e),!ye(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${E(t)})`);if(!Number.isInteger(r))throw new RangeError(`addUnit: amount must be an integer number of units (received: ${E(r)})`);const n=new Date(t.getTime());return r===0?n:e==="year"||e==="month"?(n.setFullYear(...Ba(n.getFullYear(),n.getMonth(),n.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},as=(e,t,r,n,o)=>{const a=Math.floor(t/12),[i,u,m]=e==="year"?[t,o,1]:e==="month"?[a,t-a*12,1]:os(t),[h,f,x]=r==="year"||r==="month"?Ba(i,u,m,r==="year"?n*12:n):os(Ln(i,u,m)+n);return e==="year"?Ao(h,f,o):e==="month"?h*12+f:Ln(h,f,x)},Ks=(e,t,r,n=0)=>{if(Ce("getMacroWindowStartDate","macroUnit",e),Ce("getMacroWindowStartDate","microUnit",t),!ye(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${E(r)})`);return Tt("getMacroWindowStartDate",n),qe("getMacroWindowStartDate","d",r,e,n,""),qe("getMacroWindowStartDate","d",r,t,n,""),bt(t,bt(e,r,n),n)},Gs=(e,t,r,n=0)=>{if(Ce("getMacroWindowEndDate","macroUnit",e),Ce("getMacroWindowEndDate","microUnit",t),!ye(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${E(r)})`);Tt("getMacroWindowEndDate",n);let o;const a=new Date(r.getTime());if(e==="year"&&t!=="year"){const[u,m]=Ba(Ao(a.getFullYear(),a.getMonth(),n),n,1,11);o=t==="month"?u*12+m:Ln(u,m,$a(u,m))}else if(e==="month"&&t==="day")o=Ln(a.getFullYear(),a.getMonth(),$a(a.getFullYear(),a.getMonth()));else return qe("getMacroWindowEndDate","d",r,t,n,""),bt(t,r,n);const i=oe(t,o,n);if(!ye(i))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${E(r)})`);return i},is=(e,t,r)=>e<t?t:e>r?r:e,yt=(e,t,r,n,o,a=0)=>{if(Ce("resolveMacroWindow","macroUnit",e),Ce("resolveMacroWindow","microUnit",t),Tt("resolveMacroWindow",a),xo("macroRange",r,!0,"resolveMacroWindow"),!ye(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${E(n)})`);if(!ye(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${E(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${E(n)}, maxDate: ${E(o)})`);qe("resolveMacroWindow","maxDate",o,t,a,""),qe("resolveMacroWindow","macroRange[0]",r[0],e,a,""),qe("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=Y(e,r[1],a)<Y(e,o,a)?is(Gs(e,t,r[1],a),n,o):o;return[bt(t,is(Ks(e,t,r[0],a),n,o),a),bt(t,i,a)]},qs=(e,t)=>{if(!ye(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${E(e)})`);Tt("resolveQuarter",t);const r=bt("year",e,t).getFullYear(),n=new Date(e.getTime()),o=((n.getMonth()-t)%12+12)%12,a=Math.floor(o/3)+1;return n.setFullYear(r,t+3*(a-1),1),n.setHours(0,0,0,0),{year:r,quarter:a,startDate:n}},Hc={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},ss=new Map,jc=(e,t)=>{const r=`${e}\0${t}`,n=ss.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Hc[e]);return ss.set(r,o),o},Uc=4,Wc=6,Oo=e=>e>=0?String(e).padStart(Uc,"0"):`-${String(-e).padStart(Wc,"0")}`,zc=(e,t)=>{const r=new Date(t.getTime()),n=Oo(r.getFullYear());if(e==="year")return n;const o=String(r.getMonth()+1).padStart(2,"0");if(e==="month")return`${n}-${o}`;const a=String(r.getDate()).padStart(2,"0");return`${n}-${o}-${a}`},nt=(e,t,r,n)=>(Ce("formatLabel","unit",e),ye(t)?r?r(t,e,"period"):n===void 0?zc(e,t):jc(e,n).format(t):""),Rr=(e,t,r,n)=>(Ce("formatScreenReaderLabel","unit",e),nt(e,t,r,n)),Bc=(e,t)=>{if(!ye(e))return"";Tt("formatQuarterLabel",t);const{quarter:r}=qs(e,t);return`${nt("year",bt("year",e,t))}-Q${r}`},De=(e,t,r,n=0)=>{if(Ce("findNearestDateIndex","unit",r),Tt("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!ye(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${E(t)})`);const o=qe("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=Y(r,e[a],n))return 0;if(o>=Y(r,e[i],n))return i;for(;a<=i;){const h=a+i>>1,f=Y(r,e[h],n);if(f===o)return h;f<o?a=h+1:i=h-1}const u=Math.abs(Y(r,e[a],n)-o),m=Math.abs(Y(r,e[i],n)-o);return u<m?a:i},Fc=(e,t,r,n,o=0)=>(Ce("getSortedAllowedDates","unit",t),dr("getSortedAllowedDates",No(e),t,r,n,o).dates),No=e=>({list:e,path:"allowedDates",inheritedBy:null}),dr=(e,t,r,n,o,a)=>{Tt(e,a);const{list:i,path:u}=t,m=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(en(e,`${u}${m}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[P,j]of[["minDate",n],["maxDate",o]])if(!ye(j))throw new RangeError(`${e}: ${P} must be a valid Date (received: ${E(j)})`);const h=qe(e,"minDate",n,r,a,""),f=qe(e,"maxDate",o,r,a,""),x=new Map;for(let P=0;P<i.length;P++){const j=i[P];if(!ye(j))throw new RangeError(`${e}: ${u}[${P}]${m} must be a valid Date (received: ${E(j)})`);const p=qe(e,`${u}[${P}]${m}`,j,r,a,"");p<h||p>f||x.has(p)||x.set(p,bt(r,j,a))}if(x.size===0)throw new RangeError(`${e}: every ${u} entry${m} falls outside [minDate, maxDate] (minDate: ${E(n)}, maxDate: ${E(o)}, entries: ${i.length})`);const v=Array.from(x.keys()).sort((P,j)=>P-j);return{keys:v,dates:v.map(P=>x.get(P))}},Fa=(e,t,r,n,o,a)=>{const{keys:i,dates:u}=dr(e,t,r,n,o,a);return u.length===0?null:{...tn(i,null,null),dates:u}},$n=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),no=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=De(e,n,t,o);if(r==="time"){const u=e[0].getTime(),m=e[a].getTime()-u;return m<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-u)/m))}return i/a},oo=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const u=e[0].getTime(),m=e[a].getTime()-u;return m<=0?0:De(e,new Date(u+i*m),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},Ta=(e,t,r,n,o,a,i)=>{let u=r,m=n;return i?(u=t,m=t):e==="low"?t>n?(u=n,m=t):u=t:t<r?(m=r,u=t):m=t,[Math.max(o,Math.min(a,u)),Math.max(o,Math.min(a,m))]},Xs=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:u,unit:m,yearStartMonth:h=0})=>{if(Ce("calculateConnectDragValues","unit",m),a){const p=i.length-1;if(p<=0)return[0,0];const w=Math.max(0,Math.min(p,Math.round(t))),c=Math.max(w,Math.min(p,Math.round(r)));if(u==="time"){const O=i[0].getTime(),ae=i[p].getTime(),J=i[w].getTime(),se=i[c].getTime()-J;let ne=J+e*(ae-O),A=ne+se;ne<O&&(ne=O,A=O+se),A>ae&&(A=ae,ne=ae-se);const ee=De(i,new Date(ne),m,h),M=De(i,new Date(A),m,h);return[ee,Math.max(ee,M)]}const g=Math.round(e*p);let d=w+g,re=c+g;return d<0&&(re+=-d,d=0),re>p&&(d-=re-p,re=p),[Math.max(0,Math.min(p,d)),Math.max(0,Math.min(p,re))]}const f=p=>Math.max(n,Math.min(o,p)),x=o-n;if(x<=0)return[f(t),f(r)];const v=Math.round(e*x);let P=t+v,j=r+v;return P<n&&(j+=n-P,P=n),j>o&&(P-=j-o,j=o),[f(P),f(j)]},Zs=(e,t,r,n,o,a,i,u)=>{let m=0,h=!1,f=!1;switch(e){case"ArrowRight":case"ArrowUp":m=u;break;case"ArrowLeft":case"ArrowDown":m=-u;break;case"PageUp":m=u*5;break;case"PageDown":m=-u*5;break;case"Home":h=!0;break;case"End":f=!0;break;default:return null}if(i){let P=r;return h?P=o:f?P=a:P=Math.max(o,Math.min(a,r+m)),[P,P]}let x=r,v=n;return t==="low"?h?x=o:f?x=n:x=Math.max(o,Math.min(n,r+m)):h?v=r:f?v=a:v=Math.max(r,Math.min(a,n+m)),[x,v]},Qs=8,Js=2,el=16,Kc=12,Gc=90,tl=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},Ka=(e,t)=>{const r=t?.estimatedHeightPx??el,o=Qs+(t?.anchorGapY??Js)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},Ga=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??el,u=o?.paddingPx??Kc,m=o?.maxAngleDeg??Gc,h=Qs+(o?.anchorGapY??Js),f=Ka(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return f;const x=Math.max(0,t-e)/100*r,v=a+u;if(x>=v)return f;const P=Math.max(0,Math.min(1,(v-x)/v)),p=P*P*P*(P*(P*6-15)+10)*m,w=n==="top"?-p:p,c=tl(a,i,p),g=h+c.acrossPx,d=n==="top"?-g:+g,re=2*c.alongPx,O=Math.max(0,(re+u-x)/2);return{lowAngleDeg:w,highAngleDeg:w,lowOffsetX:-O,highOffsetX:O,lowOffsetY:d,highOffsetY:d,isSlanted:P>.001,proximity:P}},rl=e=>({...e,lowOffsetX:0,highOffsetX:0}),Ht=(e,t)=>(e==="macro"?t.macroIsDiscrete:t.microIsDiscrete)===!0,Dt=(e,t)=>{const r=e==="macro"?t.macroAllowedDates:t.microAllowedDates;return r!==void 0?{list:r,path:e==="macro"?"macroAllowedDates":"microAllowedDates",inheritedBy:null}:{list:t.allowedDates,path:"allowedDates",inheritedBy:e}},po=(e,t,r,n)=>e==="pan"?_c(t,r,Math.max(r,n)):mo(t,r,Math.max(r,n)),qa=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},nl=(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 ol(e,t,r,n,o,a,i="macro-top",u=.05,m=!0,h="range"){if(qa(t,i)==="macro"){const v=Math.abs(e-r),P=Math.abs(e-n);return v<=u&&v<=P?"macro-low":P<=u&&P<v?"macro-high":m&&e>=r&&e<=n?"macro-connect":v<P?"macro-low":"macro-high"}if(h==="point")return"micro-point";const f=Math.abs(e-o),x=Math.abs(e-a);return f<=u&&f<=x?"micro-low":x<=u&&x<f?"micro-high":m&&e>=o&&e<=a?"micro-connect":f<x?"micro-low":"micro-high"}function al(e,t,r,n,o){if(e==="macro-connect"){const[h,f]=za(t-r,n,o);return[h,f,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,u]=So(a,t,n,o),m=$o(a,t,n,o);return[i,u,m==="low"?"macro-low":"macro-high"]}function il(e,t,r,n,o){if(e==="micro-point"){const[h]=So("point",t,n,o);return[h,h,"micro-point"]}if(e==="micro-connect"){const[h,f]=za(t-r,n,o);return[h,f,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,u]=So(a,t,n,o),m=$o(a,t,n,o);return[i,u,m==="low"?"micro-low":"micro-high"]}const xn=s.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",a=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",a=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return $.jsx("svg",{className:a,width:r?"8":"16",height:r?"16":"8",viewBox:r?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:$.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});xn.displayName="VernierKnobSvg";const qc=(e,t,r,n)=>{if(!ye(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${E(e)})`);if(!ye(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${E(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${E(e)}, maxDate: ${E(t)})`);for(const o of r)qe("PeriodSlider","minDate",e,o,n,Bs)},xo=(e,t,r,n="PeriodSlider")=>{if(!$t(t)||t.length!==2){const i=r?"is required and must":"must";throw new RangeError(`${n}: ${e} ${i} be a [start, end] Date tuple (received: ${E(t)})`)}const[o,a]=t;if(!ye(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${E(o)})`);if(!ye(a))throw new RangeError(`${n}: ${e}[1] must be a valid Date (received: ${E(a)})`);if(a.getTime()<o.getTime())throw new RangeError(`${n}: ${e} must not be inverted (start: ${E(o)}, end: ${E(a)})`)},sl=(e,t)=>{if(!ye(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${E(t)})`)},Fr=(e,t,r,n,o,a)=>{const i=qe("PeriodSlider",e,t,r,a,"");if(i<Y(r,n,a)||i>Y(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${E(t)}, minDate: ${E(n)}, maxDate: ${E(o)})`)},Xc=(e,t,r)=>{const n=e.yearStartMonth??0;if(e.mode==="range"){for(const o of["range","defaultRange"]){const a=e[o];a!==void 0&&(xo(o,a,!1),Fr(`${o}[0]`,a[0],e.unit,t,r,n),Fr(`${o}[1]`,a[1],e.unit,t,r,n))}return}if(e.mode==="point")for(const o of["value","defaultValue"]){const a=e[o];a!==void 0&&(sl(o,a),Fr(o,a,e.unit,t,r,n))}},Zc=(e,t,r)=>{const n=e.yearStartMonth??0;xo("macroRange",e.macroRange,!0),qe("PeriodSlider","macroRange[0]",e.macroRange[0],Qt("PeriodSlider","macroUnit",e.macroUnit,e.unit),n,"");const o=Qt("PeriodSlider","microUnit",e.microUnit,e.unit),a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,i=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&i)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(i){for(const h of["microValue","defaultMicroValue"]){const f=e[h];f!==void 0&&(sl(h,f),Fr(h,f,o,t,r,n))}const m=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(m===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[m,m]}}for(const m of["microRange","defaultMicroRange"]){const h=e[m];h!==void 0&&(xo(m,h,!1),Fr(`${m}[0]`,h[0],o,t,r,n),Fr(`${m}[1]`,h[1],o,t,r,n))}const u=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(u!==void 0)return{shape:"range",selection:u};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")},pn=(e,t,r,n,o,a,i,u,m)=>{const h=De(e,n,t,m),f=De(e,o,t,m);return i?h:u?f:Math.max(h,Math.min(f,De(e,r,t,m)+a))},ba=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null};function Qc(e,t){return t&&e[0].getTime()!==e[1].getTime()?[e[0],e[0]]:e}function Jc(e,t){return t?e==="micro-low"||e==="micro-high"||e==="micro-connect"?"micro-point":e:e==="micro-point"?"micro-high":e}const ls=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback((a,i)=>{const u=r.current;if(u!==null&&u[0].getTime()===a.getTime()&&u[1].getTime()===i.getTime())return;const m=[a,i];r.current=m,t(m)},[]),o=s.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Vo=(e,t,r)=>{try{Intl.DateTimeFormat.supportedLocalesOf([r])}catch{throw new RangeError(`${e}: ${t} must be a valid BCP 47 language tag (received: ${E(r)})`)}},zr=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const u of i){const m=u.borderBoxSize?.[0];m!==void 0&&t(h=>h!==null&&Math.abs(h.widthPx-m.inlineSize)<.5&&Math.abs(h.heightPx-m.blockSize)<.5?h:{widthPx:m.inlineSize,heightPx:m.blockSize})}});a.observe(o),r.current=a},[]);return s.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},va=(e,t)=>{const r=wo(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},wo=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},eu=e=>{const t={};let r=0;for(const o of e){const{side:a,box:i}=o;if(i===null)continue;let u;if(o.reach==="inline-size")u=i.widthPx,r=Math.max(r,i.heightPx/2);else{const m=tl(i.widthPx,i.heightPx,o.angleDeg);u=o.centreOffsetPx===null?2*m.acrossPx:Math.abs(o.centreOffsetPx)+m.acrossPx,r=Math.max(r,m.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${a}`]=`${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}},cs=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),us=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),Ro=(e,t)=>({"--ps-tooltip-tx":fa(e,"tx",t.tx),"--ps-tooltip-ty":fa(e,"ty",t.ty),"--ps-tooltip-rot":fa(e,"rot",t.rot)}),Sa=(e,t,r,n)=>{const o=Ka(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=Ga(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),i=n.isMerged?rl(a):a,u=Lo[e],m={low:cs(i.lowOffsetX,i.lowOffsetY-o.lowOffsetY,i.lowAngleDeg),high:cs(i.highOffsetX,i.highOffsetY-o.highOffsetY,i.highAngleDeg)};return{slant:i,lowStyle:Ro(u.low,m.low),highStyle:Ro(u.high,m.high),placements:m}},ds={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},ms=(e,t,r)=>{const n=Ka(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:ds,highStyle:ds,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const m=Ga(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?rl(m):m}const i=Lo.flat,u={low:us(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:us(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...Ro(i.low,u.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...Ro(i.high,u.high)},placements:o?u:null}},tu={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},ru={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"}},fs={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},nu={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Dn} ${ns.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${fs.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Dn} ${ns.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${fs.vertical}`}},hs={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"}},gs=(e,t)=>{e.setPointerCapture(t)},ou=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:u="",showStepper:m=!0,tooltipStyle:h="always",labelPosition:f="top",autoSlantLabels:x=!0,isVertical:v=!1,hideConnectBar:P=!1,showTicks:j=!1,colorScheme:p="blue-rose",formatLocale:w}=e;Ce("PeriodSlider","unit",t);const c=e.mode==="vernier"?Qt("PeriodSlider","macroUnit",e.macroUnit,t):t,g=e.mode==="vernier"?Qt("PeriodSlider","microUnit",e.microUnit,t):t,d=fr("PeriodSlider",e.yearStartMonth);qc(r,n,e.mode==="vernier"?[c,g,t]:[t],d),Xc(e,r,n),w!==void 0&&Vo("PeriodSlider","formatLocale",w);const re=e.mode==="vernier"?Zc(e,r,n):null,O=re!==null&&re.shape==="point",ae=ko(e.locale,e.labels),J=Us[p],se=s.useId(),ne=s.useRef(e),A=r.getTime(),ee=n.getTime(),M=e.mode==="vernier",D=s.useMemo(()=>M?[]:dr("PeriodSlider",No(o),t,r,n,d).dates,[M,o,t,A,ee,d]),L=D.length>0,{rangeMin:k,rangeMax:U}=s.useMemo(()=>L?{rangeMin:0,rangeMax:D.length-1}:{rangeMin:Y(t,r,d),rangeMax:Y(t,n,d)},[L,D,t,A,ee,d]),F=e.mode==="point",W=s.useCallback(l=>{if(L){const b=Math.max(0,Math.min(D.length-1,Math.round(l)));return D[b]}return oe(t,Math.round(l),d)},[L,D,t,d]),V=s.useCallback(l=>{if(l===void 0)return k;const b=bt(t,l,d);return L?De(D,b,t,d):Y(t,b,d)},[L,D,t,k,d]),[Q,ce]=s.useState(()=>re===null?null:re.selection),ve=Q??(re===null?null:re.selection),G=ve===null?null:Qc(ve,O);s.useLayoutEffect(()=>{G!==ve&&ce(l=>l===Q?G:l)});const _=e.mode==="vernier"?e.microValue?.getTime():void 0,Me=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,_]),Ee=ls(),ie=ls(),fe=e.mode!=="vernier"?null:O?Me??G:e.microRange!==void 0?e.microRange:G,ke=fe===null?null:ie.shown??fe,ot=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ke?.[0]:void 0,te=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ke?.[1]:void 0,T=e.mode==="point"?e.value??e.defaultValue:void 0,ue=e.mode==="point"?T?.getTime():ot?.getTime(),pe=e.mode==="range"?te?.getTime():ue,[at,$e]=s.useMemo(()=>{if(e.mode==="point"){const S=V(T);return[S,S]}const l=V(ot),b=V(te);return[Math.min(l,b),Math.max(l,b)]},[e.mode,ue,pe,V,T,ot,te]),He=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:O?e.microValue!==void 0:e.microRange!==void 0,[Ke,q]=s.useState(()=>M?null:[at,$e]),et=Ke??[at,$e],[it,gt]=s.useState(null),[Pe,st]=s.useState(null),Ve=s.useRef(null),[ft,Ge]=s.useState("high"),[dt,C]=s.useState(null),[Z,ze]=s.useState(null),Se=it?it[0]:He?at:et[0],ge=it?it[1]:He?$e:et[1],vt=s.useRef([Se,ge]),Ct=e.mode==="vernier"?e.vernierOrientation??(v?"macro-left":"macro-top"):"macro-top",z=Ct==="macro-top"||Ct==="macro-left",Pr=e.mode==="vernier"?e.showVernierProjection??!0:!1,rn=e.mode==="vernier"?e.showVernierTicks??!0:!1,I=e.mode==="vernier"?e.showHairline??!0:!1,le=M?Ht("macro",e):L,we=M?Ht("micro",e):L,Ye=M?Dt("macro",e).list:o,y=M?Dt("micro",e).list:o,H=M?e.formatMacroLabel??e.formatLabel:e.formatLabel,de=M?e.formatMicroLabel??e.formatLabel:e.formatLabel,_e=ot?.getTime(),Ie=te?.getTime(),[be,je]=s.useState(null),Xe=s.useRef(null),[kt,zt]=s.useState(()=>O?"micro-point":"micro-high"),Ue=Jc(kt,O);s.useLayoutEffect(()=>{Ue!==kt&&zt(l=>l===kt?Ue:l)});const pt=s.useMemo(()=>Y(c,r,d),[A,c,d]),It=s.useMemo(()=>Y(c,n,d),[ee,c,d]),Yn=s.useMemo(()=>M&&we?Fa("PeriodSlider",Dt("micro",e),g,r,n,d):null,[M,we,y,g,A,ee,d]),Ae=s.useMemo(()=>M&&le?dr("PeriodSlider",Dt("macro",e),c,r,n,d).dates:[],[M,le,Ye,c,A,ee,d]),ti=l=>[Math.max(pt,Math.min(It,Y(c,l[0],d))),Math.max(pt,Math.min(It,Y(c,l[1],d)))],[ri,ni]=e.mode!=="vernier"?[pt,It]:ti(e.macroRange),[Ze,lt]=Ee.shown===null?[ri,ni]:ti(Ee.shown),hr=s.useMemo(()=>oe(c,Ze,d),[c,Ze,d]),gr=s.useMemo(()=>oe(c,lt,d),[c,lt,d]),Hn=s.useMemo(()=>e.mode!=="vernier"?[r,n]:yt(c,g,[hr,gr],r,n,d),[e.mode,hr,gr,c,g,A,ee,d]),We=s.useMemo(()=>Y(g,Hn[0],d),[g,Hn,d]),tt=s.useMemo(()=>Y(g,Hn[1],d),[g,Hn,d]),Uo=(l,b)=>Yn===null?[]:$n(Yn,tn(Yn.ascending,l,b)),xe=s.useMemo(()=>Uo(We,tt),[Yn,We,tt]),Jt=le&&Ae.length>0,Et=we&&xe.length>0,oi=Jt?Y(c,Ae[0],d):pt,ai=Jt?Y(c,Ae[Ae.length-1],d):It,ii=Et?Y(g,xe[0],d):We,Wo=Et?Y(g,xe[xe.length-1],d):tt,Dl=Math.min(oi,Ze),yl=Math.max(ai,lt),er=(l,b,S,R)=>b.length>0?Y(g,b[De(b,l,g,d)],d):Math.max(S,Math.min(R,Y(g,l,d))),Lr=Et?xe:[],Be=s.useMemo(()=>ke===null?We:er(ke[0],Lr,We,tt),[_e,We,tt,g,ke,Lr]),rt=s.useMemo(()=>ke===null?tt:er(ke[1],Lr,We,tt),[Ie,We,tt,g,ke,Lr]),$r=s.useMemo(()=>oe(g,Be,d),[g,Be,d]),Tr=s.useMemo(()=>oe(g,rt,d),[g,rt,d]),si=!M||fe===null?null:{macroUnit:c,macroLowEnc:ri,macroHighEnc:ni,microUnit:g,microLowEnc:Y(g,fe[0],d),microHighEnc:Y(g,fe[1],d)},zo=s.useRef(si),Bo=Math.max(1,It-pt),Pt=Jt?no(Ae,c,a,hr,d):Math.max(0,Math.min(1,(Ze-pt)/Bo)),At=Math.max(Pt,Jt?no(Ae,c,a,gr,d):Math.min(1,(lt-pt)/Bo)),li=l=>Math.max(oi,Math.min(ai,Math.round(pt+l*Bo))),jn=Math.max(1,tt-We),Cr=Et?no(xe,g,a,$r,d):Math.max(0,Math.min(1,(Be-We)/jn)),nn=Math.max(Cr,Et?no(xe,g,a,Tr,d):Math.min(1,(rt-We)/jn)),Fo=s.useRef({timerId:null,emit:null}),Un=s.useRef({timerId:null,emit:null}),Wn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const l=[Fo,Un,Wn];return()=>{for(const b of l)ba(b.current)}},[]);const kr=s.useCallback((l,b,S)=>{ba(l);const{debounceMs:R}=ne.current;if(S||!R||R<=0){b();return}l.emit=b,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,b()},R)},[]),ci=s.useCallback(l=>{const b=l.emit;ba(l),b?.()},[]),Ir=s.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),A),ee)),[A,ee]),tr=s.useCallback((l,b,S=!1)=>{const[R,N]=vt.current;if((ne.current.mode==="point"?l===R:l===R&&b===N)&&Fo.current.timerId===null)return;const X=W(l),K=W(b),he=()=>{const Re=ne.current;Re.mode==="point"?Re.onChangePoint?.(X):Re.mode==="range"&&Re.onChangeRange?.(X,K)};kr(Fo.current,he,S)},[W,kr]),pr=s.useCallback((l,b,S=!1)=>{const R=zo.current;if(ne.current.mode!=="vernier"||R===null)return;const N=Ir(l),B=Ir(b);Y(R.macroUnit,N,d)===R.macroLowEnc&&Y(R.macroUnit,B,d)===R.macroHighEnc&&Un.current.timerId===null||kr(Un.current,()=>{const X=ne.current;X.mode==="vernier"&&X.onChangeMacroRange?.(N,B)},S)},[Ir,kr,d]),St=s.useCallback((l,b,S=!1)=>{const R=ne.current,N=zo.current;if(R.mode!=="vernier"||N===null)return;const B=Ir(l),X=Ir(b);Y(N.microUnit,B,d)===N.microLowEnc&&Y(N.microUnit,X,d)===N.microHighEnc&&Wn.current.timerId===null||((O?R.microValue===void 0:R.microRange===void 0)&&ce([B,X]),kr(Wn.current,()=>{const K=ne.current;if(K.mode==="vernier"){if(O){K.onChangeMicroPoint?.(B);return}K.onChangeMicroRange?.(B,X)}},S))},[Ir,kr,O,d]),ui=s.useCallback((l,b=!1)=>{St(l,l,b)},[St]),wr=s.useCallback(l=>{if(L&&a==="time"&&D.length>1){const R=Math.max(0,Math.min(D.length-1,Math.round(l))),N=D[0].getTime(),X=D[D.length-1].getTime()-N;if(X<=0)return 0;const K=D[R].getTime();return Math.max(0,Math.min(100,(K-N)/X*100))}const b=U-k;if(b<=0)return 0;const S=(l-k)/b*100;return Math.max(0,Math.min(100,S))},[L,a,D,k,U]),Ko=s.useCallback(l=>{const b=Math.max(0,Math.min(100,l));if(L){if(a==="time"&&D.length>1){const N=D[0].getTime(),X=D[D.length-1].getTime()-N,K=N+b/100*X;return De(D,new Date(K),t,d)}const R=Math.round(b/100*(D.length-1));return Math.max(0,Math.min(D.length-1,R))}const S=k+b/100*(U-k);return Math.round(S)},[L,a,D,k,U,t,d]),on=s.useRef(null),di=s.useRef(null),mi=s.useRef(0),ht=s.useRef(null),Go=s.useRef(null),fi=s.useRef(null),hi=s.useRef(null),[qo,gi]=s.useState(0),[El,Ar]=zr(),[Pl,pi]=zr(),[Ll,wi]=zr(),[$l,bi]=zr(),[Tl,Xo]=zr(),[Cl,vi]=zr(),kl=F?Ar===null?void 0:{estimatedWidthPx:Ar.widthPx,estimatedHeightPx:Ar.heightPx}:va(Ar,pi),Zo=!F&&Se===ge,Qo=Ze===lt,Jo=!O&&Be===rt,Il=z?"top":"bottom",Al=z?"bottom":"top",Si=x&&!v,Ol=Si&&!O,ea={isPointMode:F,isVertical:v,autoSlantLabels:x,isMerged:Zo,trackLengthPx:qo,labelPosition:f,config:kl},ta={trackLengthPx:qo,labelPosition:Il,config:va(wi,bi),isMerged:Qo,isSlantable:Si},ra={trackLengthPx:qo,labelPosition:Al,config:va(Xo,vi),isMerged:Jo,isSlantable:Ol};s.useEffect(()=>{const l=ht.current;if(!l)return;const b=()=>{const R=l.getBoundingClientRect(),N=v?R.height:R.width;N>0&&gi(B=>Math.abs(B-N)<.5?B:N)};if(b(),typeof ResizeObserver<"u"){const R=new ResizeObserver(N=>{for(const B of N){const X=v?B.contentRect.height:B.contentRect.width;X>0&&gi(K=>Math.abs(K-X)<.5?K:X)}});return R.observe(l),()=>R.disconnect()}const S=l.ownerDocument.defaultView;if(S)return S.addEventListener("resize",b),()=>S.removeEventListener("resize",b)},[v]);const Or=s.useCallback((l,b,S)=>{const R=v?S.height:S.width;if(!(Number.isFinite(R)&&R>0))return null;const N=v?S.bottom-b:l-S.left;return Number.isFinite(N)?Math.max(0,Math.min(1,N/R)):null},[v]),xi=s.useCallback((l,b)=>{const S=ht.current;if(!S)return null;const R=Or(l,b,S.getBoundingClientRect());return R===null?null:R*100},[Or]),an=s.useRef(null),Bt=s.useRef(null),zn=s.useRef({macroLowRatio:Pt,macroHighRatio:At,isVertical:v,isMacroFirstRail:z}),Ri=s.useRef({flat:ea,macro:ta,micro:ra});s.useLayoutEffect(()=>{zn.current={macroLowRatio:Pt,macroHighRatio:At,isVertical:v,isMacroFirstRail:z},Ri.current={flat:ea,macro:ta,micro:ra},ne.current=e,vt.current=[Se,ge],zo.current=si,Ve.current=Pe,Xe.current=be});const Mi=(l,b)=>{const S=zn.current;Go.current?.setAttribute("d",ha(l,b,S.isVertical,S.isMacroFirstRail))},Nl=(l,b,S)=>{const R=Ri.current;return l==="flat"?ms(b*100,S*100,R.flat).placements:Sa(l,b,S,l==="macro"?R.macro:R.micro).placements},sn=(l,b,S)=>{const R=ht.current;if(!R)return;an.current={rail:l,lowRatio:b,highRatio:S},pc(R,l,b,S);const N=Nl(l,b,S);N!==null&&gc(R,l,N),l==="macro"&&Mi(b,S)},br=s.useCallback(()=>{Bt.current!==null&&(clearTimeout(Bt.current),Bt.current=null);const l=ht.current;l&&(l.removeAttribute(da),l.style.removeProperty(ma))},[]),Di=()=>{const l=ht.current;if(an.current===null||!l){an.current=null;return}an.current=null,Bt.current!==null&&clearTimeout(Bt.current),l.style.setProperty(ma,`${Ji}ms`),l.setAttribute(da,"true"),wc(l),Mi(zn.current.macroLowRatio,zn.current.macroHighRatio),Bt.current=setTimeout(()=>{Bt.current=null,l.removeAttribute(da),l.style.removeProperty(ma)},Ji)};s.useLayoutEffect(()=>{const l=an.current;l!==null&&sn(l.rail,l.lowRatio,l.highRatio)}),s.useEffect(()=>()=>{Bt.current!==null&&clearTimeout(Bt.current)},[]);const Nr=s.useRef(null),Vr=s.useRef(null),Ot=s.useRef(null),na=s.useRef(null),ln=s.useRef(null),rr=s.useCallback(()=>Nr.current!==null||Vr.current!==null,[]),yi=l=>{if(i)return;if(M){const me=Vr.current;if(!me||l.pointerId!==me.pointerId||!ht.current)return;const Lt=Or(l.clientX,l.clientY,ht.current.getBoundingClientRect());if(Lt===null)return;if(me.handle==="macro-low"||me.handle==="macro-high"||me.handle==="macro-connect"){const[Qe,Fe,Ft]=al(me.handle,Lt,me.startPointerRatio,me.startMacroLowRatio,me.startMacroHighRatio);sn("macro",Qe,Fe),Ft!==Xe.current&&(Xe.current=Ft,je(Ft),zt(Ft));let Vt,wt,Kt;if(Jt){const Gt=oo(Ae,c,a,Qe,d),hn=Math.max(Gt,oo(Ae,c,a,Fe,d));wt=Ae[Gt],Kt=Ae[hn],Vt=Y(c,wt,d)}else Vt=li(Qe),wt=oe(c,Vt,d),Kt=oe(c,li(Fe),d);Ee.show(wt,Kt);const nr=`${wt.getTime()}_${Kt.getTime()}`;nr!==na.current&&(na.current=nr,pr(wt,Kt));const[fn,sc]=yt(c,g,[wt,Kt],r,n,d),Jn=Y(g,fn,d),eo=Y(g,sc,d),qi=we?Uo(Jn,eo):[],Xi={kind:"range",min:Jn,max:eo};let Sr,xr;if(me.handle==="macro-connect"){const Gt=Vt-me.startMacroLowEnc,hn=po("pan",Xi,as(g,me.initialMicroLowEnc,c,Gt,d),as(g,me.initialMicroHighEnc,c,Gt,d));if(hn===null)return;Sr=oe(g,hn[0],d),xr=oe(g,hn[1],d)}else{const Gt=po("resize",Xi,me.initialMicroLowEnc,me.initialMicroHighEnc);if(Gt===null)return;Sr=oe(g,Gt[0],d),xr=oe(g,Gt[1],d)}const Zi=er(Sr,qi,Jn,eo),lc=Math.max(Zi,er(xr,qi,Jn,eo));Sr=oe(g,Zi,d),xr=oe(g,lc,d),ie.show(Sr,xr);const Qi=`${Sr.getTime()}_${xr.getTime()}`;Qi!==ln.current&&(ln.current=Qi,St(Sr,xr))}else if(me.handle==="micro-low"||me.handle==="micro-high"||me.handle==="micro-connect"||me.handle==="micro-point"){const[Qe,Fe,Ft]=il(me.handle,Lt,me.startPointerRatio,me.startMicroLowRatio,me.startMicroHighRatio);sn("micro",Qe,Fe),Ft!==Xe.current&&(Xe.current=Ft,je(Ft),zt(Ft));let Vt,wt;if(Et){const nr=oo(xe,g,a,Qe,d),fn=Math.max(nr,oo(xe,g,a,Fe,d));Vt=xe[nr],wt=xe[fn]}else{const nr=er(oe(g,Math.round(We+Qe*jn),d),Lr,We,tt),fn=Math.max(nr,er(oe(g,Math.round(We+Fe*jn),d),Lr,We,tt));Vt=oe(g,nr,d),wt=oe(g,fn,d)}ie.show(Vt,wt);const Kt=`${Vt.getTime()}_${wt.getTime()}`;Kt!==ln.current&&(ln.current=Kt,St(Vt,wt))}return}const b=Nr.current;if(!b||l.pointerId!==b.pointerId||!ht.current)return;const S=ht.current.getBoundingClientRect(),R=v?l.clientY:l.clientX,N=v?S.height:S.width;if(!(Number.isFinite(N)&&N>0))return;if(b.handle==="connect"){const me=v?(b.startPointerPos-R)/N:(R-b.startPointerPos)/N,[Lt,Qe]=za(me,b.startLowRatio,b.startHighRatio);sn("flat",Lt,Qe);const Fe=Xs({posDiffPct:me,startLowVal:b.startLowVal,startHighVal:b.startHighVal,rangeMin:k,rangeMax:U,isDiscrete:L,sortedAllowedDates:D,snapMode:a,unit:t,yearStartMonth:d});if(Ot.current&&Ot.current[0]===Fe[0]&&Ot.current[1]===Fe[1])return;Ot.current=Fe,gt(Fe),tr(Fe[0],Fe[1],!1);return}const B=Or(l.clientX,l.clientY,S);if(B===null)return;const[X,K]=So(F?"point":b.handle,B,b.startLowRatio,b.startHighRatio);sn("flat",X,K);const he=Ko(B*100),[Re,Oe]=Ta(b.handle,he,b.startLowVal,b.startHighVal,k,U,F);if((!Ot.current||Ot.current[0]!==Re||Ot.current[1]!==Oe)&&(Ot.current=[Re,Oe],gt([Re,Oe]),tr(Re,Oe,!1)),!F&&(b.handle==="low"||b.handle==="high")){const me=$o(b.handle,B,b.startLowRatio,b.startHighRatio);Ve.current!==me&&(Ve.current=me,st(me),Ge(me))}},Ei=()=>{Di(),na.current=null,ln.current=null,Vr.current=null,Xe.current=null,je(null),Ee.release(),ie.release(),ci(Un.current),ci(Wn.current)},Pi=()=>{Di();const l=Ot.current??it;l&&(tr(l[0],l[1],!0),q(l)),Ot.current=null,gt(null),Nr.current=null,Ve.current=null,st(null)},Li=l=>{if(M){const S=Vr.current;if(!S||l.pointerId!==S.pointerId)return;Ei();return}const b=Nr.current;!b||l.pointerId!==b.pointerId||Pi()},$i=()=>{Vr.current!==null&&Ei(),Nr.current!==null&&Pi()},oa=s.useRef(yi),Ti=s.useRef(Li),Ci=s.useRef($i);s.useLayoutEffect(()=>{oa.current=yi,Ti.current=Li,Ci.current=$i});const ki=s.useRef(M);s.useEffect(()=>{ki.current!==M&&(ki.current=M,Ci.current())},[M]);const Ii=Pe!==null||be!==null;s.useEffect(()=>{if(!Ii)return;const l=on.current?.ownerDocument.defaultView;if(!l)return;const b=R=>oa.current(R),S=R=>Ti.current(R);return l.addEventListener("pointermove",b),l.addEventListener("pointerup",S),l.addEventListener("pointercancel",S),l.addEventListener("lostpointercapture",S),()=>{l.removeEventListener("pointermove",b),l.removeEventListener("pointerup",S),l.removeEventListener("pointercancel",S),l.removeEventListener("lostpointercapture",S)}},[Ii]);const aa=s.useCallback((l,b,S,R)=>{br(),gs(l,b),Nr.current={pointerId:b,handle:S,startPointerPos:R,startLowVal:Se,startHighVal:ge,startLowRatio:wr(Se)/100,startHighRatio:wr(ge)/100},Ve.current=S,st(S),S!=="connect"&&Ge(S)},[Se,ge,wr]),Ai=s.useCallback((l,b,S,R)=>{ne.current.mode==="vernier"&&(br(),gs(l,b),Vr.current={pointerId:b,handle:S,startPointerRatio:R,startMacroLowRatio:Pt,startMacroHighRatio:At,startMicroLowRatio:Cr,startMicroHighRatio:nn,startMacroLowEnc:Ze,initialMicroLowEnc:Be,initialMicroHighEnc:rt},Xe.current=S,je(S),zt(S))},[Pt,At,Cr,nn,Ze,Be,rt]),Oi=l=>b=>{if(i||rr())return;b.stopPropagation(),b.preventDefault(),Ge(l);const S=v?b.clientY:b.clientX;aa(b.currentTarget,b.pointerId,l,S)},Ni=l=>()=>{i||Ve.current!==null||Ge(l)},Bn=l=>()=>{i||Xe.current!==null||zt(l)},_r=l=>b=>{if(i||rr())return;b.stopPropagation(),b.preventDefault();const S=ht.current;if(!S)return;const R=Or(b.clientX,b.clientY,S.getBoundingClientRect());R!==null&&Ai(b.currentTarget,b.pointerId,l,R)},Vl=l=>{if(i||P||rr())return;l.stopPropagation(),l.preventDefault();const b=v?l.clientY:l.clientX;aa(l.currentTarget,l.pointerId,"connect",b)},_l=l=>{if(i||rr())return;if(M){const K=ht.current;if(!K)return;const he=K.getBoundingClientRect(),Re=Or(l.clientX,l.clientY,he);if(Re===null)return;const Oe=v?l.clientX-(he.left+he.width/2):l.clientY-(he.top+he.height/2),me=ol(Re,Oe,Pt,At,Cr,nn,Ct,void 0,!P,O?"point":"range");Ai(l.currentTarget,l.pointerId,me,Re),oa.current(l.nativeEvent);return}const b=xi(l.clientX,l.clientY);if(b===null)return;const S=Ko(b);let R="low";if(!F){const K=Math.abs(S-Se),he=Math.abs(S-ge);K<he?R="low":he<K?R="high":R=S>ge?"high":"low"}Ge(R);const[N,B]=Ta(R,S,Se,ge,k,U,F);gt([N,B]),tr(N,B,!0);const X=v?l.clientY:l.clientX;aa(l.currentTarget,l.pointerId,R,X)},Yl=l=>{if(i||M||Pe!==null)return;const b=xi(l.clientX,l.clientY);if(b===null)return;const S=Ko(b);C(S),ze(wr(S))},Hl=()=>{C(null),ze(null)},Vi=l=>b=>{if(i||rr())return;Ge(l);const S=Zs(b.key,l,Se,ge,k,U,F,1);S&&(b.preventDefault(),br(),He||q(S),tr(S[0],S[1],!0))},Yr=(l,b,S)=>{if(fe===null)return;const[R,N]=yt(c,g,[l,b],r,n,d),B=Y(g,R,d),X=Y(g,N,d),K=we?Uo(B,X):[],he=po(S,{kind:"range",min:B,max:X},Y(g,fe[0],d),Y(g,fe[1],d));if(he===null)return;const Re=er(oe(g,he[0],d),K,B,X),Oe=Math.max(Re,er(oe(g,he[1],d),K,B,X));St(oe(g,Re,d),oe(g,Oe,d),!0)},Fn=l=>b=>{if(i||!M||e.mode!=="vernier"||rr())return;zt(l);let S=0,R=!1,N=!1;switch(b.key){case"ArrowRight":case"ArrowUp":S=1;break;case"ArrowLeft":case"ArrowDown":S=-1;break;case"PageUp":S=5;break;case"PageDown":S=-5;break;case"Home":R=!0;break;case"End":N=!0;break;default:return}if(b.preventDefault(),br(),l==="macro-low"){const B=oe(c,Ze,d),X=oe(c,lt,d);if(Jt){const Re=pn(Ae,c,B,Ae[0],X,S,R,N,d);if(Re===De(Ae,B,c,d))return;const Oe=Ae[Re];pr(Oe,X,!0),Yr(Oe,X,"resize");return}let K;if(R?K=pt:N?K=lt:K=Math.max(pt,Math.min(lt,Ze+S)),K===Ze)return;const he=oe(c,K,d);pr(he,X,!0),Yr(he,X,"resize")}else if(l==="macro-high"){const B=oe(c,Ze,d),X=oe(c,lt,d);if(Jt){const Re=pn(Ae,c,X,B,Ae[Ae.length-1],S,R,N,d);if(Re===De(Ae,X,c,d))return;const Oe=Ae[Re];pr(B,Oe,!0),Yr(B,Oe,"resize");return}let K;if(R?K=Ze:N?K=It:K=Math.max(Ze,Math.min(It,lt+S)),K===lt)return;const he=oe(c,K,d);pr(B,he,!0),Yr(B,he,"resize")}else if(l==="micro-low"){const B=oe(g,Be,d),X=oe(g,rt,d);if(Et){const he=pn(xe,g,B,xe[0],X,S,R,N,d);if(he===De(xe,B,g,d))return;St(xe[he],X,!0);return}let K;if(R?K=We:N?K=rt:K=Math.max(We,Math.min(rt,Be+S)),K===Be)return;St(oe(g,K,d),X,!0)}else if(l==="micro-high"){const B=oe(g,Be,d),X=oe(g,rt,d);if(Et){const he=pn(xe,g,X,B,xe[xe.length-1],S,R,N,d);if(he===De(xe,X,g,d))return;St(B,xe[he],!0);return}let K;if(R?K=Be:N?K=tt:K=Math.max(Be,Math.min(tt,rt+S)),K===rt)return;St(B,oe(g,K,d),!0)}else if(l==="micro-point"){const B=oe(g,Be,d);if(Et){const K=pn(xe,g,B,xe[0],xe[xe.length-1],S,R,N,d);if(K===De(xe,B,g,d))return;ui(xe[K],!0);return}let X;if(R?X=We:N?X=tt:X=Math.max(We,Math.min(tt,Be+S)),X===Be)return;ui(oe(g,X,d),!0)}},jl=l=>{if(e.mode!=="vernier")return;if(br(),Jt){const X=Ae.length-1,K=De(Ae,hr,c,d),he=De(Ae,gr,c,d),Re=he-K;let Oe=K+l,me=he+l;if(l<0&&Oe<0?(Oe=0,me=Math.min(X,Re)):l>0&&me>X&&(me=X,Oe=Math.max(0,X-Re)),Oe===K&&me===he)return;const Lt=Ae[Oe],Qe=Ae[me];pr(Lt,Qe,!0),Yr(Lt,Qe,"pan");return}const b=lt-Ze;let S=Ze+l,R=lt+l;if(l<0&&S<pt?(S=pt,R=Math.min(It,S+b)):l>0&&R>It&&(R=It,S=Math.max(pt,R-b)),S===Ze&&R===lt)return;const N=oe(c,S,d),B=oe(c,R,d);pr(N,B,!0),Yr(N,B,"pan")},ia=s.useCallback(l=>{const b=ne.current;if(!(b.disabled||rr()))if(br(),b.mode==="point"){const S=Math.max(k,Math.min(U,Se+l));He||q([S,S]),tr(S,S,!0)}else if(b.mode==="vernier"){if(Et){const Re=xe.length-1,Oe=De(xe,$r,g,d),me=De(xe,Tr,g,d),Lt=me-Oe;let Qe=Oe+l,Fe=me+l;l<0&&Qe<0?(Qe=0,Fe=Math.min(Re,Lt)):l>0&&Fe>Re&&(Fe=Re,Qe=Math.max(0,Re-Lt)),(Qe!==Oe||Fe!==me)&&St(xe[Qe],xe[Fe],!0);return}const S=Be,R=rt,N=We,B=tt,X=R-S;let K=S+l,he=R+l;l<0&&K<N?(K=N,he=Math.min(B,K+X)):l>0&&he>B&&(he=B,K=Math.max(N,he-X)),(K!==S||he!==R)&&St(oe(g,K,d),oe(g,he,d),!0)}else{const S=ge-Se;let R=Se+l,N=ge+l;l<0&&R<k?(R=k,N=Math.min(U,R+S)):l>0&&N>U&&(N=U,R=Math.max(k,N-S)),R<=N&&(He||q([R,N]),tr(R,N,!0))}},[Se,ge,k,U,He,tr,St,Be,rt,We,tt,g,Et,xe,$r,Tr,br,d]),_i=l=>!i&&ga(on.current,l),Yi=(l,b)=>{const S=di.current,R=ht.current,N=on.current;if(i||S===null||R===null||N===null||!Lc(S,N,mi.current,v,l,b))return null;const B=R.getBoundingClientRect();return Math.abs(v?l-(B.left+B.width/2):b-(B.top+B.height/2))},Hi=l=>{if(i||rr())return;const b=nl(l.deltaX,l.deltaY,v);if(b===0)return;l.preventDefault();const S=l.target,R=ga(fi.current,S)||ga(hi.current,S);if(!M||R){ia(b);return}const N=ht.current;if(!N)return;const B=N.getBoundingClientRect(),X=v?l.clientX-(B.left+B.width/2):l.clientY-(B.top+B.height/2);if(qa(X,Ct)==="macro"){jl(b);return}ia(b)},Kn=s.useRef({ownsWheelHit:_i,distanceToRailPx:Yi,stepFromRangeAreaWheel:Hi});s.useLayoutEffect(()=>{Kn.current={ownsWheelHit:_i,distanceToRailPx:Yi,stepFromRangeAreaWheel:Hi}});const cn=s.useRef(null);s.useEffect(()=>{const l=on.current?.ownerDocument.defaultView??null,b=cn.current;if(b!==null&&b.view===l)return;if(b?.unregister(),l===null){cn.current=null;return}const S=Tc(l,{ownsHit:R=>Kn.current.ownsWheelHit(R),distanceToRailPx:(R,N)=>Kn.current.distanceToRailPx(R,N),step:R=>Kn.current.stepFromRangeAreaWheel(R)});cn.current={view:l,unregister:S}}),s.useEffect(()=>()=>{cn.current?.unregister(),cn.current=null},[]);const Gn=wr(Se),qn=wr(ge),sa=W(Se),la=W(ge),ca=ms(Gn,qn,ea),un=ca.slant,dn=Pe==="low"||Pe!=="high"&&ft==="low",mn=!F&&(Pe==="high"||Pe!=="low"&&ft==="high"),Ul=Qo&&Ue!=="macro-low",Wl=Qo&&Ue==="macro-low",zl=Jo&&Ue!=="micro-low",Bl=Jo&&Ue==="micro-low",Hr=Sa("macro",Pt,At,ta),jr=Sa("micro",Cr,nn,ra),Fl=Math.min(Gn,qn),Kl=Math.max(Gn,qn),[ji,Ui]=Rn.flat,[Gl,ql]=Rn.macro,[Xl,Zl]=Rn.micro,Wi=or(ji,Gn),zi=or(Ui,qn),ua=or(ji,Fl),Bi=`calc(${or(Ui,Kl)} - ${ua})`,Ur=or(Gl,Pt*100),Xn=or(ql,At*100),Wr=or(Xl,Cr*100),Zn=or(Zl,nn*100),Ql=v?{bottom:ua,height:Bi,top:"auto",left:"0",right:"0"}:{left:ua,width:Bi,top:"0",bottom:"0"},Jl=Math.max(.01,At-Pt),Fi=Math.max(.06,Math.min(.25,.28*Math.sqrt(Jl))),ec=v?{bottom:Wi,left:"50%",transform:"translate(-50%, 50%)",zIndex:dn?40:30}:{left:Wi,top:"50%",transform:"translate(-50%, -50%)",zIndex:dn?40:30},tc=v?{bottom:zi,left:"50%",transform:"translate(-50%, 50%)",zIndex:mn?40:30}:{left:zi,top:"50%",transform:"translate(-50%, -50%)",zIndex:mn?40:30},rc=v?{bottom:`${Z}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Z}%`,top:"50%",transform:"translate(-50%, -50%)"},Ki=dt!==null?W(dt):null,nc=h!=="hover"&&dt!==null&&(dt===Se||!F&&dt===ge),oc=M?Be>ii:Se>k,ac=M?rt<Wo:ge<U,Qn=eu(M?[{side:z?"before":"after",box:wo(wi,bi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:Hr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Hr.slant.lowOffsetX}},{side:z?"after":"before",box:O?Xo:wo(Xo,vi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:jr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:jr.slant.lowOffsetX}}]:[{side:v||f==="top"?"before":"after",box:F?Ar:wo(Ar,pi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:un.lowAngleDeg,centreOffsetPx:un.lowOffsetY,alongPushPx:un.lowOffsetX}}]),ic=Qn===void 0?e.style:{...e.style,...Qn.style};s.useLayoutEffect(()=>{mi.current=Qn===void 0?0:Qn.mainPx});const Nt=O?"micro-point":"micro-low",vr=i?"cursor-not-allowed opacity-50":"cursor-pointer",Gi=l=>{const b=v?"vertical":"horizontal",S=l==="decrease",R=v?!S:S;return $.jsx(yr,{ref:S?fi:hi,neighbour:"rail",direction:tu[b][l],disabled:i,canStep:S?oc:ac,onStep:()=>ia(S?-1:1),ariaLabel:S?ae.decrease:ae.increase,className:`period-slider-stepper-btn ${ru[b][l]} ${hs[b][R?"leading":"trailing"]}`})};return $.jsxs("div",{ref:on,style:ic,className:`period-slider grid select-none place-items-center ${nu[v?"vertical":"horizontal"][m?"withSteppers":"railOnly"]} ${u}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":v?"vertical":"horizontal","data-label-position":f,"data-color-scheme":p,children:[$.jsx("div",{ref:di,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),m&&Gi(v?"increase":"decrease"),$.jsx("div",{ref:ht,"data-testid":"period-slider-track","data-orientation":v?"vertical":"horizontal","data-vernier-orientation":M?Ct:void 0,className:`period-slider-track relative touch-none rounded-full ${hs[v?"vertical":"horizontal"][m?"rail":"railOnly"]} ${vr}`,onPointerDown:_l,onPointerMove:Yl,onPointerLeave:Hl,children:M?$.jsxs($.Fragment,{children:[Pr&&(v?$.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:[$.jsx("defs",{children:$.jsxs("linearGradient",{id:se,x1:"0",y1:"0",x2:"1",y2:"0",children:[$.jsx("stop",{offset:"0%",stopColor:z?J.macro:J.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:z?J.micro:J.macro,stopOpacity:Fi})]})}),$.jsx("path",{ref:Go,"data-testid":"period-slider-vernier-projection",d:ha(Pt,At,v,z),fill:`url(#${se})`})]}):$.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[$.jsx("defs",{children:$.jsxs("linearGradient",{id:se,x1:"0",y1:"0",x2:"0",y2:"1",children:[$.jsx("stop",{offset:"0%",stopColor:z?J.macro:J.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:z?J.micro:J.macro,stopOpacity:Fi})]})}),$.jsx("path",{ref:Go,"data-testid":"period-slider-vernier-projection",d:ha(Pt,At,v,z),fill:`url(#${se})`})]})),!P&&$.jsxs($.Fragment,{children:[$.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:v?{bottom:`calc(${Ur} - 8px)`,height:`calc(${Xn} - ${Ur} + 16px)`}:{left:`calc(${Ur} - 8px)`,width:`calc(${Xn} - ${Ur} + 16px)`},onPointerDown:_r("macro-connect")}),!O&&$.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:v?{bottom:`calc(${Wr} - 8px)`,height:`calc(${Zn} - ${Wr} + 16px)`}:{left:`calc(${Wr} - 8px)`,width:`calc(${Zn} - ${Wr} + 16px)`},onPointerDown:_r("micro-connect")})]}),rn&&$.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(l=>$.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:v?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`macro-tick-${l}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(l=>$.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:v?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`micro-tick-${l}`))]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ae.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Dl,"aria-valuemax":lt,"aria-valuenow":Ze,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(hr,c,"period"):Rr(c,hr,H,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Ur,left:z?0:"auto",right:z?"auto":0,transform:z?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:be==="macro-low"||Ue==="macro-low"?30:15}:{left:Ur,top:z?0:"auto",bottom:z?"auto":0,transform:z?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:be==="macro-low"||Ue==="macro-low"?30:15},onPointerDown:_r("macro-low"),onKeyDown:Fn("macro-low"),onFocus:Bn("macro-low"),"data-active":be==="macro-low"?"true":void 0,"data-front":Ue==="macro-low"?"true":void 0,"data-vernier-pos":v?z?"left":"right":z?"top":"bottom","data-handle-type":"macro-low",children:[$.jsx(xn,{type:"macro",isTop:z,isVertical:v,isLeft:z}),I&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":Ul?"true":void 0,"data-slanted":Hr.slant.isSlanted?"true":void 0,ref:Ll,style:Hr.lowStyle,children:nt(c,hr,H,w)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ae.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Ze,"aria-valuemax":yl,"aria-valuenow":lt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(gr,c,"period"):Rr(c,gr,H,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Xn,left:z?0:"auto",right:z?"auto":0,transform:z?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:be==="macro-high"||Ue==="macro-high"?30:15}:{left:Xn,top:z?0:"auto",bottom:z?"auto":0,transform:z?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:be==="macro-high"||Ue==="macro-high"?30:15},onPointerDown:_r("macro-high"),onKeyDown:Fn("macro-high"),onFocus:Bn("macro-high"),"data-active":be==="macro-high"?"true":void 0,"data-front":Ue==="macro-high"?"true":void 0,"data-vernier-pos":v?z?"left":"right":z?"top":"bottom","data-handle-type":"macro-high",children:[$.jsx(xn,{type:"macro",isTop:z,isVertical:v,isLeft:z}),I&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":Wl?"true":void 0,"data-slanted":Hr.slant.isSlanted?"true":void 0,ref:$l,style:Hr.highStyle,children:nt(c,gr,H,w)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":O?ae.microSelectedDate:ae.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":ii,"aria-valuemax":O?Wo:rt,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText($r,g,"period"):Rr(g,$r,de,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Wr,left:z?"auto":0,right:z?0:"auto",transform:z?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:be===Nt||Ue===Nt?30:20}:{left:Wr,top:z?"auto":0,bottom:z?0:"auto",transform:z?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:be===Nt||Ue===Nt?30:20},onPointerDown:_r(Nt),onKeyDown:Fn(Nt),onFocus:Bn(Nt),"data-active":be===Nt?"true":void 0,"data-front":Ue===Nt?"true":void 0,"data-vernier-pos":v?z?"right":"left":z?"bottom":"top","data-handle-type":Nt,children:[$.jsx(xn,{type:"micro",isTop:!z,isVertical:v,isLeft:!z}),I&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":zl?"true":void 0,"data-slanted":jr.slant.isSlanted?"true":void 0,ref:Tl,style:jr.lowStyle,children:nt(g,$r,de,w)})]}),!O&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ae.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Be,"aria-valuemax":Wo,"aria-valuenow":rt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Tr,g,"period"):Rr(g,Tr,de,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Zn,left:z?"auto":0,right:z?0:"auto",transform:z?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:be==="micro-high"||Ue==="micro-high"?30:20}:{left:Zn,top:z?"auto":0,bottom:z?0:"auto",transform:z?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:be==="micro-high"||Ue==="micro-high"?30:20},onPointerDown:_r("micro-high"),onKeyDown:Fn("micro-high"),onFocus:Bn("micro-high"),"data-active":be==="micro-high"?"true":void 0,"data-front":Ue==="micro-high"?"true":void 0,"data-vernier-pos":v?z?"right":"left":z?"bottom":"top","data-handle-type":"micro-high",children:[$.jsx(xn,{type:"micro",isTop:!z,isVertical:v,isLeft:!z}),I&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":Bl?"true":void 0,"data-slanted":jr.slant.isSlanted?"true":void 0,ref:Cl,style:jr.highStyle,children:nt(g,Tr,de,w)})]})]}):$.jsxs($.Fragment,{children:[!P&&$.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Ql,onPointerDown:Vl}),j&&L&&D.length>1&&$.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:D.map((l,b)=>{const S=Y(t,l,d),R=wr(b),N=v?{bottom:`${R}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${R}%`,top:"50%",transform:"translate(-50%, -50%)"};return $.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:N},`tick-${S}`)})}),!i&&dt!==null&&Z!==null&&Pe===null&&Ki&&$.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:rc,children:[$.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"}),$.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":nc?"true":void 0,className:`period-slider-hover-tooltip ${f==="bottom"&&!v?"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:nt(t,Ki,e.formatLabel,w)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":F?ae.selectedDate:ae.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":k,"aria-valuemax":F?U:ge,"aria-valuenow":Se,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(sa,t,"period"):Rr(t,sa,e.formatLabel,w),"aria-orientation":v?"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 ${vr}`,style:ec,onPointerDown:Oi("low"),onKeyDown:Vi("low"),onFocus:Ni("low"),"data-active":Pe==="low"?"true":void 0,"data-front":dn?"true":void 0,children:[$.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 ${Pe==="low"?"":"shadow-md"}`}),h!=="hover"&&$.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":f,"data-slanted":un.isSlanted?"true":void 0,"data-front":dn?"true":void 0,"data-duplicate":Zo&&!dn?"true":void 0,ref:El,style:ca.lowStyle,children:nt(t,sa,e.formatLabel,w)})]}),!F&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ae.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Se,"aria-valuemax":U,"aria-valuenow":ge,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(la,t,"period"):Rr(t,la,e.formatLabel,w),"aria-orientation":v?"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 ${vr}`,style:tc,onPointerDown:Oi("high"),onKeyDown:Vi("high"),onFocus:Ni("high"),"data-active":Pe==="high"?"true":void 0,"data-front":mn?"true":void 0,children:[$.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 ${Pe==="high"?"":"shadow-md"}`}),h!=="hover"&&$.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":f,"data-slanted":un.isSlanted?"true":void 0,"data-front":mn?"true":void 0,"data-duplicate":Zo&&!mn?"true":void 0,ref:Pl,style:ca.highStyle,children:nt(t,la,e.formatLabel,w)})]})]})}),m&&Gi(v?"decrease":"increase")]})},Je=e=>e.getTime(),ll=(e,t)=>!($t(e)&&$t(t))||e.length!==2||t.length!==2?!1:Mt(e[0],Je)===Mt(t[0],Je)&&Mt(e[1],Je)===Mt(t[1],Je),ao=(e,t)=>e===void 0||t===void 0?e===t:ll(e,t),xa=(e,t)=>{if(e===t)return!0;if(!($t(e)&&$t(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(Mt(e[r],Je)!==Mt(t[r],Je))return!1;return!0},cl=(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},au=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||Mt(e.minDate,Je)!==Mt(t.minDate,Je)||Mt(e.maxDate,Je)!==Mt(t.maxDate,Je)||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||!cl(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!Co(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!xa(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(mt(e.value,Je)!==mt(t.value,Je)||mt(e.defaultValue,Je)!==mt(t.defaultValue,Je)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!ao(e.range,t.range)||!ao(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!ao(e.microRange,t.microRange)||!ao(e.defaultMicroRange,t.defaultMicroRange)||mt(e.microValue,Je)!==mt(t.microValue,Je)||mt(e.defaultMicroValue,Je)!==mt(t.defaultMicroValue,Je)||!ll(e.macroRange,t.macroRange)||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||!xa(e.macroAllowedDates,t.macroAllowedDates)||!xa(e.microAllowedDates,t.microAllowedDates)):!1,ul=s.memo(ou,au);ul.displayName="PeriodSlider";const ps=2,Te=-1,xt=e=>Y("day",e),Tn=e=>oe("day",e),wn=e=>`${Oo(e.getFullYear())}-${String(e.getMonth()+1).padStart(ps,"0")}-${String(e.getDate()).padStart(ps,"0")}`,iu=(e,t,r,n)=>{const o=xt(e),a=xt(t),i=a>=o?a-o+1:0,u=h=>Tn(a-h),m={kind:"range",min:o,max:a};return{count:i,dateAt:u,labelAt:h=>nt("day",u(h),n,r),indexOf:h=>{const f=xt(h);return f<o||f>a?Te:a-f},nearestIndexOf:h=>{if(i===0)return Te;const f=Pn(m,xt(h));return f===null?Te:a-f}}},su=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,u=x=>e[n-x],m={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},h=x=>{const v=x.getTime();let P=r,j=n;for(;P<=j;){const p=P+j>>1,w=e[p].getTime();if(w===v)return n-p;w<v?P=p+1:j=p-1}return Te},f=x=>x===null?Te:h(Tn(x));return{count:i,dateAt:u,labelAt:x=>nt("day",u(x),a,o),indexOf:h,nearestIndexOf:x=>f(Pn(m,xt(x)))}},lu={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${E(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${E(e)})`)},indexOf:()=>Te,nearestIndexOf:()=>Te},cu=(e,t,r)=>{const n=u=>{let m=0,h=e.length;for(;m<h;){const f=m+h>>1;e[f].getTime()<u?m=f+1:h=f}return m},o=u=>{let m=0,h=e.length;for(;m<h;){const f=m+h>>1;e[f].getTime()<=u?m=f+1:h=f}return m},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},uu=(e,t)=>{const r=new Map;for(let n=0;n<e.length;n++){const o=e[n];t(n,o);const a=new Date(o);a.setHours(0,0,0,0);const i=a.getTime();r.has(i)||r.set(i,a)}return Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},du={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},mu={month:2,day:2},ws={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},bs=new Map,fu=(e,t)=>{const r=`${e}\0${t}`,n=bs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,du[e]);return bs.set(r,o),o},hu=(e,t,r)=>{if(r!==void 0)return fu(e,r).format(t);const n=new Date(t.getTime());return e==="year"?Oo(ws.year(n)):String(ws[e](n)).padStart(mu[e],"0")},dl=(e,t,r,n)=>{if(Ce("formatOptionText","unit",t),r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${E(r)})`);return ye(e)?r==="part"?hu(t,e,n):nt(t,e,void 0,n):""},gu=12,_o=(e,t,r)=>{const n=Vn(e,t,r);return n===null?Number.NaN:n*gu+r},Xa=(e,t,r)=>{const n=o=>o.value!==void 0?o.value:o.initialDate;return mt(n(e),r)!==mt(n(t),r)||t.value!==void 0&&Number.isNaN(mt(t.initialDate,r))||mt(e.minDate,r)!==mt(t.minDate,r)?!1:mt(e.maxDate,r)===mt(t.maxDate,r)};class ml{held;writeCount=0;constructor(t){this.held=t}get current(){return this.held}set current(t){this.held=t,this.writeCount+=1}get writes(){return this.writeCount}commit(t,r){this.writeCount===r&&(this.held=t)}}function fl(e,t){const[r]=s.useState(()=>t(e)),n=r.writes;return s.useInsertionEffect(()=>{r.commit(e,n)}),r}function ut(e){return fl(e,t=>new ml(t))}const pu={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},wu=["shift","start","end","single"],bu=["disable","clamp"],vu=["follow","keep"],vs={day:{day:1},month:{month:1,year:12},year:{year:1}},Ss=new WeakMap,Ca=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${E(r)})`)},xs=(e,t,r,n)=>{for(const[o,a]of Object.entries(r))if(!(a===void 0||n.includes(o)))throw new RangeError(`${e}: ${t}.${o} is not read here; the accepted keys are ${n.map(i=>`"${i}"`).join(", ")} (received: ${E(a)})`)},Er=(e,t,r,n)=>{Ca(e,t,r),xs(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];Ca(e,a,i),xs(e,a,i,pu[n]);const{motion:u,edge:m,window:h}=i;if(n!=="vernierPoint"&&(typeof u!="string"||!wu.includes(u)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${E(u)})`);if(m!==void 0){if(u!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${E(m)} with motion ${E(u)})`);if(typeof m!="string"||!bu.includes(m))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${E(m)})`)}if(h!==void 0&&(typeof h!="string"||!vu.includes(h)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${E(h)})`)}},Za=(e,t,r)=>{if(typeof t!="object"||t===null)throw new RangeError(`${e}: stepper must be an object (received: ${E(t)})`);const{onStep:n,canStepPrevious:o,canStepNext:a}=t;if(typeof n!="function")throw new RangeError(`${e}: stepper.onStep must be a function (received: ${E(n)})`);if(typeof o!="boolean")throw new RangeError(`${e}: stepper.canStepPrevious must be a boolean (received: ${E(o)})`);if(typeof a!="boolean")throw new RangeError(`${e}: stepper.canStepNext must be a boolean (received: ${E(a)})`);if(!r)throw new RangeError(`${e}: stepper requires the controlled value; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled initialDate would never change`)},qt=(e,t,r,n,o)=>{if(!ye(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${E(r)})`);return qe(e,t,r,n,o,"")},hl=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=Ss.get(r),u=i?.get(a);if(u!==void 0)return u;const m=[];for(let f=0;f<r.length;f++)m.push(qt(e,`${t}[${f}]`,r[f],n,o));const h=Array.from(new Set(m)).sort((f,x)=>f-x);return i===void 0?Ss.set(r,new Map([[a,h]])):i.set(a,h),h},Su=(e,t)=>t===1?ho(e):{stepEnd:(r,n)=>fo(e,r+t*n,n),edge:r=>yn(e,r)},ka=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},Ia=(e,t,r,n,o,a)=>{if(a){const m=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:oe(n,e[0],o);return Number.isNaN(m.getTime())?null:[m,m]}const i=e[0]===t[0]?r[0]:oe(n,e[0],o),u=e[1]===t[1]?r[1]:oe(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(u.getTime())?null:[i,u.getTime()<i.getTime()?i:u]},Aa=e=>{const t="resolveSelectorSteps";Ca(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:u,rules:m}=e;Ce(t,"unit",o);const h=Qt(t,"stepUnit",e.stepUnit,o),f=vs[o][h];if(f===void 0){const d=Object.keys(vs[o]).map(re=>`"${re}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${d} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${E(h)})`)}const x=fr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${E(n)})`);if(!$t(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${E(r)})`);Er(t,"rules",m,"motion");const v=qt(t,"selection[0]",r[0],o,x),P=qt(t,"selection[1]",r[1],o,x);if(P<v)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${E(r[0])}, end: ${E(r[1])})`);const j=a===void 0?null:qt(t,"minDate",a,o,x),p=i===void 0?null:qt(t,"maxDate",i,o,x);if(j!==null&&p!==null&&p<j)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${E(a)}, maxDate: ${E(i)})`);en(t,"allowedDates",u);const w=u===void 0?{kind:"range",min:j,max:p}:tn(hl(t,"allowedDates",u,o,x),j,p),c=Su(w,f),g=(d,re)=>{const O=La(c,v,P,d,ka(re,n));return O===null?null:Ia(O,[v,P],r,o,x,re.motion==="single")};return{previous:g(-1,m.previous),next:g(1,m.next)}},jt=(e,t)=>{const r=ut({targets:e,onStepTo:t}),n=s.useCallback(i=>{const{targets:u,onStepTo:m}=r.current,h=u[i];h!==null&&m(h,i)},[]),o=e.previous!==null,a=e.next!==null;return s.useMemo(()=>({onStep:n,canStepPrevious:o,canStepNext:a}),[n,o,a])};function xu(e,t,r,n){return e.source===t?e:t===null?{source:t,held:e.held}:{source:t,held:n(r)}}function Qa(e,t,r,n){const o=t?null:r(e),[a,i]=s.useState(()=>({source:o,held:n(e)})),u=s.useCallback(h=>i(f=>({source:f.source,held:h})),[]),m=xu(a,o,e,n);return s.useLayoutEffect(()=>{m!==a&&i(h=>h===a?m:h)}),[m.held,u]}const bo=44,Rs=7,io=8,Ru=2,gl=10,Mu=1e3,Oa=8,Ra=6,Ma=4,Da=12,bn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),xt(r)},Du=(e,t)=>{if(e.length<Ma||t.count===0)return Te;const r=Number(e.slice(0,Ma));if(!Number.isInteger(r))return Te;const n=e.length>=Ra,o=n?Number(e.slice(Ma,Ra)):Da;if(o<1||o>Da)return Te;const a=e.length>=Oa,i=a?Number(e.slice(Ra,Oa)):0,u=bn(r,o),m=(o===Da?bn(r+1,1):bn(r,o+1))-1,h=a?u+i-1:n?u:bn(r,1),f=a?h:n?m:bn(r+1,1)-1;if(a&&(i<1||h>m))return Te;for(let x=f;x>=h;x--){const v=t.indexOf(Tn(x));if(v!==Te)return v}return Te},yu=e=>e.closest(".dark")===null?"light":"dark",Eu=(e,t,r,n)=>{const o=r-e.bottom-io,a=e.top-io,i=o>=t||o>=a,m=Math.max(bo,Math.min(t,i?o:a)),h=i?e.bottom:e.top-m,f=e.width+gl,x=Math.max(io,Math.min(e.left,n-f-io));return{top:h,left:x,width:f,height:m}},Pu=(e,t)=>e<t?e:t>0?t-1:Te,pl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:u,labels:m,onCommitIndex:h,controlClassName:f})=>{const x=s.useId(),v=s.useMemo(()=>xc(m),[m]),P=`period-slider-date-listbox-${x}`,j=s.useCallback(T=>`period-slider-date-option-${x}-${T}`,[x]),[p,w]=s.useState(!1),[c,g]=s.useState(Te),[d,re]=s.useState(null),[O,ae]=s.useState(null),J=s.useRef(null),se=s.useRef(null),ne=s.useRef(null),A=s.useRef({buffer:"",at:0}),ee=e.count,M=Pu(c,ee),D=ut(M);s.useLayoutEffect(()=>{M!==c&&g(T=>T===c?M:T)});const L=Math.min(ee,Rs)*bo,k=Math.max(1,Math.min(ee,Rs)),U=s.useCallback(()=>{const T=J.current;if(T===null)return;const ue=T.getBoundingClientRect();re(Eu(ue,L,window.innerHeight,window.innerWidth))},[L]),F=ut(p),W=s.useCallback(()=>{w(!1),g(Te),A.current={buffer:"",at:0},F.current=!1},[F]);s.useLayoutEffect(()=>()=>{F.current&&W()},[F,W]);const V=s.useCallback(T=>{a||ee===0||(g(T),w(!0),F.current=!0)},[a,ee,F]);s.useLayoutEffect(()=>{if(!p){re(null),ae(null);return}const T=J.current;return T!==null&&ae(yu(T)),U(),window.addEventListener("scroll",U,!0),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,!0),window.removeEventListener("resize",U)}},[p,U]),s.useEffect(()=>{if(!p)return;const T=ue=>{const pe=ue.target;pe!==null&&se.current?.contains(pe)!==!0&&J.current?.contains(pe)!==!0&&W()};return document.addEventListener("pointerdown",T,!0),()=>document.removeEventListener("pointerdown",T,!0)},[p,W]),s.useEffect(()=>{p&&(a||ee===0)&&W()},[p,a,ee,W]),s.useEffect(()=>{if(!p)return;const T=D.current;T!==Te&&ne.current?.scrollToIndex(T,{align:"center"})},[ee,p,D]);const Q=T=>{if(ee===0)return;const ue=Math.max(0,Math.min(T,ee-1));g(ue),ne.current?.scrollToIndex(ue,{align:"center"})},ce=T=>{T<0||T>=ee||(h(T),W(),J.current?.focus())},ve=ut(ce),G=T=>{if(a||J.current===null)return;const ue=M!==Te?M:t!==Te?t:r;switch(T.key){case"ArrowDown":if(T.preventDefault(),!p){V(ue);return}Q(ue+1);return;case"ArrowUp":if(T.preventDefault(),!p){V(ue);return}Q(ue-1);return;case"Home":if(!p)return;T.preventDefault(),Q(0);return;case"End":if(!p)return;T.preventDefault(),Q(ee-1);return;case"PageDown":if(!p)return;T.preventDefault(),Q(ue+k);return;case"PageUp":if(!p)return;T.preventDefault(),Q(ue-k);return;case"Enter":if(T.preventDefault(),!p){V(ue);return}ce(M!==Te?M:ue);return;case"Escape":if(!p)return;T.preventDefault(),W();return;case"Tab":p&&W();return}if(T.key.length!==1)return;const pe=T.key>="0"&&T.key<="9",at=T.key==="-"||T.key==="/"||T.key===".";if(!(pe||at))return;T.preventDefault();const $e=Date.now(),He=$e-A.current.at>Mu?"":A.current.buffer,Ke=pe?`${He}${T.key}`.slice(0,Oa):He;A.current={buffer:Ke,at:$e};const q=Du(Ke,e);if(q!==Te){if(!p){V(q);return}Q(q)}},_=s.useCallback(T=>T,[]),Me=s.useCallback(()=>bo,[]),Ee=M===Te?null:j(M),ie=s.useCallback(()=>{const T=J.current;if(T===null||Ee===null)throw new Error("VirtualDateDropdown: the active row attached without its combobox control or an active option id, so aria-activedescendant has nothing to name it on");return T.setAttribute("aria-activedescendant",Ee),()=>{T.getAttribute("aria-activedescendant")===Ee&&T.removeAttribute("aria-activedescendant")}},[Ee]),fe=s.useCallback(T=>{const ue=T===t,pe=T===M;return $.jsx("div",{id:j(T),role:"option","aria-selected":ue,"aria-posinset":T+1,"aria-setsize":e.count,"data-testid":"period-slider-date-option","data-active":pe?"true":void 0,ref:pe?ie:void 0,className:"period-slider-date-option",style:{height:bo},onClick:()=>ve.current(T),children:e.labelAt(T)})},[e,t,M,j,ve,ie]),ke=s.useCallback(T=>(se.current=T,T.style.removeProperty("display"),()=>{se.current=null,T.style.setProperty("display","none","important")}),[]),ot=p&&d!==null&&O!==null&&ee>0,te=ot?$.jsx("div",{ref:ke,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":O,style:{top:d.top,left:d.left,width:d.width,height:d.height},onMouseDown:T=>{T.preventDefault()},children:$.jsx(ur.VirtualScroll,{ref:ne,itemCount:ee,getItem:_,getItemHeight:Me,viewportSize:d.height-Ru,initialScrollIndex:M!==Te?M:void 0,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:u,labels:v,contentProps:{id:P,role:"listbox","aria-label":i},scrollBarOptions:{width:gl,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:fe})}):null;return $.jsxs($.Fragment,{children:[$.jsx("input",{ref:J,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":p,"aria-controls":ot?P:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none",disabled:a,value:n,className:f,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:G,onMouseDown:T=>{a||J.current===null||(T.preventDefault(),J.current?.focus(),p?W():V(t!==Te?t:r))},onBlur:()=>{p&&W()}}),te===null?null:uc.createPortal(te,document.body)]})};pl.displayName="VirtualDateDropdown";const vn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Lu=Nn("leave the bound out where the variant allows it, or declare the days to offer with minYear / maxYear or allowedDates"),$u=Nn('variant="split-dropdown" requires both bounds, so declare the years to offer with minYear / maxYear'),Tu=31,Sn=(e,t,r)=>{if(!ye(t))throw new RangeError(`DateSelector: ${e} must be a valid Date (received: ${E(t)})`);qe("DateSelector",e,t,"day",0,r)},ir=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},so=e=>ir(e,1,1),Ms=e=>ir(e,12,31),wl=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,Ds=(e,t,r,n)=>wl(e,t,r)&&e.getDate()===n,Ja=e=>Vn(e,"year",0)!==null,ei=e=>_o(e,"day",0),Cu=e=>Ja(e)?ei(e):Number.NaN,lo=(e,t,r)=>{if(!Ja(t))throw new RangeError(`DateSelector: ${e} must fall in a year that starts inside the Date range, because variant="split-dropdown" draws its year (received: ${E(t)})${r}`)},ys=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const u=r(i);if(Number.isNaN(u.getTime()))break;n(u,i)&&a.push({value:i,label:o(u)})}return a},ku=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedDates:f,variant:x="date",className:v="",style:P,disabled:j=!1,locale:p,labels:w,formatLocale:c,formatOption:g}=e;c!==void 0&&Vo("DateSelector","formatLocale",c);const d=x==="split-dropdown"?$u:Lu;if(t!==void 0&&Sn("value",t,""),r!==void 0&&Sn("initialDate",r,""),m!==void 0&&Sn("minDate",m,d),h!==void 0&&Sn("maxDate",h,d),x==="split-dropdown"&&(t!==void 0&&lo("value",t,""),r!==void 0&&lo("initialDate",r,""),m!==void 0&&lo("minDate",m,d),h!==void 0&&lo("maxDate",h,d)),i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: minYear must be an integer year (received: ${E(i)})`);if(u!==void 0&&!Number.isInteger(u))throw new RangeError(`DateSelector: maxYear must be an integer year (received: ${E(u)})`);if(i!==void 0&&Number.isNaN(so(i).getTime()))throw new RangeError(`DateSelector: minYear must name a year whose first day starts inside the Date range (received: ${E(i)})`);if(u!==void 0&&Number.isNaN(Ms(u).getTime()))throw new RangeError(`DateSelector: maxYear must name a year whose last day starts inside the Date range (received: ${E(u)})`);if(x==="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');en("DateSelector","allowedDates",f);const re=t??r;if(re===void 0)throw new RangeError("DateSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected date is never inferred from the wall clock");o!==void 0&&Za("DateSelector",o,t!==void 0);const O=ko(p,w),ae=t!==void 0,[J,se]=Qa(re,ae,ei,vn),ne=t?.getTime(),A=s.useMemo(()=>t!==void 0?vn(t):J,[ne,J]);if(x==="split-dropdown"&&!ae&&!Ja(A))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${E(A)}), because that selection's year starts outside the Date range; control the date with value to decide what the split dropdown holds`);const ee=m?.getTime(),M=h?.getTime(),D=s.useMemo(()=>{const C=m?vn(m):null,Z=i!==void 0?so(i):null;return C===null?Z:Z===null||C.getTime()>=Z.getTime()?C:Z},[ee,i]),L=s.useMemo(()=>{const C=h?vn(h):null,Z=u!==void 0?Ms(u):null;return C===null?Z:Z===null||C.getTime()<=Z.getTime()?C:Z},[M,u]),k=D?.getTime()??null,U=L?.getTime()??null;if(D!==null&&L!==null&&D.getTime()>L.getTime())throw new RangeError(`DateSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${wn(D)}, upper: ${wn(L)})`);if(x!=="date"&&f===void 0&&(D===null||L===null))throw new RangeError(`DateSelector: variant=${E(x)} requires a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate)${x==="dropdown"?", or allowedDates":""}; the option list is never invented`);const F=s.useMemo(()=>f===void 0?null:f.map(C=>Mt(C,Z=>Z.getTime())).join(","),[f]),W=s.useMemo(()=>{if(f===void 0)return null;const C=uu(f,(Z,ze)=>Sn(`allowedDates[${Z}]`,ze,""));return{ascending:C,ascendingSerials:C.map(xt)}},[F]),V=s.useMemo(()=>W===null?null:{...W,...cu(W.ascending,D,L)},[W,k,U]),Q=s.useMemo(()=>V!==null?su(V.ascending,V.ascendingSerials,V.loIndex,V.hiIndex,c,g):D===null||L===null?lu:iu(D,L,c,g),[V,k,U,c,g]),ce=s.useMemo(()=>V!==null?{kind:"candidates",ascending:V.ascendingSerials,loIndex:V.loIndex,hiIndex:V.hiIndex}:{kind:"range",min:D===null?null:xt(D),max:L===null?null:xt(L)},[V,k,U]),ve=C=>!Number.isNaN(C.getTime())&&En(ce,xt(C)),G=C=>{if(j)return;const Z=vn(C);ve(Z)&&(ae||se(Z),n?.(Z))},_=A.getTime(),Me=ve(A),Ee=s.useMemo(()=>{const C=Zt(ce,xt(A),-1);if(C===null)return null;const Z=Tn(C);return Number.isNaN(Z.getTime())?null:Z},[ce,_]),ie=s.useMemo(()=>{const C=Zt(ce,xt(A),1);if(C===null)return null;const Z=Tn(C);return Number.isNaN(Z.getTime())?null:Z},[ce,_]),fe=()=>{if(o!==void 0){o.onStep("previous");return}Ee!==null&&G(Ee)},ke=()=>{if(o!==void 0){o.onStep("next");return}ie!==null&&G(ie)},ot=C=>{if(C.target.value){const Z=cc.parseISO(C.target.value);Number.isNaN(Z.getTime())||G(Z)}},te=A.getFullYear(),T=A.getMonth()+1,ue=A.getDate(),pe=s.useCallback((C,Z)=>g?g(Z,C,"part"):dl(Z,C,"part",c),[g,c]),at=s.useMemo(()=>{if(x!=="split-dropdown"||D===null||L===null)return[];const C=[];for(let Z=L.getFullYear();Z>=D.getFullYear();Z--)C.push({value:Z,label:pe("year",so(Z))});return C},[x,k,U,pe]),$e=s.useMemo(()=>{if(x!=="split-dropdown"||D===null||L===null)return[];const C=D,Z=L,ze=te===C.getFullYear()?C.getMonth()+1:1,Se=te===Z.getFullYear()?Z.getMonth()+1:12;return ys(ze,Se,ge=>ir(te,ge,1),(ge,vt)=>wl(ge,te,vt),ge=>pe("month",ge))},[x,k,U,te,pe]),He=s.useMemo(()=>{if(x!=="split-dropdown"||D===null||L===null)return[];const C=D,Z=L,ze=te===C.getFullYear()&&T===C.getMonth()+1?C.getDate():1,Se=te===Z.getFullYear()&&T===Z.getMonth()+1?Z.getDate():Tu;return ys(ze,Se,ge=>ir(te,T,ge),(ge,vt)=>Ds(ge,te,T,vt),ge=>pe("day",ge))},[x,k,U,te,T,pe]),Ke=(C,Z,ze)=>{const Se=ir(C,Z,ze);return Ds(Se,C,Z,ze)&&ve(Se)},q=(C,Z,ze)=>{Ke(C,Z,ze)&&G(ir(C,Z,ze))},et=at.some(C=>C.value===te),it=$e.some(C=>C.value===T),gt=He.some(C=>C.value===ue),Pe=wn(A),st=x==="dropdown"?nt("day",A,g,c):"",Ve=D?wn(D):void 0,ft=L?wn(L):void 0,Ge="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 $.jsxs("div",{className:`inline-flex items-center ${Dn} ${v}`,style:P,"data-variant":x,"data-out-of-range":Me?void 0:"true",children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:j,canStep:o===void 0?Ee!==null:o.canStepPrevious,onStep:fe,ariaLabel:O.previousDay}),x==="dropdown"?$.jsx(pl,{domain:Q,selectedIndex:Me?Q.indexOf(A):Te,openAnchorIndex:Q.nearestIndexOf(A),displayLabel:st,machineValue:Pe,disabled:j,ariaLabel:O.dateSelect,locale:p,labels:O,onCommitIndex:C=>G(Q.dateAt(C)),controlClassName:"period-slider-date-combobox-field w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"}):x==="split-dropdown"?$.jsxs("div",{className:"inline-flex items-center gap-1",children:[$.jsxs("select",{"aria-label":O.splitYear,disabled:j,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:et?te:"",onChange:C=>q(Number(C.target.value),T,ue),children:[et?null:$.jsx("option",{value:"",disabled:!0,className:Ge,children:pe("year",so(te))}),at.map(C=>$.jsx("option",{value:C.value,disabled:!Ke(C.value,T,ue),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":O.splitMonth,disabled:j,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:it?T:"",onChange:C=>q(te,Number(C.target.value),ue),children:[it?null:$.jsx("option",{value:"",disabled:!0,className:Ge,children:pe("month",ir(te,T,1))}),$e.map(C=>$.jsx("option",{value:C.value,disabled:!Ke(te,C.value,ue),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":O.splitDay,disabled:j,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:gt?ue:"",onChange:C=>q(te,T,Number(C.target.value)),children:[gt?null:$.jsx("option",{value:"",disabled:!0,className:Ge,children:pe("day",ir(te,T,ue))}),He.map(C=>$.jsx("option",{value:C.value,disabled:!Ke(te,T,C.value),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]})]}):$.jsx("input",{"aria-label":O.dateSelect,disabled:j,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:Pe,min:Ve,max:ft,onChange:ot,type:"date"}),$.jsx(yr,{neighbour:"control",direction:"right",disabled:j,canStep:o===void 0?ie!==null:o.canStepNext,onStep:ke,ariaLabel:O.nextDay}),a]})},Iu=(e,t)=>!(!Xa(e,t,t.variant==="split-dropdown"?Cu:ei)||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.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!Co(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),bl=s.memo(ku,Iu);bl.displayName="DateSelector";function _n(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(0);return o.setHours(0,0,0,0),o.setFullYear(r,n,1),o}function Cn(e){const t=Vn(e,"month",0);return oe("month",t===null?Number.NaN:t,0)}const vl=e=>_o(e,"month",0);function Mr(e){return`${Oo(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const Es=Nn("leave the bound out where the variant allows it, or declare the months to offer with minYear / maxYear or allowedMonths");function co(e,t,r){e!==void 0&&Sl(e,t,r)}function Sl(e,t,r){if(!ye(e))throw new RangeError(`MonthSelector: ${t} must be a valid Date (received: ${E(e)})`);qe("MonthSelector",t,e,"month",0,r)}function Ps(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`MonthSelector: ${t} must be an integer year (received: ${E(e)})`);if(Number.isNaN(_n(e,r).getTime()))throw new RangeError(`MonthSelector: ${t} must name a year whose ${r===0?"January":"December"} starts inside the Date range (received: ${E(e)})`)}}function Au(e,t){const r=e===void 0?null:_n(e,0),n=t===void 0?null:Cn(t);return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Ou(e,t){const r=e===void 0?null:_n(e,11),n=t===void 0?null:Cn(t);return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function sr(e){return e.getFullYear()*12+e.getMonth()}function Na(e){return _n(Math.floor(e/12),(e%12+12)%12)}function Ls(e){return Number.isNaN(e.getTime())?null:e}function Nu(e,t,r){const n=new Map;for(const o of e){const a=Cn(o);t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function Vu(e,t){const r=[];for(let n=sr(e);n<=sr(t);n++)r.push(Na(n));return r}function $s(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:nt("month",e[o],r,t),value:Mr(e[o])});return n}const _u=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,variant:i="date",minYear:u,maxYear:m,minDate:h,maxDate:f,allowedMonths:x,isWarning:v=!1,className:P="",style:j,disabled:p=!1,locale:w,labels:c,formatLocale:g,formatOption:d}=e;if(g!==void 0&&Vo("MonthSelector","formatLocale",g),co(t,"value",""),co(r,"initialDate",""),co(h,"minDate",Es),co(f,"maxDate",Es),Ps(u,"minYear",0),Ps(m,"maxYear",11),en("MonthSelector","allowedMonths",x),x!==void 0)for(let q=0;q<x.length;q++)Sl(x[q],`allowedMonths[${q}]`,"");const re=t??r;if(re===void 0)throw new RangeError("MonthSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected month is never inferred from the wall clock");o!==void 0&&Za("MonthSelector",o,t!==void 0);const O=ko(w,c),ae=t!==void 0,[J,se]=Qa(re,ae,vl,Cn),ne=s.useMemo(()=>t!==void 0?Cn(t):J,[t?.getTime(),J]),A=h?.getTime(),ee=f?.getTime(),M=s.useMemo(()=>Au(u,h),[u,A]),D=s.useMemo(()=>Ou(m,f),[m,ee]),L=M?.getTime()??null,k=D?.getTime()??null;if(M!==null&&D!==null&&M>D)throw new RangeError(`MonthSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Mr(M)}, upper: ${Mr(D)})`);if(i==="dropdown"&&x===void 0&&(M===null||D===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 list is never invented');const U=x===void 0?null:x.map(q=>q.getTime()).join(","),F=s.useMemo(()=>x===void 0?null:Nu(x,M,D),[U,L,k]),W=s.useMemo(()=>{if(F!==null){const q=F.map(sr);return{kind:"candidates",ascending:q,loIndex:0,hiIndex:q.length-1}}return{kind:"range",min:M===null?null:sr(M),max:D===null?null:sr(D)}},[F,L,k]),V=q=>!Number.isNaN(q.getTime())&&En(W,sr(q)),Q=q=>{if(p)return;if(!V(q))throw new RangeError(`MonthSelector: refusing to emit ${Mr(q)}, which lies outside the selectable months`);ae||se(q);const et=q.getFullYear()*100+(q.getMonth()+1);n?.(q,et)},ce=ne.getTime(),ve=V(ne),G=s.useMemo(()=>{const q=Zt(W,sr(ne),-1);return q===null?null:Ls(Na(q))},[W,ce]),_=s.useMemo(()=>{const q=Zt(W,sr(ne),1);return q===null?null:Ls(Na(q))},[W,ce]),Me=()=>{if(o!==void 0){o.onStep("previous");return}G!==null&&Q(G)},Ee=()=>{if(o!==void 0){o.onStep("next");return}_!==null&&Q(_)},ie=q=>{if(!q)return;const et=q.lastIndexOf("-");if(et<=0)return;const it=q.slice(0,et),gt=q.slice(et+1),Pe=Number(it),st=Number(gt)-1;if(!(Number.isInteger(Pe)&&Number.isInteger(st)))return;const Ve=_n(Pe,st);V(Ve)&&Q(Ve)},fe=q=>{ie(q.target.value)},ke=q=>{ie(q.target.value)},ot=Mr(ne),te=i==="dropdown"&&!ve?nt("month",ne,d,g):"",T=M?Mr(M):void 0,ue=D?Mr(D):void 0,pe=s.useMemo(()=>i!=="dropdown"?[]:F!==null?$s(F,g,d):M===null||D===null?[]:$s(Vu(M,D),g,d),[i,F,L,k,g,d]),at=ve?ot:"",$e=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",He=`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 ${$e}`,Ke=`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 ${$e}`;return $.jsxs("div",{className:`inline-flex items-center ${Dn} ${P}`,style:j,"data-out-of-range":ve?void 0:"true",children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:p,canStep:o===void 0?G!==null:o.canStepPrevious,onStep:Me,ariaLabel:O.previousMonth}),i==="dropdown"?$.jsxs("select",{"aria-label":O.monthSelect,disabled:p,className:Ke,value:at,onChange:ke,children:[ve?null:$.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:te}),pe.map(q=>$.jsx("option",{value:q.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:q.label},q.value))]}):$.jsx("input",{"aria-label":O.monthSelect,disabled:p,className:He,value:ot,min:T,max:ue,onChange:fe,type:"month"}),$.jsx(yr,{neighbour:"control",direction:"right",disabled:p,canStep:o===void 0?_!==null:o.canStepNext,onStep:Ee,ariaLabel:O.nextMonth}),a]})},Yu=(e,t)=>!(!Xa(e,t,vl)||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||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!Co(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),xl=s.memo(_u,Yu);xl.displayName="MonthSelector";const Va=Symbol("nothing handed");let ya=0;class Hu{constructor(t,r,n,o){this.states=t,this.base=r,this.superseded=n,this.setMark=o}states;base;superseded;setMark;drafts=new Map;handed=new Map;cells=new Set;notes=[];closed=!1;marked=!1;committed=!1;record(){this.marked||(this.marked=!0,this.setMark(this))}leadsTo(t){return t.every((r,n)=>r===(this.handed.has(n)?this.handed.get(n):this.states[n]))}read(t,r){return this.drafts.has(t)?this.drafts.get(t):r}write(t,r){this.drafts.set(t,r),this.cells.add(t),this.record()}hand(t,r){this.handed.set(t.slot,r),this.cells.add(t),this.record()}note(t){this.notes.push(t),this.record()}hasHanded(t){return this.handed.has(t)}lastHanded(t){return this.handed.get(t)}close(){this.closed=!0}}class ju{constructor(t,r,n){this.owner=t,this.setMark=n,this.slotWrites=r.map(()=>0),this.records=r.map(()=>Va),this.latest=this.open(r)}owner;setMark;latest;active=null;slotWrites;records;outbox=[];duringRender=t=>{if(typeof t!="function")throw new TypeError(`${this.owner}: duringRender(action) must be a function (received: ${E(t)})`);const r=this.latest;if(r.closed)throw new Error(`${this.owner}: duringRender(action) must be called during the host's render, after the hook call (call the returned functions directly from event handlers and effects)`);const n=this.active;this.active=r,ya+=1;try{t()}finally{ya-=1,this.active=n}};get pass(){if(this.active===null&&ya>0)throw new Error(`${this.owner}: a returned function was called during another hook's duringRender(action); call it inside this hook's own duringRender(action)`);return this.active}inFlight(t){return!this.latest.committed&&this.latest.hasHanded(t)}handedTo(t){return this.records[t]}recordHanded(t,r){this.records[t]=r}begin(t,r){const n=this.latest;return!n.committed&&r===n&&n.leadsTo(t)?(n.closed&&(n.closed=!1,this.closeAtEndOfRun(n)),n):(n.close(),this.latest=this.open(t),this.latest)}open(t){const r=t.map((o,a)=>this.records[a]!==Va&&this.records[a]!==o),n=new Hu(t,[...this.slotWrites],r,this.setMark);return this.closeAtEndOfRun(n),n}closeAtEndOfRun(t){queueMicrotask(()=>t.close())}applies(t,r){return!t.superseded[r]&&t.base[r]===this.slotWrites[r]}commit(t,r){t.close(),t.committed=!0;for(const n of t.cells)this.applies(t,n.slot)&&n.adopt(t,r);for(const n of t.notes)this.applies(t,n.slot)&&this.outbox.push(n.send);this.outbox.length>0&&queueMicrotask(()=>this.deliver())}deliver(){for(let t=this.outbox.shift();t!==void 0;t=this.outbox.shift())t()}wrote(t){this.deliver(),this.slotWrites[t]+=1}notify(t,r){const n=this.pass;if(n!==null){n.note({slot:t,send:r});return}this.deliver(),r()}}class Uu extends ml{constructor(t,r,n){super(t),this.scope=r,this.slot=n}scope;slot;adopted=null;get current(){const t=this.scope.pass;return t===null?super.current:t.read(this,super.current)}set current(t){const r=this.scope.pass;if(r!==null){r.write(this,t);return}this.scope.wrote(this.slot),super.current=t}hand(t){const r=this.scope.pass;if(r!==null){r.hand(this,t);return}this.adopted=null,this.scope.wrote(this.slot),this.scope.recordHanded(this.slot,t)}get holdsHanded(){const t=this.scope.pass;return t===null?this.scope.handedTo(this.slot)===super.current&&!this.scope.inFlight(this.slot):(t.hasHanded(this.slot)?t.lastHanded(this.slot):this.scope.handedTo(this.slot))===t.read(this,super.current)}forgetHanded(t){this.scope.wrote(this.slot),this.scope.handedTo(this.slot)===t&&this.scope.recordHanded(this.slot,Va)}adopt(t,r){const n=r[this.slot];if(!t.hasHanded(this.slot)||n!==t.lastHanded(this.slot))return;this.scope.recordHanded(this.slot,n);const o=t.states[this.slot];n!==o&&(this.adopted={opening:o,handed:n})}recordAdopted(t){const r=this.adopted;r!==null&&(this.adopted=null,t(n=>n===r.opening?r.handed:n))}}class Wu{constructor(t,r,n){this.scope=r,this.slot=n,this.held=t}scope;slot;held;get current(){const t=this.scope.pass;return t===null?this.held:t.read(this,this.held)}set current(t){const r=this.scope.pass;if(r!==null){r.write(this,t);return}this.scope.wrote(this.slot),this.held=t}adopt(t){this.held=t.read(this,this.held)}}const zu=(e,t)=>t;function Yo(e,t){const[r,n]=s.useReducer(zu,null),[o]=s.useState(()=>new ju(e,t,n)),a=o.begin(t,r);return s.useInsertionEffect(()=>{o.commit(a,t)}),s.useLayoutEffect(()=>{o.deliver()}),o}function Kr(e,t,r,n){const o=fl(r,a=>new Uu(a,e,t));return s.useLayoutEffect(()=>{o.recordAdopted(n)}),o}function Gr(e,t,r){const[n]=s.useState(()=>new Wu(r,e,t));return n}function Ne(e,t,r){return e<t?t:e>r?r:e}const Bu=tn([],null,null);function kn(e,t,r,n){return r===null?Bu:_a(r,Y(t,e[0],n),Y(t,e[1],n))}function Dr(e,t,r,n,o){const a=Y(t,e,o),i=Ya(n)?null:Pn(n,a);return i===null?a<Y(t,r[0],o)?r[0]:a>Y(t,r[1],o)?r[1]:e:i===a?e:oe(t,i,o)}function Br(e,t,r,n,o,a){const i=Y(t,e[0],o),u=Y(t,e[1],o),m=po(a,{kind:"range",min:Y(t,r[0],o),max:Y(t,r[1],o)},i,u);if(m===null)return e;const h=Dr(m[0]===i?e[0]:oe(t,m[0],o),t,r,n,o),f=Dr(m[1]===u?e[1]:oe(t,m[1],o),t,r,n,o);return[h,f<h?h:f]}const Ts=(e,t,r,n,o,a,i)=>{if(en(e,t,r),r===void 0||r.length===0)return null;const u=tn(hl(e,t,r,n,i),Y(n,o,i),Y(n,a,i));if(u.hiIndex<u.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${E(o)}, maxDate: ${E(a)}, entries: ${r.length})`);return u},_a=(e,t,r)=>{const n=tn(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},Ya=e=>e.hiIndex<e.loIndex,Fu=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Zt(o,t,r);a!==null&&(n===null||(r===1?a<n:a>n))&&(n=a)}return n},edge:t=>{let r=null;for(const n of e){const o=yn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Rt=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),Cs=(e,t,r,n,o)=>{if(!$t(r)||r.length!==2)throw new RangeError(`${e}: ${t} must be a [start, end] tuple of Dates (received: ${E(r)})`);const a=qt(e,`${t}[0]`,r[0],n,o),i=qt(e,`${t}[1]`,r[1],n,o);if(i<a)throw new RangeError(`${e}: ${t} must not be inverted at ${n} resolution (start: ${E(r[0])}, end: ${E(r[1])})`);return[a,i]},lr=e=>{const t="resolveVernierSelectorSteps";if(typeof e!="object"||e===null)throw new RangeError(`${t}: options must be an object (received: ${E(e)})`);const{row:r,shows:n,macroUnit:o,microUnit:a,minDate:i,maxDate:u,macroRange:m,microSelection:h}=e;if(r!=="macro"&&r!=="micro")throw new RangeError(`${t}: row must be "macro" or "micro" (received: ${E(r)})`);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${E(n)})`);Ce(t,"macroUnit",o),Ce(t,"microUnit",a);const f=fr(t,e.yearStartMonth);for(const[M,D]of[["minDate",i],["maxDate",u]])if(!ye(D))throw new RangeError(`${t}: ${M} must be a valid Date (received: ${E(D)})`);if(u.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${E(i)}, maxDate: ${E(u)})`);qt(t,"minDate",i,o,f),qt(t,"minDate",i,a,f),Er(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const x=Cs(t,"macroRange",m,o,f);if(m[1].getTime()<m[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${E(m[0])}, end: ${E(m[1])})`);const v=Cs(t,"microSelection",h,a,f),P=Ts(t,"macroAllowedDates",e.macroAllowedDates,o,i,u,f),j=Ts(t,"microAllowedDates",e.microAllowedDates,a,i,u,f),p=[m[0],m[1]],w=[h[0],h[1]],c=M=>{const D=yt(o,a,[M[0],M[1]],i,u,f);return[Y(a,D[0],f),Y(a,D[1],f)]},g=(M,D)=>{if(j!==null){const L=_a(j,M,D);if(!Ya(L))return L}return{kind:"range",min:M,max:D}},d=(M,D)=>{const L=Rt(M,p)?p:M;return L===p&&Rt(D,w)?null:{macroRange:L,microSelection:D}};if(e.row==="macro"){const M=P??{kind:"range",min:Y(o,i,f),max:Y(o,u,f)},D=ho(M),L=(U,F)=>{const W=yt(o,a,U,i,u,f);return Br(w,a,W,kn(W,a,j,f),f,F)},k=(U,F)=>{const W=La(D,x[0],x[1],U,ka(F,n));if(W===null)return null;const V=Ia(W,x,p,o,f,F.motion==="single");if(V===null)return null;const Q=[Ne(V[0],i,u),Ne(V[1],i,u)],ce=Math.sign(W[0]-x[0])===U&&Math.sign(W[1]-x[1])===U;return d(Q,L(Q,ce?"pan":"resize"))};return{previous:k(-1,e.rules.previous),next:k(1,e.rules.next)}}const re=c(p);let O=[Y(a,i,f),Y(a,u,f)];if(P!==null){const M=c([oe(o,P.ascending[P.loIndex],f),oe(o,P.ascending[P.hiIndex],f)]);O=[Math.min(M[0],re[0]),Math.max(M[1],re[1])]}const ae=j===null?null:_a(j,O[0],O[1]);let J=ho({kind:"range",min:O[0],max:O[1]});if(ae!==null&&!Ya(ae)){const M=g(re[0],re[1]);J=M.kind==="candidates"?ho(ae):Fu([ae,M])}const se=M=>{if(P===null)return[Ne(bt(o,M[0],f),i,u),Ne(bt(o,M[1],f),i,u)];const D=fo(P,Y(o,M[0],f),-1),L=fo(P,Y(o,M[1],f),1);return D===null||L===null?null:[Ne(oe(o,D,f),i,u),Ne(oe(o,L,f),i,u)]},ne=(M,D,L)=>{const[k,U]=c(M),F=g(k,U),W=ce=>{const ve=Y(a,ce,f);if(En(F,ve))return ce;const G=fo(F,ve,L);return G===null?null:oe(a,G,f)},V=W(D[0]),Q=W(D[1]);return V===null||Q===null?null:[V,Q.getTime()<V.getTime()?V:Q]},A=(M,D)=>M>=re[0]&&D<=re[1],ee=(M,D)=>{const L=La(J,v[0],v[1],M,ka(D,n));if(L===null)return null;const k=Ia(L,v,w,a,f,D.motion==="single");if(k===null)return null;const U=D.window!=="follow",F=U&&A(L[0],L[1])?p:se(k);if(F===null)return null;const W=ne(F,k,M);if(W===null)return null;const V=U&&A(Y(a,W[0],f),Y(a,W[1],f))?p:se(W);return V===null?null:d(V,W)};return{previous:ee(-1,e.rules.previous),next:ee(1,e.rules.next)}};function Ha(e,t,r){if(!ye(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${E(r)})`)}function Le(e,t,r,n,o){Ha(e,t,r),qe(e,t,r,n,o,"")}function Ho(e,t,r,n,o){if(Ha(e,"minDate",t),Ha(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${E(t)}, maxDate: ${E(r)})`);for(const a of n)qe(e,"minDate",t,a,o,Bs)}function cr(e,t,r,n,o){if(!$t(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${E(r)})`);if(Le(e,`${t}[0]`,r[0],n,o),Le(e,`${t}[1]`,r[1],n,o),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${E(r[0])}, upper: ${E(r[1])})`)}function Mo(e,t,r,n,o,a,i,u){const m=Y(r,n,u);if(m<Y(r,o,u)||m>Y(r,a,u))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${E(n)}, lower: ${E(o)}, upper: ${E(a)})`)}function Do(e,t,r,n,o,a,i,u){Mo(e,`${t}[0]`,r,n[0],o,a,i,u),Mo(e,`${t}[1]`,r,n[1],o,a,i,u)}function yo(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${E(r)}, upper: ${E(n)})`)}function qr(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${E(r)})`)}function Ut(e,t,r,n,o,a){const i=Fs(e,t,r);return ye(i)&&Vn(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function Eo(e,t,r,n,o){const a=De(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function Mn(e,t,r,n,o,a){const i=Ne(e,r,n);if(o.length===0)return i;const u=o[De(o,i,t,a)];return Y(t,u,a)===Y(t,i,a)?i:Ne(u,r,n)}function Ea(e,t,r,n,o,a){const i=Mn(e[0],t,r,n,o,a),u=Mn(e[1],t,r,n,o,a);return[i,u<i?i:u]}function In(e,t){return t[0]===e[0]&&t[1]===e[1]?e:t}const Ku={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function Wt(e,t){return t.length===0?{}:{[Ku[e]]:t}}function jo(e){const t=s.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(u=>Object.is(r[u],n[u]))||(t.current=e),t.current}const Xt={previous:null,next:null},Gu=["motion","edge","window"];function An(e){const t=s.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Gu.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const vo=(e,t)=>e.getTime()===t.getTime();function Xr(e,t,r,n){if(!r(e.current,t))e.current=t;else if(e.holdsHanded)return;e.hand(e.current),n(e.current)}function Zr(e,t,r){e.current=t,e.hand(t),r(t)}function qu(e,t){return typeof t=="function"?t(e):t}function Qr(e){return s.useReducer(qu,void 0,e)}function Jr(e,t,r,n){r===t||e.current!==r||(e.forgetHanded(t),n(o=>o===t?r:o))}function Xu(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:u,selectorStep:m,...h}=e;Ce("usePeriodSliderRange","unit",t);const f=fr("usePeriodSliderRange",i);Ho("usePeriodSliderRange",r,n,[t],f),cr("usePeriodSliderRange","initialRange",o,t,f),m!==void 0&&Er("usePeriodSliderRange","selectorStep",m,"motion");const x=jo(h),v=r.getTime(),P=n.getTime(),j=s.useMemo(()=>dr("usePeriodSliderRange",No(x.allowedDates),t,r,n,f).dates,[x.allowedDates,t,v,P,f]),p=s.useRef(o),[w,c]=Qr(()=>(Do("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",f),In(o,Ea(o,t,r,n,j,f)))),g=Yo("usePeriodSliderRange",[w]);cr("usePeriodSliderRange","range",w,t,f);const d=In(w,Ea(w,t,r,n,j,f)),re=Kr(g,0,d,c);s.useLayoutEffect(()=>{Jr(re,w,d,c)});const O=Gr(g,0,o),ae=ut({minDate:r,maxDate:n,candidates:j}),J=ut(a),se=s.useCallback(G=>{const{minDate:_,maxDate:Me,candidates:Ee}=ae.current,ie=Ea(G,t,_,Me,Ee,f);Xr(re,ie,Rt,c);const fe=O.current;ie[0].getTime()===fe[0].getTime()&&ie[1].getTime()===fe[1].getTime()||(O.current=ie,g.notify(0,()=>J.current?.(ie[0],ie[1])))},[t,f]),ne=s.useCallback(G=>{const _=typeof G=="function"?G(re.current):G;O.current=_,Zr(re,_,c)},[]),A=s.useCallback(G=>{Le("usePeriodSliderRange","setLowerDate(date)",G,t,f);const _=re.current,Me=G.getTime()>_[1].getTime()?G:_[1];se([G,Me])},[se,t,f]),ee=s.useCallback(G=>{Le("usePeriodSliderRange","setUpperDate(date)",G,t,f);const _=re.current,Me=G.getTime()<_[0].getTime()?G:_[0];se([Me,G])},[se,t,f]),M=s.useCallback((G,_)=>{Le("usePeriodSliderRange","sliderProps.onChangeRange(lower)",G,t,f),Le("usePeriodSliderRange","sliderProps.onChangeRange(upper)",_,t,f),yo("usePeriodSliderRange","sliderProps.onChangeRange",G,_),se([G,_])},[se,t,f]),D=s.useCallback(G=>{qr("usePeriodSliderRange","shiftRange",G);const{minDate:_,maxDate:Me,candidates:Ee}=ae.current,ie=re.current;if(Ee.length>0){se([Eo(Ee,t,ie[0],G,f),Eo(Ee,t,ie[1],G,f)]);return}se([Ut(t,ie[0],G,_,Me,f).date,Ut(t,ie[1],G,_,Me,f).date])},[t,se,f]),L=s.useCallback(()=>{se(p.current)},[se]),k=An(m),U=k!==void 0,F=s.useMemo(()=>{if(k===void 0)return{start:Xt,end:Xt};const G=j.length>0?x.allowedDates:void 0,_={selection:d,unit:t,yearStartMonth:f,minDate:r,maxDate:n,allowedDates:G,rules:k};return{start:Aa({..._,shows:"start"}),end:Aa({..._,shows:"end"})}},[k,d,t,f,v,P,j,x.allowedDates]),W=jt(F.start,se),V=jt(F.end,se),Q=s.useMemo(()=>({value:d[0],onChange:A,minDate:r,maxDate:d[1],unit:t,yearStartMonth:f,...Wt(t,j),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...U?{stepper:W}:{}}),[d[0],d[1],A,r,t,f,j,e.formatLocale,e.locale,e.labels,u,U,W]),ce=s.useMemo(()=>({value:d[1],onChange:ee,minDate:d[0],maxDate:n,unit:t,yearStartMonth:f,...Wt(t,j),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...U?{stepper:V}:{}}),[d[0],d[1],ee,n,t,f,j,e.formatLocale,e.locale,e.labels,u,U,V]),ve=s.useMemo(()=>({...x,mode:"range",unit:t,yearStartMonth:f,range:d,minDate:r,maxDate:n,onChangeRange:M}),[x,t,d,r,n,M,f]);return{range:d,lowerDate:d[0],upperDate:d[1],setRange:ne,setLowerDate:A,setUpperDate:ee,shiftRange:D,resetRange:L,startSelectorProps:Q,endSelectorProps:ce,sliderProps:ve,duringRender:g.duringRender}}function Zu(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:u,...m}=e;Ce("usePeriodSliderPoint","unit",t);const h=fr("usePeriodSliderPoint",i);Ho("usePeriodSliderPoint",r,n,[t],h),Le("usePeriodSliderPoint","initialValue",o,t,h);const f=jo(m),x=r.getTime(),v=n.getTime(),P=s.useMemo(()=>dr("usePeriodSliderPoint",No(f.allowedDates),t,r,n,h).dates,[f.allowedDates,t,x,v,h]),j=s.useRef(o),[p,w]=Qr(()=>(Mo("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",h),Mn(o,t,r,n,P,h))),c=Yo("usePeriodSliderPoint",[p]);Le("usePeriodSliderPoint","value",p,t,h);const g=Mn(p,t,r,n,P,h),d=Kr(c,0,g,w);s.useLayoutEffect(()=>{Jr(d,p,g,w)});const re=Gr(c,0,o),O=ut({minDate:r,maxDate:n,candidates:P}),ae=ut(a),J=s.useCallback(k=>{const{minDate:U,maxDate:F,candidates:W}=O.current,V=Mn(k,t,U,F,W,h);Xr(d,V,vo,w),V.getTime()!==re.current.getTime()&&(re.current=V,c.notify(0,()=>ae.current?.(V)))},[t,h]),se=s.useCallback(k=>{const U=typeof k=="function"?k(d.current):k;re.current=U,Zr(d,U,w)},[]),ne=s.useCallback(k=>{Le("usePeriodSliderPoint","selectorProps.onChange(date)",k,t,h),J(k)},[J,t,h]),A=s.useCallback(k=>{Le("usePeriodSliderPoint","sliderProps.onChangePoint(value)",k,t,h),J(k)},[J,t,h]),ee=s.useCallback(k=>{qr("usePeriodSliderPoint","shiftValue",k);const{minDate:U,maxDate:F,candidates:W}=O.current;if(W.length>0){J(Eo(W,t,d.current,k,h));return}J(Ut(t,d.current,k,U,F,h).date)},[t,J,h]),M=s.useCallback(()=>{J(j.current)},[J]),D=s.useMemo(()=>({value:g,onChange:ne,minDate:r,maxDate:n,unit:t,yearStartMonth:h,...Wt(t,P),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u}),[g,ne,r,n,t,h,P,e.formatLocale,e.locale,e.labels,u]),L=s.useMemo(()=>({...f,mode:"point",unit:t,yearStartMonth:h,value:g,minDate:r,maxDate:n,onChangePoint:A}),[f,t,g,r,n,A,h]);return{value:g,setValue:se,shiftValue:ee,resetValue:M,selectorProps:D,sliderProps:L,duringRender:c.duringRender}}function Qu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroRange:h,yearStartMonth:f,formatOption:x,macroSelectorStep:v,microSelectorStep:P,...j}=e;Ce("useVernierSliderRange","unit",t);const p=Qt("useVernierSliderRange","macroUnit",i,t),w=Qt("useVernierSliderRange","microUnit",u,t),c=fr("useVernierSliderRange",f);Ho("useVernierSliderRange",r,n,[p,w,t],c),cr("useVernierSliderRange","initialMacroRange",o,p,c),cr("useVernierSliderRange","initialMicroRange",a,w,c),v!==void 0&&Er("useVernierSliderRange","macroSelectorStep",v,"motion"),P!==void 0&&Er("useVernierSliderRange","microSelectorStep",P,"vernierRange");const g=jo(j),d=s.useRef(o),re=s.useRef(a),[O,ae]=Qr(()=>(Do("useVernierSliderRange","initialMacroRange",p,o,r,n,"[minDate, maxDate]",c),o)),[J,se]=Qr(()=>{const y=yt(p,w,o,r,n,c);return Do("useVernierSliderRange","initialMicroRange",w,a,y[0],y[1],"the initial macro window",c),a}),ne=Yo("useVernierSliderRange",[O,J]);cr("useVernierSliderRange","macroRange",O,p,c);const A=In(O,[Ne(O[0],r,n),Ne(O[1],r,n)]),ee=r.getTime(),M=n.getTime(),D=s.useMemo(()=>yt(p,w,A,r,n,c),[p,w,A,ee,M,c]),L=s.useMemo(()=>Ht("micro",g)?Fa("useVernierSliderRange",Dt("micro",g),w,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,w,ee,M,c]),k=s.useMemo(()=>Ht("macro",g)?dr("useVernierSliderRange",Dt("macro",g),p,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,p,ee,M,c]),U=ut(k),F=s.useMemo(()=>kn(D,w,L,c),[D,w,L,c]),W=s.useMemo(()=>$n(L,F),[L,F]);cr("useVernierSliderRange","microRange",J,w,c);const V=In(J,Br(J,w,D,F,c,"resize")),Q=Kr(ne,0,A,ae),ce=Kr(ne,1,V,se);s.useLayoutEffect(()=>{Jr(Q,O,A,ae),Jr(ce,J,V,se)});const ve=Gr(ne,1,a),G=Gr(ne,0,o),_=ut({minDate:r,maxDate:n}),Me=ut(m),Ee=ut(h),ie=s.useCallback(y=>{const{minDate:H,maxDate:de}=_.current;return yt(p,w,y,H,de,c)},[p,w,c]),fe=s.useCallback(y=>kn(y,w,L,c),[w,L,c]),ke=s.useCallback(y=>{Xr(Q,y,Rt,ae);const H=G.current;y[0].getTime()===H[0].getTime()&&y[1].getTime()===H[1].getTime()||(G.current=y,ne.notify(0,()=>Me.current?.(y[0],y[1])))},[]),ot=s.useCallback(y=>{const H=typeof y=="function"?y(Q.current):y;G.current=H,Zr(Q,H,ae)},[]),te=s.useCallback((y,H,de)=>{const _e=de==="micro"&&Rt(Q.current,y)&&Rt(G.current,y),Ie=de==="macro"&&Rt(ce.current,H)&&Rt(ve.current,H);if(_e||ke(y),Ie)return;Xr(ce,H,Rt,se);const be=ve.current;(H[0].getTime()!==be[0].getTime()||H[1].getTime()!==be[1].getTime())&&(ve.current=H,ne.notify(1,()=>Ee.current?.(H[0],H[1])))},[ke]),T=s.useCallback(y=>{const H=typeof y=="function"?y(ce.current):y;ve.current=H,Zr(ce,H,se)},[]),ue=s.useCallback((y,H,de)=>{const{minDate:_e,maxDate:Ie}=_.current,be=[Ne(y,_e,Ie),Ne(H,_e,Ie)],je=ie(be);te(be,Br(ce.current,w,je,fe(je),c,de),"macro")},[w,ie,fe,te,c]),pe=s.useCallback((y,H)=>ue(y,H,"resize"),[ue]),at=s.useCallback((y,H)=>{Le("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",y,p,c),Le("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",H,p,c),yo("useVernierSliderRange","sliderProps.onChangeMacroRange",y,H);const{minDate:de,maxDate:_e}=_.current,Ie=[Ne(y,de,_e),Ne(H,de,_e)],be=ce.current,je=ie(Ie),Xe=Br(be,w,je,fe(je),c,"resize");if(Xe[0].getTime()!==be[0].getTime()||Xe[1].getTime()!==be[1].getTime()){ke(Ie);return}te(Ie,be,"macro")},[p,w,ie,fe,ke,te,c]),$e=s.useCallback((y,H)=>{const de=ie(Q.current);te(Q.current,Br([y,H],w,de,fe(de),c,"resize"),"micro")},[w,ie,fe,te,c]),He=s.useCallback((y,H)=>{Le("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",y,w,c),Le("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",H,w,c),yo("useVernierSliderRange","sliderProps.onChangeMicroRange",y,H),$e(y,H)},[$e,w,c]),Ke=s.useCallback(y=>{Le("useVernierSliderRange","setMacroLowerDate(date)",y,p,c);const H=Q.current[1],de=y>H?y:H;pe(y,de)},[pe,p,c]),q=s.useCallback(y=>{Le("useVernierSliderRange","setMacroUpperDate(date)",y,p,c);const H=Q.current[0],de=y<H?y:H;pe(de,y)},[pe,p,c]),et=s.useCallback(y=>{Le("useVernierSliderRange","setMicroLowerDate(date)",y,w,c);const H=ce.current[1],de=y>H?y:H;$e(y,de)},[$e,w,c]),it=s.useCallback(y=>{Le("useVernierSliderRange","setMicroUpperDate(date)",y,w,c);const H=ce.current[0],de=y<H?y:H;$e(de,y)},[$e,w,c]),gt=s.useCallback(y=>{qr("useVernierSliderRange","shiftMacroRange",y);const{minDate:H,maxDate:de}=_.current,_e=Q.current,Ie=U.current;if(Ie.length>0){const Xe=De(Ie,_e[0],p,c)+y,kt=De(Ie,_e[1],p,c)+y;if(Xe<0||kt>Ie.length-1)return;ue(Ie[Xe],Ie[kt],"pan");return}const be=Ut(p,_e[0],y,H,de,c),je=Ut(p,_e[1],y,H,de,c);be.pastDateRange||je.pastDateRange||be.date<H||je.date>de||ue(be.date,je.date,"pan")},[p,ue,c]),Pe=s.useCallback(y=>{qr("useVernierSliderRange","shiftMicroRange",y);const H=Q.current,de=ce.current,_e=ie(H),[Ie,be]=_e,je=$n(L,fe(_e));if(je.length>0){const zt=De(je,de[0],w,c)+y,Ue=De(je,de[1],w,c)+y;if(zt<0||Ue>je.length-1)return;$e(je[zt],je[Ue]);return}const Xe=Ut(w,de[0],y,Ie,be,c),kt=Ut(w,de[1],y,Ie,be,c);Xe.pastDateRange||kt.pastDateRange||Y(w,Xe.date,c)<Y(w,Ie,c)||Y(w,kt.date,c)>Y(w,be,c)||$e(Xe.date,kt.date)},[w,L,ie,fe,$e,c]),st=s.useCallback(()=>{const{minDate:y,maxDate:H}=_.current,de=[Ne(d.current[0],y,H),Ne(d.current[1],y,H)],_e=ie(de);te(de,Br(re.current,w,_e,fe(_e),c,"resize"),"both")},[w,ie,fe,te,c]),Ve=An(v),ft=An(P),Ge=Ve!==void 0,dt=ft!==void 0,C=s.useMemo(()=>{const y={macroUnit:p,microUnit:w,yearStartMonth:c,minDate:r,maxDate:n,macroRange:A,microSelection:V,macroAllowedDates:Ht("macro",g)?Dt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Dt("micro",g).list:void 0};return{macroStart:Ve===void 0?Xt:lr({...y,row:"macro",shows:"start",rules:Ve}),macroEnd:Ve===void 0?Xt:lr({...y,row:"macro",shows:"end",rules:Ve}),microStart:ft===void 0?Xt:lr({...y,row:"micro",shows:"start",rules:ft}),microEnd:ft===void 0?Xt:lr({...y,row:"micro",shows:"end",rules:ft})}},[Ve,ft,p,w,c,ee,M,A,V,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),Z=s.useCallback(y=>te(y.macroRange,y.microSelection,"macro"),[te]),ze=s.useCallback(y=>te(y.macroRange,y.microSelection,"micro"),[te]),Se=jt(C.macroStart,Z),ge=jt(C.macroEnd,Z),vt=jt(C.microStart,ze),Ct=jt(C.microEnd,ze),[z,Pr]=D,rn=s.useMemo(()=>({value:A[0],onChange:Ke,minDate:r,maxDate:A[1],unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ge?{stepper:Se}:{}}),[A,Ke,r,p,c,k,e.formatLocale,e.locale,e.labels,x,Ge,Se]),I=s.useMemo(()=>({value:A[1],onChange:q,minDate:A[0],maxDate:n,unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ge?{stepper:ge}:{}}),[A,q,n,p,c,k,e.formatLocale,e.locale,e.labels,x,Ge,ge]),le=s.useMemo(()=>({value:V[0],onChange:et,minDate:z,maxDate:V[1],unit:w,yearStartMonth:c,...Wt(w,W),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...dt?{stepper:vt}:{}}),[V,et,z,w,c,W,e.formatLocale,e.locale,e.labels,x,dt,vt]),we=s.useMemo(()=>({value:V[1],onChange:it,minDate:V[0],maxDate:Pr,unit:w,yearStartMonth:c,...Wt(w,W),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...dt?{stepper:Ct}:{}}),[V,it,Pr,w,c,W,e.formatLocale,e.locale,e.labels,x,dt,Ct]),Ye=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:p,microUnit:w,minDate:r,maxDate:n,macroRange:A,microRange:V,onChangeMacroRange:at,onChangeMicroRange:He}),[g,t,p,w,r,n,A,V,at,He,c]);return{macroRange:A,setMacroRange:ot,microRange:V,setMicroRange:T,setMacroLowerDate:Ke,setMacroUpperDate:q,setMicroLowerDate:et,setMicroUpperDate:it,shiftMacroRange:gt,shiftMicroRange:Pe,resetVernier:st,macroStartSelectorProps:rn,macroEndSelectorProps:I,microStartSelectorProps:le,microEndSelectorProps:we,sliderProps:Ye,duringRender:ne.duringRender}}function Ju(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroPoint:h,yearStartMonth:f,formatOption:x,macroSelectorStep:v,microSelectorStep:P,...j}=e;Ce("useVernierSliderPoint","unit",t);const p=Qt("useVernierSliderPoint","macroUnit",i,t),w=Qt("useVernierSliderPoint","microUnit",u,t),c=fr("useVernierSliderPoint",f);Ho("useVernierSliderPoint",r,n,[p,w,t],c),cr("useVernierSliderPoint","initialMacroRange",o,p,c),Le("useVernierSliderPoint","initialMicroValue",a,w,c),v!==void 0&&Er("useVernierSliderPoint","macroSelectorStep",v,"motion"),P!==void 0&&Er("useVernierSliderPoint","microSelectorStep",P,"vernierPoint");const g=jo(j),d=s.useRef(o),re=s.useRef(a),[O,ae]=Qr(()=>(Do("useVernierSliderPoint","initialMacroRange",p,o,r,n,"[minDate, maxDate]",c),o)),[J,se]=Qr(()=>{const I=yt(p,w,o,r,n,c);return Mo("useVernierSliderPoint","initialMicroValue",w,a,I[0],I[1],"the initial macro window",c),a}),ne=Yo("useVernierSliderPoint",[O,J]);cr("useVernierSliderPoint","macroRange",O,p,c);const A=In(O,[Ne(O[0],r,n),Ne(O[1],r,n)]),ee=r.getTime(),M=n.getTime(),D=s.useMemo(()=>yt(p,w,A,r,n,c),[p,w,A,ee,M,c]),L=s.useMemo(()=>Ht("micro",g)?Fa("useVernierSliderPoint",Dt("micro",g),w,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,w,ee,M,c]),k=s.useMemo(()=>Ht("macro",g)?dr("useVernierSliderPoint",Dt("macro",g),p,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,p,ee,M,c]),U=ut(k),F=s.useMemo(()=>kn(D,w,L,c),[D,w,L,c]),W=s.useMemo(()=>$n(L,F),[L,F]);Le("useVernierSliderPoint","microValue",J,w,c);const V=Dr(J,w,D,F,c),Q=Kr(ne,0,A,ae),ce=Kr(ne,1,V,se);s.useLayoutEffect(()=>{Jr(Q,O,A,ae),Jr(ce,J,V,se)});const ve=Gr(ne,1,a),G=Gr(ne,0,o),_=ut({minDate:r,maxDate:n}),Me=ut(m),Ee=ut(h),ie=s.useCallback(I=>{const{minDate:le,maxDate:we}=_.current;return yt(p,w,I,le,we,c)},[p,w,c]),fe=s.useCallback(I=>kn(I,w,L,c),[w,L,c]),ke=s.useCallback(I=>{Xr(Q,I,Rt,ae);const le=G.current;I[0].getTime()===le[0].getTime()&&I[1].getTime()===le[1].getTime()||(G.current=I,ne.notify(0,()=>Me.current?.(I[0],I[1])))},[]),ot=s.useCallback(I=>{const le=typeof I=="function"?I(Q.current):I;G.current=le,Zr(Q,le,ae)},[]),te=s.useCallback((I,le,we)=>{const Ye=we==="micro"&&Rt(Q.current,I)&&Rt(G.current,I),y=we==="macro"&&vo(ce.current,le)&&vo(ve.current,le);Ye||ke(I),!y&&(Xr(ce,le,vo,se),le.getTime()!==ve.current.getTime()&&(ve.current=le,ne.notify(1,()=>Ee.current?.(le))))},[ke]),T=s.useCallback(I=>{const le=typeof I=="function"?I(ce.current):I;ve.current=le,Zr(ce,le,se)},[]),ue=s.useCallback((I,le)=>{const{minDate:we,maxDate:Ye}=_.current,y=[Ne(I,we,Ye),Ne(le,we,Ye)],H=ie(y);te(y,Dr(ce.current,w,H,fe(H),c),"macro")},[w,ie,fe,te,c]),pe=s.useCallback(I=>{const le=ie(Q.current);te(Q.current,Dr(I,w,le,fe(le),c),"micro")},[w,ie,fe,te,c]),at=s.useCallback((I,le)=>{Le("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",I,p,c),Le("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",le,p,c),yo("useVernierSliderPoint","sliderProps.onChangeMacroRange",I,le);const{minDate:we,maxDate:Ye}=_.current,y=[Ne(I,we,Ye),Ne(le,we,Ye)],H=ce.current,de=ie(y);if(Dr(H,w,de,fe(de),c).getTime()!==H.getTime()){ke(y);return}te(y,H,"macro")},[p,w,ie,fe,ke,te,c]),$e=s.useCallback(I=>{Le("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",I,w,c),pe(I)},[pe,w,c]),He=s.useCallback(I=>{Le("useVernierSliderPoint","setMacroLowerDate(date)",I,p,c);const le=Q.current[1],we=I>le?I:le;ue(I,we)},[ue,p,c]),Ke=s.useCallback(I=>{Le("useVernierSliderPoint","setMacroUpperDate(date)",I,p,c);const le=Q.current[0],we=I<le?I:le;ue(we,I)},[ue,p,c]),q=s.useCallback(I=>{Le("useVernierSliderPoint","setMicroDate(date)",I,w,c),pe(I)},[pe,w,c]),et=s.useCallback(I=>{qr("useVernierSliderPoint","shiftMacroRange",I);const{minDate:le,maxDate:we}=_.current,Ye=Q.current,y=U.current;if(y.length>0){const _e=De(y,Ye[0],p,c)+I,Ie=De(y,Ye[1],p,c)+I;if(_e<0||Ie>y.length-1)return;ue(y[_e],y[Ie]);return}const H=Ut(p,Ye[0],I,le,we,c),de=Ut(p,Ye[1],I,le,we,c);H.pastDateRange||de.pastDateRange||H.date<le||de.date>we||ue(H.date,de.date)},[p,ue,c]),it=s.useCallback(I=>{qr("useVernierSliderPoint","shiftMicroValue",I);const le=Q.current,we=ie(le),Ye=$n(L,fe(we));if(Ye.length>0){pe(Eo(Ye,w,ce.current,I,c));return}pe(Ut(w,ce.current,I,we[0],we[1],c).date)},[w,L,ie,fe,pe,c]),gt=s.useCallback(()=>{const{minDate:I,maxDate:le}=_.current,we=[Ne(d.current[0],I,le),Ne(d.current[1],I,le)],Ye=ie(we);te(we,Dr(re.current,w,Ye,fe(Ye),c),"both")},[w,ie,fe,te,c]),Pe=An(v),st=An(P),Ve=Pe!==void 0,ft=st!==void 0,Ge=s.useMemo(()=>{const I={macroUnit:p,microUnit:w,yearStartMonth:c,minDate:r,maxDate:n,macroRange:A,microSelection:[V,V],macroAllowedDates:Ht("macro",g)?Dt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Dt("micro",g).list:void 0};return{macroStart:Pe===void 0?Xt:lr({...I,row:"macro",shows:"start",rules:Pe}),macroEnd:Pe===void 0?Xt:lr({...I,row:"macro",shows:"end",rules:Pe}),micro:st===void 0?Xt:lr({...I,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:st.previous.window},next:{motion:"shift",window:st.next.window}}})}},[Pe,st,p,w,c,ee,M,A,V,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),dt=s.useCallback(I=>te(I.macroRange,I.microSelection[0],"macro"),[te]),C=s.useCallback(I=>te(I.macroRange,I.microSelection[0],"micro"),[te]),Z=jt(Ge.macroStart,dt),ze=jt(Ge.macroEnd,dt),Se=jt(Ge.micro,C),[ge,vt]=D,Ct=s.useMemo(()=>({value:A[0],onChange:He,minDate:r,maxDate:A[1],unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ve?{stepper:Z}:{}}),[A,He,r,p,c,k,e.formatLocale,e.locale,e.labels,x,Ve,Z]),z=s.useMemo(()=>({value:A[1],onChange:Ke,minDate:A[0],maxDate:n,unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ve?{stepper:ze}:{}}),[A,Ke,n,p,c,k,e.formatLocale,e.locale,e.labels,x,Ve,ze]),Pr=s.useMemo(()=>({value:V,onChange:q,minDate:ge,maxDate:vt,unit:w,yearStartMonth:c,...Wt(w,W),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ft?{stepper:Se}:{}}),[V,q,ge,vt,w,c,W,e.formatLocale,e.locale,e.labels,x,ft,Se]),rn=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:p,microUnit:w,minDate:r,maxDate:n,macroRange:A,microValue:V,onChangeMacroRange:at,onChangeMicroPoint:$e}),[g,t,p,w,r,n,A,V,at,$e,c]);return{macroRange:A,setMacroRange:ot,microValue:V,setMicroValue:T,setMacroLowerDate:He,setMacroUpperDate:Ke,setMicroDate:q,shiftMacroRange:et,shiftMicroValue:it,resetVernier:gt,macroStartSelectorProps:Ct,macroEndSelectorProps:z,microSelectorProps:Pr,sliderProps:rn,duringRender:ne.duringRender}}function ja(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function Po(e,t){const r=new Date(e.getTime());return Ao(r.getFullYear(),r.getMonth(),t)}function ks(e){return e===void 0?0:Ws(e)?e:Number.NaN}const Is=Nn("declare the years to offer with minYear / maxYear or allowedYears");function uo(e,t,r,n){e!==void 0&&Rl(e,t,r,n)}function Rl(e,t,r,n){if(!ye(e))throw new RangeError(`YearSelector: ${t} must be a valid Date (received: ${E(e)})`);qe("YearSelector",t,e,"year",r,n)}function As(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`YearSelector: ${t} must be an integer year (received: ${E(e)})`);if(Number.isNaN(ja(e,r).getTime()))throw new RangeError(`YearSelector: ${t} must name a year that starts inside the Date range (received: ${E(e)}); under yearStartMonth ${r} that year starts on month ${r+1}, day 1`)}}function Os(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Po(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function ed(e,t,r,n){const o=new Set;for(const a of e){const i=Po(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function td(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:ed(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function rd(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const nd=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedYears:f,className:x="",style:v,disabled:P=!1,locale:j,labels:p,formatLocale:w,formatOption:c,yearStartMonth:g}=e,d=fr("YearSelector",g);if(uo(t,"value",d,""),uo(r,"initialDate",d,""),uo(m,"minDate",d,Is),uo(h,"maxDate",d,Is),As(i,"minYear",d),As(u,"maxYear",d),en("YearSelector","allowedYears",f),f!==void 0)for(let _=0;_<f.length;_++)Rl(f[_],`allowedYears[${_}]`,d,"");w!==void 0&&Vo("YearSelector","formatLocale",w);const re=t??r;if(re===void 0)throw new RangeError("YearSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected year is never inferred from the wall clock");o!==void 0&&Za("YearSelector",o,t!==void 0);const O=ko(j,p),ae=t!==void 0,[J,se]=Qa(re,ae,_=>_o(_,"year",d),_=>Po(_,d)),ne=m?.getTime(),A=h?.getTime(),ee=s.useMemo(()=>Os(i,m,Math.max,d),[i,ne,d]),M=s.useMemo(()=>Os(u,h,Math.min,d),[u,A,d]);if(ee!==null&&M!==null&&ee>M)throw new RangeError(`YearSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${ee}, upper: ${M})`);const D=f===void 0?null:f.map(_=>_.getTime()).join(","),L=s.useMemo(()=>td(f,ee,M,d),[D,ee,M,d]);if(L===null)throw new RangeError("YearSelector: a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate), or allowedYears, are required; the option list is never invented");const k=s.useMemo(()=>L.kind==="discrete"?{kind:"candidates",ascending:L.ascending,loIndex:0,hiIndex:L.ascending.length-1}:{kind:"range",min:L.minYear,max:L.maxYear},[L]),U=t!==void 0?Po(t,d):J,F=!En(k,U),W=_=>{if(!P){if(!En(k,_))throw new RangeError(`YearSelector: refusing to emit ${_}, which lies outside the selectable years`);ae||se(_),n?.(ja(_,d),_)}},V=Zt(k,U,-1),Q=Zt(k,U,1),ce=()=>{if(o!==void 0){o.onStep("previous");return}V!==null&&W(V)},ve=()=>{if(o!==void 0){o.onStep("next");return}Q!==null&&W(Q)},G=s.useMemo(()=>{const _=L.kind==="discrete"?[...L.ascending].reverse():rd(L.minYear,L.maxYear);return F&&(_.push(U),_.sort((Me,Ee)=>Ee-Me)),_.map(Me=>({value:Me,label:nt("year",ja(Me,d),c,w)}))},[L,F,U,d,w,c]);return $.jsxs("div",{className:`inline-flex items-center ${Dn} ${x}`,style:v,"data-out-of-range":F?"true":void 0,children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:P,canStep:o===void 0?V!==null:o.canStepPrevious,onStep:ce,ariaLabel:O.previousYear}),$.jsx("select",{"aria-label":O.yearSelect,disabled:P,className:"w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",value:U,onChange:_=>{if(!_.target.value)return;const Me=Number(_.target.value);Number.isInteger(Me)&&W(Me)},children:G.map(_=>$.jsx("option",{value:_.value,disabled:F&&_.value===U,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:_.label},_.value))}),$.jsx(yr,{neighbour:"control",direction:"right",disabled:P,canStep:o===void 0?Q!==null:o.canStepNext,onStep:ve,ariaLabel:O.nextYear}),a]})},od=(e,t)=>{const r=ks(t.yearStartMonth);return!(ks(e.yearStartMonth)!==r||!Xa(e,t,n=>_o(n,"year",r))||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedYears!==t.allowedYears||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!Co(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},Ml=s.memo(nd,od);Ml.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Us;exports.DateSelector=bl;exports.MonthSelector=xl;exports.PERIOD_SLIDER_LABEL_CATALOGS=Hs;exports.PERIOD_SLIDER_LABEL_KEYS=To;exports.PeriodSlider=ul;exports.YearSelector=Ml;exports.addUnit=Fs;exports.areStylesEqual=cl;exports.calculateConnectDragValues=Xs;exports.calculateHandleDragValues=Ta;exports.calculateKeyboardActionValues=Zs;exports.calculateLabelSlant=Ga;exports.calculateVernierMacroDrag=al;exports.calculateVernierMicroDrag=il;exports.decode=oe;exports.encode=Y;exports.findNearestDateIndex=De;exports.formatLabel=nt;exports.formatOptionText=dl;exports.formatQuarterLabel=Bc;exports.formatScreenReaderLabel=Rr;exports.getMacroWindowEndDate=Gs;exports.getMacroWindowStartDate=Ks;exports.getSortedAllowedDates=Fc;exports.normalizeDateByUnit=bt;exports.resolveDraggedEdge=$o;exports.resolveMacroWindow=yt;exports.resolvePeriodSliderLabels=js;exports.resolveQuarter=qs;exports.resolveSelectorSteps=Aa;exports.resolveVernierRailZone=qa;exports.resolveVernierSelectorSteps=lr;exports.resolveVernierTargetHandle=ol;exports.resolveWheelStep=nl;exports.usePeriodSliderPoint=Zu;exports.usePeriodSliderRange=Xu;exports.useSelectorStepper=jt;exports.useVernierSliderPoint=Ju;exports.useVernierSliderRange=Qu;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),Hc=require("date-fns"),s=require("react"),dr=require("@aiquants/virtualscroll"),jc=require("react-dom"),oi="an object that cannot be converted to a string",Fc=3,ye=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},Nt=e=>{try{return Array.isArray(e)}catch{return!1}},Uc=e=>e===void 0||Nt(e);function an(e,t,r){if(!Uc(r))throw new RangeError(`${e}: ${t} must be an array of Dates (received: ${E(r)})`)}const E=e=>{if(typeof e=="string")return JSON.stringify(e);if(ye(e))return Date.prototype.toISOString.call(e);if(Nt(e))return zc(e);try{return String(e)}catch{return oi}},zc=e=>{let t;try{t=e.length}catch{return oi}const r=Math.min(t,Fc),n=[];for(let a=0;a<r;a++)n.push(Bc(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},Bc=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return Nt(r)?`Array(${r.length})`:E(r)}catch{return oi}},Pt=(e,t)=>ye(e)?t(e):Number.NaN,gt=(e,t)=>e===void 0?null:Pt(e,t),ws=120,La="data-drag-snap",$a="--ps-drag-snap-duration",En={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"]},sl=["low","high"],ll=["tx","ty","rot","leader-length","leader-angle"],Yo={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"}},ai=(e,t)=>`${e}-${t}`,Pn=(e,t,r)=>`var(${ai(e,t)}, ${r})`,Wc=(e,t,r)=>{const n=Yo[t];for(const o of sl)for(const a of ll)e.style.setProperty(ai(n[o],a),r[o][a])},cl=e=>Math.max(0,Math.min(1,e)),Lo=(e,t,r,n)=>{const o=cl(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},ii=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},Ho=(e,t,r,n)=>{const o=cl(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},Ta=(e,t,r,n)=>{if(r){const i=(1-e)*100,l=(1-t)*100;return n?`M 12 ${l} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${l} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},ir=(e,t)=>`var(${e}, ${t}%)`,Gc=(e,t,r,n)=>{const[o,a]=En[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},Kc=e=>{for(const[t,r]of Object.values(En))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Yo))for(const r of sl)for(const n of ll)e.style.removeProperty(ai(t[r],n))},qc=["transform","translate","scale","rotate","perspective","filter","backdrop-filter"],Xc=["transform","translate","scale","rotate","perspective","filter"],Zc=["paint","layout","strict","content"],Qc=["paint","strict","content"],Jc=new Set(["hidden","clip","auto","scroll","overlay"]),eu=(e,t)=>{const r=e.getPropertyValue("position");if(t==="absolute"&&r!==""&&r!=="static"||qc.some(a=>!["","none"].includes(e.getPropertyValue(a)))||!["","normal"].includes(e.getPropertyValue("container-type")))return!0;const n=e.getPropertyValue("will-change");if(Xc.some(a=>n.includes(a)))return!0;const o=e.getPropertyValue("contain");return Zc.some(a=>o.includes(a))},tu=e=>{const t=e.getPropertyValue("display");if(t==="contents"||t==="inline")return!1;if(Jc.has(e.getPropertyValue("overflow-y")))return!0;const r=e.getPropertyValue("contain");return Qc.some(n=>r.includes(n))},vs=e=>{if(e.assignedSlot!==null)return e.assignedSlot;if(e.parentElement!==null)return e.parentElement;const t=e.parentNode;return t!==null&&t.nodeType===11&&"host"in t?t.host:null},ru=e=>{const t=e.ownerDocument,r=t.defaultView;if(r===null)return[];const n=[];let o=r.getComputedStyle(e).getPropertyValue("position");for(let a=vs(e);a!==null&&a!==t.documentElement&&a!==t.body;a=vs(a)){const i=r.getComputedStyle(a);(o==="absolute"||o==="fixed")&&!eu(i,o)||(tu(i)&&n.push(a),o=i.getPropertyValue("position"))}return n},nu=e=>{const t=e.getBoundingClientRect(),r="offsetHeight"in e&&typeof e.offsetHeight=="number"?e.offsetHeight:0,n=r>0?t.height/r:1,o=t.top+e.clientTop*n;return{top:o,bottom:o+e.clientHeight*n}},ou=(e,t,r)=>{const n=e.getBoundingClientRect(),o=e.ownerDocument.documentElement.clientHeight;if(!(n.height>0&&o>0))return null;const a=n.top+n.height/2;let i=0,l=o;for(const u of ru(e)){const d=nu(u);i=Math.max(i,d.top),l=Math.min(l,d.bottom)}return t?.isConnected&&(i=Math.max(i,t.getBoundingClientRect().bottom)),r?.isConnected&&(l=Math.min(l,r.getBoundingClientRect().top)),{topPx:Math.max(0,a-i),bottomPx:Math.max(0,l-a)}},au=(e,t,r,n)=>{const o=e.ownerDocument.defaultView;if(o===null)return null;const a=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(!(a.height>0&&i.height>0))return null;const l=a.top+a.height/2,u=Number.parseFloat(o.getComputedStyle(r).getPropertyValue(n==="top"?"bottom":"top"));if(!Number.isFinite(u))return null;const d=n==="top"?i.bottom-u:i.top+u;return{anchorPx:Math.abs(d-l),knobCentrePx:Math.abs(i.top+i.height/2-l)}},ul=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],jo=[...dr.VIRTUAL_SCROLL_LABEL_KEYS,...ul],Fa=Object.freeze({en:Object.freeze({rangeStart:"Range start",rangeEnd:"Range end",selectedDate:"Selected date",macroRangeStart:"Macro range start",macroRangeEnd:"Macro range end",microRangeStart:"Micro range start",microRangeEnd:"Micro range end",microSelectedDate:"Micro selected date",decrease:"Decrease",increase:"Increase",previousYear:"Previous year",nextYear:"Next year",yearSelect:"Year",previousMonth:"Previous month",nextMonth:"Next month",monthSelect:"Month",previousDay:"Previous day",nextDay:"Next day",dateSelect:"Date",splitYear:"Year",splitMonth:"Month",splitDay:"Day"}),ja:Object.freeze({rangeStart:"期間の開始",rangeEnd:"期間の終了",selectedDate:"選択日",macroRangeStart:"広域期間の開始",macroRangeEnd:"広域期間の終了",microRangeStart:"詳細期間の開始",microRangeEnd:"詳細期間の終了",microSelectedDate:"詳細の選択日",decrease:"前へ",increase:"次へ",previousYear:"前年",nextYear:"翌年",yearSelect:"年",previousMonth:"前月",nextMonth:"翌月",monthSelect:"年月",previousDay:"前日",nextDay:"翌日",dateSelect:"日付",splitYear:"年",splitMonth:"月",splitDay:"日"})}),dl=Object.freeze({en:Object.freeze({...dr.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Fa.en}),ja:Object.freeze({...dr.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Fa.ja})}),Ss=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,iu=e=>jo.includes(e),su=(e,t)=>{const r={};let n=!1;for(const o of dr.VIRTUAL_SCROLL_LABEL_KEYS){const a=t.has(o)?e[o]:void 0;a!==void 0&&(r[o]=a,n=!0)}return n?r:void 0},lu=e=>{try{return dr.resolveVirtualScrollLocale(e)}catch(t){throw t instanceof RangeError?new RangeError(`[period-slider] locale is the UI language, not a BCP 47 tag (date formatting reads formatLocale): ${t.message}`,{cause:t}):t}},ml=(e,t)=>{const r=lu(e);if(t===void 0)return dl[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${Ss(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[period-slider] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);const o=new Set(Object.keys(t));for(const l of o)if(!iu(l))throw new RangeError(`[period-slider] labels.${l} is not a known label key; expected one of ${jo.join(", ")}`);const i={...dr.resolveVirtualScrollLabels(r,su(t,o)),...Fa[r]};for(const l of ul){const u=o.has(l)?t[l]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[period-slider] labels.${l} must be a non-blank string; got ${Ss(u)}`);i[l]=u}}return Object.freeze(i)},cu=e=>{const t={};for(const r of dr.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},uu=(e,t)=>e===t||jo.every(r=>e[r]===t[r]),Fo=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0||e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const r=new Set(Object.keys(e)),n=Object.keys(t);if(r.size!==n.length)return!1;const o=e,a=t;return n.every(i=>r.has(i)&&Object.is(o[i],a[i]))},Ca=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),xs=new Set(["hidden","clip","scroll","auto","overlay"]),Rs=["paint","strict","content"],du=["layout","paint","strict","content"],mu=["transform","perspective","filter"],wn=e=>e!==void 0&&e!==""&&e!=="none",fu=e=>e!==void 0&&e!==""&&e!=="normal",so=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},hu=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,gu=(e,t)=>t==="absolute"&&wn(e.position)&&e.position!=="static"||wn(e.transform)||wn(e.perspective)||wn(e.filter)||wn(e.backdropFilter)||fu(e.containerType)||du.some(r=>e.contain.includes(r))?!0:mu.some(r=>e.willChange.includes(r)),pu=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const l=e.getBoundingClientRect();if(l.width===0||l.height===0)return!1;const u=n?0:r,d=n?r:0;if(o<l.left-u||o>=l.right+u||a<l.top-d||a>=l.bottom+d)return!1;const m=i.getComputedStyle(t);if(m.visibility!=="visible")return!1;let M=null;for(let L=t;L!==null;L=L.parentElement){const g=L===t?m:i.getComputedStyle(L);if(M!==null&&!gu(g,M))continue;const O=xs.has(g.overflowX)||Rs.some(w=>g.contain.includes(w)),p=xs.has(g.overflowY)||Rs.some(w=>g.contain.includes(w));if(O||p){const w=L.getBoundingClientRect();if(O&&(o<w.left+so(g.borderLeftWidth)||o>=w.right-so(g.borderRightWidth))||p&&(a<w.top+so(g.borderTopWidth)||a>=w.bottom-so(g.borderBottomWidth)))return!1}M=hu(g)}return!0},Ia=new Map,bu=(e,t)=>{if(!(t.shiftKey&&t.cancelable))return;for(const o of e)if(o.ownsHit(t.target)){o.step(t);return}let r=null,n=Number.POSITIVE_INFINITY;for(const o of e){const a=o.distanceToRailPx(t.clientX,t.clientY);a===null||a>=n||(r=o,n=a)}r?.step(t)},wu=(e,t)=>{let r=Ia.get(e);if(r===void 0){const a=new Set,i=l=>bu(a,l);r={participants:a,listener:i},Ia.set(e,r),e.addEventListener("wheel",i,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(Ia.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},$n="gap-[11px]",vu={single:1,double:2},Dn=6,Er=Dn*2,lo=(e,t)=>{const r=vu[e],n=(r-1)*Dn+Dn*4/3,o=Er/2,a=Array.from({length:r},(l,u)=>{const d=u*Dn,m=d+Dn;return{left:`${d},${o} ${m},0 ${m},${Er}`,right:`${n-d},${o} ${n-m},0 ${n-m},${Er}`,up:`${o},${d} 0,${m} ${Er},${m}`,down:`${o},${n-d} 0,${n-m} ${Er},${n-m}`}[t]}),i=t==="up"||t==="down";return{widthPx:i?Er:n,heightPx:i?n:Er,triangles:a}},Ms=e=>({left:lo(e,"left"),right:lo(e,"right"),up:lo(e,"up"),down:lo(e,"down")}),Su={single:Ms("single"),double:Ms("double")},si=(e,t)=>{if(t===void 0)return"single";if(t==="single"||t==="double")return t;throw new RangeError(`${e}: stepGlyph must be "single" or "double" (received: ${E(t)})`)},Aa=e=>{e.preventDefault(),e.stopPropagation()},xu={onMouseDownCapture:Aa,onMouseUpCapture:Aa,onClickCapture:Aa},Ru="period-slider-step",Mu=`${Ru} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Du="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]",yu={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"},co="after:inset-[calc((100%-var(--ps-target-size))/2)]",Ds={horizontal:"px-[19px]",vertical:"py-[19px]"},Eu={control:{left:co,right:co,up:co,down:co},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)]"}},Tr=({direction:e,glyph:t,neighbour:r,disabled:n,canStep:o,onStep:a,ariaLabel:i,className:l,ref:u})=>{const{widthPx:d,heightPx:m,triangles:M}=Su[t][e],L=n||!o;return T.jsx("button",{ref:u,type:"button","aria-label":i,disabled:n,"aria-disabled":L?!0:void 0,...L?xu:null,onClick:L?void 0:a,className:`${l===void 0?"":`${l} `}${Mu} ${Du} ${yu[r]} ${Eu[r][e]}`,children:T.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,"data-glyph":t,width:d,height:m,viewBox:`0 0 ${d} ${m}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:M.map(g=>T.jsx("polygon",{points:g},g))})})},Uo=(e,t)=>{const r=s.useMemo(()=>ml(e,t),[e,t]),n=s.useRef(r);return uu(n.current,r)||(n.current=r),n.current},dt=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${E(r)})`)},fr=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&dt(e,"values.min",t.min),t.max!==null&&dt(e,"values.max",t.max),t.min!==null&&t.max!==null&&t.max<t.min)throw new RangeError(`${e}: values.max must not precede values.min (min: ${t.min}, max: ${t.max})`);return}dt(e,"values.loIndex",t.loIndex),dt(e,"values.hiIndex",t.hiIndex)},Hn=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,zo=(e,t)=>{let r=e.loIndex,n=e.hiIndex+1;for(;r<n;){const o=r+n>>1;e.ascending[o]<t?r=o+1:n=o}return r},Tn=(e,t)=>(fr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:Hn(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),Cn=(e,t)=>{if(fr("drawnValuesHas",e),dt("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(Hn(e))return!1;const r=zo(e,t);return r<=e.hiIndex&&e.ascending[r]===t},In=(e,t)=>{if(fr("drawnValuesNearest",e),dt("drawnValuesNearest","value",t),e.kind==="range")return e.min!==null&&t<e.min?e.min:e.max!==null&&t>e.max?e.max:t;if(Hn(e))return null;const r=zo(e,t);if(r>e.hiIndex)return e.ascending[e.hiIndex];if(e.ascending[r]===t||r===e.loIndex)return e.ascending[r];const n=e.ascending[r-1],o=e.ascending[r];return t-n<=o-t?n:o},Qt=(e,t,r)=>{if(fr("drawnValuesNeighbour",e),dt("drawnValuesNeighbour","value",t),e.kind==="range"){if(r===-1){const i=e.max===null?t-1:Math.min(t-1,e.max);return e.min!==null&&i<e.min?null:i}const a=e.min===null?t+1:Math.max(t+1,e.min);return e.max!==null&&a>e.max?null:a}if(Hn(e))return null;const n=zo(e,t);if(r===-1){const a=n-1;return a<e.loIndex?null:e.ascending[a]}const o=n<=e.hiIndex&&e.ascending[n]===t?n+1:n;return o>e.hiIndex?null:e.ascending[o]},vo=(e,t,r)=>{if(fr("clampPairIntoDrawnValues",e),dt("clampPairIntoDrawnValues","low",t),dt("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=In(e,t),o=In(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},Pu=(e,t,r)=>{if(fr("carryPairIntoDrawnValues",e),dt("carryPairIntoDrawnValues","low",t),dt("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(Hn(e))return null;const n=Tn(e,-1),o=Tn(e,1),a=r-t;return o!==null&&r>o?vo(e,o-a,o):n!==null&&t<n?vo(e,n,n+a):vo(e,t,r)},So=(e,t,r)=>(fr("drawnValuesAtOrBeyond",e),dt("drawnValuesAtOrBeyond","target",t),Qt(e,t-r,r)),sn=(e,t,r)=>{if(t!==null&&dt("drawnValuesWithin","min",t),r!==null&&dt("drawnValuesWithin","max",r),t!==null&&r!==null&&r<t)throw new RangeError(`drawnValuesWithin: max must not precede min (min: ${t}, max: ${r})`);const n={ascending:e,loIndex:0,hiIndex:e.length-1};let o=e.length;if(r!==null){let a=0;for(;a<o;){const i=a+o>>1;e[i]<=r?a=i+1:o=i}}return{kind:"candidates",ascending:e,loIndex:t===null?0:zo(n,t),hiIndex:o-1}},xo=e=>(fr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Qt(e,t,r),edge:t=>Tn(e,t)}),Ua=(e,t,r,n,o)=>{if(dt("stepPair","low",t),dt("stepPair","high",r),r<t)throw new RangeError(`stepPair: high must not precede low (low: ${t}, high: ${r})`);if(n!==-1&&n!==1)throw new RangeError(`stepPair: direction must be -1 or 1 (received: ${E(n)})`);switch(o.motion){case"shift":{if(o.edge!=="disable"&&o.edge!=="clamp")throw new RangeError(`stepPair: rule.edge must be "disable" or "clamp" (received: ${E(o.edge)})`);const a=n===1?r:t,i=n===1?t:r,l=e.stepEnd(i,n);if(l===null)return null;let u=e.stepEnd(a,n);if(u===null){const d=e.edge(n);if(o.edge==="disable"||d===null||(n===1?a>d:a<d))return null;u=d}return n===1?[l,u]:[u,l]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${E(o.shows)})`);const a=e.stepEnd(o.shows==="start"?t:r,n);return a===null?null:[a,a]}default:throw new RangeError(`stepPair: rule.motion must be one of "shift", "start", "end", "single" (received: ${E(o.motion)})`)}},fl={"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"}},hl=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,Vt=(e,t)=>{if(!hl(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${E(t)})`)},hr=(e,t)=>t===void 0?0:(Vt(e,t),t),Ce=(e,t,r)=>{if(r!=="year"&&r!=="month"&&r!=="day")throw new RangeError(`${e}: ${t} must be one of "year", "month", "day" (received: ${E(r)})`)},Jt=(e,t,r,n)=>r===void 0?n:(Ce(e,t,r),r),Lu=[31,28,31,30,31,30,31,31,30,31,30,31],gl=719468,Ro=146097,za=(e,t)=>t!==1?Lu[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,li=(e,t,r,n)=>{const o=e*12+t+n,a=Math.floor(o/12),i=o-a*12;return[a,i,Math.min(r,za(a,i))]},An=(e,t,r)=>{const n=t<2?e-1:e,o=Math.floor(n/400),a=n-o*400,i=t<2?t+10:t-2,l=Math.floor((153*i+2)/5)+r-1,u=a*365+Math.floor(a/4)-Math.floor(a/100)+l;return o*Ro+u-gl},ys=e=>{const t=e+gl,r=Math.floor(t/Ro),n=t-r*Ro,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(Ro-1)))/365),a=n-(o*365+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*a+2)/153),l=i<10?i+2:i-10;return[r*400+o+(l<2?1:0),l,a-Math.floor((153*i+2)/5)+1]},Bo=(e,t,r)=>e-(t<r?1:0),Rt=(e,t,r=0)=>{if(Ce("normalizeDateByUnit","unit",e),!ye(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${E(t)})`);Vt("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(Bo(n.getFullYear(),n.getMonth(),r),r,1),n.setHours(0,0,0,0)):(e==="month"&&n.setDate(1),n.setHours(0,0,0,0)),n},Y=(e,t,r=0)=>{Ce("encode","unit",e),Vt("encode",r);const n=Rt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:An(o,a,n.getDate())},re=(e,t,r=0)=>{Ce("decode","unit",e),Vt("decode",r);const n=new Date(0);if(n.setHours(0,0,0,0),e==="year")return n.setFullYear(t,r,1),n;if(e==="month"){const a=Math.floor(t/12),i=t-a*12;return n.setFullYear(a,i,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},jn=e=>`; ${e} instead of a sentinel for "no bound"`,pl=jn("minDate is required, so pass the earliest date to offer"),Ke=(e,t,r,n,o,a)=>{const i=Fn(r,n,o);if(i===null)throw new RangeError(`${e}: ${t} must fall in a ${n} that starts inside the Date range (received: ${E(r)})${a}`);return i},Fn=(e,t,r)=>{const n=Y(t,e,r);return Number.isInteger(n)?n:null},bl=(e,t,r)=>{if(Ce("addUnit","unit",e),!ye(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${E(t)})`);if(!Number.isInteger(r))throw new RangeError(`addUnit: amount must be an integer number of units (received: ${E(r)})`);const n=new Date(t.getTime());return r===0?n:e==="year"||e==="month"?(n.setFullYear(...li(n.getFullYear(),n.getMonth(),n.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},Es=(e,t,r,n,o)=>{const a=Math.floor(t/12),[i,l,u]=e==="year"?[t,o,1]:e==="month"?[a,t-a*12,1]:ys(t),[d,m,M]=r==="year"||r==="month"?li(i,l,u,r==="year"?n*12:n):ys(An(i,l,u)+n);return e==="year"?Bo(d,m,o):e==="month"?d*12+m:An(d,m,M)},wl=(e,t,r,n=0)=>{if(Ce("getMacroWindowStartDate","macroUnit",e),Ce("getMacroWindowStartDate","microUnit",t),!ye(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${E(r)})`);return Vt("getMacroWindowStartDate",n),Ke("getMacroWindowStartDate","d",r,e,n,""),Ke("getMacroWindowStartDate","d",r,t,n,""),Rt(t,Rt(e,r,n),n)},vl=(e,t,r,n=0)=>{if(Ce("getMacroWindowEndDate","macroUnit",e),Ce("getMacroWindowEndDate","microUnit",t),!ye(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${E(r)})`);Vt("getMacroWindowEndDate",n);let o;const a=new Date(r.getTime());if(e==="year"&&t!=="year"){const[l,u]=li(Bo(a.getFullYear(),a.getMonth(),n),n,1,11);o=t==="month"?l*12+u:An(l,u,za(l,u))}else if(e==="month"&&t==="day")o=An(a.getFullYear(),a.getMonth(),za(a.getFullYear(),a.getMonth()));else return Ke("getMacroWindowEndDate","d",r,t,n,""),Rt(t,r,n);const i=re(t,o,n);if(!ye(i))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${E(r)})`);return i},Ps=(e,t,r)=>e<t?t:e>r?r:e,$t=(e,t,r,n,o,a=0)=>{if(Ce("resolveMacroWindow","macroUnit",e),Ce("resolveMacroWindow","microUnit",t),Vt("resolveMacroWindow",a),To("macroRange",r,!0,"resolveMacroWindow"),!ye(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${E(n)})`);if(!ye(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${E(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${E(n)}, maxDate: ${E(o)})`);Ke("resolveMacroWindow","maxDate",o,t,a,""),Ke("resolveMacroWindow","macroRange[0]",r[0],e,a,""),Ke("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=Y(e,r[1],a)<Y(e,o,a)?Ps(vl(e,t,r[1],a),n,o):o;return[Rt(t,Ps(wl(e,t,r[0],a),n,o),a),Rt(t,i,a)]},Sl=(e,t)=>{if(!ye(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${E(e)})`);Vt("resolveQuarter",t);const r=Rt("year",e,t).getFullYear(),n=new Date(e.getTime()),o=((n.getMonth()-t)%12+12)%12,a=Math.floor(o/3)+1;return n.setFullYear(r,t+3*(a-1),1),n.setHours(0,0,0,0),{year:r,quarter:a,startDate:n}},$u={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Ls=new Map,Tu=(e,t)=>{const r=`${e}\0${t}`,n=Ls.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,$u[e]);return Ls.set(r,o),o},Cu=4,Iu=6,Wo=e=>e>=0?String(e).padStart(Cu,"0"):`-${String(-e).padStart(Iu,"0")}`,Au=(e,t)=>{const r=new Date(t.getTime()),n=Wo(r.getFullYear());if(e==="year")return n;const o=String(r.getMonth()+1).padStart(2,"0");if(e==="month")return`${n}-${o}`;const a=String(r.getDate()).padStart(2,"0");return`${n}-${o}-${a}`},at=(e,t,r,n)=>(Ce("formatLabel","unit",e),ye(t)?r?r(t,e,"period"):n===void 0?Au(e,t):Tu(e,n).format(t):""),Pr=(e,t,r,n)=>(Ce("formatScreenReaderLabel","unit",e),at(e,t,r,n)),ku=(e,t)=>{if(!ye(e))return"";Vt("formatQuarterLabel",t);const{quarter:r}=Sl(e,t);return`${at("year",Rt("year",e,t))}-Q${r}`},De=(e,t,r,n=0)=>{if(Ce("findNearestDateIndex","unit",r),Vt("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!ye(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${E(t)})`);const o=Ke("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=Y(r,e[a],n))return 0;if(o>=Y(r,e[i],n))return i;for(;a<=i;){const d=a+i>>1,m=Y(r,e[d],n);if(m===o)return d;m<o?a=d+1:i=d-1}const l=Math.abs(Y(r,e[a],n)-o),u=Math.abs(Y(r,e[i],n)-o);return l<u?a:i},Nu=(e,t,r,n,o=0)=>(Ce("getSortedAllowedDates","unit",t),mr("getSortedAllowedDates",Go(e),t,r,n,o).dates),Go=e=>({list:e,path:"allowedDates",inheritedBy:null}),mr=(e,t,r,n,o,a)=>{Vt(e,a);const{list:i,path:l}=t,u=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(an(e,`${l}${u}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[g,O]of[["minDate",n],["maxDate",o]])if(!ye(O))throw new RangeError(`${e}: ${g} must be a valid Date (received: ${E(O)})`);const d=Ke(e,"minDate",n,r,a,""),m=Ke(e,"maxDate",o,r,a,""),M=new Map;for(let g=0;g<i.length;g++){const O=i[g];if(!ye(O))throw new RangeError(`${e}: ${l}[${g}]${u} must be a valid Date (received: ${E(O)})`);const p=Ke(e,`${l}[${g}]${u}`,O,r,a,"");p<d||p>m||M.has(p)||M.set(p,Rt(r,O,a))}if(M.size===0)throw new RangeError(`${e}: every ${l} entry${u} falls outside [minDate, maxDate] (minDate: ${E(n)}, maxDate: ${E(o)}, entries: ${i.length})`);const L=Array.from(M.keys()).sort((g,O)=>g-O);return{keys:L,dates:L.map(g=>M.get(g))}},ci=(e,t,r,n,o,a)=>{const{keys:i,dates:l}=mr(e,t,r,n,o,a);return l.length===0?null:{...sn(i,null,null),dates:l}},kn=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),uo=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=De(e,n,t,o);if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-l)/u))}return i/a},mo=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:De(e,new Date(l+i*u),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},Ba=(e,t,r,n,o,a,i)=>{let l=r,u=n;return i?(l=t,u=t):e==="low"?t>n?(l=n,u=t):l=t:t<r?(u=r,l=t):u=t,[Math.max(o,Math.min(a,l)),Math.max(o,Math.min(a,u))]},xl=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:l,unit:u,yearStartMonth:d=0})=>{if(Ce("calculateConnectDragValues","unit",u),a){const p=i.length-1;if(p<=0)return[0,0];const w=Math.max(0,Math.min(p,Math.round(t))),h=Math.max(w,Math.min(p,Math.round(r)));if(l==="time"){const te=i[0].getTime(),ce=i[p].getTime(),B=i[w].getTime(),U=i[h].getTime()-B;let oe=B+e*(ce-te),z=oe+U;oe<te&&(oe=te,z=te+U),z>ce&&(z=ce,oe=ce-U);const ne=De(i,new Date(oe),u,d),C=De(i,new Date(z),u,d);return[ne,Math.max(ne,C)]}const S=Math.round(e*p);let v=w+S,f=h+S;return v<0&&(f+=-v,v=0),f>p&&(v-=f-p,f=p),[Math.max(0,Math.min(p,v)),Math.max(0,Math.min(p,f))]}const m=p=>Math.max(n,Math.min(o,p)),M=o-n;if(M<=0)return[m(t),m(r)];const L=Math.round(e*M);let g=t+L,O=r+L;return g<n&&(O+=n-g,g=n),O>o&&(g-=O-o,O=o),[m(g),m(O)]},Rl=(e,t,r,n,o,a,i,l)=>{let u=0,d=!1,m=!1;switch(e){case"ArrowRight":case"ArrowUp":u=l;break;case"ArrowLeft":case"ArrowDown":u=-l;break;case"PageUp":u=l*5;break;case"PageDown":u=-l*5;break;case"Home":d=!0;break;case"End":m=!0;break;default:return null}if(i){let g=r;return d?g=o:m?g=a:g=Math.max(o,Math.min(a,r+u)),[g,g]}let M=r,L=n;return t==="low"?d?M=o:m?M=n:M=Math.max(o,Math.min(n,r+u)):d?L=r:m?L=a:L=Math.max(r,Math.min(a,n+u)),[M,L]},Ml=8,Dl=2,yl=16,Vu=12,Ou=90,ui=1.15,Ko=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},$o=e=>Ml+(e?.anchorGapY??Dl),di=(e,t)=>{const r=t?.estimatedHeightPx??yl,o=$o(t)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,isFlipped:!1,proximity:0}},_u=e=>{for(const t of["topPx","bottomPx"]){const r=e[t];if(typeof r!="number"||Number.isNaN(r)||r<0)throw new RangeError(`calculateLabelSlant: config.room.${t} must be a number of pixels, zero or more (Infinity for unbounded) (received: ${E(r)})`)}},Yu=(e,t,r)=>{if(r<=t/2)return 0;const n=Math.min(1,2*r/Math.hypot(e,t));return(Math.asin(n)-Math.atan2(t,e))*180/Math.PI},Hu=(e,t,r,n,o,a,i,l)=>{if(i===void 0)return{side:t,angleDeg:e};const u=t==="top"?"bottom":"top",d=O=>O==="top"?i.topPx:i.bottomPx,m=O=>O===t?o:a,M=O=>m(O)+(1+l)*Ko(r,n,e).acrossPx;if(M(t)<=d(t))return{side:t,angleDeg:e};if(M(u)<=d(u))return{side:u,angleDeg:e};const L=d(u)-m(u)>d(t)-m(t)?u:t,g=(d(L)-m(L))/(1+l);return{side:L,angleDeg:Math.min(e,Yu(r,n,g))}},qo=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??yl,l=o?.paddingPx??Vu,u=o?.maxAngleDeg??Ou,d=o?.room,m=o?.drawnScale??1;if(d!==void 0&&_u(d),typeof m!="number"||!Number.isFinite(m)||m<=0)throw new RangeError(`calculateLabelSlant: config.drawnScale must be a positive finite number (received: ${E(m)})`);const M=$o(o),L=o?.flipClearancePx??M;if(typeof L!="number"||!Number.isFinite(L)||L<0)throw new RangeError(`calculateLabelSlant: config.flipClearancePx must be a finite number of pixels, zero or more (received: ${E(L)})`);const g=di(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return g;const O=Math.max(0,t-e)/100*r,p=a+l;if(O>=p)return g;const w=Math.max(0,Math.min(1,(p-O)/p)),h=w*w*w*(w*(w*6-15)+10),S=Hu(h*u,n,a,i,M,L,d,m),v=S.angleDeg===0?0:S.side==="top"?-S.angleDeg:S.angleDeg,f=Ko(a,i,S.angleDeg),te=(S.side===n?M:L)+f.acrossPx,ce=S.side==="top"?-te:+te,B=2*f.alongPx,U=Math.max(0,(B+l-O)/2);return{lowAngleDeg:v,highAngleDeg:v,lowOffsetX:-U,highOffsetX:U,lowOffsetY:ce,highOffsetY:ce,isSlanted:w>.001,isFlipped:S.side!==n,proximity:w}},El=e=>({...e,lowOffsetX:0,highOffsetX:0}),jt=(e,t)=>(e==="macro"?t.macroIsDiscrete:t.microIsDiscrete)===!0,Lt=(e,t)=>{const r=e==="macro"?t.macroAllowedDates:t.microAllowedDates;return r!==void 0?{list:r,path:e==="macro"?"macroAllowedDates":"microAllowedDates",inheritedBy:null}:{list:t.allowedDates,path:"allowedDates",inheritedBy:e}},Mo=(e,t,r,n)=>e==="pan"?Pu(t,r,Math.max(r,n)):vo(t,r,Math.max(r,n)),mi=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},Pl=(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 Ll(e,t,r,n,o,a,i="macro-top",l=.05,u=!0,d="range"){if(mi(t,i)==="macro"){const L=Math.abs(e-r),g=Math.abs(e-n);return L<=l&&L<=g?"macro-low":g<=l&&g<L?"macro-high":u&&e>=r&&e<=n?"macro-connect":L<g?"macro-low":"macro-high"}if(d==="point")return"micro-point";const m=Math.abs(e-o),M=Math.abs(e-a);return m<=l&&m<=M?"micro-low":M<=l&&M<m?"micro-high":u&&e>=o&&e<=a?"micro-connect":m<M?"micro-low":"micro-high"}function $l(e,t,r,n,o){if(e==="macro-connect"){const[d,m]=ii(t-r,n,o);return[d,m,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,l]=Lo(a,t,n,o),u=Ho(a,t,n,o);return[i,l,u==="low"?"macro-low":"macro-high"]}function Tl(e,t,r,n,o){if(e==="micro-point"){const[d]=Lo("point",t,n,o);return[d,d,"micro-point"]}if(e==="micro-connect"){const[d,m]=ii(t-r,n,o);return[d,m,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,l]=Lo(a,t,n,o),u=Ho(a,t,n,o);return[i,l,u==="low"?"micro-low":"micro-high"]}const yn=s.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",a=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",a=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return T.jsx("svg",{className:a,width:r?"8":"16",height:r?"16":"8",viewBox:r?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:T.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});yn.displayName="VernierKnobSvg";const ju=(e,t,r,n)=>{if(!ye(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${E(e)})`);if(!ye(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${E(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${E(e)}, maxDate: ${E(t)})`);for(const o of r)Ke("PeriodSlider","minDate",e,o,n,pl)},To=(e,t,r,n="PeriodSlider")=>{if(!Nt(t)||t.length!==2){const i=r?"is required and must":"must";throw new RangeError(`${n}: ${e} ${i} be a [start, end] Date tuple (received: ${E(t)})`)}const[o,a]=t;if(!ye(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${E(o)})`);if(!ye(a))throw new RangeError(`${n}: ${e}[1] must be a valid Date (received: ${E(a)})`);if(a.getTime()<o.getTime())throw new RangeError(`${n}: ${e} must not be inverted (start: ${E(o)}, end: ${E(a)})`)},Cl=(e,t)=>{if(!ye(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${E(t)})`)},Zr=(e,t,r,n,o,a)=>{const i=Ke("PeriodSlider",e,t,r,a,"");if(i<Y(r,n,a)||i>Y(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${E(t)}, minDate: ${E(n)}, maxDate: ${E(o)})`)},Fu=(e,t,r)=>{const n=e.yearStartMonth??0;if(e.mode==="range"){for(const o of["range","defaultRange"]){const a=e[o];a!==void 0&&(To(o,a,!1),Zr(`${o}[0]`,a[0],e.unit,t,r,n),Zr(`${o}[1]`,a[1],e.unit,t,r,n))}return}if(e.mode==="point")for(const o of["value","defaultValue"]){const a=e[o];a!==void 0&&(Cl(o,a),Zr(o,a,e.unit,t,r,n))}},Uu=(e,t,r)=>{const n=e.yearStartMonth??0;To("macroRange",e.macroRange,!0),Ke("PeriodSlider","macroRange[0]",e.macroRange[0],Jt("PeriodSlider","macroUnit",e.macroUnit,e.unit),n,"");const o=Jt("PeriodSlider","microUnit",e.microUnit,e.unit),a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,i=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&i)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(i){for(const d of["microValue","defaultMicroValue"]){const m=e[d];m!==void 0&&(Cl(d,m),Zr(d,m,o,t,r,n))}const u=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(u===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[u,u]}}for(const u of["microRange","defaultMicroRange"]){const d=e[u];d!==void 0&&(To(u,d,!1),Zr(`${u}[0]`,d[0],o,t,r,n),Zr(`${u}[1]`,d[1],o,t,r,n))}const l=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(l!==void 0)return{shape:"range",selection:l};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")},vn=(e,t,r,n,o,a,i,l,u)=>{const d=De(e,n,t,u),m=De(e,o,t,u);return i?d:l?m:Math.max(d,Math.min(m,De(e,r,t,u)+a))},ka=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null};function zu(e,t){return t&&e[0].getTime()!==e[1].getTime()?[e[0],e[0]]:e}function Bu(e,t){return t?e==="micro-low"||e==="micro-high"||e==="micro-connect"?"micro-point":e:e==="micro-point"?"micro-high":e}const $s=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback((a,i)=>{const l=r.current;if(l!==null&&l[0].getTime()===a.getTime()&&l[1].getTime()===i.getTime())return;const u=[a,i];r.current=u,t(u)},[]),o=s.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Xo=(e,t,r)=>{try{Intl.DateTimeFormat.supportedLocalesOf([r])}catch{throw new RangeError(`${e}: ${t} must be a valid BCP 47 language tag (received: ${E(r)})`)}},Wu=e=>{if(typeof e!="object"||e===null)return!1;try{return e.nodeType===1&&typeof e.getBoundingClientRect=="function"}catch{return!1}},Ts=(e,t)=>{if(t==null)return null;if(Wu(t))return t;let r=!1;try{r=typeof t=="object"&&"current"in t}catch{r=!1}throw new RangeError(`PeriodSlider: ${e} must be an Element or null (received: ${E(t)})${r?"; pass the element itself (ref.current), not the ref object":""}`)},qr=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const l of i){const u=l.borderBoxSize?.[0];u!==void 0&&t(d=>d!==null&&Math.abs(d.widthPx-u.inlineSize)<.5&&Math.abs(d.heightPx-u.blockSize)<.5?d:{widthPx:u.inlineSize,heightPx:u.blockSize})}});a.observe(o),r.current=a},[]);return s.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},Cs=(e,t)=>{const r=e.querySelector(`[data-handle-type^="${t}-"]`);if(r===null)return null;const n=r.querySelector("[data-tooltip-style]"),o=r.getAttribute("data-vernier-pos");return n===null||o!=="top"&&o!=="bottom"?null:au(e,r,n,o)},Gu=(e,t,r)=>{const n=ou(e,t,r);return n===null?null:{room:n,macro:Cs(e,"macro"),micro:Cs(e,"micro")}},Ku=.5,Co=(e,t)=>e===t||Math.abs(e-t)<Ku,Is=(e,t)=>e===null||t===null?e===t:Co(e.anchorPx,t.anchorPx)&&Co(e.knobCentrePx,t.knobCentrePx),qu=(e,t)=>e===null||t===null?e===t:Co(e.room.topPx,t.room.topPx)&&Co(e.room.bottomPx,t.room.bottomPx)&&Is(e.macro,t.macro)&&Is(e.micro,t.micro),Xu=(e,t)=>Do(yo(e,t)),Do=e=>e===null?void 0:{estimatedWidthPx:e.widthPx,estimatedHeightPx:e.heightPx},yo=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},Zu=e=>{const t=new Map;let r=0;for(const a of e){const{side:i,box:l}=a;if(l===null)continue;let u;if(a.reach==="inline-size")u=l.widthPx,r=Math.max(r,l.heightPx/2);else{const m=Ko(l.widthPx,l.heightPx,a.angleDeg);u=a.centreFromAnchorPx+m.acrossPx,r=Math.max(r,m.alongPx+Math.abs(a.alongPushPx))}const d=t.get(i);t.set(i,d===void 0?u:Math.max(d,u))}if(t.size===0)return;const n={};for(const[a,i]of t)n[`--ps-label-reach-${a}`]=`${Math.ceil(i)}px`;const o=Math.ceil(r);return n["--ps-label-reach-main"]=`${o}px`,{style:n,mainPx:o}},Wa=(e,t,r)=>({"leader-length":`${r?Math.hypot(e,t):0}px`,"leader-angle":`${Math.atan2(t,e)*180/Math.PI}deg`}),As=(e,t,r,n)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`,...n}),ks=(e,t,r,n)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`,...Wa(e,t,n)}),Io=(e,t)=>({"--ps-tooltip-tx":Pn(e,"tx",t.tx),"--ps-tooltip-ty":Pn(e,"ty",t.ty),"--ps-tooltip-rot":Pn(e,"rot",t.rot)}),Ao=(e,t)=>({"--ps-label-leader-length":Pn(e,"leader-length",t["leader-length"]),"--ps-label-leader-angle":Pn(e,"leader-angle",t["leader-angle"])}),Na=(e,t,r,n)=>{const o=Qu(n),a=o===null?n.config:o.config,i=di(n.labelPosition,a);if(!n.isSlantable)return{slant:i,lowStyle:void 0,highStyle:void 0,lowLeaderStyle:void 0,highLeaderStyle:void 0,centreFromAnchorPx:Math.abs(i.lowOffsetY)-$o(a),placements:null};const l=qo(t*100,r*100,n.trackLengthPx,n.labelPosition,a),u=n.isMerged?El(l):l,d=Yo[e],m=o!==null&&u.isFlipped?o.oppositeAnchorPx:$o(a),M=n.anchor===null?0:(n.labelPosition==="top"?-1:1)*n.anchor.knobCentrePx,L={low:As(u.lowOffsetX,u.lowOffsetY-i.lowOffsetY,u.lowAngleDeg,Wa(u.lowOffsetX,u.lowOffsetY-M,u.isFlipped)),high:As(u.highOffsetX,u.highOffsetY-i.highOffsetY,u.highAngleDeg,Wa(u.highOffsetX,u.highOffsetY-M,u.isFlipped))};return{slant:u,lowStyle:Io(d.low,L.low),highStyle:Io(d.high,L.high),lowLeaderStyle:Ao(d.low,L.low),highLeaderStyle:Ao(d.high,L.high),centreFromAnchorPx:Math.abs(u.lowOffsetY)-m,placements:L}},Qu=e=>e.config===void 0||e.anchor===null||e.opposite===null||e.room===void 0?null:{config:{...e.config,anchorGapY:e.anchor.anchorPx-Ml,flipClearancePx:e.opposite.anchorPx+e.opposite.reachPx+Dl,room:e.room,drawnScale:ui},oppositeAnchorPx:e.opposite.anchorPx},Ns=(e,t,r,n)=>{if(r.anchor===null||n===null)return null;const o=r.isSlantable?qo(e*100,t*100,r.trackLengthPx,r.labelPosition,r.config).lowAngleDeg:0;return{anchorPx:r.anchor.anchorPx,reachPx:(1+ui)*Ko(n.widthPx,n.heightPx,o).acrossPx}},Vs={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Os=(e,t,r)=>{const n=di(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Vs,highStyle:Vs,lowLeaderStyle:void 0,highLeaderStyle:void 0,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const u=r.config===void 0||r.room===void 0?r.config:{...r.config,room:r.room,drawnScale:ui},d=qo(e,t,r.trackLengthPx,r.labelPosition,u);a=r.isMerged?El(d):d}const i=Yo.flat,l={low:ks(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg,a.isFlipped),high:ks(a.highOffsetX,a.highOffsetY,a.highAngleDeg,a.isFlipped)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...Io(i.low,l.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...Io(i.high,l.high)},lowLeaderStyle:o?Ao(i.low,l.low):void 0,highLeaderStyle:o?Ao(i.high,l.high):void 0,placements:o?l:null}},Ju={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},ed={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"}},_s={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},td={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${$n} ${Ds.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${_s.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${$n} ${Ds.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${_s.vertical}`}},Ys={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"}},Hs=(e,t)=>{e.setPointerCapture(t)},rd=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:l="",showStepper:u=!0,tooltipStyle:d="always",labelPosition:m="top",autoSlantLabels:M=!0,showLabelLeaderLines:L=!1,isVertical:g=!1,hideConnectBar:O=!1,showTicks:p=!1,colorScheme:w="blue-rose",formatLocale:h}=e;Ce("PeriodSlider","unit",t);const S=e.mode==="vernier"?Jt("PeriodSlider","macroUnit",e.macroUnit,t):t,v=e.mode==="vernier"?Jt("PeriodSlider","microUnit",e.microUnit,t):t,f=hr("PeriodSlider",e.yearStartMonth);ju(r,n,e.mode==="vernier"?[S,v,t]:[t],f),Fu(e,r,n),h!==void 0&&Xo("PeriodSlider","formatLocale",h);const te=Ts("labelCeiling",e.labelCeiling),ce=Ts("labelFloor",e.labelFloor),B=e.mode==="vernier"?Uu(e,r,n):null,U=B!==null&&B.shape==="point",oe=Uo(e.locale,e.labels),z=fl[w],ne=s.useId(),C=s.useRef(e),K=r.getTime(),_=n.getTime(),y=e.mode==="vernier",$=s.useMemo(()=>y?[]:mr("PeriodSlider",Go(o),t,r,n,f).dates,[y,o,t,K,_,f]),W=$.length>0,{rangeMin:N,rangeMax:V}=s.useMemo(()=>W?{rangeMin:0,rangeMax:$.length-1}:{rangeMin:Y(t,r,f),rangeMax:Y(t,n,f)},[W,$,t,K,_,f]),H=e.mode==="point",Z=s.useCallback(c=>{if(W){const b=Math.max(0,Math.min($.length-1,Math.round(c)));return $[b]}return re(t,Math.round(c),f)},[W,$,t,f]),be=s.useCallback(c=>{if(c===void 0)return N;const b=Rt(t,c,f);return W?De($,b,t,f):Y(t,b,f)},[W,$,t,N,f]),[Q,se]=s.useState(()=>B===null?null:B.selection),ve=Q??(B===null?null:B.selection),ee=ve===null?null:zu(ve,U);s.useLayoutEffect(()=>{ee!==ve&&se(c=>c===Q?ee:c)});const ae=e.mode==="vernier"?e.microValue?.getTime():void 0,ge=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,ae]),Ne=$s(),ft=$s(),me=e.mode!=="vernier"?null:U?ge??ee:e.microRange!==void 0?e.microRange:ee,A=me===null?null:ft.shown??me,X=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?A?.[0]:void 0,ue=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?A?.[1]:void 0,Ye=e.mode==="point"?e.value??e.defaultValue:void 0,Se=e.mode==="point"?Ye?.getTime():X?.getTime(),it=e.mode==="range"?ue?.getTime():Se,[Ue,ze]=s.useMemo(()=>{if(e.mode==="point"){const x=be(Ye);return[x,x]}const c=be(X),b=be(ue);return[Math.min(c,b),Math.max(c,b)]},[e.mode,Se,it,be,Ye,X,ue]),Ge=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:U?e.microValue!==void 0:e.microRange!==void 0,[ie,tt]=s.useState(()=>y?null:[Ue,ze]),st=ie??[Ue,ze],[qe,_e]=s.useState(null),[Ee,rt]=s.useState(null),lt=s.useRef(null),[pt,bt]=s.useState("high"),[I,J]=s.useState(null),[He,ht]=s.useState(null),pe=qe?qe[0]:Ge?Ue:st[0],Me=qe?qe[1]:Ge?ze:st[1],gr=s.useRef([pe,Me]),Bt=e.mode==="vernier"?e.vernierOrientation??(g?"macro-left":"macro-top"):"macro-top",R=Bt==="macro-top"||Bt==="macro-left",le=e.mode==="vernier"?e.showVernierProjection??!0:!1,Re=e.mode==="vernier"?e.showVernierTicks??!0:!1,$e=e.mode==="vernier"?e.showHairline??!0:!1,P=y?jt("macro",e):W,j=y?jt("micro",e):W,fe=y?Lt("macro",e).list:o,Ve=y?Lt("micro",e).list:o,Pe=y?e.formatMacroLabel??e.formatLabel:e.formatLabel,Oe=y?e.formatMicroLabel??e.formatLabel:e.formatLabel,Xe=X?.getTime(),Tt=ue?.getTime(),[je,pr]=s.useState(null),Ct=s.useRef(null),[ta,Ir]=s.useState(()=>U?"micro-point":"micro-high"),Ze=Bu(ta,U);s.useLayoutEffect(()=>{Ze!==ta&&Ir(c=>c===ta?Ze:c)});const wt=s.useMemo(()=>Y(S,r,f),[K,S,f]),Ot=s.useMemo(()=>Y(S,n,f),[_,S,f]),zn=s.useMemo(()=>y&&j?ci("PeriodSlider",Lt("micro",e),v,r,n,f):null,[y,j,Ve,v,K,_,f]),Ie=s.useMemo(()=>y&&P?mr("PeriodSlider",Lt("macro",e),S,r,n,f).dates:[],[y,P,fe,S,K,_,f]),wi=c=>[Math.max(wt,Math.min(Ot,Y(S,c[0],f))),Math.max(wt,Math.min(Ot,Y(S,c[1],f)))],[vi,Si]=e.mode!=="vernier"?[wt,Ot]:wi(e.macroRange),[Qe,ct]=Ne.shown===null?[vi,Si]:wi(Ne.shown),br=s.useMemo(()=>re(S,Qe,f),[S,Qe,f]),wr=s.useMemo(()=>re(S,ct,f),[S,ct,f]),Bn=s.useMemo(()=>e.mode!=="vernier"?[r,n]:$t(S,v,[br,wr],r,n,f),[e.mode,br,wr,S,v,K,_,f]),Fe=s.useMemo(()=>Y(v,Bn[0],f),[v,Bn,f]),nt=s.useMemo(()=>Y(v,Bn[1],f),[v,Bn,f]),ra=(c,b)=>zn===null?[]:kn(zn,sn(zn.ascending,c,b)),we=s.useMemo(()=>ra(Fe,nt),[zn,Fe,nt]),er=P&&Ie.length>0,It=j&&we.length>0,xi=er?Y(S,Ie[0],f):wt,Ri=er?Y(S,Ie[Ie.length-1],f):Ot,Mi=It?Y(v,we[0],f):Fe,na=It?Y(v,we[we.length-1],f):nt,Kl=Math.min(xi,Qe),ql=Math.max(Ri,ct),tr=(c,b,x,D)=>b.length>0?Y(v,b[De(b,c,v,f)],f):Math.max(x,Math.min(D,Y(v,c,f))),Ar=It?we:[],Be=s.useMemo(()=>A===null?Fe:tr(A[0],Ar,Fe,nt),[Xe,Fe,nt,v,A,Ar]),ot=s.useMemo(()=>A===null?nt:tr(A[1],Ar,Fe,nt),[Tt,Fe,nt,v,A,Ar]),kr=s.useMemo(()=>re(v,Be,f),[v,Be,f]),Nr=s.useMemo(()=>re(v,ot,f),[v,ot,f]),Di=!y||me===null?null:{macroUnit:S,macroLowEnc:vi,macroHighEnc:Si,microUnit:v,microLowEnc:Y(v,me[0],f),microHighEnc:Y(v,me[1],f)},oa=s.useRef(Di),aa=Math.max(1,Ot-wt),Mt=er?uo(Ie,S,a,br,f):Math.max(0,Math.min(1,(Qe-wt)/aa)),At=Math.max(Mt,er?uo(Ie,S,a,wr,f):Math.min(1,(ct-wt)/aa)),yi=c=>Math.max(xi,Math.min(Ri,Math.round(wt+c*aa))),Wn=Math.max(1,nt-Fe),vr=It?uo(we,v,a,kr,f):Math.max(0,Math.min(1,(Be-Fe)/Wn)),Vr=Math.max(vr,It?uo(we,v,a,Nr,f):Math.min(1,(ot-Fe)/Wn)),ia=s.useRef({timerId:null,emit:null}),Gn=s.useRef({timerId:null,emit:null}),Kn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const c=[ia,Gn,Kn];return()=>{for(const b of c)ka(b.current)}},[]);const Or=s.useCallback((c,b,x)=>{ka(c);const{debounceMs:D}=C.current;if(x||!D||D<=0){b();return}c.emit=b,c.timerId=setTimeout(()=>{c.timerId=null,c.emit=null,b()},D)},[]),Ei=s.useCallback(c=>{const b=c.emit;ka(c),b?.()},[]),_r=s.useCallback(c=>new Date(Math.min(Math.max(c.getTime(),K),_)),[K,_]),rr=s.useCallback((c,b,x=!1)=>{const[D,k]=gr.current;if((C.current.mode==="point"?c===D:c===D&&b===k)&&ia.current.timerId===null)return;const G=Z(c),q=Z(b),he=()=>{const xe=C.current;xe.mode==="point"?xe.onChangePoint?.(G):xe.mode==="range"&&xe.onChangeRange?.(G,q)};Or(ia.current,he,x)},[Z,Or]),Sr=s.useCallback((c,b,x=!1)=>{const D=oa.current;if(C.current.mode!=="vernier"||D===null)return;const k=_r(c),F=_r(b);Y(D.macroUnit,k,f)===D.macroLowEnc&&Y(D.macroUnit,F,f)===D.macroHighEnc&&Gn.current.timerId===null||Or(Gn.current,()=>{const G=C.current;G.mode==="vernier"&&G.onChangeMacroRange?.(k,F)},x)},[_r,Or,f]),Dt=s.useCallback((c,b,x=!1)=>{const D=C.current,k=oa.current;if(D.mode!=="vernier"||k===null)return;const F=_r(c),G=_r(b);Y(k.microUnit,F,f)===k.microLowEnc&&Y(k.microUnit,G,f)===k.microHighEnc&&Kn.current.timerId===null||((U?D.microValue===void 0:D.microRange===void 0)&&se([F,G]),Or(Kn.current,()=>{const q=C.current;if(q.mode==="vernier"){if(U){q.onChangeMicroPoint?.(F);return}q.onChangeMicroRange?.(F,G)}},x))},[_r,Or,U,f]),Pi=s.useCallback((c,b=!1)=>{Dt(c,c,b)},[Dt]),xr=s.useCallback(c=>{if(W&&a==="time"&&$.length>1){const D=Math.max(0,Math.min($.length-1,Math.round(c))),k=$[0].getTime(),G=$[$.length-1].getTime()-k;if(G<=0)return 0;const q=$[D].getTime();return Math.max(0,Math.min(100,(q-k)/G*100))}const b=V-N;if(b<=0)return 0;const x=(c-N)/b*100;return Math.max(0,Math.min(100,x))},[W,a,$,N,V]),sa=s.useCallback(c=>{const b=Math.max(0,Math.min(100,c));if(W){if(a==="time"&&$.length>1){const k=$[0].getTime(),G=$[$.length-1].getTime()-k,q=k+b/100*G;return De($,new Date(q),t,f)}const D=Math.round(b/100*($.length-1));return Math.max(0,Math.min($.length-1,D))}const x=N+b/100*(V-N);return Math.round(x)},[W,a,$,N,V,t,f]),ln=s.useRef(null),Li=s.useRef(null),$i=s.useRef(0),ut=s.useRef(null),la=s.useRef(null),Ti=s.useRef(null),Ci=s.useRef(null),[ca,Ii]=s.useState(0),[Xl,qn]=qr(),[Zl,Ai]=qr(),[Ql,Jl]=qr(),[ec,tc]=qr(),[rc,ki]=qr(),[nc,oc]=qr(),[ac,ic]=s.useState(null),ua=!g&&d!=="hover",Yr=ua?ac:null,sc=H?Do(qn):Xu(qn,Ai),da=!H&&pe===Me,ma=Qe===ct,fa=!U&&Be===ot,lc=R?"top":"bottom",cc=R?"bottom":"top",Ni=M&&!g,uc=Ni&&!U,ha=Yr===null?void 0:Yr.room,ga={isPointMode:H,isVertical:g,autoSlantLabels:M,isMerged:da,trackLengthPx:ca,labelPosition:m,config:sc,room:ha},pa=yo(Jl,tc),ba=U?ki:yo(ki,oc),Vi={trackLengthPx:ca,labelPosition:lc,config:Do(pa),isMerged:ma,isSlantable:Ni,room:ha,anchor:Yr===null?null:Yr.macro},Oi={trackLengthPx:ca,labelPosition:cc,config:Do(ba),isMerged:fa,isSlantable:uc,room:ha,anchor:Yr===null?null:Yr.micro},wa={...Vi,opposite:Ns(vr,Vr,Oi,ba)},va={...Oi,opposite:Ns(Mt,At,Vi,pa)};s.useEffect(()=>{const c=ut.current;if(!c)return;const b=()=>{const D=c.getBoundingClientRect(),k=g?D.height:D.width;k>0&&Ii(F=>Math.abs(F-k)<.5?F:k)};if(b(),typeof ResizeObserver<"u"){const D=new ResizeObserver(k=>{for(const F of k){const G=g?F.contentRect.height:F.contentRect.width;G>0&&Ii(q=>Math.abs(q-G)<.5?q:G)}});return D.observe(c),()=>D.disconnect()}const x=c.ownerDocument.defaultView;if(x)return x.addEventListener("resize",b),()=>x.removeEventListener("resize",b)},[g]);const Hr=s.useCallback((c,b,x)=>{const D=g?x.height:x.width;if(!(Number.isFinite(D)&&D>0))return null;const k=g?x.bottom-b:c-x.left;return Number.isFinite(k)?Math.max(0,Math.min(1,k/D)):null},[g]),_i=s.useCallback((c,b)=>{const x=ut.current;if(!x)return null;const D=Hr(c,b,x.getBoundingClientRect());return D===null?null:D*100},[Hr]),cn=s.useRef(null),Wt=s.useRef(null),Xn=s.useRef({macroLowRatio:Mt,macroHighRatio:At,isVertical:g,isMacroFirstRail:R}),Yi=s.useRef({flat:ga,macro:wa,micro:va}),Hi=s.useRef({ceiling:te,floor:ce,isMeasured:ua});s.useLayoutEffect(()=>{Xn.current={macroLowRatio:Mt,macroHighRatio:At,isVertical:g,isMacroFirstRail:R},Yi.current={flat:ga,macro:wa,micro:va},Hi.current={ceiling:te,floor:ce,isMeasured:ua},C.current=e,gr.current=[pe,Me],oa.current=Di,lt.current=Ee,Ct.current=je});const ji=(c,b)=>{const x=Xn.current;la.current?.setAttribute("d",Ta(c,b,x.isVertical,x.isMacroFirstRail))},dc=(c,b,x)=>{const D=Yi.current;return c==="flat"?Os(b*100,x*100,D.flat).placements:Na(c,b,x,c==="macro"?D.macro:D.micro).placements},un=s.useCallback(()=>{const c=ut.current,b=Hi.current;if(c===null||!b.isMeasured)return;const x=Gu(c,b.ceiling,b.floor);ic(D=>qu(D,x)?D:x)},[]),dn=(c,b,x)=>{const D=ut.current;if(!D)return;cn.current={rail:c,lowRatio:b,highRatio:x},Gc(D,c,b,x);const k=dc(c,b,x);k!==null&&Wc(D,c,k),c==="macro"&&ji(b,x)},Rr=s.useCallback(()=>{Wt.current!==null&&(clearTimeout(Wt.current),Wt.current=null);const c=ut.current;c&&(c.removeAttribute(La),c.style.removeProperty($a))},[]),Fi=()=>{const c=ut.current;if(cn.current===null||!c){cn.current=null;return}cn.current=null,Wt.current!==null&&clearTimeout(Wt.current),c.style.setProperty($a,`${ws}ms`),c.setAttribute(La,"true"),Kc(c),ji(Xn.current.macroLowRatio,Xn.current.macroHighRatio),Wt.current=setTimeout(()=>{Wt.current=null,c.removeAttribute(La),c.style.removeProperty($a)},ws)};s.useLayoutEffect(()=>{const c=cn.current;c!==null&&dn(c.rail,c.lowRatio,c.highRatio)}),s.useEffect(()=>()=>{Wt.current!==null&&clearTimeout(Wt.current)},[]);const jr=s.useRef(null),Fr=s.useRef(null),_t=s.useRef(null),Sa=s.useRef(null),mn=s.useRef(null),nr=s.useCallback(()=>jr.current!==null||Fr.current!==null,[]),Ui=c=>{if(i)return;if(y){const de=Fr.current;if(!de||c.pointerId!==de.pointerId||!ut.current)return;const kt=Hr(c.clientX,c.clientY,ut.current.getBoundingClientRect());if(kt===null)return;if(de.handle==="macro-low"||de.handle==="macro-high"||de.handle==="macro-connect"){const[Je,We,Gt]=$l(de.handle,kt,de.startPointerRatio,de.startMacroLowRatio,de.startMacroHighRatio);dn("macro",Je,We),Gt!==Ct.current&&(Ct.current=Gt,pr(Gt),Ir(Gt));let Ht,xt,Kt;if(er){const qt=mo(Ie,S,a,Je,f),bn=Math.max(qt,mo(Ie,S,a,We,f));xt=Ie[qt],Kt=Ie[bn],Ht=Y(S,xt,f)}else Ht=yi(Je),xt=re(S,Ht,f),Kt=re(S,yi(We),f);Ne.show(xt,Kt);const ar=`${xt.getTime()}_${Kt.getTime()}`;ar!==Sa.current&&(Sa.current=ar,Sr(xt,Kt));const[pn,_c]=$t(S,v,[xt,Kt],r,n,f),ao=Y(v,pn,f),io=Y(v,_c,f),hs=j?ra(ao,io):[],gs={kind:"range",min:ao,max:io};let Dr,yr;if(de.handle==="macro-connect"){const qt=Ht-de.startMacroLowEnc,bn=Mo("pan",gs,Es(v,de.initialMicroLowEnc,S,qt,f),Es(v,de.initialMicroHighEnc,S,qt,f));if(bn===null)return;Dr=re(v,bn[0],f),yr=re(v,bn[1],f)}else{const qt=Mo("resize",gs,de.initialMicroLowEnc,de.initialMicroHighEnc);if(qt===null)return;Dr=re(v,qt[0],f),yr=re(v,qt[1],f)}const ps=tr(Dr,hs,ao,io),Yc=Math.max(ps,tr(yr,hs,ao,io));Dr=re(v,ps,f),yr=re(v,Yc,f),ft.show(Dr,yr);const bs=`${Dr.getTime()}_${yr.getTime()}`;bs!==mn.current&&(mn.current=bs,Dt(Dr,yr))}else if(de.handle==="micro-low"||de.handle==="micro-high"||de.handle==="micro-connect"||de.handle==="micro-point"){const[Je,We,Gt]=Tl(de.handle,kt,de.startPointerRatio,de.startMicroLowRatio,de.startMicroHighRatio);dn("micro",Je,We),Gt!==Ct.current&&(Ct.current=Gt,pr(Gt),Ir(Gt));let Ht,xt;if(It){const ar=mo(we,v,a,Je,f),pn=Math.max(ar,mo(we,v,a,We,f));Ht=we[ar],xt=we[pn]}else{const ar=tr(re(v,Math.round(Fe+Je*Wn),f),Ar,Fe,nt),pn=Math.max(ar,tr(re(v,Math.round(Fe+We*Wn),f),Ar,Fe,nt));Ht=re(v,ar,f),xt=re(v,pn,f)}ft.show(Ht,xt);const Kt=`${Ht.getTime()}_${xt.getTime()}`;Kt!==mn.current&&(mn.current=Kt,Dt(Ht,xt))}return}const b=jr.current;if(!b||c.pointerId!==b.pointerId||!ut.current)return;const x=ut.current.getBoundingClientRect(),D=g?c.clientY:c.clientX,k=g?x.height:x.width;if(!(Number.isFinite(k)&&k>0))return;if(b.handle==="connect"){const de=g?(b.startPointerPos-D)/k:(D-b.startPointerPos)/k,[kt,Je]=ii(de,b.startLowRatio,b.startHighRatio);dn("flat",kt,Je);const We=xl({posDiffPct:de,startLowVal:b.startLowVal,startHighVal:b.startHighVal,rangeMin:N,rangeMax:V,isDiscrete:W,sortedAllowedDates:$,snapMode:a,unit:t,yearStartMonth:f});if(_t.current&&_t.current[0]===We[0]&&_t.current[1]===We[1])return;_t.current=We,_e(We),rr(We[0],We[1],!1);return}const F=Hr(c.clientX,c.clientY,x);if(F===null)return;const[G,q]=Lo(H?"point":b.handle,F,b.startLowRatio,b.startHighRatio);dn("flat",G,q);const he=sa(F*100),[xe,Ae]=Ba(b.handle,he,b.startLowVal,b.startHighVal,N,V,H);if((!_t.current||_t.current[0]!==xe||_t.current[1]!==Ae)&&(_t.current=[xe,Ae],_e([xe,Ae]),rr(xe,Ae,!1)),!H&&(b.handle==="low"||b.handle==="high")){const de=Ho(b.handle,F,b.startLowRatio,b.startHighRatio);lt.current!==de&&(lt.current=de,rt(de),bt(de))}},zi=()=>{Fi(),Sa.current=null,mn.current=null,Fr.current=null,Ct.current=null,pr(null),Ne.release(),ft.release(),Ei(Gn.current),Ei(Kn.current)},Bi=()=>{Fi();const c=_t.current??qe;c&&(rr(c[0],c[1],!0),tt(c)),_t.current=null,_e(null),jr.current=null,lt.current=null,rt(null)},Wi=c=>{if(y){const x=Fr.current;if(!x||c.pointerId!==x.pointerId)return;zi();return}const b=jr.current;!b||c.pointerId!==b.pointerId||Bi()},Gi=()=>{Fr.current!==null&&zi(),jr.current!==null&&Bi()},xa=s.useRef(Ui),Ki=s.useRef(Wi),qi=s.useRef(Gi);s.useLayoutEffect(()=>{xa.current=Ui,Ki.current=Wi,qi.current=Gi});const Xi=s.useRef(y);s.useEffect(()=>{Xi.current!==y&&(Xi.current=y,qi.current())},[y]);const Ra=Ee!==null||je!==null;s.useEffect(()=>{if(!Ra)return;const c=ln.current?.ownerDocument.defaultView;if(!c)return;const b=D=>xa.current(D),x=D=>Ki.current(D);return c.addEventListener("pointermove",b),c.addEventListener("pointerup",x),c.addEventListener("pointercancel",x),c.addEventListener("lostpointercapture",x),()=>{c.removeEventListener("pointermove",b),c.removeEventListener("pointerup",x),c.removeEventListener("pointercancel",x),c.removeEventListener("lostpointercapture",x)}},[Ra]);const Ma=s.useCallback((c,b,x,D)=>{Rr(),Hs(c,b),un(),jr.current={pointerId:b,handle:x,startPointerPos:D,startLowVal:pe,startHighVal:Me,startLowRatio:xr(pe)/100,startHighRatio:xr(Me)/100},lt.current=x,rt(x),x!=="connect"&&bt(x)},[pe,Me,xr]),Zi=s.useCallback((c,b,x,D)=>{C.current.mode==="vernier"&&(Rr(),Hs(c,b),un(),Fr.current={pointerId:b,handle:x,startPointerRatio:D,startMacroLowRatio:Mt,startMacroHighRatio:At,startMicroLowRatio:vr,startMicroHighRatio:Vr,startMacroLowEnc:Qe,initialMicroLowEnc:Be,initialMicroHighEnc:ot},Ct.current=x,pr(x),Ir(x))},[Mt,At,vr,Vr,Qe,Be,ot]),Qi=c=>b=>{if(i||nr())return;b.stopPropagation(),b.preventDefault(),bt(c);const x=g?b.clientY:b.clientX;Ma(b.currentTarget,b.pointerId,c,x)},Ji=c=>()=>{i||lt.current!==null||bt(c)},Zn=c=>()=>{i||Ct.current!==null||Ir(c)},Ur=c=>b=>{if(i||nr())return;b.stopPropagation(),b.preventDefault();const x=ut.current;if(!x)return;const D=Hr(b.clientX,b.clientY,x.getBoundingClientRect());D!==null&&Zi(b.currentTarget,b.pointerId,c,D)},mc=c=>{if(i||O||nr())return;c.stopPropagation(),c.preventDefault();const b=g?c.clientY:c.clientX;Ma(c.currentTarget,c.pointerId,"connect",b)},fc=c=>{if(i||nr())return;if(y){const q=ut.current;if(!q)return;const he=q.getBoundingClientRect(),xe=Hr(c.clientX,c.clientY,he);if(xe===null)return;const Ae=g?c.clientX-(he.left+he.width/2):c.clientY-(he.top+he.height/2),de=Ll(xe,Ae,Mt,At,vr,Vr,Bt,void 0,!O,U?"point":"range");Zi(c.currentTarget,c.pointerId,de,xe),xa.current(c.nativeEvent);return}const b=_i(c.clientX,c.clientY);if(b===null)return;const x=sa(b);let D="low";if(!H){const q=Math.abs(x-pe),he=Math.abs(x-Me);q<he?D="low":he<q?D="high":D=x>Me?"high":"low"}bt(D);const[k,F]=Ba(D,x,pe,Me,N,V,H);_e([k,F]),rr(k,F,!0);const G=g?c.clientY:c.clientX;Ma(c.currentTarget,c.pointerId,D,G)},hc=c=>{if(i||y||Ee!==null)return;const b=_i(c.clientX,c.clientY);if(b===null)return;const x=sa(b);J(x),ht(xr(x))},gc=()=>{J(null),ht(null)},es=c=>b=>{if(i||nr())return;bt(c);const x=Rl(b.key,c,pe,Me,N,V,H,1);x&&(b.preventDefault(),Rr(),Ge||tt(x),rr(x[0],x[1],!0))},zr=(c,b,x)=>{if(me===null)return;const[D,k]=$t(S,v,[c,b],r,n,f),F=Y(v,D,f),G=Y(v,k,f),q=j?ra(F,G):[],he=Mo(x,{kind:"range",min:F,max:G},Y(v,me[0],f),Y(v,me[1],f));if(he===null)return;const xe=tr(re(v,he[0],f),q,F,G),Ae=Math.max(xe,tr(re(v,he[1],f),q,F,G));Dt(re(v,xe,f),re(v,Ae,f),!0)},Qn=c=>b=>{if(i||!y||e.mode!=="vernier"||nr())return;Ir(c);let x=0,D=!1,k=!1;switch(b.key){case"ArrowRight":case"ArrowUp":x=1;break;case"ArrowLeft":case"ArrowDown":x=-1;break;case"PageUp":x=5;break;case"PageDown":x=-5;break;case"Home":D=!0;break;case"End":k=!0;break;default:return}if(b.preventDefault(),Rr(),c==="macro-low"){const F=re(S,Qe,f),G=re(S,ct,f);if(er){const xe=vn(Ie,S,F,Ie[0],G,x,D,k,f);if(xe===De(Ie,F,S,f))return;const Ae=Ie[xe];Sr(Ae,G,!0),zr(Ae,G,"resize");return}let q;if(D?q=wt:k?q=ct:q=Math.max(wt,Math.min(ct,Qe+x)),q===Qe)return;const he=re(S,q,f);Sr(he,G,!0),zr(he,G,"resize")}else if(c==="macro-high"){const F=re(S,Qe,f),G=re(S,ct,f);if(er){const xe=vn(Ie,S,G,F,Ie[Ie.length-1],x,D,k,f);if(xe===De(Ie,G,S,f))return;const Ae=Ie[xe];Sr(F,Ae,!0),zr(F,Ae,"resize");return}let q;if(D?q=Qe:k?q=Ot:q=Math.max(Qe,Math.min(Ot,ct+x)),q===ct)return;const he=re(S,q,f);Sr(F,he,!0),zr(F,he,"resize")}else if(c==="micro-low"){const F=re(v,Be,f),G=re(v,ot,f);if(It){const he=vn(we,v,F,we[0],G,x,D,k,f);if(he===De(we,F,v,f))return;Dt(we[he],G,!0);return}let q;if(D?q=Fe:k?q=ot:q=Math.max(Fe,Math.min(ot,Be+x)),q===Be)return;Dt(re(v,q,f),G,!0)}else if(c==="micro-high"){const F=re(v,Be,f),G=re(v,ot,f);if(It){const he=vn(we,v,G,F,we[we.length-1],x,D,k,f);if(he===De(we,G,v,f))return;Dt(F,we[he],!0);return}let q;if(D?q=Be:k?q=nt:q=Math.max(Be,Math.min(nt,ot+x)),q===ot)return;Dt(F,re(v,q,f),!0)}else if(c==="micro-point"){const F=re(v,Be,f);if(It){const q=vn(we,v,F,we[0],we[we.length-1],x,D,k,f);if(q===De(we,F,v,f))return;Pi(we[q],!0);return}let G;if(D?G=Fe:k?G=nt:G=Math.max(Fe,Math.min(nt,Be+x)),G===Be)return;Pi(re(v,G,f),!0)}},pc=c=>{if(e.mode!=="vernier")return;if(Rr(),er){const G=Ie.length-1,q=De(Ie,br,S,f),he=De(Ie,wr,S,f),xe=he-q;let Ae=q+c,de=he+c;if(c<0&&Ae<0?(Ae=0,de=Math.min(G,xe)):c>0&&de>G&&(de=G,Ae=Math.max(0,G-xe)),Ae===q&&de===he)return;const kt=Ie[Ae],Je=Ie[de];Sr(kt,Je,!0),zr(kt,Je,"pan");return}const b=ct-Qe;let x=Qe+c,D=ct+c;if(c<0&&x<wt?(x=wt,D=Math.min(Ot,x+b)):c>0&&D>Ot&&(D=Ot,x=Math.max(wt,D-b)),x===Qe&&D===ct)return;const k=re(S,x,f),F=re(S,D,f);Sr(k,F,!0),zr(k,F,"pan")},Da=s.useCallback(c=>{const b=C.current;if(!(b.disabled||nr()))if(Rr(),b.mode==="point"){const x=Math.max(N,Math.min(V,pe+c));Ge||tt([x,x]),rr(x,x,!0)}else if(b.mode==="vernier"){if(It){const xe=we.length-1,Ae=De(we,kr,v,f),de=De(we,Nr,v,f),kt=de-Ae;let Je=Ae+c,We=de+c;c<0&&Je<0?(Je=0,We=Math.min(xe,kt)):c>0&&We>xe&&(We=xe,Je=Math.max(0,xe-kt)),(Je!==Ae||We!==de)&&Dt(we[Je],we[We],!0);return}const x=Be,D=ot,k=Fe,F=nt,G=D-x;let q=x+c,he=D+c;c<0&&q<k?(q=k,he=Math.min(F,q+G)):c>0&&he>F&&(he=F,q=Math.max(k,he-G)),(q!==x||he!==D)&&Dt(re(v,q,f),re(v,he,f),!0)}else{const x=Me-pe;let D=pe+c,k=Me+c;c<0&&D<N?(D=N,k=Math.min(V,D+x)):c>0&&k>V&&(k=V,D=Math.max(N,k-x)),D<=k&&(Ge||tt([D,k]),rr(D,k,!0))}},[pe,Me,N,V,Ge,rr,Dt,Be,ot,Fe,nt,v,It,we,kr,Nr,Rr,f]),ts=c=>!i&&Ca(ln.current,c),rs=(c,b)=>{const x=Li.current,D=ut.current,k=ln.current;if(i||x===null||D===null||k===null||!pu(x,k,$i.current,g,c,b))return null;const F=D.getBoundingClientRect();return Math.abs(g?c-(F.left+F.width/2):b-(F.top+F.height/2))},ns=c=>{if(i||nr())return;const b=Pl(c.deltaX,c.deltaY,g);if(b===0)return;c.preventDefault();const x=c.target,D=Ca(Ti.current,x)||Ca(Ci.current,x);if(!y||D){Da(b);return}const k=ut.current;if(!k)return;const F=k.getBoundingClientRect(),G=g?c.clientX-(F.left+F.width/2):c.clientY-(F.top+F.height/2);if(mi(G,Bt)==="macro"){pc(b);return}Da(b)},Jn=s.useRef({ownsWheelHit:ts,distanceToRailPx:rs,stepFromRangeAreaWheel:ns});s.useLayoutEffect(()=>{Jn.current={ownsWheelHit:ts,distanceToRailPx:rs,stepFromRangeAreaWheel:ns}});const fn=s.useRef(null);s.useEffect(()=>{const c=ln.current?.ownerDocument.defaultView??null,b=fn.current;if(b!==null&&b.view===c)return;if(b?.unregister(),c===null){fn.current=null;return}const x=wu(c,{ownsHit:D=>Jn.current.ownsWheelHit(D),distanceToRailPx:(D,k)=>Jn.current.distanceToRailPx(D,k),step:D=>Jn.current.stepFromRangeAreaWheel(D)});fn.current={view:c,unregister:x}}),s.useEffect(()=>()=>{fn.current?.unregister(),fn.current=null},[]);const eo=xr(pe),to=xr(Me),ya=Z(pe),Ea=Z(Me),Br=Os(eo,to,ga),or=Br.slant,hn=Ee==="low"||Ee!=="high"&&pt==="low",gn=!H&&(Ee==="high"||Ee!=="low"&&pt==="high"),bc=ma&&Ze!=="macro-low",wc=ma&&Ze==="macro-low",vc=fa&&Ze!=="micro-low",Sc=fa&&Ze==="micro-low",vt=Na("macro",Mt,At,wa),St=Na("micro",vr,Vr,va),os=Br.slant.isSlanted||vt.slant.isSlanted||St.slant.isSlanted;s.useLayoutEffect(()=>{os&&un()});const as=os||Ra;s.useEffect(()=>{if(!as)return;const c=ut.current,b=c===null?null:c.ownerDocument.defaultView;if(c===null||b===null)return;const x=c.ownerDocument;let D=null;const k=()=>{D===null&&(D=b.requestAnimationFrame(()=>{D=null,un()}))};x.addEventListener("scroll",k,{capture:!0,passive:!0}),b.addEventListener("resize",k);const F=typeof ResizeObserver>"u"?null:new ResizeObserver(k);for(const G of[te,ce])G!==null&&F?.observe(G);return()=>{x.removeEventListener("scroll",k,{capture:!0}),b.removeEventListener("resize",k),F?.disconnect(),D!==null&&b.cancelAnimationFrame(D)}},[as,te,ce,un]);const xc=Math.min(eo,to),Rc=Math.max(eo,to),[is,ss]=En.flat,[Mc,Dc]=En.macro,[yc,Ec]=En.micro,ls=ir(is,eo),cs=ir(ss,to),Pa=ir(is,xc),us=`calc(${ir(ss,Rc)} - ${Pa})`,Wr=ir(Mc,Mt*100),ro=ir(Dc,At*100),Gr=ir(yc,vr*100),no=ir(Ec,Vr*100),Pc=g?{bottom:Pa,height:us,top:"auto",left:"0",right:"0"}:{left:Pa,width:us,top:"0",bottom:"0"},Lc=Math.max(.01,At-Mt),ds=Math.max(.06,Math.min(.25,.28*Math.sqrt(Lc))),$c=g?{bottom:ls,left:"50%",transform:"translate(-50%, 50%)",zIndex:hn?40:30}:{left:ls,top:"50%",transform:"translate(-50%, -50%)",zIndex:hn?40:30},Tc=g?{bottom:cs,left:"50%",transform:"translate(-50%, 50%)",zIndex:gn?40:30}:{left:cs,top:"50%",transform:"translate(-50%, -50%)",zIndex:gn?40:30},Cc=g?{bottom:`${He}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${He}%`,top:"50%",transform:"translate(-50%, -50%)"},ms=I!==null?Z(I):null,Ic=d!=="hover"&&I!==null&&(I===pe||!H&&I===Me),Ac=y?Be>Mi:pe>N,kc=y?ot<na:Me<V,Nc=R!==vt.slant.isFlipped?"before":"after",Vc=R===St.slant.isFlipped?"before":"after",oo=Zu(y?[{side:Nc,box:pa,...g?{reach:"inline-size"}:{reach:"rotated",angleDeg:vt.slant.lowAngleDeg,centreFromAnchorPx:vt.centreFromAnchorPx,alongPushPx:vt.slant.lowOffsetX}},{side:Vc,box:ba,...g?{reach:"inline-size"}:{reach:"rotated",angleDeg:St.slant.lowAngleDeg,centreFromAnchorPx:St.centreFromAnchorPx,alongPushPx:St.slant.lowOffsetX}}]:[{side:g||m==="top"!==or.isFlipped?"before":"after",box:H?qn:yo(qn,Ai),...g?{reach:"inline-size"}:{reach:"rotated",angleDeg:or.lowAngleDeg,centreFromAnchorPx:Math.abs(or.lowOffsetY),alongPushPx:or.lowOffsetX}}]),Oc=oo===void 0?e.style:{...e.style,...oo.style};s.useLayoutEffect(()=>{$i.current=oo===void 0?0:oo.mainPx});const Yt=U?"micro-point":"micro-low",Mr=i?"cursor-not-allowed opacity-50":"cursor-pointer",Kr=c=>d==="hover"||!L||c===void 0?null:T.jsx("span",{"data-label-leader":"true","aria-hidden":"true",className:"period-slider-label-leader",style:c}),fs=c=>{const b=g?"vertical":"horizontal",x=c==="decrease",D=g?!x:x;return T.jsx(Tr,{ref:x?Ti:Ci,neighbour:"rail",direction:Ju[b][c],glyph:"single",disabled:i,canStep:x?Ac:kc,onStep:()=>Da(x?-1:1),ariaLabel:x?oe.decrease:oe.increase,className:`period-slider-stepper-btn ${ed[b][c]} ${Ys[b][D?"leading":"trailing"]}`})};return T.jsxs("div",{ref:ln,style:Oc,className:`period-slider grid select-none place-items-center ${td[g?"vertical":"horizontal"][u?"withSteppers":"railOnly"]} ${l}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":g?"vertical":"horizontal","data-label-position":m,"data-color-scheme":w,children:[T.jsx("div",{ref:Li,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),u&&fs(g?"increase":"decrease"),T.jsx("div",{ref:ut,"data-testid":"period-slider-track","data-orientation":g?"vertical":"horizontal","data-vernier-orientation":y?Bt:void 0,className:`period-slider-track relative touch-none rounded-full ${Ys[g?"vertical":"horizontal"][u?"rail":"railOnly"]} ${Mr}`,onPointerDown:fc,onPointerMove:hc,onPointerLeave:gc,children:y?T.jsxs(T.Fragment,{children:[le&&(g?T.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:[T.jsx("defs",{children:T.jsxs("linearGradient",{id:ne,x1:"0",y1:"0",x2:"1",y2:"0",children:[T.jsx("stop",{offset:"0%",stopColor:R?z.macro:z.micro,stopOpacity:"0.28"}),T.jsx("stop",{offset:"100%",stopColor:R?z.micro:z.macro,stopOpacity:ds})]})}),T.jsx("path",{ref:la,"data-testid":"period-slider-vernier-projection",d:Ta(Mt,At,g,R),fill:`url(#${ne})`})]}):T.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[T.jsx("defs",{children:T.jsxs("linearGradient",{id:ne,x1:"0",y1:"0",x2:"0",y2:"1",children:[T.jsx("stop",{offset:"0%",stopColor:R?z.macro:z.micro,stopOpacity:"0.28"}),T.jsx("stop",{offset:"100%",stopColor:R?z.micro:z.macro,stopOpacity:ds})]})}),T.jsx("path",{ref:la,"data-testid":"period-slider-vernier-projection",d:Ta(Mt,At,g,R),fill:`url(#${ne})`})]})),!O&&T.jsxs(T.Fragment,{children:[T.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:g?{bottom:`calc(${Wr} - 8px)`,height:`calc(${ro} - ${Wr} + 16px)`}:{left:`calc(${Wr} - 8px)`,width:`calc(${ro} - ${Wr} + 16px)`},onPointerDown:Ur("macro-connect")}),!U&&T.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:g?{bottom:`calc(${Gr} - 8px)`,height:`calc(${no} - ${Gr} + 16px)`}:{left:`calc(${Gr} - 8px)`,width:`calc(${no} - ${Gr} + 16px)`},onPointerDown:Ur("micro-connect")})]}),Re&&T.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(c=>T.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:g?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`macro-tick-${c}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(c=>T.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:g?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`micro-tick-${c}`))]}),T.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":oe.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Kl,"aria-valuemax":ct,"aria-valuenow":Qe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(br,S,"period"):Pr(S,br,Pe,h),"aria-orientation":g?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${g?"is-vertical":""} group absolute touch-none ${g?R?"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":R?"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 ${Mr}`,style:g?{bottom:Wr,left:R?0:"auto",right:R?"auto":0,transform:R?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:je==="macro-low"||Ze==="macro-low"?30:15}:{left:Wr,top:R?0:"auto",bottom:R?"auto":0,transform:R?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:je==="macro-low"||Ze==="macro-low"?30:15},onPointerDown:Ur("macro-low"),onKeyDown:Qn("macro-low"),onFocus:Zn("macro-low"),"data-active":je==="macro-low"?"true":void 0,"data-front":Ze==="macro-low"?"true":void 0,"data-vernier-pos":g?R?"left":"right":R?"top":"bottom","data-handle-type":"macro-low",children:[T.jsx(yn,{type:"macro",isTop:R,isVertical:g,isLeft:R}),$e&&T.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&T.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":bc?"true":void 0,"data-slanted":vt.slant.isSlanted?"true":void 0,"data-flipped":vt.slant.isFlipped?"true":void 0,ref:Ql,style:vt.lowStyle,children:at(S,br,Pe,h)}),Kr(vt.lowLeaderStyle)]}),T.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":oe.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Qe,"aria-valuemax":ql,"aria-valuenow":ct,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(wr,S,"period"):Pr(S,wr,Pe,h),"aria-orientation":g?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${g?"is-vertical":""} group absolute touch-none ${g?R?"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":R?"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 ${Mr}`,style:g?{bottom:ro,left:R?0:"auto",right:R?"auto":0,transform:R?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:je==="macro-high"||Ze==="macro-high"?30:15}:{left:ro,top:R?0:"auto",bottom:R?"auto":0,transform:R?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:je==="macro-high"||Ze==="macro-high"?30:15},onPointerDown:Ur("macro-high"),onKeyDown:Qn("macro-high"),onFocus:Zn("macro-high"),"data-active":je==="macro-high"?"true":void 0,"data-front":Ze==="macro-high"?"true":void 0,"data-vernier-pos":g?R?"left":"right":R?"top":"bottom","data-handle-type":"macro-high",children:[T.jsx(yn,{type:"macro",isTop:R,isVertical:g,isLeft:R}),$e&&T.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&T.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":wc?"true":void 0,"data-slanted":vt.slant.isSlanted?"true":void 0,"data-flipped":vt.slant.isFlipped?"true":void 0,ref:ec,style:vt.highStyle,children:at(S,wr,Pe,h)}),Kr(vt.highLeaderStyle)]}),T.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":U?oe.microSelectedDate:oe.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Mi,"aria-valuemax":U?na:ot,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(kr,v,"period"):Pr(v,kr,Oe,h),"aria-orientation":g?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${g?"is-vertical":""} group absolute touch-none ${g?R?"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":R?"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 ${Mr}`,style:g?{bottom:Gr,left:R?"auto":0,right:R?0:"auto",transform:R?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:je===Yt||Ze===Yt?30:20}:{left:Gr,top:R?"auto":0,bottom:R?0:"auto",transform:R?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:je===Yt||Ze===Yt?30:20},onPointerDown:Ur(Yt),onKeyDown:Qn(Yt),onFocus:Zn(Yt),"data-active":je===Yt?"true":void 0,"data-front":Ze===Yt?"true":void 0,"data-vernier-pos":g?R?"right":"left":R?"bottom":"top","data-handle-type":Yt,children:[T.jsx(yn,{type:"micro",isTop:!R,isVertical:g,isLeft:!R}),$e&&T.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&T.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":vc?"true":void 0,"data-slanted":St.slant.isSlanted?"true":void 0,"data-flipped":St.slant.isFlipped?"true":void 0,ref:rc,style:St.lowStyle,children:at(v,kr,Oe,h)}),Kr(St.lowLeaderStyle)]}),!U&&T.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":oe.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Be,"aria-valuemax":na,"aria-valuenow":ot,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Nr,v,"period"):Pr(v,Nr,Oe,h),"aria-orientation":g?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${g?"is-vertical":""} group absolute touch-none ${g?R?"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":R?"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 ${Mr}`,style:g?{bottom:no,left:R?"auto":0,right:R?0:"auto",transform:R?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:je==="micro-high"||Ze==="micro-high"?30:20}:{left:no,top:R?"auto":0,bottom:R?0:"auto",transform:R?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:je==="micro-high"||Ze==="micro-high"?30:20},onPointerDown:Ur("micro-high"),onKeyDown:Qn("micro-high"),onFocus:Zn("micro-high"),"data-active":je==="micro-high"?"true":void 0,"data-front":Ze==="micro-high"?"true":void 0,"data-vernier-pos":g?R?"right":"left":R?"bottom":"top","data-handle-type":"micro-high",children:[T.jsx(yn,{type:"micro",isTop:!R,isVertical:g,isLeft:!R}),$e&&T.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&T.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":Sc?"true":void 0,"data-slanted":St.slant.isSlanted?"true":void 0,"data-flipped":St.slant.isFlipped?"true":void 0,ref:nc,style:St.highStyle,children:at(v,Nr,Oe,h)}),Kr(St.highLeaderStyle)]})]}):T.jsxs(T.Fragment,{children:[!O&&T.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Pc,onPointerDown:mc}),p&&W&&$.length>1&&T.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:$.map((c,b)=>{const x=Y(t,c,f),D=xr(b),k=g?{bottom:`${D}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${D}%`,top:"50%",transform:"translate(-50%, -50%)"};return T.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:k},`tick-${x}`)})}),!i&&I!==null&&He!==null&&Ee===null&&ms&&T.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Cc,children:[T.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"}),T.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Ic?"true":void 0,className:`period-slider-hover-tooltip ${m==="bottom"&&!g?"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:at(t,ms,e.formatLabel,h)})]}),T.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":H?oe.selectedDate:oe.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":N,"aria-valuemax":H?V:Me,"aria-valuenow":pe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(ya,t,"period"):Pr(t,ya,e.formatLabel,h),"aria-orientation":g?"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 ${Mr}`,style:$c,onPointerDown:Qi("low"),onKeyDown:es("low"),onFocus:Ji("low"),"data-active":Ee==="low"?"true":void 0,"data-front":hn?"true":void 0,children:[T.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 ${Ee==="low"?"":"shadow-md"}`}),d!=="hover"&&T.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-label-position":m,"data-slanted":or.isSlanted?"true":void 0,"data-flipped":or.isFlipped?"true":void 0,"data-front":hn?"true":void 0,"data-duplicate":da&&!hn?"true":void 0,ref:Xl,style:Br.lowStyle,children:at(t,ya,e.formatLabel,h)}),Kr(Br.lowLeaderStyle)]}),!H&&T.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":oe.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":pe,"aria-valuemax":V,"aria-valuenow":Me,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Ea,t,"period"):Pr(t,Ea,e.formatLabel,h),"aria-orientation":g?"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 ${Mr}`,style:Tc,onPointerDown:Qi("high"),onKeyDown:es("high"),onFocus:Ji("high"),"data-active":Ee==="high"?"true":void 0,"data-front":gn?"true":void 0,children:[T.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 ${Ee==="high"?"":"shadow-md"}`}),d!=="hover"&&T.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-label-position":m,"data-slanted":or.isSlanted?"true":void 0,"data-flipped":or.isFlipped?"true":void 0,"data-front":gn?"true":void 0,"data-duplicate":da&&!gn?"true":void 0,ref:Zl,style:Br.highStyle,children:at(t,Ea,e.formatLabel,h)}),Kr(Br.highLeaderStyle)]})]})}),u&&fs(g?"decrease":"increase")]})},et=e=>e.getTime(),Il=(e,t)=>!(Nt(e)&&Nt(t))||e.length!==2||t.length!==2?!1:Pt(e[0],et)===Pt(t[0],et)&&Pt(e[1],et)===Pt(t[1],et),fo=(e,t)=>e===void 0||t===void 0?e===t:Il(e,t),Va=(e,t)=>{if(e===t)return!0;if(!(Nt(e)&&Nt(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(Pt(e[r],et)!==Pt(t[r],et))return!1;return!0},Al=(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},nd=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||Pt(e.minDate,et)!==Pt(t.minDate,et)||Pt(e.maxDate,et)!==Pt(t.maxDate,et)||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.labelCeiling!==t.labelCeiling||e.labelFloor!==t.labelFloor||e.showLabelLeaderLines!==t.showLabelLeaderLines||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||!Al(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!Fo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!Va(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(gt(e.value,et)!==gt(t.value,et)||gt(e.defaultValue,et)!==gt(t.defaultValue,et)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!fo(e.range,t.range)||!fo(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!fo(e.microRange,t.microRange)||!fo(e.defaultMicroRange,t.defaultMicroRange)||gt(e.microValue,et)!==gt(t.microValue,et)||gt(e.defaultMicroValue,et)!==gt(t.defaultMicroValue,et)||!Il(e.macroRange,t.macroRange)||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||!Va(e.macroAllowedDates,t.macroAllowedDates)||!Va(e.microAllowedDates,t.microAllowedDates)):!1,kl=s.memo(rd,nd);kl.displayName="PeriodSlider";const js=2,Te=-1,yt=e=>Y("day",e),Nn=e=>re("day",e),Sn=e=>`${Wo(e.getFullYear())}-${String(e.getMonth()+1).padStart(js,"0")}-${String(e.getDate()).padStart(js,"0")}`,od=(e,t,r,n)=>{const o=yt(e),a=yt(t),i=a>=o?a-o+1:0,l=d=>Nn(a-d),u={kind:"range",min:o,max:a};return{count:i,dateAt:l,labelAt:d=>at("day",l(d),n,r),indexOf:d=>{const m=yt(d);return m<o||m>a?Te:a-m},nearestIndexOf:d=>{if(i===0)return Te;const m=In(u,yt(d));return m===null?Te:a-m}}},ad=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,l=M=>e[n-M],u={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},d=M=>{const L=M.getTime();let g=r,O=n;for(;g<=O;){const p=g+O>>1,w=e[p].getTime();if(w===L)return n-p;w<L?g=p+1:O=p-1}return Te},m=M=>M===null?Te:d(Nn(M));return{count:i,dateAt:l,labelAt:M=>at("day",l(M),a,o),indexOf:d,nearestIndexOf:M=>m(In(u,yt(M)))}},id={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${E(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${E(e)})`)},indexOf:()=>Te,nearestIndexOf:()=>Te},sd=(e,t,r)=>{const n=l=>{let u=0,d=e.length;for(;u<d;){const m=u+d>>1;e[m].getTime()<l?u=m+1:d=m}return u},o=l=>{let u=0,d=e.length;for(;u<d;){const m=u+d>>1;e[m].getTime()<=l?u=m+1:d=m}return u},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},ld=(e,t)=>{const r=new Map;for(let n=0;n<e.length;n++){const o=e[n];t(n,o);const a=new Date(o);a.setHours(0,0,0,0);const i=a.getTime();r.has(i)||r.set(i,a)}return Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},cd={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},ud={month:2,day:2},Fs={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Us=new Map,dd=(e,t)=>{const r=`${e}\0${t}`,n=Us.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,cd[e]);return Us.set(r,o),o},md=(e,t,r)=>{if(r!==void 0)return dd(e,r).format(t);const n=new Date(t.getTime());return e==="year"?Wo(Fs.year(n)):String(Fs[e](n)).padStart(ud[e],"0")},Nl=(e,t,r,n)=>{if(Ce("formatOptionText","unit",t),r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${E(r)})`);return ye(e)?r==="part"?md(t,e,n):at(t,e,void 0,n):""},fd=12,Zo=(e,t,r)=>{const n=Fn(e,t,r);return n===null?Number.NaN:n*fd+r},fi=(e,t,r)=>{const n=o=>o.value!==void 0?o.value:o.initialDate;return gt(n(e),r)!==gt(n(t),r)||t.value!==void 0&&Number.isNaN(gt(t.initialDate,r))||gt(e.minDate,r)!==gt(t.minDate,r)?!1:gt(e.maxDate,r)===gt(t.maxDate,r)};class Vl{held;writeCount=0;constructor(t){this.held=t}get current(){return this.held}set current(t){this.held=t,this.writeCount+=1}get writes(){return this.writeCount}commit(t,r){this.writeCount===r&&(this.held=t)}}function Ol(e,t){const[r]=s.useState(()=>t(e)),n=r.writes;return s.useInsertionEffect(()=>{r.commit(e,n)}),r}function mt(e){return Ol(e,t=>new Vl(t))}const hd={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},gd=["shift","start","end","single"],pd=["disable","clamp"],bd=["follow","keep"],zs={day:{day:1},month:{month:1,year:12},year:{year:1}},Bs=new WeakMap,Ga=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${E(r)})`)},Ws=(e,t,r,n)=>{for(const[o,a]of Object.entries(r))if(!(a===void 0||n.includes(o)))throw new RangeError(`${e}: ${t}.${o} is not read here; the accepted keys are ${n.map(i=>`"${i}"`).join(", ")} (received: ${E(a)})`)},Cr=(e,t,r,n)=>{Ga(e,t,r),Ws(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];Ga(e,a,i),Ws(e,a,i,hd[n]);const{motion:l,edge:u,window:d}=i;if(n!=="vernierPoint"&&(typeof l!="string"||!gd.includes(l)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${E(l)})`);if(u!==void 0){if(l!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${E(u)} with motion ${E(l)})`);if(typeof u!="string"||!pd.includes(u))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${E(u)})`)}if(d!==void 0&&(typeof d!="string"||!bd.includes(d)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${E(d)})`)}},hi=(e,t,r)=>{if(typeof t!="object"||t===null)throw new RangeError(`${e}: stepper must be an object (received: ${E(t)})`);const{onStep:n,canStepPrevious:o,canStepNext:a}=t;if(typeof n!="function")throw new RangeError(`${e}: stepper.onStep must be a function (received: ${E(n)})`);if(typeof o!="boolean")throw new RangeError(`${e}: stepper.canStepPrevious must be a boolean (received: ${E(o)})`);if(typeof a!="boolean")throw new RangeError(`${e}: stepper.canStepNext must be a boolean (received: ${E(a)})`);if(!r)throw new RangeError(`${e}: stepper requires the controlled value; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled initialDate would never change`)},Xt=(e,t,r,n,o)=>{if(!ye(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${E(r)})`);return Ke(e,t,r,n,o,"")},_l=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=Bs.get(r),l=i?.get(a);if(l!==void 0)return l;const u=[];for(let m=0;m<r.length;m++)u.push(Xt(e,`${t}[${m}]`,r[m],n,o));const d=Array.from(new Set(u)).sort((m,M)=>m-M);return i===void 0?Bs.set(r,new Map([[a,d]])):i.set(a,d),d},wd=(e,t)=>t===1?xo(e):{stepEnd:(r,n)=>So(e,r+t*n,n),edge:r=>Tn(e,r)},Ka=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},qa=(e,t,r,n,o,a)=>{if(a){const u=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:re(n,e[0],o);return Number.isNaN(u.getTime())?null:[u,u]}const i=e[0]===t[0]?r[0]:re(n,e[0],o),l=e[1]===t[1]?r[1]:re(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(l.getTime())?null:[i,l.getTime()<i.getTime()?i:l]},Xa=e=>{const t="resolveSelectorSteps";Ga(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:l,rules:u}=e;Ce(t,"unit",o);const d=Jt(t,"stepUnit",e.stepUnit,o),m=zs[o][d];if(m===void 0){const v=Object.keys(zs[o]).map(f=>`"${f}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${v} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${E(d)})`)}const M=hr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${E(n)})`);if(!Nt(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${E(r)})`);Cr(t,"rules",u,"motion");const L=Xt(t,"selection[0]",r[0],o,M),g=Xt(t,"selection[1]",r[1],o,M);if(g<L)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${E(r[0])}, end: ${E(r[1])})`);const O=a===void 0?null:Xt(t,"minDate",a,o,M),p=i===void 0?null:Xt(t,"maxDate",i,o,M);if(O!==null&&p!==null&&p<O)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${E(a)}, maxDate: ${E(i)})`);an(t,"allowedDates",l);const w=l===void 0?{kind:"range",min:O,max:p}:sn(_l(t,"allowedDates",l,o,M),O,p),h=wd(w,m),S=(v,f)=>{const te=Ua(h,L,g,v,Ka(f,n));return te===null?null:qa(te,[L,g],r,o,M,f.motion==="single")};return{previous:S(-1,u.previous),next:S(1,u.next)}},Ft=(e,t)=>{const r=mt({targets:e,onStepTo:t}),n=s.useCallback(i=>{const{targets:l,onStepTo:u}=r.current,d=l[i];d!==null&&u(d,i)},[]),o=e.previous!==null,a=e.next!==null;return s.useMemo(()=>({onStep:n,canStepPrevious:o,canStepNext:a}),[n,o,a])};function vd(e,t,r,n){return e.source===t?e:t===null?{source:t,held:e.held}:{source:t,held:n(r)}}function gi(e,t,r,n){const o=t?null:r(e),[a,i]=s.useState(()=>({source:o,held:n(e)})),l=s.useCallback(d=>i(m=>({source:m.source,held:d})),[]),u=vd(a,o,e,n);return s.useLayoutEffect(()=>{u!==a&&i(d=>d===a?u:d)}),[u.held,l]}const Eo=44,Gs=7,ho=8,Sd=2,Yl=10,xd=1e3,Za=8,Oa=6,_a=4,Ya=12,xn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),yt(r)},Rd=(e,t)=>{if(e.length<_a||t.count===0)return Te;const r=Number(e.slice(0,_a));if(!Number.isInteger(r))return Te;const n=e.length>=Oa,o=n?Number(e.slice(_a,Oa)):Ya;if(o<1||o>Ya)return Te;const a=e.length>=Za,i=a?Number(e.slice(Oa,Za)):0,l=xn(r,o),u=(o===Ya?xn(r+1,1):xn(r,o+1))-1,d=a?l+i-1:n?l:xn(r,1),m=a?d:n?u:xn(r+1,1)-1;if(a&&(i<1||d>u))return Te;for(let M=m;M>=d;M--){const L=t.indexOf(Nn(M));if(L!==Te)return L}return Te},Md=e=>e.closest(".dark")===null?"light":"dark",Dd=(e,t,r,n)=>{const o=r-e.bottom-ho,a=e.top-ho,i=o>=t||o>=a,u=Math.max(Eo,Math.min(t,i?o:a)),d=i?e.bottom:e.top-u,m=e.width+Yl,M=Math.max(ho,Math.min(e.left,n-m-ho));return{top:d,left:M,width:m,height:u}},yd=(e,t)=>e<t?e:t>0?t-1:Te,Hl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:l,labels:u,onCommitIndex:d,controlClassName:m})=>{const M=s.useId(),L=s.useMemo(()=>cu(u),[u]),g=`period-slider-date-listbox-${M}`,O=s.useCallback(A=>`period-slider-date-option-${M}-${A}`,[M]),[p,w]=s.useState(!1),[h,S]=s.useState(Te),[v,f]=s.useState(null),[te,ce]=s.useState(null),B=s.useRef(null),U=s.useRef(null),oe=s.useRef(null),z=s.useRef({buffer:"",at:0}),ne=e.count,C=yd(h,ne),K=mt(C);s.useLayoutEffect(()=>{C!==h&&S(A=>A===h?C:A)});const _=Math.min(ne,Gs)*Eo,y=Math.max(1,Math.min(ne,Gs)),$=s.useCallback(()=>{const A=B.current;if(A===null)return;const X=A.getBoundingClientRect();f(Dd(X,_,window.innerHeight,window.innerWidth))},[_]),W=mt(p),N=s.useCallback(()=>{w(!1),S(Te),z.current={buffer:"",at:0},W.current=!1},[W]);s.useLayoutEffect(()=>()=>{W.current&&N()},[W,N]);const V=s.useCallback(A=>{a||ne===0||(S(A),w(!0),W.current=!0)},[a,ne,W]);s.useLayoutEffect(()=>{if(!p){f(null),ce(null);return}const A=B.current;return A!==null&&ce(Md(A)),$(),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[p,$]),s.useEffect(()=>{if(!p)return;const A=X=>{const ue=X.target;ue!==null&&U.current?.contains(ue)!==!0&&B.current?.contains(ue)!==!0&&N()};return document.addEventListener("pointerdown",A,!0),()=>document.removeEventListener("pointerdown",A,!0)},[p,N]),s.useEffect(()=>{p&&(a||ne===0)&&N()},[p,a,ne,N]),s.useEffect(()=>{if(!p)return;const A=K.current;A!==Te&&oe.current?.scrollToIndex(A,{align:"center"})},[ne,p,K]);const H=A=>{if(ne===0)return;const X=Math.max(0,Math.min(A,ne-1));S(X),oe.current?.scrollToIndex(X,{align:"center"})},Z=A=>{A<0||A>=ne||(d(A),N(),B.current?.focus())},be=mt(Z),Q=A=>{if(a||B.current===null)return;const X=C!==Te?C:t!==Te?t:r;switch(A.key){case"ArrowDown":if(A.preventDefault(),!p){V(X);return}H(X+1);return;case"ArrowUp":if(A.preventDefault(),!p){V(X);return}H(X-1);return;case"Home":if(!p)return;A.preventDefault(),H(0);return;case"End":if(!p)return;A.preventDefault(),H(ne-1);return;case"PageDown":if(!p)return;A.preventDefault(),H(X+y);return;case"PageUp":if(!p)return;A.preventDefault(),H(X-y);return;case"Enter":if(A.preventDefault(),!p){V(X);return}Z(C!==Te?C:X);return;case"Escape":if(!p)return;A.preventDefault(),N();return;case"Tab":p&&N();return}if(A.key.length!==1)return;const ue=A.key>="0"&&A.key<="9",Ye=A.key==="-"||A.key==="/"||A.key===".";if(!(ue||Ye))return;A.preventDefault();const Se=Date.now(),it=Se-z.current.at>xd?"":z.current.buffer,Ue=ue?`${it}${A.key}`.slice(0,Za):it;z.current={buffer:Ue,at:Se};const ze=Rd(Ue,e);if(ze!==Te){if(!p){V(ze);return}H(ze)}},se=s.useCallback(A=>A,[]),ve=s.useCallback(()=>Eo,[]),ee=C===Te?null:O(C),ae=s.useCallback(()=>{const A=B.current;if(A===null||ee===null)throw new Error("VirtualDateDropdown: the active row attached without its combobox control or an active option id, so aria-activedescendant has nothing to name it on");return A.setAttribute("aria-activedescendant",ee),()=>{A.getAttribute("aria-activedescendant")===ee&&A.removeAttribute("aria-activedescendant")}},[ee]),ge=s.useCallback(A=>{const X=A===t,ue=A===C;return T.jsx("div",{id:O(A),role:"option","aria-selected":X,"aria-posinset":A+1,"aria-setsize":e.count,"data-testid":"period-slider-date-option","data-active":ue?"true":void 0,ref:ue?ae:void 0,className:"period-slider-date-option",style:{height:Eo},onClick:()=>be.current(A),children:e.labelAt(A)})},[e,t,C,O,be,ae]),Ne=s.useCallback(A=>(U.current=A,A.style.removeProperty("display"),()=>{U.current=null,A.style.setProperty("display","none","important")}),[]),ft=p&&v!==null&&te!==null&&ne>0,me=ft?T.jsx("div",{ref:Ne,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":te,style:{top:v.top,left:v.left,width:v.width,height:v.height},onMouseDown:A=>{A.preventDefault()},children:T.jsx(dr.VirtualScroll,{ref:oe,itemCount:ne,getItem:se,getItemHeight:ve,viewportSize:v.height-Sd,initialScrollIndex:C!==Te?C:void 0,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:l,labels:L,contentProps:{id:g,role:"listbox","aria-label":i},scrollBarOptions:{width:Yl,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:ge})}):null;return T.jsxs(T.Fragment,{children:[T.jsx("input",{ref:B,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":p,"aria-controls":ft?g:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none",disabled:a,value:n,className:m,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:Q,onMouseDown:A=>{a||B.current===null||(A.preventDefault(),B.current?.focus(),p?N():V(t!==Te?t:r))},onBlur:()=>{p&&N()}}),me===null?null:jc.createPortal(me,document.body)]})};Hl.displayName="VirtualDateDropdown";const Rn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Ed=jn("leave the bound out where the variant allows it, or declare the days to offer with minYear / maxYear or allowedDates"),Pd=jn('variant="split-dropdown" requires both bounds, so declare the years to offer with minYear / maxYear'),Ld=31,Mn=(e,t,r)=>{if(!ye(t))throw new RangeError(`DateSelector: ${e} must be a valid Date (received: ${E(t)})`);Ke("DateSelector",e,t,"day",0,r)},sr=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},go=e=>sr(e,1,1),Ks=e=>sr(e,12,31),jl=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,qs=(e,t,r,n)=>jl(e,t,r)&&e.getDate()===n,pi=e=>Fn(e,"year",0)!==null,bi=e=>Zo(e,"day",0),$d=e=>pi(e)?bi(e):Number.NaN,po=(e,t,r)=>{if(!pi(t))throw new RangeError(`DateSelector: ${e} must fall in a year that starts inside the Date range, because variant="split-dropdown" draws its year (received: ${E(t)})${r}`)},Xs=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const l=r(i);if(Number.isNaN(l.getTime()))break;n(l,i)&&a.push({value:i,label:o(l)})}return a},Td=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,minYear:l,maxYear:u,minDate:d,maxDate:m,allowedDates:M,variant:L="date",className:g="",style:O,disabled:p=!1,locale:w,labels:h,formatLocale:S,formatOption:v}=e;S!==void 0&&Xo("DateSelector","formatLocale",S);const f=L==="split-dropdown"?Pd:Ed;if(t!==void 0&&Mn("value",t,""),r!==void 0&&Mn("initialDate",r,""),d!==void 0&&Mn("minDate",d,f),m!==void 0&&Mn("maxDate",m,f),L==="split-dropdown"&&(t!==void 0&&po("value",t,""),r!==void 0&&po("initialDate",r,""),d!==void 0&&po("minDate",d,f),m!==void 0&&po("maxDate",m,f)),l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: minYear must be an integer year (received: ${E(l)})`);if(u!==void 0&&!Number.isInteger(u))throw new RangeError(`DateSelector: maxYear must be an integer year (received: ${E(u)})`);if(l!==void 0&&Number.isNaN(go(l).getTime()))throw new RangeError(`DateSelector: minYear must name a year whose first day starts inside the Date range (received: ${E(l)})`);if(u!==void 0&&Number.isNaN(Ks(u).getTime()))throw new RangeError(`DateSelector: maxYear must name a year whose last day starts inside the Date range (received: ${E(u)})`);if(L==="split-dropdown"&&M!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour allowedDates; use variant="dropdown" or variant="date" for a discrete date set');an("DateSelector","allowedDates",M);const te=t??r;if(te===void 0)throw new RangeError("DateSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected date is never inferred from the wall clock");o!==void 0&&hi("DateSelector",o,t!==void 0);const ce=si("DateSelector",a),B=Uo(w,h),U=t!==void 0,[oe,z]=gi(te,U,bi,Rn),ne=t?.getTime(),C=s.useMemo(()=>t!==void 0?Rn(t):oe,[ne,oe]);if(L==="split-dropdown"&&!U&&!pi(C))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${E(C)}), because that selection's year starts outside the Date range; control the date with value to decide what the split dropdown holds`);const K=d?.getTime(),_=m?.getTime(),y=s.useMemo(()=>{const I=d?Rn(d):null,J=l!==void 0?go(l):null;return I===null?J:J===null||I.getTime()>=J.getTime()?I:J},[K,l]),$=s.useMemo(()=>{const I=m?Rn(m):null,J=u!==void 0?Ks(u):null;return I===null?J:J===null||I.getTime()<=J.getTime()?I:J},[_,u]),W=y?.getTime()??null,N=$?.getTime()??null;if(y!==null&&$!==null&&y.getTime()>$.getTime())throw new RangeError(`DateSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Sn(y)}, upper: ${Sn($)})`);if(L!=="date"&&M===void 0&&(y===null||$===null))throw new RangeError(`DateSelector: variant=${E(L)} requires a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate)${L==="dropdown"?", or allowedDates":""}; the option list is never invented`);const V=s.useMemo(()=>M===void 0?null:M.map(I=>Pt(I,J=>J.getTime())).join(","),[M]),H=s.useMemo(()=>{if(M===void 0)return null;const I=ld(M,(J,He)=>Mn(`allowedDates[${J}]`,He,""));return{ascending:I,ascendingSerials:I.map(yt)}},[V]),Z=s.useMemo(()=>H===null?null:{...H,...sd(H.ascending,y,$)},[H,W,N]),be=s.useMemo(()=>Z!==null?ad(Z.ascending,Z.ascendingSerials,Z.loIndex,Z.hiIndex,S,v):y===null||$===null?id:od(y,$,S,v),[Z,W,N,S,v]),Q=s.useMemo(()=>Z!==null?{kind:"candidates",ascending:Z.ascendingSerials,loIndex:Z.loIndex,hiIndex:Z.hiIndex}:{kind:"range",min:y===null?null:yt(y),max:$===null?null:yt($)},[Z,W,N]),se=I=>!Number.isNaN(I.getTime())&&Cn(Q,yt(I)),ve=I=>{if(p)return;const J=Rn(I);se(J)&&(U||z(J),n?.(J))},ee=C.getTime(),ae=se(C),ge=s.useMemo(()=>{const I=Qt(Q,yt(C),-1);if(I===null)return null;const J=Nn(I);return Number.isNaN(J.getTime())?null:J},[Q,ee]),Ne=s.useMemo(()=>{const I=Qt(Q,yt(C),1);if(I===null)return null;const J=Nn(I);return Number.isNaN(J.getTime())?null:J},[Q,ee]),ft=()=>{if(o!==void 0){o.onStep("previous");return}ge!==null&&ve(ge)},me=()=>{if(o!==void 0){o.onStep("next");return}Ne!==null&&ve(Ne)},A=I=>{if(I.target.value){const J=Hc.parseISO(I.target.value);Number.isNaN(J.getTime())||ve(J)}},X=C.getFullYear(),ue=C.getMonth()+1,Ye=C.getDate(),Se=s.useCallback((I,J)=>v?v(J,I,"part"):Nl(J,I,"part",S),[v,S]),it=s.useMemo(()=>{if(L!=="split-dropdown"||y===null||$===null)return[];const I=[];for(let J=$.getFullYear();J>=y.getFullYear();J--)I.push({value:J,label:Se("year",go(J))});return I},[L,W,N,Se]),Ue=s.useMemo(()=>{if(L!=="split-dropdown"||y===null||$===null)return[];const I=y,J=$,He=X===I.getFullYear()?I.getMonth()+1:1,ht=X===J.getFullYear()?J.getMonth()+1:12;return Xs(He,ht,pe=>sr(X,pe,1),(pe,Me)=>jl(pe,X,Me),pe=>Se("month",pe))},[L,W,N,X,Se]),ze=s.useMemo(()=>{if(L!=="split-dropdown"||y===null||$===null)return[];const I=y,J=$,He=X===I.getFullYear()&&ue===I.getMonth()+1?I.getDate():1,ht=X===J.getFullYear()&&ue===J.getMonth()+1?J.getDate():Ld;return Xs(He,ht,pe=>sr(X,ue,pe),(pe,Me)=>qs(pe,X,ue,Me),pe=>Se("day",pe))},[L,W,N,X,ue,Se]),Ge=(I,J,He)=>{const ht=sr(I,J,He);return qs(ht,I,J,He)&&se(ht)},ie=(I,J,He)=>{Ge(I,J,He)&&ve(sr(I,J,He))},tt=it.some(I=>I.value===X),st=Ue.some(I=>I.value===ue),qe=ze.some(I=>I.value===Ye),_e=Sn(C),Ee=L==="dropdown"?at("day",C,v,S):"",rt=y?Sn(y):void 0,lt=$?Sn($):void 0,pt="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 T.jsxs("div",{className:`inline-flex items-center ${$n} ${g}`,style:O,"data-variant":L,"data-out-of-range":ae?void 0:"true",children:[T.jsx(Tr,{neighbour:"control",direction:"left",glyph:ce,disabled:p,canStep:o===void 0?ge!==null:o.canStepPrevious,onStep:ft,ariaLabel:B.previousDay}),L==="dropdown"?T.jsx(Hl,{domain:be,selectedIndex:ae?be.indexOf(C):Te,openAnchorIndex:be.nearestIndexOf(C),displayLabel:Ee,machineValue:_e,disabled:p,ariaLabel:B.dateSelect,locale:w,labels:B,onCommitIndex:I=>ve(be.dateAt(I)),controlClassName:"period-slider-date-combobox-field w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"}):L==="split-dropdown"?T.jsxs("div",{className:"inline-flex items-center gap-1",children:[T.jsxs("select",{"aria-label":B.splitYear,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:tt?X:"",onChange:I=>ie(Number(I.target.value),ue,Ye),children:[tt?null:T.jsx("option",{value:"",disabled:!0,className:pt,children:Se("year",go(X))}),it.map(I=>T.jsx("option",{value:I.value,disabled:!Ge(I.value,ue,Ye),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]}),T.jsxs("select",{"aria-label":B.splitMonth,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:st?ue:"",onChange:I=>ie(X,Number(I.target.value),Ye),children:[st?null:T.jsx("option",{value:"",disabled:!0,className:pt,children:Se("month",sr(X,ue,1))}),Ue.map(I=>T.jsx("option",{value:I.value,disabled:!Ge(X,I.value,Ye),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]}),T.jsxs("select",{"aria-label":B.splitDay,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:qe?Ye:"",onChange:I=>ie(X,ue,Number(I.target.value)),children:[qe?null:T.jsx("option",{value:"",disabled:!0,className:pt,children:Se("day",sr(X,ue,Ye))}),ze.map(I=>T.jsx("option",{value:I.value,disabled:!Ge(X,ue,I.value),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]})]}):T.jsx("input",{"aria-label":B.dateSelect,disabled:p,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:_e,min:rt,max:lt,onChange:A,type:"date"}),T.jsx(Tr,{neighbour:"control",direction:"right",glyph:ce,disabled:p,canStep:o===void 0?Ne!==null:o.canStepNext,onStep:me,ariaLabel:B.nextDay}),i]})},Cd=(e,t)=>!(!fi(e,t,t.variant==="split-dropdown"?$d:bi)||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.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.stepGlyph!==t.stepGlyph||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!Fo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),Fl=s.memo(Td,Cd);Fl.displayName="DateSelector";function Un(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(0);return o.setHours(0,0,0,0),o.setFullYear(r,n,1),o}function Vn(e){const t=Fn(e,"month",0);return re("month",t===null?Number.NaN:t,0)}const Ul=e=>Zo(e,"month",0);function Lr(e){return`${Wo(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const Zs=jn("leave the bound out where the variant allows it, or declare the months to offer with minYear / maxYear or allowedMonths");function bo(e,t,r){e!==void 0&&zl(e,t,r)}function zl(e,t,r){if(!ye(e))throw new RangeError(`MonthSelector: ${t} must be a valid Date (received: ${E(e)})`);Ke("MonthSelector",t,e,"month",0,r)}function Qs(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`MonthSelector: ${t} must be an integer year (received: ${E(e)})`);if(Number.isNaN(Un(e,r).getTime()))throw new RangeError(`MonthSelector: ${t} must name a year whose ${r===0?"January":"December"} starts inside the Date range (received: ${E(e)})`)}}function Id(e,t){const r=e===void 0?null:Un(e,0),n=t===void 0?null:Vn(t);return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Ad(e,t){const r=e===void 0?null:Un(e,11),n=t===void 0?null:Vn(t);return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function lr(e){return e.getFullYear()*12+e.getMonth()}function Qa(e){return Un(Math.floor(e/12),(e%12+12)%12)}function Js(e){return Number.isNaN(e.getTime())?null:e}function kd(e,t,r){const n=new Map;for(const o of e){const a=Vn(o);t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function Nd(e,t){const r=[];for(let n=lr(e);n<=lr(t);n++)r.push(Qa(n));return r}function el(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:at("month",e[o],r,t),value:Lr(e[o])});return n}const Vd=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,variant:l="date",minYear:u,maxYear:d,minDate:m,maxDate:M,allowedMonths:L,isWarning:g=!1,className:O="",style:p,disabled:w=!1,locale:h,labels:S,formatLocale:v,formatOption:f}=e;if(v!==void 0&&Xo("MonthSelector","formatLocale",v),bo(t,"value",""),bo(r,"initialDate",""),bo(m,"minDate",Zs),bo(M,"maxDate",Zs),Qs(u,"minYear",0),Qs(d,"maxYear",11),an("MonthSelector","allowedMonths",L),L!==void 0)for(let ie=0;ie<L.length;ie++)zl(L[ie],`allowedMonths[${ie}]`,"");const te=t??r;if(te===void 0)throw new RangeError("MonthSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected month is never inferred from the wall clock");o!==void 0&&hi("MonthSelector",o,t!==void 0);const ce=si("MonthSelector",a),B=Uo(h,S),U=t!==void 0,[oe,z]=gi(te,U,Ul,Vn),ne=s.useMemo(()=>t!==void 0?Vn(t):oe,[t?.getTime(),oe]),C=m?.getTime(),K=M?.getTime(),_=s.useMemo(()=>Id(u,m),[u,C]),y=s.useMemo(()=>Ad(d,M),[d,K]),$=_?.getTime()??null,W=y?.getTime()??null;if(_!==null&&y!==null&&_>y)throw new RangeError(`MonthSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Lr(_)}, upper: ${Lr(y)})`);if(l==="dropdown"&&L===void 0&&(_===null||y===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 list is never invented');const N=L===void 0?null:L.map(ie=>ie.getTime()).join(","),V=s.useMemo(()=>L===void 0?null:kd(L,_,y),[N,$,W]),H=s.useMemo(()=>{if(V!==null){const ie=V.map(lr);return{kind:"candidates",ascending:ie,loIndex:0,hiIndex:ie.length-1}}return{kind:"range",min:_===null?null:lr(_),max:y===null?null:lr(y)}},[V,$,W]),Z=ie=>!Number.isNaN(ie.getTime())&&Cn(H,lr(ie)),be=ie=>{if(w)return;if(!Z(ie))throw new RangeError(`MonthSelector: refusing to emit ${Lr(ie)}, which lies outside the selectable months`);U||z(ie);const tt=ie.getFullYear()*100+(ie.getMonth()+1);n?.(ie,tt)},Q=ne.getTime(),se=Z(ne),ve=s.useMemo(()=>{const ie=Qt(H,lr(ne),-1);return ie===null?null:Js(Qa(ie))},[H,Q]),ee=s.useMemo(()=>{const ie=Qt(H,lr(ne),1);return ie===null?null:Js(Qa(ie))},[H,Q]),ae=()=>{if(o!==void 0){o.onStep("previous");return}ve!==null&&be(ve)},ge=()=>{if(o!==void 0){o.onStep("next");return}ee!==null&&be(ee)},Ne=ie=>{if(!ie)return;const tt=ie.lastIndexOf("-");if(tt<=0)return;const st=ie.slice(0,tt),qe=ie.slice(tt+1),_e=Number(st),Ee=Number(qe)-1;if(!(Number.isInteger(_e)&&Number.isInteger(Ee)))return;const rt=Un(_e,Ee);Z(rt)&&be(rt)},ft=ie=>{Ne(ie.target.value)},me=ie=>{Ne(ie.target.value)},A=Lr(ne),X=l==="dropdown"&&!se?at("month",ne,f,v):"",ue=_?Lr(_):void 0,Ye=y?Lr(y):void 0,Se=s.useMemo(()=>l!=="dropdown"?[]:V!==null?el(V,v,f):_===null||y===null?[]:el(Nd(_,y),v,f),[l,V,$,W,v,f]),it=se?A:"",Ue=g?"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",ze=`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 ${Ue}`,Ge=`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 ${Ue}`;return T.jsxs("div",{className:`inline-flex items-center ${$n} ${O}`,style:p,"data-out-of-range":se?void 0:"true",children:[T.jsx(Tr,{neighbour:"control",direction:"left",glyph:ce,disabled:w,canStep:o===void 0?ve!==null:o.canStepPrevious,onStep:ae,ariaLabel:B.previousMonth}),l==="dropdown"?T.jsxs("select",{"aria-label":B.monthSelect,disabled:w,className:Ge,value:it,onChange:me,children:[se?null:T.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:X}),Se.map(ie=>T.jsx("option",{value:ie.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:ie.label},ie.value))]}):T.jsx("input",{"aria-label":B.monthSelect,disabled:w,className:ze,value:A,min:ue,max:Ye,onChange:ft,type:"month"}),T.jsx(Tr,{neighbour:"control",direction:"right",glyph:ce,disabled:w,canStep:o===void 0?ee!==null:o.canStepNext,onStep:ge,ariaLabel:B.nextMonth}),i]})},Od=(e,t)=>!(!fi(e,t,Ul)||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||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.stepGlyph!==t.stepGlyph||e.children!==t.children||e.locale!==t.locale||!Fo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),Bl=s.memo(Vd,Od);Bl.displayName="MonthSelector";const Ja=Symbol("nothing handed");let Ha=0;class _d{constructor(t,r,n,o){this.states=t,this.base=r,this.superseded=n,this.setMark=o}states;base;superseded;setMark;drafts=new Map;handed=new Map;cells=new Set;notes=[];closed=!1;marked=!1;committed=!1;record(){this.marked||(this.marked=!0,this.setMark(this))}leadsTo(t){return t.every((r,n)=>r===(this.handed.has(n)?this.handed.get(n):this.states[n]))}read(t,r){return this.drafts.has(t)?this.drafts.get(t):r}write(t,r){this.drafts.set(t,r),this.cells.add(t),this.record()}hand(t,r){this.handed.set(t.slot,r),this.cells.add(t),this.record()}note(t){this.notes.push(t),this.record()}hasHanded(t){return this.handed.has(t)}lastHanded(t){return this.handed.get(t)}close(){this.closed=!0}}class Yd{constructor(t,r,n){this.owner=t,this.setMark=n,this.slotWrites=r.map(()=>0),this.records=r.map(()=>Ja),this.latest=this.open(r)}owner;setMark;latest;active=null;slotWrites;records;outbox=[];duringRender=t=>{if(typeof t!="function")throw new TypeError(`${this.owner}: duringRender(action) must be a function (received: ${E(t)})`);const r=this.latest;if(r.closed)throw new Error(`${this.owner}: duringRender(action) must be called during the host's render, after the hook call (call the returned functions directly from event handlers and effects)`);const n=this.active;this.active=r,Ha+=1;try{t()}finally{Ha-=1,this.active=n}};get pass(){if(this.active===null&&Ha>0)throw new Error(`${this.owner}: a returned function was called during another hook's duringRender(action); call it inside this hook's own duringRender(action)`);return this.active}inFlight(t){return!this.latest.committed&&this.latest.hasHanded(t)}handedTo(t){return this.records[t]}recordHanded(t,r){this.records[t]=r}begin(t,r){const n=this.latest;return!n.committed&&r===n&&n.leadsTo(t)?(n.closed&&(n.closed=!1,this.closeAtEndOfRun(n)),n):(n.close(),this.latest=this.open(t),this.latest)}open(t){const r=t.map((o,a)=>this.records[a]!==Ja&&this.records[a]!==o),n=new _d(t,[...this.slotWrites],r,this.setMark);return this.closeAtEndOfRun(n),n}closeAtEndOfRun(t){queueMicrotask(()=>t.close())}applies(t,r){return!t.superseded[r]&&t.base[r]===this.slotWrites[r]}commit(t,r){t.close(),t.committed=!0;for(const n of t.cells)this.applies(t,n.slot)&&n.adopt(t,r);for(const n of t.notes)this.applies(t,n.slot)&&this.outbox.push(n.send);this.outbox.length>0&&queueMicrotask(()=>this.deliver())}deliver(){for(let t=this.outbox.shift();t!==void 0;t=this.outbox.shift())t()}wrote(t){this.deliver(),this.slotWrites[t]+=1}notify(t,r){const n=this.pass;if(n!==null){n.note({slot:t,send:r});return}this.deliver(),r()}}class Hd extends Vl{constructor(t,r,n){super(t),this.scope=r,this.slot=n}scope;slot;adopted=null;get current(){const t=this.scope.pass;return t===null?super.current:t.read(this,super.current)}set current(t){const r=this.scope.pass;if(r!==null){r.write(this,t);return}this.scope.wrote(this.slot),super.current=t}hand(t){const r=this.scope.pass;if(r!==null){r.hand(this,t);return}this.adopted=null,this.scope.wrote(this.slot),this.scope.recordHanded(this.slot,t)}get holdsHanded(){const t=this.scope.pass;return t===null?this.scope.handedTo(this.slot)===super.current&&!this.scope.inFlight(this.slot):(t.hasHanded(this.slot)?t.lastHanded(this.slot):this.scope.handedTo(this.slot))===t.read(this,super.current)}forgetHanded(t){this.scope.wrote(this.slot),this.scope.handedTo(this.slot)===t&&this.scope.recordHanded(this.slot,Ja)}adopt(t,r){const n=r[this.slot];if(!t.hasHanded(this.slot)||n!==t.lastHanded(this.slot))return;this.scope.recordHanded(this.slot,n);const o=t.states[this.slot];n!==o&&(this.adopted={opening:o,handed:n})}recordAdopted(t){const r=this.adopted;r!==null&&(this.adopted=null,t(n=>n===r.opening?r.handed:n))}}class jd{constructor(t,r,n){this.scope=r,this.slot=n,this.held=t}scope;slot;held;get current(){const t=this.scope.pass;return t===null?this.held:t.read(this,this.held)}set current(t){const r=this.scope.pass;if(r!==null){r.write(this,t);return}this.scope.wrote(this.slot),this.held=t}adopt(t){this.held=t.read(this,this.held)}}const Fd=(e,t)=>t;function Qo(e,t){const[r,n]=s.useReducer(Fd,null),[o]=s.useState(()=>new Yd(e,t,n)),a=o.begin(t,r);return s.useInsertionEffect(()=>{o.commit(a,t)}),s.useLayoutEffect(()=>{o.deliver()}),o}function Qr(e,t,r,n){const o=Ol(r,a=>new Hd(a,e,t));return s.useLayoutEffect(()=>{o.recordAdopted(n)}),o}function Jr(e,t,r){const[n]=s.useState(()=>new jd(r,e,t));return n}function ke(e,t,r){return e<t?t:e>r?r:e}const Ud=sn([],null,null);function On(e,t,r,n){return r===null?Ud:ei(r,Y(t,e[0],n),Y(t,e[1],n))}function $r(e,t,r,n,o){const a=Y(t,e,o),i=ti(n)?null:In(n,a);return i===null?a<Y(t,r[0],o)?r[0]:a>Y(t,r[1],o)?r[1]:e:i===a?e:re(t,i,o)}function Xr(e,t,r,n,o,a){const i=Y(t,e[0],o),l=Y(t,e[1],o),u=Mo(a,{kind:"range",min:Y(t,r[0],o),max:Y(t,r[1],o)},i,l);if(u===null)return e;const d=$r(u[0]===i?e[0]:re(t,u[0],o),t,r,n,o),m=$r(u[1]===l?e[1]:re(t,u[1],o),t,r,n,o);return[d,m<d?d:m]}const tl=(e,t,r,n,o,a,i)=>{if(an(e,t,r),r===void 0||r.length===0)return null;const l=sn(_l(e,t,r,n,i),Y(n,o,i),Y(n,a,i));if(l.hiIndex<l.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${E(o)}, maxDate: ${E(a)}, entries: ${r.length})`);return l},ei=(e,t,r)=>{const n=sn(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},ti=e=>e.hiIndex<e.loIndex,zd=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Qt(o,t,r);a!==null&&(n===null||(r===1?a<n:a>n))&&(n=a)}return n},edge:t=>{let r=null;for(const n of e){const o=Tn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Et=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),rl=(e,t,r,n,o)=>{if(!Nt(r)||r.length!==2)throw new RangeError(`${e}: ${t} must be a [start, end] tuple of Dates (received: ${E(r)})`);const a=Xt(e,`${t}[0]`,r[0],n,o),i=Xt(e,`${t}[1]`,r[1],n,o);if(i<a)throw new RangeError(`${e}: ${t} must not be inverted at ${n} resolution (start: ${E(r[0])}, end: ${E(r[1])})`);return[a,i]},cr=e=>{const t="resolveVernierSelectorSteps";if(typeof e!="object"||e===null)throw new RangeError(`${t}: options must be an object (received: ${E(e)})`);const{row:r,shows:n,macroUnit:o,microUnit:a,minDate:i,maxDate:l,macroRange:u,microSelection:d}=e;if(r!=="macro"&&r!=="micro")throw new RangeError(`${t}: row must be "macro" or "micro" (received: ${E(r)})`);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${E(n)})`);Ce(t,"macroUnit",o),Ce(t,"microUnit",a);const m=hr(t,e.yearStartMonth);for(const[C,K]of[["minDate",i],["maxDate",l]])if(!ye(K))throw new RangeError(`${t}: ${C} must be a valid Date (received: ${E(K)})`);if(l.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${E(i)}, maxDate: ${E(l)})`);Xt(t,"minDate",i,o,m),Xt(t,"minDate",i,a,m),Cr(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const M=rl(t,"macroRange",u,o,m);if(u[1].getTime()<u[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${E(u[0])}, end: ${E(u[1])})`);const L=rl(t,"microSelection",d,a,m),g=tl(t,"macroAllowedDates",e.macroAllowedDates,o,i,l,m),O=tl(t,"microAllowedDates",e.microAllowedDates,a,i,l,m),p=[u[0],u[1]],w=[d[0],d[1]],h=C=>{const K=$t(o,a,[C[0],C[1]],i,l,m);return[Y(a,K[0],m),Y(a,K[1],m)]},S=(C,K)=>{if(O!==null){const _=ei(O,C,K);if(!ti(_))return _}return{kind:"range",min:C,max:K}},v=(C,K)=>{const _=Et(C,p)?p:C;return _===p&&Et(K,w)?null:{macroRange:_,microSelection:K}};if(e.row==="macro"){const C=g??{kind:"range",min:Y(o,i,m),max:Y(o,l,m)},K=xo(C),_=($,W)=>{const N=$t(o,a,$,i,l,m);return Xr(w,a,N,On(N,a,O,m),m,W)},y=($,W)=>{const N=Ua(K,M[0],M[1],$,Ka(W,n));if(N===null)return null;const V=qa(N,M,p,o,m,W.motion==="single");if(V===null)return null;const H=[ke(V[0],i,l),ke(V[1],i,l)],Z=Math.sign(N[0]-M[0])===$&&Math.sign(N[1]-M[1])===$;return v(H,_(H,Z?"pan":"resize"))};return{previous:y(-1,e.rules.previous),next:y(1,e.rules.next)}}const f=h(p);let te=[Y(a,i,m),Y(a,l,m)];if(g!==null){const C=h([re(o,g.ascending[g.loIndex],m),re(o,g.ascending[g.hiIndex],m)]);te=[Math.min(C[0],f[0]),Math.max(C[1],f[1])]}const ce=O===null?null:ei(O,te[0],te[1]);let B=xo({kind:"range",min:te[0],max:te[1]});if(ce!==null&&!ti(ce)){const C=S(f[0],f[1]);B=C.kind==="candidates"?xo(ce):zd([ce,C])}const U=C=>{if(g===null)return[ke(Rt(o,C[0],m),i,l),ke(Rt(o,C[1],m),i,l)];const K=So(g,Y(o,C[0],m),-1),_=So(g,Y(o,C[1],m),1);return K===null||_===null?null:[ke(re(o,K,m),i,l),ke(re(o,_,m),i,l)]},oe=(C,K,_)=>{const[y,$]=h(C),W=S(y,$),N=Z=>{const be=Y(a,Z,m);if(Cn(W,be))return Z;const Q=So(W,be,_);return Q===null?null:re(a,Q,m)},V=N(K[0]),H=N(K[1]);return V===null||H===null?null:[V,H.getTime()<V.getTime()?V:H]},z=(C,K)=>C>=f[0]&&K<=f[1],ne=(C,K)=>{const _=Ua(B,L[0],L[1],C,Ka(K,n));if(_===null)return null;const y=qa(_,L,w,a,m,K.motion==="single");if(y===null)return null;const $=K.window!=="follow",W=$&&z(_[0],_[1])?p:U(y);if(W===null)return null;const N=oe(W,y,C);if(N===null)return null;const V=$&&z(Y(a,N[0],m),Y(a,N[1],m))?p:U(N);return V===null?null:v(V,N)};return{previous:ne(-1,e.rules.previous),next:ne(1,e.rules.next)}};function ri(e,t,r){if(!ye(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${E(r)})`)}function Le(e,t,r,n,o){ri(e,t,r),Ke(e,t,r,n,o,"")}function Jo(e,t,r,n,o){if(ri(e,"minDate",t),ri(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${E(t)}, maxDate: ${E(r)})`);for(const a of n)Ke(e,"minDate",t,a,o,pl)}function ur(e,t,r,n,o){if(!Nt(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${E(r)})`);if(Le(e,`${t}[0]`,r[0],n,o),Le(e,`${t}[1]`,r[1],n,o),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${E(r[0])}, upper: ${E(r[1])})`)}function ko(e,t,r,n,o,a,i,l){const u=Y(r,n,l);if(u<Y(r,o,l)||u>Y(r,a,l))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${E(n)}, lower: ${E(o)}, upper: ${E(a)})`)}function No(e,t,r,n,o,a,i,l){ko(e,`${t}[0]`,r,n[0],o,a,i,l),ko(e,`${t}[1]`,r,n[1],o,a,i,l)}function Vo(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${E(r)}, upper: ${E(n)})`)}function en(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${E(r)})`)}function Ut(e,t,r,n,o,a){const i=bl(e,t,r);return ye(i)&&Fn(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function Oo(e,t,r,n,o){const a=De(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function Ln(e,t,r,n,o,a){const i=ke(e,r,n);if(o.length===0)return i;const l=o[De(o,i,t,a)];return Y(t,l,a)===Y(t,i,a)?i:ke(l,r,n)}function ja(e,t,r,n,o,a){const i=Ln(e[0],t,r,n,o,a),l=Ln(e[1],t,r,n,o,a);return[i,l<i?i:l]}function _n(e,t){return t[0]===e[0]&&t[1]===e[1]?e:t}const Bd={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function zt(e,t){return t.length===0?{}:{[Bd[e]]:t}}function ea(e){const t=s.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(l=>Object.is(r[l],n[l]))||(t.current=e),t.current}const Zt={previous:null,next:null},Wd=["motion","edge","window"];function Yn(e){const t=s.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Wd.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const Po=(e,t)=>e.getTime()===t.getTime();function tn(e,t,r,n){if(!r(e.current,t))e.current=t;else if(e.holdsHanded)return;e.hand(e.current),n(e.current)}function rn(e,t,r){e.current=t,e.hand(t),r(t)}function Gd(e,t){return typeof t=="function"?t(e):t}function nn(e){return s.useReducer(Gd,void 0,e)}function on(e,t,r,n){r===t||e.current!==r||(e.forgetHanded(t),n(o=>o===t?r:o))}function Kd(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:l,selectorStep:u,...d}=e;Ce("usePeriodSliderRange","unit",t);const m=hr("usePeriodSliderRange",i);Jo("usePeriodSliderRange",r,n,[t],m),ur("usePeriodSliderRange","initialRange",o,t,m),u!==void 0&&Cr("usePeriodSliderRange","selectorStep",u,"motion");const M=ea(d),L=r.getTime(),g=n.getTime(),O=s.useMemo(()=>mr("usePeriodSliderRange",Go(M.allowedDates),t,r,n,m).dates,[M.allowedDates,t,L,g,m]),p=s.useRef(o),[w,h]=nn(()=>(No("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",m),_n(o,ja(o,t,r,n,O,m)))),S=Qo("usePeriodSliderRange",[w]);ur("usePeriodSliderRange","range",w,t,m);const v=_n(w,ja(w,t,r,n,O,m)),f=Qr(S,0,v,h);s.useLayoutEffect(()=>{on(f,w,v,h)});const te=Jr(S,0,o),ce=mt({minDate:r,maxDate:n,candidates:O}),B=mt(a),U=s.useCallback(Q=>{const{minDate:se,maxDate:ve,candidates:ee}=ce.current,ae=ja(Q,t,se,ve,ee,m);tn(f,ae,Et,h);const ge=te.current;ae[0].getTime()===ge[0].getTime()&&ae[1].getTime()===ge[1].getTime()||(te.current=ae,S.notify(0,()=>B.current?.(ae[0],ae[1])))},[t,m]),oe=s.useCallback(Q=>{const se=typeof Q=="function"?Q(f.current):Q;te.current=se,rn(f,se,h)},[]),z=s.useCallback(Q=>{Le("usePeriodSliderRange","setLowerDate(date)",Q,t,m);const se=f.current,ve=Q.getTime()>se[1].getTime()?Q:se[1];U([Q,ve])},[U,t,m]),ne=s.useCallback(Q=>{Le("usePeriodSliderRange","setUpperDate(date)",Q,t,m);const se=f.current,ve=Q.getTime()<se[0].getTime()?Q:se[0];U([ve,Q])},[U,t,m]),C=s.useCallback((Q,se)=>{Le("usePeriodSliderRange","sliderProps.onChangeRange(lower)",Q,t,m),Le("usePeriodSliderRange","sliderProps.onChangeRange(upper)",se,t,m),Vo("usePeriodSliderRange","sliderProps.onChangeRange",Q,se),U([Q,se])},[U,t,m]),K=s.useCallback(Q=>{en("usePeriodSliderRange","shiftRange",Q);const{minDate:se,maxDate:ve,candidates:ee}=ce.current,ae=f.current;if(ee.length>0){U([Oo(ee,t,ae[0],Q,m),Oo(ee,t,ae[1],Q,m)]);return}U([Ut(t,ae[0],Q,se,ve,m).date,Ut(t,ae[1],Q,se,ve,m).date])},[t,U,m]),_=s.useCallback(()=>{U(p.current)},[U]),y=Yn(u),$=y!==void 0,W=s.useMemo(()=>{if(y===void 0)return{start:Zt,end:Zt};const Q=O.length>0?M.allowedDates:void 0,se={selection:v,unit:t,yearStartMonth:m,minDate:r,maxDate:n,allowedDates:Q,rules:y};return{start:Xa({...se,shows:"start"}),end:Xa({...se,shows:"end"})}},[y,v,t,m,L,g,O,M.allowedDates]),N=Ft(W.start,U),V=Ft(W.end,U),H=s.useMemo(()=>({value:v[0],onChange:z,minDate:r,maxDate:v[1],unit:t,yearStartMonth:m,...zt(t,O),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...$?{stepper:N}:{}}),[v[0],v[1],z,r,t,m,O,e.formatLocale,e.locale,e.labels,l,$,N]),Z=s.useMemo(()=>({value:v[1],onChange:ne,minDate:v[0],maxDate:n,unit:t,yearStartMonth:m,...zt(t,O),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...$?{stepper:V}:{}}),[v[0],v[1],ne,n,t,m,O,e.formatLocale,e.locale,e.labels,l,$,V]),be=s.useMemo(()=>({...M,mode:"range",unit:t,yearStartMonth:m,range:v,minDate:r,maxDate:n,onChangeRange:C}),[M,t,v,r,n,C,m]);return{range:v,lowerDate:v[0],upperDate:v[1],setRange:oe,setLowerDate:z,setUpperDate:ne,shiftRange:K,resetRange:_,startSelectorProps:H,endSelectorProps:Z,sliderProps:be,duringRender:S.duringRender}}function qd(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:l,...u}=e;Ce("usePeriodSliderPoint","unit",t);const d=hr("usePeriodSliderPoint",i);Jo("usePeriodSliderPoint",r,n,[t],d),Le("usePeriodSliderPoint","initialValue",o,t,d);const m=ea(u),M=r.getTime(),L=n.getTime(),g=s.useMemo(()=>mr("usePeriodSliderPoint",Go(m.allowedDates),t,r,n,d).dates,[m.allowedDates,t,M,L,d]),O=s.useRef(o),[p,w]=nn(()=>(ko("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",d),Ln(o,t,r,n,g,d))),h=Qo("usePeriodSliderPoint",[p]);Le("usePeriodSliderPoint","value",p,t,d);const S=Ln(p,t,r,n,g,d),v=Qr(h,0,S,w);s.useLayoutEffect(()=>{on(v,p,S,w)});const f=Jr(h,0,o),te=mt({minDate:r,maxDate:n,candidates:g}),ce=mt(a),B=s.useCallback(y=>{const{minDate:$,maxDate:W,candidates:N}=te.current,V=Ln(y,t,$,W,N,d);tn(v,V,Po,w),V.getTime()!==f.current.getTime()&&(f.current=V,h.notify(0,()=>ce.current?.(V)))},[t,d]),U=s.useCallback(y=>{const $=typeof y=="function"?y(v.current):y;f.current=$,rn(v,$,w)},[]),oe=s.useCallback(y=>{Le("usePeriodSliderPoint","selectorProps.onChange(date)",y,t,d),B(y)},[B,t,d]),z=s.useCallback(y=>{Le("usePeriodSliderPoint","sliderProps.onChangePoint(value)",y,t,d),B(y)},[B,t,d]),ne=s.useCallback(y=>{en("usePeriodSliderPoint","shiftValue",y);const{minDate:$,maxDate:W,candidates:N}=te.current;if(N.length>0){B(Oo(N,t,v.current,y,d));return}B(Ut(t,v.current,y,$,W,d).date)},[t,B,d]),C=s.useCallback(()=>{B(O.current)},[B]),K=s.useMemo(()=>({value:S,onChange:oe,minDate:r,maxDate:n,unit:t,yearStartMonth:d,...zt(t,g),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l}),[S,oe,r,n,t,d,g,e.formatLocale,e.locale,e.labels,l]),_=s.useMemo(()=>({...m,mode:"point",unit:t,yearStartMonth:d,value:S,minDate:r,maxDate:n,onChangePoint:z}),[m,t,S,r,n,z,d]);return{value:S,setValue:U,shiftValue:ne,resetValue:C,selectorProps:K,sliderProps:_,duringRender:h.duringRender}}function Xd(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i,microUnit:l,onChangeMacroRange:u,onChangeMicroRange:d,yearStartMonth:m,formatOption:M,macroSelectorStep:L,microSelectorStep:g,...O}=e;Ce("useVernierSliderRange","unit",t);const p=Jt("useVernierSliderRange","macroUnit",i,t),w=Jt("useVernierSliderRange","microUnit",l,t),h=hr("useVernierSliderRange",m);Jo("useVernierSliderRange",r,n,[p,w,t],h),ur("useVernierSliderRange","initialMacroRange",o,p,h),ur("useVernierSliderRange","initialMicroRange",a,w,h),L!==void 0&&Cr("useVernierSliderRange","macroSelectorStep",L,"motion"),g!==void 0&&Cr("useVernierSliderRange","microSelectorStep",g,"vernierRange");const S=ea(O),v=s.useRef(o),f=s.useRef(a),[te,ce]=nn(()=>(No("useVernierSliderRange","initialMacroRange",p,o,r,n,"[minDate, maxDate]",h),o)),[B,U]=nn(()=>{const P=$t(p,w,o,r,n,h);return No("useVernierSliderRange","initialMicroRange",w,a,P[0],P[1],"the initial macro window",h),a}),oe=Qo("useVernierSliderRange",[te,B]);ur("useVernierSliderRange","macroRange",te,p,h);const z=_n(te,[ke(te[0],r,n),ke(te[1],r,n)]),ne=r.getTime(),C=n.getTime(),K=s.useMemo(()=>$t(p,w,z,r,n,h),[p,w,z,ne,C,h]),_=s.useMemo(()=>jt("micro",S)?ci("useVernierSliderRange",Lt("micro",S),w,r,n,h):null,[S.microIsDiscrete,S.microAllowedDates,S.allowedDates,w,ne,C,h]),y=s.useMemo(()=>jt("macro",S)?mr("useVernierSliderRange",Lt("macro",S),p,r,n,h).dates:[],[S.macroIsDiscrete,S.macroAllowedDates,S.allowedDates,p,ne,C,h]),$=mt(y),W=s.useMemo(()=>On(K,w,_,h),[K,w,_,h]),N=s.useMemo(()=>kn(_,W),[_,W]);ur("useVernierSliderRange","microRange",B,w,h);const V=_n(B,Xr(B,w,K,W,h,"resize")),H=Qr(oe,0,z,ce),Z=Qr(oe,1,V,U);s.useLayoutEffect(()=>{on(H,te,z,ce),on(Z,B,V,U)});const be=Jr(oe,1,a),Q=Jr(oe,0,o),se=mt({minDate:r,maxDate:n}),ve=mt(u),ee=mt(d),ae=s.useCallback(P=>{const{minDate:j,maxDate:fe}=se.current;return $t(p,w,P,j,fe,h)},[p,w,h]),ge=s.useCallback(P=>On(P,w,_,h),[w,_,h]),Ne=s.useCallback(P=>{tn(H,P,Et,ce);const j=Q.current;P[0].getTime()===j[0].getTime()&&P[1].getTime()===j[1].getTime()||(Q.current=P,oe.notify(0,()=>ve.current?.(P[0],P[1])))},[]),ft=s.useCallback(P=>{const j=typeof P=="function"?P(H.current):P;Q.current=j,rn(H,j,ce)},[]),me=s.useCallback((P,j,fe)=>{const Ve=fe==="micro"&&Et(H.current,P)&&Et(Q.current,P),Pe=fe==="macro"&&Et(Z.current,j)&&Et(be.current,j);if(Ve||Ne(P),Pe)return;tn(Z,j,Et,U);const Oe=be.current;(j[0].getTime()!==Oe[0].getTime()||j[1].getTime()!==Oe[1].getTime())&&(be.current=j,oe.notify(1,()=>ee.current?.(j[0],j[1])))},[Ne]),A=s.useCallback(P=>{const j=typeof P=="function"?P(Z.current):P;be.current=j,rn(Z,j,U)},[]),X=s.useCallback((P,j,fe)=>{const{minDate:Ve,maxDate:Pe}=se.current,Oe=[ke(P,Ve,Pe),ke(j,Ve,Pe)],Xe=ae(Oe);me(Oe,Xr(Z.current,w,Xe,ge(Xe),h,fe),"macro")},[w,ae,ge,me,h]),ue=s.useCallback((P,j)=>X(P,j,"resize"),[X]),Ye=s.useCallback((P,j)=>{Le("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",P,p,h),Le("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",j,p,h),Vo("useVernierSliderRange","sliderProps.onChangeMacroRange",P,j);const{minDate:fe,maxDate:Ve}=se.current,Pe=[ke(P,fe,Ve),ke(j,fe,Ve)],Oe=Z.current,Xe=ae(Pe),Tt=Xr(Oe,w,Xe,ge(Xe),h,"resize");if(Tt[0].getTime()!==Oe[0].getTime()||Tt[1].getTime()!==Oe[1].getTime()){Ne(Pe);return}me(Pe,Oe,"macro")},[p,w,ae,ge,Ne,me,h]),Se=s.useCallback((P,j)=>{const fe=ae(H.current);me(H.current,Xr([P,j],w,fe,ge(fe),h,"resize"),"micro")},[w,ae,ge,me,h]),it=s.useCallback((P,j)=>{Le("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",P,w,h),Le("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",j,w,h),Vo("useVernierSliderRange","sliderProps.onChangeMicroRange",P,j),Se(P,j)},[Se,w,h]),Ue=s.useCallback(P=>{Le("useVernierSliderRange","setMacroLowerDate(date)",P,p,h);const j=H.current[1],fe=P>j?P:j;ue(P,fe)},[ue,p,h]),ze=s.useCallback(P=>{Le("useVernierSliderRange","setMacroUpperDate(date)",P,p,h);const j=H.current[0],fe=P<j?P:j;ue(fe,P)},[ue,p,h]),Ge=s.useCallback(P=>{Le("useVernierSliderRange","setMicroLowerDate(date)",P,w,h);const j=Z.current[1],fe=P>j?P:j;Se(P,fe)},[Se,w,h]),ie=s.useCallback(P=>{Le("useVernierSliderRange","setMicroUpperDate(date)",P,w,h);const j=Z.current[0],fe=P<j?P:j;Se(fe,P)},[Se,w,h]),tt=s.useCallback(P=>{en("useVernierSliderRange","shiftMacroRange",P);const{minDate:j,maxDate:fe}=se.current,Ve=H.current,Pe=$.current;if(Pe.length>0){const Tt=De(Pe,Ve[0],p,h)+P,je=De(Pe,Ve[1],p,h)+P;if(Tt<0||je>Pe.length-1)return;X(Pe[Tt],Pe[je],"pan");return}const Oe=Ut(p,Ve[0],P,j,fe,h),Xe=Ut(p,Ve[1],P,j,fe,h);Oe.pastDateRange||Xe.pastDateRange||Oe.date<j||Xe.date>fe||X(Oe.date,Xe.date,"pan")},[p,X,h]),st=s.useCallback(P=>{en("useVernierSliderRange","shiftMicroRange",P);const j=H.current,fe=Z.current,Ve=ae(j),[Pe,Oe]=Ve,Xe=kn(_,ge(Ve));if(Xe.length>0){const pr=De(Xe,fe[0],w,h)+P,Ct=De(Xe,fe[1],w,h)+P;if(pr<0||Ct>Xe.length-1)return;Se(Xe[pr],Xe[Ct]);return}const Tt=Ut(w,fe[0],P,Pe,Oe,h),je=Ut(w,fe[1],P,Pe,Oe,h);Tt.pastDateRange||je.pastDateRange||Y(w,Tt.date,h)<Y(w,Pe,h)||Y(w,je.date,h)>Y(w,Oe,h)||Se(Tt.date,je.date)},[w,_,ae,ge,Se,h]),qe=s.useCallback(()=>{const{minDate:P,maxDate:j}=se.current,fe=[ke(v.current[0],P,j),ke(v.current[1],P,j)],Ve=ae(fe);me(fe,Xr(f.current,w,Ve,ge(Ve),h,"resize"),"both")},[w,ae,ge,me,h]),_e=Yn(L),Ee=Yn(g),rt=_e!==void 0,lt=Ee!==void 0,pt=s.useMemo(()=>{const P={macroUnit:p,microUnit:w,yearStartMonth:h,minDate:r,maxDate:n,macroRange:z,microSelection:V,macroAllowedDates:jt("macro",S)?Lt("macro",S).list:void 0,microAllowedDates:jt("micro",S)?Lt("micro",S).list:void 0};return{macroStart:_e===void 0?Zt:cr({...P,row:"macro",shows:"start",rules:_e}),macroEnd:_e===void 0?Zt:cr({...P,row:"macro",shows:"end",rules:_e}),microStart:Ee===void 0?Zt:cr({...P,row:"micro",shows:"start",rules:Ee}),microEnd:Ee===void 0?Zt:cr({...P,row:"micro",shows:"end",rules:Ee})}},[_e,Ee,p,w,h,ne,C,z,V,S.macroIsDiscrete,S.macroAllowedDates,S.microIsDiscrete,S.microAllowedDates,S.allowedDates]),bt=s.useCallback(P=>me(P.macroRange,P.microSelection,"macro"),[me]),I=s.useCallback(P=>me(P.macroRange,P.microSelection,"micro"),[me]),J=Ft(pt.macroStart,bt),He=Ft(pt.macroEnd,bt),ht=Ft(pt.microStart,I),pe=Ft(pt.microEnd,I),[Me,gr]=K,Bt=s.useMemo(()=>({value:z[0],onChange:Ue,minDate:r,maxDate:z[1],unit:p,yearStartMonth:h,...zt(p,y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:M,...rt?{stepper:J}:{}}),[z,Ue,r,p,h,y,e.formatLocale,e.locale,e.labels,M,rt,J]),R=s.useMemo(()=>({value:z[1],onChange:ze,minDate:z[0],maxDate:n,unit:p,yearStartMonth:h,...zt(p,y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:M,...rt?{stepper:He}:{}}),[z,ze,n,p,h,y,e.formatLocale,e.locale,e.labels,M,rt,He]),le=s.useMemo(()=>({value:V[0],onChange:Ge,minDate:Me,maxDate:V[1],unit:w,yearStartMonth:h,...zt(w,N),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:M,...lt?{stepper:ht}:{}}),[V,Ge,Me,w,h,N,e.formatLocale,e.locale,e.labels,M,lt,ht]),Re=s.useMemo(()=>({value:V[1],onChange:ie,minDate:V[0],maxDate:gr,unit:w,yearStartMonth:h,...zt(w,N),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:M,...lt?{stepper:pe}:{}}),[V,ie,gr,w,h,N,e.formatLocale,e.locale,e.labels,M,lt,pe]),$e=s.useMemo(()=>({...S,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:p,microUnit:w,minDate:r,maxDate:n,macroRange:z,microRange:V,onChangeMacroRange:Ye,onChangeMicroRange:it}),[S,t,p,w,r,n,z,V,Ye,it,h]);return{macroRange:z,setMacroRange:ft,microRange:V,setMicroRange:A,setMacroLowerDate:Ue,setMacroUpperDate:ze,setMicroLowerDate:Ge,setMicroUpperDate:ie,shiftMacroRange:tt,shiftMicroRange:st,resetVernier:qe,macroStartSelectorProps:Bt,macroEndSelectorProps:R,microStartSelectorProps:le,microEndSelectorProps:Re,sliderProps:$e,duringRender:oe.duringRender}}function Zd(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i,microUnit:l,onChangeMacroRange:u,onChangeMicroPoint:d,yearStartMonth:m,formatOption:M,macroSelectorStep:L,microSelectorStep:g,...O}=e;Ce("useVernierSliderPoint","unit",t);const p=Jt("useVernierSliderPoint","macroUnit",i,t),w=Jt("useVernierSliderPoint","microUnit",l,t),h=hr("useVernierSliderPoint",m);Jo("useVernierSliderPoint",r,n,[p,w,t],h),ur("useVernierSliderPoint","initialMacroRange",o,p,h),Le("useVernierSliderPoint","initialMicroValue",a,w,h),L!==void 0&&Cr("useVernierSliderPoint","macroSelectorStep",L,"motion"),g!==void 0&&Cr("useVernierSliderPoint","microSelectorStep",g,"vernierPoint");const S=ea(O),v=s.useRef(o),f=s.useRef(a),[te,ce]=nn(()=>(No("useVernierSliderPoint","initialMacroRange",p,o,r,n,"[minDate, maxDate]",h),o)),[B,U]=nn(()=>{const R=$t(p,w,o,r,n,h);return ko("useVernierSliderPoint","initialMicroValue",w,a,R[0],R[1],"the initial macro window",h),a}),oe=Qo("useVernierSliderPoint",[te,B]);ur("useVernierSliderPoint","macroRange",te,p,h);const z=_n(te,[ke(te[0],r,n),ke(te[1],r,n)]),ne=r.getTime(),C=n.getTime(),K=s.useMemo(()=>$t(p,w,z,r,n,h),[p,w,z,ne,C,h]),_=s.useMemo(()=>jt("micro",S)?ci("useVernierSliderPoint",Lt("micro",S),w,r,n,h):null,[S.microIsDiscrete,S.microAllowedDates,S.allowedDates,w,ne,C,h]),y=s.useMemo(()=>jt("macro",S)?mr("useVernierSliderPoint",Lt("macro",S),p,r,n,h).dates:[],[S.macroIsDiscrete,S.macroAllowedDates,S.allowedDates,p,ne,C,h]),$=mt(y),W=s.useMemo(()=>On(K,w,_,h),[K,w,_,h]),N=s.useMemo(()=>kn(_,W),[_,W]);Le("useVernierSliderPoint","microValue",B,w,h);const V=$r(B,w,K,W,h),H=Qr(oe,0,z,ce),Z=Qr(oe,1,V,U);s.useLayoutEffect(()=>{on(H,te,z,ce),on(Z,B,V,U)});const be=Jr(oe,1,a),Q=Jr(oe,0,o),se=mt({minDate:r,maxDate:n}),ve=mt(u),ee=mt(d),ae=s.useCallback(R=>{const{minDate:le,maxDate:Re}=se.current;return $t(p,w,R,le,Re,h)},[p,w,h]),ge=s.useCallback(R=>On(R,w,_,h),[w,_,h]),Ne=s.useCallback(R=>{tn(H,R,Et,ce);const le=Q.current;R[0].getTime()===le[0].getTime()&&R[1].getTime()===le[1].getTime()||(Q.current=R,oe.notify(0,()=>ve.current?.(R[0],R[1])))},[]),ft=s.useCallback(R=>{const le=typeof R=="function"?R(H.current):R;Q.current=le,rn(H,le,ce)},[]),me=s.useCallback((R,le,Re)=>{const $e=Re==="micro"&&Et(H.current,R)&&Et(Q.current,R),P=Re==="macro"&&Po(Z.current,le)&&Po(be.current,le);$e||Ne(R),!P&&(tn(Z,le,Po,U),le.getTime()!==be.current.getTime()&&(be.current=le,oe.notify(1,()=>ee.current?.(le))))},[Ne]),A=s.useCallback(R=>{const le=typeof R=="function"?R(Z.current):R;be.current=le,rn(Z,le,U)},[]),X=s.useCallback((R,le)=>{const{minDate:Re,maxDate:$e}=se.current,P=[ke(R,Re,$e),ke(le,Re,$e)],j=ae(P);me(P,$r(Z.current,w,j,ge(j),h),"macro")},[w,ae,ge,me,h]),ue=s.useCallback(R=>{const le=ae(H.current);me(H.current,$r(R,w,le,ge(le),h),"micro")},[w,ae,ge,me,h]),Ye=s.useCallback((R,le)=>{Le("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",R,p,h),Le("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",le,p,h),Vo("useVernierSliderPoint","sliderProps.onChangeMacroRange",R,le);const{minDate:Re,maxDate:$e}=se.current,P=[ke(R,Re,$e),ke(le,Re,$e)],j=Z.current,fe=ae(P);if($r(j,w,fe,ge(fe),h).getTime()!==j.getTime()){Ne(P);return}me(P,j,"macro")},[p,w,ae,ge,Ne,me,h]),Se=s.useCallback(R=>{Le("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",R,w,h),ue(R)},[ue,w,h]),it=s.useCallback(R=>{Le("useVernierSliderPoint","setMacroLowerDate(date)",R,p,h);const le=H.current[1],Re=R>le?R:le;X(R,Re)},[X,p,h]),Ue=s.useCallback(R=>{Le("useVernierSliderPoint","setMacroUpperDate(date)",R,p,h);const le=H.current[0],Re=R<le?R:le;X(Re,R)},[X,p,h]),ze=s.useCallback(R=>{Le("useVernierSliderPoint","setMicroDate(date)",R,w,h),ue(R)},[ue,w,h]),Ge=s.useCallback(R=>{en("useVernierSliderPoint","shiftMacroRange",R);const{minDate:le,maxDate:Re}=se.current,$e=H.current,P=$.current;if(P.length>0){const Ve=De(P,$e[0],p,h)+R,Pe=De(P,$e[1],p,h)+R;if(Ve<0||Pe>P.length-1)return;X(P[Ve],P[Pe]);return}const j=Ut(p,$e[0],R,le,Re,h),fe=Ut(p,$e[1],R,le,Re,h);j.pastDateRange||fe.pastDateRange||j.date<le||fe.date>Re||X(j.date,fe.date)},[p,X,h]),ie=s.useCallback(R=>{en("useVernierSliderPoint","shiftMicroValue",R);const le=H.current,Re=ae(le),$e=kn(_,ge(Re));if($e.length>0){ue(Oo($e,w,Z.current,R,h));return}ue(Ut(w,Z.current,R,Re[0],Re[1],h).date)},[w,_,ae,ge,ue,h]),tt=s.useCallback(()=>{const{minDate:R,maxDate:le}=se.current,Re=[ke(v.current[0],R,le),ke(v.current[1],R,le)],$e=ae(Re);me(Re,$r(f.current,w,$e,ge($e),h),"both")},[w,ae,ge,me,h]),st=Yn(L),qe=Yn(g),_e=st!==void 0,Ee=qe!==void 0,rt=s.useMemo(()=>{const R={macroUnit:p,microUnit:w,yearStartMonth:h,minDate:r,maxDate:n,macroRange:z,microSelection:[V,V],macroAllowedDates:jt("macro",S)?Lt("macro",S).list:void 0,microAllowedDates:jt("micro",S)?Lt("micro",S).list:void 0};return{macroStart:st===void 0?Zt:cr({...R,row:"macro",shows:"start",rules:st}),macroEnd:st===void 0?Zt:cr({...R,row:"macro",shows:"end",rules:st}),micro:qe===void 0?Zt:cr({...R,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:qe.previous.window},next:{motion:"shift",window:qe.next.window}}})}},[st,qe,p,w,h,ne,C,z,V,S.macroIsDiscrete,S.macroAllowedDates,S.microIsDiscrete,S.microAllowedDates,S.allowedDates]),lt=s.useCallback(R=>me(R.macroRange,R.microSelection[0],"macro"),[me]),pt=s.useCallback(R=>me(R.macroRange,R.microSelection[0],"micro"),[me]),bt=Ft(rt.macroStart,lt),I=Ft(rt.macroEnd,lt),J=Ft(rt.micro,pt),[He,ht]=K,pe=s.useMemo(()=>({value:z[0],onChange:it,minDate:r,maxDate:z[1],unit:p,yearStartMonth:h,...zt(p,y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:M,..._e?{stepper:bt}:{}}),[z,it,r,p,h,y,e.formatLocale,e.locale,e.labels,M,_e,bt]),Me=s.useMemo(()=>({value:z[1],onChange:Ue,minDate:z[0],maxDate:n,unit:p,yearStartMonth:h,...zt(p,y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:M,..._e?{stepper:I}:{}}),[z,Ue,n,p,h,y,e.formatLocale,e.locale,e.labels,M,_e,I]),gr=s.useMemo(()=>({value:V,onChange:ze,minDate:He,maxDate:ht,unit:w,yearStartMonth:h,...zt(w,N),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:M,...Ee?{stepper:J}:{}}),[V,ze,He,ht,w,h,N,e.formatLocale,e.locale,e.labels,M,Ee,J]),Bt=s.useMemo(()=>({...S,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:p,microUnit:w,minDate:r,maxDate:n,macroRange:z,microValue:V,onChangeMacroRange:Ye,onChangeMicroPoint:Se}),[S,t,p,w,r,n,z,V,Ye,Se,h]);return{macroRange:z,setMacroRange:ft,microValue:V,setMicroValue:A,setMacroLowerDate:it,setMacroUpperDate:Ue,setMicroDate:ze,shiftMacroRange:Ge,shiftMicroValue:ie,resetVernier:tt,macroStartSelectorProps:pe,macroEndSelectorProps:Me,microSelectorProps:gr,sliderProps:Bt,duringRender:oe.duringRender}}function ni(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function _o(e,t){const r=new Date(e.getTime());return Bo(r.getFullYear(),r.getMonth(),t)}function nl(e){return e===void 0?0:hl(e)?e:Number.NaN}const ol=jn("declare the years to offer with minYear / maxYear or allowedYears");function wo(e,t,r,n){e!==void 0&&Wl(e,t,r,n)}function Wl(e,t,r,n){if(!ye(e))throw new RangeError(`YearSelector: ${t} must be a valid Date (received: ${E(e)})`);Ke("YearSelector",t,e,"year",r,n)}function al(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`YearSelector: ${t} must be an integer year (received: ${E(e)})`);if(Number.isNaN(ni(e,r).getTime()))throw new RangeError(`YearSelector: ${t} must name a year that starts inside the Date range (received: ${E(e)}); under yearStartMonth ${r} that year starts on month ${r+1}, day 1`)}}function il(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:_o(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function Qd(e,t,r,n){const o=new Set;for(const a of e){const i=_o(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function Jd(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:Qd(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function em(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const tm=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,minYear:l,maxYear:u,minDate:d,maxDate:m,allowedYears:M,className:L="",style:g,disabled:O=!1,locale:p,labels:w,formatLocale:h,formatOption:S,yearStartMonth:v}=e,f=hr("YearSelector",v);if(wo(t,"value",f,""),wo(r,"initialDate",f,""),wo(d,"minDate",f,ol),wo(m,"maxDate",f,ol),al(l,"minYear",f),al(u,"maxYear",f),an("YearSelector","allowedYears",M),M!==void 0)for(let ee=0;ee<M.length;ee++)Wl(M[ee],`allowedYears[${ee}]`,f,"");h!==void 0&&Xo("YearSelector","formatLocale",h);const te=t??r;if(te===void 0)throw new RangeError("YearSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected year is never inferred from the wall clock");o!==void 0&&hi("YearSelector",o,t!==void 0);const ce=si("YearSelector",a),B=Uo(p,w),U=t!==void 0,[oe,z]=gi(te,U,ee=>Zo(ee,"year",f),ee=>_o(ee,f)),ne=d?.getTime(),C=m?.getTime(),K=s.useMemo(()=>il(l,d,Math.max,f),[l,ne,f]),_=s.useMemo(()=>il(u,m,Math.min,f),[u,C,f]);if(K!==null&&_!==null&&K>_)throw new RangeError(`YearSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${K}, upper: ${_})`);const y=M===void 0?null:M.map(ee=>ee.getTime()).join(","),$=s.useMemo(()=>Jd(M,K,_,f),[y,K,_,f]);if($===null)throw new RangeError("YearSelector: a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate), or allowedYears, are required; the option list is never invented");const W=s.useMemo(()=>$.kind==="discrete"?{kind:"candidates",ascending:$.ascending,loIndex:0,hiIndex:$.ascending.length-1}:{kind:"range",min:$.minYear,max:$.maxYear},[$]),N=t!==void 0?_o(t,f):oe,V=!Cn(W,N),H=ee=>{if(!O){if(!Cn(W,ee))throw new RangeError(`YearSelector: refusing to emit ${ee}, which lies outside the selectable years`);U||z(ee),n?.(ni(ee,f),ee)}},Z=Qt(W,N,-1),be=Qt(W,N,1),Q=()=>{if(o!==void 0){o.onStep("previous");return}Z!==null&&H(Z)},se=()=>{if(o!==void 0){o.onStep("next");return}be!==null&&H(be)},ve=s.useMemo(()=>{const ee=$.kind==="discrete"?[...$.ascending].reverse():em($.minYear,$.maxYear);return V&&(ee.push(N),ee.sort((ae,ge)=>ge-ae)),ee.map(ae=>({value:ae,label:at("year",ni(ae,f),S,h)}))},[$,V,N,f,h,S]);return T.jsxs("div",{className:`inline-flex items-center ${$n} ${L}`,style:g,"data-out-of-range":V?"true":void 0,children:[T.jsx(Tr,{neighbour:"control",direction:"left",glyph:ce,disabled:O,canStep:o===void 0?Z!==null:o.canStepPrevious,onStep:Q,ariaLabel:B.previousYear}),T.jsx("select",{"aria-label":B.yearSelect,disabled:O,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:N,onChange:ee=>{if(!ee.target.value)return;const ae=Number(ee.target.value);Number.isInteger(ae)&&H(ae)},children:ve.map(ee=>T.jsx("option",{value:ee.value,disabled:V&&ee.value===N,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:ee.label},ee.value))}),T.jsx(Tr,{neighbour:"control",direction:"right",glyph:ce,disabled:O,canStep:o===void 0?be!==null:o.canStepNext,onStep:se,ariaLabel:B.nextYear}),i]})},rm=(e,t)=>{const r=nl(t.yearStartMonth);return!(nl(e.yearStartMonth)!==r||!fi(e,t,n=>Zo(n,"year",r))||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedYears!==t.allowedYears||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.stepGlyph!==t.stepGlyph||e.children!==t.children||e.locale!==t.locale||!Fo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},Gl=s.memo(tm,rm);Gl.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=fl;exports.DateSelector=Fl;exports.MonthSelector=Bl;exports.PERIOD_SLIDER_LABEL_CATALOGS=dl;exports.PERIOD_SLIDER_LABEL_KEYS=jo;exports.PeriodSlider=kl;exports.YearSelector=Gl;exports.addUnit=bl;exports.areStylesEqual=Al;exports.calculateConnectDragValues=xl;exports.calculateHandleDragValues=Ba;exports.calculateKeyboardActionValues=Rl;exports.calculateLabelSlant=qo;exports.calculateVernierMacroDrag=$l;exports.calculateVernierMicroDrag=Tl;exports.decode=re;exports.encode=Y;exports.findNearestDateIndex=De;exports.formatLabel=at;exports.formatOptionText=Nl;exports.formatQuarterLabel=ku;exports.formatScreenReaderLabel=Pr;exports.getMacroWindowEndDate=vl;exports.getMacroWindowStartDate=wl;exports.getSortedAllowedDates=Nu;exports.normalizeDateByUnit=Rt;exports.resolveDraggedEdge=Ho;exports.resolveMacroWindow=$t;exports.resolvePeriodSliderLabels=ml;exports.resolveQuarter=Sl;exports.resolveSelectorSteps=Xa;exports.resolveVernierRailZone=mi;exports.resolveVernierSelectorSteps=cr;exports.resolveVernierTargetHandle=Ll;exports.resolveWheelStep=Pl;exports.usePeriodSliderPoint=qd;exports.usePeriodSliderRange=Kd;exports.useSelectorStepper=Ft;exports.useVernierSliderPoint=Zd;exports.useVernierSliderRange=Xd;
|