@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
1,515 lines • 64.5 kB
JavaScript
"use client";
import * as u from "react";
import { useLayoutEffect as Pt } from "react";
import { i as Gt, b as se, f as Zt, c as zt, o as Jt, s as Qt, d as st, e as J, g as en, h as We, j as tn, k as Be, l as nn, m as kt, n as At } from "./floating-ui.dom.VgHc0h4l.js";
import { jsxs as Qe, jsx as ne, Fragment as rn } from "react/jsx-runtime";
import * as et from "react-dom";
/*!
* tabbable 6.2.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var on = ["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])"], ke = /* @__PURE__ */ on.join(","), Ot = typeof Element > "u", he = Ot ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, Ae = !Ot && 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 == null ? void 0 : e.ownerDocument;
}, Oe = function e(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"), s = o === "" || o === "true", i = s || n && t && e(t.parentNode);
return i;
}, sn = function(t) {
var n, r = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
return r === "" || r === "true";
}, Ft = function(t, n, r) {
if (Oe(t))
return [];
var o = Array.prototype.slice.apply(t.querySelectorAll(ke));
return n && he.call(t, ke) && o.unshift(t), o = o.filter(r), o;
}, Lt = function e(t, n, r) {
for (var o = [], s = Array.from(t); s.length; ) {
var i = s.shift();
if (!Oe(i, !1))
if (i.tagName === "SLOT") {
var a = i.assignedElements(), c = a.length ? a : i.children, l = e(c, !0, r);
r.flatten ? o.push.apply(o, l) : o.push({
scopeParent: i,
candidates: l
});
} else {
var v = he.call(i, ke);
v && r.filter(i) && (n || !t.includes(i)) && o.push(i);
var y = i.shadowRoot || // check for an undisclosed shadow
typeof r.getShadowRoot == "function" && r.getShadowRoot(i), w = !Oe(y, !1) && (!r.shadowRootFilter || r.shadowRootFilter(i));
if (y && w) {
var f = e(y === !0 ? i.children : y.children, !0, r);
r.flatten ? o.push.apply(o, f) : o.push({
scopeParent: i,
candidates: f
});
} else
s.unshift.apply(s, i.children);
}
}
return o;
}, Dt = function(t) {
return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, Nt = function(t) {
if (!t)
throw new Error("No node provided");
return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || sn(t)) && !Dt(t) ? 0 : t.tabIndex;
}, un = function(t, n) {
var r = Nt(t);
return r < 0 && n && !Dt(t) ? 0 : r;
}, an = function(t, n) {
return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
}, $t = function(t) {
return t.tagName === "INPUT";
}, cn = function(t) {
return $t(t) && t.type === "hidden";
}, ln = function(t) {
var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
return r.tagName === "SUMMARY";
});
return n;
}, fn = function(t, n) {
for (var r = 0; r < t.length; r++)
if (t[r].checked && t[r].form === n)
return t[r];
}, dn = function(t) {
if (!t.name)
return !0;
var n = t.form || Ae(t), 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(t.name));
else
try {
o = r(t.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 = fn(o, t.form);
return !s || s === t;
}, mn = function(t) {
return $t(t) && t.type === "radio";
}, vn = function(t) {
return mn(t) && !dn(t);
}, pn = function(t) {
var n, r = t && Ae(t), o = (n = r) === null || n === void 0 ? void 0 : n.host, s = !1;
if (r && r !== t) {
var i, a, c;
for (s = !!((i = o) !== null && i !== void 0 && (a = i.ownerDocument) !== null && a !== void 0 && a.contains(o) || t != null && (c = t.ownerDocument) !== null && c !== void 0 && c.contains(t)); !s && o; ) {
var l, v, y;
r = Ae(o), o = (l = r) === null || l === void 0 ? void 0 : l.host, s = !!((v = o) !== null && v !== void 0 && (y = v.ownerDocument) !== null && y !== void 0 && y.contains(o));
}
}
return s;
}, it = function(t) {
var n = t.getBoundingClientRect(), r = n.width, o = n.height;
return r === 0 && o === 0;
}, gn = function(t, n) {
var r = n.displayCheck, o = n.getShadowRoot;
if (getComputedStyle(t).visibility === "hidden")
return !0;
var s = he.call(t, "details>summary:first-of-type"), i = s ? t.parentElement : t;
if (he.call(i, "details:not([open]) *"))
return !0;
if (!r || r === "full" || r === "legacy-full") {
if (typeof o == "function") {
for (var a = t; t; ) {
var c = t.parentElement, l = Ae(t);
if (c && !c.shadowRoot && o(c) === !0)
return it(t);
t.assignedSlot ? t = t.assignedSlot : !c && l !== t.ownerDocument ? t = l.host : t = c;
}
t = a;
}
if (pn(t))
return !t.getClientRects().length;
if (r !== "legacy-full")
return !0;
} else if (r === "non-zero-area")
return it(t);
return !1;
}, bn = 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 he.call(n, "fieldset[disabled] *") ? !0 : !o.contains(t);
}
return !0;
}
n = n.parentElement;
}
return !1;
}, Ge = function(t, 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`)
Oe(n) || cn(n) || gn(n, t) || // For a details element with a summary, the summary element gets the focus
ln(n) || bn(n));
}, Ze = function(t, n) {
return !(vn(n) || Nt(n) < 0 || !Ge(t, n));
}, hn = function(t) {
var n = parseInt(t.getAttribute("tabindex"), 10);
return !!(isNaN(n) || n >= 0);
}, Rn = function e(t) {
var n = [], r = [];
return t.forEach(function(o, s) {
var i = !!o.scopeParent, a = i ? o.scopeParent : o, c = un(a, i), l = i ? e(o.candidates) : a;
c === 0 ? i ? n.push.apply(n, l) : n.push(a) : r.push({
documentOrder: s,
tabIndex: c,
item: o,
isScope: i,
content: l
});
}), r.sort(an).reduce(function(o, s) {
return s.isScope ? o.push.apply(o, s.content) : o.push(s.content), o;
}, []).concat(n);
}, De = function(t, n) {
n = n || {};
var r;
return n.getShadowRoot ? r = Lt([t], n.includeContainer, {
filter: Ze.bind(null, n),
flatten: !1,
getShadowRoot: n.getShadowRoot,
shadowRootFilter: hn
}) : r = Ft(t, n.includeContainer, Ze.bind(null, n)), Rn(r);
}, yn = function(t, n) {
n = n || {};
var r;
return n.getShadowRoot ? r = Lt([t], n.includeContainer, {
filter: Ge.bind(null, n),
flatten: !0,
getShadowRoot: n.getShadowRoot
}) : r = Ft(t, n.includeContainer, Ge.bind(null, n)), r;
}, _t = function(t, n) {
if (n = n || {}, !t)
throw new Error("No node provided");
return he.call(t, ke) === !1 ? !1 : Ze(n, t);
};
function tt() {
const e = navigator.userAgentData;
return e != null && e.platform ? e.platform : navigator.platform;
}
function Wt() {
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 Bt() {
return /apple/i.test(navigator.vendor);
}
function ze() {
const e = /android/i;
return e.test(tt()) || e.test(Wt());
}
function En() {
return tt().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
}
function Vt() {
return Wt().includes("jsdom/");
}
const ut = "data-floating-ui-focusable", wn = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
function fe(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 z(e, t) {
if (!e || !t)
return !1;
const n = t.getRootNode == null ? void 0 : t.getRootNode();
if (e.contains(t))
return !0;
if (n && Gt(n)) {
let r = t;
for (; r; ) {
if (e === r)
return !0;
r = r.parentNode || r.host;
}
}
return !1;
}
function ae(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 xn(e) {
return e.matches("html,body");
}
function Q(e) {
return (e == null ? void 0 : e.ownerDocument) || document;
}
function nt(e) {
return se(e) && e.matches(wn);
}
function at(e) {
return e ? e.getAttribute("role") === "combobox" && nt(e) : !1;
}
function Tn(e) {
if (!e || Vt()) return !0;
try {
return e.matches(":focus-visible");
} catch {
return !0;
}
}
function Je(e) {
return e ? e.hasAttribute(ut) ? e : e.querySelector("[" + ut + "]") || e : null;
}
function Re(e, t) {
let n = e.filter((o) => {
var s;
return o.parentId === t && ((s = o.context) == null ? void 0 : s.open);
}), r = n;
for (; r.length; )
r = e.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 ct(e, t) {
var n;
let r = [], o = (n = e.find((s) => s.id === t)) == null ? void 0 : n.parentId;
for (; o; ) {
const s = e.find((i) => i.id === o);
o = s == null ? void 0 : s.parentId, s && (r = r.concat(s));
}
return r;
}
function Ke(e) {
e.preventDefault(), e.stopPropagation();
}
function Cn(e) {
return "nativeEvent" in e;
}
function Sn(e) {
return e.mozInputSource === 0 && e.isTrusted ? !0 : ze() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function In(e) {
return Vt() ? !1 : !ze() && e.width === 0 && e.height === 0 || ze() && 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 Ee(e, t) {
const n = ["mouse", "pen"];
return t || n.push("", void 0), n.includes(e);
}
var Mn = typeof document < "u", Pn = function() {
}, G = Mn ? Pt : Pn;
const kn = {
...u
};
function ve(e) {
const t = u.useRef(e);
return G(() => {
t.current = e;
}), t;
}
const An = kn.useInsertionEffect, On = An || ((e) => e());
function ee(e) {
const t = u.useRef(() => {
if (process.env.NODE_ENV !== "production")
throw new Error("Cannot call an event handler while rendering.");
});
return On(() => {
t.current = e;
}), u.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 xe = () => ({
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 Kt(e, t) {
const n = De(e, xe()), r = n.length;
if (r === 0) return;
const o = fe(Q(e)), s = n.indexOf(o), i = s === -1 ? t === 1 ? 0 : r - 1 : s + t;
return n[i];
}
function qt(e) {
return Kt(Q(e).body, 1) || e;
}
function jt(e) {
return Kt(Q(e).body, -1) || e;
}
function ye(e, t) {
const n = t || e.currentTarget, r = e.relatedTarget;
return !r || !z(n, r);
}
function Fn(e) {
De(e, xe()).forEach((n) => {
n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
});
}
function lt(e) {
e.querySelectorAll("[data-tabindex]").forEach((n) => {
const r = n.dataset.tabindex;
delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
});
}
var Ln = typeof document < "u", Dn = function() {
}, Pe = Ln ? Pt : Dn;
function Fe(e, t) {
if (e === t)
return !0;
if (typeof e != typeof t)
return !1;
if (typeof e == "function" && e.toString() === t.toString())
return !0;
let n, r, o;
if (e && t && typeof e == "object") {
if (Array.isArray(e)) {
if (n = e.length, n !== t.length) return !1;
for (r = n; r-- !== 0; )
if (!Fe(e[r], t[r]))
return !1;
return !0;
}
if (o = Object.keys(e), n = o.length, n !== Object.keys(t).length)
return !1;
for (r = n; r-- !== 0; )
if (!{}.hasOwnProperty.call(t, o[r]))
return !1;
for (r = n; r-- !== 0; ) {
const s = o[r];
if (!(s === "_owner" && e.$$typeof) && !Fe(e[s], t[s]))
return !1;
}
return !0;
}
return e !== e && t !== t;
}
function Ut(e) {
return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function ft(e, t) {
const n = Ut(e);
return Math.round(t * n) / n;
}
function qe(e) {
const t = u.useRef(e);
return Pe(() => {
t.current = e;
}), t;
}
function Nn(e) {
e === void 0 && (e = {});
const {
placement: t = "bottom",
strategy: n = "absolute",
middleware: r = [],
platform: o,
elements: {
reference: s,
floating: i
} = {},
transform: a = !0,
whileElementsMounted: c,
open: l
} = e, [v, y] = u.useState({
x: 0,
y: 0,
strategy: n,
placement: t,
middlewareData: {},
isPositioned: !1
}), [w, f] = u.useState(r);
Fe(w, r) || f(r);
const [h, d] = u.useState(null), [x, C] = u.useState(null), g = u.useCallback((p) => {
p !== _.current && (_.current = p, d(p));
}, []), E = u.useCallback((p) => {
p !== A.current && (A.current = p, C(p));
}, []), S = s || h, D = i || x, _ = u.useRef(null), A = u.useRef(null), K = u.useRef(v), j = c != null, H = qe(c), N = qe(o), W = qe(l), B = u.useCallback(() => {
if (!_.current || !A.current)
return;
const p = {
placement: t,
strategy: n,
middleware: w
};
N.current && (p.platform = N.current), zt(_.current, A.current, p).then((R) => {
const I = {
...R,
// 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: W.current !== !1
};
O.current && !Fe(K.current, I) && (K.current = I, et.flushSync(() => {
y(I);
}));
});
}, [w, t, n, N, W]);
Pe(() => {
l === !1 && K.current.isPositioned && (K.current.isPositioned = !1, y((p) => ({
...p,
isPositioned: !1
})));
}, [l]);
const O = u.useRef(!1);
Pe(() => (O.current = !0, () => {
O.current = !1;
}), []), Pe(() => {
if (S && (_.current = S), D && (A.current = D), S && D) {
if (H.current)
return H.current(S, D, B);
B();
}
}, [S, D, B, H, j]);
const m = u.useMemo(() => ({
reference: _,
floating: A,
setReference: g,
setFloating: E
}), [g, E]), F = u.useMemo(() => ({
reference: S,
floating: D
}), [S, D]), T = u.useMemo(() => {
const p = {
position: n,
left: 0,
top: 0
};
if (!F.floating)
return p;
const R = ft(F.floating, v.x), I = ft(F.floating, v.y);
return a ? {
...p,
transform: "translate(" + R + "px, " + I + "px)",
...Ut(F.floating) >= 1.5 && {
willChange: "transform"
}
} : {
position: n,
left: R,
top: I
};
}, [n, a, F.floating, v.x, v.y]);
return u.useMemo(() => ({
...v,
update: B,
refs: m,
elements: F,
floatingStyles: T
}), [v, B, m, F, T]);
}
const $n = (e) => {
function t(n) {
return {}.hasOwnProperty.call(n, "current");
}
return {
name: "arrow",
options: e,
fn(n) {
const {
element: r,
padding: o
} = typeof e == "function" ? e(n) : e;
return r && t(r) ? r.current != null ? st({
element: r.current,
padding: o
}).fn(n) : {} : r ? st({
element: r,
padding: o
}).fn(n) : {};
}
};
}, mr = (e, t) => ({
...Jt(e),
options: [e, t]
}), vr = (e, t) => ({
...Qt(e),
options: [e, t]
}), pr = (e, t) => ({
...Zt(e),
options: [e, t]
}), gr = (e, t) => ({
...$n(e),
options: [e, t]
});
function br(e) {
const t = u.useRef(void 0), n = u.useCallback((r) => {
const o = e.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());
};
}, e);
return u.useMemo(() => e.every((r) => r == null) ? null : (r) => {
t.current && (t.current(), t.current = void 0), r != null && (t.current = n(r));
}, e);
}
const _n = "data-floating-ui-focusable", dt = "active", mt = "selected", Wn = {
...u
};
let vt = !1, Bn = 0;
const pt = () => (
// Ensure the id is unique with multiple independent versions of Floating UI
// on <React 18
"floating-ui-" + Math.random().toString(36).slice(2, 6) + Bn++
);
function Vn() {
const [e, t] = u.useState(() => vt ? pt() : void 0);
return G(() => {
e == null && t(pt());
}, []), u.useEffect(() => {
vt = !0;
}, []), e;
}
const Kn = Wn.useId, Ne = Kn || Vn;
let we;
process.env.NODE_ENV !== "production" && (we = /* @__PURE__ */ new Set());
function qn() {
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 = we) != null && e.has(o))) {
var s;
(s = we) == null || s.add(o), console.warn(o);
}
}
function jn() {
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 = we) != null && e.has(o))) {
var s;
(s = we) == null || s.add(o), console.error(o);
}
}
const hr = /* @__PURE__ */ u.forwardRef(function(t, n) {
const {
context: {
placement: r,
elements: {
floating: o
},
middlewareData: {
arrow: s,
shift: i
}
},
width: a = 14,
height: c = 7,
tipRadius: l = 0,
strokeWidth: v = 0,
staticOffset: y,
stroke: w,
d: f,
style: {
transform: h,
...d
} = {},
...x
} = t;
process.env.NODE_ENV !== "production" && (n || qn("The `ref` prop is required for `FloatingArrow`."));
const C = Ne(), [g, E] = u.useState(!1);
if (G(() => {
if (!o) return;
kt(o).direction === "rtl" && E(!0);
}, [o]), !o)
return null;
const [S, D] = r.split("-"), _ = S === "top" || S === "bottom";
let A = y;
(_ && i != null && i.x || !_ && i != null && i.y) && (A = null);
const K = v * 2, j = K / 2, H = a / 2 * (l / -8 + 1), N = c / 2 * l / 4, W = !!f, B = A && D === "end" ? "bottom" : "top";
let O = A && D === "end" ? "right" : "left";
A && g && (O = D === "end" ? "left" : "right");
const m = (s == null ? void 0 : s.x) != null ? A || s.x : "", F = (s == null ? void 0 : s.y) != null ? A || s.y : "", T = f || "M0,0" + (" H" + a) + (" L" + (a - H) + "," + (c - N)) + (" Q" + a / 2 + "," + c + " " + H + "," + (c - N)) + " Z", p = {
top: W ? "rotate(180deg)" : "",
left: W ? "rotate(90deg)" : "rotate(-90deg)",
bottom: W ? "" : "rotate(180deg)",
right: W ? "rotate(-90deg)" : "rotate(90deg)"
}[S];
return /* @__PURE__ */ Qe("svg", {
...x,
"aria-hidden": !0,
ref: n,
width: W ? a : a + K,
height: a,
viewBox: "0 0 " + a + " " + (c > a ? c : a),
style: {
position: "absolute",
pointerEvents: "none",
[O]: m,
[B]: F,
[S]: _ || W ? "100%" : "calc(100% - " + K / 2 + "px)",
transform: [p, h].filter((R) => !!R).join(" "),
...d
},
children: [K > 0 && /* @__PURE__ */ ne("path", {
clipPath: "url(#" + C + ")",
fill: "none",
stroke: w,
strokeWidth: K + (f ? 0 : 1),
d: T
}), /* @__PURE__ */ ne("path", {
stroke: K && !f ? x.fill : "none",
d: T
}), /* @__PURE__ */ ne("clipPath", {
id: C,
children: /* @__PURE__ */ ne("rect", {
x: -j,
y: j * (W ? -1 : 1),
width: a + K,
height: a
})
})]
});
});
function Un() {
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 Hn = /* @__PURE__ */ u.createContext(null), Yn = /* @__PURE__ */ u.createContext(null), rt = () => {
var e;
return ((e = u.useContext(Hn)) == null ? void 0 : e.id) || null;
}, $e = () => u.useContext(Yn);
function pe(e) {
return "data-floating-ui-" + e;
}
function te(e) {
e.current !== -1 && (clearTimeout(e.current), e.current = -1);
}
const gt = /* @__PURE__ */ pe("safe-polygon");
function je(e, t, n) {
if (n && !Ee(n))
return 0;
if (typeof e == "number")
return e;
if (typeof e == "function") {
const r = e();
return typeof r == "number" ? r : r == null ? void 0 : r[t];
}
return e == null ? void 0 : e[t];
}
function Ue(e) {
return typeof e == "function" ? e() : e;
}
function Rr(e, t) {
t === void 0 && (t = {});
const {
open: n,
onOpenChange: r,
dataRef: o,
events: s,
elements: i
} = e, {
enabled: a = !0,
delay: c = 0,
handleClose: l = null,
mouseOnly: v = !1,
restMs: y = 0,
move: w = !0
} = t, f = $e(), h = rt(), d = ve(l), x = ve(c), C = ve(n), g = ve(y), E = u.useRef(), S = u.useRef(-1), D = u.useRef(), _ = u.useRef(-1), A = u.useRef(!0), K = u.useRef(!1), j = u.useRef(() => {
}), H = u.useRef(!1), N = ee(() => {
var T;
const p = (T = o.current.openEvent) == null ? void 0 : T.type;
return (p == null ? void 0 : p.includes("mouse")) && p !== "mousedown";
});
u.useEffect(() => {
if (!a) return;
function T(p) {
let {
open: R
} = p;
R || (te(S), te(_), A.current = !0, H.current = !1);
}
return s.on("openchange", T), () => {
s.off("openchange", T);
};
}, [a, s]), u.useEffect(() => {
if (!a || !d.current || !n) return;
function T(R) {
N() && r(!1, R, "hover");
}
const p = Q(i.floating).documentElement;
return p.addEventListener("mouseleave", T), () => {
p.removeEventListener("mouseleave", T);
};
}, [i.floating, n, r, a, d, N]);
const W = u.useCallback(function(T, p, R) {
p === void 0 && (p = !0), R === void 0 && (R = "hover");
const I = je(x.current, "close", E.current);
I && !D.current ? (te(S), S.current = window.setTimeout(() => r(!1, T, R), I)) : p && (te(S), r(!1, T, R));
}, [x, r]), B = ee(() => {
j.current(), D.current = void 0;
}), O = ee(() => {
if (K.current) {
const T = Q(i.floating).body;
T.style.pointerEvents = "", T.removeAttribute(gt), K.current = !1;
}
}), m = ee(() => o.current.openEvent ? ["click", "mousedown"].includes(o.current.openEvent.type) : !1);
u.useEffect(() => {
if (!a) return;
function T(b) {
if (te(S), A.current = !1, v && !Ee(E.current) || Ue(g.current) > 0 && !je(x.current, "open"))
return;
const $ = je(x.current, "open", E.current);
$ ? S.current = window.setTimeout(() => {
C.current || r(!0, b, "hover");
}, $) : n || r(!0, b, "hover");
}
function p(b) {
if (m()) {
O();
return;
}
j.current();
const $ = Q(i.floating);
if (te(_), H.current = !1, d.current && o.current.floatingContext) {
n || te(S), D.current = d.current({
...o.current.floatingContext,
tree: f,
x: b.clientX,
y: b.clientY,
onClose() {
O(), B(), m() || W(b, !0, "safe-polygon");
}
});
const ce = D.current;
$.addEventListener("mousemove", ce), j.current = () => {
$.removeEventListener("mousemove", ce);
};
return;
}
(E.current === "touch" ? !z(i.floating, b.relatedTarget) : !0) && W(b);
}
function R(b) {
m() || o.current.floatingContext && (d.current == null || d.current({
...o.current.floatingContext,
tree: f,
x: b.clientX,
y: b.clientY,
onClose() {
O(), B(), m() || W(b);
}
})(b));
}
function I() {
te(S);
}
function V(b) {
m() || W(b, !1);
}
if (J(i.domReference)) {
const b = i.domReference, $ = i.floating;
return n && b.addEventListener("mouseleave", R), w && b.addEventListener("mousemove", T, {
once: !0
}), b.addEventListener("mouseenter", T), b.addEventListener("mouseleave", p), $ && ($.addEventListener("mouseleave", R), $.addEventListener("mouseenter", I), $.addEventListener("mouseleave", V)), () => {
n && b.removeEventListener("mouseleave", R), w && b.removeEventListener("mousemove", T), b.removeEventListener("mouseenter", T), b.removeEventListener("mouseleave", p), $ && ($.removeEventListener("mouseleave", R), $.removeEventListener("mouseenter", I), $.removeEventListener("mouseleave", V));
};
}
}, [i, a, e, v, w, W, B, O, r, n, C, f, x, d, o, m, g]), G(() => {
var T;
if (a && n && (T = d.current) != null && (T = T.__options) != null && T.blockPointerEvents && N()) {
K.current = !0;
const R = i.floating;
if (J(i.domReference) && R) {
var p;
const I = Q(i.floating).body;
I.setAttribute(gt, "");
const V = i.domReference, b = f == null || (p = f.nodesRef.current.find(($) => $.id === h)) == null || (p = p.context) == null ? void 0 : p.elements.floating;
return b && (b.style.pointerEvents = ""), I.style.pointerEvents = "none", V.style.pointerEvents = "auto", R.style.pointerEvents = "auto", () => {
I.style.pointerEvents = "", V.style.pointerEvents = "", R.style.pointerEvents = "";
};
}
}
}, [a, n, h, i, f, d, N]), G(() => {
n || (E.current = void 0, H.current = !1, B(), O());
}, [n, B, O]), u.useEffect(() => () => {
B(), te(S), te(_), O();
}, [a, i.domReference, B, O]);
const F = u.useMemo(() => {
function T(p) {
E.current = p.pointerType;
}
return {
onPointerDown: T,
onPointerEnter: T,
onMouseMove(p) {
const {
nativeEvent: R
} = p;
function I() {
!A.current && !C.current && r(!0, R, "hover");
}
v && !Ee(E.current) || n || Ue(g.current) === 0 || H.current && p.movementX ** 2 + p.movementY ** 2 < 2 || (te(_), E.current === "touch" ? I() : (H.current = !0, _.current = window.setTimeout(I, Ue(g.current))));
}
};
}, [v, r, n, C, g]);
return u.useMemo(() => a ? {
reference: F
} : {}, [a, F]);
}
let bt = 0;
function ge(e, t) {
t === void 0 && (t = {});
const {
preventScroll: n = !1,
cancelPrevious: r = !0,
sync: o = !1
} = t;
r && cancelAnimationFrame(bt);
const s = () => e == null ? void 0 : e.focus({
preventScroll: n
});
o ? s() : bt = requestAnimationFrame(s);
}
function Xn(e) {
return (e == null ? void 0 : e.ownerDocument) || document;
}
const be = {
inert: /* @__PURE__ */ new WeakMap(),
"aria-hidden": /* @__PURE__ */ new WeakMap(),
none: /* @__PURE__ */ new WeakMap()
};
function ht(e) {
return e === "inert" ? be.inert : e === "aria-hidden" ? be["aria-hidden"] : be.none;
}
let Se = /* @__PURE__ */ new WeakSet(), Ie = {}, He = 0;
const Gn = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype, Ht = (e) => e && (e.host || Ht(e.parentNode)), Zn = (e, t) => t.map((n) => {
if (e.contains(n))
return n;
const r = Ht(n);
return e.contains(r) ? r : null;
}).filter((n) => n != null);
function zn(e, t, n, r) {
const o = "data-floating-ui-inert", s = r ? "inert" : n ? "aria-hidden" : null, i = Zn(t, e), a = /* @__PURE__ */ new Set(), c = new Set(i), l = [];
Ie[o] || (Ie[o] = /* @__PURE__ */ new WeakMap());
const v = Ie[o];
i.forEach(y), w(t), a.clear();
function y(f) {
!f || a.has(f) || (a.add(f), f.parentNode && y(f.parentNode));
}
function w(f) {
!f || c.has(f) || [].forEach.call(f.children, (h) => {
if (At(h) !== "script")
if (a.has(h))
w(h);
else {
const d = s ? h.getAttribute(s) : null, x = d !== null && d !== "false", C = ht(s), g = (C.get(h) || 0) + 1, E = (v.get(h) || 0) + 1;
C.set(h, g), v.set(h, E), l.push(h), g === 1 && x && Se.add(h), E === 1 && h.setAttribute(o, ""), !x && s && h.setAttribute(s, s === "inert" ? "" : "true");
}
});
}
return He++, () => {
l.forEach((f) => {
const h = ht(s), x = (h.get(f) || 0) - 1, C = (v.get(f) || 0) - 1;
h.set(f, x), v.set(f, C), x || (!Se.has(f) && s && f.removeAttribute(s), Se.delete(f)), C || f.removeAttribute(o);
}), He--, He || (be.inert = /* @__PURE__ */ new WeakMap(), be["aria-hidden"] = /* @__PURE__ */ new WeakMap(), be.none = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakSet(), Ie = {});
};
}
function Rt(e, t, n) {
t === void 0 && (t = !1), n === void 0 && (n = !1);
const r = Xn(e[0]).body;
return zn(e.concat(Array.from(r.querySelectorAll("[aria-live]"))), r, t, n);
}
const _e = {
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
}, Le = /* @__PURE__ */ u.forwardRef(function(t, n) {
const [r, o] = u.useState();
G(() => {
Bt() && o("button");
}, []);
const s = {
ref: n,
tabIndex: 0,
// Role is only for VoiceOver
role: r,
"aria-hidden": r ? void 0 : !0,
[pe("focus-guard")]: "",
style: _e
};
return /* @__PURE__ */ ne("span", {
...t,
...s
});
}), Yt = /* @__PURE__ */ u.createContext(null), yt = /* @__PURE__ */ pe("portal");
function Jn(e) {
e === void 0 && (e = {});
const {
id: t,
root: n
} = e, r = Ne(), o = Xt(), [s, i] = u.useState(null), a = u.useRef(null);
return G(() => () => {
s == null || s.remove(), queueMicrotask(() => {
a.current = null;
});
}, [s]), G(() => {
if (!r || a.current) return;
const c = t ? document.getElementById(t) : null;
if (!c) return;
const l = document.createElement("div");
l.id = r, l.setAttribute(yt, ""), c.appendChild(l), a.current = l, i(l);
}, [t, r]), G(() => {
if (n === null || !r || a.current) return;
let c = n || (o == null ? void 0 : o.portalNode);
c && !J(c) && (c = c.current), c = c || document.body;
let l = null;
t && (l = document.createElement("div"), l.id = t, c.appendChild(l));
const v = document.createElement("div");
v.id = r, v.setAttribute(yt, ""), c = l || c, c.appendChild(v), a.current = v, i(v);
}, [t, n, r, o]), s;
}
function yr(e) {
const {
children: t,
id: n,
root: r,
preserveTabOrder: o = !0
} = e, s = Jn({
id: n,
root: r
}), [i, a] = u.useState(null), c = u.useRef(null), l = u.useRef(null), v = u.useRef(null), y = u.useRef(null), w = i == null ? void 0 : i.modal, f = i == null ? void 0 : i.open, h = (
// 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 u.useEffect(() => {
if (!s || !o || w)
return;
function d(x) {
s && ye(x) && (x.type === "focusin" ? lt : Fn)(s);
}
return s.addEventListener("focusin", d, !0), s.addEventListener("focusout", d, !0), () => {
s.removeEventListener("focusin", d, !0), s.removeEventListener("focusout", d, !0);
};
}, [s, o, w]), u.useEffect(() => {
s && (f || lt(s));
}, [f, s]), /* @__PURE__ */ Qe(Yt.Provider, {
value: u.useMemo(() => ({
preserveTabOrder: o,
beforeOutsideRef: c,
afterOutsideRef: l,
beforeInsideRef: v,
afterInsideRef: y,
portalNode: s,
setFocusManagerState: a
}), [o, s]),
children: [h && s && /* @__PURE__ */ ne(Le, {
"data-type": "outside",
ref: c,
onFocus: (d) => {
if (ye(d, s)) {
var x;
(x = v.current) == null || x.focus();
} else {
const C = i ? i.domReference : null, g = jt(C);
g == null || g.focus();
}
}
}), h && s && /* @__PURE__ */ ne("span", {
"aria-owns": s.id,
style: _e
}), s && /* @__PURE__ */ et.createPortal(t, s), h && s && /* @__PURE__ */ ne(Le, {
"data-type": "outside",
ref: l,
onFocus: (d) => {
if (ye(d, s)) {
var x;
(x = y.current) == null || x.focus();
} else {
const C = i ? i.domReference : null, g = qt(C);
g == null || g.focus(), i != null && i.closeOnFocusOut && (i == null || i.onOpenChange(!1, d.nativeEvent, "focus-out"));
}
}
})]
});
}
const Xt = () => u.useContext(Yt);
function Et(e) {
return u.useMemo(() => (t) => {
e.forEach((n) => {
n && (n.current = t);
});
}, e);
}
const Qn = 20;
let me = [];
function er(e) {
me = me.filter((t) => t.isConnected), e && At(e) !== "body" && (me.push(e), me.length > Qn && (me = me.slice(-20)));
}
function wt() {
return me.slice().reverse().find((e) => e.isConnected);
}
function tr(e) {
const t = xe();
return _t(e, t) ? e : De(e, t)[0] || e;
}
function xt(e, t) {
var n;
if (!t.current.includes("floating") && !((n = e.getAttribute("role")) != null && n.includes("dialog")))
return;
const r = xe(), s = yn(e, r).filter((a) => {
const c = a.getAttribute("data-tabindex") || "";
return _t(a, r) || a.hasAttribute("data-tabindex") && !c.startsWith("-");
}), i = e.getAttribute("tabindex");
t.current.includes("floating") || s.length === 0 ? i !== "0" && e.setAttribute("tabindex", "0") : (i !== "-1" || e.hasAttribute("data-tabindex") && e.getAttribute("data-tabindex") !== "-1") && (e.setAttribute("tabindex", "-1"), e.setAttribute("data-tabindex", "-1"));
}
const nr = /* @__PURE__ */ u.forwardRef(function(t, n) {
return /* @__PURE__ */ ne("button", {
...t,
type: "button",
ref: n,
tabIndex: -1,
style: _e
});
});
function Er(e) {
const {
context: t,
children: n,
disabled: r = !1,
order: o = ["content"],
guards: s = !0,
initialFocus: i = 0,
returnFocus: a = !0,
restoreFocus: c = !1,
modal: l = !0,
visuallyHiddenDismiss: v = !1,
closeOnFocusOut: y = !0,
outsideElementsInert: w = !1,
getInsideElements: f = () => []
} = e, {
open: h,
onOpenChange: d,
events: x,
dataRef: C,
elements: {
domReference: g,
floating: E
}
} = t, S = ee(() => {
var M;
return (M = C.current.floatingContext) == null ? void 0 : M.nodeId;
}), D = ee(f), _ = typeof i == "number" && i < 0, A = at(g) && _, K = Gn(), j = K ? s : !0, H = !j || K && w, N = ve(o), W = ve(i), B = ve(a), O = $e(), m = Xt(), F = u.useRef(null), T = u.useRef(null), p = u.useRef(!1), R = u.useRef(!1), I = u.useRef(-1), V = m != null, b = Je(E), $ = ee(function(M) {
return M === void 0 && (M = b), M ? De(M, xe()) : [];
}), ie = ee((M) => {
const L = $(M);
return N.current.map((P) => g && P === "reference" ? g : b && P === "floating" ? b : L).filter(Boolean).flat();
});
u.useEffect(() => {
if (r || !l) return;
function M(P) {
if (P.key === "Tab") {
z(b, fe(Q(b))) && $().length === 0 && !A && Ke(P);
const k = ie(), Y = ae(P);
N.current[0] === "reference" && Y === g && (Ke(P), P.shiftKey ? ge(k[k.length - 1]) : ge(k[1])), N.current[1] === "floating" && Y === b && P.shiftKey && (Ke(P), ge(k[0]));
}
}
const L = Q(b);
return L.addEventListener("keydown", M), () => {
L.removeEventListener("keydown", M);
};
}, [r, g, b, l, N, A, $, ie]), u.useEffect(() => {
if (r || !E) return;
function M(L) {
const P = ae(L), Y = $().indexOf(P);
Y !== -1 && (I.current = Y);
}
return E.addEventListener("focusin", M), () => {
E.removeEventListener("focusin", M);
};
}, [r, E, $]), u.useEffect(() => {
if (r || !y) return;
function M() {
R.current = !0, setTimeout(() => {
R.current = !1;
});
}
function L(P) {
const k = P.relatedTarget, Y = P.currentTarget, X = ae(P);
queueMicrotask(() => {
const oe = S(), ue = !(z(g, k) || z(E, k) || z(k, E) || z(m == null ? void 0 : m.portalNode, k) || k != null && k.hasAttribute(pe("focus-guard")) || O && (Re(O.nodesRef.current, oe).find((q) => {
var U, le;
return z((U = q.context) == null ? void 0 : U.elements.floating, k) || z((le = q.context) == null ? void 0 : le.elements.domReference, k);
}) || ct(O.nodesRef.current, oe).find((q) => {
var U, le, ot;
return [(U = q.context) == null ? void 0 : U.elements.floating, Je((le = q.context) == null ? void 0 : le.elements.floating)].includes(k) || ((ot = q.context) == null ? void 0 : ot.elements.domReference) === k;
})));
if (Y === g && b && xt(b, N), c && Y !== g && !(X != null && X.isConnected) && fe(Q(b)) === Q(b).body) {
se(b) && b.focus();
const q = I.current, U = $(), le = U[q] || U[U.length - 1] || b;
se(le) && le.focus();
}
if (C.current.insideReactTree) {
C.current.insideReactTree = !1;
return;
}
(A || !l) && k && ue && !R.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
k !== wt() && (p.current = !0, d(!1, P, "focus-out"));
});
}
if (E && se(g))
return g.addEventListener("focusout", L), g.addEventListener("pointerdown", M), E.addEventListener("focusout", L), () => {
g.removeEventListener("focusout", L), g.removeEventListener("pointerdown", M), E.removeEventListener("focusout", L);
};
}, [r, g, E, b, l, O, m, d, y, c, $, A, S, N, C]);
const ce = u.useRef(null), Z = u.useRef(null), re = Et([ce, m == null ? void 0 : m.beforeInsideRef]), de = Et([Z, m == null ? void 0 : m.afterInsideRef]);
u.useEffect(() => {
var M, L;
if (r || !E) return;
const P = Array.from((m == null || (M = m.portalNode) == null ? void 0 : M.querySelectorAll("[" + pe("portal") + "]")) || []), k = O ? ct(O.nodesRef.current, S()) : [], Y = O && !l ? k.map((q) => {
var U;
return (U = q.context) == null ? void 0 : U.elements.floating;
}) : [], X = (L = k.find((q) => {
var U;
return at(((U = q.context) == null ? void 0 : U.elements.domReference) || null);
})) == null || (L = L.context) == null ? void 0 : L.elements.domReference, oe = [E, X, ...P, ...Y, ...D(), F.current, T.current, ce.current, Z.current, m == null ? void 0 : m.beforeOutsideRef.current, m == null ? void 0 : m.afterOutsideRef.current, N.current.includes("reference") || A ? g : null].filter((q) => q != null), ue = l || A ? Rt(oe, !H, H) : Rt(oe);
return () => {
ue();
};
}, [r, g, E, l, N, m, A, j, H, O, S, D]), G(() => {
if (r || !se(b)) return;
const M = Q(b), L = fe(M);
queueMicrotask(() => {
const P = ie(b), k = W.current, Y = (typeof k == "number" ? P[k] : k.current) || b, X = z(b, L);
!_ && !X && h && ge(Y, {
preventScroll: Y === b
});
});
}, [r, h, b, _, ie, W]), G(() => {
if (r || !b) return;
const M = Q(b), L = fe(M);
er(L);
function P(X) {
let {
reason: oe,
event: ue,
nested: q
} = X;
if (["hover", "safe-polygon"].includes(oe) && ue.type === "mouseleave" && (p.current = !0), oe === "outside-press")
if (q)
p.current = !1;
else if (Sn(ue) || In(ue))
p.current = !1;
else {
let U = !1;
document.createElement("div").focus({
get preventScroll() {
return U = !0, !1;
}
}), U ? p.current = !1 : p.current = !0;
}
}
x.on("openchange", P);
const k = M.createElement("span");
k.setAttribute("tabindex", "-1"), k.setAttribute("aria-hidden", "true"), Object.assign(k.style, _e), V && g && g.insertAdjacentElement("afterend", k);
function Y() {
if (typeof B.current == "boolean") {
const X = g || wt();
return X && X.isConnected ? X : k;
}
return B.current.current || k;
}
return () => {
x.off("openchange", P);
const X = fe(M), oe = z(E, X) || O && Re(O.nodesRef.current, S()).some((q) => {
var U;
return z((U = q.context) == null ? void 0 : U.elements.floating, X);
}), ue = Y();
queueMicrotask(() => {
const q = tr(ue);
// eslint-disable-next-line react-hooks/exhaustive-deps
B.current && !p.current && se(q) && // 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
(!(q !== X && X !== M.body) || oe) && q.focus({
preventScroll: !0
}), k.remove();
});
};
}, [r, E, b, B, C, x, O, V, g, S]), u.useEffect(() => {
queueMicrotask(() => {
p.current = !1;
});
}, [r]), G(() => {
if (!r && m)
return m.setFocusManagerState({
modal: l,
closeOnFocusOut: y,
open: h,
onOpenChange: d,
domReference: g
}), () => {
m.setFocusManagerState(null);
};
}, [r, m, l, h, d, y, g]), G(() => {
r || b && xt(b, N);
}, [r, b, N]);
function Te(M) {
return r || !v || !l ? null : /* @__PURE__ */ ne(nr, {
ref: M === "start" ? F : T,
onClick: (L) => d(!1, L.nativeEvent),
children: typeof v == "string" ? v : "Dismiss"
});
}
const Ce = !r && j && (l ? !A : !0) && (V || l);
return /* @__PURE__ */ Qe(rn, {
children: [Ce && /* @__PURE__ */ ne(Le, {
"data-type": "inside",
ref: re,
onFocus: (M) => {
if (l) {
const P = ie();
ge(o[0] === "reference" ? P[0] : P[P.length - 1]);
} else if (m != null && m.preserveTabOrder && m.portalNode)
if (p.current = !1, ye(M, m.portalNode)) {
const P = qt(g);
P == null || P.focus();
} else {
var L;
(L = m.beforeOutsideRef.current) == null || L.focus();
}
}
}), !A && Te("start"), n, Te("end"), Ce && /* @__PURE__ */ ne(Le, {
"data-type": "inside",
ref: de,
onFocus: (M) => {
if (l)
ge(ie()[0]);
else if (m != null && m.preserveTabOrder && m.portalNode)
if (y && (p.current = !0), ye(M, m.portalNode)) {
const P = jt(g);
P == null || P.focus();
} else {
var L;
(L = m.afterOutsideRef.current) == null || L.focus();
}
}
})]
});
}
let Me = 0;
const Tt = "--floating-ui-scrollbar-width";
function rr() {
const e = tt(), t = /iP(hone|ad|od)|iOS/.test(e) || // iPads can claim to be MacIntel
e === "MacIntel" && navigator.maxTouchPoints > 1, n = document.body.style, o = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft ? "paddingLeft" : "paddingRight", s = window.innerWidth - document.documentElement.clientWidth, i = n.left ? parseFloat(n.left) : window.scrollX, a = n.top ? parseFloat(n.top) : window.scrollY;
if (n.overflow = "hidden", n.setProperty(Tt, s + "px"), s && (n[o] = s + "px"), t) {
var c, l;
const v = ((c = window.visualViewport) == null ? void 0 : c.offsetLeft) || 0, y = ((l = window.visualViewport) == null ? void 0 : l.offsetTop) || 0;
Object.assign(n, {
position: "fixed",
top: -(a - Math.floor(y)) + "px",
left: -(i - Math.floor(v)) + "px",
right: "0"
});
}
return () => {
Object.assign(n, {
overflow: "",
[o]: ""
}), n.removeProperty(Tt), t && (Object.assign(n, {
position: "",
top: "",
left: "",
right: ""
}), window.scrollTo(i, a));
};
}
let Ct = () => {
};
const wr = /* @__PURE__ */ u.forwardRef(function(t, n) {
const {
lockScroll: r = !1,
...o
} = t;
return G(() => {
if (r)
return Me++, Me === 1 && (Ct = rr()), () => {
Me--, Me === 0 && Ct();
};
}, [r]), /* @__PURE__ */ ne("div", {
ref: n,
...o,
style: {
position: "fixed",
overflow: "auto",
top: 0,
right: 0,
bottom: 0,
left: 0,
...o.style
}
});
});
function St(e) {
return se(e.target) && e.target.tagName === "BUTTON";
}
function or(e) {
return se(e.target) && e.target.tagName === "A";
}
function It(e) {
return nt(e);
}
function xr(e, t) {
t === void 0 && (t = {});
const {
open: n,
onOpenChange: r,
dataRef: o,
elements: {
domReference: s
}
} = e, {
enabled: i = !0,
event: a = "click",
toggle: c = !0,
ignoreMouse: l = !1,
keyboardHandlers: v = !0,
stickIfOpen: y = !0
} = t, w = u.useRef(), f = u.useRef(!1), h = u.useMemo(() => ({
onPointerDown(d) {
w.current = d.pointerType;
},
onMouseDown(d) {
const x = w.current;
d.button === 0 && a !== "click" && (Ee(x, !0) && l || (n && c && (!(o.current.openEvent && y) || o.current.openEvent.type === "mousedown") ? r(!1, d.nativeEvent, "click") : (d.preventDefault(), r(!0, d.nativeEvent, "click"))));
},
onClick(d) {
const x = w.current;
if (a === "mousedown" && w.current) {
w.current = void 0;
return;
}
Ee(x, !0) && l || (n && c && (!(o.current.openEvent && y) || o.current.openEvent.type === "click") ? r(!1, d.nativeEvent, "click") : r(!0, d.nativeEvent, "click"));
},
onKeyDown(d) {
w.current = void 0, !(d.defaultPrevented || !v || St(d)) && (d.key === " " && !It(s) && (d.preventDefault(), f.current = !0), !or(d) && d.key === "Enter" && r(!(n && c), d.nativeEvent, "click"));
},
onKeyUp(d) {
d.defaultPrevented || !v || St(d) || It(s) || d.key === " " && f.current && (f.current = !1, r(!(n && c), d.nativeEvent, "click"));
}
}), [o, s, a, l, v, r, n, y, c]);
return u.useMemo(() => i ? {
reference: h
} : {}, [i, h]);
}
const sr = {
pointerdown: "onPointerDown",
mousedown: "onMouseDown",
click: "onClick"
}, ir = {
pointerdown: "onPointerDownCapture",
mousedown: "onMouseDownCapture",
click: "onClickCapture"
}, Mt = (e) => {
var t, n;
return {
escapeKey: typeof e == "boolean" ? e : (t = e == null ? void 0 : e.escapeKey) != null ? t : !1,
outsidePress: typeof e == "boolean" ? e : (n = e == null ? void 0 : e.outsidePress) != null ? n : !0
};
};
function Tr(e, t) {
t === void 0 && (t = {});
const {
open: n,
onOpenChange: r,
elements: o,
dataRef: s
} = e, {
enabled: i = !0,
escapeKey: a = !0,
outsidePress: c = !0,
outsidePressEvent: l = "pointerdown",
referencePress: v = !1,
referencePressEvent: y = "pointerdown",
ancestorScroll: w = !1,
bubbles: f,
capture: h
} = t, d = $e(), x = ee(typeof c == "function" ? c : () => !1), C = typeof c == "function" ? x : c, g = u.useRef(!1), {
escapeKey: E,
outsidePress: S
} = Mt(f), {
escapeKey: D,
outsidePress: _
} = Mt(h), A = u.useRef(!1), K = u.useRef(-1), j = ee((m) => {
var F;
if (!n || !i || !a || m.key !== "Escape" || A.current)
return;
const T = (F = s.current.floatingContext) == null ? void 0 : F.nodeId, p = d ? Re(d.nodesRef.current, T) : [];
if (!E && (m.stopPropagation(), p.length > 0)) {
let R = !0;
if (p.forEach((I) => {
var V;
if ((V = I.context) != null && V.open && !I.context.dataRef.current.__escapeKeyBubbles) {
R = !1;
return;
}
}), !R)
return;
}
r(!1, Cn(m) ?