Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.145/Validation/transform",["module","exports","require"],(function(e,t,r){window;{function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeDataType=normalizeDataType,t.getLocalizedValue=function getLocalizedValue({defaultLanguageId:e,editingLanguageId:t}){return r=>{var a;return null!==(a=r[t])&&void 0!==a?a:r[e]}},t.getSelectedValidation=function getSelectedValidation(e){return function transformSelectedValidation(t){Array.isArray(t)&&(t=t[0]);let r=e.find((({name:e})=>e===t));return r||(r=e[0]),r}},t.transformData=function transformData({defaultLanguageId:e,editingLanguageId:t,initialDataType:r,validation:a,validations:n,value:o}){var i;const l=null!==(i=null==a?void 0:a.dataType)&&void 0!==i?i:r,c=transformValidations(n,l);return _objectSpread(_objectSpread({},getValidation(c,a,o)),{},{dataType:l,localizationMode:t!==e,validations:c})};const getValidationFromExpression=(e,t,r)=>{let a;return!r&&t&&(r=t.expression),r&&(a=e.find((e=>e.name===r.name))),a},transformValidations=(e,t)=>e[normalizeDataType(t)].map((e=>_objectSpread(_objectSpread({},e),{},{checked:!1,value:e.name}))),getValidation=(e,t,r)=>{const{errorMessage:a={},expression:n={},parameter:o={}}=r;let i="",l=getValidationFromExpression(e,t,n);const c=!!n.value;return l?i=l.parameterMessage:l=e[0],{enableValidation:c,errorMessage:a,expression:n,parameter:o,parameterMessage:i,selectedValidation:l}};function normalizeDataType(e){return"double"===e||"integer"===e?"numeric":e}}}));
//# sourceMappingURL=transform.js.map