Liferay.Loader.define("@liferay/object-web@1.0.145/js/components/ObjectAction/useObjectActionForm",["module","exports","require","@liferay/object-js-components-web","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.useObjectActionForm=function useObjectActionForm({initialValues:t,onSubmit:r}){var a;const[c,l]=(0,n.useState)([]),s=(0,n.useMemo)((()=>{const e=new Map;return c.forEach((t=>{e.set(t.name,t)})),e}),[c]),u=(0,o.useForm)({initialValues:t,onSubmit:r,validate:t=>{var r,n,a,c;const l={};if((0,o.invalidateRequired)(null===(r=t.label)||void 0===r?void 0:r[e])&&(l.label=i),(0,o.invalidateRequired)(t.name)&&(l.name=i),(0,o.invalidateRequired)(t.objectActionTriggerKey)&&(l.objectActionTriggerKey=i),(0,o.invalidateRequired)(t.objectActionExecutorKey))l.objectActionExecutorKey=i;else if("webhook"===t.objectActionExecutorKey&&(0,o.invalidateRequired)(null===(n=t.parameters)||void 0===n?void 0:n.url))l.url=i;else if("groovy"===t.objectActionExecutorKey&&(null===(a=t.parameters)||void 0===a?void 0:a.lineCount)&&t.parameters.lineCount>2987)l.script=Liferay.Language.get("the-maximum-number-of-lines-available-is-2987");else if("add-object-entry"===t.objectActionExecutorKey){var u;(null===(u=t.parameters)||void 0===u?void 0:u.objectDefinitionExternalReferenceCode)||(l.objectDefinitionExternalReferenceCode=i)}var d;if(("add-object-entry"===t.objectActionExecutorKey||"update-object-entry"===t.objectActionExecutorKey)&&(null===(d=t.parameters)||void 0===d?void 0:d.predefinedValues)){var f;(null===(f=t.parameters)||void 0===f?void 0:f.predefinedValues).forEach((({name:e,value:t})=>{var r;(null===(r=s.get(e))||void 0===r?void 0:r.required)&&(0,o.invalidateRequired)(t)&&(l.predefinedValues||(l.predefinedValues={}),l.predefinedValues[e]=i)}))}return"standalone"===t.objectActionTriggerKey&&(0,o.invalidateRequired)(null===(c=t.errorMessage)||void 0===c?void 0:c[e])&&(l.errorMessage=i),"string"==typeof t.conditionExpression&&(0,o.invalidateRequired)(t.conditionExpression)&&(l.conditionExpression=i),Object.keys(l).length&&(0,o.openToast)({message:i,type:"danger"}),l}}),{errors:d,values:f}=u,b=function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(u,["errors","values"]);return(0,n.useEffect)((()=>{var e;(null===(e=f.parameters)||void 0===e?void 0:e.objectDefinitionExternalReferenceCode)?(async()=>{var e;const t=(await o.API.getObjectFieldsByExternalReferenceCode(null===(e=f.parameters)||void 0===e?void 0:e.objectDefinitionExternalReferenceCode)).filter((({businessType:e,system:t})=>"Aggregation"!==e&&"Relationship"!==e&&!t));l(t)})():l([])}),[null===(a=f.parameters)||void 0===a?void 0:a.objectDefinitionExternalReferenceCode]),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}({errors:d,values:f},b)};var o=r("@liferay/object-js-components-web"),n=r("liferay!frontend-js-react-web$react");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}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}const e=Liferay.ThemeDisplay.getDefaultLanguageId(),i=Liferay.Language.get("required")}}));
//# sourceMappingURL=useObjectActionForm.js.map