import{j as a,u as f,k as n,l as e,m as g,w as c,v as p,t as h,n as _,p as w,o as r}from"./index-B8bqNNwo.js";const x={class:"min-h-screen flex items-center justify-center bg-gray-100 px-4"},y={class:"mb-4"},k=["disabled"],q={class:"mb-6"},S=["disabled"],V=["disabled"],j={key:0},B={key:1},C={key:0,class:"text-red-500 mt-4 text-sm text-center font-medium bg-red-50 p-2 rounded"},P={__name:"Login",setup(E){const d=a(""),u=a(""),s=a(""),t=a(!1),m=w(),b=f(),v=async()=>{try{s.value="",t.value=!0,await b.login(d.value,u.value),m.push("/dashboard")}catch(o){console.error("Full Error Object:",o),o.response?s.value=o.response.data.message||"Invalid credentials.":o.request?s.value="The server did not respond. Check your internet or CORS settings.":s.value="Request setup error: "+o.message}finally{t.value=!1}};return(o,l)=>(r(),n("div",x,[e("form",{onSubmit:_(v,["prevent"]),class:"bg-white p-8 rounded shadow-md w-full max-w-md"},[l[2]||(l[2]=e("h2",{class:"text-2xl font-semibold mb-6 text-center text-gray-800"},"Portal Login",-1)),e("div",y,[c(e("input",{"onUpdate:modelValue":l[0]||(l[0]=i=>d.value=i),type:"text",placeholder:"Email or Phone",disabled:t.value,class:"border w-full p-3 rounded focus:ring-2 focus:ring-blue-500 outline-none",required:""},null,8,k),[[p,d.value]])]),e("div",q,[c(e("input",{"onUpdate:modelValue":l[1]||(l[1]=i=>u.value=i),type:"password",placeholder:"Password",disabled:t.value,class:"border w-full p-3 rounded focus:ring-2 focus:ring-blue-500 outline-none",required:""},null,8,S),[[p,u.value]])]),e("button",{type:"submit",disabled:t.value,class:"w-full bg-blue-600 text-white p-3 rounded font-medium hover:bg-blue-700 transition disabled:bg-blue-300"},[t.value?(r(),n("span",j,"Authenticating...")):(r(),n("span",B,"Log In"))],8,V),s.value?(r(),n("p",C,h(s.value),1)):g("",!0)],32)]))}};export{P as default};
