@aiquants/virtualscroll 3.8.0 → 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"),Et=require("tailwind-merge"),Wr=["en","ja"],kr=["scrollUp","scrollDown","scrollLeft","scrollRight","scrollToTop","scrollToBottom","noItems"],wn=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:"項目がありません"})}),_n=r=>Wr.includes(r),Fr=r=>typeof r=="string"?JSON.stringify(r):r===null?"null":typeof r,Sn=r=>{if(r===void 0)return"en";if(_n(r))return r;const e=Wr.map(n=>JSON.stringify(n)).join(", ");throw new RangeError(`[virtualscroll] locale must be one of ${e}; got ${Fr(r)}`)},On=r=>kr.includes(r),Ur=(r,e)=>{const n=wn[Sn(r)];if(e===void 0)return n;if(e===null||typeof e!="object")throw new RangeError(`[virtualscroll] labels must be an object; got ${Fr(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(!On(o))throw new RangeError(`[virtualscroll] labels.${o} is not a known label key; expected one of ${kr.join(", ")}`);const a={...n};for(const o of kr){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 ${Fr(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 Rn=r=>typeof r.setPointerCapture=="function"&&typeof r.releasePointerCapture=="function"&&typeof r.hasPointerCapture=="function",Mn=(r,e)=>Rn(r)&&r.hasPointerCapture(e),xr=(r,e)=>{if(!Rn(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"}},er=(r,e)=>{Mn(r,e)&&r.releasePointerCapture(e)},ln={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Tr=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"}})]})},Gr=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[h,x]=t.useState(ln),S=t.useRef(null),M=t.useRef(null),v=t.useRef({x:0,y:0}),I=t.useRef(null),te=t.useRef(0),q=t.useCallback(C=>{x(C),r(C)},[r]),me=t.useCallback((C,B,re=!1)=>{const{x:Ke,y:ae}=v.current,ve=C-Ke,Ct=B-ae;let le,oe;if(u==="xy")le=Math.hypot(ve,Ct),oe=le<Tr?0:1;else{const ze=u==="x"?ve:Ct;le=Math.abs(ze),oe=le<Tr?0:ze<0?-1:1}const ht=te.current;let et=oe;const st=Tr+Fn;oe===0?ht!==0&&le<st?et=ht:(et=0,re||(te.current=0)):oe!==ht&&ht!==0&&le<st?et=ht:te.current=oe,q({active:re||le>=Tr,offsetX:ve,offsetY:Ct,distance:le,direction:et,pointerId:S.current})},[q,u]),Pe=t.useCallback(C=>{if(C===null)return;const B=I.current;B!==null&&er(B,C)},[]),z=t.useCallback((C=!1)=>{C&&Pe(S.current),S.current=null,M.current=null,te.current=0,q(ln)},[q,Pe]),H=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 B=I.current??C.currentTarget,{left:re,top:Ke,width:ae,height:ve}=B.getBoundingClientRect();v.current={x:re+ae/2,y:Ke+ve/2},S.current=C.pointerId,xr(B,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 B=M.current;if(M.current=null,B!==null){Pe(C.pointerId);const re=I.current;if(re===null||xr(re,B.pointerId)!=="inactive-pointer"){S.current=B.pointerId,me(B.clientX,B.clientY,!0);return}}z(!0)},[z,Pe,me]),P=t.useCallback(C=>{C.target===C.currentTarget&&S.current===C.pointerId&&z(!1)},[z]);t.useImperativeHandle(f,()=>({reset:()=>{z(!0)},getElement:()=>I.current}),[z]);const T=Math.min(Math.max(a,0),1),Q=s/64,G=Math.min(h.distance,n)/n,Y=h.direction*G*10*Q;let se;if(u==="xy"){const C=h.distance,B=C===0?0:Y*h.offsetX/C,re=C===0?0:Y*h.offsetY/C;se=`translate(${B}px, ${re}px)`}else u==="x"?se=`translateX(${Y}px)`:se=`translateY(${Y}px)`;const J=o??Hn,he={dragState:h,normalizedDistance:G,sizeScale:Q,size:s,opacity:T},Ge={...i,width:s,height:s,transform:se};return Ge.opacity=T,V.jsx("div",{ref:I,"data-testid":"virtual-scroll-tap-circle",className:Et.twMerge("aqvs-tap-scroll-circle",e),style:Ge,tabIndex:-1,onPointerDown:H,onPointerMove:ie,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:P,role:"presentation",children:J(he)})}));Gr.displayName="TapScrollCircle";const ne=(r,e,n)=>Math.max(e,Math.min(n,r)),Hr=(r,e)=>{const n=e==="x",s=r.getBoundingClientRect(),i=n?s.width:s.height,a=x=>{const S=Number.parseFloat(x);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,h=f>0?f:n?r.offsetWidth:r.offsetHeight;return h<=0||i<=0?1:i/h},vr="virtualscroll:tap-scroll-cancel",cn=20,Xn=250,$n=60,qn=20,Yn=20,Kr={maxDistance:240,minSpeedMultiplier:.2},Bn=Kr.maxDistance,un={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Vr=2.2,jn=8,Wn=120,yn=1/10,Xt={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:Bn,minSpeedMultiplier:Kr.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"},Xr=(r,e)=>{const n=r?.maxSpeedMultiplier,s=typeof n=="number"?n:In(e);return{enabled:r?.enabled??Xt.enabled,size:r?.size??Xt.size,offsetX:r?.offsetX??Xt.offsetX,offsetY:r?.offsetY??Xt.offsetY,className:r?.className??Xt.className,maxVisualDistance:r?.maxVisualDistance??Xt.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??Xt.minSpeedMultiplier,0),opacity:ne(r?.opacity??Xt.opacity,0,1),renderVisual:r?.renderVisual??Xt.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??Xt.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)},[]),f=t.useCallback(()=>{u()},[u]),h=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)},$n)},Xn);const v=()=>u();o.current=v,window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),window.addEventListener("blur",v)},[r,u,n,s]),x=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:h,handleArrowPointerUp:f,handleArrowKeyDown:x}},Zn=700,Jt=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,Nr=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:a,curve:o})=>{const u=Math.max(Jt(r,0),0),f=Jt(e,0),h=f>0?Math.min(u,f)/f:1,x=Math.max(Jt(n,0),0),S=Math.max(Jt(s,0),0),M=Math.max(Jt(i,0),0),v=Math.max(x*S,40),I=a?v:1200,te=Math.max(x*M,I),q=o?Math.max(Jt(o.exponentialScale,M),0):0,me=o?Math.min(te,Math.max(x*q,v)):te,Pe=Math.max(me,v);let z=h**1.1;if(o){const ie=Math.min(Math.max(Jt(o.exponentialSteepness,0),0),Zn);if(ie===0)z=h;else{const L=Math.expm1(ie)||1;z=Math.min(Math.max(Math.expm1(ie*h)/L,0),1)}}const H=Math.min(Math.max(Jt(o?.easedOffset,0),0),1);return v+(Pe-v)*(H+(1-H)*z)},In=r=>{if(!r||r<=0)return Vr;const e=Math.max(1,r),n=Math.log10(e),s=Vr+n*jn;return ne(s,Vr,Wn)},Zr=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:a=!0,enableArrowButtons:o=!0,enableArrowButtonTabStops:u=!0,horizontal:f=!1,enableHorizontalTapCircle:h=!1,stretchMainSize:x=!1,scrollBarWidth:S=12,className:M,ariaControls:v,tapScrollCircleOptions:I,itemCount:te,renderThumbOverlay:q,visibleStartIndex:me,visibleEndIndex:Pe,locale:z,labels:H})=>{const[ie,L]=t.useState(!1),[P,T]=t.useState(!1),[Q,G]=t.useState(!1),Y=t.useRef(null),se=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),J=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),he=t.useRef(n),Ge=t.useRef(s),C=t.useRef(un),B=t.useRef(null),re=t.useRef(null),Ke=t.useRef(null),ae=t.useRef(0),ve=t.useRef(0),Ct=t.useMemo(()=>Xr(I,te),[te,I]),le=t.useMemo(()=>Un(f),[f]),oe=t.useMemo(()=>Ur(z,H),[z,H]),ht=f?[oe.scrollLeft,oe.scrollRight]:[oe.scrollUp,oe.scrollDown],{enabled:et,size:st,offsetX:ze,offsetY:tt,className:Ze,maxVisualDistance:Qe,maxSpeedMultiplier:ue,minSpeedMultiplier:Te,opacity:_e,renderVisual:O,maxSpeedCurve:Fe}=Ct,K=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(Qe,1),tapCircleMaxSpeedMultiplier:ue,tapCircleMinSpeedMultiplier:Te,tapCircleMaxSpeedCurve:Fe,tapScrollCircleOptions:I,effectiveTrackLength:0,onScroll:s,scrollPosition:n}),{mainSizeKey:dt,crossSizeKey:j,positionKey:E,selectDelta:it,getPointerCoordinate:ye,arrowIcons:A,directionClass:at,orientation:xt}=le,Pt=Math.max(Qe,1),ot=e/r,g=Math.max(e-S*2,0),_=ot*g,de=Math.min(Math.max(cn,_||0),g||cn),U=Math.max(r-e,0),ee=Math.max(g-de,0),ke=U<=0||ee<=0?0:ne(n/U*ee,0,ee),He=ke+de/2,be=r>e||ie,Ye=be&&o;t.useLayoutEffect(()=>{K.current={viewportSize:e,maxScrollPosition:U,scrollBarVisible:be,effectiveTapMaxDistance:Pt,tapCircleMaxSpeedMultiplier:ue,tapCircleMinSpeedMultiplier:Te,tapCircleMaxSpeedCurve:Fe,tapScrollCircleOptions:I,effectiveTrackLength:ee,onScroll:s,scrollPosition:n}}),t.useLayoutEffect(()=>{he.current=n},[n]),t.useLayoutEffect(()=>{Ge.current=s},[s]),t.useEffect(()=>{i||T(!1)},[i]);const xe=Gn({isDragging:ie,isThumbHovered:P,enableThumbDrag:i}),Ne=t.useCallback((d,k)=>{const D=K.current,fe=k??he.current;if(Ge.current){const We=Ge.current(d,fe);if(typeof We=="number"&&Number.isFinite(We))return he.current=We,We}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},[]),lt=t.useCallback(d=>{const k=K.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,We=d>0&&D+d>=k.maxScrollPosition,zt=d<0&&(Le<=0||vt&&De===0)||d>0&&(Le>=k.maxScrollPosition||We&&De===0);return{nextPosition:Le,actualDelta:De,reachedBoundary:zt}},[Ne]),rt=t.useCallback((d,k)=>{d.current+=k;const D=Math.max(K.current.maxScrollPosition,0);D>0&&(d.current=ne(d.current,-D,D));const fe=lt(d.current);return d.current-=fe.actualDelta,fe.reachedBoundary&&(d.current=0),fe},[lt]),Ve=t.useCallback(()=>{re.current!==null&&(window.cancelAnimationFrame(re.current),re.current=null),Ke.current=null,ae.current=0,ve.current=0},[]),Be=t.useCallback(()=>{C.current={...un},G(!1),B.current?.reset(),Ve()},[Ve]),pe=t.useCallback(d=>{const k=C.current,D=K.current;if(!k.active||k.direction===0){Ve();return}if(!D.scrollBarVisible||D.maxScrollPosition<=0){Ve();return}const fe=Ke.current??d,Le=Math.max((d-fe)/1e3,0),De=Math.min(Le,yn);if(Ke.current=d,De<=0){re.current=window.requestAnimationFrame(pe);return}const vt=Nr({distance:k.distance,maxDistance:D.effectiveTapMaxDistance,viewportSize:D.viewportSize,minSpeedMultiplier:D.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:D.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof D.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:D.tapCircleMaxSpeedCurve});ve.current!==k.direction&&(ve.current=k.direction,ae.current=0);const{reachedBoundary:We}=rt(ae,k.direction*vt*De);if(We){Ve();return}re.current=window.requestAnimationFrame(pe)},[rt,Ve]),we=t.useCallback(()=>{re.current===null&&(Ke.current=null,ae.current=0,re.current=window.requestAnimationFrame(pe))},[pe]);t.useEffect(()=>{const d=C.current;!d.active||d.direction===0||we()},[r,e,we]),t.useEffect(()=>()=>{Ve()},[Ve]);const je=t.useCallback(d=>{C.current=d,G(d.active),d.active&&d.direction!==0?we():Ve()},[we,Ve]);t.useEffect(()=>{et||Be()},[Be,et]),t.useEffect(()=>{const d=k=>{const fe=k.detail?.paneId;fe&&v&&fe!==v||Be()};return window.addEventListener(vr,d),()=>{window.removeEventListener(vr,d)}},[v,Be]),t.useEffect(()=>{if(!et)return;const d=k=>{if(!C.current.active||C.current.pointerId===k.pointerId)return;const D=k.target;if(!(D instanceof Node)){Be();return}B.current?.getElement()?.contains(D)||Be()};return document.addEventListener("pointerdown",d,!0),()=>{document.removeEventListener("pointerdown",d,!0)}},[Be,et]);const Ie=d=>{if(!be||ee<=0||U<=0)return 0;const k=ne(d,0,ee);return ne(k/ee*U,0,U)},w=t.useCallback(d=>{const{scrollBarVisible:k,effectiveTrackLength:D,maxScrollPosition:fe}=K.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=>Hr(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=it(D,fe)/(k.scale||1);N.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:Le,startThumbPosition:k.startThumbPosition,clientY:d.clientY,startClientY:k.startClientY,metrics:K.current}));const De=w(k.startThumbPosition+Le);De!==null&&Ne(De),d.cancelable&&d.preventDefault()},[it,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&&er(k.captureTarget,d.pointerId),se.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},L(!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)},[Ce]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",Ce),document.removeEventListener("pointerup",Oe),document.removeEventListener("pointercancel",Oe)},[Ce,Oe]);const Xe=t.useRef(0),nt=t.useRef(0),ct=t.useCallback(d=>{const k=Math.max(Math.round(K.current.viewportSize/Yn),qn);nt.current!==d&&(nt.current=d,Xe.current=0),rt(Xe,d*k)},[rt]),{handleArrowPointerDown:Se,handleArrowPointerUp:Mt,handleArrowKeyDown:Gt}=Kn({canUseArrowButtons:Ye,enableArrowButtons:o,resetTapScroll:Be,scrollByStep:ct}),ir=d=>{if(!be)return;if(!i){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;Be();const k=d.currentTarget,D=y(k),fe=xr(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),T(!0),d.preventDefault(),d.stopPropagation()},Re=d=>{if(!be)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;Be();const vt=De-de/2,We=Ie(vt);Ne(We),xr(k,d.pointerId),J.current={pointerId:d.pointerId,startThumbPosition:vt,startClientX:d.clientX,startClientY:d.clientY,scale:Le},d.preventDefault(),d.stopPropagation()},pt=()=>{J.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},tr=d=>{const k=J.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=it(D,fe)/(k.scale||1),De=Ie(k.startThumbPosition+Le);Ne(De),d.cancelable&&d.preventDefault()},Kt=d=>{J.current.pointerId===d.pointerId&&(er(d.currentTarget,d.pointerId),pt(),d.preventDefault(),d.stopPropagation())},qt=d=>{J.current.pointerId===d.pointerId&&(er(d.currentTarget,d.pointerId),pt())},Me=d=>{d.target===d.currentTarget&&J.current.pointerId===d.pointerId&&pt()},yt=t.useMemo(()=>ne((Q?1:.8)*_e,0,1),[Q,_e]),Yt=t.useMemo(()=>{const k=`calc(50% - ${st/2}px + ${tt}px)`;return{left:ze,top:k}},[ze,tt,st]),rr=(d,k,D,fe)=>V.jsx("button",{type:"button",tabIndex:u?0:-1,className:"aqvs-scrollbar-arrow-button",style:{[dt]:S,[j]:S},"aria-label":k,onPointerDown:Se(d),onPointerUp:Mt,onPointerLeave:Mt,onPointerCancel:Mt,onKeyDown:Gt(d),"aria-disabled":!o,disabled:!Ye,children:V.jsx("span",{"aria-hidden":"true",children:D})},fe),gt=q&&be?{orientation:xt,scrollPosition:n,maxScrollPosition:U,contentSize:r,viewportSize:e,thumbSize:de,thumbPosition:ke,thumbCenter:He,trackSize:g,isDragging:ie,isTapScrollActive:Q,visibleStartIndex:me,visibleEndIndex:Pe}:null;return V.jsxs("div",{className:Et.twMerge("aqvs-scrollbar",at,M),style:{...x&&!f?{}:{[dt]:e},[j]:S},"data-visible":be?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":v,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":U,"aria-orientation":f?"horizontal":"vertical",children:[(!f||h)&&be&&et&&V.jsx(Gr,{axis:f?"x":"y",ref:B,className:Et.twMerge("aqvs-scrollbar-tap-circle-wrapper",Ze),size:st,maxVisualDistance:Pt,style:Yt,opacity:yt,renderVisual:O,onDragChange:je},"tap-circle"),rr(-1,ht[0],A[0],"arrow-start"),V.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:S/2},onPointerDown:Re,onPointerMove:tr,onPointerUp:Kt,onPointerCancel:qt,onLostPointerCapture:Me,"aria-disabled":!a,children:[gt&&V.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:q?.(gt)},"overlay"),V.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[dt]:de,[E]:ke,...f?{top:0,bottom:0}:{left:0,right:0}},"data-visible":be||ie?"true":"false",onPointerDown:ir,role:"slider","aria-orientation":f?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":U,"aria-disabled":!i,tabIndex:-1,children:V.jsx("div",{ref:Y,className:Et.twMerge("aqvs-scrollbar-thumb",f?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":xe,style:{borderRadius:S-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&T(!0)},onMouseLeave:()=>{i&&T(!1)}},"thumb")},"thumb-wrapper")]},"track"),rr(1,ht[1],A[1],"arrow-end")]})},Tn=({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=Nr({distance:u,maxDistance:n,viewportSize:s.viewportSize,minSpeedMultiplier:s.minSpeedMultiplier,maxSpeedMultiplier:s.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:s.hasCustomMaxSpeedMultiplier,curve:s.curve}),h=Nr({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:h*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,dn=(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:dn(s,r.deltaMode,e),verticalDelta:dn(i,r.deltaMode,e)}},En=new WeakSet,fn=r=>{En.add(r)},ts=r=>En.has(r),rs=["mouse","pen","touch"],Lr=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),ns=r=>r==="mouse"||r==="pen",gr={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},Er=(r,e,n)=>{for(const[s,i,a]of e)n==="add"?r.addEventListener(s,i,a):r.removeEventListener(s,i,a)},Cn=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:h=!0,pointerDragInputs:x=rs,onScroll:S,className:M,testId:v,style:I,background:te,tapScrollCircleOptions:q,inertiaOptions:me,itemCount:Pe,renderThumbOverlay:z,wheelSpeedMultiplier:H=1,overscrollBehavior:ie="auto",onWheelHorizontal:L,onPanHorizontal:P,contentInsets:T,visibleStartIndex:Q,visibleEndIndex:G,renderOverlay:Y,initialScrollPosition:se=0,contentProps:J,locale:he,labels:Ge},C)=>{const B=t.useRef(Number.isFinite(se)?Math.max(0,se):0),re=t.useRef(null),Ke=t.useRef(null),ae=n===void 0,[ve,Ct]=t.useState(0),le=n??ve,oe=t.useRef(null);t.useLayoutEffect(()=>{if(!ae)return;const g=Ke.current;if(!g)return;const _=()=>{const U=g.offsetHeight;if(U>0){Ct(ee=>ee===U?ee:U);return}g.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(g),()=>{de.disconnect()}},[e,ae]),t.useLayoutEffect(()=>{ae&&s?.(ve)},[ae,ve,s]),t.useLayoutEffect(()=>{if(ae)return;const g=re.current;if(!g)return;const _=()=>{const U=g.clientHeight;if(U<=0||Math.abs(U-le)<=1)return;const ee=`${le}/${U}`;oe.current!==ee&&(oe.current=ee,N.warn(`[ScrollPane] viewportSize=${le} but the host band is ${U}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(g),()=>{de.disconnect()}},[ae,le]);const ht=t.useRef(L);t.useEffect(()=>{ht.current=L},[L]);const et=t.useRef(P);t.useEffect(()=>{et.current=P},[P]);const st=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),ze=t.useMemo(()=>({maxVelocity:me?.maxVelocity??gr.maxVelocity,minVelocity:me?.minVelocity??gr.minVelocity,deceleration:me?.deceleration??gr.deceleration,velocitySampleWindow:me?.velocitySampleWindow??gr.velocitySampleWindow,startVelocityThreshold:me?.startVelocityThreshold??gr.startVelocityThreshold}),[me]),tt=t.useMemo(()=>({top:Math.max(0,T?.top??0),bottom:Math.max(0,T?.bottom??0)}),[T]);N.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:le,scrollBarWidth:i,className:M,style:I,tapScrollCircleOptions:q,inertiaOptions:me,enablePointerDrag:h,contentInsets:tt}));const Ze=t.useRef({contentSize:e,viewportSize:le}),Qe=t.useMemo(()=>e>le,[e,le]),ue=t.useCallback((g,_)=>{let de=_??Ze.current;_&&!(Number.isFinite(_.contentSize)&&Number.isFinite(_.viewportSize))&&(N.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:_}),de=Ze.current);const{contentSize:U,viewportSize:ee}=de,ke=U>ee,He=B.current;if(N.debug("[ScrollPane] scrollTo called",()=>({newPosition:g,contentSize:U,viewportSize:ee,currentIsScrollable:ke,prevPosition:He})),!ke)return B.current!==0&&(B.current=0,S?.(0,He)),B.current;const be=typeof g=="function"?g(B.current):g;if(!Number.isFinite(be))return N.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:be}),B.current;const Ye=Math.max(U-ee,0),xe=ne(be,0,Ye);return B.current!==xe&&(B.current=xe,S?.(xe,He)),B.current},[S]),Te=t.useRef(ue);t.useEffect(()=>{Te.current=ue},[ue]);const _e=t.useCallback(()=>{const g=st.current;g.generation+=1,g.frame!==null&&cancelAnimationFrame(g.frame),g.frame=null,g.velocity=0,g.lastTimestamp=null},[]),O=t.useRef(_e);t.useEffect(()=>{O.current=_e},[_e]),t.useEffect(()=>()=>{O.current()},[]);const Fe=t.useCallback(g=>{if(!Qe)return;const{maxVelocity:_,minVelocity:de,deceleration:U,startVelocityThreshold:ee}=ze,ke=ne(g,-_,_);if(Math.abs(ke)<ee)return;_e(),st.current.velocity=ke,st.current.lastTimestamp=null;const He=st.current.generation,be=Ye=>{const xe=st.current;if(xe.generation!==He)return;if(xe.lastTimestamp===null){xe.lastTimestamp=Ye,xe.frame=requestAnimationFrame(be);return}const Ne=Ye-xe.lastTimestamp;if(xe.lastTimestamp=Ye,Ne<=0){xe.frame=requestAnimationFrame(be);return}const lt=xe.velocity;let rt=lt;const Ve=U*Ne;lt>0?rt=Math.max(0,lt-Ve):lt<0&&(rt=Math.min(0,lt+Ve));const pe=(lt+rt)/2*Ne,we=B.current;if(pe!==0&&Te.current(Oe=>Oe+pe),st.current.generation!==He)return;const je=B.current,{contentSize:Ie,viewportSize:w}=Ze.current,y=Math.max(Ie-w,0);xe.velocity=rt;const Ce=je===we||je<=0&&rt<=0||je>=y&&rt>=0;if(Math.abs(rt)<de||Ce){_e();return}xe.frame=requestAnimationFrame(be)};st.current.frame=requestAnimationFrame(be)},[Qe,ze,_e]),K=t.useRef(Fe);t.useEffect(()=>{K.current=Fe},[Fe]),t.useLayoutEffect(()=>{Ze.current={contentSize:e,viewportSize:le}},[e,le]),t.useLayoutEffect(()=>{const g=Ke.current;if(!g)return;const _=()=>{g.scrollTop!==0&&(N.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:g.scrollTop})),g.scrollTop=0),g.scrollLeft!==0&&(g.scrollLeft=0)};return g.addEventListener("scroll",_),()=>g.removeEventListener("scroll",_)},[]),t.useLayoutEffect(()=>{if(Qe){N.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:le,scrollPosition:B.current}));const g=ne(e-le,0,e);B.current>g&&ue(g)}else ue(0)},[Qe,ue,e,le]);const dt=t.useRef({isScrollable:Qe,viewportSize:le,wheelSpeedMultiplier:H,overscrollBehavior:ie});t.useLayoutEffect(()=>{dt.current={isScrollable:Qe,viewportSize:le,wheelSpeedMultiplier:H,overscrollBehavior:ie}},[Qe,le,H,ie]);const j=t.useCallback(g=>{if(ts(g))return!1;const{isScrollable:_,viewportSize:de,wheelSpeedMultiplier:U,overscrollBehavior:ee}=dt.current,ke=es(g,de);if(ke.isZoomGesture)return!1;if(ke.isHorizontalDominant)return ht.current?(fn(g),g.preventDefault(),_e(),ht.current(ke.horizontalDelta),!0):!1;if(!_||ke.verticalDelta===0)return!1;let He=ke.verticalDelta;if(U!==1&&(He*=U),ee!=="contain"){const be=B.current,Ye=Math.max(Ze.current.contentSize-de,0);if(He>0&&be>=Ye||He<0&&be<=0)return!1}return fn(g),g.preventDefault(),_e(),N.debug("[ScrollPane] wheel event",()=>({deltaY:He,scrollPosition:B.current,wheelSpeedMultiplier:U,deltaMode:g.deltaMode,scrollTop:Ke.current?.scrollTop})),ue(be=>be+He),!0},[ue,_e]);t.useEffect(()=>{const g=U=>{j(U)},_=()=>{_e()},de=re.current;return de&&(de.addEventListener("wheel",g,{passive:!1}),de.addEventListener("pointerdown",_,{capture:!0,passive:!0})),()=>{de&&(de.removeEventListener("wheel",g),de.removeEventListener("pointerdown",_,{capture:!0}))}},[j,_e]),t.useImperativeHandle(C,()=>({scrollTo:(g,_)=>(_e(),ue(g,_)),getScrollPosition:()=>B.current,getContentSize:()=>e,getViewportSize:()=>le,applyWheel:j}),[ue,e,le,_e,j]);const E=t.useId(),it=J?.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(h),at=t.useRef(x);t.useEffect(()=>{A.current=h},[h]),t.useEffect(()=>{at.current=x},[x]);const xt=t.useRef(Qe);t.useEffect(()=>{xt.current=Qe},[Qe]);const Pt=t.useRef(ze);t.useEffect(()=>{Pt.current=ze},[ze]),t.useEffect(()=>{const g=ye.current;if(h&&Qe&&(g.pointerId===null||Lr(g.pointerType,x))||g.pointerId===null)return;const _=Ke.current;g.clickResetTimer!==null&&(window.clearTimeout(g.clickResetTimer),g.clickResetTimer=null);const de=g.isDragging&&g.shouldCancelNextClick,U=g.pointerId;g.pointerId=null,g.pointerType="",g.startClientY=0,g.startScroll=0,g.isDragging=!1,g.shouldCancelNextClick=de,g.velocitySamples=[],g.scale=1,_!==null&&er(_,U)},[h,x,Qe]),t.useEffect(()=>{const g=Ke.current;if(!g)return;const _=6,de=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),U=()=>{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(Xe=>Ce-Xe.time<=Oe)},He=w=>w instanceof HTMLElement&&w.closest("[data-scrollpane-ignore-drag='true']")!==null,be=w=>{const y=ye.current;y.shouldCancelNextClick&&(w.preventDefault(),w.stopPropagation(),y.shouldCancelNextClick=!1)},Ye=w=>{const y=ye.current;y.isDragging||(y.isDragging=!0,y.shouldCancelNextClick=!0,Mn(g,w.pointerId)||xr(g,w.pointerId),ke(w.clientY))},xe=w=>w.isTrusted||w.target===g,Ne=w=>{const y=ye.current;er(g,w),y.shouldCancelNextClick=!1,ee(),U()},lt=w=>{const y=ye.current;if(y.pointerId!==w.pointerId)return;if(w.buttons===0&&ns(w.pointerType)){Ne(w.pointerId);return}if(!(A.current&&xt.current)||!Lr(w.pointerType,at.current))return;if(!y.isDragging){const nt=Math.abs(w.clientY-y.startClientY),ct=et.current?Math.abs(w.clientX-y.startClientX):0;if(Math.max(nt,ct)<_||(Ye(w),!y.isDragging))return}ke(w.clientY);const Ce=(w.clientY-y.startClientY)/(y.scale||1),Oe=y.startScroll-Ce;Te.current(Oe);const Xe=et.current;if(Xe){const nt=w.clientX-y.lastPanClientX;y.lastPanClientX=w.clientX,nt!==0&&Xe(-nt/(y.scaleX||1))}w.cancelable&&w.preventDefault()},rt=()=>{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){rt();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 Xe=y.velocitySamples,nt=Pt.current.velocitySampleWindow,ct=Xe[Xe.length-1],Se=Xe.find(Mt=>ct.time-Mt.time<=nt)??Xe[0];if(ct&&Se&&ct.time!==Se.time){const Mt=ct.clientY-Se.clientY,Gt=ct.time-Se.time;Ce=-(Mt/Gt)/(y.scale||1)}}ee(),y.shouldCancelNextClick&&(y.clickResetTimer=window.setTimeout(()=>{const Xe=ye.current;Xe.shouldCancelNextClick=!1,Xe.clickResetTimer=null},0));const Oe=Pt.current.startVelocityThreshold;U(),er(g,w.pointerId),Math.abs(Ce)>=Oe&&K.current?.(Ce)},Be=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)||!Lr(w.pointerType,at.current)||w.button!==0&&w.pointerType==="mouse"||w.ctrlKey||w.metaKey||w.altKey||He(w.target))return;window.dispatchEvent(new CustomEvent(vr,{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=B.current,y.scale=Hr(g,"y"),y.scaleX=et.current?Hr(g,"x"):1,y.isDragging=!1,y.shouldCancelNextClick=!1,y.velocitySamples=[]},pe=w=>{if(ye.current.pointerId!==w.pointerId){rt();return}xe(w)&&Ne(w.pointerId)},je=[["click",be,!0],["pointerdown",Be,{passive:!1}],["lostpointercapture",w=>{w.target!==g||ye.current.pointerId!==w.pointerId||Ne(w.pointerId)},void 0]],Ie=[["pointermove",lt,{passive:!1}],["pointerup",Ve,void 0],["pointercancel",pe,void 0]];return Er(g,je,"add"),Er(window,Ie,"add"),()=>{Er(g,je,"remove"),Er(window,Ie,"remove");const w=ye.current;w.pointerId!==null&&er(g,w.pointerId),ee(),U()}},[E]);const ot=t.useCallback(g=>(_e(),ue(g)),[ue,_e]);return V.jsxs("div",{ref:re,"data-testid":v,"data-self-measured":ae?"true":void 0,className:Et.twMerge("aqvs-scroll-pane",M),style:I,children:[V.jsxs("div",{ref:Ke,className:Et.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:ae?void 0:le,paddingTop:tt.top,paddingBottom:tt.bottom,...h&&Qe&&x.some(g=>g==="touch"||g==="pen")?{touchAction:"none"}:{}},...J,id:it,children:[te,r(B.current)]}),V.jsx(Zr,{contentSize:e,viewportSize:le,stretchMainSize:ae,scrollPosition:B.current,onScroll:ot,enableThumbDrag:a,enableTrackClick:o,enableArrowButtons:u,enableArrowButtonTabStops:f,scrollBarWidth:i,ariaControls:it,tapScrollCircleOptions:q,itemCount:Pe,renderThumbOverlay:z,visibleStartIndex:Q,visibleEndIndex:G,locale:he,labels:Ge},"scrollbar"),Y?.()]})}),mn=(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,f=.8+e*.18,h=3*n,x=6*n,S=22*n,M=Math.abs(u)+x,v=u>0?h:-Math.abs(u)-h,I=Math.max(2.5,3*n),te=mn(r.offsetX,-i,i),q=mn(r.offsetY,-i,i),me=i*.35,Pe=te/i*me,z=q/i*me,H=Pe*.45,ie=z*.45,L=Math.max(S*.38,6),P=.65+e*.2,T=r.active;return V.jsxs(V.Fragment,{children:[V.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${o}, ${a})`,transition:T?"40ms transform ease-out":"200ms ease transform"}}),V.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:S,height:S,transform:`translate(calc(-50% + ${Pe}px), calc(-50% + ${z}px)) scale(${o}, ${f*a})`,transition:T?"70ms transform ease-out":"200ms ease transform"}}),V.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:L,height:L,transform:`translate(calc(-50% + ${H}px), calc(-50% + ${ie}px)) scale(${o}, ${a})`,opacity:P,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:T?"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:I,height:M,transform:`translate(-50%, ${v}px)`,opacity:e,transition:T?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},lr=100,is=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},Dr=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},cr=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 f=s?.sampleRange??{from:0,to:Math.min(lr-1,i-1)};let h=Math.max(0,Math.trunc(f.from)),x=Math.min(Math.trunc(f.to),i-1);h>x&&(h=0,x=Math.min(lr-1,i-1)),o={from:h,values:$t._collectValidatedValues(n,h,x)}}}else if(i>0){const f=s?.sampleRange??{from:0,to:Math.min(lr-1,i-1)};let h=Math.max(0,Math.trunc(f.from)),x=Math.min(Math.trunc(f.to),i-1);if(h>x&&(h=0,x=Math.min(lr-1,i-1)),i>lr)a=$t._sampleBaseValueStrided(n,i,lr),s?.materialize&&(o={from:h,values:$t._collectValidatedValues(n,h,x)});else{const S=$t._collectValidatedValues(n,h,x);a=$t._modeOrMedian([...S]),s?.materialize&&(o={from:h,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 h=o.from+f;if(h>=this.size)break;const x=o.values[f]-this.baseValue;x!==0&&(this.deltas.set(h,x),this._updateTree(h,x))}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(Dr(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,h]of i.entries())h===a&&o.push(f);const u=o.reduce((f,h)=>f+h,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(Dr(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=cr(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=cr(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=Dr(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)),h=Math.min(Math.trunc(u.to),this.size-1);for(let x=f;x<=h;x++)this._materialize(x)}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=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,f,h,x=this.total;for(;o<=u;){const v=o+u>>1n,I=Number(v),te=this.prefixSum(I);if(x=te.total,s?te.cumulative>=e:te.cumulative<=e)if(f=v,h=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=h,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:x,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 h=cr(o);if(h===0)break;o-=h}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=cr(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=cr(a);if(o===0)break;a+=o}for(;a<=i;){this.tree.set(a,(this.tree.get(a)??0)+n);const o=cr(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},Qr=(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,f=u.size!==s,h=u.valueOrFn!==e,x=as(u.options,n)||u.options?.baseValue!==n?.baseValue,S=u.size===0&&s>0&&(!i.current||i.current.base===0);if(h||x){const M=n?.resetOnValueFnChange??!0;x||h&&M||S?(n?.debug&&N.debug("[useFenwickMapTree] reset",{valueOrFnChanged:h,optionsChanged:x}),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:h}),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 os{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class _r{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 Pn(r){const e=t.useRef(new Map),n=t.useRef(new _r),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 _r;return}if(Number.isFinite(s))for(;e.current.size>s;){const x=n.current.removeHead();if(x)e.current.delete(x.key);else break}},[r,s]);const a=t.useCallback(x=>{const S=e.current.get(x);if(S)return n.current.moveToTail(S),S.value},[]),o=t.useCallback((x,S)=>{const M=i.current;if(Number.isNaN(M)||M<=0)return;let v=e.current.get(x);if(v)v.value=S,n.current.moveToTail(v);else{if(e.current.size>=M){const I=n.current.removeHead();I&&e.current.delete(I.key)}v=new os(x,S),e.current.set(x,v),n.current.addToTail(v)}},[]),u=t.useCallback(x=>e.current.has(x),[]),f=t.useCallback(x=>{const S=e.current.get(x);S&&(n.current.remove(S),e.current.delete(x))},[]),h=t.useCallback(()=>{e.current.clear(),n.current=new _r},[]);return t.useMemo(()=>({get:a,set:o,has:u,remove:f,clear:h}),[a,o,u,f,h])}const ls=1e4,cs=()=>{const{get:r,set:e,has:n,clear:s}=Pn(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))}},[])},hn=-200,pn={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(pn),s=t.useRef(null),[i,a]=t.useState(!1),o=t.useRef(null),u=t.useRef(null),f=t.useRef({residual:0,direction:0}),h=t.useRef({residual:0,direction:0}),x=t.useCallback(()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null),u.current=null,f.current={residual:0,direction:0},h.current={residual:0,direction:0}},[]),S=t.useCallback((z,H,ie,L,P,T)=>{const Q=H>0?1:H<0?-1:0;Q!==0&&Q!==z.direction&&(z.direction=Q,z.residual=0),z.residual+=H*ie;const G=Math.max(P(),0);G>0&&(z.residual=ne(z.residual,-G,G));const Y=z.residual;if(Y===0)return{actualDelta:0,atBoundary:!1};const se=L(),J=T(Y),he=J-se;z.residual-=he;const Ge=Y<0&&se+Y<=0,C=Y>0&&se+Y>=G,B=Y<0&&(J<=0||Ge&&he===0)||Y>0&&(J>=G||C&&he===0);return B&&(z.residual=0),{actualDelta:he,atBoundary:B}},[]),M=t.useCallback(z=>{const H=e.current,ie=n.current;if(!ie.active||ie.direction===0){x();return}const L=u.current??z,P=Math.max((z-L)/1e3,0),T=Math.min(P,yn);if(u.current=z,T<=0){o.current=window.requestAnimationFrame(M);return}const Q=Tn({offsetX:ie.offsetX,offsetY:ie.offsetY,maxDistance:H.maxDistance,x:H.xSpeedParams,y:H.ySpeedParams}),G=S(f.current,Q.x,T,H.getHx,H.getMaxHx,he=>H.applyHxRef.current(H.getHx()+he));G.actualDelta!==0&&(H.pendingColAnchorRef.current=null);const Y=S(h.current,Q.y,T,H.getVy,H.getMaxVy,H.applyVy),se=H.getMaxHx()<=0||G.atBoundary||ie.offsetX===0,J=H.getMaxVy()<=0||Y.atBoundary||ie.offsetY===0;if(se&&J){x();return}o.current=window.requestAnimationFrame(M)},[x,S]),v=t.useCallback(()=>{o.current===null&&(u.current=null,f.current={residual:0,direction:0},h.current={residual:0,direction:0},o.current=window.requestAnimationFrame(M))},[M]),I=t.useCallback(()=>{n.current={...pn},a(!1),s.current?.reset(),x()},[x]),te=t.useCallback(z=>{n.current=z,a(z.active),z.active&&z.direction!==0?v():x()},[v,x]),{enabled:q,xExtentFreshness:me,yExtentFreshness:Pe}=r;return t.useEffect(()=>{const z=n.current;!z.active||z.direction===0||v()},[me,Pe,v]),t.useEffect(()=>{const z=()=>{I()};return window.addEventListener(vr,z),()=>{window.removeEventListener(vr,z)}},[I]),t.useEffect(()=>{if(!q)return;const z=H=>{if(!n.current.active||n.current.pointerId===H.pointerId)return;const ie=H.target;if(!(ie instanceof Node)){I();return}s.current?.getElement()?.contains(ie)||I()};return document.addEventListener("pointerdown",z,!0),()=>{document.removeEventListener("pointerdown",z,!0)}},[q,I]),t.useEffect(()=>{q||I()},[q,I]),t.useEffect(()=>()=>{x()},[x]),{isTapActive:i,handleTapCircleDragChange:te,tapCircleHandleRef:s}},Ue=(r,e)=>e<=0?0:ne(r,0,e-1),gn=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),Rt=(r,e)=>r<=e?0:r-e,sr=(r,e)=>r<=0?0:r+e,wr=1e3,$r=2e3,kn=1048576,fs=(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},ms=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},hs=40,br=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},ps=(r,e,n,s,i,a,o,u)=>{const f=br(s);if(f===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const h=L=>L<0n?0n:L>=f?f-1n:L,x={materializeOption:{materialize:!1}},{index:S,cumulative:M}=a.findIndexAtOrAfter(r,x);let v;S===-1?v=f-1n:(M===r?v=br(S+1):v=br(S),v>=f&&(v=f-1n)),r<=0&&(v=0n),u&&r>=o&&(v=f-1n);const I=L=>{const P=Number(L);if(!Number.isSafeInteger(P))return null;const{cumulative:T}=a.prefixSum(P,{materializeOption:{materialize:!1}});if(!Number.isFinite(T))return null;const{index:Q}=a.findIndexAtOrAfter(T+.5,{materializeOption:{materialize:!1}});if(Q===-1)return null;const G=br(Q);return G>L?G:null},te=L=>{let P=0,T=L,Q=L,G=0n,Y=0;for(;T<f&&P<e;){const se=Number(T),J=i(se);if(P+=J,Q=T,T+=1n,G+=1n,!Number.isFinite(J)||J<0)break;if(J===0){if(Y+=1,Y>wr){const he=I(Q);if(he!==null&&he>T)T=he,Y=0;else if(he!==null&&he===T&&i(Number(T))>0)Y=0;else break}}else Y=0}return G===0n&&(Q=L),{height:P,end:Q}};let{height:q,end:me}=te(v);if(q<e&&v>0n){let L=v,P=q,T=0;for(;L>0n&&P<e;){L-=1n;const G=Number(L),Y=i(G);if(P+=Y,!Number.isFinite(Y)||Y<0)break;if(Y===0){if(T+=1,T>wr){const se=Number(L);if(!Number.isSafeInteger(se))break;const{cumulative:J}=a.prefixSum(se,{materializeOption:{materialize:!1}});if(!Number.isFinite(J))break;const{index:he}=a.findIndexAtOrAfter(J-.5,{materializeOption:{materialize:!1}}),Ge=he===-1?-1n:br(he);if(Ge>=0n&&Ge<L)L=Ge+1n,T=0;else if(Ge===L&&L>=1n&&i(Number(L-1n))>0)T=0;else break}}else T=0}v=h(L);const Q=te(v);q=Q.height,me=Q.end}const Pe=h(v),z=h(me),H=h(Pe-BigInt(Math.max(0,n))),ie=h(z+BigInt(Math.max(0,n)));return{renderingStartIndex:Ue(Number(H),s),renderingEndIndex:Ue(Number(ie),s),visibleStartIndex:Ue(Number(Pe),s),visibleEndIndex:Ue(Number(z),s)}},Nn=(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 ps(f,e,n,s,i,a,o,u);const{index:h,cumulative:x,currentValue:S}=a.findIndexAtOrAfter(f,{materializeOption:{materialize:!1}}),M=h===-1?e<=0||(x??0)<f+(S??0)?s-1:0:h;let v=Ue(M,s),I=0;if(h!==-1&&x===f)v=Ue(h+1,s),I=0;else if(v===h&&x!==void 0&&S!==void 0)I=x-S-f;else{const{cumulative:L,currentValue:P}=a.prefixSum(v,{materializeOption:{materialize:!1}});I=(L??0)-(P??0)-f}const te=I,q=(L,P)=>{let T=L,Q=P,G=0;for(;T<s&&Q<e;){const Y=i(T);if(Q+=Y,T++,!Number.isFinite(Y)||Y<0)break;if(Y===0){if(G++,G>wr){const{cumulative:se}=a.prefixSum(T-1,{materializeOption:{materialize:!1}}),{index:J}=Number.isFinite(se)?a.findIndexAtOrAfter(se+.5,{materializeOption:{materialize:!1}}):{index:-1};if(J>T)T=J,G=0;else if(J===T&&i(T)>0)G=0;else break}}else G=0}return{cursor:T,height:Q}},me=q(v,I);let Pe=me.cursor;if(I=me.height,I<e&&v>0){let L=I+Math.abs(Math.min(0,te)),P=v-1,T=0;for(;P>=0&&L<e;){const G=i(P);if(L+=G,!Number.isFinite(G)||G<0){P--;break}if(G===0){if(T++,T>wr){const{cumulative:Y}=a.prefixSum(P,{materializeOption:{materialize:!1}}),{index:se}=Number.isFinite(Y)?a.findIndexAtOrAfter(Y-.5,{materializeOption:{materialize:!1}}):{index:-1};if(se!==-1&&se<P){P=se,T=0;continue}if(se===P&&P>=1&&i(P-1)>0)T=0;else{P--;break}}}else T=0;P--}v=Ue(P+1,s);const Q=q(v,0);Pe=Q.cursor,I=Q.height}const z=Ue(v-n,s),H=Ue(Math.max(Pe-1,v),s),ie=Ue(H+n,s);return{renderingStartIndex:z,renderingEndIndex:ie,visibleStartIndex:v,visibleEndIndex:H}},bn=(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(h){console.error("[useThrottledInvoker] Error invoking callback",h)}i.arg=null,i.last=u}i.arg!==null&&(i.id=requestAnimationFrame(o))};i.id=requestAnimationFrame(o)},[s,n,r,i])},gs=t.memo(({index:r,top:e,height:n,item:s,children:i,clipItemHeight:a,enableKeyboardNavigation:o,onKeyDown:u,onEscapeKeyDown:f,onFocus:h,registerItemRef:x})=>{const S=t.useCallback(q=>x(r,q),[r,x]),M=t.useCallback(q=>u(q,r),[r,u]),v=t.useCallback(q=>f?.(q,r),[r,f]),I=t.useCallback(()=>h(r),[r,h]),te=t.useCallback(q=>{q.currentTarget.focus({preventScroll:!0})},[]);return V.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?I:void 0,children:i(s,r)})}),bs=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:s,viewportSize:i,overscanCount:a=15,className:o,testId:u,onScroll:f,onRangeChange:h,children:x,background:S,initialScrollIndex:M,initialScrollOffset:v,initialScrollAnchor:I,callbackThrottleMs:te=5,contentInsets:q,onItemFocus:me,scrollBarOptions:Pe,behaviorOptions:z,onWheelHorizontal:H,onPanHorizontal:ie,horizontalKeyInputs:L,horizontalKeyStep:P=hs,contentProps:T,liveRegion:Q,locale:G,labels:Y},se)=>{const{width:J,enableThumbDrag:he,enableTrackClick:Ge,enableArrowButtons:C,enableArrowButtonTabStops:B,enableScrollToTopBottomButtons:re,renderThumbOverlay:Ke,tapScrollCircleOptions:ae}=Pe??{},ve=t.useMemo(()=>Ur(G,Y),[G,Y]),{enablePointerDrag:Ct,pointerDragInputs:le,enableKeyboardNavigation:oe=!0,enableEscapeRowReturn:ht=!1,wheelSpeedMultiplier:et,inertiaOptions:st,overscrollBehavior:ze,clipItemHeight:tt=!1,resetOnGetItemHeightChange:Ze=!1}=z??{},[Qe,ue]=t.useState(0),Te=i??Qe,_e=t.useCallback(c=>{ue(p=>p===c?p:c)},[]),O=t.useRef(null),Fe=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),K=t.useRef(I&&r>0?{index:ne(Math.trunc(I.index),0,r-1),align:"top",offset:-Math.max(0,I.offsetPx??0)}:null),dt=t.useRef(!1),j=t.useRef(!0);t.useEffect(()=>{if(j.current){j.current=!1;return}Ze&&(K.current=null)},[Ze,s]);const E=t.useMemo(()=>gn(q),[q]),[it]=t.useState(()=>{const p=I?.index??M,b=typeof p=="number"&&Number.isFinite(p)?Math.max(0,Math.trunc(p)):0;return{from:Math.max(0,b-50),to:b+50}}),ye=t.useMemo(()=>({sampleRange:it,resetOnValueFnChange:Ze,materialize:!0}),[Ze,it]),A=Qr(r,s,ye),[at]=t.useState(()=>{let c=0,p=0;if(I&&r>0){const b=ne(Math.trunc(I.index),0,r-1),F=Math.max(0,I.offsetPx??0),W=ne(b-a*2,0,r-1),X=ne(b+a*2,0,r-1),Z=b>0||F>0?{materializeOption:{materialize:!0,ranges:[{from:W,to:X}]}}:void 0,{cumulative:ge,total:qe,currentValue:Ae}=A.prefixSum(b,Z),Ee=Math.max(ge-Ae+F,0);c=sr(Ee,E.top),p=qe??A.getTotal()}else if(typeof M=="number"){const b=ne(M,0,r-1),F=ne(b-a*2,0,r-1),W=ne(b+a*2,0,r-1),X=M>0?{materializeOption:{materialize:!0,ranges:[{from:F,to:W}]}}:void 0,{cumulative:Z,total:ge,currentValue:qe}=A.prefixSum(M,X),Ae=Math.max(Z-qe,0);c=sr(Ae,E.top),p=ge??A.getTotal()}else typeof v=="number"&&(c=sr(Math.max(v,0),E.top)),p=A.getTotal();return{position:c,total:p}}),[xt,Pt]=t.useState(at.position),[ot,g]=t.useState(at.total),_=t.useRef(at.position),de=t.useRef(E.top),U=t.useRef(f??void 0),ee=t.useRef(h??void 0),ke=t.useRef(H),He=(L?.length??0)>0,be=!!H;t.useEffect(()=>{He&&(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."),be||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.`))},[He,be,oe,P]);const Ye=t.useRef(new Map),xe=t.useRef(null),Ne=t.useRef(null),[lt,rt]=t.useState(null),[Ve,Be]=t.useState(!1),pe=t.useRef(null),we=t.useRef(!1),je=t.useRef(0),Ie=t.useRef(!1),w=t.useRef(!1),y=t.useRef(r);y.current!==r&&(y.current=r,w.current=!0),t.useLayoutEffect(()=>{U.current=f??void 0,ee.current=h??void 0,ke.current=H},[h,f,H]);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:p,totalHeight:b})=>{c(p,b)},[]),Xe=bn(U,te,Oe),nt=t.useCallback((c,p)=>{c(p)},[]),ct=bn(ee,te,nt),Se=t.useRef(E.top);Se.current=E.top;const Mt=t.useRef(Xe);Mt.current=Xe,t.useEffect(()=>(dt.current=!1,()=>{dt.current=!0,pe.current&&(clearTimeout(pe.current),pe.current=null)}),[]),t.useEffect(()=>{oe||(Ye.current.clear(),xe.current=null,Ne.current=null)},[oe]);const Gt=t.useCallback((c,p)=>{if(!p){Ye.current.delete(c);return}oe&&(Ye.current.set(c,p),xe.current===c&&(xe.current=null,Ne.current=c,Ce(p)))},[oe,Ce]),ir=.01,Re=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:at.position}),pt=t.useCallback(()=>{const c=Re.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{pt()},[pt]);const tr=t.useRef(()=>{}),Kt=t.useCallback(()=>{const c=Re.current;c.rafId=null;const p=_.current,b=Rt(p,Se.current),F=A.getTotal();if(Pt(X=>Math.abs(X-p)<ir?X:p),Math.abs(c.lastRenderedPosition-p)>=ir?(Mt.current({position:b,totalHeight:F}),c.lastRenderedPosition=p,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){pt();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(X=>tr.current(X));return}c.loopActive=!1},[A,pt]);tr.current=Kt;const qt=t.useCallback(()=>{const c=Re.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(Kt);return}c.loopActive=!1}},[Kt]),Me=t.useCallback((c,p)=>{const b=p?.immediate??!1,F=Rt(c,E.top);if(_.current=c,b){Re.current.lastRenderedPosition=c,Re.current.idleFrames=0,Pt(c),Xe({position:F,totalHeight:A.getTotal()});return}qt()},[qt,A,E.top,Xe]),yt=t.useCallback((c,p=0)=>{const b=O.current;if(!b)return c;const F=b.getScrollPosition();je.current+=1;const W=b.getContentSize()+p,X=b.getViewportSize(),Z=b.scrollTo(c,{contentSize:W,viewportSize:X});return Z===F&&(je.current=Math.max(0,je.current-1)),Math.abs(Z-c)>.5&&(Ie.current=!0),Z},[]),Yt=t.useRef(!1);t.useEffect(()=>{if(!Yt.current)if(Yt.current=!0,I==null&&typeof M!="number"&&typeof v=="number"){const c=sr(Math.max(v,0),E.top),p=Math.abs(c-_.current)>.5;Me(c,{immediate:!0}),p&&O.current?.scrollTo(c)}else Me(_.current,{immediate:!0})},[I,M,v,E.top,Me]),t.useEffect(()=>{const c=A.getTotal();if(ot!==c){g(c);return}if(Ie.current){Ie.current=!1;const p=O.current;if(p&&Math.abs(p.getScrollPosition()-_.current)>.5){const b=yt(_.current);Ie.current=!1,Me(b,{immediate:!0})}}},[A,ot,r,yt,Me]),t.useEffect(()=>{if(K.current!==null){const{index:c,align:p,offset:b}=K.current,F=Ue(c,r),{cumulative:W,currentValue:X}=A.prefixSum(F,{materializeOption:{materialize:!1}});if(W!==void 0&&X!==void 0){const Z=Math.max(W-X,0);let ge=Z;p==="bottom"?ge=W-Te:p==="center"&&(ge=Z+X/2-Te/2),b&&(ge-=b),ge=Math.max(0,ge);const qe=Math.max(0,ot+E.top+E.bottom-Te),Ae=Math.min(sr(ge,E.top),qe);Math.abs(Ae-_.current)>1&&(N.debug("[VirtualScroll] Drift correction",{from:_.current,to:Ae,targetIndex:F}),je.current===0&&(je.current+=1),O.current?.scrollTo(Ae),Me(Ae,{immediate:!0}))}}w.current=!1},[ot,A,r,E.top,Me,Te,E.bottom]),t.useEffect(()=>{const c=de.current;if(c===E.top||(de.current=E.top,K.current))return;const p=Rt(_.current,c),b=sr(p,E.top);_.current=b,O.current?.scrollTo(b),Me(b,{immediate:!0})},[E.top,Me]);const rr=t.useCallback((c,p)=>{if(r===0)return;const b=Ue(c,r),F=A.get(b),W=p-F,X=A.update(b,p);X!==void 0&&g(X),N.debug("[VirtualScroll] Updated item size manually",{index:b,size:p,total:X});let Z=K.current?K.current.index:null;if(Z===null){const ge=_.current,qe=gn(q).top,Ae=Rt(ge,qe),{index:Ee,cumulative:ft}=A.findIndexAtOrAfter(Ae,{materializeOption:{materialize:!1}});Z=ft!==void 0&&ft===Ae?Ee+1:Ee}if(Z!==-1&&b<Z&&W!==0){const ge=_.current,qe=ge+W;yt(qe,W),Me(qe,{immediate:!0}),N.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:ge,to:qe,causedByIndex:b,delta:W,activeVisibleStartIndex:Z})}},[A,r,yt,Me,q]),gt=t.useCallback((c,p)=>{if(!O.current||r===0)return;const b=Ue(c,r),F=Ue(b-a*2,r),W=Ue(b+a*2,r),{cumulative:X,total:Z,currentValue:ge}=A.prefixSum(b,{materializeOption:{materialize:!0,ranges:[{from:F,to:W}]}});if(N.debug("[VirtualScroll] Scrolling to index:",b,"ItemBottom:",X,"Total height:",Z,"ItemHeight:",ge,"safeIndexFrom:",F,"safeIndexTo:",W),!Z)return;const qe=Math.max(X-ge,0);let Ae=qe;p?.align==="bottom"?Ae=X-Te:p?.align==="center"&&(Ae=qe+ge/2-Te/2),p?.offset&&(Ae-=p.offset),Ae=Math.max(0,Ae);const Ee=sr(Ae,E.top),ft=O.current?.getContentSize()??Z+E.top+E.bottom,ut=Math.max(0,ft-Te),mt=Math.min(Ee,ut);K.current={index:b,align:p?.align,offset:p?.offset};const Qt=O.current?.getScrollPosition()??-1,hr=Math.abs(Qt-mt)>.5;we.current=!1,je.current=0,hr&&(we.current=!0,je.current+=1,O.current?.scrollTo(mt)),g(Z),Me(mt,{immediate:!0}),N.debug("[VirtualScroll] Setting scroll position to:",mt,{original:Ee,max:ut})},[A,a,r,E.top,E.bottom,Te,Me]),d=t.useRef(I&&r===0?I: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 p=A.getTotal(),b=ne(Math.floor(c),0,p),{index:F,cumulative:W,currentValue:X}=A.findIndexAtOrAfter(b,{materializeOption:{materialize:!1}}),ge=(W??0)-(X??0)-b;gt(F,{offset:ge})},[A,r,gt]),D=t.useCallback(()=>{if(r===0)return null;const c=Rt(_.current,E.top),{index:p,cumulative:b,currentValue:F}=A.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(p===-1)return{index:r-1,offsetPx:0};if(b===c)return{index:ne(p+1,0,r-1),offsetPx:0};const W=(b??0)-(F??0);return{index:p,offsetPx:Math.max(0,c-W)}},[A,r,E.top]),fe=t.useCallback(c=>{const p=Rt(_.current,E.top),b=typeof c=="function"?c(p):c;k(b);const F=O.current?.getScrollPosition(),W=typeof F=="number"?F:_.current;return Me(W),Rt(W,Se.current)},[E.top,k,Me]),Le=t.useCallback(c=>{const p=O.current;if(!p)return Rt(_.current,Se.current);const b=p.scrollTo(F=>F+c);return Rt(b,Se.current)},[]),De=t.useCallback(c=>O.current?.applyWheel(c)??!1,[]),vt=t.useCallback((c,p)=>{N.debug("[VirtualScroll] Scroll position changed:",c);const b=we.current;b&&(we.current=!1);const F=je.current>0;F&&(je.current=0);const W=w.current&&y.current===r;if(b||F||W||(K.current=null),Me(c),re){if(b||F)return;const X=c-p;if(N.debug("[VirtualScroll] Scroll diff:",X,"New:",c,"Prev:",p),Math.abs(X)>1){const Z=X>0?"down":"up";rt(Z),Be(!0),N.debug("[VirtualScroll] Showing scroll buttons. Direction:",Z),pe.current&&clearTimeout(pe.current),pe.current=setTimeout(()=>{Be(!1),N.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[Me,re,r]),We=t.useMemo(()=>Rt(xt,E.top),[E.top,xt]),zt=t.useMemo(()=>{const c=A.getTotal(),p=Nn(We,Te,a,r,s,A,c);return N.debug("[VirtualScroll] Calculated rendering range:",()=>({...p,scrollPosition:We,renderingContentSize:c,overscanCount:a,viewportSize:Te})),p},[We,Te,a,r,s,A]),{renderingStartIndex:wt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:Lt}=zt,bt=t.useCallback((c,p)=>{if(!oe||r===0)return;const b=Ue(c,r);if(!(p?.ensureVisible??!0)){const ut=Ye.current.get(b);ut&&(xe.current=null,Ne.current=b,Ce(ut));return}const W=A.prefixSum(b,{materializeOption:{materialize:!1}}),X=W.currentValue,Z=Math.max(W.cumulative-X,0),ge=Z+X,qe=Rt(_.current,E.top),Ae=qe+Te;if(Z<qe||ge>Ae){gt(b);const ut=Ye.current.get(b);ut?(xe.current=null,Ne.current=b,Ce(ut)):xe.current=b;return}const ft=Ye.current.get(b);if(ft){xe.current=null,Ne.current=b,Ce(ft);return}xe.current=b},[oe,r,A,E.top,gt,Ce,Te]),Bt=t.useCallback((c,p)=>{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 b=ke.current;if(!b||c.shiftKey||!L?.includes("arrow")||!(Number.isFinite(P)&&P>0))return;c.preventDefault(),b(c.key==="ArrowLeft"?-P:P);return}if(c.key==="ArrowDown"){p<r-1&&(c.preventDefault(),bt(p+1));return}if(c.key==="ArrowUp"){p>0&&(c.preventDefault(),bt(p-1));return}if(c.key==="PageDown"){if(p<r-1){c.preventDefault();const{visibleStartIndex:b,visibleEndIndex:F}=Fe.current,W=Math.max(F-b+1,1),X=Math.max(W,1),Z=Ue(Math.min(p+X,r-1),r);bt(Z)}return}if(c.key==="PageUp"&&p>0){c.preventDefault();const{visibleStartIndex:b,visibleEndIndex:F}=Fe.current,W=Math.max(F-b+1,1),X=Math.max(W,1),Z=Ue(p-X,r);bt(Z)}}},[oe,r,bt,L,P]),dr=t.useCallback((c,p)=>{if(c.key!=="Escape"||c.defaultPrevented||c.nativeEvent.isComposing||c.target===c.currentTarget)return;const b=c.target;b instanceof HTMLInputElement||b instanceof HTMLTextAreaElement||b instanceof HTMLSelectElement||b.isContentEditable||(c.preventDefault(),bt(p))},[bt]),It=t.useCallback(c=>{if(!oe)return;const p=Ue(c,r);xe.current=null,Ne.current=p,me?.(p)},[oe,r,me]);t.useEffect(()=>{const c=O.current?.getScrollPosition()??0,p=_.current,b=Rt(p,E.top);N.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:wt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:Lt,scrollPositionState:xt,paneScrollPosition:p,logicalScrollPosition:b,contentSize:ot,scrollPaneScrollPosition:c})),ct({renderingStartIndex:wt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:Lt,scrollPosition:b,totalHeight:ot})},[ot,kt,wt,E.top,ct,xt,Lt,Vt]);const Dt=t.useCallback(()=>{if(!re)return null;const c=Ve&&lt!==null,p=lt==="up";return V.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:p?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:b=>{b.stopPropagation(),we.current=!0,gt(0),Be(!1)},children:ve.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:b=>{b.stopPropagation(),we.current=!0,gt(r-1),Be(!1)},children:ve.scrollToBottom})})})},[re,Ve,lt,gt,r,ve]),_t=t.useRef(0),{visibleItems:Nt,renderAnchor:Ot}=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:ve.noItems})}),renderAnchor:0};const c=Ue(wt,r),p=Ue(kt,r),{cumulative:b,currentValue:F}=A.prefixSum(c,{materializeOption:{materialize:!1}}),W=b-F;Number.isFinite(W)&&Math.abs(W-_t.current)>kn&&(_t.current=W);const X=_t.current,Z=[],ge=[];let qe=0,Ae=W;for(let Ee=c;Ee<=p;Ee++){if(ge.length>=$r){N.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:$r,safeRenderingStartIndex:c,safeRenderingEndIndex:p});break}const ft=s(Ee),ut=A.get(Ee),mt=ft-ut;mt!==0&&Z.push({index:Ee,value:ft});const Qt=Ae+qe,hr=n?n(Ee):Ee;ge.push(V.jsx(gs,{index:Ee,top:Qt-X,height:ft,item:e(Ee),clipItemHeight:tt,enableKeyboardNavigation:oe,onKeyDown:Bt,onEscapeKeyDown:ht?dr:void 0,onFocus:It,registerItemRef:Gt,children:x},hr)),qe+=mt,Ae+=ut}return Z.length>0&&Promise.resolve().then(()=>{if(dt.current)return;let Ee=0;for(const mt of Z)if(mt.index<Vt){const Qt=A.get(mt.index);Ee+=mt.value-Qt}const ft=A.updates(Z);if(dt.current||typeof ft!="number")return;g(ft),N.debug("[VirtualScroll] Updated heights for items",Z,"New total height:",ft);const ut=O.current?.getScrollPosition()??_.current;if(Ee!==0){const mt=ut+Ee;yt(mt,Ee),Me(mt,{immediate:!0}),N.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:ut,to:mt,shiftAmount:Ee})}else ut!==_.current&&Me(ut)}),{visibleItems:ge,renderAnchor:X}},[x,tt,ot,oe,r,A,e,n,s,It,Bt,ht,dr,yt,Gt,kt,wt,ve,Me,Vt]),[Ft,Zt]=t.useState(null),St=t.useCallback(c=>{if(c===null)return;const p=ms(c);let b;const F=()=>{b?.removeEventListener("change",F);const X=p.devicePixelRatio;Zt(X),b=typeof p.matchMedia=="function"?p.matchMedia(`(resolution: ${X}dppx)`):void 0,b?.addEventListener("change",F)};return F(),()=>{b?.removeEventListener("change",F)}},[]),nr=t.useCallback(c=>{const p=(te??0)>0,b=Math.abs(c-xt),F=p&&b>.5?xt:c,W=Rt(F,E.top);if(N.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:W,renderingStartIndex:wt,renderingEndIndex:kt,itemCount:r,viewportSize:Te,callbackThrottleMs:te,diff:b,rawEffectiveScrollPosition:F})),r===0)return Nt;const X=E.top+Ot-F,Z=Ft===null?X:fs(X,Ft),ge=E.bottom>0?V.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:X,wrapperDevicePixelRatio:Ft,wrapperTranslateY:Z,logicalScrollPosition:We,resolvedInsets:E,effectiveScrollPosition:W})),V.jsxs("div",{ref:St,className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${Z}px)`,willChange:"transform"},children:[Nt,ge]})},[te,r,A,We,St,Ot,kt,wt,E,xt,Te,Nt,Ft]),jt=t.useMemo(()=>({renderingStartIndex:zt.renderingStartIndex,renderingEndIndex:zt.renderingEndIndex,visibleStartIndex:zt.visibleStartIndex,visibleEndIndex:zt.visibleEndIndex,scrollPosition:We,totalHeight:A.getTotal()}),[zt,We,A,ot]);t.useEffect(()=>{Fe.current=jt},[jt]);const[Tt,Sr]=t.useState(""),Ht=t.useRef(Q);t.useLayoutEffect(()=>{Ht.current=Q},[Q]);const Wt=Q?.debounceMs??400,Ut=Number.isFinite(Wt)&&Wt>=0,$e=Q!==void 0;t.useEffect(()=>{$e&&!Ut&&N.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${Wt}. Announcements are disabled.`)},[$e,Ut,Wt]),t.useEffect(()=>{if(!($e&&Ut)){Sr("");return}const c=setTimeout(()=>{const p=Ht.current?.format;if(!p)return;const b=p({visibleStartIndex:Vt,visibleEndIndex:Lt,itemCount:r});Sr(b)},Wt);return()=>clearTimeout(c)},[$e,Ut,Wt,Vt,Lt,r]),t.useImperativeHandle(se,()=>({getScrollPosition:()=>{const c=O.current?.getScrollPosition();return typeof c=="number"?Rt(c,Se.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:()=>Fe.current,getScrollAnchor:D,updateItemSize:rr}),[fe,Le,De,gt,A,bt,D,rr]);const fr=A.getTotal()+E.top+E.bottom,mr=V.jsx(Cn,{ref:O,contentSize:fr,viewportSize:i,onViewportSizeChange:_e,className:o,testId:u,onScroll:vt,background:S,tapScrollCircleOptions:ae,inertiaOptions:st,overscrollBehavior:ze,itemCount:r,scrollBarWidth:J,enableThumbDrag:he,enableTrackClick:Ge,enableArrowButtons:C,enableArrowButtonTabStops:B,enablePointerDrag:Ct,pointerDragInputs:le,renderThumbOverlay:Ke,wheelSpeedMultiplier:et,onWheelHorizontal:H,onPanHorizontal:ie,contentInsets:E,contentProps:T,visibleStartIndex:Vt,visibleEndIndex:Lt,renderOverlay:Dt,initialScrollPosition:at.position,locale:G,labels:Y,children:nr});return $e?V.jsxs(V.Fragment,{children:[mr,V.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Tt})]}):mr},An=t.forwardRef(bs),ur=262144,xn=3,zn=32768,qr=128,Yr=128,Br=128,jr=128,Or=10,xs=(r,e)=>Math.max(1,Math.floor((r??zn)/Math.max(1,e))),vs=(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)},Cr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=ur)){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, ${ur}] (0 = hidden). Round fractional sizes to whole pixels and split content larger than ${ur} px across several ${i}: a larger track could push cell positions past the 2^25 px layout-coordinate limit of browsers.`)}return r},ws=(r,e,n,s,i,a,o,u)=>{const f=Nn(r,e,n,s,i,a,o);if(s===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const h=ne(f.renderingStartIndex,0,s-1),{cumulative:x,currentValue:S}=a.prefixSum(h,{materializeOption:{materialize:!1}}),M=x-S,v=Number.isFinite(M)&&Math.abs(M-u)>kn?M:u;return{renderingColStart:f.renderingStartIndex,renderingColEnd:f.renderingEndIndex,visibleColStart:f.visibleStartIndex,visibleColEnd:f.visibleEndIndex,colAnchor:v}},vn=[],Ss=(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,h=0,x=r;for(;x<=e;){if(a.length>=i)return{columns:a,widthUpdates:o,truncated:e-x+1};const S=n(x),M=s.get(x);if(S!==M&&o.push({index:x,value:S}),S>0){a.push({col:x,left:f,width:S}),f+=M,h=0,x+=1;continue}if(f+=M,h+=1,x+=1,h>wr){const v=s.findIndexAtOrAfter(f+.5,{materializeOption:{materialize:!1}});if(v.index===-1||v.index<=x||!Number.isSafeInteger(v.index))break;const I=s.prefixSum(v.index,{materializeOption:{materialize:!1}});f=I.cumulative-I.currentValue,x=v.index,h=0}}return{columns:a,widthUpdates:o,truncated:0}},Rs=(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}},Ms=(r,e,n,s)=>{const i=[],a=[];let o=0;for(let u=r-e;u<r;u+=1){const f=n(u),h=s.get(u);f!==h&&a.push({index:u,value:f}),f>0&&i.push({col:u,left:o,width:f}),o+=h}return{columns:i,widthUpdates:a,width:o}},Pr=(r,e,n)=>Math.min(r,Math.max(0,n-e)),ys={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},Is=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:s,getCell:i,getCellKey:a,children:o,getCellProps:u,getRowProps:f,contentProps:h,background:x,contentInsets:S,onRowFocus:M,frozenLeadingCols:v=0,frozenLeadingRows:I=0,frozenTrailingCols:te=0,frozenTrailingRows:q=0,horizontalKeyInputs:me,horizontalKeyStep:Pe,onScroll:z,onRangeChange:H,onRenderTruncated:ie,callbackThrottleMs:L,initialScrollAnchor:P,overscanRows:T=xn,overscanCols:Q=xn,viewportSize:G,__maxRenderedCells:Y,behaviorOptions:se,scrollBarOptions:J,liveRegion:he,locale:Ge,labels:C,className:B,testId:re},Ke)=>{const ae=t.useRef(null),ve=t.useRef(null),Ct=t.useRef(n);Ct.current=n;const le=t.useRef(s);le.current=s;const oe=se?.resetOnGetColWidthChange===!0,et=se?.resetOnGetItemHeightChange===!0?n:null,st=oe?s:null,ze=t.useCallback(l=>Cr(Ct.current(l),"row",l),[et]),tt=t.useCallback(l=>Cr(le.current(l),"col",l),[st]),Ze=se?.defaultColWidth,Qe=t.useMemo(()=>{if(Ze!==void 0&&!(Number.isInteger(Ze)&&Ze>=0&&Ze<=ur))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${ur}], received ${Ze}.`);return{resetOnValueFnChange:oe,baseValue:Ze}},[oe,Ze]),ue=Qr(e,tt,Qe),[Te,_e]=t.useState(0);if(!(Number.isInteger(v)&&v>=0&&v<=qr))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${qr}], received ${v}.`);const O=Math.min(v,e),Fe=t.useRef(0);if(!(Number.isInteger(te)&&te>=0&&te<=Br))throw new RangeError(`[VirtualGrid] frozenTrailingCols must be an integer in [0, ${Br}], received ${te}.`);const K=Math.min(te,e-O),dt=t.useRef(0);if(!(Number.isInteger(I)&&I>=0&&I<=Yr))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${Yr}], received ${I}.`);const j=Math.min(I,r);if(!(Number.isInteger(q)&&q>=0&&q<=jr))throw new RangeError(`[VirtualGrid] frozenTrailingRows must be an integer in [0, ${jr}], received ${q}.`);const E=Math.min(q,r-j),it=Math.max(0,r-j-E),ye=t.useRef(!1),A=t.useRef(0),at=t.useRef(0),[xt,Pt]=t.useState(0),{frozenRows:ot,frozenHeight:g}=t.useMemo(()=>{if(j===0)return{frozenRows:[],frozenHeight:0};const l=[];let m=0;for(let R=0;R<j;R+=1){const $=ze(R);$>0&&l.push({row:R,top:m,height:$}),m+=$}return{frozenRows:l,frozenHeight:m}},[j,xt,ze]);A.current=g;const[_,de]=t.useState(0),{trailingRows:U,trailingHeight:ee}=t.useMemo(()=>{if(E===0)return{trailingRows:[],trailingHeight:0};const l=[];let m=0;for(let R=r-E;R<r;R+=1){const $=ze(R);$>0&&l.push({row:R,top:m,height:$}),m+=$}return{trailingRows:l,trailingHeight:m}},[E,r,_,ze]);at.current=ee;const ke=t.useCallback(l=>ze(l+j),[ze,j]),He=t.useRef(M);He.current=M;const be=M!==void 0,Ye=t.useMemo(()=>be?l=>He.current?.(l+j):void 0,[j,be]),xe=g,Ne=ee,[lt,rt]=t.useState(j),Ve=t.useRef(null),Be=t.useRef(!1);if(lt!==j){rt(j),Be.current=!0;const l=ae.current?.getScrollAnchor()??null;Ve.current=l===null?null:{row:l.index+lt,offsetPx:l.offsetPx}}const pe=t.useRef(0),we=t.useRef(0),je=t.useRef(!1),[Ie,w]=t.useState(ys),y=t.useRef(Ie);y.current=Ie;const Ce=t.useRef(0),[Oe,Xe]=t.useState(()=>ue.getTotal()??0),nt=t.useRef(Oe);nt.current=Oe;const ct=t.useCallback(l=>{typeof l=="number"&&Number.isFinite(l)&&(nt.current=l,Xe(l))},[]);t.useLayoutEffect(()=>{const l=ue.getTotal();typeof l=="number"&&Number.isFinite(l)&&l!==nt.current&&ct(l)});const Se=J?.width??12,Mt=G===void 0?null:{width:Math.max(0,Math.round(G.width)-Se),height:Math.max(0,Math.round(G.height)-Se)},[Gt,ir]=t.useState({width:0,height:0}),Re=Mt??Gt,pt=t.useRef(Re);pt.current=Re;const tr=Re.height>0&&Re.height-g-ee<=0;ye.current=tr;const Kt=Mt!==null;t.useLayoutEffect(()=>{if(Kt)return;const l=ve.current;if(l===null)return;const m=()=>{const $=Math.max(0,Math.round(l.clientWidth)-Se),ce=Math.max(0,Math.round(l.clientHeight)-Se);ir(Je=>Je.width===$&&Je.height===ce?Je:{width:$,height:ce})};m();const R=new ResizeObserver(m);return R.observe(l),()=>R.disconnect()},[Se,Kt]);const qt=t.useCallback(()=>{const l=ve.current;l!==null&&l.style.setProperty("--aqvs-grid-hx-residual",`${Ce.current-pe.current}px`)},[]),Me=t.useCallback(()=>Math.max(0,pt.current.width-Fe.current-dt.current),[]),yt=t.useCallback(()=>Math.max(0,nt.current-Fe.current-dt.current-Me()),[Me]),Yt=t.useCallback(()=>{const l=Me(),m=ws(Fe.current+pe.current,l,Q,e,tt,ue,nt.current,y.current.colAnchor);if(O>0&&(m.renderingColStart=Math.max(m.renderingColStart,O),m.visibleColStart=Math.max(m.visibleColStart,O)),K>0){const $=e-K-1;m.renderingColEnd=Math.min(m.renderingColEnd,$),m.visibleColEnd=Math.min(m.visibleColEnd,$)}(O>0||K>0)&&(l<=0||m.renderingColStart>m.renderingColEnd)&&(m.renderingColStart=e,m.renderingColEnd=e-1,m.visibleColStart=e,m.visibleColEnd=e-1);const R=`${m.renderingColStart}:${m.renderingColEnd}:${m.colAnchor}`;R!==y.current.key&&w({...m,key:R})},[Q,e,tt,ue,O,K,Me]),[rr,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(z);D.current=z;const fe=t.useRef(H);fe.current=H;const Le=t.useRef(ie);Le.current=ie;const De=t.useRef(null),[vt,We]=t.useState(null),[zt,wt]=t.useState(Re.height);zt!==Re.height&&(wt(Re.height),We(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 vs(Math.max(0,Re.height-A.current-at.current),ze,r,l,T)},[Re.height,ze,r,kt,T,xe,Ne]),Lt=vt??Vt,bt=t.useCallback(()=>{const l=De.current;if(l===null)return null;const m=y.current;return{renderingRowStart:l.renderingStartIndex,renderingRowEnd:l.renderingEndIndex,visibleRowStart:l.visibleStartIndex,visibleRowEnd:l.visibleEndIndex,renderingColStart:m.renderingColStart,renderingColEnd:m.renderingColEnd,visibleColStart:m.visibleColStart,visibleColEnd:m.visibleColEnd,scrollX:pe.current,scrollY:we.current,totalWidth:nt.current,totalHeight:l.totalHeight+A.current+at.current}},[]),Bt=t.useCallback(()=>{const l=bt();l!==null&&fe.current?.(l)},[bt]),dr=t.useCallback(l=>{const m=yt(),R=ne(l,0,m);return R!==pe.current&&(pe.current=R,qt(),Yt(),k(),D.current?.({x:R,y:we.current})),R},[qt,Yt,k,yt]),It=t.useRef(dr);It.current=dr,t.useLayoutEffect(()=>{Ce.current=Ie.colAnchor,qt(),Bt()},[Ie,qt,Bt]),t.useLayoutEffect(()=>{De.current!==null&&Bt()},[g,ee,Bt]);const Dt=t.useRef(null),_t=t.useCallback(l=>{const m=ne(l.col,0,Math.max(0,e-1)),R=ue.prefixSum(m,{materializeOption:{materialize:!1}}),$=R.cumulative-R.currentValue,ce=R.currentValue,Je=Me();return(l.alignX==="end"?$+ce-Fe.current-Je:l.alignX==="center"?$+ce/2-Fe.current-Je/2:$-Fe.current)+l.offsetX},[ue,e,Me]),Nt=t.useRef(null),Ot=t.useCallback(()=>{const l=Nt.current;Nt.current=null,!(l===null||l.length===0)&&(ct(ue.updates(l)),_e(m=>m+1))},[ue,ct]),Ft=t.useRef({count:0,warned:!1}),{frozenColumns:Zt,frozenWidth:St}=t.useMemo(()=>{if(O===0)return Ft.current.count=0,Ft.current.warned=!1,{frozenColumns:vn,frozenWidth:0};const{columns:l,widthUpdates:m,width:R}=Rs(O,tt,ue);if(m.length>0){const $=Ft.current;$.count>=Or?$.warned||($.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:m.length})):($.count+=1,Nt.current=[...Nt.current??[],...m],Promise.resolve().then(Ot))}else Ft.current.count=0,Ft.current.warned=!1;return{frozenColumns:l,frozenWidth:R}},[O,Te,tt,ue,Ot]);Fe.current=St,t.useLayoutEffect(()=>{O>0?ve.current?.style.setProperty("--aqvs-grid-frozen-width",`${St}px`):ve.current?.style.removeProperty("--aqvs-grid-frozen-width")},[St,O]);const nr=t.useRef({count:0,warned:!1}),{trailingColumns:jt,trailingWidth:Tt}=t.useMemo(()=>{if(K===0)return nr.current.count=0,nr.current.warned=!1,{trailingColumns:vn,trailingWidth:0};const{columns:l,widthUpdates:m,width:R}=Ms(e,K,tt,ue);if(m.length>0){const $=nr.current;$.count>=Or?$.warned||($.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:K,pendingUpdates:m.length})):($.count+=1,Nt.current=[...Nt.current??[],...m],Promise.resolve().then(Ot))}else nr.current.count=0,nr.current.warned=!1;return{trailingColumns:l,trailingWidth:R}},[K,e,Te,tt,ue,Ot]);dt.current=Tt,t.useLayoutEffect(()=>{K>0?ve.current?.style.setProperty("--aqvs-grid-trailing-width",`${Tt}px`):ve.current?.style.removeProperty("--aqvs-grid-trailing-width")},[Tt,K]);const Sr=t.useMemo(()=>({...J,tapScrollCircleOptions:{...J?.tapScrollCircleOptions,enabled:!1}}),[J]),Ht=J?.tapScrollCircleOptions,Wt=typeof Ht?.maxSpeedMultiplier=="number",Ut=t.useMemo(()=>({...Ht,offsetX:Ht?.offsetX===void 0?hn:Ht.offsetX,offsetY:Ht?.offsetY===void 0?hn:Ht.offsetY}),[Ht]),$e=t.useMemo(()=>Xr(Ut,Math.max(0,e-O-K)),[Ut,e,O,K]),fr=t.useMemo(()=>Xr(Ut,it),[Ut,it]),mr=$e.enabled,c=Math.max($e.maxVisualDistance,1),p={viewportSize:Math.max(0,Re.width-St-Tt),minSpeedMultiplier:$e.minSpeedMultiplier,maxSpeedMultiplier:$e.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:Wt,curve:$e.maxSpeedCurve},b={viewportSize:Math.max(0,Re.height-g-ee),minSpeedMultiplier:fr.minSpeedMultiplier,maxSpeedMultiplier:fr.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:Wt,curve:fr.maxSpeedCurve},F=t.useCallback(()=>pe.current,[]),W=t.useCallback(()=>{const l=ae.current;if(l===null)return we.current;const m=l.getScrollPosition();return m<0?we.current:m},[]),X=t.useCallback(()=>{const l=ae.current;return l===null?0:Math.max(0,Math.max(0,l.getContentSize())-Math.max(0,l.getViewportSize()))},[]),Z=t.useCallback(l=>{const m=ae.current;if(m===null)return we.current;const R=m.scrollBy(l);return we.current=R,R},[]),ge=yt()>0||X()>0,qe=`${Oe}:${St}:${Tt}:${Re.width}:${Ie.key}`,Ae=`${r}:${vt??-1}:${g}:${ee}:${Re.height}`,{isTapActive:Ee,handleTapCircleDragChange:ft,tapCircleHandleRef:ut}=ds({enabled:mr&&ge,maxDistance:c,xSpeedParams:p,ySpeedParams:b,applyHxRef:It,getHx:F,getMaxHx:yt,applyVy:Z,getVy:W,getMaxVy:X,pendingColAnchorRef:Dt,xExtentFreshness:qe,yExtentFreshness:Ae}),mt=t.useMemo(()=>ne((Ee?1:.8)*$e.opacity,0,1),[Ee,$e.opacity]);t.useLayoutEffect(()=>{const l=Dt.current;l===null?It.current(pe.current):It.current(_t(l)),Yt()},[Re.width,Oe,Te,St,Tt,Yt,_t]);const Qt=t.useRef(!1);t.useLayoutEffect(()=>{if(Qt.current||P===void 0||e===0)return;Qt.current=!0;const l=ne(Math.trunc(P.col),0,e-1);if(l<O||l>=e-K)return;const m={col:l,alignX:"start",offsetX:Math.max(0,P.offsetX)};Dt.current=m,It.current(_t(m))},[P,e,_t,O,K]);const hr=t.useCallback(l=>{we.current=l,je.current=!0,D.current?.({x:pe.current,y:l})},[]),Jr=t.useCallback(l=>{if(it===0||ye.current)De.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:it===0?0:l.totalHeight},we.current=0;else{const m=j;De.current={renderingStartIndex:l.renderingStartIndex+m,renderingEndIndex:l.renderingEndIndex+m,visibleStartIndex:l.visibleStartIndex+m,visibleEndIndex:l.visibleEndIndex+m,scrollPosition:l.scrollPosition,totalHeight:l.totalHeight},we.current=l.scrollPosition}We(m=>{const R=Math.max(1,l.renderingEndIndex-l.renderingStartIndex+1);return R===m?m:R}),Bt()},[Bt,j,it,r]),en=t.useCallback(l=>{Dt.current=null,It.current(pe.current+l)},[]),tn=xs(Y,Lt+ot.length+U.length),Ar=t.useRef({count:0,warned:!1}),{placedColumns:Rr,truncatedCols:Mr}=t.useMemo(()=>{const l=Math.max(0,Re.width-St-Tt);if(e===0||l<=0)return{placedColumns:[],truncatedCols:0};if(Ie.renderingColStart>Ie.renderingColEnd)return{placedColumns:[],truncatedCols:0};const m=Math.max(1,tn-Zt.length-jt.length),{columns:R,widthUpdates:$,truncated:ce}=Ss(ne(Ie.renderingColStart,0,e-1),ne(Ie.renderingColEnd,0,e-1),tt,ue,m);if($.length>0){const Je=Ar.current;Je.count>=Or?Je.warned||(Je.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:Ie.key,pendingUpdates:$.length})):(Je.count+=1,Nt.current=[...Nt.current??[],...$],Promise.resolve().then(Ot))}else Ar.current.count=0,Ar.current.warned=!1;return{placedColumns:R,truncatedCols:ce}},[Ie,e,Re.width,St,Tt,Zt.length,jt.length,Te,tt,ue,tn,Ot]),rn=t.useRef("");t.useEffect(()=>{if(Mr>0){const l=`${Ie.key}:${Mr}`;l!==rn.current&&(rn.current=l,Le.current?.({renderedCells:(Rr.length+Zt.length+jt.length)*(Lt+ot.length+U.length),droppedCols:Mr}))}},[Mr,Ie.key,Rr.length,Zt.length,jt.length,Lt,ot.length,U.length]);const nn=Ie.colAnchor,zr=t.useCallback(l=>{const m=f?.(l),R=ze(l)===0,$=R?null:Rr.map(({col:ce,left:Je,width:or})=>{const At=u?.(l,ce),pr={...At?.style,left:Je-nn,width:or};return t.createElement("div",{...At,key:a?a(l,ce):ce,className:Et.twMerge("aqvs-grid-cell",At?.className),style:pr},o(i(l,ce),l,ce))});return O===0&&K===0?V.jsx("div",{...m,className:Et.twMerge("aqvs-grid-row",m?.className),style:m?.style,children:$}):V.jsxs("div",{...m,"data-aqvs-frozen-row":O>0?"":void 0,className:Et.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",m?.className),style:m?.style,children:[R?null:Zt.map(({col:ce,left:Je,width:or})=>{const At=u?.(l,ce),pr={...At?.style,left:Je,width:or};return t.createElement("div",{...At,"data-aqvs-frozen-cell":"",key:a?a(l,ce):ce,className:Et.twMerge("aqvs-grid-cell",At?.className),style:pr},o(i(l,ce),l,ce))}),R?null:V.jsx("div",{className:"aqvs-grid-row-scroll",children:V.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:$})}),R||K===0?null:V.jsx("div",{className:"aqvs-grid-row-trailing",children:V.jsx("div",{className:"aqvs-grid-row-trailing-inner",children:jt.map(({col:ce,left:Je,width:or})=>{const At=u?.(l,ce),pr={...At?.style,left:Je,width:or};return t.createElement("div",{...At,"data-aqvs-trailing-cell":"",key:a?a(l,ce):ce,className:Et.twMerge("aqvs-grid-cell",At?.className),style:pr},o(i(l,ce),l,ce))})})})]})},[Rr,Zt,jt,O,K,nn,f,u,a,i,o,ze]),[Vn,Ln]=t.useState(""),ar=t.useRef(null),sn=t.useRef(he);sn.current=he;const yr=t.useCallback(()=>{const l=sn.current;if(l===void 0)return;const m=l.debounceMs??400;Number.isFinite(m)&&m>=0&&(ar.current!==null&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>{ar.current=null;const R=bt();R!==null&&Ln($=>{const ce=l.buildMessage(R);return ce===$?$:ce})},m))},[bt]),Ir=he?.debounceMs??400,an=Number.isFinite(Ir)&&Ir>=0,on=he!==void 0;t.useEffect(()=>{on&&!an&&N.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${Ir}. Announcements are disabled.`)},[on,an,Ir]),t.useEffect(()=>()=>{ar.current!==null&&window.clearTimeout(ar.current)},[]),t.useEffect(()=>{yr()},[Ie,yr]);const Dn=t.useCallback(l=>{Jr(l),yr()},[Jr,yr]);return t.useImperativeHandle(Ke,()=>({scrollTo:l=>{const m=ae.current;let R=we.current;l.y!==void 0&&m!==null&&(m.scrollTo(l.y),R=m.getScrollPosition(),we.current=R);let $=pe.current;return l.x!==void 0&&(Dt.current=null,$=It.current(l.x)),{x:$,y:R}},scrollBy:l=>{const m=ae.current;let R=we.current;l.y!==void 0&&l.y!==0&&m!==null&&(R=m.scrollBy(l.y),we.current=R);let $=pe.current;return l.x!==void 0&&l.x!==0&&(Dt.current=null,$=It.current(pe.current+l.x)),{x:$,y:R}},scrollToCell:(l,m,R)=>{const $=ae.current;if($!==null&&r>0){const ce=ne(Math.trunc(l),0,r-1);ce>=j&&ce<r-E&&$.scrollToIndex(ce-j,{align:R?.alignY??"top",offset:R?.offsetY})}if(e>0){const ce=ne(Math.trunc(m),0,e-1);if(ce>=O&&ce<e-K){const Je={col:ce,alignX:R?.alignX??"start",offsetX:R?.offsetX??0};Dt.current=Je,It.current(_t(Je))}}},getScrollPosition:()=>je.current||ae.current!==null?{x:pe.current,y:ae.current?.getScrollPosition()??we.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 m=Fe.current+pe.current,R=ue.findIndexAtOrAfter(m,{materializeOption:{materialize:!1}});if(R.index===-1)return{row:l.index+j,col:e-1,offsetX:0,offsetY:l.offsetPx};if(R.cumulative===m)return{row:l.index+j,col:ne(R.index+1,0,e-1),offsetX:0,offsetY:l.offsetPx};const $=(R.cumulative??0)-(R.currentValue??0);return{row:l.index+j,col:R.index,offsetX:Math.max(0,m-$),offsetY:l.offsetPx}},getViewportSize:()=>({width:pt.current.width,height:pt.current.height}),getContentSize:()=>({width:nt.current,height:ae.current===null?0:A.current+at.current+Math.max(0,ae.current.getContentSize())}),getRange:bt,updateRowSize:(l,m)=>{Cr(m,"row",l),Math.trunc(l)<j?Pt(R=>R+1):E>0&&Math.trunc(l)>=r-E?de(R=>R+1):ae.current?.updateItemSize(Math.trunc(l)-j,m)},updateColSize:(l,m)=>{Cr(m,"col",l),ct(ue.update(ne(Math.trunc(l),0,Math.max(0,e-1)),m)),_e(R=>R+1)},getFrozenSize:()=>({cols:O,width:Fe.current,rows:j,height:A.current,trailingCols:K,trailingRows:E,trailingWidth:dt.current,trailingHeight:at.current,trailingVisibleWidth:Pr(dt.current,Fe.current,pt.current.width),trailingVisibleHeight:Pr(at.current,A.current,pt.current.height)}),applyWheel:l=>ae.current?.applyWheel(l)??!1,focusRowAtIndex:(l,m)=>{const R=Math.trunc(l);R<j?ve.current?.querySelector(`[data-aqvs-frozen-band-row="${R}"]`)?.focus():E>0&&R>=r-E?ve.current?.querySelector(`[data-aqvs-trailing-band-row="${R}"]`)?.focus():ae.current?.focusItemAtIndex(R-j,m)}}),[r,e,ue,bt,ct,_t,O,j,K,E]),V.jsxs("div",{ref:ve,className:Et.twMerge("aqvs-grid",j>0?"aqvs-grid-has-frozen-rows":"",E>0?"aqvs-grid-has-trailing-rows":"",B),"data-testid":re,children:[j>0?V.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:g},"data-testid":re?`${re}-frozen-rows`:void 0,children:ot.map(({row:l,top:m,height:R})=>V.jsx("div",{"data-aqvs-frozen-band-row":l,className:"aqvs-grid-frozen-band-row",style:{top:m,height:R,right:Se},tabIndex:-1,onFocus:()=>M?.(l),children:zr(l)},l))}):null,V.jsx("div",{className:"aqvs-grid-main","data-testid":re?`${re}-main`:void 0,children:V.jsx(An,{ref:ae,itemCount:tr?0:it,getItem:l=>l+j,getItemKey:l=>l+j,getItemHeight:ke,overscanCount:T,viewportSize:Re.height>0?Math.max(0,Re.height-g-ee):void 0,callbackThrottleMs:L,behaviorOptions:se,scrollBarOptions:Sr,contentProps:h,background:x,contentInsets:S,onItemFocus:Ye,horizontalKeyInputs:me,horizontalKeyStep:Pe,initialScrollAnchor:Be.current?Ve.current!==null&&Ve.current.row>=j&&it>0?{index:Ve.current.row-j,offsetPx:Ve.current.offsetPx}:void 0:P!==void 0&&it>0&&Math.trunc(P.row)>=j&&Math.trunc(P.row)<r-E?{index:Math.trunc(P.row)-j,offsetPx:P.offsetY}:void 0,onScroll:hr,onRangeChange:Dn,onWheelHorizontal:en,onPanHorizontal:en,locale:Ge,labels:C,testId:re?`${re}-rows`:void 0,children:zr},j)}),E>0?V.jsx("div",{className:"aqvs-grid-trailing-rows",style:{height:Pr(ee,g,Re.height)},"data-testid":re?`${re}-trailing-rows`:void 0,children:V.jsx("div",{className:"aqvs-grid-trailing-rows-inner",style:{height:ee},children:U.map(({row:l,top:m,height:R})=>V.jsx("div",{"data-aqvs-trailing-band-row":l,className:"aqvs-grid-trailing-band-row",style:{top:m,height:R,right:Se},tabIndex:-1,onFocus:()=>M?.(l),children:zr(l)},l))})}):null,V.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:Se,paddingRight:K>0?Se+Pr(Tt,St,Re.width):Se},"data-testid":re?`${re}-hbar`:void 0,children:V.jsx(Zr,{horizontal:!0,contentSize:Math.max(0,Oe-St-Tt),viewportSize:Math.max(0,Re.width-St-Tt),scrollPosition:rr,itemCount:Math.max(0,e-O-K),tapScrollCircleOptions:J?.tapScrollCircleOptions,onScroll:(l,m)=>(Dt.current=null,It.current(typeof l=="function"?l(m??pe.current):l)),enableThumbDrag:J?.enableThumbDrag,enableTrackClick:J?.enableTrackClick,enableArrowButtons:J?.enableArrowButtons,enableArrowButtonTabStops:J?.enableArrowButtonTabStops,scrollBarWidth:Se,locale:Ge,labels:C})}),mr&&ge&&V.jsx("div",{className:"aqvs-grid-tap-circle-wrapper","data-aqvs-grid-tap-circle":"",style:{left:`min(calc(100% - ${Se+$e.size}px), max(calc(100% - ${Se}px + ${$e.offsetX}px), calc(75% - ${$e.size/2}px)))`,top:`min(calc(100% - ${Se+$e.size}px), max(calc(100% - ${Se}px + ${$e.offsetY}px), calc(75% - ${$e.size/2}px)))`},children:V.jsx(Gr,{axis:"xy",ref:ut,className:Et.twMerge("aqvs-grid-tap-circle",$e.className),size:$e.size,maxVisualDistance:c,opacity:mt,renderVisual:$e.renderVisual,onDragChange:ft})}),he!==void 0?V.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":re?`${re}-live`:void 0,children:Vn}):null]})},Ts=t.forwardRef(Is);exports.FenwickMapTree=$t;exports.MAX_FROZEN_LEADING_COLS=qr;exports.MAX_FROZEN_LEADING_ROWS=Yr;exports.MAX_FROZEN_TRAILING_COLS=Br;exports.MAX_FROZEN_TRAILING_ROWS=jr;exports.MAX_RENDERED_CELLS=zn;exports.MAX_TRACK_SIZE=ur;exports.ScrollBar=Zr;exports.ScrollPane=Cn;exports.TAP_SCROLL_SPEED_DEFAULTS=Kr;exports.VIRTUAL_SCROLL_LABEL_CATALOGS=wn;exports.VIRTUAL_SCROLL_LABEL_KEYS=kr;exports.VIRTUAL_SCROLL_LOCALES=Wr;exports.VirtualGrid=Ts;exports.VirtualScroll=An;exports.computeAutoTapScrollMaxSpeedMultiplier=In;exports.computeTapScrollSpeed=Nr;exports.computeTapScrollVelocity=Tn;exports.createResidualQuantizer=Qn;exports.minmax=ne;exports.resolveVirtualScrollLabels=Ur;exports.resolveVirtualScrollLocale=Sn;exports.tapScrollCircleSampleVisual=ss;exports.useFenwickMapTree=Qr;exports.useHeightCache=cs;exports.useLruCache=Pn;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;