"use client";
import { jsx, jsxs } from 'react/jsx-runtime';
import { cx } from '../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js';
import { forwardRef, useMemo } from 'react';
import { SelectMultipleValue } from './select-multiple-value.js';
import { useSelectContext } from './select-root.js';
import styles from './select.module.css.js';
import { Value } from '../../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.js';

const SelectValue = forwardRef(({ children, ...props }, ref) => {
    const { value, items, multiple } = useSelectContext();
    const item = 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 (jsx(Value, { ref: ref, ...props, children: typeof children === 'function' ? children(item) : children }));
    }
    if (Array.isArray(item))
        return jsx(SelectMultipleValue, { data: item, ref: ref, ...props });
    return (jsx(Value, { ref: ref, ...props, children: jsxs("div", { className: cx(styles.valueContent), children: [typeof item?.children === 'string' && item?.leadingIcon && (jsx("div", { className: styles.itemIcon, children: item.leadingIcon })), item?.children ?? value] }) }));
});
SelectValue.displayName = Value.displayName;

export { SelectValue };
//# sourceMappingURL=select-value.js.map
