1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11461],{11461:(e,t,a)=>{a.r(t),a.d(t,{default:()=>ep});var s=a(95155),n=a(19749),i=a(12115),l=a(85626),r=a(71945),c=a(73549),o=a.n(c),d=a(82222),m=a(76248),u=a(68128),h=a(93833),x=a(90942),p=a(95585),g=a(12642),f=a(56571),j=a(48340),b=a(45522),y=a(38469),N=a(82058),w=a(19088),v=a(46574),S=a(69250),_=a(60061),C=a(10049),k=a(71460),A=a(72764),P=a(17466),$=a(8191),E=a(58580),I=a(66622),M=a(52173),U=a(14871),F=a(41143),L=a(53877),T=a(35391),q=a(75680),Y=a(3304),B=a(82903),O=a(72772),D=a(91316),R=a(16060),K=a(9313);function z(e){return e.toLocaleString()}function X(e){return 1e6>Math.abs(e)?e.toLocaleString():new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(e)}function W(e,t){return new Intl.NumberFormat("en-US",{style:"currency",currency:(t||"usd").toUpperCase(),maximumFractionDigits:2*(e%100!=0)}).format(e/100)}function Q(e){let t,a,i=(0,n.c)(5),{label:l,rows:r}=e,c=void 0===r?3:r;return i[0]!==c?(t=(0,s.jsx)("div",{className:"space-y-2","aria-busy":"true",children:Array.from({length:c},J)}),i[0]=c,i[1]=t):t=i[1],i[2]!==l||i[3]!==t?(a=(0,s.jsx)(E.XY,{label:l,children:t}),i[2]=l,i[3]=t,i[4]=a):a=i[4],a}function J(e,t){return(0,s.jsx)(E.Bd,{className:0===t?"h-11 w-full":"h-9 w-full"},t)}function Z(e){let t,a,l,r,c,d,x,p,g,f,j,b,y,N,w,v,S,_,C,k,A,P,$,M,F,L,T,q,Y,B=(0,n.c)(86),{isLoading:O,data:D,isPaidPlan:K,usageData:W}=e,[J,Z]=i.useState(!1);if(O){let e;return B[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)(Q,{label:"Credit Balance"}),B[0]=e):e=B[0],e}if(!D?.data){let e,t,a;return B[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)(m.A,{}),B[1]=e):e=B[1],B[2]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsx)(E.XY,{label:"Credit Balance",children:(0,s.jsx)(E.B,{icon:e,title:"No subscription found",description:"Choose a plan to start your subscription.",action:(0,s.jsx)(E.CS,{variant:"primary",onClick:()=>Z(!0),children:"View Plans"})})}),B[2]=t):t=B[2],B[3]!==J?(a=(0,s.jsxs)(s.Fragment,{children:[t,(0,s.jsx)(U.Z,{open:J,onOpenChange:Z})]}),B[3]=J,B[4]=a):a=B[4],a}let V=D.data,H=V.credits.subscription+V.credits.purchased+V.credits.bonus,ee=(V.plan?.name||"").toLowerCase(),et="free"===ee||"starter"===ee,ea=W?.data?.total_credits_used,es=et&&"number"==typeof ea?ea:V.credits.used_this_period;B[5]!==H||B[6]!==es?(t=H>0?Math.round(es/H*100):0,B[5]=H,B[6]=es,B[7]=t):t=B[7];let en=100-t<20,ei=Math.max(0,V.credits.subscription-V.credits.used_this_period),el=Math.min(V.credits.purchased,V.credits.total_available),er=et?0:Math.min(ei,V.credits.total_available-el),ec=Math.max(0,V.credits.total_available-el-er),eo=et?"Starter":"Bonus",ed=Math.max(0,V.credits.pending_reserved??0),em="number"==typeof V.credits.spendable?V.credits.spendable:V.credits.total_available,eu=et?H:V.credits.subscription;B[8]!==eu||B[9]!==es?(a=eu>0?Math.min(100,Math.round(es/eu*100)):0,B[8]=eu,B[9]=es,B[10]=a):a=B[10];let eh=a,ex=eu>0&&es>=eu,ep=String(V.billing_cycle||"").toLowerCase(),eg=et?"Used this period":"Monthly allowance",ef=ex?"crit":en?"warn":"accent";B[11]!==K?(l=K?(0,s.jsx)(o(),{href:"/account/billing#credits",className:(0,E.io)("secondary","sm"),children:"Buy more credits"}):void 0,B[11]=K,B[12]=l):l=B[12];let ej="pro"===ee||"elite"===ee||"team"===ee||"enterprise"===ee?`${V.plan.display_name} plan`:`${V.plan.display_name||"Starter"} plan`;B[13]!==ej?(r=(0,s.jsx)("p",{className:"truncate text-[12.5px] font-semibold leading-tight text-dash-ink",children:ej}),B[13]=ej,B[14]=r):r=B[14],B[15]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(u.A,{className:"h-3 w-3 flex-none","aria-hidden":!0}),B[15]=c):c=B[15];let eb="annual"===ep||"yearly"===ep?"Credits refresh":"Renews";B[16]!==V.period.end?(d=new Date(V.period.end).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),B[16]=V.period.end,B[17]=d):d=B[17],B[18]!==eb||B[19]!==d?(x=(0,s.jsxs)("p",{className:"mt-1 flex items-center gap-1.5 text-[11px] leading-none text-dash-muted",children:[c,(0,s.jsxs)("span",{children:[eb," ",d]})]}),B[18]=eb,B[19]=d,B[20]=x):x=B[20],B[21]!==r||B[22]!==x?(p=(0,s.jsxs)("div",{className:"min-w-0",children:[r,x]}),B[21]=r,B[22]=x,B[23]=p):p=B[23];let ey=en?"warn":"neutral";B[24]!==V.credits.total_available?(g=z(V.credits.total_available),B[24]=V.credits.total_available,B[25]=g):g=B[25];let eN=`${g} credits available`;B[26]!==V.credits.total_available?(f=X(V.credits.total_available),B[26]=V.credits.total_available,B[27]=f):f=B[27],B[28]!==eN||B[29]!==f?(j=(0,s.jsxs)("span",{title:eN,children:[f," available"]}),B[28]=eN,B[29]=f,B[30]=j):j=B[30],B[31]!==ey||B[32]!==j?(b=(0,s.jsx)(E.xt,{tone:ey,className:"tabular-nums",children:j}),B[31]=ey,B[32]=j,B[33]=b):b=B[33],B[34]!==p||B[35]!==b?(y=(0,s.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[p,b]}),B[34]=p,B[35]=b,B[36]=y):y=B[36],B[37]!==eg?(N=(0,s.jsx)("span",{className:"text-[11.5px] text-dash-muted",children:eg}),B[37]=eg,B[38]=N):N=B[38],B[39]!==es?(w=z(es),B[39]=es,B[40]=w):w=B[40],B[41]!==eu?(v=z(eu),B[41]=eu,B[42]=v):v=B[42];let ew=`${w} of ${v} used`;return B[43]!==es?(S=X(es),B[43]=es,B[44]=S):S=B[44],B[45]!==eu?(_=X(eu),B[45]=eu,B[46]=_):_=B[46],B[47]!==ew||B[48]!==S||B[49]!==_?(C=(0,s.jsxs)("span",{className:"font-mono text-[10.5px] tabular-nums text-dash-ink",title:ew,children:[S," / ",_]}),B[47]=ew,B[48]=S,B[49]=_,B[50]=C):C=B[50],B[51]!==N||B[52]!==C?(k=(0,s.jsxs)("div",{className:"mb-1.5 flex items-baseline justify-between gap-3",children:[N,C]}),B[51]=N,B[52]=C,B[53]=k):k=B[53],B[54]!==eg||B[55]!==eh||B[56]!==ef?(A=(0,s.jsx)(E.PJ,{value:eh,label:eg,tone:ef}),B[54]=eg,B[55]=eh,B[56]=ef,B[57]=A):A=B[57],B[58]!==ex||B[59]!==el?(P=ex&&el>0&&(0,s.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-dash-muted",children:`Monthly allowance spent. Running on ${X(el)} purchased ${(0,R.Tp)(el)}. Purchased credits do not expire.`}),B[58]=ex,B[59]=el,B[60]=P):P=B[60],B[61]!==k||B[62]!==A||B[63]!==P?($=(0,s.jsxs)("div",{children:[k,A,P]}),B[61]=k,B[62]=A,B[63]=P,B[64]=$):$=B[64],B[65]!==eo||B[66]!==ec||B[67]!==el||B[68]!==er?(M=(0,s.jsx)(I.nh,{items:[{label:"Plan",full:"Subscription",value:er},{label:"Bought",full:"Purchased",value:el},{label:eo,full:eo,value:ec}].map(G)}),B[65]=eo,B[66]=ec,B[67]=el,B[68]=er,B[69]=M):M=B[69],B[70]!==y||B[71]!==$||B[72]!==M?(F=(0,s.jsxs)(E.O3,{className:"space-y-3.5",children:[y,$,M]}),B[70]=y,B[71]=$,B[72]=M,B[73]=F):F=B[73],B[74]!==en?(L=en&&(0,s.jsx)(E.YN,{tone:"warn",icon:(0,s.jsx)(h.A,{}),children:"Credits running low. Consider upgrading or purchasing more."}),B[74]=en,B[75]=L):L=B[75],B[76]!==ed||B[77]!==em?(T=ed>0&&(0,s.jsx)("div",{"data-testid":"billing-reserved-notice",children:(0,s.jsxs)(E.YN,{tone:"info",icon:(0,s.jsx)(u.A,{}),children:[(0,s.jsxs)("span",{className:"font-semibold",children:[z(ed)," credits reserved"]}),` by a request that hasn't settled, leaving ${z(em)} spendable right now. Reserved credits are released automatically â you don't need to buy more.`]}
1)}),B[76]=ed,B[77]=em,B[78]=T):T=B[78],B[79]!==F||B[80]!==L||B[81]!==T?(q=(0,s.jsxs)("div",{className:"space-y-2",children:[F,L,T]}),B[79]=F,B[80]=L,B[81]=T,B[82]=q):q=B[82],B[83]!==l||B[84]!==q?(Y=(0,s.jsx)(E.XY,{label:"Credit Balance",action:l,children:q}),B[83]=l,B[84]=q,B[85]=Y):Y=B[85],Y}function G(e){return{key:e.full,label:e.label,value:X(e.value),title:`${e.full}: ${z(e.value)} credits`}}function V(e){let t,a=(0,n.c)(28),{isLoading:l,data:r}=e,[c,o]=i.useState(!1);if(l){let e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)(Q,{label:"Usage this period",rows:1}),a[0]=e):e=a[0],e}let d=r?.data;if(a[1]!==c||a[2]!==d?.stats||a[3]!==d?.total_credits_used){let e,n,i,l,r,m,u,h,g,f,j,b=d?.stats||[];a[5]===Symbol.for("react.memo_cache_sentinel")?(e={memory:"Memory",search:"Search",graph:"Graph",context:"Context",embeddings:"Search processing",planning:"Planning",project:"Project",session:"Session",other:"Other"},a[5]=e):e=a[5];let y=e;a[6]===Symbol.for("react.memo_cache_sentinel")?(n={memory:"Store and retrieve decisions, preferences, and notes across sessions",search:"Semantic and keyword search across your codebase and memory",graph:"Code dependency analysis, impact tracing, and relationship mapping",context:"Smart context retrieval and conversation history management",embeddings:"Search processing for semantic understanding of your code",planning:"Implementation planning and task breakdown assistance",project:"Project indexing, file analysis, and codebase management",session:"Session management, compression, and state tracking",other:"Miscellaneous operations"},a[6]=n):n=a[6];let N=n;a[7]===Symbol.for("react.memo_cache_sentinel")?(i=(e,t)=>{let a=function(e){return"ai.context"===e||"ai.context_enhanced"===e||"ai.context_pack"===e?"context":"ai.embeddings"===e?"embeddings":"ai.plan"===e?"planning":e.split(".")[0]||"other"}(t.operation);return e[a]||(e[a]={count:0,credits:0,operations:[]}),e[a].count=e[a].count+t.count,e[a].credits=e[a].credits+t.credits,e[a].operations.push(t),e},a[7]=i):i=a[7];let w=b.reduce(i,{}),v=Object.keys(w).length;a[8]===Symbol.for("react.memo_cache_sentinel")?(l=()=>o(ee),a[8]=l):l=a[8];let S=d?.total_credits_used||0;a[9]!==S?(r=z(S),a[9]=S,a[10]=r):r=a[10],a[11]!==r?(m=(0,s.jsx)("span",{className:"text-[12.5px] font-semibold tabular-nums text-dash-ink",children:r}),a[11]=r,a[12]=m):m=a[12];let _=1===v?"category":"categories";a[13]!==v||a[14]!==m||a[15]!==_?(u=(0,s.jsxs)("span",{className:"min-w-0 flex-1 text-[12px] leading-snug text-dash-muted",children:[m," ","credits across ",v," ",_]}),a[13]=v,a[14]=m,a[15]=_,a[16]=u):u=a[16];let C=c?"Hide":"Details",k=c&&"rotate-180";a[17]!==k?(h=(0,$.cn)("h-3.5 w-3.5 transition-transform duration-200",k),a[17]=k,a[18]=h):h=a[18],a[19]!==h?(g=(0,s.jsx)(x.A,{"aria-hidden":!0,className:h}),a[19]=h,a[20]=g):g=a[20],a[21]!==C||a[22]!==g?(f=(0,s.jsxs)("span",{className:"flex flex-none items-center gap-1 text-[11.5px] font-semibold text-dash-muted",children:[C,g]}),a[21]=C,a[22]=g,a[23]=f):f=a[23],a[24]!==c||a[25]!==u||a[26]!==f?(j=(0,s.jsxs)("button",{type:"button","data-testid":"billing-usage-toggle","aria-expanded":c,"aria-controls":"billing-usage-details",onClick:l,className:"-mx-1.5 flex min-h-11 w-[calc(100%+0.75rem)] items-center gap-3 rounded-[6px] px-1.5 py-2 text-left transition-colors hover:bg-dash-fill-raised focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-dash-accent-ring sm:min-h-9",children:[u,f]}),a[24]=c,a[25]=u,a[26]=f,a[27]=j):j=a[27],t=(0,s.jsxs)(E.XY,{label:"Usage this period",testId:"billing-usage-card",children:[j,c?(0,s.jsx)("div",{id:"billing-usage-details","data-testid":"billing-usage-details",className:"mt-1 border-t border-dash-hair pt-1 duration-200 animate-in fade-in-0 slide-in-from-top-1",children:0===Object.keys(w).length?(0,s.jsx)("p",{className:"py-6 text-center text-[12px] text-dash-muted",children:"No usage recorded this period"}):(0,s.jsx)(K.Bc,{children:(0,s.jsx)(E.Wi,{children:Object.entries(w).sort(H).map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{role:"listitem",className:"min-w-0 border-b border-dash-hair py-2 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-1 text-[12.5px] font-semibold leading-tight text-dash-ink",children:[(0,s.jsx)("span",{className:"truncate",children:y[t]||t}),(0,s.jsxs)(K.m_,{children:[(0,s.jsx)(K.k$,{asChild:!0,children:(0,s.jsx)(p.A,{className:"h-3 w-3 flex-none cursor-help text-dash-faint"})}),(0,s.jsx)(K.ZI,{side:"top",className:"max-w-[250px] border-dash-line bg-dash-surface text-dash-ink shadow-none",children:(0,s.jsx)("p",{className:"text-[11.5px]",children:N[t]||"Operations in this category"})})]})]}),(0,s.jsxs)("span",{className:"flex-none text-[12px] tabular-nums text-dash-ink",children:[z(a.credits)," credits"]})]}),(0,s.jsxs)("div",{className:"mt-px text-[11px] text-dash-muted",children:[z(a.count)," operations"]}),a.operations.length>0&&(0,s.jsx)("div",{className:"mt-1.5 space-y-0.5 pl-3",children:a.operations.map(e=>(0,s.jsxs)("div",{className:"flex min-w-0 justify-between gap-3 font-mono text-[10.5px] text-dash-muted",children:[(0,s.jsx)("span",{className:"truncate",children:function(e){let t={"ai.context_pack":"ContextPack","project.index_file":"Project.IngestAndIndex"};return t[e]?t[e]:e.split(".").map(et).join(".")}(e.operation)}),(0,s.jsxs)("span",{className:"flex-none tabular-nums",children:[z(e.credits)," (",z(e.count),")"]})]}
1,e.operation))})]},t)})})})}):null]}),a[1]=c,a[2]=d?.stats,a[3]=d?.total_credits_used,a[4]=t}else t=a[4];return t}function H(e,t){return t[1].credits-e[1].credits}function ee(e){return!e}function et(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,"")}function ea(e){let t,a=(0,n.c)(3),{isLoading:i,data:l}=e;if(i){let e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)(Q,{label:"Recent activity"}),a[0]=e):e=a[0],e}if(a[1]!==l?.data?.transactions){let e=l?.data?.transactions||[];t=(0,s.jsx)(E.XY,{label:"Recent activity",hint:"Credit usage and purchases",children:0===e.length?(0,s.jsx)(E.B,{title:"No operations yet"}):(0,s.jsxs)(I.KQ,{label:"Recent activity",testId:"billing-transactions-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)(I.C2,{className:"w-[38%] sm:w-[19%]",children:"Date"}),(0,s.jsx)(I.C2,{className:"sm:w-[136px]",children:"Type"}),(0,s.jsx)(I.C2,{className:"hidden sm:table-cell",children:"Description"}),(0,s.jsx)(I.C2,{numeric:!0,className:"w-[72px] sm:w-[84px]",children:"Amount"}),(0,s.jsx)(I.C2,{numeric:!0,className:"hidden sm:table-cell sm:w-[88px]",children:"Balance"})]})}),(0,s.jsx)("tbody",{children:e.slice(0,10).map(es)})]})}),a[1]=l?.data?.transactions,a[2]=t}else t=a[2];return t}function es(e){return(0,s.jsxs)(I.oA,{children:[(0,s.jsx)(I.Cy,{className:"truncate whitespace-nowrap text-[11.5px] text-dash-muted tabular-nums",children:new Date(e.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}),(0,s.jsx)(I.Cy,{children:(0,s.jsx)(E.xt,{className:"max-w-full capitalize",children:(0,s.jsx)("span",{className:"truncate",children:e.transaction_type.replace("_"," ")})})}),(0,s.jsx)(I.Cy,{className:"hidden truncate whitespace-nowrap text-dash-ink-soft sm:table-cell",children:e.description||"-"}),(0,s.jsxs)(I.Cy,{numeric:!0,className:(0,$.cn)("whitespace-nowrap font-semibold",e.amount>0?"text-dash-ink":"text-dash-muted"),children:[e.amount>0?"+":"",z(e.amount)]}),(0,s.jsx)(I.Cy,{numeric:!0,className:"hidden whitespace-nowrap text-dash-muted sm:table-cell",children:z(e.balance_after)})]},e.id)}function en(e){let t,a,i,l,r,c,d,m,u=(0,n.c)(24),{isLoading:h,data:x,currentPlan:p}=e,g=(0,D.xY)();if(h){let e;return u[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)(Q,{label:"Available plans"}),u[0]=e):e=u[0],e}let f=x?.data;if(u[1]!==p||u[2]!==f||u[3]!==g){let e,n,c=(Array.isArray(f)?f:Array.isArray(f?.items)?f.items:Array.isArray(f?.data)?f.data:[]).filter(ei);u[9]!==p?(e=e=>{e!==p&&("pro"===e||"elite"===e?(0,P.c)({checkoutUrl:(0,k.my)(e,"monthly"),planDisplayName:e.charAt(0).toUpperCase()+e.slice(1)}):"team"===e&&window.location.assign((0,k.my)(e,"monthly")))},u[9]=p,u[10]=e):e=u[10];let o=e;t=E.XY,l="Available plans",r="Upgrade to get more credits. Paid plans also include Unlimited Projects (no project limits).",a="flex flex-col",u[11]!==p||u[12]!==o||u[13]!==g?(n=e=>{let t=e.name===p,a=!t,n=(0,Y.E9)(e.name,g&&!t),i=(0,q.Gs)(e.name)?(0,q.cl)(e.name):"Price locks while active";return(0,s.jsxs)("div",{onClick:()=>o(e.name),className:(0,$.cn)((0,I.W4)({interactive:a,selected:t}),"items-start py-2.5"),children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-[12.5px] font-semibold leading-tight text-dash-ink",children:e.display_name}),t&&(0,s.jsx)(E.xt,{tone:"accent",children:"Current"})]}),(0,s.jsxs)("p",{className:"mt-px truncate text-[11px] leading-snug text-dash-muted",children:[z(e.monthly_credits)," credits/mo"]})]}),(0,s.jsx)("div",{className:"flex-none text-right",children:n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-[12.5px] font-semibold leading-tight tabular-nums text-dash-ink",children:[null!==n.was&&(0,s.jsxs)(O.Mz,{className:"mr-1.5 text-[11px] font-medium",children:["$",n.was]}),"$",n.price,n.suffix]}),null!==n.was&&(0,s.jsx)(D.h$,{as:"p",className:"text-[11px] font-medium",children:(0,s.jsx)("span",{className:"cs-sale-note",children:"Limited-time sale"})}),"team"===e.name&&(0,s.jsx)("p",{className:"text-[11px] text-dash-muted",children:"3-seat minimum"}),i?(0,s.jsx)("p",{className:"text-[11px] text-dash-muted",children:i}):null,a&&(0,s.jsx)("p",{className:"text-[11px] font-semibold text-dash-accent-ink",children:"Click to upgrade"})]}):null})]},e.id)},u[11]=p,u[12]=o,u[13]=g,u[14]=n):n=u[14],i=c.map(n),u[1]=p,u[2]=f,u[3]=g,u[4]=t,u[5]=a,u[6]=i,u[7]=l,u[8]=r}else t=u[4],a=u[5],i=u[6],l=u[7],r=u[8];return u[15]!==a||u[16]!==i?(c=(0,s.jsx)("div",{className:a,children:i}),u[15]=a,u[16]=i,u[17]=c):c=u[17],u[18]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,s.jsx)(o(),{href:"/pricing",className:(0,E.io)("secondary","md","w-full sm:w-auto"),children:"View All Plans"}),(0,s.jsx)("p",{className:"text-[11px] leading-snug text-dash-muted",children:"Credit packs are available on Pro, Elite, and Team. Upgrade to top up without waiting for your monthly refill."})]}),u[18]=d):d=u[18],u[19]!==t||u[20]!==l||u[21]!==r||u[22]!==c?(m=(0,s.jsxs)(t,{label:l,hint:r,children:[c,d]}),u[19]=t,u[20]=l,u[21]=r,u[22]=c,u[23]=m):m=u[23],m}function ei(e){return e.is_active&&"enterprise"!==e.name&&e.price_monthly_cents>0}function el(e,t){let a=t[e]?.monthly;if(a){let t="team"===e?"&quantity=3":"";return`/checkout?priceId=${encodeURIComponent(a)}&mode=subscription${t}`}return(0,k.my)(e,"monthly")}let er={headline:"Choose more room to work",benefits:["Pro: 25,000 Context Credits/month","Elite: 100,000 Context Credits/month","Paid plans include unlimited projects","Every plan includes full graphs and Enhanced Context"]},ec={headline:"Unlock the full graph",benefits:["100,000 Context Credits/month (4x Pro)","Full knowledge graph","Enhanced Context with intent detection","Context compaction awareness"]},eo={headline:"Collaborate at scale",benefits:["200,000 Context Credits/seat (pooled)","Shared team knowledge graph","Admin roles + team permissions","Team-wide context sharing"]};function ed({isPaidPlan:e,userEmail:t,planName:a,planId:n,onUpgradeSuccess:l,annualSaving:r}){let[c,o]=i.useState(!1),[d,m]=i.useState(null),[u,x]=i.useState(null),[p,N]=i.useState(!1),[w,v]=i.useState(!1),[S,_]=i.useState({}),[C,A]=i.useState(null),[$,I]=i.useState(null),F=function(e,t=!1){let a,s="starter"===(a=(e||"").toLowerCase())||"free"===a||""===a?"free":a,n=[],i=e=>{let a=(0,B.Oc)(e,t);return{price:a.monthly,was:a.onSale?a.listMonthly:null,priceSuffix:q.DL[e].suffix}};return"free"===s?(n.push({name:"pro",displayName:"Pro",...i("pro"),helperText:"25,000 Context Credits/month"}),n.push({name:"elite",displayName:"Elite",...i("elite"),helperText:"100,000 Context Credits/month and full graph"})):"pro"===s?(n.push({name:"elite",displayName:"Elite",...i("elite"),helperText:"4x Pro operations plus full graph"}),n.push({name:"team",displayName:"Team",...i("team"),helperText:"Shared team workspace \xb7 3-seat minimum"})):"elite"===s&&n.push({name:"team",displayName:"Team",...i("team"),helperText:"Shared team workspace \xb7 3-seat minimum"}),n}(n,(0,D.xY)($)),L=F.length>0,T=e?"pro"===n?ec:"elite"===n?eo:null:er;i.useEffect(()=>{fetch("/api/billing/config").then(e=>e.json()).then(e=>{e.prices&&_(e.prices),I(!!e.sale)}).catch(e=>console.error("Failed to fetch billing config:",e))},[]);let Y=async()=>
1{if(!t)throw Error("Unable to load user email");if(!C?.priceId)throw Error("Plan pricing not configured");o(!0),m(null),x(null);try{let e=await fetch("/api/billing/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("auth_token")??""}`},body:JSON.stringify({customerEmail:t,newPriceId:C.priceId})}),a=await e.json();if(!e.ok)throw Error(a.error||"Failed to upgrade subscription");x(a.message||`Successfully upgraded to ${C.displayName}!`),l?.()}catch(e){throw m(e instanceof Error?e.message:"An error occurred"),e}finally{o(!1)}};return(0,s.jsx)("div",{id:"billing-upgrade-options","data-testid":"billing-upgrade-options",className:"scroll-mt-4",children:(0,s.jsxs)(E.XY,{label:e?"Manage subscription":"Upgrade your plan",hint:e?`You're on the ${a||"paid"} plan`:T?.headline||"Unlock more credits and features",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[r?.eligible&&(0,s.jsxs)(E.O3,{"data-testid":"billing-switch-to-annual",className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("p",{className:"text-[12.5px] font-semibold leading-tight text-dash-ink",children:["Pay yearly and save ",r.savingPercent,"%"]}),(0,s.jsx)("p",{className:"mt-1 text-[11.5px] leading-snug text-dash-muted",children:`${W(r.savingCents,r.currency)} a year against ${W(r.twelveMonthsCents,r.currency)} in monthly payments. You keep your current rate, and credits still refresh every month.`})]}),(0,s.jsx)(E.CS,{variant:"secondary",className:"w-full sm:w-auto",onClick:()=>window.location.assign((0,k.my)(r.plan,"annual",r.quantity)),children:"Switch to annual billing"})]}),T&&(L||!e)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("ul",{className:"grid gap-x-4 gap-y-1 sm:grid-cols-2",children:T.benefits.map((e,t)=>(0,s.jsxs)("li",{className:"flex min-w-0 items-start gap-2 text-[12px] leading-snug text-dash-ink-soft",children:[(0,s.jsx)(g.A,{"aria-hidden":!0,className:"mt-0.5 h-3 w-3 flex-none text-dash-accent-ink"}),(0,s.jsx)("span",{className:"min-w-0",children:e})]},t))}),(0,s.jsx)("p",{className:"mt-2 text-[11px] leading-snug text-dash-muted",children:"Your current rate is locked while your subscription stays active."})]}),e&&!L&&(0,s.jsx)("p",{className:"text-[12px] leading-snug text-dash-muted",children:"Manage your subscription, update payment method, view invoices, or cancel your plan."}),d&&(0,s.jsx)(E.YN,{tone:"crit",icon:(0,s.jsx)(h.A,{}),children:d}),u&&(0,s.jsx)(E.YN,{tone:"ok",icon:(0,s.jsx)(f.A,{}),children:u}),F.some(e=>null!=e.was)&&(0,s.jsxs)(D.h$,{as:"div",className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[(0,s.jsx)(O.ds,{}),(0,s.jsx)("span",{className:"cs-sale-note",children:D.RC})]}),F.length>0&&(0,s.jsx)(E.Wi,{children:F.map((t,a)=>(0,s.jsx)(E.ic,{title:t.displayName,badges:(0,s.jsxs)("span",{className:"text-[12px] tabular-nums text-dash-ink-soft",children:[null!=t.was&&(0,s.jsxs)(O.Mz,{className:"mr-1",children:["$",t.was]}),"$",t.price,t.priceSuffix]}),meta:t.helperText,trailing:(0,s.jsxs)(E.CS,{size:"sm",variant:0===a?"primary":"secondary",onClick:()=>(t=>{let a=S[t.name]?.monthly;if(!e)return void(0,P.c)({checkoutUrl:el(t.name,S),planDisplayName:t.name.charAt(0).toUpperCase()+t.name.slice(1)});if(a){A({...t,priceId:a}),N(!0);return}window.location.assign(el(t.name,S))})(t),disabled:c,children:[c&&C?.name===t.name?(0,s.jsx)(j.A,{className:"animate-spin"}):(0,s.jsx)(b.A,{}),"Upgrade to ",t.displayName]})},t.name))}),!e&&(0,s.jsxs)(E.CS,{onClick:()=>v(!0),className:"w-full sm:w-auto",variant:"secondary",children:[(0,s.jsx)(y.A,{}),"Compare All Plans"]})]}),(0,s.jsx)(U.Z,{open:w,onOpenChange:v}),t&&C&&(0,s.jsx)(M.R,{open:p,onOpenChange:N,onConfirm:Y,userEmail:t,targetPriceId:C.priceId,targetPlanName:C.displayName,source:"billing_page"})]})})}function em({userEmail:e,onSeatsChanged:t}){let[a,n]=i.useState(!0),[l,r]=i.useState(!1),[c,o]=i.useState(null),[d,m]=i.useState(null),[u,x]=i.useState(3),[p,f]=i.useState(3),[b,y]=i.useState(null);i.useEffect(()=>{e&&(n(!0),fetch(`/api/billing/seats?email=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${localStorage.getItem("auth_token")??""}`}}).then(e=>e.json()).then(e=>{e.error?o(e.error):(x(e.seats),f(e.seats),y({pricePerSeat:e.pricePerSeat,operationsPerSeat:e.operationsPerSeat}))}).catch(e=>{console.error("Failed to fetch seat info:",e),o("Failed to load seat information")}).finally(()=>n(!1)))},[e]);let S=async()=>
1{if(e&&p!==u){r(!0),o(null),m(null);try{let a=await fetch("/api/billing/seats",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("auth_token")??""}`},body:JSON.stringify({customerEmail:e,newSeatCount:p})}),s=await a.json();if(!a.ok)throw Error(s.error||"Failed to update seats");m(s.message),x(p),t?.()}catch(e){o(e instanceof Error?e.message:"An error occurred")}finally{r(!1)}}},_=p!==u,C=b?.pricePerSeat||20,k=b?.operationsPerSeat||2e5;return a?(0,s.jsx)(Q,{label:"Manage team seats"}):(0,s.jsxs)(E.XY,{label:"Manage team seats",hint:"Add or remove seats from your team subscription",testId:"billing-seats",children:[(0,s.jsxs)(E.Wi,{children:[(0,s.jsx)(E.ic,{title:"Number of seats",trailing:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(E.CS,{size:"icon",onClick:()=>f(Math.max(3,p-1)),disabled:p<=3||l,"aria-label":"Decrease seats",children:(0,s.jsx)(N.A,{})}),(0,s.jsx)("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:p,onChange:e=>{let t=e.target.value.replace(/\D/g,"");""===t?f(3):f(parseInt(t,10))},onBlur:()=>{f(Math.min(1e4,Math.max(3,p)))},disabled:l,"aria-label":"Number of seats",className:(0,$.cn)(E.cx,"w-16 text-center font-semibold tabular-nums")}),(0,s.jsx)(E.CS,{size:"icon",onClick:()=>f(Math.min(1e4,p+1)),disabled:p>=1e4||l,"aria-label":"Increase seats",children:(0,s.jsx)(w.A,{})})]})}),(0,s.jsx)(E.ic,{title:"Context Credits/month",meta:_?`Was ${z(u*k)}`:void 0,trailing:(0,s.jsx)("span",{className:"text-[12.5px] font-semibold tabular-nums text-dash-ink",children:z(p*k)})}),(0,s.jsx)(E.ic,{title:"Monthly total",meta:_?`Was $${u*C}/mo`:void 0,trailing:(0,s.jsxs)("span",{className:"text-[12.5px] font-semibold tabular-nums text-dash-ink",children:["$",p*C,"/mo"]})})]}),(0,s.jsxs)("div",{className:"mt-3 space-y-2",children:[c&&(0,s.jsx)(E.YN,{tone:"crit",icon:(0,s.jsx)(h.A,{}),children:c}),d&&(0,s.jsx)(E.YN,{tone:"ok",icon:(0,s.jsx)(g.A,{}),children:d}),(0,s.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[(0,s.jsx)("p",{className:"text-[11px] leading-snug text-dash-muted",children:"Minimum 3 seats required. Changes are prorated to your billing cycle."}),(0,s.jsx)(E.CS,{variant:"primary",onClick:S,disabled:!_||l,className:"w-full sm:w-auto",children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j.A,{className:"animate-spin"}),"Updating..."]}):_?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(v.A,{}),p>u?`Add ${p-u} Seat${p-u>1?"s":""}`:`Remove ${u-p} Seat${u-p>1?"s":""}`]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(v.A,{}),"No changes"]})})]})]})]})}function eu(){let e,t=(0,n.c)(1);if(t[0]===Symbol.for("react.memo_cache_sentinel")){let a=(0,A.Uu)().map(ex);e=(0,s.jsx)("div",{id:"credits",className:"scroll-mt-4",children:(0,s.jsx)(E.XY,{label:"Buy credits",hint:"Purchase additional credits that never expire",children:(0,s.jsx)("div",{className:"flex flex-col",children:a.map(eh)})})}),t[0]=e}else e=t[0];return e}function eh(e){return(0,s.jsxs)(o(),{href:(0,k.kN)(e.id),className:(0,I.W4)({interactive:!0,selected:e.popular}),children:[(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsxs)("span",{className:"truncate text-[12.5px] font-semibold leading-tight text-dash-ink",children:[z(e.credits)," Credits"]}),e.popular&&(0,s.jsx)(E.xt,{tone:"accent",children:"Popular"})]}),(0,s.jsxs)("span",{className:"mt-px block truncate text-[11px] leading-snug text-dash-muted tabular-nums",children:[e.perCredit,"/credit",e.discount&&(0,s.jsxs)("span",{className:"text-dash-ink-soft",children:[" \xb7 Save ",e.discount]})]})]}),(0,s.jsxs)("span",{className:"flex flex-none items-center gap-2.5",children:[(0,s.jsxs)("span",{className:"text-[12.5px] font-semibold tabular-nums text-dash-ink",children:["$",e.price]}),(0,s.jsx)("span",{className:(0,E.io)("secondary","sm"),children:"Buy now"})]})]},e.id)}function ex(e){let t=(0,A.Te)(e);return{id:e.id,credits:e.credits,price:e.price,perCredit:(0,A.d)(e),discount:null===t?void 0:`${t}%`}}function ep(){let e,t,a,c,m,u,h,x,p,g,f,b,y,N,w,v,S,k,A,P,$,I,M,U,q,Y,B,O,D,R=(0,n.c)(82),{status:K}=(0,_.As)(),z=(0,C.S)(),[X,W]=i.useState(!1),Q=(0,d.useRouter)(),J="authenticated"===K,G=(0,l.jE)();R[0]===Symbol.for("react.memo_cache_sentinel")?(e=["me"],R[0]=e):e=R[0],R[1]!==J?(t={queryKey:e,queryFn:ev,enabled:J},R[1]=J,R[2]=t):t=R[2];let H=(0,r.I)(t);R[3]===Symbol.for("react.memo_cache_sentinel")?(a=["credit-balance"],R[3]=a):a=R[3],R[4]!==J?(c={queryKey:a,queryFn:ew,enabled:J},R[4]=J,R[5]=c):c=R[5];let ee=(0,r.I)(c);R[6]===Symbol.for("react.memo_cache_sentinel")?(m=["credit-usage"],R[6]=m):m=R[6],R[7]!==J?(u={queryKey:m,queryFn:eN,enabled:J},R[7]=J,R[8]=u):u=R[8];let et=(0,r.I)(u);R[9]===Symbol.for("react.memo_cache_sentinel")?(h=["credit-transactions"],R[9]=h):h=R[9],R[10]!==J?(x={queryKey:h,queryFn:ey,enabled:J},R[10]=J,R[11]=x):x=R[11];let es=(0,r.I)(x);R[12]===Symbol.for("react.memo_cache_sentinel")?(p=["subscription-plans"],R[12]=p):p=R[12],R[13]!==J?(g={queryKey:p,queryFn:eb,enabled:J},R[13]=J,R[14]=g):g=R[14];let ei=(0,r.I)(g),el=ee.data?.data?.plan?.name,er=ee.data?.data?.plan?.display_name,ec="pro"===el||"elite"===el||"team"===el,eo=("starter"===el||"free"===el)&&!z,eh=!!el&&(!eo||
1X),ex="team"===el||"enterprise"===el,ep=H.data?.data?.email;R[15]===Symbol.for("react.memo_cache_sentinel")?(f=["annual-savings"],R[15]=f):f=R[15];let eS=J&&ec;R[16]!==eS?(b={queryKey:f,queryFn:ej,enabled:eS,staleTime:6e5,refetchOnWindowFocus:!1},R[16]=eS,R[17]=b):b=R[17];let e_=(0,r.I)(b);R[18]===Symbol.for("react.memo_cache_sentinel")?(y=["team-overview"],R[18]=y):y=R[18];let eC=J&&ex;R[19]!==eC?(N={queryKey:y,queryFn:ef,enabled:eC,staleTime:12e4},R[19]=eC,R[20]=N):N=R[20];let ek=(0,r.I)(N),eA=ek.data?.data?.is_admin??!1,eP=ex&&!ek.isLoading&&!eA;R[21]!==eP||R[22]!==Q?(w=()=>{eP&&Q.replace("/account/profile")},v=[eP,Q],R[21]=eP,R[22]=Q,R[23]=w,R[24]=v):(w=R[23],v=R[24]),i.useEffect(w,v),R[25]!==G?(S=()=>{G.invalidateQueries({queryKey:["credit-balance"]}),G.invalidateQueries({queryKey:["me"]}),G.invalidateQueries({queryKey:["credit-transactions"]})},R[25]=G,R[26]=S):S=R[26];let e$=S;if(eP){let e;return R[27]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)(j.A,{className:"h-5 w-5 animate-spin text-dash-muted"})}),R[27]=e):e=R[27],e}return R[28]!==eo||R[29]!==X?(k=eo&&(0,s.jsxs)(E.O3,{"data-testid":"starter-first-task",className:"space-y-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[12.5px] font-semibold leading-tight text-dash-ink",children:"Start with the credits you have"}),(0,s.jsx)("p",{className:"mt-1 text-[12px] leading-snug text-dash-muted",children:"Try an agent task before choosing a paid plan. No upgrade is needed to use your available credits."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,s.jsx)(o(),{href:"/dashboard",className:(0,E.io)("primary"),children:"Start a task"}),(0,s.jsx)("button",{type:"button",className:"min-h-11 text-[12px] text-dash-muted underline underline-offset-4 transition-colors hover:text-dash-ink sm:min-h-8","aria-expanded":X,onClick:()=>W(eg),children:X?"Not now â hide plans":"Compare plans (optional)"})]})]}),R[28]=eo,R[29]=X,R[30]=k):k=R[30],R[31]!==ee.data||R[32]!==ee.isLoading||R[33]!==ec||R[34]!==et.data?(A=(0,s.jsx)(Z,{isLoading:ee.isLoading,data:ee.data,isPaidPlan:ec,usageData:et.data}),R[31]=ee.data,R[32]=ee.isLoading,R[33]=ec,R[34]=et.data,R[35]=A):A=R[35],R[36]!==et.data||R[37]!==et.isLoading?(P=(0,s.jsx)(V,{isLoading:et.isLoading,data:et.data}),R[36]=et.data,R[37]=et.isLoading,R[38]=P):P=R[38],R[39]!==e$||R[40]!==eA||R[41]!==ex||R[42]!==ep?($=ex&&eA&&(0,s.jsx)(em,{userEmail:ep,onSeatsChanged:e$}),R[39]=e$,R[40]=eA,R[41]=ex,R[42]=ep,R[43]=$):$=R[43],R[44]!==e_||R[45]!==el||R[46]!==er||R[47]!==e$||R[48]!==ec||R[49]!==eh||R[50]!==ep?(I=eh&&(0,s.jsx)(ed,{isPaidPlan:ec,userEmail:ep,planName:er,planId:el,onUpgradeSuccess:e$,annualSaving:e_.data}),R[44]=e_,R[45]=el,R[46]=er,R[47]=e$,R[48]=ec,R[49]=eh,R[50]=ep,R[51]=I):I=R[51],R[52]!==el||R[53]!==ec||R[54]!==ex||R[55]!==ei||R[56]!==eh?(M=ec&&!ex?(0,s.jsx)(eu,{}):!ec&&eh?(0,s.jsx)(en,{isLoading:ei.isLoading,data:ei.data,currentPlan:el}):null,R[52]=el,R[53]=ec,R[54]=ex,R[55]=ei,R[56]=eh,R[57]=M):M=R[57],R[58]!==eA||R[59]!==ex?(U=ex&&eA&&(0,s.jsx)(eu,{}),R[58]=eA,R[59]=ex,R[60]=U):U=R[60],R[61]!==ep?(q=(0,s.jsx)(F.x,{userEmail:ep}),Y=(0,s.jsx)(L.g,{userEmail:ep}),R[61]=ep,R[62]=q,R[63]=Y):(q=R[62],Y=R[63]),R[64]!==es.data||R[65]!==es.isLoading?(B=(0,s.jsx)(ea,{isLoading:es.isLoading,data:es.data}),R[64]=es.data,R[65]=es.isLoading,R[66]=B):B=R[66],R[67]!==ec||R[68]!==ep?(O=ec&&(0,s.jsx)(T.j,{userEmail:ep}),R[67]=ec,R[68]=ep,R[69]=O):O=R[69],R[70]!==k||R[71]!==A||R[72]!==P||R[73]!==$||R[74]!==I||R[75]!==M||R[76]!==U||R[77]!==q||R[78]!==Y||R[79]!==B||R[80]!==O?(D=(0,s.jsxs)("div",{className:"min-w-0 space-y-7",children:[k,A,P,$,I,M,U,q,Y,B,O]}),R[70]=k,R[71]=A,R[72]=P,R[73]=$,R[74]=I,R[75]=M,R[76]=U,R[77]=q,R[78]=Y,R[79]=B,R[80]=O,R[81]=D):D=R[81],D}function eg(e){return!e}function ef(){return S.uE.getTeamOverview()}async function ej(){let e=await fetch("/api/billing/annual-savings",{headers:{Authorization:`Bearer ${window.localStorage.getItem("auth_token")??""}`}});return e.ok?await e.json():null}function eb(){return S.uE.getSubscriptionPlans()}function ey(){return S.uE.getCreditTransactions({limit:10})}function eN(){return S.uE.getCreditUsage()}function ew(){return S.uE.getCreditBalance()}function ev(){return S.uE.getCurrentUser()}}}]);
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.