"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.context.mjs";
import { createContextMenuHandlers } from "../../../utils/Floating/create-context-menu-handlers.mjs";
import { cloneElement } from "react";
//#region packages/@mantine/core/src/components/Popover/PopoverContextMenu/PopoverContextMenu.tsx
function PopoverContextMenu(props) {
	const { children, disabled } = useProps("PopoverContextMenu", null, props);
	const child = getSingleElementChild(children);
	if (!child) throw new Error("Popover.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 = usePopoverContext();
	return cloneElement(child, createContextMenuHandlers({
		childProps: child.props,
		disabled: disabled || ctx.disabled,
		opened: ctx.opened,
		setReference: ctx.reference,
		open: () => {
			if (!ctx.opened) ctx.onToggle();
		}
	}));
}
PopoverContextMenu.displayName = "@mantine/core/PopoverContextMenu";
//#endregion
export { PopoverContextMenu };

//# sourceMappingURL=PopoverContextMenu.mjs.map