Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ObjectAction/fetchUtil",["module","exports","require","@liferay/object-js-components-web"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.fetchObjectDefinitions=async function fetchObjectDefinitions({objectDefinitionsRelationshipsURL:e,setAddObjectEntryDefinitions:t,setObjectOptions:n,setSelectedObjectDefinition:i,values:r}){const c=await o.API.fetchJSON(e),a=[],l=[];null==c||c.forEach((e=>{const{externalReferenceCode:t,id:n,label:o,system:i}=e;(e.related?a:l).push({label:o,value:"".concat(t,",").concat(n,",").concat(i)})}));const s=[];fillSelect(Liferay.Language.get("related-objects"),a,s),fillSelect(Liferay.Language.get("unrelated-objects"),l,s);const{objectDefinitionExternalReferenceCode:f}=r.parameters;if(i&&f){const{defaultLanguageId:e,label:t,name:n}=await o.API.getObjectDefinitionByExternalReferenceCode(f);i((0,o.getLocalizableLabel)(e,t,n))}n(s),t(c)},t.fetchObjectDefinitionFields=async function fetchObjectDefinitionFields(e,t,n,i,r,c,a){let l=e,s=t,f=n;const b=[];if("add-object-entry"===i.objectActionExecutorKey){var u,d,p;l=null==i||null===(u=i.parameters)||void 0===u?void 0:u.objectDefinitionId,s=null===(d=i.parameters)||void 0===d?void 0:d.objectDefinitionExternalReferenceCode,f=!!(null==i||null===(p=i.parameters)||void 0===p?void 0:p.system)}if(s){(await o.API.getObjectFieldsByExternalReferenceCode(s)).forEach((e=>{r(e,f)&&b.push(e)}))}c(b);const{predefinedValues:j=[]}=i.parameters,y=new Map;j.forEach((e=>{y.set(e.name,e)}));const O=[];b.forEach((({businessType:e,label:t,name:n,required:o})=>{if(y.has(n)){const e=y.get(n);O.push(e)}else if(o&&"add-object-entry"===i.objectActionExecutorKey){const o="DateTime"===e;O.push({businessType:e,inputAsValue:o,label:t,name:n,value:""})}})),a({parameters:_objectSpread(_objectSpread({},i.parameters),{},{objectDefinitionExternalReferenceCode:s,objectDefinitionId:l,predefinedValues:O})})};var o=n("@liferay/object-js-components-web");function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fillSelect(e,t,n){t.length&&n.push({label:e,options:t,type:"group"})}}}));
//# sourceMappingURL=fetchUtil.js.map