Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/thunks/multipleUndo",["module","exports","require","../actions/index","../actions/types","../components/undo/undoActions","../config/constants/serviceNetworkStatusTypes","../config/constants/undoTypes","../reducers/index","./../components/undo/undoActions"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({numberOfActions:e,store:t,type:r}){return d=>{if(!t.undoHistory&&!t.redoHistory)return;let y,O,f,l,T=t;return r===c.UNDO_TYPES.undo?(y={isUndo:!0},f=t.undoHistory.slice(0,e),O=t.undoHistory.slice(e,t.undoHistory.length),l={type:n.UPDATE_UNDO_ACTIONS,undoHistory:O}):(y={isRedo:!0},f=t.redoHistory.slice(0,e),O=t.redoHistory.slice(e,t.redoHistory.length),l={redoHistory:O,type:n.UPDATE_REDO_ACTIONS}),d((0,o.updateNetwork)({status:s.SERVICE_NETWORK_STATUS_TYPES.savingDraft})),f.reduce(((e,t)=>e.then((()=>{return(0,i.undoAction)({action:t,store:T})((e=t.originalType||t.type,t=>{(0,a.canUndoAction)(t)&&(T=(0,u.reducer)(T,p(p({},t),{},{actionType:t.type,originalType:e,type:r===c.UNDO_TYPES.undo?n.ADD_REDO_ACTION:n.ADD_UNDO_ACTION})),T=(0,u.reducer)(T,p(p(p({},t),y),{},{originalType:e})))}),(()=>T));var e}))),Promise.resolve()).then((()=>{d((0,o.updateNetwork)({requestGenerateDraft:!1,status:s.SERVICE_NETWORK_STATUS_TYPES.draftSaved})),T=(0,u.reducer)(T,l),d({store:T,type:"UPDATE_STORE"})})).catch((e=>{d((0,o.updateNetwork)({error:Liferay.Language.get("an-unexpected-error-occurred"),status:s.SERVICE_NETWORK_STATUS_TYPES.error}))}))}};var o=r("../actions/index"),n=r("../actions/types"),i=r("../components/undo/undoActions"),s=r("../config/constants/serviceNetworkStatusTypes"),c=r("../config/constants/undoTypes"),u=r("../reducers/index"),a=r("./../components/undo/undoActions");function d(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 p(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){y(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 y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}}));
//# sourceMappingURL=multipleUndo.js.map