1import{R as d,r as a,j as e,B as u}from"./index-Ci53hMpI.js";function b(){const{token:r}=d.useSearch(),[n,t]=a.useState("checking"),[i,o]=a.useState(!1);a.useEffect(()=>{if(!r){t("invalid");return}fetch(`/email/unsubscribe?token=${encodeURIComponent(r)}`).then(s=>s.ok?s.json():Promise.reject()).then(s=>t(s.valid?"valid":s.reason==="already_unsubscribed"?"done":"invalid")).catch(()=>t("invalid"))},[r]);async function l(){o(!0);try{const s=await fetch("/email/unsubscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r})}),c=await s.json().catch(()=>null);t(s.ok&&(c?.success||c?.reason==="already_unsubscribed")?"done":"error")}catch{t("error")}finally{o(!1)}}return e.jsx("div",{className:"pt-12 md:pt-20 pb-24",children:e.jsxs("section",{className:"container-rail max-w-2xl",children:[e.jsx("div",{className:"eyebrow text-muted-foreground",children:"Email preferences"}),e.jsx("h1",{className:"display-xl mt-4",children:"Unsubscribe."}),n==="checking"&&e.jsx("p",{className:"mt-6 text-foreground/75",children:"Checking your unsubscribe linkâ¦"}),n==="valid"&&e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-foreground/75 leading-relaxed",children:"Confirm that you no longer want to receive Project Materia emails at this address."}),e.jsx(u,{type:"button",onClick:l,disabled:i,className:"mt-6 h-12 px-8 rounded-none bg-foreground text-background hover:bg-[var(--cocoa)] eyebrow",children:i?"Unsubscribingâ¦":"Confirm unsubscribe"})]}),n==="done"&&e.jsx("p",{className:"mt-6 text-foreground/75",children:"You have been unsubscribed."}),n==="invalid"&&e.jsx("p",{className:"mt-6 text-foreground/75",children:"This unsubscribe link is invalid or expired."}),n==="error"&&e.jsx("p",{className:"mt-6 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.