@angeluxee/cerberus-calendar
Version:
A highly configurable React calendar component with day, week, and month views
1,688 lines • 211 kB
JavaScript
import { jsx as u, Fragment as ye, jsxs as M } from "react/jsx-runtime";
import * as d from "react";
import De, { useLayoutEffect as ni, useEffect as fe, useState as Q, useRef as ct } from "react";
import { format as oi, startOfWeek as zr, addDays as Jt, startOfMonth as ii, endOfMonth as si, endOfWeek as ai, subMonths as ci, addMonths as li, subWeeks as di, addWeeks as ui, subDays as fi, isSameDay as pi, isWithinInterval as Bt, startOfDay as gi, endOfDay as bi, isSameMonth as vi, isToday as mi } from "date-fns";
import { es as yi } from "date-fns/locale";
import { cva as er } from "class-variance-authority";
import { clsx as hi } from "clsx";
import { twMerge as xi } from "tailwind-merge";
import * as xt from "react-dom";
import jr from "react-dom";
import { ChevronDown as Ur, ChevronUp as wi, Check as Ci, ChevronLeft as Si, ChevronRight as Ni, X as Ei } from "lucide-react";
const X = (e, t) => oi(e, t, { locale: yi }), Ri = (e) => {
const t = zr(e, { weekStartsOn: 1 }), n = [];
for (let o = 0; o < 7; o++)
n.push(Jt(t, o));
return n;
}, ki = (e) => {
const t = ii(e), n = si(e), o = zr(t, { weekStartsOn: 1 }), i = ai(n, { weekStartsOn: 1 }), r = [];
let s = o;
for (; s <= i; )
r.push(s), s = Jt(s, 1);
return r;
}, Di = (e, t, n) => {
switch (n) {
case "day":
return t === "prev" ? fi(e, 1) : Jt(e, 1);
case "week":
return t === "prev" ? di(e, 1) : ui(e, 1);
case "month":
return t === "prev" ? ci(e, 1) : li(e, 1);
default:
return e;
}
}, ft = (e, t) => e.filter((n) => n.allDay ? pi(n.start, t) : Bt(t, { start: gi(n.start), end: bi(n.end) })), Fl = (e, t, n) => e.filter((o) => Bt(o.start, { start: t, end: n }) || Bt(o.end, { start: t, end: n }) || o.start <= t && o.end >= n), Kr = (e = 0, t = 24, n = 30) => {
const o = [];
for (let i = e; i < t; i++)
for (let r = 0; r < 60; r += n)
o.push({
hour: i,
minute: r,
date: new Date(0, 0, 0, i, r)
});
return o;
}, Ti = (e, t, n) => {
const o = new Date(e.start), i = new Date(e.end), r = o.getHours() * 60 + o.getMinutes(), s = i.getHours() * 60 + i.getMinutes(), a = t * 60, c = (r - a) / 60 * n, l = (s - r) / 60 * n;
return { top: Math.max(0, c), height: Math.max(30, l) };
}, Hl = (e, t = 30) => {
const n = e.getMinutes(), o = Math.round(n / t) * t;
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), o);
}, Bl = (e, t, n, o) => {
const i = e / o * 60 + n * 60, r = Math.floor(i / 60), s = i % 60;
return new Date(t.getFullYear(), t.getMonth(), t.getDate(), r, s);
};
function Pi(e, t) {
typeof e == "function" ? e(t) : e != null && (e.current = t);
}
function Yr(...e) {
return (t) => e.forEach((n) => Pi(n, t));
}
function Y(...e) {
return d.useCallback(Yr(...e), e);
}
var Pe = d.forwardRef((e, t) => {
const { children: n, ...o } = e, i = d.Children.toArray(n), r = i.find(Mi);
if (r) {
const s = r.props.children, a = i.map((c) => c === r ? d.Children.count(s) > 1 ? d.Children.only(null) : d.isValidElement(s) ? s.props.children : null : c);
return /* @__PURE__ */ u($t, { ...o, ref: t, children: d.isValidElement(s) ? d.cloneElement(s, void 0, a) : null });
}
return /* @__PURE__ */ u($t, { ...o, ref: t, children: n });
});
Pe.displayName = "Slot";
var $t = d.forwardRef((e, t) => {
const { children: n, ...o } = e;
if (d.isValidElement(n)) {
const i = Ii(n);
return d.cloneElement(n, {
...Oi(o, n.props),
// @ts-ignore
ref: t ? Yr(t, i) : i
});
}
return d.Children.count(n) > 1 ? d.Children.only(null) : null;
});
$t.displayName = "SlotClone";
var Ai = ({ children: e }) => /* @__PURE__ */ u(ye, { children: e });
function Mi(e) {
return d.isValidElement(e) && e.type === Ai;
}
function Oi(e, t) {
const n = { ...t };
for (const o in t) {
const i = e[o], r = t[o];
/^on[A-Z]/.test(o) ? i && r ? n[o] = (...a) => {
r(...a), i(...a);
} : i && (n[o] = i) : o === "style" ? n[o] = { ...i, ...r } : o === "className" && (n[o] = [i, r].filter(Boolean).join(" "));
}
return { ...e, ...n };
}
function Ii(e) {
var o, i;
let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning;
return n ? e.ref : (t = (i = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : i.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
function H(...e) {
return xi(hi(e));
}
const _i = er(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline"
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10"
}
},
defaultVariants: {
variant: "default",
size: "default"
}
}
), Te = d.forwardRef(
({ className: e, variant: t, size: n, asChild: o = !1, ...i }, r) => /* @__PURE__ */ u(
o ? Pe : "button",
{
className: H(_i({ variant: t, size: n, className: e })),
ref: r,
...i
}
)
);
Te.displayName = "Button";
function xr(e, [t, n]) {
return Math.min(n, Math.max(t, e));
}
function U(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
return function(i) {
if (e == null || e(i), n === !1 || !i.defaultPrevented)
return t == null ? void 0 : t(i);
};
}
function Li(e, t = []) {
let n = [];
function o(r, s) {
const a = d.createContext(s), c = n.length;
n = [...n, s];
function l(f) {
const { scope: b, children: v, ...y } = f, p = (b == null ? void 0 : b[e][c]) || a, m = d.useMemo(() => y, Object.values(y));
return /* @__PURE__ */ u(p.Provider, { value: m, children: v });
}
function g(f, b) {
const v = (b == null ? void 0 : b[e][c]) || a, y = d.useContext(v);
if (y) return y;
if (s !== void 0) return s;
throw new Error(`\`${f}\` must be used within \`${r}\``);
}
return l.displayName = r + "Provider", [l, g];
}
const i = () => {
const r = n.map((s) => d.createContext(s));
return function(a) {
const c = (a == null ? void 0 : a[e]) || r;
return d.useMemo(
() => ({ [`__scope${e}`]: { ...a, [e]: c } }),
[a, c]
);
};
};
return i.scopeName = e, [o, Fi(i, ...t)];
}
function Fi(...e) {
const t = e[0];
if (e.length === 1) return t;
const n = () => {
const o = e.map((i) => ({
useScope: i(),
scopeName: i.scopeName
}));
return function(r) {
const s = o.reduce((a, { useScope: c, scopeName: l }) => {
const f = c(r)[`__scope${l}`];
return { ...a, ...f };
}, {});
return d.useMemo(() => ({ [`__scope${t.scopeName}`]: s }), [s]);
};
};
return n.scopeName = t.scopeName, n;
}
function Hi(e) {
const t = e + "CollectionProvider", [n, o] = Li(t), [i, r] = n(
t,
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
), s = (v) => {
const { scope: y, children: p } = v, m = De.useRef(null), x = De.useRef(/* @__PURE__ */ new Map()).current;
return /* @__PURE__ */ u(i, { scope: y, itemMap: x, collectionRef: m, children: p });
};
s.displayName = t;
const a = e + "CollectionSlot", c = De.forwardRef(
(v, y) => {
const { scope: p, children: m } = v, x = r(a, p), h = Y(y, x.collectionRef);
return /* @__PURE__ */ u(Pe, { ref: h, children: m });
}
);
c.displayName = a;
const l = e + "CollectionItemSlot", g = "data-radix-collection-item", f = De.forwardRef(
(v, y) => {
const { scope: p, children: m, ...x } = v, h = De.useRef(null), w = Y(y, h), S = r(l, p);
return De.useEffect(() => (S.itemMap.set(h, { ref: h, ...x }), () => void S.itemMap.delete(h))), /* @__PURE__ */ u(Pe, { [g]: "", ref: w, children: m });
}
);
f.displayName = l;
function b(v) {
const y = r(e + "CollectionConsumer", v);
return De.useCallback(() => {
const m = y.collectionRef.current;
if (!m) return [];
const x = Array.from(m.querySelectorAll(`[${g}]`));
return Array.from(y.itemMap.values()).sort(
(S, N) => x.indexOf(S.ref.current) - x.indexOf(N.ref.current)
);
}, [y.collectionRef, y.itemMap]);
}
return [
{ Provider: s, Slot: c, ItemSlot: f },
b,
o
];
}
function Bi(e, t) {
const n = d.createContext(t), o = (r) => {
const { children: s, ...a } = r, c = d.useMemo(() => a, Object.values(a));
return /* @__PURE__ */ u(n.Provider, { value: c, children: s });
};
o.displayName = e + "Provider";
function i(r) {
const s = d.useContext(n);
if (s) return s;
if (t !== void 0) return t;
throw new Error(`\`${r}\` must be used within \`${e}\``);
}
return [o, i];
}
function tr(e, t = []) {
let n = [];
function o(r, s) {
const a = d.createContext(s), c = n.length;
n = [...n, s];
const l = (f) => {
var x;
const { scope: b, children: v, ...y } = f, p = ((x = b == null ? void 0 : b[e]) == null ? void 0 : x[c]) || a, m = d.useMemo(() => y, Object.values(y));
return /* @__PURE__ */ u(p.Provider, { value: m, children: v });
};
l.displayName = r + "Provider";
function g(f, b) {
var p;
const v = ((p = b == null ? void 0 : b[e]) == null ? void 0 : p[c]) || a, y = d.useContext(v);
if (y) return y;
if (s !== void 0) return s;
throw new Error(`\`${f}\` must be used within \`${r}\``);
}
return [l, g];
}
const i = () => {
const r = n.map((s) => d.createContext(s));
return function(a) {
const c = (a == null ? void 0 : a[e]) || r;
return d.useMemo(
() => ({ [`__scope${e}`]: { ...a, [e]: c } }),
[a, c]
);
};
};
return i.scopeName = e, [o, $i(i, ...t)];
}
function $i(...e) {
const t = e[0];
if (e.length === 1) return t;
const n = () => {
const o = e.map((i) => ({
useScope: i(),
scopeName: i.scopeName
}));
return function(r) {
const s = o.reduce((a, { useScope: c, scopeName: l }) => {
const f = c(r)[`__scope${l}`];
return { ...a, ...f };
}, {});
return d.useMemo(() => ({ [`__scope${t.scopeName}`]: s }), [s]);
};
};
return n.scopeName = t.scopeName, n;
}
var Wi = d.createContext(void 0);
function Vi(e) {
const t = d.useContext(Wi);
return e || t || "ltr";
}
var zi = [
"a",
"button",
"div",
"form",
"h2",
"h3",
"img",
"input",
"label",
"li",
"nav",
"ol",
"p",
"span",
"svg",
"ul"
], z = zi.reduce((e, t) => {
const n = d.forwardRef((o, i) => {
const { asChild: r, ...s } = o, a = r ? Pe : t;
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ u(a, { ...s, ref: i });
});
return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
}, {});
function ji(e, t) {
e && xt.flushSync(() => e.dispatchEvent(t));
}
function pe(e) {
const t = d.useRef(e);
return d.useEffect(() => {
t.current = e;
}), d.useMemo(() => (...n) => {
var o;
return (o = t.current) == null ? void 0 : o.call(t, ...n);
}, []);
}
function Ui(e, t = globalThis == null ? void 0 : globalThis.document) {
const n = pe(e);
d.useEffect(() => {
const o = (i) => {
i.key === "Escape" && n(i);
};
return t.addEventListener("keydown", o, { capture: !0 }), () => t.removeEventListener("keydown", o, { capture: !0 });
}, [n, t]);
}
var Ki = "DismissableLayer", Wt = "dismissableLayer.update", Yi = "dismissableLayer.pointerDownOutside", Gi = "dismissableLayer.focusOutside", wr, Gr = d.createContext({
layers: /* @__PURE__ */ new Set(),
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
branches: /* @__PURE__ */ new Set()
}), rr = d.forwardRef(
(e, t) => {
const {
disableOutsidePointerEvents: n = !1,
onEscapeKeyDown: o,
onPointerDownOutside: i,
onFocusOutside: r,
onInteractOutside: s,
onDismiss: a,
...c
} = e, l = d.useContext(Gr), [g, f] = d.useState(null), b = (g == null ? void 0 : g.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, v] = d.useState({}), y = Y(t, (k) => f(k)), p = Array.from(l.layers), [m] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), x = p.indexOf(m), h = g ? p.indexOf(g) : -1, w = l.layersWithOutsidePointerEventsDisabled.size > 0, S = h >= x, N = Zi((k) => {
const L = k.target, B = [...l.branches].some((P) => P.contains(L));
!S || B || (i == null || i(k), s == null || s(k), k.defaultPrevented || a == null || a());
}, b), I = Qi((k) => {
const L = k.target;
[...l.branches].some((P) => P.contains(L)) || (r == null || r(k), s == null || s(k), k.defaultPrevented || a == null || a());
}, b);
return Ui((k) => {
h === l.layers.size - 1 && (o == null || o(k), !k.defaultPrevented && a && (k.preventDefault(), a()));
}, b), d.useEffect(() => {
if (g)
return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && (wr = b.body.style.pointerEvents, b.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(g)), l.layers.add(g), Cr(), () => {
n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (b.body.style.pointerEvents = wr);
};
}, [g, b, n, l]), d.useEffect(() => () => {
g && (l.layers.delete(g), l.layersWithOutsidePointerEventsDisabled.delete(g), Cr());
}, [g, l]), d.useEffect(() => {
const k = () => v({});
return document.addEventListener(Wt, k), () => document.removeEventListener(Wt, k);
}, []), /* @__PURE__ */ u(
z.div,
{
...c,
ref: y,
style: {
pointerEvents: w ? S ? "auto" : "none" : void 0,
...e.style
},
onFocusCapture: U(e.onFocusCapture, I.onFocusCapture),
onBlurCapture: U(e.onBlurCapture, I.onBlurCapture),
onPointerDownCapture: U(
e.onPointerDownCapture,
N.onPointerDownCapture
)
}
);
}
);
rr.displayName = Ki;
var Xi = "DismissableLayerBranch", qi = d.forwardRef((e, t) => {
const n = d.useContext(Gr), o = d.useRef(null), i = Y(t, o);
return d.useEffect(() => {
const r = o.current;
if (r)
return n.branches.add(r), () => {
n.branches.delete(r);
};
}, [n.branches]), /* @__PURE__ */ u(z.div, { ...e, ref: i });
});
qi.displayName = Xi;
function Zi(e, t = globalThis == null ? void 0 : globalThis.document) {
const n = pe(e), o = d.useRef(!1), i = d.useRef(() => {
});
return d.useEffect(() => {
const r = (a) => {
if (a.target && !o.current) {
let c = function() {
Xr(
Yi,
n,
l,
{ discrete: !0 }
);
};
const l = { originalEvent: a };
a.pointerType === "touch" ? (t.removeEventListener("click", i.current), i.current = c, t.addEventListener("click", i.current, { once: !0 })) : c();
} else
t.removeEventListener("click", i.current);
o.current = !1;
}, s = window.setTimeout(() => {
t.addEventListener("pointerdown", r);
}, 0);
return () => {
window.clearTimeout(s), t.removeEventListener("pointerdown", r), t.removeEventListener("click", i.current);
};
}, [t, n]), {
// ensures we check React component tree (not just DOM tree)
onPointerDownCapture: () => o.current = !0
};
}
function Qi(e, t = globalThis == null ? void 0 : globalThis.document) {
const n = pe(e), o = d.useRef(!1);
return d.useEffect(() => {
const i = (r) => {
r.target && !o.current && Xr(Gi, n, { originalEvent: r }, {
discrete: !1
});
};
return t.addEventListener("focusin", i), () => t.removeEventListener("focusin", i);
}, [t, n]), {
onFocusCapture: () => o.current = !0,
onBlurCapture: () => o.current = !1
};
}
function Cr() {
const e = new CustomEvent(Wt);
document.dispatchEvent(e);
}
function Xr(e, t, n, { discrete: o }) {
const i = n.originalEvent.target, r = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
t && i.addEventListener(e, t, { once: !0 }), o ? ji(i, r) : i.dispatchEvent(r);
}
var Pt = 0;
function qr() {
d.useEffect(() => {
const e = document.querySelectorAll("[data-radix-focus-guard]");
return document.body.insertAdjacentElement("afterbegin", e[0] ?? Sr()), document.body.insertAdjacentElement("beforeend", e[1] ?? Sr()), Pt++, () => {
Pt === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((t) => t.remove()), Pt--;
};
}, []);
}
function Sr() {
const e = document.createElement("span");
return e.setAttribute("data-radix-focus-guard", ""), e.tabIndex = 0, e.style.outline = "none", e.style.opacity = "0", e.style.position = "fixed", e.style.pointerEvents = "none", e;
}
var At = "focusScope.autoFocusOnMount", Mt = "focusScope.autoFocusOnUnmount", Nr = { bubbles: !1, cancelable: !0 }, Ji = "FocusScope", nr = d.forwardRef((e, t) => {
const {
loop: n = !1,
trapped: o = !1,
onMountAutoFocus: i,
onUnmountAutoFocus: r,
...s
} = e, [a, c] = d.useState(null), l = pe(i), g = pe(r), f = d.useRef(null), b = Y(t, (p) => c(p)), v = d.useRef({
paused: !1,
pause() {
this.paused = !0;
},
resume() {
this.paused = !1;
}
}).current;
d.useEffect(() => {
if (o) {
let p = function(w) {
if (v.paused || !a) return;
const S = w.target;
a.contains(S) ? f.current = S : me(f.current, { select: !0 });
}, m = function(w) {
if (v.paused || !a) return;
const S = w.relatedTarget;
S !== null && (a.contains(S) || me(f.current, { select: !0 }));
}, x = function(w) {
if (document.activeElement === document.body)
for (const N of w)
N.removedNodes.length > 0 && me(a);
};
document.addEventListener("focusin", p), document.addEventListener("focusout", m);
const h = new MutationObserver(x);
return a && h.observe(a, { childList: !0, subtree: !0 }), () => {
document.removeEventListener("focusin", p), document.removeEventListener("focusout", m), h.disconnect();
};
}
}, [o, a, v.paused]), d.useEffect(() => {
if (a) {
Rr.add(v);
const p = document.activeElement;
if (!a.contains(p)) {
const x = new CustomEvent(At, Nr);
a.addEventListener(At, l), a.dispatchEvent(x), x.defaultPrevented || (es(is(Zr(a)), { select: !0 }), document.activeElement === p && me(a));
}
return () => {
a.removeEventListener(At, l), setTimeout(() => {
const x = new CustomEvent(Mt, Nr);
a.addEventListener(Mt, g), a.dispatchEvent(x), x.defaultPrevented || me(p ?? document.body, { select: !0 }), a.removeEventListener(Mt, g), Rr.remove(v);
}, 0);
};
}
}, [a, l, g, v]);
const y = d.useCallback(
(p) => {
if (!n && !o || v.paused) return;
const m = p.key === "Tab" && !p.altKey && !p.ctrlKey && !p.metaKey, x = document.activeElement;
if (m && x) {
const h = p.currentTarget, [w, S] = ts(h);
w && S ? !p.shiftKey && x === S ? (p.preventDefault(), n && me(w, { select: !0 })) : p.shiftKey && x === w && (p.preventDefault(), n && me(S, { select: !0 })) : x === h && p.preventDefault();
}
},
[n, o, v.paused]
);
return /* @__PURE__ */ u(z.div, { tabIndex: -1, ...s, ref: b, onKeyDown: y });
});
nr.displayName = Ji;
function es(e, { select: t = !1 } = {}) {
const n = document.activeElement;
for (const o of e)
if (me(o, { select: t }), document.activeElement !== n) return;
}
function ts(e) {
const t = Zr(e), n = Er(t, e), o = Er(t.reverse(), e);
return [n, o];
}
function Zr(e) {
const t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
acceptNode: (o) => {
const i = o.tagName === "INPUT" && o.type === "hidden";
return o.disabled || o.hidden || i ? NodeFilter.FILTER_SKIP : o.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
}
});
for (; n.nextNode(); ) t.push(n.currentNode);
return t;
}
function Er(e, t) {
for (const n of e)
if (!rs(n, { upTo: t })) return n;
}
function rs(e, { upTo: t }) {
if (getComputedStyle(e).visibility === "hidden") return !0;
for (; e; ) {
if (t !== void 0 && e === t) return !1;
if (getComputedStyle(e).display === "none") return !0;
e = e.parentElement;
}
return !1;
}
function ns(e) {
return e instanceof HTMLInputElement && "select" in e;
}
function me(e, { select: t = !1 } = {}) {
if (e && e.focus) {
const n = document.activeElement;
e.focus({ preventScroll: !0 }), e !== n && ns(e) && t && e.select();
}
}
var Rr = os();
function os() {
let e = [];
return {
add(t) {
const n = e[0];
t !== n && (n == null || n.pause()), e = kr(e, t), e.unshift(t);
},
remove(t) {
var n;
e = kr(e, t), (n = e[0]) == null || n.resume();
}
};
}
function kr(e, t) {
const n = [...e], o = n.indexOf(t);
return o !== -1 && n.splice(o, 1), n;
}
function is(e) {
return e.filter((t) => t.tagName !== "A");
}
var Z = globalThis != null && globalThis.document ? d.useLayoutEffect : () => {
}, ss = d.useId || (() => {
}), as = 0;
function Be(e) {
const [t, n] = d.useState(ss());
return Z(() => {
n((o) => o ?? String(as++));
}, [e]), t ? `radix-${t}` : "";
}
const cs = ["top", "right", "bottom", "left"], he = Math.min, ee = Math.max, pt = Math.round, tt = Math.floor, xe = (e) => ({
x: e,
y: e
}), ls = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, ds = {
start: "end",
end: "start"
};
function Vt(e, t, n) {
return ee(e, he(t, n));
}
function ge(e, t) {
return typeof e == "function" ? e(t) : e;
}
function be(e) {
return e.split("-")[0];
}
function ze(e) {
return e.split("-")[1];
}
function or(e) {
return e === "x" ? "y" : "x";
}
function ir(e) {
return e === "y" ? "height" : "width";
}
function we(e) {
return ["top", "bottom"].includes(be(e)) ? "y" : "x";
}
function sr(e) {
return or(we(e));
}
function us(e, t, n) {
n === void 0 && (n = !1);
const o = ze(e), i = sr(e), r = ir(i);
let s = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
return t.reference[r] > t.floating[r] && (s = gt(s)), [s, gt(s)];
}
function fs(e) {
const t = gt(e);
return [zt(e), t, zt(t)];
}
function zt(e) {
return e.replace(/start|end/g, (t) => ds[t]);
}
function ps(e, t, n) {
const o = ["left", "right"], i = ["right", "left"], r = ["top", "bottom"], s = ["bottom", "top"];
switch (e) {
case "top":
case "bottom":
return n ? t ? i : o : t ? o : i;
case "left":
case "right":
return t ? r : s;
default:
return [];
}
}
function gs(e, t, n, o) {
const i = ze(e);
let r = ps(be(e), n === "start", o);
return i && (r = r.map((s) => s + "-" + i), t && (r = r.concat(r.map(zt)))), r;
}
function gt(e) {
return e.replace(/left|right|bottom|top/g, (t) => ls[t]);
}
function bs(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function Qr(e) {
return typeof e != "number" ? bs(e) : {
top: e,
right: e,
bottom: e,
left: e
};
}
function bt(e) {
const {
x: t,
y: n,
width: o,
height: i
} = e;
return {
width: o,
height: i,
top: n,
left: t,
right: t + o,
bottom: n + i,
x: t,
y: n
};
}
function Dr(e, t, n) {
let {
reference: o,
floating: i
} = e;
const r = we(t), s = sr(t), a = ir(s), c = be(t), l = r === "y", g = o.x + o.width / 2 - i.width / 2, f = o.y + o.height / 2 - i.height / 2, b = o[a] / 2 - i[a] / 2;
let v;
switch (c) {
case "top":
v = {
x: g,
y: o.y - i.height
};
break;
case "bottom":
v = {
x: g,
y: o.y + o.height
};
break;
case "right":
v = {
x: o.x + o.width,
y: f
};
break;
case "left":
v = {
x: o.x - i.width,
y: f
};
break;
default:
v = {
x: o.x,
y: o.y
};
}
switch (ze(t)) {
case "start":
v[s] -= b * (n && l ? -1 : 1);
break;
case "end":
v[s] += b * (n && l ? -1 : 1);
break;
}
return v;
}
const vs = async (e, t, n) => {
const {
placement: o = "bottom",
strategy: i = "absolute",
middleware: r = [],
platform: s
} = n, a = r.filter(Boolean), c = await (s.isRTL == null ? void 0 : s.isRTL(t));
let l = await s.getElementRects({
reference: e,
floating: t,
strategy: i
}), {
x: g,
y: f
} = Dr(l, o, c), b = o, v = {}, y = 0;
for (let p = 0; p < a.length; p++) {
const {
name: m,
fn: x
} = a[p], {
x: h,
y: w,
data: S,
reset: N
} = await x({
x: g,
y: f,
initialPlacement: o,
placement: b,
strategy: i,
middlewareData: v,
rects: l,
platform: s,
elements: {
reference: e,
floating: t
}
});
g = h ?? g, f = w ?? f, v = {
...v,
[m]: {
...v[m],
...S
}
}, N && y <= 50 && (y++, typeof N == "object" && (N.placement && (b = N.placement), N.rects && (l = N.rects === !0 ? await s.getElementRects({
reference: e,
floating: t,
strategy: i
}) : N.rects), {
x: g,
y: f
} = Dr(l, b, c)), p = -1);
}
return {
x: g,
y: f,
placement: b,
strategy: i,
middlewareData: v
};
};
async function qe(e, t) {
var n;
t === void 0 && (t = {});
const {
x: o,
y: i,
platform: r,
rects: s,
elements: a,
strategy: c
} = e, {
boundary: l = "clippingAncestors",
rootBoundary: g = "viewport",
elementContext: f = "floating",
altBoundary: b = !1,
padding: v = 0
} = ge(t, e), y = Qr(v), m = a[b ? f === "floating" ? "reference" : "floating" : f], x = bt(await r.getClippingRect({
element: (n = await (r.isElement == null ? void 0 : r.isElement(m))) == null || n ? m : m.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(a.floating)),
boundary: l,
rootBoundary: g,
strategy: c
})), h = f === "floating" ? {
x: o,
y: i,
width: s.floating.width,
height: s.floating.height
} : s.reference, w = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a.floating)), S = await (r.isElement == null ? void 0 : r.isElement(w)) ? await (r.getScale == null ? void 0 : r.getScale(w)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, N = bt(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: a,
rect: h,
offsetParent: w,
strategy: c
}) : h);
return {
top: (x.top - N.top + y.top) / S.y,
bottom: (N.bottom - x.bottom + y.bottom) / S.y,
left: (x.left - N.left + y.left) / S.x,
right: (N.right - x.right + y.right) / S.x
};
}
const ms = (e) => ({
name: "arrow",
options: e,
async fn(t) {
const {
x: n,
y: o,
placement: i,
rects: r,
platform: s,
elements: a,
middlewareData: c
} = t, {
element: l,
padding: g = 0
} = ge(e, t) || {};
if (l == null)
return {};
const f = Qr(g), b = {
x: n,
y: o
}, v = sr(i), y = ir(v), p = await s.getDimensions(l), m = v === "y", x = m ? "top" : "left", h = m ? "bottom" : "right", w = m ? "clientHeight" : "clientWidth", S = r.reference[y] + r.reference[v] - b[v] - r.floating[y], N = b[v] - r.reference[v], I = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(l));
let k = I ? I[w] : 0;
(!k || !await (s.isElement == null ? void 0 : s.isElement(I))) && (k = a.floating[w] || r.floating[y]);
const L = S / 2 - N / 2, B = k / 2 - p[y] / 2 - 1, P = he(f[x], B), D = he(f[h], B), _ = P, O = k - p[y] - D, C = k / 2 - p[y] / 2 + L, A = Vt(_, C, O), E = !c.arrow && ze(i) != null && C !== A && r.reference[y] / 2 - (C < _ ? P : D) - p[y] / 2 < 0, R = E ? C < _ ? C - _ : C - O : 0;
return {
[v]: b[v] + R,
data: {
[v]: A,
centerOffset: C - A - R,
...E && {
alignmentOffset: R
}
},
reset: E
};
}
}), ys = function(e) {
return e === void 0 && (e = {}), {
name: "flip",
options: e,
async fn(t) {
var n, o;
const {
placement: i,
middlewareData: r,
rects: s,
initialPlacement: a,
platform: c,
elements: l
} = t, {
mainAxis: g = !0,
crossAxis: f = !0,
fallbackPlacements: b,
fallbackStrategy: v = "bestFit",
fallbackAxisSideDirection: y = "none",
flipAlignment: p = !0,
...m
} = ge(e, t);
if ((n = r.arrow) != null && n.alignmentOffset)
return {};
const x = be(i), h = we(a), w = be(a) === a, S = await (c.isRTL == null ? void 0 : c.isRTL(l.floating)), N = b || (w || !p ? [gt(a)] : fs(a)), I = y !== "none";
!b && I && N.push(...gs(a, p, y, S));
const k = [a, ...N], L = await qe(t, m), B = [];
let P = ((o = r.flip) == null ? void 0 : o.overflows) || [];
if (g && B.push(L[x]), f) {
const C = us(i, s, S);
B.push(L[C[0]], L[C[1]]);
}
if (P = [...P, {
placement: i,
overflows: B
}], !B.every((C) => C <= 0)) {
var D, _;
const C = (((D = r.flip) == null ? void 0 : D.index) || 0) + 1, A = k[C];
if (A)
return {
data: {
index: C,
overflows: P
},
reset: {
placement: A
}
};
let E = (_ = P.filter((R) => R.overflows[0] <= 0).sort((R, T) => R.overflows[1] - T.overflows[1])[0]) == null ? void 0 : _.placement;
if (!E)
switch (v) {
case "bestFit": {
var O;
const R = (O = P.filter((T) => {
if (I) {
const $ = we(T.placement);
return $ === h || // Create a bias to the `y` side axis due to horizontal
// reading directions favoring greater width.
$ === "y";
}
return !0;
}).map((T) => [T.placement, T.overflows.filter(($) => $ > 0).reduce(($, G) => $ + G, 0)]).sort((T, $) => T[1] - $[1])[0]) == null ? void 0 : O[0];
R && (E = R);
break;
}
case "initialPlacement":
E = a;
break;
}
if (i !== E)
return {
reset: {
placement: E
}
};
}
return {};
}
};
};
function Tr(e, t) {
return {
top: e.top - t.height,
right: e.right - t.width,
bottom: e.bottom - t.height,
left: e.left - t.width
};
}
function Pr(e) {
return cs.some((t) => e[t] >= 0);
}
const hs = function(e) {
return e === void 0 && (e = {}), {
name: "hide",
options: e,
async fn(t) {
const {
rects: n
} = t, {
strategy: o = "referenceHidden",
...i
} = ge(e, t);
switch (o) {
case "referenceHidden": {
const r = await qe(t, {
...i,
elementContext: "reference"
}), s = Tr(r, n.reference);
return {
data: {
referenceHiddenOffsets: s,
referenceHidden: Pr(s)
}
};
}
case "escaped": {
const r = await qe(t, {
...i,
altBoundary: !0
}), s = Tr(r, n.floating);
return {
data: {
escapedOffsets: s,
escaped: Pr(s)
}
};
}
default:
return {};
}
}
};
};
async function xs(e, t) {
const {
placement: n,
platform: o,
elements: i
} = e, r = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), s = be(n), a = ze(n), c = we(n) === "y", l = ["left", "top"].includes(s) ? -1 : 1, g = r && c ? -1 : 1, f = ge(t, e);
let {
mainAxis: b,
crossAxis: v,
alignmentAxis: y
} = typeof f == "number" ? {
mainAxis: f,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: f.mainAxis || 0,
crossAxis: f.crossAxis || 0,
alignmentAxis: f.alignmentAxis
};
return a && typeof y == "number" && (v = a === "end" ? y * -1 : y), c ? {
x: v * g,
y: b * l
} : {
x: b * l,
y: v * g
};
}
const ws = function(e) {
return e === void 0 && (e = 0), {
name: "offset",
options: e,
async fn(t) {
var n, o;
const {
x: i,
y: r,
placement: s,
middlewareData: a
} = t, c = await xs(t, e);
return s === ((n = a.offset) == null ? void 0 : n.placement) && (o = a.arrow) != null && o.alignmentOffset ? {} : {
x: i + c.x,
y: r + c.y,
data: {
...c,
placement: s
}
};
}
};
}, Cs = function(e) {
return e === void 0 && (e = {}), {
name: "shift",
options: e,
async fn(t) {
const {
x: n,
y: o,
placement: i
} = t, {
mainAxis: r = !0,
crossAxis: s = !1,
limiter: a = {
fn: (m) => {
let {
x,
y: h
} = m;
return {
x,
y: h
};
}
},
...c
} = ge(e, t), l = {
x: n,
y: o
}, g = await qe(t, c), f = we(be(i)), b = or(f);
let v = l[b], y = l[f];
if (r) {
const m = b === "y" ? "top" : "left", x = b === "y" ? "bottom" : "right", h = v + g[m], w = v - g[x];
v = Vt(h, v, w);
}
if (s) {
const m = f === "y" ? "top" : "left", x = f === "y" ? "bottom" : "right", h = y + g[m], w = y - g[x];
y = Vt(h, y, w);
}
const p = a.fn({
...t,
[b]: v,
[f]: y
});
return {
...p,
data: {
x: p.x - n,
y: p.y - o,
enabled: {
[b]: r,
[f]: s
}
}
};
}
};
}, Ss = function(e) {
return e === void 0 && (e = {}), {
options: e,
fn(t) {
const {
x: n,
y: o,
placement: i,
rects: r,
middlewareData: s
} = t, {
offset: a = 0,
mainAxis: c = !0,
crossAxis: l = !0
} = ge(e, t), g = {
x: n,
y: o
}, f = we(i), b = or(f);
let v = g[b], y = g[f];
const p = ge(a, t), m = typeof p == "number" ? {
mainAxis: p,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...p
};
if (c) {
const w = b === "y" ? "height" : "width", S = r.reference[b] - r.floating[w] + m.mainAxis, N = r.reference[b] + r.reference[w] - m.mainAxis;
v < S ? v = S : v > N && (v = N);
}
if (l) {
var x, h;
const w = b === "y" ? "width" : "height", S = ["top", "left"].includes(be(i)), N = r.reference[f] - r.floating[w] + (S && ((x = s.offset) == null ? void 0 : x[f]) || 0) + (S ? 0 : m.crossAxis), I = r.reference[f] + r.reference[w] + (S ? 0 : ((h = s.offset) == null ? void 0 : h[f]) || 0) - (S ? m.crossAxis : 0);
y < N ? y = N : y > I && (y = I);
}
return {
[b]: v,
[f]: y
};
}
};
}, Ns = function(e) {
return e === void 0 && (e = {}), {
name: "size",
options: e,
async fn(t) {
var n, o;
const {
placement: i,
rects: r,
platform: s,
elements: a
} = t, {
apply: c = () => {
},
...l
} = ge(e, t), g = await qe(t, l), f = be(i), b = ze(i), v = we(i) === "y", {
width: y,
height: p
} = r.floating;
let m, x;
f === "top" || f === "bottom" ? (m = f, x = b === (await (s.isRTL == null ? void 0 : s.isRTL(a.floating)) ? "start" : "end") ? "left" : "right") : (x = f, m = b === "end" ? "top" : "bottom");
const h = p - g.top - g.bottom, w = y - g.left - g.right, S = he(p - g[m], h), N = he(y - g[x], w), I = !t.middlewareData.shift;
let k = S, L = N;
if ((n = t.middlewareData.shift) != null && n.enabled.x && (L = w), (o = t.middlewareData.shift) != null && o.enabled.y && (k = h), I && !b) {
const P = ee(g.left, 0), D = ee(g.right, 0), _ = ee(g.top, 0), O = ee(g.bottom, 0);
v ? L = y - 2 * (P !== 0 || D !== 0 ? P + D : ee(g.left, g.right)) : k = p - 2 * (_ !== 0 || O !== 0 ? _ + O : ee(g.top, g.bottom));
}
await c({
...t,
availableWidth: L,
availableHeight: k
});
const B = await s.getDimensions(a.floating);
return y !== B.width || p !== B.height ? {
reset: {
rects: !0
}
} : {};
}
};
};
function wt() {
return typeof window < "u";
}
function je(e) {
return Jr(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function te(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function de(e) {
var t;
return (t = (Jr(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function Jr(e) {
return wt() ? e instanceof Node || e instanceof te(e).Node : !1;
}
function oe(e) {
return wt() ? e instanceof Element || e instanceof te(e).Element : !1;
}
function le(e) {
return wt() ? e instanceof HTMLElement || e instanceof te(e).HTMLElement : !1;
}
function Ar(e) {
return !wt() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof te(e).ShadowRoot;
}
function Qe(e) {
const {
overflow: t,
overflowX: n,
overflowY: o,
display: i
} = ie(e);
return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !["inline", "contents"].includes(i);
}
function Es(e) {
return ["table", "td", "th"].includes(je(e));
}
function Ct(e) {
return [":popover-open", ":modal"].some((t) => {
try {
return e.matches(t);
} catch {
return !1;
}
});
}
function ar(e) {
const t = cr(), n = oe(e) ? ie(e) : e;
return n.transform !== "none" || n.perspective !== "none" || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || ["transform", "perspective", "filter"].some((o) => (n.willChange || "").includes(o)) || ["paint", "layout", "strict", "content"].some((o) => (n.contain || "").includes(o));
}
function Rs(e) {
let t = Ce(e);
for (; le(t) && !Ve(t); ) {
if (ar(t))
return t;
if (Ct(t))
return null;
t = Ce(t);
}
return null;
}
function cr() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
function Ve(e) {
return ["html", "body", "#document"].includes(je(e));
}
function ie(e) {
return te(e).getComputedStyle(e);
}
function St(e) {
return oe(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function Ce(e) {
if (je(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.
Ar(e) && e.host || // Fallback.
de(e)
);
return Ar(t) ? t.host : t;
}
function en(e) {
const t = Ce(e);
return Ve(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : le(t) && Qe(t) ? t : en(t);
}
function Ze(e, t, n) {
var o;
t === void 0 && (t = []), n === void 0 && (n = !0);
const i = en(e), r = i === ((o = e.ownerDocument) == null ? void 0 : o.body), s = te(i);
if (r) {
const a = jt(s);
return t.concat(s, s.visualViewport || [], Qe(i) ? i : [], a && n ? Ze(a) : []);
}
return t.concat(i, Ze(i, [], n));
}
function jt(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
function tn(e) {
const t = ie(e);
let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
const i = le(e), r = i ? e.offsetWidth : n, s = i ? e.offsetHeight : o, a = pt(n) !== r || pt(o) !== s;
return a && (n = r, o = s), {
width: n,
height: o,
$: a
};
}
function lr(e) {
return oe(e) ? e : e.contextElement;
}
function $e(e) {
const t = lr(e);
if (!le(t))
return xe(1);
const n = t.getBoundingClientRect(), {
width: o,
height: i,
$: r
} = tn(t);
let s = (r ? pt(n.width) : n.width) / o, a = (r ? pt(n.height) : n.height) / i;
return (!s || !Number.isFinite(s)) && (s = 1), (!a || !Number.isFinite(a)) && (a = 1), {
x: s,
y: a
};
}
const ks = /* @__PURE__ */ xe(0);
function rn(e) {
const t = te(e);
return !cr() || !t.visualViewport ? ks : {
x: t.visualViewport.offsetLeft,
y: t.visualViewport.offsetTop
};
}
function Ds(e, t, n) {
return t === void 0 && (t = !1), !n || t && n !== te(e) ? !1 : t;
}
function Ae(e, t, n, o) {
t === void 0 && (t = !1), n === void 0 && (n = !1);
const i = e.getBoundingClientRect(), r = lr(e);
let s = xe(1);
t && (o ? oe(o) && (s = $e(o)) : s = $e(e));
const a = Ds(r, n, o) ? rn(r) : xe(0);
let c = (i.left + a.x) / s.x, l = (i.top + a.y) / s.y, g = i.width / s.x, f = i.height / s.y;
if (r) {
const b = te(r), v = o && oe(o) ? te(o) : o;
let y = b, p = jt(y);
for (; p && o && v !== y; ) {
const m = $e(p), x = p.getBoundingClientRect(), h = ie(p), w = x.left + (p.clientLeft + parseFloat(h.paddingLeft)) * m.x, S = x.top + (p.clientTop + parseFloat(h.paddingTop)) * m.y;
c *= m.x, l *= m.y, g *= m.x, f *= m.y, c += w, l += S, y = te(p), p = jt(y);
}
}
return bt({
width: g,
height: f,
x: c,
y: l
});
}
function Ts(e) {
let {
elements: t,
rect: n,
offsetParent: o,
strategy: i
} = e;
const r = i === "fixed", s = de(o), a = t ? Ct(t.floating) : !1;
if (o === s || a && r)
return n;
let c = {
scrollLeft: 0,
scrollTop: 0
}, l = xe(1);
const g = xe(0), f = le(o);
if ((f || !f && !r) && ((je(o) !== "body" || Qe(s)) && (c = St(o)), le(o))) {
const b = Ae(o);
l = $e(o), g.x = b.x + o.clientLeft, g.y = b.y + o.clientTop;
}
return {
width: n.width * l.x,
height: n.height * l.y,
x: n.x * l.x - c.scrollLeft * l.x + g.x,
y: n.y * l.y - c.scrollTop * l.y + g.y
};
}
function Ps(e) {
return Array.from(e.getClientRects());
}
function Ut(e, t) {
const n = St(e).scrollLeft;
return t ? t.left + n : Ae(de(e)).left + n;
}
function As(e) {
const t = de(e), n = St(e), o = e.ownerDocument.body, i = ee(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), r = ee(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
let s = -n.scrollLeft + Ut(e);
const a = -n.scrollTop;
return ie(o).direction === "rtl" && (s += ee(t.clientWidth, o.clientWidth) - i), {
width: i,
height: r,
x: s,
y: a
};
}
function Ms(e, t) {
const n = te(e), o = de(e), i = n.visualViewport;
let r = o.clientWidth, s = o.clientHeight, a = 0, c = 0;
if (i) {
r = i.width, s = i.height;
const l = cr();
(!l || l && t === "fixed") && (a = i.offsetLeft, c = i.offsetTop);
}
return {
width: r,
height: s,
x: a,
y: c
};
}
function Os(e, t) {
const n = Ae(e, !0, t === "fixed"), o = n.top + e.clientTop, i = n.left + e.clientLeft, r = le(e) ? $e(e) : xe(1), s = e.clientWidth * r.x, a = e.clientHeight * r.y, c = i * r.x, l = o * r.y;
return {
width: s,
height: a,
x: c,
y: l
};
}
function Mr(e, t, n) {
let o;
if (t === "viewport")
o = Ms(e, n);
else if (t === "document")
o = As(de(e));
else if (oe(t))
o = Os(t, n);
else {
const i = rn(e);
o = {
...t,
x: t.x - i.x,
y: t.y - i.y
};
}
return bt(o);
}
function nn(e, t) {
const n = Ce(e);
return n === t || !oe(n) || Ve(n) ? !1 : ie(n).position === "fixed" || nn(n, t);
}
function Is(e, t) {
const n = t.get(e);
if (n)
return n;
let o = Ze(e, [], !1).filter((a) => oe(a) && je(a) !== "body"), i = null;
const r = ie(e).position === "fixed";
let s = r ? Ce(e) : e;
for (; oe(s) && !Ve(s); ) {
const a = ie(s), c = ar(s);
!c && a.position === "fixed" && (i = null), (r ? !c && !i : !c && a.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || Qe(s) && !c && nn(e, s)) ? o = o.filter((g) => g !== s) : i = a, s = Ce(s);
}
return t.set(e, o), o;
}
function _s(e) {
let {
element: t,
boundary: n,
rootBoundary: o,
strategy: i
} = e;
const s = [...n === "clippingAncestors" ? Ct(t) ? [] : Is(t, this._c) : [].concat(n), o], a = s[0], c = s.reduce((l, g) => {
const f = Mr(t, g, i);
return l.top = ee(f.top, l.top), l.right = he(f.right, l.right), l.bottom = he(f.bottom, l.bottom), l.left = ee(f.left, l.left), l;
}, Mr(t, a, i));
return {
width: c.right - c.left,
height: c.bottom - c.top,
x: c.left,
y: c.top
};
}
function Ls(e) {
const {
width: t,
height: n
} = tn(e);
return {
width: t,
height: n
};
}
function Fs(e, t, n) {
const o = le(t), i = de(t), r = n === "fixed", s = Ae(e, !0, r, t);
let a = {
scrollLeft: 0,
scrollTop: 0
};
const c = xe(0);
if (o || !o && !r)
if ((je(t) !== "body" || Qe(i)) && (a = St(t)), o) {
const v = Ae(t, !0, r, t);
c.x = v.x + t.clientLeft, c.y = v.y + t.clientTop;
} else i && (c.x = Ut(i));
let l = 0, g = 0;
if (i && !o && !r) {
const v = i.getBoundingClientRect();
g = v.top + a.scrollTop, l = v.left + a.scrollLeft - // RTL <body> scrollbar.
Ut(i, v);
}
const f = s.left + a.scrollLeft - c.x - l, b = s.top + a.scrollTop - c.y - g;
return {
x: f,
y: b,
width: s.width,
height: s.height
};
}
function Ot(e) {
return ie(e).position === "static";
}
function Or(e, t) {
if (!le(e) || ie(e).position === "fixed")
return null;
if (t)
return t(e);
let n = e.offsetParent;
return de(e) === n && (n = n.ownerDocument.body), n;
}
function on(e, t) {
const n = te(e);
if (Ct(e))
return n;
if (!le(e)) {
let i = Ce(e);
for (; i && !Ve(i); ) {
if (oe(i) && !Ot(i))
return i;
i = Ce(i);
}
return n;
}
let o = Or(e, t);
for (; o && Es(o) && Ot(o); )
o = Or(o, t);
return o && Ve(o) && Ot(o) && !ar(o) ? n : o || Rs(e) || n;
}
const Hs = async function(e) {
const t = this.getOffsetParent || on, n = this.getDimensions, o = await n(e.floating);
return {
reference: Fs(e.reference, await t(e.floating), e.strategy),
floating: {
x: 0,
y: 0,
width: o.width,
height: o.height
}
};
};
function Bs(e) {
return ie(e).direction === "rtl";
}
const $s = {
convertOffsetParentRelativeRectToViewportRelativeRect: Ts,
getDocumentElement: de,
getClippingRect: _s,
getOffsetParent: on,
getElementRects: Hs,
getClientRects: Ps,
getDimensions: Ls,
getScale: $e,
isElement: oe,
isRTL: Bs
};
function Ws(e, t) {
let n = null, o;
const i = de(e);
function r() {
var a;
clearTimeout(o), (a = n) == null || a.disconnect(), n = null;
}
function s(a, c) {
a === void 0 && (a = !1), c === void 0 && (c = 1), r();
const {
left: l,
top: g,
width: f,
height: b
} = e.getBoundingClientRect();
if (a || t(), !f || !b)
return;
const v = tt(g), y = tt(i.clientWidth - (l + f)), p = tt(i.clientHeight - (g + b)), m = tt(l), h = {
rootMargin: -v + "px " + -y + "px " + -p + "px " + -m + "px",
threshold: ee(0, he(1, c)) || 1
};
let w = !0;
function S(N) {
const I = N[0].intersectionRatio;
if (I !== c) {
if (!w)
return s();
I ? s(!1, I) : o = setTimeout(() => {
s(!1, 1e-7);
}, 1e3);
}
w = !1;
}
try {
n = new IntersectionObserver(S, {
...h,
// Handle <iframe>s
root: i.ownerDocument
});
} catch {
n = new IntersectionObserver(S, h);
}
n.observe(e);
}
return s(!0), r;
}
function Vs(e, t, n, o) {
o === void 0 && (o = {});
const {
ancestorScroll: i = !0,
ancestorResize: r = !0,
elementResize: s = typeof ResizeObserver == "function",
layoutShift: a = typeof IntersectionObserver == "function",
animationFrame: c = !1
} = o, l = lr(e), g = i || r ? [...l ? Ze(l) : [], ...Ze(t)] : [];
g.forEach((x) => {
i && x.addEventListener("scroll", n, {
passive: !0
}), r && x.addEventListener("resize", n);
});
const f = l && a ? Ws(l, n) : null;
let b = -1, v = null;
s && (v = new ResizeObserver((x) => {
let [h] = x;
h && h.target === l && v && (v.unobserve(t), cancelAnimationFrame(b), b = requestAnimationFrame(() => {
var w;
(w = v) == null || w.observe(t);
})), n();
}), l && !c && v.observe(l), v.observe(t));
let y, p