import{u as x,r as d,j as e,L as b,s as u,t as g}from"./index-CEqTxpJr.js";function h(){const p=x(),[n,s]=d.useState("signin"),[a,i]=d.useState(!1);async function m(r){r.preventDefault(),i(!0);const o=new FormData(r.currentTarget),c=String(o.get("email")),l=String(o.get("password"));try{if(n==="signup"){const{error:t}=await u.auth.signUp({email:c,password:l,options:{emailRedirectTo:window.location.origin+"/admin"}});if(t)throw t;g.success("Account created. Sign in to continue."),s("signin")}else{const{error:t}=await u.auth.signInWithPassword({email:c,password:l});if(t)throw t;p({to:"/admin"})}}catch(t){g.error(t instanceof Error?t.message:"Authentication failed")}finally{i(!1)}}return e.jsx("div",{className:"grid min-h-screen place-items-center bg-ivory px-4",children:e.jsxs("div",{className:"w-full max-w-md bg-white p-8 ring-1 ring-navy/10",children:[e.jsx(b,{to:"/",className:"font-display text-2xl font-extrabold uppercase tracking-tighter",children:"Bridgefield"}),e.jsx("h1",{className:"mt-6 font-display text-2xl font-bold",children:n==="signin"?"Admin Sign In":"Create Admin Account"}),e.jsxs("form",{onSubmit:m,className:"mt-6 space-y-4",children:[e.jsx("input",{required:!0,name:"email",type:"email",placeholder:"Email",className:"w-full border-b border-navy/15 bg-transparent py-2.5 text-sm outline-none focus:border-gold"}),e.jsx("input",{required:!0,name:"password",type:"password",placeholder:"Password",minLength:6,className:"w-full border-b border-navy/15 bg-transparent py-2.5 text-sm outline-none focus:border-gold"}),e.jsx("button",{type:"submit",disabled:a,className:"w-full bg-navy py-4 text-[10px] font-bold uppercase tracking-widest text-ivory hover:bg-gold hover:text-navy disabled:opacity-60",children:a?"Please wait…":n==="signin"?"Sign In":"Sign Up"})]}),e.jsx("button",{onClick:()=>s(n==="signin"?"signup":"signin"),className:"mt-6 text-xs text-navy/60 underline",children:n==="signin"?"Need an account? Sign up":"Have an account? Sign in"}),e.jsx("p",{className:"mt-6 text-[10px] uppercase tracking-widest text-navy/40",children:"Admin role must be granted in the database after signup."})]})})}export{h as component};
