ag-grid-react-components
Version:
Give your users the date filtering they deserve. Relative date queries, quick filters, and shareable views for AG Grid.
1,729 lines • 283 kB
JavaScript
var ro = Object.defineProperty;
var no = (r, a, t) => a in r ? ro(r, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[a] = t;
var Ir = (r, a, t) => no(r, typeof a != "symbol" ? a + "" : a, t);
import * as W from "react";
import D, { useCallback as z, useLayoutEffect as bn, cloneElement as _n, createRef as Ae, Component as Z, useRef as pe, useEffect as se, createElement as oo, useState as X, useMemo as _e } from "react";
import { useGridFilter as ao } from "ag-grid-react";
import { isBefore as He, isAfter as Ye, isDate as Fe, getYear as B, getSeconds as Ne, getMinutes as ke, getHours as Se, getMonth as oe, isEqual as io, parseISO as so, toDate as kn, isValid as dt, differenceInCalendarDays as Pt, min as Pr, max as Lr, startOfDay as ut, endOfDay as Sn, parse as hr, isWithinInterval as pt, endOfYear as _r, startOfYear as zt, endOfMonth as kr, startOfMonth as Sr, setHours as Tt, setMinutes as Rt, setSeconds as Ot, isSameDay as lo, addMonths as Ce, subMonths as Ie, setYear as ve, differenceInDays as co, addDays as Pe, setMonth as he, subYears as Ue, addYears as xe, format as le, isSameYear as uo, isSameMonth as po, addWeeks as Lt, subWeeks as mr, subDays as xn, startOfWeek as En, differenceInCalendarMonths as At, subQuarters as Cn, differenceInCalendarQuarters as Yt, differenceInCalendarYears as jt, addQuarters as Mn, getTime as vr, setQuarter as Ge, getQuarter as ct, addMinutes as gr, endOfWeek as Tn, isSameQuarter as fo, startOfQuarter as ho, addHours as mo, addSeconds as vo, getISOWeek as go, getDay as yo, getDate as Ar } from "date-fns";
import * as Do from "react-dom";
import Rn from "react-dom";
function wo(r) {
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
}
var Dt = { exports: {} }, ot = {};
/**
* @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 Yr;
function bo() {
if (Yr) return ot;
Yr = 1;
var r = Symbol.for("react.transitional.element"), a = Symbol.for("react.fragment");
function t(e, n, o) {
var i = null;
if (o !== void 0 && (i = "" + o), n.key !== void 0 && (i = "" + n.key), "key" in n) {
o = {};
for (var s in n)
s !== "key" && (o[s] = n[s]);
} else o = n;
return n = o.ref, {
$$typeof: r,
type: e,
key: i,
ref: n !== void 0 ? n : null,
props: o
};
}
return ot.Fragment = a, ot.jsx = t, ot.jsxs = t, ot;
}
var at = {};
/**
* @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 jr;
function _o() {
return jr || (jr = 1, process.env.NODE_ENV !== "production" && function() {
function r(C) {
if (C == null) return null;
if (typeof C == "function")
return C.$$typeof === A ? null : C.displayName || C.name || null;
if (typeof C == "string") return C;
switch (C) {
case h:
return "Fragment";
case y:
return "Profiler";
case m:
return "StrictMode";
case M:
return "Suspense";
case w:
return "SuspenseList";
case P:
return "Activity";
}
if (typeof C == "object")
switch (typeof C.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), C.$$typeof) {
case v:
return "Portal";
case S:
return (C.displayName || "Context") + ".Provider";
case R:
return (C._context.displayName || "Context") + ".Consumer";
case E:
var j = C.render;
return C = C.displayName, C || (C = j.displayName || j.name || "", C = C !== "" ? "ForwardRef(" + C + ")" : "ForwardRef"), C;
case k:
return j = C.displayName || null, j !== null ? j : r(C.type) || "Memo";
case _:
j = C._payload, C = C._init;
try {
return r(C(j));
} catch {
}
}
return null;
}
function a(C) {
return "" + C;
}
function t(C) {
try {
a(C);
var j = !1;
} catch {
j = !0;
}
if (j) {
j = console;
var J = j.error, re = typeof Symbol == "function" && Symbol.toStringTag && C[Symbol.toStringTag] || C.constructor.name || "Object";
return J.call(
j,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
re
), a(C);
}
}
function e(C) {
if (C === h) return "<>";
if (typeof C == "object" && C !== null && C.$$typeof === _)
return "<...>";
try {
var j = r(C);
return j ? "<" + j + ">" : "<...>";
} catch {
return "<...>";
}
}
function n() {
var C = g.A;
return C === null ? null : C.getOwner();
}
function o() {
return Error("react-stack-top-frame");
}
function i(C) {
if (N.call(C, "key")) {
var j = Object.getOwnPropertyDescriptor(C, "key").get;
if (j && j.isReactWarning) return !1;
}
return C.key !== void 0;
}
function s(C, j) {
function J() {
x || (x = !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)",
j
));
}
J.isReactWarning = !0, Object.defineProperty(C, "key", {
get: J,
configurable: !0
});
}
function l() {
var C = r(this.type);
return F[C] || (F[C] = !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."
)), C = this.props.ref, C !== void 0 ? C : null;
}
function c(C, j, J, re, Me, me, tr, rr) {
return J = me.ref, C = {
$$typeof: f,
type: C,
key: j,
props: me,
_owner: Me
}, (J !== void 0 ? J : null) !== null ? Object.defineProperty(C, "ref", {
enumerable: !1,
get: l
}) : Object.defineProperty(C, "ref", { enumerable: !1, value: null }), C._store = {}, Object.defineProperty(C._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(C, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.defineProperty(C, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: tr
}), Object.defineProperty(C, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: rr
}), Object.freeze && (Object.freeze(C.props), Object.freeze(C)), C;
}
function d(C, j, J, re, Me, me, tr, rr) {
var ne = j.children;
if (ne !== void 0)
if (re)
if (T(ne)) {
for (re = 0; re < ne.length; re++)
p(ne[re]);
Object.freeze && Object.freeze(ne);
} 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 p(ne);
if (N.call(j, "key")) {
ne = r(C);
var Ke = Object.keys(j).filter(function(to) {
return to !== "key";
});
re = 0 < Ke.length ? "{key: someKey, " + Ke.join(": ..., ") + ": ...}" : "{key: someKey}", q[ne + re] || (Ke = 0 < Ke.length ? "{" + Ke.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} />`,
re,
ne,
Ke,
ne
), q[ne + re] = !0);
}
if (ne = null, J !== void 0 && (t(J), ne = "" + J), i(j) && (t(j.key), ne = "" + j.key), "key" in j) {
J = {};
for (var nr in j)
nr !== "key" && (J[nr] = j[nr]);
} else J = j;
return ne && s(
J,
typeof C == "function" ? C.displayName || C.name || "Unknown" : C
), c(
C,
ne,
me,
Me,
n(),
J,
tr,
rr
);
}
function p(C) {
typeof C == "object" && C !== null && C.$$typeof === f && C._store && (C._store.validated = 1);
}
var u = D, f = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), R = Symbol.for("react.consumer"), S = Symbol.for("react.context"), E = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), k = Symbol.for("react.memo"), _ = Symbol.for("react.lazy"), P = Symbol.for("react.activity"), A = Symbol.for("react.client.reference"), g = u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, T = Array.isArray, O = console.createTask ? console.createTask : function() {
return null;
};
u = {
"react-stack-bottom-frame": function(C) {
return C();
}
};
var x, F = {}, L = u["react-stack-bottom-frame"].bind(
u,
o
)(), Y = O(e(o)), q = {};
at.Fragment = h, at.jsx = function(C, j, J, re, Me) {
var me = 1e4 > g.recentlyCreatedOwnerStacks++;
return d(
C,
j,
J,
!1,
re,
Me,
me ? Error("react-stack-top-frame") : L,
me ? O(e(C)) : Y
);
}, at.jsxs = function(C, j, J, re, Me) {
var me = 1e4 > g.recentlyCreatedOwnerStacks++;
return d(
C,
j,
J,
!0,
re,
Me,
me ? Error("react-stack-top-frame") : L,
me ? O(e(C)) : Y
);
};
}()), at;
}
var Wr;
function ko() {
return Wr || (Wr = 1, process.env.NODE_ENV === "production" ? Dt.exports = bo() : Dt.exports = _o()), Dt.exports;
}
var b = ko();
const or = process.env.NODE_ENV === "development", So = (r) => ({
log: (...a) => Q.log(`[${r}]`, ...a),
warn: (...a) => Q.warn(`[${r}]`, ...a),
error: (...a) => Q.error(`[${r}]`, ...a),
debug: (...a) => Q.debug(`[${r}]`, ...a),
info: (...a) => Q.log(`[${r}]`, ...a)
}), Q = {
log: (...r) => {
or && console.log(...r);
},
warn: (...r) => {
or && console.warn(...r);
},
error: (...r) => {
console.error(...r);
},
debug: (...r) => {
or && console.debug(...r);
}
}, xo = "_filterModeSection_v2epc_1", Eo = "_filterLabel_v2epc_5", Co = "_dateModeSelector_v2epc_13", Mo = "_dateModeOption_v2epc_21", To = "_selected_v2epc_43", We = {
filterModeSection: xo,
filterLabel: Eo,
dateModeSelector: Co,
dateModeOption: Mo,
selected: To
}, Ro = ({
mode: r,
onModeChange: a,
className: t = ""
}) => /* @__PURE__ */ b.jsxs("div", { className: `${We.filterModeSection} ${t}`, children: [
/* @__PURE__ */ b.jsx("label", { id: "date-mode-label", className: We.filterLabel, children: "Date Mode" }),
/* @__PURE__ */ b.jsxs(
"div",
{
className: We.dateModeSelector,
"data-testid": "mode-toggle",
role: "radiogroup",
"aria-labelledby": "date-mode-label",
"aria-describedby": "date-mode-description",
children: [
/* @__PURE__ */ b.jsx(
"button",
{
className: `${We.dateModeOption} ${r === "absolute" ? We.selected : ""}`,
role: "radio",
"aria-checked": r === "absolute",
tabIndex: r === "absolute" ? 0 : -1,
onClick: () => r !== "absolute" && a(),
onKeyDown: (e) => {
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), r !== "absolute" && a());
},
children: "Specific"
}
),
/* @__PURE__ */ b.jsx(
"button",
{
className: `${We.dateModeOption} ${r === "relative" ? We.selected : ""}`,
role: "radio",
"aria-checked": r === "relative",
tabIndex: r === "relative" ? 0 : -1,
onClick: () => r !== "relative" && a(),
onKeyDown: (e) => {
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), r !== "relative" && a());
},
children: "Relative"
}
)
]
}
),
/* @__PURE__ */ b.jsx("div", { id: "date-mode-description", className: "sr-only", "aria-live": "polite", children: 'Choose between specific dates or relative date expressions like "Today+7d"' })
] }), Oo = D.memo(
Ro,
(r, a) => r.mode === a.mode && r.className === a.className
), Fo = "_filterTypeSection_1vejc_1", No = "_filterLabel_1vejc_5", Io = "_filterTypeSelect_1vejc_13", Po = "_screenReaderOnly_1vejc_39", wt = {
filterTypeSection: Fo,
filterLabel: No,
filterTypeSelect: Io,
screenReaderOnly: Po
}, Lo = ({
filterType: r,
onTypeChange: a,
className: t = ""
}) => {
const e = z(
(n) => {
a(n.target.value);
},
[a]
);
return /* @__PURE__ */ b.jsxs("div", { className: `${wt.filterTypeSection} ${t}`, children: [
/* @__PURE__ */ b.jsx("label", { htmlFor: "filter-type-select", className: wt.filterLabel, children: "Filter Type" }),
/* @__PURE__ */ b.jsxs(
"select",
{
id: "filter-type-select",
className: wt.filterTypeSelect,
value: r,
onChange: e,
"aria-label": "Select filter type",
"aria-describedby": "filter-type-description",
children: [
/* @__PURE__ */ b.jsx("option", { value: "equals", children: "Equals" }),
/* @__PURE__ */ b.jsx("option", { value: "notEqual", children: "Not Equal" }),
/* @__PURE__ */ b.jsx("option", { value: "after", children: "After" }),
/* @__PURE__ */ b.jsx("option", { value: "before", children: "Before" }),
/* @__PURE__ */ b.jsx("option", { value: "inRange", children: "In Range" })
]
}
),
/* @__PURE__ */ b.jsx(
"div",
{
id: "filter-type-description",
className: wt.screenReaderOnly,
"aria-live": "polite",
children: "Choose how to filter dates: equals a specific date, not equal to a date, after a date, before a date, or within a date range"
}
)
] });
}, Ao = D.memo(
Lo,
(r, a) => r.filterType === a.filterType && r.className === a.className
);
function On(r) {
var a, t, e = "";
if (typeof r == "string" || typeof r == "number") e += r;
else if (typeof r == "object") if (Array.isArray(r)) {
var n = r.length;
for (a = 0; a < n; a++) r[a] && (t = On(r[a])) && (e && (e += " "), e += t);
} else for (t in r) r[t] && (e && (e += " "), e += t);
return e;
}
function te() {
for (var r, a, t = 0, e = "", n = arguments.length; t < n; t++) (r = arguments[t]) && (a = On(r)) && (e && (e += " "), e += a);
return e;
}
function Kt() {
return typeof window < "u";
}
function nt(r) {
return Fn(r) ? (r.nodeName || "").toLowerCase() : "#document";
}
function ce(r) {
var a;
return (r == null || (a = r.ownerDocument) == null ? void 0 : a.defaultView) || window;
}
function be(r) {
var a;
return (a = (Fn(r) ? r.ownerDocument : r.document) || window.document) == null ? void 0 : a.documentElement;
}
function Fn(r) {
return Kt() ? r instanceof Node || r instanceof ce(r).Node : !1;
}
function ae(r) {
return Kt() ? r instanceof Element || r instanceof ce(r).Element : !1;
}
function we(r) {
return Kt() ? r instanceof HTMLElement || r instanceof ce(r).HTMLElement : !1;
}
function Br(r) {
return !Kt() || typeof ShadowRoot > "u" ? !1 : r instanceof ShadowRoot || r instanceof ce(r).ShadowRoot;
}
function mt(r) {
const {
overflow: a,
overflowX: t,
overflowY: e,
display: n
} = fe(r);
return /auto|scroll|overlay|hidden|clip/.test(a + e + t) && !["inline", "contents"].includes(n);
}
function Yo(r) {
return ["table", "td", "th"].includes(nt(r));
}
function qt(r) {
return [":popover-open", ":modal"].some((a) => {
try {
return r.matches(a);
} catch {
return !1;
}
});
}
function xr(r) {
const a = Er(), t = ae(r) ? fe(r) : r;
return ["transform", "translate", "scale", "rotate", "perspective"].some((e) => t[e] ? t[e] !== "none" : !1) || (t.containerType ? t.containerType !== "normal" : !1) || !a && (t.backdropFilter ? t.backdropFilter !== "none" : !1) || !a && (t.filter ? t.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((e) => (t.willChange || "").includes(e)) || ["paint", "layout", "strict", "content"].some((e) => (t.contain || "").includes(e));
}
function jo(r) {
let a = je(r);
for (; we(a) && !Ze(a); ) {
if (xr(a))
return a;
if (qt(a))
return null;
a = je(a);
}
return null;
}
function Er() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
function Ze(r) {
return ["html", "body", "#document"].includes(nt(r));
}
function fe(r) {
return ce(r).getComputedStyle(r);
}
function Gt(r) {
return ae(r) ? {
scrollLeft: r.scrollLeft,
scrollTop: r.scrollTop
} : {
scrollLeft: r.scrollX,
scrollTop: r.scrollY
};
}
function je(r) {
if (nt(r) === "html")
return r;
const a = (
// Step into the shadow DOM of the parent of a slotted node.
r.assignedSlot || // DOM Element detected.
r.parentNode || // ShadowRoot detected.
Br(r) && r.host || // Fallback.
be(r)
);
return Br(a) ? a.host : a;
}
function Nn(r) {
const a = je(r);
return Ze(a) ? r.ownerDocument ? r.ownerDocument.body : r.body : we(a) && mt(a) ? a : Nn(a);
}
function ft(r, a, t) {
var e;
a === void 0 && (a = []), t === void 0 && (t = !0);
const n = Nn(r), o = n === ((e = r.ownerDocument) == null ? void 0 : e.body), i = ce(n);
if (o) {
const s = yr(i);
return a.concat(i, i.visualViewport || [], mt(n) ? n : [], s && t ? ft(s) : []);
}
return a.concat(n, ft(n, [], t));
}
function yr(r) {
return r.parent && Object.getPrototypeOf(r.parent) ? r.frameElement : null;
}
const et = Math.min, Ve = Math.max, Wt = Math.round, bt = Math.floor, De = (r) => ({
x: r,
y: r
}), Wo = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, Bo = {
start: "end",
end: "start"
};
function $o(r, a, t) {
return Ve(r, et(a, t));
}
function Jt(r, a) {
return typeof r == "function" ? r(a) : r;
}
function tt(r) {
return r.split("-")[0];
}
function vt(r) {
return r.split("-")[1];
}
function Vo(r) {
return r === "x" ? "y" : "x";
}
function Cr(r) {
return r === "y" ? "height" : "width";
}
function Be(r) {
return ["top", "bottom"].includes(tt(r)) ? "y" : "x";
}
function Mr(r) {
return Vo(Be(r));
}
function Ho(r, a, t) {
t === void 0 && (t = !1);
const e = vt(r), n = Mr(r), o = Cr(n);
let i = n === "x" ? e === (t ? "end" : "start") ? "right" : "left" : e === "start" ? "bottom" : "top";
return a.reference[o] > a.floating[o] && (i = Bt(i)), [i, Bt(i)];
}
function Uo(r) {
const a = Bt(r);
return [Dr(r), a, Dr(a)];
}
function Dr(r) {
return r.replace(/start|end/g, (a) => Bo[a]);
}
function Qo(r, a, t) {
const e = ["left", "right"], n = ["right", "left"], o = ["top", "bottom"], i = ["bottom", "top"];
switch (r) {
case "top":
case "bottom":
return t ? a ? n : e : a ? e : n;
case "left":
case "right":
return a ? o : i;
default:
return [];
}
}
function zo(r, a, t, e) {
const n = vt(r);
let o = Qo(tt(r), t === "start", e);
return n && (o = o.map((i) => i + "-" + n), a && (o = o.concat(o.map(Dr)))), o;
}
function Bt(r) {
return r.replace(/left|right|bottom|top/g, (a) => Wo[a]);
}
function Ko(r) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...r
};
}
function In(r) {
return typeof r != "number" ? Ko(r) : {
top: r,
right: r,
bottom: r,
left: r
};
}
function $t(r) {
const {
x: a,
y: t,
width: e,
height: n
} = r;
return {
width: e,
height: n,
top: t,
left: a,
right: a + e,
bottom: t + n,
x: a,
y: t
};
}
var qo = typeof document < "u", Go = function() {
}, Vt = qo ? bn : Go;
const Jo = {
...W
}, Xo = Jo.useInsertionEffect, Zo = Xo || ((r) => r());
function ea(r) {
const a = W.useRef(() => {
if (process.env.NODE_ENV !== "production")
throw new Error("Cannot call an event handler while rendering.");
});
return Zo(() => {
a.current = r;
}), W.useCallback(function() {
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
e[n] = arguments[n];
return a.current == null ? void 0 : a.current(...e);
}, []);
}
function $r(r, a, t) {
let {
reference: e,
floating: n
} = r;
const o = Be(a), i = Mr(a), s = Cr(i), l = tt(a), c = o === "y", d = e.x + e.width / 2 - n.width / 2, p = e.y + e.height / 2 - n.height / 2, u = e[s] / 2 - n[s] / 2;
let f;
switch (l) {
case "top":
f = {
x: d,
y: e.y - n.height
};
break;
case "bottom":
f = {
x: d,
y: e.y + e.height
};
break;
case "right":
f = {
x: e.x + e.width,
y: p
};
break;
case "left":
f = {
x: e.x - n.width,
y: p
};
break;
default:
f = {
x: e.x,
y: e.y
};
}
switch (vt(a)) {
case "start":
f[i] -= u * (t && c ? -1 : 1);
break;
case "end":
f[i] += u * (t && c ? -1 : 1);
break;
}
return f;
}
const ta = async (r, a, t) => {
const {
placement: e = "bottom",
strategy: n = "absolute",
middleware: o = [],
platform: i
} = t, s = o.filter(Boolean), l = await (i.isRTL == null ? void 0 : i.isRTL(a));
let c = await i.getElementRects({
reference: r,
floating: a,
strategy: n
}), {
x: d,
y: p
} = $r(c, e, l), u = e, f = {}, v = 0;
for (let h = 0; h < s.length; h++) {
const {
name: m,
fn: y
} = s[h], {
x: R,
y: S,
data: E,
reset: M
} = await y({
x: d,
y: p,
initialPlacement: e,
placement: u,
strategy: n,
middlewareData: f,
rects: c,
platform: i,
elements: {
reference: r,
floating: a
}
});
d = R ?? d, p = S ?? p, f = {
...f,
[m]: {
...f[m],
...E
}
}, M && v <= 50 && (v++, typeof M == "object" && (M.placement && (u = M.placement), M.rects && (c = M.rects === !0 ? await i.getElementRects({
reference: r,
floating: a,
strategy: n
}) : M.rects), {
x: d,
y: p
} = $r(c, u, l)), h = -1);
}
return {
x: d,
y: p,
placement: u,
strategy: n,
middlewareData: f
};
};
async function ra(r, a) {
var t;
a === void 0 && (a = {});
const {
x: e,
y: n,
platform: o,
rects: i,
elements: s,
strategy: l
} = r, {
boundary: c = "clippingAncestors",
rootBoundary: d = "viewport",
elementContext: p = "floating",
altBoundary: u = !1,
padding: f = 0
} = Jt(a, r), v = In(f), m = s[u ? p === "floating" ? "reference" : "floating" : p], y = $t(await o.getClippingRect({
element: (t = await (o.isElement == null ? void 0 : o.isElement(m))) == null || t ? m : m.contextElement || await (o.getDocumentElement == null ? void 0 : o.getDocumentElement(s.floating)),
boundary: c,
rootBoundary: d,
strategy: l
})), R = p === "floating" ? {
x: e,
y: n,
width: i.floating.width,
height: i.floating.height
} : i.reference, S = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(s.floating)), E = await (o.isElement == null ? void 0 : o.isElement(S)) ? await (o.getScale == null ? void 0 : o.getScale(S)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, M = $t(o.convertOffsetParentRelativeRectToViewportRelativeRect ? await o.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: s,
rect: R,
offsetParent: S,
strategy: l
}) : R);
return {
top: (y.top - M.top + v.top) / E.y,
bottom: (M.bottom - y.bottom + v.bottom) / E.y,
left: (y.left - M.left + v.left) / E.x,
right: (M.right - y.right + v.right) / E.x
};
}
const na = (r) => ({
name: "arrow",
options: r,
async fn(a) {
const {
x: t,
y: e,
placement: n,
rects: o,
platform: i,
elements: s,
middlewareData: l
} = a, {
element: c,
padding: d = 0
} = Jt(r, a) || {};
if (c == null)
return {};
const p = In(d), u = {
x: t,
y: e
}, f = Mr(n), v = Cr(f), h = await i.getDimensions(c), m = f === "y", y = m ? "top" : "left", R = m ? "bottom" : "right", S = m ? "clientHeight" : "clientWidth", E = o.reference[v] + o.reference[f] - u[f] - o.floating[v], M = u[f] - o.reference[f], w = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(c));
let k = w ? w[S] : 0;
(!k || !await (i.isElement == null ? void 0 : i.isElement(w))) && (k = s.floating[S] || o.floating[v]);
const _ = E / 2 - M / 2, P = k / 2 - h[v] / 2 - 1, A = et(p[y], P), g = et(p[R], P), N = A, T = k - h[v] - g, O = k / 2 - h[v] / 2 + _, x = $o(N, O, T), F = !l.arrow && vt(n) != null && O !== x && o.reference[v] / 2 - (O < N ? A : g) - h[v] / 2 < 0, L = F ? O < N ? O - N : O - T : 0;
return {
[f]: u[f] + L,
data: {
[f]: x,
centerOffset: O - x - L,
...F && {
alignmentOffset: L
}
},
reset: F
};
}
}), oa = function(r) {
return r === void 0 && (r = {}), {
name: "flip",
options: r,
async fn(a) {
var t, e;
const {
placement: n,
middlewareData: o,
rects: i,
initialPlacement: s,
platform: l,
elements: c
} = a, {
mainAxis: d = !0,
crossAxis: p = !0,
fallbackPlacements: u,
fallbackStrategy: f = "bestFit",
fallbackAxisSideDirection: v = "none",
flipAlignment: h = !0,
...m
} = Jt(r, a);
if ((t = o.arrow) != null && t.alignmentOffset)
return {};
const y = tt(n), R = Be(s), S = tt(s) === s, E = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), M = u || (S || !h ? [Bt(s)] : Uo(s)), w = v !== "none";
!u && w && M.push(...zo(s, h, v, E));
const k = [s, ...M], _ = await ra(a, m), P = [];
let A = ((e = o.flip) == null ? void 0 : e.overflows) || [];
if (d && P.push(_[y]), p) {
const O = Ho(n, i, E);
P.push(_[O[0]], _[O[1]]);
}
if (A = [...A, {
placement: n,
overflows: P
}], !P.every((O) => O <= 0)) {
var g, N;
const O = (((g = o.flip) == null ? void 0 : g.index) || 0) + 1, x = k[O];
if (x && (!(p === "alignment" ? R !== Be(x) : !1) || // We leave the current main axis only if every placement on that axis
// overflows the main axis.
A.every((Y) => Y.overflows[0] > 0 && Be(Y.placement) === R)))
return {
data: {
index: O,
overflows: A
},
reset: {
placement: x
}
};
let F = (N = A.filter((L) => L.overflows[0] <= 0).sort((L, Y) => L.overflows[1] - Y.overflows[1])[0]) == null ? void 0 : N.placement;
if (!F)
switch (f) {
case "bestFit": {
var T;
const L = (T = A.filter((Y) => {
if (w) {
const q = Be(Y.placement);
return q === R || // Create a bias to the `y` side axis due to horizontal
// reading directions favoring greater width.
q === "y";
}
return !0;
}).map((Y) => [Y.placement, Y.overflows.filter((q) => q > 0).reduce((q, C) => q + C, 0)]).sort((Y, q) => Y[1] - q[1])[0]) == null ? void 0 : T[0];
L && (F = L);
break;
}
case "initialPlacement":
F = s;
break;
}
if (n !== F)
return {
reset: {
placement: F
}
};
}
return {};
}
};
};
async function aa(r, a) {
const {
placement: t,
platform: e,
elements: n
} = r, o = await (e.isRTL == null ? void 0 : e.isRTL(n.floating)), i = tt(t), s = vt(t), l = Be(t) === "y", c = ["left", "top"].includes(i) ? -1 : 1, d = o && l ? -1 : 1, p = Jt(a, r);
let {
mainAxis: u,
crossAxis: f,
alignmentAxis: v
} = typeof p == "number" ? {
mainAxis: p,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: p.mainAxis || 0,
crossAxis: p.crossAxis || 0,
alignmentAxis: p.alignmentAxis
};
return s && typeof v == "number" && (f = s === "end" ? v * -1 : v), l ? {
x: f * d,
y: u * c
} : {
x: u * c,
y: f * d
};
}
const ia = function(r) {
return r === void 0 && (r = 0), {
name: "offset",
options: r,
async fn(a) {
var t, e;
const {
x: n,
y: o,
placement: i,
middlewareData: s
} = a, l = await aa(a, r);
return i === ((t = s.offset) == null ? void 0 : t.placement) && (e = s.arrow) != null && e.alignmentOffset ? {} : {
x: n + l.x,
y: o + l.y,
data: {
...l,
placement: i
}
};
}
};
};
function Pn(r) {
const a = fe(r);
let t = parseFloat(a.width) || 0, e = parseFloat(a.height) || 0;
const n = we(r), o = n ? r.offsetWidth : t, i = n ? r.offsetHeight : e, s = Wt(t) !== o || Wt(e) !== i;
return s && (t = o, e = i), {
width: t,
height: e,
$: s
};
}
function Tr(r) {
return ae(r) ? r : r.contextElement;
}
function Je(r) {
const a = Tr(r);
if (!we(a))
return De(1);
const t = a.getBoundingClientRect(), {
width: e,
height: n,
$: o
} = Pn(a);
let i = (o ? Wt(t.width) : t.width) / e, s = (o ? Wt(t.height) : t.height) / n;
return (!i || !Number.isFinite(i)) && (i = 1), (!s || !Number.isFinite(s)) && (s = 1), {
x: i,
y: s
};
}
const sa = /* @__PURE__ */ De(0);
function Ln(r) {
const a = ce(r);
return !Er() || !a.visualViewport ? sa : {
x: a.visualViewport.offsetLeft,
y: a.visualViewport.offsetTop
};
}
function la(r, a, t) {
return a === void 0 && (a = !1), !t || a && t !== ce(r) ? !1 : a;
}
function Qe(r, a, t, e) {
a === void 0 && (a = !1), t === void 0 && (t = !1);
const n = r.getBoundingClientRect(), o = Tr(r);
let i = De(1);
a && (e ? ae(e) && (i = Je(e)) : i = Je(r));
const s = la(o, t, e) ? Ln(o) : De(0);
let l = (n.left + s.x) / i.x, c = (n.top + s.y) / i.y, d = n.width / i.x, p = n.height / i.y;
if (o) {
const u = ce(o), f = e && ae(e) ? ce(e) : e;
let v = u, h = yr(v);
for (; h && e && f !== v; ) {
const m = Je(h), y = h.getBoundingClientRect(), R = fe(h), S = y.left + (h.clientLeft + parseFloat(R.paddingLeft)) * m.x, E = y.top + (h.clientTop + parseFloat(R.paddingTop)) * m.y;
l *= m.x, c *= m.y, d *= m.x, p *= m.y, l += S, c += E, v = ce(h), h = yr(v);
}
}
return $t({
width: d,
height: p,
x: l,
y: c
});
}
function Rr(r, a) {
const t = Gt(r).scrollLeft;
return a ? a.left + t : Qe(be(r)).left + t;
}
function An(r, a, t) {
t === void 0 && (t = !1);
const e = r.getBoundingClientRect(), n = e.left + a.scrollLeft - (t ? 0 : (
// RTL <body> scrollbar.
Rr(r, e)
)), o = e.top + a.scrollTop;
return {
x: n,
y: o
};
}
function ca(r) {
let {
elements: a,
rect: t,
offsetParent: e,
strategy: n
} = r;
const o = n === "fixed", i = be(e), s = a ? qt(a.floating) : !1;
if (e === i || s && o)
return t;
let l = {
scrollLeft: 0,
scrollTop: 0
}, c = De(1);
const d = De(0), p = we(e);
if ((p || !p && !o) && ((nt(e) !== "body" || mt(i)) && (l = Gt(e)), we(e))) {
const f = Qe(e);
c = Je(e), d.x = f.x + e.clientLeft, d.y = f.y + e.clientTop;
}
const u = i && !p && !o ? An(i, l, !0) : De(0);
return {
width: t.width * c.x,
height: t.height * c.y,
x: t.x * c.x - l.scrollLeft * c.x + d.x + u.x,
y: t.y * c.y - l.scrollTop * c.y + d.y + u.y
};
}
function da(r) {
return Array.from(r.getClientRects());
}
function ua(r) {
const a = be(r), t = Gt(r), e = r.ownerDocument.body, n = Ve(a.scrollWidth, a.clientWidth, e.scrollWidth, e.clientWidth), o = Ve(a.scrollHeight, a.clientHeight, e.scrollHeight, e.clientHeight);
let i = -t.scrollLeft + Rr(r);
const s = -t.scrollTop;
return fe(e).direction === "rtl" && (i += Ve(a.clientWidth, e.clientWidth) - n), {
width: n,
height: o,
x: i,
y: s
};
}
function pa(r, a) {
const t = ce(r), e = be(r), n = t.visualViewport;
let o = e.clientWidth, i = e.clientHeight, s = 0, l = 0;
if (n) {
o = n.width, i = n.height;
const c = Er();
(!c || c && a === "fixed") && (s = n.offsetLeft, l = n.offsetTop);
}
return {
width: o,
height: i,
x: s,
y: l
};
}
function fa(r, a) {
const t = Qe(r, !0, a === "fixed"), e = t.top + r.clientTop, n = t.left + r.clientLeft, o = we(r) ? Je(r) : De(1), i = r.clientWidth * o.x, s = r.clientHeight * o.y, l = n * o.x, c = e * o.y;
return {
width: i,
height: s,
x: l,
y: c
};
}
function Vr(r, a, t) {
let e;
if (a === "viewport")
e = pa(r, t);
else if (a === "document")
e = ua(be(r));
else if (ae(a))
e = fa(a, t);
else {
const n = Ln(r);
e = {
x: a.x - n.x,
y: a.y - n.y,
width: a.width,
height: a.height
};
}
return $t(e);
}
function Yn(r, a) {
const t = je(r);
return t === a || !ae(t) || Ze(t) ? !1 : fe(t).position === "fixed" || Yn(t, a);
}
function ha(r, a) {
const t = a.get(r);
if (t)
return t;
let e = ft(r, [], !1).filter((s) => ae(s) && nt(s) !== "body"), n = null;
const o = fe(r).position === "fixed";
let i = o ? je(r) : r;
for (; ae(i) && !Ze(i); ) {
const s = fe(i), l = xr(i);
!l && s.position === "fixed" && (n = null), (o ? !l && !n : !l && s.position === "static" && !!n && ["absolute", "fixed"].includes(n.position) || mt(i) && !l && Yn(r, i)) ? e = e.filter((d) => d !== i) : n = s, i = je(i);
}
return a.set(r, e), e;
}
function ma(r) {
let {
element: a,
boundary: t,
rootBoundary: e,
strategy: n
} = r;
const i = [...t === "clippingAncestors" ? qt(a) ? [] : ha(a, this._c) : [].concat(t), e], s = i[0], l = i.reduce((c, d) => {
const p = Vr(a, d, n);
return c.top = Ve(p.top, c.top), c.right = et(p.right, c.right), c.bottom = et(p.bottom, c.bottom), c.left = Ve(p.left, c.left), c;
}, Vr(a, s, n));
return {
width: l.right - l.left,
height: l.bottom - l.top,
x: l.left,
y: l.top
};
}
function va(r) {
const {
width: a,
height: t
} = Pn(r);
return {
width: a,
height: t
};
}
function ga(r, a, t) {
const e = we(a), n = be(a), o = t === "fixed", i = Qe(r, !0, o, a);
let s = {
scrollLeft: 0,
scrollTop: 0
};
const l = De(0);
function c() {
l.x = Rr(n);
}
if (e || !e && !o)
if ((nt(a) !== "body" || mt(n)) && (s = Gt(a)), e) {
const f = Qe(a, !0, o, a);
l.x = f.x + a.clientLeft, l.y = f.y + a.clientTop;
} else n && c();
o && !e && n && c();
const d = n && !e && !o ? An(n, s) : De(0), p = i.left + s.scrollLeft - l.x - d.x, u = i.top + s.scrollTop - l.y - d.y;
return {
x: p,
y: u,
width: i.width,
height: i.height
};
}
function ar(r) {
return fe(r).position === "static";
}
function Hr(r, a) {
if (!we(r) || fe(r).position === "fixed")
return null;
if (a)
return a(r);
let t = r.offsetParent;
return be(r) === t && (t = t.ownerDocument.body), t;
}
function jn(r, a) {
const t = ce(r);
if (qt(r))
return t;
if (!we(r)) {
let n = je(r);
for (; n && !Ze(n); ) {
if (ae(n) && !ar(n))
return n;
n = je(n);
}
return t;
}
let e = Hr(r, a);
for (; e && Yo(e) && ar(e); )
e = Hr(e, a);
return e && Ze(e) && ar(e) && !xr(e) ? t : e || jo(r) || t;
}
const ya = async function(r) {
const a = this.getOffsetParent || jn, t = this.getDimensions, e = await t(r.floating);
return {
reference: ga(r.reference, await a(r.floating), r.strategy),
floating: {
x: 0,
y: 0,
width: e.width,
height: e.height
}
};
};
function Da(r) {
return fe(r).direction === "rtl";
}
const wa = {
convertOffsetParentRelativeRectToViewportRelativeRect: ca,
getDocumentElement: be,
getClippingRect: ma,
getOffsetParent: jn,
getElementRects: ya,
getClientRects: da,
getDimensions: va,
getScale: Je,
isElement: ae,
isRTL: Da
};
function Wn(r, a) {
return r.x === a.x && r.y === a.y && r.width === a.width && r.height === a.height;
}
function ba(r, a) {
let t = null, e;
const n = be(r);
function o() {
var s;
clearTimeout(e), (s = t) == null || s.disconnect(), t = null;
}
function i(s, l) {
s === void 0 && (s = !1), l === void 0 && (l = 1), o();
const c = r.getBoundingClientRect(), {
left: d,
top: p,
width: u,
height: f
} = c;
if (s || a(), !u || !f)
return;
const v = bt(p), h = bt(n.clientWidth - (d + u)), m = bt(n.clientHeight - (p + f)), y = bt(d), S = {
rootMargin: -v + "px " + -h + "px " + -m + "px " + -y + "px",
threshold: Ve(0, et(1, l)) || 1
};
let E = !0;
function M(w) {
const k = w[0].intersectionRatio;
if (k !== l) {
if (!E)
return i();
k ? i(!1, k) : e = setTimeout(() => {
i(!1, 1e-7);
}, 1e3);
}
k === 1 && !Wn(c, r.getBoundingClientRect()) && i(), E = !1;
}
try {
t = new IntersectionObserver(M, {
...S,
// Handle <iframe>s
root: n.ownerDocument
});
} catch {
t = new IntersectionObserver(M, S);
}
t.observe(r);
}
return i(!0), o;
}
function _a(r, a, t, e) {
e === void 0 && (e = {});
const {
ancestorScroll: n = !0,
ancestorResize: o = !0,
elementResize: i = typeof ResizeObserver == "function",
layoutShift: s = typeof IntersectionObserver == "function",
animationFrame: l = !1
} = e, c = Tr(r), d = n || o ? [...c ? ft(c) : [], ...ft(a)] : [];
d.forEach((y) => {
n && y.addEventListener("scroll", t, {
passive: !0
}), o && y.addEventListener("resize", t);
});
const p = c && s ? ba(c, t) : null;
let u = -1, f = null;
i && (f = new ResizeObserver((y) => {
let [R] = y;
R && R.target === c && f && (f.unobserve(a), cancelAnimationFrame(u), u = requestAnimationFrame(() => {
var S;
(S = f) == null || S.observe(a);
})), t();
}), c && !l && f.observe(c), f.observe(a));
let v, h = l ? Qe(r) : null;
l && m();
function m() {
const y = Qe(r);
h && !Wn(h, y) && t(), h = y, v = requestAnimationFrame(m);
}
return t(), () => {
var y;
d.forEach((R) => {
n && R.removeEventListener("scroll", t), o && R.removeEventListener("resize", t);
}), p == null || p(), (y = f) == null || y.disconnect(), f = null, l && cancelAnimationFrame(v);
};
}
const ka = ia, Sa = oa, Ur = na, xa = (r, a, t) => {
const e = /* @__PURE__ */ new Map(), n = {
platform: wa,
...t
}, o = {
...n.platform,
_c: e
};
return ta(r, a, {
...n,
platform: o
});
};
var Ea = typeof document < "u", Ca = function() {
}, Ft = Ea ? bn : Ca;
function Ht(r, a) {
if (r === a)
return !0;
if (typeof r != typeof a)
return !1;
if (typeof r == "function" && r.toString() === a.toString())
return !0;
let t, e, n;
if (r && a && typeof r == "object") {
if (Array.isArray(r)) {
if (t = r.length, t !== a.length) return !1;
for (e = t; e-- !== 0; )
if (!Ht(r[e], a[e]))
return !1;
return !0;
}
if (n = Object.keys(r), t = n.length, t !== Object.keys(a).length)
return !1;
for (e = t; e-- !== 0; )
if (!{}.hasOwnProperty.call(a, n[e]))
return !1;
for (e = t; e-- !== 0; ) {
const o = n[e];
if (!(o === "_owner" && r.$$typeof) && !Ht(r[o], a[o]))
return !1;
}
return !0;
}
return r !== r && a !== a;
}
function Bn(r) {
return typeof window > "u" ? 1 : (r.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function Qr(r, a) {
const t = Bn(r);
return Math.round(a * t) / t;
}
function ir(r) {
const a = W.useRef(r);
return Ft(() => {
a.current = r;
}), a;
}
function Ma(r) {
r === void 0 && (r = {});
const {
placement: a = "bottom",
strategy: t = "absolute",
middleware: e = [],
platform: n,
elements: {
reference: o,
floating: i
} = {},
transform: s = !0,
whileElementsMounted: l,
open: c
} = r, [d, p] = W.useState({
x: 0,
y: 0,
strategy: t,
placement: a,
middlewareData: {},
isPositioned: !1
}), [u, f] = W.useState(e);
Ht(u, e) || f(e);
const [v, h] = W.useState(null), [m, y] = W.useState(null), R = W.useCallback((Y) => {
Y !== w.current && (w.current = Y, h(Y));
}, []), S = W.useCallback((Y) => {
Y !== k.current && (k.current = Y, y(Y));
}, []), E = o || v, M = i || m, w = W.useRef(null), k = W.useRef(null), _ = W.useRef(d), P = l != null, A = ir(l), g = ir(n), N = ir(c), T = W.useCallback(() => {
if (!w.current || !k.current)
return;
const Y = {
placement: a,
strategy: t,
middleware: u
};
g.current && (Y.platform = g.current), xa(w.current, k.current, Y).then((q) => {
const C = {
...q,
// 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: N.current !== !1
};
O.current && !Ht(_.current, C) && (_.current = C, Do.flushSync(() => {
p(C);
}));
});
}, [u, a, t, g, N]);
Ft(() => {
c === !1 && _.current.isPositioned && (_.current.isPositioned = !1, p((Y) => ({
...Y,
isPositioned: !1
})));
}, [c]);
const O = W.useRef(!1);
Ft(() => (O.current = !0, () => {
O.current = !1;
}), []), Ft(() => {
if (E && (w.current = E), M && (k.current = M), E && M) {
if (A.current)
return A.current(E, M, T);
T();
}
}, [E, M, T, A, P]);
const x = W.useMemo(() => ({
reference: w,
floating: k,
setReference: R,
setFloating: S
}), [R, S]), F = W.useMemo(() => ({
reference: E,
floating: M
}), [E, M]), L = W.useMemo(() => {
const Y = {
position: t,
left: 0,
top: 0
};
if (!F.floating)
return Y;
const q = Qr(F.floating, d.x), C = Qr(F.floating, d.y);
return s ? {
...Y,
transform: "translate(" + q + "px, " + C + "px)",
...Bn(F.floating) >= 1.5 && {
willChange: "transform"
}
} : {
position: t,
left: q,
top: C
};
}, [t, s, F.floating, d.x, d.y]);
return W.useMemo(() => ({
...d,
update: T,
refs: x,
elements: F,
floatingStyles: L
}), [d, T, x, F, L]);
}
const Ta = (r) => {
function a(t) {
return {}.hasOwnProperty.call(t, "current");
}
return {
name: "arrow",
options: r,
fn(t) {
const {
element: e,
padding: n
} = typeof r == "function" ? r(t) : r;
return e && a(e) ? e.current != null ? Ur({
element: e.current,
padding: n
}).fn(t) : {} : e ? Ur({
element: e,
padding: n
}).fn(t) : {};
}
};
}, Ra = (r, a) => ({
...ka(r),
options: [r, a]
}), Oa = (r, a) => ({
...Sa(r),
options: [r, a]
}), Fa = (r, a) => ({
...Ta(r),
options: [r, a]
}), Na = {
...W
};
let zr = !1, Ia = 0;
const Kr = () => (
// Ensure the id is unique with multiple independent versions of Floating UI
// on <React 18
"floating-ui-" + Math.random().toString(36).slice(2, 6) + Ia++
);
function Pa() {
const [r, a] = W.useState(() => zr ? Kr() : void 0);
return Vt(() => {
r == null && a(Kr());
}, []), W.useEffect(() => {
zr = !0;
}, []), r;
}
const La = Na.useId, $n = La || Pa;
let ht;
process.env.NODE_ENV !== "production" && (ht = /* @__PURE__ */ new Set());
function Aa() {
for (var r, a = arguments.length, t = new Array(a), e = 0; e < a; e++)
t[e] = arguments[e];
const n = "Floating UI: " + t.join(" ");
if (!((r = ht) != null && r.has(n))) {
var o;
(o = ht) == null || o.add(n), console.warn(n);
}
}
function Ya() {
for (var r, a = arguments.length, t = new Array(a), e = 0; e < a; e++)
t[e] = arguments[e];
const n = "Floating UI: " + t.join(" ");
if (!((r = ht) != null && r.has(n))) {
var o;
(o = ht) == null || o.add(n), console.error(n);
}
}
const ja = /* @__PURE__ */ W.forwardRef(function(a, t) {
const {
context: {
placement: e,
elements: {
floating: n
},
middlewareData: {
arrow: o,
shift: i
}
},
width: s = 14,
height: l = 7,
tipRadius: c = 0,
strokeWidth: d = 0,
staticOffset: p,
stroke: u,
d: f,
style: {
transform: v,
...h
} = {},
...m
} = a;
process.env.NODE_ENV !== "production" && (t || Aa("The `ref` prop is required for `FloatingArrow`."));
const y = $n(), [R, S] = W.useState(!1);
if (Vt(() => {
if (!n) return;
fe(n).direction === "rtl" && S(!0);
}, [n]), !n)
return null;
const [E, M] = e.split("-"), w = E === "top" || E === "bottom";
let k = p;
(w && i != null && i.x || !w && i != null && i.y) && (k = null);
const _ = d * 2, P = _ / 2, A = s / 2 * (c / -8 + 1), g = l / 2 * c / 4, N = !!f, T = k && M === "end" ? "bottom" : "top";
let O = k && M === "end" ? "right" : "left";
k && R && (O = M === "end" ? "left" : "right");
const x = (o == null ? void 0 : o.x) != null ? k || o.x : "", F = (o == null ? void 0 : o.y) != null ? k || o.y : "", L = f || "M0,0" + (" H" + s) + (" L" + (s - A) + "," + (l - g)) + (" Q" + s / 2 + "," + l + " " + A + "," + (l - g)) + " Z", Y = {
top: N ? "rotate(180deg)" : "",
left: N ? "rotate(90deg)" : "rotate(-90deg)",
bottom: N ? "" : "rotate(180deg)",
right: N ? "rotate(-90deg)" : "rotate(90deg)"
}[E];
return /* @__PURE__ */ b.jsxs("svg", {
...m,
"aria-hidden": !0,
ref: t,
width: N ? s : s + _,
height: s,
viewBox: "0 0 " + s + " " + (l > s ? l : s),
style: {
position: "absolute",
pointerEvents: "none",
[O]: x,
[T]: F,
[E]: w || N ? "100%" : "calc(100% - " + _ / 2 + "px)",
transform: [Y, v].filter((q) => !!q).join(" "),
...h
},
children: [_ > 0 && /* @__PURE__ */ b.jsx("path", {
clipPath: "url(#" + y + ")",
fill: "none",
stroke: u,
strokeWidth: _ + (f ? 0 : 1),
d: L
}), /* @__PURE__ */ b.jsx("path", {
stroke: _ && !f ? m.fill : "none",
d: L
}), /* @__PURE__ */ b.jsx("clipPath", {
id: y,
children: /* @__PURE__ */ b.jsx("rect", {
x: -P,
y: P * (N ? -1 : 1),
width: s + _,
height: s
})
})]
});
});
function Wa() {
const r = /* @__PURE__ */ new Map();
return {
emit(a, t) {
var e;
(e = r.get(a)) == null || e.forEach((n) => n(t));
},
on(a, t) {
r.has(a) || r.set(a, /* @__PURE__ */ new Set()), r.get(a).add(t);
},
off(a, t) {
var e;
(e = r.get(a)) == null || e.delete(t);
}
};
}
const Ba = /* @__PURE__ */ W.createContext(null), $a = /* @__PURE__ */ W.createContext(null), Va = () => {
var r;
return ((r = W.useContext(Ba)) == null ? void 0 : r.id) || null;
}, Ha = () => W.useContext($a);
function Ua(r) {
const {
open: a = !1,
onOpenChange: t,
elements: e
} = r, n = $n(), o = W.useRef({}), [i] = W.useState(() => Wa()), s = Va() != null;
if (process.env.NODE_ENV !== "production") {
const f = e.reference;
f && !ae(f) && Ya("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
}
const [l, c] = W.useState(e.reference), d = ea((f, v, h) => {
o.current.openEvent = f ? v : void 0, i.emit("openchange", {
open: f,
event: v,
reason: h,
nested: s
}), t == null || t(f, v, h);
}), p = W.useMemo(() => ({
setPositionReference: c
}), []), u = W.useMemo(() => ({
reference: l || e.reference || null,
floating: e.floating || null,
domReference: e.reference
}), [l, e.reference, e.floating]);
return W.useMemo(() => ({
dataRef: o,
open: a,
onOpenChange: d,
elements: u,
events: i,
floatingId: n,
refs: p
}), [a, d, u, i, n, p]);
}
function Qa(r) {
r === void 0 && (r = {});
const {
nodeId: a
} = r, t = Ua({
...r,
elements: {
reference: null,
floating: null,
...r.elements
}
}), e = r.roo