"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var JMHAJKUZ = require('../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/@ariakit/react-core/esm/__chunks/JMHAJKUZ.cjs');
var index$1 = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var checkbox = require('../checkbox/checkbox.cjs');
var utils = require('../dropdown-menu/utils.cjs');
var text = require('../text/text.cjs');
var selectRoot = require('./select-root.cjs');
var select_module = require('./select.module.css.cjs');
var index = require('../../node_modules/.pnpm/@radix-ui_react-select@2.2.5_@types_react-dom@19.1.7_@types_react@19.1.9__@types_react@19.1.9_irkq3yh3qlkawac7zwq2rwd6bi/node_modules/@radix-ui/react-select/dist/index.cjs');

const SelectItem = React.forwardRef(({ className, children, value: providedValue, leadingIcon, disabled, ...props }, ref) => {
    const value = String(providedValue);
    const { registerItem, unregisterItem, autocomplete, searchValue, value: selectValue, shouldFilter, multiple } = selectRoot.useSelectContext();
    const isSelected = multiple
        ? selectValue?.includes(value)
        : value === selectValue;
    const isMatched = utils.getMatch(value, children, searchValue);
    const isHidden = shouldFilter && isSelected && !isMatched;
    const element = typeof children === 'string' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [leadingIcon && jsxRuntime.jsx("div", { className: select_module.default.itemIcon, children: leadingIcon }), jsxRuntime.jsx(text.Text, { children: children })] })) : (children);
    React.useLayoutEffect(() => {
        registerItem({ leadingIcon, children, value });
        return () => {
            unregisterItem(value);
        };
    }, [value, children, registerItem, unregisterItem, leadingIcon]);
    if (shouldFilter && !isMatched && !isSelected) {
        // Not selected and doesn't match search, so don't render at all
        return null;
    }
    return (jsxRuntime.jsx(index.Item, { ref: ref, value: value, className: index$1.cx(select_module.default.menuitem, className, isHidden && select_module.default.hidden), "data-hidden": isHidden, disabled: disabled || isHidden, asChild: autocomplete, "aria-selected": isSelected, "data-checked": isSelected, ...props, children: autocomplete ? (jsxRuntime.jsxs(JMHAJKUZ.ComboboxItem, { clickOnEnter: false, clickOnSpace: false, onBlurCapture: event => {
                event.preventDefault();
            }, children: [multiple && jsxRuntime.jsx(checkbox.Checkbox, { checked: isSelected }), element] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [multiple && jsxRuntime.jsx(checkbox.Checkbox, { checked: isSelected }), element] })) }));
});
SelectItem.displayName = index.Item.displayName;

exports.SelectItem = SelectItem;
//# sourceMappingURL=select-item.cjs.map
