"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.calcTreeLine = calcTreeLine;
exports.getItemCacheObj = getItemCacheObj;
function countTreeExpand($xeTree, prevNode) {
  var count = 1;
  if (!prevNode) {
    return count;
  }
  var props = $xeTree;
  var transform = props.transform;
  var reactData = $xeTree.reactData;
  var updateExpandedFlag = reactData.updateExpandedFlag;
  var internalData = $xeTree.internalData;
  var treeExpandedMaps = internalData.treeExpandedMaps;
  var childrenField = $xeTree.computeChildrenField;
  var mapChildrenField = $xeTree.computeMapChildrenField;
  var nodeChildren = prevNode[transform ? mapChildrenField : childrenField];
  if (nodeChildren && updateExpandedFlag && treeExpandedMaps[$xeTree.getNodeId(prevNode)]) {
    for (var index = 0; index < nodeChildren.length; index++) {
      count += countTreeExpand($xeTree, nodeChildren[index]);
    }
  }
  return count;
}
function calcTreeLine($xeTree, node, prevNode) {
  var internalData = $xeTree.internalData;
  var scrollYStore = internalData.scrollYStore;
  var rowHeight = scrollYStore.rowHeight;
  var expandSize = 1;
  if (prevNode) {
    expandSize = countTreeExpand($xeTree, prevNode);
  }
  return (rowHeight || 28) * expandSize - (prevNode ? 1 : 12);
}
function getItemCacheObj(item) {
  return {
    item: item,
    index: -1,
    $index: -1,
    _index: -1,
    items: [],
    parent: null,
    nodes: [],
    level: 0,
    treeIndex: -1,
    lineCount: 0,
    treeLoaded: false
  };
}