const S = ["top", "right", "bottom", "left"], m = Math.min, h = Math.max, j = Math.round, w = Math.floor, C = (t) => ({
  x: t,
  y: t
}), p = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
};
function L(t, n, e) {
  return h(t, m(n, e));
}
function k(t, n) {
  return typeof t == "function" ? t(n) : t;
}
function l(t) {
  return t.split("-")[0];
}
function g(t) {
  return t.split("-")[1];
}
function b(t) {
  return t === "x" ? "y" : "x";
}
function d(t) {
  return t === "y" ? "height" : "width";
}
function x(t) {
  const n = t[0];
  return n === "t" || n === "b" ? "y" : "x";
}
function A(t) {
  return b(x(t));
}
function q(t, n, e) {
  e === void 0 && (e = !1);
  const s = g(t), i = A(t), o = d(i);
  let r = i === "x" ? s === (e ? "end" : "start") ? "right" : "left" : s === "start" ? "bottom" : "top";
  return n.reference[o] > n.floating[o] && (r = a(r)), [r, a(r)];
}
function E(t) {
  const n = a(t);
  return [c(t), n, c(n)];
}
function c(t) {
  return t.includes("start") ? t.replace("start", "end") : t.replace("end", "start");
}
const f = ["left", "right"], u = ["right", "left"], P = ["top", "bottom"], y = ["bottom", "top"];
function O(t, n, e) {
  switch (t) {
    case "top":
    case "bottom":
      return e ? n ? u : f : n ? f : u;
    case "left":
    case "right":
      return n ? P : y;
    default:
      return [];
  }
}
function R(t, n, e, s) {
  const i = g(t);
  let o = O(l(t), e === "start", s);
  return i && (o = o.map((r) => r + "-" + i), n && (o = o.concat(o.map(c)))), o;
}
function a(t) {
  const n = l(t);
  return p[n] + t.slice(n.length);
}
function M(t) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...t
  };
}
function T(t) {
  return typeof t != "number" ? M(t) : {
    top: t,
    right: t,
    bottom: t,
    left: t
  };
}
function z(t) {
  const {
    x: n,
    y: e,
    width: s,
    height: i
  } = t;
  return {
    width: s,
    height: i,
    top: e,
    left: n,
    right: n + s,
    bottom: e + i,
    x: n,
    y: e
  };
}
export {
  x as a,
  a as b,
  E as c,
  R as d,
  k as e,
  w as f,
  l as g,
  q as h,
  g as i,
  h as j,
  A as k,
  T as l,
  m,
  d as n,
  L as o,
  b as p,
  C as q,
  z as r,
  S as s,
  j as t
};
