"use client";
import { g as oe, d as Ee, c as pt, e as Ze, i as j } from "./floating-ui.utils.dom-jr2suqy2.js";
import { d as et, e as tt } from "./detectBrowser-Dn2N72k1.js";
import { o as N } from "./owner-rKN292Q9.js";
import { u as z } from "./useIsoLayoutEffect-DpJo20by.js";
import { T as Me, u as ge } from "./useTimeout-DAqPwigF.js";
import { A as bt, u as nt } from "./useAnimationFrame-DIc6eFHa.js";
import { N as mt, c as Pe, E as ht } from "./useRenderElement-DNB2vtF1.js";
import * as v from "react";
import { b as gt, e as vt, t as rt, f as ke, c as Ge, h as Ne, g as We, i as Ye, j as De, k as yt, l as Et, C as kt, m as ot, n as wt } from "./popupStateMapping-BT9Y_jIq.js";
import { u as ae } from "./useValueAsRef-LhoZc6As.js";
import { u as Z } from "./useStableCallback-CudqoENs.js";
import { b as Tt, o as Rt, c as re, f as St, a as Ct } from "./createBaseUIEventDetails-CqidROtw.js";
import { r as X } from "./useOpenChangeComplete-DkeH9FGJ.js";
import { jsxs as xt, jsx as ve } from "react/jsx-runtime";
import { j as Ve, g as Be, a as K, c as R, d as st, b as fe } from "./element-DSo91iOi.js";
import { i as Ot, a as Ft, s as It, b as He, c as Lt } from "./event-BCa0Un_3.js";
import { j as At } from "./composite-BASdnlNo.js";
import { u as Mt } from "./useValueChanged-Bissqjjn.js";
let Xe = {}, $e = {}, qe = "";
function Pt(e) {
  if (typeof document > "u")
    return !1;
  const r = N(e);
  return oe(r).innerWidth - r.documentElement.clientWidth > 0;
}
function Gt(e) {
  if (!(typeof CSS < "u" && CSS.supports && CSS.supports("scrollbar-gutter", "stable")) || typeof document > "u")
    return !1;
  const t = N(e), n = t.documentElement, o = t.body, i = Ee(n) ? n : o, s = i.style.overflowY, b = n.style.scrollbarGutter;
  n.style.scrollbarGutter = "stable", i.style.overflowY = "scroll";
  const k = i.offsetWidth;
  i.style.overflowY = "hidden";
  const w = i.offsetWidth;
  return i.style.overflowY = s, n.style.scrollbarGutter = b, k === w;
}
function Nt(e) {
  const r = N(e), t = r.documentElement, n = r.body, o = Ee(t) ? t : n, i = {
    overflowY: o.style.overflowY,
    overflowX: o.style.overflowX
  };
  return Object.assign(o.style, {
    overflowY: "hidden",
    overflowX: "hidden"
  }), () => {
    Object.assign(o.style, i);
  };
}
function Wt(e) {
  const r = N(e), t = r.documentElement, n = r.body, o = oe(t);
  let i = 0, s = 0, b = !1;
  const k = bt.create();
  if (tt && (o.visualViewport?.scale ?? 1) !== 1)
    return () => {
    };
  function w() {
    const Y = o.getComputedStyle(t), O = o.getComputedStyle(n), m = (Y.scrollbarGutter || "").includes("both-edges") ? "stable both-edges" : "stable";
    i = t.scrollTop, s = t.scrollLeft, Xe = {
      scrollbarGutter: t.style.scrollbarGutter,
      overflowY: t.style.overflowY,
      overflowX: t.style.overflowX
    }, qe = t.style.scrollBehavior, $e = {
      position: n.style.position,
      height: n.style.height,
      width: n.style.width,
      boxSizing: n.style.boxSizing,
      overflowY: n.style.overflowY,
      overflowX: n.style.overflowX,
      scrollBehavior: n.style.scrollBehavior
    };
    const f = t.scrollHeight > t.clientHeight, a = t.scrollWidth > t.clientWidth, W = Y.overflowY === "scroll" || O.overflowY === "scroll", y = Y.overflowX === "scroll" || O.overflowX === "scroll", S = Math.max(0, o.innerWidth - n.clientWidth), M = Math.max(0, o.innerHeight - n.clientHeight), C = parseFloat(O.marginTop) + parseFloat(O.marginBottom), F = parseFloat(O.marginLeft) + parseFloat(O.marginRight), U = Ee(t) ? t : n;
    if (b = Gt(e), b) {
      t.style.scrollbarGutter = m, U.style.overflowY = "hidden", U.style.overflowX = "hidden";
      return;
    }
    Object.assign(t.style, {
      scrollbarGutter: m,
      overflowY: "hidden",
      overflowX: "hidden"
    }), (f || W) && (t.style.overflowY = "scroll"), (a || y) && (t.style.overflowX = "scroll"), Object.assign(n.style, {
      position: "relative",
      height: C || M ? `calc(100dvh - ${C + M}px)` : "100dvh",
      width: F || S ? `calc(100vw - ${F + S}px)` : "100vw",
      boxSizing: "border-box",
      overflow: "hidden",
      scrollBehavior: "unset"
    }), n.scrollTop = i, n.scrollLeft = s, t.setAttribute("data-base-ui-scroll-locked", ""), t.style.scrollBehavior = "unset";
  }
  function L() {
    Object.assign(t.style, Xe), Object.assign(n.style, $e), b || (t.scrollTop = i, t.scrollLeft = s, t.removeAttribute("data-base-ui-scroll-locked"), t.style.scrollBehavior = qe);
  }
  function x() {
    L(), k.request(w);
  }
  return w(), o.addEventListener("resize", x), () => {
    k.cancel(), L(), typeof o.removeEventListener == "function" && o.removeEventListener("resize", x);
  };
}
class Yt {
  lockCount = 0;
  restore = null;
  timeoutLock = Me.create();
  timeoutUnlock = Me.create();
  acquire(r) {
    return this.lockCount += 1, this.lockCount === 1 && this.restore === null && this.timeoutLock.start(0, () => this.lock(r)), this.release;
  }
  release = () => {
    this.lockCount -= 1, this.lockCount === 0 && this.restore && this.timeoutUnlock.start(0, this.unlock);
  };
  unlock = () => {
    this.lockCount === 0 && this.restore && (this.restore?.(), this.restore = null);
  };
  lock(r) {
    if (this.lockCount === 0 || this.restore !== null)
      return;
    const n = N(r).documentElement, o = oe(n).getComputedStyle(n).overflowY;
    if (o === "hidden" || o === "clip") {
      this.restore = mt;
      return;
    }
    const i = et || !Pt(r);
    this.restore = i ? Nt(r) : Wt(r);
  }
}
const Dt = new Yt();
function dn(e = !0, r = null) {
  z(() => {
    if (e)
      return Dt.acquire(r);
  }, [e, r]);
}
let je = 0;
function de(e, r = {}) {
  const {
    preventScroll: t = !1,
    cancelPrevious: n = !0,
    sync: o = !1
  } = r;
  n && cancelAnimationFrame(je);
  const i = () => e?.focus({
    preventScroll: t
  });
  o ? i() : je = requestAnimationFrame(i);
}
const pe = {
  inert: /* @__PURE__ */ new WeakMap(),
  "aria-hidden": /* @__PURE__ */ new WeakMap()
}, Ke = "data-base-ui-inert", ye = {
  inert: /* @__PURE__ */ new WeakSet(),
  "aria-hidden": /* @__PURE__ */ new WeakSet()
};
let Q = /* @__PURE__ */ new WeakMap(), be = 0;
function Vt(e) {
  return ye[e];
}
function ct(e) {
  return e ? pt(e) ? e.host : ct(e.parentNode) : null;
}
const me = (e, r) => r.map((t) => {
  if (e.contains(t))
    return t;
  const n = ct(t);
  return e.contains(n) ? n : null;
}).filter((t) => t != null), ze = (e) => {
  const r = /* @__PURE__ */ new Set();
  return e.forEach((t) => {
    let n = t;
    for (; n && !r.has(n); )
      r.add(n), n = n.parentNode;
  }), r;
}, Ue = (e, r, t) => {
  const n = [], o = (i) => {
    !i || t.has(i) || Array.from(i.children).forEach((s) => {
      Ze(s) !== "script" && (r.has(s) ? o(s) : n.push(s));
    });
  };
  return o(e), n;
};
function Bt(e, r, t, n, {
  mark: o = !0,
  markerIgnoreElements: i = []
}) {
  const s = n ? "inert" : t ? "aria-hidden" : null;
  let b = null, k = null;
  const w = me(r, e), L = o ? me(r, i) : [], x = new Set(L), Y = o ? Ue(r, ze(w), new Set(w)).filter((c) => !x.has(c)) : [], O = [], B = [];
  if (s) {
    const c = pe[s], m = Vt(s);
    k = m, b = c;
    const f = me(r, Array.from(r.querySelectorAll("[aria-live]"))), a = w.concat(f);
    Ue(r, ze(a), new Set(a)).forEach((y) => {
      const S = y.getAttribute(s), M = S !== null && S !== "false", C = (c.get(y) || 0) + 1;
      c.set(y, C), O.push(y), C === 1 && M && m.add(y), M || y.setAttribute(s, s === "inert" ? "" : "true");
    });
  }
  return o && Y.forEach((c) => {
    const m = (Q.get(c) || 0) + 1;
    Q.set(c, m), B.push(c), m === 1 && c.setAttribute(Ke, "");
  }), be += 1, () => {
    b && O.forEach((c) => {
      const f = (b.get(c) || 0) - 1;
      b.set(c, f), f || (!k?.has(c) && s && c.removeAttribute(s), k?.delete(c));
    }), o && B.forEach((c) => {
      const m = (Q.get(c) || 0) - 1;
      Q.set(c, m), m || c.removeAttribute(Ke);
    }), be -= 1, be || (pe.inert = /* @__PURE__ */ new WeakMap(), pe["aria-hidden"] = /* @__PURE__ */ new WeakMap(), ye.inert = /* @__PURE__ */ new WeakSet(), ye["aria-hidden"] = /* @__PURE__ */ new WeakSet(), Q = /* @__PURE__ */ new WeakMap());
  };
}
function _e(e, r = {}) {
  const {
    ariaHidden: t = !1,
    inert: n = !1,
    mark: o = !0,
    markerIgnoreElements: i = []
  } = r, s = N(e[0]).body;
  return Bt(e, s, t, n, {
    mark: o,
    markerIgnoreElements: i
  });
}
function Ht(e, r) {
  const t = oe(e.target);
  return e instanceof t.KeyboardEvent ? "keyboard" : e instanceof t.FocusEvent ? r || "keyboard" : "pointerType" in e ? e.pointerType || "keyboard" : "touches" in e ? "touch" : e instanceof t.MouseEvent ? r || (e.detail === 0 ? "keyboard" : "mouse") : "";
}
const Je = 20;
let $ = [];
function we() {
  $ = $.filter((e) => e.deref()?.isConnected);
}
function Xt(e) {
  we(), e && Ze(e) !== "body" && ($.push(new WeakRef(e)), $.length > Je && ($ = $.slice(-Je)));
}
function he() {
  return we(), $[$.length - 1]?.deref();
}
function $t(e) {
  if (!e)
    return null;
  const r = ke();
  return ot(e, r) ? e : rt(e, r)[0] || e;
}
function qt(e) {
  return !e || !e.isConnected ? !1 : typeof e.checkVisibility == "function" ? e.checkVisibility() : At(e);
}
function Qe(e, r) {
  if (!r.current.includes("floating") && !e.getAttribute("role")?.includes("dialog"))
    return;
  const t = ke(), o = wt(e, t).filter((s) => {
    const b = s.getAttribute("data-tabindex") || "";
    return ot(s, t) || s.hasAttribute("data-tabindex") && !b.startsWith("-");
  }), i = e.getAttribute("tabindex");
  r.current.includes("floating") || o.length === 0 ? i !== "0" && e.setAttribute("tabindex", "0") : (i !== "-1" || e.hasAttribute("data-tabindex") && e.getAttribute("data-tabindex") !== "-1") && (e.setAttribute("tabindex", "-1"), e.setAttribute("data-tabindex", "-1"));
}
function pn(e) {
  const {
    context: r,
    children: t,
    disabled: n = !1,
    initialFocus: o = !0,
    returnFocus: i = !0,
    restoreFocus: s = !1,
    modal: b = !0,
    closeOnFocusOut: k = !0,
    openInteractionType: w = "",
    nextFocusableElement: L,
    previousFocusableElement: x,
    beforeContentFocusGuardRef: Y,
    externalTree: O,
    getInsideElements: B
  } = e, c = "rootStore" in r ? r.rootStore : r, m = c.useState("open"), f = c.useState("domReferenceElement"), a = c.useState("floatingElement"), {
    events: W,
    dataRef: y
  } = c.context, S = Z(() => y.current.floatingContext?.nodeId), M = o === !1, C = Ve(f) && M, F = v.useRef(["content"]), U = ae(o), ee = ae(i), Te = ae(w), D = gt(O), g = vt(), V = v.useRef(!1), te = v.useRef(!1), se = v.useRef(!1), Re = v.useRef(-1), Se = v.useRef(""), ce = v.useRef(""), ie = v.useRef(null), le = v.useRef(null), it = Pe(ie, Y, g?.beforeInsideRef), lt = Pe(le, g?.afterInsideRef), Ce = ge(), xe = ge(), Oe = nt(), ut = g != null, h = Be(a), q = Z((l = h) => l ? rt(l, ke()) : []), H = Z(() => B?.().filter((l) => l != null) ?? []), _ = Z((l) => {
    const E = q(l);
    return F.current.map(() => E).filter(Boolean).flat();
  });
  v.useEffect(() => {
    if (n || !b)
      return;
    function l(I) {
      I.key === "Tab" && R(h, K(N(h))) && q().length === 0 && !C && It(I);
    }
    const E = N(h);
    return E.addEventListener("keydown", l), () => {
      E.removeEventListener("keydown", l);
    };
  }, [n, f, h, b, F, C, q, _]), v.useEffect(() => {
    if (n || !m)
      return;
    const l = N(h);
    function E() {
      se.current = !1;
    }
    function I(p) {
      const d = fe(p), P = H(), T = R(a, d) || R(f, d) || R(g?.portalNode, d) || P.some((u) => u === d || R(u, d));
      se.current = !T, ce.current = p.pointerType || "keyboard", d?.closest(`[${kt}]`) && (te.current = !0);
    }
    function A() {
      ce.current = "keyboard";
    }
    return l.addEventListener("pointerdown", I, !0), l.addEventListener("pointerup", E, !0), l.addEventListener("pointercancel", E, !0), l.addEventListener("keydown", A, !0), () => {
      l.removeEventListener("pointerdown", I, !0), l.removeEventListener("pointerup", E, !0), l.removeEventListener("pointercancel", E, !0), l.removeEventListener("keydown", A, !0);
    };
  }, [n, a, f, h, m, g, H]), v.useEffect(() => {
    if (n || !k)
      return;
    const l = N(h);
    function E() {
      te.current = !0, xe.start(0, () => {
        te.current = !1;
      });
    }
    function I(T) {
      const u = fe(T), ne = q().indexOf(u);
      ne !== -1 && (Re.current = ne);
    }
    function A(T) {
      const u = T.relatedTarget, J = T.currentTarget, ne = fe(T);
      queueMicrotask(() => {
        const Ie = S(), Le = c.context.triggerElements, at = H(), ft = u?.hasAttribute(Ge("focus-guard")) && [ie.current, le.current, g?.beforeInsideRef.current, g?.afterInsideRef.current, g?.beforeOutsideRef.current, g?.afterOutsideRef.current, X(x), X(L)].includes(u), dt = !(R(f, u) || R(a, u) || R(u, a) || R(g?.portalNode, u) || at.some((G) => G === u || R(G, u)) || u != null && Le.hasElement(u) || Le.hasMatchingElement((G) => R(G, u)) || ft || D && (We(D.nodesRef.current, Ie).find((G) => R(G.context?.elements.floating, u) || R(G.context?.elements.domReference, u)) || Ne(D.nodesRef.current, Ie).find((G) => [G.context?.elements.floating, Be(G.context?.elements.floating)].includes(u) || G.context?.elements.domReference === u)));
        if (J === f && h && Qe(h, F), s && J !== f && !qt(ne) && K(l) === l.body) {
          if (j(h) && (h.focus(), s === "popup")) {
            Oe.request(() => {
              h.focus();
            });
            return;
          }
          const G = Re.current, ue = q(), Ae = ue[G] || ue[ue.length - 1] || h;
          j(Ae) && Ae.focus();
        }
        if (y.current.insideReactTree) {
          y.current.insideReactTree = !1;
          return;
        }
        (C || !b) && u && dt && !te.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
        // For an "untrapped" typeable combobox (input role=combobox with
        // initialFocus=false), re-opening the popup and tabbing out should still close it even
        // when the previously focused element (e.g. the next tabbable outside the popup) is
        // focused again. Otherwise, the popup remains open on the second Tab sequence:
        // click input -> Tab (closes) -> click input -> Tab.
        // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element.
        (C || u !== he()) && (V.current = !0, c.setOpen(!1, re(St, T)));
      });
    }
    function p() {
      se.current || (y.current.insideReactTree = !0, Ce.start(0, () => {
        y.current.insideReactTree = !1;
      }));
    }
    const d = j(f) ? f : null, P = [];
    if (!(!a && !d))
      return d && (d.addEventListener("focusout", A), d.addEventListener("pointerdown", E), P.push(() => {
        d.removeEventListener("focusout", A), d.removeEventListener("pointerdown", E);
      })), a && (a.addEventListener("focusin", I), a.addEventListener("focusout", A), g && (a.addEventListener("focusout", p, !0), P.push(() => {
        a.removeEventListener("focusout", p, !0);
      })), P.push(() => {
        a.removeEventListener("focusin", I), a.removeEventListener("focusout", A);
      })), () => {
        P.forEach((T) => {
          T();
        });
      };
  }, [n, f, a, h, b, D, g, c, k, s, q, C, S, F, y, Ce, xe, Oe, L, x, H]), v.useEffect(() => {
    if (n || !a || !m)
      return;
    const l = Array.from(g?.portalNode?.querySelectorAll(`[${Ge("portal")}]`) || []), I = (D ? Ne(D.nodesRef.current, S()) : []).find((u) => Ve(u.context?.elements.domReference || null))?.context?.elements.domReference, p = [...[a, ...l, ie.current, le.current, g?.beforeOutsideRef.current, g?.afterOutsideRef.current, ...H()], I, X(x), X(L), C ? f : null].filter((u) => u != null), d = _e(p, {
      ariaHidden: b || C,
      mark: !1
    }), P = [a, ...l].filter((u) => u != null), T = _e(P);
    return () => {
      T(), d();
    };
  }, [m, n, f, a, b, F, g, C, D, S, L, x, H]), z(() => {
    if (!m || n || !j(h))
      return;
    const l = N(h), E = K(l);
    queueMicrotask(() => {
      const I = _(h), A = U.current, p = typeof A == "function" ? A(Te.current || "") : A;
      if (p === void 0 || p === !1)
        return;
      let d;
      p === !0 || p === null ? d = I[0] || h : d = X(p), d = d || I[0] || h, !R(h, E) && de(d, {
        preventScroll: d === h
      });
    });
  }, [n, m, h, M, _, U, Te]), z(() => {
    if (n || !h)
      return;
    const l = N(h), E = K(l);
    Xt(E);
    function I(p) {
      if (p.open || (Se.current = Ht(p.nativeEvent, ce.current)), p.reason === Tt && p.nativeEvent.type === "mouseleave" && (V.current = !0), p.reason === Rt)
        if (p.nested)
          V.current = !1;
        else if (Ot(p.nativeEvent) || Ft(p.nativeEvent))
          V.current = !1;
        else {
          let d = !1;
          document.createElement("div").focus({
            get preventScroll() {
              return d = !0, !1;
            }
          }), d ? V.current = !1 : V.current = !0;
        }
    }
    W.on("openchange", I);
    function A() {
      const p = ee.current;
      let d = typeof p == "function" ? p(Se.current) : p;
      if (d === void 0 || d === !1)
        return null;
      if (d === null && (d = !0), typeof d == "boolean") {
        const T = f || he();
        return T && T.isConnected ? T : null;
      }
      const P = f || he();
      return X(d) || P || null;
    }
    return () => {
      W.off("openchange", I);
      const p = K(l), d = H(), P = R(a, p) || d.some((u) => u === p || R(u, p)) || D && We(D.nodesRef.current, S(), !1).some((u) => R(u.context?.elements.floating, p)), T = A();
      queueMicrotask(() => {
        const u = $t(T), J = typeof ee.current != "boolean";
        // eslint-disable-next-line react-hooks/exhaustive-deps
        ee.current && !V.current && j(u) && // If the focus moved somewhere else after mount, avoid returning focus
        // since it likely entered a different element which should be
        // respected: https://github.com/floating-ui/floating-ui/issues/2607
        (!(!J && u !== p && p !== l.body) || P) && u.focus({
          preventScroll: !0
        }), V.current = !1;
      });
    };
  }, [n, a, h, ee, y, W, D, f, S, H]), z(() => {
    if (!tt || m || !a)
      return;
    const l = K(N(a));
    !j(l) || !st(l) || R(a, l) && l.blur();
  }, [m, a]), z(() => {
    if (!(n || !g))
      return g.setFocusManagerState({
        modal: b,
        closeOnFocusOut: k,
        open: m,
        onOpenChange: c.setOpen,
        domReference: f
      }), () => {
        g.setFocusManagerState(null);
      };
  }, [n, g, b, m, c, k, f]), z(() => {
    if (!(n || !h))
      return Qe(h, F), () => {
        queueMicrotask(we);
      };
  }, [n, h, F]);
  const Fe = !n && (b ? !C : !0) && (ut || b);
  return /* @__PURE__ */ xt(v.Fragment, {
    children: [Fe && /* @__PURE__ */ ve(Ye, {
      "data-type": "inside",
      ref: it,
      onFocus: (l) => {
        if (b) {
          const E = _();
          de(E[E.length - 1]);
        } else g?.portalNode && (V.current = !1, De(l, g.portalNode) ? yt(f)?.focus() : X(x ?? g.beforeOutsideRef)?.focus());
      }
    }), t, Fe && /* @__PURE__ */ ve(Ye, {
      "data-type": "inside",
      ref: lt,
      onFocus: (l) => {
        b ? de(_()[0]) : g?.portalNode && (k && (V.current = !0), De(l, g.portalNode) ? Et(f)?.focus() : X(L ?? g.afterOutsideRef)?.focus());
      }
    })]
  });
}
function bn(e, r = {}) {
  const t = "rootStore" in e ? e.rootStore : e, n = t.context.dataRef, {
    enabled: o = !0,
    event: i = "click",
    toggle: s = !0,
    ignoreMouse: b = !1,
    stickIfOpen: k = !0,
    touchOpenDelay: w = 0,
    reason: L = Ct
  } = r, x = v.useRef(void 0), Y = nt(), O = ge(), B = v.useMemo(() => ({
    onPointerDown(c) {
      x.current = c.pointerType;
    },
    onMouseDown(c) {
      const m = x.current, f = c.nativeEvent, a = t.select("open");
      if (c.button !== 0 || i === "click" || He(m, !0) && b)
        return;
      const W = n.current.openEvent, y = W?.type, S = t.select("domReferenceElement") !== c.currentTarget, M = a && S || !(a && s && (!(W && k) || y === "click" || y === "mousedown"));
      if (st(f.target)) {
        const F = re(L, f, f.target);
        M && m === "touch" && w > 0 ? O.start(w, () => {
          t.setOpen(!0, F);
        }) : t.setOpen(M, F);
        return;
      }
      const C = c.currentTarget;
      Y.request(() => {
        const F = re(L, f, C);
        M && m === "touch" && w > 0 ? O.start(w, () => {
          t.setOpen(!0, F);
        }) : t.setOpen(M, F);
      });
    },
    onClick(c) {
      if (i === "mousedown-only")
        return;
      const m = x.current;
      if (i === "mousedown" && m) {
        x.current = void 0;
        return;
      }
      if (He(m, !0) && b)
        return;
      const f = t.select("open"), a = n.current.openEvent, W = t.select("domReferenceElement") !== c.currentTarget, y = f && W || !(f && s && (!(a && k) || Lt(a))), S = re(L, c.nativeEvent, c.currentTarget);
      y && m === "touch" && w > 0 ? O.start(w, () => {
        t.setOpen(!0, S);
      }) : t.setOpen(y, S);
    },
    onKeyDown() {
      x.current = void 0;
    }
  }), [n, i, b, t, k, s, Y, O, w, L]);
  return v.useMemo(() => o ? {
    reference: B
  } : ht, [o, B]);
}
function jt(e) {
  const r = v.useRef(""), t = v.useCallback((o) => {
    o.defaultPrevented || (r.current = o.pointerType, e(o, o.pointerType));
  }, [e]);
  return {
    onClick: v.useCallback((o) => {
      if (o.detail === 0) {
        e(o, "keyboard");
        return;
      }
      "pointerType" in o ? e(o, o.pointerType) : e(o, r.current), r.current = "";
    }, [e]),
    onPointerDown: t
  };
}
function mn(e) {
  const [r, t] = v.useState(null), n = Z((s, b) => {
    e || t(b || // On iOS Safari, the hitslop around touch targets means tapping outside an element's
    // bounds does not fire `pointerdown` but does fire `mousedown`. The `interactionType`
    // will be "" in that case.
    (et ? "touch" : ""));
  });
  Mt(e, (s) => {
    s && !e && t(null);
  });
  const {
    onClick: o,
    onPointerDown: i
  } = jt(n);
  return v.useMemo(() => ({
    openMethod: r,
    triggerProps: {
      onClick: o,
      onPointerDown: i
    }
  }), [r, o, i]);
}
const Kt = /* @__PURE__ */ v.forwardRef(function(r, t) {
  const {
    cutout: n,
    ...o
  } = r;
  let i;
  if (n) {
    const s = n?.getBoundingClientRect();
    i = `polygon(
      0% 0%,
      100% 0%,
      100% 100%,
      0% 100%,
      0% 0%,
      ${s.left}px ${s.top}px,
      ${s.left}px ${s.bottom}px,
      ${s.right}px ${s.bottom}px,
      ${s.right}px ${s.top}px,
      ${s.left}px ${s.top}px
    )`;
  }
  return /* @__PURE__ */ ve("div", {
    ref: t,
    role: "presentation",
    "data-base-ui-inert": "",
    ...o,
    style: {
      position: "fixed",
      inset: 0,
      userSelect: "none",
      WebkitUserSelect: "none",
      clipPath: i
    }
  });
});
process.env.NODE_ENV !== "production" && (Kt.displayName = "InternalBackdrop");
export {
  pn as F,
  Kt as I,
  dn as a,
  bn as b,
  de as e,
  mn as u
};
