/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';

function getLabelIsEllipsis(node, size) {
  var sizeMap = {
    small: 11,
    medium: 9,
    large: 8
  };
  return sizeMap[size] < node.label.length;
}
function getNodeStatusClass(node, CLASSNAMES, cascaderContext) {
  var _ref;

  var checkStrictly = cascaderContext.checkStrictly,
      multiple = cascaderContext.multiple,
      value = cascaderContext.value,
      max = cascaderContext.max;
  var expandedActive = !checkStrictly && node.expanded && (multiple ? !node.isLeaf() : true);
  var isLeaf = node.isLeaf();
  var isDisabled = node.disabled || multiple && value.length >= max && max !== 0;
  var isSelected = node.checked || multiple && !checkStrictly && node.expanded && !isLeaf;
  return [(_ref = {}, _defineProperty(_ref, CLASSNAMES.STATUS.selected, !isDisabled && isSelected), _defineProperty(_ref, CLASSNAMES.STATUS.expanded, !isDisabled && expandedActive), _defineProperty(_ref, CLASSNAMES.STATUS.disabled, isDisabled), _ref)];
}
function getCascaderItemClass(prefix, node, CLASSNAMES, cascaderContext) {
  var _ref2;

  var size = cascaderContext.size;
  return ["".concat(prefix, "-cascader__item")].concat(_toConsumableArray(getNodeStatusClass(node, CLASSNAMES, cascaderContext)), [(_ref2 = {}, _defineProperty(_ref2, "".concat(prefix, "-cascader__item--with-icon"), node.children), _defineProperty(_ref2, "".concat(prefix, "-cascader__item--leaf"), node.isLeaf()), _defineProperty(_ref2, CLASSNAMES.SIZE[size], size), _ref2)]);
}
function getCascaderItemIconClass(prefix, node, CLASSNAMES, cascaderContext) {
  return ["".concat(prefix, "-cascader__item-icon")].concat(_toConsumableArray(getNodeStatusClass(node, CLASSNAMES, cascaderContext)));
}

export { getCascaderItemClass, getCascaderItemIconClass, getLabelIsEllipsis, getNodeStatusClass };
//# sourceMappingURL=item.js.map
