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