"use client";
import { o as e, r as t, t as n, u as r } from "./useRenderElement-CmuWsiNa.js";
import { i, l as a, t as o } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as s } from "./useBaseUiId-DOm5ACje.js";
import { a as c, t as l } from "./useOpenChangeComplete-DjMFUwhi.js";
import { t as u } from "./useButton-AXffhTAZ.js";
import { n as d, r as f } from "./shadowDom-C-4Ejp9R.js";
import { C as p, P as m, V as h, a as g, c as _, d as v, f as y, j as b, l as x, m as S, o as C, p as w, r as T, s as E, t as D, u as O, v as k, w as A } from "./popupStateMapping-PdIQcWEz.js";
import { o as j } from "./composite-BlDfbDkL.js";
import { a as M, i as N, n as P, r as ee, s as te } from "./useOpenInteractionType-D-ymktmc.js";
import { n as ne, r as F, t as I } from "./store-Bdrhndby.js";
import { t as L } from "./inertValue-C36grUTu.js";
import * as R from "react";
import { jsx as z, jsxs as B } from "react/jsx-runtime";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/root/useDialogRoot.js
function V(e) {
	let { store: t, parentContext: n, actionsRef: r, isDrawer: i } = e, s = t.useState("open");
	y(t, s), x(t);
	let { forceUnmount: c } = O(s, t), l = R.useCallback(() => {
		t.setOpen(!1, o(a));
	}, [t]);
	return R.useImperativeHandle(r, () => ({
		unmount: c,
		close: l
	}), [c, l]), {
		parentContext: n,
		isDrawer: i
	};
}
function H({ store: n, dialogRoot: r }) {
	let { parentContext: i, isDrawer: a } = r, o = n.useState("open"), s = n.useState("disablePointerDismissal"), c = n.useState("modal"), l = n.useState("popupElement"), u = n.useState("floatingRootContext"), [p, m] = R.useState(0), [h, g] = R.useState(0), _ = p === 0, y = A(u, {
		outsidePressEvent() {
			return n.context.internalBackdropRef.current || n.context.backdropRef.current ? "intentional" : {
				mouse: c === "trap-focus" ? "sloppy" : "intentional",
				touch: "sloppy"
			};
		},
		outsidePress(e) {
			if (!n.context.outsidePressEnabledRef.current || "button" in e && e.button !== 0 || "touches" in e && e.touches.length !== 1) return !1;
			let t = f(e);
			if (_ && !s) {
				let e = t;
				return c && (n.context.internalBackdropRef.current || n.context.backdropRef.current) ? n.context.internalBackdropRef.current === e || n.context.backdropRef.current === e || d(e, l) && !e?.hasAttribute("data-base-ui-portal") : !0;
			}
			return !1;
		},
		escapeKey: _
	});
	return te(o && c === !0, l), n.useContextCallback("onNestedDialogOpen", (e, t) => {
		m(e), g(t);
	}), n.useContextCallback("onNestedDialogClose", () => {
		m(0), g(0);
	}), R.useEffect(() => (i?.onNestedDialogOpen && o && i.onNestedDialogOpen(p + 1, h + +!!a), i?.onNestedDialogClose && !o && i.onNestedDialogClose(), () => {
		i?.onNestedDialogClose && o && i.onNestedDialogClose();
	}), [
		a,
		o,
		p,
		h,
		i
	]), v(n, {
		activeTriggerProps: y.reference ?? e,
		inactiveTriggerProps: y.trigger ?? e,
		popupProps: R.useMemo(() => t(E, y.floating), [y.floating]),
		nestedOpenDialogCount: p,
		nestedOpenDrawerCount: h
	}), null;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/root/DialogRootContext.js
var U = /*#__PURE__*/ R.createContext(!1);
process.env.NODE_ENV !== "production" && (U.displayName = "IsDrawerContext");
var W = /*#__PURE__*/ R.createContext(void 0);
process.env.NODE_ENV !== "production" && (W.displayName = "DialogRootContext");
function G(e) {
	let t = R.useContext(W);
	if (e === !1 && t === void 0) throw Error(process.env.NODE_ENV === "production" ? r(27) : "Base UI: DialogRootContext is missing. Dialog parts must be placed within <Dialog.Root>.");
	return t;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/store/DialogStore.js
var re = {
	...F,
	modal: p((e) => e.modal),
	nested: p((e) => e.nested),
	nestedOpenDialogCount: p((e) => e.nestedOpenDialogCount),
	nestedOpenDrawerCount: p((e) => e.nestedOpenDrawerCount),
	disablePointerDismissal: p((e) => e.disablePointerDismissal),
	openMethod: p((e) => e.openMethod),
	descriptionElementId: p((e) => e.descriptionElementId),
	titleElementId: p((e) => e.titleElementId),
	viewportElement: p((e) => e.viewportElement),
	role: p((e) => e.role)
}, ie = class e extends k {
	constructor(e, t, n = !1) {
		let r = new C(), i = ae(e);
		i.floatingRootContext = ne(r, t, n), super(i, {
			popupRef: /*#__PURE__*/ R.createRef(),
			backdropRef: /*#__PURE__*/ R.createRef(),
			internalBackdropRef: /*#__PURE__*/ R.createRef(),
			outsidePressEnabledRef: { current: !0 },
			triggerElements: r,
			onOpenChange: void 0,
			onOpenChangeComplete: void 0
		}, re);
	}
	setOpen = (e, t) => {
		if (t.preventUnmountOnClose = () => {
			this.set("preventUnmountingOnClose", !0);
		}, !e && t.trigger == null && this.state.activeTriggerId != null && (t.trigger = this.state.activeTriggerElement ?? void 0), this.context.onOpenChange?.(e, t), t.isCanceled) return;
		this.state.floatingRootContext.dispatchOpenChange(e, t);
		let n = { open: e };
		_(n, e, t.trigger), this.update(n);
	};
	static useStore(t, n) {
		return w(t, (t, r) => new e(n, t, r), !0).store;
	}
};
function ae(e = {}) {
	return {
		...I(),
		modal: !0,
		disablePointerDismissal: !1,
		popupElement: null,
		viewportElement: null,
		descriptionElementId: void 0,
		titleElementId: void 0,
		openMethod: null,
		nested: !1,
		nestedOpenDialogCount: 0,
		nestedOpenDrawerCount: 0,
		role: "dialog",
		...e
	};
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/root/useRenderDialogRoot.js
function oe(e, t = "dialog") {
	let { children: n, open: r, defaultOpen: i = !1, onOpenChange: a, onOpenChangeComplete: o, disablePointerDismissal: s = !1, modal: c = !0, actionsRef: l, handle: u, triggerId: d, defaultTriggerId: f = null } = e, p = t === "drawer", m = t === "alert-dialog", g = m ? !0 : c, _ = m || s, v = m ? "alertdialog" : "dialog", y = G(!0), b = {
		modal: g,
		disablePointerDismissal: _,
		nested: !!y,
		role: v
	}, x = ie.useStore(u?.store, {
		open: i,
		openProp: r,
		activeTriggerId: f,
		triggerIdProp: d,
		...b
	});
	h(() => {
		let e = r === void 0 && x.state.open === !1 && i === !0 ? {
			open: !0,
			activeTriggerId: f
		} : null;
		m ? x.update(e ? {
			...b,
			...e
		} : b) : e && x.update(e);
	}), x.useControlledProp("openProp", r), x.useControlledProp("triggerIdProp", d), x.useSyncedValues(b), x.useContextCallback("onOpenChange", a), x.useContextCallback("onOpenChangeComplete", o);
	let S = x.useState("open"), C = x.useState("mounted"), w = x.useState("payload"), T = V({
		store: x,
		actionsRef: l,
		parentContext: y?.store.context,
		isDrawer: p
	}), E = S || C, D = R.useMemo(() => ({ store: x }), [x]);
	return /*#__PURE__*/ z(U.Provider, {
		value: !1,
		children: /*#__PURE__*/ B(W.Provider, {
			value: D,
			children: [E && /*#__PURE__*/ z(H, {
				store: x,
				dialogRoot: T
			}), typeof n == "function" ? n({ payload: w }) : n]
		})
	});
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/backdrop/DialogBackdrop.js
var se = {
	...T,
	...c
}, K = /*#__PURE__*/ R.forwardRef(function(e, t) {
	let { render: r, className: i, style: a, forceRender: o = !1, ...s } = e, { store: c } = G(), l = c.useState("open"), u = c.useState("nested"), d = c.useState("mounted");
	return n("div", e, {
		state: {
			open: l,
			transitionStatus: c.useState("transitionStatus")
		},
		ref: [c.context.backdropRef, t],
		stateAttributesMapping: se,
		props: [{
			role: "presentation",
			hidden: !d,
			style: {
				userSelect: "none",
				WebkitUserSelect: "none"
			}
		}, s],
		enabled: o || !u
	});
});
process.env.NODE_ENV !== "production" && (K.displayName = "DialogBackdrop");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/close/DialogClose.js
var q = /*#__PURE__*/ R.forwardRef(function(e, t) {
	let { render: r, className: a, style: s, disabled: c = !1, nativeButton: l = !0, ...d } = e, { store: f } = G(), p = f.useState("open"), { getButtonProps: m, buttonRef: h } = u({
		disabled: c,
		native: l
	}), g = { disabled: c };
	function _(e) {
		p && f.setOpen(!1, o(i, e.nativeEvent));
	}
	return n("button", e, {
		state: g,
		ref: [t, h],
		props: [
			{ onClick: _ },
			d,
			m
		]
	});
});
process.env.NODE_ENV !== "production" && (q.displayName = "DialogClose");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/description/DialogDescription.js
var J = /*#__PURE__*/ R.forwardRef(function(e, t) {
	let { render: r, className: i, style: a, id: o, ...c } = e, { store: l } = G(), u = s(o);
	return l.useSyncedValueWithCleanup("descriptionElementId", u), n("p", e, {
		ref: t,
		props: [{ id: u }, c]
	});
});
process.env.NODE_ENV !== "production" && (J.displayName = "DialogDescription");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/popup/DialogPopupCssVars.js
var ce = /*#__PURE__*/ function(e) {
	return e.nestedDialogs = "--nested-dialogs", e;
}({}), le = function(e) {
	return e[e.open = D.open] = "open", e[e.closed = D.closed] = "closed", e[e.startingStyle = D.startingStyle] = "startingStyle", e[e.endingStyle = D.endingStyle] = "endingStyle", e.nested = "data-nested", e.nestedDialogOpen = "data-nested-dialog-open", e;
}({}), Y = /*#__PURE__*/ R.createContext(void 0);
process.env.NODE_ENV !== "production" && (Y.displayName = "DialogPortalContext");
function ue() {
	let e = R.useContext(Y);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? r(26) : "Base UI: <Dialog.Portal> is missing.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/popup/DialogPopup.js
var de = {
	...T,
	...c,
	nestedDialogOpen(e) {
		return e ? { [le.nestedDialogOpen]: "" } : null;
	}
}, X = /*#__PURE__*/ R.forwardRef(function(e, t) {
	let { render: r, className: i, style: a, finalFocus: o, initialFocus: s, ...c } = e, { store: u } = G(), d = u.useState("descriptionElementId"), f = u.useState("disablePointerDismissal"), p = u.useState("floatingRootContext"), m = u.useState("popupProps"), h = u.useState("modal"), g = u.useState("mounted"), _ = u.useState("nested"), v = u.useState("nestedOpenDialogCount"), y = u.useState("open"), b = u.useState("openMethod"), x = u.useState("titleElementId"), S = u.useState("transitionStatus"), C = u.useState("role"), w = p.useState("floatingId"), T = c.id ?? w;
	ue(), l({
		open: y,
		ref: u.context.popupRef,
		onComplete() {
			y && u.context.onOpenChangeComplete?.(!0);
		}
	});
	function D(e) {
		return e === "touch" ? u.context.popupRef.current : !0;
	}
	let O = s === void 0 ? D : s, k = v > 0, A = u.useStateSetter("popupElement"), N = n("div", e, {
		state: {
			open: y,
			nested: _,
			transitionStatus: S,
			nestedDialogOpen: k
		},
		props: [
			m,
			{
				id: T,
				"aria-labelledby": x ?? void 0,
				"aria-describedby": d ?? void 0,
				role: C,
				...E,
				hidden: !g,
				onKeyDown(e) {
					j.has(e.key) && e.stopPropagation();
				},
				style: { [ce.nestedDialogs]: v }
			},
			c
		],
		ref: [
			t,
			u.context.popupRef,
			A
		],
		stateAttributesMapping: de
	});
	return /*#__PURE__*/ z(M, {
		context: p,
		openInteractionType: b,
		disabled: !g,
		closeOnFocusOut: !f,
		initialFocus: O,
		returnFocus: o,
		modal: h !== !1,
		restoreFocus: "popup",
		children: N
	});
});
process.env.NODE_ENV !== "production" && (X.displayName = "DialogPopup");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/portal/DialogPortal.js
var Z = /*#__PURE__*/ R.forwardRef(function(e, t) {
	let { keepMounted: n = !1, ...r } = e, { store: i } = G(), a = i.useState("mounted"), o = i.useState("modal"), s = i.useState("open");
	return a || n ? /*#__PURE__*/ z(Y.Provider, {
		value: n,
		children: /*#__PURE__*/ B(b, {
			ref: t,
			...r,
			children: [a && o === !0 && /*#__PURE__*/ z(ee, {
				ref: i.context.internalBackdropRef,
				inert: L(!s)
			}), e.children]
		})
	}) : null;
});
process.env.NODE_ENV !== "production" && (Z.displayName = "DialogPortal");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/title/DialogTitle.js
var Q = /*#__PURE__*/ R.forwardRef(function(e, t) {
	let { render: r, className: i, style: a, id: o, ...c } = e, { store: l } = G(), u = s(o);
	return l.useSyncedValueWithCleanup("titleElementId", u), n("h2", e, {
		ref: t,
		props: [{ id: u }, c]
	});
});
process.env.NODE_ENV !== "production" && (Q.displayName = "DialogTitle");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/dialog/trigger/DialogTrigger.js
var $ = /*#__PURE__*/ R.forwardRef(function(e, t) {
	let { render: i, className: a, style: o, disabled: c = !1, nativeButton: l = !0, id: d, payload: f, handle: p, ...h } = e, _ = G(!0), v = p?.store ?? _?.store;
	if (!v) throw Error(process.env.NODE_ENV === "production" ? r(79) : "Base UI: <Dialog.Trigger> must be used within <Dialog.Root> or provided with a handle.");
	let y = s(d), b = v.useState("floatingRootContext"), x = v.useState("isOpenedByTrigger", y), C = v.useState("triggerPopupId", y), w = R.useRef(null), { registerTrigger: T, isMountedByThisTrigger: E } = S(y, w, v, { payload: f }), { getButtonProps: D, buttonRef: O } = u({
		disabled: c,
		native: l
	}), k = N(b, { enabled: b != null }), A = P(() => v.select("open"), (e) => {
		v.set("openMethod", e);
	}), j = {
		disabled: c,
		open: x
	}, M = v.useState("triggerProps", E);
	return n("button", e, {
		state: j,
		ref: [
			O,
			t,
			T,
			w
		],
		props: [
			k.reference,
			M,
			A,
			{
				[m]: "",
				id: y,
				"aria-haspopup": "dialog",
				"aria-expanded": x,
				"aria-controls": C
			},
			h,
			D
		],
		stateAttributesMapping: g
	});
});
process.env.NODE_ENV !== "production" && ($.displayName = "DialogTrigger");
//#endregion
export { J as a, oe as c, X as i, U as l, Q as n, q as o, Z as r, K as s, $ as t };
