1import{r as P,A as u,d as B,m as r,h as y,a6 as W,t as a,f as t,o as i,j as O,O as U,b as z,w as A,l as s,q as h,x as M,F as T,n as C,af as Z,_ as G,p as D,ay as tt,L as et,ac as st,I as nt,y as at,J as ot,az as it}from"./index-Ctdla73g.js";import{h as H,f as J,s as lt}from"./peak-rate-qZGUWdry.js";import{_ as rt}from"./PageContainer.vue_vue_type_script_setup_true_lang-dIEKrbJk.js";import{_ as ut}from"./PageHeader.vue_vue_type_script_setup_true_lang-CaaCE1m3.js";import{_ as E}from"./SectionHeading.vue_vue_type_script_setup_true_lang-DmcURhqE.js";import{_ as I}from"./Skeleton.vue_vue_type_script_setup_true_lang-DbKyNKZe.js";import{_ as V}from"./ErrorNotice.vue_vue_type_script_setup_true_lang-CUPWZiXW.js";import{p as ct}from"./payment-DkkT6FZD.js";import{e as Q}from"./apiError-szRqMG5e.js";import{g as dt}from"./subscriptions-Df8hLPd4.js";import{_ as X}from"./Card.vue_vue_type_script_setup_true_lang-qXnS5Q3F.js";import{f as Y}from"./useFormat-DdFkGdWY.js";import{c as pt}from"./currency-B17qpPdD.js";import{p as mt}from"./platformColors-RjqQIeOK.js";import{p as ft}from"./pricing-Dyvgt2ab.js";import{_ as gt}from"./index-ZdQrihZN.js";import{q as xt,e as _t,o as bt}from"./subscriptionView-BWtegmFG.js";import{S as vt}from"./sparkles-7B9nR_HL.js";import"./LoadingState.vue_vue_type_script_setup_true_lang-BIx0-_pT.js";import"./AlertTitle.vue_vue_type_script_setup_true_lang-DltRuN_m.js";import"./platforms-BPKrgTUe.js";import"./subscriptionQuota-RAAb1Khr.js";function ht(e){return Array.isArray(e)?e:e?e.split(` 2`).map(l=>l.trim()).filter(Boolean):[]}function yt(e){const l=Array.isArray(e)?e[0]:e;return typeof l=="string"?l:null}function kt(){const e=P([]),l=P(!1),n=P(null),c=P(!1);let o=0;async function d(){const m=++o;l.value=!0,n.value=null;try{const{data:f}=await ct.getCheckoutInfo();if(m!==o)return;const k=(f==null?void 0:f.plans)??[];e.value=k.filter(b=>b.for_sale).map(b=>({...b,features:ht(b.features)})).sort((b,q)=>b.sort_order-q.sort_order),c.value=!0}catch(f){if(m!==o)return;e.value=[],n.value=Q(f,"")}finally{m===o&&(l.value=!1)}}function p(m){const f=yt(m.group);if(!f)return[];const k=Number(f);return Number.isFinite(k)?e.value.filter(b=>b.group_id===k):[]}return{plans:e,loading:l,error:n,loaded:c,load:d,renewalTarget:p}}function wt(){const e=P([]),l=P(!1),n=P(null),c=P(!1),o=u(()=>e.value.filter(m=>m.status==="active"));let d=0;async function p(){const m=++d;l.value=!0,n.value=null;try{const f=await dt();if(m!==d)return;e.value=f??[],c.value=!0}catch(f){if(m!==d)return;e.value=[],n.value=Q(f,"")}finally{m===d&&(l.value=!1)}}return{items:e,active:o,loading:l,error:n,loaded:c,load:p}}function $t(e,l){const n=String(e.validity_unit||"day").trim().toLowerCase(),c=n.endsWith("s")?n.slice(0,-1):n,o=e.validity_days;return c==="month"?o===1?l("toknex.billing.plan.perMonth"):`${o}${l("toknex.billing.plan.months")}`:c==="week"?`${o}${l("toknex.billing.plan.weeks")}`:`${o}${l("toknex.billing.plan.days")}`}const K=B({__name:"PlatformPill",props:{platform:{}},setup(e){const l=e,n=u(()=>{const c=ft(l.platform??"");return{backgroundColor:`hsl(var(--chart-${c}) / 0.14)`,color:`hsl(var(--chart-${c}))`}});return(c,o)=>e.platform?(i(),r("span",{key:0,class:"inline-flex shrink-0 items-center rounded-full px-2.5 py-0.5 text-xs font-medium",style:W(n.value),"data-testid":"platform-pill"},a(t(mt)(e.platform)),5)):y("",!0)}}),St={class:"flex items-start justify-between gap-3"},qt={class:"min-w-0 space-y-1"},Pt=["title"],Tt={key:0,class:"line-clamp-2 text-sm text-muted-foreground","data-testid":"plan-card-description"},Ct={class:"flex shrink-0 flex-col items-end"},zt={class:"font-num text-2xl font-bold tracking-tight"},jt={class:"text-right text-xs text-muted-foreground"},At={key:0},Nt={key:0,class:"mt-1 flex items-center justify-end gap-1.5"},Rt={class:"font-num text-xs text-muted-foreground line-through"},Bt={class:"rounded-md bg-destructive/10 px-1.5 py-0.5 text-[11px] font-semibold text-destructive"},Lt={class:"grid grid-cols-2 gap-x-4 gap-y-2 rounded-xl bg-muted/50 px-4 py-3 text-xs"},Mt={class:"col-span-2 flex items-center justify-between gap-2 sm:col-span-1"},Ot={class:"text-muted-foreground"},Dt={class:"font-num font-medium"},Et={class:"col-span-2 flex items-center justify-between gap-2 sm:col-span-1"},It={class:"text-muted-foreground"},Vt={class:"font-medium"},Ft={key:0,class:"col-span-2 flex items-center justify-between gap-2"},Wt={class:"text-muted-foreground"},Ut={class:"text-right font-medium text-warning"},Gt={class:"text-muted-foreground"},Ht={class:"font-num font-medium"},Jt={key:1,class:"col-span-2 flex items-center justify-between gap-2"},Qt={class:"text-muted-foreground"},Xt={class:"font-medium"},Yt={key:2,class:"col-span-2 flex items-start justify-between gap-2"},Kt={class:"text-muted-foreground"},Zt={class:"flex flex-wrap justify-end gap-1"},te=["aria-label"],ee=B({__name:"PlanCard",props:{plan:{},isRenewal:{type:Boolean},tz:{}},emits:["select"],setup(e,{emit:l}){const n=e,c=l,{t:o}=O(),{lt:d,ltLines:p}=U(),m=u(()=>d(n.plan.description)),f=u(()=>p(n.plan.features.join(` 3`))),k=u(()=>pt(n.plan.currency||"USD")),b=u(()=>`${k.value}${n.plan.price}`),q=u(()=>`${k.value}${n.plan.original_price}`),x=u(()=>{const _=n.plan.original_price;if(!_||_<=0)return 0;const S=Math.round((1-n.plan.price/_)*100);return S>0?S:0}),w=u(()=>Number((n.plan.rate_multiplier??1).toPrecision(10))),g=u(()=>H(n.plan)),N=u(()=>J(n.plan,n.tz)),j=u(()=>$t(n.plan,o)),L=u(()=>[["daily",n.plan.daily_limit_usd],["weekly",n.plan.weekly_limit_usd],["monthly",n.plan.monthly_limit_usd]].filter(([,_])=>_!=null).map(([_,S])=>({kind:_,text:Y(S,"USD")}))),v={claude:"Claude",gemini_text:"Gemini",gemini_image:"Imagen"},R=u(()=>n.plan.group_platform!=="antigravity"?[]:(n.plan.supported_model_scopes??[]).map(_=>v[_]||_));return(_,S)=>(i(),z(t(X),{class:"flex flex-col gap-4 p-5","data-testid":"plan-card"},{default:A(()=>[s("div",St,[s("div",qt,[s("h3",{class:"line-clamp-2 break-words text-base font-semibold [overflow-wrap:anywhere]",title:e.plan.name},a(e.plan.name),9,Pt),m.value?(i(),r("p",Tt,a(m.value),1)):y("",!0)]),s("div",Ct,[h(K,{platform:e.plan.group_platform,class:"mb-1"},null,8,["platform"]),s("p",zt,a(b.value),1),s("p",jt,[e.plan.currency?(i(),r("span",At,a(e.plan.currency),1)):y("",!0),M("/ "+a(j.value),1)]),x.value?(i(),r("p",Nt,[s("span",Rt,a(q.value),1),s("span",Bt,a(t(o)("toknex.billing.plans.discount",{percent:x.value})),1)])):y("",!0)])]),s("dl",Lt,[s("div",Mt,[s("dt",Ot,a(t(o)("toknex.billing.plans.rate")),1),s("dd",Dt,"Ã"+a(w.value),1)]),s("div",Et,[s("dt",It,a(t(o)("toknex.billing.plans.validity")),1),s("dd",Vt,a(j.value),1)]),g.value?(i(),r("div",Ft,[s("dt",Wt,a(t(
3o)("toknex.billing.plans.peak")),1),s("dd",Ut,a(N.value),1)])):y("",!0),(i(!0),r(T,null,C(L.value,$=>(i(),r("div",{key:$.kind,class:"col-span-2 flex items-center justify-between gap-2 sm:col-span-1"},[s("dt",Gt,a(t(o)(`toknex.billing.subscription.${$.kind}`)),1),s("dd",Ht,a($.text),1)]))),128)),L.value.length?y("",!0):(i(),r("div",Jt,[s("dt",Qt,a(t(o)("toknex.billing.plans.quota")),1),s("dd",Xt,a(t(o)("toknex.billing.subscription.unlimited")),1)])),R.value.length?(i(),r("div",Yt,[s("dt",Kt,a(t(o)("toknex.billing.plans.supports")),1),s("dd",Zt,[(i(!0),r(T,null,C(R.value,$=>(i(),r("span",{key:$,class:"rounded-md bg-accent px-1.5 py-0.5 text-[11px] font-medium text-accent-foreground"},a($),1))),128))])])):y("",!0)]),f.value.length?(i(),r("ul",{key:0,class:"space-y-1.5","aria-label":t(o)("toknex.billing.plans.features")},[(i(!0),r(T,null,C(f.value,$=>(i(),r("li",{key:$,class:"flex items-start gap-2 text-sm"},[h(t(Z),{class:"mt-0.5 h-3.5 w-3.5 shrink-0 text-success"}),s("span",null,a($),1)]))),128))],8,te)):y("",!0),S[1]||(S[1]=s("div",{class:"flex-1"},null,-1)),h(t(G),{class:"w-full","data-testid":"plan-select",onClick:S[0]||(S[0]=$=>c("select",e.plan))},{default:A(()=>[M(a(e.isRenewal?t(o)("toknex.billing.plans.renew"):t(o)("toknex.billing.plans.subscribe")),1)]),_:1})]),_:1}))}}),se=["data-testid"],ne={class:"flex items-baseline justify-between gap-3"},ae={class:"text-sm font-medium"},oe={class:"font-num text-xs tabular-nums text-muted-foreground"},ie=["aria-label","aria-valuenow"],le={class:"text-xs text-muted-foreground"},re=B({__name:"WindowProgress",props:{quota:{}},setup(e){const{t:l}=O(),n=o=>Y(o,"USD"),c={success:"bg-success",warning:"bg-warning",destructive:"bg-destructive"};return(o,d)=>(i(),r("div",{class:"space-y-1.5","data-testid":`sub-window-${e.quota.kind}`},[s("div",ne,[s("span",ae,a(t(l)(`toknex.billing.subscription.${e.quota.kind}`)),1),s("span",oe,a(t(l)("toknex.billing.subscription.usageOf",{used:n(e.quota.used),limit:n(e.quota.limit)})),1)]),s("div",{class:"h-1.5 w-full overflow-hidden rounded-full bg-muted",role:"progressbar","aria-label":t(l)(`toknex.billing.subscription.${e.quota.kind}`),"aria-valuenow":Math.round(e.quota.percent),"aria-valuemin":"0","aria-valuemax":"100"},[s("div",{class:D(["h-full rounded-full transition-all",c[e.quota.tone]]),style:W({width:`${e.quota.percent}%`})},null,6)],8,ie),s("p",le,a(t(l)(e.quota.resetText.key,e.quota.resetText.params??{})),1)],8,se))}}),ue={class:"flex flex-wrap items-start justify-between gap-3"},ce={class:"min-w-0 space-y-1"},de={class:"flex flex-wrap items-center gap-2"},pe={class:"line-clamp-2 break-words text-base font-semibold [overflow-wrap:anywhere]"},me={key:0,class:"text-sm text-muted-foreground","data-testid":"subscription-group-description"},fe={class:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground"},ge={key:0,class:"text-warning"},xe={class:"flex shrink-0 items-center gap-2"},_e={class:"flex items-baseline justify-between gap-3 border-t border-border/60 pt-3 text-sm"},be={class:"text-muted-foreground"},ve=["title"],he={key:0,class:"space-y-3"},ye={key:1,class:"rounded-xl bg-success/10 px-4 py-5 text-center","data-testid":"subscription-unlimited"},ke={class:"text-sm font-medium text-success"},we={class:"mt-1 text-xs text-success/80"},$e={key:0,class:"mt-2 text-xs text-muted-foreground"},Se=B({__name:"SubscriptionCard",props:{sub:{},tz:{}},emits:["renew"],setup(e,{emit:l}){const n=e,c=l,{t:o}=O(),{lt:d}=U(),p=u(()=>{var v;return d((v=n.sub.group)==null?void 0:v.description)}),m={active:"success",expired:"secondary",revoked:"destructive",suspended:"warning"},f={muted:"text-foreground",warning:"text-warning",destructive:"text-destructive font-medium"},k=u(()=>{var v;return((v=n.sub.group)==null?void 0:v.platform)??""}),b=u(()=>{var v;return((v=n.sub.group)==null?void 0:v.name)||`Group #${n.sub.group_id}`}),q=u(()=>{var v;return Number((((v=n.sub.group)==null?void 0:v.rate_multiplier)??1).toPrecision(10))}),x=u(()=>H(n.sub.group)),w=u(()=>J(n.sub.group,n.tz)),g=u(()=>xt(n.sub)),N=u(()=>_t(n.sub)),j=u(()=>bt(n.sub)),L=u(()=>n.sub.expires_at?o("toknex.billing.subscription.expiresOn",{date:tt(new Date(n.sub.expires_at))}):void 0);return(v,R)=>(i(),z(t(X),{class:"flex flex-col gap-4 p-5","data-testid":"subscription-card"},{default:A(()=>[s("div",ue,[s("div",ce,[s("div",de,[s("h3",pe,a(b.value),1),h(K,{platform:k.value},null,8,["platform"])]),p.value?(i(),r("p",me,a(p.value),1)):y("",!0),s("div",fe,[s("span",null,a(t(o)("toknex.billing.plans.rate"))+": Ã"+a(q.value),1),x.value?(i(),r("span",ge,a(t(o)("toknex.billing.plans.peak"))+": "+a(w.value),1)):y("",!0)])]),s("div",xe,[h(t(gt),{variant:m[e.sub.status]},{default:A(()=>[M(a(t(o)(`toknex.billing.subscription.status.${e.sub.status}`)),1)]),_:1},8,["variant"]),e.sub.status==="active"?(i(),z(t(G),{key:0,size:"sm","data-testid":"subscription-renew",onClick:R[0]||(R[0]=_=>c("renew",e.sub.group_id))},{default:A(()=>[M(a(t(o)("toknex.billing.subscription.renew")),1)]),_:1})):y("",!0)])]),s("div",_e,[s("span",be,a(t(o)("toknex.billing.subscription.expires")),1),s("span",{class:D(f[
3N.value.tone]),title:L.value,"data-testid":"subscription-expiry"},a(t(o)(N.value.key,N.value.params??{})),11,ve)]),g.value.length?(i(),r("div",he,[(i(!0),r(T,null,C(g.value,_=>(i(),z(re,{key:_.kind,quota:_},null,8,["quota"]))),128))])):(i(),r("div",ye,[s("p",ke,"â "+a(t(o)("toknex.billing.subscription.unlimited")),1),s("p",we,a(t(o)("toknex.billing.subscription.unlimitedBody")),1),j.value?(i(),r("p",$e,a(t(o)(j.value.key,j.value.params)),1)):y("",!0)]))]),_:1}))}}),qe={class:"space-y-8"},Pe={class:"space-y-3"},Te={key:0,class:"grid gap-4 xl:grid-cols-2"},Ce={key:1,"data-testid":"subscriptions-error"},ze={key:2,"data-testid":"subscriptions-empty",class:"flex flex-col items-start gap-4 rounded-2xl border border-border/60 bg-card p-5 shadow-brand sm:flex-row sm:items-center"},je={class:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-accent text-accent-foreground"},Ae={class:"min-w-0 flex-1"},Ne={class:"text-sm font-semibold"},Re={class:"mt-0.5 text-sm text-muted-foreground"},Be=["href"],Le={key:3,class:"grid gap-4 xl:grid-cols-2"},Me={key:0,class:"grid gap-4 md:grid-cols-2 xl:grid-cols-3"},Oe={key:1,"data-testid":"plans-error"},De={key:2,"data-testid":"plans-empty",class:"rounded-2xl border border-dashed border-border/60 px-5 py-10 text-center text-sm text-muted-foreground"},Ee={key:3,class:"grid gap-4 md:grid-cols-2 xl:grid-cols-3"},F="toknex-plans",us=B({__name:"SubscriptionsPage",setup(e){const{t:l}=O(),n=at(),c=ot(),o=et(),d=wt(),p=kt(),m=u(()=>{var x;return lt((x=o.cachedPublicSettings)==null?void 0:x.server_utc_offset)}),f=u(()=>new Set(d.active.value.map(x=>x.group_id)));function k(x){c.push({path:"/topup",query:{plan:String(x.id)}})}function b(x){const w=p.renewalTarget({group:String(x)}),g=w.length===1?{plan:String(w[0].id)}:{group:String(x)};c.push({path:"/topup",query:g})}let q=!0;return st(()=>{q=!1}),nt(async()=>{if(await Promise.all([d.load(),p.load()]),!q)return;const x=p.renewalTarget(n.query);x.length===1&&c.replace({path:"/topup",query:{plan:String(x[0].id)}})}),(x,w)=>(i(),z(rt,null,{default:A(()=>[h(ut,{title:t(l)("toknex.billing.pages.subscriptions.title"),description:t(l)("toknex.billing.pages.subscriptions.description")},null,8,["title","description"]),s("div",qe,[s("section",Pe,[h(E,{title:t(l)("toknex.billing.subscription.current")},null,8,["title"]),t(d).loading.value&&!t(d).loaded.value?(i(),r("div",Te,[(i(),r(T,null,C(2,g=>h(t(I),{key:g,class:"h-40 w-full rounded-2xl"})),64))])):t(d).error.value!==null?(i(),r("div",Ce,[h(V,{message:t(d).error.value||t(l)("toknex.billing.subscription.loadFailed"),onRetry:w[0]||(w[0]=g=>t(d).load())},null,8,["message"])])):t(d).items.value.length?(i(),r("div",Le,[(i(!0),r(T,null,C(t(d).items.value,g=>(i(),z(Se,{key:g.id,sub:g,tz:m.value,onRenew:b},null,8,["sub","tz"]))),128))])):(i(),r("div",ze,[s("span",je,[h(t(vt),{class:"h-5 w-5"})]),s("div",Ae,[s("p",Ne,a(t(l)("toknex.billing.subscription.none")),1),s("p",Re,a(t(l)("toknex.billing.subscription.noneBody")),1)]),s("a",{"data-testid":"subscriptions-browse-plans",href:`#${F}`,class:D(t(it)({variant:"outline",size:"sm"}))},a(t(l)("toknex.billing.subscription.browsePlans")),11,Be)]))]),s("section",{id:F,class:"scroll-mt-24 space-y-3"},[h(E,{title:t(l)("toknex.billing.plans.title")},null,8,["title"]),t(p).loading.value&&!t(p).loaded.value?(i(),r("div",Me,[(i(),r(T,null,C(3,g=>h(t(I),{key:g,class:"h-64 w-full rounded-2xl"})),64))])):t(p).error.value!==null?(i(),r("div",Oe,[h(V,{message:t(p).error.value||t(l)("toknex.billing.plans.loadFailed"),onRetry:w[1]||(w[1]=g=>t(p).load())},null,8,["message"])])):t(p).plans.value.length?(i(),r("div",Ee,[(i(!0),r(T,null,C(t(p).plans.value,g=>(i(),z(ee,{key:g.id,plan:g,tz:m.value,"is-renewal":f.value.has(g.group_id),onSelect:k},null,8,["plan","tz","is-renewal"]))),128))])):(i(),r("p",De,a(t(l)("toknex.billing.plans.empty")),1))])])]),_:1}))}});export{us 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.