import{f as T,c as H,r as s,j as p,bA as w}from"./index-6fe66247.js";import{L}from"./List-11a0d6f8.js";const j=T(L,{shouldForwardProp:r=>r!=="styles"})(({theme:r,styles:t})=>({maxHeight:t==null?void 0:t.maxHeight,marginTop:"0px",overflowY:"auto",padding:"0 8px","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-thumb":{backgroundColor:r.palette.primary.main,borderRadius:"8px"},...t})),R=({styles:r,loading:t,params:o,fetchapi:l,list:n,keyExtractor:a,renderItem:g})=>{const m=H(),[f,x]=s.useState(null),i=s.useRef(null),d=!t&&o&&o.page<o.no_of_pages&&l,u=()=>{d&&l&&o&&m(l({...o,page:o.page+1}))},b=e=>{const c=e.currentTarget;Math.ceil(c.scrollTop+c.clientHeight)>=c.scrollHeight&&u()},S=e=>{a&&x(a(e))};return s.useEffect(()=>{const e=i.current;if(!e)return;const h=setTimeout(()=>{e.scrollHeight<=e.clientHeight&&d&&u()},200);return()=>clearTimeout(h)},[n.length]),p.jsxs(j,{onScroll:b,styles:r,ref:i,children:[n==null?void 0:n.map((e,c)=>g(e,c,f,S)),t&&p.jsx(w,{})]})};export{R as S};
