"use strict";
const React = require("react");
const inline = require("./inline.js");
const pop = require("./pop.js");
const context = require("../context.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
function SubMenu(props, ref) {
  var children = props.children, popup = props.popup, level = props.level;
  var _a = React.useContext(context), mode = _a.mode, collapse = _a.collapse, inDropdown = _a.inDropdown, collectInlineMenuKeys = _a.collectInlineMenuKeys;
  var forcePopup = !!(typeof popup === "function" ? popup(level) : popup);
  var mergedPopup = forcePopup || collapse || inDropdown || mode !== "vertical";
  var MergedMenu = mergedPopup ? pop : inline;
  React.useEffect(function() {
    collectInlineMenuKeys(props._key);
    return function() {
      collectInlineMenuKeys(props._key, true);
    };
  }, []);
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(MergedMenu, {
    ...__assign({
      forwardedRef: ref
    }, props),
    children
  });
}
var ForwardRefSubMenu = React.forwardRef(SubMenu);
var SubMenuComponent = ForwardRefSubMenu;
SubMenuComponent.displayName = "SubMenu";
SubMenuComponent.menuType = "SubMenu";
const SubMenu$1 = SubMenuComponent;
module.exports = SubMenu$1;
//# sourceMappingURL=index.js.map
