Liferay.Loader.define("data-engine-js-components-web@1.0.75/js/utils/settingsContext",["module","exports","require","../core/utils/fields","./fieldSupport","./fields.es","./visitors.es"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getSettingsContextProperty=function(e,t,n="value"){let i;return new o.PagesVisitor(e.pages).mapFields((e=>{t===e.fieldName&&(i=e[n])})),i},t.setFieldReferenceErrorMessage=u,t.updateSettingsContextProperty=p,t.updateSettingsContextInstanceId=function({settingsContext:e}){const t=new o.PagesVisitor(e.pages);return l(l({},e),{},{pages:t.mapFields((e=>l(l({},e),{},{instanceId:(0,a.generateInstanceId)()})))})},t.updateFieldName=c,t.updateFieldReference=function(e,t=!1,n=!1){const{settingsContext:i}=e;return e=l(l({},e),{},{settingsContext:u(i,"fieldReference",t,n)})},t.updateFieldDataType=f,t.updateFieldLabel=g,t.updateFieldProperty=b,t.updateFieldOptions=m,t.updateField=function({defaultLanguageId:e,editingLanguageId:t,fieldNameGenerator:n,generateFieldNameUsingFieldLabel:i},a,r,o){a=l(l({},a),"dataType"===r?f(e,t,a,o):"label"===r?g(e,t,n,a,i,o):"name"===r?c(e,t,n,a,o):"numericInputMask"===r?o:"options"===r?m(e,t,a,o):b(e,t,a,r,o));return a};var i=n("../core/utils/fields"),a=n("./fieldSupport"),r=n("./fields.es"),o=n("./visitors.es");function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t,n=!0,i=!1){const a=new o.PagesVisitor(e.pages);return l(l({},e),{},{pages:a.mapFields((e=>(t===e.fieldName&&(e=l(l({},e),{},{displayErrors:n,errorMessage:Liferay.Language.get("this-reference-is-already-being-used"),shouldUpdateValue:i,valid:!n})),e)))})}function p(e=themeDisplay.getDefaultLanguageId(),t,n,i,a){const r=new o.PagesVisitor(n.pages),s="label"===i&&"object"==typeof a;return l(l({},n),{},{pages:r.mapFields((n=>{if(i===n.fieldName){var r;let i=a;s&&(i=a[t]||a[e]),(n=l(l({},n),{},{value:i})).localizable&&s&&(n.localizedValue=l({},a)),n.localizedValue=l(l({},null!==(r=n.localizedValue)&&void 0!==r?r:{}),{},{[t]:i})}return n}))})}function c(e,t,n,o,s){const{fieldName:d}=o;let u;if(u=n(""!==(0,r.normalizeFieldName)(s)?s:(0,a.getDefaultFieldName)(),d),u){let{settingsContext:n}=o;n=l(l({},n),{},{pages:(0,i.updateFieldValidationProperty)(n.pages,d,"fieldName",u)}),o=l(l({},o),{},{fieldName:u,name:u,settingsContext:p(e,t,n,"name",u)})}return o}function f(e,t,n,a){let{settingsContext:r}=n;return r=l(l({},r),{},{pages:(0,i.updateFieldValidationProperty)(r.pages,n.fieldName,"dataType",a)}),l(l({},n),{},{dataType:a,settingsContext:p(e,t,r,"dataType",a)})}function g(e,t,n,i,a,r){let{fieldName:o,settingsContext:s}=i,d=r;if(a&&e===t){const a=c(e,t,n,i,r);o=a.fieldName,s=a.settingsContext}return"object"==typeof r&&(d=r[t]||r[e]),l(l({},i),{},{fieldName:o,label:d,settingsContext:p(e,t,s,"label",r)})}const e=({localizable:e,value:t})=>"object"==typeof t&&e,y=(t,n,i,a)=>e({localizable:t,value:n})&&void 0!==n[a]?n[a]:e({localizable:t,value:n})&&n[i]?n[i]:n;function b(e,t,n,i,a){return l(l({},n),{},{[i]:y(n.localizable,a,e,t),settingsContext:p(e,t,n.settingsContext,i,a)})}function m(e,t,n,i){const a=i[t];return l(l({},n),{},{options:a,settingsContext:p(e,t,n.settingsContext,"options",i)})}}}));
//# sourceMappingURL=settingsContext.js.map