var lt = Object.defineProperty;
var pt = (t, e, r) => e in t ? lt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
var N = (t, e, r) => pt(t, typeof e != "symbol" ? e + "" : e, r);
import { z as i } from "zod";
const G = i.tuple([i.number(), i.number()]);
i.tuple([i.bigint(), i.bigint()]);
const ge = i.object({ width: i.number(), height: i.number() }), ht = i.object({
  signedWidth: i.number(),
  signedHeight: i.number()
}), yt = ["width", "height"];
i.enum(yt);
const dt = ["start", "center", "end"], gt = ["signedWidth", "signedHeight"];
i.enum(gt);
const R = i.object({ x: i.number(), y: i.number() }), Ce = i.object({ clientX: i.number(), clientY: i.number() }), be = ["x", "y"], xe = i.enum(be), Re = ["top", "right", "bottom", "left"], bt = i.enum(Re), J = ["left", "right"], fe = i.enum(J), K = ["top", "bottom"], me = i.enum(K), we = ["center"], Ae = i.enum(we), xt = [...Re, ...we], $e = i.enum(xt), jn = i.enum(dt), ft = ["first", "last"], Tn = i.enum(ft), _e = i.object({ lower: i.number(), upper: i.number() }), mt = i.object({ lower: i.bigint(), upper: i.bigint() });
i.union([_e, G]);
i.union([mt, G]);
const wt = i.union([xe, $e]), $t = i.union([xe, $e, i.instanceof(String)]), ve = (t, e) => typeof t == "bigint" ? t - BigInt(e) : t - Number(e), Le = (t, e) => typeof t == "bigint" ? t + BigInt(e) : t + Number(e), vt = (t, e, r = 1e-4) => Math.abs(t - e) < r, Mt = (t) => {
  const e = Math.pow(10, Math.floor(Math.log10(t)));
  return Math.round(t / e) * e;
}, Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  add: Le,
  closeTo: vt,
  roundToNearestMagnitude: Mt,
  sub: ve
}, Symbol.toStringTag, { value: "Module" })), c = (t, e) => {
  const r = {};
  if (typeof t == "number" || typeof t == "bigint")
    e != null ? (r.lower = t, r.upper = e) : (r.lower = typeof t == "bigint" ? 0n : 0, r.upper = t);
  else if (Array.isArray(t)) {
    if (t.length !== 2) throw new Error("bounds: expected array of length 2");
    [r.lower, r.upper] = t;
  } else return oe(t);
  return oe(r);
}, Ot = Object.freeze({ lower: 0, upper: 0 }), jt = Object.freeze({ lower: -1 / 0, upper: 1 / 0 }), Tt = Object.freeze({ lower: 0, upper: 1 }), St = Object.freeze({ lower: -1, upper: 1 }), Et = (t, e) => {
  if (t == null && e == null) return !0;
  if (t == null || e == null) return !1;
  const r = c(t), n = c(e);
  return (r == null ? void 0 : r.lower) === (n == null ? void 0 : n.lower) && (r == null ? void 0 : r.upper) === (n == null ? void 0 : n.upper);
}, oe = (t) => t.lower > t.upper ? { lower: t.upper, upper: t.lower } : t, It = (t, e) => {
  const r = c(t);
  return e < r.lower ? r.lower : e >= r.upper ? r.upper - (typeof r.upper == "number" ? 1 : 1n) : e;
}, S = (t, e) => {
  const r = c(t);
  if (typeof e == "number" || typeof e == "bigint")
    return e >= r.lower && e < r.upper;
  const n = c(e);
  return n.lower >= r.lower && n.upper <= r.upper;
}, Bt = (t, e) => {
  const r = c(t), n = c(e);
  return r.lower === n.lower ? !0 : n.upper === r.lower || n.lower === r.upper ? !1 : S(r, n.upper) || S(r, n.lower) || S(n, r.upper) || S(n, r.lower);
}, w = (t) => {
  const e = c(t);
  return e.upper - e.lower;
}, At = (t) => {
  const e = c(t);
  return typeof e.lower == "bigint" ? e.lower === 0n && e.upper === 0n : e.lower === 0 && e.upper === 0;
}, Nt = (t) => {
  const e = w(t);
  return typeof e == "number" ? e === 0 : e === 0n;
}, zt = (t) => {
  const e = c(t);
  return typeof e.lower == "bigint" ? !0 : Number.isFinite(e.lower) && Number.isFinite(e.upper);
}, Ct = (t) => ({
  lower: Math.min(...t.map((e) => c(e).lower)),
  upper: Math.max(...t.map((e) => c(e).upper))
}), Rt = (t) => ({
  lower: Math.max(...t.map((e) => c(e).lower)),
  upper: Math.min(...t.map((e) => c(e).upper))
}), _t = (t) => {
  const e = c(t), r = typeof e.lower == "bigint";
  return Array.from({ length: Number(w(t)) }, (n, o) => r ? e.lower + BigInt(o) : e.lower + o);
}, se = (t, e) => {
  const r = t.map((s) => c(s)), n = r.findIndex(
    (s, u) => S(s, e) || e < r[u].lower
  );
  if (n === -1) return { index: t.length, position: 0 };
  const o = r[n];
  return S(o, e) ? { index: n, position: Number(e - o.lower) } : { index: n, position: 0 };
}, re = {
  removeBefore: 0,
  removeAfter: 0,
  insertInto: 0,
  deleteInBetween: 0
}, Pe = (t, e) => {
  const r = t.map((h) => c(h)), n = c(e);
  if (r.length === 0) return re;
  const o = se(r, n.lower), s = se(r, n.upper);
  if (o.index === t.length) return { ...re, insertInto: t.length };
  if (s.index === 0) return { ...re, removeAfter: s.position };
  if (o.index === s.index)
    return o.position !== 0 && s.position !== 0 ? null : {
      removeAfter: s.position,
      removeBefore: o.position,
      insertInto: o.index,
      deleteInBetween: 0
    };
  let u = s.index - o.index, a = o.index, y = ve(Number(w(r[o.index])), o.position);
  return o.position !== 0 ? (u -= 1, a += 1) : y = 0, {
    removeBefore: y,
    removeAfter: s.position,
    insertInto: a,
    deleteInBetween: u
  };
}, Lt = (t, e) => {
  const r = Pe(t, e), n = t.map((s) => c(s));
  if (r == null) return n;
  const o = c(e);
  return o.lower = Le(o.lower, r.removeBefore), o.upper = ve(o.upper, r.removeAfter), n.splice(r.insertInto, r.deleteInBetween, o), n;
}, Pt = (t, e) => {
  const r = c(t), n = c(e);
  return r.upper <= n.lower || r.lower >= n.upper ? 0 : r.lower >= n.lower && r.upper <= n.upper ? 1 : r.lower <= n.lower && r.upper >= n.upper ? w(n) / w(r) : r.lower <= n.lower ? (r.upper - n.lower) / w(r) : (n.upper - r.lower) / w(r);
}, En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  CLIP: St,
  DECIMAL: Tt,
  INFINITE: jt,
  ZERO: Ot,
  bounds: _e,
  buildInsertionPlan: Pe,
  clamp: It,
  construct: c,
  contains: S,
  equals: Et,
  exposure: Pt,
  findInsertPosition: se,
  insert: Lt,
  isFinite: zt,
  isZero: At,
  linspace: _t,
  makeValid: oe,
  max: Ct,
  min: Rt,
  overlapsWith: Bt,
  span: w,
  spanIsZero: Nt
}, Symbol.toStringTag, { value: "Module" })), He = wt, T = (t) => be.includes(t) ? t : K.includes(t) ? "y" : "x", Ht = (t) => T(t) === "x" ? "y" : "x", Zt = (t) => T(t) === "x" ? "width" : "height", Yt = (t) => T(t) === "x" ? "left" : "top", Ft = (t) => He.safeParse(t).success, Wt = (t) => T(t) === "x" ? "signedWidth" : "signedHeight", Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  construct: T,
  crude: He,
  dimension: Zt,
  direction: xe,
  isDirection: Ft,
  location: Yt,
  signedDimension: Wt,
  swap: Ht
}, Symbol.toStringTag, { value: "Module" })), kt = (t) => {
  const e = t.replace(/_[a-z]/g, (r) => r[1].toUpperCase());
  return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() ? e : e[0].toLowerCase() + e.slice(1);
}, Ze = (t) => {
  const e = (r, n = V) => {
    if (typeof r == "string") return t(r);
    if (Array.isArray(r)) return r.map((u) => e(u, n));
    if (!W(r)) return r;
    n = Fe(n);
    const o = {}, s = r;
    return Object.keys(s).forEach((u) => {
      let a = s[u];
      const y = t(u);
      n.recursive && (W(a) ? ue(a, n.keepTypesOnRecursion) || (a = e(a, n)) : n.recursiveInArray && ie(a) && (a = [...a].map((h) => {
        let d = h;
        return W(h) ? ue(d, n.keepTypesOnRecursion) || (d = e(h, n)) : ie(h) && (d = e({ key: h }, n).key), d;
      }))), o[y] = a;
    }), o;
  };
  return e;
}, Dt = Ze(kt), Vt = (t) => t.replace(/([a-z0-9])([A-Z])/g, (e, r, n) => `${r}_${n.toLowerCase()}`), qt = Ze(Vt), Ye = (t) => t.length === 0 ? t : t[0].toUpperCase() + t.slice(1), V = {
  recursive: !0,
  recursiveInArray: !0,
  keepTypesOnRecursion: [Number, String, Uint8Array]
}, Fe = (t = V) => (t.recursive == null ? t = V : t.recursiveInArray == null && (t.recursiveInArray = !1), t), ie = (t) => t != null && Array.isArray(t), W = (t) => t != null && typeof t == "object" && !Array.isArray(t), ue = (t, e) => (e || []).some((r) => t instanceof r), In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  belongToTypes: ue,
  camelToSnake: qt,
  capitalize: Ye,
  defaultOptions: V,
  isArrayObject: ie,
  isValidObject: W,
  snakeToCamel: Dt,
  validateOptions: Fe
}, Symbol.toStringTag, { value: "Module" })), Ut = fe, Gt = me, Jt = {
  top: "bottom",
  right: "left",
  bottom: "top",
  left: "right",
  center: "center"
}, Kt = {
  top: "left",
  right: "top",
  bottom: "right",
  left: "bottom",
  center: "center"
}, Qt = $t, M = (t) => t instanceof String ? t : be.includes(t) ? t === "x" ? "left" : "top" : t, er = (t) => Jt[M(t)], tr = (t) => Kt[M(t)], _ = (t) => {
  const e = M(t);
  return e === "top" || e === "bottom" ? "y" : "x";
}, rr = i.object({
  x: fe.or(Ae),
  y: me.or(Ae)
}), We = i.object({ x: fe, y: me }), L = Object.freeze({ x: "left", y: "top" }), Me = Object.freeze({ x: "right", y: "top" }), Q = Object.freeze({ x: "left", y: "bottom" }), Oe = Object.freeze({ x: "right", y: "bottom" }), je = Object.freeze({ x: "center", y: "center" }), Xe = Object.freeze({ x: "center", y: "top" }), ke = Object.freeze({ x: "center", y: "bottom" }), De = Object.freeze({ x: "right", y: "center" }), Ve = Object.freeze({ x: "left", y: "center" }), nr = Object.freeze([
  Ve,
  De,
  Xe,
  ke,
  L,
  Me,
  Q,
  Oe,
  je
]), Te = (t, e) => t.x === e.x && t.y === e.y, or = (t, e) => {
  if (typeof e == "object") {
    let r = !0;
    return "x" in e && (t.x === e.x || (r = !1)), "y" in e && (t.y === e.y || (r = !1)), r;
  }
  return t.x === e || t.y === e;
}, qe = (t) => [t.x, t.y], X = (t) => _(M(t)) === "x", sr = (t) => _(M(t)) === "y", ir = (t) => `${t.x}${Ye(t.y)}`, ur = (t, e) => {
  let r, n;
  if (typeof t == "object" && "x" in t ? (r = t.x, n = t.y) : (r = M(t), n = M(e ?? t)), _(r) === _(n) && r !== "center" && n !== "center")
    throw new Error(
      `[XYLocation] - encountered two locations with the same direction: ${r.toString()} - ${n.toString()}`
    );
  const o = { ...je };
  return r === "center" ? X(n) ? [o.x, o.y] = [n, r] : [o.x, o.y] = [r, n] : n === "center" ? X(r) ? [o.x, o.y] = [r, n] : [o.x, o.y] = [n, r] : X(r) ? [o.x, o.y] = [r, n] : [o.x, o.y] = [n, r], o;
}, Ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  BOTTOM_CENTER: ke,
  BOTTOM_LEFT: Q,
  BOTTOM_RIGHT: Oe,
  CENTER: je,
  CENTER_LOCATIONS: we,
  LEFT_CENTER: Ve,
  RIGHT_CENTER: De,
  TOP_CENTER: Xe,
  TOP_LEFT: L,
  TOP_RIGHT: Me,
  XY_LOCATIONS: nr,
  X_LOCATIONS: J,
  Y_LOCATIONS: K,
  construct: M,
  constructXY: ur,
  corner: We,
  crude: Qt,
  direction: _,
  isX: X,
  isY: sr,
  location: $e,
  outer: bt,
  rotate90: tr,
  swap: er,
  x: Ut,
  xy: rr,
  xyCouple: qe,
  xyEquals: Te,
  xyMatches: or,
  xyToString: ir,
  y: Gt
}, Symbol.toStringTag, { value: "Module" })), ae = i.union([
  i.number(),
  R,
  G,
  ge,
  ht,
  Ce
]), p = (t, e) => {
  if (typeof t == "string") {
    if (e === void 0) throw new Error("The y coordinate must be given.");
    return t === "x" ? { x: e, y: 0 } : { x: 0, y: e };
  }
  return typeof t == "number" ? { x: t, y: e ?? t } : Array.isArray(t) ? { x: t[0], y: t[1] } : "signedWidth" in t ? { x: t.signedWidth, y: t.signedHeight } : "clientX" in t ? { x: t.clientX, y: t.clientY } : "width" in t ? { x: t.width, y: t.height } : { x: t.x, y: t.y };
}, m = Object.freeze({ x: 0, y: 0 }), Ge = Object.freeze({ x: 1, y: 1 }), ar = Object.freeze({ x: 1 / 0, y: 1 / 0 }), cr = Object.freeze({ x: NaN, y: NaN }), q = (t, e, r = 0) => {
  const n = p(t), o = p(e);
  return r === 0 ? n.x === o.x && n.y === o.y : Math.abs(n.x - o.x) <= r && Math.abs(n.y - o.y) <= r;
}, lr = (t) => q(t, m), pr = (t, e, r) => {
  const n = p(t), o = p(e, r);
  return { x: n.x * o.x, y: n.y * o.y };
}, Je = (t, e) => {
  const r = p(t);
  return { x: r.x + e, y: r.y };
}, Ke = (t, e) => {
  const r = p(t);
  return { x: r.x, y: r.y + e };
}, U = (t, e, r, ...n) => typeof e == "string" && typeof r == "number" ? e === "x" ? Je(t, r) : Ke(t, r) : [t, e, r ?? m, ...n].reduce((o, s) => {
  const u = p(s);
  return { x: o.x + u.x, y: o.y + u.y };
}, m), hr = (t, e, r) => {
  const n = p(t);
  return e === "x" ? { x: r, y: n.y } : { x: n.x, y: r };
}, yr = (t, e) => {
  const r = p(t), n = p(e);
  return Math.sqrt((r.x - n.x) ** 2 + (r.y - n.y) ** 2);
}, dr = (t, e) => {
  const r = p(t), n = p(e);
  return { x: n.x - r.x, y: n.y - r.y };
}, gr = (t) => {
  const e = p(t);
  return Number.isNaN(e.x) || Number.isNaN(e.y);
}, br = (t) => {
  const e = p(t);
  return Number.isFinite(e.x) && Number.isFinite(e.y);
}, xr = (t) => {
  const e = p(t);
  return [e.x, e.y];
}, fr = (t) => {
  const e = p(t);
  return { left: e.x, top: e.y };
}, ce = (t, e = 0) => {
  const r = p(t);
  return { x: Number(r.x.toFixed(e)), y: Number(r.y.toFixed(e)) };
}, Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  INFINITY: ar,
  NAN: cr,
  ONE: Ge,
  ZERO: m,
  clientXY: Ce,
  construct: p,
  couple: xr,
  crudeZ: ae,
  css: fr,
  distance: yr,
  equals: q,
  isFinite: br,
  isNan: gr,
  isZero: lr,
  scale: pr,
  set: hr,
  translate: U,
  translateX: Je,
  translateY: Ke,
  translation: dr,
  truncate: ce,
  xy: R
}, Symbol.toStringTag, { value: "Module" })), H = i.union([i.number(), i.string()]);
i.object({
  top: H,
  left: H,
  width: H,
  height: H
});
i.object({
  left: i.number(),
  top: i.number(),
  right: i.number(),
  bottom: i.number()
});
const mr = i.object({
  one: R,
  two: R,
  root: We
}), Qe = { one: m, two: m, root: L }, wr = { one: m, two: Ge, root: Q }, et = (t, e) => ({
  one: t.one,
  two: t.two,
  root: e ?? t.root
}), l = (t, e, r = 0, n = 0, o) => {
  const s = {
    one: { ...m },
    two: { ...m },
    root: o ?? L
  };
  if (typeof t == "number") {
    if (typeof e != "number")
      throw new Error("Box constructor called with invalid arguments");
    return s.one = { x: t, y: e }, s.two = { x: s.one.x + r, y: s.one.y + n }, s;
  }
  return "one" in t && "two" in t && "root" in t ? { ...t, root: o ?? t.root } : ("getBoundingClientRect" in t && (t = t.getBoundingClientRect()), "left" in t ? (s.one = { x: t.left, y: t.top }, s.two = { x: t.right, y: t.bottom }, s) : (s.one = t, e == null ? s.two = { x: s.one.x + r, y: s.one.y + n } : typeof e == "number" ? s.two = { x: s.one.x + e, y: s.one.y + r } : "width" in e ? s.two = {
    x: s.one.x + e.width,
    y: s.one.y + e.height
  } : "signedWidth" in e ? s.two = {
    x: s.one.x + e.signedWidth,
    y: s.one.y + e.signedHeight
  } : s.two = e, s));
}, $r = (t, e, r) => {
  const n = l(t);
  if (typeof e == "string") {
    if (r == null) throw new Error("Invalid arguments for resize");
    const o = T(e);
    return l(
      n.one,
      void 0,
      o === "x" ? r : O(n),
      o === "y" ? r : j(n),
      n.root
    );
  }
  return l(n.one, e, void 0, void 0, n.root);
}, vr = (t, e, r = !0) => {
  const n = l(t);
  let o = (s, u) => s < u;
  return r && (o = (s, u) => s <= u), "one" in e ? o($(n), $(e)) && o(E(e), E(n)) && o(v(n), v(e)) && o(I(e), I(n)) : o($(n), e.x) && o(e.x, E(n)) && o(v(n), e.y) && o(e.y, I(n));
}, Mr = (t, e) => q(t.one, e.one) && q(t.two, e.two) && Te(t.root, e.root), tt = (t) => ({
  width: O(t),
  height: j(t)
}), Or = (t) => ({
  signedWidth: ee(t),
  signedHeight: te(t)
}), jr = (t) => ({
  top: v(t),
  left: $(t),
  width: O(t),
  height: j(t)
}), Se = (t, e, r = !1) => {
  const n = T(e) === "y" ? te(t) : ee(t);
  return r ? n : Math.abs(n);
}, P = (t, e) => {
  const r = l(t);
  return {
    x: e.x === "center" ? le(r).x : B(r, e.x),
    y: e.y === "center" ? le(r).y : B(r, e.y)
  };
}, B = (t, e) => {
  const r = l(t), n = qe(r.root).includes(e) ? Math.min : Math.max;
  return J.includes(e) ? n(r.one.x, r.two.x) : n(r.one.y, r.two.y);
}, Tr = (t) => t.one.x === t.two.x && t.one.y === t.two.y, O = (t) => Se(t, "x"), j = (t) => Se(t, "y"), ee = (t) => {
  const e = l(t);
  return e.two.x - e.one.x;
}, te = (t) => {
  const e = l(t);
  return e.two.y - e.one.y;
}, rt = (t) => P(t, L), Sr = (t) => P(t, Me), Er = (t) => P(t, Q), Ir = (t) => P(t, Oe), E = (t) => B(t, "right"), I = (t) => B(t, "bottom"), $ = (t) => B(t, "left"), v = (t) => B(t, "top"), le = (t) => U(rt(t), {
  x: ee(t) / 2,
  y: te(t) / 2
}), Ee = (t) => {
  const e = l(t);
  return e.root.x === "left" ? $(e) : E(e);
}, Ie = (t) => {
  const e = l(t);
  return e.root.y === "top" ? v(e) : I(e);
}, Br = (t) => ({ x: Ee(t), y: Ie(t) }), k = (t) => {
  const e = l(t);
  return { lower: e.one.x, upper: e.two.x };
}, D = (t) => {
  const e = l(t);
  return { lower: e.one.y, upper: e.two.y };
}, Ar = (t, e) => et(t, e), Nr = (t, e) => {
  const r = l(t), n = J.includes(e) ? "x" : K.includes(e) ? "y" : null;
  if (n === null) throw new Error(`Invalid location: ${Ue}`);
  const o = e === "top" || e === "left" ? Math.min : Math.max, s = { ...r.one }, u = { ...r.two };
  return s[n] = o(r.one[n], r.two[n]), u[n] = o(r.one[n], r.two[n]), [s, u];
}, zr = (t, e) => {
  const r = l(t), n = l(e), o = Ee(n) + (O(n) - O(r)) / 2, s = Ie(n) + (j(n) - j(r)) / 2;
  return l({ x: o, y: s }, tt(r));
}, nt = (t) => typeof t != "object" || t == null ? !1 : "one" in t && "two" in t && "root" in t, Cr = (t) => O(t) / j(t), Rr = (t, e, r) => {
  if (typeof e == "string") {
    if (r == null) throw new Error("Undefined amount passed into box.translate");
    const o = T(e);
    e = p(o, r);
  }
  const n = l(t);
  return l(
    U(n.one, e),
    U(n.two, e),
    void 0,
    void 0,
    n.root
  );
}, _r = (t, e) => {
  const r = Math.max($(t), $(e)), n = Math.max(v(t), v(e)), o = Math.min(E(t), E(e)), s = Math.min(I(t), I(e));
  return r > o || n > s ? Qe : l({ x: r, y: n }, { x: o, y: s }, void 0, void 0, t.root);
}, Lr = (t) => O(t) * j(t), Pr = (t, e) => {
  const r = l(t);
  return l(
    ce(r.one, e),
    ce(r.two, e),
    void 0,
    void 0,
    r.root
  );
}, Hr = (t, e, r, n, o, s) => {
  const u = { x: t, y: e }, a = { x: t + r, y: e + n };
  return o.x !== s.x && (o.x === "center" ? (u.x -= r / 2, a.x -= r / 2) : (u.x -= r, a.x -= r)), o.y !== s.y && (o.y === "center" ? (u.y -= n / 2, a.y -= n / 2) : (u.y -= n, a.y -= n)), l(u, a, void 0, void 0, s);
}, An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  DECIMAL: wr,
  ZERO: Qe,
  area: Lr,
  areaIsZero: Tr,
  aspect: Cr,
  bottom: I,
  bottomLeft: Er,
  bottomRight: Ir,
  box: mr,
  center: le,
  construct: l,
  constructWithAlternateRoot: Hr,
  contains: vr,
  copy: et,
  css: jr,
  dim: Se,
  dims: tt,
  edgePoints: Nr,
  equals: Mr,
  height: j,
  intersection: _r,
  isBox: nt,
  left: $,
  loc: B,
  positionInCenter: zr,
  reRoot: Ar,
  resize: $r,
  right: E,
  root: Br,
  signedDims: Or,
  signedHeight: te,
  signedWidth: ee,
  top: v,
  topLeft: rt,
  topRight: Sr,
  translate: Rr,
  truncate: Pr,
  width: O,
  x: Ee,
  xBounds: k,
  xyLoc: P,
  y: Ie,
  yBounds: D
}, Symbol.toStringTag, { value: "Module" })), ot = i.object({ signedWidth: i.number(), signedHeight: i.number() }), Zr = i.union([ge, ot, R, G]), Yr = { width: 0, height: 0 }, Fr = { width: 1, height: 1 }, g = (t, e) => typeof t == "number" ? { width: t, height: e ?? t } : Array.isArray(t) ? { width: t[0], height: t[1] } : "x" in t ? { width: t.x, height: t.y } : "signedWidth" in t ? { width: t.signedWidth, height: t.signedHeight } : { ...t }, Wr = (t, e) => {
  if (e == null) return !1;
  const r = g(t), n = g(e);
  return r.width === n.width && r.height === n.height;
}, Xr = (t) => {
  const e = g(t);
  return { width: e.height, height: e.width };
}, kr = (t) => {
  const e = g(t);
  return `0 0 ${e.width} ${e.height}`;
}, Dr = (t) => {
  const e = g(t);
  return [e.width, e.height];
}, Vr = (t) => ({
  width: Math.max(...t.map((e) => g(e).width)),
  height: Math.max(...t.map((e) => g(e).height))
}), qr = (t) => ({
  width: Math.min(...t.map((e) => g(e).width)),
  height: Math.min(...t.map((e) => g(e).height))
}), Ur = (t, e) => {
  const r = g(t);
  return { width: r.width * e, height: r.height * e };
}, Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  DECIMAL: Fr,
  ZERO: Yr,
  construct: g,
  couple: Dr,
  crude: Zr,
  dimensions: ge,
  equals: Wr,
  max: Vr,
  min: qr,
  scale: Ur,
  signed: ot,
  svgViewBox: kr,
  swap: Xr
}, Symbol.toStringTag, { value: "Module" }));
var Gr = Object.defineProperty, Jr = (t, e, r) => e in t ? Gr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, f = (t, e, r) => Jr(t, typeof e != "symbol" ? e + "" : e, r);
const Kr = (t, e, r) => e !== void 0 && t < e ? e : r !== void 0 && t > r ? r : t, Qr = i.object({ offset: ae, scale: ae }), en = (t) => (e, r, n, o) => r === "dimension" ? [e, n] : [
  e,
  o ? n - t : n + t
], tn = (t) => (e, r, n, o) => [
  e,
  o ? n / t : n * t
], rn = (t) => (e, r, n) => {
  if (e === null) return [t, n];
  const { lower: o, upper: s } = e, { lower: u, upper: a } = t, y = s - o, h = a - u;
  if (r === "dimension") return [t, n * (h / y)];
  const d = (n - o) * (h / y) + u;
  return [t, d];
}, nn = (t) => (e, r, n) => [t, n], on = () => (t, e, r) => {
  if (t === null) throw new Error("cannot invert without bounds");
  if (e === "dimension") return [t, r];
  const { lower: n, upper: o } = t;
  return [t, o - (r - n)];
}, sn = (t) => (e, r, n) => {
  const { lower: o, upper: s } = t;
  return n = Kr(n, o, s), [e, n];
}, pe = class C {
  constructor() {
    f(this, "ops", []), f(this, "currBounds", null), f(this, "currType", null), f(this, "reversed", !1), this.ops = [];
  }
  static translate(e) {
    return new C().translate(e);
  }
  static magnify(e) {
    return new C().magnify(e);
  }
  static scale(e, r) {
    return new C().scale(e, r);
  }
  translate(e) {
    const r = this.new(), n = en(e);
    return n.type = "translate", r.ops.push(n), r;
  }
  magnify(e) {
    const r = this.new(), n = tn(e);
    return n.type = "magnify", r.ops.push(n), r;
  }
  scale(e, r) {
    const n = c(e, r), o = this.new(), s = rn(n);
    return s.type = "scale", o.ops.push(s), o;
  }
  clamp(e, r) {
    const n = c(e, r), o = this.new(), s = sn(n);
    return s.type = "clamp", o.ops.push(s), o;
  }
  reBound(e, r) {
    const n = c(e, r), o = this.new(), s = nn(n);
    return s.type = "re-bound", o.ops.push(s), o;
  }
  invert() {
    const e = on();
    e.type = "invert";
    const r = this.new();
    return r.ops.push(e), r;
  }
  pos(e) {
    return this.exec("position", e);
  }
  dim(e) {
    return this.exec("dimension", e);
  }
  new() {
    const e = new C();
    return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
  }
  exec(e, r) {
    return this.currBounds = null, this.ops.reduce(
      ([n, o], s) => s(n, e, o, this.reversed),
      [null, r]
    )[1];
  }
  reverse() {
    const e = this.new();
    e.ops.reverse();
    const r = [];
    return e.ops.forEach((n, o) => {
      if (n.type === "scale" || r.some(([u, a]) => o >= u && o <= a))
        return;
      const s = e.ops.findIndex((u, a) => u.type === "scale" && a > o);
      s !== -1 && r.push([o, s]);
    }), r.forEach(([n, o]) => {
      const s = e.ops.slice(n, o);
      s.unshift(e.ops[o]), e.ops.splice(n, o - n + 1, ...s);
    }), e.reversed = !e.reversed, e;
  }
};
f(pe, "IDENTITY", new pe());
let he = pe;
const un = (t) => ({
  scale: {
    x: t.x.dim(1),
    y: t.y.dim(1)
  },
  offset: {
    x: t.x.pos(0),
    y: t.y.pos(0)
  }
}), ye = class x {
  constructor(e = new he(), r = new he(), n = null) {
    f(this, "x"), f(this, "y"), f(this, "currRoot"), this.x = e, this.y = r, this.currRoot = n;
  }
  static translate(e, r) {
    return new x().translate(e, r);
  }
  static translateX(e) {
    return new x().translateX(e);
  }
  static translateY(e) {
    return new x().translateY(e);
  }
  static clamp(e) {
    return new x().clamp(e);
  }
  static magnify(e) {
    return new x().magnify(e);
  }
  static scale(e) {
    return new x().scale(e);
  }
  static reBound(e) {
    return new x().reBound(e);
  }
  translate(e, r) {
    const n = p(e, r), o = this.copy();
    return o.x = this.x.translate(n.x), o.y = this.y.translate(n.y), o;
  }
  translateX(e) {
    const r = this.copy();
    return r.x = this.x.translate(e), r;
  }
  translateY(e) {
    const r = this.copy();
    return r.y = this.y.translate(e), r;
  }
  magnify(e) {
    const r = this.copy();
    return r.x = this.x.magnify(e.x), r.y = this.y.magnify(e.y), r;
  }
  scale(e) {
    const r = this.copy();
    if (nt(e)) {
      const n = this.currRoot;
      return r.currRoot = e.root, n != null && !Te(n, e.root) && (n.x !== e.root.x && (r.x = r.x.invert()), n.y !== e.root.y && (r.y = r.y.invert())), r.x = r.x.scale(k(e)), r.y = r.y.scale(D(e)), r;
    }
    return r.x = r.x.scale(e.width), r.y = r.y.scale(e.height), r;
  }
  reBound(e) {
    const r = this.copy();
    return r.x = this.x.reBound(k(e)), r.y = this.y.reBound(D(e)), r;
  }
  clamp(e) {
    const r = this.copy();
    return r.x = this.x.clamp(k(e)), r.y = this.y.clamp(D(e)), r;
  }
  copy() {
    const e = new x();
    return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
  }
  reverse() {
    const e = this.copy();
    return e.x = this.x.reverse(), e.y = this.y.reverse(), e;
  }
  pos(e) {
    return { x: this.x.pos(e.x), y: this.y.pos(e.y) };
  }
  box(e) {
    return l(
      this.pos(e.one),
      this.pos(e.two),
      0,
      0,
      this.currRoot ?? e.root
    );
  }
};
f(ye, "IDENTITY", new ye());
let an = ye;
const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Scale: he,
  XY: an,
  crudeXYTransform: Qr,
  xyScaleToTransform: un
}, Symbol.toStringTag, { value: "Module" }));
function st(t) {
  var e, r, n = "";
  if (typeof t == "string" || typeof t == "number") n += t;
  else if (typeof t == "object") if (Array.isArray(t)) {
    var o = t.length;
    for (e = 0; e < o; e++) t[e] && (r = st(t[e])) && (n && (n += " "), n += r);
  } else for (r in t) t[r] && (n && (n += " "), n += r);
  return n;
}
function cn() {
  for (var t, e, r = 0, n = "", o = arguments.length; r < o; r++) (t = arguments[r]) && (e = st(t)) && (n && (n += " "), n += e);
  return n;
}
const ln = cn, Ne = "-", ze = "__", Z = "--", it = (t) => {
  const e = (...r) => ln(...r);
  return e.B = (r) => t + Ne + r, e.E = (r) => t + ze + r, e.M = (r) => t + Z + r, e.BM = (r, n) => e.B(r) + Z + n, e.BE = (r, n) => e.B(r) + ze + n, e.BEM = (r, n, o) => e.BE(r, n) + Z + o, e.extend = (r) => it(e.B(r)), e.var = (r) => Z + t + Ne + r, e;
}, pn = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, de = i.string().regex(pn), z = i.number().min(0).max(255), hn = i.number().min(0).max(1), Be = i.tuple([z, z, z, hn]), ut = i.tuple([z, z, z]), at = i.object({ rgba255: Be }), yn = (t) => t == null ? void 0 : new A(t).hex, dn = (t) => {
  if (t == null) return;
  const e = A.z.safeParse(t);
  if (e.success) return e.data.rgbaCSS;
  if (typeof t == "string") return t;
  throw e.error;
}, b = class b {
  /**
   * @constructor Creates a new color from the given color value. The color value can be
   * a hex string, an array of RGB or RGBA values, or another color.
   *
   * @param color - The color value to create the color from. If the color value is a
   * string, it must be a valid hex color (with or without the '#') with a hasheless
   * length 6 or 8. If the hex color is 8 characters long, the last twoc haracters are
   * used as the alpha value. If the color value is an array, it must be an array of
   * length 3 or 4, with each value between 0 and 255. If the color value is another
   * color, the color will be copied.
   *
   * @param alpha - An optional alpha value to set. If the color value carries its own
   * alpha value, this value will be ignored. Defaults to 1.
   */
  constructor(e, r = 1) {
    /**
     * @property the color as an RGBA tuple, with each color value between 0 and 255,
     * and the alpha value between 0 and 1.
     */
    N(this, "rgba255");
    if (typeof e == "string")
      this.rgba255 = b.fromHex(e, r);
    else if (Array.isArray(e)) {
      if (e.length < 3 || e.length > 4)
        throw new Error(`Invalid color: [${e.join(", ")}]`);
      this.rgba255 = e.length === 3 ? [...e, r ?? 1] : e;
    } else this.rgba255 = e.rgba255;
  }
  /**
   * @returns true if the given color is semantically equal to this color. Different
   * representations of the same color are considered equal (e.g. hex and rgba).
   */
  equals(e) {
    if (e == null) return !1;
    const r = new b(e);
    return this.rgba255.every((n, o) => n === r.rgba255[o]);
  }
  /**
   * @returns the hex representation of the color. If the color has an opacity of 1,
   * the returned hex will be 6 characters long. Otherwise, it will be 8 characters
   * long.
   */
  get hex() {
    const [e, r, n, o] = this.rgba255;
    return `#${Y(e)}${Y(r)}${Y(n)}${o === 1 ? "" : Y(o * 255)}`;
  }
  /**
   * @returns the color as a CSS RGBA string.
   */
  get rgbaCSS() {
    const [e, r, n, o] = this.rgba255;
    return `rgba(${e}, ${r}, ${n}, ${o})`;
  }
  /**
   * @returns the color as a CSS RGB string with no alpha value.
   */
  get rgbCSS() {
    return `rgb(${this.rgbString})`;
  }
  /**
   * @returns the color as an RGB string, with each color value between 0 and 255.
   * @example "255, 255, 255"
   */
  get rgbString() {
    const [e, r, n] = this.rgba255;
    return `${e}, ${r}, ${n}`;
  }
  /**
   * @returns the color as an RGBA tuple, with each color value between 0 and 1,
   * and the alpha value between 0 and 1.
   */
  get rgba1() {
    return [...this.rgb1, this.rgba255[3]];
  }
  get rgb1() {
    return [this.rgba255[0] / 255, this.rgba255[1] / 255, this.rgba255[2] / 255];
  }
  /** @returns the red value of the color, between 0 and 255. */
  get r() {
    return this.rgba255[0];
  }
  /** @returns the green value of the color, between 0 and 255. */
  get g() {
    return this.rgba255[1];
  }
  /** @returns the blue value of the color, between 0 and 255. */
  get b() {
    return this.rgba255[2];
  }
  /** @returns the alpha value of the color, between 0 and 1. */
  get a() {
    return this.rgba255[3];
  }
  /** @returns true if all RGBA values are 0. */
  get isZero() {
    return this.equals(ct);
  }
  get hsla() {
    return xn(this.rgba255);
  }
  /**
   * Creates a new color with the given alpha.
   *
   * @param alpha - The alpha value to set. If the value is greater than 1, it will be
   * divided by 100.
   * @returns A new color with the given alpha.
   */
  setAlpha(e) {
    const [r, n, o] = this.rgba255;
    if (e > 100)
      throw new Error(`Color opacity must be between 0 and 100, got ${e}`);
    return e > 1 && (e = e / 100), new b([r, n, o, e]);
  }
  /**
   * @returns the luminance of the color, between 0 and 1.
   */
  get luminance() {
    const [e, r, n] = this.rgb1.map((o) => o <= 0.03928 ? o / 12.92 : ((o + 0.055) / 1.055) ** 2.4);
    return Number((0.2126 * e + 0.7152 * r + 0.0722 * n).toFixed(3));
  }
  /**
   * @returns the contrast ratio between this color and the given color. The contrast
   * ratio is a number between 1 and 21, where 1 is the lowest contrast and 21 is the
   * highest.
   * @param other
   * @returns
   */
  contrast(e) {
    const r = new b(e), n = this.luminance, o = r.luminance;
    return (Math.max(n, o) + 0.5) / (Math.min(n, o) + 0.5);
  }
  pickByContrast(...e) {
    if (e.length === 0)
      throw new Error("[Color.pickByContrast] - must provide at least one color");
    const [r] = e.map((n) => new b(n)).sort((n, o) => this.contrast(o) - this.contrast(n));
    return r;
  }
  get isDark() {
    return this.luminance < 0.5;
  }
  get isLight() {
    return !this.isDark;
  }
  static fromHex(e, r = 1) {
    if (!de.safeParse(e).success) throw new Error(`Invalid hex color: ${e}`);
    return e = gn(e), [
      F(e, 0),
      F(e, 2),
      F(e, 4),
      e.length === 8 ? F(e, 6) / 255 : r
    ];
  }
};
N(b, "z", i.union([de, Be, ut, i.instanceof(b), at]).transform((e) => new b(e)));
let A = b;
const ct = new A([0, 0, 0, 0]), Y = (t) => Math.floor(t).toString(16).padStart(2, "0"), F = (t, e) => parseInt(t.slice(e, e + 2), 16), gn = (t) => t.startsWith("#") ? t.slice(1) : t, bn = (t) => {
  let [e, r, n] = t;
  const o = t[3];
  e /= 360, r /= 100, n /= 100;
  let s, u, a;
  if (r === 0)
    s = u = a = n;
  else {
    const y = n < 0.5 ? n * (1 + r) : n + r - n * r, h = 2 * n - y;
    s = ne(h, y, e + 1 / 3), u = ne(h, y, e), a = ne(h, y, e - 1 / 3);
  }
  return [Math.round(s * 255), Math.round(u * 255), Math.round(a * 255), o];
}, ne = (t, e, r) => (r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? t + (e - t) * 6 * r : r < 1 / 2 ? e : r < 2 / 3 ? t + (e - t) * (2 / 3 - r) * 6 : t), xn = (t) => {
  let [e, r, n] = t;
  const o = t[3];
  e /= 255, r /= 255, n /= 255, e /= 255, r /= 255, n /= 255;
  const s = Math.max(e, r, n), u = Math.min(e, r, n);
  let a, y, h = (s + u) / 2;
  if (s === u)
    a = y = 0;
  else {
    const d = s - u;
    y = h > 0.5 ? d / (2 - s - u) : d / (s + u), s === e ? a = (r - n) / d + (r < n ? 6 : 0) : s === r ? a = (n - e) / d + 2 : a = (e - r) / d + 4, a /= 6;
  }
  return a *= 360, y *= 100, h *= 100, [Math.round(a), Math.round(y), Math.round(h), o];
}, fn = i.union([
  de,
  Be,
  i.instanceof(A),
  i.string(),
  ut,
  at
]), Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Color: A,
  ZERO: ct,
  crudeZ: fn,
  cssString: dn,
  fromHSLA: bn,
  toHex: yn
}, Symbol.toStringTag, { value: "Module" }));
class mn {
  constructor(e = "") {
    N(this, "rows", []);
    N(this, "columns", []);
    N(this, "prefix");
    this.prefix = e;
  }
  row(e, r, n) {
    const { prefix: o } = this;
    return this.rows.push({ startLabel: o + e, endLabel: o + r, size: n }), this;
  }
  col(e, r, n) {
    const { prefix: o } = this;
    return this.columns.push({ startLabel: o + e, endLabel: o + r, size: n }), this;
  }
  build() {
    return {
      display: "grid",
      gridTemplateRows: this.rows.map((e, r) => {
        let n = r === 0 ? "[" : "";
        return n += `${e.startLabel}] ${e.size}${typeof e.size == "number" ? "px" : ""} [${e.endLabel}`, n += r === this.rows.length - 1 ? "]" : "", n;
      }).join(" "),
      gridTemplateColumns: this.columns.map((e, r) => {
        let n = r === 0 ? "[" : "";
        return n += `${e.startLabel}] ${e.size}${typeof e.size == "number" ? "px" : ""} [${e.endLabel}`, n += r === this.columns.length - 1 ? "]" : "", n;
      }).join(" ")
    };
  }
}
const wn = (t, e) => Object.entries(e).forEach(
  ([r, n]) => n != null && t.style.setProperty(r, `${n}`)
), $n = (t, e) => Array.from(t.style).forEach((r) => {
  r.startsWith(e) && t.style.removeProperty(r);
}), vn = (t) => {
  const e = it(t);
  return e.visible = (r) => e.M(r ? "visible" : "hidden"), e.expanded = (r) => e.M(r ? "expanded" : "collapsed"), e.loc = (r) => e.M(Ue.construct(r)), e.disabled = (r) => r === !0 && e.M("disabled"), e.align = (r) => e.M(r), e.dir = (r) => r != null && e.M(Xt.construct(r)), e.size = (r) => typeof r == "string" && e.M(r), e.sharp = (r) => r !== !1 && e.M("sharp"), e.rounded = (r) => r !== !1 && e.M("rounded"), e.bordered = (r) => typeof r == "boolean" ? r && e.M("bordered") : r != null ? e.M("bordered-" + r) : e.M("bordered"), e.selected = (r) => r && e.M("selected"), e.altColor = (r) => r && e.M("altColor"), e.editable = (r) => r && e.M("editable"), e.noSelect = e.M("no-select"), e.noWrap = (r) => r && e.M("no-wrap"), e.applyVars = wn, e.removeVars = $n, e.newGridBuilder = (r) => new mn(r), e.dropRegion = (r) => r && e.B("haul-drop-region"), e.px = (r) => `${r}px`, e.inheritDims = (r = !0) => r && e.M("inherit-dims"), e.shade = (r) => e.M(`shade-${r}`), e.shadeVar = (r) => `var(--${t}-gray-l${r})`, e;
}, Rn = vn("pluto");
export {
  Te as $,
  Hr as A,
  or as B,
  Rn as C,
  jn as D,
  L as E,
  j as F,
  O as G,
  Lr as H,
  _r as I,
  Ue as J,
  er as K,
  nr as M,
  En as R,
  An as T,
  ct as Z,
  In as _,
  A as a,
  fn as b,
  dn as c,
  Cn as d,
  Dt as e,
  bn as f,
  Xt as g,
  Sn as h,
  cn as i,
  Kr as j,
  zn as k,
  Nn as l,
  ft as m,
  it as n,
  c as o,
  Tn as p,
  Bn as q,
  rr as r,
  $e as s,
  yn as t,
  dt as u,
  qt as v,
  T as w,
  l as x,
  je as y,
  P as z
};
