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

import { usePrefixClass } from '../../hooks/useConfig.js';
import { getTNode } from '../util.js';
import '@vue/composition-api';
import '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../../_chunks/dep-67ff4010.js';
import '../../config-provider/type.js';
import '@babel/runtime/helpers/defineProperty';
import 'lodash/camelCase';

function useRenderLine(props) {
  var componentName = usePrefixClass("tree").value;
  var renderLine = function renderLine(h) {
    var node = props.node,
      treeScope = props.treeScope;
    var scopedSlots = treeScope.scopedSlots;
    var treeProps = (treeScope === null || treeScope === void 0 ? void 0 : treeScope.treeProps) || {};
    var line = treeProps.line;
    var iconVisible = !!treeProps.icon;
    var lineNode = null;
    if (line === true) {
      if (scopedSlots !== null && scopedSlots !== void 0 && scopedSlots.line) {
        lineNode = scopedSlots.line({
          node: node === null || node === void 0 ? void 0 : node.getModel()
        });
      } else if (node.parent && node.tree) {
        var vmIsLeaf = node.vmIsLeaf,
          vmIsFirst = node.vmIsFirst,
          level = node.level;
        var lineClasses = [];
        lineClasses.push("".concat(componentName, "__line"));
        if (vmIsLeaf || !iconVisible) lineClasses.push("".concat(componentName, "__line--leaf"));
        if (vmIsFirst && iconVisible) lineClasses.push("".concat(componentName, "__line--first"));
        var shadowStyles = [];
        var parents = node.getParents();
        parents.pop();
        parents.forEach(function (pnode, index) {
          if (!pnode.vmIsLast) shadowStyles.push("calc(-".concat(index + 1, " * var(--space)) 0 var(--color)"));
        });
        var styles = {
          "--level": level ? String(level) : void 0,
          "box-shadow": shadowStyles.join(",")
        };
        lineNode = h("span", {
          "class": lineClasses,
          "style": styles
        });
      }
    } else {
      lineNode = getTNode(line, {
        createElement: h,
        node: node
      });
    }
    return lineNode;
  };
  return {
    renderLine: renderLine
  };
}

export { useRenderLine as default };
//# sourceMappingURL=useRenderLine.js.map
