"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "getButtonLabel", {
    enumerable: true,
    get: function() {
        return getButtonLabel;
    }
});
const _utils = require("../../../utils");
const getLabel = ({ value, valueToItemMap, renderValue })=>{
    const label = valueToItemMap.get(value)?.label || value.toString();
    return renderValue ? renderValue(valueToItemMap.get(value) || {
        value,
        label
    }) : label;
};
const getButtonLabel = ({ value, valueToItemMap, label, renderValue, multiselect, isTargetAmount })=>{
    if ((0, _utils.isEmpty)(value) && typeof value !== 'number') {
        return label || '';
    }
    if (multiselect && Array.isArray(value) && isTargetAmount) {
        return `Выбрано ${value.length}`;
    }
    if (multiselect && Array.isArray(value)) {
        return value?.map((itemValue)=>getLabel({
                value: itemValue,
                valueToItemMap,
                renderValue
            })).join(', ');
    }
    return getLabel({
        value,
        valueToItemMap,
        renderValue
    });
};
