@als-tp/als-react-ts-ui
Version:
A comprehensive React TypeScript UI component library built with Base UI by ALSInnovation
1,719 lines (1,718 loc) • 738 kB
JavaScript
import { jsx as x, jsxs as De, Fragment as vf } from "react/jsx-runtime";
import * as i from "react";
import ke, { createElement as qr, createContext as Qn, forwardRef as Te, useContext as eo, useLayoutEffect as yf, useState as Vt, useCallback as Gt, useRef as ao, useId as P_, useEffect as Kn, useMemo as _f } from "react";
import * as at from "react-dom";
import { createPortal as A_ } from "react-dom";
function St({
controlled: e,
default: t,
name: n,
state: o = "value"
}) {
const {
current: r
} = i.useRef(e !== void 0), [s, a] = i.useState(t), c = r ? e : s;
if (process.env.NODE_ENV !== "production") {
i.useEffect(() => {
r !== (e !== void 0) && console.error([`Base UI: A component is changing the ${r ? "" : "un"}controlled ${o} state of ${n} to be ${r ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${n} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join(`
`));
}, [o, n, e]);
const {
current: u
} = i.useRef(t);
i.useEffect(() => {
!r && JSON.stringify(u) !== JSON.stringify(t) && console.error([`Base UI: A component is changing the default ${o} state of an uncontrolled ${n} after being initialized. To suppress this warning opt to use a controlled ${n}.`].join(`
`));
}, [JSON.stringify(t)]);
}
const l = i.useCallback((u) => {
r || a(u);
}, []);
return [c, l];
}
const Yu = {};
function Pt(e, t) {
const n = i.useRef(Yu);
return n.current === Yu && (n.current = e(t)), n;
}
const ca = i[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)], M_ = (
// React 17 doesn't have useInsertionEffect.
ca && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
ca !== i.useLayoutEffect ? ca : (e) => e()
);
function Z(e) {
const t = Pt(T_).current;
return t.next = e, M_(t.effect), t.trampoline;
}
function T_() {
const e = {
next: void 0,
callback: O_,
trampoline: (...t) => e.callback?.(...t),
effect: () => {
e.callback = e.next;
}
};
return e;
}
function O_() {
if (process.env.NODE_ENV !== "production")
throw new Error("Base UI: Cannot call an event handler while rendering.");
}
const L_ = () => {
}, ae = typeof document < "u" ? i.useLayoutEffect : L_;
let Ca;
process.env.NODE_ENV !== "production" && (Ca = /* @__PURE__ */ new Set());
function ns(...e) {
if (process.env.NODE_ENV !== "production") {
const t = e.join(" ");
Ca.has(t) || (Ca.add(t), console.warn(`Base UI: ${t}`));
}
}
const ja = /* @__PURE__ */ i.createContext({
register: () => {
},
unregister: () => {
},
subscribeMapChange: () => () => {
},
elementsRef: {
current: []
},
nextIndexRef: {
current: 0
}
});
process.env.NODE_ENV !== "production" && (ja.displayName = "CompositeListContext");
function k_() {
return i.useContext(ja);
}
function Wo(e) {
const {
children: t,
elementsRef: n,
labelsRef: o,
onMapChange: r
} = e, s = Z(r), a = i.useRef(0), c = Pt(D_).current, l = Pt(V_).current, [u, d] = i.useState(0), f = i.useRef(u), p = Z((y, b) => {
l.set(y, b ?? null), f.current += 1, d(f.current);
}), g = Z((y) => {
l.delete(y), f.current += 1, d(f.current);
}), h = i.useMemo(() => {
const y = /* @__PURE__ */ new Map();
return Array.from(l.keys()).sort(F_).forEach((E, _) => {
const S = l.get(E) ?? {};
y.set(E, {
...S,
index: _
});
}), y;
}, [l, u]);
ae(() => {
if (typeof MutationObserver != "function" || h.size === 0)
return;
const y = new MutationObserver((b) => {
const E = /* @__PURE__ */ new Set(), _ = (S) => E.has(S) ? E.delete(S) : E.add(S);
b.forEach((S) => {
S.removedNodes.forEach(_), S.addedNodes.forEach(_);
}), E.size === 0 && (f.current += 1, d(f.current));
});
return h.forEach((b, E) => {
E.parentElement && y.observe(E.parentElement, {
childList: !0
});
}), () => {
y.disconnect();
};
}, [h]), ae(() => {
f.current === u && (n.current.length !== h.size && (n.current.length = h.size), o && o.current.length !== h.size && (o.current.length = h.size), a.current = h.size), s(h);
}, [s, h, n, o, u]), ae(() => () => {
n.current = [];
}, [n]), ae(() => () => {
o && (o.current = []);
}, [o]);
const m = Z((y) => (c.add(y), () => {
c.delete(y);
}));
ae(() => {
c.forEach((y) => y(h));
}, [c, h]);
const v = i.useMemo(() => ({
register: p,
unregister: g,
subscribeMapChange: m,
elementsRef: n,
labelsRef: o,
nextIndexRef: a
}), [p, g, m, n, o, a]);
return /* @__PURE__ */ x(ja.Provider, {
value: v,
children: t
});
}
function V_() {
return /* @__PURE__ */ new Map();
}
function D_() {
return /* @__PURE__ */ new Set();
}
function F_(e, t) {
const n = e.compareDocumentPosition(t);
return n & Node.DOCUMENT_POSITION_FOLLOWING || n & Node.DOCUMENT_POSITION_CONTAINED_BY ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING || n & Node.DOCUMENT_POSITION_CONTAINS ? 1 : 0;
}
const xf = /* @__PURE__ */ i.createContext(void 0);
process.env.NODE_ENV !== "production" && (xf.displayName = "DirectionContext");
function sn() {
return i.useContext(xf)?.direction ?? "ltr";
}
function Le(e, ...t) {
const n = new URL(`https://base-ui.com/production-error/${e}`);
return t.forEach((o) => n.searchParams.append("args[]", o)), `Base UI error #${e}; visit ${n} for the full message.`;
}
const Ka = /* @__PURE__ */ i.createContext(void 0);
process.env.NODE_ENV !== "production" && (Ka.displayName = "AccordionRootContext");
function Xa() {
const e = i.useContext(Ka);
if (e === void 0)
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: AccordionRootContext is missing. Accordion parts must be placed within <Accordion.Root>." : Le(10));
return e;
}
function Dt(e, t, n, o) {
const r = Pt(Ef).current;
return B_(r, e, t, n, o) && Rf(r, [e, t, n, o]), r.callback;
}
function $_(e) {
const t = Pt(Ef).current;
return H_(t, e) && Rf(t, e), t.callback;
}
function Ef() {
return {
callback: null,
cleanup: null,
refs: []
};
}
function B_(e, t, n, o, r) {
return e.refs[0] !== t || e.refs[1] !== n || e.refs[2] !== o || e.refs[3] !== r;
}
function H_(e, t) {
return e.refs.length !== t.length || e.refs.some((n, o) => n !== t[o]);
}
function Rf(e, t) {
if (e.refs = t, t.every((n) => n == null)) {
e.callback = null;
return;
}
e.callback = (n) => {
if (e.cleanup && (e.cleanup(), e.cleanup = null), n != null) {
const o = Array(t.length).fill(null);
for (let r = 0; r < t.length; r += 1) {
const s = t[r];
if (s != null)
switch (typeof s) {
case "function": {
const a = s(n);
typeof a == "function" && (o[r] = a);
break;
}
case "object": {
s.current = n;
break;
}
}
}
e.cleanup = () => {
for (let r = 0; r < t.length; r += 1) {
const s = t[r];
if (s != null)
switch (typeof s) {
case "function": {
const a = o[r];
typeof a == "function" ? a() : s(null);
break;
}
case "object": {
s.current = null;
break;
}
}
}
};
}
};
}
const z_ = parseInt(i.version, 10);
function Sf(e) {
return z_ >= e;
}
function ju(e) {
if (!/* @__PURE__ */ i.isValidElement(e))
return null;
const t = e, n = t.props;
return (Sf(19) ? n?.ref : t.ref) ?? null;
}
function wa(e, t) {
if (e && !t)
return e;
if (!e && t)
return t;
if (e || t)
return {
...e,
...t
};
}
function U_(e, t) {
const n = {};
for (const o in e) {
const r = e[o];
if (t?.hasOwnProperty(o)) {
const s = t[o](r);
s != null && Object.assign(n, s);
continue;
}
r === !0 ? n[`data-${o.toLowerCase()}`] = "" : r && (n[`data-${o.toLowerCase()}`] = r.toString());
}
return n;
}
function W_(e, t) {
return typeof e == "function" ? e(t) : e;
}
function G_(e, t) {
return typeof e == "function" ? e(t) : e;
}
const Wr = {};
function gn(e, t, n, o, r) {
let s = {
...Na(e, Wr)
};
return t && (s = zr(s, t)), n && (s = zr(s, n)), o && (s = zr(s, o)), r && (s = zr(s, r)), s;
}
function q_(e) {
if (e.length === 0)
return Wr;
if (e.length === 1)
return Na(e[0], Wr);
let t = {
...Na(e[0], Wr)
};
for (let n = 1; n < e.length; n += 1)
t = zr(t, e[n]);
return t;
}
function zr(e, t) {
return Cf(t) ? t(e) : Y_(e, t);
}
function Y_(e, t) {
if (!t)
return e;
for (const n in t) {
const o = t[n];
switch (n) {
case "style": {
e[n] = wa(e.style, o);
break;
}
case "className": {
e[n] = wf(e.className, o);
break;
}
default:
j_(n, o) ? e[n] = K_(e[n], o) : e[n] = o;
}
}
return e;
}
function j_(e, t) {
const n = e.charCodeAt(0), o = e.charCodeAt(1), r = e.charCodeAt(2);
return n === 111 && o === 110 && r >= 65 && r <= 90 && (typeof t == "function" || typeof t > "u");
}
function Cf(e) {
return typeof e == "function";
}
function Na(e, t) {
return Cf(e) ? e(t) : e ?? Wr;
}
function K_(e, t) {
return t ? e ? (n) => {
if (X_(n)) {
const r = n;
Ia(r);
const s = t(r);
return r.baseUIHandlerPrevented || e?.(r), s;
}
const o = t(n);
return e?.(n), o;
} : t : e;
}
function Ia(e) {
return e.preventBaseUIHandler = () => {
e.baseUIHandlerPrevented = !0;
}, e;
}
function wf(e, t) {
return t ? e ? t + " " + e : t : e;
}
function X_(e) {
return e != null && typeof e == "object" && "nativeEvent" in e;
}
function Ze() {
}
const kt = Object.freeze([]), et = Object.freeze({}), Z_ = 500, Za = 500, J_ = {
style: {
transition: "none"
}
}, Ja = "data-base-ui-click-trigger", pi = {
fallbackAxisSide: "none"
}, Qa = {
fallbackAxisSide: "end"
}, Nf = {
clipPath: "inset(50%)",
position: "fixed",
top: 0,
left: 0
};
function re(e, t, n = {}) {
const o = t.render, r = Q_(t, n);
if (n.enabled === !1)
return null;
const s = n.state ?? et;
return ex(e, o, r, s);
}
function Q_(e, t = {}) {
const {
className: n,
style: o,
render: r
} = e, {
state: s = et,
ref: a,
props: c,
stateAttributesMapping: l,
enabled: u = !0
} = t, d = u ? W_(n, s) : void 0, f = u ? G_(o, s) : void 0, p = u ? U_(s, l) : et, g = u ? wa(p, Array.isArray(c) ? q_(c) : c) ?? et : et;
return typeof document < "u" && (u ? Array.isArray(a) ? g.ref = $_([g.ref, ju(r), ...a]) : g.ref = Dt(g.ref, ju(r), a) : Dt(null, null)), u ? (d !== void 0 && (g.className = wf(g.className, d)), f !== void 0 && (g.style = wa(g.style, f)), g) : et;
}
function ex(e, t, n, o) {
if (t) {
if (typeof t == "function")
return t(n, o);
const r = gn(n, t.props);
return r.ref = n.ref, /* @__PURE__ */ i.cloneElement(t, r);
}
if (e && typeof e == "string")
return tx(e, n);
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : Le(8));
}
function tx(e, t) {
return e === "button" ? /* @__PURE__ */ qr("button", {
type: "button",
...t,
key: t.key
}) : e === "img" ? /* @__PURE__ */ qr("img", {
alt: "",
...t,
key: t.key
}) : /* @__PURE__ */ i.createElement(e, t);
}
const dt = "none", Zt = "trigger-press", Je = "trigger-hover", Fo = "trigger-focus", mi = "outside-press", co = "item-press", If = "close-press", nx = "link-press", Ku = "clear-press", Xu = "track-press", kn = "input-change", Rn = "input-clear", Zu = "input-blur", ox = "input-paste", Qt = "focus-out", xr = "escape-key", dr = "list-navigation", ar = "keyboard", rx = "pointer", sx = "drag", Ju = "scrub", ec = "cancel-open", Ur = "sibling-open", tc = "imperative-action", ix = "window-resize";
function he(e, t, n, o) {
let r = !1, s = !1;
const a = o ?? et;
return {
reason: e,
event: t ?? new Event("base-ui"),
cancel() {
r = !0;
},
allowPropagation() {
s = !0;
},
get isCanceled() {
return r;
},
get isPropagationAllowed() {
return s;
},
trigger: n,
...a
};
}
function Xt(e, t, n) {
const o = n ?? et;
return {
reason: e,
event: t ?? new Event("base-ui"),
...o
};
}
const ax = {
value: () => null
}, Pf = /* @__PURE__ */ i.forwardRef(function(t, n) {
const {
render: o,
className: r,
disabled: s = !1,
hiddenUntilFound: a,
keepMounted: c,
loopFocus: l = !0,
onValueChange: u,
multiple: d = !1,
orientation: f = "vertical",
value: p,
defaultValue: g,
...h
} = t, m = sn();
process.env.NODE_ENV !== "production" && ae(() => {
a && c === !1 && ns("The `keepMounted={false}` prop on a Accordion.Root will be ignored when using `hiddenUntilFound` since it requires Panels to remain mounted when closed.");
}, [a, c]);
const v = i.useMemo(() => {
if (p === void 0)
return g ?? [];
}, [p, g]), y = Z(u), b = i.useRef([]), [E, _] = St({
controlled: p,
default: v,
name: "Accordion",
state: "value"
}), S = Z((T, V) => {
const k = he(dt);
if (d)
if (V) {
const O = E.slice();
if (O.push(T), y(O, k), k.isCanceled)
return;
_(O);
} else {
const O = E.filter((w) => w !== T);
if (y(O, k), k.isCanceled)
return;
_(O);
}
else {
const O = E[0] === T ? [] : [T];
if (y(O, k), k.isCanceled)
return;
_(O);
}
}), C = i.useMemo(() => ({
value: E,
disabled: s,
orientation: f
}), [E, s, f]), R = i.useMemo(() => ({
accordionItemRefs: b,
direction: m,
disabled: s,
handleValueChange: S,
hiddenUntilFound: a ?? !1,
keepMounted: c ?? !1,
loopFocus: l,
orientation: f,
state: C,
value: E
}), [m, s, S, a, c, l, f, C, E]), P = re("div", t, {
state: C,
ref: n,
props: [{
dir: m,
role: "region"
}, h],
stateAttributesMapping: ax
});
return /* @__PURE__ */ x(Ka.Provider, {
value: R,
children: /* @__PURE__ */ x(Wo, {
elementsRef: b,
children: P
})
});
});
process.env.NODE_ENV !== "production" && (Pf.displayName = "AccordionRoot");
const cx = {
...i
};
let Qu = 0;
function lx(e, t = "mui") {
const [n, o] = i.useState(e), r = e || n;
return i.useEffect(() => {
n == null && (Qu += 1, o(`${t}-${Qu}`));
}, [n, t]), r;
}
const ed = cx.useId;
function Mn(e, t) {
if (ed !== void 0) {
const n = ed();
return e ?? (t ? `${t}-${n}` : n);
}
return lx(e, t);
}
function We(e) {
return Mn(e, "base-ui");
}
const ux = [];
function vo(e) {
i.useEffect(e, ux);
}
const ws = null;
let td = globalThis.requestAnimationFrame;
class dx {
/* This implementation uses an array as a backing data-structure for frame callbacks.
* It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
* never calls the native `cancelAnimationFrame` if there are no frames left. This can
* be much more efficient if there is a call pattern that alterns as
* "request-cancel-request-cancel-…".
* But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
* frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
callbacks = [];
callbacksCount = 0;
nextId = 1;
startId = 1;
isScheduled = !1;
tick = (t) => {
this.isScheduled = !1;
const n = this.callbacks, o = this.callbacksCount;
if (this.callbacks = [], this.callbacksCount = 0, this.startId = this.nextId, o > 0)
for (let r = 0; r < n.length; r += 1)
n[r]?.(t);
};
request(t) {
const n = this.nextId;
this.nextId += 1, this.callbacks.push(t), this.callbacksCount += 1;
const o = process.env.NODE_ENV === "test" && td !== requestAnimationFrame && (td = requestAnimationFrame, !0);
return (!this.isScheduled || o) && (requestAnimationFrame(this.tick), this.isScheduled = !0), n;
}
cancel(t) {
const n = t - this.startId;
n < 0 || n >= this.callbacks.length || (this.callbacks[n] = null, this.callbacksCount -= 1);
}
}
const Ns = new dx();
class bt {
static create() {
return new bt();
}
static request(t) {
return Ns.request(t);
}
static cancel(t) {
return Ns.cancel(t);
}
currentId = ws;
/**
* Executes `fn` after `delay`, clearing any previously scheduled call.
*/
request(t) {
this.cancel(), this.currentId = Ns.request(() => {
this.currentId = ws, t();
});
}
cancel = () => {
this.currentId !== ws && (Ns.cancel(this.currentId), this.currentId = ws);
};
disposeEffect = () => this.cancel;
}
function wn() {
const e = Pt(bt.create).current;
return vo(e.disposeEffect), e;
}
function Oo(e) {
return e == null ? e : "current" in e ? e.current : e;
}
function os(e, t = !1, n = !0) {
const o = wn();
return Z((r, s = null) => {
o.cancel();
const a = Oo(e);
a != null && (typeof a.getAnimations != "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED ? r() : o.request(() => {
function c() {
a && Promise.all(a.getAnimations().map((l) => l.finished)).then(() => {
s != null && s.aborted || at.flushSync(r);
}).catch(() => {
if (n) {
if (s != null && s.aborted)
return;
at.flushSync(r);
} else a.getAnimations().length > 0 && a.getAnimations().some((l) => l.pending || l.playState !== "finished") && c();
});
}
t ? o.request(c) : c();
}));
});
}
function an(e, t = !1, n = !1) {
const [o, r] = i.useState(e && t ? "idle" : void 0), [s, a] = i.useState(e);
return e && !s && (a(!0), r("starting")), !e && s && o !== "ending" && !n && r("ending"), !e && !s && o === "ending" && r(void 0), ae(() => {
if (!e && s && o !== "ending" && n) {
const c = bt.request(() => {
r("ending");
});
return () => {
bt.cancel(c);
};
}
}, [e, s, o, n]), ae(() => {
if (!e || t)
return;
const c = bt.request(() => {
at.flushSync(() => {
r(void 0);
});
});
return () => {
bt.cancel(c);
};
}, [t, e]), ae(() => {
if (!e || !t)
return;
e && s && o !== "idle" && r("starting");
const c = bt.request(() => {
r("idle");
});
return () => {
bt.cancel(c);
};
}, [t, e, s, r, o]), i.useMemo(() => ({
mounted: s,
setMounted: a,
transitionStatus: o
}), [s, o]);
}
function Af(e) {
const {
open: t,
defaultOpen: n,
onOpenChange: o,
disabled: r
} = e, s = t !== void 0, [a, c] = St({
controlled: t,
default: n,
name: "Collapsible",
state: "open"
}), {
mounted: l,
setMounted: u,
transitionStatus: d
} = an(a, !0, !0), [f, p] = i.useState(a), [{
height: g,
width: h
}, m] = i.useState({
height: void 0,
width: void 0
}), v = We(), [y, b] = i.useState(), E = y ?? v, [_, S] = i.useState(!1), [C, R] = i.useState(!1), P = i.useRef(null), T = i.useRef(null), V = i.useRef(null), k = i.useRef(null), O = os(k, !1), w = Z((M) => {
const N = !a, A = he(Zt, M.nativeEvent);
if (o(N, A), A.isCanceled)
return;
const L = k.current;
T.current === "css-animation" && L != null && L.style.removeProperty("animation-name"), !_ && !C && (T.current != null && T.current !== "css-animation" && !l && N && u(!0), T.current === "css-animation" && (!f && N && p(!0), !l && N && u(!0))), c(N), T.current === "none" && l && !N && u(!1);
});
return ae(() => {
s && T.current === "none" && !C && !a && u(!1);
}, [s, C, a, t, u]), i.useMemo(() => ({
abortControllerRef: P,
animationTypeRef: T,
disabled: r,
handleTrigger: w,
height: g,
mounted: l,
open: a,
panelId: E,
panelRef: k,
runOnceAnimationsFinish: O,
setDimensions: m,
setHiddenUntilFound: S,
setKeepMounted: R,
setMounted: u,
setOpen: c,
setPanelIdState: b,
setVisible: p,
transitionDimensionRef: V,
transitionStatus: d,
visible: f,
width: h
}), [P, T, r, w, g, l, a, E, k, O, m, S, R, u, c, p, V, d, f, h]);
}
const Yr = /* @__PURE__ */ i.createContext(void 0);
process.env.NODE_ENV !== "production" && (Yr.displayName = "CollapsibleRootContext");
function gi() {
const e = i.useContext(Yr);
if (e === void 0)
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : Le(15));
return e;
}
let nc = /* @__PURE__ */ (function(e) {
return e[e.None = 0] = "None", e[e.GuessFromOrder = 1] = "GuessFromOrder", e;
})({});
function Hn(e = {}) {
const {
label: t,
metadata: n,
textRef: o,
indexGuessBehavior: r,
index: s
} = e, {
register: a,
unregister: c,
subscribeMapChange: l,
elementsRef: u,
labelsRef: d,
nextIndexRef: f
} = k_(), p = i.useRef(-1), [g, h] = i.useState(s ?? (r === nc.GuessFromOrder ? () => {
if (p.current === -1) {
const y = f.current;
f.current += 1, p.current = y;
}
return p.current;
} : -1)), m = i.useRef(null), v = i.useCallback((y) => {
if (m.current = y, g !== -1 && y !== null && (u.current[g] = y, d)) {
const b = t !== void 0;
d.current[g] = b ? t : o?.current?.textContent ?? y.textContent;
}
}, [g, u, d, t, o]);
return ae(() => {
if (s != null)
return;
const y = m.current;
if (y)
return a(y, n), () => {
c(y);
};
}, [s, a, c, n]), ae(() => {
if (s == null)
return l((y) => {
const b = m.current ? y.get(m.current)?.index : null;
b != null && h(b);
});
}, [s, l, h]), i.useMemo(() => ({
ref: v,
index: g
}), [g, v]);
}
const oc = /* @__PURE__ */ i.createContext(void 0);
process.env.NODE_ENV !== "production" && (oc.displayName = "AccordionItemContext");
function rc() {
const e = i.useContext(oc);
if (e === void 0)
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: AccordionItemContext is missing. Accordion parts must be placed within <Accordion.Item>." : Le(9));
return e;
}
let hr = /* @__PURE__ */ (function(e) {
return e.startingStyle = "data-starting-style", e.endingStyle = "data-ending-style", e;
})({});
const fx = {
[hr.startingStyle]: ""
}, px = {
[hr.endingStyle]: ""
}, gt = {
transitionStatus(e) {
return e === "starting" ? fx : e === "ending" ? px : null;
}
};
let Gr = (function(e) {
return e.open = "data-open", e.closed = "data-closed", e[e.startingStyle = hr.startingStyle] = "startingStyle", e[e.endingStyle = hr.endingStyle] = "endingStyle", e;
})({}), mx = /* @__PURE__ */ (function(e) {
return e.panelOpen = "data-panel-open", e;
})({});
const gx = {
[Gr.open]: ""
}, hx = {
[Gr.closed]: ""
}, Mf = {
open(e) {
return e ? {
[mx.panelOpen]: ""
} : null;
}
}, Tf = {
open(e) {
return e ? gx : hx;
}
};
let bx = /* @__PURE__ */ (function(e) {
return e.index = "data-index", e.disabled = "data-disabled", e.open = "data-open", e;
})({});
const sc = {
...Tf,
index: (e) => Number.isInteger(e) ? {
[bx.index]: String(e)
} : null,
...gt,
value: () => null
}, Of = /* @__PURE__ */ i.forwardRef(function(t, n) {
const {
className: o,
disabled: r = !1,
onOpenChange: s,
render: a,
value: c,
...l
} = t, {
ref: u,
index: d
} = Hn(), f = Dt(n, u), {
disabled: p,
handleValueChange: g,
state: h,
value: m
} = Xa(), v = We(), y = c ?? v, b = r || p, E = i.useMemo(() => {
if (!m)
return !1;
for (let w = 0; w < m.length; w += 1)
if (m[w] === y)
return !0;
return !1;
}, [m, y]), _ = Z((w, M) => {
s?.(w, M), !M.isCanceled && g(y, w);
}), S = Af({
open: E,
onOpenChange: _,
disabled: b
}), C = i.useMemo(() => ({
open: S.open,
disabled: S.disabled,
hidden: !S.mounted,
transitionStatus: S.transitionStatus
}), [S.open, S.disabled, S.mounted, S.transitionStatus]), R = i.useMemo(() => ({
...S,
onOpenChange: _,
state: C
}), [S, C, _]), P = i.useMemo(() => ({
...h,
index: d,
disabled: b,
open: E
}), [b, d, E, h]), [T, V] = i.useState(We()), k = i.useMemo(() => ({
open: E,
state: P,
setTriggerId: V,
triggerId: T
}), [E, P, V, T]), O = re("div", t, {
state: P,
ref: f,
props: l,
stateAttributesMapping: sc
});
return /* @__PURE__ */ x(Yr.Provider, {
value: R,
children: /* @__PURE__ */ x(oc.Provider, {
value: k,
children: O
})
});
});
process.env.NODE_ENV !== "production" && (Of.displayName = "AccordionItem");
const Lf = /* @__PURE__ */ i.forwardRef(function(t, n) {
const {
render: o,
className: r,
...s
} = t, {
state: a
} = rc();
return re("h3", t, {
state: a,
ref: n,
props: s,
stateAttributesMapping: sc
});
});
process.env.NODE_ENV !== "production" && (Lf.displayName = "AccordionHeader");
function Pa(e) {
return e == null || e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true";
}
function hi() {
return typeof window < "u";
}
function yo(e) {
return ic(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function nt(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function zn(e) {
var t;
return (t = (ic(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function ic(e) {
return hi() ? e instanceof Node || e instanceof nt(e).Node : !1;
}
function je(e) {
return hi() ? e instanceof Element || e instanceof nt(e).Element : !1;
}
function ot(e) {
return hi() ? e instanceof HTMLElement || e instanceof nt(e).HTMLElement : !1;
}
function Aa(e) {
return !hi() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof nt(e).ShadowRoot;
}
const vx = /* @__PURE__ */ new Set(["inline", "contents"]);
function Go(e) {
const {
overflow: t,
overflowX: n,
overflowY: o,
display: r
} = en(e);
return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !vx.has(r);
}
const yx = /* @__PURE__ */ new Set(["table", "td", "th"]);
function _x(e) {
return yx.has(yo(e));
}
const xx = [":popover-open", ":modal"];
function bi(e) {
return xx.some((t) => {
try {
return e.matches(t);
} catch {
return !1;
}
});
}
const Ex = ["transform", "translate", "scale", "rotate", "perspective"], Rx = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Sx = ["paint", "layout", "strict", "content"];
function ac(e) {
const t = vi(), n = je(e) ? en(e) : e;
return Ex.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || Rx.some((o) => (n.willChange || "").includes(o)) || Sx.some((o) => (n.contain || "").includes(o));
}
function Cx(e) {
let t = $n(e);
for (; ot(t) && !Vn(t); ) {
if (ac(t))
return t;
if (bi(t))
return null;
t = $n(t);
}
return null;
}
function vi() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const wx = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function Vn(e) {
return wx.has(yo(e));
}
function en(e) {
return nt(e).getComputedStyle(e);
}
function yi(e) {
return je(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function $n(e) {
if (yo(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.
Aa(e) && e.host || // Fallback.
zn(e)
);
return Aa(t) ? t.host : t;
}
function kf(e) {
const t = $n(e);
return Vn(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : ot(t) && Go(t) ? t : kf(t);
}
function lo(e, t, n) {
var o;
t === void 0 && (t = []), n === void 0 && (n = !0);
const r = kf(e), s = r === ((o = e.ownerDocument) == null ? void 0 : o.body), a = nt(r);
if (s) {
const c = Ma(a);
return t.concat(a, a.visualViewport || [], Go(r) ? r : [], c && n ? lo(c) : []);
}
return t.concat(r, lo(r, [], n));
}
function Ma(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
let Ta;
process.env.NODE_ENV !== "production" && (Ta = /* @__PURE__ */ new Set());
function nd(...e) {
if (process.env.NODE_ENV !== "production") {
const t = e.join(" ");
Ta.has(t) || (Ta.add(t), console.error(`Base UI: ${t}`));
}
}
const cc = /* @__PURE__ */ i.createContext(void 0);
process.env.NODE_ENV !== "production" && (cc.displayName = "CompositeRootContext");
function lc(e = !1) {
const t = i.useContext(cc);
if (t === void 0 && !e)
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : Le(16));
return t;
}
function Vf(e) {
const {
focusableWhenDisabled: t,
disabled: n,
composite: o = !1,
tabIndex: r = 0,
isNativeButton: s
} = e, a = o && t !== !1, c = o && t === !1;
return {
props: i.useMemo(() => {
const u = {
// allow Tabbing away from focusableWhenDisabled elements
onKeyDown(d) {
n && t && d.key !== "Tab" && d.preventDefault();
}
};
return o || (u.tabIndex = r, !s && n && (u.tabIndex = t ? r : -1)), (s && (t || a) || !s && n) && (u["aria-disabled"] = n), s && (!t || c) && (u.disabled = n), u;
}, [o, n, t, a, c, s, r])
};
}
function pt(e = {}) {
const {
disabled: t = !1,
focusableWhenDisabled: n,
tabIndex: o = 0,
native: r = !0
} = e, s = i.useRef(null), a = lc(!0) !== void 0, c = Z(() => {
const p = s.current;
return !!(p?.tagName === "A" && p?.href);
}), {
props: l
} = Vf({
focusableWhenDisabled: n,
disabled: t,
composite: a,
tabIndex: o,
isNativeButton: r
});
process.env.NODE_ENV !== "production" && i.useEffect(() => {
if (!s.current)
return;
const p = s.current.tagName === "BUTTON";
r ? p || nd("A component that acts as a button was not rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is a real <button>, or set the `nativeButton` prop on the component to `false`.") : p && nd("A component that acts as a button was rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is not a real <button>, or set the `nativeButton` prop on the component to `true`.");
}, [r]);
const u = i.useCallback(() => {
const p = s.current;
Nx(p) && a && t && l.disabled === void 0 && p.disabled && (p.disabled = !1);
}, [t, l.disabled, a]);
ae(u, [u]);
const d = i.useCallback((p = {}) => {
const {
onClick: g,
onMouseDown: h,
onKeyUp: m,
onKeyDown: v,
onPointerDown: y,
...b
} = p;
return gn({
type: r ? "button" : void 0,
onClick(_) {
if (t) {
_.preventDefault();
return;
}
g?.(_);
},
onMouseDown(_) {
t || h?.(_);
},
onKeyDown(_) {
if (t || (Ia(_), v?.(_)), _.baseUIHandlerPrevented)
return;
const S = _.target === _.currentTarget && !r && !c() && !t, C = _.key === "Enter", R = _.key === " ";
S && ((R || C) && _.preventDefault(), C && g?.(_));
},
onKeyUp(_) {
t || (Ia(_), m?.(_)), !_.baseUIHandlerPrevented && _.target === _.currentTarget && !r && !t && _.key === " " && g?.(_);
},
onPointerDown(_) {
if (t) {
_.preventDefault();
return;
}
y?.(_);
}
}, r ? void 0 : {
role: "button"
}, l, b);
}, [t, l, r, c]), f = Z((p) => {
s.current = p, u();
});
return {
getButtonProps: d,
buttonRef: f
};
}
function Nx(e) {
return ot(e) && e.tagName === "BUTTON";
}
const qo = typeof navigator < "u", la = Px(), Df = Mx(), uc = Ax(), rs = typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter:none"), Ff = (
// iPads can claim to be MacIntel
la.platform === "MacIntel" && la.maxTouchPoints > 1 ? !0 : /iP(hone|ad|od)|iOS/.test(la.platform)
), od = qo && /firefox/i.test(uc), $f = qo && /apple/i.test(navigator.vendor), Qs = qo && /android/i.test(Df) || /android/i.test(uc), Ix = qo && Df.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints, Bf = uc.includes("jsdom/");
function Px() {
if (!qo)
return {
platform: "",
maxTouchPoints: -1
};
const e = navigator.userAgentData;
return e?.platform ? {
platform: e.platform,
maxTouchPoints: navigator.maxTouchPoints
} : {
platform: navigator.platform ?? "",
maxTouchPoints: navigator.maxTouchPoints ?? -1
};
}
function Ax() {
if (!qo)
return "";
const e = navigator.userAgentData;
return e && Array.isArray(e.brands) ? e.brands.map(({
brand: t,
version: n
}) => `${t}/${n}`).join(" ") : navigator.userAgent;
}
function Mx() {
if (!qo)
return "";
const e = navigator.userAgentData;
return e?.platform ? e.platform : navigator.platform ?? "";
}
const Oa = "data-base-ui-focusable", Hf = "active", zf = "selected", dc = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])", uo = "ArrowLeft", fo = "ArrowRight", fc = "ArrowUp", ss = "ArrowDown";
function wt(e) {
let t = e.activeElement;
for (; t?.shadowRoot?.activeElement != null; )
t = t.shadowRoot.activeElement;
return t;
}
function Ae(e, t) {
if (!e || !t)
return !1;
const n = t.getRootNode?.();
if (e.contains(t))
return !0;
if (n && Aa(n)) {
let o = t;
for (; o; ) {
if (e === o)
return !0;
o = o.parentNode || o.host;
}
}
return !1;
}
function rt(e) {
return "composedPath" in e ? e.composedPath()[0] : e.target;
}
function xn(e, t) {
if (t == null)
return !1;
if ("composedPath" in e)
return e.composedPath().includes(t);
const n = e;
return n.target != null && t.contains(n.target);
}
function Tx(e) {
return e.matches("html,body");
}
function st(e) {
return e?.ownerDocument || document;
}
function pc(e) {
return ot(e) && e.matches(dc);
}
function La(e) {
return e ? e.getAttribute("role") === "combobox" && pc(e) : !1;
}
function ei(e) {
if (!e || Bf)
return !0;
try {
return e.matches(":focus-visible");
} catch {
return !0;
}
}
function jr(e) {
return e ? e.hasAttribute(Oa) ? e : e.querySelector(`[${Oa}]`) || e : null;
}
function po(e, t, n = !0) {
return e.filter((r) => r.parentId === t && (!n || r.context?.open)).flatMap((r) => [r, ...po(e, r.id, n)]);
}
function rd(e, t) {
let n = [], o = e.find((r) => r.id === t)?.parentId;
for (; o; ) {
const r = e.find((s) => s.id === o);
o = r?.parentId, r && (n = n.concat(r));
}
return n;
}
function it(e) {
e.preventDefault(), e.stopPropagation();
}
function Ox(e) {
return "nativeEvent" in e;
}
function Uf(e) {
return e.mozInputSource === 0 && e.isTrusted ? !0 : Qs && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function Wf(e) {
return Bf ? !1 : !Qs && e.width === 0 && e.height === 0 || Qs && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
}
function go(e, t) {
const n = ["mouse", "pen"];
return t || n.push("", void 0), n.includes(e);
}
const Lx = ["top", "right", "bottom", "left"], br = Math.min, on = Math.max, vr = Math.round, lr = Math.floor, Dn = (e) => ({
x: e,
y: e
}), kx = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, Vx = {
start: "end",
end: "start"
};
function ka(e, t, n) {
return on(e, br(t, n));
}
function Xn(e, t) {
return typeof e == "function" ? e(t) : e;
}
function Jt(e) {
return e.split("-")[0];
}
function _o(e) {
return e.split("-")[1];
}
function mc(e) {
return e === "x" ? "y" : "x";
}
function gc(e) {
return e === "y" ? "height" : "width";
}
const Dx = /* @__PURE__ */ new Set(["top", "bottom"]);
function un(e) {
return Dx.has(Jt(e)) ? "y" : "x";
}
function hc(e) {
return mc(un(e));
}
function Fx(e, t, n) {
n === void 0 && (n = !1);
const o = _o(e), r = hc(e), s = gc(r);
let a = r === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
return t.reference[s] > t.floating[s] && (a = ti(a)), [a, ti(a)];
}
function $x(e) {
const t = ti(e);
return [Va(e), t, Va(t)];
}
function Va(e) {
return e.replace(/start|end/g, (t) => Vx[t]);
}
const sd = ["left", "right"], id = ["right", "left"], Bx = ["top", "bottom"], Hx = ["bottom", "top"];
function zx(e, t, n) {
switch (e) {
case "top":
case "bottom":
return n ? t ? id : sd : t ? sd : id;
case "left":
case "right":
return t ? Bx : Hx;
default:
return [];
}
}
function Ux(e, t, n, o) {
const r = _o(e);
let s = zx(Jt(e), n === "start", o);
return r && (s = s.map((a) => a + "-" + r), t && (s = s.concat(s.map(Va)))), s;
}
function ti(e) {
return e.replace(/left|right|bottom|top/g, (t) => kx[t]);
}
function Wx(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function Gf(e) {
return typeof e != "number" ? Wx(e) : {
top: e,
right: e,
bottom: e,
left: e
};
}
function ni(e) {
const {
x: t,
y: n,
width: o,
height: r
} = e;
return {
width: o,
height: r,
top: n,
left: t,
right: t + o,
bottom: n + r,
x: t,
y: n
};
}
function Is(e, t, n) {
return Math.floor(e / t) !== n;
}
function fr(e, t) {
return t < 0 || t >= e.current.length;
}
function js(e, t) {
return Ot(e, {
disabledIndices: t
});
}
function Da(e, t) {
return Ot(e, {
decrement: !0,
startingIndex: e.current.length,
disabledIndices: t
});
}
function Ot(e, {
startingIndex: t = -1,
decrement: n = !1,
disabledIndices: o,
amount: r = 1
} = {}) {
let s = t;
do
s += n ? -r : r;
while (s >= 0 && s <= e.current.length - 1 && mo(e, s, o));
return s;
}
function qf(e, {
event: t,
orientation: n,
loopFocus: o,
rtl: r,
cols: s,
disabledIndices: a,
minIndex: c,
maxIndex: l,
prevIndex: u,
stopEvent: d = !1
}) {
let f = u;
const p = [], g = {};
let h = !1;
{
let y = null, b = -1;
e.current.forEach((E, _) => {
if (E == null)
return;
const S = E.closest('[role="row"]');
S && (h = !0), (S !== y || b === -1) && (y = S, b += 1, p[b] = []), p[b].push(_), g[_] = b;
});
}
const m = h && p.length > 0 && p.some((y) => y.length !== s);
function v(y) {
if (!m || u === -1)
return;
const b = g[u];
if (b == null)
return;
const E = p[b].indexOf(u);
let _ = y === "up" ? b - 1 : b + 1;
o && (_ < 0 ? _ = p.length - 1 : _ >= p.length && (_ = 0));
const S = /* @__PURE__ */ new Set();
for (; _ >= 0 && _ < p.length && !S.has(_); ) {
S.add(_);
const C = p[_];
if (C.length === 0) {
_ = y === "up" ? _ - 1 : _ + 1;
continue;
}
const R = Math.min(E, C.length - 1);
for (let P = R; P >= 0; P -= 1) {
const T = C[P];
if (!mo(e, T, a))
return T;
}
_ = y === "up" ? _ - 1 : _ + 1, o && (_ < 0 ? _ = p.length - 1 : _ >= p.length && (_ = 0));
}
}
if (t.key === fc) {
const y = v("up");
if (y !== void 0)
d && it(t), f = y;
else {
if (d && it(t), u === -1)
f = l;
else if (f = Ot(e, {
startingIndex: f,
amount: s,
decrement: !0,
disabledIndices: a
}), o && (u - s < c || f < 0)) {
const b = u % s, E = l % s, _ = l - (E - b);
E === b ? f = l : f = E > b ? _ : _ - s;
}
fr(e, f) && (f = u);
}
}
if (t.key === ss) {
const y = v("down");
y !== void 0 ? (d && it(t), f = y) : (d && it(t), u === -1 ? f = c : (f = Ot(e, {
startingIndex: u,
amount: s,
disabledIndices: a
}), o && u + s > l && (f = Ot(e, {
startingIndex: u % s - s,
amount: s,
disabledIndices: a
}))), fr(e, f) && (f = u));
}
if (n === "both") {
const y = lr(u / s);
t.key === (r ? uo : fo) && (d && it(t), u % s !== s - 1 ? (f = Ot(e, {
startingIndex: u,
disabledIndices: a
}), o && Is(f, s, y) && (f = Ot(e, {
startingIndex: u - u % s - 1,
disabledIndices: a
}))) : o && (f = Ot(e, {
startingIndex: u - u % s - 1,
disabledIndices: a
})), Is(f, s, y) && (f = u)), t.key === (r ? fo : uo) && (d && it(t), u % s !== 0 ? (f = Ot(e, {
startingIndex: u,
decrement: !0,
disabledIndices: a
}), o && Is(f, s, y) && (f = Ot(e, {
startingIndex: u + (s - u % s),
decrement: !0,
disabledIndices: a
}))) : o && (f = Ot(e, {
startingIndex: u + (s - u % s),
decrement: !0,
disabledIndices: a
})), Is(f, s, y) && (f = u));
const b = lr(l / s) === y;
fr(e, f) && (o && b ? f = t.key === (r ? fo : uo) ? l : Ot(e, {
startingIndex: u - u % s - 1,
disabledIndices: a
}) : f = u);
}
return f;
}
function Yf(e, t, n) {
const o = [];
let r = 0;
return e.forEach(({
width: s,
height: a
}, c) => {
if (s > t && process.env.NODE_ENV !== "production")
throw new Error(process.env.NODE_ENV !== "production" ? `[Floating UI]: Invalid grid - item width at index ${c} is greater than grid columns` : Le(29, c));
let l = !1;
for (n && (r = 0); !l; ) {
const u = [];
for (let d = 0; d < s; d += 1)
for (let f = 0; f < a; f += 1)
u.push(r + d + f * t);
r % t + s <= t && u.every((d) => o[d] == null) ? (u.forEach((d) => {
o[d] = c;
}), l = !0) : r += 1;
}
}), [...o];
}
function jf(e, t, n, o, r) {
if (e === -1)
return -1;
const s = n.indexOf(e), a = t[e];
switch (r) {
case "tl":
return s;
case "tr":
return a ? s + a.width - 1 : s;
case "bl":
return a ? s + (a.height - 1) * o : s;
case "br":
return n.lastIndexOf(e);
default:
return -1;
}
}
function Kf(e, t) {
return t.flatMap((n, o) => e.includes(n) ? [o] : []);
}
function mo(e, t, n) {
if (typeof n == "function")
return n(t);
if (n)
return n.includes(t);
const o = e.current[t];
return o ? o.hasAttribute("disabled") || o.getAttribute("aria-disabled") === "true" : !1;
}
var Gx = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], oi = /* @__PURE__ */ Gx.join(","), Xf = typeof Element > "u", yr = Xf ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, ri = !Xf && Element.prototype.getRootNode ? function(e) {
var t;
return e == null || (t = e.getRootNode) === null || t === void 0 ? void 0 : t.call(e);
} : function(e) {
return e?.ownerDocument;
}, Kr = function(t, n) {
var o;
n === void 0 && (n = !0);
var r = t == null || (o = t.getAttribute) === null || o === void 0 ? void 0 : o.call(t, "inert"), s = r === "" || r === "true", a = s || n && t && Kr(t.parentNode);
return a;
}, qx = function(t) {
var n, o = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
return o === "" || o === "true";
}, Zf = function(t, n, o) {
if (Kr(t))
return [];
var r = Array.prototype.slice.apply(t.querySelectorAll(oi));
return n && yr.call(t, oi) && r.unshift(t), r = r.filter(o), r;
}, si = function(t, n, o) {
for (var r = [], s = Array.from(t); s.length; ) {
var a = s.shift();
if (!Kr(a, !1))
if (a.tagName === "SLOT") {
var c = a.assignedElements(), l = c.length ? c : a.children, u = si(l, !0, o);
o.flatten ? r.push.apply(r, u) : r.push({
scopeParent: a,
candidates: u
});
} else {
var d = yr.call(a, oi);
d && o.filter(a) && (n || !t.includes(a)) && r.push(a);
var f = a.shadowRoot || // check for an undisclosed shadow
typeof o.getShadowRoot == "function" && o.getShadowRoot(a), p = !Kr(f, !1) && (!o.shadowRootFilter || o.shadowRootFilter(a));
if (f && p) {
var g = si(f === !0 ? a.children : f.children, !0, o);
o.flatten ? r.push.apply(r, g) : r.push({
scopeParent: a,
candidates: g
});
} else
s.unshift.apply(s, a.children);
}
}
return r;
}, Jf = function(t) {
return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, Qf = function(t) {
if (!t)
throw new Error("No node provided");
return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || qx(t)) && !Jf(t) ? 0 : t.tabIndex;
}, Yx = function(t, n) {
var o = Qf(t);
return o < 0 && n && !Jf(t) ? 0 : o;
}, jx = function(t, n) {
return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
}, ep = function(t) {
return t.tagName === "INPUT";
}, Kx = function(t) {
return ep(t) && t.type === "hidden";
}, Xx = function(t) {
var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(o) {
return o.tagName === "SUMMARY";
});
return n;
}, Zx = function(t, n) {
for (var o = 0; o < t.length; o++)
if (t[o].checked && t[o].form === n)
return t[o];
}, Jx = function(t) {
if (!t.name)
return !0;
var n = t.form || ri(t), o = function(c) {
return n.querySelectorAll('input[type="radio"][name="' + c + '"]');
}, r;
if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
r = o(window.CSS.escape(t.name));
else
try {
r = o(t.name);
} catch (a) {
return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", a.message), !1;
}
var s = Zx(r, t.form);
return !s || s === t;
}, Qx = function(t) {
return ep(t) && t.type === "radio";
}, eE = function(t) {
return Qx(t) && !Jx(t);
}, tE = function(t) {
var n, o = t && ri(t), r = (n = o) === null || n === void 0 ? void 0 : n.host, s = !1;
if (o && o !== t) {
var a, c, l;
for (s = !!((a = r) !== null && a !== void 0 && (c = a.ownerDocument) !== null && c !== void 0 && c.contains(r) || t != null && (l = t.ownerDocument) !== null && l !== void 0 && l.contains(t)); !s && r; ) {
var u, d, f;
o = ri(r), r = (u = o) === null || u === void 0 ? void 0 : u.host, s = !!((d = r) !== null && d !== void 0 && (f = d.ownerDocument) !== null && f !== void 0 && f.contains(r));
}
}
return s;
}, ad = function(t) {
var n = t.getBoundingClientRect(), o = n.width, r = n.height;
return o === 0 && r === 0;
}, nE = function(t, n) {
var o = n.displayCheck, r = n.getShadowRoot;
if (o === "full-native" && "checkVisibility" in t) {
var s = t.checkVisibility({
// Checking opacity might be desirable for some use cases, but natively,
// opacity zero elements _are_ focusable and tabbable.
checkOpacity: !1,
opacityProperty: !1,
contentVisibilityAuto: !0,
visibilityProperty: !0,
// This is an alias for `visibilityProperty`. Contemporary browsers
// support both. However, this alias has wider browser support (Chrome
// >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
// we include it anyway.
checkVisibilityCSS: !0
});
return !s;
}
if (getComputedStyle(t).visibility === "hidden")
return !0;
var a = yr.call(t, "details>summary:first-of-type"), c = a ? t.parentElement : t;
if (yr.call(c, "details:not([open]) *"))
return !0;
if (!o || o === "full" || // full-native can run this branch when it falls through in case
// Element#checkVisibility is unsupported
o === "full-native" || o === "legacy-full") {
if (typeof r == "function") {
for (var l = t; t; ) {
var u = t.parentElement, d = ri(t);
if (u && !u.shadowRoot && r(u) === !0)
return ad(t);
t.assignedSlot ? t = t.assignedSlot : !u && d !== t.ownerDocument ? t = d.host : t = u;
}
t = l;
}
if (tE(t))
return !t.getClientRects().length;
if (o !== "legacy-full")
return !0;
} else if (o === "non-zero-area")
return ad(t);
return !1;
}, oE = function(t) {
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
for (var n = t.parentElement; n; ) {
if (n.tagName === "FIELDSET" && n.disabled) {
for (var o = 0; o < n.children.length; o++) {
var r = n.children.item(o);