"use client";
import * as O from "react";
import { useLayoutEffect as Xt } from "react";
import * as qt from "react-dom";
function at() {
  return typeof window < "u";
}
function Z(t) {
  return kt(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function M(t) {
  var e;
  return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
}
function H(t) {
  var e;
  return (e = (kt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
}
function kt(t) {
  return at() ? t instanceof Node || t instanceof M(t).Node : !1;
}
function F(t) {
  return at() ? t instanceof Element || t instanceof M(t).Element : !1;
}
function N(t) {
  return at() ? t instanceof HTMLElement || t instanceof M(t).HTMLElement : !1;
}
function At(t) {
  return !at() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof M(t).ShadowRoot;
}
const Yt = /* @__PURE__ */ new Set(["inline", "contents"]);
function nt(t) {
  const {
    overflow: e,
    overflowX: n,
    overflowY: o,
    display: i
  } = W(t);
  return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !Yt.has(i);
}
const Ut = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Kt(t) {
  return Ut.has(Z(t));
}
const Gt = [":popover-open", ":modal"];
function ut(t) {
  return Gt.some((e) => {
    try {
      return t.matches(e);
    } catch {
      return !1;
    }
  });
}
const Jt = ["transform", "translate", "scale", "rotate", "perspective"], Qt = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Zt = ["paint", "layout", "strict", "content"];
function xt(t) {
  const e = yt(), n = F(t) ? W(t) : t;
  return Jt.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || Qt.some((o) => (n.willChange || "").includes(o)) || Zt.some((o) => (n.contain || "").includes(o));
}
function te(t) {
  let e = q(t);
  for (; N(e) && !J(e); ) {
    if (xt(e))
      return e;
    if (ut(e))
      return null;
    e = q(e);
  }
  return null;
}
function yt() {
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const ee = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function J(t) {
  return ee.has(Z(t));
}
function W(t) {
  return M(t).getComputedStyle(t);
}
function dt(t) {
  return F(t) ? {
    scrollLeft: t.scrollLeft,
    scrollTop: t.scrollTop
  } : {
    scrollLeft: t.scrollX,
    scrollTop: t.scrollY
  };
}
function q(t) {
  if (Z(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.
    At(t) && t.host || // Fallback.
    H(t)
  );
  return At(e) ? e.host : e;
}
function Ft(t) {
  const e = q(t);
  return J(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : N(e) && nt(e) ? e : Ft(e);
}
function tt(t, e, n) {
  var o;
  e === void 0 && (e = []), n === void 0 && (n = !0);
  const i = Ft(t), s = i === ((o = t.ownerDocument) == null ? void 0 : o.body), r = M(i);
  if (s) {
    const c = pt(r);
    return e.concat(r, r.visualViewport || [], nt(i) ? i : [], c && n ? tt(c) : []);
  }
  return e.concat(i, tt(i, [], n));
}
function pt(t) {
  return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
const ne = ["top", "right", "bottom", "left"], Q = Math.min, T = Math.max, rt = Math.round, it = Math.floor, V = (t) => ({
  x: t,
  y: t
}), oe = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, ie = {
  start: "end",
  end: "start"
};
function Rt(t, e, n) {
  return T(t, Q(e, n));
}
function Y(t, e) {
  return typeof t == "function" ? t(e) : t;
}
function j(t) {
  return t.split("-")[0];
}
function ot(t) {
  return t.split("-")[1];
}
function vt(t) {
  return t === "x" ? "y" : "x";
}
function Wt(t) {
  return t === "y" ? "height" : "width";
}
const se = /* @__PURE__ */ new Set(["top", "bottom"]);
function $(t) {
  return se.has(j(t)) ? "y" : "x";
}
function Bt(t) {
  return vt($(t));
}
function re(t, e, n) {
  n === void 0 && (n = !1);
  const o = ot(t), i = Bt(t), s = Wt(i);
  let r = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
  return e.reference[s] > e.floating[s] && (r = ct(r)), [r, ct(r)];
}
function ce(t) {
  const e = ct(t);
  return [wt(t), e, wt(e)];
}
function wt(t) {
  return t.replace(/start|end/g, (e) => ie[e]);
}
const St = ["left", "right"], Ot = ["right", "left"], le = ["top", "bottom"], fe = ["bottom", "top"];
function ae(t, e, n) {
  switch (t) {
    case "top":
    case "bottom":
      return n ? e ? Ot : St : e ? St : Ot;
    case "left":
    case "right":
      return e ? le : fe;
    default:
      return [];
  }
}
function ue(t, e, n, o) {
  const i = ot(t);
  let s = ae(j(t), n === "start", o);
  return i && (s = s.map((r) => r + "-" + i), e && (s = s.concat(s.map(wt)))), s;
}
function ct(t) {
  return t.replace(/left|right|bottom|top/g, (e) => oe[e]);
}
function de(t) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...t
  };
}
function me(t) {
  return typeof t != "number" ? de(t) : {
    top: t,
    right: t,
    bottom: t,
    left: t
  };
}
function lt(t) {
  const {
    x: e,
    y: n,
    width: o,
    height: i
  } = t;
  return {
    width: o,
    height: i,
    top: n,
    left: e,
    right: e + o,
    bottom: n + i,
    x: e,
    y: n
  };
}
function Ct(t, e, n) {
  let {
    reference: o,
    floating: i
  } = t;
  const s = $(e), r = Bt(e), c = Wt(r), f = j(e), a = s === "y", l = o.x + o.width / 2 - i.width / 2, u = o.y + o.height / 2 - i.height / 2, m = o[c] / 2 - i[c] / 2;
  let d;
  switch (f) {
    case "top":
      d = {
        x: l,
        y: o.y - i.height
      };
      break;
    case "bottom":
      d = {
        x: l,
        y: o.y + o.height
      };
      break;
    case "right":
      d = {
        x: o.x + o.width,
        y: u
      };
      break;
    case "left":
      d = {
        x: o.x - i.width,
        y: u
      };
      break;
    default:
      d = {
        x: o.x,
        y: o.y
      };
  }
  switch (ot(e)) {
    case "start":
      d[r] -= m * (n && a ? -1 : 1);
      break;
    case "end":
      d[r] += m * (n && a ? -1 : 1);
      break;
  }
  return d;
}
const he = async (t, e, n) => {
  const {
    placement: o = "bottom",
    strategy: i = "absolute",
    middleware: s = [],
    platform: r
  } = n, c = s.filter(Boolean), f = await (r.isRTL == null ? void 0 : r.isRTL(e));
  let a = await r.getElementRects({
    reference: t,
    floating: e,
    strategy: i
  }), {
    x: l,
    y: u
  } = Ct(a, o, f), m = o, d = {}, h = 0;
  for (let p = 0; p < c.length; p++) {
    const {
      name: w,
      fn: g
    } = c[p], {
      x,
      y: v,
      data: b,
      reset: y
    } = await g({
      x: l,
      y: u,
      initialPlacement: o,
      placement: m,
      strategy: i,
      middlewareData: d,
      rects: a,
      platform: r,
      elements: {
        reference: t,
        floating: e
      }
    });
    l = x ?? l, u = v ?? u, d = {
      ...d,
      [w]: {
        ...d[w],
        ...b
      }
    }, y && h <= 50 && (h++, typeof y == "object" && (y.placement && (m = y.placement), y.rects && (a = y.rects === !0 ? await r.getElementRects({
      reference: t,
      floating: e,
      strategy: i
    }) : y.rects), {
      x: l,
      y: u
    } = Ct(a, m, f)), p = -1);
  }
  return {
    x: l,
    y: u,
    placement: m,
    strategy: i,
    middlewareData: d
  };
};
async function et(t, e) {
  var n;
  e === void 0 && (e = {});
  const {
    x: o,
    y: i,
    platform: s,
    rects: r,
    elements: c,
    strategy: f
  } = t, {
    boundary: a = "clippingAncestors",
    rootBoundary: l = "viewport",
    elementContext: u = "floating",
    altBoundary: m = !1,
    padding: d = 0
  } = Y(e, t), h = me(d), w = c[m ? u === "floating" ? "reference" : "floating" : u], g = lt(await s.getClippingRect({
    element: (n = await (s.isElement == null ? void 0 : s.isElement(w))) == null || n ? w : w.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(c.floating)),
    boundary: a,
    rootBoundary: l,
    strategy: f
  })), x = u === "floating" ? {
    x: o,
    y: i,
    width: r.floating.width,
    height: r.floating.height
  } : r.reference, v = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c.floating)), b = await (s.isElement == null ? void 0 : s.isElement(v)) ? await (s.getScale == null ? void 0 : s.getScale(v)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, y = lt(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: c,
    rect: x,
    offsetParent: v,
    strategy: f
  }) : x);
  return {
    top: (g.top - y.top + h.top) / b.y,
    bottom: (y.bottom - g.bottom + h.bottom) / b.y,
    left: (g.left - y.left + h.left) / b.x,
    right: (y.right - g.right + h.right) / b.x
  };
}
const ge = function(t) {
  return t === void 0 && (t = {}), {
    name: "flip",
    options: t,
    async fn(e) {
      var n, o;
      const {
        placement: i,
        middlewareData: s,
        rects: r,
        initialPlacement: c,
        platform: f,
        elements: a
      } = e, {
        mainAxis: l = !0,
        crossAxis: u = !0,
        fallbackPlacements: m,
        fallbackStrategy: d = "bestFit",
        fallbackAxisSideDirection: h = "none",
        flipAlignment: p = !0,
        ...w
      } = Y(t, e);
      if ((n = s.arrow) != null && n.alignmentOffset)
        return {};
      const g = j(i), x = $(c), v = j(c) === c, b = await (f.isRTL == null ? void 0 : f.isRTL(a.floating)), y = m || (v || !p ? [ct(c)] : ce(c)), R = h !== "none";
      !m && R && y.push(...ue(c, p, h, b));
      const S = [c, ...y], D = await et(e, w), _ = [];
      let C = ((o = s.flip) == null ? void 0 : o.overflows) || [];
      if (l && _.push(D[g]), u) {
        const k = re(i, r, b);
        _.push(D[k[0]], D[k[1]]);
      }
      if (C = [...C, {
        placement: i,
        overflows: _
      }], !_.every((k) => k <= 0)) {
        var z, I;
        const k = (((z = s.flip) == null ? void 0 : z.index) || 0) + 1, K = S[k];
        if (K && (!(u === "alignment" ? x !== $(K) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        C.every((A) => $(A.placement) === x ? A.overflows[0] > 0 : !0)))
          return {
            data: {
              index: k,
              overflows: C
            },
            reset: {
              placement: K
            }
          };
        let L = (I = C.filter((B) => B.overflows[0] <= 0).sort((B, A) => B.overflows[1] - A.overflows[1])[0]) == null ? void 0 : I.placement;
        if (!L)
          switch (d) {
            case "bestFit": {
              var P;
              const B = (P = C.filter((A) => {
                if (R) {
                  const E = $(A.placement);
                  return E === x || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  E === "y";
                }
                return !0;
              }).map((A) => [A.placement, A.overflows.filter((E) => E > 0).reduce((E, X) => E + X, 0)]).sort((A, E) => A[1] - E[1])[0]) == null ? void 0 : P[0];
              B && (L = B);
              break;
            }
            case "initialPlacement":
              L = c;
              break;
          }
        if (i !== L)
          return {
            reset: {
              placement: L
            }
          };
      }
      return {};
    }
  };
};
function Lt(t, e) {
  return {
    top: t.top - e.height,
    right: t.right - e.width,
    bottom: t.bottom - e.height,
    left: t.left - e.width
  };
}
function Et(t) {
  return ne.some((e) => t[e] >= 0);
}
const pe = function(t) {
  return t === void 0 && (t = {}), {
    name: "hide",
    options: t,
    async fn(e) {
      const {
        rects: n
      } = e, {
        strategy: o = "referenceHidden",
        ...i
      } = Y(t, e);
      switch (o) {
        case "referenceHidden": {
          const s = await et(e, {
            ...i,
            elementContext: "reference"
          }), r = Lt(s, n.reference);
          return {
            data: {
              referenceHiddenOffsets: r,
              referenceHidden: Et(r)
            }
          };
        }
        case "escaped": {
          const s = await et(e, {
            ...i,
            altBoundary: !0
          }), r = Lt(s, n.floating);
          return {
            data: {
              escapedOffsets: r,
              escaped: Et(r)
            }
          };
        }
        default:
          return {};
      }
    }
  };
}, $t = /* @__PURE__ */ new Set(["left", "top"]);
async function we(t, e) {
  const {
    placement: n,
    platform: o,
    elements: i
  } = t, s = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), r = j(n), c = ot(n), f = $(n) === "y", a = $t.has(r) ? -1 : 1, l = s && f ? -1 : 1, u = Y(e, t);
  let {
    mainAxis: m,
    crossAxis: d,
    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" && (d = c === "end" ? h * -1 : h), f ? {
    x: d * l,
    y: m * a
  } : {
    x: m * a,
    y: d * l
  };
}
const xe = function(t) {
  return t === void 0 && (t = 0), {
    name: "offset",
    options: t,
    async fn(e) {
      var n, o;
      const {
        x: i,
        y: s,
        placement: r,
        middlewareData: c
      } = e, f = await we(e, t);
      return r === ((n = c.offset) == null ? void 0 : n.placement) && (o = c.arrow) != null && o.alignmentOffset ? {} : {
        x: i + f.x,
        y: s + f.y,
        data: {
          ...f,
          placement: r
        }
      };
    }
  };
}, ye = function(t) {
  return t === void 0 && (t = {}), {
    name: "shift",
    options: t,
    async fn(e) {
      const {
        x: n,
        y: o,
        placement: i
      } = e, {
        mainAxis: s = !0,
        crossAxis: r = !1,
        limiter: c = {
          fn: (w) => {
            let {
              x: g,
              y: x
            } = w;
            return {
              x: g,
              y: x
            };
          }
        },
        ...f
      } = Y(t, e), a = {
        x: n,
        y: o
      }, l = await et(e, f), u = $(j(i)), m = vt(u);
      let d = a[m], h = a[u];
      if (s) {
        const w = m === "y" ? "top" : "left", g = m === "y" ? "bottom" : "right", x = d + l[w], v = d - l[g];
        d = Rt(x, d, v);
      }
      if (r) {
        const w = u === "y" ? "top" : "left", g = u === "y" ? "bottom" : "right", x = h + l[w], v = h - l[g];
        h = Rt(x, h, v);
      }
      const p = c.fn({
        ...e,
        [m]: d,
        [u]: h
      });
      return {
        ...p,
        data: {
          x: p.x - n,
          y: p.y - o,
          enabled: {
            [m]: s,
            [u]: r
          }
        }
      };
    }
  };
}, ve = function(t) {
  return t === void 0 && (t = {}), {
    options: t,
    fn(e) {
      const {
        x: n,
        y: o,
        placement: i,
        rects: s,
        middlewareData: r
      } = e, {
        offset: c = 0,
        mainAxis: f = !0,
        crossAxis: a = !0
      } = Y(t, e), l = {
        x: n,
        y: o
      }, u = $(i), m = vt(u);
      let d = l[m], h = l[u];
      const p = Y(c, e), w = typeof p == "number" ? {
        mainAxis: p,
        crossAxis: 0
      } : {
        mainAxis: 0,
        crossAxis: 0,
        ...p
      };
      if (f) {
        const v = m === "y" ? "height" : "width", b = s.reference[m] - s.floating[v] + w.mainAxis, y = s.reference[m] + s.reference[v] - w.mainAxis;
        d < b ? d = b : d > y && (d = y);
      }
      if (a) {
        var g, x;
        const v = m === "y" ? "width" : "height", b = $t.has(j(i)), y = s.reference[u] - s.floating[v] + (b && ((g = r.offset) == null ? void 0 : g[u]) || 0) + (b ? 0 : w.crossAxis), R = s.reference[u] + s.reference[v] + (b ? 0 : ((x = r.offset) == null ? void 0 : x[u]) || 0) - (b ? w.crossAxis : 0);
        h < y ? h = y : h > R && (h = R);
      }
      return {
        [m]: d,
        [u]: h
      };
    }
  };
}, be = function(t) {
  return t === void 0 && (t = {}), {
    name: "size",
    options: t,
    async fn(e) {
      var n, o;
      const {
        placement: i,
        rects: s,
        platform: r,
        elements: c
      } = e, {
        apply: f = () => {
        },
        ...a
      } = Y(t, e), l = await et(e, a), u = j(i), m = ot(i), d = $(i) === "y", {
        width: h,
        height: p
      } = s.floating;
      let w, g;
      u === "top" || u === "bottom" ? (w = u, g = m === (await (r.isRTL == null ? void 0 : r.isRTL(c.floating)) ? "start" : "end") ? "left" : "right") : (g = u, w = m === "end" ? "top" : "bottom");
      const x = p - l.top - l.bottom, v = h - l.left - l.right, b = Q(p - l[w], x), y = Q(h - l[g], v), R = !e.middlewareData.shift;
      let S = b, D = y;
      if ((n = e.middlewareData.shift) != null && n.enabled.x && (D = v), (o = e.middlewareData.shift) != null && o.enabled.y && (S = x), R && !m) {
        const C = T(l.left, 0), z = T(l.right, 0), I = T(l.top, 0), P = T(l.bottom, 0);
        d ? D = h - 2 * (C !== 0 || z !== 0 ? C + z : T(l.left, l.right)) : S = p - 2 * (I !== 0 || P !== 0 ? I + P : T(l.top, l.bottom));
      }
      await f({
        ...e,
        availableWidth: D,
        availableHeight: S
      });
      const _ = await r.getDimensions(c.floating);
      return h !== _.width || p !== _.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function Vt(t) {
  const e = W(t);
  let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0;
  const i = N(t), s = i ? t.offsetWidth : n, r = i ? t.offsetHeight : o, c = rt(n) !== s || rt(o) !== r;
  return c && (n = s, o = r), {
    width: n,
    height: o,
    $: c
  };
}
function bt(t) {
  return F(t) ? t : t.contextElement;
}
function G(t) {
  const e = bt(t);
  if (!N(e))
    return V(1);
  const n = e.getBoundingClientRect(), {
    width: o,
    height: i,
    $: s
  } = Vt(e);
  let r = (s ? rt(n.width) : n.width) / o, c = (s ? rt(n.height) : n.height) / i;
  return (!r || !Number.isFinite(r)) && (r = 1), (!c || !Number.isFinite(c)) && (c = 1), {
    x: r,
    y: c
  };
}
const Ae = /* @__PURE__ */ V(0);
function Nt(t) {
  const e = M(t);
  return !yt() || !e.visualViewport ? Ae : {
    x: e.visualViewport.offsetLeft,
    y: e.visualViewport.offsetTop
  };
}
function Re(t, e, n) {
  return e === void 0 && (e = !1), !n || e && n !== M(t) ? !1 : e;
}
function U(t, e, n, o) {
  e === void 0 && (e = !1), n === void 0 && (n = !1);
  const i = t.getBoundingClientRect(), s = bt(t);
  let r = V(1);
  e && (o ? F(o) && (r = G(o)) : r = G(t));
  const c = Re(s, n, o) ? Nt(s) : V(0);
  let f = (i.left + c.x) / r.x, a = (i.top + c.y) / r.y, l = i.width / r.x, u = i.height / r.y;
  if (s) {
    const m = M(s), d = o && F(o) ? M(o) : o;
    let h = m, p = pt(h);
    for (; p && o && d !== h; ) {
      const w = G(p), g = p.getBoundingClientRect(), x = W(p), v = g.left + (p.clientLeft + parseFloat(x.paddingLeft)) * w.x, b = g.top + (p.clientTop + parseFloat(x.paddingTop)) * w.y;
      f *= w.x, a *= w.y, l *= w.x, u *= w.y, f += v, a += b, h = M(p), p = pt(h);
    }
  }
  return lt({
    width: l,
    height: u,
    x: f,
    y: a
  });
}
function mt(t, e) {
  const n = dt(t).scrollLeft;
  return e ? e.left + n : U(H(t)).left + n;
}
function Ht(t, e) {
  const n = t.getBoundingClientRect(), o = n.left + e.scrollLeft - mt(t, n), i = n.top + e.scrollTop;
  return {
    x: o,
    y: i
  };
}
function Se(t) {
  let {
    elements: e,
    rect: n,
    offsetParent: o,
    strategy: i
  } = t;
  const s = i === "fixed", r = H(o), c = e ? ut(e.floating) : !1;
  if (o === r || c && s)
    return n;
  let f = {
    scrollLeft: 0,
    scrollTop: 0
  }, a = V(1);
  const l = V(0), u = N(o);
  if ((u || !u && !s) && ((Z(o) !== "body" || nt(r)) && (f = dt(o)), N(o))) {
    const d = U(o);
    a = G(o), l.x = d.x + o.clientLeft, l.y = d.y + o.clientTop;
  }
  const m = r && !u && !s ? Ht(r, f) : V(0);
  return {
    width: n.width * a.x,
    height: n.height * a.y,
    x: n.x * a.x - f.scrollLeft * a.x + l.x + m.x,
    y: n.y * a.y - f.scrollTop * a.y + l.y + m.y
  };
}
function Oe(t) {
  return Array.from(t.getClientRects());
}
function Ce(t) {
  const e = H(t), n = dt(t), o = t.ownerDocument.body, i = T(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), s = T(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight);
  let r = -n.scrollLeft + mt(t);
  const c = -n.scrollTop;
  return W(o).direction === "rtl" && (r += T(e.clientWidth, o.clientWidth) - i), {
    width: i,
    height: s,
    x: r,
    y: c
  };
}
const Tt = 25;
function Le(t, e) {
  const n = M(t), o = H(t), i = n.visualViewport;
  let s = o.clientWidth, r = o.clientHeight, c = 0, f = 0;
  if (i) {
    s = i.width, r = i.height;
    const l = yt();
    (!l || l && e === "fixed") && (c = i.offsetLeft, f = i.offsetTop);
  }
  const a = mt(o);
  if (a <= 0) {
    const l = o.ownerDocument, u = l.body, m = getComputedStyle(u), d = l.compatMode === "CSS1Compat" && parseFloat(m.marginLeft) + parseFloat(m.marginRight) || 0, h = Math.abs(o.clientWidth - u.clientWidth - d);
    h <= Tt && (s -= h);
  } else a <= Tt && (s += a);
  return {
    width: s,
    height: r,
    x: c,
    y: f
  };
}
const Ee = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function Te(t, e) {
  const n = U(t, !0, e === "fixed"), o = n.top + t.clientTop, i = n.left + t.clientLeft, s = N(t) ? G(t) : V(1), r = t.clientWidth * s.x, c = t.clientHeight * s.y, f = i * s.x, a = o * s.y;
  return {
    width: r,
    height: c,
    x: f,
    y: a
  };
}
function Mt(t, e, n) {
  let o;
  if (e === "viewport")
    o = Le(t, n);
  else if (e === "document")
    o = Ce(H(t));
  else if (F(e))
    o = Te(e, n);
  else {
    const i = Nt(t);
    o = {
      x: e.x - i.x,
      y: e.y - i.y,
      width: e.width,
      height: e.height
    };
  }
  return lt(o);
}
function _t(t, e) {
  const n = q(t);
  return n === e || !F(n) || J(n) ? !1 : W(n).position === "fixed" || _t(n, e);
}
function Me(t, e) {
  const n = e.get(t);
  if (n)
    return n;
  let o = tt(t, [], !1).filter((c) => F(c) && Z(c) !== "body"), i = null;
  const s = W(t).position === "fixed";
  let r = s ? q(t) : t;
  for (; F(r) && !J(r); ) {
    const c = W(r), f = xt(r);
    !f && c.position === "fixed" && (i = null), (s ? !f && !i : !f && c.position === "static" && !!i && Ee.has(i.position) || nt(r) && !f && _t(t, r)) ? o = o.filter((l) => l !== r) : i = c, r = q(r);
  }
  return e.set(t, o), o;
}
function De(t) {
  let {
    element: e,
    boundary: n,
    rootBoundary: o,
    strategy: i
  } = t;
  const r = [...n === "clippingAncestors" ? ut(e) ? [] : Me(e, this._c) : [].concat(n), o], c = r[0], f = r.reduce((a, l) => {
    const u = Mt(e, l, i);
    return a.top = T(u.top, a.top), a.right = Q(u.right, a.right), a.bottom = Q(u.bottom, a.bottom), a.left = T(u.left, a.left), a;
  }, Mt(e, c, i));
  return {
    width: f.right - f.left,
    height: f.bottom - f.top,
    x: f.left,
    y: f.top
  };
}
function Pe(t) {
  const {
    width: e,
    height: n
  } = Vt(t);
  return {
    width: e,
    height: n
  };
}
function ke(t, e, n) {
  const o = N(e), i = H(e), s = n === "fixed", r = U(t, !0, s, e);
  let c = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const f = V(0);
  function a() {
    f.x = mt(i);
  }
  if (o || !o && !s)
    if ((Z(e) !== "body" || nt(i)) && (c = dt(e)), o) {
      const d = U(e, !0, s, e);
      f.x = d.x + e.clientLeft, f.y = d.y + e.clientTop;
    } else i && a();
  s && !o && i && a();
  const l = i && !o && !s ? Ht(i, c) : V(0), u = r.left + c.scrollLeft - f.x - l.x, m = r.top + c.scrollTop - f.y - l.y;
  return {
    x: u,
    y: m,
    width: r.width,
    height: r.height
  };
}
function ht(t) {
  return W(t).position === "static";
}
function Dt(t, e) {
  if (!N(t) || W(t).position === "fixed")
    return null;
  if (e)
    return e(t);
  let n = t.offsetParent;
  return H(t) === n && (n = n.ownerDocument.body), n;
}
function zt(t, e) {
  const n = M(t);
  if (ut(t))
    return n;
  if (!N(t)) {
    let i = q(t);
    for (; i && !J(i); ) {
      if (F(i) && !ht(i))
        return i;
      i = q(i);
    }
    return n;
  }
  let o = Dt(t, e);
  for (; o && Kt(o) && ht(o); )
    o = Dt(o, e);
  return o && J(o) && ht(o) && !xt(o) ? n : o || te(t) || n;
}
const Fe = async function(t) {
  const e = this.getOffsetParent || zt, n = this.getDimensions, o = await n(t.floating);
  return {
    reference: ke(t.reference, await e(t.floating), t.strategy),
    floating: {
      x: 0,
      y: 0,
      width: o.width,
      height: o.height
    }
  };
};
function We(t) {
  return W(t).direction === "rtl";
}
const Be = {
  convertOffsetParentRelativeRectToViewportRelativeRect: Se,
  getDocumentElement: H,
  getClippingRect: De,
  getOffsetParent: zt,
  getElementRects: Fe,
  getClientRects: Oe,
  getDimensions: Pe,
  getScale: G,
  isElement: F,
  isRTL: We
};
function jt(t, e) {
  return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
}
function $e(t, e) {
  let n = null, o;
  const i = H(t);
  function s() {
    var c;
    clearTimeout(o), (c = n) == null || c.disconnect(), n = null;
  }
  function r(c, f) {
    c === void 0 && (c = !1), f === void 0 && (f = 1), s();
    const a = t.getBoundingClientRect(), {
      left: l,
      top: u,
      width: m,
      height: d
    } = a;
    if (c || e(), !m || !d)
      return;
    const h = it(u), p = it(i.clientWidth - (l + m)), w = it(i.clientHeight - (u + d)), g = it(l), v = {
      rootMargin: -h + "px " + -p + "px " + -w + "px " + -g + "px",
      threshold: T(0, Q(1, f)) || 1
    };
    let b = !0;
    function y(R) {
      const S = R[0].intersectionRatio;
      if (S !== f) {
        if (!b)
          return r();
        S ? r(!1, S) : o = setTimeout(() => {
          r(!1, 1e-7);
        }, 1e3);
      }
      S === 1 && !jt(a, t.getBoundingClientRect()) && r(), b = !1;
    }
    try {
      n = new IntersectionObserver(y, {
        ...v,
        // Handle <iframe>s
        root: i.ownerDocument
      });
    } catch {
      n = new IntersectionObserver(y, v);
    }
    n.observe(t);
  }
  return r(!0), s;
}
function Ue(t, e, n, o) {
  o === void 0 && (o = {});
  const {
    ancestorScroll: i = !0,
    ancestorResize: s = !0,
    elementResize: r = typeof ResizeObserver == "function",
    layoutShift: c = typeof IntersectionObserver == "function",
    animationFrame: f = !1
  } = o, a = bt(t), l = i || s ? [...a ? tt(a) : [], ...tt(e)] : [];
  l.forEach((g) => {
    i && g.addEventListener("scroll", n, {
      passive: !0
    }), s && g.addEventListener("resize", n);
  });
  const u = a && c ? $e(a, n) : null;
  let m = -1, d = null;
  r && (d = new ResizeObserver((g) => {
    let [x] = g;
    x && x.target === a && d && (d.unobserve(e), cancelAnimationFrame(m), m = requestAnimationFrame(() => {
      var v;
      (v = d) == null || v.observe(e);
    })), n();
  }), a && !f && d.observe(a), d.observe(e));
  let h, p = f ? U(t) : null;
  f && w();
  function w() {
    const g = U(t);
    p && !jt(p, g) && n(), p = g, h = requestAnimationFrame(w);
  }
  return n(), () => {
    var g;
    l.forEach((x) => {
      i && x.removeEventListener("scroll", n), s && x.removeEventListener("resize", n);
    }), u?.(), (g = d) == null || g.disconnect(), d = null, f && cancelAnimationFrame(h);
  };
}
const Ve = xe, Ne = ye, He = ge, _e = be, ze = pe, je = ve, Ie = (t, e, n) => {
  const o = /* @__PURE__ */ new Map(), i = {
    platform: Be,
    ...n
  }, s = {
    ...i.platform,
    _c: o
  };
  return he(t, e, {
    ...i,
    platform: s
  });
};
var Xe = typeof document < "u", qe = function() {
}, st = Xe ? Xt : qe;
function ft(t, e) {
  if (t === e)
    return !0;
  if (typeof t != typeof e)
    return !1;
  if (typeof t == "function" && t.toString() === e.toString())
    return !0;
  let n, o, i;
  if (t && e && typeof t == "object") {
    if (Array.isArray(t)) {
      if (n = t.length, n !== e.length) return !1;
      for (o = n; o-- !== 0; )
        if (!ft(t[o], e[o]))
          return !1;
      return !0;
    }
    if (i = Object.keys(t), n = i.length, n !== Object.keys(e).length)
      return !1;
    for (o = n; o-- !== 0; )
      if (!{}.hasOwnProperty.call(e, i[o]))
        return !1;
    for (o = n; o-- !== 0; ) {
      const s = i[o];
      if (!(s === "_owner" && t.$$typeof) && !ft(t[s], e[s]))
        return !1;
    }
    return !0;
  }
  return t !== t && e !== e;
}
function It(t) {
  return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function Pt(t, e) {
  const n = It(t);
  return Math.round(e * n) / n;
}
function gt(t) {
  const e = O.useRef(t);
  return st(() => {
    e.current = t;
  }), e;
}
function Ke(t) {
  t === void 0 && (t = {});
  const {
    placement: e = "bottom",
    strategy: n = "absolute",
    middleware: o = [],
    platform: i,
    elements: {
      reference: s,
      floating: r
    } = {},
    transform: c = !0,
    whileElementsMounted: f,
    open: a
  } = t, [l, u] = O.useState({
    x: 0,
    y: 0,
    strategy: n,
    placement: e,
    middlewareData: {},
    isPositioned: !1
  }), [m, d] = O.useState(o);
  ft(m, o) || d(o);
  const [h, p] = O.useState(null), [w, g] = O.useState(null), x = O.useCallback((A) => {
    A !== R.current && (R.current = A, p(A));
  }, []), v = O.useCallback((A) => {
    A !== S.current && (S.current = A, g(A));
  }, []), b = s || h, y = r || w, R = O.useRef(null), S = O.useRef(null), D = O.useRef(l), _ = f != null, C = gt(f), z = gt(i), I = gt(a), P = O.useCallback(() => {
    if (!R.current || !S.current)
      return;
    const A = {
      placement: e,
      strategy: n,
      middleware: m
    };
    z.current && (A.platform = z.current), Ie(R.current, S.current, A).then((E) => {
      const X = {
        ...E,
        // The floating element's position may be recomputed while it's closed
        // but still mounted (such as when transitioning out). To ensure
        // `isPositioned` will be `false` initially on the next open, avoid
        // setting it to `true` when `open === false` (must be specified).
        isPositioned: I.current !== !1
      };
      k.current && !ft(D.current, X) && (D.current = X, qt.flushSync(() => {
        u(X);
      }));
    });
  }, [m, e, n, z, I]);
  st(() => {
    a === !1 && D.current.isPositioned && (D.current.isPositioned = !1, u((A) => ({
      ...A,
      isPositioned: !1
    })));
  }, [a]);
  const k = O.useRef(!1);
  st(() => (k.current = !0, () => {
    k.current = !1;
  }), []), st(() => {
    if (b && (R.current = b), y && (S.current = y), b && y) {
      if (C.current)
        return C.current(b, y, P);
      P();
    }
  }, [b, y, P, C, _]);
  const K = O.useMemo(() => ({
    reference: R,
    floating: S,
    setReference: x,
    setFloating: v
  }), [x, v]), L = O.useMemo(() => ({
    reference: b,
    floating: y
  }), [b, y]), B = O.useMemo(() => {
    const A = {
      position: n,
      left: 0,
      top: 0
    };
    if (!L.floating)
      return A;
    const E = Pt(L.floating, l.x), X = Pt(L.floating, l.y);
    return c ? {
      ...A,
      transform: "translate(" + E + "px, " + X + "px)",
      ...It(L.floating) >= 1.5 && {
        willChange: "transform"
      }
    } : {
      position: n,
      left: E,
      top: X
    };
  }, [n, c, L.floating, l.x, l.y]);
  return O.useMemo(() => ({
    ...l,
    update: P,
    refs: K,
    elements: L,
    floatingStyles: B
  }), [l, P, K, L, B]);
}
const Ge = (t, e) => ({
  ...Ve(t),
  options: [t, e]
}), Je = (t, e) => ({
  ...Ne(t),
  options: [t, e]
}), Qe = (t, e) => ({
  ...je(t),
  options: [t, e]
}), Ze = (t, e) => ({
  ...He(t),
  options: [t, e]
}), tn = (t, e) => ({
  ..._e(t),
  options: [t, e]
}), en = (t, e) => ({
  ...ze(t),
  options: [t, e]
});
export {
  Je as A,
  Qe as B,
  rt as C,
  nt as D,
  N as a,
  F as b,
  kt as c,
  M as d,
  W as e,
  it as f,
  Z as g,
  J as h,
  At as i,
  q as j,
  tt as k,
  yt as l,
  Y as m,
  me as n,
  Bt as o,
  ot as p,
  Rt as q,
  Wt as r,
  en as s,
  j as t,
  Ke as u,
  Ze as v,
  Ge as w,
  tn as x,
  $ as y,
  Ue as z
};
//# sourceMappingURL=vendor-floating-ui-BgbEw62H.js.map
