1import{R as l,r as i,j as e,B as u}from"./main-B9MRBnNy.js";function b(){const{token:t}=l.useSearch(),[r,s]=i.useState("loading"),[o,c]=i.useState(!1);i.useEffect(()=>{if(!t){s("invalid");return}(async()=>{try{const a=await fetch(`/email/unsubscribe?token=${encodeURIComponent(t)}`),n=await a.json();a.ok?n.valid?s("ready"):n.reason==="already_unsubscribed"?s("already"):s("invalid"):s("invalid")}catch{s("error")}})()},[t]);const d=async()=>{c(!0);try{const n=await(await fetch("/email/unsubscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t})})).json();n.success?s("done"):n.reason==="already_unsubscribed"?s("already"):s("error")}catch{s("error")}finally{c(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background px-4",children:e.jsxs("div",{className:"max-w-md w-full bg-card border border-border rounded-xl p-8 text-center space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Unsubscribe"}),r==="loading"&&e.jsx("p",{className:"text-muted-foreground",children:"Verifyingâ¦"}),r==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground",children:"Stop receiving emails from AstraQom?"}),e.jsx(u,{onClick:d,disabled:o,children:o?"Processingâ¦":"Confirm unsubscribe"})]}),r==="done"&&e.jsx("p",{className:"text-muted-foreground",children:"You've been unsubscribed."}),r==="already"&&e.jsx("p",{className:"text-muted-foreground",children:"You're already unsubscribed."}),r==="invalid"&&e.jsx("p",{className:"text-destructive",children:"This link is invalid or expired."}),r==="error"&&e.jsx("p",{className:"text-destructive",children:"Something went wrong. Please try again."})]})})}export{b as component};
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.