1import{q as te,k as re,r as m,j as e}from"./vendor-BFXU7DOE.js";import{b as _,d as w,h as ae,e as I,B as b,A as V,R as L,s as U,m as Y}from"./index-0a0uir_3.js";import{G as ne}from"./GuardianLogo-CR5GMaoV.js";import{I as T}from"./input-tkUwFhSJ.js";import{i as O}from"./EnvelopeSimple.es-BTA2XrXc.js";import{n as le}from"./Key.es-CGCi7Bz1.js";import"./ui-B_QsM55A.js";import"./radix-BmG-mZpu.js";const ie={BASE:"Guardian Pro Platform",ENTERPRISE:"Enterprise"};function pe(){const[$]=te(),E=re(),[x,r]=m.useState("loading"),[h,z]=m.useState(""),[k,H]=m.useState(""),[v,g]=m.useState(""),[R,W]=m.useState(""),[S,f]=m.useState(null),[y,J]=m.useState({}),[A,K]=m.useState(null),[Q,G]=m.useState(!1),[P,C]=m.useState(""),[F,j]=m.useState(""),[M,q]=m.useState(0),[p,N]=m.useState(!1);m.useEffect(()=>{const s=$.get("x-amzn-marketplace-token");if(!s){r("recovery_mode");return}K(s),X(s)},[$]);const X=async s=>{var i,c,a,l,n;try{r("loading");const o=await _.post("/marketplace/fulfill",{token:s});B(o.data)}catch(o){console.error("Token resolution error:",o);const t=o instanceof Error&&"response"in o?o:null,d=(i=t==null?void 0:t.response)==null?void 0:i.status,u=(c=t==null?void 0:t.response)==null?void 0:c.data;if(d===403){f((u==null?void 0:u.message)||"No active AWS Marketplace subscription found for this account."),r("no_subscription");return}if((a=u==null?void 0:u.error)!=null&&a.includes("expired")||(l=u==null?void 0:u.error)!=null&&l.includes("invalid")||(n=u==null?void 0:u.error)!=null&&n.includes("Invalid token")){r("recovery_mode");return}r("recovery_mode")}},B=s=>{switch(s.action){case"email_required":J({customerIdentifier:s.organizationId,productC
1ode:s.message,tier:s.tier,awsAccountId:s.awsAccountId}),r("email_required");break;case"reactivated":s.isTrial&&G(!0),r("success"),setTimeout(()=>{E("/login",{state:{message:"Welcome back! Your account has been reactivated. Please log in.",fromMarketplace:!0}})},3e3);break;case"existing_customer":r("existing"),setTimeout(()=>{E("/login",{state:{message:"Welcome back! Please log in to continue.",fromMarketplace:!0}})},2e3);break;case"new_customer":s.isTrial&&G(!0),r("success"),setTimeout(()=>{E("/login",{state:{message:"Account created! Check your email for login credentials.",fromMarketplace:!0,email:s.email}})},3e3);break;default:throw new Error("Unexpected response from server")}},D=async()=>{var s,i;try{await _.post("/marketplace/verify-email",{email:h}),q(60);const c=setInterval(()=>{q(a=>a<=1?(clearInterval(c),0):a-1)},1e3)}catch(c){const a=c instanceof Error&&"response"in c?c:null;if(((s=a==null?void 0:a.response)==null?void 0:s.status)===429){f(((i=a.response.data)==null?void 0:i.message)||"Too many attempts. Please wait a few minutes."),r("rate_limited");return}throw c}},Z=async s=>{var c;if(s.preventDefault(),p)return;if(!h||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h)){g("Please enter a valid email address");return}if(!A){r("recovery_mode");return}try{N(!0),g(""),await D(),C(""),j(""),r("verify_email")}catch(a){console.error("Email verification send error:",a);const l=a instanceof Error&&"response"in a?a:null,n=(c=l==null?void 0:l.response)==null?void 0:c.data;g((n==null?void 0:n.error)||(n==null?void 0:n.message)||"Failed to send verification code")}finally{N(!1)}},ee=async s=>{var a,l;if(s.preventDefault(),p)return;if(!h||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h)){g("Please enter a valid email address");return}if(!k||!/^\d{12}$/.test(k)){W("Please enter a valid 12-digit AWS Account ID");return}try{N(!0),g(""),W(""),await D(),C(""),j(""),r("verify_email")}catch(n){console.error("Recovery verification send error:",n);const o=n instanceof Error&&"response"in n?n:null,t=(a=o==null?void 0:o.response)==null?void 0:a.status,d=(l=o==null?void 0:o.response)==null?void 0:l.data;if(t===403){f((d==null?void 0:d.message)||"No active AWS Marketplace subscription found for this account."),r("no_subscription");return}if(t===503){f((d==null?void 0:d.message)||"Verification service is temporarily unavailable."),r("service_unavailable");return}g((d==null?void 0:d.error)||(d==null?void 0:d.message)||"Failed to send verification code")}finally{N(!1)}},se=async s=>{var c,a;if(s.preventDefault(),p)return;const i=P.replace(/\s/g,"");if(!i||!/^\d{6}$/.test(i)){j("Please enter the 6-digit code from your email");return}try{N(!0),r("processing"),j("");let l;A?l=await _.post("/marketplace/fulfill",{token:A,email:h,verificationCode:i}):l=await _.post("/marketplace/recover",{email:h,awsAccountId:k,verificationCode:i}),B(l.data)}catch(l){console.error("Verification code submit error:",l);const n=l instanceof Error&&"response"in l?l:null,o=(c=n==null?void 0:n.response)==null?void 0:c.status,t=(a=n==null?void 0:n.response)==null?void 0:a.data;if((t==null?void 0:t.code)==="VERIFICATION_FAILED"){j(t.error||"Invalid verification code"),r("verify_email");return}if(o===403){f((t==null?void 0:t.message)||"No active subscription found."),r("no_subscription");return}if(o===429){f((t==null?void 0:t.message)||"Too many attempts."),r("rate_limited");return}f((t==null?void 0:t.error)||(t==null?void 0:t.message)||"Failed to create account"),r("error")}finally{N(!1)}};return e.jsx("div",{className:"min-h-screen bg-linear-to-br from-slate-900 via-brand-darker to-slate-900 flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-md w-full",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsx(ne,{size:"lg",variant:"light"})}),e.jsxs("div",{className:"bg-surface-solid rounded-2xl shadow-2xl overflow-hidden border border-edge",children:[e.jsx("div",{className:"bg-linear-to-r from-brand to-blue-400 px-6 py-3",children:e.jsx("p",{className:"text-white text-sm font-medium text-center",children:"AWS Marketplace Subscription"})}),e.jsxs("div",{className:"p-8",children:[x==="loading"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(w,{className:"w-12 h-12 text-brand animate-spin mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Verifying Your Subscription"}),e.jsx("p",{className:"text-fg-subtle",children:"Connecting to AWS Marketplace..."})]}),x==="email_required"&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-green-500/20 rounded-full mb-4",children:e.jsx(ae,{className:"w-6 h-6 text-status-green"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Subscription Verified"}
1),e.jsx("p",{className:"text-fg-subtle",children:"Your AWS Marketplace subscription has been confirmed. Enter your email to finish setup."})]}),e.jsxs("div",{className:"bg-green-500/10 border border-green-500/20 rounded-lg p-4 mb-6 space-y-2",children:[y.awsAccountId&&e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"text-status-green",children:"AWS Account"}),e.jsx("span",{className:"font-mono font-medium text-status-green",children:y.awsAccountId.replace(/(\d{4})(\d{4})(\d{4})/,"$1-$2-$3")})]}),y.tier&&e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"text-status-green",children:"Plan"}),e.jsx("span",{className:"font-semibold text-status-green",children:ie[y.tier]||y.tier})]})]}),e.jsxs("form",{onSubmit:Z,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-fg-subtle mb-2",children:"Email Address"}),e.jsx(T,{type:"email",id:"email",value:h,onChange:s=>{z(s.target.value),g("")},placeholder:"[email protected]",className:I("px-4 py-3 text-fg",v&&"border-red-500"),autoFocus:!0}),v&&e.jsx("p",{className:"mt-2 text-sm text-status-red",children:v})]}),e.jsx(b,{type:"submit",disabled:p,className:"w-full",children:p?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"w-4 h-4 animate-spin"}),"Sending Code..."]}):e.jsxs(e.Fragment,{children:["Complete Setup",e.jsx(V,{className:"w-4 h-4"})]})})]}),e.jsx("p",{className:"mt-4 text-xs text-gray-500 text-center",children:"We'll send a verification code to this email address."})]}),x==="verify_email"&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-brand/20 rounded-full mb-4",children:e.jsx(O,{className:"w-6 h-6 text-brand"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Check Your Email"}),e.jsxs("p",{className:"text-fg-subtle",children:["We sent a 6-digit verification code to"," ",e.jsx("strong",{className:"text-fg",children:h})]})]}),e.jsxs("form",{onSubmit:se,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"verificationCode",className:"block text-sm font-medium text-fg-subtle mb-2",children:"Verification Code"}),e.jsx(T,{type:"text",id:"verificationCode",value:P,onChange:s=>{const i=s.target.value.replace(/\D/g,"").slice(0,6);C(i),j("")},placeholder:"000000",className:I("px-4 py-4 text-fg text-center text-2xl font-mono tracking-widest",F&&"border-red-500"),autoFocus:!0,inputMode:"numeric",autoComplete:"one-time-code"}),F&&e.jsx("p",{className:"mt-2 text-sm text-status-red",children:F})]}),e.jsx(b,{type:"submit",disabled:P.length!==6||p,className:"w-full",children:p?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"w-4 h-4 animate-spin"}),"Creating Account..."]}):e.jsxs(e.Fragment,{children:["Verify & Create Account",e.jsx(V,{className:"w-4 h-4"})]})})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between text-sm",children:[e.jsx(b,{variant:"link",size:"sm",onClick:()=>{C(""),j(""),r(A?"email_required":"recovery_mode")},className:"text-gray-500 hover:text-fg-subtle p-0 h-auto",children:"â Change email"}),e.jsx(b,{variant:"link",size:"sm",onClick:async()=>{try{await D()}catch{j("Failed to resend code. Please try again.")}},disabled:M>0,className:"p-0 h-auto",children:M>0?`Resend in ${M}s`:"Resend code"})]})]}),x==="recovery_mode"&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-blue-500/20 rounded-full mb-4",children:e.jsx(L,{className:"w-6 h-6 text-status-blue"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Set Up Your Account"}),e.jsx("p",{className:"text-fg-subtle",children:"Enter your AWS account details to verify your subscription and create your Guardian Pro account."})]}),e.jsx("div",{className:"bg-blue-500/10 rounded-lg p-4 mb-6",children:e.jsxs("p",{className:"text-sm text-status-blue",children:[e.jsx("strong",{children:"Tip:"})," Your AWS Account ID can be found in the top-right corner of your AWS Console."]})}),e.jsxs("form",{onSubmit:ee,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"awsAccountId",className:"block text-sm font-medium text-fg-subtle mb-2",children:"AWS Account ID"}),e.jsxs("div",{className:"relative",children:[e.jsx(le,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-fg-subtle"}),e.jsx(T,{type:"text",id:"awsAccountId",value:k,onChange:s=>{const i=s.target.value.replace(/\D/g,"").slice(0,12);H(i),W("")},placeholder:"123456789012",className:I("pl-10 pr-4 py-3 text-fg",R&&"border-red-500"),autoFocus:!0})]}),R&&e.jsx("p",{className:"mt-2 text-sm text-status-red",children:R}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"The 12-digit ID of the AWS account that subscribed"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"recoveryEmail",className:"block text-sm font-medium text-fg-subtle mb-2",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(O,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-fg-subtle"}),e.jsx(T,{type:"email",id:"recoveryEmail",value:h,onChange:s=>{z(s.target.value),g("")},placeholder:"[email protected]",className:I("pl-10 pr-4 py-3 text-fg",v&&"border-red-500")})]}),v&&e.jsx("p",{className:"mt-2 text-sm text-status-red",children:v})]}),e.jsx(b,{type:"submit",disabled:p,className:"w-full",children:p?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"w-4 h-4 animate-spin"}),"Verifying..."]}):e.jsxs(e.Fragment,{children:["Verify & Create Account",e.jsx(V,{className:"w-4 h-4"})]})})]}),e.jsx("p",{className:"mt-4 text-xs text-gray-500 text-center",children:"We'll verify your subscription and send a verification code to your email."})]}),x==="processing"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(w,{className:"w-12 h-12 text-brand animate-spin mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Creating Your Account"}),e.jsx("p",{className:"text-fg-subtle",children:"Setting up your organization and sending login credentials..."})]}),x==="success"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-green-500/20 rounded-full mb-4",children:e.jsx(U,{className:"w-8 h-8 text-status-green"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Welcome to Guardian Pro!"}),e.jsx("p",{className:"text-fg-subtle mb-4",children:"Your account has been created successfully."}),Q&&e.jsx("div",{className:"bg-yellow-500/10 rounded-lg p-4 mb-4",children:e.jsx("p",{className:"text-sm text-status-yellow font-medium",children:"Your free trial is active. Explore all features for the next 14 days!"})}),e.jsx("div",{className:"bg-green-500/10 rounded-lg p-4",children:e.jsx("p",{className:"text-sm text-status-green",children:"Check your email for your temporary password."})}),e.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Redirecting to login..."})]}),x==="existing"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-blue-500/20 rounded-full mb-4",children:e.jsx(U,{className:"w-8 h-8 text-status-blue"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Welcome Back!"}),e.jsx("p",{className:"text-fg-subtle mb-4",children:"You already have a Guardian Pro account."}),e.jsx("p",{className:"text-sm text-gray-500",children:"Redirecting to login..."})]}),x==="no_subscription"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-yellow-500/20 rounded-full mb-4",children:e.jsx(Y,{className:"w-8 h-8 text-status-yellow"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"No Subscription Found"}),e.jsx("p",{className:"text-fg-subtle mb-4",children:S||"No active AWS Mar
1ketplace subscription found for this account."}),e.jsx("div",{className:"bg-yellow-500/10 rounded-lg p-4 mb-6",children:e.jsx("p",{className:"text-sm text-status-yellow",children:"Please ensure you've subscribed to Guardian Pro through AWS Marketplace before completing setup."})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{onClick:()=>{f(null),r("recovery_mode")},className:"w-full",children:"Try Again"}),e.jsx("a",{href:"mailto:[email protected]",className:"block w-full text-center py-3 px-4 border border-edge rounded-lg text-fg-subtle hover:bg-surface-inset transition",children:"Contact Support"})]})]}),x==="service_unavailable"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-orange-500/20 rounded-full mb-4",children:e.jsx(L,{className:"w-8 h-8 text-status-orange"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Temporarily Unavailable"}),e.jsx("p",{className:"text-fg-subtle mb-4",children:S||"The subscription verification service is temporarily unavailable."}),e.jsx("div",{className:"bg-orange-500/10 rounded-lg p-4 mb-6",children:e.jsx("p",{className:"text-sm text-status-orange",children:"This is usually resolved within a few minutes. Please try again shortly."})}),e.jsx(b,{onClick:()=>{f(null),r("recovery_mode")},className:"w-full",children:"Try Again"})]}),x==="rate_limited"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-red-500/20 rounded-full mb-4",children:e.jsx(Y,{className:"w-8 h-8 text-status-red"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Too Many Attempts"}),e.jsx("p",{className:"text-fg-subtle mb-4",children:S||"Please wait a few minutes before trying again."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{onClick:()=>{f(null),r("recovery_mode")},className:"w-full",children:"Try Again"}),e.jsx("a",{href:"mailto:[email protected]",className:"block w-full text-center py-3 px-4 border border-edge rounded-lg text-fg-subtle hover:bg-surface-inset transition",children:"Contact Support"})]})]}),x==="error"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-red-500/20 rounded-full mb-4",children:e.jsx(Y,{className:"w-8 h-8 text-status-red"})}),e.jsx("h2",{className:"text-xl font-semibold text-fg mb-2",children:"Something Went Wrong"}),e.jsx("p",{className:"text-fg-subtle mb-4",children:S||"An unexpected error occurred"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{onClick:()=>{f(null),r("recovery_mode")},className:"w-full",children:"Try Manual Setup"}),e.jsx("a",{href:"mailto:[email protected]",className:"block w-full text-center py-3 px-4 border border-edge rounded-lg text-fg-subtle hover:bg-surface-inset transition",children:"Contact Support"})]})]})]}),e.jsx("div",{className:"bg-surface-elevated px-8 py-4 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center justify-center gap-6 text-xs text-gray-500",children:[e.jsx("span",{children:"â Security Scanning"}),e.jsx("span",{children:"â Cost Optimization"}),e.jsx("span",{children:"â Auto Remediation"})]})})]}),e.jsxs("p",{className:"text-center mt-6 text-white/70 text-sm",children:["Need help?"," ",e.jsx("a",{href:"mailto:[email protected]",className:"text-brand-light hover:text-white hover:underline focus:outline-hidden focus:ring-2 focus:ring-brand rounded",children:"Contact Support"})]})]})})}export{pe 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.