import{n as e}from"./rolldown-runtime-BG2f4sTM.js";function t({entries:e,gapPx:t,measuredHeightsByKey:n}){let r=[],i=[],a=new Map,o=[],s=0;for(let[l,u]of e.entries()){let d=u.turnKey,f=n[d]??u.estimatedHeightPx??c;a.set(d,l),o.push(d),i.push(s),r.push(f),s+=f,l<e.length-1&&(s+=t)}return{bottomOffsetsPx:i.map((e,t)=>s-e-(r[t]??0)),heightsPx:r,topOffsetsPx:i,totalHeightPx:s,turnIndexByKey:a,turnKeys:o}}function n({distanceFromBottomPx:e,layout:t,overscanCount:n,viewportHeightPx:r}){if(t.turnKeys.length===0)return{startIndex:0,endIndex:0};let i=Math.min(Math.max(0,e),t.totalHeightPx),a=Math.min(i+Math.max(0,r),t.totalHeightPx),c=o(t.bottomOffsetsPx,a),l=s(t.bottomOffsetsPx,t.heightsPx,i);return{startIndex:Math.max(0,c-n),endIndex:Math.min(t.turnKeys.length,Math.max(l,c+1)+n)}}function r({anchorKey:e,layout:t,previousRange:n}){let r=t.turnIndexByKey.get(e);return r==null?null:{startIndex:r,endIndex:Math.min(t.turnKeys.length,r+n.endIndex-n.startIndex)}}function i({anchorKey:e,distanceFromBottomPx:t,nextLayout:n,previousLayout:r}){let i=r.turnIndexByKey.get(e),a=n.turnIndexByKey.get(e);if(i==null||a==null)return null;let o=(r.bottomOffsetsPx[i]??0)+(r.heightsPx[i]??0),s=(n.bottomOffsetsPx[a]??0)+(n.heightsPx[a]??0);return Math.max(0,t+s-o)}function a({layout:e,turnKey:t,viewportHeightPx:n}){let r=e.turnIndexByKey.get(t);return r==null?null:Math.max(0,(e.bottomOffsetsPx[r]??0)-n/2+(e.heightsPx[r]??0)/2)}function o(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);(e[i]??0)<t?r=i:n=i+1}return n}function s(e,t,n){let r=0,i=e.length;for(;r<i;){let a=Math.floor((r+i)/2);(e[a]??0)+(t[a]??0)<=n?i=a:r=a+1}return r}var c,l=e((()=>{c=280}));export{r as a,n as i,i as n,l as o,a as r,t};
//# sourceMappingURL=thread-virtualizer-43g3Bw27.js.map