"use client";
import { createSplitProps } from "../../utils/create-split-props.js";
import { ark } from "../factory.js";
import { useMenuContext } from "./use-menu-context.js";
import { MenuItemProvider } from "./use-menu-item-context.js";
import { MenuItemPropsProvider } from "./use-menu-option-item-props-context.js";
import { forwardRef, useEffect } from "react";
import { mergeProps } from "@zag-js/react";
import { jsx } from "react/jsx-runtime";
//#region src/components/menu/menu-item.tsx
var splitItemBaseProps = createSplitProps();
var MenuItem = forwardRef((props, ref) => {
	const [itemProps, localProps] = splitItemBaseProps(props, [
		"closeOnSelect",
		"disabled",
		"value",
		"valueText",
		"onSelect"
	]);
	const menu = useMenuContext();
	const mergedProps = mergeProps(menu.getItemProps(itemProps), localProps);
	const itemState = menu.getItemState(itemProps);
	useEffect(() => {
		return menu.addItemListener({
			id: itemState.id,
			onSelect: itemProps.onSelect
		});
	}, [itemState.id, itemProps.onSelect]);
	return /* @__PURE__ */ jsx(MenuItemPropsProvider, {
		value: itemProps,
		children: /* @__PURE__ */ jsx(MenuItemProvider, {
			value: itemState,
			children: /* @__PURE__ */ jsx(ark.div, {
				...mergedProps,
				ref
			})
		})
	});
});
MenuItem.displayName = "MenuItem";
//#endregion
export { MenuItem };
