/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

import { defineComponent, toRefs, provide, reactive, computed, ref, watch } from '@vue/composition-api';
import { Submenu, MenuItem, HeadMenu, Menu } from '../../components/menu/index.js';
import { LdesignMenuProps } from './props.js';
import LdesignMenuItem from './menu-item.js';
import { hasChildren, renderIcon } from './utils.js';
import '../../utils/withInstall.js';
import 'vue';
import 'lodash/capitalize';
import '../../config.js';
import '../../utils/map-props.js';
import '../../components/menu/menu.js';
import '../../utils/render-node.js';
import 'lodash';
import '../../hooks/useConfig.js';
import '../../components/config-provider/useConfig.js';
import '../../components/config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../../chunks/zh_CN.js';
import '../../components/config-provider/type.js';
import '../../components/menu/props.js';
import '../../components/menu/v-menu.js';
import '@babel/runtime/helpers/defineProperty';
import '../../components/menu/head-menu.js';
import '../../components/tabs/index.js';
import '../../components/tabs/tabs.js';
import '../../chunks/helper.js';
import '../../chunks/_commonjsHelpers.js';
import 'lodash/kebabCase';
import '../../utils/event.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../../components/config-provider/config-receiver.js';
import '../../utils/mixins.js';
import '../../components/tabs/props.js';
import '../../components/tabs/tab-panel.js';
import '../../hooks/useDestroyOnClose.js';
import '../../components/tabs/tab-nav.js';
import 'lodash/debounce';
import '@ldesign/icons-vue';
import '../../components/tabs/tab-nav-item.js';
import '../../utils/ripple.js';
import '../../chunks/set-style.js';
import '../../components/tabs/style/css.js';
import '../../components/tabs/type.js';
import '../../components/menu/sub-menu.js';
import '../../components/common/fake-arrow.js';
import '../../components/menu/menu-item.js';
import '../../components/menu/menu-group.js';
import '../../components/menu/style/css.js';
import '../../components/menu/type.js';

var _LdesignMenu = defineComponent({
  name: "LdesignMenu",
  props: {
    ...LdesignMenuProps
  },
  setup(props2, ctx) {
    const {
      allowRouter,
      active
    } = toRefs(props2);
    provide("menuContext", reactive({
      allowRouter
    }));
    const dataList = computed(() => props2.list);
    const activePath = ref(props2.active);
    watch(active, v => {
      activePath.value = v;
    });
    return {
      dataList,
      activePath
    };
  },
  methods: {
    renderCore() {
      const h = this.$createElement;
      return this.dataList.map(item => {
        if (hasChildren(item)) {
          return h(Submenu, {
            "attrs": {
              "title": item.title,
              "value": item.path
            }
          }, [renderIcon(item.icon, this.iconUrl), h(LdesignMenuItem, {
            "attrs": {
              "list": item.children
            }
          })]);
        } else {
          return h(MenuItem, {
            "attrs": {
              "value": item.path,
              "to": item.path
            }
          }, [renderIcon(item.icon, this.iconUrl), h("span", [item.title])]);
        }
      });
    }
  },
  render() {
    const h = arguments[0];
    return h("div", {
      "style": "width:100%;height:100%;"
    }, [this.layout === "horizontal" ? h(HeadMenu, {
      "attrs": {
        "defaultValue": this.activePath,
        "defaultExpanded": this.expand,
        "expandType": "popup",
        "theme": this.mode
      }
    }, [this.renderCore()]) : h(Menu, {
      "attrs": {
        "expandType": this.expandType,
        "defaultValue": this.activePath,
        "defaultExpanded": this.expand,
        "collapsed": this.collapsed,
        "theme": this.mode
      }
    }, [this.renderCore()])]);
  }
});

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