import { isEmpty } from "../../../utils";
var getLabel = function getLabel(param) {
    var value = param.value, valueToItemMap = param.valueToItemMap, renderValue = param.renderValue;
    var _valueToItemMap_get;
    var label = ((_valueToItemMap_get = valueToItemMap.get(value)) === null || _valueToItemMap_get === void 0 ? void 0 : _valueToItemMap_get.label) || value.toString();
    return renderValue ? renderValue(valueToItemMap.get(value) || {
        value: value,
        label: label
    }) : label;
};
export var getButtonLabel = function getButtonLabel(param) {
    var value = param.value, valueToItemMap = param.valueToItemMap, label = param.label, renderValue = param.renderValue, selectProps = param.selectProps;
    if (isEmpty(value) && typeof value !== 'number') {
        return label || '';
    }
    if (selectProps.multiselect && Array.isArray(value) && selectProps.isTargetAmount) {
        return "Выбрано ".concat(value.length);
    }
    if (selectProps.multiselect && Array.isArray(value)) {
        return value === null || value === void 0 ? void 0 : value.map(function(itemValue) {
            return getLabel({
                value: itemValue,
                valueToItemMap: valueToItemMap,
                renderValue: renderValue
            });
        }).join(', ');
    }
    return getLabel({
        value: value,
        valueToItemMap: valueToItemMap,
        renderValue: renderValue
    });
};
