Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.145/Options/util.es",["module","exports","require","data-engine-js-components-web"],(function(e,r,n){window;{Object.defineProperty(r,"__esModule",{value:!0}),r.random=function random(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,random)},r.compose=function compose(...e){return e.reduceRight(((e,r)=>(...n)=>{const t=r(...n);return Array.isArray(t)?e(...t):e(t)}))},r.isOptionValueGenerated=function isOptionValueGenerated(e,r,n,o){if(e!==r)return!1;if(""===o.value)return!0;const a=n.indexOf(o);if(n.some((({value:e},r)=>e===o.value&&r!==a)))return!0;if(o.edited)return!1;if(new RegExp("^".concat(Liferay.Language.get("option"),"\\d*$")).test(o.value))return!0;if(new RegExp("^".concat(o.value.replace(/\d+$/,""),"\\d*")).test((0,t.normalizeFieldName)(o.label)))return!0;return!0},r.dedupValue=dedupValue,r.findDuplicateReference=findDuplicateReference,r.getDefaultOptionValue=getDefaultOptionValue,r.normalizeReference=normalizeReference,r.normalizeValue=normalizeValue,r.normalizeFields=function normalizeFields(e,r,n){return r.map(((t,o)=>{const a=normalizeValue(e,t,r,n);return _objectSpread(_objectSpread({},t),{},{reference:normalizeReference(r,_objectSpread(_objectSpread({},t),{},{value:a}),o),value:a})}))};var t=n("data-engine-js-components-web");function ownKeys(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(n),!0).forEach((function(r){_defineProperty(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function _defineProperty(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function dedupValue(e,r,n,o){let a=0;const recursive=(e,i)=>{const u=e.find((e=>{var r;return(null===(r=e.value)||void 0===r?void 0:r.toLowerCase())===(null==i?void 0:i.toLowerCase())}));u&&u.id!==n?o?(a+=1,recursive(e,r+a)):recursive(e,t.FieldSupport.getDefaultFieldName(!0)):r=i};return recursive(e,r),r}function findDuplicateReference(e,r,n){return e.filter(((e,n)=>n!==r)).some((({reference:e})=>(null==e?void 0:e.toLowerCase())===(null==n?void 0:n.toLowerCase())))}function getDefaultOptionValue(e,r){return e?r:t.FieldSupport.getDefaultFieldName(!0)}function normalizeReference(e,r,n){const{reference:o,value:a}=r;return!o||findDuplicateReference(e,n,o)?a||t.FieldSupport.getDefaultFieldName(!0):o}function normalizeValue(e,r,n,o){const{label:a,value:i}=r;let u=i||getDefaultOptionValue(o,a);return u||(u=Liferay.Language.get("option")),u=dedupValue(n,u,r.id,o),e?u:(0,t.normalizeFieldName)(u)}}}));
//# sourceMappingURL=util.es.js.map