import { getArrowOffsetToken as m } from "../style/placementArrow.mjs";
function g(l, a, n, s) {
  if (s === !1)
    return {
      adjustX: !1,
      adjustY: !1
    };
  const f = s && typeof s == "object" ? s : {}, o = {};
  switch (l) {
    case "top":
    case "bottom":
      o.shiftX = a.arrowOffsetHorizontal * 2 + n, o.shiftY = !0, o.adjustY = !0;
      break;
    case "left":
    case "right":
      o.shiftY = a.arrowOffsetVertical * 2 + n, o.shiftX = !0, o.adjustX = !0;
      break;
  }
  const r = Object.assign(Object.assign({}, o), f);
  return r.shiftX || (r.adjustX = !0), r.shiftY || (r.adjustY = !0), r;
}
const b = {
  left: {
    points: ["cr", "cl"]
  },
  right: {
    points: ["cl", "cr"]
  },
  top: {
    points: ["bc", "tc"]
  },
  bottom: {
    points: ["tc", "bc"]
  },
  topLeft: {
    points: ["bl", "tl"]
  },
  leftTop: {
    points: ["tr", "tl"]
  },
  topRight: {
    points: ["br", "tr"]
  },
  rightTop: {
    points: ["tl", "tr"]
  },
  bottomRight: {
    points: ["tr", "br"]
  },
  rightBottom: {
    points: ["bl", "br"]
  },
  bottomLeft: {
    points: ["tl", "bl"]
  },
  leftBottom: {
    points: ["br", "bl"]
  }
}, u = {
  topLeft: {
    points: ["bl", "tc"]
  },
  leftTop: {
    points: ["tr", "cl"]
  },
  topRight: {
    points: ["br", "tc"]
  },
  rightTop: {
    points: ["tl", "cr"]
  },
  bottomRight: {
    points: ["tr", "bc"]
  },
  rightBottom: {
    points: ["bl", "cr"]
  },
  bottomLeft: {
    points: ["tl", "bc"]
  },
  leftBottom: {
    points: ["br", "cl"]
  }
}, w = /* @__PURE__ */ new Set(["topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]);
function R(l) {
  const {
    arrowWidth: a,
    autoAdjustOverflow: n,
    arrowPointAtCenter: s,
    offset: f,
    borderRadius: o,
    visibleFirst: r
  } = l, e = a / 2, p = {};
  return Object.keys(b).forEach((i) => {
    const h = s && u[i] || b[i], t = Object.assign(Object.assign({}, h), {
      offset: [0, 0],
      dynamicInset: !0
    });
    switch (p[i] = t, w.has(i) && (t.autoArrow = !1), i) {
      case "top":
      case "topLeft":
      case "topRight":
        t.offset[1] = -e - f;
        break;
      case "bottom":
      case "bottomLeft":
      case "bottomRight":
        t.offset[1] = e + f;
        break;
      case "left":
      case "leftTop":
      case "leftBottom":
        t.offset[0] = -e - f;
        break;
      case "right":
      case "rightTop":
      case "rightBottom":
        t.offset[0] = e + f;
        break;
    }
    const c = m({
      contentRadius: o,
      limitVerticalRadius: !0
    });
    if (s)
      switch (i) {
        case "topLeft":
        case "bottomLeft":
          t.offset[0] = -c.arrowOffsetHorizontal - e;
          break;
        case "topRight":
        case "bottomRight":
          t.offset[0] = c.arrowOffsetHorizontal + e;
          break;
        case "leftTop":
        case "rightTop":
          t.offset[1] = -c.arrowOffsetHorizontal - e;
          break;
        case "leftBottom":
        case "rightBottom":
          t.offset[1] = c.arrowOffsetHorizontal + e;
          break;
      }
    t.overflow = g(i, c, a, n), r && (t.htmlRegion = "visibleFirst");
  }), p;
}
export {
  R as default,
  g as getOverflowOptions
};
