/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _typeof from '@babel/runtime/helpers/typeof';

function getNodeDataByValue(values, data, keys) {
  var getTreeNodeData = function getTreeNodeData(values2, data2, keys2) {
    var results2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : /* @__PURE__ */new Map();
    var _loop = function _loop() {
      var _item$children;
      var item = data2[i];
      var index = values2.findIndex(function (val) {
        return item[keys2.value] === val;
      });
      if (index !== -1) {
        results2.set(values2[index], item);
      }
      if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) getTreeNodeData(values2, item.children, keys2, results2);
      if (results2.size >= values2.length) return {
        v: results2
      };
    };
    for (var i = 0, len = data2.length; i < len; i++) {
      var _ret = _loop();
      if (_typeof(_ret) === "object") return _ret.v;
    }
    return results2;
  };
  var results = getTreeNodeData(values, data, keys);
  if (values.length && results.size < values.length) {
    values.forEach(function (value) {
      var _results$set;
      if (!results.get(value)) results.set(value, (_results$set = {}, _defineProperty(_results$set, keys.label, value), _defineProperty(_results$set, keys.value, value), _results$set));
    });
  }
  return values.map(function (value) {
    return results.get(value);
  });
}
var utils = {};

export { utils as default, getNodeDataByValue };
//# sourceMappingURL=utils.js.map
