import { n as e } from "./dist-CTlQcJNK.js";
import { n as t, o as n, t as r } from "./dist-koa_pEtu.js";
import { t as i } from "./dist-RmXz0NYF.js";
import * as a from "react";
import { jsx as o } from "react/jsx-runtime";
//#region node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs
function s(e, t = globalThis?.document) {
	let n = i(e);
	a.useEffect(() => {
		let e = (e) => {
			e.key === "Escape" && n(e);
		};
		return t.addEventListener("keydown", e, { capture: !0 }), () => t.removeEventListener("keydown", e, { capture: !0 });
	}, [n, t]);
}
//#endregion
//#region node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
var c = "DismissableLayer", l = "dismissableLayer.update", u = "dismissableLayer.pointerDownOutside", d = "dismissableLayer.focusOutside", f, p = a.createContext({
	layers: /* @__PURE__ */ new Set(),
	layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
	branches: /* @__PURE__ */ new Set()
}), m = a.forwardRef((t, i) => {
	let { disableOutsidePointerEvents: c = !1, onEscapeKeyDown: u, onPointerDownOutside: d, onFocusOutside: m, onInteractOutside: h, onDismiss: g, ...b } = t, x = a.useContext(p), [S, C] = a.useState(null), w = S?.ownerDocument ?? globalThis?.document, [, T] = a.useState({}), E = e(i, (e) => C(e)), D = Array.from(x.layers), [O] = [...x.layersWithOutsidePointerEventsDisabled].slice(-1), k = D.indexOf(O), A = S ? D.indexOf(S) : -1, j = x.layersWithOutsidePointerEventsDisabled.size > 0, M = A >= k, N = _((e) => {
		let t = e.target, n = [...x.branches].some((e) => e.contains(t));
		!M || n || (d?.(e), h?.(e), e.defaultPrevented || g?.());
	}, w), P = v((e) => {
		let t = e.target;
		[...x.branches].some((e) => e.contains(t)) || (m?.(e), h?.(e), e.defaultPrevented || g?.());
	}, w);
	return s((e) => {
		A === x.layers.size - 1 && (u?.(e), !e.defaultPrevented && g && (e.preventDefault(), g()));
	}, w), a.useEffect(() => {
		if (S) return c && (x.layersWithOutsidePointerEventsDisabled.size === 0 && (f = w.body.style.pointerEvents, w.body.style.pointerEvents = "none"), x.layersWithOutsidePointerEventsDisabled.add(S)), x.layers.add(S), y(), () => {
			c && x.layersWithOutsidePointerEventsDisabled.size === 1 && (w.body.style.pointerEvents = f);
		};
	}, [
		S,
		w,
		c,
		x
	]), a.useEffect(() => () => {
		S && (x.layers.delete(S), x.layersWithOutsidePointerEventsDisabled.delete(S), y());
	}, [S, x]), a.useEffect(() => {
		let e = () => T({});
		return document.addEventListener(l, e), () => document.removeEventListener(l, e);
	}, []), /* @__PURE__ */ o(r.div, {
		...b,
		ref: E,
		style: {
			pointerEvents: j ? M ? "auto" : "none" : void 0,
			...t.style
		},
		onFocusCapture: n(t.onFocusCapture, P.onFocusCapture),
		onBlurCapture: n(t.onBlurCapture, P.onBlurCapture),
		onPointerDownCapture: n(t.onPointerDownCapture, N.onPointerDownCapture)
	});
});
m.displayName = c;
var h = "DismissableLayerBranch", g = a.forwardRef((t, n) => {
	let i = a.useContext(p), s = a.useRef(null), c = e(n, s);
	return a.useEffect(() => {
		let e = s.current;
		if (e) return i.branches.add(e), () => {
			i.branches.delete(e);
		};
	}, [i.branches]), /* @__PURE__ */ o(r.div, {
		...t,
		ref: c
	});
});
g.displayName = h;
function _(e, t = globalThis?.document) {
	let n = i(e), r = a.useRef(!1), o = a.useRef(() => {});
	return a.useEffect(() => {
		let e = (e) => {
			if (e.target && !r.current) {
				let r = function() {
					b(u, n, i, { discrete: !0 });
				}, i = { originalEvent: e };
				e.pointerType === "touch" ? (t.removeEventListener("click", o.current), o.current = r, t.addEventListener("click", o.current, { once: !0 })) : r();
			} else t.removeEventListener("click", o.current);
			r.current = !1;
		}, i = window.setTimeout(() => {
			t.addEventListener("pointerdown", e);
		}, 0);
		return () => {
			window.clearTimeout(i), t.removeEventListener("pointerdown", e), t.removeEventListener("click", o.current);
		};
	}, [t, n]), { onPointerDownCapture: () => r.current = !0 };
}
function v(e, t = globalThis?.document) {
	let n = i(e), r = a.useRef(!1);
	return a.useEffect(() => {
		let e = (e) => {
			e.target && !r.current && b(d, n, { originalEvent: e }, { discrete: !1 });
		};
		return t.addEventListener("focusin", e), () => t.removeEventListener("focusin", e);
	}, [t, n]), {
		onFocusCapture: () => r.current = !0,
		onBlurCapture: () => r.current = !1
	};
}
function y() {
	let e = new CustomEvent(l);
	document.dispatchEvent(e);
}
function b(e, n, r, { discrete: i }) {
	let a = r.originalEvent.target, o = new CustomEvent(e, {
		bubbles: !1,
		cancelable: !0,
		detail: r
	});
	n && a.addEventListener(e, n, { once: !0 }), i ? t(a, o) : a.dispatchEvent(o);
}
//#endregion
export { m as t };

//# sourceMappingURL=dist-BBVMDH9A.js.map