"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index = require("../../../hooks/use-locale/index.js");
const index$1 = require("../../../hooks/use-namespace/index.js");
const constants = require("../../form/src/constants.js");
const fixedSizeList = require("../../virtual-list/src/components/fixed-size-list.js");
const virtualTree = require("./virtual-tree.js");
const useTree = require("./composables/useTree.js");
const treeNode = require("./tree-node.js");
const Vue = require("vue");
var tree_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElTreeV2",
  __name: "tree",
  props: virtualTree.treeProps,
  emits: virtualTree.treeEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const slots = Vue.useSlots();
    const treeNodeSize = Vue.computed(() => props.itemSize);
    Vue.provide(virtualTree.ROOT_TREE_INJECTION_KEY, {
      ctx: {
        emit,
        slots
      },
      props,
      instance: Vue.getCurrentInstance()
    });
    Vue.provide(constants.formItemContextKey, void 0);
    const { t } = index.useLocale();
    const ns = index$1.useNamespace("tree");
    const { flattenTree, isNotEmpty, listRef, toggleExpand, isIndeterminate, isChecked, isDisabled, isCurrent, isForceHiddenExpandIcon, handleNodeClick, handleNodeDrop, handleNodeCheck, toggleCheckbox, getCurrentNode, getCurrentKey, setCurrentKey, getCheckedKeys, getCheckedNodes, getHalfCheckedKeys, getHalfCheckedNodes, setChecked, setCheckedKeys, filter, setData, getNode, expandNode, collapseNode, setExpandedKeys, scrollToNode, scrollTo } = useTree.useTree(props, emit);
    __expose({
      toggleCheckbox,
      getCurrentNode,
      getCurrentKey,
      setCurrentKey,
      getCheckedKeys,
      getCheckedNodes,
      getHalfCheckedKeys,
      getHalfCheckedNodes,
      setChecked,
      setCheckedKeys,
      filter,
      setData,
      getNode,
      expandNode,
      collapseNode,
      setExpandedKeys,
      scrollToNode,
      scrollTo
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("div", {
        class: Vue.normalizeClass([Vue.unref(ns).b(), { [Vue.unref(ns).m("highlight-current")]: __props.highlightCurrent }]),
        role: "tree"
      }, [Vue.unref(isNotEmpty) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(fixedSizeList.default), {
        key: 0,
        ref_key: "listRef",
        ref: listRef,
        "class-name": Vue.unref(ns).b("virtual-list"),
        data: Vue.unref(flattenTree),
        total: Vue.unref(flattenTree).length,
        height: __props.height,
        "item-size": treeNodeSize.value,
        "perf-mode": __props.perfMode,
        "scrollbar-always-on": __props.scrollbarAlwaysOn
      }, {
        default: Vue.withCtx(({ data, index: index2, style }) => [(Vue.openBlock(), Vue.createBlock(treeNode.default, {
          key: data[index2].key,
          style: Vue.normalizeStyle(style),
          node: data[index2],
          expanded: data[index2].expanded,
          "show-checkbox": __props.showCheckbox,
          checked: Vue.unref(isChecked)(data[index2]),
          indeterminate: Vue.unref(isIndeterminate)(data[index2]),
          "item-size": treeNodeSize.value,
          disabled: Vue.unref(isDisabled)(data[index2]),
          current: Vue.unref(isCurrent)(data[index2]),
          "hidden-expand-icon": Vue.unref(isForceHiddenExpandIcon)(data[index2]),
          onClick: Vue.unref(handleNodeClick),
          onToggle: Vue.unref(toggleExpand),
          onCheck: Vue.unref(handleNodeCheck),
          onDrop: Vue.unref(handleNodeDrop)
        }, null, 8, [
          "style",
          "node",
          "expanded",
          "show-checkbox",
          "checked",
          "indeterminate",
          "item-size",
          "disabled",
          "current",
          "hidden-expand-icon",
          "onClick",
          "onToggle",
          "onCheck",
          "onDrop"
        ]))]),
        _: 1
      }, 8, [
        "class-name",
        "data",
        "total",
        "height",
        "item-size",
        "perf-mode",
        "scrollbar-always-on"
      ])) : (Vue.openBlock(), Vue.createElementBlock("div", {
        key: 1,
        class: Vue.normalizeClass(Vue.unref(ns).e("empty-block"))
      }, [Vue.renderSlot(_ctx.$slots, "empty", {}, () => [Vue.createElementVNode("span", { class: Vue.normalizeClass(Vue.unref(ns).e("empty-text")) }, Vue.toDisplayString(__props.emptyText ?? Vue.unref(t)("el.tree.emptyText")), 3)])], 2))], 2);
    };
  }
});
exports.default = tree_vue_vue_type_script_setup_true_lang_default;
