import{o as e}from"./chunk-QXcFz7f5.js";import{c as t,l as n,n as r,r as i,t as a}from"./app-G6wC4CCm.js";import{S as o,g as s,h as c}from"./ui-D0zPIw82.js";import{t as l}from"./loader-circle-DtuHVunH.js";import{r as u}from"./theme-Cl--dRB8.js";import{t as d}from"./BackToHomeLink-BpDHgWuv.js";var f=e(t(),1),p=a(),m=2e3,h=3e4;function g({sessionId:e}){u();let[t,a]=(0,f.useState)(null),[g,_]=(0,f.useState)(!1),v=(0,f.useRef)(Date.now());return(0,f.useEffect)(()=>{let e=!1,t,n=async()=>{try{let r=await fetch(`/account/subscription/status`,{method:`GET`,credentials:`same-origin`,headers:{Accept:`application/json`,"X-Requested-With":`XMLHttpRequest`}});if(!r.ok)return;let i=await r.json();if(e)return;if(i.has_active_subscription){a(i);return}if(Date.now()-v.current>h){_(!0);return}t=window.setTimeout(n,m)}catch{if(e)return;if(Date.now()-v.current>h){_(!0);return}t=window.setTimeout(n,m)}};return n(),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r,{title:`Subscription confirmed`}),(0,p.jsx)(`main`,{className:`min-h-screen bg-background text-foreground`,children:(0,p.jsxs)(`div`,{className:`mx-auto flex min-h-screen max-w-md flex-col justify-center px-6 py-16`,children:[(0,p.jsx)(d,{className:`mb-10 inline-flex w-fit items-center gap-2 text-[11px] font-medium text-muted-foreground hover:text-accent`}),(0,p.jsx)(c,{padding:`lg`,"data-testid":`checkout-success-card`,children:t===null?(0,p.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,p.jsx)(`div`,{className:`rounded-full bg-muted p-2 text-muted-foreground`,children:g?(0,p.jsx)(o,{className:`h-6 w-6`,strokeWidth:2.5,"aria-hidden":!0}):(0,p.jsx)(l,{className:`h-6 w-6 animate-spin`,strokeWidth:2.5,"aria-hidden":!0})}),(0,p.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground`,children:`Subscription confirmed`}),(0,p.jsx)(`p`,{className:`text-sm leading-[1.6] text-muted-foreground`,children:g?`Your payment went through. The activation is taking a little longer than usual — refresh in a moment, or contact support if it doesn’t land.`:`Your payment went through. We’re waiting on the provider to confirm activation — this usually takes a few seconds.`}),e&&(0,p.jsxs)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,"data-testid":`checkout-success-session-id`,children:[`Reference:`,` `,(0,p.jsx)(`span`,{className:`break-all font-mono`,children:e})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex w-full flex-col gap-2`,children:[(0,p.jsx)(s,{variant:`secondary`,className:`w-full`,onClick:()=>n.reload(),children:`Refresh status`}),(0,p.jsx)(i,{href:`/projects`,className:`block w-full`,children:(0,p.jsx)(s,{variant:`ghost`,className:`w-full`,children:`Continue to projects`})})]})]}):(0,p.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,p.jsx)(`div`,{className:`rounded-full bg-accent/10 p-2 text-accent`,children:(0,p.jsx)(o,{className:`h-6 w-6`,strokeWidth:2.5,"aria-hidden":!0})}),(0,p.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground`,children:`Subscription active`}),(0,p.jsxs)(`p`,{className:`text-sm leading-[1.6] text-muted-foreground`,children:[`Your`,` `,(0,p.jsx)(`span`,{className:`font-medium text-foreground`,children:t?.plan_key}),` `,`plan is now live. Time to ship some screenshots.`]}),(0,p.jsx)(i,{href:`/projects`,className:`mt-3 block w-full`,children:(0,p.jsx)(s,{variant:`primary`,className:`w-full`,children:`Go to projects`})})]})})]})})]})}export{g as default};