import{E as S,G as V,H as h,a0 as y,d as A,aj as M,aM as T,ak as j,j as k,aq as C,O as N}from"./ResizeObserver.es.b7226882.js";const[O,_]=S("form"),q={colon:Boolean,disabled:Boolean,readonly:Boolean,showError:Boolean,labelWidth:V,labelAlign:String,inputAlign:String,scrollToError:Boolean,validateFirst:Boolean,submitOnEnter:h,validateTrigger:y("onBlur"),showErrorMessage:h,errorMessageAlign:String};var x=A({name:O,props:q,emits:["submit","failed"],setup(o,{emit:r,slots:c}){const{children:s,linkChildren:g}=M(T),i=e=>e?s.filter(t=>e.includes(t.name)):s,v=e=>new Promise((t,n)=>{const l=[];i(e).reduce((F,w)=>F.then(()=>{if(!l.length)return w.validate().then(m=>{m&&l.push(m)})}),Promise.resolve()).then(()=>{l.length?n(l):t()})}),p=e=>new Promise((t,n)=>{const l=i(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):o.validateFirst?v(e):p(e),P=e=>{typeof e=="string"&&(e=[e]),i(e).forEach(n=>{n.resetValidation()})},u=(e,t)=>{s.some(n=>n.name===e?(n.$el.scrollIntoView(t),!0):!1)},B=()=>s.reduce((e,t)=>(e[t.name]=t.formValue.value,e),{}),f=()=>{const e=B();d().then(()=>r("submit",e)).catch(t=>{r("failed",{values:e,errors:t}),o.scrollToError&&t[0].name&&u(t[0].name)})},E=e=>{C(e),f()};return g({props:o}),j({submit:f,validate:d,scrollToField:u,resetValidation:P}),()=>{var e;return k("form",{class:_(),onSubmit:E},[(e=c.default)==null?void 0:e.call(c)])}}});const D=N(x);export{D as F};