import{c as p,g as v,a as m,u as y,i as l,b as n,t as L}from"./web.4OCuPnM3.js";import{a as q,g as c}from"./errors.BxTAJicR.js";import{T as x,F as g}from"./toast.BAoR90zK.js";import{n as C}from"./router.BaxLfCzj.js";var D=L('<form method=post class="flex flex-col gap-5 md:gap-10 max-w-sm mx-auto"><!$><!/><!$><!/><!$><!/><div class="flex flex-wrap justify-center mt-5"><button type=submit class="bg-blue-950 rounded-lg text-white p-2 w-[10rem]">');const G=()=>{const[b,f]=p(!1),[a,$]=p();let i;const _=async e=>{e.preventDefault(),f(!0);try{const r=new FormData(i),{data:s,error:t}=await q.register(r);if($(t),await x.fire({icon:"success",title:t?"Failed":"Successful",text:s?.message??a()?.message}),!t)return i.reset(),C("/dashboard")}catch(r){await x.fire({icon:"error",title:"Error",text:r.message})}finally{f(!1)}};return(()=>{var e=v(D),r=e.firstChild,[s,t]=m(r.nextSibling),N=s.nextSibling,[u,w]=m(N.nextSibling),h=u.nextSibling,[d,F]=m(h.nextSibling),S=d.nextSibling,E=S.firstChild;return y(o=>i=o,e),e.addEventListener("submit",o=>_(o)),l(e,n(g,{name:"firstName",required:!0,label:"First Name",placeholder:"First Name",className:"grow",error:()=>c(["firstName"],a())}),s,t),l(e,n(g,{name:"lastName",required:!0,label:"Last Name",placeholder:"Last Name",className:"grow",error:()=>c(["lastName"],a())}),u,w),l(e,n(g,{name:"email",required:!0,label:"Email",type:"email",placeholder:"Email",className:"grow",error:()=>c(["email"],a())}),d,F),l(E,()=>b()?"...loading":"Register"),e})()};export{G as RegisterForm};
