Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.130/page_editor/app/components/layout-data-items/FragmentWithControls",["module","exports","require","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../../../core/hooks/useSetRef","../../../prop-types/index","../../config/constants/freemarkerFragmentEntryProcessor","../../contexts/ControlsContext","../../contexts/StoreContext","../../utils/getLayoutDataItemTopperUniqueClassName","../../utils/hasInnerCustomStyles","../fragment-content/FragmentContent","../topper/Topper","./getAllPortals","./isHovered"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=g(r("liferay!frontend-js-react-web$classnames")),o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=y();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=n?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),a=g(r("../../../core/hooks/useSetRef")),l=(r("../../../prop-types/index"),r("../../config/constants/freemarkerFragmentEntryProcessor")),s=r("../../contexts/ControlsContext"),i=r("../../contexts/StoreContext"),u=g(r("../../utils/getLayoutDataItemTopperUniqueClassName")),f=g(r("../../utils/hasInnerCustomStyles")),d=g(r("../fragment-content/FragmentContent")),c=g(r("../topper/Topper")),m=g(r("./getAllPortals")),p=g(r("./isHovered"));function y(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return y=function(){return e},e}function g(e){return e&&e.__esModule?e:{default:e}}const e=["itemSelector","collectionSelector"],E=o.default.forwardRef((({item:e},t)=>{const[r,l]=(0,o.useState)(!1),s=(0,i.useSelectorCallback)((t=>t.fragmentEntryLinks[e.config.fragmentEntryLinkId]),[e.config.fragmentEntryLinkId]),p=(0,o.useCallback)((e=>(0,m.default)(e)),[]),[y,g]=(0,a.default)(t);return o.default.createElement(o.default.Fragment,null,o.default.createElement(b,{fragmentEntryLink:s,hovered:r,setHovered:l}),o.default.createElement(c.default,{className:(0,n.default)({[(0,u.default)(e.itemId)]:!(0,f.default)(s),"page-editor__topper--hovered":r}),item:e,itemElement:g},o.default.createElement(d.default,{computeEditables:!0,elementRef:y,fragmentEntryLinkId:e.config.fragmentEntryLinkId,getPortals:p,item:e})))}));E.displayName="FragmentWithControls";var v=E;t.default=v;const b=({fragmentEntryLink:t,hovered:r,setHovered:n})=>{const a=(0,s.useHoveredItemType)(),i=(0,s.useHoveredItemId)(),u=(0,o.useMemo)((()=>{const r=[];if(t){var n,o;null===(n=t.configuration)||void 0===n||null===(o=n.fieldSets)||void 0===o||o.forEach((t=>{t.fields.forEach((t=>{e.includes(t.type)&&r.push(t.name)}))}));return r.filter((e=>{var r,n;return null===(r=t.editableValues[l.FREEMARKER_FRAGMENT_ENTRY_PROCESSOR])||void 0===r||null===(n=r[e])||void 0===n?void 0:n.classPK})).map((e=>{var r;return(null===(r=t.editableValues[l.FREEMARKER_FRAGMENT_ENTRY_PROCESSOR])||void 0===r?void 0:r[e])||{}}))}}),[t]);return(0,o.useEffect)((()=>{if(u.length){const e=u.some((e=>(0,p.default)({editableValue:e,hoveredItemId:i,hoveredItemType:a})));r!==e&&n(e)}}),[a,i,u,n,r]),null}}}));
//# sourceMappingURL=FragmentWithControls.js.map