"use client";
const require_get_default_z_index = require("../../core/utils/get-default-z-index/get-default-z-index.cjs");
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
const require_factory = require("../../core/factory/factory.cjs");
const require_Drawer_module = require("./Drawer.module.cjs");
const require_DrawerBody = require("./DrawerBody.cjs");
const require_DrawerCloseButton = require("./DrawerCloseButton.cjs");
const require_DrawerContent = require("./DrawerContent.cjs");
const require_DrawerHeader = require("./DrawerHeader.cjs");
const require_DrawerOverlay = require("./DrawerOverlay.cjs");
const require_DrawerRoot = require("./DrawerRoot.cjs");
const require_DrawerStack = require("./DrawerStack.cjs");
const require_DrawerTitle = require("./DrawerTitle.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/Drawer/Drawer.tsx
const defaultProps = {
	closeOnClickOutside: true,
	withinPortal: true,
	lockScroll: true,
	trapFocus: true,
	returnFocus: true,
	closeOnEscape: true,
	keepMounted: false,
	zIndex: require_get_default_z_index.getDefaultZIndex("modal"),
	withOverlay: true,
	withCloseButton: true
};
const Drawer = require_factory.factory((_props) => {
	const { title, withOverlay, overlayProps, withCloseButton, closeButtonProps, children, opened, stackId, zIndex, ...others } = require_use_props.useProps("Drawer", defaultProps, _props);
	const ctx = (0, react.use)(require_DrawerStack.DrawerStackContext);
	const hasHeader = !!title || withCloseButton;
	const stackProps = ctx && stackId ? {
		closeOnEscape: ctx.currentId === stackId,
		trapFocus: ctx.currentId === stackId,
		zIndex: ctx.getZIndex(stackId)
	} : {};
	const overlayVisible = withOverlay === false ? false : stackId && ctx ? ctx.currentId === stackId : opened;
	(0, react.useEffect)(() => {
		if (ctx && stackId) opened ? ctx.addModal(stackId, zIndex || require_get_default_z_index.getDefaultZIndex("modal")) : ctx.removeModal(stackId);
	}, [
		opened,
		stackId,
		zIndex
	]);
	return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_DrawerRoot.DrawerRoot, {
		opened,
		zIndex: ctx && stackId ? ctx.getZIndex(stackId) : zIndex,
		...others,
		...stackProps,
		children: [withOverlay && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DrawerOverlay.DrawerOverlay, {
			visible: overlayVisible,
			transitionProps: ctx && stackId ? { duration: 0 } : void 0,
			...overlayProps
		}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_DrawerContent.DrawerContent, {
			__hidden: ctx && stackId && opened ? stackId !== ctx.currentId : false,
			children: [hasHeader && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_DrawerHeader.DrawerHeader, { children: [title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DrawerTitle.DrawerTitle, { children: title }), withCloseButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DrawerCloseButton.DrawerCloseButton, { ...closeButtonProps })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DrawerBody.DrawerBody, { children })]
		})]
	});
});
Drawer.classes = require_Drawer_module.default;
Drawer.displayName = "@mantine/core/Drawer";
Drawer.Root = require_DrawerRoot.DrawerRoot;
Drawer.Overlay = require_DrawerOverlay.DrawerOverlay;
Drawer.Content = require_DrawerContent.DrawerContent;
Drawer.Body = require_DrawerBody.DrawerBody;
Drawer.Header = require_DrawerHeader.DrawerHeader;
Drawer.Title = require_DrawerTitle.DrawerTitle;
Drawer.CloseButton = require_DrawerCloseButton.DrawerCloseButton;
Drawer.Stack = require_DrawerStack.DrawerStack;
//#endregion
exports.Drawer = Drawer;

//# sourceMappingURL=Drawer.cjs.map