// Metro module 5292 (f5293). import _classCallCheck from "./_classCallCheck"; import _createClass from "./_createClass"; import _possibleConstructorReturn from "./_possibleConstructorReturn"; import _getPrototypeOf from "./_getPrototypeOf"; import _inherits from "./_inherits"; import { Children, createRef, Component, cloneElement } from "react"; import { UIManager, Platform, DeviceEventEmitter } from "react-native"; import { jsx } from "react/jsx-runtime"; import { customDirectEventTypes } from "./Module5293"; import { isFabric, isReact19, deepEqual, tagMessage, isTestEnv } from "./deepEqual"; import Module5282 from "./Module5282"; import { State } from "./Module5278"; import { getNextHandlerTag } from "./Module5294"; import { registerOldGestureHandler, handlerIDToTag, unregisterOldGestureHandler } from "./Module5276"; import { ActionType } from "./Module5295"; import { scheduleFlushOperations, filterConfig } from "./transformIntoHandlerTags"; import { ghQueueMicrotask } from "./Module5297"; import { MountRegistry } from "./MountRegistry"; import Module5299 from "./Module5299"; import Module5288 from "./Module5288"; import { HermesBuiltin } from "../_hermes/prelude"; function $mk104262() { return (a0) => a0 ? a0.current === null : a0; } let setJSResponder, clearJSResponder, c3197_12; let env3197 = {}; env3197[9] = function _isNativeReflectConstruct() { let c14783_0; try { c14783_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); } catch ($e) {} const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() { return !!c14783_0; }; env3197[9] = _isNativeReflectConstruct2; return _isNativeReflectConstruct2(); }; Platform; DeviceEventEmitter; jsx; customDirectEventTypes.topGestureHandlerEvent = { registrationName: "onGestureHandlerEvent" }; const r43 = { onGestureHandlerEvent: { registrationName: "onGestureHandlerEvent" }, onGestureHandlerStateChange: { registrationName: "onGestureHandlerStateChange" }, ...isFabric() && { topOnGestureHandlerEvent: { registrationName: "onGestureHandlerEvent" }, topOnGestureHandlerStateChange: { registrationName: "onGestureHandlerStateChange" } } }; UIManager.genericDirectEventTypes = { ...UIManager.genericDirectEventTypes, ...r43 }; const getViewManagerConfig = UIManager.getViewManagerConfig; const r62 = getViewManagerConfig == null ? void 0 : getViewManagerConfig.call(UIManager, "getConstants"); if (r62) { r62.genericDirectEventTypes = { ...r62.genericDirectEventTypes, ...r43 }; } let setJSResponder2 = UIManager.setJSResponder; if (setJSResponder2 === void 0) { setJSResponder2 = () => {}; } setJSResponder = setJSResponder2; let clearJSResponder2 = UIManager.clearJSResponder; if (clearJSResponder2 === void 0) { clearJSResponder2 = () => {}; } clearJSResponder = clearJSResponder2; UIManager.setJSResponder = (a0, a1) => { Module5282.handleSetJSResponder(a0, a1); setJSResponder(a0, a1); }; UIManager.clearJSResponder = () => { Module5282.handleClearJSResponder(); clearJSResponder(); }; const r75 = {}; r75[State.UNDETERMINED] = void 0; r75[State.BEGAN] = "onBegan"; r75[State.FAILED] = "onFailed"; r75[State.CANCELLED] = "onCancelled"; r75[State.ACTIVE] = "onActivated"; r75[State.END] = "onEnded"; c3197_12 = r75; export default function createHandler(a0) { let env14784 = { $parent: env3197 }; const name = a0.name; env14784[0] = name; let allowedProps = a0.allowedProps; if (allowedProps === void 0) { allowedProps = []; } env14784[1] = allowedProps; let config = a0.config; if (config === void 0) { config = {}; } env14784[2] = config; env14784[3] = a0.transformProps; let customNativeProps = a0.customNativeProps; if (customNativeProps === void 0) { customNativeProps = []; } env14784[4] = customNativeProps; const Handler2 = function Handler(a0) { _classCallCheck(this, Handler2); const r11 = [a0]; const r10 = _getPrototypeOf(Handler2); const r28 = _possibleConstructorReturn(this, (0, env3197[9])() ? Reflect.construct(r10, r11, _getPrototypeOf(this).constructor) : r10.apply(this, r11)); r28.handlerTag = -1; r28.onGestureHandlerEvent = (a0) => { const handlerTag = a0.nativeEvent.handlerTag; if (handlerTag === this.handlerTag) { if (typeof this.props.onGestureEvent === "function") { const props2 = this.props; const onGestureEvent = props2.onGestureEvent; if (onGestureEvent != null) { onGestureEvent.call(props2, a0); } } } else { const props = this.props; const onGestureHandlerEvent = props.onGestureHandlerEvent; if (onGestureHandlerEvent != null) { onGestureHandlerEvent.call(props, a0); } } }; r28.onGestureHandlerStateChange = (a0) => { const handlerTag = a0.nativeEvent.handlerTag; if (handlerTag === this.handlerTag) { if (typeof this.props.onHandlerStateChange === "function") { const props2 = this.props; const onHandlerStateChange = props2.onHandlerStateChange; if (onHandlerStateChange != null) { onHandlerStateChange.call(props2, a0); } } const r20 = c3197_12[a0.nativeEvent.state]; const r21 = r20 && this.props[r20]; if (r21 && typeof r21 === "function") { r21(a0); } } else { const props = this.props; const onGestureHandlerStateChange = props.onGestureHandlerStateChange; if (onGestureHandlerStateChange != null) { onGestureHandlerStateChange.call(props, a0); } } }; r28.refHandler = (a0) => { this.viewNode = a0; const r12 = Children.only(this.props.children); const r19 = isReact19() ? r12.props?.ref : r12?.ref; if (r19) { if (typeof r19 === "function") { r19(a0); } else { r19.current = a0; } } }; r28.createGestureHandler = (a0) => { this.handlerTag = getNextHandlerTag(); this.config = a0; Module5282.createGestureHandler(env14784[0], this.handlerTag, a0); }; r28.attachGestureHandler = (a0) => { let NATIVE_ANIMATED_EVENT; this.viewTag = a0; registerOldGestureHandler(this.handlerTag, { onGestureEvent: this.onGestureHandlerEvent, onGestureStateChange: this.onGestureHandlerStateChange }); const onGestureEvent = this.props?.onGestureEvent; const r20 = onGestureEvent && ("current" in onGestureEvent || "workletEventHandler" in onGestureEvent); const onHandlerStateChange = this.props?.onHandlerStateChange; L18: { L17: { if (!r20) { if (onHandlerStateChange) { if ("current" in onHandlerStateChange) { break L17; } if ("workletEventHandler" in onHandlerStateChange) { break L17; } } if (onGestureEvent && "__isNative" in onGestureEvent) { NATIVE_ANIMATED_EVENT = ActionType.NATIVE_ANIMATED_EVENT; break L18; } NATIVE_ANIMATED_EVENT = ActionType.JS_FUNCTION_OLD_API; break L18; } } NATIVE_ANIMATED_EVENT = ActionType.REANIMATED_WORKLET; } Module5282.attachGestureHandler(this.handlerTag, a0, NATIVE_ANIMATED_EVENT); scheduleFlushOperations(); ghQueueMicrotask(() => { MountRegistry.gestureHandlerWillMount(this); }); }; r28.updateGestureHandler = (a0) => { this.config = a0; Module5282.updateGestureHandler(this.handlerTag, a0); scheduleFlushOperations(); }; r28.config = {}; r28.propsRef = createRef(); r28.isMountedRef = createRef(); r28.state = { allowTouches: true }; if (a0.id) { if (handlerIDToTag[a0.id] !== void 0) { throw new Error(`Handler with ID "${a0.id}" already registered`); } handlerIDToTag[a0.id] = r28.handlerTag; } return r28; }; _inherits(Handler2, Component); const r29 = _createClass(Handler2, [{ key: "componentDidMount", value: function componentDidMount() { const props = this.props; this.isMountedRef.current = true; const simultaneousHandlers = props.simultaneousHandlers; let r19 = Array.isArray(simultaneousHandlers) ? simultaneousHandlers.some($mk104262()) : simultaneousHandlers && simultaneousHandlers.current === null; if (!r19) { const waitFor = props.waitFor; r19 = Array.isArray(waitFor) ? waitFor.some($mk104262()) : waitFor && waitFor.current === null; } if (r19) { ghQueueMicrotask(() => { this.update(1); }); } const createGestureHandler = this.createGestureHandler; const r12 = env14784[3]; const props2 = this.props; createGestureHandler.call(this, filterConfig(r12 ? r12(props2) : props2, [...env14784[1], ...env14784[4]], env14784[2])); if (this.viewNode) { this.attachGestureHandler(Module5299(this.viewNode)); return void 0; } throw new Error(`[Gesture Handler] Failed to obtain view for ${Handler2.displayName}. Note that old API doesn't support functional components.`); } }, { key: "componentDidUpdate", value: function componentDidUpdate() { const r9 = Module5299(this.viewNode); if (this.viewTag !== r9) { this.attachGestureHandler(r9); } this.update(1); } }, { key: "componentWillUnmount", value: function componentWillUnmount() { const inspectorToggleListener = this.inspectorToggleListener; if (inspectorToggleListener != null) { inspectorToggleListener.remove(); } this.isMountedRef.current = false; unregisterOldGestureHandler(this.handlerTag); Module5282.dropGestureHandler(this.handlerTag); scheduleFlushOperations(); const id = this.props.id; if (id) { delete handlerIDToTag[id]; } MountRegistry.gestureHandlerWillUnmount(this); } }, { key: "update", value: function update(a0) { let c29495_0; L21: { c29495_0 = a0; if (this.isMountedRef.current) { const props = this.props; const simultaneousHandlers = props.simultaneousHandlers; let r19 = Array.isArray(simultaneousHandlers) ? simultaneousHandlers.some($mk104262()) : simultaneousHandlers && simultaneousHandlers.current === null; if (!r19) { const waitFor = props.waitFor; r19 = Array.isArray(waitFor) ? waitFor.some($mk104262()) : waitFor && waitFor.current === null; } if (r19 && a0 > 0) { ghQueueMicrotask(() => { this.update(c29495_0 - 1); }); break L21; } const r12 = env14784[3]; const props2 = this.props; const r48 = filterConfig(r12 ? r12(props2) : props2, [...env14784[1], ...env14784[4]], env14784[2]); if (!deepEqual(this.config, r48)) { this.updateGestureHandler(r48); } } } } }, { key: "setNativeProps", value: function setNativeProps(a0) { const r8 = { ...this.props, ...a0 }; const r18 = env14784[3]; this.updateGestureHandler(filterConfig(r18 ? r18(r8) : r8, [...env14784[1], ...env14784[4]], env14784[2])); } }, { key: "render", value: function render() { let r2, r26, r48; const onGestureHandlerEvent = this.onGestureHandlerEvent; const props = this.props; const { onGestureEvent, onGestureHandlerEvent: onGestureHandlerEvent2 } = props; if (onGestureEvent && typeof onGestureEvent !== "function") { r2 = onGestureEvent; if (onGestureHandlerEvent2) { throw new Error("Nesting touch handlers with native animated driver is not supported yet"); } } else { r2 = onGestureHandlerEvent; if (onGestureHandlerEvent2) { r2 = onGestureHandlerEvent; if (typeof onGestureHandlerEvent2 !== "function") { throw new Error("Nesting touch handlers with native animated driver is not supported yet"); } } } const onGestureHandlerStateChange = this.onGestureHandlerStateChange; const props2 = this.props; const { onHandlerStateChange, onGestureHandlerStateChange: onGestureHandlerStateChange2 } = props2; if (onHandlerStateChange && typeof onHandlerStateChange !== "function") { r26 = onHandlerStateChange; if (onGestureHandlerStateChange2) { throw new Error("Nesting touch handlers with native animated driver is not supported yet"); } } else { r26 = onGestureHandlerStateChange; if (onGestureHandlerStateChange2) { r26 = onGestureHandlerStateChange; if (typeof onGestureHandlerStateChange2 !== "function") { throw new Error("Nesting touch handlers with native animated driver is not supported yet"); } } } const current = { onGestureHandlerEvent: this.state.allowTouches ? r2 : void 0, onGestureHandlerStateChange: this.state.allowTouches ? r26 : void 0 }; this.propsRef.current = current; try { r48 = Children.only(this.props.children); } catch ($e) { throw new Error(tagMessage(`${env14784[0]} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`)); } const r49 = r48; const children = r49.props.children; const r53 = { ref: this.refHandler, collapsable: false, ...isTestEnv() ? { handlerType: env14784[0], handlerTag: this.handlerTag, enabled: this.props.enabled } : {} }; let testID = this.props.testID; if (testID == null) { testID = r48.props.testID; } r53.testID = testID; HermesBuiltin.copyDataProperties(r53, current); return cloneElement(r49, r53, children); } }]); r29.displayName = name; r29.contextType = Module5288; return r29; };