// Metro module 14934 (f14935). import { useRef, useState, useCallback, useEffect } from "react"; import AccessibilityStore from "../../a11y/AccessibilityStore"; import HomeDrawerStore from "./HomeDrawerStore"; import { ME } from "../../../Constants"; import { ContentDismissActionType } from "../../dismissible_content/DismissibleContentConstants"; import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport"; import { Easing, useAnimatedReaction } from "../../reanimated/ReanimatedRexport"; import { DismissibleContent } from "../../../_bundle/Module1358"; import { useIsFocused } from "../../../_bundle/Module1481"; import { useDrawerOpen } from "./useDrawerState"; import { useStateFromStores } from "../../../_bundle/Module589"; import { useGuildsRouteGuildAndChannelId } from "../../main_tabs_v2/navigator/useGuildsRouteGuildId"; import { useIsDismissibleContentDismissed_UNSAFE } from "../../dismissible_content/DismissibleContentUnsafeUtils"; import { useSelectedDismissibleContent } from "../../dismissible_content/hooks/useSelectedDismissibleContent"; import { withTiming } from "../../../design/animation/reanimated/timing/timing"; import { withSpring } from "../../../design/animation/reanimated/spring/spring"; import { HOME_DRAWER_FLING_PHYSICS } from "./useHomeDrawerGesture"; let c10562_8 = 2000; const easing = Easing.inOut(Easing.cubic); let c10562_10 = []; let c10562_11 = [DismissibleContent.HOME_DRAWER_SWIPE_PEEK_NUX]; const __initData = { code: "function useHomeDrawerPeekHintTsx1(){const{gestureState,panelX,PEEK_HINT_DRAWER_DRAG_THRESHOLD}=this.__closure;return gestureState.get().active&&panelX.get()>PEEK_HINT_DRAWER_DRAG_THRESHOLD;}" }; const __initData2 = { code: "function useHomeDrawerPeekHintTsx2(isDragged,wasDragged){const{isPeekGranted,runOnJS,handleDrawerDragged}=this.__closure;if(!isPeekGranted||wasDragged==null)return;if(isDragged&&!wasDragged){runOnJS(handleDrawerDragged)();}}" }; export const PEEK_HINT_DISTANCE = 40; export function useHomeDrawerPeekHint(a0, a1) { let c21465_7, ref, ref2, ref3, ref4, ref5, callback, c21465_17, callback2, callback3; let r6 = a0; let c21465_0 = a1; const r23 = HomeDrawerStore(); const { panelX, gestureState, lastInteractionAt, isPanelTouchActive, noteInteraction } = r23; const isFocused = useIsFocused(); const drawerOpen = useDrawerOpen(a0); const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion); const [r40] = useGuildsRouteGuildAndChannelId(); const r2 = !useIsDismissibleContentDismissed_UNSAFE(DismissibleContent.HOME_DRAWER_SWIPE_PEEK_NUX); if (a0) { r6 = isFocused; } if (r6) { r6 = r40 != null; } if (r6) { r6 = r40 !== ME; } if (r6) { r6 = !drawerOpen; } if (r6) { r6 = !stateFromStores; } if (r6) { r6 = r2; } c21465_7 = r6; ref = useRef(false); const [state, setState] = useState(false); if (state ? !r6 : state) { setState(false); } let [r67, current] = useSelectedDismissibleContent(state && r6 ? c10562_11 : c10562_10, void 0, true); ref2 = useRef(null); ref3 = useRef(null); ref4 = useRef(false); ref5 = useRef(null); callback = useCallback(() => { if (ref2.current != null) { clearTimeout(ref2.current); ref2.current = null; } ref4.current = true; c21465_0.set(withTiming(40, { duration: 1500, easing })); ref3.current = setTimeout(() => { ref3.current = null; ref4.current = false; c21465_0.set(withSpring(0, HOME_DRAWER_FLING_PHYSICS)); const current2 = ref5.current; if (current2 != null) { current2.call(ref5, ContentDismissActionType.AUTO_DISMISS); } setState(false); }, 2500); }, [a1]); const isPeekGranted = r67 === DismissibleContent.HOME_DRAWER_SWIPE_PEEK_NUX; c21465_17 = isPeekGranted; useEffect(() => { if (c21465_17 && !ref4.current) { ref5.current = current; callback(); } }, [isPeekGranted, callback, current]); callback2 = useCallback(() => { if (ref2.current != null) { clearTimeout(ref2.current); ref2.current = null; } if (ref3.current != null) { clearTimeout(ref3.current); ref3.current = null; } if (ref4.current) { ref4.current = false; c21465_0.set(withSpring(0, HOME_DRAWER_FLING_PHYSICS)); } }, [a1]); useEffect(() => { if (c21465_7 && !state && !ref.current) { noteInteraction(); const r5 = setTimeout; const checkIdle2 = function checkIdle() { ref2.current = null; let r1 = c10562_8 - (Date.now() - lastInteractionAt.current); if (!isPanelTouchActive.get() && !(0 < r1)) { setState(true); } else { const r22 = setTimeout; if (!(0 < r1)) { r1 = c10562_8; } ref2.current = r22(checkIdle2, r1); } }; ref2.current = r5(checkIdle2, c10562_8); return () => { if (ref2.current != null) { clearTimeout(ref2.current); ref2.current = null; } }; } }, [r6, state, noteInteraction, lastInteractionAt, isPanelTouchActive]); useEffect(() => { if (drawerOpen) { ref.current = true; callback2(); } }, [drawerOpen, callback2]); useEffect(() => { if (c21465_7 ? !c21465_7 : ref4.current) { callback2(); const current2 = ref5.current; if (current2 != null) { current2.call(ref5, ContentDismissActionType.AUTO_DISMISS); } } }, [r6, callback2]); callback3 = useCallback(() => { callback2(); const current2 = ref5.current; if (current2 != null) { current2.call(ref5, ContentDismissActionType.INDIRECT_ACTION); } setState(false); }, [callback2]); const V = () => gestureState.get().active && panelX.get() > 8; V.__closure = { gestureState, panelX, PEEK_HINT_DRAWER_DRAG_THRESHOLD: 8 }; V.__workletHash = 15765003051494; V.__initData = __initData; const Q = function Q(a0, a1) { if (c21465_17 && a1 != null && a0 && !a1) { _ReanimatedRexport.runOnJS(callback3)(); } }; Q.__closure = { isPeekGranted, runOnJS: _ReanimatedRexport.runOnJS, handleDrawerDragged: callback3 }; Q.__workletHash = 10054961085184; Q.__initData = __initData2; useAnimatedReaction(V, Q); }