1import{e as l,r as a,j as e}from"./vendor-react-Cs2IwLQc.js";import{s as d}from"./index-RNfTF_ci.js";import{B as u}from"./button-BGt3UZfR.js";import"./vendor-supabase-CL7Ndi3k.js";const m="https://sqiordomutobpuivppsn.supabase.co",p="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNxaW9yZG9tdXRvYnB1aXZwcHNuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU4Mzc4ODMsImV4cCI6MjA5MTQxMzg4M30.nkfMZpMfpY9wDL70MH7elz6VPqbBO9ag7ntMrNNVx3M";function x(){const[t]=l(),o=t.get("token")||"",[i,s]=a.useState("loading");a.useEffect(()=>{if(!o){s("invalid");return}(async()=>{try{const r=await fetch(`${m}/functions/v1/handle-email-unsubscribe?token=${encodeURIComponent(o)}`,{headers:{apikey:p}}),n=await r.json();r.ok?n.valid===!1&&n.reason==="already_unsubscribed"?s("already"):n.valid?s("valid"):s("invalid"):s("invalid")}catch{s("error")}})()},[o]);const c=async()=>{s("confirming");const{data:r,error:n}=await d.functions.invoke("handle-email-unsubscribe",{body:{token:o}});n?s("error"):r!=null&&r.success||(r==null?void 0:r.reason)==="already_unsubscribed"?s("done"):s("error")};return e.jsx("div",{className:"min-h-screen flex items-center justify-center p-6",style:{backgroundColor:"#0D1B2A"},children:e.jsxs("div",{className:"max-w-md w-full text-center",style:{backgroundColor:"#F5F0E8",padding:"40px 32px",borderRadius:8},children:[e.jsx("h1",{style:{color:"#0D1B2A",fontFamily:"Cormorant Garamond, serif",fontSize:28,marginBottom:16},children:"Unsubscribe"}),i==="loading"&&e.jsx("p",{style:{color:"#3a4a5e"},children:"Checking your linkâ¦"}),i==="valid"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"#3a4a5e",marginBottom:24},children:"Click below to stop receiving emails from Eventscape.ai."}),e.jsx(u,{onClick:c,style:{backgroundColor:"#C9A84C",color:"#0D1B2A"},children:"Confirm unsubscribe"})]}),i==="confirming"&&e.jsx("p",{style:{color:"#3a4a5e"},children:"Processingâ¦"}),i==="done"&&e.jsx("p",{style:{color:"#3a4a5e"},children:"You've been unsubscribed. Sorry to see you go."}),i==="already"&&e.jsx("p",{style:{color:"#3a4a5e"},children:"This address is already unsubscribed."}),i==="invalid"&&e.jsx("p",{style:{color:"#3a4a5e"},children:"This unsubscribe link is invalid or has expired."}),i==="error"&&e.jsx("p",{style:{color:"#3a4a5e"},children:"Something went wrong. Please try again later."})]})})}export{x 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.