@luciodale/react-searchable-dropdown
Version:
A reusable React searchable dropdown component.
1,739 lines • 180 kB
JavaScript
import * as N from "react";
import P, { useLayoutEffect as cr, createElement as ln, useRef as Dt, useCallback as xe, useEffect as Gt, useState as ze, useMemo as Ft } from "react";
import * as ar from "react-dom";
import Bi from "react-dom";
var ur = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Kn(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var Wn = { exports: {} }, Lt = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var yo;
function Wi() {
if (yo) return Lt;
yo = 1;
var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
function n(o, r, i) {
var s = null;
if (i !== void 0 && (s = "" + i), r.key !== void 0 && (s = "" + r.key), "key" in r) {
i = {};
for (var l in r)
l !== "key" && (i[l] = r[l]);
} else i = r;
return r = i.ref, {
$$typeof: e,
type: o,
key: s,
ref: r !== void 0 ? r : null,
props: i
};
}
return Lt.Fragment = t, Lt.jsx = n, Lt.jsxs = n, Lt;
}
var zt = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Co;
function _i() {
return Co || (Co = 1, process.env.NODE_ENV !== "production" && function() {
function e(S) {
if (S == null) return null;
if (typeof S == "function")
return S.$$typeof === H ? null : S.displayName || S.name || null;
if (typeof S == "string") return S;
switch (S) {
case w:
return "Fragment";
case m:
return "Profiler";
case p:
return "StrictMode";
case T:
return "Suspense";
case x:
return "SuspenseList";
case M:
return "Activity";
}
if (typeof S == "object")
switch (typeof S.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), S.$$typeof) {
case v:
return "Portal";
case b:
return (S.displayName || "Context") + ".Provider";
case h:
return (S._context.displayName || "Context") + ".Consumer";
case C:
var F = S.render;
return S = S.displayName, S || (S = F.displayName || F.name || "", S = S !== "" ? "ForwardRef(" + S + ")" : "ForwardRef"), S;
case y:
return F = S.displayName || null, F !== null ? F : e(S.type) || "Memo";
case I:
F = S._payload, S = S._init;
try {
return e(S(F));
} catch {
}
}
return null;
}
function t(S) {
return "" + S;
}
function n(S) {
try {
t(S);
var F = !1;
} catch {
F = !0;
}
if (F) {
F = console;
var Z = F.error, Q = typeof Symbol == "function" && Symbol.toStringTag && S[Symbol.toStringTag] || S.constructor.name || "Object";
return Z.call(
F,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
Q
), t(S);
}
}
function o(S) {
if (S === w) return "<>";
if (typeof S == "object" && S !== null && S.$$typeof === I)
return "<...>";
try {
var F = e(S);
return F ? "<" + F + ">" : "<...>";
} catch {
return "<...>";
}
}
function r() {
var S = z.A;
return S === null ? null : S.getOwner();
}
function i() {
return Error("react-stack-top-frame");
}
function s(S) {
if (B.call(S, "key")) {
var F = Object.getOwnPropertyDescriptor(S, "key").get;
if (F && F.isReactWarning) return !1;
}
return S.key !== void 0;
}
function l(S, F) {
function Z() {
$ || ($ = !0, console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
F
));
}
Z.isReactWarning = !0, Object.defineProperty(S, "key", {
get: Z,
configurable: !0
});
}
function c() {
var S = e(this.type);
return X[S] || (X[S] = !0, console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
)), S = this.props.ref, S !== void 0 ? S : null;
}
function a(S, F, Z, Q, ue, ne, me, ge) {
return Z = ne.ref, S = {
$$typeof: d,
type: S,
key: F,
props: ne,
_owner: ue
}, (Z !== void 0 ? Z : null) !== null ? Object.defineProperty(S, "ref", {
enumerable: !1,
get: c
}) : Object.defineProperty(S, "ref", { enumerable: !1, value: null }), S._store = {}, Object.defineProperty(S._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(S, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.defineProperty(S, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: me
}), Object.defineProperty(S, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: ge
}), Object.freeze && (Object.freeze(S.props), Object.freeze(S)), S;
}
function u(S, F, Z, Q, ue, ne, me, ge) {
var R = F.children;
if (R !== void 0)
if (Q)
if (W(R)) {
for (Q = 0; Q < R.length; Q++)
f(R[Q]);
Object.freeze && Object.freeze(R);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else f(R);
if (B.call(F, "key")) {
R = e(S);
var D = Object.keys(F).filter(function(le) {
return le !== "key";
});
Q = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", te[R + Q] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,
Q,
R,
D,
R
), te[R + Q] = !0);
}
if (R = null, Z !== void 0 && (n(Z), R = "" + Z), s(F) && (n(F.key), R = "" + F.key), "key" in F) {
Z = {};
for (var Y in F)
Y !== "key" && (Z[Y] = F[Y]);
} else Z = F;
return R && l(
Z,
typeof S == "function" ? S.displayName || S.name || "Unknown" : S
), a(
S,
R,
ne,
ue,
r(),
Z,
me,
ge
);
}
function f(S) {
typeof S == "object" && S !== null && S.$$typeof === d && S._store && (S._store.validated = 1);
}
var g = P, d = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), w = Symbol.for("react.fragment"), p = Symbol.for("react.strict_mode"), m = Symbol.for("react.profiler"), h = Symbol.for("react.consumer"), b = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), x = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), H = Symbol.for("react.client.reference"), z = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, W = Array.isArray, O = console.createTask ? console.createTask : function() {
return null;
};
g = {
react_stack_bottom_frame: function(S) {
return S();
}
};
var $, X = {}, K = g.react_stack_bottom_frame.bind(
g,
i
)(), _ = O(o(i)), te = {};
zt.Fragment = w, zt.jsx = function(S, F, Z, Q, ue) {
var ne = 1e4 > z.recentlyCreatedOwnerStacks++;
return u(
S,
F,
Z,
!1,
Q,
ue,
ne ? Error("react-stack-top-frame") : K,
ne ? O(o(S)) : _
);
}, zt.jsxs = function(S, F, Z, Q, ue) {
var ne = 1e4 > z.recentlyCreatedOwnerStacks++;
return u(
S,
F,
Z,
!0,
Q,
ue,
ne ? Error("react-stack-top-frame") : K,
ne ? O(o(S)) : _
);
};
}()), zt;
}
process.env.NODE_ENV === "production" ? Wn.exports = Wi() : Wn.exports = _i();
var k = Wn.exports;
function Sn() {
return typeof window < "u";
}
function kt(e) {
return eo(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function je(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function Ke(e) {
var t;
return (t = (eo(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function eo(e) {
return Sn() ? e instanceof Node || e instanceof je(e).Node : !1;
}
function ye(e) {
return Sn() ? e instanceof Element || e instanceof je(e).Element : !1;
}
function Je(e) {
return Sn() ? e instanceof HTMLElement || e instanceof je(e).HTMLElement : !1;
}
function _n(e) {
return !Sn() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof je(e).ShadowRoot;
}
const Vi = /* @__PURE__ */ new Set(["inline", "contents"]);
function qt(e) {
const {
overflow: t,
overflowX: n,
overflowY: o,
display: r
} = Ue(e);
return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !Vi.has(r);
}
const Ui = /* @__PURE__ */ new Set(["table", "td", "th"]);
function $i(e) {
return Ui.has(kt(e));
}
const Yi = [":popover-open", ":modal"];
function yn(e) {
return Yi.some((t) => {
try {
return e.matches(t);
} catch {
return !1;
}
});
}
const Gi = ["transform", "translate", "scale", "rotate", "perspective"], qi = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Xi = ["paint", "layout", "strict", "content"];
function to(e) {
const t = no(), n = ye(e) ? Ue(e) : e;
return Gi.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || qi.some((o) => (n.willChange || "").includes(o)) || Xi.some((o) => (n.contain || "").includes(o));
}
function Qi(e) {
let t = st(e);
for (; Je(t) && !Rt(t); ) {
if (to(t))
return t;
if (yn(t))
return null;
t = st(t);
}
return null;
}
function no() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const Ji = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function Rt(e) {
return Ji.has(kt(e));
}
function Ue(e) {
return je(e).getComputedStyle(e);
}
function Cn(e) {
return ye(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function st(e) {
if (kt(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.
_n(e) && e.host || // Fallback.
Ke(e)
);
return _n(t) ? t.host : t;
}
function fr(e) {
const t = st(e);
return Rt(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Je(t) && qt(t) ? t : fr(t);
}
function Bt(e, t, n) {
var o;
t === void 0 && (t = []), n === void 0 && (n = !0);
const r = fr(e), i = r === ((o = e.ownerDocument) == null ? void 0 : o.body), s = je(r);
if (i) {
const l = Vn(s);
return t.concat(s, s.visualViewport || [], qt(r) ? r : [], l && n ? Bt(l) : []);
}
return t.concat(r, Bt(r, [], n));
}
function Vn(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
const It = Math.min, Pe = Math.max, fn = Math.round, on = Math.floor, Qe = (e) => ({
x: e,
y: e
}), Zi = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, Ki = {
start: "end",
end: "start"
};
function Ro(e, t, n) {
return Pe(e, It(t, n));
}
function Xt(e, t) {
return typeof e == "function" ? e(t) : e;
}
function lt(e) {
return e.split("-")[0];
}
function Qt(e) {
return e.split("-")[1];
}
function dr(e) {
return e === "x" ? "y" : "x";
}
function hr(e) {
return e === "y" ? "height" : "width";
}
const es = /* @__PURE__ */ new Set(["top", "bottom"]);
function rt(e) {
return es.has(lt(e)) ? "y" : "x";
}
function mr(e) {
return dr(rt(e));
}
function ts(e, t, n) {
n === void 0 && (n = !1);
const o = Qt(e), r = mr(e), i = hr(r);
let s = r === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
return t.reference[i] > t.floating[i] && (s = dn(s)), [s, dn(s)];
}
function ns(e) {
const t = dn(e);
return [Un(e), t, Un(t)];
}
function Un(e) {
return e.replace(/start|end/g, (t) => Ki[t]);
}
const Io = ["left", "right"], Eo = ["right", "left"], os = ["top", "bottom"], rs = ["bottom", "top"];
function is(e, t, n) {
switch (e) {
case "top":
case "bottom":
return n ? t ? Eo : Io : t ? Io : Eo;
case "left":
case "right":
return t ? os : rs;
default:
return [];
}
}
function ss(e, t, n, o) {
const r = Qt(e);
let i = is(lt(e), n === "start", o);
return r && (i = i.map((s) => s + "-" + r), t && (i = i.concat(i.map(Un)))), i;
}
function dn(e) {
return e.replace(/left|right|bottom|top/g, (t) => Zi[t]);
}
function ls(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function cs(e) {
return typeof e != "number" ? ls(e) : {
top: e,
right: e,
bottom: e,
left: e
};
}
function hn(e) {
const {
x: t,
y: n,
width: o,
height: r
} = e;
return {
width: o,
height: r,
top: n,
left: t,
right: t + o,
bottom: n + r,
x: t,
y: n
};
}
/*!
* tabbable 6.2.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var as = ["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])"], $n = /* @__PURE__ */ as.join(","), gr = typeof Element > "u", Wt = gr ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, mn = !gr && 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;
}, gn = function e(t, n) {
var o;
n === void 0 && (n = !0);
var r = t == null || (o = t.getAttribute) === null || o === void 0 ? void 0 : o.call(t, "inert"), i = r === "" || r === "true", s = i || n && t && e(t.parentNode);
return s;
}, us = function(t) {
var n, o = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
return o === "" || o === "true";
}, fs = function(t, n, o) {
if (gn(t))
return [];
var r = Array.prototype.slice.apply(t.querySelectorAll($n));
return n && Wt.call(t, $n) && r.unshift(t), r = r.filter(o), r;
}, ds = function e(t, n, o) {
for (var r = [], i = Array.from(t); i.length; ) {
var s = i.shift();
if (!gn(s, !1))
if (s.tagName === "SLOT") {
var l = s.assignedElements(), c = l.length ? l : s.children, a = e(c, !0, o);
o.flatten ? r.push.apply(r, a) : r.push({
scopeParent: s,
candidates: a
});
} else {
var u = Wt.call(s, $n);
u && o.filter(s) && (n || !t.includes(s)) && r.push(s);
var f = s.shadowRoot || // check for an undisclosed shadow
typeof o.getShadowRoot == "function" && o.getShadowRoot(s), g = !gn(f, !1) && (!o.shadowRootFilter || o.shadowRootFilter(s));
if (f && g) {
var d = e(f === !0 ? s.children : f.children, !0, o);
o.flatten ? r.push.apply(r, d) : r.push({
scopeParent: s,
candidates: d
});
} else
i.unshift.apply(i, s.children);
}
}
return r;
}, pr = function(t) {
return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, vr = function(t) {
if (!t)
throw new Error("No node provided");
return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || us(t)) && !pr(t) ? 0 : t.tabIndex;
}, hs = function(t, n) {
var o = vr(t);
return o < 0 && n && !pr(t) ? 0 : o;
}, ms = function(t, n) {
return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
}, xr = function(t) {
return t.tagName === "INPUT";
}, gs = function(t) {
return xr(t) && t.type === "hidden";
}, ps = function(t) {
var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(o) {
return o.tagName === "SUMMARY";
});
return n;
}, vs = function(t, n) {
for (var o = 0; o < t.length; o++)
if (t[o].checked && t[o].form === n)
return t[o];
}, xs = function(t) {
if (!t.name)
return !0;
var n = t.form || mn(t), o = function(l) {
return n.querySelectorAll('input[type="radio"][name="' + l + '"]');
}, r;
if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
r = o(window.CSS.escape(t.name));
else
try {
r = o(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 = vs(r, t.form);
return !i || i === t;
}, ws = function(t) {
return xr(t) && t.type === "radio";
}, bs = function(t) {
return ws(t) && !xs(t);
}, Ts = function(t) {
var n, o = t && mn(t), r = (n = o) === null || n === void 0 ? void 0 : n.host, i = !1;
if (o && o !== t) {
var s, l, c;
for (i = !!((s = r) !== null && s !== void 0 && (l = s.ownerDocument) !== null && l !== void 0 && l.contains(r) || t != null && (c = t.ownerDocument) !== null && c !== void 0 && c.contains(t)); !i && r; ) {
var a, u, f;
o = mn(r), r = (a = o) === null || a === void 0 ? void 0 : a.host, i = !!((u = r) !== null && u !== void 0 && (f = u.ownerDocument) !== null && f !== void 0 && f.contains(r));
}
}
return i;
}, Ao = function(t) {
var n = t.getBoundingClientRect(), o = n.width, r = n.height;
return o === 0 && r === 0;
}, Ss = function(t, n) {
var o = n.displayCheck, r = n.getShadowRoot;
if (getComputedStyle(t).visibility === "hidden")
return !0;
var i = Wt.call(t, "details>summary:first-of-type"), s = i ? t.parentElement : t;
if (Wt.call(s, "details:not([open]) *"))
return !0;
if (!o || o === "full" || o === "legacy-full") {
if (typeof r == "function") {
for (var l = t; t; ) {
var c = t.parentElement, a = mn(t);
if (c && !c.shadowRoot && r(c) === !0)
return Ao(t);
t.assignedSlot ? t = t.assignedSlot : !c && a !== t.ownerDocument ? t = a.host : t = c;
}
t = l;
}
if (Ts(t))
return !t.getClientRects().length;
if (o !== "legacy-full")
return !0;
} else if (o === "non-zero-area")
return Ao(t);
return !1;
}, ys = function(t) {
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
for (var n = t.parentElement; n; ) {
if (n.tagName === "FIELDSET" && n.disabled) {
for (var o = 0; o < n.children.length; o++) {
var r = n.children.item(o);
if (r.tagName === "LEGEND")
return Wt.call(n, "fieldset[disabled] *") ? !0 : !r.contains(t);
}
return !0;
}
n = n.parentElement;
}
return !1;
}, Cs = 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`)
gn(n) || gs(n) || Ss(n, t) || // For a details element with a summary, the summary element gets the focus
ps(n) || ys(n));
}, ko = function(t, n) {
return !(bs(n) || vr(n) < 0 || !Cs(t, n));
}, Rs = function(t) {
var n = parseInt(t.getAttribute("tabindex"), 10);
return !!(isNaN(n) || n >= 0);
}, Is = function e(t) {
var n = [], o = [];
return t.forEach(function(r, i) {
var s = !!r.scopeParent, l = s ? r.scopeParent : r, c = hs(l, s), a = s ? e(r.candidates) : l;
c === 0 ? s ? n.push.apply(n, a) : n.push(l) : o.push({
documentOrder: i,
tabIndex: c,
item: r,
isScope: s,
content: a
});
}), o.sort(ms).reduce(function(r, i) {
return i.isScope ? r.push.apply(r, i.content) : r.push(i.content), r;
}, []).concat(n);
}, wr = function(t, n) {
n = n || {};
var o;
return n.getShadowRoot ? o = ds([t], n.includeContainer, {
filter: ko.bind(null, n),
flatten: !1,
getShadowRoot: n.getShadowRoot,
shadowRootFilter: Rs
}) : o = fs(t, n.includeContainer, ko.bind(null, n)), Is(o);
};
function Es() {
return /apple/i.test(navigator.vendor);
}
function As(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 ks(e, t) {
if (!e || !t)
return !1;
const n = t.getRootNode == null ? void 0 : t.getRootNode();
if (e.contains(t))
return !0;
if (n && _n(n)) {
let o = t;
for (; o; ) {
if (e === o)
return !0;
o = o.parentNode || o.host;
}
}
return !1;
}
function oo(e) {
return (e == null ? void 0 : e.ownerDocument) || document;
}
var Os = typeof document < "u", Hs = function() {
}, xt = Os ? cr : Hs;
const Ms = {
...N
}, Ls = Ms.useInsertionEffect, zs = Ls || ((e) => e());
function Ps(e) {
const t = N.useRef(() => {
if (process.env.NODE_ENV !== "production")
throw new Error("Cannot call an event handler while rendering.");
});
return zs(() => {
t.current = e;
}), N.useCallback(function() {
for (var n = arguments.length, o = new Array(n), r = 0; r < n; r++)
o[r] = arguments[r];
return t.current == null ? void 0 : t.current(...o);
}, []);
}
const br = () => ({
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 Tr(e, t) {
const n = wr(e, br()), o = n.length;
if (o === 0) return;
const r = As(oo(e)), i = n.indexOf(r), s = i === -1 ? t === 1 ? 0 : o - 1 : i + t;
return n[s];
}
function Fs(e) {
return Tr(oo(e).body, 1) || e;
}
function js(e) {
return Tr(oo(e).body, -1) || e;
}
function Ln(e, t) {
const n = t || e.currentTarget, o = e.relatedTarget;
return !o || !ks(n, o);
}
function Ns(e) {
wr(e, br()).forEach((n) => {
n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
});
}
function Oo(e) {
e.querySelectorAll("[data-tabindex]").forEach((n) => {
const o = n.dataset.tabindex;
delete n.dataset.tabindex, o ? n.setAttribute("tabindex", o) : n.removeAttribute("tabindex");
});
}
function Ho(e, t, n) {
let {
reference: o,
floating: r
} = e;
const i = rt(t), s = mr(t), l = hr(s), c = lt(t), a = i === "y", u = o.x + o.width / 2 - r.width / 2, f = o.y + o.height / 2 - r.height / 2, g = o[l] / 2 - r[l] / 2;
let d;
switch (c) {
case "top":
d = {
x: u,
y: o.y - r.height
};
break;
case "bottom":
d = {
x: u,
y: o.y + o.height
};
break;
case "right":
d = {
x: o.x + o.width,
y: f
};
break;
case "left":
d = {
x: o.x - r.width,
y: f
};
break;
default:
d = {
x: o.x,
y: o.y
};
}
switch (Qt(t)) {
case "start":
d[s] -= g * (n && a ? -1 : 1);
break;
case "end":
d[s] += g * (n && a ? -1 : 1);
break;
}
return d;
}
const Ds = async (e, t, n) => {
const {
placement: o = "bottom",
strategy: r = "absolute",
middleware: i = [],
platform: s
} = n, l = i.filter(Boolean), c = await (s.isRTL == null ? void 0 : s.isRTL(t));
let a = await s.getElementRects({
reference: e,
floating: t,
strategy: r
}), {
x: u,
y: f
} = Ho(a, o, c), g = o, d = {}, v = 0;
for (let w = 0; w < l.length; w++) {
const {
name: p,
fn: m
} = l[w], {
x: h,
y: b,
data: C,
reset: T
} = await m({
x: u,
y: f,
initialPlacement: o,
placement: g,
strategy: r,
middlewareData: d,
rects: a,
platform: s,
elements: {
reference: e,
floating: t
}
});
u = h ?? u, f = b ?? f, d = {
...d,
[p]: {
...d[p],
...C
}
}, T && v <= 50 && (v++, typeof T == "object" && (T.placement && (g = T.placement), T.rects && (a = T.rects === !0 ? await s.getElementRects({
reference: e,
floating: t,
strategy: r
}) : T.rects), {
x: u,
y: f
} = Ho(a, g, c)), w = -1);
}
return {
x: u,
y: f,
placement: g,
strategy: r,
middlewareData: d
};
};
async function ro(e, t) {
var n;
t === void 0 && (t = {});
const {
x: o,
y: r,
platform: i,
rects: s,
elements: l,
strategy: c
} = e, {
boundary: a = "clippingAncestors",
rootBoundary: u = "viewport",
elementContext: f = "floating",
altBoundary: g = !1,
padding: d = 0
} = Xt(t, e), v = cs(d), p = l[g ? f === "floating" ? "reference" : "floating" : f], m = hn(await i.getClippingRect({
element: (n = await (i.isElement == null ? void 0 : i.isElement(p))) == null || n ? p : p.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(l.floating)),
boundary: a,
rootBoundary: u,
strategy: c
})), h = f === "floating" ? {
x: o,
y: r,
width: s.floating.width,
height: s.floating.height
} : s.reference, b = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(l.floating)), C = await (i.isElement == null ? void 0 : i.isElement(b)) ? await (i.getScale == null ? void 0 : i.getScale(b)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, T = hn(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: l,
rect: h,
offsetParent: b,
strategy: c
}) : h);
return {
top: (m.top - T.top + v.top) / C.y,
bottom: (T.bottom - m.bottom + v.bottom) / C.y,
left: (m.left - T.left + v.left) / C.x,
right: (T.right - m.right + v.right) / C.x
};
}
const Bs = function(e) {
return e === void 0 && (e = {}), {
name: "flip",
options: e,
async fn(t) {
var n, o;
const {
placement: r,
middlewareData: i,
rects: s,
initialPlacement: l,
platform: c,
elements: a
} = t, {
mainAxis: u = !0,
crossAxis: f = !0,
fallbackPlacements: g,
fallbackStrategy: d = "bestFit",
fallbackAxisSideDirection: v = "none",
flipAlignment: w = !0,
...p
} = Xt(e, t);
if ((n = i.arrow) != null && n.alignmentOffset)
return {};
const m = lt(r), h = rt(l), b = lt(l) === l, C = await (c.isRTL == null ? void 0 : c.isRTL(a.floating)), T = g || (b || !w ? [dn(l)] : ns(l)), x = v !== "none";
!g && x && T.push(...ss(l, w, v, C));
const y = [l, ...T], I = await ro(t, p), M = [];
let H = ((o = i.flip) == null ? void 0 : o.overflows) || [];
if (u && M.push(I[m]), f) {
const O = ts(r, s, C);
M.push(I[O[0]], I[O[1]]);
}
if (H = [...H, {
placement: r,
overflows: M
}], !M.every((O) => O <= 0)) {
var z, B;
const O = (((z = i.flip) == null ? void 0 : z.index) || 0) + 1, $ = y[O];
if ($ && (!(f === "alignment" ? h !== rt($) : !1) || // We leave the current main axis only if every placement on that axis
// overflows the main axis.
H.every((_) => _.overflows[0] > 0 && rt(_.placement) === h)))
return {
data: {
index: O,
overflows: H
},
reset: {
placement: $
}
};
let X = (B = H.filter((K) => K.overflows[0] <= 0).sort((K, _) => K.overflows[1] - _.overflows[1])[0]) == null ? void 0 : B.placement;
if (!X)
switch (d) {
case "bestFit": {
var W;
const K = (W = H.filter((_) => {
if (x) {
const te = rt(_.placement);
return te === h || // Create a bias to the `y` side axis due to horizontal
// reading directions favoring greater width.
te === "y";
}
return !0;
}).map((_) => [_.placement, _.overflows.filter((te) => te > 0).reduce((te, S) => te + S, 0)]).sort((_, te) => _[1] - te[1])[0]) == null ? void 0 : W[0];
K && (X = K);
break;
}
case "initialPlacement":
X = l;
break;
}
if (r !== X)
return {
reset: {
placement: X
}
};
}
return {};
}
};
}, Ws = /* @__PURE__ */ new Set(["left", "top"]);
async function _s(e, t) {
const {
placement: n,
platform: o,
elements: r
} = e, i = await (o.isRTL == null ? void 0 : o.isRTL(r.floating)), s = lt(n), l = Qt(n), c = rt(n) === "y", a = Ws.has(s) ? -1 : 1, u = i && c ? -1 : 1, f = Xt(t, e);
let {
mainAxis: g,
crossAxis: d,
alignmentAxis: v
} = typeof f == "number" ? {
mainAxis: f,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: f.mainAxis || 0,
crossAxis: f.crossAxis || 0,
alignmentAxis: f.alignmentAxis
};
return l && typeof v == "number" && (d = l === "end" ? v * -1 : v), c ? {
x: d * u,
y: g * a
} : {
x: g * a,
y: d * u
};
}
const Vs = function(e) {
return e === void 0 && (e = 0), {
name: "offset",
options: e,
async fn(t) {
var n, o;
const {
x: r,
y: i,
placement: s,
middlewareData: l
} = t, c = await _s(t, e);
return s === ((n = l.offset) == null ? void 0 : n.placement) && (o = l.arrow) != null && o.alignmentOffset ? {} : {
x: r + c.x,
y: i + c.y,
data: {
...c,
placement: s
}
};
}
};
}, Us = function(e) {
return e === void 0 && (e = {}), {
name: "shift",
options: e,
async fn(t) {
const {
x: n,
y: o,
placement: r
} = t, {
mainAxis: i = !0,
crossAxis: s = !1,
limiter: l = {
fn: (p) => {
let {
x: m,
y: h
} = p;
return {
x: m,
y: h
};
}
},
...c
} = Xt(e, t), a = {
x: n,
y: o
}, u = await ro(t, c), f = rt(lt(r)), g = dr(f);
let d = a[g], v = a[f];
if (i) {
const p = g === "y" ? "top" : "left", m = g === "y" ? "bottom" : "right", h = d + u[p], b = d - u[m];
d = Ro(h, d, b);
}
if (s) {
const p = f === "y" ? "top" : "left", m = f === "y" ? "bottom" : "right", h = v + u[p], b = v - u[m];
v = Ro(h, v, b);
}
const w = l.fn({
...t,
[g]: d,
[f]: v
});
return {
...w,
data: {
x: w.x - n,
y: w.y - o,
enabled: {
[g]: i,
[f]: s
}
}
};
}
};
}, $s = function(e) {
return e === void 0 && (e = {}), {
name: "size",
options: e,
async fn(t) {
var n, o;
const {
placement: r,
rects: i,
platform: s,
elements: l
} = t, {
apply: c = () => {
},
...a
} = Xt(e, t), u = await ro(t, a), f = lt(r), g = Qt(r), d = rt(r) === "y", {
width: v,
height: w
} = i.floating;
let p, m;
f === "top" || f === "bottom" ? (p = f, m = g === (await (s.isRTL == null ? void 0 : s.isRTL(l.floating)) ? "start" : "end") ? "left" : "right") : (m = f, p = g === "end" ? "top" : "bottom");
const h = w - u.top - u.bottom, b = v - u.left - u.right, C = It(w - u[p], h), T = It(v - u[m], b), x = !t.middlewareData.shift;
let y = C, I = T;
if ((n = t.middlewareData.shift) != null && n.enabled.x && (I = b), (o = t.middlewareData.shift) != null && o.enabled.y && (y = h), x && !g) {
const H = Pe(u.left, 0), z = Pe(u.right, 0), B = Pe(u.top, 0), W = Pe(u.bottom, 0);
d ? I = v - 2 * (H !== 0 || z !== 0 ? H + z : Pe(u.left, u.right)) : y = w - 2 * (B !== 0 || W !== 0 ? B + W : Pe(u.top, u.bottom));
}
await c({
...t,
availableWidth: I,
availableHeight: y
});
const M = await s.getDimensions(l.floating);
return v !== M.width || w !== M.height ? {
reset: {
rects: !0
}
} : {};
}
};
};
function Sr(e) {
const t = Ue(e);
let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
const r = Je(e), i = r ? e.offsetWidth : n, s = r ? e.offsetHeight : o, l = fn(n) !== i || fn(o) !== s;
return l && (n = i, o = s), {
width: n,
height: o,
$: l
};
}
function io(e) {
return ye(e) ? e : e.contextElement;
}
function yt(e) {
const t = io(e);
if (!Je(t))
return Qe(1);
const n = t.getBoundingClientRect(), {
width: o,
height: r,
$: i
} = Sr(t);
let s = (i ? fn(n.width) : n.width) / o, l = (i ? fn(n.height) : n.height) / r;
return (!s || !Number.isFinite(s)) && (s = 1), (!l || !Number.isFinite(l)) && (l = 1), {
x: s,
y: l
};
}
const Ys = /* @__PURE__ */ Qe(0);
function yr(e) {
const t = je(e);
return !no() || !t.visualViewport ? Ys : {
x: t.visualViewport.offsetLeft,
y: t.visualViewport.offsetTop
};
}
function Gs(e, t, n) {
return t === void 0 && (t = !1), !n || t && n !== je(e) ? !1 : t;
}
function wt(e, t, n, o) {
t === void 0 && (t = !1), n === void 0 && (n = !1);
const r = e.getBoundingClientRect(), i = io(e);
let s = Qe(1);
t && (o ? ye(o) && (s = yt(o)) : s = yt(e));
const l = Gs(i, n, o) ? yr(i) : Qe(0);
let c = (r.left + l.x) / s.x, a = (r.top + l.y) / s.y, u = r.width / s.x, f = r.height / s.y;
if (i) {
const g = je(i), d = o && ye(o) ? je(o) : o;
let v = g, w = Vn(v);
for (; w && o && d !== v; ) {
const p = yt(w), m = w.getBoundingClientRect(), h = Ue(w), b = m.left + (w.clientLeft + parseFloat(h.paddingLeft)) * p.x, C = m.top + (w.clientTop + parseFloat(h.paddingTop)) * p.y;
c *= p.x, a *= p.y, u *= p.x, f *= p.y, c += b, a += C, v = je(w), w = Vn(v);
}
}
return hn({
width: u,
height: f,
x: c,
y: a
});
}
function so(e, t) {
const n = Cn(e).scrollLeft;
return t ? t.left + n : wt(Ke(e)).left + n;
}
function Cr(e, t, n) {
n === void 0 && (n = !1);
const o = e.getBoundingClientRect(), r = o.left + t.scrollLeft - (n ? 0 : (
// RTL <body> scrollbar.
so(e, o)
)), i = o.top + t.scrollTop;
return {
x: r,
y: i
};
}
function qs(e) {
let {
elements: t,
rect: n,
offsetParent: o,
strategy: r
} = e;
const i = r === "fixed", s = Ke(o), l = t ? yn(t.floating) : !1;
if (o === s || l && i)
return n;
let c = {
scrollLeft: 0,
scrollTop: 0
}, a = Qe(1);
const u = Qe(0), f = Je(o);
if ((f || !f && !i) && ((kt(o) !== "body" || qt(s)) && (c = Cn(o)), Je(o))) {
const d = wt(o);
a = yt(o), u.x = d.x + o.clientLeft, u.y = d.y + o.clientTop;
}
const g = s && !f && !i ? Cr(s, c, !0) : Qe(0);
return {
width: n.width * a.x,
height: n.height * a.y,
x: n.x * a.x - c.scrollLeft * a.x + u.x + g.x,
y: n.y * a.y - c.scrollTop * a.y + u.y + g.y
};
}
function Xs(e) {
return Array.from(e.getClientRects());
}
function Qs(e) {
const t = Ke(e), n = Cn(e), o = e.ownerDocument.body, r = Pe(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), i = Pe(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
let s = -n.scrollLeft + so(e);
const l = -n.scrollTop;
return Ue(o).direction === "rtl" && (s += Pe(t.clientWidth, o.clientWidth) - r), {
width: r,
height: i,
x: s,
y: l
};
}
function Js(e, t) {
const n = je(e), o = Ke(e), r = n.visualViewport;
let i = o.clientWidth, s = o.clientHeight, l = 0, c = 0;
if (r) {
i = r.width, s = r.height;
const a = no();
(!a || a && t === "fixed") && (l = r.offsetLeft, c = r.offsetTop);
}
return {
width: i,
height: s,
x: l,
y: c
};
}
const Zs = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function Ks(e, t) {
const n = wt(e, !0, t === "fixed"), o = n.top + e.clientTop, r = n.left + e.clientLeft, i = Je(e) ? yt(e) : Qe(1), s = e.clientWidth * i.x, l = e.clientHeight * i.y, c = r * i.x, a = o * i.y;
return {
width: s,
height: l,
x: c,
y: a
};
}
function Mo(e, t, n) {
let o;
if (t === "viewport")
o = Js(e, n);
else if (t === "document")
o = Qs(Ke(e));
else if (ye(t))
o = Ks(t, n);
else {
const r = yr(e);
o = {
x: t.x - r.x,
y: t.y - r.y,
width: t.width,
height: t.height
};
}
return hn(o);
}
function Rr(e, t) {
const n = st(e);
return n === t || !ye(n) || Rt(n) ? !1 : Ue(n).position === "fixed" || Rr(n, t);
}
function el(e, t) {
const n = t.get(e);
if (n)
return n;
let o = Bt(e, [], !1).filter((l) => ye(l) && kt(l) !== "body"), r = null;
const i = Ue(e).position === "fixed";
let s = i ? st(e) : e;
for (; ye(s) && !Rt(s); ) {
const l = Ue(s), c = to(s);
!c && l.position === "fixed" && (r = null), (i ? !c && !r : !c && l.position === "static" && !!r && Zs.has(r.position) || qt(s) && !c && Rr(e, s)) ? o = o.filter((u) => u !== s) : r = l, s = st(s);
}
return t.set(e, o), o;
}
function tl(e) {
let {
element: t,
boundary: n,
rootBoundary: o,
strategy: r
} = e;
const s = [...n === "clippingAncestors" ? yn(t) ? [] : el(t, this._c) : [].concat(n), o], l = s[0], c = s.reduce((a, u) => {
const f = Mo(t, u, r);
return a.top = Pe(f.top, a.top), a.right = It(f.right, a.right), a.bottom = It(f.bottom, a.bottom), a.left = Pe(f.left, a.left), a;
}, Mo(t, l, r));
return {
width: c.right - c.left,
height: c.bottom - c.top,
x: c.left,
y: c.top
};
}
function nl(e) {
const {
width: t,
height: n
} = Sr(e);
return {
width: t,
height: n
};
}
function ol(e, t, n) {
const o = Je(t), r = Ke(t), i = n === "fixed", s = wt(e, !0, i, t);
let l = {
scrollLeft: 0,
scrollTop: 0
};
const c = Qe(0);
function a() {
c.x = so(r);
}
if (o || !o && !i)
if ((kt(t) !== "body" || qt(r)) && (l = Cn(t)), o) {
const d = wt(t, !0, i, t);
c.x = d.x + t.clientLeft, c.y = d.y + t.clientTop;
} else r && a();
i && !o && r && a();
const u = r && !o && !i ? Cr(r, l) : Qe(0), f = s.left + l.scrollLeft - c.x - u.x, g = s.top + l.scrollTop - c.y - u.y;
return {
x: f,
y: g,
width: s.width,
height: s.height
};
}
function zn(e) {
return Ue(e).position === "static";
}
function Lo(e, t) {
if (!Je(e) || Ue(e).position === "fixed")
return null;
if (t)
return t(e);
let n = e.offsetParent;
return Ke(e) === n && (n = n.ownerDocument.body), n;
}
function Ir(e, t) {
const n = je(e);
if (yn(e))
return n;
if (!Je(e)) {
let r = st(e);
for (; r && !Rt(r); ) {
if (ye(r) && !zn(r))
return r;
r = st(r);
}
return n;
}
let o = Lo(e, t);
for (; o && $i(o) && zn(o); )
o = Lo(o, t);
return o && Rt(o) && zn(o) && !to(o) ? n : o || Qi(e) || n;
}
const rl = async function(e) {
const t = this.getOffsetParent || Ir, n = this.getDimensions, o = await n(e.floating);
return {
reference: ol(e.reference, await t(e.floating), e.strategy),
floating: {
x: 0,
y: 0,
width: o.width,
height: o.height
}
};
};
function il(e) {
return Ue(e).direction === "rtl";
}
const sl = {
convertOffsetParentRelativeRectToViewportRelativeRect: qs,
getDocumentElement: Ke,
getClippingRect: tl,
getOffsetParent: Ir,
getElementRects: rl,
getClientRects: Xs,
getDimensions: nl,
getScale: yt,
isElement: ye,
isRTL: il
};
function Er(e, t) {
return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function ll(e, t) {
let n = null, o;
const r = Ke(e);
function i() {
var l;
clearTimeout(o), (l = n) == null || l.disconnect(), n = null;
}
function s(l, c) {
l === void 0 && (l = !1), c === void 0 && (c = 1), i();
const a = e.getBoundingClientRect(), {
left: u,
top: f,
width: g,
height: d
} = a;
if (l || t(), !g || !d)
return;
const v = on(f), w = on(r.clientWidth - (u + g)), p = on(r.clientHeight - (f + d)), m = on(u), b = {
rootMargin: -v + "px " + -w + "px " + -p + "px " + -m + "px",
threshold: Pe(0, It(1, c)) || 1
};
let C = !0;
function T(x) {
const y = x[0].intersectionRatio;
if (y !== c) {
if (!C)
return s();
y ? s(!1, y) : o = setTimeout(() => {
s(!1, 1e-7);
}, 1e3);
}
y === 1 && !Er(a, e.getBoundingClientRect()) && s(), C = !1;
}
try {
n = new IntersectionObserver(T, {
...b,
// Handle <iframe>s
root: r.ownerDocument
});
} catch {
n = new IntersectionObserver(T, b);
}
n.observe(e);
}
return s(!0), i;
}
function Ar(e, t, n, o) {
o === void 0 && (o = {});
const {
ancestorScroll: r = !0,
ancestorResize: i = !0,
elementResize: s = typeof ResizeObserver == "function",
layoutShift: l = typeof IntersectionObserver == "function",
animationFrame: c = !1
} = o, a = io(e), u = r || i ? [...a ? Bt(a) : [], ...Bt(t)] : [];
u.forEach((m) => {
r && m.addEventListener("scroll", n, {
passive: !0
}), i && m.addEventListener("resize", n);
});
const f = a && l ? ll(a, n) : null;
let g = -1, d = null;
s && (d = new ResizeObserver((m) => {
let [h] = m;
h && h.target === a && d && (d.unobserve(t), cancelAnimationFrame(g), g = requestAnimationFrame(() => {
var b;
(b = d) == null || b.observe(t);
})), n();
}), a && !c && d.observe(a), d.observe(t));
let v, w = c ? wt(e) : null;
c && p();
function p() {
const m = wt(e);
w && !Er(w, m) && n(), w = m, v = requestAnimationFrame(p);
}
return n(), () => {
var m;
u.forEach((h) => {
r && h.removeEventListener("scroll", n), i && h.removeEventListener("resize", n);
}), f == null || f(), (m = d) == null || m.disconnect(), d = null, c && cancelAnimationFrame(v);
};
}
const cl = Vs, al = Us, ul = Bs, fl = $s, dl = (e, t, n) => {
const o = /* @__PURE__ */ new Map(), r = {
platform: sl,
...n
}, i = {
...r.platform,
_c: o
};
return Ds(e, t, {
...r,
platform: i
});
};
var hl = typeof document < "u", ml = function() {
}, cn = hl ? cr : ml;
function pn(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, o, r;
if (e && t && typeof e == "object") {
if (Array.isArray(e)) {
if (n = e.length, n !== t.length) return !1;
for (o = n; o-- !== 0; )
if (!pn(e[o], t[o]))
return !1;
return !0;
}
if (r = Object.keys(e), n = r.length, n !== Object.keys(t).length)
return !1;
for (o = n; o-- !== 0; )
if (!{}.hasOwnProperty.call(t, r[o]))
return !1;
for (o = n; o-- !== 0; ) {
const i = r[o];
if (!(i === "_owner" && e.$$typeof) && !pn(e[i], t[i]))
return !1;
}
return !0;
}
return e !== e && t !== t;
}
function kr(e) {
return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function zo(e, t) {
const n = kr(e);
return Math.round(t * n) / n;
}
function Pn(e) {
const t = N.useRef(e);
return cn(() => {
t.current = e;
}), t;
}
function gl(e) {
e === void 0 && (e = {});
const {
placement: t = "bottom",
strategy: n = "absolute",
middleware: o = [],
platform: r,
elements: {
reference: i,
floating: s
} = {},
transform: l = !0,
whileElementsMounted: c,
open: a
} = e, [u, f] = N.useState({
x: 0,
y: 0,
strategy: n,
placement: t,
middlewareData: {},
isPositioned: !1
}), [g, d] = N.useState(o);
pn(g, o) || d(o);
const [v, w] = N.useState(null), [p, m] = N.useState(null), h = N.useCallback((_) => {
_ !== x.current && (x.current = _, w(_));
}, []), b = N.useCallback((_) => {
_ !== y.current && (y.current = _, m(_));
}, []), C = i || v, T = s || p, x = N.useRef(null), y = N.useRef(null), I = N.useRef(u), M = c != null, H = Pn(c), z = Pn(r), B = Pn(a), W = N.useCallback(() => {
if (!x.current || !y.current)
return;
const _ = {
placement: t,
strategy: n,
middleware: g
};
z.current && (_.platform = z.current), dl(x.current, y.current, _).then((te) => {
const S = {
...te,
// 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: B.current !== !1
};
O.current && !pn(I.current, S) && (I.current = S, ar.flushSync(() => {
f(S);
}));
});
}, [g, t, n, z, B]);
cn(() => {
a === !1 && I.current.isPositioned && (I.current.isPositioned = !1, f((_) => ({
..._,
isPositioned: !1
})));
}, [a]);
const O = N.useRef(!1);
cn(() => (O.current = !0, () => {
O.current = !1;
}), []), cn(() => {
if (C && (x.current = C), T && (y.current = T), C && T) {
if (H.current)
return H.current(C, T, W);
W();
}
}, [C, T, W, H, M]);
const $ = N.useMemo(() => ({
reference: x,
floating: y,
setReference: h,
setFloating: b
}), [h, b]), X = N.useMemo(() => ({
reference: C,
floating: T
}), [C, T]), K = N.useMemo(() => {
const _ = {
position: n,
left: 0,
top: 0
};
if (!X.floating)
return _;
const te = zo(X.floating, u.x), S = zo(X.floating, u.y);
return l ? {
..._,
transform: "translate(" + te + "px, " + S + "px)",
...kr(X.floating) >= 1.5 && {
willChange: "transform"
}
} : {
position: n,
left: te,
top: S
};
}, [n, l, X.floating, u.x, u.y]);
return N.useMemo(() => ({
...u,
update: W,
refs: $,
elements: X,
floatingStyles: K
}), [u, W, $, X, K]);
}
const Or = (e, t) => ({
...cl(e),
options: [e, t]
}), Hr = (e, t) => ({
...al(e),
options: [e, t]
}), Mr = (e, t) => ({
...ul(e),
options: [e, t]
}), Lr = (e, t) => ({
...fl(e),
options: [e, t]
}), pl = {
...N
};
let Po = !1, vl = 0;
const Fo = () => (
// Ensure the id is unique with multiple independent versions of Floating UI
// on <React 18
"floating-ui-" + Math.random().toString(36).slice(2, 6) + vl++
);
function xl() {
const [e, t] = N.useState(() => Po ? Fo() : void 0);
return xt(() => {
e == null && t(Fo());
}, []), N.useEffect(() => {
Po = !0;
}, []), e;
}
const wl = pl.useId, zr = wl || xl;
let Yn;
process.env.NODE_ENV !== "production" && (Yn = /* @__PURE__ */ new Set());
function bl() {
for (var e, t = arguments.length, n = new Array(t), o = 0; o < t; o++)
n[o] = arguments[o];
const r = "Floating UI: " + n.join(" ");
if (!((e = Yn) != null && e.has(r))) {
var i;
(i = Yn) == null || i.add(r), console.error(r);
}
}
function Tl() {
const e = /* @__PURE__ */ new Map();
return {
emit(t, n) {
var o;
(o = e.get(t)) == null || o.forEach((r) => r(n));
},
on(t, n) {
e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n);
},
off(t, n) {
var o;
(o = e.get(t)) == null || o.delete(n);
}
};
}
const Sl = /*