import { j as jsxRuntimeExports } from '../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js';
import { useMenuContext } from '../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@18.3.1_react@18.2.0__react@18.2.0/node_modules/@ariakit/react-core/esm/__chunks/VIIRIBF3.js';
import { MenuItem } from '../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@18.3.1_react@18.2.0__react@18.2.0/node_modules/@ariakit/react-core/esm/__chunks/2NBKRL7C.js';
import { ComboboxItem } from '../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@18.3.1_react@18.2.0__react@18.2.0/node_modules/@ariakit/react-core/esm/__chunks/JMHAJKUZ.js';
import { forwardRef } from 'react';
import { Cell } from './cell.js';
import { useDropdownContext } from './dropdown-menu-root.js';
import { getMatch } from './utils.js';
import { Root as Slot } from '../../node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@18.2.12_react@18.2.0/node_modules/@radix-ui/react-slot/dist/index.js';

const DropdownMenuItem = forwardRef(({ children, asChild, forceRender, value, ...props }, ref) => {
    const { autocomplete, searchValue, shouldFilter } = useDropdownContext();
    const menu = useMenuContext();
    const defaultProps = {
        ref,
        focusOnHover: true,
        blurOnHoverEnd: false,
        render: asChild ? jsxRuntimeExports.jsx(Slot, {}) : jsxRuntimeExports.jsx(Cell, {}),
        ...props
    };
    // In auto mode, hide items that don't match the search value
    if (!forceRender && shouldFilter && !getMatch(value, children, searchValue)) {
        return null;
    }
    if (forceRender === 'combobox' || autocomplete) {
        const comboboxProps = defaultProps;
        return (jsxRuntimeExports.jsx(ComboboxItem, { ...comboboxProps, value: value, setValueOnClick: false, selectValueOnClick: false, hideOnClick: event => {
                // Make sure that clicking on a combobox item that opens a nested
                // menu/dialog does not close the menu.
                const expandable = event.currentTarget.hasAttribute('aria-expanded');
                if (expandable)
                    return false;
                // By default, clicking on a ComboboxItem only closes its own popover.
                // However, since we're in a menu context, we also close all parent
                // menus.
                menu?.hideAll();
                return true;
            }, children: children }));
    }
    return jsxRuntimeExports.jsx(MenuItem, { ...defaultProps, children: children });
});

export { DropdownMenuItem };
//# sourceMappingURL=dropdown-menu-item.js.map
