// Metro module 9740 (f9741). import { useRef } from "react"; import { useDerivedValue } from "./Module1606"; function $mk106698($env) { return (a0, a1) => a0 === $env[0][a1]; } let isArraysEqual; const __initData = { code: "function pnpm_useVisibleRangesTsx1(){const{windowSize,translation,viewSize,Total,loop,isArraysEqual,cachedRanges}=this.__closure;var _cachedRanges$current,_cachedRanges$current2,_cachedRanges$current3,_cachedRanges$current4;const positiveCount=Math.round(windowSize/2);const negativeCount=windowSize-positiveCount;let currentIndex=Math.round(-translation.value/viewSize);currentIndex=currentIndex<0?currentIndex%Total+Total:currentIndex;let newRanges;if(!loop){newRanges={negativeRange:[0+currentIndex-(windowSize-1),0+currentIndex],positiveRange:[0+currentIndex,currentIndex+(windowSize-1)]};}else{const negativeRange=[(currentIndex-negativeCount+Total)%Total,(currentIndex-1+Total)%Total];const positiveRange=[(currentIndex+Total)%Total,(currentIndex+positiveCount+Total)%Total];if(negativeRange[0]negativeRange[1]){negativeRange[1]=Total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=Total-1;positiveRange[0]=0;}newRanges={negativeRange:negativeRange,positiveRange:positiveRange};}if(isArraysEqual((_cachedRanges$current=(_cachedRanges$current2=cachedRanges.current)===null||_cachedRanges$current2===void 0?void 0:_cachedRanges$current2.negativeRange)!==null&&_cachedRanges$current!==void 0?_cachedRanges$current:[],newRanges.negativeRange)&&isArraysEqual((_cachedRanges$current3=(_cachedRanges$current4=cachedRanges.current)===null||_cachedRanges$current4===void 0?void 0:_cachedRanges$current4.positiveRange)!==null&&_cachedRanges$current3!==void 0?_cachedRanges$current3:[],newRanges.positiveRange))return cachedRanges.current;cachedRanges.current=newRanges;return cachedRanges.current;}" }; const isArraysEqual2 = function isArraysEqual(a0, a1) { let env26526; const r1 = env26526 = {}; env26526[0] = a1; return a0.length === a1.length && a0.every($mk106698(r1)); }; isArraysEqual2.__closure = {}; isArraysEqual2.__workletHash = 6222082561981; isArraysEqual2.__initData = { code: "function isArraysEqual_Pnpm_useVisibleRangesTsx2(a,b){if(a.length!==b.length)return false;return a.every(function(value,index){return value===b[index];});}" }; isArraysEqual = isArraysEqual2; export function useVisibleRanges(a0) { const { Total = 0, viewSize, translation } = a0; let windowSize = a0.windowSize; const _loop = a0.loop; if (windowSize == null) { windowSize = Total; } const total2 = windowSize; const ref = useRef(null); const r20 = function() { let current; const r11 = Math.round(total2 / 2); const r15 = total2 - r11; const r21 = Math.round(-translation.value / viewSize); let r23 = r21; if (r23 < 0) { r23 = r21 % Total + Total; } if (_loop) { const negativeRange2 = [(r23 - r15 + Total) % Total, (r23 - 1 + Total) % Total]; const positiveRange2 = [(r23 + Total) % Total, (r23 + r11 + Total) % Total]; if (negativeRange2[0] < Total && negativeRange2[0] > negativeRange2[1]) { negativeRange2[1] = Total - 1; positiveRange2[0] = 0; } if (positiveRange2[0] > positiveRange2[1]) { negativeRange2[1] = Total - 1; positiveRange2[0] = 0; } current = { negativeRange: negativeRange2, positiveRange: positiveRange2 }; } else { current = { negativeRange: [0 + r23 - (total2 - 1), 0 + r23], positiveRange: [0 + r23, r23 + (total2 - 1)] }; } let r64 = ref.current?.negativeRange; if (r64 == null) { r64 = []; } const negativeRange = current.negativeRange; let env26527; const r67 = env26527 = {}; env26527[0] = negativeRange; let r70 = r64.length === negativeRange.length && r64.every($mk106698(r67)); if (r70) { let r75 = ref.current?.positiveRange; if (r75 == null) { r75 = []; } const positiveRange = current.positiveRange; let env26528; const r79 = env26528 = {}; env26528[0] = positiveRange; r70 = r75.length === positiveRange.length && r75.every($mk106698(r79)); } if (!r70) { ref.current = current; } return ref.current; }; r20.__closure = { windowSize: total2, translation, viewSize, Total, loop: _loop, isArraysEqual, cachedRanges: ref }; r20.__workletHash = 627759706032; r20.__initData = __initData; return useDerivedValue(r20, [_loop, Total, total2, translation]); }