2 lines
23 KiB
JavaScript
2 lines
23 KiB
JavaScript
import{r as y,a as k}from"./react-vendor-CgzNJrV9.js";function W(r,u,t){const e=new Array(r);return new Proxy(e,{get(s,i,o){if(typeof i=="string"){const n=i.charCodeAt(0);if(n>=48&&n<=57){const l=+i;if(Number.isInteger(l)&&l>=0&&l<r){let h=s[l];if(!h){const c=u[l*2];h=s[l]={index:l,key:t(l),start:c,size:u[l*2+1],end:c+u[l*2+1],lane:0}}return h}}if(i==="length")return r}return Reflect.get(s,i,o)}})}function x(r,u,t){let e=t.initialDeps??[],s,i=!0;function o(){const n=r();return(n.length!==e.length||n.some((h,c)=>e[c]!==h))&&(e=n,s=u(...n),t!=null&&t.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(s),i=!1),s}return o.updateDeps=n=>{e=n},o}function A(r,u){if(r===void 0)throw new Error("Unexpected undefined");return r}const D=(r,u)=>Math.abs(r-u)<1.01,L=(r,u,t)=>{let e;return function(...s){r.clearTimeout(e),e=r.setTimeout(()=>u.apply(this,s),t)}};let I;const w=()=>{if(I!==void 0)return I;if(typeof navigator>"u")return I=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return I=!0;const r=navigator.maxTouchPoints;return I=navigator.platform==="MacIntel"&&r!==void 0&&r>0},R=r=>{const{offsetWidth:u,offsetHeight:t}=r;return{width:u,height:t}},j=r=>r,V=r=>{const u=Math.max(r.startIndex-r.overscan,0),e=Math.min(r.endIndex+r.overscan,r.count-1)-u+1,s=new Array(e);for(let i=0;i<e;i++)s[i]=u+i;return s},K=(r,u)=>{const t=r.scrollElement;if(!t)return;const e=r.targetWindow;if(!e)return;const s=o=>{const{width:n,height:l}=o;u({width:Math.round(n),height:Math.round(l)})};if(s(R(t)),!e.ResizeObserver)return()=>{};const i=new e.ResizeObserver(o=>{const n=()=>{const l=o[0];if(l!=null&&l.borderBoxSize){const h=l.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s(R(t))};r.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(n):n()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},_={passive:!0},P=typeof window>"u"?!0:"onscrollend"in window,N=(r,u,t)=>{const e=r.scrollElement;if(!e)return;const s=r.targetWindow;if(!s)return;const i=r.options.useScrollendEvent&&P;let o=0;const n=i?null:L(s,()=>u(o,!1),r.options.isScrollingResetDelay),l=f=>()=>{o=t(e),n==null||n(),u(o,f)},h=l(!0),c=l(!1);return e.addEventListener("scroll",h,_),i&&e.addEventListener("scrollend",c,_),()=>{e.removeEventListener("scroll",h),i&&e.removeEventListener("scrollend",c)}},B=(r,u)=>N(r,u,t=>{const{horizontal:e,isRtl:s}=r.options;return e?t.scrollLeft*(s&&-1||1):t.scrollTop}),H=(r,u,t)=>{if(t.options.useCachedMeasurements){const e=t.indexFromElement(r),s=t.options.getItemKey(e);return t.itemSizeCache.get(s)??t.options.estimateSize(e)}if(u!=null&&u.borderBoxSize){const e=u.borderBoxSize[0];if(e)return Math.round(e[t.options.horizontal?"inlineSize":"blockSize"])}if(!u){const e=t.indexFromElement(r),s=t.options.getItemKey(e),i=t.itemSizeCache.get(s);if(i!==void 0)return i}return r[t.options.horizontal?"offsetWidth":"offsetHeight"]},J=(r,{adjustments:u=0,behavior:t},e)=>{var s,i;(i=(s=e.scrollElement)==null?void 0:s.scrollTo)==null||i.call(s,{[e.options.horizontal?"left":"top"]:r+u,behavior:t})},$=J;class q{constructor(u){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,e,s;return((s=(e=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:e.now)==null?void 0:s.call(e))??Date.now()},this.observer=(()=>{let t=null;const e=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(s=>{s.forEach(i=>{const o=()=>{const n=i.target,l=this.indexFromElement(n);if(!n.isConnected){this.observer.unobserve(n);for(const[h,c]of this.elementsCache)if(c===n){this.elementsCache.delete(h);break}return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(n,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=e())==null||s.disconnect(),t=null},observe:s=>{var i;return(i=e())==null?void 0:i.observe(s,{box:"border-box"})},unobserve:s=>{var i;return(i=e())==null?void 0:i.unobserve(s)}}})(),this.range=null,this.setOptions=t=>{var e,s;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:j,rangeExtractor:V,onChange:()=>{},measureElement:H,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const a in t){const g=t[a];g!==void 0&&(i[a]=g)}const o=this.options;let n=null,l=null,h=!1;if(o!==void 0&&o.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const a=o.count,g=i.count,d=this.getMeasurements(),S=a>0?((e=d[0])==null?void 0:e.key)??o.getItemKey(0):null,v=a>0?((s=d[a-1])==null?void 0:s.key)??o.getItemKey(a-1):null;if(g!==a||a>0&&g>0&&(i.getItemKey(0)!==S||i.getItemKey(g-1)!==v)){h=!0;const m=a>0?this.getVirtualItemForOffset(this.getScrollOffset())??d[0]:null;m&&(n=[m.key,this.getScrollOffset()-m.start]);const E=i.followOnAppend===!0?"auto":i.followOnAppend||null;E&&g>a&&this.isAtEnd(o.scrollEndThreshold)&&(a===0||i.getItemKey(g-1)!==v)&&(l=E)}}this.options=i,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let c=!1,f=0;if(n&&this.scrollOffset!==null){const[a,g]=n,d=this.getMeasurements(),{count:S,getItemKey:v}=this.options;let p=0;for(;p<S&&v(p)!==a;)p++;if(p<S){const b=d[p];if(b){const m=b.start+g;m!==this.scrollOffset&&(f=m-this.scrollOffset,this.scrollOffset=m,c=!0)}}}(c||l)&&(this.pendingScrollAnchor=[c?n[0]:null,c?n[1]:0,l,f])},this.notify=t=>{var e,s;(s=(e=this.options).onChange)==null||s.call(e,this,t)},this.maybeNotify=x(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,o)=>{this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!w()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",o,_),i.addEventListener("touchend",n,_),this.unsubs.push(()=>{i.removeEventListener("touchstart",o),i.removeEventListener("touchend",n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const s=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled){const[i,o,n,l]=s;i!==null&&!n&&(w()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),n&&this.scrollToEnd({behavior:n})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),e=this.getMaxScrollOffset();if(t<0||t>e)return;const s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=s,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,e)=>{const s=new Map,i=new Map;for(let o=e-1;o>=0;o--){const n=t[o];if(s.has(n.lane))continue;const l=i.get(n.lane);if(l==null||n.end>l.end?i.set(n.lane,n):n.end<l.end&&s.set(n.lane,!0),s.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,n)=>o.end===n.end?o.index-n.index:o.end-n.end)[0]:void 0},this.getMeasurementOptions=x(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,e,s,i,o,n,l)=>(this.prevLanes!==void 0&&this.prevLanes!==n&&(this.lanesChangedFlag=!0),this.prevLanes=n,this.pendingMin=null,{count:t,paddingStart:e,scrollMargin:s,getItemKey:i,enabled:o,lanes:n,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=x(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:e,scrollMargin:s,getItemKey:i,enabled:o,lanes:n,laneAssignmentMode:l},h)=>{const c=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const d of this.laneAssignments.keys())d>=t&&this.laneAssignments.delete(d);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),n===1){const d=this.options.gap,S=t*2;let v=this._flatMeasurements;if(!v||v.length<S){const m=new Float64Array(S);v&&f>0&&m.set(v.subarray(0,f*2)),v=m,this._flatMeasurements=v}let p;if(f===0)p=e+s;else{const m=f-1;p=v[m*2]+v[m*2+1]+d}for(let m=f;m<t;m++){const E=i(m),z=c.get(E),M=typeof z=="number"?z:this.options.estimateSize(m);v[m*2]=p,v[m*2+1]=M,p+=M+d}const b=W(t,v,i);return this.measurementsCache=b,b}const a=this.measurementsCache.slice(0,f),g=new Array(n).fill(void 0);for(let d=0;d<f;d++){const S=a[d];S&&(g[S.lane]=d)}for(let d=f;d<t;d++){const S=i(d),v=this.laneAssignments.get(d);let p,b;const m=l==="estimate"||c.has(S);if(v!==void 0&&this.options.lanes>1){p=v;const O=g[p],C=O!==void 0?a[O]:void 0;b=C?C.end+this.options.gap:e+s}else{const O=this.options.lanes===1?a[d-1]:this.getFurthestMeasurement(a,d);b=O?O.end+this.options.gap:e+s,p=O?O.lane:d%this.options.lanes,this.options.lanes>1&&m&&this.laneAssignments.set(d,p)}const E=c.get(S),z=typeof E=="number"?E:this.options.estimateSize(d),M=b+z;a[d]={index:d,start:b,size:z,end:M,key:S,lane:p},g[p]=d}return this.measurementsCache=a,a},{key:!1,debug:()=>this.options.debug}),this.calculateRange=x(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,e,s,i)=>this.range=t.length>0&&e>0?U({measurements:t,outerSize:e,scrollOffset:s,lanes:i,flat:i===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=x(()=>{let t=null,e=null;const s=this.calculateRange();return s&&(t=s.startIndex,e=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,e]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,e]},(t,e,s,i,o)=>i===null||o===null?[]:t({startIndex:i,endIndex:o,overscan:e,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const e=this.options.indexAttribute,s=t.getAttribute(e);return s?parseInt(s,10):(console.warn(`Missing attribute name '${e}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var e;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const s=this.scrollState.index??((e=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:e.index);if(s!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,s-i),n=Math.min(this.options.count-1,s+i);return t>=o&&t<=n}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((o,n)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(n))});return}const e=this.indexFromElement(t),s=this.options.getItemKey(e),i=this.elementsCache.get(s);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(s,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(e)&&this.resizeItem(e,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,e)=>{var s,i;if(t<0||t>=this.options.count)return;let o,n,l;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)l=this.options.getItemKey(t),n=h[t*2],o=h[t*2+1];else{const a=this.measurementsCache[t];if(!a)return;l=a.key,n=a.start,o=a.size}const c=this.itemSizeCache.get(l)??o,f=e-c;if(f!==0){const a=this.options.anchorTo==="end"&&((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,g=a?this.getTotalSize():0,d=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:l,start:n,size:o,end:n+o,lane:0},f,this):n<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!=="backward");(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(l,e),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-g):d&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=x(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,e)=>{const s=[];for(let i=0,o=t.length;i<o;i++){const n=t[i],l=e[n];s.push(l)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const e=this.getMeasurements();if(e.length===0)return;const s=this._flatMeasurements,i=this.options.lanes===1&&s!=null,o=F(0,e.length-1,i?n=>s[n*2]:n=>A(e[n]).start,t);return A(e[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,e,s=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();e==="auto"&&(e=t>=o+i?"end":"start"),e==="center"?t+=(s-i)/2:e==="end"&&(t-=i);const n=this.getMaxScrollOffset();return Math.max(Math.min(n,t),0)},this.getOffsetForIndex=(t,e="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const s=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[t];if(!o)return;if(e==="auto")if(o.end>=i+s-this.options.scrollPaddingEnd)e="end";else if(o.start<=i+this.options.scrollPaddingStart)e="start";else return[i,e];if(e==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),e];const n=e==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(n,e,o.size),e]},this.scrollToOffset=(t,{align:e="start",behavior:s="auto"}={})=>{const i=this.getOffsetForAlignment(t,e),o=this.now();this.scrollState={index:null,align:e,behavior:s,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:e="auto",behavior:s="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,e);if(!i)return;const[o,n]=i,l=this.now();this.scrollState={index:t,align:n,behavior:s,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:e="auto"}={})=>{const s=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:e,startedAt:i,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const e=this.getMeasurements();let s;if(e.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){const i=e.length-1,o=this._flatMeasurements;o!=null?s=o[i*2]+o[i*2+1]:s=((t=e[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let o=e.length-1;for(;o>=0&&i.some(n=>n===null);){const n=e[o];i[n.lane]===null&&(i[n.lane]=n.end),o--}s=Math.max(...i.filter(n=>n!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const e=this.getMeasurements();for(const s of e)s&&this.itemSizeCache.has(s.key)&&t.push({index:s.index,key:s.key,start:s.start,size:s.size,end:s.end,lane:s.lane});return t},this._scrollToOffset=(t,{adjustments:e,behavior:s})=>{this._intendedScrollOffset=t+(e??0),this.options.scrollToFn(t,{behavior:s,adjustments:e},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(u)}applyScrollAdjustment(u,t){u!==0&&(w()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=u:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=u,behavior:t}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const e=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,s=e?e[0]:this.scrollState.lastTargetOffset,i=1,o=s!==this.scrollState.lastTargetOffset;if(!o&&D(s,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==s&&this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const n=this.getSize()||600,l=Math.abs(s-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&l>n;this.scrollState.lastTargetOffset=s,h||(this.scrollState.behavior="auto"),this._scrollToOffset(s,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const F=(r,u,t,e)=>{for(;r<=u;){const s=(r+u)/2|0,i=t(s);if(i<e)r=s+1;else if(i>e)u=s-1;else return s}return r>0?r-1:0};function U({measurements:r,outerSize:u,scrollOffset:t,lanes:e,flat:s}){const i=r.length-1,o=s?c=>s[c*2]:c=>r[c].start,n=s?c=>s[c*2]+s[c*2+1]:c=>r[c].end;if(r.length<=e)return{startIndex:0,endIndex:i};let l=F(0,i,o,t),h=l;if(e===1)for(;h<i&&n(h)<t+u;)h++;else if(e>1){const c=Array(e).fill(0);for(;h<i&&c.some(a=>a<t+u);){const a=r[h];c[a.lane]=a.end,h++}const f=Array(e).fill(t+u);for(;l>=0&&f.some(a=>a>=t);){const a=r[l];f[a.lane]=a.start,l--}l=Math.max(0,l-l%e),h=Math.min(i,h+(e-1-h%e))}return{startIndex:l,endIndex:h}}const T=typeof document<"u"?y.useLayoutEffect:y.useEffect;function X({useFlushSync:r=!0,directDomUpdates:u=!1,directDomUpdatesMode:t="transform",...e}){const s=y.useReducer(h=>h+1,0)[1],i=y.useRef({enabled:u,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=u,i.current.mode=t;const o=h=>{const c=i.current;if(!c.enabled)return;const f=h.getTotalSize();if(c.container&&f!==c.lastSize){c.lastSize=f;const p=h.options.horizontal?"width":"height";c.container.style[p]=`${f}px`}const a=!!h.options.horizontal,g=c.mode==="transform",d=a?"left":"top",S=h.options.scrollMargin,v=h.getVirtualItems();for(const p of v){const b=p.start-S,m=h.elementsCache.get(p.key);m&&c.lastPositions.get(m)!==b&&(c.lastPositions.set(m,b),g?m.style.transform=a?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:m.style[d]=`${b}px`)}},n={...e,onChange:(h,c)=>{var f;const a=i.current;let g=!0;if(a.enabled){o(h);const d=h.range,S=a.prevRange;g=!S||S.isScrolling!==h.isScrolling||S.startIndex!==(d==null?void 0:d.startIndex)||S.endIndex!==(d==null?void 0:d.endIndex),g&&(a.prevRange=d?{startIndex:d.startIndex,endIndex:d.endIndex,isScrolling:h.isScrolling}:null)}g&&(r&&c?k.flushSync(s):s()),(f=e.onChange)==null||f.call(e,h,c)}},[l]=y.useState(()=>{const h=new q(n);return Object.assign(h,{containerRef:c=>{const f=i.current;if(f.container=c,f.lastSize=null,c&&f.enabled){const a=h.getTotalSize();f.lastSize=a;const g=h.options.horizontal?"width":"height";c.style[g]=`${a}px`}}})});return l.setOptions(n),T(()=>l._didMount(),[]),T(()=>l._willUpdate()),T(()=>{o(l)}),l}function Q(r){return X({observeElementRect:K,observeElementOffset:B,scrollToFn:$,...r})}export{Q as u};
|