@juliantanx/aiusage-widget 1.5.4 → 1.5.6
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.md +4 -0
- package/README_zh.md +4 -0
- package/dist/i18n.js +10 -0
- package/dist/main.js +57 -3
- package/dist/preload.js +4 -0
- package/dist/renderer/assets/index-DfzDTAdy.js +1 -0
- package/dist/renderer/index.html +1 -1
- package/package.json +1 -1
- package/dist/renderer/assets/index-CvTfd0Ry.js +0 -1
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@ A lightweight system tray widget for [AIUsage](https://github.com/juliantanx/aiu
|
|
|
4
4
|
|
|
5
5
|
English | [中文](./README_zh.md)
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://cdn.jsdelivr.net/gh/juliantanx/aiusage@main/packages/site/static/screenshots/widget.png" alt="AIUsage Widget screenshot" width="360" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
7
11
|
## Features
|
|
8
12
|
|
|
9
13
|
- **System tray integration** — lives in your system tray, click to toggle a compact stats panel.
|
package/README_zh.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
[English](./README.md) | 中文
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://cdn.jsdelivr.net/gh/juliantanx/aiusage@main/packages/site/static/screenshots/widget.png" alt="AIUsage Widget 截图" width="360" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
7
11
|
## 功能
|
|
8
12
|
|
|
9
13
|
- **系统托盘集成** — 常驻系统托盘,点击即可弹出简洁的统计面板。
|
package/dist/i18n.js
CHANGED
|
@@ -38,6 +38,11 @@ const en = {
|
|
|
38
38
|
installLaunching: 'Starting dashboard...',
|
|
39
39
|
installDone: 'Done! Opening...',
|
|
40
40
|
installFailed: 'Installation failed',
|
|
41
|
+
setupTitle: 'First Time Setup',
|
|
42
|
+
setupChecking: 'Checking CLI...',
|
|
43
|
+
setupParsing: 'Parsing usage logs...',
|
|
44
|
+
setupDone: 'Ready!',
|
|
45
|
+
setupFailed: 'Setup failed',
|
|
41
46
|
};
|
|
42
47
|
const zh = {
|
|
43
48
|
today: '今日',
|
|
@@ -76,6 +81,11 @@ const zh = {
|
|
|
76
81
|
installLaunching: '正在启动仪表盘...',
|
|
77
82
|
installDone: '完成!正在打开...',
|
|
78
83
|
installFailed: '安装失败',
|
|
84
|
+
setupTitle: '首次配置',
|
|
85
|
+
setupChecking: '检测 CLI...',
|
|
86
|
+
setupParsing: '解析使用日志...',
|
|
87
|
+
setupDone: '就绪!',
|
|
88
|
+
setupFailed: '配置失败',
|
|
79
89
|
};
|
|
80
90
|
const translations = { en, zh };
|
|
81
91
|
function t(locale) {
|
package/dist/main.js
CHANGED
|
@@ -33,8 +33,9 @@ electron_1.app.setName('AIUsage Widget');
|
|
|
33
33
|
if (process.platform === 'darwin' && electron_1.app.dock) {
|
|
34
34
|
electron_1.app.dock.hide();
|
|
35
35
|
}
|
|
36
|
-
electron_1.app.whenReady().then(() => {
|
|
37
|
-
|
|
36
|
+
electron_1.app.whenReady().then(async () => {
|
|
37
|
+
const dbExists = (0, node_fs_1.existsSync)(DB_PATH);
|
|
38
|
+
if (dbExists) {
|
|
38
39
|
db = new Database(DB_PATH, {
|
|
39
40
|
readonly: true,
|
|
40
41
|
nativeBinding: (0, ui_1.getWidgetNativeBindingPath)(__dirname),
|
|
@@ -45,7 +46,10 @@ electron_1.app.whenReady().then(() => {
|
|
|
45
46
|
createWindow();
|
|
46
47
|
startAutoRefresh();
|
|
47
48
|
void refreshExchangeRate();
|
|
48
|
-
if (
|
|
49
|
+
if (!dbExists) {
|
|
50
|
+
await autoSetup();
|
|
51
|
+
}
|
|
52
|
+
else if ((0, ui_1.shouldShowWindowOnLaunch)(electron_1.app.isPackaged)) {
|
|
49
53
|
showWindowWhenTrayReady();
|
|
50
54
|
}
|
|
51
55
|
});
|
|
@@ -303,6 +307,56 @@ async function installAiusageCli() {
|
|
|
303
307
|
}
|
|
304
308
|
return { success: false, error: 'No package manager (npm/pnpm/yarn) could install @juliantanx/aiusage.' };
|
|
305
309
|
}
|
|
310
|
+
function checkCliInstalled() {
|
|
311
|
+
const { execFile } = nodeRequire('child_process');
|
|
312
|
+
return new Promise((resolve) => {
|
|
313
|
+
execFile('aiusage', ['--version'], { timeout: 10000, shell: true }, (err) => {
|
|
314
|
+
resolve(!err);
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
function runFirstParse() {
|
|
319
|
+
const { execFile } = nodeRequire('child_process');
|
|
320
|
+
return new Promise((resolve) => {
|
|
321
|
+
execFile('aiusage', ['parse'], { timeout: 120000, shell: true }, (err, _stdout, stderr) => {
|
|
322
|
+
if (err) {
|
|
323
|
+
resolve({ success: false, error: stderr || err.message });
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
resolve({ success: true });
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
async function autoSetup() {
|
|
332
|
+
// Show overlay
|
|
333
|
+
notifyRenderer('setup:status', { phase: 'checking' });
|
|
334
|
+
showWindow();
|
|
335
|
+
// Check if CLI is installed
|
|
336
|
+
const cliFound = await checkCliInstalled();
|
|
337
|
+
if (!cliFound) {
|
|
338
|
+
// Install CLI
|
|
339
|
+
notifyRenderer('setup:status', { phase: 'installing' });
|
|
340
|
+
const installResult = await installAiusageCli();
|
|
341
|
+
if (!installResult.success) {
|
|
342
|
+
notifyRenderer('setup:status', { phase: 'failed', error: installResult.error });
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Run first parse
|
|
347
|
+
notifyRenderer('setup:status', { phase: 'parsing' });
|
|
348
|
+
await runFirstParse();
|
|
349
|
+
// Parse failure is not fatal — user may have no logs yet
|
|
350
|
+
// Open database if it now exists
|
|
351
|
+
if ((0, node_fs_1.existsSync)(DB_PATH)) {
|
|
352
|
+
db = new Database(DB_PATH, {
|
|
353
|
+
readonly: true,
|
|
354
|
+
nativeBinding: (0, ui_1.getWidgetNativeBindingPath)(__dirname),
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
notifyRenderer('setup:status', { phase: 'done' });
|
|
358
|
+
pushDataUpdate();
|
|
359
|
+
}
|
|
306
360
|
// IPC handlers
|
|
307
361
|
electron_1.ipcMain.handle('widget:get-data', () => {
|
|
308
362
|
if (!db)
|
package/dist/preload.js
CHANGED
|
@@ -14,6 +14,10 @@ electron_1.contextBridge.exposeInMainWorld('widget', {
|
|
|
14
14
|
electron_1.ipcRenderer.removeAllListeners('install:status');
|
|
15
15
|
electron_1.ipcRenderer.on('install:status', (_event, status) => callback(status));
|
|
16
16
|
},
|
|
17
|
+
onSetupStatus: (callback) => {
|
|
18
|
+
electron_1.ipcRenderer.removeAllListeners('setup:status');
|
|
19
|
+
electron_1.ipcRenderer.on('setup:status', (_event, status) => callback(status));
|
|
20
|
+
},
|
|
17
21
|
getSettings: () => electron_1.ipcRenderer.invoke('widget:get-settings'),
|
|
18
22
|
saveSettings: (settings) => electron_1.ipcRenderer.invoke('widget:save-settings', settings),
|
|
19
23
|
getExchangeRate: () => electron_1.ipcRenderer.invoke('widget:get-exchange-rate'),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Pl=Object.defineProperty;var El=(e,t,l)=>t in e?Pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l;var ut=(e,t,l)=>El(e,typeof t!="symbol"?t+"":t,l);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function l(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(o){if(o.ep)return;o.ep=!0;const s=l(o);fetch(o.href,s)}})();function fe(){}function Sl(e){return e()}function jt(){return Object.create(null)}function De(e){e.forEach(Sl)}function Xe(e){return typeof e=="function"}function Ge(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Al(e){return Object.keys(e).length===0}function r(e,t){e.appendChild(t)}function E(e,t,l){e.insertBefore(t,l||null)}function R(e){e.parentNode&&e.parentNode.removeChild(e)}function we(e,t){for(let l=0;l<e.length;l+=1)e[l]&&e[l].d(t)}function v(e){return document.createElement(e)}function X(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function H(e){return document.createTextNode(e)}function D(){return H(" ")}function ve(){return H("")}function de(e,t,l,n){return e.addEventListener(t,l,n),()=>e.removeEventListener(t,l,n)}function i(e,t,l){l==null?e.removeAttribute(t):e.getAttribute(t)!==l&&e.setAttribute(t,l)}function Bl(e){return Array.from(e.childNodes)}function W(e,t){t=""+t,e.data!==t&&(e.data=t)}function Se(e,t,l,n){l==null?e.style.removeProperty(t):e.style.setProperty(t,l,"")}function G(e,t,l){e.classList.toggle(t,!!l)}function Il(e,t,{bubbles:l=!1,cancelable:n=!1}={}){return new CustomEvent(e,{detail:t,bubbles:l,cancelable:n})}let Ze;function Qe(e){Ze=e}function yt(){if(!Ze)throw new Error("Function called outside component initialization");return Ze}function Ml(e){yt().$$.on_mount.push(e)}function Nl(e){yt().$$.after_update.push(e)}function Ol(){const e=yt();return(t,l,{cancelable:n=!1}={})=>{const o=e.$$.callbacks[t];if(o){const s=Il(t,l,{cancelable:n});return o.slice().forEach(a=>{a.call(e,s)}),!s.defaultPrevented}return!0}}const ze=[],_t=[];let Ve=[];const qt=[],Ll=Promise.resolve();let mt=!1;function Dl(){mt||(mt=!0,Ll.then(jl))}function Rt(){return Dl(),Ll}function pt(e){Ve.push(e)}const ht=new Set;let We=0;function jl(){if(We!==0)return;const e=Ze;do{try{for(;We<ze.length;){const t=ze[We];We++,Qe(t),Hl(t.$$)}}catch(t){throw ze.length=0,We=0,t}for(Qe(null),ze.length=0,We=0;_t.length;)_t.pop()();for(let t=0;t<Ve.length;t+=1){const l=Ve[t];ht.has(l)||(ht.add(l),l())}Ve.length=0}while(ze.length);for(;qt.length;)qt.pop()();mt=!1,ht.clear(),Qe(e)}function Hl(e){if(e.fragment!==null){e.update(),De(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(pt)}}function Ul(e){const t=[],l=[];Ve.forEach(n=>e.indexOf(n)===-1?t.push(n):l.push(n)),l.forEach(n=>n()),Ve=t}const tt=new Set;let Fe;function vt(){Fe={r:0,c:[],p:Fe}}function bt(){Fe.r||De(Fe.c),Fe=Fe.p}function ne(e,t){e&&e.i&&(tt.delete(e),e.i(t))}function _e(e,t,l,n){if(e&&e.o){if(tt.has(e))return;tt.add(e),Fe.c.push(()=>{tt.delete(e),n&&(l&&e.d(1),n())}),e.o(t)}else n&&n()}function te(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function Pe(e){e&&e.c()}function Me(e,t,l){const{fragment:n,after_update:o}=e.$$;n&&n.m(t,l),pt(()=>{const s=e.$$.on_mount.map(Sl).filter(Xe);e.$$.on_destroy?e.$$.on_destroy.push(...s):De(s),e.$$.on_mount=[]}),o.forEach(pt)}function Le(e,t){const l=e.$$;l.fragment!==null&&(Ul(l.after_update),De(l.on_destroy),l.fragment&&l.fragment.d(t),l.on_destroy=l.fragment=null,l.ctx=[])}function Wl(e,t){e.$$.dirty[0]===-1&&(ze.push(e),Dl(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Ke(e,t,l,n,o,s,a=null,h=[-1]){const c=Ze;Qe(e);const u=e.$$={fragment:null,ctx:[],props:s,update:fe,not_equal:o,bound:jt(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(c?c.$$.context:[])),callbacks:jt(),dirty:h,skip_bound:!1,root:t.target||c.$$.root};a&&a(u.root);let f=!1;if(u.ctx=l?l(e,t.props||{},(m,d,...g)=>{const w=g.length?g[0]:d;return u.ctx&&o(u.ctx[m],u.ctx[m]=w)&&(!u.skip_bound&&u.bound[m]&&u.bound[m](w),f&&Wl(e,m)),d}):[],u.update(),f=!0,De(u.before_update),u.fragment=n?n(u.ctx):!1,t.target){if(t.hydrate){const m=Bl(t.target);u.fragment&&u.fragment.l(m),m.forEach(R)}else u.fragment&&u.fragment.c();t.intro&&ne(e.$$.fragment),Me(e,t.target,t.anchor),jl()}Qe(c)}class Ye{constructor(){ut(this,"$$");ut(this,"$$set")}$destroy(){Le(this,1),this.$destroy=fe}$on(t,l){if(!Xe(l))return fe;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(l),()=>{const o=n.indexOf(l);o!==-1&&n.splice(o,1)}}$set(t){this.$$set&&!Al(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const zl="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(zl);function Ft(e){let t,l;return{c(){t=v("span"),l=H(e[6]),i(t,"class","status svelte-1c4hcx6")},m(n,o){E(n,t,o),r(t,l)},p(n,o){o&64&&W(l,n[6])},d(n){n&&R(t)}}}function Vl(e){let t,l,n,o,s,a,h,c,u,f,m,d,g,w,N,K,Q,S,Y,A,F,B,I,P,T,L,z,Z,U,_=e[6]&&Ft(e);return{c(){t=v("div"),l=v("div"),n=X("svg"),o=X("rect"),s=X("rect"),a=X("rect"),h=X("rect"),c=D(),u=v("span"),u.textContent="AIUsage",f=D(),_&&_.c(),m=D(),d=v("div"),g=v("button"),w=X("svg"),N=X("path"),K=X("path"),Q=X("path"),S=X("path"),Y=D(),A=v("button"),F=X("svg"),B=X("circle"),I=X("path"),P=D(),T=v("button"),L=X("svg"),z=X("path"),i(o,"width","64"),i(o,"height","64"),i(o,"rx","14"),i(o,"fill","oklch(0.55 0.12 175)"),i(s,"x","10"),i(s,"y","38"),i(s,"width","12"),i(s,"height","16"),i(s,"rx","3"),i(s,"fill","white"),i(a,"x","26"),i(a,"y","26"),i(a,"width","12"),i(a,"height","28"),i(a,"rx","3"),i(a,"fill","white"),i(h,"x","42"),i(h,"y","14"),i(h,"width","12"),i(h,"height","40"),i(h,"rx","3"),i(h,"fill","white"),i(n,"xmlns","http://www.w3.org/2000/svg"),i(n,"width","14"),i(n,"height","14"),i(n,"viewBox","0 0 64 64"),Se(n,"display","block"),Se(n,"border-radius","3px"),i(u,"class","logo svelte-1c4hcx6"),i(l,"class","brand svelte-1c4hcx6"),i(N,"d","M2.5 8a5.5 5.5 0 0 1 9.36-3.93"),i(K,"d","M13.5 8a5.5 5.5 0 0 1-9.36 3.93"),i(Q,"d","M12 1.5v3h-3"),i(S,"d","M4 11.5v3h3"),i(w,"width","13"),i(w,"height","13"),i(w,"viewBox","0 0 16 16"),i(w,"fill","none"),i(w,"stroke","currentColor"),i(w,"stroke-width","1.8"),i(w,"stroke-linecap","round"),i(g,"class","icon-btn svelte-1c4hcx6"),i(g,"title",e[3]),i(g,"aria-label",e[3]),i(B,"cx","12"),i(B,"cy","12"),i(B,"r","3"),i(I,"d","M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"),i(F,"width","13"),i(F,"height","13"),i(F,"viewBox","0 0 24 24"),i(F,"fill","none"),i(F,"stroke","currentColor"),i(F,"stroke-width","2"),i(F,"stroke-linecap","round"),i(F,"stroke-linejoin","round"),i(A,"class","icon-btn svelte-1c4hcx6"),i(A,"title",e[4]),i(A,"aria-label",e[4]),i(z,"d","M2 2l8 8M10 2l-8 8"),i(L,"width","11"),i(L,"height","11"),i(L,"viewBox","0 0 12 12"),i(L,"fill","none"),i(L,"stroke","currentColor"),i(L,"stroke-width","1.8"),i(L,"stroke-linecap","round"),i(T,"class","icon-btn svelte-1c4hcx6"),i(T,"title",e[5]),i(T,"aria-label",e[5]),i(d,"class","actions svelte-1c4hcx6"),i(t,"class","header svelte-1c4hcx6")},m(j,k){E(j,t,k),r(t,l),r(l,n),r(n,o),r(n,s),r(n,a),r(n,h),r(l,c),r(l,u),r(l,f),_&&_.m(l,null),r(t,m),r(t,d),r(d,g),r(g,w),r(w,N),r(w,K),r(w,Q),r(w,S),r(d,Y),r(d,A),r(A,F),r(F,B),r(F,I),r(d,P),r(d,T),r(T,L),r(L,z),Z||(U=[de(g,"click",function(){Xe(e[0])&&e[0].apply(this,arguments)}),de(A,"click",function(){Xe(e[2])&&e[2].apply(this,arguments)}),de(T,"click",function(){Xe(e[1])&&e[1].apply(this,arguments)})],Z=!0)},p(j,[k]){e=j,e[6]?_?_.p(e,k):(_=Ft(e),_.c(),_.m(l,null)):_&&(_.d(1),_=null),k&8&&i(g,"title",e[3]),k&8&&i(g,"aria-label",e[3]),k&16&&i(A,"title",e[4]),k&16&&i(A,"aria-label",e[4]),k&32&&i(T,"title",e[5]),k&32&&i(T,"aria-label",e[5])},i:fe,o:fe,d(j){j&&R(t),_&&_.d(),Z=!1,De(U)}}}function Gl(e,t,l){let{onRefresh:n}=t,{onClose:o}=t,{onToggleSettings:s}=t,{refreshLabel:a}=t,{settingsLabel:h}=t,{closeLabel:c}=t,{statusText:u=""}=t;return e.$$set=f=>{"onRefresh"in f&&l(0,n=f.onRefresh),"onClose"in f&&l(1,o=f.onClose),"onToggleSettings"in f&&l(2,s=f.onToggleSettings),"refreshLabel"in f&&l(3,a=f.refreshLabel),"settingsLabel"in f&&l(4,h=f.settingsLabel),"closeLabel"in f&&l(5,c=f.closeLabel),"statusText"in f&&l(6,u=f.statusText)},[n,o,s,a,h,c,u]}class Kl extends Ye{constructor(t){super(),Ke(this,t,Gl,Vl,Ge,{onRefresh:0,onClose:1,onToggleSettings:2,refreshLabel:3,settingsLabel:4,closeLabel:5,statusText:6})}}function Pt(e){let t,l;return{c(){t=v("span"),l=H(e[2]),i(t,"class","sub svelte-1un0gu")},m(n,o){E(n,t,o),r(t,l)},p(n,o){o&4&&W(l,n[2])},d(n){n&&R(t)}}}function Yl(e){let t,l,n,o,s,a,h,c,u=e[2]&&Pt(e);return{c(){t=v("div"),l=v("span"),n=H(e[0]),o=D(),s=v("div"),a=v("span"),h=H(e[1]),c=D(),u&&u.c(),i(l,"class","label svelte-1un0gu"),i(a,"class","value svelte-1un0gu"),i(a,"title",e[1]),G(a,"accent",e[3]),i(s,"class","right svelte-1un0gu"),i(t,"class","row svelte-1un0gu")},m(f,m){E(f,t,m),r(t,l),r(l,n),r(t,o),r(t,s),r(s,a),r(a,h),r(s,c),u&&u.m(s,null)},p(f,[m]){m&1&&W(n,f[0]),m&2&&W(h,f[1]),m&2&&i(a,"title",f[1]),m&8&&G(a,"accent",f[3]),f[2]?u?u.p(f,m):(u=Pt(f),u.c(),u.m(s,null)):u&&(u.d(1),u=null)},i:fe,o:fe,d(f){f&&R(t),u&&u.d()}}}function Xl(e,t,l){let{label:n}=t,{value:o}=t,{sub:s=""}=t,{accent:a=!1}=t;return e.$$set=h=>{"label"in h&&l(0,n=h.label),"value"in h&&l(1,o=h.value),"sub"in h&&l(2,s=h.sub),"accent"in h&&l(3,a=h.accent)},[n,o,s,a]}class dt extends Ye{constructor(t){super(),Ke(this,t,Xl,Yl,Ge,{label:0,value:1,sub:2,accent:3})}}function Et(e,t,l){const n=e.slice();return n[7]=t[l],n}function At(e,t,l){const n=e.slice();return n[7]=t[l],n}function Ql(e){let t;return{c(){t=v("div"),t.textContent="No token data",i(t,"class","empty svelte-4y3y1j")},m(l,n){E(l,t,n)},p:fe,d(l){l&&R(t)}}}function Zl(e){let t,l,n,o=te(e[0]),s=[];for(let c=0;c<o.length;c+=1)s[c]=Bt(At(e,o,c));let a=te(e[0]),h=[];for(let c=0;c<a.length;c+=1)h[c]=It(Et(e,a,c));return{c(){t=v("div");for(let c=0;c<s.length;c+=1)s[c].c();l=D(),n=v("div");for(let c=0;c<h.length;c+=1)h[c].c();i(t,"class","bar svelte-4y3y1j"),i(n,"class","legend svelte-4y3y1j")},m(c,u){E(c,t,u);for(let f=0;f<s.length;f+=1)s[f]&&s[f].m(t,null);E(c,l,u),E(c,n,u);for(let f=0;f<h.length;f+=1)h[f]&&h[f].m(n,null)},p(c,u){if(u&3){o=te(c[0]);let f;for(f=0;f<o.length;f+=1){const m=At(c,o,f);s[f]?s[f].p(m,u):(s[f]=Bt(m),s[f].c(),s[f].m(t,null))}for(;f<s.length;f+=1)s[f].d(1);s.length=o.length}if(u&1){a=te(c[0]);let f;for(f=0;f<a.length;f+=1){const m=Et(c,a,f);h[f]?h[f].p(m,u):(h[f]=It(m),h[f].c(),h[f].m(n,null))}for(;f<h.length;f+=1)h[f].d(1);h.length=a.length}},d(c){c&&(R(t),R(l),R(n)),we(s,c),we(h,c)}}}function Bt(e){let t,l;return{c(){t=v("div"),i(t,"class","segment svelte-4y3y1j"),Se(t,"width",e[7].value/e[1]*100+"%"),Se(t,"background",e[7].color),i(t,"title",l=e[7].label+": "+lt(e[7].value))},m(n,o){E(n,t,o)},p(n,o){o&3&&Se(t,"width",n[7].value/n[1]*100+"%"),o&1&&Se(t,"background",n[7].color),o&1&&l!==(l=n[7].label+": "+lt(n[7].value))&&i(t,"title",l)},d(n){n&&R(t)}}}function It(e){let t,l,n,o,s=e[7].label+"",a,h,c,u=lt(e[7].value)+"",f,m;return{c(){t=v("div"),l=v("span"),n=D(),o=v("span"),a=H(s),h=D(),c=v("span"),f=H(u),m=D(),i(l,"class","dot svelte-4y3y1j"),Se(l,"background",e[7].color),i(o,"class","legend-label svelte-4y3y1j"),i(c,"class","legend-value svelte-4y3y1j"),i(t,"class","legend-item svelte-4y3y1j")},m(d,g){E(d,t,g),r(t,l),r(t,n),r(t,o),r(o,a),r(t,h),r(t,c),r(c,f),r(t,m)},p(d,g){g&1&&Se(l,"background",d[7].color),g&1&&s!==(s=d[7].label+"")&&W(a,s),g&1&&u!==(u=lt(d[7].value)+"")&&W(f,u)},d(d){d&&R(t)}}}function Jl(e){let t;function l(s,a){return s[1]>0?Zl:Ql}let n=l(e),o=n(e);return{c(){t=v("div"),o.c(),i(t,"class","breakdown svelte-4y3y1j")},m(s,a){E(s,t,a),o.m(t,null)},p(s,[a]){n===(n=l(s))&&o?o.p(s,a):(o.d(1),o=n(s),o&&(o.c(),o.m(t,null)))},i:fe,o:fe,d(s){s&&R(t),o.d()}}}function lt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function $l(e,t,l){let n,o,{input:s=0}=t,{output:a=0}=t,{cacheRead:h=0}=t,{cacheWrite:c=0}=t,{thinking:u=0}=t;return e.$$set=f=>{"input"in f&&l(2,s=f.input),"output"in f&&l(3,a=f.output),"cacheRead"in f&&l(4,h=f.cacheRead),"cacheWrite"in f&&l(5,c=f.cacheWrite),"thinking"in f&&l(6,u=f.thinking)},e.$$.update=()=>{e.$$.dirty&124&&l(1,n=s+a+h+c+u),e.$$.dirty&124&&l(0,o=[{label:"Input",value:s,color:"var(--chart-input)"},{label:"Output",value:a,color:"var(--chart-output)"},{label:"Cache R",value:h,color:"var(--chart-cache-read)"},{label:"Cache W",value:c,color:"var(--chart-cache-write)"},{label:"Think",value:u,color:"var(--chart-thinking)"}].filter(f=>f.value>0))},[o,n,s,a,h,c,u]}class xl extends Ye{constructor(t){super(),Ke(this,t,$l,Jl,Ge,{input:2,output:3,cacheRead:4,cacheWrite:5,thinking:6})}}const Nt=[{code:"USD",label:"USD"},{code:"CNY",label:"CNY"}];function ql(e,t,l){return t==="USD"?e:l!=null&&l.rate&&Number.isFinite(l.rate)?e*l.rate:null}function kt(e,t,l,n,o=!1){const s=ql(e,t,n);return s===null?"--":Rl(s,t,l,o)}function Rl(e,t,l,n=!1){const o=n&&Math.abs(e)>=1e3?"compact":"standard",s=e>=100||o==="compact"?0:e>=1?2:e>0?3:0;return new Intl.NumberFormat(l,{style:"currency",currency:t,currencyDisplay:"narrowSymbol",notation:o,minimumFractionDigits:s,maximumFractionDigits:s}).format(e)}function Ot(e,t,l){const n=e.slice();return n[33]=t[l],n}function gt(e){const t=e.slice(),l=t[0][t[6]];t[36]=l;const n=t[21]();t[37]=n;const o=t[23](t[6]);t[38]=o;const s=t[22](t[6]);return t[39]=s,t}function Ht(e,t,l){const n=e.slice();return n[40]=t[l],n}function Ut(e,t,l){const n=e.slice();return n[40]=t[l],n[44]=l,n}function Wt(e){let t,l,n,o,s,a=nl(e[40])+"",h,c;return{c(){t=X("line"),s=X("text"),h=H(a),i(t,"x1",me),i(t,"y1",l=e[15](e[40])),i(t,"x2",n=me+e[9]),i(t,"y2",o=e[15](e[40])),i(t,"stroke","var(--border)"),i(t,"stroke-width","0.5"),i(t,"stroke-dasharray",e[44]===0?"none":"2,2"),i(s,"x",me-7),i(s,"y",c=e[15](e[40])+3),i(s,"text-anchor","end"),i(s,"class","y-label svelte-15p89al")},m(u,f){E(u,t,f),E(u,s,f),r(s,h)},p(u,f){f[0]&2048&&l!==(l=u[15](u[40]))&&i(t,"y1",l),f[0]&512&&n!==(n=me+u[9])&&i(t,"x2",n),f[0]&2048&&o!==(o=u[15](u[40]))&&i(t,"y2",o),f[0]&2048&&a!==(a=nl(u[40])+"")&&W(h,a),f[0]&2048&&c!==(c=u[15](u[40])+3)&&i(s,"y",c)},d(u){u&&(R(t),R(s))}}}function zt(e){let t,l=te(e[10]),n=[];for(let o=0;o<l.length;o+=1)n[o]=Vt(Ht(e,l,o));return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=ve()},m(o,s){for(let a=0;a<n.length;a+=1)n[a]&&n[a].m(o,s);E(o,t,s)},p(o,s){if(s[0]&198144){l=te(o[10]);let a;for(a=0;a<l.length;a+=1){const h=Ht(o,l,a);n[a]?n[a].p(h,s):(n[a]=Vt(h),n[a].c(),n[a].m(t.parentNode,t))}for(;a<n.length;a+=1)n[a].d(1);n.length=l.length}},d(o){o&&R(t),we(n,o)}}}function Vt(e){let t,l=e[17](e[40])+"",n,o,s;return{c(){t=X("text"),n=H(l),i(t,"x",o=me+e[9]+7),i(t,"y",s=e[16](e[40])+3),i(t,"text-anchor","start"),i(t,"class","y-label y-label-cost svelte-15p89al")},m(a,h){E(a,t,h),r(t,n)},p(a,h){h[0]&1024&&l!==(l=a[17](a[40])+"")&&W(n,l),h[0]&512&&o!==(o=me+a[9]+7)&&i(t,"x",o),h[0]&1024&&s!==(s=a[16](a[40])+3)&&i(t,"y",s)},d(a){a&&R(t)}}}function Gt(e){let t;return{c(){t=X("path"),i(t,"d",e[12]),i(t,"fill","url(#areaGrad)"),i(t,"clip-path","url(#chartClip)"),i(t,"class","area svelte-15p89al")},m(l,n){E(l,t,n)},p(l,n){n[0]&4096&&i(t,"d",l[12])},d(l){l&&R(t)}}}function Kt(e){let t;return{c(){t=X("path"),i(t,"d",e[13]),i(t,"fill","none"),i(t,"stroke","var(--chart-cache-read)"),i(t,"stroke-width","1.3"),i(t,"stroke-linecap","round"),i(t,"stroke-linejoin","round"),i(t,"clip-path","url(#chartClip)"),i(t,"class","line cost-line svelte-15p89al")},m(l,n){E(l,t,n)},p(l,n){n[0]&8192&&i(t,"d",l[13])},d(l){l&&R(t)}}}function Yt(e){let t;return{c(){t=X("path"),i(t,"d",e[4]),i(t,"fill","none"),i(t,"stroke","var(--accent)"),i(t,"stroke-width","1.8"),i(t,"stroke-linecap","round"),i(t,"stroke-linejoin","round"),i(t,"clip-path","url(#chartClip)"),i(t,"class","line svelte-15p89al")},m(l,n){E(l,t,n)},p(l,n){n[0]&16&&i(t,"d",l[4])},d(l){l&&R(t)}}}function Xt(e){let t,l,n,o;return{c(){t=X("line"),i(t,"x1",l=e[14](e[6])),i(t,"y1",ke),i(t,"x2",n=e[14](e[6])),i(t,"y2",o=ke+e[2]),i(t,"stroke","var(--text-muted)"),i(t,"stroke-width","0.5"),i(t,"stroke-dasharray","2,2")},m(s,a){E(s,t,a)},p(s,a){a[0]&64&&l!==(l=s[14](s[6]))&&i(t,"x1",l),a[0]&64&&n!==(n=s[14](s[6]))&&i(t,"x2",n),a[0]&4&&o!==(o=ke+s[2])&&i(t,"y2",o)},d(s){s&&R(t)}}}function Qt(e){let t,l,n,o,s=e[1]&&Zt(e);return{c(){t=X("circle"),s&&s.c(),o=ve(),i(t,"cx",l=e[14](e[6])),i(t,"cy",n=e[15](e[3][e[6]])),i(t,"r","4"),i(t,"fill","var(--bg)"),i(t,"stroke","var(--accent)"),i(t,"stroke-width","2")},m(a,h){E(a,t,h),s&&s.m(a,h),E(a,o,h)},p(a,h){h[0]&64&&l!==(l=a[14](a[6]))&&i(t,"cx",l),h[0]&72&&n!==(n=a[15](a[3][a[6]]))&&i(t,"cy",n),a[1]?s?s.p(a,h):(s=Zt(a),s.c(),s.m(o.parentNode,o)):s&&(s.d(1),s=null)},d(a){a&&(R(t),R(o)),s&&s.d(a)}}}function Zt(e){let t,l,n;return{c(){t=X("circle"),i(t,"cx",l=e[14](e[6])),i(t,"cy",n=e[16](e[5][e[6]])),i(t,"r","3"),i(t,"fill","var(--bg)"),i(t,"stroke","var(--chart-cache-read)"),i(t,"stroke-width","1.5")},m(o,s){E(o,t,s)},p(o,s){s[0]&64&&l!==(l=o[14](o[6]))&&i(t,"cx",l),s[0]&96&&n!==(n=o[16](o[5][o[6]]))&&i(t,"cy",n)},d(o){o&&R(t)}}}function Jt(e){let t,l,n,o=e[18](e[36].date)+"",s,a,h=ll(e[36].tokens)+"",c,u,f,m=e[1]&&e[36].cost>0&&$t(e);return{c(){t=X("foreignObject"),l=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n=document.createElementNS("http://www.w3.org/1999/xhtml","span"),s=H(o),a=document.createElementNS("http://www.w3.org/1999/xhtml","span"),c=H(h),m&&m.c(),i(n,"class","tooltip-date svelte-15p89al"),i(a,"class","tooltip-metric token-dot svelte-15p89al"),i(l,"class","tooltip svelte-15p89al"),i(l,"xmlns","http://www.w3.org/1999/xhtml"),G(l,"pointer-left",e[24](e[6])==="left"),G(l,"pointer-right",e[24](e[6])==="right"),i(t,"x",u=e[38]),i(t,"y",f=e[39]),i(t,"width",e[37]),i(t,"height","28"),i(t,"class","tooltip-fo svelte-15p89al")},m(d,g){E(d,t,g),r(t,l),r(l,n),r(n,s),r(l,a),r(a,c),m&&m.m(l,null)},p(d,g){g[0]&65&&o!==(o=d[18](d[36].date)+"")&&W(s,o),g[0]&65&&h!==(h=ll(d[36].tokens)+"")&&W(c,h),d[1]&&d[36].cost>0?m?m.p(d,g):(m=$t(d),m.c(),m.m(l,null)):m&&(m.d(1),m=null),g[0]&16777280&&G(l,"pointer-left",d[24](d[6])==="left"),g[0]&16777280&&G(l,"pointer-right",d[24](d[6])==="right"),g[0]&64&&u!==(u=d[38])&&i(t,"x",u),g[0]&64&&f!==(f=d[39])&&i(t,"y",f)},d(d){d&&R(t),m&&m.d()}}}function $t(e){let t,l=e[20](e[36].cost)+"",n;return{c(){t=document.createElementNS("http://www.w3.org/1999/xhtml","span"),n=H(l),i(t,"class","tooltip-metric cost-dot svelte-15p89al")},m(o,s){E(o,t,s),r(t,n)},p(o,s){s[0]&65&&l!==(l=o[20](o[36].cost)+"")&&W(n,l)},d(o){o&&R(t)}}}function xt(e){let t,l=e[19](e[0][e[33]].date)+"",n,o;return{c(){t=X("text"),n=H(l),i(t,"x",o=e[14](e[33])),i(t,"y",nt-2),i(t,"text-anchor","middle"),i(t,"class","tick-label svelte-15p89al")},m(s,a){E(s,t,a),r(t,n)},p(s,a){a[0]&257&&l!==(l=s[19](s[0][s[33]].date)+"")&&W(n,l),a[0]&256&&o!==(o=s[14](s[33]))&&i(t,"x",o)},d(s){s&&R(t)}}}function el(e){let t,l=e[0][e[33]]&&xt(e);return{c(){l&&l.c(),t=ve()},m(n,o){l&&l.m(n,o),E(n,t,o)},p(n,o){n[0][n[33]]?l?l.p(n,o):(l=xt(n),l.c(),l.m(t.parentNode,t)):l&&(l.d(1),l=null)},d(n){n&&R(t),l&&l.d(n)}}}function en(e){let t,l,n,o,s,a,h,c,u,f,m,d,g,w,N,K,Q,S,Y=te(e[11]),A=[];for(let _=0;_<Y.length;_+=1)A[_]=Wt(Ut(e,Y,_));let F=e[1]&&zt(e),B=e[12]&&Gt(e),I=e[13]&&Kt(e),P=e[4]&&Yt(e),T=e[6]!==null&&Xt(e),L=e[6]!==null&&Qt(e),z=e[6]!==null&&e[0][e[6]]&&Jt(gt(e)),Z=te(e[8]),U=[];for(let _=0;_<Z.length;_+=1)U[_]=el(Ot(e,Z,_));return{c(){t=v("div"),l=X("svg"),n=X("defs"),o=X("linearGradient"),s=X("stop"),a=X("stop"),h=X("clipPath"),c=X("rect");for(let _=0;_<A.length;_+=1)A[_].c();u=ve(),F&&F.c(),f=ve(),B&&B.c(),m=ve(),I&&I.c(),d=ve(),P&&P.c(),g=ve(),T&&T.c(),w=ve(),L&&L.c(),N=ve(),z&&z.c(),K=ve();for(let _=0;_<U.length;_+=1)U[_].c();i(s,"offset","0%"),i(s,"stop-color","var(--accent)"),i(s,"stop-opacity","0.2"),i(a,"offset","100%"),i(a,"stop-color","var(--accent)"),i(a,"stop-opacity","0.02"),i(o,"id","areaGrad"),i(o,"x1","0"),i(o,"y1","0"),i(o,"x2","0"),i(o,"y2","1"),i(c,"x",me),i(c,"y",ke),i(c,"width",e[9]),i(c,"height",e[2]),i(h,"id","chartClip"),i(l,"viewBox","0 0 "+wt+" "+nt),i(l,"width","100%"),i(l,"height",nt),i(l,"class","chart-svg svelte-15p89al"),i(l,"role","img"),i(l,"aria-label","Token usage trend chart"),G(l,"mounted",e[7]),i(t,"class","chart-wrapper svelte-15p89al")},m(_,j){E(_,t,j),r(t,l),r(l,n),r(n,o),r(o,s),r(o,a),r(n,h),r(h,c);for(let k=0;k<A.length;k+=1)A[k]&&A[k].m(l,null);r(l,u),F&&F.m(l,null),r(l,f),B&&B.m(l,null),r(l,m),I&&I.m(l,null),r(l,d),P&&P.m(l,null),r(l,g),T&&T.m(l,null),r(l,w),L&&L.m(l,null),r(l,N),z&&z.m(l,null),r(l,K);for(let k=0;k<U.length;k+=1)U[k]&&U[k].m(l,null);Q||(S=[de(l,"mousemove",e[25]),de(l,"mouseleave",e[26])],Q=!0)},p(_,j){if(j[0]&512&&i(c,"width",_[9]),j[0]&4&&i(c,"height",_[2]),j[0]&35328){Y=te(_[11]);let k;for(k=0;k<Y.length;k+=1){const V=Ut(_,Y,k);A[k]?A[k].p(V,j):(A[k]=Wt(V),A[k].c(),A[k].m(l,u))}for(;k<A.length;k+=1)A[k].d(1);A.length=Y.length}if(_[1]?F?F.p(_,j):(F=zt(_),F.c(),F.m(l,f)):F&&(F.d(1),F=null),_[12]?B?B.p(_,j):(B=Gt(_),B.c(),B.m(l,m)):B&&(B.d(1),B=null),_[13]?I?I.p(_,j):(I=Kt(_),I.c(),I.m(l,d)):I&&(I.d(1),I=null),_[4]?P?P.p(_,j):(P=Yt(_),P.c(),P.m(l,g)):P&&(P.d(1),P=null),_[6]!==null?T?T.p(_,j):(T=Xt(_),T.c(),T.m(l,w)):T&&(T.d(1),T=null),_[6]!==null?L?L.p(_,j):(L=Qt(_),L.c(),L.m(l,N)):L&&(L.d(1),L=null),_[6]!==null&&_[0][_[6]]?z?z.p(gt(_),j):(z=Jt(gt(_)),z.c(),z.m(l,K)):z&&(z.d(1),z=null),j[0]&540929){Z=te(_[8]);let k;for(k=0;k<Z.length;k+=1){const V=Ot(_,Z,k);U[k]?U[k].p(V,j):(U[k]=el(V),U[k].c(),U[k].m(l,null))}for(;k<U.length;k+=1)U[k].d(1);U.length=Z.length}j[0]&128&&G(l,"mounted",_[7])},i:fe,o:fe,d(_){_&&R(t),we(A,_),F&&F.d(),B&&B.d(),I&&I.d(),P&&P.d(),T&&T.d(),L&&L.d(),z&&z.d(),we(U,_),Q=!1,De(S)}}}const wt=352,nt=126,ke=14,tn=18,me=34,ln=36;function tl(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),l=e/t;return(l<=1?1:l<=2?2:l<=5?5:10)*t}function ll(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e))}function nl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e5?`${Math.round(e/1e3)}K`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e))}function il(e){return new Date(e+"T00:00:00")}function nn(e,t,l){let n,o,s,a,h,c,u,f,m,d,g,w,{data:N=[]}=t,{showCost:K=!1}=t,{locale:Q="en"}=t,{currency:S="USD"}=t,{exchangeRate:Y=null}=t,A=null,F=!1;Ml(()=>{requestAnimationFrame(()=>{l(7,F=!0)})});function B(M){return me+M/Math.max(N.length-1,1)*h}function I(M){return ke+c-M/s*c}function P(M){return ke+c-M/a*c}function T(M,le){if(M.length<2)return"";const C=M.length,y=M.map((q,ee)=>B(ee)),O=M.map(q=>le(q));if(C===2)return`M${y[0]},${O[0]}L${y[1]},${O[1]}`;const J=[],$=[];for(let q=0;q<C-1;q++)J.push((O[q+1]-O[q])/(y[q+1]-y[q]));$.push(J[0]);for(let q=1;q<C-1;q++)J[q-1]*J[q]<=0?$.push(0):$.push((J[q-1]+J[q])/2);$.push(J[C-2]);for(let q=0;q<C-1;q++)if(Math.abs(J[q])<1e-12)$[q]=0,$[q+1]=0;else{const ee=$[q]/J[q],ge=$[q+1]/J[q],ye=ee*ee+ge*ge;if(ye>9){const Te=3/Math.sqrt(ye);$[q]=Te*ee*J[q],$[q+1]=Te*ge*J[q]}}let ce=`M${y[0].toFixed(1)},${O[0].toFixed(1)}`;for(let q=0;q<C-1;q++){const ee=(y[q+1]-y[q])/3,ge=y[q]+ee,ye=O[q]+$[q]*ee,Te=y[q+1]-ee,Je=O[q+1]-$[q+1]*ee;ce+=`C${ge.toFixed(1)},${ye.toFixed(1)},${Te.toFixed(1)},${Je.toFixed(1)},${y[q+1].toFixed(1)},${O[q+1].toFixed(1)}`}return ce}function L(M){return Rl(M,S,Q,!0)}function z(M){const le=il(M);return new Intl.DateTimeFormat(Q,{month:Q==="zh"?"numeric":"short",day:"numeric"}).format(le)}function Z(M){const le=il(M);return new Intl.DateTimeFormat(Q,{month:"numeric",day:"numeric"}).format(le)}function U(M){return kt(M,S,Q,Y)}function _(){return K?156:116}function j(M){const le=I(n[M]??0)-30;return Math.min(Math.max(le,4),ke+c-28)}function k(M){const C=_(),y=B(M),O=V(M)==="right"?y-C-8:y+8;return Math.min(Math.max(O,me),me+h-C)}function V(M){return B(M)>me+h/2?"right":"left"}function be(M){const C=M.currentTarget.getBoundingClientRect(),y=(M.clientX-C.left)/C.width*wt;let O=1/0,J=0;for(let $=0;$<N.length;$++){const ce=Math.abs(B($)-y);ce<O&&(O=ce,J=$)}l(6,A=J)}function pe(){l(6,A=null)}return e.$$set=M=>{"data"in M&&l(0,N=M.data),"showCost"in M&&l(1,K=M.showCost),"locale"in M&&l(27,Q=M.locale),"currency"in M&&l(28,S=M.currency),"exchangeRate"in M&&l(29,Y=M.exchangeRate)},e.$$.update=()=>{e.$$.dirty[0]&1&&l(3,n=N.map(M=>M.tokens)),e.$$.dirty[0]&805306369&&l(5,o=N.map(M=>ql(M.cost,S,Y)??0)),e.$$.dirty[0]&8&&l(31,s=tl(Math.max(...n,1))),e.$$.dirty[0]&32&&l(30,a=tl(Math.max(...o,1))),e.$$.dirty[0]&8&&l(4,u=T(n,I)),e.$$.dirty[0]&34&&l(13,f=K?T(o,P):""),e.$$.dirty[0]&28&&l(12,m=u?`${u}L${B(n.length-1).toFixed(1)},${(ke+c).toFixed(1)}L${B(0).toFixed(1)},${(ke+c).toFixed(1)}Z`:""),e.$$.dirty[1]&1&&l(11,d=[0,s/2,s]),e.$$.dirty[0]&1073741824&&l(10,g=[0,a/2,a]),e.$$.dirty[0]&1&&l(8,w=N.length<=5?N.map((M,le)=>le):[0,Math.floor(N.length*.25),Math.floor(N.length*.5),Math.floor(N.length*.75),N.length-1])},l(9,h=wt-me-ln),l(2,c=nt-ke-tn),[N,K,c,n,u,o,A,F,w,h,g,d,m,f,B,I,P,L,z,Z,U,_,j,k,V,be,pe,Q,S,Y,a,s]}class on extends Ye{constructor(t){super(),Ke(this,t,nn,en,Ge,{data:0,showCost:1,locale:27,currency:28,exchangeRate:29},null,[-1,-1])}}const sn={today:"Today",lastNDays:e=>`Last ${e} days`,tokenBreakdown:"Token breakdown",tokenBreakdownToday:"Token breakdown (Today)",trend:"Trend",topModel:"Top Model",topTool:"Top Tool",sessions:"Sessions",settings:"Settings",theme:"Theme",timeRange:"Time range",refreshInterval:"Refresh interval",display:"Display",currency:"Currency",exchangeRate:"Exchange rate",exchangeRateUpdated:e=>`Updated ${e}`,exchangeRateUnavailable:"Exchange rate unavailable",language:"Language",showCost:"Show cost",tokenBreakdownToggle:"Token breakdown",activityChart:"Activity chart",syncedAt:e=>`Synced ${e}`,themeSystem:"System",themeLight:"Light",themeDark:"Dark",showPanel:"Show Panel",openDashboard:"Open Dashboard",refresh:"Refresh",quit:"Quit",close:"Close",installTitle:"Dashboard Setup",installPreparing:"Preparing...",installInstalling:"Installing @juliantanx/aiusage...",installLaunching:"Starting dashboard...",installDone:"Done! Opening...",installFailed:"Installation failed",setupTitle:"First Time Setup",setupChecking:"Checking CLI...",setupParsing:"Parsing usage logs...",setupDone:"Ready!",setupFailed:"Setup failed"},an={today:"今日",lastNDays:e=>`近 ${e} 天`,tokenBreakdown:"Token 分布",tokenBreakdownToday:"Token 分布 (今日)",trend:"趋势",topModel:"常用模型",topTool:"常用工具",sessions:"会话数",settings:"设置",theme:"主题",timeRange:"时间范围",refreshInterval:"刷新间隔",display:"显示",currency:"币种",exchangeRate:"汇率",exchangeRateUpdated:e=>`更新于 ${e}`,exchangeRateUnavailable:"汇率不可用",language:"语言",showCost:"显示费用",tokenBreakdownToggle:"Token 分布",activityChart:"活动图表",syncedAt:e=>`同步于 ${e}`,themeSystem:"跟随系统",themeLight:"浅色",themeDark:"深色",showPanel:"显示面板",openDashboard:"打开仪表盘",refresh:"刷新",quit:"退出",close:"关闭",installTitle:"仪表盘配置",installPreparing:"准备中...",installInstalling:"正在安装 @juliantanx/aiusage...",installLaunching:"正在启动仪表盘...",installDone:"完成!正在打开...",installFailed:"安装失败",setupTitle:"首次配置",setupChecking:"检测 CLI...",setupParsing:"解析使用日志...",setupDone:"就绪!",setupFailed:"配置失败"},ol={en:sn,zh:an};function Fl(e){return ol[e]??ol.en}function sl(e,t,l){const n=e.slice();return n[22]=t[l],n}function al(e,t,l){const n=e.slice();return n[25]=t[l],n}function rl(e,t,l){const n=e.slice();return n[28]=t[l],n}function fl(e,t,l){const n=e.slice();return n[31]=t[l],n}function cl(e,t,l){const n=e.slice();return n[34]=t[l],n}function ul(e){let t,l,n;function o(){return e[14](e[34])}return{c(){t=v("button"),t.textContent=`${e[34].label} `,i(t,"class","option-btn svelte-198qnem"),G(t,"active",e[1].locale===e[34].value)},m(s,a){E(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&2050&&G(t,"active",e[1].locale===e[34].value)},d(s){s&&R(t),l=!1,n()}}}function hl(e){let t,l,n;function o(){return e[15](e[31])}return{c(){t=v("button"),t.textContent=`${e[31].label} `,i(t,"class","option-btn svelte-198qnem"),G(t,"active",e[1].currency===e[31].code)},m(s,a){E(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&2&&G(t,"active",e[1].currency===e[31].code)},d(s){s&&R(t),l=!1,n()}}}function dl(e){var d;let t,l,n=e[2].exchangeRate+"",o,s,a,h,c=e[7](),u,f=c&&rn(e),m=((d=e[0])==null?void 0:d.error)&&gl(e);return{c(){var g;t=v("div"),l=v("span"),o=H(n),s=D(),a=v("strong"),a.textContent=`${e[6]()}`,h=D(),f&&f.c(),u=D(),m&&m.c(),i(a,"class","svelte-198qnem"),i(t,"class","rate-info svelte-198qnem"),G(t,"error",!((g=e[0])!=null&&g.rate))},m(g,w){E(g,t,w),r(t,l),r(l,o),r(t,s),r(t,a),r(t,h),f&&f.m(t,null),r(t,u),m&&m.m(t,null)},p(g,w){var N,K;w[0]&4&&n!==(n=g[2].exchangeRate+"")&&W(o,n),c&&f.p(g,w),(N=g[0])!=null&&N.error?m?m.p(g,w):(m=gl(g),m.c(),m.m(t,null)):m&&(m.d(1),m=null),w[0]&1&&G(t,"error",!((K=g[0])!=null&&K.rate))},d(g){g&&R(t),f&&f.d(),m&&m.d()}}}function rn(e){let t;return{c(){t=v("small"),t.textContent=`${e[7]()}`,i(t,"class","svelte-198qnem")},m(l,n){E(l,t,n)},p:fe,d(l){l&&R(t)}}}function gl(e){let t,l=e[0].error+"",n;return{c(){t=v("small"),n=H(l),i(t,"class","svelte-198qnem")},m(o,s){E(o,t,s),r(t,n)},p(o,s){s[0]&1&&l!==(l=o[0].error+"")&&W(n,l)},d(o){o&&R(t)}}}function _l(e){let t,l=e[28].label+"",n,o,s,a;function h(){return e[16](e[28])}return{c(){t=v("button"),n=H(l),o=D(),i(t,"class","option-btn svelte-198qnem"),G(t,"active",e[1].theme===e[28].value)},m(c,u){E(c,t,u),r(t,n),r(t,o),s||(a=de(t,"click",h),s=!0)},p(c,u){e=c,u[0]&8&&l!==(l=e[28].label+"")&&W(n,l),u[0]&10&&G(t,"active",e[1].theme===e[28].value)},d(c){c&&R(t),s=!1,a()}}}function ml(e){let t,l,n;function o(){return e[17](e[25])}return{c(){t=v("button"),t.textContent=`${e[25].label} `,i(t,"class","option-btn svelte-198qnem"),G(t,"active",e[1].rangeDays===e[25].value)},m(s,a){E(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&1026&&G(t,"active",e[1].rangeDays===e[25].value)},d(s){s&&R(t),l=!1,n()}}}function pl(e){let t,l,n;function o(){return e[18](e[22])}return{c(){t=v("button"),t.textContent=`${e[22].label} `,i(t,"class","option-btn svelte-198qnem"),G(t,"active",e[1].refreshIntervalSec===e[22].value)},m(s,a){E(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&514&&G(t,"active",e[1].refreshIntervalSec===e[22].value)},d(s){s&&R(t),l=!1,n()}}}function fn(e){let t,l,n,o=e[2].settings+"",s,a,h,c,u,f,m=e[2].language+"",d,g,w,N,K,Q,S=e[2].currency+"",Y,A,F,B,I,P,T,L=e[2].theme+"",z,Z,U,_,j,k,V=e[2].timeRange+"",be,pe,M,le,C,y,O=e[2].refreshInterval+"",J,$,ce,q,ee,ge,ye=e[2].display+"",Te,Je,Ce,Ee,it,$e=e[2].showCost+"",ot,Tt,je,Ct,Ae,st,xe=e[2].tokenBreakdownToggle+"",at,St,qe,Mt,Be,rt,et=e[2].activityChart+"",ft,Lt,Re,ct,Dt,Ie=te(e[11]),ie=[];for(let b=0;b<Ie.length;b+=1)ie[b]=ul(cl(e,Ie,b));let Ne=te(Nt),oe=[];for(let b=0;b<Ne.length;b+=1)oe[b]=hl(fl(e,Ne,b));let ue=e[1].currency==="CNY"&&dl(e),Oe=te(e[3]),se=[];for(let b=0;b<Oe.length;b+=1)se[b]=_l(rl(e,Oe,b));let He=te(e[10]),ae=[];for(let b=0;b<He.length;b+=1)ae[b]=ml(al(e,He,b));let Ue=te(e[9]),re=[];for(let b=0;b<Ue.length;b+=1)re[b]=pl(sl(e,Ue,b));return{c(){t=v("div"),l=v("div"),n=v("span"),s=H(o),a=D(),h=v("button"),h.innerHTML='<svg width="11" height="11" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="M2 2l8 8M10 2l-8 8"></path></svg>',c=D(),u=v("div"),f=v("div"),d=H(m),g=D(),w=v("div");for(let b=0;b<ie.length;b+=1)ie[b].c();N=D(),K=v("div"),Q=v("div"),Y=H(S),A=D(),F=v("div");for(let b=0;b<oe.length;b+=1)oe[b].c();B=D(),ue&&ue.c(),I=D(),P=v("div"),T=v("div"),z=H(L),Z=D(),U=v("div");for(let b=0;b<se.length;b+=1)se[b].c();_=D(),j=v("div"),k=v("div"),be=H(V),pe=D(),M=v("div");for(let b=0;b<ae.length;b+=1)ae[b].c();le=D(),C=v("div"),y=v("div"),J=H(O),$=D(),ce=v("div");for(let b=0;b<re.length;b+=1)re[b].c();q=D(),ee=v("div"),ge=v("div"),Te=H(ye),Je=D(),Ce=v("div"),Ee=v("label"),it=v("span"),ot=H($e),Tt=D(),je=v("button"),je.innerHTML='<span class="toggle-thumb svelte-198qnem"></span>',Ct=D(),Ae=v("label"),st=v("span"),at=H(xe),St=D(),qe=v("button"),qe.innerHTML='<span class="toggle-thumb svelte-198qnem"></span>',Mt=D(),Be=v("label"),rt=v("span"),ft=H(et),Lt=D(),Re=v("button"),Re.innerHTML='<span class="toggle-thumb svelte-198qnem"></span>',i(n,"class","settings-title svelte-198qnem"),i(h,"class","back-btn svelte-198qnem"),i(l,"class","settings-header svelte-198qnem"),i(f,"class","section-label svelte-198qnem"),i(w,"class","button-group svelte-198qnem"),i(u,"class","section svelte-198qnem"),i(Q,"class","section-label svelte-198qnem"),i(F,"class","button-group svelte-198qnem"),i(K,"class","section svelte-198qnem"),i(T,"class","section-label svelte-198qnem"),i(U,"class","button-group svelte-198qnem"),i(P,"class","section svelte-198qnem"),i(k,"class","section-label svelte-198qnem"),i(M,"class","button-group svelte-198qnem"),i(j,"class","section svelte-198qnem"),i(y,"class","section-label svelte-198qnem"),i(ce,"class","button-group svelte-198qnem"),i(C,"class","section svelte-198qnem"),i(ge,"class","section-label svelte-198qnem"),i(je,"class","toggle svelte-198qnem"),G(je,"on",e[1].showCost),i(Ee,"class","toggle-row svelte-198qnem"),i(qe,"class","toggle svelte-198qnem"),G(qe,"on",e[1].showTokenBreakdown),i(Ae,"class","toggle-row svelte-198qnem"),i(Re,"class","toggle svelte-198qnem"),G(Re,"on",e[1].showHeatmap),i(Be,"class","toggle-row svelte-198qnem"),i(Ce,"class","toggles svelte-198qnem"),i(ee,"class","section svelte-198qnem"),i(t,"class","settings svelte-198qnem")},m(b,x){E(b,t,x),r(t,l),r(l,n),r(n,s),r(l,a),r(l,h),r(t,c),r(t,u),r(u,f),r(f,d),r(u,g),r(u,w);for(let p=0;p<ie.length;p+=1)ie[p]&&ie[p].m(w,null);r(t,N),r(t,K),r(K,Q),r(Q,Y),r(K,A),r(K,F);for(let p=0;p<oe.length;p+=1)oe[p]&&oe[p].m(F,null);r(K,B),ue&&ue.m(K,null),r(t,I),r(t,P),r(P,T),r(T,z),r(P,Z),r(P,U);for(let p=0;p<se.length;p+=1)se[p]&&se[p].m(U,null);r(t,_),r(t,j),r(j,k),r(k,be),r(j,pe),r(j,M);for(let p=0;p<ae.length;p+=1)ae[p]&&ae[p].m(M,null);r(t,le),r(t,C),r(C,y),r(y,J),r(C,$),r(C,ce);for(let p=0;p<re.length;p+=1)re[p]&&re[p].m(ce,null);r(t,q),r(t,ee),r(ee,ge),r(ge,Te),r(ee,Je),r(ee,Ce),r(Ce,Ee),r(Ee,it),r(it,ot),r(Ee,Tt),r(Ee,je),r(Ce,Ct),r(Ce,Ae),r(Ae,st),r(st,at),r(Ae,St),r(Ae,qe),r(Ce,Mt),r(Ce,Be),r(Be,rt),r(rt,ft),r(Be,Lt),r(Be,Re),ct||(Dt=[de(h,"click",e[13]),de(je,"click",e[19]),de(qe,"click",e[20]),de(Re,"click",e[21])],ct=!0)},p(b,x){if(x[0]&4&&o!==(o=b[2].settings+"")&&W(s,o),x[0]&4&&m!==(m=b[2].language+"")&&W(d,m),x[0]&2082){Ie=te(b[11]);let p;for(p=0;p<Ie.length;p+=1){const he=cl(b,Ie,p);ie[p]?ie[p].p(he,x):(ie[p]=ul(he),ie[p].c(),ie[p].m(w,null))}for(;p<ie.length;p+=1)ie[p].d(1);ie.length=Ie.length}if(x[0]&4&&S!==(S=b[2].currency+"")&&W(Y,S),x[0]&34){Ne=te(Nt);let p;for(p=0;p<Ne.length;p+=1){const he=fl(b,Ne,p);oe[p]?oe[p].p(he,x):(oe[p]=hl(he),oe[p].c(),oe[p].m(F,null))}for(;p<oe.length;p+=1)oe[p].d(1);oe.length=Ne.length}if(b[1].currency==="CNY"?ue?ue.p(b,x):(ue=dl(b),ue.c(),ue.m(K,null)):ue&&(ue.d(1),ue=null),x[0]&4&&L!==(L=b[2].theme+"")&&W(z,L),x[0]&42){Oe=te(b[3]);let p;for(p=0;p<Oe.length;p+=1){const he=rl(b,Oe,p);se[p]?se[p].p(he,x):(se[p]=_l(he),se[p].c(),se[p].m(U,null))}for(;p<se.length;p+=1)se[p].d(1);se.length=Oe.length}if(x[0]&4&&V!==(V=b[2].timeRange+"")&&W(be,V),x[0]&1058){He=te(b[10]);let p;for(p=0;p<He.length;p+=1){const he=al(b,He,p);ae[p]?ae[p].p(he,x):(ae[p]=ml(he),ae[p].c(),ae[p].m(M,null))}for(;p<ae.length;p+=1)ae[p].d(1);ae.length=He.length}if(x[0]&4&&O!==(O=b[2].refreshInterval+"")&&W(J,O),x[0]&546){Ue=te(b[9]);let p;for(p=0;p<Ue.length;p+=1){const he=sl(b,Ue,p);re[p]?re[p].p(he,x):(re[p]=pl(he),re[p].c(),re[p].m(ce,null))}for(;p<re.length;p+=1)re[p].d(1);re.length=Ue.length}x[0]&4&&ye!==(ye=b[2].display+"")&&W(Te,ye),x[0]&4&&$e!==($e=b[2].showCost+"")&&W(ot,$e),x[0]&2&&G(je,"on",b[1].showCost),x[0]&4&&xe!==(xe=b[2].tokenBreakdownToggle+"")&&W(at,xe),x[0]&2&&G(qe,"on",b[1].showTokenBreakdown),x[0]&4&&et!==(et=b[2].activityChart+"")&&W(ft,et),x[0]&2&&G(Re,"on",b[1].showHeatmap)},i:fe,o:fe,d(b){b&&R(t),we(ie,b),we(oe,b),ue&&ue.d(),we(se,b),we(ae,b),we(re,b),ct=!1,De(Dt)}}}function cn(e,t,l){let n,o,{settings:s}=t,{exchangeRate:a=null}=t;const h=Ol();let c={...s};function u(){h("save",c)}function f(){return a!=null&&a.rate?`1 USD = ${a.rate.toFixed(4)} CNY`:n.exchangeRateUnavailable}function m(){if(!(a!=null&&a.fetchedAt))return"";const T=new Date(a.fetchedAt),L=String(T.getHours()).padStart(2,"0"),z=String(T.getMinutes()).padStart(2,"0");return n.exchangeRateUpdated(`${L}:${z}`)}function d(T){typeof c[T]=="boolean"&&(l(1,c={...c,[T]:!c[T]}),u())}const g=[{label:"30s",value:30},{label:"1m",value:60},{label:"5m",value:300},{label:"10m",value:600}],w=[{label:"7d",value:7},{label:"14d",value:14},{label:"30d",value:30},{label:"60d",value:60},{label:"90d",value:90}],N=[{label:"English",value:"en"},{label:"中文",value:"zh"}],K=()=>h("close"),Q=T=>{l(1,c={...c,locale:T.value}),u()},S=T=>{l(1,c={...c,currency:T.code}),u()},Y=T=>{l(1,c={...c,theme:T.value}),u()},A=T=>{l(1,c={...c,rangeDays:T.value}),u()},F=T=>{l(1,c={...c,refreshIntervalSec:T.value}),u()},B=()=>d("showCost"),I=()=>d("showTokenBreakdown"),P=()=>d("showHeatmap");return e.$$set=T=>{"settings"in T&&l(12,s=T.settings),"exchangeRate"in T&&l(0,a=T.exchangeRate)},e.$$.update=()=>{e.$$.dirty[0]&2&&l(2,n=Fl(c.locale??"en")),e.$$.dirty[0]&4&&l(3,o=[{label:n.themeSystem,value:"system"},{label:n.themeLight,value:"light"},{label:n.themeDark,value:"dark"}])},[a,c,n,o,h,u,f,m,d,g,w,N,s,K,Q,S,Y,A,F,B,I,P]}class un extends Ye{constructor(t){super(),Ke(this,t,cn,fn,Ge,{settings:12,exchangeRate:0},null,[-1,-1])}}function vl(e){let t,l,n,o,s,a=(e[4]?e[5].setupTitle:e[5].installTitle)+"",h,c,u,f,m,d=e[11]&&bl(e);return{c(){t=v("div"),l=v("div"),n=v("div"),o=D(),s=v("div"),h=H(a),c=D(),u=v("div"),f=H(e[12]),m=D(),d&&d.c(),i(n,"class","install-spinner svelte-1sj3khb"),G(n,"hidden",e[3]==="done"||e[3]==="failed"),i(s,"class","install-title svelte-1sj3khb"),i(u,"class","install-message svelte-1sj3khb"),i(l,"class","install-content svelte-1sj3khb"),i(t,"class","install-overlay svelte-1sj3khb"),G(t,"failed",e[3]==="failed"),G(t,"done",e[3]==="done")},m(g,w){E(g,t,w),r(t,l),r(l,n),r(l,o),r(l,s),r(s,h),r(l,c),r(l,u),r(u,f),r(l,m),d&&d.m(l,null)},p(g,w){w[0]&8&&G(n,"hidden",g[3]==="done"||g[3]==="failed"),w[0]&48&&a!==(a=(g[4]?g[5].setupTitle:g[5].installTitle)+"")&&W(h,a),w[0]&4096&&W(f,g[12]),g[11]?d?d.p(g,w):(d=bl(g),d.c(),d.m(l,null)):d&&(d.d(1),d=null),w[0]&8&&G(t,"failed",g[3]==="failed"),w[0]&8&&G(t,"done",g[3]==="done")},d(g){g&&R(t),d&&d.d()}}}function bl(e){let t,l;return{c(){t=v("div"),l=H(e[11]),i(t,"class","install-error svelte-1sj3khb")},m(n,o){E(n,t,o),r(t,l)},p(n,o){o[0]&2048&&W(l,n[11])},d(n){n&&R(t)}}}function hn(e){var be,pe,M,le;let t,l,n,o,s,a=e[5].today+"",h,c,u,f,m,d,g,w,N,K,Q,S,Y,A,F,B,I,P,T,L,z,Z,U,_=((be=e[1])==null?void 0:be.showCost)&&kl(e),j=((pe=e[1])==null?void 0:pe.showCost)&&wl(e),k=((M=e[1])==null?void 0:M.showTokenBreakdown)&&e[0]&&yl(e),V=((le=e[1])==null?void 0:le.showHeatmap)&&e[0]&&Tl(e);return P=new dt({props:{label:e[5].topModel,value:e[18],sub:e[17]}}),L=new dt({props:{label:e[5].topTool,value:e[16],sub:e[15]}}),Z=new dt({props:{label:e[5].sessions,value:e[14]}}),{c(){t=v("div"),l=v("div"),n=v("div"),o=v("div"),s=v("span"),h=H(a),c=D(),u=v("span"),f=H(e[23]),m=D(),_&&_.c(),d=D(),g=v("div"),w=v("span"),N=H(e[19]),K=D(),Q=v("span"),S=H(e[22]),Y=D(),j&&j.c(),A=D(),k&&k.c(),F=D(),V&&V.c(),B=D(),I=v("div"),Pe(P.$$.fragment),T=D(),Pe(L.$$.fragment),z=D(),Pe(Z.$$.fragment),i(s,"class","metric-label svelte-1sj3khb"),i(u,"class","metric-value svelte-1sj3khb"),i(o,"class","metric svelte-1sj3khb"),i(w,"class","metric-label svelte-1sj3khb"),i(Q,"class","metric-value svelte-1sj3khb"),i(g,"class","metric svelte-1sj3khb"),i(n,"class","metric-grid svelte-1sj3khb"),i(l,"class","section svelte-1sj3khb"),i(I,"class","section details svelte-1sj3khb"),i(t,"class","content svelte-1sj3khb")},m(C,y){E(C,t,y),r(t,l),r(l,n),r(n,o),r(o,s),r(s,h),r(o,c),r(o,u),r(u,f),r(o,m),_&&_.m(o,null),r(n,d),r(n,g),r(g,w),r(w,N),r(g,K),r(g,Q),r(Q,S),r(g,Y),j&&j.m(g,null),r(t,A),k&&k.m(t,null),r(t,F),V&&V.m(t,null),r(t,B),r(t,I),Me(P,I,null),r(I,T),Me(L,I,null),r(I,z),Me(Z,I,null),U=!0},p(C,y){var ce,q,ee,ge;(!U||y[0]&32)&&a!==(a=C[5].today+"")&&W(h,a),(!U||y[0]&8388608)&&W(f,C[23]),(ce=C[1])!=null&&ce.showCost?_?_.p(C,y):(_=kl(C),_.c(),_.m(o,null)):_&&(_.d(1),_=null),(!U||y[0]&524288)&&W(N,C[19]),(!U||y[0]&4194304)&&W(S,C[22]),(q=C[1])!=null&&q.showCost?j?j.p(C,y):(j=wl(C),j.c(),j.m(g,null)):j&&(j.d(1),j=null),(ee=C[1])!=null&&ee.showTokenBreakdown&&C[0]?k?(k.p(C,y),y[0]&3&&ne(k,1)):(k=yl(C),k.c(),ne(k,1),k.m(t,F)):k&&(vt(),_e(k,1,1,()=>{k=null}),bt()),(ge=C[1])!=null&&ge.showHeatmap&&C[0]?V?(V.p(C,y),y[0]&3&&ne(V,1)):(V=Tl(C),V.c(),ne(V,1),V.m(t,B)):V&&(vt(),_e(V,1,1,()=>{V=null}),bt());const O={};y[0]&32&&(O.label=C[5].topModel),y[0]&262144&&(O.value=C[18]),y[0]&131072&&(O.sub=C[17]),P.$set(O);const J={};y[0]&32&&(J.label=C[5].topTool),y[0]&65536&&(J.value=C[16]),y[0]&32768&&(J.sub=C[15]),L.$set(J);const $={};y[0]&32&&($.label=C[5].sessions),y[0]&16384&&($.value=C[14]),Z.$set($)},i(C){U||(ne(k),ne(V),ne(P.$$.fragment,C),ne(L.$$.fragment,C),ne(Z.$$.fragment,C),U=!0)},o(C){_e(k),_e(V),_e(P.$$.fragment,C),_e(L.$$.fragment,C),_e(Z.$$.fragment,C),U=!1},d(C){C&&R(t),_&&_.d(),j&&j.d(),k&&k.d(),V&&V.d(),Le(P),Le(L),Le(Z)}}}function dn(e){let t,l;return t=new un({props:{settings:e[1],exchangeRate:e[2]}}),t.$on("save",e[25]),t.$on("close",e[27]),{c(){Pe(t.$$.fragment)},m(n,o){Me(t,n,o),l=!0},p(n,o){const s={};o[0]&2&&(s.settings=n[1]),o[0]&4&&(s.exchangeRate=n[2]),t.$set(s)},i(n){l||(ne(t.$$.fragment,n),l=!0)},o(n){_e(t.$$.fragment,n),l=!1},d(n){Le(t,n)}}}function kl(e){let t,l;return{c(){t=v("span"),l=H(e[21]),i(t,"class","metric-cost svelte-1sj3khb")},m(n,o){E(n,t,o),r(t,l)},p(n,o){o[0]&2097152&&W(l,n[21])},d(n){n&&R(t)}}}function wl(e){let t,l;return{c(){t=v("span"),l=H(e[20]),i(t,"class","metric-cost svelte-1sj3khb")},m(n,o){E(n,t,o),r(t,l)},p(n,o){o[0]&1048576&&W(l,n[20])},d(n){n&&R(t)}}}function yl(e){let t,l,n=e[5].tokenBreakdownToday+"",o,s,a,h;return a=new xl({props:{input:e[0].todayTokens.input,output:e[0].todayTokens.output,cacheRead:e[0].todayTokens.cacheRead,cacheWrite:e[0].todayTokens.cacheWrite,thinking:e[0].todayTokens.thinking}}),{c(){t=v("div"),l=v("div"),o=H(n),s=D(),Pe(a.$$.fragment),i(l,"class","section-title svelte-1sj3khb"),i(t,"class","section svelte-1sj3khb")},m(c,u){E(c,t,u),r(t,l),r(l,o),r(t,s),Me(a,t,null),h=!0},p(c,u){(!h||u[0]&32)&&n!==(n=c[5].tokenBreakdownToday+"")&&W(o,n);const f={};u[0]&1&&(f.input=c[0].todayTokens.input),u[0]&1&&(f.output=c[0].todayTokens.output),u[0]&1&&(f.cacheRead=c[0].todayTokens.cacheRead),u[0]&1&&(f.cacheWrite=c[0].todayTokens.cacheWrite),u[0]&1&&(f.thinking=c[0].todayTokens.thinking),a.$set(f)},i(c){h||(ne(a.$$.fragment,c),h=!0)},o(c){_e(a.$$.fragment,c),h=!1},d(c){c&&R(t),Le(a)}}}function Tl(e){var c;let t,l,n=e[5].trend+"",o,s,a,h;return a=new on({props:{data:e[0].dailyHistory,showCost:((c=e[1])==null?void 0:c.showCost)??!1,locale:e[6],currency:e[7],exchangeRate:e[2]}}),{c(){t=v("div"),l=v("div"),o=H(n),s=D(),Pe(a.$$.fragment),i(l,"class","section-title svelte-1sj3khb"),i(t,"class","section svelte-1sj3khb")},m(u,f){E(u,t,f),r(t,l),r(l,o),r(t,s),Me(a,t,null),h=!0},p(u,f){var d;(!h||f[0]&32)&&n!==(n=u[5].trend+"")&&W(o,n);const m={};f[0]&1&&(m.data=u[0].dailyHistory),f[0]&2&&(m.showCost=((d=u[1])==null?void 0:d.showCost)??!1),f[0]&64&&(m.locale=u[6]),f[0]&128&&(m.currency=u[7]),f[0]&4&&(m.exchangeRate=u[2]),a.$set(m)},i(u){h||(ne(a.$$.fragment,u),h=!0)},o(u){_e(a.$$.fragment,u),h=!1},d(u){u&&R(t),Le(a)}}}function gn(e){let t,l,n,o,s,a,h,c=e[3]&&vl(e);n=new Kl({props:{onRefresh:e[24],onClose:mn,onToggleSettings:e[26],refreshLabel:e[5].refresh,settingsLabel:e[5].settings,closeLabel:e[5].close,statusText:e[13]}});const u=[dn,hn],f=[];function m(d,g){return d[9]&&d[1]?0:1}return s=m(e),a=f[s]=u[s](e),{c(){t=v("div"),c&&c.c(),l=D(),Pe(n.$$.fragment),o=D(),a.c(),i(t,"class","panel svelte-1sj3khb"),G(t,"loading",e[8])},m(d,g){E(d,t,g),c&&c.m(t,null),r(t,l),Me(n,t,null),r(t,o),f[s].m(t,null),e[28](t),h=!0},p(d,g){d[3]?c?c.p(d,g):(c=vl(d),c.c(),c.m(t,l)):c&&(c.d(1),c=null);const w={};g[0]&512&&(w.onToggleSettings=d[26]),g[0]&32&&(w.refreshLabel=d[5].refresh),g[0]&32&&(w.settingsLabel=d[5].settings),g[0]&32&&(w.closeLabel=d[5].close),g[0]&8192&&(w.statusText=d[13]),n.$set(w);let N=s;s=m(d),s===N?f[s].p(d,g):(vt(),_e(f[N],1,1,()=>{f[N]=null}),bt(),a=f[s],a?a.p(d,g):(a=f[s]=u[s](d),a.c()),ne(a,1),a.m(t,null)),(!h||g[0]&256)&&G(t,"loading",d[8])},i(d){h||(ne(n.$$.fragment,d),ne(a),h=!0)},o(d){_e(n.$$.fragment,d),_e(a),h=!1},d(d){d&&R(t),c&&c.d(),Le(n),f[s].d(),e[28](null)}}}function _n(){return typeof navigator<"u"&&navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}function Cl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function mn(){window.widget.hideWindow()}function pn(e,t,l){let n,o,s,a,h,c,u,f,m,d,g,w,N,K,Q,S=null,Y=null,A=null,F=_n(),B=!0,I=!1,P,T=0,L=null,z=null,Z=!1;function U(y){return o.lastNDays(y)}function _(y){const O=new Date(y),J=String(O.getHours()).padStart(2,"0"),$=String(O.getMinutes()).padStart(2,"0");return o.syncedAt(`${J}:${$}`)}async function j(){l(8,B=!0),l(0,S=await window.widget.getData()),l(8,B=!1)}async function k(){l(1,Y=await window.widget.getSettings())}async function V(){l(2,A=await window.widget.getExchangeRate())}async function be(y){l(1,Y=await window.widget.saveSettings(y.detail)),j()}function pe(){if(!P)return;const y=Math.ceil(P.getBoundingClientRect().height);y<=0||Math.abs(y-T)<2||(T=y,window.widget.resizeWindow(y))}Ml(()=>{j(),k(),V(),window.widget.onDataUpdate(O=>{l(0,S=O),l(8,B=!1)}),window.widget.onInstallStatus(O=>{l(3,L=O.phase),l(11,z=O.error??null),(O.phase==="done"||O.phase==="failed")&&setTimeout(()=>{l(3,L=null),l(11,z=null)},3e3)}),window.widget.onSetupStatus(O=>{l(4,Z=!0),l(3,L=O.phase),l(11,z=O.error??null),(O.phase==="done"||O.phase==="failed")&&setTimeout(()=>{l(3,L=null),l(11,z=null),l(4,Z=!1)},3e3)});const y=new ResizeObserver(()=>pe());return y.observe(P),Rt().then(pe),()=>y.disconnect()}),Nl(()=>{Rt().then(pe)});const M=()=>{l(9,I=!I)},le=()=>{l(9,I=!1)};function C(y){_t[y?"unshift":"push"](()=>{P=y,l(10,P)})}return e.$$.update=()=>{var y;e.$$.dirty[0]&2&&l(6,n=(Y==null?void 0:Y.locale)??F),e.$$.dirty[0]&64&&l(5,o=Fl(n)),e.$$.dirty[0]&2&&l(7,s=(Y==null?void 0:Y.currency)??"USD"),e.$$.dirty[0]&1&&l(23,a=S?Cl(S.todayTokens.total):"--"),e.$$.dirty[0]&1&&l(22,h=S?Cl(S.rangeTokens.total):"--"),e.$$.dirty[0]&197&&l(21,c=S?kt(S.todayCost,s,n,A):"--"),e.$$.dirty[0]&197&&l(20,u=S?kt(S.rangeCost,s,n,A):"--"),e.$$.dirty[0]&33&&l(19,f=S?U(S.rangeDays):o.lastNDays(30)),e.$$.dirty[0]&1&&l(18,m=S!=null&&S.topModel?S.topModel.name:"--"),e.$$.dirty[0]&1&&l(17,d=S!=null&&S.topModel?`${S.topModel.share}%`:""),e.$$.dirty[0]&1&&l(16,g=((y=S==null?void 0:S.topTool)==null?void 0:y.name)??"--"),e.$$.dirty[0]&1&&l(15,w=S!=null&&S.topTool?`${S.topTool.share}%`:""),e.$$.dirty[0]&1&&l(14,N=S?String(S.sessionCountToday):"--"),e.$$.dirty[0]&1&&l(13,K=S?_(S.lastUpdated):""),e.$$.dirty[0]&56&&l(12,Q=L==="checking"?o.setupChecking:L==="parsing"?o.setupParsing:L==="installing"?o.installInstalling:L==="launching"?o.installLaunching:L==="done"?Z?o.setupDone:o.installDone:L==="failed"?Z?o.setupFailed:o.installFailed:o.installPreparing)},[S,Y,A,L,Z,o,n,s,B,I,P,z,Q,K,N,w,g,d,m,f,u,c,h,a,j,be,M,le,C]}class vn extends Ye{constructor(t){super(),Ke(this,t,pn,gn,Ge,{},null,[-1,-1])}}new vn({target:document.getElementById("app")});
|
package/dist/renderer/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'" />
|
|
7
7
|
<title>AIUsage Widget</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-DfzDTAdy.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-DJPcmhcI.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var El=Object.defineProperty;var Al=(e,t,l)=>t in e?El(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l;var ut=(e,t,l)=>Al(e,typeof t!="symbol"?t+"":t,l);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function l(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(o){if(o.ep)return;o.ep=!0;const s=l(o);fetch(o.href,s)}})();function fe(){}function Sl(e){return e()}function jt(){return Object.create(null)}function De(e){e.forEach(Sl)}function Xe(e){return typeof e=="function"}function Ge(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Pl(e){return Object.keys(e).length===0}function r(e,t){e.appendChild(t)}function A(e,t,l){e.insertBefore(t,l||null)}function R(e){e.parentNode&&e.parentNode.removeChild(e)}function ke(e,t){for(let l=0;l<e.length;l+=1)e[l]&&e[l].d(t)}function v(e){return document.createElement(e)}function Y(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function O(e){return document.createTextNode(e)}function L(){return O(" ")}function ve(){return O("")}function de(e,t,l,n){return e.addEventListener(t,l,n),()=>e.removeEventListener(t,l,n)}function i(e,t,l){l==null?e.removeAttribute(t):e.getAttribute(t)!==l&&e.setAttribute(t,l)}function Bl(e){return Array.from(e.childNodes)}function U(e,t){t=""+t,e.data!==t&&(e.data=t)}function Se(e,t,l,n){l==null?e.style.removeProperty(t):e.style.setProperty(t,l,"")}function z(e,t,l){e.classList.toggle(t,!!l)}function Nl(e,t,{bubbles:l=!1,cancelable:n=!1}={}){return new CustomEvent(e,{detail:t,bubbles:l,cancelable:n})}let Ze;function Qe(e){Ze=e}function yt(){if(!Ze)throw new Error("Function called outside component initialization");return Ze}function Ml(e){yt().$$.on_mount.push(e)}function Il(e){yt().$$.after_update.push(e)}function Ol(){const e=yt();return(t,l,{cancelable:n=!1}={})=>{const o=e.$$.callbacks[t];if(o){const s=Nl(t,l,{cancelable:n});return o.slice().forEach(a=>{a.call(e,s)}),!s.defaultPrevented}return!0}}const ze=[],_t=[];let Ve=[];const qt=[],Ll=Promise.resolve();let mt=!1;function Dl(){mt||(mt=!0,Ll.then(jl))}function Rt(){return Dl(),Ll}function pt(e){Ve.push(e)}const ht=new Set;let We=0;function jl(){if(We!==0)return;const e=Ze;do{try{for(;We<ze.length;){const t=ze[We];We++,Qe(t),Hl(t.$$)}}catch(t){throw ze.length=0,We=0,t}for(Qe(null),ze.length=0,We=0;_t.length;)_t.pop()();for(let t=0;t<Ve.length;t+=1){const l=Ve[t];ht.has(l)||(ht.add(l),l())}Ve.length=0}while(ze.length);for(;qt.length;)qt.pop()();mt=!1,ht.clear(),Qe(e)}function Hl(e){if(e.fragment!==null){e.update(),De(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(pt)}}function Ul(e){const t=[],l=[];Ve.forEach(n=>e.indexOf(n)===-1?t.push(n):l.push(n)),l.forEach(n=>n()),Ve=t}const tt=new Set;let Fe;function vt(){Fe={r:0,c:[],p:Fe}}function bt(){Fe.r||De(Fe.c),Fe=Fe.p}function ne(e,t){e&&e.i&&(tt.delete(e),e.i(t))}function _e(e,t,l,n){if(e&&e.o){if(tt.has(e))return;tt.add(e),Fe.c.push(()=>{tt.delete(e),n&&(l&&e.d(1),n())}),e.o(t)}else n&&n()}function te(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function Ee(e){e&&e.c()}function Me(e,t,l){const{fragment:n,after_update:o}=e.$$;n&&n.m(t,l),pt(()=>{const s=e.$$.on_mount.map(Sl).filter(Xe);e.$$.on_destroy?e.$$.on_destroy.push(...s):De(s),e.$$.on_mount=[]}),o.forEach(pt)}function Le(e,t){const l=e.$$;l.fragment!==null&&(Ul(l.after_update),De(l.on_destroy),l.fragment&&l.fragment.d(t),l.on_destroy=l.fragment=null,l.ctx=[])}function Wl(e,t){e.$$.dirty[0]===-1&&(ze.push(e),Dl(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Ke(e,t,l,n,o,s,a=null,h=[-1]){const c=Ze;Qe(e);const u=e.$$={fragment:null,ctx:[],props:s,update:fe,not_equal:o,bound:jt(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(c?c.$$.context:[])),callbacks:jt(),dirty:h,skip_bound:!1,root:t.target||c.$$.root};a&&a(u.root);let f=!1;if(u.ctx=l?l(e,t.props||{},(m,d,...g)=>{const y=g.length?g[0]:d;return u.ctx&&o(u.ctx[m],u.ctx[m]=y)&&(!u.skip_bound&&u.bound[m]&&u.bound[m](y),f&&Wl(e,m)),d}):[],u.update(),f=!0,De(u.before_update),u.fragment=n?n(u.ctx):!1,t.target){if(t.hydrate){const m=Bl(t.target);u.fragment&&u.fragment.l(m),m.forEach(R)}else u.fragment&&u.fragment.c();t.intro&&ne(e.$$.fragment),Me(e,t.target,t.anchor),jl()}Qe(c)}class Ye{constructor(){ut(this,"$$");ut(this,"$$set")}$destroy(){Le(this,1),this.$destroy=fe}$on(t,l){if(!Xe(l))return fe;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(l),()=>{const o=n.indexOf(l);o!==-1&&n.splice(o,1)}}$set(t){this.$$set&&!Pl(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const zl="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(zl);function Ft(e){let t,l;return{c(){t=v("span"),l=O(e[6]),i(t,"class","status svelte-1c4hcx6")},m(n,o){A(n,t,o),r(t,l)},p(n,o){o&64&&U(l,n[6])},d(n){n&&R(t)}}}function Vl(e){let t,l,n,o,s,a,h,c,u,f,m,d,g,y,I,V,X,C,G,P,F,B,N,E,T,D,K,J,H,_=e[6]&&Ft(e);return{c(){t=v("div"),l=v("div"),n=Y("svg"),o=Y("rect"),s=Y("rect"),a=Y("rect"),h=Y("rect"),c=L(),u=v("span"),u.textContent="AIUsage",f=L(),_&&_.c(),m=L(),d=v("div"),g=v("button"),y=Y("svg"),I=Y("path"),V=Y("path"),X=Y("path"),C=Y("path"),G=L(),P=v("button"),F=Y("svg"),B=Y("circle"),N=Y("path"),E=L(),T=v("button"),D=Y("svg"),K=Y("path"),i(o,"width","64"),i(o,"height","64"),i(o,"rx","14"),i(o,"fill","oklch(0.55 0.12 175)"),i(s,"x","10"),i(s,"y","38"),i(s,"width","12"),i(s,"height","16"),i(s,"rx","3"),i(s,"fill","white"),i(a,"x","26"),i(a,"y","26"),i(a,"width","12"),i(a,"height","28"),i(a,"rx","3"),i(a,"fill","white"),i(h,"x","42"),i(h,"y","14"),i(h,"width","12"),i(h,"height","40"),i(h,"rx","3"),i(h,"fill","white"),i(n,"xmlns","http://www.w3.org/2000/svg"),i(n,"width","14"),i(n,"height","14"),i(n,"viewBox","0 0 64 64"),Se(n,"display","block"),Se(n,"border-radius","3px"),i(u,"class","logo svelte-1c4hcx6"),i(l,"class","brand svelte-1c4hcx6"),i(I,"d","M2.5 8a5.5 5.5 0 0 1 9.36-3.93"),i(V,"d","M13.5 8a5.5 5.5 0 0 1-9.36 3.93"),i(X,"d","M12 1.5v3h-3"),i(C,"d","M4 11.5v3h3"),i(y,"width","13"),i(y,"height","13"),i(y,"viewBox","0 0 16 16"),i(y,"fill","none"),i(y,"stroke","currentColor"),i(y,"stroke-width","1.8"),i(y,"stroke-linecap","round"),i(g,"class","icon-btn svelte-1c4hcx6"),i(g,"title",e[3]),i(g,"aria-label",e[3]),i(B,"cx","12"),i(B,"cy","12"),i(B,"r","3"),i(N,"d","M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"),i(F,"width","13"),i(F,"height","13"),i(F,"viewBox","0 0 24 24"),i(F,"fill","none"),i(F,"stroke","currentColor"),i(F,"stroke-width","2"),i(F,"stroke-linecap","round"),i(F,"stroke-linejoin","round"),i(P,"class","icon-btn svelte-1c4hcx6"),i(P,"title",e[4]),i(P,"aria-label",e[4]),i(K,"d","M2 2l8 8M10 2l-8 8"),i(D,"width","11"),i(D,"height","11"),i(D,"viewBox","0 0 12 12"),i(D,"fill","none"),i(D,"stroke","currentColor"),i(D,"stroke-width","1.8"),i(D,"stroke-linecap","round"),i(T,"class","icon-btn svelte-1c4hcx6"),i(T,"title",e[5]),i(T,"aria-label",e[5]),i(d,"class","actions svelte-1c4hcx6"),i(t,"class","header svelte-1c4hcx6")},m(q,w){A(q,t,w),r(t,l),r(l,n),r(n,o),r(n,s),r(n,a),r(n,h),r(l,c),r(l,u),r(l,f),_&&_.m(l,null),r(t,m),r(t,d),r(d,g),r(g,y),r(y,I),r(y,V),r(y,X),r(y,C),r(d,G),r(d,P),r(P,F),r(F,B),r(F,N),r(d,E),r(d,T),r(T,D),r(D,K),J||(H=[de(g,"click",function(){Xe(e[0])&&e[0].apply(this,arguments)}),de(P,"click",function(){Xe(e[2])&&e[2].apply(this,arguments)}),de(T,"click",function(){Xe(e[1])&&e[1].apply(this,arguments)})],J=!0)},p(q,[w]){e=q,e[6]?_?_.p(e,w):(_=Ft(e),_.c(),_.m(l,null)):_&&(_.d(1),_=null),w&8&&i(g,"title",e[3]),w&8&&i(g,"aria-label",e[3]),w&16&&i(P,"title",e[4]),w&16&&i(P,"aria-label",e[4]),w&32&&i(T,"title",e[5]),w&32&&i(T,"aria-label",e[5])},i:fe,o:fe,d(q){q&&R(t),_&&_.d(),J=!1,De(H)}}}function Gl(e,t,l){let{onRefresh:n}=t,{onClose:o}=t,{onToggleSettings:s}=t,{refreshLabel:a}=t,{settingsLabel:h}=t,{closeLabel:c}=t,{statusText:u=""}=t;return e.$$set=f=>{"onRefresh"in f&&l(0,n=f.onRefresh),"onClose"in f&&l(1,o=f.onClose),"onToggleSettings"in f&&l(2,s=f.onToggleSettings),"refreshLabel"in f&&l(3,a=f.refreshLabel),"settingsLabel"in f&&l(4,h=f.settingsLabel),"closeLabel"in f&&l(5,c=f.closeLabel),"statusText"in f&&l(6,u=f.statusText)},[n,o,s,a,h,c,u]}class Kl extends Ye{constructor(t){super(),Ke(this,t,Gl,Vl,Ge,{onRefresh:0,onClose:1,onToggleSettings:2,refreshLabel:3,settingsLabel:4,closeLabel:5,statusText:6})}}function Et(e){let t,l;return{c(){t=v("span"),l=O(e[2]),i(t,"class","sub svelte-1un0gu")},m(n,o){A(n,t,o),r(t,l)},p(n,o){o&4&&U(l,n[2])},d(n){n&&R(t)}}}function Yl(e){let t,l,n,o,s,a,h,c,u=e[2]&&Et(e);return{c(){t=v("div"),l=v("span"),n=O(e[0]),o=L(),s=v("div"),a=v("span"),h=O(e[1]),c=L(),u&&u.c(),i(l,"class","label svelte-1un0gu"),i(a,"class","value svelte-1un0gu"),i(a,"title",e[1]),z(a,"accent",e[3]),i(s,"class","right svelte-1un0gu"),i(t,"class","row svelte-1un0gu")},m(f,m){A(f,t,m),r(t,l),r(l,n),r(t,o),r(t,s),r(s,a),r(a,h),r(s,c),u&&u.m(s,null)},p(f,[m]){m&1&&U(n,f[0]),m&2&&U(h,f[1]),m&2&&i(a,"title",f[1]),m&8&&z(a,"accent",f[3]),f[2]?u?u.p(f,m):(u=Et(f),u.c(),u.m(s,null)):u&&(u.d(1),u=null)},i:fe,o:fe,d(f){f&&R(t),u&&u.d()}}}function Xl(e,t,l){let{label:n}=t,{value:o}=t,{sub:s=""}=t,{accent:a=!1}=t;return e.$$set=h=>{"label"in h&&l(0,n=h.label),"value"in h&&l(1,o=h.value),"sub"in h&&l(2,s=h.sub),"accent"in h&&l(3,a=h.accent)},[n,o,s,a]}class dt extends Ye{constructor(t){super(),Ke(this,t,Xl,Yl,Ge,{label:0,value:1,sub:2,accent:3})}}function At(e,t,l){const n=e.slice();return n[7]=t[l],n}function Pt(e,t,l){const n=e.slice();return n[7]=t[l],n}function Ql(e){let t;return{c(){t=v("div"),t.textContent="No token data",i(t,"class","empty svelte-4y3y1j")},m(l,n){A(l,t,n)},p:fe,d(l){l&&R(t)}}}function Zl(e){let t,l,n,o=te(e[0]),s=[];for(let c=0;c<o.length;c+=1)s[c]=Bt(Pt(e,o,c));let a=te(e[0]),h=[];for(let c=0;c<a.length;c+=1)h[c]=Nt(At(e,a,c));return{c(){t=v("div");for(let c=0;c<s.length;c+=1)s[c].c();l=L(),n=v("div");for(let c=0;c<h.length;c+=1)h[c].c();i(t,"class","bar svelte-4y3y1j"),i(n,"class","legend svelte-4y3y1j")},m(c,u){A(c,t,u);for(let f=0;f<s.length;f+=1)s[f]&&s[f].m(t,null);A(c,l,u),A(c,n,u);for(let f=0;f<h.length;f+=1)h[f]&&h[f].m(n,null)},p(c,u){if(u&3){o=te(c[0]);let f;for(f=0;f<o.length;f+=1){const m=Pt(c,o,f);s[f]?s[f].p(m,u):(s[f]=Bt(m),s[f].c(),s[f].m(t,null))}for(;f<s.length;f+=1)s[f].d(1);s.length=o.length}if(u&1){a=te(c[0]);let f;for(f=0;f<a.length;f+=1){const m=At(c,a,f);h[f]?h[f].p(m,u):(h[f]=Nt(m),h[f].c(),h[f].m(n,null))}for(;f<h.length;f+=1)h[f].d(1);h.length=a.length}},d(c){c&&(R(t),R(l),R(n)),ke(s,c),ke(h,c)}}}function Bt(e){let t,l;return{c(){t=v("div"),i(t,"class","segment svelte-4y3y1j"),Se(t,"width",e[7].value/e[1]*100+"%"),Se(t,"background",e[7].color),i(t,"title",l=e[7].label+": "+lt(e[7].value))},m(n,o){A(n,t,o)},p(n,o){o&3&&Se(t,"width",n[7].value/n[1]*100+"%"),o&1&&Se(t,"background",n[7].color),o&1&&l!==(l=n[7].label+": "+lt(n[7].value))&&i(t,"title",l)},d(n){n&&R(t)}}}function Nt(e){let t,l,n,o,s=e[7].label+"",a,h,c,u=lt(e[7].value)+"",f,m;return{c(){t=v("div"),l=v("span"),n=L(),o=v("span"),a=O(s),h=L(),c=v("span"),f=O(u),m=L(),i(l,"class","dot svelte-4y3y1j"),Se(l,"background",e[7].color),i(o,"class","legend-label svelte-4y3y1j"),i(c,"class","legend-value svelte-4y3y1j"),i(t,"class","legend-item svelte-4y3y1j")},m(d,g){A(d,t,g),r(t,l),r(t,n),r(t,o),r(o,a),r(t,h),r(t,c),r(c,f),r(t,m)},p(d,g){g&1&&Se(l,"background",d[7].color),g&1&&s!==(s=d[7].label+"")&&U(a,s),g&1&&u!==(u=lt(d[7].value)+"")&&U(f,u)},d(d){d&&R(t)}}}function Jl(e){let t;function l(s,a){return s[1]>0?Zl:Ql}let n=l(e),o=n(e);return{c(){t=v("div"),o.c(),i(t,"class","breakdown svelte-4y3y1j")},m(s,a){A(s,t,a),o.m(t,null)},p(s,[a]){n===(n=l(s))&&o?o.p(s,a):(o.d(1),o=n(s),o&&(o.c(),o.m(t,null)))},i:fe,o:fe,d(s){s&&R(t),o.d()}}}function lt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function $l(e,t,l){let n,o,{input:s=0}=t,{output:a=0}=t,{cacheRead:h=0}=t,{cacheWrite:c=0}=t,{thinking:u=0}=t;return e.$$set=f=>{"input"in f&&l(2,s=f.input),"output"in f&&l(3,a=f.output),"cacheRead"in f&&l(4,h=f.cacheRead),"cacheWrite"in f&&l(5,c=f.cacheWrite),"thinking"in f&&l(6,u=f.thinking)},e.$$.update=()=>{e.$$.dirty&124&&l(1,n=s+a+h+c+u),e.$$.dirty&124&&l(0,o=[{label:"Input",value:s,color:"var(--chart-input)"},{label:"Output",value:a,color:"var(--chart-output)"},{label:"Cache R",value:h,color:"var(--chart-cache-read)"},{label:"Cache W",value:c,color:"var(--chart-cache-write)"},{label:"Think",value:u,color:"var(--chart-thinking)"}].filter(f=>f.value>0))},[o,n,s,a,h,c,u]}class xl extends Ye{constructor(t){super(),Ke(this,t,$l,Jl,Ge,{input:2,output:3,cacheRead:4,cacheWrite:5,thinking:6})}}const It=[{code:"USD",label:"USD"},{code:"CNY",label:"CNY"}];function ql(e,t,l){return t==="USD"?e:l!=null&&l.rate&&Number.isFinite(l.rate)?e*l.rate:null}function kt(e,t,l,n,o=!1){const s=ql(e,t,n);return s===null?"--":Rl(s,t,l,o)}function Rl(e,t,l,n=!1){const o=n&&Math.abs(e)>=1e3?"compact":"standard",s=e>=100||o==="compact"?0:e>=1?2:e>0?3:0;return new Intl.NumberFormat(l,{style:"currency",currency:t,currencyDisplay:"narrowSymbol",notation:o,minimumFractionDigits:s,maximumFractionDigits:s}).format(e)}function Ot(e,t,l){const n=e.slice();return n[33]=t[l],n}function gt(e){const t=e.slice(),l=t[0][t[6]];t[36]=l;const n=t[21]();t[37]=n;const o=t[23](t[6]);t[38]=o;const s=t[22](t[6]);return t[39]=s,t}function Ht(e,t,l){const n=e.slice();return n[40]=t[l],n}function Ut(e,t,l){const n=e.slice();return n[40]=t[l],n[44]=l,n}function Wt(e){let t,l,n,o,s,a=nl(e[40])+"",h,c;return{c(){t=Y("line"),s=Y("text"),h=O(a),i(t,"x1",pe),i(t,"y1",l=e[15](e[40])),i(t,"x2",n=pe+e[9]),i(t,"y2",o=e[15](e[40])),i(t,"stroke","var(--border)"),i(t,"stroke-width","0.5"),i(t,"stroke-dasharray",e[44]===0?"none":"2,2"),i(s,"x",pe-7),i(s,"y",c=e[15](e[40])+3),i(s,"text-anchor","end"),i(s,"class","y-label svelte-15p89al")},m(u,f){A(u,t,f),A(u,s,f),r(s,h)},p(u,f){f[0]&2048&&l!==(l=u[15](u[40]))&&i(t,"y1",l),f[0]&512&&n!==(n=pe+u[9])&&i(t,"x2",n),f[0]&2048&&o!==(o=u[15](u[40]))&&i(t,"y2",o),f[0]&2048&&a!==(a=nl(u[40])+"")&&U(h,a),f[0]&2048&&c!==(c=u[15](u[40])+3)&&i(s,"y",c)},d(u){u&&(R(t),R(s))}}}function zt(e){let t,l=te(e[10]),n=[];for(let o=0;o<l.length;o+=1)n[o]=Vt(Ht(e,l,o));return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=ve()},m(o,s){for(let a=0;a<n.length;a+=1)n[a]&&n[a].m(o,s);A(o,t,s)},p(o,s){if(s[0]&198144){l=te(o[10]);let a;for(a=0;a<l.length;a+=1){const h=Ht(o,l,a);n[a]?n[a].p(h,s):(n[a]=Vt(h),n[a].c(),n[a].m(t.parentNode,t))}for(;a<n.length;a+=1)n[a].d(1);n.length=l.length}},d(o){o&&R(t),ke(n,o)}}}function Vt(e){let t,l=e[17](e[40])+"",n,o,s;return{c(){t=Y("text"),n=O(l),i(t,"x",o=pe+e[9]+7),i(t,"y",s=e[16](e[40])+3),i(t,"text-anchor","start"),i(t,"class","y-label y-label-cost svelte-15p89al")},m(a,h){A(a,t,h),r(t,n)},p(a,h){h[0]&1024&&l!==(l=a[17](a[40])+"")&&U(n,l),h[0]&512&&o!==(o=pe+a[9]+7)&&i(t,"x",o),h[0]&1024&&s!==(s=a[16](a[40])+3)&&i(t,"y",s)},d(a){a&&R(t)}}}function Gt(e){let t;return{c(){t=Y("path"),i(t,"d",e[12]),i(t,"fill","url(#areaGrad)"),i(t,"clip-path","url(#chartClip)"),i(t,"class","area svelte-15p89al")},m(l,n){A(l,t,n)},p(l,n){n[0]&4096&&i(t,"d",l[12])},d(l){l&&R(t)}}}function Kt(e){let t;return{c(){t=Y("path"),i(t,"d",e[13]),i(t,"fill","none"),i(t,"stroke","var(--chart-cache-read)"),i(t,"stroke-width","1.3"),i(t,"stroke-linecap","round"),i(t,"stroke-linejoin","round"),i(t,"clip-path","url(#chartClip)"),i(t,"class","line cost-line svelte-15p89al")},m(l,n){A(l,t,n)},p(l,n){n[0]&8192&&i(t,"d",l[13])},d(l){l&&R(t)}}}function Yt(e){let t;return{c(){t=Y("path"),i(t,"d",e[4]),i(t,"fill","none"),i(t,"stroke","var(--accent)"),i(t,"stroke-width","1.8"),i(t,"stroke-linecap","round"),i(t,"stroke-linejoin","round"),i(t,"clip-path","url(#chartClip)"),i(t,"class","line svelte-15p89al")},m(l,n){A(l,t,n)},p(l,n){n[0]&16&&i(t,"d",l[4])},d(l){l&&R(t)}}}function Xt(e){let t,l,n,o;return{c(){t=Y("line"),i(t,"x1",l=e[14](e[6])),i(t,"y1",be),i(t,"x2",n=e[14](e[6])),i(t,"y2",o=be+e[2]),i(t,"stroke","var(--text-muted)"),i(t,"stroke-width","0.5"),i(t,"stroke-dasharray","2,2")},m(s,a){A(s,t,a)},p(s,a){a[0]&64&&l!==(l=s[14](s[6]))&&i(t,"x1",l),a[0]&64&&n!==(n=s[14](s[6]))&&i(t,"x2",n),a[0]&4&&o!==(o=be+s[2])&&i(t,"y2",o)},d(s){s&&R(t)}}}function Qt(e){let t,l,n,o,s=e[1]&&Zt(e);return{c(){t=Y("circle"),s&&s.c(),o=ve(),i(t,"cx",l=e[14](e[6])),i(t,"cy",n=e[15](e[3][e[6]])),i(t,"r","4"),i(t,"fill","var(--bg)"),i(t,"stroke","var(--accent)"),i(t,"stroke-width","2")},m(a,h){A(a,t,h),s&&s.m(a,h),A(a,o,h)},p(a,h){h[0]&64&&l!==(l=a[14](a[6]))&&i(t,"cx",l),h[0]&72&&n!==(n=a[15](a[3][a[6]]))&&i(t,"cy",n),a[1]?s?s.p(a,h):(s=Zt(a),s.c(),s.m(o.parentNode,o)):s&&(s.d(1),s=null)},d(a){a&&(R(t),R(o)),s&&s.d(a)}}}function Zt(e){let t,l,n;return{c(){t=Y("circle"),i(t,"cx",l=e[14](e[6])),i(t,"cy",n=e[16](e[5][e[6]])),i(t,"r","3"),i(t,"fill","var(--bg)"),i(t,"stroke","var(--chart-cache-read)"),i(t,"stroke-width","1.5")},m(o,s){A(o,t,s)},p(o,s){s[0]&64&&l!==(l=o[14](o[6]))&&i(t,"cx",l),s[0]&96&&n!==(n=o[16](o[5][o[6]]))&&i(t,"cy",n)},d(o){o&&R(t)}}}function Jt(e){let t,l,n,o=e[18](e[36].date)+"",s,a,h=ll(e[36].tokens)+"",c,u,f,m=e[1]&&e[36].cost>0&&$t(e);return{c(){t=Y("foreignObject"),l=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n=document.createElementNS("http://www.w3.org/1999/xhtml","span"),s=O(o),a=document.createElementNS("http://www.w3.org/1999/xhtml","span"),c=O(h),m&&m.c(),i(n,"class","tooltip-date svelte-15p89al"),i(a,"class","tooltip-metric token-dot svelte-15p89al"),i(l,"class","tooltip svelte-15p89al"),i(l,"xmlns","http://www.w3.org/1999/xhtml"),z(l,"pointer-left",e[24](e[6])==="left"),z(l,"pointer-right",e[24](e[6])==="right"),i(t,"x",u=e[38]),i(t,"y",f=e[39]),i(t,"width",e[37]),i(t,"height","28"),i(t,"class","tooltip-fo svelte-15p89al")},m(d,g){A(d,t,g),r(t,l),r(l,n),r(n,s),r(l,a),r(a,c),m&&m.m(l,null)},p(d,g){g[0]&65&&o!==(o=d[18](d[36].date)+"")&&U(s,o),g[0]&65&&h!==(h=ll(d[36].tokens)+"")&&U(c,h),d[1]&&d[36].cost>0?m?m.p(d,g):(m=$t(d),m.c(),m.m(l,null)):m&&(m.d(1),m=null),g[0]&16777280&&z(l,"pointer-left",d[24](d[6])==="left"),g[0]&16777280&&z(l,"pointer-right",d[24](d[6])==="right"),g[0]&64&&u!==(u=d[38])&&i(t,"x",u),g[0]&64&&f!==(f=d[39])&&i(t,"y",f)},d(d){d&&R(t),m&&m.d()}}}function $t(e){let t,l=e[20](e[36].cost)+"",n;return{c(){t=document.createElementNS("http://www.w3.org/1999/xhtml","span"),n=O(l),i(t,"class","tooltip-metric cost-dot svelte-15p89al")},m(o,s){A(o,t,s),r(t,n)},p(o,s){s[0]&65&&l!==(l=o[20](o[36].cost)+"")&&U(n,l)},d(o){o&&R(t)}}}function xt(e){let t,l=e[19](e[0][e[33]].date)+"",n,o;return{c(){t=Y("text"),n=O(l),i(t,"x",o=e[14](e[33])),i(t,"y",nt-2),i(t,"text-anchor","middle"),i(t,"class","tick-label svelte-15p89al")},m(s,a){A(s,t,a),r(t,n)},p(s,a){a[0]&257&&l!==(l=s[19](s[0][s[33]].date)+"")&&U(n,l),a[0]&256&&o!==(o=s[14](s[33]))&&i(t,"x",o)},d(s){s&&R(t)}}}function el(e){let t,l=e[0][e[33]]&&xt(e);return{c(){l&&l.c(),t=ve()},m(n,o){l&&l.m(n,o),A(n,t,o)},p(n,o){n[0][n[33]]?l?l.p(n,o):(l=xt(n),l.c(),l.m(t.parentNode,t)):l&&(l.d(1),l=null)},d(n){n&&R(t),l&&l.d(n)}}}function en(e){let t,l,n,o,s,a,h,c,u,f,m,d,g,y,I,V,X,C,G=te(e[11]),P=[];for(let _=0;_<G.length;_+=1)P[_]=Wt(Ut(e,G,_));let F=e[1]&&zt(e),B=e[12]&&Gt(e),N=e[13]&&Kt(e),E=e[4]&&Yt(e),T=e[6]!==null&&Xt(e),D=e[6]!==null&&Qt(e),K=e[6]!==null&&e[0][e[6]]&&Jt(gt(e)),J=te(e[8]),H=[];for(let _=0;_<J.length;_+=1)H[_]=el(Ot(e,J,_));return{c(){t=v("div"),l=Y("svg"),n=Y("defs"),o=Y("linearGradient"),s=Y("stop"),a=Y("stop"),h=Y("clipPath"),c=Y("rect");for(let _=0;_<P.length;_+=1)P[_].c();u=ve(),F&&F.c(),f=ve(),B&&B.c(),m=ve(),N&&N.c(),d=ve(),E&&E.c(),g=ve(),T&&T.c(),y=ve(),D&&D.c(),I=ve(),K&&K.c(),V=ve();for(let _=0;_<H.length;_+=1)H[_].c();i(s,"offset","0%"),i(s,"stop-color","var(--accent)"),i(s,"stop-opacity","0.2"),i(a,"offset","100%"),i(a,"stop-color","var(--accent)"),i(a,"stop-opacity","0.02"),i(o,"id","areaGrad"),i(o,"x1","0"),i(o,"y1","0"),i(o,"x2","0"),i(o,"y2","1"),i(c,"x",pe),i(c,"y",be),i(c,"width",e[9]),i(c,"height",e[2]),i(h,"id","chartClip"),i(l,"viewBox","0 0 "+wt+" "+nt),i(l,"width","100%"),i(l,"height",nt),i(l,"class","chart-svg svelte-15p89al"),i(l,"role","img"),i(l,"aria-label","Token usage trend chart"),z(l,"mounted",e[7]),i(t,"class","chart-wrapper svelte-15p89al")},m(_,q){A(_,t,q),r(t,l),r(l,n),r(n,o),r(o,s),r(o,a),r(n,h),r(h,c);for(let w=0;w<P.length;w+=1)P[w]&&P[w].m(l,null);r(l,u),F&&F.m(l,null),r(l,f),B&&B.m(l,null),r(l,m),N&&N.m(l,null),r(l,d),E&&E.m(l,null),r(l,g),T&&T.m(l,null),r(l,y),D&&D.m(l,null),r(l,I),K&&K.m(l,null),r(l,V);for(let w=0;w<H.length;w+=1)H[w]&&H[w].m(l,null);X||(C=[de(l,"mousemove",e[25]),de(l,"mouseleave",e[26])],X=!0)},p(_,q){if(q[0]&512&&i(c,"width",_[9]),q[0]&4&&i(c,"height",_[2]),q[0]&35328){G=te(_[11]);let w;for(w=0;w<G.length;w+=1){const W=Ut(_,G,w);P[w]?P[w].p(W,q):(P[w]=Wt(W),P[w].c(),P[w].m(l,u))}for(;w<P.length;w+=1)P[w].d(1);P.length=G.length}if(_[1]?F?F.p(_,q):(F=zt(_),F.c(),F.m(l,f)):F&&(F.d(1),F=null),_[12]?B?B.p(_,q):(B=Gt(_),B.c(),B.m(l,m)):B&&(B.d(1),B=null),_[13]?N?N.p(_,q):(N=Kt(_),N.c(),N.m(l,d)):N&&(N.d(1),N=null),_[4]?E?E.p(_,q):(E=Yt(_),E.c(),E.m(l,g)):E&&(E.d(1),E=null),_[6]!==null?T?T.p(_,q):(T=Xt(_),T.c(),T.m(l,y)):T&&(T.d(1),T=null),_[6]!==null?D?D.p(_,q):(D=Qt(_),D.c(),D.m(l,I)):D&&(D.d(1),D=null),_[6]!==null&&_[0][_[6]]?K?K.p(gt(_),q):(K=Jt(gt(_)),K.c(),K.m(l,V)):K&&(K.d(1),K=null),q[0]&540929){J=te(_[8]);let w;for(w=0;w<J.length;w+=1){const W=Ot(_,J,w);H[w]?H[w].p(W,q):(H[w]=el(W),H[w].c(),H[w].m(l,null))}for(;w<H.length;w+=1)H[w].d(1);H.length=J.length}q[0]&128&&z(l,"mounted",_[7])},i:fe,o:fe,d(_){_&&R(t),ke(P,_),F&&F.d(),B&&B.d(),N&&N.d(),E&&E.d(),T&&T.d(),D&&D.d(),K&&K.d(),ke(H,_),X=!1,De(C)}}}const wt=352,nt=126,be=14,tn=18,pe=34,ln=36;function tl(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),l=e/t;return(l<=1?1:l<=2?2:l<=5?5:10)*t}function ll(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e))}function nl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e5?`${Math.round(e/1e3)}K`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e))}function il(e){return new Date(e+"T00:00:00")}function nn(e,t,l){let n,o,s,a,h,c,u,f,m,d,g,y,{data:I=[]}=t,{showCost:V=!1}=t,{locale:X="en"}=t,{currency:C="USD"}=t,{exchangeRate:G=null}=t,P=null,F=!1;Ml(()=>{requestAnimationFrame(()=>{l(7,F=!0)})});function B(S){return pe+S/Math.max(I.length-1,1)*h}function N(S){return be+c-S/s*c}function E(S){return be+c-S/a*c}function T(S,le){if(S.length<2)return"";const k=S.length,M=S.map((j,ee)=>B(ee)),$=S.map(j=>le(j));if(k===2)return`M${M[0]},${$[0]}L${M[1]},${$[1]}`;const Q=[],x=[];for(let j=0;j<k-1;j++)Q.push(($[j+1]-$[j])/(M[j+1]-M[j]));x.push(Q[0]);for(let j=1;j<k-1;j++)Q[j-1]*Q[j]<=0?x.push(0):x.push((Q[j-1]+Q[j])/2);x.push(Q[k-2]);for(let j=0;j<k-1;j++)if(Math.abs(Q[j])<1e-12)x[j]=0,x[j+1]=0;else{const ee=x[j]/Q[j],ge=x[j+1]/Q[j],ye=ee*ee+ge*ge;if(ye>9){const Te=3/Math.sqrt(ye);x[j]=Te*ee*Q[j],x[j+1]=Te*ge*Q[j]}}let ce=`M${M[0].toFixed(1)},${$[0].toFixed(1)}`;for(let j=0;j<k-1;j++){const ee=(M[j+1]-M[j])/3,ge=M[j]+ee,ye=$[j]+x[j]*ee,Te=M[j+1]-ee,Je=$[j+1]-x[j+1]*ee;ce+=`C${ge.toFixed(1)},${ye.toFixed(1)},${Te.toFixed(1)},${Je.toFixed(1)},${M[j+1].toFixed(1)},${$[j+1].toFixed(1)}`}return ce}function D(S){return Rl(S,C,X,!0)}function K(S){const le=il(S);return new Intl.DateTimeFormat(X,{month:X==="zh"?"numeric":"short",day:"numeric"}).format(le)}function J(S){const le=il(S);return new Intl.DateTimeFormat(X,{month:"numeric",day:"numeric"}).format(le)}function H(S){return kt(S,C,X,G)}function _(){return V?156:116}function q(S){const le=N(n[S]??0)-30;return Math.min(Math.max(le,4),be+c-28)}function w(S){const k=_(),M=B(S),$=W(S)==="right"?M-k-8:M+8;return Math.min(Math.max($,pe),pe+h-k)}function W(S){return B(S)>pe+h/2?"right":"left"}function me(S){const k=S.currentTarget.getBoundingClientRect(),M=(S.clientX-k.left)/k.width*wt;let $=1/0,Q=0;for(let x=0;x<I.length;x++){const ce=Math.abs(B(x)-M);ce<$&&($=ce,Q=x)}l(6,P=Q)}function we(){l(6,P=null)}return e.$$set=S=>{"data"in S&&l(0,I=S.data),"showCost"in S&&l(1,V=S.showCost),"locale"in S&&l(27,X=S.locale),"currency"in S&&l(28,C=S.currency),"exchangeRate"in S&&l(29,G=S.exchangeRate)},e.$$.update=()=>{e.$$.dirty[0]&1&&l(3,n=I.map(S=>S.tokens)),e.$$.dirty[0]&805306369&&l(5,o=I.map(S=>ql(S.cost,C,G)??0)),e.$$.dirty[0]&8&&l(31,s=tl(Math.max(...n,1))),e.$$.dirty[0]&32&&l(30,a=tl(Math.max(...o,1))),e.$$.dirty[0]&8&&l(4,u=T(n,N)),e.$$.dirty[0]&34&&l(13,f=V?T(o,E):""),e.$$.dirty[0]&28&&l(12,m=u?`${u}L${B(n.length-1).toFixed(1)},${(be+c).toFixed(1)}L${B(0).toFixed(1)},${(be+c).toFixed(1)}Z`:""),e.$$.dirty[1]&1&&l(11,d=[0,s/2,s]),e.$$.dirty[0]&1073741824&&l(10,g=[0,a/2,a]),e.$$.dirty[0]&1&&l(8,y=I.length<=5?I.map((S,le)=>le):[0,Math.floor(I.length*.25),Math.floor(I.length*.5),Math.floor(I.length*.75),I.length-1])},l(9,h=wt-pe-ln),l(2,c=nt-be-tn),[I,V,c,n,u,o,P,F,y,h,g,d,m,f,B,N,E,D,K,J,H,_,q,w,W,me,we,X,C,G,a,s]}class on extends Ye{constructor(t){super(),Ke(this,t,nn,en,Ge,{data:0,showCost:1,locale:27,currency:28,exchangeRate:29},null,[-1,-1])}}const sn={today:"Today",lastNDays:e=>`Last ${e} days`,tokenBreakdown:"Token breakdown",tokenBreakdownToday:"Token breakdown (Today)",trend:"Trend",topModel:"Top Model",topTool:"Top Tool",sessions:"Sessions",settings:"Settings",theme:"Theme",timeRange:"Time range",refreshInterval:"Refresh interval",display:"Display",currency:"Currency",exchangeRate:"Exchange rate",exchangeRateUpdated:e=>`Updated ${e}`,exchangeRateUnavailable:"Exchange rate unavailable",language:"Language",showCost:"Show cost",tokenBreakdownToggle:"Token breakdown",activityChart:"Activity chart",syncedAt:e=>`Synced ${e}`,themeSystem:"System",themeLight:"Light",themeDark:"Dark",showPanel:"Show Panel",openDashboard:"Open Dashboard",refresh:"Refresh",quit:"Quit",close:"Close",installTitle:"Dashboard Setup",installPreparing:"Preparing...",installInstalling:"Installing @juliantanx/aiusage...",installLaunching:"Starting dashboard...",installDone:"Done! Opening...",installFailed:"Installation failed"},an={today:"今日",lastNDays:e=>`近 ${e} 天`,tokenBreakdown:"Token 分布",tokenBreakdownToday:"Token 分布 (今日)",trend:"趋势",topModel:"常用模型",topTool:"常用工具",sessions:"会话数",settings:"设置",theme:"主题",timeRange:"时间范围",refreshInterval:"刷新间隔",display:"显示",currency:"币种",exchangeRate:"汇率",exchangeRateUpdated:e=>`更新于 ${e}`,exchangeRateUnavailable:"汇率不可用",language:"语言",showCost:"显示费用",tokenBreakdownToggle:"Token 分布",activityChart:"活动图表",syncedAt:e=>`同步于 ${e}`,themeSystem:"跟随系统",themeLight:"浅色",themeDark:"深色",showPanel:"显示面板",openDashboard:"打开仪表盘",refresh:"刷新",quit:"退出",close:"关闭",installTitle:"仪表盘配置",installPreparing:"准备中...",installInstalling:"正在安装 @juliantanx/aiusage...",installLaunching:"正在启动仪表盘...",installDone:"完成!正在打开...",installFailed:"安装失败"},ol={en:sn,zh:an};function Fl(e){return ol[e]??ol.en}function sl(e,t,l){const n=e.slice();return n[22]=t[l],n}function al(e,t,l){const n=e.slice();return n[25]=t[l],n}function rl(e,t,l){const n=e.slice();return n[28]=t[l],n}function fl(e,t,l){const n=e.slice();return n[31]=t[l],n}function cl(e,t,l){const n=e.slice();return n[34]=t[l],n}function ul(e){let t,l,n;function o(){return e[14](e[34])}return{c(){t=v("button"),t.textContent=`${e[34].label} `,i(t,"class","option-btn svelte-198qnem"),z(t,"active",e[1].locale===e[34].value)},m(s,a){A(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&2050&&z(t,"active",e[1].locale===e[34].value)},d(s){s&&R(t),l=!1,n()}}}function hl(e){let t,l,n;function o(){return e[15](e[31])}return{c(){t=v("button"),t.textContent=`${e[31].label} `,i(t,"class","option-btn svelte-198qnem"),z(t,"active",e[1].currency===e[31].code)},m(s,a){A(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&2&&z(t,"active",e[1].currency===e[31].code)},d(s){s&&R(t),l=!1,n()}}}function dl(e){var d;let t,l,n=e[2].exchangeRate+"",o,s,a,h,c=e[7](),u,f=c&&rn(e),m=((d=e[0])==null?void 0:d.error)&&gl(e);return{c(){var g;t=v("div"),l=v("span"),o=O(n),s=L(),a=v("strong"),a.textContent=`${e[6]()}`,h=L(),f&&f.c(),u=L(),m&&m.c(),i(a,"class","svelte-198qnem"),i(t,"class","rate-info svelte-198qnem"),z(t,"error",!((g=e[0])!=null&&g.rate))},m(g,y){A(g,t,y),r(t,l),r(l,o),r(t,s),r(t,a),r(t,h),f&&f.m(t,null),r(t,u),m&&m.m(t,null)},p(g,y){var I,V;y[0]&4&&n!==(n=g[2].exchangeRate+"")&&U(o,n),c&&f.p(g,y),(I=g[0])!=null&&I.error?m?m.p(g,y):(m=gl(g),m.c(),m.m(t,null)):m&&(m.d(1),m=null),y[0]&1&&z(t,"error",!((V=g[0])!=null&&V.rate))},d(g){g&&R(t),f&&f.d(),m&&m.d()}}}function rn(e){let t;return{c(){t=v("small"),t.textContent=`${e[7]()}`,i(t,"class","svelte-198qnem")},m(l,n){A(l,t,n)},p:fe,d(l){l&&R(t)}}}function gl(e){let t,l=e[0].error+"",n;return{c(){t=v("small"),n=O(l),i(t,"class","svelte-198qnem")},m(o,s){A(o,t,s),r(t,n)},p(o,s){s[0]&1&&l!==(l=o[0].error+"")&&U(n,l)},d(o){o&&R(t)}}}function _l(e){let t,l=e[28].label+"",n,o,s,a;function h(){return e[16](e[28])}return{c(){t=v("button"),n=O(l),o=L(),i(t,"class","option-btn svelte-198qnem"),z(t,"active",e[1].theme===e[28].value)},m(c,u){A(c,t,u),r(t,n),r(t,o),s||(a=de(t,"click",h),s=!0)},p(c,u){e=c,u[0]&8&&l!==(l=e[28].label+"")&&U(n,l),u[0]&10&&z(t,"active",e[1].theme===e[28].value)},d(c){c&&R(t),s=!1,a()}}}function ml(e){let t,l,n;function o(){return e[17](e[25])}return{c(){t=v("button"),t.textContent=`${e[25].label} `,i(t,"class","option-btn svelte-198qnem"),z(t,"active",e[1].rangeDays===e[25].value)},m(s,a){A(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&1026&&z(t,"active",e[1].rangeDays===e[25].value)},d(s){s&&R(t),l=!1,n()}}}function pl(e){let t,l,n;function o(){return e[18](e[22])}return{c(){t=v("button"),t.textContent=`${e[22].label} `,i(t,"class","option-btn svelte-198qnem"),z(t,"active",e[1].refreshIntervalSec===e[22].value)},m(s,a){A(s,t,a),l||(n=de(t,"click",o),l=!0)},p(s,a){e=s,a[0]&514&&z(t,"active",e[1].refreshIntervalSec===e[22].value)},d(s){s&&R(t),l=!1,n()}}}function fn(e){let t,l,n,o=e[2].settings+"",s,a,h,c,u,f,m=e[2].language+"",d,g,y,I,V,X,C=e[2].currency+"",G,P,F,B,N,E,T,D=e[2].theme+"",K,J,H,_,q,w,W=e[2].timeRange+"",me,we,S,le,k,M,$=e[2].refreshInterval+"",Q,x,ce,j,ee,ge,ye=e[2].display+"",Te,Je,Ce,Ae,it,$e=e[2].showCost+"",ot,Tt,je,Ct,Pe,st,xe=e[2].tokenBreakdownToggle+"",at,St,qe,Mt,Be,rt,et=e[2].activityChart+"",ft,Lt,Re,ct,Dt,Ne=te(e[11]),ie=[];for(let b=0;b<Ne.length;b+=1)ie[b]=ul(cl(e,Ne,b));let Ie=te(It),oe=[];for(let b=0;b<Ie.length;b+=1)oe[b]=hl(fl(e,Ie,b));let ue=e[1].currency==="CNY"&&dl(e),Oe=te(e[3]),se=[];for(let b=0;b<Oe.length;b+=1)se[b]=_l(rl(e,Oe,b));let He=te(e[10]),ae=[];for(let b=0;b<He.length;b+=1)ae[b]=ml(al(e,He,b));let Ue=te(e[9]),re=[];for(let b=0;b<Ue.length;b+=1)re[b]=pl(sl(e,Ue,b));return{c(){t=v("div"),l=v("div"),n=v("span"),s=O(o),a=L(),h=v("button"),h.innerHTML='<svg width="11" height="11" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="M2 2l8 8M10 2l-8 8"></path></svg>',c=L(),u=v("div"),f=v("div"),d=O(m),g=L(),y=v("div");for(let b=0;b<ie.length;b+=1)ie[b].c();I=L(),V=v("div"),X=v("div"),G=O(C),P=L(),F=v("div");for(let b=0;b<oe.length;b+=1)oe[b].c();B=L(),ue&&ue.c(),N=L(),E=v("div"),T=v("div"),K=O(D),J=L(),H=v("div");for(let b=0;b<se.length;b+=1)se[b].c();_=L(),q=v("div"),w=v("div"),me=O(W),we=L(),S=v("div");for(let b=0;b<ae.length;b+=1)ae[b].c();le=L(),k=v("div"),M=v("div"),Q=O($),x=L(),ce=v("div");for(let b=0;b<re.length;b+=1)re[b].c();j=L(),ee=v("div"),ge=v("div"),Te=O(ye),Je=L(),Ce=v("div"),Ae=v("label"),it=v("span"),ot=O($e),Tt=L(),je=v("button"),je.innerHTML='<span class="toggle-thumb svelte-198qnem"></span>',Ct=L(),Pe=v("label"),st=v("span"),at=O(xe),St=L(),qe=v("button"),qe.innerHTML='<span class="toggle-thumb svelte-198qnem"></span>',Mt=L(),Be=v("label"),rt=v("span"),ft=O(et),Lt=L(),Re=v("button"),Re.innerHTML='<span class="toggle-thumb svelte-198qnem"></span>',i(n,"class","settings-title svelte-198qnem"),i(h,"class","back-btn svelte-198qnem"),i(l,"class","settings-header svelte-198qnem"),i(f,"class","section-label svelte-198qnem"),i(y,"class","button-group svelte-198qnem"),i(u,"class","section svelte-198qnem"),i(X,"class","section-label svelte-198qnem"),i(F,"class","button-group svelte-198qnem"),i(V,"class","section svelte-198qnem"),i(T,"class","section-label svelte-198qnem"),i(H,"class","button-group svelte-198qnem"),i(E,"class","section svelte-198qnem"),i(w,"class","section-label svelte-198qnem"),i(S,"class","button-group svelte-198qnem"),i(q,"class","section svelte-198qnem"),i(M,"class","section-label svelte-198qnem"),i(ce,"class","button-group svelte-198qnem"),i(k,"class","section svelte-198qnem"),i(ge,"class","section-label svelte-198qnem"),i(je,"class","toggle svelte-198qnem"),z(je,"on",e[1].showCost),i(Ae,"class","toggle-row svelte-198qnem"),i(qe,"class","toggle svelte-198qnem"),z(qe,"on",e[1].showTokenBreakdown),i(Pe,"class","toggle-row svelte-198qnem"),i(Re,"class","toggle svelte-198qnem"),z(Re,"on",e[1].showHeatmap),i(Be,"class","toggle-row svelte-198qnem"),i(Ce,"class","toggles svelte-198qnem"),i(ee,"class","section svelte-198qnem"),i(t,"class","settings svelte-198qnem")},m(b,Z){A(b,t,Z),r(t,l),r(l,n),r(n,s),r(l,a),r(l,h),r(t,c),r(t,u),r(u,f),r(f,d),r(u,g),r(u,y);for(let p=0;p<ie.length;p+=1)ie[p]&&ie[p].m(y,null);r(t,I),r(t,V),r(V,X),r(X,G),r(V,P),r(V,F);for(let p=0;p<oe.length;p+=1)oe[p]&&oe[p].m(F,null);r(V,B),ue&&ue.m(V,null),r(t,N),r(t,E),r(E,T),r(T,K),r(E,J),r(E,H);for(let p=0;p<se.length;p+=1)se[p]&&se[p].m(H,null);r(t,_),r(t,q),r(q,w),r(w,me),r(q,we),r(q,S);for(let p=0;p<ae.length;p+=1)ae[p]&&ae[p].m(S,null);r(t,le),r(t,k),r(k,M),r(M,Q),r(k,x),r(k,ce);for(let p=0;p<re.length;p+=1)re[p]&&re[p].m(ce,null);r(t,j),r(t,ee),r(ee,ge),r(ge,Te),r(ee,Je),r(ee,Ce),r(Ce,Ae),r(Ae,it),r(it,ot),r(Ae,Tt),r(Ae,je),r(Ce,Ct),r(Ce,Pe),r(Pe,st),r(st,at),r(Pe,St),r(Pe,qe),r(Ce,Mt),r(Ce,Be),r(Be,rt),r(rt,ft),r(Be,Lt),r(Be,Re),ct||(Dt=[de(h,"click",e[13]),de(je,"click",e[19]),de(qe,"click",e[20]),de(Re,"click",e[21])],ct=!0)},p(b,Z){if(Z[0]&4&&o!==(o=b[2].settings+"")&&U(s,o),Z[0]&4&&m!==(m=b[2].language+"")&&U(d,m),Z[0]&2082){Ne=te(b[11]);let p;for(p=0;p<Ne.length;p+=1){const he=cl(b,Ne,p);ie[p]?ie[p].p(he,Z):(ie[p]=ul(he),ie[p].c(),ie[p].m(y,null))}for(;p<ie.length;p+=1)ie[p].d(1);ie.length=Ne.length}if(Z[0]&4&&C!==(C=b[2].currency+"")&&U(G,C),Z[0]&34){Ie=te(It);let p;for(p=0;p<Ie.length;p+=1){const he=fl(b,Ie,p);oe[p]?oe[p].p(he,Z):(oe[p]=hl(he),oe[p].c(),oe[p].m(F,null))}for(;p<oe.length;p+=1)oe[p].d(1);oe.length=Ie.length}if(b[1].currency==="CNY"?ue?ue.p(b,Z):(ue=dl(b),ue.c(),ue.m(V,null)):ue&&(ue.d(1),ue=null),Z[0]&4&&D!==(D=b[2].theme+"")&&U(K,D),Z[0]&42){Oe=te(b[3]);let p;for(p=0;p<Oe.length;p+=1){const he=rl(b,Oe,p);se[p]?se[p].p(he,Z):(se[p]=_l(he),se[p].c(),se[p].m(H,null))}for(;p<se.length;p+=1)se[p].d(1);se.length=Oe.length}if(Z[0]&4&&W!==(W=b[2].timeRange+"")&&U(me,W),Z[0]&1058){He=te(b[10]);let p;for(p=0;p<He.length;p+=1){const he=al(b,He,p);ae[p]?ae[p].p(he,Z):(ae[p]=ml(he),ae[p].c(),ae[p].m(S,null))}for(;p<ae.length;p+=1)ae[p].d(1);ae.length=He.length}if(Z[0]&4&&$!==($=b[2].refreshInterval+"")&&U(Q,$),Z[0]&546){Ue=te(b[9]);let p;for(p=0;p<Ue.length;p+=1){const he=sl(b,Ue,p);re[p]?re[p].p(he,Z):(re[p]=pl(he),re[p].c(),re[p].m(ce,null))}for(;p<re.length;p+=1)re[p].d(1);re.length=Ue.length}Z[0]&4&&ye!==(ye=b[2].display+"")&&U(Te,ye),Z[0]&4&&$e!==($e=b[2].showCost+"")&&U(ot,$e),Z[0]&2&&z(je,"on",b[1].showCost),Z[0]&4&&xe!==(xe=b[2].tokenBreakdownToggle+"")&&U(at,xe),Z[0]&2&&z(qe,"on",b[1].showTokenBreakdown),Z[0]&4&&et!==(et=b[2].activityChart+"")&&U(ft,et),Z[0]&2&&z(Re,"on",b[1].showHeatmap)},i:fe,o:fe,d(b){b&&R(t),ke(ie,b),ke(oe,b),ue&&ue.d(),ke(se,b),ke(ae,b),ke(re,b),ct=!1,De(Dt)}}}function cn(e,t,l){let n,o,{settings:s}=t,{exchangeRate:a=null}=t;const h=Ol();let c={...s};function u(){h("save",c)}function f(){return a!=null&&a.rate?`1 USD = ${a.rate.toFixed(4)} CNY`:n.exchangeRateUnavailable}function m(){if(!(a!=null&&a.fetchedAt))return"";const T=new Date(a.fetchedAt),D=String(T.getHours()).padStart(2,"0"),K=String(T.getMinutes()).padStart(2,"0");return n.exchangeRateUpdated(`${D}:${K}`)}function d(T){typeof c[T]=="boolean"&&(l(1,c={...c,[T]:!c[T]}),u())}const g=[{label:"30s",value:30},{label:"1m",value:60},{label:"5m",value:300},{label:"10m",value:600}],y=[{label:"7d",value:7},{label:"14d",value:14},{label:"30d",value:30},{label:"60d",value:60},{label:"90d",value:90}],I=[{label:"English",value:"en"},{label:"中文",value:"zh"}],V=()=>h("close"),X=T=>{l(1,c={...c,locale:T.value}),u()},C=T=>{l(1,c={...c,currency:T.code}),u()},G=T=>{l(1,c={...c,theme:T.value}),u()},P=T=>{l(1,c={...c,rangeDays:T.value}),u()},F=T=>{l(1,c={...c,refreshIntervalSec:T.value}),u()},B=()=>d("showCost"),N=()=>d("showTokenBreakdown"),E=()=>d("showHeatmap");return e.$$set=T=>{"settings"in T&&l(12,s=T.settings),"exchangeRate"in T&&l(0,a=T.exchangeRate)},e.$$.update=()=>{e.$$.dirty[0]&2&&l(2,n=Fl(c.locale??"en")),e.$$.dirty[0]&4&&l(3,o=[{label:n.themeSystem,value:"system"},{label:n.themeLight,value:"light"},{label:n.themeDark,value:"dark"}])},[a,c,n,o,h,u,f,m,d,g,y,I,s,V,X,C,G,P,F,B,N,E]}class un extends Ye{constructor(t){super(),Ke(this,t,cn,fn,Ge,{settings:12,exchangeRate:0},null,[-1,-1])}}function vl(e){let t,l,n,o,s,a=e[4].installTitle+"",h,c,u,f,m,d=e[10]&&bl(e);return{c(){t=v("div"),l=v("div"),n=v("div"),o=L(),s=v("div"),h=O(a),c=L(),u=v("div"),f=O(e[11]),m=L(),d&&d.c(),i(n,"class","install-spinner svelte-1sj3khb"),z(n,"hidden",e[3]==="done"||e[3]==="failed"),i(s,"class","install-title svelte-1sj3khb"),i(u,"class","install-message svelte-1sj3khb"),i(l,"class","install-content svelte-1sj3khb"),i(t,"class","install-overlay svelte-1sj3khb"),z(t,"failed",e[3]==="failed"),z(t,"done",e[3]==="done")},m(g,y){A(g,t,y),r(t,l),r(l,n),r(l,o),r(l,s),r(s,h),r(l,c),r(l,u),r(u,f),r(l,m),d&&d.m(l,null)},p(g,y){y[0]&8&&z(n,"hidden",g[3]==="done"||g[3]==="failed"),y[0]&16&&a!==(a=g[4].installTitle+"")&&U(h,a),y[0]&2048&&U(f,g[11]),g[10]?d?d.p(g,y):(d=bl(g),d.c(),d.m(l,null)):d&&(d.d(1),d=null),y[0]&8&&z(t,"failed",g[3]==="failed"),y[0]&8&&z(t,"done",g[3]==="done")},d(g){g&&R(t),d&&d.d()}}}function bl(e){let t,l;return{c(){t=v("div"),l=O(e[10]),i(t,"class","install-error svelte-1sj3khb")},m(n,o){A(n,t,o),r(t,l)},p(n,o){o[0]&1024&&U(l,n[10])},d(n){n&&R(t)}}}function hn(e){var me,we,S,le;let t,l,n,o,s,a=e[4].today+"",h,c,u,f,m,d,g,y,I,V,X,C,G,P,F,B,N,E,T,D,K,J,H,_=((me=e[1])==null?void 0:me.showCost)&&kl(e),q=((we=e[1])==null?void 0:we.showCost)&&wl(e),w=((S=e[1])==null?void 0:S.showTokenBreakdown)&&e[0]&&yl(e),W=((le=e[1])==null?void 0:le.showHeatmap)&&e[0]&&Tl(e);return E=new dt({props:{label:e[4].topModel,value:e[17],sub:e[16]}}),D=new dt({props:{label:e[4].topTool,value:e[15],sub:e[14]}}),J=new dt({props:{label:e[4].sessions,value:e[13]}}),{c(){t=v("div"),l=v("div"),n=v("div"),o=v("div"),s=v("span"),h=O(a),c=L(),u=v("span"),f=O(e[22]),m=L(),_&&_.c(),d=L(),g=v("div"),y=v("span"),I=O(e[18]),V=L(),X=v("span"),C=O(e[21]),G=L(),q&&q.c(),P=L(),w&&w.c(),F=L(),W&&W.c(),B=L(),N=v("div"),Ee(E.$$.fragment),T=L(),Ee(D.$$.fragment),K=L(),Ee(J.$$.fragment),i(s,"class","metric-label svelte-1sj3khb"),i(u,"class","metric-value svelte-1sj3khb"),i(o,"class","metric svelte-1sj3khb"),i(y,"class","metric-label svelte-1sj3khb"),i(X,"class","metric-value svelte-1sj3khb"),i(g,"class","metric svelte-1sj3khb"),i(n,"class","metric-grid svelte-1sj3khb"),i(l,"class","section svelte-1sj3khb"),i(N,"class","section details svelte-1sj3khb"),i(t,"class","content svelte-1sj3khb")},m(k,M){A(k,t,M),r(t,l),r(l,n),r(n,o),r(o,s),r(s,h),r(o,c),r(o,u),r(u,f),r(o,m),_&&_.m(o,null),r(n,d),r(n,g),r(g,y),r(y,I),r(g,V),r(g,X),r(X,C),r(g,G),q&&q.m(g,null),r(t,P),w&&w.m(t,null),r(t,F),W&&W.m(t,null),r(t,B),r(t,N),Me(E,N,null),r(N,T),Me(D,N,null),r(N,K),Me(J,N,null),H=!0},p(k,M){var ce,j,ee,ge;(!H||M[0]&16)&&a!==(a=k[4].today+"")&&U(h,a),(!H||M[0]&4194304)&&U(f,k[22]),(ce=k[1])!=null&&ce.showCost?_?_.p(k,M):(_=kl(k),_.c(),_.m(o,null)):_&&(_.d(1),_=null),(!H||M[0]&262144)&&U(I,k[18]),(!H||M[0]&2097152)&&U(C,k[21]),(j=k[1])!=null&&j.showCost?q?q.p(k,M):(q=wl(k),q.c(),q.m(g,null)):q&&(q.d(1),q=null),(ee=k[1])!=null&&ee.showTokenBreakdown&&k[0]?w?(w.p(k,M),M[0]&3&&ne(w,1)):(w=yl(k),w.c(),ne(w,1),w.m(t,F)):w&&(vt(),_e(w,1,1,()=>{w=null}),bt()),(ge=k[1])!=null&&ge.showHeatmap&&k[0]?W?(W.p(k,M),M[0]&3&&ne(W,1)):(W=Tl(k),W.c(),ne(W,1),W.m(t,B)):W&&(vt(),_e(W,1,1,()=>{W=null}),bt());const $={};M[0]&16&&($.label=k[4].topModel),M[0]&131072&&($.value=k[17]),M[0]&65536&&($.sub=k[16]),E.$set($);const Q={};M[0]&16&&(Q.label=k[4].topTool),M[0]&32768&&(Q.value=k[15]),M[0]&16384&&(Q.sub=k[14]),D.$set(Q);const x={};M[0]&16&&(x.label=k[4].sessions),M[0]&8192&&(x.value=k[13]),J.$set(x)},i(k){H||(ne(w),ne(W),ne(E.$$.fragment,k),ne(D.$$.fragment,k),ne(J.$$.fragment,k),H=!0)},o(k){_e(w),_e(W),_e(E.$$.fragment,k),_e(D.$$.fragment,k),_e(J.$$.fragment,k),H=!1},d(k){k&&R(t),_&&_.d(),q&&q.d(),w&&w.d(),W&&W.d(),Le(E),Le(D),Le(J)}}}function dn(e){let t,l;return t=new un({props:{settings:e[1],exchangeRate:e[2]}}),t.$on("save",e[24]),t.$on("close",e[26]),{c(){Ee(t.$$.fragment)},m(n,o){Me(t,n,o),l=!0},p(n,o){const s={};o[0]&2&&(s.settings=n[1]),o[0]&4&&(s.exchangeRate=n[2]),t.$set(s)},i(n){l||(ne(t.$$.fragment,n),l=!0)},o(n){_e(t.$$.fragment,n),l=!1},d(n){Le(t,n)}}}function kl(e){let t,l;return{c(){t=v("span"),l=O(e[20]),i(t,"class","metric-cost svelte-1sj3khb")},m(n,o){A(n,t,o),r(t,l)},p(n,o){o[0]&1048576&&U(l,n[20])},d(n){n&&R(t)}}}function wl(e){let t,l;return{c(){t=v("span"),l=O(e[19]),i(t,"class","metric-cost svelte-1sj3khb")},m(n,o){A(n,t,o),r(t,l)},p(n,o){o[0]&524288&&U(l,n[19])},d(n){n&&R(t)}}}function yl(e){let t,l,n=e[4].tokenBreakdownToday+"",o,s,a,h;return a=new xl({props:{input:e[0].todayTokens.input,output:e[0].todayTokens.output,cacheRead:e[0].todayTokens.cacheRead,cacheWrite:e[0].todayTokens.cacheWrite,thinking:e[0].todayTokens.thinking}}),{c(){t=v("div"),l=v("div"),o=O(n),s=L(),Ee(a.$$.fragment),i(l,"class","section-title svelte-1sj3khb"),i(t,"class","section svelte-1sj3khb")},m(c,u){A(c,t,u),r(t,l),r(l,o),r(t,s),Me(a,t,null),h=!0},p(c,u){(!h||u[0]&16)&&n!==(n=c[4].tokenBreakdownToday+"")&&U(o,n);const f={};u[0]&1&&(f.input=c[0].todayTokens.input),u[0]&1&&(f.output=c[0].todayTokens.output),u[0]&1&&(f.cacheRead=c[0].todayTokens.cacheRead),u[0]&1&&(f.cacheWrite=c[0].todayTokens.cacheWrite),u[0]&1&&(f.thinking=c[0].todayTokens.thinking),a.$set(f)},i(c){h||(ne(a.$$.fragment,c),h=!0)},o(c){_e(a.$$.fragment,c),h=!1},d(c){c&&R(t),Le(a)}}}function Tl(e){var c;let t,l,n=e[4].trend+"",o,s,a,h;return a=new on({props:{data:e[0].dailyHistory,showCost:((c=e[1])==null?void 0:c.showCost)??!1,locale:e[5],currency:e[6],exchangeRate:e[2]}}),{c(){t=v("div"),l=v("div"),o=O(n),s=L(),Ee(a.$$.fragment),i(l,"class","section-title svelte-1sj3khb"),i(t,"class","section svelte-1sj3khb")},m(u,f){A(u,t,f),r(t,l),r(l,o),r(t,s),Me(a,t,null),h=!0},p(u,f){var d;(!h||f[0]&16)&&n!==(n=u[4].trend+"")&&U(o,n);const m={};f[0]&1&&(m.data=u[0].dailyHistory),f[0]&2&&(m.showCost=((d=u[1])==null?void 0:d.showCost)??!1),f[0]&32&&(m.locale=u[5]),f[0]&64&&(m.currency=u[6]),f[0]&4&&(m.exchangeRate=u[2]),a.$set(m)},i(u){h||(ne(a.$$.fragment,u),h=!0)},o(u){_e(a.$$.fragment,u),h=!1},d(u){u&&R(t),Le(a)}}}function gn(e){let t,l,n,o,s,a,h,c=e[3]&&vl(e);n=new Kl({props:{onRefresh:e[23],onClose:mn,onToggleSettings:e[25],refreshLabel:e[4].refresh,settingsLabel:e[4].settings,closeLabel:e[4].close,statusText:e[12]}});const u=[dn,hn],f=[];function m(d,g){return d[8]&&d[1]?0:1}return s=m(e),a=f[s]=u[s](e),{c(){t=v("div"),c&&c.c(),l=L(),Ee(n.$$.fragment),o=L(),a.c(),i(t,"class","panel svelte-1sj3khb"),z(t,"loading",e[7])},m(d,g){A(d,t,g),c&&c.m(t,null),r(t,l),Me(n,t,null),r(t,o),f[s].m(t,null),e[27](t),h=!0},p(d,g){d[3]?c?c.p(d,g):(c=vl(d),c.c(),c.m(t,l)):c&&(c.d(1),c=null);const y={};g[0]&256&&(y.onToggleSettings=d[25]),g[0]&16&&(y.refreshLabel=d[4].refresh),g[0]&16&&(y.settingsLabel=d[4].settings),g[0]&16&&(y.closeLabel=d[4].close),g[0]&4096&&(y.statusText=d[12]),n.$set(y);let I=s;s=m(d),s===I?f[s].p(d,g):(vt(),_e(f[I],1,1,()=>{f[I]=null}),bt(),a=f[s],a?a.p(d,g):(a=f[s]=u[s](d),a.c()),ne(a,1),a.m(t,null)),(!h||g[0]&128)&&z(t,"loading",d[7])},i(d){h||(ne(n.$$.fragment,d),ne(a),h=!0)},o(d){_e(n.$$.fragment,d),_e(a),h=!1},d(d){d&&R(t),c&&c.d(),Le(n),f[s].d(),e[27](null)}}}function _n(){return typeof navigator<"u"&&navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}function Cl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function mn(){window.widget.hideWindow()}function pn(e,t,l){let n,o,s,a,h,c,u,f,m,d,g,y,I,V,X,C=null,G=null,P=null,F=_n(),B=!0,N=!1,E,T=0,D=null,K=null;function J(k){return o.lastNDays(k)}function H(k){const M=new Date(k),$=String(M.getHours()).padStart(2,"0"),Q=String(M.getMinutes()).padStart(2,"0");return o.syncedAt(`${$}:${Q}`)}async function _(){l(7,B=!0),l(0,C=await window.widget.getData()),l(7,B=!1)}async function q(){l(1,G=await window.widget.getSettings())}async function w(){l(2,P=await window.widget.getExchangeRate())}async function W(k){l(1,G=await window.widget.saveSettings(k.detail)),_()}function me(){if(!E)return;const k=Math.ceil(E.getBoundingClientRect().height);k<=0||Math.abs(k-T)<2||(T=k,window.widget.resizeWindow(k))}Ml(()=>{_(),q(),w(),window.widget.onDataUpdate(M=>{l(0,C=M),l(7,B=!1)}),window.widget.onInstallStatus(M=>{l(3,D=M.phase),l(10,K=M.error??null),(M.phase==="done"||M.phase==="failed")&&setTimeout(()=>{l(3,D=null),l(10,K=null)},3e3)});const k=new ResizeObserver(()=>me());return k.observe(E),Rt().then(me),()=>k.disconnect()}),Il(()=>{Rt().then(me)});const we=()=>{l(8,N=!N)},S=()=>{l(8,N=!1)};function le(k){_t[k?"unshift":"push"](()=>{E=k,l(9,E)})}return e.$$.update=()=>{var k;e.$$.dirty[0]&2&&l(5,n=(G==null?void 0:G.locale)??F),e.$$.dirty[0]&32&&l(4,o=Fl(n)),e.$$.dirty[0]&2&&l(6,s=(G==null?void 0:G.currency)??"USD"),e.$$.dirty[0]&1&&l(22,a=C?Cl(C.todayTokens.total):"--"),e.$$.dirty[0]&1&&l(21,h=C?Cl(C.rangeTokens.total):"--"),e.$$.dirty[0]&101&&l(20,c=C?kt(C.todayCost,s,n,P):"--"),e.$$.dirty[0]&101&&l(19,u=C?kt(C.rangeCost,s,n,P):"--"),e.$$.dirty[0]&17&&l(18,f=C?J(C.rangeDays):o.lastNDays(30)),e.$$.dirty[0]&1&&l(17,m=C!=null&&C.topModel?C.topModel.name:"--"),e.$$.dirty[0]&1&&l(16,d=C!=null&&C.topModel?`${C.topModel.share}%`:""),e.$$.dirty[0]&1&&l(15,g=((k=C==null?void 0:C.topTool)==null?void 0:k.name)??"--"),e.$$.dirty[0]&1&&l(14,y=C!=null&&C.topTool?`${C.topTool.share}%`:""),e.$$.dirty[0]&1&&l(13,I=C?String(C.sessionCountToday):"--"),e.$$.dirty[0]&1&&l(12,V=C?H(C.lastUpdated):""),e.$$.dirty[0]&24&&l(11,X=D==="installing"?o.installInstalling:D==="launching"?o.installLaunching:D==="done"?o.installDone:D==="failed"?o.installFailed:o.installPreparing)},[C,G,P,D,o,n,s,B,N,E,K,X,V,I,y,g,d,m,f,u,c,h,a,_,W,we,S,le]}class vn extends Ye{constructor(t){super(),Ke(this,t,pn,gn,Ge,{},null,[-1,-1])}}new vn({target:document.getElementById("app")});
|