import { isEmpty } from '../../../utils/isEmpty.js';

var getLabel = function getLabel(_ref) {
  var _valueToItemMap$get;
  var value = _ref.value,
    valueToItemMap = _ref.valueToItemMap,
    renderValue = _ref.renderValue;
  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;
};
var getButtonLabel = function getButtonLabel(_ref2) {
  var value = _ref2.value,
    valueToItemMap = _ref2.valueToItemMap,
    label = _ref2.label,
    renderValue = _ref2.renderValue,
    multiselect = _ref2.multiselect,
    isTargetAmount = _ref2.isTargetAmount;
  if (isEmpty(value) && typeof value !== 'number') {
    return label || '';
  }
  if (multiselect && Array.isArray(value) && isTargetAmount) {
    return "\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(value.length);
  }
  if (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
  });
};

export { getButtonLabel };
