// Metro module 14940 (f14941). import { useContext, useRef, useEffect, useCallback, useMemo } from "react"; import { Dimensions } from "react-native"; import GuildStore from "../../../../stores/GuildStore"; import SortedGuildStore, { GuildsNodeType } from "../../../../stores/SortedGuildStore"; import GuildsBarDnDStore from "../GuildsBarDnDStore"; import { FastListRenderSections, useGuildWrapperSize } from "../GuildsBarConstants"; import * as _ReanimatedRexport from "../../../reanimated/ReanimatedRexport"; import { makeMutable, useAnimatedRef, useSharedValue, useFrameCallback } from "../../../reanimated/ReanimatedRexport"; import debounce from "../../../../_bundle/debounce"; import { HapticFeedbackTypes, triggerHapticFeedback } from "../../../haptics/HapticUtils.native"; import { AccessibilityAnnouncer } from "../../../../design/shared"; import { throttle } from "../../../../_bundle/Module12"; import SentryUtils_native from "../../../../utils/SentryUtils.native"; import * as _index_native from "../../../../intl/index.native"; import { intl } from "../../../../intl/index.native"; import { FastListItemTypes } from "../../../../lib/native/FastList"; import { HomeDrawerStateContext } from "../../../home_drawer/native/useHomeDrawerGesture"; import { useToken } from "../../../../design/tokens/native/useToken"; import Module712 from "../../../../_bundle/Module712"; import { shallow } from "../../../../_bundle/Module3802"; import roundToNearestPixel from "../../../voice_panel/native/utils/roundToNearestPixel"; import { batchUpdates } from "../../../../_bundle/Module705"; import GuildActionCreators from "../../../../actions/GuildActionCreators"; import { saveGuildFolders } from "../../../../actions/UserSettingsActionCreators"; import { ContextMenuStore, showContextMenu, hideContextMenu, updateContextMenuState } from "../../../../design/components/ContextMenu/native/ContextMenuState.native"; import * as _PlatformUtils from "../../../../utils/PlatformUtils"; import { getSafeAreaInsets } from "../../../safe_area/useSafeAreaInsets.native"; import { getIsScreenReaderEnabled } from "../../../a11y/native/useIsScreenReaderEnabled.native"; import getGuildsBarGuildMenuItems from "../utils/getGuildsBarGuildMenuItems"; import { getGuildFolderMenuItems } from "../GuildsBarFolderMenuItems"; import { useExternalScrollEventHandler } from "../../../quests/native/QuestDock/QuestDockExternalCoordinationContext"; import { Gesture } from "../../../../_bundle/Module5273"; let GESTURE_ACCELERATION_RANGE, MS_PER_FRAME_60FPS, GuildsBarDnDStore2, state, c10568_16, c10568_17, c10568_18, c10568_19, c10568_21, triggerHapticsAndAnnouncementsIfNecessary, getItemAndNodeFromTouchEvent, __initData, __initData2, __initData3, __initData4, __initData5, __initData6, __initData7, __initData8, __initData9, __initData10; const getDropIndex = function getDropIndex(dragNode, a1, overState) { const r5 = overState === "self" ? dragNode : a1; const flattenedGuildFolderList = SortedGuildStore.getFlattenedGuildFolderList(); let r20 = -1; for (const item of flattenedGuildFolderList) { r20 = r20 + 1; if (item.id !== r5.id) { continue; } break; } if (overState !== "after" && overState !== "convert-after") { return r20; } return r20 + 1; }; triggerHapticsAndAnnouncementsIfNecessary = function triggerHapticsAndAnnouncementsIfNecessary(a0) { let r102, itemName, itemName2, itemName3, itemName4; L84: { const type = a0.type; if (type === "drag-start") { const node3 = a0.node; const type6 = node3.type; if (GuildsNodeType.GUILD === type6) { let r253 = GuildStore.getGuild(node3.id)?.name; if (r253 == null) { r253 = intl.string(_index_native.t.fKYRlM); } itemName4 = r253; } else { const FOLDER4 = GuildsNodeType.FOLDER; itemName4 = void 0; if (FOLDER4 === type6) { let name4 = node3.name; if (name4 == null) { name4 = intl.string(_index_native.t.ebAnWE); } itemName4 = name4; } } if (itemName4 != null) { AccessibilityAnnouncer.announce(intl.formatToPlainString(_index_native.t["vHD/Je"], { itemName: itemName4 })); } c10568_16(HapticFeedbackTypes.DRAG_AND_DROP_START); c10568_16.flush(); } else if (type === "drag-move") { if (c10568_21?.type === "drag-move" && c10568_21.overNode.id === a0.overNode.id && c10568_21.overState === a0.overState) { break L84; } const r59 = c10568_21?.type === "drag-move" ? getDropIndex(c10568_21.dragNode, c10568_21.overNode, c10568_21.overState) : getDropIndex(a0.dragNode, a0.dragNode, "self"); const dropIndex = getDropIndex(a0.dragNode, a0.overNode, a0.overState); const type3 = c10568_21?.type; let r76 = "self"; if (type3 !== "drag-start") { let r79 = c10568_21?.overState; if (r79 == null) { r79 = "self"; } r76 = r79; } if (r59 === dropIndex) { const overState = a0.overState; if ((overState != null && overState.startsWith("convert")) === (r76 != null && r76.startsWith("convert"))) { break L84; } } L69: { c10568_16(HapticFeedbackTypes.DRAG_AND_DROP_MOVE); a0.dragNode; const { overNode, overState: overState2 } = a0; if (overState2 !== "convert-before" && overState2 !== "convert-after") { if (overState2 === "drop-into") { r102 = overNode.type === GuildsNodeType.FOLDER ? intl.formatToPlainString(_index_native.t.uLDoxR, { folderName: overNode.name }) : void 0; break L69; } if (overState2 === "before") { const r144 = _index_native.t["A5aDw+"]; const type4 = overNode.type; if (GuildsNodeType.GUILD === type4) { let r164 = GuildStore.getGuild(overNode.id)?.name; if (r164 == null) { r164 = intl.string(_index_native.t.fKYRlM); } itemName2 = r164; } else { const FOLDER2 = GuildsNodeType.FOLDER; itemName2 = void 0; if (FOLDER2 === type4) { let name2 = overNode.name; if (name2 == null) { name2 = intl.string(_index_native.t.ebAnWE); } itemName2 = name2; } } r102 = intl.formatToPlainString(r144, { itemName: itemName2 }); break L69; } r102 = void 0; if (overState2 !== "after") { break L69; } const w8FN92 = _index_native.t.w8FN92; const type2 = overNode.type; if (GuildsNodeType.GUILD === type2) { let r127 = GuildStore.getGuild(overNode.id)?.name; if (r127 == null) { r127 = intl.string(_index_native.t.fKYRlM); } itemName = r127; } else { const FOLDER = GuildsNodeType.FOLDER; itemName = void 0; if (FOLDER === type2) { let name = overNode.name; if (name == null) { name = intl.string(_index_native.t.ebAnWE); } itemName = name; } } r102 = intl.formatToPlainString(w8FN92, { itemName }); } else { const qiQ0QI = _index_native.t.qiQ0QI; const type5 = overNode.type; if (GuildsNodeType.GUILD === type5) { let r215 = GuildStore.getGuild(overNode.id)?.name; if (r215 == null) { r215 = intl.string(_index_native.t.fKYRlM); } itemName3 = r215; } else { const FOLDER3 = GuildsNodeType.FOLDER; itemName3 = void 0; if (FOLDER3 === type5) { let name3 = overNode.name; if (name3 == null) { name3 = intl.string(_index_native.t.ebAnWE); } itemName3 = name3; } } r102 = intl.formatToPlainString(qiQ0QI, { itemName: itemName3 }); } } if (r102 != null) { c10568_17(r102); } } else if (type === "drag-drop") { c10568_16(HapticFeedbackTypes.DRAG_AND_DROP_END); c10568_16.flush(); c10568_17.flush(); AccessibilityAnnouncer.announce(intl.string(_index_native.t.lMkmz7)); } } c10568_21 = a0.type !== "drag-drop" ? a0 : void 0; }; getItemAndNodeFromTouchEvent = function getItemAndNodeFromTouchEvent(a0, a1, ref, map) { let r40; const state3 = GuildsBarDnDStore.getState(); const dragRegion2 = state3.DragRegion; const r12 = state3.scrollPosition.get() + a0; let pointerPosition = r12; if (a1) { const r23 = dragRegion2.get(); pointerPosition = Math.max(Math.min(r12, r23.max - 2), r23.min + 2); } const current = ref.current; let r32 = current == null ? void 0 : current.getSectionItemFromPosition(pointerPosition, map); if (r32 == null) { r32 = { item: void 0, positionPercentage: 0 }; } const { item, positionPercentage } = r32; const r37 = item != null; let node3 = void 0; if (r37) { L20: { const r39 = item == null; r40 = void 0; if (!r39) { const r44 = item.section < FastListRenderSections.GUILDS; r40 = void 0; if (!r44) { const r51 = SortedGuildStore.getFastListGuildFolders()[item.section - FastListRenderSections.GUILDS]; const r52 = r51 != null; r40 = void 0; if (r52) { const type = item.type; if (FastListItemTypes.SECTION === type) { if (r51 != null) { const type4 = r51.type; const FOLDER2 = GuildsNodeType.FOLDER; r40 = r51; if (type4 === FOLDER2) { break L20; } } r40 = void 0; } else { const ITEM = FastListItemTypes.ITEM; r40 = void 0; if (ITEM === type) { const type2 = r51.type; const ROOT = GuildsNodeType.ROOT; r40 = void 0; if (type2 !== ROOT) { const type3 = r51.type; const FOLDER = GuildsNodeType.FOLDER; let r67 = r51; if (type3 === FOLDER) { const r70 = r51.children[item.item]; const r71 = r70 == null; r67 = r70; r40 = void 0; if (r71) { break L20; } } r40 = r67.type === GuildsNodeType.GUILD ? r67 : void 0; } } } } } } } node3 = r40; } return { item, overPercentage: Math.floor(100 * positionPercentage) / 100, node: node3, pointerPosition }; }; GESTURE_ACCELERATION_RANGE = 160; MS_PER_FRAME_60FPS = 16.666666666666668; GuildsBarDnDStore2 = GuildsBarDnDStore; state = { pan: makeMutable(-1), itemMeasurements: makeMutable([]), activeIndex: makeMutable(-1) }; c10568_16 = debounce(triggerHapticFeedback, 16); c10568_17 = debounce((a0) => { AccessibilityAnnouncer.announce(a0); }, 500); c10568_18 = throttle((a0) => { SentryUtils_native.addBreadcrumb({ category: "GuildsBarGesture", message: "handleGuildDrag started", data: a0 }); }, 2000); c10568_19 = throttle((a0) => { SentryUtils_native.addBreadcrumb({ category: "GuildsBarGesture", message: "handleGestureEnd started", data: a0 }); }, 3000); c10568_21 = void 0; __initData = { code: "function useGuildsBarGestureTsx1({timeSincePreviousFrame:timeSincePreviousFrame}){const{gestureState,pushScrollAccumulatedTime,MS_PER_FRAME_60FPS,pushScroll,scrollTo,scrollerRef,roundToNearestPixel,scrollPosition}=this.__closure;if(timeSincePreviousFrame==null||timeSincePreviousFrame<=0||gestureState.get().mode!=='drag'){return;}pushScrollAccumulatedTime.set(pushScrollAccumulatedTime.get()+timeSincePreviousFrame);if(pushScrollAccumulatedTime.get()DragRegion.get().max){manager.fail();}else if(event.changedTouches.length===1){runOnJS(handleTouchesDown)(touch.absoluteX,touch.absoluteY);}}" }; __initData7 = { code: "function useGuildsBarGestureTsx7(){const{runOnJS,handleGestureEnd}=this.__closure;runOnJS(handleGestureEnd)('cancel');}" }; __initData8 = { code: "function useGuildsBarGestureTsx8(){const{gestureState,runOnJS,handleGestureEnd}=this.__closure;if(gestureState.get().mode==='drag'){runOnJS(handleGestureEnd)('drop');}else if(gestureState.get().mode==='contextmenu'){runOnJS(handleGestureEnd)('contextmenu-open');}else{runOnJS(handleGestureEnd)('cancel');}}" }; __initData9 = { code: "function useGuildsBarGestureTsx9({absoluteX:absoluteX,absoluteY:absoluteY}){const{gestureState,listInsets,GESTURE_ACCELERATION_RANGE,windowSize,runOnJS,handleGuildDrag,handleContextMenuDrag}=this.__closure;if(gestureState.get().mode==='drag'){if(absoluteX!==gestureState.get().absoluteX||absoluteY!==gestureState.get().absoluteY){let{initialY:initialY}=gestureState.get();const minPushRange=listInsets.get().start+GESTURE_ACCELERATION_RANGE;const maxPushRange=windowSize-listInsets.get().end-GESTURE_ACCELERATION_RANGE;if(initialYinitialY){initialY=absoluteY;}else if(initialY>maxPushRange&&absoluteYDRAG_GESTURE_MINIMUM_DISTANCE&&diffX>absDiffY){gestureState.set({...gestureState.get(),mode:'contextmenu',absoluteX:touch.absoluteX,absoluteY:touch.absoluteY});dragDropInProgress.set(false);manager.activate();runOnJS(handleContextMenuDrag)(touch.absoluteX,touch.absoluteY);}else if(absDiffY>DRAG_GESTURE_MINIMUM_DISTANCE){gestureState.set({...gestureState.get(),mode:'drag',initialX:touch.absoluteX,initialY:touch.absoluteY,absoluteX:touch.absoluteX,absoluteY:touch.absoluteY});manager.activate();dragDropInProgress.set(true);runOnJS(handleGuildDrag)(touch.absoluteY);}}" }; export default function useGuildsBarGesture() { let gestureState, scrollPosition, DragRegion, windowSize, listInsets, dragDropInProgress, frameCallback, callback, callback2, callback3, callback4, callback5; const gesture = useContext(HomeDrawerStateContext).gesture; const guildWrapperSize = useGuildWrapperSize(); const token = useToken(Module712.modules.mobile.GUILD_BAR_ITEM_SIZE); const animatedRef = useAnimatedRef(); const ref = useRef(null); const sharedValue = useSharedValue(0); const sharedValue2 = useSharedValue(0); const r54 = GuildsBarDnDStore2((a0) => ({ gestureState: a0.gestureState, scrollPosition: a0.scrollPosition, DragRegion: a0.DragRegion, windowSize: a0.windowSize, listInsets: a0.listInsets, dragDropInProgress: a0.dragDropInProgress }), shallow); gestureState = r54.gestureState; scrollPosition = r54.scrollPosition; DragRegion = r54.DragRegion; windowSize = r54.windowSize; listInsets = r54.listInsets; dragDropInProgress = r54.dragDropInProgress; const persistantKeys = GuildsBarDnDStore2(({ dropSpecs, dragSpecs: dragSpecs3 }) => { const set = new Set(); if (dragSpecs3 != null) { set.add(dragSpecs3.item.recyclerKey); } if (dropSpecs != null) { set.add(dropSpecs.dragRecyclerKey); } return set.size > 0 ? Array.from(set) : void 0; }, shallow); useEffect(() => { const current = ref.current; const r7 = current == null ? void 0 : current.computeScrollPosition(FastListRenderSections.GUILDS); const current2 = ref.current; let r16 = current2 == null ? void 0 : current2.props.sections; if (r16 == null) { r16 = []; } const r1 = r16.length - 1; let r19 = r16[r1]; if (r19 == null) { r19 = 0; } const r20 = r19 - 1; const current3 = ref.current; const r23 = current3 == null ? void 0 : current3.computeScrollPosition(r1, r20); let min = r7?.scrollPosition; if (min == null) { min = 0; } const max = r23 != null ? r23.scrollPosition + r23.size : Infinity; const dragRegion2 = GuildsBarDnDStore.getState().DragRegion; const r37 = dragRegion2.get(); if (!(min === r37.min && max === r37.max)) { dragRegion2.set({ min, max }); } }); const W = function W({ timeSincePreviousFrame }) { if (timeSincePreviousFrame != null && !(timeSincePreviousFrame <= 0) && gestureState.get().mode === "drag") { sharedValue2.set(sharedValue2.get() + timeSincePreviousFrame); if (!(sharedValue2.get() < MS_PER_FRAME_60FPS)) { const r2 = 1000 * sharedValue.get(); const r34 = sharedValue2.get() / 1000; sharedValue2.set(0); _ReanimatedRexport.scrollTo(animatedRef, 0, Math.max(roundToNearestPixel(scrollPosition.get() + r34 * r2), 0), false); } } }; W.__closure = { gestureState, pushScrollAccumulatedTime: sharedValue2, MS_PER_FRAME_60FPS, pushScroll: sharedValue, scrollTo: _ReanimatedRexport.scrollTo, scrollerRef: animatedRef, roundToNearestPixel, scrollPosition }; W.__workletHash = 14384524602726; W.__initData = __initData; frameCallback = useFrameCallback(W, false); callback = useCallback((a0) => { let r67; let dropPosition, node, node2, c27864_4, c27864_5, state2, id; const state3 = GuildsBarDnDStore.getState(); const { dragSpecs, overSpecs: overSpecs2, gestureState: gestureState2, dragDropInProgress: dragDropInProgress2, setStateShallow: setStateShallow2 } = state3; sharedValue.set(0); sharedValue2.set(0); if (frameCallback.isActive) { frameCallback.setActive(false); } if (a0 === "cancel") { c10568_19({ event: a0, dragSpecs, overSpecs: overSpecs2, gestureState: gestureState2.get() }); } else { SentryUtils_native.addBreadcrumb({ category: "GuildsBarGesture", message: "handleGestureEnd started", data: { event: a0, dragSpecs, overSpecs: overSpecs2, gestureState: gestureState2.get() } }); } L59: { if (a0 === "drop" && (overSpecs2 != null && dragSpecs != null)) { L23: { const item = dragSpecs.item; const item2 = overSpecs2.item; const type = item.type; if (FastListItemTypes.SECTION !== type) { const ITEM = FastListItemTypes.ITEM; r67 = void 0; if (ITEM !== type) { break L23; } } const type2 = item2.type; if (FastListItemTypes.SECTION !== type2) { const ITEM2 = FastListItemTypes.ITEM; r67 = void 0; if (ITEM2 !== type2) { break L23; } } const r3 = item2.section < item.section; let r19 = "before"; let r79 = "before"; if (!r3) { const r81 = item2.section > item.section; let r82 = "after"; let r83 = "after"; if (!r81) { if (!(item2.item < item.item)) { if (!(item2.item > item.item)) { r82 = item2.item === item.item ? "self" : void 0; } r19 = r82; } r83 = r19; } r79 = r83; } r67 = r79; } dropPosition = (overSpecs2.state === "after" ? overSpecs2.item.layoutStart + dragSpecs.itemSize : overSpecs2.item.layoutStart) - (r67 === "after" ? dragSpecs.item.layoutSize : 0); node = dragSpecs.node; node2 = overSpecs2.node; const r104 = overSpecs2.state === "after"; c27864_4 = r104; c27864_5 = overSpecs2.state === "convert-before" || overSpecs2.state === "convert-after" || overSpecs2.state === "drop-into"; state2 = overSpecs2.state; if (state2 !== "self" && state2 != null) { const id2 = node2.id; id = id2; if (node.type === GuildsNodeType.FOLDER && (node2.type === GuildsNodeType.GUILD && node2.parentId != null)) { id = node2.parentId; } else if (node2.type === GuildsNodeType.FOLDER && node2.expanded && r104) { c27864_4 = false; let r140 = node2.children[0]?.id; if (r140 == null) { r140 = id2; } id = r140; } batchUpdates(() => { const id2 = node.id; if (id2 !== id) { const id3 = node.id; GuildActionCreators.moveById(id3, id, !!c27864_5 || c27864_4, c27864_5); (async () => { let c31751_3 = 0; L10: { try { c31751_3 = 1; await saveGuildFolders(SortedGuildStore.getCompatibleGuildFolders()); c31751_3 = 0; } catch ($e) { let r7 = $e; if (c31751_3 !== 0) { while (true) { try { c31751_3 = 0; break L10; } catch ($e) { r7 = $e; if (c31751_3 === 0) { break; } } } } throw r7; } } })(); } const state3 = GuildsBarDnDStore.getState(); let dragRecyclerKey = dragSpecs.item?.recyclerKey; if (dragRecyclerKey == null) { dragRecyclerKey = ""; } state3.dropStart({ dragNode: node, overNode: node2, dropPosition, dragRecyclerKey, itemSize: dragSpecs.itemSize, overState: state2 }); }); triggerHapticsAndAnnouncementsIfNecessary({ type: "drag-drop", dragNode: node, overNode: node2, overState: state2 }); break L59; } const state4 = GuildsBarDnDStore.getState(); let dragRecyclerKey = dragSpecs.item?.recyclerKey; if (dragRecyclerKey == null) { dragRecyclerKey = ""; } state4.dropStart({ dragNode: node, overNode: node, dropPosition: dragSpecs.itemTop, itemSize: dragSpecs.itemSize, dragRecyclerKey, overState: "self" }); triggerHapticsAndAnnouncementsIfNecessary({ type: "drag-drop", dragNode: node, overNode: node, overState: "self" }); } else { if (a0 === "contextmenu-open") { const menu = ContextMenuStore.getState().menu; if (menu != null) { menu.requestClose(menu.state.activeIndex.get() === -1); } } setStateShallow2({ dragSpecs: void 0, overSpecs: void 0 }); const r173 = gestureState2.get(); if (r173.mode != null) { gestureState2.set({ ...r173, mode: null }); dragDropInProgress2.set(false); } } } }, [sharedValue, sharedValue2, frameCallback]); callback2 = useCallback((a0, a1) => { const state3 = GuildsBarDnDStore.getState(); const { gestureState: gestureState2, dragDropInProgress: dragDropInProgress2 } = state3; const item = getItemAndNodeFromTouchEvent(a1, false, ref).item; const r20 = gestureState2.get(); if (item == null && r20.mode == null) { gestureState2.set({ ...r20, mode: "cancel" }); dragDropInProgress2.set(false); } }, []); callback3 = useCallback((a0, a1) => { let r78; const state3 = GuildsBarDnDStore.getState(); state3.dragSpecs; const { scrollPosition: scrollPosition2, gestureState: gestureState2, dragDropInProgress: dragDropInProgress2, setStateShallow: setStateShallow2 } = state3; SentryUtils_native.addBreadcrumb({ category: "GuildsBarGesture", message: "handlePress started", data: { absoluteX: a0, absoluteY: a1 } }); const itemAndNodeFromTouchEvent = getItemAndNodeFromTouchEvent(a1, false, ref); const { item, node: node3 } = itemAndNodeFromTouchEvent; if (item != null && node3 != null) { const dragSpecs3 = { node: node3, item, itemTop: item.layoutStart, itemSize: item.layoutSize }; const height = Dimensions.get("window").height; const isAndroid = _PlatformUtils.isAndroid(); let windowSize3 = height; if (isAndroid) { const safeAreaInsets = getSafeAreaInsets(); windowSize3 = height + (safeAreaInsets.top + safeAreaInsets.bottom); } state.activeIndex.set(-1); if (getIsScreenReaderEnabled()) { triggerHapticsAndAnnouncementsIfNecessary({ type: "drag-start", node: node3 }); } else { const type = node3.type; if (GuildsNodeType.GUILD === type) { const guild = GuildStore.getGuild(node3.id); r78 = { key: node3.id, title: guild?.name, items: guild != null ? getGuildsBarGuildMenuItems(guild.id, SortedGuildStore.getGuildsTree().version) : [] }; } else { r78 = GuildsNodeType.FOLDER === type ? { key: node3.id, title: node3.name, items: getGuildFolderMenuItems(node3.id) } : void 0; } const { items, key, title } = r78; if (items.length > 0) { showContextMenu({ key: `${key}`, title, items, x: 12 + token + 12, y: item.layoutStart - scrollPosition2.get(), positionX: "left", positionY: "below", width: token, height: token, state, dividerIndexes: [], keyboardShouldPersistTaps: "never", requestClose: (a0) => { if (!a0) { const r10 = items[state.activeIndex.get()]; if (r10 != null) { r10.action(); } } state.activeIndex.set(-1); hideContextMenu(); callback("contextmenu-close"); }, onClose: () => {} }); } } setStateShallow2({ dragSpecs: dragSpecs3, overSpecs: void 0, windowSize: windowSize3 }); gestureState2.set({ mode: "pressed", initialY: a1, initialX: a0, absoluteY: a1, absoluteX: a0 }); triggerHapticFeedback(HapticFeedbackTypes.IMPACT_MEDIUM); } else { gestureState2.set({ ...gestureState2.get(), mode: null }); dragDropInProgress2.set(false); } }, [callback, token]); callback4 = useCallback((a0, a1) => { updateContextMenuState(a0, a1, state); }, []); callback5 = useCallback((a0) => { let r145, overState; const state3 = GuildsBarDnDStore.getState(); const overSpecs2 = state3.overSpecs; let overSpecs = overSpecs2; let dragSpecs2 = state3.dragSpecs; const { windowSize: windowSize2, setStateShallow, listInsets: listInsets2, gestureState: gestureState2 } = state3; c10568_18({ overSpecs: overSpecs2, dragSpecs: dragSpecs2, windowSize: windowSize2, gestureState: gestureState2.get() }); if (dragSpecs2 != null) { const r13 = gestureState2.get(); if (!(getIsScreenReaderEnabled() || dragSpecs2.node == null || overSpecs2 != null)) { triggerHapticsAndAnnouncementsIfNecessary({ type: "drag-start", node: dragSpecs2.node }); } const map = new Map(); const r61 = overSpecs2 != null && overSpecs2.state !== "self"; if (r61) { map.set(dragSpecs2.item.recyclerKey, 0); map.set(overSpecs2.item.recyclerKey, 2 * dragSpecs2.itemSize); } const itemAndNodeFromTouchEvent = getItemAndNodeFromTouchEvent(a0, true, ref, map); const { item, overPercentage, node: node3 } = itemAndNodeFromTouchEvent; if (!((overSpecs2 == null ? void 0 : overSpecs2.node.id) === node3?.id && overSpecs2?.percentage === overPercentage)) { if (ContextMenuStore.getState().menu != null) { hideContextMenu(); } let overNode = node3; let percentage = overPercentage; let item3 = item; if (item != null) { const r27 = overSpecs2 == null ? void 0 : overSpecs2.item.recyclerKey; const recyclerKey = item.recyclerKey; overNode = node3; percentage = overPercentage; item3 = item; if (r27 !== recyclerKey) { map.clear(); if (dragSpecs2.item.recyclerKey !== item.recyclerKey) { let recyclerKey2 = dragSpecs2.item.recyclerKey; if (recyclerKey2 == null) { recyclerKey2 = ""; } map.set(recyclerKey2, 0); map.set(item.recyclerKey, 2 * guildWrapperSize); } const itemAndNodeFromTouchEvent2 = getItemAndNodeFromTouchEvent(a0, true, ref, map); item3 = itemAndNodeFromTouchEvent2.item; percentage = itemAndNodeFromTouchEvent2.overPercentage; overNode = itemAndNodeFromTouchEvent2.node; } } L73: { const { node: node4, item: item2 } = dragSpecs2; const r128 = item2 != null; overState = void 0; if (r128) { const r130 = item3 != null; overState = void 0; if (r130) { const r131 = node4 != null; overState = void 0; if (r131) { const r132 = overNode != null; overState = void 0; if (r132) { const id2 = node4.id; const id3 = overNode.id; overState = "self"; if (id2 !== id3) { L44: { const type2 = item2.type; if (FastListItemTypes.SECTION !== type2) { const ITEM = FastListItemTypes.ITEM; r145 = void 0; if (ITEM !== type2) { break L44; } } const type3 = item3.type; r145 = FastListItemTypes.SECTION !== type3 ? FastListItemTypes.ITEM === type3 ? item3.recyclerKey !== item2.recyclerKey ? percentage < 0.5 ? "before" : "after" : "self" : void 0 : item3.recyclerKey !== item2.recyclerKey ? percentage < 0.5 ? "before" : "after" : "self"; } const type = node4.type; const FOLDER = GuildsNodeType.FOLDER; const type4 = overNode.type; const FOLDER2 = GuildsNodeType.FOLDER; if (type === FOLDER) { const r165 = type4 === FOLDER2; if (r145 === "after") { if (r165) { const expanded = overNode.expanded; overState = void 0; if (expanded) { break L73; } } if (!r165 && overNode.parentId != null) { const node5 = SortedGuildStore.getGuildsTree().getNode(overNode.parentId); if (node5 != null) { const r180 = node5.children[node5.children.length - 1]; if (r180 != null) { const id4 = r180.id; const id5 = overNode.id; overState = void 0; if (id4 !== id5) { break L73; } } } } } if (r145 === "before" && !r165) { const r185 = overNode.parentId != null; overState = void 0; if (r185) { break L73; } } } overState = r145; if (r145 !== "self") { overState = r145; if (r145 != null) { if (node4.type === GuildsNodeType.GUILD && overNode.type === GuildsNodeType.GUILD && overNode.parentId == null) { overState = r145; if (!(percentage > 0.35)) { break L73; } overState = r145; if (!(percentage < 0.65)) { break L73; } if (r145 === "before") { overState = "convert-before"; break L73; } overState = r145; if (overState !== "after") { break L73; } overState = "convert-after"; break L73; } overState = node4.type === GuildsNodeType.GUILD ? overNode.type === GuildsNodeType.FOLDER ? overNode.expanded ? r145 : percentage > 0.35 ? percentage < 0.65 ? "drop-into" : r145 : r145 : r145 : r145; } } } } } } } } if (overState == null) { overNode = dragSpecs2.node; item3 = dragSpecs2.item; overState = "self"; } if (overNode != null && overSpecs2 != null) { triggerHapticsAndAnnouncementsIfNecessary({ type: "drag-move", dragNode: dragSpecs2.node, overNode, overState }); } if (!(overNode == null || item3 == null || overSpecs2?.node === overNode && overSpecs2?.item === item3 && overSpecs2?.state === overState)) { overSpecs = { node: overNode, item: item3, state: overState, percentage }; } } const r221 = listInsets2.get().start + GESTURE_ACCELERATION_RANGE; const r226 = windowSize2 - listInsets2.get().end - GESTURE_ACCELERATION_RANGE; const r228 = a0 < r221 ? -1 * Math.max(Math.min(Math.min(r13.initialY, r221) - a0, GESTURE_ACCELERATION_RANGE) / GESTURE_ACCELERATION_RANGE, 0) : a0 > r226 ? Math.max(Math.min(a0 - Math.max(r13.initialY, r226), GESTURE_ACCELERATION_RANGE) / GESTURE_ACCELERATION_RANGE, 0) : 0; sharedValue.set(r228); let r256 = r228 === 0; if (r256 && frameCallback.isActive) { sharedValue2.set(0); frameCallback.setActive(false); } else { if (!r256) { r256 = frameCallback.isActive; } if (!r256) { frameCallback.setActive(true); } } batchUpdates(() => { if (dragSpecs2 != null && dragSpecs2.node.type === GuildsNodeType.FOLDER && dragSpecs2.node.expanded) { GuildActionCreators.toggleGuildFolderExpand(dragSpecs2.node.id); const node3 = SortedGuildStore.getGuildsTree().getNode(dragSpecs2.node.id); if (node3 !== dragSpecs2.node && node3?.type === GuildsNodeType.FOLDER) { dragSpecs2 = { ...dragSpecs2, node: node3 }; } } setStateShallow({ overSpecs, dragSpecs: dragSpecs2, windowSize: windowSize2 }); }); } }, [sharedValue, sharedValue2, frameCallback, guildWrapperSize]); const externalScrollEventHandler = useExternalScrollEventHandler({ id: "guilds" }); const callback6 = useCallback(() => { const r8 = GuildsBarDnDStore.getState().gestureState.get(); if (r8.mode === "drag") { callback5(r8.absoluteY); } }, [callback5]); const memo = useMemo(() => { const r8 = Gesture.LongPress(); const h = function h(a0, a1) { const r10 = a0.changedTouches[0]; let r8 = r10?.absoluteY; if (r8 == null) { r8 = 0; } L11: { const r12 = r8 + scrollPosition.get(); if (r10 != null && (gestureState.get().mode !== "cancel" && (!(r12 < DragRegion.get().min) && !(r12 > DragRegion.get().max)))) { if (a0.changedTouches.length !== 1) { break L11; } _ReanimatedRexport.runOnJS(callback2)(r10.absoluteX, r10.absoluteY); } else { a1.fail(); } } }; h.__closure = { scrollPosition, gestureState, DragRegion, runOnJS: _ReanimatedRexport.runOnJS, handleTouchesDown: callback2 }; h.__workletHash = 5430653816983; h.__initData = __initData6; const r31 = r8.onTouchesDown(h); const f = function f(a0, a1) { if (gestureState.get().mode === "cancel") { a1.fail(); } }; f.__closure = { gestureState }; f.__workletHash = 8960390413776; f.__initData = __initData5; const r37 = r31.onTouchesMove(f); const c = function c({ absoluteX, absoluteY }) { if (gestureState.get().mode !== "cancel") { _ReanimatedRexport.runOnJS(callback3)(absoluteX, absoluteY); } }; c.__closure = { gestureState, runOnJS: _ReanimatedRexport.runOnJS, handlePress: callback3 }; c.__workletHash = 2121892092583; c.__initData = __initData4; const r47 = r37.onStart(c); const u = function u() { if (gestureState.get().mode === "cancel") { _ReanimatedRexport.runOnJS(callback)("cancel"); } }; u.__closure = { gestureState, runOnJS: _ReanimatedRexport.runOnJS, handleGestureEnd: callback }; u.__workletHash = 2371934536573; u.__initData = __initData3; const r57 = r47.onEnd(u); const l = function l() { if (!(gestureState.get().mode != null && gestureState.get().mode !== "cancel")) { _ReanimatedRexport.runOnJS(callback)("cancel"); } }; l.__closure = { gestureState, runOnJS: _ReanimatedRexport.runOnJS, handleGestureEnd: callback }; l.__workletHash = 8240921685123; l.__initData = __initData2; const r65 = r57.onTouchesCancelled(l); const shouldCancelWhenOutside = Gesture.Pan().manualActivation(true).simultaneousWithExternalGesture(animatedRef, gesture).shouldCancelWhenOutside(false); const r81 = function(a0, a1) { L11: { const r15 = a0.changedTouches[0]; if (gestureState.get().mode === "pressed" && r15 != null) { const r33 = r15.absoluteX - gestureState.get().initialX; const r39 = Math.abs(r15.absoluteY - gestureState.get().absoluteY); if (r33 > 10 && r33 > r39) { gestureState.set({ ...gestureState.get(), mode: "contextmenu", absoluteX: r15.absoluteX, absoluteY: r15.absoluteY }); dragDropInProgress.set(false); a1.activate(); _ReanimatedRexport.runOnJS(callback4)(r15.absoluteX, r15.absoluteY); break L11; } if (!(r39 > 10)) { break L11; } gestureState.set({ ...gestureState.get(), mode: "drag", initialX: r15.absoluteX, initialY: r15.absoluteY, absoluteX: r15.absoluteX, absoluteY: r15.absoluteY }); a1.activate(); dragDropInProgress.set(true); _ReanimatedRexport.runOnJS(callback5)(r15.absoluteY); } else if (!(gestureState.get().mode !== "cancel" && r15 != null)) { a1.fail(); dragDropInProgress.set(false); } } }; r81.__closure = { gestureState, dragDropInProgress, DRAG_GESTURE_MINIMUM_DISTANCE: 10, runOnJS: _ReanimatedRexport.runOnJS, handleContextMenuDrag: callback4, handleGuildDrag: callback5 }; r81.__workletHash = 15225957003871; r81.__initData = __initData10; const r89 = shouldCancelWhenOutside.onTouchesMove(r81); const r91 = function(a0) { L14: { const { absoluteX, absoluteY } = a0; if (gestureState.get().mode === "drag") { if (absoluteX === gestureState.get().absoluteX && absoluteY === gestureState.get().absoluteY) { break L14; } let initialY = gestureState.get().initialY; const r44 = listInsets.get().start + GESTURE_ACCELERATION_RANGE; const r0 = windowSize - listInsets.get().end - GESTURE_ACCELERATION_RANGE; if (initialY < r44 && absoluteY > initialY || initialY > r0 && absoluteY < initialY) { initialY = absoluteY; } gestureState.set({ ...gestureState.get(), absoluteX, absoluteY, initialY }); _ReanimatedRexport.runOnJS(callback5)(absoluteY); } else if (gestureState.get().mode === "contextmenu") { _ReanimatedRexport.runOnJS(callback4)(absoluteX, absoluteY); } } }; r91.__closure = { gestureState, listInsets, GESTURE_ACCELERATION_RANGE, windowSize, runOnJS: _ReanimatedRexport.runOnJS, handleGuildDrag: callback5, handleContextMenuDrag: callback4 }; r91.__workletHash = 14488930469604; r91.__initData = __initData9; const r100 = r89.onUpdate(r91); const n = function n() { if (gestureState.get().mode === "drag") { _ReanimatedRexport.runOnJS(callback)("drop"); } else if (gestureState.get().mode === "contextmenu") { _ReanimatedRexport.runOnJS(callback)("contextmenu-open"); } else { _ReanimatedRexport.runOnJS(callback)("cancel"); } }; n.__closure = { gestureState, runOnJS: _ReanimatedRexport.runOnJS, handleGestureEnd: callback }; n.__workletHash = 9863070264039; n.__initData = __initData8; const r109 = r100.onEnd(n); const t = function t() { _ReanimatedRexport.runOnJS(callback)("cancel"); }; t.__closure = { runOnJS: _ReanimatedRexport.runOnJS, handleGestureEnd: callback }; t.__workletHash = 9715999020978; t.__initData = __initData7; return Gesture.Simultaneous(r65, r109.onTouchesCancelled(t)); }, [dragDropInProgress, DragRegion, gestureState, callback4, callback, callback5, callback3, callback2, listInsets, scrollPosition, animatedRef, windowSize, gesture]); useEffect(() => GuildsBarDnDStore.subscribe((a0) => { L6: { const { dragSpecs: dragSpecs3, dropSpecs } = a0; if (dragSpecs3 == null && dropSpecs == null) { const current = ref.current; if (current == null) { break L6; } current.setDisableRecycling(false); } else { const current2 = ref.current; if (current2 != null) { current2.setDisableRecycling(true); } } } }), []); return { scrollPosition, gesture: memo, scrollerRef: animatedRef, fastListRef: ref, persistantKeys, onFastListScroll: callback6, onFastListScrollWorklet: externalScrollEventHandler }; };