import{isStringEmpty as a}from"../utils.js";import{g as t,f as e,i,a as n}from"../../form-utils-4685920e.js";import{CcFormValidEvent as r,CcFormInvalidEvent as o}from"./form.events.js";import{Validation as l}from"./validation.js";function s(s){return m=>{m.preventDefault();const d=m.target,f=function(t){const e=Array.from(t.elements),r=[];return e.forEach((t=>{if(function(t){return!a(t.name)}(t)){const a=t.name;i(t)&&t.willValidate?r.push({name:a,validate:()=>t.validate(),report:()=>{t.reportInlineValidity()}}):n(t)&&t.willValidate&&r.push({name:a,validate:()=>t.checkValidity()?l.VALID:l.invalid(t.validationMessage),report:()=>{}})}})),r}(d),v=f.map((a=>({name:a.name,validity:a.validate()})));f.forEach((a=>a.report()));if(v.every((a=>a.validity.valid))){const a=t(d);s.onValid?.(a,d),d.dispatchEvent(new r(a))}else s.onInvalid?.(v,d),e(d),d.dispatchEvent(new o(v))}}export{s as formSubmitHandler};
//# sourceMappingURL=form-submit-handler.js.map
