"use client";
import { getSingleElementChild } from "../../../core/utils/get-single-element-child/get-single-element-child.mjs";
import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs";
import { usePopoverContext } from "../../Popover/Popover.context.mjs";
import { createContextMenuHandlers } from "../../../utils/Floating/create-context-menu-handlers.mjs";
import { useMenuContext } from "../Menu.context.mjs";
import { cloneElement } from "react";
//#region packages/@mantine/core/src/components/Menu/MenuContextMenu/MenuContextMenu.tsx
function MenuContextMenu(props) {
	const { children, disabled } = useProps("MenuContextMenu", null, props);
	const child = getSingleElementChild(children);
	if (!child) throw new Error("Menu.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");
	const ctx = useMenuContext();
	const popoverCtx = usePopoverContext();
	return cloneElement(child, createContextMenuHandlers({
		childProps: child.props,
		disabled: disabled || popoverCtx.disabled,
		opened: ctx.opened,
		setReference: popoverCtx.reference,
		open: () => ctx.openDropdown()
	}));
}
MenuContextMenu.displayName = "@mantine/core/MenuContextMenu";
//#endregion
export { MenuContextMenu };

//# sourceMappingURL=MenuContextMenu.mjs.map