@aidotnet/server-darwin-arm64 0.9.4 → 0.9.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/bin/astra-server +2 -2
- package/bin/wwwroot/assets/ClientsPage-DEetiYfc.js +9 -0
- package/bin/wwwroot/assets/KeyPage-cq7HprCR.js +1 -0
- package/bin/wwwroot/assets/ModelDetailPage-Uj6p-r8V.js +1 -0
- package/bin/wwwroot/assets/ModelsPage-B-l5oEGF.js +1 -0
- package/bin/wwwroot/assets/PluginsPage-BH9KjyfC.js +2 -0
- package/bin/wwwroot/assets/PrivacyPage-C5XhVKZd.js +1 -0
- package/bin/wwwroot/assets/ProviderDetailPage-uLPHWm2i.js +3 -0
- package/bin/wwwroot/assets/ProvidersPage-CNU_ji4e.js +2 -0
- package/bin/wwwroot/assets/SettingsPage-B3tbYdLW.js +2 -0
- package/bin/wwwroot/assets/TokenDetailPage-BVyb_-ev.js +1 -0
- package/bin/wwwroot/assets/TokenPoolEditor-7LX143SO.js +1 -0
- package/bin/wwwroot/assets/TokensPage-vRrXvqkK.js +1 -0
- package/bin/wwwroot/assets/{TracesPage-Bzy2gUvV.js → TracesPage-C9mYB_7E.js} +2 -2
- package/bin/wwwroot/assets/{TrayPanelPage-BZS_htv0.js → TrayPanelPage-NIkRrLCt.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-CYoAUUiY.js → TrayPanelView-BpQQa0qi.js} +1 -1
- package/bin/wwwroot/assets/alert-CN1yWco4.js +15 -0
- package/bin/wwwroot/assets/{arrow-down-7oFM4dM3.js → arrow-down-DP0xP3tk.js} +1 -1
- package/bin/wwwroot/assets/{arrow-left-Dn6_YDkh.js → arrow-left-UUQiUGQ1.js} +1 -1
- package/bin/wwwroot/assets/{checkbox-DzIMWhhw.js → checkbox-BEWRhO5r.js} +1 -1
- package/bin/wwwroot/assets/{cloud-download-Bvry8vmS.js → cloud-download-DebyBXx2.js} +1 -1
- package/bin/wwwroot/assets/confirm-morph-DwiVsert.js +1 -0
- package/bin/wwwroot/assets/{download-5xAFYJ6Q.js → download-C4--ZCHf.js} +1 -1
- package/bin/wwwroot/assets/{ellipsis-Dxds5r72.js → ellipsis-D250KISp.js} +1 -1
- package/bin/wwwroot/assets/{external-link-Bq_1v6I1.js → external-link-Bnshhxip.js} +1 -1
- package/bin/wwwroot/assets/{folder-open-BXsxEYtm.js → folder-open-BzVuhS53.js} +1 -1
- package/bin/wwwroot/assets/{index-mlmGhWY4.js → index-CBrXkG99.js} +10 -10
- package/bin/wwwroot/assets/index-DE_l9Wt4.css +1 -0
- package/bin/wwwroot/assets/{log-out-B9HHsF8m.js → log-out-DEZofPIg.js} +1 -1
- package/bin/wwwroot/assets/minus-BAoIEc33.js +1 -0
- package/bin/wwwroot/assets/overlays-D2pWmtov.js +41 -0
- package/bin/wwwroot/assets/{pencil-BAzRd1Ro.js → pencil-DuD1bQje.js} +1 -1
- package/bin/wwwroot/assets/{power-DrpargJA.js → power-LE8gLJKc.js} +1 -1
- package/bin/wwwroot/assets/radio-cards-D1yOuSfh.js +1 -0
- package/bin/wwwroot/assets/{rotate-ccw-D6r7Boub.js → rotate-ccw-Cx9vNOkF.js} +1 -1
- package/bin/wwwroot/assets/sortable.esm-B0eMzUNN.js +5 -0
- package/bin/wwwroot/index.html +4 -4
- package/package.json +1 -1
- package/bin/wwwroot/assets/ClientsPage-DzZnCU7V.js +0 -12
- package/bin/wwwroot/assets/KeyPage-CtHw5I7A.js +0 -1
- package/bin/wwwroot/assets/ModelDetailPage-KY2k0x3l.js +0 -1
- package/bin/wwwroot/assets/ModelsPage-Bo8oA3Zb.js +0 -1
- package/bin/wwwroot/assets/PluginsPage-BMP78mVY.js +0 -2
- package/bin/wwwroot/assets/PrivacyPage-BgldsSQj.js +0 -1
- package/bin/wwwroot/assets/ProviderDetailPage-B6EfUhXb.js +0 -3
- package/bin/wwwroot/assets/ProvidersPage-DclHIvR2.js +0 -2
- package/bin/wwwroot/assets/SettingsPage-D29CZiaV.js +0 -2
- package/bin/wwwroot/assets/TokensPage-CaF-wXlr.js +0 -1
- package/bin/wwwroot/assets/alert-CGUFPyGb.js +0 -15
- package/bin/wwwroot/assets/confirm-morph-DnwMPT3r.js +0 -1
- package/bin/wwwroot/assets/index-BXZibBui.css +0 -1
- package/bin/wwwroot/assets/minus-BVd6Aw9t.js +0 -1
- package/bin/wwwroot/assets/overlays-B1a0OZYb.js +0 -41
- package/bin/wwwroot/assets/radio-cards-Cr0tP9In.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ca as e,Ct as t,Ea as n,Sa as r,Si as i,Tr as a,ot as o,xa as s}from"./alert-CN1yWco4.js";import{F as c,P as l,R as u,a as d,gt as f,o as p,z as m}from"./overlays-D2pWmtov.js";import{t as h}from"./TrayPanelView-BpQQa0qi.js";var g=n(e(),1),_=r(),v=new Set([`astra.theme`,`astra.accent`,`astra.locale`]);function y(){let{t:e}=o(),n=s(),{toast:r}=p(),y=i(),[b]=u(),x=m(),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(`overview`),E=c(b,{enabled:x.running,background:!0,live:S}),D=a(),O=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{let e=document.documentElement;e.dataset.view=`tray`,e.style.background=`transparent`,document.body.style.background=`transparent`},[]);let k=(0,g.useCallback)(()=>{n.invalidateQueries({queryKey:[`stats`]}),n.invalidateQueries({queryKey:t.providers}),n.invalidateQueries({queryKey:t.clients}),n.invalidateQueries({queryKey:[`provider-accounts`]})},[n]);(0,g.useEffect)(()=>y?.tray.onVisibilityChanged(e=>{C(e),e&&(T(`overview`),k())}),[y,k]),(0,g.useEffect)(()=>{x.running&&k()},[x.running,k]),(0,g.useEffect)(()=>{let e=e=>{e.key&&v.has(e.key)&&window.location.reload()};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&y?.tray.command(`hide`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y]),(0,g.useLayoutEffect)(()=>{let e=O.current;if(!e||!y)return;let t=[`header`,`tabs`,`body`,`footer`].map(t=>e.querySelector(`[data-tray-part="${t}"]`)),n=()=>{let n=e.offsetHeight-e.clientHeight,r=t.reduce((e,t)=>e+(t?.offsetHeight??0),0)+n;y.tray.resize(r)},r=new ResizeObserver(n);for(let e of t)e&&r.observe(e);return n(),()=>r.disconnect()},[y]),l(b,x,E.summary,E.plans);let A=e=>void y?.tray.command(e),j=async()=>{E.settings&&await f.copy(`${E.settings.gatewayBaseUrl}/v1`)&&r(e(`common.copied`))},M=async t=>{let n=E.providers;if(n.length===0)return;let i=await f.contextMenu(n.map(n=>({id:n.id,label:n.enabled?n.name:e(`tray.disabledProvider`,{name:n.name}),type:`checkbox`,checked:n.id===t.providerId})));i&&i!==t.providerId&&D.mutate({kind:t.kind,providerId:i},{onError:e=>r(d(e),`error`)})};return(0,_.jsx)(`div`,{className:`h-full`,children:(0,_.jsx)(h,{ref:O,className:`h-full`,prefs:b,state:x,data:E,tab:w,onTabChange:T,onCommand:A,onRefresh:k,onCopyAddress:()=>void j(),onSwitchClient:e=>void M(e)})})}export{y as TrayPanelPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{J as e,K as t,Sa as n,ct as r,it as i,lt as a,ot as o,pt as s,s as c,v as l,va as u,vt as d,ya as f}from"./alert-CGUFPyGb.js";import{G as p,H as m,J as h,K as g,Q as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_t as w,lt as T,q as E}from"./overlays-B1a0OZYb.js";import{t as D}from"./ellipsis-Dxds5r72.js";import{t as O}from"./rotate-ccw-D6r7Boub.js";import{B as k,I as A,U as ee,_ as j,m as M,x as N,y as P}from"./index-mlmGhWY4.js";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 I=d(F),L={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};L.node;var R=d(L),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 B=d(z),V={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`}]]};V.node;var H=d(V),U=n(f(),1),W=u(),G={green:`var(--success)`,orange:`var(--warning)`,red:`var(--danger)`},K=(0,U.forwardRef)(function({prefs:e,state:t,data:n,onCommand:l,onRefresh:u,onCopyAddress:d,onSwitchClient:f,preview:p,tab:m,onTabChange:h,className:g},_){let{t:v}=o(),[y,b]=(0,U.useState)(`overview`),x=t.activity!==null,S=t.running&&!x,C=e=>l?.(e),T=[`overview`];e.sections.quota&&(n.plans.length>0||n.hasSubscriptions)&&T.push(`quota`),e.sections.clients&&n.clients.some(e=>e.enabled)&&T.push(`clients`);let E=m??y,k=T.includes(E)?E:`overview`,A=e=>{b(e),h?.(e)},j=(t.running||x)&&T.length>1,M=n.settings?.gatewayBaseUrl.replace(/^https?:\/\//,``)??(t.port?`127.0.0.1:${t.port}`:``),N=t.activity?v(`tray.status.${t.activity}`):t.running?v(`tray.status.running`):v(`tray.status.stopped`);return(0,W.jsxs)(`div`,{ref:_,className:i(`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)]`,g),children:[(0,W.jsxs)(`header`,{"data-tray-part":`header`,className:`shrink-0 border-b border-[var(--border)] px-4 pt-3.5 pb-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(c,{tone:x?`orange`:t.running?`green`:`red`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold`,children:N}),(0,W.jsx)(q,{label:v(`tray.copyAddress`),onClick:d,disabled:!M,children:(0,W.jsx)(s,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.settings`),onClick:()=>C(`open-settings`),children:(0,W.jsx)(w,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.more`),onClick:()=>C(`menu`),children:(0,W.jsx)(D,{className:`size-4`})}),!p&&(0,W.jsx)(q,{label:v(`common.close`),onClick:()=>C(`hide`),children:(0,W.jsx)(r,{className:`size-4`})})]}),M&&(0,W.jsx)(`div`,{className:`selectable mt-0.5 truncate pl-4 font-mono text-[12px] text-[var(--text-secondary)]`,children:M}),(t.apiVersionMismatch||t.updateAvailable)&&(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 pl-4`,children:[t.apiVersionMismatch&&(0,W.jsxs)(J,{tone:`orange`,children:[(0,W.jsx)(a,{className:`size-3`}),v(`tray.mismatch`)]}),t.updateAvailable&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`check-updates`),className:`cursor-default`,children:(0,W.jsx)(J,{tone:`accent`,children:v(`tray.update`)})})]})]}),(0,W.jsx)(`div`,{"data-tray-part":`tabs`,className:`shrink-0`,children:j&&(0,W.jsx)(te,{tabs:T,active:k,onChange:A})}),(0,W.jsx)(`div`,{className:`scroll min-h-0 flex-1 overflow-y-auto`,children:(0,W.jsx)(`div`,{"data-tray-part":`body`,className:`flex flex-col gap-3 px-4 py-3.5`,children:!t.running&&!x?(0,W.jsx)(re,{onStart:()=>C(`start`)}):(0,W.jsxs)(W.Fragment,{children:[k===`overview`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ne,{prefs:e,data:n,onViewQuota:()=>A(`quota`)}),(0,W.jsx)(ae,{prefs:e,data:n,onRefresh:u}),e.sections.quota&&(0,W.jsx)(se,{data:n,onViewAll:()=>A(`quota`)})]}),k===`quota`&&(0,W.jsx)(ce,{data:n,plain:!0}),k===`clients`&&(0,W.jsx)(ue,{data:n,disabled:!S,onSwitch:f,plain:!0})]})})}),(0,W.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,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:v(`tray.restart`),onClick:()=>C(`restart`),disabled:x,children:(0,W.jsx)(O,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.stop`),onClick:()=>C(`stop`),disabled:x,children:(0,W.jsx)(ee,{className:`size-4`})})]}):(0,W.jsx)(q,{label:v(`shell.startService`),onClick:()=>C(`start`),disabled:x,children:(0,W.jsx)(H,{className:`size-4`})}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`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:v(`tray.quit`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>C(`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:[v(`tray.open`),(0,W.jsx)(R,{className:`size-3.5`})]})]})]})});function q({label:e,onClick:t,disabled:n,children:r}){return(0,W.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 J({tone:e,children:t,title:n}){let r={red:`var(--danger)`,orange:`var(--warning)`,accent:`var(--accent)`,neutral:`var(--text-secondary)`}[e];return(0,W.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 te({tabs:e,active:t,onChange:n}){let{t:r}=o(),a={overview:r(`tray.tab.overview`),quota:r(`tray.tab.quota`),clients:r(`tray.clients`)};return(0,W.jsx)(`div`,{role:`tablist`,className:`flex gap-1 px-3 pt-2.5`,children:e.map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===t,onClick:()=>n(e),className:i(`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:a[e]},e))})}function Y({tone:e,onClick:t,children:n}){let r=e===`red`?`var(--danger)`:`var(--warning)`,o={color:r,borderColor:`color-mix(in oklab, ${r} 45%, transparent)`,background:`color-mix(in oklab, ${r} 10%, transparent)`},s=`flex w-full items-center gap-1.5 rounded-[8px] border px-2.5 py-1.5 text-left text-[12.5px]`,c=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(a,{className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n})]});return t?(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:i(s,`cursor-default`),style:o,children:[c,(0,W.jsx)(k,{className:`size-3.5 shrink-0`})]}):(0,W.jsx)(`div`,{className:s,style:o,children:c})}function ne({prefs:e,data:n,onViewQuota:r}){let{t:i,locale:a}=o(),s=n.summary,c=e.sections.overview&&s?m(s):0,l=e.sections.quota?E(n.plans):null,u=l&&l.row.remaining<30?l:null;return!s||c===0&&!u?null:(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[c>0&&(0,W.jsx)(Y,{tone:`red`,children:i(`tray.alert.failures`,{count:c,share:t(c/s.requests)})}),u&&(0,W.jsx)(Y,{tone:u.row.remaining<10?`red`:`orange`,onClick:r,children:i(`tray.alert.quota`,{plan:u.plan.providerName,window:Q(u.row,i,a),remaining:`${Math.round(u.row.remaining)}%`})})]})}function re({onStart:e}){let{t}=o();return(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-6 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[13px] font-medium`,children:t(`tray.status.stopped`)}),(0,W.jsx)(`div`,{className:`max-w-[260px] text-[12px] text-[var(--text-secondary)]`,children:t(`tray.stoppedHint`)}),(0,W.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,W.jsx)(H,{className:`size-3.5`}),t(`shell.startService`)]})]})}function ie(e=3e4){let[t,n]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ae({prefs:n,data:r,onRefresh:i}){let{t:a,locale:s}=o(),c=ie(),u=r.summary,d=n.sections,f=d.overview||d.cost,p=u?u.inputTokens+u.outputTokens:0,m=x(r.updatedAt,s,a(`tray.justNow`),c),h=d.topModel?S(r.top,p):null,g=d.cacheHitRate&&u?M(u.cacheReadTokens,u.inputTokens):null,b=d.compareYesterday&&u?y(p,_(r.daily,new Date(c))):null,C=d.topModel||d.cacheHitRate||d.compareYesterday;return!f&&!d.chart&&!C?null:(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-[var(--text-secondary)]`,children:a(`tray.today`)}),(0,W.jsx)(`div`,{className:`flex-1`}),m&&(0,W.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`tray.updated`,{time:m})}),(0,W.jsx)(q,{label:a(`common.refresh`),onClick:i,children:(0,W.jsx)(A,{className:`size-3.5`})})]}),u?(0,W.jsxs)(W.Fragment,{children:[f&&(0,W.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-px overflow-hidden rounded-[10px] bg-[var(--border)]`,children:[d.overview&&(0,W.jsx)(X,{label:a(`tray.requests`),value:e(u.requests,!0)}),d.overview&&(0,W.jsx)(X,{label:a(`tray.tokens`),value:e(p,!0)}),d.cost&&(0,W.jsx)(X,{label:a(`tray.cost`),value:v(u.costUsd)})]}),d.chart&&(0,W.jsx)(oe,{data:r,now:c}),C&&(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h&&(0,W.jsxs)(Z,{label:a(`tray.topModel`),title:h.model,children:[(0,W.jsx)(`span`,{className:`truncate`,children:h.model}),(0,W.jsxs)(`span`,{className:`shrink-0`,children:[`· `,t(h.share)]})]}),d.cacheHitRate&&(0,W.jsx)(Z,{label:a(`tray.cacheHit`),children:(0,W.jsx)(`span`,{children:g==null?`—`:t(g)})}),d.compareYesterday&&(0,W.jsx)(Z,{label:a(`tray.vsYesterday`),children:b==null?(0,W.jsx)(`span`,{children:`—`}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[b>=0?(0,W.jsx)(R,{className:`size-3`}):(0,W.jsx)(I,{className:`size-3`}),t(Math.abs(b))]})})]})]}):r.error?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:a(`tray.loadFailed`)}):(0,W.jsx)(l,{lines:2})]})}function X({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`min-w-0 bg-[var(--surface-muted)] px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate text-[12px] text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`div`,{className:`num mt-0.5 truncate text-[20px] leading-tight font-semibold`,title:t,children:t})]})}function Z({label:e,title:t,children:n}){return(0,W.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,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 font-medium`,children:n})]})}function oe({data:e,now:t}){let{t:n}=o(),r=b(e.hourly,new Date(t)),i=Math.max(1,...r.map(e=>e.value)),a=new Date(t).getHours();return(0,W.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,W.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 se({data:e,onViewAll:t}){let{t:n,locale:r}=o();if(e.plans.length===0)return e.hasSubscriptions?(0,W.jsx)(`div`,{className:`border-t border-[var(--border)] pt-3 text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):null;let i=h(e.plans,3),a=e.plans.reduce((e,t)=>e+t.rows.length,0);return(0,W.jsxs)(`section`,{className:`flex flex-col gap-2 border-t border-[var(--border)] pt-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{className:`flex-1`,children:n(`tray.quotaTightest`)}),a>i.length&&(0,W.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,W.jsx)(k,{className:`size-3`})]})]}),i.map(({plan:e,row:t},i)=>(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_64px_40px_60px] items-center gap-2 text-[12.5px]`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(N,{name:e.providerName,icon:e.providerIcon,size:14}),(0,W.jsx)(`span`,{className:`truncate font-medium`,children:e.providerName}),(0,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:Q(t,n,r)})]}),(0,W.jsx)($,{row:t,locale:r})]},`${e.accountId}-${t.kind}-${i}`))]})}function ce({data:e,plain:t}){let{t:n}=o();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,W.jsxs)(`section`,{className:i(`flex flex-col gap-2`,!t&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-[1fr_48px_72px] items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{children:n(`tray.quota`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaRemaining`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaReset`)})]}),e.plans.length===0?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):e.plans.map(e=>(0,W.jsx)(le,{plan:e,showAccount:(r.get(e.providerId)??0)>1},e.accountId))]})}function Q(e,t,n){return e.kind===`balance`?e.label??t(`tray.quotaBalance`):e.kind===`credits`||e.windowMinutes==null?t(`tray.quotaCredits`):C(e.windowMinutes,n)}function $({row:e,locale:t}){let n=e.remaining,r=n===null?void 0:G[p(n)];return(0,W.jsxs)(W.Fragment,{children:[n===null?(0,W.jsx)(`span`,{}):(0,W.jsx)(`span`,{className:`h-1.5 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,W.jsx)(`span`,{className:`block h-full rounded-full`,style:{width:`${n}%`,background:r}})}),e.amount?(0,W.jsx)(`span`,{className:`num col-span-2 truncate text-right font-medium`,children:T(e.amount.value,e.amount.unit,t)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`num text-right font-medium`,children:n===null?`—`:`${Math.round(n)}%`}),(0,W.jsx)(`span`,{className:`truncate text-right text-[var(--text-secondary)]`,children:g(e.resetsAt,t)??`—`})]})]})}function le({plan:e,showAccount:t}){let{t:n,locale:r}=o();return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(N,{name:e.providerName,icon:e.providerIcon,size:16}),(0,W.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.providerName}),t&&(0,W.jsx)(`span`,{className:`truncate text-[12px] text-[var(--text-muted)]`,children:e.accountName})]}),e.rows.map((e,t)=>{let i=Q(e,n,r);return(0,W.jsxs)(`div`,{className:`grid grid-cols-[52px_1fr_48px_72px] items-center gap-2 pl-6 text-[12.5px]`,children:[(0,W.jsx)(`span`,{className:`truncate text-[var(--text-secondary)]`,title:i,children:i}),(0,W.jsx)($,{row:e,locale:r})]},`${e.kind}-${t}`)})]})}function ue({data:e,disabled:t,onSwitch:n,plain:r}){let{t:a}=o(),s=e.clients.filter(e=>e.enabled);if(s.length===0)return null;let c=t=>e.providers.find(e=>e.id===t)?.name??a(`tray.unbound`);return(0,W.jsxs)(`section`,{className:i(`flex flex-col gap-1`,!r&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsx)(`div`,{className:`mb-0.5 text-[12px] text-[var(--text-secondary)]`,children:a(`tray.clients`)}),s.map(e=>(0,W.jsxs)(`button`,{type:`button`,disabled:t||!n,onClick:()=>n?.(e),"aria-label":a(`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 j&&(0,W.jsx)(P,{kind:e.kind,size:16}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`max-w-[45%] truncate text-[12px] text-[var(--text-secondary)]`,children:c(e.providerId)}),n&&(0,W.jsx)(B,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`})]},e.kind))]})}export{K as t};
|
|
1
|
+
import{Ca as e,Ea as t,J as n,K as r,Sa as i,ct as a,it as o,lt as s,ot as c,pt as l,s as u,v as d,vt as f}from"./alert-CN1yWco4.js";import{G as p,H as m,J as h,K as g,Q as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_t as w,lt as T,q as E}from"./overlays-D2pWmtov.js";import{t as D}from"./ellipsis-D250KISp.js";import{t as O}from"./rotate-ccw-Cx9vNOkF.js";import{L as k,V as A,W as ee,_ as j,m as M,x as N,y as P}from"./index-CBrXkG99.js";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 I=f(F),L={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};L.node;var R=f(L),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 B=f(z),V={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`}]]};V.node;var H=f(V),U=t(e(),1),W=i(),G={green:`var(--success)`,orange:`var(--warning)`,red:`var(--danger)`},K=(0,U.forwardRef)(function({prefs:e,state:t,data:n,onCommand:r,onRefresh:i,onCopyAddress:d,onSwitchClient:f,preview:p,tab:m,onTabChange:h,className:g},_){let{t:v}=c(),[y,b]=(0,U.useState)(`overview`),x=t.activity!==null,S=t.running&&!x,C=e=>r?.(e),T=[`overview`];e.sections.quota&&(n.plans.length>0||n.hasSubscriptions)&&T.push(`quota`),e.sections.clients&&n.clients.some(e=>e.enabled)&&T.push(`clients`);let E=m??y,k=T.includes(E)?E:`overview`,A=e=>{b(e),h?.(e)},j=(t.running||x)&&T.length>1,M=n.settings?.gatewayBaseUrl.replace(/^https?:\/\//,``)??(t.port?`127.0.0.1:${t.port}`:``),N=t.activity?v(`tray.status.${t.activity}`):t.running?v(`tray.status.running`):v(`tray.status.stopped`);return(0,W.jsxs)(`div`,{ref:_,className:o(`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)]`,g),children:[(0,W.jsxs)(`header`,{"data-tray-part":`header`,className:`shrink-0 border-b border-[var(--border)] px-4 pt-3.5 pb-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(u,{tone:x?`orange`:t.running?`green`:`red`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold`,children:N}),(0,W.jsx)(q,{label:v(`tray.copyAddress`),onClick:d,disabled:!M,children:(0,W.jsx)(l,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.settings`),onClick:()=>C(`open-settings`),children:(0,W.jsx)(w,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.more`),onClick:()=>C(`menu`),children:(0,W.jsx)(D,{className:`size-4`})}),!p&&(0,W.jsx)(q,{label:v(`common.close`),onClick:()=>C(`hide`),children:(0,W.jsx)(a,{className:`size-4`})})]}),M&&(0,W.jsx)(`div`,{className:`selectable mt-0.5 truncate pl-4 font-mono text-[12px] text-[var(--text-secondary)]`,children:M}),(t.apiVersionMismatch||t.updateAvailable)&&(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 pl-4`,children:[t.apiVersionMismatch&&(0,W.jsxs)(J,{tone:`orange`,children:[(0,W.jsx)(s,{className:`size-3`}),v(`tray.mismatch`)]}),t.updateAvailable&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`check-updates`),className:`cursor-default`,children:(0,W.jsx)(J,{tone:`accent`,children:v(`tray.update`)})})]})]}),(0,W.jsx)(`div`,{"data-tray-part":`tabs`,className:`shrink-0`,children:j&&(0,W.jsx)(te,{tabs:T,active:k,onChange:A})}),(0,W.jsx)(`div`,{className:`scroll min-h-0 flex-1 overflow-y-auto`,children:(0,W.jsx)(`div`,{"data-tray-part":`body`,className:`flex flex-col gap-3 px-4 py-3.5`,children:!t.running&&!x?(0,W.jsx)(re,{onStart:()=>C(`start`)}):(0,W.jsxs)(W.Fragment,{children:[k===`overview`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ne,{prefs:e,data:n,onViewQuota:()=>A(`quota`)}),(0,W.jsx)(ae,{prefs:e,data:n,onRefresh:i}),e.sections.quota&&(0,W.jsx)(se,{data:n,onViewAll:()=>A(`quota`)})]}),k===`quota`&&(0,W.jsx)(ce,{data:n,plain:!0}),k===`clients`&&(0,W.jsx)(ue,{data:n,disabled:!S,onSwitch:f,plain:!0})]})})}),(0,W.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,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:v(`tray.restart`),onClick:()=>C(`restart`),disabled:x,children:(0,W.jsx)(O,{className:`size-4`})}),(0,W.jsx)(q,{label:v(`tray.stop`),onClick:()=>C(`stop`),disabled:x,children:(0,W.jsx)(ee,{className:`size-4`})})]}):(0,W.jsx)(q,{label:v(`shell.startService`),onClick:()=>C(`start`),disabled:x,children:(0,W.jsx)(H,{className:`size-4`})}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(`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:v(`tray.quit`)}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>C(`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:[v(`tray.open`),(0,W.jsx)(R,{className:`size-3.5`})]})]})]})});function q({label:e,onClick:t,disabled:n,children:r}){return(0,W.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 J({tone:e,children:t,title:n}){let r={red:`var(--danger)`,orange:`var(--warning)`,accent:`var(--accent)`,neutral:`var(--text-secondary)`}[e];return(0,W.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 te({tabs:e,active:t,onChange:n}){let{t:r}=c(),i={overview:r(`tray.tab.overview`),quota:r(`tray.tab.quota`),clients:r(`tray.clients`)};return(0,W.jsx)(`div`,{role:`tablist`,className:`flex gap-1 px-3 pt-2.5`,children:e.map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===t,onClick:()=>n(e),className:o(`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 Y({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]`,c=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(s,{className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n})]});return t?(0,W.jsxs)(`button`,{type:`button`,onClick:t,className:o(a,`cursor-default`),style:i,children:[c,(0,W.jsx)(A,{className:`size-3.5 shrink-0`})]}):(0,W.jsx)(`div`,{className:a,style:i,children:c})}function ne({prefs:e,data:t,onViewQuota:n}){let{t:i,locale:a}=c(),o=t.summary,s=e.sections.overview&&o?m(o):0,l=e.sections.quota?E(t.plans):null,u=l&&l.row.remaining<30?l:null;return!o||s===0&&!u?null:(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s>0&&(0,W.jsx)(Y,{tone:`red`,children:i(`tray.alert.failures`,{count:s,share:r(s/o.requests)})}),u&&(0,W.jsx)(Y,{tone:u.row.remaining<10?`red`:`orange`,onClick:n,children:i(`tray.alert.quota`,{plan:u.plan.providerName,window:Q(u.row,i,a),remaining:`${Math.round(u.row.remaining)}%`})})]})}function re({onStart:e}){let{t}=c();return(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-6 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[13px] font-medium`,children:t(`tray.status.stopped`)}),(0,W.jsx)(`div`,{className:`max-w-[260px] text-[12px] text-[var(--text-secondary)]`,children:t(`tray.stoppedHint`)}),(0,W.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,W.jsx)(H,{className:`size-3.5`}),t(`shell.startService`)]})]})}function ie(e=3e4){let[t,n]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ae({prefs:e,data:t,onRefresh:i}){let{t:a,locale:o}=c(),s=ie(),l=t.summary,u=e.sections,f=u.overview||u.cost,p=l?l.inputTokens+l.outputTokens:0,m=x(t.updatedAt,o,a(`tray.justNow`),s),h=u.topModel?S(t.top,p):null,g=u.cacheHitRate&&l?M(l.cacheReadTokens,l.inputTokens):null,b=u.compareYesterday&&l?y(p,_(t.daily,new Date(s))):null,C=u.topModel||u.cacheHitRate||u.compareYesterday;return!f&&!u.chart&&!C?null:(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-[var(--text-secondary)]`,children:a(`tray.today`)}),(0,W.jsx)(`div`,{className:`flex-1`}),m&&(0,W.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`tray.updated`,{time:m})}),(0,W.jsx)(q,{label:a(`common.refresh`),onClick:i,children:(0,W.jsx)(k,{className:`size-3.5`})})]}),l?(0,W.jsxs)(W.Fragment,{children:[f&&(0,W.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-px overflow-hidden rounded-[10px] bg-[var(--border)]`,children:[u.overview&&(0,W.jsx)(X,{label:a(`tray.requests`),value:n(l.requests,!0)}),u.overview&&(0,W.jsx)(X,{label:a(`tray.tokens`),value:n(p,!0)}),u.cost&&(0,W.jsx)(X,{label:a(`tray.cost`),value:v(l.costUsd)})]}),u.chart&&(0,W.jsx)(oe,{data:t,now:s}),C&&(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h&&(0,W.jsxs)(Z,{label:a(`tray.topModel`),title:h.model,children:[(0,W.jsx)(`span`,{className:`truncate`,children:h.model}),(0,W.jsxs)(`span`,{className:`shrink-0`,children:[`· `,r(h.share)]})]}),u.cacheHitRate&&(0,W.jsx)(Z,{label:a(`tray.cacheHit`),children:(0,W.jsx)(`span`,{children:g==null?`—`:r(g)})}),u.compareYesterday&&(0,W.jsx)(Z,{label:a(`tray.vsYesterday`),children:b==null?(0,W.jsx)(`span`,{children:`—`}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[b>=0?(0,W.jsx)(R,{className:`size-3`}):(0,W.jsx)(I,{className:`size-3`}),r(Math.abs(b))]})})]})]}):t.error?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:a(`tray.loadFailed`)}):(0,W.jsx)(d,{lines:2})]})}function X({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`min-w-0 bg-[var(--surface-muted)] px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate text-[12px] text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`div`,{className:`num mt-0.5 truncate text-[20px] leading-tight font-semibold`,title:t,children:t})]})}function Z({label:e,title:t,children:n}){return(0,W.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,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e}),(0,W.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 font-medium`,children:n})]})}function oe({data:e,now:t}){let{t:n}=c(),r=b(e.hourly,new Date(t)),i=Math.max(1,...r.map(e=>e.value)),a=new Date(t).getHours();return(0,W.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,W.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 se({data:e,onViewAll:t}){let{t:n,locale:r}=c();if(e.plans.length===0)return e.hasSubscriptions?(0,W.jsx)(`div`,{className:`border-t border-[var(--border)] pt-3 text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):null;let i=h(e.plans,3),a=e.plans.reduce((e,t)=>e+t.rows.length,0);return(0,W.jsxs)(`section`,{className:`flex flex-col gap-2 border-t border-[var(--border)] pt-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{className:`flex-1`,children:n(`tray.quotaTightest`)}),a>i.length&&(0,W.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,W.jsx)(A,{className:`size-3`})]})]}),i.map(({plan:e,row:t},i)=>(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_64px_40px_60px] items-center gap-2 text-[12.5px]`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(N,{name:e.providerName,icon:e.providerIcon,size:14}),(0,W.jsx)(`span`,{className:`truncate font-medium`,children:e.providerName}),(0,W.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:Q(t,n,r)})]}),(0,W.jsx)($,{row:t,locale:r})]},`${e.accountId}-${t.kind}-${i}`))]})}function ce({data:e,plain:t}){let{t:n}=c();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,W.jsxs)(`section`,{className:o(`flex flex-col gap-2`,!t&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-[1fr_48px_72px] items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,W.jsx)(`span`,{children:n(`tray.quota`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaRemaining`)}),(0,W.jsx)(`span`,{className:`text-right`,children:n(`tray.quotaReset`)})]}),e.plans.length===0?(0,W.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`tray.quotaPending`)}):e.plans.map(e=>(0,W.jsx)(le,{plan:e,showAccount:(r.get(e.providerId)??0)>1},e.accountId))]})}function Q(e,t,n){return e.kind===`balance`?e.label??t(`tray.quotaBalance`):e.kind===`credits`||e.windowMinutes==null?t(`tray.quotaCredits`):C(e.windowMinutes,n)}function $({row:e,locale:t}){let n=e.remaining,r=n===null?void 0:G[p(n)];return(0,W.jsxs)(W.Fragment,{children:[n===null?(0,W.jsx)(`span`,{}):(0,W.jsx)(`span`,{className:`h-1.5 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,W.jsx)(`span`,{className:`block h-full rounded-full`,style:{width:`${n}%`,background:r}})}),e.amount?(0,W.jsx)(`span`,{className:`num col-span-2 truncate text-right font-medium`,children:T(e.amount.value,e.amount.unit,t)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`num text-right font-medium`,children:n===null?`—`:`${Math.round(n)}%`}),(0,W.jsx)(`span`,{className:`truncate text-right text-[var(--text-secondary)]`,children:g(e.resetsAt,t)??`—`})]})]})}function le({plan:e,showAccount:t}){let{t:n,locale:r}=c();return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(N,{name:e.providerName,icon:e.providerIcon,size:16}),(0,W.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.providerName}),t&&(0,W.jsx)(`span`,{className:`truncate text-[12px] text-[var(--text-muted)]`,children:e.accountName})]}),e.rows.map((e,t)=>{let i=Q(e,n,r);return(0,W.jsxs)(`div`,{className:`grid grid-cols-[52px_1fr_48px_72px] items-center gap-2 pl-6 text-[12.5px]`,children:[(0,W.jsx)(`span`,{className:`truncate text-[var(--text-secondary)]`,title:i,children:i}),(0,W.jsx)($,{row:e,locale:r})]},`${e.kind}-${t}`)})]})}function ue({data:e,disabled:t,onSwitch:n,plain:r}){let{t:i}=c(),a=e.clients.filter(e=>e.enabled);if(a.length===0)return null;let s=t=>e.providers.find(e=>e.id===t)?.name??i(`tray.unbound`);return(0,W.jsxs)(`section`,{className:o(`flex flex-col gap-1`,!r&&`border-t border-[var(--border)] pt-3`),children:[(0,W.jsx)(`div`,{className:`mb-0.5 text-[12px] text-[var(--text-secondary)]`,children:i(`tray.clients`)}),a.map(e=>(0,W.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 j&&(0,W.jsx)(P,{kind:e.kind,size:16}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`max-w-[45%] truncate text-[12px] text-[var(--text-secondary)]`,children:s(e.providerId)}),n&&(0,W.jsx)(B,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`})]},e.kind))]})}export{K as t};
|