Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/components/fragment-content/FragmentContentProcessor",["module","exports","require","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../contexts/CollectionItemContext","../../contexts/EditableProcessorContext","../../contexts/StoreContext","../../selectors/selectLanguageId","../../thunks/updateEditableValues"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=b;var n=u(r("liferay!frontend-js-react-web$prop-types")),o=r("liferay!frontend-js-react-web$react"),a=r("../../contexts/CollectionItemContext"),s=r("../../contexts/EditableProcessorContext"),i=r("../../contexts/StoreContext"),l=u(r("../../selectors/selectLanguageId")),c=u(r("../../thunks/updateEditableValues"));function u(e){return e&&e.__esModule?e:{default:e}}function d(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 f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){p(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b({editables:e,fragmentEntryLinkId:t}){const r=(0,i.useDispatch)(),n=(0,s.useEditableProcessorClickPosition)(),u=(0,s.useEditableProcessorUniqueId)(),d=(0,i.useSelector)(l.default),p=(0,s.useSetEditableProcessorUniqueId)(),b=(0,a.useToControlsId)(),y=e.find((e=>u===b(e.itemId))),g=b(y?y.itemId:""),m=(0,i.useSelectorCallback)((e=>e.fragmentEntryLinks[t]&&e.fragmentEntryLinks[t].editableValues),[t]);return(0,o.useEffect)((()=>{if(!y||!m||g!==u)return;const e=m[y.editableValueNamespace][y.editableId];y.processor.createEditor(y.element,((n,o={})=>{var a,s;const i=null!==(a=null===(s=e.defaultValue)||void 0===s?void 0:s.replace(/\s+/g," ").trim())&&void 0!==a?a:"",l=e[d];if(l===n||!l&&n===i)return Promise.resolve();const u=f(f({},e.config||{}),o);return r((0,c.default)({editableValues:f(f({},m),{},{[y.editableValueNamespace]:f(f({},m[y.editableValueNamespace]),{},{[y.editableId]:f(f({},e),{},{config:u,[d]:n})})}),fragmentEntryLinkId:t}))}),(()=>{g===u&&p(null),y.processor.destroyEditor(y.element,e.config)}),n,e[d]||e.defaultValue||"")}),[r,y,g,n,u,m,t,d,p]),null}b.propTypes={fragmentEntryLinkId:n.default.string.isRequired}}}));
//# sourceMappingURL=FragmentContentProcessor.js.map