1import{u as S,j as e}from"./index-DTo46tGQ.js";import{f as C,i as k,b as r}from"./react-vendor-CfoRXicY.js";import{B as P}from"./Brand-Cf729PPA.js";import{supabase as b}from"./supabase-CNbjEO5G.js";import{L as E}from"./lock-keyhole-BKekcEx5.js";import"./supabase-DHizuabt.js";function z(){const h=C(),[l]=k(),{session:f,loading:w}=S(),[o,g]=r.useState(""),[n,y]=r.useState(""),[i,v]=r.useState(""),[d,t]=r.useState(""),[m,c]=r.useState(!1),[u,p]=r.useState(!1);r.useEffect(()=>{const s=l.get("error"),a=l.get("message");s&&t(a||"That password setup link is invalid or expired. Send yourself a fresh one below.")},[l]);const j=async s=>{if(s.preventDefault(),t(""),o.length<8){t("Use at least 8 characters.");return}if(o!==n){t("Passwords do not match.");return}c(!0);try{const{error:a}=await b.auth.updateUser({password:o});if(a)throw a;t("Password saved. Opening Company Brain."),h("/company-brain",{replace:!0})}catch(a){t(a instanceof Error?a.message:"Could not save password.")}finally{c(!1)}},N=async()=>{const s=i.trim().toLowerCase();if(t(""),!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(s)){t("Enter a valid founder email address.");return}p(!0);try{const{error:a}=await b.auth.resetPasswordForEmail(s,{redirectTo:`${window.location.origin}/auth/callback?next=company-brain-reset`});if(a)throw a;t(`Fresh password setup email sent to ${s}.`)}catch(a){t(a instanceof Error?a.message:"Could not send a fresh password setup email.")}finally{p(!1)}},x=!!f&&!w;return e.jsxs("div",{className:"theme-light min-h-screen bg-[#f6f7f8] text-slate-950",children:[e.jsx("header",{className:"border-b border-slate-200 bg-white/90 backdrop-blur",children:e.jsxs("div",{className:"mx-auto flex max-w-5xl items-center justify-between px-5 py-4",children:[e.jsx(P,{size:"lg"}),e.jsx("div",{className:"text-sm font-medium text-slate-500",children:"Founder access"})]})}),e.jsx("main",{className:"mx-auto grid min-h-[calc(100vh-73px)] max-w-5xl place-items-center px-5 py-10",children:e.jsxs("div",{className:"w-full max-w-xl rounded-2xl border border-slate-200 bg-white p-6 shadow-sm sm:p-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-slate-200 bg-slate-50 px-3 py-1 text-xs font-medium text-slate-600",children:[e.jsx(E,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Password setup"]}),e.jsx("h1",{className:"mt-5 text-3xl font-semibold tracking-normal text-slate-950",children:"Set your Company Brain password"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-slate-600",children:"Use the password setup email from Supabase, then save a password for founder-only Company Brain access."}),x?null:e.jsx("div",{className:"mt-5 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:"Open a fresh password setup email first. If the old link expired, send a new one below."}),e.jsxs("form",{onSubmit:j,className:"mt-6 space-y-4",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-700",htmlFor:"company-brain-new-password",children:"New password"}),e.jsx("input",{id:"company-brain-new-password",type:"password",value:o,onChange:s=>g(s.target.value),autoComplete:"new-password",className:"h-12 w-full rounded-lg border border-slate-200 bg-white px-3 text-sm text-slate-950 outline-none focus:border-slate-500"}),e.jsx("label",{className:"block text-sm font-medium text-slate-700",htmlFor:"company-brain-confirm-password",children:"Confirm password"}),e.jsx("input",{id:"company-brain-confirm-password",type:"password",value:n,onChange:s=>y(s.target.value),autoComplete:"new-password",className:"h-12 w-full rounded-lg border border-slate-200 bg-white px-3 text-sm text-slate-950 outline-none focus:border-slate-500"}),e.jsx("button",{type:"submit",disabled:m||!x,className:"h-12 w-full rounded-lg bg-slate-950 px-4 text-sm font-medium text-white hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-50",children:m?"Saving...":"Save password"})]}),e.jsxs("div",{className:"relative my-6",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-slate-200"})}),e.jsx("div",{className:"relative flex justify-center text-[11px] uppercase tracking-wider",children:e.jsx("span",{className:"bg-white px-3 text-slate-400",children:"or"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-700",htmlFor:"company-brain-reset-email",children:"Founder email"}),e.jsx("input",{id:"company-brain-reset-email",type:"email",value:i,onChange:s=>v(s.target.value),autoComplete:"email",className:"h-12 w-full rounded-lg border border-slate-200 bg-white px-3 text-sm text-slate-950 outline-none focus:border-slate-500"}),e.jsx("button",{type:"button",onClick:N,disabled:u,className:"h-11 w-full rounded-lg border border-slate-200 bg-white px-4 text-sm font-medium text-slate-950 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:u?"Sending...":"Send fresh setup email"})]}),d?e.jsx("div",{className:"mt-4 rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-600",children:d}):null]})})]})}export{z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.