Liferay.Loader.define("data-engine-taglib@3.3.50/data_layout_builder/js/components/sidebar/MultiPanelSidebar.es",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/loading-indicator","@frontend-taglib-clay$clayui/tooltip","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../../hooks/useLoad.es","./MultiPanelSidebar.scss"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function MultiPanelSidebar({createPlugin:t,currentPanelId:a,onChange:f,open:b,panels:p,sidebarPanels:y,variant:m="dark"}){const[g,h]=(0,d.useStateSafe)(!1),E=(0,d.useIsMounted)(),P=(0,u.default)(),v=(0,c.useRef)(y),[_,I]=(0,c.useState)([]);(0,c.useEffect)((()=>{const e=Object.values(v.current).map((e=>P(e.sidebarPanelId,e.pluginEntryPoint).then((a=>{const r=new a(t({panel:e,sidebarOpen:!0,sidebarPanelId:e.sidebarPanelId}),e);return{Component:()=>r.renderSidebar(),sidebarPanelId:e.sidebarPanelId}})).catch((e=>console.error(e)))));I([]),Promise.all(e).then((e=>{E()&&I(e)}))}),[E,P]),(0,c.useEffect)((()=>{const e=Liferay.SideNavigation.instance(document.querySelector(".product-menu-toggle"));if(e){b&&e.hide();const t=e.on("openStart.lexicon.sidenav",(()=>f({sidebarOpen:!1})));return()=>t.removeListener()}}),[f,b]);return c.default.createElement(i.ClayTooltipProvider,null,c.default.createElement("div",{className:(0,o.default)("multi-panel-sidebar","multi-panel-sidebar-".concat(m),{"menu-indicator-enabled":document.querySelector(e.join(","))})},c.default.createElement("nav",{className:(0,o.default)("multi-panel-sidebar-buttons","tbar","tbar-stacked","dark"===m?"tbar-".concat(m,"-d1"):"tbar-".concat(m))},c.default.createElement("ul",{className:"tbar-nav"},p.reduce(((e,t,l)=>{const i=t.map(((e,t)=>{const l=y[e],i=b&&a===e,{icon:d,isLink:u,label:p,pluginEntryPoint:m,url:g}=l,prefetch=()=>P(l.sidebarPanelId,m).then(...s),h=(0,o.default)("tbar-btn tbar-btn-monospaced",{active:i});return c.default.createElement("li",{className:(0,o.default)("tbar-item","tbar-item--".concat(l.sidebarPanelId)),key:l.sidebarPanelId},u?c.default.createElement("a",{className:h,href:g},c.default.createElement(n.default,{symbol:d})):c.default.createElement(r.ClayButtonWithIcon,{"aria-pressed":i,className:h,"data-tooltip-align":"left",displayType:"unstyled",id:l.sidebarPanelId,onClick:()=>(({sidebarPanelId:e})=>f({sidebarOpen:e!==a||!b,sidebarPanelId:e}))(l),onFocus:prefetch,onMouseEnter:prefetch,symbol:d,tabIndex:0===t?"0":"-1",title:p}))}));return l===p.length-1?e.concat(i):e.concat([...i,c.default.createElement("hr",{key:"separator-".concat(l)})])}),[]))),c.default.createElement("div",{"aria-label":Liferay.Language.get("sidebar"),className:(0,o.default)("multi-panel-sidebar-content",{"multi-panel-sidebar-content-open":b})},g?c.default.createElement("div",null,c.default.createElement(r.default,{block:!0,displayType:"secondary",onClick:()=>{f({sidebarOpen:!1}),h(!1)},small:!0},Liferay.Language.get("refresh"))):c.default.createElement(ErrorBoundary,{handleError:()=>{h(!0)}},!_.length&&c.default.createElement(l.default,null),_.map((e=>c.default.createElement("div",{className:(0,o.default)({"d-none":e.sidebarPanelId!==a}),key:e.sidebarPanelId},c.default.createElement(e.Component,null))))))))};var r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/button")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/loading-indicator")),i=a("@frontend-taglib-clay$clayui/tooltip"),d=a("@liferay/frontend-js-react-web"),o=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),c=_interopRequireWildcard(a("liferay!frontend-js-react-web$react")),u=_interopRequireDefault(a("../../hooks/useLoad.es"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}return a.default=e,t&&t.set(e,a),a}a("./MultiPanelSidebar.scss");const e=[".change-tracking-indicator",".staging-indicator"],s=[e=>e,e=>{}];class ErrorBoundary extends c.default.Component{static getDerivedStateFromError(e){return{hasError:!0}}constructor(e){super(e),this.state={hasError:!1}}componentDidCatch(e){this.props.handleError&&this.props.handleError(e)}render(){return this.state.hasError?null:this.props.children}}}}));
//# sourceMappingURL=MultiPanelSidebar.es.js.map