import { configurator as c, Modifier as u } from "./index.js";
var y = Object.defineProperty, v = Object.defineProperties, x = Object.getOwnPropertyDescriptors, p = Object.getOwnPropertySymbols, d = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable, f = (t, r, e) => r in t ? y(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e, l = (t, r) => {
  for (var e in r || (r = {}))
    d.call(r, e) && f(t, e, r[e]);
  if (p)
    for (var e of p(r))
      O.call(r, e) && f(t, e, r[e]);
  return t;
}, _ = (t, r) => v(t, x(r)), o = class extends u {
  /**
   * Applies the axis restriction to the drag operation.
   *
   * @param operation - The current drag operation
   * @returns The modified transform with the axis restriction applied
   */
  apply({ transform: r }) {
    if (!this.options)
      return r;
    const { axis: e, value: i } = this.options;
    return _(l({}, r), {
      [e]: i
    });
  }
};
o.configure = c(o);
var g = o;
g.configure({
  axis: "x",
  value: 0
});
g.configure({
  axis: "y",
  value: 0
});
function w(t, r, e) {
  const i = l({}, r);
  return t.boundingRectangle.top + r.y <= e.top ? i.y = e.top - t.boundingRectangle.top : t.boundingRectangle.bottom + r.y >= e.top + e.height && (i.y = e.top + e.height - t.boundingRectangle.bottom), t.boundingRectangle.left + r.x <= e.left ? i.x = e.left - t.boundingRectangle.left : t.boundingRectangle.right + r.x >= e.left + e.width && (i.x = e.left + e.width - t.boundingRectangle.right), i;
}
var s = class extends u {
  /**
   * Applies the snap grid to the drag operation.
   *
   * @param operation - The current drag operation
   * @returns The modified transform with coordinates snapped to the grid
   */
  apply({ transform: r }) {
    var e;
    const { size: i = 20 } = (e = this.options) != null ? e : {}, n = typeof i == "number" ? i : i.x, a = typeof i == "number" ? i : i.y;
    return _(l({}, r), {
      x: Math.ceil(r.x / n) * n,
      y: Math.ceil(r.y / a) * a
    });
  }
};
s.configure = c(s);
export {
  g as AxisModifier,
  w as restrictShapeToBoundingRectangle
};
//# sourceMappingURL=modifiers.js.map
