import { V as a, c as et } from "./index-maths-0ab39ae9.esm.js";
function st(s, t) {
  if (typeof s != "object" || s === null) return s;
  var e = s[Symbol.toPrimitive];
  if (e !== void 0) {
    var i = e.call(s, t);
    if (typeof i != "object") return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (t === "string" ? String : Number)(s);
}
function it(s) {
  var t = st(s, "string");
  return typeof t == "symbol" ? t : String(t);
}
function f(s, t, e) {
  return t = it(t), t in s ? Object.defineProperty(s, t, {
    value: e,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : s[t] = e, s;
}
function P(s, t) {
  var e = Object.keys(s);
  if (Object.getOwnPropertySymbols) {
    var i = Object.getOwnPropertySymbols(s);
    t && (i = i.filter(function(n) {
      return Object.getOwnPropertyDescriptor(s, n).enumerable;
    })), e.push.apply(e, i);
  }
  return e;
}
function u(s) {
  for (var t = 1; t < arguments.length; t++) {
    var e = arguments[t] != null ? arguments[t] : {};
    t % 2 ? P(Object(e), !0).forEach(function(i) {
      f(s, i, e[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(e)) : P(Object(e)).forEach(function(i) {
      Object.defineProperty(s, i, Object.getOwnPropertyDescriptor(e, i));
    });
  }
  return s;
}
const H = {
  pointer: {
    start: "down",
    change: "move",
    end: "up"
  },
  mouse: {
    start: "down",
    change: "move",
    end: "up"
  },
  touch: {
    start: "start",
    change: "move",
    end: "end"
  },
  gesture: {
    start: "start",
    change: "change",
    end: "end"
  }
};
function M(s) {
  return s ? s[0].toUpperCase() + s.slice(1) : "";
}
const nt = ["enter", "leave"];
function rt(s = !1, t) {
  return s && !nt.includes(t);
}
function jt(s, t = "", e = !1) {
  const i = H[s], n = i && i[t] || t;
  return "on" + M(s) + M(n) + (rt(e, n) ? "Capture" : "");
}
const ot = ["gotpointercapture", "lostpointercapture"];
function Ht(s) {
  let t = s.substring(2).toLowerCase();
  const e = !!~t.indexOf("passive");
  e && (t = t.replace("passive", ""));
  const i = ot.includes(t) ? "capturecapture" : "capture", n = !!~t.indexOf(i);
  return n && (t = t.replace("capture", "")), {
    device: t,
    capture: n,
    passive: e
  };
}
function Xt(s, t = "") {
  const e = H[s], i = e && e[t] || t;
  return s + i;
}
function C(s) {
  return "touches" in s;
}
function X(s) {
  return C(s) ? "touch" : "pointerType" in s ? s.pointerType : "mouse";
}
function at(s) {
  return Array.from(s.touches).filter((t) => {
    var e, i;
    return t.target === s.currentTarget || ((e = s.currentTarget) === null || e === void 0 || (i = e.contains) === null || i === void 0 ? void 0 : i.call(e, t.target));
  });
}
function ct(s) {
  return s.type === "touchend" || s.type === "touchcancel" ? s.changedTouches : s.targetTouches;
}
function W(s) {
  return C(s) ? ct(s)[0] : s;
}
function k(s, t) {
  try {
    const e = t.clientX - s.clientX, i = t.clientY - s.clientY, n = (t.clientX + s.clientX) / 2, r = (t.clientY + s.clientY) / 2, o = Math.hypot(e, i);
    return {
      angle: -(Math.atan2(e, i) * 180) / Math.PI,
      distance: o,
      origin: [n, r]
    };
  } catch {
  }
  return null;
}
function Wt(s) {
  return at(s).map((t) => t.identifier);
}
function L(s, t) {
  const [e, i] = Array.from(s.touches).filter((n) => t.includes(n.identifier));
  return k(e, i);
}
function x(s) {
  const t = W(s);
  return C(s) ? t.identifier : t.pointerId;
}
function _(s) {
  const t = W(s);
  return [t.clientX, t.clientY];
}
const N = 40, V = 800;
function z(s) {
  let {
    deltaX: t,
    deltaY: e,
    deltaMode: i
  } = s;
  return i === 1 ? (t *= N, e *= N) : i === 2 && (t *= V, e *= V), [t, e];
}
function ut(s) {
  var t, e;
  const {
    scrollX: i,
    scrollY: n,
    scrollLeft: r,
    scrollTop: o
  } = s.currentTarget;
  return [(t = i ?? r) !== null && t !== void 0 ? t : 0, (e = n ?? o) !== null && e !== void 0 ? e : 0];
}
function ht(s) {
  const t = {};
  if ("buttons" in s && (t.buttons = s.buttons), "shiftKey" in s) {
    const {
      shiftKey: e,
      altKey: i,
      metaKey: n,
      ctrlKey: r
    } = s;
    Object.assign(t, {
      shiftKey: e,
      altKey: i,
      metaKey: n,
      ctrlKey: r
    });
  }
  return t;
}
function A(s, ...t) {
  return typeof s == "function" ? s(...t) : s;
}
function lt() {
}
function zt(...s) {
  return s.length === 0 ? lt : s.length === 1 ? s[0] : function() {
    let t;
    for (const e of s)
      t = e.apply(this, arguments) || t;
    return t;
  };
}
function K(s, t) {
  return Object.assign({}, t, s || {});
}
const ft = 32;
class G {
  constructor(t, e, i) {
    this.ctrl = t, this.args = e, this.key = i, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
  }
  get state() {
    return this.ctrl.state[this.key];
  }
  set state(t) {
    this.ctrl.state[this.key] = t;
  }
  get shared() {
    return this.ctrl.state.shared;
  }
  get eventStore() {
    return this.ctrl.gestureEventStores[this.key];
  }
  get timeoutStore() {
    return this.ctrl.gestureTimeoutStores[this.key];
  }
  get config() {
    return this.ctrl.config[this.key];
  }
  get sharedConfig() {
    return this.ctrl.config.shared;
  }
  get handler() {
    return this.ctrl.handlers[this.key];
  }
  reset() {
    const {
      state: t,
      shared: e,
      ingKey: i,
      args: n
    } = this;
    e[i] = t._active = t.active = t._blocked = t._force = !1, t._step = [!1, !1], t.intentional = !1, t._movement = [0, 0], t._distance = [0, 0], t._direction = [0, 0], t._delta = [0, 0], t._bounds = [[-1 / 0, 1 / 0], [-1 / 0, 1 / 0]], t.args = n, t.axis = void 0, t.memo = void 0, t.elapsedTime = t.timeDelta = 0, t.direction = [0, 0], t.distance = [0, 0], t.overflow = [0, 0], t._movementBound = [!1, !1], t.velocity = [0, 0], t.movement = [0, 0], t.delta = [0, 0], t.timeStamp = 0;
  }
  start(t) {
    const e = this.state, i = this.config;
    e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = i.from ? A(i.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
  }
  computeValues(t) {
    const e = this.state;
    e._values = t, e.values = this.config.transform(t);
  }
  computeInitial() {
    const t = this.state;
    t._initial = t._values, t.initial = t.values;
  }
  compute(t) {
    const {
      state: e,
      config: i,
      shared: n
    } = this;
    e.args = this.args;
    let r = 0;
    if (t && (e.event = t, i.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, n.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, n.locked = !!document.pointerLockElement, Object.assign(n, ht(t)), n.down = n.pressed = n.buttons % 2 === 1 || n.touches > 0, r = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
      const m = e._delta.map(Math.abs);
      a.addTo(e._distance, m);
    }
    this.axisIntent && this.axisIntent(t);
    const [o, h] = e._movement, [p, v] = i.threshold, {
      _step: c,
      values: y
    } = e;
    if (i.hasCustomTransform ? (c[0] === !1 && (c[0] = Math.abs(o) >= p && y[0]), c[1] === !1 && (c[1] = Math.abs(h) >= v && y[1])) : (c[0] === !1 && (c[0] = Math.abs(o) >= p && Math.sign(o) * p), c[1] === !1 && (c[1] = Math.abs(h) >= v && Math.sign(h) * v)), e.intentional = c[0] !== !1 || c[1] !== !1, !e.intentional) return;
    const d = [0, 0];
    if (i.hasCustomTransform) {
      const [m, tt] = y;
      d[0] = c[0] !== !1 ? m - c[0] : 0, d[1] = c[1] !== !1 ? tt - c[1] : 0;
    } else
      d[0] = c[0] !== !1 ? o - c[0] : 0, d[1] = c[1] !== !1 ? h - c[1] : 0;
    this.restrictToAxis && !e._blocked && this.restrictToAxis(d);
    const w = e.offset, T = e._active && !e._blocked || e.active;
    T && (e.first = e._active && !e.active, e.last = !e._active && e.active, e.active = n[this.ingKey] = e._active, t && (e.first && ("bounds" in i && (e._bounds = A(i.bounds, e)), this.setup && this.setup()), e.movement = d, this.computeOffset()));
    const [D, I] = e.offset, [[S, F], [J, Q]] = e._bounds;
    e.overflow = [D < S ? -1 : D > F ? 1 : 0, I < J ? -1 : I > Q ? 1 : 0], e._movementBound[0] = e.overflow[0] ? e._movementBound[0] === !1 ? e._movement[0] : e._movementBound[0] : !1, e._movementBound[1] = e.overflow[1] ? e._movementBound[1] === !1 ? e._movement[1] : e._movementBound[1] : !1;
    const Z = e._active ? i.rubberband || [0, 0] : [0, 0];
    if (e.offset = et(e._bounds, e.offset, Z), e.delta = a.sub(e.offset, w), this.computeMovement(), T && (!e.last || r > ft)) {
      e.delta = a.sub(e.offset, w);
      const m = e.delta.map(Math.abs);
      a.addTo(e.distance, m), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && r > 0 && (e.velocity = [m[0] / r, m[1] / r], e.timeDelta = r);
    }
  }
  emit() {
    const t = this.state, e = this.shared, i = this.config;
    if (t._active || this.clean(), (t._blocked || !t.intentional) && !t._force && !i.triggerAllEvents) return;
    const n = this.handler(u(u(u({}, e), t), {}, {
      [this.aliasKey]: t.values
    }));
    n !== void 0 && (t.memo = n);
  }
  clean() {
    this.eventStore.clean(), this.timeoutStore.clean();
  }
}
function dt([s, t], e) {
  const i = Math.abs(s), n = Math.abs(t);
  if (i > n && i > e)
    return "x";
  if (n > i && n > e)
    return "y";
}
class b extends G {
  constructor(...t) {
    super(...t), f(this, "aliasKey", "xy");
  }
  reset() {
    super.reset(), this.state.axis = void 0;
  }
  init() {
    this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
  }
  computeOffset() {
    this.state.offset = a.add(this.state.lastOffset, this.state.movement);
  }
  computeMovement() {
    this.state.movement = a.sub(this.state.offset, this.state.lastOffset);
  }
  axisIntent(t) {
    const e = this.state, i = this.config;
    if (!e.axis && t) {
      const n = typeof i.axisThreshold == "object" ? i.axisThreshold[X(t)] : i.axisThreshold;
      e.axis = dt(e._movement, n);
    }
    e._blocked = (i.lockDirection || !!i.axis) && !e.axis || !!i.axis && i.axis !== e.axis;
  }
  restrictToAxis(t) {
    if (this.config.axis || this.config.lockDirection)
      switch (this.state.axis) {
        case "x":
          t[1] = 0;
          break;
        case "y":
          t[0] = 0;
          break;
      }
  }
}
const R = (s) => s, U = 0.15, O = {
  enabled(s = !0) {
    return s;
  },
  eventOptions(s, t, e) {
    return u(u({}, e.shared.eventOptions), s);
  },
  preventDefault(s = !1) {
    return s;
  },
  triggerAllEvents(s = !1) {
    return s;
  },
  rubberband(s = 0) {
    switch (s) {
      case !0:
        return [U, U];
      case !1:
        return [0, 0];
      default:
        return a.toVector(s);
    }
  },
  from(s) {
    if (typeof s == "function") return s;
    if (s != null) return a.toVector(s);
  },
  transform(s, t, e) {
    const i = s || e.shared.transform;
    if (this.hasCustomTransform = !!i, process.env.NODE_ENV === "development") {
      const n = i || R;
      return (r) => {
        const o = n(r);
        return !isFinite(o[0]) || isFinite(o[1]), o;
      };
    }
    return i || R;
  },
  threshold(s) {
    return a.toVector(s, 0);
  }
};
process.env.NODE_ENV === "development" && Object.assign(O, {
  domTarget(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
    return NaN;
  },
  lockDirection(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");
    return NaN;
  },
  initial(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");
    return NaN;
  }
});
const pt = 0, g = u(u({}, O), {}, {
  axis(s, t, {
    axis: e
  }) {
    if (this.lockDirection = e === "lock", !this.lockDirection) return e;
  },
  axisThreshold(s = pt) {
    return s;
  },
  bounds(s = {}) {
    if (typeof s == "function")
      return (r) => g.bounds(s(r));
    if ("current" in s)
      return () => s.current;
    if (typeof HTMLElement == "function" && s instanceof HTMLElement)
      return s;
    const {
      left: t = -1 / 0,
      right: e = 1 / 0,
      top: i = -1 / 0,
      bottom: n = 1 / 0
    } = s;
    return [[t, e], [i, n]];
  }
}), B = {
  ArrowRight: (s, t = 1) => [s * t, 0],
  ArrowLeft: (s, t = 1) => [-1 * s * t, 0],
  ArrowUp: (s, t = 1) => [0, -1 * s * t],
  ArrowDown: (s, t = 1) => [0, s * t]
};
class mt extends b {
  constructor(...t) {
    super(...t), f(this, "ingKey", "dragging");
  }
  reset() {
    super.reset();
    const t = this.state;
    t._pointerId = void 0, t._pointerActive = !1, t._keyboardActive = !1, t._preventScroll = !1, t._delayed = !1, t.swipe = [0, 0], t.tap = !1, t.canceled = !1, t.cancel = this.cancel.bind(this);
  }
  setup() {
    const t = this.state;
    if (t._bounds instanceof HTMLElement) {
      const e = t._bounds.getBoundingClientRect(), i = t.currentTarget.getBoundingClientRect(), n = {
        left: e.left - i.left + t.offset[0],
        right: e.right - i.right + t.offset[0],
        top: e.top - i.top + t.offset[1],
        bottom: e.bottom - i.bottom + t.offset[1]
      };
      t._bounds = g.bounds(n);
    }
  }
  cancel() {
    const t = this.state;
    t.canceled || (t.canceled = !0, t._active = !1, setTimeout(() => {
      this.compute(), this.emit();
    }, 0));
  }
  setActive() {
    this.state._active = this.state._pointerActive || this.state._keyboardActive;
  }
  clean() {
    this.pointerClean(), this.state._pointerActive = !1, this.state._keyboardActive = !1, super.clean();
  }
  pointerDown(t) {
    const e = this.config, i = this.state;
    if (t.buttons != null && (Array.isArray(e.pointerButtons) ? !e.pointerButtons.includes(t.buttons) : e.pointerButtons !== -1 && e.pointerButtons !== t.buttons)) return;
    const n = this.ctrl.setEventIds(t);
    e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(n && n.size > 1 && i._pointerActive) && (this.start(t), this.setupPointer(t), i._pointerId = x(t), i._pointerActive = !0, this.computeValues(_(t)), this.computeInitial(), e.preventScrollAxis && X(t) !== "mouse" ? (i._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
  }
  startPointerDrag(t) {
    const e = this.state;
    e._active = !0, e._preventScroll = !0, e._delayed = !1, this.compute(t), this.emit();
  }
  pointerMove(t) {
    const e = this.state, i = this.config;
    if (!e._pointerActive || e.type === t.type && t.timeStamp === e.timeStamp) return;
    const n = x(t);
    if (e._pointerId !== void 0 && n !== e._pointerId) return;
    const r = _(t);
    if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = a.sub(r, e._values), this.computeValues(r)), a.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
      this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
      return;
    }
    if (i.preventScrollAxis && !e._preventScroll)
      if (e.axis)
        if (e.axis === i.preventScrollAxis || i.preventScrollAxis === "xy") {
          e._active = !1, this.clean();
          return;
        } else {
          this.timeoutStore.remove("startPointerDrag"), this.startPointerDrag(t);
          return;
        }
      else
        return;
    this.emit();
  }
  pointerUp(t) {
    this.ctrl.setEventIds(t);
    try {
      this.config.pointerCapture && t.target.hasPointerCapture(t.pointerId) && t.target.releasePointerCapture(t.pointerId);
    } catch {
      process.env.NODE_ENV;
    }
    const e = this.state, i = this.config;
    if (!e._active || !e._pointerActive) return;
    const n = x(t);
    if (e._pointerId !== void 0 && n !== e._pointerId) return;
    this.state._pointerActive = !1, this.setActive(), this.compute(t);
    const [r, o] = e._distance;
    if (e.tap = r <= i.tapsThreshold && o <= i.tapsThreshold, e.tap && i.filterTaps)
      e._force = !0;
    else {
      const [h, p] = e._delta, [v, c] = e._movement, [y, d] = i.swipe.velocity, [w, T] = i.swipe.distance, D = i.swipe.duration;
      if (e.elapsedTime < D) {
        const I = Math.abs(h / e.timeDelta), S = Math.abs(p / e.timeDelta);
        I > y && Math.abs(v) > w && (e.swipe[0] = Math.sign(h)), S > d && Math.abs(c) > T && (e.swipe[1] = Math.sign(p));
      }
    }
    this.emit();
  }
  pointerClick(t) {
    !this.state.tap && t.detail > 0 && (t.preventDefault(), t.stopPropagation());
  }
  setupPointer(t) {
    const e = this.config, i = e.device;
    if (process.env.NODE_ENV === "development")
      try {
        if (i === "pointer" && e.preventScrollDelay === void 0) {
          const n = "uv" in t ? t.sourceEvent.currentTarget : t.currentTarget;
          window.getComputedStyle(n).touchAction;
        }
      } catch {
      }
    e.pointerLock && t.currentTarget.requestPointerLock(), e.pointerCapture || (this.eventStore.add(this.sharedConfig.window, i, "change", this.pointerMove.bind(this)), this.eventStore.add(this.sharedConfig.window, i, "end", this.pointerUp.bind(this)), this.eventStore.add(this.sharedConfig.window, i, "cancel", this.pointerUp.bind(this)));
  }
  pointerClean() {
    this.config.pointerLock && document.pointerLockElement === this.state.currentTarget && document.exitPointerLock();
  }
  preventScroll(t) {
    this.state._preventScroll && t.cancelable && t.preventDefault();
  }
  setupScrollPrevention(t) {
    this.state._preventScroll = !1, gt(t);
    const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
      passive: !1
    });
    this.eventStore.add(this.sharedConfig.window, "touch", "end", e), this.eventStore.add(this.sharedConfig.window, "touch", "cancel", e), this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, t);
  }
  setupDelayTrigger(t) {
    this.state._delayed = !0, this.timeoutStore.add("dragDelay", () => {
      this.state._step = [0, 0], this.startPointerDrag(t);
    }, this.config.delay);
  }
  keyDown(t) {
    const e = B[t.key];
    if (e) {
      const i = this.state, n = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
      this.start(t), i._delta = e(this.config.keyboardDisplacement, n), i._keyboardActive = !0, a.addTo(i._movement, i._delta), this.compute(t), this.emit();
    }
  }
  keyUp(t) {
    t.key in B && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
  }
  bind(t) {
    const e = this.config.device;
    t(e, "start", this.pointerDown.bind(this)), this.config.pointerCapture && (t(e, "change", this.pointerMove.bind(this)), t(e, "end", this.pointerUp.bind(this)), t(e, "cancel", this.pointerUp.bind(this)), t("lostPointerCapture", "", this.pointerUp.bind(this))), this.config.keys && (t("key", "down", this.keyDown.bind(this)), t("key", "up", this.keyUp.bind(this))), this.config.filterTaps && t("click", "", this.pointerClick.bind(this), {
      capture: !0,
      passive: !1
    });
  }
}
function gt(s) {
  "persist" in s && typeof s.persist == "function" && s.persist();
}
const E = typeof window < "u" && window.document && window.document.createElement;
function _t() {
  return E && "ontouchstart" in window;
}
function Y() {
  return _t() || E && window.navigator.maxTouchPoints > 1;
}
function vt() {
  return E && "onpointerdown" in window;
}
function yt() {
  return E && "exitPointerLock" in window.document;
}
function bt() {
  try {
    return "constructor" in GestureEvent;
  } catch {
    return !1;
  }
}
const l = {
  isBrowser: E,
  gesture: bt(),
  touch: Y(),
  touchscreen: Y(),
  pointer: vt(),
  pointerLock: yt()
}, Et = 250, wt = 180, Tt = 0.5, Dt = 50, It = 250, At = 10, j = {
  mouse: 0,
  touch: 0,
  pen: 8
}, $ = u(u({}, g), {}, {
  device(s, t, {
    pointer: {
      touch: e = !1,
      lock: i = !1,
      mouse: n = !1
    } = {}
  }) {
    return this.pointerLock = i && l.pointerLock, l.touch && e ? "touch" : this.pointerLock ? "mouse" : l.pointer && !n ? "pointer" : l.touch ? "touch" : "mouse";
  },
  preventScrollAxis(s, t, {
    preventScroll: e
  }) {
    if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && s ? Et : void 0, !(!l.touchscreen || e === !1))
      return s || (e !== void 0 ? "y" : void 0);
  },
  pointerCapture(s, t, {
    pointer: {
      capture: e = !0,
      buttons: i = 1,
      keys: n = !0
    } = {}
  }) {
    return this.pointerButtons = i, this.keys = n, !this.pointerLock && this.device === "pointer" && e;
  },
  threshold(s, t, {
    filterTaps: e = !1,
    tapsThreshold: i = 3,
    axis: n = void 0
  }) {
    const r = a.toVector(s, e ? i : n ? 1 : 0);
    return this.filterTaps = e, this.tapsThreshold = i, r;
  },
  swipe({
    velocity: s = Tt,
    distance: t = Dt,
    duration: e = It
  } = {}) {
    return {
      velocity: this.transform(a.toVector(s)),
      distance: this.transform(a.toVector(t)),
      duration: e
    };
  },
  delay(s = 0) {
    switch (s) {
      case !0:
        return wt;
      case !1:
        return 0;
      default:
        return s;
    }
  },
  axisThreshold(s) {
    return s ? u(u({}, j), s) : j;
  },
  keyboardDisplacement(s = At) {
    return s;
  }
});
process.env.NODE_ENV === "development" && Object.assign($, {
  useTouch(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
    return NaN;
  },
  experimental_preventWindowScrollY(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");
    return NaN;
  },
  swipeVelocity(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");
    return NaN;
  },
  swipeDistance(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");
    return NaN;
  },
  swipeDuration(s) {
    if (s !== void 0)
      throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");
    return NaN;
  }
});
function q(s) {
  const [t, e] = s.overflow, [i, n] = s._delta, [r, o] = s._direction;
  (t < 0 && i > 0 && r < 0 || t > 0 && i < 0 && r > 0) && (s._movement[0] = s._movementBound[0]), (e < 0 && n > 0 && o < 0 || e > 0 && n < 0 && o > 0) && (s._movement[1] = s._movementBound[1]);
}
const St = 30, xt = 100;
class kt extends G {
  constructor(...t) {
    super(...t), f(this, "ingKey", "pinching"), f(this, "aliasKey", "da");
  }
  init() {
    this.state.offset = [1, 0], this.state.lastOffset = [1, 0], this.state._pointerEvents = /* @__PURE__ */ new Map();
  }
  reset() {
    super.reset();
    const t = this.state;
    t._touchIds = [], t.canceled = !1, t.cancel = this.cancel.bind(this), t.turns = 0;
  }
  computeOffset() {
    const {
      type: t,
      movement: e,
      lastOffset: i
    } = this.state;
    t === "wheel" ? this.state.offset = a.add(e, i) : this.state.offset = [(1 + e[0]) * i[0], e[1] + i[1]];
  }
  computeMovement() {
    const {
      offset: t,
      lastOffset: e
    } = this.state;
    this.state.movement = [t[0] / e[0], t[1] - e[1]];
  }
  axisIntent() {
    const t = this.state, [e, i] = t._movement;
    if (!t.axis) {
      const n = Math.abs(e) * St - Math.abs(i);
      n < 0 ? t.axis = "angle" : n > 0 && (t.axis = "scale");
    }
  }
  restrictToAxis(t) {
    this.config.lockDirection && (this.state.axis === "scale" ? t[1] = 0 : this.state.axis === "angle" && (t[0] = 0));
  }
  cancel() {
    const t = this.state;
    t.canceled || setTimeout(() => {
      t.canceled = !0, t._active = !1, this.compute(), this.emit();
    }, 0);
  }
  touchStart(t) {
    this.ctrl.setEventIds(t);
    const e = this.state, i = this.ctrl.touchIds;
    if (e._active && e._touchIds.every((r) => i.has(r)) || i.size < 2) return;
    this.start(t), e._touchIds = Array.from(i).slice(0, 2);
    const n = L(t, e._touchIds);
    n && this.pinchStart(t, n);
  }
  pointerStart(t) {
    if (t.buttons != null && t.buttons % 2 !== 1) return;
    this.ctrl.setEventIds(t), t.target.setPointerCapture(t.pointerId);
    const e = this.state, i = e._pointerEvents, n = this.ctrl.pointerIds;
    if (e._active && Array.from(i.keys()).every((o) => n.has(o)) || (i.size < 2 && i.set(t.pointerId, t), e._pointerEvents.size < 2)) return;
    this.start(t);
    const r = k(...Array.from(i.values()));
    r && this.pinchStart(t, r);
  }
  pinchStart(t, e) {
    const i = this.state;
    i.origin = e.origin, this.computeValues([e.distance, e.angle]), this.computeInitial(), this.compute(t), this.emit();
  }
  touchMove(t) {
    if (!this.state._active) return;
    const e = L(t, this.state._touchIds);
    e && this.pinchMove(t, e);
  }
  pointerMove(t) {
    const e = this.state._pointerEvents;
    if (e.has(t.pointerId) && e.set(t.pointerId, t), !this.state._active) return;
    const i = k(...Array.from(e.values()));
    i && this.pinchMove(t, i);
  }
  pinchMove(t, e) {
    const i = this.state, n = i._values[1], r = e.angle - n;
    let o = 0;
    Math.abs(r) > 270 && (o += Math.sign(r)), this.computeValues([e.distance, e.angle - 360 * o]), i.origin = e.origin, i.turns = o, i._movement = [i._values[0] / i._initial[0] - 1, i._values[1] - i._initial[1]], this.compute(t), this.emit();
  }
  touchEnd(t) {
    this.ctrl.setEventIds(t), this.state._active && this.state._touchIds.some((e) => !this.ctrl.touchIds.has(e)) && (this.state._active = !1, this.compute(t), this.emit());
  }
  pointerEnd(t) {
    const e = this.state;
    this.ctrl.setEventIds(t);
    try {
      t.target.releasePointerCapture(t.pointerId);
    } catch {
    }
    e._pointerEvents.has(t.pointerId) && e._pointerEvents.delete(t.pointerId), e._active && e._pointerEvents.size < 2 && (e._active = !1, this.compute(t), this.emit());
  }
  gestureStart(t) {
    t.cancelable && t.preventDefault();
    const e = this.state;
    e._active || (this.start(t), this.computeValues([t.scale, t.rotation]), e.origin = [t.clientX, t.clientY], this.compute(t), this.emit());
  }
  gestureMove(t) {
    if (t.cancelable && t.preventDefault(), !this.state._active) return;
    const e = this.state;
    this.computeValues([t.scale, t.rotation]), e.origin = [t.clientX, t.clientY];
    const i = e._movement;
    e._movement = [t.scale - 1, t.rotation], e._delta = a.sub(e._movement, i), this.compute(t), this.emit();
  }
  gestureEnd(t) {
    this.state._active && (this.state._active = !1, this.compute(t), this.emit());
  }
  wheel(t) {
    const e = this.config.modifierKey;
    e && !t[e] || (this.state._active ? this.wheelChange(t) : this.wheelStart(t), this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this)));
  }
  wheelStart(t) {
    this.start(t), this.wheelChange(t);
  }
  wheelChange(t) {
    "uv" in t || (t.cancelable && t.preventDefault(), process.env.NODE_ENV === "development" && t.defaultPrevented);
    const i = this.state;
    i._delta = [-z(t)[1] / xt * i.offset[0], 0], a.addTo(i._movement, i._delta), q(i), this.state.origin = [t.clientX, t.clientY], this.compute(t), this.emit();
  }
  wheelEnd() {
    this.state._active && (this.state._active = !1, this.compute(), this.emit());
  }
  bind(t) {
    const e = this.config.device;
    e && (t(e, "start", this[e + "Start"].bind(this)), t(e, "change", this[e + "Move"].bind(this)), t(e, "end", this[e + "End"].bind(this)), t(e, "cancel", this[e + "End"].bind(this))), this.config.pinchOnWheel && t("wheel", "", this.wheel.bind(this), {
      passive: !1
    });
  }
}
const Ct = u(u({}, O), {}, {
  device(s, t, {
    shared: e,
    pointer: {
      touch: i = !1
    } = {}
  }) {
    if (e.target && !l.touch && l.gesture) return "gesture";
    if (l.touch && i) return "touch";
    if (l.touchscreen) {
      if (l.pointer) return "pointer";
      if (l.touch) return "touch";
    }
  },
  bounds(s, t, {
    scaleBounds: e = {},
    angleBounds: i = {}
  }) {
    const n = (o) => {
      const h = K(A(e, o), {
        min: -1 / 0,
        max: 1 / 0
      });
      return [h.min, h.max];
    }, r = (o) => {
      const h = K(A(i, o), {
        min: -1 / 0,
        max: 1 / 0
      });
      return [h.min, h.max];
    };
    return typeof e != "function" && typeof i != "function" ? [n(), r()] : (o) => [n(o), r(o)];
  },
  threshold(s, t, e) {
    return this.lockDirection = e.axis === "lock", a.toVector(s, this.lockDirection ? [0.1, 3] : 0);
  },
  modifierKey(s) {
    return s === void 0 ? "ctrlKey" : s;
  },
  pinchOnWheel(s = !0) {
    return s;
  }
});
class Ot extends b {
  constructor(...t) {
    super(...t), f(this, "ingKey", "moving");
  }
  move(t) {
    this.config.mouseOnly && t.pointerType !== "mouse" || (this.state._active ? this.moveChange(t) : this.moveStart(t), this.timeoutStore.add("moveEnd", this.moveEnd.bind(this)));
  }
  moveStart(t) {
    this.start(t), this.computeValues(_(t)), this.compute(t), this.computeInitial(), this.emit();
  }
  moveChange(t) {
    if (!this.state._active) return;
    const e = _(t), i = this.state;
    i._delta = a.sub(e, i._values), a.addTo(i._movement, i._delta), this.computeValues(e), this.compute(t), this.emit();
  }
  moveEnd(t) {
    this.state._active && (this.state._active = !1, this.compute(t), this.emit());
  }
  bind(t) {
    t("pointer", "change", this.move.bind(this)), t("pointer", "leave", this.moveEnd.bind(this));
  }
}
const Pt = u(u({}, g), {}, {
  mouseOnly: (s = !0) => s
});
class Mt extends b {
  constructor(...t) {
    super(...t), f(this, "ingKey", "scrolling");
  }
  scroll(t) {
    this.state._active || this.start(t), this.scrollChange(t), this.timeoutStore.add("scrollEnd", this.scrollEnd.bind(this));
  }
  scrollChange(t) {
    t.cancelable && t.preventDefault();
    const e = this.state, i = ut(t);
    e._delta = a.sub(i, e._values), a.addTo(e._movement, e._delta), this.computeValues(i), this.compute(t), this.emit();
  }
  scrollEnd() {
    this.state._active && (this.state._active = !1, this.compute(), this.emit());
  }
  bind(t) {
    t("scroll", "", this.scroll.bind(this));
  }
}
const Lt = g;
class Nt extends b {
  constructor(...t) {
    super(...t), f(this, "ingKey", "wheeling");
  }
  wheel(t) {
    this.state._active || this.start(t), this.wheelChange(t), this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this));
  }
  wheelChange(t) {
    const e = this.state;
    e._delta = z(t), a.addTo(e._movement, e._delta), q(e), this.compute(t), this.emit();
  }
  wheelEnd() {
    this.state._active && (this.state._active = !1, this.compute(), this.emit());
  }
  bind(t) {
    t("wheel", "", this.wheel.bind(this));
  }
}
const Vt = g;
class Kt extends b {
  constructor(...t) {
    super(...t), f(this, "ingKey", "hovering");
  }
  enter(t) {
    this.config.mouseOnly && t.pointerType !== "mouse" || (this.start(t), this.computeValues(_(t)), this.compute(t), this.emit());
  }
  leave(t) {
    if (this.config.mouseOnly && t.pointerType !== "mouse") return;
    const e = this.state;
    if (!e._active) return;
    e._active = !1;
    const i = _(t);
    e._movement = e._delta = a.sub(i, e._values), this.computeValues(i), this.compute(t), e.delta = e.movement, this.emit();
  }
  bind(t) {
    t("pointer", "enter", this.enter.bind(this)), t("pointer", "leave", this.leave.bind(this));
  }
}
const Rt = u(u({}, g), {}, {
  mouseOnly: (s = !0) => s
}), Ut = /* @__PURE__ */ new Map(), Bt = /* @__PURE__ */ new Map();
function Gt(s) {
  Ut.set(s.key, s.engine), Bt.set(s.key, s.resolver);
}
const $t = {
  key: "drag",
  engine: mt,
  resolver: $
}, qt = {
  key: "hover",
  engine: Kt,
  resolver: Rt
}, Ft = {
  key: "move",
  engine: Ot,
  resolver: Pt
}, Jt = {
  key: "pinch",
  engine: kt,
  resolver: Ct
}, Qt = {
  key: "scroll",
  engine: Mt,
  resolver: Lt
}, Zt = {
  key: "wheel",
  engine: Nt,
  resolver: Vt
};
export {
  Bt as C,
  Ut as E,
  l as S,
  u as _,
  f as a,
  Wt as b,
  zt as c,
  jt as d,
  $t as e,
  Jt as f,
  qt as h,
  C as i,
  Ft as m,
  Ht as p,
  Gt as r,
  Qt as s,
  Xt as t,
  Zt as w
};
