Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.130/page_editor/app/thunks/deleteItem",["module","exports","require","frontend-js-web","../actions/deleteItem","../actions/updatePageContents","../config/constants/freemarkerFragmentEntryProcessor","../config/constants/layoutDataItemTypes","../selectors/selectEditableValue","../selectors/selectFormConfiguration","../services/FormService","../services/InfoItemService","../services/LayoutService","../utils/cache","../utils/getFormErrorDescription","../utils/getFragmentEntryLinkIdsFromItemId","../utils/hasFormParent","../utils/isRequiredFormInput"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({itemId:e,selectItem:t=(()=>{})}){return(r,E)=>{const{fragmentEntryLinks:F,layoutData:O,segmentsExperienceId:_}=E();return function({fragmentEntryLinks:e,itemId:t,layoutData:r,onNetworkStatus:n,segmentsExperienceId:o}){const s=P(t,r,e);return m.default.markItemForDeletion({itemId:t,onNetworkStatus:n,portletIds:s,segmentsExperienceId:o}).then((e=>b(b({},e),{},{portletIds:s})))}({fragmentEntryLinks:F,itemId:e,layoutData:O,onNetworkStatus:r,segmentsExperienceId:_}).then((({portletIds:s=[],layoutData:d})=>{t(null);const m=(0,g.default)({itemId:e,layoutData:d});r((0,o.default)({fragmentEntryLinkIds:m,itemId:e,layoutData:d,portletIds:s})),function(e,t,r){var o;const s=null==e||null===(o=e.items)||void 0===o?void 0:o[t];if(!s||s.type!==i.LAYOUT_DATA_ITEM_TYPES.fragment||!(0,I.hasFormParent)(s,e))return null;const{classNameId:d,classTypeId:m}=(0,l.default)(s,e),g=(0,f.getCacheKey)([f.CACHE_KEYS.formFields,d,m]),{data:E}=(0,f.getCacheItem)(g);(E?Promise.resolve(E):u.default.getFormFields({classNameId:d,classTypeId:m})).then((e=>{if(s.type===i.LAYOUT_DATA_ITEM_TYPES.fragment&&(0,y.isRequiredFormInput)(s,r,e)){const t=(0,c.default)({fragmentEntryLinks:r},s.config.fragmentEntryLinkId,"inputFieldId",a.FREEMARKER_FRAGMENT_ENTRY_PROCESSOR),{message:o}=(0,p.getFormErrorDescription)({name:v(t,e),type:p.FORM_ERROR_TYPES.deletedFragment});(0,n.openToast)({message:o,type:"warning"})}}))}(O,e,F)})).then((()=>{d.default.getPageContents({onNetworkStatus:r,segmentsExperienceId:_}).then((e=>{r((0,s.default)({pageContents:e}))}))}))}};var n=r("frontend-js-web"),o=E(r("../actions/deleteItem")),s=E(r("../actions/updatePageContents")),a=r("../config/constants/freemarkerFragmentEntryProcessor"),i=r("../config/constants/layoutDataItemTypes"),c=E(r("../selectors/selectEditableValue")),l=E(r("../selectors/selectFormConfiguration")),u=E(r("../services/FormService")),d=E(r("../services/InfoItemService")),m=E(r("../services/LayoutService")),f=r("../utils/cache"),p=r("../utils/getFormErrorDescription"),g=E(r("../utils/getFragmentEntryLinkIdsFromItemId")),I=r("../utils/hasFormParent"),y=r("../utils/isRequiredFormInput");function E(e){return e&&e.__esModule?e:{default:e}}function F(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 b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){O(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function P(e,t,r){const n=t.items[e],{config:o={},children:s=[]}=n;if(n.type===i.LAYOUT_DATA_ITEM_TYPES.fragment&&o.fragmentEntryLinkId){const{editableValues:e={}}=r[o.fragmentEntryLinkId];if(e.portletId)return[e.instanceId?"".concat(e.portletId,"_INSTANCE_").concat(e.instanceId):e.portletId]}const a=[];return s.forEach((e=>{a.push(...P(e,t,r))})),a}function v(e,t){return t.flatMap((e=>e.fields)).find((t=>t.key===e)).label}}}));
//# sourceMappingURL=deleteItem.js.map