tokentracker-cli 0.57.1 → 0.59.0
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.
- package/README.ja.md +6 -5
- package/README.ko.md +6 -5
- package/README.md +7 -6
- package/README.zh-CN.md +6 -5
- package/dashboard/dist/assets/{ActivityHeatmap-BvbV3_J7.js → ActivityHeatmap-DrF_K5ys.js} +1 -1
- package/dashboard/dist/assets/{Card-DJZ6ntik.js → Card-B13p4G_t.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-BCWtoeRf.js +19 -0
- package/dashboard/dist/assets/{DevicePage-DW6XIKeU.js → DevicePage-Be88eLBY.js} +1 -1
- package/dashboard/dist/assets/{DialogTitle-BsrlMQVP.js → DialogTitle-BZmopQRt.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-XjqQkcHf.js → FadeIn-BEym_KpF.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-DcwDZDfU.js → HeaderGithubStar-Ckhzj9HH.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-DwWHgam0.js → IpCheckPage-CJb8fFzg.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-BqtWjGwE.js → LandingPage-CjTv2ISs.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardAvatar-BeBtwC-_.js → LeaderboardAvatar-Cf0GnSTi.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-0TwqZOxu.js → LeaderboardPage-rIE2Ygw4.js} +3 -3
- package/dashboard/dist/assets/LeaderboardProfileModal-CT876wK9.js +72 -0
- package/dashboard/dist/assets/{LeaderboardProfilePage-865y5FBU.js → LeaderboardProfilePage-EyJsH0Yf.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-DNg_cqiC.js +2 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-CTKip6yZ.js → LocalOnlyNotice-Dz8c-3ZD.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-DhfoXUgm.js → LoginPage-iekpEtgT.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-3YotW-4M.js → PopoverPopup-BhT2-G0O.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-CqEEo2VL.js → ResetPasswordPage-B69CFuJ-.js} +1 -1
- package/dashboard/dist/assets/{Select-BjnA__CB.js → Select-SwlPWXxZ.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-CoQ0e4TL.js → SelectItemText-DpUKUC8A.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-ushnnb65.js → SettingsPage-_spYM3Kx.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-CW4mBNzt.js → SkillsPage-CfTvatpr.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-BiwEsW3y.js → WidgetsPage-Cs0kJgks.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-vu2gEGcG.js → WrappedPage-9EChVGEl.js} +1 -1
- package/dashboard/dist/assets/{agent-logos-CvsRxSzl.js → agent-logos-LiqKeIhs.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-DwYMKA3i.js → arrow-up-right-B7ItQsbP.js} +1 -1
- package/dashboard/dist/assets/{download-BpLBXlyg.js → download-ZBU9wTAZ.js} +1 -1
- package/dashboard/dist/assets/{info-D7gs3LAC.js → info-CExabEBS.js} +1 -1
- package/dashboard/dist/assets/{main-D2iJg7iA.js → main-CgiMNMS_.js} +15 -11
- package/dashboard/dist/assets/{main-Bb0Bwbp7.css → main-xFJe2FDa.css} +1 -1
- package/dashboard/dist/assets/use-limits-display-prefs-bSTssszE.js +1 -0
- package/dashboard/dist/assets/{use-native-settings-C-JvsUqt.js → use-native-settings-C3pXNNqf.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-DfKKdPYm.js → use-usage-limits-8f1hUzNE.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-CAzf_Pmi.js → useCurrency-CrMUx8Pg.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-DNuJyLo9.js → useScrollLock-BaJCW9Ak.js} +1 -1
- package/dashboard/dist/brand-logos/zcode.svg +1 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +2 -2
- package/src/commands/init.js +9 -2
- package/src/commands/status.js +11 -0
- package/src/commands/sync.js +45 -0
- package/src/lib/pricing/curated-overrides.json +6 -2
- package/src/lib/pricing/matcher.js +17 -2
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +40 -0
- package/src/lib/usage-limits.js +6 -1
- package/src/lib/zcode-limits.js +213 -0
- package/dashboard/dist/assets/DashboardPage-Bu3v5Fm2.js +0 -19
- package/dashboard/dist/assets/LeaderboardProfileModal-3HwkYdbM.js +0 -72
- package/dashboard/dist/assets/LimitsPage-CfGYwdDz.js +0 -2
- package/dashboard/dist/assets/use-limits-display-prefs-BDCL1zsb.js +0 -1
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import{c as D,r as g,dp as K,j as e,G as n,dq as Q,aB as ee,dr as ae,V as c,Y as re,ds as te,aD as se,L as ie,n as oe,U as T,X as ne,J as I,I as le,ae as de}from"./main-D2iJg7iA.js";import{u as ce}from"./useCurrency-CAzf_Pmi.js";import{L as W}from"./LeaderboardAvatar-BeBtwC-_.js";import{A as me}from"./ActivityHeatmap-BvbV3_J7.js";import{A as U}from"./arrow-up-right-DwYMKA3i.js";import{C as xe}from"./useScrollLock-DNuJyLo9.js";import{D as ge,a as pe,b as he,c as fe,d as be,e as ue}from"./DialogTitle-BsrlMQVP.js";import"./info-D7gs3LAC.js";const ye=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ke=D("code-xml",ye);const je=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],ve=D("heart",je);const Ne=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],_e=D("link-2",Ne),C="tokentracker_likes";function F(a){if(!a)return!1;try{const r=localStorage.getItem(C);return r?!!JSON.parse(r)?.[a]:!1}catch{return!1}}function z(a,r){if(a)try{const t=localStorage.getItem(C),s=t?JSON.parse(t):{};r?s[a]=!0:delete s[a],localStorage.setItem(C,JSON.stringify(s))}catch{}}function E({userId:a}){const[r,t]=g.useState(!1),[s,i]=g.useState(0),[l,m]=g.useState(!1),[d,p]=g.useState(!1),[y,k]=g.useState(!1),[j,M]=g.useState([]),[v,b]=g.useState(!1),N=g.useRef(0);g.useEffect(()=>{let o=!1;return a?(m(!1),t(F(a)),K({userId:a}).then(x=>{o||(i(Number(x?.count)||0),m(!0))}).catch(()=>{o||(i(0),m(!0))}),()=>{o=!0}):(m(!1),()=>{o=!0})},[a]);const _=()=>{k(!0),setTimeout(()=>k(!1),450),b(!0),setTimeout(()=>b(!1),500);const o=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],x=["circle","heart"],f=[];for(let h=0;h<12;h++){const S=(h*30+Math.random()*20-10)*(Math.PI/180),A=45+Math.random()*45,O=Math.cos(S)*A,q=Math.sin(S)*A-(10+Math.random()*15),J=Math.random()*360-180,X=6+Math.random()*8,Y=o[Math.floor(Math.random()*o.length)],V=x[Math.floor(Math.random()*x.length)],Z=++N.current;f.push({id:Z,tx:O,ty:q,rot:J,size:X,color:Y,shape:V})}M(h=>[...h,...f]),setTimeout(()=>{M(h=>h.filter(S=>!f.find(A=>A.id===S.id)))},850)},u=async o=>{p(!0);try{const x=await Q({userId:a,delta:o}),f=Number(x?.count);Number.isFinite(f)&&i(f)}catch{t(x=>!x),i(x=>Math.max(0,x-o)),z(a,!F(a))}finally{p(!1)}},w=o=>{o.stopPropagation(),!(!a||!l||d)&&(r?(t(!1),i(x=>Math.max(0,x-1)),z(a,!1),u(-1)):(t(!0),i(x=>x+1),z(a,!0),_(),u(1)))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
2
|
-
@keyframes tt-like-pop {
|
|
3
|
-
0% { transform: scale(1); }
|
|
4
|
-
25% { transform: scale(0.75); }
|
|
5
|
-
50% { transform: scale(1.35); }
|
|
6
|
-
75% { transform: scale(0.9); }
|
|
7
|
-
100% { transform: scale(1); }
|
|
8
|
-
}
|
|
9
|
-
@keyframes tt-particle-fly {
|
|
10
|
-
0% {
|
|
11
|
-
transform: translate(0, 0) scale(1) rotate(0deg);
|
|
12
|
-
opacity: 1;
|
|
13
|
-
}
|
|
14
|
-
70% {
|
|
15
|
-
opacity: 0.8;
|
|
16
|
-
}
|
|
17
|
-
100% {
|
|
18
|
-
transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
|
|
19
|
-
opacity: 0;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
@keyframes tt-num-scroll {
|
|
23
|
-
0% { transform: translateY(8px); opacity: 0; }
|
|
24
|
-
100% { transform: translateY(0); opacity: 1; }
|
|
25
|
-
}
|
|
26
|
-
.tt-animate-pop {
|
|
27
|
-
animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
|
|
28
|
-
}
|
|
29
|
-
.tt-particle {
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 50%;
|
|
32
|
-
left: 50%;
|
|
33
|
-
margin-top: -6px;
|
|
34
|
-
margin-left: -6px;
|
|
35
|
-
pointer-events: none;
|
|
36
|
-
z-index: 50;
|
|
37
|
-
}
|
|
38
|
-
.tt-num-anim {
|
|
39
|
-
animation: tt-num-scroll 0.25s ease-out forwards;
|
|
40
|
-
}
|
|
41
|
-
`}}),j.map(o=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${o.tx}px`,"--ty":`${o.ty}px`,"--rot":`${o.rot}deg`,width:`${o.size}px`,height:`${o.size}px`,backgroundColor:o.shape==="circle"?o.color:"transparent",borderRadius:o.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:o.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:o.color,className:"w-full h-full",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})})},o.id)),e.jsxs("button",{type:"button",onClick:w,disabled:!l||d,"aria-label":r?n("leaderboard.profile.like.aria_unlike"):n("leaderboard.profile.like.aria_like"),className:`group flex items-center justify-center gap-1.5 h-8 min-w-[48px] px-2.5 rounded-full border transition-all duration-300 outline-none focus-visible:ring-2 focus-visible:ring-rose-500/50 disabled:opacity-60 disabled:cursor-default ${r?"bg-rose-50/60 border-rose-200/80 text-rose-500 dark:bg-rose-950/20 dark:border-rose-900/40 dark:text-rose-400 shadow-sm":"bg-white/80 border-oai-gray-200 text-oai-gray-500 hover:border-rose-200 hover:text-rose-500 hover:bg-rose-50/30 dark:bg-oai-gray-950/50 dark:border-white/10 dark:text-oai-gray-400 dark:hover:border-rose-900/50 dark:hover:text-rose-400 dark:hover:bg-rose-950/5"}`,children:[e.jsx("span",{className:y?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(ve,{size:14,className:`transition-all duration-300 ${r?"fill-rose-500 text-rose-500 dark:fill-rose-400 dark:text-rose-400":"fill-transparent"}`})}),e.jsx("span",{className:`text-[12px] font-bold font-mono tabular-nums tracking-tight ${r?"text-rose-600 dark:text-rose-400":"text-oai-gray-600 dark:text-oai-gray-400"} ${v?"tt-num-anim":""}`,children:l?s:"·"})]})]})}function we(a,r,t){const s=Number(a);return!Number.isFinite(s)||s<0?"—":s>0&&s<.01?`<${r==="USD"?"$":""}0.01`:le(s,{decimals:2,currency:r,rate:t})}function H(a,r,t){const s=Number(a);if(!Number.isFinite(s)||s<0)return"—";if(s<1e3)return we(s,r,t);const i=r==="USD"?s:s*(t||1);return`${r==="USD"?"$":""}${I(i,{decimals:1})}`}function $(a){const r=Number(a);return!Number.isFinite(r)||r<=0?"0":I(r,{decimals:1})}function Se(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const t=r.map(i=>({day:i.date,total_tokens:i.total_tokens,models:i.models||null})),s=r[r.length-1]?.date;return oe({dailyRows:t,weeks:52,to:s})}const Ae=`
|
|
42
|
-
@keyframes tt-shimmer {
|
|
43
|
-
100% { transform: translateX(100%); }
|
|
44
|
-
}
|
|
45
|
-
.tt-shimmer-bar {
|
|
46
|
-
position: relative;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
}
|
|
49
|
-
.tt-shimmer-bar::after {
|
|
50
|
-
position: absolute;
|
|
51
|
-
top: 0; right: 0; bottom: 0; left: 0;
|
|
52
|
-
transform: translateX(-100%);
|
|
53
|
-
background-image: linear-gradient(
|
|
54
|
-
90deg,
|
|
55
|
-
rgba(0, 0, 0, 0) 0%,
|
|
56
|
-
rgba(0, 0, 0, 0.02) 20%,
|
|
57
|
-
rgba(0, 0, 0, 0.06) 60%,
|
|
58
|
-
rgba(0, 0, 0, 0) 100%
|
|
59
|
-
);
|
|
60
|
-
animation: tt-shimmer 1.6s infinite;
|
|
61
|
-
content: '';
|
|
62
|
-
}
|
|
63
|
-
.dark .tt-shimmer-bar::after {
|
|
64
|
-
background-image: linear-gradient(
|
|
65
|
-
90deg,
|
|
66
|
-
rgba(255, 255, 255, 0) 0%,
|
|
67
|
-
rgba(255, 255, 255, 0.02) 20%,
|
|
68
|
-
rgba(255, 255, 255, 0.06) 60%,
|
|
69
|
-
rgba(255, 255, 255, 0) 100%
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
`;function Le({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",t=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Ae}}),t?e.jsxs("div",{className:"flex items-start gap-5 px-6 sm:px-8 pt-8 pb-7 animate-fade-in",children:[e.jsx("div",{className:"h-[68px] w-[68px] rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start justify-between gap-4 pt-0.5",children:[e.jsxs("div",{className:"min-w-0 space-y-2.5",children:[e.jsx("div",{className:c(r,"h-7 w-48")}),e.jsx("div",{className:c(r,"h-3.5 w-32")})]}),e.jsxs("div",{className:"shrink-0 space-y-1.5 flex flex-col items-end",children:[e.jsx("div",{className:c(r,"h-2.5 w-8")}),e.jsx("div",{className:c(r,"h-7 w-12")})]})]})]}):e.jsxs("div",{className:"flex items-start gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60 animate-fade-in",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2 pt-1",children:[e.jsx("div",{className:c(r,"h-4 w-40")}),e.jsx("div",{className:c(r,"h-3 w-56")})]}),e.jsx("div",{className:c(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:c("space-y-6",t?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"px-6 py-5"),children:[e.jsx("div",{className:"grid grid-cols-4 gap-x-6 gap-y-4",children:Array.from({length:4}).map((s,i)=>e.jsxs("div",{children:[e.jsx("div",{className:c(r,"h-6 w-20")}),e.jsx("div",{className:c(r,"mt-2 h-3 w-14")})]},i))}),e.jsx("div",{className:"space-y-3 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:Array.from({length:3}).map((s,i)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-3 w-24")}),e.jsx("div",{className:c(r,"h-3 w-44")})]},i))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-44 mb-4")}),e.jsx("div",{className:"grid grid-cols-[repeat(52,1fr)] gap-[2px]",children:Array.from({length:364}).map((s,i)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},i))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((s,i)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-4 w-4")}),e.jsx("div",{className:c(r,"h-3 w-16")}),e.jsx("div",{className:c(r,"h-[3px] flex-1")}),e.jsx("div",{className:c(r,"h-3 w-12")})]},i))})]})]})]})}function G(a){if(!a)return null;const r=String(a).match(/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})/i);return r?r[1]:null}function R({children:a}){return e.jsx("h3",{className:"text-[11px] uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400 mb-3",children:a})}function L({value:a,label:r}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-black tabular-nums tracking-tight leading-none text-oai-black dark:text-white",style:{fontFamily:'"DIN Alternate-Bold", "DIN Alternate", "DIN Condensed-Bold", "Impact", -apple-system, sans-serif',fontWeight:900},children:a}),e.jsx("div",{className:"mt-1.5 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r})]})}function P({label:a,children:r}){return e.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"shrink-0 w-28 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"min-w-0 flex-1 text-oai-gray-900 dark:text-oai-gray-100 tabular-nums truncate flex items-baseline gap-2 flex-wrap",children:r})]})}function Me({user:a,onClose:r}){const t=G(a?.github_url);return e.jsxs("div",{className:"flex items-center gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60",children:[e.jsx(W,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"lg",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.rank?e.jsx("span",{className:c("shrink-0 inline-flex items-center px-2 py-0.5 rounded text-xs font-bold font-mono uppercase tracking-wider border shadow-sm",a.rank===1&&"bg-amber-500/10 text-amber-600 border-amber-500/20 dark:text-amber-400 dark:bg-amber-400/10",a.rank===2&&"bg-slate-500/10 text-slate-600 border-slate-500/20 dark:text-slate-400 dark:bg-slate-400/10",a.rank===3&&"bg-orange-500/10 text-orange-700 border-orange-500/20 dark:text-orange-400 dark:bg-orange-400/10",a.rank>3&&"bg-oai-gray-100 dark:bg-oai-gray-900/60 text-oai-gray-500 dark:text-oai-gray-400 border-oai-gray-200/60 dark:border-oai-gray-800"),children:n("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),t&&e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[12px] text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200 transition-colors",children:[e.jsx(T,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",t]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(E,{userId:a.user_id})}),r&&e.jsx("button",{type:"button",onClick:r,className:"shrink-0 -mr-1 -mt-1 flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-500 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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors group","aria-label":n("leaderboard.profile_modal.close"),children:e.jsx(ne,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function ze({user:a}){const r=G(a?.github_url),t=Number(a?.rank)||0,s=t===1?"text-amber-500 dark:text-amber-400":t===2?"text-slate-500 dark:text-slate-300":t===3?"text-orange-600 dark:text-orange-400":"text-oai-gray-400 dark:text-oai-gray-500";return e.jsxs("div",{className:"flex items-center gap-5 px-6 sm:px-8 pt-8 pb-7",children:[e.jsx(W,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"xl",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"truncate text-2xl sm:text-[28px] font-semibold tracking-tight leading-tight text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.user_id&&e.jsx(E,{userId:a.user_id})]}),r?e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white transition-colors",children:[e.jsx(T,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",r]})]}):null]}),t?e.jsxs("div",{className:"shrink-0 text-right leading-none",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:c("mt-1.5 text-3xl font-black tabular-nums tracking-tight",s),children:n("leaderboard.profile_modal.rank",{rank:t})})]}):null]})]})}function Pe({data:a}){const r=Array.isArray(a)?a:[];return r.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:r.map(t=>{const s=Math.max(0,Math.min(1,Number(t?.percent)||0));return e.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center justify-center w-4 h-4",children:e.jsx(T,{provider:String(t.source).toUpperCase(),size:14})}),e.jsx("span",{className:"shrink-0 capitalize w-16 text-oai-gray-700 dark:text-oai-gray-300",children:t.source}),e.jsx("span",{className:"flex-1 h-[3px] rounded-full bg-oai-gray-200/60 dark:bg-oai-gray-800/80 overflow-hidden",children:e.jsx("span",{className:"block h-full bg-oai-brand-500 dark:bg-oai-brand-400",style:{width:`${(s*100).toFixed(1)}%`}})}),e.jsx("span",{className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:$(t.total_tokens)}),e.jsxs("span",{className:"shrink-0 w-10 text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[(s*100).toFixed(0),"%"]})]},t.source)})})}function B({icon:a,label:r,value:t}){const[s,i]=g.useState(!1),l=async()=>{await de(t)&&(i(!0),setTimeout(()=>i(!1),1600))};return e.jsxs("button",{type:"button",onClick:l,className:c("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",s?"border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/[0.06]":"border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-gray-900 dark:hover:text-oai-gray-100 hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[s?e.jsx(xe,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:s?n("leaderboard.profile_modal.badge.copied"):r})]})}function Ce({data:a,currency:r,rate:t,onClose:s,variant:i="modal"}){const{user:l,totals:m,streak:d,best_day:p,models:y,by_provider:k,heatmap:j,period:M}=a,v=i==="page",b=g.useMemo(()=>Se(j),[j]),N=y?.favorite?.model_name,_=Number(y?.count)||0,u=re(),w=!!(u?.user?.id&&l?.user_id&&u.user.id===l.user_id),o=l?.user_id?`https://www.tokentracker.cc/u/${l.user_id}`:null,x=l?.user_id?`[}/functions/tokentracker-embed-svg?user_id=${l.user_id}&theme=dark)](${o}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[v?e.jsx(ze,{user:l}):e.jsx(Me,{user:l,onClose:s}),e.jsxs("div",{className:c("space-y-6",v?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"flex-1 min-h-0 overflow-y-auto oai-scrollbar px-6 py-5"),children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-4",children:[e.jsx(L,{value:$(m?.total_tokens),label:n("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(L,{value:H(m?.estimated_cost_usd,r,t),label:n("leaderboard.profile_modal.stat.total_cost")}),e.jsx(L,{value:String(m?.active_days??0),label:n("leaderboard.profile_modal.stat.active_days")}),e.jsx(L,{value:H(m?.avg_per_day_usd,r,t),label:n("leaderboard.profile_modal.stat.avg_per_day")})]}),e.jsxs("dl",{className:"space-y-2 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsxs(P,{label:n("leaderboard.profile_modal.streak.current"),children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:n("leaderboard.profile_modal.streak.days",{count:d?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",d?.longest_days??0,")"]})]}),e.jsx(P,{label:n("leaderboard.profile_modal.best_day.title"),children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:$(p.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",p.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.best_day.none")})}),e.jsx(P,{label:n("leaderboard.profile_modal.models.favorite"),children:N?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30 truncate max-w-[200px] inline-block align-bottom",children:N}),_>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:n("leaderboard.profile_modal.models.count",{count:_})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.models.none")})})]}),b&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(R,{children:n("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(me,{heatmap:b,hideLegend:!0,embedded:!0})})]}),e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(R,{children:n("leaderboard.profile_modal.providers.title")}),e.jsx(Pe,{data:k})]}),l?.user_id&&(s||w)&&e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-3",children:[s&&(se()?e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:s,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:n("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]}):e.jsxs(ie,{to:`/u/${l.user_id}`,onClick:s,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:n("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),w&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{icon:_e,label:n("leaderboard.profile_modal.badge.copy_url"),value:o}),e.jsx(B,{icon:ke,label:n("leaderboard.profile_modal.badge.copy"),value:x})]})]})]})]})}function $e({userId:a,period:r,accessToken:t,enabled:s=!0}){const[i,l]=g.useState({loading:!1,error:null,data:null});return g.useEffect(()=>{if(!s||!a)return;let m=!0;return l({loading:!0,error:null,data:null}),(async()=>{try{const d=t?await ee(t):null;if(!m)return;const p=await ae({accessToken:d,userId:a,period:r||"week"});if(!m)return;l({loading:!1,error:null,data:p})}catch(d){if(!m)return;d?.status===404?l({loading:!1,error:null,data:null}):l({loading:!1,error:d?.message||String(d),data:null})}})(),()=>{m=!1}},[s,a,r,t]),i}function We({isOpen:a,onClose:r,userId:t,period:s,accessToken:i}){const{currency:l,rate:m}=ce(),d=$e({userId:t,period:s,accessToken:i,enabled:a});return e.jsx(ge,{open:a,onOpenChange:p=>{p||r?.()},children:e.jsxs(pe,{children:[e.jsx(he,{className:"cost-modal-backdrop"}),e.jsx(fe,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(be,{className:c("cost-modal-popup","relative w-full max-w-[540px] max-h-[calc(100vh-2rem)] flex flex-col","rounded-2xl bg-white dark:bg-oai-gray-950","shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)]","ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden","dark:border-t dark:border-white/[0.08]"),children:[e.jsx(ue,{render:e.jsx("h2",{className:"sr-only"}),children:d.data?.user?.display_name||n("leaderboard.profile_modal.loading")}),d.loading&&e.jsx(Le,{}),!d.loading&&d.error&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:n("leaderboard.profile_modal.error")})}),!d.loading&&!d.error&&!d.data&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.profile_modal.empty")})}),!d.loading&&!d.error&&d.data&&e.jsx(Ce,{data:d.data,currency:l,rate:m,onClose:r})]})})]})})}export{We as LeaderboardProfileModal,Ce as ProfileContent,Le as ProfileSkeleton,$e as useLeaderboardProfileData};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as i,V as S,G as d,N as C,r as h,U as $,aG as W,i as B,L as G,aH as U}from"./main-D2iJg7iA.js";import{u as H}from"./use-usage-limits-DfKKdPYm.js";import{L as m,a as z,l as b,b as V,u as X}from"./use-limits-display-prefs-BDCL1zsb.js";import{C as I}from"./Card-DJZ6ntik.js";import{F as Y}from"./FadeIn-XjqQkcHf.js";import{L as q}from"./LocalOnlyNotice-CTKip6yZ.js";import"./arrow-up-right-DwYMKA3i.js";import"./download-BpLBXlyg.js";const J=[3,2,3,3,2,2,3];function f({className:e}){return i.jsx("div",{className:S("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",e)})}function Q(){return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(f,{className:"h-3 w-12 shrink-0"}),i.jsx(f,{className:"flex-1 h-1.5 rounded-full min-w-0"}),i.jsx(f,{className:"h-3 w-[30px] shrink-0"}),i.jsx(f,{className:"h-3 w-6 shrink-0"})]})}function Z({bars:e,index:t}){const n=t%3===0?"w-24":t%3===1?"w-20":"w-[4.5rem]";return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(f,{className:"h-[14px] w-[14px] rounded shrink-0"}),i.jsx(f,{className:S("h-4",n)})]}),Array.from({length:e},(a,r)=>i.jsx(Q,{},r))]})}function ee(){return i.jsx(I,{children:i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx(f,{className:"h-3.5 w-28"}),J.map((e,t)=>i.jsx(Z,{bars:e,index:t},t))]})})}function te(e,t){if(!(e>0))return null;const n=(e-t)/e;return Number.isFinite(n)?Math.min(Math.max(n,0),1):null}function ie(e,t,n=.03){return e>t+n}function ne(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600);return n>24?`${Math.floor(n/24)}d`:n>0?`${n}h`:`${Math.floor(t/60)}m`}function re(e,t){if(typeof e.windowSeconds=="number")return e.windowSeconds;if(e.windowSecondsField&&t){const n=t[e.windowSecondsField];return typeof n=="number"&&n>0?n:null}return null}function P(e){return e==null?NaN:typeof e=="number"?e*1e3:Date.parse(e)}function ae({usedPercent:e,windowSeconds:t,resetMs:n,mode:a,now:r=Date.now()}){const o=Math.min(Math.max(Number(e)||0,0),100)/100,s={pacePercent:null,paceOver:!1,expectedPercent:null,runsOutEta:null,projectedEnd:null};if(!(t>0)||!Number.isFinite(n))return s;const c=Math.max(0,(n-r)/1e3),l=te(t,c);if(l==null)return s;if(s.expectedPercent=Math.round(l*100),s.paceOver=ie(o,l),o>=.05){const u=a==="remaining"?1-l:l;s.pacePercent=u*100}if(l>.02&&o>0){const u=t*l,x=o/u,p=o/l;p>=1&&x>0?s.runsOutEta=ne((1-o)/x):s.projectedEnd=Math.round(Math.min(p,1)*100)}return s}const _=100;function E(e){const t=Date.parse(e);return Number.isFinite(t)?t:null}function le(e){return Math.max(0,Math.min(_,Math.round(e)))}function oe(e){return new Intl.DateTimeFormat(C(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(e))}function se(e,t,n){if(e==null||e>=t)return _;const a=t-e,r=t-n;return le(r/a*_)}function de(e){const t=e.available_count;return t===null?null:Number.isInteger(t)&&t>=0?t:void 0}function ce(e,{now:t}={}){if(!e||typeof e!="object")return null;const n=de(e);if(n===void 0)return null;const a=Array.isArray(e.credits)?e.credits:[],r=t instanceof Date?t.getTime():Number(t??Date.now()),o=[];for(const s of a){const c=E(s?.expires_at);if(c==null)continue;const l=o.length+1;o.push({key:`reset-${l}`,label:d("limits.codex_reset_bank.row_label",{index:l}),expiresAt:oe(c),percent:se(E(s?.granted_at),c,r)})}return n===0?null:o.length>0?{kind:"rows",availableCount:n??o.length,rows:o}:n>0?{kind:"count_only",availableCount:n,rows:[]}:null}const L={claude:{windows(e){return[{key:"5h",labelKey:"limits.label.claude_5h",window:e.five_hour,pctField:"utilization",resetField:"resets_at",windowSeconds:5*3600},{key:"7d",labelKey:"limits.label.claude_7d",window:e.seven_day,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400},{key:"opus",labelKey:"limits.label.claude_opus",window:e.seven_day_opus,pctField:"utilization",resetField:"resets_at",windowSeconds:7*86400}]}},codex:{extra:"codex_reset_bank",windows(e){return[{key:"5h",labelKey:"limits.label.codex_5h",window:e.primary_window,windowSecondsField:"limit_window_seconds"},{key:"7d",labelKey:"limits.label.codex_7d",window:e.secondary_window,windowSecondsField:"limit_window_seconds"},{key:"spark-5h",labelKey:"limits.label.codex_spark_5h",window:e.spark_primary_window,windowSecondsField:"limit_window_seconds"},{key:"spark-7d",labelKey:"limits.label.codex_spark_7d",window:e.spark_secondary_window,windowSecondsField:"limit_window_seconds"}]}},cursor:{windows(e){return[{key:"plan",labelKey:"limits.label.cursor_plan",window:e.primary_window},{key:"auto",labelKey:"limits.label.cursor_auto",window:e.secondary_window},{key:"api",labelKey:"limits.label.cursor_api",window:e.tertiary_window}]}},gemini:{windows(e){return[{key:"pro",labelKey:"limits.label.gemini_pro",window:e.primary_window},{key:"flash",labelKey:"limits.label.gemini_flash",window:e.secondary_window},{key:"lite",labelKey:"limits.label.gemini_lite",window:e.tertiary_window}]}},kimi:{extra:"kimi_parallel",windows(e){return[{key:"weekly",labelKey:"limits.label.kimi_weekly",window:e.primary_window,windowSeconds:7*86400},{key:"5h",labelKey:"limits.label.kimi_5h",window:e.secondary_window,windowSeconds:5*3600},{key:"total",labelKey:"limits.label.kimi_total",window:e.tertiary_window}]}},kiro:{windows(e){return[{key:"month",labelKey:"limits.label.kiro_month",window:e.primary_window},{key:"bonus",labelKey:"limits.label.kiro_bonus",window:e.secondary_window}]}},grok:{windows(e){return[{key:"month",labelKey:"limits.label.grok_month",window:e.primary_window},{key:"ondemand",labelKey:"limits.label.grok_ondemand",window:e.secondary_window}]}},antigravity:{windows(e){return[{key:"claude",labelKey:"limits.label.antigravity_claude",window:e.primary_window},{key:"gpro",labelKey:"limits.label.antigravity_gpro",window:e.secondary_window},{key:"flash",labelKey:"limits.label.antigravity_flash",window:e.tertiary_window}]}},copilot:{extra:"copilot_otel",windows(e){return[{key:"premium",labelKey:"limits.label.copilot_premium",window:e.primary_window},{key:"chat",labelKey:"limits.label.copilot_chat",window:e.secondary_window}]}}},ue="shrink-0 text-oai-black dark:text-oai-white";function me(e){const t=P(e);if(!Number.isFinite(t))return null;const n=t-Date.now();if(n<=0)return d("shared.time.now");const a=Math.floor(n/6e4);if(a<60)return`${a}m`;const r=Math.floor(a/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}function xe(e,t){const n=t===m.REMAINING?100-e:e;return n>=90?"bg-red-500":n>=70?"bg-amber-500":"bg-emerald-500"}function g(e,t="used_percent"){return e?t==="utilization"?e.utilization:e.used_percent:null}function R(e,t="reset_at"){return e?t==="resets_at"?e.resets_at:e.reset_at:null}function pe(e,t){return ae({usedPercent:g(e.window,e.pctField),windowSeconds:re(e,e.window),resetMs:P(R(e.window,e.resetField)),mode:t})}function we({label:e,pct:t,reset:n,mode:a=m.USED,pacePercent:r=null,paceOver:o=!1}){const s=Math.max(0,Math.min(100,Number(t)||0)),c=a===m.REMAINING?100-s:s,l=Math.round(c),u=c>0&&l===0?Math.max(c,.35):c;let x=String(l);c>0&&l===0&&(x=d("limits.bar.sub_one_percent"));const p=r==null?null:Math.max(0,Math.min(100,r));return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:e}),i.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[i.jsx("div",{className:`${xe(c,a)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${u}%`,minWidth:c>0?"3px":0}}),p!=null&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${p}% - 3px)`,width:"6px"}}),i.jsx("div",{className:`absolute top-0 h-full ${o?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${p}% - 1px)`,width:"2px"}})]})]}),i.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[x,"%"]}),n&&i.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:n})]})}function fe(e,t,n){const a=d(e.labelKey),r=n===m.REMAINING,o=l=>r?100-l:l;if(t.expectedPercent==null){const l=Math.round(Math.max(0,Math.min(100,Number(g(e.window,e.pctField))||0)));return r?d("limits.explain.remaining",{label:a,used:o(l)}):d("limits.explain.used",{label:a,used:l})}if(t.paceOver){if(t.runsOutEta)return d("limits.explain.ahead_eta",{label:a,eta:t.runsOutEta});const l=o(t.projectedEnd??100);return d(r?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:a,pct:l})}const s=Math.round(Math.max(0,Math.min(100,Number(g(e.window,e.pctField))||0))),c=o(t.projectedEnd??s);return d(r?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:a,pct:c})}function he({rows:e,mode:t}){if(e.length===0)return null;const n=t===m.REMAINING;return i.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[e.map(({spec:a,pace:r})=>i.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:fe(a,r,t)},a.key)),i.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:d(n?"limits.explain.body_remaining":"limits.explain.body")})]})}function k({name:e,providerId:t,children:n,expandable:a=!1,expanded:r=!1,onToggle:o}){const s=V(t),c=i.jsxs("div",{className:"flex items-center gap-1.5",children:[s?i.jsx($,{provider:s,size:14,className:ue}):null,i.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:e})]});return a?i.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":r,onClick:o,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[c,n]}):i.jsxs("div",{className:"flex flex-col gap-1.5",children:[c,n]})}const ye=z;function y({children:e,tone:t="neutral"}){const n=t==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return i.jsx("div",{className:`text-[11px] leading-snug ${n}`,children:e})}function ge({rows:e,mode:t,extra:n=null}){const a=e.length===0&&!n;return i.jsxs(i.Fragment,{children:[e.map(({spec:r,pace:o})=>i.jsx(we,{label:d(r.labelKey),pct:g(r.window,r.pctField),reset:me(R(r.window,r.resetField)),mode:t,pacePercent:o.pacePercent,paceOver:o.paceOver},r.key)),a?i.jsx(y,{children:d("limits.status.no_data")}):null,n]})}function be({row:e}){const t=Math.max(0,Math.min(100,Number(e.percent)||0));return i.jsxs("div",{className:"flex items-center gap-2","data-reset-bank-row":"",children:[i.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:e.label}),i.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:i.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${t}%`,minWidth:t>0?"3px":0}})}),i.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:e.expiresAt})]})}function _e({model:e}){const t=e.kind==="count_only"?d("limits.codex_reset_bank.count_only",{count:e.availableCount}):null;return i.jsxs("div",{className:"mt-1 flex flex-col gap-1","data-reset-bank-section":e.kind,children:[i.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:d("limits.codex_reset_bank.title")}),t?i.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:t}):e.rows.map(n=>i.jsx(be,{row:n},n.key))]})}function ke(e,t){if(e==="codex_reset_bank"){const n=ce(t.reset_credits);return n?i.jsx(_e,{model:n}):null}return e==="kimi_parallel"&&t.parallel_limit?i.jsx(y,{children:d("limits.label.kimi_parallel",{count:t.parallel_limit})}):e==="copilot_otel"&&!t.otel_has_files&&!t.otel_enabled?i.jsx(Ne,{defaultDir:t.otel_default_dir}):null}function je(e,t,n,a,r,o){const s=L[e];if(!s)return null;const c=s.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:pe(u,a)})),l=ke(s.extra,t);return i.jsxs(k,{name:n,providerId:e,expandable:c.length>0,expanded:r,onToggle:o,children:[i.jsx(ge,{mode:a,rows:c,extra:l}),r?i.jsx(he,{rows:c,mode:a}):null]},e)}function ve(e,t,n,a,r){if(!L[e])return null;if(!t?.configured)return i.jsx(k,{name:b(e),providerId:e,children:i.jsx(y,{children:d("limits.status.not_connected")})},e);if(t.error)return i.jsx(k,{name:b(e),providerId:e,children:i.jsx(y,{tone:"error",children:d("shared.error.prefix",{error:t.error})})},e);const o=b(e),s=t.plan_label?`${o} ${t.plan_label}`:o;return je(e,t,s,n,a,r)}function Ne({defaultDir:e}){const[t,n]=h.useState(!1),r=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${e||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
|
|
2
|
-
`),o=async s=>{s.stopPropagation();try{await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),1600)}catch{}};return i.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[i.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:d("limits.copilot.otelHint.title")}),i.jsx("div",{className:"mt-0.5 leading-snug",children:d("limits.copilot.otelHint.body")}),i.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:r}),i.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?d("limits.copilot.otelHint.copied"):d("limits.copilot.otelHint.copy")})]})}function Me(e){const[t,n]=h.useState(0);return h.useLayoutEffect(()=>{const a=e.current;if(!a)return;const r=a.querySelectorAll("[data-limit-label]");let o=0,s=null;if(r.length>0)try{s=document.createElement("canvas").getContext("2d")}catch{s=null}if(s){const l=window.getComputedStyle(r[0]);s.font=`${l.fontStyle} ${l.fontWeight} ${l.fontSize} ${l.fontFamily}`;for(const u of r)o=Math.max(o,s.measureText(u.textContent).width)}const c=Math.ceil(o);n(l=>l===c?l:c)}),t}function Ee({claude:e,codex:t,cursor:n,gemini:a,kimi:r,kiro:o,grok:s,antigravity:c,copilot:l,order:u,visibility:x,displayMode:p}){const F={claude:e,codex:t,cursor:n,gemini:a,kimi:r,kiro:o,grok:s,antigravity:c,copilot:l},j=h.useRef(null),v=Me(j),[O,K]=h.useState(null),T=Array.isArray(u)&&u.length>0?u:ye,N=p===m.REMAINING?m.REMAINING:m.USED,D=N===m.REMAINING?d("limits.settings.display_mode_remaining"):d("limits.settings.display_mode_used"),M=T.filter(w=>!x||x[w]!==!1).map(w=>ve(w,F[w],N,O===w,()=>K(A=>A===w?null:w))).filter(Boolean);return i.jsx(Y,{delay:.15,children:i.jsx(I,{children:i.jsxs("div",{ref:j,className:"flex flex-col gap-3",style:v>0?{"--tt-limits-label-w":`${v}px`}:void 0,children:[i.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[d("limits.panel.title"),d("limits.panel.mode_separator"),D]}),M.length>0?M:i.jsx(y,{children:d("limits.status.all_hidden")})]})})})}const Se=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");function De(){const e=W(),{data:t,error:n,isLoading:a}=H(e?{initialRefresh:!0,initialState:e,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),r=X();return!Se&&!B()?i.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:i.jsx(q,{})}):i.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:i.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:i.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[i.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:d("nav.limits")}),i.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:d("limits.page.subtitle")})]}),i.jsx(G,{to:"/settings","aria-label":d("limits.page.openSettings"),title:d("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:i.jsx(U,{className:"h-4 w-4","aria-hidden":!0})})]}),a?i.jsx(ee,{}):i.jsxs(i.Fragment,{children:[n?i.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:d("shared.error.prefix",{error:n})}):null,i.jsx(Ee,{claude:t?.claude,codex:t?.codex,cursor:t?.cursor,gemini:t?.gemini,kimi:t?.kimi,kiro:t?.kiro,grok:t?.grok,antigravity:t?.antigravity,copilot:t?.copilot,order:r.order,visibility:r.visibility,displayMode:r.displayMode})]})]})})})}export{De as LimitsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as u,r as a,a_ as M,a$ as j,b0 as G,b1 as J}from"./main-D2iJg7iA.js";const B=["claude","codex","cursor","gemini","kimi","kiro","grok","copilot","antigravity"],q={claude:"CLAUDE",codex:"CODEX",cursor:"CURSOR",gemini:"GEMINI",kimi:"KIMI",kiro:"KIRO",grok:"GROK",copilot:"COPILOT",antigravity:"ANTIGRAVITY"};function se(e){return q[e]||null}function ae(e){switch(e){case"claude":return u("limits.provider.claude");case"codex":return u("limits.provider.codex");case"cursor":return u("limits.provider.cursor");case"gemini":return u("limits.provider.gemini");case"kimi":return u("limits.provider.kimi");case"kiro":return u("limits.provider.kiro");case"grok":return u("limits.provider.grok");case"copilot":return u("limits.provider.copilot");case"antigravity":return u("limits.provider.antigravity");default:return String(e||"")}}const y=B,A="tt.limits.providerOrder",E="tt.limits.providerVisibility",h="tt.limits.displayMode",O="tt.limits.updatedAt",V="limitsPreferences",F="limitsDisplayMode",v=Object.freeze({USED:"used",REMAINING:"remaining"}),g=new Set(Object.values(v)),L=new Set([A,E,h,O]);function I(){return[...y]}function b(){return Object.fromEntries(y.map(e=>[e,!0]))}function _(e){const r=[];if(Array.isArray(e))for(const n of e)y.includes(n)&&!r.includes(n)&&r.push(n);for(const n of y)r.includes(n)||r.push(n);return r}function N(e){const r=b();if(!e||typeof e!="object"||Array.isArray(e))return r;for(const n of y)typeof e[n]=="boolean"&&(r[n]=e[n]);return r}function X(e){return g.has(e)?e:v.USED}function m(e){if(e!=null){if(typeof e=="number")return Number.isSafeInteger(e)?e:void 0;if(typeof e=="string"){const r=e.trim();if(r==="")return;const n=Number(r);return Number.isSafeInteger(n)?n:void 0}}}function w(e={}){const r=e&&typeof e=="object"?e:{};return{displayMode:X(r.displayMode),providerOrder:_(r.providerOrder),providerVisibility:N(r.providerVisibility),updatedAt:m(r.updatedAt)}}function $(){if(typeof window>"u")return I();try{const e=window.localStorage.getItem(A);return _(e?JSON.parse(e):void 0)}catch{return I()}}function H(){if(typeof window>"u")return b();try{const e=window.localStorage.getItem(E);return N(e?JSON.parse(e):void 0)}catch{return b()}}function Q(){if(typeof window>"u")return v.USED;try{const e=window.localStorage.getItem(h);return g.has(e)?e:v.USED}catch{return v.USED}}function W(){if(!(typeof window>"u"))try{return m(window.localStorage.getItem(O))}catch{return}}function Z(){if(typeof window>"u")return!1;try{for(const e of L)if(window.localStorage.getItem(e)!==null)return!0}catch{return!1}return!1}function S(){return w({displayMode:Q(),providerOrder:$(),providerVisibility:H(),updatedAt:W()})}function ee(e){if(typeof window>"u")return;const r=w(e);try{window.localStorage.setItem(A,JSON.stringify(r.providerOrder)),window.localStorage.setItem(E,JSON.stringify(r.providerVisibility)),window.localStorage.setItem(h,r.displayMode),r.updatedAt===void 0?window.localStorage.removeItem(O):window.localStorage.setItem(O,String(r.updatedAt))}catch(n){console.warn("[tokentracker] limits preferences localStorage write failed:",n)}}function re(e){const r=w(e);return{displayMode:r.displayMode,providerOrder:[...r.providerOrder],providerVisibility:{...r.providerVisibility},updatedAt:r.updatedAt??null}}function te(...e){let r;for(const s of e){const l=m(s);l!==void 0&&(r=r===void 0?l:Math.max(r,l))}const n=Date.now();return r!==void 0&&n<=r?r+1:n}function ie(e,r){return e.length===r.length&&e.every((n,s)=>n===r[s])}function ne(e,r){return y.every(n=>e[n]===r[n])}function R(e,r){return e.displayMode===r.displayMode&&ie(e.providerOrder,r.providerOrder)&&ne(e.providerVisibility,r.providerVisibility)}function oe(e,r){return R(e,r)&&m(e.updatedAt)===m(r.updatedAt)}function k(e,r){const n=m(e.updatedAt),s=m(r.updatedAt);return n!==void 0&&(s===void 0||n>s)}function ce(){const[e,r]=a.useState(S),n=a.useRef(e),s=a.useCallback((o,t={})=>{const i=w(o);return n.current=i,r(i),t.writeLocal&&ee(i),i},[]),l=a.useCallback(o=>{M()&&j(V,re(o))},[]),c=a.useCallback(o=>{const t=S(),i=k(t,n.current)?s(t):n.current,d=w(o(i));if(R(i,d))return;const f=te(t.updatedAt,i.updatedAt),p=s({...d,updatedAt:f},{writeLocal:!0});l(p)},[s,l]),P=a.useCallback(o=>{g.has(o)&&c(t=>({...t,displayMode:o}))},[c]),D=a.useCallback(o=>{if(!g.has(o))return;const t=S();if(t.updatedAt!==void 0){s(t);return}s({...t,displayMode:o,updatedAt:void 0},{writeLocal:!0})},[s]);a.useEffect(()=>{if(!M())return;const o=G(t=>{const i=t?.[V];if(i&&typeof i=="object"){const d=w(i);if(!Z()){s(d,{writeLocal:!0});return}const f=S();if(k(d,f))s(d,{writeLocal:!0});else{const p=s(f);oe(d,f)||l(p)}return}D(t?.[F])});return J(),o},[D,s,l]),a.useEffect(()=>{if(typeof window>"u")return;const o=t=>{(t.key===null||L.has(t.key))&&s(S())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[s]);const x=a.useCallback(o=>{y.includes(o)&&c(t=>({...t,providerVisibility:{...t.providerVisibility,[o]:!t.providerVisibility[o]}}))},[c]),C=a.useCallback(o=>{c(t=>{const i=t.providerOrder.indexOf(o);if(i<=0)return t;const d=[...t.providerOrder];return[d[i-1],d[i]]=[d[i],d[i-1]],{...t,providerOrder:d}})},[c]),U=a.useCallback(o=>{c(t=>{const i=t.providerOrder.indexOf(o);if(i<0||i>=t.providerOrder.length-1)return t;const d=[...t.providerOrder];return[d[i],d[i+1]]=[d[i+1],d[i]],{...t,providerOrder:d}})},[c]),T=a.useCallback((o,t)=>{o!==t&&c(i=>{const d=i.providerOrder.indexOf(o),f=i.providerOrder.indexOf(t);if(d<0||f<0)return i;const p=[...i.providerOrder],[z]=p.splice(d,1);return p.splice(f,0,z),{...i,providerOrder:p}})},[c]),Y=a.useCallback(()=>{c(()=>({displayMode:v.USED,providerOrder:I(),providerVisibility:b()}))},[c]),K=a.useMemo(()=>e.providerOrder.filter(o=>e.providerVisibility[o]!==!1),[e.providerOrder,e.providerVisibility]);return{order:e.providerOrder,visibility:e.providerVisibility,displayMode:e.displayMode,setDisplayMode:P,visibleOrdered:K,toggle:x,moveUp:C,moveDown:U,moveToward:T,reset:Y}}export{v as L,B as a,se as b,ae as l,ce as u};
|