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