1import{r as a,j as e}from"./react-runtime-BZYMbA0n.js";import{L as c}from"./routing-BJcY-oaB.js";import{c as x,B as o}from"./index-B66or0X1.js";import{S as p}from"./SnapcaseLogo-CHCYawUe.js";import{l as f,u as g}from"./lifecycle-email-BPUth_5F.js";import{S as b}from"./shield-check-DoU-OpER.js";import{C as j}from"./circle-check-DME656jJ.js";import"./data-services-DGj08KhI.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const v=x("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]),M=()=>{const[r]=a.useState(()=>{var s;return typeof window>"u"?"":((s=new URLSearchParams(window.location.search).get("token"))==null?void 0:s.trim())??""}),[t,i]=a.useState(r?"loading":"missing"),[n,l]=a.useState(!1);a.useLayoutEffect(()=>{if(!r)return;const s=new URL(window.location.href);s.searchParams.delete("token"),window.history.replaceState(window.history.state,"",`${s.pathname}${s.search}${s.hash}`)},[r]),a.useEffect(()=>{if(document.title="Email preferences | Snapcase",!r)return;let s=!0;return f(r).then(h=>s&&i(h)).catch(()=>s&&i("error")),()=>{s=!1}},[r]);const d=async()=>{if(!(!r||n)){l(!0);try{const s=await g(r);i(s==="unsubscribed"||s==="already_unsubscribed"?"suppressed":s)}catch{i("error")}finally{l(!1)}}},m=t==="subscribed",u=t==="suppressed"||t==="unsubscribed"||t==="already_unsubscribed";return e.jsxs("div",{className:"min-h-screen bg-background","data-email-preferences":"no-login",children:[e.jsx("header",{className:"border-b border-border/50",children:e.jsxs("div",{className:"container mx-auto flex h-16 items-center justify-between px-6",children:[e.jsx(c,{to:"/",className:"-ml-2 inline-flex min-h-11 items-center px-2",children:e.jsx(p,{className:"text-xl"})}),e.jsx(o,{asChild:!0,variant:"ghost",children:e.jsx(c,{to:"/",children:"Back to Snapcase"})})]})}),e.jsx("main",{className:"container mx-auto flex min-h-[calc(100vh-4rem)] items-center justify-center px-6 py-16",children:e.jsxs("section",{className:"w-full max-w-2xl overflow-hidden rounded-[2rem] border border-border bg-card shadow-strong",children:[e.jsx("div",{className:"h-2 bg-[linear-gradient(90deg,hsl(var(--cta)),hsl(var(--accent)),hsl(var(--primary-emphasis)))]","aria-hidden":"true"}),e.jsxs("div",{className:"p-7 md:p-12",children:[e.jsxs("p",{className:"mb-5 inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.18em] text-cta-emphasis",children:[e.jsx(b,{className:"h-4 w-4","aria-hidden":"true"}),"Private, password-free preference link"]}),e.jsx("h1",{className:"font-display text-3xl font-bold tracking-tight text-foreground md:text-5xl",children:"Email preferences"}),e.jsx("div",{className:"mt-8","aria-live":"polite","data-preference-state":t,children:t==="loading"?e.jsx("p",{role:"status",className:"text-muted-foreground",children:"Checking your preferenceâ¦"}):m?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(j,{className:"mt-1 h-6 w-6 shrink-0 text-cta-emphasis","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Marketing email is on"}),e.jsx("p",{className:"mt-2 leading-7 text-muted-foreground",children:"You can turn it off immediately below. Your order and account messages are managed separately."})]})]}),e.jsx(o,{type:"button",variant:"destructive",className:"mt-8 min-h-12 px-6",onClick:d,disabled:n,children:n?"Unsubscribingâ¦":"Unsubscribe from marketing email"})]}):u?e.jsxs("div",{role:"status",className:"flex items-start gap-4",children:[e.jsx(v,{className:"mt-1 h-6 w-6 shrink-0 text-cta-emphasis","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Youâre unsubscribed"}),e.jsx("p",{className:"mt-2 leading-7 text-muted-foreground",children:"Marketing email is off. This suppression stays in place and cannot be reversed by an automated signup."})]})]}):t==="invalid"||t==="missing"?e.jsxs("div",{role:"alert",children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Use your personal preference link"}),e.jsx("p",{className:"mt-2 leading-7 text-muted-foreground",children:"This link is missing or no longer valid. Open the preference link from a Snapcase marketing email, or contact support for help."})]}):e.jsxs("div",{role:"alert",children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"We couldnât load this preference"}),e.jsx("p",{className:"mt-2 leading-7 text-muted-foreground",children:"Please try again. We wonât change an existing suppression while the service is unavailable."})]})}),e.jsxs("p",{className:"mt-10 border-t border-border pt-6 text-sm leading-6 text-muted-foreground",children:["This page does not require an account. For privacy questions, visit our"," ",e.jsx(c,{to:"/privacy",className:"underline underline-offset-2 hover:text-foreground",children:"privacy policy"}),"."]})]})]})})]})};export{M 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.