tokentracker-cli 0.5.13 → 0.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- import{ay as Le,az as Te,ah as Ce,ai as Ae,r as c,aA as Ee,h as Pe,j as Ie,B as o,aB as Me,aC as I,aD as Re,C as e,aE as b,au as z,a9 as se,aF as $e,aG as Be,a8 as Ue,aH as ie,aI as le,aJ as ze}from"./main-7kFIj2vL.js";import{L as be,a as Fe,l as de,b as ce,c as me,d as De,e as He}from"./leaderboard-columns-2mvo_uNL.js";import{u as Ke,T as Oe}from"./ThemeToggle-DVKbB4qC.js";function S(t,{min:r,max:n,fallback:s}){const i=Number(t);if(!Number.isFinite(i))return s;const d=Math.floor(i);return d<r?r:d>n?n:d}function Ge(t,r){const n=S(r,{min:0,max:1e6,fallback:0}),s=S(t,{min:1,max:Math.max(1,n||1),fallback:1});if(n<=1)return[1];const i=new Set([1,n,s-2,s-1,s,s+1,s+2]),d=Array.from(i).filter(x=>Number.isInteger(x)&&x>=1&&x<=n).sort((x,L)=>x-L),g=[];let f=null;for(const x of d)f!=null&&x-f>1&&g.push(null),g.push(x),f=x;return g}function Ye({page:t,totalPages:r}){const n=typeof r=="number"&&Number.isFinite(r)&&r>=0,s=n?S(r,{min:0,max:1e6,fallback:0}):null,i=S(t,{min:1,max:n?Math.max(1,s||1):1e6,fallback:1}),d=i>1,g=n?i<s:!0;return{canPrev:d,canNext:g,safePage:i,safeTotal:s}}function Je({entries:t,me:r,meLabel:n,limit:s}){const i=S(s,{min:1,max:1e3,fallback:20}),d=Array.isArray(t)?t.slice(0,i):[],g=r&&typeof r.rank=="number"?r.rank:null,f=d.some(N=>!!N?.is_me);if(!g||f)return d;const x={rank:g,is_me:!0,display_name:n,avatar_url:null,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0"},L=3,A=4,m=d.filter(N=>!N?.is_me).filter((N,y)=>y!==L).slice();return m.splice(Math.min(A,m.length),0,x),m.slice(0,i)}const U=20;function xe(t){const r=Number(t);return!Number.isFinite(r)||r<=0?"-":r>=1e3?`$${Math.round(r).toLocaleString()}`:r>=10?`$${Math.round(r)}`:`$${r.toFixed(2)}`}function ge(t,r){const n=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",s=r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 ";return be.map(i=>e.jsx("td",{className:b("px-4 py-4 whitespace-nowrap",n,s),children:z(t?.[i.key])},i.key))}function F(t){if(typeof t!="string")return null;const r=t.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function Ve(t){if(!t)return o("shared.error.prefix",{error:o("leaderboard.error.unknown")});const r=t?.message||String(t),n=String(r||"").trim()||o("leaderboard.error.unknown");return o("shared.error.prefix",{error:n})}function he(t){return typeof t!="string"?"":t.trim()}function We(t){const r=he(t);return r?r.toLowerCase()==="anonymous":!0}function qe(t,r=""){if(typeof t!="string")return null;const n=t.trim().toLowerCase();if(!n)return null;const s=new URLSearchParams(typeof r=="string"?r:""),i=F(s.get("period")),d=i?`?period=${i}`:"";return`/share/pv1-${n}${d}`}function ue(t,r){const n=typeof t?.user_id=="string"?t.user_id.trim():"";return n||`${t?.rank??""}:${r}`}function aa({auth:t,signedIn:r,sessionSoftExpired:n}){const s=Le(),i=Te(),{openLoginModal:d}=Ce(),{signedIn:g,loading:f}=Ae(),{resolvedTheme:x,toggleTheme:L}=Ke(),A=c.useMemo(()=>Ee(),[]),p=Pe(),m=r&&!n,N=c.useMemo(()=>m&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,m]),y=m?N:null,_=m&&Ie(y),D=o("shared.placeholder.short"),[M,T]=c.useState(1),[fe,H]=c.useState(0),[u,E]=c.useState(()=>({loading:!1,error:null,data:null})),[K,pe]=c.useState(()=>Me()),[O,G]=c.useState(!1),[Y,J]=c.useState(!1),k=c.useMemo(()=>{const a=new URLSearchParams(s?.search||"");return F(a.get("period"))||"total"},[s?.search]),ye=s?.search||"",ke=a=>{const l=F(a);if(!l||l===k)return;const v=new URLSearchParams(s?.search||"");v.set("period",l),T(1),i(`${s?.pathname||"/leaderboard"}?${v.toString()}`,{replace:!0})};c.useEffect(()=>{f||p||g||d()},[g,f,p,d]),c.useEffect(()=>{T(1)},[k]),c.useEffect(()=>{p||m&&(_||E({loading:!1,error:null,data:null}))},[m,_,p]);const V=c.useMemo(()=>(S(M,{min:1,max:1e6,fallback:1})-1)*U,[M]);c.useEffect(()=>{if(!A&&!p||!p&&m&&!_)return;let a=!0;return E(l=>({...l,loading:!0,error:null})),(async()=>{const l=m?await I(y):null,v=await Re({accessToken:l,period:k,limit:U,offset:V});a&&E({loading:!1,error:null,data:v})})().catch(l=>{a&&E({loading:!1,error:Ve(l),data:null})}),()=>{a=!1}},[A,y,m,_,V,fe,p,k]);const h=u.data,P=h?.total_pages??null,j=h?.page??M,we=c.useMemo(()=>Ge(j,P),[j,P]),W=h?.from||null,q=h?.to||null,Q=h?.generated_at||null,X=h?.me||null,R=o("leaderboard.me_label"),je=o("leaderboard.anon_label"),Z=o("leaderboard.period.week"),ee=o("leaderboard.period.month"),ae=o("leaderboard.period.total"),re=k==="month"?ee:k==="total"?ae:Z,$=c.useMemo(()=>{const a=Array.isArray(h?.entries)?h.entries:[];return j!==1?a:Je({entries:a,me:X,meLabel:R,limit:U})},[j,h?.entries,X,R]),ve=async()=>{G(!0);try{ze(!0),pe(!0),await ie(()=>I(y));const a=await I(y);a&&await le({accessToken:a}),H(l=>l+1)}catch(a){console.warn("[tokentracker] sync:",a)}finally{G(!1)}},Ne=async()=>{J(!0);try{const a=await I(y);K&&a&&await ie(()=>Promise.resolve(a)),a&&await le({accessToken:a}),H(l=>l+1)}catch(a){console.warn("[tokentracker] refresh:",a)}finally{J(!1)}},{canPrev:te,canNext:oe}=Ye({page:j,totalPages:P}),_e=Array.isArray($)&&$.length!==0;let C=null;u.loading?C=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.loading")})}):u.error?C=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:u.error})}):_e?C=e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:b(De,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:o("leaderboard.column.rank")}),e.jsx("th",{className:b(He,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:o("leaderboard.column.user")}),e.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:o("leaderboard.column.total")}),e.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",title:"Based on estimated API pricing, not actual billing",children:"Est. Cost"}),be.map(a=>e.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:e.jsx(Fe,{iconSrc:a.icon,label:o(a.copyKey)})},a.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:$.map(a=>{const l=!!a?.is_me,v=typeof a?.user_id=="string"?a.user_id:null,ne=he(a?.display_name),Se=We(ne)?je:ne,w=l?R:Se;return!!v&&!l&&!!a?.is_public&&qe(v,ye),l?e.jsxs("tr",{className:"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30 bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",children:[e.jsx("td",{className:b(de(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400"),children:a?.rank??D}),e.jsx("td",{className:me(!0),children:e.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[e.jsx(ce,{avatarUrl:a?.avatar_url,displayName:w,seed:ue(a,w)}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:w})]})}),e.jsx("td",{className:"px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap bg-oai-brand-50 dark:bg-oai-brand-900/10",children:z(a?.total_tokens)}),e.jsx("td",{className:"px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:xe(a?.estimated_cost_usd)}),ge(a,!0)]},`row-${a?.rank}-${w}`):e.jsxs("tr",{className:"group transition-colors",children:[e.jsx("td",{className:b(de(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:a?.rank??D}),e.jsx("td",{className:me(!1),children:e.jsxs("div",{className:"flex min-w-0 max-w-[min(160px,40vw)] items-center gap-4",children:[e.jsx(ce,{avatarUrl:a?.avatar_url,displayName:w,seed:ue(a,w)}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:w})]})}),e.jsx("td",{className:"px-4 py-4 text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap bg-white dark:bg-oai-gray-950 ",children:z(a?.total_tokens)}),e.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap bg-white dark:bg-oai-gray-950 ",title:"Based on estimated API pricing, not actual billing",children:xe(a?.estimated_cost_usd)}),ge(a,!1)]},`row-${a?.rank}-${w}`)})})]})}):C=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.empty")})});let B=null;return typeof P=="number"?B=we.map((a,l)=>a==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:o("leaderboard.pagination.ellipsis")},`ellipsis-${l}`):e.jsx("button",{className:b("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",a===j?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>T(a),disabled:u.loading,children:String(a)},`page-${a}`)):B=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o("leaderboard.pagination.page_unknown",{page:String(j)})}),e.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[e.jsx("header",{className:"sticky top-0 z-50 bg-white/80 dark:bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-200 dark:border-oai-gray-900 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsxs(se,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),e.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx($e,{})})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx(Oe,{theme:x,onToggle:L}),e.jsx(se,{to:Be(),className:b("no-underline inline-flex items-center justify-center h-9 px-5 text-sm font-medium rounded-full transition-colors",g?"shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-900 hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100":"ring-1 ring-oai-gray-200 dark:ring-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800"),children:o("landing.v2.cta.primary")}),e.jsx(Ue,{})]})]})}),e.jsx("main",{className:"flex-1 py-12 sm:py-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-10",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:o("leaderboard.title")}),e.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[k==="total"?o("leaderboard.range.total"):W&&q?o("leaderboard.range",{period:re,from:W,to:q}):o("leaderboard.range_loading",{period:re}),Q&&e.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:o("leaderboard.generated_at",{ts:Q})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[m&&_&&e.jsx("button",{onClick:Ne,disabled:Y||u.loading,className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white transition-colors disabled:opacity-50",children:Y?"Refreshing...":"↻"}),e.jsx("div",{className:"inline-flex p-1 border border-oai-gray-200 dark:border-oai-gray-800 rounded-lg",children:["week","month","total"].map(a=>e.jsx("button",{onClick:()=>ke(a),disabled:u.loading,className:b("px-4 py-1.5 text-sm font-medium rounded-md transition-colors",k===a?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:a==="week"?Z:a==="month"?ee:ae},a))})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Sign in to join the leaderboard"}),e.jsx("button",{onClick:d,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:"Sign In"})]}),m&&_&&!K&&e.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:"Enable Cloud Sync to appear in rankings"}),e.jsx("button",{onClick:ve,disabled:O,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 disabled:opacity-50 transition-colors",children:O?"Syncing...":"Enable & Sync"})]}),e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[C,e.jsxs("div",{className:"px-6 py-3 border-t border-oai-gray-200 dark:border-oai-gray-800 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:b("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",te&&!u.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>T(a=>Math.max(1,a-1)),disabled:!te||u.loading,children:o("leaderboard.pagination.prev")}),e.jsx("button",{className:b("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",oe&&!u.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>T(a=>a+1),disabled:!oe||u.loading,children:o("leaderboard.pagination.next")})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:B})]})]})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:o("landing.v2.footer.line")}),e.jsx("a",{href:"https://github.com/mm7894215/TokenTracker",className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:o("landing.v2.nav.github")})]})})]})}export{aa as LeaderboardPage};
@@ -1 +0,0 @@
1
- import{ay as H,r as x,aA as M,h as O,j as D,aC as Y,aK as $,B as a,C as e,aE as f,au as A,a9 as j,aF as F,a8 as G}from"./main-7kFIj2vL.js";import{L as E,a as W,l as q,f as J,b as Q,d as V,g as X}from"./leaderboard-columns-2mvo_uNL.js";import{u as Z,T as I}from"./ThemeToggle-DVKbB4qC.js";function ee(r){if(!r)return a("shared.error.prefix",{error:a("leaderboard.error.unknown")});const o=r?.message||String(r),y=String(o||"").trim()||a("leaderboard.error.unknown");return a("shared.error.prefix",{error:y})}function ae(r){return typeof r!="string"?"":r.trim()}function re(r){if(typeof r!="string")return null;const o=r.trim().toLowerCase();return o==="week"||o==="month"||o==="total"?o:null}function ie({auth:r,signedIn:o,sessionSoftExpired:y,userId:s}){const b=H(),{resolvedTheme:R,toggleTheme:C}=Z(),N=x.useMemo(()=>M(),[]),p=O(),i=o&&!y,P=x.useMemo(()=>i&&(typeof r=="function"||typeof r=="string"||r&&typeof r=="object")?r:null,[r,i]),u=i?P:null,w=i&&D(u),c=x.useMemo(()=>{const t=new URLSearchParams(b?.search||"");return re(t.get("period"))||"week"},[b?.search]),v=b?.search||"",[m,g]=x.useState(()=>({loading:!1,error:null,data:null}));x.useEffect(()=>{if(!N&&!p||!s||!p&&(!i||!w))return;let t=!0;return g(d=>({...d,loading:!0,error:null})),(async()=>{const d=await Y(u);if(!t)return;if(!d){g({loading:!1,error:null,data:null});return}const z=await $({accessToken:d,userId:s,period:c});t&&g({loading:!1,error:null,data:z})})().catch(d=>{t&&g({loading:!1,error:ee(d),data:null})}),()=>{t=!1}},[i,w,N,u,p,c,s]);const h=m.data,T=h?.from||null,L=h?.to||null,_=h?.generated_at||null,n=h?.entry||null,k=ae(n?.display_name)||a("leaderboard.anon_label"),B=a("leaderboard.period.week"),K=a("leaderboard.period.month"),U=a("leaderboard.period.total"),S=c==="month"?K:c==="total"?U:B;let l=null;return s?m.loading?l=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.loading")})}):m.error?l=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:m.error})}):n?l=e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:f(V,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:a("leaderboard.column.rank")}),e.jsx("th",{className:f(X,"font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap"),children:a("leaderboard.column.total")}),E.map(t=>e.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:e.jsx(W,{iconSrc:t.icon,label:a(t.copyKey)})},t.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:e.jsxs("tr",{className:"transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60",children:[e.jsx("td",{className:f(q(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:n?.rank??a("shared.placeholder.short")}),e.jsx("td",{className:f(J(),"text-oai-gray-700 dark:text-oai-gray-300"),children:A(n?.total_tokens)}),E.map(t=>e.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:A(n?.[t.key])},t.key))]})})]})}):l=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.empty")})}):l=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("leaderboard.empty")})}),e.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[e.jsx("header",{className:"sticky top-0 z-50 bg-white/80 dark:bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-200 dark:border-oai-gray-900 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsxs(j,{to:"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),e.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(F,{})})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx(j,{to:`/leaderboard${v}`,className:"no-underline inline-flex items-center justify-center h-9 px-5 text-sm font-medium rounded-full shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-900 hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors",children:a("leaderboard.profile.nav.back")}),e.jsx(I,{theme:R,onToggle:C}),e.jsx(G,{})]})]})}),e.jsx("main",{className:"flex-1 py-12 sm:py-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-6 mb-10",children:[e.jsx(Q,{avatarUrl:n?.avatar_url,displayName:k,seed:typeof s=="string"?s:k,size:"lg",className:"shrink-0 ring-2 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:k}),e.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[c==="total"?a("leaderboard.range.total"):T&&L?a("leaderboard.range",{period:S,from:T,to:L}):a("leaderboard.range_loading",{period:S}),_&&e.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:a("leaderboard.generated_at",{ts:_})})]})]})]}),e.jsx("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:l})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:a("landing.v2.footer.line")}),e.jsx(j,{to:`/leaderboard${v}`,className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:a("leaderboard.profile.nav.back")})]})})]})}export{ie as LeaderboardProfilePage};
@@ -1 +0,0 @@
1
- import{r as x,aL as m,ab as k,C as t,ac as u}from"./main-7kFIj2vL.js";function j(){const a=x.useContext(m);if(a===null)throw new Error("useTheme must be used within a ThemeProvider");return a}function y({theme:a,onToggle:g,className:s="",size:e=36,iconSize:n=20}){const p=k(),o=a==="dark",i=()=>{g?.(o?"light":"dark")},c={width:e,height:e,borderRadius:8,background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--oai-gray-600)",transition:"background-color 150ms ease, color 150ms ease"},l={backgroundColor:"var(--oai-gray-100)",color:"var(--oai-black)"},d=()=>t.jsxs("svg",{"aria-hidden":"true",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"4"}),t.jsx("path",{d:"M12 2v2"}),t.jsx("path",{d:"M12 20v2"}),t.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),t.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),t.jsx("path",{d:"M2 12h2"}),t.jsx("path",{d:"M20 12h2"}),t.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),t.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]}),h=()=>t.jsx("svg",{"aria-hidden":"true",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})});return p?t.jsx("button",{type:"button","aria-label":o?"Switch to light mode":"Switch to dark mode",onClick:i,className:`oai-button-ghost oai-button-sm ${s}`,style:{...c,width:e,height:e,padding:0},title:o?"切换到亮色模式":"切换到暗色模式",onMouseEnter:r=>{r.currentTarget.style.backgroundColor=l.backgroundColor,r.currentTarget.style.color=l.color},onMouseLeave:r=>{r.currentTarget.style.backgroundColor="transparent",r.currentTarget.style.color="var(--oai-gray-600)"},children:o?t.jsx(h,{}):t.jsx(d,{})}):t.jsx(u.button,{type:"button","aria-label":o?"Switch to light mode":"Switch to dark mode",onClick:i,className:`oai-button-ghost oai-button-sm ${s}`,style:{...c,width:e,height:e,padding:0},title:o?"切换到亮色模式":"切换到暗色模式",whileHover:{backgroundColor:"var(--oai-gray-100)",color:"var(--oai-black)"},whileTap:{scale:.95},transition:{type:"spring",stiffness:400,damping:25},children:t.jsx(u.div,{initial:{scale:.8,opacity:0,rotate:-20},animate:{scale:1,opacity:1,rotate:0},exit:{scale:.8,opacity:0,rotate:20},transition:{type:"spring",stiffness:400,damping:25},children:o?t.jsx(h,{}):t.jsx(d,{})},o?"moon":"sun")})}export{y as T,j as u};
@@ -1 +0,0 @@
1
- import{C as n,aE as i}from"./main-7kFIj2vL.js";function l(r){let e=0;const o=String(r??"");for(let a=0;a<o.length;a+=1)e=Math.imul(31,e)+o.charCodeAt(a)|0;return Math.abs(e)%360}function b(r){const e=String(r??"").trim();if(!e)return"?";const o=e.split(/\s+/).filter(Boolean);if(o.length>=2){const a=o[0][0]||"",t=o[1][0]||"";return`${a}${t}`.toUpperCase()}return e.slice(0,2).toUpperCase()}const c={sm:"h-7 w-7 min-h-7 min-w-7 text-[10px]",md:"h-8 w-8 min-h-8 min-w-8 text-[11px]",lg:"h-14 w-14 min-h-14 min-w-14 text-base"};function y({avatarUrl:r,displayName:e,seed:o,size:a="md",className:t}){const s=c[a]||c.md,g=l(o??e??""),d=typeof r=="string"?r.trim():"";return d?n.jsx("img",{src:d,alt:"",className:i("rounded-full object-cover ring-1 ring-white/10",s,t)}):n.jsx("div",{className:i("flex shrink-0 items-center justify-center rounded-full font-semibold text-white ring-1 ring-white/10",s,t),style:{backgroundColor:`hsl(${g} 42% 34%)`},"aria-hidden":!0,children:b(e)})}function m({iconSrc:r,label:e}){return n.jsxs("span",{className:"inline-flex items-center gap-3",children:[n.jsx("img",{src:r,alt:"",width:16,height:16,className:"h-4 w-4 shrink-0 object-contain opacity-90"}),n.jsx("span",{className:"whitespace-nowrap",children:e})]})}const u=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:"/brand-logos/gemini.svg"}],h="sticky left-0 z-40 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4",k="sticky left-[72px] z-40 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4",x="sticky left-[72px] z-40 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4";function w(r){return i("sticky left-0 z-30 w-[72px] min-w-[72px] max-w-[72px] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function f(r){return i("sticky left-[72px] z-30 min-w-[140px] max-w-[min(180px,35vw)] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 min-w-0",r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function _(r){return i("sticky left-[72px] z-30 min-w-[6rem] border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap","bg-white dark:bg-oai-gray-950")}export{u as L,m as a,y as b,f as c,h as d,k as e,_ as f,x as g,w as l};