import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{a as t,o as n}from"./query-BtP_B6q9.js";import{c as r,n as i,u as a}from"./react-CdhQMFNz.js";import{v as o}from"./vendor-B2maTQLc.js";import{_ as s,c,h as l,i as u,n as d}from"./Logo-CWvlQZMc.js";import{s as f}from"./main-DV3J5_jb.js";import{t as p}from"./AuthLayout-Cc_D8XEr.js";var m=e(n(),1),h=t();function g(){let[e]=a(),{refresh:t,isAuthenticated:n}=f(),o=r(),g=e.get(`path`),_=e.get(`signature`),v=e.get(`expires`),y=g!==null&&_!==null,[b,x]=(0,m.useState)(`verifying`),[S,C]=(0,m.useState)(``),w=(0,m.useRef)(!1);return(0,m.useEffect)(()=>{w.current||!y||(w.current=!0,(async()=>{try{let e=await u.get(g.replace(/^\/api\/v1/,``),{query:{signature:_,expires:v}});x(`done`),C(e.message),n&&await t()}catch(e){x(`failed`),C(e instanceof d?e.message:`This confirmation link could not be used.`)}})())},[g,_,v,y,t,n]),y?(0,h.jsxs)(p,{title:`Confirming your email`,children:[b===`verifying`&&(0,h.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-text-secondary`,children:[(0,h.jsx)(c,{label:`Confirming your email address`}),`Confirming your email address…`]}),b===`done`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s,{tone:`success`,title:`Email confirmed`,children:S}),(0,h.jsx)(`div`,{className:`mt-5`,children:(0,h.jsx)(l,{size:`lg`,fullWidth:!0,onClick:()=>o(n?`/dashboard`:`/login`),children:n?`Go to dashboard`:`Sign in`})})]}),b===`failed`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s,{tone:`error`,title:`Could not confirm`,children:S}),(0,h.jsx)(`div`,{className:`mt-5`,children:(0,h.jsx)(i,{to:`/verify-email/pending`,children:(0,h.jsx)(l,{variant:`secondary`,size:`lg`,fullWidth:!0,children:`Request a new link`})})})]})]}):(0,h.jsxs)(p,{title:`Confirmation link incomplete`,children:[(0,h.jsx)(s,{tone:`error`,title:`This link is not usable`,children:`Open the most recent confirmation link from your email, or request a new one.`}),(0,h.jsx)(`div`,{className:`mt-5`,children:(0,h.jsx)(i,{to:`/verify-email/pending`,children:(0,h.jsx)(l,{variant:`secondary`,size:`lg`,fullWidth:!0,children:`Request a new link`})})})]})}function _(){let{user:e,isAuthenticated:t}=f(),[n,r]=(0,m.useState)(null),[a,c]=(0,m.useState)(null),[g,_]=(0,m.useState)(!1);return(0,h.jsx)(p,{title:`Confirm your email address`,description:e?.email===void 0?`We sent you a confirmation link.`:`We sent a confirmation link to ${e.email}.`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,h.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-border-subtle bg-surface-sunken px-4 py-3.5`,children:[(0,h.jsx)(o,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-text-accent`}),(0,h.jsx)(`p`,{className:`text-sm text-text-secondary`,children:`You can browse the marketplace straight away. Confirming your address is required before making an offer, buying, or listing a domain.`})]}),n!==null&&(0,h.jsx)(s,{tone:`success`,children:n}),a!==null&&(0,h.jsx)(s,{tone:`error`,children:a}),t&&(0,h.jsx)(l,{variant:`secondary`,size:`lg`,fullWidth:!0,isLoading:g,onClick:async()=>{r(null),c(null),_(!0);try{let e=await u.post(`/auth/email/resend`);r(e.message)}catch(e){c(e instanceof d?e.message:`Could not send a new link. Try again shortly.`)}finally{_(!1)}},children:`Send a new link`}),(0,h.jsx)(i,{to:`/domains`,children:(0,h.jsx)(l,{variant:`ghost`,size:`lg`,fullWidth:!0,children:`Browse domains`})})]})})}export{g as VerifyEmailPage,_ as VerifyEmailPendingPage};
//# sourceMappingURL=VerifyEmailPage-CCZKe_55.js.map