tokentracker-cli 0.21.3 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +457 -0
- package/README.ko.md +457 -0
- package/README.md +45 -6
- package/README.zh-CN.md +45 -6
- package/dashboard/dist/assets/{Card-Cv4wn6W8.js → Card-CD18G4Ge.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-DKY_Mi9v.js +64 -0
- package/dashboard/dist/assets/DevicePage-BkavlAal.js +1 -0
- package/dashboard/dist/assets/{FadeIn-DjQyRfLZ.js → FadeIn-CVNJ4aZy.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-D2BjLT1b.js → HeaderGithubStar-COu1Xy3I.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-D0uvbHPe.js → IpCheckPage-B2HjZ3vY.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-DGJcVAg7.js → LandingPage-9PSLFnys.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-Dnt_YLsP.js → LeaderboardPage-CQT5dBHU.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-DM7S9_kG.js → LeaderboardProfilePage-aPP-Raey.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-COomwRa6.js → LimitsPage-eFrAHmoA.js} +2 -2
- package/dashboard/dist/assets/{LoginPage-k0k50kws.js → LoginPage-CczTNZ_P.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-DctOj5-q.js → PopoverPopup-CEvWSWgZ.js} +2 -2
- package/dashboard/dist/assets/{ProviderIcon-DGlYzr9I.js → ProviderIcon-ewev19y3.js} +1 -1
- package/dashboard/dist/assets/SettingsPage-taBxq6ux.js +1 -0
- package/dashboard/dist/assets/SkillsPage-cqHO3rMB.js +1 -0
- package/dashboard/dist/assets/{WidgetsPage-DsMj8Qcz.js → WidgetsPage-B53b1hwG.js} +1 -1
- package/dashboard/dist/assets/WrappedPage-DwAhprTa.js +1 -0
- package/dashboard/dist/assets/check-JnFJsHgI.js +1 -0
- package/dashboard/dist/assets/{chevron-down-kcaroSaH.js → chevron-down-zOKEzHdv.js} +1 -1
- package/dashboard/dist/assets/{download-DKMK6oF8.js → download-BZZ4vKc1.js} +1 -1
- package/dashboard/dist/assets/{leaderboard-columns-BZ06dD2h.js → leaderboard-columns-BNGlMUsD.js} +1 -1
- package/dashboard/dist/assets/main-A_x5MMU-.css +1 -0
- package/dashboard/dist/assets/{main-DKVBnAOd.js → main-D0Irg9xR.js} +62 -17
- package/dashboard/dist/assets/{use-limits-display-prefs-Bx-K-27B.js → use-limits-display-prefs-BTuSZo27.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-DtuifRKC.js → use-native-settings-BPXVZrWe.js} +1 -1
- package/dashboard/dist/assets/{use-reduced-motion-Cen-UCKO.js → use-reduced-motion-HUOV_JD1.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-CAWz6ijv.js → use-usage-limits-G6-vCBcN.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +3 -2
- package/src/cli.js +11 -0
- package/src/commands/device-login.js +161 -0
- package/src/commands/status.js +199 -1
- package/src/commands/sync.js +85 -2
- package/src/commands/wrapped.js +150 -0
- package/src/lib/local-api.js +37 -2
- package/src/lib/passive-mode.js +185 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +913 -0
- package/src/lib/wrapped-aggregator.js +225 -0
- package/dashboard/dist/assets/DashboardPage-DsfcNgai.js +0 -1
- package/dashboard/dist/assets/SettingsPage-D2sqM9g_.js +0 -1
- package/dashboard/dist/assets/SkillsPage-B8K--edc.js +0 -1
- package/dashboard/dist/assets/main-DX38hz5f.css +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import{c as Kt,i as Mi,f as Jr,a as Zr,J as Ci,u as eo,m as Di,r as m,M as to,b as Ti,d as Ai,e as Yn,g as Oi,h as It,j as Xt,k as Pt,l as Ei,n as fa,o as bn,p as ba,q as Cn,s as Fi,t as Wi,v as Pi,w as ka,x as qt,y as zn,z as Ii,A as ze,B as h,C as o,D as no,X as ao,E as He,L as Li,F as $e,R as $,G as Dn,H as jn,I as $i,K as ro,N as oo,O as wa,P as Ri,Q as so,_ as io,S as ma,T as Bi,U as Yi,V as zi,W as Hi,Y as Ui,Z as qi,$ as Gi,a0 as Vi,a1 as Ki,a2 as Xi,a3 as dt,a4 as sr}from"./main-D0Irg9xR.js";import{u as Qi}from"./use-usage-limits-G6-vCBcN.js";import{I as va,u as Ji,a as Zi,b as el,c as tl,d as nl,D as al,e as rl,f as ol,g as sl,h as il,i as ll,C as cl,P as dl,j as ul,k as fl,l as ml,m as hl,L as gl}from"./PopoverPopup-CEvWSWgZ.js";import{C as _a}from"./Card-CD18G4Ge.js";import{u as Na}from"./use-reduced-motion-HUOV_JD1.js";import{P as lo}from"./ProviderIcon-ewev19y3.js";import{F as Yt}from"./FadeIn-CVNJ4aZy.js";const yl=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],pl=Kt("maximize-2",yl);const xl=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],bl=Kt("pause",xl);const kl=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],wl=Kt("play",kl);const vl=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],_l=Kt("rotate-ccw",vl);const Nl=[["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"}]],jl=Kt("square-arrow-out-up-right",Nl);const Sl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ml=Kt("terminal",Sl);function Cl(...e){const t=!Array.isArray(e[0]),n=t?0:-1,a=e[0+n],r=e[1+n],s=e[2+n],i=e[3+n],l=Mi(r,s,i);return t?l(a):l}function Dl(e,t,n={}){const a=e.get();let r=null,s=a,i;const l=typeof a=="string"?a.replace(/[\d.-]/g,""):void 0,c=()=>{r&&(r.stop(),r=null),e.animation=void 0},d=()=>{const u=ir(e.get()),y=ir(s);if(u===y){c();return}const g=r?r.getGeneratorVelocity():e.getVelocity();c(),r=new Ci({keyframes:[u,y],velocity:g,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:i})},f=()=>{d(),e.animation=r??void 0,e.events.animationStart?.notify(),r?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((u,y)=>{s=u,i=g=>y(Hn(g,l)),Jr.postRender(f)},c),Zr(t)){let u=n.skipInitialAnimation===!0;const y=t.on("change",x=>{u?(u=!1,e.jump(Hn(x,l),!1)):e.set(Hn(x,l))}),g=e.on("destroy",y);return()=>{y(),g()}}return c}function Hn(e,t){return t?e+t:e}function ir(e){return typeof e=="number"?e:parseFloat(e)}function ja(e){const t=eo(()=>Di(e)),{isStatic:n}=m.useContext(to);if(n){const[,a]=m.useState(e);m.useEffect(()=>t.on("change",a),[])}return t}function co(e,t){const n=ja(t()),a=()=>n.set(t());return a(),Ti(()=>{const r=()=>Jr.preRender(a,!1,!0),s=e.map(i=>i.on("change",r));return()=>{s.forEach(i=>i()),Ai(a)}}),n}function Tl(e){Yn.current=[],e();const t=co(Yn.current,e);return Yn.current=void 0,t}function uo(e,t,n,a){if(typeof e=="function")return Tl(e);const s=typeof t=="function"?t:Cl(t,n,a),i=Array.isArray(e)?lr(e,s):lr([e],([c])=>s(c)),l=Array.isArray(e)?void 0:e.accelerate;return l&&!l.isTransformed&&typeof t!="function"&&Array.isArray(n)&&a?.clamp!==!1&&(i.accelerate={...l,times:t,keyframes:n,isTransformed:!0}),i}function lr(e,t){const n=eo(()=>[]);return co(e,()=>{n.length=0;const a=e.length;for(let r=0;r<a;r++)n[r]=e[r].get();return t(n)})}function Al(e,t={}){const{isStatic:n}=m.useContext(to),a=()=>Zr(e)?e.get():e;if(n)return uo(a);const r=ja(a());return m.useInsertionEffect(()=>Dl(r,e,t),[r,JSON.stringify(t)]),r}function Ol(e,t={}){return Al(e,{type:"spring",...t})}function El({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:a=52,weekStartsOn:r="sun",cacheKey:s,timeZone:i,tzOffsetMinutes:l,now:c}={}){const d=m.useMemo(()=>Oi({weeks:a,weekStartsOn:r,now:c}),[c,a,r]),[f,u]=m.useState([]),[y,g]=m.useState(null),[x,p]=m.useState("edge"),[b,k]=m.useState(!1),[v,w]=m.useState(null),C=It(),D=Xt(t),S=!n,I=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=m.useMemo(()=>{if(!s)return null;const L=Cn({timeZone:i,offsetMinutes:l});return`tokentracker.heatmap.${s}.${a}.${r}.${L}`},[s,i,l,a,r]),O=m.useCallback(()=>{if(!N||typeof window>"u")return null;try{const L=window.localStorage.getItem(N);if(!L)return null;const B=JSON.parse(L);return!B||!B.heatmap?null:B}catch{return null}},[N]),E=m.useCallback(L=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(L))}catch{}},[N]),F=m.useCallback(()=>{if(!(!N||typeof window>"u"))try{window.localStorage.removeItem(N)}catch{}},[N]),Q=m.useCallback(async()=>{const L=await Pt(t);if(!(!L&&!C&&!I)){k(!0),w(null);try{try{const Y=await Ei({baseUrl:e,accessToken:L,weeks:a,to:d.to,weekStartsOn:r,timeZone:i,tzOffsetMinutes:l}),P=Array.isArray(Y?.weeks)?Y.weeks:[];if(!P.length&&S){const G=O();if(G?.heatmap){g(G.heatmap),u(G.daily||[]),p("cache");return}}if(!P.some(G=>(Array.isArray(G)?G:[]).some(de=>de&&Number.isFinite(Number(de.level))))&&P.length){const G=[];for(const W of P)for(const V of Array.isArray(W)?W:[])V?.day&&G.push({day:V.day,total_tokens:V.total_tokens??V.value??0,billable_total_tokens:V.billable_total_tokens??V.value??V.total_tokens??0});const de=fa({dailyRows:G,weeks:a,to:Y?.to||d.to,weekStartsOn:r});u(G),g({...de,week_starts_on:r,active_days:G.filter(W=>Number(W?.billable_total_tokens??W?.total_tokens)>0).length,streak_days:bn({dailyRows:G,to:Y?.to||d.to})}),p("client"),S?E({heatmap:{...de,week_starts_on:r,active_days:G.filter(W=>Number(W?.billable_total_tokens??W?.total_tokens)>0).length,streak_days:bn({dailyRows:G,to:Y?.to||d.to})},daily:G,fetchedAt:new Date().toISOString()}):F();return}g(Y||null),u([]),p("edge"),Y&&S?E({heatmap:Y,daily:[],fetchedAt:new Date().toISOString()}):S||F();return}catch(Y){const P=Y,z=P?.status??P?.statusCode;if(z===401||z===403)throw Y}const B=await ba({baseUrl:e,accessToken:L,from:d.from,to:d.to,timeZone:i,tzOffsetMinutes:l}),M=Array.isArray(B?.data)?B.data:[];u(M);const Z=fa({dailyRows:M,weeks:a,to:d.to,weekStartsOn:r});g({...Z,week_starts_on:r,active_days:M.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:bn({dailyRows:M,to:d.to})}),p("client"),S?E({heatmap:{...Z,week_starts_on:r,active_days:M.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:bn({dailyRows:M,to:d.to})},daily:M,fetchedAt:new Date().toISOString()}):F()}catch(B){if(S){const M=O();if(M?.heatmap)g(M.heatmap),u(M.daily||[]),p("cache"),w(null);else{const Z=B;w(Z?.message||String(Z)),u([]),g(null),p("edge")}}else{const M=B;w(M?.message||String(M)),u([]),g(null),p("edge")}}finally{k(!1)}}},[t,e,C,n,S,d.from,d.to,O,D,i,l,r,a,F,E,I]);return m.useEffect(()=>{if(!D&&!n&&!C&&!I){u([]),k(!1),w(null),g(null),p("edge");return}if(!S)F(),u([]),w(null),g(null),p("edge");else{const L=O();L?.heatmap&&(g(L.heatmap),u(L.daily||[]),p("cache"))}Q()},[t,C,O,Q,D,n,S,F,I]),{range:d,daily:f,heatmap:y,source:C?"mock":x==="client"?"edge":x,loading:b,error:v,refresh:Q}}function Fl({baseUrl:e,accessToken:t,limit:n=3,from:a,to:r,source:s,timeZone:i,tzOffsetMinutes:l}={}){const[c,d]=m.useState([]),[f,u]=m.useState(!1),[y,g]=m.useState(null),x=It(),p=Xt(t),b=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),k=m.useCallback(async()=>{const v=await Pt(t);if(!v&&!x&&!b){d([]),g(null),u(!1);return}u(!0),g(null);try{const w=await Fi({baseUrl:e,accessToken:v,limit:n,from:a,to:r,source:s,timeZone:i,tzOffsetMinutes:l});d(Array.isArray(w?.entries)?w.entries:[])}catch(w){const C=w?.message||String(w);g(C),d([])}finally{u(!1)}},[t,e,a,n,x,s,i,r,l,b]);return m.useEffect(()=>{if(!p&&!x&&!b){d([]),g(null),u(!1);return}k()},[x,k,p,b]),{entries:c,loading:f,error:y,refresh:k}}const Wl=24;function Pl({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:a,from:r,to:s,months:i=Wl,cacheKey:l,timeZone:c,tzOffsetMinutes:d,now:f,sharedRows:u,sharedRange:y}={}){const[g,x]=m.useState([]),[p,b]=m.useState(()=>({from:r,to:s})),[k,v]=m.useState("edge"),[w,C]=m.useState(null),[D,S]=m.useState(!1),[I,N]=m.useState(null),O=It(),E=Xt(t),F=!n,Q=Array.isArray(u),j=y?.from||r,L=y?.to||s,B=m.useMemo(()=>a==="day"?"hourly":a==="total"?"monthly":"daily",[a]),M=(()=>{if(!l)return null;const W=Il(e)||"default",V=Cn({timeZone:c,offsetMinutes:d});if(B==="hourly")return`tokentracker.trend.${l}.${W}.hourly.${s||r||"day"}.${V}`;if(B==="monthly")return`tokentracker.trend.${l}.${W}.monthly.${i}.${s||"today"}.${V}`;const ue=`${r||""}.${s||""}`;return`tokentracker.trend.${l}.${W}.daily.${ue}.${V}`})(),Z=m.useCallback(()=>{if(!M||typeof window>"u")return null;try{const W=window.localStorage.getItem(M);if(!W)return null;const V=JSON.parse(W);return!V||!Array.isArray(V.rows)?null:V}catch{return null}},[M]),Y=m.useCallback(W=>{if(!(!M||typeof window>"u"))try{window.localStorage.setItem(M,JSON.stringify(W))}catch{}},[M]),P=m.useCallback(()=>{if(!(!M||typeof window>"u"))try{window.localStorage.removeItem(M)}catch{}},[M]),z=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),G=m.useCallback(async()=>{if(Q){x(Array.isArray(u)?u:[]),b({from:j,to:L}),v("shared"),C(null),S(!1),N(null);return}const W=await Pt(t);if(!(!W&&!O&&!z)){S(!0),N(null);try{let V;B==="hourly"?V=await Wi({baseUrl:e,accessToken:W,day:s||r,timeZone:c,tzOffsetMinutes:d}):B==="monthly"?V=await Pi({baseUrl:e,accessToken:W,months:i,to:s,timeZone:c,tzOffsetMinutes:d}):V=await ba({baseUrl:e,accessToken:W,from:r,to:s,timeZone:c,tzOffsetMinutes:d});const ue=V?.from||r||V?.day||null,me=V?.to||s||V?.day||null;let T=Array.isArray(V?.data)?V.data:[];B==="daily"?T=qn(T,ue||r,me||s,{timeZone:c,offsetMinutes:d,now:f}):B==="hourly"?T=Gn(T,{timeZone:c,offsetMinutes:d,now:f}):B==="monthly"&&(T=Vn(T,{timeZone:c,offsetMinutes:d,now:f}));const oe=new Date().toISOString();x(T),b({from:ue,to:me}),v("edge"),C(oe),F?Y({rows:T,from:ue,to:me,mode:B,fetchedAt:oe}):P()}catch(V){if(F){const ue=Z();if(ue?.rows){let me=B==="daily"?qn(ue.rows||[],ue.from||r,ue.to||s,{timeZone:c,offsetMinutes:d,now:f}):Array.isArray(ue.rows)?ue.rows:[];B==="hourly"?me=Gn(me,{timeZone:c,offsetMinutes:d,now:f}):B==="monthly"&&(me=Vn(me,{timeZone:c,offsetMinutes:d,now:f})),x(me),b({from:ue.from||r,to:ue.to||s}),v("cache"),C(ue.fetchedAt||null),N(null)}else{x([]),b({from:r,to:s}),v("edge"),C(null);const me=V;N(me?.message||String(me))}}else{x([]),b({from:r,to:s}),v("edge"),C(null);const ue=V;N(ue?.message||String(ue))}}finally{S(!1)}}},[t,e,r,O,n,F,B,i,Z,E,Q,j,u,L,c,s,d,f,P,Y,z]);m.useEffect(()=>{if(Q){x(Array.isArray(u)?u:[]),b({from:j,to:L}),v("shared"),C(null),S(!1),N(null);return}if(!E&&!n&&!O&&!z){x([]),b({from:r,to:s}),N(null),S(!1),v("edge"),C(null);return}if(!F)P(),x([]),b({from:r,to:s}),N(null),v("edge"),C(null);else{const W=Z();if(W?.rows){let V=B==="daily"?qn(W.rows||[],W.from||r,W.to||s,{timeZone:c,offsetMinutes:d,now:f}):Array.isArray(W.rows)?W.rows:[];B==="hourly"?V=Gn(V,{timeZone:c,offsetMinutes:d,now:f}):B==="monthly"&&(V=Vn(V,{timeZone:c,offsetMinutes:d,now:f})),x(V),b({from:W.from||r,to:W.to||s}),v("cache"),C(W.fetchedAt||null)}}G()},[t,O,Z,G,Q,j,u,L,E,n,F,P,z]);const de=O?"mock":k;return{rows:g,from:p.from||r,to:p.to||s,source:de,fetchedAt:w,loading:D,error:I,refresh:G}}function Il(e){try{return new URL(e).host}catch{return null}}function Un(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const a=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const i=new Date(Date.UTC(a,r,s));return Number.isFinite(i.getTime())&&qt(i)===t?i:null}function Ll(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function qn(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const i=Un(t),l=Un(n);if(!i||!l||l<i)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,d=ka({timeZone:a,offsetMinutes:r,date:c}),f=Un(d),u=f?f.getTime():c.getTime(),y=new Map;for(const x of e||[])x?.day&&y.set(x.day,x);const g=[];for(let x=i;x<=l;x=Ll(x,1)){const p=qt(x),b=y.get(p),k=x.getTime()>u;if(b){g.push({...b,missing:!1,future:k});continue}g.push({day:p,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!k,future:k})}return g}function Gn(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=fo({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const i=s?.hour||s?.label||"",l=$l(i);if(!l)return{...s,future:!1};const c=l.dayNum>r.dayNum||l.dayNum===r.dayNum&&l.slot>r.slot;return{...s,future:c}}):e}function Vn(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=fo({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const i=s?.month||s?.label||"",l=Rl(i);if(!l)return{...s,future:!1};const c=l.year>r.year||l.year===r.year&&l.month>r.month;return{...s,future:c}}):e}function fo({timeZone:e,offsetMinutes:t,now:n}={}){const a=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const y=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(a).reduce((v,w)=>(w.type&&w.value&&(v[w.type]=w.value),v),{}),g=Number(y.year),x=Number(y.month),p=Number(y.day),b=Number(y.hour),k=Number(y.minute);if(Number.isFinite(g)&&Number.isFinite(x)&&Number.isFinite(p)&&Number.isFinite(b)&&Number.isFinite(k)){const v=b*2+(k>=30?1:0);return{year:g,month:x,day:p,hour:b,minute:k,dayNum:g*1e4+x*100+p,slot:v}}}catch{}if(Number.isFinite(t)){const f=new Date(a.getTime()+t*60*1e3),u=f.getUTCFullYear(),y=f.getUTCMonth()+1,g=f.getUTCDate(),x=f.getUTCHours(),p=f.getUTCMinutes(),b=x*2+(p>=30?1:0);return{year:u,month:y,day:g,hour:x,minute:p,dayNum:u*1e4+y*100+g,slot:b}}const r=a.getFullYear(),s=a.getMonth()+1,i=a.getDate(),l=a.getHours(),c=a.getMinutes(),d=l*2+(c>=30?1:0);return{year:r,month:s,day:i,hour:l,minute:c,dayNum:r*1e4+s*100+i,slot:d}}function $l(e){if(!e)return null;const t=String(e).trim(),[n,a]=t.split("T");if(!n||!a)return null;const r=n.split("-");if(r.length!==3)return null;const s=Number(r[0]),i=Number(r[1]),l=Number(r[2]);if(!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(l))return null;const c=a.split(":"),d=Number(c[0]),f=Number(c[1]);if(!Number.isFinite(d)||d<0||d>23||!Number.isFinite(f)||f<0||f>59)return null;const u=d*2+(f>=30?1:0);return{dayNum:s*1e4+i*100+l,slot:u}}function Rl(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const a=Number(n[0]),r=Number(n[1]);return!Number.isFinite(a)||!Number.isFinite(r)||r<1||r>12?null:{year:a,month:r}}function cr({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,includeDaily:s=!0,cacheKey:i,timeZone:l,tzOffsetMinutes:c,now:d}={}){const[f,u]=m.useState([]),[y,g]=m.useState(null),[x,p]=m.useState(null),[b,k]=m.useState("edge"),[v,w]=m.useState(null),[C,D]=m.useState(!1),[S,I]=m.useState(null),N=It(),O=Xt(t),E=!n,F=(()=>{if(!i)return null;const Y=Bl(e)||"default",P=s?"daily":"summary",z=Cn({timeZone:l,offsetMinutes:c});return`tokentracker.usage.${i}.${Y}.${a}.${r}.${P}.${z}`})(),Q=m.useCallback(()=>{if(!F||typeof window>"u")return null;try{const Y=window.localStorage.getItem(F);if(!Y)return null;const P=JSON.parse(Y);return!P||!P.summary?null:P}catch{return null}},[F]),j=m.useCallback(Y=>{if(!(!F||typeof window>"u"))try{window.localStorage.setItem(F,JSON.stringify(Y))}catch{}},[F]),L=m.useCallback(()=>{if(!(!F||typeof window>"u"))try{window.localStorage.removeItem(F)}catch{}},[F]),B=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),M=m.useCallback(async()=>{const Y=await Pt(t);if(!(!Y&&!N&&!B)){D(!0),I(null);try{let P=null,z=null;if(s){const[ue,me]=await Promise.allSettled([ba({baseUrl:e,accessToken:Y,from:a,to:r,timeZone:l,tzOffsetMinutes:c}),zn({baseUrl:e,accessToken:Y,from:a,to:r,timeZone:l,tzOffsetMinutes:c,rolling:!0})]);if(ue.status==="rejected")throw ue.reason;P=ue.value,z=me.status==="fulfilled"?me.value:null}else z=await zn({baseUrl:e,accessToken:Y,from:a,to:r,timeZone:l,tzOffsetMinutes:c,rolling:!0});let G=s&&Array.isArray(P?.data)?P.data:[];s&&(G=Xn(G,a,r,{timeZone:l,offsetMinutes:c,now:d}));let de=z?.totals||P?.summary?.totals||null,W=z?.rolling||P?.summary?.rolling||null;if(s&&!de&&!z)try{const ue=await zn({baseUrl:e,accessToken:Y,from:a,to:r,timeZone:l,tzOffsetMinutes:c,rolling:!0});de=ue?.totals||null,W=ue?.rolling||W}catch{}const V=new Date().toISOString();u(G),g(de),p(W),k("edge"),w(V),de&&E?j({summary:de,rolling:W,daily:G,from:a,to:r,includeDaily:s,fetchedAt:V}):E||L()}catch(P){if(E){const z=Q();if(z?.summary){g(z.summary),p(z.rolling||null);const G=Array.isArray(z.daily)?z.daily:[],de=s?Xn(G,z.from||a,z.to||r,{timeZone:l,offsetMinutes:c,now:d}):G;u(de),k("cache"),w(z.fetchedAt||null),I(null)}else{const G=P;I(G?.message||String(G)),u([]),g(null),p(null),k("edge"),w(null)}}else{const z=P;I(z?.message||String(z)),u([]),g(null),p(null),k("edge"),w(null)}}finally{D(!1)}}},[t,e,a,s,N,n,E,d,Q,O,l,r,c,L,j,B]);return m.useEffect(()=>{const Y=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!O&&!n&&!N&&!Y){u([]),g(null),p(null),I(null),D(!1),k("edge"),w(null);return}if(!E)L(),u([]),g(null),p(null),I(null),k("edge"),w(null);else{const P=Q();if(P?.summary){g(P.summary),p(P.rolling||null);const z=Array.isArray(P.daily)?P.daily:[],G=s?Xn(z,P.from||a,P.to||r,{timeZone:l,offsetMinutes:c,now:d}):z;u(G),k("cache"),w(P.fetchedAt||null)}}M()},[t,N,Q,M,O,n,E,L,B]),{daily:f,summary:y,rolling:x,source:N?"mock":b,fetchedAt:v,loading:C,error:S,refresh:M}}function Bl(e){try{return new URL(e).host}catch{return null}}function Kn(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const a=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const i=new Date(Date.UTC(a,r,s));return Number.isFinite(i.getTime())&&qt(i)===t?i:null}function Yl(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Xn(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const i=Kn(t),l=Kn(n);if(!i||!l||l<i)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,d=ka({timeZone:a,offsetMinutes:r,date:c}),f=Kn(d),u=f?f.getTime():c.getTime(),y=new Map;for(const x of e||[])x?.day&&y.set(x.day,x);const g=[];for(let x=i;x<=l;x=Yl(x,1)){const p=qt(x),b=y.get(p),k=x.getTime()>u;if(b){g.push({...b,missing:!1,future:k});continue}g.push({day:p,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!k,future:k})}return g}function zl({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,cacheKey:s,timeZone:i,tzOffsetMinutes:l}={}){const[c,d]=m.useState(null),[f,u]=m.useState("edge"),[y,g]=m.useState(!1),[x,p]=m.useState(null),b=It(),k=Xt(t),v=!n,w=m.useMemo(()=>{if(!s)return null;const E=Hl(e)||"default",F=Cn({timeZone:i,offsetMinutes:l});return`tokentracker.modelBreakdown.${s}.${E}.${a}.${r}.${F}`},[e,s,a,i,r,l]),C=m.useCallback(()=>{if(!w||typeof window>"u")return null;try{const E=window.localStorage.getItem(w);if(!E)return null;const F=JSON.parse(E);return!F||!F.breakdown?null:F}catch{return null}},[w]),D=m.useCallback(E=>{if(!(!w||typeof window>"u"))try{window.localStorage.setItem(w,JSON.stringify(E))}catch{}},[w]),S=m.useCallback(()=>{if(!(!w||typeof window>"u"))try{window.localStorage.removeItem(w)}catch{}},[w]),I=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=m.useCallback(async()=>{const E=await Pt(t);if(!(!E&&!b&&!I)){g(!0),p(null);try{const F=await Ii({baseUrl:e,accessToken:E,from:a,to:r,timeZone:i,tzOffsetMinutes:l});d(F||null),u("edge"),F&&v?D({breakdown:F,fetchedAt:new Date().toISOString()}):v||S()}catch(F){if(v){const Q=C();if(Q?.breakdown)d(Q.breakdown),u("cache"),p(null);else{d(null),u("edge");const j=F;p(j?.message||String(j))}}else{d(null),u("edge");const Q=F;p(Q?.message||String(Q))}}finally{g(!1)}}},[t,e,a,b,n,v,C,i,r,k,l,S,D,I]);return m.useEffect(()=>{if(!k&&!n&&!b&&!I){d(null),u("edge"),p(null),g(!1);return}if(!v)S(),d(null),u("edge"),p(null);else{const E=C();E?.breakdown&&(d(E.breakdown),u("cache"))}N()},[t,b,C,N,k,n,v,S,I]),{breakdown:c,source:b?"mock":f,loading:y,error:x,refresh:N}}function Hl(e){try{return new URL(e).host}catch{return null}}const mo=new Set(["day","hour","month"]);function Ul(e){return mo.has(e)}function dr(e){if(e==null)return null;const t=String(e).trim();if(!/^[0-9]+$/.test(t))return null;const n=t.replace(/^0+/,"");return n.length===0?"0":n}function ql(e,t){const n=dr(e),a=dr(t);if(n&&a)return n.length!==a.length?n.length<a.length?-1:1:n===a?0:n<a?-1:1;const r=ze(e),s=ze(t);return r==null&&s==null?0:r==null?1:s==null?-1:r===s?0:r<s?-1:1}function Gl(e,t){const n=typeof e=="string"?e:String(e||""),a=typeof t=="string"?t:String(t||"");return n===a?0:n<a?-1:1}function Vl(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]),s=Number(n[3]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const i=new Date(Date.UTC(a,r-1,s));return!Number.isFinite(i.getTime())||i.getUTCFullYear()!==a||i.getUTCMonth()+1!==r||i.getUTCDate()!==s?null:i.getTime()}function Kl(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||r<1||r>12)return null;const s=new Date(Date.UTC(a,r-1,1));return Number.isFinite(s.getTime())?s.getTime():null}function Xl(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]),s=Number(n[3]),i=Number(n[4]),l=Number(n[5]),c=Number(n[6]||0);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(l)||!Number.isFinite(c)||r<1||r>12||s<1||s>31||i<0||i>23||l<0||l>59||c<0||c>59)return null;const d=new Date(Date.UTC(a,r-1,s,i,l,c));return Number.isFinite(d.getTime())?d.getTime():null}function Ql(e,t,n){const a=n==="hour"?Xl:n==="month"?Kl:Vl,r=a(e),s=a(t);return r!=null&&s!=null?r===s?0:r<s?-1:1:Gl(e,t)}function ho(e,{key:t,dir:n}){const a=n==="asc"?1:-1,r=Array.isArray(e)?e:[],s=mo.has(t)?(l,c)=>Ql(l,c,t):ql,i=l=>t==="total_tokens"&&l?.billable_total_tokens!=null?l.billable_total_tokens:l?.[t];return r.map((l,c)=>({row:l,index:c})).sort((l,c)=>{const d=i(l.row),f=i(c.row),u=d==null,y=f==null;if(u&&y)return l.index-c.index;if(u)return 1;if(y)return-1;const g=s(d,f);return g!==0?g*a:l.index-c.index}).map(l=>l.row)}function Jl(){return[{key:"day",label:h("daily.sort.date.label"),title:h("daily.sort.date.title")},{key:"total_tokens",label:h("daily.sort.total.label"),title:h("daily.sort.total.title")},{key:"input_tokens",label:h("daily.sort.input.label"),title:h("daily.sort.input.title")},{key:"output_tokens",label:h("daily.sort.output.label"),title:h("daily.sort.output.title")},{key:"cached_input_tokens",label:h("daily.sort.cached.label"),title:h("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:h("daily.sort.reasoning.label"),title:h("daily.sort.reasoning.title")},{key:"conversation_count",label:h("daily.sort.conversations.label"),title:h("daily.sort.conversations.title")}]}function ur(e){const t=Ul(e)?e:"day";return Jl().map((n,a)=>a===0?{...n,key:t}:n)}function fr(e,{key:t,dir:n}){return ho(e,{key:t,dir:n})}const Sn=12,Zl=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function ec(e){if(typeof e=="bigint")return e!==0n;if(typeof e=="number")return Number.isFinite(e)&&e!==0;if(e==null)return!1;const t=String(e).trim();if(!t||!/^-?\d+$/.test(t))return!1;const n=t.startsWith("-")?t.slice(1):t;return/[1-9]/.test(n)}function tc(e){return Zl.some(t=>ec(e?.[t]))}function nc(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=ho(t,{key:"month",dir:"asc"}),a=n.findIndex(r=>r?.month&&tc(r));return a===-1?t:n.slice(a)}function ac(e,t,n=Sn){const a=Array.isArray(e)?e:[],r=Number.isFinite(n)&&n>0?n:Sn,i=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*r;return a.slice(i,i+r)}function rc({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:a,heatmapLoading:r,activeDays:s,hasActiveDeviceToken:i}={}){return e||t?!1:n?!0:a&&!r&&s===0&&!i}function go(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function oc(e){const t=go(e?.model_id);return t||null}function yo(e,t){return e?.model?String(e.model):t}function Gt(e,t=0){const n=ze(e?.billable_total_tokens),a=ze(e?.total_tokens);return n!=null&&n>0?n:a!=null&&a>0?a:n??a??t}function sc(e,{copyFn:t}={}){const n=typeof t=="function"?t:i=>i,r=(Array.isArray(e?.sources)?e.sources:[]).map(i=>{const l=Gt(i?.totals),c=ze(i?.totals?.total_cost_usd)??0;return{source:i?.source,totalTokens:Number.isFinite(l)?l:0,totalCost:Number.isFinite(c)?c:0,models:Array.isArray(i?.models)?i.models:[]}}).filter(i=>i.totalTokens>0);if(!r.length)return[];const s=r.reduce((i,l)=>i+l.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),r.slice().sort((i,l)=>l.totalTokens-i.totalTokens).map(i=>{const l=i.source?String(i.source).toUpperCase():n("shared.placeholder.short"),c=s>0?i.totalTokens/s*100:0,d=Number.isFinite(c)?c.toFixed(1):"0.0",f=i.models.map(u=>{const y=Gt(u?.totals);if(!Number.isFinite(y)||y<=0)return null;const g=i.totalTokens>0?Math.round(y/i.totalTokens*1e3)/10:0,x=yo(u,n("shared.placeholder.short")),p=oc(u),b=ze(u?.totals?.total_cost_usd),k=b??(i.totalCost>0&&i.totalTokens>0?y/i.totalTokens*i.totalCost:null);return{id:p,name:x,share:g,usage:y,cost:k}}).filter(Boolean);return{source:i.source,label:l,totalPercent:String(d),usd:i.totalCost,usage:i.totalTokens,models:f}})}function ic(e,{limit:t=3,copyFn:n}={}){const a=typeof n=="function"?n:y=>y,r=Array.isArray(e?.sources)?e.sources:[];if(!r.length)return[];const s=new Map,i=new Map,l=new Map;let c=0;for(const y of r){const g=Array.isArray(y?.models)?y.models:[];for(const x of g){const p=Gt(x?.totals);if(!Number.isFinite(p)||p<=0)continue;c+=p;const b=yo(x,a("shared.placeholder.short")),k=go(b);if(!k)continue;s.set(k,(s.get(k)||0)+p);const v=l.get(k)||0;p>=v&&(l.set(k,p),i.set(k,b))}}if(!s.size)return[];const d=Array.from(s.values()).reduce((y,g)=>y+g,0),f=c>0?c:d,u=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(s.entries()).map(([y,g])=>{const x=f>0?(g/f*100).toFixed(1):"0.0";return{id:y,name:i.get(y)||a("shared.placeholder.short"),tokens:g,percent:String(x)}}).sort((y,g)=>g.tokens!==y.tokens?g.tokens-y.tokens:String(y.name).localeCompare(String(g.name))).slice(0,u)}const ft={emerald:{light:["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],dark:["#2d333b","#065f46","#059669","#10b981","#34d399"],gridColor:{light:"rgba(16, 185, 129, 0.12)",dark:"rgba(52, 211, 153, 0.08)"}},ocean:{light:["#f1f5f9","#93c5fd","#60a5fa","#3b82f6","#1d4ed8"],dark:["#1e293b","#1e3a8a","#2563eb","#3b82f6","#60a5fa"],gridColor:{light:"rgba(59, 130, 246, 0.12)",dark:"rgba(96, 165, 250, 0.08)"}},neon:{light:["#faf5ff","#ebd5ff","#c084fc","#a855f7","#7e22ce"],dark:["#2e1065","#581c87","#8b5cf6","#a855f7","#c084fc"],gridColor:{light:"rgba(168, 85, 247, 0.12)",dark:"rgba(192, 132, 252, 0.08)"}},amber:{light:["#fffbeb","#fde68a","#f59e0b","#d97706","#b45309"],dark:["#451a03","#78350f","#b45309","#d97706","#f59e0b"],gridColor:{light:"rgba(245, 158, 11, 0.12)",dark:"rgba(245, 158, 11, 0.08)"}}};function lc(e,t){const n=/^#([0-9a-f]{6})$/i.exec(e);if(!n)return e;const a=parseInt(n[1],16),r=a>>16&255,s=a>>8&255,i=a&255,l=c=>Math.max(0,Math.min(255,Math.round(c*t)));return`rgb(${l(r)}, ${l(s)}, ${l(i)})`}function Ze(e,t,n,a,r){const s=Math.cos(a),i=Math.sin(a),l=e*s-t*i,c=e*i+t*s,d=n,f=Math.cos(r),u=Math.sin(r),y=l,g=c*f-d*u,x=c*u+d*f;return{x:y,y:g,z:x}}function cc(e,t,n,a,r){return Ze(e,t,n,a,r)}function po(e,t){const n=Number(t).toLocaleString();if(e>=4){const a=Math.floor(Math.random()*3)+1;return h(`heatmap.3d.voxel.joke.${a}`,{value:n})}else return e===3?h("heatmap.3d.voxel.level3",{value:n}):e===2?h("heatmap.3d.voxel.level2",{value:n}):e===1?h("heatmap.3d.voxel.level1",{value:n}):h("heatmap.3d.voxel.level0")}function mr({weeks:e,palette:t="auto",isDark:n=!1,interactive:a=!1,autoRotateInit:r=!1,onResetViewRef:s=null}){const i=ft[t]||(t==="auto"?ft.emerald:null),l=i?n?i.dark:i.light:Array.isArray(t)?t:n?ft.emerald.dark:ft.emerald.light,c=i?n?i.gridColor.dark:i.gridColor.light:n?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",d=-.2,f=.88,[u,y]=m.useState({yaw:d,pitch:f}),[g,x]=m.useState(r),[p,b]=m.useState(1),k=a?13:10.5,v=m.useMemo(()=>{const A=[],R=e.length;if(R===0||!a)return[];for(let J=0;J<=7;J++){const H=(J-3.5)*k,ie=Ze(-R/2*k,H,0,u.yaw,u.pitch),se=Ze(R/2*k,H,0,u.yaw,u.pitch);A.push({d:`M${ie.x},${ie.y} L${se.x},${se.y}`,key:`horiz-${J}`})}for(let J=0;J<=R;J+=4){const H=(J-R/2)*k,ie=Ze(H,-3.5*k,0,u.yaw,u.pitch),se=Ze(H,3.5*k,0,u.yaw,u.pitch);A.push({d:`M${ie.x},${ie.y} L${se.x},${se.y}`,key:`vert-${J}`})}if(R%4!==0){const J=(R-R/2)*k,H=Ze(J,-3.5*k,0,u.yaw,u.pitch),ie=Ze(J,3.5*k,0,u.yaw,u.pitch);A.push({d:`M${H.x},${H.y} L${ie.x},${ie.y}`,key:"vert-last"})}return A},[e.length,u,k,a]);m.useEffect(()=>{s&&(s.current={reset:()=>{y({yaw:d,pitch:f}),x(!1),b(1),B()},toggleAutoRotate:A=>{x(A)}})},[s]);const w=m.useRef(null),C=m.useRef(null),D=m.useRef(!1),S=m.useRef({x:0,y:0}),I=m.useRef({yaw:d,pitch:f}),N=m.useRef({x:0,y:0}),O=m.useRef({x:0,y:0,time:0}),E=m.useRef(null),[F,Q]=m.useState(0),j=m.useRef(null),L=m.useRef(!0);m.useEffect(()=>(L.current=!0,()=>{L.current=!1}),[]);const B=()=>{j.current&&cancelAnimationFrame(j.current),Q(0);const A=performance.now(),R=1200,J=H=>{if(!L.current)return;const ie=H-A,se=Math.min(1,ie/R),xe=1-Math.pow(1-se,3);Q(xe),se<1?j.current=requestAnimationFrame(J):j.current=null};j.current=requestAnimationFrame(J)};m.useEffect(()=>(B(),()=>{j.current&&cancelAnimationFrame(j.current)}),[a]),m.useEffect(()=>{if(!g||D.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let R;const J=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){R=requestAnimationFrame(J);return}y(H=>({yaw:H.yaw+.002,pitch:H.pitch})),R=requestAnimationFrame(J)};return R=requestAnimationFrame(J),()=>cancelAnimationFrame(R)},[g]);const M=(A,R)=>{a&&(D.current=!0,S.current={x:A,y:R},I.current={yaw:u.yaw,pitch:u.pitch},N.current={x:0,y:0},O.current={x:A,y:R,time:performance.now()},E.current&&cancelAnimationFrame(E.current))},Z=(A,R)=>{if(!D.current)return;const J=A-S.current.x,H=R-S.current.y,ie=performance.now(),se=ie-O.current.time;se>0&&(N.current={x:(A-O.current.x)/se,y:(R-O.current.y)/se}),O.current={x:A,y:R,time:ie};const xe=.005,_e=I.current.yaw-J*xe,Ne=Math.PI/2.3,ae=Math.max(-Ne,Math.min(Ne,I.current.pitch-H*xe));y({yaw:_e,pitch:ae})},Y=()=>{if(!D.current)return;D.current=!1;let A=-N.current.x*12,R=-N.current.y*12;const J=.95,H=()=>{D.current||(A*=J,R*=J,!(Math.abs(A)<.01&&Math.abs(R)<.01)&&(y(ie=>{const se=ie.yaw+A*.005,xe=Math.PI/2.3,_e=Math.max(-xe,Math.min(xe,ie.pitch+R*.005));return{yaw:se,pitch:_e}}),E.current=requestAnimationFrame(H)))};E.current=requestAnimationFrame(H)},[P,z]=m.useState(null),[G,de]=m.useState({x:0,y:0,shiftX:0}),W=m.useRef(null);m.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]),m.useEffect(()=>{if(!a||!C.current)return;const A=J=>{J.preventDefault();const H=-J.deltaY*.0025;b(ie=>{const se=ie+H;return Math.max(.5,Math.min(3,se))})},R=C.current;return R.addEventListener("wheel",A,{passive:!1}),()=>{R.removeEventListener("wheel",A)}},[a]);const V=m.useMemo(()=>{const A=[];return e.forEach((R,J)=>{(Array.isArray(R)?R:[]).forEach((H,ie)=>{H&&A.push({key:H.day||`${J}-${ie}`,col:J,row:ie,level:H.level||0,value:H.value||0,day:H.day,models:H.models||null})})}),A},[e]),me=k-(a?1.8:1.5),T=a?38:28,oe=A=>Math.max(1.8,Number(A)/4*T),pe=m.useMemo(()=>{if(V.length===0)return[];const A=e.length;return V.map(R=>{const J=oe(R.level),H=Math.sqrt(Math.pow(R.col-A/2,2)+Math.pow(R.row-3.5,2)),ie=Math.sqrt(Math.pow(A/2,2)+Math.pow(3.5,2)),se=H/ie*.4,xe=Math.min(1,Math.max(0,(F-se)*(1/.6))),_e=J*xe,Ne=(R.col-A/2)*k,ae=(R.row-3.5)*k,ge=me/2,we=[{x:Ne-ge,y:ae-ge,z:0},{x:Ne+ge,y:ae-ge,z:0},{x:Ne+ge,y:ae+ge,z:0},{x:Ne-ge,y:ae+ge,z:0},{x:Ne-ge,y:ae-ge,z:_e},{x:Ne+ge,y:ae-ge,z:_e},{x:Ne+ge,y:ae+ge,z:_e},{x:Ne-ge,y:ae+ge,z:_e}].map(ne=>Ze(ne.x,ne.y,ne.z,u.yaw,u.pitch)),Re=Ze(Ne,ae,_e/2,u.yaw,u.pitch),ot=[{name:"top",indices:[4,5,6,7],scale:1,normal:[0,0,1]},{name:"bottom",indices:[3,2,1,0],scale:.4,normal:[0,0,-1]},{name:"left",indices:[3,0,4,7],scale:.55,normal:[-1,0,0]},{name:"right",indices:[1,2,6,5],scale:.75,normal:[1,0,0]},{name:"front",indices:[0,1,5,4],scale:.85,normal:[0,-1,0]},{name:"back",indices:[2,3,7,6],scale:.65,normal:[0,1,0]}],Nt=l[Math.min(4,Math.max(0,Number(R.level)||0))],gt=[],yt=.35,jt=-.4,ee=.83;return ot.forEach(ne=>{const U=cc(ne.normal[0],ne.normal[1],ne.normal[2],u.yaw,u.pitch);if(U.z>.001){const te=we[ne.indices[0]],Oe=we[ne.indices[1]],ce=we[ne.indices[2]],pt=we[ne.indices[3]],xt=`M${te.x},${te.y} L${Oe.x},${Oe.y} L${ce.x},${ce.y} L${pt.x},${pt.y} Z`,bt=U.x*yt+U.y*jt+U.z*ee,Ge=n?.18:0,st=ne.scale*(.82+.28*Math.max(0,bt))+Ge;gt.push({name:ne.name,d:xt,fill:lc(Nt,st)})}}),{...R,centerProj:Re,renderedFaces:gt}})},[V,u,l,e.length,F,k,me,T]),fe=m.useMemo(()=>[...pe].sort((A,R)=>A.centerProj.z-R.centerProj.z),[pe]),le=m.useMemo(()=>{if(fe.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let A=1/0,R=1/0,J=-1/0,H=-1/0;return fe.forEach(ie=>{const se=k*2,xe=ie.centerProj.x,_e=ie.centerProj.y;xe-se<A&&(A=xe-se),xe+se>J&&(J=xe+se),_e-se<R&&(R=_e-se),_e+se>H&&(H=_e+se)}),{minX:A,minY:R,maxX:J,maxY:H}},[fe,k]),he=12,Pe=le.maxX-le.minX+he*2,De=le.maxY-le.minY+he*2,ke=Pe/p,Ie=De/p,je=le.minX-he+(Pe-ke)/2,Te=le.minY-he+(De-Ie)/2,Ce=`${je} ${Te} ${ke} ${Ie}`;return V.length===0?o.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:h("heatmap.empty")}):o.jsxs("div",{ref:C,className:`relative select-none outline-none ${a?"cursor-grab active:cursor-grabbing w-full h-full flex items-center justify-center":"w-full overflow-hidden flex justify-center"}`,onMouseDown:A=>{if(!a)return;M(A.clientX,A.clientY);const R=H=>Z(H.clientX,H.clientY),J=()=>{Y(),window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",J)};window.addEventListener("mousemove",R),window.addEventListener("mouseup",J)},onTouchStart:A=>{!a||A.touches.length===0||M(A.touches[0].clientX,A.touches[0].clientY)},onTouchMove:A=>{!a||A.touches.length===0||Z(A.touches[0].clientX,A.touches[0].clientY)},onTouchEnd:()=>{a&&Y()},children:[o.jsxs("svg",{ref:w,viewBox:Ce,width:a?"95%":"100%",height:a?"95%":"auto",role:"img","aria-label":h("heatmap.iso.aria")||"3D interactive activity heatmap",style:{display:"block",width:"100%",height:"auto",maxWidth:a?"none":`${Pe}px`,maxHeight:a?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[a&&v.map(A=>o.jsx("path",{d:A.d,fill:"none",stroke:c,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},A.key)),fe.map(A=>{const R=P&&P.key===A.key;return o.jsxs("g",{onMouseEnter:J=>{if(W.current&&(clearTimeout(W.current),W.current=null),z(A),a&&w.current){const H=Ze((A.col-e.length/2)*k,(A.row-3.5)*k,oe(A.level),u.yaw,u.pitch);let ie=0,se=0;const xe=w.current;if(C.current&&typeof xe.createSVGPoint=="function"&&typeof xe.getScreenCTM=="function")try{const ge=xe.createSVGPoint();ge.x=H.x,ge.y=H.y;const Se=xe.getScreenCTM();if(Se){const we=ge.matrixTransform(Se),Re=C.current.getBoundingClientRect();ie=we.x-Re.left,se=we.y-Re.top}}catch{const Se=xe.getBoundingClientRect(),we=le.maxX-le.minX+he*2,Re=le.maxY-le.minY+he*2;ie=(H.x-(le.minX-he))/we*Se.width,se=(H.y-(le.minY-he))/Re*Se.height}else{const ge=xe.getBoundingClientRect(),Se=le.maxX-le.minX+he*2,we=le.maxY-le.minY+he*2;ie=(H.x-(le.minX-he))/Se*ge.width,se=(H.y-(le.minY-he))/we*ge.height}const _e=140;let Ne=0;const ae=C.current?C.current.getBoundingClientRect().width:xe.getBoundingClientRect().width;ie<_e?Ne=_e-ie:ie>ae-_e&&(Ne=ae-_e-ie),de({x:ie,y:se,shiftX:Ne})}},onMouseLeave:()=>{W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{z(null)},150)},className:"transition-all duration-200",style:{filter:R?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:a?"pointer":"default"},children:[!a&&A.day&&o.jsx("title",{children:`${A.day}: ${Number(A.value).toLocaleString()} tokens`}),A.renderedFaces.map((J,H)=>o.jsx("path",{d:J.d,fill:J.fill,stroke:J.fill,strokeWidth:.25,strokeLinejoin:"round"},H))]},A.key)})]}),a&&P&&o.jsxs("div",{onMouseEnter:()=>{W.current&&(clearTimeout(W.current),W.current=null)},onMouseLeave:()=>{W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{z(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${G.x}px`,top:`${G.y}px`},children:[o.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${G.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:P.day}),(()=>{const A=P.level===0?n?"#9ca3af":"#6b7280":l[P.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:A+"22",color:A,border:`1px solid ${A}44`},children:["Level ",P.level]})})()]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Number(P.value).toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),P.models&&Object.keys(P.models).length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(P.models).map(([A,R])=>({name:A,val:Number(R)})).sort((A,R)=>R.val-A.val).map(({name:A,val:R})=>{const J=Number(P.value)||1,H=Math.round(R/J*100);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:A,children:A}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:R.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[H,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${H}%`,backgroundColor:l[4],boxShadow:`0 0 4px ${l[4]}55`}})})]},A)})})]}):o.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:po(P.level,P.value)})]})]}),o.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]})]})}const Ct=12,tn=3,Qn=26,dc=["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],uc=["#30363d","#065f46","#059669","#10b981","#34d399"];function hr(e){const t=Number(e);return Number.isFinite(t)?t<1e3?t.toLocaleString():He(t,{decimals:2}):"0"}function fc(e){if(typeof e!="string")return null;const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;const n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return Number.isFinite(n.getTime())?n:null}function xo(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function mc(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function hc(e,t){const n=t==="mon"?1:0,a=e.getUTCDay();return xo(e,-((a-n+7)%7))}function gc(e,t,n,a){if(!e)return[];const r=fc(t)||new Date,s=[];for(let f=11;f>=0;f-=1)s.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-f,1)));const i=hc(r,n),l=xo(i,-(e-1)*7),c=[],d=new Set;for(const f of s){const u=Math.floor(mc(l,f)/7);u<0||u>=e||d.has(u)||(d.add(u),c.push({label:a[f.getUTCMonth()],index:u}))}return c}function yc({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:a=!1}){const{resolvedTheme:r}=no(),s=r==="dark",i=s?uc:dc,l=m.useRef(null),c=m.useRef(null),[d,f]=m.useState(null),[u,y]=m.useState({x:0,y:0,shiftX:0}),g=m.useRef(null);m.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const[x,p]=m.useState(!1),[b,k]=m.useState(!1),[v,w]=m.useState(!1),C=m.useRef(null),[D,S]=m.useState("emerald"),I=[h("heatmap.month.jan"),h("heatmap.month.feb"),h("heatmap.month.mar"),h("heatmap.month.apr"),h("heatmap.month.may"),h("heatmap.month.jun"),h("heatmap.month.jul"),h("heatmap.month.aug"),h("heatmap.month.sep"),h("heatmap.month.oct"),h("heatmap.month.nov"),h("heatmap.month.dec")],N=(T,oe)=>{if(!oe||!oe.day)return;g.current&&(clearTimeout(g.current),g.current=null),f(oe);const pe=T.currentTarget.getBoundingClientRect(),fe=c.current;if(!fe)return;const le=fe.getBoundingClientRect(),he=pe.left-le.left+pe.width/2,Pe=pe.top-le.top,De=140;let ke=0;he<De?ke=De-he:he>le.width-De&&(ke=le.width-De-he),y({x:he,y:Pe,shiftX:ke})},O=()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{f(null)},150)},E=()=>{g.current&&(clearTimeout(g.current),g.current=null)},F=()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{f(null)},150)},Q=()=>{k(!1),p(!0)},j=()=>{k(!0)},L=T=>{T.target===T.currentTarget&&b&&(p(!1),k(!1))};m.useEffect(()=>{if(!x||b)return;const T=oe=>{oe.key==="Escape"&&j()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[x,b]);const B=m.useMemo(()=>({emerald:{accentText:"text-emerald-500 dark:text-emerald-400",accentBg:"bg-emerald-500/10 dark:bg-emerald-400/10",accentBorder:"border-emerald-500/20 dark:border-emerald-400/15",hoverBorder:"hover:border-emerald-500/30 dark:hover:border-emerald-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(16,185,129,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(52,211,153,0.25)]",rawColor:"#10b981"},ocean:{accentText:"text-blue-500 dark:text-blue-400",accentBg:"bg-blue-500/10 dark:bg-blue-400/10",accentBorder:"border-blue-500/20 dark:border-blue-400/15",hoverBorder:"hover:border-blue-500/30 dark:hover:border-blue-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(59,130,246,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(96,165,250,0.25)]",rawColor:"#3b82f6"},neon:{accentText:"text-purple-500 dark:text-purple-400",accentBg:"bg-purple-500/10 dark:bg-purple-400/10",accentBorder:"border-purple-500/20 dark:border-purple-400/15",hoverBorder:"hover:border-purple-500/30 dark:hover:border-purple-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(168,85,247,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(192,132,252,0.25)]",rawColor:"#a855f7"},amber:{accentText:"text-amber-500 dark:text-amber-400",accentBg:"bg-amber-500/10 dark:bg-amber-400/10",accentBorder:"border-amber-500/20 dark:border-amber-400/15",hoverBorder:"hover:border-amber-500/30 dark:hover:border-amber-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(245,158,11,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(245,158,11,0.25)]",rawColor:"#f59e0b"}}),[]),M=B[D]||B.emerald,Z=ft[D]?s?ft[D].dark:ft[D].light:s?ft.emerald.dark:ft.emerald.light,[Y,P]=m.useState(()=>{try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});m.useEffect(()=>{try{window.localStorage?.setItem("tt:heatmap-view",Y)}catch{}},[Y]),m.useEffect(()=>{const T=l.current;T&&(T.scrollLeft=T.scrollWidth)},[e?.weeks]),m.useEffect(()=>{const T=l.current;if(!T)return;const oe=()=>{g.current&&(clearTimeout(g.current),g.current=null),f(null)};return T.addEventListener("scroll",oe),()=>T.removeEventListener("scroll",oe)},[]);const z=e?.week_starts_on==="mon"?"mon":"sun",G=m.useMemo(()=>{const T=Array.isArray(e?.weeks)?e.weeks:[];if(!T.length)return{weeks:[]};const oe=[];for(const pe of T)for(const fe of Array.isArray(pe)?pe:[])fe?.day&&oe.push({day:fe.day,total_tokens:fe.total_tokens??fe.value??0,billable_total_tokens:fe.billable_total_tokens??fe.value??fe.total_tokens??0,models:fe.models??null});return fa({dailyRows:oe,weeks:Math.max(52,T.length),to:e?.to,weekStartsOn:z})},[e?.to,e?.weeks,z]),de=G?.weeks||[],W=m.useMemo(()=>{let T=0,oe=0,pe={day:"无数据",value:0},fe=0,le=0;const he=[];de.forEach(Ce=>{(Array.isArray(Ce)?Ce:[]).forEach(A=>{A&&A.day&&he.push(A)})}),he.sort((Ce,A)=>Ce.day.localeCompare(A.day)),he.forEach(Ce=>{const A=Number(Ce.value)||0;T+=A,A>0?(oe++,fe++,fe>le&&(le=fe)):fe=0,A>pe.value&&(pe={day:Ce.day,value:A})});const Pe=he.length||365,De=(oe/Pe*100).toFixed(1);let ke="heatmap.3d.modal.ai.eval.default",Ie="heatmap.3d.modal.ai.title.default";T>=15e6?(Ie="heatmap.3d.modal.ai.title.peak",ke="heatmap.3d.modal.ai.eval.peak"):T>=5e6?(Ie="heatmap.3d.modal.ai.title.heavy",ke="heatmap.3d.modal.ai.eval.heavy"):T>=1e6?(Ie="heatmap.3d.modal.ai.title.core",ke="heatmap.3d.modal.ai.eval.core"):T>=2e4&&(Ie="heatmap.3d.modal.ai.title.steady",ke="heatmap.3d.modal.ai.eval.steady");const je=e?.total_cost_usd,Te=je!=null?Number(je):T/15e5;return{totalTokens:T,activeDays:oe,activeRate:De,maxSingleDay:pe,maxStreak:le,aiEvaluationTitleKey:Ie,aiEvaluationKey:ke,totalCostUsd:Te}},[de,e?.total_cost_usd]),V=z==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(T=>h(`heatmap.day.${T.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(T=>h(`heatmap.day.${T.toLowerCase()}`)),ue=m.useMemo(()=>gc(de.length,G?.to,z,I),[G?.to,de.length,z,I]);if(!de.length)return o.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:h("heatmap.empty")});const me=Qn+de.length*Ct+Math.max(0,de.length-1)*tn;return o.jsxs("div",{ref:c,className:"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[o.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:h("heatmap.title")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{role:"tablist","aria-label":"Heatmap view",className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[10px]",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":Y==="2d",onClick:()=>P("2d"),className:Y==="2d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:h("heatmap.view.2d")}),o.jsx("button",{type:"button",role:"tab","aria-selected":Y==="3d",onClick:()=>P("3d"),className:Y==="3d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:h("heatmap.view.3d")})]}),o.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-450",children:n||h("heatmap.legend.utc")})]})]}),Y==="3d"&&o.jsxs("div",{onClick:Q,className:"cursor-pointer group relative overflow-hidden rounded-lg hover:border-oai-gray-350 dark:hover:border-oai-gray-700 border border-transparent transition-all",title:h("heatmap.3d.hover_tip"),children:[o.jsx(mr,{weeks:de,isDark:s,palette:D}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-oai-gray-900/5 to-transparent pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2",children:o.jsxs("span",{className:"text-[10px] bg-white/95 dark:bg-oai-gray-900/95 shadow border border-oai-gray-200/60 dark:border-oai-gray-800/80 px-2.5 py-1 rounded-full font-medium text-oai-gray-500 dark:text-oai-gray-400 flex items-center gap-1 transform translate-y-2 group-hover:translate-y-0 transition-transform duration-200",children:[o.jsx(pl,{size:9}),h("heatmap.3d.hover_tip")]})})]}),Y==="2d"&&o.jsx("div",{ref:l,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:o.jsxs("div",{style:{minWidth:me},children:[o.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${Qn}px repeat(${de.length}, ${Ct}px)`,columnGap:tn},children:[o.jsx("span",{}),ue.map(T=>o.jsx("span",{style:{gridColumnStart:T.index+2},className:"whitespace-nowrap",children:T.label},`${T.label}-${T.index}`))]}),o.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${Qn}px repeat(${de.length}, ${Ct}px)`,columnGap:tn},children:[o.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${Ct}px)`,rowGap:tn},children:V.map(T=>o.jsx("span",{className:"leading-none",children:T},T))}),o.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Ct}px)`,gap:tn},children:de.map((T,oe)=>(Array.isArray(T)?T:[]).map((pe,fe)=>{if(!pe)return null;const le=pe.day||`e-${oe}-${fe}`,he=Number(pe.level)||0,Pe=i[he]||i[0];return o.jsx("span",{onMouseEnter:De=>N(De,pe),onMouseLeave:O,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:Ct,height:Ct,background:Pe}},le)}))})]})]})}),!a&&o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:h("heatmap.legend.less")}),o.jsx("div",{className:"flex gap-0.5",children:i.map((T,oe)=>o.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:T}},oe))}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:h("heatmap.legend.more")})]}),x&&o.jsx("div",{onAnimationEnd:L,onClick:T=>{T.target===T.currentTarget&&j()},className:`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 ${b?"animate-tt-fade-out":"animate-tt-fade-in"}`,children:o.jsxs("div",{className:`relative w-full max-w-6xl 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 ${b?"animate-tt-modal-exit":"animate-tt-modal"}`,children:[o.jsx("button",{type:"button",onClick:j,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 transition-all duration-300",children:o.jsx(ao,{size:16})}),o.jsxs("div",{className:"w-full md:w-[340px] 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-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[o.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:M.rawColor}}),o.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:M.rawColor}})]}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:"3D Insight"})]}),o.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:h("heatmap.3d.modal.title")}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:h("heatmap.3d.modal.desc")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[o.jsxs("div",{className:"flex flex-col gap-1 relative group cursor-help",children:[o.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:o.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[o.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:h("heatmap.3d.modal.stats.precision_total_tokens")}),o.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[W.totalTokens.toLocaleString()," Tokens"]})]})}),o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:h("heatmap.3d.modal.stats.total_tokens")}),o.jsxs("div",{className:"flex items-baseline gap-1.5",children:[o.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:hr(W.totalTokens)}),o.jsx("div",{className:"opacity-30 group-hover:opacity-60 transition-opacity",children:o.jsx("svg",{width:"24",height:"10",viewBox:"0 0 24 10",fill:"none",children:o.jsx("path",{d:"M1 9C3 7 5 7 7 4C9 1 11 0 13 2C15 4 17 0 23 0",stroke:M.rawColor,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:h("heatmap.3d.modal.stats.estimated_cost")}),o.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:"$"+W.totalCostUsd.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:h("heatmap.3d.modal.stats.active_rate_days")}),o.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[W.activeRate,"% ",o.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",W.activeDays,"D)"]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:h("heatmap.3d.modal.stats.max_streak")}),o.jsxs("span",{className:"text-xl font-black text-amber-500 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[W.maxStreak," ",o.jsx("span",{className:"text-[10px] font-bold text-amber-500/80 font-mono",children:h("heatmap.3d.modal.stats.days_suffix")})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 col-span-2 relative group cursor-help",children:[o.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:o.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[o.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:h("heatmap.3d.modal.stats.precision_peak_value")}),o.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[W.maxSingleDay.value>0?W.maxSingleDay.value.toLocaleString():h("heatmap.3d.modal.stats.no_data")," Tokens"]}),o.jsx("span",{className:"text-[8px] text-zinc-400 dark:text-zinc-500 mt-0.5",children:W.maxSingleDay.day!=="无数据"?W.maxSingleDay.day:h("heatmap.3d.modal.stats.no_data")})]})}),o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:h("heatmap.3d.modal.stats.peak_day")}),o.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[W.maxSingleDay.value>0?hr(W.maxSingleDay.value):h("heatmap.3d.modal.stats.no_data")," ",o.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",W.maxSingleDay.day!=="无数据"?W.maxSingleDay.day:h("heatmap.3d.modal.stats.no_data"),")"]})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5 py-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsx(Ml,{size:11,style:{color:M.rawColor}}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:M.rawColor},children:h(W.aiEvaluationTitleKey)})]}),o.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:M.rawColor},children:[o.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:M.rawColor}}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:h(W.aiEvaluationKey)})]})]}),o.jsx("div",{className:"mt-auto border-t border-zinc-200/50 dark:border-zinc-800/50 pt-4 select-none",children:o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:h("heatmap.3d.modal.legend.title")}),o.jsx("span",{className:"text-[10px] font-medium text-zinc-500 dark:text-zinc-400",children:h(`heatmap.3d.modal.palette.${D}`)})]}),o.jsx("div",{className:"flex gap-1",children:Z.map((T,oe)=>o.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:T},title:`Level ${oe}`},oe))})]})})]}),o.jsxs("div",{className:"flex-1 h-full relative flex items-center justify-center overflow-hidden p-4",children:[o.jsx("div",{className:"absolute top-1/4 left-1/3 w-96 h-96 rounded-full blur-[130px] pointer-events-none -translate-x-1/2 -translate-y-1/2 transition-all duration-500",style:{backgroundColor:M.rawColor+"15"}}),o.jsx("div",{className:"absolute bottom-1/4 right-1/3 w-80 h-80 rounded-full blur-[120px] pointer-events-none translate-x-1/2 translate-y-1/2 bg-purple-500/[0.04] dark:bg-purple-500/[0.08]"}),o.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-3 p-1.5 backdrop-blur-md bg-white/70 dark:bg-oai-gray-900/75 border border-oai-gray-200/60 dark:border-oai-gray-800/80 rounded-full shadow-lg z-30 select-none",children:[o.jsx("div",{className:"flex items-center gap-1.5 px-2",children:Object.keys(B).map(T=>{const oe=D===T;return o.jsx("button",{type:"button",onClick:()=>S(T),title:h(`heatmap.3d.modal.palette.${T}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${T==="emerald"?"bg-[#10b981]":T==="ocean"?"bg-[#3b82f6]":T==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:oe&&o.jsx("span",{className:"absolute inset-0 rounded-full ring-2 ring-offset-1 ring-offset-white dark:ring-offset-oai-gray-900 ring-oai-gray-900 dark:ring-white scale-110"})},T)})}),o.jsx("div",{className:"w-[1px] h-4 bg-oai-gray-200 dark:bg-oai-gray-800"}),o.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[o.jsx("button",{type:"button",onClick:()=>{const T=!v;w(T),C.current&&C.current.toggleAutoRotate(T)},title:v?h("heatmap.3d.modal.control.pause"):h("heatmap.3d.modal.control.play"),className:`p-1.5 rounded-full transition-all duration-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 ${v?M.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:v?o.jsx(bl,{size:12}):o.jsx(wl,{size:12})}),o.jsx("button",{type:"button",onClick:()=>{w(!1),C.current&&C.current.reset()},title:h("heatmap.3d.modal.control.reset"),className:"p-1.5 rounded-full text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-all duration-200",children:o.jsx(_l,{size:12})})]})]}),o.jsx(mr,{weeks:de,isDark:s,interactive:!0,palette:D,autoRotateInit:v,onResetViewRef:C}),o.jsxs("div",{className:"absolute bottom-4 right-4 flex items-center gap-1.5 text-[9px] font-bold text-oai-gray-400 bg-white/80 dark:bg-oai-gray-900/80 border border-oai-gray-200/50 dark:border-oai-gray-800/80 rounded-md px-2.5 py-1.5 select-none pointer-events-none backdrop-blur-md shadow-sm",children:[o.jsx(va,{size:10,className:M.accentText}),o.jsx("span",{children:h("heatmap.3d.modal.footer.tip")})]})]})]})}),d&&!x&&o.jsxs("div",{onMouseEnter:E,onMouseLeave:F,className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${u.x}px`,top:`${u.y}px`},children:[o.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${u.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:d.day}),(()=>{const T=d.level===0?s?"#9ca3af":"#6b7280":i[d.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:T+"22",color:T,border:`1px solid ${T}44`},children:["Level ",d.level]})})()]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Number(d.total_tokens??d.value).toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),d.models&&Object.keys(d.models).length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(d.models).map(([T,oe])=>({name:T,val:Number(oe)})).sort((T,oe)=>oe.val-T.val).map(({name:T,val:oe})=>{const pe=Number(d.total_tokens??d.value)||1,fe=Math.round(oe/pe*100);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:T,children:T}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:oe.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[fe,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${fe}%`,backgroundColor:i[4],boxShadow:`0 0 4px ${i[4]}55`}})})]},T)})})]}):o.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:po(d.level,d.total_tokens??d.value)})]})]}),o.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]}),o.jsx("style",{children:`
|
|
2
|
+
.scrollbar-thin::-webkit-scrollbar {
|
|
3
|
+
width: 4px;
|
|
4
|
+
height: 4px;
|
|
5
|
+
}
|
|
6
|
+
.scrollbar-thin::-webkit-scrollbar-track {
|
|
7
|
+
background: transparent;
|
|
8
|
+
}
|
|
9
|
+
.scrollbar-thin::-webkit-scrollbar-thumb {
|
|
10
|
+
background: rgba(156, 163, 175, 0.25);
|
|
11
|
+
border-radius: 9999px;
|
|
12
|
+
transition: background 0.2s ease;
|
|
13
|
+
}
|
|
14
|
+
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
|
|
15
|
+
background: rgba(156, 163, 175, 0.45);
|
|
16
|
+
}
|
|
17
|
+
.dark .scrollbar-thin::-webkit-scrollbar-thumb {
|
|
18
|
+
background: rgba(156, 163, 175, 0.18);
|
|
19
|
+
}
|
|
20
|
+
.dark .scrollbar-thin::-webkit-scrollbar-thumb:hover {
|
|
21
|
+
background: rgba(156, 163, 175, 0.3);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@keyframes tt-fade-in {
|
|
25
|
+
from { opacity: 0; }
|
|
26
|
+
to { opacity: 1; }
|
|
27
|
+
}
|
|
28
|
+
@keyframes tt-fade-out {
|
|
29
|
+
from { opacity: 1; }
|
|
30
|
+
to { opacity: 0; }
|
|
31
|
+
}
|
|
32
|
+
@keyframes tt-modal-entrance {
|
|
33
|
+
from {
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: scale(0.96) translateY(10px);
|
|
36
|
+
}
|
|
37
|
+
to {
|
|
38
|
+
opacity: 1;
|
|
39
|
+
transform: scale(1) translateY(0);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
@keyframes tt-modal-exit {
|
|
43
|
+
from {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
transform: scale(1) translateY(0);
|
|
46
|
+
}
|
|
47
|
+
to {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
transform: scale(0.96) translateY(10px);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
.animate-tt-fade-in {
|
|
53
|
+
animation: tt-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
54
|
+
}
|
|
55
|
+
.animate-tt-fade-out {
|
|
56
|
+
animation: tt-fade-out 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
57
|
+
}
|
|
58
|
+
.animate-tt-modal {
|
|
59
|
+
animation: tt-modal-entrance 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
|
|
60
|
+
}
|
|
61
|
+
.animate-tt-modal-exit {
|
|
62
|
+
animation: tt-modal-exit 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
63
|
+
}
|
|
64
|
+
`})]})}function pc(){return o.jsxs(Li,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[o.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),o.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function xc({children:e,header:t,footer:n,className:a="",hideHeader:r=!1,hideFooter:s=!1,bare:i=!1}){return i?o.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${a}`,children:[o.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!s&&n&&o.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:n})]}):o.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 ${a}`,children:[!r&&o.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:[o.jsx(pc,{}),o.jsx("div",{className:"flex-1 flex justify-center",children:t})]}),o.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!s&&n&&o.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:n})]})}function bc({children:e,variant:t="info",size:n="md",className:a=""}){const r="inline-flex items-center font-medium",s={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"},l=`${r} ${s[t]} ${i[n]} ${a}`.trim();return o.jsx("span",{className:l,children:e})}const kc=m.forwardRef(function(t,n){const{render:a,className:r,disabled:s=!1,nativeButton:i=!0,...l}=t,{store:c}=Ji(),d=c.useState("open");function f(x){d&&c.setOpen(!1,tl(nl,x.nativeEvent))}const{getButtonProps:u,buttonRef:y}=Zi({disabled:s,native:i}),g=m.useMemo(()=>({disabled:s}),[s]);return el("button",t,{state:g,ref:[n,y],props:[{onClick:f},l,u]})});var wc={};function vc(e,t){return e==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:e===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:t}}function _c({mv:e,digit:t,height:n}){const a=uo(e,r=>{const s=(r%10+10)%10,i=(10+t-s)%10;let l=i*n;return i>5&&(l-=10*n),l});return o.jsx($e.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:a},children:t})}function Nc(e){const t=Math.round(e),n=1e-9*Math.max(1,Math.abs(e));return Math.abs(e-t)<n?t:e}function jc(e,t){const n=e/t;return Math.floor(Nc(n))}function Sc(e){const t=String(e??""),n=Array.from(t),a=n.indexOf(".");let r=n.filter((l,c)=>/\d/.test(l)&&(a===-1||c<a)).length,s=0,i=!1;return n.map(l=>{if(!/\d/.test(l))return l==="."&&(i=!0),l;if(!i){const c=10**Math.max(r-1,0);return r-=1,c}return s+=1,10**-s})}function Mc({place:e,value:t,height:n,digitStyle:a,shouldReduceMotion:r}){if(typeof e!="number"){const c=vc(e,n);return o.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:n,...c,...a},children:e})}const s=jc(t,e),i=ja(0),l=Ol(i,{stiffness:220,damping:26,mass:.8});return m.useEffect(()=>{i.set(s)},[i,s]),r?o.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...a},children:Math.abs(s)%10}):o.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...a},children:Array.from({length:10},(c,d)=>o.jsx(_c,{mv:l,digit:d,height:n},d))})}function Cc({value:e,displayValue:t,fontSize:n=72,padding:a=0,places:r,gap:s=6,borderRadius:i=4,horizontalPadding:l=0,textColor:c="inherit",fontWeight:d="inherit",containerStyle:f,counterStyle:u,digitStyle:y,gradientHeight:g=14,gradientFrom:x="rgba(255,255,255,0.95)",gradientTo:p="rgba(255,255,255,0)",topGradientStyle:b,bottomGradientStyle:k}){const v=String(t??e??""),w=m.useMemo(()=>Array.isArray(r)&&r.length?r:Sc(v),[r,v]),C=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&wc?.VITEST==="true",D=Na()||C,S=Number.isFinite(Number(e))?Math.abs(Number(e)):0,I=n+a;return D?o.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:c,fontSize:n,fontWeight:d,lineHeight:1,...f,...u},children:v}):o.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...f},children:[o.jsx("span",{style:{fontSize:n,display:"flex",gap:s,overflow:"hidden",borderRadius:i,paddingLeft:l,paddingRight:l,lineHeight:1,color:c,fontWeight:d,...u},children:w.map((N,O)=>o.jsx(Mc,{place:N,value:S,height:I,digitStyle:y,shouldReduceMotion:D},`${String(N)}-${O}`))}),o.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[o.jsx("span",{style:b??{height:g,background:`linear-gradient(to bottom, ${x}, ${p})`}}),o.jsx("span",{style:k??{height:g,background:`linear-gradient(to top, ${x}, ${p})`}})]})]})}function Dc(e){if(!Number.isFinite(e))return h("shared.placeholder.short");const t=Dn(e.toFixed(2),{decimals:2});return t==="-"?h("shared.placeholder.short"):t}function gr(e){return!Number.isFinite(e)||e<=0?null:e<.01?"<$0.01":Dn(e.toFixed(2),{decimals:2})}function yr(e){const t=Number(e);return!Number.isFinite(t)||t<=0?null:He(t,{decimals:1})}const Tc=$.memo(function({isOpen:t,onClose:n,fleetData:a=[]}){const r=m.useMemo(()=>(Array.isArray(a)?a:[]).map(i=>{const l=ze(i?.usd)??0,c=ze(i?.usage)??0,d=Array.isArray(i?.models)?i.models:[];return{label:i?.label?String(i.label):"",usdValue:l,usdLabel:gr(l),tokensLabel:yr(c),models:d.map(f=>{const u=ze(f?.usage)??0,y=ze(f?.cost)??0;return{id:f?.id?String(f.id):"",name:f?.name?String(f.name):"",tokensLabel:yr(u),costLabel:gr(y),sortCost:y}}).filter(f=>f.costLabel||f.tokensLabel).sort((f,u)=>u.sortCost-f.sortCost)}}).filter(i=>i.usdValue>0||i.models.length>0).sort((i,l)=>l.usdValue-i.usdValue),[a]),s=m.useMemo(()=>{const i=r.reduce((l,c)=>l+c.usdValue,0);return Dc(i)},[r]);return o.jsx(al,{open:t,onOpenChange:i=>{i||n?.()},children:o.jsxs(rl,{children:[o.jsx(ol,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),o.jsx(sl,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:o.jsxs(il,{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:[o.jsx(ll,{render:o.jsx("h2",{className:"sr-only"}),children:h("dashboard.cost_breakdown.title")}),o.jsx(kc,{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":h("dashboard.cost_breakdown.close"),children:o.jsx(ao,{size:16,strokeWidth:2,"aria-hidden":!0})}),o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:o.jsxs("div",{className:"px-3 py-6",children:[o.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:h("dashboard.cost_breakdown.total_label")}),o.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:s}),r.length===0?o.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):o.jsxs("div",{role:"table","aria-label":h("dashboard.cost_breakdown.title"),children:[o.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:[o.jsx("span",{role:"columnheader",children:"Model"}),o.jsx("span",{role:"columnheader",children:"Cost"})]}),r.map((i,l)=>{const c=`fleet-${l}`;return o.jsxs("div",{role:"rowgroup","aria-labelledby":c,className:l>0?"mt-5":"mt-2",children:[o.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[o.jsx("span",{id:c,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:i.label}),o.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:i.usdLabel||"—"})]}),i.models.map((d,f)=>o.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[o.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:d.name,children:d.name}),o.jsx("span",{role:"cell",className:"shrink-0 text-caption text-oai-gray-700 dark:text-oai-gray-300 tabular-nums leading-none",children:d.costLabel||""})]},d.id||`${d.name}-${f}`))]},`${i.label}-${l}`)})]})]})})]})})]})})});function Ac({projectEntries:e=[],projectLimit:t=3,onProjectLimitChange:n,copy:a,hasDetailsActual:r,dailyEmptyPrefix:s,installSyncCmd:i,dailyEmptySuffix:l,detailsColumns:c,ariaSortFor:d,toggleSort:f,sortIconFor:u,pagedDetails:y,dailyBreakdownRows:g=[],dailyBreakdownColumns:x=[],dailyBreakdownAriaSortFor:p,dailyBreakdownSortIconFor:b,dailyBreakdownDateKey:k="day",detailsDateKey:v,renderDetailDate:w,renderDailyBreakdownDate:C,renderDetailCell:D,DETAILS_PAGED_PERIODS:S,period:I,detailsPageCount:N,detailsPage:O,setDetailsPage:E}){const[F,Q]=m.useState("daily");return o.jsxs(_a,{children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[o.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[o.jsx("button",{role:"tab","aria-selected":F==="daily",type:"button",onClick:()=>Q("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${F==="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:a("dashboard.daily.title")}),o.jsx("button",{role:"tab","aria-selected":F==="projects",type:"button",onClick:()=>Q("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${F==="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:a("dashboard.projects.title")})]}),F==="projects"&&o.jsxs("select",{"aria-label":"Number of projects to display",value:t,onChange:j=>n?.(Number(j.target.value)),className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded px-2 py-1 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 focus:border-oai-brand dark:focus:border-oai-brand focus:outline-none transition-colors",children:[o.jsx("option",{value:3,children:a("dashboard.projects.limit_top_3")}),o.jsx("option",{value:6,children:a("dashboard.projects.limit_top_6")}),o.jsx("option",{value:10,children:a("dashboard.projects.limit_top_10")})]})]}),F==="projects"&&o.jsx("div",{className:"space-y-1",children:e.slice(0,t).map((j,L)=>{const B=typeof j?.project_ref=="string"?j.project_ref:"",M=j?.project_key||B||`entry-${L}`,Z=j?.billable_total_tokens??j?.total_tokens,Y=Number(Z),P=Number.isFinite(Y)?Y.toLocaleString():"—",z=j?.project_key||B.split("/").pop()||"—";return o.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg",children:[o.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300",children:(j?.project_key?.[0]||"?").toUpperCase()}),o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:z})}),o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:P})]},M)})}),F==="daily"&&o.jsxs("div",{children:[g?.length===0?o.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[s,o.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:i}),l]}):o.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:o.jsxs("table",{className:"w-full border-collapse",children:[o.jsx("thead",{className:"sticky top-0 z-10",children:o.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:x.map(j=>o.jsx("th",{"aria-sort":p?.(j.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:o.jsx("button",{type:"button",onClick:()=>f(j.key),className:"flex w-full items-center justify-start 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:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx("span",{children:j.label}),o.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:b?.(j.key)||""})]})})},j.key))})}),o.jsx("tbody",{children:g.map(j=>o.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 ${j.missing?"text-oai-gray-400 dark:text-oai-gray-400":j.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[o.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:C?C(j):w(j)}),o.jsx("td",{className:"px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:D(j,"total_tokens")}),o.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:D(j,"input_tokens")}),o.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:D(j,"output_tokens")}),o.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:D(j,"cached_input_tokens")}),o.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:D(j,"reasoning_output_tokens")}),o.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:D(j,"conversation_count")})]},String(j?.[k]||j?.day||j?.hour||j?.month||"")))})]})}),F!=="daily"&&S.has(I)&&N>1?o.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[o.jsx("button",{type:"button",onClick:()=>E(j=>Math.max(0,j-1)),disabled:O===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:a("details.pagination.prev")}),o.jsxs("span",{className:"oai-text-muted",children:[O+1," / ",N]}),o.jsx("button",{type:"button",onClick:()=>E(j=>Math.min(N-1,j+1)),disabled:O+1>=N,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:a("details.pagination.next")})]}):null]})]})}function Nn(e){return typeof e!="string"?"":e.trim()}function pr(e){const t=Nn(e);return t?t.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function Oc(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!n||typeof n!="object")continue;const a=Nn(n.tool),r=Nn(n.planType)||Nn(n.plan_type);if(!a||!r)continue;const s=pr(a)||a,i=pr(r)||r;t.set(`${a.toLowerCase()}::${r.toLowerCase()}`,{tool:s,plan:i})}return Array.from(t.values())}function Ec({period:e="month",rankLabel:t,streakDays:n,subscriptions:a=[],periodConversations:r,rolling:s,topModels:i=[],className:l=""}){const c=h("shared.placeholder.short"),d=h("shared.unit.percent"),f=t??h("identity_card.rank_placeholder"),u=Number.isFinite(Number(n))?Number(n):0,y=u?h("identity_card.streak_value",{days:u}):h("identity_card.rank_placeholder"),g=Oc(a),x={thousandSuffix:h("shared.unit.thousand_abbrev"),millionSuffix:h("shared.unit.million_abbrev"),billionSuffix:h("shared.unit.billion_abbrev")},p=v=>{if(v==null)return c;const w=He(v,x);return w==="-"?c:w},b=(()=>{switch(e){case"day":return h("stats.period.today");case"week":return h("stats.period.week");case"month":return h("stats.period.month");case"total":return h("stats.period.all");default:return h("stats.period.convs")}})(),k=i.slice(0,3);return o.jsxs(_a,{className:`h-full ${l}`,children:[o.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[o.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[o.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:p(s?.last_7d?.totals?.billable_total_tokens)}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"7d"})]}),o.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[o.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:p(s?.last_30d?.totals?.billable_total_tokens)}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"30d"})]}),o.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[o.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:p(s?.last_30d?.avg_per_active_day)}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"avg"})]}),o.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[o.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:p(r)}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:b})]})]}),k.length>0&&o.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:k.map((v,w)=>{const C=v?.name?String(v.name):c,D=v?.percent?String(v.percent):"",S=w===k.length-1,I=w+1;return o.jsxs("div",{className:`flex items-center py-2 ${S?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[o.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:I}),o.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:C,children:C}),o.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[D,d]})]},v.id||C)})}),g.length>0&&o.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:g.map((v,w)=>o.jsxs(bc,{variant:"secondary",size:"sm",children:[v.tool," ",v.plan]},`${v.tool}:${v.plan}:${w}`))}),o.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:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{children:h("identity_card.rank_label")}),o.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:f})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{children:h("identity_card.streak_label")}),o.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:y})]})]})]})}function Fc(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const Wc={},sn={};function Et(e,t){try{const a=(Wc[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return a in sn?sn[a]:xr(a,a.split(":"))}catch{if(e in sn)return sn[e];const n=e?.match(Pc);return n?xr(e,n.slice(1)):NaN}}const Pc=/([+-]\d\d):?(\d\d)?/;function xr(e,t){const n=+(t[0]||0),a=+(t[1]||0),r=+(t[2]||0)/60;return sn[e]=n*60+a>0?n*60+a+r:n*60-a-r}class nt extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Et(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),bo(this),ha(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new nt(...n,t):new nt(Date.now(),t)}withTimeZone(t){return new nt(+this,t)}getTimezoneOffset(){const t=-Et(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),ha(this),+this}[Symbol.for("constructDateFrom")](t){return new nt(+new Date(t),this.timeZone)}}const br=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!br.test(e))return;const t=e.replace(br,"$1UTC");nt.prototype[t]&&(e.startsWith("get")?nt.prototype[e]=function(){return this.internal[t]()}:(nt.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Ic(this),+this},nt.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),ha(this),+this}))});function ha(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Et(e.timeZone,e)*60))}function Ic(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),bo(e)}function bo(e){const t=Et(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),a=new Date(+e);a.setUTCHours(a.getUTCHours()-1);const r=-new Date(+e).getTimezoneOffset(),s=-new Date(+a).getTimezoneOffset(),i=r-s,l=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&l&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=r-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const d=new Date(+e);d.setUTCSeconds(0);const f=r>0?d.getSeconds():(d.getSeconds()-60)%60,u=Math.round(-(Et(e.timeZone,e)*60))%60;(u||f)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+f));const y=Et(e.timeZone,e),g=y>0?Math.floor(y):Math.ceil(y),p=-new Date(+e).getTimezoneOffset()-g,b=g!==n,k=p-c;if(b&&k){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+k);const v=Et(e.timeZone,e),w=v>0?Math.floor(v):Math.ceil(v),C=g-w;C&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+C),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+C))}}class Le extends nt{static tz(t,...n){return n.length?new Le(...n,t):new Le(Date.now(),t)}toISOString(){const[t,n,a]=this.tzComponents(),r=`${t}${n}:${a}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,a,r]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${a} ${n} ${r}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,a,r]=this.tzComponents();return`${t} GMT${n}${a}${r} (${Fc(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",a=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),r=String(Math.abs(t)%60).padStart(2,"0");return[n,a,r]}withTimeZone(t){return new Le(+this,t)}[Symbol.for("constructDateFrom")](t){return new Le(+new Date(t),this.timeZone)}}const ko=6048e5,Lc=864e5,kr=Symbol.for("constructDateFrom");function Ee(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&kr in e?e[kr](t):e instanceof Date?new e.constructor(t):new Date(t)}function be(e,t){return Ee(t||e,e)}function wo(e,t,n){const a=be(e,n?.in);return isNaN(t)?Ee(e,NaN):(t&&a.setDate(a.getDate()+t),a)}function vo(e,t,n){const a=be(e,n?.in);if(isNaN(t))return Ee(e,NaN);if(!t)return a;const r=a.getDate(),s=Ee(e,a.getTime());s.setMonth(a.getMonth()+t+1,0);const i=s.getDate();return r>=i?s:(a.setFullYear(s.getFullYear(),s.getMonth(),r),a)}let $c={};function dn(){return $c}function Vt(e,t){const n=dn(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=be(e,t?.in),s=r.getDay(),i=(s<a?7:0)+s-a;return r.setDate(r.getDate()-i),r.setHours(0,0,0,0),r}function ln(e,t){return Vt(e,{...t,weekStartsOn:1})}function _o(e,t){const n=be(e,t?.in),a=n.getFullYear(),r=Ee(n,0);r.setFullYear(a+1,0,4),r.setHours(0,0,0,0);const s=ln(r),i=Ee(n,0);i.setFullYear(a,0,4),i.setHours(0,0,0,0);const l=ln(i);return n.getTime()>=s.getTime()?a+1:n.getTime()>=l.getTime()?a:a-1}function wr(e){const t=be(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Qt(e,...t){const n=Ee.bind(null,t.find(a=>typeof a=="object"));return t.map(n)}function cn(e,t){const n=be(e,t?.in);return n.setHours(0,0,0,0),n}function Sa(e,t,n){const[a,r]=Qt(n?.in,e,t),s=cn(a),i=cn(r),l=+s-wr(s),c=+i-wr(i);return Math.round((l-c)/Lc)}function Rc(e,t){const n=_o(e,t),a=Ee(e,0);return a.setFullYear(n,0,4),a.setHours(0,0,0,0),ln(a)}function Bc(e,t,n){return wo(e,t*7,n)}function Yc(e,t,n){return vo(e,t*12,n)}function zc(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Ee.bind(null,r));const s=be(r,a);(!n||n<s||isNaN(+s))&&(n=s)}),Ee(a,n||NaN)}function Hc(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Ee.bind(null,r));const s=be(r,a);(!n||n>s||isNaN(+s))&&(n=s)}),Ee(a,n||NaN)}function Uc(e,t,n){const[a,r]=Qt(n?.in,e,t);return+cn(a)==+cn(r)}function No(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function qc(e){return!(!No(e)&&typeof e!="number"||isNaN(+be(e)))}function jo(e,t,n){const[a,r]=Qt(n?.in,e,t),s=a.getFullYear()-r.getFullYear(),i=a.getMonth()-r.getMonth();return s*12+i}function Gc(e,t){const n=be(e,t?.in),a=n.getMonth();return n.setFullYear(n.getFullYear(),a+1,0),n.setHours(23,59,59,999),n}function So(e,t){const[n,a]=Qt(e,t.start,t.end);return{start:n,end:a}}function Vc(e,t){const{start:n,end:a}=So(t?.in,e);let r=+n>+a;const s=r?+n:+a,i=r?a:n;i.setHours(0,0,0,0),i.setDate(1);let l=1;const c=[];for(;+i<=s;)c.push(Ee(n,i)),i.setMonth(i.getMonth()+l);return r?c.reverse():c}function Kc(e,t){const n=be(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Xc(e,t){const n=be(e,t?.in),a=n.getFullYear();return n.setFullYear(a+1,0,0),n.setHours(23,59,59,999),n}function Mo(e,t){const n=be(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Qc(e,t){const{start:n,end:a}=So(t?.in,e);let r=+n>+a;const s=r?+n:+a,i=r?a:n;i.setHours(0,0,0,0),i.setMonth(0,1);let l=1;const c=[];for(;+i<=s;)c.push(Ee(n,i)),i.setFullYear(i.getFullYear()+l);return r?c.reverse():c}function Co(e,t){const n=dn(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=be(e,t?.in),s=r.getDay(),i=(s<a?-7:0)+6-(s-a);return r.setDate(r.getDate()+i),r.setHours(23,59,59,999),r}function Jc(e,t){return Co(e,{...t,weekStartsOn:1})}const Zc={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ed=(e,t,n)=>{let a;const r=Zc[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function Jn(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const td={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},nd={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ad={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},rd={date:Jn({formats:td,defaultWidth:"full"}),time:Jn({formats:nd,defaultWidth:"full"}),dateTime:Jn({formats:ad,defaultWidth:"full"})},od={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},sd=(e,t,n,a)=>od[e];function nn(e){return(t,n)=>{const a=n?.context?String(n.context):"standalone";let r;if(a==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,l=n?.width?String(n.width):i;r=e.formattingValues[l]||e.formattingValues[i]}else{const i=e.defaultWidth,l=n?.width?String(n.width):e.defaultWidth;r=e.values[l]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return r[s]}}const id={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ld={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},cd={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},dd={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ud={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},fd={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},md=(e,t)=>{const n=Number(e),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},hd={ordinalNumber:md,era:nn({values:id,defaultWidth:"wide"}),quarter:nn({values:ld,defaultWidth:"wide",argumentCallback:e=>e-1}),month:nn({values:cd,defaultWidth:"wide"}),day:nn({values:dd,defaultWidth:"wide"}),dayPeriod:nn({values:ud,defaultWidth:"wide",formattingValues:fd,defaultFormattingWidth:"wide"})};function an(e){return(t,n={})=>{const a=n.width,r=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],s=t.match(r);if(!s)return null;const i=s[0],l=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?yd(l,u=>u.test(i)):gd(l,u=>u.test(i));let d;d=e.valueCallback?e.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const f=t.slice(i.length);return{value:d,rest:f}}}function gd(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function yd(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function pd(e){return(t,n={})=>{const a=t.match(e.matchPattern);if(!a)return null;const r=a[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const l=t.slice(r.length);return{value:i,rest:l}}}const xd=/^(\d+)(th|st|nd|rd)?/i,bd=/\d+/i,kd={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},wd={any:[/^b/i,/^(a|c)/i]},vd={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},_d={any:[/1/i,/2/i,/3/i,/4/i]},Nd={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},jd={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Sd={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Md={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Cd={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Dd={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Td={ordinalNumber:pd({matchPattern:xd,parsePattern:bd,valueCallback:e=>parseInt(e,10)}),era:an({matchPatterns:kd,defaultMatchWidth:"wide",parsePatterns:wd,defaultParseWidth:"any"}),quarter:an({matchPatterns:vd,defaultMatchWidth:"wide",parsePatterns:_d,defaultParseWidth:"any",valueCallback:e=>e+1}),month:an({matchPatterns:Nd,defaultMatchWidth:"wide",parsePatterns:jd,defaultParseWidth:"any"}),day:an({matchPatterns:Sd,defaultMatchWidth:"wide",parsePatterns:Md,defaultParseWidth:"any"}),dayPeriod:an({matchPatterns:Cd,defaultMatchWidth:"any",parsePatterns:Dd,defaultParseWidth:"any"})},Ut={code:"en-US",formatDistance:ed,formatLong:rd,formatRelative:sd,localize:hd,match:Td,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Ad(e,t){const n=be(e,t?.in);return Sa(n,Mo(n))+1}function Ma(e,t){const n=be(e,t?.in),a=+ln(n)-+Rc(n);return Math.round(a/ko)+1}function Do(e,t){const n=be(e,t?.in),a=n.getFullYear(),r=dn(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,i=Ee(t?.in||e,0);i.setFullYear(a+1,0,s),i.setHours(0,0,0,0);const l=Vt(i,t),c=Ee(t?.in||e,0);c.setFullYear(a,0,s),c.setHours(0,0,0,0);const d=Vt(c,t);return+n>=+l?a+1:+n>=+d?a:a-1}function Od(e,t){const n=dn(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=Do(e,t),s=Ee(t?.in||e,0);return s.setFullYear(r,0,a),s.setHours(0,0,0,0),Vt(s,t)}function Ca(e,t){const n=be(e,t?.in),a=+Vt(n,t)-+Od(n,t);return Math.round(a/ko)+1}function ye(e,t){const n=e<0?"-":"",a=Math.abs(e).toString().padStart(t,"0");return n+a}const wt={y(e,t){const n=e.getFullYear(),a=n>0?n:1-n;return ye(t==="yy"?a%100:a,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ye(n+1,2)},d(e,t){return ye(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ye(e.getHours()%12||12,t.length)},H(e,t){return ye(e.getHours(),t.length)},m(e,t){return ye(e.getMinutes(),t.length)},s(e,t){return ye(e.getSeconds(),t.length)},S(e,t){const n=t.length,a=e.getMilliseconds(),r=Math.trunc(a*Math.pow(10,n-3));return ye(r,t.length)}},zt={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},vr={G:function(e,t,n){const a=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});default:return n.era(a,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const a=e.getFullYear(),r=a>0?a:1-a;return n.ordinalNumber(r,{unit:"year"})}return wt.y(e,t)},Y:function(e,t,n,a){const r=Do(e,a),s=r>0?r:1-r;if(t==="YY"){const i=s%100;return ye(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ye(s,t.length)},R:function(e,t){const n=_o(e);return ye(n,t.length)},u:function(e,t){const n=e.getFullYear();return ye(n,t.length)},Q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return ye(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return ye(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(e,t,n){const a=e.getMonth();switch(t){case"M":case"MM":return wt.M(e,t);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(e,t,n){const a=e.getMonth();switch(t){case"L":return String(a+1);case"LL":return ye(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(e,t,n,a){const r=Ca(e,a);return t==="wo"?n.ordinalNumber(r,{unit:"week"}):ye(r,t.length)},I:function(e,t,n){const a=Ma(e);return t==="Io"?n.ordinalNumber(a,{unit:"week"}):ye(a,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):wt.d(e,t)},D:function(e,t,n){const a=Ad(e);return t==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):ye(a,t.length)},E:function(e,t,n){const a=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(e,t,n,a){const r=e.getDay(),s=(r-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ye(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,n,a){const r=e.getDay(),s=(r-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ye(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(r,{width:"narrow",context:"standalone"});case"cccccc":return n.day(r,{width:"short",context:"standalone"});default:return n.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,n){const a=e.getDay(),r=a===0?7:a;switch(t){case"i":return String(r);case"ii":return ye(r,t.length);case"io":return n.ordinalNumber(r,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(e,t,n){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){const a=e.getHours();let r;switch(a===12?r=zt.noon:a===0?r=zt.midnight:r=a/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){const a=e.getHours();let r;switch(a>=17?r=zt.evening:a>=12?r=zt.afternoon:a>=4?r=zt.morning:r=zt.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let a=e.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return wt.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):wt.H(e,t)},K:function(e,t,n){const a=e.getHours()%12;return t==="Ko"?n.ordinalNumber(a,{unit:"hour"}):ye(a,t.length)},k:function(e,t,n){let a=e.getHours();return a===0&&(a=24),t==="ko"?n.ordinalNumber(a,{unit:"hour"}):ye(a,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):wt.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):wt.s(e,t)},S:function(e,t){return wt.S(e,t)},X:function(e,t,n){const a=e.getTimezoneOffset();if(a===0)return"Z";switch(t){case"X":return Nr(a);case"XXXX":case"XX":return At(a);default:return At(a,":")}},x:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"x":return Nr(a);case"xxxx":case"xx":return At(a);default:return At(a,":")}},O:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+_r(a,":");default:return"GMT"+At(a,":")}},z:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+_r(a,":");default:return"GMT"+At(a,":")}},t:function(e,t,n){const a=Math.trunc(+e/1e3);return ye(a,t.length)},T:function(e,t,n){return ye(+e,t.length)}};function _r(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),r=Math.trunc(a/60),s=a%60;return s===0?n+String(r):n+String(r)+t+ye(s,2)}function Nr(e,t){return e%60===0?(e>0?"-":"+")+ye(Math.abs(e)/60,2):At(e,t)}function At(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),r=ye(Math.trunc(a/60),2),s=ye(a%60,2);return n+r+t+s}const jr=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},To=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Ed=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],a=n[1],r=n[2];if(!r)return jr(e,t);let s;switch(a){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",jr(a,t)).replace("{{time}}",To(r,t))},Fd={p:To,P:Ed},Wd=/^D+$/,Pd=/^Y+$/,Id=["D","DD","YY","YYYY"];function Ld(e){return Wd.test(e)}function $d(e){return Pd.test(e)}function Rd(e,t,n){const a=Bd(e,t,n);if(console.warn(a),Id.includes(e))throw new RangeError(a)}function Bd(e,t,n){const a=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Yd=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,zd=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Hd=/^'([^]*?)'?$/,Ud=/''/g,qd=/[a-zA-Z]/;function at(e,t,n){const a=dn(),r=n?.locale??a.locale??Ut,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,l=be(e,n?.in);if(!qc(l))throw new RangeError("Invalid time value");let c=t.match(zd).map(f=>{const u=f[0];if(u==="p"||u==="P"){const y=Fd[u];return y(f,r.formatLong)}return f}).join("").match(Yd).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const u=f[0];if(u==="'")return{isToken:!1,value:Gd(f)};if(vr[u])return{isToken:!0,value:f};if(u.match(qd))throw new RangeError("Format string contains an unescaped latin alphabet character `"+u+"`");return{isToken:!1,value:f}});r.localize.preprocessor&&(c=r.localize.preprocessor(l,c));const d={firstWeekContainsDate:s,weekStartsOn:i,locale:r};return c.map(f=>{if(!f.isToken)return f.value;const u=f.value;(!n?.useAdditionalWeekYearTokens&&$d(u)||!n?.useAdditionalDayOfYearTokens&&Ld(u))&&Rd(u,t,String(e));const y=vr[u[0]];return y(l,u,r.localize,d)}).join("")}function Gd(e){const t=e.match(Hd);return t?t[1].replace(Ud,"'"):e}function Vd(e,t){const n=be(e,t?.in),a=n.getFullYear(),r=n.getMonth(),s=Ee(n,0);return s.setFullYear(a,r+1,0),s.setHours(0,0,0,0),s.getDate()}function Kd(e,t){return be(e,t?.in).getMonth()}function Xd(e,t){return be(e,t?.in).getFullYear()}function Qd(e,t){return+be(e)>+be(t)}function Jd(e,t){return+be(e)<+be(t)}function Zd(e,t,n){const[a,r]=Qt(n?.in,e,t);return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function eu(e,t,n){const[a,r]=Qt(n?.in,e,t);return a.getFullYear()===r.getFullYear()}function tu(e,t,n){const a=be(e,n?.in),r=a.getFullYear(),s=a.getDate(),i=Ee(e,0);i.setFullYear(r,t,15),i.setHours(0,0,0,0);const l=Vd(i);return a.setMonth(t,Math.min(s,l)),a}function nu(e,t,n){const a=be(e,n?.in);return isNaN(+a)?Ee(e,NaN):(a.setFullYear(t),a)}const Sr=5,au=4;function ru(e,t){const n=t.startOfMonth(e),a=n.getDay()>0?n.getDay():7,r=t.addDays(e,-a+1),s=t.addDays(r,Sr*7-1);return t.getMonth(e)===t.getMonth(s)?Sr:au}function Ao(e,t){const n=t.startOfMonth(e),a=n.getDay();return a===1?n:a===0?t.addDays(n,-6):t.addDays(n,-1*(a-1))}function ou(e,t){const n=Ao(e,t),a=ru(e,t);return t.addDays(n,a*7-1)}const Oo={...Ut,labels:{labelDayButton:(e,t,n,a)=>{let r;a&&typeof a.format=="function"?r=a.format.bind(a):r=(i,l)=>at(i,l,{locale:Ut,...n});let s=r(e,"PPPP");return t.today&&(s=`Today, ${s}`),t.selected&&(s=`${s}, selected`),s},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let a;return n&&typeof n.format=="function"?a=n.format.bind(n):a=(r,s)=>at(r,s,{locale:Ut,...t}),a(e,"LLLL yyyy")},labelGridcell:(e,t,n,a)=>{let r;a&&typeof a.format=="function"?r=a.format.bind(a):r=(i,l)=>at(i,l,{locale:Ut,...n});let s=r(e,"PPPP");return t?.today&&(s=`Today, ${s}`),s},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let a;return n&&typeof n.format=="function"?a=n.format.bind(n):a=(r,s)=>at(r,s,{locale:Ut,...t}),a(e,"cccc")}}};class Ue{constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?Le.tz(this.options.timeZone):new this.Date,this.newDate=(a,r,s)=>this.overrides?.newDate?this.overrides.newDate(a,r,s):this.options.timeZone?new Le(a,r,s,this.options.timeZone):new Date(a,r,s),this.addDays=(a,r)=>this.overrides?.addDays?this.overrides.addDays(a,r):wo(a,r),this.addMonths=(a,r)=>this.overrides?.addMonths?this.overrides.addMonths(a,r):vo(a,r),this.addWeeks=(a,r)=>this.overrides?.addWeeks?this.overrides.addWeeks(a,r):Bc(a,r),this.addYears=(a,r)=>this.overrides?.addYears?this.overrides.addYears(a,r):Yc(a,r),this.differenceInCalendarDays=(a,r)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(a,r):Sa(a,r),this.differenceInCalendarMonths=(a,r)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(a,r):jo(a,r),this.eachMonthOfInterval=a=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(a):Vc(a),this.eachYearOfInterval=a=>{const r=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(a):Qc(a),s=new Set(r.map(l=>this.getYear(l)));if(s.size===r.length)return r;const i=[];return s.forEach(l=>{i.push(new Date(l,0,1))}),i},this.endOfBroadcastWeek=a=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(a):ou(a,this),this.endOfISOWeek=a=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(a):Jc(a),this.endOfMonth=a=>this.overrides?.endOfMonth?this.overrides.endOfMonth(a):Gc(a),this.endOfWeek=(a,r)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(a,r):Co(a,this.options),this.endOfYear=a=>this.overrides?.endOfYear?this.overrides.endOfYear(a):Xc(a),this.format=(a,r,s)=>{const i=this.overrides?.format?this.overrides.format(a,r,this.options):at(a,r,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(i):i},this.getISOWeek=a=>this.overrides?.getISOWeek?this.overrides.getISOWeek(a):Ma(a),this.getMonth=(a,r)=>this.overrides?.getMonth?this.overrides.getMonth(a,this.options):Kd(a,this.options),this.getYear=(a,r)=>this.overrides?.getYear?this.overrides.getYear(a,this.options):Xd(a,this.options),this.getWeek=(a,r)=>this.overrides?.getWeek?this.overrides.getWeek(a,this.options):Ca(a,this.options),this.isAfter=(a,r)=>this.overrides?.isAfter?this.overrides.isAfter(a,r):Qd(a,r),this.isBefore=(a,r)=>this.overrides?.isBefore?this.overrides.isBefore(a,r):Jd(a,r),this.isDate=a=>this.overrides?.isDate?this.overrides.isDate(a):No(a),this.isSameDay=(a,r)=>this.overrides?.isSameDay?this.overrides.isSameDay(a,r):Uc(a,r),this.isSameMonth=(a,r)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(a,r):Zd(a,r),this.isSameYear=(a,r)=>this.overrides?.isSameYear?this.overrides.isSameYear(a,r):eu(a,r),this.max=a=>this.overrides?.max?this.overrides.max(a):zc(a),this.min=a=>this.overrides?.min?this.overrides.min(a):Hc(a),this.setMonth=(a,r)=>this.overrides?.setMonth?this.overrides.setMonth(a,r):tu(a,r),this.setYear=(a,r)=>this.overrides?.setYear?this.overrides.setYear(a,r):nu(a,r),this.startOfBroadcastWeek=(a,r)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(a,this):Ao(a,this),this.startOfDay=a=>this.overrides?.startOfDay?this.overrides.startOfDay(a):cn(a),this.startOfISOWeek=a=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(a):ln(a),this.startOfMonth=a=>this.overrides?.startOfMonth?this.overrides.startOfMonth(a):Kc(a),this.startOfWeek=(a,r)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(a,this.options):Vt(a,this.options),this.startOfYear=a=>this.overrides?.startOfYear?this.overrides.startOfYear(a):Mo(a),this.options={locale:Oo,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),a={};for(let r=0;r<10;r++)a[r.toString()]=n.format(r);return a}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,a=>n[a]||a)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){const t=this.options.locale?.code;return t&&Ue.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:a,numerals:r}=this.options,s=n?.code;if(s&&Ue.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:a,numberingSystem:r}).format(t)}catch{}const i=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,i)}}Ue.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const rt=new Ue;class Eo{constructor(t,n,a=rt){this.date=t,this.displayMonth=n,this.outside=!!(n&&!a.isSameMonth(t,n)),this.dateLib=a,this.isoDate=a.format(t,"yyyy-MM-dd"),this.displayMonthId=a.format(n,"yyyy-MM"),this.dateMonthId=a.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class su{constructor(t,n){this.date=t,this.weeks=n}}class iu{constructor(t,n){this.days=n,this.weekNumber=t}}function lu(e){return $.createElement("button",{...e})}function cu(e){return $.createElement("span",{...e})}function du(e){const{size:t=24,orientation:n="left",className:a}=e;return $.createElement("svg",{className:a,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&$.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&$.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&$.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&$.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function uu(e){const{day:t,modifiers:n,...a}=e;return $.createElement("td",{...a})}function fu(e){const{day:t,modifiers:n,...a}=e,r=$.useRef(null);return $.useEffect(()=>{n.focused&&r.current?.focus()},[n.focused]),$.createElement("button",{ref:r,...a})}var X;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(X||(X={}));var Me;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(Me||(Me={}));var Qe;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Qe||(Qe={}));var Ye;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Ye||(Ye={}));function mu(e){const{options:t,className:n,components:a,classNames:r,...s}=e,i=[r[X.Dropdown],n].join(" "),l=t?.find(({value:c})=>c===s.value);return $.createElement("span",{"data-disabled":s.disabled,className:r[X.DropdownRoot]},$.createElement(a.Select,{className:i,...s},t?.map(({value:c,label:d,disabled:f})=>$.createElement(a.Option,{key:c,value:c,disabled:f},d))),$.createElement("span",{className:r[X.CaptionLabel],"aria-hidden":!0},l?.label,$.createElement(a.Chevron,{orientation:"down",size:18,className:r[X.Chevron]})))}function hu(e){return $.createElement("div",{...e})}function gu(e){return $.createElement("div",{...e})}function yu(e){const{calendarMonth:t,displayIndex:n,...a}=e;return $.createElement("div",{...a},e.children)}function pu(e){const{calendarMonth:t,displayIndex:n,...a}=e;return $.createElement("div",{...a})}function xu(e){return $.createElement("table",{...e})}function bu(e){return $.createElement("div",{...e})}const Fo=m.createContext(void 0);function un(){const e=m.useContext(Fo);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function ku(e){const{components:t}=un();return $.createElement(t.Dropdown,{...e})}function wu(e){const{onPreviousClick:t,onNextClick:n,previousMonth:a,nextMonth:r,...s}=e,{components:i,classNames:l,labels:{labelPrevious:c,labelNext:d}}=un(),f=m.useCallback(y=>{r&&n?.(y)},[r,n]),u=m.useCallback(y=>{a&&t?.(y)},[a,t]);return $.createElement("nav",{...s},$.createElement(i.PreviousMonthButton,{type:"button",className:l[X.PreviousMonthButton],tabIndex:a?void 0:-1,"aria-disabled":a?void 0:!0,"aria-label":c(a),onClick:u},$.createElement(i.Chevron,{disabled:a?void 0:!0,className:l[X.Chevron],orientation:"left"})),$.createElement(i.NextMonthButton,{type:"button",className:l[X.NextMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":d(r),onClick:f},$.createElement(i.Chevron,{disabled:r?void 0:!0,orientation:"right",className:l[X.Chevron]})))}function vu(e){const{components:t}=un();return $.createElement(t.Button,{...e})}function _u(e){return $.createElement("option",{...e})}function Nu(e){const{components:t}=un();return $.createElement(t.Button,{...e})}function ju(e){const{rootRef:t,...n}=e;return $.createElement("div",{...n,ref:t})}function Su(e){return $.createElement("select",{...e})}function Mu(e){const{week:t,...n}=e;return $.createElement("tr",{...n})}function Cu(e){return $.createElement("th",{...e})}function Du(e){return $.createElement("thead",{"aria-hidden":!0},$.createElement("tr",{...e}))}function Tu(e){const{week:t,...n}=e;return $.createElement("th",{...n})}function Au(e){return $.createElement("th",{...e})}function Ou(e){return $.createElement("tbody",{...e})}function Eu(e){const{components:t}=un();return $.createElement(t.Dropdown,{...e})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,Button:lu,CaptionLabel:cu,Chevron:du,Day:uu,DayButton:fu,Dropdown:mu,DropdownNav:hu,Footer:gu,Month:yu,MonthCaption:pu,MonthGrid:xu,Months:bu,MonthsDropdown:ku,Nav:wu,NextMonthButton:vu,Option:_u,PreviousMonthButton:Nu,Root:ju,Select:Su,Week:Mu,WeekNumber:Tu,WeekNumberHeader:Au,Weekday:Cu,Weekdays:Du,Weeks:Ou,YearsDropdown:Eu},Symbol.toStringTag,{value:"Module"}));function mt(e,t,n=!1,a=rt){let{from:r,to:s}=e;const{differenceInCalendarDays:i,isSameDay:l}=a;return r&&s?(i(s,r)<0&&([r,s]=[s,r]),i(t,r)>=(n?1:0)&&i(s,t)>=(n?1:0)):!n&&s?l(s,t):!n&&r?l(r,t):!1}function Da(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function Tn(e){return!!(e&&typeof e=="object"&&"from"in e)}function Ta(e){return!!(e&&typeof e=="object"&&"after"in e)}function Aa(e){return!!(e&&typeof e=="object"&&"before"in e)}function Wo(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function Po(e,t){return Array.isArray(e)&&e.every(t.isDate)}function ht(e,t,n=rt){const a=Array.isArray(t)?t:[t],{isSameDay:r,differenceInCalendarDays:s,isAfter:i}=n;return a.some(l=>{if(typeof l=="boolean")return l;if(n.isDate(l))return r(e,l);if(Po(l,n))return l.some(c=>r(e,c));if(Tn(l))return mt(l,e,!1,n);if(Wo(l))return Array.isArray(l.dayOfWeek)?l.dayOfWeek.includes(e.getDay()):l.dayOfWeek===e.getDay();if(Da(l)){const c=s(l.before,e),d=s(l.after,e),f=c>0,u=d<0;return i(l.before,l.after)?u&&f:f||u}return Ta(l)?s(e,l.after)>0:Aa(l)?s(l.before,e)>0:typeof l=="function"?l(e):!1})}function Wu(e,t,n,a,r){const{disabled:s,hidden:i,modifiers:l,showOutsideDays:c,broadcastCalendar:d,today:f=r.today()}=t,{isSameDay:u,isSameMonth:y,startOfMonth:g,isBefore:x,endOfMonth:p,isAfter:b}=r,k=n&&g(n),v=a&&p(a),w={[Me.focused]:[],[Me.outside]:[],[Me.disabled]:[],[Me.hidden]:[],[Me.today]:[]},C={};for(const D of e){const{date:S,displayMonth:I}=D,N=!!(I&&!y(S,I)),O=!!(k&&x(S,k)),E=!!(v&&b(S,v)),F=!!(s&&ht(S,s,r)),Q=!!(i&&ht(S,i,r))||O||E||!d&&!c&&N||d&&c===!1&&N,j=u(S,f);N&&w.outside.push(D),F&&w.disabled.push(D),Q&&w.hidden.push(D),j&&w.today.push(D),l&&Object.keys(l).forEach(L=>{const B=l?.[L];B&&ht(S,B,r)&&(C[L]?C[L].push(D):C[L]=[D])})}return D=>{const S={[Me.focused]:!1,[Me.disabled]:!1,[Me.hidden]:!1,[Me.outside]:!1,[Me.today]:!1},I={};for(const N in w){const O=w[N];S[N]=O.some(E=>E===D)}for(const N in C)I[N]=C[N].some(O=>O===D);return{...S,...I}}}function Pu(e,t,n={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[s])=>(n[s]?r.push(n[s]):t[Me[s]]?r.push(t[Me[s]]):t[Qe[s]]&&r.push(t[Qe[s]]),r),[t[X.Day]])}function Iu(e){return{...Fu,...e}}function Lu(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,a])=>{n.startsWith("data-")&&(t[n]=a)}),t}function $u(){const e={};for(const t in X)e[X[t]]=`rdp-${X[t]}`;for(const t in Me)e[Me[t]]=`rdp-${Me[t]}`;for(const t in Qe)e[Qe[t]]=`rdp-${Qe[t]}`;for(const t in Ye)e[Ye[t]]=`rdp-${Ye[t]}`;return e}function Io(e,t,n){return(n??new Ue(t)).formatMonthYear(e)}const Ru=Io;function Bu(e,t,n){return(n??new Ue(t)).format(e,"d")}function Yu(e,t=rt){return t.format(e,"LLLL")}function zu(e,t,n){return(n??new Ue(t)).format(e,"cccccc")}function Hu(e,t=rt){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function Uu(){return""}function Lo(e,t=rt){return t.format(e,"yyyy")}const qu=Lo,Gu=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Io,formatDay:Bu,formatMonthCaption:Ru,formatMonthDropdown:Yu,formatWeekNumber:Hu,formatWeekNumberHeader:Uu,formatWeekdayName:zu,formatYearCaption:qu,formatYearDropdown:Lo},Symbol.toStringTag,{value:"Module"}));function Vu(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...Gu,...e}}function Oa(e,t,n,a){let r=(a??new Ue(n)).format(e,"PPPP");return t.today&&(r=`Today, ${r}`),t.selected&&(r=`${r}, selected`),r}const Ku=Oa;function Ea(e,t,n){return(n??new Ue(t)).formatMonthYear(e)}const Xu=Ea;function $o(e,t,n,a){let r=(a??new Ue(n)).format(e,"PPPP");return t?.today&&(r=`Today, ${r}`),r}function Ro(e){return"Choose the Month"}function Bo(){return""}const Qu="Go to the Next Month";function Yo(e,t){return Qu}function zo(e){return"Go to the Previous Month"}function Ho(e,t,n){return(n??new Ue(t)).format(e,"cccc")}function Uo(e,t){return`Week ${e}`}function qo(e){return"Week Number"}function Go(e){return"Choose the Year"}const Ju=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:Xu,labelDay:Ku,labelDayButton:Oa,labelGrid:Ea,labelGridcell:$o,labelMonthDropdown:Ro,labelNav:Bo,labelNext:Yo,labelPrevious:zo,labelWeekNumber:Uo,labelWeekNumberHeader:qo,labelWeekday:Ho,labelYearDropdown:Go},Symbol.toStringTag,{value:"Module"})),Xe=(e,t,n)=>t||(n?typeof n=="function"?n:(...a)=>n:e);function Zu(e,t){const n=t.locale?.labels??{};return{...Ju,...e??{},labelDayButton:Xe(Oa,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Xe(Ro,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Xe(Yo,e?.labelNext,n.labelNext),labelPrevious:Xe(zo,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Xe(Uo,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Xe(Go,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Xe(Ea,e?.labelGrid,n.labelGrid),labelGridcell:Xe($o,e?.labelGridcell,n.labelGridcell),labelNav:Xe(Bo,e?.labelNav,n.labelNav),labelWeekNumberHeader:Xe(qo,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Xe(Ho,e?.labelWeekday,n.labelWeekday)}}function ef(e,t,n,a,r){const{startOfMonth:s,startOfYear:i,endOfYear:l,eachMonthOfInterval:c,getMonth:d}=r;return c({start:i(e),end:l(e)}).map(y=>{const g=a.formatMonthDropdown(y,r),x=d(y),p=t&&y<s(t)||n&&y>s(n)||!1;return{value:x,label:g,disabled:p}})}function tf(e,t={},n={}){let a={...t?.[X.Day]};return Object.entries(e).filter(([,r])=>r===!0).forEach(([r])=>{a={...a,...n?.[r]}}),a}function nf(e,t,n,a){const r=a??e.today(),s=n?e.startOfBroadcastWeek(r,e):t?e.startOfISOWeek(r):e.startOfWeek(r),i=[];for(let l=0;l<7;l++){const c=e.addDays(s,l);i.push(c)}return i}function af(e,t,n,a,r=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:i,eachYearOfInterval:l,getYear:c}=a,d=s(e),f=i(t),u=l({start:d,end:f});return r&&u.reverse(),u.map(y=>{const g=n.formatYearDropdown(y,a);return{value:c(y),label:g,disabled:!1}})}function rf(e,t={}){const{weekStartsOn:n,locale:a}=t,r=n??a?.options?.weekStartsOn??0,s=l=>{const c=typeof l=="number"||typeof l=="string"?new Date(l):l;return new Le(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,e)},i=l=>{const c=s(l);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>s(Le.tz(e)),newDate:(l,c,d)=>new Le(l,c,d,12,0,0,e),startOfDay:l=>s(l),startOfWeek:(l,c)=>{const d=s(l),f=c?.weekStartsOn??r,u=(d.getDay()-f+7)%7;return d.setDate(d.getDate()-u),d},startOfISOWeek:l=>{const c=s(l),d=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-d),c},startOfMonth:l=>{const c=s(l);return c.setDate(1),c},startOfYear:l=>{const c=s(l);return c.setMonth(0,1),c},endOfWeek:(l,c)=>{const d=s(l),y=(((c?.weekStartsOn??r)+6)%7-d.getDay()+7)%7;return d.setDate(d.getDate()+y),d},endOfISOWeek:l=>{const c=s(l),d=(7-c.getDay())%7;return c.setDate(c.getDate()+d),c},endOfMonth:l=>{const c=s(l);return c.setMonth(c.getMonth()+1,0),c},endOfYear:l=>{const c=s(l);return c.setMonth(11,31),c},eachMonthOfInterval:l=>{const c=s(l.start),d=s(l.end),f=[],u=new Le(c.getFullYear(),c.getMonth(),1,12,0,0,e),y=d.getFullYear()*12+d.getMonth();for(;u.getFullYear()*12+u.getMonth()<=y;)f.push(new Le(u,e)),u.setMonth(u.getMonth()+1,1);return f},addDays:(l,c)=>{const d=s(l);return d.setDate(d.getDate()+c),d},addWeeks:(l,c)=>{const d=s(l);return d.setDate(d.getDate()+c*7),d},addMonths:(l,c)=>{const d=s(l);return d.setMonth(d.getMonth()+c),d},addYears:(l,c)=>{const d=s(l);return d.setFullYear(d.getFullYear()+c),d},eachYearOfInterval:l=>{const c=s(l.start),d=s(l.end),f=[],u=new Le(c.getFullYear(),0,1,12,0,0,e);for(;u.getFullYear()<=d.getFullYear();)f.push(new Le(u,e)),u.setFullYear(u.getFullYear()+1,0,1);return f},getWeek:(l,c)=>{const d=i(l);return Ca(d,{weekStartsOn:c?.weekStartsOn??r,firstWeekContainsDate:c?.firstWeekContainsDate??a?.options?.firstWeekContainsDate??1})},getISOWeek:l=>{const c=i(l);return Ma(c)},differenceInCalendarDays:(l,c)=>{const d=i(l),f=i(c);return Sa(d,f)},differenceInCalendarMonths:(l,c)=>{const d=i(l),f=i(c);return jo(d,f)}}}const fn=e=>e instanceof HTMLElement?e:null,Zn=e=>[...e.querySelectorAll("[data-animated-month]")??[]],of=e=>fn(e.querySelector("[data-animated-month]")),ea=e=>fn(e.querySelector("[data-animated-caption]")),ta=e=>fn(e.querySelector("[data-animated-weeks]")),sf=e=>fn(e.querySelector("[data-animated-nav]")),lf=e=>fn(e.querySelector("[data-animated-weekdays]"));function cf(e,t,{classNames:n,months:a,focused:r,dateLib:s}){const i=m.useRef(null),l=m.useRef(a),c=m.useRef(!1);m.useLayoutEffect(()=>{const d=l.current;if(l.current=a,!t||!e.current||!(e.current instanceof HTMLElement)||a.length===0||d.length===0||a.length!==d.length)return;const f=s.isSameMonth(a[0].date,d[0].date),u=s.isAfter(a[0].date,d[0].date),y=u?n[Ye.caption_after_enter]:n[Ye.caption_before_enter],g=u?n[Ye.weeks_after_enter]:n[Ye.weeks_before_enter],x=i.current,p=e.current.cloneNode(!0);if(p instanceof HTMLElement?(Zn(p).forEach(w=>{if(!(w instanceof HTMLElement))return;const C=of(w);C&&w.contains(C)&&w.removeChild(C);const D=ea(w);D&&D.classList.remove(y);const S=ta(w);S&&S.classList.remove(g)}),i.current=p):i.current=null,c.current||f||r)return;const b=x instanceof HTMLElement?Zn(x):[],k=Zn(e.current);if(k?.every(v=>v instanceof HTMLElement)&&b&&b.every(v=>v instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const v=sf(e.current);v&&(v.style.zIndex="1"),k.forEach((w,C)=>{const D=b[C];if(!D)return;w.style.position="relative",w.style.overflow="hidden";const S=ea(w);S&&S.classList.add(y);const I=ta(w);I&&I.classList.add(g);const N=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),v&&(v.style.zIndex=""),S&&S.classList.remove(y),I&&I.classList.remove(g),w.style.position="",w.style.overflow="",w.contains(D)&&w.removeChild(D)};D.style.pointerEvents="none",D.style.position="absolute",D.style.overflow="hidden",D.setAttribute("aria-hidden","true");const O=lf(D);O&&(O.style.opacity="0");const E=ea(D);E&&(E.classList.add(u?n[Ye.caption_before_exit]:n[Ye.caption_after_exit]),E.addEventListener("animationend",N));const F=ta(D);F&&F.classList.add(u?n[Ye.weeks_before_exit]:n[Ye.weeks_after_exit]),w.insertBefore(D,w.firstChild)})}})}function df(e,t,n,a){const r=e[0],s=e[e.length-1],{ISOWeek:i,fixedWeeks:l,broadcastCalendar:c}=n??{},{addDays:d,differenceInCalendarDays:f,differenceInCalendarMonths:u,endOfBroadcastWeek:y,endOfISOWeek:g,endOfMonth:x,endOfWeek:p,isAfter:b,startOfBroadcastWeek:k,startOfISOWeek:v,startOfWeek:w}=a,C=c?k(r,a):i?v(r):w(r),D=c?y(s):i?g(x(s)):p(x(s)),S=t&&(c?y(t):i?g(t):p(t)),I=S&&b(D,S)?S:D,N=f(I,C),O=u(s,r)+1,E=[];for(let j=0;j<=N;j++){const L=d(C,j);E.push(L)}const Q=(c?35:42)*O;if(l&&E.length<Q){const j=Q-E.length;for(let L=0;L<j;L++){const B=d(E[E.length-1],1);E.push(B)}}return E}function uf(e){const t=[];return e.reduce((n,a)=>{const r=a.weeks.reduce((s,i)=>s.concat(i.days.slice()),t.slice());return n.concat(r.slice())},t.slice())}function ff(e,t,n,a){const{numberOfMonths:r=1}=n,s=[];for(let i=0;i<r;i++){const l=a.addMonths(e,i);if(t&&l>t)break;s.push(l)}return s}function Mr(e,t,n,a){const{month:r,defaultMonth:s,today:i=a.today(),numberOfMonths:l=1}=e;let c=r||s||i;const{differenceInCalendarMonths:d,addMonths:f,startOfMonth:u}=a;if(n&&d(n,c)<l-1){const y=-1*(l-1);c=f(n,y)}return t&&d(c,t)<0&&(c=t),u(c)}function mf(e,t,n,a){const{addDays:r,endOfBroadcastWeek:s,endOfISOWeek:i,endOfMonth:l,endOfWeek:c,getISOWeek:d,getWeek:f,startOfBroadcastWeek:u,startOfISOWeek:y,startOfWeek:g}=a,x=e.reduce((p,b)=>{const k=n.broadcastCalendar?u(b,a):n.ISOWeek?y(b):g(b),v=n.broadcastCalendar?s(b):n.ISOWeek?i(l(b)):c(l(b)),w=t.filter(I=>I>=k&&I<=v),C=n.broadcastCalendar?35:42;if(n.fixedWeeks&&w.length<C){const I=t.filter(N=>{const O=C-w.length;return N>v&&N<=r(v,O)});w.push(...I)}const D=w.reduce((I,N)=>{const O=n.ISOWeek?d(N):f(N),E=I.find(Q=>Q.weekNumber===O),F=new Eo(N,b,a);return E?E.days.push(F):I.push(new iu(O,[F])),I},[]),S=new su(b,D);return p.push(S),p},[]);return n.reverseMonths?x.reverse():x}function hf(e,t){let{startMonth:n,endMonth:a}=e;const{startOfYear:r,startOfDay:s,startOfMonth:i,endOfMonth:l,addYears:c,endOfYear:d,newDate:f,today:u}=t,{fromYear:y,toYear:g,fromMonth:x,toMonth:p}=e;!n&&x&&(n=x),!n&&y&&(n=t.newDate(y,0,1)),!a&&p&&(a=p),!a&&g&&(a=f(g,11,31));const b=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=i(n):y?n=f(y,0,1):!n&&b&&(n=r(c(e.today??u(),-100))),a?a=l(a):g?a=f(g,11,31):!a&&b&&(a=d(e.today??u())),[n&&s(n),a&&s(a)]}function gf(e,t,n,a){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:s=1}=n,{startOfMonth:i,addMonths:l,differenceInCalendarMonths:c}=a,d=r?s:1,f=i(e);if(!t)return l(f,d);if(!(c(t,e)<s))return l(f,d)}function yf(e,t,n,a){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:s}=n,{startOfMonth:i,addMonths:l,differenceInCalendarMonths:c}=a,d=r?s??1:1,f=i(e);if(!t)return l(f,-d);if(!(c(f,t)<=0))return l(f,-d)}function pf(e){const t=[];return e.reduce((n,a)=>n.concat(a.weeks.slice()),t.slice())}function An(e,t){const[n,a]=m.useState(e);return[t===void 0?n:t,a]}function xf(e,t){const[n,a]=hf(e,t),{startOfMonth:r,endOfMonth:s}=t,i=Mr(e,n,a,t),[l,c]=An(i,e.month?i:void 0);m.useEffect(()=>{const C=Mr(e,n,a,t);c(C)},[e.timeZone]);const{months:d,weeks:f,days:u,previousMonth:y,nextMonth:g}=m.useMemo(()=>{const C=ff(l,a,{numberOfMonths:e.numberOfMonths},t),D=df(C,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),S=mf(C,D,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),I=pf(S),N=uf(S),O=yf(l,n,e,t),E=gf(l,a,e,t);return{months:S,weeks:I,days:N,previousMonth:O,nextMonth:E}},[t,l.getTime(),a?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:x,onMonthChange:p}=e,b=C=>f.some(D=>D.days.some(S=>S.isEqualTo(C))),k=C=>{if(x)return;let D=r(C);n&&D<r(n)&&(D=r(n)),a&&D>r(a)&&(D=r(a)),c(D),p?.(D)};return{months:d,weeks:f,days:u,navStart:n,navEnd:a,previousMonth:y,nextMonth:g,goToMonth:k,goToDay:C=>{b(C)||k(C.date)}}}var et;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(et||(et={}));function Cr(e){return!e[Me.disabled]&&!e[Me.hidden]&&!e[Me.outside]}function bf(e,t,n,a){let r,s=-1;for(const i of e){const l=t(i);Cr(l)&&(l[Me.focused]&&s<et.FocusedModifier?(r=i,s=et.FocusedModifier):a?.isEqualTo(i)&&s<et.LastFocused?(r=i,s=et.LastFocused):n(i.date)&&s<et.Selected?(r=i,s=et.Selected):l[Me.today]&&s<et.Today&&(r=i,s=et.Today))}return r||(r=e.find(i=>Cr(t(i)))),r}function kf(e,t,n,a,r,s,i){const{ISOWeek:l,broadcastCalendar:c}=s,{addDays:d,addMonths:f,addWeeks:u,addYears:y,endOfBroadcastWeek:g,endOfISOWeek:x,endOfWeek:p,max:b,min:k,startOfBroadcastWeek:v,startOfISOWeek:w,startOfWeek:C}=i;let S={day:d,week:u,month:f,year:y,startOfWeek:I=>c?v(I,i):l?w(I):C(I),endOfWeek:I=>c?g(I):l?x(I):p(I)}[e](n,t==="after"?1:-1);return t==="before"&&a?S=b([a,S]):t==="after"&&r&&(S=k([r,S])),S}function Vo(e,t,n,a,r,s,i,l=0){if(l>365)return;const c=kf(e,t,n.date,a,r,s,i),d=!!(s.disabled&&ht(c,s.disabled,i)),f=!!(s.hidden&&ht(c,s.hidden,i)),u=c,y=new Eo(c,u,i);return!d&&!f?y:Vo(e,t,y,a,r,s,i,l+1)}function wf(e,t,n,a,r){const{autoFocus:s}=e,[i,l]=m.useState(),c=bf(t.days,n,a||(()=>!1),i),[d,f]=m.useState(s?c:void 0);return{isFocusTarget:p=>!!c?.isEqualTo(p),setFocused:f,focused:d,blur:()=>{l(d),f(void 0)},moveFocus:(p,b)=>{if(!d)return;const k=Vo(p,b,d,t.navStart,t.navEnd,e,r);k&&(e.disableNavigation&&!t.days.some(w=>w.isEqualTo(k))||(t.goToDay(k),f(k)))}}}function vf(e,t){const{selected:n,required:a,onSelect:r}=e,[s,i]=An(n,r?n:void 0),l=r?n:s,{isSameDay:c}=t,d=g=>l?.some(x=>c(x,g))??!1,{min:f,max:u}=e;return{selected:l,select:(g,x,p)=>{let b=[...l??[]];if(d(g)){if(l?.length===f||a&&l?.length===1)return;b=l?.filter(k=>!c(k,g))}else l?.length===u?b=[g]:b=[...b,g];return r||i(b),r?.(b,g,x,p),b},isSelected:d}}function _f(e,t,n=0,a=0,r=!1,s=rt){const{from:i,to:l}=t||{},{isSameDay:c,isAfter:d,isBefore:f}=s;let u;if(!i&&!l)u={from:e,to:n>0?void 0:e};else if(i&&!l)c(i,e)?n===0?u={from:i,to:e}:r?u={from:i,to:void 0}:u=void 0:f(e,i)?u={from:e,to:i}:u={from:i,to:e};else if(i&&l)if(c(i,e)&&c(l,e))r?u={from:i,to:l}:u=void 0;else if(c(i,e))u={from:i,to:n>0?void 0:e};else if(c(l,e))u={from:e,to:n>0?void 0:e};else if(f(e,i))u={from:e,to:l};else if(d(e,i))u={from:i,to:e};else if(d(e,l))u={from:i,to:e};else throw new Error("Invalid range");if(u?.from&&u?.to){const y=s.differenceInCalendarDays(u.to,u.from);a>0&&y>a?u={from:e,to:void 0}:n>1&&y<n&&(u={from:e,to:void 0})}return u}function Nf(e,t,n=rt){const a=Array.isArray(t)?t:[t];let r=e.from;const s=n.differenceInCalendarDays(e.to,e.from),i=Math.min(s,6);for(let l=0;l<=i;l++){if(a.includes(r.getDay()))return!0;r=n.addDays(r,1)}return!1}function Dr(e,t,n=rt){return mt(e,t.from,!1,n)||mt(e,t.to,!1,n)||mt(t,e.from,!1,n)||mt(t,e.to,!1,n)}function jf(e,t,n=rt){const a=Array.isArray(t)?t:[t];if(a.filter(l=>typeof l!="function").some(l=>typeof l=="boolean"?l:n.isDate(l)?mt(e,l,!1,n):Po(l,n)?l.some(c=>mt(e,c,!1,n)):Tn(l)?l.from&&l.to?Dr(e,{from:l.from,to:l.to},n):!1:Wo(l)?Nf(e,l.dayOfWeek,n):Da(l)?n.isAfter(l.before,l.after)?Dr(e,{from:n.addDays(l.after,1),to:n.addDays(l.before,-1)},n):ht(e.from,l,n)||ht(e.to,l,n):Ta(l)||Aa(l)?ht(e.from,l,n)||ht(e.to,l,n):!1))return!0;const i=a.filter(l=>typeof l=="function");if(i.length){let l=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let d=0;d<=c;d++){if(i.some(f=>f(l)))return!0;l=n.addDays(l,1)}}return!1}function Sf(e,t){const{disabled:n,excludeDisabled:a,resetOnSelect:r,selected:s,required:i,onSelect:l}=e,[c,d]=An(s,l?s:void 0),f=l?s:c;return{selected:f,select:(g,x,p)=>{const{min:b,max:k}=e;let v;if(g){const w=f?.from,C=f?.to,D=!!w&&!!C,S=!!w&&!!C&&t.isSameDay(w,C)&&t.isSameDay(g,w);r&&(D||!f?.from)?!i&&S?v=void 0:v={from:g,to:void 0}:v=_f(g,f,b,k,i,t)}return a&&n&&v?.from&&v.to&&jf({from:v.from,to:v.to},n,t)&&(v.from=g,v.to=void 0),l||d(v),l?.(v,g,x,p),v},isSelected:g=>f&&mt(f,g,!1,t)}}function Mf(e,t){const{selected:n,required:a,onSelect:r}=e,[s,i]=An(n,r?n:void 0),l=r?n:s,{isSameDay:c}=t;return{selected:l,select:(u,y,g)=>{let x=u;return!a&&l&&l&&c(u,l)&&(x=void 0),r||i(x),r?.(x,u,y,g),x},isSelected:u=>l?c(l,u):!1}}function Cf(e,t){const n=Mf(e,t),a=vf(e,t),r=Sf(e,t);switch(e.mode){case"single":return n;case"multiple":return a;case"range":return r;default:return}}function qe(e,t){return e instanceof Le&&e.timeZone===t?e:new Le(e,t)}function Ht(e,t,n){return qe(e,t)}function Tr(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?Ht(e,t):Array.isArray(e)?e.map(a=>a instanceof Date?Ht(a,t):a):Tn(e)?{...e,from:e.from?qe(e.from,t):e.from,to:e.to?qe(e.to,t):e.to}:Da(e)?{before:Ht(e.before,t),after:Ht(e.after,t)}:Ta(e)?{after:Ht(e.after,t)}:Aa(e)?{before:Ht(e.before,t)}:e}function na(e,t,n){return e&&(Array.isArray(e)?e.map(a=>Tr(a,t)):Tr(e,t))}function Df(e){let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=qe(t.today,n)),t.month&&(t.month=qe(t.month,n)),t.defaultMonth&&(t.defaultMonth=qe(t.defaultMonth,n)),t.startMonth&&(t.startMonth=qe(t.startMonth,n)),t.endMonth&&(t.endMonth=qe(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=qe(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map(ee=>qe(ee,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?qe(t.selected.from,n):t.selected.from,to:t.selected.to?qe(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=na(t.disabled,n)),t.hidden!==void 0&&(t.hidden=na(t.hidden,n)),t.modifiers)){const ee={};Object.keys(t.modifiers).forEach(ne=>{ee[ne]=na(t.modifiers?.[ne],n)}),t.modifiers=ee}const{components:a,formatters:r,labels:s,dateLib:i,locale:l,classNames:c}=m.useMemo(()=>{const ee={...Oo,...t.locale},ne=t.broadcastCalendar?1:t.weekStartsOn,U=t.noonSafe&&t.timeZone?rf(t.timeZone,{weekStartsOn:ne,locale:ee}):void 0,te=t.dateLib&&U?{...U,...t.dateLib}:t.dateLib??U,Oe=new Ue({locale:ee,weekStartsOn:ne,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},te);return{dateLib:Oe,components:Iu(t.components),formatters:Vu(t.formatters),labels:Zu(t.labels,Oe.options),locale:ee,classNames:{...$u(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:i.today()});const{captionLayout:d,mode:f,navLayout:u,numberOfMonths:y=1,onDayBlur:g,onDayClick:x,onDayFocus:p,onDayKeyDown:b,onDayMouseEnter:k,onDayMouseLeave:v,onNextClick:w,onPrevClick:C,showWeekNumber:D,styles:S}=t,{formatCaption:I,formatDay:N,formatMonthDropdown:O,formatWeekNumber:E,formatWeekNumberHeader:F,formatWeekdayName:Q,formatYearDropdown:j}=r,L=xf(t,i),{days:B,months:M,navStart:Z,navEnd:Y,previousMonth:P,nextMonth:z,goToMonth:G}=L,de=Wu(B,t,Z,Y,i),{isSelected:W,select:V,selected:ue}=Cf(t,i)??{},{blur:me,focused:T,isFocusTarget:oe,moveFocus:pe,setFocused:fe}=wf(t,L,de,W??(()=>!1),i),{labelDayButton:le,labelGridcell:he,labelGrid:Pe,labelMonthDropdown:De,labelNav:ke,labelPrevious:Ie,labelNext:je,labelWeekday:Te,labelWeekNumber:Ce,labelWeekNumberHeader:A,labelYearDropdown:R}=s,J=m.useMemo(()=>nf(i,t.ISOWeek,t.broadcastCalendar,t.today),[i,t.ISOWeek,t.broadcastCalendar,t.today]),H=f!==void 0||x!==void 0,ie=m.useCallback(()=>{P&&(G(P),C?.(P))},[P,G,C]),se=m.useCallback(()=>{z&&(G(z),w?.(z))},[G,z,w]),xe=m.useCallback((ee,ne)=>U=>{U.preventDefault(),U.stopPropagation(),fe(ee),!ne.disabled&&(V?.(ee.date,ne,U),x?.(ee.date,ne,U))},[V,x,fe]),_e=m.useCallback((ee,ne)=>U=>{fe(ee),p?.(ee.date,ne,U)},[p,fe]),Ne=m.useCallback((ee,ne)=>U=>{me(),g?.(ee.date,ne,U)},[me,g]),ae=m.useCallback((ee,ne)=>U=>{const te={ArrowLeft:[U.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[U.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[U.shiftKey?"year":"week","after"],ArrowUp:[U.shiftKey?"year":"week","before"],PageUp:[U.shiftKey?"year":"month","before"],PageDown:[U.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(te[U.key]){U.preventDefault(),U.stopPropagation();const[Oe,ce]=te[U.key];pe(Oe,ce)}b?.(ee.date,ne,U)},[pe,b,t.dir]),ge=m.useCallback((ee,ne)=>U=>{k?.(ee.date,ne,U)},[k]),Se=m.useCallback((ee,ne)=>U=>{v?.(ee.date,ne,U)},[v]),we=m.useCallback(ee=>ne=>{const U=Number(ne.target.value),te=i.setMonth(i.startOfMonth(ee),U);G(te)},[i,G]),Re=m.useCallback(ee=>ne=>{const U=Number(ne.target.value),te=i.setYear(i.startOfMonth(ee),U);G(te)},[i,G]),{className:ot,style:Nt}=m.useMemo(()=>({className:[c[X.Root],t.className].filter(Boolean).join(" "),style:{...S?.[X.Root],...t.style}}),[c,t.className,t.style,S]),gt=Lu(t),yt=m.useRef(null);cf(yt,!!t.animate,{classNames:c,months:M,focused:T,dateLib:i});const jt={dayPickerProps:t,selected:ue,select:V,isSelected:W,months:M,nextMonth:z,previousMonth:P,goToMonth:G,getModifiers:de,components:a,classNames:c,styles:S,labels:s,formatters:r};return $.createElement(Fo.Provider,{value:jt},$.createElement(a.Root,{rootRef:t.animate?yt:void 0,className:ot,style:Nt,dir:t.dir,id:t.id,lang:t.lang??l.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...gt},$.createElement(a.Months,{className:c[X.Months],style:S?.[X.Months]},!t.hideNavigation&&!u&&$.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[X.Nav],style:S?.[X.Nav],"aria-label":ke(),onPreviousClick:ie,onNextClick:se,previousMonth:P,nextMonth:z}),M.map((ee,ne)=>$.createElement(a.Month,{"data-animated-month":t.animate?"true":void 0,className:c[X.Month],style:S?.[X.Month],key:ne,displayIndex:ne,calendarMonth:ee},u==="around"&&!t.hideNavigation&&ne===0&&$.createElement(a.PreviousMonthButton,{type:"button",className:c[X.PreviousMonthButton],tabIndex:P?void 0:-1,"aria-disabled":P?void 0:!0,"aria-label":Ie(P),onClick:ie,"data-animated-button":t.animate?"true":void 0},$.createElement(a.Chevron,{disabled:P?void 0:!0,className:c[X.Chevron],orientation:t.dir==="rtl"?"right":"left"})),$.createElement(a.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[X.MonthCaption],style:S?.[X.MonthCaption],calendarMonth:ee,displayIndex:ne},d?.startsWith("dropdown")?$.createElement(a.DropdownNav,{className:c[X.Dropdowns],style:S?.[X.Dropdowns]},(()=>{const U=d==="dropdown"||d==="dropdown-months"?$.createElement(a.MonthsDropdown,{key:"month",className:c[X.MonthsDropdown],"aria-label":De(),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:we(ee.date),options:ef(ee.date,Z,Y,r,i),style:S?.[X.Dropdown],value:i.getMonth(ee.date)}):$.createElement("span",{key:"month"},O(ee.date,i)),te=d==="dropdown"||d==="dropdown-years"?$.createElement(a.YearsDropdown,{key:"year",className:c[X.YearsDropdown],"aria-label":R(i.options),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:Re(ee.date),options:af(Z,Y,r,i,!!t.reverseYears),style:S?.[X.Dropdown],value:i.getYear(ee.date)}):$.createElement("span",{key:"year"},j(ee.date,i));return i.getMonthYearOrder()==="year-first"?[te,U]:[U,te]})(),$.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},I(ee.date,i.options,i))):$.createElement(a.CaptionLabel,{className:c[X.CaptionLabel],role:"status","aria-live":"polite"},I(ee.date,i.options,i))),u==="around"&&!t.hideNavigation&&ne===y-1&&$.createElement(a.NextMonthButton,{type:"button",className:c[X.NextMonthButton],tabIndex:z?void 0:-1,"aria-disabled":z?void 0:!0,"aria-label":je(z),onClick:se,"data-animated-button":t.animate?"true":void 0},$.createElement(a.Chevron,{disabled:z?void 0:!0,className:c[X.Chevron],orientation:t.dir==="rtl"?"left":"right"})),ne===y-1&&u==="after"&&!t.hideNavigation&&$.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[X.Nav],style:S?.[X.Nav],"aria-label":ke(),onPreviousClick:ie,onNextClick:se,previousMonth:P,nextMonth:z}),$.createElement(a.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":Pe(ee.date,i.options,i)||void 0,className:c[X.MonthGrid],style:S?.[X.MonthGrid]},!t.hideWeekdays&&$.createElement(a.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[X.Weekdays],style:S?.[X.Weekdays]},D&&$.createElement(a.WeekNumberHeader,{"aria-label":A(i.options),className:c[X.WeekNumberHeader],style:S?.[X.WeekNumberHeader],scope:"col"},F()),J.map(U=>$.createElement(a.Weekday,{"aria-label":Te(U,i.options,i),className:c[X.Weekday],key:String(U),style:S?.[X.Weekday],scope:"col"},Q(U,i.options,i)))),$.createElement(a.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[X.Weeks],style:S?.[X.Weeks]},ee.weeks.map(U=>$.createElement(a.Week,{className:c[X.Week],key:U.weekNumber,style:S?.[X.Week],week:U},D&&$.createElement(a.WeekNumber,{week:U,style:S?.[X.WeekNumber],"aria-label":Ce(U.weekNumber,{locale:l}),className:c[X.WeekNumber],scope:"row",role:"rowheader"},E(U.weekNumber,i)),U.days.map(te=>{const{date:Oe}=te,ce=de(te);if(ce[Me.focused]=!ce.hidden&&!!T?.isEqualTo(te),ce[Qe.selected]=W?.(Oe)||ce.selected,Tn(ue)){const{from:Ge,to:st}=ue;ce[Qe.range_start]=!!(Ge&&st&&i.isSameDay(Oe,Ge)),ce[Qe.range_end]=!!(Ge&&st&&i.isSameDay(Oe,st)),ce[Qe.range_middle]=mt(ue,Oe,!0,i)}const pt=tf(ce,S,t.modifiersStyles),xt=Pu(ce,c,t.modifiersClassNames),bt=!H&&!ce.hidden?he(Oe,ce,i.options,i):void 0;return $.createElement(a.Day,{key:`${te.isoDate}_${te.displayMonthId}`,day:te,modifiers:ce,className:xt.join(" "),style:pt,role:"gridcell","aria-selected":ce.selected||void 0,"aria-label":bt,"data-day":te.isoDate,"data-month":te.outside?te.dateMonthId:void 0,"data-selected":ce.selected||void 0,"data-disabled":ce.disabled||void 0,"data-hidden":ce.hidden||void 0,"data-outside":te.outside||void 0,"data-focused":ce.focused||void 0,"data-today":ce.today||void 0},!ce.hidden&&H?$.createElement(a.DayButton,{className:c[X.DayButton],style:S?.[X.DayButton],type:"button",day:te,modifiers:ce,disabled:!ce.focused&&ce.disabled||void 0,"aria-disabled":ce.focused&&ce.disabled||void 0,tabIndex:oe(te)?0:-1,"aria-label":le(Oe,ce,i.options,i),onClick:xe(te,ce),onBlur:Ne(te,ce),onFocus:_e(te,ce),onKeyDown:ae(te,ce),onMouseEnter:ge(te,ce),onMouseLeave:Se(te,ce)},N(Oe,i.options,i)):!ce.hidden&&N(te.date,i.options,i))})))))))),t.footer&&$.createElement(a.Footer,{className:c[X.Footer],style:S?.[X.Footer],role:"status","aria-live":"polite"},t.footer)))}function Ar(e){if(!e)return"";const t=e.split("-");if(t.length!==3)return e;const n=new Date(Number(t[0]),Number(t[1])-1,Number(t[2]));return Number.isFinite(n.getTime())?at(n,"MMM d"):e}function Tf({from:e,to:t,onApply:n,onCancel:a}){const r=m.useMemo(()=>{const d={from:void 0,to:void 0};if(e){const f=e.split("-");d.from=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}if(t){const f=t.split("-");d.to=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}return d},[e,t]),[s,i]=m.useState(r),l=()=>{if(!s?.from)return;const d=at(s.from,"yyyy-MM-dd"),f=s.to?at(s.to,"yyyy-MM-dd"):d;n?.(d,f)},c=!!s?.from;return o.jsxs("div",{className:"p-4",children:[o.jsx(Df,{mode:"range",selected:s,onSelect:i,numberOfMonths:2,showOutsideDays:!1,classNames:{root:"rdp-oai",months:"flex gap-4",month:"space-y-3",month_caption:"flex justify-center items-center h-8",caption_label:"text-sm font-medium text-oai-black dark:text-oai-white",nav:"flex items-center justify-between absolute inset-x-0 top-0 px-2",button_previous:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",button_next:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",chevron:"w-4 h-4",month_grid:"border-collapse",weekdays:"flex",weekday:"w-9 text-center text-xs font-medium text-oai-gray-400 dark:text-oai-gray-500 py-1",week:"flex",day:"w-9 h-9 text-center text-sm p-0 relative",day_button:"w-full h-full inline-flex items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 text-oai-black dark:text-oai-white cursor-pointer rdp-day-btn",today:"font-bold",selected:"rdp-selected",range_start:"rdp-selected rdp-range-start",range_end:"rdp-selected rdp-range-end",range_middle:"rdp-range-mid",outside:"text-oai-gray-300 dark:text-oai-gray-600",disabled:"text-oai-gray-300 dark:text-oai-gray-600 cursor-not-allowed",hidden:"invisible"},styles:{months:{position:"relative"}}}),o.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 pt-3 border-t border-oai-gray-200 dark:border-oai-gray-700",children:[c&&s.from&&o.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[at(s.from,"MMM d, yyyy"),s.to&&s.to.getTime()!==s.from.getTime()?` — ${at(s.to,"MMM d, yyyy")}`:""]}),o.jsx(jn,{variant:"secondary",size:"sm",onClick:a,children:"Cancel"}),o.jsx(jn,{variant:"primary",size:"sm",onClick:l,disabled:!c,children:"Apply"})]})]})}const Or={claude:290,codex:165},Er={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 Af(e,t){const n=Or[t]??Or.claude,a=Er[e]||Er.system_prompt;return`oklch(${a.l} ${a.c} ${n})`}const Of=[{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"]}],Ef=[["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"]],Ff={duration:.18,ease:[.4,0,.2,1]},Wf={height:0,opacity:0},Pf={height:"auto",opacity:1},If={height:0,opacity:0};function Lf(e){const t=Number(e||0);return Number.isFinite(t)&&t>0?t:0}function $f(e,t){const n={};for(const a of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])n[a]=Math.round(Number(e?.[a]||0)*t);return n}function Ko(e,t=null){const n=e.reduce((i,l)=>i+Number(l.totals.total_tokens||0),0),a=Lf(t),r=a||n,s=a&&n>0?a/n:1;return e.map(i=>{const l=s===1?i.totals:$f(i.totals,s);return{...i,totals:l,percent:r>0?Number((l.total_tokens/r*100).toFixed(2)):0}}).sort((i,l)=>l.totals.total_tokens-i.totals.total_tokens)}function Rf(e,t=null){const n=new Map;for(const r of e||[])n.set(r.key,r);const a=Of.map(r=>{const s={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 r.from){const l=n.get(i);if(!l)continue;const c=l.totals||{};s.input_tokens+=c.input_tokens||0,s.cached_input_tokens+=c.cached_input_tokens||0,s.cache_creation_input_tokens+=c.cache_creation_input_tokens||0,s.output_tokens+=c.output_tokens||0,s.reasoning_output_tokens+=c.reasoning_output_tokens||0,s.total_tokens+=c.total_tokens||0}return{key:r.key,totals:s}});return Ko(a,t)}function Bf(e,t=null){const n=e?.totals||{},a=Number(n.reasoning_output_tokens||0),r=(e?.tool_calls_breakdown?.categories||[]).reduce((d,f)=>f?.name==="Text Response"?d:d+Number(f?.totals?.total_tokens||0),0),s=Number(n.total_tokens||0),i=Math.min(Math.max(0,r),Math.max(0,s-a)),c=[{key:"messages",totals:{total_tokens:Math.max(0,s-a-i)}},{key:"tool_calls",totals:{total_tokens:i}},{key:"reasoning",totals:{total_tokens:a}}];return Ko(c,t)}const Fr="MCP: ";function Yf(e){if(!e?.categories?.length)return{mcpSet:null,residualSet:e,mcpTotalTokens:0};const t=[],n=[];let a=0;for(const r of e.categories){const s=String(r?.name||"");s.startsWith(Fr)?(t.push({...r,name:s.slice(Fr.length)}),a+=Number(r?.totals?.total_tokens||0)):n.push(r)}return t.length===0?{mcpSet:null,residualSet:e,mcpTotalTokens:0}:(t.sort((r,s)=>(s.totals?.total_tokens||0)-(r.totals?.total_tokens||0)),{mcpSet:{...e,categories:t},residualSet:{...e,categories:n},mcpTotalTokens:a})}function Wr(e){return h(`dashboard.context_breakdown.category.${e}`)}function tt(e){return!Number.isFinite(Number(e))||Number(e)<=0?"0":He(Number(e),{decimals:1})}function zf(e){return typeof e!="string"?"":e.startsWith("mcp__")?e.split("__").slice(2).join("__")||e:e.includes("/")&&e.split("/").pop()||e}function Hf(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||null,a=Number(n?n.input_tokens||0:t?.input_tokens||0),r=Number(n?n.output_tokens||0:t?.output_tokens||0),s=Number(n?n.cached_input_tokens||0:t?.cache_read||0),i=Number(n?n.cache_creation_input_tokens||0:t?.cache_creation||0),l=Number(n?n.total_tokens||a+r:t?.total_tokens||r);return{name:zf(t?.name?String(t.name):""),calls:Number(t?.calls||0),input_tokens:a,output_tokens:r,cache_read:s,cache_creation:i,total_tokens:Number(l||0)}}).filter(t=>t.name).sort((t,n)=>(n.total_tokens||0)-(t.total_tokens||0))}function Uf(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Array.isArray(t?.tools)?t.tools:[],r=Number(n.input_tokens||0),s=Number(n.output_tokens||0),i=Number(n.cached_input_tokens||0),l=Number(n.cache_creation_input_tokens||0);return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),totals:{input_tokens:r,output_tokens:s,cached_input_tokens:i,cache_creation_input_tokens:l,total_tokens:Number(n.total_tokens||r+s)},tools:Hf(a),toolCount:a.length}}).filter(t=>t.name).sort((t,n)=>(n.totals.total_tokens||0)-(t.totals.total_tokens||0))}function qf(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Number(n.input_tokens||0),r=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),i=Number(n.cache_creation_input_tokens||0);return{key:t?.key?String(t.key):"",name:t?.name?String(t.name):"",totals:{input_tokens:a,output_tokens:r,cached_input_tokens:s,cache_creation_input_tokens:i,total_tokens:Number(n.total_tokens||a+r+s+i)}}}).filter(t=>t.key||t.name).sort((t,n)=>(n.totals.total_tokens||0)-(t.totals.total_tokens||0))}function Gf(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{};return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),total_tokens:Number(n.total_tokens||0)}}).filter(t=>t.name).sort((t,n)=>Number(n.total_tokens||0)-Number(t.total_tokens||0))}function Vf(e){if(e?.key){const t=h(`dashboard.context_breakdown.message_details.${e.key}`);if(t&&!t.includes("dashboard.context_breakdown"))return t}return e?.name||""}function Kf(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Number(n.input_tokens||0),r=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),i=Number(n.cache_creation_input_tokens||0);return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),failures:Number(t?.failures||0),duration_ms:Number(t?.duration_ms||0),max_duration_ms:Number(t?.max_duration_ms||0),output_chars:Number(t?.output_chars||0),output_lines:Number(t?.output_lines||0),totals:{input_tokens:a,output_tokens:r,cached_input_tokens:s,cache_creation_input_tokens:i,total_tokens:Number(n.total_tokens||a+r)}}}).filter(t=>t.name).sort((t,n)=>Number(n.totals.total_tokens||0)-Number(t.totals.total_tokens||0))}function Pr(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"0ms":t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.round(t/1e3)}s`}function Xf(e,t){return e?t==="by_executable"?e.by_executable||[]:t==="by_command"?e.by_command||[]:t==="by_duration"?e.by_duration||[]:t==="by_output"?e.by_output||[]:t==="by_exit"?e.by_exit||[]:e.by_type||[]:[]}function Ir(e){return e==="exec_command"||e==="Bash"}function Xo(e){return e==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function Qf(e){return e==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function Jf(e){return e==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const Zf=10;function ut({level:e=0,colorSquare:t=null,label:n,labelSuffix:a=null,labelTone:r="default",hasChevron:s=!1,open:i=!1,onToggle:l,tokens:c,percent:d=null,children:f,share:u=null,fillColor:y=null}){const g=r==="accent"?"text-oai-brand truncate":r==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":r==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",x=o.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:Zf},"aria-hidden":!t,children:t}),p=o.jsxs(o.Fragment,{children:[x,o.jsx("span",{className:g,children:n}),a,s&&o.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:o.jsx(cl,{size:11})})]}),b=y&&u!=null&&u>0,k=b?Math.max(0,Math.min(100,u)):0;return o.jsxs("li",{className:"min-w-0 group/row",children:[o.jsxs("div",{className:"relative grid grid-cols-[minmax(0,1fr)_64px_48px] items-center gap-2 text-xs py-1 px-1 rounded-sm transition-colors duration-150",style:b?{backgroundImage:`linear-gradient(to right, ${y.replace(/\)\s*$/," / 0.10)")} 0%, ${y.replace(/\)\s*$/," / 0.10)")} ${k}%, transparent ${k}%)`}:void 0,children:[s?o.jsx("button",{type:"button",onClick:l,"aria-expanded":i,className:"relative 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:p}):o.jsx("div",{className:"relative flex items-center gap-1.5 min-w-0",children:p}),o.jsx("span",{className:"relative text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),o.jsx("span",{className:"relative text-right tabular-nums text-[10px] text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:d||""})]}),s&&f?o.jsx(wa,{initial:!1,children:i&&o.jsx($e.div,{initial:Wf,animate:Pf,exit:If,transition:Ff,style:{overflow:"hidden"},children:f},"content")}):null]})}function Lr({execDetails:e,source:t="claude"}){const[n,a]=m.useState("by_type"),r=Kf(Xf(e,n)),s=t==="codex",i=s?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return o.jsxs("div",{className:"mt-2 ml-4",children:[o.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:Ef.map(([l,c])=>o.jsx("button",{type:"button",onClick:()=>a(l),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(n===l?"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:h(c)},l))}),r.length===0?o.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):o.jsx("div",{className:"mt-2 overflow-x-auto",children:o.jsxs("div",{role:"table","aria-label":h("dashboard.context_breakdown.exec_details.title"),className:s?"min-w-[420px]":"min-w-[260px]",children:[o.jsxs("div",{role:"row",className:`grid ${i} 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:[o.jsx("span",{role:"columnheader",children:h("dashboard.context_breakdown.exec_details.kind_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:h("dashboard.context_breakdown.exec_details.calls_column")}),s&&o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"columnheader",className:"text-right",children:h("dashboard.context_breakdown.exec_details.failures_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:h("dashboard.context_breakdown.exec_details.duration_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:h("dashboard.context_breakdown.exec_details.max_duration_column")})]}),o.jsx("span",{role:"columnheader",className:"text-right",children:h("dashboard.context_breakdown.tool_details.total_column")}),s&&o.jsx("span",{role:"columnheader",className:"text-right",children:h("dashboard.context_breakdown.exec_details.output_column")})]}),r.map((l,c)=>o.jsxs($e.div,{role:"row",className:`grid ${i} gap-2 py-1.5`,title:l.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:c*.02},children:[o.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:l.name}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:He(l.calls||0)}),s&&o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:He(l.failures||0)}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Pr(l.duration_ms||0)}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Pr(l.max_duration_ms||0)})]}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:tt(l.totals.total_tokens||0)}),s&&o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:He(l.output_lines||0)})]},l.name))]})})]})}function rn({toolSet:e,execDetails:t,source:n,codexQueueFallback:a}){const[r,s]=m.useState({}),[i,l]=m.useState(!1),c=Uf(e?.categories||[]);function d(f){s(u=>({...u,[f]:!u[f]}))}return c.length===0?o.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:n==="codex"&&a?h("dashboard.context_breakdown.tool_details.unavailable_codex"):h(Xo(n))}):o.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(f=>{const u=f.toolCount>0,y=f.name==="Execution"&&t,g=y&&f.tools.some(p=>Ir(p.name)),x=!!r[f.name];return o.jsxs(ut,{level:1,label:f.name,labelTone:"strong",hasChevron:u||y&&!g,open:x||y&&!g&&i,onToggle:()=>{u?d(f.name):y&&!g&&l(p=>!p)},tokens:tt(f.totals.total_tokens||0),percent:null,children:[u&&o.jsx("ul",{className:"space-y-0.5",children:f.tools.map(p=>{const b=y&&Ir(p.name);return o.jsx(ut,{level:2,label:p.name,labelTone:b?"accent":"default",hasChevron:b,open:i,onToggle:()=>l(k=>!k),tokens:tt(p.total_tokens||0),percent:null,children:b&&o.jsx(Lr,{execDetails:t,source:n})},p.name)})}),y&&!g&&o.jsx(Lr,{execDetails:t,source:n})]},f.name)})})}function em({from:e,to:t,source:n="claude",referenceTotalTokens:a=null,onLoadingChange:r=null}){const[s,i]=m.useState(null),[l,c]=m.useState(!1),[d,f]=m.useState(null),[u,y]=m.useState({});function g(M){y(Z=>({...Z,[M]:!Z[M]}))}if(m.useEffect(()=>{let M=!1;return c(!0),r?.(!0),f(null),$i({from:e,to:t,source:n,timeZone:oo(),tzOffsetMinutes:ro()}).then(Z=>{M||i(Z)}).catch(Z=>{M||f(Z?.message||String(Z))}).finally(()=>{M||(c(!1),r?.(!1))}),()=>{M=!0}},[e,t,n]),l&&!s)return o.jsxs("div",{children:[o.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),o.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(M=>o.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${M*80}ms`}},M))}),o.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:h("dashboard.context_breakdown.loading_hint")})]});if(d)return o.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:h(Qf(n))});if(!s||s.scope!=="supported"||!s.totals?.total_tokens)return o.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:h(Xo(n))});const x=n==="claude"?Rf(s.categories||[],a):Bf(s,a),p=s.tool_calls_breakdown||null,b=s.skills_breakdown||null,k=s.message_breakdown||null,v=s.configured_resources||null,w=s.exec_command_breakdown||null,C=Gf(b?.skills||[]),D=qf(k?.categories||[]),S=n==="codex"&&(s?.breakdown_status==="queue_fallback"||s?.fallback==="queue_totals"),I=n==="claude"?p?.tool_calls||null:p||null,{mcpSet:N,residualSet:O,mcpTotalTokens:E}=Yf(I),F=n==="claude"&&p?.subagents||null,Q=F?.categories?.length>0||(v?.custom_agents_count||0)>0,j=n==="claude"?(O?.categories||[]).reduce((M,Z)=>M+Number(Z?.totals?.total_tokens||0),0):0,L=n==="claude"?(F?.categories||[]).reduce((M,Z)=>M+Number(Z?.totals?.total_tokens||0),0):0,B=[...x].sort((M,Z)=>(Z.totals?.total_tokens||0)-(M.totals?.total_tokens||0));return o.jsxs("div",{role:"region","aria-label":h("dashboard.context_breakdown.bar_aria",{summary:x.filter(M=>M.percent>0).filter(M=>!(n==="claude"&&(M.key==="tool_calls"||M.key==="custom_agents"))).map(M=>`${Wr(M.key)} ${M.percent}%`).join(",")}),children:[o.jsxs("ul",{className:"space-y-0.5",children:[B.map(M=>{const Z=M.key==="system_prompt",Y=M.key==="messages",P=M.key==="tool_calls",z=M.key==="custom_agents";if(M.key,n==="claude"&&(P||z))return null;const G=Y&&D.length>0||P&&(O?.categories?.length>0||S)||z&&Q&&F,de=!!u[M.key],W=Af(M.key,n),V=o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:W},"aria-hidden":"true"}),ue=Z?o.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[o.jsx(va,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),o.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:h("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,me=M.percent>0?`${M.percent.toFixed(M.percent<.1&&M.percent>0?2:1)}%`:"0.0%";return o.jsxs(ut,{level:0,colorSquare:V,label:Wr(M.key),labelSuffix:ue,tokens:tt(M.totals?.total_tokens||0),percent:me,hasChevron:G,open:de,onToggle:()=>g(M.key),share:M.percent,fillColor:W,children:[Y&&o.jsx("ul",{className:"space-y-0.5",children:D.map(T=>o.jsx(ut,{level:1,label:Vf(T),tokens:tt(T.totals.total_tokens||0),percent:null},T.key||T.name))}),P&&O&&o.jsx(rn,{toolSet:O,execDetails:w,source:n,codexQueueFallback:S}),P&&S&&!O&&o.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:h("dashboard.context_breakdown.tool_details.unavailable_codex")}),z&&F&&o.jsx(rn,{toolSet:F,execDetails:null,source:n,codexQueueFallback:!1})]},M.key)}),n==="claude"&&O?.categories?.length>0&&o.jsx(ut,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:h("dashboard.context_breakdown.category.tool_calls"),tokens:tt(j),percent:null,hasChevron:!0,open:!!u.tool_calls_aux,onToggle:()=>g("tool_calls_aux"),children:o.jsx(rn,{toolSet:O,execDetails:w,source:n,codexQueueFallback:!1})}),n==="claude"&&F?.categories?.length>0&&o.jsx(ut,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:h("dashboard.context_breakdown.category.custom_agents"),tokens:tt(L),percent:null,hasChevron:!0,open:!!u.custom_agents_aux,onToggle:()=>g("custom_agents_aux"),children:o.jsx(rn,{toolSet:F,execDetails:null,source:n,codexQueueFallback:!1})}),N?.categories?.length>0&&o.jsx(ut,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:h("dashboard.context_breakdown.category.mcp_servers"),tokens:tt(E),percent:null,hasChevron:!0,open:!!u.mcp_servers,onToggle:()=>g("mcp_servers"),children:o.jsx(rn,{toolSet:N,execDetails:null,source:n,codexQueueFallback:!1})}),C.length>0&&o.jsx(ut,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:h("dashboard.context_breakdown.category.skills"),tokens:tt(C.reduce((M,Z)=>M+(Z.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!u.skills,onToggle:()=>g("skills"),children:o.jsx("ul",{className:"space-y-0.5",children:C.slice(0,12).map(M=>o.jsx(ut,{level:1,label:M.name,tokens:tt(M.total_tokens),percent:null},M.name))})})]}),o.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:h(Jf(n))}),S?o.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:h("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,v?o.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[He(v.skills_count||0)," skills ·"," ",He(v.mcp_servers_count||0)," MCP servers ·"," ",He(v.custom_agents_count||0)," agents ·"," ",He(v.memory_files_count||0)," memory files"]}):null]})}function Qo(e){if(!Number.isFinite(Number(e)))return null;const t=Number(e);return t<=0?null:He(t,{decimals:1})}function Jo(e){const t=Number(e);return!Number.isFinite(t)||t<=0?null:t<.01?"<$0.01":Dn(t.toFixed(2),{decimals:2})}function tm(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{key:t,label:$r(t)}:{key:t.key,label:t.label||$r(t.key)}):[]}function nm(e){if(typeof e!="string")return null;const t=e.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!t)return null;const n=Number(t[0]);return Number.isFinite(n)?n:null}const am={CODEX:"#10b981",CLAUDE:"#8b5cf6",OPENCODE:"#f59e0b",GEMINI:"#3b82f6",KIMI:"#a78bfa","KILO-CLI":"#facc15","KILO-CODE":"#facc15"};function aa(e,t){const n=e?.toUpperCase?.()||"";return am[n]||`hsl(${150+t*40}, 60%, 45%)`}function rm(e){const t=String(e?.source||"").trim().toLowerCase(),n=String(e?.label||"").trim().toLowerCase();return t==="claude"||n==="claude"?"claude":t==="codex"||n==="codex"?"codex":null}const om={day:"usage.period.day",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function $r(e){const t=om[e];return t?h(t):String(e).toUpperCase()}function sm({loading:e,onClick:t}){const n=Na();return o.jsx(jn,{variant:"secondary",size:"sm",disabled:e,onClick:t,"aria-label":h("usage.button.refresh"),className:"w-8 p-0",children:o.jsx($e.span,{"aria-hidden":"true",animate:e?{rotate:360}:{rotate:0},transition:e&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function im({period:e,periods:t,onPeriodChange:n,summaryValue:a,summaryLabel:r,summaryCostValue:s,onCostInfo:i,fleetData:l=[],onRefresh:c,loading:d,className:f="",customFrom:u,customTo:y,onCustomRangeApply:g,customRangeOpen:x,onCustomRangeOpenChange:p,onOpenShare:b,from:k,to:v}){const w=tm(t),C=nm(String(a??"")),D=C!=null,[S,I]=m.useState(null),{resolvedTheme:N}=no(),O=N==="dark",E=O?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",F=O?"rgba(10,10,10,0)":"rgba(255,255,255,0)",Q=l.filter(j=>j.models?.length>0);return o.jsxs(_a,{className:f,children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[o.jsx("div",{role:"tablist","aria-label":h("usage.overview.tablist_aria"),className:"flex gap-1",children:w.map(j=>{const L=e===j.key,B=`text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${L?"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(j.key==="custom"){const M=L&&u&&y?`${Ar(u)} — ${Ar(y)}`:j.label;return o.jsxs(dl,{open:x,onOpenChange:Z=>{Z?n?.("custom"):p?.(Z)},children:[o.jsx(ul,{render:o.jsx("button",{role:"tab","aria-selected":L,type:"button",className:B}),children:M}),o.jsx(fl,{children:o.jsx(ml,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:o.jsx(hl,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:o.jsx(Tf,{from:u,to:y,onApply:g,onCancel:()=>p?.(!1)})})})})]},"custom")}return o.jsx("button",{role:"tab","aria-selected":L,type:"button",className:B,onClick:()=>n?.(j.key),children:j.label},j.key)})}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[b?o.jsxs("button",{type:"button",onClick:b,"aria-label":h("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:[o.jsx(jl,{className:"h-3.5 w-3.5",strokeWidth:2}),h("share.button.label")]}):null,c&&o.jsx(sm,{loading:d,onClick:c})]})]}),o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:r}),o.jsx("div",{className:"text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:D?o.jsx(Cc,{value:C,displayValue:a,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:O?0:8,gradientFrom:E,gradientTo:F,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):a}),s&&o.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:i?o.jsxs("button",{type:"button",onClick:i,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":h("usage.overview.cost_breakdown_aria"),children:[s,o.jsx(va,{size:16,strokeWidth:2,className:"opacity-80"})]}):o.jsx("span",{className:"text-xl font-bold text-oai-brand",children:s})})]}),Q.length>0&&o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{role:"img","aria-label":h("usage.overview.distribution_aria",{items:Q.map(j=>h("usage.overview.distribution_item",{label:j.label,percent:j.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:Q.map((j,L)=>{const B=aa(j.label,L);return o.jsx($e.div,{initial:{width:0},animate:{width:`${j.totalPercent}%`},transition:{duration:.5,delay:.45+L*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:B},title:`${j.label}: ${j.totalPercent}%`},j.label)})}),o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-5 gap-3",children:Q.map((j,L)=>{const B=aa(j.label,L),M=S===j.label;return o.jsxs("button",{"aria-expanded":M,"aria-controls":`provider-details-${j.label}`,"aria-label":h("usage.overview.provider_card_aria",{provider:j.label,percent:j.totalPercent,tokens:Qo(j.usage)||"0",cost:Jo(j.usd)||"$0",action:h(M?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>I(M?null:j.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${M?"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:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[o.jsx(lo,{provider:j.label,size:15,color:B,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),o.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:j.label})]}),o.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[j.totalPercent,"%"]}),o.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:h("usage.overview.model_count",{count:j.models.length})})]},j.label)})}),S&&o.jsx("div",{id:`provider-details-${S}`,role:"region","aria-label":h("usage.overview.model_details_aria",{provider:S}),className:"mt-2",children:Q.filter(j=>j.label===S).map(j=>{const L=aa(j.label,0),B=rm(j),M=[...j.models].sort((Y,P)=>(P.share||0)-(Y.share||0)),Z=B?`${B==="claude"?"Claude":"Codex"} Context Breakdown`:j.label;return o.jsx(lm,{provider:j,color:L,providerHeading:Z,contextSource:B,from:k,to:v,sortedModels:M},j.label)})})]})]})}function lm({provider:e,color:t,providerHeading:n,contextSource:a,from:r,to:s,sortedModels:i}){const[l,c]=m.useState(!1),d=String(e?.source||e?.label||"").trim().toLowerCase()==="antigravity";return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[o.jsx(lo,{provider:e.label,size:14,color:t,className:"shrink-0"}),o.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:n}),a&&l&&o.jsx(gl,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":h("dashboard.context_breakdown.loading_aria")})]}),d&&o.jsxs("p",{className:"mb-3 text-[10px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:[o.jsxs("span",{className:"font-medium text-oai-gray-500 dark:text-oai-gray-400",children:[h("usage.overview.antigravity_notice_title"),"."]})," ",h("usage.overview.antigravity_notice_body")]}),a?o.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:o.jsx(em,{from:r,to:s,source:a,referenceTotalTokens:e.usage,onLoadingChange:c})}):null,o.jsx("div",{className:"space-y-3",children:i.map(f=>{const u=Qo(f.usage),y=Jo(f.cost),g=Math.max(0,Math.min(100,Number(f.share)||0));return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-baseline gap-4 mb-1.5",children:[o.jsx("span",{className:"flex-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:f.name,children:f.name}),o.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:u}),o.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:y}),o.jsxs("span",{className:"shrink-0 w-12 text-right text-sm text-oai-black dark:text-oai-white tabular-nums",children:[f.share,"%"]})]}),o.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":g,"aria-valuemin":0,"aria-valuemax":100,children:o.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${g}%`,backgroundColor:t,opacity:.45}})})]},f.id||f.name)})})]})}function Rr(e,t){if(!Array.isArray(e)||e.length===0)return 0;if(e.length===1)return e[0];const n=(e.length-1)*t,a=Math.floor(n),r=Math.ceil(n);if(a===r)return e[a];const s=n-a;return e[a]+(e[r]-e[a])*s}function cm(e){const t=Array.isArray(e)?e.filter(r=>Number.isFinite(r)&&r>0).sort((r,s)=>r-s):[];if(t.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(e)?e.map(()=>0):[]};const n=t.at(-1)??0;let a=n;if(t.length>=4){const r=Rr(t,.25),s=Rr(t,.75),i=Math.max(s-r,0),l=s+i*1.5;n>l&&(a=Math.max(l,s,1))}return{rawMax:n,effectiveMax:Math.max(a,1),clippedValues:Array.isArray(e)?e.map(r=>!Number.isFinite(r)||r<=0?0:Math.min(r,Math.max(a,1))):[]}}function dm({value:e,displayValue:t,scale:n,index:a,row:r,totalBars:s}){const i=Na(),l=n.effectiveMax>0?t/n.effectiveMax*100:0,c=`${Math.max(l,2)}%`,d=r?.missing,f=r?.future,u=s<=7?"6px":s<=14?"4px":"3px";return o.jsx($e.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:i?0:.3,delay:i?0:.4+a*.008,ease:[.16,1,.3,1]},style:{originY:1},children:o.jsxs("div",{className:"absolute inset-x-0 bottom-0",style:{height:c},children:[o.jsx("div",{"data-trend-bar":"true",className:"h-full w-full cursor-pointer transition-all duration-200 group-hover:brightness-110",style:{minHeight:e>0?"4px":"2px",opacity:d||f?.2:1,borderRadius:`${u} ${u} 0 0`,background:e>0?"#10b981":"var(--oai-gray-100)"},title:`${e.toLocaleString()}`}),o.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-oai-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-20",children:e.toLocaleString()})]})})}function um({rows:e,from:t,to:n,period:a,timeZoneLabel:r,showTimeZoneLabel:s=!0,className:i=""}){const l=Array.isArray(e)&&e.length?e:[],c=l.map(f=>{if(f?.missing||f?.future)return 0;const u=f?.billable_total_tokens??f?.total_tokens??f?.value;if(u==null)return 0;const y=Number(u);return Number.isFinite(y)?y:0}),d=cm(c);return o.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 ${i}`,children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:h("trend.monitor.label")}),s&&r&&o.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:r})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(f=>o.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-f}%`}},f))}),o.jsx("div",{className:"h-40 flex items-end gap-1 relative z-0",children:c.length>0?c.map((f,u)=>o.jsx(dm,{value:f,displayValue:d.clippedValues[u]??0,scale:d,index:u,row:l[u],totalBars:c.length},u)):o.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:o.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]}),t&&n&&o.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[o.jsx("span",{children:t}),o.jsx("span",{children:n})]})]})]})}const Br={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},ra=new Map;async function fm(e){if(ra.has(e))return ra.get(e);const t=await fetch(`/clawd/${e}`);if(!t.ok)return null;const a=(await t.text()).replace(/<svg([^>]*)>/,(r,s)=>`<svg${s.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return ra.set(e,a),a}function mm({state:e="idle-living",size:t=48,className:n=""}){const[a,r]=m.useState(""),s=m.useRef(null),l=hm()?"static-base":e,c=Br[l]||Br["static-base"];return m.useEffect(()=>{let d=!1;return fm(c).then(f=>{!d&&f&&r(f)}),()=>{d=!0}},[c]),m.useEffect(()=>{const d=s.current?.querySelector("svg");if(d)try{const f=d.getBBox();f.width>0&&f.height>0&&d.setAttribute("viewBox",`${f.x-2} ${f.y-2} ${f.width+4} ${f.height+4}`)}catch{}},[a]),o.jsx("div",{ref:s,className:`clawd-animated ${n}`,style:{width:t,height:t,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:a}})}function hm(){const[e,t]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return m.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),a=r=>t(r.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[]),e}function gm({todayTokens:e=0,isSyncing:t=!1,hasError:n=!1,isDisconnected:a=!1}={}){return m.useMemo(()=>n?"error":a?"disconnected":t?"working-typing":e===0?"sleeping":e<5e4?"idle-living":e<2e5?"idle-look":e<5e5?"working-ultrathink":e<2e6?"working-typing":"working-ultrathink",[e,t,n,a])}const Yr="macAppBannerDismissed",ym="leaderboardBannerDismissed",pm="https://github.com/mm7894215/TokenTracker/releases/latest",zr="tokentracker_native_app",kn=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(zr,"1"),!0):localStorage.getItem(zr)==="1"}catch{return!1}})();function xm({todayTokens:e=0,isSyncing:t=!1,enterDelay:n=0}){const{openLoginModal:a}=Ri(),{signedIn:r}=so(),s=gm({todayTokens:e,isSyncing:t}),i=kn?ym:Yr,[l,c]=m.useState(()=>{try{return localStorage.getItem(i)==="1"?!0:!kn&&new URLSearchParams(window.location.search).get("from")==="menubar"?(localStorage.setItem(Yr,"1"),!0):!1}catch{return!1}}),d=m.useCallback(()=>{c(!0);try{localStorage.setItem(i,"1")}catch{}},[i]);if(l)return null;let f,u,y,g,x,p;kn&&r?(f="View the Leaderboard",u="Compare your usage globally",y="Leaderboard",g=o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:o.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)"})}),x=()=>{window.location.pathname="/leaderboard"}):kn?(f="Join the Leaderboard",u="Log in to compare your usage with others",y="Log In",g=o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:o.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"})}),x=a):(f="Try the Menu Bar App",u="Always-on stats with Clawd companion",y="Download",g=o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:o.jsx("path",{d:"M6 2v6m0 0L3.5 5.5M6 8l2.5-2.5M2 10h8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),p=pm);const b=p?$e.a:$e.button,k=p?{href:p,target:"_blank",rel:"noopener noreferrer"}:{onClick:x};return o.jsx($e.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:n,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:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex-shrink-0",children:o.jsx(mm,{state:s,size:56})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-oai-gray-900 dark:text-oai-white",children:f}),o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-0.5",children:u})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsxs(b,{...k,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:[y,g]}),o.jsx("button",{onClick:d,className:"p-1 text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 transition-colors","aria-label":"Dismiss",children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:o.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})]})})}const Hr="widgetOnboardingDismissed",Ur="tokentracker_native_app",bm=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(Ur,"1"),!0):localStorage.getItem(Ur)==="1"}catch{return!1}})();function km({enterDelay:e=0}){const[t,n]=m.useState(()=>{try{return localStorage.getItem(Hr)==="1"}catch{return!1}}),a=m.useCallback(()=>{n(!0);try{localStorage.setItem(Hr,"1")}catch{}},[]);return bm?o.jsx(wa,{initial:!1,children:!t&&o.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:e,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:[o.jsx("button",{type:"button",onClick:a,"aria-label":h("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:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),o.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:o.jsx("img",{src:"/widgets-overview.png",alt:h("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),o.jsxs("div",{className:"mt-4",children:[o.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:h("dashboard.widgets.title")}),o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:h("dashboard.widgets.hint")})]})]},"widget-onboarding-card")}):null}function wm(e){const{copy:t,onOpenShare:n,screenshotMode:a,showExpiredGate:r,showAuthGate:s,screenshotTitleLine1:i,screenshotTitleLine2:l,identityDisplayName:c,identityStartDate:d,activeDays:f,identitySubscriptions:u,identityScrambleDurationMs:y,projectUsageEntries:g,projectUsageLimit:x,setProjectUsageLimit:p,topModels:b,signedIn:k,publicMode:v,isLocalMode:w,shouldShowInstall:C,installPrompt:D,handleCopyInstall:S,installCopied:I,installInitCmdDisplay:N,trendRowsForDisplay:O,trendFromForDisplay:E,trendToForDisplay:F,usageFrom:Q,usageTo:j,period:L,trendTimeZoneLabel:B,activityHeatmapBlock:M,isCapturing:Z,handleShareToX:Y,screenshotTwitterButton:P,screenshotTwitterHint:z,periodsForDisplay:G,setSelectedPeriod:de,customFrom:W,customTo:V,onCustomRangeApply:ue,customRangeOpen:me,onCustomRangeOpenChange:T,summaryLabel:oe,summaryValue:pe,summaryTotalTokensRaw:fe,summaryCostValue:le,summaryConversationsValue:he,rollingUsage:Pe,costInfoEnabled:De,openCostModal:ke,costModalOpen:Ie,closeCostModal:je,allowBreakdownToggle:Te,refreshAll:Ce,usageLoadingState:A,fleetData:R,hasDetailsActual:J,dailyEmptyPrefix:H,installSyncCmd:ie,dailyEmptySuffix:se,detailsColumns:xe,ariaSortFor:_e,toggleSort:Ne,sortIconFor:ae,pagedDetails:ge,dailyBreakdownRows:Se,dailyBreakdownColumns:we,dailyBreakdownAriaSortFor:Re,dailyBreakdownSortIconFor:ot,dailyBreakdownDateKey:Nt,detailsDateKey:gt,renderDetailDate:yt,renderDailyBreakdownDate:jt,renderDetailCell:ee,DETAILS_PAGED_PERIODS:ne,detailsPageCount:U,detailsPage:te,setDetailsPage:Oe}=e,ce=null,pt=null,xt=.06,bt=.05,Ge=.11;let st=0;const it=()=>Ge+xt*st++,lt=Ge+xt*5;return o.jsxs(o.Fragment,{children:[o.jsx(xc,{bare:!a,hideHeader:a,header:ce,footer:a?null:pt,className:a?"screenshot-mode":"",children:r||s?null:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[o.jsxs("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0 order-2 lg:order-1",children:[a?o.jsx("div",{className:"flex items-start justify-between gap-4",children:o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:i}),o.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:l})]})}):null,w?o.jsx(xm,{todayTokens:fe,isSyncing:A,enterDelay:it()}):null,o.jsx(Yt,{delay:it(),children:o.jsx(Ec,{title:t("dashboard.identity.title"),subtitle:t("dashboard.identity.subtitle"),period:L,rankLabel:d??t("identity_card.rank_placeholder"),streakDays:f,subscriptions:u,periodConversations:he,rolling:Pe,topModels:b})}),w?o.jsx(km,{enterDelay:it()}):null,C?o.jsx(Yt,{delay:it(),children:o.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:[o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:D}),o.jsxs($e.button,{onClick:S,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:[o.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:N}),o.jsx($e.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:I?"Copied ✓":"Copy"},I?"copied":"copy")]})]})}):null,M&&o.jsx(Yt,{delay:it(),children:M}),a?null:o.jsx(Yt,{delay:it(),children:o.jsx(um,{rows:O,from:E,to:F,period:L,timeZoneLabel:B,showTimeZoneLabel:!1})}),a?o.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2","data-screenshot-exclude":"true",style:Z?{display:"none"}:void 0,children:[o.jsx(jn,{type:"button",onClick:Y,variant:"primary",size:"lg",disabled:Z,children:P}),o.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300",children:z})]}):null]}),o.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0 order-1 lg:order-2",children:[o.jsx(Yt,{delay:bt,children:o.jsx(im,{period:L,periods:G,onPeriodChange:de,summaryLabel:oe,summaryValue:pe,summaryCostValue:le,onCostInfo:De?ke:null,fleetData:R,onRefresh:a?null:Ce,loading:A,onOpenShare:a?null:n,customFrom:W,customTo:V,onCustomRangeApply:ue,customRangeOpen:me,onCustomRangeOpenChange:T,from:Q,to:j})}),a?null:o.jsx(Yt,{delay:lt,children:o.jsx(Ac,{projectEntries:g,projectLimit:x,onProjectLimitChange:p,copy:t,hasDetailsActual:J,dailyEmptyPrefix:H,installSyncCmd:ie,dailyEmptySuffix:se,detailsColumns:xe,ariaSortFor:_e,toggleSort:Ne,sortIconFor:ae,pagedDetails:ge,dailyBreakdownRows:Se,dailyBreakdownColumns:we,dailyBreakdownAriaSortFor:Re,dailyBreakdownSortIconFor:ot,dailyBreakdownDateKey:Nt,detailsDateKey:gt,renderDetailDate:yt,renderDailyBreakdownDate:jt,renderDetailCell:ee,DETAILS_PAGED_PERIODS:ne,period:L,detailsPageCount:U,detailsPage:te,setDetailsPage:Oe})})]})]})}),o.jsx(Tc,{isOpen:Ie,onClose:je,fleetData:R})]})}function Zo(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ft=new Map,Wt=new Map;function es(){typeof window>"u"||window.__tokentrackerNativeSaveListener||(window.__tokentrackerNativeSaveListener=!0,window.addEventListener("native:saveImageResult",e=>{const t=e?.detail||{},n=typeof t.requestId=="string"?t.requestId:null;if(!n||!Ft.has(n))return;const a=Ft.get(n);Ft.delete(n),a({ok:!!t.ok,path:typeof t.path=="string"?t.path:void 0,error:typeof t.error=="string"?t.error:void 0})}),window.addEventListener("native:copyImageResult",e=>{const t=e?.detail||{},n=typeof t.requestId=="string"?t.requestId:null;if(!n||!Wt.has(n))return;const a=Wt.get(n);Wt.delete(n),a({ok:!!t.ok,error:typeof t.error=="string"?t.error:void 0})}))}async function vm(e){if(!Zo()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const t=window?.webkit?.messageHandlers?.nativeBridge;if(!t)return{ok:!1,error:"native bridge unavailable"};es();const n=`copy_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(a=>{const r=window.setTimeout(()=>{Wt.has(n)&&(Wt.delete(n),a({ok:!1,error:"timeout"}))},8e3);Wt.set(n,s=>{window.clearTimeout(r),a(s)});try{t.postMessage({type:"action",name:"copyImageToClipboard",requestId:n,dataUrl:e})}catch(s){Wt.delete(n),window.clearTimeout(r),a({ok:!1,error:s?.message||String(s)})}})}async function qr(e,t){if(!Zo()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const n=window?.webkit?.messageHandlers?.nativeBridge;if(!n)return{ok:!1,error:"native bridge unavailable"};es();const a=`save_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{const s=window.setTimeout(()=>{Ft.has(a)&&(Ft.delete(a),r({ok:!1,error:"timeout"}))},8e3);Ft.set(a,i=>{window.clearTimeout(s),r(i)});try{n.postMessage({type:"action",name:"saveImageToDownloads",requestId:a,filename:t,dataUrl:e})}catch(i){Ft.delete(a),window.clearTimeout(s),r({ok:!1,error:i?.message||String(i)})}})}const ts=1200,ns=1630,as={broadsheet:{width:1200,height:1630},"annual-report":{width:1080,height:1865}},_m="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 oa=!1;function Nm(){if(typeof document>"u"||oa)return;if(document.querySelector('link[data-share-card-fonts="true"]')){oa=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=_m,t.dataset.shareCardFonts="true",t.crossOrigin="anonymous",document.head.appendChild(t),oa=!0}async function jm(){if(typeof document>"u")return;const e=document.fonts;if(!(!e||typeof e.ready?.then!="function"))try{await e.ready}catch{}}async function Sm(e,t={}){if(typeof window>"u"||!e)return null;Nm(),await jm(),await new Promise(c=>requestAnimationFrame(()=>c(null)));const{toBlob:n,toPng:a}=await io(async()=>{const{toBlob:c,toPng:d}=await import("./index-BeoRn2gJ.js");return{toBlob:c,toPng:d}},[]),r=t.pixelRatio??2,s=e.offsetWidth||ts,i=e.offsetHeight||ns,l={pixelRatio:r,cacheBust:!0,width:s,height:i,style:{width:`${s}px`,height:`${i}px`},skipFonts:!1,filter:c=>!(c instanceof HTMLElement)||c.dataset?.screenshotExclude!=="true"};try{const c=await n(e,l);if(c)return c}catch{}try{const c=await a(e,l);return c?await(await fetch(c)).blob():null}catch{return null}}async function sa(e){return new Promise(t=>{const n=new FileReader;n.onload=()=>{const a=typeof n.result=="string"?n.result:null;t(a)},n.onerror=()=>t(null),n.readAsDataURL(e)})}function Gr(e,t){if(typeof window>"u"||!e)return!1;try{const n=URL.createObjectURL(e),a=document.createElement("a");return a.href=n,a.download=t,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3),!0}catch{return!1}}function ga(e){const t=ze(e);return Number.isFinite(t)?t:0}function Mm(e){return e?ga(e.billable_total_tokens??e.total_tokens):0}function Cm(e){const t=Array.isArray(e?.weeks)?e.weeks:[];if(!t.length)return{weeks:[],totalDays:0,activeDays:0};let n=0,a=0;return{weeks:t.map(s=>(Array.isArray(s)?s:[]).slice(0,7).map(l=>{const c=!!l?.future,d=Number.isFinite(l?.level)?Math.max(0,Math.min(4,Math.round(l.level))):0;l?.day&&!c&&(n+=1,d>0&&(a+=1));const f=l?.billable_total_tokens??l?.total_tokens??l?.value??0,u=Number.isFinite(f)?Math.max(0,f):0;return{day:typeof l?.day=="string"?l.day:"",level:d,value:u,future:c}})),totalDays:n,activeDays:a}}function Dm(e){const{handle:t,startDate:n,activeDays:a,summary:r,topModels:s,rank:i,period:l,periodFrom:c,periodTo:d,heatmap:f,capturedAt:u}=e,y=Mm(r),g=ga(r?.total_cost_usd),x=Array.isArray(s)?s.slice(0,3).map(b=>({id:b?.id??null,name:typeof b?.name=="string"&&b.name?b.name:"—",tokens:ga(b?.tokens),percent:typeof b?.percent=="string"&&b.percent?b.percent:"0.0"})):[],p=Cm(f);return{handle:t||"—",startDate:n||null,activeDays:Number.isFinite(a)&&a>0?Math.floor(a):0,totalTokens:y,totalCost:g,period:l,periodFrom:c,periodTo:d,topModels:x,rank:typeof i=="number"&&Number.isFinite(i)&&i>0?Math.floor(i):null,heatmapWeeks:p.weeks,heatmapTotalDays:p.totalDays,heatmapActiveDays:p.activeDays,capturedAt:u||new Date().toISOString()}}const Tm=["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 Am(e){const t=Tm[e];return t?h(t):"—"}function rs(e,t){return h("share.date.month_year",{month:Am(e),year:t})}function Om(e){if(!e)return"—";const t=e.split("-");if(t.length!==3)return e;const[n,a]=t,r=Number(a)-1;return r<0||r>11?e:rs(r,n)}function Em(e){if(e.period==="total")return h("share.issue.all_time");if(e.period==="day"&&e.periodTo)return e.periodTo.replace(/-/g,".");if(e.period==="custom"&&e.periodFrom&&e.periodTo)return`${e.periodFrom.replace(/-/g,".")} — ${e.periodTo.replace(/-/g,".")}`;if(e.periodTo){const t=new Date(`${e.periodTo}T00:00:00Z`);if(!Number.isNaN(t.getTime()))return rs(t.getUTCMonth(),t.getUTCFullYear())}return h(`usage.period.${e.period}`)}function ya(e){return Number.isFinite(e)?Math.round(e).toLocaleString("en-US"):"—"}function os(e){return!Number.isFinite(e)||e<=0?"$0.00":e>=1e3?`$${Math.round(e).toLocaleString("en-US")}`:`$${e.toFixed(2)}`}function Fm(e){const t=e.topModels[0];if(t){const n=parseFloat(t.percent);return Number.isFinite(n)&&n>=60?h("share.hook.top_loyal",{percent:Math.round(n),name:t.name}):e.activeDays>=60?h("share.hook.days_record",{days:e.activeDays}):Number.isFinite(n)&&n>=30?h("share.hook.top_led",{name:t.name,percent:Math.round(n)}):e.topModels.length>1?h("share.hook.multi_models",{count:e.topModels.length,days:e.activeDays}):h("share.hook.days_with_model",{days:e.activeDays,name:t.name})}return e.activeDays>0?h("share.hook.days_record",{days:e.activeDays}):h("share.hook.new_chapter")}function Wm(e,t){const n=(e||"").length;if(n<=t.baseChars)return t.baseSize;const a=t.baseSize-(n-t.baseChars)*t.shrinkPerChar;return Math.max(t.minSize,a)}function Pm(e){if(!e||e.future)return null;const t=typeof e.level=="number"?e.level:0;return t<0?0:t>4?4:Math.round(t)}function Im({weeks:e,palette:t,width:n,gap:a=3,radius:r=2,emptyColor:s}){if(!Array.isArray(e)||e.length===0||!n||n<=0)return null;const i=t||["#eee","#ccc","#999","#666","#333"],l=s||i[0],c=e.length,d=(c-1)*a,f=Math.max(4,(n-d)/c),u=7*f+6*a;return o.jsx("svg",{width:n,height:u,viewBox:`0 0 ${n} ${u}`,xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,style:{display:"block"},children:e.map((y,g)=>(Array.isArray(y)?y:[]).map((p,b)=>{if(b>=7)return null;const k=Pm(p),v=g*(f+a),w=b*(f+a),C=k===null?l:i[k];return o.jsx("rect",{x:v,y:w,width:f,height:f,rx:r,ry:r,fill:C},`${g}-${b}`)}))})}const Lm="oklch(0.97 0.01 85)",Be="oklch(0.18 0.02 85)",vt="oklch(0.38 0.015 85)",Vr="oklch(0.55 0.012 85)",Dt="oklch(0.55 0.22 25)",Tt='"Instrument Serif", "Times New Roman", Georgia, serif',$m='"Inter Tight", "Helvetica Neue", Arial, sans-serif',Rm=["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)"];function ss({data:e}){const t=Em(e),n=ya(e.totalTokens),a=os(e.totalCost),r=Om(e.startDate),s=Wm(n,{baseSize:188,baseChars:9,shrinkPerChar:14,minSize:104}),i=Fm(e),l=Array.isArray(e.heatmapWeeks)&&e.heatmapWeeks.length>0;return o.jsxs("div",{style:{width:"100%",height:"100%",background:Lm,color:Be,fontFamily:$m,padding:"80px 88px 68px 88px",boxSizing:"border-box",display:"flex",flexDirection:"column",position:"relative"},children:[o.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,paddingBottom:14,borderBottom:`1px solid ${Vr}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,fontSize:14,fontWeight:500,letterSpacing:"0.22em",textTransform:"uppercase",color:Be},children:[o.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:Dt}}),"The Token Tracker"]}),o.jsxs("div",{style:{fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:vt,textAlign:"right"},children:[h("share.card.broadsheet.issue")," № ",t]})]}),o.jsxs("div",{style:{marginTop:24,display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:24},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:12,letterSpacing:"0.2em",textTransform:"uppercase",color:vt,marginBottom:6},children:h("share.card.broadsheet.by")}),o.jsx("div",{style:{fontFamily:Tt,fontSize:52,fontStyle:"italic",lineHeight:1,color:Be,letterSpacing:"-0.01em"},children:e.handle})]}),o.jsxs("div",{style:{fontSize:12,letterSpacing:"0.18em",textTransform:"uppercase",color:vt,textAlign:"right",lineHeight:1.6},children:[h("share.card.broadsheet.tracked_since"),o.jsx("br",{}),o.jsx("span",{style:{color:Be},children:r})]})]}),o.jsxs("div",{style:{marginTop:40,display:"flex",flexDirection:"column"},children:[o.jsx("div",{style:{fontSize:13,letterSpacing:"0.3em",textTransform:"uppercase",color:Dt,marginBottom:10},children:h("share.card.broadsheet.total_tokens")}),o.jsx("div",{style:{fontFamily:Tt,fontSize:s,fontWeight:400,lineHeight:.86,letterSpacing:"-0.032em",color:Be,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap",overflow:"hidden"},children:n}),o.jsxs("div",{style:{marginTop:14,fontFamily:Tt,fontStyle:"italic",fontSize:34,lineHeight:1.15,color:Be,letterSpacing:"-0.005em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:["“",i,"”"]}),o.jsx("div",{style:{marginTop:14,height:1,background:Dt,width:"100%"}}),o.jsxs("div",{style:{marginTop:10,display:"flex",justifyContent:"space-between",fontSize:13,letterSpacing:"0.16em",textTransform:"uppercase",color:vt},children:[o.jsxs("span",{children:[h("share.card.broadsheet.estimated_spend")," · ",a]}),o.jsx("span",{children:h("share.card.broadsheet.billable_days",{days:e.activeDays})})]})]}),l?o.jsxs("section",{style:{marginTop:40},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:12},children:[o.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Be,fontWeight:600},children:h("share.card.broadsheet.heatmap_title")}),o.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:vt},children:h("share.card.broadsheet.heatmap_days_on_record",{active:e.heatmapActiveDays,total:e.heatmapTotalDays})})]}),o.jsx(Im,{weeks:e.heatmapWeeks,palette:Rm,width:1024,gap:3,radius:2})]}):null,o.jsxs("section",{style:{marginTop:30,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",borderBottom:`1px solid ${Be}`,paddingBottom:10,marginBottom:6},children:[o.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Be,fontWeight:600},children:h("share.card.broadsheet.roster_title")}),o.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:vt},children:h("share.card.broadsheet.roster_subtitle")})]}),e.topModels.length===0?o.jsx("div",{style:{fontFamily:Tt,fontStyle:"italic",fontSize:26,color:vt,paddingTop:14},children:h("share.card.broadsheet.empty")}):e.topModels.map((c,d)=>o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"52px 1fr auto 68px",alignItems:"baseline",gap:16,padding:"13px 0",borderBottom:`1px solid ${Vr}`},children:[o.jsx("div",{style:{fontFamily:Tt,fontSize:34,fontStyle:"italic",color:Dt,lineHeight:1},children:String(d+1).padStart(2,"0")}),o.jsx("div",{style:{fontFamily:Tt,fontSize:32,color:Be,lineHeight:1.1,letterSpacing:"-0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name}),o.jsx("div",{style:{fontFamily:Tt,fontSize:28,color:Be,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap"},children:ya(c.tokens)}),o.jsxs("div",{style:{fontSize:13,letterSpacing:"0.1em",color:vt,textAlign:"right",fontFeatureSettings:'"tnum" 1'},children:[c.percent,"%"]})]},c.id||c.name))]}),o.jsxs("footer",{style:{marginTop:18,paddingTop:12,borderTop:`1px solid ${Be}`,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:Be},children:[o.jsxs("div",{style:{display:"flex",gap:28},children:[o.jsxs("span",{children:[h("share.card.broadsheet.global_rank")," ",o.jsxs("span",{style:{color:Dt},children:["№ ",e.rank!=null?e.rank:"—"]})]}),o.jsxs("span",{children:[h("share.card.broadsheet.active_days")," ",o.jsx("span",{style:{color:Dt},children:h("share.card.broadsheet.days_count",{days:e.activeDays})})]})]}),o.jsxs("div",{children:[h("share.card.broadsheet.track_yours")," ",o.jsx("span",{style:{color:Dt},children:"→ tokentracker.cc"})]})]})]})}const Bm=as["annual-report"].width,Ym="#0a0820",_t="#ffffffee",Ot="rgba(255,255,255,0.45)",ia="#a78bfa",zm={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(", ")},wn={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"},pa='"Space Grotesk", "Inter Tight", sans-serif',la='"Inter Tight", sans-serif',Hm="rgba(255,255,255,0.06)",is=[Hm,"#4a3d8f","#6b5cbe","#9060e0","#d946ef"],ls=48,cs=28,Mn=4,ds=20,Um=Bm-ls*2-cs*2,qm=(Um-ds*2)/3,xa=Math.min(Math.floor((qm-Mn*6)/7),40),Gm=xa*7+Mn*6;function Vm(e){if(!Array.isArray(e))return e;const t=[];for(const l of e)if(Array.isArray(l))for(const c of l)c?.day&&!c.future&&c.value>0&&t.push(c.value);if(!t.length)return e;t.sort((l,c)=>l-c);const n=l=>{const c=t.length,d=(c-1)*l,f=Math.floor(d);return Math.round((t[f]??0)+((t[Math.min(c-1,f+1)]??0)-(t[f]??0))*(d-f))},a=n(.5),r=n(.75),s=n(.9),i=l=>!l||l<=0?0:l<=a?1:l<=r?2:l<=s?3:4;return e.map(l=>Array.isArray(l)?l.map(c=>c?.day&&!c.future&&typeof c.value=="number"?{...c,level:i(c.value)}:c):l)}function Km(e){if(!Array.isArray(e))return[];const t={},n=Vm(e);for(const a of n)if(Array.isArray(a))for(const r of a){if(!r?.day||r.future)continue;const s=r.day.split("-");if(s.length<2)continue;const i=`${s[0]}-${s[1]}`;(t[i]??=[]).push(r)}return Object.entries(t).sort(([a],[r])=>a.localeCompare(r)).slice(-12).map(([a,r])=>({month:parseInt(a.split("-")[1],10),cells:r}))}function Xm(e){if(!e.length)return[];const t=[...e].sort((i,l)=>i.day.localeCompare(l.day));let n=new Date(`${t[0].day}T00:00:00Z`).getUTCDay();const a=Array(n).fill(null).concat(t),r=[];for(let i=0;i<a.length;i+=7)r.push(a.slice(i,i+7));const s=r[r.length-1];for(;s&&s.length<7;)s.push(null);return r.slice(0,6)}const Qm=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Jm(e){if(!Array.isArray(e))return 0;const t=[];for(const r of e)if(Array.isArray(r))for(const s of r)s?.day&&!s.future&&t.push(s);t.sort((r,s)=>r.day.localeCompare(s.day));let n=0,a=0;for(const r of t)(r.level||0)>0?(a++,a>n&&(n=a)):a=0;return n}function Kr(e){const[t,n]=m.useState(null);return m.useEffect(()=>{if(!e){n(null);return}let a=!1;const r=new Image;return r.crossOrigin="anonymous",r.onload=()=>{if(!a)try{const s=document.createElement("canvas");s.width=r.naturalWidth,s.height=r.naturalHeight,s.getContext("2d").drawImage(r,0,0),n(s.toDataURL("image/png"))}catch{n(null)}},r.onerror=()=>{a||n(null)},r.src=e,()=>{a=!0}},[e]),t}function Zm({data:e}){const t=Xm(e.cells);return o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:16,fontWeight:600,color:Ot,fontFamily:pa,marginBottom:4},children:Qm[e.month]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:Mn},children:t.map((n,a)=>o.jsx("div",{style:{display:"flex",gap:Mn},children:n.map((r,s)=>{const i=r?Math.min(4,Math.max(0,r.level||0)):-1;return o.jsx("div",{style:{width:xa,height:xa,borderRadius:4,background:i<0?"transparent":is[i]}},s)})},a))})]})}function eh({data:e}){const t=Km(e.heatmapWeeks),n=Jm(e.heatmapWeeks),a=e.topModels[0],r=e.avatarUrl||null,s=Kr(r),i=Kr("/neon_bg.png"),l=(e.handle||"?")[0].toUpperCase(),c=16;return o.jsxs("div",{style:{width:"100%",height:"100%",background:Ym,fontFamily:pa,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[o.jsx("img",{src:i||"/neon_bg.png",alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),o.jsxs("div",{style:{position:"relative",zIndex:1,display:"flex",flexDirection:"column",height:"100%",padding:ls,boxSizing:"border-box"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:c*3},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[o.jsx("img",{src:"/app-icon.png",alt:"",width:64,height:64,style:{width:64,height:64,borderRadius:16,display:"block"}}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:20,fontWeight:500,color:Ot,lineHeight:1.2},children:"Token Tracker"}),o.jsx("div",{style:{fontSize:36,fontWeight:700,lineHeight:1.15,color:_t},children:h("share.card.annual.report_title")})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.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:s?o.jsx("img",{src:s,alt:"",width:48,height:48,style:{width:48,height:48,objectFit:"cover",display:"block"},crossOrigin:"anonymous",referrerPolicy:"no-referrer"}):o.jsx("span",{style:{fontSize:20,fontWeight:700,color:_t},children:l})}),o.jsx("div",{style:{fontSize:32,fontWeight:700,color:_t},children:e.handle})]})]}),o.jsxs("div",{style:{...zm,borderRadius:22,padding:cs,marginBottom:c},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:14,color:Ot},children:[o.jsx("span",{children:h("share.card.annual.less")}),is.map((d,f)=>o.jsx("div",{style:{width:16,height:16,borderRadius:3,background:d}},f)),o.jsx("span",{children:h("share.card.annual.more")})]}),o.jsx("div",{style:{fontSize:16,fontWeight:700,letterSpacing:"0.14em",color:"rgba(255,255,255,0.22)",textTransform:"uppercase"},children:h("share.card.annual.heatmap_title")})]}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(3,${Gm}px)`,gap:`8px ${ds}px`,justifyContent:"center"},children:t.map(d=>o.jsx(Zm,{data:d},d.month))})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:c,marginBottom:c},children:[o.jsxs("div",{style:{...wn,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[o.jsx("div",{style:{fontFamily:la,fontSize:52,fontWeight:700,color:_t,letterSpacing:"-0.02em",lineHeight:1},children:ya(e.totalTokens)}),o.jsx("div",{style:{fontSize:22,color:Ot,marginTop:12},children:h("share.card.annual.total_tokens")})]}),o.jsxs("div",{style:{...wn,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[o.jsx("div",{style:{fontFamily:la,fontSize:52,fontWeight:700,color:_t,letterSpacing:"-0.02em",lineHeight:1},children:os(e.totalCost)}),o.jsx("div",{style:{fontSize:22,color:Ot,marginTop:12},children:h("share.card.annual.estimated_cost")})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c},children:[o.jsxs("div",{style:{...wn,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:ia,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.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"}),o.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),o.jsx("span",{style:{fontSize:20,color:Ot},children:h("share.card.annual.longest_streak")})]}),o.jsx("span",{style:{fontFamily:la,fontSize:28,fontWeight:700,color:_t},children:h("share.card.annual.days_count",{days:n})})]}),o.jsxs("div",{style:{...wn,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:ia,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.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"}),o.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),o.jsx("span",{style:{fontSize:20,color:Ot},children:h("share.card.annual.top_model")})]}),o.jsx("span",{style:{fontFamily:pa,fontSize:28,fontWeight:700,color:_t},children:a?a.name:"—"})]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"auto"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("img",{src:"/app-icon.png",alt:"",width:44,height:44,style:{width:44,height:44,borderRadius:8,display:"block"}}),o.jsx("span",{style:{fontSize:22,fontWeight:600,color:_t},children:"Token Tracker"})]}),o.jsx("span",{style:{fontSize:22,fontWeight:600,color:ia},children:"tokentracker.cc"})]})]})]})}const us=[{id:"annual-report",labelKey:"share.variant.neon"},{id:"broadsheet",labelKey:"share.variant.broadsheet"}],th={broadsheet:ss,"annual-report":eh};function fs(e){return as[e]||{width:ts,height:ns}}function nh(e){const t=us.find(n=>n.id===e);return t?.labelKey?h(t.labelKey):e}const Xr=m.forwardRef(function({data:t,variant:n},a){const r=th[n]||ss,{width:s,height:i}=fs(n);return o.jsx("div",{ref:a,"data-share-card":"true",style:{width:s,height:i,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:o.jsx(r,{data:t})})});function vn(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const ah=440;function rh(){const[e,t]=m.useState(null),n=m.useRef(null),a=m.useCallback((r,s="info")=>{n.current&&window.clearTimeout(n.current),t({id:Date.now(),kind:s,text:r}),n.current=window.setTimeout(()=>t(null),2800)},[]);return m.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{toast:e,push:a}}function ca({onClick:e,disabled:t,children:n,emphasis:a,ariaLabel:r}){return o.jsx("button",{type:"button",onClick:e,disabled:t,"aria-label":r,className:["group relative flex items-center justify-between gap-3 w-full px-4 py-3 text-left","rounded-lg border transition-colors",a?"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",t?"opacity-60 cursor-not-allowed":"cursor-pointer"].join(" "),children:n})}function oh({open:e,onClose:t,data:n,twitterText:a}){const[r,s]=m.useState(null),[i,l]=m.useState(""),[c,d]=m.useState("annual-report"),f=m.useRef(null),{toast:u,push:y}=rh(),g=so(),x=m.useMemo(()=>{const N=g?.user;if(!N||typeof N!="object")return null;const O=N.user_metadata||{},E=N.profile||{},F=O.avatar_url||O.picture||E.avatar_url||N.avatar_url;return typeof F=="string"&&F.trim()?F.trim():null},[g?.user]);m.useEffect(()=>{e&&(s(null),l(n?.handle||""))},[e,n?.handle]);const p=n&&{...n,handle:i||n.handle,avatarUrl:x},{width:b,height:k}=fs(c),v=ah/b;m.useEffect(()=>{if(!e)return;const N=O=>{O.key==="Escape"&&t?.()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,t]);const w=m.useCallback(async()=>{const N=f.current;if(!N)return null;try{return await Sm(N)}catch(O){return console.warn("[share] capture failed",O),null}},[]),C=m.useCallback(async()=>{if(r)return;s("copy");const N=await w();if(!N){y(h("share.toast.failed"),"error"),s(null);return}let O=!1;if(vn()){const E=await sa(N);E&&(O=(await vm(E)).ok)}else O=await ma(N);y(O?h("share.toast.copied"):h("share.toast.failed"),O?"success":"error"),s(null)},[r,w,y]),D=m.useCallback(()=>`tokentracker-share-${Date.now()}.png`,[]),S=m.useCallback(async()=>{if(r)return;s("download");const N=await w();if(!N){y(h("share.toast.failed"),"error"),s(null);return}if(vn()){const E=await sa(N);if(E&&(await qr(E,D())).ok){y(h("share.toast.downloaded"),"success"),s(null);return}}const O=Gr(N,D());y(O?h("share.toast.downloaded"):h("share.toast.failed"),O?"success":"error"),s(null)},[r,w,D,y]),I=m.useCallback(async()=>{if(r)return;s("x");const N=await w();if(!N){y(h("share.toast.failed"),"error"),s(null);return}if(vn()){const E=await sa(N);E&&(await qr(E,D()),y(h("share.toast.downloaded"),"success"))}else await ma(N)?y(h("share.toast.copied"),"success"):Gr(N,D());const O=new URL("https://twitter.com/intent/tweet");if(a&&O.searchParams.set("text",a),vn())try{window.webkit?.messageHandlers?.nativeBridge?.postMessage({type:"action",name:"openURL",value:O.toString()})}catch{window.open(O.toString(),"_blank","noopener,noreferrer")}else window.open(O.toString(),"_blank","noopener,noreferrer");s(null)},[r,w,y,a,D]);return e?o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":h("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:N=>{N.target===N.currentTarget&&t?.()},children:[o.jsx("div",{"aria-hidden":!0,style:{position:"fixed",left:0,top:0,width:b,height:k,pointerEvents:"none",opacity:0,zIndex:-1,clip:"rect(0,0,0,0)",overflow:"hidden"},children:o.jsx(Xr,{ref:f,data:p,variant:c})}),o.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:[o.jsxs("div",{className:"flex flex-col lg:flex-row max-h-[92vh]",children:[o.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:o.jsxs("div",{style:{width:b*v,height:k*v,flexShrink:0,position:"relative"},className:"rounded-xl overflow-hidden shadow-oai-md ring-1 ring-black/5",children:[r?o.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-black/50",children:o.jsxs("svg",{className:"animate-spin h-6 w-6 text-oai-gray-500",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):null,o.jsx("div",{style:{width:b,height:k,transform:`scale(${v})`,transformOrigin:"top left"},children:o.jsx(Xr,{data:p,variant:c})})]})}),o.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:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-oai-white",children:h("share.modal.title")}),o.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:h("share.modal.subtitle")})]}),o.jsx("button",{type:"button",onClick:t,"aria-label":h("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:o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),o.jsxs("div",{children:[o.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:h("share.modal.name_label")}),o.jsx("input",{id:"share-handle",type:"text",value:i,onChange:N=>l(N.target.value),placeholder:h("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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:h("share.modal.style_label")}),o.jsx("div",{className:"flex gap-2",children:us.map(N=>o.jsx("button",{type:"button",onClick:()=>d(N.id),className:["flex-1 px-3 py-2 text-sm rounded-lg border transition-colors",c===N.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:nh(N.id)},N.id))})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[o.jsxs(ca,{onClick:I,disabled:!!r,emphasis:!0,children:[o.jsxs("span",{className:"flex items-center gap-3",children:[o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:o.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"})}),o.jsx("span",{className:"font-medium text-sm",children:h("share.modal.action.x")})]}),o.jsx("span",{className:"text-[11px] opacity-70",children:r==="x"?h("share.toast.working"):h("share.modal.hint.x")})]}),o.jsxs(ca,{onClick:S,disabled:!!r,children:[o.jsxs("span",{className:"flex items-center gap-3",children:[o.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:[o.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o.jsx("polyline",{points:"7 10 12 15 17 10"}),o.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),o.jsx("span",{className:"font-medium text-sm",children:h("share.modal.action.download")})]}),o.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:"PNG"})]}),o.jsxs(ca,{onClick:C,disabled:!!r,children:[o.jsxs("span",{className:"flex items-center gap-3",children:[o.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:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),o.jsx("span",{className:"font-medium text-sm",children:h("share.modal.action.copy")})]}),o.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:h("share.modal.hint.copy")})]})]}),o.jsx("div",{className:"mt-auto pt-4 border-t border-oai-gray-200 dark:border-oai-gray-800",children:o.jsx("p",{className:"text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:h("share.modal.footer")})})]})]}),o.jsx(wa,{children:u?o.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:o.jsx("div",{className:["px-4 py-2 rounded-full text-xs font-medium shadow-oai-md",u.kind==="error"?"bg-red-600 text-white":u.kind==="success"?"bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black":"bg-oai-gray-800 text-white"].join(" "),children:u.text})},u.id):null})]})]}):null}function sh(e){const{enabled:t,handle:n,startDate:a,activeDays:r,summary:s,topModels:i,period:l,periodFrom:c,periodTo:d,heatmap:f,accessToken:u,userId:y}=e,[g,x]=m.useState(null);return m.useEffect(()=>{if(!t||!y&&!It())return;let p=!1;return(async()=>{try{const k=await Bi({accessToken:u,userId:y,period:l==="day"||l==="custom"?"week":l,metric:"all",limit:100,offset:0});if(p)return;const w=(Array.isArray(k?.entries)?k.entries:Array.isArray(k)?k:[]).find(D=>D?.is_me===!0),C=typeof w?.rank=="number"?w.rank:null;x(C)}catch{p||x(null)}})(),()=>{p=!0}},[t,u,y,l]),m.useMemo(()=>Dm({handle:n,startDate:a,activeDays:r,summary:s,topModels:i,rank:g,period:l,periodFrom:c,periodTo:d,heatmap:f}),[n,a,r,s,i,g,l,c,d,f])}const ih=["day","week","month","total","custom"],da=new Set(["day","hour","month"]),on=new Set(["day","total","custom"]);function ua(e,t){if(typeof t=="number"&&t>0)return!0;if(typeof e=="bigint")return e>0n;if(typeof e=="number")return Number.isFinite(e)&&e>0;if(typeof e=="string"){const n=e.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const a=Number(n);return Number.isFinite(a)&&a>0}return!1}function _n(e){return e?Gt(e,null):null}function Qr(e){return e?e?.billable_total_tokens??e?.value??e?.total_tokens:null}function lh(e){if(typeof e!="string"||!e)return null;const t=e.split("-");if(t.length!==3)return null;const n=Number(t[0]),a=Number(t[1])-1,r=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(a)||!Number.isFinite(r))return null;const s=new Date(Date.UTC(n,a,r));return Number.isFinite(s.getTime())?s:null}function ch(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function dh(e){return e?e==="www.tokentracker.cc"||e==="tokentracker.cc":!1}function uh(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search),t=String(e.get("force_install")||"").toLowerCase();return t!=="1"&&t!=="true"?!1:!dh(window.location.hostname)}function wh({baseUrl:e,auth:t,signedIn:n,sessionSoftExpired:a,signOut:r,publicMode:s=!1,publicToken:i=null,signInUrl:l="/sign-in",signUpUrl:c="/sign-up"}){const{resolvedLocale:d}=Yi(),[f,u]=m.useState(!1),[y,g]=m.useState(null),[x,p]=m.useState(null),[b,k]=m.useState(!1),[v,w]=m.useState(null),[C,D]=m.useState(0),[S,I]=m.useState(0),[N,O]=m.useState(null),[E,F]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),Q=m.useMemo(()=>typeof window>"u"?!1:zi(window.location.search),[]),j=m.useMemo(()=>uh(),[]),[L,B]=m.useState(!1),[M,Z]=m.useState(!1),Y=2200,[P,z]=m.useState(!0),[G,de]=m.useState(!1),[W,V]=m.useState(!1),[ue,me]=m.useState(!1),T=It(),oe=n&&!a,pe=m.useMemo(()=>oe&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,oe]),fe=oe?pe:null,le=s?Hi(i):fe,he=n||T||s,Pe=oe&&Xt(fe),De=n&&a&&!s;m.useEffect(()=>{if(!n||T){g(null),p(null),k(!1),w(null);return}if(s)return;if(!Pe){g(null),p(null),k(!1),w(null);return}let _=!0;const q=()=>{g(null),p(null),k(!1),w(null)};return k(!0),w(null),(async()=>{let K=null;try{K=await Pt(fe)}catch{K=null}if(_){if(!K){q();return}try{const re={link_code:null,expires_at:null};if(!_)return;g(typeof re?.link_code=="string"?re.link_code:null),p(typeof re?.expires_at=="string"?re.expires_at:null)}catch(re){if(!_)return;g(null),p(null),w(re?.message||"Failed to load link code")}finally{if(!_)return;k(!1)}}})(),()=>{_=!1}},[e,T,n,s,Pe,fe,S]);const ke=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");m.useEffect(()=>{if(!ke&&(!n||T||s)){O(null);return}if(!ke&&!Pe){O(null);return}let _=!0;return(async()=>{let q=null;try{q=await Pt(fe)}catch{q=null}if(_){if(!q&&!ke){O(null);return}try{const K=await Ui({baseUrl:e,accessToken:q});if(!_)return;O(K&&typeof K=="object"?K:null)}catch{if(!_)return;O(null)}}})(),()=>{_=!1}},[Pe,e,fe,T,s,n]);const Ie=m.useMemo(()=>{if(!x)return!1;const _=Date.parse(x);if(!Number.isFinite(_))return!1;const q=C||Date.now();return _<=q},[x,C]);m.useEffect(()=>{!n||T||s||!x||!Ie||b||(g(null),p(null),w(null),I(_=>_+1))},[Ie,x,b,T,n]),m.useEffect(()=>{if(!x||s)return;const _=Date.parse(x);if(!Number.isFinite(_))return;const q=Date.now();if(D(q),_<=q)return;const K=window.setTimeout(()=>D(Date.now()),_-q),re=()=>{typeof document>"u"||document.visibilityState==="visible"&&D(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",re),window.addEventListener("focus",re),()=>{window.clearTimeout(K),typeof document<"u"&&document.removeEventListener("visibilitychange",re),window.removeEventListener("focus",re)}},[x]),m.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const _=window.matchMedia("(max-width: 640px)"),q=()=>F(_.matches);return q(),_.addEventListener?(_.addEventListener("change",q),()=>_.removeEventListener("change",q)):(_.addListener(q),()=>_.removeListener(q))},[]);const je=m.useMemo(()=>oo(),[]),Te=m.useMemo(()=>ro(),[]),Ce=m.useMemo(()=>qi(),[]),A=s?null:t?.userId||t?.email||"default",[R,J]=m.useState("month"),[H,ie]=m.useState(null),[se,xe]=m.useState(null),[_e,Ne]=m.useState(!1),ae=Q?"total":R,ge=m.useMemo(()=>ae==="custom"&&H&&se?{from:H,to:se}:Gi(ae,{timeZone:je,offsetMinutes:Te,now:Ce}),[Ce,ae,je,Te,H,se]),Se=ge.from,we=ge.to,Re=m.useMemo(()=>Vi({timeZone:je,offsetMinutes:Te}),[je,Te]),ot=m.useMemo(()=>Ki({timeZone:je,offsetMinutes:Te}),[je,Te]),Nt=m.useMemo(()=>`Local time (${ot})`,[ot]),gt=je,yt=Te,jt=Re,ee=m.useMemo(()=>ka({timeZone:je,offsetMinutes:Te,date:Ce||new Date}),[Ce,je,Te]),ne=m.useMemo(()=>{const _=lh(ee)||new Date,q=ch(_,-29);return{from:qt(q),to:qt(_)}},[ee]),{daily:U,summary:te,rolling:Oe,source:ce,loading:pt,error:xt,refresh:bt}=cr({baseUrl:e,accessToken:le,guestAllowed:De,from:Se,to:we,includeDaily:ae!=="total",cacheKey:A,timeZone:je,tzOffsetMinutes:Te,now:Ce}),{daily:Ge,loading:st,refresh:it}=cr({baseUrl:e,accessToken:le,guestAllowed:De,from:ne.from,to:ne.to,includeDaily:!0,cacheKey:A?`${A}.daily-breakdown`:"daily-breakdown",timeZone:je,tzOffsetMinutes:Te,now:Ce}),{breakdown:lt,loading:ms,refresh:Fa}=zl({baseUrl:e,accessToken:le,guestAllowed:De,from:Se,to:we,cacheKey:A,timeZone:je,tzOffsetMinutes:Te}),[Wa,hs]=m.useState(3),{entries:gs,loading:ys,refresh:Pa}=Fl({baseUrl:e,accessToken:le,limit:Wa,from:Se,to:we,timeZone:je,tzOffsetMinutes:Te}),Ia=ae==="week"||ae==="month",mn=ae==="week"||ae==="month",La=m.useMemo(()=>U.filter(_=>_?.future?!1:!_?.day||!ee?!0:String(_.day)<=String(ee)),[U,ee]),{rows:ct,from:ps,to:xs,loading:bs,refresh:$a}=Pl({baseUrl:e,accessToken:le,guestAllowed:De,period:ae,from:Se,to:we,months:24,cacheKey:A,timeZone:gt,tzOffsetMinutes:yt,now:Ce,sharedRows:Ia?U:null,sharedRange:Ia?{from:Se,to:we}:null}),{daily:Lt,heatmap:Je,loading:Ra,refresh:Ba}=El({baseUrl:e,accessToken:le,guestAllowed:De,weeks:52,cacheKey:A,timeZone:je,tzOffsetMinutes:Te,now:Ce}),{refresh:Ya}=Qi(),Ve=m.useMemo(()=>ae==="day"?"hour":ae==="total"?"month":"day",[ae]),ks=m.useMemo(()=>ur(Ve),[Ve]),hn="day",ws=m.useMemo(()=>ur(hn),[]),[Ke,za]=m.useState(()=>({key:"day",dir:"desc"}));m.useEffect(()=>{za(_=>!da.has(_.key)||_.key===Ve?_:{key:Ve,dir:_.dir})},[Ve]);const $t=m.useMemo(()=>da.has(Ke.key)&&Ke.key!==Ve?{...Ke,key:Ve}:Ke,[Ve,Ke]),gn=m.useMemo(()=>{if(ae==="day")return Array.isArray(ct)?ct.filter(K=>K?.hour&&!K?.future):[];if(ae==="total"){const K=Array.isArray(ct)?ct.filter(re=>re?.month&&!re?.future):[];return nc(K)}const _=La;return!_.some(K=>!K?.missing&&!K?.future)&&U.length>0?U.filter(K=>!K?.future).slice(-30).filter(K=>K?.day):_},[ae,ct,La,U]),Jt=m.useMemo(()=>fr(gn,$t),[gn,$t]),vs=m.useMemo(()=>gn.some(_=>!_?.missing&&!_?.future),[gn]),On=m.useMemo(()=>{if(!on.has(ae))return 1;const _=Math.ceil(Jt.length/Sn);return _>0?_:1},[ae,Jt.length]),[En,yn]=m.useState(0);m.useEffect(()=>{if(!on.has(ae)){yn(0);return}yn(_=>Math.min(_,On-1))},[On,ae]),m.useEffect(()=>{on.has(ae)&&yn(0)},[ae,Ke.dir,Ke.key]);const _s=m.useMemo(()=>on.has(ae)?ac(Jt,En,Sn):Jt,[En,ae,Jt]),Ha=m.useMemo(()=>Ge.filter(_=>!_?.future&&_?.day).slice(-30),[Ge]),Rt=m.useMemo(()=>da.has(Ke.key)?{...Ke,key:hn}:Ke,[Ke]),Ns=m.useMemo(()=>fr(Ha,Rt),[Ha,Rt]),js=m.useMemo(()=>mn?U:ae==="day"?Array.isArray(ct)?ct.filter(_=>_?.hour):[]:ct,[U,ae,ct,mn]),Ss=mn?Se:ps,Ms=mn?we:xs;function Cs(_,q){return _?.future?"—":_?.missing?h("shared.status.unsynced"):q==="total_tokens"?dt(_n(_)):dt(_?.[q])}function Ds(_){const q=_?.[Ve];if(q==null)return"";const K=String(q);if(Ve==="hour"){const[re,Fe]=K.split("T");if(re&&Fe)return`${re} ${Fe.slice(0,5)}`}return K}function Ts(_){const q=_?.[hn];return q==null?"":String(q)}function As(_){za(q=>q.key===_?{key:_,dir:q.dir==="asc"?"desc":"asc"}:{key:_,dir:"desc"})}function Os(_){return $t.key!==_?"none":$t.dir==="asc"?"ascending":"descending"}function Es(_){return $t.key!==_?"":$t.dir==="asc"?"▲":"▼"}function Fs(_){return Rt.key!==_?"none":Rt.dir==="asc"?"ascending":"descending"}function Ws(_){return Rt.key!==_?"":Rt.dir==="asc"?"▲":"▼"}const Fn=m.useMemo(()=>{if(!n&&!T&&!s&&!ke)return 0;const _=Number(Je?.active_days);if(Number.isFinite(_))return _;let q=0;const K=new Set,re=(ve,Ae,We)=>{typeof ve!="string"||!ve||K.has(ve)||ua(Ae,We)&&(K.add(ve),q+=1)};if(Array.isArray(Lt))for(const ve of Lt)re(ve?.day,_n(ve));const Fe=Array.isArray(Je?.weeks)?Je.weeks:[];for(const ve of Fe)for(const Ae of Array.isArray(ve)?ve:[]){const We=Qr(Ae);re(Ae?.day,We,Ae?.level)}return q},[n,T,Je?.active_days,Je?.weeks,Lt]),[Ua,qa]=m.useState("month"),Ps=m.useCallback(_=>{_==="custom"?(qa(q=>q==="custom"?"month":q),J(q=>H&&se?"custom":q),Ne(!0)):(J(_),qa(_),Ne(!1))},[H,se]),Is=m.useCallback((_,q)=>{ie(_),xe(q),J("custom"),Ne(!1)},[]),Ls=m.useCallback(_=>{Ne(_),!_&&R==="custom"&&!H&&J(Ua)},[R,H,Ua]),Ga=m.useCallback(async()=>{await Promise.all([bt(),Ba(),$a(),Fa(),Pa(),it(),Ya()])},[it,Ba,Fa,Pa,$a,bt,Ya]),$s=m.useCallback(async()=>{me(!0);try{ke&&await Xi(),await Ga()}catch(_){console.error("[DashboardPage] Refresh failed:",_)}finally{me(!1)}},[ke,Ga]),Rs=ue||pt||st||Ra||bs||ms||ys,Bs=m.useMemo(()=>h("shared.data_source",{source:String(ce||"edge").toUpperCase()}),[ce,d]),pn=m.useMemo(()=>typeof t?.name!="string"?"":t.name.trim(),[t?.name]),Ys="",Va=m.useMemo(()=>!pn||pn.includes("@")?h("dashboard.identity.fallback"):pn,[pn]),Ka=m.useMemo(()=>Va.replace(/[^a-zA-Z0-9._-]/g,"_"),[Va]),Xa=m.useMemo(()=>s?h("dashboard.identity.fallback"):Ka,[Ka,Ys,s]),Qa=m.useMemo(()=>{let _=null;const q=re=>{typeof re!="string"||!re||(!_||re<_)&&(_=re)};if(Array.isArray(Lt))for(const re of Lt)re?.day&&ua(_n(re))&&q(re.day);const K=Array.isArray(Je?.weeks)?Je.weeks:[];for(const re of K)for(const Fe of Array.isArray(re)?re:[]){if(!Fe?.day)continue;const ve=Qr(Fe),Ae=Fe?.level;ua(ve,Ae)&&q(Fe.day)}return _},[Je?.weeks,Lt]),zs=m.useMemo(()=>s?[]:(Array.isArray(N?.subscriptions?.items)?N.subscriptions.items:[]).map(K=>{const re=typeof K?.tool=="string"?K.tool.trim():"",ve=(typeof K?.plan_type=="string"?K.plan_type:typeof K?.planType=="string"?K.planType:"").trim();return!re||!ve?null:{tool:re,planType:ve,provider:typeof K?.provider=="string"?K.provider.trim():"",product:typeof K?.product=="string"?K.product.trim():"",rateLimitTier:typeof K?.rate_limit_tier=="string"?K.rate_limit_tier.trim():typeof K?.rateLimitTier=="string"?K.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[s,N]),Hs=o.jsx(yc,{heatmap:Je,timeZoneLabel:Re,timeZoneShortLabel:ot,hideLegend:Q,defaultToLatestMonth:Q}),Us=m.useMemo(()=>`${Se}..${we}`,[Se,ae,we]),qs=h("usage.summary.total"),St=_n(te),Ja=h("shared.unit.thousand_abbrev"),Za=h("shared.unit.million_abbrev"),er=h("shared.unit.billion_abbrev"),xn=ze(St),tr=E&&xn!=null&&Math.abs(xn)>=1e9,Gs=m.useMemo(()=>tr?He(xn,{thousandSuffix:Ja,millionSuffix:Za,billionSuffix:er,decimals:1}):dt(St),[er,Za,St,xn,Ja,tr]),Vs=h("dashboard.core_index.collapse_label"),Ks=h("dashboard.core_index.expand_label"),Xs=h("dashboard.core_index.collapse_aria"),Qs=h("dashboard.core_index.expand_aria"),Js=!Q,Zs=h("dashboard.screenshot.title_line1"),ei=h("dashboard.screenshot.title_line2"),ti=h("dashboard.screenshot.twitter_label"),ni=h("dashboard.screenshot.twitter_button"),ai=h("dashboard.screenshot.twitter_hint"),Bt=h("shared.placeholder.short"),Wn=m.useMemo(()=>{const _=Array.isArray(lt?.sources)?lt.sources:[];let q=null,K=0;for(const Ae of _){const We=Gt(Ae?.totals);!Number.isFinite(We)||We<=0||We>K&&(K=We,q=Ae)}let re=Bt,Fe=Bt,ve="0.0";if(q&&K>0){re=q?.source?String(q.source).toUpperCase():Bt;const Ae=Array.isArray(q?.models)?q.models:[];let We=0;for(const kt of Ae){const en=Gt(kt?.totals);!Number.isFinite(en)||en<=0||en>We&&(We=en,Fe=kt?.model?String(kt.model):Bt)}We>0&&(ve=(We/K*100).toFixed(1))}return{agentName:re,modelName:Fe,modelPercent:ve}},[lt,Bt]),nr=dt(St),Pn=h("dashboard.screenshot.twitter_text",{total_tokens:nr==="-"?Bt:nr,agent_name:Wn.agentName,model_name:Wn.modelName,model_percent:Wn.modelPercent}),In=m.useMemo(()=>{if(typeof window>"u")return"";const _=new URL("https://twitter.com/intent/tweet");return _.searchParams.set("text",Pn),_.toString()},[Pn]),ar=m.useCallback(async()=>{if(typeof window>"u")return null;const _=async()=>{const Ae=performance.now();for(;performance.now()-Ae<2e3;){const We=document.querySelector("[data-heatmap-scroll='true']");if(!We||We.dataset.latestMonthReady==="true")return;await new Promise(kt=>requestAnimationFrame(kt))}},q=document.querySelector("#root")||document.body,K=document.documentElement,{scrollWidth:re,scrollHeight:Fe}=document.documentElement;K?.classList.add("screenshot-capture"),document.body?.classList.add("screenshot-capture"),await new Promise(ve=>requestAnimationFrame(ve)),await _();try{const{toBlob:ve,toPng:Ae}=await io(async()=>{const{toBlob:Mt,toPng:Si}=await import("./index-BeoRn2gJ.js");return{toBlob:Mt,toPng:Si}},[]),We=await ve(q,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:re,height:Fe,style:{width:`${re}px`,height:`${Fe}px`},filter:Mt=>!(Mt instanceof HTMLElement)||Mt.dataset?.screenshotExclude!=="true"});if(We)return We;const kt=await Ae(q,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:re,height:Fe,style:{width:`${re}px`,height:`${Fe}px`},filter:Mt=>!(Mt instanceof HTMLElement)||Mt.dataset?.screenshotExclude!=="true"});return kt?await(await fetch(kt)).blob():null}finally{K?.classList.remove("screenshot-capture"),document.body?.classList.remove("screenshot-capture")}},[]),ri=m.useCallback(async()=>{if(typeof window>"u"||L)return;B(!0);const _=navigator?.userAgent||"",q=/iP(hone|od|ad)/i.test(_),K=/Safari/i.test(_)&&!/Chrome|Chromium|Edg|OPR|CriOS|FxiOS/i.test(_),re=typeof navigator<"u"&&!!navigator.clipboard?.write&&typeof window<"u"&&!!window.ClipboardItem;let ve=!re||q||K;try{const Ae=await ar();Ae&&re&&(typeof document<"u"&&!document.hasFocus()&&window.focus?.(),ve=await ma(Ae))}catch(Ae){console.error("Failed to capture screenshot",Ae)}finally{if(B(!1),!ve){console.warn("Failed to write screenshot to clipboard.");return}In&&(window.location.href=In)}},[ar,L,In]),oi=m.useMemo(()=>Q?[]:ih,[Q]),si=m.useMemo(()=>[{label:h("usage.metric.total"),value:dt(St),valueClassName:"text-white"},{label:h("usage.metric.input"),value:dt(te?.input_tokens)},{label:h("usage.metric.output"),value:dt(te?.output_tokens)},{label:h("usage.metric.cached_input"),value:dt(te?.cached_input_tokens)},{label:h("usage.metric.reasoning_output"),value:dt(te?.reasoning_output_tokens)}],[te?.cached_input_tokens,te?.input_tokens,te?.output_tokens,te?.reasoning_output_tokens,St]),Ln=m.useMemo(()=>{const _=Dn(te?.total_cost_usd);return!_||_==="-"||_.startsWith("$")?_:`$${_}`},[te?.total_cost_usd]),ii=m.useMemo(()=>te?.conversation_count??null,[te?.conversation_count]),rr=m.useMemo(()=>sc(lt,{copyFn:h}),[lt]),or=m.useMemo(()=>ic(lt,{limit:3,copyFn:h}),[lt]),li=sh({enabled:M,handle:Xa,startDate:Qa,activeDays:Fn,summary:te,topModels:or,period:ae,periodFrom:Se,periodTo:we,heatmap:Je,accessToken:typeof le=="string"?le:null,userId:t?.userId||null}),ci=m.useCallback(()=>Z(!0),[]),di=m.useCallback(()=>Z(!1),[]),ui=m.useCallback(()=>u(!0),[]),fi=m.useCallback(()=>u(!1),[]),mi=Ln&&Ln!=="-"&&rr.length>0,Zt=h("dashboard.install.cmd.init"),$n=Ie?null:y,Rn=$n?h("dashboard.install.cmd.init_link_code",{link_code:$n}):Zt,hi=Zt,gi=h("dashboard.install.cmd.sync"),yi=$n?h("dashboard.install.copy"):h("dashboard.install.copy_base"),pi=h("dashboard.install.copied");h("dashboard.session_expired.copy_label"),h("dashboard.session_expired.copied");const xi=!!(N?.install?.has_active_device_token??N?.install?.hasActiveDeviceToken),bi=rc({publicMode:s,screenshotMode:Q,forceInstall:j,accessEnabled:he,heatmapLoading:Ra,activeDays:Fn,hasActiveDeviceToken:xi}),ki=h("dashboard.install.prompt"),wi=m.useCallback(async()=>{!Rn||!await sr(Rn)||(de(!0),window.setTimeout(()=>de(!1),2e3))},[Rn]);m.useCallback(async()=>{!Zt||!await sr(Zt)||(V(!0),window.setTimeout(()=>V(!1),2e3))},[Zt]);const Bn=m.useMemo(()=>h("dashboard.daily.empty",{cmd:"{{cmd}}"}),[d]),[vi,_i]=m.useMemo(()=>{const _=Bn.split("{{cmd}}");return _.length===1?[Bn,""]:[_[0],_.slice(1).join("{{cmd}}")]},[Bn]),Ni=a&&!s,ji=!n&&!T&&!a&&!ke&&!s;return o.jsxs(o.Fragment,{children:[o.jsx(wm,{copy:h,onOpenShare:ci,screenshotMode:Q,showExpiredGate:Ni,showAuthGate:ji,screenshotTitleLine1:Zs,screenshotTitleLine2:ei,identityDisplayName:Xa,identityStartDate:Qa,activeDays:Fn,identitySubscriptions:zs,identityScrambleDurationMs:Y,projectUsageEntries:gs,projectUsageLimit:Wa,setProjectUsageLimit:hs,topModels:or,signedIn:n,publicMode:s,isLocalMode:ke,shouldShowInstall:bi,installPrompt:ki,handleCopyInstall:wi,installCopied:G,installCopiedLabel:pi,installCopyLabel:yi,installInitCmdDisplay:hi,linkCodeLoading:b,linkCodeError:v,trendRowsForDisplay:js,trendFromForDisplay:Ss,trendToForDisplay:Ms,usageFrom:Se,usageTo:we,period:ae,trendTimeZoneLabel:jt,activityHeatmapBlock:Hs,isCapturing:L,handleShareToX:ri,screenshotTwitterLabel:ti,screenshotTwitterButton:ni,screenshotTwitterHint:ai,periodsForDisplay:oi,setSelectedPeriod:Ps,customFrom:H,customTo:se,onCustomRangeApply:Is,customRangeOpen:_e,onCustomRangeOpenChange:Ls,metricsRows:si,summaryLabel:qs,summaryValue:Gs,summaryTotalTokensRaw:ze(St)||0,summaryCostValue:Ln,summaryConversationsValue:ii,rollingUsage:Oe,costInfoEnabled:mi,openCostModal:ui,allowBreakdownToggle:Js,coreIndexCollapsed:P,setCoreIndexCollapsed:z,coreIndexCollapseLabel:Vs,coreIndexExpandLabel:Ks,coreIndexCollapseAria:Xs,coreIndexExpandAria:Qs,refreshAll:$s,usageLoadingState:Rs,usageError:xt,rangeLabel:Us,timeZoneRangeLabel:Nt,usageSourceLabel:Bs,fleetData:rr,hasDetailsActual:vs,dailyEmptyPrefix:vi,installSyncCmd:gi,dailyEmptySuffix:_i,detailsColumns:ks,ariaSortFor:Os,toggleSort:As,sortIconFor:Es,pagedDetails:_s,dailyBreakdownRows:Ns,dailyBreakdownColumns:ws,dailyBreakdownAriaSortFor:Fs,dailyBreakdownSortIconFor:Ws,dailyBreakdownDateKey:hn,detailsDateKey:Ve,renderDetailDate:Ds,renderDailyBreakdownDate:Ts,renderDetailCell:Cs,DETAILS_PAGED_PERIODS:on,detailsPageCount:On,detailsPage:En,setDetailsPage:yn,costModalOpen:f,closeCostModal:fi}),o.jsx(oh,{open:M,onClose:di,data:li,twitterText:Pn})]})}export{wh as DashboardPage};
|