import e,{useRef as n,useMemo as t}from"react";import{DialogPlacementEnum as i,usePopover as o,DialogContentContainer as l}from"@vibe/dialog/mockedClassNames";import{useIsomorphicLayoutEffect as s}from"@vibe/shared";var r=function(r){var u,c=r.anchorRef,a=r.open,d=r.autoFocusOnMount,v=r.onClose,m=r.children,p=r.submenuPosition,b=r.autoAdjustOnSubMenuContentResize,f=n(null),O=n(null);s((function(){d&&a&&(null==f?void 0:f.current)&&requestAnimationFrame((function(){f.current.focus()}))}),[d,a]);var h=t((function(){return"left"===p?i.LEFT_START:void 0}),[p]),g=o(null==c?void 0:c.current,null==O?void 0:O.current,{isOpen:a,placement:h,observeContentResize:b}),j=g.styles,y=g.attributes,C=m&&e.Children.only(m);return(null===(u=null==C?void 0:C.type)||void 0===u?void 0:u.isMenu)?e.createElement("div",Object.assign({style:Object.assign(Object.assign({},j.popper),{visibility:a?"visible":"hidden"})},y.popper,{ref:O}),C&&a&&e.createElement(l,null,e.cloneElement(C,Object.assign(Object.assign({},null==C?void 0:C.props),{isVisible:a,isSubMenu:!0,onClose:v,ref:f,useDocumentEventListeners:!d})))):(console.error("MenuItem can accept only Menu element as first level child, this element is not valid: ",C),null)};export{r as default};
//# sourceMappingURL=MenuItemSubMenu.js.map
