import{r as t,u as y,j as e,L as d,l as N,P as b}from"./index-BVAJPyoi.js";import{A as w}from"./AuthPageLayout-TP0-Bmay.js";import{S,a as k,C as E}from"./Checkbox-Buquo3pl.js";import{L as m}from"./Label-CXb26FYI.js";import{I as x}from"./InputField-D578Umz6.js";import{B as C}from"./Button-C2c0QzSM.js";import"./bundle-mjs-COJ8Fh6m.js";import"./clsx-B-dksMZM.js";function I(){const[n,h]=t.useState(""),[l,g]=t.useState(""),[i,u]=t.useState(!1),[p,f]=t.useState(!1),[o,c]=t.useState(""),j=y(),v=async s=>{s.preventDefault(),c("");try{await N(n,l),j("/home")}catch(a){let r="Unexpected error during login";a instanceof Error&&(a.message==="Invalid credentials"?r="Invalid credentials. Check your email and password.":a.message==="Email not verified"?r="You must verify your email before logging in.":r=a.message),c(r)}};return e.jsx("div",{className:"flex flex-col flex-1",children:e.jsx("div",{className:"flex flex-col justify-center flex-1 w-full max-w-md mx-auto",children:e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 sm:mb-8",children:[e.jsx("h1",{className:"mb-2 font-semibold text-gray-800 text-title-sm dark:text-white/90 sm:text-title-md",children:"Sign In"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Enter your email and password to sign in!"})]}),e.jsx("form",{onSubmit:v,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs(m,{children:["Email ",e.jsx("span",{className:"text-error-500",children:"*"})]}),e.jsx(x,{placeholder:"info@gmail.com",value:n,onChange:s=>h(s.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsxs(m,{children:["Password ",e.jsx("span",{className:"text-error-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(x,{type:i?"text":"password",placeholder:"Enter your password",value:l,onChange:s=>g(s.target.value),required:!0}),e.jsx("span",{onClick:()=>u(!i),className:"absolute z-30 -translate-y-1/2 cursor-pointer right-4 top-1/2",children:i?e.jsx(S,{className:"fill-gray-500 dark:fill-gray-400 size-5"}):e.jsx(k,{className:"fill-gray-500 dark:fill-gray-400 size-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(E,{checked:p,onChange:f}),e.jsx("span",{className:"block font-normal text-gray-700 text-theme-sm dark:text-gray-400",children:"Keep me logged in"})]}),e.jsx(d,{to:"/reset-password",className:"text-sm text-brand-500 hover:text-brand-600 dark:text-brand-400",children:"Forgot password?"})]}),e.jsx("div",{children:e.jsx(C,{className:"w-full",size:"sm",type:"submit",children:"Sign in"})}),o&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:o})]})}),e.jsx("div",{className:"mt-5",children:e.jsxs("p",{className:"text-sm font-normal text-center text-gray-700 dark:text-gray-400 sm:text-start",children:["Don't have an account?"," ",e.jsx(d,{to:"/signup",className:"text-brand-500 hover:text-brand-600 dark:text-brand-400",children:"Sign Up"})]})})]})})})}function M(){return e.jsxs(e.Fragment,{children:[e.jsx(b,{title:"Scipion",description:"Scipion Web"}),e.jsx(w,{children:e.jsx(I,{})})]})}export{M as default};
