Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ObjectValidation/EditObjectValidation",["module","exports","require","@frontend-taglib-clay$clayui/tabs","@liferay/object-js-components-web","liferay!frontend-js-react-web$react","../../utils/constants","./BasicInfo","./Conditions","./useObjectValidationForm"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function EditObjectValidation({creationLanguageId:t,learnResources:a,objectDefinitionId:l,objectValidationRuleElements:c,objectValidationRuleId:d,readOnly:f}){var b;const[p,y]=(0,i.useState)(0),[g,j]=(0,i.useState)({}),[m,O]=(0,i.useState)([]),{errors:v,handleChange:w,handleSubmit:_,setValues:P,values:h}=(0,s.useObjectValidationForm)({initialValues:u,onSubmit:async e=>{delete e.lineCount;try{await r.API.save("/o/object-admin/v1.0/object-validation-rules/".concat(e.id),e),(0,r.saveAndReload)(),(0,r.openToast)({message:Liferay.Language.get("the-object-validation-was-updated-successfully")})}catch(e){const{detail:t,message:a}=e,{fieldName:n,message:i}=JSON.parse(t);j({[n]:i}),(0,r.openToast)({message:a,type:"danger"})}}});return(0,i.useEffect)((()=>{Object.keys(v).length&&(0,r.openToast)({message:Liferay.Language.get("please-fill-out-all-required-fields"),type:"danger"})}),[v]),(0,i.useEffect)((()=>{(async()=>{const e=await r.API.getObjectValidationRuleById(d);if(Liferay.FeatureFlags["LPS-187846"]){const t=_objectSpread(_objectSpread({},e),{},{script:"script_placeholder"===e.script?"":e.script}),a=await r.API.getObjectFieldsById(l);O(a.filter((e=>!e.system))),P(t)}else P(_objectSpread(_objectSpread({},e),{},{script:"script_placeholder"===e.script?"":e.script}))})()}),[l,d]),i.default.createElement(r.SidePanelForm,{onSubmit:_,title:null===(b=u.name)||void 0===b?void 0:b[o.defaultLanguageId]},i.default.createElement(n.default,{className:"side-panel-iframe__tabs"},e.map((({label:e},t)=>{var a;return(null===(a=h.engine)||void 0===a?void 0:a.startsWith("function#"))&&1===t?i.default.createElement(i.default.Fragment,{key:t}):i.default.createElement(n.default.Item,{active:p===t,key:t,onClick:()=>y(t)},e)}))),i.default.createElement(n.default.Content,{activeIndex:p,fade:!0},e.map((({Component:e,label:r},o)=>p===o?i.default.createElement(n.default.TabPane,{key:o},i.default.createElement(e,{componentLabel:r,creationLanguageId:t,disabled:f,errors:0!==Object.keys(v).length?v:g,handleChange:w,learnResources:a,objectFields:null!=m?m:[],objectValidationRuleElements:c,setValues:P,values:h})):i.default.createElement(i.default.Fragment,{key:o})))))};var n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(a("@frontend-taglib-clay$clayui/tabs")),r=a("@liferay/object-js-components-web"),i=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=n?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(a,r,i):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),o=a("../../utils/constants"),l=a("./BasicInfo"),c=a("./Conditions"),s=a("./useObjectValidationForm");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const e=[{Component:l.BasicInfo,label:Liferay.Language.get("basic-info")},{Component:c.Conditions,label:Liferay.Language.get("conditions")}],u={active:!1,engine:"",engineLabel:"",errorLabel:{},id:0,name:{en_US:""},script:""}}}));
//# sourceMappingURL=EditObjectValidation.js.map