"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = _interopRequireDefault(require("react"));

var _input = _interopRequireDefault(require("../input"));

var _verticalTreeNode = _interopRequireDefault(require("./verticalTreeNode"));

var _rcVirtualList = _interopRequireDefault(require("../components/rc-virtual-list"));

var _treeFunctions = require("./utils/treeFunctions");

var _utils = require("./utils/_utils");

var _traverseUtils = require("./utils/traverseUtils");

var dragInitData = {
  dragStartNode: null,
  dragOverNode: null,
  dragStartPosition: null
};

var VerticalTreeRenderFunction = function VerticalTreeRenderFunction(props, ref) {
  var hover = props.hover,
      multiple = props.multiple,
      className = props.className,
      showSearch = props.showSearch,
      checkable = props.checkable,
      draggable = props.draggable,
      virtual = props.virtual,
      listHeight = props.height,
      allLineClickable = props.allLineClickable,
      prefixCls = props.prefixCls,
      switcherIcon = props.switcherIcon,
      searchListType = props.searchListType,
      placeholder = props.placeholder,
      outerSearchValue = props.searchValue,
      outerSearchList = props.searchList,
      outerTreeData = props.treeData,
      outerCheckedKeys = props.checkedKeys,
      outerSelectedKeys = props.selectedKeys,
      outerExpandedKeys = props.expandedKeys,
      _props$defaultChecked = props.defaultCheckedKeys,
      defaultCheckedKeys = _props$defaultChecked === void 0 ? [] : _props$defaultChecked,
      _props$defaultSelecte = props.defaultSelectedKeys,
      defaultSelectedKeys = _props$defaultSelecte === void 0 ? [] : _props$defaultSelecte,
      _props$defaultExpande = props.defaultExpandedKeys,
      defaultExpandedKeys = _props$defaultExpande === void 0 ? [] : _props$defaultExpande,
      defaultExpandAll = props.defaultExpandAll,
      autoExpandParent = props.autoExpandParent,
      _props$fieldNames = props.fieldNames,
      fieldNames = _props$fieldNames === void 0 ? _utils.__DEFAULT_FIELDNAMES__ : _props$fieldNames,
      customSearch = props.customSearch,
      onDrop = props.onDrop,
      showIcon = props.showIcon,
      showLine = props.showLine,
      searchProps = props.searchProps,
      renderTreeNode = props.renderTreeNode,
      onDragEnd = props.onDragEnd,
      onDragEnter = props.onDragEnter,
      onDragLeave = props.onDragLeave,
      onDragOver = props.onDragOver,
      onDragStart = props.onDragStart,
      onSelect = props.onSelect,
      onCheck = props.onCheck,
      onExpand = props.onExpand,
      onSearchChange = props.onSearchChange,
      onSearchListSelect = props.onSearchListSelect,
      loadData = props.loadData,
      reset = (0, _objectWithoutProperties2.default)(props, ["hover", "multiple", "className", "showSearch", "checkable", "draggable", "virtual", "height", "allLineClickable", "prefixCls", "switcherIcon", "searchListType", "placeholder", "searchValue", "searchList", "treeData", "checkedKeys", "selectedKeys", "expandedKeys", "defaultCheckedKeys", "defaultSelectedKeys", "defaultExpandedKeys", "defaultExpandAll", "autoExpandParent", "fieldNames", "customSearch", "onDrop", "showIcon", "showLine", "searchProps", "renderTreeNode", "onDragEnd", "onDragEnter", "onDragLeave", "onDragOver", "onDragStart", "onSelect", "onCheck", "onExpand", "onSearchChange", "onSearchListSelect", "loadData"]);
  var endFieldNames = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _utils.__DEFAULT_FIELDNAMES__), fieldNames); // key -> node

  var keyToTreeNodeMapRef = _react.default.useRef(new Map()); // title -> key


  var titleToKeyMapRef = _react.default.useRef(new Map()); // key number set


  var numberKeysSetRef = _react.default.useRef(new Set()); // tree dom


  var verticalTreeRef = _react.default.useRef(null); // 保存上一次的expandedKeys


  var prevExpandedKeysRef = _react.default.useRef(); // 保存上一次的checkedKeys


  var prevCheckedKeysRef = _react.default.useRef(); // 保存当前选中的keys


  var checkedKeysRef = _react.default.useRef(); // 保存上一次的treeData


  var prevTreeDataRef = _react.default.useRef(); // 保存转换后的treeData


  var traversedTreeDataRef = _react.default.useRef([]);

  var _React$useState = _react.default.useState([]),
      _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
      searchList = _React$useState2[0],
      setSearchList = _React$useState2[1];

  var _React$useState3 = _react.default.useState(null),
      _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
      curLoadingKey = _React$useState4[0],
      setCurLoadingKey = _React$useState4[1];

  var _React$useState5 = _react.default.useState(outerCheckedKeys || defaultCheckedKeys),
      _React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
      checkedKeys = _React$useState6[0],
      setCheckedKeys = _React$useState6[1];

  var _React$useState7 = _react.default.useState((0, _utils.getExpandedKeys)(traversedTreeDataRef.current, outerExpandedKeys || defaultExpandedKeys, // 默认展开并且不受控
  defaultExpandAll && typeof outerExpandedKeys === 'undefined', autoExpandParent)),
      _React$useState8 = (0, _slicedToArray2.default)(_React$useState7, 2),
      expandedKeys = _React$useState8[0],
      setExpandedKeys = _React$useState8[1];

  var _React$useState9 = _react.default.useState(outerSelectedKeys || defaultSelectedKeys),
      _React$useState10 = (0, _slicedToArray2.default)(_React$useState9, 2),
      selectedKeys = _React$useState10[0],
      setSelectedKeys = _React$useState10[1];

  var _React$useState11 = _react.default.useState(new Set()),
      _React$useState12 = (0, _slicedToArray2.default)(_React$useState11, 2),
      halfCheckedKeys = _React$useState12[0],
      setHalfCheckedKeys = _React$useState12[1];

  var _React$useState13 = _react.default.useState(outerSearchValue),
      _React$useState14 = (0, _slicedToArray2.default)(_React$useState13, 2),
      inputValue = _React$useState14[0],
      setInputValue = _React$useState14[1];

  var _React$useState15 = _react.default.useState({
    dragBottom: false
  }),
      _React$useState16 = (0, _slicedToArray2.default)(_React$useState15, 2),
      dargoverInfo = _React$useState16[0],
      setDargoverInfo = _React$useState16[1];

  var updateKeys = function updateKeys(updateCheckedKeys) {
    var _getNodeKeys = (0, _treeFunctions.getNodeKeys)(updateCheckedKeys, keyToTreeNodeMapRef.current),
        _getNodeKeys2 = (0, _slicedToArray2.default)(_getNodeKeys, 2),
        endKeys = _getNodeKeys2[0],
        halfKeys = _getNodeKeys2[1];

    setCheckedKeys((0, _toConsumableArray2.default)(endKeys));
    setHalfCheckedKeys(halfKeys);
  }; // 防止每次更新都对outerTreeData进行数据转换


  if (typeof outerTreeData !== 'undefined' && outerTreeData !== prevTreeDataRef.current) {
    traversedTreeDataRef.current = (0, _traverseUtils.traverseTreeNode)(outerTreeData, endFieldNames, keyToTreeNodeMapRef.current, numberKeysSetRef.current, false, titleToKeyMapRef.current); // 数据变化更新Keys

    if (checkable) {
      updateKeys(new Set((0, _toConsumableArray2.default)(checkedKeys)));
    }
  }

  var expandedKeysSet = new Set(expandedKeys);
  var checkedKeysSet = new Set(checkedKeys);
  var selectedKeysSet = new Set(selectedKeys); //保存拖拽信息

  var dragDataRef = _react.default.useRef(dragInitData);

  if (typeof outerSearchValue !== 'undefined' && outerSearchValue !== inputValue) {
    setInputValue(outerSearchValue);
  }

  if (typeof outerSearchList !== 'undefined' && outerSearchList !== searchList) {
    setSearchList(outerSearchList);
  }

  if (typeof outerCheckedKeys !== 'undefined' && outerCheckedKeys !== prevCheckedKeysRef.current) {
    updateKeys(new Set((0, _toConsumableArray2.default)(outerCheckedKeys)));
  }

  if (typeof outerExpandedKeys !== 'undefined' && outerExpandedKeys !== prevExpandedKeysRef.current) {
    setExpandedKeys((0, _utils.getExpandedKeys)(traversedTreeDataRef.current, outerExpandedKeys || defaultExpandedKeys, false, autoExpandParent));
  }

  if (typeof outerSelectedKeys !== 'undefined' && outerSelectedKeys !== selectedKeys) {
    setSelectedKeys(outerSelectedKeys);
  }

  prevCheckedKeysRef.current = outerCheckedKeys;
  prevExpandedKeysRef.current = outerExpandedKeys;
  prevTreeDataRef.current = outerTreeData;
  checkedKeysRef.current = checkedKeys;

  var nodeExpand = function nodeExpand(node) {
    var expanded = node.expanded;

    if (!expanded) {
      expandedKeysSet.add(node.nodeKey);
    } else {
      expandedKeysSet.delete(node.nodeKey);
    }

    if (typeof outerExpandedKeys === 'undefined') {
      setExpandedKeys((0, _toConsumableArray2.default)(expandedKeysSet));
    }

    onExpand === null || onExpand === void 0 ? void 0 : onExpand((0, _toConsumableArray2.default)(expandedKeysSet), {
      expand: !!expanded,
      node: node
    });
  };

  var onNodeExpand = function onNodeExpand(treeNode) {
    var copyTreeNode = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, treeNode), {}, {
      key: treeNode.nodeKey
    }); // 如果有children就代表数据已经加载过了

    if (loadData && !copyTreeNode.children && !copyTreeNode.isLeaf) {
      setCurLoadingKey(copyTreeNode.nodeKey);
      loadData(copyTreeNode, copyTreeNode.level + 1).then(function () {
        // 数据异步回来之后这里需要获取到最新的treeNode
        var newTreeNode = keyToTreeNodeMapRef.current.get(copyTreeNode.nodeKey);
        setCurLoadingKey(null);
        if (!newTreeNode) return; // updateKeys(checkedKeysSet);

        nodeExpand(newTreeNode);
      });
      return;
    }

    nodeExpand(copyTreeNode);
  };

  var onNodeSelect = function onNodeSelect(e, node) {
    var _onTreeNodeSelect = (0, _treeFunctions.onTreeNodeSelect)(node, selectedKeysSet, endFieldNames, keyToTreeNodeMapRef.current, multiple),
        _onTreeNodeSelect2 = (0, _slicedToArray2.default)(_onTreeNodeSelect, 2),
        keys = _onTreeNodeSelect2[0],
        selectedTreeNodes = _onTreeNodeSelect2[1];

    if (typeof outerSelectedKeys === 'undefined') {
      setSelectedKeys(keys);
    }

    onSelect === null || onSelect === void 0 ? void 0 : onSelect(keys, {
      event: 'select',
      selected: !!node.selected,
      selectedNodes: selectedTreeNodes,
      nativeEvent: e.nativeEvent
    });
  };

  var onNodeCheck = function onNodeCheck(e, treeNode) {
    var newCheckedKeysSet = new Set((0, _toConsumableArray2.default)(checkedKeys));

    var _onTreeNodeCheck = (0, _treeFunctions.onTreeNodeCheck)(treeNode, e.target.checked, newCheckedKeysSet, keyToTreeNodeMapRef.current),
        _onTreeNodeCheck2 = (0, _slicedToArray2.default)(_onTreeNodeCheck, 3),
        exportCheckedKeys = _onTreeNodeCheck2[0],
        exportFilterAnCheckedKeys = _onTreeNodeCheck2[1],
        halfKeysSet = _onTreeNodeCheck2[2];

    if (typeof outerCheckedKeys === 'undefined') {
      setCheckedKeys((0, _toConsumableArray2.default)(newCheckedKeysSet));
      setHalfCheckedKeys(halfKeysSet);
    }

    var _getCheckedNodes = (0, _utils.getCheckedNodes)(treeNode, checkedKeysSet, endFieldNames, keyToTreeNodeMapRef.current),
        _getCheckedNodes2 = (0, _slicedToArray2.default)(_getCheckedNodes, 1),
        checkedTreeNode = _getCheckedNodes2[0];

    onCheck === null || onCheck === void 0 ? void 0 : onCheck(exportCheckedKeys, {
      checked: e.target.checked,
      checkedNodes: checkedTreeNode,
      event: 'check',
      nativeEvent: e.nativeEvent,
      checkedChildrenKeys: exportFilterAnCheckedKeys
    });
  };

  var clearDragState = function clearDragState() {
    setDargoverInfo({});
    dragDataRef.current = dragInitData;
  };

  var onNodeDragStart = function onNodeDragStart(e, node) {
    var clientX = e.clientX,
        clientY = e.clientY; // 设置当前正在拖拽的节点

    dragDataRef.current.dragStartNode = node; // 记录当前位置

    dragDataRef.current.dragStartPosition = [clientX, clientY];
    onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart({
      event: e,
      node: node
    });
  };

  var onNodeDragEnter = function onNodeDragEnter(e, node) {
    onDragEnter === null || onDragEnter === void 0 ? void 0 : onDragEnter({
      event: e,
      node: node
    });
  };

  var onNodeDragLeave = function onNodeDragLeave(e, node) {
    onDragLeave === null || onDragLeave === void 0 ? void 0 : onDragLeave({
      event: e,
      node: node
    });
  };

  var onNodeDragOver = function onNodeDragOver(e, node) {
    var _treeData$;

    e.preventDefault();
    var treeData = traversedTreeDataRef.current;
    var clientX = e.clientX,
        clientY = e.clientY,
        currentTarget = e.currentTarget;
    var isDragBottom,
        isDragTop = false;
    var dragBottom = dargoverInfo.dragBottom,
        dragTop = dargoverInfo.dragTop;
    /* eslint-disable prefer-const */

    var _dragDataRef$current = dragDataRef.current,
        dragOverNode = _dragDataRef$current.dragOverNode,
        dragStartNode = _dragDataRef$current.dragStartNode,
        dragStartPosition = _dragDataRef$current.dragStartPosition;

    if (!dragStartPosition) {
      dragStartPosition = [clientX, clientY];
    }

    var _dragStartPosition = dragStartPosition,
        _dragStartPosition2 = (0, _slicedToArray2.default)(_dragStartPosition, 1),
        startX = _dragStartPosition2[0]; // 目标节点为第一个节点（treeData[0]）并且被拖拽节点期望和该节点交换位置


    var _e$target$getBounding = e.target.getBoundingClientRect(),
        top = _e$target$getBounding.top,
        height = _e$target$getBounding.height;

    if (((_treeData$ = treeData[0]) === null || _treeData$ === void 0 ? void 0 : _treeData$.nodeKey) === node.nodeKey && clientY < top + height / 2) {
      isDragTop = true;
    } else {
      isDragTop = false;
    } // 大于20代表当前拖动节点将作为目标元素子节点


    if (clientX - startX >= _utils.__AsTargetChildXOffset__) {
      isDragBottom = true;
    } else {
      isDragBottom = false;
    } // 防止dragover重复执行


    if ((dragOverNode === null || dragOverNode === void 0 ? void 0 : dragOverNode.nodeKey) === node.nodeKey && dragBottom === isDragBottom && dragTop === isDragTop) {
      return;
    } // 检测被拖拽的节点是否是目标节点的父节点


    var currentDragNodeIsFather = false;
    var temp = node;

    while (temp) {
      if ((dragStartNode === null || dragStartNode === void 0 ? void 0 : dragStartNode.nodeKey) === temp.nodeKey) {
        currentDragNodeIsFather = true;
      }

      temp = temp.parent;
    }

    if (currentDragNodeIsFather) return; // 目标节点显示下划线
    // setInfoKey(node.nodeKey)

    setDargoverInfo({
      targetKey: node.nodeKey,
      dragBottom: isDragBottom,
      dragTop: isDragTop
    }); // 当前节点未展开则展开节点

    if (!expandedKeysSet.has(node.nodeKey)) {
      onNodeExpand(node);
    }

    dragDataRef.current.dragOverNode = node;
    onDragOver === null || onDragOver === void 0 ? void 0 : onDragOver({
      node: node,
      event: e
    });
  };

  var onNodeDragEnd = function onNodeDragEnd(e, node) {
    clearDragState();
    onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd({
      event: e,
      node: node
    });
  };

  var onNodeDrop = function onNodeDrop(e, node) {
    var dragStartNode = dragDataRef.current.dragStartNode;

    if ((dragStartNode === null || dragStartNode === void 0 ? void 0 : dragStartNode.nodeKey) === node.nodeKey) {
      clearDragState();
      return;
    }

    var dragBottom = dargoverInfo.dragBottom,
        dragTop = dargoverInfo.dragTop;

    var _handleExportNodes = (0, _utils.handleExportNodes)([dragStartNode, node], endFieldNames),
        _handleExportNodes2 = (0, _slicedToArray2.default)(_handleExportNodes, 1),
        _handleExportNodes2$ = (0, _slicedToArray2.default)(_handleExportNodes2[0], 2),
        exportDragNode = _handleExportNodes2$[0],
        exportDropNode = _handleExportNodes2$[1];

    var dropPosition = 1;

    if (dragBottom) {
      dropPosition = 0;
    }

    if (dragTop) {
      dropPosition = -1;
    }

    onDrop === null || onDrop === void 0 ? void 0 : onDrop({
      dragNode: exportDragNode,
      node: exportDropNode,
      dropPosition: dropPosition,
      event: e
    });
    clearDragState();
  };

  var onInputChange = function onInputChange(val) {
    // 无法配合按需加载使用
    if (loadData || customSearch) return;
    var eKeysSet = new Set();
    var endSearchPanelList = [];
    titleToKeyMapRef.current.forEach(function (value, title) {
      if (title.includes(val)) {
        var nodeKey = titleToKeyMapRef.current.get(title);

        if (nodeKey) {
          eKeysSet.add(nodeKey);
        }
      }
    }); // 如果是展示成tree-list形式，内部逻辑

    if (searchListType === 'tree-list') {
      setExpandedKeys((0, _utils.getExpandedKeys)(traversedTreeDataRef.current, [].concat((0, _toConsumableArray2.default)(outerExpandedKeys || []), (0, _toConsumableArray2.default)(val ? eKeysSet : [])), false, autoExpandParent));
    } // 如果是展示成list形式，允许受控


    if (searchListType === 'list' && val) {
      var endKeysSet = new Set((0, _toConsumableArray2.default)(eKeysSet)); // 过滤数据

      eKeysSet.forEach(function (nodeKey) {
        var targetNode = keyToTreeNodeMapRef.current.get(nodeKey);
        if (!targetNode) return;
        var parent = targetNode.parent;

        while (parent) {
          if (endKeysSet.has(parent.nodeKey)) {
            endKeysSet.delete(parent.nodeKey);
          }

          parent = parent.parent;
        }
      });
      endKeysSet.forEach(function (nodeKey) {
        var currentPath = [];
        var targetNode = keyToTreeNodeMapRef.current.get(nodeKey);

        if (targetNode) {
          // 组装listpanel的数据
          currentPath.push(targetNode.title);
          var parent = targetNode.parent;

          while (parent) {
            currentPath.unshift(parent.title);
            parent = parent.parent;
          }

          var children = targetNode.children;
          (0, _traverseUtils.traverse)(children, function (node) {
            currentPath.push(node.title);
          }, function () {
            return currentPath.pop();
          });
          endSearchPanelList.push(currentPath);
        }
      });
    }

    if (typeof outerSearchList === 'undefined') {
      setSearchList(endSearchPanelList);
    }

    if (typeof outerSearchValue === 'undefined') {
      setInputValue(val);
    }

    onSearchChange === null || onSearchChange === void 0 ? void 0 : onSearchChange(val, endSearchPanelList);
  };

  var renderSearchedTitle = function renderSearchedTitle(title, searchValue) {
    if (searchValue && typeof title === 'string' && title.includes(searchValue)) {
      var index = title.indexOf(searchValue);
      var leftStr = title.slice(0, index);
      var rightStr = title.slice(index + searchValue.length, title.length);
      var searchedStr = title.slice(index, index + searchValue.length);
      return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, leftStr, /*#__PURE__*/_react.default.createElement("span", {
        className: "".concat(prefixCls, "-searching")
      }, searchedStr), rightStr);
    }

    return title;
  };

  var renderSearch = function renderSearch() {
    if (!showSearch) return null;
    return /*#__PURE__*/_react.default.createElement("div", {
      className: "".concat(prefixCls, "-search-wrapper")
    }, /*#__PURE__*/_react.default.createElement(_input.default.Search, Object.assign({
      className: "".concat(prefixCls, "-search"),
      // onSearch={onInputSearch}
      value: inputValue,
      onChange: function onChange(e) {
        return onInputChange(e.target.value);
      },
      placeholder: placeholder
    }, searchProps)));
  };

  _react.default.useImperativeHandle(ref, function () {
    return {
      onSearchChange: onInputChange,
      element: verticalTreeRef
    };
  });
  /**
   * to do
   * 这里其实可以针对searchListPanel做个优化
   * searchListPanel的更新优先级较低
   * 因此依赖项都应该是deferredValue，比如searchList和inputValue
   */


  var renderSearchListPanel = function renderSearchListPanel() {
    if ((searchList === null || searchList === void 0 ? void 0 : searchList.length) && searchListType === 'list' && inputValue !== '') {
      return /*#__PURE__*/_react.default.createElement("div", {
        className: "".concat(prefixCls, "-searchListPanel")
      }, searchList.map(function (path, outerIndex) {
        return /*#__PURE__*/_react.default.createElement("div", {
          key: outerIndex,
          className: "".concat(prefixCls, "-searchListPanel-item"),
          title: path.join('/'),
          onClick: function onClick(e) {
            return onSearchListSelect === null || onSearchListSelect === void 0 ? void 0 : onSearchListSelect(path, e);
          }
        }, path.map(function (title, index) {
          return /*#__PURE__*/_react.default.createElement("span", {
            key: index
          }, index === 0 ? '' : /*#__PURE__*/_react.default.createElement("span", null, "\xA0/\xA0"), renderSearchedTitle(title, inputValue));
        }));
      }));
    }

    return null;
  };

  var renderTreeList = function renderTreeList() {
    if (searchList.length) return null;
    var nodeList = [];
    var treeData = traversedTreeDataRef.current;

    var renderTreeNodes = function renderTreeNodes(children) {
      if (!children || !children.length) return;
      children.forEach(function (treeNode, index) {
        // 当前节点层级不在第一级并且父级key不展开时
        if (treeNode.level !== 0 && treeNode.parent && !expandedKeysSet.has(treeNode.parent.nodeKey)) {
          return;
        }

        nodeList.push((0, _objectSpread2.default)({
          indexAtLevel: index,
          childrenLen: children.length
        }, treeNode));
        renderTreeNodes(treeNode.children);
      });
      return;
    };

    renderTreeNodes(treeData);
    return /*#__PURE__*/_react.default.createElement(_rcVirtualList.default, {
      itemKey: "key",
      itemHeight: 32,
      data: nodeList,
      height: listHeight,
      virtual: virtual,
      prefixCls: "".concat(prefixCls, "-list")
    }, function (treeNode) {
      return /*#__PURE__*/_react.default.createElement(_verticalTreeNode.default, Object.assign({}, treeNode, {
        fieldNames: endFieldNames,
        searchValue: inputValue,
        hover: hover,
        showIcon: showIcon,
        checkable: checkable,
        draggable: draggable,
        showLine: showLine,
        switcherIcon: switcherIcon,
        dragoverInfo: dargoverInfo,
        allLineClickable: allLineClickable,
        checked: checkedKeysSet.has(treeNode.nodeKey),
        expanded: expandedKeysSet.has(treeNode.nodeKey),
        selected: selectedKeysSet.has(treeNode.nodeKey),
        indeterminate: halfCheckedKeys.has(treeNode.nodeKey),
        numberKeysSet: numberKeysSetRef.current,
        isLeaf: (0, _utils.getNodeIsLeaf)(treeNode, !!loadData),
        loading: loadData && treeNode.nodeKey === curLoadingKey && !treeNode.children,
        renderTreeNode: renderTreeNode,
        renderSearchedTitle: renderSearchedTitle,
        onNodeSelect: onNodeSelect,
        onNodeExpand: onNodeExpand,
        onNodeCheck: onNodeCheck,
        onNodeDragStart: onNodeDragStart,
        onNodeDragEnd: onNodeDragEnd,
        onNodeDragEnter: onNodeDragEnter,
        onNodeDragOver: onNodeDragOver,
        onNodeDragLeave: onNodeDragLeave,
        onNodeDrop: onNodeDrop
      }));
    });
  };

  return /*#__PURE__*/_react.default.createElement("div", Object.assign({}, reset, {
    className: className,
    ref: verticalTreeRef
  }), renderSearch(), renderTreeList(), renderSearchListPanel());
};

var VerticalTree = /*#__PURE__*/_react.default.forwardRef(VerticalTreeRenderFunction);

VerticalTree.defaultProps = {
  // direction: 'horizontal'
  searchListType: 'tree-list',
  hover: 'longtest',
  multiple: false,
  checkable: false,
  virtual: true,
  autoExpandParent: false
};
var _default = VerticalTree;
exports.default = _default;