Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.130/page_editor/app/components/MasterLayout",["module","exports","require","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../prop-types/index","../config/constants/layoutDataItemTypes","../contexts/ControlsContext","../contexts/StoreContext","./Layout","./fragment-content/FragmentContent","./layout-data-items/index"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){const e=(0,u.useSelector)((e=>e.fragmentEntryLinks)),t=(0,u.useSelector)((e=>{var t;return null===(t=e.masterLayout)||void 0===t?void 0:t.masterLayoutData})),n=t.items[t.rootItems.main];return a.default.createElement("div",{className:"master-page"},a.default.createElement(p,{fragmentEntryLinks:e,item:n,layoutData:t}))};var r=m(n("liferay!frontend-js-react-web$classnames")),a=(m(n("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=r?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=e[a]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react"))),o=(n("../../prop-types/index"),n("../config/constants/layoutDataItemTypes")),l=n("../contexts/ControlsContext"),u=n("../contexts/StoreContext"),c=m(n("./Layout")),i=m(n("./fragment-content/FragmentContent")),s=n("./layout-data-items/index");function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function m(e){return e&&e.__esModule?e:{default:e}}function d(){return(d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function y(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}const e={[o.LAYOUT_DATA_ITEM_TYPES.collection]:s.Collection,[o.LAYOUT_DATA_ITEM_TYPES.collectionItem]:function({children:e}){return a.default.createElement("div",null,e)},[o.LAYOUT_DATA_ITEM_TYPES.column]:function(e){let{children:t,className:n}=e,o=y(e,["children","className"]);return a.default.createElement(s.Column,d({},o,{className:(0,r.default)(n,"page-editor__col--master")}),t)},[o.LAYOUT_DATA_ITEM_TYPES.container]:s.Container,[o.LAYOUT_DATA_ITEM_TYPES.form]:s.Form,[o.LAYOUT_DATA_ITEM_TYPES.dropZone]:function(){const e=(0,u.useSelector)((e=>e.layoutData.rootItems.main));return a.default.createElement(c.default,{mainItemId:e,withinMasterPage:!0})},[o.LAYOUT_DATA_ITEM_TYPES.fragment]:function({item:e}){const t=(0,a.useRef)(null),n=(0,l.useSelectItem)();(0,a.useEffect)((()=>{const e=t.current;if(!e)return;const r=e=>{e.target.closest("[href]")&&e.preventDefault(),e.target.closest(".page-editor")||n(null)};return e.addEventListener("click",r),()=>{e.removeEventListener("click",r)}}));const r=(0,u.useSelector)((e=>e.fragmentEntryLinks)),o=(0,u.useSelector)((e=>{var t;return null===(t=e.masterLayout)||void 0===t?void 0:t.masterLayoutData})),c=(0,a.useCallback)((e=>Array.from(e.querySelectorAll("lfr-drop-zone")).map((e=>{const t=e.getAttribute("uuid")||"",n=()=>t?a.default.createElement(p,{fragmentEntryLinks:r,item:o.items[t],layoutData:o}):null;return n.displayName="DropZone(".concat(t,")"),{Component:n,element:e}}))),[r,o]);return a.default.createElement(i.default,{className:"page-editor__fragment-content--master",elementRef:t,fragmentEntryLinkId:e.config.fragmentEntryLinkId,getPortals:c,item:e})},[o.LAYOUT_DATA_ITEM_TYPES.fragmentDropZone]:E,[o.LAYOUT_DATA_ITEM_TYPES.root]:E,[o.LAYOUT_DATA_ITEM_TYPES.row]:s.Row};function p({fragmentEntryLinks:t,item:n,layoutData:r}){const o=e[n.type];return o?a.default.createElement(o,{fragmentEntryLinks:t,item:n,layoutData:r},n.children.map((e=>a.default.createElement(p,{fragmentEntryLinks:t,item:r.items[e],key:e,layoutData:r})))):null}function E({children:e}){return a.default.createElement("div",null,e)}}}));
//# sourceMappingURL=MasterLayout.js.map