this.primereact=this.primereact||{},this.primereact.tieredmenu=function(e,t,n,i,r,o,s,l){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=a(t),c=a(l);function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(e,t){for(var n=0;ni.width-n.DomHandler.calculateScrollbarWidth()&&n.DomHandler.addClass(this.element,"p-submenu-list-flipped")}}},{key:"onItemMouseEnter",value:function(e,t){t.disabled?e.preventDefault():this.props.root?(this.state.activeItem||this.props.popup)&&this.setState({activeItem:t}):this.setState({activeItem:t})}},{key:"onItemClick",value:function(e,t){t.disabled?e.preventDefault():(t.url||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t}),this.props.root&&t.items&&this.setState(this.state.activeItem&&t===this.state.activeItem?{activeItem:null}:{activeItem:t}),t.items||this.onLeafClick())}},{key:"onItemKeyDown",value:function(e,t){var n=e.currentTarget.parentElement;switch(e.which){case 40:var i=this.findNextItem(n);i&&i.children[0].focus(),e.preventDefault();break;case 38:var r=this.findPrevItem(n);r&&r.children[0].focus(),e.preventDefault();break;case 39:t.items&&(this.setState({activeItem:t}),setTimeout((function(){n.children[1].children[0].children[0].focus()}),50)),e.preventDefault()}this.props.onKeyDown&&this.props.onKeyDown(e,n)}},{key:"onChildItemKeyDown",value:function(e,t){37===e.which&&(this.setState({activeItem:null}),t.parentElement.previousElementSibling.focus())}},{key:"findNextItem",value:function(e){var t=e.nextElementSibling;return t?n.DomHandler.hasClass(t,"p-disabled")||!n.DomHandler.hasClass(t,"p-menuitem")?this.findNextItem(t):t:null}},{key:"findPrevItem",value:function(e){var t=e.previousElementSibling;return t?n.DomHandler.hasClass(t,"p-disabled")||!n.DomHandler.hasClass(t,"p-menuitem")?this.findPrevItem(t):t:null}},{key:"onLeafClick",value:function(){this.setState({activeItem:null}),this.props.onLeafClick&&this.props.onLeafClick()}},{key:"renderSeparator",value:function(e){return u.default.createElement("li",{key:"separator_"+e,className:"p-menu-separator",role:"separator"})}},{key:"renderSubmenu",value:function(e){return e.items?u.default.createElement(s,{model:e.items,onLeafClick:this.onLeafClick,popup:this.props.popup,onKeyDown:this.onChildItemKeyDown,parentActive:e===this.state.activeItem}):null}},{key:"renderMenuitem",value:function(e,t){var r=this,o=this.state.activeItem===e,s=n.classNames("p-menuitem",{"p-menuitem-active":o},e.className),l=n.classNames("p-menuitem-link",{"p-disabled":e.disabled}),a=n.classNames("p-menuitem-icon",e.icon),c="p-submenu-icon pi pi-angle-right",p=e.icon&&u.default.createElement("span",{className:a}),m=e.label&&u.default.createElement("span",{className:"p-menuitem-text"},e.label),d=e.items&&u.default.createElement("span",{className:c}),f=this.renderSubmenu(e),h=u.default.createElement("a",{href:e.url||"#",className:l,target:e.target,role:"menuitem","aria-haspopup":null!=e.items,onClick:function(t){return r.onItemClick(t,e)},onKeyDown:function(t){return r.onItemKeyDown(t,e)},"aria-disabled":e.disabled},p,m,d,u.default.createElement(i.Ripple,null));e.template&&(h=n.ObjectUtils.getJSXElement(e.template,e,{onClick:function(t){return r.onItemClick(t,e)},onKeyDown:function(t){return r.onItemKeyDown(t,e)},className:l,labelClassName:"p-menuitem-text",iconClassName:a,submenuIconClassName:c,element:h,props:this.props,active:o}));return u.default.createElement("li",{key:e.label+"_"+t,className:s,style:e.style,onMouseEnter:function(t){return r.onItemMouseEnter(t,e)},role:"none"},h,f)}},{key:"renderItem",value:function(e,t){return e.separator?this.renderSeparator(t):this.renderMenuitem(e,t)}},{key:"renderMenu",value:function(){var e=this;return this.props.model?this.props.model.map((function(t,n){return e.renderItem(t,n)})):null}},{key:"render",value:function(){var e=this,t=n.classNames({"p-submenu-list":!this.props.root}),i=this.renderMenu();return u.default.createElement("ul",{ref:function(t){return e.element=t},className:t,role:this.props.root?"menubar":"menu","aria-orientation":"horizontal"},i)}}]),s}(t.Component);function D(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}E(L,"defaultProps",{model:null,root:!1,className:null,popup:!1,onLeafClick:null,onKeyDown:null,parentActive:!1});var I=function(e){v(a,e);var t,i,l=(t=a,i=D(),function(){var e,n=k(t);if(i){var r=k(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return b(this,e)});function a(e){var t;return p(this,a),(t=l.call(this,e)).state={visible:!e.popup},t.onEnter=t.onEnter.bind(f(t)),t.onEntered=t.onEntered.bind(f(t)),t.onExit=t.onExit.bind(f(t)),t.onExited=t.onExited.bind(f(t)),t.onPanelClick=t.onPanelClick.bind(f(t)),t.menuRef=u.default.createRef(),t}return d(a,[{key:"onPanelClick",value:function(e){this.props.popup&&o.OverlayService.emit("overlay-click",{originalEvent:e,target:this.target})}},{key:"toggle",value:function(e){this.props.popup&&(this.state.visible?this.hide(e):this.show(e))}},{key:"show",value:function(e){var t=this;this.target=e.currentTarget;var n=e;this.setState({visible:!0},(function(){t.props.onShow&&t.props.onShow(n)}))}},{key:"hide",value:function(e){var t=this,n=e;this.setState({visible:!1},(function(){t.props.onHide&&t.props.onHide(n)}))}},{key:"onEnter",value:function(){this.props.autoZIndex&&n.ZIndexUtils.set("menu",this.menuRef.current,c.default.autoZIndex,this.props.baseZIndex||c.default.zIndex.menu),n.DomHandler.absolutePosition(this.menuRef.current,this.target)}},{key:"onEntered",value:function(){this.bindDocumentListeners(),this.bindScrollListener()}},{key:"onExit",value:function(){this.target=null,this.unbindDocumentListeners(),this.unbindScrollListener()}},{key:"onExited",value:function(){n.ZIndexUtils.clear(this.menuRef.current)}},{key:"bindDocumentListeners",value:function(){this.bindDocumentClickListener(),this.bindDocumentResizeListener()}},{key:"unbindDocumentListeners",value:function(){this.unbindDocumentClickListener(),this.unbindDocumentResizeListener()}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.props.popup&&e.state.visible&&e.menuRef.current&&!e.menuRef.current.contains(t.target)&&e.hide(t)},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindDocumentResizeListener",value:function(){var e=this;this.documentResizeListener||(this.documentResizeListener=function(t){e.state.visible&&!n.DomHandler.isTouchDevice()&&e.hide(t)},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentResizeListener",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new n.ConnectedOverlayScrollHandler(this.target,(function(t){e.state.visible&&e.hide(t)}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"componentWillUnmount",value:function(){this.unbindDocumentListeners(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),n.ZIndexUtils.clear(this.menuRef.current)}},{key:"renderElement",value:function(){var e=n.classNames("p-tieredmenu p-component",{"p-tieredmenu-overlay":this.props.popup},this.props.className);return u.default.createElement(r.CSSTransition,{nodeRef:this.menuRef,classNames:"p-connected-overlay",in:this.state.visible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onEnter,onEntered:this.onEntered,onExit:this.onExit,onExited:this.onExited},u.default.createElement("div",{ref:this.menuRef,id:this.props.id,className:e,style:this.props.style,onClick:this.onPanelClick},u.default.createElement(L,{model:this.props.model,root:!0,popup:this.props.popup})))}},{key:"render",value:function(){var e=this.renderElement();return this.props.popup?u.default.createElement(s.Portal,{element:e,appendTo:this.props.appendTo}):e}}]),a}(t.Component);return E(I,"defaultProps",{id:null,model:null,popup:!1,style:null,className:null,autoZIndex:!0,baseZIndex:0,appendTo:null,transitionOptions:null,onShow:null,onHide:null}),e.TieredMenu=I,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple,primereact.csstransition,primereact.overlayservice,primereact.portal,primereact.api);