UNPKG

strapi-plugin-navigation

Version:
1,753 lines 1.4 MB
import * as y from "react"; import $e, { useRef as te, useEffect as Z, useMemo as _e, useCallback as ue, createContext as ri, createElement as T, useContext as bo, forwardRef as k, Children as $r, isValidElement as ol, cloneElement as Lu, Fragment as Gl, useState as Q, useLayoutEffect as Yl, useReducer as Sg, useImperativeHandle as bx, startTransition as j0 } from "react"; import { jsx as h, jsxs as L, Fragment as dt } from "react/jsx-runtime"; import Vn, { useTheme as E, css as ve, styled as N, keyframes as bt, ThemeProvider as vx, createGlobalStyle as wx } from "styled-components"; import { getFetchClient as Ue, useRBAC as yx, Form as Xl, useNotification as vo, Layouts as _i, useStrapiApp as xx, Page as wr, useAuth as Cx } from "@strapi/strapi/admin"; import { useDrop as $x, useDrag as Sx, DndProvider as Ax } from "react-dnd"; import { HTML5Backend as kx } from "react-dnd-html5-backend"; import { Routes as Mx, Route as K0 } from "react-router-dom"; import * as wo from "react-dom"; import Tx, { flushSync as Ql, createPortal as Ix } from "react-dom"; import { once as Rx, isEmpty as Tt, orderBy as Ex, capitalize as Ag, get as vt, first as Nu, isObject as Es, isNil as Zi, isString as Zl, set as Jl, sortBy as Ds, isNumber as G0, isBoolean as Dx, isNull as Ox, isArray as Lx } from "lodash"; import { useQuery as Lr, useMutation as _n, useQueryClient as cr, QueryClient as kg, QueryClientProvider as Mg } from "@tanstack/react-query"; import { useIntl as me } from "react-intl"; import { Field as Le, usePluginTheme as Tg, prefixPluginTranslations as Y0, flattenObject as X0 } from "@sensinum/strapi-utils"; import * as I from "zod"; import { z as P } from "zod"; import { prop as sl } from "lodash/fp"; const en = "navigation", Nx = ({ setPlugin: t }) => { const e = te(t); return Z(() => { e.current?.(en); }, []), null; }, Bx = 92, Fx = Vn.svg` path { fill: ${({ theme: t }) => t.colors.neutral500}; } `, Vx = ({ width: t = 20, height: e = 20 }) => /* @__PURE__ */ h( Fx, { viewBox: `0 0 ${t} ${e}`, xmlns: "http://www.w3.org/2000/svg", height: e, width: t, children: /* @__PURE__ */ h("g", { style: { transform: `scale(${t / Bx})` }, 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` } ) }) } ), _x = () => /* @__PURE__ */ h(Vx, {}); function tt(t) { const e = te(t); return Z(() => { e.current = t; }), _e( () => (...n) => { var r; return (r = e.current) === null || r === void 0 ? void 0 : r.call(e, ...n); }, [] ); } function ed(t, e) { return t - e * Math.floor(t / e); } const Ig = 1721426; function na(t, e, n, r) { e = Bu(t, e); let i = e - 1, o = -2; return n <= 2 ? o = 0 : qa(e) && (o = -1), Ig - 1 + 365 * i + Math.floor(i / 4) - Math.floor(i / 100) + Math.floor(i / 400) + Math.floor((367 * n - 362) / 12 + o + r); } function qa(t) { return t % 4 === 0 && (t % 100 !== 0 || t % 400 === 0); } function Bu(t, e) { return t === "BC" ? 1 - e : e; } function zx(t) { let e = "AD"; return t <= 0 && (e = "BC", t = 1 - t), [ e, t ]; } const Hx = { 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 Ji { fromJulianDay(e) { let n = e, r = n - Ig, i = Math.floor(r / 146097), o = ed(r, 146097), s = Math.floor(o / 36524), a = ed(o, 36524), l = Math.floor(a / 1461), c = ed(a, 1461), d = Math.floor(c / 365), u = i * 400 + s * 100 + l * 4 + d + (s !== 4 && d !== 4 ? 1 : 0), [f, p] = zx(u), m = n - na(f, p, 1, 1), g = 2; n < na(f, p, 3, 1) ? g = 0 : qa(p) && (g = 1); let b = Math.floor(((m + g) * 12 + 373) / 367), v = n - na(f, p, b, 1) + 1; return new os(f, p, b, v); } toJulianDay(e) { return na(e.era, e.year, e.month, e.day); } getDaysInMonth(e) { return Hx[qa(e.year) ? "leapyear" : "standard"][e.month - 1]; } // eslint-disable-next-line @typescript-eslint/no-unused-vars getMonthsInYear(e) { return 12; } getDaysInYear(e) { return qa(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 Px = { "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 Rg(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 Eg(t, e) { let n = t.calendar.toJulianDay(t), r = Math.ceil(n + 1 - Gx(e)) % 7; return r < 0 && (r += 7), r; } function Wx(t) { return Jn(Date.now(), t); } function Fu(t) { return Fg(Wx(t)); } function Dg(t, e) { return t.calendar.toJulianDay(t) - e.calendar.toJulianDay(e); } function qx(t, e) { return Q0(t) - Q0(e); } function Q0(t) { return t.hour * 36e5 + t.minute * 6e4 + t.second * 1e3 + t.millisecond; } let td = null; function eo() { return td == null && (td = new Intl.DateTimeFormat().resolvedOptions().timeZone), td; } function Ux(t) { return t.subtract({ days: t.day - 1 }); } function jx(t) { return t.add({ days: t.calendar.getDaysInMonth(t) - t.day }); } function Og(t, e) { let n = Eg(t, e); return t.subtract({ days: n }); } const Z0 = /* @__PURE__ */ new Map(); function Kx(t) { if (Intl.Locale) { let n = Z0.get(t); return n || (n = new Intl.Locale(t).maximize().region, n && Z0.set(t, n)), n; } let e = t.split("-")[1]; return e === "u" ? void 0 : e; } function Gx(t) { let e = Kx(t); return e && Px[e] || 0; } function ih(t, e) { return t && e ? t.compare(e) <= 0 ? t : e : t || e; } function oh(t, e) { return t && e ? t.compare(e) >= 0 ? t : e : t || e; } function to(t) { t = on(t, new Ji()); let e = Bu(t.era, t.year); return Lg(e, t.month, t.day, t.hour, t.minute, t.second, t.millisecond); } function Lg(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 sh(t, e) { if (e === "UTC") return 0; if (t > 0 && e === eo()) return new Date(t).getTimezoneOffset() * -6e4; let { year: n, month: r, day: i, hour: o, minute: s, second: a } = Ng(t, e); return Lg(n, r, i, o, s, a, 0) - Math.floor(t / 1e3) * 1e3; } const J0 = /* @__PURE__ */ new Map(); function Ng(t, e) { let n = J0.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" }), J0.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 e1 = 864e5; function Yx(t, e, n, r) { return (n === r ? [ n ] : [ n, r ]).filter((o) => Xx(t, e, o)); } function Xx(t, e, n) { let r = Ng(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 = ii(t); if (e === "UTC") return to(r); if (e === eo() && n === "compatible") { r = on(r, new Ji()); let l = /* @__PURE__ */ new Date(), c = Bu(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 = to(r), o = sh(i - e1, e), s = sh(i + e1, e), a = Yx(r, e, i - o, i - s); if (a.length === 1) return a[0]; if (a.length > 1) switch (n) { // 'compatible' means 'earlier' for "fall back" transitions 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); // 'compatible' means 'later' for "spring forward" transitions case "compatible": case "later": return Math.max(i - o, i - s); case "reject": throw new RangeError("No such absolute time found"); } } function Bg(t, e, n = "compatible") { return new Date(Xn(t, e, n)); } function Jn(t, e) { let n = sh(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 no(i, o, s, e, n, a, l, c, d); } function Fg(t) { return new os(t.calendar, t.era, t.year, t.month, t.day); } function ii(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 ll(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, oi(r), r; } function Qx(t, e, n) { if (t instanceof no) return t.timeZone === e ? t : Vg(t, e); let r = Xn(t, e, n); return Jn(r, e); } function Zx(t) { let e = to(t) - t.offset; return new Date(e); } function Vg(t, e) { let n = to(t) - t.offset; return on(Jn(n, e), t.calendar); } const No = 36e5; function ec(t, e) { let n = t.copy(), r = "hour" in n ? n6(n, e) : 0; ah(n, e.years || 0), n.calendar.balanceYearMonth && n.calendar.balanceYearMonth(n, t), n.month += e.months || 0, lh(n), _g(n), n.day += (e.weeks || 0) * 7, n.day += e.days || 0, n.day += r, Jx(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 ah(t, e) { var n, r; !((n = (r = t.calendar).isInverseEra) === null || n === void 0) && n.call(r, t) && (e = -e), t.year += e; } function lh(t) { for (; t.month < 1; ) ah(t, -1), t.month += t.calendar.getMonthsInYear(t); let e = 0; for (; t.month > (e = t.calendar.getMonthsInYear(t)); ) t.month -= e, ah(t, 1); } function Jx(t) { for (; t.day < 1; ) t.month--, lh(t), t.day += t.calendar.getDaysInMonth(t); for (; t.day > t.calendar.getDaysInMonth(t); ) t.day -= t.calendar.getDaysInMonth(t), t.month++, lh(t); } function _g(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 oi(t) { t.calendar.constrainDate && t.calendar.constrainDate(t), t.year = Math.max(1, Math.min(t.calendar.getYearsInEra(t), t.year)), _g(t); } function zg(t) { let e = {}; for (let n in t) typeof t[n] == "number" && (e[n] = -t[n]); return e; } function Hg(t, e) { return ec(t, zg(e)); } function Vu(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), oi(n), n; } function al(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), t6(n), n; } function e6(t) { t.second += Math.floor(t.millisecond / 1e3), t.millisecond = ra(t.millisecond, 1e3), t.minute += Math.floor(t.second / 60), t.second = ra(t.second, 60), t.hour += Math.floor(t.minute / 60), t.minute = ra(t.minute, 60); let e = Math.floor(t.hour / 24); return t.hour = ra(t.hour, 24), e; } function t6(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 ra(t, e) { let n = t % e; return n < 0 && (n += e), n; } function n6(t, e) { return t.hour += e.hours || 0, t.minute += e.minutes || 0, t.second += e.seconds || 0, t.millisecond += e.milliseconds || 0, e6(t); } function _u(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 = er(l, n, 0, a.length - 1, r?.round), i.era = a[l], oi(i); break; } case "year": var o, s; !((o = (s = i.calendar).isInverseEra) === null || o === void 0) && o.call(s, i) && (n = -n), i.year = er(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 = er(t.month, n, 1, t.calendar.getMonthsInYear(t), r?.round); break; case "day": i.day = er(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), oi(i), i; } function Pg(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 = er(o, n, s, a, r?.round); break; } case "minute": i.minute = er(t.minute, n, 0, 59, r?.round); break; case "second": i.second = er(t.second, n, 0, 59, r?.round); break; case "millisecond": i.millisecond = er(t.millisecond, n, 0, 999, r?.round); break; default: throw new Error("Unsupported field " + e); } return i; } function er(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 Wg(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 = ec(ii(t), { years: e.years, months: e.months, weeks: e.weeks, days: e.days }); n = Xn(i, t.timeZone); } else n = to(t) - t.offset; n += e.milliseconds || 0, n += (e.seconds || 0) * 1e3, n += (e.minutes || 0) * 6e4, n += (e.hours || 0) * 36e5; let r = Jn(n, t.timeZone); return on(r, t.calendar); } function r6(t, e) { return Wg(t, zg(e)); } function i6(t, e, n, r) { switch (e) { case "hour": { let i = 0, o = 23; if (r?.hourCycle === 12) { let m = t.hour >= 12; i = m ? 12 : 0, o = m ? 23 : 11; } let s = ii(t), a = on(al(s, { hour: i }), new Ji()), l = [ Xn(a, t.timeZone, "earlier"), Xn(a, t.timeZone, "later") ].filter((m) => Jn(m, t.timeZone).day === a.day)[0], c = on(al(s, { hour: o }), new Ji()), d = [ Xn(c, t.timeZone, "earlier"), Xn(c, t.timeZone, "later") ].filter((m) => Jn(m, t.timeZone).day === c.day).pop(), u = to(t) - t.offset, f = Math.floor(u / No), p = u % No; return u = er(f, n, Math.floor(l / No), Math.floor(d / No), r?.round) * No + p, on(Jn(u, t.timeZone), t.calendar); } case "minute": case "second": case "millisecond": return Pg(t, e, n, r); case "era": case "year": case "month": case "day": { let i = _u(ii(t), e, n, r), o = Xn(i, t.timeZone); return on(Jn(o, t.timeZone), t.calendar); } default: throw new Error("Unsupported field " + e); } } function o6(t, e, n) { let r = ii(t), i = al(Vu(r, e), e); if (i.compare(r) === 0) return t; let o = Xn(i, t.timeZone, n); return on(Jn(o, t.timeZone), t.calendar); } const s6 = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/; function qg(t, e) { let n = t.match(s6); if (!n) throw new Error("Invalid ISO 8601 date time string: " + t); let r = new no(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), Vg(r, e); } function a6(t) { return qg(t, eo()); } 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 l6(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 Ug(t) { let e = on(t, new Ji()); return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`; } function jg(t) { return `${Ug(t)}T${l6(t)}`; } function c6(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 d6(t) { return `${jg(t)}${c6(t.offset)}[${t.timeZone}]`; } function h6(t, e) { if (e.has(t)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } function zu(t, e, n) { h6(t, e), e.set(t, n); } function Hu(t) { let e = typeof t[0] == "object" ? t.shift() : new Ji(), 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 u6 = /* @__PURE__ */ new WeakMap(); class os { /** Returns a copy of this date. */ copy() { return this.era ? new os(this.calendar, this.era, this.year, this.month, this.day) : new os(this.calendar, this.year, this.month, this.day); } /** Returns a new `CalendarDate` with the given duration added to it. */ add(e) { return ec(this, e); } /** Returns a new `CalendarDate` with the given duration subtracted from it. */ subtract(e) { return Hg(this, e); } /** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(e) { return Vu(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 _u(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 Bg(this, e); } /** Converts the date to an ISO 8601 formatted string. */ toString() { return Ug(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 Dg(this, e); } constructor(...e) { zu(this, u6, { writable: !0, value: void 0 }); let [n, r, i, o, s] = Hu(e); this.calendar = n, this.era = r, this.year = i, this.month = o, this.day = s, oi(this); } } var f6 = /* @__PURE__ */ new WeakMap(); class ll { /** Returns a copy of this date. */ copy() { return this.era ? new ll(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond) : new ll(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 ec(this, e); } /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */ subtract(e) { return Hg(this, e); } /** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(e) { return Vu(al(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 _u(this, e, n, r); default: return Pg(this, e, n, r); } } /** Converts the date to a native JavaScript Date object in the given time zone. */ toDate(e, n) { return Bg(this, e, n); } /** Converts the date to an ISO 8601 formatted string. */ toString() { return jg(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 = Dg(this, e); return n === 0 ? qx(this, ii(e)) : n; } constructor(...e) { zu(this, f6, { writable: !0, value: void 0 }); let [n, r, i, o, s] = Hu(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, oi(this); } } var p6 = /* @__PURE__ */ new WeakMap(); class no { /** Returns a copy of this date. */ copy() { return this.era ? new no(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond) : new no(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 Wg(this, e); } /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */ subtract(e) { return r6(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 o6(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 i6(this, e, n, r); } /** Converts the date to a native JavaScript Date object. */ toDate() { return Zx(this); } /** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */ toString() { return d6(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() - Qx(e, this.timeZone).toDate().getTime(); } constructor(...e) { zu(this, p6, { writable: !0, value: void 0 }); let [n, r, i, o, s] = Hu(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, oi(this); } } let nd = /* @__PURE__ */ new Map(); class m6 { /** 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 v6() && (this.resolvedHourCycle || (this.resolvedHourCycle = w6(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 = Kg(e, n), this.options = n; } } const g6 = { true: { // Only Japanese uses the h11 style for 12 hour time. All others use h12. ja: "h11" }, false: {} }; function Kg(t, e = {}) { if (typeof e.hour12 == "boolean" && b6()) { e = { ...e }; let i = g6[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 (nd.has(n)) return nd.get(n); let r = new Intl.DateTimeFormat(t, e); return nd.set(n, r), r; } let rd = null; function b6() { return rd == null && (rd = new Intl.DateTimeFormat("en-US", { hour: "numeric", hour12: !1 }).format(new Date(2020, 2, 3, 0)) === "24"), rd; } let id = null; function v6() { return id == null && (id = new Intl.DateTimeFormat("fr", { hour: "numeric", hour12: !1 }).resolvedOptions().hourCycle === "h12"), id; } function w6(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 = Kg(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 y6(t, e) { typeof t == "function" ? t(e) : t != null && (t.current = e); } function tc(...t) { return (e) => t.forEach( (n) => y6(n, e) ); } function pe(...t) { return ue(tc(...t), t); } function Pu(t, e) { const n = /* @__PURE__ */ ri(e); function r(o) { const { children: s, ...a } = o, l = _e( () => a, Object.values(a) ); return /* @__PURE__ */ T(n.Provider, { value: l }, s); } function i(o) { const s = bo(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__ */ ri(s), l = n.length; n = [ ...n, s ]; function c(u) { const { scope: f, children: p, ...m } = u, g = f?.[t][l] || a, b = _e( () => m, Object.values(m) ); return /* @__PURE__ */ T(g.Provider, { value: b }, p); } function d(u, f) { const p = f?.[t][l] || a, m = bo(p); if (m) return m; 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__ */ ri(s)); return function(a) { const l = a?.[t] || o; return _e( () => ({ [`__scope${t}`]: { ...a, [t]: l } }), [ a, l ] ); }; }; return i.scopeName = t, [ r, x6(i, ...e) ]; } function x6(...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 _e( () => ({ [`__scope${e.scopeName}`]: s }), [ s ] ); }; }; return n.scopeName = e.scopeName, n; } const On = /* @__PURE__ */ k((t, e) => { const { children: n, ...r } = t, i = $r.toArray(n), o = i.find(C6); if (o) { const s = o.props.children, a = i.map((l) => l === o ? $r.count(s) > 1 ? $r.only(null) : /* @__PURE__ */ ol(s) ? s.props.children : null : l); return /* @__PURE__ */ T(ch, H({}, r, { ref: e }), /* @__PURE__ */ ol(s) ? /* @__PURE__ */ Lu(s, void 0, a) : null); } return /* @__PURE__ */ T(ch, H({}, r, { ref: e }), n); }); On.displayName = "Slot"; const ch = /* @__PURE__ */ k((t, e) => { const { children: n, ...r } = t; return /* @__PURE__ */ ol(n) ? /* @__PURE__ */ Lu(n, { ...$6(r, n.props), ref: e ? tc(e, n.ref) : n.ref }) : $r.count(n) > 1 ? $r.only(null) : null; }); ch.displayName = "SlotClone"; const Wu = ({ children: t }) => /* @__PURE__ */ T(Gl, null, t); function C6(t) { return /* @__PURE__ */ ol(t) && t.type === Wu; } function $6(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 S6 = [ "a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "span", "svg", "ul" ], de = S6.reduce((t, e) => { const n = /* @__PURE__ */ k((r, i) => { const { asChild: o, ...s } = r, a = o ? On : e; return Z(() => { window[Symbol.for("radix-ui")] = !0; }, []), /* @__PURE__ */ T(a, H({}, s, { ref: i })); }); return n.displayName = `Primitive.${e}`, { ...t, [e]: n }; }, {}); function A6(t, e) { t && Ql( () => t.dispatchEvent(e) ); } function k6(t, e = globalThis?.document) { const n = tt(t); Z(() => { const r = (i) => { i.key === "Escape" && n(i); }; return e.addEventListener("keydown", r), () => e.removeEventListener("keydown", r); }, [ n, e ]); } const dh = "dismissableLayer.update", M6 = "dismissableLayer.pointerDownOutside", T6 = "dismissableLayer.focusOutside"; let t1; const I6 = /* @__PURE__ */ ri({ layers: /* @__PURE__ */ new Set(), layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(), branches: /* @__PURE__ */ new Set() }), mi = /* @__PURE__ */ k((t, e) => { var n; const { disableOutsidePointerEvents: r = !1, onEscapeKeyDown: i, onPointerDownOutside: o, onFocusOutside: s, onInteractOutside: a, onDismiss: l, ...c } = t, d = bo(I6), [u, f] = Q(null), p = (n = u?.ownerDocument) !== null && n !== void 0 ? n : globalThis?.document, [, m] = Q({}), g = pe( e, (R) => f(R) ), 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 = R6((R) => { const D = R.target, O = [ ...d.branches ].some( (z) => z.contains(D) ); !$ || O || (o?.(R), a?.(R), R.defaultPrevented || l?.()); }, p), A = E6((R) => { const D = R.target; [ ...d.branches ].some( (z) => z.contains(D) ) || (s?.(R), a?.(R), R.defaultPrevented || l?.()); }, p); return k6((R) => { x === d.layers.size - 1 && (i?.(R), !R.defaultPrevented && l && (R.preventDefault(), l())); }, p), Z(() => { if (u) return r && (d.layersWithOutsidePointerEventsDisabled.size === 0 && (t1 = p.body.style.pointerEvents, p.body.style.pointerEvents = "none"), d.layersWithOutsidePointerEventsDisabled.add(u)), d.layers.add(u), n1(), () => { r && d.layersWithOutsidePointerEventsDisabled.size === 1 && (p.body.style.pointerEvents = t1); }; }, [ u, p, r, d ]), Z(() => () => { u && (d.layers.delete(u), d.layersWithOutsidePointerEventsDisabled.delete(u), n1()); }, [ u, d ]), Z(() => { const R = () => m({}); return document.addEventListener(dh, R), () => document.removeEventListener(dh, R); }, []), /* @__PURE__ */ T(de.div, H({}, c, { ref: g, style: { pointerEvents: C ? $ ? "auto" : "none" : void 0, ...t.style }, onFocusCapture: Y(t.onFocusCapture, A.onFocusCapture), onBlurCapture: Y(t.onBlurCapture, A.onBlurCapture), onPointerDownCapture: Y(t.onPointerDownCapture, S.onPointerDownCapture) })); }); function R6(t, e = globalThis?.document) { const n = tt(t), r = te(!1), i = te(() => { }); return Z(() => { const o = (a) => { if (a.target && !r.current) { let c = function() { Gg(M6, 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 E6(t, e = globalThis?.document) { const n = tt(t), r = te(!1); return Z(() => { const i = (o) => { o.target && !r.current && Gg(T6, 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 n1() { const t = new CustomEvent(dh); document.dispatchEvent(t); } function Gg(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 ? A6(i, o) : i.dispatchEvent(o); } const D6 = mi, qe = globalThis?.document ? Yl : () => { }, O6 = y.useId || (() => { }); let L6 = 0; function gt(t) { const [e, n] = y.useState(O6()); return qe(() => { n( (r) => r ?? String(L6++) ); }, [ t ]), e ? `radix-${e}` : ""; } const N6 = ["top", "right", "bottom", "left"], kr = Math.min, Ut = Math.max, cl = Math.round, ia = Math.floor, In = (t) => ({ x: t, y: t }), B6 = { left: "right", right: "left", bottom: "top", top: "bottom" }, F6 = { start: "end", end: "start" }; function hh(t, e, n) { return Ut(t, kr(e, n)); } function ir(t, e) { return typeof t == "function" ? t(e) : t; } function or(t) { return t.split("-")[0]; } function yo(t) { return t.split("-")[1]; } function qu(t) { return t === "x" ? "y" : "x"; } function Uu(t) { return t === "y" ? "height" : "width"; } const V6 = /* @__PURE__ */ new Set(["top", "bottom"]); function An(t) { return V6.has(or(t)) ? "y" : "x"; } function ju(t) { return qu(An(t)); } function _6(t, e, n) { n === void 0 && (n = !1); const r = yo(t), i = ju(t), o = Uu(i); let s = i === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top"; return e.reference[o] > e.floating[o] && (s = dl(s)), [s, dl(s)]; } function z6(t) { const e = dl(t); return [uh(t), e, uh(e)]; } function uh(t) { return t.replace(/start|end/g, (e) => F6[e]); } const r1 = ["left", "right"], i1 = ["right", "left"], H6 = ["top", "bottom"], P6 = ["bottom", "top"]; function W6(t, e, n) { switch (t) { case "top": case "bottom": return n ? e ? i1 : r1 : e ? r1 : i1; case "left": case "right": return e ? H6 : P6; default: return []; } } function q6(t, e, n, r) { const i = yo(t); let o = W6(or(t), n === "start", r); return i && (o = o.map((s) => s + "-" + i), e && (o = o.concat(o.map(uh)))), o; } function dl(t) { return t.replace(/left|right|bottom|top/g, (e) => B6[e]); } function U6(t) { return { top: 0, right: 0, bottom: 0, left: 0, ...t }; } function Yg(t) { return typeof t != "number" ? U6(t) : { top: t, right: t, bottom: t, left: t }; } function hl(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 o1(t, e, n) { let { reference: r, floating: i } = t; const o = An(e), s = ju(e), a = Uu(s), l = or(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 (yo(e)) { case "start": p[s] -= f * (n && c ? -1 : 1); break; case "end": p[s] += f * (n && c ? -1 : 1); break; } return p; } const j6 = 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 } = o1(c, r, l), f = r, p = {}, m = 0; for (let g = 0; g < a.length; g++) { const { name: b, fn: v } = a[g], { 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 } }, $ && m <= 50 && (m++, typeof $ == "object" && ($.placement && (f = $.placement), $.rects && (c = $.rects === !0 ? await s.getElementRects({ reference: t, floating: e, strategy: i }) : $.rects), { x: d, y: u } = o1(c, f, l)), g = -1); } return { x: d, y: u, placement: f, strategy: i, middlewareData: p }; }; async function ss(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 } = ir(e, t), m = Yg(p), b = a[f ? u === "floating" ? "reference" : "floating" : u], v = hl(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 }, $ = hl(o.convertOffsetParentRelativeRectToViewportRelativeRect ? await o.convertOffsetParentRelativeRectToViewportRelativeRect({ elements: a, rect: w, offsetParent: x, strategy: l }) : w); return { top: (v.top - $.top + m.top) / C.y, bottom: ($.bottom - v.bottom + m.bottom) / C.y, left: (v.left - $.left + m.left) / C.x, right: ($.right - v.right + m.right) / C.x }; } const K6 = (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 } = ir(t, e) || {}; if (c == null) return {}; const u = Yg(d), f = { x: n, y: r }, p = ju(i), m = Uu(p), g = await s.getDimensions(c), b = p === "y", v = b ? "top" : "left", w = b ? "bottom" : "right", x = b ? "clientHeight" : "clientWidth", C = o.reference[m] + o.reference[p] - f[p] - o.floating[m], $ = f[p] - o.reference[p], S = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c)); let A = S ? S[x] : 0; (!A || !await (s.isElement == null ? void 0 : s.isElement(S))) && (A = a.floating[x] || o.floating[m]); const R = C / 2 - $ / 2, D = A / 2 - g[m] / 2 - 1, O = kr(u[v], D), z = kr(u[w], D), B = O, j = A - g[m] - z, q = A / 2 - g[m] / 2 + R, K = hh(B, q, j), J = !l.arrow && yo(i) != null && q !== K && o.reference[m] / 2 - (q < B ? O : z) - g[m] / 2 < 0, W = J ? q < B ? q - B : q - j : 0; return { [p]: f[p] + W, data: { [p]: K, centerOffset: q - K - W, ...J && { alignmentOffset: W } }, reset: J }; } }), G6 = 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: m = "none", flipAlignment: g = !0, ...b } = ir(t, e); if ((n = o.arrow) != null && n.alignmentOffset) return {}; const v = or(i), w = An(a), x = or(a) === a, C = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), $ = f || (x || !g ? [dl(a)] : z6(a)), S = m !== "none"; !f && S && $.push(...q6(a, g, m, C)); const A = [a, ...$], R = await ss(e, b), D = []; let O = ((r = o.flip) == null ? void 0 : r.overflows) || []; if (d && D.push(R[v]), u) { const q = _6(i, s, C); D.push(R[q[0]], R[q[1]]); } if (O = [...O, { placement: i, overflows: D }], !D.every((q) => q <= 0)) { var z, B; const q = (((z = o.flip) == null ? void 0 : z.index) || 0) + 1, K = A[q]; 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((_) => An(_.placement) === w ? _.overflows[0] > 0 : !0))) return { data: { index: q, overflows: O }, reset: { placement: K } }; let J = (B = O.filter((W) => W.overflows[0] <= 0).sort((W, _) => W.overflows[1] - _.overflows[1])[0]) == null ? void 0 : B.placement; if (!J) switch (p) { case "bestFit": { var j; const W = (j = O.filter((_) => { if (S) { const F = An(_.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((_) => [_.placement, _.overflows.filter((F) => F > 0).reduce((F, ee) => F + ee, 0)]).sort((_, F) => _[1] - F[1])[0]) == null ? void 0 : j[0]; W && (J = W); break; } case "initialPlacement": J = a; break; } if (i !== J) return { reset: { placement: J } }; } return {}; } }; }; function s1(t, e) { return { top: t.top - e.height, right: t.right - e.width, bottom: t.bottom - e.height, left: t.left - e.width }; } function a1(t) { return N6.some((e) => t[e] >= 0); } const Y6 = function(t) { return t === void 0 && (t = {}), { name: "hide", options: t, async fn(e) { const { rects: n } = e, { strategy: r = "referenceHidden", ...i } = ir(t, e); switch (r) { case "referenceHidden": { const o = await ss(e, { ...i, elementContext: "reference" }), s = s1(o, n.reference); return { data: { referenceHiddenOffsets: s, referenceHidden: a1(s) } }; } case "escaped": { const o = await ss(e, { ...i, altBoundary: !0 }), s = s1(o, n.floating); return { data: { escapedOffsets: s, escaped: a1(s) } }; } default: return {}; } } }; }, Xg = /* @__PURE__ */ new Set(["left", "top"]); async function X6(t, e) { const { placement: n, platform: r, elements: i } = t, o = await (r.isRTL == null ? void 0 : r.isRTL(i.floating)), s = or(n), a = yo(n), l = An(n) === "y", c = Xg.has(s) ? -1 : 1, d = o && l ? -1 : 1, u = ir(e, t); let { mainAxis: f, crossAxis: p, alignmentAxis: m } = typeof u == "number" ? { mainAxis: u, crossAxis: 0, alignmentAxis: null } : { mainAxis: u.mainAxis || 0, crossAxis: u.crossAxis || 0, alignmentAxis: u.alignmentAxis }; return a && typeof m == "number" && (p = a === "end" ? m * -1 : m), l ? { x: p * d, y: f * c } : { x: f * c, y: p * d }; } const Q6 = 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 X6(e, t); return s