import{c as w,d as y,ab as A,Z as T,a as C,n as M,t as g,p as N,bq as _,k}from"./index-869d77fb.js";const[q,x]=w("form"),I={colon:Boolean,disabled:Boolean,readonly:Boolean,showError:Boolean,labelWidth:M,labelAlign:String,inputAlign:String,scrollToError:Boolean,validateFirst:Boolean,submitOnEnter:g,showErrorMessage:g,errorMessageAlign:String,validateTrigger:{type:[String,Array],default:"onBlur"}};var O=y({name:q,props:I,emits:["submit","failed"],setup(i,{emit:r,slots:c}){const{children:s,linkChildren:v}=A(_),o=e=>e?s.filter(t=>e.includes(t.name)):s,p=e=>new Promise((t,n)=>{const l=[];o(e).reduce((F,V)=>F.then(()=>{if(!l.length)return V.validate().then(h=>{h&&l.push(h)})}),Promise.resolve()).then(()=>{l.length?n(l):t()})}),b=e=>new Promise((t,n)=>{const l=o(e);Promise.all(l.map(a=>a.validate())).then(a=>{a=a.filter(Boolean),a.length?n(a):t()})}),B=e=>{const t=s.find(n=>n.name===e);return t?new Promise((n,l)=>{t.validate().then(a=>{a?l(a):n()})}):Promise.reject()},d=e=>typeof e=="string"?B(e):i.validateFirst?p(e):b(e),P=e=>{typeof e=="string"&&(e=[e]),o(e).forEach(n=>{n.resetValidation()})},S=()=>s.reduce((e,t)=>(e[t.name]=t.getValidationStatus(),e),{}),u=(e,t)=>{s.some(n=>n.name===e?(n.$el.scrollIntoView(t),!0):!1)},f=()=>s.reduce((e,t)=>(t.name!==void 0&&(e[t.name]=t.formValue.value),e),{}),m=()=>{const e=f();d().then(()=>r("submit",e)).catch(t=>{r("failed",{values:e,errors:t}),i.scrollToError&&t[0].name&&u(t[0].name)})},E=e=>{N(e),m()};return v({props:i}),T({submit:m,validate:d,getValues:f,scrollToField:u,resetValidation:P,getValidationStatus:S}),()=>{var e;return C("form",{class:x(),onSubmit:E},[(e=c.default)==null?void 0:e.call(c)])}}});const D=k(O);export{D as F};