"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
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@19.1.7_@types_react@19.1.9__@types_react@19.1.9_irkq3yh3qlkawac7zwq2rwd6bi/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.jsx(index.Value, { ref: ref, ...props, children: typeof children === 'function' ? children(item) : children }));
    }
    if (Array.isArray(item))
        return jsxRuntime.jsx(selectMultipleValue.SelectMultipleValue, { data: item, ref: ref, ...props });
    return (jsxRuntime.jsx(index.Value, { ref: ref, ...props, children: jsxRuntime.jsxs("div", { className: index$1.cx(select_module.default.valueContent), children: [typeof item?.children === 'string' && item?.leadingIcon && (jsxRuntime.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
