@aidotnet/server-linux-arm64 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/ClientsPage-CwrpIsjp.js +11 -0
  3. package/bin/wwwroot/assets/ModelDetailPage-CDrpIJ2a.js +1 -0
  4. package/bin/wwwroot/assets/ModelsPage-C0SIEL78.js +1 -0
  5. package/bin/wwwroot/assets/Page-D9s9brqr.js +3 -0
  6. package/bin/wwwroot/assets/PluginsPage-CU6HnW-3.js +2 -0
  7. package/bin/wwwroot/assets/PrivacyPage-B_Gvd1LU.js +1 -0
  8. package/bin/wwwroot/assets/ProviderDetailPage-VHzmmtBT.js +3 -0
  9. package/bin/wwwroot/assets/ProvidersPage-Dj_CsU72.js +2 -0
  10. package/bin/wwwroot/assets/SettingsPage-BKlK87nl.js +1 -0
  11. package/bin/wwwroot/assets/TokensPage-RhLk-cLA.js +1 -0
  12. package/bin/wwwroot/assets/TrayPanelPage-glZe4Vli.js +1 -0
  13. package/bin/wwwroot/assets/TrayPanelView-BPGmNn0R.js +1 -0
  14. package/bin/wwwroot/assets/arrow-down-dwUtKoOn.js +1 -0
  15. package/bin/wwwroot/assets/arrow-up-DFb4XkB6.js +1 -0
  16. package/bin/wwwroot/assets/checkbox-w2_7QuDk.js +1 -0
  17. package/bin/wwwroot/assets/cloud-download-C1VSdmBb.js +1 -0
  18. package/bin/wwwroot/assets/confirm-morph-B9k3rCnO.js +1 -0
  19. package/bin/wwwroot/assets/download-DoTXPUWy.js +1 -0
  20. package/bin/wwwroot/assets/ellipsis-B2d4aPpF.js +1 -0
  21. package/bin/wwwroot/assets/external-link-DhHaJlE-.js +1 -0
  22. package/bin/wwwroot/assets/folder-open-DC0j6uC-.js +1 -0
  23. package/bin/wwwroot/assets/index-br322rzz.js +15 -0
  24. package/bin/wwwroot/assets/log-out-CtwqdEhG.js +1 -0
  25. package/bin/wwwroot/assets/{format-CkDcAs-_.js → overlays-CnzrFKmb.js} +16 -16
  26. package/bin/wwwroot/assets/pencil-nlLBeib5.js +1 -0
  27. package/bin/wwwroot/assets/power-DQiCs26X.js +1 -0
  28. package/bin/wwwroot/assets/radio-cards-Byb8E5K7.js +1 -0
  29. package/bin/wwwroot/assets/rotate-ccw-BLaDyhPe.js +1 -0
  30. package/bin/wwwroot/assets/use-transform-C8au3Jv4.js +1 -0
  31. package/bin/wwwroot/index.html +6 -6
  32. package/package.json +1 -1
  33. package/bin/wwwroot/assets/ClientsPage-CcTgjJ-D.js +0 -11
  34. package/bin/wwwroot/assets/ModelDetailPage-B9205fOF.js +0 -1
  35. package/bin/wwwroot/assets/ModelsPage-CAXCnMox.js +0 -1
  36. package/bin/wwwroot/assets/Page-iMwsVZGv.js +0 -3
  37. package/bin/wwwroot/assets/PluginsPage-1htR9MlO.js +0 -2
  38. package/bin/wwwroot/assets/PrivacyPage-DDrC7ZN2.js +0 -1
  39. package/bin/wwwroot/assets/ProviderDetailPage-BrLQ3wxI.js +0 -3
  40. package/bin/wwwroot/assets/ProvidersPage-DEwFPi0w.js +0 -2
  41. package/bin/wwwroot/assets/SettingsPage-vDXq5KMg.js +0 -1
  42. package/bin/wwwroot/assets/TokensPage-nnTsXi1X.js +0 -1
  43. package/bin/wwwroot/assets/TrayPanelPage-BLLZAck0.js +0 -1
  44. package/bin/wwwroot/assets/arrow-down-Bgpt1Ug2.js +0 -1
  45. package/bin/wwwroot/assets/arrow-up-DqX0vZ8v.js +0 -1
  46. package/bin/wwwroot/assets/checkbox-BQx1e8t-.js +0 -1
  47. package/bin/wwwroot/assets/cloud-download-B-iX6FzV.js +0 -1
  48. package/bin/wwwroot/assets/confirm-morph-C93BpFKZ.js +0 -1
  49. package/bin/wwwroot/assets/download-Bbci4NYa.js +0 -1
  50. package/bin/wwwroot/assets/ellipsis-O3neUtss.js +0 -1
  51. package/bin/wwwroot/assets/external-link-BotneeB5.js +0 -1
  52. package/bin/wwwroot/assets/folder-open-BReAI4XO.js +0 -1
  53. package/bin/wwwroot/assets/index-C6Mqffdm.js +0 -15
  54. package/bin/wwwroot/assets/log-out-BSESm3Q8.js +0 -1
  55. package/bin/wwwroot/assets/pencil-C5urmout.js +0 -1
  56. package/bin/wwwroot/assets/power-rKYGhi1K.js +0 -1
  57. package/bin/wwwroot/assets/quota-fdOyhiov.js +0 -1
  58. package/bin/wwwroot/assets/radio-cards-CKDDH2FI.js +0 -1
  59. package/bin/wwwroot/assets/rotate-ccw-CJ2l4No1.js +0 -1
  60. package/bin/wwwroot/assets/use-transform-CJhlgN8s.js +0 -1
  61. package/bin/wwwroot/assets/useTrayData-CUUZrKRf.js +0 -1
  62. /package/bin/wwwroot/assets/{format-Cnf3vGpI.css → overlays-Cnf3vGpI.css} +0 -0
@@ -1 +0,0 @@
1
- import{Ot as e}from"./format-CkDcAs-_.js";var t={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +0,0 @@
1
- import{Ot as e}from"./format-CkDcAs-_.js";var t={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +0,0 @@
1
- import{Ot as e}from"./format-CkDcAs-_.js";var t={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +0,0 @@
1
- import{c as e,d as t}from"./format-CkDcAs-_.js";import{C as n,S as r,x as i}from"./index-C6Mqffdm.js";function a(e){return Math.max(0,Math.round(e.requests*(1-e.successRate)))}function o(e){return!Number.isFinite(e)||e<=0?`$0`:e<.01?`$<0.01`:e<1e3?`$${e.toFixed(2)}`:t(e,{compact:!0})}function s(e,t=new Date){return r(i(e,`requests`),n(`today`,t))}var c=e=>String(e).padStart(2,`0`);function l(e,t=new Date){let n=new Date(t.getFullYear(),t.getMonth(),t.getDate()-1),r=`${n.getFullYear()}-${c(n.getMonth()+1)}-${c(n.getDate())}`;return e.filter(e=>e.bucket===r).reduce((e,t)=>e+t.tokens,0)}function u(e,t){return t<=0?null:(e-t)/t}function d(e,t){let n=[...e].sort((e,t)=>t.tokens-e.tokens)[0];return!n||n.tokens<=0?null:{model:n.model,share:t>0?Math.min(1,n.tokens/t):1}}var f={session:300,weekly:10080};function p(e){return e==null||!Number.isFinite(e)?null:Math.min(100,Math.max(0,100-e))}function m(e,t){let n=p(t?.usedPercent);return n===null?null:{kind:e,windowMinutes:t?.windowMinutes??f[e],remaining:n,resetsAt:t?.resetsAtUtc??null}}function h(e){let t=[];for(let{provider:n,account:r}of e){if(r.status!==`active`||!r.quota)continue;let e=r.quota,i=[m(`session`,e.session),m(`weekly`,e.weekly)].filter(e=>e!==null),a=p(e.credits?.usedPercent);a!==null&&i.push({kind:`credits`,windowMinutes:null,remaining:a,resetsAt:null}),i.length!==0&&t.push({accountId:r.id,providerId:n.id,providerName:e.planLabel||n.name,providerIcon:n.icon??null,accountName:r.displayName||r.accountEmail||r.id,rows:i})}return t}function g(e){let t=[];for(let n of e){if(!n.enabled||!P(n)||n.quota?.isValid===!1)continue;let e=[];for(let t of n.quota?.plans??[]){let n=O(t);D(t)?e.push({kind:`window`,windowMinutes:t.windowMinutes??null,remaining:100-(n??0),resetsAt:t.resetsAtUtc??null}):(t.remaining!=null||n!=null)&&e.push({kind:`balance`,windowMinutes:null,remaining:n==null?null:100-n,resetsAt:t.resetsAtUtc??null,amount:t.remaining==null?null:{value:t.remaining,unit:t.unit??null},label:t.name??null})}e.length!==0&&t.push({accountId:`provider:${n.id}`,providerId:n.id,providerName:n.name,providerIcon:n.icon??null,accountName:``,rows:e})}return t}function _(e){let t=null;for(let n of e)for(let e of n.rows)e.remaining!==null&&(!t||e.remaining<t.row.remaining)&&(t={plan:n,row:{...e,remaining:e.remaining}});return t}function v(e,t){let n=[];for(let t of e)for(let e of t.rows)e.remaining!==null&&n.push({plan:t,row:{...e,remaining:e.remaining}});return n.sort((e,t)=>e.row.remaining-t.row.remaining).slice(0,t)}function y(e){return e<10?`red`:e<30?`orange`:`green`}function b(e,t){let n=(e,n)=>new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{style:`unit`,unit:n,unitDisplay:t===`zh`?`long`:`narrow`}).format(e);return e>=1440&&e%1440==0?n(e/1440,`day`):e>=60?n(Math.round(e/60),`hour`):n(e,`minute`)}function x(e,t,n=Date.now()){if(!e)return null;let r=new Date(e).getTime()-n;if(!Number.isFinite(r)||r<=0)return null;let i=new Intl.RelativeTimeFormat(t===`zh`?`zh-CN`:`en-US`,{numeric:`auto`}),a=r/36e5;return a>=48?i.format(Math.round(a/24),`day`):a>=1?i.format(Math.round(a),`hour`):i.format(Math.max(1,Math.round(r/6e4)),`minute`)}function S(e,t,n,r=Date.now()){if(!e)return null;let i=Math.max(0,(r-e)/1e3),a=new Intl.RelativeTimeFormat(t===`zh`?`zh-CN`:`en-US`,{numeric:`auto`});return i<60?n:i<3600?a.format(-Math.round(i/60),`minute`):a.format(-Math.round(i/3600),`hour`)}function C(t,n,r){let i={title:``,detail:``};if(t===`none`)return i;if(t===`alerts`){if(!n.running)return{title:`!`,detail:r.stopped};let e=n.summary?a(n.summary):0;if(e>0)return{title:`⚠ ${e}`,detail:r.failures(e)};let t=_(n.plans);if(t&&t.row.remaining<10){let e=`${Math.round(t.row.remaining)}%`;return{title:`⚠ ${e}`,detail:r.quota(t.plan.providerName,r.windowName(t.row),e)}}return i}if(t===`quota`){let e=_(n.plans);if(!e)return i;let t=`${Math.round(e.row.remaining)}%`;return{title:t,detail:r.quota(e.plan.providerName,r.windowName(e.row),t)}}let s=n.summary;if(!s||!n.running)return i;switch(t){case`requests`:{let t=e(s.requests,!0);return{title:t,detail:r.requests(t)}}case`tokens`:{let t=e(s.inputTokens+s.outputTokens,!0);return{title:t,detail:r.tokens(t)}}case`cost`:{let e=o(s.costUsd);return{title:e,detail:r.cost(e)}}}}var w={config:`providers.quota.error.config`,no_key:`providers.quota.error.no_key`,unauthorized:`providers.quota.error.unauthorized`,no_endpoint:`providers.quota.error.no_endpoint`,rate_limited:`providers.quota.error.rate_limited`,upstream:`providers.quota.error.upstream`,timeout:`providers.quota.error.timeout`,network:`providers.quota.error.network`,not_json:`providers.quota.error.not_json`,too_large:`providers.quota.error.too_large`,empty:`providers.quota.error.empty`},T=/^[A-Z]{3}$/;function E(e,t,n){let r=n===`zh`?`zh-CN`:`en-US`;if(t&&T.test(t))try{let n=e!==0&&Math.abs(e)<1;return new Intl.NumberFormat(r,{style:`currency`,currency:t,minimumFractionDigits:2,maximumFractionDigits:n?4:2}).format(e)}catch{}let i=new Intl.NumberFormat(r,{maximumFractionDigits:2}).format(e);return t?`${i} ${t}`:i}var D=e=>e.windowMinutes!=null&&e.usedPercent!=null;function O(e){return e.usedPercent!=null&&Number.isFinite(e.usedPercent)?Math.min(100,Math.max(0,e.usedPercent)):e.used!=null&&e.total!=null&&e.total>0?Math.min(100,Math.max(0,e.used/e.total*100)):null}function k(e){return!e?.error||e.fetchedAtUtc&&e.errorAtUtc&&new Date(e.errorAtUtc).getTime()<new Date(e.fetchedAtUtc).getTime()?null:{code:e.errorCode??null,message:e.error}}function A(e,t){return e.code?t(w[e.code]):e.message}function j(e,t,n){let r=O(e);if(D(e))return t(`providers.quota.window`,{window:b(e.windowMinutes,n),percent:Math.round(r??0)});if(e.remaining!=null){let i=t(`providers.quota.balance`,{amount:E(e.remaining,e.unit,n)});return r==null?i:`${i} · ${t(`providers.quota.usedPercent`,{percent:Math.round(r)})}`}return r==null?e.used!=null&&e.total!=null?t(`providers.quota.totalUsed`,{used:E(e.used,e.unit,n),total:E(e.total,e.unit,n)}):null:t(`providers.quota.usedPercent`,{percent:Math.round(r)})}function M(e,t,n){let r=x(e.resetsAtUtc??null,n);return r?t(`providers.quota.resets`,{time:r}):null}function N(e,t,n){let r=(e?.plans??[]).map(e=>j(e,t,n)).filter(e=>!!e);return e?.isValid===!1&&r.unshift(t(`providers.quota.invalid`)),r.length?r.join(` · `):null}var P=e=>e.authScheme!==`oauth-subscription`&&!!e.quotaConfig?.enabled;export{l as S,v as _,P as a,S as b,u as c,s as d,g as f,_ as g,x as h,M as i,a as l,y as m,E as n,k as o,h as p,j as r,N as s,A as t,o as u,d as v,b as x,C as y};
@@ -1 +0,0 @@
1
- import{Ci as e,Si as t,ha as n,ma as r,va as i,wi as a,xi as o,yt as s}from"./format-CkDcAs-_.js";var c=i(n(),1),l={root:`_root_1erkf_1`,ring:`_ring_1erkf_16`,card:`_card_1erkf_26`,label:`_label_1erkf_46`,meta:`_meta_1erkf_46`,indicator:`_indicator_1erkf_48`,indicatorDot:`_indicatorDot_1erkf_61`,body:`_body_1erkf_64`,labelText:`_labelText_1erkf_66`,icon:`_icon_1erkf_67`,description:`_description_1erkf_70`},u=r(),d=[...s.ease.standard],f=((e,t)=>{let n=2*Math.PI/(e*1.2);return{type:`spring`,stiffness:n*n,damping:2*(1-t)*n,mass:1}})(.42,.14),p=()=>()=>{};function m(){let t=(0,c.useSyncExternalStore)(p,()=>!0,()=>!1);return!!e()&&t}var h=(0,c.forwardRef)(function({options:e,value:n,defaultValue:r=null,onValueChange:i,layout:p=`grid`,minColumnWidth:h=180,name:g,required:_,disabled:v=!1,className:y,style:b,...x},S){let C=m(),w=(0,c.useId)().replace(/[^a-zA-Z0-9_-]/g,``),T=(0,c.useRef)(null);(0,c.useImperativeHandle)(S,()=>T.current);let[E,D]=(0,c.useState)(r),O=n===void 0?E:n,k=e.findIndex(e=>e.value===O),A=e=>!v&&!e.disabled,j=k>=0&&A(e[k])?k:e.findIndex(A),M=e=>{e!==O&&(n===void 0&&D(e),i?.(e))},N=a(0),P=a(0),F=a(0),I=a(0),L=a(0),R=(0,c.useRef)(!1),z=(0,c.useCallback)(e=>{let n=k<0?null:T.current?.querySelector(`[data-card="${k}"]`);if(!n){L.set(0),R.current=!1;return}let r=[n.offsetLeft,n.offsetTop,n.offsetWidth,n.offsetHeight];if(!e||!R.current||C){N.jump(r[0]),P.jump(r[1]),F.jump(r[2]),I.jump(r[3]),!R.current&&!C&&e?(L.jump(0),t(L,1,{duration:s.duration.fast,ease:d})):L.jump(1),R.current=!0;return}t(N,r[0],f),t(P,r[1],f),t(F,r[2],f),t(I,r[3],f),L.set(1)},[I,L,C,k,F,N,P]),B=(0,c.useRef)(z);(0,c.useLayoutEffect)(()=>{B.current=z,z(!0)},[z]),(0,c.useLayoutEffect)(()=>{let e=T.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>B.current(!1));return t.observe(e),()=>t.disconnect()},[]);let V=()=>Array.from(T.current?.querySelectorAll(`[data-card]`)??[]),H=(t,n)=>{let r=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(t.key===` `||t.key===`Enter`){t.preventDefault(),A(e[n])&&M(e[n].value);return}if(!r&&t.key!==`Home`&&t.key!==`End`)return;t.preventDefault();let i=e.length,a=r&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)&&getComputedStyle(t.currentTarget).direction===`rtl`?-1:1,o=t.key===`Home`?-1:t.key===`End`?i:n,s=t.key===`Home`?1:t.key===`End`?-1:r*a;for(let t=0;t<i;t++)if(o=(o+s+i)%i,A(e[o])){V()[o]?.focus(),M(e[o].value);return}};return(0,u.jsxs)(`div`,{ref:T,role:`radiogroup`,"aria-disabled":v||void 0,"aria-required":_||void 0,className:[l.root,y].filter(Boolean).join(` `),"data-layout":p,style:{"--min-column":`${h}px`,...b},...x,children:[(0,u.jsx)(o.span,{className:l.ring,style:{x:N,y:P,width:F,height:I,opacity:L},"aria-hidden":`true`}),e.map((e,t)=>{let n=t===k,r=!A(e),i=`${w}-${t}-label`,a=`${w}-${t}-description`,c=r&&e.disabledReason?e.disabledReason:e.description;return(0,u.jsxs)(`div`,{role:`radio`,"data-card":t,className:l.card,"aria-checked":n,"aria-disabled":r||void 0,"aria-labelledby":i,"aria-describedby":c?a:void 0,tabIndex:t===j?0:-1,"data-checked":n||void 0,onClick:()=>{r||M(e.value)},onKeyDown:e=>H(e,t),children:[(0,u.jsx)(`span`,{className:l.indicator,"aria-hidden":`true`,children:(0,u.jsx)(o.span,{className:l.indicatorDot,initial:!1,animate:{scale:+!!n},transition:C?{duration:0}:s.spring.snappy})}),(0,u.jsxs)(`span`,{className:l.body,children:[(0,u.jsxs)(`span`,{id:i,className:l.label,children:[e.icon&&(0,u.jsx)(`span`,{className:l.icon,children:e.icon}),(0,u.jsx)(`span`,{className:l.labelText,children:e.label})]}),c&&(0,u.jsx)(`span`,{id:a,className:l.description,children:c})]}),e.meta&&(0,u.jsx)(`span`,{className:l.meta,children:e.meta})]},e.value)}),g&&(0,u.jsx)(`input`,{type:`hidden`,name:g,value:O??``,required:_})]})});export{h as t};
@@ -1 +0,0 @@
1
- import{Ot as e}from"./format-CkDcAs-_.js";var t={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +0,0 @@
1
- import{Fi as e,Ii as t,Li as n,Mi as r,Ni as i,Pi as a,wi as o}from"./format-CkDcAs-_.js";function s(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],a=e[1+n],o=e[2+n],s=e[3+n],c=i(a,o,s);return t?c(r):c}function c(n,r){let i=o(r()),s=()=>i.set(r());return s(),t(()=>{let t=()=>e.preRender(s,!1,!0),r=n.map(e=>e.on(`change`,t));return()=>{r.forEach(e=>e()),a(s)}}),i}function l(e){r.current=[],e();let t=c(r.current,e);return r.current=void 0,t}function u(e,t,n,r){if(typeof e==`function`)return l(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return f(e,t,n,r);let i=typeof t==`function`?t:s(t,n,r),a=Array.isArray(e)?d(e,i):d([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;if(o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1){let e=r?.ease;a.accelerate={...o,times:[0,...t,1],keyframes:[n[0],...n,n[n.length-1]],isTransformed:!0,...e?{ease:Array.isArray(e)?[e[0],...e]:e}:{}}}return a}function d(e,t){let r=n(()=>[]);return c(e,()=>{r.length=0;let n=e.length;for(let t=0;t<n;t++)r[t]=e[t].get();return t(r)})}function f(e,t,r,i){let a=n(()=>Object.keys(r)),o=n(()=>({}));for(let n of a)o[n]=u(e,t,r[n],i);return o}export{u as t};
@@ -1 +0,0 @@
1
- import{Bi as e,Gi as t,Gt as n,Hi as r,Ki as i,On as a,Ot as o,Qi as s,Ri as c,St as l,Ui as u,Ut as d,Vi as f,Vt as p,Wi as m,Yi as h,bt as g,c as _,ca as v,di as y,ea as b,ft as x,ha as S,li as C,ma as w,mi as T,o as E,oa as D,pa as O,qi as ee,tt as te,ua as ne,va as re,wt as ie,xt as k,zi as A}from"./format-CkDcAs-_.js";import{t as ae}from"./ellipsis-O3neUtss.js";import{t as oe}from"./rotate-ccw-CJ2l4No1.js";import{E as se,O as j,f as ce,l as le,m as M,u as ue}from"./index-C6Mqffdm.js";import{S as de,_ as fe,b as pe,c as me,d as he,f as ge,g as _e,h as ve,l as ye,m as be,n as xe,p as Se,u as Ce,v as we,x as Te}from"./quota-fdOyhiov.js";function N(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var Ee=class extends b{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,s.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ne(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(N(e,n).forEach(e=>{e.destroy()}),N(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=v(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new h(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&s.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},P=re(S(),1);function De({queries:n,...a},o){let c=O(o),l=ee(),d=i(),p=a.subscribed!==!1,g=P.useMemo(()=>n.map(e=>{let t=c.defaultQueryOptions(e);return t._optimisticResults=l?`isRestoring`:p?`optimistic`:void 0,t}),[n,c,l,p]);g.forEach(t=>{e(t);let n=c.getQueryCache().get(t.queryHash);u(t,d,n)}),t(d);let[_]=P.useState(()=>new Ee(c,g,a)),[v,y,b]=_.getOptimisticResult(g,a.combine),x=!l&&p;P.useSyncExternalStore(P.useCallback(e=>x?_.subscribe(s.batchCalls(e)):D,[_,x]),()=>_.getCurrentResult(),()=>_.getCurrentResult()),P.useEffect(()=>{_.setQueries(g,a)},[g,a,_]);let S=v.some((e,t)=>r(g[t],e))?v.flatMap((e,t)=>{let n=g[t];if(n&&r(n,e)){let e=new h(c,n);return f(n,e,d)}return[]}):[];if(S.length>0)throw Promise.all(S);let C=v.find((e,t)=>{let n=g[t];return n&&m({result:e,errorResetBoundary:d,throwOnError:n.throwOnError,query:c.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(C)throw C.error;return y(b())}var F={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};F.node;var Oe=o(F),I={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};I.node;var L=o(I),R={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};R.node;var ke=o(R),z={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};z.node;var Ae=o(z),B={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};B.node;var V=o(B),H=w(),je={green:`var(--success)`,orange:`var(--warning)`,red:`var(--danger)`},Me=(0,P.forwardRef)(function({prefs:e,state:t,data:n,onCommand:r,onRefresh:i,onCopyAddress:a,onSwitchClient:o,preview:s,tab:c,onTabChange:u,className:f},m){let{t:h}=d(),[_,v]=(0,P.useState)(`overview`),y=t.activity!==null,b=t.running&&!y,x=e=>r?.(e),S=[`overview`];e.sections.quota&&(n.plans.length>0||n.hasSubscriptions)&&S.push(`quota`),e.sections.clients&&n.clients.some(e=>e.enabled)&&S.push(`clients`);let C=c??_,w=S.includes(C)?C:`overview`,T=e=>{v(e),u?.(e)},E=(t.running||y)&&S.length>1,D=n.settings?.gatewayBaseUrl.replace(/^https?:\/\//,``)??(t.port?`127.0.0.1:${t.port}`:``),O=t.activity?h(`tray.status.${t.activity}`):t.running?h(`tray.status.running`):h(`tray.status.stopped`);return(0,H.jsxs)(`div`,{ref:m,className:p(`chrome flex max-h-full flex-col overflow-hidden rounded-[14px] border border-[var(--border-strong)] bg-[var(--surface-raised)] text-[13px] text-[var(--foreground)]`,f),children:[(0,H.jsxs)(`header`,{"data-tray-part":`header`,className:`shrink-0 border-b border-[var(--border)] px-4 pt-3.5 pb-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(te,{tone:y?`orange`:t.running?`green`:`red`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold`,children:O}),(0,H.jsx)(U,{label:h(`tray.copyAddress`),onClick:a,disabled:!D,children:(0,H.jsx)(ie,{className:`size-4`})}),(0,H.jsx)(U,{label:h(`tray.settings`),onClick:()=>x(`open-settings`),children:(0,H.jsx)(l,{className:`size-4`})}),(0,H.jsx)(U,{label:h(`tray.more`),onClick:()=>x(`menu`),children:(0,H.jsx)(ae,{className:`size-4`})}),!s&&(0,H.jsx)(U,{label:h(`common.close`),onClick:()=>x(`hide`),children:(0,H.jsx)(g,{className:`size-4`})})]}),D&&(0,H.jsx)(`div`,{className:`selectable mt-0.5 truncate pl-4 font-mono text-[12px] text-[var(--text-secondary)]`,children:D}),(t.apiVersionMismatch||t.updateAvailable)&&(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 pl-4`,children:[t.apiVersionMismatch&&(0,H.jsxs)(W,{tone:`orange`,children:[(0,H.jsx)(k,{className:`size-3`}),h(`tray.mismatch`)]}),t.updateAvailable&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>x(`check-updates`),className:`cursor-default`,children:(0,H.jsx)(W,{tone:`accent`,children:h(`tray.update`)})})]})]}),(0,H.jsx)(`div`,{"data-tray-part":`tabs`,className:`shrink-0`,children:E&&(0,H.jsx)(Ne,{tabs:S,active:w,onChange:T})}),(0,H.jsx)(`div`,{className:`scroll min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsx)(`div`,{"data-tray-part":`body`,className:`flex flex-col gap-3 px-4 py-3.5`,children:!t.running&&!y?(0,H.jsx)(Fe,{onStart:()=>x(`start`)}):(0,H.jsxs)(H.Fragment,{children:[w===`overview`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Pe,{prefs:e,data:n,onViewQuota:()=>T(`quota`)}),(0,H.jsx)(Le,{prefs:e,data:n,onRefresh:i}),e.sections.quota&&(0,H.jsx)(ze,{data:n,onViewAll:()=>T(`quota`)})]}),w===`quota`&&(0,H.jsx)(Be,{data:n,plain:!0}),w===`clients`&&(0,H.jsx)(He,{data:n,disabled:!b,onSwitch:o,plain:!0})]})})}),(0,H.jsxs)(`footer`,{"data-tray-part":`footer`,className:`flex shrink-0 items-center gap-1 border-t border-[var(--border)] px-3 py-2.5`,children:[t.running?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{label:h(`tray.restart`),onClick:()=>x(`restart`),disabled:y,children:(0,H.jsx)(oe,{className:`size-4`})}),(0,H.jsx)(U,{label:h(`tray.stop`),onClick:()=>x(`stop`),disabled:y,children:(0,H.jsx)(ke,{className:`size-4`})})]}):(0,H.jsx)(U,{label:h(`shell.startService`),onClick:()=>x(`start`),disabled:y,children:(0,H.jsx)(V,{className:`size-4`})}),(0,H.jsx)(`div`,{className:`flex-1`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>x(`quit`),className:`h-8 cursor-default rounded-[8px] px-2.5 text-[13px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-muted)] hover:text-[var(--foreground)]`,children:h(`tray.quit`)}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>x(`open`),className:`inline-flex h-8 cursor-default items-center gap-1.5 rounded-[8px] border border-[var(--border-strong)] px-3 text-[13px] font-medium transition-colors hover:bg-[var(--surface-muted)]`,children:[h(`tray.open`),(0,H.jsx)(L,{className:`size-3.5`})]})]})]})});function U({label:e,onClick:t,disabled:n,children:r}){return(0,H.jsx)(`button`,{type:`button`,title:e,"aria-label":e,disabled:n,onClick:t,className:`inline-flex size-8 shrink-0 cursor-default items-center justify-center rounded-[8px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-muted)] hover:text-[var(--foreground)] disabled:opacity-40 disabled:hover:bg-transparent`,children:r})}function W({tone:e,children:t,title:n}){let r={red:`var(--danger)`,orange:`var(--warning)`,accent:`var(--accent)`,neutral:`var(--text-secondary)`}[e];return(0,H.jsx)(`span`,{title:n,className:`inline-flex max-w-full items-center gap-1 rounded-[6px] border px-1.5 py-px text-[11.5px] leading-[18px] whitespace-nowrap`,style:{color:r,borderColor:`color-mix(in oklab, ${r} 45%, transparent)`,background:`color-mix(in oklab, ${r} 10%, transparent)`},children:t})}function Ne({tabs:e,active:t,onChange:n}){let{t:r}=d(),i={overview:r(`tray.tab.overview`),quota:r(`tray.tab.quota`),clients:r(`tray.clients`)};return(0,H.jsx)(`div`,{role:`tablist`,className:`flex gap-1 px-3 pt-2.5`,children:e.map(e=>(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===t,onClick:()=>n(e),className:p(`h-7 cursor-default rounded-[7px] px-2.5 text-[12.5px] transition-colors`,e===t?`bg-[var(--surface-muted)] font-medium text-[var(--foreground)]`:`text-[var(--text-secondary)] hover:text-[var(--foreground)]`),children:i[e]},e))})}function G({tone:e,onClick:t,children:n}){let r=e===`red`?`var(--danger)`:`var(--warning)`,i={color:r,borderColor:`color-mix(in oklab, ${r} 45%, transparent)`,background:`color-mix(in oklab, ${r} 10%, transparent)`},a=`flex w-full items-center gap-1.5 rounded-[8px] border px-2.5 py-1.5 text-left text-[12.5px]`,o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(k,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n})]});return t?(0,H.jsxs)(`button`,{type:`button`,onClick:t,className:p(a,`cursor-default`),style:i,children:[o,(0,H.jsx)(j,{className:`size-3.5 shrink-0`})]}):(0,H.jsx)(`div`,{className:a,style:i,children:o})}function Pe({prefs:e,data:t,onViewQuota:n}){let{t:r,locale:i}=d(),a=t.summary,o=e.sections.overview&&a?ye(a):0,s=e.sections.quota?_e(t.plans):null,c=s&&s.row.remaining<30?s:null;return!a||o===0&&!c?null:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[o>0&&(0,H.jsx)(G,{tone:`red`,children:r(`tray.alert.failures`,{count:o,share:E(o/a.requests)})}),c&&(0,H.jsx)(G,{tone:c.row.remaining<10?`red`:`orange`,onClick:n,children:r(`tray.alert.quota`,{plan:c.plan.providerName,window:J(c.row,r,i),remaining:`${Math.round(c.row.remaining)}%`})})]})}function Fe({onStart:e}){let{t}=d();return(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-6 text-center`,children:[(0,H.jsx)(`div`,{className:`text-[13px] font-medium`,children:t(`tray.status.stopped`)}),(0,H.jsx)(`div`,{className:`max-w-[260px] text-[12px] text-[var(--text-secondary)]`,children:t(`tray.stoppedHint`)}),(0,H.jsxs)(`button`,{type:`button`,onClick:e,className:`mt-1 inline-flex h-8 cursor-default items-center gap-1.5 rounded-[8px] bg-[var(--accent)] px-3 text-[13px] font-medium text-[var(--on-accent)]`,children:[(0,H.jsx)(V,{className:`size-3.5`}),t(`shell.startService`)]})]})}function Ie(e=3e4){let[t,n]=(0,P.useState)(()=>Date.now());return(0,P.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Le({prefs:e,data:t,onRefresh:n}){let{t:r,locale:i}=d(),a=Ie(),o=t.summary,s=e.sections,c=s.overview||s.cost,l=o?o.inputTokens+o.outputTokens:0,u=pe(t.updatedAt,i,r(`tray.justNow`),a),f=s.topModel?we(t.top,l):null,p=s.cacheHitRate&&o?le(o.cacheReadTokens,o.inputTokens):null,m=s.compareYesterday&&o?me(l,de(t.daily,new Date(a))):null,h=s.topModel||s.cacheHitRate||s.compareYesterday;return!c&&!s.chart&&!h?null:(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-[13px] text-[var(--text-secondary)]`,children:r(`tray.today`)}),(0,H.jsx)(`div`,{className:`flex-1`}),u&&(0,H.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`tray.updated`,{time:u})}),(0,H.jsx)(U,{label:r(`common.refresh`),onClick:n,children:(0,H.jsx)(se,{className:`size-3.5`})})]}),o?(0,H.jsxs)(H.Fragment,{children:[c&&(0,H.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-px overflow-hidden rounded-[10px] bg-[var(--border)]`,children:[s.overview&&(0,H.jsx)(K,{label:r(`tray.requests`),value:_(o.requests,!0)}),s.overview&&(0,H.jsx)(K,{label:r(`tray.tokens`),value:_(l,!0)}),s.cost&&(0,H.jsx)(K,{label:r(`tray.cost`),value:Ce(o.costUsd)})]}),s.chart&&(0,H.jsx)(Re,{data:t,now:a}),h&&(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[f&&(0,H.jsxs)(q,{label:r(`tray.topModel`),title:f.model,children:[(0,H.jsx)(`span`,{className:`truncate`,children:f.model}),(0,H.jsxs)(`span`,{className:`shrink-0`,children:[`· `,E(f.share)]})]}),s.cacheHitRate&&(0,H.jsx)(q,{label:r(`tray.cacheHit`),children:(0,H.jsx)(`span`,{children:p==null?`—`:E(p)})}),s.compareYesterday&&(0,H.jsx)(q,{label:r(`tray.vsYesterday`),children:m==null?(0,H.jsx)(`span`,{children:`—`}):(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[m>=0?(0,H.jsx)(L,{className:`size-3`}):(0,H.jsx)(Oe,{className:`size-3`}),E(Math.abs(m))]})})]})]}):t.error?(0,H.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:r(`tray.loadFailed`)}):(0,H.jsx)(x,{lines:2})]})}function K({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`min-w-0 bg-[var(--surface-muted)] px-3 py-2.5`,children:[(0,H.jsx)(`div`,{className:`truncate text-[12px] text-[var(--text-secondary)]`,children:e}),(0,H.jsx)(`div`,{className:`num mt-0.5 truncate text-[20px] leading-tight font-semibold`,title:t,children:t})]})}function q({label:e,title:t,children:n}){return(0,H.jsxs)(`span`,{title:t,className:`inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-[7px] border border-[var(--border)] px-2 py-0.5 text-[12px]`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e}),(0,H.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 font-medium`,children:n})]})}function Re({data:e,now:t}){let{t:n}=d(),r=he(e.hourly,new Date(t)),i=Math.max(1,...r.map(e=>e.value)),a=new Date(t).getHours();return(0,H.jsx)(`div`,{role:`img`,"aria-label":n(`tray.chartLabel`),className:`flex h-16 items-end gap-[3px]`,children:r.map((e,t)=>{let r=e.value>0?Math.max(4,Math.round(e.value/i*64)):2;return(0,H.jsx)(`span`,{title:n(`tray.hourBar`,{hour:`${String(t).padStart(2,`0`)}:00`,count:e.value}),className:`flex-1 rounded-[2px]`,style:{height:r,background:t===a?`var(--accent)`:e.value>0?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`var(--border)`,opacity:t>a?.5:1}},e.bucket)})})}function ze({data:e,onViewAll:t}){let{t:n,locale:r}=d();if(e.plans.length===0)return e.hasSubscriptions?(0,H.jsx)(`div`,{className:`border-t border-[var(--border)] pt-3 text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):null;let i=fe(e.plans,3),a=e.plans.reduce((e,t)=>e+t.rows.length,0);return(0,H.jsxs)(`section`,{className:`flex flex-col gap-2 border-t border-[var(--border)] pt-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center text-[12px] text-[var(--text-secondary)]`,children:[(0,H.jsx)(`span`,{className:`flex-1`,children:n(`tray.quotaTightest`)}),a>i.length&&(0,H.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex cursor-default items-center gap-0.5 hover:text-[var(--foreground)]`,children:[n(`tray.viewAll`),(0,H.jsx)(j,{className:`size-3`})]})]}),i.map(({plan:e,row:t},i)=>(0,H.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_64px_40px_60px] items-center gap-2 text-[12.5px]`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,H.jsx)(M,{name:e.providerName,icon:e.providerIcon,size:14}),(0,H.jsx)(`span`,{className:`truncate font-medium`,children:e.providerName}),(0,H.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:J(t,n,r)})]}),(0,H.jsx)(Y,{row:t,locale:r})]},`${e.accountId}-${t.kind}-${i}`))]})}function Be({data:e,plain:t}){let{t:n}=d();if(e.plans.length===0&&!e.hasSubscriptions)return null;let r=new Map;for(let t of e.plans)r.set(t.providerId,(r.get(t.providerId)??0)+1);return(0,H.jsxs)(`section`,{className:p(`flex flex-col gap-2`,!t&&`border-t border-[var(--border)] pt-3`),children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-[1fr_48px_72px] items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,H.jsx)(`span`,{children:n(`tray.quota`)}),(0,H.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaRemaining`)}),(0,H.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaReset`)})]}),e.plans.length===0?(0,H.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):e.plans.map(e=>(0,H.jsx)(Ve,{plan:e,showAccount:(r.get(e.providerId)??0)>1},e.accountId))]})}function J(e,t,n){return e.kind===`balance`?e.label??t(`tray.quotaBalance`):e.kind===`credits`||e.windowMinutes==null?t(`tray.quotaCredits`):Te(e.windowMinutes,n)}function Y({row:e,locale:t}){let n=e.remaining,r=n===null?void 0:je[be(n)];return(0,H.jsxs)(H.Fragment,{children:[n===null?(0,H.jsx)(`span`,{}):(0,H.jsx)(`span`,{className:`h-1.5 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,H.jsx)(`span`,{className:`block h-full rounded-full`,style:{width:`${n}%`,background:r}})}),e.amount?(0,H.jsx)(`span`,{className:`num col-span-2 truncate text-right font-medium`,children:xe(e.amount.value,e.amount.unit,t)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`num text-right font-medium`,children:n===null?`—`:`${Math.round(n)}%`}),(0,H.jsx)(`span`,{className:`truncate text-right text-[var(--text-secondary)]`,children:ve(e.resetsAt,t)??`—`})]})]})}function Ve({plan:e,showAccount:t}){let{t:n,locale:r}=d();return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(M,{name:e.providerName,icon:e.providerIcon,size:16}),(0,H.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.providerName}),t&&(0,H.jsx)(`span`,{className:`truncate text-[12px] text-[var(--text-muted)]`,children:e.accountName})]}),e.rows.map((e,t)=>{let i=J(e,n,r);return(0,H.jsxs)(`div`,{className:`grid grid-cols-[52px_1fr_48px_72px] items-center gap-2 pl-6 text-[12.5px]`,children:[(0,H.jsx)(`span`,{className:`truncate text-[var(--text-secondary)]`,title:i,children:i}),(0,H.jsx)(Y,{row:e,locale:r})]},`${e.kind}-${t}`)})]})}function He({data:e,disabled:t,onSwitch:n,plain:r}){let{t:i}=d(),a=e.clients.filter(e=>e.enabled);if(a.length===0)return null;let o=t=>e.providers.find(e=>e.id===t)?.name??i(`tray.unbound`);return(0,H.jsxs)(`section`,{className:p(`flex flex-col gap-1`,!r&&`border-t border-[var(--border)] pt-3`),children:[(0,H.jsx)(`div`,{className:`mb-0.5 text-[12px] text-[var(--text-secondary)]`,children:i(`tray.clients`)}),a.map(e=>(0,H.jsxs)(`button`,{type:`button`,disabled:t||!n,onClick:()=>n?.(e),"aria-label":i(`tray.switchProvider`,{client:e.name}),className:`-mx-2 flex h-8 cursor-default items-center gap-2 rounded-[8px] px-2 text-left transition-colors enabled:hover:bg-[var(--surface-muted)]`,children:[e.kind in ue&&(0,H.jsx)(ce,{kind:e.kind,size:16}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,H.jsx)(`span`,{className:`max-w-[45%] truncate text-[12px] text-[var(--text-secondary)]`,children:o(e.providerId)}),n&&(0,H.jsx)(Ae,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`})]},e.kind))]})}var X={title:`requests`,sections:{overview:!0,cost:!0,chart:!0,topModel:!0,compareYesterday:!1,cacheHitRate:!1,quota:!0,clients:!1}},Ue=()=>!!T()?.tray;function We(){let[e,t]=(0,P.useState)(X),[n,r]=(0,P.useState)(!T()?.tray);return(0,P.useEffect)(()=>{let e=T()?.tray;if(!e)return;let n=!0;e.getPrefs().then(e=>{n&&(t(e),r(!0))});let i=e.onPrefsChanged(t);return()=>{n=!1,i()}},[]),[e,(0,P.useCallback)(e=>{t(e);let n=T()?.tray;n&&n.setPrefs(e).then(t)},[]),n]}function Ge(){let e=a(),[t,n]=(0,P.useState)(null);return(0,P.useEffect)(()=>{let e=T()?.tray;if(!e)return;let t=!0;e.getState().then(e=>{t&&n(e)});let r=e.onStateChanged(n);return()=>{t=!1,r()}},[]),t??{running:e.isSuccess,port:null,activity:null,apiVersionMismatch:!1,updateAvailable:null}}function Ke(e,t,n){return{...e,sections:{...e.sections,[t]:n}}}var Z=3e5,Q=new Map,$=()=>-new Date().getTimezoneOffset();function qe(e,t){let r=O(),{enabled:i,background:a}=t,o={refetchInterval:15e3,refetchIntervalInBackground:a},s=e.sections.quota||e.title===`quota`||e.title===`alerts`,l=A({queryKey:n.settings,queryFn:()=>C(`GET`,`/api/settings`),enabled:i}),u=A({queryKey:n.stats(`summary`,`today`,``,``),queryFn:()=>C(`GET`,`/api/stats/summary?range=today`),enabled:i,...o}),d=A({queryKey:n.stats(`timeseries`,`today`,`hour`,`provider`,``,``,$()),queryFn:()=>C(`GET`,`/api/stats/timeseries?range=today&groupBy=hour&by=provider&tzOffset=${$()}`),enabled:i&&e.sections.chart,...o,refetchInterval:3e4}),f=A({queryKey:n.stats(`timeseries`,`7d`,`day`,`provider`,``,``,$()),queryFn:()=>C(`GET`,`/api/stats/timeseries?range=7d&groupBy=day&by=provider&tzOffset=${$()}`),enabled:i&&e.sections.compareYesterday,...o,refetchInterval:6e4}),p=A({queryKey:n.stats(`top`,`today`,``,3,``),queryFn:()=>C(`GET`,`/api/stats/top-models?range=today&limit=3`),enabled:i&&e.sections.topModel,...o,refetchInterval:3e4}),m=A({queryKey:n.providers,queryFn:()=>C(`GET`,`/api/providers`),enabled:i&&(s||e.sections.clients),...o,refetchInterval:6e4}),h=A({queryKey:n.clients,queryFn:()=>C(`GET`,`/api/clients`),enabled:i&&e.sections.clients,...o,refetchInterval:3e4}),g=(0,P.useMemo)(()=>(m.data??[]).filter(e=>e.enabled&&e.authScheme===`oauth-subscription`),[m.data]),_=De({queries:g.map(e=>({queryKey:n.providerAccounts(e.id),queryFn:()=>C(`GET`,`/api/providers/${y(e.id)}/accounts`),enabled:i&&s,...o,refetchInterval:6e4}))}),v=g.flatMap((e,t)=>(_[t]?.data??[]).map(t=>({provider:e,account:t}))),b=v.map(e=>`${e.account.id}:${e.account.status}:${e.account.quota?.fetchedAtUtc??``}`).join(`|`),x=c({mutationFn:e=>C(`POST`,`/api/provider-accounts/${y(e)}/quota`),onSettled:e=>{e&&r.invalidateQueries({queryKey:n.providerAccounts(e.providerId)})}}),S=i&&s&&(t.live||e.title===`quota`||e.title===`alerts`);(0,P.useEffect)(()=>{if(!S)return;let e=Date.now();for(let{account:t}of v){if(t.status!==`active`)continue;let n=t.quota?.fetchedAtUtc?new Date(t.quota.fetchedAtUtc).getTime():0;Number.isFinite(n)&&e-n<Z||e-(Q.get(t.id)??0)<Z||(Q.set(t.id,e),x.mutate(t.id,{onError:()=>{}}))}},[S,b]);let w=[...Se(v),...ge(m.data??[])];return{settings:l.data,summary:u.data,hourly:d.data??[],daily:f.data??[],top:p.data??[],plans:w,hasSubscriptions:v.some(e=>e.account.status===`active`),clients:h.data??[],providers:m.data??[],updatedAt:u.dataUpdatedAt,loading:u.isLoading,error:u.isError}}export{Ge as a,We as i,X as n,Ke as o,Ue as r,Me as s,qe as t};