Liferay.Loader.define("@liferay/object-web@1.0.145/js/components/ObjectField/useObjectFieldForm",["module","exports","require","@liferay/object-js-components-web","frontend-js-web","../../utils/fieldSettings"],(function(e,i,a){window;{Object.defineProperty(i,"__esModule",{value:!0}),i.useObjectFieldForm=function useObjectFieldForm({forbiddenChars:i,forbiddenLastChars:a,forbiddenNames:o,initialValues:u,onSubmit:r}){const{errors:d,handleChange:m,handleSubmit:c,setValues:f,values:g}=(0,t.useForm)({initialValues:u,onSubmit:r,validate:u=>{var r,d;const m={},c=null===(r=u.label)||void 0===r?void 0:r[e],f=(0,s.normalizeFieldSettings)(u.objectFieldSettings);if((0,t.invalidateRequired)(c)&&(m.label=l),(0,t.invalidateRequired)(null!==(d=u.name)&&void 0!==d?d:c)&&(m.name=l),u.businessType)if("Aggregation"===u.businessType)f.function||(m.function=l),"COUNT"===f.function||f.objectFieldName||(m.objectFieldName=l),f.objectRelationshipName||(m.objectRelationshipName=l);else if("Attachment"===u.businessType){const e=Math.floor(Liferay.PropsValues.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE/1048576);if((0,t.invalidateRequired)(f.acceptedFileExtensions)&&(m.acceptedFileExtensions=l),f.fileSource||(m.fileSource=l),f.maximumFileSize||0===f.maximumFileSize?f.maximumFileSize>e?m.maximumFileSize=(0,n.sub)(Liferay.Language.get("file-size-is-larger-than-the-allowed-overall-maximum-upload-request-size-x-mb"),e):f.maximumFileSize<0&&(m.maximumFileSize=(0,n.sub)(Liferay.Language.get("only-integers-greater-than-or-equal-to-x-are-allowed"),0)):m.maximumFileSize=l,f.showFilesInDocumentsAndMedia)if((0,t.invalidateRequired)(f.storageDLFolderPath))m.storageDLFolderPath=l;else{const e=(e=>{const t=e[e.length-1];if(null==a?void 0:a.some((e=>e===t)))return(0,n.sub)(Liferay.Language.get("the-folder-name-cannot-end-with-the-following-characters-x"),a.join(" "));if(null==i?void 0:i.some((i=>e.includes(i))))return(0,n.sub)(Liferay.Language.get("the-folder-name-cannot-contain-the-following-invalid-characters-x"),i.join(" "));const s=new Set(o);return o&&e.split("/").some((e=>s.has(e)))?(0,n.sub)(Liferay.Language.get("the-folder-name-cannot-have-a-reserved-word-such-as-x"),o.join(", ")):null})(f.storageDLFolderPath);null!==e&&(m.storageDLFolderPath=e)}}else"Formula"===u.businessType?(0,t.invalidateRequired)(f.output)&&(m.output=l):"LongText"===u.businessType||"Text"===u.businessType?f.showCounter&&!f.maxLength&&(m.maxLength=l):"Picklist"===u.businessType&&(u.listTypeDefinitionId||(m.listTypeDefinitionId=l),u.state&&!u.defaultValue&&(m.defaultValue=l));else m.businessType=l;return m}});return{errors:d,handleChange:m,handleSubmit:c,setValues:f,values:g}};var t=a("@liferay/object-js-components-web"),n=a("frontend-js-web"),s=a("../../utils/fieldSettings");const e=Liferay.ThemeDisplay.getDefaultLanguageId(),l=Liferay.Language.get("required")}}));
//# sourceMappingURL=useObjectFieldForm.js.map