1import{t as f,r as l,j as e}from"./react-vendor-Q2BSRknM.js";import{C as b,B as j}from"./index-BgCZMvjj.js";import{a4 as g,L as c,b as o,X as p}from"./lucide-Ckh7y__x.js";import"./capacitor-DSpR9wll.js";import"./ui-radix-DzQ_orwq.js";import"./supabase-DoZmW4Yf.js";import"./query-BLOP9k_M.js";import"./date-utils-DaNoSKVa.js";const d="https://grwhdhnlafqrcmiuqhhi.supabase.co",u="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imdyd2hkaG5sYWZxcmNtaXVxaGhpIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjI2NDk4NjMsImV4cCI6MjA3ODIyNTg2M30.AS7_JF_qguIDtEEtN6YhNrACYmEzw_UdufeXVK1vXjg";function E(){const[m]=f(),a=m.get("token"),[r,s]=l.useState("validating"),[x,n]=l.useState("");l.useEffect(()=>{if(!a){s("invalid"),n("Missing unsubscribe token.");return}(async()=>{try{const i=await fetch(`${d}/functions/v1/handle-email-unsubscribe?token=${encodeURIComponent(a)}`,{headers:{apikey:u}}),t=await i.json();if(!i.ok){s("invalid"),n(t.error||"Invalid or expired link.");return}if(t.valid===!1&&t.reason==="already_unsubscribed"){s("already_unsubscribed");return}if(t.valid){s("valid");return}s("invalid")}catch{s("invalid"),n("Could not reach server. Please try again.")}})()},[a]);const h=async()=>{if(a){s("submitting");try{const t=await(await fetch(`${d}/functions/v1/handle-email-unsubscribe`,{method:"POST",headers:{apikey:u,"Content-Type":"application/json"},body:JSON.stringify({token:a})})).json();t.success?s("success"):t.reason==="already_unsubscribed"?s("already_unsubscribed"):(s("error"),n(t.error||"Something went wrong."))}catch{s("error"),n("Could not reach server. Please try again.")}}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:e.jsxs(b,{className:"max-w-md w-full p-8 text-center space-y-6",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-muted flex items-center justify-center",children:e.jsx(g,{className:"h-6 w-6 text-muted-foreground"})}),r==="validating"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Checking your linkâ¦"}),e.jsx(c,{className:"h-6 w-6 mx-auto animate-spin text-muted-foreground"})]}),r==="valid"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Unsubscribe from PB Pulse emails?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You'll stop receiving prize notifications and other app emails. You can still use the app normally."}),e.jsx(j,{onClick:h,size:"lg",className:"w-full",children:"Confirm Unsubscribe"})]}),r==="submitting"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Unsubscribingâ¦"}),e.jsx(c,{className:"h-6 w-6 mx-auto animate-spin text-muted-foreground"})]}),r==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-green-500/15 flex items-center justify-center",children:e.jsx(o,{className:"h-6 w-6 text-green-500"})}),e.jsx("h1",{className:"text-xl font-bold",children:"You've been unsubscribed"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You won't receive any more emails from us. Sorry to see you go!"})]}),r==="already_unsubscribed"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-muted flex items-center justify-center",children:e.jsx(o,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h1",{className:"text-xl font-bold",children:"Already unsubscribed"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This email address has already been unsubscribed."})]}),(r==="invalid"||r==="error")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-destructive/15 flex items-center justify-center",children:e.jsx(p,{className:"h-6 w-6 text-destructive"})}),e.jsx("h1",{className:"text-xl font-bold",children:"Couldn't process request"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x||"This link is invalid or has expired."})]})]})})}export{E 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.