Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.145/page_editor/app/reducers/widgetsReducer",["module","exports","require","../actions/types"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function widgetsReducer(t=null,r){switch(r.type){case o.TOGGLE_WIDGET_HIGHLIGHTED:{const{highlighted:o,highlightedPortlets:i,portletId:a}=r,c=t.reduce(((t,r)=>(r.path!==e&&t.push(_objectSpread(_objectSpread({},r),{},{portlets:r.portlets.map((e=>e.portletId===a?_objectSpread(_objectSpread({},e),{},{highlighted:o}):e))})),t)),[]);return i.length&&c.unshift(_objectSpread(_objectSpread({},n),{},{portlets:i})),c}case o.UPDATE_WIDGETS:return normalizeCategories(r.widgets||t,r.fragmentEntryLinks);default:return t}};var o=r("../actions/types");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e="root--category-highlighted",n={categories:[],path:e,portlets:[],title:Liferay.Language.get("highlighted")};function normalizePortlets(e,t){return e.map((e=>{var r;const o=_objectSpread(_objectSpread({},e),{},{used:t.has(e.portletId)});return(null===(r=e.portletItems)||void 0===r?void 0:r.length)&&(o.portletItems=normalizePortlets(e.portletItems,t)),o}))}function normalizeCategories(e,t){return e?e.map((e=>{var r;const o=new Set(Array.from(t).map((({portletId:e})=>e))),n=_objectSpread(_objectSpread({},e),{},{portlets:normalizePortlets(e.portlets,o)});return(null===(r=e.categories)||void 0===r?void 0:r.length)&&(n.categories=normalizeCategories(e.categories,o)),n})):null}}}));
//# sourceMappingURL=widgetsReducer.js.map