// Metro module 10867 (f10868). import { STANDARD_EASING } from "../../../design/void/native"; import * as _spring from "../../../design/animation/reanimated/spring/spring"; import * as _timing from "../../../design/animation/reanimated/timing/timing"; import { useSharedValue } from "../../reanimated/ReanimatedRexport"; import { Gesture } from "../../../_bundle/Module5273"; function $mk118274($env) { return (a0, a1) => { const r7 = Math; const r8 = $env[0]; const r11 = r7.abs(a0 - r8); const r16 = Math.abs(a1 - r8); return r11 < r16 ? -1 : r11 > r16 ? 1 : 0; }; } let getNearestValue, withPanGestureSpring, withPanGestureTiming, __initData2, __initData3, __initData4, __initData5; let c7305_2 = { damping: 30, mass: 1, stiffness: 250, overshootClamping: true, restSpeedThreshold: 0.001, restDisplacementThreshold: 0.001 }; let c7305_3 = { duration: 500, easing: STANDARD_EASING }; const __initData = { code: "function getSortedByMeasure_PanGestureAnimationsTsx2(array,measure){const sorted=new Array(...array).sort(function(left,right){const al=Math.abs(left-measure);const ar=Math.abs(right-measure);return alar?1:0;});return sorted;}" }; const getNearestValue2 = function getNearestValue(a0, a1) { let r31; let c26817_0 = a1; let r7 = arguments[2]; if (r7 === void 0) { r7 = 0; } const r0 = r7 < 0 ? -1 : r7 > 0 ? 1 : 0; let c26817_1 = r0; const getSortedByMeasure = function getSortedByMeasure(a0, a1) { let env31591; const r1 = env31591 = {}; env31591[0] = a1; return new Array(...[...a0]).sort($mk118274(r1)); }; getSortedByMeasure.__closure = {}; getSortedByMeasure.__workletHash = 9192847351523; getSortedByMeasure.__initData = __initData; if (a0.length === 0) { return a1; } let env26818; const r20 = env26818 = {}; env26818[0] = a1; const r30 = new Array(...[...a0]).sort($mk118274(r20)); if (r0 !== 0) { let r34 = r30.find((item) => c26817_1 < 0 ? c26817_0 > item : c26817_0 < item); if (r34 == null) { r34 = r30[0]; } r31 = r34; } else { r31 = r30[0]; } return r31; }; getNearestValue2.__closure = {}; getNearestValue2.__workletHash = 4186929947751; getNearestValue2.__initData = { code: "function getNearestValue_PanGestureAnimationsTsx1(array,measure,velocity=0){const unitVector=velocity<0?-1:velocity>0?1:0;function getSortedByMeasure(array,measure){'worklet';const sorted=new Array(...array).sort(function(left,right){const al=Math.abs(left-measure);const ar=Math.abs(right-measure);return alar?1:0;});return sorted;}if(array.length===0){return measure;}const sorted=getSortedByMeasure(array,measure);if(unitVector!==0){var _sorted$find;return(_sorted$find=sorted.find(function(value){const result=unitVector<0?measure>value:measureswipeVelocityThreshold?velocity.get():0;const snapPoint=getNearestValue(snapPositions.get(),translate.get(),swipeVelocity);if(swipeVelocity!==0){translate.set(withPanGestureSpring(snapPoint,velocity.get()));}else{translate.set(withPanGestureTiming(snapPoint));}(_onEnd=onEnd)===null||_onEnd===void 0||_onEnd(event,{success:success,destination:snapPoint,startPosition:start.get()});}}" }; __initData4 = { code: "function PanGestureAnimationsTsx7(event){const{start,vertical,LowerBounds,upperBounds,velocity,translate,onChange}=this.__closure;var _onChange;const{velocityY:velocityY,translationY:translationY,velocityX:velocityX,translationX:translationX}=event;let next=start.get()+(vertical?translationY:translationX);if(LowerBounds!=null&&nextupperBounds){next=upperBounds;}velocity.set(vertical?velocityY:velocityX);translate.set(next);(_onChange=onChange)===null||_onChange===void 0||_onChange(event,{destination:translate.get(),startPosition:start.get()});}" }; __initData5 = { code: "function PanGestureAnimationsTsx8(event){const{start,translate,velocity,isGestureInProgress,onStart}=this.__closure;var _onStart;start.set(translate.get());velocity.set(0);if(isGestureInProgress!=null){isGestureInProgress.set(true);}(_onStart=onStart)===null||_onStart===void 0||_onStart(event,{destination:start.get(),startPosition:start.get()});}" }; export default function usePanGesture(a0) { const { LowerBounds, upperBounds, snapPositions, swipeVelocityThreshold = 300 } = a0; let c18325_3 = swipeVelocityThreshold; const { translate, onStart, onChange, onEnd, vertical = true } = a0; let c18325_8 = vertical; const isGestureInProgress = a0.isGestureInProgress; const sharedValue = useSharedValue(0); const sharedValue2 = useSharedValue(0); const r30 = Gesture.Pan(); const N = function N(a0) { sharedValue.set(translate.get()); sharedValue2.set(0); if (isGestureInProgress != null) { isGestureInProgress.set(true); } if (onStart != null) { onStart(a0, { destination: sharedValue.get(), startPosition: sharedValue.get() }); } }; N.__closure = { start: sharedValue, translate, velocity: sharedValue2, isGestureInProgress, onStart }; N.__workletHash = 7008504704609; N.__initData = __initData5; const r36 = r30.onStart(N); const C = function C(a0) { const { velocityY, translationY } = a0; let velocityX = a0.velocityX; let translationX = a0.translationX; const r12 = sharedValue.get(); if (c18325_8) { translationX = translationY; } const r13 = r12 + translationX; let r14 = LowerBounds; if (!(LowerBounds != null && r13 < LowerBounds)) { r14 = upperBounds != null && r13 > upperBounds ? upperBounds : r13; } if (c18325_8) { velocityX = velocityY; } sharedValue2.set(velocityX); translate.set(r14); if (onChange != null) { onChange(a0, { destination: translate.get(), startPosition: sharedValue.get() }); } }; C.__closure = { start: sharedValue, vertical, LowerBounds, upperBounds, velocity: sharedValue2, translate, onChange }; C.__workletHash = 15962975179371; C.__initData = __initData4; const r42 = r36.onChange(C); const T = function T(a0, a1) { sharedValue.set(translate.get()); if (snapPositions != null) { const r24 = Math.abs(sharedValue2.get()) > c18325_3 ? sharedValue2.get() : 0; const nearestValue = getNearestValue(snapPositions.get(), translate.get(), r24); if (r24 !== 0) { translate.set(_spring.withSpring(nearestValue, { ...c7305_2, velocity: sharedValue2.get() })); } else { translate.set(_timing.withTiming(nearestValue, c7305_3)); } if (onEnd != null) { onEnd(a0, { success: a1, destination: nearestValue, startPosition: sharedValue.get() }); } } }; T.__closure = { start: sharedValue, translate, snapPositions, velocity: sharedValue2, swipeVelocityThreshold, getNearestValue, withPanGestureSpring, withPanGestureTiming, onEnd }; T.__workletHash = 15665959414289; T.__initData = __initData3; const r51 = r42.onEnd(T); const S = function S() { if (isGestureInProgress != null) { isGestureInProgress.set(false); } }; S.__closure = { isGestureInProgress }; S.__workletHash = 11128244755178; S.__initData = __initData2; return r51.onFinalize(S); }; export { c7305_2 as SPRING_CONFIG }; export { c7305_3 as TIMING_CONFIG }; export { withPanGestureSpring }; export { withPanGestureTiming };