"use client";
import { getDefaultZIndex } from "../../core/utils/get-default-z-index/get-default-z-index.mjs";
import { getShadow, getSpacing } from "../../core/utils/get-size/get-size.mjs";
import { Box } from "../../core/Box/Box.mjs";
import { OptionalPortal } from "../Portal/OptionalPortal.mjs";
import { ModalBaseProvider } from "./ModalBase.context.mjs";
import { useModal } from "./use-modal.mjs";
import { RemoveScroll } from "react-remove-scroll";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/ModalBase/ModalBase.tsx
function ModalBase({ keepMounted, opened, onClose, id, transitionProps, onExitTransitionEnd, onEnterTransitionEnd, trapFocus, closeOnEscape, returnFocus, closeOnClickOutside, withinPortal, portalProps, lockScroll, children, zIndex, shadow, padding, __vars, unstyled, removeScrollProps, ...others }) {
	const { _id, titleMounted, bodyMounted, shouldLockScroll, setTitleMounted, setBodyMounted } = useModal({
		id,
		transitionProps,
		opened,
		trapFocus,
		closeOnEscape,
		onClose,
		returnFocus
	});
	const { key: removeScrollKey, ...otherRemoveScrollProps } = removeScrollProps || {};
	return /* @__PURE__ */ jsx(OptionalPortal, {
		...portalProps,
		withinPortal,
		children: /* @__PURE__ */ jsx(ModalBaseProvider, {
			value: {
				opened,
				onClose,
				closeOnClickOutside,
				onExitTransitionEnd,
				onEnterTransitionEnd,
				transitionProps: {
					...transitionProps,
					keepMounted
				},
				getTitleId: () => `${_id}-title`,
				getBodyId: () => `${_id}-body`,
				titleMounted,
				bodyMounted,
				setTitleMounted,
				setBodyMounted,
				trapFocus,
				closeOnEscape,
				zIndex,
				unstyled
			},
			children: /* @__PURE__ */ jsx(RemoveScroll, {
				enabled: shouldLockScroll && lockScroll,
				...otherRemoveScrollProps,
				children: /* @__PURE__ */ jsx(Box, {
					...others,
					id: _id,
					__vars: {
						...__vars,
						"--mb-z-index": (zIndex || getDefaultZIndex("modal")).toString(),
						"--mb-shadow": getShadow(shadow),
						"--mb-padding": getSpacing(padding)
					},
					children
				})
			}, removeScrollKey)
		})
	});
}
ModalBase.displayName = "@mantine/core/ModalBase";
//#endregion
export { ModalBase };

//# sourceMappingURL=ModalBase.mjs.map