'use strict';

var jsxRuntime = require('../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.cjs');
var VIIRIBF3 = require('../../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.cjs');
var _2NBKRL7C = require('../../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.cjs');
var JMHAJKUZ = require('../../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.cjs');
var React = require('react');
var cell = require('./cell.cjs');
var dropdownMenuRoot = require('./dropdown-menu-root.cjs');
var utils = require('./utils.cjs');
var index = require('../../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.cjs');

const DropdownMenuItem = React.forwardRef(({ children, asChild, forceRender, value, ...props }, ref) => {
    const { autocomplete, searchValue, shouldFilter } = dropdownMenuRoot.useDropdownContext();
    const menu = VIIRIBF3.useMenuContext();
    const defaultProps = {
        ref,
        focusOnHover: true,
        blurOnHoverEnd: false,
        render: asChild ? jsxRuntime.jsxRuntimeExports.jsx(index.Root, {}) : jsxRuntime.jsxRuntimeExports.jsx(cell.Cell, {}),
        ...props
    };
    // In auto mode, hide items that don't match the search value
    if (!forceRender && shouldFilter && !utils.getMatch(value, children, searchValue)) {
        return null;
    }
    if (forceRender === 'combobox' || autocomplete) {
        const comboboxProps = defaultProps;
        return (jsxRuntime.jsxRuntimeExports.jsx(JMHAJKUZ.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 jsxRuntime.jsxRuntimeExports.jsx(_2NBKRL7C.MenuItem, { ...defaultProps, children: children });
});

exports.DropdownMenuItem = DropdownMenuItem;
//# sourceMappingURL=dropdown-menu-item.cjs.map
