import { addPointerEvent as m } from "../../events/add-pointer-event.es.js";
import { Feature as P } from "../../motion/features/Feature.es.js";
import { getContextWindow as h } from "../../utils/get-context-window.es.js";
import { PanSession as p } from "./PanSession.es.js";
import { noop as u } from "../../../../../../../motion-utils@12.23.6/node_modules/motion-utils/dist/es/noop.es.js";
import { frame as r } from "../../../../../../../motion-dom@12.23.23/node_modules/motion-dom/dist/es/frameloop/frame.es.js";
const s = (e) => (n, o) => {
  e && r.postRender(() => e(n, o));
};
class v extends P {
  constructor() {
    super(...arguments), this.removePointerDownListener = u;
  }
  onPointerDown(n) {
    this.session = new p(n, this.createPanHandlers(), {
      transformPagePoint: this.node.getTransformPagePoint(),
      contextWindow: h(this.node)
    });
  }
  createPanHandlers() {
    const { onPanSessionStart: n, onPanStart: o, onPan: i, onPanEnd: t } = this.node.getProps();
    return {
      onSessionStart: s(n),
      onStart: s(o),
      onMove: i,
      onEnd: (a, d) => {
        delete this.session, t && r.postRender(() => t(a, d));
      }
    };
  }
  mount() {
    this.removePointerDownListener = m(this.node.current, "pointerdown", (n) => this.onPointerDown(n));
  }
  update() {
    this.session && this.session.updateHandlers(this.createPanHandlers());
  }
  unmount() {
    this.removePointerDownListener(), this.session && this.session.end();
  }
}
export {
  v as PanGesture
};
//# sourceMappingURL=index.es.js.map
