"use client";
import { getDefaultZIndex } from "../../core/utils/get-default-z-index/get-default-z-index.mjs";
import { createContext, useState } from "react";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Drawer/DrawerStack.tsx
const DrawerStackContext = createContext(null);
function DrawerStack({ children }) {
	const [stack, setStack] = useState([]);
	const [maxZIndex, setMaxZIndex] = useState(getDefaultZIndex("modal"));
	return /* @__PURE__ */ jsx(DrawerStackContext, {
		value: {
			stack,
			addModal: (id, zIndex) => {
				setStack((current) => [...new Set([...current, id])]);
				setMaxZIndex((current) => typeof zIndex === "number" && typeof current === "number" ? Math.max(current, zIndex) : current);
			},
			removeModal: (id) => setStack((current) => current.filter((currentId) => currentId !== id)),
			getZIndex: (id) => `calc(${maxZIndex} + ${stack.indexOf(id)} + 1)`,
			currentId: stack[stack.length - 1],
			maxZIndex
		},
		children
	});
}
DrawerStack.displayName = "@mantine/core/DrawerStack";
//#endregion
export { DrawerStack, DrawerStackContext };

//# sourceMappingURL=DrawerStack.mjs.map