'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.cjs');
require('../../../vue-components/index.cjs');
var useConfigInject = require('../../config-provider/src/hooks/useConfigInject.cjs');
var index = require('../style/index.cjs');
var iconUtil = require('./utils/iconUtil.cjs');
var dropIndicator = require('./utils/dropIndicator.cjs');
var props = require('./props.cjs');
var initDefaultProps = require('../../../utils/vue/initDefaultProps.cjs');
var log = require('../../../utils/log.cjs');
var omit = require('../../../utils/lang/omit.cjs');
var props$1 = require('../../../utils/vue/props.cjs');
var Tree = require('../../../vue-components/vc-tree/src/Tree.cjs');
var _class = require('../../../utils/dom/class.cjs');

var ATree = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ATree",
  inheritAttrs: false,
  props: initDefaultProps.initDefaultProps(props.treeProps(), {
    checkable: false,
    selectable: true,
    showIcon: false,
    blockNode: false
  }),
  slots: Object,
  setup(props, {
    attrs,
    expose,
    emit,
    slots
  }) {
    log.devWarning(!(props.treeData === void 0 && slots.default), "`children` of Tree is deprecated. Please use `treeData` instead.");
    const {
      prefixCls,
      direction,
      virtual
    } = useConfigInject.default("tree", props);
    const [wrapSSR, hashId] = index.default(prefixCls);
    const treeRef = vue.ref();
    const scrollTo = (scroll) => {
      var _a;
      (_a = treeRef.value) == null ? void 0 : _a.scrollTo(scroll);
    };
    expose({
      treeRef,
      onNodeExpand: (...args) => {
        var _a;
        (_a = treeRef.value) == null ? void 0 : _a.onNodeExpand(...args);
      },
      scrollTo,
      selectedKeys: vue.computed(() => {
        var _a;
        return (_a = treeRef.value) == null ? void 0 : _a.selectedKeys;
      }),
      checkedKeys: vue.computed(() => {
        var _a;
        return (_a = treeRef.value) == null ? void 0 : _a.checkedKeys;
      }),
      halfCheckedKeys: vue.computed(() => {
        var _a;
        return (_a = treeRef.value) == null ? void 0 : _a.halfCheckedKeys;
      }),
      loadedKeys: vue.computed(() => {
        var _a;
        return (_a = treeRef.value) == null ? void 0 : _a.loadedKeys;
      }),
      loadingKeys: vue.computed(() => {
        var _a;
        return (_a = treeRef.value) == null ? void 0 : _a.loadingKeys;
      }),
      expandedKeys: vue.computed(() => {
        var _a;
        return (_a = treeRef.value) == null ? void 0 : _a.expandedKeys;
      })
    });
    vue.watchEffect(() => {
      log.devWarning(props.replaceFields === void 0, "Tree", "`replaceFields` is deprecated, please use fieldNames instead");
    });
    const handleCheck = (checkedObjOrKeys, eventObj) => {
      emit("update:checkedKeys", checkedObjOrKeys);
      emit("check", checkedObjOrKeys, eventObj);
    };
    const handleExpand = (expandedKeys, eventObj) => {
      emit("update:expandedKeys", expandedKeys);
      emit("expand", expandedKeys, eventObj);
    };
    const handleSelect = (selectedKeys, eventObj) => {
      emit("update:selectedKeys", selectedKeys);
      emit("select", selectedKeys, eventObj);
    };
    return () => {
      const {
        showIcon,
        showLine,
        switcherIcon = slots.switcherIcon,
        icon = slots.icon,
        blockNode,
        checkable,
        selectable,
        fieldNames = props.replaceFields,
        motion = props.openAnimation,
        itemHeight = 28,
        onDoubleclick,
        onDblclick
      } = props;
      const newProps = {
        ...attrs,
        ...omit.omit(props, ["onUpdate:checkedKeys", "onUpdate:expandedKeys", "onUpdate:selectedKeys", "onDoubleclick"]),
        showLine: Boolean(showLine),
        dropIndicatorRender: dropIndicator.default,
        fieldNames,
        icon,
        itemHeight
      };
      const children = slots.default ? props$1.filterEmpty(slots.default()) : void 0;
      return wrapSSR(vue.createVNode(Tree.default, {
        ...newProps,
        "virtual": virtual.value,
        "motion": motion,
        "ref": treeRef,
        "prefixCls": prefixCls.value,
        "class": _class.classNames({
          [`${prefixCls.value}-icon-hide`]: !showIcon,
          [`${prefixCls.value}-block-node`]: blockNode,
          [`${prefixCls.value}-unselectable`]: !selectable,
          [`${prefixCls.value}-rtl`]: direction.value === "rtl"
        }, attrs.class, hashId.value),
        "direction": direction.value,
        "checkable": checkable,
        "selectable": selectable,
        "switcherIcon": (nodeProps) => iconUtil.default(prefixCls.value, switcherIcon, nodeProps, slots.leafIcon, showLine),
        "onCheck": handleCheck,
        "onExpand": handleExpand,
        "onSelect": handleSelect,
        "onDblclick": onDblclick || onDoubleclick,
        "children": children
      }, {
        ...slots,
        checkable: () => vue.createVNode("span", {
          "class": `${prefixCls.value}-checkbox-inner`
        }, null)
      }));
    };
  }
});

exports.default = ATree;
//# sourceMappingURL=Tree.cjs.map
