@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
1,506 lines • 55.8 kB
JavaScript
"use client";
import { jsxs as Et, jsx as J, Fragment as Gt } from "react/jsx-runtime";
import { d as Oe } from "./index.CgTHIF3K.js";
import * as l from "react";
import { useLayoutEffect as yt, isValidElement as xt, useState as Yt, createContext as Xt, forwardRef as wt, cloneElement as zt, useContext as Zt } from "react";
import { i as Jt, b as se, f as Qt, c as en, o as tn, s as nn, d as z, g as St, e as Fe, h as rn, j as on, k as Le, l as sn, a as an } from "./floating-ui.dom.C9TD1WpB.js";
import * as Ct from "react-dom";
import { c as un } from "./index.CEyLAtio.js";
import { g as Ce, c as Je } from "./helpers.BbWkXTr3.js";
import '../assets/Popover.BDTDsPAt.css';const ln = "ds-popover_popover_zyqhl_5", cn = {
popover: ln
};
/*!
* tabbable 6.2.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var fn = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], Te = /* @__PURE__ */ fn.join(","), Tt = typeof Element > "u", ve = Tt ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, Ie = !Tt && Element.prototype.getRootNode ? function(t) {
var e;
return t == null || (e = t.getRootNode) === null || e === void 0 ? void 0 : e.call(t);
} : function(t) {
return t == null ? void 0 : t.ownerDocument;
}, Pe = function t(e, n) {
var r;
n === void 0 && (n = !0);
var o = e == null || (r = e.getAttribute) === null || r === void 0 ? void 0 : r.call(e, "inert"), s = o === "" || o === "true", i = s || n && e && t(e.parentNode);
return i;
}, dn = function(e) {
var n, r = e == null || (n = e.getAttribute) === null || n === void 0 ? void 0 : n.call(e, "contenteditable");
return r === "" || r === "true";
}, It = function(e, n, r) {
if (Pe(e))
return [];
var o = Array.prototype.slice.apply(e.querySelectorAll(Te));
return n && ve.call(e, Te) && o.unshift(e), o = o.filter(r), o;
}, Pt = function t(e, n, r) {
for (var o = [], s = Array.from(e); s.length; ) {
var i = s.shift();
if (!Pe(i, !1))
if (i.tagName === "SLOT") {
var a = i.assignedElements(), u = a.length ? a : i.children, c = t(u, !0, r);
r.flatten ? o.push.apply(o, c) : o.push({
scopeParent: i,
candidates: c
});
} else {
var p = ve.call(i, Te);
p && r.filter(i) && (n || !e.includes(i)) && o.push(i);
var g = i.shadowRoot || // check for an undisclosed shadow
typeof r.getShadowRoot == "function" && r.getShadowRoot(i), h = !Pe(g, !1) && (!r.shadowRootFilter || r.shadowRootFilter(i));
if (g && h) {
var d = t(g === !0 ? i.children : g.children, !0, r);
r.flatten ? o.push.apply(o, d) : o.push({
scopeParent: i,
candidates: d
});
} else
s.unshift.apply(s, i.children);
}
}
return o;
}, At = function(e) {
return !isNaN(parseInt(e.getAttribute("tabindex"), 10));
}, Dt = function(e) {
if (!e)
throw new Error("No node provided");
return e.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName) || dn(e)) && !At(e) ? 0 : e.tabIndex;
}, pn = function(e, n) {
var r = Dt(e);
return r < 0 && n && !At(e) ? 0 : r;
}, vn = function(e, n) {
return e.tabIndex === n.tabIndex ? e.documentOrder - n.documentOrder : e.tabIndex - n.tabIndex;
}, Ot = function(e) {
return e.tagName === "INPUT";
}, mn = function(e) {
return Ot(e) && e.type === "hidden";
}, gn = function(e) {
var n = e.tagName === "DETAILS" && Array.prototype.slice.apply(e.children).some(function(r) {
return r.tagName === "SUMMARY";
});
return n;
}, bn = function(e, n) {
for (var r = 0; r < e.length; r++)
if (e[r].checked && e[r].form === n)
return e[r];
}, hn = function(e) {
if (!e.name)
return !0;
var n = e.form || Ie(e), r = function(a) {
return n.querySelectorAll('input[type="radio"][name="' + a + '"]');
}, o;
if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
o = r(window.CSS.escape(e.name));
else
try {
o = r(e.name);
} catch (i) {
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", i.message), !1;
}
var s = bn(o, e.form);
return !s || s === e;
}, Rn = function(e) {
return Ot(e) && e.type === "radio";
}, En = function(e) {
return Rn(e) && !hn(e);
}, yn = function(e) {
var n, r = e && Ie(e), o = (n = r) === null || n === void 0 ? void 0 : n.host, s = !1;
if (r && r !== e) {
var i, a, u;
for (s = !!((i = o) !== null && i !== void 0 && (a = i.ownerDocument) !== null && a !== void 0 && a.contains(o) || e != null && (u = e.ownerDocument) !== null && u !== void 0 && u.contains(e)); !s && o; ) {
var c, p, g;
r = Ie(o), o = (c = r) === null || c === void 0 ? void 0 : c.host, s = !!((p = o) !== null && p !== void 0 && (g = p.ownerDocument) !== null && g !== void 0 && g.contains(o));
}
}
return s;
}, Qe = function(e) {
var n = e.getBoundingClientRect(), r = n.width, o = n.height;
return r === 0 && o === 0;
}, xn = function(e, n) {
var r = n.displayCheck, o = n.getShadowRoot;
if (getComputedStyle(e).visibility === "hidden")
return !0;
var s = ve.call(e, "details>summary:first-of-type"), i = s ? e.parentElement : e;
if (ve.call(i, "details:not([open]) *"))
return !0;
if (!r || r === "full" || r === "legacy-full") {
if (typeof o == "function") {
for (var a = e; e; ) {
var u = e.parentElement, c = Ie(e);
if (u && !u.shadowRoot && o(u) === !0)
return Qe(e);
e.assignedSlot ? e = e.assignedSlot : !u && c !== e.ownerDocument ? e = c.host : e = u;
}
e = a;
}
if (yn(e))
return !e.getClientRects().length;
if (r !== "legacy-full")
return !0;
} else if (r === "non-zero-area")
return Qe(e);
return !1;
}, wn = function(e) {
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))
for (var n = e.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 ve.call(n, "fieldset[disabled] *") ? !0 : !o.contains(e);
}
return !0;
}
n = n.parentElement;
}
return !1;
}, qe = function(e, n) {
return !(n.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
// because we're limited in the type of selectors we can use in JSDom (see related
// note related to `candidateSelectors`)
Pe(n) || mn(n) || xn(n, e) || // For a details element with a summary, the summary element gets the focus
gn(n) || wn(n));
}, Ue = function(e, n) {
return !(En(n) || Dt(n) < 0 || !qe(e, n));
}, Sn = function(e) {
var n = parseInt(e.getAttribute("tabindex"), 10);
return !!(isNaN(n) || n >= 0);
}, Cn = function t(e) {
var n = [], r = [];
return e.forEach(function(o, s) {
var i = !!o.scopeParent, a = i ? o.scopeParent : o, u = pn(a, i), c = i ? t(o.candidates) : a;
u === 0 ? i ? n.push.apply(n, c) : n.push(a) : r.push({
documentOrder: s,
tabIndex: u,
item: o,
isScope: i,
content: c
});
}), r.sort(vn).reduce(function(o, s) {
return s.isScope ? o.push.apply(o, s.content) : o.push(s.content), o;
}, []).concat(n);
}, ke = function(e, n) {
n = n || {};
var r;
return n.getShadowRoot ? r = Pt([e], n.includeContainer, {
filter: Ue.bind(null, n),
flatten: !1,
getShadowRoot: n.getShadowRoot,
shadowRootFilter: Sn
}) : r = It(e, n.includeContainer, Ue.bind(null, n)), Cn(r);
}, Tn = function(e, n) {
n = n || {};
var r;
return n.getShadowRoot ? r = Pt([e], n.includeContainer, {
filter: qe.bind(null, n),
flatten: !0,
getShadowRoot: n.getShadowRoot
}) : r = It(e, n.includeContainer, qe.bind(null, n)), r;
}, kt = function(e, n) {
if (n = n || {}, !e)
throw new Error("No node provided");
return ve.call(e, Te) === !1 ? !1 : Ue(n, e);
};
function In() {
const t = navigator.userAgentData;
return t != null && t.platform ? t.platform : navigator.platform;
}
function Mt() {
const t = navigator.userAgentData;
return t && Array.isArray(t.brands) ? t.brands.map((e) => {
let {
brand: n,
version: r
} = e;
return n + "/" + r;
}).join(" ") : navigator.userAgent;
}
function Pn() {
return /apple/i.test(navigator.vendor);
}
function je() {
const t = /android/i;
return t.test(In()) || t.test(Mt());
}
function An() {
return Mt().includes("jsdom/");
}
const et = "data-floating-ui-focusable", Dn = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
function de(t) {
let e = t.activeElement;
for (; ((n = e) == null || (n = n.shadowRoot) == null ? void 0 : n.activeElement) != null; ) {
var n;
e = e.shadowRoot.activeElement;
}
return e;
}
function Y(t, e) {
if (!t || !e)
return !1;
const n = e.getRootNode == null ? void 0 : e.getRootNode();
if (t.contains(e))
return !0;
if (n && Jt(n)) {
let r = e;
for (; r; ) {
if (t === r)
return !0;
r = r.parentNode || r.host;
}
}
return !1;
}
function ue(t) {
return "composedPath" in t ? t.composedPath()[0] : t.target;
}
function _e(t, e) {
if (e == null)
return !1;
if ("composedPath" in t)
return t.composedPath().includes(e);
const n = t;
return n.target != null && e.contains(n.target);
}
function On(t) {
return t.matches("html,body");
}
function ee(t) {
return (t == null ? void 0 : t.ownerDocument) || document;
}
function Nt(t) {
return se(t) && t.matches(Dn);
}
function tt(t) {
return t ? t.getAttribute("role") === "combobox" && Nt(t) : !1;
}
function He(t) {
return t ? t.hasAttribute(et) ? t : t.querySelector("[" + et + "]") || t : null;
}
function ge(t, e) {
let n = t.filter((o) => {
var s;
return o.parentId === e && ((s = o.context) == null ? void 0 : s.open);
}), r = n;
for (; r.length; )
r = t.filter((o) => {
var s;
return (s = r) == null ? void 0 : s.some((i) => {
var a;
return o.parentId === i.id && ((a = o.context) == null ? void 0 : a.open);
});
}), n = n.concat(r);
return n;
}
function nt(t, e) {
var n;
let r = [], o = (n = t.find((s) => s.id === e)) == null ? void 0 : n.parentId;
for (; o; ) {
const s = t.find((i) => i.id === o);
o = s == null ? void 0 : s.parentId, s && (r = r.concat(s));
}
return r;
}
function $e(t) {
t.preventDefault(), t.stopPropagation();
}
function kn(t) {
return "nativeEvent" in t;
}
function Mn(t) {
return t.mozInputSource === 0 && t.isTrusted ? !0 : je() && t.pointerType ? t.type === "click" && t.buttons === 1 : t.detail === 0 && !t.pointerType;
}
function Nn(t) {
return An() ? !1 : !je() && t.width === 0 && t.height === 0 || je() && t.width === 1 && t.height === 1 && t.pressure === 0 && t.detail === 0 && t.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
t.width < 1 && t.height < 1 && t.pressure === 0 && t.detail === 0 && t.pointerType === "touch";
}
function rt(t, e) {
return ["mouse", "pen"].includes(t);
}
var Fn = typeof document < "u", Ln = function() {
}, Z = Fn ? yt : Ln;
const _n = {
...l
};
function Be(t) {
const e = l.useRef(t);
return Z(() => {
e.current = t;
}), e;
}
const $n = _n.useInsertionEffect, Bn = $n || ((t) => t());
function re(t) {
const e = l.useRef(() => {
if (process.env.NODE_ENV !== "production")
throw new Error("Cannot call an event handler while rendering.");
});
return Bn(() => {
e.current = t;
}), l.useCallback(function() {
for (var n = arguments.length, r = new Array(n), o = 0; o < n; o++)
r[o] = arguments[o];
return e.current == null ? void 0 : e.current(...r);
}, []);
}
const Re = () => ({
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(t, e) {
const n = ke(t, Re()), r = n.length;
if (r === 0) return;
const o = de(ee(t)), s = n.indexOf(o), i = s === -1 ? e === 1 ? 0 : r - 1 : s + e;
return n[i];
}
function Lt(t) {
return Ft(ee(t).body, 1) || t;
}
function _t(t) {
return Ft(ee(t).body, -1) || t;
}
function be(t, e) {
const n = e || t.currentTarget, r = t.relatedTarget;
return !r || !Y(n, r);
}
function Vn(t) {
ke(t, Re()).forEach((n) => {
n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
});
}
function ot(t) {
t.querySelectorAll("[data-tabindex]").forEach((n) => {
const r = n.dataset.tabindex;
delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
});
}
var Kn = typeof document < "u", Wn = function() {
}, Se = Kn ? yt : Wn;
function Ae(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, r, o;
if (t && e && typeof t == "object") {
if (Array.isArray(t)) {
if (n = t.length, n !== e.length) return !1;
for (r = n; r-- !== 0; )
if (!Ae(t[r], e[r]))
return !1;
return !0;
}
if (o = Object.keys(t), n = o.length, n !== Object.keys(e).length)
return !1;
for (r = n; r-- !== 0; )
if (!{}.hasOwnProperty.call(e, o[r]))
return !1;
for (r = n; r-- !== 0; ) {
const s = o[r];
if (!(s === "_owner" && t.$$typeof) && !Ae(t[s], e[s]))
return !1;
}
return !0;
}
return t !== t && e !== e;
}
function $t(t) {
return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function st(t, e) {
const n = $t(t);
return Math.round(e * n) / n;
}
function Ve(t) {
const e = l.useRef(t);
return Se(() => {
e.current = t;
}), e;
}
function qn(t) {
t === void 0 && (t = {});
const {
placement: e = "bottom",
strategy: n = "absolute",
middleware: r = [],
platform: o,
elements: {
reference: s,
floating: i
} = {},
transform: a = !0,
whileElementsMounted: u,
open: c
} = t, [p, g] = l.useState({
x: 0,
y: 0,
strategy: n,
placement: e,
middlewareData: {},
isPositioned: !1
}), [h, d] = l.useState(r);
Ae(h, r) || d(r);
const [b, f] = l.useState(null), [E, y] = l.useState(null), m = l.useCallback((x) => {
x !== L.current && (L.current = x, f(x));
}, []), R = l.useCallback((x) => {
x !== O.current && (O.current = x, y(x));
}, []), P = s || b, M = i || E, L = l.useRef(null), O = l.useRef(null), G = l.useRef(p), B = u != null, j = Ve(u), N = Ve(o), X = Ve(c), V = l.useCallback(() => {
if (!L.current || !O.current)
return;
const x = {
placement: e,
strategy: n,
middleware: h
};
N.current && (x.platform = N.current), en(L.current, O.current, x).then((w) => {
const k = {
...w,
// 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: X.current !== !1
};
$.current && !Ae(G.current, k) && (G.current = k, Ct.flushSync(() => {
g(k);
}));
});
}, [h, e, n, N, X]);
Se(() => {
c === !1 && G.current.isPositioned && (G.current.isPositioned = !1, g((x) => ({
...x,
isPositioned: !1
})));
}, [c]);
const $ = l.useRef(!1);
Se(() => ($.current = !0, () => {
$.current = !1;
}), []), Se(() => {
if (P && (L.current = P), M && (O.current = M), P && M) {
if (j.current)
return j.current(P, M, V);
V();
}
}, [P, M, V, j, B]);
const v = l.useMemo(() => ({
reference: L,
floating: O,
setReference: m,
setFloating: R
}), [m, R]), D = l.useMemo(() => ({
reference: P,
floating: M
}), [P, M]), K = l.useMemo(() => {
const x = {
position: n,
left: 0,
top: 0
};
if (!D.floating)
return x;
const w = st(D.floating, p.x), k = st(D.floating, p.y);
return a ? {
...x,
transform: "translate(" + w + "px, " + k + "px)",
...$t(D.floating) >= 1.5 && {
willChange: "transform"
}
} : {
position: n,
left: w,
top: k
};
}, [n, a, D.floating, p.x, p.y]);
return l.useMemo(() => ({
...p,
update: V,
refs: v,
elements: D,
floatingStyles: K
}), [p, V, v, D, K]);
}
const Un = (t, e) => ({
...tn(t),
options: [t, e]
}), jn = (t, e) => ({
...nn(t),
options: [t, e]
}), Hn = (t, e) => ({
...Qt(t),
options: [t, e]
});
function Bt(t) {
const e = l.useRef(void 0), n = l.useCallback((r) => {
const o = t.map((s) => {
if (s != null) {
if (typeof s == "function") {
const i = s, a = i(r);
return typeof a == "function" ? a : () => {
i(null);
};
}
return s.current = r, () => {
s.current = null;
};
}
});
return () => {
o.forEach((s) => s == null ? void 0 : s());
};
}, t);
return l.useMemo(() => t.every((r) => r == null) ? null : (r) => {
e.current && (e.current(), e.current = void 0), r != null && (e.current = n(r));
}, t);
}
const Gn = "data-floating-ui-focusable", it = "active", at = "selected", Yn = {
...l
};
let ut = !1, Xn = 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) + Xn++
);
function zn() {
const [t, e] = l.useState(() => ut ? lt() : void 0);
return Z(() => {
t == null && e(lt());
}, []), l.useEffect(() => {
ut = !0;
}, []), t;
}
const Zn = Yn.useId, Ye = Zn || zn;
let Ge;
process.env.NODE_ENV !== "production" && (Ge = /* @__PURE__ */ new Set());
function Jn() {
for (var t, e = arguments.length, n = new Array(e), r = 0; r < e; r++)
n[r] = arguments[r];
const o = "Floating UI: " + n.join(" ");
if (!((t = Ge) != null && t.has(o))) {
var s;
(s = Ge) == null || s.add(o), console.error(o);
}
}
function Qn() {
const t = /* @__PURE__ */ new Map();
return {
emit(e, n) {
var r;
(r = t.get(e)) == null || r.forEach((o) => o(n));
},
on(e, n) {
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(n);
},
off(e, n) {
var r;
(r = t.get(e)) == null || r.delete(n);
}
};
}
const er = /* @__PURE__ */ l.createContext(null), tr = /* @__PURE__ */ l.createContext(null), Vt = () => {
var t;
return ((t = l.useContext(er)) == null ? void 0 : t.id) || null;
}, Xe = () => l.useContext(tr);
function he(t) {
return "data-floating-ui-" + t;
}
function nr(t) {
t.current !== -1 && (clearTimeout(t.current), t.current = -1);
}
let ct = 0;
function fe(t, e) {
e === void 0 && (e = {});
const {
preventScroll: n = !1,
cancelPrevious: r = !0,
sync: o = !1
} = e;
r && cancelAnimationFrame(ct);
const s = () => t == null ? void 0 : t.focus({
preventScroll: n
});
o ? s() : ct = requestAnimationFrame(s);
}
function rr(t) {
return (t == null ? void 0 : t.ownerDocument) || document;
}
const pe = {
inert: /* @__PURE__ */ new WeakMap(),
"aria-hidden": /* @__PURE__ */ new WeakMap(),
none: /* @__PURE__ */ new WeakMap()
};
function ft(t) {
return t === "inert" ? pe.inert : t === "aria-hidden" ? pe["aria-hidden"] : pe.none;
}
let xe = /* @__PURE__ */ new WeakSet(), we = {}, Ke = 0;
const or = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype, Kt = (t) => t && (t.host || Kt(t.parentNode)), sr = (t, e) => e.map((n) => {
if (t.contains(n))
return n;
const r = Kt(n);
return t.contains(r) ? r : null;
}).filter((n) => n != null);
function ir(t, e, n, r) {
const o = "data-floating-ui-inert", s = r ? "inert" : n ? "aria-hidden" : null, i = sr(e, t), a = /* @__PURE__ */ new Set(), u = new Set(i), c = [];
we[o] || (we[o] = /* @__PURE__ */ new WeakMap());
const p = we[o];
i.forEach(g), h(e), a.clear();
function g(d) {
!d || a.has(d) || (a.add(d), d.parentNode && g(d.parentNode));
}
function h(d) {
!d || u.has(d) || [].forEach.call(d.children, (b) => {
if (St(b) !== "script")
if (a.has(b))
h(b);
else {
const f = s ? b.getAttribute(s) : null, E = f !== null && f !== "false", y = ft(s), m = (y.get(b) || 0) + 1, R = (p.get(b) || 0) + 1;
y.set(b, m), p.set(b, R), c.push(b), m === 1 && E && xe.add(b), R === 1 && b.setAttribute(o, ""), !E && s && b.setAttribute(s, s === "inert" ? "" : "true");
}
});
}
return Ke++, () => {
c.forEach((d) => {
const b = ft(s), E = (b.get(d) || 0) - 1, y = (p.get(d) || 0) - 1;
b.set(d, E), p.set(d, y), E || (!xe.has(d) && s && d.removeAttribute(s), xe.delete(d)), y || d.removeAttribute(o);
}), Ke--, Ke || (pe.inert = /* @__PURE__ */ new WeakMap(), pe["aria-hidden"] = /* @__PURE__ */ new WeakMap(), pe.none = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakSet(), we = {});
};
}
function dt(t, e, n) {
e === void 0 && (e = !1), n === void 0 && (n = !1);
const r = rr(t[0]).body;
return ir(t.concat(Array.from(r.querySelectorAll("[aria-live]"))), r, e, n);
}
const Me = {
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
}, De = /* @__PURE__ */ l.forwardRef(function(e, n) {
const [r, o] = l.useState();
Z(() => {
Pn() && o("button");
}, []);
const s = {
ref: n,
tabIndex: 0,
// Role is only for VoiceOver
role: r,
"aria-hidden": r ? void 0 : !0,
[he("focus-guard")]: "",
style: Me
};
return /* @__PURE__ */ J("span", {
...e,
...s
});
}), Wt = /* @__PURE__ */ l.createContext(null), pt = /* @__PURE__ */ he("portal");
function ar(t) {
t === void 0 && (t = {});
const {
id: e,
root: n
} = t, r = Ye(), o = qt(), [s, i] = l.useState(null), a = l.useRef(null);
return Z(() => () => {
s == null || s.remove(), queueMicrotask(() => {
a.current = null;
});
}, [s]), Z(() => {
if (!r || a.current) return;
const u = e ? document.getElementById(e) : null;
if (!u) return;
const c = document.createElement("div");
c.id = r, c.setAttribute(pt, ""), u.appendChild(c), a.current = c, i(c);
}, [e, r]), Z(() => {
if (n === null || !r || a.current) return;
let u = n || (o == null ? void 0 : o.portalNode);
u && !z(u) && (u = u.current), u = u || document.body;
let c = null;
e && (c = document.createElement("div"), c.id = e, u.appendChild(c));
const p = document.createElement("div");
p.id = r, p.setAttribute(pt, ""), u = c || u, u.appendChild(p), a.current = p, i(p);
}, [e, n, r, o]), s;
}
function ur(t) {
const {
children: e,
id: n,
root: r,
preserveTabOrder: o = !0
} = t, s = ar({
id: n,
root: r
}), [i, a] = l.useState(null), u = l.useRef(null), c = l.useRef(null), p = l.useRef(null), g = l.useRef(null), h = i == null ? void 0 : i.modal, d = i == null ? void 0 : i.open, b = (
// The FocusManager and therefore floating element are currently open/
// rendered.
!!i && // Guards are only for non-modal focus management.
!i.modal && // Don't render if unmount is transitioning.
i.open && o && !!(r || s)
);
return l.useEffect(() => {
if (!s || !o || h)
return;
function f(E) {
s && be(E) && (E.type === "focusin" ? ot : Vn)(s);
}
return s.addEventListener("focusin", f, !0), s.addEventListener("focusout", f, !0), () => {
s.removeEventListener("focusin", f, !0), s.removeEventListener("focusout", f, !0);
};
}, [s, o, h]), l.useEffect(() => {
s && (d || ot(s));
}, [d, s]), /* @__PURE__ */ Et(Wt.Provider, {
value: l.useMemo(() => ({
preserveTabOrder: o,
beforeOutsideRef: u,
afterOutsideRef: c,
beforeInsideRef: p,
afterInsideRef: g,
portalNode: s,
setFocusManagerState: a
}), [o, s]),
children: [b && s && /* @__PURE__ */ J(De, {
"data-type": "outside",
ref: u,
onFocus: (f) => {
if (be(f, s)) {
var E;
(E = p.current) == null || E.focus();
} else {
const y = i ? i.domReference : null, m = _t(y);
m == null || m.focus();
}
}
}), b && s && /* @__PURE__ */ J("span", {
"aria-owns": s.id,
style: Me
}), s && /* @__PURE__ */ Ct.createPortal(e, s), b && s && /* @__PURE__ */ J(De, {
"data-type": "outside",
ref: c,
onFocus: (f) => {
if (be(f, s)) {
var E;
(E = g.current) == null || E.focus();
} else {
const y = i ? i.domReference : null, m = Lt(y);
m == null || m.focus(), i != null && i.closeOnFocusOut && (i == null || i.onOpenChange(!1, f.nativeEvent, "focus-out"));
}
}
})]
});
}
const qt = () => l.useContext(Wt);
function vt(t) {
return l.useMemo(() => (e) => {
t.forEach((n) => {
n && (n.current = e);
});
}, t);
}
const lr = 20;
let ce = [];
function cr(t) {
ce = ce.filter((e) => e.isConnected), t && St(t) !== "body" && (ce.push(t), ce.length > lr && (ce = ce.slice(-20)));
}
function mt() {
return ce.slice().reverse().find((t) => t.isConnected);
}
function fr(t) {
const e = Re();
return kt(t, e) ? t : ke(t, e)[0] || t;
}
function gt(t, e) {
var n;
if (!e.current.includes("floating") && !((n = t.getAttribute("role")) != null && n.includes("dialog")))
return;
const r = Re(), s = Tn(t, r).filter((a) => {
const u = a.getAttribute("data-tabindex") || "";
return kt(a, r) || a.hasAttribute("data-tabindex") && !u.startsWith("-");
}), i = t.getAttribute("tabindex");
e.current.includes("floating") || s.length === 0 ? i !== "0" && t.setAttribute("tabindex", "0") : (i !== "-1" || t.hasAttribute("data-tabindex") && t.getAttribute("data-tabindex") !== "-1") && (t.setAttribute("tabindex", "-1"), t.setAttribute("data-tabindex", "-1"));
}
const dr = /* @__PURE__ */ l.forwardRef(function(e, n) {
return /* @__PURE__ */ J("button", {
...e,
type: "button",
ref: n,
tabIndex: -1,
style: Me
});
});
function pr(t) {
const {
context: e,
children: n,
disabled: r = !1,
order: o = ["content"],
guards: s = !0,
initialFocus: i = 0,
returnFocus: a = !0,
restoreFocus: u = !1,
modal: c = !0,
visuallyHiddenDismiss: p = !1,
closeOnFocusOut: g = !0,
outsideElementsInert: h = !1,
getInsideElements: d = () => []
} = t, {
open: b,
onOpenChange: f,
events: E,
dataRef: y,
elements: {
domReference: m,
floating: R
}
} = e, P = re(() => {
var C;
return (C = y.current.floatingContext) == null ? void 0 : C.nodeId;
}), M = re(d), L = typeof i == "number" && i < 0, O = tt(m) && L, G = or(), B = G ? s : !0, j = !B || G && h, N = Be(o), X = Be(i), V = Be(a), $ = Xe(), v = qt(), D = l.useRef(null), K = l.useRef(null), x = l.useRef(!1), w = l.useRef(!1), k = l.useRef(-1), W = v != null, S = He(R), te = re(function(C) {
return C === void 0 && (C = S), C ? ke(C, Re()) : [];
}), ie = re((C) => {
const A = te(C);
return N.current.map((T) => m && T === "reference" ? m : S && T === "floating" ? S : A).filter(Boolean).flat();
});
l.useEffect(() => {
if (r || !c) return;
function C(T) {
if (T.key === "Tab") {
Y(S, de(ee(S))) && te().length === 0 && !O && $e(T);
const I = ie(), q = ue(T);
N.current[0] === "reference" && q === m && ($e(T), T.shiftKey ? fe(I[I.length - 1]) : fe(I[1])), N.current[1] === "floating" && q === S && T.shiftKey && ($e(T), fe(I[0]));
}
}
const A = ee(S);
return A.addEventListener("keydown", C), () => {
A.removeEventListener("keydown", C);
};
}, [r, m, S, c, N, O, te, ie]), l.useEffect(() => {
if (r || !R) return;
function C(A) {
const T = ue(A), q = te().indexOf(T);
q !== -1 && (k.current = q);
}
return R.addEventListener("focusin", C), () => {
R.removeEventListener("focusin", C);
};
}, [r, R, te]), l.useEffect(() => {
if (r || !g) return;
function C() {
w.current = !0, setTimeout(() => {
w.current = !1;
});
}
function A(T) {
const I = T.relatedTarget, q = T.currentTarget, U = ue(T);
queueMicrotask(() => {
const ne = P(), oe = !(Y(m, I) || Y(R, I) || Y(I, R) || Y(v == null ? void 0 : v.portalNode, I) || I != null && I.hasAttribute(he("focus-guard")) || $ && (ge($.nodesRef.current, ne).find((F) => {
var _, ae;
return Y((_ = F.context) == null ? void 0 : _.elements.floating, I) || Y((ae = F.context) == null ? void 0 : ae.elements.domReference, I);
}) || nt($.nodesRef.current, ne).find((F) => {
var _, ae, Ze;
return [(_ = F.context) == null ? void 0 : _.elements.floating, He((ae = F.context) == null ? void 0 : ae.elements.floating)].includes(I) || ((Ze = F.context) == null ? void 0 : Ze.elements.domReference) === I;
})));
if (q === m && S && gt(S, N), u && q !== m && !(U != null && U.isConnected) && de(ee(S)) === ee(S).body) {
se(S) && S.focus();
const F = k.current, _ = te(), ae = _[F] || _[_.length - 1] || S;
se(ae) && ae.focus();
}
if (y.current.insideReactTree) {
y.current.insideReactTree = !1;
return;
}
(O || !c) && I && oe && !w.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
I !== mt() && (x.current = !0, f(!1, T, "focus-out"));
});
}
if (R && se(m))
return m.addEventListener("focusout", A), m.addEventListener("pointerdown", C), R.addEventListener("focusout", A), () => {
m.removeEventListener("focusout", A), m.removeEventListener("pointerdown", C), R.removeEventListener("focusout", A);
};
}, [r, m, R, S, c, $, v, f, g, u, te, O, P, N, y]);
const me = l.useRef(null), H = l.useRef(null), Q = vt([me, v == null ? void 0 : v.beforeInsideRef]), le = vt([H, v == null ? void 0 : v.afterInsideRef]);
l.useEffect(() => {
var C, A;
if (r || !R) return;
const T = Array.from((v == null || (C = v.portalNode) == null ? void 0 : C.querySelectorAll("[" + he("portal") + "]")) || []), I = $ ? nt($.nodesRef.current, P()) : [], q = $ && !c ? I.map((F) => {
var _;
return (_ = F.context) == null ? void 0 : _.elements.floating;
}) : [], U = (A = I.find((F) => {
var _;
return tt(((_ = F.context) == null ? void 0 : _.elements.domReference) || null);
})) == null || (A = A.context) == null ? void 0 : A.elements.domReference, ne = [R, U, ...T, ...q, ...M(), D.current, K.current, me.current, H.current, v == null ? void 0 : v.beforeOutsideRef.current, v == null ? void 0 : v.afterOutsideRef.current, N.current.includes("reference") || O ? m : null].filter((F) => F != null), oe = c || O ? dt(ne, !j, j) : dt(ne);
return () => {
oe();
};
}, [r, m, R, c, N, v, O, B, j, $, P, M]), Z(() => {
if (r || !se(S)) return;
const C = ee(S), A = de(C);
queueMicrotask(() => {
const T = ie(S), I = X.current, q = (typeof I == "number" ? T[I] : I.current) || S, U = Y(S, A);
!L && !U && b && fe(q, {
preventScroll: q === S
});
});
}, [r, b, S, L, ie, X]), Z(() => {
if (r || !S) return;
const C = ee(S), A = de(C);
cr(A);
function T(U) {
let {
reason: ne,
event: oe,
nested: F
} = U;
if (["hover", "safe-polygon"].includes(ne) && oe.type === "mouseleave" && (x.current = !0), ne === "outside-press")
if (F)
x.current = !1;
else if (Mn(oe) || Nn(oe))
x.current = !1;
else {
let _ = !1;
document.createElement("div").focus({
get preventScroll() {
return _ = !0, !1;
}
}), _ ? x.current = !1 : x.current = !0;
}
}
E.on("openchange", T);
const I = C.createElement("span");
I.setAttribute("tabindex", "-1"), I.setAttribute("aria-hidden", "true"), Object.assign(I.style, Me), W && m && m.insertAdjacentElement("afterend", I);
function q() {
if (typeof V.current == "boolean") {
const U = m || mt();
return U && U.isConnected ? U : I;
}
return V.current.current || I;
}
return () => {
E.off("openchange", T);
const U = de(C), ne = Y(R, U) || $ && ge($.nodesRef.current, P()).some((F) => {
var _;
return Y((_ = F.context) == null ? void 0 : _.elements.floating, U);
}), oe = q();
queueMicrotask(() => {
const F = fr(oe);
// eslint-disable-next-line react-hooks/exhaustive-deps
V.current && !x.current && se(F) && // 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
(!(F !== U && U !== C.body) || ne) && F.focus({
preventScroll: !0
}), I.remove();
});
};
}, [r, R, S, V, y, E, $, W, m, P]), l.useEffect(() => {
queueMicrotask(() => {
x.current = !1;
});
}, [r]), Z(() => {
if (!r && v)
return v.setFocusManagerState({
modal: c,
closeOnFocusOut: g,
open: b,
onOpenChange: f,
domReference: m
}), () => {
v.setFocusManagerState(null);
};
}, [r, v, c, b, f, g, m]), Z(() => {
r || S && gt(S, N);
}, [r, S, N]);
function Ee(C) {
return r || !p || !c ? null : /* @__PURE__ */ J(dr, {
ref: C === "start" ? D : K,
onClick: (A) => f(!1, A.nativeEvent),
children: typeof p == "string" ? p : "Dismiss"
});
}
const ye = !r && B && (c ? !O : !0) && (W || c);
return /* @__PURE__ */ Et(Gt, {
children: [ye && /* @__PURE__ */ J(De, {
"data-type": "inside",
ref: Q,
onFocus: (C) => {
if (c) {
const T = ie();
fe(o[0] === "reference" ? T[0] : T[T.length - 1]);
} else if (v != null && v.preserveTabOrder && v.portalNode)
if (x.current = !1, be(C, v.portalNode)) {
const T = Lt(m);
T == null || T.focus();
} else {
var A;
(A = v.beforeOutsideRef.current) == null || A.focus();
}
}
}), !O && Ee("start"), n, Ee("end"), ye && /* @__PURE__ */ J(De, {
"data-type": "inside",
ref: le,
onFocus: (C) => {
if (c)
fe(ie()[0]);
else if (v != null && v.preserveTabOrder && v.portalNode)
if (g && (x.current = !0), be(C, v.portalNode)) {
const T = _t(m);
T == null || T.focus();
} else {
var A;
(A = v.afterOutsideRef.current) == null || A.focus();
}
}
})]
});
}
function bt(t) {
return se(t.target) && t.target.tagName === "BUTTON";
}
function vr(t) {
return se(t.target) && t.target.tagName === "A";
}
function ht(t) {
return Nt(t);
}
function mr(t, e) {
e === void 0 && (e = {});
const {
open: n,
onOpenChange: r,
dataRef: o,
elements: {
domReference: s
}
} = t, {
enabled: i = !0,
event: a = "click",
toggle: u = !0,
ignoreMouse: c = !1,
keyboardHandlers: p = !0,
stickIfOpen: g = !0
} = e, h = l.useRef(), d = l.useRef(!1), b = l.useMemo(() => ({
onPointerDown(f) {
h.current = f.pointerType;
},
onMouseDown(f) {
const E = h.current;
f.button === 0 && a !== "click" && (rt(E) && c || (n && u && (!(o.current.openEvent && g) || o.current.openEvent.type === "mousedown") ? r(!1, f.nativeEvent, "click") : (f.preventDefault(), r(!0, f.nativeEvent, "click"))));
},
onClick(f) {
const E = h.current;
if (a === "mousedown" && h.current) {
h.current = void 0;
return;
}
rt(E) && c || (n && u && (!(o.current.openEvent && g) || o.current.openEvent.type === "click") ? r(!1, f.nativeEvent, "click") : r(!0, f.nativeEvent, "click"));
},
onKeyDown(f) {
h.current = void 0, !(f.defaultPrevented || !p || bt(f)) && (f.key === " " && !ht(s) && (f.preventDefault(), d.current = !0), !vr(f) && f.key === "Enter" && r(!(n && u), f.nativeEvent, "click"));
},
onKeyUp(f) {
f.defaultPrevented || !p || bt(f) || ht(s) || f.key === " " && d.current && (d.current = !1, r(!(n && u), f.nativeEvent, "click"));
}
}), [o, s, a, c, p, r, n, g, u]);
return l.useMemo(() => i ? {
reference: b
} : {}, [i, b]);
}
const gr = {
pointerdown: "onPointerDown",
mousedown: "onMouseDown",
click: "onClick"
}, br = {
pointerdown: "onPointerDownCapture",
mousedown: "onMouseDownCapture",
click: "onClickCapture"
}, Rt = (t) => {
var e, n;
return {
escapeKey: typeof t == "boolean" ? t : (e = t == null ? void 0 : t.escapeKey) != null ? e : !1,
outsidePress: typeof t == "boolean" ? t : (n = t == null ? void 0 : t.outsidePress) != null ? n : !0
};
};
function hr(t, e) {
e === void 0 && (e = {});
const {
open: n,
onOpenChange: r,
elements: o,
dataRef: s
} = t, {
enabled: i = !0,
escapeKey: a = !0,
outsidePress: u = !0,
outsidePressEvent: c = "pointerdown",
referencePress: p = !1,
referencePressEvent: g = "pointerdown",
ancestorScroll: h = !1,
bubbles: d,
capture: b
} = e, f = Xe(), E = re(typeof u == "function" ? u : () => !1), y = typeof u == "function" ? E : u, m = l.useRef(!1), {
escapeKey: R,
outsidePress: P
} = Rt(d), {
escapeKey: M,
outsidePress: L
} = Rt(b), O = l.useRef(!1), G = l.useRef(-1), B = re((v) => {
var D;
if (!n || !i || !a || v.key !== "Escape" || O.current)
return;
const K = (D = s.current.floatingContext) == null ? void 0 : D.nodeId, x = f ? ge(f.nodesRef.current, K) : [];
if (!R && (v.stopPropagation(), x.length > 0)) {
let w = !0;
if (x.forEach((k) => {
var W;
if ((W = k.context) != null && W.open && !k.context.dataRef.current.__escapeKeyBubbles) {
w = !1;
return;
}
}), !w)
return;
}
r(!1, kn(v) ? v.nativeEvent : v, "escape-key");
}), j = re((v) => {
var D;
const K = () => {
var x;
B(v), (x = ue(v)) == null || x.removeEventListener("keydown", K);
};
(D = ue(v)) == null || D.addEventListener("keydown", K);
}), N = re((v) => {
var D;
const K = s.current.insideReactTree;
s.current.insideReactTree = !1;
const x = m.current;
if (m.current = !1, c === "click" && x || K || typeof y == "function" && !y(v))
return;
const w = ue(v), k = "[" + he("inert") + "]", W = ee(o.floating).querySelectorAll(k);
let S = z(w) ? w : null;
for (; S && !Fe(S); ) {
const H = rn(S);
if (Fe(H) || !z(H))
break;
S = H;
}
if (W.length && z(w) && !On(w) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
!Y(w, o.floating) && // If the target root element contains none of the markers, then the
// element was injected after the floating element rendered.
Array.from(W).every((H) => !Y(S, H)))
return;
if (se(w) && $) {
const H = Fe(w), Q = on(w), le = /auto|scroll/, Ee = H || le.test(Q.overflowX), ye = H || le.test(Q.overflowY), C = Ee && w.clientWidth > 0 && w.scrollWidth > w.clientWidth, A = ye && w.clientHeight > 0 && w.scrollHeight > w.clientHeight, T = Q.direction === "rtl", I = A && (T ? v.offsetX <= w.offsetWidth - w.clientWidth : v.offsetX > w.clientWidth), q = C && v.offsetY > w.clientHeight;
if (I || q)
return;
}
const te = (D = s.current.floatingContext) == null ? void 0 : D.nodeId, ie = f && ge(f.nodesRef.current, te).some((H) => {
var Q;
return _e(v, (Q = H.context) == null ? void 0 : Q.elements.floating);
});
if (_e(v, o.floating) || _e(v, o.domReference) || ie)
return;
const me = f ? ge(f.nodesRef.current, te) : [];
if (me.length > 0) {
let H = !0;
if (me.forEach((Q) => {
var le;
if ((le = Q.context) != null && le.open && !Q.context.dataRef.current.__outsidePressBubbles) {
H = !1;
return;
}
}), !H)
return;
}
r(!1, v, "outside-press");
}), X = re((v) => {
var D;
const K = () => {
var x;
N(v), (x = ue(v)) == null || x.removeEventListener(c, K);
};
(D = ue(v)) == null || D.addEventListener(c, K);
});
l.useEffect(() => {
if (!n || !i)
return;
s.current.__escapeKeyBubbles = R, s.current.__outsidePressBubbles = P;
let v = -1;
function D(W) {
r(!1, W, "ancestor-scroll");
}
function K() {
window.clearTimeout(v), O.current = !0;
}
function x() {
v = 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.
sn() ? 5 : 0
);
}
const w = ee(o.floating);
a && (w.addEventListener("keydown", M ? j : B, M), w.addEventListener("compositionstart", K), w.addEventListener("compositionend", x)), y && w.addEventListener(c, L ? X : N, L);
let k = [];
return h && (z(o.domReference) && (k = Le(o.domReference)), z(o.floating) && (k = k.concat(Le(o.floating))), !z(o.reference) && o.reference && o.reference.contextElement && (k = k.concat(Le(o.reference.contextElement)))), k = k.filter((W) => {
var S;
return W !== ((S = w.defaultView) == null ? void 0 : S.visualViewport);
}), k.forEach((W) => {
W.addEventListener("scroll", D, {
passive: !0
});
}), () => {
a && (w.removeEventListener("keydown", M ? j : B, M), w.removeEventListener("compositionstart", K), w.removeEventListener("compositionend", x)), y && w.removeEventListener(c, L ? X : N, L), k.forEach((W) => {
W.removeEventListener("scroll", D);
}), window.clearTimeout(v);
};
}, [s, o, a, y, c, n, r, h, i, R, P, B, M, j, N, L, X]), l.useEffect(() => {
s.current.insideReactTree = !1;
}, [s, y, c]);
const V = l.useMemo(() => ({
onKeyDown: B,
...p && {
[gr[g]]: (v) => {
r(!1, v.nativeEvent, "reference-press");
},
...g !== "click" && {
onClick(v) {
r(!1, v.nativeEvent, "reference-press");
}
}
}
}), [B, r, p, g]), $ = l.useMemo(() => ({
onKeyDown: B,
onMouseDown() {
m.current = !0;
},
onMouseUp() {
m.current = !0;
},
[br[c]]: () => {
s.current.insideReactTree = !0;
},
onBlurCapture() {
f || (nr(G), s.current.insideReactTree = !0, G.current = window.setTimeout(() => {
s.current.insideReactTree = !1;
}));
}
}), [B, c, s, f]);
return l.useMemo(() => i ? {
reference: V,
floating: $
} : {}, [i, V, $]);
}
function Rr(t) {
const {
open: e = !1,
onOpenChange: n,
elements: r
} = t, o = Ye(), s = l.useRef({}), [i] = l.useState(() => Qn()), a = Vt() != null;
if (process.env.NODE_ENV !== "production") {
const d = r.reference;
d && !z(d) && Jn("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
}
const [u, c] = l.useState(r.reference), p = re((d, b, f) => {
s.current.openEvent = d ? b : void 0, i.emit("openchange", {
open: d,
event: b,
reason: f,
nested: a
}), n == null || n(d, b, f);
}), g = l.useMemo(() => ({
setPositionReference: c
}), []), h = l.useMemo(() => ({
reference: u || r.reference || null,
floating: r.floating || null,
domReference: r.reference
}), [u, r.reference, r.floating]);
return l.useMemo(() => ({
dataRef: s,
open: e,
onOpenChange: p,
elements: h,
events: i,
floatingId: o,
refs: g
}), [e, p, h, i, o, g]);
}
function Er(t) {
t === void 0 && (t = {});
const {
nodeId: e
} = t, n = Rr({
...t,
elements: {
reference: null,
floating: null,
...t.elements
}
}), r = t.rootContext || n, o = r.elements, [s, i] = l.useState(null), [a, u] = l.useState(null), p = (o == null ? void 0 : o.domReference) || s, g = l.useRef(null), h = Xe();
Z(() => {
p && (g.current = p);
}, [p]);
const d = qn({
...t,
elements: {
...o,
...a && {
reference: a
}
}
}), b = l.useCallback((R) => {
const P = z(R) ? {
getBoundingClientRect: () => R.getBoundingClientRect(),
getClientRects: () => R.getClientRects(),
contextElement: R
} : R;
u(P), d.refs.setReference(P);
}, [d.refs]), f = l.useCallback((R) => {
(z(R) || R === null) && (g.current = R, i(R)), (z(d.refs.reference.current) || d.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.
R !== null && !z(R)) && d.refs.setReference(R);
}, [d.refs]), E = l.useMemo(() => ({
...d.refs,
setReference: f,
setPositionReference: b,
domReference: g
}), [d.refs, f, b]), y = l.useMemo(() => ({
...d.elements,
domReference: p
}), [d.elements, p]), m = l.useMemo(() => ({
...d,
...r,
refs: E,
elements: y,
nodeId: e
}), [d, E, y, e, r]);
return Z(() => {
r.dataRef.current.floatingContext = m;
const R = h == null ? void 0 : h.nodesRef.current.find((P) => P.id === e);
R && (R.context = m);
}), l.useMemo(() => ({
...d,
context: m,
refs: E,
elements: y
}), [d, E, y, m]);
}
function We(t, e, n) {
const r = /* @__PURE__ */ new Map(), o = n === "item";
let s = t;
if (o && t) {
const {
[it]: i,
[at]: a,
...u
} = t;
s = u;
}
return {
...n === "floating" && {
tabIndex: -1,
[Gn]: ""
},
...s,
...e.map((i) => {
const a = i ? i[n] : null;
return typeof a == "function" ? t ? a(t) : null : a;
}).concat(t).reduce((i, a) => (a && Object.entries(a).forEach((u) => {
let [c, p] = u;
if (!(o && [it, at].includes(c)))
if (c.indexOf("on") === 0) {
if (r.has(c) || r.set(c, []), typeof p == "function") {
var g;
(g = r.get(c)) == null || g.push(p), i[c] = function() {
for (var h, d = arguments.length, b = new Array(d), f = 0; f < d; f++)
b[f] = arguments[f];
return (h = r.get(c)) == null ? void 0 : h.map((E) => E(...b)).find((E) => E !== void 0);
};
}
} else
i[c] = p;
}), i), {})
};
}
function yr(t) {
t === void 0 && (t = []);
const e = t.map((a) => a == null ? void 0 : a.reference), n = t.map((a) => a == null ? void 0 : a.floating), r = t.map((a) => a == null ? void 0 : a.item), o = l.useCallback(
(a) => We(a, t, "reference"),
// eslint-disable-next-line react-hooks/exhaustive-deps
e
), s = l.useCallback(
(a) => We(a, t, "floating"),
// eslint-disable-next-line react-hooks/exhaustive-deps
n
), i = l.useCallback(
(a) => We(a, t, "item"),
// eslint-disable-next-line react-hooks/exhaustive-deps
r
);
return l.useMemo(() => ({
getReferenceProps: o,
getFloatingProps: s,
getItemProps: i
}), [o, s, i]);
}
const xr = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
function wr(t, e) {
var n, r;
e === void 0 && (e = {});
const {
open: o,
elements: s,
floatingId: i
} = t, {
enabled: a = !0,
role: u = "dialog"
} = e, c = Ye(), p = ((n = s.domReference) == null ? void 0 : n.id) || c, g = l.useMemo(() => {
var m;
return ((m = He(s.floating)) == null ? void 0 : m.id) || i;
}, [s.floating, i]), h = (r = xr.get(u)) != null ? r : u, b = Vt() != null, f = l.useMemo(() => h === "tooltip" || u === "label" ? {
["aria-" + (u === "label" ? "labelledby" : "describedby")]: o ? g : void 0
} : {
"aria-expanded": o ? "true" : "false",
"aria-haspopup": h === "alertdialog" ? "dialog" : h,
"aria-controls": o ? g : void 0,
...h === "listbox" && {
role: "combobox"
},
...h === "menu" && {
id: p
},
...h === "menu" && b && {
role: "menuitem"
},
...u === "select" && {
"aria-autocomplete": "none"
},
...u === "combobox" && {
"aria-autocomplete": "list"
}
}, [h, g, b, o, p, u]), E = l.useMemo(() => {
const m = {
id: g,
...h && {
role: h
}
};
return h === "tooltip" || u === "label" ? m : {
...m,
...h === "menu" && {
"aria-labelledby": p
}
};
}, [h, g, p, u]), y = l.useCallback((m) => {