import{r as i,j as r}from"./main-D6SjkSWq.js";import{I as z}from"./infinite-scroll-sentinel-CjTkiVp_.js";import{a as x,b as m}from"./table-BI0jS7jz.js";import{$ as C}from"./getScrollParent--OCc5gFh.js";import{u as E,o as S}from"./index-DfOoXeJd.js";function M({renderRowAs:l,totalItems:n=0,query:t,rowKeyGenerator:s}){const{data:o}=i.useContext(x),e=n<=0?10:Math.min(n-o.length,10);return n<91?r.jsx(v,{placeholderRowCount:e,renderRowAs:l,query:t,rowKeyGenerator:s}):r.jsx(V,{placeholderRowCount:e,renderRowAs:l,query:t,rowKeyGenerator:s})}function v({renderRowAs:l,placeholderRowCount:n,query:t,rowKeyGenerator:s}){const{data:o}=i.useContext(x);return r.jsxs(i.Fragment,{children:[o.map((e,a)=>r.jsx(m,{item:e,index:a,renderAs:l},s?s(e):e.id)),t?r.jsx(j,{dataCount:o.length,placeholderRowCount:n,query:t}):null]})}const h=56;function V({renderRowAs:l,placeholderRowCount:n,query:t,rowKeyGenerator:s}){var g;const{data:o}=i.useContext(x),e=i.useRef(null),a=i.useRef(null),u=i.useRef(0),p=()=>(a.current||e.current&&(a.current=C(e.current)),a.current);i.useEffect(()=>{e.current&&(u.current=e.current.getBoundingClientRect().top+p().scrollTop)},[e]);const d=E({overscan:10,count:o.length,getScrollElement:p,estimateSize:()=>h,observeElementOffset:(c,f)=>S(c,($,T)=>{f($-u.current,T)})}),b=d.getVirtualItems(),R=`${d.getTotalSize()+(t&&t.isFetchingNextPage?n*h:0)}px`;return r.jsxs("div",{ref:e,role:"presentation",className:"relative w-full",style:{height:R},children:[b.map(c=>{const f=o[c.index];return r.jsx(m,{item:f,index:c.index,renderAs:l,className:"absolute left-0 top-0 w-full",style:{height:`${c.size}px`,transform:`translateY(${c.start}px)`}},s?s(f):f.id)}),t?r.jsx(j,{dataCount:((g=d.range)==null?void 0:g.endIndex)??0,placeholderRowCount:n,query:t,style:{top:`${d.getTotalSize()}px`}}):null]})}function j({dataCount:l,placeholderRowCount:n,renderRowAs:t,query:s,style:o}){return r.jsx(z,{query:s,style:o,loaderMarginTop:"mt-0",className:"absolute left-0",children:[...new Array(Math.max(n,1)).keys()].map((e,a)=>{const u=`placeholder-${e}`;return r.jsx(m,{item:{id:u,isPlaceholder:!0},index:l+a,renderAs:t},u)})})}export{M as V};
