import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useEffect,useRef,useState}from"react";import{useMutableRef}from"../useMutableRef";import{useRefs}from"../useRefs";import{useResizeObserved}from"../useResizeObserved";import{calculateBounds,calculateSavedSizes,defaultItemsCalculationCount,getElementHeight,useCalculateVisiblePosition,useScroll}from"./hellpers";export var useVirtualScroll=function(a){var b=a.length,c=a.onScrollToBottom,d=a.isActive,e=void 0!==d&&d,f=useState([0,0]),g=_slicedToArray(f,2),h=g[0],i=g[1],j=useState([[0,0],[0,e?defaultItemsCalculationCount:b]]),k=_slicedToArray(j,2),l=k[0],m=k[1],n=useRefs(b,h),o=useRef(null),p=useResizeObserved(n,getElementHeight),q=useRef(calculateSavedSizes([],p)),r=useMutableRef(c);return useScroll(o,useCalculateVisiblePosition(o.current,i),e),useEffect(function(){e?(q.current=calculateSavedSizes(q.current,p),m(calculateBounds(q.current,p,h,b))):m([[0,0],[0,b]])},[].concat(_toConsumableArray(h),[p,b,e])),useEffect(function(){r.current&&e&&l[1][1]+1>=b&&r.current(b)},[l[1][1],b,e]),{listRefs:n,scrollElementRef:o,slice:[0===l[1][0]?0:l[1][0]+1,0===l[1][1]?0:l[1][1]+1],spaceTop:l[0][0]}};
//# sourceMappingURL=useVirtualScroll.js.map