@aidotnet/server-darwin-arm64 0.11.3 → 0.11.4
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 +1 -1
- package/bin/wwwroot/assets/{ClientsPage-DUe3cdEu.js → ClientsPage-TqHAFA25.js} +1 -1
- package/bin/wwwroot/assets/{KeyPage-D2ItNgUp.js → KeyPage-CNp0pPiQ.js} +1 -1
- package/bin/wwwroot/assets/{ModelDetailPage-HlmdOI1u.js → ModelDetailPage-B61Xlxp4.js} +1 -1
- package/bin/wwwroot/assets/{ModelsPage-jTdzziih.js → ModelsPage-KeUV0kEe.js} +1 -1
- package/bin/wwwroot/assets/{PluginsPage-CrRbTNkX.js → PluginsPage-D-Idp7rX.js} +1 -1
- package/bin/wwwroot/assets/{PrivacyPage-C24xx5h0.js → PrivacyPage-C3YpZHD5.js} +1 -1
- package/bin/wwwroot/assets/{ProviderDetailPage-C8oS6Rpp.js → ProviderDetailPage-CeXebQjO.js} +1 -1
- package/bin/wwwroot/assets/{ProvidersPage-CtzKM5FI.js → ProvidersPage-Ca7aGIQg.js} +1 -1
- package/bin/wwwroot/assets/{SettingsPage-CuaktA37.js → SettingsPage-CpD7hQB4.js} +2 -2
- package/bin/wwwroot/assets/{SmartRoutingPage-DRExfwox.js → SmartRoutingPage-d7VpOJbs.js} +1 -1
- package/bin/wwwroot/assets/{TokenDetailPage-BecIf_R9.js → TokenDetailPage-TJa2J-N_.js} +1 -1
- package/bin/wwwroot/assets/{TokenPoolEditor-B3t0QNlg.js → TokenPoolEditor-D1m8Jjy3.js} +1 -1
- package/bin/wwwroot/assets/{TokensPage-DnMBcutS.js → TokensPage-CnAympZG.js} +1 -1
- package/bin/wwwroot/assets/{TracesPage-AYH3RZE9.js → TracesPage-D8KIKCul.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelPage-OyBx1HTr.js → TrayPanelPage-DaxLSbIE.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-B4sGBvxd.js → TrayPanelView-D6QJsy-r.js} +1 -1
- package/bin/wwwroot/assets/{alert-qNPoglGp.js → alert-BadMvy1R.js} +2 -2
- package/bin/wwwroot/assets/{arrow-down-BtJQJK1L.js → arrow-down-Cv-6a_e3.js} +1 -1
- package/bin/wwwroot/assets/{arrow-left-D6dVbOnl.js → arrow-left-dS7bcLEo.js} +1 -1
- package/bin/wwwroot/assets/{checkbox-B47xSnbl.js → checkbox-CaaP8Tue.js} +1 -1
- package/bin/wwwroot/assets/{cloud-download-D2BBix7a.js → cloud-download-CpuzW7lP.js} +1 -1
- package/bin/wwwroot/assets/{confirm-morph-CgGgkVSl.js → confirm-morph-XE52Kxj6.js} +1 -1
- package/bin/wwwroot/assets/{download-COSgQOSF.js → download-DhWYUpCm.js} +1 -1
- package/bin/wwwroot/assets/{ellipsis-DU9LNejQ.js → ellipsis-DhDdch5j.js} +1 -1
- package/bin/wwwroot/assets/{external-link--dZT5Rkw.js → external-link-D3yhOoFs.js} +1 -1
- package/bin/wwwroot/assets/{folder-open-ClaryP3F.js → folder-open-Bggy7qkR.js} +1 -1
- package/bin/wwwroot/assets/{index-DDjZdUEf.js → index-BUGU_FDT.js} +3 -3
- package/bin/wwwroot/assets/{log-out-Tl6vCHvW.js → log-out-DV1PNbkn.js} +1 -1
- package/bin/wwwroot/assets/minus-DxRH0N_9.js +1 -0
- package/bin/wwwroot/assets/{overlays-ORpFxiz4.js → overlays-D-LaJu2w.js} +1 -1
- package/bin/wwwroot/assets/{pencil-jnrNOWQy.js → pencil-TH_5IGXD.js} +1 -1
- package/bin/wwwroot/assets/{power-BYCH_AFm.js → power-DF2viDB7.js} +1 -1
- package/bin/wwwroot/assets/{radio-cards-CyXEQMJG.js → radio-cards-Geph_wiF.js} +1 -1
- package/bin/wwwroot/assets/{rotate-ccw-D-Km3lpa.js → rotate-ccw-BxvPRjim.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-Br0EL6LB.js → sortable.esm-DYxWT0KU.js} +1 -1
- package/bin/wwwroot/index.html +3 -3
- package/package.json +1 -1
- package/bin/wwwroot/assets/minus-Bs-msHR3.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$r as e,H as t,Ia as n,J as r,Ma as i,Na as a,Pr as o,Q as s,Sr as c,Tr as l,X as u,Y as d,_ as f,ai as p,c as m,ct as h,d as g,gt as _,l as v,ln as y,n as b,or as x,p as S,q as C,r as w,s as T,t as E,tn as D,v as O,vi as k,xt as A}from"./alert-qNPoglGp.js";import{a as j,gt as M,i as N,n as ee,o as P,r as F}from"./overlays-ORpFxiz4.js";import{t as te}from"./ellipsis-DU9LNejQ.js";import{t as ne}from"./pencil-jnrNOWQy.js";import{t as re}from"./power-BYCH_AFm.js";import{t as ie}from"./rotate-ccw-D-Km3lpa.js";import{H as ae,L as oe,N as I,P as se,V as L,X as R,_ as z,h as B,s as V,y as H,z as U}from"./index-DDjZdUEf.js";import{a as ce,i as W,n as G,r as K,t as q}from"./TokenPoolEditor-B3t0QNlg.js";var J={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};J.node;var le=A(J),Y={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};Y.node;var ue=A(Y),X=n(a(),1),Z=i();function de(){let{t}=h(),n=e(),r=o(),i=p(),a=i.data?.state===`connected`?i.data.publicUrl:null,[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null);return(0,Z.jsxs)(B,{title:t(`nav.tokens`),subtitle:t(`tokens.subtitle`),actions:(0,Z.jsx)(w,{variant:`primary`,icon:(0,Z.jsx)(U,{className:`size-3.5`}),onClick:()=>c(!0),children:t(`tokens.add`)}),children:[(0,Z.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4`,children:[r.data&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 px-1 text-[12px] text-[var(--text-secondary)]`,children:[(0,Z.jsx)(`p`,{children:t(`tokens.directHint`,{url:`${r.data.gatewayBaseUrl}/v1`})}),(0,Z.jsx)(`p`,{className:`selectable`,children:t(`tokens.selfServiceHint`,{url:r.data.gatewayBaseUrl})}),a&&(0,Z.jsx)(`p`,{className:`selectable text-[var(--accent)]`,children:t(`tokens.remoteHint`,{url:`${a}/v1`,key:`${a}/key`})})]}),n.isLoading&&(0,Z.jsx)(O,{lines:4}),n.isError&&(0,Z.jsx)(E,{tone:`danger`,title:t(`common.error`),children:j(n.error)}),n.data?.length===0&&(0,Z.jsx)(`div`,{className:`card`,children:(0,Z.jsx)(m,{icon:(0,Z.jsx)(L,{className:`size-6`}),title:t(`tokens.empty`)})}),n.data&&n.data.length>0&&(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:n.data.map(e=>(0,Z.jsx)(fe,{token:e,defaultOpen:n.data.length===1,onEdit:()=>u(e)},e.id))})]}),(0,Z.jsx)(_e,{open:s,onOpenChange:c}),(0,Z.jsx)(ve,{token:l,onClose:()=>u(null)})]})}function fe({token:e,defaultOpen:n,onEdit:i}){let{t:a,locale:u}=h(),{toast:f,confirm:p}=P(),m=x(),g=o(),v=l(),S=k(),C=c(),E=y(),[D,O]=(0,X.useState)(n),A=(m.data??[]).find(t=>t.id===e.providerId),N=ce(),F=`token-detail-${e.id}`,L=(e,t)=>{f(t,`success`),e.skipped.length>0&&f(a(`tokens.skipped`,{clients:e.skipped.map(e=>z[e]?.name??e).join(`, `)}),`error`)},B=()=>v.mutate(e.id,{onSuccess:async({token:e})=>{await M.copy(e)?f(a(`tokens.copied`)):f(a(`tokens.copyFailed`),`error`)},onError:e=>f(j(e),`error`)}),V=async()=>{let e=g.data?.gatewayBaseUrl;e&&(await M.copy(`${e}/v1`)?f(a(`tokens.urlCopied`)):f(a(`tokens.copyFailed`),`error`))},U=async()=>{let e=g.data?.gatewayBaseUrl;e&&(await M.copy(`npx @aidotnet/astra-connect join ${e}`)?f(a(`tokens.joinCopied`)):f(a(`tokens.copyFailed`),`error`))},W=async()=>{(!e.enabled||await p({title:a(`tokens.disableConfirm`,{name:e.name}),detail:a(`tokens.disableDetail`),confirmLabel:a(`tokens.disable`),destructive:!0}))&&S.mutate({id:e.id,enabled:!e.enabled},{onError:e=>f(j(e),`error`)})},K=async()=>{await p({title:a(`tokens.resetConfirm`,{name:e.name}),detail:a(`tokens.resetDetail`),confirmLabel:a(`tokens.reset`),destructive:!0})&&C.mutate(e.id,{onSuccess:e=>L(e,a(`tokens.resetDone`,{count:e.rewritten.length})),onError:e=>f(j(e),`error`)})},q=async()=>{await p({title:a(`tokens.deleteConfirm`,{name:e.name}),detail:a(`tokens.deleteDetail`),confirmLabel:a(`common.delete`),destructive:!0})&&E.mutate(e.id,{onSuccess:t=>L(t,a(`tokens.deleted`,{name:e.name})),onError:e=>f(j(e),`error`)})},J=e.lastUsedAt?t(e.lastUsedAt,u):a(`tokens.neverUsed`);return(0,Z.jsxs)(`article`,{children:[(0,Z.jsxs)(`div`,{className:`flex cursor-pointer flex-wrap items-center gap-x-5 gap-y-2 px-4 py-3 hover:bg-[var(--surface-muted)]`,onClick:()=>O(e=>!e),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 items-start gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`mt-0.5 rounded text-[var(--text-muted)]`,"aria-expanded":D,"aria-controls":F,"aria-label":a(`tokens.details`),onClick:e=>{e.stopPropagation(),O(e=>!e)},children:(0,Z.jsx)(ae,{className:`size-4 transition-transform ${D?`rotate-90`:``}`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`truncate text-[14px] font-medium ${e.enabled?``:`text-[var(--text-muted)]`}`,children:e.name}),e.isDefault&&(0,Z.jsx)(b,{tone:`accent`,children:a(`tokens.default`)}),!e.enabled&&(0,Z.jsx)(b,{tone:`orange`,children:a(`tokens.disabledBadge`)}),e.limitUsage.some(e=>e.exhausted)&&(0,Z.jsx)(b,{tone:`orange`,children:a(`tokens.limitExhausted`)}),e.pool&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:e.pool.members.map(e=>e.providerId).join(`, `),children:[(0,Z.jsx)(b,{children:a(`tokens.pool.summary`,{count:e.pool.members.length,strategy:a(`tokens.strategy.${e.pool.strategy}`)})}),e.pool.members.map(e=>(0,Z.jsx)(T,{tone:G(e.health.state)},e.providerId))]})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)] selectable`,children:e.keyMasked}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(_,{className:`size-3.5`}),"aria-label":a(`tokens.copy`),title:a(`tokens.copy`),loading:v.isPending,onClick:B}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(ue,{className:`size-3.5`}),"aria-label":a(`tokens.copyUrl`),title:a(`tokens.copyUrl`),disabled:!g.data,onClick:()=>void V()}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(se,{className:`size-3.5`}),"aria-label":a(`tokens.copyJoin`),title:a(`tokens.copyJoin`),disabled:!g.data,onClick:()=>void U()})]})]})]}),(0,Z.jsx)(`div`,{className:`hidden w-16 items-center gap-1.5 md:flex`,title:e.clients.map(e=>z[e]?.name??e).join(`, `)||a(`tokens.noClients`),children:e.clients.length===0?(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:`—`}):e.clients.map(e=>(0,Z.jsx)(H,{kind:e,size:16},e))}),(0,Z.jsx)(Q,{label:a(`tokens.today`),value:s(e.today.costUsd),context:a(`tokens.requestsContext`,{count:d(e.today.requests)})}),(0,Z.jsx)(Q,{label:a(`tokens.total`),value:s(e.total.costUsd),context:`${d(e.total.totalTokens,!0)} Token`}),(0,Z.jsx)(Q,{label:a(`tokens.lastUsedTitle`),value:e.lastUsedAt?r(e.lastUsedAt,u):`—`,context:e.lastUsedAt?``:a(`tokens.neverUsed`),title:J}),(0,Z.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(ee,{label:a(`common.more`),icon:(0,Z.jsx)(te,{className:`size-4`}),items:[{id:`settings`,label:a(`tokens.settings`),icon:(0,Z.jsx)(ne,{className:`size-3.5`}),onSelect:i},{id:`toggle`,label:e.enabled?a(`tokens.disable`):a(`tokens.enable`),icon:(0,Z.jsx)(re,{className:`size-3.5`}),onSelect:()=>void W()},{id:`reset`,label:a(`tokens.reset`),icon:(0,Z.jsx)(ie,{className:`size-3.5`}),onSelect:()=>void K()},...e.isDefault?[]:[{id:`delete`,label:a(`tokens.delete`),icon:(0,Z.jsx)(I,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void q()}]]})})]}),D&&(0,Z.jsxs)(`div`,{id:F,className:`border-t border-[var(--border-subtle)] bg-[var(--surface-muted)] px-4 py-3 md:pl-10`,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-wrap gap-x-8 gap-y-2 text-[12px]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:a(`tokens.clients`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1 text-[var(--text-secondary)]`,children:e.clients.length===0?a(`tokens.noClients`):e.clients.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(H,{kind:e,size:14}),z[e]?.name??e]},e))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:e.pool?a(`tokens.pool.title`):a(`tokens.directProvider`)}),e.pool?(0,Z.jsx)(`dd`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[var(--text-secondary)]`,children:e.pool.members.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:N(e.health),children:[(0,Z.jsx)(T,{tone:G(e.health.state)}),(m.data??[]).find(t=>t.id===e.providerId)?.name??e.providerId]},e.providerId))}):(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:A?.name??(e.providerId?e.providerId:a(`tokens.directNone`))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:a(`tokens.allowedClients`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:e.allowedClients==null?a(`tokens.allowedClientsAny`):e.allowedClients.length===0?a(`tokens.directOnly`):e.allowedClients.map(e=>z[e]?.name??e).join(`, `)})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:a(`tokens.lastUsedTitle`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:J})]})]}),(0,Z.jsx)(pe,{token:e}),(0,Z.jsx)(he,{today:e.today,total:e.total}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,Z.jsx)(R,{to:`/tokens/${encodeURIComponent(e.id)}`,children:(0,Z.jsx)(w,{size:`sm`,icon:(0,Z.jsx)(le,{className:`size-3.5`}),children:a(`tokens.detail.open`)})}),(0,Z.jsx)(R,{to:`/requests?token=${encodeURIComponent(e.id)}`,children:(0,Z.jsx)(w,{size:`sm`,icon:(0,Z.jsx)(oe,{className:`size-3.5`}),children:a(`tokens.detail.viewLogs`)})})]})]})]})}function pe({token:e}){let{t}=h(),n=e.limits?.rpm;return(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`tokens.limits`)}),e.limitUsage.length===0&&n==null?(0,Z.jsx)(`div`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t(`tokens.unlimited`)}):(0,Z.jsxs)(`div`,{className:`mt-1.5 grid gap-3 sm:grid-cols-2`,children:[e.limitUsage.map(e=>(0,Z.jsx)(me,{usage:e},`${e.metric}:${e.period}`)),n!=null&&(0,Z.jsxs)(`div`,{className:`text-[11.5px] text-[var(--text-secondary)]`,children:[t(`tokens.rpm`),` · `,(0,Z.jsx)(`span`,{className:`num`,children:t(`tokens.rpmUsage`,{used:e.recentRequests,limit:n})})]})]})]})}function me({usage:e}){let{t:n,locale:r}=h(),i=`${n(`tokens.period.${e.period}`)} · ${n(`tokens.metric.${e.metric}`)}`,a=t=>e.metric===`cost`?s(t):d(t,!0),o=Math.max(0,Math.min(100,Math.round(e.usedPercent))),c=o>=90?`var(--danger)`:o>=70?`var(--warning)`:`var(--accent)`;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[11.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:i}),(0,Z.jsx)(`span`,{className:`num`,children:n(`tokens.limitUsed`,{used:a(e.used),limit:a(e.limit)})})]}),(0,Z.jsx)(`div`,{role:`progressbar`,"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface)]`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${o}%`,background:c}})}),e.resetsAt&&(0,Z.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[var(--text-muted)]`,children:n(`tokens.limitResets`,{time:t(e.resetsAt,r)})})]})}function Q({label:e,value:t,context:n,title:r}){return(0,Z.jsxs)(`div`,{className:`w-24 min-w-0`,title:r,children:[(0,Z.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,Z.jsx)(`div`,{className:`num truncate text-[14px] leading-tight font-semibold`,children:t}),(0,Z.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:n||`\xA0`})]})}function he({today:e,total:t}){let{t:n}=h(),r=[[n(`tokens.today`),e],[n(`tokens.total`),t]],i=`px-3 py-1.5 text-right font-normal whitespace-nowrap text-[var(--text-muted)]`,a=`num px-3 py-1.5 text-right whitespace-nowrap`;return(0,Z.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-[var(--radius-control)] bg-[var(--surface)]`,children:(0,Z.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-[var(--border-subtle)]`,children:[(0,Z.jsx)(`th`,{className:`${i} text-left`}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.cost`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.requests`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.tokens`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.inOut`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.cacheHit`)}),(0,Z.jsx)(`th`,{className:i,title:n(`tokens.tpsContext`),children:n(`tokens.tps`)})]})}),(0,Z.jsx)(`tbody`,{children:r.map(([e,t])=>(0,Z.jsxs)(`tr`,{children:[(0,Z.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-medium whitespace-nowrap text-[var(--text-secondary)]`,children:e}),(0,Z.jsx)(`td`,{className:`${a} font-semibold selectable`,children:s(t.costUsd)}),(0,Z.jsx)(`td`,{className:a,children:d(t.requests)}),(0,Z.jsx)(`td`,{className:a,children:d(t.totalTokens,!0)}),(0,Z.jsxs)(`td`,{className:`${a} text-[var(--text-secondary)]`,children:[d(t.inputTokens,!0),` / `,d(t.outputTokens,!0)]}),(0,Z.jsx)(`td`,{className:a,title:n(`usage.cacheAmounts`,{read:d(t.cacheReadTokens,!0),write:d(t.cacheWriteTokens,!0)}),children:t.cacheHitRate==null?`—`:C(t.cacheHitRate)}),(0,Z.jsx)(`td`,{className:a,children:t.tps==null?`—`:u(t.tps)})]},e))})]})})}function ge(){let{t:e}=h(),t=(x().data??[]).filter(e=>e.enabled);return{providers:t,options:[{value:``,label:e(`tokens.directNone`)},...t.map(e=>({value:e.id,label:e.name}))]}}function _e({open:e,onOpenChange:t}){let{t:n}=h(),{toast:r}=P(),i=D(),{options:a}=ge(),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``);return(0,X.useEffect)(()=>{e&&(s(``),l(``))},[e]),(0,Z.jsx)(N,{open:e,onOpenChange:t,title:n(`tokens.createTitle`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(w,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,Z.jsx)(w,{variant:`primary`,disabled:!o.trim(),loading:i.isPending,onClick:()=>i.mutate({name:o.trim(),providerId:c||null},{onSuccess:e=>{t(!1),r(n(`tokens.created`,{name:e.name}),`success`)},onError:e=>r(j(e),`error`)}),children:n(`common.create`)})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(v,{label:n(`tokens.name`),children:(0,Z.jsx)(g,{value:o,maxLength:64,placeholder:n(`tokens.namePlaceholder`),onChange:e=>s(e.target.value)})}),(0,Z.jsx)(v,{label:n(`tokens.directProvider`),children:(0,Z.jsx)(F,{value:c,onChange:l,options:a})})]})})}function ve({token:e,onClose:t}){let{t:n}=h(),{toast:r}=P(),i=k(),a=x(),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)([]),[p,m]=(0,X.useState)(null),[_,y]=(0,X.useState)(`any`),[b,C]=(0,X.useState)([]),T=new Set(u.map(e=>`${e.metric}:${e.period}`)).size<u.length,E=new Map((e?.pool?.members??[]).map(e=>[e.providerId,e.health]));return(0,X.useEffect)(()=>{e&&(s(e.name),l(K(e)),d(e.limits?.budgets.map(e=>({...e}))??[]),m(e.limits?.rpm??null),y(e.allowedClients==null?`any`:`only`),C(e.allowedClients??[]))},[e]),(0,Z.jsx)(N,{open:e!==null,onOpenChange:e=>!e&&t(),title:n(`tokens.settingsTitle`,{name:e?.name??``}),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(w,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(w,{variant:`primary`,disabled:!o.trim()||T,loading:i.isPending,onClick:()=>{if(!e)return;let s=u.flatMap(e=>e.limit!=null&&e.limit>0?[{...e,limit:e.limit}]:[]),l=s.length>0||p!=null&&p>0?{budgets:s,rpm:p!=null&&p>0?Math.floor(p):null}:null;i.mutate({id:e.id,name:o.trim(),...c?{pool:W(c,a.data??[])}:{},limits:l,allowedClients:_===`any`?null:b},{onSuccess:()=>{t(),r(n(`common.saved`),`success`)},onError:e=>r(j(e),`error`)})},children:n(`common.save`)})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(v,{label:n(`tokens.name`),children:(0,Z.jsx)(g,{value:o,maxLength:64,onChange:e=>s(e.target.value)})}),(0,Z.jsx)(v,{label:n(`tokens.pool.title`),hint:n(`tokens.pool.hint`),children:c&&(0,Z.jsx)(q,{draft:c,onChange:l,providers:a.data??[],health:E})}),(0,Z.jsx)(v,{label:n(`tokens.limits`),hint:n(`tokens.limitsHint`),error:T?n(`tokens.limitDuplicate`):void 0,children:(0,Z.jsx)(be,{budgets:u,onChange:d})}),(0,Z.jsx)(v,{label:n(`tokens.rpm`),hint:n(`tokens.rpmHint`),children:(0,Z.jsx)(S,{value:p,min:1,step:1,label:n(`tokens.rpm`),placeholder:n(`tokens.unlimited`),onChange:m})}),(0,Z.jsx)(v,{label:n(`tokens.allowedClients`),hint:n(`tokens.allowedClientsHint`),children:(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(f,{ariaLabel:n(`tokens.allowedClients`),value:_,onChange:y,items:[{value:`any`,label:n(`tokens.allowedClientsAny`)},{value:`only`,label:n(`tokens.allowedClientsOnly`)}]}),_===`only`&&(0,Z.jsx)(V,{label:n(`tokens.allowedClients`),options:[...new Set([...Object.keys(z),...b])].map(e=>({value:e,label:z[e]?.name??e})),value:b,onValueChange:e=>C(e)})]})})]})})}var $=[`cost`,`requests`,`tokens`],ye=[`day`,`week`,`month`,`total`];function be({budgets:e,onChange:t}){let{t:n}=h(),r=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),i=$.flatMap(e=>ye.map(t=>({metric:e,period:t}))).find(t=>!e.some(e=>e.metric===t.metric&&e.period===t.period));return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[e.length===0&&(0,Z.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`tokens.unlimited`)}),e.map((i,a)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-2`,children:[(0,Z.jsx)(F,{ariaLabel:n(`tokens.limitMetric`),value:i.metric,onChange:e=>r(a,{metric:e}),options:$.map(e=>({value:e,label:n(`tokens.metric.${e}`)}))}),(0,Z.jsx)(F,{ariaLabel:n(`tokens.limitPeriod`),value:i.period,onChange:e=>r(a,{period:e}),options:ye.map(e=>({value:e,label:n(`tokens.period.${e}`)}))}),(0,Z.jsx)(S,{label:n(`tokens.limitValue`),value:i.limit,min:0,step:i.metric===`cost`?`any`:1,placeholder:n(`tokens.limitValue`),onChange:e=>r(a,{limit:e})}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(I,{className:`size-3.5`}),"aria-label":n(`tokens.removeLimit`),title:n(`tokens.removeLimit`),onClick:()=>t(e.filter((e,t)=>t!==a))})]},a)),i&&(0,Z.jsx)(`div`,{children:(0,Z.jsx)(w,{size:`sm`,icon:(0,Z.jsx)(U,{className:`size-3.5`}),onClick:()=>t([...e,{...i,limit:null}]),children:n(`tokens.addLimit`)})})]})}export{de as TokensPage};
|
|
1
|
+
import{$r as e,H as t,Ia as n,J as r,Ma as i,Na as a,Pr as o,Q as s,Sr as c,Tr as l,X as u,Y as d,_ as f,ai as p,c as m,ct as h,d as g,gt as _,l as v,ln as y,n as b,or as x,p as S,q as C,r as w,s as T,t as E,tn as D,v as O,vi as k,xt as A}from"./alert-BadMvy1R.js";import{a as j,gt as M,i as N,n as ee,o as P,r as F}from"./overlays-D-LaJu2w.js";import{t as te}from"./ellipsis-DhDdch5j.js";import{t as ne}from"./pencil-TH_5IGXD.js";import{t as re}from"./power-DF2viDB7.js";import{t as ie}from"./rotate-ccw-BxvPRjim.js";import{H as ae,L as oe,N as I,P as se,V as L,X as R,_ as z,h as B,s as V,y as H,z as U}from"./index-BUGU_FDT.js";import{a as ce,i as W,n as G,r as K,t as q}from"./TokenPoolEditor-D1m8Jjy3.js";var J={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};J.node;var le=A(J),Y={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};Y.node;var ue=A(Y),X=n(a(),1),Z=i();function de(){let{t}=h(),n=e(),r=o(),i=p(),a=i.data?.state===`connected`?i.data.publicUrl:null,[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null);return(0,Z.jsxs)(B,{title:t(`nav.tokens`),subtitle:t(`tokens.subtitle`),actions:(0,Z.jsx)(w,{variant:`primary`,icon:(0,Z.jsx)(U,{className:`size-3.5`}),onClick:()=>c(!0),children:t(`tokens.add`)}),children:[(0,Z.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4`,children:[r.data&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 px-1 text-[12px] text-[var(--text-secondary)]`,children:[(0,Z.jsx)(`p`,{children:t(`tokens.directHint`,{url:`${r.data.gatewayBaseUrl}/v1`})}),(0,Z.jsx)(`p`,{className:`selectable`,children:t(`tokens.selfServiceHint`,{url:r.data.gatewayBaseUrl})}),a&&(0,Z.jsx)(`p`,{className:`selectable text-[var(--accent)]`,children:t(`tokens.remoteHint`,{url:`${a}/v1`,key:`${a}/key`})})]}),n.isLoading&&(0,Z.jsx)(O,{lines:4}),n.isError&&(0,Z.jsx)(E,{tone:`danger`,title:t(`common.error`),children:j(n.error)}),n.data?.length===0&&(0,Z.jsx)(`div`,{className:`card`,children:(0,Z.jsx)(m,{icon:(0,Z.jsx)(L,{className:`size-6`}),title:t(`tokens.empty`)})}),n.data&&n.data.length>0&&(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:n.data.map(e=>(0,Z.jsx)(fe,{token:e,defaultOpen:n.data.length===1,onEdit:()=>u(e)},e.id))})]}),(0,Z.jsx)(_e,{open:s,onOpenChange:c}),(0,Z.jsx)(ve,{token:l,onClose:()=>u(null)})]})}function fe({token:e,defaultOpen:n,onEdit:i}){let{t:a,locale:u}=h(),{toast:f,confirm:p}=P(),m=x(),g=o(),v=l(),S=k(),C=c(),E=y(),[D,O]=(0,X.useState)(n),A=(m.data??[]).find(t=>t.id===e.providerId),N=ce(),F=`token-detail-${e.id}`,L=(e,t)=>{f(t,`success`),e.skipped.length>0&&f(a(`tokens.skipped`,{clients:e.skipped.map(e=>z[e]?.name??e).join(`, `)}),`error`)},B=()=>v.mutate(e.id,{onSuccess:async({token:e})=>{await M.copy(e)?f(a(`tokens.copied`)):f(a(`tokens.copyFailed`),`error`)},onError:e=>f(j(e),`error`)}),V=async()=>{let e=g.data?.gatewayBaseUrl;e&&(await M.copy(`${e}/v1`)?f(a(`tokens.urlCopied`)):f(a(`tokens.copyFailed`),`error`))},U=async()=>{let e=g.data?.gatewayBaseUrl;e&&(await M.copy(`npx @aidotnet/astra-connect join ${e}`)?f(a(`tokens.joinCopied`)):f(a(`tokens.copyFailed`),`error`))},W=async()=>{(!e.enabled||await p({title:a(`tokens.disableConfirm`,{name:e.name}),detail:a(`tokens.disableDetail`),confirmLabel:a(`tokens.disable`),destructive:!0}))&&S.mutate({id:e.id,enabled:!e.enabled},{onError:e=>f(j(e),`error`)})},K=async()=>{await p({title:a(`tokens.resetConfirm`,{name:e.name}),detail:a(`tokens.resetDetail`),confirmLabel:a(`tokens.reset`),destructive:!0})&&C.mutate(e.id,{onSuccess:e=>L(e,a(`tokens.resetDone`,{count:e.rewritten.length})),onError:e=>f(j(e),`error`)})},q=async()=>{await p({title:a(`tokens.deleteConfirm`,{name:e.name}),detail:a(`tokens.deleteDetail`),confirmLabel:a(`common.delete`),destructive:!0})&&E.mutate(e.id,{onSuccess:t=>L(t,a(`tokens.deleted`,{name:e.name})),onError:e=>f(j(e),`error`)})},J=e.lastUsedAt?t(e.lastUsedAt,u):a(`tokens.neverUsed`);return(0,Z.jsxs)(`article`,{children:[(0,Z.jsxs)(`div`,{className:`flex cursor-pointer flex-wrap items-center gap-x-5 gap-y-2 px-4 py-3 hover:bg-[var(--surface-muted)]`,onClick:()=>O(e=>!e),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 items-start gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`mt-0.5 rounded text-[var(--text-muted)]`,"aria-expanded":D,"aria-controls":F,"aria-label":a(`tokens.details`),onClick:e=>{e.stopPropagation(),O(e=>!e)},children:(0,Z.jsx)(ae,{className:`size-4 transition-transform ${D?`rotate-90`:``}`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`truncate text-[14px] font-medium ${e.enabled?``:`text-[var(--text-muted)]`}`,children:e.name}),e.isDefault&&(0,Z.jsx)(b,{tone:`accent`,children:a(`tokens.default`)}),!e.enabled&&(0,Z.jsx)(b,{tone:`orange`,children:a(`tokens.disabledBadge`)}),e.limitUsage.some(e=>e.exhausted)&&(0,Z.jsx)(b,{tone:`orange`,children:a(`tokens.limitExhausted`)}),e.pool&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:e.pool.members.map(e=>e.providerId).join(`, `),children:[(0,Z.jsx)(b,{children:a(`tokens.pool.summary`,{count:e.pool.members.length,strategy:a(`tokens.strategy.${e.pool.strategy}`)})}),e.pool.members.map(e=>(0,Z.jsx)(T,{tone:G(e.health.state)},e.providerId))]})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)] selectable`,children:e.keyMasked}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(_,{className:`size-3.5`}),"aria-label":a(`tokens.copy`),title:a(`tokens.copy`),loading:v.isPending,onClick:B}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(ue,{className:`size-3.5`}),"aria-label":a(`tokens.copyUrl`),title:a(`tokens.copyUrl`),disabled:!g.data,onClick:()=>void V()}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(se,{className:`size-3.5`}),"aria-label":a(`tokens.copyJoin`),title:a(`tokens.copyJoin`),disabled:!g.data,onClick:()=>void U()})]})]})]}),(0,Z.jsx)(`div`,{className:`hidden w-16 items-center gap-1.5 md:flex`,title:e.clients.map(e=>z[e]?.name??e).join(`, `)||a(`tokens.noClients`),children:e.clients.length===0?(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:`—`}):e.clients.map(e=>(0,Z.jsx)(H,{kind:e,size:16},e))}),(0,Z.jsx)(Q,{label:a(`tokens.today`),value:s(e.today.costUsd),context:a(`tokens.requestsContext`,{count:d(e.today.requests)})}),(0,Z.jsx)(Q,{label:a(`tokens.total`),value:s(e.total.costUsd),context:`${d(e.total.totalTokens,!0)} Token`}),(0,Z.jsx)(Q,{label:a(`tokens.lastUsedTitle`),value:e.lastUsedAt?r(e.lastUsedAt,u):`—`,context:e.lastUsedAt?``:a(`tokens.neverUsed`),title:J}),(0,Z.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(ee,{label:a(`common.more`),icon:(0,Z.jsx)(te,{className:`size-4`}),items:[{id:`settings`,label:a(`tokens.settings`),icon:(0,Z.jsx)(ne,{className:`size-3.5`}),onSelect:i},{id:`toggle`,label:e.enabled?a(`tokens.disable`):a(`tokens.enable`),icon:(0,Z.jsx)(re,{className:`size-3.5`}),onSelect:()=>void W()},{id:`reset`,label:a(`tokens.reset`),icon:(0,Z.jsx)(ie,{className:`size-3.5`}),onSelect:()=>void K()},...e.isDefault?[]:[{id:`delete`,label:a(`tokens.delete`),icon:(0,Z.jsx)(I,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void q()}]]})})]}),D&&(0,Z.jsxs)(`div`,{id:F,className:`border-t border-[var(--border-subtle)] bg-[var(--surface-muted)] px-4 py-3 md:pl-10`,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-wrap gap-x-8 gap-y-2 text-[12px]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:a(`tokens.clients`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1 text-[var(--text-secondary)]`,children:e.clients.length===0?a(`tokens.noClients`):e.clients.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(H,{kind:e,size:14}),z[e]?.name??e]},e))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:e.pool?a(`tokens.pool.title`):a(`tokens.directProvider`)}),e.pool?(0,Z.jsx)(`dd`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[var(--text-secondary)]`,children:e.pool.members.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:N(e.health),children:[(0,Z.jsx)(T,{tone:G(e.health.state)}),(m.data??[]).find(t=>t.id===e.providerId)?.name??e.providerId]},e.providerId))}):(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:A?.name??(e.providerId?e.providerId:a(`tokens.directNone`))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:a(`tokens.allowedClients`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:e.allowedClients==null?a(`tokens.allowedClientsAny`):e.allowedClients.length===0?a(`tokens.directOnly`):e.allowedClients.map(e=>z[e]?.name??e).join(`, `)})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:a(`tokens.lastUsedTitle`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:J})]})]}),(0,Z.jsx)(pe,{token:e}),(0,Z.jsx)(he,{today:e.today,total:e.total}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,Z.jsx)(R,{to:`/tokens/${encodeURIComponent(e.id)}`,children:(0,Z.jsx)(w,{size:`sm`,icon:(0,Z.jsx)(le,{className:`size-3.5`}),children:a(`tokens.detail.open`)})}),(0,Z.jsx)(R,{to:`/requests?token=${encodeURIComponent(e.id)}`,children:(0,Z.jsx)(w,{size:`sm`,icon:(0,Z.jsx)(oe,{className:`size-3.5`}),children:a(`tokens.detail.viewLogs`)})})]})]})]})}function pe({token:e}){let{t}=h(),n=e.limits?.rpm;return(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`tokens.limits`)}),e.limitUsage.length===0&&n==null?(0,Z.jsx)(`div`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t(`tokens.unlimited`)}):(0,Z.jsxs)(`div`,{className:`mt-1.5 grid gap-3 sm:grid-cols-2`,children:[e.limitUsage.map(e=>(0,Z.jsx)(me,{usage:e},`${e.metric}:${e.period}`)),n!=null&&(0,Z.jsxs)(`div`,{className:`text-[11.5px] text-[var(--text-secondary)]`,children:[t(`tokens.rpm`),` · `,(0,Z.jsx)(`span`,{className:`num`,children:t(`tokens.rpmUsage`,{used:e.recentRequests,limit:n})})]})]})]})}function me({usage:e}){let{t:n,locale:r}=h(),i=`${n(`tokens.period.${e.period}`)} · ${n(`tokens.metric.${e.metric}`)}`,a=t=>e.metric===`cost`?s(t):d(t,!0),o=Math.max(0,Math.min(100,Math.round(e.usedPercent))),c=o>=90?`var(--danger)`:o>=70?`var(--warning)`:`var(--accent)`;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[11.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:i}),(0,Z.jsx)(`span`,{className:`num`,children:n(`tokens.limitUsed`,{used:a(e.used),limit:a(e.limit)})})]}),(0,Z.jsx)(`div`,{role:`progressbar`,"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface)]`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${o}%`,background:c}})}),e.resetsAt&&(0,Z.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[var(--text-muted)]`,children:n(`tokens.limitResets`,{time:t(e.resetsAt,r)})})]})}function Q({label:e,value:t,context:n,title:r}){return(0,Z.jsxs)(`div`,{className:`w-24 min-w-0`,title:r,children:[(0,Z.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,Z.jsx)(`div`,{className:`num truncate text-[14px] leading-tight font-semibold`,children:t}),(0,Z.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:n||`\xA0`})]})}function he({today:e,total:t}){let{t:n}=h(),r=[[n(`tokens.today`),e],[n(`tokens.total`),t]],i=`px-3 py-1.5 text-right font-normal whitespace-nowrap text-[var(--text-muted)]`,a=`num px-3 py-1.5 text-right whitespace-nowrap`;return(0,Z.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-[var(--radius-control)] bg-[var(--surface)]`,children:(0,Z.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-[var(--border-subtle)]`,children:[(0,Z.jsx)(`th`,{className:`${i} text-left`}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.cost`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.requests`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.tokens`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.inOut`)}),(0,Z.jsx)(`th`,{className:i,children:n(`tokens.cacheHit`)}),(0,Z.jsx)(`th`,{className:i,title:n(`tokens.tpsContext`),children:n(`tokens.tps`)})]})}),(0,Z.jsx)(`tbody`,{children:r.map(([e,t])=>(0,Z.jsxs)(`tr`,{children:[(0,Z.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-medium whitespace-nowrap text-[var(--text-secondary)]`,children:e}),(0,Z.jsx)(`td`,{className:`${a} font-semibold selectable`,children:s(t.costUsd)}),(0,Z.jsx)(`td`,{className:a,children:d(t.requests)}),(0,Z.jsx)(`td`,{className:a,children:d(t.totalTokens,!0)}),(0,Z.jsxs)(`td`,{className:`${a} text-[var(--text-secondary)]`,children:[d(t.inputTokens,!0),` / `,d(t.outputTokens,!0)]}),(0,Z.jsx)(`td`,{className:a,title:n(`usage.cacheAmounts`,{read:d(t.cacheReadTokens,!0),write:d(t.cacheWriteTokens,!0)}),children:t.cacheHitRate==null?`—`:C(t.cacheHitRate)}),(0,Z.jsx)(`td`,{className:a,children:t.tps==null?`—`:u(t.tps)})]},e))})]})})}function ge(){let{t:e}=h(),t=(x().data??[]).filter(e=>e.enabled);return{providers:t,options:[{value:``,label:e(`tokens.directNone`)},...t.map(e=>({value:e.id,label:e.name}))]}}function _e({open:e,onOpenChange:t}){let{t:n}=h(),{toast:r}=P(),i=D(),{options:a}=ge(),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``);return(0,X.useEffect)(()=>{e&&(s(``),l(``))},[e]),(0,Z.jsx)(N,{open:e,onOpenChange:t,title:n(`tokens.createTitle`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(w,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,Z.jsx)(w,{variant:`primary`,disabled:!o.trim(),loading:i.isPending,onClick:()=>i.mutate({name:o.trim(),providerId:c||null},{onSuccess:e=>{t(!1),r(n(`tokens.created`,{name:e.name}),`success`)},onError:e=>r(j(e),`error`)}),children:n(`common.create`)})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(v,{label:n(`tokens.name`),children:(0,Z.jsx)(g,{value:o,maxLength:64,placeholder:n(`tokens.namePlaceholder`),onChange:e=>s(e.target.value)})}),(0,Z.jsx)(v,{label:n(`tokens.directProvider`),children:(0,Z.jsx)(F,{value:c,onChange:l,options:a})})]})})}function ve({token:e,onClose:t}){let{t:n}=h(),{toast:r}=P(),i=k(),a=x(),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)([]),[p,m]=(0,X.useState)(null),[_,y]=(0,X.useState)(`any`),[b,C]=(0,X.useState)([]),T=new Set(u.map(e=>`${e.metric}:${e.period}`)).size<u.length,E=new Map((e?.pool?.members??[]).map(e=>[e.providerId,e.health]));return(0,X.useEffect)(()=>{e&&(s(e.name),l(K(e)),d(e.limits?.budgets.map(e=>({...e}))??[]),m(e.limits?.rpm??null),y(e.allowedClients==null?`any`:`only`),C(e.allowedClients??[]))},[e]),(0,Z.jsx)(N,{open:e!==null,onOpenChange:e=>!e&&t(),title:n(`tokens.settingsTitle`,{name:e?.name??``}),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(w,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(w,{variant:`primary`,disabled:!o.trim()||T,loading:i.isPending,onClick:()=>{if(!e)return;let s=u.flatMap(e=>e.limit!=null&&e.limit>0?[{...e,limit:e.limit}]:[]),l=s.length>0||p!=null&&p>0?{budgets:s,rpm:p!=null&&p>0?Math.floor(p):null}:null;i.mutate({id:e.id,name:o.trim(),...c?{pool:W(c,a.data??[])}:{},limits:l,allowedClients:_===`any`?null:b},{onSuccess:()=>{t(),r(n(`common.saved`),`success`)},onError:e=>r(j(e),`error`)})},children:n(`common.save`)})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(v,{label:n(`tokens.name`),children:(0,Z.jsx)(g,{value:o,maxLength:64,onChange:e=>s(e.target.value)})}),(0,Z.jsx)(v,{label:n(`tokens.pool.title`),hint:n(`tokens.pool.hint`),children:c&&(0,Z.jsx)(q,{draft:c,onChange:l,providers:a.data??[],health:E})}),(0,Z.jsx)(v,{label:n(`tokens.limits`),hint:n(`tokens.limitsHint`),error:T?n(`tokens.limitDuplicate`):void 0,children:(0,Z.jsx)(be,{budgets:u,onChange:d})}),(0,Z.jsx)(v,{label:n(`tokens.rpm`),hint:n(`tokens.rpmHint`),children:(0,Z.jsx)(S,{value:p,min:1,step:1,label:n(`tokens.rpm`),placeholder:n(`tokens.unlimited`),onChange:m})}),(0,Z.jsx)(v,{label:n(`tokens.allowedClients`),hint:n(`tokens.allowedClientsHint`),children:(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(f,{ariaLabel:n(`tokens.allowedClients`),value:_,onChange:y,items:[{value:`any`,label:n(`tokens.allowedClientsAny`)},{value:`only`,label:n(`tokens.allowedClientsOnly`)}]}),_===`only`&&(0,Z.jsx)(V,{label:n(`tokens.allowedClients`),options:[...new Set([...Object.keys(z),...b])].map(e=>({value:e,label:z[e]?.name??e})),value:b,onValueChange:e=>C(e)})]})})]})})}var $=[`cost`,`requests`,`tokens`],ye=[`day`,`week`,`month`,`total`];function be({budgets:e,onChange:t}){let{t:n}=h(),r=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),i=$.flatMap(e=>ye.map(t=>({metric:e,period:t}))).find(t=>!e.some(e=>e.metric===t.metric&&e.period===t.period));return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[e.length===0&&(0,Z.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`tokens.unlimited`)}),e.map((i,a)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-2`,children:[(0,Z.jsx)(F,{ariaLabel:n(`tokens.limitMetric`),value:i.metric,onChange:e=>r(a,{metric:e}),options:$.map(e=>({value:e,label:n(`tokens.metric.${e}`)}))}),(0,Z.jsx)(F,{ariaLabel:n(`tokens.limitPeriod`),value:i.period,onChange:e=>r(a,{period:e}),options:ye.map(e=>({value:e,label:n(`tokens.period.${e}`)}))}),(0,Z.jsx)(S,{label:n(`tokens.limitValue`),value:i.limit,min:0,step:i.metric===`cost`?`any`:1,placeholder:n(`tokens.limitValue`),onChange:e=>r(a,{limit:e})}),(0,Z.jsx)(w,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(I,{className:`size-3.5`}),"aria-label":n(`tokens.removeLimit`),title:n(`tokens.removeLimit`),onClick:()=>t(e.filter((e,t)=>t!==a))})]},a)),i&&(0,Z.jsx)(`div`,{children:(0,Z.jsx)(w,{size:`sm`,icon:(0,Z.jsx)(U,{className:`size-3.5`}),onClick:()=>t([...e,{...i,limit:null}]),children:n(`tokens.addLimit`)})})]})}export{de as TokensPage};
|