'use strict';

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

var vue = require('vue');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "RecursiveMenu" },
  __name: "recursive-menu",
  props: {
    items: {
      type: Array,
      default: () => []
    }
  },
  emits: {
    claimSelected: (item) => !!item
  },
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const getMenuItemProps = (item) => {
      const { label, subMenu, type, icon, color, ...rest } = item;
      return rest;
    };
    const getSubMenuProps = (item) => {
      const { label, subMenu, icon, color, ...rest } = item;
      return rest;
    };
    const handleClick = (item) => {
      emit("claimSelected", item);
    };
    return (_ctx, _cache) => {
      const _component_a_menu_divider = vue.resolveComponent("a-menu-divider");
      const _component_ll_icon = vue.resolveComponent("ll-icon");
      const _component_a_menu_item = vue.resolveComponent("a-menu-item");
      const _component_RecursiveMenu = vue.resolveComponent("RecursiveMenu", true);
      const _component_a_sub_menu = vue.resolveComponent("a-sub-menu");
      return vue.openBlock(true), vue.createElementBlock(
        vue.Fragment,
        null,
        vue.renderList(props.items, (item, index) => {
          return vue.openBlock(), vue.createElementBlock(
            vue.Fragment,
            {
              key: item?.key ?? index
            },
            [
              vue.createCommentVNode(" \u5206\u9694\u7EBF "),
              item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_a_menu_divider, { key: 0 })) : !item.subMenu || item.subMenu.length === 0 ? (vue.openBlock(), vue.createElementBlock(
                vue.Fragment,
                { key: 1 },
                [
                  vue.createCommentVNode(" \u666E\u901A\u83DC\u5355\u9879 "),
                  vue.createVNode(_component_a_menu_item, vue.mergeProps({ ref_for: true }, getMenuItemProps(item), {
                    onClick: ($event) => handleClick(item)
                  }), vue.createSlots({
                    default: vue.withCtx(() => [
                      vue.createElementVNode(
                        "span",
                        {
                          style: vue.normalizeStyle({ color: item.disabled ? "" : item.color })
                        },
                        vue.toDisplayString(item.label),
                        5
                        /* TEXT, STYLE */
                      )
                    ]),
                    _: 2
                    /* DYNAMIC */
                  }, [
                    item.icon ? {
                      name: "icon",
                      fn: vue.withCtx(() => [
                        vue.createVNode(_component_ll_icon, {
                          "icon-name": item.icon,
                          color: item.disabled ? "" : item.color
                        }, null, 8, ["icon-name", "color"])
                      ]),
                      key: "0"
                    } : void 0
                  ]), 1040, ["onClick"])
                ],
                2112
                /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
              )) : (vue.openBlock(), vue.createElementBlock(
                vue.Fragment,
                { key: 2 },
                [
                  vue.createCommentVNode(" \u5B50\u83DC\u5355 "),
                  vue.createVNode(
                    _component_a_sub_menu,
                    vue.mergeProps({ ref_for: true }, getSubMenuProps(item)),
                    vue.createSlots({
                      title: vue.withCtx(() => [
                        vue.createElementVNode(
                          "span",
                          {
                            style: vue.normalizeStyle({ color: item.disabled ? "" : item.color })
                          },
                          vue.toDisplayString(item.label),
                          5
                          /* TEXT, STYLE */
                        )
                      ]),
                      default: vue.withCtx(() => [
                        vue.createVNode(_component_RecursiveMenu, {
                          items: item.subMenu,
                          onClaimSelected: handleClick
                        }, null, 8, ["items"])
                      ]),
                      _: 2
                      /* DYNAMIC */
                    }, [
                      item.icon ? {
                        name: "icon",
                        fn: vue.withCtx(() => [
                          vue.createVNode(_component_ll_icon, {
                            "icon-name": item.icon,
                            color: item.disabled ? "" : item.color
                          }, null, 8, ["icon-name", "color"])
                        ]),
                        key: "0"
                      } : void 0
                    ]),
                    1040
                    /* FULL_PROPS, DYNAMIC_SLOTS */
                  )
                ],
                2112
                /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
              ))
            ],
            64
            /* STABLE_FRAGMENT */
          );
        }),
        128
        /* KEYED_FRAGMENT */
      );
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=recursive-menu.vue2.js.map
