"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VirtualList=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),react_router_dom_1=require("react-router-dom"),theme_1=require("@redocly/theme"),INITIAL_VISIBLE_ITEMS=3,BUFFER_ITEMS=1,FULL_LIST_DELAY=1e3,VirtualListComponent=({items:e=[],renderItem:t,routingBasePath:r})=>{const a=r||"/",n=(0,react_router_dom_1.useLocation)(),s=(0,theme_1.removeLeadingSlash)(n.pathname.replace(a,"")),o=(0,react_1.useMemo)((()=>{const t=new Map(e.map(((e,t)=>[(0,theme_1.removeLeadingSlash)(e.href),t])));return e=>e?t.get(e):void 0}),[e]),u=(0,react_1.useCallback)((t=>{const r=o(t);return{start:Math.max(0,r?r-1:0),end:Math.min(e.length,r?r+1+1:3)}}),[o,e.length]),[i,m]=(0,react_1.useState)((()=>{const{start:t,end:r}=u(s);return e.slice(t,r)}));return(0,react_1.useEffect)((()=>{const t=setTimeout((()=>{m(e)}),1e3);return()=>clearTimeout(t)}),[e]),(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:i.map(t)})};exports.VirtualList=(0,react_1.memo)(VirtualListComponent);
//# sourceMappingURL=VirtualList.js.map