Liferay.Loader.define("data-engine-js-components-web@1.0.79/js/utils/objectFields",["module","exports","require","frontend-js-web","../custom/form/eventTypes"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getFieldsGroupedByTypes=function(e){const t=e.map((({type:e})=>e));return t.filter(((e,n)=>t.indexOf(e)===n)).map((t=>({fields:e.filter((({type:e})=>t===e)),type:t})))},t.addObjectFields=async function(e){const t=(await Liferay.componentReady("formSettingsAPI")).reactComponentRef.current.getObjectDefinitionId();if(t){const{objectFields:n}=await s(t);e({payload:{objectFields:n},type:r.EVENT_TYPES.OBJECT.FIELDS_CHANGE})}},t.updateObjectFields=async function(e){const t=(await Liferay.componentReady("formSettingsAPI")).reactComponentRef.current.getObjectDefinitionId();if(t){const{objectFields:n}=await s(t);e({payload:{objectFields:n},type:r.EVENT_TYPES.OBJECT.FIELDS_CHANGE})}else e({payload:{objectFields:[]},type:r.EVENT_TYPES.OBJECT.FIELDS_CHANGE})},t.getSelectedValue=function(e){if("string"==typeof e&&""!==e){const t=JSON.parse(e);return Array.isArray(t)?t[0]:t}return e[0]},t.getObjectFieldName=function({settingsContext:e}){var t;const n=null===(t=e.pages.find((({title:e})=>e===Liferay.Language.get("advanced"))))||void 0===t?void 0:t.rows[0].columns[0].fields;if("fieldset"===e.type||!n)return;return n.find((e=>"objectFieldName"===e.fieldName))};var o=n("frontend-js-web"),r=n("../custom/form/eventTypes");function i(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 c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const e={Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json"},a=(e,t)=>{t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({p_auth:Liferay.authToken,t:Date.now()},t);const n=new URL("".concat(window.location.origin).concat(e));return Object.keys(t).forEach((e=>n.searchParams.set(e,t[e]))),n.toString()},s=t=>{const n=themeDisplay.getPathContext();return(0,o.fetch)(a(n+"/o/object-admin/v1.0/object-definitions/".concat(t)),{headers:e,method:"GET"}).then((e=>e.json()))}}}));
//# sourceMappingURL=objectFields.js.map