var f=Object.defineProperty;var p=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>(p(r,typeof e!="symbol"?e+"":e,t),t);import{bd as v,F as d,aH as l,ap as m}from"./index.f2790301.js";var y=Object.prototype,b=y.hasOwnProperty;function E(r,e){return r!=null&&b.call(r,e)}function O(r,e){return r!=null&&v(r,e,E)}class h extends Promise{constructor(){super(...arguments);u(this,"errors",{})}all(t){return this.catch(a=>{Object.keys(a).forEach(n=>{const o=a[n],s={};Object.keys(o).forEach(i=>{s[i]=t}),this.handle(n,s)})})}handle(t,a){return this.catch(n=>(this.errors=n,Object.keys(a).forEach(o=>{try{const s=a[o];typeof s=="function"&&O(this.errors[t],o)&&(s(d(this.errors[t][o])[0]),delete this.errors[t][o],l(this.errors[t])&&delete this.errors[t])}catch(s){console.error("formError: ",s)}}),new h((o,s)=>{(l(this.errors)?Promise.resolve(!0):Promise.reject(this.errors)).then(o).catch(s)})))}oops(){return this.catch(t=>{const a=Object.values(t)[0],n=Object.values(a)[0];return snackbar.error(n[0]),this.errors={},new h((o,s)=>{Promise.resolve(!0).then(o).catch(s)})})}success(t){return this.then(t)}}const c=new m("form"),w={on(r,e){c.on(r,e)},off(r,e){c.off(r,e)},request(r,e,t){c.request(r,e,t)},reply(r,e){c.reply(r,e)},validate(r,e="form"){return new h((t,a)=>c.request(`${e}-validate-${r}`).then(t).catch(a))},value(r){return c.request(`field-value-${r}`)},values(r){return c.request(`form-values-${r}`)}};export{w as f,O as h};
//# sourceMappingURL=forms.daaaa22a.js.map
