import { defineComponent, ref, computed, openBlock, createElementBlock, Fragment, createCommentVNode, normalizeStyle, createVNode, mergeProps, withCtx, renderSlot, unref, normalizeClass, createElementVNode, withDirectives, vShow } from 'vue';
import { MeExpandMenu } from '../../expand-menu/index.mjs';
import './column-menu.vue.mjs';
import './main-menu.vue.mjs';
import { ElScrollbar } from 'element-plus';
import script$1 from './main-menu.vue2.mjs';
import script$2 from './column-menu.vue2.mjs';

"use strict";
const _hoisted_1 = { class: "footer" };
const __default__ = defineComponent({
  name: "me-menu"
});
var script = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    mainMenuProps: { type: Object, required: true },
    columnMenuProps: { type: Object, required: true },
    width: { type: Number, required: false },
    show: { type: Boolean, required: false, default: true },
    menuStyle: { type: Object, required: false }
  },
  emits: ["mainMenuClick", "menuItemClick"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const menuExpanded = ref(true);
    const menuRef = ref();
    const mainMenuData = computed(() => props.mainMenuProps.data);
    const columnMenuData = computed(() => props.columnMenuProps.data || []);
    const menuStyle = computed(() => {
      return {
        width: props.width + "px",
        ...props.menuStyle
      };
    });
    const onMainMenuClick = (item) => {
      emit("mainMenuClick", item);
    };
    const onMenuItemClick = (item) => {
      emit("menuItemClick", item);
    };
    const handleMenuExpand = (val) => {
      menuExpanded.value = val;
    };
    const dragbarVisible = computed(() => {
      const isHide = columnMenuData.value?.every((item) => item.hideFlag);
      if (columnMenuData.value.length > 0 && !isHide) {
        menuExpanded.value = true;
        return true;
      } else {
        menuExpanded.value = false;
        return false;
      }
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock(
        Fragment,
        null,
        [
          createCommentVNode(" \u83DC\u5355\u5BB9\u5668 "),
          props.show ? (openBlock(), createElementBlock(
            "div",
            {
              key: 0,
              class: "me-menu",
              style: normalizeStyle(menuStyle.value),
              ref_key: "menuRef",
              ref: menuRef
            },
            [
              createVNode(script$1, mergeProps({ onMainMenuClick }, props.mainMenuProps, { data: mainMenuData.value }), {
                logo: withCtx(() => [
                  renderSlot(_ctx.$slots, "logo")
                ]),
                _: 3
                /* FORWARDED */
              }, 16, ["data"]),
              createVNode(unref(ElScrollbar), {
                class: normalizeClass(["aside-column-menu", {
                  "is-hide": !menuExpanded.value
                }]),
                style: normalizeStyle({ width: props.columnMenuProps.width + "px" })
              }, {
                default: withCtx(() => [
                  createVNode(script$2, mergeProps(props.columnMenuProps, {
                    data: columnMenuData.value,
                    onMenuItemClick
                  }), null, 16, ["data"])
                ]),
                _: 1
                /* STABLE */
              }, 8, ["class", "style"]),
              createElementVNode("div", _hoisted_1, [
                renderSlot(_ctx.$slots, "footer")
              ]),
              withDirectives(createVNode(unref(MeExpandMenu), {
                target: menuRef.value,
                autoHide: "",
                onExpandChangeEvent: handleMenuExpand
              }, null, 8, ["target"]), [
                [vShow, dragbarVisible.value]
              ])
            ],
            4
            /* STYLE */
          )) : createCommentVNode("v-if", true)
        ],
        2112
        /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
      );
    };
  }
});

export { script as default };
//# sourceMappingURL=menu.vue2.mjs.map
