import { useId as e } from "react";
import { getOrCreatePortalRoot as t, useEscapeDismiss as n, useOverlayFocus as r } from "@ryuzaki13/react-foundation-lib/dom";
import { jsx as i, jsxs as a } from "react/jsx-runtime";
import { createPortal as o } from "react-dom";
//#region src/dialog/Dialog.tsx
function s({ title: s, description: c, open: l, onClose: u, minWidth: d, children: f }) {
	let p = e(), m = e(), h = r({
		active: l,
		trapFocus: !0,
		restoreFocus: !0,
		initialFocus: "auto"
	});
	if (n({
		active: l,
		onDismiss: u,
		containerRef: h
	}), !l || typeof document > "u") return null;
	let g = t("dialog-root");
	return g ? o(/* @__PURE__ */ i("div", {
		className: "fixed inset0 flexCenter surfaceBackdrop",
		style: { zIndex: "var(--z-dialog)" },
		onMouseDown: (e) => e.target === e.currentTarget && u(),
		children: /* @__PURE__ */ a("div", {
			ref: h,
			role: "dialog",
			"aria-modal": "true",
			"aria-labelledby": s ? p : void 0,
			"aria-describedby": c ? m : void 0,
			tabIndex: -1,
			className: "surface0 shadowMd paddingLg radiusSm",
			style: { minWidth: d },
			children: [
				s && /* @__PURE__ */ i("h2", {
					id: p,
					className: "margin0",
					children: s
				}),
				c && /* @__PURE__ */ i("p", {
					id: m,
					children: c
				}),
				f
			]
		})
	}), g) : null;
}
//#endregion
export { s as Dialog };

//# sourceMappingURL=index.js.map