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

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var components_menu_index = require('../../components/menu/index.js');
var modules_menu_props = require('./props.js');
var modules_menu_menuItem = require('./menu-item.js');
var modules_menu_utils = require('./utils.js');
require('../../utils/withInstall.js');
require('vue');
require('lodash/capitalize');
require('../../config.js');
require('../../utils/map-props.js');
require('../../components/menu/menu.js');
require('../../utils/render-node.js');
require('lodash');
require('../../hooks/useConfig.js');
require('../../components/config-provider/useConfig.js');
require('../../components/config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../../chunks/zh_CN.js');
require('../../components/menu/props.js');
require('../../components/menu/v-menu.js');
require('@babel/runtime/helpers/defineProperty');
require('../../components/menu/head-menu.js');
require('../../components/tabs/index.js');
require('../../components/tabs/tabs.js');
require('../../chunks/helper.js');
require('lodash/kebabCase');
require('../../utils/event.js');
require('../../utils/helper.js');
require('lodash/camelCase');
require('../../components/config-provider/config-receiver.js');
require('../../utils/mixins.js');
require('../../components/tabs/props.js');
require('../../components/tabs/tab-panel.js');
require('../../hooks/useDestroyOnClose.js');
require('../../components/tabs/tab-nav.js');
require('lodash/debounce');
require('@ldesign/icons-vue');
require('../../components/tabs/tab-nav-item.js');
require('../../utils/ripple.js');
require('../../chunks/set-style.js');
require('../../components/menu/sub-menu.js');
require('../../components/common/fake-arrow.js');
require('../../components/menu/menu-item.js');
require('../../components/menu/menu-group.js');

var _LdesignMenu = VueCompositionAPI.defineComponent({
  name: "LdesignMenu",
  props: {
    ...modules_menu_props.LdesignMenuProps
  },
  setup(props2, ctx) {
    const {
      allowRouter,
      active
    } = VueCompositionAPI.toRefs(props2);
    VueCompositionAPI.provide("menuContext", VueCompositionAPI.reactive({
      allowRouter
    }));
    const dataList = VueCompositionAPI.computed(() => props2.list);
    const activePath = VueCompositionAPI.ref(props2.active);
    VueCompositionAPI.watch(active, v => {
      activePath.value = v;
    });
    return {
      dataList,
      activePath
    };
  },
  methods: {
    renderCore() {
      const h = this.$createElement;
      return this.dataList.map(item => {
        if (modules_menu_utils.hasChildren(item)) {
          return h(components_menu_index.Submenu, {
            "attrs": {
              "title": item.title,
              "value": item.path
            }
          }, [modules_menu_utils.renderIcon(item.icon, this.iconUrl), h(modules_menu_menuItem["default"], {
            "attrs": {
              "list": item.children
            }
          })]);
        } else {
          return h(components_menu_index.MenuItem, {
            "attrs": {
              "value": item.path,
              "to": item.path
            }
          }, [modules_menu_utils.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(components_menu_index.HeadMenu, {
      "attrs": {
        "defaultValue": this.activePath,
        "defaultExpanded": this.expand,
        "expandType": "popup",
        "theme": this.mode
      }
    }, [this.renderCore()]) : h(components_menu_index.Menu, {
      "attrs": {
        "expandType": this.expandType,
        "defaultValue": this.activePath,
        "defaultExpanded": this.expand,
        "collapsed": this.collapsed,
        "theme": this.mode
      }
    }, [this.renderCore()])]);
  }
});

exports["default"] = _LdesignMenu;
//# sourceMappingURL=menu.js.map
