Liferay.Loader.define("data-engine-js-components-web@1.0.89/js/core/thunks/pageLanguageUpdate.es",["module","exports","require","frontend-js-web","../../utils/formatFieldValue.es","../../utils/setDataRecord.es","../../utils/visitors.es","../actions/eventTypes.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function pageLanguageUpdate({ddmStructureLayoutId:e,defaultLanguageId:t,nextEditingLanguageId:a,pages:n,portletNamespace:o,preserveValue:d,prevEditingLanguageId:u,readOnly:l}){return c=>{const p=getDataRecordValues({nextEditingLanguageId:a,pages:n,preserveValue:d,prevEditingLanguageId:u});(0,r.fetch)("/o/data-engine/v2.0/data-layouts/".concat(e,"/context"),{body:JSON.stringify({dataRecordValues:p,namespace:o,pathThemeImages:themeDisplay.getPathThemeImages(),readOnly:l,scopeGroupId:themeDisplay.getScopeGroupId(),siteGroupId:themeDisplay.getSiteGroupId()}),headers:{"Accept-Language":a.replace("_","-"),"Content-Type":"application/json"},method:"POST"}).then((e=>e.json())).then((e=>{const r=new i.PagesVisitor(e.pages).mapFields((e=>(e.localizedValue||(e.localizedValue={}),e.localizable||(e.localizedValue={[t]:e.value}),_objectSpread(_objectSpread(_objectSpread({},e),getFieldProperties(e.fieldName,n)),{},{editingLanguageId:a}))),!0,!0);c({payload:{defaultLanguageId:t,editingLanguageId:a,pages:r},type:s.EVENT_TYPES.LANGUAGE.CHANGE})}))}};var r=a("frontend-js-web"),n=_interopRequireDefault(a("../../utils/formatFieldValue.es")),o=_interopRequireDefault(a("../../utils/setDataRecord.es")),i=a("../../utils/visitors.es"),s=a("../actions/eventTypes.es");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const getDataRecordValues=({nextEditingLanguageId:e,pages:t,preserveValue:a,prevEditingLanguageId:r})=>{const s=new i.PagesVisitor(t),d={};return s.mapFields((t=>{(0,o.default)(_objectSpread(_objectSpread({},t),{},{value:(0,n.default)(t,a,e,r)}),d,a?e:r,a)}),!0,!0),d},getFieldProperties=(e,t)=>{const a=new i.PagesVisitor(t),{itemSelectorURL:r,locale:n,localizedValueEdited:o={[n]:!0}}=a.findField((t=>t.fieldName===e));return{itemSelectorURL:r,localizedValueEdited:o}}}}));
//# sourceMappingURL=pageLanguageUpdate.es.js.map