"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const aria = require("../../../constants/aria.js");
const event = require("../../../utils/dom/event.js");
const refs = require("../../../utils/vue/refs.js");
const index = require("../../../hooks/use-namespace/index.js");
const rovingFocusGroup = require("../../roving-focus-group/src/roving-focus-group.js");
const tokens$1 = require("../../roving-focus-group/src/tokens.js");
const dropdown = require("./dropdown.js");
const tokens = require("./tokens.js");
const useDropdown = require("./useDropdown.js");
const Vue = require("vue");
var dropdown_menu_vue_vue_type_script_lang_default = Vue.defineComponent({
  name: "ElDropdownMenu",
  props: dropdown.dropdownMenuProps,
  setup(props) {
    const ns = index.useNamespace("dropdown");
    const { _elDropdownSize } = useDropdown.useDropdown();
    const size = _elDropdownSize.value;
    const { contentRef, role, triggerId, isUsingKeyboard, handleClose } = Vue.inject(tokens.DROPDOWN_INJECTION_KEY, void 0);
    const { rovingFocusGroupRef, rovingFocusGroupRootStyle, onBlur, onFocus, onKeydown, onMousedown } = Vue.inject(tokens$1.ROVING_FOCUS_GROUP_INJECTION_KEY, void 0);
    const { collectionRef: rovingFocusGroupCollectionRef } = Vue.inject(rovingFocusGroup.ROVING_FOCUS_COLLECTION_INJECTION_KEY, void 0);
    const dropdownKls = Vue.computed(() => {
      return [ns.b("menu"), ns.bm("menu", size == null ? void 0 : size.value)];
    });
    const dropdownListWrapperRef = refs.composeRefs(contentRef, rovingFocusGroupRef, rovingFocusGroupCollectionRef);
    const handleKeydown = event.composeEventHandlers((e) => {
      var _a;
      (_a = props.onKeydown) == null ? void 0 : _a.call(props, e);
    }, (e) => {
      const { currentTarget, target } = e;
      const code = event.getEventCode(e);
      if (currentTarget.contains(target)) ;
      if (aria.EVENT_CODE.tab === code) return handleClose();
      onKeydown(e);
    });
    function handleFocus(e) {
      isUsingKeyboard.value && onFocus(e);
    }
    return {
      size,
      rovingFocusGroupRootStyle,
      dropdownKls,
      role,
      triggerId,
      dropdownListWrapperRef,
      handleKeydown,
      onBlur,
      handleFocus,
      onMousedown
    };
  }
});
exports.default = dropdown_menu_vue_vue_type_script_lang_default;
