strapi-plugin-navigation
Version:
Strapi - Navigation plugin
1,754 lines (1,753 loc) • 1.35 MB
JavaScript
import * as y from "react";
import $e, { useRef as te, useEffect as J, useMemo as Pe, useCallback as ue, createContext as ti, createElement as M, useContext as go, forwardRef as A, Children as Gr, isValidElement as tl, cloneElement as ku, Fragment as Ul, useState as Z, useLayoutEffect as jl, useReducer as im, useImperativeHandle as K3 } from "react";
import { jsx as h, jsxs as L, Fragment as mt } from "react/jsx-runtime";
import fn, { useTheme as R, css as we, styled as N, keyframes as bt, ThemeProvider as G3, createGlobalStyle as Y3 } from "styled-components";
import { getFetchClient as Ue, useRBAC as X3, Form as Kl, useNotification as mo, Layouts as Bi, useStrapiApp as Q3, Page as br, useAuth as Z3 } from "@strapi/strapi/admin";
import { useDrop as J3, useDrag as ex, DndProvider as tx } from "react-dnd";
import { HTML5Backend as nx } from "react-dnd-html5-backend";
import { Routes as rx, Route as V0 } from "react-router-dom";
import * as bo from "react-dom";
import ix, { flushSync as om, createPortal as sm } from "react-dom";
import { once as ox, isEmpty as Tt, orderBy as sx, capitalize as am, get as vt, first as Tu, isObject as Ts, isNil as Yi, isString as Gl, set as Yl, sortBy as Ms, isNumber as _0, isBoolean as ax, isNull as lx, isArray as cx } from "lodash";
import { useQuery as Dr, useMutation as Vn, useQueryClient as ar, QueryClient as lm, QueryClientProvider as cm } from "@tanstack/react-query";
import { useIntl as me } from "react-intl";
import { Field as Le, usePluginTheme as dm, prefixPluginTranslations as H0, flattenObject as P0 } from "@sensinum/strapi-utils";
import * as I from "zod";
import { z as P } from "zod";
import { prop as nl } from "lodash/fp";
const en = "navigation", dx = ({ setPlugin: t }) => {
const e = te(t);
return J(() => {
e.current?.(en);
}, []), null;
}, hx = 92, ux = fn.svg`
path {
fill: ${({ theme: t }) => t.colors.neutral500};
}
`, fx = ({ width: t = 20, height: e = 20 }) => /* @__PURE__ */ h(
ux,
{
viewBox: `0 0 ${t} ${e}`,
xmlns: "http://www.w3.org/2000/svg",
height: e,
width: t,
children: /* @__PURE__ */ h("g", { style: { transform: `scale(${t / hx})` }, children: /* @__PURE__ */ h(
"path",
{
d: `M78,23.5H14c-3.6,0-6.5-2.9-6.5-6.5s2.9-6.5,6.5-6.5h64c3.6,0,6.5,2.9,6.5,6.5S81.6,23.5,78,23.5z M84.5,46
c0-3.6-2.9-6.5-6.5-6.5H14c-3.6,0-6.5,2.9-6.5,6.5s2.9,6.5,6.5,6.5h64C81.6,52.5,84.5,49.6,84.5,46z M84.5,75c0-3.6-2.9-6.5-6.5-6.5
H14c-3.6,0-6.5,2.9-6.5,6.5s2.9,6.5,6.5,6.5h64C81.6,81.5,84.5,78.6,84.5,75z`
}
) })
}
), px = () => /* @__PURE__ */ h(fx, {});
function tt(t) {
const e = te(t);
return J(() => {
e.current = t;
}), Pe(
() => (...n) => {
var r;
return (r = e.current) === null || r === void 0 ? void 0 : r.call(e, ...n);
},
[]
);
}
function Yc(t, e) {
return t - e * Math.floor(t / e);
}
const hm = 1721426;
function Zs(t, e, n, r) {
e = Mu(t, e);
let i = e - 1, o = -2;
return n <= 2 ? o = 0 : _a(e) && (o = -1), hm - 1 + 365 * i + Math.floor(i / 4) - Math.floor(i / 100) + Math.floor(i / 400) + Math.floor((367 * n - 362) / 12 + o + r);
}
function _a(t) {
return t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0);
}
function Mu(t, e) {
return t === "BC" ? 1 - e : e;
}
function gx(t) {
let e = "AD";
return t <= 0 && (e = "BC", t = 1 - t), [
e,
t
];
}
const mx = {
standard: [
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
],
leapyear: [
31,
29,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
]
};
class Xi {
fromJulianDay(e) {
let n = e, r = n - hm, i = Math.floor(r / 146097), o = Yc(r, 146097), s = Math.floor(o / 36524), a = Yc(o, 36524), l = Math.floor(a / 1461), c = Yc(a, 1461), d = Math.floor(c / 365), u = i * 400 + s * 100 + l * 4 + d + (s !== 4 && d !== 4 ? 1 : 0), [f, p] = gx(u), g = n - Zs(f, p, 1, 1), m = 2;
n < Zs(f, p, 3, 1) ? m = 0 : _a(p) && (m = 1);
let b = Math.floor(((g + m) * 12 + 373) / 367), v = n - Zs(f, p, b, 1) + 1;
return new ns(f, p, b, v);
}
toJulianDay(e) {
return Zs(e.era, e.year, e.month, e.day);
}
getDaysInMonth(e) {
return mx[_a(e.year) ? "leapyear" : "standard"][e.month - 1];
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getMonthsInYear(e) {
return 12;
}
getDaysInYear(e) {
return _a(e.year) ? 366 : 365;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getYearsInEra(e) {
return 9999;
}
getEras() {
return [
"BC",
"AD"
];
}
isInverseEra(e) {
return e.era === "BC";
}
balanceDate(e) {
e.year <= 0 && (e.era = e.era === "BC" ? "AD" : "BC", e.year = 1 - e.year);
}
constructor() {
this.identifier = "gregory";
}
}
const bx = {
"001": 1,
AD: 1,
AE: 6,
AF: 6,
AI: 1,
AL: 1,
AM: 1,
AN: 1,
AR: 1,
AT: 1,
AU: 1,
AX: 1,
AZ: 1,
BA: 1,
BE: 1,
BG: 1,
BH: 6,
BM: 1,
BN: 1,
BY: 1,
CH: 1,
CL: 1,
CM: 1,
CN: 1,
CR: 1,
CY: 1,
CZ: 1,
DE: 1,
DJ: 6,
DK: 1,
DZ: 6,
EC: 1,
EE: 1,
EG: 6,
ES: 1,
FI: 1,
FJ: 1,
FO: 1,
FR: 1,
GB: 1,
GE: 1,
GF: 1,
GP: 1,
GR: 1,
HR: 1,
HU: 1,
IE: 1,
IQ: 6,
IR: 6,
IS: 1,
IT: 1,
JO: 6,
KG: 1,
KW: 6,
KZ: 1,
LB: 1,
LI: 1,
LK: 1,
LT: 1,
LU: 1,
LV: 1,
LY: 6,
MC: 1,
MD: 1,
ME: 1,
MK: 1,
MN: 1,
MQ: 1,
MV: 5,
MY: 1,
NL: 1,
NO: 1,
NZ: 1,
OM: 6,
PL: 1,
QA: 6,
RE: 1,
RO: 1,
RS: 1,
RU: 1,
SD: 6,
SE: 1,
SI: 1,
SK: 1,
SM: 1,
SY: 6,
TJ: 1,
TM: 1,
TR: 1,
UA: 1,
UY: 1,
UZ: 1,
VA: 1,
VN: 1,
XK: 1
};
function um(t, e) {
return e = on(e, t.calendar), t.era === e.era && t.year === e.year && t.month === e.month && t.day === e.day;
}
function fm(t, e) {
let n = t.calendar.toJulianDay(t), r = Math.ceil(n + 1 - $x(e)) % 7;
return r < 0 && (r += 7), r;
}
function vx(t) {
return Zn(Date.now(), t);
}
function Iu(t) {
return wm(vx(t));
}
function pm(t, e) {
return t.calendar.toJulianDay(t) - e.calendar.toJulianDay(e);
}
function wx(t, e) {
return z0(t) - z0(e);
}
function z0(t) {
return t.hour * 36e5 + t.minute * 6e4 + t.second * 1e3 + t.millisecond;
}
let Xc = null;
function Qi() {
return Xc == null && (Xc = new Intl.DateTimeFormat().resolvedOptions().timeZone), Xc;
}
function yx(t) {
return t.subtract({
days: t.day - 1
});
}
function xx(t) {
return t.add({
days: t.calendar.getDaysInMonth(t) - t.day
});
}
function gm(t, e) {
let n = fm(t, e);
return t.subtract({
days: n
});
}
const W0 = /* @__PURE__ */ new Map();
function Cx(t) {
if (Intl.Locale) {
let n = W0.get(t);
return n || (n = new Intl.Locale(t).maximize().region, n && W0.set(t, n)), n;
}
let e = t.split("-")[1];
return e === "u" ? void 0 : e;
}
function $x(t) {
let e = Cx(t);
return e && bx[e] || 0;
}
function Qd(t, e) {
return t && e ? t.compare(e) <= 0 ? t : e : t || e;
}
function Zd(t, e) {
return t && e ? t.compare(e) >= 0 ? t : e : t || e;
}
function Zi(t) {
t = on(t, new Xi());
let e = Mu(t.era, t.year);
return mm(e, t.month, t.day, t.hour, t.minute, t.second, t.millisecond);
}
function mm(t, e, n, r, i, o, s) {
let a = /* @__PURE__ */ new Date();
return a.setUTCHours(r, i, o, s), a.setUTCFullYear(t, e - 1, n), a.getTime();
}
function Jd(t, e) {
if (e === "UTC") return 0;
if (t > 0 && e === Qi()) return new Date(t).getTimezoneOffset() * -6e4;
let { year: n, month: r, day: i, hour: o, minute: s, second: a } = bm(t, e);
return mm(n, r, i, o, s, a, 0) - Math.floor(t / 1e3) * 1e3;
}
const q0 = /* @__PURE__ */ new Map();
function bm(t, e) {
let n = q0.get(e);
n || (n = new Intl.DateTimeFormat("en-US", {
timeZone: e,
hour12: !1,
era: "short",
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric"
}), q0.set(e, n));
let r = n.formatToParts(new Date(t)), i = {};
for (let o of r) o.type !== "literal" && (i[o.type] = o.value);
return {
// Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253
year: i.era === "BC" || i.era === "B" ? -i.year + 1 : +i.year,
month: +i.month,
day: +i.day,
hour: i.hour === "24" ? 0 : +i.hour,
minute: +i.minute,
second: +i.second
};
}
const U0 = 864e5;
function Sx(t, e, n, r) {
return (n === r ? [
n
] : [
n,
r
]).filter((o) => Ax(t, e, o));
}
function Ax(t, e, n) {
let r = bm(n, e);
return t.year === r.year && t.month === r.month && t.day === r.day && t.hour === r.hour && t.minute === r.minute && t.second === r.second;
}
function Xn(t, e, n = "compatible") {
let r = ni(t);
if (e === "UTC") return Zi(r);
if (e === Qi() && n === "compatible") {
r = on(r, new Xi());
let l = /* @__PURE__ */ new Date(), c = Mu(r.era, r.year);
return l.setFullYear(c, r.month - 1, r.day), l.setHours(r.hour, r.minute, r.second, r.millisecond), l.getTime();
}
let i = Zi(r), o = Jd(i - U0, e), s = Jd(i + U0, e), a = Sx(r, e, i - o, i - s);
if (a.length === 1) return a[0];
if (a.length > 1) switch (n) {
case "compatible":
case "earlier":
return a[0];
case "later":
return a[a.length - 1];
case "reject":
throw new RangeError("Multiple possible absolute times found");
}
switch (n) {
case "earlier":
return Math.min(i - o, i - s);
case "compatible":
case "later":
return Math.max(i - o, i - s);
case "reject":
throw new RangeError("No such absolute time found");
}
}
function vm(t, e, n = "compatible") {
return new Date(Xn(t, e, n));
}
function Zn(t, e) {
let n = Jd(t, e), r = new Date(t + n), i = r.getUTCFullYear(), o = r.getUTCMonth() + 1, s = r.getUTCDate(), a = r.getUTCHours(), l = r.getUTCMinutes(), c = r.getUTCSeconds(), d = r.getUTCMilliseconds();
return new Ji(i, o, s, e, n, a, l, c, d);
}
function wm(t) {
return new ns(t.calendar, t.era, t.year, t.month, t.day);
}
function ni(t, e) {
let n = 0, r = 0, i = 0, o = 0;
if ("timeZone" in t) ({ hour: n, minute: r, second: i, millisecond: o } = t);
else if ("hour" in t && !e) return t;
return e && ({ hour: n, minute: r, second: i, millisecond: o } = e), new il(t.calendar, t.era, t.year, t.month, t.day, n, r, i, o);
}
function on(t, e) {
if (t.calendar.identifier === e.identifier) return t;
let n = e.fromJulianDay(t.calendar.toJulianDay(t)), r = t.copy();
return r.calendar = e, r.era = n.era, r.year = n.year, r.month = n.month, r.day = n.day, ri(r), r;
}
function kx(t, e, n) {
if (t instanceof Ji)
return t.timeZone === e ? t : ym(t, e);
let r = Xn(t, e, n);
return Zn(r, e);
}
function Tx(t) {
let e = Zi(t) - t.offset;
return new Date(e);
}
function ym(t, e) {
let n = Zi(t) - t.offset;
return on(Zn(n, e), t.calendar);
}
const Do = 36e5;
function Xl(t, e) {
let n = t.copy(), r = "hour" in n ? Ex(n, e) : 0;
eh(n, e.years || 0), n.calendar.balanceYearMonth && n.calendar.balanceYearMonth(n, t), n.month += e.months || 0, th(n), xm(n), n.day += (e.weeks || 0) * 7, n.day += e.days || 0, n.day += r, Mx(n), n.calendar.balanceDate && n.calendar.balanceDate(n), n.year < 1 && (n.year = 1, n.month = 1, n.day = 1);
let i = n.calendar.getYearsInEra(n);
if (n.year > i) {
var o, s;
let l = (o = (s = n.calendar).isInverseEra) === null || o === void 0 ? void 0 : o.call(s, n);
n.year = i, n.month = l ? 1 : n.calendar.getMonthsInYear(n), n.day = l ? 1 : n.calendar.getDaysInMonth(n);
}
n.month < 1 && (n.month = 1, n.day = 1);
let a = n.calendar.getMonthsInYear(n);
return n.month > a && (n.month = a, n.day = n.calendar.getDaysInMonth(n)), n.day = Math.max(1, Math.min(n.calendar.getDaysInMonth(n), n.day)), n;
}
function eh(t, e) {
var n, r;
!((n = (r = t.calendar).isInverseEra) === null || n === void 0) && n.call(r, t) && (e = -e), t.year += e;
}
function th(t) {
for (; t.month < 1; )
eh(t, -1), t.month += t.calendar.getMonthsInYear(t);
let e = 0;
for (; t.month > (e = t.calendar.getMonthsInYear(t)); )
t.month -= e, eh(t, 1);
}
function Mx(t) {
for (; t.day < 1; )
t.month--, th(t), t.day += t.calendar.getDaysInMonth(t);
for (; t.day > t.calendar.getDaysInMonth(t); )
t.day -= t.calendar.getDaysInMonth(t), t.month++, th(t);
}
function xm(t) {
t.month = Math.max(1, Math.min(t.calendar.getMonthsInYear(t), t.month)), t.day = Math.max(1, Math.min(t.calendar.getDaysInMonth(t), t.day));
}
function ri(t) {
t.calendar.constrainDate && t.calendar.constrainDate(t), t.year = Math.max(1, Math.min(t.calendar.getYearsInEra(t), t.year)), xm(t);
}
function Cm(t) {
let e = {};
for (let n in t) typeof t[n] == "number" && (e[n] = -t[n]);
return e;
}
function $m(t, e) {
return Xl(t, Cm(e));
}
function Ru(t, e) {
let n = t.copy();
return e.era != null && (n.era = e.era), e.year != null && (n.year = e.year), e.month != null && (n.month = e.month), e.day != null && (n.day = e.day), ri(n), n;
}
function rl(t, e) {
let n = t.copy();
return e.hour != null && (n.hour = e.hour), e.minute != null && (n.minute = e.minute), e.second != null && (n.second = e.second), e.millisecond != null && (n.millisecond = e.millisecond), Rx(n), n;
}
function Ix(t) {
t.second += Math.floor(t.millisecond / 1e3), t.millisecond = Js(t.millisecond, 1e3), t.minute += Math.floor(t.second / 60), t.second = Js(t.second, 60), t.hour += Math.floor(t.minute / 60), t.minute = Js(t.minute, 60);
let e = Math.floor(t.hour / 24);
return t.hour = Js(t.hour, 24), e;
}
function Rx(t) {
t.millisecond = Math.max(0, Math.min(t.millisecond, 1e3)), t.second = Math.max(0, Math.min(t.second, 59)), t.minute = Math.max(0, Math.min(t.minute, 59)), t.hour = Math.max(0, Math.min(t.hour, 23));
}
function Js(t, e) {
let n = t % e;
return n < 0 && (n += e), n;
}
function Ex(t, e) {
return t.hour += e.hours || 0, t.minute += e.minutes || 0, t.second += e.seconds || 0, t.millisecond += e.milliseconds || 0, Ix(t);
}
function Eu(t, e, n, r) {
let i = t.copy();
switch (e) {
case "era": {
let a = t.calendar.getEras(), l = a.indexOf(t.era);
if (l < 0) throw new Error("Invalid era: " + t.era);
l = Jn(l, n, 0, a.length - 1, r?.round), i.era = a[l], ri(i);
break;
}
case "year":
var o, s;
!((o = (s = i.calendar).isInverseEra) === null || o === void 0) && o.call(s, i) && (n = -n), i.year = Jn(t.year, n, -1 / 0, 9999, r?.round), i.year === -1 / 0 && (i.year = 1), i.calendar.balanceYearMonth && i.calendar.balanceYearMonth(i, t);
break;
case "month":
i.month = Jn(t.month, n, 1, t.calendar.getMonthsInYear(t), r?.round);
break;
case "day":
i.day = Jn(t.day, n, 1, t.calendar.getDaysInMonth(t), r?.round);
break;
default:
throw new Error("Unsupported field " + e);
}
return t.calendar.balanceDate && t.calendar.balanceDate(i), ri(i), i;
}
function Sm(t, e, n, r) {
let i = t.copy();
switch (e) {
case "hour": {
let o = t.hour, s = 0, a = 23;
if (r?.hourCycle === 12) {
let l = o >= 12;
s = l ? 12 : 0, a = l ? 23 : 11;
}
i.hour = Jn(o, n, s, a, r?.round);
break;
}
case "minute":
i.minute = Jn(t.minute, n, 0, 59, r?.round);
break;
case "second":
i.second = Jn(t.second, n, 0, 59, r?.round);
break;
case "millisecond":
i.millisecond = Jn(t.millisecond, n, 0, 999, r?.round);
break;
default:
throw new Error("Unsupported field " + e);
}
return i;
}
function Jn(t, e, n, r, i = !1) {
if (i) {
t += Math.sign(e), t < n && (t = r);
let o = Math.abs(e);
e > 0 ? t = Math.ceil(t / o) * o : t = Math.floor(t / o) * o, t > r && (t = n);
} else
t += e, t < n ? t = r - (n - t - 1) : t > r && (t = n + (t - r - 1));
return t;
}
function Am(t, e) {
let n;
if (e.years != null && e.years !== 0 || e.months != null && e.months !== 0 || e.weeks != null && e.weeks !== 0 || e.days != null && e.days !== 0) {
let i = Xl(ni(t), {
years: e.years,
months: e.months,
weeks: e.weeks,
days: e.days
});
n = Xn(i, t.timeZone);
} else
n = Zi(t) - t.offset;
n += e.milliseconds || 0, n += (e.seconds || 0) * 1e3, n += (e.minutes || 0) * 6e4, n += (e.hours || 0) * 36e5;
let r = Zn(n, t.timeZone);
return on(r, t.calendar);
}
function Dx(t, e) {
return Am(t, Cm(e));
}
function Ox(t, e, n, r) {
switch (e) {
case "hour": {
let i = 0, o = 23;
if (r?.hourCycle === 12) {
let g = t.hour >= 12;
i = g ? 12 : 0, o = g ? 23 : 11;
}
let s = ni(t), a = on(rl(s, {
hour: i
}), new Xi()), l = [
Xn(a, t.timeZone, "earlier"),
Xn(a, t.timeZone, "later")
].filter((g) => Zn(g, t.timeZone).day === a.day)[0], c = on(rl(s, {
hour: o
}), new Xi()), d = [
Xn(c, t.timeZone, "earlier"),
Xn(c, t.timeZone, "later")
].filter((g) => Zn(g, t.timeZone).day === c.day).pop(), u = Zi(t) - t.offset, f = Math.floor(u / Do), p = u % Do;
return u = Jn(f, n, Math.floor(l / Do), Math.floor(d / Do), r?.round) * Do + p, on(Zn(u, t.timeZone), t.calendar);
}
case "minute":
case "second":
case "millisecond":
return Sm(t, e, n, r);
case "era":
case "year":
case "month":
case "day": {
let i = Eu(ni(t), e, n, r), o = Xn(i, t.timeZone);
return on(Zn(o, t.timeZone), t.calendar);
}
default:
throw new Error("Unsupported field " + e);
}
}
function Lx(t, e, n) {
let r = ni(t), i = rl(Ru(r, e), e);
if (i.compare(r) === 0) return t;
let o = Xn(i, t.timeZone, n);
return on(Zn(o, t.timeZone), t.calendar);
}
const Nx = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;
function km(t, e) {
let n = t.match(Nx);
if (!n) throw new Error("Invalid ISO 8601 date time string: " + t);
let r = new Ji(jn(n[1], 1, 9999), jn(n[2], 1, 12), 1, e, 0, n[4] ? jn(n[4], 0, 23) : 0, n[5] ? jn(n[5], 0, 59) : 0, n[6] ? jn(n[6], 0, 59) : 0, n[7] ? jn(n[7], 0, 1 / 0) * 1e3 : 0);
r.day = jn(n[3], 0, r.calendar.getDaysInMonth(r));
var i;
return n[8] && (r.offset = jn(n[8], -23, 23) * 36e5 + jn((i = n[9]) !== null && i !== void 0 ? i : "0", 0, 59) * 6e4), ym(r, e);
}
function Bx(t) {
return km(t, Qi());
}
function jn(t, e, n) {
let r = Number(t);
if (r < e || r > n) throw new RangeError(`Value out of range: ${e} <= ${r} <= ${n}`);
return r;
}
function Fx(t) {
return `${String(t.hour).padStart(2, "0")}:${String(t.minute).padStart(2, "0")}:${String(t.second).padStart(2, "0")}${t.millisecond ? String(t.millisecond / 1e3).slice(1) : ""}`;
}
function Tm(t) {
let e = on(t, new Xi());
return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
}
function Mm(t) {
return `${Tm(t)}T${Fx(t)}`;
}
function Vx(t) {
let e = Math.sign(t) < 0 ? "-" : "+";
t = Math.abs(t);
let n = Math.floor(t / 36e5), r = t % 36e5 / 6e4;
return `${e}${String(n).padStart(2, "0")}:${String(r).padStart(2, "0")}`;
}
function _x(t) {
return `${Mm(t)}${Vx(t.offset)}[${t.timeZone}]`;
}
function Hx(t, e) {
if (e.has(t))
throw new TypeError("Cannot initialize the same private elements twice on an object");
}
function Du(t, e, n) {
Hx(t, e), e.set(t, n);
}
function Ou(t) {
let e = typeof t[0] == "object" ? t.shift() : new Xi(), n;
if (typeof t[0] == "string") n = t.shift();
else {
let s = e.getEras();
n = s[s.length - 1];
}
let r = t.shift(), i = t.shift(), o = t.shift();
return [
e,
n,
r,
i,
o
];
}
var Px = /* @__PURE__ */ new WeakMap();
class ns {
/** Returns a copy of this date. */
copy() {
return this.era ? new ns(this.calendar, this.era, this.year, this.month, this.day) : new ns(this.calendar, this.year, this.month, this.day);
}
/** Returns a new `CalendarDate` with the given duration added to it. */
add(e) {
return Xl(this, e);
}
/** Returns a new `CalendarDate` with the given duration subtracted from it. */
subtract(e) {
return $m(this, e);
}
/** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */
set(e) {
return Ru(this, e);
}
/**
* Returns a new `CalendarDate` with the given field adjusted by a specified amount.
* When the resulting value reaches the limits of the field, it wraps around.
*/
cycle(e, n, r) {
return Eu(this, e, n, r);
}
/** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */
toDate(e) {
return vm(this, e);
}
/** Converts the date to an ISO 8601 formatted string. */
toString() {
return Tm(this);
}
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
compare(e) {
return pm(this, e);
}
constructor(...e) {
Du(this, Px, {
writable: !0,
value: void 0
});
let [n, r, i, o, s] = Ou(e);
this.calendar = n, this.era = r, this.year = i, this.month = o, this.day = s, ri(this);
}
}
var zx = /* @__PURE__ */ new WeakMap();
class il {
/** Returns a copy of this date. */
copy() {
return this.era ? new il(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond) : new il(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
}
/** Returns a new `CalendarDateTime` with the given duration added to it. */
add(e) {
return Xl(this, e);
}
/** Returns a new `CalendarDateTime` with the given duration subtracted from it. */
subtract(e) {
return $m(this, e);
}
/** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
set(e) {
return Ru(rl(this, e), e);
}
/**
* Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.
* When the resulting value reaches the limits of the field, it wraps around.
*/
cycle(e, n, r) {
switch (e) {
case "era":
case "year":
case "month":
case "day":
return Eu(this, e, n, r);
default:
return Sm(this, e, n, r);
}
}
/** Converts the date to a native JavaScript Date object in the given time zone. */
toDate(e, n) {
return vm(this, e, n);
}
/** Converts the date to an ISO 8601 formatted string. */
toString() {
return Mm(this);
}
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
compare(e) {
let n = pm(this, e);
return n === 0 ? wx(this, ni(e)) : n;
}
constructor(...e) {
Du(this, zx, {
writable: !0,
value: void 0
});
let [n, r, i, o, s] = Ou(e);
this.calendar = n, this.era = r, this.year = i, this.month = o, this.day = s, this.hour = e.shift() || 0, this.minute = e.shift() || 0, this.second = e.shift() || 0, this.millisecond = e.shift() || 0, ri(this);
}
}
var Wx = /* @__PURE__ */ new WeakMap();
class Ji {
/** Returns a copy of this date. */
copy() {
return this.era ? new Ji(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond) : new Ji(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
}
/** Returns a new `ZonedDateTime` with the given duration added to it. */
add(e) {
return Am(this, e);
}
/** Returns a new `ZonedDateTime` with the given duration subtracted from it. */
subtract(e) {
return Dx(this, e);
}
/** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
set(e, n) {
return Lx(this, e, n);
}
/**
* Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.
* When the resulting value reaches the limits of the field, it wraps around.
*/
cycle(e, n, r) {
return Ox(this, e, n, r);
}
/** Converts the date to a native JavaScript Date object. */
toDate() {
return Tx(this);
}
/** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */
toString() {
return _x(this);
}
/** Converts the date to an ISO 8601 formatted string in UTC. */
toAbsoluteString() {
return this.toDate().toISOString();
}
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
compare(e) {
return this.toDate().getTime() - kx(e, this.timeZone).toDate().getTime();
}
constructor(...e) {
Du(this, Wx, {
writable: !0,
value: void 0
});
let [n, r, i, o, s] = Ou(e), a = e.shift(), l = e.shift();
this.calendar = n, this.era = r, this.year = i, this.month = o, this.day = s, this.timeZone = a, this.offset = l, this.hour = e.shift() || 0, this.minute = e.shift() || 0, this.second = e.shift() || 0, this.millisecond = e.shift() || 0, ri(this);
}
}
let Qc = /* @__PURE__ */ new Map();
class qx {
/** Formats a date as a string according to the locale and format options passed to the constructor. */
format(e) {
return this.formatter.format(e);
}
/** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */
formatToParts(e) {
return this.formatter.formatToParts(e);
}
/** Formats a date range as a string. */
formatRange(e, n) {
if (typeof this.formatter.formatRange == "function")
return this.formatter.formatRange(e, n);
if (n < e) throw new RangeError("End date must be >= start date");
return `${this.formatter.format(e)} – ${this.formatter.format(n)}`;
}
/** Formats a date range as an array of parts. */
formatRangeToParts(e, n) {
if (typeof this.formatter.formatRangeToParts == "function")
return this.formatter.formatRangeToParts(e, n);
if (n < e) throw new RangeError("End date must be >= start date");
let r = this.formatter.formatToParts(e), i = this.formatter.formatToParts(n);
return [
...r.map((o) => ({
...o,
source: "startRange"
})),
{
type: "literal",
value: " – ",
source: "shared"
},
...i.map((o) => ({
...o,
source: "endRange"
}))
];
}
/** Returns the resolved formatting options based on the values passed to the constructor. */
resolvedOptions() {
let e = this.formatter.resolvedOptions();
return Kx() && (this.resolvedHourCycle || (this.resolvedHourCycle = Gx(e.locale, this.options)), e.hourCycle = this.resolvedHourCycle, e.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12"), e.calendar === "ethiopic-amete-alem" && (e.calendar = "ethioaa"), e;
}
constructor(e, n = {}) {
this.formatter = Im(e, n), this.options = n;
}
}
const Ux = {
true: {
// Only Japanese uses the h11 style for 12 hour time. All others use h12.
ja: "h11"
},
false: {}
};
function Im(t, e = {}) {
if (typeof e.hour12 == "boolean" && jx()) {
e = {
...e
};
let i = Ux[String(e.hour12)][t.split("-")[0]], o = e.hour12 ? "h12" : "h23";
e.hourCycle = i ?? o, delete e.hour12;
}
let n = t + (e ? Object.entries(e).sort((i, o) => i[0] < o[0] ? -1 : 1).join() : "");
if (Qc.has(n)) return Qc.get(n);
let r = new Intl.DateTimeFormat(t, e);
return Qc.set(n, r), r;
}
let Zc = null;
function jx() {
return Zc == null && (Zc = new Intl.DateTimeFormat("en-US", {
hour: "numeric",
hour12: !1
}).format(new Date(2020, 2, 3, 0)) === "24"), Zc;
}
let Jc = null;
function Kx() {
return Jc == null && (Jc = new Intl.DateTimeFormat("fr", {
hour: "numeric",
hour12: !1
}).resolvedOptions().hourCycle === "h12"), Jc;
}
function Gx(t, e) {
if (!e.timeStyle && !e.hour) return;
t = t.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, ""), t += (t.includes("-u-") ? "" : "-u") + "-nu-latn";
let n = Im(t, {
...e,
timeZone: void 0
// use local timezone
}), r = parseInt(n.formatToParts(new Date(2020, 2, 3, 0)).find((o) => o.type === "hour").value, 10), i = parseInt(n.formatToParts(new Date(2020, 2, 3, 23)).find((o) => o.type === "hour").value, 10);
if (r === 0 && i === 23) return "h23";
if (r === 24 && i === 23) return "h24";
if (r === 0 && i === 11) return "h11";
if (r === 12 && i === 11) return "h12";
throw new Error("Unexpected hour cycle result");
}
function H() {
return H = Object.assign ? Object.assign.bind() : function(t) {
for (var e = 1; e < arguments.length; e++) {
var n = arguments[e];
for (var r in n) ({}).hasOwnProperty.call(n, r) && (t[r] = n[r]);
}
return t;
}, H.apply(null, arguments);
}
function Y(t, e, { checkForDefaultPrevented: n = !0 } = {}) {
return function(i) {
if (t?.(i), n === !1 || !i.defaultPrevented) return e?.(i);
};
}
function Yx(t, e) {
typeof t == "function" ? t(e) : t != null && (t.current = e);
}
function Ql(...t) {
return (e) => t.forEach(
(n) => Yx(n, e)
);
}
function pe(...t) {
return ue(Ql(...t), t);
}
function Lu(t, e) {
const n = /* @__PURE__ */ ti(e);
function r(o) {
const { children: s, ...a } = o, l = Pe(
() => a,
Object.values(a)
);
return /* @__PURE__ */ M(n.Provider, {
value: l
}, s);
}
function i(o) {
const s = go(n);
if (s) return s;
if (e !== void 0) return e;
throw new Error(`\`${o}\` must be used within \`${t}\``);
}
return r.displayName = t + "Provider", [
r,
i
];
}
function Je(t, e = []) {
let n = [];
function r(o, s) {
const a = /* @__PURE__ */ ti(s), l = n.length;
n = [
...n,
s
];
function c(u) {
const { scope: f, children: p, ...g } = u, m = f?.[t][l] || a, b = Pe(
() => g,
Object.values(g)
);
return /* @__PURE__ */ M(m.Provider, {
value: b
}, p);
}
function d(u, f) {
const p = f?.[t][l] || a, g = go(p);
if (g) return g;
if (s !== void 0) return s;
throw new Error(`\`${u}\` must be used within \`${o}\``);
}
return c.displayName = o + "Provider", [
c,
d
];
}
const i = () => {
const o = n.map((s) => /* @__PURE__ */ ti(s));
return function(a) {
const l = a?.[t] || o;
return Pe(
() => ({
[`__scope${t}`]: {
...a,
[t]: l
}
}),
[
a,
l
]
);
};
};
return i.scopeName = t, [
r,
Xx(i, ...e)
];
}
function Xx(...t) {
const e = t[0];
if (t.length === 1) return e;
const n = () => {
const r = t.map(
(i) => ({
useScope: i(),
scopeName: i.scopeName
})
);
return function(o) {
const s = r.reduce((a, { useScope: l, scopeName: c }) => {
const u = l(o)[`__scope${c}`];
return {
...a,
...u
};
}, {});
return Pe(
() => ({
[`__scope${e.scopeName}`]: s
}),
[
s
]
);
};
};
return n.scopeName = e.scopeName, n;
}
const On = /* @__PURE__ */ A((t, e) => {
const { children: n, ...r } = t, i = Gr.toArray(n), o = i.find(Qx);
if (o) {
const s = o.props.children, a = i.map((l) => l === o ? Gr.count(s) > 1 ? Gr.only(null) : /* @__PURE__ */ tl(s) ? s.props.children : null : l);
return /* @__PURE__ */ M(nh, H({}, r, {
ref: e
}), /* @__PURE__ */ tl(s) ? /* @__PURE__ */ ku(s, void 0, a) : null);
}
return /* @__PURE__ */ M(nh, H({}, r, {
ref: e
}), n);
});
On.displayName = "Slot";
const nh = /* @__PURE__ */ A((t, e) => {
const { children: n, ...r } = t;
return /* @__PURE__ */ tl(n) ? /* @__PURE__ */ ku(n, {
...Zx(r, n.props),
ref: e ? Ql(e, n.ref) : n.ref
}) : Gr.count(n) > 1 ? Gr.only(null) : null;
});
nh.displayName = "SlotClone";
const Nu = ({ children: t }) => /* @__PURE__ */ M(Ul, null, t);
function Qx(t) {
return /* @__PURE__ */ tl(t) && t.type === Nu;
}
function Zx(t, e) {
const n = {
...e
};
for (const r in e) {
const i = t[r], o = e[r];
/^on[A-Z]/.test(r) ? i && o ? n[r] = (...a) => {
o(...a), i(...a);
} : i && (n[r] = i) : r === "style" ? n[r] = {
...i,
...o
} : r === "className" && (n[r] = [
i,
o
].filter(Boolean).join(" "));
}
return {
...t,
...n
};
}
const Jx = [
"a",
"button",
"div",
"form",
"h2",
"h3",
"img",
"input",
"label",
"li",
"nav",
"ol",
"p",
"span",
"svg",
"ul"
], de = Jx.reduce((t, e) => {
const n = /* @__PURE__ */ A((r, i) => {
const { asChild: o, ...s } = r, a = o ? On : e;
return J(() => {
window[Symbol.for("radix-ui")] = !0;
}, []), /* @__PURE__ */ M(a, H({}, s, {
ref: i
}));
});
return n.displayName = `Primitive.${e}`, {
...t,
[e]: n
};
}, {});
function e6(t, e) {
t && om(
() => t.dispatchEvent(e)
);
}
function t6(t, e = globalThis?.document) {
const n = tt(t);
J(() => {
const r = (i) => {
i.key === "Escape" && n(i);
};
return e.addEventListener("keydown", r), () => e.removeEventListener("keydown", r);
}, [
n,
e
]);
}
const rh = "dismissableLayer.update", n6 = "dismissableLayer.pointerDownOutside", r6 = "dismissableLayer.focusOutside";
let j0;
const i6 = /* @__PURE__ */ ti({
layers: /* @__PURE__ */ new Set(),
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
branches: /* @__PURE__ */ new Set()
}), fi = /* @__PURE__ */ A((t, e) => {
var n;
const { disableOutsidePointerEvents: r = !1, onEscapeKeyDown: i, onPointerDownOutside: o, onFocusOutside: s, onInteractOutside: a, onDismiss: l, ...c } = t, d = go(i6), [u, f] = Z(null), p = (n = u?.ownerDocument) !== null && n !== void 0 ? n : globalThis?.document, [, g] = Z({}), m = pe(
e,
(D) => f(D)
), b = Array.from(d.layers), [v] = [
...d.layersWithOutsidePointerEventsDisabled
].slice(-1), w = b.indexOf(v), x = u ? b.indexOf(u) : -1, C = d.layersWithOutsidePointerEventsDisabled.size > 0, $ = x >= w, S = o6((D) => {
const E = D.target, O = [
...d.branches
].some(
(V) => V.contains(E)
);
!$ || O || (o?.(D), a?.(D), D.defaultPrevented || l?.());
}, p), k = s6((D) => {
const E = D.target;
[
...d.branches
].some(
(V) => V.contains(E)
) || (s?.(D), a?.(D), D.defaultPrevented || l?.());
}, p);
return t6((D) => {
x === d.layers.size - 1 && (i?.(D), !D.defaultPrevented && l && (D.preventDefault(), l()));
}, p), J(() => {
if (u)
return r && (d.layersWithOutsidePointerEventsDisabled.size === 0 && (j0 = p.body.style.pointerEvents, p.body.style.pointerEvents = "none"), d.layersWithOutsidePointerEventsDisabled.add(u)), d.layers.add(u), K0(), () => {
r && d.layersWithOutsidePointerEventsDisabled.size === 1 && (p.body.style.pointerEvents = j0);
};
}, [
u,
p,
r,
d
]), J(() => () => {
u && (d.layers.delete(u), d.layersWithOutsidePointerEventsDisabled.delete(u), K0());
}, [
u,
d
]), J(() => {
const D = () => g({});
return document.addEventListener(rh, D), () => document.removeEventListener(rh, D);
}, []), /* @__PURE__ */ M(de.div, H({}, c, {
ref: m,
style: {
pointerEvents: C ? $ ? "auto" : "none" : void 0,
...t.style
},
onFocusCapture: Y(t.onFocusCapture, k.onFocusCapture),
onBlurCapture: Y(t.onBlurCapture, k.onBlurCapture),
onPointerDownCapture: Y(t.onPointerDownCapture, S.onPointerDownCapture)
}));
});
function o6(t, e = globalThis?.document) {
const n = tt(t), r = te(!1), i = te(() => {
});
return J(() => {
const o = (a) => {
if (a.target && !r.current) {
let c = function() {
Rm(n6, n, l, {
discrete: !0
});
};
const l = {
originalEvent: a
};
a.pointerType === "touch" ? (e.removeEventListener("click", i.current), i.current = c, e.addEventListener("click", i.current, {
once: !0
})) : c();
} else
e.removeEventListener("click", i.current);
r.current = !1;
}, s = window.setTimeout(() => {
e.addEventListener("pointerdown", o);
}, 0);
return () => {
window.clearTimeout(s), e.removeEventListener("pointerdown", o), e.removeEventListener("click", i.current);
};
}, [
e,
n
]), {
// ensures we check React component tree (not just DOM tree)
onPointerDownCapture: () => r.current = !0
};
}
function s6(t, e = globalThis?.document) {
const n = tt(t), r = te(!1);
return J(() => {
const i = (o) => {
o.target && !r.current && Rm(r6, n, {
originalEvent: o
}, {
discrete: !1
});
};
return e.addEventListener("focusin", i), () => e.removeEventListener("focusin", i);
}, [
e,
n
]), {
onFocusCapture: () => r.current = !0,
onBlurCapture: () => r.current = !1
};
}
function K0() {
const t = new CustomEvent(rh);
document.dispatchEvent(t);
}
function Rm(t, e, n, { discrete: r }) {
const i = n.originalEvent.target, o = new CustomEvent(t, {
bubbles: !1,
cancelable: !0,
detail: n
});
e && i.addEventListener(t, e, {
once: !0
}), r ? e6(i, o) : i.dispatchEvent(o);
}
const a6 = fi, qe = globalThis?.document ? jl : () => {
}, l6 = y.useId || (() => {
});
let c6 = 0;
function gt(t) {
const [e, n] = y.useState(l6());
return qe(() => {
n(
(r) => r ?? String(c6++)
);
}, [
t
]), e ? `radix-${e}` : "";
}
const d6 = ["top", "right", "bottom", "left"], Sr = Math.min, Ut = Math.max, ol = Math.round, ea = Math.floor, In = (t) => ({
x: t,
y: t
}), h6 = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, u6 = {
start: "end",
end: "start"
};
function ih(t, e, n) {
return Ut(t, Sr(e, n));
}
function nr(t, e) {
return typeof t == "function" ? t(e) : t;
}
function rr(t) {
return t.split("-")[0];
}
function vo(t) {
return t.split("-")[1];
}
function Bu(t) {
return t === "x" ? "y" : "x";
}
function Fu(t) {
return t === "y" ? "height" : "width";
}
const f6 = /* @__PURE__ */ new Set(["top", "bottom"]);
function An(t) {
return f6.has(rr(t)) ? "y" : "x";
}
function Vu(t) {
return Bu(An(t));
}
function p6(t, e, n) {
n === void 0 && (n = !1);
const r = vo(t), i = Vu(t), o = Fu(i);
let s = i === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
return e.reference[o] > e.floating[o] && (s = sl(s)), [s, sl(s)];
}
function g6(t) {
const e = sl(t);
return [oh(t), e, oh(e)];
}
function oh(t) {
return t.replace(/start|end/g, (e) => u6[e]);
}
const G0 = ["left", "right"], Y0 = ["right", "left"], m6 = ["top", "bottom"], b6 = ["bottom", "top"];
function v6(t, e, n) {
switch (t) {
case "top":
case "bottom":
return n ? e ? Y0 : G0 : e ? G0 : Y0;
case "left":
case "right":
return e ? m6 : b6;
default:
return [];
}
}
function w6(t, e, n, r) {
const i = vo(t);
let o = v6(rr(t), n === "start", r);
return i && (o = o.map((s) => s + "-" + i), e && (o = o.concat(o.map(oh)))), o;
}
function sl(t) {
return t.replace(/left|right|bottom|top/g, (e) => h6[e]);
}
function y6(t) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...t
};
}
function Em(t) {
return typeof t != "number" ? y6(t) : {
top: t,
right: t,
bottom: t,
left: t
};
}
function al(t) {
const {
x: e,
y: n,
width: r,
height: i
} = t;
return {
width: r,
height: i,
top: n,
left: e,
right: e + r,
bottom: n + i,
x: e,
y: n
};
}
function X0(t, e, n) {
let {
reference: r,
floating: i
} = t;
const o = An(e), s = Vu(e), a = Fu(s), l = rr(e), c = o === "y", d = r.x + r.width / 2 - i.width / 2, u = r.y + r.height / 2 - i.height / 2, f = r[a] / 2 - i[a] / 2;
let p;
switch (l) {
case "top":
p = {
x: d,
y: r.y - i.height
};
break;
case "bottom":
p = {
x: d,
y: r.y + r.height
};
break;
case "right":
p = {
x: r.x + r.width,
y: u
};
break;
case "left":
p = {
x: r.x - i.width,
y: u
};
break;
default:
p = {
x: r.x,
y: r.y
};
}
switch (vo(e)) {
case "start":
p[s] -= f * (n && c ? -1 : 1);
break;
case "end":
p[s] += f * (n && c ? -1 : 1);
break;
}
return p;
}
const x6 = async (t, e, n) => {
const {
placement: r = "bottom",
strategy: i = "absolute",
middleware: o = [],
platform: s
} = n, a = o.filter(Boolean), l = await (s.isRTL == null ? void 0 : s.isRTL(e));
let c = await s.getElementRects({
reference: t,
floating: e,
strategy: i
}), {
x: d,
y: u
} = X0(c, r, l), f = r, p = {}, g = 0;
for (let m = 0; m < a.length; m++) {
const {
name: b,
fn: v
} = a[m], {
x: w,
y: x,
data: C,
reset: $
} = await v({
x: d,
y: u,
initialPlacement: r,
placement: f,
strategy: i,
middlewareData: p,
rects: c,
platform: s,
elements: {
reference: t,
floating: e
}
});
d = w ?? d, u = x ?? u, p = {
...p,
[b]: {
...p[b],
...C
}
}, $ && g <= 50 && (g++, typeof $ == "object" && ($.placement && (f = $.placement), $.rects && (c = $.rects === !0 ? await s.getElementRects({
reference: t,
floating: e,
strategy: i
}) : $.rects), {
x: d,
y: u
} = X0(c, f, l)), m = -1);
}
return {
x: d,
y: u,
placement: f,
strategy: i,
middlewareData: p
};
};
async function rs(t, e) {
var n;
e === void 0 && (e = {});
const {
x: r,
y: i,
platform: o,
rects: s,
elements: a,
strategy: l
} = t, {
boundary: c = "clippingAncestors",
rootBoundary: d = "viewport",
elementContext: u = "floating",
altBoundary: f = !1,
padding: p = 0
} = nr(e, t), g = Em(p), b = a[f ? u === "floating" ? "reference" : "floating" : u], v = al(await o.getClippingRect({
element: (n = await (o.isElement == null ? void 0 : o.isElement(b))) == null || n ? b : b.contextElement || await (o.getDocumentElement == null ? void 0 : o.getDocumentElement(a.floating)),
boundary: c,
rootBoundary: d,
strategy: l
})), w = u === "floating" ? {
x: r,
y: i,
width: s.floating.width,
height: s.floating.height
} : s.reference, x = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(a.floating)), C = await (o.isElement == null ? void 0 : o.isElement(x)) ? await (o.getScale == null ? void 0 : o.getScale(x)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, $ = al(o.convertOffsetParentRelativeRectToViewportRelativeRect ? await o.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: a,
rect: w,
offsetParent: x,
strategy: l
}) : w);
return {
top: (v.top - $.top + g.top) / C.y,
bottom: ($.bottom - v.bottom + g.bottom) / C.y,
left: (v.left - $.left + g.left) / C.x,
right: ($.right - v.right + g.right) / C.x
};
}
const C6 = (t) => ({
name: "arrow",
options: t,
async fn(e) {
const {
x: n,
y: r,
placement: i,
rects: o,
platform: s,
elements: a,
middlewareData: l
} = e, {
element: c,
padding: d = 0
} = nr(t, e) || {};
if (c == null)
return {};
const u = Em(d), f = {
x: n,
y: r
}, p = Vu(i), g = Fu(p), m = await s.getDimensions(c), b = p === "y", v = b ? "top" : "left", w = b ? "bottom" : "right", x = b ? "clientHeight" : "clientWidth", C = o.reference[g] + o.reference[p] - f[p] - o.floating[g], $ = f[p] - o.reference[p], S = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c));
let k = S ? S[x] : 0;
(!k || !await (s.isElement == null ? void 0 : s.isElement(S))) && (k = a.floating[x] || o.floating[g]);
const D = C / 2 - $ / 2, E = k / 2 - m[g] / 2 - 1, O = Sr(u[v], E), V = Sr(u[w], E), B = O, q = k - m[g] - V, z = k / 2 - m[g] / 2 + D, K = ih(B, z, q), Q = !l.arrow && vo(i) != null && z !== K && o.reference[g] / 2 - (z < B ? O : V) - m[g] / 2 < 0, j = Q ? z < B ? z - B : z - q : 0;
return {
[p]: f[p] + j,
data: {
[p]: K,
centerOffset: z - K - j,
...Q && {
alignmentOffset: j
}
},
reset: Q
};
}
}), $6 = function(t) {
return t === void 0 && (t = {}), {
name: "flip",
options: t,
async fn(e) {
var n, r;
const {
placement: i,
middlewareData: o,
rects: s,
initialPlacement: a,
platform: l,
elements: c
} = e, {
mainAxis: d = !0,
crossAxis: u = !0,
fallbackPlacements: f,
fallbackStrategy: p = "bestFit",
fallbackAxisSideDirection: g = "none",
flipAlignment: m = !0,
...b
} = nr(t, e);
if ((n = o.arrow) != null && n.alignmentOffset)
return {};
const v = rr(i), w = An(a), x = rr(a) === a, C = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), $ = f || (x || !m ? [sl(a)] : g6(a)), S = g !== "none";
!f && S && $.push(...w6(a, m, g, C));
const k = [a, ...$], D = await rs(e, b), E = [];
let O = ((r = o.flip) == null ? void 0 : r.overflows) || [];
if (d && E.push(D[v]), u) {
const z = p6(i, s, C);
E.push(D[z[0]], D[z[1]]);
}
if (O = [...O, {
placement: i,
overflows: E
}], !E.every((z) => z <= 0)) {
var V, B;
const z = (((V = o.flip) == null ? void 0 : V.index) || 0) + 1, K = k[z];
if (K && (!(u === "alignment" ? w !== An(K) : !1) || // We leave the current main axis only if every placement on that axis
// overflows the main axis.
O.every((W) => An(W.placement) === w ? W.overflows[0] > 0 : !0)))
return {
data: {
index: z,
overflows: O
},
reset: {
placement: K
}
};
let Q = (B = O.filter((j) => j.overflows[0] <= 0).sort((j, W) => j.overflows[1] - W.overflows[1])[0]) == null ? void 0 : B.placement;
if (!Q)
switch (p) {
case "bestFit": {
var q;
const j = (q = O.filter((W) => {
if (S) {
const F = An(W.placement);
return F === w || // Create a bias to the `y` side axis due to horizontal
// reading directions favoring greater width.
F === "y";
}
return !0;
}).map((W) => [W.placement, W.overflows.filter((F) => F > 0).reduce((F, ne) => F + ne, 0)]).sort((W, F) => W[1] - F[1])[0]) == null ? void 0 : q[0];
j && (Q = j);
break;
}
case "initialPlacement":
Q = a;
break;
}
if (i !== Q)
return {
reset: {
placement: Q
}
};
}
return {};
}
};
};
function Q0(t, e) {
return {
top: t.top - e.height,
right: t.right - e.width,
bottom: t.bottom - e.height,
left: t.left - e.width
};
}
function Z0(t) {
return d6.some((e) => t[e] >= 0);
}
const S6 = function(t) {
return t === void 0 && (t = {}), {
name: "hide",
options: t,
async fn(e) {
const {
rects: n
} = e, {
strategy: r = "referenceHidden",
...i
} = nr(t, e);
switch (r) {
case "referenceHidden": {
const o = await rs(e, {
...i,
elementContext: "reference"
}), s = Q0(o, n.reference);
return {
data: {
referenceHiddenOffsets: s,
referenceHidden: Z0(s)
}
};
}
case "escaped": {
const o = await rs(e, {
...i,
altBoundary: !0
}), s = Q0(o, n.floating);
return {
data: {
escapedOffsets: s,
escaped: Z0(s)
}
};
}
default:
return {};
}
}
};
}, Dm = /* @__PURE__ */ new Set(["left", "top"]);
async function A6(t, e) {
const {
placement: n,
platform: r,
elements: i
} = t, o = await (r.isRTL == null ? void 0 : r.isRTL(i.floating)), s = rr(n), a = vo(n), l = An(n) === "y", c = Dm.has(s) ? -1 : 1, d = o && l ? -1 : 1, u = nr(e, t);
let {
mainAxis: f,
crossAxis: p,
alignmentAxis: g
} = typeof u == "number" ? {
mainAxis: u,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: u.mainAxis || 0,
crossAxis: u.crossAxis || 0,
alignmentAxis: u.alignmentAxis
};
return a && typeof g == "number" && (p = a === "end" ? g * -1 : g), l ? {
x: p * d,
y: f * c
} : {
x: f * c,
y: p * d
};
}
const k6 = function(t) {
return t === void 0 && (t = 0), {
name: "offset",
options: t,
async fn(e) {
var n, r;
const {
x: i,
y: o,
placement: s,
middlewareData: a
} = e, l = await A6(e, t);
return s === ((n = a.offset) == null ? void 0 : n.placement) && (r = a.arrow) != null && r.alignmentOffset ? {} : {
x: i + l.x,
y: o + l.y,