Liferay.Loader.define("data-engine-js-components-web@1.0.55/js/custom/form/reducers/pageReducer.es",["module","exports","require","../../../utils/FormSupport.es","../../../utils/formId.es","../eventTypes.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,r){switch(r.type){case o.EVENT_TYPES.SUCCESS_PAGE:{const{defaultLanguageId:e,pages:n,paginationMode:o}=t,{enabled:i}=r.payload,s=n[n.length-1];let c=n.filter((({contentRenderer:e})=>"success"!==e));if(i){const t="success"===s.contentRenderer?s:{id:(0,a.getUid)()};c=[...c,l(l({},t),{},{contentRenderer:"success",defaultLanguageId:e,paginationItemRenderer:"".concat(o,"_success"),rows:[],successPageSettings:r.payload})]}return{pages:c,successPageSettings:r.payload}}case o.EVENT_TYPES.PAGE.ADD:{const{pageIndex:o}=r.payload,{editingLanguageId:i,pages:s}=t;return{activePage:o+1,pages:[...s.slice(0,o+1),l(l({description:"",enabled:!0,headerRenderer:"editable",id:(0,a.getUid)(),rows:[n.implAddRow(12,[])],showRequiredFieldsWarning:!0,title:""},e(i,"title","")),e(i,"description","")),...s.slice(o+1)]}}case o.EVENT_TYPES.PAGE.DELETE:{const{pages:e}=t,{pageIndex:n}=r.payload;return{activePage:Math.max(0,n-1),pages:e.filter(((e,t)=>t!==n))}}case o.EVENT_TYPES.PAGE.RESET:{const{pageIndex:a}=r.payload,{editingLanguageId:o,pages:i}=t;return i[a]=l(l(l({},i[a]),{},{description:"",enabled:!0,rows:[n.implAddRow(12,[])],showRequiredFieldsWarning:!0,title:""},e(o,"title","")),e(o,"description","")),{pages:[...i]}}case o.EVENT_TYPES.PAGE.SWAP:{const{pages:e}=t,{firstIndex:n,secondIndex:a}=r.payload,[o,i]=[e[n],e[a]];return{pages:e.map(((e,t)=>t===n?i:t===a?o:e))}}case o.EVENT_TYPES.PAGE.TITLE_CHANGE:{const{pageIndex:e,value:n}=r.payload,{editingLanguageId:a,pages:o}=t,i=o[e],{localizedTitle:c}=i,p=s(i,["localizedTitle"]);return o[e]=l(l({},p),{},{localizedTitle:l(l({},c),{},{[a]:n}),title:n}),{pages:[...o]}}case o.EVENT_TYPES.PAGE.DESCRIPTION_CHANGE:{const{pageIndex:e,value:n}=r.payload,{editingLanguageId:a,pages:o}=t,i=o[e],{localizedDescription:c}=i,p=s(i,["localizedDescription"]);return o[e]=l(l({},p),{},{description:n,localizedDescription:l(l({},c),{},{[a]:n})}),{pages:[...o]}}default:return t}};var n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("../../../utils/FormSupport.es")),a=r("../../../utils/formId.es"),o=r("../eventTypes.es");function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function s(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function c(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 l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){p(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(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}const e=(e,t,r)=>({["localized".concat(t.replace(/^\w/,(e=>e.toUpperCase())))]:{[e]:r}})}}));
//# sourceMappingURL=pageReducer.es.js.map