"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Feature = require("./dist-es-motion-features-Feature.cjs");
require("../motion-utils/dist-es-errors.cjs");
const index = require("../motion-dom/dist-es-gestures-press-index.cjs");
const eventInfo = require("./dist-es-events-event-info.cjs");
const frame = require("./dist-es-frameloop-frame.cjs");
function handlePressEvent(node, event, lifecycle) {
  const { props } = node;
  if (node.animationState && props.whileTap) {
    node.animationState.setActive("whileTap", lifecycle === "Start");
  }
  const eventName = "onTap" + (lifecycle === "End" ? "" : lifecycle);
  const callback = props[eventName];
  if (callback) {
    frame.frame.postRender(() => callback(event, eventInfo.extractEventInfo(event)));
  }
}
class PressGesture extends Feature.Feature {
  mount() {
    const { current } = this.node;
    if (!current)
      return;
    this.unmount = index.press(current, (startEvent) => {
      handlePressEvent(this.node, startEvent, "Start");
      return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
    }, { useGlobalTarget: this.node.props.globalTapTarget });
  }
  unmount() {
  }
}
exports.PressGesture = PressGesture;
//# sourceMappingURL=dist-es-gestures-press.cjs.map
