import { jsxs as Ce, jsx as N, Fragment as Kt } from "react/jsx-runtime";
import * as c from "react";
import { useLayoutEffect as wt, forwardRef as Wt, useState as Se, useRef as Ht, useEffect as Ut, useId as qt } from "react";
import { i as ne, a as St, u as jt, b as Z, g as Me, c as Gt, d as Le, e as Yt, f as Zt, h as zt, j as xt, k as Xt, o as Jt, l as Qt } from "./floating-ui.react-dom-0ol4sFzt.mjs";
import * as en from "react-dom";
import { C as Je } from "./calendar-DDie8jSH.mjs";
import { D as Qe } from "./date-field-D_6iP2fC.mjs";
import { D as _e } from "./drawer-Boqmgh-i.mjs";
import { b as tn } from "./icon-DNHpBTHs-JfI8WyiR.mjs";
import { c as nn } from "./bind-CU-R61T-.mjs";
var rn = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], Ie = /* @__PURE__ */ rn.join(","), Tt = typeof Element > "u", ge = Tt ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, Ae = !Tt && Element.prototype.getRootNode ? function(e) {
  var t;
  return e == null || (t = e.getRootNode) === null || t === void 0 ? void 0 : t.call(e);
} : function(e) {
  return e?.ownerDocument;
}, ke = function(t, n) {
  var r;
  n === void 0 && (n = !0);
  var o = t == null || (r = t.getAttribute) === null || r === void 0 ? void 0 : r.call(t, "inert"), i = o === "" || o === "true", s = i || n && t && // closest does not exist on shadow roots, so we fall back to a manual
  // lookup upward, in case it is not defined.
  (typeof t.closest == "function" ? t.closest("[inert]") : ke(t.parentNode));
  return s;
}, on = function(t) {
  var n, r = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
  return r === "" || r === "true";
}, Ct = function(t, n, r) {
  if (ke(t))
    return [];
  var o = Array.prototype.slice.apply(t.querySelectorAll(Ie));
  return n && ge.call(t, Ie) && o.unshift(t), o = o.filter(r), o;
}, De = function(t, n, r) {
  for (var o = [], i = Array.from(t); i.length; ) {
    var s = i.shift();
    if (!ke(s, !1))
      if (s.tagName === "SLOT") {
        var u = s.assignedElements(), d = u.length ? u : s.children, a = De(d, !0, r);
        r.flatten ? o.push.apply(o, a) : o.push({
          scopeParent: s,
          candidates: a
        });
      } else {
        var v = ge.call(s, Ie);
        v && r.filter(s) && (n || !t.includes(s)) && o.push(s);
        var E = s.shadowRoot || // check for an undisclosed shadow
        typeof r.getShadowRoot == "function" && r.getShadowRoot(s), I = !ke(E, !1) && (!r.shadowRootFilter || r.shadowRootFilter(s));
        if (E && I) {
          var f = De(E === !0 ? s.children : E.children, !0, r);
          r.flatten ? o.push.apply(o, f) : o.push({
            scopeParent: s,
            candidates: f
          });
        } else
          i.unshift.apply(i, s.children);
      }
  }
  return o;
}, It = function(t) {
  return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, At = function(t) {
  if (!t)
    throw new Error("No node provided");
  return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || on(t)) && !It(t) ? 0 : t.tabIndex;
}, sn = function(t, n) {
  var r = At(t);
  return r < 0 && n && !It(t) ? 0 : r;
}, an = function(t, n) {
  return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
}, kt = function(t) {
  return t.tagName === "INPUT";
}, un = function(t) {
  return kt(t) && t.type === "hidden";
}, cn = function(t) {
  var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
    return r.tagName === "SUMMARY";
  });
  return n;
}, ln = function(t, n) {
  for (var r = 0; r < t.length; r++)
    if (t[r].checked && t[r].form === n)
      return t[r];
}, fn = function(t) {
  if (!t.name)
    return !0;
  var n = t.form || Ae(t), r = function(u) {
    return n.querySelectorAll('input[type="radio"][name="' + u + '"]');
  }, o;
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
    o = r(window.CSS.escape(t.name));
  else
    try {
      o = r(t.name);
    } catch (s) {
      return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", s.message), !1;
    }
  var i = ln(o, t.form);
  return !i || i === t;
}, dn = function(t) {
  return kt(t) && t.type === "radio";
}, vn = function(t) {
  return dn(t) && !fn(t);
}, bn = function(t) {
  var n, r = t && Ae(t), o = (n = r) === null || n === void 0 ? void 0 : n.host, i = !1;
  if (r && r !== t) {
    var s, u, d;
    for (i = !!((s = o) !== null && s !== void 0 && (u = s.ownerDocument) !== null && u !== void 0 && u.contains(o) || t != null && (d = t.ownerDocument) !== null && d !== void 0 && d.contains(t)); !i && o; ) {
      var a, v, E;
      r = Ae(o), o = (a = r) === null || a === void 0 ? void 0 : a.host, i = !!((v = o) !== null && v !== void 0 && (E = v.ownerDocument) !== null && E !== void 0 && E.contains(o));
    }
  }
  return i;
}, et = function(t) {
  var n = t.getBoundingClientRect(), r = n.width, o = n.height;
  return r === 0 && o === 0;
}, mn = function(t, n) {
  var r = n.displayCheck, o = n.getShadowRoot;
  if (r === "full-native" && "checkVisibility" in t) {
    var i = t.checkVisibility({
      // Checking opacity might be desirable for some use cases, but natively,
      // opacity zero elements _are_ focusable and tabbable.
      checkOpacity: !1,
      opacityProperty: !1,
      contentVisibilityAuto: !0,
      visibilityProperty: !0,
      // This is an alias for `visibilityProperty`. Contemporary browsers
      // support both. However, this alias has wider browser support (Chrome
      // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
      // we include it anyway.
      checkVisibilityCSS: !0
    });
    return !i;
  }
  if (getComputedStyle(t).visibility === "hidden")
    return !0;
  var s = ge.call(t, "details>summary:first-of-type"), u = s ? t.parentElement : t;
  if (ge.call(u, "details:not([open]) *"))
    return !0;
  if (!r || r === "full" || // full-native can run this branch when it falls through in case
  // Element#checkVisibility is unsupported
  r === "full-native" || r === "legacy-full") {
    if (typeof o == "function") {
      for (var d = t; t; ) {
        var a = t.parentElement, v = Ae(t);
        if (a && !a.shadowRoot && o(a) === !0)
          return et(t);
        t.assignedSlot ? t = t.assignedSlot : !a && v !== t.ownerDocument ? t = v.host : t = a;
      }
      t = d;
    }
    if (bn(t))
      return !t.getClientRects().length;
    if (r !== "legacy-full")
      return !0;
  } else if (r === "non-zero-area")
    return et(t);
  return !1;
}, gn = function(t) {
  if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
    for (var n = t.parentElement; n; ) {
      if (n.tagName === "FIELDSET" && n.disabled) {
        for (var r = 0; r < n.children.length; r++) {
          var o = n.children.item(r);
          if (o.tagName === "LEGEND")
            return ge.call(n, "fieldset[disabled] *") ? !0 : !o.contains(t);
        }
        return !0;
      }
      n = n.parentElement;
    }
  return !1;
}, He = function(t, n) {
  return !(n.disabled || un(n) || mn(n, t) || // For a details element with a summary, the summary element gets the focus
  cn(n) || gn(n));
}, Ue = function(t, n) {
  return !(vn(n) || At(n) < 0 || !He(t, n));
}, pn = function(t) {
  var n = parseInt(t.getAttribute("tabindex"), 10);
  return !!(isNaN(n) || n >= 0);
}, Dt = function(t) {
  var n = [], r = [];
  return t.forEach(function(o, i) {
    var s = !!o.scopeParent, u = s ? o.scopeParent : o, d = sn(u, s), a = s ? Dt(o.candidates) : u;
    d === 0 ? s ? n.push.apply(n, a) : n.push(u) : r.push({
      documentOrder: i,
      tabIndex: d,
      item: o,
      isScope: s,
      content: a
    });
  }), r.sort(an).reduce(function(o, i) {
    return i.isScope ? o.push.apply(o, i.content) : o.push(i.content), o;
  }, []).concat(n);
}, Ne = function(t, n) {
  n = n || {};
  var r;
  return n.getShadowRoot ? r = De([t], n.includeContainer, {
    filter: Ue.bind(null, n),
    flatten: !1,
    getShadowRoot: n.getShadowRoot,
    shadowRootFilter: pn
  }) : r = Ct(t, n.includeContainer, Ue.bind(null, n)), Dt(r);
}, hn = function(t, n) {
  n = n || {};
  var r;
  return n.getShadowRoot ? r = De([t], n.includeContainer, {
    filter: He.bind(null, n),
    flatten: !0,
    getShadowRoot: n.getShadowRoot
  }) : r = Ct(t, n.includeContainer, He.bind(null, n)), r;
}, Pt = function(t, n) {
  if (n = n || {}, !t)
    throw new Error("No node provided");
  return ge.call(t, Ie) === !1 ? !1 : Ue(n, t);
};
function Rn() {
  const e = navigator.userAgentData;
  return e != null && e.platform ? e.platform : navigator.platform;
}
function Nt() {
  const e = navigator.userAgentData;
  return e && Array.isArray(e.brands) ? e.brands.map((t) => {
    let {
      brand: n,
      version: r
    } = t;
    return n + "/" + r;
  }).join(" ") : navigator.userAgent;
}
function En() {
  return /apple/i.test(navigator.vendor);
}
function qe() {
  const e = /android/i;
  return e.test(Rn()) || e.test(Nt());
}
function yn() {
  return Nt().includes("jsdom/");
}
const tt = "data-floating-ui-focusable", wn = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
function ve(e) {
  let t = e.activeElement;
  for (; ((n = t) == null || (n = n.shadowRoot) == null ? void 0 : n.activeElement) != null; ) {
    var n;
    t = t.shadowRoot.activeElement;
  }
  return t;
}
function U(e, t) {
  if (!e || !t)
    return !1;
  const n = t.getRootNode == null ? void 0 : t.getRootNode();
  if (e.contains(t))
    return !0;
  if (n && St(n)) {
    let r = t;
    for (; r; ) {
      if (e === r)
        return !0;
      r = r.parentNode || r.host;
    }
  }
  return !1;
}
function ue(e) {
  return "composedPath" in e ? e.composedPath()[0] : e.target;
}
function Ve(e, t) {
  if (t == null)
    return !1;
  if ("composedPath" in e)
    return e.composedPath().includes(t);
  const n = e;
  return n.target != null && t.contains(n.target);
}
function Sn(e) {
  return e.matches("html,body");
}
function z(e) {
  return e?.ownerDocument || document;
}
function Ot(e) {
  return ne(e) && e.matches(wn);
}
function nt(e) {
  return e ? e.getAttribute("role") === "combobox" && Ot(e) : !1;
}
function rt(e) {
  return e ? e.hasAttribute(tt) ? e : e.querySelector("[" + tt + "]") || e : null;
}
function be(e, t, n) {
  return n === void 0 && (n = !0), e.filter((o) => {
    var i;
    return o.parentId === t && (!n || ((i = o.context) == null ? void 0 : i.open));
  }).flatMap((o) => [o, ...be(e, o.id, n)]);
}
function ot(e, t) {
  var n;
  let r = [], o = (n = e.find((i) => i.id === t)) == null ? void 0 : n.parentId;
  for (; o; ) {
    const i = e.find((s) => s.id === o);
    o = i?.parentId, i && (r = r.concat(i));
  }
  return r;
}
function $e(e) {
  e.preventDefault(), e.stopPropagation();
}
function xn(e) {
  return "nativeEvent" in e;
}
function Tn(e) {
  return e.mozInputSource === 0 && e.isTrusted ? !0 : qe() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function Cn(e) {
  return yn() ? !1 : !qe() && e.width === 0 && e.height === 0 || qe() && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
  e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
}
function it(e, t) {
  return ["mouse", "pen"].includes(e);
}
var In = typeof document < "u", An = function() {
}, G = In ? wt : An;
const kn = {
  ...c
};
function Be(e) {
  const t = c.useRef(e);
  return G(() => {
    t.current = e;
  }), t;
}
const Dn = kn.useInsertionEffect, Pn = Dn || ((e) => e());
function J(e) {
  const t = c.useRef(() => {
    if (process.env.NODE_ENV !== "production")
      throw new Error("Cannot call an event handler while rendering.");
  });
  return Pn(() => {
    t.current = e;
  }), c.useCallback(function() {
    for (var n = arguments.length, r = new Array(n), o = 0; o < n; o++)
      r[o] = arguments[o];
    return t.current == null ? void 0 : t.current(...r);
  }, []);
}
const Ee = () => ({
  getShadowRoot: !0,
  displayCheck: (
    // JSDOM does not support the `tabbable` library. To solve this we can
    // check if `ResizeObserver` is a real function (not polyfilled), which
    // determines if the current environment is JSDOM-like.
    typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
  )
});
function Ft(e, t) {
  const n = Ne(e, Ee()), r = n.length;
  if (r === 0) return;
  const o = ve(z(e)), i = n.indexOf(o), s = i === -1 ? t === 1 ? 0 : r - 1 : i + t;
  return n[s];
}
function Mt(e) {
  return Ft(z(e).body, 1) || e;
}
function Lt(e) {
  return Ft(z(e).body, -1) || e;
}
function he(e, t) {
  const n = t || e.currentTarget, r = e.relatedTarget;
  return !r || !U(n, r);
}
function Nn(e) {
  Ne(e, Ee()).forEach((n) => {
    n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
  });
}
function st(e) {
  e.querySelectorAll("[data-tabindex]").forEach((n) => {
    const r = n.dataset.tabindex;
    delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
  });
}
const On = "data-floating-ui-focusable", at = "active", ut = "selected", Fn = {
  ...c
};
let ct = !1, Mn = 0;
const lt = () => (
  // Ensure the id is unique with multiple independent versions of Floating UI
  // on <React 18
  "floating-ui-" + Math.random().toString(36).slice(2, 6) + Mn++
);
function Ln() {
  const [e, t] = c.useState(() => ct ? lt() : void 0);
  return G(() => {
    e == null && t(lt());
  }, []), c.useEffect(() => {
    ct = !0;
  }, []), e;
}
const _n = Fn.useId, _t = _n || Ln;
let je;
process.env.NODE_ENV !== "production" && (je = /* @__PURE__ */ new Set());
function Vn() {
  for (var e, t = arguments.length, n = new Array(t), r = 0; r < t; r++)
    n[r] = arguments[r];
  const o = "Floating UI: " + n.join(" ");
  if (!((e = je) != null && e.has(o))) {
    var i;
    (i = je) == null || i.add(o), console.error(o);
  }
}
function $n() {
  const e = /* @__PURE__ */ new Map();
  return {
    emit(t, n) {
      var r;
      (r = e.get(t)) == null || r.forEach((o) => o(n));
    },
    on(t, n) {
      e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n);
    },
    off(t, n) {
      var r;
      (r = e.get(t)) == null || r.delete(n);
    }
  };
}
const Bn = /* @__PURE__ */ c.createContext(null), Kn = /* @__PURE__ */ c.createContext(null), Wn = () => {
  var e;
  return ((e = c.useContext(Bn)) == null ? void 0 : e.id) || null;
}, Ye = () => c.useContext(Kn);
function Re(e) {
  return "data-floating-ui-" + e;
}
function Hn(e) {
  e.current !== -1 && (clearTimeout(e.current), e.current = -1);
}
let ft = 0;
function de(e, t) {
  t === void 0 && (t = {});
  const {
    preventScroll: n = !1,
    cancelPrevious: r = !0,
    sync: o = !1
  } = t;
  r && cancelAnimationFrame(ft);
  const i = () => e?.focus({
    preventScroll: n
  });
  o ? i() : ft = requestAnimationFrame(i);
}
function Un(e) {
  return e?.ownerDocument || document;
}
const me = {
  inert: /* @__PURE__ */ new WeakMap(),
  "aria-hidden": /* @__PURE__ */ new WeakMap(),
  none: /* @__PURE__ */ new WeakMap()
};
function dt(e) {
  return e === "inert" ? me.inert : e === "aria-hidden" ? me["aria-hidden"] : me.none;
}
let xe = /* @__PURE__ */ new WeakSet(), Te = {}, Ke = 0;
const qn = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype;
function Vt(e) {
  return e ? St(e) ? e.host : Vt(e.parentNode) : null;
}
const jn = (e, t) => t.map((n) => {
  if (e.contains(n))
    return n;
  const r = Vt(n);
  return e.contains(r) ? r : null;
}).filter((n) => n != null);
function Gn(e, t, n, r) {
  const o = "data-floating-ui-inert", i = r ? "inert" : n ? "aria-hidden" : null, s = jn(t, e), u = /* @__PURE__ */ new Set(), d = new Set(s), a = [];
  Te[o] || (Te[o] = /* @__PURE__ */ new WeakMap());
  const v = Te[o];
  s.forEach(E), I(t), u.clear();
  function E(f) {
    !f || u.has(f) || (u.add(f), f.parentNode && E(f.parentNode));
  }
  function I(f) {
    !f || d.has(f) || [].forEach.call(f.children, (h) => {
      if (xt(h) !== "script")
        if (u.has(h))
          I(h);
        else {
          const l = i ? h.getAttribute(i) : null, w = l !== null && l !== "false", x = dt(i), g = (x.get(h) || 0) + 1, p = (v.get(h) || 0) + 1;
          x.set(h, g), v.set(h, p), a.push(h), g === 1 && w && xe.add(h), p === 1 && h.setAttribute(o, ""), !w && i && h.setAttribute(i, i === "inert" ? "" : "true");
        }
    });
  }
  return Ke++, () => {
    a.forEach((f) => {
      const h = dt(i), w = (h.get(f) || 0) - 1, x = (v.get(f) || 0) - 1;
      h.set(f, w), v.set(f, x), w || (!xe.has(f) && i && f.removeAttribute(i), xe.delete(f)), x || f.removeAttribute(o);
    }), Ke--, Ke || (me.inert = /* @__PURE__ */ new WeakMap(), me["aria-hidden"] = /* @__PURE__ */ new WeakMap(), me.none = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakSet(), Te = {});
  };
}
function vt(e, t, n) {
  t === void 0 && (t = !1), n === void 0 && (n = !1);
  const r = Un(e[0]).body;
  return Gn(e.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))), r, t, n);
}
const Ze = {
  border: 0,
  clip: "rect(0 0 0 0)",
  height: "1px",
  margin: "-1px",
  overflow: "hidden",
  padding: 0,
  position: "fixed",
  whiteSpace: "nowrap",
  width: "1px",
  top: 0,
  left: 0
}, Pe = /* @__PURE__ */ c.forwardRef(function(t, n) {
  const [r, o] = c.useState();
  G(() => {
    En() && o("button");
  }, []);
  const i = {
    ref: n,
    tabIndex: 0,
    // Role is only for VoiceOver
    role: r,
    "aria-hidden": r ? void 0 : !0,
    [Re("focus-guard")]: "",
    style: Ze
  };
  return /* @__PURE__ */ N("span", {
    ...t,
    ...i
  });
}), Yn = {
  clipPath: "inset(50%)",
  position: "fixed",
  top: 0,
  left: 0
}, $t = /* @__PURE__ */ c.createContext(null), bt = /* @__PURE__ */ Re("portal");
function Zn(e) {
  e === void 0 && (e = {});
  const {
    id: t,
    root: n
  } = e, r = _t(), o = Bt(), [i, s] = c.useState(null), u = c.useRef(null);
  return G(() => () => {
    i?.remove(), queueMicrotask(() => {
      u.current = null;
    });
  }, [i]), G(() => {
    if (!r || u.current) return;
    const d = t ? document.getElementById(t) : null;
    if (!d) return;
    const a = document.createElement("div");
    a.id = r, a.setAttribute(bt, ""), d.appendChild(a), u.current = a, s(a);
  }, [t, r]), G(() => {
    if (n === null || !r || u.current) return;
    let d = n || o?.portalNode;
    d && !zt(d) && (d = d.current), d = d || document.body;
    let a = null;
    t && (a = document.createElement("div"), a.id = t, d.appendChild(a));
    const v = document.createElement("div");
    v.id = r, v.setAttribute(bt, ""), d = a || d, d.appendChild(v), u.current = v, s(v);
  }, [t, n, r, o]), i;
}
function zn(e) {
  const {
    children: t,
    id: n,
    root: r,
    preserveTabOrder: o = !0
  } = e, i = Zn({
    id: n,
    root: r
  }), [s, u] = c.useState(null), d = c.useRef(null), a = c.useRef(null), v = c.useRef(null), E = c.useRef(null), I = s?.modal, f = s?.open, h = (
    // The FocusManager and therefore floating element are currently open/
    // rendered.
    !!s && // Guards are only for non-modal focus management.
    !s.modal && // Don't render if unmount is transitioning.
    s.open && o && !!(r || i)
  );
  return c.useEffect(() => {
    if (!i || !o || I)
      return;
    function l(w) {
      i && he(w) && (w.type === "focusin" ? st : Nn)(i);
    }
    return i.addEventListener("focusin", l, !0), i.addEventListener("focusout", l, !0), () => {
      i.removeEventListener("focusin", l, !0), i.removeEventListener("focusout", l, !0);
    };
  }, [i, o, I]), c.useEffect(() => {
    i && (f || st(i));
  }, [f, i]), /* @__PURE__ */ Ce($t.Provider, {
    value: c.useMemo(() => ({
      preserveTabOrder: o,
      beforeOutsideRef: d,
      afterOutsideRef: a,
      beforeInsideRef: v,
      afterInsideRef: E,
      portalNode: i,
      setFocusManagerState: u
    }), [o, i]),
    children: [h && i && /* @__PURE__ */ N(Pe, {
      "data-type": "outside",
      ref: d,
      onFocus: (l) => {
        if (he(l, i)) {
          var w;
          (w = v.current) == null || w.focus();
        } else {
          const x = s ? s.domReference : null, g = Lt(x);
          g?.focus();
        }
      }
    }), h && i && /* @__PURE__ */ N("span", {
      "aria-owns": i.id,
      style: Yn
    }), i && /* @__PURE__ */ en.createPortal(t, i), h && i && /* @__PURE__ */ N(Pe, {
      "data-type": "outside",
      ref: a,
      onFocus: (l) => {
        if (he(l, i)) {
          var w;
          (w = E.current) == null || w.focus();
        } else {
          const x = s ? s.domReference : null, g = Mt(x);
          g?.focus(), s?.closeOnFocusOut && s?.onOpenChange(!1, l.nativeEvent, "focus-out");
        }
      }
    })]
  });
}
const Bt = () => c.useContext($t);
function mt(e) {
  return c.useMemo(() => (t) => {
    e.forEach((n) => {
      n && (n.current = t);
    });
  }, e);
}
const gt = 20;
let ce = [];
function ze() {
  ce = ce.filter((e) => {
    var t;
    return (t = e.deref()) == null ? void 0 : t.isConnected;
  });
}
function Xn(e) {
  ze(), e && xt(e) !== "body" && (ce.push(new WeakRef(e)), ce.length > gt && (ce = ce.slice(-gt)));
}
function pt() {
  ze();
  const e = ce[ce.length - 1];
  return e?.deref();
}
function Jn(e) {
  const t = Ee();
  return Pt(e, t) ? e : Ne(e, t)[0] || e;
}
function ht(e, t) {
  var n;
  if (!t.current.includes("floating") && !((n = e.getAttribute("role")) != null && n.includes("dialog")))
    return;
  const r = Ee(), i = hn(e, r).filter((u) => {
    const d = u.getAttribute("data-tabindex") || "";
    return Pt(u, r) || u.hasAttribute("data-tabindex") && !d.startsWith("-");
  }), s = e.getAttribute("tabindex");
  t.current.includes("floating") || i.length === 0 ? s !== "0" && e.setAttribute("tabindex", "0") : (s !== "-1" || e.hasAttribute("data-tabindex") && e.getAttribute("data-tabindex") !== "-1") && (e.setAttribute("tabindex", "-1"), e.setAttribute("data-tabindex", "-1"));
}
const Qn = /* @__PURE__ */ c.forwardRef(function(t, n) {
  return /* @__PURE__ */ N("button", {
    ...t,
    type: "button",
    ref: n,
    tabIndex: -1,
    style: Ze
  });
});
function er(e) {
  const {
    context: t,
    children: n,
    disabled: r = !1,
    order: o = ["content"],
    guards: i = !0,
    initialFocus: s = 0,
    returnFocus: u = !0,
    restoreFocus: d = !1,
    modal: a = !0,
    visuallyHiddenDismiss: v = !1,
    closeOnFocusOut: E = !0,
    outsideElementsInert: I = !1,
    getInsideElements: f = () => []
  } = e, {
    open: h,
    onOpenChange: l,
    events: w,
    dataRef: x,
    elements: {
      domReference: g,
      floating: p
    }
  } = t, L = J(() => {
    var y;
    return (y = x.current.floatingContext) == null ? void 0 : y.nodeId;
  }), K = J(f), W = typeof s == "number" && s < 0, O = nt(g) && W, B = qn(), re = B ? i : !0, Q = !re || B && I, T = Be(o), pe = Be(s), oe = Be(u), m = Ye(), b = Bt(), $ = c.useRef(null), _ = c.useRef(null), R = c.useRef(!1), F = c.useRef(!1), V = c.useRef(-1), Y = c.useRef(-1), fe = b != null, C = rt(p), X = J(function(y) {
    return y === void 0 && (y = C), y ? Ne(y, Ee()) : [];
  }), P = J((y) => {
    const A = X(y);
    return T.current.map((S) => g && S === "reference" ? g : C && S === "floating" ? C : A).filter(Boolean).flat();
  });
  c.useEffect(() => {
    if (r || !a) return;
    function y(S) {
      if (S.key === "Tab") {
        U(C, ve(z(C))) && X().length === 0 && !O && $e(S);
        const D = P(), M = ue(S);
        T.current[0] === "reference" && M === g && ($e(S), S.shiftKey ? de(D[D.length - 1]) : de(D[1])), T.current[1] === "floating" && M === C && S.shiftKey && ($e(S), de(D[0]));
      }
    }
    const A = z(C);
    return A.addEventListener("keydown", y), () => {
      A.removeEventListener("keydown", y);
    };
  }, [r, g, C, a, T, O, X, P]), c.useEffect(() => {
    if (r || !p) return;
    function y(A) {
      const S = ue(A), M = X().indexOf(S);
      M !== -1 && (V.current = M);
    }
    return p.addEventListener("focusin", y), () => {
      p.removeEventListener("focusin", y);
    };
  }, [r, p, X]), c.useEffect(() => {
    if (r || !E) return;
    function y() {
      F.current = !0, setTimeout(() => {
        F.current = !1;
      });
    }
    function A(M) {
      const k = M.relatedTarget, ee = M.currentTarget, j = ue(M);
      queueMicrotask(() => {
        const H = L(), le = !(U(g, k) || U(p, k) || U(k, p) || U(b?.portalNode, k) || k != null && k.hasAttribute(Re("focus-guard")) || m && (be(m.nodesRef.current, H).find((se) => {
          var te, ae;
          return U((te = se.context) == null ? void 0 : te.elements.floating, k) || U((ae = se.context) == null ? void 0 : ae.elements.domReference, k);
        }) || ot(m.nodesRef.current, H).find((se) => {
          var te, ae, Xe;
          return [(te = se.context) == null ? void 0 : te.elements.floating, rt((ae = se.context) == null ? void 0 : ae.elements.floating)].includes(k) || ((Xe = se.context) == null ? void 0 : Xe.elements.domReference) === k;
        })));
        if (ee === g && C && ht(C, T), d && ee !== g && !(j != null && j.isConnected) && ve(z(C)) === z(C).body) {
          ne(C) && C.focus();
          const se = V.current, te = X(), ae = te[se] || te[te.length - 1] || C;
          ne(ae) && ae.focus();
        }
        if (x.current.insideReactTree) {
          x.current.insideReactTree = !1;
          return;
        }
        (O || !a) && k && le && !F.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
        k !== pt() && (R.current = !0, l(!1, M, "focus-out"));
      });
    }
    const S = !!(!m && b);
    function D() {
      Hn(Y), x.current.insideReactTree = !0, Y.current = window.setTimeout(() => {
        x.current.insideReactTree = !1;
      });
    }
    if (p && ne(g))
      return g.addEventListener("focusout", A), g.addEventListener("pointerdown", y), p.addEventListener("focusout", A), S && p.addEventListener("focusout", D, !0), () => {
        g.removeEventListener("focusout", A), g.removeEventListener("pointerdown", y), p.removeEventListener("focusout", A), S && p.removeEventListener("focusout", D, !0);
      };
  }, [r, g, p, C, a, m, b, l, E, d, X, O, L, T, x]);
  const q = c.useRef(null), ie = c.useRef(null), Oe = mt([q, b?.beforeInsideRef]), Fe = mt([ie, b?.afterInsideRef]);
  c.useEffect(() => {
    var y, A;
    if (r || !p) return;
    const S = Array.from((b == null || (y = b.portalNode) == null ? void 0 : y.querySelectorAll("[" + Re("portal") + "]")) || []), M = (A = (m ? ot(m.nodesRef.current, L()) : []).find((j) => {
      var H;
      return nt(((H = j.context) == null ? void 0 : H.elements.domReference) || null);
    })) == null || (A = A.context) == null ? void 0 : A.elements.domReference, k = [p, M, ...S, ...K(), $.current, _.current, q.current, ie.current, b?.beforeOutsideRef.current, b?.afterOutsideRef.current, T.current.includes("reference") || O ? g : null].filter((j) => j != null), ee = a || O ? vt(k, !Q, Q) : vt(k);
    return () => {
      ee();
    };
  }, [r, g, p, a, T, b, O, re, Q, m, L, K]), G(() => {
    if (r || !ne(C)) return;
    const y = z(C), A = ve(y);
    queueMicrotask(() => {
      const S = P(C), D = pe.current, M = (typeof D == "number" ? S[D] : D.current) || C, k = U(C, A);
      !W && !k && h && de(M, {
        preventScroll: M === C
      });
    });
  }, [r, h, C, W, P, pe]), G(() => {
    if (r || !C) return;
    const y = z(C), A = ve(y);
    Xn(A);
    function S(k) {
      let {
        reason: ee,
        event: j,
        nested: H
      } = k;
      if (["hover", "safe-polygon"].includes(ee) && j.type === "mouseleave" && (R.current = !0), ee === "outside-press")
        if (H)
          R.current = !1;
        else if (Tn(j) || Cn(j))
          R.current = !1;
        else {
          let le = !1;
          document.createElement("div").focus({
            get preventScroll() {
              return le = !0, !1;
            }
          }), le ? R.current = !1 : R.current = !0;
        }
    }
    w.on("openchange", S);
    const D = y.createElement("span");
    D.setAttribute("tabindex", "-1"), D.setAttribute("aria-hidden", "true"), Object.assign(D.style, Ze), fe && g && g.insertAdjacentElement("afterend", D);
    function M() {
      if (typeof oe.current == "boolean") {
        const k = g || pt();
        return k && k.isConnected ? k : D;
      }
      return oe.current.current || D;
    }
    return () => {
      w.off("openchange", S);
      const k = ve(y), ee = U(p, k) || m && be(m.nodesRef.current, L(), !1).some((H) => {
        var le;
        return U((le = H.context) == null ? void 0 : le.elements.floating, k);
      }), j = M();
      queueMicrotask(() => {
        const H = Jn(j);
        // eslint-disable-next-line react-hooks/exhaustive-deps
        oe.current && !R.current && ne(H) && // 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
        (!(H !== k && k !== y.body) || ee) && H.focus({
          preventScroll: !0
        }), D.remove();
      });
    };
  }, [r, p, C, oe, x, w, m, fe, g, L]), c.useEffect(() => (queueMicrotask(() => {
    R.current = !1;
  }), () => {
    queueMicrotask(ze);
  }), [r]), G(() => {
    if (!r && b)
      return b.setFocusManagerState({
        modal: a,
        closeOnFocusOut: E,
        open: h,
        onOpenChange: l,
        domReference: g
      }), () => {
        b.setFocusManagerState(null);
      };
  }, [r, b, a, h, l, E, g]), G(() => {
    r || C && ht(C, T);
  }, [r, C, T]);
  function ye(y) {
    return r || !v || !a ? null : /* @__PURE__ */ N(Qn, {
      ref: y === "start" ? $ : _,
      onClick: (A) => l(!1, A.nativeEvent),
      children: typeof v == "string" ? v : "Dismiss"
    });
  }
  const we = !r && re && (a ? !O : !0) && (fe || a);
  return /* @__PURE__ */ Ce(Kt, {
    children: [we && /* @__PURE__ */ N(Pe, {
      "data-type": "inside",
      ref: Oe,
      onFocus: (y) => {
        if (a) {
          const S = P();
          de(o[0] === "reference" ? S[0] : S[S.length - 1]);
        } else if (b != null && b.preserveTabOrder && b.portalNode)
          if (R.current = !1, he(y, b.portalNode)) {
            const S = Mt(g);
            S?.focus();
          } else {
            var A;
            (A = b.beforeOutsideRef.current) == null || A.focus();
          }
      }
    }), !O && ye("start"), n, ye("end"), we && /* @__PURE__ */ N(Pe, {
      "data-type": "inside",
      ref: Fe,
      onFocus: (y) => {
        if (a)
          de(P()[0]);
        else if (b != null && b.preserveTabOrder && b.portalNode)
          if (E && (R.current = !0), he(y, b.portalNode)) {
            const S = Lt(g);
            S?.focus();
          } else {
            var A;
            (A = b.afterOutsideRef.current) == null || A.focus();
          }
      }
    })]
  });
}
function Rt(e) {
  return ne(e.target) && e.target.tagName === "BUTTON";
}
function tr(e) {
  return ne(e.target) && e.target.tagName === "A";
}
function Et(e) {
  return Ot(e);
}
function nr(e, t) {
  t === void 0 && (t = {});
  const {
    open: n,
    onOpenChange: r,
    dataRef: o,
    elements: {
      domReference: i
    }
  } = e, {
    enabled: s = !0,
    event: u = "click",
    toggle: d = !0,
    ignoreMouse: a = !1,
    keyboardHandlers: v = !0,
    stickIfOpen: E = !0
  } = t, I = c.useRef(), f = c.useRef(!1), h = c.useMemo(() => ({
    onPointerDown(l) {
      I.current = l.pointerType;
    },
    onMouseDown(l) {
      const w = I.current;
      l.button === 0 && u !== "click" && (it(w) && a || (n && d && (!(o.current.openEvent && E) || o.current.openEvent.type === "mousedown") ? r(!1, l.nativeEvent, "click") : (l.preventDefault(), r(!0, l.nativeEvent, "click"))));
    },
    onClick(l) {
      const w = I.current;
      if (u === "mousedown" && I.current) {
        I.current = void 0;
        return;
      }
      it(w) && a || (n && d && (!(o.current.openEvent && E) || o.current.openEvent.type === "click") ? r(!1, l.nativeEvent, "click") : r(!0, l.nativeEvent, "click"));
    },
    onKeyDown(l) {
      I.current = void 0, !(l.defaultPrevented || !v || Rt(l)) && (l.key === " " && !Et(i) && (l.preventDefault(), f.current = !0), !tr(l) && l.key === "Enter" && r(!(n && d), l.nativeEvent, "click"));
    },
    onKeyUp(l) {
      l.defaultPrevented || !v || Rt(l) || Et(i) || l.key === " " && f.current && (f.current = !1, r(!(n && d), l.nativeEvent, "click"));
    }
  }), [o, i, u, a, v, r, n, E, d]);
  return c.useMemo(() => s ? {
    reference: h
  } : {}, [s, h]);
}
const rr = {
  pointerdown: "onPointerDown",
  mousedown: "onMouseDown",
  click: "onClick"
}, or = {
  pointerdown: "onPointerDownCapture",
  mousedown: "onMouseDownCapture",
  click: "onClickCapture"
}, yt = (e) => {
  var t, n;
  return {
    escapeKey: typeof e == "boolean" ? e : (t = e?.escapeKey) != null ? t : !1,
    outsidePress: typeof e == "boolean" ? e : (n = e?.outsidePress) != null ? n : !0
  };
};
function ir(e, t) {
  t === void 0 && (t = {});
  const {
    open: n,
    onOpenChange: r,
    elements: o,
    dataRef: i
  } = e, {
    enabled: s = !0,
    escapeKey: u = !0,
    outsidePress: d = !0,
    outsidePressEvent: a = "pointerdown",
    referencePress: v = !1,
    referencePressEvent: E = "pointerdown",
    ancestorScroll: I = !1,
    bubbles: f,
    capture: h
  } = t, l = Ye(), w = J(typeof d == "function" ? d : () => !1), x = typeof d == "function" ? w : d, g = c.useRef(!1), {
    escapeKey: p,
    outsidePress: L
  } = yt(f), {
    escapeKey: K,
    outsidePress: W
  } = yt(h), O = c.useRef(!1), B = J((m) => {
    var b;
    if (!n || !s || !u || m.key !== "Escape" || O.current)
      return;
    const $ = (b = i.current.floatingContext) == null ? void 0 : b.nodeId, _ = l ? be(l.nodesRef.current, $) : [];
    if (!p && (m.stopPropagation(), _.length > 0)) {
      let R = !0;
      if (_.forEach((F) => {
        var V;
        if ((V = F.context) != null && V.open && !F.context.dataRef.current.__escapeKeyBubbles) {
          R = !1;
          return;
        }
      }), !R)
        return;
    }
    r(!1, xn(m) ? m.nativeEvent : m, "escape-key");
  }), re = J((m) => {
    var b;
    const $ = () => {
      var _;
      B(m), (_ = ue(m)) == null || _.removeEventListener("keydown", $);
    };
    (b = ue(m)) == null || b.addEventListener("keydown", $);
  }), Q = J((m) => {
    var b;
    const $ = i.current.insideReactTree;
    i.current.insideReactTree = !1;
    const _ = g.current;
    if (g.current = !1, a === "click" && _ || $ || typeof x == "function" && !x(m))
      return;
    const R = ue(m), F = "[" + Re("inert") + "]", V = z(o.floating).querySelectorAll(F);
    let Y = Z(R) ? R : null;
    for (; Y && !Le(Y); ) {
      const P = Yt(Y);
      if (Le(P) || !Z(P))
        break;
      Y = P;
    }
    if (V.length && Z(R) && !Sn(R) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
    !U(R, o.floating) && // If the target root element contains none of the markers, then the
    // element was injected after the floating element rendered.
    Array.from(V).every((P) => !U(Y, P)))
      return;
    if (ne(R) && oe) {
      const P = Le(R), q = Zt(R), ie = /auto|scroll/, Oe = P || ie.test(q.overflowX), Fe = P || ie.test(q.overflowY), ye = Oe && R.clientWidth > 0 && R.scrollWidth > R.clientWidth, we = Fe && R.clientHeight > 0 && R.scrollHeight > R.clientHeight, y = q.direction === "rtl", A = we && (y ? m.offsetX <= R.offsetWidth - R.clientWidth : m.offsetX > R.clientWidth), S = ye && m.offsetY > R.clientHeight;
      if (A || S)
        return;
    }
    const fe = (b = i.current.floatingContext) == null ? void 0 : b.nodeId, C = l && be(l.nodesRef.current, fe).some((P) => {
      var q;
      return Ve(m, (q = P.context) == null ? void 0 : q.elements.floating);
    });
    if (Ve(m, o.floating) || Ve(m, o.domReference) || C)
      return;
    const X = l ? be(l.nodesRef.current, fe) : [];
    if (X.length > 0) {
      let P = !0;
      if (X.forEach((q) => {
        var ie;
        if ((ie = q.context) != null && ie.open && !q.context.dataRef.current.__outsidePressBubbles) {
          P = !1;
          return;
        }
      }), !P)
        return;
    }
    r(!1, m, "outside-press");
  }), T = J((m) => {
    var b;
    const $ = () => {
      var _;
      Q(m), (_ = ue(m)) == null || _.removeEventListener(a, $);
    };
    (b = ue(m)) == null || b.addEventListener(a, $);
  });
  c.useEffect(() => {
    if (!n || !s)
      return;
    i.current.__escapeKeyBubbles = p, i.current.__outsidePressBubbles = L;
    let m = -1;
    function b(V) {
      r(!1, V, "ancestor-scroll");
    }
    function $() {
      window.clearTimeout(m), O.current = !0;
    }
    function _() {
      m = window.setTimeout(
        () => {
          O.current = !1;
        },
        // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
        // Only apply to WebKit for the test to remain 0ms.
        Gt() ? 5 : 0
      );
    }
    const R = z(o.floating);
    u && (R.addEventListener("keydown", K ? re : B, K), R.addEventListener("compositionstart", $), R.addEventListener("compositionend", _)), x && R.addEventListener(a, W ? T : Q, W);
    let F = [];
    return I && (Z(o.domReference) && (F = Me(o.domReference)), Z(o.floating) && (F = F.concat(Me(o.floating))), !Z(o.reference) && o.reference && o.reference.contextElement && (F = F.concat(Me(o.reference.contextElement)))), F = F.filter((V) => {
      var Y;
      return V !== ((Y = R.defaultView) == null ? void 0 : Y.visualViewport);
    }), F.forEach((V) => {
      V.addEventListener("scroll", b, {
        passive: !0
      });
    }), () => {
      u && (R.removeEventListener("keydown", K ? re : B, K), R.removeEventListener("compositionstart", $), R.removeEventListener("compositionend", _)), x && R.removeEventListener(a, W ? T : Q, W), F.forEach((V) => {
        V.removeEventListener("scroll", b);
      }), window.clearTimeout(m);
    };
  }, [i, o, u, x, a, n, r, I, s, p, L, B, K, re, Q, W, T]), c.useEffect(() => {
    i.current.insideReactTree = !1;
  }, [i, x, a]);
  const pe = c.useMemo(() => ({
    onKeyDown: B,
    ...v && {
      [rr[E]]: (m) => {
        r(!1, m.nativeEvent, "reference-press");
      },
      ...E !== "click" && {
        onClick(m) {
          r(!1, m.nativeEvent, "reference-press");
        }
      }
    }
  }), [B, r, v, E]), oe = c.useMemo(() => {
    function m(b) {
      b.button === 0 && (g.current = !0);
    }
    return {
      onKeyDown: B,
      onMouseDown: m,
      onMouseUp: m,
      [or[a]]: () => {
        i.current.insideReactTree = !0;
      }
    };
  }, [B, a, i]);
  return c.useMemo(() => s ? {
    reference: pe,
    floating: oe
  } : {}, [s, pe, oe]);
}
function sr(e) {
  const {
    open: t = !1,
    onOpenChange: n,
    elements: r
  } = e, o = _t(), i = c.useRef({}), [s] = c.useState(() => $n()), u = Wn() != null;
  if (process.env.NODE_ENV !== "production") {
    const f = r.reference;
    f && !Z(f) && Vn("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
  }
  const [d, a] = c.useState(r.reference), v = J((f, h, l) => {
    i.current.openEvent = f ? h : void 0, s.emit("openchange", {
      open: f,
      event: h,
      reason: l,
      nested: u
    }), n?.(f, h, l);
  }), E = c.useMemo(() => ({
    setPositionReference: a
  }), []), I = c.useMemo(() => ({
    reference: d || r.reference || null,
    floating: r.floating || null,
    domReference: r.reference
  }), [d, r.reference, r.floating]);
  return c.useMemo(() => ({
    dataRef: i,
    open: t,
    onOpenChange: v,
    elements: I,
    events: s,
    floatingId: o,
    refs: E
  }), [t, v, I, s, o, E]);
}
function ar(e) {
  e === void 0 && (e = {});
  const {
    nodeId: t
  } = e, n = sr({
    ...e,
    elements: {
      reference: null,
      floating: null,
      ...e.elements
    }
  }), r = e.rootContext || n, o = r.elements, [i, s] = c.useState(null), [u, d] = c.useState(null), v = o?.domReference || i, E = c.useRef(null), I = Ye();
  G(() => {
    v && (E.current = v);
  }, [v]);
  const f = jt({
    ...e,
    elements: {
      ...o,
      ...u && {
        reference: u
      }
    }
  }), h = c.useCallback((p) => {
    const L = Z(p) ? {
      getBoundingClientRect: () => p.getBoundingClientRect(),
      getClientRects: () => p.getClientRects(),
      contextElement: p
    } : p;
    d(L), f.refs.setReference(L);
  }, [f.refs]), l = c.useCallback((p) => {
    (Z(p) || p === null) && (E.current = p, s(p)), (Z(f.refs.reference.current) || f.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
    // `null` to support `positionReference` + an unstable `reference`
    // callback ref.
    p !== null && !Z(p)) && f.refs.setReference(p);
  }, [f.refs]), w = c.useMemo(() => ({
    ...f.refs,
    setReference: l,
    setPositionReference: h,
    domReference: E
  }), [f.refs, l, h]), x = c.useMemo(() => ({
    ...f.elements,
    domReference: v
  }), [f.elements, v]), g = c.useMemo(() => ({
    ...f,
    ...r,
    refs: w,
    elements: x,
    nodeId: t
  }), [f, w, x, t, r]);
  return G(() => {
    r.dataRef.current.floatingContext = g;
    const p = I?.nodesRef.current.find((L) => L.id === t);
    p && (p.context = g);
  }), c.useMemo(() => ({
    ...f,
    context: g,
    refs: w,
    elements: x
  }), [f, w, x, g]);
}
function We(e, t, n) {
  const r = /* @__PURE__ */ new Map(), o = n === "item";
  let i = e;
  if (o && e) {
    const {
      [at]: s,
      [ut]: u,
      ...d
    } = e;
    i = d;
  }
  return {
    ...n === "floating" && {
      tabIndex: -1,
      [On]: ""
    },
    ...i,
    ...t.map((s) => {
      const u = s ? s[n] : null;
      return typeof u == "function" ? e ? u(e) : null : u;
    }).concat(e).reduce((s, u) => (u && Object.entries(u).forEach((d) => {
      let [a, v] = d;
      if (!(o && [at, ut].includes(a)))
        if (a.indexOf("on") === 0) {
          if (r.has(a) || r.set(a, []), typeof v == "function") {
            var E;
            (E = r.get(a)) == null || E.push(v), s[a] = function() {
              for (var I, f = arguments.length, h = new Array(f), l = 0; l < f; l++)
                h[l] = arguments[l];
              return (I = r.get(a)) == null ? void 0 : I.map((w) => w(...h)).find((w) => w !== void 0);
            };
          }
        } else
          s[a] = v;
    }), s), {})
  };
}
function ur(e) {
  e === void 0 && (e = []);
  const t = e.map((u) => u?.reference), n = e.map((u) => u?.floating), r = e.map((u) => u?.item), o = c.useCallback(
    (u) => We(u, e, "reference"),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    t
  ), i = c.useCallback(
    (u) => We(u, e, "floating"),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    n
  ), s = c.useCallback(
    (u) => We(u, e, "item"),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    r
  );
  return c.useMemo(() => ({
    getReferenceProps: o,
    getFloatingProps: i,
    getItemProps: s
  }), [o, i, s]);
}
const cr = {
  name: "calendar",
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M8 1.6a.9.9 0 0 1 .9.9V7a.9.9 0 0 1-1.8 0V5.9H4a.1.1 0 0 0-.1.1v3.105A.91.91 0 0 1 4 9.1h16.1V6a.1.1 0 0 0-.1-.1h-3.1V7a.9.9 0 1 1-1.8 0V5.9h-3.6a.9.9 0 1 1 0-1.8h3.6V2.5a.9.9 0 1 1 1.8 0v1.6H20c1.05 0 1.9.85 1.9 1.9v14a1.9 1.9 0 0 1-1.9 1.9H4A1.9 1.9 0 0 1 2.1 20V6c0-1.05.85-1.9 1.9-1.9h3.1V2.5a.9.9 0 0 1 .9-.9Zm12.1 9.3H4a.917.917 0 0 1-.1-.005V20a.1.1 0 0 0 .1.1h16a.1.1 0 0 0 .1-.1v-9.1ZM5.6 13.5a.9.9 0 0 1 .9-.9h1a.9.9 0 1 1 0 1.8h-1a.9.9 0 0 1-.9-.9Zm5 0a.9.9 0 0 1 .9-.9h1a.9.9 0 1 1 0 1.8h-1a.9.9 0 0 1-.9-.9Zm5 0a.9.9 0 0 1 .9-.9h1a.9.9 0 1 1 0 1.8h-1a.9.9 0 0 1-.9-.9Zm-10 4a.9.9 0 0 1 .9-.9h1a.9.9 0 1 1 0 1.8h-1a.9.9 0 0 1-.9-.9Zm5 0a.9.9 0 0 1 .9-.9h1a.9.9 0 1 1 0 1.8h-1a.9.9 0 0 1-.9-.9Zm5 0a.9.9 0 0 1 .9-.9h1a.9.9 0 1 1 0 1.8h-1a.9.9 0 0 1-.9-.9Z" clip-rule="evenodd"/></svg>',
  keywords: ["calendar"],
  category: "other"
}, Ge = (e) => /* @__PURE__ */ N(tn, { ...e, svg: cr });
Ge.displayName = "IconCalendar";
const lr = {
  "date-picker-calendar-container": "_date-picker-calendar-container_17f84_1"
}, fr = nn.bind(lr), dr = Wt(
  ({
    calendarProps: e,
    drawerContentProps: t,
    value: n,
    onChange: r,
    overlayZIndex: o,
    ...i
  }, s) => {
    const [u, d] = Se(!1), [a, v] = Se(!1), [E, I] = Se(!1), f = Ht(null), { context: h, refs: l, floatingStyles: w } = ar({
      open: u,
      onOpenChange: (T) => {
        i.readOnly || d(T);
      },
      placement: "bottom-start",
      middleware: [
        Jt({
          mainAxis: 10,
          crossAxis: -32
          // left padding + small icon
        }),
        Qt()
      ],
      whileElementsMounted: Xt
    }), x = nr(h), g = ir(h), { getFloatingProps: p, getReferenceProps: L } = ur([x, g]), [K, W] = Se(n);
    Ut(() => {
      W(n);
    }, [n]);
    const O = (T) => {
      T ? (W(T), r?.(T), (u || a) && (d(!1), v(!1))) : (W(void 0), r?.(void 0));
    }, B = qt();
    return wt(() => {
      const T = () => {
        I(window.innerWidth < 600);
      };
      return T(), window.addEventListener("resize", T), () => {
        window.removeEventListener("resize", T);
      };
    }, []), E ? /* @__PURE__ */ Ce(_e, { open: a, onOpenChange: v, children: [
      /* @__PURE__ */ N(_e.Trigger, { children: /* @__PURE__ */ N(
        Qe,
        {
          ...i,
          startAdornment: /* @__PURE__ */ N(Ge, { size: "sm" }),
          id: B,
          value: K,
          onChange: (T) => O(T),
          "data-testid": i["data-testid"]
        }
      ) }),
      /* @__PURE__ */ N(
        _e.Content,
        {
          "data-testid": i["data-testid"] && `${i["data-testid"]}-calendar`,
          fitToContent: !0,
          ...t,
          zIndex: o,
          children: /* @__PURE__ */ N(
            Je,
            {
              showOutsideDays: !0,
              ...e,
              mode: "single",
              selected: K,
              onSelect: (T) => O(T)
            }
          )
        }
      )
    ] }) : /* @__PURE__ */ Ce("div", { ref: s, children: [
      /* @__PURE__ */ N(
        Qe,
        {
          ...L(i),
          ref: l.setReference,
          startAdornment: /* @__PURE__ */ N(Ge, { size: "sm" }),
          id: B,
          value: K,
          onChange: (T) => O(T),
          "data-testid": i["data-testid"]
        }
      ),
      u && !i.readOnly && /* @__PURE__ */ N(zn, { children: /* @__PURE__ */ N(er, { context: h, initialFocus: f, children: /* @__PURE__ */ N(
        "div",
        {
          "data-testid": i["data-testid"] && `${i["data-testid"]}-calendar`,
          className: fr("date-picker-calendar-container"),
          ref: l.setFloating,
          style: { ...w, zIndex: o },
          ...p(),
          children: /* @__PURE__ */ N(
            Je,
            {
              showOutsideDays: !0,
              ...e,
              mode: "single",
              selected: K,
              onSelect: (T) => O(T),
              firstElementRef: f
            }
          )
        }
      ) }) })
    ] });
  }
);
dr.displayName = "DatePicker";
export {
  dr as D
};
//# sourceMappingURL=date-picker-BRnwwZv1.mjs.map
