@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
1,777 lines • 89.2 kB
JavaScript
"use client";
import * as f from "react";
import { useLayoutEffect as wn } from "react";
import { jsxs as Lt, jsx as re, Fragment as Yn } from "react/jsx-runtime";
import * as It from "react-dom";
function rt() {
return typeof window < "u";
}
function xe(e) {
return kt(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function ee(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function ue(e) {
var t;
return (t = (kt(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function kt(e) {
return rt() ? e instanceof Node || e instanceof ee(e).Node : !1;
}
function K(e) {
return rt() ? e instanceof Element || e instanceof ee(e).Element : !1;
}
function U(e) {
return rt() ? e instanceof HTMLElement || e instanceof ee(e).HTMLElement : !1;
}
function Et(e) {
return !rt() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof ee(e).ShadowRoot;
}
const zn = /* @__PURE__ */ new Set(["inline", "contents"]);
function We(e) {
const {
overflow: t,
overflowX: n,
overflowY: r,
display: o
} = oe(e);
return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && !zn.has(o);
}
const Gn = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Zn(e) {
return Gn.has(xe(e));
}
const Jn = [":popover-open", ":modal"];
function ot(e) {
return Jn.some((t) => {
try {
return e.matches(t);
} catch {
return !1;
}
});
}
const Qn = ["transform", "translate", "scale", "rotate", "perspective"], er = ["transform", "translate", "scale", "rotate", "perspective", "filter"], tr = ["paint", "layout", "strict", "content"];
function Dt(e) {
const t = it(), n = K(e) ? oe(e) : e;
return Qn.some((r) => n[r] ? n[r] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || er.some((r) => (n.willChange || "").includes(r)) || tr.some((r) => (n.contain || "").includes(r));
}
function nr(e) {
let t = ge(e);
for (; U(t) && !me(t); ) {
if (Dt(t))
return t;
if (ot(t))
return null;
t = ge(t);
}
return null;
}
function it() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const rr = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function me(e) {
return rr.has(xe(e));
}
function oe(e) {
return ee(e).getComputedStyle(e);
}
function st(e) {
return K(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function ge(e) {
if (xe(e) === "html")
return e;
const t = (
// Step into the shadow DOM of the parent of a slotted node.
e.assignedSlot || // DOM Element detected.
e.parentNode || // ShadowRoot detected.
Et(e) && e.host || // Fallback.
ue(e)
);
return Et(t) ? t.host : t;
}
function Rn(e) {
const t = ge(e);
return me(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : U(t) && We(t) ? t : Rn(t);
}
function Re(e, t, n) {
var r;
t === void 0 && (t = []), n === void 0 && (n = !0);
const o = Rn(e), i = o === ((r = e.ownerDocument) == null ? void 0 : r.body), s = ee(o);
if (i) {
const c = Tt(s);
return t.concat(s, s.visualViewport || [], We(o) ? o : [], c && n ? Re(c) : []);
}
return t.concat(o, Re(o, [], n));
}
function Tt(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
const ke = Math.min, Se = Math.max, ze = Math.round, je = Math.floor, le = (e) => ({
x: e,
y: e
}), or = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, ir = {
start: "end",
end: "start"
};
function St(e, t, n) {
return Se(e, ke(t, n));
}
function $e(e, t) {
return typeof e == "function" ? e(t) : e;
}
function Ce(e) {
return e.split("-")[0];
}
function Ve(e) {
return e.split("-")[1];
}
function xn(e) {
return e === "x" ? "y" : "x";
}
function Ft(e) {
return e === "y" ? "height" : "width";
}
const sr = /* @__PURE__ */ new Set(["top", "bottom"]);
function ye(e) {
return sr.has(Ce(e)) ? "y" : "x";
}
function Nt(e) {
return xn(ye(e));
}
function cr(e, t, n) {
n === void 0 && (n = !1);
const r = Ve(e), o = Nt(e), i = Ft(o);
let s = o === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
return t.reference[i] > t.floating[i] && (s = Ge(s)), [s, Ge(s)];
}
function lr(e) {
const t = Ge(e);
return [Ct(e), t, Ct(t)];
}
function Ct(e) {
return e.replace(/start|end/g, (t) => ir[t]);
}
const Kt = ["left", "right"], jt = ["right", "left"], ur = ["top", "bottom"], ar = ["bottom", "top"];
function fr(e, t, n) {
switch (e) {
case "top":
case "bottom":
return n ? t ? jt : Kt : t ? Kt : jt;
case "left":
case "right":
return t ? ur : ar;
default:
return [];
}
}
function dr(e, t, n, r) {
const o = Ve(e);
let i = fr(Ce(e), n === "start", r);
return o && (i = i.map((s) => s + "-" + o), t && (i = i.concat(i.map(Ct)))), i;
}
function Ge(e) {
return e.replace(/left|right|bottom|top/g, (t) => or[t]);
}
function mr(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function En(e) {
return typeof e != "number" ? mr(e) : {
top: e,
right: e,
bottom: e,
left: e
};
}
function Ze(e) {
const {
x: t,
y: n,
width: r,
height: o
} = e;
return {
width: r,
height: o,
top: n,
left: t,
right: t + r,
bottom: n + o,
x: t,
y: n
};
}
/*!
* tabbable 6.2.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var gr = ["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])"], Je = /* @__PURE__ */ gr.join(","), Tn = typeof Element > "u", De = Tn ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, Qe = !Tn && 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;
}, et = 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"), i = o === "" || o === "true", s = i || n && t && e(t.parentNode);
return s;
}, pr = function(t) {
var n, r = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
return r === "" || r === "true";
}, Sn = function(t, n, r) {
if (et(t))
return [];
var o = Array.prototype.slice.apply(t.querySelectorAll(Je));
return n && De.call(t, Je) && o.unshift(t), o = o.filter(r), o;
}, Cn = function e(t, n, r) {
for (var o = [], i = Array.from(t); i.length; ) {
var s = i.shift();
if (!et(s, !1))
if (s.tagName === "SLOT") {
var c = s.assignedElements(), l = c.length ? c : s.children, u = e(l, !0, r);
r.flatten ? o.push.apply(o, u) : o.push({
scopeParent: s,
candidates: u
});
} else {
var d = De.call(s, Je);
d && r.filter(s) && (n || !t.includes(s)) && o.push(s);
var g = s.shadowRoot || // check for an undisclosed shadow
typeof r.getShadowRoot == "function" && r.getShadowRoot(s), h = !et(g, !1) && (!r.shadowRootFilter || r.shadowRootFilter(s));
if (g && h) {
var a = e(g === !0 ? s.children : g.children, !0, r);
r.flatten ? o.push.apply(o, a) : o.push({
scopeParent: s,
candidates: a
});
} else
i.unshift.apply(i, s.children);
}
}
return o;
}, An = function(t) {
return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, On = function(t) {
if (!t)
throw new Error("No node provided");
return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || pr(t)) && !An(t) ? 0 : t.tabIndex;
}, vr = function(t, n) {
var r = On(t);
return r < 0 && n && !An(t) ? 0 : r;
}, hr = function(t, n) {
return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
}, Mn = function(t) {
return t.tagName === "INPUT";
}, br = function(t) {
return Mn(t) && t.type === "hidden";
}, yr = function(t) {
var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
return r.tagName === "SUMMARY";
});
return n;
}, wr = function(t, n) {
for (var r = 0; r < t.length; r++)
if (t[r].checked && t[r].form === n)
return t[r];
}, Rr = function(t) {
if (!t.name)
return !0;
var n = t.form || Qe(t), r = function(c) {
return n.querySelectorAll('input[type="radio"][name="' + c + '"]');
}, 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 = wr(o, t.form);
return !i || i === t;
}, xr = function(t) {
return Mn(t) && t.type === "radio";
}, Er = function(t) {
return xr(t) && !Rr(t);
}, Tr = function(t) {
var n, r = t && Qe(t), o = (n = r) === null || n === void 0 ? void 0 : n.host, i = !1;
if (r && r !== t) {
var s, c, l;
for (i = !!((s = o) !== null && s !== void 0 && (c = s.ownerDocument) !== null && c !== void 0 && c.contains(o) || t != null && (l = t.ownerDocument) !== null && l !== void 0 && l.contains(t)); !i && o; ) {
var u, d, g;
r = Qe(o), o = (u = r) === null || u === void 0 ? void 0 : u.host, i = !!((d = o) !== null && d !== void 0 && (g = d.ownerDocument) !== null && g !== void 0 && g.contains(o));
}
}
return i;
}, qt = function(t) {
var n = t.getBoundingClientRect(), r = n.width, o = n.height;
return r === 0 && o === 0;
}, Sr = function(t, n) {
var r = n.displayCheck, o = n.getShadowRoot;
if (getComputedStyle(t).visibility === "hidden")
return !0;
var i = De.call(t, "details>summary:first-of-type"), s = i ? t.parentElement : t;
if (De.call(s, "details:not([open]) *"))
return !0;
if (!r || r === "full" || r === "legacy-full") {
if (typeof o == "function") {
for (var c = t; t; ) {
var l = t.parentElement, u = Qe(t);
if (l && !l.shadowRoot && o(l) === !0)
return qt(t);
t.assignedSlot ? t = t.assignedSlot : !l && u !== t.ownerDocument ? t = u.host : t = l;
}
t = c;
}
if (Tr(t))
return !t.getClientRects().length;
if (r !== "legacy-full")
return !0;
} else if (r === "non-zero-area")
return qt(t);
return !1;
}, Cr = 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 De.call(n, "fieldset[disabled] *") ? !0 : !o.contains(t);
}
return !0;
}
n = n.parentElement;
}
return !1;
}, At = 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`)
et(n) || br(n) || Sr(n, t) || // For a details element with a summary, the summary element gets the focus
yr(n) || Cr(n));
}, Ot = function(t, n) {
return !(Er(n) || On(n) < 0 || !At(t, n));
}, Ar = function(t) {
var n = parseInt(t.getAttribute("tabindex"), 10);
return !!(isNaN(n) || n >= 0);
}, Or = function e(t) {
var n = [], r = [];
return t.forEach(function(o, i) {
var s = !!o.scopeParent, c = s ? o.scopeParent : o, l = vr(c, s), u = s ? e(o.candidates) : c;
l === 0 ? s ? n.push.apply(n, u) : n.push(c) : r.push({
documentOrder: i,
tabIndex: l,
item: o,
isScope: s,
content: u
});
}), r.sort(hr).reduce(function(o, i) {
return i.isScope ? o.push.apply(o, i.content) : o.push(i.content), o;
}, []).concat(n);
}, ct = function(t, n) {
n = n || {};
var r;
return n.getShadowRoot ? r = Cn([t], n.includeContainer, {
filter: Ot.bind(null, n),
flatten: !1,
getShadowRoot: n.getShadowRoot,
shadowRootFilter: Ar
}) : r = Sn(t, n.includeContainer, Ot.bind(null, n)), Or(r);
}, Mr = function(t, n) {
n = n || {};
var r;
return n.getShadowRoot ? r = Cn([t], n.includeContainer, {
filter: At.bind(null, n),
flatten: !0,
getShadowRoot: n.getShadowRoot
}) : r = Sn(t, n.includeContainer, At.bind(null, n)), r;
}, Pn = function(t, n) {
if (n = n || {}, !t)
throw new Error("No node provided");
return De.call(t, Je) === !1 ? !1 : Ot(n, t);
};
function Bt() {
const e = navigator.userAgentData;
return e != null && e.platform ? e.platform : navigator.platform;
}
function Ln() {
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 In() {
return /apple/i.test(navigator.vendor);
}
function Mt() {
const e = /android/i;
return e.test(Bt()) || e.test(Ln());
}
function Pr() {
return Bt().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
}
function kn() {
return Ln().includes("jsdom/");
}
const Xt = "data-floating-ui-focusable", Lr = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
function be(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 && Et(n)) {
let r = t;
for (; r; ) {
if (e === r)
return !0;
r = r.parentNode || r.host;
}
}
return !1;
}
function de(e) {
return "composedPath" in e ? e.composedPath()[0] : e.target;
}
function gt(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 Ir(e) {
return e.matches("html,body");
}
function J(e) {
return e?.ownerDocument || document;
}
function Wt(e) {
return U(e) && e.matches(Lr);
}
function Ut(e) {
return e ? e.getAttribute("role") === "combobox" && Wt(e) : !1;
}
function kr(e) {
if (!e || kn()) return !0;
try {
return e.matches(":focus-visible");
} catch {
return !0;
}
}
function Pt(e) {
return e ? e.hasAttribute(Xt) ? e : e.querySelector("[" + Xt + "]") || e : null;
}
function Pe(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, ...Pe(e, o.id, n)]);
}
function Yt(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 pt(e) {
e.preventDefault(), e.stopPropagation();
}
function Dr(e) {
return "nativeEvent" in e;
}
function Fr(e) {
return e.mozInputSource === 0 && e.isTrusted ? !0 : Mt() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function Nr(e) {
return kn() ? !1 : !Mt() && e.width === 0 && e.height === 0 || Mt() && 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 Ne(e, t) {
const n = ["mouse", "pen"];
return t || n.push("", void 0), n.includes(e);
}
var Br = typeof document < "u", Wr = function() {
}, G = Br ? wn : Wr;
const $r = {
...f
};
function Te(e) {
const t = f.useRef(e);
return G(() => {
t.current = e;
}), t;
}
const Vr = $r.useInsertionEffect, _r = Vr || ((e) => e());
function Q(e) {
const t = f.useRef(() => {
if (process.env.NODE_ENV !== "production")
throw new Error("Cannot call an event handler while rendering.");
});
return _r(() => {
t.current = e;
}), f.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 _e = () => ({
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 Dn(e, t) {
const n = ct(e, _e()), r = n.length;
if (r === 0) return;
const o = be(J(e)), i = n.indexOf(o), s = i === -1 ? t === 1 ? 0 : r - 1 : i + t;
return n[s];
}
function Fn(e) {
return Dn(J(e).body, 1) || e;
}
function Nn(e) {
return Dn(J(e).body, -1) || e;
}
function Fe(e, t) {
const n = t || e.currentTarget, r = e.relatedTarget;
return !r || !Z(n, r);
}
function Hr(e) {
ct(e, _e()).forEach((n) => {
n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
});
}
function zt(e) {
e.querySelectorAll("[data-tabindex]").forEach((n) => {
const r = n.dataset.tabindex;
delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
});
}
function Gt(e, t, n) {
let {
reference: r,
floating: o
} = e;
const i = ye(t), s = Nt(t), c = Ft(s), l = Ce(t), u = i === "y", d = r.x + r.width / 2 - o.width / 2, g = r.y + r.height / 2 - o.height / 2, h = r[c] / 2 - o[c] / 2;
let a;
switch (l) {
case "top":
a = {
x: d,
y: r.y - o.height
};
break;
case "bottom":
a = {
x: d,
y: r.y + r.height
};
break;
case "right":
a = {
x: r.x + r.width,
y: g
};
break;
case "left":
a = {
x: r.x - o.width,
y: g
};
break;
default:
a = {
x: r.x,
y: r.y
};
}
switch (Ve(t)) {
case "start":
a[s] -= h * (n && u ? -1 : 1);
break;
case "end":
a[s] += h * (n && u ? -1 : 1);
break;
}
return a;
}
const Kr = async (e, t, n) => {
const {
placement: r = "bottom",
strategy: o = "absolute",
middleware: i = [],
platform: s
} = n, c = i.filter(Boolean), l = await (s.isRTL == null ? void 0 : s.isRTL(t));
let u = await s.getElementRects({
reference: e,
floating: t,
strategy: o
}), {
x: d,
y: g
} = Gt(u, r, l), h = r, a = {}, p = 0;
for (let m = 0; m < c.length; m++) {
const {
name: y,
fn: R
} = c[m], {
x: b,
y: w,
data: S,
reset: A
} = await R({
x: d,
y: g,
initialPlacement: r,
placement: h,
strategy: o,
middlewareData: a,
rects: u,
platform: s,
elements: {
reference: e,
floating: t
}
});
d = b ?? d, g = w ?? g, a = {
...a,
[y]: {
...a[y],
...S
}
}, A && p <= 50 && (p++, typeof A == "object" && (A.placement && (h = A.placement), A.rects && (u = A.rects === !0 ? await s.getElementRects({
reference: e,
floating: t,
strategy: o
}) : A.rects), {
x: d,
y: g
} = Gt(u, h, l)), m = -1);
}
return {
x: d,
y: g,
placement: h,
strategy: o,
middlewareData: a
};
};
async function Bn(e, t) {
var n;
t === void 0 && (t = {});
const {
x: r,
y: o,
platform: i,
rects: s,
elements: c,
strategy: l
} = e, {
boundary: u = "clippingAncestors",
rootBoundary: d = "viewport",
elementContext: g = "floating",
altBoundary: h = !1,
padding: a = 0
} = $e(t, e), p = En(a), y = c[h ? g === "floating" ? "reference" : "floating" : g], R = Ze(await i.getClippingRect({
element: (n = await (i.isElement == null ? void 0 : i.isElement(y))) == null || n ? y : y.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(c.floating)),
boundary: u,
rootBoundary: d,
strategy: l
})), b = g === "floating" ? {
x: r,
y: o,
width: s.floating.width,
height: s.floating.height
} : s.reference, w = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(c.floating)), S = await (i.isElement == null ? void 0 : i.isElement(w)) ? await (i.getScale == null ? void 0 : i.getScale(w)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, A = Ze(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: c,
rect: b,
offsetParent: w,
strategy: l
}) : b);
return {
top: (R.top - A.top + p.top) / S.y,
bottom: (A.bottom - R.bottom + p.bottom) / S.y,
left: (R.left - A.left + p.left) / S.x,
right: (A.right - R.right + p.right) / S.x
};
}
const jr = (e) => ({
name: "arrow",
options: e,
async fn(t) {
const {
x: n,
y: r,
placement: o,
rects: i,
platform: s,
elements: c,
middlewareData: l
} = t, {
element: u,
padding: d = 0
} = $e(e, t) || {};
if (u == null)
return {};
const g = En(d), h = {
x: n,
y: r
}, a = Nt(o), p = Ft(a), m = await s.getDimensions(u), y = a === "y", R = y ? "top" : "left", b = y ? "bottom" : "right", w = y ? "clientHeight" : "clientWidth", S = i.reference[p] + i.reference[a] - h[a] - i.floating[p], A = h[a] - i.reference[a], I = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(u));
let M = I ? I[w] : 0;
(!M || !await (s.isElement == null ? void 0 : s.isElement(I))) && (M = c.floating[w] || i.floating[p]);
const D = S / 2 - A / 2, j = M / 2 - m[p] / 2 - 1, W = ke(g[R], j), B = ke(g[b], j), $ = W, V = M - m[p] - B, x = M / 2 - m[p] / 2 + D, E = St($, x, V), P = !l.arrow && Ve(o) != null && x !== E && i.reference[p] / 2 - (x < $ ? W : B) - m[p] / 2 < 0, T = P ? x < $ ? x - $ : x - V : 0;
return {
[a]: h[a] + T,
data: {
[a]: E,
centerOffset: x - E - T,
...P && {
alignmentOffset: T
}
},
reset: P
};
}
}), qr = function(e) {
return e === void 0 && (e = {}), {
name: "flip",
options: e,
async fn(t) {
var n, r;
const {
placement: o,
middlewareData: i,
rects: s,
initialPlacement: c,
platform: l,
elements: u
} = t, {
mainAxis: d = !0,
crossAxis: g = !0,
fallbackPlacements: h,
fallbackStrategy: a = "bestFit",
fallbackAxisSideDirection: p = "none",
flipAlignment: m = !0,
...y
} = $e(e, t);
if ((n = i.arrow) != null && n.alignmentOffset)
return {};
const R = Ce(o), b = ye(c), w = Ce(c) === c, S = await (l.isRTL == null ? void 0 : l.isRTL(u.floating)), A = h || (w || !m ? [Ge(c)] : lr(c)), I = p !== "none";
!h && I && A.push(...dr(c, m, p, S));
const M = [c, ...A], D = await Bn(t, y), j = [];
let W = ((r = i.flip) == null ? void 0 : r.overflows) || [];
if (d && j.push(D[R]), g) {
const x = cr(o, s, S);
j.push(D[x[0]], D[x[1]]);
}
if (W = [...W, {
placement: o,
overflows: j
}], !j.every((x) => x <= 0)) {
var B, $;
const x = (((B = i.flip) == null ? void 0 : B.index) || 0) + 1, E = M[x];
if (E && (!(g === "alignment" ? b !== ye(E) : !1) || // We leave the current main axis only if every placement on that axis
// overflows the main axis.
W.every((v) => ye(v.placement) === b ? v.overflows[0] > 0 : !0)))
return {
data: {
index: x,
overflows: W
},
reset: {
placement: E
}
};
let P = ($ = W.filter((T) => T.overflows[0] <= 0).sort((T, v) => T.overflows[1] - v.overflows[1])[0]) == null ? void 0 : $.placement;
if (!P)
switch (a) {
case "bestFit": {
var V;
const T = (V = W.filter((v) => {
if (I) {
const C = ye(v.placement);
return C === b || // Create a bias to the `y` side axis due to horizontal
// reading directions favoring greater width.
C === "y";
}
return !0;
}).map((v) => [v.placement, v.overflows.filter((C) => C > 0).reduce((C, L) => C + L, 0)]).sort((v, C) => v[1] - C[1])[0]) == null ? void 0 : V[0];
T && (P = T);
break;
}
case "initialPlacement":
P = c;
break;
}
if (o !== P)
return {
reset: {
placement: P
}
};
}
return {};
}
};
}, Xr = /* @__PURE__ */ new Set(["left", "top"]);
async function Ur(e, t) {
const {
placement: n,
platform: r,
elements: o
} = e, i = await (r.isRTL == null ? void 0 : r.isRTL(o.floating)), s = Ce(n), c = Ve(n), l = ye(n) === "y", u = Xr.has(s) ? -1 : 1, d = i && l ? -1 : 1, g = $e(t, e);
let {
mainAxis: h,
crossAxis: a,
alignmentAxis: p
} = typeof g == "number" ? {
mainAxis: g,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: g.mainAxis || 0,
crossAxis: g.crossAxis || 0,
alignmentAxis: g.alignmentAxis
};
return c && typeof p == "number" && (a = c === "end" ? p * -1 : p), l ? {
x: a * d,
y: h * u
} : {
x: h * u,
y: a * d
};
}
const Yr = function(e) {
return e === void 0 && (e = 0), {
name: "offset",
options: e,
async fn(t) {
var n, r;
const {
x: o,
y: i,
placement: s,
middlewareData: c
} = t, l = await Ur(t, e);
return s === ((n = c.offset) == null ? void 0 : n.placement) && (r = c.arrow) != null && r.alignmentOffset ? {} : {
x: o + l.x,
y: i + l.y,
data: {
...l,
placement: s
}
};
}
};
}, zr = function(e) {
return e === void 0 && (e = {}), {
name: "shift",
options: e,
async fn(t) {
const {
x: n,
y: r,
placement: o
} = t, {
mainAxis: i = !0,
crossAxis: s = !1,
limiter: c = {
fn: (y) => {
let {
x: R,
y: b
} = y;
return {
x: R,
y: b
};
}
},
...l
} = $e(e, t), u = {
x: n,
y: r
}, d = await Bn(t, l), g = ye(Ce(o)), h = xn(g);
let a = u[h], p = u[g];
if (i) {
const y = h === "y" ? "top" : "left", R = h === "y" ? "bottom" : "right", b = a + d[y], w = a - d[R];
a = St(b, a, w);
}
if (s) {
const y = g === "y" ? "top" : "left", R = g === "y" ? "bottom" : "right", b = p + d[y], w = p - d[R];
p = St(b, p, w);
}
const m = c.fn({
...t,
[h]: a,
[g]: p
});
return {
...m,
data: {
x: m.x - n,
y: m.y - r,
enabled: {
[h]: i,
[g]: s
}
}
};
}
};
};
function Wn(e) {
const t = oe(e);
let n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0;
const o = U(e), i = o ? e.offsetWidth : n, s = o ? e.offsetHeight : r, c = ze(n) !== i || ze(r) !== s;
return c && (n = i, r = s), {
width: n,
height: r,
$: c
};
}
function $t(e) {
return K(e) ? e : e.contextElement;
}
function Le(e) {
const t = $t(e);
if (!U(t))
return le(1);
const n = t.getBoundingClientRect(), {
width: r,
height: o,
$: i
} = Wn(t);
let s = (i ? ze(n.width) : n.width) / r, c = (i ? ze(n.height) : n.height) / o;
return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), {
x: s,
y: c
};
}
const Gr = /* @__PURE__ */ le(0);
function $n(e) {
const t = ee(e);
return !it() || !t.visualViewport ? Gr : {
x: t.visualViewport.offsetLeft,
y: t.visualViewport.offsetTop
};
}
function Zr(e, t, n) {
return t === void 0 && (t = !1), !n || t && n !== ee(e) ? !1 : t;
}
function Ae(e, t, n, r) {
t === void 0 && (t = !1), n === void 0 && (n = !1);
const o = e.getBoundingClientRect(), i = $t(e);
let s = le(1);
t && (r ? K(r) && (s = Le(r)) : s = Le(e));
const c = Zr(i, n, r) ? $n(i) : le(0);
let l = (o.left + c.x) / s.x, u = (o.top + c.y) / s.y, d = o.width / s.x, g = o.height / s.y;
if (i) {
const h = ee(i), a = r && K(r) ? ee(r) : r;
let p = h, m = Tt(p);
for (; m && r && a !== p; ) {
const y = Le(m), R = m.getBoundingClientRect(), b = oe(m), w = R.left + (m.clientLeft + parseFloat(b.paddingLeft)) * y.x, S = R.top + (m.clientTop + parseFloat(b.paddingTop)) * y.y;
l *= y.x, u *= y.y, d *= y.x, g *= y.y, l += w, u += S, p = ee(m), m = Tt(p);
}
}
return Ze({
width: d,
height: g,
x: l,
y: u
});
}
function lt(e, t) {
const n = st(e).scrollLeft;
return t ? t.left + n : Ae(ue(e)).left + n;
}
function Vn(e, t) {
const n = e.getBoundingClientRect(), r = n.left + t.scrollLeft - lt(e, n), o = n.top + t.scrollTop;
return {
x: r,
y: o
};
}
function Jr(e) {
let {
elements: t,
rect: n,
offsetParent: r,
strategy: o
} = e;
const i = o === "fixed", s = ue(r), c = t ? ot(t.floating) : !1;
if (r === s || c && i)
return n;
let l = {
scrollLeft: 0,
scrollTop: 0
}, u = le(1);
const d = le(0), g = U(r);
if ((g || !g && !i) && ((xe(r) !== "body" || We(s)) && (l = st(r)), U(r))) {
const a = Ae(r);
u = Le(r), d.x = a.x + r.clientLeft, d.y = a.y + r.clientTop;
}
const h = s && !g && !i ? Vn(s, l) : le(0);
return {
width: n.width * u.x,
height: n.height * u.y,
x: n.x * u.x - l.scrollLeft * u.x + d.x + h.x,
y: n.y * u.y - l.scrollTop * u.y + d.y + h.y
};
}
function Qr(e) {
return Array.from(e.getClientRects());
}
function eo(e) {
const t = ue(e), n = st(e), r = e.ownerDocument.body, o = Se(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), i = Se(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight);
let s = -n.scrollLeft + lt(e);
const c = -n.scrollTop;
return oe(r).direction === "rtl" && (s += Se(t.clientWidth, r.clientWidth) - o), {
width: o,
height: i,
x: s,
y: c
};
}
const Zt = 25;
function to(e, t) {
const n = ee(e), r = ue(e), o = n.visualViewport;
let i = r.clientWidth, s = r.clientHeight, c = 0, l = 0;
if (o) {
i = o.width, s = o.height;
const d = it();
(!d || d && t === "fixed") && (c = o.offsetLeft, l = o.offsetTop);
}
const u = lt(r);
if (u <= 0) {
const d = r.ownerDocument, g = d.body, h = getComputedStyle(g), a = d.compatMode === "CSS1Compat" && parseFloat(h.marginLeft) + parseFloat(h.marginRight) || 0, p = Math.abs(r.clientWidth - g.clientWidth - a);
p <= Zt && (i -= p);
} else u <= Zt && (i += u);
return {
width: i,
height: s,
x: c,
y: l
};
}
const no = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function ro(e, t) {
const n = Ae(e, !0, t === "fixed"), r = n.top + e.clientTop, o = n.left + e.clientLeft, i = U(e) ? Le(e) : le(1), s = e.clientWidth * i.x, c = e.clientHeight * i.y, l = o * i.x, u = r * i.y;
return {
width: s,
height: c,
x: l,
y: u
};
}
function Jt(e, t, n) {
let r;
if (t === "viewport")
r = to(e, n);
else if (t === "document")
r = eo(ue(e));
else if (K(t))
r = ro(t, n);
else {
const o = $n(e);
r = {
x: t.x - o.x,
y: t.y - o.y,
width: t.width,
height: t.height
};
}
return Ze(r);
}
function _n(e, t) {
const n = ge(e);
return n === t || !K(n) || me(n) ? !1 : oe(n).position === "fixed" || _n(n, t);
}
function oo(e, t) {
const n = t.get(e);
if (n)
return n;
let r = Re(e, [], !1).filter((c) => K(c) && xe(c) !== "body"), o = null;
const i = oe(e).position === "fixed";
let s = i ? ge(e) : e;
for (; K(s) && !me(s); ) {
const c = oe(s), l = Dt(s);
!l && c.position === "fixed" && (o = null), (i ? !l && !o : !l && c.position === "static" && !!o && no.has(o.position) || We(s) && !l && _n(e, s)) ? r = r.filter((d) => d !== s) : o = c, s = ge(s);
}
return t.set(e, r), r;
}
function io(e) {
let {
element: t,
boundary: n,
rootBoundary: r,
strategy: o
} = e;
const s = [...n === "clippingAncestors" ? ot(t) ? [] : oo(t, this._c) : [].concat(n), r], c = s[0], l = s.reduce((u, d) => {
const g = Jt(t, d, o);
return u.top = Se(g.top, u.top), u.right = ke(g.right, u.right), u.bottom = ke(g.bottom, u.bottom), u.left = Se(g.left, u.left), u;
}, Jt(t, c, o));
return {
width: l.right - l.left,
height: l.bottom - l.top,
x: l.left,
y: l.top
};
}
function so(e) {
const {
width: t,
height: n
} = Wn(e);
return {
width: t,
height: n
};
}
function co(e, t, n) {
const r = U(t), o = ue(t), i = n === "fixed", s = Ae(e, !0, i, t);
let c = {
scrollLeft: 0,
scrollTop: 0
};
const l = le(0);
function u() {
l.x = lt(o);
}
if (r || !r && !i)
if ((xe(t) !== "body" || We(o)) && (c = st(t)), r) {
const a = Ae(t, !0, i, t);
l.x = a.x + t.clientLeft, l.y = a.y + t.clientTop;
} else o && u();
i && !r && o && u();
const d = o && !r && !i ? Vn(o, c) : le(0), g = s.left + c.scrollLeft - l.x - d.x, h = s.top + c.scrollTop - l.y - d.y;
return {
x: g,
y: h,
width: s.width,
height: s.height
};
}
function vt(e) {
return oe(e).position === "static";
}
function Qt(e, t) {
if (!U(e) || oe(e).position === "fixed")
return null;
if (t)
return t(e);
let n = e.offsetParent;
return ue(e) === n && (n = n.ownerDocument.body), n;
}
function Hn(e, t) {
const n = ee(e);
if (ot(e))
return n;
if (!U(e)) {
let o = ge(e);
for (; o && !me(o); ) {
if (K(o) && !vt(o))
return o;
o = ge(o);
}
return n;
}
let r = Qt(e, t);
for (; r && Zn(r) && vt(r); )
r = Qt(r, t);
return r && me(r) && vt(r) && !Dt(r) ? n : r || nr(e) || n;
}
const lo = async function(e) {
const t = this.getOffsetParent || Hn, n = this.getDimensions, r = await n(e.floating);
return {
reference: co(e.reference, await t(e.floating), e.strategy),
floating: {
x: 0,
y: 0,
width: r.width,
height: r.height
}
};
};
function uo(e) {
return oe(e).direction === "rtl";
}
const ao = {
convertOffsetParentRelativeRectToViewportRelativeRect: Jr,
getDocumentElement: ue,
getClippingRect: io,
getOffsetParent: Hn,
getElementRects: lo,
getClientRects: Qr,
getDimensions: so,
getScale: Le,
isElement: K,
isRTL: uo
};
function Kn(e, t) {
return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function fo(e, t) {
let n = null, r;
const o = ue(e);
function i() {
var c;
clearTimeout(r), (c = n) == null || c.disconnect(), n = null;
}
function s(c, l) {
c === void 0 && (c = !1), l === void 0 && (l = 1), i();
const u = e.getBoundingClientRect(), {
left: d,
top: g,
width: h,
height: a
} = u;
if (c || t(), !h || !a)
return;
const p = je(g), m = je(o.clientWidth - (d + h)), y = je(o.clientHeight - (g + a)), R = je(d), w = {
rootMargin: -p + "px " + -m + "px " + -y + "px " + -R + "px",
threshold: Se(0, ke(1, l)) || 1
};
let S = !0;
function A(I) {
const M = I[0].intersectionRatio;
if (M !== l) {
if (!S)
return s();
M ? s(!1, M) : r = setTimeout(() => {
s(!1, 1e-7);
}, 1e3);
}
M === 1 && !Kn(u, e.getBoundingClientRect()) && s(), S = !1;
}
try {
n = new IntersectionObserver(A, {
...w,
// Handle <iframe>s
root: o.ownerDocument
});
} catch {
n = new IntersectionObserver(A, w);
}
n.observe(e);
}
return s(!0), i;
}
function zo(e, t, n, r) {
r === void 0 && (r = {});
const {
ancestorScroll: o = !0,
ancestorResize: i = !0,
elementResize: s = typeof ResizeObserver == "function",
layoutShift: c = typeof IntersectionObserver == "function",
animationFrame: l = !1
} = r, u = $t(e), d = o || i ? [...u ? Re(u) : [], ...Re(t)] : [];
d.forEach((R) => {
o && R.addEventListener("scroll", n, {
passive: !0
}), i && R.addEventListener("resize", n);
});
const g = u && c ? fo(u, n) : null;
let h = -1, a = null;
s && (a = new ResizeObserver((R) => {
let [b] = R;
b && b.target === u && a && (a.unobserve(t), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
var w;
(w = a) == null || w.observe(t);
})), n();
}), u && !l && a.observe(u), a.observe(t));
let p, m = l ? Ae(e) : null;
l && y();
function y() {
const R = Ae(e);
m && !Kn(m, R) && n(), m = R, p = requestAnimationFrame(y);
}
return n(), () => {
var R;
d.forEach((b) => {
o && b.removeEventListener("scroll", n), i && b.removeEventListener("resize", n);
}), g?.(), (R = a) == null || R.disconnect(), a = null, l && cancelAnimationFrame(p);
};
}
const mo = Yr, go = zr, po = qr, en = jr, vo = (e, t, n) => {
const r = /* @__PURE__ */ new Map(), o = {
platform: ao,
...n
}, i = {
...o.platform,
_c: r
};
return Kr(e, t, {
...o,
platform: i
});
};
var ho = typeof document < "u", bo = function() {
}, Ye = ho ? wn : bo;
function tt(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 (!tt(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 i = o[r];
if (!(i === "_owner" && e.$$typeof) && !tt(e[i], t[i]))
return !1;
}
return !0;
}
return e !== e && t !== t;
}
function jn(e) {
return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function tn(e, t) {
const n = jn(e);
return Math.round(t * n) / n;
}
function ht(e) {
const t = f.useRef(e);
return Ye(() => {
t.current = e;
}), t;
}
function yo(e) {
e === void 0 && (e = {});
const {
placement: t = "bottom",
strategy: n = "absolute",
middleware: r = [],
platform: o,
elements: {
reference: i,
floating: s
} = {},
transform: c = !0,
whileElementsMounted: l,
open: u
} = e, [d, g] = f.useState({
x: 0,
y: 0,
strategy: n,
placement: t,
middlewareData: {},
isPositioned: !1
}), [h, a] = f.useState(r);
tt(h, r) || a(r);
const [p, m] = f.useState(null), [y, R] = f.useState(null), b = f.useCallback((v) => {
v !== I.current && (I.current = v, m(v));
}, []), w = f.useCallback((v) => {
v !== M.current && (M.current = v, R(v));
}, []), S = i || p, A = s || y, I = f.useRef(null), M = f.useRef(null), D = f.useRef(d), j = l != null, W = ht(l), B = ht(o), $ = ht(u), V = f.useCallback(() => {
if (!I.current || !M.current)
return;
const v = {
placement: t,
strategy: n,
middleware: h
};
B.current && (v.platform = B.current), vo(I.current, M.current, v).then((C) => {
const L = {
...C,
// 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: $.current !== !1
};
x.current && !tt(D.current, L) && (D.current = L, It.flushSync(() => {
g(L);
}));
});
}, [h, t, n, B, $]);
Ye(() => {
u === !1 && D.current.isPositioned && (D.current.isPositioned = !1, g((v) => ({
...v,
isPositioned: !1
})));
}, [u]);
const x = f.useRef(!1);
Ye(() => (x.current = !0, () => {
x.current = !1;
}), []), Ye(() => {
if (S && (I.current = S), A && (M.current = A), S && A) {
if (W.current)
return W.current(S, A, V);
V();
}
}, [S, A, V, W, j]);
const E = f.useMemo(() => ({
reference: I,
floating: M,
setReference: b,
setFloating: w
}), [b, w]), P = f.useMemo(() => ({
reference: S,
floating: A
}), [S, A]), T = f.useMemo(() => {
const v = {
position: n,
left: 0,
top: 0
};
if (!P.floating)
return v;
const C = tn(P.floating, d.x), L = tn(P.floating, d.y);
return c ? {
...v,
transform: "translate(" + C + "px, " + L + "px)",
...jn(P.floating) >= 1.5 && {
willChange: "transform"
}
} : {
position: n,
left: C,
top: L
};
}, [n, c, P.floating, d.x, d.y]);
return f.useMemo(() => ({
...d,
update: V,
refs: E,
elements: P,
floatingStyles: T
}), [d, V, E, P, T]);
}
const wo = (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 ? en({
element: r.current,
padding: o
}).fn(n) : {} : r ? en({
element: r,
padding: o
}).fn(n) : {};
}
};
}, Go = (e, t) => ({
...mo(e),
options: [e, t]
}), Zo = (e, t) => ({
...go(e),
options: [e, t]
}), Jo = (e, t) => ({
...po(e),
options: [e, t]
}), Qo = (e, t) => ({
...wo(e),
options: [e, t]
});
function ei(e) {
const t = f.useRef(void 0), n = f.useCallback((r) => {
const o = e.map((i) => {
if (i != null) {
if (typeof i == "function") {
const s = i, c = s(r);
return typeof c == "function" ? c : () => {
s(null);
};
}
return i.current = r, () => {
i.current = null;
};
}
});
return () => {
o.forEach((i) => i?.());
};
}, e);
return f.useMemo(() => e.every((r) => r == null) ? null : (r) => {
t.current && (t.current(), t.current = void 0), r != null && (t.current = n(r));
}, e);
}
const Ro = "data-floating-ui-focusable", nn = "active", rn = "selected", xo = {
...f
};
let on = !1, Eo = 0;
const sn = () => (
// Ensure the id is unique with multiple independent versions of Floating UI
// on <React 18
"floating-ui-" + Math.random().toString(36).slice(2, 6) + Eo++
);
function To() {
const [e, t] = f.useState(() => on ? sn() : void 0);
return G(() => {
e == null && t(sn());
}, []), f.useEffect(() => {
on = !0;
}, []), e;
}
const So = xo.useId, ut = So || To;
let Be;
process.env.NODE_ENV !== "production" && (Be = /* @__PURE__ */ new Set());
function Co() {
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 = Be) != null && e.has(o))) {
var i;
(i = Be) == null || i.add(o), console.warn(o);
}
}
function Ao() {
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 = Be) != null && e.has(o))) {
var i;
(i = Be) == null || i.add(o), console.error(o);
}
}
const ti = /* @__PURE__ */ f.forwardRef(function(t, n) {
const {
context: {
placement: r,
elements: {
floating: o
},
middlewareData: {
arrow: i,
shift: s
}
},
width: c = 14,
height: l = 7,
tipRadius: u = 0,
strokeWidth: d = 0,
staticOffset: g,
stroke: h,
d: a,
style: {
transform: p,
...m
} = {},
...y
} = t;
process.env.NODE_ENV !== "production" && (n || Co("The `ref` prop is required for `FloatingArrow`."));
const R = ut(), [b, w] = f.useState(!1);
if (G(() => {
if (!o) return;
oe(o).direction === "rtl" && w(!0);
}, [o]), !o)
return null;
const [S, A] = r.split("-"), I = S === "top" || S === "bottom";
let M = g;
(I && s != null && s.x || !I && s != null && s.y) && (M = null);
const D = d * 2, j = D / 2, W = c / 2 * (u / -8 + 1), B = l / 2 * u / 4, $ = !!a, V = M && A === "end" ? "bottom" : "top";
let x = M && A === "end" ? "right" : "left";
M && b && (x = A === "end" ? "left" : "right");
const E = i?.x != null ? M || i.x : "", P = i?.y != null ? M || i.y : "", T = a || "M0,0" + (" H" + c) + (" L" + (c - W) + "," + (l - B)) + (" Q" + c / 2 + "," + l + " " + W + "," + (l - B)) + " Z", v = {
top: $ ? "rotate(180deg)" : "",
left: $ ? "rotate(90deg)" : "rotate(-90deg)",
bottom: $ ? "" : "rotate(180deg)",
right: $ ? "rotate(-90deg)" : "rotate(90deg)"
}[S];
return /* @__PURE__ */ Lt("svg", {
...y,
"aria-hidden": !0,
ref: n,
width: $ ? c : c + D,
height: c,
viewBox: "0 0 " + c + " " + (l > c ? l : c),
style: {
position: "absolute",
pointerEvents: "none",
[x]: E,
[V]: P,
[S]: I || $ ? "100%" : "calc(100% - " + D / 2 + "px)",
transform: [v, p].filter((C) => !!C).join(" "),
...m
},
children: [D > 0 && /* @__PURE__ */ re("path", {
clipPath: "url(#" + R + ")",
fill: "none",
stroke: h,
strokeWidth: D + (a ? 0 : 1),
d: T
}), /* @__PURE__ */ re("path", {
stroke: D && !a ? y.fill : "none",
d: T
}), /* @__PURE__ */ re("clipPath", {
id: R,
children: /* @__PURE__ */ re("rect", {
x: -j,
y: j * ($ ? -1 : 1),
width: c + D,
height: c
})
})]
});
});
function Oo() {
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 Mo = /* @__PURE__ */ f.createContext(null), Po = /* @__PURE__ */ f.createContext(null), Vt = () => {
var e;
return ((e = f.useContext(Mo)) == null ? void 0 : e.id) || null;
}, at = () => f.useContext(Po);
function Oe(e) {
return "data-floating-ui-" + e;
}
function ne(e) {
e.current !== -1 && (clearTimeout(e.current), e.current = -1);
}
const cn = /* @__PURE__ */ Oe("safe-polygon");
function bt(e, t, n) {
if (n && !Ne(n))
return 0;
if (typeof e == "number")
return e;
if (typeof e == "function") {
const r = e();
return typeof r == "number" ? r : r?.[t];
}
return e?.[t];
}
function yt(e) {
return typeof e == "function" ? e() : e;
}
function ni(e, t) {
t === void 0 && (t = {});
const {
open: n,
onOpenChange: r,
dataRef: o,
events: i,
elements: s
} = e, {
enabled: c = !0,
delay: l = 0,
handleClose: u = null,
mouseOnly: d = !1,
restMs: g = 0,
move: h = !0
} = t, a = at(), p = Vt(), m = Te(u), y = Te(l), R = Te(n), b = Te(g), w = f.useRef(), S = f.useRef(-1), A = f.useRef(), I = f.useRef(-1), M = f.useRef(!0), D = f.useRef(!1), j = f.useRef(() => {
}), W = f.useRef(!1), B = Q(() => {
var T;
const v = (T = o.current.openEvent) == null ? void 0 : T.type;
return v?.includes("mouse") && v !== "mousedown";
});
f.useEffect(() => {
if (!c) return;
function T(v) {
let {
open: C
} = v;
C || (ne(S), ne(I), M.current = !0, W.current = !1);
}
return i.on("openchange", T), () => {
i.off("openchange", T);
};
}, [c, i]), f.useEffect(() => {
if (!c || !m.current || !n) return;
function T(C) {
B() && r(!1, C, "hover");
}
const v = J(s.floating).documentElement;
return v.addEventListener("mouseleave", T), () => {
v.removeEventListener("mouseleave", T);
};
}, [s.floating, n, r, c, m, B]);
const $ = f.useCallback(function(T, v, C) {
v === void 0 && (v = !0), C === void 0 && (C = "hover");
const L = bt(y.current, "close", w.current);
L && !A.current ? (ne(S), S.current = window.setTimeout(() => r(!1, T, C), L)) : v && (ne(S), r(!1, T, C));
}, [y, r]), V = Q(() => {
j.current(), A.current = void 0;
}), x = Q(() => {
if (D.current) {
const T = J(s.floating).body;
T.style.pointerEvents = "", T.removeAttribute(cn), D.current = !1;
}
}), E = Q(() => o.curr