1import{a as o,j as e}from"./vendor-radix-DA_aSpdM.js";import{S as lt,q as dt,g as ut,u as mt,N as pt,e as ft,H as ht,L as me,E as xt,F as gt,C as We,B as Me,d as ne}from"./App-B5Gw_pr3.js";import{supabase as N}from"./client-CfsuD3lc.js";import{I as M}from"./input-Be8YzUgr.js";import{L as bt}from"./label-C-UxXqOz.js";import{e as Re}from"./edgeFunctionErrors-tek4dUTq.js";import{a as yt}from"./plausibleEvents-CSRfB-5I.js";import{B as vt}from"./billingDescriptor-D5uwSYYo.js";import{u as Ct}from"./useKeyboardVisibility-ByIRFiiI.js";import{f as kt,i as Ae,b as wt,a as Le,c as jt}from"./introOffers-Bz1q52IL.js";import{C as $e}from"./chevron-left-XoMKRW-P.js";import{L as Nt}from"./lock-BLxspFqh.js";import{C as St}from"./crown-D0qgxAkK.js";import{G as _t}from"./gem-v2N4VyXp.js";import{C as It}from"./chevron-right-Cmx-b24l.js";import{C as Be}from"./circle-alert-CMzDKVzP.js";import"./vendor-supabase-BQ1HIAaS.js";import"./index-C1MkrzIu.js";import"./sentry-kztijHPz.js";import"./platformErrorLogger-4hUhfrtL.js";import"./lazyWithRetry-DxnkR6rW.js";import"./edgeFunctionClient-Cktd4gAf.js";async function Et(t){try{let s={};try{s=lt()??{}}catch{}const{data:i,error:a}=await N.functions.invoke("checkout-telemetry",{body:{action:"start",productParam:t,attribution:s}});return a||!(i!=null&&i.attemptId)?null:String(i.attemptId)}catch{return null}}function Ye(t,s,i={}){t&&N.functions.invoke("checkout-telemetry",{body:{action:"step",attemptId:t,stage:"tokenize_failed",failureCode:s,...i}}).catch(()=>{})}function Pt(t,s,i={}){t&&N.functions.invoke("checkout-telemetry",{body:{action:"blocked",attemptId:t,reason:s,...i}}).catch(()=>{})}const pe=new Map;function Ue(t,s={}){const{isReady:i,timeoutMs:a=1e4}=s;if(i!=null&&i())return Promise.resolve();const S=pe.get(t);if(S)return S;const h=new Promise((v,C)=>{let _=!1,b=0,A=0;const L=W=>{_||(_=!0,window.clearTimeout(b),window.clearInterval(A),W?C(W):v())};b=window.setTimeout(()=>L(new Error(`Timed out loading ${t}`)),a),i&&(A=window.setInterval(()=>{i()&&L()},150));let $=document.querySelector(`script[src="${t}"]`);$||($=document.createElement("script"),$.src=t,$.async=!0,document.head.appendChild($)),$.addEventListener("load",()=>{(!i||i())&&L()}),$.addEventListener("error",()=>L(new Error(`Failed to load ${t}`)))});return pe.set(t,h),h.catch(()=>{pe.delete(t)}),h}const Tt=[{key:"firstName",label:"first name"},{key:"lastName",label:"last name"},{key:"nameOnCard",label:"name on card"},{key:"cardNumber",label:"card number"},{key:"expMonth",label:"expiry month"},{key:"expYear",label:"expiry year"},{key:"cvv2",label:"security code"},{key:"postalCode",label:"postal code"},{key:"country",label:"country"}];function Mt(t){return Tt.filter(({key:s})=>!String(t[s]??"").trim()).map(s=>s.label)}function Rt(t){const s=t.paymentMode==="saved"&&t.hasSavedMethod,i=!s&&t.turnstileStatus!=="disabled";if(i){if(t.turnstileStatus==="error")return{code:"verification_failed",message:"Checkout verification didn't load. Tap Retry, or disable your ad blocker for this page.",canRetryVerification:!0};if(t.turnstileStatus==="expired")return{code:"verification_expired",message:"Checkout verification expired. Tap Retry to refresh it.",canRetryVerification:!0}}if(!t.hasSelection)return{code:"no_plan",message:"Choose a plan to continue.",canRetryVerification:!1};if(!t.email.trim())return{code:"email_missing",message:"Enter your email to continue.",canRetryVerification:!1};if(!s){const a=Mt(t.card);if(a.length>0)return{code:"card_details_missing",message:a.length>2?"Complete your card and billing details to continue.":`Enter your ${a.join(" and ")} to continue.`,canRetryVerification:!1}}return i&&!t.turnstileToken?{code:"verification_loading",message:"Finishing checkout verificationâ¦",canRetryVerification:!1}:null}const At="https://js.ccbill.com/v1.13.1/ccbill-advanced-widget.js",Lt="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",fe="0x4AAAAAAD__jgtPlsqessgn".trim(),Fe=840;function $t(t){const s=t.filter(i=>Number.isFinite(i.priceCents)&&i.priceCents>0);return s.find(i=>i.packageId==="premium-monthly")??s.filter(i=>i.kind==="subscription").sort((i,a)=>i.priceCents-a.priceCents||i.packageId.localeCompare(a.packageId))[0]??s.sort((i,a)=>i.priceCents-a.priceCents||i.packageId.localeCompare(a.packageId))[0]??null}const F=t=>`$${(t/100).toFixed(2)}`;function Bt(t){return t?t.startsWith("platinum-")?"platinum":t.startsWith("premium-")?"premium":null:null}function Yt(t){return t?t.endsWith("-yearly")?"yearly":t.endsWith("-monthly")?"monthly":null:null}function Oe(t){return t==="platinum"?2:t==="premium"?1:0}function Ft(t){if(!t)return null;const s=t.trim().toLowerCase().replace(/-/g,"_");return/^(premium|platinum)_(monthly|yearly)$/.test(s)?s:null}function Ot(t){return new Promise(s=>window.setTimeout(s,t))}function qt(t){var h,v,C,_,b,A;if(!t||typeof t!="object")return!1;const s=t,i=((C=(v=(h=s.data)==null?void 0:h.response)==null?void 0:v.raw)==null?void 0:C.toLowerCase())??"",a=((b=(_=s.error)==null?void 0:_.message)==null?void 0:b.toLowerCase())??"",S=(A=s.data)==null?void 0:A.status;return S===504||typeof S=="number"&&S>=500||i.includes("timeout")||a.includes("timeout")||a.includes("service unavailable")}const Dt=()=>{var t;return!!((t=window.ccbill)!=null&&t.CCBillAdvancedWidget)},Vt=()=>!!window.turnstile,qe=2e4,Kt=3;async function De(){try{const t=await fetch("https://api4.ipify.org?format=json",{cache:"no-store"});if(!t.ok)return;const s=await t.json();return typeof(s==null?void 0:s.ip)=="string"&&/^\d{1,3}(\.\d{1,3}){3}$/.test(s.ip)?s.ip:void 0}catch{return}}function he(t){const s=document.querySelector('[data-ccbill="ipAddress"]');s&&t&&(s.value=t)}const fr=()=>{const t=dt(),s=ut(),i=Ct(),{user:a,isSuperAdmin:S}=mt(),{isSubscribed:h,plan:v,billingInterval:C,accessTier:_,isLoading:b}=pt(),[A]=ft(),[L,$]=o.useState([]),[W,ze]=o.useState(!0),[se,Ge]=o.useState(null),[H,ie]=o.useState(null),[xe,U]=o.useState(!1),[ae,X]=o.useState("idle"),[ge,be]=o.useState(null),[ye,ve]=o.useState(),[I,oe]=o.useState(null),[E,J]=o.useState("new"),[Ce,Qe]=o.useState([]),[ce,He]=o.useState({}),[Z,z]=o.useState(null),[ee,G]=o.useState(fe?"loading":"disabled"),[Xe,Je]=o.useState(0),V=o.useRef(null),ke=o.useRef(!1),Ze=o.useCallback(n=>{z(n),G("ready")},[]),et=o.useCallback(()=>{z(null),G(n=>n==="disabled"?n:"loading")},[]),tt=o.useCallback(()=>{z(null),G(n=>n==="disabled"?n:"expired")},[]),rt=o.useCallback(()=>{z(null),G(n=>n==="disabled"?n:"error")},[]),[m,we]=o.useState({firstName:"",lastName:"",email:"",postalCode:"",country:"US",nameOnCard:"",cardNumber:"",expMonth:"",expYear:"",cvv2:""}),P=n=>u=>we(g=>({...g,[n]:u.target.value}));o.useEffect(()=>{a!=null&&a.email&&we(n=>n.email?n:{...n,email:a.email??""})},[a]),o.useEffect(()=>{let n=!1;return De().then(u=>{!n&&u&&(ve(u),he(u))}),()=>{n=!0}},[]),o.useEffect(()=>{yt("Checkout Start",{product:A.get("product")||"unknown"}),!ke.current&&(ke.current=!0,Et(A.get("product")).then(n=>{V.current=n}))},[]),o.useEffect(()=>{let n=!1;if(!a){oe(null),J("new");return}return(async()=>{const{data:u}=await N.functions.invoke("ccbill-payment-methods");if(n)return;const g=(u==null?void 0:u.defaultPaymentMethod)??null;oe(g),J(g?"saved":"new")})(),()=>{n=!0}},[a]),o.useEffect(()=>{let n=!1;return(async()=>{try{const[u,g,w,y,B]=await Promise.all([N.from("gem_packages").select("id,name,gems,price_cents,bonus_percent,display_order").eq("is_active",!0).order("display_order"),N.from("products").select("id,name,slug,type,is_active,display_order,metadata").eq("type","subscription").eq("is_active",!0).order("display_order"),N.from("prices").select("id,product_id,amount,currency,interval,is_active").eq("is_active",!0).eq("currency","usd"),N.from("feature_tier_config").select("feature_key,feature_name,free_limit,premium_limit,platinum_limit,limit_unit,display_order").eq("is_active",!0).order("display_order"),kt()]);if(n)return;if(u.error||g.error||w.error)throw u.error||g.error||w.error;y.error||Qe(y.data??[]),He(B);const q=new Map;for(const d of w.data??[]){const c=q.get(d.product_id)??[];c.push(d),q.set(d.product_id,c)}const Q=(u.data??[]).map(d=>{const c=d.bonus_percent??0,p=d.gems+Math.floor(d.gems*c/100);return{key:`gems:${d.id}`,kind:"gems",title:d.name,subtitle:`${p} gems${c?` · incl. +${c}% bonus`:""}`,priceCents:d.price_cents,packageId:`gems-${d.gems}`,selectId:d.id,gems:p}}),K=[...(g.data??[]).flatMap(d=>(q.get(d.id)??[]).filter(c=>c.amount>0).map(c=>{var p,f;return{key:`sub:${c.id}`,kind:"subscription",title:d.name,subtitle:`${F(c.amount)} / ${c.interval}`,priceCents:c.amount,packageId:`${d.slug}-${c.interval==="year"?"yearly":"monthly"}`,selectId:c.id,periodDays:c.interval==="year"?365:30,recurring:!0,monthlyGems:Number(((p=d.metadata)==null?void 0:p.monthly_gems)??0)||void 0,tier:(f=d.metadata)==null?void 0:f.tier}})),...Q];$(K);const j=A.get("product"),l=K.find(d=>d.packageId===j||d.selectId===j),D=$t(K);ie((l==null?void 0:l.key)??(D==null?void 0:D.key)??null),!l&&K.length>1&&U(!0)}catch{n||Ge("Couldn't load plans. Please refresh and try again.")}finally{n||ze(!1)}})(),()=>{n=!0}},[]);const r=o.useMemo(()=>L.find(n=>n.key===H)??null,[L,H]),T=o.useMemo(()=>(r==null?void 0:r.kind)==="subscription"?Ae(ce,r.packageId,r.priceCents):null,[ce,r]),k=ae!=="idle",te=Bt(r==null?void 0:r.packageId),je=Yt(r==null?void 0:r.packageId),Ne=!S&&["free","no_access"].includes(_??"free");o.useEffect(()=>{(r==null?void 0:r.kind)==="gems"&&Ne&&!b&&t("/checkout?product=premium-monthly",{replace:!0})},[r,Ne,b,t]);const Se=o.useMemo(()=>
1{if((r==null?void 0:r.kind)!=="subscription")return[];const n=r.tier??(r.packageId.startsWith("platinum")?"platinum":"premium");if(n!=="premium"&&n!=="platinum")return[];const u=Ce.find(w=>w.feature_key==="uncensored_mode");return[...(u?Number(n==="platinum"?u.platinum_limit:u.premium_limit):0)!==0?["Uncensored mode included"]:[],"Unlimited text chat â no gem spending",...r.monthlyGems?[`${r.monthlyGems.toLocaleString()} gems added now, then every month`]:[]]},[r,Ce]),nt=!!((r==null?void 0:r.kind)==="subscription"&&h&&te&&(Oe(te)>Oe(v)||te===v&&C==="monthly"&&je==="yearly")),st=!!((r==null?void 0:r.kind)==="subscription"&&h&&te===v&&je===C),O=!!fe,x=o.useMemo(()=>Rt({hasSelection:!!r,email:m.email,paymentMode:E,hasSavedMethod:!!I,card:{firstName:m.firstName,lastName:m.lastName,nameOnCard:m.nameOnCard,cardNumber:m.cardNumber,expMonth:m.expMonth,expYear:m.expYear,cvv2:m.cvv2,postalCode:m.postalCode,country:m.country},turnstileStatus:O?ee:"disabled",turnstileToken:Z}),[r,m,E,I,O,ee,Z]),_e=!!x||k||b,le=()=>{z(null),G(O?"loading":"disabled"),Je(n=>n+1)},re=o.useRef(new Set);o.useEffect(()=>{if(!x||k||re.current.size>=Kt||re.current.has(x.code))return;const n=x.code,u=window.setTimeout(()=>{re.current.has(n)||(re.current.add(n),Pt(V.current,n,{blockedMs:qe,turnstileStatus:O?ee:"disabled"}))},qe);return()=>window.clearTimeout(u)},[x,k,O,ee]);const de=async()=>{a!=null&&a.id&&await Promise.all([s.invalidateQueries({queryKey:["subscription",a.id]}),s.invalidateQueries({queryKey:["access-tier",a.id]}),s.refetchQueries({queryKey:["subscription",a.id]}),s.refetchQueries({queryKey:["access-tier",a.id]})])},it=async n=>{if(!(a!=null&&a.id))return!1;const u=Ft(n);if(!u)return!1;X("confirming");for(let g=0;g<30;g+=1){await de();const{data:w,error:y}=await N.from("subscriptions").select("id").eq("user_id",a.id).eq("plan",u).in("status",["active","trialing","past_due"]).gt("current_period_end",new Date().toISOString()).limit(1).maybeSingle();if(!y&&(w!=null&&w.id))return!0;await Ot(2e3)}return await de(),!1},Ie=async()=>{var n,u,g,w;if(!(!r||k||b)){be(null);try{if(!Number.isFinite(r.priceCents)||r.priceCents<=0)throw new Error("This product is not available for purchase. Please choose a paid plan.");if(st)throw new Error("You already have this subscription plan active.");if(E==="new"&&O&&!Z)throw new Error("Please complete checkout verification before continuing.");const y=r.kind==="subscription"?"subscription":"single_purchase";X(E==="saved"?"charging":"tokenizing");const B=ye??await De();B&&(ve(B),he(B));let q;const Q=E==="saved"?I==null?void 0:I.id:void 0;if(!Q){const{data:l,error:D}=await N.functions.invoke("ccbill-create-frontend-token",{body:{flow:y,clientIp:B,checkoutAttemptId:V.current,turnstileToken:Z}});if(D||!(l!=null&&l.accessToken)||!(l!=null&&l.frontendClientId))throw new Error(D?await Re(D):"Couldn't start checkout. Please try again in a moment.");he(l.clientIp||B),await Ue(At,{isReady:Dt}).catch(()=>{throw new Error("Secure payment form failed to load. Please retry.")});const d=window.ccbill;if(!(d!=null&&d.CCBillAdvancedWidget))throw new Error("Secure payment form failed to load. Please retry.");try{const c={frontendClientId:l.frontendClientId,clientAccnum:l.clientAccnum,clientSubacc:l.clientSubacc,flow:y};console.info("[CCBillCheckout] Starting Advanced Widget tokenization",{...c,hasAccessToken:!!l.accessToken});const f=await new d.CCBillAdvancedWidget(l.frontendClientId).createPaymentToken(l.accessToken,l.clientAccnum,l.clientSubacc),Y=f&&typeof f.json=="function"?await f.json():f;q=Y==null?void 0:Y.paymentTokenId,q||console.warn("[CCBillCheckout] Advanced Widget returned no paymentTokenId",{responseType:(n=f==null?void 0:f.constructor)==null?void 0:n.name,payloadKeys:Y&&typeof Y=="object"?Object.keys(Y):[]})}catch(c){let p=null;if(c instanceof Response){const ct=c.clone();let ue=null;try{ue=await ct.json()}catch{ue=await c.clone().text().catch(()=>null)}p={status:c.status,statusText:c.statusText,url:c.url,body:ue}}const f=p!=null&&p.body&&typeof p.body=="object"&&!Array.isArray(p.body)?p.body:null,Y={frontendClientId:l.frontendClientId,clientAccnum:l.clientAccnum,clientSubacc:l.clientSubacc,flow:y};
1throw console.error("[CCBillCheckout] Advanced Widget tokenization failed",{errorName:c instanceof Error?c.name:void 0,errorMessage:c instanceof Error?c.message:String(c),ccbillResponse:p,...Y}),Ye(V.current,"widget_exception",{ccbillResponse:p,ccbillErrorCode:typeof(f==null?void 0:f.errorCode)=="string"?f.errorCode:null,ccbillErrorMessage:typeof(f==null?void 0:f.generalMessage)=="string"?f.generalMessage:null,ccbillErrorId:typeof(f==null?void 0:f.id)=="string"?f.id:null,httpStatus:typeof(p==null?void 0:p.status)=="number"?p.status:null,ccbillUrl:typeof(p==null?void 0:p.url)=="string"?p.url:null,tokenizationContext:Y}),new Error("Your card couldn't be verified. Please check the details and try again.")}if(!q)throw Ye(V.current,"no_payment_token",{tokenizationContext:{frontendClientId:l.frontendClientId,clientAccnum:l.clientAccnum,clientSubacc:l.clientSubacc,flow:y}}),new Error("Your card was not accepted. Please try a different card.")}X("charging");const Te=m.cardNumber.replace(/\D/g,"").slice(-4)||void 0,K=Q?{savedPaymentTokenId:Q,clientIp:B}:{paymentTokenId:q,clientIp:B,cardLast4:Te,expMonth:Number(m.expMonth),expYear:Number(m.expYear)},j=r.kind==="gems"?await N.functions.invoke("ccbill-charge-token",{body:{...K,checkoutAttemptId:V.current,flow:"single_purchase",currencyCode:Fe,packageId:r.packageId}}):await N.functions.invoke("ccbill-create-subscription",{body:{...K,checkoutAttemptId:V.current,currencyCode:Fe,packageId:r.packageId}});if(j.error||!((u=j.data)!=null&&u.success)){const l=j.error?await Re(j.error):typeof((g=j.data)==null?void 0:g.error)=="string"?j.data.error:void 0;if(r.kind==="subscription"&&qt(j)){if(await it(r.packageId)){t(`/billing/success?ref=${encodeURIComponent(r.packageId)}`);return}throw new Error("Payment status could not be confirmed yet. Please refresh in a moment or contact [email protected] before trying again.")}throw new Error(l||"Payment was declined. Please try another card or contact [email protected].")}(w=j.data)!=null&&w.savedPaymentMethod&&(oe(j.data.savedPaymentMethod),J("saved")),a!=null&&a.id&&await de(),t(`/billing/success?ref=${encodeURIComponent(r.packageId)}`)}catch(y){X("idle"),be((y==null?void 0:y.message)||"Something went wrong. Please try again."),E==="new"&&O&&le()}}},Ee=L.filter(n=>n.kind==="subscription"),Pe=L.filter(n=>n.kind==="gems"),at=k?ae==="tokenizing"?"Verifying cardâ¦":ae==="confirming"?"Confirming paymentâ¦":"Processingâ¦":T?`Pay ${wt(T)}`:r?`Pay ${F(r.priceCents)}${r.recurring?" / "+(r.periodDays===365?"yr":"mo"):""}`:"Select a plan",ot=()=>{k||(window.history.length>1?t(-1):t("/pricing"))};return e.jsxs("div",{className:"min-h-screen bg-background pt-6 sm:pt-10 px-4 pb-28 md:pb-10",children:[e.jsxs(ht,{children:[e.jsx("title",{children:"Checkout | Person.ai"}),e.jsx("meta",{name:"robots",content:"noindex"})]}),e.jsxs("div",{className:"mx-auto max-w-md",children:[e.jsxs("button",{type:"button",onClick:ot,disabled:k,className:"mb-4 inline-flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx($e,{className:"w-4 h-4"}),"Back to app"]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-1",children:"Checkout"}),e.jsxs("p",{className:"text-muted-foreground mb-6 flex items-center gap-1.5 text-sm",children:[e.jsx(Nt,{className:"w-3.5 h-3.5"})," Card details go straight to CCBill â never to our servers."]}),W?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground py-20 justify-center",children:[e.jsx(me,{className:"w-5 h-5 animate-spin"})," Loading plansâ¦"]}):se?e.jsx("div",{className:"text-center text-destructive py-20",children:se}):xe?e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>U(!1),className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground mb-4",children:[e.jsx($e,{className:"w-4 h-4"})," Back"]}),e.jsxs("div",{className:"space-y-6",children:[Ee.length>0&&e.jsx(Ve,{title:"Membership",icon:e.jsx(St,{className:"w-4 h-4"}),children:Ee.map(n=>e.jsx(Ke,{p:n,selected:H===n.key,intro:Ae(ce,n.packageId,n.priceCents),onSelect:()=>{ie(n.key),U(!1)}},n.key))}),Pe.length>0&&e.jsx(Ve,{title:"Gems (one-time)",icon:e.jsx(_t,{className:"w-4 h-4"}),children:Pe.map(n=>e.jsx(Ke,{p:n,selected:H===n.key,onSelect:()=>{ie(n.key),U(!1)}},n.key))})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>U(!0),className:"w-full flex items-center justify-between rounded-lg border border-border px-4 py-3 mb-4 text-left hover:border-primary/50 transition",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Selected plan"}),e.jsxs("div",{className:"font-medium text-foreground truncate",children:[r?r.title:"Cho
1ose a plan",r&&e.jsxs("span",{className:"text-muted-foreground font-normal",children:[" · ",T?Le(T):`${F(r.priceCents)}${r.recurring?`/${r.periodDays===365?"yr":"mo"}`:""}`]})]})]}),e.jsxs("span",{className:"text-sm text-primary font-medium shrink-0 ml-3 inline-flex items-center gap-0.5",children:["Change ",e.jsx(It,{className:"w-4 h-4"})]})]}),e.jsx(xt,{children:e.jsxs(gt,{className:"pt-6 space-y-3",children:[(r==null?void 0:r.kind)==="subscription"&&Se.length>0&&e.jsxs("div",{className:"space-y-2 rounded-md border border-primary/20 bg-primary/5 px-3 py-3",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Included with your plan"}),Se.map(n=>e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(We,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-primary","aria-hidden":"true"}),e.jsx("span",{children:n})]},n))]}),e.jsx(R,{label:"Email",children:e.jsx(M,{"data-ccbill":"email",type:"email",value:m.email,onChange:P("email"),autoComplete:"email"})}),E==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(R,{label:"First name",children:e.jsx(M,{"data-ccbill":"firstName",value:m.firstName,onChange:P("firstName"),autoComplete:"given-name"})}),e.jsx(R,{label:"Last name",children:e.jsx(M,{"data-ccbill":"lastName",value:m.lastName,onChange:P("lastName"),autoComplete:"family-name"})})]}),e.jsx(R,{label:"Name on card",children:e.jsx(M,{"data-ccbill":"nameOnCard",value:m.nameOnCard,onChange:P("nameOnCard"),autoComplete:"cc-name"})}),e.jsx(R,{label:"Card number",children:e.jsx(M,{"data-ccbill":"cardNumber",inputMode:"numeric",value:m.cardNumber,onChange:P("cardNumber"),autoComplete:"cc-number",placeholder:"â¢â¢â¢â¢ â¢â¢â¢â¢ â¢â¢â¢â¢ â¢â¢â¢â¢"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(R,{label:"MM",children:e.jsx(M,{"data-ccbill":"expMonth",inputMode:"numeric",maxLength:2,value:m.expMonth,onChange:P("expMonth"),placeholder:"MM",autoComplete:"cc-exp-month"})}),e.jsx(R,{label:"YYYY",children:e.jsx(M,{"data-ccbill":"expYear",inputMode:"numeric",maxLength:4,value:m.expYear,onChange:P("expYear"),placeholder:"YYYY",autoComplete:"cc-exp-year"})}),e.jsx(R,{label:"CVV",children:e.jsx(M,{"data-ccbill":"cvv2",inputMode:"numeric",maxLength:4,value:m.cvv2,onChange:P("cvv2"),placeholder:"CVV",autoComplete:"cc-csc"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(R,{label:"Postal code",children:e.jsx(M,{"data-ccbill":"postalCode",value:m.postalCode,onChange:P("postalCode"),autoComplete:"postal-code"})}),e.jsx(R,{label:"Country",children:e.jsx(M,{"data-ccbill":"country",value:m.country,onChange:P("country"),maxLength:2,autoComplete:"country"})})]})]}),e.jsx("input",{type:"hidden","data-ccbill":"ipAddress",value:ye??"",readOnly:!0}),E==="new"&&O&&e.jsx(Wt,{siteKey:fe,resetKey:Xe,onToken:Ze,onReset:et,onExpire:tt,onError:rt}),E==="new"&&(x==null?void 0:x.canRetryVerification)&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-200",children:[e.jsx(Be,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsx("span",{className:"flex-1",children:x.message}),e.jsx("button",{type:"button",onClick:le,className:"shrink-0 font-semibold underline underline-offset-2 hover:text-amber-100",children:"Retry"})]}),I&&e.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"Saved payment method"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Card ending in ",I.last4??"saved",I.expMonth&&I.expYear?` · Expires ${String(I.expMonth).padStart(2,"0")}/${I.expYear}`:""]})]}),e.jsx("button",{type:"button",disabled:k,onClick:()=>J(E==="saved"?"new":"saved"),className:"text-xs font-medium text-primary hover:underline disabled:cursor-not-allowed disabled:opacity-50",children:E==="saved"?"Use new card":"Use saved"})]})}),nt&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:["Your unused ",C==="yearly"?"yearly":"current"," membership value will be credited toward the first charge, and your previous subscription will be cancelled after the upgrade succeeds."]}),ge&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx(Be,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsx("span",{children:ge})]}),e.jsxs(Me,{className:ne("w-full mt-1 md:flex",i?"flex":"hidden"),disabled:_e,onClick:Ie,children:[k&&e.jsx(me,{className:"w-4 h-4 mr-2 animate-spin"}),at]}),x&&!k&&e.jsx("p",{className:ne("md:block text-xs text-muted-foreground text-center",i?"block":"hidden"),role:"status",children:x.message}),e.jsxs("p",{className:"text-[11px] text-muted-foreground text-center",children:[T?`${jt(T)} Access continues to the end of the paid period. `:r!=null&&r.recurring?"Recurring billing until cancelled. Cancel anytime in Settings or via CCBill support; access continues to the end of the paid period. ":"","Billed by CCBill, our payment processor. ",vt," ","Fulfillment confirms automatically after payment."," ",e.jsx("a",{href:"/subscription-terms",className:"underline hover:text-foreground",children:"Subscription terms"})]})]})})]})]}),!i&&!W&&!se&&!xe&&e.jsx("div",{className:"md:hidden fixed inset-x-0 bottom-0 z-40 border-t border-border bg-background/95 backdrop-blur px-4 py-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))]",children:e.jsxs("div",{className:"mx-auto max-w-md",children:[x&&!k&&e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs",role:"status",children:[e.jsx("span",{className:ne("flex-1",x.canRetryVerification?"text-amber-200":"text-muted-foreground"),children:x.message}),x.canRetryVerification&&e.jsx("button",{type:"button",onClick:le,className:"shrink-0 font-semibold text-amber-200 underline underline-offset-2",children:"Retry"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:r?r.title:"Select a plan"}),r&&e.jsx("div",{className:"text-xs text-muted-foreground",children:T?Le(T):`${F(r.priceCents)}${r.recurring?` / ${r.periodDays===365?"yr":"mo"}`:""}`})]}),e.jsx(Me,{className:"h-11 px-6 shrink-0",disabled:_e,onClick:Ie,children:k?e.jsx(me,{className:"w-4 h-4 animate-spin"}):T?`Pay ${F(T.introCents)}`:`Pay${r?" "+F(r.priceCents):""}`})]})]})})]})},Ve=({title:t,icon:s,children:i})=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground mb-2",children:[s,t]}),e.jsx("div",{className:"space-y-2",children:i})]}),Ke=({p:t,selected:s,onSelect:i,intro:a})=>e.jsxs("button",{type:"button",onClick:i,className:ne("w-full flex items-center justify-between rounded-lg border px-4 py-3 text-left transition",s?"border-primary ring-1 ring-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t.title}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.subtitle})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a?e.jsxs("span",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground line-through",children:F(a.recurringCents)}),e.jsx("span",{className:"font-semibold text-foreground",children:F(a.introCents)})]}):e.jsx("span",{className:"font-semibold text-foreground",children:F(t.priceCents)}),s&&e.jsx(We,{className:"w-4 h-4 text-primary"})]})]}),Wt=({siteKey:t,resetKey:s,onToken:i,onReset:a,onExpire:S,onError:h})=>{const v=o.useRef(null);return o.useEffect(()=>{let C=!1,_;return a(),Ue(Lt,{isReady:Vt}).then(()=>
1{if(!C){if(!v.current||!window.turnstile){h();return}try{_=window.turnstile.render(v.current,{sitekey:t,action:"ccbill_checkout",theme:"dark",callback:i,"expired-callback":S,"error-callback":h})}catch{h()}}}).catch(()=>{C||h()}),()=>{var b;C=!0,_&&((b=window.turnstile)!=null&&b.remove)&&window.turnstile.remove(_)}},[a,S,h,i,s,t]),e.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-3",children:[e.jsx("div",{ref:v,className:"min-h-[65px]"}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:"Verification protects checkout from automated card testing."})]})},R=({label:t,children:s})=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(bt,{className:"text-xs text-muted-foreground",children:t}),s]});export{fr 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.