'use strict';

var jsxRuntime = require('../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.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 selectMultipleValue = require('./select-multiple-value.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@18.0.11_@types_react@18.2.12_react-dom@18.3.1_react@18.2.0__react@18.2.0/node_modules/@radix-ui/react-select/dist/index.cjs');

const SelectValue = React.forwardRef(({ children, ...props }, ref) => {
    const { value, items, multiple } = selectRoot.useSelectContext();
    const item = React.useMemo(() => {
        if (!value)
            return undefined;
        if (multiple && Array.isArray(value)) {
            const itemValues = value.map(v => items[v]);
            if (itemValues.length === 1)
                return itemValues[0];
            return itemValues;
        }
        return items[value];
    }, [value, items, multiple]);
    if (children) {
        return (jsxRuntime.jsxRuntimeExports.jsx(index.Value, { ref: ref, ...props, children: typeof children === 'function' ? children(item) : children }));
    }
    if (Array.isArray(item))
        return jsxRuntime.jsxRuntimeExports.jsx(selectMultipleValue.SelectMultipleValue, { data: item, ref: ref, ...props });
    return (jsxRuntime.jsxRuntimeExports.jsx(index.Value, { ref: ref, ...props, children: jsxRuntime.jsxRuntimeExports.jsxs("div", { className: index$1.cx(select_module.default.valueContent), children: [typeof item?.children === 'string' && item?.leadingIcon && (jsxRuntime.jsxRuntimeExports.jsx("div", { className: select_module.default.itemIcon, children: item.leadingIcon })), item?.children ?? value] }) }));
});
SelectValue.displayName = index.Value.displayName;

exports.SelectValue = SelectValue;
//# sourceMappingURL=select-value.cjs.map
