@pdf-viewer/react
Version:
The PDF Viewer component for React and Next.js
1,422 lines • 54.6 kB
JavaScript
import * as o from "react";
import V from "react";
import { b as xe, P as D, e as de, a as K, i as Te, u as ne, h as gn, f as ot, c as S, g as Me, j as at, d as wn } from "./index-1cb41342.js";
import { jsx as l } from "react/jsx-runtime";
import { u as Ne, D as Cn } from "./index-aa2d3884.js";
import { u as Mn, a as En, o as Rn, s as bn, l as Sn, f as yn, b as _n, c as Pn, h as In } from "./floating-ui.react-dom-15b9b819.js";
import An from "react-dom";
import { c as xn, _ as Tn, u as Nn, a as te, f as Dn, z as On, s as Fn, b as kn, R as Ln, e as Kn, h as Gn } from "./component-1da194e8.js";
var $n = "Portal", ct = o.forwardRef((e, t) => {
var s;
const { container: n, ...r } = e, [a, c] = o.useState(!1);
xe(() => c(!0), []);
const u = n || a && ((s = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : s.body);
return u ? An.createPortal(/* @__PURE__ */ l(D.div, { ...r, ref: t }), u) : null;
});
ct.displayName = $n;
function st(e) {
const t = e + "CollectionProvider", [n, r] = de(t), [a, c] = n(
t,
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
), u = (C) => {
const { scope: f, children: i } = C, w = V.useRef(null), h = V.useRef(/* @__PURE__ */ new Map()).current;
return /* @__PURE__ */ l(a, { scope: f, itemMap: h, collectionRef: w, children: i });
};
u.displayName = t;
const s = e + "CollectionSlot", m = V.forwardRef(
(C, f) => {
const { scope: i, children: w } = C, h = c(s, i), M = K(f, h.collectionRef);
return /* @__PURE__ */ l(Te, { ref: M, children: w });
}
);
m.displayName = s;
const p = e + "CollectionItemSlot", v = "data-radix-collection-item", d = V.forwardRef(
(C, f) => {
const { scope: i, children: w, ...h } = C, M = V.useRef(null), R = K(f, M), b = c(p, i);
return V.useEffect(() => (b.itemMap.set(M, { ref: M, ...h }), () => void b.itemMap.delete(M))), /* @__PURE__ */ l(Te, { [v]: "", ref: R, children: w });
}
);
d.displayName = p;
function g(C) {
const f = c(e + "CollectionConsumer", C);
return V.useCallback(() => {
const w = f.collectionRef.current;
if (!w)
return [];
const h = Array.from(w.querySelectorAll(`[${v}]`));
return Array.from(f.itemMap.values()).sort(
(b, y) => h.indexOf(b.ref.current) - h.indexOf(y.ref.current)
);
}, [f.collectionRef, f.itemMap]);
}
return [
{ Provider: u, Slot: m, ItemSlot: d },
g,
r
];
}
var Un = o.createContext(void 0);
function it(e) {
const t = o.useContext(Un);
return e || t || "ltr";
}
var ye = 0;
function Bn() {
o.useEffect(() => {
const e = document.querySelectorAll("[data-radix-focus-guard]");
return document.body.insertAdjacentElement("afterbegin", e[0] ?? ze()), document.body.insertAdjacentElement("beforeend", e[1] ?? ze()), ye++, () => {
ye === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((t) => t.remove()), ye--;
};
}, []);
}
function ze() {
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 _e = "focusScope.autoFocusOnMount", Pe = "focusScope.autoFocusOnUnmount", Ze = { bubbles: !1, cancelable: !0 }, Yn = "FocusScope", ut = o.forwardRef((e, t) => {
const {
loop: n = !1,
trapped: r = !1,
onMountAutoFocus: a,
onUnmountAutoFocus: c,
...u
} = e, [s, m] = o.useState(null), p = ne(a), v = ne(c), d = o.useRef(null), g = K(t, (i) => m(i)), C = o.useRef({
paused: !1,
pause() {
this.paused = !0;
},
resume() {
this.paused = !1;
}
}).current;
o.useEffect(() => {
if (r) {
let i = function(R) {
if (C.paused || !s)
return;
const b = R.target;
s.contains(b) ? d.current = b : H(d.current, { select: !0 });
}, w = function(R) {
if (C.paused || !s)
return;
const b = R.relatedTarget;
b !== null && (s.contains(b) || H(d.current, { select: !0 }));
}, h = function(R) {
if (document.activeElement === document.body)
for (const y of R)
y.removedNodes.length > 0 && H(s);
};
document.addEventListener("focusin", i), document.addEventListener("focusout", w);
const M = new MutationObserver(h);
return s && M.observe(s, { childList: !0, subtree: !0 }), () => {
document.removeEventListener("focusin", i), document.removeEventListener("focusout", w), M.disconnect();
};
}
}, [r, s, C.paused]), o.useEffect(() => {
if (s) {
Qe.add(C);
const i = document.activeElement;
if (!s.contains(i)) {
const h = new CustomEvent(_e, Ze);
s.addEventListener(_e, p), s.dispatchEvent(h), h.defaultPrevented || (Hn(zn(lt(s)), { select: !0 }), document.activeElement === i && H(s));
}
return () => {
s.removeEventListener(_e, p), setTimeout(() => {
const h = new CustomEvent(Pe, Ze);
s.addEventListener(Pe, v), s.dispatchEvent(h), h.defaultPrevented || H(i ?? document.body, { select: !0 }), s.removeEventListener(Pe, v), Qe.remove(C);
}, 0);
};
}
}, [s, p, v, C]);
const f = o.useCallback(
(i) => {
if (!n && !r || C.paused)
return;
const w = i.key === "Tab" && !i.altKey && !i.ctrlKey && !i.metaKey, h = document.activeElement;
if (w && h) {
const M = i.currentTarget, [R, b] = Wn(M);
R && b ? !i.shiftKey && h === b ? (i.preventDefault(), n && H(R, { select: !0 })) : i.shiftKey && h === R && (i.preventDefault(), n && H(b, { select: !0 })) : h === M && i.preventDefault();
}
},
[n, r, C.paused]
);
return /* @__PURE__ */ l(D.div, { tabIndex: -1, ...u, ref: g, onKeyDown: f });
});
ut.displayName = Yn;
function Hn(e, { select: t = !1 } = {}) {
const n = document.activeElement;
for (const r of e)
if (H(r, { select: t }), document.activeElement !== n)
return;
}
function Wn(e) {
const t = lt(e), n = qe(t, e), r = qe(t.reverse(), e);
return [n, r];
}
function lt(e) {
const t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
acceptNode: (r) => {
const a = r.tagName === "INPUT" && r.type === "hidden";
return r.disabled || r.hidden || a ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
}
});
for (; n.nextNode(); )
t.push(n.currentNode);
return t;
}
function qe(e, t) {
for (const n of e)
if (!Xn(n, { upTo: t }))
return n;
}
function Xn(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 Vn(e) {
return e instanceof HTMLInputElement && "select" in e;
}
function H(e, { select: t = !1 } = {}) {
if (e && e.focus) {
const n = document.activeElement;
e.focus({ preventScroll: !0 }), e !== n && Vn(e) && t && e.select();
}
}
var Qe = jn();
function jn() {
let e = [];
return {
add(t) {
const n = e[0];
t !== n && (n == null || n.pause()), e = Je(e, t), e.unshift(t);
},
remove(t) {
var n;
e = Je(e, t), (n = e[0]) == null || n.resume();
}
};
}
function Je(e, t) {
const n = [...e], r = n.indexOf(t);
return r !== -1 && n.splice(r, 1), n;
}
function zn(e) {
return e.filter((t) => t.tagName !== "A");
}
var Zn = "Arrow", dt = o.forwardRef((e, t) => {
const { children: n, width: r = 10, height: a = 5, ...c } = e;
return /* @__PURE__ */ l(
D.svg,
{
...c,
ref: t,
width: r,
height: a,
viewBox: "0 0 30 10",
preserveAspectRatio: "none",
children: e.asChild ? n : /* @__PURE__ */ l("polygon", { points: "0,0 30,0 15,10" })
}
);
});
dt.displayName = Zn;
var qn = dt, ke = "Popper", [ft, pt] = de(ke), [Qn, mt] = ft(ke), vt = (e) => {
const { __scopePopper: t, children: n } = e, [r, a] = o.useState(null);
return /* @__PURE__ */ l(Qn, { scope: t, anchor: r, onAnchorChange: a, children: n });
};
vt.displayName = ke;
var ht = "PopperAnchor", gt = o.forwardRef(
(e, t) => {
const { __scopePopper: n, virtualRef: r, ...a } = e, c = mt(ht, n), u = o.useRef(null), s = K(t, u);
return o.useEffect(() => {
c.onAnchorChange((r == null ? void 0 : r.current) || u.current);
}), r ? null : /* @__PURE__ */ l(D.div, { ...a, ref: s });
}
);
gt.displayName = ht;
var Le = "PopperContent", [Jn, er] = ft(Le), wt = o.forwardRef(
(e, t) => {
var B, ae, O, ce, Xe, Ve;
const {
__scopePopper: n,
side: r = "bottom",
sideOffset: a = 0,
align: c = "center",
alignOffset: u = 0,
arrowPadding: s = 0,
avoidCollisions: m = !0,
collisionBoundary: p = [],
collisionPadding: v = 0,
sticky: d = "partial",
hideWhenDetached: g = !1,
updatePositionStrategy: C = "optimized",
onPlaced: f,
...i
} = e, w = mt(Le, n), [h, M] = o.useState(null), R = K(t, (se) => M(se)), [b, y] = o.useState(null), P = gn(b), I = (P == null ? void 0 : P.width) ?? 0, _ = (P == null ? void 0 : P.height) ?? 0, k = r + (c !== "center" ? "-" + c : ""), $ = typeof v == "number" ? v : { top: 0, right: 0, bottom: 0, left: 0, ...v }, Y = Array.isArray(p) ? p : [p], W = Y.length > 0, U = {
padding: $,
boundary: Y.filter(nr),
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
altBoundary: W
}, { refs: Z, floatingStyles: q, placement: L, isPositioned: Q, middlewareData: N } = Mn({
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
strategy: "fixed",
placement: k,
whileElementsMounted: (...se) => En(...se, {
animationFrame: C === "always"
}),
elements: {
reference: w.anchor
},
middleware: [
Rn({ mainAxis: a + _, alignmentAxis: u }),
m && bn({
mainAxis: !0,
crossAxis: !1,
limiter: d === "partial" ? Sn() : void 0,
...U
}),
m && yn({ ...U }),
_n({
...U,
apply: ({ elements: se, rects: je, availableWidth: pn, availableHeight: mn }) => {
const { width: vn, height: hn } = je.reference, ve = se.floating.style;
ve.setProperty("--radix-popper-available-width", `${pn}px`), ve.setProperty("--radix-popper-available-height", `${mn}px`), ve.setProperty("--radix-popper-anchor-width", `${vn}px`), ve.setProperty("--radix-popper-anchor-height", `${hn}px`);
}
}),
b && Pn({ element: b, padding: s }),
rr({ arrowWidth: I, arrowHeight: _ }),
g && In({ strategy: "referenceHidden", ...U })
]
}), [E, T] = Et(L), A = ne(f);
xe(() => {
Q && (A == null || A());
}, [Q, A]);
const G = (B = N.arrow) == null ? void 0 : B.x, re = (ae = N.arrow) == null ? void 0 : ae.y, oe = ((O = N.arrow) == null ? void 0 : O.centerOffset) !== 0, [me, X] = o.useState();
return xe(() => {
h && X(window.getComputedStyle(h).zIndex);
}, [h]), /* @__PURE__ */ l(
"div",
{
ref: Z.setFloating,
"data-radix-popper-content-wrapper": "",
style: {
...q,
transform: Q ? q.transform : "translate(0, -200%)",
// keep off the page when measuring
minWidth: "max-content",
zIndex: me,
"--radix-popper-transform-origin": [
(ce = N.transformOrigin) == null ? void 0 : ce.x,
(Xe = N.transformOrigin) == null ? void 0 : Xe.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
...((Ve = N.hide) == null ? void 0 : Ve.referenceHidden) && {
visibility: "hidden",
pointerEvents: "none"
}
},
dir: e.dir,
children: /* @__PURE__ */ l(
Jn,
{
scope: n,
placedSide: E,
onArrowChange: y,
arrowX: G,
arrowY: re,
shouldHideArrow: oe,
children: /* @__PURE__ */ l(
D.div,
{
"data-side": E,
"data-align": T,
...i,
ref: R,
style: {
...i.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: Q ? void 0 : "none"
}
}
)
}
)
}
);
}
);
wt.displayName = Le;
var Ct = "PopperArrow", tr = {
top: "bottom",
right: "left",
bottom: "top",
left: "right"
}, Mt = o.forwardRef(function(t, n) {
const { __scopePopper: r, ...a } = t, c = er(Ct, r), u = tr[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__ */ l(
"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__ */ l(
qn,
{
...a,
ref: n,
style: {
...a.style,
// ensures the element can be measured correctly (mostly for if SVG)
display: "block"
}
}
)
}
)
);
});
Mt.displayName = Ct;
function nr(e) {
return e !== null;
}
var rr = (e) => ({
name: "transformOrigin",
options: e,
fn(t) {
var w, h, M;
const { placement: n, rects: r, middlewareData: a } = t, u = ((w = a.arrow) == null ? void 0 : w.centerOffset) !== 0, s = u ? 0 : e.arrowWidth, m = u ? 0 : e.arrowHeight, [p, v] = Et(n), d = { start: "0%", center: "50%", end: "100%" }[v], g = (((h = a.arrow) == null ? void 0 : h.x) ?? 0) + s / 2, C = (((M = a.arrow) == null ? void 0 : M.y) ?? 0) + m / 2;
let f = "", i = "";
return p === "bottom" ? (f = u ? d : `${g}px`, i = `${-m}px`) : p === "top" ? (f = u ? d : `${g}px`, i = `${r.floating.height + m}px`) : p === "right" ? (f = `${-m}px`, i = u ? d : `${C}px`) : p === "left" && (f = `${r.floating.width + m}px`, i = u ? d : `${C}px`), { data: { x: f, y: i } };
}
});
function Et(e) {
const [t, n = "center"] = e.split("-");
return [t, n];
}
var or = vt, ar = gt, cr = wt, sr = Mt, Ie = "rovingFocusGroup.onEntryFocus", ir = { bubbles: !1, cancelable: !0 }, Ee = "RovingFocusGroup", [De, Rt, ur] = st(Ee), [lr, bt] = de(
Ee,
[ur]
), [dr, fr] = lr(Ee), St = o.forwardRef(
(e, t) => /* @__PURE__ */ l(De.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ l(De.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ l(pr, { ...e, ref: t }) }) })
);
St.displayName = Ee;
var pr = o.forwardRef((e, t) => {
const {
__scopeRovingFocusGroup: n,
orientation: r,
loop: a = !1,
dir: c,
currentTabStopId: u,
defaultCurrentTabStopId: s,
onCurrentTabStopIdChange: m,
onEntryFocus: p,
preventScrollOnEntryFocus: v = !1,
...d
} = e, g = o.useRef(null), C = K(t, g), f = it(c), [i = null, w] = ot({
prop: u,
defaultProp: s,
onChange: m
}), [h, M] = o.useState(!1), R = ne(p), b = Rt(n), y = o.useRef(!1), [P, I] = o.useState(0);
return o.useEffect(() => {
const _ = g.current;
if (_)
return _.addEventListener(Ie, R), () => _.removeEventListener(Ie, R);
}, [R]), /* @__PURE__ */ l(
dr,
{
scope: n,
orientation: r,
dir: f,
loop: a,
currentTabStopId: i,
onItemFocus: o.useCallback(
(_) => w(_),
[w]
),
onItemShiftTab: o.useCallback(() => M(!0), []),
onFocusableItemAdd: o.useCallback(
() => I((_) => _ + 1),
[]
),
onFocusableItemRemove: o.useCallback(
() => I((_) => _ - 1),
[]
),
children: /* @__PURE__ */ l(
D.div,
{
tabIndex: h || P === 0 ? -1 : 0,
"data-orientation": r,
...d,
ref: C,
style: { outline: "none", ...e.style },
onMouseDown: S(e.onMouseDown, () => {
y.current = !0;
}),
onFocus: S(e.onFocus, (_) => {
const k = !y.current;
if (_.target === _.currentTarget && k && !h) {
const $ = new CustomEvent(Ie, ir);
if (_.currentTarget.dispatchEvent($), !$.defaultPrevented) {
const Y = b().filter((L) => L.focusable), W = Y.find((L) => L.active), U = Y.find((L) => L.id === i), q = [W, U, ...Y].filter(
Boolean
).map((L) => L.ref.current);
Pt(q, v);
}
}
y.current = !1;
}),
onBlur: S(e.onBlur, () => M(!1))
}
)
}
);
}), yt = "RovingFocusGroupItem", _t = o.forwardRef(
(e, t) => {
const {
__scopeRovingFocusGroup: n,
focusable: r = !0,
active: a = !1,
tabStopId: c,
...u
} = e, s = Ne(), m = c || s, p = fr(yt, n), v = p.currentTabStopId === m, d = Rt(n), { onFocusableItemAdd: g, onFocusableItemRemove: C } = p;
return o.useEffect(() => {
if (r)
return g(), () => C();
}, [r, g, C]), /* @__PURE__ */ l(
De.ItemSlot,
{
scope: n,
id: m,
focusable: r,
active: a,
children: /* @__PURE__ */ l(
D.span,
{
tabIndex: v ? 0 : -1,
"data-orientation": p.orientation,
...u,
ref: t,
onMouseDown: S(e.onMouseDown, (f) => {
r ? p.onItemFocus(m) : f.preventDefault();
}),
onFocus: S(e.onFocus, () => p.onItemFocus(m)),
onKeyDown: S(e.onKeyDown, (f) => {
if (f.key === "Tab" && f.shiftKey) {
p.onItemShiftTab();
return;
}
if (f.target !== f.currentTarget)
return;
const i = hr(f, p.orientation, p.dir);
if (i !== void 0) {
if (f.metaKey || f.ctrlKey || f.altKey || f.shiftKey)
return;
f.preventDefault();
let h = d().filter((M) => M.focusable).map((M) => M.ref.current);
if (i === "last")
h.reverse();
else if (i === "prev" || i === "next") {
i === "prev" && h.reverse();
const M = h.indexOf(f.currentTarget);
h = p.loop ? gr(h, M + 1) : h.slice(M + 1);
}
setTimeout(() => Pt(h));
}
})
}
)
}
);
}
);
_t.displayName = yt;
var mr = {
ArrowLeft: "prev",
ArrowUp: "prev",
ArrowRight: "next",
ArrowDown: "next",
PageUp: "first",
Home: "first",
PageDown: "last",
End: "last"
};
function vr(e, t) {
return t !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
}
function hr(e, t, n) {
const r = vr(e.key, n);
if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(r)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(r)))
return mr[r];
}
function Pt(e, t = !1) {
const n = document.activeElement;
for (const r of e)
if (r === n || (r.focus({ preventScroll: t }), document.activeElement !== n))
return;
}
function gr(e, t) {
return e.map((n, r) => e[(t + r) % e.length]);
}
var wr = St, Cr = _t, It = xn(), Ae = function() {
}, Re = o.forwardRef(function(e, t) {
var n = o.useRef(null), r = o.useState({
onScrollCapture: Ae,
onWheelCapture: Ae,
onTouchMoveCapture: Ae
}), a = r[0], c = r[1], u = e.forwardProps, s = e.children, m = e.className, p = e.removeScrollBar, v = e.enabled, d = e.shards, g = e.sideCar, C = e.noIsolation, f = e.inert, i = e.allowPinchZoom, w = e.as, h = w === void 0 ? "div" : w, M = e.gapMode, R = Tn(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), b = g, y = Nn([n, t]), P = te(te({}, R), a);
return o.createElement(
o.Fragment,
null,
v && o.createElement(b, { sideCar: It, removeScrollBar: p, shards: d, noIsolation: C, inert: f, setCallbacks: c, allowPinchZoom: !!i, lockRef: n, gapMode: M }),
u ? o.cloneElement(o.Children.only(s), te(te({}, P), { ref: y })) : o.createElement(h, te({}, P, { className: m, ref: y }), s)
);
});
Re.defaultProps = {
enabled: !0,
removeScrollBar: !0,
inert: !1
};
Re.classNames = {
fullWidth: Dn,
zeroRight: On
};
var Oe = !1;
if (typeof window < "u")
try {
var he = Object.defineProperty({}, "passive", {
get: function() {
return Oe = !0, !0;
}
});
window.addEventListener("test", he, he), window.removeEventListener("test", he, he);
} catch {
Oe = !1;
}
var J = Oe ? { passive: !1 } : !1, Mr = function(e) {
return e.tagName === "TEXTAREA";
}, At = 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 && !Mr(e) && n[t] === "visible")
);
}, Er = function(e) {
return At(e, "overflowY");
}, Rr = function(e) {
return At(e, "overflowX");
}, et = function(e, t) {
var n = t.ownerDocument, r = t;
do {
typeof ShadowRoot < "u" && r instanceof ShadowRoot && (r = r.host);
var a = xt(e, r);
if (a) {
var c = Tt(e, r), u = c[1], s = c[2];
if (u > s)
return !0;
}
r = r.parentNode;
} while (r && r !== n.body);
return !1;
}, br = function(e) {
var t = e.scrollTop, n = e.scrollHeight, r = e.clientHeight;
return [
t,
n,
r
];
}, Sr = function(e) {
var t = e.scrollLeft, n = e.scrollWidth, r = e.clientWidth;
return [
t,
n,
r
];
}, xt = function(e, t) {
return e === "v" ? Er(t) : Rr(t);
}, Tt = function(e, t) {
return e === "v" ? br(t) : Sr(t);
}, yr = function(e, t) {
return e === "h" && t === "rtl" ? -1 : 1;
}, _r = function(e, t, n, r, a) {
var c = yr(e, window.getComputedStyle(t).direction), u = c * r, s = n.target, m = t.contains(s), p = !1, v = u > 0, d = 0, g = 0;
do {
var C = Tt(e, s), f = C[0], i = C[1], w = C[2], h = i - w - c * f;
(f || h) && xt(e, s) && (d += h, g += f), s instanceof ShadowRoot ? s = s.host : s = s.parentNode;
} while (
// portaled content
!m && s !== document.body || // self content
m && (t.contains(s) || t === s)
);
return (v && (a && Math.abs(d) < 1 || !a && u > d) || !v && (a && Math.abs(g) < 1 || !a && -u > g)) && (p = !0), p;
}, ge = function(e) {
return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0];
}, tt = function(e) {
return [e.deltaX, e.deltaY];
}, nt = function(e) {
return e && "current" in e ? e.current : e;
}, Pr = function(e, t) {
return e[0] === t[0] && e[1] === t[1];
}, Ir = function(e) {
return `
.block-interactivity-`.concat(e, ` {pointer-events: none;}
.allow-interactivity-`).concat(e, ` {pointer-events: all;}
`);
}, Ar = 0, ee = [];
function xr(e) {
var t = o.useRef([]), n = o.useRef([0, 0]), r = o.useRef(), a = o.useState(Ar++)[0], c = o.useState(Fn)[0], u = o.useRef(e);
o.useEffect(function() {
u.current = e;
}, [e]), o.useEffect(function() {
if (e.inert) {
document.body.classList.add("block-interactivity-".concat(a));
var i = kn([e.lockRef.current], (e.shards || []).map(nt), !0).filter(Boolean);
return i.forEach(function(w) {
return w.classList.add("allow-interactivity-".concat(a));
}), function() {
document.body.classList.remove("block-interactivity-".concat(a)), i.forEach(function(w) {
return w.classList.remove("allow-interactivity-".concat(a));
});
};
}
}, [e.inert, e.lockRef.current, e.shards]);
var s = o.useCallback(function(i, w) {
if ("touches" in i && i.touches.length === 2 || i.type === "wheel" && i.ctrlKey)
return !u.current.allowPinchZoom;
var h = ge(i), M = n.current, R = "deltaX" in i ? i.deltaX : M[0] - h[0], b = "deltaY" in i ? i.deltaY : M[1] - h[1], y, P = i.target, I = Math.abs(R) > Math.abs(b) ? "h" : "v";
if ("touches" in i && I === "h" && P.type === "range")
return !1;
var _ = et(I, P);
if (!_)
return !0;
if (_ ? y = I : (y = I === "v" ? "h" : "v", _ = et(I, P)), !_)
return !1;
if (!r.current && "changedTouches" in i && (R || b) && (r.current = y), !y)
return !0;
var k = r.current || y;
return _r(k, w, i, k === "h" ? R : b, !0);
}, []), m = o.useCallback(function(i) {
var w = i;
if (!(!ee.length || ee[ee.length - 1] !== c)) {
var h = "deltaY" in w ? tt(w) : ge(w), M = t.current.filter(function(y) {
return y.name === w.type && (y.target === w.target || w.target === y.shadowParent) && Pr(y.delta, h);
})[0];
if (M && M.should) {
w.cancelable && w.preventDefault();
return;
}
if (!M) {
var R = (u.current.shards || []).map(nt).filter(Boolean).filter(function(y) {
return y.contains(w.target);
}), b = R.length > 0 ? s(w, R[0]) : !u.current.noIsolation;
b && w.cancelable && w.preventDefault();
}
}
}, []), p = o.useCallback(function(i, w, h, M) {
var R = { name: i, delta: w, target: h, should: M, shadowParent: Tr(h) };
t.current.push(R), setTimeout(function() {
t.current = t.current.filter(function(b) {
return b !== R;
});
}, 1);
}, []), v = o.useCallback(function(i) {
n.current = ge(i), r.current = void 0;
}, []), d = o.useCallback(function(i) {
p(i.type, tt(i), i.target, s(i, e.lockRef.current));
}, []), g = o.useCallback(function(i) {
p(i.type, ge(i), i.target, s(i, e.lockRef.current));
}, []);
o.useEffect(function() {
return ee.push(c), e.setCallbacks({
onScrollCapture: d,
onWheelCapture: d,
onTouchMoveCapture: g
}), document.addEventListener("wheel", m, J), document.addEventListener("touchmove", m, J), document.addEventListener("touchstart", v, J), function() {
ee = ee.filter(function(i) {
return i !== c;
}), document.removeEventListener("wheel", m, J), document.removeEventListener("touchmove", m, J), document.removeEventListener("touchstart", v, J);
};
}, []);
var C = e.removeScrollBar, f = e.inert;
return o.createElement(
o.Fragment,
null,
f ? o.createElement(c, { styles: Ir(a) }) : null,
C ? o.createElement(Ln, { gapMode: e.gapMode }) : null
);
}
function Tr(e) {
for (var t = null; e !== null; )
e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode;
return t;
}
const Nr = Kn(It, xr);
var Nt = o.forwardRef(function(e, t) {
return o.createElement(Re, te({}, e, { ref: t, sideCar: Nr }));
});
Nt.classNames = Re.classNames;
const Dr = Nt;
var Fe = ["Enter", " "], Or = ["ArrowDown", "PageUp", "Home"], Dt = ["ArrowUp", "PageDown", "End"], Fr = [...Or, ...Dt], kr = {
ltr: [...Fe, "ArrowRight"],
rtl: [...Fe, "ArrowLeft"]
}, Lr = {
ltr: ["ArrowLeft"],
rtl: ["ArrowRight"]
}, fe = "Menu", [ue, Kr, Gr] = st(fe), [j, Ot] = de(fe, [
Gr,
pt,
bt
]), be = pt(), Ft = bt(), [$r, z] = j(fe), [Ur, pe] = j(fe), kt = (e) => {
const { __scopeMenu: t, open: n = !1, children: r, dir: a, onOpenChange: c, modal: u = !0 } = e, s = be(t), [m, p] = o.useState(null), v = o.useRef(!1), d = ne(c), g = it(a);
return o.useEffect(() => {
const C = () => {
v.current = !0, document.addEventListener("pointerdown", f, { capture: !0, once: !0 }), document.addEventListener("pointermove", f, { capture: !0, once: !0 });
}, f = () => v.current = !1;
return document.addEventListener("keydown", C, { capture: !0 }), () => {
document.removeEventListener("keydown", C, { capture: !0 }), document.removeEventListener("pointerdown", f, { capture: !0 }), document.removeEventListener("pointermove", f, { capture: !0 });
};
}, []), /* @__PURE__ */ l(or, { ...s, children: /* @__PURE__ */ l(
$r,
{
scope: t,
open: n,
onOpenChange: d,
content: m,
onContentChange: p,
children: /* @__PURE__ */ l(
Ur,
{
scope: t,
onClose: o.useCallback(() => d(!1), [d]),
isUsingKeyboardRef: v,
dir: g,
modal: u,
children: r
}
)
}
) });
};
kt.displayName = fe;
var Br = "MenuAnchor", Ke = o.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e, a = be(n);
return /* @__PURE__ */ l(ar, { ...a, ...r, ref: t });
}
);
Ke.displayName = Br;
var Ge = "MenuPortal", [Yr, Lt] = j(Ge, {
forceMount: void 0
}), Kt = (e) => {
const { __scopeMenu: t, forceMount: n, children: r, container: a } = e, c = z(Ge, t);
return /* @__PURE__ */ l(Yr, { scope: t, forceMount: n, children: /* @__PURE__ */ l(Me, { present: n || c.open, children: /* @__PURE__ */ l(ct, { asChild: !0, container: a, children: r }) }) });
};
Kt.displayName = Ge;
var F = "MenuContent", [Hr, $e] = j(F), Gt = o.forwardRef(
(e, t) => {
const n = Lt(F, e.__scopeMenu), { forceMount: r = n.forceMount, ...a } = e, c = z(F, e.__scopeMenu), u = pe(F, e.__scopeMenu);
return /* @__PURE__ */ l(ue.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ l(Me, { present: r || c.open, children: /* @__PURE__ */ l(ue.Slot, { scope: e.__scopeMenu, children: u.modal ? /* @__PURE__ */ l(Wr, { ...a, ref: t }) : /* @__PURE__ */ l(Xr, { ...a, ref: t }) }) }) });
}
), Wr = o.forwardRef(
(e, t) => {
const n = z(F, e.__scopeMenu), r = o.useRef(null), a = K(t, r);
return o.useEffect(() => {
const c = r.current;
if (c)
return Gn(c);
}, []), /* @__PURE__ */ l(
Ue,
{
...e,
ref: a,
trapFocus: n.open,
disableOutsidePointerEvents: n.open,
disableOutsideScroll: !0,
onFocusOutside: S(
e.onFocusOutside,
(c) => c.preventDefault(),
{ checkForDefaultPrevented: !1 }
),
onDismiss: () => n.onOpenChange(!1)
}
);
}
), Xr = o.forwardRef((e, t) => {
const n = z(F, e.__scopeMenu);
return /* @__PURE__ */ l(
Ue,
{
...e,
ref: t,
trapFocus: !1,
disableOutsidePointerEvents: !1,
disableOutsideScroll: !1,
onDismiss: () => n.onOpenChange(!1)
}
);
}), Ue = o.forwardRef(
(e, t) => {
const {
__scopeMenu: n,
loop: r = !1,
trapFocus: a,
onOpenAutoFocus: c,
onCloseAutoFocus: u,
disableOutsidePointerEvents: s,
onEntryFocus: m,
onEscapeKeyDown: p,
onPointerDownOutside: v,
onFocusOutside: d,
onInteractOutside: g,
onDismiss: C,
disableOutsideScroll: f,
...i
} = e, w = z(F, n), h = pe(F, n), M = be(n), R = Ft(n), b = Kr(n), [y, P] = o.useState(null), I = o.useRef(null), _ = K(t, I, w.onContentChange), k = o.useRef(0), $ = o.useRef(""), Y = o.useRef(0), W = o.useRef(null), U = o.useRef("right"), Z = o.useRef(0), q = f ? Dr : o.Fragment, L = f ? { as: Te, allowPinchZoom: !0 } : void 0, Q = (E) => {
var B, ae;
const T = $.current + E, A = b().filter((O) => !O.disabled), G = document.activeElement, re = (B = A.find((O) => O.ref.current === G)) == null ? void 0 : B.textValue, oe = A.map((O) => O.textValue), me = oo(oe, T, re), X = (ae = A.find((O) => O.textValue === me)) == null ? void 0 : ae.ref.current;
(function O(ce) {
$.current = ce, window.clearTimeout(k.current), ce !== "" && (k.current = window.setTimeout(() => O(""), 1e3));
})(T), X && setTimeout(() => X.focus());
};
o.useEffect(() => () => window.clearTimeout(k.current), []), Bn();
const N = o.useCallback((E) => {
var A, G;
return U.current === ((A = W.current) == null ? void 0 : A.side) && co(E, (G = W.current) == null ? void 0 : G.area);
}, []);
return /* @__PURE__ */ l(
Hr,
{
scope: n,
searchRef: $,
onItemEnter: o.useCallback(
(E) => {
N(E) && E.preventDefault();
},
[N]
),
onItemLeave: o.useCallback(
(E) => {
var T;
N(E) || ((T = I.current) == null || T.focus(), P(null));
},
[N]
),
onTriggerLeave: o.useCallback(
(E) => {
N(E) && E.preventDefault();
},
[N]
),
pointerGraceTimerRef: Y,
onPointerGraceIntentChange: o.useCallback((E) => {
W.current = E;
}, []),
children: /* @__PURE__ */ l(q, { ...L, children: /* @__PURE__ */ l(
ut,
{
asChild: !0,
trapped: a,
onMountAutoFocus: S(c, (E) => {
var T;
E.preventDefault(), (T = I.current) == null || T.focus({ preventScroll: !0 });
}),
onUnmountAutoFocus: u,
children: /* @__PURE__ */ l(
Cn,
{
asChild: !0,
disableOutsidePointerEvents: s,
onEscapeKeyDown: p,
onPointerDownOutside: v,
onFocusOutside: d,
onInteractOutside: g,
onDismiss: C,
children: /* @__PURE__ */ l(
wr,
{
asChild: !0,
...R,
dir: h.dir,
orientation: "vertical",
loop: r,
currentTabStopId: y,
onCurrentTabStopIdChange: P,
onEntryFocus: S(m, (E) => {
h.isUsingKeyboardRef.current || E.preventDefault();
}),
preventScrollOnEntryFocus: !0,
children: /* @__PURE__ */ l(
cr,
{
role: "menu",
"aria-orientation": "vertical",
"data-state": tn(w.open),
"data-radix-menu-content": "",
dir: h.dir,
...M,
...i,
ref: _,
style: { outline: "none", ...i.style },
onKeyDown: S(i.onKeyDown, (E) => {
const A = E.target.closest("[data-radix-menu-content]") === E.currentTarget, G = E.ctrlKey || E.altKey || E.metaKey, re = E.key.length === 1;
A && (E.key === "Tab" && E.preventDefault(), !G && re && Q(E.key));
const oe = I.current;
if (E.target !== oe || !Fr.includes(E.key))
return;
E.preventDefault();
const X = b().filter((B) => !B.disabled).map((B) => B.ref.current);
Dt.includes(E.key) && X.reverse(), no(X);
}),
onBlur: S(e.onBlur, (E) => {
E.currentTarget.contains(E.target) || (window.clearTimeout(k.current), $.current = "");
}),
onPointerMove: S(
e.onPointerMove,
le((E) => {
const T = E.target, A = Z.current !== E.clientX;
if (E.currentTarget.contains(T) && A) {
const G = E.clientX > Z.current ? "right" : "left";
U.current = G, Z.current = E.clientX;
}
})
)
}
)
}
)
}
)
}
) })
}
);
}
);
Gt.displayName = F;
var Vr = "MenuGroup", Be = o.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e;
return /* @__PURE__ */ l(D.div, { role: "group", ...r, ref: t });
}
);
Be.displayName = Vr;
var jr = "MenuLabel", $t = o.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e;
return /* @__PURE__ */ l(D.div, { ...r, ref: t });
}
);
$t.displayName = jr;
var we = "MenuItem", rt = "menu.itemSelect", Se = o.forwardRef(
(e, t) => {
const { disabled: n = !1, onSelect: r, ...a } = e, c = o.useRef(null), u = pe(we, e.__scopeMenu), s = $e(we, e.__scopeMenu), m = K(t, c), p = o.useRef(!1), v = () => {
const d = c.current;
if (!n && d) {
const g = new CustomEvent(rt, { bubbles: !0, cancelable: !0 });
d.addEventListener(rt, (C) => r == null ? void 0 : r(C), { once: !0 }), wn(d, g), g.defaultPrevented ? p.current = !1 : u.onClose();
}
};
return /* @__PURE__ */ l(
Ut,
{
...a,
ref: m,
disabled: n,
onClick: S(e.onClick, v),
onPointerDown: (d) => {
var g;
(g = e.onPointerDown) == null || g.call(e, d), p.current = !0;
},
onPointerUp: S(e.onPointerUp, (d) => {
var g;
p.current || (g = d.currentTarget) == null || g.click();
}),
onKeyDown: S(e.onKeyDown, (d) => {
const g = s.searchRef.current !== "";
n || g && d.key === " " || Fe.includes(d.key) && (d.currentTarget.click(), d.preventDefault());
})
}
);
}
);
Se.displayName = we;
var Ut = o.forwardRef(
(e, t) => {
const { __scopeMenu: n, disabled: r = !1, textValue: a, ...c } = e, u = $e(we, n), s = Ft(n), m = o.useRef(null), p = K(t, m), [v, d] = o.useState(!1), [g, C] = o.useState("");
return o.useEffect(() => {
const f = m.current;
f && C((f.textContent ?? "").trim());
}, [c.children]), /* @__PURE__ */ l(
ue.ItemSlot,
{
scope: n,
disabled: r,
textValue: a ?? g,
children: /* @__PURE__ */ l(Cr, { asChild: !0, ...s, focusable: !r, children: /* @__PURE__ */ l(
D.div,
{
role: "menuitem",
"data-highlighted": v ? "" : void 0,
"aria-disabled": r || void 0,
"data-disabled": r ? "" : void 0,
...c,
ref: p,
onPointerMove: S(
e.onPointerMove,
le((f) => {
r ? u.onItemLeave(f) : (u.onItemEnter(f), f.defaultPrevented || f.currentTarget.focus({ preventScroll: !0 }));
})
),
onPointerLeave: S(
e.onPointerLeave,
le((f) => u.onItemLeave(f))
),
onFocus: S(e.onFocus, () => d(!0)),
onBlur: S(e.onBlur, () => d(!1))
}
) })
}
);
}
), zr = "MenuCheckboxItem", Bt = o.forwardRef(
(e, t) => {
const { checked: n = !1, onCheckedChange: r, ...a } = e;
return /* @__PURE__ */ l(Vt, { scope: e.__scopeMenu, checked: n, children: /* @__PURE__ */ l(
Se,
{
role: "menuitemcheckbox",
"aria-checked": Ce(n) ? "mixed" : n,
...a,
ref: t,
"data-state": He(n),
onSelect: S(
a.onSelect,
() => r == null ? void 0 : r(Ce(n) ? !0 : !n),
{ checkForDefaultPrevented: !1 }
)
}
) });
}
);
Bt.displayName = zr;
var Yt = "MenuRadioGroup", [Zr, qr] = j(
Yt,
{ value: void 0, onValueChange: () => {
} }
), Ht = o.forwardRef(
(e, t) => {
const { value: n, onValueChange: r, ...a } = e, c = ne(r);
return /* @__PURE__ */ l(Zr, { scope: e.__scopeMenu, value: n, onValueChange: c, children: /* @__PURE__ */ l(Be, { ...a, ref: t }) });
}
);
Ht.displayName = Yt;
var Wt = "MenuRadioItem", Xt = o.forwardRef(
(e, t) => {
const { value: n, ...r } = e, a = qr(Wt, e.__scopeMenu), c = n === a.value;
return /* @__PURE__ */ l(Vt, { scope: e.__scopeMenu, checked: c, children: /* @__PURE__ */ l(
Se,
{
role: "menuitemradio",
"aria-checked": c,
...r,
ref: t,
"data-state": He(c),
onSelect: S(
r.onSelect,
() => {
var u;
return (u = a.onValueChange) == null ? void 0 : u.call(a, n);
},
{ checkForDefaultPrevented: !1 }
)
}
) });
}
);
Xt.displayName = Wt;
var Ye = "MenuItemIndicator", [Vt, Qr] = j(
Ye,
{ checked: !1 }
), jt = o.forwardRef(
(e, t) => {
const { __scopeMenu: n, forceMount: r, ...a } = e, c = Qr(Ye, n);
return /* @__PURE__ */ l(
Me,
{
present: r || Ce(c.checked) || c.checked === !0,
children: /* @__PURE__ */ l(
D.span,
{
...a,
ref: t,
"data-state": He(c.checked)
}
)
}
);
}
);
jt.displayName = Ye;
var Jr = "MenuSeparator", zt = o.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e;
return /* @__PURE__ */ l(
D.div,
{
role: "separator",
"aria-orientation": "horizontal",
...r,
ref: t
}
);
}
);
zt.displayName = Jr;
var eo = "MenuArrow", Zt = o.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...r } = e, a = be(n);
return /* @__PURE__ */ l(sr, { ...a, ...r, ref: t });
}
);
Zt.displayName = eo;
var to = "MenuSub", [Qo, qt] = j(to), ie = "MenuSubTrigger", Qt = o.forwardRef(
(e, t) => {
const n = z(ie, e.__scopeMenu), r = pe(ie, e.__scopeMenu), a = qt(ie, e.__scopeMenu), c = $e(ie, e.__scopeMenu), u = o.useRef(null), { pointerGraceTimerRef: s, onPointerGraceIntentChange: m } = c, p = { __scopeMenu: e.__scopeMenu }, v = o.useCallback(() => {
u.current && window.clearTimeout(u.current), u.current = null;
}, []);
return o.useEffect(() => v, [v]), o.useEffect(() => {
const d = s.current;
return () => {
window.clearTimeout(d), m(null);
};
}, [s, m]), /* @__PURE__ */ l(Ke, { asChild: !0, ...p, children: /* @__PURE__ */ l(
Ut,
{
id: a.triggerId,
"aria-haspopup": "menu",
"aria-expanded": n.open,
"aria-controls": a.contentId,
"data-state": tn(n.open),
...e,
ref: at(t, a.onTriggerChange),
onClick: (d) => {
var g;
(g = e.onClick) == null || g.call(e, d), !(e.disabled || d.defaultPrevented) && (d.currentTarget.focus(), n.open || n.onOpenChange(!0));
},
onPointerMove: S(
e.onPointerMove,
le((d) => {
c.onItemEnter(d), !d.defaultPrevented && !e.disabled && !n.open && !u.current && (c.onPointerGraceIntentChange(null), u.current = window.setTimeout(() => {
n.onOpenChange(!0), v();
}, 100));
})
),
onPointerLeave: S(
e.onPointerLeave,
le((d) => {
var C, f;
v();
const g = (C = n.content) == null ? void 0 : C.getBoundingClientRect();
if (g) {
const i = (f = n.content) == null ? void 0 : f.dataset.side, w = i === "right", h = w ? -5 : 5, M = g[w ? "left" : "right"], R = g[w ? "right" : "left"];
c.onPointerGraceIntentChange({
area: [
// Apply a bleed on clientX to ensure that our exit point is
// consistently within polygon bounds
{ x: d.clientX + h, y: d.clientY },
{ x: M, y: g.top },
{ x: R, y: g.top },
{ x: R, y: g.bottom },
{ x: M, y: g.bottom }
],
side: i
}), window.clearTimeout(s.current), s.current = window.setTimeout(
() => c.onPointerGraceIntentChange(null),
300
);
} else {
if (c.onTriggerLeave(d), d.defaultPrevented)
return;
c.onPointerGraceIntentChange(null);
}
})
),
onKeyDown: S(e.onKeyDown, (d) => {
var C;
const g = c.searchRef.current !== "";
e.disabled || g && d.key === " " || kr[r.dir].includes(d.key) && (n.onOpenChange(!0), (C = n.content) == null || C.focus(), d.preventDefault());
})
}
) });
}
);
Qt.displayName = ie;
var Jt = "MenuSubContent", en = o.forwardRef(
(e, t) => {
const n = Lt(F, e.__scopeMenu), { forceMount: r = n.forceMount, ...a } = e, c = z(F, e.__scopeMenu), u = pe(F, e.__scopeMenu), s = qt(Jt, e.__scopeMenu), m = o.useRef(null), p = K(t, m);
return /* @__PURE__ */ l(ue.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ l(Me, { present: r || c.open, children: /* @__PURE__ */ l(ue.Slot, { scope: e.__scopeMenu, children: /* @__PURE__ */ l(
Ue,
{
id: s.contentId,
"aria-labelledby": s.triggerId,
...a,
ref: p,
align: "start",
side: u.dir === "rtl" ? "left" : "right",
disableOutsidePointerEvents: !1,
disableOutsideScroll: !1,
trapFocus: !1,
onOpenAutoFocus: (v) => {
var d;
u.isUsingKeyboardRef.current && ((d = m.current) == null || d.focus()), v.preventDefault();
},
onCloseAutoFocus: (v) => v.preventDefault(),
onFocusOutside: S(e.onFocusOutside, (v) => {
v.target !== s.trigger && c.onOpenChange(!1);
}),
onEscapeKeyDown: S(e.onEscapeKeyDown, (v) => {
u.onClose(), v.preventDefault();
}),
onKeyDown: S(e.onKeyDown, (v) => {
var C;
const d = v.currentTarget.contains(v.target), g = Lr[u.dir].includes(v.key);
d && g && (c.onOpenChange(!1), (C = s.trigger) == null || C.focus(), v.preventDefault());
})
}
) }) }) });
}
);
en.displayName = Jt;
function tn(e) {
return e ? "open" : "closed";
}
function Ce(e) {
return e === "indeterminate";
}
function He(e) {
return Ce(e) ? "indeterminate" : e ? "checked" : "unchecked";
}
function no(e) {
const t = document.activeElement;
for (const n of e)
if (n === t || (n.focus(), document.activeElement !== t))
return;
}
function ro(e, t) {
return e.map((n, r) => e[(t + r) % e.length]);
}
function oo(e, t, n) {
const a = t.length > 1 && Array.from(t).every((p) => p === t[0]) ? t[0] : t, c = n ? e.indexOf(n) : -1;
let u = ro(e, Math.max(c, 0));
a.length === 1 && (u = u.filter((p) => p !== n));
const m = u.find(
(p) => p.toLowerCase().startsWith(a.toLowerCase())
);
return m !== n ? m : void 0;
}
function ao(e, t) {
const { x: n, y: r } = e;
let a = !1;
for (let c = 0, u = t.length - 1; c < t.length; u = c++) {
const s = t[c].x, m = t[c].y, p = t[u].x, v = t[u].y;
m > r != v > r && n < (p - s) * (r - m) / (v - m) + s && (a = !a);
}
return a;
}
function co(e, t) {
if (!t)
return !1;
const n = { x: e.clientX, y: e.clientY };
return ao(n, t);
}
function le(e) {
return (t) => t.pointerType === "mouse" ? e(t) : void 0;
}
var so = kt, io = Ke, uo = Kt, lo = Gt, fo = Be, po = $t, mo = Se, vo = Bt, ho = Ht, go = Xt, wo = jt, Co = zt, Mo = Zt, Eo = Qt, Ro = en, We = "DropdownMenu", [bo, Jo] = de(
We,
[Ot]
), x = Ot(), [So, nn] = bo(We), rn = (e) => {
const {
__scopeDropdownMenu: t,
children: n,
dir: r,
open: a,
defaultOpen: c,
onOpenChange: u,
modal: s = !0
} = e, m = x(t), p = o.useRef(null), [v = !1, d] = ot({
prop: a,
defaultProp: c,
onChange: u
});
return /* @__PURE__ */ l(
So,
{
scope: t,
triggerId: Ne(),
triggerRef: p,
contentId: Ne(),
open: v,
onOpenChange: d,
onOpenToggle: o.useCallback(() => d((g) => !g), [d]),
modal: s,
children: /* @__PURE__ */ l(so, { ...m, open: v, onOpenChange: d, dir: r, modal: s, children: n })
}
);
};
rn.displayName = We;
var on = "DropdownMenuTrigger", an = o.forwardRef(
(e, t) => {
const { __scopeDropdownMenu: n, disabled: r = !1, ...a } = e, c = nn(on, n), u = x(n);
return /* @__PURE__ */ l(io, { asChild: !0, ...u, children: /* @__PURE__ */ l(
D.button,
{
type: "button",
id: c.triggerId,
"aria-haspopup": "menu",
"aria-expanded": c.open,
"aria-controls": c.open ? c.contentId : void 0,
"data-state": c.open ? "open" : "closed",
"data-disabled": r ? "" : void 0,
disabled: r,
...a,
ref: at(t, c.triggerRef),
onPointerDown: S(e.onPointerDown, (s) => {
!r && s.button === 0 && s.ctrlKey === !1 && (c.onOpenToggle(), c.open || s.preventDefault());
}),
onKeyDown: S(e.onKeyDown, (s) => {
r || (["Enter", " "].includes(s.key) && c.onOpenToggl