Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/services/serviceFetch",["module","exports","require","frontend-js-web","../actions/index","../config/constants/serviceNetworkStatusTypes","../config/index"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t={body:{}},r,{requestGenerateDraft:a=!1}={requestGenerateDraft:!1}){let{body:i={},method:s}=t,d=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(t,["body","method"]);a&&r((0,o.updateNetwork)({status:c.SERVICE_NETWORK_STATUS_TYPES.savingDraft}));return(0,n.fetch)(e,u(u({},d),{},{body:f(i),method:s||"POST"})).then((e=>new Promise(((t,r)=>{e.clone().json().then((r=>t([e,r]))).catch((()=>e.clone().text())).then((r=>t([e,r]))).catch(r)})))).then((([e,t])=>"object"!=typeof t||"exception"in t?p(Liferay.Language.get("an-unexpected-error-occurred"),r):"error"in t?p(Liferay.Language.get(t.error),r):e.status>=400?p(Liferay.Language.get("an-unexpected-error-occurred"),r):(a&&r((0,o.updateNetwork)({error:null,status:c.SERVICE_NETWORK_STATUS_TYPES.draftSaved})),t)))};var n=r("frontend-js-web"),o=r("../actions/index"),c=r("../config/constants/serviceNetworkStatusTypes"),a=r("../config/index");function i(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 u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){const t=new FormData;return Object.entries(e).forEach((([e,r])=>{t.append("".concat(a.config.portletNamespace).concat(e),r)})),t}function p(e,t){return t((0,o.updateNetwork)({error:e,status:c.SERVICE_NETWORK_STATUS_TYPES.error})),Promise.reject(e)}}}));
//# sourceMappingURL=serviceFetch.js.map