{"ast":null,"code":"import { extractEventInfo } from '../events/event-info.mjs';\nimport { addDomEvent } from '../events/add-dom-event.mjs';\nimport { addPointerEvent } from '../events/add-pointer-event.mjs';\nimport { Feature } from '../motion/features/Feature.mjs';\nimport { pipe } from '../utils/pipe.mjs';\nimport { isDragActive } from './drag/utils/lock.mjs';\nimport { isNodeOrChild } from './utils/is-node-or-child.mjs';\nimport { noop } from '../utils/noop.mjs';\nimport { frame } from '../frameloop/frame.mjs';\nfunction fireSyntheticPointerEvent(name, handler) {\n  if (!handler) return;\n  const syntheticPointerEvent = new PointerEvent(\"pointer\" + name);\n  handler(syntheticPointerEvent, extractEventInfo(syntheticPointerEvent));\n}\nclass PressGesture extends Feature {\n  constructor() {\n    super(...arguments);\n    this.removeStartListeners = noop;\n    this.removeEndListeners = noop;\n    this.removeAccessibleListeners = noop;\n    this.startPointerPress = (startEvent, startInfo) => {\n      if (this.isPressing) return;\n      this.removeEndListeners();\n      const props = this.node.getProps();\n      const endPointerPress = (endEvent, endInfo) => {\n        if (!this.checkPressEnd()) return;\n        const {\n          onTap,\n          onTapCancel,\n          globalTapTarget\n        } = this.node.getProps();\n        frame.update(() => {\n          /**\n           * We only count this as a tap gesture if the event.target is the same\n           * as, or a child of, this component's element\n           */\n          !globalTapTarget && !isNodeOrChild(this.node.current, endEvent.target) ? onTapCancel && onTapCancel(endEvent, endInfo) : onTap && onTap(endEvent, endInfo);\n        });\n      };\n      const removePointerUpListener = addPointerEvent(window, \"pointerup\", endPointerPress, {\n        passive: !(props.onTap || props[\"onPointerUp\"])\n      });\n      const removePointerCancelListener = addPointerEvent(window, \"pointercancel\", (cancelEvent, cancelInfo) => this.cancelPress(cancelEvent, cancelInfo), {\n        passive: !(props.onTapCancel || props[\"onPointerCancel\"])\n      });\n      this.removeEndListeners = pipe(removePointerUpListener, removePointerCancelListener);\n      this.startPress(startEvent, startInfo);\n    };\n    this.startAccessiblePress = () => {\n      const handleKeydown = keydownEvent => {\n        if (keydownEvent.key !== \"Enter\" || this.isPressing) return;\n        const handleKeyup = keyupEvent => {\n          if (keyupEvent.key !== \"Enter\" || !this.checkPressEnd()) return;\n          fireSyntheticPointerEvent(\"up\", (event, info) => {\n            const {\n              onTap\n            } = this.node.getProps();\n            if (onTap) {\n              frame.update(() => onTap(event, info));\n            }\n          });\n        };\n        this.removeEndListeners();\n        this.removeEndListeners = addDomEvent(this.node.current, \"keyup\", handleKeyup);\n        fireSyntheticPointerEvent(\"down\", (event, info) => {\n          this.startPress(event, info);\n        });\n      };\n      const removeKeydownListener = addDomEvent(this.node.current, \"keydown\", handleKeydown);\n      const handleBlur = () => {\n        if (!this.isPressing) return;\n        fireSyntheticPointerEvent(\"cancel\", (cancelEvent, cancelInfo) => this.cancelPress(cancelEvent, cancelInfo));\n      };\n      const removeBlurListener = addDomEvent(this.node.current, \"blur\", handleBlur);\n      this.removeAccessibleListeners = pipe(removeKeydownListener, removeBlurListener);\n    };\n  }\n  startPress(event, info) {\n    this.isPressing = true;\n    const {\n      onTapStart,\n      whileTap\n    } = this.node.getProps();\n    /**\n     * Ensure we trigger animations before firing event callback\n     */\n    if (whileTap && this.node.animationState) {\n      this.node.animationState.setActive(\"whileTap\", true);\n    }\n    if (onTapStart) {\n      frame.update(() => onTapStart(event, info));\n    }\n  }\n  checkPressEnd() {\n    this.removeEndListeners();\n    this.isPressing = false;\n    const props = this.node.getProps();\n    if (props.whileTap && this.node.animationState) {\n      this.node.animationState.setActive(\"whileTap\", false);\n    }\n    return !isDragActive();\n  }\n  cancelPress(event, info) {\n    if (!this.checkPressEnd()) return;\n    const {\n      onTapCancel\n    } = this.node.getProps();\n    if (onTapCancel) {\n      frame.update(() => onTapCancel(event, info));\n    }\n  }\n  mount() {\n    const props = this.node.getProps();\n    const removePointerListener = addPointerEvent(props.globalTapTarget ? window : this.node.current, \"pointerdown\", this.startPointerPress, {\n      passive: !(props.onTapStart || props[\"onPointerStart\"])\n    });\n    const removeFocusListener = addDomEvent(this.node.current, \"focus\", this.startAccessiblePress);\n    this.removeStartListeners = pipe(removePointerListener, removeFocusListener);\n  }\n  unmount() {\n    this.removeStartListeners();\n    this.removeEndListeners();\n    this.removeAccessibleListeners();\n  }\n}\nexport { PressGesture };","map":{"version":3,"names":["extractEventInfo","addDomEvent","addPointerEvent","Feature","pipe","isDragActive","isNodeOrChild","noop","frame","fireSyntheticPointerEvent","name","handler","syntheticPointerEvent","PointerEvent","PressGesture","constructor","arguments","removeStartListeners","removeEndListeners","removeAccessibleListeners","startPointerPress","startEvent","startInfo","isPressing","props","node","getProps","endPointerPress","endEvent","endInfo","checkPressEnd","onTap","onTapCancel","globalTapTarget","update","current","target","removePointerUpListener","window","passive","removePointerCancelListener","cancelEvent","cancelInfo","cancelPress","startPress","startAccessiblePress","handleKeydown","keydownEvent","key","handleKeyup","keyupEvent","event","info","removeKeydownListener","handleBlur","removeBlurListener","onTapStart","whileTap","animationState","setActive","mount","removePointerListener","removeFocusListener","unmount"],"sources":["/opt/bitnami/minigames/frasle/node_modules/framer-motion/dist/es/gestures/press.mjs"],"sourcesContent":["import { extractEventInfo } from '../events/event-info.mjs';\nimport { addDomEvent } from '../events/add-dom-event.mjs';\nimport { addPointerEvent } from '../events/add-pointer-event.mjs';\nimport { Feature } from '../motion/features/Feature.mjs';\nimport { pipe } from '../utils/pipe.mjs';\nimport { isDragActive } from './drag/utils/lock.mjs';\nimport { isNodeOrChild } from './utils/is-node-or-child.mjs';\nimport { noop } from '../utils/noop.mjs';\nimport { frame } from '../frameloop/frame.mjs';\n\nfunction fireSyntheticPointerEvent(name, handler) {\n    if (!handler)\n        return;\n    const syntheticPointerEvent = new PointerEvent(\"pointer\" + name);\n    handler(syntheticPointerEvent, extractEventInfo(syntheticPointerEvent));\n}\nclass PressGesture extends Feature {\n    constructor() {\n        super(...arguments);\n        this.removeStartListeners = noop;\n        this.removeEndListeners = noop;\n        this.removeAccessibleListeners = noop;\n        this.startPointerPress = (startEvent, startInfo) => {\n            if (this.isPressing)\n                return;\n            this.removeEndListeners();\n            const props = this.node.getProps();\n            const endPointerPress = (endEvent, endInfo) => {\n                if (!this.checkPressEnd())\n                    return;\n                const { onTap, onTapCancel, globalTapTarget } = this.node.getProps();\n                frame.update(() => {\n                    /**\n                     * We only count this as a tap gesture if the event.target is the same\n                     * as, or a child of, this component's element\n                     */\n                    !globalTapTarget &&\n                        !isNodeOrChild(this.node.current, endEvent.target)\n                        ? onTapCancel && onTapCancel(endEvent, endInfo)\n                        : onTap && onTap(endEvent, endInfo);\n                });\n            };\n            const removePointerUpListener = addPointerEvent(window, \"pointerup\", endPointerPress, { passive: !(props.onTap || props[\"onPointerUp\"]) });\n            const removePointerCancelListener = addPointerEvent(window, \"pointercancel\", (cancelEvent, cancelInfo) => this.cancelPress(cancelEvent, cancelInfo), { passive: !(props.onTapCancel || props[\"onPointerCancel\"]) });\n            this.removeEndListeners = pipe(removePointerUpListener, removePointerCancelListener);\n            this.startPress(startEvent, startInfo);\n        };\n        this.startAccessiblePress = () => {\n            const handleKeydown = (keydownEvent) => {\n                if (keydownEvent.key !== \"Enter\" || this.isPressing)\n                    return;\n                const handleKeyup = (keyupEvent) => {\n                    if (keyupEvent.key !== \"Enter\" || !this.checkPressEnd())\n                        return;\n                    fireSyntheticPointerEvent(\"up\", (event, info) => {\n                        const { onTap } = this.node.getProps();\n                        if (onTap) {\n                            frame.update(() => onTap(event, info));\n                        }\n                    });\n                };\n                this.removeEndListeners();\n                this.removeEndListeners = addDomEvent(this.node.current, \"keyup\", handleKeyup);\n                fireSyntheticPointerEvent(\"down\", (event, info) => {\n                    this.startPress(event, info);\n                });\n            };\n            const removeKeydownListener = addDomEvent(this.node.current, \"keydown\", handleKeydown);\n            const handleBlur = () => {\n                if (!this.isPressing)\n                    return;\n                fireSyntheticPointerEvent(\"cancel\", (cancelEvent, cancelInfo) => this.cancelPress(cancelEvent, cancelInfo));\n            };\n            const removeBlurListener = addDomEvent(this.node.current, \"blur\", handleBlur);\n            this.removeAccessibleListeners = pipe(removeKeydownListener, removeBlurListener);\n        };\n    }\n    startPress(event, info) {\n        this.isPressing = true;\n        const { onTapStart, whileTap } = this.node.getProps();\n        /**\n         * Ensure we trigger animations before firing event callback\n         */\n        if (whileTap && this.node.animationState) {\n            this.node.animationState.setActive(\"whileTap\", true);\n        }\n        if (onTapStart) {\n            frame.update(() => onTapStart(event, info));\n        }\n    }\n    checkPressEnd() {\n        this.removeEndListeners();\n        this.isPressing = false;\n        const props = this.node.getProps();\n        if (props.whileTap && this.node.animationState) {\n            this.node.animationState.setActive(\"whileTap\", false);\n        }\n        return !isDragActive();\n    }\n    cancelPress(event, info) {\n        if (!this.checkPressEnd())\n            return;\n        const { onTapCancel } = this.node.getProps();\n        if (onTapCancel) {\n            frame.update(() => onTapCancel(event, info));\n        }\n    }\n    mount() {\n        const props = this.node.getProps();\n        const removePointerListener = addPointerEvent(props.globalTapTarget ? window : this.node.current, \"pointerdown\", this.startPointerPress, { passive: !(props.onTapStart || props[\"onPointerStart\"]) });\n        const removeFocusListener = addDomEvent(this.node.current, \"focus\", this.startAccessiblePress);\n        this.removeStartListeners = pipe(removePointerListener, removeFocusListener);\n    }\n    unmount() {\n        this.removeStartListeners();\n        this.removeEndListeners();\n        this.removeAccessibleListeners();\n    }\n}\n\nexport { PressGesture };\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,WAAW,QAAQ,6BAA6B;AACzD,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,OAAO,QAAQ,gCAAgC;AACxD,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,KAAK,QAAQ,wBAAwB;AAE9C,SAASC,yBAAyBA,CAACC,IAAI,EAAEC,OAAO,EAAE;EAC9C,IAAI,CAACA,OAAO,EACR;EACJ,MAAMC,qBAAqB,GAAG,IAAIC,YAAY,CAAC,S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