import { addPointerEvent as m } from "../../events/add-pointer-event.es.js";
import { getContextWindow as P } from "../../utils/get-context-window.es.js";
import { PanSession as h } from "./PanSession.es.js";
import { Feature as p } from "../../../../../../../motion-dom@12.38.0/node_modules/motion-dom/dist/es/render/Feature.es.js";
import { noop as u } from "../../../../../../../motion-utils@12.36.0/node_modules/motion-utils/dist/es/noop.es.js";
import { frame as r } from "../../../../../../../motion-dom@12.38.0/node_modules/motion-dom/dist/es/frameloop/frame.es.js";
const o = (e) => (n, t) => {
  e && r.update(() => e(n, t), !1, !0);
};
class v extends p {
  constructor() {
    super(...arguments), this.removePointerDownListener = u;
  }
  onPointerDown(n) {
    this.session = new h(n, this.createPanHandlers(), {
      transformPagePoint: this.node.getTransformPagePoint(),
      contextWindow: P(this.node)
    });
  }
  createPanHandlers() {
    const { onPanSessionStart: n, onPanStart: t, onPan: i, onPanEnd: s } = this.node.getProps();
    return {
      onSessionStart: o(n),
      onStart: o(t),
      onMove: o(i),
      onEnd: (a, d) => {
        delete this.session, s && r.postRender(() => s(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
