tokentracker-cli 0.82.2 → 0.83.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/dashboard/dist/assets/{AchievementBadge-Dz8bedOl.js → AchievementBadge-CFuXV5fe.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-DYeOB_b5.js → AchievementsPage-BZjeqSoK.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-ByvPCFbJ.js → AchievementsSection-CbUEDJz0.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-CyfdVn-N.js → BadgeDetailModal-DEKnEruJ.js} +1 -1
- package/dashboard/dist/assets/{Card-C-9AAzrt.js → Card-BfIA_INW.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-85mtsgNG.js → ClawdAnimated-CwR_ecYb.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-BcY_bUKs.js → CommunityStatsModal-DbvrEHOl.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-1F-oKSQV.js → ConfirmModal-C8j0RpGd.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-iHzYecBI.js +1 -0
- package/dashboard/dist/assets/{DevicePage-Dz6nuSzK.js → DevicePage-RjjWbW4F.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-DoAFJvy1.js → DialogClose-DTi8qCfV.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-B1bA7SgT.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-DXvcoQzl.js → DialogTitle-DS810PC0.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-C8JjNrTO.js → FadeIn-BdzFMsS_.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-xAchQaWn.js → HeaderGithubStar-C2QtX7sw.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BMAw8ydi.js → IpCheckPage-CgMt9L_t.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-DHQemdKQ.js → LandingPage-CVUU3YZx.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardAvatar-BJULUEGJ.js → LeaderboardAvatar-CVvOwhnW.js} +1 -1
- package/dashboard/dist/assets/LeaderboardPage-Cu5LKqRp.js +2 -0
- package/dashboard/dist/assets/{LeaderboardProfileModal-B2gmyvsz.js → LeaderboardProfileModal-BUydt-W1.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-CcPzqTDF.js → LeaderboardProfilePage-DS0-21QT.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-BahJx6CU.js → LimitsPage-BPs_yxZq.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-tbkd3Hic.js → LocalOnlyNotice-BaK2hDrE.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-DH94HwWF.js → LoginPage-B1LXDbg1.js} +1 -1
- package/dashboard/dist/assets/{PetPage-Bgha7egO.js → PetPage-CcQkf379.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-kRGuXnS1.js → PopoverPopup-Bi8OnMB7.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-DDJBMz-A.js → ResetPasswordPage-DWmnjhYZ.js} +1 -1
- package/dashboard/dist/assets/{Select-DbPDNra5.js → Select-DZKuIQbj.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-D5FrEa78.js → SelectItemText-BR4lCZFV.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-DC3zR4gl.js → SettingsPage-BBSl_Z-L.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-CnmtS3f-.js → SkillsPage-CqCEBfol.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-DixWn0Ji.js → TrendMonitor-B3BX8OWh.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-9TJfxcmr.js → WidgetsPage-DGlgqfrI.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-DiEg9GtQ.js → WrappedPage-3NmejmVU.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-BQjn-jcg.js → __vite-browser-external-BoyaLR3G.js} +16 -16
- package/dashboard/dist/assets/{__vite-browser-external-DWSIu6d0.css → __vite-browser-external-C44tPAD-.css} +1 -1
- package/dashboard/dist/assets/{agent-logos-9DPVn5O-.js → agent-logos-D17Yygwp.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-DRXKp-g8.js → arrow-up-right-DvzvdSQb.js} +1 -1
- package/dashboard/dist/assets/{check-Bp-cxir1.js → check-CoXa_Xbp.js} +1 -1
- package/dashboard/dist/assets/{copy-eRWKRZgV.js → copy-Dj_-rH-c.js} +1 -1
- package/dashboard/dist/assets/{download-BYBgztAF.js → download-CR4S1Aif.js} +1 -1
- package/dashboard/dist/assets/{flame-Dn3di8Oc.js → flame-nDDFx8aX.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-CUBOjHb3.js → format-tokens-B1ivtp29.js} +1 -1
- package/dashboard/dist/assets/{icons-DGmKoYrQ.js → icons-DcLZmQNe.js} +1 -1
- package/dashboard/dist/assets/{info-hNxx3heq.js → info-DSsp1azO.js} +1 -1
- package/dashboard/dist/assets/{limits-providers-DbDbUJlS.js → limits-providers-B4Uj6owF.js} +1 -1
- package/dashboard/dist/assets/{link-2-DLpasKnO.js → link-2-XUFa3f41.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-Dr8XBEwL.js → loader-circle-BirzI_cK.js} +1 -1
- package/dashboard/dist/assets/{provider-display-BaIvawBI.js → provider-display-BhSu_Pfw.js} +2 -2
- package/dashboard/dist/assets/{terminal-XHI11uAB.js → terminal-BcVv_u2s.js} +1 -1
- package/dashboard/dist/assets/{trash-2-B_iuyhQd.js → trash-2-ChpB4JZy.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-DXyHOYbX.js → use-community-stats-CdwfjUzX.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-BdFQf_ea.js → use-limits-display-prefs-Dux0zZ9d.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-Gia9MO-Y.js → use-native-settings-B3uhNxG6.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-m5UXCO_e.js → use-ordered-list-CGzxXBMg.js} +1 -1
- package/dashboard/dist/assets/{use-session-efficiency-pref-wCgbduxT.js → use-session-efficiency-pref-D46S_ial.js} +1 -1
- package/dashboard/dist/assets/{use-transform-CqiRAEK5.js → use-transform-CTs3oD8M.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-B-zrEGe6.js → use-usage-limits-Bg7JDy3y.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-ko1kI_y1.js → useCurrency-gI4OcAFt.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-C24aFA2G.js → useScrollLock-Bf0bCnKB.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-CNxtNtIi.js → useTokenFormat-LEqBrCju.js} +1 -1
- package/dashboard/dist/assets/{zap-Dqpw2hFM.js → zap-DFBBQ-y1.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +1 -1
- package/src/lib/pricing/index.js +5 -0
- package/src/lib/pricing/matcher.js +1 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +19 -2
- package/dashboard/dist/assets/DashboardPage-ClasFW2f.js +0 -1
- package/dashboard/dist/assets/DialogDescription-DHznQh6m.js +0 -1
- package/dashboard/dist/assets/LeaderboardPage-CwIJH5cz.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as va,a7 as No,bY as Ts,cM as So,r as d,a4 as Co,j as e,L as To,w as Ds,x as _e,cN as Do,I as ct,aw as Ot,cO as Ie,cP as Ao,cQ as Lo,ae as Br,cR as da,cS as As,cT as Ls,cU as fr,cV as Mo,cW as Eo,cX as Ro,cY as pr,cZ as zt,c_ as Io,c$ as Fo,d0 as re,c as l,R as wt,X as yr,aC as ja,af as Na,i as Ze,v as Ms,d1 as $o,aZ as ka,P as Nt,b as vt,d2 as Po,H as Es,F as Rs,K as br,W as Bo,B as zo,ah as Oo,Y as Uo,e as Is,cc as Ho,d3 as Vo,d4 as Wo,d5 as Ko,l as pa,f as zr,d6 as Go,N as Or,_ as qo,d7 as Ur,g as Yo,bj as Zo,cL as Jo,d8 as Qo,d9 as Xo,da as ei,db as ti,dc as ai,dd as ri,de as si,am as ni,df as oi,dg as ii,dh as Hr,ag as Vr,di as li}from"./__vite-browser-external-BoyaLR3G.js";import{a as Wr,u as ci,C as di,b as ui,c as Kr,D as mi,S as hi,v as xi,s as gi,K as fi,P as pi}from"./use-ordered-list-CGzxXBMg.js";import{u as Ut,T as Fs,g as yi,f as Gr,D as bi,a as ki,b as wi}from"./TrendMonitor-B3BX8OWh.js";import{u as _i}from"./use-usage-limits-Bg7JDy3y.js";import{u as Sa}from"./useCurrency-gI4OcAFt.js";import{u as Fe}from"./useTokenFormat-LEqBrCju.js";import{f as _t,A as vi}from"./provider-display-BhSu_Pfw.js";import{D as ji,a as Ni,b as Si,c as Ci,d as Ti,e as Di}from"./DialogTitle-DS810PC0.js";import{D as Ai}from"./DialogClose-DTi8qCfV.js";import{C as Ne}from"./Card-BfIA_INW.js";import{S as $s}from"./Select-DZKuIQbj.js";import{a as Ps,u as Bs}from"./use-transform-CTs3oD8M.js";import{I as zs}from"./info-DSsp1azO.js";import{C as Li,P as Mi,a as Ei,b as Ri,c as Ii,d as Fi}from"./PopoverPopup-Bi8OnMB7.js";import{L as $i}from"./loader-circle-BirzI_cK.js";import{F as rt}from"./FadeIn-BdzFMsS_.js";import{C as Pi}from"./ClawdAnimated-CwR_ecYb.js";import{u as Bi,a as zi,P as Oi}from"./use-session-efficiency-pref-D46S_ial.js";import{L as Ui,A as Hi}from"./agent-logos-D17Yygwp.js";import{C as Vi}from"./check-CoXa_Xbp.js";import"./terminal-BcVv_u2s.js";import"./limits-providers-B4Uj6owF.js";import"./useScrollLock-Bf0bCnKB.js";import"./SelectItemText-BR4lCZFV.js";const Wi=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Ki=va("git-branch",Wi);const Gi=[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]],qi=va("laptop",Gi);const Yi=[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]],Os=va("monitor-smartphone",Yi);const Zi=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],Ji=va("square-arrow-out-up-right",Zi);function Qi(t,a,r={}){const s=t.get();let n=null,o=s,i;const u=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,c=()=>{n&&(n.stop(),n=null),t.animation=void 0},x=()=>{const g=qr(t.get()),m=qr(o);if(g===m){c();return}const f=n?n.getGeneratorVelocity():t.getVelocity();c(),n=new So({keyframes:[g,m],velocity:f,type:"spring",restDelta:.001,restSpeed:.01,...r,onUpdate:i})},h=()=>{x(),t.animation=n??void 0,t.events.animationStart?.notify(),n?.then(()=>{t.animation=void 0,t.events.animationComplete?.notify()})};if(t.attach((g,m)=>{o=g,i=f=>m(Ga(f,u)),No.postRender(h)},c),Ts(a)){let g=r.skipInitialAnimation===!0;const m=a.on("change",p=>{g?(g=!1,t.jump(Ga(p,u),!1)):t.set(Ga(p,u))}),f=t.on("destroy",m);return()=>{m(),f()}}return c}function Ga(t,a){return a?t+a:t}function qr(t){return typeof t=="number"?t:parseFloat(t)}function Xi(t,a={}){const{isStatic:r}=d.useContext(Co),s=()=>Ts(t)?t.get():t;if(r)return Ps(s);const n=Bs(s());return d.useInsertionEffect(()=>Qi(n,t,a),[n,JSON.stringify(a)]),n}function el(t,a={}){return Xi(t,{type:"spring",...a})}function tl(){return e.jsxs(To,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[e.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function al({children:t,header:a,footer:r,className:s="",hideHeader:n=!1,hideFooter:o=!1,bare:i=!1}){return i?e.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${s}`,children:[e.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!o&&r&&e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:r})]}):e.jsxs("div",{className:`min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-sans flex flex-col transition-colors duration-200 ${s}`,children:[!n&&e.jsxs("header",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 flex items-center justify-between transition-colors duration-200",children:[e.jsx(tl,{}),e.jsx("div",{className:"flex-1 flex justify-center",children:a})]}),e.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!o&&r&&e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:r})]})}function rl({children:t,variant:a="info",size:r="md",className:s=""}){const n="inline-flex items-center font-medium",o={success:"bg-oai-brand-100 dark:bg-oai-brand-900/30 text-oai-brand-700 dark:text-oai-brand-400 rounded-full",warning:"bg-oai-amber-50 dark:bg-oai-amber-900/30 text-oai-amber-dark dark:text-oai-amber-400 rounded-full",error:"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded-full",info:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 rounded-full",secondary:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-500 dark:text-oai-gray-300 rounded-md"},i={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},u=`${n} ${o[a]} ${i[r]} ${s}`.trim();return e.jsx("span",{className:u,children:t})}var sl={};function nl(t,a){return t==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:t===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:a}}function ol({mv:t,digit:a,height:r}){const s=Ps(t,n=>{const o=(n%10+10)%10,i=(10+a-o)%10;let u=i*r;return i>5&&(u-=10*r),u});return e.jsx(_e.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:s},children:a})}function il(t){const a=Math.round(t),r=1e-9*Math.max(1,Math.abs(t));return Math.abs(t-a)<r?a:t}function ll(t,a){const r=t/a;return Math.floor(il(r))}function cl(t){const a=String(t??""),r=Array.from(a),s=r.indexOf(".");let n=r.filter((u,c)=>/\d/.test(u)&&(s===-1||c<s)).length,o=0,i=!1;return r.map(u=>{if(!/\d/.test(u))return u==="."&&(i=!0),u;if(!i){const c=10**Math.max(n-1,0);return n-=1,c}return o+=1,10**-o})}function dl({place:t,value:a,height:r,digitStyle:s,shouldReduceMotion:n}){if(typeof t!="number"){const c=nl(t,r),x=t!=="."&&t!==",",h=t===".";return e.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:r,...c,...s,...x?{width:"auto",paddingInline:"0.06ch",justifyContent:"center"}:null,...h?{width:c.width}:null},children:t})}const o=ll(a,t),i=Bs(0),u=el(i,{stiffness:220,damping:26,mass:.8});return d.useEffect(()=>{i.set(o)},[i,o]),n?e.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:r,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...s},children:Math.abs(o)%10}):e.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:r,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...s},children:Array.from({length:10},(c,x)=>e.jsx(ol,{mv:u,digit:x,height:r},x))})}function ul({value:t,displayValue:a,fontSize:r=72,padding:s=0,places:n,gap:o=6,borderRadius:i=4,horizontalPadding:u=0,textColor:c="inherit",fontWeight:x="inherit",containerStyle:h,counterStyle:g,digitStyle:m,gradientHeight:f=14,gradientFrom:p="rgba(255,255,255,0.95)",gradientTo:k="rgba(255,255,255,0)",topGradientStyle:y,bottomGradientStyle:v}){const _=String(a??t??""),A=d.useMemo(()=>Array.isArray(n)&&n.length?n:cl(_),[n,_]),T=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&sl?.VITEST==="true",M=Ds()||T,L=Number.isFinite(Number(t))?Math.abs(Number(t)):0,U=r+s;return M?e.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:c,fontSize:r,fontWeight:x,lineHeight:1,...h,...g},children:_}):e.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...h},children:[e.jsx("span",{style:{fontSize:r,display:"flex",gap:o,overflow:"hidden",borderRadius:i,paddingLeft:u,paddingRight:u,lineHeight:1,color:c,fontWeight:x,...g},children:A.map((w,j)=>e.jsx(dl,{place:w,value:L,height:U,digitStyle:m,shouldReduceMotion:M},`${String(w)}-${j}`))}),e.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[e.jsx("span",{style:y??{height:f,background:`linear-gradient(to bottom, ${p}, ${k})`}}),e.jsx("span",{style:v??{height:f,background:`linear-gradient(to top, ${p}, ${k})`}})]})]})}function ml({baseUrl:t,accessToken:a,guestAllowed:r=!1,weeks:s=52,weekStartsOn:n="sun",cacheKey:o,timeZone:i,tzOffsetMinutes:u,now:c,accountView:x=!1,accountAccessToken:h=null,accountRevision:g=0,accountViewResolving:m=!1,deviceId:f=null}={}){const p=!!(x&&h),k=p?"cloud":"local",y=d.useMemo(()=>Do({weeks:s,weekStartsOn:n,now:c}),[c,s,n]),[v,_]=d.useState([]),[A,T]=d.useState(null),[M,L]=d.useState("edge"),[U,w]=d.useState(!1),[j,D]=d.useState(null),P=ct(),O=Ot(a),V=!r,E=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),R=d.useMemo(()=>{if(!o)return null;const J=fr({timeZone:i,offsetMinutes:u});return`tokentracker.heatmap.${o}.${k}.${s}.${n}.${J}.${f||"all"}`},[o,f,k,i,u,s,n]),q=d.useCallback(()=>{if(!R||typeof window>"u")return null;try{const J=window.localStorage.getItem(R);if(!J)return null;const de=JSON.parse(J);return!de||!de.heatmap?null:de}catch{return null}},[R]),N=d.useCallback(J=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(J))}catch{}},[R]),S=d.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),Y=d.useRef(k);d.useEffect(()=>{Y.current!==k&&(Y.current=k,_([]),T(null),L("edge"),D(null),w(!0))},[k]);const H=d.useCallback(async()=>{const J=await Ie(a),de=p?await Ie(h):null;if(!J&&!P&&!E&&!p)return;if(p&&!de){D("Your session expired. Please sign in again to view account data."),w(!1);return}const oe=p?de:J,he=p?Ao:Lo,ye=p?As:Ls;w(!0),D(null);try{try{const B=await he({baseUrl:t,accessToken:oe,weeks:s,to:y.to,weekStartsOn:n,device:f,timeZone:i,tzOffsetMinutes:u}),X=Array.isArray(B?.weeks)?B.weeks:[];if(!X.length&&V){const W=q();if(W?.heatmap){T(W.heatmap),_(W.daily||[]),L("cache");return}}if(!X.some(W=>(Array.isArray(W)?W:[]).some(C=>C&&Number.isFinite(Number(C.level))))&&X.length){const W=[];for(const z of X)for(const F of Array.isArray(z)?z:[])F?.day&&W.push({day:F.day,total_tokens:F.total_tokens??F.value??0,billable_total_tokens:F.billable_total_tokens??F.value??F.total_tokens??0});const C=Br({dailyRows:W,weeks:s,to:B?.to||y.to,weekStartsOn:n});_(W),T({...C,week_starts_on:n,active_days:W.filter(z=>Number(z?.billable_total_tokens??z?.total_tokens)>0).length,streak_days:da({dailyRows:W,to:B?.to||y.to})}),L("client"),V?N({heatmap:{...C,week_starts_on:n,active_days:W.filter(z=>Number(z?.billable_total_tokens??z?.total_tokens)>0).length,streak_days:da({dailyRows:W,to:B?.to||y.to})},daily:W,fetchedAt:new Date().toISOString()}):S();return}T(B||null),_([]),L("edge"),B&&V?N({heatmap:B,daily:[],fetchedAt:new Date().toISOString()}):V||S();return}catch(B){const X=B,xe=X?.status??X?.statusCode;if(xe===401||xe===403)throw B}const ue=await ye({baseUrl:t,accessToken:oe,from:y.from,to:y.to,device:f,timeZone:i,tzOffsetMinutes:u}),ee=Array.isArray(ue?.data)?ue.data:[];_(ee);const Q=Br({dailyRows:ee,weeks:s,to:y.to,weekStartsOn:n});T({...Q,week_starts_on:n,active_days:ee.filter(B=>Number(B?.billable_total_tokens??B?.total_tokens)>0).length,streak_days:da({dailyRows:ee,to:y.to})}),L("client"),V?N({heatmap:{...Q,week_starts_on:n,active_days:ee.filter(B=>Number(B?.billable_total_tokens??B?.total_tokens)>0).length,streak_days:da({dailyRows:ee,to:y.to})},daily:ee,fetchedAt:new Date().toISOString()}):S()}catch(ue){if(V){const ee=q();if(ee?.heatmap)T(ee.heatmap),_(ee.daily||[]),L("cache"),D(null);else{const Q=ue;D(Q?.message||String(Q)),_([]),T(null),L("edge")}}else{const ee=ue;D(ee?.message||String(ee)),_([]),T(null),L("edge")}}finally{w(!1)}},[a,t,P,r,V,y.from,y.to,q,O,i,u,n,s,S,N,E,p,h,g,f]);return d.useEffect(()=>{if(m){w(!0);return}if(!O&&!r&&!P&&!E&&!p){_([]),w(!1),D(null),T(null),L("edge");return}if(!V)S(),_([]),D(null),T(null),L("edge");else{const J=q();J?.heatmap&&(T(J.heatmap),_(J.daily||[]),L("cache"))}H()},[a,P,q,H,O,r,V,S,E,m]),{range:y,daily:v,heatmap:A,source:P?"mock":M==="client"?"edge":M,loading:U,error:j,refresh:H}}const hl="tokentracker.dashboard.leftCardOrder.v1",xl="tokentracker.dashboard.rightCardOrder.v1";function gl(t,a){const r=Wr(hl,t),s=Wr(xl,a),n=r.order.join("|")!==t.join("|")||s.order.join("|")!==a.join("|"),o=d.useCallback(()=>{r.reset(),s.reset()},[r,s]);return{left:r,right:s,isCustomized:n,resetAll:o}}const fl=10;function pl({baseUrl:t,accessToken:a,from:r,to:s,source:n,timeZone:o,tzOffsetMinutes:i}={}){const[u,c]=d.useState([]),[x,h]=d.useState(!1),[g,m]=d.useState(null),f=ct(),p=Ot(a),k=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),y=Ut([t,a,r,s,n,o,i]),v=d.useCallback(async()=>{const _=y(),A=await Ie(a);if(_()){if(!A&&!f&&!k){c([]),m(null),h(!1);return}h(!0),m(null);try{const T=await Mo({baseUrl:t,accessToken:A,limit:fl,from:r,to:s,source:n,timeZone:o,tzOffsetMinutes:i});if(!_())return;c(Array.isArray(T?.entries)?T.entries:[])}catch(T){if(!_())return;const M=T?.message||String(T);m(M),c([])}finally{_()&&h(!1)}}},[a,t,r,f,n,o,s,i,k,y]);return d.useEffect(()=>{if(!p&&!f&&!k){c([]),m(null),h(!1);return}c([]),m(null),h(!0),v()},[f,v,p,k]),{entries:u,loading:x,error:g,refresh:v}}function Yr({baseUrl:t,accessToken:a,guestAllowed:r=!1,from:s,to:n,includeDaily:o=!0,includeSummary:i=!0,cacheKey:u,timeZone:c,tzOffsetMinutes:x,now:h,accountView:g=!1,accountAccessToken:m=null,accountRevision:f=0,accountViewResolving:p=!1,deviceId:k=null}={}){const y=!!(g&&m),v=y?"cloud":"local",[_,A]=d.useState([]),[T,M]=d.useState(null),[L,U]=d.useState(null),[w,j]=d.useState("edge"),[D,P]=d.useState(null),[O,V]=d.useState(!1),[E,R]=d.useState(null),q=ct(),N=Ot(a),S=!r&&!q,Y=k||"all",H=(()=>{if(!u)return null;const Q=yl(t)||"default",B=o?i?"daily-summary":"daily-only":"summary",X=fr({timeZone:c,offsetMinutes:x});return`tokentracker.usage.${u}.${v}.${Q}.${s}.${n}.${B}.${X}.${Y}`})(),ce=d.useRef(v);d.useEffect(()=>{ce.current!==v&&(ce.current=v,A([]),M(null),U(null),j("edge"),P(null),R(null),V(!0))},[v]);const J=d.useCallback(()=>{if(!H||typeof window>"u")return null;try{const Q=window.localStorage.getItem(H);if(!Q)return null;const B=JSON.parse(Q),X=i?!!B?.summary:Array.isArray(B?.daily);return!B||!X?null:B}catch{return null}},[i,H]),de=d.useCallback(Q=>{if(!(!H||typeof window>"u"))try{window.localStorage.setItem(H,JSON.stringify(Q))}catch{}},[H]),oe=d.useCallback(()=>{if(!(!H||typeof window>"u"))try{window.localStorage.removeItem(H)}catch{}},[H]),he=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),ye=Ut([t,s,n,o,i,v,a,m,f,k,c,x]),ue=d.useCallback(async()=>{const Q=ye(),B=await Ie(a),X=y?await Ie(m):null;if(!Q()||!B&&!q&&!he&&!y)return;if(y&&!X){R("Your session expired. Please sign in again to view account data."),V(!1);return}const xe=y?As:Ls,W=y?Eo:Ro,C=y?X:B;V(!0),R(null);try{let z=null,F=null;if(o)if(i){const[Le,Se]=await Promise.allSettled([xe({baseUrl:t,accessToken:C,from:s,to:n,device:k,timeZone:c,tzOffsetMinutes:x}),W({baseUrl:t,accessToken:C,from:s,to:n,device:k,timeZone:c,tzOffsetMinutes:x,rolling:!0})]);if(Le.status==="rejected")throw Le.reason;z=Le.value,F=Se.status==="fulfilled"?Se.value:null}else z=await xe({baseUrl:t,accessToken:C,from:s,to:n,device:k,timeZone:c,tzOffsetMinutes:x});else i&&(F=await W({baseUrl:t,accessToken:C,from:s,to:n,device:k,timeZone:c,tzOffsetMinutes:x,rolling:!0}));let K=o&&Array.isArray(z?.data)?z.data:[];o&&(K=Ya(K,s,n,{timeZone:c,offsetMinutes:x,now:h}));let se=i&&(F?.totals||z?.summary?.totals)||null,we=i&&(F?.rolling||z?.summary?.rolling)||null;if(i&&o&&!se&&!F)try{const Le=await W({baseUrl:t,accessToken:C,from:s,to:n,device:k,timeZone:c,tzOffsetMinutes:x,rolling:!0});se=Le?.totals||null,we=Le?.rolling||we}catch{}const ve=new Date().toISOString();if(!Q())return;A(K),M(se),U(we),j("edge"),P(ve),(se||!i&&o)&&S?de({summary:se,rolling:we,daily:K,from:s,to:n,includeDaily:o,includeSummary:i,fetchedAt:ve}):S||oe()}catch(z){if(!Q())return;if(S){const F=J();if(F?.summary||!i&&Array.isArray(F?.daily)){M(F.summary),U(F.rolling||null);const K=Array.isArray(F.daily)?F.daily:[],se=o?Ya(K,F.from||s,F.to||n,{timeZone:c,offsetMinutes:x,now:h}):K;A(se),j("cache"),P(F.fetchedAt||null),R(null)}else{const K=z;R(K?.message||String(K)),A([]),M(null),U(null),j("edge"),P(null)}}else{const F=z;R(F?.message||String(F)),A([]),M(null),U(null),j("edge"),P(null)}}finally{Q()&&V(!1)}},[a,t,s,o,i,q,r,S,h,J,N,c,n,x,oe,de,he,y,m,f,k,ye]);return d.useEffect(()=>{if(p){V(!0);return}const Q=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!N&&!r&&!q&&!Q&&!y){A([]),M(null),U(null),R(null),V(!1),j("edge"),P(null);return}if(!S)oe(),A([]),M(null),U(null),R(null),j("edge"),P(null);else{const B=J();if(B?.summary||!i&&Array.isArray(B?.daily)){M(B.summary),U(B.rolling||null);const X=Array.isArray(B.daily)?B.daily:[],xe=o?Ya(X,B.from||s,B.to||n,{timeZone:c,offsetMinutes:x,now:h}):X;A(xe),j("cache"),P(B.fetchedAt||null),R(null)}else A([]),M(null),U(null),j("edge"),P(null),R(null)}V(!0),ue()},[a,q,J,ue,N,r,S,oe,he,p,i]),d.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const Q=15e3;let B=Date.now();const X=()=>{if(document.visibilityState!=="visible")return;const xe=Date.now();xe-B<Q||(B=xe,ue())};return window.addEventListener("focus",X),document.addEventListener("visibilitychange",X),()=>{window.removeEventListener("focus",X),document.removeEventListener("visibilitychange",X)}},[ue]),{daily:_,summary:T,rolling:L,source:q?"mock":w,fetchedAt:D,loading:O,error:E,refresh:ue}}function yl(t){try{return new URL(t).host}catch{return null}}function qa(t){if(!t)return null;const a=String(t).trim(),r=a.split("-");if(r.length!==3)return null;const s=Number(r[0]),n=Number(r[1])-1,o=Number(r[2]);if(!Number.isFinite(s)||!Number.isFinite(n)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(s,n,o));return Number.isFinite(i.getTime())&&zt(i)===a?i:null}function bl(t,a){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+a))}function Ya(t,a,r,{timeZone:s,offsetMinutes:n,now:o}={}){const i=qa(a),u=qa(r);if(!i||!u||u<i)return Array.isArray(t)?t:[];const c=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,x=pr({timeZone:s,offsetMinutes:n,date:c}),h=qa(x),g=h?h.getTime():c.getTime(),m=new Map;for(const p of t||[])p?.day&&m.set(p.day,p);const f=[];for(let p=i;p<=u;p=bl(p,1)){const k=zt(p),y=m.get(k),v=p.getTime()>g;if(y){f.push({...y,missing:!1,future:v});continue}f.push({day:k,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return f}function kl({baseUrl:t,accessToken:a,guestAllowed:r=!1,from:s,to:n,cacheKey:o,timeZone:i,tzOffsetMinutes:u,accountView:c=!1,accountAccessToken:x=null,accountRevision:h=0,accountViewResolving:g=!1,deviceId:m=null}={}){const f=!!(c&&x),p=f?"cloud":"local",[k,y]=d.useState(null),[v,_]=d.useState("edge"),[A,T]=d.useState(!1),[M,L]=d.useState(null),U=ct(),w=Ot(a),j=!r,D=d.useMemo(()=>{if(!o)return null;const Y=wl(t)||"default",H=fr({timeZone:i,offsetMinutes:u});return`tokentracker.modelBreakdown.${o}.${p}.${Y}.${s}.${n}.${H}.${m||"all"}`},[t,o,m,s,p,i,n,u]),P=d.useCallback(()=>{if(!D||typeof window>"u")return null;try{const Y=window.localStorage.getItem(D);if(!Y)return null;const H=JSON.parse(Y);return!H||!H.breakdown?null:H}catch{return null}},[D]),O=d.useCallback(Y=>{if(!(!D||typeof window>"u"))try{window.localStorage.setItem(D,JSON.stringify(Y))}catch{}},[D]),V=d.useCallback(()=>{if(!(!D||typeof window>"u"))try{window.localStorage.removeItem(D)}catch{}},[D]),E=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),R=Ut([t,s,n,p,a,x,h,m,i,u]),q=d.useRef(p);d.useEffect(()=>{q.current!==p&&(q.current=p,y(null),_("edge"),L(null),T(!0))},[p]);const N=d.useCallback(async()=>{const Y=R(),H=await Ie(a),ce=f?await Ie(x):null;if(!Y()||!H&&!U&&!E&&!f)return;if(f&&!ce){L("Your session expired. Please sign in again to view account data."),T(!1);return}const J=f?ce:H,de=f?Io:Fo;T(!0),L(null);try{const oe=await de({baseUrl:t,accessToken:J,from:s,to:n,device:m,timeZone:i,tzOffsetMinutes:u});if(!Y())return;y(oe||null),_("edge"),oe&&j?O({breakdown:oe,fetchedAt:new Date().toISOString()}):j||V()}catch(oe){if(!Y())return;if(j){const he=P();if(he?.breakdown)y(he.breakdown),_("cache"),L(null);else{y(null),_("edge");const ye=oe;L(ye?.message||String(ye))}}else{y(null),_("edge");const he=oe;L(he?.message||String(he))}}finally{Y()&&T(!1)}},[a,t,s,U,r,j,P,i,n,w,u,V,O,E,f,x,h,m,R]);return d.useEffect(()=>{if(g){T(!0);return}if(!w&&!r&&!U&&!E&&!f){y(null),_("edge"),L(null),T(!1);return}if(!j)V(),y(null),_("edge"),L(null);else{const Y=P();Y?.breakdown?(y(Y.breakdown),_("cache"),L(null)):(y(null),_("edge"),L(null))}T(!0),N()},[a,U,P,N,w,r,j,V,E,g]),{breakdown:k,source:U?"mock":v,loading:A,error:M,refresh:N}}function wl(t){try{return new URL(t).host}catch{return null}}const Us=new Set(["day","hour","month"]);function _l(t){return Us.has(t)}function Zr(t){if(t==null)return null;const a=String(t).trim();if(!/^[0-9]+$/.test(a))return null;const r=a.replace(/^0+/,"");return r.length===0?"0":r}function vl(t,a){const r=Zr(t),s=Zr(a);if(r&&s)return r.length!==s.length?r.length<s.length?-1:1:r===s?0:r<s?-1:1;const n=re(t),o=re(a);return n==null&&o==null?0:n==null?1:o==null?-1:n===o?0:n<o?-1:1}function jl(t,a){const r=typeof t=="string"?t:String(t||""),s=typeof a=="string"?a:String(a||"");return r===s?0:r<s?-1:1}function Nl(t){if(!t)return null;const r=String(t).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!r)return null;const s=Number(r[1]),n=Number(r[2]),o=Number(r[3]);if(!Number.isFinite(s)||!Number.isFinite(n)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(s,n-1,o));return!Number.isFinite(i.getTime())||i.getUTCFullYear()!==s||i.getUTCMonth()+1!==n||i.getUTCDate()!==o?null:i.getTime()}function Sl(t){if(!t)return null;const r=String(t).trim().match(/^(\d{4})-(\d{2})$/);if(!r)return null;const s=Number(r[1]),n=Number(r[2]);if(!Number.isFinite(s)||!Number.isFinite(n)||n<1||n>12)return null;const o=new Date(Date.UTC(s,n-1,1));return Number.isFinite(o.getTime())?o.getTime():null}function Cl(t){if(!t)return null;const r=String(t).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!r)return null;const s=Number(r[1]),n=Number(r[2]),o=Number(r[3]),i=Number(r[4]),u=Number(r[5]),c=Number(r[6]||0);if(!Number.isFinite(s)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(u)||!Number.isFinite(c)||n<1||n>12||o<1||o>31||i<0||i>23||u<0||u>59||c<0||c>59)return null;const x=new Date(Date.UTC(s,n-1,o,i,u,c));return Number.isFinite(x.getTime())?x.getTime():null}function Tl(t,a,r){const s=r==="hour"?Cl:r==="month"?Sl:Nl,n=s(t),o=s(a);return n!=null&&o!=null?n===o?0:n<o?-1:1:jl(t,a)}function Hs(t,{key:a,dir:r}){const s=r==="asc"?1:-1,n=Array.isArray(t)?t:[],o=Us.has(a)?(u,c)=>Tl(u,c,a):vl,i=u=>a==="total_tokens"&&u?.billable_total_tokens!=null?u.billable_total_tokens:u?.[a];return n.map((u,c)=>({row:u,index:c})).sort((u,c)=>{const x=i(u.row),h=i(c.row),g=x==null,m=h==null;if(g&&m)return u.index-c.index;if(g)return 1;if(m)return-1;const f=o(x,h);return f!==0?f*s:u.index-c.index}).map(u=>u.row)}function Dl(){return[{key:"day",label:l("daily.sort.date.label"),title:l("daily.sort.date.title")},{key:"total_tokens",label:l("daily.sort.total.label"),title:l("daily.sort.total.title")},{key:"input_tokens",label:l("daily.sort.input.label"),title:l("daily.sort.input.title")},{key:"output_tokens",label:l("daily.sort.output.label"),title:l("daily.sort.output.title")},{key:"cached_input_tokens",label:l("daily.sort.cached.label"),title:l("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:l("daily.sort.reasoning.label"),title:l("daily.sort.reasoning.title")},{key:"conversation_count",label:l("daily.sort.conversations.label"),title:l("daily.sort.conversations.title")}]}function Jr(t){const a=_l(t)?t:"day";return Dl().map((r,s)=>s===0?{...r,key:a}:r)}function Qr(t,{key:a,dir:r}){return Hs(t,{key:a,dir:r})}const wa=12,Al=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Ll(t){if(typeof t=="bigint")return t!==0n;if(typeof t=="number")return Number.isFinite(t)&&t!==0;if(t==null)return!1;const a=String(t).trim();if(!a||!/^-?\d+$/.test(a))return!1;const r=a.startsWith("-")?a.slice(1):a;return/[1-9]/.test(r)}function Ml(t){return Al.some(a=>Ll(t?.[a]))}function El(t){const a=Array.isArray(t)?t:[];if(!a.length)return[];const r=Hs(a,{key:"month",dir:"asc"}),s=r.findIndex(n=>n?.month&&Ml(n));return s===-1?a:r.slice(s)}function Rl(t,a,r=wa){const s=Array.isArray(t)?t:[],n=Number.isFinite(r)&&r>0?r:wa,i=(Number.isFinite(a)&&a>=0?Math.floor(a):0)*n;return s.slice(i,i+n)}function Il({publicMode:t,screenshotMode:a,forceInstall:r,accessEnabled:s,heatmapLoading:n,activeDays:o,hasActiveDeviceToken:i}={}){return t||a?!1:r?!0:s&&!n&&o===0&&!i}const ua=Object.freeze({active:3e4,warm:2*6e4,idle:10*6e4,longIdle:30*6e4});function Fl({visible:t=!0,lastInteractionAt:a=0,now:r=Date.now()}={}){if(!t)return ua.longIdle;const s=Math.max(0,r-(Number(a)||0));return s<=10*6e4?ua.active:s<=60*6e4?ua.warm:ua.idle}const $l=3e4;function Pl({refresh:t,intervalMs:a=$l,windowRef:r=window,documentRef:s=document,onError:n=()=>{}}){let o=!1,i=null,u=Date.now(),c=0;const x=()=>{if(o||s.visibilityState!=="visible"||i)return i;const f=Promise.resolve().then(()=>t()).catch(p=>n(p)).then(()=>{}).finally(()=>{i===f&&(i=null)});return i=f,f},h=r.setInterval(()=>{const f=Date.now();f<c||(c=f+Fl({visible:s.visibilityState==="visible",lastInteractionAt:u,now:f}),x())},a),g=()=>{s.visibilityState==="visible"&&(u=Date.now(),c=0,x())},m=()=>{u=Date.now()};return r.addEventListener("focus",g),r.addEventListener("pointerdown",m),r.addEventListener("keydown",m),s.addEventListener("visibilitychange",g),{run:x,stop(){o=!0,r.clearInterval(h),r.removeEventListener("focus",g),r.removeEventListener("pointerdown",m),r.removeEventListener("keydown",m),s.removeEventListener("visibilitychange",g)}}}function Bl(t){if(!t)return null;const a=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!a)return null;const r=new Date(Date.UTC(Number(a[1]),Number(a[2])-1,Number(a[3])));return zt(r)===t?r:null}function zl({period:t,selectedFrom:a,selectedTo:r,todayKey:s}={}){if(t==="total"&&a&&r)return{from:a,to:r};const n=Bl(s)||new Date,o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()-29));return{from:zt(o),to:zt(n)}}function Ol(t,{period:a}={}){const r=(Array.isArray(t)?t:[]).filter(n=>!n?.future&&n?.day);return(a==="total"?r.filter(n=>!n?.missing):r).slice(-30)}function Vs(t){if(typeof t!="string")return null;const a=t.trim();return a?a.toLowerCase():null}function Ul(t){const a=Vs(t?.model_id);return a||null}function Ws(t,a){return t?.model?String(t.model):a}function jt(t,a=0){const r=re(t?.billable_total_tokens),s=re(t?.total_tokens);return r!=null&&r>0?r:s!=null&&s>0?s:r??s??a}function Hl(t,{copyFn:a}={}){const r=typeof a=="function"?a:i=>i,n=(Array.isArray(t?.sources)?t.sources:[]).map(i=>{const u=jt(i?.totals),c=re(i?.totals?.total_cost_usd)??0;return{source:i?.source,totalTokens:Number.isFinite(u)?u:0,totalCost:Number.isFinite(c)?c:0,inputTokens:Math.max(0,re(i?.totals?.input_tokens)??0),cacheRead:Math.max(0,re(i?.totals?.cached_input_tokens)??0),cacheCreate:Math.max(0,re(i?.totals?.cache_creation_input_tokens)??0),models:Array.isArray(i?.models)?i.models:[]}}).filter(i=>i.totalTokens>0);if(!n.length)return[];const o=n.reduce((i,u)=>i+u.totalTokens,0);return typeof t?.pricing?.pricing_mode=="string"&&t.pricing.pricing_mode.toUpperCase(),n.slice().sort((i,u)=>u.totalTokens-i.totalTokens).map(i=>{const u=i.source?String(i.source).toUpperCase():r("shared.placeholder.short"),c=o>0?i.totalTokens/o*100:0,x=Number.isFinite(c)?c.toFixed(2):"0.00",h=i.models.map(p=>{const k=jt(p?.totals);if(!Number.isFinite(k)||k<=0)return null;const y=i.totalTokens>0?Math.round(k/i.totalTokens*1e3)/10:0,v=Ws(p,r("shared.placeholder.short")),_=Ul(p),A=re(p?.totals?.total_cost_usd),T=A??(i.totalCost>0&&i.totalTokens>0?k/i.totalTokens*i.totalCost:null);return{id:_,name:v,share:y,usage:k,cost:T}}).filter(Boolean),g=i.inputTokens+i.cacheRead+i.cacheCreate,f=i.cacheRead+i.cacheCreate>0&&g>0?Math.round(i.cacheRead/g*100):null;return{source:i.source,label:u,totalPercent:String(x),totalPercentValue:c,usd:i.totalCost,usage:i.totalTokens,cacheHitRate:f,cacheReusedTokens:i.cacheRead,cacheInputTokens:g,models:h}})}function Vl(t,{limit:a=3,copyFn:r}={}){const s=typeof r=="function"?r:m=>m,n=Array.isArray(t?.sources)?t.sources:[];if(!n.length)return[];const o=new Map,i=new Map,u=new Map;let c=0;for(const m of n){const f=Array.isArray(m?.models)?m.models:[];for(const p of f){const k=jt(p?.totals);if(!Number.isFinite(k)||k<=0)continue;c+=k;const y=Ws(p,s("shared.placeholder.short")),v=Vs(y);if(!v)continue;o.set(v,(o.get(v)||0)+k);const _=u.get(v)||0;k>=_&&(u.set(v,k),i.set(v,y))}}if(!o.size)return[];const x=Array.from(o.values()).reduce((m,f)=>m+f,0),h=c>0?c:x,g=Number.isFinite(a)?Math.max(0,Math.floor(a)):3;return Array.from(o.entries()).map(([m,f])=>{const p=h>0?(f/h*100).toFixed(1):"0.0";return{id:m,name:i.get(m)||s("shared.placeholder.short"),tokens:f,percent:String(p)}}).sort((m,f)=>f.tokens!==m.tokens?f.tokens-m.tokens:String(m.name).localeCompare(String(f.name))).slice(0,g)}function Wl(t,a,r){if(!Number.isFinite(t))return l("shared.placeholder.short");const s=Na(t,{decimals:2,currency:a,rate:r});return s==="-"?l("shared.placeholder.short"):s}function Xr(t,a,r){if(!Number.isFinite(t)||t<=0)return null;const s=ja(a);return(a===Ms?t:t*r)<.01?`<${s}0.01`:Na(t,{decimals:2,currency:a,rate:r})}function es(t){const a=Number(t);return!Number.isFinite(a)||a<=0?null:Ze(a,{decimals:1})}const Kl=wt.memo(function({isOpen:a,onClose:r,fleetData:s=[]}){const{currency:n,rate:o}=Sa(),i=d.useMemo(()=>(Array.isArray(s)?s:[]).map(c=>{const x=re(c?.usd)??0,h=re(c?.usage)??0,g=Array.isArray(c?.models)?c.models:[];return{label:c?.label?String(c.label):"",usdValue:x,costLabel:Xr(x,n,o),tokensLabel:es(h),models:g.map(m=>{const f=re(m?.usage)??0,p=re(m?.cost)??0;return{id:m?.id?String(m.id):"",name:m?.name?String(m.name):"",tokensLabel:es(f),costLabel:Xr(p,n,o),sortCost:p}}).filter(m=>m.costLabel||m.tokensLabel).sort((m,f)=>f.sortCost-m.sortCost)}}).filter(c=>c.usdValue>0||c.models.length>0).sort((c,x)=>x.usdValue-c.usdValue),[s,n,o]),u=d.useMemo(()=>{const c=i.reduce((x,h)=>x+h.usdValue,0);return Wl(c,n,o)},[i,n,o]);return e.jsx(ji,{open:a,onOpenChange:c=>{c||r?.()},children:e.jsxs(Ni,{children:[e.jsx(Si,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),e.jsx(Ci,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(Ti,{className:"cost-modal-popup relative w-full max-w-[460px] 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",children:[e.jsx(Di,{render:e.jsx("h2",{className:"sr-only"}),children:l("dashboard.cost_breakdown.title")}),e.jsx(Ai,{type:"button",className:"absolute top-3 right-3 flex h-9 w-9 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-100 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 z-10","aria-label":l("dashboard.cost_breakdown.close"),children:e.jsx(yr,{size:16,strokeWidth:2,"aria-hidden":!0})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:e.jsxs("div",{className:"px-3 py-6",children:[e.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:l("dashboard.cost_breakdown.total_label")}),e.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:u}),i.length===0?e.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):e.jsxs("div",{role:"table","aria-label":l("dashboard.cost_breakdown.title"),children:[e.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2 mb-2 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{role:"columnheader",children:"Model"}),e.jsx("span",{role:"columnheader",children:"Cost"})]}),i.map((c,x)=>{const h=`fleet-${x}`;return e.jsxs("div",{role:"rowgroup","aria-labelledby":h,className:x>0?"mt-5":"mt-2",children:[e.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[e.jsx("span",{id:h,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:c.label}),e.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:c.costLabel||"—"})]}),c.models.map((g,m)=>e.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[e.jsx("span",{role:"cell",className:"flex-1 min-w-0 text-caption text-oai-gray-500 dark:text-oai-gray-400 truncate leading-none",title:g.name,children:g.name}),e.jsx("span",{role:"cell",className:"shrink-0 text-caption text-oai-gray-700 dark:text-oai-gray-300 tabular-nums leading-none",children:g.costLabel||""})]},g.id||`${g.name}-${m}`))]},`${c.label}-${x}`)})]})]})})]})})]})})});function Gl({projectKey:t,from:a,to:r,timeZone:s,tzOffsetMinutes:n}={}){const[o,i]=d.useState(null),[u,c]=d.useState(!1),[x,h]=d.useState(null),g=ct();return d.useEffect(()=>{if(!t){i(null),h(null),c(!1);return}let m=!0;return c(!0),h(null),$o({projectKey:t,from:a,to:r,timeZone:s,tzOffsetMinutes:n}).then(f=>{m&&i(f||null)}).catch(f=>{m&&(h(f?.message||String(f)),i(null))}).finally(()=>{m&&c(!1)}),()=>{m=!1}},[t,a,r,s,n,g]),{data:o,loading:u,error:x}}function Ks(t){if(typeof t!="string"||!t)return{owner:"",repo:""};const a=t.indexOf("/");return a<0?{owner:"",repo:t}:{owner:t.slice(0,a),repo:t.slice(a+1)}}function Gs(t){try{return new URL(t).hostname.toLowerCase()}catch{return""}}function qs(t){return t?t==="github.com"||t.endsWith(".github.com")?"github":t.includes("gitlab")||t.startsWith("git.")?"gitlab":"generic":""}function Ys(t,a){return a&&qs(Gs(t))==="github"?a:""}function Zs({githubOwner:t,letter:a,size:r="w-8 h-8"}){const[s,n]=d.useState(!1);return t&&!s?e.jsx("img",{src:`https://github.com/${t}.png?size=80`,alt:"",loading:"lazy",onError:()=>n(!0),className:`${r} rounded-md object-cover bg-oai-gray-100 dark:bg-oai-gray-800 flex-shrink-0`}):e.jsx("div",{className:`${r} rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0`,children:a})}const ts="#10b981",Za=[{key:"input_tokens",labelKey:"dashboard.projects.detail.comp_input",color:"#38bdf8"},{key:"cached_input_tokens",labelKey:"dashboard.projects.detail.comp_cached",color:"#14b8a6"},{key:"cache_creation_input_tokens",labelKey:"dashboard.projects.detail.comp_cache_write",color:"#f59e0b"},{key:"output_tokens",labelKey:"dashboard.projects.detail.comp_output",color:"#a78bfa"},{key:"reasoning_output_tokens",labelKey:"dashboard.projects.detail.comp_reasoning",color:"#fb7185"}],Ja=60;function ql(t,a,r,s){if(!Array.isArray(t)||t.length===0)return[];const n=new Map(t.map(m=>[m.day,m]));let o=a||t[0].day,i=r||t[t.length-1].day;o>i&&([o,i]=[i,o]),s&&i>s&&(i=s);const u=t[t.length-1].day;i<u&&(i=u);const c=new Date(`${o}T00:00:00Z`),x=new Date(`${i}T00:00:00Z`);if(!Number.isFinite(c.getTime())||!Number.isFinite(x.getTime()))return t;const h=Math.round((x.getTime()-c.getTime())/864e5)+1;h>Ja&&c.setUTCDate(c.getUTCDate()+(h-Ja));const g=[];for(;c.getTime()<=x.getTime()&&g.length<Ja;){const m=c.toISOString().slice(0,10);g.push(n.get(m)||{day:m,total_tokens:0,billable_total_tokens:0}),c.setUTCDate(c.getUTCDate()+1)}return g}function Qa(t){if(!Number.isFinite(t))return"—";const a=t*100;return`${a>=10?Math.round(a):a.toFixed(1)}%`}function kt({label:t,value:a,title:r}){return e.jsxs("div",{className:"flex flex-col gap-1.5 group min-w-0",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:t}),e.jsx("span",{className:"text-xl font-black font-mono text-zinc-900 dark:text-zinc-50 tracking-tight leading-none tabular-nums truncate transition-transform duration-200 group-hover:-translate-y-[1px]",title:r,children:a})]})}function Yl({host:t}){if(!t)return null;let a;const r=qs(t);return r==="github"||r==="gitlab"?a=e.jsx(Nt,{provider:r,size:12,className:"fill-current"}):a=e.jsx(Ki,{size:12}),e.jsx("span",{title:t,"aria-label":t,className:"inline-flex flex-shrink-0 items-center",children:a})}function Xa({children:t}){return e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500 select-none",children:t})}function Zl({entry:t,query:a={},onClose:r}){const[s,n]=wt.useState(!1),o=typeof t?.project_key=="string"?t.project_key:"",{owner:i,repo:u}=Ks(o),c=typeof t?.project_ref=="string"?t.project_ref:"",x=Gs(c),{data:h,loading:g,error:m}=Gl({projectKey:o,from:a.from,to:a.to,timeZone:a.timeZone,tzOffsetMinutes:a.tzOffsetMinutes}),{formatTokens:f,formatTokensTooltip:p}=Fe(),k=wt.useCallback(()=>n(!0),[]),y=E=>{E.target===E.currentTarget&&s&&r()};wt.useEffect(()=>{const E=R=>{R.key==="Escape"&&k()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[k]);const v=h?.totals||null,_=re(v?.billable_total_tokens)??0,A=Number(h?.days_active||0),T=re(v?.input_tokens)??0,M=re(v?.cached_input_tokens)??0,L=T+M>0?M/(T+M):null,U=re(h?.range_total_tokens)??0,w=re(v?.total_tokens)??0,j=U>0?w/U:null,D=wt.useMemo(()=>ql(h?.daily,h?.from,h?.to,pr({timeZone:a.timeZone,offsetMinutes:a.tzOffsetMinutes})),[h,a.timeZone,a.tzOffsetMinutes]),P=Za.reduce((E,R)=>E+(re(v?.[R.key])??0),0),O=Array.isArray(h?.sources)?h.sources:[],V=!g&&!m&&v&&w>0;return e.jsx("div",{onAnimationEnd:y,onClick:E=>{E.target===E.currentTarget&&k()},className:vt("fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40",s?"animate-tt-fade-out":"animate-tt-fade-in"),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":o,className:vt("relative w-full max-w-4xl max-h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden",s?"animate-tt-modal-exit":"animate-tt-modal"),children:[e.jsx("button",{type:"button",onClick:k,"aria-label":l("dashboard.projects.detail.close_aria"),className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60 transition-all duration-300",children:e.jsx(yr,{size:16})}),e.jsxs("div",{className:"w-full md:w-[300px] shrink-0 border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-5 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:ts}}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:ts}})]}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:l("dashboard.projects.detail.badge")})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-3 min-w-0",children:[e.jsx(Zs,{githubOwner:Ys(c,i),letter:(u?.[0]||o?.[0]||"?").toUpperCase(),size:"w-10 h-10"}),e.jsxs("div",{className:"min-w-0",children:[i?e.jsxs("p",{className:"text-[10px] font-mono text-zinc-400 dark:text-zinc-500 truncate leading-tight",children:[i,"/"]}):null,e.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-tight truncate",children:u||o||"—"})]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[10px] font-mono text-zinc-400 dark:text-zinc-500 leading-relaxed",children:[e.jsx(Yl,{host:x}),x&&h?.from&&h?.to?e.jsx("span",{children:"·"}):null,h?.from&&h?.to?e.jsxs("span",{className:"tabular-nums",children:[h.from," – ",h.to]}):null]})]}),V?e.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-t border-zinc-200/50 dark:border-zinc-800/50 pt-5 select-none",children:[e.jsx(kt,{label:l("dashboard.projects.detail.stat_total"),value:f(_),title:p(_)}),e.jsx(kt,{label:l("dashboard.projects.detail.stat_share"),value:j==null?"—":Qa(j)}),e.jsx(kt,{label:l("dashboard.projects.detail.stat_cache_hit"),value:L==null?"—":Qa(L)}),e.jsx(kt,{label:l("dashboard.projects.detail.stat_conversations"),value:ka(v.conversation_count)}),e.jsx(kt,{label:l("dashboard.projects.detail.stat_active_days"),value:ka(A)}),e.jsx(kt,{label:l("dashboard.projects.detail.stat_avg_day"),value:A>0?f(Math.round(_/A)):"—"})]}):null]}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-y-auto",children:[g&&e.jsxs("div",{className:"space-y-4 p-5 md:p-6",children:[e.jsx("div",{className:"h-32 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse"}),e.jsx("div",{className:"h-16 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse"}),e.jsx("div",{className:"h-24 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse"})]}),!g&&m&&e.jsx("p",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 p-5 md:p-6",children:l("dashboard.projects.detail.error")}),!g&&!m&&!V&&e.jsx("p",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 p-5 md:p-6",children:l("dashboard.projects.detail.empty_range")}),V&&e.jsxs("div",{className:"divide-y divide-zinc-200/50 dark:divide-zinc-800/40",children:[D.length>1&&e.jsxs("section",{className:"px-5 py-5 md:px-6 first:md:pt-6",children:[e.jsx(Xa,{children:l("dashboard.projects.detail.section_trend")}),e.jsx("div",{className:"mt-3",children:e.jsx(Fs,{embedded:!0,rows:D,from:D[0]?.day,to:D[D.length-1]?.day,period:"month",showTimeZoneLabel:!1,chartHeightClass:"h-36"})})]}),P>0&&e.jsxs("section",{className:"px-5 py-5 md:px-6 first:md:pt-6",children:[e.jsx(Xa,{children:l("dashboard.projects.detail.section_composition")}),e.jsx("div",{className:"mt-3 flex h-1.5 w-full overflow-hidden rounded-full",children:Za.map(E=>{const R=re(v[E.key])??0;return R<=0?null:e.jsx("div",{style:{width:`${R/P*100}%`,backgroundColor:E.color,minWidth:"2px"}},E.key)})}),e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-x-4 gap-y-1.5",children:Za.map(E=>{const R=re(v[E.key])??0;return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{backgroundColor:E.color}}),e.jsx("span",{className:"text-[11px] text-zinc-500 dark:text-zinc-400",children:l(E.labelKey)}),e.jsx("span",{className:"text-[11px] font-bold font-mono text-zinc-900 dark:text-zinc-50 tabular-nums",title:p(R),children:f(R)})]},E.key)})})]}),O.length>0&&e.jsxs("section",{className:"px-5 py-5 md:px-6 first:md:pt-6",children:[e.jsx(Xa,{children:l("dashboard.projects.detail.section_sources")}),e.jsx("div",{className:"mt-3 space-y-3.5",children:O.map(E=>{const R=Number(E.total_tokens||0),q=w>0?R/w:0,N=q*100,S=Number(E.conversation_count||0),Y=yi(E.source||"unknown");return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(Nt,{provider:E.source,size:13,className:"flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wide text-zinc-900 dark:text-zinc-50 truncate",children:_t(E.source)}),e.jsxs("span",{className:"hidden text-[10px] font-mono text-zinc-400 dark:text-zinc-500 tabular-nums whitespace-nowrap sm:inline",children:[l("dashboard.projects.detail.source_days",{n:Number(E.days_active||0)}),S>0?e.jsxs(e.Fragment,{children:[" · ",l("dashboard.projects.detail.source_conv",{n:S})]}):null]}),e.jsx("span",{className:"ml-auto text-[12px] font-bold font-mono text-zinc-900 dark:text-zinc-50 tabular-nums",title:p(R),children:f(R)}),e.jsx("span",{className:"w-9 text-right text-[10px] font-mono text-zinc-400 dark:text-zinc-500 tabular-nums",children:Qa(q)})]}),e.jsx("div",{className:"mt-1.5 h-1 w-full overflow-hidden rounded-full bg-zinc-100 dark:bg-zinc-800/60",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.min(100,Math.max(N,R>0?1:0))}%`,minWidth:R>0?"3px":0,backgroundColor:Y}})})]},E.source)})})]})]})]})]})})}const Jl=5;function Ql({entry:t,maxTokens:a,copy:r,formatTokens:s,formatTokensTooltip:n,onSelect:o}){const i=typeof t?.project_key=="string"?t.project_key:"",u=typeof t?.project_ref=="string"?t.project_ref:"",{owner:c,repo:x}=Ks(i),h=Ys(u,c),g=re(t?.billable_total_tokens??t?.total_tokens)??0,m=a>0?Math.min(100,Math.max(2,g/a*100)):0,f=Array.isArray(t?.sources)?t.sources:[],p=f.slice(0,Jl),k=f.length-p.length;return e.jsxs("button",{type:"button",onClick:()=>o?.(t),className:"flex w-full items-center gap-3 p-2 rounded-lg text-left hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50 active:bg-oai-gray-100 dark:active:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/60 transition-colors",children:[e.jsx(Zs,{githubOwner:h,letter:(x?.[0]||i?.[0]||"?").toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline min-w-0",children:[c?e.jsxs("span",{className:"oai-text-caption text-oai-gray-400 dark:text-oai-gray-500 truncate flex-shrink-[2]",children:[c,"/"]}):null,e.jsx("span",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:x||i||"—"})]}),p.length>0&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-1",children:[p.map(y=>e.jsx(Nt,{provider:y.source,size:12,className:"text-oai-gray-400 dark:text-oai-gray-500"},y.source)),k>0&&e.jsx("span",{className:"oai-text-caption text-oai-gray-400 dark:text-oai-gray-500",children:r("dashboard.projects.sources_more",{n:k})})]})]}),e.jsxs("div",{className:"flex w-24 flex-shrink-0 flex-col items-end gap-1",children:[e.jsx("span",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",title:n(g),children:s(g)}),e.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-oai-gray-100 dark:bg-oai-gray-800",children:e.jsx("div",{className:"h-full rounded-full bg-emerald-500",style:{width:`${m}%`,minWidth:g>0?"3px":0}})})]})]})}function Xl({projectEntries:t=[],projectLimit:a=3,onProjectLimitChange:r,projectDetailQuery:s={},copy:n,hasDetailsActual:o,dailyEmptyPrefix:i,installSyncCmd:u,dailyEmptySuffix:c,detailsColumns:x,ariaSortFor:h,toggleSort:g,sortIconFor:m,pagedDetails:f,dailyBreakdownRows:p=[],dailyBreakdownColumns:k=[],dailyBreakdownAriaSortFor:y,dailyBreakdownSortIconFor:v,dailyBreakdownDateKey:_="day",detailsDateKey:A,renderDetailDate:T,renderDailyBreakdownDate:M,renderDetailCell:L,DETAILS_PAGED_PERIODS:U,period:w,detailsPageCount:j,detailsPage:D,setDetailsPage:P}){const[O,V]=d.useState("daily"),[E,R]=d.useState(null),{formatTokens:q,formatTokensTooltip:N}=Fe();return e.jsxs(Ne,{children:[e.jsxs("div",{className:`flex items-center justify-between gap-3 ${O==="projects"?"mb-4":"mb-0"}`,children:[e.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[e.jsx("button",{role:"tab","aria-selected":O==="daily",type:"button",onClick:()=>V("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${O==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:n("dashboard.daily.title")}),e.jsx("button",{role:"tab","aria-selected":O==="projects",type:"button",onClick:()=>V("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${O==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:n("dashboard.projects.title")})]}),O==="projects"&&e.jsx($s,{ariaLabel:n("dashboard.projects.limit_aria"),value:a,onValueChange:S=>r?.(Number(S)),options:[{value:3,label:n("dashboard.projects.limit_top_3")},{value:6,label:n("dashboard.projects.limit_top_6")},{value:10,label:n("dashboard.projects.limit_top_10")}],align:"end",className:"px-2 py-1 text-xs text-oai-gray-600 dark:text-oai-gray-300"})]}),O==="projects"&&(()=>{const S=t.slice(0,a);if(S.length===0)return e.jsx("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:n("dashboard.projects.empty")});const Y=S.reduce((H,ce)=>{const J=re(ce?.billable_total_tokens??ce?.total_tokens)??0;return J>H?J:H},0);return e.jsx("div",{className:"space-y-1",children:S.map((H,ce)=>e.jsx(Ql,{entry:H,maxTokens:Y,copy:n,formatTokens:q,formatTokensTooltip:N,onSelect:R},H?.project_key||H?.project_ref||`entry-${ce}`))})})(),E&&e.jsx(Zl,{entry:E,query:s,onClose:()=>R(null)}),O==="daily"&&e.jsxs("div",{children:[p?.length===0?e.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[i,e.jsx("code",{className:"mx-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 font-mono oai-text-caption",children:u}),c]}):e.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 z-10",children:e.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:k.map(S=>e.jsx("th",{"aria-sort":y?.(S.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:e.jsx("button",{type:"button",onClick:()=>g(S.key),className:"flex w-full items-center justify-start px-2.5 sm:px-4 py-2 text-left oai-text-caption font-semibold text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white transition-colors",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{children:S.label}),e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:v?.(S.key)||""})]})})},S.key))})}),e.jsx("tbody",{children:p.map(S=>e.jsxs("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 hover:bg-oai-gray-50/50 dark:hover:bg-oai-gray-800/50 transition-colors ${S.missing?"text-oai-gray-400 dark:text-oai-gray-400":S.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[e.jsx("td",{className:"px-2.5 sm:px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 whitespace-nowrap",children:M?M(S):T(S)}),e.jsx("td",{className:"px-2.5 sm:px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:L(S,"total_tokens")}),e.jsx("td",{className:"px-2.5 sm:px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:L(S,"input_tokens")}),e.jsx("td",{className:"px-2.5 sm:px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:L(S,"output_tokens")}),e.jsx("td",{className:"px-2.5 sm:px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:L(S,"cached_input_tokens")}),e.jsx("td",{className:"px-2.5 sm:px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:L(S,"reasoning_output_tokens")}),e.jsx("td",{className:"px-2.5 sm:px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:L(S,"conversation_count")})]},String(S?.[_]||S?.day||S?.hour||S?.month||"")))})]})}),O!=="daily"&&U.has(w)&&j>1?e.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[e.jsx("button",{type:"button",onClick:()=>P(S=>Math.max(0,S-1)),disabled:D===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:n("details.pagination.prev")}),e.jsxs("span",{className:"oai-text-muted",children:[D+1," / ",j]}),e.jsx("button",{type:"button",onClick:()=>P(S=>Math.min(j-1,S+1)),disabled:D+1>=j,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:n("details.pagination.next")})]}):null]})]})}function ya(t){return typeof t!="string"?"":t.trim()}function as(t){const a=ya(t);return a?a.split(/[_\-\s]+/).filter(Boolean).map(r=>r.slice(0,1).toUpperCase()+r.slice(1).toLowerCase()).join(" "):""}function ec(t){if(!Array.isArray(t))return[];const a=new Map;for(const r of t){if(!r||typeof r!="object")continue;const s=ya(r.tool),n=ya(r.planType)||ya(r.plan_type);if(!s||!n)continue;const o=as(s)||s,i=as(n)||n;a.set(`${s.toLowerCase()}::${n.toLowerCase()}`,{tool:o,plan:i})}return Array.from(a.values())}function tc({startDate:t,streakDays:a,subscriptions:r=[],periodConversations:s,rolling:n,topModels:o=[],className:i=""}){const{formatTokensTooltip:u}=Fe(),c=l("shared.placeholder.short"),x=l("shared.unit.percent"),h=t??l("identity_card.rank_placeholder"),g=Number.isFinite(Number(a))?Number(a):0,m=g?l("identity_card.streak_value",{days:g}):l("identity_card.rank_placeholder"),f=ec(r),p={thousandSuffix:l("shared.unit.thousand_abbrev"),millionSuffix:l("shared.unit.million_abbrev"),billionSuffix:l("shared.unit.billion_abbrev")},k=_=>{if(_==null)return c;const A=Ze(_,p);return A==="-"?c:A},y={last7d:l("stats.period.last_7d"),last30d:l("stats.period.last_30d"),avg:l("stats.period.avg"),convs:l("stats.period.convs")},v=o.slice(0,3);return e.jsxs(Ne,{className:`h-full ${i}`,children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-2 xl:grid-cols-4 gap-2",children:[e.jsxs("div",{className:"min-w-0 flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[e.jsx("span",{title:u(n?.last_7d?.totals?.billable_total_tokens),className:"w-full min-w-0 truncate text-center text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:k(n?.last_7d?.totals?.billable_total_tokens)}),e.jsx("span",{className:"w-full min-w-0 truncate text-center text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:y.last7d})]}),e.jsxs("div",{className:"min-w-0 flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[e.jsx("span",{title:u(n?.last_30d?.totals?.billable_total_tokens),className:"w-full min-w-0 truncate text-center text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:k(n?.last_30d?.totals?.billable_total_tokens)}),e.jsx("span",{className:"w-full min-w-0 truncate text-center text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:y.last30d})]}),e.jsxs("div",{className:"min-w-0 flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[e.jsx("span",{title:u(n?.last_30d?.avg_per_active_day),className:"w-full min-w-0 truncate text-center text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:k(n?.last_30d?.avg_per_active_day)}),e.jsx("span",{className:"w-full min-w-0 truncate text-center text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:y.avg})]}),e.jsxs("div",{className:"min-w-0 flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[e.jsx("span",{className:"w-full min-w-0 truncate text-center text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:k(s)}),e.jsx("span",{className:"w-full min-w-0 truncate text-center text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:y.convs})]})]}),v.length>0&&e.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:v.map((_,A)=>{const T=_?.name?String(_.name):c,M=_?.percent?String(_.percent):"",L=A===v.length-1,U=A+1;return e.jsxs("div",{className:`flex items-center py-2 ${L?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[e.jsx("span",{className:"w-5 h-5 flex items-center justify-center rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 text-[10px] font-semibold text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0",children:U}),e.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:T,children:T}),e.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[M,x]})]},_.id||T)})}),f.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex flex-wrap gap-1.5",children:f.map((_,A)=>e.jsxs(rl,{variant:"secondary",size:"sm",children:[_.tool," ",_.plan]},`${_.tool}:${_.plan}:${A}`))}),e.jsxs("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:l("identity_card.rank_label")}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:h})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:l("identity_card.streak_label")}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:m})]})]})]})}let ma=null;function ac(){if(ma===null)try{ma=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("color","oklch(0 0 0)")}catch{ma=!1}return ma}function rc(t,a,r){const s=r*Math.PI/180,n=a*Math.cos(s),o=a*Math.sin(s),i=t+.3963377774*n+.2158037573*o,u=t-.1055613458*n-.0638541728*o,c=t-.0894841775*n-1.291485548*o,x=i*i*i,h=u*u*u,g=c*c*c;return[4.0767416621*x-3.3077115913*h+.2309699292*g,-1.2684380046*x+2.6097574011*h-.3413193965*g,-.0041960863*x-.7034186147*h+1.707614701*g].map(f=>{const p=Math.min(1,Math.max(0,f)),k=p<=.0031308?12.92*p:1.055*Math.pow(p,1/2.4)-.055;return Math.round(k*255)})}function Js(t,a,r,s){if(ac())return s==null?`oklch(${t} ${a} ${r})`:`oklch(${t} ${a} ${r} / ${s})`;const[n,o,i]=rc(t,a,r);return s==null?`rgb(${n} ${o} ${i})`:`rgb(${n} ${o} ${i} / ${s})`}function St(t){const a=/^oklch\(\s*([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s*\)$/.exec(t);return a?Js(Number(a[1]),Number(a[2]),Number(a[3])):t}const rs={claude:35,codex:250},ss={system_prompt:{l:.55,c:.05},messages:{l:.65,c:.18},tool_calls:{l:.6,c:.14},custom_agents:{l:.55,c:.1},reasoning:{l:.7,c:.08}};function sc(t,a){const r=rs[a]??rs.claude,s=ss[t]||ss.system_prompt;return Js(s.l,s.c,r)}const nc=[{key:"system_prompt",from:["system_prefix"]},{key:"messages",from:["user_input","conversation_history","assistant_response"]},{key:"tool_calls",from:["tool_calls"]},{key:"custom_agents",from:["subagents"]},{key:"reasoning",from:["reasoning"]}],oc=[["by_type","dashboard.context_breakdown.exec_details.group_by_type"],["by_executable","dashboard.context_breakdown.exec_details.group_by_executable"],["by_command","dashboard.context_breakdown.exec_details.group_by_command"],["by_duration","dashboard.context_breakdown.exec_details.group_by_duration"],["by_output","dashboard.context_breakdown.exec_details.group_by_output"],["by_exit","dashboard.context_breakdown.exec_details.group_by_exit"]],ic={duration:.18,ease:[.4,0,.2,1]},lc={height:0,opacity:0},cc={height:"auto",opacity:1},dc={height:0,opacity:0};function uc(t){const a=Number(t||0);return Number.isFinite(a)&&a>0?a:0}function mc(t,a){const r={};for(const s of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])r[s]=Math.round(Number(t?.[s]||0)*a);return r}function Qs(t,a=null){const r=t.reduce((i,u)=>i+Number(u.totals.total_tokens||0),0),s=uc(a),n=s||r,o=s&&r>0?s/r:1;return t.map(i=>{const u=o===1?i.totals:mc(i.totals,o);return{...i,totals:u,percent:n>0?Number((u.total_tokens/n*100).toFixed(2)):0}}).sort((i,u)=>u.totals.total_tokens-i.totals.total_tokens)}function hc(t,a=null){const r=new Map;for(const n of t||[])r.set(n.key,n);const s=nc.map(n=>{const o={input_tokens:0,cached_input_tokens:0,cache_creation_input_tokens:0,output_tokens:0,reasoning_output_tokens:0,total_tokens:0};for(const i of n.from){const u=r.get(i);if(!u)continue;const c=u.totals||{};o.input_tokens+=c.input_tokens||0,o.cached_input_tokens+=c.cached_input_tokens||0,o.cache_creation_input_tokens+=c.cache_creation_input_tokens||0,o.output_tokens+=c.output_tokens||0,o.reasoning_output_tokens+=c.reasoning_output_tokens||0,o.total_tokens+=c.total_tokens||0}return{key:n.key,totals:o}});return Qs(s,a)}function xc(t,a=null){const r=t?.totals||{},s=Number(r.reasoning_output_tokens||0),n=(t?.tool_calls_breakdown?.categories||[]).reduce((x,h)=>h?.name==="Text Response"?x:x+Number(h?.totals?.total_tokens||0),0),o=Number(r.total_tokens||0),i=Math.min(Math.max(0,n),Math.max(0,o-s)),c=[{key:"messages",totals:{total_tokens:Math.max(0,o-s-i)}},{key:"tool_calls",totals:{total_tokens:i}},{key:"reasoning",totals:{total_tokens:s}}];return Qs(c,a)}const ns="MCP: ";function gc(t){if(!t?.categories?.length)return{mcpSet:null,residualSet:t,mcpTotalTokens:0};const a=[],r=[];let s=0;for(const n of t.categories){const o=String(n?.name||"");o.startsWith(ns)?(a.push({...n,name:o.slice(ns.length)}),s+=Number(n?.totals?.total_tokens||0)):r.push(n)}return a.length===0?{mcpSet:null,residualSet:t,mcpTotalTokens:0}:(a.sort((n,o)=>(o.totals?.total_tokens||0)-(n.totals?.total_tokens||0)),{mcpSet:{...t,categories:a},residualSet:{...t,categories:r},mcpTotalTokens:s})}function os(t){return l(`dashboard.context_breakdown.category.${t}`)}function fc(t){return typeof t!="string"?"":t.startsWith("mcp__")?t.split("__").slice(2).join("__")||t:t.includes("/")&&t.split("/").pop()||t}function pc(t){return(Array.isArray(t)?t:[]).map(a=>{const r=a?.totals||null,s=Number(r?r.input_tokens||0:a?.input_tokens||0),n=Number(r?r.output_tokens||0:a?.output_tokens||0),o=Number(r?r.cached_input_tokens||0:a?.cache_read||0),i=Number(r?r.cache_creation_input_tokens||0:a?.cache_creation||0),u=Number(r?r.total_tokens||s+n:a?.total_tokens||n);return{name:fc(a?.name?String(a.name):""),calls:Number(a?.calls||0),input_tokens:s,output_tokens:n,cache_read:o,cache_creation:i,total_tokens:Number(u||0)}}).filter(a=>a.name).sort((a,r)=>(r.total_tokens||0)-(a.total_tokens||0))}function yc(t){return(Array.isArray(t)?t:[]).map(a=>{const r=a?.totals||{},s=Array.isArray(a?.tools)?a.tools:[],n=Number(r.input_tokens||0),o=Number(r.output_tokens||0),i=Number(r.cached_input_tokens||0),u=Number(r.cache_creation_input_tokens||0);return{name:a?.name?String(a.name):"",calls:Number(a?.calls||0),totals:{input_tokens:n,output_tokens:o,cached_input_tokens:i,cache_creation_input_tokens:u,total_tokens:Number(r.total_tokens||n+o)},tools:pc(s),toolCount:s.length}}).filter(a=>a.name).sort((a,r)=>(r.totals.total_tokens||0)-(a.totals.total_tokens||0))}function bc(t){return(Array.isArray(t)?t:[]).map(a=>{const r=a?.totals||{},s=Number(r.input_tokens||0),n=Number(r.output_tokens||0),o=Number(r.cached_input_tokens||0),i=Number(r.cache_creation_input_tokens||0);return{key:a?.key?String(a.key):"",name:a?.name?String(a.name):"",totals:{input_tokens:s,output_tokens:n,cached_input_tokens:o,cache_creation_input_tokens:i,total_tokens:Number(r.total_tokens||s+n+o+i)}}}).filter(a=>a.key||a.name).sort((a,r)=>(r.totals.total_tokens||0)-(a.totals.total_tokens||0))}function kc(t){return(Array.isArray(t)?t:[]).map(a=>{const r=a?.totals||{};return{name:a?.name?String(a.name):"",calls:Number(a?.calls||0),total_tokens:Number(r.total_tokens||0)}}).filter(a=>a.name).sort((a,r)=>Number(r.total_tokens||0)-Number(a.total_tokens||0))}function wc(t){if(t?.key){const a=l(`dashboard.context_breakdown.message_details.${t.key}`);if(a&&!a.includes("dashboard.context_breakdown"))return a}return t?.name||""}function _c(t){return(Array.isArray(t)?t:[]).map(a=>{const r=a?.totals||{},s=Number(r.input_tokens||0),n=Number(r.output_tokens||0),o=Number(r.cached_input_tokens||0),i=Number(r.cache_creation_input_tokens||0);return{name:a?.name?String(a.name):"",calls:Number(a?.calls||0),failures:Number(a?.failures||0),duration_ms:Number(a?.duration_ms||0),max_duration_ms:Number(a?.max_duration_ms||0),output_chars:Number(a?.output_chars||0),output_lines:Number(a?.output_lines||0),totals:{input_tokens:s,output_tokens:n,cached_input_tokens:o,cache_creation_input_tokens:i,total_tokens:Number(r.total_tokens||s+n)}}}).filter(a=>a.name).sort((a,r)=>Number(r.totals.total_tokens||0)-Number(a.totals.total_tokens||0))}function is(t){const a=Number(t||0);return!Number.isFinite(a)||a<=0?"0ms":a<1e3?`${Math.round(a)}ms`:a<6e4?`${(a/1e3).toFixed(1)}s`:`${Math.round(a/1e3)}s`}function vc(t,a){return t?a==="by_executable"?t.by_executable||[]:a==="by_command"?t.by_command||[]:a==="by_duration"?t.by_duration||[]:a==="by_output"?t.by_output||[]:a==="by_exit"?t.by_exit||[]:t.by_type||[]:[]}function ls(t){return t==="exec_command"||t==="Bash"}function Xs(t){return t==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function jc(t){return t==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function Nc(t){return t==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const Sc=10;function Ye({level:t=0,colorSquare:a=null,label:r,labelSuffix:s=null,labelTone:n="default",hasChevron:o=!1,open:i=!1,onToggle:u,tokens:c,percent:x=null,children:h,share:g=null,fillColor:m=null}){const f=n==="accent"?"text-oai-brand truncate":n==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":n==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",p=e.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:Sc},"aria-hidden":!a,children:a}),k=e.jsxs(e.Fragment,{children:[p,e.jsx("span",{className:f,children:r}),s,o&&e.jsx(_e.span,{animate:{rotate:i?90:0},transition:{duration:.15},className:"shrink-0 text-oai-gray-400 dark:text-oai-gray-500 flex items-center","aria-hidden":"true",children:e.jsx(Li,{size:11})})]}),y=m&&g!=null&&g>0,v=y?Math.max(0,Math.min(100,g)):0;return e.jsxs("li",{className:"min-w-0 group/row",children:[e.jsxs("div",{className:"relative grid grid-cols-[minmax(0,1fr)_minmax(9rem,max-content)_4rem] items-center gap-x-3 text-xs py-1 px-1 rounded-sm transition-colors duration-150",style:y?{backgroundImage:`linear-gradient(to right, ${m.replace(/\)\s*$/," / 0.10)")} 0%, ${m.replace(/\)\s*$/," / 0.10)")} ${v}%, transparent ${v}%)`}:void 0,children:[o?e.jsx("button",{type:"button",onClick:u,"aria-expanded":i,className:"relative col-start-1 row-start-1 flex items-center gap-1.5 min-w-0 text-left cursor-pointer focus-visible:outline-none focus-visible:ring-inset focus-visible:ring-2 focus-visible:ring-oai-brand/40 rounded-sm",children:k}):e.jsx("div",{className:"relative col-start-1 row-start-1 flex items-center gap-1.5 min-w-0",children:k}),e.jsx("span",{className:"relative col-start-2 row-start-1 text-right whitespace-nowrap tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),e.jsx("span",{className:"relative col-start-3 row-start-1 text-right whitespace-nowrap tabular-nums text-[10px] text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:x||""})]}),o&&h?e.jsx(br,{initial:!1,children:i&&e.jsx(_e.div,{initial:lc,animate:cc,exit:dc,transition:ic,style:{overflow:"hidden"},children:h},"content")}):null]})}function cs({execDetails:t,source:a="claude"}){const{formatTokens:r}=Fe(),[s,n]=d.useState("by_type"),o=_c(vc(t,s)),i=a==="codex",u=i?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return e.jsxs("div",{className:"mt-2 ml-4",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-md bg-oai-gray-100 dark:bg-oai-gray-900 p-1 w-fit max-w-full",children:oc.map(([c,x])=>e.jsx("button",{type:"button",onClick:()=>n(c),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(s===c?"bg-oai-white dark:bg-oai-gray-800 text-oai-black dark:text-oai-white shadow-sm":"text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-white/70 dark:hover:bg-oai-gray-800/70"),children:l(x)},c))}),o.length===0?e.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):e.jsx("div",{className:"mt-2 overflow-x-auto",children:e.jsxs("div",{role:"table","aria-label":l("dashboard.context_breakdown.exec_details.title"),className:i?"min-w-[420px]":"min-w-[260px]",children:[e.jsxs("div",{role:"row",className:`grid ${u} gap-2 py-1.5 mb-1 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400`,children:[e.jsx("span",{role:"columnheader",children:l("dashboard.context_breakdown.exec_details.kind_column")}),e.jsx("span",{role:"columnheader",className:"text-right",children:l("dashboard.context_breakdown.exec_details.calls_column")}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"columnheader",className:"text-right",children:l("dashboard.context_breakdown.exec_details.failures_column")}),e.jsx("span",{role:"columnheader",className:"text-right",children:l("dashboard.context_breakdown.exec_details.duration_column")}),e.jsx("span",{role:"columnheader",className:"text-right",children:l("dashboard.context_breakdown.exec_details.max_duration_column")})]}),e.jsx("span",{role:"columnheader",className:"text-right",children:l("dashboard.context_breakdown.tool_details.total_column")}),i&&e.jsx("span",{role:"columnheader",className:"text-right",children:l("dashboard.context_breakdown.exec_details.output_column")})]}),o.map((c,x)=>e.jsxs(_e.div,{role:"row",className:`grid ${u} gap-2 py-1.5`,title:c.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:x*.02},children:[e.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:c.name}),e.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ze(c.calls||0)}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ze(c.failures||0)}),e.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:is(c.duration_ms||0)}),e.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:is(c.max_duration_ms||0)})]}),e.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:r(c.totals.total_tokens||0)}),i&&e.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ze(c.output_lines||0)})]},c.name))]})})]})}function Pt({toolSet:t,execDetails:a,source:r,codexQueueFallback:s}){const{formatTokens:n}=Fe(),[o,i]=d.useState({}),[u,c]=d.useState(!1),x=yc(t?.categories||[]);function h(g){i(m=>({...m,[g]:!m[g]}))}return x.length===0?e.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:r==="codex"&&s?l("dashboard.context_breakdown.tool_details.unavailable_codex"):l(Xs(r))}):e.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:x.map(g=>{const m=g.toolCount>0,f=g.name==="Execution"&&a,p=f&&g.tools.some(y=>ls(y.name)),k=!!o[g.name];return e.jsxs(Ye,{level:1,label:g.name,labelTone:"strong",hasChevron:m||f&&!p,open:k||f&&!p&&u,onToggle:()=>{m?h(g.name):f&&!p&&c(y=>!y)},tokens:n(g.totals.total_tokens||0),percent:null,children:[m&&e.jsx("ul",{className:"space-y-0.5",children:g.tools.map(y=>{const v=f&&ls(y.name);return e.jsx(Ye,{level:2,label:y.name,labelTone:v?"accent":"default",hasChevron:v,open:u,onToggle:()=>c(_=>!_),tokens:n(y.total_tokens||0),percent:null,children:v&&e.jsx(cs,{execDetails:a,source:r})},y.name)})}),f&&!p&&e.jsx(cs,{execDetails:a,source:r})]},g.name)})})}function Cc({from:t,to:a,source:r="claude",referenceTotalTokens:s=null,onLoadingChange:n=null}){const{formatTokens:o}=Fe(),[i,u]=d.useState(null),[c,x]=d.useState(!1),[h,g]=d.useState(null),[m,f]=d.useState({});function p(N){f(S=>({...S,[N]:!S[N]}))}if(d.useEffect(()=>{let N=!1;return x(!0),n?.(!0),g(null),Po({from:t,to:a,source:r,timeZone:Rs(),tzOffsetMinutes:Es()}).then(S=>{N||u(S)}).catch(S=>{N||g(S?.message||String(S))}).finally(()=>{N||(x(!1),n?.(!1))}),()=>{N=!0}},[t,a,r]),c&&!i)return e.jsxs("div",{children:[e.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),e.jsx("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2",children:[0,1,2,3,4].map(N=>e.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${N*80}ms`}},N))}),e.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:l("dashboard.context_breakdown.loading_hint")})]});if(h)return e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:l(jc(r))});if(!i||i.scope!=="supported"||!i.totals?.total_tokens)return e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:l(Xs(r))});const k=r==="claude"?hc(i.categories||[],s):xc(i,s),y=i.tool_calls_breakdown||null,v=i.skills_breakdown||null,_=i.message_breakdown||null,A=i.configured_resources||null,T=i.exec_command_breakdown||null,M=kc(v?.skills||[]),L=bc(_?.categories||[]),U=r==="codex"&&(i?.breakdown_status==="queue_fallback"||i?.fallback==="queue_totals"),w=r==="claude"?y?.tool_calls||null:y||null,{mcpSet:j,residualSet:D,mcpTotalTokens:P}=gc(w),O=r==="claude"&&y?.subagents||null,V=O?.categories?.length>0||(A?.custom_agents_count||0)>0,E=r==="claude"?(D?.categories||[]).reduce((N,S)=>N+Number(S?.totals?.total_tokens||0),0):0,R=r==="claude"?(O?.categories||[]).reduce((N,S)=>N+Number(S?.totals?.total_tokens||0),0):0,q=[...k].sort((N,S)=>(S.totals?.total_tokens||0)-(N.totals?.total_tokens||0));return e.jsxs("div",{role:"region","aria-label":l("dashboard.context_breakdown.bar_aria",{summary:k.filter(N=>N.percent>0).filter(N=>!(r==="claude"&&(N.key==="tool_calls"||N.key==="custom_agents"))).map(N=>`${os(N.key)} ${N.percent}%`).join(",")}),children:[e.jsxs("ul",{className:"space-y-0.5",children:[q.map(N=>{const S=N.key==="system_prompt",Y=N.key==="messages",H=N.key==="tool_calls",ce=N.key==="custom_agents";if(N.key,r==="claude"&&(H||ce))return null;const J=Y&&L.length>0||H&&(D?.categories?.length>0||U)||ce&&V&&O,de=!!m[N.key],oe=sc(N.key,r),he=e.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:oe},"aria-hidden":"true"}),ye=S?e.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[e.jsx(zs,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),e.jsx("span",{role:"tooltip",className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-1.5 -translate-x-1/2 w-64 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-oai-gray-700 dark:text-oai-gray-200 shadow-md opacity-0 group-hover:opacity-100 transition-opacity",children:l("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,ue=N.percent>0?`${N.percent.toFixed(N.percent<.1&&N.percent>0?2:1)}%`:"0.0%";return e.jsxs(Ye,{level:0,colorSquare:he,label:os(N.key),labelSuffix:ye,tokens:o(N.totals?.total_tokens||0),percent:ue,hasChevron:J,open:de,onToggle:()=>p(N.key),share:N.percent,fillColor:oe,children:[Y&&e.jsx("ul",{className:"space-y-0.5",children:L.map(ee=>e.jsx(Ye,{level:1,label:wc(ee),tokens:o(ee.totals.total_tokens||0),percent:null},ee.key||ee.name))}),H&&D&&e.jsx(Pt,{toolSet:D,execDetails:T,source:r,codexQueueFallback:U}),H&&U&&!D&&e.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:l("dashboard.context_breakdown.tool_details.unavailable_codex")}),ce&&O&&e.jsx(Pt,{toolSet:O,execDetails:null,source:r,codexQueueFallback:!1})]},N.key)}),r==="claude"&&D?.categories?.length>0&&e.jsx(Ye,{level:0,colorSquare:e.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:l("dashboard.context_breakdown.category.tool_calls"),tokens:o(E),percent:null,hasChevron:!0,open:!!m.tool_calls_aux,onToggle:()=>p("tool_calls_aux"),children:e.jsx(Pt,{toolSet:D,execDetails:T,source:r,codexQueueFallback:!1})}),r==="claude"&&O?.categories?.length>0&&e.jsx(Ye,{level:0,colorSquare:e.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:l("dashboard.context_breakdown.category.custom_agents"),tokens:o(R),percent:null,hasChevron:!0,open:!!m.custom_agents_aux,onToggle:()=>p("custom_agents_aux"),children:e.jsx(Pt,{toolSet:O,execDetails:null,source:r,codexQueueFallback:!1})}),j?.categories?.length>0&&e.jsx(Ye,{level:0,colorSquare:e.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:l("dashboard.context_breakdown.category.mcp_servers"),tokens:o(P),percent:null,hasChevron:!0,open:!!m.mcp_servers,onToggle:()=>p("mcp_servers"),children:e.jsx(Pt,{toolSet:j,execDetails:null,source:r,codexQueueFallback:!1})}),M.length>0&&e.jsx(Ye,{level:0,colorSquare:e.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:l("dashboard.context_breakdown.category.skills"),tokens:o(M.reduce((N,S)=>N+(S.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!m.skills,onToggle:()=>p("skills"),children:e.jsx("ul",{className:"space-y-0.5",children:M.slice(0,12).map(N=>e.jsx(Ye,{level:1,label:N.name,tokens:o(N.total_tokens),percent:null},N.name))})})]}),e.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:l(Nc(r))}),U?e.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:l("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,A?e.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ze(A.skills_count||0)," skills ·"," ",Ze(A.mcp_servers_count||0)," MCP servers ·"," ",Ze(A.custom_agents_count||0)," agents ·"," ",Ze(A.memory_files_count||0)," memory files"]}):null]})}function ba(t,a){const r=Number(a);return Number.isFinite(r)&&r>0?t(r):null}function en(t,a,r){const s=Number(t);if(!Number.isFinite(s)||s<=0)return null;const n=ja(a);return(a===Ms?s:s*r)<.01?`<${n}0.01`:Na(s,{decimals:2,currency:a,rate:r})}function Tc(t){return Array.isArray(t)?t.map(a=>typeof a=="string"?{key:a,label:ds(a)}:{key:a.key,label:a.label||ds(a.key)}):[]}function Dc(t){if(typeof t!="string")return null;const a=t.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!a)return null;const r=Number(a[0]);return Number.isFinite(r)?r:null}const Ac={CODEX:"#3b82f6",CLAUDE:"#d97757",OPENCODE:"#f59e0b",GEMINI:"#2196f3",KIMI:"#a78bfa","KILO-CLI":"#facc15","KILO-CODE":"#facc15",MIMO:"#ff6900",DROID:"#ef4444",ZCODE:"#14b8a6",ANYTHINGLLM:"var(--provider-anythingllm)"};function er(t,a){const r=t?.toUpperCase?.()||"";return Ac[r]||`hsl(${150+a*40}, 60%, 45%)`}function Lc(t){const a=String(t?.source||"").trim().toLowerCase(),r=String(t?.label||"").trim().toLowerCase();return a==="claude"||r==="claude"?"claude":a==="codex"||r==="codex"?"codex":null}function Mc(t){return!!t?.models?.length}function tn(t){const a=Number(t?.totalPercentValue??t?.totalPercent);return Number.isFinite(a)?Math.max(0,a):0}function tr(t){const a=tn(t);return a>0&&!(a>=.01)?l("usage.overview.percent_below_threshold"):a.toFixed(2)}const Ec={day:"usage.period.day",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function ds(t){const a=Ec[t];return a?l(a):String(t).toUpperCase()}function Rc({loading:t,onClick:a}){const r=Ds();return e.jsx(zo,{variant:"secondary",size:"sm",disabled:t,onClick:a,"aria-label":l("usage.button.refresh"),className:"w-8 p-0",children:e.jsx(_e.span,{"aria-hidden":"true",animate:t?{rotate:360}:{rotate:0},transition:t&&!r?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function Ic(){return e.jsx("div",{"data-testid":"usage-summary-skeleton","aria-hidden":"true",className:"mx-auto h-[58px] sm:h-[72px] w-[min(72vw,18rem)] rounded-2xl bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse motion-reduce:animate-none"})}function Fc(){return e.jsxs("div",{"data-testid":"usage-provider-skeleton","aria-hidden":"true",className:"space-y-6",children:[e.jsx("div",{className:"h-1.5 w-full rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse motion-reduce:animate-none"}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-3",children:[0,1,2,3].map(t=>e.jsx("div",{className:"h-[92px] rounded-xl border border-oai-gray-100 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-800/60 animate-pulse motion-reduce:animate-none",style:{animationDelay:`${t*70}ms`}},t))})]})}function $c({period:t,periods:a,onPeriodChange:r,summaryValue:s,summaryFullValue:n,onToggleSummaryFormat:o,summaryLabel:i,summaryCostValue:u,onCostInfo:c,fleetData:x=[],onRefresh:h,loading:g,announceLoading:m=!1,summaryLoading:f=!1,providersLoading:p=!1,hasSummary:k=!0,className:y="",customFrom:v,customTo:_,onCustomRangeApply:A,customRangeOpen:T,onCustomRangeOpenChange:M,onOpenShare:L,from:U,to:w,deviceOptions:j=[],selectedDevice:D="",onDeviceChange:P}){const O=Tc(a),V=ki(Oo()),E=Dc(String(s??"")),R=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches,[q,N]=d.useState(R);d.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const C=window.matchMedia("(max-width: 639px)"),z=F=>N(F.matches);return C.addEventListener("change",z),()=>C.removeEventListener("change",z)},[]);const S=E!=null&&!q,Y=d.useRef(null);d.useEffect(()=>{const C=Y.current?.querySelector('[aria-selected="true"]');C&&typeof C.scrollIntoView=="function"&&C.scrollIntoView({block:"nearest",inline:"center"})},[t]);const[H,ce]=d.useState(null),{resolvedTheme:J}=Bo(),{currency:de,rate:oe}=Sa(),{formatTokens:he}=Fe(),ye=J==="dark",ue=ye?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",ee=ye?"rgba(10,10,10,0)":"rgba(255,255,255,0)",Q=f&&!k,B=p&&!x.some(Mc),X=C=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(C.key))return;const z=Array.from(C.currentTarget.querySelectorAll('[role="tab"]')).filter(se=>!se.disabled),F=z.indexOf(C.target.closest('[role="tab"]'));if(F===-1||z.length===0)return;C.preventDefault();let K=F;C.key==="Home"?K=0:C.key==="End"?K=z.length-1:C.key==="ArrowRight"?K=(F+1)%z.length:K=(F-1+z.length)%z.length,z[K].focus(),z[K].click()},xe=S?e.jsx(ul,{value:E,displayValue:s,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:ye?0:8,gradientFrom:ue,gradientTo:ee,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):s,W=x.filter(C=>C.models?.length>0);return e.jsx(Ne,{className:y,children:e.jsxs("div",{"aria-busy":g||Q||B,children:[m?e.jsx("span",{className:"sr-only",role:"status",children:l("qpd.card.updating")}):null,e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx("div",{ref:Y,role:"tablist","aria-label":l("usage.overview.tablist_aria"),onKeyDown:X,className:"flex flex-1 min-w-0 gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:O.map(C=>{const z=t===C.key,F=`shrink-0 whitespace-nowrap text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${z?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800"}`;if(C.key==="custom"){const K=z&&v&&_?`${Gr(v,V)} — ${Gr(_,V)}`:C.label;return e.jsxs(Mi,{open:T,onOpenChange:se=>{se?r?.("custom"):M?.(se)},children:[e.jsx(Ei,{render:e.jsx("button",{role:"tab","aria-selected":z,tabIndex:z?0:-1,type:"button",className:F}),children:K}),e.jsx(Ri,{children:e.jsx(Ii,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:e.jsx(Fi,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:e.jsx(bi,{from:v,to:_,onApply:A,onCancel:()=>M?.(!1)})})})})]},"custom")}return e.jsx("button",{role:"tab","aria-selected":z,tabIndex:z?0:-1,type:"button",className:F,onClick:()=>r?.(C.key),children:C.label},C.key)})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[j.length>1?e.jsx($s,{value:D,onValueChange:P,options:j,ariaLabel:l("dashboard.device_filter.aria"),matchTriggerWidth:!0,className:"h-8 px-3 text-xs font-medium rounded-md border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-brand hover:text-oai-brand hover:[&_svg]:text-oai-brand transition-colors duration-200"}):null,L?e.jsxs("button",{type:"button",onClick:L,"aria-label":l("share.button.aria"),className:"inline-flex items-center justify-center gap-1.5 h-8 px-3 text-xs font-medium rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-brand hover:text-oai-brand transition-colors duration-200",children:[e.jsx(Ji,{className:"h-3.5 w-3.5",strokeWidth:2}),l("share.button.label")]}):null,h&&e.jsx(Rc,{loading:g,onClick:h})]})]}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:i}),e.jsxs("div",{className:"relative text-5xl sm:text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:[e.jsx("div",{className:Q?"invisible":void 0,children:o?e.jsx("button",{type:"button",onClick:o,title:n||void 0,"aria-label":l("usage.summary.toggle_aria"),className:"cursor-pointer rounded-lg leading-none transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand",children:xe}):e.jsx("span",{title:n||void 0,children:xe})}),e.jsx("div",{className:`absolute inset-0 flex items-center justify-center ${Q?"":"hidden"}`,children:e.jsx(Ic,{})})]}),u&&e.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:c?e.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1.5 text-xl font-bold text-oai-brand hover:text-oai-brand-dark dark:hover:text-oai-brand-light transition-colors cursor-pointer","aria-label":l("usage.overview.cost_breakdown_aria"),children:[u,e.jsx(zs,{size:16,strokeWidth:2,className:"opacity-80"})]}):e.jsx("span",{className:"text-xl font-bold text-oai-brand",children:u})})]}),e.jsx("div",{className:B?void 0:"hidden",children:e.jsx(Fc,{})}),W.length>0&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{role:"img","aria-label":l("usage.overview.distribution_aria",{items:W.map(C=>l("usage.overview.distribution_item",{label:_t(C.label),percent:tr(C)})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:W.map((C,z)=>{const F=er(C.label,z),K=_t(C.label),se=tr(C);return e.jsx(_e.div,{initial:{width:0},animate:{width:`${tn(C)}%`},transition:{duration:.5,delay:.45+z*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:F},title:`${K}: ${se}%`},C.label)})}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-3",children:W.map((C,z)=>{const F=er(C.label,z),K=H===C.label,se=_t(C.label),we=tr(C);return e.jsxs("button",{"aria-expanded":K,"aria-controls":`provider-details-${C.label}`,"aria-label":l("usage.overview.provider_card_aria",{provider:se,percent:we,tokens:ba(he,C.usage)||String(0),cost:en(C.usd,de,oe)||`${ja(de)}0`,action:l(K?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>ce(K?null:C.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${K?"border-oai-gray-300 dark:border-oai-gray-600 bg-oai-gray-50 dark:bg-oai-gray-800":"border-oai-gray-200 dark:border-oai-gray-700 hover:border-oai-gray-300 dark:hover:border-oai-gray-600"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1 min-w-0",children:[e.jsx(Nt,{provider:C.label,size:15,color:F,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white truncate",title:se,children:se})]}),e.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[we,"%"]}),e.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:l("usage.overview.model_count",{count:C.models.length})})]},C.label)})}),H&&e.jsx("div",{id:`provider-details-${H}`,role:"region","aria-label":l("usage.overview.model_details_aria",{provider:H}),className:"mt-2",children:W.filter(C=>C.label===H).map(C=>{const z=er(C.label,0),F=Lc(C),K=[...C.models].sort((we,ve)=>(ve.share||0)-(we.share||0)),se=F?`${F==="claude"?"Claude":"Codex"} Context Breakdown`:_t(C.label);return e.jsx(Pc,{provider:C,color:z,providerHeading:se,contextSource:F,from:U,to:w,sortedModels:K},C.label)})})]})]})})}function Pc({provider:t,color:a,providerHeading:r,contextSource:s,from:n,to:o,sortedModels:i}){const{currency:u,rate:c}=Sa(),{formatTokens:x,formatTokensTooltip:h}=Fe(),[g,m]=d.useState(!1),f=String(t?.source||t?.label||"").trim().toLowerCase()==="antigravity";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[e.jsx(Nt,{provider:t.label,size:14,color:a,className:"shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:r}),s&&g&&e.jsx($i,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":l("dashboard.context_breakdown.loading_aria")})]}),t.cacheHitRate!=null&&e.jsxs("p",{className:"mb-3 text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:[e.jsx("span",{className:"font-medium text-oai-gray-600 dark:text-oai-gray-300",children:l("usage.overview.cache_hit_rate_label")})," ",e.jsxs("span",{className:"text-oai-black dark:text-oai-white",children:[t.cacheHitRate,"%"]})," · ",l("usage.overview.cache_hit_rate_detail",{reused:ba(x,t.cacheReusedTokens)||String(0),input:ba(x,t.cacheInputTokens)||String(0)})]}),f&&e.jsxs("p",{className:"mb-3 text-[10px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsxs("span",{className:"font-medium text-oai-gray-500 dark:text-oai-gray-400",children:[l("usage.overview.antigravity_notice_title"),"."]})," ",l("usage.overview.antigravity_notice_body")]}),s?e.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:e.jsx(Cc,{from:n,to:o,source:s,referenceTotalTokens:t.usage,onLoadingChange:m})}):null,e.jsx("div",{className:"space-y-3",children:i.map(p=>{const k=ba(x,p.usage),y=en(p.cost,u,c),v=Math.max(0,Math.min(100,Number(p.share)||0));return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(8rem,max-content)_minmax(5.5rem,max-content)_4rem] items-baseline gap-x-3 mb-1.5",children:[e.jsx("span",{className:"col-start-1 row-start-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:p.name,children:p.name}),e.jsx("span",{title:h(p.usage),className:"col-start-2 row-start-1 text-right whitespace-nowrap text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:k}),e.jsx("span",{className:"col-start-3 row-start-1 text-right whitespace-nowrap text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:y}),e.jsxs("span",{className:"col-start-4 row-start-1 text-right whitespace-nowrap text-sm text-oai-black dark:text-oai-white tabular-nums",children:[p.share,"%"]})]}),e.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":v,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${v}%`,backgroundColor:a,opacity:.45}})})]},p.id||p.name)})})]})}function Bc({id:t,children:a,onEmptyChange:r}){const{attributes:s,listeners:n,setNodeRef:o,transform:i,transition:u,isDragging:c}=ci({id:t}),x=d.useRef(null),h=d.useRef(null);d.useLayoutEffect(()=>{if(!r)return;const m=x.current?x.current.childNodes.length===0:!0;h.current!==m&&(h.current=m,r(t,m))});const g={transform:di.Transform.toString(i)||void 0,transition:u,zIndex:c?20:void 0};return e.jsxs("div",{ref:o,style:g,className:vt("group/sortable relative has-[[data-sortable-body]:empty]:hidden",c&&"opacity-90"),children:[e.jsx("button",{type:"button","aria-label":l("dashboard.overview.layout.drag_handle"),className:vt("peer absolute left-1/2 top-1 z-10 flex h-5 w-6 -translate-x-1/2 items-center justify-center rounded-md","cursor-grab active:cursor-grabbing touch-none select-none","text-oai-gray-400 dark:text-oai-gray-600 opacity-0 transition-colors duration-150","hover:text-oai-gray-600 dark:hover:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800","group-hover/sortable:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50",c&&"opacity-100 bg-oai-gray-100 dark:bg-oai-gray-800"),...s,...n,children:e.jsxs("svg",{viewBox:"0 0 14 8",width:"14",height:"8",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"2",cy:"2",r:"1"}),e.jsx("circle",{cx:"2",cy:"6",r:"1"}),e.jsx("circle",{cx:"7",cy:"2",r:"1"}),e.jsx("circle",{cx:"7",cy:"6",r:"1"}),e.jsx("circle",{cx:"12",cy:"2",r:"1"}),e.jsx("circle",{cx:"12",cy:"6",r:"1"})]})}),e.jsx("div",{ref:x,"data-sortable-body":!0,className:vt("rounded-xl transition-shadow duration-200 ease-out","peer-hover:shadow-[0_12px_28px_-14px_rgba(15,23,42,0.22)] dark:peer-hover:shadow-[0_12px_28px_-12px_rgba(0,0,0,0.6)]","peer-focus-visible:shadow-[0_12px_28px_-14px_rgba(15,23,42,0.22)] dark:peer-focus-visible:shadow-[0_12px_28px_-12px_rgba(0,0,0,0.6)]",c&&"shadow-[0_12px_28px_-14px_rgba(15,23,42,0.22)] dark:shadow-[0_12px_28px_-12px_rgba(0,0,0,0.6)]"),children:a})]})}function zc({todayTokens:t=0,isSyncing:a=!1,hasError:r=!1,isDisconnected:s=!1}={}){return d.useMemo(()=>r?"error":s?"disconnected":a?"working-typing":t===0?"sleeping":t<5e4?"idle-living":t<2e5?"idle-look":t<5e5?"working-ultrathink":t<2e6?"working-typing":"working-ultrathink",[t,a,r,s])}const us="macAppBannerDismissed",Oc="leaderboardBannerDismissed",Uc="https://github.com/mm7894215/TokenTracker/releases/latest",ms="tokentracker_native_app",ha=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(ms,"1"),!0):localStorage.getItem(ms)==="1"}catch{return!1}})();function Hc({todayTokens:t=0,isSyncing:a=!1,enterDelay:r=0}){const{openLoginModal:s}=Uo(),{signedIn:n}=Is(),o=zc({todayTokens:t,isSyncing:a}),i=ha?Oc:us,[u,c]=d.useState(()=>{try{return localStorage.getItem(i)==="1"?!0:!ha&&new URLSearchParams(window.location.search).get("from")==="menubar"?(localStorage.setItem(us,"1"),!0):!1}catch{return!1}}),x=d.useCallback(()=>{c(!0);try{localStorage.setItem(i,"1")}catch{}},[i]);if(u)return null;let h,g,m,f,p,k;ha&&n?(h="View the Leaderboard",g="Compare your usage globally",m="Leaderboard",f=e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:e.jsx("path",{d:"M2 8.5V10h8V8.5M6 1.5v6m0 0L3.5 5M6 7.5l2.5-2.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(180 6 6)"})}),p=()=>{window.location.pathname="/leaderboard"}):ha?(h="Join the Leaderboard",g="Log in to compare your usage with others",m="Log In",f=e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:e.jsx("path",{d:"M6.5 1.5h3a1 1 0 011 1v7a1 1 0 01-1 1h-3M5 8.5L7.5 6 5 3.5M7.5 6H1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),p=s):(h="Try the Menu Bar App",g="Always-on stats with Clawd companion",m="Download",f=e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:e.jsx("path",{d:"M6 2v6m0 0L3.5 5.5M6 8l2.5-2.5M2 10h8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),k=Uc);const y=k?_e.a:_e.button,v=k?{href:k,target:"_blank",rel:"noopener noreferrer"}:{onClick:p};return e.jsx(_e.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:r,ease:[.16,1,.3,1]},className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Pi,{state:o,size:56})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-oai-gray-900 dark:text-oai-white",children:h}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-0.5",children:g})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(y,{...v,whileHover:{scale:1.03},whileTap:{scale:.97},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-oai-gray-900 dark:bg-oai-white dark:text-oai-gray-900 rounded-md hover:opacity-90 transition-opacity",children:[m,f]}),e.jsx("button",{onClick:x,className:"p-1 text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 transition-colors","aria-label":"Dismiss",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})]})})}const hs="widgetOnboardingDismissed",xs="tokentracker_native_app",Vc=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(xs,"1"),!0):localStorage.getItem(xs)==="1"}catch{return!1}})();function Wc({enterDelay:t=0}){const[a,r]=d.useState(()=>{try{return localStorage.getItem(hs)==="1"}catch{return!1}}),s=d.useCallback(()=>{r(!0);try{localStorage.setItem(hs,"1")}catch{}},[]);return!Vc||Ho()?null:e.jsx(br,{initial:!1,children:!a&&e.jsxs(_e.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8,transition:{duration:.2,ease:[.4,0,.2,1]}},transition:{duration:.35,delay:t,ease:[.16,1,.3,1]},className:"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:[e.jsx("button",{type:"button",onClick:s,"aria-label":l("dashboard.widgets.dismiss_aria"),className:"absolute top-2.5 right-2.5 z-10 inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-300 dark:focus-visible:ring-oai-gray-600 transition-colors",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),e.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:e.jsx("img",{src:"/widgets-overview.png",alt:l("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:l("dashboard.widgets.title")}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:l("dashboard.widgets.hint")})]})]},"widget-onboarding-card")})}function Kc({enabled:t=!1,from:a,to:r,accessToken:s,deviceId:n=null}={}){const[o,i]=d.useState(null),[u,c]=d.useState(!1),[x,h]=d.useState(null),g=Ut([t,a,r,s,n]),m=d.useCallback(async()=>{if(!t)return;const f=g();c(!0),h(null);try{const p=await Ie(s);if(!f())return;const k=await Vo({from:a,to:r,device:n,accessToken:p});if(!f())return;i(k||null)}catch(p){if(!f())return;h(p?.message||String(p)),i(null)}finally{f()&&c(!1)}},[t,a,r,s,n,g]);return d.useEffect(()=>{if(!t){i(null),h(null),c(!1);return}i(null),h(null),c(!0),m()},[t,m]),{data:o,loading:u,error:x,refresh:m}}function an(t){return t==null?"—":t===0?"$0":t<1?`$${t.toFixed(4)}`:`$${t.toFixed(2)}`}function rn(t){return t==null?"—":`${Math.round(t*100)}%`}function Gc(t,a){if(a==null||a===0||t==null||t===0)return"—";const r=t/a;return r<1?`$${r.toFixed(4)}`:`$${r.toFixed(2)}`}function qc({row:t}){return e.jsxs("tr",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800/60 hover:bg-oai-gray-50/40 dark:hover:bg-oai-gray-800/10 transition-colors",children:[e.jsx("td",{className:"py-2.5 pr-2 font-mono text-[11px] text-oai-gray-700 dark:text-oai-gray-300 truncate max-w-[80px] xs:max-w-[110px] sm:max-w-[140px]",title:t.key,children:t.key}),e.jsx("td",{className:"py-2.5 px-1.5 text-right tabular-nums text-oai-gray-600 dark:text-oai-gray-400",children:an(t.cost_usd)}),e.jsxs("td",{className:"py-2.5 px-1.5 text-right tabular-nums text-oai-gray-600 dark:text-oai-gray-400",children:[t.accepted,"/",t.outcomes]}),e.jsx("td",{className:"py-2.5 px-1.5 text-right tabular-nums text-oai-gray-600 dark:text-oai-gray-400",children:rn(t.acceptance_rate)}),e.jsx("td",{className:"py-2.5 pl-2 pr-2 text-right tabular-nums font-semibold text-oai-black dark:text-oai-white",children:Gc(t.cost_usd,t.accepted)})]})}function Yc({from:t,to:a,deviceId:r=null}){const{formatTokens:s,formatTokensTooltip:n}=Fe(),{enabled:o}=Bi(),{data:i,loading:u}=Kc({enabled:o,from:t,to:a,deviceId:r});if(!o)return null;const c=(i&&i.available&&Array.isArray(i.by_model)?i.by_model:[]).filter(m=>m.outcomes>0&&m.key!=="unknown");if(!c.length)return null;const x=c.slice(0,6),h=i.totals||{},g=`${l("qpd.card.subtitle")}${u?` ${l("qpd.card.updating")}`:""}`;return e.jsxs(Ne,{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:l("qpd.card.title")}),e.jsx("span",{className:"px-1.5 py-0.5 text-[9px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase",children:l("qpd.card.badge")})]}),e.jsx("p",{className:"mb-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:g}),e.jsx("div",{className:"w-full overflow-x-auto oai-scrollbar",children:e.jsxs("table",{className:"w-full text-xs min-w-[340px] sm:min-w-0",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("th",{className:"pb-1.5 pr-2 text-left font-medium",children:l("qpd.card.col_model")}),e.jsx("th",{className:"pb-1.5 px-1.5 text-right font-medium",children:l("qpd.card.col_cost")}),e.jsx("th",{className:"pb-1.5 px-1.5 text-right font-medium",children:l("qpd.card.col_accepted")}),e.jsx("th",{className:"pb-1.5 px-1.5 text-right font-medium",children:l("qpd.card.col_rate")}),e.jsx("th",{className:"pb-1.5 pl-2 pr-2 text-right font-medium",title:l("qpd.card.qpd_tooltip"),children:l("qpd.card.col_qpd")})]})}),e.jsx("tbody",{children:x.map(m=>e.jsx(qc,{row:m},m.key))})]})}),e.jsxs("div",{className:"mt-3 flex items-center justify-between border-t border-oai-gray-200 dark:border-oai-gray-800 pt-2.5 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:l("qpd.card.totals",{accepted:h.accepted??0,outcomes:h.outcomes??0,cost:an(h.cost_usd)})}),e.jsx("span",{title:`${l("qpd.card.et_tooltip")} · ${n(h.effective_tokens)}`,children:l("qpd.card.et",{tokens:s(h.effective_tokens),rate:rn(h.acceptance_rate)})})]}),h.outcomes<15&&e.jsxs("p",{className:"mt-3 text-[10px] text-oai-gray-400 dark:text-oai-gray-500 italic border-t border-oai-gray-100 dark:border-oai-gray-800/40 pt-2",children:["* ",l("qpd.card.sparse_notice","Tip: Spark outcomes dataset might skew Quality/$ ratios. For precise metrics, select a narrower time window.")]})]})}const Zc=new Set(["unknown","synthetic","openai"]);function ar(t){return t==null?"—":`${Math.round(t*100)}%`}function Jc(t){return t==null?"—":t<1?`$${t.toFixed(4)}`:`$${t.toFixed(2)}`}function qe(t){const a=Number(t);return Number.isFinite(a)?new Intl.NumberFormat().format(Math.round(a)):"0"}function Qc(t){const r=String(t?.model||"").trim().toLowerCase().replace(/^<|>$/g,"");return!!r&&!Zc.has(r)&&Number(t?.edit_turns||0)>0}function gs(){return e.jsx("div",{className:"mb-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-black dark:text-white",children:l("sessions.card.title")}),e.jsx("span",{className:"rounded bg-oai-gray-100 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:bg-oai-gray-800/80 dark:text-oai-gray-400",children:l("qpd.card.badge")})]}),e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:l("sessions.card.subtitle")})]})})}function Xc({from:t,to:a}){const[r,s]=d.useState({loading:!0,sessions:null,context:null}),n=d.useId(),{enabled:o}=zi(),{formatTokens:i}=Fe(),u=y=>i(y,{mode:pa.COMPACT});d.useEffect(()=>{if(!o){s({loading:!1,sessions:null,context:null});return}let y=!1;return s(v=>({...v,loading:!0})),Promise.all([Wo({from:t,to:a}),Ko()]).then(([v,_])=>{y||s({loading:!1,sessions:v,context:_})}).catch(()=>{y||s({loading:!1,sessions:null,context:null})}),()=>{y=!0}},[o,t,a]);const c=d.useMemo(()=>(r.sessions?.by_model||[]).filter(Qc).slice(0,5),[r.sessions]),x=d.useMemo(()=>(r.sessions?.subagents||[]).slice(0,3),[r.sessions]);if(!o||!r.loading&&!r.sessions?.available&&!r.context?.estimated_fixed_tokens)return null;const h=r.sessions?.summary||{},g=h.edit_session_rate??h.productive_rate,m=h.first_pass_rate??h.one_shot_rate,f=h.edit_sessions??h.productive_sessions??0,p=h.sessions??r.sessions?.session_count??0,k=h.edit_turns??0;return r.loading&&!r.sessions&&!r.context?e.jsxs(Ne,{children:[e.jsx(gs,{}),e.jsx("div",{role:"status",className:"flex h-24 items-center justify-center rounded-lg bg-oai-gray-50 text-xs text-oai-gray-400 dark:bg-oai-gray-800/50 dark:text-oai-gray-500",children:l("sessions.card.loading")})]}):e.jsxs(Ne,{children:[e.jsx(gs,{}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-3",children:[e.jsx(rr,{label:l("sessions.card.edit_sessions"),value:ar(g),detail:l("sessions.card.edit_session_value",{edits:qe(f),sessions:qe(p)})}),e.jsx(rr,{label:l("sessions.card.first_pass"),value:ar(m),detail:l("sessions.card.edit_session_value",{edits:qe(h.first_pass_sessions??h.one_shot_sessions??0),sessions:qe(f)})}),e.jsx(rr,{label:l("sessions.card.cost_edit"),value:Jc(h.cost_per_edit),detail:l("sessions.card.edit_turn_count",{count:qe(k)})})]}),e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:l("sessions.card.sample",{sessions:qe(p),edits:qe(k)})}),e.jsxs("span",{className:"group relative inline-flex shrink-0",children:[e.jsx("button",{type:"button","aria-describedby":n,className:"cursor-help rounded-sm underline decoration-dotted underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/40",children:l("sessions.card.methodology_label")}),e.jsx("span",{id:n,role:"tooltip",className:"pointer-events-none absolute right-0 top-full z-20 mt-2 w-64 rounded-xl border border-oai-gray-200/60 bg-white/95 px-3 py-2 text-left text-[10.5px] font-normal leading-relaxed text-oai-gray-700 opacity-0 shadow-xl backdrop-blur-md transition-opacity duration-150 group-hover:opacity-100 group-focus-within:opacity-100 dark:border-oai-gray-700/70 dark:bg-oai-gray-900/95 dark:text-oai-gray-200",children:l("sessions.card.methodology")})]})]}),!!c.length&&e.jsx("div",{className:"overflow-x-auto oai-scrollbar",children:e.jsxs("table",{className:"w-full min-w-[440px] text-xs",children:[e.jsx("thead",{className:"text-[10px] uppercase tracking-wide text-oai-gray-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"pb-1.5 text-left font-medium",children:l("sessions.card.model")}),e.jsx("th",{className:"pb-1.5 text-right font-medium",children:l("sessions.card.edit_sessions")}),e.jsx("th",{className:"pb-1.5 text-right font-medium",children:l("sessions.card.first_pass")}),e.jsx("th",{className:"pb-1.5 text-right font-medium",children:l("sessions.card.tokens_edit")})]})}),e.jsx("tbody",{children:c.map(y=>e.jsxs("tr",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800/60",children:[e.jsx("td",{className:"py-2 pr-2 font-mono text-[11px] truncate max-w-[150px]",title:y.model,children:y.model}),e.jsx("td",{className:"py-2 pl-2 text-right tabular-nums",children:l("sessions.card.edit_session_value",{edits:qe(y.edit_sessions??y.productive_sessions??0),sessions:qe(y.sessions)})}),e.jsx("td",{className:"py-2 pl-2 text-right tabular-nums",children:ar(y.first_pass_rate??y.one_shot_rate)}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:u(y.tokens_per_edit)})]},y.model))})]})}),r.context?e.jsxs("div",{className:"mt-3 pt-2.5 border-t border-oai-gray-200 dark:border-oai-gray-800 flex items-center justify-between gap-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:l("sessions.card.context")}),e.jsx("span",{className:"tabular-nums",title:l("sessions.card.context_tooltip"),children:u(r.context.estimated_fixed_tokens)})]}):null,!!x.length&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:l("sessions.card.subagents")}),x.map(y=>e.jsx("span",{className:"rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 px-1.5 py-0.5",children:l("sessions.card.subagent_item",{name:y.name,calls:Math.round(y.calls)})},y.name))]}),e.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:l("sessions.card.privacy")})]})}function rr({label:t,value:a,detail:r}){return e.jsxs("div",{className:"rounded-lg bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2",children:[e.jsx("div",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-400 truncate",children:t}),e.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums text-oai-black dark:text-white",children:a}),e.jsx("div",{className:"mt-0.5 text-[9px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 truncate",children:r})]})}function te({className:t}){return e.jsx("div",{className:vt("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function ed(){return e.jsx("div",{className:"flex gap-1 overflow-hidden",children:Array.from({length:20},(t,a)=>e.jsx("div",{className:"flex flex-col gap-1",children:Array.from({length:7},(r,s)=>e.jsx(te,{className:"h-2.5 w-2.5 rounded-[2px]"},s))},a))})}function td(){return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[e.jsxs("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0 order-2 lg:order-1",children:[e.jsx(Ne,{children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(te,{className:"h-4 w-32"}),e.jsx(te,{className:"h-6 w-24"})]})}),e.jsx(Ne,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(te,{className:"h-3.5 w-24"}),Array.from({length:4},(t,a)=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(te,{className:"h-3 w-20"}),e.jsx(te,{className:"h-3 w-12"})]},a))]})}),e.jsx(Ne,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(te,{className:"h-3.5 w-20"}),e.jsx(ed,{})]})}),e.jsx(Ne,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(te,{className:"h-3.5 w-28"}),e.jsx(te,{className:"h-32 w-full"})]})})]}),e.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0 order-1 lg:order-2",children:[e.jsxs(Ne,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx("div",{className:"flex flex-1 min-w-0 gap-1",children:Array.from({length:5},(t,a)=>e.jsx(te,{className:"h-7 w-14 rounded-md shrink-0"},a))}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(te,{className:"h-8 w-20 rounded-md"}),e.jsx(te,{className:"h-8 w-8 rounded-md"})]})]}),e.jsxs("div",{className:"flex flex-col items-center gap-4 mb-8",children:[e.jsx(te,{className:"h-3 w-28"}),e.jsx(te,{className:"h-14 w-3/5 max-w-xs"}),e.jsx(te,{className:"h-6 w-24"})]}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(te,{className:"h-1.5 w-full rounded-full"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-5 gap-3",children:Array.from({length:5},(t,a)=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(te,{className:"h-[15px] w-[15px] rounded-sm shrink-0"}),e.jsx(te,{className:"h-3 w-12"})]}),e.jsx(te,{className:"h-5 w-10"}),e.jsx(te,{className:"h-2.5 w-14"})]},a))})]})]}),e.jsxs(Ne,{children:[e.jsxs("div",{className:"flex items-center gap-1 mb-4",children:[e.jsx(te,{className:"h-7 w-16 rounded"}),e.jsx(te,{className:"h-7 w-20 rounded"})]}),e.jsxs("div",{className:"flex items-center gap-3 border-b border-oai-gray-200 dark:border-oai-gray-700 pb-2",children:[e.jsx(te,{className:"h-3 w-20 shrink-0"}),Array.from({length:5},(t,a)=>e.jsx(te,{className:"h-3 flex-1"},a))]}),e.jsx("div",{className:"flex flex-col",children:Array.from({length:8},(t,a)=>e.jsxs("div",{className:"flex items-center gap-3 border-b border-oai-gray-100 dark:border-oai-gray-800 py-2.5 last:border-b-0",children:[e.jsx(te,{className:"h-3.5 w-20 shrink-0"}),Array.from({length:5},(r,s)=>e.jsx(te,{className:"h-3.5 flex-1"},s))]},a))})]})]})]})}const ad=Hi.slice(0,10),fs=.06,rd=.11,sd=.05,nd=new Set(["macAppBanner","widgetOnboarding"]);function ps({title:t,subtitle:a,desc:r,loginCard:s,copy:n}){return e.jsxs("div",{className:"min-h-[85vh] w-full flex items-center justify-center text-oai-black dark:text-white relative overflow-hidden px-4 md:px-8 py-8 md:py-16 transition-colors duration-200 bg-[linear-gradient(to_right,#80808007_1px,transparent_1px),linear-gradient(to_bottom,#80808007_1px,transparent_1px)] bg-[size:40px_40px]",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_50%_0%,rgba(59,130,246,0.03),transparent_50%)] dark:bg-[radial-gradient(circle_at_50%_0%,rgba(99,102,241,0.05),transparent_50%)] pointer-events-none"}),e.jsxs("div",{className:"w-full max-w-5xl grid grid-cols-1 lg:grid-cols-12 gap-8 lg:gap-16 items-start relative z-10",children:[e.jsxs("div",{className:"lg:col-span-7 flex flex-col justify-center space-y-8 text-left pr-0 lg:pr-6",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:32,height:32,className:"rounded-md shadow-md border border-oai-gray-200/50 dark:border-oai-gray-800 shadow-black/10 dark:shadow-black/30"}),e.jsx("span",{className:"text-xl font-bold tracking-tight bg-gradient-to-r from-oai-black to-oai-gray-600 dark:from-white dark:to-oai-gray-400 bg-clip-text text-transparent font-oai",children:n("shared.app_name")})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl md:text-4xl lg:text-4.5xl font-black tracking-tight leading-[1.15] text-oai-black dark:text-white",children:t}),e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm md:text-base max-w-xl leading-relaxed",children:r})]}),e.jsx("div",{className:"w-full max-w-[280px] sm:max-w-md opacity-85 hover:opacity-100 transition-opacity duration-200",children:e.jsx("div",{className:"flex justify-start",children:e.jsx(Ui,{logos:ad,columnCount:6})})})]})]}),e.jsx("div",{className:"lg:col-span-5 flex justify-center",children:e.jsxs(_e.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3},className:"w-full max-w-[400px] rounded-2xl border border-oai-gray-200/80 dark:border-oai-gray-800 bg-white/70 dark:bg-oai-gray-950/40 backdrop-blur-md shadow-2xl p-1 relative overflow-hidden",children:[e.jsx("div",{className:"absolute -inset-px bg-gradient-to-b from-white/10 dark:from-white/5 to-transparent pointer-events-none rounded-2xl"}),s]})})]})]})}function od(t){const{copy:a,onOpenShare:r,screenshotMode:s,showExpiredGate:n,showAuthGate:o,identityDisplayName:i,identityStartDate:u,activeDays:c,identitySubscriptions:x,identityScrambleDurationMs:h,projectUsageEntries:g,projectUsageLimit:m,setProjectUsageLimit:f,projectDetailQuery:p,topModels:k,signedIn:y,publicMode:v,isLocalMode:_,shouldShowInstall:A,installPrompt:T,handleCopyInstall:M,installCopied:L,installInitCmdDisplay:U,trendRowsForDisplay:w,trendFromForDisplay:j,trendToForDisplay:D,trendZoomConfig:P,usageFrom:O,usageTo:V,period:E,trendTimeZoneLabel:R,activityHeatmapBlock:q,periodsForDisplay:N,setSelectedPeriod:S,customFrom:Y,customTo:H,onCustomRangeApply:ce,customRangeOpen:J,onCustomRangeOpenChange:de,summaryLabel:oe,summaryValue:he,summaryFullValue:ye,hasSummary:ue,summaryLoading:ee,providersLoading:Q,onToggleSummaryFormat:B,summaryTotalTokensRaw:X,summaryCostValue:xe,summaryConversationsValue:W,rollingUsage:C,costInfoEnabled:z,openCostModal:F,costModalOpen:K,closeCostModal:se,allowBreakdownToggle:we,refreshAll:ve,usageLoadingState:Le,announceUsageLoading:Se,initialDashboardLoading:Ht,fleetData:ie,hasDetailsActual:$e,dailyEmptyPrefix:ze,installSyncCmd:je,dailyEmptySuffix:Ct,detailsColumns:ge,ariaSortFor:fe,toggleSort:Me,sortIconFor:Oe,pagedDetails:Tt,dailyBreakdownRows:dt,dailyBreakdownColumns:Ue,dailyBreakdownAriaSortFor:Ca,dailyBreakdownSortIconFor:Je,dailyBreakdownDateKey:Ta,detailsDateKey:Da,renderDetailDate:ut,renderDailyBreakdownDate:Z,renderDetailCell:Vt,DETAILS_PAGED_PERIODS:be,detailsPageCount:ke,detailsPage:Ee,setDetailsPage:mt,deviceOptions:Wt,selectedDevice:Dt,onDeviceChange:Aa,deviceUsageBlock:He,leftCardOrder:Kt,onLeftReorder:tt,rightCardOrder:At,onRightReorder:Gt}=t,La=null,qt=null,[ht,Ma]=d.useState(()=>new Set),Lt=d.useCallback((ne,ae)=>{nd.has(ne)&&Ma(le=>{if(le.has(ne)===ae)return le;const Qe=new Set(le);return ae?Qe.add(ne):Qe.delete(ne),Qe})},[]),Mt={macAppBanner:_,statsPanel:!0,widgetOnboarding:_,installCopy:A,activityHeatmap:!!q,deviceUsage:!!He,trendMonitor:!s,qualityPerDollar:!s,sessionInsights:_&&!s},Ea=(Kt||[]).filter(ne=>Mt[ne]&&!ht.has(ne)),at={usageOverview:!0,dataDetails:!s},Yt=(At||[]).filter(ne=>at[ne]&&!ht.has(ne));function Ve(ne,ae){switch(ne){case"macAppBanner":return e.jsx(Hc,{todayTokens:X,isSyncing:Le,enterDelay:ae});case"statsPanel":return e.jsx(rt,{delay:ae,children:e.jsx(tc,{title:a("dashboard.identity.title"),subtitle:a("dashboard.identity.subtitle"),period:E,startDate:u??a("identity_card.rank_placeholder"),streakDays:c,subscriptions:x,periodConversations:W,rolling:C,topModels:k})});case"widgetOnboarding":return e.jsx(Wc,{enterDelay:ae});case"installCopy":return e.jsx(rt,{delay:ae,children:e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3",children:[e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:T}),e.jsxs(_e.button,{onClick:M,whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full flex items-center justify-between px-3 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 rounded-lg transition-colors",children:[e.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:U}),e.jsx(_e.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:L?"Copied ✓":"Copy"},L?"copied":"copy")]})]})});case"activityHeatmap":return e.jsx(rt,{delay:ae,children:q});case"deviceUsage":return e.jsx(rt,{delay:ae,children:He});case"trendMonitor":return e.jsx(rt,{delay:ae,children:e.jsx(Fs,{rows:w,from:j,to:D,period:E,timeZoneLabel:R,showTimeZoneLabel:!1,zoomConfig:P})});case"qualityPerDollar":return e.jsx(Yc,{from:O,to:V,deviceId:Dt});case"sessionInsights":return e.jsx(Xc,{from:O,to:V});default:return null}}function me(ne,ae){switch(ne){case"usageOverview":return e.jsx(rt,{delay:ae,children:e.jsx($c,{period:E,periods:N,onPeriodChange:S,summaryLabel:oe,summaryValue:he,summaryFullValue:ye,hasSummary:ue,summaryLoading:ee,providersLoading:Q,onToggleSummaryFormat:ue?B:null,summaryCostValue:xe,onCostInfo:z?F:null,fleetData:ie,onRefresh:s?null:ve,loading:Le,announceLoading:Se,onOpenShare:s?null:r,customFrom:Y,customTo:H,onCustomRangeApply:ce,customRangeOpen:J,onCustomRangeOpenChange:de,from:O,to:V,deviceOptions:Wt,selectedDevice:Dt,onDeviceChange:Aa})});case"dataDetails":return e.jsx(rt,{delay:ae,children:e.jsx(Xl,{projectEntries:g,projectLimit:m,onProjectLimitChange:f,projectDetailQuery:p,copy:a,hasDetailsActual:$e,dailyEmptyPrefix:ze,installSyncCmd:je,dailyEmptySuffix:Ct,detailsColumns:ge,ariaSortFor:fe,toggleSort:Me,sortIconFor:Oe,pagedDetails:Tt,dailyBreakdownRows:dt,dailyBreakdownColumns:Ue,dailyBreakdownAriaSortFor:Ca,dailyBreakdownSortIconFor:Je,dailyBreakdownDateKey:Ta,detailsDateKey:Da,renderDetailDate:ut,renderDailyBreakdownDate:Z,renderDetailCell:Vt,DETAILS_PAGED_PERIODS:be,period:E,detailsPageCount:ke,detailsPage:Ee,setDetailsPage:mt})});default:return null}}const Ra=ui(Kr(pi,{activationConstraint:{distance:6}}),Kr(fi,{coordinateGetter:gi})),Zt=d.useCallback(ne=>{const{active:ae,over:le}=ne;!le||ae.id===le.id||tt?.(String(ae.id),String(le.id))},[tt]),Jt=d.useCallback(ne=>{const{active:ae,over:le}=ne;!le||ae.id===le.id||Gt?.(String(ae.id),String(le.id))},[Gt]);function Qt(ne,ae,le,Qe){return s?e.jsx(e.Fragment,{children:ne.map((Ke,Et)=>e.jsx(wt.Fragment,{children:ae(Ke,le+fs*Et)},Ke))}):e.jsx(mi,{sensors:Ra,onDragEnd:Qe,children:e.jsx(hi,{items:ne,strategy:xi,children:ne.map((Ke,Et)=>e.jsx(Bc,{id:Ke,onEmptyChange:Lt,children:ae(Ke,le+fs*Et)},Ke))})})}const Xt=Qt(Ea,Ve,rd,Zt),ea=Qt(Yt,me,sd,Jt);return e.jsxs(e.Fragment,{children:[e.jsxs(al,{bare:!s,hideHeader:s,header:La,footer:s?null:qt,className:s?"screenshot-mode":"",children:[o&&e.jsx(ps,{title:a("dashboard.auth_gate.hero_title"),desc:a("dashboard.auth_gate.desc"),copy:a,loginCard:e.jsx(zr,{title:a("dashboard.auth_gate.title"),subtitle:a("dashboard.auth_gate.subtitle"),hideLogo:!0,className:"bg-transparent rounded-xl"})}),n&&e.jsx(ps,{title:a("dashboard.expired_gate.hero_title"),desc:a("dashboard.expired_gate.desc"),copy:a,loginCard:e.jsx(zr,{title:a("dashboard.expired_gate.title"),subtitle:a("dashboard.expired_gate.subtitle"),hideLogo:!0,className:"bg-transparent rounded-xl"})}),!o&&!n&&Ht&&e.jsx(td,{}),!o&&!n&&!Ht&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[e.jsx("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0 order-2 lg:order-1",children:Xt}),e.jsx("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0 order-1 lg:order-2",children:ea})]})})]}),e.jsx(Kl,{isOpen:K,onClose:se,fleetData:ie})]})}function id({from:t,to:a,timeZone:r,tzOffsetMinutes:s,accountView:n=!1,accountAccessToken:o=null,accountRevision:i=0}={}){const u=!!(n&&o),[c,x]=d.useState([]),[h,g]=d.useState([]),[m,f]=d.useState(!1),[p,k]=d.useState(null),y=Ut([u,t,a,r,s,o,i]),v=d.useCallback(async()=>{const _=y();if(!u){x([]),g([]),f(!1),k(null);return}f(!0),k(null);try{const A=await Ie(o);if(!_())return;const T=await Go({from:t,to:a,timeZone:r,tzOffsetMinutes:s,accessToken:A});if(!_())return;x(Array.isArray(T?.devices)?T.devices:[]),g(Array.isArray(T?.account_sources)?T.account_sources:[])}catch(A){if(!_())return;k(A?.message||String(A)),x([]),g([])}finally{_()&&f(!1)}},[u,o,t,a,r,s,i,y]);return d.useEffect(()=>{x([]),g([]),k(null),u&&f(!0),v()},[u,v]),{devices:c,accountSources:h,loading:m,error:p,refresh:v}}const ld=/^Token Tracker \(dashboard\)(?: #([0-9a-fA-F]+))?$/;function ys(t){const a=String(t||"").toLowerCase();return/iphone|ipad|ios/.test(a)?"iOS":/android/.test(a)?"Android":/mac|darwin/.test(a)?"Mac":/win/.test(a)?"Windows":/linux/.test(a)?"Linux":"Web"}function ur(t){if(!t)return null;const a=typeof t.device_name=="string"?t.device_name.trim():"",r=a.match(ld);if(!r)return a||null;const s=(r[1]||String(t.id||"")).slice(0,8).toLowerCase();return s?`${ys(t.platform)} · ${s}`:ys(t.platform)}const bs=" · ",ks="%";function ws({platform:t,className:a}){const r=String(t||"").toLowerCase();return r.includes("darwin")||r.includes("mac")?e.jsx(qi,{className:a,"aria-hidden":!0}):r.includes("win")?e.jsx(Or,{className:a,"aria-hidden":!0}):r.includes("linux")?e.jsx(Or,{className:a,"aria-hidden":!0}):e.jsx(Os,{className:a,"aria-hidden":!0})}function cd({devices:t=[],accountSources:a=[],selectedDeviceId:r="",onSelectDevice:s,onRenameDevice:n}){const{formatTokens:o,formatTokensTooltip:i}=Fe(),[u,c]=d.useState(""),[x,h]=d.useState(""),[g,m]=d.useState(!1),[f,p]=d.useState(""),k=typeof n=="function",y=typeof s=="function",v=!!r,_=t.reduce((w,j)=>w+(Number(j.total_tokens)||0),0)+a.reduce((w,j)=>w+(Number(j.total_tokens)||0),0),A=d.useMemo(()=>t.filter(w=>(Number(w.total_tokens)||0)>0).sort((w,j)=>(Number(j.total_tokens)||0)-(Number(w.total_tokens)||0)),[t]);function T(w){p(""),c(w.id);const j=typeof w.device_name=="string"?w.device_name:"";h(ur(w)===j?j:"")}function M(){c(""),h(""),p("")}async function L(w){const j=x.trim();if(!(!j||g)){m(!0),p("");try{await n(w.id,j),c(""),h("")}catch{p(w.id)}finally{m(!1)}}}const U=a.filter(w=>(Number(w.total_tokens)||0)>0);return A.length===0&&U.length===0?e.jsxs(Ne,{bodyClassName:"!px-3 !py-3.5",children:[e.jsx("div",{className:"flex items-center justify-between gap-2 mb-2 px-2",children:e.jsx("div",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide px-2",children:l("dashboard.device_card.title")})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[e.jsx(Os,{className:"h-7 w-7 text-oai-gray-300 dark:text-oai-gray-600 mb-2 stroke-[1.5]"}),e.jsx("p",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 font-medium",children:l("dashboard.device_card.empty")})]})]}):e.jsxs(Ne,{bodyClassName:"!px-3 !py-3.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2 px-2",children:[e.jsx("div",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:l("dashboard.device_card.title")}),y&&v&&e.jsx("button",{type:"button",onClick:()=>s(""),className:"text-xs text-oai-gray-400 hover:text-oai-brand focus:outline-none transition-colors",children:l("dashboard.device_card.clear")})]}),e.jsxs("div",{className:"space-y-[2px]",children:[A.map(w=>{const j=Number(w.total_tokens)||0,D=_>0?(j/_*100).toFixed(1):"0.0",P=r===w.id,O=ur(w)||l("dashboard.device_card.unnamed"),V=u===w.id,E=P?"bg-oai-brand":v?"bg-oai-gray-300 dark:bg-oai-gray-600":"bg-oai-brand/50",R=v&&!P?"opacity-40 hover:opacity-80":"opacity-100";return e.jsxs("div",{className:"group relative",children:[V?e.jsxs("div",{className:"w-full rounded-md px-2 py-1.5 bg-oai-gray-50/50 dark:bg-oai-gray-900/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(ws,{platform:w.platform,className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400"}),e.jsx("input",{autoFocus:!0,value:x,disabled:g,maxLength:60,placeholder:l("dashboard.device_card.rename_placeholder"),onChange:q=>h(q.target.value),onKeyDown:q=>{q.key==="Enter"?L(w):q.key==="Escape"&&M()},className:"flex-1 min-w-0 bg-transparent text-xs font-medium text-oai-black dark:text-oai-white border-b border-oai-gray-300 dark:border-oai-gray-700 focus:outline-none focus:border-oai-brand py-0"})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5",children:[e.jsx("button",{type:"button","aria-label":l("dashboard.device_card.rename_save"),disabled:g||!x.trim(),onClick:()=>L(w),className:"text-oai-gray-400 hover:text-oai-brand dark:hover:text-white disabled:opacity-30 transition-colors p-0.5",children:e.jsx(Vi,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","aria-label":l("dashboard.device_card.rename_cancel"),disabled:g,onClick:M,className:"text-oai-gray-400 hover:text-oai-black dark:hover:text-white disabled:opacity-30 transition-colors p-0.5",children:e.jsx(yr,{className:"h-3.5 w-3.5"})})]})]}),e.jsx("div",{className:"mt-1.5 h-[2px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden opacity-40 select-none",children:e.jsx("div",{className:`h-full rounded-full transition-[width,background-color] duration-700 ease-out ${E}`,style:{width:`${D}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button","aria-pressed":P,"aria-label":`${l("dashboard.device_filter.aria")}: ${O}`,onClick:()=>s?.(P?"":w.id),className:`w-full text-left rounded-md px-2 py-1.5 transition-all duration-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-oai-brand/50 ${R} ${P?"bg-oai-gray-100/70 dark:bg-oai-gray-800/80 text-oai-black dark:text-oai-white":"bg-transparent hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 text-oai-black dark:text-oai-white"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(ws,{platform:w.platform,className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400"}),e.jsx("span",{className:"block truncate text-[13px] font-medium text-oai-black dark:text-oai-white",title:O,children:O})]}),e.jsxs("span",{title:i(j),className:`shrink-0 text-[13px] font-semibold tabular-nums text-oai-black dark:text-oai-white transition-opacity duration-150 ${k?"group-hover:opacity-0":""}`,children:[o(j),e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:[bs,D,ks]})]})]}),e.jsx("div",{className:"mt-1.5 h-[2px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-[width,background-color] duration-700 ease-out ${E}`,style:{width:`${D}%`}})})]}),k&&e.jsx("button",{type:"button","aria-label":l("dashboard.device_card.rename_aria"),onClick:()=>T(w),className:"absolute right-2 top-1.5 flex h-4 items-center text-oai-gray-400 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-oai-brand focus:outline-none transition-opacity duration-150",children:e.jsx(Oi,{className:"h-3 w-3"})})]}),f===w.id&&e.jsx("div",{className:"px-2 mt-1 text-xs text-red-500 font-medium",children:l("dashboard.device_card.rename_error")})]},w.id)}),U.map(w=>{const j=Number(w.total_tokens)||0,D=_>0?(j/_*100).toFixed(1):"0.0",P=v?"opacity-40":"opacity-100";return e.jsxs("div",{className:`rounded-md px-2 py-1.5 transition-all duration-200 ${P}`,title:l("dashboard.device_card.account_scope_tip"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"h-3.5 w-3.5 shrink-0 flex items-center justify-center",children:e.jsx(Nt,{provider:w.source,size:14})}),e.jsx("span",{className:"block truncate text-[13px] font-medium text-oai-black dark:text-oai-white",children:_t(w.source)}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:l("dashboard.device_card.account_scope")})]}),e.jsxs("span",{title:i(j),className:"shrink-0 text-[13px] font-semibold tabular-nums text-oai-black dark:text-oai-white",children:[o(j),e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:[bs,D,ks]})]})]}),e.jsx("div",{className:"mt-1.5 h-[2px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-[width,background-color] duration-700 ease-out ${v?"bg-oai-gray-300 dark:bg-oai-gray-600":"bg-oai-brand/50"}`,style:{width:`${D}%`}})})]},`account-${w.source}`)})]})]})}function sn(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const it=new Map,lt=new Map;function nn(){typeof window>"u"||window.__tokentrackerNativeSaveListener||(window.__tokentrackerNativeSaveListener=!0,window.addEventListener("native:saveImageResult",t=>{const a=t?.detail||{},r=typeof a.requestId=="string"?a.requestId:null;if(!r||!it.has(r))return;const s=it.get(r);it.delete(r),s({ok:!!a.ok,path:typeof a.path=="string"?a.path:void 0,error:typeof a.error=="string"?a.error:void 0})}),window.addEventListener("native:copyImageResult",t=>{const a=t?.detail||{},r=typeof a.requestId=="string"?a.requestId:null;if(!r||!lt.has(r))return;const s=lt.get(r);lt.delete(r),s({ok:!!a.ok,error:typeof a.error=="string"?a.error:void 0})}))}async function dd(t){if(!sn()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const a=window?.webkit?.messageHandlers?.nativeBridge;if(!a)return{ok:!1,error:"native bridge unavailable"};nn();const r=`copy_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{const n=window.setTimeout(()=>{lt.has(r)&&(lt.delete(r),s({ok:!1,error:"timeout"}))},8e3);lt.set(r,o=>{window.clearTimeout(n),s(o)});try{a.postMessage({type:"action",name:"copyImageToClipboard",requestId:r,dataUrl:t})}catch(o){lt.delete(r),window.clearTimeout(n),s({ok:!1,error:o?.message||String(o)})}})}async function _s(t,a){if(!sn()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const r=window?.webkit?.messageHandlers?.nativeBridge;if(!r)return{ok:!1,error:"native bridge unavailable"};nn();const s=`save_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(n=>{const o=window.setTimeout(()=>{it.has(s)&&(it.delete(s),n({ok:!1,error:"timeout"}))},8e3);it.set(s,i=>{window.clearTimeout(o),n(i)});try{r.postMessage({type:"action",name:"saveImageToDownloads",requestId:s,filename:a,dataUrl:t})}catch(i){it.delete(s),window.clearTimeout(o),n({ok:!1,error:i?.message||String(i)})}})}const on=1200,ln=1630,cn={broadsheet:{width:1200,height:1630},"annual-report":{width:1080,height:1865}},ud="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600;700&family=IBM+Plex+Serif:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap";let sr=!1;function md(){if(typeof document>"u"||sr)return;if(document.querySelector('link[data-share-card-fonts="true"]')){sr=!0;return}const a=document.createElement("link");a.rel="stylesheet",a.href=ud,a.dataset.shareCardFonts="true",a.crossOrigin="anonymous",document.head.appendChild(a),sr=!0}async function hd(){if(typeof document>"u")return;const t=document.fonts;if(!(!t||typeof t.ready?.then!="function"))try{await t.ready}catch{}}async function xd(t,a={}){if(typeof window>"u"||!t)return null;md(),await hd(),await new Promise(c=>requestAnimationFrame(()=>c(null)));const{toBlob:r,toPng:s}=await qo(async()=>{const{toBlob:c,toPng:x}=await import("./index-BFIcLxb4.js");return{toBlob:c,toPng:x}},[]),n=a.pixelRatio??2,o=t.offsetWidth||on,i=t.offsetHeight||ln,u={pixelRatio:n,cacheBust:!0,width:o,height:i,style:{width:`${o}px`,height:`${i}px`},skipFonts:!1,filter:c=>!(c instanceof HTMLElement)||c.dataset?.screenshotExclude!=="true"};try{const c=await r(t,u);if(c)return c}catch{}try{const c=await s(t,u);return c?await(await fetch(c)).blob():null}catch{return null}}async function nr(t){return new Promise(a=>{const r=new FileReader;r.onload=()=>{const s=typeof r.result=="string"?r.result:null;a(s)},r.onerror=()=>a(null),r.readAsDataURL(t)})}function vs(t,a){if(typeof window>"u"||!t)return!1;try{const r=URL.createObjectURL(t),s=document.createElement("a");return s.href=r,s.download=a,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3),!0}catch{return!1}}function mr(t){const a=re(t);return Number.isFinite(a)?a:0}function gd(t){return t?mr(t.billable_total_tokens??t.total_tokens):0}function fd(t){const a=Array.isArray(t?.weeks)?t.weeks:[];if(!a.length)return{weeks:[],totalDays:0,activeDays:0};let r=0,s=0;return{weeks:a.map(o=>(Array.isArray(o)?o:[]).slice(0,7).map(u=>{const c=!!u?.future,x=Number.isFinite(u?.level)?Math.max(0,Math.min(4,Math.round(u.level))):0;u?.day&&!c&&(r+=1,x>0&&(s+=1));const h=u?.billable_total_tokens??u?.total_tokens??u?.value??0,g=Number.isFinite(h)?Math.max(0,h):0;return{day:typeof u?.day=="string"?u.day:"",level:x,value:g,future:c}})),totalDays:r,activeDays:s}}function pd(t){const{handle:a,startDate:r,activeDays:s,summary:n,topModels:o,rank:i,period:u,periodFrom:c,periodTo:x,heatmap:h,capturedAt:g,currency:m,exchangeRate:f}=t,p=gd(n),k=mr(n?.total_cost_usd),y=Array.isArray(o)?o.slice(0,3).map(_=>({id:_?.id??null,name:typeof _?.name=="string"&&_.name?_.name:"—",tokens:mr(_?.tokens),percent:typeof _?.percent=="string"&&_.percent?_.percent:"0.0"})):[],v=fd(h);return{handle:a||"—",startDate:r||null,activeDays:Number.isFinite(s)&&s>0?Math.floor(s):0,totalTokens:p,totalCost:k,period:u,periodFrom:c,periodTo:x,topModels:y,rank:typeof i=="number"&&Number.isFinite(i)&&i>0?Math.floor(i):null,heatmapWeeks:v.weeks,heatmapTotalDays:v.totalDays,heatmapActiveDays:v.activeDays,capturedAt:g||new Date().toISOString(),currency:typeof m=="string"&&m.length>0?m.toUpperCase():"USD",exchangeRate:Number.isFinite(f)&&f>0?f:1}}const yd=["share.month_short.jan","share.month_short.feb","share.month_short.mar","share.month_short.apr","share.month_short.may","share.month_short.jun","share.month_short.jul","share.month_short.aug","share.month_short.sep","share.month_short.oct","share.month_short.nov","share.month_short.dec"];function bd(t){const a=yd[t];return a?l(a):"—"}function dn(t,a){return l("share.date.month_year",{month:bd(t),year:a})}function kd(t){if(!t)return"—";const a=t.split("-");if(a.length!==3)return t;const[r,s]=a,n=Number(s)-1;return n<0||n>11?t:dn(n,r)}function wd(t){if(t.period==="total")return l("share.issue.all_time");if(t.period==="day"&&t.periodTo)return t.periodTo.replace(/-/g,".");if(t.period==="custom"&&t.periodFrom&&t.periodTo)return`${t.periodFrom.replace(/-/g,".")} — ${t.periodTo.replace(/-/g,".")}`;if(t.periodTo){const a=new Date(`${t.periodTo}T00:00:00Z`);if(!Number.isNaN(a.getTime()))return dn(a.getUTCMonth(),a.getUTCFullYear())}return l(`usage.period.${t.period}`)}function hr(t){return Number.isFinite(t)?Math.round(t).toLocaleString("en-US"):"—"}function un(t,a={}){const{currency:r="USD",rate:s=1}=a,n=ja(r);if(!Number.isFinite(t)||t<=0)return`${n}0.00`;const o=r!=="USD"&&Number.isFinite(s)&&s>0?t*s:t;return o>=1e3?`${n}${Math.round(o).toLocaleString("en-US")}`:`${n}${o.toFixed(2)}`}function _d(t){const a=t.topModels[0];if(a){const r=parseFloat(a.percent);return Number.isFinite(r)&&r>=60?l("share.hook.top_loyal",{percent:Math.round(r),name:a.name}):t.activeDays>=60?l("share.hook.days_record",{days:t.activeDays}):Number.isFinite(r)&&r>=30?l("share.hook.top_led",{name:a.name,percent:Math.round(r)}):t.topModels.length>1?l("share.hook.multi_models",{count:t.topModels.length,days:t.activeDays}):l("share.hook.days_with_model",{days:t.activeDays,name:a.name})}return t.activeDays>0?l("share.hook.days_record",{days:t.activeDays}):l("share.hook.new_chapter")}function vd(t,a){const r=(t||"").length;if(r<=a.baseChars)return a.baseSize;const s=a.baseSize-(r-a.baseChars)*a.shrinkPerChar;return Math.max(a.minSize,s)}function jd(t){if(!t||t.future)return null;const a=typeof t.level=="number"?t.level:0;return a<0?0:a>4?4:Math.round(a)}function Nd({weeks:t,palette:a,width:r,gap:s=3,radius:n=2,emptyColor:o}){if(!Array.isArray(t)||t.length===0||!r||r<=0)return null;const i=a||["#eee","#ccc","#999","#666","#333"],u=o||i[0],c=t.length,x=(c-1)*s,h=Math.max(4,(r-x)/c),g=7*h+6*s;return e.jsx("svg",{width:r,height:g,viewBox:`0 0 ${r} ${g}`,xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,style:{display:"block"},children:t.map((m,f)=>(Array.isArray(m)?m:[]).map((k,y)=>{if(y>=7)return null;const v=jd(k),_=f*(h+s),A=y*(h+s),T=v===null?u:i[v];return e.jsx("rect",{x:_,y:A,width:h,height:h,rx:n,ry:n,fill:T},`${f}-${y}`)}))})}const Sd=St("oklch(0.97 0.01 85)"),Ae=St("oklch(0.18 0.02 85)"),Xe=St("oklch(0.38 0.015 85)"),js=St("oklch(0.55 0.012 85)"),st=St("oklch(0.55 0.22 25)"),nt='"Instrument Serif", "Times New Roman", Georgia, serif',Cd='"Inter Tight", "Helvetica Neue", Arial, sans-serif',Td=["oklch(0.93 0.013 80)","oklch(0.87 0.04 55)","oklch(0.78 0.09 45)","oklch(0.67 0.16 35)","oklch(0.55 0.22 25)"].map(St);function mn({data:t}){const a=wd(t),r=hr(t.totalTokens),s=un(t.totalCost,{currency:t.currency,rate:t.exchangeRate}),n=kd(t.startDate),o=vd(r,{baseSize:188,baseChars:9,shrinkPerChar:14,minSize:104}),i=_d(t),u=Array.isArray(t.heatmapWeeks)&&t.heatmapWeeks.length>0;return e.jsxs("div",{style:{width:"100%",height:"100%",background:Sd,color:Ae,fontFamily:Cd,padding:"80px 88px 68px 88px",boxSizing:"border-box",display:"flex",flexDirection:"column",position:"relative"},children:[e.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,paddingBottom:14,borderBottom:`1px solid ${js}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,fontSize:14,fontWeight:500,letterSpacing:"0.22em",textTransform:"uppercase",color:Ae},children:[e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:st}}),"The Token Tracker"]}),e.jsxs("div",{style:{fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:Xe,textAlign:"right"},children:[l("share.card.broadsheet.issue")," № ",a]})]}),e.jsxs("div",{style:{marginTop:24,display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:24},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,letterSpacing:"0.2em",textTransform:"uppercase",color:Xe,marginBottom:6},children:l("share.card.broadsheet.by")}),e.jsx("div",{style:{fontFamily:nt,fontSize:52,fontStyle:"italic",lineHeight:1,color:Ae,letterSpacing:"-0.01em"},children:t.handle})]}),e.jsxs("div",{style:{fontSize:12,letterSpacing:"0.18em",textTransform:"uppercase",color:Xe,textAlign:"right",lineHeight:1.6},children:[l("share.card.broadsheet.tracked_since"),e.jsx("br",{}),e.jsx("span",{style:{color:Ae},children:n})]})]}),e.jsxs("div",{style:{marginTop:40,display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{fontSize:13,letterSpacing:"0.3em",textTransform:"uppercase",color:st,marginBottom:10},children:l("share.card.broadsheet.total_tokens")}),e.jsx("div",{style:{fontFamily:nt,fontSize:o,fontWeight:400,lineHeight:.86,letterSpacing:"-0.032em",color:Ae,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap",overflow:"hidden"},children:r}),e.jsxs("div",{style:{marginTop:14,fontFamily:nt,fontStyle:"italic",fontSize:34,lineHeight:1.15,color:Ae,letterSpacing:"-0.005em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:["“",i,"”"]}),e.jsx("div",{style:{marginTop:14,height:1,background:st,width:"100%"}}),e.jsxs("div",{style:{marginTop:10,display:"flex",justifyContent:"space-between",fontSize:13,letterSpacing:"0.16em",textTransform:"uppercase",color:Xe},children:[e.jsxs("span",{children:[l("share.card.broadsheet.estimated_spend")," · ",s]}),e.jsx("span",{children:l("share.card.broadsheet.billable_days",{days:t.activeDays})})]})]}),u?e.jsxs("section",{style:{marginTop:40},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:12},children:[e.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ae,fontWeight:600},children:l("share.card.broadsheet.heatmap_title")}),e.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:Xe},children:l("share.card.broadsheet.heatmap_days_on_record",{active:t.heatmapActiveDays,total:t.heatmapTotalDays})})]}),e.jsx(Nd,{weeks:t.heatmapWeeks,palette:Td,width:1024,gap:3,radius:2})]}):null,e.jsxs("section",{style:{marginTop:30,flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",borderBottom:`1px solid ${Ae}`,paddingBottom:10,marginBottom:6},children:[e.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ae,fontWeight:600},children:l("share.card.broadsheet.roster_title")}),e.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:Xe},children:l("share.card.broadsheet.roster_subtitle")})]}),t.topModels.length===0?e.jsx("div",{style:{fontFamily:nt,fontStyle:"italic",fontSize:26,color:Xe,paddingTop:14},children:l("share.card.broadsheet.empty")}):t.topModels.map((c,x)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"52px 1fr auto 68px",alignItems:"baseline",gap:16,padding:"13px 0",borderBottom:`1px solid ${js}`},children:[e.jsx("div",{style:{fontFamily:nt,fontSize:34,fontStyle:"italic",color:st,lineHeight:1},children:String(x+1).padStart(2,"0")}),e.jsx("div",{style:{fontFamily:nt,fontSize:32,color:Ae,lineHeight:1.1,letterSpacing:"-0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name}),e.jsx("div",{style:{fontFamily:nt,fontSize:28,color:Ae,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap"},children:hr(c.tokens)}),e.jsxs("div",{style:{fontSize:13,letterSpacing:"0.1em",color:Xe,textAlign:"right",fontFeatureSettings:'"tnum" 1'},children:[c.percent,"%"]})]},c.id||c.name))]}),e.jsxs("footer",{style:{marginTop:18,paddingTop:12,borderTop:`1px solid ${Ae}`,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:Ae},children:[e.jsxs("div",{style:{display:"flex",gap:28},children:[e.jsxs("span",{children:[l("share.card.broadsheet.global_rank")," ",e.jsxs("span",{style:{color:st},children:["№ ",t.rank!=null?t.rank:"—"]})]}),e.jsxs("span",{children:[l("share.card.broadsheet.active_days")," ",e.jsx("span",{style:{color:st},children:l("share.card.broadsheet.days_count",{days:t.activeDays})})]})]}),e.jsxs("div",{children:[l("share.card.broadsheet.track_yours")," ",e.jsx("span",{style:{color:st},children:"→ tokentracker.cc"})]})]})]})}const Dd=cn["annual-report"].width,Ad="#0a0820",et="#ffffffee",ot="rgba(255,255,255,0.45)",or="#a78bfa",Ld={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(40px)",WebkitBackdropFilter:"blur(40px)",border:"1px solid rgba(255,255,255,0.05)",boxShadow:["0 39px 56px -36px rgba(255,255,255,0.10) inset","0 7px 11px -4px rgba(255,255,255,0.06) inset","0 -82px 68px -64px rgba(101,67,149,0.08) inset","0 98px 100px -48px rgba(208,171,255,0.06) inset","0 4px 18px 0 rgba(156,146,215,0.06) inset","0 1px 40px 0 rgba(228,222,255,0.04) inset"].join(", ")},xa={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(32px)",WebkitBackdropFilter:"blur(32px)",border:"1px solid rgba(255,255,255,0.06)",boxShadow:"0 1px 8px 0 rgba(228,222,255,0.06) inset"},xr='"Space Grotesk", "Inter Tight", sans-serif',ir='"Inter Tight", sans-serif',Md="rgba(255,255,255,0.06)",hn=[Md,"#4a3d8f","#6b5cbe","#9060e0","#d946ef"],xn=48,gn=28,_a=4,fn=20,Ed=Dd-xn*2-gn*2,Rd=(Ed-fn*2)/3,gr=Math.min(Math.floor((Rd-_a*6)/7),40),Id=gr*7+_a*6;function Fd(t){if(!Array.isArray(t))return t;const a=[];for(const u of t)if(Array.isArray(u))for(const c of u)c?.day&&!c.future&&c.value>0&&a.push(c.value);if(!a.length)return t;a.sort((u,c)=>u-c);const r=u=>{const c=a.length,x=(c-1)*u,h=Math.floor(x);return Math.round((a[h]??0)+((a[Math.min(c-1,h+1)]??0)-(a[h]??0))*(x-h))},s=r(.5),n=r(.75),o=r(.9),i=u=>!u||u<=0?0:u<=s?1:u<=n?2:u<=o?3:4;return t.map(u=>Array.isArray(u)?u.map(c=>c?.day&&!c.future&&typeof c.value=="number"?{...c,level:i(c.value)}:c):u)}function $d(t){if(!Array.isArray(t))return[];const a={},r=Fd(t);for(const s of r)if(Array.isArray(s))for(const n of s){if(!n?.day||n.future)continue;const o=n.day.split("-");if(o.length<2)continue;const i=`${o[0]}-${o[1]}`;(a[i]??=[]).push(n)}return Object.entries(a).sort(([s],[n])=>s.localeCompare(n)).slice(-12).map(([s,n])=>({month:parseInt(s.split("-")[1],10),cells:n}))}function Pd(t){if(!t.length)return[];const a=[...t].sort((i,u)=>i.day.localeCompare(u.day));let r=new Date(`${a[0].day}T00:00:00Z`).getUTCDay();const s=Array(r).fill(null).concat(a),n=[];for(let i=0;i<s.length;i+=7)n.push(s.slice(i,i+7));const o=n[n.length-1];for(;o&&o.length<7;)o.push(null);return n.slice(0,6)}const Bd=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function zd(t){if(!Array.isArray(t))return 0;const a=[];for(const n of t)if(Array.isArray(n))for(const o of n)o?.day&&!o.future&&a.push(o);a.sort((n,o)=>n.day.localeCompare(o.day));let r=0,s=0;for(const n of a)(n.level||0)>0?(s++,s>r&&(r=s)):s=0;return r}function Ns(t){const[a,r]=d.useState(null);return d.useEffect(()=>{if(!t){r(null);return}let s=!1;const n=new Image;return n.crossOrigin="anonymous",n.onload=()=>{if(!s)try{const o=document.createElement("canvas");o.width=n.naturalWidth,o.height=n.naturalHeight,o.getContext("2d").drawImage(n,0,0),r(o.toDataURL("image/png"))}catch{r(null)}},n.onerror=()=>{s||r(null)},n.src=t,()=>{s=!0}},[t]),a}function Od({data:t}){const a=Pd(t.cells);return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600,color:ot,fontFamily:xr,marginBottom:4},children:Bd[t.month]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:_a},children:a.map((r,s)=>e.jsx("div",{style:{display:"flex",gap:_a},children:r.map((n,o)=>{const i=n?Math.min(4,Math.max(0,n.level||0)):-1;return e.jsx("div",{style:{width:gr,height:gr,borderRadius:4,background:i<0?"transparent":hn[i]}},o)})},s))})]})}function Ud({data:t}){const a=$d(t.heatmapWeeks),r=zd(t.heatmapWeeks),s=t.topModels[0],n=t.avatarUrl||null,o=Ns(n),i=Ns("/neon_bg.png"),u=(t.handle||"?")[0].toUpperCase(),c=16;return e.jsxs("div",{style:{width:"100%",height:"100%",background:Ad,fontFamily:xr,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[e.jsx("img",{src:i||"/neon_bg.png",alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),e.jsxs("div",{style:{position:"relative",zIndex:1,display:"flex",flexDirection:"column",height:"100%",padding:xn,boxSizing:"border-box"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:c*3},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:64,height:64,style:{width:64,height:64,borderRadius:16,display:"block"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:20,fontWeight:500,color:ot,lineHeight:1.2},children:"Token Tracker"}),e.jsx("div",{style:{fontSize:36,fontWeight:700,lineHeight:1.15,color:et},children:l("share.card.annual.report_title")})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:"50%",background:"linear-gradient(135deg,#4c1d95,#7c3aed)",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid rgba(255,255,255,0.15)",overflow:"hidden",flexShrink:0},children:o?e.jsx("img",{src:o,alt:"",width:48,height:48,style:{width:48,height:48,objectFit:"cover",display:"block"},crossOrigin:"anonymous",referrerPolicy:"no-referrer"}):e.jsx("span",{style:{fontSize:20,fontWeight:700,color:et},children:u})}),e.jsx("div",{style:{fontSize:32,fontWeight:700,color:et},children:t.handle})]})]}),e.jsxs("div",{style:{...Ld,borderRadius:22,padding:gn,marginBottom:c},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:14,color:ot},children:[e.jsx("span",{children:l("share.card.annual.less")}),hn.map((x,h)=>e.jsx("div",{style:{width:16,height:16,borderRadius:3,background:x}},h)),e.jsx("span",{children:l("share.card.annual.more")})]}),e.jsx("div",{style:{fontSize:16,fontWeight:700,letterSpacing:"0.14em",color:"rgba(255,255,255,0.22)",textTransform:"uppercase"},children:l("share.card.annual.heatmap_title")})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(3,${Id}px)`,gap:`8px ${fn}px`,justifyContent:"center"},children:a.map(x=>e.jsx(Od,{data:x},x.month))})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:c,marginBottom:c},children:[e.jsxs("div",{style:{...xa,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[e.jsx("div",{style:{fontFamily:ir,fontSize:52,fontWeight:700,color:et,letterSpacing:"-0.02em",lineHeight:1},children:hr(t.totalTokens)}),e.jsx("div",{style:{fontSize:22,color:ot,marginTop:12},children:l("share.card.annual.total_tokens")})]}),e.jsxs("div",{style:{...xa,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[e.jsx("div",{style:{fontFamily:ir,fontSize:52,fontWeight:700,color:et,letterSpacing:"-0.02em",lineHeight:1},children:un(t.totalCost,{currency:t.currency,rate:t.exchangeRate})}),e.jsx("div",{style:{fontSize:22,color:ot,marginTop:12},children:l("share.card.annual.estimated_cost")})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c},children:[e.jsxs("div",{style:{...xa,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:or,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48 2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48 2.83-2.83"}),e.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),e.jsx("span",{style:{fontSize:20,color:ot},children:l("share.card.annual.longest_streak")})]}),e.jsx("span",{style:{fontFamily:ir,fontSize:28,fontWeight:700,color:et},children:l("share.card.annual.days_count",{days:r})})]}),e.jsxs("div",{style:{...xa,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:or,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),e.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),e.jsx("span",{style:{fontSize:20,color:ot},children:l("share.card.annual.top_model")})]}),e.jsx("span",{style:{fontFamily:xr,fontSize:28,fontWeight:700,color:et},children:s?s.name:"—"})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:44,height:44,style:{width:44,height:44,borderRadius:8,display:"block"}}),e.jsx("span",{style:{fontSize:22,fontWeight:600,color:et},children:"Token Tracker"})]}),e.jsx("span",{style:{fontSize:22,fontWeight:600,color:or},children:"tokentracker.cc"})]})]})]})}const pn=[{id:"annual-report",labelKey:"share.variant.neon"},{id:"broadsheet",labelKey:"share.variant.broadsheet"}],Hd={broadsheet:mn,"annual-report":Ud};function yn(t){return cn[t]||{width:on,height:ln}}function Vd(t){const a=pn.find(r=>r.id===t);return a?.labelKey?l(a.labelKey):t}const Ss=d.forwardRef(function({data:a,variant:r},s){const n=Hd[r]||mn,{width:o,height:i}=yn(r);return e.jsx("div",{ref:s,"data-share-card":"true",style:{width:o,height:i,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:e.jsx(n,{data:a})})});function ga(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Wd=440;function Kd(){const[t,a]=d.useState(null),r=d.useRef(null),s=d.useCallback((n,o="info")=>{r.current&&window.clearTimeout(r.current),a({id:Date.now(),kind:o,text:n}),r.current=window.setTimeout(()=>a(null),2800)},[]);return d.useEffect(()=>()=>{r.current&&window.clearTimeout(r.current)},[]),{toast:t,push:s}}function lr({onClick:t,disabled:a,children:r,emphasis:s,ariaLabel:n}){return e.jsx("button",{type:"button",onClick:t,disabled:a,"aria-label":n,className:["group relative flex items-center justify-between gap-3 w-full px-4 py-3 text-left","rounded-lg border transition-colors",s?"border-oai-black dark:border-oai-white bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black hover:opacity-90":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600",a?"opacity-60 cursor-not-allowed":"cursor-pointer"].join(" "),children:r})}function Gd({open:t,onClose:a,data:r,twitterText:s}){const[n,o]=d.useState(null),[i,u]=d.useState(""),[c,x]=d.useState("annual-report"),h=d.useRef(null),{toast:g,push:m}=Kd(),f=Is(),p=d.useMemo(()=>{const w=f?.user;if(!w||typeof w!="object")return null;const j=w.user_metadata||{},D=w.profile||{},P=j.avatar_url||j.picture||D.avatar_url||w.avatar_url;return typeof P=="string"&&P.trim()?P.trim():null},[f?.user]);d.useEffect(()=>{t&&(o(null),u(r?.handle||""))},[t,r?.handle]);const k=r&&{...r,handle:i||r.handle,avatarUrl:p},{width:y,height:v}=yn(c),_=Wd/y;d.useEffect(()=>{if(!t)return;const w=j=>{j.key==="Escape"&&a?.()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,a]);const A=d.useCallback(async()=>{const w=h.current;if(!w)return null;try{return await xd(w)}catch(j){return console.warn("[share] capture failed",j),null}},[]),T=d.useCallback(async()=>{if(n)return;o("copy");const w=await A();if(!w){m(l("share.toast.failed"),"error"),o(null);return}let j=!1;if(ga()){const D=await nr(w);D&&(j=(await dd(D)).ok)}else j=await Ur(w);m(j?l("share.toast.copied"):l("share.toast.failed"),j?"success":"error"),o(null)},[n,A,m]),M=d.useCallback(()=>`tokentracker-share-${Date.now()}.png`,[]),L=d.useCallback(async()=>{if(n)return;o("download");const w=await A();if(!w){m(l("share.toast.failed"),"error"),o(null);return}if(ga()){const D=await nr(w);if(D&&(await _s(D,M())).ok){m(l("share.toast.downloaded"),"success"),o(null);return}}const j=vs(w,M());m(j?l("share.toast.downloaded"):l("share.toast.failed"),j?"success":"error"),o(null)},[n,A,M,m]),U=d.useCallback(async()=>{if(n)return;o("x");const w=await A();if(!w){m(l("share.toast.failed"),"error"),o(null);return}if(ga()){const O=await nr(w);O&&(await _s(O,M()),m(l("share.toast.downloaded"),"success"))}else await Ur(w)?m(l("share.toast.copied"),"success"):vs(w,M());const j=new URL("https://twitter.com/intent/tweet");s&&j.searchParams.set("text",s);const D=f?.user?.id,P=typeof D=="string"&&D?`/u/${D}`:"/";if(j.searchParams.set("url",`https://www.tokentracker.cc${P}?ref=share`),ga())try{window.webkit?.messageHandlers?.nativeBridge?.postMessage({type:"action",name:"openURL",value:j.toString()})}catch{window.open(j.toString(),"_blank","noopener,noreferrer")}else window.open(j.toString(),"_blank","noopener,noreferrer");o(null)},[n,A,m,s,M,f]);return t?e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":l("share.modal.title"),"data-screenshot-exclude":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6",style:{background:"rgba(10,10,10,0.72)"},onClick:w=>{w.target===w.currentTarget&&a?.()},children:[e.jsx("div",{"aria-hidden":!0,style:{position:"fixed",left:0,top:0,width:y,height:v,pointerEvents:"none",opacity:0,zIndex:-1,clip:"rect(0,0,0,0)",overflow:"hidden"},children:e.jsx(Ss,{ref:h,data:k,variant:c})}),e.jsxs(_e.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},transition:{duration:.18,ease:[.2,.8,.2,1]},className:"relative w-full max-w-[1040px] max-h-[92vh] overflow-hidden rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-black shadow-oai-lg",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row max-h-[92vh]",children:[e.jsx("div",{className:"flex-1 min-w-0 p-4 sm:p-7 bg-oai-gray-50 dark:bg-oai-gray-950 flex items-center justify-center overflow-auto",children:e.jsxs("div",{style:{width:y*_,height:v*_,flexShrink:0,position:"relative"},className:"rounded-xl overflow-hidden shadow-oai-md ring-1 ring-black/5",children:[n?e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-black/50",children:e.jsxs("svg",{className:"animate-spin h-6 w-6 text-oai-gray-500",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):null,e.jsx("div",{style:{width:y,height:v,transform:`scale(${_})`,transformOrigin:"top left"},children:e.jsx(Ss,{data:k,variant:c})})]})}),e.jsxs("div",{className:"w-full lg:w-[340px] flex-shrink-0 border-t lg:border-t-0 lg:border-l border-oai-gray-200 dark:border-oai-gray-800 p-5 sm:p-6 flex flex-col gap-5 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-oai-white",children:l("share.modal.title")}),e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:l("share.modal.subtitle")})]}),e.jsx("button",{type:"button",onClick:a,"aria-label":l("share.modal.close"),className:"p-1.5 -mt-1 -mr-1 rounded-md text-oai-gray-500 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"share-handle",className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:l("share.modal.name_label")}),e.jsx("input",{id:"share-handle",type:"text",value:i,onChange:w=>u(w.target.value),placeholder:l("share.modal.name_placeholder"),className:"w-full px-3 py-2 text-sm rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white placeholder:text-oai-gray-400 dark:placeholder:text-oai-gray-600 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-oai-brand transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:l("share.modal.style_label")}),e.jsx("div",{className:"flex gap-2",children:pn.map(w=>e.jsx("button",{type:"button",onClick:()=>x(w.id),className:["flex-1 px-3 py-2 text-sm rounded-lg border transition-colors",c===w.id?"border-oai-black dark:border-oai-white bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white font-medium":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:border-oai-gray-400 dark:hover:border-oai-gray-600"].join(" "),children:Vd(w.id)},w.id))})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[e.jsxs(lr,{onClick:U,disabled:!!n,emphasis:!0,children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),e.jsx("span",{className:"font-medium text-sm",children:l("share.modal.action.x")})]}),e.jsx("span",{className:"text-[11px] opacity-70",children:n==="x"?l("share.toast.working"):l("share.modal.hint.x")})]}),e.jsxs(lr,{onClick:L,disabled:!!n,children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),e.jsx("span",{className:"font-medium text-sm",children:l("share.modal.action.download")})]}),e.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:"PNG"})]}),e.jsxs(lr,{onClick:T,disabled:!!n,children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),e.jsx("span",{className:"font-medium text-sm",children:l("share.modal.action.copy")})]}),e.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:l("share.modal.hint.copy")})]})]}),e.jsx("div",{className:"mt-auto pt-4 border-t border-oai-gray-200 dark:border-oai-gray-800",children:e.jsx("p",{className:"text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:l("share.modal.footer")})})]})]}),e.jsx(br,{children:g?e.jsx(_e.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},className:"pointer-events-none absolute left-1/2 bottom-4 -translate-x-1/2",children:e.jsx("div",{className:["px-4 py-2 rounded-full text-xs font-medium shadow-oai-md",g.kind==="error"?"bg-red-600 text-white":g.kind==="success"?"bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black":"bg-oai-gray-800 text-white"].join(" "),children:g.text})},g.id):null})]})]}):null}function qd(t){const{enabled:a,handle:r,startDate:s,activeDays:n,summary:o,topModels:i,period:u,periodFrom:c,periodTo:x,heatmap:h,accessToken:g,userId:m,currency:f,exchangeRate:p}=t,[k,y]=d.useState(null),v=p;return d.useEffect(()=>{if(!a||!m&&!ct())return;let _=!1;return(async()=>{try{const T=await Yo({accessToken:g,userId:m,period:u==="day"||u==="custom"?"week":u,metric:"all",limit:100,offset:0});if(_)return;const L=(Array.isArray(T?.entries)?T.entries:Array.isArray(T)?T:[]).find(w=>w?.is_me===!0),U=typeof L?.rank=="number"?L.rank:null;y(U)}catch{_||y(null)}})(),()=>{_=!0}},[a,g,m,u]),d.useMemo(()=>pd({handle:r,startDate:s,activeDays:n,summary:o,topModels:i,rank:k,period:u,periodFrom:c,periodTo:x,heatmap:h,currency:f,exchangeRate:typeof v=="number"?v:void 0}),[r,s,n,o,i,k,u,c,x,h,f,v])}const Yd=["day","week","month","total","custom"],cr=new Set(["day","hour","month"]),Bt=new Set(["day","total","custom"]),Zd=["macAppBanner","statsPanel","widgetOnboarding","installCopy","activityHeatmap","deviceUsage","trendMonitor","qualityPerDollar","sessionInsights"],Jd=["usageOverview","dataDetails"];function dr(t,a){if(typeof a=="number"&&a>0)return!0;if(typeof t=="bigint")return t>0n;if(typeof t=="number")return Number.isFinite(t)&&t>0;if(typeof t=="string"){const r=t.trim();if(!r)return!1;if(/^[0-9]+$/.test(r))try{return BigInt(r)>0n}catch{return!1}const s=Number(r);return Number.isFinite(s)&&s>0}return!1}function fa(t){return t?jt(t,null):null}function Cs(t){return t?t?.billable_total_tokens??t?.value??t?.total_tokens:null}function Qd(t){return t?t==="www.tokentracker.cc"||t==="tokentracker.cc":!1}function Xd(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search),a=String(t.get("force_install")||"").toLowerCase();return a!=="1"&&a!=="true"?!1:!Qd(window.location.hostname)}function Su({baseUrl:t,auth:a,signedIn:r,sessionSoftExpired:s,signOut:n,publicMode:o=!1,publicToken:i=null,signInUrl:u="/sign-in",signUpUrl:c="/sign-up",onMainContentVisible:x}){const{resolvedLocale:h}=Zo(),{currency:g,rate:m}=Sa(),{mode:f,setMode:p,formatTokens:k,formatTokensTooltip:y}=Fe(),[v,_]=d.useState(!1),[A,T]=d.useState(null),[M,L]=d.useState(null),[U,w]=d.useState(!1),[j,D]=d.useState(null),[P,O]=d.useState(0),[V,E]=d.useState(0),[R,q]=d.useState(null),N=d.useMemo(()=>typeof window>"u"?!1:Jo(window.location.search),[]),S=d.useMemo(()=>Xd(),[]),[Y,H]=d.useState(!1),ce=2200,[J,de]=d.useState(!0),[oe,he]=d.useState(!1),[ye,ue]=d.useState(!1),[ee,Q]=d.useState(!1),[B,X]=d.useState(!1),xe=d.useRef(!1),W=ct(),C=r&&!s,z=d.useMemo(()=>C&&(typeof a=="function"||typeof a=="string"||a&&typeof a=="object")?a:null,[a,C]),F=C?z:null,K=o?Qo(i):F,se=r||W||o,we=C&&Ot(F),ve=r&&s&&!o,{accountView:Le,revision:Se,resolving:Ht}=Xo(),ie=Le&&!o,$e=ie?F:null,ze=Ht&&!o;d.useEffect(()=>{if(!r||W){T(null),L(null),w(!1),D(null);return}if(o)return;if(!we){T(null),L(null),w(!1),D(null);return}let b=!0;const $=()=>{T(null),L(null),w(!1),D(null)};return w(!0),D(null),(async()=>{let I=null;try{I=await Ie(F)}catch{I=null}if(b){if(!I){$();return}try{const G={link_code:null,expires_at:null};if(!b)return;T(typeof G?.link_code=="string"?G.link_code:null),L(typeof G?.expires_at=="string"?G.expires_at:null)}catch(G){if(!b)return;T(null),L(null),D(G?.message||"Failed to load link code")}finally{if(!b)return;w(!1)}}})(),()=>{b=!1}},[t,W,r,o,we,F,V]);const je=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");d.useEffect(()=>{if(!je&&(!r||W||o)){q(null);return}if(!je&&!we){q(null);return}let b=!0;return(async()=>{let $=null;try{$=await Ie(F)}catch{$=null}if(b){if(!$&&!je){q(null);return}try{const I=await ei({baseUrl:t,accessToken:$});if(!b)return;q(I&&typeof I=="object"?I:null)}catch{if(!b)return;q(null)}}})(),()=>{b=!1}},[we,t,F,W,o,r]);const Ct=d.useMemo(()=>{if(!M)return!1;const b=Date.parse(M);if(!Number.isFinite(b))return!1;const $=P||Date.now();return b<=$},[M,P]);d.useEffect(()=>{!r||W||o||!M||!Ct||U||(T(null),L(null),D(null),E(b=>b+1))},[Ct,M,U,W,r]),d.useEffect(()=>{if(!M||o)return;const b=Date.parse(M);if(!Number.isFinite(b))return;const $=Date.now();if(O($),b<=$)return;const I=window.setTimeout(()=>O(Date.now()),b-$),G=()=>{typeof document>"u"||document.visibilityState==="visible"&&O(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",G),window.addEventListener("focus",G),()=>{window.clearTimeout(I),typeof document<"u"&&document.removeEventListener("visibilitychange",G),window.removeEventListener("focus",G)}},[M]);const ge=d.useMemo(()=>Rs(),[]),fe=d.useMemo(()=>Es(),[]),Me=d.useMemo(()=>ti(),[]),Oe=o?null:a?.userId||a?.email||"default",[Tt,dt]=d.useState("month"),[Ue,Ca]=d.useState(null),[Je,Ta]=d.useState(null),[Da,ut]=d.useState(!1),Z=N?"total":Tt,Vt=d.useMemo(()=>Z==="custom"&&Ue&&Je?{from:Ue,to:Je}:ai(Z,{timeZone:ge,offsetMinutes:fe,now:Me}),[Me,Z,ge,fe,Ue,Je]),be=Vt.from,ke=Vt.to,[Ee,mt]=d.useState(null),{devices:Wt,accountSources:Dt,refresh:Aa}=id({from:be,to:ke,timeZone:ge,tzOffsetMinutes:fe,accountView:ie,accountAccessToken:$e,accountRevision:Se}),He=d.useMemo(()=>Wt.filter(b=>(Number(b.total_tokens)||0)>0),[Wt]),Kt=d.useMemo(()=>Dt.filter(b=>(Number(b.total_tokens)||0)>0),[Dt]),tt=ie&&He.length>=2,At=ie&&He.length+Kt.length>=2;d.useEffect(()=>{if(!tt&&!At){Ee!==null&&mt(null);return}Ee&&!He.some(b=>b.id===Ee)&&mt(null)},[tt,At,He,Ee]);const Gt=d.useMemo(()=>tt?[{value:"",label:l("dashboard.device_filter.all")},...He.map(b=>({value:b.id,label:ur(b)||l("dashboard.device_card.unnamed")}))]:[],[tt,He,h]),La=At?e.jsx(cd,{devices:He,accountSources:Kt,selectedDeviceId:Ee||"",onSelectDevice:b=>mt(b||null),onRenameDevice:async(b,$)=>{const I=await Ie($e);await li({deviceId:b,name:$,accessToken:I}),await Aa()}}):null,qt=d.useMemo(()=>ri({timeZone:ge,offsetMinutes:fe}),[ge,fe]),ht=d.useMemo(()=>si({timeZone:ge,offsetMinutes:fe}),[ge,fe]),Ma=d.useMemo(()=>`Local time (${ht})`,[ht]),Lt=ge,Mt=fe,Ea=qt,at=d.useMemo(()=>pr({timeZone:ge,offsetMinutes:fe,date:Me||new Date}),[Me,ge,fe]),Yt=d.useMemo(()=>zl({period:Z,selectedFrom:be,selectedTo:ke,todayKey:at}),[be,Z,ke,at]),{daily:Ve,summary:me,rolling:Ra,source:Zt,loading:Jt,error:Qt,refresh:Xt}=Yr({baseUrl:t,accessToken:K,guestAllowed:ve,from:be,to:ke,includeDaily:Z!=="total",cacheKey:Oe,timeZone:ge,tzOffsetMinutes:fe,now:Me,accountView:ie,accountAccessToken:$e,accountRevision:Se,accountViewResolving:ze,deviceId:Ee}),{daily:ea,loading:ne,refresh:ae}=Yr({baseUrl:t,accessToken:K,guestAllowed:ve,from:Yt.from,to:Yt.to,includeDaily:!0,includeSummary:!1,cacheKey:Oe?`${Oe}.daily-breakdown`:"daily-breakdown",timeZone:ge,tzOffsetMinutes:fe,now:Me,accountView:ie,accountAccessToken:$e,accountRevision:Se,accountViewResolving:ze}),{breakdown:le,loading:Qe,refresh:Ke}=kl({baseUrl:t,accessToken:K,guestAllowed:ve,from:be,to:ke,cacheKey:Oe,timeZone:ge,tzOffsetMinutes:fe,accountView:ie,accountAccessToken:$e,accountRevision:Se,accountViewResolving:ze,deviceId:Ee}),[Et,bn]=d.useState(3),{entries:kn,loading:wn,refresh:kr}=pl({baseUrl:t,accessToken:K,from:be,to:ke,timeZone:ge,tzOffsetMinutes:fe}),wr=Z==="week"||Z==="month",ta=Z==="week"||Z==="month",_r=d.useMemo(()=>Ve.filter(b=>b?.future?!1:!b?.day||!at?!0:String(b.day)<=String(at)),[Ve,at]),{rows:Ge,from:_n,to:vn,loading:jn,refresh:vr}=wi({baseUrl:t,accessToken:K,guestAllowed:ve,period:Z,from:be,to:ke,months:24,cacheKey:Oe,timeZone:Lt,tzOffsetMinutes:Mt,now:Me,sharedRows:wr?Ve:null,sharedRange:wr?{from:be,to:ke}:null,accountView:ie,accountAccessToken:$e,accountRevision:Se,accountViewResolving:ze,deviceId:Ee}),Nn=d.useMemo(()=>({baseUrl:t,accessToken:K,guestAllowed:ve,cacheKey:Oe,timeZone:Lt,tzOffsetMinutes:Mt,now:Me,accountView:ie,accountAccessToken:$e,accountRevision:Se,accountViewResolving:ze}),[t,K,ve,Oe,Lt,Mt,Me,ie,$e,Se,ze]),{daily:xt,heatmap:We,loading:jr,refresh:Nr}=ml({baseUrl:t,accessToken:K,guestAllowed:ve,weeks:52,cacheKey:Oe,timeZone:ge,tzOffsetMinutes:fe,now:Me,accountView:ie,accountAccessToken:$e,accountRevision:Se,accountViewResolving:ze,deviceId:Ee}),{data:aa,refresh:Sr}=_i();d.useEffect(()=>{aa&&typeof aa=="object"&&ni(aa)},[aa]);const Pe=d.useMemo(()=>Z==="day"?"hour":Z==="total"?"month":"day",[Z]),Sn=d.useMemo(()=>Jr(Pe),[Pe]),ra="day",Cn=d.useMemo(()=>Jr(ra),[]),[Be,Cr]=d.useState(()=>({key:"day",dir:"desc"}));d.useEffect(()=>{Cr(b=>!cr.has(b.key)||b.key===Pe?b:{key:Pe,dir:b.dir})},[Pe]);const gt=d.useMemo(()=>cr.has(Be.key)&&Be.key!==Pe?{...Be,key:Pe}:Be,[Pe,Be]),sa=d.useMemo(()=>{if(Z==="day")return Array.isArray(Ge)?Ge.filter(I=>I?.hour&&!I?.future):[];if(Z==="total"){const I=Array.isArray(Ge)?Ge.filter(G=>G?.month&&!G?.future):[];return El(I)}const b=_r;return!b.some(I=>!I?.missing&&!I?.future)&&Ve.length>0?Ve.filter(I=>!I?.future).slice(-30).filter(I=>I?.day):b},[Z,Ge,_r,Ve]),Rt=d.useMemo(()=>Qr(sa,gt),[sa,gt]),Tr=d.useMemo(()=>sa.some(b=>!b?.missing&&!b?.future),[sa]),Ia=d.useMemo(()=>{if(!Bt.has(Z))return 1;const b=Math.ceil(Rt.length/wa);return b>0?b:1},[Z,Rt.length]),[Fa,na]=d.useState(0);d.useEffect(()=>{if(!Bt.has(Z)){na(0);return}na(b=>Math.min(b,Ia-1))},[Ia,Z]),d.useEffect(()=>{Bt.has(Z)&&na(0)},[Z,Be.dir,Be.key]);const Tn=d.useMemo(()=>Bt.has(Z)?Rl(Rt,Fa,wa):Rt,[Fa,Z,Rt]),Dr=d.useMemo(()=>Ol(ea,{period:Z}),[ea,Z]),ft=d.useMemo(()=>cr.has(Be.key)?{...Be,key:ra}:Be,[Be]),Dn=d.useMemo(()=>Qr(Dr,ft),[Dr,ft]),An=d.useMemo(()=>ta?Ve:Z==="day"?Array.isArray(Ge)?Ge.filter(b=>b?.hour):[]:Ge,[Ve,Z,Ge,ta]),Ln=ta?be:_n,Mn=ta?ke:vn;function En(b,$){if(b?.future)return"—";if(b?.missing)return l("shared.status.unsynced");if($.endsWith("_tokens")){const I=$==="total_tokens"?fa(b):b?.[$];return e.jsx("span",{title:y(I),children:k(I)})}return ka(b?.[$])}function Rn(b){const $=b?.[Pe];if($==null)return"";const I=String($);if(Pe==="hour"){const[G,Te]=I.split("T");if(G&&Te)return`${G} ${Te.slice(0,5)}`}return I}function In(b){const $=b?.[ra];return $==null?"":String($)}function Fn(b){Cr($=>$.key===b?{key:b,dir:$.dir==="asc"?"desc":"asc"}:{key:b,dir:"desc"})}function $n(b){return gt.key!==b?"none":gt.dir==="asc"?"ascending":"descending"}function Pn(b){return gt.key!==b?"":gt.dir==="asc"?"▲":"▼"}function Bn(b){return ft.key!==b?"none":ft.dir==="asc"?"ascending":"descending"}function zn(b){return ft.key!==b?"":ft.dir==="asc"?"▲":"▼"}const $a=d.useMemo(()=>{if(!r&&!W&&!o&&!je)return 0;const b=Number(We?.active_days);if(Number.isFinite(b))return b;let $=0;const I=new Set,G=(pe,Re,De)=>{typeof pe!="string"||!pe||I.has(pe)||dr(Re,De)&&(I.add(pe),$+=1)};if(Array.isArray(xt))for(const pe of xt)G(pe?.day,fa(pe));const Te=Array.isArray(We?.weeks)?We.weeks:[];for(const pe of Te)for(const Re of Array.isArray(pe)?pe:[]){const De=Cs(Re);G(Re?.day,De,Re?.level)}return $},[r,W,We?.active_days,We?.weeks,xt]),[Ar,Lr]=d.useState("month"),On=d.useCallback(b=>{b==="custom"?(Lr($=>$==="custom"?"month":$),dt($=>Ue&&Je?"custom":$),ut(!0)):(dt(b),Lr(b),ut(!1))},[Ue,Je]),Un=d.useCallback((b,$)=>{Ca(b),Ta($),dt("custom"),ut(!1)},[]),Hn=d.useCallback(b=>{ut(b),!b&&Tt==="custom"&&!Ue&&dt(Ar)},[Tt,Ue,Ar]),pt=d.useCallback(async()=>{ie&&oi(),ie||ii(),await Promise.all([Xt(),Nr(),vr(),Ke(),kr(),ae()])},[ie,ae,Nr,Ke,kr,vr,Xt]),Mr=d.useCallback(async()=>{await Promise.all([pt(),Sr()])},[pt,Sr]),Pa=d.useRef(null);d.useEffect(()=>{if(!je||W||ie)return;Pa.current||(Pa.current=Hr({auto:!0,background:!0,allLocalSources:!0}));let b=!0;return Pa.current.then(()=>{if(b)return pt()}).catch($=>{b&&console.warn("[DashboardPage] Reload sync failed:",$)}),()=>{b=!1}},[je,W,ie,pt]),d.useEffect(()=>{if(!je||W||ie)return;const b=Pl({refresh:pt,onError:$=>console.warn("[DashboardPage] Automatic usage refresh failed:",$)});return()=>b.stop()},[je,W,ie,pt]);const Vn=d.useCallback(async()=>{Q(!0);try{je&&await Hr(),await Mr()}catch(b){console.error("[DashboardPage] Refresh failed:",b)}finally{Q(!1)}},[je,Mr]),oa=ee||Jt||ne||jr||jn||Qe||wn,Ba=!B&&(ze||ie&&oa&&!Tr),Wn=d.useMemo(()=>l("shared.data_source",{source:String(Zt||"edge").toUpperCase()}),[Zt,h]),ia=d.useMemo(()=>typeof a?.name!="string"?"":a.name.trim(),[a?.name]),Kn="",Er=d.useMemo(()=>!ia||ia.includes("@")?l("dashboard.identity.fallback"):ia,[ia]),Rr=d.useMemo(()=>Er.replace(/[^a-zA-Z0-9._-]/g,"_"),[Er]),Ir=d.useMemo(()=>o?l("dashboard.identity.fallback"):Rr,[Rr,Kn,o]),Fr=d.useMemo(()=>{let b=null;const $=G=>{typeof G!="string"||!G||(!b||G<b)&&(b=G)};if(Array.isArray(xt))for(const G of xt)G?.day&&dr(fa(G))&&$(G.day);const I=Array.isArray(We?.weeks)?We.weeks:[];for(const G of I)for(const Te of Array.isArray(G)?G:[]){if(!Te?.day)continue;const pe=Cs(Te),Re=Te?.level;dr(pe,Re)&&$(Te.day)}return b},[We?.weeks,xt]),Gn=d.useMemo(()=>o?[]:(Array.isArray(R?.subscriptions?.items)?R.subscriptions.items:[]).map(I=>{const G=typeof I?.tool=="string"?I.tool.trim():"",pe=(typeof I?.plan_type=="string"?I.plan_type:typeof I?.planType=="string"?I.planType:"").trim();return!G||!pe?null:{tool:G,planType:pe,provider:typeof I?.provider=="string"?I.provider.trim():"",product:typeof I?.product=="string"?I.product.trim():"",rateLimitTier:typeof I?.rate_limit_tier=="string"?I.rate_limit_tier.trim():typeof I?.rateLimitTier=="string"?I.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[o,R]),qn=e.jsx(vi,{heatmap:We,timeZoneLabel:qt,timeZoneShortLabel:ht,hideLegend:N,defaultToLatestMonth:N}),Yn=d.useMemo(()=>`${be}..${ke}`,[be,Z,ke]),Zn=l("usage.summary.total"),Ce=me!=null,yt=Ce?fa(me):0,Jn=k(yt),Qn=d.useCallback(()=>{p(f===pa.COMPACT?pa.FULL:pa.COMPACT)},[p,f]),Xn=l("dashboard.core_index.collapse_label"),eo=l("dashboard.core_index.expand_label"),to=l("dashboard.core_index.collapse_aria"),ao=l("dashboard.core_index.expand_aria"),ro=!N,bt=l("shared.placeholder.short"),za=d.useMemo(()=>{const b=Array.isArray(le?.sources)?le.sources:[];let $=null,I=0;for(const Re of b){const De=jt(Re?.totals);!Number.isFinite(De)||De<=0||De>I&&(I=De,$=Re)}let G=bt,Te=bt,pe="0.0";if($&&I>0){G=$?.source?String($.source).toUpperCase():bt;const Re=Array.isArray($?.models)?$.models:[];let De=0;for(const Ka of Re){const ca=jt(Ka?.totals);!Number.isFinite(ca)||ca<=0||ca>De&&(De=ca,Te=Ka?.model?String(Ka.model):bt)}De>0&&(pe=(De/I*100).toFixed(1))}return{agentName:G,modelName:Te,modelPercent:pe}},[le,bt]),Oa=ka(yt),so=l("dashboard.screenshot.twitter_text",{total_tokens:Oa==="-"?bt:Oa,agent_name:za.agentName,model_name:za.modelName,model_percent:za.modelPercent}),no=d.useMemo(()=>N?[]:Yd,[N]),oo=d.useMemo(()=>[{label:l("usage.metric.total"),value:Ce?k(yt):"—",title:Ce?y(yt):void 0,valueClassName:"text-white"},{label:l("usage.metric.input"),value:Ce?k(me?.input_tokens):"—",title:Ce?y(me?.input_tokens):void 0},{label:l("usage.metric.output"),value:Ce?k(me?.output_tokens):"—",title:Ce?y(me?.output_tokens):void 0},{label:l("usage.metric.cached_input"),value:Ce?k(me?.cached_input_tokens):"—",title:Ce?y(me?.cached_input_tokens):void 0},{label:l("usage.metric.reasoning_output"),value:Ce?k(me?.reasoning_output_tokens):"—",title:Ce?y(me?.reasoning_output_tokens):void 0}],[me?.cached_input_tokens,me?.input_tokens,me?.output_tokens,me?.reasoning_output_tokens,yt,Ce,k,y]),Ua=d.useMemo(()=>Na(me?.total_cost_usd,{currency:g,rate:m}),[me?.total_cost_usd,g,m]),io=d.useMemo(()=>me?.conversation_count??null,[me?.conversation_count]),$r=d.useMemo(()=>Hl(le,{copyFn:l}),[le]),Pr=d.useMemo(()=>Vl(le,{limit:3,copyFn:l}),[le]),lo=qd({enabled:Y,handle:Ir,startDate:Fr,activeDays:$a,summary:me,topModels:Pr,period:Z,periodFrom:be,periodTo:ke,heatmap:We,accessToken:typeof K=="string"?K:null,userId:a?.userId||null,currency:g,exchangeRate:m}),co=d.useCallback(()=>H(!0),[]),uo=d.useCallback(()=>H(!1),[]),mo=d.useCallback(()=>_(!0),[]),ho=d.useCallback(()=>_(!1),[]),xo=Ua&&Ua!=="-"&&$r.length>0,It=l("dashboard.install.cmd.init"),Ha=Ct?null:A,Va=Ha?l("dashboard.install.cmd.init_link_code",{link_code:Ha}):It,go=It,fo=l("dashboard.install.cmd.sync"),po=Ha?l("dashboard.install.copy"):l("dashboard.install.copy_base"),yo=l("dashboard.install.copied");l("dashboard.session_expired.copy_label"),l("dashboard.session_expired.copied");const bo=!!(R?.install?.has_active_device_token??R?.install?.hasActiveDeviceToken),ko=Il({publicMode:o,screenshotMode:N,forceInstall:S,accessEnabled:se,heatmapLoading:jr,activeDays:$a,hasActiveDeviceToken:bo}),wo=l("dashboard.install.prompt"),_o=d.useCallback(async()=>{!Va||!await Vr(Va)||(he(!0),window.setTimeout(()=>he(!1),2e3))},[Va]);d.useCallback(async()=>{!It||!await Vr(It)||(ue(!0),window.setTimeout(()=>ue(!1),2e3))},[It]);const Wa=d.useMemo(()=>l("dashboard.daily.empty",{cmd:"{{cmd}}"}),[h]),[vo,jo]=d.useMemo(()=>{const b=Wa.split("{{cmd}}");return b.length===1?[Wa,""]:[b[0],b.slice(1).join("{{cmd}}")]},[Wa]),Ft=s&&!o,$t=!r&&!W&&!s&&!je&&!o;d.useEffect(()=>{Ft||$t||Ba||X(!0)},[Ba,$t,Ft]);const la=gl(Zd,Jd);return d.useEffect(()=>{xe.current||Ft||$t||oa||(xe.current=!0,x?.())},[x,$t,Ft,oa]),e.jsxs(e.Fragment,{children:[e.jsx(od,{copy:l,onOpenShare:co,screenshotMode:N,showExpiredGate:Ft,showAuthGate:$t,identityDisplayName:Ir,identityStartDate:Fr,activeDays:$a,identitySubscriptions:Gn,identityScrambleDurationMs:ce,projectUsageEntries:kn,projectUsageLimit:Et,setProjectUsageLimit:bn,projectDetailQuery:{from:be,to:ke,timeZone:ge,tzOffsetMinutes:fe},topModels:Pr,signedIn:r,publicMode:o,isLocalMode:je,shouldShowInstall:ko,installPrompt:wo,handleCopyInstall:_o,installCopied:oe,installCopiedLabel:yo,installCopyLabel:po,installInitCmdDisplay:go,linkCodeLoading:U,linkCodeError:j,trendRowsForDisplay:An,trendFromForDisplay:Ln,trendToForDisplay:Mn,trendZoomConfig:Nn,usageFrom:be,usageTo:ke,period:Z,trendTimeZoneLabel:Ea,activityHeatmapBlock:qn,periodsForDisplay:no,setSelectedPeriod:On,customFrom:Ue,customTo:Je,onCustomRangeApply:Un,customRangeOpen:Da,onCustomRangeOpenChange:Hn,metricsRows:oo,summaryLabel:Zn,summaryValue:Jn,hasSummary:Ce,summaryLoading:Jt,providersLoading:Qe,summaryFullValue:Oa,onToggleSummaryFormat:Qn,summaryTotalTokensRaw:re(yt)||0,summaryCostValue:Ua,summaryConversationsValue:io,rollingUsage:Ra,costInfoEnabled:xo,openCostModal:mo,allowBreakdownToggle:ro,coreIndexCollapsed:J,setCoreIndexCollapsed:de,coreIndexCollapseLabel:Xn,coreIndexExpandLabel:eo,coreIndexCollapseAria:to,coreIndexExpandAria:ao,refreshAll:Vn,usageLoadingState:oa,announceUsageLoading:ee,initialDashboardLoading:Ba,usageError:Qt,rangeLabel:Yn,timeZoneRangeLabel:Ma,usageSourceLabel:Wn,fleetData:$r,hasDetailsActual:Tr,dailyEmptyPrefix:vo,installSyncCmd:fo,dailyEmptySuffix:jo,detailsColumns:Sn,ariaSortFor:$n,toggleSort:Fn,sortIconFor:Pn,pagedDetails:Tn,dailyBreakdownRows:Dn,dailyBreakdownColumns:Cn,dailyBreakdownAriaSortFor:Bn,dailyBreakdownSortIconFor:zn,dailyBreakdownDateKey:ra,detailsDateKey:Pe,renderDetailDate:Rn,renderDailyBreakdownDate:In,renderDetailCell:En,DETAILS_PAGED_PERIODS:Bt,detailsPageCount:Ia,detailsPage:Fa,setDetailsPage:na,costModalOpen:v,closeCostModal:ho,deviceOptions:Gt,selectedDevice:Ee||"",onDeviceChange:b=>mt(b||null),deviceUsageBlock:La,leftCardOrder:la.left.order,onLeftReorder:la.left.reorder,rightCardOrder:la.right.order,onRightReorder:la.right.reorder}),e.jsx(Gd,{open:Y,onClose:uo,data:lo,twitterText:so})]})}export{Su as DashboardPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as p,r as c,j as e,h as b}from"./__vite-browser-external-
|
|
1
|
+
import{e as p,r as c,j as e,h as b}from"./__vite-browser-external-BoyaLR3G.js";const f={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_VERSION:"0.83.0",VITE_INSFORGE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3OC0xMjM0LTU2NzgtOTBhYi1jZGVmMTIzNDU2NzgiLCJlbWFpbCI6ImFub25AaW5zZm9yZ2UuY29tIiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODExNDU5NDd9.T0auta_IrVIh0uXW1bob5QSnzvsnJmN28r5XkSGEuQY",VITE_INSFORGE_BASE_URL:"https://srctyff5.us-east.insforge.app"};function x(){return b(),`${(f&&"https://srctyff5.us-east.insforge.app"||"https://srctyff5.us-east.insforge.app").replace(/\/$/,"")}/functions/tokentracker-device-flow-grant`}function l(a){return(a||"").toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9-]/g,"")}function k(){const a=p(),[m,u]=c.useState(""),[t,r]=c.useState({kind:"idle",message:""});c.useEffect(()=>{try{const i=new URLSearchParams(window.location.search).get("user_code");i&&u(l(i))}catch{}},[]);async function g(d){if(d?.preventDefault?.(),!a?.signedIn){r({kind:"error",message:"Please sign in first."});return}const i=l(m);if(!/^[A-HJKMNP-Z2-9]{4}-[A-HJKMNP-Z2-9]{4}$/.test(i)){r({kind:"error",message:"Invalid code format. Expected XXXX-XXXX."});return}r({kind:"working",message:"Approving…"});try{const n=await a.getAccessToken?.();if(!n){r({kind:"error",message:"No access token — please sign in again."});return}const s=await fetch(x(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({user_code:i})}),o=await s.json().catch(()=>({}));s.ok?r({kind:"success",message:o.status==="already_approved"?`Already approved earlier${o.client_info?" ("+o.client_info+")":""}.`:`Approved${o.client_info?" for "+o.client_info:""}. You can close this tab — your CLI will pick it up within a few seconds.`}):s.status===404?r({kind:"error",message:"Code not found. Double-check what your CLI printed."}):s.status===410?r({kind:"error",message:"Code expired. Re-run `tracker device-login` and try again."}):s.status===401?r({kind:"error",message:"Session expired. Sign out, sign in, and try again."}):r({kind:"error",message:o?.error||`Server error (HTTP ${s.status}).`})}catch(n){r({kind:"error",message:`Network error: ${n?.message||n}`})}}return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white dark:bg-oai-gray-950 px-6 py-12",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-8",children:[e.jsx("h1",{className:"text-2xl font-semibold text-oai-gray-900 dark:text-white mb-2",children:"Approve your CLI"}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mb-6",children:"Type the code your CLI showed you. We'll link it to your account so token usage from that machine flows into your leaderboard profile."}),a?.signedIn?null:e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-900/20 dark:border-amber-800 p-4 mb-4",children:e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:"Sign in first, then return to this page."})}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400 mb-1",children:"CLI code"}),e.jsx("input",{type:"text",value:m,onChange:d=>u(l(d.target.value)),placeholder:"XXXX-XXXX",spellCheck:!1,autoCapitalize:"characters",maxLength:9,className:"w-full font-mono text-xl tracking-widest text-center rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-900 dark:text-white px-4 py-3 focus:outline-none focus:ring-inset focus:ring-2 focus:ring-emerald-600"})]}),e.jsx("button",{type:"submit",disabled:t.kind==="working"||!a?.signedIn,className:"w-full rounded-md bg-emerald-600 hover:bg-emerald-500 disabled:bg-oai-gray-300 disabled:cursor-not-allowed text-white font-medium py-3 transition-colors",children:t.kind==="working"?"Approving…":"Approve"})]}),t.kind==="success"&&e.jsx("div",{className:"mt-4 rounded-md border border-emerald-200 bg-emerald-50 dark:bg-emerald-900/20 dark:border-emerald-800 p-4",children:e.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-300",children:t.message})}),t.kind==="error"&&e.jsx("div",{className:"mt-4 rounded-md border border-red-200 bg-red-50 dark:bg-red-900/20 dark:border-red-800 p-4",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:t.message})})]})})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,y as d,z as m,A as C,E as g}from"./__vite-browser-external-
|
|
1
|
+
import{r as p,y as d,z as m,A as C,E as g}from"./__vite-browser-external-BoyaLR3G.js";import{u as v}from"./DialogTitle-DS810PC0.js";const h=p.forwardRef(function(e,o){const{render:E,className:R,style:b,disabled:t=!1,nativeButton:n=!0,...a}=e,{store:s}=v(),r=s.useState("open"),{getButtonProps:l,buttonRef:i}=d({disabled:t,native:n}),u={disabled:t};function c(f){r&&s.setOpen(!1,C(g,f.nativeEvent))}return m("button",e,{state:u,ref:[o,i],props:[{onClick:c},a,l]})});export{h as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n,z as a}from"./__vite-browser-external-BoyaLR3G.js";import{u as p}from"./DialogTitle-DS810PC0.js";import{u as c}from"./useScrollLock-Bf0bCnKB.js";const x=n.forwardRef(function(e,r){const{render:l,className:u,style:m,id:s,...t}=e,{store:i}=p(),o=c(s);return i.useSyncedValueWithCleanup("descriptionElementId",o),a("p",e,{ref:r,props:[{id:o},t]})});export{x as D};
|