var se=Object.defineProperty;var ie=(e,t,n)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var z=(e,t,n)=>ie(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const f of s.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&o(f)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function w(){}function re(e){return e()}function X(){return Object.create(null)}function T(e){e.forEach(re)}function R(e){return typeof e=="function"}function Y(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function le(e){return Object.keys(e).length===0}function d(e,t){e.appendChild(t)}function I(e,t,n){e.insertBefore(t,n||null)}function M(e){e.parentNode&&e.parentNode.removeChild(e)}function g(e){return document.createElement(e)}function F(e){return document.createTextNode(e)}function _(){return F(" ")}function K(e,t,n,o){return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)}function p(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function fe(e){return Array.from(e.childNodes)}function U(e,t){t=""+t,e.data!==t&&(e.data=t)}function Z(e,t,n){e.classList.toggle(t,!!n)}let L;function x(e){L=e}function ce(){if(!L)throw new Error("Function called outside component initialization");return L}function ue(e){ce().$$.on_mount.push(e)}const $=[],ee=[];let k=[];const te=[],ae=Promise.resolve();let V=!1;function de(){V||(V=!0,ae.then(oe))}function W(e){k.push(e)}const B=new Set;let v=0;function oe(){if(v!==0)return;const e=L;do{try{for(;v<$.length;){const t=$[v];v++,x(t),he(t.$$)}}catch(t){throw $.length=0,v=0,t}for(x(null),$.length=0,v=0;ee.length;)ee.pop()();for(let t=0;t<k.length;t+=1){const n=k[t];B.has(n)||(B.add(n),n())}k.length=0}while($.length);for(;te.length;)te.pop()();V=!1,B.clear(),x(e)}function he(e){if(e.fragment!==null){e.update(),T(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(W)}}function pe(e){const t=[],n=[];k.forEach(o=>e.indexOf(o)===-1?t.push(o):n.push(o)),n.forEach(o=>o()),k=t}const P=new Set;let ge;function O(e,t){e&&e.i&&(P.delete(e),e.i(t))}function N(e,t,n,o){if(e&&e.o){if(P.has(e))return;P.add(e),ge.c.push(()=>{P.delete(e)}),e.o(t)}}function A(e){e&&e.c()}function E(e,t,n){const{fragment:o,after_update:r}=e.$$;o&&o.m(t,n),W(()=>{const s=e.$$.on_mount.map(re).filter(R);e.$$.on_destroy?e.$$.on_destroy.push(...s):T(s),e.$$.on_mount=[]}),r.forEach(W)}function C(e,t){const n=e.$$;n.fragment!==null&&(pe(n.after_update),T(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function me(e,t){e.$$.dirty[0]===-1&&($.push(e),de(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function G(e,t,n,o,r,s,f=null,h=[-1]){const l=L;x(e);const i=e.$$={fragment:null,ctx:[],props:s,update:w,not_equal:r,bound:X(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:X(),dirty:h,skip_bound:!1,root:t.target||l.$$.root};f&&f(i.root);let u=!1;if(i.ctx=n?n(e,t.props||{},(c,m,...b)=>{const S=b.length?b[0]:m;return i.ctx&&r(i.ctx[c],i.ctx[c]=S)&&(!i.skip_bound&&i.bound[c]&&i.bound[c](S),u&&me(e,c)),m}):[],i.update(),u=!0,T(i.before_update),i.fragment=o?o(i.ctx):!1,t.target){if(t.hydrate){const c=fe(t.target);i.fragment&&i.fragment.l(c),c.forEach(M)}else i.fragment&&i.fragment.c();t.intro&&O(e.$$.fragment),E(e,t.target,t.anchor),oe()}x(l)}class J{constructor(){z(this,"$$");z(this,"$$set")}$destroy(){C(this,1),this.$destroy=w}$on(t,n){if(!R(n))return w;const o=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return o.push(n),()=>{const r=o.indexOf(n);r!==-1&&o.splice(r,1)}}$set(t){this.$$set&&!le(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const ye="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ye);function _e(e){let t,n,o,r,s,f,h,l,i;return{c(){t=g("div"),n=g("span"),n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 64 64" style="display:block;border-radius:4px"><rect width="64" height="64" rx="14" fill="#0d9488"></rect><rect x="10" y="38" width="12" height="16" rx="3" fill="white"></rect><rect x="26" y="26" width="12" height="28" rx="3" fill="white"></rect><rect x="42" y="14" width="12" height="40" rx="3" fill="white"></rect></svg>
    aiusage`,o=_(),r=g("div"),s=g("button"),s.textContent="↻",f=_(),h=g("button"),h.textContent="✕",p(n,"class","logo svelte-soepgf"),p(s,"class","icon-btn svelte-soepgf"),p(s,"title","Refresh"),p(h,"class","icon-btn svelte-soepgf"),p(h,"title","Close"),p(r,"class","actions svelte-soepgf"),p(t,"class","header svelte-soepgf")},m(u,c){I(u,t,c),d(t,n),d(t,o),d(t,r),d(r,s),d(r,f),d(r,h),l||(i=[K(s,"click",function(){R(e[0])&&e[0].apply(this,arguments)}),K(h,"click",function(){R(e[1])&&e[1].apply(this,arguments)})],l=!0)},p(u,[c]){e=u},i:w,o:w,d(u){u&&M(t),l=!1,T(i)}}}function we(e,t,n){let{onRefresh:o}=t,{onClose:r}=t;return e.$$set=s=>{"onRefresh"in s&&n(0,o=s.onRefresh),"onClose"in s&&n(1,r=s.onClose)},[o,r]}class be extends J{constructor(t){super(),G(this,t,we,_e,Y,{onRefresh:0,onClose:1})}}function ne(e){let t,n;return{c(){t=g("span"),n=F(e[2]),p(t,"class","secondary svelte-savwyt")},m(o,r){I(o,t,r),d(t,n)},p(o,r){r&4&&U(n,o[2])},d(o){o&&M(t)}}}function ve(e){let t,n,o,r,s,f,h,l,i=e[2]&&ne(e);return{c(){t=g("div"),n=g("div"),o=F(e[0]),r=_(),s=g("div"),f=g("span"),h=F(e[1]),l=_(),i&&i.c(),p(n,"class","section-label svelte-savwyt"),p(f,"class","primary svelte-savwyt"),p(s,"class","values svelte-savwyt"),p(t,"class","section svelte-savwyt")},m(u,c){I(u,t,c),d(t,n),d(n,o),d(t,r),d(t,s),d(s,f),d(f,h),d(s,l),i&&i.m(s,null)},p(u,[c]){c&1&&U(o,u[0]),c&2&&U(h,u[1]),u[2]?i?i.p(u,c):(i=ne(u),i.c(),i.m(s,null)):i&&(i.d(1),i=null)},i:w,o:w,d(u){u&&M(t),i&&i.d()}}}function $e(e,t,n){let{label:o}=t,{primary:r}=t,{secondary:s=""}=t;return e.$$set=f=>{"label"in f&&n(0,o=f.label),"primary"in f&&n(1,r=f.primary),"secondary"in f&&n(2,s=f.secondary)},[o,r,s]}class H extends J{constructor(t){super(),G(this,t,$e,ve,Y,{label:0,primary:1,secondary:2})}}function ke(e){let t,n,o,r,s,f,h,l,i,u,c,m,b,S;return n=new be({props:{onRefresh:e[6],onClose:Se}}),r=new H({props:{label:"TODAY",primary:e[5],secondary:e[4]}}),f=new H({props:{label:"THIS MONTH",primary:e[3]}}),l=new H({props:{label:"TOP MODEL",primary:e[2],secondary:e[1]}}),{c(){t=g("div"),A(n.$$.fragment),o=_(),A(r.$$.fragment),s=_(),A(f.$$.fragment),h=_(),A(l.$$.fragment),i=_(),u=g("div"),c=g("button"),c.textContent="Open Full Dashboard →",p(c,"class","open-btn svelte-z2p4qk"),p(u,"class","footer svelte-z2p4qk"),p(t,"class","panel svelte-z2p4qk"),Z(t,"loading",e[0])},m(a,y){I(a,t,y),E(n,t,null),d(t,o),E(r,t,null),d(t,s),E(f,t,null),d(t,h),E(l,t,null),d(t,i),d(t,u),d(u,c),m=!0,b||(S=K(c,"click",Oe),b=!0)},p(a,[y]){const j={};y&32&&(j.primary=a[5]),y&16&&(j.secondary=a[4]),r.$set(j);const Q={};y&8&&(Q.primary=a[3]),f.$set(Q);const q={};y&4&&(q.primary=a[2]),y&2&&(q.secondary=a[1]),l.$set(q),(!m||y&1)&&Z(t,"loading",a[0])},i(a){m||(O(n.$$.fragment,a),O(r.$$.fragment,a),O(f.$$.fragment,a),O(l.$$.fragment,a),m=!0)},o(a){N(n.$$.fragment,a),N(r.$$.fragment,a),N(f.$$.fragment,a),N(l.$$.fragment,a),m=!1},d(a){a&&M(t),C(n),C(r),C(f),C(l),b=!1,S()}}}function D(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Se(){window.widget.hideWindow()}async function Oe(){await window.widget.openDashboard()}function Ee(e,t,n){let o,r,s,f,h,l=null,i=!0;async function u(){n(0,i=!0),n(7,l=await window.widget.getData()),n(0,i=!1)}return ue(()=>{u(),window.widget.onDataUpdate(c=>{n(7,l=c),n(0,i=!1)})}),e.$$.update=()=>{var c;e.$$.dirty&128&&n(5,o=l?D(l.todayTokens.total):"—"),e.$$.dirty&128&&n(4,r=l?`↑${D(l.todayTokens.input)}  ↓${D(l.todayTokens.output)}`:""),e.$$.dirty&128&&n(3,s=l?D(l.monthTokens.total):"—"),e.$$.dirty&128&&n(2,f=((c=l==null?void 0:l.topModel)==null?void 0:c.name)??"—"),e.$$.dirty&128&&n(1,h=l!=null&&l.topModel?`${l.topModel.share}%`:"")},[i,h,f,s,r,o,u,l]}class Ce extends J{constructor(t){super(),G(this,t,Ee,ke,Y,{})}}new Ce({target:document.getElementById("app")});
