var index = 1000;
export var createDataSource = function createDataSource(list, map) {
  if (map === void 0) {
    map = {};
  }
  if (!list) return [];
  return list.filter(function (item) {
    return item.type === 'node';
  }).map(function (_ref) {
    var value = _ref.value,
      children = _ref.children,
      state = _ref.state;
    var key = String(index++);
    if (state === 'active') {
      if (!children || children.length === 0) {
        map.selected.push(key);
      } else {
        map.expanded.push(key);
      }
    }
    return {
      value: key,
      label: value,
      disabled: state === 'disabled',
      children: createDataSource(children, map)
    };
  });
};