const Y = Math.min, z = Math.max, ot = Math.round, nt = Math.floor, P = (t) => ({
  x: t,
  y: t
}), $t = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
};
function dt(t, e, o) {
  return z(t, Y(e, o));
}
function Z(t, e) {
  return typeof t == "function" ? t(e) : t;
}
function I(t) {
  return t.split("-")[0];
}
function tt(t) {
  return t.split("-")[1];
}
function Et(t) {
  return t === "x" ? "y" : "x";
}
function gt(t) {
  return t === "y" ? "height" : "width";
}
function N(t) {
  const e = t[0];
  return e === "t" || e === "b" ? "y" : "x";
}
function pt(t) {
  return Et(N(t));
}
function _t(t, e, o) {
  o === void 0 && (o = !1);
  const n = tt(t), i = pt(t), r = gt(i);
  let s = i === "x" ? n === (o ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top";
  return e.reference[r] > e.floating[r] && (s = it(s)), [s, it(s)];
}
function Ht(t) {
  const e = it(t);
  return [mt(t), e, mt(e)];
}
function mt(t) {
  return t.includes("start") ? t.replace("start", "end") : t.replace("end", "start");
}
const vt = ["left", "right"], bt = ["right", "left"], zt = ["top", "bottom"], It = ["bottom", "top"];
function Xt(t, e, o) {
  switch (t) {
    case "top":
    case "bottom":
      return o ? e ? bt : vt : e ? vt : bt;
    case "left":
    case "right":
      return e ? zt : It;
    default:
      return [];
  }
}
function jt(t, e, o, n) {
  const i = tt(t);
  let r = Xt(I(t), o === "start", n);
  return i && (r = r.map((s) => s + "-" + i), e && (r = r.concat(r.map(mt)))), r;
}
function it(t) {
  const e = I(t);
  return $t[e] + t.slice(e.length);
}
function Yt(t) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...t
  };
}
function Lt(t) {
  return typeof t != "number" ? Yt(t) : {
    top: t,
    right: t,
    bottom: t,
    left: t
  };
}
function st(t) {
  const {
    x: e,
    y: o,
    width: n,
    height: i
  } = t;
  return {
    width: n,
    height: i,
    top: o,
    left: e,
    right: e + n,
    bottom: o + i,
    x: e,
    y: o
  };
}
function Rt(t, e, o) {
  let {
    reference: n,
    floating: i
  } = t;
  const r = N(e), s = pt(e), c = gt(s), l = I(e), a = r === "y", d = n.x + n.width / 2 - i.width / 2, u = n.y + n.height / 2 - i.height / 2, m = n[c] / 2 - i[c] / 2;
  let f;
  switch (l) {
    case "top":
      f = {
        x: d,
        y: n.y - i.height
      };
      break;
    case "bottom":
      f = {
        x: d,
        y: n.y + n.height
      };
      break;
    case "right":
      f = {
        x: n.x + n.width,
        y: u
      };
      break;
    case "left":
      f = {
        x: n.x - i.width,
        y: u
      };
      break;
    default:
      f = {
        x: n.x,
        y: n.y
      };
  }
  switch (tt(e)) {
    case "start":
      f[s] -= m * (o && a ? -1 : 1);
      break;
    case "end":
      f[s] += m * (o && a ? -1 : 1);
      break;
  }
  return f;
}
async function Tt(t, e) {
  var o;
  e === void 0 && (e = {});
  const {
    x: n,
    y: i,
    platform: r,
    rects: s,
    elements: c,
    strategy: l
  } = t, {
    boundary: a = "clippingAncestors",
    rootBoundary: d = "viewport",
    elementContext: u = "floating",
    altBoundary: m = !1,
    padding: f = 0
  } = Z(e, t), h = Lt(f), w = c[m ? u === "floating" ? "reference" : "floating" : u], p = st(await r.getClippingRect({
    element: (o = await (r.isElement == null ? void 0 : r.isElement(w))) == null || o ? w : w.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(c.floating)),
    boundary: a,
    rootBoundary: d,
    strategy: l
  })), x = u === "floating" ? {
    x: n,
    y: i,
    width: s.floating.width,
    height: s.floating.height
  } : s.reference, y = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c.floating)), v = await (r.isElement == null ? void 0 : r.isElement(y)) ? await (r.getScale == null ? void 0 : r.getScale(y)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, O = st(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: c,
    rect: x,
    offsetParent: y,
    strategy: l
  }) : x);
  return {
    top: (p.top - O.top + h.top) / v.y,
    bottom: (O.bottom - p.bottom + h.bottom) / v.y,
    left: (p.left - O.left + h.left) / v.x,
    right: (O.right - p.right + h.right) / v.x
  };
}
const qt = 50, Ut = async (t, e, o) => {
  const {
    placement: n = "bottom",
    strategy: i = "absolute",
    middleware: r = [],
    platform: s
  } = o, c = s.detectOverflow ? s : {
    ...s,
    detectOverflow: Tt
  }, l = await (s.isRTL == null ? void 0 : s.isRTL(e));
  let a = await s.getElementRects({
    reference: t,
    floating: e,
    strategy: i
  }), {
    x: d,
    y: u
  } = Rt(a, n, l), m = n, f = 0;
  const h = {};
  for (let g = 0; g < r.length; g++) {
    const w = r[g];
    if (!w)
      continue;
    const {
      name: p,
      fn: x
    } = w, {
      x: y,
      y: v,
      data: O,
      reset: b
    } = await x({
      x: d,
      y: u,
      initialPlacement: n,
      placement: m,
      strategy: i,
      middlewareData: h,
      rects: a,
      platform: c,
      elements: {
        reference: t,
        floating: e
      }
    });
    d = y ?? d, u = v ?? u, h[p] = {
      ...h[p],
      ...O
    }, b && f < qt && (f++, typeof b == "object" && (b.placement && (m = b.placement), b.rects && (a = b.rects === !0 ? await s.getElementRects({
      reference: t,
      floating: e,
      strategy: i
    }) : b.rects), {
      x: d,
      y: u
    } = Rt(a, m, l)), g = -1);
  }
  return {
    x: d,
    y: u,
    placement: m,
    strategy: i,
    middlewareData: h
  };
}, Kt = (t) => ({
  name: "arrow",
  options: t,
  async fn(e) {
    const {
      x: o,
      y: n,
      placement: i,
      rects: r,
      platform: s,
      elements: c,
      middlewareData: l
    } = e, {
      element: a,
      padding: d = 0
    } = Z(t, e) || {};
    if (a == null)
      return {};
    const u = Lt(d), m = {
      x: o,
      y: n
    }, f = pt(i), h = gt(f), g = await s.getDimensions(a), w = f === "y", p = w ? "top" : "left", x = w ? "bottom" : "right", y = w ? "clientHeight" : "clientWidth", v = r.reference[h] + r.reference[f] - m[f] - r.floating[h], O = m[f] - r.reference[f], b = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(a));
    let C = b ? b[y] : 0;
    (!C || !await (s.isElement == null ? void 0 : s.isElement(b))) && (C = c.floating[y] || r.floating[h]);
    const K = v / 2 - O / 2, V = C / 2 - g[h] / 2 - 1, F = Y(u[p], V), G = Y(u[x], V), $ = F, J = C - g[h] - G, R = C / 2 - g[h] / 2 + K, _ = dt($, R, J), M = !l.arrow && tt(i) != null && R !== _ && r.reference[h] / 2 - (R < $ ? F : G) - g[h] / 2 < 0, S = M ? R < $ ? R - $ : R - J : 0;
    return {
      [f]: m[f] + S,
      data: {
        [f]: _,
        centerOffset: R - _ - S,
        ...M && {
          alignmentOffset: S
        }
      },
      reset: M
    };
  }
}), Gt = function(t) {
  return t === void 0 && (t = {}), {
    name: "flip",
    options: t,
    async fn(e) {
      var o, n;
      const {
        placement: i,
        middlewareData: r,
        rects: s,
        initialPlacement: c,
        platform: l,
        elements: a
      } = e, {
        mainAxis: d = !0,
        crossAxis: u = !0,
        fallbackPlacements: m,
        fallbackStrategy: f = "bestFit",
        fallbackAxisSideDirection: h = "none",
        flipAlignment: g = !0,
        ...w
      } = Z(t, e);
      if ((o = r.arrow) != null && o.alignmentOffset)
        return {};
      const p = I(i), x = N(c), y = I(c) === c, v = await (l.isRTL == null ? void 0 : l.isRTL(a.floating)), O = m || (y || !g ? [it(c)] : Ht(c)), b = h !== "none";
      !m && b && O.push(...jt(c, g, h, v));
      const C = [c, ...O], K = await l.detectOverflow(e, w), V = [];
      let F = ((n = r.flip) == null ? void 0 : n.overflows) || [];
      if (d && V.push(K[p]), u) {
        const R = _t(i, s, v);
        V.push(K[R[0]], K[R[1]]);
      }
      if (F = [...F, {
        placement: i,
        overflows: V
      }], !V.every((R) => R <= 0)) {
        var G, $;
        const R = (((G = r.flip) == null ? void 0 : G.index) || 0) + 1, _ = C[R];
        if (_ && (!(u === "alignment" ? x !== N(_) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        F.every((E) => N(E.placement) === x ? E.overflows[0] > 0 : !0)))
          return {
            data: {
              index: R,
              overflows: F
            },
            reset: {
              placement: _
            }
          };
        let M = ($ = F.filter((S) => S.overflows[0] <= 0).sort((S, E) => S.overflows[1] - E.overflows[1])[0]) == null ? void 0 : $.placement;
        if (!M)
          switch (f) {
            case "bestFit": {
              var J;
              const S = (J = F.filter((E) => {
                if (b) {
                  const k = N(E.placement);
                  return k === x || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  k === "y";
                }
                return !0;
              }).map((E) => [E.placement, E.overflows.filter((k) => k > 0).reduce((k, Vt) => k + Vt, 0)]).sort((E, k) => E[1] - k[1])[0]) == null ? void 0 : J[0];
              S && (M = S);
              break;
            }
            case "initialPlacement":
              M = c;
              break;
          }
        if (i !== M)
          return {
            reset: {
              placement: M
            }
          };
      }
      return {};
    }
  };
}, Jt = /* @__PURE__ */ new Set(["left", "top"]);
async function Qt(t, e) {
  const {
    placement: o,
    platform: n,
    elements: i
  } = t, r = await (n.isRTL == null ? void 0 : n.isRTL(i.floating)), s = I(o), c = tt(o), l = N(o) === "y", a = Jt.has(s) ? -1 : 1, d = r && l ? -1 : 1, u = Z(e, t);
  let {
    mainAxis: m,
    crossAxis: f,
    alignmentAxis: h
  } = typeof u == "number" ? {
    mainAxis: u,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: u.mainAxis || 0,
    crossAxis: u.crossAxis || 0,
    alignmentAxis: u.alignmentAxis
  };
  return c && typeof h == "number" && (f = c === "end" ? h * -1 : h), l ? {
    x: f * d,
    y: m * a
  } : {
    x: m * a,
    y: f * d
  };
}
const Zt = function(t) {
  return t === void 0 && (t = 0), {
    name: "offset",
    options: t,
    async fn(e) {
      var o, n;
      const {
        x: i,
        y: r,
        placement: s,
        middlewareData: c
      } = e, l = await Qt(e, t);
      return s === ((o = c.offset) == null ? void 0 : o.placement) && (n = c.arrow) != null && n.alignmentOffset ? {} : {
        x: i + l.x,
        y: r + l.y,
        data: {
          ...l,
          placement: s
        }
      };
    }
  };
}, te = function(t) {
  return t === void 0 && (t = {}), {
    name: "shift",
    options: t,
    async fn(e) {
      const {
        x: o,
        y: n,
        placement: i,
        platform: r
      } = e, {
        mainAxis: s = !0,
        crossAxis: c = !1,
        limiter: l = {
          fn: (p) => {
            let {
              x,
              y
            } = p;
            return {
              x,
              y
            };
          }
        },
        ...a
      } = Z(t, e), d = {
        x: o,
        y: n
      }, u = await r.detectOverflow(e, a), m = N(I(i)), f = Et(m);
      let h = d[f], g = d[m];
      if (s) {
        const p = f === "y" ? "top" : "left", x = f === "y" ? "bottom" : "right", y = h + u[p], v = h - u[x];
        h = dt(y, h, v);
      }
      if (c) {
        const p = m === "y" ? "top" : "left", x = m === "y" ? "bottom" : "right", y = g + u[p], v = g - u[x];
        g = dt(y, g, v);
      }
      const w = l.fn({
        ...e,
        [f]: h,
        [m]: g
      });
      return {
        ...w,
        data: {
          x: w.x - o,
          y: w.y - n,
          enabled: {
            [f]: s,
            [m]: c
          }
        }
      };
    }
  };
};
function rt() {
  return typeof window < "u";
}
function U(t) {
  return Pt(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function A(t) {
  var e;
  return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
}
function D(t) {
  var e;
  return (e = (Pt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
}
function Pt(t) {
  return rt() ? t instanceof Node || t instanceof A(t).Node : !1;
}
function L(t) {
  return rt() ? t instanceof Element || t instanceof A(t).Element : !1;
}
function W(t) {
  return rt() ? t instanceof HTMLElement || t instanceof A(t).HTMLElement : !1;
}
function Ot(t) {
  return !rt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof A(t).ShadowRoot;
}
function et(t) {
  const {
    overflow: e,
    overflowX: o,
    overflowY: n,
    display: i
  } = T(t);
  return /auto|scroll|overlay|hidden|clip/.test(e + n + o) && i !== "inline" && i !== "contents";
}
function ee(t) {
  return /^(table|td|th)$/.test(U(t));
}
function ct(t) {
  try {
    if (t.matches(":popover-open"))
      return !0;
  } catch {
  }
  try {
    return t.matches(":modal");
  } catch {
    return !1;
  }
}
const ne = /transform|translate|scale|rotate|perspective|filter/, oe = /paint|layout|strict|content/, H = (t) => !!t && t !== "none";
let at;
function wt(t) {
  const e = L(t) ? T(t) : t;
  return H(e.transform) || H(e.translate) || H(e.scale) || H(e.rotate) || H(e.perspective) || !xt() && (H(e.backdropFilter) || H(e.filter)) || ne.test(e.willChange || "") || oe.test(e.contain || "");
}
function ie(t) {
  let e = B(t);
  for (; W(e) && !q(e); ) {
    if (wt(e))
      return e;
    if (ct(e))
      return null;
    e = B(e);
  }
  return null;
}
function xt() {
  return at == null && (at = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), at;
}
function q(t) {
  return /^(html|body|#document)$/.test(U(t));
}
function T(t) {
  return A(t).getComputedStyle(t);
}
function lt(t) {
  return L(t) ? {
    scrollLeft: t.scrollLeft,
    scrollTop: t.scrollTop
  } : {
    scrollLeft: t.scrollX,
    scrollTop: t.scrollY
  };
}
function B(t) {
  if (U(t) === "html")
    return t;
  const e = (
    // Step into the shadow DOM of the parent of a slotted node.
    t.assignedSlot || // DOM Element detected.
    t.parentNode || // ShadowRoot detected.
    Ot(t) && t.host || // Fallback.
    D(t)
  );
  return Ot(e) ? e.host : e;
}
function Dt(t) {
  const e = B(t);
  return q(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : W(e) && et(e) ? e : Dt(e);
}
function Q(t, e, o) {
  var n;
  e === void 0 && (e = []), o === void 0 && (o = !0);
  const i = Dt(t), r = i === ((n = t.ownerDocument) == null ? void 0 : n.body), s = A(i);
  if (r) {
    const c = ht(s);
    return e.concat(s, s.visualViewport || [], et(i) ? i : [], c && o ? Q(c) : []);
  } else
    return e.concat(i, Q(i, [], o));
}
function ht(t) {
  return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
function Ft(t) {
  const e = T(t);
  let o = parseFloat(e.width) || 0, n = parseFloat(e.height) || 0;
  const i = W(t), r = i ? t.offsetWidth : o, s = i ? t.offsetHeight : n, c = ot(o) !== r || ot(n) !== s;
  return c && (o = r, n = s), {
    width: o,
    height: n,
    $: c
  };
}
function yt(t) {
  return L(t) ? t : t.contextElement;
}
function j(t) {
  const e = yt(t);
  if (!W(e))
    return P(1);
  const o = e.getBoundingClientRect(), {
    width: n,
    height: i,
    $: r
  } = Ft(e);
  let s = (r ? ot(o.width) : o.width) / n, c = (r ? ot(o.height) : o.height) / i;
  return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), {
    x: s,
    y: c
  };
}
const se = /* @__PURE__ */ P(0);
function Mt(t) {
  const e = A(t);
  return !xt() || !e.visualViewport ? se : {
    x: e.visualViewport.offsetLeft,
    y: e.visualViewport.offsetTop
  };
}
function re(t, e, o) {
  return e === void 0 && (e = !1), !o || e && o !== A(t) ? !1 : e;
}
function X(t, e, o, n) {
  e === void 0 && (e = !1), o === void 0 && (o = !1);
  const i = t.getBoundingClientRect(), r = yt(t);
  let s = P(1);
  e && (n ? L(n) && (s = j(n)) : s = j(t));
  const c = re(r, o, n) ? Mt(r) : P(0);
  let l = (i.left + c.x) / s.x, a = (i.top + c.y) / s.y, d = i.width / s.x, u = i.height / s.y;
  if (r) {
    const m = A(r), f = n && L(n) ? A(n) : n;
    let h = m, g = ht(h);
    for (; g && n && f !== h; ) {
      const w = j(g), p = g.getBoundingClientRect(), x = T(g), y = p.left + (g.clientLeft + parseFloat(x.paddingLeft)) * w.x, v = p.top + (g.clientTop + parseFloat(x.paddingTop)) * w.y;
      l *= w.x, a *= w.y, d *= w.x, u *= w.y, l += y, a += v, h = A(g), g = ht(h);
    }
  }
  return st({
    width: d,
    height: u,
    x: l,
    y: a
  });
}
function ft(t, e) {
  const o = lt(t).scrollLeft;
  return e ? e.left + o : X(D(t)).left + o;
}
function Wt(t, e) {
  const o = t.getBoundingClientRect(), n = o.left + e.scrollLeft - ft(t, o), i = o.top + e.scrollTop;
  return {
    x: n,
    y: i
  };
}
function ce(t) {
  let {
    elements: e,
    rect: o,
    offsetParent: n,
    strategy: i
  } = t;
  const r = i === "fixed", s = D(n), c = e ? ct(e.floating) : !1;
  if (n === s || c && r)
    return o;
  let l = {
    scrollLeft: 0,
    scrollTop: 0
  }, a = P(1);
  const d = P(0), u = W(n);
  if ((u || !u && !r) && ((U(n) !== "body" || et(s)) && (l = lt(n)), u)) {
    const f = X(n);
    a = j(n), d.x = f.x + n.clientLeft, d.y = f.y + n.clientTop;
  }
  const m = s && !u && !r ? Wt(s, l) : P(0);
  return {
    width: o.width * a.x,
    height: o.height * a.y,
    x: o.x * a.x - l.scrollLeft * a.x + d.x + m.x,
    y: o.y * a.y - l.scrollTop * a.y + d.y + m.y
  };
}
function le(t) {
  return Array.from(t.getClientRects());
}
function fe(t) {
  const e = D(t), o = lt(t), n = t.ownerDocument.body, i = z(e.scrollWidth, e.clientWidth, n.scrollWidth, n.clientWidth), r = z(e.scrollHeight, e.clientHeight, n.scrollHeight, n.clientHeight);
  let s = -o.scrollLeft + ft(t);
  const c = -o.scrollTop;
  return T(n).direction === "rtl" && (s += z(e.clientWidth, n.clientWidth) - i), {
    width: i,
    height: r,
    x: s,
    y: c
  };
}
const At = 25;
function ae(t, e) {
  const o = A(t), n = D(t), i = o.visualViewport;
  let r = n.clientWidth, s = n.clientHeight, c = 0, l = 0;
  if (i) {
    r = i.width, s = i.height;
    const d = xt();
    (!d || d && e === "fixed") && (c = i.offsetLeft, l = i.offsetTop);
  }
  const a = ft(n);
  if (a <= 0) {
    const d = n.ownerDocument, u = d.body, m = getComputedStyle(u), f = d.compatMode === "CSS1Compat" && parseFloat(m.marginLeft) + parseFloat(m.marginRight) || 0, h = Math.abs(n.clientWidth - u.clientWidth - f);
    h <= At && (r -= h);
  } else a <= At && (r += a);
  return {
    width: r,
    height: s,
    x: c,
    y: l
  };
}
function ue(t, e) {
  const o = X(t, !0, e === "fixed"), n = o.top + t.clientTop, i = o.left + t.clientLeft, r = W(t) ? j(t) : P(1), s = t.clientWidth * r.x, c = t.clientHeight * r.y, l = i * r.x, a = n * r.y;
  return {
    width: s,
    height: c,
    x: l,
    y: a
  };
}
function Ct(t, e, o) {
  let n;
  if (e === "viewport")
    n = ae(t, o);
  else if (e === "document")
    n = fe(D(t));
  else if (L(e))
    n = ue(e, o);
  else {
    const i = Mt(t);
    n = {
      x: e.x - i.x,
      y: e.y - i.y,
      width: e.width,
      height: e.height
    };
  }
  return st(n);
}
function kt(t, e) {
  const o = B(t);
  return o === e || !L(o) || q(o) ? !1 : T(o).position === "fixed" || kt(o, e);
}
function de(t, e) {
  const o = e.get(t);
  if (o)
    return o;
  let n = Q(t, [], !1).filter((c) => L(c) && U(c) !== "body"), i = null;
  const r = T(t).position === "fixed";
  let s = r ? B(t) : t;
  for (; L(s) && !q(s); ) {
    const c = T(s), l = wt(s);
    !l && c.position === "fixed" && (i = null), (r ? !l && !i : !l && c.position === "static" && !!i && (i.position === "absolute" || i.position === "fixed") || et(s) && !l && kt(t, s)) ? n = n.filter((d) => d !== s) : i = c, s = B(s);
  }
  return e.set(t, n), n;
}
function me(t) {
  let {
    element: e,
    boundary: o,
    rootBoundary: n,
    strategy: i
  } = t;
  const s = [...o === "clippingAncestors" ? ct(e) ? [] : de(e, this._c) : [].concat(o), n], c = Ct(e, s[0], i);
  let l = c.top, a = c.right, d = c.bottom, u = c.left;
  for (let m = 1; m < s.length; m++) {
    const f = Ct(e, s[m], i);
    l = z(f.top, l), a = Y(f.right, a), d = Y(f.bottom, d), u = z(f.left, u);
  }
  return {
    width: a - u,
    height: d - l,
    x: u,
    y: l
  };
}
function he(t) {
  const {
    width: e,
    height: o
  } = Ft(t);
  return {
    width: e,
    height: o
  };
}
function ge(t, e, o) {
  const n = W(e), i = D(e), r = o === "fixed", s = X(t, !0, r, e);
  let c = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const l = P(0);
  function a() {
    l.x = ft(i);
  }
  if (n || !n && !r)
    if ((U(e) !== "body" || et(i)) && (c = lt(e)), n) {
      const f = X(e, !0, r, e);
      l.x = f.x + e.clientLeft, l.y = f.y + e.clientTop;
    } else i && a();
  r && !n && i && a();
  const d = i && !n && !r ? Wt(i, c) : P(0), u = s.left + c.scrollLeft - l.x - d.x, m = s.top + c.scrollTop - l.y - d.y;
  return {
    x: u,
    y: m,
    width: s.width,
    height: s.height
  };
}
function ut(t) {
  return T(t).position === "static";
}
function St(t, e) {
  if (!W(t) || T(t).position === "fixed")
    return null;
  if (e)
    return e(t);
  let o = t.offsetParent;
  return D(t) === o && (o = o.ownerDocument.body), o;
}
function Nt(t, e) {
  const o = A(t);
  if (ct(t))
    return o;
  if (!W(t)) {
    let i = B(t);
    for (; i && !q(i); ) {
      if (L(i) && !ut(i))
        return i;
      i = B(i);
    }
    return o;
  }
  let n = St(t, e);
  for (; n && ee(n) && ut(n); )
    n = St(n, e);
  return n && q(n) && ut(n) && !wt(n) ? o : n || ie(t) || o;
}
const pe = async function(t) {
  const e = this.getOffsetParent || Nt, o = this.getDimensions, n = await o(t.floating);
  return {
    reference: ge(t.reference, await e(t.floating), t.strategy),
    floating: {
      x: 0,
      y: 0,
      width: n.width,
      height: n.height
    }
  };
};
function we(t) {
  return T(t).direction === "rtl";
}
const xe = {
  convertOffsetParentRelativeRectToViewportRelativeRect: ce,
  getDocumentElement: D,
  getClippingRect: me,
  getOffsetParent: Nt,
  getElementRects: pe,
  getClientRects: le,
  getDimensions: he,
  getScale: j,
  isElement: L,
  isRTL: we
};
function Bt(t, e) {
  return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
}
function ye(t, e) {
  let o = null, n;
  const i = D(t);
  function r() {
    var c;
    clearTimeout(n), (c = o) == null || c.disconnect(), o = null;
  }
  function s(c, l) {
    c === void 0 && (c = !1), l === void 0 && (l = 1), r();
    const a = t.getBoundingClientRect(), {
      left: d,
      top: u,
      width: m,
      height: f
    } = a;
    if (c || e(), !m || !f)
      return;
    const h = nt(u), g = nt(i.clientWidth - (d + m)), w = nt(i.clientHeight - (u + f)), p = nt(d), y = {
      rootMargin: -h + "px " + -g + "px " + -w + "px " + -p + "px",
      threshold: z(0, Y(1, l)) || 1
    };
    let v = !0;
    function O(b) {
      const C = b[0].intersectionRatio;
      if (C !== l) {
        if (!v)
          return s();
        C ? s(!1, C) : n = setTimeout(() => {
          s(!1, 1e-7);
        }, 1e3);
      }
      C === 1 && !Bt(a, t.getBoundingClientRect()) && s(), v = !1;
    }
    try {
      o = new IntersectionObserver(O, {
        ...y,
        // Handle <iframe>s
        root: i.ownerDocument
      });
    } catch {
      o = new IntersectionObserver(O, y);
    }
    o.observe(t);
  }
  return s(!0), r;
}
function ve(t, e, o, n) {
  n === void 0 && (n = {});
  const {
    ancestorScroll: i = !0,
    ancestorResize: r = !0,
    elementResize: s = typeof ResizeObserver == "function",
    layoutShift: c = typeof IntersectionObserver == "function",
    animationFrame: l = !1
  } = n, a = yt(t), d = i || r ? [...a ? Q(a) : [], ...e ? Q(e) : []] : [];
  d.forEach((p) => {
    i && p.addEventListener("scroll", o, {
      passive: !0
    }), r && p.addEventListener("resize", o);
  });
  const u = a && c ? ye(a, o) : null;
  let m = -1, f = null;
  s && (f = new ResizeObserver((p) => {
    let [x] = p;
    x && x.target === a && f && e && (f.unobserve(e), cancelAnimationFrame(m), m = requestAnimationFrame(() => {
      var y;
      (y = f) == null || y.observe(e);
    })), o();
  }), a && !l && f.observe(a), e && f.observe(e));
  let h, g = l ? X(t) : null;
  l && w();
  function w() {
    const p = X(t);
    g && !Bt(g, p) && o(), g = p, h = requestAnimationFrame(w);
  }
  return o(), () => {
    var p;
    d.forEach((x) => {
      i && x.removeEventListener("scroll", o), r && x.removeEventListener("resize", o);
    }), u == null || u(), (p = f) == null || p.disconnect(), f = null, l && cancelAnimationFrame(h);
  };
}
const be = Tt, Re = Zt, Oe = te, Ae = Gt, Ce = Kt, Se = (t, e, o) => {
  const n = /* @__PURE__ */ new Map(), i = {
    platform: xe,
    ...o
  }, r = {
    ...i.platform,
    _c: n
  };
  return Ut(t, e, {
    ...i,
    platform: r
  });
};
export {
  Ce as a,
  ve as b,
  Se as c,
  be as d,
  Ae as f,
  Re as o,
  Oe as s
};
