'use strict';

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

var vue = require('vue');
require('../../../utils/index.js');
var operateTree = require('./operate-tree.js');
var iconsVue = require('@ant-design/icons-vue');
var createNamespace = require('../../../utils/create-namespace.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "LlOperateTree" },
  __name: "operate-tree",
  props: operateTree.operateTreeProps,
  emits: operateTree.operateTreeEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const attrs = vue.useAttrs();
    const newExpandedKeys = vue.ref([]);
    const hoverTreeNodeItem = vue.ref();
    const bem = createNamespace.createNamespace("operate-tree");
    const handleMouseenter = ({ node }) => {
      hoverTreeNodeItem.value = node;
    };
    const handleMouseleave = () => {
      hoverTreeNodeItem.value = void 0;
    };
    const expand = (expandedKeys, data) => {
      newExpandedKeys.value = expandedKeys;
      emits("expand", expandedKeys, data);
    };
    const select = (selectedKeys, e) => {
      emits("select", selectedKeys, e);
    };
    vue.watch(
      () => props.expandedKeys,
      (keys) => {
        if (keys) {
          newExpandedKeys.value = keys;
        }
      },
      {
        deep: true,
        immediate: true
      }
    );
    return (_ctx, _cache) => {
      const _component_a_directory_tree = vue.resolveComponent("a-directory-tree");
      const _component_ll_empty = vue.resolveComponent("ll-empty");
      const _component_a_spin = vue.resolveComponent("a-spin");
      return vue.openBlock(), vue.createBlock(_component_a_spin, { spinning: _ctx.loading }, {
        default: vue.withCtx(() => [
          vue.createElementVNode(
            "div",
            {
              class: vue.normalizeClass(vue.unref(bem).b()),
              onMouseleave: handleMouseleave
            },
            [
              _ctx.treeData?.length ? (vue.openBlock(), vue.createBlock(_component_a_directory_tree, vue.mergeProps({ key: 0 }, vue.unref(attrs), {
                "block-node": true,
                multiple: "",
                "tree-data": _ctx.treeData,
                "expanded-keys": newExpandedKeys.value,
                "field-names": _ctx.fieldNames,
                onExpand: expand,
                onSelect: select,
                onMouseenter: handleMouseenter
              }), {
                switcherIcon: vue.withCtx((slots) => [
                  vue.renderSlot(_ctx.$slots, "switcherIcon", vue.normalizeProps(vue.guardReactiveProps(slots)), () => [
                    !slots.expanded ? (vue.openBlock(), vue.createBlock(vue.unref(iconsVue.CaretRightOutlined), { key: 0 })) : (vue.openBlock(), vue.createBlock(vue.unref(iconsVue.CaretDownOutlined), { key: 1 }))
                  ])
                ]),
                title: vue.withCtx((slots) => [
                  vue.createElementVNode(
                    "div",
                    {
                      class: vue.normalizeClass(vue.unref(bem).e("title"))
                    },
                    [
                      vue.createElementVNode("div", null, [
                        vue.createCommentVNode(" icon-slots "),
                        _ctx.$slots.icon ? (vue.openBlock(), vue.createElementBlock(
                          "div",
                          {
                            key: 0,
                            class: vue.normalizeClass(vue.unref(bem).e("icon"))
                          },
                          [
                            vue.renderSlot(_ctx.$slots, "icon", vue.normalizeProps(vue.guardReactiveProps(slots)))
                          ],
                          2
                          /* CLASS */
                        )) : vue.createCommentVNode("v-if", true),
                        vue.createCommentVNode(" title-slots "),
                        vue.renderSlot(_ctx.$slots, "treeTitle", vue.normalizeProps(vue.guardReactiveProps(slots)), () => [
                          vue.createElementVNode(
                            "span",
                            null,
                            vue.toDisplayString(slots[_ctx.fieldNames["title"]]),
                            1
                            /* TEXT */
                          )
                        ])
                      ]),
                      vue.createCommentVNode(" operate-slots "),
                      vue.createVNode(
                        vue.Transition,
                        { duration: 100 },
                        {
                          default: vue.withCtx(() => [
                            hoverTreeNodeItem.value && hoverTreeNodeItem.value[_ctx.fieldNames["key"]] === slots[_ctx.fieldNames["key"]] ? (vue.openBlock(), vue.createElementBlock(
                              "div",
                              {
                                key: 0,
                                class: vue.normalizeClass(`${vue.unref(bem).e("operate")} ${hoverTreeNodeItem.value && hoverTreeNodeItem.value[_ctx.fieldNames["key"]] === slots[_ctx.fieldNames["key"]] && ((props.dropdownOpenState?.[slots[_ctx.fieldNames["key"]]] || props.operateDropdownOpen) ?? false) ? vue.unref(bem).is("open") : vue.unref(bem).is("close")}`)
                              },
                              [
                                vue.renderSlot(_ctx.$slots, "treeOperate", { data: slots })
                              ],
                              2
                              /* CLASS */
                            )) : vue.createCommentVNode("v-if", true)
                          ]),
                          _: 2
                          /* DYNAMIC */
                        },
                        1024
                        /* DYNAMIC_SLOTS */
                      )
                    ],
                    2
                    /* CLASS */
                  )
                ]),
                _: 3
                /* FORWARDED */
              }, 16, ["tree-data", "expanded-keys", "field-names"])) : (vue.openBlock(), vue.createElementBlock(
                vue.Fragment,
                { key: 1 },
                [
                  vue.createCommentVNode(" empty-slots "),
                  vue.renderSlot(_ctx.$slots, "empty", {}, () => [
                    vue.createVNode(_component_ll_empty, null, {
                      content: vue.withCtx(() => [..._cache[0] || (_cache[0] = [
                        vue.createTextVNode(
                          "\u6682\u65E0\u6570\u636E",
                          -1
                          /* CACHED */
                        )
                      ])]),
                      _: 1
                      /* STABLE */
                    })
                  ])
                ],
                64
                /* STABLE_FRAGMENT */
              ))
            ],
            34
            /* CLASS, NEED_HYDRATION */
          )
        ]),
        _: 3
        /* FORWARDED */
      }, 8, ["spinning"]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=operate-tree.vue2.js.map
