/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _typeof = require('@babel/runtime/helpers/typeof');
var isEmpty = require('lodash/isEmpty');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);

function getFullPathLabel(node) {
  return node.getPath().map(function (node2) {
    return node2.label;
  }).join("/");
}
var getTreeValue = function getTreeValue(value) {
  var treeValue = [];

  if (Array.isArray(value)) {
    if (value.length > 0 && _typeof__default["default"](value[0]) === "object") {
      treeValue = value.map(function (val) {
        return val.value;
      });
    } else if (value.length) {
      treeValue = value;
    }
  } else if (value) {
    if (_typeof__default["default"](value) === "object") {
      treeValue = [value.value];
    } else {
      treeValue = [value];
    }
  }

  return treeValue;
};
var getValue = function getValue(value, valueType, multiple) {
  if (valueType === "single") {
    return value;
  }

  if (multiple) {
    return value.map(function (item) {
      return item[item.length - 1];
    });
  }

  return value[value.length - 1];
};
function isEmptyValues(value) {
  if (typeof value === "number" && !isNaN(value)) return false;
  return isEmpty__default["default"](value);
}
var helper = {
  getFullPathLabel: getFullPathLabel
};

exports["default"] = helper;
exports.getFullPathLabel = getFullPathLabel;
exports.getTreeValue = getTreeValue;
exports.getValue = getValue;
exports.isEmptyValues = isEmptyValues;
//# sourceMappingURL=helper.js.map
