@aiquants/virtualscroll 3.7.1 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react/jsx-runtime"),t=require("react"),It=require("tailwind-merge"),qr=["en","ja"],Tr=["scrollUp","scrollDown","scrollLeft","scrollRight","scrollToTop","scrollToBottom","noItems"],bn=Object.freeze({en:Object.freeze({scrollUp:"Scroll up",scrollDown:"Scroll down",scrollLeft:"Scroll left",scrollRight:"Scroll right",scrollToTop:"Top",scrollToBottom:"Bottom",noItems:"No items"}),ja:Object.freeze({scrollUp:"上へスクロール",scrollDown:"下へスクロール",scrollLeft:"左へスクロール",scrollRight:"右へスクロール",scrollToTop:"先頭へ",scrollToBottom:"末尾へ",noItems:"項目がありません"})}),On=r=>qr.includes(r),Lr=r=>typeof r=="string"?JSON.stringify(r):r===null?"null":typeof r,xn=r=>{if(r===void 0)return"en";if(On(r))return r;const e=qr.map(n=>JSON.stringify(n)).join(", ");throw new RangeError(`[virtualscroll] locale must be one of ${e}; got ${Lr(r)}`)},_n=r=>Tr.includes(r),Yr=(r,e)=>{const n=bn[xn(r)];if(e===void 0)return n;if(e===null||typeof e!="object")throw new RangeError(`[virtualscroll] labels must be an object; got ${Lr(e)}`);const s=Object.getPrototypeOf(e);if(s!==Object.prototype&&s!==null)throw new RangeError(`[virtualscroll] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(e)?"an array":"an object with a non-plain prototype"}`);const i=new Set(Object.keys(e));for(const o of i)if(!_n(o))throw new RangeError(`[virtualscroll] labels.${o} is not a known label key; expected one of ${Tr.join(", ")}`);const a={...n};for(const o of Tr){const u=i.has(o)?e[o]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[virtualscroll] labels.${o} must be a non-blank string; got ${Lr(u)}`);a[o]=u}}return Object.freeze(a)};class k{level;prefix;impl;constructor(e=2,n="[virtualscroll]",s=console){this.level=e,this.prefix=n,this.impl=s}static instance=new k(2,"[virtualscroll]");static setLevel(e){k.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){k.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){k.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return k.instance.isEnabled(e)}isEnabled(e){return this.level<=e}static resolveLazy(e){if(typeof e!="function")return e;try{return e()}catch{return e}}formatMessage(e){return typeof e=="string"?[`${this.prefix} ${e}`]:[this.prefix,e]}static debug(e,...n){k.instance.debug(e,...n)}debug(e,...n){this.level<=0&&this.impl.debug(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static info(e,...n){k.instance.info(e,...n)}info(e,...n){this.level<=1&&this.impl.info(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static warn(e,...n){k.instance.warn(e,...n)}warn(e,...n){this.level<=2&&this.impl.warn(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static error(e,...n){k.instance.error(e,...n)}error(e,...n){this.level<=3&&this.impl.error(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}}const vn=r=>typeof r.setPointerCapture=="function"&&typeof r.releasePointerCapture=="function"&&typeof r.hasPointerCapture=="function",Sn=(r,e)=>vn(r)&&r.hasPointerCapture(e),hr=(r,e)=>{if(!vn(r))return"unsupported";try{return r.setPointerCapture(e),"captured"}catch(n){return(typeof n=="object"&&n!==null&&"name"in n?n.name:void 0)==="NotFoundError"?"inactive-pointer":"rejected"}},Jt=(r,e)=>{Sn(r,e)&&r.releasePointerCapture(e)},sn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Rr=6,Fn=8,Hn=({dragState:r,normalizedDistance:e})=>{const n=1+e*.18,s=.16+e*.24,i=.38+e*.28,a=r.active?"80ms ease-out":"220ms ease";return V.jsxs(V.Fragment,{children:[V.jsx("div",{className:"aqvs-tap-scroll-circle-visual-outer",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.62), rgba(72,72,72,0.48))",boxShadow:`0 0 0 1px rgba(255,255,255,0.28), 0 10px 22px rgba(0,0,0,${s})`,transform:`scale(${n})`,transition:`${a}, ${r.active?"80ms":"260ms"} box-shadow ease`}}),V.jsx("div",{className:"aqvs-tap-scroll-circle-inner",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.72), rgba(28,28,28,0.58))",boxShadow:"inset 0 4px 10px rgba(0,0,0,0.24), inset 0 0 2px rgba(255,255,255,0.55)",opacity:i,transition:r.active?"120ms opacity ease-out":"220ms opacity ease"}})]})},Br=t.memo(t.forwardRef(({onDragChange:r,className:e,maxVisualDistance:n=160,size:s=40,style:i,opacity:a=1,renderVisual:o,axis:u="y"},m)=>{const[g,b]=t.useState(sn),I=t.useRef(null),y=t.useRef(null),S=t.useRef({x:0,y:0}),P=t.useRef(null),W=t.useRef(0),_=t.useCallback(M=>{b(M),r(M)},[r]),Re=t.useCallback((M,ee,te=!1)=>{const{x:_e,y:ce}=S.current,qe=M-_e,pe=ee-ce;let J,Ue;if(u==="xy")J=Math.hypot(qe,pe),Ue=J<Rr?0:1;else{const Fe=u==="x"?qe:pe;J=Math.abs(Fe),Ue=J<Rr?0:Fe<0?-1:1}const rt=W.current;let Ge=Ue;const pt=Rr+Fn;Ue===0?rt!==0&&J<pt?Ge=rt:(Ge=0,te||(W.current=0)):Ue!==rt&&rt!==0&&J<pt?Ge=rt:W.current=Ue,_({active:te||J>=Rr,offsetX:qe,offsetY:pe,distance:J,direction:Ge,pointerId:I.current})},[_,u]),Te=t.useCallback(M=>{if(M===null)return;const ee=P.current;ee!==null&&Jt(ee,M)},[]),A=t.useCallback((M=!1)=>{M&&Te(I.current),I.current=null,y.current=null,W.current=0,_(sn)},[_,Te]),F=t.useCallback(M=>{if(I.current!==null&&I.current!==M.pointerId){y.current={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY},M.preventDefault(),M.stopPropagation();return}M.preventDefault(),M.stopPropagation();const ee=P.current??M.currentTarget,{left:te,top:_e,width:ce,height:qe}=ee.getBoundingClientRect();S.current={x:te+ce/2,y:_e+qe/2},I.current=M.pointerId,hr(ee,M.pointerId),Re(M.clientX,M.clientY,!0)},[Re]),ae=t.useCallback(M=>{if(I.current!==M.pointerId){y.current!==null&&y.current.pointerId===M.pointerId&&(y.current={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY});return}M.preventDefault(),Re(M.clientX,M.clientY)},[Re]),L=t.useCallback(M=>{if(I.current!==M.pointerId){y.current!==null&&y.current.pointerId===M.pointerId&&(y.current=null);return}M.preventDefault(),M.stopPropagation();const ee=y.current;if(y.current=null,ee!==null){Te(M.pointerId);const te=P.current;if(te===null||hr(te,ee.pointerId)!=="inactive-pointer"){I.current=ee.pointerId,Re(ee.clientX,ee.clientY,!0);return}}A(!0)},[A,Te,Re]),T=t.useCallback(M=>{M.target===M.currentTarget&&I.current===M.pointerId&&A(!1)},[A]);t.useImperativeHandle(m,()=>({reset:()=>{A(!0)},getElement:()=>P.current}),[A]);const z=Math.min(Math.max(a,0),1),U=s/64,Y=Math.min(g.distance,n)/n,H=g.direction*Y*10*U;let K;if(u==="xy"){const M=g.distance,ee=M===0?0:H*g.offsetX/M,te=M===0?0:H*g.offsetY/M;K=`translate(${ee}px, ${te}px)`}else u==="x"?K=`translateX(${H}px)`:K=`translateY(${H}px)`;const re=o??Hn,he={dragState:g,normalizedDistance:Y,sizeScale:U,size:s,opacity:z},Oe={...i,width:s,height:s,transform:K};return Oe.opacity=z,V.jsx("div",{ref:P,"data-testid":"virtual-scroll-tap-circle",className:It.twMerge("aqvs-tap-scroll-circle",e),style:Oe,tabIndex:-1,onPointerDown:F,onPointerMove:ae,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:T,role:"presentation",children:re(he)})}));Br.displayName="TapScrollCircle";const Q=(r,e,n)=>Math.max(e,Math.min(n,r)),Dr=(r,e)=>{const n=e==="x",s=r.getBoundingClientRect(),i=n?s.width:s.height,a=b=>{const I=Number.parseFloat(b);return Number.isFinite(I)?I:0},o=window.getComputedStyle(r),u=a(n?o.width:o.height),m=u>0?u+a(n?o.paddingLeft:o.paddingTop)+a(n?o.paddingRight:o.paddingBottom)+a(n?o.borderLeftWidth:o.borderTopWidth)+a(n?o.borderRightWidth:o.borderBottomWidth):0,g=m>0?m:n?r.offsetWidth:r.offsetHeight;return g<=0||i<=0?1:i/g},pr="virtualscroll:tap-scroll-cancel",an=20,Xn=250,$n=60,qn=20,Yn=20,jr={maxDistance:240,minSpeedMultiplier:.2},Bn=jr.maxDistance,on={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Nr=2.2,jn=8,Wn=120,wn=1/10,Ot={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:Bn,minSpeedMultiplier:jr.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},Un=r=>r?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,n)=>e,getPointerCoordinate:({clientX:e})=>e,arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,n)=>n,getPointerCoordinate:({clientY:e})=>e,arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},Or=(r,e)=>{const n=r?.maxSpeedMultiplier,s=typeof n=="number"?n:Rn(e);return{enabled:r?.enabled??Ot.enabled,size:r?.size??Ot.size,offsetX:r?.offsetX??Ot.offsetX,offsetY:r?.offsetY??Ot.offsetY,className:r?.className??Ot.className,maxVisualDistance:r?.maxVisualDistance??Ot.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??Ot.minSpeedMultiplier,0),opacity:Q(r?.opacity??Ot.opacity,0,1),renderVisual:r?.renderVisual??Ot.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??Ot.maxSpeedCurve}},Gn=({isDragging:r,isThumbHovered:e,enableThumbDrag:n})=>t.useMemo(()=>n?r?"dragging":e?"hover":"idle":"disabled",[n,r,e]),Kn=({canUseArrowButtons:r,enableArrowButtons:e,resetTapScroll:n,scrollByStep:s})=>{const i=t.useRef(null),a=t.useRef(null),o=t.useRef(null),u=t.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null),a.current!==null&&(window.clearTimeout(a.current),a.current=null),o.current!==null&&(window.removeEventListener("pointerup",o.current),window.removeEventListener("pointercancel",o.current),window.removeEventListener("blur",o.current),o.current=null)},[]),m=t.useCallback(()=>{u()},[u]),g=t.useCallback(I=>y=>{if(!r)return;y.cancelable&&y.preventDefault(),y.stopPropagation(),n(),u(),s(I),a.current=window.setTimeout(()=>{i.current=window.setInterval(()=>{s(I)},$n)},Xn);const S=()=>u();o.current=S,window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S)},[r,u,n,s]),b=t.useCallback(I=>y=>{e&&(y.key==="Enter"||y.key===" "||y.key==="Spacebar")&&(y.preventDefault(),s(I))},[e,s]);return t.useEffect(()=>{r||u()},[r,u]),t.useEffect(()=>()=>{u()},[u]),{handleArrowPointerDown:g,handleArrowPointerUp:m,handleArrowKeyDown:b}},Zn=700,Qt=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,Er=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:a,curve:o})=>{const u=Math.max(Qt(r,0),0),m=Qt(e,0),g=m>0?Math.min(u,m)/m:1,b=Math.max(Qt(n,0),0),I=Math.max(Qt(s,0),0),y=Math.max(Qt(i,0),0),S=Math.max(b*I,40),P=a?S:1200,W=Math.max(b*y,P),_=o?Math.max(Qt(o.exponentialScale,y),0):0,Re=o?Math.min(W,Math.max(b*_,S)):W,Te=Math.max(Re,S);let A=g**1.1;if(o){const ae=Math.min(Math.max(Qt(o.exponentialSteepness,0),0),Zn);if(ae===0)A=g;else{const L=Math.expm1(ae)||1;A=Math.min(Math.max(Math.expm1(ae*g)/L,0),1)}}const F=Math.min(Math.max(Qt(o?.easedOffset,0),0),1);return S+(Te-S)*(F+(1-F)*A)},Rn=r=>{if(!r||r<=0)return Nr;const e=Math.max(1,r),n=Math.log10(e),s=Nr+n*jn;return Q(s,Nr,Wn)},Wr=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:a=!0,enableArrowButtons:o=!0,horizontal:u=!1,enableHorizontalTapCircle:m=!1,stretchMainSize:g=!1,scrollBarWidth:b=12,className:I,ariaControls:y,tapScrollCircleOptions:S,itemCount:P,renderThumbOverlay:W,visibleStartIndex:_,visibleEndIndex:Re,locale:Te,labels:A})=>{const[F,ae]=t.useState(!1),[L,T]=t.useState(!1),[z,U]=t.useState(!1),Y=t.useRef(null),H=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),K=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),re=t.useRef(n),he=t.useRef(s),Oe=t.useRef(on),M=t.useRef(null),ee=t.useRef(null),te=t.useRef(null),_e=t.useRef(0),ce=t.useRef(0),qe=t.useMemo(()=>Or(S,P),[P,S]),pe=t.useMemo(()=>Un(u),[u]),J=t.useMemo(()=>Yr(Te,A),[Te,A]),Ue=u?[J.scrollLeft,J.scrollRight]:[J.scrollUp,J.scrollDown],{enabled:rt,size:Ge,offsetX:pt,offsetY:Fe,className:He,maxVisualDistance:Ee,maxSpeedMultiplier:nt,minSpeedMultiplier:Z,opacity:ke,renderVisual:Me,maxSpeedCurve:oe}=qe,ge=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(Ee,1),tapCircleMaxSpeedMultiplier:nt,tapCircleMinSpeedMultiplier:Z,tapCircleMaxSpeedCurve:oe,tapScrollCircleOptions:S,effectiveTrackLength:0,onScroll:s,scrollPosition:n}),{mainSizeKey:ue,crossSizeKey:ft,positionKey:w,selectDelta:Ve,getPointerCoordinate:de,arrowIcons:O,directionClass:at,orientation:Ke}=pe,Tt=Math.max(Ee,1),gt=e/r,x=Math.max(e-b*2,0),N=gt*x,le=Math.min(Math.max(an,N||0),x||an),G=Math.max(r-e,0),ne=Math.max(x-le,0),fe=G<=0||ne<=0?0:Q(n/G*ne,0,ne),Ye=fe+le/2,be=r>e||F,Xe=be&&o;t.useLayoutEffect(()=>{ge.current={viewportSize:e,maxScrollPosition:G,scrollBarVisible:be,effectiveTapMaxDistance:Tt,tapCircleMaxSpeedMultiplier:nt,tapCircleMinSpeedMultiplier:Z,tapCircleMaxSpeedCurve:oe,tapScrollCircleOptions:S,effectiveTrackLength:ne,onScroll:s,scrollPosition:n}}),t.useLayoutEffect(()=>{re.current=n},[n]),t.useLayoutEffect(()=>{he.current=s},[s]),t.useEffect(()=>{i||T(!1)},[i]);const Se=Gn({isDragging:F,isThumbHovered:L,enableThumbDrag:i}),Ae=t.useCallback((d,E)=>{const D=ge.current,se=E??re.current;if(he.current){const je=he.current(d,se);if(typeof je=="number"&&Number.isFinite(je))return re.current=je,je}const De=typeof d=="function"?d(se):d,Be=Math.max(D.maxScrollPosition,0),ut=D.scrollBarVisible?Q(De,0,Be):0;return re.current=ut,ut},[]),ct=t.useCallback(d=>{const E=ge.current,D=re.current;if(!E.scrollBarVisible||E.maxScrollPosition<=0){const vt=Ae(0,D),kt=vt-D;return{nextPosition:vt,actualDelta:kt,reachedBoundary:!0}}if(d===0)return{nextPosition:D,actualDelta:0,reachedBoundary:!1};const De=Ae(vt=>Q(vt+d,0,E.maxScrollPosition),D),Be=De-D,ut=d<0&&D+d<=0,je=d>0&&D+d>=E.maxScrollPosition,zt=d<0&&(De<=0||ut&&Be===0)||d>0&&(De>=E.maxScrollPosition||je&&Be===0);return{nextPosition:De,actualDelta:Be,reachedBoundary:zt}},[Ae]),Ze=t.useCallback((d,E)=>{d.current+=E;const D=Math.max(ge.current.maxScrollPosition,0);D>0&&(d.current=Q(d.current,-D,D));const se=ct(d.current);return d.current-=se.actualDelta,se.reachedBoundary&&(d.current=0),se},[ct]),Qe=t.useCallback(()=>{ee.current!==null&&(window.cancelAnimationFrame(ee.current),ee.current=null),te.current=null,_e.current=0,ce.current=0},[]),Le=t.useCallback(()=>{Oe.current={...on},U(!1),M.current?.reset(),Qe()},[Qe]),st=t.useCallback(d=>{const E=Oe.current,D=ge.current;if(!E.active||E.direction===0){Qe();return}if(!D.scrollBarVisible||D.maxScrollPosition<=0){Qe();return}const se=te.current??d,De=Math.max((d-se)/1e3,0),Be=Math.min(De,wn);if(te.current=d,Be<=0){ee.current=window.requestAnimationFrame(st);return}const ut=Er({distance:E.distance,maxDistance:D.effectiveTapMaxDistance,viewportSize:D.viewportSize,minSpeedMultiplier:D.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:D.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof D.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:D.tapCircleMaxSpeedCurve});ce.current!==E.direction&&(ce.current=E.direction,_e.current=0);const{reachedBoundary:je}=Ze(_e,E.direction*ut*Be);if(je){Qe();return}ee.current=window.requestAnimationFrame(st)},[Ze,Qe]),xe=t.useCallback(()=>{ee.current===null&&(te.current=null,_e.current=0,ee.current=window.requestAnimationFrame(st))},[st]);t.useEffect(()=>{const d=Oe.current;!d.active||d.direction===0||xe()},[r,e,xe]),t.useEffect(()=>()=>{Qe()},[Qe]);const me=t.useCallback(d=>{Oe.current=d,U(d.active),d.active&&d.direction!==0?xe():Qe()},[xe,Qe]);t.useEffect(()=>{rt||Le()},[Le,rt]),t.useEffect(()=>{const d=E=>{const se=E.detail?.paneId;se&&y&&se!==y||Le()};return window.addEventListener(pr,d),()=>{window.removeEventListener(pr,d)}},[y,Le]),t.useEffect(()=>{if(!rt)return;const d=E=>{if(!Oe.current.active||Oe.current.pointerId===E.pointerId)return;const D=E.target;if(!(D instanceof Node)){Le();return}M.current?.getElement()?.contains(D)||Le()};return document.addEventListener("pointerdown",d,!0),()=>{document.removeEventListener("pointerdown",d,!0)}},[Le,rt]);const bt=d=>{if(!be||ne<=0||G<=0)return 0;const E=Q(d,0,ne);return Q(E/ne*G,0,G)},h=t.useCallback(d=>{const{scrollBarVisible:E,effectiveTrackLength:D,maxScrollPosition:se}=ge.current;if(k.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:d,trackLen:D,maxScroll:se})),D<=0||se<=0)return null;const De=Q(d,0,D);return Q(De/D*se,0,se)},[]),C=t.useCallback(d=>Dr(d,u?"x":"y"),[u]),ye=t.useCallback(d=>{const E=H.current;if(E.pointerId!==d.pointerId)return;const D=d.clientX-E.startClientX,se=d.clientY-E.startClientY,De=Ve(D,se)/(E.scale||1);k.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:De,startThumbPosition:E.startThumbPosition,clientY:d.clientY,startClientY:E.startClientY,metrics:ge.current}));const Be=h(E.startThumbPosition+De);Be!==null&&Ae(Be),d.cancelable&&d.preventDefault()},[Ve,h,Ae]),Je=t.useCallback(d=>{const E=H.current;if(E.pointerId===d.pointerId)if(document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",Je),document.removeEventListener("pointercancel",Je),E.captureTarget!==null&&Jt(E.captureTarget,d.pointerId),H.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},ae(!1),Y.current){const D=Y.current.getBoundingClientRect();d.clientX>=D.left&&d.clientX<=D.right&&d.clientY>=D.top&&d.clientY<=D.bottom||T(!1)}else T(!1)},[ye]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",Je),document.removeEventListener("pointercancel",Je)},[ye,Je]);const Ce=t.useRef(0),Rt=t.useRef(0),et=t.useCallback(d=>{const E=Math.max(Math.round(ge.current.viewportSize/Yn),qn);Rt.current!==d&&(Rt.current=d,Ce.current=0),Ze(Ce,d*E)},[Ze]),{handleArrowPointerDown:it,handleArrowPointerUp:Pe,handleArrowKeyDown:Ft}=Kn({canUseArrowButtons:Xe,enableArrowButtons:o,resetTapScroll:Le,scrollByStep:et}),nr=d=>{if(!be)return;if(!i){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;Le();const E=d.currentTarget,D=C(E),se=hr(E,d.pointerId)==="captured"?E:null;H.current={pointerId:d.pointerId,startThumbPosition:fe,startClientX:d.clientX,startClientY:d.clientY,scale:D,captureTarget:se},document.addEventListener("pointermove",ye),document.addEventListener("pointerup",Je),document.addEventListener("pointercancel",Je),ae(!0),T(!0),d.preventDefault(),d.stopPropagation()},Ht=d=>{if(!be)return;if(!a){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;const E=d.currentTarget,D=E.getBoundingClientRect(),se=de(d),De=C(E),Be=(se-(u?D.left:D.top))/De;Le();const ut=Be-le/2,je=bt(ut);Ae(je),hr(E,d.pointerId),K.current={pointerId:d.pointerId,startThumbPosition:ut,startClientX:d.clientX,startClientY:d.clientY,scale:De},d.preventDefault(),d.stopPropagation()},ve=()=>{K.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},Nt=d=>{const E=K.current;if(E.pointerId!==d.pointerId)return;if(d.pointerType==="mouse"&&d.buttons===0){ve();return}const D=d.clientX-E.startClientX,se=d.clientY-E.startClientY,De=Ve(D,se)/(E.scale||1),Be=bt(E.startThumbPosition+De);Ae(Be),d.cancelable&&d.preventDefault()},Bt=d=>{K.current.pointerId===d.pointerId&&(Jt(d.currentTarget,d.pointerId),ve(),d.preventDefault(),d.stopPropagation())},er=d=>{K.current.pointerId===d.pointerId&&(Jt(d.currentTarget,d.pointerId),ve())},Ie=d=>{d.target===d.currentTarget&&K.current.pointerId===d.pointerId&&ve()},xt=t.useMemo(()=>Q((z?1:.8)*ke,0,1),[z,ke]),Xt=t.useMemo(()=>{const E=`calc(50% - ${Ge/2}px + ${Fe}px)`;return{left:pt,top:E}},[pt,Fe,Ge]),Lt=(d,E,D,se)=>V.jsx("button",{type:"button",tabIndex:0,className:"aqvs-scrollbar-arrow-button",style:{[ue]:b,[ft]:b},"aria-label":E,onPointerDown:it(d),onPointerUp:Pe,onPointerLeave:Pe,onPointerCancel:Pe,onKeyDown:Ft(d),"aria-disabled":!o,disabled:!Xe,children:V.jsx("span",{"aria-hidden":"true",children:D})},se),mt=W&&be?{orientation:Ke,scrollPosition:n,maxScrollPosition:G,contentSize:r,viewportSize:e,thumbSize:le,thumbPosition:fe,thumbCenter:Ye,trackSize:x,isDragging:F,isTapScrollActive:z,visibleStartIndex:_,visibleEndIndex:Re}:null;return V.jsxs("div",{className:It.twMerge("aqvs-scrollbar",at,I),style:{...g&&!u?{}:{[ue]:e},[ft]:b},"data-visible":be?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":y,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":G,"aria-orientation":u?"horizontal":"vertical",children:[(!u||m)&&be&&rt&&V.jsx(Br,{axis:u?"x":"y",ref:M,className:It.twMerge("aqvs-scrollbar-tap-circle-wrapper",He),size:Ge,maxVisualDistance:Tt,style:Xt,opacity:xt,renderVisual:Me,onDragChange:me},"tap-circle"),Lt(-1,Ue[0],O[0],"arrow-start"),V.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:b/2},onPointerDown:Ht,onPointerMove:Nt,onPointerUp:Bt,onPointerCancel:er,onLostPointerCapture:Ie,"aria-disabled":!a,children:[mt&&V.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:W?.(mt)},"overlay"),V.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[ue]:le,[w]:fe,...u?{top:0,bottom:0}:{left:0,right:0}},"data-visible":be||F?"true":"false",onPointerDown:nr,role:"slider","aria-orientation":u?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":G,"aria-disabled":!i,tabIndex:-1,children:V.jsx("div",{ref:Y,className:It.twMerge("aqvs-scrollbar-thumb",u?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":Se,style:{borderRadius:b-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&T(!0)},onMouseLeave:()=>{i&&T(!1)}},"thumb")},"thumb-wrapper")]},"track"),Lt(1,Ue[1],O[1],"arrow-end")]})},Mn=({offsetX:r,offsetY:e,maxDistance:n,x:s,y:i})=>{const a=Number.isFinite(r)?r:0,o=Number.isFinite(e)?e:0,u=Math.hypot(a,o);if(u===0)return{x:0,y:0};const m=Er({distance:u,maxDistance:n,viewportSize:s.viewportSize,minSpeedMultiplier:s.minSpeedMultiplier,maxSpeedMultiplier:s.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:s.hasCustomMaxSpeedMultiplier,curve:s.curve}),g=Er({distance:u,maxDistance:n,viewportSize:i.viewportSize,minSpeedMultiplier:i.minSpeedMultiplier,maxSpeedMultiplier:i.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:i.hasCustomMaxSpeedMultiplier,curve:i.curve});return{x:m*a/u,y:g*o/u}},Qn=r=>{const{quantum:e,resetOnDirectionChange:n=!0}=r;if(!(Number.isFinite(e)&&e>0))throw new TypeError(`[createResidualQuantizer] quantum must be a finite positive number, received ${e}`);let s=0;return{push:i=>{if(!Number.isFinite(i)||Math.abs(i)>Number.MAX_SAFE_INTEGER)return 0;n&&s!==0&&i!==0&&Math.sign(i)!==Math.sign(s)&&(s=0),s+=i;const a=Math.trunc(s/e)*e+0;return s-=a,a},peekResidue:()=>s,reset:()=>{s=0}}},Jn=16,ln=(r,e,n)=>e===1?r*Jn:e===2?r*n:r,es=(r,e)=>{const n=r.shiftKey&&r.deltaX===0,s=n?r.deltaY:r.deltaX,i=n?0:r.deltaY,a=s!==0&&Math.abs(s)>=Math.abs(i);return{isZoomGesture:r.ctrlKey,isHorizontalDominant:a,horizontalDelta:ln(s,r.deltaMode,e),verticalDelta:ln(i,r.deltaMode,e)}},yn=new WeakSet,cn=r=>{yn.add(r)},ts=r=>yn.has(r),rs=["mouse","pen","touch"],zr=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),ns=r=>r==="mouse"||r==="pen",fr={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},Mr=(r,e,n)=>{for(const[s,i,a]of e)n==="add"?r.addEventListener(s,i,a):r.removeEventListener(s,i,a)},In=t.forwardRef(({children:r,contentSize:e,viewportSize:n,onViewportSizeChange:s,scrollBarWidth:i=12,enableThumbDrag:a=!0,enableTrackClick:o=!0,enableArrowButtons:u=!0,enablePointerDrag:m=!0,pointerDragInputs:g=rs,onScroll:b,className:I,testId:y,style:S,background:P,tapScrollCircleOptions:W,inertiaOptions:_,itemCount:Re,renderThumbOverlay:Te,wheelSpeedMultiplier:A=1,overscrollBehavior:F="auto",onWheelHorizontal:ae,onPanHorizontal:L,contentInsets:T,visibleStartIndex:z,visibleEndIndex:U,renderOverlay:Y,initialScrollPosition:H=0,contentProps:K,locale:re,labels:he},Oe)=>{const M=t.useRef(Number.isFinite(H)?Math.max(0,H):0),ee=t.useRef(null),te=t.useRef(null),_e=n===void 0,[ce,qe]=t.useState(0),pe=n??ce,J=t.useRef(null);t.useLayoutEffect(()=>{if(!_e)return;const x=te.current;if(!x)return;const N=()=>{const G=x.offsetHeight;if(G>0){qe(ne=>ne===G?ne:G);return}x.offsetParent!==null&&e>0&&J.current!=="zero"&&(J.current="zero",k.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly."))};if(N(),typeof ResizeObserver!="function")return;const le=new ResizeObserver(N);return le.observe(x),()=>{le.disconnect()}},[e,_e]),t.useLayoutEffect(()=>{_e&&s?.(ce)},[_e,ce,s]),t.useLayoutEffect(()=>{if(_e)return;const x=ee.current;if(!x)return;const N=()=>{const G=x.clientHeight;if(G<=0||Math.abs(G-pe)<=1)return;const ne=`${pe}/${G}`;J.current!==ne&&(J.current=ne,k.warn(`[ScrollPane] viewportSize=${pe} but the host band is ${G}px. The clip window, max scroll position, thumb mapping, rendered row count and scrollability all derive from viewportSize, so they are now wrong. Omit viewportSize to let the pane measure itself.`))};if(N(),typeof ResizeObserver!="function")return;const le=new ResizeObserver(N);return le.observe(x),()=>{le.disconnect()}},[_e,pe]);const Ue=t.useRef(ae);t.useEffect(()=>{Ue.current=ae},[ae]);const rt=t.useRef(L);t.useEffect(()=>{rt.current=L},[L]);const Ge=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),pt=t.useMemo(()=>({maxVelocity:_?.maxVelocity??fr.maxVelocity,minVelocity:_?.minVelocity??fr.minVelocity,deceleration:_?.deceleration??fr.deceleration,velocitySampleWindow:_?.velocitySampleWindow??fr.velocitySampleWindow,startVelocityThreshold:_?.startVelocityThreshold??fr.startVelocityThreshold}),[_]),Fe=t.useMemo(()=>({top:Math.max(0,T?.top??0),bottom:Math.max(0,T?.bottom??0)}),[T]);k.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:pe,scrollBarWidth:i,className:I,style:S,tapScrollCircleOptions:W,inertiaOptions:_,enablePointerDrag:m,contentInsets:Fe}));const He=t.useRef({contentSize:e,viewportSize:pe}),Ee=t.useMemo(()=>e>pe,[e,pe]),nt=t.useCallback((x,N)=>{let le=N??He.current;N&&!(Number.isFinite(N.contentSize)&&Number.isFinite(N.viewportSize))&&(k.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:N}),le=He.current);const{contentSize:G,viewportSize:ne}=le,fe=G>ne,Ye=M.current;if(k.debug("[ScrollPane] scrollTo called",()=>({newPosition:x,contentSize:G,viewportSize:ne,currentIsScrollable:fe,prevPosition:Ye})),!fe)return M.current!==0&&(M.current=0,b?.(0,Ye)),M.current;const be=typeof x=="function"?x(M.current):x;if(!Number.isFinite(be))return k.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:be}),M.current;const Xe=Math.max(G-ne,0),Se=Q(be,0,Xe);return M.current!==Se&&(M.current=Se,b?.(Se,Ye)),M.current},[b]),Z=t.useRef(nt);t.useEffect(()=>{Z.current=nt},[nt]);const ke=t.useCallback(()=>{const x=Ge.current;x.generation+=1,x.frame!==null&&cancelAnimationFrame(x.frame),x.frame=null,x.velocity=0,x.lastTimestamp=null},[]),Me=t.useRef(ke);t.useEffect(()=>{Me.current=ke},[ke]),t.useEffect(()=>()=>{Me.current()},[]);const oe=t.useCallback(x=>{if(!Ee)return;const{maxVelocity:N,minVelocity:le,deceleration:G,startVelocityThreshold:ne}=pt,fe=Q(x,-N,N);if(Math.abs(fe)<ne)return;ke(),Ge.current.velocity=fe,Ge.current.lastTimestamp=null;const Ye=Ge.current.generation,be=Xe=>{const Se=Ge.current;if(Se.generation!==Ye)return;if(Se.lastTimestamp===null){Se.lastTimestamp=Xe,Se.frame=requestAnimationFrame(be);return}const Ae=Xe-Se.lastTimestamp;if(Se.lastTimestamp=Xe,Ae<=0){Se.frame=requestAnimationFrame(be);return}const ct=Se.velocity;let Ze=ct;const Qe=G*Ae;ct>0?Ze=Math.max(0,ct-Qe):ct<0&&(Ze=Math.min(0,ct+Qe));const st=(ct+Ze)/2*Ae,xe=M.current;if(st!==0&&Z.current(Je=>Je+st),Ge.current.generation!==Ye)return;const me=M.current,{contentSize:bt,viewportSize:h}=He.current,C=Math.max(bt-h,0);Se.velocity=Ze;const ye=me===xe||me<=0&&Ze<=0||me>=C&&Ze>=0;if(Math.abs(Ze)<le||ye){ke();return}Se.frame=requestAnimationFrame(be)};Ge.current.frame=requestAnimationFrame(be)},[Ee,pt,ke]),ge=t.useRef(oe);t.useEffect(()=>{ge.current=oe},[oe]),t.useLayoutEffect(()=>{He.current={contentSize:e,viewportSize:pe}},[e,pe]),t.useLayoutEffect(()=>{const x=te.current;if(!x)return;const N=()=>{x.scrollTop!==0&&(k.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:x.scrollTop})),x.scrollTop=0),x.scrollLeft!==0&&(x.scrollLeft=0)};return x.addEventListener("scroll",N),()=>x.removeEventListener("scroll",N)},[]),t.useLayoutEffect(()=>{if(Ee){k.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:pe,scrollPosition:M.current}));const x=Q(e-pe,0,e);M.current>x&&nt(x)}else nt(0)},[Ee,nt,e,pe]);const ue=t.useRef({isScrollable:Ee,viewportSize:pe,wheelSpeedMultiplier:A,overscrollBehavior:F});t.useLayoutEffect(()=>{ue.current={isScrollable:Ee,viewportSize:pe,wheelSpeedMultiplier:A,overscrollBehavior:F}},[Ee,pe,A,F]);const ft=t.useCallback(x=>{if(ts(x))return!1;const{isScrollable:N,viewportSize:le,wheelSpeedMultiplier:G,overscrollBehavior:ne}=ue.current,fe=es(x,le);if(fe.isZoomGesture)return!1;if(fe.isHorizontalDominant)return Ue.current?(cn(x),x.preventDefault(),ke(),Ue.current(fe.horizontalDelta),!0):!1;if(!N||fe.verticalDelta===0)return!1;let Ye=fe.verticalDelta;if(G!==1&&(Ye*=G),ne!=="contain"){const be=M.current,Xe=Math.max(He.current.contentSize-le,0);if(Ye>0&&be>=Xe||Ye<0&&be<=0)return!1}return cn(x),x.preventDefault(),ke(),k.debug("[ScrollPane] wheel event",()=>({deltaY:Ye,scrollPosition:M.current,wheelSpeedMultiplier:G,deltaMode:x.deltaMode,scrollTop:te.current?.scrollTop})),nt(be=>be+Ye),!0},[nt,ke]);t.useEffect(()=>{const x=G=>{ft(G)},N=()=>{ke()},le=ee.current;return le&&(le.addEventListener("wheel",x,{passive:!1}),le.addEventListener("pointerdown",N,{capture:!0,passive:!0})),()=>{le&&(le.removeEventListener("wheel",x),le.removeEventListener("pointerdown",N,{capture:!0}))}},[ft,ke]),t.useImperativeHandle(Oe,()=>({scrollTo:(x,N)=>(ke(),nt(x,N)),getScrollPosition:()=>M.current,getContentSize:()=>e,getViewportSize:()=>pe,applyWheel:ft}),[nt,e,pe,ke,ft]);const w=t.useId(),Ve=K?.id??w,de=t.useRef({pointerType:"",pointerId:null,startClientY:0,startClientX:0,lastPanClientX:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1,scaleX:1}),O=t.useRef(m),at=t.useRef(g);t.useEffect(()=>{O.current=m},[m]),t.useEffect(()=>{at.current=g},[g]);const Ke=t.useRef(Ee);t.useEffect(()=>{Ke.current=Ee},[Ee]);const Tt=t.useRef(pt);t.useEffect(()=>{Tt.current=pt},[pt]),t.useEffect(()=>{const x=de.current;if(m&&Ee&&(x.pointerId===null||zr(x.pointerType,g))||x.pointerId===null)return;const N=te.current;x.clickResetTimer!==null&&(window.clearTimeout(x.clickResetTimer),x.clickResetTimer=null);const le=x.isDragging&&x.shouldCancelNextClick,G=x.pointerId;x.pointerId=null,x.pointerType="",x.startClientY=0,x.startScroll=0,x.isDragging=!1,x.shouldCancelNextClick=le,x.velocitySamples=[],x.scale=1,N!==null&&Jt(N,G)},[m,g,Ee]),t.useEffect(()=>{const x=te.current;if(!x)return;const N=6,le=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),G=()=>{const h=de.current;h.pointerId=null,h.pointerType="",h.startClientY=0,h.startScroll=0,h.isDragging=!1,h.velocitySamples=[],h.scale=1},ne=()=>{const h=de.current;h.clickResetTimer!==null&&(window.clearTimeout(h.clickResetTimer),h.clickResetTimer=null)},fe=h=>{const C=de.current,ye=le();C.velocitySamples.push({clientY:h,time:ye});const Je=Tt.current.velocitySampleWindow;C.velocitySamples=C.velocitySamples.filter(Ce=>ye-Ce.time<=Je)},Ye=h=>h instanceof HTMLElement&&h.closest("[data-scrollpane-ignore-drag='true']")!==null,be=h=>{const C=de.current;C.shouldCancelNextClick&&(h.preventDefault(),h.stopPropagation(),C.shouldCancelNextClick=!1)},Xe=h=>{const C=de.current;C.isDragging||(C.isDragging=!0,C.shouldCancelNextClick=!0,Sn(x,h.pointerId)||hr(x,h.pointerId),fe(h.clientY))},Se=h=>h.isTrusted||h.target===x,Ae=h=>{const C=de.current;Jt(x,h),C.shouldCancelNextClick=!1,ne(),G()},ct=h=>{const C=de.current;if(C.pointerId!==h.pointerId)return;if(h.buttons===0&&ns(h.pointerType)){Ae(h.pointerId);return}if(!(O.current&&Ke.current)||!zr(h.pointerType,at.current))return;if(!C.isDragging){const Rt=Math.abs(h.clientY-C.startClientY),et=rt.current?Math.abs(h.clientX-C.startClientX):0;if(Math.max(Rt,et)<N||(Xe(h),!C.isDragging))return}fe(h.clientY);const ye=(h.clientY-C.startClientY)/(C.scale||1),Je=C.startScroll-ye;Z.current(Je);const Ce=rt.current;if(Ce){const Rt=h.clientX-C.lastPanClientX;C.lastPanClientX=h.clientX,Rt!==0&&Ce(-Rt/(C.scaleX||1))}h.cancelable&&h.preventDefault()},Ze=()=>{const h=de.current;return h.pointerId!==null||!h.shouldCancelNextClick?!1:(ne(),h.clickResetTimer=window.setTimeout(()=>{const C=de.current;C.shouldCancelNextClick=!1,C.clickResetTimer=null},0),!0)},Qe=h=>{const C=de.current;if(C.pointerId!==h.pointerId){Ze();return}C.isDragging&&C.shouldCancelNextClick&&h.cancelable&&(h.preventDefault(),h.stopPropagation()),C.isDragging&&fe(h.clientY);let ye=0;if(C.isDragging&&C.velocitySamples.length>=2){const Ce=C.velocitySamples,Rt=Tt.current.velocitySampleWindow,et=Ce[Ce.length-1],it=Ce.find(Pe=>et.time-Pe.time<=Rt)??Ce[0];if(et&&it&&et.time!==it.time){const Pe=et.clientY-it.clientY,Ft=et.time-it.time;ye=-(Pe/Ft)/(C.scale||1)}}ne(),C.shouldCancelNextClick&&(C.clickResetTimer=window.setTimeout(()=>{const Ce=de.current;Ce.shouldCancelNextClick=!1,Ce.clickResetTimer=null},0));const Je=Tt.current.startVelocityThreshold;G(),Jt(x,h.pointerId),Math.abs(ye)>=Je&&ge.current?.(ye)},Le=h=>{if(de.current.pointerId!==null){if(!h.isPrimary||h.pointerType!==de.current.pointerType)return;Ae(de.current.pointerId)}if(de.current.shouldCancelNextClick&&(ne(),de.current.shouldCancelNextClick=!1),!(O.current&&Ke.current)||!zr(h.pointerType,at.current)||h.button!==0&&h.pointerType==="mouse"||h.ctrlKey||h.metaKey||h.altKey||Ye(h.target))return;window.dispatchEvent(new CustomEvent(pr,{detail:{paneId:w}})),Me.current?.();const C=de.current;ne(),C.pointerId=h.pointerId,C.pointerType=h.pointerType,C.startClientY=h.clientY,C.startClientX=h.clientX,C.lastPanClientX=h.clientX,C.startScroll=M.current,C.scale=Dr(x,"y"),C.scaleX=rt.current?Dr(x,"x"):1,C.isDragging=!1,C.shouldCancelNextClick=!1,C.velocitySamples=[]},st=h=>{if(de.current.pointerId!==h.pointerId){Ze();return}Se(h)&&Ae(h.pointerId)},me=[["click",be,!0],["pointerdown",Le,{passive:!1}],["lostpointercapture",h=>{h.target!==x||de.current.pointerId!==h.pointerId||Ae(h.pointerId)},void 0]],bt=[["pointermove",ct,{passive:!1}],["pointerup",Qe,void 0],["pointercancel",st,void 0]];return Mr(x,me,"add"),Mr(window,bt,"add"),()=>{Mr(x,me,"remove"),Mr(window,bt,"remove");const h=de.current;h.pointerId!==null&&Jt(x,h.pointerId),ne(),G()}},[w]);const gt=t.useCallback(x=>(ke(),nt(x)),[nt,ke]);return V.jsxs("div",{ref:ee,"data-testid":y,"data-self-measured":_e?"true":void 0,className:It.twMerge("aqvs-scroll-pane",I),style:S,children:[V.jsxs("div",{ref:te,className:It.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:_e?void 0:pe,paddingTop:Fe.top,paddingBottom:Fe.bottom,...m&&Ee&&g.some(x=>x==="touch"||x==="pen")?{touchAction:"none"}:{}},...K,id:Ve,children:[P,r(M.current)]}),V.jsx(Wr,{contentSize:e,viewportSize:pe,stretchMainSize:_e,scrollPosition:M.current,onScroll:gt,enableThumbDrag:a,enableTrackClick:o,enableArrowButtons:u,scrollBarWidth:i,ariaControls:Ve,tapScrollCircleOptions:W,itemCount:Re,renderThumbOverlay:Te,visibleStartIndex:z,visibleEndIndex:U,locale:re,labels:he},"scrollbar"),Y?.()]})}),un=(r,e,n)=>Math.min(Math.max(r,e),n),ss=({dragState:r,normalizedDistance:e,sizeScale:n,size:s})=>{const i=Math.max(s/2,1),a=1+e*.65,o=Math.max(.65,1-e*.25),u=r.direction*e*26*n,m=.8+e*.18,g=3*n,b=6*n,I=22*n,y=Math.abs(u)+b,S=u>0?g:-Math.abs(u)-g,P=Math.max(2.5,3*n),W=un(r.offsetX,-i,i),_=un(r.offsetY,-i,i),Re=i*.35,Te=W/i*Re,A=_/i*Re,F=Te*.45,ae=A*.45,L=Math.max(I*.38,6),T=.65+e*.2,z=r.active;return V.jsxs(V.Fragment,{children:[V.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${o}, ${a})`,transition:z?"40ms transform ease-out":"200ms ease transform"}}),V.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:I,height:I,transform:`translate(calc(-50% + ${Te}px), calc(-50% + ${A}px)) scale(${o}, ${m*a})`,transition:z?"70ms transform ease-out":"200ms ease transform"}}),V.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:L,height:L,transform:`translate(calc(-50% + ${F}px), calc(-50% + ${ae}px)) scale(${o}, ${a})`,opacity:T,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:z?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),V.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:P,height:y,transform:`translate(-50%, ${S}px)`,opacity:e,transition:z?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},ar=100,is=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},kr=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},or=r=>{if(r<=0||!Number.isFinite(r))return 0;const e=Math.trunc(r);if(e<=2147483647)return e&-e;const n=BigInt(e)&-BigInt(e);return Number(n)};class _t{tree;deltas;size;baseValue;valueFn;total;constructor(e,n,s){this.reset(e,n,s)}reset(e,n,s){const i=Number.isFinite(e)&&e>0?Math.trunc(e):0;if(typeof n!="function"){this.size=i,this.tree=new Map,this.deltas=new Map,this.valueFn=void 0,this.baseValue=n,this.total=this.baseValue*this.size;return}let a=0,o;const u=s?.baseValue;if(u!==void 0&&!(Number.isFinite(u)&&u>=0))throw new RangeError(`[FenwickMapTree] options.baseValue must be a finite number >= 0, received ${u}.`);if(i>0&&u!==void 0){if(a=u,s?.materialize){const m=s?.sampleRange??{from:0,to:Math.min(ar-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),b=Math.min(Math.trunc(m.to),i-1);g>b&&(g=0,b=Math.min(ar-1,i-1)),o={from:g,values:_t._collectValidatedValues(n,g,b)}}}else if(i>0){const m=s?.sampleRange??{from:0,to:Math.min(ar-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),b=Math.min(Math.trunc(m.to),i-1);if(g>b&&(g=0,b=Math.min(ar-1,i-1)),i>ar)a=_t._sampleBaseValueStrided(n,i,ar),s?.materialize&&(o={from:g,values:_t._collectValidatedValues(n,g,b)});else{const I=_t._collectValidatedValues(n,g,b);a=_t._modeOrMedian([...I]),s?.materialize&&(o={from:g,values:I})}}if(this.size=i,this.tree=new Map,this.deltas=new Map,this.total=void 0,this.valueFn=n,this.baseValue=a,o)for(let m=0;m<o.values.length;m++){const g=o.from+m;if(g>=this.size)break;const b=o.values[m]-this.baseValue;b!==0&&(this.deltas.set(g,b),this._updateTree(g,b))}this.total=this.getTotal()}setValueFn(e,n){if(n?.reset){this.reset(this.size,e);return}typeof e=="function"?this.valueFn=e:(this.valueFn=void 0,this.baseValue=e,this.total=this._computeTreeTotal())}static _collectValidatedValues(e,n,s){const i=[];for(let a=n;a<=s;a++)i.push(kr(e(a),a));return i}static _modeOrMedian(e){if(e.length===0)return 0;e.sort((o,u)=>o-u);const n=Math.floor(e.length/2);let s;e.length%2===0?s=Math.floor((e[n-1]+e[n])/2):s=e[n];const i=new Map;let a=0;for(const o of e){const u=(i.get(o)??0)+1;i.set(o,u),u>a&&(a=u)}if(a>e.length*.2){const o=[];for(const[m,g]of i.entries())g===a&&o.push(m);const u=o.reduce((m,g)=>m+g,0);s=Math.floor(u/o.length)}return s}static _sampleBaseValueStrided(e,n,s){if(n<=0)return 0;let i=Math.max(1,Math.ceil(n/s));i%2===0&&(i+=1);const a=[];for(let o=0;o<n&&a.length<s;o+=i)a.push(kr(e(o),o));return _t._modeOrMedian(a)}update(e,n){return this.updates([{index:e,value:n}])}updates(e){const n=this._buildDeltaUpdates(e);return n.length>0?this.updateDeltas(n):this.total}updateDelta(e,n){return this.updateDeltas([{index:e,change:n}])}updateDeltas(e){const n=new Map;for(const{index:s,change:i}of e){if(s<0||s>=this.size)throw new Error(`Index ${s} out of bounds`);if(!Number.isInteger(s))throw new Error(`Index must be an integer: ${s}`);if(!Number.isFinite(i))throw new Error(`Change must be a finite number: ${i}`);const o=(n.get(s)??this.deltas.get(s)??0)+i;if(o+this.baseValue<-1e-9)throw new Error(`Change would make the value at index ${s} negative: ${o+this.baseValue}`);n.set(s,o)}for(const{index:s,change:i}of e){const o=(this.deltas.get(s)??0)+i;o===0?this.deltas.delete(s):this.deltas.set(s,o),this._updateTree(s,i)}return this.total}_updateTree(e,n){if(n===0)return;let s=e+1;for(;s<=this.size;){this.tree.set(s,(this.tree.get(s)??0)+n);const i=or(s);if(i===0)break;s+=i}this.total!==void 0&&(this.total+=n)}_buildDeltaUpdates(e){const n=[],s=new Map;for(const{index:i,value:a}of e){if(i<0||i>=this.size)throw new Error(`Index ${i} out of bounds`);if(!Number.isInteger(i))throw new Error(`Index must be an integer: ${i}`);if(!Number.isFinite(a))throw new Error(`Value must be a finite number: ${a}`);if(a<0)throw new Error("Value cannot be negative.");const o=s.has(i)?s.get(i)??0:this.deltas.get(i)??0,u=o+this.baseValue,m=a-u;m!==0&&n.push({index:i,change:m}),s.set(i,o+m)}return n}_computeTreeTotal(){if(this.size<=0)return 0;let e=0,n=this.size;for(;n>0;){e+=this.tree.get(n)??0;const s=or(n);if(s===0)break;n-=s}return e+this.baseValue*this.size}_materialize(e,n=!0){if(this.valueFn){const s=this.deltas.get(e)??0,a=kr(this.valueFn(e),e)-this.baseValue;if(a!==s&&(a===0?this.deltas.delete(e):this.deltas.set(e,a),n)){const o=a-s;this._updateTree(e,o)}}}_materializeRanges(e,n,s=!1){if(!(e?.materialize&&this.valueFn))return;const i=e.ranges;if(i&&i.length>0){for(const u of i){const m=Math.max(0,Math.trunc(u.from)),g=Math.min(Math.trunc(u.to),this.size-1);for(let b=m;b<=g;b++)this._materialize(b)}if(n===void 0)return;if(s){this._materialize(n);return}const a=i[0].from,o=i[i.length-1].to;n>=a&&n<=o&&this._materialize(n);return}n!==void 0&&this._materialize(n)}_findIndex(e,n={},s){if(this.size>=1073741824)return this._findIndexLarge(e,n,s);if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const i=n.materializeOption?.materialize===!0;let a;for(;;){if(a=this._descend(e,s),a<0||a>=this.size)return{index:-1,total:this.total??this.getTotal(),cumulative:void 0,currentValue:void 0,safeIndex:void 0};if(!i)break;const u=this.deltas.get(a)??0;if(this._materialize(a),(this.deltas.get(a)??0)===u)break}const o=this.prefixSum(a);return{index:a,total:this.total??o.total,cumulative:o.cumulative,currentValue:o.currentValue,safeIndex:o.safeIndex}}_descend(e,n){let s=0,i=0,a=1;for(;a<<1<=this.size;)a<<=1;for(;a>0;a>>=1){const o=s+a;if(o<=this.size){const m=(this.tree.get(o)??0)+this.baseValue*a;(n?i+m<e:i+m<=e)&&(s=o,i+=m)}}return n?s:s-1}_findIndexLarge(e,n,s){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};const i=is(this.size);if(i===0n)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const a=n.materializeOption?.materialize===!0;for(;;){let o=0n,u=i-1n,m,g,b=this.total;for(;o<=u;){const S=o+u>>1n,P=Number(S),W=this.prefixSum(P);if(b=W.total,s?W.cumulative>=e:W.cumulative<=e)if(m=S,g=W,s){if(S===0n)break;u=S-1n}else o=S+1n;else if(s)o=S+1n;else{if(S===0n)break;u=S-1n}}const I=g,y=m!==void 0?Number(m):-1;if(a&&y>=0){const S=this.deltas.get(y)??0;if(this._materialize(y),(this.deltas.get(y)??0)!==S)continue}return{index:y,total:b,cumulative:I?.cumulative,currentValue:I?.currentValue,safeIndex:I?.safeIndex}}}prefixSum(e,n){if(e<0||Number.isNaN(e))return{cumulative:0,total:this.total,currentValue:0,safeIndex:0};if(this.size===0)return{cumulative:0,total:this.total??0,currentValue:0,safeIndex:0};const s=Q(Math.trunc(e),0,this.size-1),i=n?.materializeOption;this._materializeRanges(i,s,!0);let a=0,o=s+1;for(;o>0;){const m=this.tree.get(o)??0;a+=m;const g=or(o);if(g===0)break;o-=g}const u=i?.materialize?this.get(s):(this.deltas.get(s)||0)+this.baseValue;return{cumulative:a+this.baseValue*(s+1),total:this.total,currentValue:u,safeIndex:s}}get(e,n){if(this.size===0)return 0;if(!Number.isInteger(e)||e<0||e>=this.size)throw new Error("Index out of bounds");const s=n?.materializeOption;return this._materializeRanges(s,e),(this.deltas.get(e)??0)+this.baseValue}getTotal(e){const n=e?.materializeOption;if(this._materializeRanges(n),this.total===void 0)if(this.size===0)this.total=0;else{this.total=this._computeTreeTotal();const s=this.prefixSum(this.getSize()-1);s.cumulative!==s.total&&k.error("Inconsistent Fenwick Tree state")}return this.total}rebuildTree(e){if(e?.materialize&&this.valueFn){const s=this.valueFn;this.reset(this.size,i=>s(i),{materialize:!0});return}const n=new Map;for(const[s,i]of this.deltas.entries()){if(i===0)continue;let a=s+1;for(;a<=this.size;){n.set(a,(n.get(a)??0)+i);const o=or(a);if(o===0)break;a+=o}}this.tree=n,this.total=this._computeTreeTotal()}calculateAccumulatedError(){if(this.total===void 0)return 0;let e=this.baseValue*this.size;for(const[n,s]of this.deltas)n<this.size&&(e+=s);return this.total-e}changeSize(e){if(!Number.isFinite(e))throw new Error(`Size must be a finite number: ${e}`);const n=Math.max(0,Math.trunc(e)),s=this.size;if(n===s)return;if(n>s)if(s===0&&this.deltas.size>0){for(const a of this.deltas.keys())a>=n&&this.deltas.delete(a);this.size=n,this.rebuildTree()}else this._growSize(s,n);else{if(n>0)for(const a of this.deltas.keys())a>=n&&this.deltas.delete(a);this.size=n,this.rebuildTree()}const i=this.prefixSum(this.getSize()-1);i.cumulative!==i.total&&k.error("Inconsistent Fenwick Tree state")}static _minCoveredLowBound(e,n){let s=1;for(;;){const i=s*2;if(Math.floor(n/i)*i<=e)break;s=i}return s*Math.floor(e/s)}_propagateDeltaToGrownNodes(e,n,s,i){let a=e+1;for(;a<=s;){const o=or(a);if(o===0)break;a+=o}for(;a<=i;){this.tree.set(a,(this.tree.get(a)??0)+n);const o=or(a);if(o===0)break;a+=o}}_growSize(e,n){if(this.size=n,this.deltas.size>0){const s=_t._minCoveredLowBound(e,n);if(e-s<this.deltas.size)for(let a=s;a<e;a++){const o=this.deltas.get(a);o===void 0||o===0||this._propagateDeltaToGrownNodes(a,o,e,n)}else for(const[a,o]of this.deltas.entries())o===0||a<s||this._propagateDeltaToGrownNodes(a,o,e,n)}this.total=this._computeTreeTotal()}getSize(){return this.size}get base(){return this.baseValue}findIndexAtOrAfter(e,n){return this._findIndex(e,n??{},!0)}findIndexAtOrBefore(e,n){return this._findIndex(e,n??{},!1)}}const as=(r,e)=>{const n=r?.sampleRange,s=e?.sampleRange;return n===s?!1:n&&s?n.from!==s.from||n.to!==s.to:!0},Ur=(r,e,n)=>{const s=Number.isFinite(r)&&r>0?Math.trunc(r):0,i=t.useRef(null),a=t.useRef({size:s,valueOrFn:e,options:n});i.current===null&&(i.current=new _t(s,e,n));const o=i.current,u=a.current,m=u.size!==s,g=u.valueOrFn!==e,b=as(u.options,n)||u.options?.baseValue!==n?.baseValue,I=u.size===0&&s>0&&(!i.current||i.current.base===0);if(g||b){const y=n?.resetOnValueFnChange??!0;b||g&&y||I?(n?.debug&&k.debug("[useFenwickMapTree] reset",{valueOrFnChanged:g,optionsChanged:b}),o.reset(s,e,n)):(m&&(n?.debug&&k.debug("[useFenwickMapTree] resize (with valueFn change)",{from:u.size,to:s}),o.changeSize(s)),n?.debug&&k.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:g}),o.setValueFn(e,{reset:!1})),a.current={size:s,valueOrFn:e,options:n}}else m&&(n?.debug&&k.debug("[useFenwickMapTree] resize",{from:u.size,to:s}),I?o.reset(s,e,n):o.changeSize(s),a.current={size:s,valueOrFn:e,options:n});return o};class os{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class Ar{head=null;tail=null;addToTail(e){this.tail?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e}remove(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=null,e.next=null}removeHead(){const e=this.head;return e&&this.remove(e),e}moveToTail(e){this.remove(e),this.addToTail(e)}}function Tn(r){const e=t.useRef(new Map),n=t.useRef(new Ar),s=Math.floor(r),i=t.useRef(s);t.useEffect(()=>{if(i.current=s,Number.isNaN(s)||s<0){k.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`),e.current.clear(),n.current=new Ar;return}if(Number.isFinite(s))for(;e.current.size>s;){const b=n.current.removeHead();if(b)e.current.delete(b.key);else break}},[r,s]);const a=t.useCallback(b=>{const I=e.current.get(b);if(I)return n.current.moveToTail(I),I.value},[]),o=t.useCallback((b,I)=>{const y=i.current;if(Number.isNaN(y)||y<=0)return;let S=e.current.get(b);if(S)S.value=I,n.current.moveToTail(S);else{if(e.current.size>=y){const P=n.current.removeHead();P&&e.current.delete(P.key)}S=new os(b,I),e.current.set(b,S),n.current.addToTail(S)}},[]),u=t.useCallback(b=>e.current.has(b),[]),m=t.useCallback(b=>{const I=e.current.get(b);I&&(n.current.remove(I),e.current.delete(b))},[]),g=t.useCallback(()=>{e.current.clear(),n.current=new Ar},[]);return t.useMemo(()=>({get:a,set:o,has:u,remove:m,clear:g}),[a,o,u,m,g])}const ls=1e4,cs=()=>{const{get:r,set:e,has:n,clear:s}=Tn(ls);return t.useMemo(()=>({get:r,set:e,has:n,clear:s}),[r,e,n,s])},us=(r,e)=>{const n=t.useRef(e),s=t.useRef(r);t.useLayoutEffect(()=>{n.current=e,s.current=r},[e,r]);const i=t.useRef(new WeakMap);return t.useCallback(a=>{if(!a||i.current.has(a))return;const o=u=>{n.current?.enableBridge!==!1&&s.current.current?.applyWheel(u)};return a.addEventListener("wheel",o,{passive:!1}),i.current.set(a,o),()=>{i.current.get(a)===o&&(a.removeEventListener("wheel",o),i.current.delete(a))}},[])},dn=-200,fn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},ds=r=>{const e=t.useRef(r);e.current=r;const n=t.useRef(fn),s=t.useRef(null),[i,a]=t.useState(!1),o=t.useRef(null),u=t.useRef(null),m=t.useRef({residual:0,direction:0}),g=t.useRef({residual:0,direction:0}),b=t.useCallback(()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null),u.current=null,m.current={residual:0,direction:0},g.current={residual:0,direction:0}},[]),I=t.useCallback((A,F,ae,L,T,z)=>{const U=F>0?1:F<0?-1:0;U!==0&&U!==A.direction&&(A.direction=U,A.residual=0),A.residual+=F*ae;const Y=Math.max(T(),0);Y>0&&(A.residual=Q(A.residual,-Y,Y));const H=A.residual;if(H===0)return{actualDelta:0,atBoundary:!1};const K=L(),re=z(H),he=re-K;A.residual-=he;const Oe=H<0&&K+H<=0,M=H>0&&K+H>=Y,ee=H<0&&(re<=0||Oe&&he===0)||H>0&&(re>=Y||M&&he===0);return ee&&(A.residual=0),{actualDelta:he,atBoundary:ee}},[]),y=t.useCallback(A=>{const F=e.current,ae=n.current;if(!ae.active||ae.direction===0){b();return}const L=u.current??A,T=Math.max((A-L)/1e3,0),z=Math.min(T,wn);if(u.current=A,z<=0){o.current=window.requestAnimationFrame(y);return}const U=Mn({offsetX:ae.offsetX,offsetY:ae.offsetY,maxDistance:F.maxDistance,x:F.xSpeedParams,y:F.ySpeedParams}),Y=I(m.current,U.x,z,F.getHx,F.getMaxHx,he=>F.applyHxRef.current(F.getHx()+he));Y.actualDelta!==0&&(F.pendingColAnchorRef.current=null);const H=I(g.current,U.y,z,F.getVy,F.getMaxVy,F.applyVy),K=F.getMaxHx()<=0||Y.atBoundary||ae.offsetX===0,re=F.getMaxVy()<=0||H.atBoundary||ae.offsetY===0;if(K&&re){b();return}o.current=window.requestAnimationFrame(y)},[b,I]),S=t.useCallback(()=>{o.current===null&&(u.current=null,m.current={residual:0,direction:0},g.current={residual:0,direction:0},o.current=window.requestAnimationFrame(y))},[y]),P=t.useCallback(()=>{n.current={...fn},a(!1),s.current?.reset(),b()},[b]),W=t.useCallback(A=>{n.current=A,a(A.active),A.active&&A.direction!==0?S():b()},[S,b]),{enabled:_,xExtentFreshness:Re,yExtentFreshness:Te}=r;return t.useEffect(()=>{const A=n.current;!A.active||A.direction===0||S()},[Re,Te,S]),t.useEffect(()=>{const A=()=>{P()};return window.addEventListener(pr,A),()=>{window.removeEventListener(pr,A)}},[P]),t.useEffect(()=>{if(!_)return;const A=F=>{if(!n.current.active||n.current.pointerId===F.pointerId)return;const ae=F.target;if(!(ae instanceof Node)){P();return}s.current?.getElement()?.contains(ae)||P()};return document.addEventListener("pointerdown",A,!0),()=>{document.removeEventListener("pointerdown",A,!0)}},[_,P]),t.useEffect(()=>{_||P()},[_,P]),t.useEffect(()=>()=>{b()},[b]),{isTapActive:i,handleTapCircleDragChange:W,tapCircleHandleRef:s}},We=(r,e)=>e<=0?0:Q(r,0,e-1),mn=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),wt=(r,e)=>r<=e?0:r-e,rr=(r,e)=>r<=0?0:r+e,gr=1e3,_r=2e3,En=1048576,fs=40,mr=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},ms=(r,e,n,s,i,a,o,u)=>{const m=mr(s);if(m===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const g=L=>L<0n?0n:L>=m?m-1n:L,b={materializeOption:{materialize:!1}},{index:I,cumulative:y}=a.findIndexAtOrAfter(r,b);let S;I===-1?S=m-1n:(y===r?S=mr(I+1):S=mr(I),S>=m&&(S=m-1n)),r<=0&&(S=0n),u&&r>=o&&(S=m-1n);const P=L=>{const T=Number(L);if(!Number.isSafeInteger(T))return null;const{cumulative:z}=a.prefixSum(T,{materializeOption:{materialize:!1}});if(!Number.isFinite(z))return null;const{index:U}=a.findIndexAtOrAfter(z+.5,{materializeOption:{materialize:!1}});if(U===-1)return null;const Y=mr(U);return Y>L?Y:null},W=L=>{let T=0,z=L,U=L,Y=0n,H=0;for(;z<m&&T<e;){const K=Number(z),re=i(K);if(T+=re,U=z,z+=1n,Y+=1n,!Number.isFinite(re)||re<0)break;if(re===0){if(H+=1,H>gr){const he=P(U);if(he!==null&&he>z)z=he,H=0;else if(he!==null&&he===z&&i(Number(z))>0)H=0;else break}}else H=0}return Y===0n&&(U=L),{height:T,end:U}};let{height:_,end:Re}=W(S);if(_<e&&S>0n){let L=S,T=_,z=0;for(;L>0n&&T<e;){L-=1n;const Y=Number(L),H=i(Y);if(T+=H,!Number.isFinite(H)||H<0)break;if(H===0){if(z+=1,z>gr){const K=Number(L);if(!Number.isSafeInteger(K))break;const{cumulative:re}=a.prefixSum(K,{materializeOption:{materialize:!1}});if(!Number.isFinite(re))break;const{index:he}=a.findIndexAtOrAfter(re-.5,{materializeOption:{materialize:!1}}),Oe=he===-1?-1n:mr(he);if(Oe>=0n&&Oe<L)L=Oe+1n,z=0;else if(Oe===L&&L>=1n&&i(Number(L-1n))>0)z=0;else break}}else z=0}S=g(L);const U=W(S);_=U.height,Re=U.end}const Te=g(S),A=g(Re),F=g(Te-BigInt(Math.max(0,n))),ae=g(A+BigInt(Math.max(0,n)));return{renderingStartIndex:We(Number(F),s),renderingEndIndex:We(Number(ae),s),visibleStartIndex:We(Number(Te),s),visibleEndIndex:We(Number(A),s)}},Cn=(r,e,n,s,i,a,o)=>{if(s===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const u=Number.isFinite(o),m=u?Math.min(Math.max(0,r),o):Math.max(0,r);if(s>=Number.MAX_SAFE_INTEGER)return ms(m,e,n,s,i,a,o,u);const{index:g,cumulative:b,currentValue:I}=a.findIndexAtOrAfter(m,{materializeOption:{materialize:!1}}),y=g===-1?e<=0||(b??0)<m+(I??0)?s-1:0:g;let S=We(y,s),P=0;if(g!==-1&&b===m)S=We(g+1,s),P=0;else if(S===g&&b!==void 0&&I!==void 0)P=b-I-m;else{const{cumulative:L,currentValue:T}=a.prefixSum(S,{materializeOption:{materialize:!1}});P=(L??0)-(T??0)-m}const W=P,_=(L,T)=>{let z=L,U=T,Y=0;for(;z<s&&U<e;){const H=i(z);if(U+=H,z++,!Number.isFinite(H)||H<0)break;if(H===0){if(Y++,Y>gr){const{cumulative:K}=a.prefixSum(z-1,{materializeOption:{materialize:!1}}),{index:re}=Number.isFinite(K)?a.findIndexAtOrAfter(K+.5,{materializeOption:{materialize:!1}}):{index:-1};if(re>z)z=re,Y=0;else if(re===z&&i(z)>0)Y=0;else break}}else Y=0}return{cursor:z,height:U}},Re=_(S,P);let Te=Re.cursor;if(P=Re.height,P<e&&S>0){let L=P+Math.abs(Math.min(0,W)),T=S-1,z=0;for(;T>=0&&L<e;){const Y=i(T);if(L+=Y,!Number.isFinite(Y)||Y<0){T--;break}if(Y===0){if(z++,z>gr){const{cumulative:H}=a.prefixSum(T,{materializeOption:{materialize:!1}}),{index:K}=Number.isFinite(H)?a.findIndexAtOrAfter(H-.5,{materializeOption:{materialize:!1}}):{index:-1};if(K!==-1&&K<T){T=K,z=0;continue}if(K===T&&T>=1&&i(T-1)>0)z=0;else{T--;break}}}else z=0;T--}S=We(T+1,s);const U=_(S,0);Te=U.cursor,P=U.height}const A=We(S-n,s),F=We(Math.max(Te-1,S),s),ae=We(F+n,s);return{renderingStartIndex:A,renderingEndIndex:ae,visibleStartIndex:S,visibleEndIndex:F}},hn=(r,e,n)=>{const s=Math.max(0,e??0),i=t.useRef({last:0,id:null,arg:null}).current;return t.useEffect(()=>()=>{if(i.id!==null&&(cancelAnimationFrame(i.id),i.id=null),i.arg!==null&&r.current){try{n(r.current,i.arg)}catch(a){console.error("[useThrottledInvoker] Error flushing pending callback on unmount",a)}i.arg=null}},[i,r,n]),t.useCallback(a=>{if(i.arg=a,i.id!==null)return;const o=u=>{if(i.id=null,i.arg===null)return;const m=u-i.last;if(s===0||i.last===0||m>=s){if(r.current)try{n(r.current,i.arg)}catch(g){console.error("[useThrottledInvoker] Error invoking callback",g)}i.arg=null,i.last=u}i.arg!==null&&(i.id=requestAnimationFrame(o))};i.id=requestAnimationFrame(o)},[s,n,r,i])},hs=t.memo(({index:r,top:e,height:n,item:s,children:i,clipItemHeight:a,enableKeyboardNavigation:o,onKeyDown:u,onEscapeKeyDown:m,onFocus:g,registerItemRef:b})=>{const I=t.useCallback(_=>b(r,_),[r,b]),y=t.useCallback(_=>u(_,r),[r,u]),S=t.useCallback(_=>m?.(_,r),[r,m]),P=t.useCallback(()=>g(r),[r,g]),W=t.useCallback(_=>{_.currentTarget.focus({preventScroll:!0})},[]);return V.jsx("div",{ref:I,"data-index":r,"data-virtualscroll-item":"true",className:"aqvs-item-container",style:{top:e,height:n,overflow:a?"hidden":void 0},tabIndex:o?-1:void 0,onPointerDown:o?W:void 0,onKeyDownCapture:o?y:void 0,onKeyDown:o&&m?S:void 0,onFocusCapture:o?P:void 0,children:i(s,r)})}),ps=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:s,viewportSize:i,overscanCount:a=15,className:o,testId:u,onScroll:m,onRangeChange:g,children:b,background:I,initialScrollIndex:y,initialScrollOffset:S,initialScrollAnchor:P,callbackThrottleMs:W=5,contentInsets:_,onItemFocus:Re,scrollBarOptions:Te,behaviorOptions:A,onWheelHorizontal:F,onPanHorizontal:ae,horizontalKeyInputs:L,horizontalKeyStep:T=fs,contentProps:z,liveRegion:U,locale:Y,labels:H},K)=>{const{width:re,enableThumbDrag:he,enableTrackClick:Oe,enableArrowButtons:M,enableScrollToTopBottomButtons:ee,renderThumbOverlay:te,tapScrollCircleOptions:_e}=Te??{},ce=t.useMemo(()=>Yr(Y,H),[Y,H]),{enablePointerDrag:qe,pointerDragInputs:pe,enableKeyboardNavigation:J=!0,enableEscapeRowReturn:Ue=!1,wheelSpeedMultiplier:rt,inertiaOptions:Ge,overscrollBehavior:pt,clipItemHeight:Fe=!1,resetOnGetItemHeightChange:He=!1}=A??{},[Ee,nt]=t.useState(0),Z=i??Ee,ke=t.useCallback(c=>{nt(f=>f===c?f:c)},[]),Me=t.useRef(null),oe=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),ge=t.useRef(P&&r>0?{index:Q(Math.trunc(P.index),0,r-1),align:"top",offset:-Math.max(0,P.offsetPx??0)}:null),ue=t.useRef(!1),ft=t.useRef(!0);t.useEffect(()=>{if(ft.current){ft.current=!1;return}He&&(ge.current=null)},[He,s]);const w=t.useMemo(()=>mn(_),[_]),[Ve]=t.useState(()=>{const f=P?.index??y,v=typeof f=="number"&&Number.isFinite(f)?Math.max(0,Math.trunc(f)):0;return{from:Math.max(0,v-50),to:v+50}}),de=t.useMemo(()=>({sampleRange:Ve,resetOnValueFnChange:He,materialize:!0}),[He,Ve]),O=Ur(r,s,de),[at]=t.useState(()=>{let c=0,f=0;if(P&&r>0){const v=Q(Math.trunc(P.index),0,r-1),$=Math.max(0,P.offsetPx??0),q=Q(v-a*2,0,r-1),B=Q(v+a*2,0,r-1),j=v>0||$>0?{materializeOption:{materialize:!0,ranges:[{from:q,to:B}]}}:void 0,{cumulative:we,total:$e,currentValue:Ne}=O.prefixSum(v,j),ze=Math.max(we-Ne+$,0);c=rr(ze,w.top),f=$e??O.getTotal()}else if(typeof y=="number"){const v=Q(y,0,r-1),$=Q(v-a*2,0,r-1),q=Q(v+a*2,0,r-1),B=y>0?{materializeOption:{materialize:!0,ranges:[{from:$,to:q}]}}:void 0,{cumulative:j,total:we,currentValue:$e}=O.prefixSum(y,B),Ne=Math.max(j-$e,0);c=rr(Ne,w.top),f=we??O.getTotal()}else typeof S=="number"&&(c=rr(Math.max(S,0),w.top)),f=O.getTotal();return{position:c,total:f}}),[Ke,Tt]=t.useState(at.position),[gt,x]=t.useState(at.total),N=t.useRef(at.position),le=t.useRef(w.top),G=t.useRef(m??void 0),ne=t.useRef(g??void 0),fe=t.useRef(F),Ye=(L?.length??0)>0,be=!!F;t.useEffect(()=>{Ye&&(J||k.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),be||k.warn("[VirtualScroll] horizontalKeyInputs is set but onWheelHorizontal is missing; horizontal keyboard scrolling is disabled because the package does not own the horizontal axis."),Number.isFinite(T)&&T>0||k.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${T}. Horizontal arrow keys are left untouched.`))},[Ye,be,J,T]);const Xe=t.useRef(new Map),Se=t.useRef(null),Ae=t.useRef(null),[ct,Ze]=t.useState(null),[Qe,Le]=t.useState(!1),st=t.useRef(null),xe=t.useRef(!1),me=t.useRef(0),bt=t.useRef(!1),h=t.useRef(!1),C=t.useRef(r);C.current!==r&&(C.current=r,h.current=!0),t.useLayoutEffect(()=>{G.current=m??void 0,ne.current=g??void 0,fe.current=F},[g,m,F]);const ye=t.useCallback(c=>{if(J&&c&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},[J]),Je=t.useCallback((c,{position:f,totalHeight:v})=>{c(f,v)},[]),Ce=hn(G,W,Je),Rt=t.useCallback((c,f)=>{c(f)},[]),et=hn(ne,W,Rt),it=t.useRef(w.top);it.current=w.top;const Pe=t.useRef(Ce);Pe.current=Ce,t.useEffect(()=>(ue.current=!1,()=>{ue.current=!0,st.current&&(clearTimeout(st.current),st.current=null)}),[]),t.useEffect(()=>{J||(Xe.current.clear(),Se.current=null,Ae.current=null)},[J]);const Ft=t.useCallback((c,f)=>{if(!f){Xe.current.delete(c);return}J&&(Xe.current.set(c,f),Se.current===c&&(Se.current=null,Ae.current=c,ye(f)))},[J,ye]),nr=.01,Ht=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:at.position}),ve=t.useCallback(()=>{const c=Ht.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{ve()},[ve]);const Nt=t.useRef(()=>{}),Bt=t.useCallback(()=>{const c=Ht.current;c.rafId=null;const f=N.current,v=wt(f,it.current),$=O.getTotal();if(Tt(B=>Math.abs(B-f)<nr?B:f),Math.abs(c.lastRenderedPosition-f)>=nr?(Pe.current({position:v,totalHeight:$}),c.lastRenderedPosition=f,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){ve();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(B=>Nt.current(B));return}c.loopActive=!1},[O,ve]);Nt.current=Bt;const er=t.useCallback(()=>{const c=Ht.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(Bt);return}c.loopActive=!1}},[Bt]),Ie=t.useCallback((c,f)=>{const v=f?.immediate??!1,$=wt(c,w.top);if(N.current=c,v){Ht.current.lastRenderedPosition=c,Ht.current.idleFrames=0,Tt(c),Ce({position:$,totalHeight:O.getTotal()});return}er()},[er,O,w.top,Ce]),xt=t.useCallback((c,f=0)=>{const v=Me.current;if(!v)return c;const $=v.getScrollPosition();me.current+=1;const q=v.getContentSize()+f,B=v.getViewportSize(),j=v.scrollTo(c,{contentSize:q,viewportSize:B});return j===$&&(me.current=Math.max(0,me.current-1)),Math.abs(j-c)>.5&&(bt.current=!0),j},[]),Xt=t.useRef(!1);t.useEffect(()=>{if(!Xt.current)if(Xt.current=!0,P==null&&typeof y!="number"&&typeof S=="number"){const c=rr(Math.max(S,0),w.top),f=Math.abs(c-N.current)>.5;Ie(c,{immediate:!0}),f&&Me.current?.scrollTo(c)}else Ie(N.current,{immediate:!0})},[P,y,S,w.top,Ie]),t.useEffect(()=>{const c=O.getTotal();if(gt!==c){x(c);return}if(bt.current){bt.current=!1;const f=Me.current;if(f&&Math.abs(f.getScrollPosition()-N.current)>.5){const v=xt(N.current);bt.current=!1,Ie(v,{immediate:!0})}}},[O,gt,r,xt,Ie]),t.useEffect(()=>{if(ge.current!==null){const{index:c,align:f,offset:v}=ge.current,$=We(c,r),{cumulative:q,currentValue:B}=O.prefixSum($,{materializeOption:{materialize:!1}});if(q!==void 0&&B!==void 0){const j=Math.max(q-B,0);let we=j;f==="bottom"?we=q-Z:f==="center"&&(we=j+B/2-Z/2),v&&(we-=v),we=Math.max(0,we);const $e=Math.max(0,gt+w.top+w.bottom-Z),Ne=Math.min(rr(we,w.top),$e);Math.abs(Ne-N.current)>1&&(k.debug("[VirtualScroll] Drift correction",{from:N.current,to:Ne,targetIndex:$}),me.current===0&&(me.current+=1),Me.current?.scrollTo(Ne),Ie(Ne,{immediate:!0}))}}h.current=!1},[gt,O,r,w.top,Ie,Z,w.bottom]),t.useEffect(()=>{const c=le.current;if(c===w.top||(le.current=w.top,ge.current))return;const f=wt(N.current,c),v=rr(f,w.top);N.current=v,Me.current?.scrollTo(v),Ie(v,{immediate:!0})},[w.top,Ie]);const Lt=t.useCallback((c,f)=>{if(r===0)return;const v=We(c,r),$=O.get(v),q=f-$,B=O.update(v,f);B!==void 0&&x(B),k.debug("[VirtualScroll] Updated item size manually",{index:v,size:f,total:B});let j=ge.current?ge.current.index:null;if(j===null){const we=N.current,$e=mn(_).top,Ne=wt(we,$e),{index:ze,cumulative:ot}=O.findIndexAtOrAfter(Ne,{materializeOption:{materialize:!1}});j=ot!==void 0&&ot===Ne?ze+1:ze}if(j!==-1&&v<j&&q!==0){const we=N.current,$e=we+q;xt($e,q),Ie($e,{immediate:!0}),k.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:we,to:$e,causedByIndex:v,delta:q,activeVisibleStartIndex:j})}},[O,r,xt,Ie,_]),mt=t.useCallback((c,f)=>{if(!Me.current||r===0)return;const v=We(c,r),$=We(v-a*2,r),q=We(v+a*2,r),{cumulative:B,total:j,currentValue:we}=O.prefixSum(v,{materializeOption:{materialize:!0,ranges:[{from:$,to:q}]}});if(k.debug("[VirtualScroll] Scrolling to index:",v,"ItemBottom:",B,"Total height:",j,"ItemHeight:",we,"safeIndexFrom:",$,"safeIndexTo:",q),!j)return;const $e=Math.max(B-we,0);let Ne=$e;f?.align==="bottom"?Ne=B-Z:f?.align==="center"&&(Ne=$e+we/2-Z/2),f?.offset&&(Ne-=f.offset),Ne=Math.max(0,Ne);const ze=rr(Ne,w.top),ot=Me.current?.getContentSize()??j+w.top+w.bottom,lt=Math.max(0,ot-Z),dt=Math.min(ze,lt);ge.current={index:v,align:f?.align,offset:f?.offset};const Zt=Me.current?.getScrollPosition()??-1,ur=Math.abs(Zt-dt)>.5;xe.current=!1,me.current=0,ur&&(xe.current=!0,me.current+=1,Me.current?.scrollTo(dt)),x(j),Ie(dt,{immediate:!0}),k.debug("[VirtualScroll] Setting scroll position to:",dt,{original:ze,max:lt})},[O,a,r,w.top,w.bottom,Z,Ie]),d=t.useRef(P&&r===0?P:null);t.useEffect(()=>{const c=d.current;!c||r===0||(d.current=null,mt(Q(Math.trunc(c.index),0,r-1),{align:"top",offset:-Math.max(0,c.offsetPx??0)}))},[r,mt]);const E=t.useCallback(c=>{if(!Me.current||r===0)return;const f=O.getTotal(),v=Q(Math.floor(c),0,f),{index:$,cumulative:q,currentValue:B}=O.findIndexAtOrAfter(v,{materializeOption:{materialize:!1}}),we=(q??0)-(B??0)-v;mt($,{offset:we})},[O,r,mt]),D=t.useCallback(()=>{if(r===0)return null;const c=wt(N.current,w.top),{index:f,cumulative:v,currentValue:$}=O.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(f===-1)return{index:r-1,offsetPx:0};if(v===c)return{index:Q(f+1,0,r-1),offsetPx:0};const q=(v??0)-($??0);return{index:f,offsetPx:Math.max(0,c-q)}},[O,r,w.top]),se=t.useCallback(c=>{const f=wt(N.current,w.top),v=typeof c=="function"?c(f):c;E(v);const $=Me.current?.getScrollPosition(),q=typeof $=="number"?$:N.current;return Ie(q),wt(q,it.current)},[w.top,E,Ie]),De=t.useCallback(c=>{const f=Me.current;if(!f)return wt(N.current,it.current);const v=f.scrollTo($=>$+c);return wt(v,it.current)},[]),Be=t.useCallback(c=>Me.current?.applyWheel(c)??!1,[]),ut=t.useCallback((c,f)=>{k.debug("[VirtualScroll] Scroll position changed:",c);const v=xe.current;v&&(xe.current=!1);const $=me.current>0;$&&(me.current=0);const q=h.current&&C.current===r;if(v||$||q||(ge.current=null),Ie(c),ee){if(v||$)return;const B=c-f;if(k.debug("[VirtualScroll] Scroll diff:",B,"New:",c,"Prev:",f),Math.abs(B)>1){const j=B>0?"down":"up";Ze(j),Le(!0),k.debug("[VirtualScroll] Showing scroll buttons. Direction:",j),st.current&&clearTimeout(st.current),st.current=setTimeout(()=>{Le(!1),k.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[Ie,ee,r]),je=t.useMemo(()=>wt(Ke,w.top),[w.top,Ke]),zt=t.useMemo(()=>{const c=O.getTotal(),f=Cn(je,Z,a,r,s,O,c);return k.debug("[VirtualScroll] Calculated rendering range:",()=>({...f,scrollPosition:je,renderingContentSize:c,overscanCount:a,viewportSize:Z})),f},[je,Z,a,r,s,O]),{renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:At,visibleEndIndex:jt}=zt,Mt=t.useCallback((c,f)=>{if(!J||r===0)return;const v=We(c,r);if(!(f?.ensureVisible??!0)){const lt=Xe.current.get(v);lt&&(Se.current=null,Ae.current=v,ye(lt));return}const q=O.prefixSum(v,{materializeOption:{materialize:!1}}),B=q.currentValue,j=Math.max(q.cumulative-B,0),we=j+B,$e=wt(N.current,w.top),Ne=$e+Z;if(j<$e||we>Ne){mt(v);const lt=Xe.current.get(v);lt?(Se.current=null,Ae.current=v,ye(lt)):Se.current=v;return}const ot=Xe.current.get(v);if(ot){Se.current=null,Ae.current=v,ye(ot);return}Se.current=v},[J,r,O,w.top,mt,ye,Z]),$t=t.useCallback((c,f)=>{if(!(!J||c.defaultPrevented)&&!(c.altKey||c.metaKey||c.ctrlKey)&&c.target===c.currentTarget&&!c.currentTarget.isContentEditable){if(c.key==="ArrowLeft"||c.key==="ArrowRight"){const v=fe.current;if(!v||c.shiftKey||!L?.includes("arrow")||!(Number.isFinite(T)&&T>0))return;c.preventDefault(),v(c.key==="ArrowLeft"?-T:T);return}if(c.key==="ArrowDown"){f<r-1&&(c.preventDefault(),Mt(f+1));return}if(c.key==="ArrowUp"){f>0&&(c.preventDefault(),Mt(f-1));return}if(c.key==="PageDown"){if(f<r-1){c.preventDefault();const{visibleStartIndex:v,visibleEndIndex:$}=oe.current,q=Math.max($-v+1,1),B=Math.max(q,1),j=We(Math.min(f+B,r-1),r);Mt(j)}return}if(c.key==="PageUp"&&f>0){c.preventDefault();const{visibleStartIndex:v,visibleEndIndex:$}=oe.current,q=Math.max($-v+1,1),B=Math.max(q,1),j=We(f-B,r);Mt(j)}}},[J,r,Mt,L,T]),qt=t.useCallback((c,f)=>{if(c.key!=="Escape"||c.defaultPrevented||c.nativeEvent.isComposing||c.target===c.currentTarget)return;const v=c.target;v instanceof HTMLInputElement||v instanceof HTMLTextAreaElement||v instanceof HTMLSelectElement||v.isContentEditable||(c.preventDefault(),Mt(f))},[Mt]),lr=t.useCallback(c=>{if(!J)return;const f=We(c,r);Se.current=null,Ae.current=f,Re?.(f)},[J,r,Re]);t.useEffect(()=>{const c=Me.current?.getScrollPosition()??0,f=N.current,v=wt(f,w.top);k.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:At,visibleEndIndex:jt,scrollPositionState:Ke,paneScrollPosition:f,logicalScrollPosition:v,contentSize:gt,scrollPaneScrollPosition:c})),et({renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:At,visibleEndIndex:jt,scrollPosition:v,totalHeight:gt})},[gt,kt,vt,w.top,et,Ke,jt,At]);const Et=t.useCallback(()=>{if(!ee)return null;const c=Qe&&ct!==null,f=ct==="up";return V.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:f?V.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:V.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:v=>{v.stopPropagation(),xe.current=!0,mt(0),Le(!1)},children:ce.scrollToTop})}):V.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:V.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:v=>{v.stopPropagation(),xe.current=!0,mt(r-1),Le(!1)},children:ce.scrollToBottom})})})},[ee,Qe,ct,mt,r,ce]),Ct=t.useRef(0),{visibleItems:Dt,renderAnchor:Pt}=t.useMemo(()=>{if(r===0)return{visibleItems:V.jsx("div",{className:"aqvs-no-items-container",children:V.jsx("div",{className:"aqvs-no-items-text",children:ce.noItems})}),renderAnchor:0};const c=We(vt,r),f=We(kt,r),{cumulative:v,currentValue:$}=O.prefixSum(c,{materializeOption:{materialize:!1}}),q=v-$;Number.isFinite(q)&&Math.abs(q-Ct.current)>En&&(Ct.current=q);const B=Ct.current,j=[],we=[];let $e=0,Ne=q;for(let ze=c;ze<=f;ze++){if(we.length>=_r){k.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:_r,safeRenderingStartIndex:c,safeRenderingEndIndex:f});break}const ot=s(ze),lt=O.get(ze),dt=ot-lt;dt!==0&&j.push({index:ze,value:ot});const Zt=Ne+$e,ur=n?n(ze):ze;we.push(V.jsx(hs,{index:ze,top:Zt-B,height:ot,item:e(ze),clipItemHeight:Fe,enableKeyboardNavigation:J,onKeyDown:$t,onEscapeKeyDown:Ue?qt:void 0,onFocus:lr,registerItemRef:Ft,children:b},ur)),$e+=dt,Ne+=lt}return j.length>0&&Promise.resolve().then(()=>{if(ue.current)return;let ze=0;for(const dt of j)if(dt.index<At){const Zt=O.get(dt.index);ze+=dt.value-Zt}const ot=O.updates(j);if(ue.current||typeof ot!="number")return;x(ot),k.debug("[VirtualScroll] Updated heights for items",j,"New total height:",ot);const lt=Me.current?.getScrollPosition()??N.current;if(ze!==0){const dt=lt+ze;xt(dt,ze),Ie(dt,{immediate:!0}),k.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:lt,to:dt,shiftAmount:ze})}else lt!==N.current&&Ie(lt)}),{visibleItems:we,renderAnchor:B}},[b,Fe,gt,J,r,O,e,n,s,lr,$t,Ue,qt,xt,Ft,kt,vt,ce,Ie,At]),Wt=t.useCallback(c=>{const f=(W??0)>0,v=Math.abs(c-Ke),$=f&&v>.5?Ke:c,q=wt($,w.top);if(k.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:q,renderingStartIndex:vt,renderingEndIndex:kt,itemCount:r,viewportSize:Z,callbackThrottleMs:W,diff:v,rawEffectiveScrollPosition:$})),r===0)return Dt;const B=w.top+Pt-$,j=w.bottom>0?V.jsx("div",{className:"aqvs-bottom-inset",style:{top:O.getTotal()-Pt,height:w.bottom}},"virtualscroll-bottom-inset"):null;return k.debug("[VirtualScroll] Rendering items",()=>({containerTop:B,logicalScrollPosition:je,resolvedInsets:w,effectiveScrollPosition:q})),V.jsxs("div",{className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${B}px)`,willChange:"transform"},children:[Dt,j]})},[W,r,O,je,Pt,kt,vt,w,Ke,Z,Dt]),Ut=t.useMemo(()=>({renderingStartIndex:zt.renderingStartIndex,renderingEndIndex:zt.renderingEndIndex,visibleStartIndex:zt.visibleStartIndex,visibleEndIndex:zt.visibleEndIndex,scrollPosition:je,totalHeight:O.getTotal()}),[zt,je,O,gt]);t.useEffect(()=>{oe.current=Ut},[Ut]);const[Gt,St]=t.useState(""),Kt=t.useRef(U);t.useLayoutEffect(()=>{Kt.current=U},[U]);const yt=U?.debounceMs??400,ht=Number.isFinite(yt)&&yt>=0,tr=U!==void 0;t.useEffect(()=>{tr&&!ht&&k.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${yt}. Announcements are disabled.`)},[tr,ht,yt]),t.useEffect(()=>{if(!(tr&&ht)){St("");return}const c=setTimeout(()=>{const f=Kt.current?.format;if(!f)return;const v=f({visibleStartIndex:At,visibleEndIndex:jt,itemCount:r});St(v)},yt);return()=>clearTimeout(c)},[tr,ht,yt,At,jt,r]),t.useImperativeHandle(K,()=>({getScrollPosition:()=>{const c=Me.current?.getScrollPosition();return typeof c=="number"?wt(c,it.current):-1},getContentSize:()=>Me.current?.getContentSize()??-1,getViewportSize:()=>Me.current?.getViewportSize()??-1,scrollTo:se,scrollBy:De,applyWheel:Be,scrollToIndex:mt,getFenwickTreeTotalHeight:()=>O.getTotal(),getFenwickSize:()=>O.getSize(),focusItemAtIndex:Mt,getRange:()=>oe.current,getScrollAnchor:D,updateItemSize:Lt}),[se,De,Be,mt,O,Mt,D,Lt]);const Yt=O.getTotal()+w.top+w.bottom,cr=V.jsx(In,{ref:Me,contentSize:Yt,viewportSize:i,onViewportSizeChange:ke,className:o,testId:u,onScroll:ut,background:I,tapScrollCircleOptions:_e,inertiaOptions:Ge,overscrollBehavior:pt,itemCount:r,scrollBarWidth:re,enableThumbDrag:he,enableTrackClick:Oe,enableArrowButtons:M,enablePointerDrag:qe,pointerDragInputs:pe,renderThumbOverlay:te,wheelSpeedMultiplier:rt,onWheelHorizontal:F,onPanHorizontal:ae,contentInsets:w,contentProps:z,visibleStartIndex:At,visibleEndIndex:jt,renderOverlay:Et,initialScrollPosition:at.position,locale:Y,labels:H,children:Wt});return tr?V.jsxs(V.Fragment,{children:[cr,V.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Gt})]}):cr},Pn=t.forwardRef(ps),br=262144,pn=3,Nn=32768,Fr=128,Hr=128,Xr=128,$r=128,Vr=10,gs=(r,e)=>Math.max(1,Math.floor((r??Nn)/Math.max(1,e))),bs=(r,e,n,s,i)=>{let a=0,o=0,u=Math.max(0,Math.min(s,n-1));for(;u<n&&a<r&&o<_r;)a+=e(u),o+=1,u+=1;return Math.max(1,o+2*i+2)},yr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=br))throw new RangeError(`[VirtualGrid] ${e==="row"?"getRowHeight":"getColWidth"}(${n}) returned ${r} — must be an integer in [0, ${br}] (0 = hidden). Oversized tracks would pierce the browser layout-coordinate wall (see the design plan §3.1/§6).`);return r},xs=(r,e,n,s,i,a,o,u)=>{const m=Cn(r,e,n,s,i,a,o);if(s===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const g=Q(m.renderingStartIndex,0,s-1),{cumulative:b,currentValue:I}=a.prefixSum(g,{materializeOption:{materialize:!1}}),y=b-I,S=Number.isFinite(y)&&Math.abs(y-u)>En?y:u;return{renderingColStart:m.renderingStartIndex,renderingColEnd:m.renderingEndIndex,visibleColStart:m.visibleStartIndex,visibleColEnd:m.visibleEndIndex,colAnchor:S}},gn=[],vs=(r,e,n,s,i)=>{const a=[],o=[];if(e<r)return{columns:a,widthUpdates:o,truncated:0};const u=s.prefixSum(r,{materializeOption:{materialize:!1}});let m=u.cumulative-u.currentValue,g=0,b=r;for(;b<=e;){if(a.length>=i)return{columns:a,widthUpdates:o,truncated:e-b+1};const I=n(b),y=s.get(b);if(I!==y&&o.push({index:b,value:I}),I>0){a.push({col:b,left:m,width:I}),m+=y,g=0,b+=1;continue}if(m+=y,g+=1,b+=1,g>gr){const S=s.findIndexAtOrAfter(m+.5,{materializeOption:{materialize:!1}});if(S.index===-1||S.index<=b||!Number.isSafeInteger(S.index))break;const P=s.prefixSum(S.index,{materializeOption:{materialize:!1}});m=P.cumulative-P.currentValue,b=S.index,g=0}}return{columns:a,widthUpdates:o,truncated:0}},Ss=(r,e,n)=>{const s=[],i=[];let a=0;for(let o=0;o<r;o+=1){const u=e(o),m=n.get(o);u!==m&&i.push({index:o,value:u}),u>0&&s.push({col:o,left:a,width:u}),a+=m}return{columns:s,widthUpdates:i,width:a}},ws=(r,e,n,s)=>{const i=[],a=[];let o=0;for(let u=r-e;u<r;u+=1){const m=n(u),g=s.get(u);m!==g&&a.push({index:u,value:m}),m>0&&i.push({col:u,left:o,width:m}),o+=g}return{columns:i,widthUpdates:a,width:o}},Ir=(r,e,n)=>Math.min(r,Math.max(0,n-e)),Rs={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},Ms=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:s,getCell:i,getCellKey:a,children:o,getCellProps:u,getRowProps:m,contentProps:g,background:b,contentInsets:I,onRowFocus:y,frozenLeadingCols:S=0,frozenLeadingRows:P=0,frozenTrailingCols:W=0,frozenTrailingRows:_=0,horizontalKeyInputs:Re,horizontalKeyStep:Te,onScroll:A,onRangeChange:F,onRenderTruncated:ae,callbackThrottleMs:L,initialScrollAnchor:T,overscanRows:z=pn,overscanCols:U=pn,viewportSize:Y,__maxRenderedCells:H,behaviorOptions:K,scrollBarOptions:re,liveRegion:he,locale:Oe,labels:M,className:ee,testId:te},_e)=>{const ce=t.useRef(null),qe=t.useRef(null),pe=t.useRef(n);pe.current=n;const J=t.useRef(s);J.current=s;const Ue=K?.resetOnGetColWidthChange===!0,Ge=K?.resetOnGetItemHeightChange===!0?n:null,pt=Ue?s:null,Fe=t.useCallback(l=>yr(pe.current(l),"row",l),[Ge]),He=t.useCallback(l=>yr(J.current(l),"col",l),[pt]),Ee=K?.defaultColWidth,nt=t.useMemo(()=>{if(Ee!==void 0&&!(Number.isInteger(Ee)&&Ee>=0&&Ee<=br))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${br}], received ${Ee}.`);return{resetOnValueFnChange:Ue,baseValue:Ee}},[Ue,Ee]),Z=Ur(e,He,nt),[ke,Me]=t.useState(0);if(!(Number.isInteger(S)&&S>=0&&S<=Fr))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${Fr}], received ${S}.`);const oe=Math.min(S,e),ge=t.useRef(0);if(!(Number.isInteger(W)&&W>=0&&W<=Xr))throw new RangeError(`[VirtualGrid] frozenTrailingCols must be an integer in [0, ${Xr}], received ${W}.`);const ue=Math.min(W,e-oe),ft=t.useRef(0);if(!(Number.isInteger(P)&&P>=0&&P<=Hr))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${Hr}], received ${P}.`);const w=Math.min(P,r);if(!(Number.isInteger(_)&&_>=0&&_<=$r))throw new RangeError(`[VirtualGrid] frozenTrailingRows must be an integer in [0, ${$r}], received ${_}.`);const Ve=Math.min(_,r-w),de=Math.max(0,r-w-Ve),O=t.useRef(!1),at=t.useRef(0),Ke=t.useRef(0),[Tt,gt]=t.useState(0),{frozenRows:x,frozenHeight:N}=t.useMemo(()=>{if(w===0)return{frozenRows:[],frozenHeight:0};const l=[];let p=0;for(let R=0;R<w;R+=1){const X=Fe(R);X>0&&l.push({row:R,top:p,height:X}),p+=X}return{frozenRows:l,frozenHeight:p}},[w,Tt,Fe]);at.current=N;const[le,G]=t.useState(0),{trailingRows:ne,trailingHeight:fe}=t.useMemo(()=>{if(Ve===0)return{trailingRows:[],trailingHeight:0};const l=[];let p=0;for(let R=r-Ve;R<r;R+=1){const X=Fe(R);X>0&&l.push({row:R,top:p,height:X}),p+=X}return{trailingRows:l,trailingHeight:p}},[Ve,r,le,Fe]);Ke.current=fe;const Ye=t.useCallback(l=>Fe(l+w),[Fe,w]),be=t.useRef(y);be.current=y;const Xe=y!==void 0,Se=t.useMemo(()=>Xe?l=>be.current?.(l+w):void 0,[w,Xe]),Ae=N,ct=fe,[Ze,Qe]=t.useState(w),Le=t.useRef(null),st=t.useRef(!1);if(Ze!==w){Qe(w),st.current=!0;const l=ce.current?.getScrollAnchor()??null;Le.current=l===null?null:{row:l.index+Ze,offsetPx:l.offsetPx}}const xe=t.useRef(0),me=t.useRef(0),bt=t.useRef(!1),[h,C]=t.useState(Rs),ye=t.useRef(h);ye.current=h;const Je=t.useRef(0),[Ce,Rt]=t.useState(()=>Z.getTotal()??0),et=t.useRef(Ce);et.current=Ce;const it=t.useCallback(l=>{typeof l=="number"&&Number.isFinite(l)&&(et.current=l,Rt(l))},[]);t.useLayoutEffect(()=>{const l=Z.getTotal();typeof l=="number"&&Number.isFinite(l)&&l!==et.current&&it(l)});const Pe=re?.width??12,Ft=Y===void 0?null:{width:Math.max(0,Math.round(Y.width)-Pe),height:Math.max(0,Math.round(Y.height)-Pe)},[nr,Ht]=t.useState({width:0,height:0}),ve=Ft??nr,Nt=t.useRef(ve);Nt.current=ve;const Bt=ve.height>0&&ve.height-N-fe<=0;O.current=Bt;const er=Ft!==null;t.useLayoutEffect(()=>{if(er)return;const l=qe.current;if(l===null)return;const p=()=>{const X=Math.max(0,Math.round(l.clientWidth)-Pe),ie=Math.max(0,Math.round(l.clientHeight)-Pe);Ht(tt=>tt.width===X&&tt.height===ie?tt:{width:X,height:ie})};p();const R=new ResizeObserver(p);return R.observe(l),()=>R.disconnect()},[Pe,er]);const Ie=t.useCallback(()=>{const l=qe.current;l!==null&&l.style.setProperty("--aqvs-grid-hx-residual",`${Je.current-xe.current}px`)},[]),xt=t.useCallback(()=>Math.max(0,Nt.current.width-ge.current-ft.current),[]),Xt=t.useCallback(()=>Math.max(0,et.current-ge.current-ft.current-xt()),[xt]),Lt=t.useCallback(()=>{const l=xt(),p=xs(ge.current+xe.current,l,U,e,He,Z,et.current,ye.current.colAnchor);if(oe>0&&(p.renderingColStart=Math.max(p.renderingColStart,oe),p.visibleColStart=Math.max(p.visibleColStart,oe)),ue>0){const X=e-ue-1;p.renderingColEnd=Math.min(p.renderingColEnd,X),p.visibleColEnd=Math.min(p.visibleColEnd,X)}(oe>0||ue>0)&&(l<=0||p.renderingColStart>p.renderingColEnd)&&(p.renderingColStart=e,p.renderingColEnd=e-1,p.visibleColStart=e,p.visibleColEnd=e-1);const R=`${p.renderingColStart}:${p.renderingColEnd}:${p.colAnchor}`;R!==ye.current.key&&C({...p,key:R})},[U,e,He,Z,oe,ue,xt]),[mt,d]=t.useState(0),E=t.useRef(null),D=t.useCallback(()=>{E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null,d(xe.current)}))},[]);t.useEffect(()=>()=>{E.current!==null&&cancelAnimationFrame(E.current)},[]);const se=t.useRef(A);se.current=A;const De=t.useRef(F);De.current=F;const Be=t.useRef(ae);Be.current=ae;const ut=t.useRef(null),[je,zt]=t.useState(null),[vt,kt]=t.useState(ve.height);vt!==ve.height&&(kt(ve.height),zt(null));const At=T===void 0||r===0?0:Q(Math.trunc(T.row),0,r-1),jt=t.useMemo(()=>{const l=ut.current?.renderingStartIndex??At;return bs(Math.max(0,ve.height-at.current-Ke.current),Fe,r,l,z)},[ve.height,Fe,r,At,z,Ae,ct]),Mt=je??jt,$t=t.useCallback(()=>{const l=ut.current;if(l===null)return null;const p=ye.current;return{renderingRowStart:l.renderingStartIndex,renderingRowEnd:l.renderingEndIndex,visibleRowStart:l.visibleStartIndex,visibleRowEnd:l.visibleEndIndex,renderingColStart:p.renderingColStart,renderingColEnd:p.renderingColEnd,visibleColStart:p.visibleColStart,visibleColEnd:p.visibleColEnd,scrollX:xe.current,scrollY:me.current,totalWidth:et.current,totalHeight:l.totalHeight+at.current+Ke.current}},[]),qt=t.useCallback(()=>{const l=$t();l!==null&&De.current?.(l)},[$t]),lr=t.useCallback(l=>{const p=Xt(),R=Q(l,0,p);return R!==xe.current&&(xe.current=R,Ie(),Lt(),D(),se.current?.({x:R,y:me.current})),R},[Ie,Lt,D,Xt]),Et=t.useRef(lr);Et.current=lr,t.useLayoutEffect(()=>{Je.current=h.colAnchor,Ie(),qt()},[h,Ie,qt]),t.useLayoutEffect(()=>{ut.current!==null&&qt()},[N,fe,qt]);const Ct=t.useRef(null),Dt=t.useCallback(l=>{const p=Q(l.col,0,Math.max(0,e-1)),R=Z.prefixSum(p,{materializeOption:{materialize:!1}}),X=R.cumulative-R.currentValue,ie=R.currentValue,tt=xt();return(l.alignX==="end"?X+ie-ge.current-tt:l.alignX==="center"?X+ie/2-ge.current-tt/2:X-ge.current)+l.offsetX},[Z,e,xt]),Pt=t.useRef(null),Wt=t.useCallback(()=>{const l=Pt.current;Pt.current=null,!(l===null||l.length===0)&&(it(Z.updates(l)),Me(p=>p+1))},[Z,it]),Ut=t.useRef({count:0,warned:!1}),{frozenColumns:Gt,frozenWidth:St}=t.useMemo(()=>{if(oe===0)return Ut.current.count=0,Ut.current.warned=!1,{frozenColumns:gn,frozenWidth:0};const{columns:l,widthUpdates:p,width:R}=Ss(oe,He,Z);if(p.length>0){const X=Ut.current;X.count>=Vr?X.warned||(X.warned=!0,k.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values inside the frozen band; width self-heal is suspended until a converged pass re-arms it (unstable accessor).",{frozenCols:oe,pendingUpdates:p.length})):(X.count+=1,Pt.current=[...Pt.current??[],...p],Promise.resolve().then(Wt))}else Ut.current.count=0,Ut.current.warned=!1;return{frozenColumns:l,frozenWidth:R}},[oe,ke,He,Z,Wt]);ge.current=St,t.useLayoutEffect(()=>{oe>0?qe.current?.style.setProperty("--aqvs-grid-frozen-width",`${St}px`):qe.current?.style.removeProperty("--aqvs-grid-frozen-width")},[St,oe]);const Kt=t.useRef({count:0,warned:!1}),{trailingColumns:yt,trailingWidth:ht}=t.useMemo(()=>{if(ue===0)return Kt.current.count=0,Kt.current.warned=!1,{trailingColumns:gn,trailingWidth:0};const{columns:l,widthUpdates:p,width:R}=ws(e,ue,He,Z);if(p.length>0){const X=Kt.current;X.count>=Vr?X.warned||(X.warned=!0,k.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values inside the trailing band; width self-heal is suspended until a converged pass re-arms it (unstable accessor).",{trailingCols:ue,pendingUpdates:p.length})):(X.count+=1,Pt.current=[...Pt.current??[],...p],Promise.resolve().then(Wt))}else Kt.current.count=0,Kt.current.warned=!1;return{trailingColumns:l,trailingWidth:R}},[ue,e,ke,He,Z,Wt]);ft.current=ht,t.useLayoutEffect(()=>{ue>0?qe.current?.style.setProperty("--aqvs-grid-trailing-width",`${ht}px`):qe.current?.style.removeProperty("--aqvs-grid-trailing-width")},[ht,ue]);const tr=t.useMemo(()=>({...re,tapScrollCircleOptions:{...re?.tapScrollCircleOptions,enabled:!1}}),[re]),Yt=re?.tapScrollCircleOptions,cr=typeof Yt?.maxSpeedMultiplier=="number",c=t.useMemo(()=>({...Yt,offsetX:Yt?.offsetX===void 0?dn:Yt.offsetX,offsetY:Yt?.offsetY===void 0?dn:Yt.offsetY}),[Yt]),f=t.useMemo(()=>Or(c,Math.max(0,e-oe-ue)),[c,e,oe,ue]),v=t.useMemo(()=>Or(c,de),[c,de]),$=f.enabled,q=Math.max(f.maxVisualDistance,1),B={viewportSize:Math.max(0,ve.width-St-ht),minSpeedMultiplier:f.minSpeedMultiplier,maxSpeedMultiplier:f.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:cr,curve:f.maxSpeedCurve},j={viewportSize:Math.max(0,ve.height-N-fe),minSpeedMultiplier:v.minSpeedMultiplier,maxSpeedMultiplier:v.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:cr,curve:v.maxSpeedCurve},we=t.useCallback(()=>xe.current,[]),$e=t.useCallback(()=>{const l=ce.current;if(l===null)return me.current;const p=l.getScrollPosition();return p<0?me.current:p},[]),Ne=t.useCallback(()=>{const l=ce.current;return l===null?0:Math.max(0,Math.max(0,l.getContentSize())-Math.max(0,l.getViewportSize()))},[]),ze=t.useCallback(l=>{const p=ce.current;if(p===null)return me.current;const R=p.scrollBy(l);return me.current=R,R},[]),ot=Xt()>0||Ne()>0,lt=`${Ce}:${St}:${ht}:${ve.width}:${h.key}`,dt=`${r}:${je??-1}:${N}:${fe}:${ve.height}`,{isTapActive:Zt,handleTapCircleDragChange:ur,tapCircleHandleRef:zn}=ds({enabled:$&&ot,maxDistance:q,xSpeedParams:B,ySpeedParams:j,applyHxRef:Et,getHx:we,getMaxHx:Xt,applyVy:ze,getVy:$e,getMaxVy:Ne,pendingColAnchorRef:Ct,xExtentFreshness:lt,yExtentFreshness:dt}),kn=t.useMemo(()=>Q((Zt?1:.8)*f.opacity,0,1),[Zt,f.opacity]);t.useLayoutEffect(()=>{const l=Ct.current;l===null?Et.current(xe.current):Et.current(Dt(l)),Lt()},[ve.width,Ce,ke,St,ht,Lt,Dt]);const Gr=t.useRef(!1);t.useLayoutEffect(()=>{if(Gr.current||T===void 0||e===0)return;Gr.current=!0;const l=Q(Math.trunc(T.col),0,e-1);if(l<oe||l>=e-ue)return;const p={col:l,alignX:"start",offsetX:Math.max(0,T.offsetX)};Ct.current=p,Et.current(Dt(p))},[T,e,Dt,oe,ue]);const An=t.useCallback(l=>{me.current=l,bt.current=!0,se.current?.({x:xe.current,y:l})},[]),Kr=t.useCallback(l=>{if(de===0||O.current)ut.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:de===0?0:l.totalHeight},me.current=0;else{const p=w;ut.current={renderingStartIndex:l.renderingStartIndex+p,renderingEndIndex:l.renderingEndIndex+p,visibleStartIndex:l.visibleStartIndex+p,visibleEndIndex:l.visibleEndIndex+p,scrollPosition:l.scrollPosition,totalHeight:l.totalHeight},me.current=l.scrollPosition}zt(p=>{const R=Math.max(1,l.renderingEndIndex-l.renderingStartIndex+1);return R===p?p:R}),qt()},[qt,w,de,r]),Zr=t.useCallback(l=>{Ct.current=null,Et.current(xe.current+l)},[]),Qr=gs(H,Mt+x.length+ne.length),Cr=t.useRef({count:0,warned:!1}),{placedColumns:xr,truncatedCols:vr}=t.useMemo(()=>{const l=Math.max(0,ve.width-St-ht);if(e===0||l<=0)return{placedColumns:[],truncatedCols:0};if(h.renderingColStart>h.renderingColEnd)return{placedColumns:[],truncatedCols:0};const p=Math.max(1,Qr-Gt.length-yt.length),{columns:R,widthUpdates:X,truncated:ie}=vs(Q(h.renderingColStart,0,e-1),Q(h.renderingColEnd,0,e-1),He,Z,p);if(X.length>0){const tt=Cr.current;tt.count>=Vr?tt.warned||(tt.warned=!0,k.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values; width self-heal is suspended until a converged (zero-deviation) pass re-arms it (unstable accessor — the accessor must be index-stable while the ordering is unchanged).",{window:h.key,pendingUpdates:X.length})):(tt.count+=1,Pt.current=[...Pt.current??[],...X],Promise.resolve().then(Wt))}else Cr.current.count=0,Cr.current.warned=!1;return{placedColumns:R,truncatedCols:ie}},[h,e,ve.width,St,ht,Gt.length,yt.length,ke,He,Z,Qr,Wt]),Jr=t.useRef("");t.useEffect(()=>{if(vr>0){const l=`${h.key}:${vr}`;l!==Jr.current&&(Jr.current=l,Be.current?.({renderedCells:(xr.length+Gt.length+yt.length)*(Mt+x.length+ne.length),droppedCols:vr}))}},[vr,h.key,xr.length,Gt.length,yt.length,Mt,x.length,ne.length]);const en=h.colAnchor,Pr=t.useCallback(l=>{const p=m?.(l),R=Fe(l)===0,X=R?null:xr.map(({col:ie,left:tt,width:ir})=>{const Vt=u?.(l,ie),dr={...Vt?.style,left:tt-en,width:ir};return t.createElement("div",{...Vt,key:a?a(l,ie):ie,className:It.twMerge("aqvs-grid-cell",Vt?.className),style:dr},o(i(l,ie),l,ie))});return oe===0&&ue===0?V.jsx("div",{...p,className:It.twMerge("aqvs-grid-row",p?.className),style:p?.style,children:X}):V.jsxs("div",{...p,"data-aqvs-frozen-row":oe>0?"":void 0,className:It.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",p?.className),style:p?.style,children:[R?null:Gt.map(({col:ie,left:tt,width:ir})=>{const Vt=u?.(l,ie),dr={...Vt?.style,left:tt,width:ir};return t.createElement("div",{...Vt,"data-aqvs-frozen-cell":"",key:a?a(l,ie):ie,className:It.twMerge("aqvs-grid-cell",Vt?.className),style:dr},o(i(l,ie),l,ie))}),R?null:V.jsx("div",{className:"aqvs-grid-row-scroll",children:V.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:X})}),R||ue===0?null:V.jsx("div",{className:"aqvs-grid-row-trailing",children:V.jsx("div",{className:"aqvs-grid-row-trailing-inner",children:yt.map(({col:ie,left:tt,width:ir})=>{const Vt=u?.(l,ie),dr={...Vt?.style,left:tt,width:ir};return t.createElement("div",{...Vt,"data-aqvs-trailing-cell":"",key:a?a(l,ie):ie,className:It.twMerge("aqvs-grid-cell",Vt?.className),style:dr},o(i(l,ie),l,ie))})})})]})},[xr,Gt,yt,oe,ue,en,m,u,a,i,o,Fe]),[Vn,Ln]=t.useState(""),sr=t.useRef(null),tn=t.useRef(he);tn.current=he;const Sr=t.useCallback(()=>{const l=tn.current;if(l===void 0)return;const p=l.debounceMs??400;Number.isFinite(p)&&p>=0&&(sr.current!==null&&window.clearTimeout(sr.current),sr.current=window.setTimeout(()=>{sr.current=null;const R=$t();R!==null&&Ln(X=>{const ie=l.buildMessage(R);return ie===X?X:ie})},p))},[$t]),wr=he?.debounceMs??400,rn=Number.isFinite(wr)&&wr>=0,nn=he!==void 0;t.useEffect(()=>{nn&&!rn&&k.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${wr}. Announcements are disabled.`)},[nn,rn,wr]),t.useEffect(()=>()=>{sr.current!==null&&window.clearTimeout(sr.current)},[]),t.useEffect(()=>{Sr()},[h,Sr]);const Dn=t.useCallback(l=>{Kr(l),Sr()},[Kr,Sr]);return t.useImperativeHandle(_e,()=>({scrollTo:l=>{const p=ce.current;let R=me.current;l.y!==void 0&&p!==null&&(p.scrollTo(l.y),R=p.getScrollPosition(),me.current=R);let X=xe.current;return l.x!==void 0&&(Ct.current=null,X=Et.current(l.x)),{x:X,y:R}},scrollBy:l=>{const p=ce.current;let R=me.current;l.y!==void 0&&l.y!==0&&p!==null&&(R=p.scrollBy(l.y),me.current=R);let X=xe.current;return l.x!==void 0&&l.x!==0&&(Ct.current=null,X=Et.current(xe.current+l.x)),{x:X,y:R}},scrollToCell:(l,p,R)=>{const X=ce.current;if(X!==null&&r>0){const ie=Q(Math.trunc(l),0,r-1);ie>=w&&ie<r-Ve&&X.scrollToIndex(ie-w,{align:R?.alignY??"top",offset:R?.offsetY})}if(e>0){const ie=Q(Math.trunc(p),0,e-1);if(ie>=oe&&ie<e-ue){const tt={col:ie,alignX:R?.alignX??"start",offsetX:R?.offsetX??0};Ct.current=tt,Et.current(Dt(tt))}}},getScrollPosition:()=>bt.current||ce.current!==null?{x:xe.current,y:ce.current?.getScrollPosition()??me.current}:{x:-1,y:-1},getScrollAnchor:()=>{if(r===0||e===0)return null;const l=ce.current?.getScrollAnchor()??null;if(l===null)return null;const p=ge.current+xe.current,R=Z.findIndexAtOrAfter(p,{materializeOption:{materialize:!1}});if(R.index===-1)return{row:l.index+w,col:e-1,offsetX:0,offsetY:l.offsetPx};if(R.cumulative===p)return{row:l.index+w,col:Q(R.index+1,0,e-1),offsetX:0,offsetY:l.offsetPx};const X=(R.cumulative??0)-(R.currentValue??0);return{row:l.index+w,col:R.index,offsetX:Math.max(0,p-X),offsetY:l.offsetPx}},getViewportSize:()=>({width:Nt.current.width,height:Nt.current.height}),getContentSize:()=>({width:et.current,height:ce.current===null?0:at.current+Ke.current+Math.max(0,ce.current.getContentSize())}),getRange:$t,updateRowSize:(l,p)=>{yr(p,"row",l),Math.trunc(l)<w?gt(R=>R+1):Ve>0&&Math.trunc(l)>=r-Ve?G(R=>R+1):ce.current?.updateItemSize(Math.trunc(l)-w,p)},updateColSize:(l,p)=>{yr(p,"col",l),it(Z.update(Q(Math.trunc(l),0,Math.max(0,e-1)),p)),Me(R=>R+1)},getFrozenSize:()=>({cols:oe,width:ge.current,rows:w,height:at.current,trailingCols:ue,trailingRows:Ve,trailingWidth:ft.current,trailingHeight:Ke.current,trailingVisibleWidth:Ir(ft.current,ge.current,Nt.current.width),trailingVisibleHeight:Ir(Ke.current,at.current,Nt.current.height)}),applyWheel:l=>ce.current?.applyWheel(l)??!1,focusRowAtIndex:(l,p)=>{const R=Math.trunc(l);R<w?qe.current?.querySelector(`[data-aqvs-frozen-band-row="${R}"]`)?.focus():Ve>0&&R>=r-Ve?qe.current?.querySelector(`[data-aqvs-trailing-band-row="${R}"]`)?.focus():ce.current?.focusItemAtIndex(R-w,p)}}),[r,e,Z,$t,it,Dt,oe,w,ue,Ve]),V.jsxs("div",{ref:qe,className:It.twMerge("aqvs-grid",w>0?"aqvs-grid-has-frozen-rows":"",Ve>0?"aqvs-grid-has-trailing-rows":"",ee),"data-testid":te,children:[w>0?V.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:N},"data-testid":te?`${te}-frozen-rows`:void 0,children:x.map(({row:l,top:p,height:R})=>V.jsx("div",{"data-aqvs-frozen-band-row":l,className:"aqvs-grid-frozen-band-row",style:{top:p,height:R,right:Pe},tabIndex:-1,onFocus:()=>y?.(l),children:Pr(l)},l))}):null,V.jsx("div",{className:"aqvs-grid-main","data-testid":te?`${te}-main`:void 0,children:V.jsx(Pn,{ref:ce,itemCount:Bt?0:de,getItem:l=>l+w,getItemKey:l=>l+w,getItemHeight:Ye,overscanCount:z,viewportSize:ve.height>0?Math.max(0,ve.height-N-fe):void 0,callbackThrottleMs:L,behaviorOptions:K,scrollBarOptions:tr,contentProps:g,background:b,contentInsets:I,onItemFocus:Se,horizontalKeyInputs:Re,horizontalKeyStep:Te,initialScrollAnchor:st.current?Le.current!==null&&Le.current.row>=w&&de>0?{index:Le.current.row-w,offsetPx:Le.current.offsetPx}:void 0:T!==void 0&&de>0&&Math.trunc(T.row)>=w&&Math.trunc(T.row)<r-Ve?{index:Math.trunc(T.row)-w,offsetPx:T.offsetY}:void 0,onScroll:An,onRangeChange:Dn,onWheelHorizontal:Zr,onPanHorizontal:Zr,locale:Oe,labels:M,testId:te?`${te}-rows`:void 0,children:Pr},w)}),Ve>0?V.jsx("div",{className:"aqvs-grid-trailing-rows",style:{height:Ir(fe,N,ve.height)},"data-testid":te?`${te}-trailing-rows`:void 0,children:V.jsx("div",{className:"aqvs-grid-trailing-rows-inner",style:{height:fe},children:ne.map(({row:l,top:p,height:R})=>V.jsx("div",{"data-aqvs-trailing-band-row":l,className:"aqvs-grid-trailing-band-row",style:{top:p,height:R,right:Pe},tabIndex:-1,onFocus:()=>y?.(l),children:Pr(l)},l))})}):null,V.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:Pe,paddingRight:ue>0?Pe+Ir(ht,St,ve.width):Pe},"data-testid":te?`${te}-hbar`:void 0,children:V.jsx(Wr,{horizontal:!0,contentSize:Math.max(0,Ce-St-ht),viewportSize:Math.max(0,ve.width-St-ht),scrollPosition:mt,itemCount:Math.max(0,e-oe-ue),tapScrollCircleOptions:re?.tapScrollCircleOptions,onScroll:(l,p)=>(Ct.current=null,Et.current(typeof l=="function"?l(p??xe.current):l)),scrollBarWidth:Pe,locale:Oe,labels:M})}),$&&ot&&V.jsx("div",{className:"aqvs-grid-tap-circle-wrapper","data-aqvs-grid-tap-circle":"",style:{left:`min(calc(100% - ${Pe+f.size}px), max(calc(100% - ${Pe}px + ${f.offsetX}px), calc(75% - ${f.size/2}px)))`,top:`min(calc(100% - ${Pe+f.size}px), max(calc(100% - ${Pe}px + ${f.offsetY}px), calc(75% - ${f.size/2}px)))`},children:V.jsx(Br,{axis:"xy",ref:zn,className:It.twMerge("aqvs-grid-tap-circle",f.className),size:f.size,maxVisualDistance:q,opacity:kn,renderVisual:f.renderVisual,onDragChange:ur})}),he!==void 0?V.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":te?`${te}-live`:void 0,children:Vn}):null]})},ys=t.forwardRef(Ms);exports.FenwickMapTree=_t;exports.MAX_FROZEN_LEADING_COLS=Fr;exports.MAX_FROZEN_LEADING_ROWS=Hr;exports.MAX_FROZEN_TRAILING_COLS=Xr;exports.MAX_FROZEN_TRAILING_ROWS=$r;exports.MAX_RENDERED_CELLS=Nn;exports.MAX_TRACK_SIZE=br;exports.ScrollBar=Wr;exports.ScrollPane=In;exports.TAP_SCROLL_SPEED_DEFAULTS=jr;exports.VIRTUAL_SCROLL_LABEL_CATALOGS=bn;exports.VIRTUAL_SCROLL_LABEL_KEYS=Tr;exports.VIRTUAL_SCROLL_LOCALES=qr;exports.VirtualGrid=ys;exports.VirtualScroll=Pn;exports.computeAutoTapScrollMaxSpeedMultiplier=Rn;exports.computeTapScrollSpeed=Er;exports.computeTapScrollVelocity=Mn;exports.createResidualQuantizer=Qn;exports.minmax=Q;exports.resolveVirtualScrollLabels=Yr;exports.resolveVirtualScrollLocale=xn;exports.tapScrollCircleSampleVisual=ss;exports.useFenwickMapTree=Ur;exports.useHeightCache=cs;exports.useLruCache=Tn;exports.useWheelBridge=us;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react/jsx-runtime"),t=require("react"),Et=require("tailwind-merge"),Yr=["en","ja"],Er=["scrollUp","scrollDown","scrollLeft","scrollRight","scrollToTop","scrollToBottom","noItems"],xn=Object.freeze({en:Object.freeze({scrollUp:"Scroll up",scrollDown:"Scroll down",scrollLeft:"Scroll left",scrollRight:"Scroll right",scrollToTop:"Top",scrollToBottom:"Bottom",noItems:"No items"}),ja:Object.freeze({scrollUp:"上へスクロール",scrollDown:"下へスクロール",scrollLeft:"左へスクロール",scrollRight:"右へスクロール",scrollToTop:"先頭へ",scrollToBottom:"末尾へ",noItems:"項目がありません"})}),On=r=>Yr.includes(r),Dr=r=>typeof r=="string"?JSON.stringify(r):r===null?"null":typeof r,vn=r=>{if(r===void 0)return"en";if(On(r))return r;const e=Yr.map(n=>JSON.stringify(n)).join(", ");throw new RangeError(`[virtualscroll] locale must be one of ${e}; got ${Dr(r)}`)},Fn=r=>Er.includes(r),Br=(r,e)=>{const n=xn[vn(r)];if(e===void 0)return n;if(e===null||typeof e!="object")throw new RangeError(`[virtualscroll] labels must be an object; got ${Dr(e)}`);const s=Object.getPrototypeOf(e);if(s!==Object.prototype&&s!==null)throw new RangeError(`[virtualscroll] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(e)?"an array":"an object with a non-plain prototype"}`);const i=new Set(Object.keys(e));for(const o of i)if(!Fn(o))throw new RangeError(`[virtualscroll] labels.${o} is not a known label key; expected one of ${Er.join(", ")}`);const a={...n};for(const o of Er){const u=i.has(o)?e[o]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[virtualscroll] labels.${o} must be a non-blank string; got ${Dr(u)}`);a[o]=u}}return Object.freeze(a)};class N{level;prefix;impl;constructor(e=2,n="[virtualscroll]",s=console){this.level=e,this.prefix=n,this.impl=s}static instance=new N(2,"[virtualscroll]");static setLevel(e){N.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){N.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){N.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return N.instance.isEnabled(e)}isEnabled(e){return this.level<=e}static resolveLazy(e){if(typeof e!="function")return e;try{return e()}catch{return e}}formatMessage(e){return typeof e=="string"?[`${this.prefix} ${e}`]:[this.prefix,e]}static debug(e,...n){N.instance.debug(e,...n)}debug(e,...n){this.level<=0&&this.impl.debug(...this.formatMessage(N.resolveLazy(e)),...n.map(N.resolveLazy))}static info(e,...n){N.instance.info(e,...n)}info(e,...n){this.level<=1&&this.impl.info(...this.formatMessage(N.resolveLazy(e)),...n.map(N.resolveLazy))}static warn(e,...n){N.instance.warn(e,...n)}warn(e,...n){this.level<=2&&this.impl.warn(...this.formatMessage(N.resolveLazy(e)),...n.map(N.resolveLazy))}static error(e,...n){N.instance.error(e,...n)}error(e,...n){this.level<=3&&this.impl.error(...this.formatMessage(N.resolveLazy(e)),...n.map(N.resolveLazy))}}const wn=r=>typeof r.setPointerCapture=="function"&&typeof r.releasePointerCapture=="function"&&typeof r.hasPointerCapture=="function",Sn=(r,e)=>wn(r)&&r.hasPointerCapture(e),pr=(r,e)=>{if(!wn(r))return"unsupported";try{return r.setPointerCapture(e),"captured"}catch(n){return(typeof n=="object"&&n!==null&&"name"in n?n.name:void 0)==="NotFoundError"?"inactive-pointer":"rejected"}},Kt=(r,e)=>{Sn(r,e)&&r.releasePointerCapture(e)},an={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Mr=6,Hn=8,Xn=({dragState:r,normalizedDistance:e})=>{const n=1+e*.18,s=.16+e*.24,i=.38+e*.28,a=r.active?"80ms ease-out":"220ms ease";return z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"aqvs-tap-scroll-circle-visual-outer",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.62), rgba(72,72,72,0.48))",boxShadow:`0 0 0 1px rgba(255,255,255,0.28), 0 10px 22px rgba(0,0,0,${s})`,transform:`scale(${n})`,transition:`${a}, ${r.active?"80ms":"260ms"} box-shadow ease`}}),z.jsx("div",{className:"aqvs-tap-scroll-circle-inner",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.72), rgba(28,28,28,0.58))",boxShadow:"inset 0 4px 10px rgba(0,0,0,0.24), inset 0 0 2px rgba(255,255,255,0.55)",opacity:i,transition:r.active?"120ms opacity ease-out":"220ms opacity ease"}})]})},jr=t.memo(t.forwardRef(({onDragChange:r,className:e,maxVisualDistance:n=160,size:s=40,style:i,opacity:a=1,renderVisual:o,axis:u="y"},f)=>{const[m,b]=t.useState(an),S=t.useRef(null),M=t.useRef(null),v=t.useRef({x:0,y:0}),T=t.useRef(null),te=t.useRef(0),X=t.useCallback(C=>{b(C),r(C)},[r]),me=t.useCallback((C,q,re=!1)=>{const{x:Ge,y:ae}=v.current,xe=C-Ge,Ct=q-ae;let le,oe;if(u==="xy")le=Math.hypot(xe,Ct),oe=le<Mr?0:1;else{const ze=u==="x"?xe:Ct;le=Math.abs(ze),oe=le<Mr?0:ze<0?-1:1}const ht=te.current;let Je=oe;const nt=Mr+Hn;oe===0?ht!==0&&le<nt?Je=ht:(Je=0,re||(te.current=0)):oe!==ht&&ht!==0&&le<nt?Je=ht:te.current=oe,X({active:re||le>=Mr,offsetX:xe,offsetY:Ct,distance:le,direction:Je,pointerId:S.current})},[X,u]),Pe=t.useCallback(C=>{if(C===null)return;const q=T.current;q!==null&&Kt(q,C)},[]),V=t.useCallback((C=!1)=>{C&&Pe(S.current),S.current=null,M.current=null,te.current=0,X(an)},[X,Pe]),F=t.useCallback(C=>{if(S.current!==null&&S.current!==C.pointerId){M.current={pointerId:C.pointerId,clientX:C.clientX,clientY:C.clientY},C.preventDefault(),C.stopPropagation();return}C.preventDefault(),C.stopPropagation();const q=T.current??C.currentTarget,{left:re,top:Ge,width:ae,height:xe}=q.getBoundingClientRect();v.current={x:re+ae/2,y:Ge+xe/2},S.current=C.pointerId,pr(q,C.pointerId),me(C.clientX,C.clientY,!0)},[me]),ie=t.useCallback(C=>{if(S.current!==C.pointerId){M.current!==null&&M.current.pointerId===C.pointerId&&(M.current={pointerId:C.pointerId,clientX:C.clientX,clientY:C.clientY});return}C.preventDefault(),me(C.clientX,C.clientY)},[me]),L=t.useCallback(C=>{if(S.current!==C.pointerId){M.current!==null&&M.current.pointerId===C.pointerId&&(M.current=null);return}C.preventDefault(),C.stopPropagation();const q=M.current;if(M.current=null,q!==null){Pe(C.pointerId);const re=T.current;if(re===null||pr(re,q.pointerId)!=="inactive-pointer"){S.current=q.pointerId,me(q.clientX,q.clientY,!0);return}}V(!0)},[V,Pe,me]),P=t.useCallback(C=>{C.target===C.currentTarget&&S.current===C.pointerId&&V(!1)},[V]);t.useImperativeHandle(f,()=>({reset:()=>{V(!0)},getElement:()=>T.current}),[V]);const I=Math.min(Math.max(a,0),1),Z=s/64,U=Math.min(m.distance,n)/n,$=m.direction*U*10*Z;let se;if(u==="xy"){const C=m.distance,q=C===0?0:$*m.offsetX/C,re=C===0?0:$*m.offsetY/C;se=`translate(${q}px, ${re}px)`}else u==="x"?se=`translateX(${$}px)`:se=`translateY(${$}px)`;const Q=o??Xn,he={dragState:m,normalizedDistance:U,sizeScale:Z,size:s,opacity:I},Ue={...i,width:s,height:s,transform:se};return Ue.opacity=I,z.jsx("div",{ref:T,"data-testid":"virtual-scroll-tap-circle",className:Et.twMerge("aqvs-tap-scroll-circle",e),style:Ue,tabIndex:-1,onPointerDown:F,onPointerMove:ie,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:P,role:"presentation",children:Q(he)})}));jr.displayName="TapScrollCircle";const ne=(r,e,n)=>Math.max(e,Math.min(n,r)),_r=(r,e)=>{const n=e==="x",s=r.getBoundingClientRect(),i=n?s.width:s.height,a=b=>{const S=Number.parseFloat(b);return Number.isFinite(S)?S:0},o=window.getComputedStyle(r),u=a(n?o.width:o.height),f=u>0?u+a(n?o.paddingLeft:o.paddingTop)+a(n?o.paddingRight:o.paddingBottom)+a(n?o.borderLeftWidth:o.borderTopWidth)+a(n?o.borderRightWidth:o.borderBottomWidth):0,m=f>0?f:n?r.offsetWidth:r.offsetHeight;return m<=0||i<=0?1:i/m},gr="virtualscroll:tap-scroll-cancel",on=20,$n=250,qn=60,Yn=20,Bn=20,Wr={maxDistance:240,minSpeedMultiplier:.2},jn=Wr.maxDistance,ln={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Nr=2.2,Wn=8,Un=120,Rn=1/10,Ft={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:jn,minSpeedMultiplier:Wr.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},Gn=r=>r?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,n)=>e,getPointerCoordinate:({clientX:e})=>e,arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,n)=>n,getPointerCoordinate:({clientY:e})=>e,arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},Or=(r,e)=>{const n=r?.maxSpeedMultiplier,s=typeof n=="number"?n:Mn(e);return{enabled:r?.enabled??Ft.enabled,size:r?.size??Ft.size,offsetX:r?.offsetX??Ft.offsetX,offsetY:r?.offsetY??Ft.offsetY,className:r?.className??Ft.className,maxVisualDistance:r?.maxVisualDistance??Ft.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??Ft.minSpeedMultiplier,0),opacity:ne(r?.opacity??Ft.opacity,0,1),renderVisual:r?.renderVisual??Ft.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??Ft.maxSpeedCurve}},Kn=({isDragging:r,isThumbHovered:e,enableThumbDrag:n})=>t.useMemo(()=>n?r?"dragging":e?"hover":"idle":"disabled",[n,r,e]),Zn=({canUseArrowButtons:r,enableArrowButtons:e,resetTapScroll:n,scrollByStep:s})=>{const i=t.useRef(null),a=t.useRef(null),o=t.useRef(null),u=t.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null),a.current!==null&&(window.clearTimeout(a.current),a.current=null),o.current!==null&&(window.removeEventListener("pointerup",o.current),window.removeEventListener("pointercancel",o.current),window.removeEventListener("blur",o.current),o.current=null)},[]),f=t.useCallback(()=>{u()},[u]),m=t.useCallback(S=>M=>{if(!r)return;M.cancelable&&M.preventDefault(),M.stopPropagation(),n(),u(),s(S),a.current=window.setTimeout(()=>{i.current=window.setInterval(()=>{s(S)},qn)},$n);const v=()=>u();o.current=v,window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),window.addEventListener("blur",v)},[r,u,n,s]),b=t.useCallback(S=>M=>{e&&(M.key==="Enter"||M.key===" "||M.key==="Spacebar")&&(M.preventDefault(),s(S))},[e,s]);return t.useEffect(()=>{r||u()},[r,u]),t.useEffect(()=>()=>{u()},[u]),{handleArrowPointerDown:m,handleArrowPointerUp:f,handleArrowKeyDown:b}},Qn=700,Gt=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,Cr=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:a,curve:o})=>{const u=Math.max(Gt(r,0),0),f=Gt(e,0),m=f>0?Math.min(u,f)/f:1,b=Math.max(Gt(n,0),0),S=Math.max(Gt(s,0),0),M=Math.max(Gt(i,0),0),v=Math.max(b*S,40),T=a?v:1200,te=Math.max(b*M,T),X=o?Math.max(Gt(o.exponentialScale,M),0):0,me=o?Math.min(te,Math.max(b*X,v)):te,Pe=Math.max(me,v);let V=m**1.1;if(o){const ie=Math.min(Math.max(Gt(o.exponentialSteepness,0),0),Qn);if(ie===0)V=m;else{const L=Math.expm1(ie)||1;V=Math.min(Math.max(Math.expm1(ie*m)/L,0),1)}}const F=Math.min(Math.max(Gt(o?.easedOffset,0),0),1);return v+(Pe-v)*(F+(1-F)*V)},Mn=r=>{if(!r||r<=0)return Nr;const e=Math.max(1,r),n=Math.log10(e),s=Nr+n*Wn;return ne(s,Nr,Un)},Ur=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:a=!0,enableArrowButtons:o=!0,enableArrowButtonTabStops:u=!0,horizontal:f=!1,enableHorizontalTapCircle:m=!1,stretchMainSize:b=!1,scrollBarWidth:S=12,className:M,ariaControls:v,tapScrollCircleOptions:T,itemCount:te,renderThumbOverlay:X,visibleStartIndex:me,visibleEndIndex:Pe,locale:V,labels:F})=>{const[ie,L]=t.useState(!1),[P,I]=t.useState(!1),[Z,U]=t.useState(!1),$=t.useRef(null),se=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),Q=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),he=t.useRef(n),Ue=t.useRef(s),C=t.useRef(ln),q=t.useRef(null),re=t.useRef(null),Ge=t.useRef(null),ae=t.useRef(0),xe=t.useRef(0),Ct=t.useMemo(()=>Or(T,te),[te,T]),le=t.useMemo(()=>Gn(f),[f]),oe=t.useMemo(()=>Br(V,F),[V,F]),ht=f?[oe.scrollLeft,oe.scrollRight]:[oe.scrollUp,oe.scrollDown],{enabled:Je,size:nt,offsetX:ze,offsetY:et,className:Ke,maxVisualDistance:Ze,maxSpeedMultiplier:ue,minSpeedMultiplier:Ie,opacity:_e,renderVisual:O,maxSpeedCurve:He}=Ct,G=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(Ze,1),tapCircleMaxSpeedMultiplier:ue,tapCircleMinSpeedMultiplier:Ie,tapCircleMaxSpeedCurve:He,tapScrollCircleOptions:T,effectiveTrackLength:0,onScroll:s,scrollPosition:n}),{mainSizeKey:ft,crossSizeKey:Y,positionKey:E,selectDelta:st,getPointerCoordinate:ye,arrowIcons:A,directionClass:it,orientation:xt}=le,Pt=Math.max(Ze,1),at=e/r,p=Math.max(e-S*2,0),_=at*p,de=Math.min(Math.max(on,_||0),p||on),j=Math.max(r-e,0),ee=Math.max(p-de,0),ke=j<=0||ee<=0?0:ne(n/j*ee,0,ee),Xe=ke+de/2,ge=r>e||ie,qe=ge&&o;t.useLayoutEffect(()=>{G.current={viewportSize:e,maxScrollPosition:j,scrollBarVisible:ge,effectiveTapMaxDistance:Pt,tapCircleMaxSpeedMultiplier:ue,tapCircleMinSpeedMultiplier:Ie,tapCircleMaxSpeedCurve:He,tapScrollCircleOptions:T,effectiveTrackLength:ee,onScroll:s,scrollPosition:n}}),t.useLayoutEffect(()=>{he.current=n},[n]),t.useLayoutEffect(()=>{Ue.current=s},[s]),t.useEffect(()=>{i||I(!1)},[i]);const be=Kn({isDragging:ie,isThumbHovered:P,enableThumbDrag:i}),Ne=t.useCallback((d,k)=>{const D=G.current,fe=k??he.current;if(Ue.current){const je=Ue.current(d,fe);if(typeof je=="number"&&Number.isFinite(je))return he.current=je,je}const Le=typeof d=="function"?d(fe):d,De=Math.max(D.maxScrollPosition,0),vt=D.scrollBarVisible?ne(Le,0,De):0;return he.current=vt,vt},[]),ot=t.useCallback(d=>{const k=G.current,D=he.current;if(!k.scrollBarVisible||k.maxScrollPosition<=0){const wt=Ne(0,D),kt=wt-D;return{nextPosition:wt,actualDelta:kt,reachedBoundary:!0}}if(d===0)return{nextPosition:D,actualDelta:0,reachedBoundary:!1};const Le=Ne(wt=>ne(wt+d,0,k.maxScrollPosition),D),De=Le-D,vt=d<0&&D+d<=0,je=d>0&&D+d>=k.maxScrollPosition,zt=d<0&&(Le<=0||vt&&De===0)||d>0&&(Le>=k.maxScrollPosition||je&&De===0);return{nextPosition:Le,actualDelta:De,reachedBoundary:zt}},[Ne]),tt=t.useCallback((d,k)=>{d.current+=k;const D=Math.max(G.current.maxScrollPosition,0);D>0&&(d.current=ne(d.current,-D,D));const fe=ot(d.current);return d.current-=fe.actualDelta,fe.reachedBoundary&&(d.current=0),fe},[ot]),Ve=t.useCallback(()=>{re.current!==null&&(window.cancelAnimationFrame(re.current),re.current=null),Ge.current=null,ae.current=0,xe.current=0},[]),Ye=t.useCallback(()=>{C.current={...ln},U(!1),q.current?.reset(),Ve()},[Ve]),pe=t.useCallback(d=>{const k=C.current,D=G.current;if(!k.active||k.direction===0){Ve();return}if(!D.scrollBarVisible||D.maxScrollPosition<=0){Ve();return}const fe=Ge.current??d,Le=Math.max((d-fe)/1e3,0),De=Math.min(Le,Rn);if(Ge.current=d,De<=0){re.current=window.requestAnimationFrame(pe);return}const vt=Cr({distance:k.distance,maxDistance:D.effectiveTapMaxDistance,viewportSize:D.viewportSize,minSpeedMultiplier:D.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:D.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof D.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:D.tapCircleMaxSpeedCurve});xe.current!==k.direction&&(xe.current=k.direction,ae.current=0);const{reachedBoundary:je}=tt(ae,k.direction*vt*De);if(je){Ve();return}re.current=window.requestAnimationFrame(pe)},[tt,Ve]),ve=t.useCallback(()=>{re.current===null&&(Ge.current=null,ae.current=0,re.current=window.requestAnimationFrame(pe))},[pe]);t.useEffect(()=>{const d=C.current;!d.active||d.direction===0||ve()},[r,e,ve]),t.useEffect(()=>()=>{Ve()},[Ve]);const Be=t.useCallback(d=>{C.current=d,U(d.active),d.active&&d.direction!==0?ve():Ve()},[ve,Ve]);t.useEffect(()=>{Je||Ye()},[Ye,Je]),t.useEffect(()=>{const d=k=>{const fe=k.detail?.paneId;fe&&v&&fe!==v||Ye()};return window.addEventListener(gr,d),()=>{window.removeEventListener(gr,d)}},[v,Ye]),t.useEffect(()=>{if(!Je)return;const d=k=>{if(!C.current.active||C.current.pointerId===k.pointerId)return;const D=k.target;if(!(D instanceof Node)){Ye();return}q.current?.getElement()?.contains(D)||Ye()};return document.addEventListener("pointerdown",d,!0),()=>{document.removeEventListener("pointerdown",d,!0)}},[Ye,Je]);const Te=d=>{if(!ge||ee<=0||j<=0)return 0;const k=ne(d,0,ee);return ne(k/ee*j,0,j)},w=t.useCallback(d=>{const{scrollBarVisible:k,effectiveTrackLength:D,maxScrollPosition:fe}=G.current;if(N.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:d,trackLen:D,maxScroll:fe})),D<=0||fe<=0)return null;const Le=ne(d,0,D);return ne(Le/D*fe,0,fe)},[]),y=t.useCallback(d=>_r(d,f?"x":"y"),[f]),Ce=t.useCallback(d=>{const k=se.current;if(k.pointerId!==d.pointerId)return;const D=d.clientX-k.startClientX,fe=d.clientY-k.startClientY,Le=st(D,fe)/(k.scale||1);N.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:Le,startThumbPosition:k.startThumbPosition,clientY:d.clientY,startClientY:k.startClientY,metrics:G.current}));const De=w(k.startThumbPosition+Le);De!==null&&Ne(De),d.cancelable&&d.preventDefault()},[st,w,Ne]),Oe=t.useCallback(d=>{const k=se.current;if(k.pointerId===d.pointerId)if(document.removeEventListener("pointermove",Ce),document.removeEventListener("pointerup",Oe),document.removeEventListener("pointercancel",Oe),k.captureTarget!==null&&Kt(k.captureTarget,d.pointerId),se.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},L(!1),$.current){const D=$.current.getBoundingClientRect();d.clientX>=D.left&&d.clientX<=D.right&&d.clientY>=D.top&&d.clientY<=D.bottom||I(!1)}else I(!1)},[Ce]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",Ce),document.removeEventListener("pointerup",Oe),document.removeEventListener("pointercancel",Oe)},[Ce,Oe]);const $e=t.useRef(0),rt=t.useRef(0),lt=t.useCallback(d=>{const k=Math.max(Math.round(G.current.viewportSize/Bn),Yn);rt.current!==d&&(rt.current=d,$e.current=0),tt($e,d*k)},[tt]),{handleArrowPointerDown:we,handleArrowPointerUp:Rt,handleArrowKeyDown:jt}=Zn({canUseArrowButtons:qe,enableArrowButtons:o,resetTapScroll:Ye,scrollByStep:lt}),nr=d=>{if(!ge)return;if(!i){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;Ye();const k=d.currentTarget,D=y(k),fe=pr(k,d.pointerId)==="captured"?k:null;se.current={pointerId:d.pointerId,startThumbPosition:ke,startClientX:d.clientX,startClientY:d.clientY,scale:D,captureTarget:fe},document.addEventListener("pointermove",Ce),document.addEventListener("pointerup",Oe),document.addEventListener("pointercancel",Oe),L(!0),I(!0),d.preventDefault(),d.stopPropagation()},Se=d=>{if(!ge)return;if(!a){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;const k=d.currentTarget,D=k.getBoundingClientRect(),fe=ye(d),Le=y(k),De=(fe-(f?D.left:D.top))/Le;Ye();const vt=De-de/2,je=Te(vt);Ne(je),pr(k,d.pointerId),Q.current={pointerId:d.pointerId,startThumbPosition:vt,startClientX:d.clientX,startClientY:d.clientY,scale:Le},d.preventDefault(),d.stopPropagation()},pt=()=>{Q.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},Zt=d=>{const k=Q.current;if(k.pointerId!==d.pointerId)return;if(d.pointerType==="mouse"&&d.buttons===0){pt();return}const D=d.clientX-k.startClientX,fe=d.clientY-k.startClientY,Le=st(D,fe)/(k.scale||1),De=Te(k.startThumbPosition+Le);Ne(De),d.cancelable&&d.preventDefault()},Wt=d=>{Q.current.pointerId===d.pointerId&&(Kt(d.currentTarget,d.pointerId),pt(),d.preventDefault(),d.stopPropagation())},Xt=d=>{Q.current.pointerId===d.pointerId&&(Kt(d.currentTarget,d.pointerId),pt())},Re=d=>{d.target===d.currentTarget&&Q.current.pointerId===d.pointerId&&pt()},Mt=t.useMemo(()=>ne((Z?1:.8)*_e,0,1),[Z,_e]),$t=t.useMemo(()=>{const k=`calc(50% - ${nt/2}px + ${et}px)`;return{left:ze,top:k}},[ze,et,nt]),Qt=(d,k,D,fe)=>z.jsx("button",{type:"button",tabIndex:u?0:-1,className:"aqvs-scrollbar-arrow-button",style:{[ft]:S,[Y]:S},"aria-label":k,onPointerDown:we(d),onPointerUp:Rt,onPointerLeave:Rt,onPointerCancel:Rt,onKeyDown:jt(d),"aria-disabled":!o,disabled:!qe,children:z.jsx("span",{"aria-hidden":"true",children:D})},fe),gt=X&&ge?{orientation:xt,scrollPosition:n,maxScrollPosition:j,contentSize:r,viewportSize:e,thumbSize:de,thumbPosition:ke,thumbCenter:Xe,trackSize:p,isDragging:ie,isTapScrollActive:Z,visibleStartIndex:me,visibleEndIndex:Pe}:null;return z.jsxs("div",{className:Et.twMerge("aqvs-scrollbar",it,M),style:{...b&&!f?{}:{[ft]:e},[Y]:S},"data-visible":ge?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":v,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":j,"aria-orientation":f?"horizontal":"vertical",children:[(!f||m)&&ge&&Je&&z.jsx(jr,{axis:f?"x":"y",ref:q,className:Et.twMerge("aqvs-scrollbar-tap-circle-wrapper",Ke),size:nt,maxVisualDistance:Pt,style:$t,opacity:Mt,renderVisual:O,onDragChange:Be},"tap-circle"),Qt(-1,ht[0],A[0],"arrow-start"),z.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:S/2},onPointerDown:Se,onPointerMove:Zt,onPointerUp:Wt,onPointerCancel:Xt,onLostPointerCapture:Re,"aria-disabled":!a,children:[gt&&z.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:X?.(gt)},"overlay"),z.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[ft]:de,[E]:ke,...f?{top:0,bottom:0}:{left:0,right:0}},"data-visible":ge||ie?"true":"false",onPointerDown:nr,role:"slider","aria-orientation":f?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":j,"aria-disabled":!i,tabIndex:-1,children:z.jsx("div",{ref:$,className:Et.twMerge("aqvs-scrollbar-thumb",f?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":be,style:{borderRadius:S-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&I(!0)},onMouseLeave:()=>{i&&I(!1)}},"thumb")},"thumb-wrapper")]},"track"),Qt(1,ht[1],A[1],"arrow-end")]})},yn=({offsetX:r,offsetY:e,maxDistance:n,x:s,y:i})=>{const a=Number.isFinite(r)?r:0,o=Number.isFinite(e)?e:0,u=Math.hypot(a,o);if(u===0)return{x:0,y:0};const f=Cr({distance:u,maxDistance:n,viewportSize:s.viewportSize,minSpeedMultiplier:s.minSpeedMultiplier,maxSpeedMultiplier:s.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:s.hasCustomMaxSpeedMultiplier,curve:s.curve}),m=Cr({distance:u,maxDistance:n,viewportSize:i.viewportSize,minSpeedMultiplier:i.minSpeedMultiplier,maxSpeedMultiplier:i.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:i.hasCustomMaxSpeedMultiplier,curve:i.curve});return{x:f*a/u,y:m*o/u}},Jn=r=>{const{quantum:e,resetOnDirectionChange:n=!0}=r;if(!(Number.isFinite(e)&&e>0))throw new TypeError(`[createResidualQuantizer] quantum must be a finite positive number, received ${e}`);let s=0;return{push:i=>{if(!Number.isFinite(i)||Math.abs(i)>Number.MAX_SAFE_INTEGER)return 0;n&&s!==0&&i!==0&&Math.sign(i)!==Math.sign(s)&&(s=0),s+=i;const a=Math.trunc(s/e)*e+0;return s-=a,a},peekResidue:()=>s,reset:()=>{s=0}}},es=16,cn=(r,e,n)=>e===1?r*es:e===2?r*n:r,ts=(r,e)=>{const n=r.shiftKey&&r.deltaX===0,s=n?r.deltaY:r.deltaX,i=n?0:r.deltaY,a=s!==0&&Math.abs(s)>=Math.abs(i);return{isZoomGesture:r.ctrlKey,isHorizontalDominant:a,horizontalDelta:cn(s,r.deltaMode,e),verticalDelta:cn(i,r.deltaMode,e)}},Tn=new WeakSet,un=r=>{Tn.add(r)},rs=r=>Tn.has(r),ns=["mouse","pen","touch"],Ar=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),ss=r=>r==="mouse"||r==="pen",mr={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},yr=(r,e,n)=>{for(const[s,i,a]of e)n==="add"?r.addEventListener(s,i,a):r.removeEventListener(s,i,a)},In=t.forwardRef(({children:r,contentSize:e,viewportSize:n,onViewportSizeChange:s,scrollBarWidth:i=12,enableThumbDrag:a=!0,enableTrackClick:o=!0,enableArrowButtons:u=!0,enableArrowButtonTabStops:f=!0,enablePointerDrag:m=!0,pointerDragInputs:b=ns,onScroll:S,className:M,testId:v,style:T,background:te,tapScrollCircleOptions:X,inertiaOptions:me,itemCount:Pe,renderThumbOverlay:V,wheelSpeedMultiplier:F=1,overscrollBehavior:ie="auto",onWheelHorizontal:L,onPanHorizontal:P,contentInsets:I,visibleStartIndex:Z,visibleEndIndex:U,renderOverlay:$,initialScrollPosition:se=0,contentProps:Q,locale:he,labels:Ue},C)=>{const q=t.useRef(Number.isFinite(se)?Math.max(0,se):0),re=t.useRef(null),Ge=t.useRef(null),ae=n===void 0,[xe,Ct]=t.useState(0),le=n??xe,oe=t.useRef(null);t.useLayoutEffect(()=>{if(!ae)return;const p=Ge.current;if(!p)return;const _=()=>{const j=p.offsetHeight;if(j>0){Ct(ee=>ee===j?ee:j);return}p.offsetParent!==null&&e>0&&oe.current!=="zero"&&(oe.current="zero",N.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly."))};if(_(),typeof ResizeObserver!="function")return;const de=new ResizeObserver(_);return de.observe(p),()=>{de.disconnect()}},[e,ae]),t.useLayoutEffect(()=>{ae&&s?.(xe)},[ae,xe,s]),t.useLayoutEffect(()=>{if(ae)return;const p=re.current;if(!p)return;const _=()=>{const j=p.clientHeight;if(j<=0||Math.abs(j-le)<=1)return;const ee=`${le}/${j}`;oe.current!==ee&&(oe.current=ee,N.warn(`[ScrollPane] viewportSize=${le} but the host band is ${j}px. The clip window, max scroll position, thumb mapping, rendered row count and scrollability all derive from viewportSize, so they are now wrong. Omit viewportSize to let the pane measure itself.`))};if(_(),typeof ResizeObserver!="function")return;const de=new ResizeObserver(_);return de.observe(p),()=>{de.disconnect()}},[ae,le]);const ht=t.useRef(L);t.useEffect(()=>{ht.current=L},[L]);const Je=t.useRef(P);t.useEffect(()=>{Je.current=P},[P]);const nt=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),ze=t.useMemo(()=>({maxVelocity:me?.maxVelocity??mr.maxVelocity,minVelocity:me?.minVelocity??mr.minVelocity,deceleration:me?.deceleration??mr.deceleration,velocitySampleWindow:me?.velocitySampleWindow??mr.velocitySampleWindow,startVelocityThreshold:me?.startVelocityThreshold??mr.startVelocityThreshold}),[me]),et=t.useMemo(()=>({top:Math.max(0,I?.top??0),bottom:Math.max(0,I?.bottom??0)}),[I]);N.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:le,scrollBarWidth:i,className:M,style:T,tapScrollCircleOptions:X,inertiaOptions:me,enablePointerDrag:m,contentInsets:et}));const Ke=t.useRef({contentSize:e,viewportSize:le}),Ze=t.useMemo(()=>e>le,[e,le]),ue=t.useCallback((p,_)=>{let de=_??Ke.current;_&&!(Number.isFinite(_.contentSize)&&Number.isFinite(_.viewportSize))&&(N.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:_}),de=Ke.current);const{contentSize:j,viewportSize:ee}=de,ke=j>ee,Xe=q.current;if(N.debug("[ScrollPane] scrollTo called",()=>({newPosition:p,contentSize:j,viewportSize:ee,currentIsScrollable:ke,prevPosition:Xe})),!ke)return q.current!==0&&(q.current=0,S?.(0,Xe)),q.current;const ge=typeof p=="function"?p(q.current):p;if(!Number.isFinite(ge))return N.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:ge}),q.current;const qe=Math.max(j-ee,0),be=ne(ge,0,qe);return q.current!==be&&(q.current=be,S?.(be,Xe)),q.current},[S]),Ie=t.useRef(ue);t.useEffect(()=>{Ie.current=ue},[ue]);const _e=t.useCallback(()=>{const p=nt.current;p.generation+=1,p.frame!==null&&cancelAnimationFrame(p.frame),p.frame=null,p.velocity=0,p.lastTimestamp=null},[]),O=t.useRef(_e);t.useEffect(()=>{O.current=_e},[_e]),t.useEffect(()=>()=>{O.current()},[]);const He=t.useCallback(p=>{if(!Ze)return;const{maxVelocity:_,minVelocity:de,deceleration:j,startVelocityThreshold:ee}=ze,ke=ne(p,-_,_);if(Math.abs(ke)<ee)return;_e(),nt.current.velocity=ke,nt.current.lastTimestamp=null;const Xe=nt.current.generation,ge=qe=>{const be=nt.current;if(be.generation!==Xe)return;if(be.lastTimestamp===null){be.lastTimestamp=qe,be.frame=requestAnimationFrame(ge);return}const Ne=qe-be.lastTimestamp;if(be.lastTimestamp=qe,Ne<=0){be.frame=requestAnimationFrame(ge);return}const ot=be.velocity;let tt=ot;const Ve=j*Ne;ot>0?tt=Math.max(0,ot-Ve):ot<0&&(tt=Math.min(0,ot+Ve));const pe=(ot+tt)/2*Ne,ve=q.current;if(pe!==0&&Ie.current(Oe=>Oe+pe),nt.current.generation!==Xe)return;const Be=q.current,{contentSize:Te,viewportSize:w}=Ke.current,y=Math.max(Te-w,0);be.velocity=tt;const Ce=Be===ve||Be<=0&&tt<=0||Be>=y&&tt>=0;if(Math.abs(tt)<de||Ce){_e();return}be.frame=requestAnimationFrame(ge)};nt.current.frame=requestAnimationFrame(ge)},[Ze,ze,_e]),G=t.useRef(He);t.useEffect(()=>{G.current=He},[He]),t.useLayoutEffect(()=>{Ke.current={contentSize:e,viewportSize:le}},[e,le]),t.useLayoutEffect(()=>{const p=Ge.current;if(!p)return;const _=()=>{p.scrollTop!==0&&(N.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:p.scrollTop})),p.scrollTop=0),p.scrollLeft!==0&&(p.scrollLeft=0)};return p.addEventListener("scroll",_),()=>p.removeEventListener("scroll",_)},[]),t.useLayoutEffect(()=>{if(Ze){N.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:le,scrollPosition:q.current}));const p=ne(e-le,0,e);q.current>p&&ue(p)}else ue(0)},[Ze,ue,e,le]);const ft=t.useRef({isScrollable:Ze,viewportSize:le,wheelSpeedMultiplier:F,overscrollBehavior:ie});t.useLayoutEffect(()=>{ft.current={isScrollable:Ze,viewportSize:le,wheelSpeedMultiplier:F,overscrollBehavior:ie}},[Ze,le,F,ie]);const Y=t.useCallback(p=>{if(rs(p))return!1;const{isScrollable:_,viewportSize:de,wheelSpeedMultiplier:j,overscrollBehavior:ee}=ft.current,ke=ts(p,de);if(ke.isZoomGesture)return!1;if(ke.isHorizontalDominant)return ht.current?(un(p),p.preventDefault(),_e(),ht.current(ke.horizontalDelta),!0):!1;if(!_||ke.verticalDelta===0)return!1;let Xe=ke.verticalDelta;if(j!==1&&(Xe*=j),ee!=="contain"){const ge=q.current,qe=Math.max(Ke.current.contentSize-de,0);if(Xe>0&&ge>=qe||Xe<0&&ge<=0)return!1}return un(p),p.preventDefault(),_e(),N.debug("[ScrollPane] wheel event",()=>({deltaY:Xe,scrollPosition:q.current,wheelSpeedMultiplier:j,deltaMode:p.deltaMode,scrollTop:Ge.current?.scrollTop})),ue(ge=>ge+Xe),!0},[ue,_e]);t.useEffect(()=>{const p=j=>{Y(j)},_=()=>{_e()},de=re.current;return de&&(de.addEventListener("wheel",p,{passive:!1}),de.addEventListener("pointerdown",_,{capture:!0,passive:!0})),()=>{de&&(de.removeEventListener("wheel",p),de.removeEventListener("pointerdown",_,{capture:!0}))}},[Y,_e]),t.useImperativeHandle(C,()=>({scrollTo:(p,_)=>(_e(),ue(p,_)),getScrollPosition:()=>q.current,getContentSize:()=>e,getViewportSize:()=>le,applyWheel:Y}),[ue,e,le,_e,Y]);const E=t.useId(),st=Q?.id??E,ye=t.useRef({pointerType:"",pointerId:null,startClientY:0,startClientX:0,lastPanClientX:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1,scaleX:1}),A=t.useRef(m),it=t.useRef(b);t.useEffect(()=>{A.current=m},[m]),t.useEffect(()=>{it.current=b},[b]);const xt=t.useRef(Ze);t.useEffect(()=>{xt.current=Ze},[Ze]);const Pt=t.useRef(ze);t.useEffect(()=>{Pt.current=ze},[ze]),t.useEffect(()=>{const p=ye.current;if(m&&Ze&&(p.pointerId===null||Ar(p.pointerType,b))||p.pointerId===null)return;const _=Ge.current;p.clickResetTimer!==null&&(window.clearTimeout(p.clickResetTimer),p.clickResetTimer=null);const de=p.isDragging&&p.shouldCancelNextClick,j=p.pointerId;p.pointerId=null,p.pointerType="",p.startClientY=0,p.startScroll=0,p.isDragging=!1,p.shouldCancelNextClick=de,p.velocitySamples=[],p.scale=1,_!==null&&Kt(_,j)},[m,b,Ze]),t.useEffect(()=>{const p=Ge.current;if(!p)return;const _=6,de=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),j=()=>{const w=ye.current;w.pointerId=null,w.pointerType="",w.startClientY=0,w.startScroll=0,w.isDragging=!1,w.velocitySamples=[],w.scale=1},ee=()=>{const w=ye.current;w.clickResetTimer!==null&&(window.clearTimeout(w.clickResetTimer),w.clickResetTimer=null)},ke=w=>{const y=ye.current,Ce=de();y.velocitySamples.push({clientY:w,time:Ce});const Oe=Pt.current.velocitySampleWindow;y.velocitySamples=y.velocitySamples.filter($e=>Ce-$e.time<=Oe)},Xe=w=>w instanceof HTMLElement&&w.closest("[data-scrollpane-ignore-drag='true']")!==null,ge=w=>{const y=ye.current;y.shouldCancelNextClick&&(w.preventDefault(),w.stopPropagation(),y.shouldCancelNextClick=!1)},qe=w=>{const y=ye.current;y.isDragging||(y.isDragging=!0,y.shouldCancelNextClick=!0,Sn(p,w.pointerId)||pr(p,w.pointerId),ke(w.clientY))},be=w=>w.isTrusted||w.target===p,Ne=w=>{const y=ye.current;Kt(p,w),y.shouldCancelNextClick=!1,ee(),j()},ot=w=>{const y=ye.current;if(y.pointerId!==w.pointerId)return;if(w.buttons===0&&ss(w.pointerType)){Ne(w.pointerId);return}if(!(A.current&&xt.current)||!Ar(w.pointerType,it.current))return;if(!y.isDragging){const rt=Math.abs(w.clientY-y.startClientY),lt=Je.current?Math.abs(w.clientX-y.startClientX):0;if(Math.max(rt,lt)<_||(qe(w),!y.isDragging))return}ke(w.clientY);const Ce=(w.clientY-y.startClientY)/(y.scale||1),Oe=y.startScroll-Ce;Ie.current(Oe);const $e=Je.current;if($e){const rt=w.clientX-y.lastPanClientX;y.lastPanClientX=w.clientX,rt!==0&&$e(-rt/(y.scaleX||1))}w.cancelable&&w.preventDefault()},tt=()=>{const w=ye.current;return w.pointerId!==null||!w.shouldCancelNextClick?!1:(ee(),w.clickResetTimer=window.setTimeout(()=>{const y=ye.current;y.shouldCancelNextClick=!1,y.clickResetTimer=null},0),!0)},Ve=w=>{const y=ye.current;if(y.pointerId!==w.pointerId){tt();return}y.isDragging&&y.shouldCancelNextClick&&w.cancelable&&(w.preventDefault(),w.stopPropagation()),y.isDragging&&ke(w.clientY);let Ce=0;if(y.isDragging&&y.velocitySamples.length>=2){const $e=y.velocitySamples,rt=Pt.current.velocitySampleWindow,lt=$e[$e.length-1],we=$e.find(Rt=>lt.time-Rt.time<=rt)??$e[0];if(lt&&we&&lt.time!==we.time){const Rt=lt.clientY-we.clientY,jt=lt.time-we.time;Ce=-(Rt/jt)/(y.scale||1)}}ee(),y.shouldCancelNextClick&&(y.clickResetTimer=window.setTimeout(()=>{const $e=ye.current;$e.shouldCancelNextClick=!1,$e.clickResetTimer=null},0));const Oe=Pt.current.startVelocityThreshold;j(),Kt(p,w.pointerId),Math.abs(Ce)>=Oe&&G.current?.(Ce)},Ye=w=>{if(ye.current.pointerId!==null){if(!w.isPrimary||w.pointerType!==ye.current.pointerType)return;Ne(ye.current.pointerId)}if(ye.current.shouldCancelNextClick&&(ee(),ye.current.shouldCancelNextClick=!1),!(A.current&&xt.current)||!Ar(w.pointerType,it.current)||w.button!==0&&w.pointerType==="mouse"||w.ctrlKey||w.metaKey||w.altKey||Xe(w.target))return;window.dispatchEvent(new CustomEvent(gr,{detail:{paneId:E}})),O.current?.();const y=ye.current;ee(),y.pointerId=w.pointerId,y.pointerType=w.pointerType,y.startClientY=w.clientY,y.startClientX=w.clientX,y.lastPanClientX=w.clientX,y.startScroll=q.current,y.scale=_r(p,"y"),y.scaleX=Je.current?_r(p,"x"):1,y.isDragging=!1,y.shouldCancelNextClick=!1,y.velocitySamples=[]},pe=w=>{if(ye.current.pointerId!==w.pointerId){tt();return}be(w)&&Ne(w.pointerId)},Be=[["click",ge,!0],["pointerdown",Ye,{passive:!1}],["lostpointercapture",w=>{w.target!==p||ye.current.pointerId!==w.pointerId||Ne(w.pointerId)},void 0]],Te=[["pointermove",ot,{passive:!1}],["pointerup",Ve,void 0],["pointercancel",pe,void 0]];return yr(p,Be,"add"),yr(window,Te,"add"),()=>{yr(p,Be,"remove"),yr(window,Te,"remove");const w=ye.current;w.pointerId!==null&&Kt(p,w.pointerId),ee(),j()}},[E]);const at=t.useCallback(p=>(_e(),ue(p)),[ue,_e]);return z.jsxs("div",{ref:re,"data-testid":v,"data-self-measured":ae?"true":void 0,className:Et.twMerge("aqvs-scroll-pane",M),style:T,children:[z.jsxs("div",{ref:Ge,className:Et.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:ae?void 0:le,paddingTop:et.top,paddingBottom:et.bottom,...m&&Ze&&b.some(p=>p==="touch"||p==="pen")?{touchAction:"none"}:{}},...Q,id:st,children:[te,r(q.current)]}),z.jsx(Ur,{contentSize:e,viewportSize:le,stretchMainSize:ae,scrollPosition:q.current,onScroll:at,enableThumbDrag:a,enableTrackClick:o,enableArrowButtons:u,enableArrowButtonTabStops:f,scrollBarWidth:i,ariaControls:st,tapScrollCircleOptions:X,itemCount:Pe,renderThumbOverlay:V,visibleStartIndex:Z,visibleEndIndex:U,locale:he,labels:Ue},"scrollbar"),$?.()]})}),dn=(r,e,n)=>Math.min(Math.max(r,e),n),is=({dragState:r,normalizedDistance:e,sizeScale:n,size:s})=>{const i=Math.max(s/2,1),a=1+e*.65,o=Math.max(.65,1-e*.25),u=r.direction*e*26*n,f=.8+e*.18,m=3*n,b=6*n,S=22*n,M=Math.abs(u)+b,v=u>0?m:-Math.abs(u)-m,T=Math.max(2.5,3*n),te=dn(r.offsetX,-i,i),X=dn(r.offsetY,-i,i),me=i*.35,Pe=te/i*me,V=X/i*me,F=Pe*.45,ie=V*.45,L=Math.max(S*.38,6),P=.65+e*.2,I=r.active;return z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${o}, ${a})`,transition:I?"40ms transform ease-out":"200ms ease transform"}}),z.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:S,height:S,transform:`translate(calc(-50% + ${Pe}px), calc(-50% + ${V}px)) scale(${o}, ${f*a})`,transition:I?"70ms transform ease-out":"200ms ease transform"}}),z.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:L,height:L,transform:`translate(calc(-50% + ${F}px), calc(-50% + ${ie}px)) scale(${o}, ${a})`,opacity:P,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:I?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),z.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:T,height:M,transform:`translate(-50%, ${v}px)`,opacity:e,transition:I?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},or=100,as=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},zr=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},lr=r=>{if(r<=0||!Number.isFinite(r))return 0;const e=Math.trunc(r);if(e<=2147483647)return e&-e;const n=BigInt(e)&-BigInt(e);return Number(n)};class Ht{tree;deltas;size;baseValue;valueFn;total;constructor(e,n,s){this.reset(e,n,s)}reset(e,n,s){const i=Number.isFinite(e)&&e>0?Math.trunc(e):0;if(typeof n!="function"){this.size=i,this.tree=new Map,this.deltas=new Map,this.valueFn=void 0,this.baseValue=n,this.total=this.baseValue*this.size;return}let a=0,o;const u=s?.baseValue;if(u!==void 0&&!(Number.isFinite(u)&&u>=0))throw new RangeError(`[FenwickMapTree] options.baseValue must be a finite number >= 0, received ${u}.`);if(i>0&&u!==void 0){if(a=u,s?.materialize){const f=s?.sampleRange??{from:0,to:Math.min(or-1,i-1)};let m=Math.max(0,Math.trunc(f.from)),b=Math.min(Math.trunc(f.to),i-1);m>b&&(m=0,b=Math.min(or-1,i-1)),o={from:m,values:Ht._collectValidatedValues(n,m,b)}}}else if(i>0){const f=s?.sampleRange??{from:0,to:Math.min(or-1,i-1)};let m=Math.max(0,Math.trunc(f.from)),b=Math.min(Math.trunc(f.to),i-1);if(m>b&&(m=0,b=Math.min(or-1,i-1)),i>or)a=Ht._sampleBaseValueStrided(n,i,or),s?.materialize&&(o={from:m,values:Ht._collectValidatedValues(n,m,b)});else{const S=Ht._collectValidatedValues(n,m,b);a=Ht._modeOrMedian([...S]),s?.materialize&&(o={from:m,values:S})}}if(this.size=i,this.tree=new Map,this.deltas=new Map,this.total=void 0,this.valueFn=n,this.baseValue=a,o)for(let f=0;f<o.values.length;f++){const m=o.from+f;if(m>=this.size)break;const b=o.values[f]-this.baseValue;b!==0&&(this.deltas.set(m,b),this._updateTree(m,b))}this.total=this.getTotal()}setValueFn(e,n){if(n?.reset){this.reset(this.size,e);return}typeof e=="function"?this.valueFn=e:(this.valueFn=void 0,this.baseValue=e,this.total=this._computeTreeTotal())}static _collectValidatedValues(e,n,s){const i=[];for(let a=n;a<=s;a++)i.push(zr(e(a),a));return i}static _modeOrMedian(e){if(e.length===0)return 0;e.sort((o,u)=>o-u);const n=Math.floor(e.length/2);let s;e.length%2===0?s=Math.floor((e[n-1]+e[n])/2):s=e[n];const i=new Map;let a=0;for(const o of e){const u=(i.get(o)??0)+1;i.set(o,u),u>a&&(a=u)}if(a>e.length*.2){const o=[];for(const[f,m]of i.entries())m===a&&o.push(f);const u=o.reduce((f,m)=>f+m,0);s=Math.floor(u/o.length)}return s}static _sampleBaseValueStrided(e,n,s){if(n<=0)return 0;let i=Math.max(1,Math.ceil(n/s));i%2===0&&(i+=1);const a=[];for(let o=0;o<n&&a.length<s;o+=i)a.push(zr(e(o),o));return Ht._modeOrMedian(a)}update(e,n){return this.updates([{index:e,value:n}])}updates(e){const n=this._buildDeltaUpdates(e);return n.length>0?this.updateDeltas(n):this.total}updateDelta(e,n){return this.updateDeltas([{index:e,change:n}])}updateDeltas(e){const n=new Map;for(const{index:s,change:i}of e){if(s<0||s>=this.size)throw new Error(`Index ${s} out of bounds`);if(!Number.isInteger(s))throw new Error(`Index must be an integer: ${s}`);if(!Number.isFinite(i))throw new Error(`Change must be a finite number: ${i}`);const o=(n.get(s)??this.deltas.get(s)??0)+i;if(o+this.baseValue<-1e-9)throw new Error(`Change would make the value at index ${s} negative: ${o+this.baseValue}`);n.set(s,o)}for(const{index:s,change:i}of e){const o=(this.deltas.get(s)??0)+i;o===0?this.deltas.delete(s):this.deltas.set(s,o),this._updateTree(s,i)}return this.total}_updateTree(e,n){if(n===0)return;let s=e+1;for(;s<=this.size;){this.tree.set(s,(this.tree.get(s)??0)+n);const i=lr(s);if(i===0)break;s+=i}this.total!==void 0&&(this.total+=n)}_buildDeltaUpdates(e){const n=[],s=new Map;for(const{index:i,value:a}of e){if(i<0||i>=this.size)throw new Error(`Index ${i} out of bounds`);if(!Number.isInteger(i))throw new Error(`Index must be an integer: ${i}`);if(!Number.isFinite(a))throw new Error(`Value must be a finite number: ${a}`);if(a<0)throw new Error("Value cannot be negative.");const o=s.has(i)?s.get(i)??0:this.deltas.get(i)??0,u=o+this.baseValue,f=a-u;f!==0&&n.push({index:i,change:f}),s.set(i,o+f)}return n}_computeTreeTotal(){if(this.size<=0)return 0;let e=0,n=this.size;for(;n>0;){e+=this.tree.get(n)??0;const s=lr(n);if(s===0)break;n-=s}return e+this.baseValue*this.size}_materialize(e,n=!0){if(this.valueFn){const s=this.deltas.get(e)??0,a=zr(this.valueFn(e),e)-this.baseValue;if(a!==s&&(a===0?this.deltas.delete(e):this.deltas.set(e,a),n)){const o=a-s;this._updateTree(e,o)}}}_materializeRanges(e,n,s=!1){if(!(e?.materialize&&this.valueFn))return;const i=e.ranges;if(i&&i.length>0){for(const u of i){const f=Math.max(0,Math.trunc(u.from)),m=Math.min(Math.trunc(u.to),this.size-1);for(let b=f;b<=m;b++)this._materialize(b)}if(n===void 0)return;if(s){this._materialize(n);return}const a=i[0].from,o=i[i.length-1].to;n>=a&&n<=o&&this._materialize(n);return}n!==void 0&&this._materialize(n)}_findIndex(e,n={},s){if(this.size>=1073741824)return this._findIndexLarge(e,n,s);if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const i=n.materializeOption?.materialize===!0;let a;for(;;){if(a=this._descend(e,s),a<0||a>=this.size)return{index:-1,total:this.total??this.getTotal(),cumulative:void 0,currentValue:void 0,safeIndex:void 0};if(!i)break;const u=this.deltas.get(a)??0;if(this._materialize(a),(this.deltas.get(a)??0)===u)break}const o=this.prefixSum(a);return{index:a,total:this.total??o.total,cumulative:o.cumulative,currentValue:o.currentValue,safeIndex:o.safeIndex}}_descend(e,n){let s=0,i=0,a=1;for(;a<<1<=this.size;)a<<=1;for(;a>0;a>>=1){const o=s+a;if(o<=this.size){const f=(this.tree.get(o)??0)+this.baseValue*a;(n?i+f<e:i+f<=e)&&(s=o,i+=f)}}return n?s:s-1}_findIndexLarge(e,n,s){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};const i=as(this.size);if(i===0n)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const a=n.materializeOption?.materialize===!0;for(;;){let o=0n,u=i-1n,f,m,b=this.total;for(;o<=u;){const v=o+u>>1n,T=Number(v),te=this.prefixSum(T);if(b=te.total,s?te.cumulative>=e:te.cumulative<=e)if(f=v,m=te,s){if(v===0n)break;u=v-1n}else o=v+1n;else if(s)o=v+1n;else{if(v===0n)break;u=v-1n}}const S=m,M=f!==void 0?Number(f):-1;if(a&&M>=0){const v=this.deltas.get(M)??0;if(this._materialize(M),(this.deltas.get(M)??0)!==v)continue}return{index:M,total:b,cumulative:S?.cumulative,currentValue:S?.currentValue,safeIndex:S?.safeIndex}}}prefixSum(e,n){if(e<0||Number.isNaN(e))return{cumulative:0,total:this.total,currentValue:0,safeIndex:0};if(this.size===0)return{cumulative:0,total:this.total??0,currentValue:0,safeIndex:0};const s=ne(Math.trunc(e),0,this.size-1),i=n?.materializeOption;this._materializeRanges(i,s,!0);let a=0,o=s+1;for(;o>0;){const f=this.tree.get(o)??0;a+=f;const m=lr(o);if(m===0)break;o-=m}const u=i?.materialize?this.get(s):(this.deltas.get(s)||0)+this.baseValue;return{cumulative:a+this.baseValue*(s+1),total:this.total,currentValue:u,safeIndex:s}}get(e,n){if(this.size===0)return 0;if(!Number.isInteger(e)||e<0||e>=this.size)throw new Error("Index out of bounds");const s=n?.materializeOption;return this._materializeRanges(s,e),(this.deltas.get(e)??0)+this.baseValue}getTotal(e){const n=e?.materializeOption;if(this._materializeRanges(n),this.total===void 0)if(this.size===0)this.total=0;else{this.total=this._computeTreeTotal();const s=this.prefixSum(this.getSize()-1);s.cumulative!==s.total&&N.error("Inconsistent Fenwick Tree state")}return this.total}rebuildTree(e){if(e?.materialize&&this.valueFn){const s=this.valueFn;this.reset(this.size,i=>s(i),{materialize:!0});return}const n=new Map;for(const[s,i]of this.deltas.entries()){if(i===0)continue;let a=s+1;for(;a<=this.size;){n.set(a,(n.get(a)??0)+i);const o=lr(a);if(o===0)break;a+=o}}this.tree=n,this.total=this._computeTreeTotal()}calculateAccumulatedError(){if(this.total===void 0)return 0;let e=this.baseValue*this.size;for(const[n,s]of this.deltas)n<this.size&&(e+=s);return this.total-e}changeSize(e){if(!Number.isFinite(e))throw new Error(`Size must be a finite number: ${e}`);const n=Math.max(0,Math.trunc(e)),s=this.size;if(n===s)return;if(n>s)if(s===0&&this.deltas.size>0){for(const a of this.deltas.keys())a>=n&&this.deltas.delete(a);this.size=n,this.rebuildTree()}else this._growSize(s,n);else{if(n>0)for(const a of this.deltas.keys())a>=n&&this.deltas.delete(a);this.size=n,this.rebuildTree()}const i=this.prefixSum(this.getSize()-1);i.cumulative!==i.total&&N.error("Inconsistent Fenwick Tree state")}static _minCoveredLowBound(e,n){let s=1;for(;;){const i=s*2;if(Math.floor(n/i)*i<=e)break;s=i}return s*Math.floor(e/s)}_propagateDeltaToGrownNodes(e,n,s,i){let a=e+1;for(;a<=s;){const o=lr(a);if(o===0)break;a+=o}for(;a<=i;){this.tree.set(a,(this.tree.get(a)??0)+n);const o=lr(a);if(o===0)break;a+=o}}_growSize(e,n){if(this.size=n,this.deltas.size>0){const s=Ht._minCoveredLowBound(e,n);if(e-s<this.deltas.size)for(let a=s;a<e;a++){const o=this.deltas.get(a);o===void 0||o===0||this._propagateDeltaToGrownNodes(a,o,e,n)}else for(const[a,o]of this.deltas.entries())o===0||a<s||this._propagateDeltaToGrownNodes(a,o,e,n)}this.total=this._computeTreeTotal()}getSize(){return this.size}get base(){return this.baseValue}findIndexAtOrAfter(e,n){return this._findIndex(e,n??{},!0)}findIndexAtOrBefore(e,n){return this._findIndex(e,n??{},!1)}}const os=(r,e)=>{const n=r?.sampleRange,s=e?.sampleRange;return n===s?!1:n&&s?n.from!==s.from||n.to!==s.to:!0},Gr=(r,e,n)=>{const s=Number.isFinite(r)&&r>0?Math.trunc(r):0,i=t.useRef(null),a=t.useRef({size:s,valueOrFn:e,options:n});i.current===null&&(i.current=new Ht(s,e,n));const o=i.current,u=a.current,f=u.size!==s,m=u.valueOrFn!==e,b=os(u.options,n)||u.options?.baseValue!==n?.baseValue,S=u.size===0&&s>0&&(!i.current||i.current.base===0);if(m||b){const M=n?.resetOnValueFnChange??!0;b||m&&M||S?(n?.debug&&N.debug("[useFenwickMapTree] reset",{valueOrFnChanged:m,optionsChanged:b}),o.reset(s,e,n)):(f&&(n?.debug&&N.debug("[useFenwickMapTree] resize (with valueFn change)",{from:u.size,to:s}),o.changeSize(s)),n?.debug&&N.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:m}),o.setValueFn(e,{reset:!1})),a.current={size:s,valueOrFn:e,options:n}}else f&&(n?.debug&&N.debug("[useFenwickMapTree] resize",{from:u.size,to:s}),S?o.reset(s,e,n):o.changeSize(s),a.current={size:s,valueOrFn:e,options:n});return o};class ls{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class Vr{head=null;tail=null;addToTail(e){this.tail?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e}remove(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=null,e.next=null}removeHead(){const e=this.head;return e&&this.remove(e),e}moveToTail(e){this.remove(e),this.addToTail(e)}}function En(r){const e=t.useRef(new Map),n=t.useRef(new Vr),s=Math.floor(r),i=t.useRef(s);t.useEffect(()=>{if(i.current=s,Number.isNaN(s)||s<0){N.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`),e.current.clear(),n.current=new Vr;return}if(Number.isFinite(s))for(;e.current.size>s;){const b=n.current.removeHead();if(b)e.current.delete(b.key);else break}},[r,s]);const a=t.useCallback(b=>{const S=e.current.get(b);if(S)return n.current.moveToTail(S),S.value},[]),o=t.useCallback((b,S)=>{const M=i.current;if(Number.isNaN(M)||M<=0)return;let v=e.current.get(b);if(v)v.value=S,n.current.moveToTail(v);else{if(e.current.size>=M){const T=n.current.removeHead();T&&e.current.delete(T.key)}v=new ls(b,S),e.current.set(b,v),n.current.addToTail(v)}},[]),u=t.useCallback(b=>e.current.has(b),[]),f=t.useCallback(b=>{const S=e.current.get(b);S&&(n.current.remove(S),e.current.delete(b))},[]),m=t.useCallback(()=>{e.current.clear(),n.current=new Vr},[]);return t.useMemo(()=>({get:a,set:o,has:u,remove:f,clear:m}),[a,o,u,f,m])}const cs=1e4,us=()=>{const{get:r,set:e,has:n,clear:s}=En(cs);return t.useMemo(()=>({get:r,set:e,has:n,clear:s}),[r,e,n,s])},ds=(r,e)=>{const n=t.useRef(e),s=t.useRef(r);t.useLayoutEffect(()=>{n.current=e,s.current=r},[e,r]);const i=t.useRef(new WeakMap);return t.useCallback(a=>{if(!a||i.current.has(a))return;const o=u=>{n.current?.enableBridge!==!1&&s.current.current?.applyWheel(u)};return a.addEventListener("wheel",o,{passive:!1}),i.current.set(a,o),()=>{i.current.get(a)===o&&(a.removeEventListener("wheel",o),i.current.delete(a))}},[])},fn=-200,mn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},fs=r=>{const e=t.useRef(r);e.current=r;const n=t.useRef(mn),s=t.useRef(null),[i,a]=t.useState(!1),o=t.useRef(null),u=t.useRef(null),f=t.useRef({residual:0,direction:0}),m=t.useRef({residual:0,direction:0}),b=t.useCallback(()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null),u.current=null,f.current={residual:0,direction:0},m.current={residual:0,direction:0}},[]),S=t.useCallback((V,F,ie,L,P,I)=>{const Z=F>0?1:F<0?-1:0;Z!==0&&Z!==V.direction&&(V.direction=Z,V.residual=0),V.residual+=F*ie;const U=Math.max(P(),0);U>0&&(V.residual=ne(V.residual,-U,U));const $=V.residual;if($===0)return{actualDelta:0,atBoundary:!1};const se=L(),Q=I($),he=Q-se;V.residual-=he;const Ue=$<0&&se+$<=0,C=$>0&&se+$>=U,q=$<0&&(Q<=0||Ue&&he===0)||$>0&&(Q>=U||C&&he===0);return q&&(V.residual=0),{actualDelta:he,atBoundary:q}},[]),M=t.useCallback(V=>{const F=e.current,ie=n.current;if(!ie.active||ie.direction===0){b();return}const L=u.current??V,P=Math.max((V-L)/1e3,0),I=Math.min(P,Rn);if(u.current=V,I<=0){o.current=window.requestAnimationFrame(M);return}const Z=yn({offsetX:ie.offsetX,offsetY:ie.offsetY,maxDistance:F.maxDistance,x:F.xSpeedParams,y:F.ySpeedParams}),U=S(f.current,Z.x,I,F.getHx,F.getMaxHx,he=>F.applyHxRef.current(F.getHx()+he));U.actualDelta!==0&&(F.pendingColAnchorRef.current=null);const $=S(m.current,Z.y,I,F.getVy,F.getMaxVy,F.applyVy),se=F.getMaxHx()<=0||U.atBoundary||ie.offsetX===0,Q=F.getMaxVy()<=0||$.atBoundary||ie.offsetY===0;if(se&&Q){b();return}o.current=window.requestAnimationFrame(M)},[b,S]),v=t.useCallback(()=>{o.current===null&&(u.current=null,f.current={residual:0,direction:0},m.current={residual:0,direction:0},o.current=window.requestAnimationFrame(M))},[M]),T=t.useCallback(()=>{n.current={...mn},a(!1),s.current?.reset(),b()},[b]),te=t.useCallback(V=>{n.current=V,a(V.active),V.active&&V.direction!==0?v():b()},[v,b]),{enabled:X,xExtentFreshness:me,yExtentFreshness:Pe}=r;return t.useEffect(()=>{const V=n.current;!V.active||V.direction===0||v()},[me,Pe,v]),t.useEffect(()=>{const V=()=>{T()};return window.addEventListener(gr,V),()=>{window.removeEventListener(gr,V)}},[T]),t.useEffect(()=>{if(!X)return;const V=F=>{if(!n.current.active||n.current.pointerId===F.pointerId)return;const ie=F.target;if(!(ie instanceof Node)){T();return}s.current?.getElement()?.contains(ie)||T()};return document.addEventListener("pointerdown",V,!0),()=>{document.removeEventListener("pointerdown",V,!0)}},[X,T]),t.useEffect(()=>{X||T()},[X,T]),t.useEffect(()=>()=>{b()},[b]),{isTapActive:i,handleTapCircleDragChange:te,tapCircleHandleRef:s}},We=(r,e)=>e<=0?0:ne(r,0,e-1),hn=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),St=(r,e)=>r<=e?0:r-e,rr=(r,e)=>r<=0?0:r+e,br=1e3,Fr=2e3,Cn=1048576,ms=(r,e)=>{if(!(Number.isFinite(e)&&e>0))throw new RangeError(`[VirtualScroll] devicePixelRatio must be a finite number > 0, received ${e}`);return Math.round(r*e)/e},hs=r=>{const e=r.ownerDocument.defaultView;if(e===null)throw new Error("[VirtualScroll] the items wrapper belongs to a document without a window, so it has no device-pixel ratio");return e},Pn=()=>{},ps=()=>null,gs=()=>typeof window>"u"?null:window,bs=(r,e)=>{if(typeof r.matchMedia!="function")return Pn;let n=r.matchMedia(`(resolution: ${r.devicePixelRatio}dppx)`);const s=()=>{n.removeEventListener("change",s),n=r.matchMedia(`(resolution: ${r.devicePixelRatio}dppx)`),n.addEventListener("change",s),e()};return n.addEventListener("change",s),()=>{n.removeEventListener("change",s)}},xs=({translateY:r,children:e})=>{const[n,s]=t.useState(gs),i=t.useCallback(m=>n===null?Pn:bs(n,m),[n]),a=t.useCallback(()=>n===null?null:n.devicePixelRatio,[n]),o=t.useSyncExternalStore(i,a,ps),u=t.useCallback(m=>{if(m===null)return;const b=hs(m);b!==n&&s(b)},[n]),f=o===null?r:ms(r,o);return z.jsx("div",{ref:u,className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${f}px)`,willChange:"transform"},children:e})},vs=40,hr=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},ws=(r,e,n,s,i,a,o,u)=>{const f=hr(s);if(f===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const m=L=>L<0n?0n:L>=f?f-1n:L,b={materializeOption:{materialize:!1}},{index:S,cumulative:M}=a.findIndexAtOrAfter(r,b);let v;S===-1?v=f-1n:(M===r?v=hr(S+1):v=hr(S),v>=f&&(v=f-1n)),r<=0&&(v=0n),u&&r>=o&&(v=f-1n);const T=L=>{const P=Number(L);if(!Number.isSafeInteger(P))return null;const{cumulative:I}=a.prefixSum(P,{materializeOption:{materialize:!1}});if(!Number.isFinite(I))return null;const{index:Z}=a.findIndexAtOrAfter(I+.5,{materializeOption:{materialize:!1}});if(Z===-1)return null;const U=hr(Z);return U>L?U:null},te=L=>{let P=0,I=L,Z=L,U=0n,$=0;for(;I<f&&P<e;){const se=Number(I),Q=i(se);if(P+=Q,Z=I,I+=1n,U+=1n,!Number.isFinite(Q)||Q<0)break;if(Q===0){if($+=1,$>br){const he=T(Z);if(he!==null&&he>I)I=he,$=0;else if(he!==null&&he===I&&i(Number(I))>0)$=0;else break}}else $=0}return U===0n&&(Z=L),{height:P,end:Z}};let{height:X,end:me}=te(v);if(X<e&&v>0n){let L=v,P=X,I=0;for(;L>0n&&P<e;){L-=1n;const U=Number(L),$=i(U);if(P+=$,!Number.isFinite($)||$<0)break;if($===0){if(I+=1,I>br){const se=Number(L);if(!Number.isSafeInteger(se))break;const{cumulative:Q}=a.prefixSum(se,{materializeOption:{materialize:!1}});if(!Number.isFinite(Q))break;const{index:he}=a.findIndexAtOrAfter(Q-.5,{materializeOption:{materialize:!1}}),Ue=he===-1?-1n:hr(he);if(Ue>=0n&&Ue<L)L=Ue+1n,I=0;else if(Ue===L&&L>=1n&&i(Number(L-1n))>0)I=0;else break}}else I=0}v=m(L);const Z=te(v);X=Z.height,me=Z.end}const Pe=m(v),V=m(me),F=m(Pe-BigInt(Math.max(0,n))),ie=m(V+BigInt(Math.max(0,n)));return{renderingStartIndex:We(Number(F),s),renderingEndIndex:We(Number(ie),s),visibleStartIndex:We(Number(Pe),s),visibleEndIndex:We(Number(V),s)}},kn=(r,e,n,s,i,a,o)=>{if(s===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const u=Number.isFinite(o),f=u?Math.min(Math.max(0,r),o):Math.max(0,r);if(s>=Number.MAX_SAFE_INTEGER)return ws(f,e,n,s,i,a,o,u);const{index:m,cumulative:b,currentValue:S}=a.findIndexAtOrAfter(f,{materializeOption:{materialize:!1}}),M=m===-1?e<=0||(b??0)<f+(S??0)?s-1:0:m;let v=We(M,s),T=0;if(m!==-1&&b===f)v=We(m+1,s),T=0;else if(v===m&&b!==void 0&&S!==void 0)T=b-S-f;else{const{cumulative:L,currentValue:P}=a.prefixSum(v,{materializeOption:{materialize:!1}});T=(L??0)-(P??0)-f}const te=T,X=(L,P)=>{let I=L,Z=P,U=0;for(;I<s&&Z<e;){const $=i(I);if(Z+=$,I++,!Number.isFinite($)||$<0)break;if($===0){if(U++,U>br){const{cumulative:se}=a.prefixSum(I-1,{materializeOption:{materialize:!1}}),{index:Q}=Number.isFinite(se)?a.findIndexAtOrAfter(se+.5,{materializeOption:{materialize:!1}}):{index:-1};if(Q>I)I=Q,U=0;else if(Q===I&&i(I)>0)U=0;else break}}else U=0}return{cursor:I,height:Z}},me=X(v,T);let Pe=me.cursor;if(T=me.height,T<e&&v>0){let L=T+Math.abs(Math.min(0,te)),P=v-1,I=0;for(;P>=0&&L<e;){const U=i(P);if(L+=U,!Number.isFinite(U)||U<0){P--;break}if(U===0){if(I++,I>br){const{cumulative:$}=a.prefixSum(P,{materializeOption:{materialize:!1}}),{index:se}=Number.isFinite($)?a.findIndexAtOrAfter($-.5,{materializeOption:{materialize:!1}}):{index:-1};if(se!==-1&&se<P){P=se,I=0;continue}if(se===P&&P>=1&&i(P-1)>0)I=0;else{P--;break}}}else I=0;P--}v=We(P+1,s);const Z=X(v,0);Pe=Z.cursor,T=Z.height}const V=We(v-n,s),F=We(Math.max(Pe-1,v),s),ie=We(F+n,s);return{renderingStartIndex:V,renderingEndIndex:ie,visibleStartIndex:v,visibleEndIndex:F}},pn=(r,e,n)=>{const s=Math.max(0,e??0),i=t.useRef({last:0,id:null,arg:null}).current;return t.useEffect(()=>()=>{if(i.id!==null&&(cancelAnimationFrame(i.id),i.id=null),i.arg!==null&&r.current){try{n(r.current,i.arg)}catch(a){console.error("[useThrottledInvoker] Error flushing pending callback on unmount",a)}i.arg=null}},[i,r,n]),t.useCallback(a=>{if(i.arg=a,i.id!==null)return;const o=u=>{if(i.id=null,i.arg===null)return;const f=u-i.last;if(s===0||i.last===0||f>=s){if(r.current)try{n(r.current,i.arg)}catch(m){console.error("[useThrottledInvoker] Error invoking callback",m)}i.arg=null,i.last=u}i.arg!==null&&(i.id=requestAnimationFrame(o))};i.id=requestAnimationFrame(o)},[s,n,r,i])},Ss=t.memo(({index:r,top:e,height:n,item:s,children:i,clipItemHeight:a,enableKeyboardNavigation:o,onKeyDown:u,onEscapeKeyDown:f,onFocus:m,registerItemRef:b})=>{const S=t.useCallback(X=>b(r,X),[r,b]),M=t.useCallback(X=>u(X,r),[r,u]),v=t.useCallback(X=>f?.(X,r),[r,f]),T=t.useCallback(()=>m(r),[r,m]),te=t.useCallback(X=>{X.currentTarget.focus({preventScroll:!0})},[]);return z.jsx("div",{ref:S,"data-index":r,"data-virtualscroll-item":"true",className:"aqvs-item-container",style:{top:e,height:n,overflow:a?"hidden":void 0},tabIndex:o?-1:void 0,onPointerDown:o?te:void 0,onKeyDownCapture:o?M:void 0,onKeyDown:o&&f?v:void 0,onFocusCapture:o?T:void 0,children:i(s,r)})}),Rs=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:s,viewportSize:i,overscanCount:a=15,className:o,testId:u,onScroll:f,onRangeChange:m,children:b,background:S,initialScrollIndex:M,initialScrollOffset:v,initialScrollAnchor:T,callbackThrottleMs:te=5,contentInsets:X,onItemFocus:me,scrollBarOptions:Pe,behaviorOptions:V,onWheelHorizontal:F,onPanHorizontal:ie,horizontalKeyInputs:L,horizontalKeyStep:P=vs,contentProps:I,liveRegion:Z,locale:U,labels:$},se)=>{const{width:Q,enableThumbDrag:he,enableTrackClick:Ue,enableArrowButtons:C,enableArrowButtonTabStops:q,enableScrollToTopBottomButtons:re,renderThumbOverlay:Ge,tapScrollCircleOptions:ae}=Pe??{},xe=t.useMemo(()=>Br(U,$),[U,$]),{enablePointerDrag:Ct,pointerDragInputs:le,enableKeyboardNavigation:oe=!0,enableEscapeRowReturn:ht=!1,wheelSpeedMultiplier:Je,inertiaOptions:nt,overscrollBehavior:ze,clipItemHeight:et=!1,resetOnGetItemHeightChange:Ke=!1}=V??{},[Ze,ue]=t.useState(0),Ie=i??Ze,_e=t.useCallback(c=>{ue(g=>g===c?g:c)},[]),O=t.useRef(null),He=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),G=t.useRef(T&&r>0?{index:ne(Math.trunc(T.index),0,r-1),align:"top",offset:-Math.max(0,T.offsetPx??0)}:null),ft=t.useRef(!1),Y=t.useRef(!0);t.useEffect(()=>{if(Y.current){Y.current=!1;return}Ke&&(G.current=null)},[Ke,s]);const E=t.useMemo(()=>hn(X),[X]),[st]=t.useState(()=>{const g=T?.index??M,x=typeof g=="number"&&Number.isFinite(g)?Math.max(0,Math.trunc(g)):0;return{from:Math.max(0,x-50),to:x+50}}),ye=t.useMemo(()=>({sampleRange:st,resetOnValueFnChange:Ke,materialize:!0}),[Ke,st]),A=Gr(r,s,ye),[it]=t.useState(()=>{let c=0,g=0;if(T&&r>0){const x=ne(Math.trunc(T.index),0,r-1),B=Math.max(0,T.offsetPx??0),W=ne(x-a*2,0,r-1),K=ne(x+a*2,0,r-1),J=x>0||B>0?{materializeOption:{materialize:!0,ranges:[{from:W,to:K}]}}:void 0,{cumulative:Me,total:Fe,currentValue:Ae}=A.prefixSum(x,J),Ee=Math.max(Me-Ae+B,0);c=rr(Ee,E.top),g=Fe??A.getTotal()}else if(typeof M=="number"){const x=ne(M,0,r-1),B=ne(x-a*2,0,r-1),W=ne(x+a*2,0,r-1),K=M>0?{materializeOption:{materialize:!0,ranges:[{from:B,to:W}]}}:void 0,{cumulative:J,total:Me,currentValue:Fe}=A.prefixSum(M,K),Ae=Math.max(J-Fe,0);c=rr(Ae,E.top),g=Me??A.getTotal()}else typeof v=="number"&&(c=rr(Math.max(v,0),E.top)),g=A.getTotal();return{position:c,total:g}}),[xt,Pt]=t.useState(it.position),[at,p]=t.useState(it.total),_=t.useRef(it.position),de=t.useRef(E.top),j=t.useRef(f??void 0),ee=t.useRef(m??void 0),ke=t.useRef(F),Xe=(L?.length??0)>0,ge=!!F;t.useEffect(()=>{Xe&&(oe||N.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),ge||N.warn("[VirtualScroll] horizontalKeyInputs is set but onWheelHorizontal is missing; horizontal keyboard scrolling is disabled because the package does not own the horizontal axis."),Number.isFinite(P)&&P>0||N.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${P}. Horizontal arrow keys are left untouched.`))},[Xe,ge,oe,P]);const qe=t.useRef(new Map),be=t.useRef(null),Ne=t.useRef(null),[ot,tt]=t.useState(null),[Ve,Ye]=t.useState(!1),pe=t.useRef(null),ve=t.useRef(!1),Be=t.useRef(0),Te=t.useRef(!1),w=t.useRef(!1),y=t.useRef(r);y.current!==r&&(y.current=r,w.current=!0),t.useLayoutEffect(()=>{j.current=f??void 0,ee.current=m??void 0,ke.current=F},[m,f,F]);const Ce=t.useCallback(c=>{if(oe&&c&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},[oe]),Oe=t.useCallback((c,{position:g,totalHeight:x})=>{c(g,x)},[]),$e=pn(j,te,Oe),rt=t.useCallback((c,g)=>{c(g)},[]),lt=pn(ee,te,rt),we=t.useRef(E.top);we.current=E.top;const Rt=t.useRef($e);Rt.current=$e,t.useEffect(()=>(ft.current=!1,()=>{ft.current=!0,pe.current&&(clearTimeout(pe.current),pe.current=null)}),[]),t.useEffect(()=>{oe||(qe.current.clear(),be.current=null,Ne.current=null)},[oe]);const jt=t.useCallback((c,g)=>{if(!g){qe.current.delete(c);return}oe&&(qe.current.set(c,g),be.current===c&&(be.current=null,Ne.current=c,Ce(g)))},[oe,Ce]),nr=.01,Se=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:it.position}),pt=t.useCallback(()=>{const c=Se.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{pt()},[pt]);const Zt=t.useRef(()=>{}),Wt=t.useCallback(()=>{const c=Se.current;c.rafId=null;const g=_.current,x=St(g,we.current),B=A.getTotal();if(Pt(K=>Math.abs(K-g)<nr?K:g),Math.abs(c.lastRenderedPosition-g)>=nr?(Rt.current({position:x,totalHeight:B}),c.lastRenderedPosition=g,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){pt();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(K=>Zt.current(K));return}c.loopActive=!1},[A,pt]);Zt.current=Wt;const Xt=t.useCallback(()=>{const c=Se.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(Wt);return}c.loopActive=!1}},[Wt]),Re=t.useCallback((c,g)=>{const x=g?.immediate??!1,B=St(c,E.top);if(_.current=c,x){Se.current.lastRenderedPosition=c,Se.current.idleFrames=0,Pt(c),$e({position:B,totalHeight:A.getTotal()});return}Xt()},[Xt,A,E.top,$e]),Mt=t.useCallback((c,g=0)=>{const x=O.current;if(!x)return c;const B=x.getScrollPosition();Be.current+=1;const W=x.getContentSize()+g,K=x.getViewportSize(),J=x.scrollTo(c,{contentSize:W,viewportSize:K});return J===B&&(Be.current=Math.max(0,Be.current-1)),Math.abs(J-c)>.5&&(Te.current=!0),J},[]),$t=t.useRef(!1);t.useEffect(()=>{if(!$t.current)if($t.current=!0,T==null&&typeof M!="number"&&typeof v=="number"){const c=rr(Math.max(v,0),E.top),g=Math.abs(c-_.current)>.5;Re(c,{immediate:!0}),g&&O.current?.scrollTo(c)}else Re(_.current,{immediate:!0})},[T,M,v,E.top,Re]),t.useEffect(()=>{const c=A.getTotal();if(at!==c){p(c);return}if(Te.current){Te.current=!1;const g=O.current;if(g&&Math.abs(g.getScrollPosition()-_.current)>.5){const x=Mt(_.current);Te.current=!1,Re(x,{immediate:!0})}}},[A,at,r,Mt,Re]),t.useEffect(()=>{if(G.current!==null){const{index:c,align:g,offset:x}=G.current,B=We(c,r),{cumulative:W,currentValue:K}=A.prefixSum(B,{materializeOption:{materialize:!1}});if(W!==void 0&&K!==void 0){const J=Math.max(W-K,0);let Me=J;g==="bottom"?Me=W-Ie:g==="center"&&(Me=J+K/2-Ie/2),x&&(Me-=x),Me=Math.max(0,Me);const Fe=Math.max(0,at+E.top+E.bottom-Ie),Ae=Math.min(rr(Me,E.top),Fe);Math.abs(Ae-_.current)>1&&(N.debug("[VirtualScroll] Drift correction",{from:_.current,to:Ae,targetIndex:B}),Be.current===0&&(Be.current+=1),O.current?.scrollTo(Ae),Re(Ae,{immediate:!0}))}}w.current=!1},[at,A,r,E.top,Re,Ie,E.bottom]),t.useEffect(()=>{const c=de.current;if(c===E.top||(de.current=E.top,G.current))return;const g=St(_.current,c),x=rr(g,E.top);_.current=x,O.current?.scrollTo(x),Re(x,{immediate:!0})},[E.top,Re]);const Qt=t.useCallback((c,g)=>{if(r===0)return;const x=We(c,r),B=A.get(x),W=g-B,K=A.update(x,g);K!==void 0&&p(K),N.debug("[VirtualScroll] Updated item size manually",{index:x,size:g,total:K});let J=G.current?G.current.index:null;if(J===null){const Me=_.current,Fe=hn(X).top,Ae=St(Me,Fe),{index:Ee,cumulative:mt}=A.findIndexAtOrAfter(Ae,{materializeOption:{materialize:!1}});J=mt!==void 0&&mt===Ae?Ee+1:Ee}if(J!==-1&&x<J&&W!==0){const Me=_.current,Fe=Me+W;Mt(Fe,W),Re(Fe,{immediate:!0}),N.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:Me,to:Fe,causedByIndex:x,delta:W,activeVisibleStartIndex:J})}},[A,r,Mt,Re,X]),gt=t.useCallback((c,g)=>{if(!O.current||r===0)return;const x=We(c,r),B=We(x-a*2,r),W=We(x+a*2,r),{cumulative:K,total:J,currentValue:Me}=A.prefixSum(x,{materializeOption:{materialize:!0,ranges:[{from:B,to:W}]}});if(N.debug("[VirtualScroll] Scrolling to index:",x,"ItemBottom:",K,"Total height:",J,"ItemHeight:",Me,"safeIndexFrom:",B,"safeIndexTo:",W),!J)return;const Fe=Math.max(K-Me,0);let Ae=Fe;g?.align==="bottom"?Ae=K-Ie:g?.align==="center"&&(Ae=Fe+Me/2-Ie/2),g?.offset&&(Ae-=g.offset),Ae=Math.max(0,Ae);const Ee=rr(Ae,E.top),mt=O.current?.getContentSize()??J+E.top+E.bottom,ut=Math.max(0,mt-Ie),dt=Math.min(Ee,ut);G.current={index:x,align:g?.align,offset:g?.offset};const tr=O.current?.getScrollPosition()??-1,dr=Math.abs(tr-dt)>.5;ve.current=!1,Be.current=0,dr&&(ve.current=!0,Be.current+=1,O.current?.scrollTo(dt)),p(J),Re(dt,{immediate:!0}),N.debug("[VirtualScroll] Setting scroll position to:",dt,{original:Ee,max:ut})},[A,a,r,E.top,E.bottom,Ie,Re]),d=t.useRef(T&&r===0?T:null);t.useEffect(()=>{const c=d.current;!c||r===0||(d.current=null,gt(ne(Math.trunc(c.index),0,r-1),{align:"top",offset:-Math.max(0,c.offsetPx??0)}))},[r,gt]);const k=t.useCallback(c=>{if(!O.current||r===0)return;const g=A.getTotal(),x=ne(Math.floor(c),0,g),{index:B,cumulative:W,currentValue:K}=A.findIndexAtOrAfter(x,{materializeOption:{materialize:!1}}),Me=(W??0)-(K??0)-x;gt(B,{offset:Me})},[A,r,gt]),D=t.useCallback(()=>{if(r===0)return null;const c=St(_.current,E.top),{index:g,cumulative:x,currentValue:B}=A.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(g===-1)return{index:r-1,offsetPx:0};if(x===c)return{index:ne(g+1,0,r-1),offsetPx:0};const W=(x??0)-(B??0);return{index:g,offsetPx:Math.max(0,c-W)}},[A,r,E.top]),fe=t.useCallback(c=>{const g=St(_.current,E.top),x=typeof c=="function"?c(g):c;k(x);const B=O.current?.getScrollPosition(),W=typeof B=="number"?B:_.current;return Re(W),St(W,we.current)},[E.top,k,Re]),Le=t.useCallback(c=>{const g=O.current;if(!g)return St(_.current,we.current);const x=g.scrollTo(B=>B+c);return St(x,we.current)},[]),De=t.useCallback(c=>O.current?.applyWheel(c)??!1,[]),vt=t.useCallback((c,g)=>{N.debug("[VirtualScroll] Scroll position changed:",c);const x=ve.current;x&&(ve.current=!1);const B=Be.current>0;B&&(Be.current=0);const W=w.current&&y.current===r;if(x||B||W||(G.current=null),Re(c),re){if(x||B)return;const K=c-g;if(N.debug("[VirtualScroll] Scroll diff:",K,"New:",c,"Prev:",g),Math.abs(K)>1){const J=K>0?"down":"up";tt(J),Ye(!0),N.debug("[VirtualScroll] Showing scroll buttons. Direction:",J),pe.current&&clearTimeout(pe.current),pe.current=setTimeout(()=>{Ye(!1),N.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[Re,re,r]),je=t.useMemo(()=>St(xt,E.top),[E.top,xt]),zt=t.useMemo(()=>{const c=A.getTotal(),g=kn(je,Ie,a,r,s,A,c);return N.debug("[VirtualScroll] Calculated rendering range:",()=>({...g,scrollPosition:je,renderingContentSize:c,overscanCount:a,viewportSize:Ie})),g},[je,Ie,a,r,s,A]),{renderingStartIndex:wt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:Lt}=zt,bt=t.useCallback((c,g)=>{if(!oe||r===0)return;const x=We(c,r);if(!(g?.ensureVisible??!0)){const ut=qe.current.get(x);ut&&(be.current=null,Ne.current=x,Ce(ut));return}const W=A.prefixSum(x,{materializeOption:{materialize:!1}}),K=W.currentValue,J=Math.max(W.cumulative-K,0),Me=J+K,Fe=St(_.current,E.top),Ae=Fe+Ie;if(J<Fe||Me>Ae){gt(x);const ut=qe.current.get(x);ut?(be.current=null,Ne.current=x,Ce(ut)):be.current=x;return}const mt=qe.current.get(x);if(mt){be.current=null,Ne.current=x,Ce(mt);return}be.current=x},[oe,r,A,E.top,gt,Ce,Ie]),qt=t.useCallback((c,g)=>{if(!(!oe||c.defaultPrevented)&&!(c.altKey||c.metaKey||c.ctrlKey)&&c.target===c.currentTarget&&!c.currentTarget.isContentEditable){if(c.key==="ArrowLeft"||c.key==="ArrowRight"){const x=ke.current;if(!x||c.shiftKey||!L?.includes("arrow")||!(Number.isFinite(P)&&P>0))return;c.preventDefault(),x(c.key==="ArrowLeft"?-P:P);return}if(c.key==="ArrowDown"){g<r-1&&(c.preventDefault(),bt(g+1));return}if(c.key==="ArrowUp"){g>0&&(c.preventDefault(),bt(g-1));return}if(c.key==="PageDown"){if(g<r-1){c.preventDefault();const{visibleStartIndex:x,visibleEndIndex:B}=He.current,W=Math.max(B-x+1,1),K=Math.max(W,1),J=We(Math.min(g+K,r-1),r);bt(J)}return}if(c.key==="PageUp"&&g>0){c.preventDefault();const{visibleStartIndex:x,visibleEndIndex:B}=He.current,W=Math.max(B-x+1,1),K=Math.max(W,1),J=We(g-K,r);bt(J)}}},[oe,r,bt,L,P]),ur=t.useCallback((c,g)=>{if(c.key!=="Escape"||c.defaultPrevented||c.nativeEvent.isComposing||c.target===c.currentTarget)return;const x=c.target;x instanceof HTMLInputElement||x instanceof HTMLTextAreaElement||x instanceof HTMLSelectElement||x.isContentEditable||(c.preventDefault(),bt(g))},[bt]),yt=t.useCallback(c=>{if(!oe)return;const g=We(c,r);be.current=null,Ne.current=g,me?.(g)},[oe,r,me]);t.useEffect(()=>{const c=O.current?.getScrollPosition()??0,g=_.current,x=St(g,E.top);N.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:wt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:Lt,scrollPositionState:xt,paneScrollPosition:g,logicalScrollPosition:x,contentSize:at,scrollPaneScrollPosition:c})),lt({renderingStartIndex:wt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:Lt,scrollPosition:x,totalHeight:at})},[at,kt,wt,E.top,lt,xt,Lt,Vt]);const Dt=t.useCallback(()=>{if(!re)return null;const c=Ve&&ot!==null,g=ot==="up";return z.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:g?z.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:z.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:x=>{x.stopPropagation(),ve.current=!0,gt(0),Ye(!1)},children:xe.scrollToTop})}):z.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:z.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:x=>{x.stopPropagation(),ve.current=!0,gt(r-1),Ye(!1)},children:xe.scrollToBottom})})})},[re,Ve,ot,gt,r,xe]),_t=t.useRef(0),{visibleItems:Nt,renderAnchor:Ot}=t.useMemo(()=>{if(r===0)return{visibleItems:z.jsx("div",{className:"aqvs-no-items-container",children:z.jsx("div",{className:"aqvs-no-items-text",children:xe.noItems})}),renderAnchor:0};const c=We(wt,r),g=We(kt,r),{cumulative:x,currentValue:B}=A.prefixSum(c,{materializeOption:{materialize:!1}}),W=x-B;Number.isFinite(W)&&Math.abs(W-_t.current)>Cn&&(_t.current=W);const K=_t.current,J=[],Me=[];let Fe=0,Ae=W;for(let Ee=c;Ee<=g;Ee++){if(Me.length>=Fr){N.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:Fr,safeRenderingStartIndex:c,safeRenderingEndIndex:g});break}const mt=s(Ee),ut=A.get(Ee),dt=mt-ut;dt!==0&&J.push({index:Ee,value:mt});const tr=Ae+Fe,dr=n?n(Ee):Ee;Me.push(z.jsx(Ss,{index:Ee,top:tr-K,height:mt,item:e(Ee),clipItemHeight:et,enableKeyboardNavigation:oe,onKeyDown:qt,onEscapeKeyDown:ht?ur:void 0,onFocus:yt,registerItemRef:jt,children:b},dr)),Fe+=dt,Ae+=ut}return J.length>0&&Promise.resolve().then(()=>{if(ft.current)return;let Ee=0;for(const dt of J)if(dt.index<Vt){const tr=A.get(dt.index);Ee+=dt.value-tr}const mt=A.updates(J);if(ft.current||typeof mt!="number")return;p(mt),N.debug("[VirtualScroll] Updated heights for items",J,"New total height:",mt);const ut=O.current?.getScrollPosition()??_.current;if(Ee!==0){const dt=ut+Ee;Mt(dt,Ee),Re(dt,{immediate:!0}),N.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:ut,to:dt,shiftAmount:Ee})}else ut!==_.current&&Re(ut)}),{visibleItems:Me,renderAnchor:K}},[b,et,at,oe,r,A,e,n,s,yt,qt,ht,ur,Mt,jt,kt,wt,xe,Re,Vt]),Jt=t.useCallback(c=>{const g=(te??0)>0,x=Math.abs(c-xt),B=g&&x>.5?xt:c,W=St(B,E.top);if(N.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:W,renderingStartIndex:wt,renderingEndIndex:kt,itemCount:r,viewportSize:Ie,callbackThrottleMs:te,diff:x,rawEffectiveScrollPosition:B})),r===0)return Nt;const K=E.top+Ot-B,J=E.bottom>0?z.jsx("div",{className:"aqvs-bottom-inset",style:{top:A.getTotal()-Ot,height:E.bottom}},"virtualscroll-bottom-inset"):null;return N.debug("[VirtualScroll] Rendering items",()=>({containerTop:K,logicalScrollPosition:je,resolvedInsets:E,effectiveScrollPosition:W})),z.jsxs(xs,{translateY:K,children:[Nt,J]})},[te,r,A,je,Ot,kt,wt,E,xt,Ie,Nt]),Yt=t.useMemo(()=>({renderingStartIndex:zt.renderingStartIndex,renderingEndIndex:zt.renderingEndIndex,visibleStartIndex:zt.visibleStartIndex,visibleEndIndex:zt.visibleEndIndex,scrollPosition:je,totalHeight:A.getTotal()}),[zt,je,A,at]);t.useEffect(()=>{He.current=Yt},[Yt]);const[Tt,Ut]=t.useState(""),Bt=t.useRef(Z);t.useLayoutEffect(()=>{Bt.current=Z},[Z]);const ct=Z?.debounceMs??400,sr=Number.isFinite(ct)&&ct>=0,It=Z!==void 0;t.useEffect(()=>{It&&!sr&&N.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${ct}. Announcements are disabled.`)},[It,sr,ct]),t.useEffect(()=>{if(!(It&&sr)){Ut("");return}const c=setTimeout(()=>{const g=Bt.current?.format;if(!g)return;const x=g({visibleStartIndex:Vt,visibleEndIndex:Lt,itemCount:r});Ut(x)},ct);return()=>clearTimeout(c)},[It,sr,ct,Vt,Lt,r]),t.useImperativeHandle(se,()=>({getScrollPosition:()=>{const c=O.current?.getScrollPosition();return typeof c=="number"?St(c,we.current):-1},getContentSize:()=>O.current?.getContentSize()??-1,getViewportSize:()=>O.current?.getViewportSize()??-1,scrollTo:fe,scrollBy:Le,applyWheel:De,scrollToIndex:gt,getFenwickTreeTotalHeight:()=>A.getTotal(),getFenwickSize:()=>A.getSize(),focusItemAtIndex:bt,getRange:()=>He.current,getScrollAnchor:D,updateItemSize:Qt}),[fe,Le,De,gt,A,bt,D,Qt]);const xr=A.getTotal()+E.top+E.bottom,er=z.jsx(In,{ref:O,contentSize:xr,viewportSize:i,onViewportSizeChange:_e,className:o,testId:u,onScroll:vt,background:S,tapScrollCircleOptions:ae,inertiaOptions:nt,overscrollBehavior:ze,itemCount:r,scrollBarWidth:Q,enableThumbDrag:he,enableTrackClick:Ue,enableArrowButtons:C,enableArrowButtonTabStops:q,enablePointerDrag:Ct,pointerDragInputs:le,renderThumbOverlay:Ge,wheelSpeedMultiplier:Je,onWheelHorizontal:F,onPanHorizontal:ie,contentInsets:E,contentProps:I,visibleStartIndex:Vt,visibleEndIndex:Lt,renderOverlay:Dt,initialScrollPosition:it.position,locale:U,labels:$,children:Jt});return It?z.jsxs(z.Fragment,{children:[er,z.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Tt})]}):er},Nn=t.forwardRef(Rs),cr=262144,gn=3,An=32768,Hr=128,Xr=128,$r=128,qr=128,Lr=10,Ms=(r,e)=>Math.max(1,Math.floor((r??An)/Math.max(1,e))),ys=(r,e,n,s,i)=>{let a=0,o=0,u=Math.max(0,Math.min(s,n-1));for(;u<n&&a<r&&o<Fr;)a+=e(u),o+=1,u+=1;return Math.max(1,o+2*i+2)},Tr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=cr)){const s=e==="row"?"getRowHeight":"getColWidth",i=e==="row"?"rows":"columns";throw new RangeError(`[VirtualGrid] ${s}(${n}) returned ${r} — must be an integer in [0, ${cr}] (0 = hidden). Round fractional sizes to whole pixels and split content larger than ${cr} px across several ${i}: a larger track could push cell positions past the 2^25 px layout-coordinate limit of browsers.`)}return r},Ts=(r,e,n,s,i,a,o,u)=>{const f=kn(r,e,n,s,i,a,o);if(s===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const m=ne(f.renderingStartIndex,0,s-1),{cumulative:b,currentValue:S}=a.prefixSum(m,{materializeOption:{materialize:!1}}),M=b-S,v=Number.isFinite(M)&&Math.abs(M-u)>Cn?M:u;return{renderingColStart:f.renderingStartIndex,renderingColEnd:f.renderingEndIndex,visibleColStart:f.visibleStartIndex,visibleColEnd:f.visibleEndIndex,colAnchor:v}},bn=[],Is=(r,e,n,s,i)=>{const a=[],o=[];if(e<r)return{columns:a,widthUpdates:o,truncated:0};const u=s.prefixSum(r,{materializeOption:{materialize:!1}});let f=u.cumulative-u.currentValue,m=0,b=r;for(;b<=e;){if(a.length>=i)return{columns:a,widthUpdates:o,truncated:e-b+1};const S=n(b),M=s.get(b);if(S!==M&&o.push({index:b,value:S}),S>0){a.push({col:b,left:f,width:S}),f+=M,m=0,b+=1;continue}if(f+=M,m+=1,b+=1,m>br){const v=s.findIndexAtOrAfter(f+.5,{materializeOption:{materialize:!1}});if(v.index===-1||v.index<=b||!Number.isSafeInteger(v.index))break;const T=s.prefixSum(v.index,{materializeOption:{materialize:!1}});f=T.cumulative-T.currentValue,b=v.index,m=0}}return{columns:a,widthUpdates:o,truncated:0}},Es=(r,e,n)=>{const s=[],i=[];let a=0;for(let o=0;o<r;o+=1){const u=e(o),f=n.get(o);u!==f&&i.push({index:o,value:u}),u>0&&s.push({col:o,left:a,width:u}),a+=f}return{columns:s,widthUpdates:i,width:a}},Cs=(r,e,n,s)=>{const i=[],a=[];let o=0;for(let u=r-e;u<r;u+=1){const f=n(u),m=s.get(u);f!==m&&a.push({index:u,value:f}),f>0&&i.push({col:u,left:o,width:f}),o+=m}return{columns:i,widthUpdates:a,width:o}},Ir=(r,e,n)=>Math.min(r,Math.max(0,n-e)),Ps={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},ks=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:s,getCell:i,getCellKey:a,children:o,getCellProps:u,getRowProps:f,contentProps:m,background:b,contentInsets:S,onRowFocus:M,frozenLeadingCols:v=0,frozenLeadingRows:T=0,frozenTrailingCols:te=0,frozenTrailingRows:X=0,horizontalKeyInputs:me,horizontalKeyStep:Pe,onScroll:V,onRangeChange:F,onRenderTruncated:ie,callbackThrottleMs:L,initialScrollAnchor:P,overscanRows:I=gn,overscanCols:Z=gn,viewportSize:U,__maxRenderedCells:$,behaviorOptions:se,scrollBarOptions:Q,liveRegion:he,locale:Ue,labels:C,className:q,testId:re},Ge)=>{const ae=t.useRef(null),xe=t.useRef(null),Ct=t.useRef(n);Ct.current=n;const le=t.useRef(s);le.current=s;const oe=se?.resetOnGetColWidthChange===!0,Je=se?.resetOnGetItemHeightChange===!0?n:null,nt=oe?s:null,ze=t.useCallback(l=>Tr(Ct.current(l),"row",l),[Je]),et=t.useCallback(l=>Tr(le.current(l),"col",l),[nt]),Ke=se?.defaultColWidth,Ze=t.useMemo(()=>{if(Ke!==void 0&&!(Number.isInteger(Ke)&&Ke>=0&&Ke<=cr))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${cr}], received ${Ke}.`);return{resetOnValueFnChange:oe,baseValue:Ke}},[oe,Ke]),ue=Gr(e,et,Ze),[Ie,_e]=t.useState(0);if(!(Number.isInteger(v)&&v>=0&&v<=Hr))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${Hr}], received ${v}.`);const O=Math.min(v,e),He=t.useRef(0);if(!(Number.isInteger(te)&&te>=0&&te<=$r))throw new RangeError(`[VirtualGrid] frozenTrailingCols must be an integer in [0, ${$r}], received ${te}.`);const G=Math.min(te,e-O),ft=t.useRef(0);if(!(Number.isInteger(T)&&T>=0&&T<=Xr))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${Xr}], received ${T}.`);const Y=Math.min(T,r);if(!(Number.isInteger(X)&&X>=0&&X<=qr))throw new RangeError(`[VirtualGrid] frozenTrailingRows must be an integer in [0, ${qr}], received ${X}.`);const E=Math.min(X,r-Y),st=Math.max(0,r-Y-E),ye=t.useRef(!1),A=t.useRef(0),it=t.useRef(0),[xt,Pt]=t.useState(0),{frozenRows:at,frozenHeight:p}=t.useMemo(()=>{if(Y===0)return{frozenRows:[],frozenHeight:0};const l=[];let h=0;for(let R=0;R<Y;R+=1){const H=ze(R);H>0&&l.push({row:R,top:h,height:H}),h+=H}return{frozenRows:l,frozenHeight:h}},[Y,xt,ze]);A.current=p;const[_,de]=t.useState(0),{trailingRows:j,trailingHeight:ee}=t.useMemo(()=>{if(E===0)return{trailingRows:[],trailingHeight:0};const l=[];let h=0;for(let R=r-E;R<r;R+=1){const H=ze(R);H>0&&l.push({row:R,top:h,height:H}),h+=H}return{trailingRows:l,trailingHeight:h}},[E,r,_,ze]);it.current=ee;const ke=t.useCallback(l=>ze(l+Y),[ze,Y]),Xe=t.useRef(M);Xe.current=M;const ge=M!==void 0,qe=t.useMemo(()=>ge?l=>Xe.current?.(l+Y):void 0,[Y,ge]),be=p,Ne=ee,[ot,tt]=t.useState(Y),Ve=t.useRef(null),Ye=t.useRef(!1);if(ot!==Y){tt(Y),Ye.current=!0;const l=ae.current?.getScrollAnchor()??null;Ve.current=l===null?null:{row:l.index+ot,offsetPx:l.offsetPx}}const pe=t.useRef(0),ve=t.useRef(0),Be=t.useRef(!1),[Te,w]=t.useState(Ps),y=t.useRef(Te);y.current=Te;const Ce=t.useRef(0),[Oe,$e]=t.useState(()=>ue.getTotal()??0),rt=t.useRef(Oe);rt.current=Oe;const lt=t.useCallback(l=>{typeof l=="number"&&Number.isFinite(l)&&(rt.current=l,$e(l))},[]);t.useLayoutEffect(()=>{const l=ue.getTotal();typeof l=="number"&&Number.isFinite(l)&&l!==rt.current&&lt(l)});const we=Q?.width??12,Rt=U===void 0?null:{width:Math.max(0,Math.round(U.width)-we),height:Math.max(0,Math.round(U.height)-we)},[jt,nr]=t.useState({width:0,height:0}),Se=Rt??jt,pt=t.useRef(Se);pt.current=Se;const Zt=Se.height>0&&Se.height-p-ee<=0;ye.current=Zt;const Wt=Rt!==null;t.useLayoutEffect(()=>{if(Wt)return;const l=xe.current;if(l===null)return;const h=()=>{const H=Math.max(0,Math.round(l.clientWidth)-we),ce=Math.max(0,Math.round(l.clientHeight)-we);nr(Qe=>Qe.width===H&&Qe.height===ce?Qe:{width:H,height:ce})};h();const R=new ResizeObserver(h);return R.observe(l),()=>R.disconnect()},[we,Wt]);const Xt=t.useCallback(()=>{const l=xe.current;l!==null&&l.style.setProperty("--aqvs-grid-hx-residual",`${Ce.current-pe.current}px`)},[]),Re=t.useCallback(()=>Math.max(0,pt.current.width-He.current-ft.current),[]),Mt=t.useCallback(()=>Math.max(0,rt.current-He.current-ft.current-Re()),[Re]),$t=t.useCallback(()=>{const l=Re(),h=Ts(He.current+pe.current,l,Z,e,et,ue,rt.current,y.current.colAnchor);if(O>0&&(h.renderingColStart=Math.max(h.renderingColStart,O),h.visibleColStart=Math.max(h.visibleColStart,O)),G>0){const H=e-G-1;h.renderingColEnd=Math.min(h.renderingColEnd,H),h.visibleColEnd=Math.min(h.visibleColEnd,H)}(O>0||G>0)&&(l<=0||h.renderingColStart>h.renderingColEnd)&&(h.renderingColStart=e,h.renderingColEnd=e-1,h.visibleColStart=e,h.visibleColEnd=e-1);const R=`${h.renderingColStart}:${h.renderingColEnd}:${h.colAnchor}`;R!==y.current.key&&w({...h,key:R})},[Z,e,et,ue,O,G,Re]),[Qt,gt]=t.useState(0),d=t.useRef(null),k=t.useCallback(()=>{d.current===null&&(d.current=requestAnimationFrame(()=>{d.current=null,gt(pe.current)}))},[]);t.useEffect(()=>()=>{d.current!==null&&cancelAnimationFrame(d.current)},[]);const D=t.useRef(V);D.current=V;const fe=t.useRef(F);fe.current=F;const Le=t.useRef(ie);Le.current=ie;const De=t.useRef(null),[vt,je]=t.useState(null),[zt,wt]=t.useState(Se.height);zt!==Se.height&&(wt(Se.height),je(null));const kt=P===void 0||r===0?0:ne(Math.trunc(P.row),0,r-1),Vt=t.useMemo(()=>{const l=De.current?.renderingStartIndex??kt;return ys(Math.max(0,Se.height-A.current-it.current),ze,r,l,I)},[Se.height,ze,r,kt,I,be,Ne]),Lt=vt??Vt,bt=t.useCallback(()=>{const l=De.current;if(l===null)return null;const h=y.current;return{renderingRowStart:l.renderingStartIndex,renderingRowEnd:l.renderingEndIndex,visibleRowStart:l.visibleStartIndex,visibleRowEnd:l.visibleEndIndex,renderingColStart:h.renderingColStart,renderingColEnd:h.renderingColEnd,visibleColStart:h.visibleColStart,visibleColEnd:h.visibleColEnd,scrollX:pe.current,scrollY:ve.current,totalWidth:rt.current,totalHeight:l.totalHeight+A.current+it.current}},[]),qt=t.useCallback(()=>{const l=bt();l!==null&&fe.current?.(l)},[bt]),ur=t.useCallback(l=>{const h=Mt(),R=ne(l,0,h);return R!==pe.current&&(pe.current=R,Xt(),$t(),k(),D.current?.({x:R,y:ve.current})),R},[Xt,$t,k,Mt]),yt=t.useRef(ur);yt.current=ur,t.useLayoutEffect(()=>{Ce.current=Te.colAnchor,Xt(),qt()},[Te,Xt,qt]),t.useLayoutEffect(()=>{De.current!==null&&qt()},[p,ee,qt]);const Dt=t.useRef(null),_t=t.useCallback(l=>{const h=ne(l.col,0,Math.max(0,e-1)),R=ue.prefixSum(h,{materializeOption:{materialize:!1}}),H=R.cumulative-R.currentValue,ce=R.currentValue,Qe=Re();return(l.alignX==="end"?H+ce-He.current-Qe:l.alignX==="center"?H+ce/2-He.current-Qe/2:H-He.current)+l.offsetX},[ue,e,Re]),Nt=t.useRef(null),Ot=t.useCallback(()=>{const l=Nt.current;Nt.current=null,!(l===null||l.length===0)&&(lt(ue.updates(l)),_e(h=>h+1))},[ue,lt]),Jt=t.useRef({count:0,warned:!1}),{frozenColumns:Yt,frozenWidth:Tt}=t.useMemo(()=>{if(O===0)return Jt.current.count=0,Jt.current.warned=!1,{frozenColumns:bn,frozenWidth:0};const{columns:l,widthUpdates:h,width:R}=Es(O,et,ue);if(h.length>0){const H=Jt.current;H.count>=Lr?H.warned||(H.warned=!0,N.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values inside the frozen band; width self-heal is suspended until a converged pass re-arms it (unstable accessor).",{frozenCols:O,pendingUpdates:h.length})):(H.count+=1,Nt.current=[...Nt.current??[],...h],Promise.resolve().then(Ot))}else Jt.current.count=0,Jt.current.warned=!1;return{frozenColumns:l,frozenWidth:R}},[O,Ie,et,ue,Ot]);He.current=Tt,t.useLayoutEffect(()=>{O>0?xe.current?.style.setProperty("--aqvs-grid-frozen-width",`${Tt}px`):xe.current?.style.removeProperty("--aqvs-grid-frozen-width")},[Tt,O]);const Ut=t.useRef({count:0,warned:!1}),{trailingColumns:Bt,trailingWidth:ct}=t.useMemo(()=>{if(G===0)return Ut.current.count=0,Ut.current.warned=!1,{trailingColumns:bn,trailingWidth:0};const{columns:l,widthUpdates:h,width:R}=Cs(e,G,et,ue);if(h.length>0){const H=Ut.current;H.count>=Lr?H.warned||(H.warned=!0,N.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values inside the trailing band; width self-heal is suspended until a converged pass re-arms it (unstable accessor).",{trailingCols:G,pendingUpdates:h.length})):(H.count+=1,Nt.current=[...Nt.current??[],...h],Promise.resolve().then(Ot))}else Ut.current.count=0,Ut.current.warned=!1;return{trailingColumns:l,trailingWidth:R}},[G,e,Ie,et,ue,Ot]);ft.current=ct,t.useLayoutEffect(()=>{G>0?xe.current?.style.setProperty("--aqvs-grid-trailing-width",`${ct}px`):xe.current?.style.removeProperty("--aqvs-grid-trailing-width")},[ct,G]);const sr=t.useMemo(()=>({...Q,tapScrollCircleOptions:{...Q?.tapScrollCircleOptions,enabled:!1}}),[Q]),It=Q?.tapScrollCircleOptions,xr=typeof It?.maxSpeedMultiplier=="number",er=t.useMemo(()=>({...It,offsetX:It?.offsetX===void 0?fn:It.offsetX,offsetY:It?.offsetY===void 0?fn:It.offsetY}),[It]),c=t.useMemo(()=>Or(er,Math.max(0,e-O-G)),[er,e,O,G]),g=t.useMemo(()=>Or(er,st),[er,st]),x=c.enabled,B=Math.max(c.maxVisualDistance,1),W={viewportSize:Math.max(0,Se.width-Tt-ct),minSpeedMultiplier:c.minSpeedMultiplier,maxSpeedMultiplier:c.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:xr,curve:c.maxSpeedCurve},K={viewportSize:Math.max(0,Se.height-p-ee),minSpeedMultiplier:g.minSpeedMultiplier,maxSpeedMultiplier:g.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:xr,curve:g.maxSpeedCurve},J=t.useCallback(()=>pe.current,[]),Me=t.useCallback(()=>{const l=ae.current;if(l===null)return ve.current;const h=l.getScrollPosition();return h<0?ve.current:h},[]),Fe=t.useCallback(()=>{const l=ae.current;return l===null?0:Math.max(0,Math.max(0,l.getContentSize())-Math.max(0,l.getViewportSize()))},[]),Ae=t.useCallback(l=>{const h=ae.current;if(h===null)return ve.current;const R=h.scrollBy(l);return ve.current=R,R},[]),Ee=Mt()>0||Fe()>0,mt=`${Oe}:${Tt}:${ct}:${Se.width}:${Te.key}`,ut=`${r}:${vt??-1}:${p}:${ee}:${Se.height}`,{isTapActive:dt,handleTapCircleDragChange:tr,tapCircleHandleRef:dr}=fs({enabled:x&&Ee,maxDistance:B,xSpeedParams:W,ySpeedParams:K,applyHxRef:yt,getHx:J,getMaxHx:Mt,applyVy:Ae,getVy:Me,getMaxVy:Fe,pendingColAnchorRef:Dt,xExtentFreshness:mt,yExtentFreshness:ut}),zn=t.useMemo(()=>ne((dt?1:.8)*c.opacity,0,1),[dt,c.opacity]);t.useLayoutEffect(()=>{const l=Dt.current;l===null?yt.current(pe.current):yt.current(_t(l)),$t()},[Se.width,Oe,Ie,Tt,ct,$t,_t]);const Kr=t.useRef(!1);t.useLayoutEffect(()=>{if(Kr.current||P===void 0||e===0)return;Kr.current=!0;const l=ne(Math.trunc(P.col),0,e-1);if(l<O||l>=e-G)return;const h={col:l,alignX:"start",offsetX:Math.max(0,P.offsetX)};Dt.current=h,yt.current(_t(h))},[P,e,_t,O,G]);const Vn=t.useCallback(l=>{ve.current=l,Be.current=!0,D.current?.({x:pe.current,y:l})},[]),Zr=t.useCallback(l=>{if(st===0||ye.current)De.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:st===0?0:l.totalHeight},ve.current=0;else{const h=Y;De.current={renderingStartIndex:l.renderingStartIndex+h,renderingEndIndex:l.renderingEndIndex+h,visibleStartIndex:l.visibleStartIndex+h,visibleEndIndex:l.visibleEndIndex+h,scrollPosition:l.scrollPosition,totalHeight:l.totalHeight},ve.current=l.scrollPosition}je(h=>{const R=Math.max(1,l.renderingEndIndex-l.renderingStartIndex+1);return R===h?h:R}),qt()},[qt,Y,st,r]),Qr=t.useCallback(l=>{Dt.current=null,yt.current(pe.current+l)},[]),Jr=Ms($,Lt+at.length+j.length),Pr=t.useRef({count:0,warned:!1}),{placedColumns:vr,truncatedCols:wr}=t.useMemo(()=>{const l=Math.max(0,Se.width-Tt-ct);if(e===0||l<=0)return{placedColumns:[],truncatedCols:0};if(Te.renderingColStart>Te.renderingColEnd)return{placedColumns:[],truncatedCols:0};const h=Math.max(1,Jr-Yt.length-Bt.length),{columns:R,widthUpdates:H,truncated:ce}=Is(ne(Te.renderingColStart,0,e-1),ne(Te.renderingColEnd,0,e-1),et,ue,h);if(H.length>0){const Qe=Pr.current;Qe.count>=Lr?Qe.warned||(Qe.warned=!0,N.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values; width self-heal is suspended until a converged (zero-deviation) pass re-arms it (unstable accessor — the accessor must be index-stable while the ordering is unchanged).",{window:Te.key,pendingUpdates:H.length})):(Qe.count+=1,Nt.current=[...Nt.current??[],...H],Promise.resolve().then(Ot))}else Pr.current.count=0,Pr.current.warned=!1;return{placedColumns:R,truncatedCols:ce}},[Te,e,Se.width,Tt,ct,Yt.length,Bt.length,Ie,et,ue,Jr,Ot]),en=t.useRef("");t.useEffect(()=>{if(wr>0){const l=`${Te.key}:${wr}`;l!==en.current&&(en.current=l,Le.current?.({renderedCells:(vr.length+Yt.length+Bt.length)*(Lt+at.length+j.length),droppedCols:wr}))}},[wr,Te.key,vr.length,Yt.length,Bt.length,Lt,at.length,j.length]);const tn=Te.colAnchor,kr=t.useCallback(l=>{const h=f?.(l),R=ze(l)===0,H=R?null:vr.map(({col:ce,left:Qe,width:ar})=>{const At=u?.(l,ce),fr={...At?.style,left:Qe-tn,width:ar};return t.createElement("div",{...At,key:a?a(l,ce):ce,className:Et.twMerge("aqvs-grid-cell",At?.className),style:fr},o(i(l,ce),l,ce))});return O===0&&G===0?z.jsx("div",{...h,className:Et.twMerge("aqvs-grid-row",h?.className),style:h?.style,children:H}):z.jsxs("div",{...h,"data-aqvs-frozen-row":O>0?"":void 0,className:Et.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",h?.className),style:h?.style,children:[R?null:Yt.map(({col:ce,left:Qe,width:ar})=>{const At=u?.(l,ce),fr={...At?.style,left:Qe,width:ar};return t.createElement("div",{...At,"data-aqvs-frozen-cell":"",key:a?a(l,ce):ce,className:Et.twMerge("aqvs-grid-cell",At?.className),style:fr},o(i(l,ce),l,ce))}),R?null:z.jsx("div",{className:"aqvs-grid-row-scroll",children:z.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:H})}),R||G===0?null:z.jsx("div",{className:"aqvs-grid-row-trailing",children:z.jsx("div",{className:"aqvs-grid-row-trailing-inner",children:Bt.map(({col:ce,left:Qe,width:ar})=>{const At=u?.(l,ce),fr={...At?.style,left:Qe,width:ar};return t.createElement("div",{...At,"data-aqvs-trailing-cell":"",key:a?a(l,ce):ce,className:Et.twMerge("aqvs-grid-cell",At?.className),style:fr},o(i(l,ce),l,ce))})})})]})},[vr,Yt,Bt,O,G,tn,f,u,a,i,o,ze]),[Ln,Dn]=t.useState(""),ir=t.useRef(null),rn=t.useRef(he);rn.current=he;const Sr=t.useCallback(()=>{const l=rn.current;if(l===void 0)return;const h=l.debounceMs??400;Number.isFinite(h)&&h>=0&&(ir.current!==null&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{ir.current=null;const R=bt();R!==null&&Dn(H=>{const ce=l.buildMessage(R);return ce===H?H:ce})},h))},[bt]),Rr=he?.debounceMs??400,nn=Number.isFinite(Rr)&&Rr>=0,sn=he!==void 0;t.useEffect(()=>{sn&&!nn&&N.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${Rr}. Announcements are disabled.`)},[sn,nn,Rr]),t.useEffect(()=>()=>{ir.current!==null&&window.clearTimeout(ir.current)},[]),t.useEffect(()=>{Sr()},[Te,Sr]);const _n=t.useCallback(l=>{Zr(l),Sr()},[Zr,Sr]);return t.useImperativeHandle(Ge,()=>({scrollTo:l=>{const h=ae.current;let R=ve.current;l.y!==void 0&&h!==null&&(h.scrollTo(l.y),R=h.getScrollPosition(),ve.current=R);let H=pe.current;return l.x!==void 0&&(Dt.current=null,H=yt.current(l.x)),{x:H,y:R}},scrollBy:l=>{const h=ae.current;let R=ve.current;l.y!==void 0&&l.y!==0&&h!==null&&(R=h.scrollBy(l.y),ve.current=R);let H=pe.current;return l.x!==void 0&&l.x!==0&&(Dt.current=null,H=yt.current(pe.current+l.x)),{x:H,y:R}},scrollToCell:(l,h,R)=>{const H=ae.current;if(H!==null&&r>0){const ce=ne(Math.trunc(l),0,r-1);ce>=Y&&ce<r-E&&H.scrollToIndex(ce-Y,{align:R?.alignY??"top",offset:R?.offsetY})}if(e>0){const ce=ne(Math.trunc(h),0,e-1);if(ce>=O&&ce<e-G){const Qe={col:ce,alignX:R?.alignX??"start",offsetX:R?.offsetX??0};Dt.current=Qe,yt.current(_t(Qe))}}},getScrollPosition:()=>Be.current||ae.current!==null?{x:pe.current,y:ae.current?.getScrollPosition()??ve.current}:{x:-1,y:-1},getScrollAnchor:()=>{if(r===0||e===0)return null;const l=ae.current?.getScrollAnchor()??null;if(l===null)return null;const h=He.current+pe.current,R=ue.findIndexAtOrAfter(h,{materializeOption:{materialize:!1}});if(R.index===-1)return{row:l.index+Y,col:e-1,offsetX:0,offsetY:l.offsetPx};if(R.cumulative===h)return{row:l.index+Y,col:ne(R.index+1,0,e-1),offsetX:0,offsetY:l.offsetPx};const H=(R.cumulative??0)-(R.currentValue??0);return{row:l.index+Y,col:R.index,offsetX:Math.max(0,h-H),offsetY:l.offsetPx}},getViewportSize:()=>({width:pt.current.width,height:pt.current.height}),getContentSize:()=>({width:rt.current,height:ae.current===null?0:A.current+it.current+Math.max(0,ae.current.getContentSize())}),getRange:bt,updateRowSize:(l,h)=>{Tr(h,"row",l),Math.trunc(l)<Y?Pt(R=>R+1):E>0&&Math.trunc(l)>=r-E?de(R=>R+1):ae.current?.updateItemSize(Math.trunc(l)-Y,h)},updateColSize:(l,h)=>{Tr(h,"col",l),lt(ue.update(ne(Math.trunc(l),0,Math.max(0,e-1)),h)),_e(R=>R+1)},getFrozenSize:()=>({cols:O,width:He.current,rows:Y,height:A.current,trailingCols:G,trailingRows:E,trailingWidth:ft.current,trailingHeight:it.current,trailingVisibleWidth:Ir(ft.current,He.current,pt.current.width),trailingVisibleHeight:Ir(it.current,A.current,pt.current.height)}),applyWheel:l=>ae.current?.applyWheel(l)??!1,focusRowAtIndex:(l,h)=>{const R=Math.trunc(l);R<Y?xe.current?.querySelector(`[data-aqvs-frozen-band-row="${R}"]`)?.focus():E>0&&R>=r-E?xe.current?.querySelector(`[data-aqvs-trailing-band-row="${R}"]`)?.focus():ae.current?.focusItemAtIndex(R-Y,h)}}),[r,e,ue,bt,lt,_t,O,Y,G,E]),z.jsxs("div",{ref:xe,className:Et.twMerge("aqvs-grid",Y>0?"aqvs-grid-has-frozen-rows":"",E>0?"aqvs-grid-has-trailing-rows":"",q),"data-testid":re,children:[Y>0?z.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:p},"data-testid":re?`${re}-frozen-rows`:void 0,children:at.map(({row:l,top:h,height:R})=>z.jsx("div",{"data-aqvs-frozen-band-row":l,className:"aqvs-grid-frozen-band-row",style:{top:h,height:R,right:we},tabIndex:-1,onFocus:()=>M?.(l),children:kr(l)},l))}):null,z.jsx("div",{className:"aqvs-grid-main","data-testid":re?`${re}-main`:void 0,children:z.jsx(Nn,{ref:ae,itemCount:Zt?0:st,getItem:l=>l+Y,getItemKey:l=>l+Y,getItemHeight:ke,overscanCount:I,viewportSize:Se.height>0?Math.max(0,Se.height-p-ee):void 0,callbackThrottleMs:L,behaviorOptions:se,scrollBarOptions:sr,contentProps:m,background:b,contentInsets:S,onItemFocus:qe,horizontalKeyInputs:me,horizontalKeyStep:Pe,initialScrollAnchor:Ye.current?Ve.current!==null&&Ve.current.row>=Y&&st>0?{index:Ve.current.row-Y,offsetPx:Ve.current.offsetPx}:void 0:P!==void 0&&st>0&&Math.trunc(P.row)>=Y&&Math.trunc(P.row)<r-E?{index:Math.trunc(P.row)-Y,offsetPx:P.offsetY}:void 0,onScroll:Vn,onRangeChange:_n,onWheelHorizontal:Qr,onPanHorizontal:Qr,locale:Ue,labels:C,testId:re?`${re}-rows`:void 0,children:kr},Y)}),E>0?z.jsx("div",{className:"aqvs-grid-trailing-rows",style:{height:Ir(ee,p,Se.height)},"data-testid":re?`${re}-trailing-rows`:void 0,children:z.jsx("div",{className:"aqvs-grid-trailing-rows-inner",style:{height:ee},children:j.map(({row:l,top:h,height:R})=>z.jsx("div",{"data-aqvs-trailing-band-row":l,className:"aqvs-grid-trailing-band-row",style:{top:h,height:R,right:we},tabIndex:-1,onFocus:()=>M?.(l),children:kr(l)},l))})}):null,z.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:we,paddingRight:G>0?we+Ir(ct,Tt,Se.width):we},"data-testid":re?`${re}-hbar`:void 0,children:z.jsx(Ur,{horizontal:!0,contentSize:Math.max(0,Oe-Tt-ct),viewportSize:Math.max(0,Se.width-Tt-ct),scrollPosition:Qt,itemCount:Math.max(0,e-O-G),tapScrollCircleOptions:Q?.tapScrollCircleOptions,onScroll:(l,h)=>(Dt.current=null,yt.current(typeof l=="function"?l(h??pe.current):l)),enableThumbDrag:Q?.enableThumbDrag,enableTrackClick:Q?.enableTrackClick,enableArrowButtons:Q?.enableArrowButtons,enableArrowButtonTabStops:Q?.enableArrowButtonTabStops,scrollBarWidth:we,locale:Ue,labels:C})}),x&&Ee&&z.jsx("div",{className:"aqvs-grid-tap-circle-wrapper","data-aqvs-grid-tap-circle":"",style:{left:`min(calc(100% - ${we+c.size}px), max(calc(100% - ${we}px + ${c.offsetX}px), calc(75% - ${c.size/2}px)))`,top:`min(calc(100% - ${we+c.size}px), max(calc(100% - ${we}px + ${c.offsetY}px), calc(75% - ${c.size/2}px)))`},children:z.jsx(jr,{axis:"xy",ref:dr,className:Et.twMerge("aqvs-grid-tap-circle",c.className),size:c.size,maxVisualDistance:B,opacity:zn,renderVisual:c.renderVisual,onDragChange:tr})}),he!==void 0?z.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":re?`${re}-live`:void 0,children:Ln}):null]})},Ns=t.forwardRef(ks);exports.FenwickMapTree=Ht;exports.MAX_FROZEN_LEADING_COLS=Hr;exports.MAX_FROZEN_LEADING_ROWS=Xr;exports.MAX_FROZEN_TRAILING_COLS=$r;exports.MAX_FROZEN_TRAILING_ROWS=qr;exports.MAX_RENDERED_CELLS=An;exports.MAX_TRACK_SIZE=cr;exports.ScrollBar=Ur;exports.ScrollPane=In;exports.TAP_SCROLL_SPEED_DEFAULTS=Wr;exports.VIRTUAL_SCROLL_LABEL_CATALOGS=xn;exports.VIRTUAL_SCROLL_LABEL_KEYS=Er;exports.VIRTUAL_SCROLL_LOCALES=Yr;exports.VirtualGrid=Ns;exports.VirtualScroll=Nn;exports.computeAutoTapScrollMaxSpeedMultiplier=Mn;exports.computeTapScrollSpeed=Cr;exports.computeTapScrollVelocity=yn;exports.createResidualQuantizer=Jn;exports.minmax=ne;exports.resolveVirtualScrollLabels=Br;exports.resolveVirtualScrollLocale=vn;exports.tapScrollCircleSampleVisual=is;exports.useFenwickMapTree=Gr;exports.useHeightCache=us;exports.useLruCache=En;exports.useWheelBridge=ds;