// Metro module 9806 (f9807). import { useState, useRef, useCallback, useEffect } from "react"; import AccessibilityStore from "../../../a11y/AccessibilityStore"; import { useStateFromStores } from "../../../../_bundle/Module589"; import usePrevious from "../../../../hooks/usePrevious"; export function useVirtualCurrencyBalanceAnimationData({ initialRenderedBalance, balance }) { let state, setState, ref, ref2, setState2, state2, setState3, c17502_10, callback; state = void 0; setState = void 0; ref = void 0; ref2 = void 0; setState2 = void 0; state2 = void 0; setState3 = void 0; c17502_10 = void 0; callback = void 0; const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion); [state, setState] = useState(null); ref = useRef(null); ref2 = useRef(null); let showInitialRenderedBalance; [showInitialRenderedBalance, setState2] = useState(initialRenderedBalance != null); [state2, setState3] = useState(initialRenderedBalance == null); const previous = usePrevious(balance); c17502_10 = previous; const callback2 = useCallback(() => {}, []); const callback3 = useCallback(() => { ref.current = null; setState(null); }, []); callback = useCallback((a0) => { if (a0 !== 0) { ref.current = a0 > 0 ? "earn" : "spend"; if (state === ref.current) { const current = ref2.current; if (current != null) { current.play(); } } else { setState(ref.current); } } }, [state]); useEffect(() => { if (initialRenderedBalance != null && balance !== null && !state2) { let c26541_0 = setTimeout(() => { if (!stateFromStores) { callback(balance - initialRenderedBalance); } setState2(false); setState3(true); }, 1250); return () => clearTimeout(c26541_0); } }, [initialRenderedBalance, balance, state2, stateFromStores, callback]); useEffect(() => { if (balance !== null && c17502_10 !== null && balance !== c17502_10 && state2 && !stateFromStores) { callback(balance - c17502_10); } }, [balance, previous, state, state2, stateFromStores, callback]); return { onValueChange: callback2, onValueReached: callback3, showInitialRenderedBalance, currentAnimationType: state, lottieRef: ref2 }; }