import{j as e}from"./ui-vendor-Cn57k9R1.js";import{r as t,j as k,u as C,L as S}from"./react-vendor-B9tfxWGs.js";import{u as A,b as B,B as P,a as f,p as z}from"./index-DT-X9ySe.js";import{I as h}from"./input-DSW3IQ5Z.js";import{C as D}from"./checkbox-s3CrKDPd.js";import{E as I}from"./eye-off-vu7LJGiw.js";import{E as R}from"./eye-B79ITPqV.js";import"./query-vendor-BGnEs3s8.js";import"./charts-vendor-DecUTkfU.js";import"./editor-vendor-BA3QzDsK.js";const U=()=>{var u,x;const[m,p]=t.useState(""),[d,g]=t.useState(""),[r,b]=t.useState(!1),[j,y]=t.useState(!1),[a,c]=t.useState(!1),o=k(),N=C(),{login:v,isAuthenticated:n,isBootstrapping:i}=A(),l=((x=(u=N.state)==null?void 0:u.from)==null?void 0:x.pathname)||"/admin/dashboard";t.useEffect(()=>{!i&&n&&o(l,{replace:!0})},[n,i,o,l]);const w=async s=>{if(s.preventDefault(),!a){c(!0);try{await v(m,d),f.success("Login successful"),o(l,{replace:!0})}catch(L){const E=z(L);f.error(E.message)}finally{c(!1)}}};return i?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-secondary",style:{background:"#2D3142"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})}):n?null:e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-secondary",style:{background:"#2D3142"},children:e.jsxs("div",{className:"w-full max-w-sm bg-card rounded-2xl p-10 shadow-2xl mx-4",children:[e.jsxs("div",{className:"flex flex-col items-center mb-8",children:[e.jsx("img",{src:B,alt:"Boaze Estate Logo",className:"w-12 h-12 rounded-xl object-contain mb-3"}),e.jsx("h1",{className:"font-display text-2xl font-bold text-foreground",children:"Admin Login"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body mt-1",children:"Boaze Estate Management Panel"})]}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-foreground font-body mb-1.5 block",children:"Email"}),e.jsx(h,{type:"email",value:m,onChange:s=>p(s.target.value),placeholder:"admin@boaze.com",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-foreground font-body mb-1.5 block",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(h,{type:r?"text":"password",value:d,onChange:s=>g(s.target.value),placeholder:"••••••••",required:!0}),e.jsx("button",{type:"button",onClick:()=>b(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:r?e.jsx(I,{className:"w-4 h-4"}):e.jsx(R,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{id:"remember",checked:j,onCheckedChange:s=>y(s)}),e.jsx("label",{htmlFor:"remember",className:"text-sm text-muted-foreground font-body cursor-pointer",children:"Remember me for 7 days"})]}),e.jsx(P,{type:"submit",disabled:a,className:"w-full bg-primary hover:bg-primary-dark text-primary-foreground font-body",children:a?"Logging in...":"Login"}),e.jsx("div",{className:"text-center",children:e.jsx(S,{to:"/admin/forgot-password",className:"text-sm text-primary hover:underline font-body",children:"Forgot your password?"})})]})]})})};export{U as default};
