@aiquants/virtualscroll 3.1.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +159 -1
- package/README.md +97 -3
- package/dist/ScrollBar.d.cts +9 -1
- package/dist/ScrollBar.d.ts +9 -1
- package/dist/ScrollBar.d.ts.map +1 -1
- package/dist/ScrollPane.d.cts +13 -0
- package/dist/ScrollPane.d.ts +13 -0
- package/dist/ScrollPane.d.ts.map +1 -1
- package/dist/TapScrollCircle.d.cts +7 -1
- package/dist/TapScrollCircle.d.ts +7 -1
- package/dist/TapScrollCircle.d.ts.map +1 -1
- package/dist/VirtualGrid.d.cts +472 -0
- package/dist/VirtualGrid.d.ts +473 -0
- package/dist/VirtualGrid.d.ts.map +1 -0
- package/dist/VirtualScroll.d.cts +47 -0
- package/dist/VirtualScroll.d.ts +47 -0
- package/dist/VirtualScroll.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2280 -1674
- package/dist/styles/virtualscroll.css +1 -1
- package/dist/styles/virtualscroll.standalone.css +1 -1
- package/dist/useFenwickMapTree.d.cts +7 -4
- package/dist/useFenwickMapTree.d.ts +7 -4
- package/dist/useFenwickMapTree.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ScrollBar.tsx +15 -3
- package/src/ScrollPane.tsx +46 -1
- package/src/TapScrollCircle.tsx +14 -5
- package/src/VirtualGrid.tsx +1822 -0
- package/src/VirtualScroll.tsx +30 -6
- package/src/index.ts +14 -0
- package/src/styles/virtualscroll.css +178 -0
- package/src/useFenwickMapTree.ts +34 -12
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),r=require("react"),Mt=require("tailwind-merge"),Pr=n=>{const{quantum:e,resetOnDirectionChange:t=!0}=n;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;t&&s!==0&&i!==0&&Math.sign(i)!==Math.sign(s)&&(s=0),s+=i;const o=Math.trunc(s/e)*e+0;return s-=o,o},peekResidue:()=>s,reset:()=>{s=0}}};class R{level;prefix;impl;constructor(e=2,t="[virtualscroll]",s=console){this.level=e,this.prefix=t,this.impl=s}static instance=new R(2,"[virtualscroll]");static setLevel(e){R.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){R.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){R.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return R.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,...t){R.instance.debug(e,...t)}debug(e,...t){this.level<=0&&this.impl.debug(...this.formatMessage(R.resolveLazy(e)),...t.map(R.resolveLazy))}static info(e,...t){R.instance.info(e,...t)}info(e,...t){this.level<=1&&this.impl.info(...this.formatMessage(R.resolveLazy(e)),...t.map(R.resolveLazy))}static warn(e,...t){R.instance.warn(e,...t)}warn(e,...t){this.level<=2&&this.impl.warn(...this.formatMessage(R.resolveLazy(e)),...t.map(R.resolveLazy))}static error(e,...t){R.instance.error(e,...t)}error(e,...t){this.level<=3&&this.impl.error(...this.formatMessage(R.resolveLazy(e)),...t.map(R.resolveLazy))}}const sr={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Xt=6,yr=8,Er=({dragState:n,normalizedDistance:e})=>{const t=1+e*.18,s=.16+e*.24,i=.38+e*.28,o=n.active?"80ms ease-out":"220ms ease";return q.jsxs(q.Fragment,{children:[q.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(${t})`,transition:`${o}, ${n.active?"80ms":"260ms"} box-shadow ease`}}),q.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:n.active?"120ms opacity ease-out":"220ms opacity ease"}})]})},mr=r.memo(r.forwardRef(({onDragChange:n,className:e,maxVisualDistance:t=160,size:s=40,style:i,opacity:o=1,renderVisual:l},p)=>{const[d,b]=r.useState(sr),x=r.useRef(null),I=r.useRef(null),N=r.useRef({x:0,y:0}),g=r.useRef(null),D=r.useRef(0),j=r.useCallback(S=>{b(S),n(S)},[n]),z=r.useCallback((S,U,ce=!1)=>{const{x:Ye,y:Be}=N.current,k=S-Ye,Ae=U-Be,He=Math.abs(Ae),Ee=He<Xt?0:Ae<0?-1:1,Le=D.current;let qe=Ee;const Ne=Xt+yr;Ee===0?Le!==0&&He<Ne?qe=Le:(qe=0,ce||(D.current=0)):Ee!==Le&&Le!==0&&He<Ne?qe=Le:D.current=Ee,j({active:ce||He>=Xt,offsetX:k,offsetY:Ae,distance:He,direction:qe,pointerId:x.current})},[j]),oe=r.useCallback(S=>{if(S===null)return;const U=g.current;U?.hasPointerCapture(S)&&U.releasePointerCapture(S)},[]),ae=r.useCallback((S=!1)=>{S&&oe(x.current),x.current=null,I.current=null,D.current=0,j(sr)},[j,oe]),te=r.useCallback(S=>{if(x.current!==null&&x.current!==S.pointerId){I.current={pointerId:S.pointerId,clientX:S.clientX,clientY:S.clientY},S.preventDefault(),S.stopPropagation();return}S.preventDefault(),S.stopPropagation();const U=g.current??S.currentTarget,{left:ce,top:Ye,width:Be,height:k}=U.getBoundingClientRect();N.current={x:ce+Be/2,y:Ye+k/2},x.current=S.pointerId;try{U.setPointerCapture(S.pointerId)}catch{}z(S.clientX,S.clientY,!0)},[z]),ne=r.useCallback(S=>{if(x.current!==S.pointerId){I.current!==null&&I.current.pointerId===S.pointerId&&(I.current={pointerId:S.pointerId,clientX:S.clientX,clientY:S.clientY});return}S.preventDefault(),z(S.clientX,S.clientY)},[z]),le=r.useCallback(S=>{if(x.current!==S.pointerId){I.current!==null&&I.current.pointerId===S.pointerId&&(I.current=null);return}S.preventDefault(),S.stopPropagation();const U=I.current;if(I.current=null,U!==null){oe(S.pointerId);const ce=g.current;let Ye=!0;if(ce!==null&&typeof ce.setPointerCapture=="function")try{ce.setPointerCapture(U.pointerId)}catch(Be){(typeof Be=="object"&&Be!==null&&"name"in Be?Be.name:void 0)==="NotFoundError"&&(Ye=!1)}if(Ye){x.current=U.pointerId,z(U.clientX,U.clientY,!0);return}}ae(!0)},[ae,oe,z]),P=r.useCallback(S=>{S.target===S.currentTarget&&x.current===S.pointerId&&ae(!1)},[ae]);r.useImperativeHandle(p,()=>({reset:()=>{ae(!0)},getElement:()=>g.current}),[ae]);const _=Math.min(Math.max(o,0),1),w=s/64,K=Math.min(d.distance,t)/t,G=d.direction*K*10*w,$=l??Er,de={dragState:d,normalizedDistance:K,sizeScale:w,size:s,opacity:_},V={...i,width:s,height:s,transform:`translateY(${G}px)`};return V.opacity=_,q.jsx("div",{ref:g,"data-testid":"virtual-scroll-tap-circle",className:Mt.twMerge("aqvs-tap-scroll-circle",e),style:V,tabIndex:-1,onPointerDown:te,onPointerMove:ne,onPointerUp:le,onPointerCancel:le,onLostPointerCapture:P,role:"presentation",children:$(de)})}));mr.displayName="TapScrollCircle";const ee=(n,e,t)=>Math.max(e,Math.min(t,n)),pr=(n,e)=>{const t=e==="x",s=n.getBoundingClientRect(),i=t?s.width:s.height,o=x=>{const I=Number.parseFloat(x);return Number.isFinite(I)?I:0},l=window.getComputedStyle(n),p=o(t?l.width:l.height),d=p>0?p+o(t?l.paddingLeft:l.paddingTop)+o(t?l.paddingRight:l.paddingBottom)+o(t?l.borderLeftWidth:l.borderTopWidth)+o(t?l.borderRightWidth:l.borderBottomWidth):0,b=d>0?d:t?n.offsetWidth:n.offsetHeight;return b<=0||i<=0?1:i/b},Kt="virtualscroll:tap-scroll-cancel",ir=20,Cr=250,kr=60,Nr=20,zr=20,Gt={maxDistance:240,minSpeedMultiplier:.2},Vr=Gt.maxDistance,or={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},jt=2.2,Dr=8,Ar=120,Lr=1/10,it={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:Vr,minSpeedMultiplier:Gt.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},Or=n=>n?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,t)=>e,getPointerCoordinate:({clientX:e})=>e,arrowLabels:["Scroll left","Scroll right"],arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,t)=>t,getPointerCoordinate:({clientY:e})=>e,arrowLabels:["Scroll up","Scroll down"],arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},_r=(n,e)=>{const t=n?.maxSpeedMultiplier,s=typeof t=="number"?t:gr(e);return{enabled:n?.enabled??it.enabled,size:n?.size??it.size,offsetX:n?.offsetX??it.offsetX,offsetY:n?.offsetY??it.offsetY,className:n?.className??it.className,maxVisualDistance:n?.maxVisualDistance??it.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(n?.minSpeedMultiplier??it.minSpeedMultiplier,0),opacity:ee(n?.opacity??it.opacity,0,1),renderVisual:n?.renderVisual??it.renderVisual,maxSpeedCurve:n?.maxSpeedCurve??it.maxSpeedCurve}},Fr=({isDragging:n,isThumbHovered:e,enableThumbDrag:t})=>r.useMemo(()=>t?n?"dragging":e?"hover":"idle":"disabled",[t,n,e]),Yr=({canUseArrowButtons:n,enableArrowButtons:e,resetTapScroll:t,scrollByStep:s})=>{const i=r.useRef(null),o=r.useRef(null),l=r.useRef(null),p=r.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null),o.current!==null&&(window.clearTimeout(o.current),o.current=null),l.current!==null&&(window.removeEventListener("pointerup",l.current),window.removeEventListener("pointercancel",l.current),window.removeEventListener("blur",l.current),l.current=null)},[]),d=r.useCallback(()=>{p()},[p]),b=r.useCallback(I=>N=>{if(!n)return;N.cancelable&&N.preventDefault(),N.stopPropagation(),t(),p(),s(I),o.current=window.setTimeout(()=>{i.current=window.setInterval(()=>{s(I)},kr)},Cr);const g=()=>p();l.current=g,window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),window.addEventListener("blur",g)},[n,p,t,s]),x=r.useCallback(I=>N=>{e&&(N.key==="Enter"||N.key===" "||N.key==="Spacebar")&&(N.preventDefault(),s(I))},[e,s]);return r.useEffect(()=>{n||p()},[n,p]),r.useEffect(()=>()=>{p()},[p]),{handleArrowPointerDown:b,handleArrowPointerUp:d,handleArrowKeyDown:x}},Br=700,gt=(n,e)=>typeof n=="number"&&Number.isFinite(n)?n:e,hr=({distance:n,maxDistance:e,viewportSize:t,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:o,curve:l})=>{const p=Math.max(gt(n,0),0),d=gt(e,0),b=d>0?Math.min(p,d)/d:1,x=Math.max(gt(t,0),0),I=Math.max(gt(s,0),0),N=Math.max(gt(i,0),0),g=Math.max(x*I,40),D=o?g:1200,j=Math.max(x*N,D),z=l?Math.max(gt(l.exponentialScale,N),0):0,oe=l?Math.min(j,Math.max(x*z,g)):j,ae=Math.max(oe,g);let te=b**1.1;if(l){const le=Math.min(Math.max(gt(l.exponentialSteepness,0),0),Br);if(le===0)te=b;else{const P=Math.expm1(le)||1;te=Math.min(Math.max(Math.expm1(le*b)/P,0),1)}}const ne=Math.min(Math.max(gt(l?.easedOffset,0),0),1);return g+(ae-g)*(ne+(1-ne)*te)},gr=n=>{if(!n||n<=0)return jt;const e=Math.max(1,n),t=Math.log10(e),s=jt+t*Dr;return ee(s,jt,Ar)},br=({contentSize:n,viewportSize:e,scrollPosition:t,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:o=!0,enableArrowButtons:l=!0,horizontal:p=!1,scrollBarWidth:d=12,className:b,ariaControls:x,tapScrollCircleOptions:I,itemCount:N,renderThumbOverlay:g,visibleStartIndex:D,visibleEndIndex:j})=>{const[z,oe]=r.useState(!1),[ae,te]=r.useState(!1),[ne,le]=r.useState(!1),P=r.useRef(null),_=r.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),w=r.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),K=r.useRef(t),G=r.useRef(s),$=r.useRef(or),de=r.useRef(null),V=r.useRef(null),S=r.useRef(null),U=r.useRef(0),ce=r.useRef(0),Ye=r.useMemo(()=>_r(I,N),[N,I]),Be=r.useMemo(()=>Or(p),[p]),{enabled:k,size:Ae,offsetX:He,offsetY:Ee,className:Le,maxVisualDistance:qe,maxSpeedMultiplier:Ne,minSpeedMultiplier:we,opacity:Ce,renderVisual:he,maxSpeedCurve:xe}=Ye,W=r.useRef({viewportSize:e,maxScrollPosition:Math.max(n-e,0),scrollBarVisible:n>e,effectiveTapMaxDistance:Math.max(qe,1),tapCircleMaxSpeedMultiplier:Ne,tapCircleMinSpeedMultiplier:we,tapCircleMaxSpeedCurve:xe,tapScrollCircleOptions:I,effectiveTrackLength:0,onScroll:s,scrollPosition:t}),{mainSizeKey:Ue,crossSizeKey:Xe,positionKey:ot,selectDelta:Je,getPointerCoordinate:y,arrowLabels:dt,arrowIcons:re,directionClass:E,orientation:et}=Be,je=Math.max(qe,1),at=e/n,ze=Math.max(e-d*2,0),m=at*ze,M=Math.min(Math.max(ir,m||0),ze||ir),H=n-e,Y=Math.max(ze-M,0),Z=H<=0||Y<=0?0:ee(t/H*Y,0,Y),Se=Z+M/2,Q=n>e||z,ge=Q&&l;r.useLayoutEffect(()=>{W.current={viewportSize:e,maxScrollPosition:H,scrollBarVisible:Q,effectiveTapMaxDistance:je,tapCircleMaxSpeedMultiplier:Ne,tapCircleMinSpeedMultiplier:we,tapCircleMaxSpeedCurve:xe,tapScrollCircleOptions:I,effectiveTrackLength:Y,onScroll:s,scrollPosition:t}}),r.useLayoutEffect(()=>{K.current=t},[t]),r.useLayoutEffect(()=>{G.current=s},[s]),r.useEffect(()=>{i||te(!1)},[i]);const Te=Fr({isDragging:z,isThumbHovered:ae,enableThumbDrag:i}),X=r.useCallback((c,v)=>{const C=W.current,B=v??K.current;if(G.current){const Qe=G.current(c,B);if(typeof Qe=="number"&&Number.isFinite(Qe))return K.current=Qe,Qe}const pe=typeof c=="function"?c(B):c,ye=Math.max(C.maxScrollPosition,0),Ze=C.scrollBarVisible?ee(pe,0,ye):0;return K.current=Ze,Ze},[]),Me=r.useCallback(c=>{const v=W.current,C=K.current;if(!v.scrollBarVisible||v.maxScrollPosition<=0){const rt=X(0,C),ct=rt-C;return{nextPosition:rt,actualDelta:ct,reachedBoundary:!0}}if(c===0)return{nextPosition:C,actualDelta:0,reachedBoundary:!1};const pe=X(rt=>ee(rt+c,0,v.maxScrollPosition),C),ye=pe-C,Ze=c<0&&C+c<=0,Qe=c>0&&C+c>=v.maxScrollPosition,lt=c<0&&(pe<=0||Ze&&ye===0)||c>0&&(pe>=v.maxScrollPosition||Qe&&ye===0);return{nextPosition:pe,actualDelta:ye,reachedBoundary:lt}},[X]),ke=r.useCallback((c,v)=>{c.current+=v;const C=Math.max(W.current.maxScrollPosition,0);C>0&&(c.current=ee(c.current,-C,C));const B=Me(c.current);return c.current-=B.actualDelta,B.reachedBoundary&&(c.current=0),B},[Me]),ue=r.useCallback(()=>{V.current!==null&&(window.cancelAnimationFrame(V.current),V.current=null),S.current=null,U.current=0,ce.current=0},[]),Re=r.useCallback(()=>{$.current={...or},le(!1),de.current?.reset(),ue()},[ue]),We=r.useCallback(c=>{const v=$.current,C=W.current;if(!v.active||v.direction===0){ue();return}if(!C.scrollBarVisible||C.maxScrollPosition<=0){ue();return}const B=S.current??c,pe=Math.max((c-B)/1e3,0),ye=Math.min(pe,Lr);if(S.current=c,ye<=0){V.current=window.requestAnimationFrame(We);return}const Ze=hr({distance:v.distance,maxDistance:C.effectiveTapMaxDistance,viewportSize:C.viewportSize,minSpeedMultiplier:C.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:C.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof C.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:C.tapCircleMaxSpeedCurve});ce.current!==v.direction&&(ce.current=v.direction,U.current=0);const{reachedBoundary:Qe}=ke(U,v.direction*Ze*ye);if(Qe){ue();return}V.current=window.requestAnimationFrame(We)},[ke,ue]),Ve=r.useCallback(()=>{V.current===null&&(S.current=null,U.current=0,V.current=window.requestAnimationFrame(We))},[We]);r.useEffect(()=>{const c=$.current;!c.active||c.direction===0||Ve()},[n,e,Ve]),r.useEffect(()=>()=>{ue()},[ue]);const tt=r.useCallback(c=>{$.current=c,le(c.active),c.active&&c.direction!==0?Ve():ue()},[Ve,ue]);r.useEffect(()=>{k||Re()},[Re,k]),r.useEffect(()=>{const c=v=>{const B=v.detail?.paneId;B&&x&&B!==x||Re()};return window.addEventListener(Kt,c),()=>{window.removeEventListener(Kt,c)}},[x,Re]),r.useEffect(()=>{if(!k)return;const c=v=>{if(!$.current.active||$.current.pointerId===v.pointerId)return;const C=v.target;if(!(C instanceof Node)){Re();return}de.current?.getElement()?.contains(C)||Re()};return document.addEventListener("pointerdown",c,!0),()=>{document.removeEventListener("pointerdown",c,!0)}},[Re,k]);const Ie=c=>{if(!Q||Y<=0||H<=0)return 0;const v=ee(c,0,Y);return ee(v/Y*H,0,H)},Ke=r.useCallback(c=>{const{scrollBarVisible:v,effectiveTrackLength:C,maxScrollPosition:B}=W.current;if(R.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:c,trackLen:C,maxScroll:B})),C<=0||B<=0)return null;const pe=ee(c,0,C);return ee(pe/C*B,0,B)},[]),h=r.useCallback(c=>pr(c,p?"x":"y"),[p]),T=r.useCallback(c=>{const v=_.current;if(v.pointerId!==c.pointerId)return;const C=c.clientX-v.startClientX,B=c.clientY-v.startClientY,pe=Je(C,B)/(v.scale||1);R.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:pe,startThumbPosition:v.startThumbPosition,clientY:c.clientY,startClientY:v.startClientY,metrics:W.current}));const ye=Ke(v.startThumbPosition+pe);ye!==null&&X(ye),c.cancelable&&c.preventDefault()},[Je,Ke,X]),se=r.useCallback(c=>{const v=_.current;if(v.pointerId!==c.pointerId)return;document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",se),document.removeEventListener("pointercancel",se);const C=v.captureTarget;if(C?.hasPointerCapture?.(c.pointerId)&&C.releasePointerCapture(c.pointerId),_.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},oe(!1),P.current){const B=P.current.getBoundingClientRect();c.clientX>=B.left&&c.clientX<=B.right&&c.clientY>=B.top&&c.clientY<=B.bottom||te(!1)}else te(!1)},[T]);r.useEffect(()=>()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",se),document.removeEventListener("pointercancel",se)},[T,se]);const Ge=r.useRef(0),Pe=r.useRef(0),Rt=r.useCallback(c=>{const v=Math.max(Math.round(W.current.viewportSize/zr),Nr);Pe.current!==c&&(Pe.current=c,Ge.current=0),ke(Ge,c*v)},[ke]),{handleArrowPointerDown:nt,handleArrowPointerUp:Oe,handleArrowKeyDown:mt}=Yr({canUseArrowButtons:ge,enableArrowButtons:l,resetTapScroll:Re,scrollByStep:Rt}),St=c=>{if(!Q)return;if(!i){c.preventDefault(),c.stopPropagation();return}if(c.pointerType==="mouse"&&c.button!==0||c.ctrlKey)return;Re();const v=c.currentTarget,C=h(v);let B=null;if(v.setPointerCapture)try{v.setPointerCapture(c.pointerId),B=v}catch{B=null}_.current={pointerId:c.pointerId,startThumbPosition:Z,startClientX:c.clientX,startClientY:c.clientY,scale:C,captureTarget:B},document.addEventListener("pointermove",T),document.addEventListener("pointerup",se),document.addEventListener("pointercancel",se),oe(!0),te(!0),c.preventDefault(),c.stopPropagation()},Vt=c=>{if(!Q)return;if(!o){c.preventDefault(),c.stopPropagation();return}if(c.pointerType==="mouse"&&c.button!==0||c.ctrlKey)return;const v=c.currentTarget,C=v.getBoundingClientRect(),B=y(c),pe=h(v),ye=(B-(p?C.left:C.top))/pe;Re();const Ze=ye-M/2,Qe=Ie(Ze);if(X(Qe),v.setPointerCapture)try{v.setPointerCapture(c.pointerId)}catch{}w.current={pointerId:c.pointerId,startThumbPosition:Ze,startClientX:c.clientX,startClientY:c.clientY,scale:pe},c.preventDefault(),c.stopPropagation()},st=()=>{w.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},vt=c=>{const v=w.current;if(v.pointerId!==c.pointerId)return;if(c.pointerType==="mouse"&&c.buttons===0){st();return}const C=c.clientX-v.startClientX,B=c.clientY-v.startClientY,pe=Je(C,B)/(v.scale||1),ye=Ie(v.startThumbPosition+pe);X(ye),c.cancelable&&c.preventDefault()},Dt=c=>{if(w.current.pointerId!==c.pointerId)return;const v=c.currentTarget;v.hasPointerCapture?.(c.pointerId)&&v.releasePointerCapture(c.pointerId),st(),c.preventDefault(),c.stopPropagation()},Pt=c=>{if(w.current.pointerId!==c.pointerId)return;const v=c.currentTarget;v.hasPointerCapture?.(c.pointerId)&&v.releasePointerCapture(c.pointerId),st()},At=c=>{c.target===c.currentTarget&&w.current.pointerId===c.pointerId&&st()},me=r.useMemo(()=>ee((ne?1:.8)*Ce,0,1),[ne,Ce]),pt=r.useMemo(()=>{const v=`calc(50% - ${Ae/2}px + ${Ee}px)`;return{left:He,top:v}},[He,Ee,Ae]),yt=(c,v,C,B)=>q.jsx("button",{type:"button",tabIndex:0,className:"aqvs-scrollbar-arrow-button",style:{[Ue]:d,[Xe]:d},"aria-label":v,onPointerDown:nt(c),onPointerUp:Oe,onPointerLeave:Oe,onPointerCancel:Oe,onKeyDown:mt(c),"aria-disabled":!l,disabled:!ge,children:q.jsx("span",{"aria-hidden":"true",children:C})},B),Et=g&&Q?{orientation:et,scrollPosition:t,maxScrollPosition:H,contentSize:n,viewportSize:e,thumbSize:M,thumbPosition:Z,thumbCenter:Se,trackSize:ze,isDragging:z,isTapScrollActive:ne,visibleStartIndex:D,visibleEndIndex:j}:null;return q.jsxs("div",{className:Mt.twMerge("aqvs-scrollbar",E,b),style:{[Ue]:e,[Xe]:d},"data-visible":Q?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":x,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":H,"aria-orientation":p?"horizontal":"vertical",children:[!p&&Q&&k&&q.jsx(mr,{ref:de,className:Mt.twMerge("aqvs-scrollbar-tap-circle-wrapper",Le),size:Ae,maxVisualDistance:je,style:pt,opacity:me,renderVisual:he,onDragChange:tt},"tap-circle"),yt(-1,dt[0],re[0],"arrow-start"),q.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:d/2},onPointerDown:Vt,onPointerMove:vt,onPointerUp:Dt,onPointerCancel:Pt,onLostPointerCapture:At,"aria-disabled":!o,children:[Et&&q.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:g?.(Et)},"overlay"),q.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[Ue]:M,[ot]:Z,...p?{top:0,bottom:0}:{left:0,right:0}},"data-visible":Q||z?"true":"false",onPointerDown:St,role:"slider","aria-orientation":p?"horizontal":"vertical","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":H,"aria-disabled":!i,tabIndex:-1,children:q.jsx("div",{ref:P,className:Mt.twMerge("aqvs-scrollbar-thumb",p?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":Te,style:{borderRadius:d-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&te(!0)},onMouseLeave:()=>{i&&te(!1)}},"thumb")},"thumb-wrapper")]},"track"),yt(1,dt[1],re[1],"arrow-end")]})},Hr=16,ar=(n,e,t)=>e===1?n*Hr:e===2?n*t:n,qr=(n,e)=>{const t=n.shiftKey&&n.deltaX===0,s=t?n.deltaY:n.deltaX,i=t?0:n.deltaY,o=s!==0&&Math.abs(s)>=Math.abs(i);return{isZoomGesture:n.ctrlKey,isHorizontalDominant:o,horizontalDelta:ar(s,n.deltaMode,e),verticalDelta:ar(i,n.deltaMode,e)}},xr=new WeakSet,lr=n=>{xr.add(n)},Xr=n=>xr.has(n),jr=["mouse","pen","touch"],$t=(n,e)=>!(n==="mouse"||n==="pen"||n==="touch")||e.includes(n),$r=n=>n==="mouse"||n==="pen",Nt={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},Ot=(n,e,t)=>{for(const[s,i,o]of e)t==="add"?n.addEventListener(s,i,o):n.removeEventListener(s,i,o)},Sr=r.forwardRef(({children:n,contentSize:e,viewportSize:t,onViewportSizeChange:s,scrollBarWidth:i=12,enableThumbDrag:o=!0,enableTrackClick:l=!0,enableArrowButtons:p=!0,enablePointerDrag:d=!0,pointerDragInputs:b=jr,onScroll:x,className:I,testId:N,style:g,background:D,tapScrollCircleOptions:j,inertiaOptions:z,itemCount:oe,renderThumbOverlay:ae,wheelSpeedMultiplier:te=1,overscrollBehavior:ne="auto",onWheelHorizontal:le,contentInsets:P,visibleStartIndex:_,visibleEndIndex:w,renderOverlay:K,initialScrollPosition:G=0,contentProps:$},de)=>{const V=r.useRef(Number.isFinite(G)?Math.max(0,G):0),S=r.useRef(null),U=r.useRef(null),ce=t===void 0,[Ye,Be]=r.useState(0),k=t??Ye,Ae=r.useRef(null);r.useLayoutEffect(()=>{if(!ce)return;const m=U.current;if(!m)return;const M=()=>{const Y=m.offsetHeight;if(Y>0){Be(Z=>Z===Y?Z:Y);return}m.offsetParent!==null&&e>0&&Ae.current!=="zero"&&(Ae.current="zero",R.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(M(),typeof ResizeObserver!="function")return;const H=new ResizeObserver(M);return H.observe(m),()=>{H.disconnect()}},[e,ce]),r.useLayoutEffect(()=>{ce&&s?.(Ye)},[ce,Ye,s]),r.useLayoutEffect(()=>{if(ce)return;const m=S.current;if(!m)return;const M=()=>{const Y=m.clientHeight;if(Y<=0||Math.abs(Y-k)<=1)return;const Z=`${k}/${Y}`;Ae.current!==Z&&(Ae.current=Z,R.warn(`[ScrollPane] viewportSize=${k} but the host band is ${Y}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(M(),typeof ResizeObserver!="function")return;const H=new ResizeObserver(M);return H.observe(m),()=>{H.disconnect()}},[ce,k]);const He=r.useRef(le);r.useEffect(()=>{He.current=le},[le]);const Ee=r.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),Le=r.useMemo(()=>({maxVelocity:z?.maxVelocity??Nt.maxVelocity,minVelocity:z?.minVelocity??Nt.minVelocity,deceleration:z?.deceleration??Nt.deceleration,velocitySampleWindow:z?.velocitySampleWindow??Nt.velocitySampleWindow,startVelocityThreshold:z?.startVelocityThreshold??Nt.startVelocityThreshold}),[z]),qe=r.useMemo(()=>({top:Math.max(0,P?.top??0),bottom:Math.max(0,P?.bottom??0)}),[P]);R.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:k,scrollBarWidth:i,className:I,style:g,tapScrollCircleOptions:j,inertiaOptions:z,enablePointerDrag:d,contentInsets:qe}));const Ne=r.useRef({contentSize:e,viewportSize:k}),we=r.useMemo(()=>e>k,[e,k]),Ce=r.useCallback((m,M)=>{let H=M??Ne.current;M&&!(Number.isFinite(M.contentSize)&&Number.isFinite(M.viewportSize))&&(R.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:M}),H=Ne.current);const{contentSize:Y,viewportSize:Z}=H,Se=Y>Z,Q=V.current;if(R.debug("[ScrollPane] scrollTo called",()=>({newPosition:m,contentSize:Y,viewportSize:Z,currentIsScrollable:Se,prevPosition:Q})),!Se)return V.current!==0&&(V.current=0,x?.(0,Q)),V.current;const ge=typeof m=="function"?m(V.current):m;if(!Number.isFinite(ge))return R.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:ge}),V.current;const Te=Math.max(Y-Z,0),X=ee(ge,0,Te);return V.current!==X&&(V.current=X,x?.(X,Q)),V.current},[x]),he=r.useRef(Ce);r.useEffect(()=>{he.current=Ce},[Ce]);const xe=r.useCallback(()=>{const m=Ee.current;m.generation+=1,m.frame!==null&&cancelAnimationFrame(m.frame),m.frame=null,m.velocity=0,m.lastTimestamp=null},[]),W=r.useRef(xe);r.useEffect(()=>{W.current=xe},[xe]),r.useEffect(()=>()=>{W.current()},[]);const Ue=r.useCallback(m=>{if(!we)return;const{maxVelocity:M,minVelocity:H,deceleration:Y,startVelocityThreshold:Z}=Le,Se=ee(m,-M,M);if(Math.abs(Se)<Z)return;xe(),Ee.current.velocity=Se,Ee.current.lastTimestamp=null;const Q=Ee.current.generation,ge=Te=>{const X=Ee.current;if(X.generation!==Q)return;if(X.lastTimestamp===null){X.lastTimestamp=Te,X.frame=requestAnimationFrame(ge);return}const Me=Te-X.lastTimestamp;if(X.lastTimestamp=Te,Me<=0){X.frame=requestAnimationFrame(ge);return}const ke=X.velocity;let ue=ke;const Re=Y*Me;ke>0?ue=Math.max(0,ke-Re):ke<0&&(ue=Math.min(0,ke+Re));const Ve=(ke+ue)/2*Me,tt=V.current;if(Ve!==0&&he.current(Ge=>Ge+Ve),Ee.current.generation!==Q)return;const Ie=V.current,{contentSize:Ke,viewportSize:h}=Ne.current,T=Math.max(Ke-h,0);X.velocity=ue;const se=Ie===tt||Ie<=0&&ue<=0||Ie>=T&&ue>=0;if(Math.abs(ue)<H||se){xe();return}X.frame=requestAnimationFrame(ge)};Ee.current.frame=requestAnimationFrame(ge)},[we,Le,xe]),Xe=r.useRef(Ue);r.useEffect(()=>{Xe.current=Ue},[Ue]),r.useLayoutEffect(()=>{Ne.current={contentSize:e,viewportSize:k}},[e,k]),r.useLayoutEffect(()=>{const m=U.current;if(!m)return;const M=()=>{m.scrollTop!==0&&(R.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:m.scrollTop})),m.scrollTop=0),m.scrollLeft!==0&&(m.scrollLeft=0)};return m.addEventListener("scroll",M),()=>m.removeEventListener("scroll",M)},[]),r.useLayoutEffect(()=>{if(we){R.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:k,scrollPosition:V.current}));const m=ee(e-k,0,e);V.current>m&&Ce(m)}else Ce(0)},[we,Ce,e,k]);const ot=r.useRef({isScrollable:we,viewportSize:k,wheelSpeedMultiplier:te,overscrollBehavior:ne});r.useLayoutEffect(()=>{ot.current={isScrollable:we,viewportSize:k,wheelSpeedMultiplier:te,overscrollBehavior:ne}},[we,k,te,ne]);const Je=r.useCallback(m=>{if(Xr(m))return!1;const{isScrollable:M,viewportSize:H,wheelSpeedMultiplier:Y,overscrollBehavior:Z}=ot.current,Se=qr(m,H);if(Se.isZoomGesture)return!1;if(Se.isHorizontalDominant)return He.current?(lr(m),m.preventDefault(),xe(),He.current(Se.horizontalDelta),!0):!1;if(!M||Se.verticalDelta===0)return!1;let Q=Se.verticalDelta;if(Y!==1&&(Q*=Y),Z!=="contain"){const ge=V.current,Te=Math.max(Ne.current.contentSize-H,0);if(Q>0&&ge>=Te||Q<0&&ge<=0)return!1}return lr(m),m.preventDefault(),xe(),R.debug("[ScrollPane] wheel event",()=>({deltaY:Q,scrollPosition:V.current,wheelSpeedMultiplier:Y,deltaMode:m.deltaMode,scrollTop:U.current?.scrollTop})),Ce(ge=>ge+Q),!0},[Ce,xe]);r.useEffect(()=>{const m=Y=>{Je(Y)},M=()=>{xe()},H=S.current;return H&&(H.addEventListener("wheel",m,{passive:!1}),H.addEventListener("pointerdown",M,{capture:!0,passive:!0})),()=>{H&&(H.removeEventListener("wheel",m),H.removeEventListener("pointerdown",M,{capture:!0}))}},[Je,xe]),r.useImperativeHandle(de,()=>({scrollTo:(m,M)=>(xe(),Ce(m,M)),getScrollPosition:()=>V.current,getContentSize:()=>e,getViewportSize:()=>k,applyWheel:Je}),[Ce,e,k,xe,Je]);const y=r.useId(),dt=$?.id??y,re=r.useRef({pointerType:"",pointerId:null,startClientY:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1}),E=r.useRef(d),et=r.useRef(b);r.useEffect(()=>{E.current=d},[d]),r.useEffect(()=>{et.current=b},[b]);const je=r.useRef(we);r.useEffect(()=>{je.current=we},[we]);const at=r.useRef(Le);r.useEffect(()=>{at.current=Le},[Le]),r.useEffect(()=>{const m=re.current;if(d&&we&&(m.pointerId===null||$t(m.pointerType,b))||m.pointerId===null)return;const M=U.current;m.clickResetTimer!==null&&(window.clearTimeout(m.clickResetTimer),m.clickResetTimer=null);const H=m.isDragging&&m.shouldCancelNextClick,Y=m.pointerId;m.pointerId=null,m.pointerType="",m.startClientY=0,m.startScroll=0,m.isDragging=!1,m.shouldCancelNextClick=H,m.velocitySamples=[],m.scale=1,M?.hasPointerCapture(Y)&&M.releasePointerCapture(Y)},[d,b,we]),r.useEffect(()=>{const m=U.current;if(!m)return;const M=6,H=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),Y=()=>{const h=re.current;h.pointerId=null,h.pointerType="",h.startClientY=0,h.startScroll=0,h.isDragging=!1,h.velocitySamples=[],h.scale=1},Z=()=>{const h=re.current;h.clickResetTimer!==null&&(window.clearTimeout(h.clickResetTimer),h.clickResetTimer=null)},Se=h=>{const T=re.current,se=H();T.velocitySamples.push({clientY:h,time:se});const Ge=at.current.velocitySampleWindow;T.velocitySamples=T.velocitySamples.filter(Pe=>se-Pe.time<=Ge)},Q=h=>h instanceof HTMLElement&&h.closest("[data-scrollpane-ignore-drag='true']")!==null,ge=h=>{const T=re.current;T.shouldCancelNextClick&&(h.preventDefault(),h.stopPropagation(),T.shouldCancelNextClick=!1)},Te=h=>{const T=re.current;if(!T.isDragging){if(T.isDragging=!0,T.shouldCancelNextClick=!0,!m.hasPointerCapture(h.pointerId))try{m.setPointerCapture(h.pointerId)}catch{}Se(h.clientY)}},X=h=>h.isTrusted||h.target===m,Me=h=>{const T=re.current;m.hasPointerCapture(h)&&m.releasePointerCapture(h),T.shouldCancelNextClick=!1,Z(),Y()},ke=h=>{const T=re.current;if(T.pointerId!==h.pointerId)return;if(h.buttons===0&&$r(h.pointerType)){Me(h.pointerId);return}if(!(E.current&&je.current)||!$t(h.pointerType,et.current)||!T.isDragging&&(Math.abs(h.clientY-T.startClientY)<M||(Te(h),!T.isDragging)))return;Se(h.clientY);const se=(h.clientY-T.startClientY)/(T.scale||1),Ge=T.startScroll-se;he.current(Ge),h.cancelable&&h.preventDefault()},ue=()=>{const h=re.current;return h.pointerId!==null||!h.shouldCancelNextClick?!1:(Z(),h.clickResetTimer=window.setTimeout(()=>{const T=re.current;T.shouldCancelNextClick=!1,T.clickResetTimer=null},0),!0)},Re=h=>{const T=re.current;if(T.pointerId!==h.pointerId){ue();return}T.isDragging&&T.shouldCancelNextClick&&h.cancelable&&(h.preventDefault(),h.stopPropagation()),T.isDragging&&Se(h.clientY);let se=0;if(T.isDragging&&T.velocitySamples.length>=2){const Pe=T.velocitySamples,Rt=at.current.velocitySampleWindow,nt=Pe[Pe.length-1],Oe=Pe.find(mt=>nt.time-mt.time<=Rt)??Pe[0];if(nt&&Oe&&nt.time!==Oe.time){const mt=nt.clientY-Oe.clientY,St=nt.time-Oe.time;se=-(mt/St)/(T.scale||1)}}Z(),T.shouldCancelNextClick&&(T.clickResetTimer=window.setTimeout(()=>{const Pe=re.current;Pe.shouldCancelNextClick=!1,Pe.clickResetTimer=null},0));const Ge=at.current.startVelocityThreshold;Y(),m.hasPointerCapture(h.pointerId)&&m.releasePointerCapture(h.pointerId),Math.abs(se)>=Ge&&Xe.current?.(se)},We=h=>{if(re.current.pointerId!==null){if(!h.isPrimary||h.pointerType!==re.current.pointerType)return;Me(re.current.pointerId)}if(re.current.shouldCancelNextClick&&(Z(),re.current.shouldCancelNextClick=!1),!(E.current&&je.current)||!$t(h.pointerType,et.current)||h.button!==0&&h.pointerType==="mouse"||h.ctrlKey||h.metaKey||h.altKey||Q(h.target))return;window.dispatchEvent(new CustomEvent(Kt,{detail:{paneId:y}})),W.current?.();const T=re.current;Z(),T.pointerId=h.pointerId,T.pointerType=h.pointerType,T.startClientY=h.clientY,T.startScroll=V.current,T.scale=pr(m,"y"),T.isDragging=!1,T.shouldCancelNextClick=!1,T.velocitySamples=[]},Ve=h=>{if(re.current.pointerId!==h.pointerId){ue();return}X(h)&&Me(h.pointerId)},Ie=[["click",ge,!0],["pointerdown",We,{passive:!1}],["lostpointercapture",h=>{h.target!==m||re.current.pointerId!==h.pointerId||Me(h.pointerId)},void 0]],Ke=[["pointermove",ke,{passive:!1}],["pointerup",Re,void 0],["pointercancel",Ve,void 0]];return Ot(m,Ie,"add"),Ot(window,Ke,"add"),()=>{Ot(m,Ie,"remove"),Ot(window,Ke,"remove");const h=re.current;h.pointerId!==null&&m.hasPointerCapture(h.pointerId)&&m.releasePointerCapture(h.pointerId),Z(),Y()}},[y]);const ze=r.useCallback(m=>(xe(),Ce(m)),[Ce,xe]);return q.jsxs("div",{ref:S,"data-testid":N,"data-self-measured":ce?"true":void 0,className:Mt.twMerge("aqvs-scroll-pane",I),style:g,children:[q.jsxs("div",{ref:U,className:Mt.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:ce?void 0:k,paddingTop:qe.top,paddingBottom:qe.bottom,...d&&we&&b.some(m=>m==="touch"||m==="pen")?{touchAction:"none"}:{}},...$,id:dt,children:[D,n(V.current)]}),q.jsx(br,{contentSize:e,viewportSize:k,scrollPosition:V.current,onScroll:ze,enableThumbDrag:o,enableTrackClick:l,enableArrowButtons:p,scrollBarWidth:i,ariaControls:dt,tapScrollCircleOptions:j,itemCount:oe,renderThumbOverlay:ae,visibleStartIndex:_,visibleEndIndex:w},"scrollbar"),K?.()]})}),cr=(n,e,t)=>Math.min(Math.max(n,e),t),Ur=({dragState:n,normalizedDistance:e,sizeScale:t,size:s})=>{const i=Math.max(s/2,1),o=1+e*.65,l=Math.max(.65,1-e*.25),p=n.direction*e*26*t,d=.8+e*.18,b=3*t,x=6*t,I=22*t,N=Math.abs(p)+x,g=p>0?b:-Math.abs(p)-b,D=Math.max(2.5,3*t),j=cr(n.offsetX,-i,i),z=cr(n.offsetY,-i,i),oe=i*.35,ae=j/i*oe,te=z/i*oe,ne=ae*.45,le=te*.45,P=Math.max(I*.38,6),_=.65+e*.2,w=n.active;return q.jsxs(q.Fragment,{children:[q.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${l}, ${o})`,transition:w?"40ms transform ease-out":"200ms ease transform"}}),q.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:I,height:I,transform:`translate(calc(-50% + ${ae}px), calc(-50% + ${te}px)) scale(${l}, ${d*o})`,transition:w?"70ms transform ease-out":"200ms ease transform"}}),q.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:P,height:P,transform:`translate(calc(-50% + ${ne}px), calc(-50% + ${le}px)) scale(${l}, ${o})`,opacity:_,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:w?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),q.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:D,height:N,transform:`translate(-50%, ${g}px)`,opacity:e,transition:w?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},_t=100,Wr=n=>{if(!Number.isFinite(n))return 0n;const e=Math.trunc(n);return e<=0?0n:BigInt(e)},Ut=(n,e)=>{if(!Number.isFinite(n))throw new Error(`valueFn returned a non-finite value at index ${e}: ${n}`);return n},Tt=n=>{if(n<=0||!Number.isFinite(n))return 0;const e=Math.trunc(n);if(e<=2147483647)return e&-e;const t=BigInt(e)&-BigInt(e);return Number(t)};class ft{tree;deltas;size;baseValue;valueFn;total;constructor(e,t,s){this.reset(e,t,s)}reset(e,t,s){const i=Number.isFinite(e)&&e>0?Math.trunc(e):0;if(typeof t!="function"){this.size=i,this.tree=new Map,this.deltas=new Map,this.valueFn=void 0,this.baseValue=t,this.total=this.baseValue*this.size;return}let o=0,l;if(i>0){const p=s?.sampleRange??{from:0,to:Math.min(_t-1,i-1)};let d=Math.max(0,Math.trunc(p.from)),b=Math.min(Math.trunc(p.to),i-1);if(d>b&&(d=0,b=Math.min(_t-1,i-1)),i>_t)o=ft._sampleBaseValueStrided(t,i,_t),s?.materialize&&(l={from:d,values:ft._collectValidatedValues(t,d,b)});else{const x=ft._collectValidatedValues(t,d,b);o=ft._modeOrMedian([...x]),s?.materialize&&(l={from:d,values:x})}}if(this.size=i,this.tree=new Map,this.deltas=new Map,this.total=void 0,this.valueFn=t,this.baseValue=o,l)for(let p=0;p<l.values.length;p++){const d=l.from+p;if(d>=this.size)break;const b=l.values[p]-this.baseValue;b!==0&&(this.deltas.set(d,b),this._updateTree(d,b))}this.total=this.getTotal()}setValueFn(e,t){if(t?.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,t,s){const i=[];for(let o=t;o<=s;o++)i.push(Ut(e(o),o));return i}static _modeOrMedian(e){if(e.length===0)return 0;e.sort((l,p)=>l-p);const t=Math.floor(e.length/2);let s;e.length%2===0?s=Math.floor((e[t-1]+e[t])/2):s=e[t];const i=new Map;let o=0;for(const l of e){const p=(i.get(l)??0)+1;i.set(l,p),p>o&&(o=p)}if(o>e.length*.2){const l=[];for(const[d,b]of i.entries())b===o&&l.push(d);const p=l.reduce((d,b)=>d+b,0);s=Math.floor(p/l.length)}return s}static _sampleBaseValueStrided(e,t,s){if(t<=0)return 0;let i=Math.max(1,Math.ceil(t/s));i%2===0&&(i+=1);const o=[];for(let l=0;l<t&&o.length<s;l+=i)o.push(Ut(e(l),l));return ft._modeOrMedian(o)}update(e,t){return this.updates([{index:e,value:t}])}updates(e){const t=this._buildDeltaUpdates(e);return t.length>0?this.updateDeltas(t):this.total}updateDelta(e,t){return this.updateDeltas([{index:e,change:t}])}updateDeltas(e){const t=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 l=(t.get(s)??this.deltas.get(s)??0)+i;if(l+this.baseValue<-1e-9)throw new Error(`Change would make the value at index ${s} negative: ${l+this.baseValue}`);t.set(s,l)}for(const{index:s,change:i}of e){const l=(this.deltas.get(s)??0)+i;l===0?this.deltas.delete(s):this.deltas.set(s,l),this._updateTree(s,i)}return this.total}_updateTree(e,t){if(t===0)return;let s=e+1;for(;s<=this.size;){this.tree.set(s,(this.tree.get(s)??0)+t);const i=Tt(s);if(i===0)break;s+=i}this.total!==void 0&&(this.total+=t)}_buildDeltaUpdates(e){const t=[],s=new Map;for(const{index:i,value:o}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(o))throw new Error(`Value must be a finite number: ${o}`);if(o<0)throw new Error("Value cannot be negative.");const l=s.has(i)?s.get(i)??0:this.deltas.get(i)??0,p=l+this.baseValue,d=o-p;d!==0&&t.push({index:i,change:d}),s.set(i,l+d)}return t}_computeTreeTotal(){if(this.size<=0)return 0;let e=0,t=this.size;for(;t>0;){e+=this.tree.get(t)??0;const s=Tt(t);if(s===0)break;t-=s}return e+this.baseValue*this.size}_materialize(e,t=!0){if(this.valueFn){const s=this.deltas.get(e)??0,o=Ut(this.valueFn(e),e)-this.baseValue;if(o!==s&&(o===0?this.deltas.delete(e):this.deltas.set(e,o),t)){const l=o-s;this._updateTree(e,l)}}}_materializeRanges(e,t,s=!1){if(!(e?.materialize&&this.valueFn))return;const i=e.ranges;if(i&&i.length>0){for(const p of i){const d=Math.max(0,Math.trunc(p.from)),b=Math.min(Math.trunc(p.to),this.size-1);for(let x=d;x<=b;x++)this._materialize(x)}if(t===void 0)return;if(s){this._materialize(t);return}const o=i[0].from,l=i[i.length-1].to;t>=o&&t<=l&&this._materialize(t);return}t!==void 0&&this._materialize(t)}_findIndex(e,t={},s){if(this.size>=1073741824)return this._findIndexLarge(e,t,s);if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(t.materializeOption);const i=t.materializeOption?.materialize===!0;let o;for(;;){if(o=this._descend(e,s),o<0||o>=this.size)return{index:-1,total:this.total??this.getTotal(),cumulative:void 0,currentValue:void 0,safeIndex:void 0};if(!i)break;const p=this.deltas.get(o)??0;if(this._materialize(o),(this.deltas.get(o)??0)===p)break}const l=this.prefixSum(o);return{index:o,total:this.total??l.total,cumulative:l.cumulative,currentValue:l.currentValue,safeIndex:l.safeIndex}}_descend(e,t){let s=0,i=0,o=1;for(;o<<1<=this.size;)o<<=1;for(;o>0;o>>=1){const l=s+o;if(l<=this.size){const d=(this.tree.get(l)??0)+this.baseValue*o;(t?i+d<e:i+d<=e)&&(s=l,i+=d)}}return t?s:s-1}_findIndexLarge(e,t,s){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};const i=Wr(this.size);if(i===0n)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(t.materializeOption);const o=t.materializeOption?.materialize===!0;for(;;){let l=0n,p=i-1n,d,b,x=this.total;for(;l<=p;){const g=l+p>>1n,D=Number(g),j=this.prefixSum(D);if(x=j.total,s?j.cumulative>=e:j.cumulative<=e)if(d=g,b=j,s){if(g===0n)break;p=g-1n}else l=g+1n;else if(s)l=g+1n;else{if(g===0n)break;p=g-1n}}const I=b,N=d!==void 0?Number(d):-1;if(o&&N>=0){const g=this.deltas.get(N)??0;if(this._materialize(N),(this.deltas.get(N)??0)!==g)continue}return{index:N,total:x,cumulative:I?.cumulative,currentValue:I?.currentValue,safeIndex:I?.safeIndex}}}prefixSum(e,t){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=ee(Math.trunc(e),0,this.size-1),i=t?.materializeOption;this._materializeRanges(i,s,!0);let o=0,l=s+1;for(;l>0;){const d=this.tree.get(l)??0;o+=d;const b=Tt(l);if(b===0)break;l-=b}const p=i?.materialize?this.get(s):(this.deltas.get(s)||0)+this.baseValue;return{cumulative:o+this.baseValue*(s+1),total:this.total,currentValue:p,safeIndex:s}}get(e,t){if(this.size===0)return 0;if(!Number.isInteger(e)||e<0||e>=this.size)throw new Error("Index out of bounds");const s=t?.materializeOption;return this._materializeRanges(s,e),(this.deltas.get(e)??0)+this.baseValue}getTotal(e){const t=e?.materializeOption;if(this._materializeRanges(t),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&&R.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 t=new Map;for(const[s,i]of this.deltas.entries()){if(i===0)continue;let o=s+1;for(;o<=this.size;){t.set(o,(t.get(o)??0)+i);const l=Tt(o);if(l===0)break;o+=l}}this.tree=t,this.total=this._computeTreeTotal()}calculateAccumulatedError(){if(this.total===void 0)return 0;let e=this.baseValue*this.size;for(const[t,s]of this.deltas)t<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 t=Math.max(0,Math.trunc(e)),s=this.size;if(t===s)return;if(t>s)if(s===0&&this.deltas.size>0){for(const o of this.deltas.keys())o>=t&&this.deltas.delete(o);this.size=t,this.rebuildTree()}else this._growSize(s,t);else{if(t>0)for(const o of this.deltas.keys())o>=t&&this.deltas.delete(o);this.size=t,this.rebuildTree()}const i=this.prefixSum(this.getSize()-1);i.cumulative!==i.total&&R.error("Inconsistent Fenwick Tree state")}static _minCoveredLowBound(e,t){let s=1;for(;;){const i=s*2;if(Math.floor(t/i)*i<=e)break;s=i}return s*Math.floor(e/s)}_propagateDeltaToGrownNodes(e,t,s,i){let o=e+1;for(;o<=s;){const l=Tt(o);if(l===0)break;o+=l}for(;o<=i;){this.tree.set(o,(this.tree.get(o)??0)+t);const l=Tt(o);if(l===0)break;o+=l}}_growSize(e,t){if(this.size=t,this.deltas.size>0){const s=ft._minCoveredLowBound(e,t);if(e-s<this.deltas.size)for(let o=s;o<e;o++){const l=this.deltas.get(o);l===void 0||l===0||this._propagateDeltaToGrownNodes(o,l,e,t)}else for(const[o,l]of this.deltas.entries())l===0||o<s||this._propagateDeltaToGrownNodes(o,l,e,t)}this.total=this._computeTreeTotal()}getSize(){return this.size}get base(){return this.baseValue}findIndexAtOrAfter(e,t){return this._findIndex(e,t??{},!0)}findIndexAtOrBefore(e,t){return this._findIndex(e,t??{},!1)}}const Kr=(n,e)=>{const t=n?.sampleRange,s=e?.sampleRange;return t===s?!1:t&&s?t.from!==s.from||t.to!==s.to:!0},vr=(n,e,t)=>{const s=Number.isFinite(n)&&n>0?Math.trunc(n):0,i=r.useRef(null),o=r.useRef({size:s,valueOrFn:e,options:t});i.current===null&&(i.current=new ft(s,e,t));const l=i.current,p=o.current,d=p.size!==s,b=p.valueOrFn!==e,x=Kr(p.options,t),I=p.size===0&&s>0&&(!i.current||i.current.base===0);if(b||x){const N=t?.resetOnValueFnChange??!0;x||b&&N||I?(t?.debug&&R.debug("[useFenwickMapTree] reset",{valueOrFnChanged:b,optionsChanged:x}),l.reset(s,e,t)):(d&&(t?.debug&&R.debug("[useFenwickMapTree] resize (with valueFn change)",{from:p.size,to:s}),l.changeSize(s)),t?.debug&&R.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:b}),l.setValueFn(e,{reset:!1})),o.current={size:s,valueOrFn:e,options:t}}else d&&(t?.debug&&R.debug("[useFenwickMapTree] resize",{from:p.size,to:s}),I?l.reset(s,e,t):l.changeSize(s),o.current={size:s,valueOrFn:e,options:t});return l};class Gr{key;value;prev=null;next=null;constructor(e,t){this.key=e,this.value=t}}class Wt{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 Ir(n){const e=r.useRef(new Map),t=r.useRef(new Wt),s=Math.floor(n),i=r.useRef(s);r.useEffect(()=>{if(i.current=s,Number.isNaN(s)||s<0){R.warn(`useLruCache: invalid capacity ${n}; the cache will not store any entries.`),e.current.clear(),t.current=new Wt;return}if(Number.isFinite(s))for(;e.current.size>s;){const x=t.current.removeHead();if(x)e.current.delete(x.key);else break}},[n,s]);const o=r.useCallback(x=>{const I=e.current.get(x);if(I)return t.current.moveToTail(I),I.value},[]),l=r.useCallback((x,I)=>{const N=i.current;if(Number.isNaN(N)||N<=0)return;let g=e.current.get(x);if(g)g.value=I,t.current.moveToTail(g);else{if(e.current.size>=N){const D=t.current.removeHead();D&&e.current.delete(D.key)}g=new Gr(x,I),e.current.set(x,g),t.current.addToTail(g)}},[]),p=r.useCallback(x=>e.current.has(x),[]),d=r.useCallback(x=>{const I=e.current.get(x);I&&(t.current.remove(I),e.current.delete(x))},[]),b=r.useCallback(()=>{e.current.clear(),t.current=new Wt},[]);return r.useMemo(()=>({get:o,set:l,has:p,remove:d,clear:b}),[o,l,p,d,b])}const Zr=1e4,Qr=()=>{const{get:n,set:e,has:t,clear:s}=Ir(Zr);return r.useMemo(()=>({get:n,set:e,has:t,clear:s}),[n,e,t,s])},Jr=(n,e)=>{const t=r.useRef(e),s=r.useRef(n);r.useLayoutEffect(()=>{t.current=e,s.current=n},[e,n]);const i=r.useRef(new WeakMap);return r.useCallback(o=>{if(!o||i.current.has(o))return;const l=p=>{t.current?.enableBridge!==!1&&s.current.current?.applyWheel(p)};return o.addEventListener("wheel",l,{passive:!1}),i.current.set(o,l),()=>{i.current.get(o)===l&&(o.removeEventListener("wheel",l),i.current.delete(o))}},[])},be=(n,e)=>e<=0?0:ee(n,0,e-1),ur=n=>({top:Math.max(0,n?.top??0),bottom:Math.max(0,n?.bottom??0)}),$e=(n,e)=>n<=e?0:n-e,xt=(n,e)=>n<=0?0:n+e,Ft=1e3,fr=2e3,en=1048576,tn=40,zt=n=>{if(!Number.isFinite(n))return 0n;const e=Math.trunc(n);return e<=0?0n:BigInt(e)},rn=(n,e,t,s,i,o,l,p)=>{const d=zt(s);if(d===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const b=P=>P<0n?0n:P>=d?d-1n:P,x={materializeOption:{materialize:!1}},{index:I,cumulative:N}=o.findIndexAtOrAfter(n,x);let g;I===-1?g=d-1n:(N===n?g=zt(I+1):g=zt(I),g>=d&&(g=d-1n)),n<=0&&(g=0n),p&&n>=l&&(g=d-1n);const D=P=>{const _=Number(P);if(!Number.isSafeInteger(_))return null;const{cumulative:w}=o.prefixSum(_,{materializeOption:{materialize:!1}});if(!Number.isFinite(w))return null;const{index:K}=o.findIndexAtOrAfter(w+.5,{materializeOption:{materialize:!1}});if(K===-1)return null;const G=zt(K);return G>P?G:null},j=P=>{let _=0,w=P,K=P,G=0n,$=0;for(;w<d&&_<e;){const de=Number(w),V=i(de);if(_+=V,K=w,w+=1n,G+=1n,!Number.isFinite(V)||V<0)break;if(V===0){if($+=1,$>Ft){const S=D(K);if(S!==null&&S>w)w=S,$=0;else if(S!==null&&S===w&&i(Number(w))>0)$=0;else break}}else $=0}return G===0n&&(K=P),{height:_,end:K}};let{height:z,end:oe}=j(g);if(z<e&&g>0n){let P=g,_=z,w=0;for(;P>0n&&_<e;){P-=1n;const G=Number(P),$=i(G);if(_+=$,!Number.isFinite($)||$<0)break;if($===0){if(w+=1,w>Ft){const de=Number(P);if(!Number.isSafeInteger(de))break;const{cumulative:V}=o.prefixSum(de,{materializeOption:{materialize:!1}});if(!Number.isFinite(V))break;const{index:S}=o.findIndexAtOrAfter(V-.5,{materializeOption:{materialize:!1}}),U=S===-1?-1n:zt(S);if(U>=0n&&U<P)P=U+1n,w=0;else if(U===P&&P>=1n&&i(Number(P-1n))>0)w=0;else break}}else w=0}g=b(P);const K=j(g);z=K.height,oe=K.end}const ae=b(g),te=b(oe),ne=b(ae-BigInt(Math.max(0,t))),le=b(te+BigInt(Math.max(0,t)));return{renderingStartIndex:be(Number(ne),s),renderingEndIndex:be(Number(le),s),visibleStartIndex:be(Number(ae),s),visibleEndIndex:be(Number(te),s)}},nn=(n,e,t,s,i,o,l)=>{if(s===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const p=Number.isFinite(l),d=p?Math.min(Math.max(0,n),l):Math.max(0,n);if(s>=Number.MAX_SAFE_INTEGER)return rn(d,e,t,s,i,o,l,p);const{index:b,cumulative:x,currentValue:I}=o.findIndexAtOrAfter(d,{materializeOption:{materialize:!1}}),N=b===-1?e<=0||(x??0)<d+(I??0)?s-1:0:b;let g=be(N,s),D=0;if(b!==-1&&x===d)g=be(b+1,s),D=0;else if(g===b&&x!==void 0&&I!==void 0)D=x-I-d;else{const{cumulative:P,currentValue:_}=o.prefixSum(g,{materializeOption:{materialize:!1}});D=(P??0)-(_??0)-d}const j=D,z=(P,_)=>{let w=P,K=_,G=0;for(;w<s&&K<e;){const $=i(w);if(K+=$,w++,!Number.isFinite($)||$<0)break;if($===0){if(G++,G>Ft){const{cumulative:de}=o.prefixSum(w-1,{materializeOption:{materialize:!1}}),{index:V}=Number.isFinite(de)?o.findIndexAtOrAfter(de+.5,{materializeOption:{materialize:!1}}):{index:-1};if(V>w)w=V,G=0;else if(V===w&&i(w)>0)G=0;else break}}else G=0}return{cursor:w,height:K}},oe=z(g,D);let ae=oe.cursor;if(D=oe.height,D<e&&g>0){let P=D+Math.abs(Math.min(0,j)),_=g-1,w=0;for(;_>=0&&P<e;){const G=i(_);if(P+=G,!Number.isFinite(G)||G<0){_--;break}if(G===0){if(w++,w>Ft){const{cumulative:$}=o.prefixSum(_,{materializeOption:{materialize:!1}}),{index:de}=Number.isFinite($)?o.findIndexAtOrAfter($-.5,{materializeOption:{materialize:!1}}):{index:-1};if(de!==-1&&de<_){_=de,w=0;continue}if(de===_&&_>=1&&i(_-1)>0)w=0;else{_--;break}}}else w=0;_--}g=be(_+1,s);const K=z(g,0);ae=K.cursor,D=K.height}const te=be(g-t,s),ne=be(Math.max(ae-1,g),s),le=be(ne+t,s);return{renderingStartIndex:te,renderingEndIndex:le,visibleStartIndex:g,visibleEndIndex:ne}},dr=(n,e,t)=>{const s=Math.max(0,e??0),i=r.useRef({last:0,id:null,arg:null}).current;return r.useEffect(()=>()=>{if(i.id!==null&&(cancelAnimationFrame(i.id),i.id=null),i.arg!==null&&n.current){try{t(n.current,i.arg)}catch(o){console.error("[useThrottledInvoker] Error flushing pending callback on unmount",o)}i.arg=null}},[i,n,t]),r.useCallback(o=>{if(i.arg=o,i.id!==null)return;const l=p=>{if(i.id=null,i.arg===null)return;const d=p-i.last;if(s===0||i.last===0||d>=s){if(n.current)try{t(n.current,i.arg)}catch(b){console.error("[useThrottledInvoker] Error invoking callback",b)}i.arg=null,i.last=p}i.arg!==null&&(i.id=requestAnimationFrame(l))};i.id=requestAnimationFrame(l)},[s,t,n,i])},sn=r.memo(({index:n,top:e,height:t,item:s,children:i,clipItemHeight:o,enableKeyboardNavigation:l,onKeyDown:p,onEscapeKeyDown:d,onFocus:b,registerItemRef:x})=>{const I=r.useCallback(z=>x(n,z),[n,x]),N=r.useCallback(z=>p(z,n),[n,p]),g=r.useCallback(z=>d?.(z,n),[n,d]),D=r.useCallback(()=>b(n),[n,b]),j=r.useCallback(z=>{z.currentTarget.focus({preventScroll:!0})},[]);return q.jsx("div",{ref:I,"data-index":n,"data-virtualscroll-item":"true",className:"aqvs-item-container",style:{top:e,height:t,overflow:o?"hidden":void 0},tabIndex:l?-1:void 0,onPointerDown:l?j:void 0,onKeyDownCapture:l?N:void 0,onKeyDown:l&&d?g:void 0,onFocusCapture:l?D:void 0,children:i(s,n)})}),on=({itemCount:n,getItem:e,getItemKey:t,getItemHeight:s,viewportSize:i,overscanCount:o=15,className:l,testId:p,onScroll:d,onRangeChange:b,children:x,background:I,initialScrollIndex:N,initialScrollOffset:g,initialScrollAnchor:D,callbackThrottleMs:j=5,contentInsets:z,onItemFocus:oe,scrollBarOptions:ae,behaviorOptions:te,onWheelHorizontal:ne,horizontalKeyInputs:le,horizontalKeyStep:P=tn,contentProps:_,liveRegion:w},K)=>{const{width:G,enableThumbDrag:$,enableTrackClick:de,enableArrowButtons:V,enableScrollToTopBottomButtons:S,renderThumbOverlay:U,tapScrollCircleOptions:ce}=ae??{},{enablePointerDrag:Ye,pointerDragInputs:Be,enableKeyboardNavigation:k=!0,enableEscapeRowReturn:Ae=!1,wheelSpeedMultiplier:He,inertiaOptions:Ee,overscrollBehavior:Le,clipItemHeight:qe=!1,resetOnGetItemHeightChange:Ne=!1}=te??{},[we,Ce]=r.useState(0),he=i??we,xe=r.useCallback(a=>{Ce(u=>u===a?u:a)},[]),W=r.useRef(null),Ue=r.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),Xe=r.useRef(D&&n>0?{index:ee(Math.trunc(D.index),0,n-1),align:"top",offset:-Math.max(0,D.offsetPx??0)}:null),ot=r.useRef(!1),Je=r.useRef(!0);r.useEffect(()=>{if(Je.current){Je.current=!1;return}Ne&&(Xe.current=null)},[Ne,s]);const y=r.useMemo(()=>ur(z),[z]),[dt]=r.useState(()=>{const u=D?.index??N,f=typeof u=="number"&&Number.isFinite(u)?Math.max(0,Math.trunc(u)):0;return{from:Math.max(0,f-50),to:f+50}}),re=r.useMemo(()=>({sampleRange:dt,resetOnValueFnChange:Ne,materialize:!0}),[Ne,dt]),E=vr(n,s,re),[et]=r.useState(()=>{let a=0,u=0;if(D&&n>0){const f=ee(Math.trunc(D.index),0,n-1),A=Math.max(0,D.offsetPx??0),L=ee(f-o*2,0,n-1),O=ee(f+o*2,0,n-1),F=f>0||A>0?{materializeOption:{materialize:!0,ranges:[{from:L,to:O}]}}:void 0,{cumulative:J,total:ve,currentValue:fe}=E.prefixSum(f,F),ie=Math.max(J-fe+A,0);a=xt(ie,y.top),u=ve??E.getTotal()}else if(typeof N=="number"){const f=ee(N,0,n-1),A=ee(f-o*2,0,n-1),L=ee(f+o*2,0,n-1),O=N>0?{materializeOption:{materialize:!0,ranges:[{from:A,to:L}]}}:void 0,{cumulative:F,total:J,currentValue:ve}=E.prefixSum(N,O),fe=Math.max(F-ve,0);a=xt(fe,y.top),u=J??E.getTotal()}else typeof g=="number"&&(a=xt(Math.max(g,0),y.top)),u=E.getTotal();return{position:a,total:u}}),[je,at]=r.useState(et.position),[ze,m]=r.useState(et.total),M=r.useRef(et.position),H=r.useRef(y.top),Y=r.useRef(d??void 0),Z=r.useRef(b??void 0),Se=r.useRef(ne),Q=(le?.length??0)>0,ge=!!ne;r.useEffect(()=>{Q&&(k||R.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),ge||R.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||R.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${P}. Horizontal arrow keys are left untouched.`))},[Q,ge,k,P]);const Te=r.useRef(new Map),X=r.useRef(null),Me=r.useRef(null),[ke,ue]=r.useState(null),[Re,We]=r.useState(!1),Ve=r.useRef(null),tt=r.useRef(!1),Ie=r.useRef(0),Ke=r.useRef(!1),h=r.useRef(!1),T=r.useRef(n);T.current!==n&&(T.current=n,h.current=!0),r.useLayoutEffect(()=>{Y.current=d??void 0,Z.current=b??void 0,Se.current=ne},[b,d,ne]);const se=r.useCallback(a=>{if(k&&a&&typeof a.focus=="function")try{a.focus({preventScroll:!0})}catch{a.focus()}},[k]),Ge=r.useCallback((a,{position:u,totalHeight:f})=>{a(u,f)},[]),Pe=dr(Y,j,Ge),Rt=r.useCallback((a,u)=>{a(u)},[]),nt=dr(Z,j,Rt),Oe=r.useRef(y.top);Oe.current=y.top;const mt=r.useRef(Pe);mt.current=Pe,r.useEffect(()=>(ot.current=!1,()=>{ot.current=!0,Ve.current&&(clearTimeout(Ve.current),Ve.current=null)}),[]),r.useEffect(()=>{k||(Te.current.clear(),X.current=null,Me.current=null)},[k]);const St=r.useCallback((a,u)=>{if(!u){Te.current.delete(a);return}k&&(Te.current.set(a,u),X.current===a&&(X.current=null,Me.current=a,se(u)))},[k,se]),Vt=.01,st=r.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:et.position}),vt=r.useCallback(()=>{const a=st.current;a.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(a.rafId),a.rafId=null,a.loopActive=!1,a.idleFrames=0},[]);r.useEffect(()=>()=>{vt()},[vt]);const Dt=r.useRef(()=>{}),Pt=r.useCallback(()=>{const a=st.current;a.rafId=null;const u=M.current,f=$e(u,Oe.current),A=E.getTotal();if(at(O=>Math.abs(O-u)<Vt?O:u),Math.abs(a.lastRenderedPosition-u)>=Vt?(mt.current({position:f,totalHeight:A}),a.lastRenderedPosition=u,a.idleFrames=0):a.idleFrames+=1,a.idleFrames>=2){vt();return}if(typeof requestAnimationFrame=="function"){a.rafId=requestAnimationFrame(O=>Dt.current(O));return}a.loopActive=!1},[E,vt]);Dt.current=Pt;const At=r.useCallback(()=>{const a=st.current;if(a.idleFrames=0,!a.loopActive){if(a.loopActive=!0,typeof requestAnimationFrame=="function"){a.rafId=requestAnimationFrame(Pt);return}a.loopActive=!1}},[Pt]),me=r.useCallback((a,u)=>{const f=u?.immediate??!1,A=$e(a,y.top);if(M.current=a,f){st.current.lastRenderedPosition=a,st.current.idleFrames=0,at(a),Pe({position:A,totalHeight:E.getTotal()});return}At()},[At,E,y.top,Pe]),pt=r.useCallback((a,u=0)=>{const f=W.current;if(!f)return a;const A=f.getScrollPosition();Ie.current+=1;const L=f.getContentSize()+u,O=f.getViewportSize(),F=f.scrollTo(a,{contentSize:L,viewportSize:O});return F===A&&(Ie.current=Math.max(0,Ie.current-1)),Math.abs(F-a)>.5&&(Ke.current=!0),F},[]),yt=r.useRef(!1);r.useEffect(()=>{if(!yt.current)if(yt.current=!0,D==null&&typeof N!="number"&&typeof g=="number"){const a=xt(Math.max(g,0),y.top),u=Math.abs(a-M.current)>.5;me(a,{immediate:!0}),u&&W.current?.scrollTo(a)}else me(M.current,{immediate:!0})},[D,N,g,y.top,me]),r.useEffect(()=>{const a=E.getTotal();if(ze!==a){m(a);return}if(Ke.current){Ke.current=!1;const u=W.current;if(u&&Math.abs(u.getScrollPosition()-M.current)>.5){const f=pt(M.current);Ke.current=!1,me(f,{immediate:!0})}}},[E,ze,n,pt,me]),r.useEffect(()=>{if(Xe.current!==null){const{index:a,align:u,offset:f}=Xe.current,A=be(a,n),{cumulative:L,currentValue:O}=E.prefixSum(A,{materializeOption:{materialize:!1}});if(L!==void 0&&O!==void 0){const F=Math.max(L-O,0);let J=F;u==="bottom"?J=L-he:u==="center"&&(J=F+O/2-he/2),f&&(J-=f),J=Math.max(0,J);const ve=Math.max(0,ze+y.top+y.bottom-he),fe=Math.min(xt(J,y.top),ve);Math.abs(fe-M.current)>1&&(R.debug("[VirtualScroll] Drift correction",{from:M.current,to:fe,targetIndex:A}),Ie.current===0&&(Ie.current+=1),W.current?.scrollTo(fe),me(fe,{immediate:!0}))}}h.current=!1},[ze,E,n,y.top,me,he,y.bottom]),r.useEffect(()=>{const a=H.current;if(a===y.top||(H.current=y.top,Xe.current))return;const u=$e(M.current,a),f=xt(u,y.top);M.current=f,W.current?.scrollTo(f),me(f,{immediate:!0})},[y.top,me]);const Et=r.useCallback((a,u)=>{if(n===0)return;const f=be(a,n),A=E.get(f),L=u-A,O=E.update(f,u);O!==void 0&&m(O),R.debug("[VirtualScroll] Updated item size manually",{index:f,size:u,total:O});let F=Xe.current?Xe.current.index:null;if(F===null){const J=M.current,ve=ur(z).top,fe=$e(J,ve),{index:ie,cumulative:_e}=E.findIndexAtOrAfter(fe,{materializeOption:{materialize:!1}});F=_e!==void 0&&_e===fe?ie+1:ie}if(F!==-1&&f<F&&L!==0){const J=M.current,ve=J+L;pt(ve,L),me(ve,{immediate:!0}),R.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:J,to:ve,causedByIndex:f,delta:L,activeVisibleStartIndex:F})}},[E,n,pt,me,z]),c=r.useCallback((a,u)=>{if(!W.current||n===0)return;const f=be(a,n),A=be(f-o*2,n),L=be(f+o*2,n),{cumulative:O,total:F,currentValue:J}=E.prefixSum(f,{materializeOption:{materialize:!0,ranges:[{from:A,to:L}]}});if(R.debug("[VirtualScroll] Scrolling to index:",f,"ItemBottom:",O,"Total height:",F,"ItemHeight:",J,"safeIndexFrom:",A,"safeIndexTo:",L),!F)return;const ve=Math.max(O-J,0);let fe=ve;u?.align==="bottom"?fe=O-he:u?.align==="center"&&(fe=ve+J/2-he/2),u?.offset&&(fe-=u.offset),fe=Math.max(0,fe);const ie=xt(fe,y.top),_e=W.current?.getContentSize()??F+y.top+y.bottom,De=Math.max(0,_e-he),Fe=Math.min(ie,De);Xe.current={index:f,align:u?.align,offset:u?.offset};const kt=W.current?.getScrollPosition()??-1,qt=Math.abs(kt-Fe)>.5;tt.current=!1,Ie.current=0,qt&&(tt.current=!0,Ie.current+=1,W.current?.scrollTo(Fe)),m(F),me(Fe,{immediate:!0}),R.debug("[VirtualScroll] Setting scroll position to:",Fe,{original:ie,max:De})},[E,o,n,y.top,y.bottom,he,me]),v=r.useRef(D&&n===0?D:null);r.useEffect(()=>{const a=v.current;!a||n===0||(v.current=null,c(ee(Math.trunc(a.index),0,n-1),{align:"top",offset:-Math.max(0,a.offsetPx??0)}))},[n,c]);const C=r.useCallback(a=>{if(!W.current||n===0)return;const u=E.getTotal(),f=ee(Math.floor(a),0,u),{index:A,cumulative:L,currentValue:O}=E.findIndexAtOrAfter(f,{materializeOption:{materialize:!1}}),J=(L??0)-(O??0)-f;c(A,{offset:J})},[E,n,c]),B=r.useCallback(()=>{if(n===0)return null;const a=$e(M.current,y.top),{index:u,cumulative:f,currentValue:A}=E.findIndexAtOrAfter(a,{materializeOption:{materialize:!1}});if(u===-1)return{index:n-1,offsetPx:0};if(f===a)return{index:ee(u+1,0,n-1),offsetPx:0};const L=(f??0)-(A??0);return{index:u,offsetPx:Math.max(0,a-L)}},[E,n,y.top]),pe=r.useCallback(a=>{const u=$e(M.current,y.top),f=typeof a=="function"?a(u):a;C(f);const A=W.current?.getScrollPosition(),L=typeof A=="number"?A:M.current;return me(L),$e(L,Oe.current)},[y.top,C,me]),ye=r.useCallback(a=>{const u=W.current;if(!u)return $e(M.current,Oe.current);const f=u.scrollTo(A=>A+a);return $e(f,Oe.current)},[]),Ze=r.useCallback(a=>W.current?.applyWheel(a)??!1,[]),Qe=r.useCallback((a,u)=>{R.debug("[VirtualScroll] Scroll position changed:",a);const f=tt.current;f&&(tt.current=!1);const A=Ie.current>0;A&&(Ie.current=0);const L=h.current&&T.current===n;if(f||A||L||(Xe.current=null),me(a),S){if(f||A)return;const O=a-u;if(R.debug("[VirtualScroll] Scroll diff:",O,"New:",a,"Prev:",u),Math.abs(O)>1){const F=O>0?"down":"up";ue(F),We(!0),R.debug("[VirtualScroll] Showing scroll buttons. Direction:",F),Ve.current&&clearTimeout(Ve.current),Ve.current=setTimeout(()=>{We(!1),R.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[me,S,n]),lt=r.useMemo(()=>$e(je,y.top),[y.top,je]),rt=r.useMemo(()=>{const a=E.getTotal(),u=nn(lt,he,o,n,s,E,a);return R.debug("[VirtualScroll] Calculated rendering range:",()=>({...u,scrollPosition:lt,renderingContentSize:a,overscanCount:o,viewportSize:he})),u},[lt,he,o,n,s,E]),{renderingStartIndex:ct,renderingEndIndex:bt,visibleStartIndex:ht,visibleEndIndex:It}=rt,ut=r.useCallback((a,u)=>{if(!k||n===0)return;const f=be(a,n);if(!(u?.ensureVisible??!0)){const De=Te.current.get(f);De&&(X.current=null,Me.current=f,se(De));return}const L=E.prefixSum(f,{materializeOption:{materialize:!1}}),O=L.currentValue,F=Math.max(L.cumulative-O,0),J=F+O,ve=$e(M.current,y.top),fe=ve+he;if(F<ve||J>fe){c(f);const De=Te.current.get(f);De?(X.current=null,Me.current=f,se(De)):X.current=f;return}const _e=Te.current.get(f);if(_e){X.current=null,Me.current=f,se(_e);return}X.current=f},[k,n,E,y.top,c,se,he]),Zt=r.useCallback((a,u)=>{if(!(!k||a.defaultPrevented)&&!(a.altKey||a.metaKey||a.ctrlKey)&&a.target===a.currentTarget&&!a.currentTarget.isContentEditable){if(a.key==="ArrowLeft"||a.key==="ArrowRight"){const f=Se.current;if(!f||a.shiftKey||!le?.includes("arrow")||!(Number.isFinite(P)&&P>0))return;a.preventDefault(),f(a.key==="ArrowLeft"?-P:P);return}if(a.key==="ArrowDown"){u<n-1&&(a.preventDefault(),ut(u+1));return}if(a.key==="ArrowUp"){u>0&&(a.preventDefault(),ut(u-1));return}if(a.key==="PageDown"){if(u<n-1){a.preventDefault();const{visibleStartIndex:f,visibleEndIndex:A}=Ue.current,L=Math.max(A-f+1,1),O=Math.max(L,1),F=be(Math.min(u+O,n-1),n);ut(F)}return}if(a.key==="PageUp"&&u>0){a.preventDefault();const{visibleStartIndex:f,visibleEndIndex:A}=Ue.current,L=Math.max(A-f+1,1),O=Math.max(L,1),F=be(u-O,n);ut(F)}}},[k,n,ut,le,P]),Qt=r.useCallback((a,u)=>{if(a.key!=="Escape"||a.defaultPrevented||a.nativeEvent.isComposing||a.target===a.currentTarget)return;const f=a.target;f instanceof HTMLInputElement||f instanceof HTMLTextAreaElement||f instanceof HTMLSelectElement||f.isContentEditable||(a.preventDefault(),ut(u))},[ut]),Jt=r.useCallback(a=>{if(!k)return;const u=be(a,n);X.current=null,Me.current=u,oe?.(u)},[k,n,oe]);r.useEffect(()=>{const a=W.current?.getScrollPosition()??0,u=M.current,f=$e(u,y.top);R.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:ct,renderingEndIndex:bt,visibleStartIndex:ht,visibleEndIndex:It,scrollPositionState:je,paneScrollPosition:u,logicalScrollPosition:f,contentSize:ze,scrollPaneScrollPosition:a})),nt({renderingStartIndex:ct,renderingEndIndex:bt,visibleStartIndex:ht,visibleEndIndex:It,scrollPosition:f,totalHeight:ze})},[ze,bt,ct,y.top,nt,je,It,ht]);const wr=r.useCallback(()=>{if(!S)return null;const a=Re&&ke!==null,u=ke==="up";return q.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":a,inert:!a,children:u?q.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:q.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:a?0:-1,onClick:f=>{f.stopPropagation(),tt.current=!0,c(0),We(!1)},children:"Top"})}):q.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:q.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:a?0:-1,onClick:f=>{f.stopPropagation(),tt.current=!0,c(n-1),We(!1)},children:"Bottom"})})})},[S,Re,ke,c,n]),Yt=r.useRef(0),{visibleItems:Bt,renderAnchor:Ht}=r.useMemo(()=>{if(n===0)return{visibleItems:q.jsx("div",{className:"aqvs-no-items-container",children:q.jsx("div",{className:"aqvs-no-items-text",children:"No items"})}),renderAnchor:0};const a=be(ct,n),u=be(bt,n),{cumulative:f,currentValue:A}=E.prefixSum(a,{materializeOption:{materialize:!1}}),L=f-A;Number.isFinite(L)&&Math.abs(L-Yt.current)>en&&(Yt.current=L);const O=Yt.current,F=[],J=[];let ve=0,fe=L;for(let ie=a;ie<=u;ie++){if(J.length>=fr){R.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:fr,safeRenderingStartIndex:a,safeRenderingEndIndex:u});break}const _e=s(ie),De=E.get(ie),Fe=_e-De;Fe!==0&&F.push({index:ie,value:_e});const kt=fe+ve,qt=t?t(ie):ie;J.push(q.jsx(sn,{index:ie,top:kt-O,height:_e,item:e(ie),clipItemHeight:qe,enableKeyboardNavigation:k,onKeyDown:Zt,onEscapeKeyDown:Ae?Qt:void 0,onFocus:Jt,registerItemRef:St,children:x},qt)),ve+=Fe,fe+=De}return F.length>0&&Promise.resolve().then(()=>{if(ot.current)return;let ie=0;for(const Fe of F)if(Fe.index<ht){const kt=E.get(Fe.index);ie+=Fe.value-kt}const _e=E.updates(F);if(ot.current||typeof _e!="number")return;m(_e),R.debug("[VirtualScroll] Updated heights for items",F,"New total height:",_e);const De=W.current?.getScrollPosition()??M.current;if(ie!==0){const Fe=De+ie;pt(Fe,ie),me(Fe,{immediate:!0}),R.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:De,to:Fe,shiftAmount:ie})}else De!==M.current&&me(De)}),{visibleItems:J,renderAnchor:O}},[x,qe,ze,k,n,E,e,t,s,Jt,Zt,Ae,Qt,pt,St,bt,ct,me,ht]),Tr=r.useCallback(a=>{const u=(j??0)>0,f=Math.abs(a-je),A=u&&f>.5?je:a,L=$e(A,y.top);if(R.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:a,effectiveScrollPosition:L,renderingStartIndex:ct,renderingEndIndex:bt,itemCount:n,viewportSize:he,callbackThrottleMs:j,diff:f,rawEffectiveScrollPosition:A})),n===0)return Bt;const O=y.top+Ht-A,F=y.bottom>0?q.jsx("div",{className:"aqvs-bottom-inset",style:{top:E.getTotal()-Ht,height:y.bottom}},"virtualscroll-bottom-inset"):null;return R.debug("[VirtualScroll] Rendering items",()=>({containerTop:O,logicalScrollPosition:lt,resolvedInsets:y,effectiveScrollPosition:L})),q.jsxs("div",{className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${O}px)`,willChange:"transform"},children:[Bt,F]})},[j,n,E,lt,Ht,bt,ct,y,je,he,Bt]),er=r.useMemo(()=>({renderingStartIndex:rt.renderingStartIndex,renderingEndIndex:rt.renderingEndIndex,visibleStartIndex:rt.visibleStartIndex,visibleEndIndex:rt.visibleEndIndex,scrollPosition:lt,totalHeight:E.getTotal()}),[rt,lt,E,ze]);r.useEffect(()=>{Ue.current=er},[er]);const[Mr,tr]=r.useState(""),rr=r.useRef(w);r.useLayoutEffect(()=>{rr.current=w},[w]);const wt=w?.debounceMs??400,Lt=Number.isFinite(wt)&&wt>=0,Ct=w!==void 0;r.useEffect(()=>{Ct&&!Lt&&R.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${wt}. Announcements are disabled.`)},[Ct,Lt,wt]),r.useEffect(()=>{if(!(Ct&&Lt)){tr("");return}const a=setTimeout(()=>{const u=rr.current?.format;if(!u)return;const f=u({visibleStartIndex:ht,visibleEndIndex:It,itemCount:n});tr(f)},wt);return()=>clearTimeout(a)},[Ct,Lt,wt,ht,It,n]),r.useImperativeHandle(K,()=>({getScrollPosition:()=>{const a=W.current?.getScrollPosition();return typeof a=="number"?$e(a,Oe.current):-1},getContentSize:()=>W.current?.getContentSize()??-1,getViewportSize:()=>W.current?.getViewportSize()??-1,scrollTo:pe,scrollBy:ye,applyWheel:Ze,scrollToIndex:c,getFenwickTreeTotalHeight:()=>E.getTotal(),getFenwickSize:()=>E.getSize(),focusItemAtIndex:ut,getRange:()=>Ue.current,getScrollAnchor:B,updateItemSize:Et}),[pe,ye,Ze,c,E,ut,B,Et]);const Rr=E.getTotal()+y.top+y.bottom,nr=q.jsx(Sr,{ref:W,contentSize:Rr,viewportSize:i,onViewportSizeChange:xe,className:l,testId:p,onScroll:Qe,background:I,tapScrollCircleOptions:ce,inertiaOptions:Ee,overscrollBehavior:Le,itemCount:n,scrollBarWidth:G,enableThumbDrag:$,enableTrackClick:de,enableArrowButtons:V,enablePointerDrag:Ye,pointerDragInputs:Be,renderThumbOverlay:U,wheelSpeedMultiplier:He,onWheelHorizontal:ne,contentInsets:y,contentProps:_,visibleStartIndex:ht,visibleEndIndex:It,renderOverlay:wr,initialScrollPosition:et.position,children:Tr});return Ct?q.jsxs(q.Fragment,{children:[nr,q.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Mr})]}):nr},an=r.forwardRef(on);exports.FenwickMapTree=ft;exports.ScrollBar=br;exports.ScrollPane=Sr;exports.TAP_SCROLL_SPEED_DEFAULTS=Gt;exports.VirtualScroll=an;exports.computeAutoTapScrollMaxSpeedMultiplier=gr;exports.computeTapScrollSpeed=hr;exports.createResidualQuantizer=Pr;exports.minmax=ee;exports.tapScrollCircleSampleVisual=Ur;exports.useFenwickMapTree=vr;exports.useHeightCache=Qr;exports.useLruCache=Ir;exports.useWheelBridge=Jr;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),t=require("react"),yt=require("tailwind-merge"),Kr=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}}};class P{level;prefix;impl;constructor(e=2,n="[virtualscroll]",s=console){this.level=e,this.prefix=n,this.impl=s}static instance=new P(2,"[virtualscroll]");static setLevel(e){P.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){P.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){P.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return P.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){P.instance.debug(e,...n)}debug(e,...n){this.level<=0&&this.impl.debug(...this.formatMessage(P.resolveLazy(e)),...n.map(P.resolveLazy))}static info(e,...n){P.instance.info(e,...n)}info(e,...n){this.level<=1&&this.impl.info(...this.formatMessage(P.resolveLazy(e)),...n.map(P.resolveLazy))}static warn(e,...n){P.instance.warn(e,...n)}warn(e,...n){this.level<=2&&this.impl.warn(...this.formatMessage(P.resolveLazy(e)),...n.map(P.resolveLazy))}static error(e,...n){P.instance.error(e,...n)}error(e,...n){this.level<=3&&this.impl.error(...this.formatMessage(P.resolveLazy(e)),...n.map(P.resolveLazy))}}const Nr={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},mr=6,Qr=8,Jr=({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 A.jsxs(A.Fragment,{children:[A.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`}}),A.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"}})]})},Hr=t.memo(t.forwardRef(({onDragChange:r,className:e,maxVisualDistance:n=160,size:s=40,style:i,opacity:a=1,renderVisual:l,axis:f="y"},m)=>{const[g,w]=t.useState(Nr),M=t.useRef(null),I=t.useRef(null),v=t.useRef({x:0,y:0}),V=t.useRef(null),G=t.useRef(0),W=t.useCallback(T=>{w(T),r(T)},[r]),me=t.useCallback((T,j,ye=!1)=>{const{x:ge,y:ke}=v.current,D=T-ge,nt=j-ke,ot=f==="x"?D:nt,st=Math.abs(ot),Je=st<mr?0:ot<0?-1:1,Ke=G.current;let xe=Je;const Ve=mr+Qr;Je===0?Ke!==0&&st<Ve?xe=Ke:(xe=0,ye||(G.current=0)):Je!==Ke&&Ke!==0&&st<Ve?xe=Ke:G.current=Je,W({active:ye||st>=mr,offsetX:D,offsetY:nt,distance:st,direction:xe,pointerId:M.current})},[W,f]),Ne=t.useCallback(T=>{if(T===null)return;const j=V.current;j?.hasPointerCapture(T)&&j.releasePointerCapture(T)},[]),pe=t.useCallback((T=!1)=>{T&&Ne(M.current),M.current=null,I.current=null,G.current=0,W(Nr)},[W,Ne]),ie=t.useCallback(T=>{if(M.current!==null&&M.current!==T.pointerId){I.current={pointerId:T.pointerId,clientX:T.clientX,clientY:T.clientY},T.preventDefault(),T.stopPropagation();return}T.preventDefault(),T.stopPropagation();const j=V.current??T.currentTarget,{left:ye,top:ge,width:ke,height:D}=j.getBoundingClientRect();v.current={x:ye+ke/2,y:ge+D/2},M.current=T.pointerId;try{j.setPointerCapture(T.pointerId)}catch{}me(T.clientX,T.clientY,!0)},[me]),ze=t.useCallback(T=>{if(M.current!==T.pointerId){I.current!==null&&I.current.pointerId===T.pointerId&&(I.current={pointerId:T.pointerId,clientX:T.clientX,clientY:T.clientY});return}T.preventDefault(),me(T.clientX,T.clientY)},[me]),_=t.useCallback(T=>{if(M.current!==T.pointerId){I.current!==null&&I.current.pointerId===T.pointerId&&(I.current=null);return}T.preventDefault(),T.stopPropagation();const j=I.current;if(I.current=null,j!==null){Ne(T.pointerId);const ye=V.current;let ge=!0;if(ye!==null&&typeof ye.setPointerCapture=="function")try{ye.setPointerCapture(j.pointerId)}catch(ke){(typeof ke=="object"&&ke!==null&&"name"in ke?ke.name:void 0)==="NotFoundError"&&(ge=!1)}if(ge){M.current=j.pointerId,me(j.clientX,j.clientY,!0);return}}pe(!0)},[pe,Ne,me]),C=t.useCallback(T=>{T.target===T.currentTarget&&M.current===T.pointerId&&pe(!1)},[pe]);t.useImperativeHandle(m,()=>({reset:()=>{pe(!0)},getElement:()=>V.current}),[pe]);const z=Math.min(Math.max(a,0),1),Z=s/64,ne=Math.min(g.distance,n)/n,ae=g.direction*ne*10*Z,oe=l??Jr,Ee={dragState:g,normalizedDistance:ne,sizeScale:Z,size:s,opacity:z},H={...i,width:s,height:s,transform:`translateY(${ae}px)`};return H.opacity=z,A.jsx("div",{ref:V,"data-testid":"virtual-scroll-tap-circle",className:yt.twMerge("aqvs-tap-scroll-circle",e),style:H,tabIndex:-1,onPointerDown:ie,onPointerMove:ze,onPointerUp:_,onPointerCancel:_,onLostPointerCapture:C,role:"presentation",children:oe(Ee)})}));Hr.displayName="TapScrollCircle";const K=(r,e,n)=>Math.max(e,Math.min(n,r)),wr=(r,e)=>{const n=e==="x",s=r.getBoundingClientRect(),i=n?s.width:s.height,a=w=>{const M=Number.parseFloat(w);return Number.isFinite(M)?M:0},l=window.getComputedStyle(r),f=a(n?l.width:l.height),m=f>0?f+a(n?l.paddingLeft:l.paddingTop)+a(n?l.paddingRight:l.paddingBottom)+a(n?l.borderLeftWidth:l.borderTopWidth)+a(n?l.borderRightWidth:l.borderBottomWidth):0,g=m>0?m:n?r.offsetWidth:r.offsetHeight;return g<=0||i<=0?1:i/g},Rr="virtualscroll:tap-scroll-cancel",zr=20,en=250,tn=60,rn=20,nn=20,Tr={maxDistance:240,minSpeedMultiplier:.2},sn=Tr.maxDistance,kr={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},pr=2.2,an=8,on=120,ln=1/10,Dt={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:sn,minSpeedMultiplier:Tr.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},cn=r=>r?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,n)=>e,getPointerCoordinate:({clientX:e})=>e,arrowLabels:["Scroll left","Scroll right"],arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,n)=>n,getPointerCoordinate:({clientY:e})=>e,arrowLabels:["Scroll up","Scroll down"],arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},un=(r,e)=>{const n=r?.maxSpeedMultiplier,s=typeof n=="number"?n:Xr(e);return{enabled:r?.enabled??Dt.enabled,size:r?.size??Dt.size,offsetX:r?.offsetX??Dt.offsetX,offsetY:r?.offsetY??Dt.offsetY,className:r?.className??Dt.className,maxVisualDistance:r?.maxVisualDistance??Dt.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??Dt.minSpeedMultiplier,0),opacity:K(r?.opacity??Dt.opacity,0,1),renderVisual:r?.renderVisual??Dt.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??Dt.maxSpeedCurve}},fn=({isDragging:r,isThumbHovered:e,enableThumbDrag:n})=>t.useMemo(()=>n?r?"dragging":e?"hover":"idle":"disabled",[n,r,e]),dn=({canUseArrowButtons:r,enableArrowButtons:e,resetTapScroll:n,scrollByStep:s})=>{const i=t.useRef(null),a=t.useRef(null),l=t.useRef(null),f=t.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null),a.current!==null&&(window.clearTimeout(a.current),a.current=null),l.current!==null&&(window.removeEventListener("pointerup",l.current),window.removeEventListener("pointercancel",l.current),window.removeEventListener("blur",l.current),l.current=null)},[]),m=t.useCallback(()=>{f()},[f]),g=t.useCallback(M=>I=>{if(!r)return;I.cancelable&&I.preventDefault(),I.stopPropagation(),n(),f(),s(M),a.current=window.setTimeout(()=>{i.current=window.setInterval(()=>{s(M)},tn)},en);const v=()=>f();l.current=v,window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),window.addEventListener("blur",v)},[r,f,n,s]),w=t.useCallback(M=>I=>{e&&(I.key==="Enter"||I.key===" "||I.key==="Spacebar")&&(I.preventDefault(),s(M))},[e,s]);return t.useEffect(()=>{r||f()},[r,f]),t.useEffect(()=>()=>{f()},[f]),{handleArrowPointerDown:g,handleArrowPointerUp:m,handleArrowKeyDown:w}},hn=700,Zt=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,qr=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:a,curve:l})=>{const f=Math.max(Zt(r,0),0),m=Zt(e,0),g=m>0?Math.min(f,m)/m:1,w=Math.max(Zt(n,0),0),M=Math.max(Zt(s,0),0),I=Math.max(Zt(i,0),0),v=Math.max(w*M,40),V=a?v:1200,G=Math.max(w*I,V),W=l?Math.max(Zt(l.exponentialScale,I),0):0,me=l?Math.min(G,Math.max(w*W,v)):G,Ne=Math.max(me,v);let pe=g**1.1;if(l){const ze=Math.min(Math.max(Zt(l.exponentialSteepness,0),0),hn);if(ze===0)pe=g;else{const _=Math.expm1(ze)||1;pe=Math.min(Math.max(Math.expm1(ze*g)/_,0),1)}}const ie=Math.min(Math.max(Zt(l?.easedOffset,0),0),1);return v+(Ne-v)*(ie+(1-ie)*pe)},Xr=r=>{if(!r||r<=0)return pr;const e=Math.max(1,r),n=Math.log10(e),s=pr+n*an;return K(s,pr,on)},Cr=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:a=!0,enableArrowButtons:l=!0,horizontal:f=!1,enableHorizontalTapCircle:m=!1,scrollBarWidth:g=12,className:w,ariaControls:M,tapScrollCircleOptions:I,itemCount:v,renderThumbOverlay:V,visibleStartIndex:G,visibleEndIndex:W})=>{const[me,Ne]=t.useState(!1),[pe,ie]=t.useState(!1),[ze,_]=t.useState(!1),C=t.useRef(null),z=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),Z=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),ne=t.useRef(n),ae=t.useRef(s),oe=t.useRef(kr),Ee=t.useRef(null),H=t.useRef(null),T=t.useRef(null),j=t.useRef(0),ye=t.useRef(0),ge=t.useMemo(()=>un(I,v),[v,I]),ke=t.useMemo(()=>cn(f),[f]),{enabled:D,size:nt,offsetX:ot,offsetY:st,className:Je,maxVisualDistance:Ke,maxSpeedMultiplier:xe,minSpeedMultiplier:Ve,opacity:Re,renderVisual:se,maxSpeedCurve:Se}=ge,F=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(Ke,1),tapCircleMaxSpeedMultiplier:xe,tapCircleMinSpeedMultiplier:Ve,tapCircleMaxSpeedCurve:Se,tapScrollCircleOptions:I,effectiveTrackLength:0,onScroll:s,scrollPosition:n}),{mainSizeKey:lt,crossSizeKey:Q,positionKey:Ye,selectDelta:fe,getPointerCoordinate:N,arrowLabels:B,arrowIcons:Le,directionClass:R,orientation:dt}=ke,Fe=Math.max(Ke,1),ct=e/r,He=Math.max(e-g*2,0),Vt=ct*He,d=Math.min(Math.max(zr,Vt||0),He||zr),O=Math.max(r-e,0),J=Math.max(He-d,0),ee=O<=0||J<=0?0:K(n/O*J,0,J),de=ee+d/2,te=r>e||me,De=te&&l;t.useLayoutEffect(()=>{F.current={viewportSize:e,maxScrollPosition:O,scrollBarVisible:te,effectiveTapMaxDistance:Fe,tapCircleMaxSpeedMultiplier:xe,tapCircleMinSpeedMultiplier:Ve,tapCircleMaxSpeedCurve:Se,tapScrollCircleOptions:I,effectiveTrackLength:J,onScroll:s,scrollPosition:n}}),t.useLayoutEffect(()=>{ne.current=n},[n]),t.useLayoutEffect(()=>{ae.current=s},[s]),t.useEffect(()=>{i||ie(!1)},[i]);const ve=fn({isDragging:me,isThumbHovered:pe,enableThumbDrag:i}),he=t.useCallback((u,y)=>{const k=F.current,U=y??ne.current;if(ae.current){const tt=ae.current(u,U);if(typeof tt=="number"&&Number.isFinite(tt))return ne.current=tt,tt}const Ie=typeof u=="function"?u(U):u,Xe=Math.max(k.maxScrollPosition,0),ft=k.scrollBarVisible?K(Ie,0,Xe):0;return ne.current=ft,ft},[]),be=t.useCallback(u=>{const y=F.current,k=ne.current;if(!y.scrollBarVisible||y.maxScrollPosition<=0){const mt=he(0,k),Ct=mt-k;return{nextPosition:mt,actualDelta:Ct,reachedBoundary:!0}}if(u===0)return{nextPosition:k,actualDelta:0,reachedBoundary:!1};const Ie=he(mt=>K(mt+u,0,y.maxScrollPosition),k),Xe=Ie-k,ft=u<0&&k+u<=0,tt=u>0&&k+u>=y.maxScrollPosition,Tt=u<0&&(Ie<=0||ft&&Xe===0)||u>0&&(Ie>=y.maxScrollPosition||tt&&Xe===0);return{nextPosition:Ie,actualDelta:Xe,reachedBoundary:Tt}},[he]),Qe=t.useCallback((u,y)=>{u.current+=y;const k=Math.max(F.current.maxScrollPosition,0);k>0&&(u.current=K(u.current,-k,k));const U=be(u.current);return u.current-=U.actualDelta,U.reachedBoundary&&(u.current=0),U},[be]),Ae=t.useCallback(()=>{H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null),T.current=null,j.current=0,ye.current=0},[]),we=t.useCallback(()=>{oe.current={...kr},_(!1),Ee.current?.reset(),Ae()},[Ae]),it=t.useCallback(u=>{const y=oe.current,k=F.current;if(!y.active||y.direction===0){Ae();return}if(!k.scrollBarVisible||k.maxScrollPosition<=0){Ae();return}const U=T.current??u,Ie=Math.max((u-U)/1e3,0),Xe=Math.min(Ie,ln);if(T.current=u,Xe<=0){H.current=window.requestAnimationFrame(it);return}const ft=qr({distance:y.distance,maxDistance:k.effectiveTapMaxDistance,viewportSize:k.viewportSize,minSpeedMultiplier:k.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:k.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof k.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:k.tapCircleMaxSpeedCurve});ye.current!==y.direction&&(ye.current=y.direction,j.current=0);const{reachedBoundary:tt}=Qe(j,y.direction*ft*Xe);if(tt){Ae();return}H.current=window.requestAnimationFrame(it)},[Qe,Ae]),$e=t.useCallback(()=>{H.current===null&&(T.current=null,j.current=0,H.current=window.requestAnimationFrame(it))},[it]);t.useEffect(()=>{const u=oe.current;!u.active||u.direction===0||$e()},[r,e,$e]),t.useEffect(()=>()=>{Ae()},[Ae]);const at=t.useCallback(u=>{oe.current=u,_(u.active),u.active&&u.direction!==0?$e():Ae()},[$e,Ae]);t.useEffect(()=>{D||we()},[we,D]),t.useEffect(()=>{const u=y=>{const U=y.detail?.paneId;U&&M&&U!==M||we()};return window.addEventListener(Rr,u),()=>{window.removeEventListener(Rr,u)}},[M,we]),t.useEffect(()=>{if(!D)return;const u=y=>{if(!oe.current.active||oe.current.pointerId===y.pointerId)return;const k=y.target;if(!(k instanceof Node)){we();return}Ee.current?.getElement()?.contains(k)||we()};return document.addEventListener("pointerdown",u,!0),()=>{document.removeEventListener("pointerdown",u,!0)}},[we,D]);const le=u=>{if(!te||J<=0||O<=0)return 0;const y=K(u,0,J);return K(y/J*O,0,O)},Te=t.useCallback(u=>{const{scrollBarVisible:y,effectiveTrackLength:k,maxScrollPosition:U}=F.current;if(P.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:u,trackLen:k,maxScroll:U})),k<=0||U<=0)return null;const Ie=K(u,0,k);return K(Ie/k*U,0,U)},[]),ht=t.useCallback(u=>wr(u,f?"x":"y"),[f]),h=t.useCallback(u=>{const y=z.current;if(y.pointerId!==u.pointerId)return;const k=u.clientX-y.startClientX,U=u.clientY-y.startClientY,Ie=fe(k,U)/(y.scale||1);P.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:Ie,startThumbPosition:y.startThumbPosition,clientY:u.clientY,startClientY:y.startClientY,metrics:F.current}));const Xe=Te(y.startThumbPosition+Ie);Xe!==null&&he(Xe),u.cancelable&&u.preventDefault()},[fe,Te,he]),E=t.useCallback(u=>{const y=z.current;if(y.pointerId!==u.pointerId)return;document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",E),document.removeEventListener("pointercancel",E);const k=y.captureTarget;if(k?.hasPointerCapture?.(u.pointerId)&&k.releasePointerCapture(u.pointerId),z.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},Ne(!1),C.current){const U=C.current.getBoundingClientRect();u.clientX>=U.left&&u.clientX<=U.right&&u.clientY>=U.top&&u.clientY<=U.bottom||ie(!1)}else ie(!1)},[h]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",E),document.removeEventListener("pointercancel",E)},[h,E]);const je=t.useRef(0),et=t.useRef(0),qe=t.useCallback(u=>{const y=Math.max(Math.round(F.current.viewportSize/nn),rn);et.current!==u&&(et.current=u,je.current=0),Qe(je,u*y)},[Qe]),{handleArrowPointerDown:bt,handleArrowPointerUp:Me,handleArrowKeyDown:ut}=dn({canUseArrowButtons:De,enableArrowButtons:l,resetTapScroll:we,scrollByStep:qe}),Ue=u=>{if(!te)return;if(!i){u.preventDefault(),u.stopPropagation();return}if(u.pointerType==="mouse"&&u.button!==0||u.ctrlKey)return;we();const y=u.currentTarget,k=ht(y);let U=null;if(y.setPointerCapture)try{y.setPointerCapture(u.pointerId),U=y}catch{U=null}z.current={pointerId:u.pointerId,startThumbPosition:ee,startClientX:u.clientX,startClientY:u.clientY,scale:k,captureTarget:U},document.addEventListener("pointermove",h),document.addEventListener("pointerup",E),document.addEventListener("pointercancel",E),Ne(!0),ie(!0),u.preventDefault(),u.stopPropagation()},Ot=u=>{if(!te)return;if(!a){u.preventDefault(),u.stopPropagation();return}if(u.pointerType==="mouse"&&u.button!==0||u.ctrlKey)return;const y=u.currentTarget,k=y.getBoundingClientRect(),U=N(u),Ie=ht(y),Xe=(U-(f?k.left:k.top))/Ie;we();const ft=Xe-d/2,tt=le(ft);if(he(tt),y.setPointerCapture)try{y.setPointerCapture(u.pointerId)}catch{}Z.current={pointerId:u.pointerId,startThumbPosition:ft,startClientX:u.clientX,startClientY:u.clientY,scale:Ie},u.preventDefault(),u.stopPropagation()},Rt=()=>{Z.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},Xt=u=>{const y=Z.current;if(y.pointerId!==u.pointerId)return;if(u.pointerType==="mouse"&&u.buttons===0){Rt();return}const k=u.clientX-y.startClientX,U=u.clientY-y.startClientY,Ie=fe(k,U)/(y.scale||1),Xe=le(y.startThumbPosition+Ie);he(Xe),u.cancelable&&u.preventDefault()},_e=u=>{if(Z.current.pointerId!==u.pointerId)return;const y=u.currentTarget;y.hasPointerCapture?.(u.pointerId)&&y.releasePointerCapture(u.pointerId),Rt(),u.preventDefault(),u.stopPropagation()},St=u=>{if(Z.current.pointerId!==u.pointerId)return;const y=u.currentTarget;y.hasPointerCapture?.(u.pointerId)&&y.releasePointerCapture(u.pointerId),Rt()},Kt=u=>{u.target===u.currentTarget&&Z.current.pointerId===u.pointerId&&Rt()},Ce=t.useMemo(()=>K((ze?1:.8)*Re,0,1),[ze,Re]),xt=t.useMemo(()=>{const y=`calc(50% - ${nt/2}px + ${st}px)`;return{left:ot,top:y}},[ot,st,nt]),Mt=(u,y,k,U)=>A.jsx("button",{type:"button",tabIndex:0,className:"aqvs-scrollbar-arrow-button",style:{[lt]:g,[Q]:g},"aria-label":y,onPointerDown:bt(u),onPointerUp:Me,onPointerLeave:Me,onPointerCancel:Me,onKeyDown:ut(u),"aria-disabled":!l,disabled:!De,children:A.jsx("span",{"aria-hidden":"true",children:k})},U),At=V&&te?{orientation:dt,scrollPosition:n,maxScrollPosition:O,contentSize:r,viewportSize:e,thumbSize:d,thumbPosition:ee,thumbCenter:de,trackSize:He,isDragging:me,isTapScrollActive:ze,visibleStartIndex:G,visibleEndIndex:W}:null;return A.jsxs("div",{className:yt.twMerge("aqvs-scrollbar",R,w),style:{[lt]:e,[Q]:g},"data-visible":te?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":M,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":O,"aria-orientation":f?"horizontal":"vertical",children:[(!f||m)&&te&&D&&A.jsx(Hr,{axis:f?"x":"y",ref:Ee,className:yt.twMerge("aqvs-scrollbar-tap-circle-wrapper",Je),size:nt,maxVisualDistance:Fe,style:xt,opacity:Ce,renderVisual:se,onDragChange:at},"tap-circle"),Mt(-1,B[0],Le[0],"arrow-start"),A.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:g/2},onPointerDown:Ot,onPointerMove:Xt,onPointerUp:_e,onPointerCancel:St,onLostPointerCapture:Kt,"aria-disabled":!a,children:[At&&A.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:V?.(At)},"overlay"),A.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[lt]:d,[Ye]:ee,...f?{top:0,bottom:0}:{left:0,right:0}},"data-visible":te||me?"true":"false",onPointerDown:Ue,role:"slider","aria-orientation":f?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":O,"aria-disabled":!i,tabIndex:-1,children:A.jsx("div",{ref:C,className:yt.twMerge("aqvs-scrollbar-thumb",f?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":ve,style:{borderRadius:g-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&ie(!0)},onMouseLeave:()=>{i&&ie(!1)}},"thumb")},"thumb-wrapper")]},"track"),Mt(1,B[1],Le[1],"arrow-end")]})},mn=16,Vr=(r,e,n)=>e===1?r*mn:e===2?r*n:r,pn=(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:Vr(s,r.deltaMode,e),verticalDelta:Vr(i,r.deltaMode,e)}},Wr=new WeakSet,Ar=r=>{Wr.add(r)},gn=r=>Wr.has(r),bn=["mouse","pen","touch"],gr=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),xn=r=>r==="mouse"||r==="pen",ar={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},ur=(r,e,n)=>{for(const[s,i,a]of e)n==="add"?r.addEventListener(s,i,a):r.removeEventListener(s,i,a)},Br=t.forwardRef(({children:r,contentSize:e,viewportSize:n,onViewportSizeChange:s,scrollBarWidth:i=12,enableThumbDrag:a=!0,enableTrackClick:l=!0,enableArrowButtons:f=!0,enablePointerDrag:m=!0,pointerDragInputs:g=bn,onScroll:w,className:M,testId:I,style:v,background:V,tapScrollCircleOptions:G,inertiaOptions:W,itemCount:me,renderThumbOverlay:Ne,wheelSpeedMultiplier:pe=1,overscrollBehavior:ie="auto",onWheelHorizontal:ze,onPanHorizontal:_,contentInsets:C,visibleStartIndex:z,visibleEndIndex:Z,renderOverlay:ne,initialScrollPosition:ae=0,contentProps:oe},Ee)=>{const H=t.useRef(Number.isFinite(ae)?Math.max(0,ae):0),T=t.useRef(null),j=t.useRef(null),ye=n===void 0,[ge,ke]=t.useState(0),D=n??ge,nt=t.useRef(null);t.useLayoutEffect(()=>{if(!ye)return;const d=j.current;if(!d)return;const O=()=>{const ee=d.offsetHeight;if(ee>0){ke(de=>de===ee?de:ee);return}d.offsetParent!==null&&e>0&&nt.current!=="zero"&&(nt.current="zero",P.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(O(),typeof ResizeObserver!="function")return;const J=new ResizeObserver(O);return J.observe(d),()=>{J.disconnect()}},[e,ye]),t.useLayoutEffect(()=>{ye&&s?.(ge)},[ye,ge,s]),t.useLayoutEffect(()=>{if(ye)return;const d=T.current;if(!d)return;const O=()=>{const ee=d.clientHeight;if(ee<=0||Math.abs(ee-D)<=1)return;const de=`${D}/${ee}`;nt.current!==de&&(nt.current=de,P.warn(`[ScrollPane] viewportSize=${D} but the host band is ${ee}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(O(),typeof ResizeObserver!="function")return;const J=new ResizeObserver(O);return J.observe(d),()=>{J.disconnect()}},[ye,D]);const ot=t.useRef(ze);t.useEffect(()=>{ot.current=ze},[ze]);const st=t.useRef(_);t.useEffect(()=>{st.current=_},[_]);const Je=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),Ke=t.useMemo(()=>({maxVelocity:W?.maxVelocity??ar.maxVelocity,minVelocity:W?.minVelocity??ar.minVelocity,deceleration:W?.deceleration??ar.deceleration,velocitySampleWindow:W?.velocitySampleWindow??ar.velocitySampleWindow,startVelocityThreshold:W?.startVelocityThreshold??ar.startVelocityThreshold}),[W]),xe=t.useMemo(()=>({top:Math.max(0,C?.top??0),bottom:Math.max(0,C?.bottom??0)}),[C]);P.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:D,scrollBarWidth:i,className:M,style:v,tapScrollCircleOptions:G,inertiaOptions:W,enablePointerDrag:m,contentInsets:xe}));const Ve=t.useRef({contentSize:e,viewportSize:D}),Re=t.useMemo(()=>e>D,[e,D]),se=t.useCallback((d,O)=>{let J=O??Ve.current;O&&!(Number.isFinite(O.contentSize)&&Number.isFinite(O.viewportSize))&&(P.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:O}),J=Ve.current);const{contentSize:ee,viewportSize:de}=J,te=ee>de,De=H.current;if(P.debug("[ScrollPane] scrollTo called",()=>({newPosition:d,contentSize:ee,viewportSize:de,currentIsScrollable:te,prevPosition:De})),!te)return H.current!==0&&(H.current=0,w?.(0,De)),H.current;const ve=typeof d=="function"?d(H.current):d;if(!Number.isFinite(ve))return P.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:ve}),H.current;const he=Math.max(ee-de,0),be=K(ve,0,he);return H.current!==be&&(H.current=be,w?.(be,De)),H.current},[w]),Se=t.useRef(se);t.useEffect(()=>{Se.current=se},[se]);const F=t.useCallback(()=>{const d=Je.current;d.generation+=1,d.frame!==null&&cancelAnimationFrame(d.frame),d.frame=null,d.velocity=0,d.lastTimestamp=null},[]),lt=t.useRef(F);t.useEffect(()=>{lt.current=F},[F]),t.useEffect(()=>()=>{lt.current()},[]);const Q=t.useCallback(d=>{if(!Re)return;const{maxVelocity:O,minVelocity:J,deceleration:ee,startVelocityThreshold:de}=Ke,te=K(d,-O,O);if(Math.abs(te)<de)return;F(),Je.current.velocity=te,Je.current.lastTimestamp=null;const De=Je.current.generation,ve=he=>{const be=Je.current;if(be.generation!==De)return;if(be.lastTimestamp===null){be.lastTimestamp=he,be.frame=requestAnimationFrame(ve);return}const Qe=he-be.lastTimestamp;if(be.lastTimestamp=he,Qe<=0){be.frame=requestAnimationFrame(ve);return}const Ae=be.velocity;let we=Ae;const it=ee*Qe;Ae>0?we=Math.max(0,Ae-it):Ae<0&&(we=Math.min(0,Ae+it));const at=(Ae+we)/2*Qe,le=H.current;if(at!==0&&Se.current(et=>et+at),Je.current.generation!==De)return;const Te=H.current,{contentSize:ht,viewportSize:h}=Ve.current,E=Math.max(ht-h,0);be.velocity=we;const je=Te===le||Te<=0&&we<=0||Te>=E&&we>=0;if(Math.abs(we)<J||je){F();return}be.frame=requestAnimationFrame(ve)};Je.current.frame=requestAnimationFrame(ve)},[Re,Ke,F]),Ye=t.useRef(Q);t.useEffect(()=>{Ye.current=Q},[Q]),t.useLayoutEffect(()=>{Ve.current={contentSize:e,viewportSize:D}},[e,D]),t.useLayoutEffect(()=>{const d=j.current;if(!d)return;const O=()=>{d.scrollTop!==0&&(P.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:d.scrollTop})),d.scrollTop=0),d.scrollLeft!==0&&(d.scrollLeft=0)};return d.addEventListener("scroll",O),()=>d.removeEventListener("scroll",O)},[]),t.useLayoutEffect(()=>{if(Re){P.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:D,scrollPosition:H.current}));const d=K(e-D,0,e);H.current>d&&se(d)}else se(0)},[Re,se,e,D]);const fe=t.useRef({isScrollable:Re,viewportSize:D,wheelSpeedMultiplier:pe,overscrollBehavior:ie});t.useLayoutEffect(()=>{fe.current={isScrollable:Re,viewportSize:D,wheelSpeedMultiplier:pe,overscrollBehavior:ie}},[Re,D,pe,ie]);const N=t.useCallback(d=>{if(gn(d))return!1;const{isScrollable:O,viewportSize:J,wheelSpeedMultiplier:ee,overscrollBehavior:de}=fe.current,te=pn(d,J);if(te.isZoomGesture)return!1;if(te.isHorizontalDominant)return ot.current?(Ar(d),d.preventDefault(),F(),ot.current(te.horizontalDelta),!0):!1;if(!O||te.verticalDelta===0)return!1;let De=te.verticalDelta;if(ee!==1&&(De*=ee),de!=="contain"){const ve=H.current,he=Math.max(Ve.current.contentSize-J,0);if(De>0&&ve>=he||De<0&&ve<=0)return!1}return Ar(d),d.preventDefault(),F(),P.debug("[ScrollPane] wheel event",()=>({deltaY:De,scrollPosition:H.current,wheelSpeedMultiplier:ee,deltaMode:d.deltaMode,scrollTop:j.current?.scrollTop})),se(ve=>ve+De),!0},[se,F]);t.useEffect(()=>{const d=ee=>{N(ee)},O=()=>{F()},J=T.current;return J&&(J.addEventListener("wheel",d,{passive:!1}),J.addEventListener("pointerdown",O,{capture:!0,passive:!0})),()=>{J&&(J.removeEventListener("wheel",d),J.removeEventListener("pointerdown",O,{capture:!0}))}},[N,F]),t.useImperativeHandle(Ee,()=>({scrollTo:(d,O)=>(F(),se(d,O)),getScrollPosition:()=>H.current,getContentSize:()=>e,getViewportSize:()=>D,applyWheel:N}),[se,e,D,F,N]);const B=t.useId(),Le=oe?.id??B,R=t.useRef({pointerType:"",pointerId:null,startClientY:0,startClientX:0,lastPanClientX:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1,scaleX:1}),dt=t.useRef(m),Fe=t.useRef(g);t.useEffect(()=>{dt.current=m},[m]),t.useEffect(()=>{Fe.current=g},[g]);const ct=t.useRef(Re);t.useEffect(()=>{ct.current=Re},[Re]);const He=t.useRef(Ke);t.useEffect(()=>{He.current=Ke},[Ke]),t.useEffect(()=>{const d=R.current;if(m&&Re&&(d.pointerId===null||gr(d.pointerType,g))||d.pointerId===null)return;const O=j.current;d.clickResetTimer!==null&&(window.clearTimeout(d.clickResetTimer),d.clickResetTimer=null);const J=d.isDragging&&d.shouldCancelNextClick,ee=d.pointerId;d.pointerId=null,d.pointerType="",d.startClientY=0,d.startScroll=0,d.isDragging=!1,d.shouldCancelNextClick=J,d.velocitySamples=[],d.scale=1,O?.hasPointerCapture(ee)&&O.releasePointerCapture(ee)},[m,g,Re]),t.useEffect(()=>{const d=j.current;if(!d)return;const O=6,J=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),ee=()=>{const h=R.current;h.pointerId=null,h.pointerType="",h.startClientY=0,h.startScroll=0,h.isDragging=!1,h.velocitySamples=[],h.scale=1},de=()=>{const h=R.current;h.clickResetTimer!==null&&(window.clearTimeout(h.clickResetTimer),h.clickResetTimer=null)},te=h=>{const E=R.current,je=J();E.velocitySamples.push({clientY:h,time:je});const et=He.current.velocitySampleWindow;E.velocitySamples=E.velocitySamples.filter(qe=>je-qe.time<=et)},De=h=>h instanceof HTMLElement&&h.closest("[data-scrollpane-ignore-drag='true']")!==null,ve=h=>{const E=R.current;E.shouldCancelNextClick&&(h.preventDefault(),h.stopPropagation(),E.shouldCancelNextClick=!1)},he=h=>{const E=R.current;if(!E.isDragging){if(E.isDragging=!0,E.shouldCancelNextClick=!0,!d.hasPointerCapture(h.pointerId))try{d.setPointerCapture(h.pointerId)}catch{}te(h.clientY)}},be=h=>h.isTrusted||h.target===d,Qe=h=>{const E=R.current;d.hasPointerCapture(h)&&d.releasePointerCapture(h),E.shouldCancelNextClick=!1,de(),ee()},Ae=h=>{const E=R.current;if(E.pointerId!==h.pointerId)return;if(h.buttons===0&&xn(h.pointerType)){Qe(h.pointerId);return}if(!(dt.current&&ct.current)||!gr(h.pointerType,Fe.current))return;if(!E.isDragging){const bt=Math.abs(h.clientY-E.startClientY),Me=st.current?Math.abs(h.clientX-E.startClientX):0;if(Math.max(bt,Me)<O||(he(h),!E.isDragging))return}te(h.clientY);const je=(h.clientY-E.startClientY)/(E.scale||1),et=E.startScroll-je;Se.current(et);const qe=st.current;if(qe){const bt=h.clientX-E.lastPanClientX;E.lastPanClientX=h.clientX,bt!==0&&qe(-bt/(E.scaleX||1))}h.cancelable&&h.preventDefault()},we=()=>{const h=R.current;return h.pointerId!==null||!h.shouldCancelNextClick?!1:(de(),h.clickResetTimer=window.setTimeout(()=>{const E=R.current;E.shouldCancelNextClick=!1,E.clickResetTimer=null},0),!0)},it=h=>{const E=R.current;if(E.pointerId!==h.pointerId){we();return}E.isDragging&&E.shouldCancelNextClick&&h.cancelable&&(h.preventDefault(),h.stopPropagation()),E.isDragging&&te(h.clientY);let je=0;if(E.isDragging&&E.velocitySamples.length>=2){const qe=E.velocitySamples,bt=He.current.velocitySampleWindow,Me=qe[qe.length-1],ut=qe.find(Ue=>Me.time-Ue.time<=bt)??qe[0];if(Me&&ut&&Me.time!==ut.time){const Ue=Me.clientY-ut.clientY,Ot=Me.time-ut.time;je=-(Ue/Ot)/(E.scale||1)}}de(),E.shouldCancelNextClick&&(E.clickResetTimer=window.setTimeout(()=>{const qe=R.current;qe.shouldCancelNextClick=!1,qe.clickResetTimer=null},0));const et=He.current.startVelocityThreshold;ee(),d.hasPointerCapture(h.pointerId)&&d.releasePointerCapture(h.pointerId),Math.abs(je)>=et&&Ye.current?.(je)},$e=h=>{if(R.current.pointerId!==null){if(!h.isPrimary||h.pointerType!==R.current.pointerType)return;Qe(R.current.pointerId)}if(R.current.shouldCancelNextClick&&(de(),R.current.shouldCancelNextClick=!1),!(dt.current&&ct.current)||!gr(h.pointerType,Fe.current)||h.button!==0&&h.pointerType==="mouse"||h.ctrlKey||h.metaKey||h.altKey||De(h.target))return;window.dispatchEvent(new CustomEvent(Rr,{detail:{paneId:B}})),lt.current?.();const E=R.current;de(),E.pointerId=h.pointerId,E.pointerType=h.pointerType,E.startClientY=h.clientY,E.startClientX=h.clientX,E.lastPanClientX=h.clientX,E.startScroll=H.current,E.scale=wr(d,"y"),E.scaleX=st.current?wr(d,"x"):1,E.isDragging=!1,E.shouldCancelNextClick=!1,E.velocitySamples=[]},at=h=>{if(R.current.pointerId!==h.pointerId){we();return}be(h)&&Qe(h.pointerId)},Te=[["click",ve,!0],["pointerdown",$e,{passive:!1}],["lostpointercapture",h=>{h.target!==d||R.current.pointerId!==h.pointerId||Qe(h.pointerId)},void 0]],ht=[["pointermove",Ae,{passive:!1}],["pointerup",it,void 0],["pointercancel",at,void 0]];return ur(d,Te,"add"),ur(window,ht,"add"),()=>{ur(d,Te,"remove"),ur(window,ht,"remove");const h=R.current;h.pointerId!==null&&d.hasPointerCapture(h.pointerId)&&d.releasePointerCapture(h.pointerId),de(),ee()}},[B]);const Vt=t.useCallback(d=>(F(),se(d)),[se,F]);return A.jsxs("div",{ref:T,"data-testid":I,"data-self-measured":ye?"true":void 0,className:yt.twMerge("aqvs-scroll-pane",M),style:v,children:[A.jsxs("div",{ref:j,className:yt.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:ye?void 0:D,paddingTop:xe.top,paddingBottom:xe.bottom,...m&&Re&&g.some(d=>d==="touch"||d==="pen")?{touchAction:"none"}:{}},...oe,id:Le,children:[V,r(H.current)]}),A.jsx(Cr,{contentSize:e,viewportSize:D,scrollPosition:H.current,onScroll:Vt,enableThumbDrag:a,enableTrackClick:l,enableArrowButtons:f,scrollBarWidth:i,ariaControls:Le,tapScrollCircleOptions:G,itemCount:me,renderThumbOverlay:Ne,visibleStartIndex:z,visibleEndIndex:Z},"scrollbar"),ne?.()]})}),Lr=(r,e,n)=>Math.min(Math.max(r,e),n),vn=({dragState:r,normalizedDistance:e,sizeScale:n,size:s})=>{const i=Math.max(s/2,1),a=1+e*.65,l=Math.max(.65,1-e*.25),f=r.direction*e*26*n,m=.8+e*.18,g=3*n,w=6*n,M=22*n,I=Math.abs(f)+w,v=f>0?g:-Math.abs(f)-g,V=Math.max(2.5,3*n),G=Lr(r.offsetX,-i,i),W=Lr(r.offsetY,-i,i),me=i*.35,Ne=G/i*me,pe=W/i*me,ie=Ne*.45,ze=pe*.45,_=Math.max(M*.38,6),C=.65+e*.2,z=r.active;return A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${l}, ${a})`,transition:z?"40ms transform ease-out":"200ms ease transform"}}),A.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:M,height:M,transform:`translate(calc(-50% + ${Ne}px), calc(-50% + ${pe}px)) scale(${l}, ${m*a})`,transition:z?"70ms transform ease-out":"200ms ease transform"}}),A.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:_,height:_,transform:`translate(calc(-50% + ${ie}px), calc(-50% + ${ze}px)) scale(${l}, ${a})`,opacity:C,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:z?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),A.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:V,height:I,transform:`translate(-50%, ${v}px)`,opacity:e,transition:z?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},tr=100,wn=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},br=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},rr=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,l;const f=s?.baseValue;if(f!==void 0&&!(Number.isFinite(f)&&f>=0))throw new RangeError(`[FenwickMapTree] options.baseValue must be a finite number >= 0, received ${f}.`);if(i>0&&f!==void 0){if(a=f,s?.materialize){const m=s?.sampleRange??{from:0,to:Math.min(tr-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),w=Math.min(Math.trunc(m.to),i-1);g>w&&(g=0,w=Math.min(tr-1,i-1)),l={from:g,values:_t._collectValidatedValues(n,g,w)}}}else if(i>0){const m=s?.sampleRange??{from:0,to:Math.min(tr-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),w=Math.min(Math.trunc(m.to),i-1);if(g>w&&(g=0,w=Math.min(tr-1,i-1)),i>tr)a=_t._sampleBaseValueStrided(n,i,tr),s?.materialize&&(l={from:g,values:_t._collectValidatedValues(n,g,w)});else{const M=_t._collectValidatedValues(n,g,w);a=_t._modeOrMedian([...M]),s?.materialize&&(l={from:g,values:M})}}if(this.size=i,this.tree=new Map,this.deltas=new Map,this.total=void 0,this.valueFn=n,this.baseValue=a,l)for(let m=0;m<l.values.length;m++){const g=l.from+m;if(g>=this.size)break;const w=l.values[m]-this.baseValue;w!==0&&(this.deltas.set(g,w),this._updateTree(g,w))}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(br(e(a),a));return i}static _modeOrMedian(e){if(e.length===0)return 0;e.sort((l,f)=>l-f);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 l of e){const f=(i.get(l)??0)+1;i.set(l,f),f>a&&(a=f)}if(a>e.length*.2){const l=[];for(const[m,g]of i.entries())g===a&&l.push(m);const f=l.reduce((m,g)=>m+g,0);s=Math.floor(f/l.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 l=0;l<n&&a.length<s;l+=i)a.push(br(e(l),l));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 l=(n.get(s)??this.deltas.get(s)??0)+i;if(l+this.baseValue<-1e-9)throw new Error(`Change would make the value at index ${s} negative: ${l+this.baseValue}`);n.set(s,l)}for(const{index:s,change:i}of e){const l=(this.deltas.get(s)??0)+i;l===0?this.deltas.delete(s):this.deltas.set(s,l),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=rr(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 l=s.has(i)?s.get(i)??0:this.deltas.get(i)??0,f=l+this.baseValue,m=a-f;m!==0&&n.push({index:i,change:m}),s.set(i,l+m)}return n}_computeTreeTotal(){if(this.size<=0)return 0;let e=0,n=this.size;for(;n>0;){e+=this.tree.get(n)??0;const s=rr(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=br(this.valueFn(e),e)-this.baseValue;if(a!==s&&(a===0?this.deltas.delete(e):this.deltas.set(e,a),n)){const l=a-s;this._updateTree(e,l)}}}_materializeRanges(e,n,s=!1){if(!(e?.materialize&&this.valueFn))return;const i=e.ranges;if(i&&i.length>0){for(const f of i){const m=Math.max(0,Math.trunc(f.from)),g=Math.min(Math.trunc(f.to),this.size-1);for(let w=m;w<=g;w++)this._materialize(w)}if(n===void 0)return;if(s){this._materialize(n);return}const a=i[0].from,l=i[i.length-1].to;n>=a&&n<=l&&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 f=this.deltas.get(a)??0;if(this._materialize(a),(this.deltas.get(a)??0)===f)break}const l=this.prefixSum(a);return{index:a,total:this.total??l.total,cumulative:l.cumulative,currentValue:l.currentValue,safeIndex:l.safeIndex}}_descend(e,n){let s=0,i=0,a=1;for(;a<<1<=this.size;)a<<=1;for(;a>0;a>>=1){const l=s+a;if(l<=this.size){const m=(this.tree.get(l)??0)+this.baseValue*a;(n?i+m<e:i+m<=e)&&(s=l,i+=m)}}return n?s:s-1}_findIndexLarge(e,n,s){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};const i=wn(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 l=0n,f=i-1n,m,g,w=this.total;for(;l<=f;){const v=l+f>>1n,V=Number(v),G=this.prefixSum(V);if(w=G.total,s?G.cumulative>=e:G.cumulative<=e)if(m=v,g=G,s){if(v===0n)break;f=v-1n}else l=v+1n;else if(s)l=v+1n;else{if(v===0n)break;f=v-1n}}const M=g,I=m!==void 0?Number(m):-1;if(a&&I>=0){const v=this.deltas.get(I)??0;if(this._materialize(I),(this.deltas.get(I)??0)!==v)continue}return{index:I,total:w,cumulative:M?.cumulative,currentValue:M?.currentValue,safeIndex:M?.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=K(Math.trunc(e),0,this.size-1),i=n?.materializeOption;this._materializeRanges(i,s,!0);let a=0,l=s+1;for(;l>0;){const m=this.tree.get(l)??0;a+=m;const g=rr(l);if(g===0)break;l-=g}const f=i?.materialize?this.get(s):(this.deltas.get(s)||0)+this.baseValue;return{cumulative:a+this.baseValue*(s+1),total:this.total,currentValue:f,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&&P.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 l=rr(a);if(l===0)break;a+=l}}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&&P.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 l=rr(a);if(l===0)break;a+=l}for(;a<=i;){this.tree.set(a,(this.tree.get(a)??0)+n);const l=rr(a);if(l===0)break;a+=l}}_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 l=this.deltas.get(a);l===void 0||l===0||this._propagateDeltaToGrownNodes(a,l,e,n)}else for(const[a,l]of this.deltas.entries())l===0||a<s||this._propagateDeltaToGrownNodes(a,l,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 Rn=(r,e)=>{const n=r?.sampleRange,s=e?.sampleRange;return n===s?!1:n&&s?n.from!==s.from||n.to!==s.to:!0},Pr=(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 l=i.current,f=a.current,m=f.size!==s,g=f.valueOrFn!==e,w=Rn(f.options,n)||f.options?.baseValue!==n?.baseValue,M=f.size===0&&s>0&&(!i.current||i.current.base===0);if(g||w){const I=n?.resetOnValueFnChange??!0;w||g&&I||M?(n?.debug&&P.debug("[useFenwickMapTree] reset",{valueOrFnChanged:g,optionsChanged:w}),l.reset(s,e,n)):(m&&(n?.debug&&P.debug("[useFenwickMapTree] resize (with valueFn change)",{from:f.size,to:s}),l.changeSize(s)),n?.debug&&P.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:g}),l.setValueFn(e,{reset:!1})),a.current={size:s,valueOrFn:e,options:n}}else m&&(n?.debug&&P.debug("[useFenwickMapTree] resize",{from:f.size,to:s}),M?l.reset(s,e,n):l.changeSize(s),a.current={size:s,valueOrFn:e,options:n});return l};class Sn{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class xr{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 Yr(r){const e=t.useRef(new Map),n=t.useRef(new xr),s=Math.floor(r),i=t.useRef(s);t.useEffect(()=>{if(i.current=s,Number.isNaN(s)||s<0){P.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`),e.current.clear(),n.current=new xr;return}if(Number.isFinite(s))for(;e.current.size>s;){const w=n.current.removeHead();if(w)e.current.delete(w.key);else break}},[r,s]);const a=t.useCallback(w=>{const M=e.current.get(w);if(M)return n.current.moveToTail(M),M.value},[]),l=t.useCallback((w,M)=>{const I=i.current;if(Number.isNaN(I)||I<=0)return;let v=e.current.get(w);if(v)v.value=M,n.current.moveToTail(v);else{if(e.current.size>=I){const V=n.current.removeHead();V&&e.current.delete(V.key)}v=new Sn(w,M),e.current.set(w,v),n.current.addToTail(v)}},[]),f=t.useCallback(w=>e.current.has(w),[]),m=t.useCallback(w=>{const M=e.current.get(w);M&&(n.current.remove(M),e.current.delete(w))},[]),g=t.useCallback(()=>{e.current.clear(),n.current=new xr},[]);return t.useMemo(()=>({get:a,set:l,has:f,remove:m,clear:g}),[a,l,f,m,g])}const Mn=1e4,In=()=>{const{get:r,set:e,has:n,clear:s}=Yr(Mn);return t.useMemo(()=>({get:r,set:e,has:n,clear:s}),[r,e,n,s])},En=(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 l=f=>{n.current?.enableBridge!==!1&&s.current.current?.applyWheel(f)};return a.addEventListener("wheel",l,{passive:!1}),i.current.set(a,l),()=>{i.current.get(a)===l&&(a.removeEventListener("wheel",l),i.current.delete(a))}},[])},Be=(r,e)=>e<=0?0:K(r,0,e-1),Dr=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),gt=(r,e)=>r<=e?0:r-e,Qt=(r,e)=>r<=0?0:r+e,lr=1e3,Sr=2e3,$r=1048576,yn=40,or=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},Tn=(r,e,n,s,i,a,l,f)=>{const m=or(s);if(m===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const g=_=>_<0n?0n:_>=m?m-1n:_,w={materializeOption:{materialize:!1}},{index:M,cumulative:I}=a.findIndexAtOrAfter(r,w);let v;M===-1?v=m-1n:(I===r?v=or(M+1):v=or(M),v>=m&&(v=m-1n)),r<=0&&(v=0n),f&&r>=l&&(v=m-1n);const V=_=>{const C=Number(_);if(!Number.isSafeInteger(C))return null;const{cumulative:z}=a.prefixSum(C,{materializeOption:{materialize:!1}});if(!Number.isFinite(z))return null;const{index:Z}=a.findIndexAtOrAfter(z+.5,{materializeOption:{materialize:!1}});if(Z===-1)return null;const ne=or(Z);return ne>_?ne:null},G=_=>{let C=0,z=_,Z=_,ne=0n,ae=0;for(;z<m&&C<e;){const oe=Number(z),Ee=i(oe);if(C+=Ee,Z=z,z+=1n,ne+=1n,!Number.isFinite(Ee)||Ee<0)break;if(Ee===0){if(ae+=1,ae>lr){const H=V(Z);if(H!==null&&H>z)z=H,ae=0;else if(H!==null&&H===z&&i(Number(z))>0)ae=0;else break}}else ae=0}return ne===0n&&(Z=_),{height:C,end:Z}};let{height:W,end:me}=G(v);if(W<e&&v>0n){let _=v,C=W,z=0;for(;_>0n&&C<e;){_-=1n;const ne=Number(_),ae=i(ne);if(C+=ae,!Number.isFinite(ae)||ae<0)break;if(ae===0){if(z+=1,z>lr){const oe=Number(_);if(!Number.isSafeInteger(oe))break;const{cumulative:Ee}=a.prefixSum(oe,{materializeOption:{materialize:!1}});if(!Number.isFinite(Ee))break;const{index:H}=a.findIndexAtOrAfter(Ee-.5,{materializeOption:{materialize:!1}}),T=H===-1?-1n:or(H);if(T>=0n&&T<_)_=T+1n,z=0;else if(T===_&&_>=1n&&i(Number(_-1n))>0)z=0;else break}}else z=0}v=g(_);const Z=G(v);W=Z.height,me=Z.end}const Ne=g(v),pe=g(me),ie=g(Ne-BigInt(Math.max(0,n))),ze=g(pe+BigInt(Math.max(0,n)));return{renderingStartIndex:Be(Number(ie),s),renderingEndIndex:Be(Number(ze),s),visibleStartIndex:Be(Number(Ne),s),visibleEndIndex:Be(Number(pe),s)}},jr=(r,e,n,s,i,a,l)=>{if(s===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const f=Number.isFinite(l),m=f?Math.min(Math.max(0,r),l):Math.max(0,r);if(s>=Number.MAX_SAFE_INTEGER)return Tn(m,e,n,s,i,a,l,f);const{index:g,cumulative:w,currentValue:M}=a.findIndexAtOrAfter(m,{materializeOption:{materialize:!1}}),I=g===-1?e<=0||(w??0)<m+(M??0)?s-1:0:g;let v=Be(I,s),V=0;if(g!==-1&&w===m)v=Be(g+1,s),V=0;else if(v===g&&w!==void 0&&M!==void 0)V=w-M-m;else{const{cumulative:_,currentValue:C}=a.prefixSum(v,{materializeOption:{materialize:!1}});V=(_??0)-(C??0)-m}const G=V,W=(_,C)=>{let z=_,Z=C,ne=0;for(;z<s&&Z<e;){const ae=i(z);if(Z+=ae,z++,!Number.isFinite(ae)||ae<0)break;if(ae===0){if(ne++,ne>lr){const{cumulative:oe}=a.prefixSum(z-1,{materializeOption:{materialize:!1}}),{index:Ee}=Number.isFinite(oe)?a.findIndexAtOrAfter(oe+.5,{materializeOption:{materialize:!1}}):{index:-1};if(Ee>z)z=Ee,ne=0;else if(Ee===z&&i(z)>0)ne=0;else break}}else ne=0}return{cursor:z,height:Z}},me=W(v,V);let Ne=me.cursor;if(V=me.height,V<e&&v>0){let _=V+Math.abs(Math.min(0,G)),C=v-1,z=0;for(;C>=0&&_<e;){const ne=i(C);if(_+=ne,!Number.isFinite(ne)||ne<0){C--;break}if(ne===0){if(z++,z>lr){const{cumulative:ae}=a.prefixSum(C,{materializeOption:{materialize:!1}}),{index:oe}=Number.isFinite(ae)?a.findIndexAtOrAfter(ae-.5,{materializeOption:{materialize:!1}}):{index:-1};if(oe!==-1&&oe<C){C=oe,z=0;continue}if(oe===C&&C>=1&&i(C-1)>0)z=0;else{C--;break}}}else z=0;C--}v=Be(C+1,s);const Z=W(v,0);Ne=Z.cursor,V=Z.height}const pe=Be(v-n,s),ie=Be(Math.max(Ne-1,v),s),ze=Be(ie+n,s);return{renderingStartIndex:pe,renderingEndIndex:ze,visibleStartIndex:v,visibleEndIndex:ie}},_r=(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 l=f=>{if(i.id=null,i.arg===null)return;const m=f-i.last;if(s===0||i.last===0||m>=s){if(r.current)try{n(r.current,i.arg)}catch(g){console.error("[useThrottledInvoker] Error invoking callback",g)}i.arg=null,i.last=f}i.arg!==null&&(i.id=requestAnimationFrame(l))};i.id=requestAnimationFrame(l)},[s,n,r,i])},Cn=t.memo(({index:r,top:e,height:n,item:s,children:i,clipItemHeight:a,enableKeyboardNavigation:l,onKeyDown:f,onEscapeKeyDown:m,onFocus:g,registerItemRef:w})=>{const M=t.useCallback(W=>w(r,W),[r,w]),I=t.useCallback(W=>f(W,r),[r,f]),v=t.useCallback(W=>m?.(W,r),[r,m]),V=t.useCallback(()=>g(r),[r,g]),G=t.useCallback(W=>{W.currentTarget.focus({preventScroll:!0})},[]);return A.jsx("div",{ref:M,"data-index":r,"data-virtualscroll-item":"true",className:"aqvs-item-container",style:{top:e,height:n,overflow:a?"hidden":void 0},tabIndex:l?-1:void 0,onPointerDown:l?G:void 0,onKeyDownCapture:l?I:void 0,onKeyDown:l&&m?v:void 0,onFocusCapture:l?V:void 0,children:i(s,r)})}),Pn=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:s,viewportSize:i,overscanCount:a=15,className:l,testId:f,onScroll:m,onRangeChange:g,children:w,background:M,initialScrollIndex:I,initialScrollOffset:v,initialScrollAnchor:V,callbackThrottleMs:G=5,contentInsets:W,onItemFocus:me,scrollBarOptions:Ne,behaviorOptions:pe,onWheelHorizontal:ie,onPanHorizontal:ze,horizontalKeyInputs:_,horizontalKeyStep:C=yn,contentProps:z,liveRegion:Z},ne)=>{const{width:ae,enableThumbDrag:oe,enableTrackClick:Ee,enableArrowButtons:H,enableScrollToTopBottomButtons:T,renderThumbOverlay:j,tapScrollCircleOptions:ye}=Ne??{},{enablePointerDrag:ge,pointerDragInputs:ke,enableKeyboardNavigation:D=!0,enableEscapeRowReturn:nt=!1,wheelSpeedMultiplier:ot,inertiaOptions:st,overscrollBehavior:Je,clipItemHeight:Ke=!1,resetOnGetItemHeightChange:xe=!1}=pe??{},[Ve,Re]=t.useState(0),se=i??Ve,Se=t.useCallback(c=>{Re(p=>p===c?p:c)},[]),F=t.useRef(null),lt=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),Q=t.useRef(V&&r>0?{index:K(Math.trunc(V.index),0,r-1),align:"top",offset:-Math.max(0,V.offsetPx??0)}:null),Ye=t.useRef(!1),fe=t.useRef(!0);t.useEffect(()=>{if(fe.current){fe.current=!1;return}xe&&(Q.current=null)},[xe,s]);const N=t.useMemo(()=>Dr(W),[W]),[B]=t.useState(()=>{const p=V?.index??I,x=typeof p=="number"&&Number.isFinite(p)?Math.max(0,Math.trunc(p)):0;return{from:Math.max(0,x-50),to:x+50}}),Le=t.useMemo(()=>({sampleRange:B,resetOnValueFnChange:xe,materialize:!0}),[xe,B]),R=Pr(r,s,Le),[dt]=t.useState(()=>{let c=0,p=0;if(V&&r>0){const x=K(Math.trunc(V.index),0,r-1),q=Math.max(0,V.offsetPx??0),X=K(x-a*2,0,r-1),Y=K(x+a*2,0,r-1),$=x>0||q>0?{materializeOption:{materialize:!0,ranges:[{from:X,to:Y}]}}:void 0,{cumulative:ce,total:Oe,currentValue:Pe}=R.prefixSum(x,$),ue=Math.max(ce-Pe+q,0);c=Qt(ue,N.top),p=Oe??R.getTotal()}else if(typeof I=="number"){const x=K(I,0,r-1),q=K(x-a*2,0,r-1),X=K(x+a*2,0,r-1),Y=I>0?{materializeOption:{materialize:!0,ranges:[{from:q,to:X}]}}:void 0,{cumulative:$,total:ce,currentValue:Oe}=R.prefixSum(I,Y),Pe=Math.max($-Oe,0);c=Qt(Pe,N.top),p=ce??R.getTotal()}else typeof v=="number"&&(c=Qt(Math.max(v,0),N.top)),p=R.getTotal();return{position:c,total:p}}),[Fe,ct]=t.useState(dt.position),[He,Vt]=t.useState(dt.total),d=t.useRef(dt.position),O=t.useRef(N.top),J=t.useRef(m??void 0),ee=t.useRef(g??void 0),de=t.useRef(ie),te=(_?.length??0)>0,De=!!ie;t.useEffect(()=>{te&&(D||P.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),De||P.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(C)&&C>0||P.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${C}. Horizontal arrow keys are left untouched.`))},[te,De,D,C]);const ve=t.useRef(new Map),he=t.useRef(null),be=t.useRef(null),[Qe,Ae]=t.useState(null),[we,it]=t.useState(!1),$e=t.useRef(null),at=t.useRef(!1),le=t.useRef(0),Te=t.useRef(!1),ht=t.useRef(!1),h=t.useRef(r);h.current!==r&&(h.current=r,ht.current=!0),t.useLayoutEffect(()=>{J.current=m??void 0,ee.current=g??void 0,de.current=ie},[g,m,ie]);const E=t.useCallback(c=>{if(D&&c&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},[D]),je=t.useCallback((c,{position:p,totalHeight:x})=>{c(p,x)},[]),et=_r(J,G,je),qe=t.useCallback((c,p)=>{c(p)},[]),bt=_r(ee,G,qe),Me=t.useRef(N.top);Me.current=N.top;const ut=t.useRef(et);ut.current=et,t.useEffect(()=>(Ye.current=!1,()=>{Ye.current=!0,$e.current&&(clearTimeout($e.current),$e.current=null)}),[]),t.useEffect(()=>{D||(ve.current.clear(),he.current=null,be.current=null)},[D]);const Ue=t.useCallback((c,p)=>{if(!p){ve.current.delete(c);return}D&&(ve.current.set(c,p),he.current===c&&(he.current=null,be.current=c,E(p)))},[D,E]),Ot=.01,Rt=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:dt.position}),Xt=t.useCallback(()=>{const c=Rt.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{Xt()},[Xt]);const _e=t.useRef(()=>{}),St=t.useCallback(()=>{const c=Rt.current;c.rafId=null;const p=d.current,x=gt(p,Me.current),q=R.getTotal();if(ct(Y=>Math.abs(Y-p)<Ot?Y:p),Math.abs(c.lastRenderedPosition-p)>=Ot?(ut.current({position:x,totalHeight:q}),c.lastRenderedPosition=p,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){Xt();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(Y=>_e.current(Y));return}c.loopActive=!1},[R,Xt]);_e.current=St;const Kt=t.useCallback(()=>{const c=Rt.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(St);return}c.loopActive=!1}},[St]),Ce=t.useCallback((c,p)=>{const x=p?.immediate??!1,q=gt(c,N.top);if(d.current=c,x){Rt.current.lastRenderedPosition=c,Rt.current.idleFrames=0,ct(c),et({position:q,totalHeight:R.getTotal()});return}Kt()},[Kt,R,N.top,et]),xt=t.useCallback((c,p=0)=>{const x=F.current;if(!x)return c;const q=x.getScrollPosition();le.current+=1;const X=x.getContentSize()+p,Y=x.getViewportSize(),$=x.scrollTo(c,{contentSize:X,viewportSize:Y});return $===q&&(le.current=Math.max(0,le.current-1)),Math.abs($-c)>.5&&(Te.current=!0),$},[]),Mt=t.useRef(!1);t.useEffect(()=>{if(!Mt.current)if(Mt.current=!0,V==null&&typeof I!="number"&&typeof v=="number"){const c=Qt(Math.max(v,0),N.top),p=Math.abs(c-d.current)>.5;Ce(c,{immediate:!0}),p&&F.current?.scrollTo(c)}else Ce(d.current,{immediate:!0})},[V,I,v,N.top,Ce]),t.useEffect(()=>{const c=R.getTotal();if(He!==c){Vt(c);return}if(Te.current){Te.current=!1;const p=F.current;if(p&&Math.abs(p.getScrollPosition()-d.current)>.5){const x=xt(d.current);Te.current=!1,Ce(x,{immediate:!0})}}},[R,He,r,xt,Ce]),t.useEffect(()=>{if(Q.current!==null){const{index:c,align:p,offset:x}=Q.current,q=Be(c,r),{cumulative:X,currentValue:Y}=R.prefixSum(q,{materializeOption:{materialize:!1}});if(X!==void 0&&Y!==void 0){const $=Math.max(X-Y,0);let ce=$;p==="bottom"?ce=X-se:p==="center"&&(ce=$+Y/2-se/2),x&&(ce-=x),ce=Math.max(0,ce);const Oe=Math.max(0,He+N.top+N.bottom-se),Pe=Math.min(Qt(ce,N.top),Oe);Math.abs(Pe-d.current)>1&&(P.debug("[VirtualScroll] Drift correction",{from:d.current,to:Pe,targetIndex:q}),le.current===0&&(le.current+=1),F.current?.scrollTo(Pe),Ce(Pe,{immediate:!0}))}}ht.current=!1},[He,R,r,N.top,Ce,se,N.bottom]),t.useEffect(()=>{const c=O.current;if(c===N.top||(O.current=N.top,Q.current))return;const p=gt(d.current,c),x=Qt(p,N.top);d.current=x,F.current?.scrollTo(x),Ce(x,{immediate:!0})},[N.top,Ce]);const At=t.useCallback((c,p)=>{if(r===0)return;const x=Be(c,r),q=R.get(x),X=p-q,Y=R.update(x,p);Y!==void 0&&Vt(Y),P.debug("[VirtualScroll] Updated item size manually",{index:x,size:p,total:Y});let $=Q.current?Q.current.index:null;if($===null){const ce=d.current,Oe=Dr(W).top,Pe=gt(ce,Oe),{index:ue,cumulative:rt}=R.findIndexAtOrAfter(Pe,{materializeOption:{materialize:!1}});$=rt!==void 0&&rt===Pe?ue+1:ue}if($!==-1&&x<$&&X!==0){const ce=d.current,Oe=ce+X;xt(Oe,X),Ce(Oe,{immediate:!0}),P.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:ce,to:Oe,causedByIndex:x,delta:X,activeVisibleStartIndex:$})}},[R,r,xt,Ce,W]),u=t.useCallback((c,p)=>{if(!F.current||r===0)return;const x=Be(c,r),q=Be(x-a*2,r),X=Be(x+a*2,r),{cumulative:Y,total:$,currentValue:ce}=R.prefixSum(x,{materializeOption:{materialize:!0,ranges:[{from:q,to:X}]}});if(P.debug("[VirtualScroll] Scrolling to index:",x,"ItemBottom:",Y,"Total height:",$,"ItemHeight:",ce,"safeIndexFrom:",q,"safeIndexTo:",X),!$)return;const Oe=Math.max(Y-ce,0);let Pe=Oe;p?.align==="bottom"?Pe=Y-se:p?.align==="center"&&(Pe=Oe+ce/2-se/2),p?.offset&&(Pe-=p.offset),Pe=Math.max(0,Pe);const ue=Qt(Pe,N.top),rt=F.current?.getContentSize()??$+N.top+N.bottom,We=Math.max(0,rt-se),Ge=Math.min(ue,We);Q.current={index:x,align:p?.align,offset:p?.offset};const Gt=F.current?.getScrollPosition()??-1,Jt=Math.abs(Gt-Ge)>.5;at.current=!1,le.current=0,Jt&&(at.current=!0,le.current+=1,F.current?.scrollTo(Ge)),Vt($),Ce(Ge,{immediate:!0}),P.debug("[VirtualScroll] Setting scroll position to:",Ge,{original:ue,max:We})},[R,a,r,N.top,N.bottom,se,Ce]),y=t.useRef(V&&r===0?V:null);t.useEffect(()=>{const c=y.current;!c||r===0||(y.current=null,u(K(Math.trunc(c.index),0,r-1),{align:"top",offset:-Math.max(0,c.offsetPx??0)}))},[r,u]);const k=t.useCallback(c=>{if(!F.current||r===0)return;const p=R.getTotal(),x=K(Math.floor(c),0,p),{index:q,cumulative:X,currentValue:Y}=R.findIndexAtOrAfter(x,{materializeOption:{materialize:!1}}),ce=(X??0)-(Y??0)-x;u(q,{offset:ce})},[R,r,u]),U=t.useCallback(()=>{if(r===0)return null;const c=gt(d.current,N.top),{index:p,cumulative:x,currentValue:q}=R.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(p===-1)return{index:r-1,offsetPx:0};if(x===c)return{index:K(p+1,0,r-1),offsetPx:0};const X=(x??0)-(q??0);return{index:p,offsetPx:Math.max(0,c-X)}},[R,r,N.top]),Ie=t.useCallback(c=>{const p=gt(d.current,N.top),x=typeof c=="function"?c(p):c;k(x);const q=F.current?.getScrollPosition(),X=typeof q=="number"?q:d.current;return Ce(X),gt(X,Me.current)},[N.top,k,Ce]),Xe=t.useCallback(c=>{const p=F.current;if(!p)return gt(d.current,Me.current);const x=p.scrollTo(q=>q+c);return gt(x,Me.current)},[]),ft=t.useCallback(c=>F.current?.applyWheel(c)??!1,[]),tt=t.useCallback((c,p)=>{P.debug("[VirtualScroll] Scroll position changed:",c);const x=at.current;x&&(at.current=!1);const q=le.current>0;q&&(le.current=0);const X=ht.current&&h.current===r;if(x||q||X||(Q.current=null),Ce(c),T){if(x||q)return;const Y=c-p;if(P.debug("[VirtualScroll] Scroll diff:",Y,"New:",c,"Prev:",p),Math.abs(Y)>1){const $=Y>0?"down":"up";Ae($),it(!0),P.debug("[VirtualScroll] Showing scroll buttons. Direction:",$),$e.current&&clearTimeout($e.current),$e.current=setTimeout(()=>{it(!1),P.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[Ce,T,r]),Tt=t.useMemo(()=>gt(Fe,N.top),[N.top,Fe]),mt=t.useMemo(()=>{const c=R.getTotal(),p=jr(Tt,se,a,r,s,R,c);return P.debug("[VirtualScroll] Calculated rendering range:",()=>({...p,scrollPosition:Tt,renderingContentSize:c,overscanCount:a,viewportSize:se})),p},[Tt,se,a,r,s,R]),{renderingStartIndex:Ct,renderingEndIndex:Ft,visibleStartIndex:Pt,visibleEndIndex:Wt}=mt,vt=t.useCallback((c,p)=>{if(!D||r===0)return;const x=Be(c,r);if(!(p?.ensureVisible??!0)){const We=ve.current.get(x);We&&(he.current=null,be.current=x,E(We));return}const X=R.prefixSum(x,{materializeOption:{materialize:!1}}),Y=X.currentValue,$=Math.max(X.cumulative-Y,0),ce=$+Y,Oe=gt(d.current,N.top),Pe=Oe+se;if($<Oe||ce>Pe){u(x);const We=ve.current.get(x);We?(he.current=null,be.current=x,E(We)):he.current=x;return}const rt=ve.current.get(x);if(rt){he.current=null,be.current=x,E(rt);return}he.current=x},[D,r,R,N.top,u,E,se]),Ht=t.useCallback((c,p)=>{if(!(!D||c.defaultPrevented)&&!(c.altKey||c.metaKey||c.ctrlKey)&&c.target===c.currentTarget&&!c.currentTarget.isContentEditable){if(c.key==="ArrowLeft"||c.key==="ArrowRight"){const x=de.current;if(!x||c.shiftKey||!_?.includes("arrow")||!(Number.isFinite(C)&&C>0))return;c.preventDefault(),x(c.key==="ArrowLeft"?-C:C);return}if(c.key==="ArrowDown"){p<r-1&&(c.preventDefault(),vt(p+1));return}if(c.key==="ArrowUp"){p>0&&(c.preventDefault(),vt(p-1));return}if(c.key==="PageDown"){if(p<r-1){c.preventDefault();const{visibleStartIndex:x,visibleEndIndex:q}=lt.current,X=Math.max(q-x+1,1),Y=Math.max(X,1),$=Be(Math.min(p+Y,r-1),r);vt($)}return}if(c.key==="PageUp"&&p>0){c.preventDefault();const{visibleStartIndex:x,visibleEndIndex:q}=lt.current,X=Math.max(q-x+1,1),Y=Math.max(X,1),$=Be(p-Y,r);vt($)}}},[D,r,vt,_,C]),qt=t.useCallback((c,p)=>{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(),vt(p))},[vt]),nr=t.useCallback(c=>{if(!D)return;const p=Be(c,r);he.current=null,be.current=p,me?.(p)},[D,r,me]);t.useEffect(()=>{const c=F.current?.getScrollPosition()??0,p=d.current,x=gt(p,N.top);P.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:Ct,renderingEndIndex:Ft,visibleStartIndex:Pt,visibleEndIndex:Wt,scrollPositionState:Fe,paneScrollPosition:p,logicalScrollPosition:x,contentSize:He,scrollPaneScrollPosition:c})),bt({renderingStartIndex:Ct,renderingEndIndex:Ft,visibleStartIndex:Pt,visibleEndIndex:Wt,scrollPosition:x,totalHeight:He})},[He,Ft,Ct,N.top,bt,Fe,Wt,Pt]);const Nt=t.useCallback(()=>{if(!T)return null;const c=we&&Qe!==null,p=Qe==="up";return A.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:p?A.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:A.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:x=>{x.stopPropagation(),at.current=!0,u(0),it(!1)},children:"Top"})}):A.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:A.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:x=>{x.stopPropagation(),at.current=!0,u(r-1),it(!1)},children:"Bottom"})})})},[T,we,Qe,u,r]),zt=t.useRef(0),{visibleItems:Lt,renderAnchor:It}=t.useMemo(()=>{if(r===0)return{visibleItems:A.jsx("div",{className:"aqvs-no-items-container",children:A.jsx("div",{className:"aqvs-no-items-text",children:"No items"})}),renderAnchor:0};const c=Be(Ct,r),p=Be(Ft,r),{cumulative:x,currentValue:q}=R.prefixSum(c,{materializeOption:{materialize:!1}}),X=x-q;Number.isFinite(X)&&Math.abs(X-zt.current)>$r&&(zt.current=X);const Y=zt.current,$=[],ce=[];let Oe=0,Pe=X;for(let ue=c;ue<=p;ue++){if(ce.length>=Sr){P.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:Sr,safeRenderingStartIndex:c,safeRenderingEndIndex:p});break}const rt=s(ue),We=R.get(ue),Ge=rt-We;Ge!==0&&$.push({index:ue,value:rt});const Gt=Pe+Oe,Jt=n?n(ue):ue;ce.push(A.jsx(Cn,{index:ue,top:Gt-Y,height:rt,item:e(ue),clipItemHeight:Ke,enableKeyboardNavigation:D,onKeyDown:Ht,onEscapeKeyDown:nt?qt:void 0,onFocus:nr,registerItemRef:Ue,children:w},Jt)),Oe+=Ge,Pe+=We}return $.length>0&&Promise.resolve().then(()=>{if(Ye.current)return;let ue=0;for(const Ge of $)if(Ge.index<Pt){const Gt=R.get(Ge.index);ue+=Ge.value-Gt}const rt=R.updates($);if(Ye.current||typeof rt!="number")return;Vt(rt),P.debug("[VirtualScroll] Updated heights for items",$,"New total height:",rt);const We=F.current?.getScrollPosition()??d.current;if(ue!==0){const Ge=We+ue;xt(Ge,ue),Ce(Ge,{immediate:!0}),P.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:We,to:Ge,shiftAmount:ue})}else We!==d.current&&Ce(We)}),{visibleItems:ce,renderAnchor:Y}},[w,Ke,He,D,r,R,e,n,s,nr,Ht,nt,qt,xt,Ue,Ft,Ct,Ce,Pt]),Bt=t.useCallback(c=>{const p=(G??0)>0,x=Math.abs(c-Fe),q=p&&x>.5?Fe:c,X=gt(q,N.top);if(P.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:X,renderingStartIndex:Ct,renderingEndIndex:Ft,itemCount:r,viewportSize:se,callbackThrottleMs:G,diff:x,rawEffectiveScrollPosition:q})),r===0)return Lt;const Y=N.top+It-q,$=N.bottom>0?A.jsx("div",{className:"aqvs-bottom-inset",style:{top:R.getTotal()-It,height:N.bottom}},"virtualscroll-bottom-inset"):null;return P.debug("[VirtualScroll] Rendering items",()=>({containerTop:Y,logicalScrollPosition:Tt,resolvedInsets:N,effectiveScrollPosition:X})),A.jsxs("div",{className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${Y}px)`,willChange:"transform"},children:[Lt,$]})},[G,r,R,Tt,It,Ft,Ct,N,Fe,se,Lt]),Yt=t.useMemo(()=>({renderingStartIndex:mt.renderingStartIndex,renderingEndIndex:mt.renderingEndIndex,visibleStartIndex:mt.visibleStartIndex,visibleEndIndex:mt.visibleEndIndex,scrollPosition:Tt,totalHeight:R.getTotal()}),[mt,Tt,R,He]);t.useEffect(()=>{lt.current=Yt},[Yt]);const[$t,Et]=t.useState(""),jt=t.useRef(Z);t.useLayoutEffect(()=>{jt.current=Z},[Z]);const wt=Z?.debounceMs??400,pt=Number.isFinite(wt)&&wt>=0,Ut=Z!==void 0;t.useEffect(()=>{Ut&&!pt&&P.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${wt}. Announcements are disabled.`)},[Ut,pt,wt]),t.useEffect(()=>{if(!(Ut&&pt)){Et("");return}const c=setTimeout(()=>{const p=jt.current?.format;if(!p)return;const x=p({visibleStartIndex:Pt,visibleEndIndex:Wt,itemCount:r});Et(x)},wt);return()=>clearTimeout(c)},[Ut,pt,wt,Pt,Wt,r]),t.useImperativeHandle(ne,()=>({getScrollPosition:()=>{const c=F.current?.getScrollPosition();return typeof c=="number"?gt(c,Me.current):-1},getContentSize:()=>F.current?.getContentSize()??-1,getViewportSize:()=>F.current?.getViewportSize()??-1,scrollTo:Ie,scrollBy:Xe,applyWheel:ft,scrollToIndex:u,getFenwickTreeTotalHeight:()=>R.getTotal(),getFenwickSize:()=>R.getSize(),focusItemAtIndex:vt,getRange:()=>lt.current,getScrollAnchor:U,updateItemSize:At}),[Ie,Xe,ft,u,R,vt,U,At]);const hr=R.getTotal()+N.top+N.bottom,sr=A.jsx(Br,{ref:F,contentSize:hr,viewportSize:i,onViewportSizeChange:Se,className:l,testId:f,onScroll:tt,background:M,tapScrollCircleOptions:ye,inertiaOptions:st,overscrollBehavior:Je,itemCount:r,scrollBarWidth:ae,enableThumbDrag:oe,enableTrackClick:Ee,enableArrowButtons:H,enablePointerDrag:ge,pointerDragInputs:ke,renderThumbOverlay:j,wheelSpeedMultiplier:ot,onWheelHorizontal:ie,onPanHorizontal:ze,contentInsets:N,contentProps:z,visibleStartIndex:Pt,visibleEndIndex:Wt,renderOverlay:Nt,initialScrollPosition:dt.position,children:Bt});return Ut?A.jsxs(A.Fragment,{children:[sr,A.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:$t})]}):sr},Ur=t.forwardRef(Pn),cr=262144,Or=3,Gr=32768,Mr=128,Ir=128,Er=128,yr=128,vr=10,Nn=(r,e)=>Math.max(1,Math.floor((r??Gr)/Math.max(1,e))),zn=(r,e,n,s,i)=>{let a=0,l=0,f=Math.max(0,Math.min(s,n-1));for(;f<n&&a<r&&l<Sr;)a+=e(f),l+=1,f+=1;return Math.max(1,l+2*i+2)},fr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=cr))throw new RangeError(`[VirtualGrid] ${e==="row"?"getRowHeight":"getColWidth"}(${n}) returned ${r} — must be an integer in [0, ${cr}] (0 = hidden). Oversized tracks would pierce the browser layout-coordinate wall (see the design plan §3.1/§6).`);return r},kn=(r,e,n,s,i,a,l,f)=>{const m=jr(r,e,n,s,i,a,l);if(s===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const g=K(m.renderingStartIndex,0,s-1),{cumulative:w,currentValue:M}=a.prefixSum(g,{materializeOption:{materialize:!1}}),I=w-M,v=Number.isFinite(I)&&Math.abs(I-f)>$r?I:f;return{renderingColStart:m.renderingStartIndex,renderingColEnd:m.renderingEndIndex,visibleColStart:m.visibleStartIndex,visibleColEnd:m.visibleEndIndex,colAnchor:v}},Fr=[],Vn=(r,e,n,s,i)=>{const a=[],l=[];if(e<r)return{columns:a,widthUpdates:l,truncated:0};const f=s.prefixSum(r,{materializeOption:{materialize:!1}});let m=f.cumulative-f.currentValue,g=0,w=r;for(;w<=e;){if(a.length>=i)return{columns:a,widthUpdates:l,truncated:e-w+1};const M=n(w),I=s.get(w);if(M!==I&&l.push({index:w,value:M}),M>0){a.push({col:w,left:m,width:M}),m+=I,g=0,w+=1;continue}if(m+=I,g+=1,w+=1,g>lr){const v=s.findIndexAtOrAfter(m+.5,{materializeOption:{materialize:!1}});if(v.index===-1||v.index<=w||!Number.isSafeInteger(v.index))break;const V=s.prefixSum(v.index,{materializeOption:{materialize:!1}});m=V.cumulative-V.currentValue,w=v.index,g=0}}return{columns:a,widthUpdates:l,truncated:0}},An=(r,e,n)=>{const s=[],i=[];let a=0;for(let l=0;l<r;l+=1){const f=e(l),m=n.get(l);f!==m&&i.push({index:l,value:f}),f>0&&s.push({col:l,left:a,width:f}),a+=m}return{columns:s,widthUpdates:i,width:a}},Ln=(r,e,n,s)=>{const i=[],a=[];let l=0;for(let f=r-e;f<r;f+=1){const m=n(f),g=s.get(f);m!==g&&a.push({index:f,value:m}),m>0&&i.push({col:f,left:l,width:m}),l+=g}return{columns:i,widthUpdates:a,width:l}},dr=(r,e,n)=>Math.min(r,Math.max(0,n-e)),Dn={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},_n=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:s,getCell:i,getCellKey:a,children:l,getCellProps:f,getRowProps:m,contentProps:g,background:w,contentInsets:M,onRowFocus:I,frozenLeadingCols:v=0,frozenLeadingRows:V=0,frozenTrailingCols:G=0,frozenTrailingRows:W=0,horizontalKeyInputs:me,horizontalKeyStep:Ne,onScroll:pe,onRangeChange:ie,onRenderTruncated:ze,callbackThrottleMs:_,initialScrollAnchor:C,overscanRows:z=Or,overscanCols:Z=Or,viewportSize:ne,__maxRenderedCells:ae,behaviorOptions:oe,scrollBarOptions:Ee,liveRegion:H,className:T,testId:j},ye)=>{const ge=t.useRef(null),ke=t.useRef(null),D=t.useRef(n);D.current=n;const nt=t.useRef(s);nt.current=s;const ot=oe?.resetOnGetColWidthChange===!0,Je=oe?.resetOnGetItemHeightChange===!0?n:null,Ke=ot?s:null,xe=t.useCallback(o=>fr(D.current(o),"row",o),[Je]),Ve=t.useCallback(o=>fr(nt.current(o),"col",o),[Ke]),Re=oe?.defaultColWidth,se=t.useMemo(()=>{if(Re!==void 0&&!(Number.isInteger(Re)&&Re>=0&&Re<=cr))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${cr}], received ${Re}.`);return{resetOnValueFnChange:ot,baseValue:Re}},[ot,Re]),Se=Pr(e,Ve,se),[F,lt]=t.useState(0);if(!(Number.isInteger(v)&&v>=0&&v<=Mr))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${Mr}], received ${v}.`);const Q=Math.min(v,e),Ye=t.useRef(0);if(!(Number.isInteger(G)&&G>=0&&G<=Er))throw new RangeError(`[VirtualGrid] frozenTrailingCols must be an integer in [0, ${Er}], received ${G}.`);const fe=Math.min(G,e-Q),N=t.useRef(0);if(!(Number.isInteger(V)&&V>=0&&V<=Ir))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${Ir}], received ${V}.`);const B=Math.min(V,r);if(!(Number.isInteger(W)&&W>=0&&W<=yr))throw new RangeError(`[VirtualGrid] frozenTrailingRows must be an integer in [0, ${yr}], received ${W}.`);const Le=Math.min(W,r-B),R=Math.max(0,r-B-Le),dt=t.useRef(!1),Fe=t.useRef(0),ct=t.useRef(0),[He,Vt]=t.useState(0),{frozenRows:d,frozenHeight:O}=t.useMemo(()=>{if(B===0)return{frozenRows:[],frozenHeight:0};const o=[];let b=0;for(let S=0;S<B;S+=1){const L=xe(S);L>0&&o.push({row:S,top:b,height:L}),b+=L}return{frozenRows:o,frozenHeight:b}},[B,He,xe]);Fe.current=O;const[J,ee]=t.useState(0),{trailingRows:de,trailingHeight:te}=t.useMemo(()=>{if(Le===0)return{trailingRows:[],trailingHeight:0};const o=[];let b=0;for(let S=r-Le;S<r;S+=1){const L=xe(S);L>0&&o.push({row:S,top:b,height:L}),b+=L}return{trailingRows:o,trailingHeight:b}},[Le,r,J,xe]);ct.current=te;const De=t.useCallback(o=>xe(o+B),[xe,B]),ve=t.useRef(I);ve.current=I;const he=I!==void 0,be=t.useMemo(()=>he?o=>ve.current?.(o+B):void 0,[B,he]),Qe=O,Ae=te,[we,it]=t.useState(B),$e=t.useRef(null),at=t.useRef(!1);if(we!==B){it(B),at.current=!0;const o=ge.current?.getScrollAnchor()??null;$e.current=o===null?null:{row:o.index+we,offsetPx:o.offsetPx}}const le=t.useRef(0),Te=t.useRef(0),ht=t.useRef(!1),[h,E]=t.useState(Dn),je=t.useRef(h);je.current=h;const et=t.useRef(0),[qe,bt]=t.useState(()=>Se.getTotal()??0),Me=t.useRef(qe);Me.current=qe;const ut=t.useCallback(o=>{typeof o=="number"&&Number.isFinite(o)&&(Me.current=o,bt(o))},[]);t.useLayoutEffect(()=>{const o=Se.getTotal();typeof o=="number"&&Number.isFinite(o)&&o!==Me.current&&ut(o)});const Ue=Ee?.width??12,Ot=ne===void 0?null:{width:Math.max(0,Math.round(ne.width)-Ue),height:Math.max(0,Math.round(ne.height)-Ue)},[Rt,Xt]=t.useState({width:0,height:0}),_e=Ot??Rt,St=t.useRef(_e);St.current=_e;const Kt=_e.height>0&&_e.height-O-te<=0;dt.current=Kt;const Ce=Ot!==null;t.useLayoutEffect(()=>{if(Ce)return;const o=ke.current;if(o===null)return;const b=()=>{const L=Math.max(0,Math.round(o.clientWidth)-Ue),re=Math.max(0,Math.round(o.clientHeight)-Ue);Xt(Ze=>Ze.width===L&&Ze.height===re?Ze:{width:L,height:re})};b();const S=new ResizeObserver(b);return S.observe(o),()=>S.disconnect()},[Ue,Ce]);const xt=t.useCallback(()=>{const o=ke.current;o!==null&&o.style.setProperty("--aqvs-grid-hx-residual",`${et.current-le.current}px`)},[]),Mt=t.useCallback(()=>Math.max(0,St.current.width-Ye.current-N.current),[]),At=t.useCallback(()=>{const o=Mt(),b=kn(Ye.current+le.current,o,Z,e,Ve,Se,Me.current,je.current.colAnchor);if(Q>0&&(b.renderingColStart=Math.max(b.renderingColStart,Q),b.visibleColStart=Math.max(b.visibleColStart,Q)),fe>0){const L=e-fe-1;b.renderingColEnd=Math.min(b.renderingColEnd,L),b.visibleColEnd=Math.min(b.visibleColEnd,L)}(Q>0||fe>0)&&(o<=0||b.renderingColStart>b.renderingColEnd)&&(b.renderingColStart=e,b.renderingColEnd=e-1,b.visibleColStart=e,b.visibleColEnd=e-1);const S=`${b.renderingColStart}:${b.renderingColEnd}:${b.colAnchor}`;S!==je.current.key&&E({...b,key:S})},[Z,e,Ve,Se,Q,fe,Mt]),[u,y]=t.useState(0),k=t.useRef(null),U=t.useCallback(()=>{k.current===null&&(k.current=requestAnimationFrame(()=>{k.current=null,y(le.current)}))},[]);t.useEffect(()=>()=>{k.current!==null&&cancelAnimationFrame(k.current)},[]);const Ie=t.useRef(pe);Ie.current=pe;const Xe=t.useRef(ie);Xe.current=ie;const ft=t.useRef(ze);ft.current=ze;const tt=t.useRef(null),[Tt,mt]=t.useState(null),[Ct,Ft]=t.useState(_e.height);Ct!==_e.height&&(Ft(_e.height),mt(null));const Pt=C===void 0||r===0?0:K(Math.trunc(C.row),0,r-1),Wt=t.useMemo(()=>{const o=tt.current?.renderingStartIndex??Pt;return zn(Math.max(0,_e.height-Fe.current-ct.current),xe,r,o,z)},[_e.height,xe,r,Pt,z,Qe,Ae]),vt=Tt??Wt,Ht=t.useCallback(()=>{const o=tt.current;if(o===null)return null;const b=je.current;return{renderingRowStart:o.renderingStartIndex,renderingRowEnd:o.renderingEndIndex,visibleRowStart:o.visibleStartIndex,visibleRowEnd:o.visibleEndIndex,renderingColStart:b.renderingColStart,renderingColEnd:b.renderingColEnd,visibleColStart:b.visibleColStart,visibleColEnd:b.visibleColEnd,scrollX:le.current,scrollY:Te.current,totalWidth:Me.current,totalHeight:o.totalHeight+Fe.current+ct.current}},[]),qt=t.useCallback(()=>{const o=Ht();o!==null&&Xe.current?.(o)},[Ht]),nr=t.useCallback(o=>{const b=Mt(),S=Math.max(0,Me.current-Ye.current-N.current-b),L=K(o,0,S);return L!==le.current&&(le.current=L,xt(),At(),U(),Ie.current?.({x:L,y:Te.current})),L},[xt,At,U,Mt]),Nt=t.useRef(nr);Nt.current=nr,t.useLayoutEffect(()=>{et.current=h.colAnchor,xt(),qt()},[h,xt,qt]),t.useLayoutEffect(()=>{tt.current!==null&&qt()},[O,te,qt]);const zt=t.useRef(null),Lt=t.useCallback(o=>{const b=K(o.col,0,Math.max(0,e-1)),S=Se.prefixSum(b,{materializeOption:{materialize:!1}}),L=S.cumulative-S.currentValue,re=S.currentValue,Ze=Mt();return(o.alignX==="end"?L+re-Ye.current-Ze:o.alignX==="center"?L+re/2-Ye.current-Ze/2:L-Ye.current)+o.offsetX},[Se,e,Mt]),It=t.useRef(null),Bt=t.useCallback(()=>{const o=It.current;It.current=null,!(o===null||o.length===0)&&(ut(Se.updates(o)),lt(b=>b+1))},[Se,ut]),Yt=t.useRef({count:0,warned:!1}),{frozenColumns:$t,frozenWidth:Et}=t.useMemo(()=>{if(Q===0)return Yt.current.count=0,Yt.current.warned=!1,{frozenColumns:Fr,frozenWidth:0};const{columns:o,widthUpdates:b,width:S}=An(Q,Ve,Se);if(b.length>0){const L=Yt.current;L.count>=vr?L.warned||(L.warned=!0,P.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:Q,pendingUpdates:b.length})):(L.count+=1,It.current=[...It.current??[],...b],Promise.resolve().then(Bt))}else Yt.current.count=0,Yt.current.warned=!1;return{frozenColumns:o,frozenWidth:S}},[Q,F,Ve,Se,Bt]);Ye.current=Et,t.useLayoutEffect(()=>{Q>0?ke.current?.style.setProperty("--aqvs-grid-frozen-width",`${Et}px`):ke.current?.style.removeProperty("--aqvs-grid-frozen-width")},[Et,Q]);const jt=t.useRef({count:0,warned:!1}),{trailingColumns:wt,trailingWidth:pt}=t.useMemo(()=>{if(fe===0)return jt.current.count=0,jt.current.warned=!1,{trailingColumns:Fr,trailingWidth:0};const{columns:o,widthUpdates:b,width:S}=Ln(e,fe,Ve,Se);if(b.length>0){const L=jt.current;L.count>=vr?L.warned||(L.warned=!0,P.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:fe,pendingUpdates:b.length})):(L.count+=1,It.current=[...It.current??[],...b],Promise.resolve().then(Bt))}else jt.current.count=0,jt.current.warned=!1;return{trailingColumns:o,trailingWidth:S}},[fe,e,F,Ve,Se,Bt]);N.current=pt,t.useLayoutEffect(()=>{fe>0?ke.current?.style.setProperty("--aqvs-grid-trailing-width",`${pt}px`):ke.current?.style.removeProperty("--aqvs-grid-trailing-width")},[pt,fe]),t.useLayoutEffect(()=>{const o=zt.current;o===null?Nt.current(le.current):Nt.current(Lt(o)),At()},[_e.width,qe,F,Et,pt,At,Lt]);const Ut=t.useRef(!1);t.useLayoutEffect(()=>{if(Ut.current||C===void 0||e===0)return;Ut.current=!0;const o=K(Math.trunc(C.col),0,e-1);if(o<Q||o>=e-fe)return;const b={col:o,alignX:"start",offsetX:Math.max(0,C.offsetX)};zt.current=b,Nt.current(Lt(b))},[C,e,Lt,Q,fe]);const hr=t.useCallback(o=>{Te.current=o,ht.current=!0,Ie.current?.({x:le.current,y:o})},[]),sr=t.useCallback(o=>{if(R===0||dt.current)tt.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:R===0?0:o.totalHeight},Te.current=0;else{const b=B;tt.current={renderingStartIndex:o.renderingStartIndex+b,renderingEndIndex:o.renderingEndIndex+b,visibleStartIndex:o.visibleStartIndex+b,visibleEndIndex:o.visibleEndIndex+b,scrollPosition:o.scrollPosition,totalHeight:o.totalHeight},Te.current=o.scrollPosition}mt(b=>{const S=Math.max(1,o.renderingEndIndex-o.renderingStartIndex+1);return S===b?b:S}),qt()},[qt,B,R,r]),c=t.useCallback(o=>{zt.current=null,Nt.current(le.current+o)},[]),p=Nn(ae,vt+d.length+de.length),x=t.useRef({count:0,warned:!1}),{placedColumns:q,truncatedCols:X}=t.useMemo(()=>{const o=Math.max(0,_e.width-Et-pt);if(e===0||o<=0)return{placedColumns:[],truncatedCols:0};if(h.renderingColStart>h.renderingColEnd)return{placedColumns:[],truncatedCols:0};const b=Math.max(1,p-$t.length-wt.length),{columns:S,widthUpdates:L,truncated:re}=Vn(K(h.renderingColStart,0,e-1),K(h.renderingColEnd,0,e-1),Ve,Se,b);if(L.length>0){const Ze=x.current;Ze.count>=vr?Ze.warned||(Ze.warned=!0,P.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values; width self-heal is suspended until a converged (zero-deviation) pass re-arms it (unstable accessor — the accessor must be index-stable while the ordering is unchanged).",{window:h.key,pendingUpdates:L.length})):(Ze.count+=1,It.current=[...It.current??[],...L],Promise.resolve().then(Bt))}else x.current.count=0,x.current.warned=!1;return{placedColumns:S,truncatedCols:re}},[h,e,_e.width,Et,pt,$t.length,wt.length,F,Ve,Se,p,Bt]),Y=t.useRef("");t.useEffect(()=>{if(X>0){const o=`${h.key}:${X}`;o!==Y.current&&(Y.current=o,ft.current?.({renderedCells:(q.length+$t.length+wt.length)*(vt+d.length+de.length),droppedCols:X}))}},[X,h.key,q.length,$t.length,wt.length,vt,d.length,de.length]);const $=h.colAnchor,ce=t.useCallback(o=>{const b=m?.(o),S=xe(o)===0,L=S?null:q.map(({col:re,left:Ze,width:er})=>{const kt=f?.(o,re),ir={...kt?.style,left:Ze-$,width:er};return t.createElement("div",{...kt,key:a?a(o,re):re,className:yt.twMerge("aqvs-grid-cell",kt?.className),style:ir},l(i(o,re),o,re))});return Q===0&&fe===0?A.jsx("div",{...b,className:yt.twMerge("aqvs-grid-row",b?.className),style:b?.style,children:L}):A.jsxs("div",{...b,"data-aqvs-frozen-row":Q>0?"":void 0,className:yt.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",b?.className),style:b?.style,children:[S?null:$t.map(({col:re,left:Ze,width:er})=>{const kt=f?.(o,re),ir={...kt?.style,left:Ze,width:er};return t.createElement("div",{...kt,"data-aqvs-frozen-cell":"",key:a?a(o,re):re,className:yt.twMerge("aqvs-grid-cell",kt?.className),style:ir},l(i(o,re),o,re))}),S?null:A.jsx("div",{className:"aqvs-grid-row-scroll",children:A.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:L})}),S||fe===0?null:A.jsx("div",{className:"aqvs-grid-row-trailing",children:A.jsx("div",{className:"aqvs-grid-row-trailing-inner",children:wt.map(({col:re,left:Ze,width:er})=>{const kt=f?.(o,re),ir={...kt?.style,left:Ze,width:er};return t.createElement("div",{...kt,"data-aqvs-trailing-cell":"",key:a?a(o,re):re,className:yt.twMerge("aqvs-grid-cell",kt?.className),style:ir},l(i(o,re),o,re))})})})]})},[q,$t,wt,Q,fe,$,m,f,a,i,l,xe]),[Oe,Pe]=t.useState(""),ue=t.useRef(null),rt=t.useRef(H);rt.current=H;const We=t.useCallback(()=>{const o=rt.current;if(o===void 0)return;const b=o.debounceMs??400;Number.isFinite(b)&&b>=0&&(ue.current!==null&&window.clearTimeout(ue.current),ue.current=window.setTimeout(()=>{ue.current=null;const S=Ht();S!==null&&Pe(L=>{const re=o.buildMessage(S);return re===L?L:re})},b))},[Ht]),Ge=H?.debounceMs??400,Gt=Number.isFinite(Ge)&&Ge>=0,Jt=H!==void 0;t.useEffect(()=>{Jt&&!Gt&&P.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${Ge}. Announcements are disabled.`)},[Jt,Gt,Ge]),t.useEffect(()=>()=>{ue.current!==null&&window.clearTimeout(ue.current)},[]),t.useEffect(()=>{We()},[h,We]);const Zr=t.useCallback(o=>{sr(o),We()},[sr,We]);return t.useImperativeHandle(ye,()=>({scrollTo:o=>{const b=ge.current;let S=Te.current;o.y!==void 0&&b!==null&&(b.scrollTo(o.y),S=b.getScrollPosition(),Te.current=S);let L=le.current;return o.x!==void 0&&(zt.current=null,L=Nt.current(o.x)),{x:L,y:S}},scrollBy:o=>{const b=ge.current;let S=Te.current;o.y!==void 0&&o.y!==0&&b!==null&&(S=b.scrollBy(o.y),Te.current=S);let L=le.current;return o.x!==void 0&&o.x!==0&&(zt.current=null,L=Nt.current(le.current+o.x)),{x:L,y:S}},scrollToCell:(o,b,S)=>{const L=ge.current;if(L!==null&&r>0){const re=K(Math.trunc(o),0,r-1);re>=B&&re<r-Le&&L.scrollToIndex(re-B,{align:S?.alignY??"top",offset:S?.offsetY})}if(e>0){const re=K(Math.trunc(b),0,e-1);if(re>=Q&&re<e-fe){const Ze={col:re,alignX:S?.alignX??"start",offsetX:S?.offsetX??0};zt.current=Ze,Nt.current(Lt(Ze))}}},getScrollPosition:()=>ht.current||ge.current!==null?{x:le.current,y:ge.current?.getScrollPosition()??Te.current}:{x:-1,y:-1},getScrollAnchor:()=>{if(r===0||e===0)return null;const o=ge.current?.getScrollAnchor()??null;if(o===null)return null;const b=Ye.current+le.current,S=Se.findIndexAtOrAfter(b,{materializeOption:{materialize:!1}});if(S.index===-1)return{row:o.index+B,col:e-1,offsetX:0,offsetY:o.offsetPx};if(S.cumulative===b)return{row:o.index+B,col:K(S.index+1,0,e-1),offsetX:0,offsetY:o.offsetPx};const L=(S.cumulative??0)-(S.currentValue??0);return{row:o.index+B,col:S.index,offsetX:Math.max(0,b-L),offsetY:o.offsetPx}},getViewportSize:()=>({width:St.current.width,height:St.current.height}),getContentSize:()=>({width:Me.current,height:ge.current===null?0:Fe.current+ct.current+Math.max(0,ge.current.getContentSize())}),getRange:Ht,updateRowSize:(o,b)=>{fr(b,"row",o),Math.trunc(o)<B?Vt(S=>S+1):Le>0&&Math.trunc(o)>=r-Le?ee(S=>S+1):ge.current?.updateItemSize(Math.trunc(o)-B,b)},updateColSize:(o,b)=>{fr(b,"col",o),ut(Se.update(K(Math.trunc(o),0,Math.max(0,e-1)),b)),lt(S=>S+1)},getFrozenSize:()=>({cols:Q,width:Ye.current,rows:B,height:Fe.current,trailingCols:fe,trailingRows:Le,trailingWidth:N.current,trailingHeight:ct.current,trailingVisibleWidth:dr(N.current,Ye.current,St.current.width),trailingVisibleHeight:dr(ct.current,Fe.current,St.current.height)}),applyWheel:o=>ge.current?.applyWheel(o)??!1,focusRowAtIndex:(o,b)=>{const S=Math.trunc(o);S<B?ke.current?.querySelector(`[data-aqvs-frozen-band-row="${S}"]`)?.focus():Le>0&&S>=r-Le?ke.current?.querySelector(`[data-aqvs-trailing-band-row="${S}"]`)?.focus():ge.current?.focusItemAtIndex(S-B,b)}}),[r,e,Se,Ht,ut,Lt,Q,B,fe,Le]),A.jsxs("div",{ref:ke,className:yt.twMerge("aqvs-grid",B>0?"aqvs-grid-has-frozen-rows":"",Le>0?"aqvs-grid-has-trailing-rows":"",T),"data-testid":j,children:[B>0?A.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:O},"data-testid":j?`${j}-frozen-rows`:void 0,children:d.map(({row:o,top:b,height:S})=>A.jsx("div",{"data-aqvs-frozen-band-row":o,className:"aqvs-grid-frozen-band-row",style:{top:b,height:S,right:Ue},tabIndex:-1,onFocus:()=>I?.(o),children:ce(o)},o))}):null,A.jsx("div",{className:"aqvs-grid-main","data-testid":j?`${j}-main`:void 0,children:A.jsx(Ur,{ref:ge,itemCount:Kt?0:R,getItem:o=>o+B,getItemKey:o=>o+B,getItemHeight:De,overscanCount:z,viewportSize:_e.height>0?Math.max(0,_e.height-O-te):void 0,callbackThrottleMs:_,behaviorOptions:oe,scrollBarOptions:Ee,contentProps:g,background:w,contentInsets:M,onItemFocus:be,horizontalKeyInputs:me,horizontalKeyStep:Ne,initialScrollAnchor:at.current?$e.current!==null&&$e.current.row>=B&&R>0?{index:$e.current.row-B,offsetPx:$e.current.offsetPx}:void 0:C!==void 0&&R>0&&Math.trunc(C.row)>=B&&Math.trunc(C.row)<r-Le?{index:Math.trunc(C.row)-B,offsetPx:C.offsetY}:void 0,onScroll:hr,onRangeChange:Zr,onWheelHorizontal:c,onPanHorizontal:c,testId:j?`${j}-rows`:void 0,children:ce},B)}),Le>0?A.jsx("div",{className:"aqvs-grid-trailing-rows",style:{height:dr(te,O,_e.height)},"data-testid":j?`${j}-trailing-rows`:void 0,children:A.jsx("div",{className:"aqvs-grid-trailing-rows-inner",style:{height:te},children:de.map(({row:o,top:b,height:S})=>A.jsx("div",{"data-aqvs-trailing-band-row":o,className:"aqvs-grid-trailing-band-row",style:{top:b,height:S,right:Ue},tabIndex:-1,onFocus:()=>I?.(o),children:ce(o)},o))})}):null,A.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:Ue,paddingRight:fe>0?Ue+dr(pt,Et,_e.width):Ue},"data-testid":j?`${j}-hbar`:void 0,children:A.jsx(Cr,{horizontal:!0,enableHorizontalTapCircle:!0,contentSize:Math.max(0,qe-Et-pt),viewportSize:Math.max(0,_e.width-Et-pt),scrollPosition:u,itemCount:Math.max(0,e-Q-fe),tapScrollCircleOptions:Ee?.tapScrollCircleOptions,onScroll:(o,b)=>(zt.current=null,Nt.current(typeof o=="function"?o(b??le.current):o)),scrollBarWidth:Ue})}),H!==void 0?A.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":j?`${j}-live`:void 0,children:Oe}):null]})},On=t.forwardRef(_n);exports.FenwickMapTree=_t;exports.MAX_FROZEN_LEADING_COLS=Mr;exports.MAX_FROZEN_LEADING_ROWS=Ir;exports.MAX_FROZEN_TRAILING_COLS=Er;exports.MAX_FROZEN_TRAILING_ROWS=yr;exports.MAX_RENDERED_CELLS=Gr;exports.MAX_TRACK_SIZE=cr;exports.ScrollBar=Cr;exports.ScrollPane=Br;exports.TAP_SCROLL_SPEED_DEFAULTS=Tr;exports.VirtualGrid=On;exports.VirtualScroll=Ur;exports.computeAutoTapScrollMaxSpeedMultiplier=Xr;exports.computeTapScrollSpeed=qr;exports.createResidualQuantizer=Kr;exports.minmax=K;exports.tapScrollCircleSampleVisual=vn;exports.useFenwickMapTree=Pr;exports.useHeightCache=In;exports.useLruCache=Yr;exports.useWheelBridge=En;
|
package/dist/index.d.cts
CHANGED
|
@@ -14,4 +14,5 @@ export { useHeightCache } from './useHeightCache.cjs';
|
|
|
14
14
|
export { useLruCache } from './useLruCache.cjs';
|
|
15
15
|
export { useWheelBridge, type WheelBridgeOptions, type WheelBridgeTarget } from './useWheelBridge.cjs';
|
|
16
16
|
export { minmax } from './utils.cjs';
|
|
17
|
+
export { MAX_FROZEN_LEADING_COLS, MAX_FROZEN_LEADING_ROWS, MAX_FROZEN_TRAILING_COLS, MAX_FROZEN_TRAILING_ROWS, MAX_RENDERED_CELLS, MAX_TRACK_SIZE, VirtualGrid, type VirtualGridBehaviorOptions, type VirtualGridHandle, type VirtualGridLiveRegionOptions, type VirtualGridProps, type VirtualGridRange, } from './VirtualGrid.cjs';
|
|
17
18
|
export { VirtualScroll, type VirtualScrollBehaviorOptions, type VirtualScrollHandle, type VirtualScrollLiveRegionOptions, type VirtualScrollLiveRegionRange, type VirtualScrollProps, type VirtualScrollRange, type VirtualScrollScrollBarOptions, } from './VirtualScroll.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ export { useHeightCache } from './useHeightCache.ts';
|
|
|
14
14
|
export { useLruCache } from './useLruCache.ts';
|
|
15
15
|
export { useWheelBridge, type WheelBridgeOptions, type WheelBridgeTarget } from './useWheelBridge.ts';
|
|
16
16
|
export { minmax } from './utils.ts';
|
|
17
|
+
export { MAX_FROZEN_LEADING_COLS, MAX_FROZEN_LEADING_ROWS, MAX_FROZEN_TRAILING_COLS, MAX_FROZEN_TRAILING_ROWS, MAX_RENDERED_CELLS, MAX_TRACK_SIZE, VirtualGrid, type VirtualGridBehaviorOptions, type VirtualGridHandle, type VirtualGridLiveRegionOptions, type VirtualGridProps, type VirtualGridRange, } from './VirtualGrid.tsx';
|
|
17
18
|
export { VirtualScroll, type VirtualScrollBehaviorOptions, type VirtualScrollHandle, type VirtualScrollLiveRegionOptions, type VirtualScrollLiveRegionRange, type VirtualScrollProps, type VirtualScrollRange, type VirtualScrollScrollBarOptions, } from './VirtualScroll.tsx';
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACvH,OAAO,EAAE,sCAAsC,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,yBAAyB,EAAE,KAAK,gCAAgC,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC3P,OAAO,EAAE,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvJ,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EACH,aAAa,EACb,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACrC,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACvH,OAAO,EAAE,sCAAsC,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,yBAAyB,EAAE,KAAK,gCAAgC,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC3P,OAAO,EAAE,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvJ,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACxB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,aAAa,EACb,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACrC,MAAM,qBAAqB,CAAA"}
|