@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
1,445 lines (1,440 loc) • 64.6 kB
JavaScript
import * as a from "react";
import j, { useState as Dn } from "react";
import { f as $e, P as O, c as pe, u as $, i as Ue, d as On, e as ht, a as S, b as _e, j as gt, h as Fn } from "./index-35c7f4a2.js";
import { jsx as d } from "react/jsx-runtime";
import { d as oe, u as kn, a as Ln, o as Gn, s as Kn, l as $n, f as Un, b as Bn, c as Wn, h as Hn, e as Be, D as Yn } from "./floating-ui.react-dom-6b2fe0df.js";
import Vn from "react-dom";
var Xn = "Portal", wt = a.forwardRef((e, t) => {
var i;
const { container: n, ...r } = e, [o, c] = a.useState(!1);
$e(() => c(!0), []);
const u = n || o && ((i = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : i.body);
return u ? Vn.createPortal(/* @__PURE__ */ d(O.div, { ...r, ref: t }), u) : null;
});
wt.displayName = Xn;
function yt(e) {
const t = e + "CollectionProvider", [n, r] = pe(t), [o, c] = n(
t,
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
), u = (l) => {
const { scope: v, children: g } = l, b = j.useRef(null), y = j.useRef(/* @__PURE__ */ new Map()).current;
return /* @__PURE__ */ d(o, { scope: v, itemMap: y, collectionRef: b, children: g });
};
u.displayName = t;
const i = e + "CollectionSlot", h = Ue(i), m = j.forwardRef(
(l, v) => {
const { scope: g, children: b } = l, y = c(i, g), E = $(v, y.collectionRef);
return /* @__PURE__ */ d(h, { ref: E, children: b });
}
);
m.displayName = i;
const f = e + "CollectionItemSlot", s = "data-radix-collection-item", p = Ue(f), w = j.forwardRef(
(l, v) => {
const { scope: g, children: b, ...y } = l, E = j.useRef(null), R = $(v, E), P = c(f, g);
return j.useEffect(() => (P.itemMap.set(E, { ref: E, ...y }), () => void P.itemMap.delete(E))), /* @__PURE__ */ d(p, { [s]: "", ref: R, children: b });
}
);
w.displayName = f;
function C(l) {
const v = c(e + "CollectionConsumer", l);
return j.useCallback(() => {
const b = v.collectionRef.current;
if (!b)
return [];
const y = Array.from(b.querySelectorAll(`[${s}]`));
return Array.from(v.itemMap.values()).sort(
(P, I) => y.indexOf(P.ref.current) - y.indexOf(I.ref.current)
);
}, [v.collectionRef, v.itemMap]);
}
return [
{ Provider: u, Slot: m, ItemSlot: w },
C,
r
];
}
var jn = a.createContext(void 0);
function Ct(e) {
const t = a.useContext(jn);
return e || t || "ltr";
}
var Ne = 0;
function zn() {
a.useEffect(() => {
const e = document.querySelectorAll("[data-radix-focus-guard]");
return document.body.insertAdjacentElement("afterbegin", e[0] ?? ot()), document.body.insertAdjacentElement("beforeend", e[1] ?? ot()), Ne++, () => {
Ne === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((t) => t.remove()), Ne--;
};
}, []);
}
function ot() {
const e = document.createElement("span");
return e.setAttribute("data-radix-focus-guard", ""), e.tabIndex = 0, e.style.outline = "none", e.style.opacity = "0", e.style.position = "fixed", e.style.pointerEvents = "none", e;
}
var De = "focusScope.autoFocusOnMount", Oe = "focusScope.autoFocusOnUnmount", at = { bubbles: !1, cancelable: !0 }, Zn = "FocusScope", bt = a.forwardRef((e, t) => {
const {
loop: n = !1,
trapped: r = !1,
onMountAutoFocus: o,
onUnmountAutoFocus: c,
...u
} = e, [i, h] = a.useState(null), m = oe(o), f = oe(c), s = a.useRef(null), p = $(t, (l) => h(l)), w = a.useRef({
paused: !1,
pause() {
this.paused = !0;
},
resume() {
this.paused = !1;
}
}).current;
a.useEffect(() => {
if (r) {
let l = function(y) {
if (w.paused || !i)
return;
const E = y.target;
i.contains(E) ? s.current = E : V(s.current, { select: !0 });
}, v = function(y) {
if (w.paused || !i)
return;
const E = y.relatedTarget;
E !== null && (i.contains(E) || V(s.current, { select: !0 }));
}, g = function(y) {
if (document.activeElement === document.body)
for (const R of y)
R.removedNodes.length > 0 && V(i);
};
document.addEventListener("focusin", l), document.addEventListener("focusout", v);
const b = new MutationObserver(g);
return i && b.observe(i, { childList: !0, subtree: !0 }), () => {
document.removeEventListener("focusin", l), document.removeEventListener("focusout", v), b.disconnect();
};
}
}, [r, i, w.paused]), a.useEffect(() => {
if (i) {
it.add(w);
const l = document.activeElement;
if (!i.contains(l)) {
const g = new CustomEvent(De, at);
i.addEventListener(De, m), i.dispatchEvent(g), g.defaultPrevented || (qn(nr(Et(i)), { select: !0 }), document.activeElement === l && V(i));
}
return () => {
i.removeEventListener(De, m), setTimeout(() => {
const g = new CustomEvent(Oe, at);
i.addEventListener(Oe, f), i.dispatchEvent(g), g.defaultPrevented || V(l ?? document.body, { select: !0 }), i.removeEventListener(Oe, f), it.remove(w);
}, 0);
};
}
}, [i, m, f, w]);
const C = a.useCallback(
(l) => {
if (!n && !r || w.paused)
return;
const v = l.key === "Tab" && !l.altKey && !l.ctrlKey && !l.metaKey, g = document.activeElement;
if (v && g) {
const b = l.currentTarget, [y, E] = Qn(b);
y && E ? !l.shiftKey && g === E ? (l.preventDefault(), n && V(y, { select: !0 })) : l.shiftKey && g === y && (l.preventDefault(), n && V(E, { select: !0 })) : g === b && l.preventDefault();
}
},
[n, r, w.paused]
);
return /* @__PURE__ */ d(O.div, { tabIndex: -1, ...u, ref: p, onKeyDown: C });
});
bt.displayName = Zn;
function qn(e, { select: t = !1 } = {}) {
const n = document.activeElement;
for (const r of e)
if (V(r, { select: t }), document.activeElement !== n)
return;
}
function Qn(e) {
const t = Et(e), n = ct(t, e), r = ct(t.reverse(), e);
return [n, r];
}
function Et(e) {
const t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
acceptNode: (r) => {
const o = r.tagName === "INPUT" && r.type === "hidden";
return r.disabled || r.hidden || o ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
}
});
for (; n.nextNode(); )
t.push(n.currentNode);
return t;
}
function ct(e, t) {
for (const n of e)
if (!Jn(n, { upTo: t }))
return n;
}
function Jn(e, { upTo: t }) {
if (getComputedStyle(e).visibility === "hidden")
return !0;
for (; e; ) {
if (t !== void 0 && e === t)
return !1;
if (getComputedStyle(e).display === "none")
return !0;
e = e.parentElement;
}
return !1;
}
function er(e) {
return e instanceof HTMLInputElement && "select" in e;
}
function V(e, { select: t = !1 } = {}) {
if (e && e.focus) {
const n = document.activeElement;
e.focus({ preventScroll: !0 }), e !== n && er(e) && t && e.select();
}
}
var it = tr();
function tr() {
let e = [];
return {
add(t) {
const n = e[0];
t !== n && (n == null || n.pause()), e = ut(e, t), e.unshift(t);
},
remove(t) {
var n;
e = ut(e, t), (n = e[0]) == null || n.resume();
}
};
}
function ut(e, t) {
const n = [...e], r = n.indexOf(t);
return r !== -1 && n.splice(r, 1), n;
}
function nr(e) {
return e.filter((t) => t.tagName !== "A");
}
var rr = "Arrow", Mt = a.forwardRef((e, t) => {
const { children: n, width: r = 10, height: o = 5, ...c } = e;
return /* @__PURE__ */ d(
O.svg,
{
...c,
ref: t,
width: r,
height: o,
viewBox: "0 0 30 10",
preserveAspectRatio: "none",
children: e.asChild ? n : /* @__PURE__ */ d("polygon", { points: "0,0 30,0 15,10" })
}
);
});
Mt.displayName = rr;
var or = Mt, Ve = "Popper", [St, Rt] = pe(Ve), [ar, Pt] = St(Ve), _t = (e) => {
const { __scopePopper: t, children: n } = e, [r, o] = a.useState(null);
return /* @__PURE__ */ d(ar, { scope: t, anchor: r, onAnchorChange: o, children: n });
};
_t.displayName = Ve;
var It = "PopperAnchor", At = a.forwardRef(
(e, t) => {
const { __scopePopper: n, virtualRef: r, ...o } = e, c = Pt(It, n), u = a.useRef(null), i = $(t, u), h = a.useRef(null);
return a.useEffect(() => {
const m = h.current;
h.current = (r == null ? void 0 : r.current) || u.current, m !== h.current && c.onAnchorChange(h.current);
}), r ? null : /* @__PURE__ */ d(O.div, { ...o, ref: i });
}
);
At.displayName = It;
var Xe = "PopperContent", [cr, ir] = St(Xe), xt = a.forwardRef(
(e, t) => {
var Y, ie, k, ue, tt, nt;
const {
__scopePopper: n,
side: r = "bottom",
sideOffset: o = 0,
align: c = "center",
alignOffset: u = 0,
arrowPadding: i = 0,
avoidCollisions: h = !0,
collisionBoundary: m = [],
collisionPadding: f = 0,
sticky: s = "partial",
hideWhenDetached: p = !1,
updatePositionStrategy: w = "optimized",
onPlaced: C,
...l
} = e, v = Pt(Xe, n), [g, b] = a.useState(null), y = $(t, (se) => b(se)), [E, R] = a.useState(null), P = On(E), I = (P == null ? void 0 : P.width) ?? 0, _ = (P == null ? void 0 : P.height) ?? 0, F = r + (c !== "center" ? "-" + c : ""), G = typeof f == "number" ? f : { top: 0, right: 0, bottom: 0, left: 0, ...f }, N = Array.isArray(m) ? m : [m], U = N.length > 0, H = {
padding: G,
boundary: N.filter(sr),
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
altBoundary: U
}, { refs: q, floatingStyles: Q, placement: K, isPositioned: J, middlewareData: D } = kn({
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
strategy: "fixed",
placement: F,
whileElementsMounted: (...se) => Ln(...se, {
animationFrame: w === "always"
}),
elements: {
reference: v.anchor
},
middleware: [
Gn({ mainAxis: o + _, alignmentAxis: u }),
h && Kn({
mainAxis: !0,
crossAxis: !1,
limiter: s === "partial" ? $n() : void 0,
...H
}),
h && Un({ ...H }),
Bn({
...H,
apply: ({ elements: se, rects: rt, availableWidth: An, availableHeight: xn }) => {
const { width: Tn, height: Nn } = rt.reference, we = se.floating.style;
we.setProperty("--radix-popper-available-width", `${An}px`), we.setProperty("--radix-popper-available-height", `${xn}px`), we.setProperty("--radix-popper-anchor-width", `${Tn}px`), we.setProperty("--radix-popper-anchor-height", `${Nn}px`);
}
}),
E && Wn({ element: E, padding: i }),
lr({ arrowWidth: I, arrowHeight: _ }),
p && Hn({ strategy: "referenceHidden", ...H })
]
}), [M, T] = Dt(K), A = oe(C);
$e(() => {
J && (A == null || A());
}, [J, A]);
const B = (Y = D.arrow) == null ? void 0 : Y.x, ae = (ie = D.arrow) == null ? void 0 : ie.y, ce = ((k = D.arrow) == null ? void 0 : k.centerOffset) !== 0, [ge, X] = a.useState();
return $e(() => {
g && X(window.getComputedStyle(g).zIndex);
}, [g]), /* @__PURE__ */ d(
"div",
{
ref: q.setFloating,
"data-radix-popper-content-wrapper": "",
style: {
...Q,
transform: J ? Q.transform : "translate(0, -200%)",
// keep off the page when measuring
minWidth: "max-content",
zIndex: ge,
"--radix-popper-transform-origin": [
(ue = D.transformOrigin) == null ? void 0 : ue.x,
(tt = D.transformOrigin) == null ? void 0 : tt.y
].join(" "),
// hide the content if using the hide middleware and should be hidden
// set visibility to hidden and disable pointer events so the UI behaves
// as if the PopperContent isn't there at all
...((nt = D.hide) == null ? void 0 : nt.referenceHidden) && {
visibility: "hidden",
pointerEvents: "none"
}
},
dir: e.dir,
children: /* @__PURE__ */ d(
cr,
{
scope: n,
placedSide: M,
onArrowChange: R,
arrowX: B,
arrowY: ae,
shouldHideArrow: ce,
children: /* @__PURE__ */ d(
O.div,
{
"data-side": M,
"data-align": T,
...l,
ref: y,
style: {
...l.style,
// if the PopperContent hasn't been placed yet (not all measurements done)
// we prevent animations so that users's animation don't kick in too early referring wrong sides
animation: J ? void 0 : "none"
}
}
)
}
)
}
);
}
);
xt.displayName = Xe;
var Tt = "PopperArrow", ur = {
top: "bottom",
right: "left",
bottom: "top",
left: "right"
}, Nt = a.forwardRef(function(t, n) {
const { __scopePopper: r, ...o } = t, c = ir(Tt, r), u = ur[c.placedSide];
return (
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
// doesn't report size as we'd expect on SVG elements.
// it reports their bounding box which is effectively the largest path inside the SVG.
/* @__PURE__ */ d(
"span",
{
ref: c.onArrowChange,
style: {
position: "absolute",
left: c.arrowX,
top: c.arrowY,
[u]: 0,
transformOrigin: {
top: "",
right: "0 0",
bottom: "center 0",
left: "100% 0"
}[c.placedSide],
transform: {
top: "translateY(100%)",
right: "translateY(50%) rotate(90deg) translateX(-50%)",
bottom: "rotate(180deg)",
left: "translateY(50%) rotate(-90deg) translateX(50%)"
}[c.placedSide],
visibility: c.shouldHideArrow ? "hidden" : void 0
},
children: /* @__PURE__ */ d(
or,
{
...o,
ref: n,
style: {
...o.style,
// ensures the element can be measured correctly (mostly for if SVG)
display: "block"
}
}
)
}
)
);
});
Nt.displayName = Tt;
function sr(e) {
return e !== null;
}
var lr = (e) => ({
name: "transformOrigin",
options: e,
fn(t) {
var v, g, b;
const { placement: n, rects: r, middlewareData: o } = t, u = ((v = o.arrow) == null ? void 0 : v.centerOffset) !== 0, i = u ? 0 : e.arrowWidth, h = u ? 0 : e.arrowHeight, [m, f] = Dt(n), s = { start: "0%", center: "50%", end: "100%" }[f], p = (((g = o.arrow) == null ? void 0 : g.x) ?? 0) + i / 2, w = (((b = o.arrow) == null ? void 0 : b.y) ?? 0) + h / 2;
let C = "", l = "";
return m === "bottom" ? (C = u ? s : `${p}px`, l = `${-h}px`) : m === "top" ? (C = u ? s : `${p}px`, l = `${r.floating.height + h}px`) : m === "right" ? (C = `${-h}px`, l = u ? s : `${w}px`) : m === "left" && (C = `${r.floating.width + h}px`, l = u ? s : `${w}px`), { data: { x: C, y: l } };
}
});
function Dt(e) {
const [t, n = "center"] = e.split("-");
return [t, n];
}
var dr = _t, fr = At, pr = xt, vr = Nt, Fe = "rovingFocusGroup.onEntryFocus", mr = { bubbles: !1, cancelable: !0 }, ve = "RovingFocusGroup", [We, Ot, hr] = yt(ve), [gr, Ft] = pe(
ve,
[hr]
), [wr, yr] = gr(ve), kt = a.forwardRef(
(e, t) => /* @__PURE__ */ d(We.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(We.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(Cr, { ...e, ref: t }) }) })
);
kt.displayName = ve;
var Cr = a.forwardRef((e, t) => {
const {
__scopeRovingFocusGroup: n,
orientation: r,
loop: o = !1,
dir: c,
currentTabStopId: u,
defaultCurrentTabStopId: i,
onCurrentTabStopIdChange: h,
onEntryFocus: m,
preventScrollOnEntryFocus: f = !1,
...s
} = e, p = a.useRef(null), w = $(t, p), C = Ct(c), [l, v] = ht({
prop: u,
defaultProp: i ?? null,
onChange: h,
caller: ve
}), [g, b] = a.useState(!1), y = oe(m), E = Ot(n), R = a.useRef(!1), [P, I] = a.useState(0);
return a.useEffect(() => {
const _ = p.current;
if (_)
return _.addEventListener(Fe, y), () => _.removeEventListener(Fe, y);
}, [y]), /* @__PURE__ */ d(
wr,
{
scope: n,
orientation: r,
dir: C,
loop: o,
currentTabStopId: l,
onItemFocus: a.useCallback(
(_) => v(_),
[v]
),
onItemShiftTab: a.useCallback(() => b(!0), []),
onFocusableItemAdd: a.useCallback(
() => I((_) => _ + 1),
[]
),
onFocusableItemRemove: a.useCallback(
() => I((_) => _ - 1),
[]
),
children: /* @__PURE__ */ d(
O.div,
{
tabIndex: g || P === 0 ? -1 : 0,
"data-orientation": r,
...s,
ref: w,
style: { outline: "none", ...e.style },
onMouseDown: S(e.onMouseDown, () => {
R.current = !0;
}),
onFocus: S(e.onFocus, (_) => {
const F = !R.current;
if (_.target === _.currentTarget && F && !g) {
const G = new CustomEvent(Fe, mr);
if (_.currentTarget.dispatchEvent(G), !G.defaultPrevented) {
const N = E().filter((K) => K.focusable), U = N.find((K) => K.active), H = N.find((K) => K.id === l), Q = [U, H, ...N].filter(
Boolean
).map((K) => K.ref.current);
Kt(Q, f);
}
}
R.current = !1;
}),
onBlur: S(e.onBlur, () => b(!1))
}
)
}
);
}), Lt = "RovingFocusGroupItem", Gt = a.forwardRef(
(e, t) => {
const {
__scopeRovingFocusGroup: n,
focusable: r = !0,
active: o = !1,
tabStopId: c,
children: u,
...i
} = e, h = Be(), m = c || h, f = yr(Lt, n), s = f.currentTabStopId === m, p = Ot(n), { onFocusableItemAdd: w, onFocusableItemRemove: C, currentTabStopId: l } = f;
return a.useEffect(() => {
if (r)
return w(), () => C();
}, [r, w, C]), /* @__PURE__ */ d(
We.ItemSlot,
{
scope: n,
id: m,
focusable: r,
active: o,
children: /* @__PURE__ */ d(
O.span,
{
tabIndex: s ? 0 : -1,
"data-orientation": f.orientation,
...i,
ref: t,
onMouseDown: S(e.onMouseDown, (v) => {
r ? f.onItemFocus(m) : v.preventDefault();
}),
onFocus: S(e.onFocus, () => f.onItemFocus(m)),
onKeyDown: S(e.onKeyDown, (v) => {
if (v.key === "Tab" && v.shiftKey) {
f.onItemShiftTab();
return;
}
if (v.target !== v.currentTarget)
return;
const g = Mr(v, f.orientation, f.dir);
if (g !== void 0) {
if (v.metaKey || v.ctrlKey || v.altKey || v.shiftKey)
return;
v.preventDefault();
let y = p().filter((E) => E.focusable).map((E) => E.ref.current);
if (g === "last")
y.reverse();
else if (g === "prev" || g === "next") {
g === "prev" && y.reverse();
const E = y.indexOf(v.currentTarget);
y = f.loop ? Sr(y, E + 1) : y.slice(E + 1);
}
setTimeout(() => Kt(y));
}
}),
children: typeof u == "function" ? u({ isCurrentTabStop: s, hasTabStop: l != null }) : u
}
)
}
);
}
);
Gt.displayName = Lt;
var br = {
ArrowLeft: "prev",
ArrowUp: "prev",
ArrowRight: "next",
ArrowDown: "next",
PageUp: "first",
Home: "first",
PageDown: "last",
End: "last"
};
function Er(e, t) {
return t !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
}
function Mr(e, t, n) {
const r = Er(e.key, n);
if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(r)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(r)))
return br[r];
}
function Kt(e, t = !1) {
const n = document.activeElement;
for (const r of e)
if (r === n || (r.focus({ preventScroll: t }), document.activeElement !== n))
return;
}
function Sr(e, t) {
return e.map((n, r) => e[(t + r) % e.length]);
}
var Rr = kt, Pr = Gt, _r = function(e) {
if (typeof document > "u")
return null;
var t = Array.isArray(e) ? e[0] : e;
return t.ownerDocument.body;
}, ee = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), Ce = {}, ke = 0, $t = function(e) {
return e && (e.host || $t(e.parentNode));
}, Ir = function(e, t) {
return t.map(function(n) {
if (e.contains(n))
return n;
var r = $t(n);
return r && e.contains(r) ? r : (console.error("aria-hidden", n, "in not contained inside", e, ". Doing nothing"), null);
}).filter(function(n) {
return !!n;
});
}, Ar = function(e, t, n, r) {
var o = Ir(t, Array.isArray(e) ? e : [e]);
Ce[n] || (Ce[n] = /* @__PURE__ */ new WeakMap());
var c = Ce[n], u = [], i = /* @__PURE__ */ new Set(), h = new Set(o), m = function(s) {
!s || i.has(s) || (i.add(s), m(s.parentNode));
};
o.forEach(m);
var f = function(s) {
!s || h.has(s) || Array.prototype.forEach.call(s.children, function(p) {
if (i.has(p))
f(p);
else
try {
var w = p.getAttribute(r), C = w !== null && w !== "false", l = (ee.get(p) || 0) + 1, v = (c.get(p) || 0) + 1;
ee.set(p, l), c.set(p, v), u.push(p), l === 1 && C && ye.set(p, !0), v === 1 && p.setAttribute(n, "true"), C || p.setAttribute(r, "true");
} catch (g) {
console.error("aria-hidden: cannot operate on ", p, g);
}
});
};
return f(t), i.clear(), ke++, function() {
u.forEach(function(s) {
var p = ee.get(s) - 1, w = c.get(s) - 1;
ee.set(s, p), c.set(s, w), p || (ye.has(s) || s.removeAttribute(r), ye.delete(s)), w || s.removeAttribute(n);
}), ke--, ke || (ee = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), Ce = {});
};
}, xr = function(e, t, n) {
n === void 0 && (n = "data-aria-hidden");
var r = Array.from(Array.isArray(e) ? e : [e]), o = t || _r(e);
return o ? (r.push.apply(r, Array.from(o.querySelectorAll("[aria-live], script"))), Ar(r, o, n, "aria-hidden")) : function() {
return null;
};
}, W = function() {
return W = Object.assign || function(t) {
for (var n, r = 1, o = arguments.length; r < o; r++) {
n = arguments[r];
for (var c in n)
Object.prototype.hasOwnProperty.call(n, c) && (t[c] = n[c]);
}
return t;
}, W.apply(this, arguments);
};
function Ut(e, t) {
var n = {};
for (var r in e)
Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
if (e != null && typeof Object.getOwnPropertySymbols == "function")
for (var o = 0, r = Object.getOwnPropertySymbols(e); o < r.length; o++)
t.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[o]) && (n[r[o]] = e[r[o]]);
return n;
}
function Tr(e, t, n) {
if (n || arguments.length === 2)
for (var r = 0, o = t.length, c; r < o; r++)
(c || !(r in t)) && (c || (c = Array.prototype.slice.call(t, 0, r)), c[r] = t[r]);
return e.concat(c || Array.prototype.slice.call(t));
}
var Me = "right-scroll-bar-position", Se = "width-before-scroll-bar", Nr = "with-scroll-bars-hidden", Dr = "--removed-body-scroll-bar-size";
function Le(e, t) {
return typeof e == "function" ? e(t) : e && (e.current = t), e;
}
function Or(e, t) {
var n = Dn(function() {
return {
// value
value: e,
// last callback
callback: t,
// "memoized" public interface
facade: {
get current() {
return n.value;
},
set current(r) {
var o = n.value;
o !== r && (n.value = r, n.callback(r, o));
}
}
};
})[0];
return n.callback = t, n.facade;
}
var Fr = typeof window < "u" ? a.useLayoutEffect : a.useEffect, st = /* @__PURE__ */ new WeakMap();
function kr(e, t) {
var n = Or(t || null, function(r) {
return e.forEach(function(o) {
return Le(o, r);
});
});
return Fr(function() {
var r = st.get(n);
if (r) {
var o = new Set(r), c = new Set(e), u = n.current;
o.forEach(function(i) {
c.has(i) || Le(i, null);
}), c.forEach(function(i) {
o.has(i) || Le(i, u);
});
}
st.set(n, e);
}, [e]), n;
}
function Lr(e) {
return e;
}
function Gr(e, t) {
t === void 0 && (t = Lr);
var n = [], r = !1, o = {
read: function() {
if (r)
throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
return n.length ? n[n.length - 1] : e;
},
useMedium: function(c) {
var u = t(c, r);
return n.push(u), function() {
n = n.filter(function(i) {
return i !== u;
});
};
},
assignSyncMedium: function(c) {
for (r = !0; n.length; ) {
var u = n;
n = [], u.forEach(c);
}
n = {
push: function(i) {
return c(i);
},
filter: function() {
return n;
}
};
},
assignMedium: function(c) {
r = !0;
var u = [];
if (n.length) {
var i = n;
n = [], i.forEach(c), u = n;
}
var h = function() {
var f = u;
u = [], f.forEach(c);
}, m = function() {
return Promise.resolve().then(h);
};
m(), n = {
push: function(f) {
u.push(f), m();
},
filter: function(f) {
return u = u.filter(f), n;
}
};
}
};
return o;
}
function Kr(e) {
e === void 0 && (e = {});
var t = Gr(null);
return t.options = W({ async: !0, ssr: !1 }, e), t;
}
var Bt = function(e) {
var t = e.sideCar, n = Ut(e, ["sideCar"]);
if (!t)
throw new Error("Sidecar: please provide `sideCar` property to import the right car");
var r = t.read();
if (!r)
throw new Error("Sidecar medium not found");
return a.createElement(r, W({}, n));
};
Bt.isSideCarExport = !0;
function $r(e, t) {
return e.useMedium(t), Bt;
}
var Wt = Kr(), Ge = function() {
}, Ie = a.forwardRef(function(e, t) {
var n = a.useRef(null), r = a.useState({
onScrollCapture: Ge,
onWheelCapture: Ge,
onTouchMoveCapture: Ge
}), o = r[0], c = r[1], u = e.forwardProps, i = e.children, h = e.className, m = e.removeScrollBar, f = e.enabled, s = e.shards, p = e.sideCar, w = e.noRelative, C = e.noIsolation, l = e.inert, v = e.allowPinchZoom, g = e.as, b = g === void 0 ? "div" : g, y = e.gapMode, E = Ut(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), R = p, P = kr([n, t]), I = W(W({}, E), o);
return a.createElement(
a.Fragment,
null,
f && a.createElement(R, { sideCar: Wt, removeScrollBar: m, shards: s, noRelative: w, noIsolation: C, inert: l, setCallbacks: c, allowPinchZoom: !!v, lockRef: n, gapMode: y }),
u ? a.cloneElement(a.Children.only(i), W(W({}, I), { ref: P })) : a.createElement(b, W({}, I, { className: h, ref: P }), i)
);
});
Ie.defaultProps = {
enabled: !0,
removeScrollBar: !0,
inert: !1
};
Ie.classNames = {
fullWidth: Se,
zeroRight: Me
};
var lt, Ur = function() {
if (lt)
return lt;
if (typeof __webpack_nonce__ < "u")
return __webpack_nonce__;
};
function Br() {
if (!document)
return null;
var e = document.createElement("style");
e.type = "text/css";
var t = Ur();
return t && e.setAttribute("nonce", t), e;
}
function Wr(e, t) {
e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
}
function Hr(e) {
var t = document.head || document.getElementsByTagName("head")[0];
t.appendChild(e);
}
var Yr = function() {
var e = 0, t = null;
return {
add: function(n) {
e == 0 && (t = Br()) && (Wr(t, n), Hr(t)), e++;
},
remove: function() {
e--, !e && t && (t.parentNode && t.parentNode.removeChild(t), t = null);
}
};
}, Vr = function() {
var e = Yr();
return function(t, n) {
a.useEffect(function() {
return e.add(t), function() {
e.remove();
};
}, [t && n]);
};
}, Ht = function() {
var e = Vr(), t = function(n) {
var r = n.styles, o = n.dynamic;
return e(r, o), null;
};
return t;
}, Xr = {
left: 0,
top: 0,
right: 0,
gap: 0
}, Ke = function(e) {
return parseInt(e || "", 10) || 0;
}, jr = function(e) {
var t = window.getComputedStyle(document.body), n = t[e === "padding" ? "paddingLeft" : "marginLeft"], r = t[e === "padding" ? "paddingTop" : "marginTop"], o = t[e === "padding" ? "paddingRight" : "marginRight"];
return [Ke(n), Ke(r), Ke(o)];
}, zr = function(e) {
if (e === void 0 && (e = "margin"), typeof window > "u")
return Xr;
var t = jr(e), n = document.documentElement.clientWidth, r = window.innerWidth;
return {
left: t[0],
top: t[1],
right: t[2],
gap: Math.max(0, r - n + t[2] - t[0])
};
}, Zr = Ht(), re = "data-scroll-locked", qr = function(e, t, n, r) {
var o = e.left, c = e.top, u = e.right, i = e.gap;
return n === void 0 && (n = "margin"), `
.`.concat(Nr, ` {
overflow: hidden `).concat(r, `;
padding-right: `).concat(i, "px ").concat(r, `;
}
body[`).concat(re, `] {
overflow: hidden `).concat(r, `;
overscroll-behavior: contain;
`).concat([
t && "position: relative ".concat(r, ";"),
n === "margin" && `
padding-left: `.concat(o, `px;
padding-top: `).concat(c, `px;
padding-right: `).concat(u, `px;
margin-left:0;
margin-top:0;
margin-right: `).concat(i, "px ").concat(r, `;
`),
n === "padding" && "padding-right: ".concat(i, "px ").concat(r, ";")
].filter(Boolean).join(""), `
}
.`).concat(Me, ` {
right: `).concat(i, "px ").concat(r, `;
}
.`).concat(Se, ` {
margin-right: `).concat(i, "px ").concat(r, `;
}
.`).concat(Me, " .").concat(Me, ` {
right: 0 `).concat(r, `;
}
.`).concat(Se, " .").concat(Se, ` {
margin-right: 0 `).concat(r, `;
}
body[`).concat(re, `] {
`).concat(Dr, ": ").concat(i, `px;
}
`);
}, dt = function() {
var e = parseInt(document.body.getAttribute(re) || "0", 10);
return isFinite(e) ? e : 0;
}, Qr = function() {
a.useEffect(function() {
return document.body.setAttribute(re, (dt() + 1).toString()), function() {
var e = dt() - 1;
e <= 0 ? document.body.removeAttribute(re) : document.body.setAttribute(re, e.toString());
};
}, []);
}, Jr = function(e) {
var t = e.noRelative, n = e.noImportant, r = e.gapMode, o = r === void 0 ? "margin" : r;
Qr();
var c = a.useMemo(function() {
return zr(o);
}, [o]);
return a.createElement(Zr, { styles: qr(c, !t, o, n ? "" : "!important") });
}, He = !1;
if (typeof window < "u")
try {
var be = Object.defineProperty({}, "passive", {
get: function() {
return He = !0, !0;
}
});
window.addEventListener("test", be, be), window.removeEventListener("test", be, be);
} catch {
He = !1;
}
var te = He ? { passive: !1 } : !1, eo = function(e) {
return e.tagName === "TEXTAREA";
}, Yt = function(e, t) {
if (!(e instanceof Element))
return !1;
var n = window.getComputedStyle(e);
return (
// not-not-scrollable
n[t] !== "hidden" && // contains scroll inside self
!(n.overflowY === n.overflowX && !eo(e) && n[t] === "visible")
);
}, to = function(e) {
return Yt(e, "overflowY");
}, no = function(e) {
return Yt(e, "overflowX");
}, ft = function(e, t) {
var n = t.ownerDocument, r = t;
do {
typeof ShadowRoot < "u" && r instanceof ShadowRoot && (r = r.host);
var o = Vt(e, r);
if (o) {
var c = Xt(e, r), u = c[1], i = c[2];
if (u > i)
return !0;
}
r = r.parentNode;
} while (r && r !== n.body);
return !1;
}, ro = function(e) {
var t = e.scrollTop, n = e.scrollHeight, r = e.clientHeight;
return [
t,
n,
r
];
}, oo = function(e) {
var t = e.scrollLeft, n = e.scrollWidth, r = e.clientWidth;
return [
t,
n,
r
];
}, Vt = function(e, t) {
return e === "v" ? to(t) : no(t);
}, Xt = function(e, t) {
return e === "v" ? ro(t) : oo(t);
}, ao = function(e, t) {
return e === "h" && t === "rtl" ? -1 : 1;
}, co = function(e, t, n, r, o) {
var c = ao(e, window.getComputedStyle(t).direction), u = c * r, i = n.target, h = t.contains(i), m = !1, f = u > 0, s = 0, p = 0;
do {
if (!i)
break;
var w = Xt(e, i), C = w[0], l = w[1], v = w[2], g = l - v - c * C;
(C || g) && Vt(e, i) && (s += g, p += C);
var b = i.parentNode;
i = b && b.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? b.host : b;
} while (
// portaled content
!h && i !== document.body || // self content
h && (t.contains(i) || t === i)
);
return (f && (o && Math.abs(s) < 1 || !o && u > s) || !f && (o && Math.abs(p) < 1 || !o && -u > p)) && (m = !0), m;
}, Ee = function(e) {
return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0];
}, pt = function(e) {
return [e.deltaX, e.deltaY];
}, vt = function(e) {
return e && "current" in e ? e.current : e;
}, io = function(e, t) {
return e[0] === t[0] && e[1] === t[1];
}, uo = function(e) {
return `
.block-interactivity-`.concat(e, ` {pointer-events: none;}
.allow-interactivity-`).concat(e, ` {pointer-events: all;}
`);
}, so = 0, ne = [];
function lo(e) {
var t = a.useRef([]), n = a.useRef([0, 0]), r = a.useRef(), o = a.useState(so++)[0], c = a.useState(Ht)[0], u = a.useRef(e);
a.useEffect(function() {
u.current = e;
}, [e]), a.useEffect(function() {
if (e.inert) {
document.body.classList.add("block-interactivity-".concat(o));
var l = Tr([e.lockRef.current], (e.shards || []).map(vt), !0).filter(Boolean);
return l.forEach(function(v) {
return v.classList.add("allow-interactivity-".concat(o));
}), function() {
document.body.classList.remove("block-interactivity-".concat(o)), l.forEach(function(v) {
return v.classList.remove("allow-interactivity-".concat(o));
});
};
}
}, [e.inert, e.lockRef.current, e.shards]);
var i = a.useCallback(function(l, v) {
if ("touches" in l && l.touches.length === 2 || l.type === "wheel" && l.ctrlKey)
return !u.current.allowPinchZoom;
var g = Ee(l), b = n.current, y = "deltaX" in l ? l.deltaX : b[0] - g[0], E = "deltaY" in l ? l.deltaY : b[1] - g[1], R, P = l.target, I = Math.abs(y) > Math.abs(E) ? "h" : "v";
if ("touches" in l && I === "h" && P.type === "range")
return !1;
var _ = window.getSelection(), F = _ && _.anchorNode, G = F ? F === P || F.contains(P) : !1;
if (G)
return !1;
var N = ft(I, P);
if (!N)
return !0;
if (N ? R = I : (R = I === "v" ? "h" : "v", N = ft(I, P)), !N)
return !1;
if (!r.current && "changedTouches" in l && (y || E) && (r.current = R), !R)
return !0;
var U = r.current || R;
return co(U, v, l, U === "h" ? y : E, !0);
}, []), h = a.useCallback(function(l) {
var v = l;
if (!(!ne.length || ne[ne.length - 1] !== c)) {
var g = "deltaY" in v ? pt(v) : Ee(v), b = t.current.filter(function(R) {
return R.name === v.type && (R.target === v.target || v.target === R.shadowParent) && io(R.delta, g);
})[0];
if (b && b.should) {
v.cancelable && v.preventDefault();
return;
}
if (!b) {
var y = (u.current.shards || []).map(vt).filter(Boolean).filter(function(R) {
return R.contains(v.target);
}), E = y.length > 0 ? i(v, y[0]) : !u.current.noIsolation;
E && v.cancelable && v.preventDefault();
}
}
}, []), m = a.useCallback(function(l, v, g, b) {
var y = { name: l, delta: v, target: g, should: b, shadowParent: fo(g) };
t.current.push(y), setTimeout(function() {
t.current = t.current.filter(function(E) {
return E !== y;
});
}, 1);
}, []), f = a.useCallback(function(l) {
n.current = Ee(l), r.current = void 0;
}, []), s = a.useCallback(function(l) {
m(l.type, pt(l), l.target, i(l, e.lockRef.current));
}, []), p = a.useCallback(function(l) {
m(l.type, Ee(l), l.target, i(l, e.lockRef.current));
}, []);
a.useEffect(function() {
return ne.push(c), e.setCallbacks({
onScrollCapture: s,
onWheelCapture: s,
onTouchMoveCapture: p
}), document.addEventListener("wheel", h, te), document.addEventListener("touchmove", h, te), document.addEventListener("touchstart", f, te), function() {
ne = ne.filter(function(l) {
return l !== c;
}), document.removeEventListener("wheel", h, te), document.removeEventListener("touchmove", h, te), document.removeEventListener("touchstart", f, te);
};
}, []);
var w = e.removeScrollBar, C = e.inert;
return a.createElement(
a.Fragment,
null,
C ? a.createElement(c, { styles: uo(o) }) : null,
w ? a.createElement(Jr, { noRelative: e.noRelative, gapMode: e.gapMode }) : null
);
}
function fo(e) {
for (var t = null; e !== null; )
e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode;
return t;
}
const po = $r(Wt, lo);
var jt = a.forwardRef(function(e, t) {
return a.createElement(Ie, W({}, e, { ref: t, sideCar: po }));
});
jt.classNames = Ie.classNames;
const vo = jt;
var Ye = ["Enter", " "], mo = ["ArrowDown", "PageUp", "Home"], zt = ["ArrowUp", "PageDown", "End"], ho = [...mo, ...zt], go = {
ltr: [...Ye, "ArrowRight"],
rtl: [...Ye, "ArrowLeft"]
}, wo = {
ltr: ["ArrowLeft"],
rtl: ["ArrowRight"]
}, me = "Menu", [de, yo, Co] = yt(me), [z, Zt] = pe(me, [
Co,
Rt,
Ft
]), Ae = Rt(), qt = Ft(), [bo, Z] = z(me), [Eo, he] = z(me), Qt = (e) => {
const { __scopeMenu: t, open: n = !1, children: r, dir: o, onOpenChange: c, modal: u = !0 } = e, i = Ae(t), [h, m] = a.useState(null), f = a.useRef(!1), s = oe(c), p = Ct(o);
return a.useEffect(() => {
const w = () => {
f.current = !0, document.addEventListener("pointerdown", C, { capture: !0, once: !0 }), document.addEventListener("pointermove", C, { capture: !0, once: !0 });
}, C = () => f.current = !1;
return document.addEventListener("keydown", w, { capture: !0 }), () => {
document.removeEventListener("keydown", w, { capture: !0 }), document.removeEventListener("pointerdown", C, { capture: !0 }), document.removeEventListener("pointermove", C, { capture: !0 });
};
}, []), /* @__PURE__ */ d(dr, { ...i, children: /* @__PURE__ */ d(
bo,
{
scope: t,
open: n,
onOpenChange: s,
content: h,
onContentChange: m,
children: /* @__PURE__ */ d(
Eo,
{
scope: t,
onClose: a.useCallback(() => s(!1), [s]),
isUsingKeyboardRef: f,
dir: p,
modal: u,
children: r
}
)
}
) });
};
Qt.displayName = me;
var Mo = "MenuAnchor", je = a.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e, o = Ae(n);
return /* @__PURE__ */ d(fr, { ...o, ...r, ref: t });
}
);
je.displayName = Mo;
var ze = "MenuPortal", [So, Jt] = z(ze, {
forceMount: void 0
}), en = (e) => {
const { __scopeMenu: t, forceMount: n, children: r, container: o } = e, c = Z(ze, t);
return /* @__PURE__ */ d(So, { scope: t, forceMount: n, children: /* @__PURE__ */ d(_e, { present: n || c.open, children: /* @__PURE__ */ d(wt, { asChild: !0, container: o, children: r }) }) });
};
en.displayName = ze;
var L = "MenuContent", [Ro, Ze] = z(L), tn = a.forwardRef(
(e, t) => {
const n = Jt(L, e.__scopeMenu), { forceMount: r = n.forceMount, ...o } = e, c = Z(L, e.__scopeMenu), u = he(L, e.__scopeMenu);
return /* @__PURE__ */ d(de.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ d(_e, { present: r || c.open, children: /* @__PURE__ */ d(de.Slot, { scope: e.__scopeMenu, children: u.modal ? /* @__PURE__ */ d(Po, { ...o, ref: t }) : /* @__PURE__ */ d(_o, { ...o, ref: t }) }) }) });
}
), Po = a.forwardRef(
(e, t) => {
const n = Z(L, e.__scopeMenu), r = a.useRef(null), o = $(t, r);
return a.useEffect(() => {
const c = r.current;
if (c)
return xr(c);
}, []), /* @__PURE__ */ d(
qe,
{
...e,
ref: o,
trapFocus: n.open,
disableOutsidePointerEvents: n.open,
disableOutsideScroll: !0,
onFocusOutside: S(
e.onFocusOutside,
(c) => c.preventDefault(),
{ checkForDefaultPrevented: !1 }
),
onDismiss: () => n.onOpenChange(!1)
}
);
}
), _o = a.forwardRef((e, t) => {
const n = Z(L, e.__scopeMenu);
return /* @__PURE__ */ d(
qe,
{
...e,
ref: t,
trapFocus: !1,
disableOutsidePointerEvents: !1,
disableOutsideScroll: !1,
onDismiss: () => n.onOpenChange(!1)
}
);
}), Io = Ue("MenuContent.ScrollLock"), qe = a.forwardRef(
(e, t) => {
const {
__scopeMenu: n,
loop: r = !1,
trapFocus: o,
onOpenAutoFocus: c,
onCloseAutoFocus: u,
disableOutsidePointerEvents: i,
onEntryFocus: h,
onEscapeKeyDown: m,
onPointerDownOutside: f,
onFocusOutside: s,
onInteractOutside: p,
onDismiss: w,
disableOutsideScroll: C,
...l
} = e, v = Z(L, n), g = he(L, n), b = Ae(n), y = qt(n), E = yo(n), [R, P] = a.useState(null), I = a.useRef(null), _ = $(t, I, v.onContentChange), F = a.useRef(0), G = a.useRef(""), N = a.useRef(0), U = a.useRef(null), H = a.useRef("right"), q = a.useRef(0), Q = C ? vo : a.Fragment, K = C ? { as: Io, allowPinchZoom: !0 } : void 0, J = (M) => {
var Y, ie;
const T = G.current + M, A = E().filter((k) => !k.disabled), B = document.activeElement, ae = (Y = A.find((k) => k.ref.current === B)) == null ? void 0 : Y.textValue, ce = A.map((k) => k.textValue), ge = $o(ce, T, ae), X = (ie = A.find((k) => k.textValue === ge)) == null ? void 0 : ie.ref.current;
(function k(ue) {
G.current = ue, window.clearTimeout(F.current), ue !== "" && (F.current = window.setTimeout(() => k(""), 1e3));
})(T), X && setTimeout(() => X.focus());
};
a.useEffect(() => () => window.clearTimeout(F.current), []), zn();
const D = a.useCallback((M) => {
var A, B;
return H.current === ((A = U.current) == null ? void 0 : A.side) && Bo(M, (B = U.current) == null ? void 0 : B.area);
}, []);
return /* @__PURE__ */ d(
Ro,
{
scope: n,
searchRef: G,
onItemEnter: a.useCallback(
(M) => {
D(M) && M.preventDefault();
},
[D]
),
onItemLeave: a.useCallback(
(M) => {
var T;
D(M) || ((T = I.current) == null || T.focus(), P(null));
},
[D]
),
onTriggerLeave: a.useCallback(
(M) => {
D(M) && M.preventDefault();
},
[D]
),
pointerGraceTimerRef: N,
onPointerGraceIntentChange: a.useCallback((M) => {
U.current = M;
}, []),
children: /* @__PURE__ */ d(Q, { ...K, children: /* @__PURE__ */ d(
bt,
{
asChild: !0,
trapped: o,
onMountAutoFocus: S(c, (M) => {
var T;
M.preventDefault(), (T = I.current) == null || T.focus({ preventScroll: !0 });
}),
onUnmountAutoFocus: u,
children: /* @__PURE__ */ d(
Yn,
{
asChild: !0,
disableOutsidePointerEvents: i,
onEscapeKeyDown: m,
onPointerDownOutside: f,
onFocusOutside: s,
onInteractOutside: p,
onDismiss: w,
children: /* @__PURE__ */ d(
Rr,
{
asChild: !0,
...y,
dir: g.dir,
orientation: "vertical",
loop: r,
currentTabStopId: R,
onCurrentTabStopIdChange: P,
onEntryFocus: S(h, (M) => {
g.isUsingKeyboardRef.current || M.preventDefault();
}),
preventScrollOnEntryFocus: !0,
children: /* @__PURE__ */ d(
pr,
{
role: "menu",
"aria-orientation": "vertical",
"data-state": wn(v.open),
"data-radix-menu-content": "",
dir: g.dir,
...b,
...l,
ref: _,
style: { outline: "none", ...l.style },
onKeyDown: S(l.onKeyDown, (M) => {
const A = M.target.closest("[data-radix-menu-content]") === M.currentTarget, B = M.ctrlKey || M.altKey || M.metaKey, ae = M.key.length === 1;
A && (M.key === "Tab" && M.preventDefault(), !B && ae && J(M.key));
const ce = I.current;
if (M.target !== ce || !ho.includes(M.key))
return;
M.preventDefault();
const X = E().filter((Y) => !Y.disabled).map((Y) => Y.ref.current);
zt.includes(M.key) && X.reverse(), Go(X);
}),
onBlur: S(e.onBlur, (M) => {
M.currentTarget.contains(M.target) || (window.clearTimeout(F.current), G.current = "");
}),
onPointerMove: S(
e.onPointerMove,
fe((M) => {
const T = M.target, A = q.current !== M.clientX;
if (M.currentTarget.contains(T) && A) {
const B = M.clientX > q.current ? "right" : "left";
H.current = B, q.current = M.clientX;
}
})
)
}
)
}
)
}
)
}
) })
}
);
}
);
tn.displayName = L;
var Ao = "MenuGroup", Qe = a.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e;
return /* @__PURE__ */ d(O.div, { role: "group", ...r, ref: t });
}
);
Qe.displayName = Ao;
var xo = "MenuLabel", nn = a.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e;
return /* @__PURE__ */ d(O.div, { ...r, ref: t });
}
);
nn.displayName = xo;
var Re = "MenuItem", mt = "menu.itemSelect", xe = a.forwardRef(
(e, t) => {
const { disabled: n = !1, onSelect: r, ...o } = e, c = a.useRef(null), u = he(Re, e.__scopeMenu), i = Ze(Re, e.__scopeMenu), h = $(t, c), m = a.useRef(!1), f = () => {
const s = c.current;
if (!n && s) {
const p = new CustomEvent(mt, { bubbles: !0, cancelable: !0 });
s.addEventListener(mt, (w) => r == null ? void 0 : r(w), { once: !0 }), Fn(s, p), p.defaultPrevented ? m.current = !1 : u.onClose();
}
};
return /* @__PURE__ */ d(
rn,
{
...o,
ref: h,
disabled: n,
onClick: S(e.onClick, f),
onPointerDown: (s) => {
var p;
(p = e.onPointerDown) == null || p.call(e, s), m.current = !0;
},
onPointerUp: S(e.onPointerUp, (s) => {
var p;
m.current || (p = s.currentTarget) == null || p.click();
}),
onKeyDown: S(e.onKeyDown, (s) => {
const p = i.searchRef.current !== "";
n || p && s.key === " " || Ye.includes(s.key) && (s.currentTarget.click(), s.preventDefault());
})
}
);
}
);
xe.displayName = Re;
var rn = a.forwardRef(
(e, t) => {
const { __scopeMenu: n, disabled: r = !1, textValue: o, ...c } = e, u = Ze(Re, n), i = qt(n), h = a.useRef(null), m = $(t, h), [f, s] = a.useState(!1), [p, w] = a.useState("");
return a.useEffect(() => {
const C = h.current;
C && w((C.textContent ?? "").trim());
}, [c.children]), /* @__PURE__ */ d(
de.ItemSlot,
{
scope: n,
disabled: r,
textValue: o ?? p,
children: /* @__PURE__ */ d(Pr, { asChild: !0, ...i, focusable: !r, children: /* @__PURE__ */ d(
O.div,
{
role: "menuitem",
"data-highlighted": f ? "" : void 0,
"aria-disabled": r || void 0,
"data-disabled": r ? "" : void 0,
...c,
ref: m,
onPointerMove: S(
e.onPointerMove,
fe((C) => {
r ? u.onItemLeave(C) : (u.onItemEnter(C), C.defaultPrevented || C.currentTarget.focus({ preventScroll: !0 }));
})
),
onPointerLeave: S(
e.onPointerLeave,
fe((C) => u.onItemLeave(C))
),
onFocus: S(e.onFocus, () => s(!0)),
onBlur: S(e.onBlur, () => s(!1))
}
) })
}
);
}
), To = "MenuCheckboxItem", on = a.forwardR