Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/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=FragmentContentProcessor;var o=_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),n=r("liferay!frontend-js-react-web$react"),a=r("../../contexts/CollectionItemContext"),s=r("../../contexts/EditableProcessorContext"),i=r("../../contexts/StoreContext"),c=_interopRequireDefault(r("../../selectors/selectLanguageId")),l=_interopRequireDefault(r("../../thunks/updateEditableValues"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}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}function FragmentContentProcessor({editables:e,fragmentEntryLinkId:t}){const r=(0,i.useDispatch)(),o=(0,s.useEditableProcessorClickPosition)(),u=(0,s.useEditableProcessorUniqueId)(),d=(0,i.useSelector)(c.default),f=(0,s.useSetEditableProcessorUniqueId)(),p=(0,a.useToControlsId)(),b=e.find((e=>u===p(e.itemId))),y=p(b?b.itemId:""),g=(0,i.useSelectorCallback)((e=>e.fragmentEntryLinks[t]&&e.fragmentEntryLinks[t].editableValues),[t]);return(0,n.useEffect)((()=>{if(!b||!g||y!==u)return;const e=g[b.editableValueNamespace][b.editableId];b.processor.createEditor(b.element,((o,n={})=>{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:"",c=e[d];if(c===o||!c&&o===i)return Promise.resolve();const u=_objectSpread(_objectSpread({},e.config||{}),n);return r((0,l.default)({editableValues:_objectSpread(_objectSpread({},g),{},{[b.editableValueNamespace]:_objectSpread(_objectSpread({},g[b.editableValueNamespace]),{},{[b.editableId]:_objectSpread(_objectSpread({},e),{},{config:u,[d]:o})})}),fragmentEntryLinkId:t}))}),(()=>{y===u&&f(null),b.processor.destroyEditor(b.element,e.config)}),o)}),[r,b,y,o,u,g,t,d,f]),null}FragmentContentProcessor.propTypes={fragmentEntryLinkId:o.default.string.isRequired}}}));
//# sourceMappingURL=FragmentContentProcessor.js.map