import{c as $,g as L,a as i,i as l,b as n,t as M,u as N}from"./web.4OCuPnM3.js";import{T as d,F as o}from"./toast.BAoR90zK.js";import{a as D,g as m}from"./errors.BxTAJicR.js";var A=M('<form method=post class="flex flex-col gap-3"><h4 class="balance text-blue-950 font-semibold text-[1.3rem] !mt-0 md:!mt-4 uppercase tracking-wider">Leave Us A Message</h4><div class="grid gap-3"><!$><!/><!$><!/><!$><!/><!$><!/></div><div class="flex flex-wrap justify-center md:justify-end gap-3 *:grow *:md:shrink"><button type=reset class="border-blue-950 border rounded-lg text-blue-950 p-2 w-[10rem]">Clear</button><button type=submit class="bg-blue-950 rounded-lg text-white p-2 w-[10rem]">');const U=()=>{const[f,b]=$(!1),[s,h]=$();let c;const y=async t=>{t.preventDefault(),b(!0),h();try{const r=new FormData(c),e=r.get("name"),{data:g,error:a}=await D.sendMessage(r);a?await d.fire({title:"Try Again",text:a?.message,html:`
        <strong> Sorry "${e??""}"</strong> 
        <p class='my-2'> Kindly Retry by clicking on the submit button </p>
        `}):(c.reset(),await d.fire({title:"Recieved",text:g?.message,html:`
        <strong> Thank your "${e??""}"</strong> 
        <p class='my-2'> We will get back to you within the next 48 hours maximum </p>
        `}))}catch(r){await d.fire({icon:"error",title:"Error",text:r.message})}finally{b(!1)}};return(()=>{var t=L(A),r=t.firstChild,e=r.nextSibling,g=e.firstChild,[a,_]=i(g.nextSibling),w=a.nextSibling,[p,S]=i(w.nextSibling),v=p.nextSibling,[x,E]=i(v.nextSibling),k=x.nextSibling,[C,F]=i(k.nextSibling),j=e.nextSibling,q=j.firstChild,T=q.nextSibling;return N(u=>c=u,t),t.addEventListener("submit",u=>y(u)),l(e,n(o,{name:"name",required:!0,label:"Name",placeholder:"Full name",error:()=>m(["name"],s())}),a,_),l(e,n(o,{name:"email",type:"email",required:!0,label:"Email",placeholder:"user@example.com",error:()=>m(["email"],s())}),p,S),l(e,n(o,{name:"subject",required:!0,label:"Subject",placeholder:"Enquiry",error:()=>m(["subject"],s())}),x,E),l(e,n(o,{name:"message",multiLine:!0,required:!0,label:"Message",placeholder:"Type your message",className:"grow",error:()=>m(["message"],s())}),C,F),l(T,()=>f()?"...loading":"Submit"),t})()};export{U as ContactForm};
