Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/plugins/page_content/components/ContentsSidebar",["module","exports","require","liferay!frontend-js-react-web$react","../../../app/config/constants/editableFragmentEntryProcessor","../../../app/config/constants/editableTypes","../../../app/contexts/StoreContext","../../../app/selectors/selectLanguageId","../../../app/selectors/selectPageContents","../../../app/utils/editable_value/isMapped","../../../app/utils/getEditableLocalizedValue","../../../app/utils/getFragmentItem","../../../app/utils/hasRestrictedParent","../../../common/components/SidebarPanelHeader","./NoPageContents","./PageContents"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function ContentsSidebar(){const e=(0,i.useSelector)((e=>e.fragmentEntryLinks)),t=(0,i.useSelector)(l.default),r=(0,i.useSelector)((e=>e.layoutData)),a=(0,i.useSelector)(c.selectPageContents),o=(0,i.useSelector)((e=>e.restrictedItemIds)),u=(0,i.useSelector)((e=>e.segmentsExperienceId)),p=(0,n.useMemo)((()=>getEditableValues(e,u,r,o).map((e=>normalizeEditableValues(e,t))).filter((e=>e.title))),[e,t,o,u,r]),s=_objectSpread(_objectSpread({},normalizePageContents(a)),p.length&&{[Liferay.Language.get("inline-text")]:p}),d=Object.keys(s).length?n.default.createElement(b.default,{pageContents:s}):n.default.createElement(g.default,null);return n.default.createElement(n.default.Fragment,null,n.default.createElement(f.default,null,Liferay.Language.get("page-content")),n.default.createElement("div",{className:"d-flex flex-column page-editor__page-contents"},d))};var n=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 r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),a=r("../../../app/config/constants/editableFragmentEntryProcessor"),o=r("../../../app/config/constants/editableTypes"),i=r("../../../app/contexts/StoreContext"),l=_interopRequireDefault(r("../../../app/selectors/selectLanguageId")),c=r("../../../app/selectors/selectPageContents"),u=_interopRequireDefault(r("../../../app/utils/editable_value/isMapped")),p=r("../../../app/utils/getEditableLocalizedValue"),s=_interopRequireDefault(r("../../../app/utils/getFragmentItem")),d=r("../../../app/utils/hasRestrictedParent"),f=_interopRequireDefault(r("../../../common/components/SidebarPanelHeader")),g=_interopRequireDefault(r("./NoPageContents")),b=_interopRequireDefault(r("./PageContents"));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 ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}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 getEditableTitle=(e,t)=>{const r=document.createElement("div");return r.innerHTML=(0,p.getEditableLocalizedValue)(e,t),r.textContent.trim()},getEditableValues=(e,t,r,n)=>Object.values(e).filter((e=>{if(Liferay.FeatureFlags["LPS-169923"]){const t=(0,s.default)(r,e.fragmentEntryLinkId);if(t&&(0,d.hasRestrictedParent)(t,r,n))return}return!e.masterLayout&&e.editableValues&&!e.removed&&e.segmentsExperienceId===t})).map((e=>{var t;return Object.entries(null!==(t=e.editableValues[a.EDITABLE_FRAGMENT_ENTRY_PROCESSOR])&&void 0!==t?t:{}).filter((([t,r])=>(e.editableTypes[t]===o.EDITABLE_TYPES.text||e.editableTypes[t]===o.EDITABLE_TYPES["rich-text"])&&!(0,u.default)(r))).map((([t,r])=>_objectSpread(_objectSpread({},r),{},{editableId:"".concat(e.fragmentEntryLinkId,"-").concat(t),type:e.editableTypes[t]})))})).reduce(((e,t)=>[...e,...t]),[]),normalizeEditableValues=(e,t)=>_objectSpread(_objectSpread({},e),{},{icon:"align-left",title:getEditableTitle(e,t)}),normalizePageContents=e=>e.reduce(((e,t)=>e[t.type]?_objectSpread(_objectSpread({},e),{},{[t.type]:[...e[t.type],t]}):_objectSpread(_objectSpread({},e),{},{[t.type]:[t]})),{})}}));
//# sourceMappingURL=ContentsSidebar.js.map