@aidotnet/server-linux-x64 0.9.8 → 0.10.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.
- package/bin/astra-server +2 -2
- package/bin/wwwroot/assets/ClientsPage-C-x5kPpG.js +9 -0
- package/bin/wwwroot/assets/KeyPage-CxvUUC6Z.js +1 -0
- package/bin/wwwroot/assets/ModelDetailPage-CQol60ci.js +1 -0
- package/bin/wwwroot/assets/ModelsPage-Bp1-Rhad.js +1 -0
- package/bin/wwwroot/assets/PluginsPage-YPDqytJ6.js +2 -0
- package/bin/wwwroot/assets/PrivacyPage-Co1ffmVU.js +1 -0
- package/bin/wwwroot/assets/ProviderDetailPage-CacRreeZ.js +3 -0
- package/bin/wwwroot/assets/ProvidersPage-DSwvae35.js +2 -0
- package/bin/wwwroot/assets/SettingsPage-CvIE8pBq.js +2 -0
- package/bin/wwwroot/assets/TokenDetailPage-w1XONN5-.js +1 -0
- package/bin/wwwroot/assets/TokenPoolEditor-BITgITLH.js +1 -0
- package/bin/wwwroot/assets/TokensPage-CiL0dLkj.js +1 -0
- package/bin/wwwroot/assets/{TracesPage-Ckw0m9u0.js → TracesPage-zcvvDcj3.js} +2 -2
- package/bin/wwwroot/assets/TrayPanelPage-BwaSGRbR.js +1 -0
- package/bin/wwwroot/assets/{TrayPanelView-daUwEIRH.js → TrayPanelView-CAF6qwfK.js} +1 -1
- package/bin/wwwroot/assets/alert-BhYHbQ5M.js +15 -0
- package/bin/wwwroot/assets/{arrow-down-BjT6LDhw.js → arrow-down-CHVkKqVB.js} +1 -1
- package/bin/wwwroot/assets/{arrow-left-Bv8IR_At.js → arrow-left-ByzgpjKh.js} +1 -1
- package/bin/wwwroot/assets/{checkbox-DQpzihMp.js → checkbox-B_oHm90b.js} +1 -1
- package/bin/wwwroot/assets/{cloud-download-B7vzhwxM.js → cloud-download-DEv0Zu87.js} +1 -1
- package/bin/wwwroot/assets/confirm-morph-RDk31i1j.js +1 -0
- package/bin/wwwroot/assets/{download-CI3oqkmw.js → download-DXwZa8b6.js} +1 -1
- package/bin/wwwroot/assets/{ellipsis-Br3iFNj9.js → ellipsis-DhvUvMq3.js} +1 -1
- package/bin/wwwroot/assets/{external-link-LUcufY2s.js → external-link-D9cY56rt.js} +1 -1
- package/bin/wwwroot/assets/{folder-open-rO9o554n.js → folder-open-Dt-7Rdbw.js} +1 -1
- package/bin/wwwroot/assets/{index-DE_l9Wt4.css → index-Dt3DJ3Cx.css} +1 -1
- package/bin/wwwroot/assets/index-XVK9epgF.js +17 -0
- package/bin/wwwroot/assets/{log-out-Ggrqw-Tp.js → log-out-wpGBd0OK.js} +1 -1
- package/bin/wwwroot/assets/minus-3JX68qL9.js +1 -0
- package/bin/wwwroot/assets/overlays-CF55BHOs.js +41 -0
- package/bin/wwwroot/assets/{pencil-o6T1_skE.js → pencil-BjMGSY_u.js} +1 -1
- package/bin/wwwroot/assets/{power-BJvJ4uzr.js → power-zBXM8vYz.js} +1 -1
- package/bin/wwwroot/assets/radio-cards-BVdDbnT-.js +1 -0
- package/bin/wwwroot/assets/{rotate-ccw-CqwU1cME.js → rotate-ccw-Omdd6cJU.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-BhxNcP2n.js → sortable.esm-CTCQ-9IR.js} +1 -1
- package/bin/wwwroot/index.html +4 -4
- package/package.json +1 -1
- package/bin/wwwroot/assets/ClientsPage-CMvzWWAq.js +0 -9
- package/bin/wwwroot/assets/KeyPage-C8QfP545.js +0 -1
- package/bin/wwwroot/assets/ModelDetailPage-Dj3Fuga6.js +0 -1
- package/bin/wwwroot/assets/ModelsPage-DIYCYGb2.js +0 -1
- package/bin/wwwroot/assets/PluginsPage-B2nac94b.js +0 -2
- package/bin/wwwroot/assets/PrivacyPage-CeRqlQGU.js +0 -1
- package/bin/wwwroot/assets/ProviderDetailPage-DWy8CIbx.js +0 -3
- package/bin/wwwroot/assets/ProvidersPage-CeisTEUC.js +0 -2
- package/bin/wwwroot/assets/SettingsPage-Bcv3aAmF.js +0 -2
- package/bin/wwwroot/assets/TokenDetailPage-B9WJQ1HP.js +0 -1
- package/bin/wwwroot/assets/TokenPoolEditor-D8mQHyNt.js +0 -1
- package/bin/wwwroot/assets/TokensPage-Cx1hPs0r.js +0 -1
- package/bin/wwwroot/assets/TrayPanelPage-BfD_xXkg.js +0 -1
- package/bin/wwwroot/assets/alert-BzjF81CS.js +0 -15
- package/bin/wwwroot/assets/confirm-morph-BOdW6fKN.js +0 -1
- package/bin/wwwroot/assets/index-D7HIE1TG.js +0 -17
- package/bin/wwwroot/assets/minus-2zK3DUtq.js +0 -1
- package/bin/wwwroot/assets/overlays-8ByMRpma.js +0 -41
- package/bin/wwwroot/assets/radio-cards-CWiI0xhT.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$r as e,$t as t,Ai as n,Ca as r,Ci as i,Cn as a,Cr as o,Ct as s,Dn as c,E as l,Ea as u,Gr as d,It as f,Lt as p,Mi as m,Mt as h,Nt as g,Or as _,Pi as v,Pt as y,Qr as b,Sa as x,Si as S,U as C,Ur as w,V as T,Vr as E,Vt as ee,Yt as D,Zr as O,_ as te,_i as k,ar as ne,bi as re,cn as ie,d as A,di as ae,en as oe,ft as se,hi as ce,i as le,ji as ue,ki as j,l as M,m as N,mi as de,n as P,nr as fe,o as pe,oi as me,ot as F,p as he,pi as ge,pt as I,r as L,s as _e,si as ve,sn as ye,t as be,u as R,ui as xe,v as z,vr as Se,vt as B,wi as Ce,wr as we,xa as V,y as H,yi as Te}from"./alert-BzjF81CS.js";import{B as Ee,F as De,I as Oe,L as ke,R as Ae,a as U,gt as W,i as je,n as Me,o as G,r as K,vt as q,z as Ne}from"./overlays-8ByMRpma.js";import{t as Pe}from"./TrayPanelView-daUwEIRH.js";import{t as Fe}from"./download-CI3oqkmw.js";import{t as Ie}from"./ellipsis-Br3iFNj9.js";import{t as Le}from"./external-link-LUcufY2s.js";import{n as Re,t as ze}from"./radio-cards-CWiI0xhT.js";import{t as Be}from"./folder-open-rO9o554n.js";import{t as Ve}from"./log-out-Ggrqw-Tp.js";import{t as He}from"./minus-2zK3DUtq.js";import{t as Ue}from"./pencil-o6T1_skE.js";import{t as We}from"./rotate-ccw-CqwU1cME.js";import{B as Ge,C as Ke,E as qe,L as Je,N as Ye,Q as Xe,R as J,T as Ze,Z as Qe,h as $e,n as et,s as tt,t as nt,tt as rt,w as it}from"./index-D7HIE1TG.js";var at={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};at.node;var ot=B(at),st={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};st.node;var ct=B(st),lt={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};lt.node;var ut=B(lt),dt={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};dt.node;var ft=B(dt),pt={name:`panel-top`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};pt.node;var mt=B(pt),ht={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};ht.node;var gt=B(ht),_t={name:`webhook`,size:24,node:[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]};_t.node;var vt=B(_t),Y=u(r(),1),X=x(),yt=`https://astra-gate.si/docs/guide/remote-access`,bt=`astra.remote.acknowledged`;function xt(e,t){return e.mode===`named`&&!e.hasToken?t(`settings.remote.block.token`):e.mode===`named`&&!e.hostname?t(`settings.remote.block.hostname`):e.allowAdmin&&!e.checks.passwordSet?t(`settings.remote.block.password`):e.checks.blocker??null}function St(e,t,n){return/can no longer be read/i.test(e)?n(`settings.remote.err.tokenLost`):/downloading cloudflared|checksum/i.test(e)?n(`settings.remote.err.download`):/unauthorized|invalid tunnel secret|token.*(invalid|not valid|malformed)/i.test(e)?n(`settings.remote.err.token`):/origin service|origin server/i.test(e)?n(`settings.remote.err.origin`,{origin:t.originUrl}):/429|too many requests|rate.?limit/i.test(e)?n(`settings.remote.err.rate`):/dial|timeout|timed out|no such host|unreachable|quic|edge/i.test(e)?n(`settings.remote.err.network`):n(`settings.remote.err.generic`)}function Ct(){try{return localStorage.getItem(bt)===`1`}catch{return!1}}function wt(){try{localStorage.setItem(bt,`1`)}catch{}}function Tt(){let{t:e}=F(),t=O(),n=t.data;return n?n.supported?(0,X.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[(0,X.jsx)(Et,{s:n}),(0,X.jsx)(Dt,{s:n}),(0,X.jsx)(Ot,{s:n}),(0,X.jsx)(jt,{s:n}),(0,X.jsx)(pe,{title:n.cloudflared.path&&n.cloudflared.version?e(`settings.remote.logWithVersion`,{version:n.cloudflared.version}):e(`settings.remote.log`),children:n.log.length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:e(`settings.remote.logEmpty`)}):(0,X.jsx)(`pre`,{className:`max-h-72 overflow-auto font-mono text-[10.5px] leading-relaxed whitespace-pre-wrap text-[var(--text-secondary)] selectable`,children:n.log.join(`
|
|
2
|
-
`)})})]}):(0,X.jsx)(`div`,{className:`mx-auto max-w-[680px]`,children:(0,X.jsx)(be,{tone:`info`,title:e(`settings.remote.unsupported`),children:e(`settings.remote.unsupportedDetail`)})}):(0,X.jsx)(`div`,{className:`mx-auto max-w-[680px]`,children:t.isError?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:U(t.error)}):(0,X.jsx)(z,{className:`mx-auto my-8`})})}function Et({s:e}){let{t,locale:n}=F(),{toast:r,confirm:i}=G(),a=w(),o=f(),s=xt(e,t),c=async e=>{await W.copy(e)&&r(t(`common.copied`))},l=async e=>{if(e&&!Ct()){if(!await i({title:t(`settings.remote.enableConfirm`),detail:t(`settings.remote.enableDetail`),confirmLabel:t(`settings.remote.enableAction`)}))return;wt()}(e||!o.data?.remote||await i({title:t(`settings.remote.disableSelfConfirm`),detail:t(`settings.remote.disableSelfDetail`),confirmLabel:t(`settings.remote.disableAction`),destructive:!0}))&&a.mutate(e,{onError:e=>r(U(e),`error`)})},u=e.state===`connected`?`green`:e.state===`off`?`neutral`:`orange`,d=e.connectedAt?Date.now()-new Date(e.connectedAt).getTime():null,p=e.state===`connected`&&d!==null?d<6e4?t(`settings.remote.connectedJustNow`):t(`settings.remote.connectedFor`,{duration:C(d,n)}):e.state===`downloading`&&e.cloudflared.source?t(`settings.remote.state.downloadingFrom`,{source:e.cloudflared.source}):t(`settings.remote.state.${e.state}`),m=e.cloudflared,h=m.downloading||m.path?null:m.asset?t(`settings.remote.cloudflaredMissing`,{version:m.version??``}):t(`settings.remote.cloudflaredUnsupported`),g=e.enabled?e.error??m.error??null:null,_=g!==null&&(e.state!==`connected`||/origin service|origin server/i.test(g)),v=e.publicUrl;return(0,X.jsxs)(R,{title:t(`settings.remote.status`),footer:t(`settings.remote.statusFooter`),children:[(0,X.jsx)(N,{label:t(`settings.remote.enable`),detail:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:e.connectedAt?T(e.connectedAt,n):void 0,children:[(0,X.jsx)(_e,{tone:u}),p,m.downloading&&m.progress!=null&&(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(m.progress*100),`%`]})]}),children:(0,X.jsx)(H,{checked:e.enabled,label:t(`settings.remote.enable`),disabled:a.isPending||!e.enabled&&s!==null,onChange:e=>void l(e)})}),!e.enabled&&s&&(0,X.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--warning)]`,children:s}),!e.enabled&&!s&&h&&(0,X.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--text-muted)]`,children:h}),e.enabled&&v&&(0,X.jsxs)(N,{label:t(`settings.remote.publicUrl`),detail:(0,X.jsx)(`span`,{className:`font-mono selectable`,children:`${v}/v1`}),children:[(0,X.jsx)(Me,{label:t(`settings.remote.copyMenu`),icon:(0,X.jsx)(I,{className:`size-3.5`}),iconOnly:!0,items:[{id:`openai`,label:t(`settings.remote.copy.openai`),onSelect:()=>void c(`${v}/v1`)},{id:`anthropic`,label:t(`settings.remote.copy.anthropic`),onSelect:()=>void c(v)},{id:`key`,label:t(`settings.remote.copy.key`),onSelect:()=>void c(`${v}/key`),separatorBefore:!0}]}),(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Le,{className:`size-3.5`}),"aria-label":t(`settings.remote.openPage`),title:t(`settings.remote.openPage`),onClick:()=>window.open(v,`_blank`,`noopener`)})]}),e.enabled&&v&&(0,X.jsx)(`p`,{className:`px-4 py-2 text-[11px] text-[var(--text-muted)]`,children:t(`settings.remote.publicUrlHint`)}),_&&(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(be,{tone:e.state===`connected`?`warning`:`danger`,title:St(g,e,t),children:g})})]})}function Dt({s:e}){let{t}=F(),{toast:n,confirm:r}=G(),i=xe(),[a,o]=(0,Y.useState)({token:``,hostname:e.hostname??``});(0,Y.useEffect)(()=>o(t=>({...t,hostname:e.hostname??``})),[e.hostname]);let s=async e=>{await W.copy(e)&&n(t(`common.copied`))},c=async a=>{if(e.enabled){let n=a===`named`&&(!e.hasToken||!e.hostname);if(!await r({title:t(`settings.remote.modeSwitchConfirm`),detail:t(n?`settings.remote.modeSwitchStopDetail`:`settings.remote.modeSwitchDetail`),confirmLabel:t(`settings.remote.modeSwitchAction`),destructive:n}))return}i.mutate({mode:a},{onError:e=>n(U(e),`error`)})},l=()=>i.mutate({hostname:a.hostname.trim()||null,...a.token.trim()?{token:a.token.trim()}:{}},{onSuccess:e=>{n(e.enabled?t(`settings.remote.savedRestart`):t(`settings.remote.saved`)),o(e=>({...e,token:``}))},onError:e=>n(U(e),`error`)}),u=a.token.trim()!==``||a.hostname.trim()!==(e.hostname??``);return(0,X.jsxs)(R,{title:t(`settings.remote.mode`),footer:e.mode===`named`?t(`settings.remote.namedFooter`):void 0,children:[(0,X.jsx)(N,{label:t(`settings.remote.modeLabel`),detail:t(`settings.remote.mode.${e.mode}.hint`),children:(0,X.jsx)(te,{ariaLabel:t(`settings.remote.modeLabel`),value:e.mode,onChange:e=>void c(e),items:[{value:`quick`,label:t(`settings.remote.mode.quick`)},{value:`named`,label:t(`settings.remote.mode.named`)}]})}),e.mode===`quick`?(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(be,{tone:`warning`,title:t(`settings.remote.quickWarning`)})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.remote.token`),detail:e.hasToken?t(`settings.remote.tokenSaved`):t(`settings.remote.tokenHint`),children:(0,X.jsx)(A,{className:`w-64`,type:`password`,autoComplete:`off`,mono:!0,"aria-label":t(`settings.remote.token`),placeholder:e.hasToken?`••••••••`:`eyJhIjoi…`,value:a.token,onChange:e=>o({...a,token:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.remote.hostname`),detail:t(`settings.remote.hostnameHint`),children:(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.remote.hostname`),placeholder:`astra.example.com`,value:a.hostname,onChange:e=>o({...a,hostname:e.target.value})})}),(0,X.jsxs)(N,{label:t(`settings.remote.origin`),detail:t(`settings.remote.originHint`),children:[(0,X.jsx)(`span`,{className:`font-mono text-[12px] selectable`,children:e.originUrl}),(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(I,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void s(e.originUrl)})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2`,children:[(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(ut,{className:`size-3.5`}),onClick:()=>window.open(yt,`_blank`,`noopener`),children:t(`settings.remote.guide`)}),(0,X.jsx)(L,{size:`sm`,disabled:!u||i.isPending,onClick:l,children:t(`common.save`)})]})]})]})}function Ot({s:e}){let{t}=F(),{toast:n,confirm:r}=G(),i=xe(),a=f(),o=async e=>{(!e||await r({title:t(`settings.remote.adminConfirm`),detail:t(`settings.remote.adminDetail`),confirmLabel:t(`settings.remote.adminAction`),destructive:!0}))&&(e||!a.data?.remote||await r({title:t(`settings.remote.adminOffSelfConfirm`),detail:t(`settings.remote.adminOffSelfDetail`),confirmLabel:t(`settings.remote.disableAction`),destructive:!0}))&&i.mutate({allowAdmin:e},{onError:e=>n(U(e),`error`)})};return(0,X.jsxs)(R,{title:t(`settings.remote.scope`),footer:t(`settings.remote.scopeFooter`),children:[(0,X.jsx)(N,{label:t(`settings.remote.scope.gateway`),detail:t(`settings.remote.scope.gatewayHint`),children:(0,X.jsx)(P,{tone:`green`,children:t(`settings.remote.scope.gatewayBadge`)})}),(0,X.jsx)(N,{label:t(`settings.remote.scope.admin`),detail:e.checks.passwordSet?t(`settings.remote.scope.adminHint`):t(`settings.remote.block.password`),children:(0,X.jsx)(H,{checked:e.allowAdmin,label:t(`settings.remote.scope.admin`),disabled:i.isPending||!e.allowAdmin&&!e.checks.passwordSet,onChange:e=>void o(e)})}),(0,X.jsx)(kt,{passwordSet:e.checks.passwordSet})]})}function kt({passwordSet:e}){let{t}=F(),{toast:n}=G(),r=f(),i=o(),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(``);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.remote.password`),detail:t(e?`settings.remote.passwordSet`:`settings.remote.passwordMissing`),children:!a&&!r.data?.required&&(0,X.jsx)(L,{size:`sm`,onClick:()=>s(!0),children:t(e?`settings.remote.passwordChange`:`settings.remote.passwordSetAction`)})}),a&&(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2`,children:[(0,X.jsx)(A,{className:`w-64`,type:`password`,autoComplete:`new-password`,autoFocus:!0,"aria-label":t(`settings.remote.passwordNew`),placeholder:t(`settings.remote.passwordNew`),value:c,onChange:e=>l(e.target.value)}),(0,X.jsx)(L,{size:`sm`,variant:`plain`,onClick:()=>s(!1),children:t(`common.cancel`)}),(0,X.jsx)(L,{size:`sm`,variant:`primary`,disabled:c.length<8,loading:i.isPending,onClick:()=>i.mutate(c,{onSuccess:()=>{n(t(`settings.remote.passwordSaved`)),s(!1),l(``)},onError:e=>n(U(e),`error`)}),children:t(`common.save`)})]})]})}var At=[`auto`,`github`,`astra`,`custom`];function jt({s:e}){let{t}=F(),{toast:n}=G(),r=xe(),i=ie(),a=f(),o=e.cloudflared,[s,c]=(0,Y.useState)(e.download.downloadBaseUrl??``),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)(``);(0,Y.useEffect)(()=>c(e.download.downloadBaseUrl??``),[e.download.downloadBaseUrl]);let[m,h]=(0,Y.useState)(e.download.downloadSource);(0,Y.useEffect)(()=>h(e.download.downloadSource),[e.download.downloadSource]);let g=(e,i)=>r.mutate(e,{onSuccess:()=>{n(t(`settings.remote.cf.saved`)),i?.()},onError:e=>n(U(e),`error`)}),_=t=>{h(t),(t!==`custom`||e.download.downloadBaseUrl)&&g({downloadSource:t})},v=()=>i.mutate(void 0,{onSuccess:e=>e.path?p(e.path):n(t(`settings.remote.cf.detectNone`)),onError:e=>n(U(e),`error`)}),y=o.fromEnvironment?t(`settings.remote.cf.fromEnv`):o.installed?o.version?t(`settings.remote.cf.installedProgram`,{version:o.version}):t(`settings.remote.cf.installedUnknown`):o.path?t(`settings.remote.cf.downloaded`,{version:o.version??``}):o.asset?t(`settings.remote.cf.notDownloaded`,{version:o.version??``}):t(`settings.remote.cloudflaredUnsupported`);return(0,X.jsxs)(R,{title:`cloudflared`,footer:t(`settings.remote.cf.footer`),children:[(0,X.jsx)(N,{label:t(`settings.remote.cf.program`),detail:(0,X.jsx)(`span`,{title:o.path??void 0,children:y}),children:(0,X.jsx)(_e,{tone:o.path?`green`:o.asset?`neutral`:`red`})}),!e.download.cloudflaredPath&&!o.fromEnvironment&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.remote.cf.source`),detail:t(`settings.remote.cf.source.${m}.hint`),children:(0,X.jsx)(K,{className:`w-44`,ariaLabel:t(`settings.remote.cf.source`),value:m,onChange:_,options:At.map(e=>({value:e,label:t(`settings.remote.cf.source.${e}`)}))})}),m===`custom`&&(0,X.jsxs)(N,{label:t(`settings.remote.cf.baseUrl`),detail:t(`settings.remote.cf.baseUrlHint`),children:[(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.remote.cf.baseUrl`),placeholder:`https://…/cloudflare/cloudflared/releases/download`,value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(L,{size:`sm`,disabled:!s.trim()||r.isPending||s.trim()===(e.download.downloadBaseUrl??``)&&e.download.downloadSource===`custom`,onClick:()=>g({downloadSource:`custom`,downloadBaseUrl:s.trim()}),children:t(`common.save`)})]})]}),!a.data?.remote&&!o.fromEnvironment&&(0,X.jsx)(N,{label:t(`settings.remote.cf.installed`),detail:e.download.cloudflaredPath?(0,X.jsx)(`span`,{className:`font-mono selectable`,children:e.download.cloudflaredPath}):t(`settings.remote.cf.installedHint`),children:e.download.cloudflaredPath?(0,X.jsx)(L,{size:`sm`,disabled:r.isPending,onClick:()=>g({cloudflaredPath:``}),children:t(`settings.remote.cf.useDownloaded`)}):!l&&(0,X.jsx)(L,{size:`sm`,onClick:()=>{u(!0),v()},children:t(`settings.remote.cf.choose`)})}),l&&!e.download.cloudflaredPath&&(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2`,children:[(0,X.jsx)(A,{className:`w-72`,mono:!0,autoFocus:!0,"aria-label":t(`settings.remote.cf.installedPath`),placeholder:t(`settings.remote.cf.installedPath`),value:d,onChange:e=>p(e.target.value)}),(0,X.jsx)(L,{size:`sm`,variant:`plain`,loading:i.isPending,onClick:v,children:t(`settings.remote.cf.detect`)}),(0,X.jsx)(L,{size:`sm`,variant:`plain`,onClick:()=>u(!1),children:t(`common.cancel`)}),(0,X.jsx)(L,{size:`sm`,variant:`primary`,disabled:!d.trim(),loading:r.isPending,onClick:()=>g({cloudflaredPath:d.trim()},()=>u(!1)),children:t(`settings.remote.cf.use`)})]})]})}var Mt=[`127.0.0.1`,`localhost`,`::1`,`[::1]`],Nt={local:`127.0.0.1`,lan:`0.0.0.0`},Pt=e=>Mt.includes(e)?`local`:`lan`;function Ft(){let{t}=F(),{toast:n,confirm:r}=G(),o=V(),s=a(),c=f(),l=e(),[u,d]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),h=s.data;if(!h)return(0,X.jsx)(N,{label:t(`settings.listen`),detail:s.isError?U(s.error):void 0,children:s.isPending&&(0,X.jsx)(z,{className:`size-3.5`})});let g=`${h.host}:${h.port}`,_=Pt(h.configuredHost),v=h.configuredHost!==h.host,y=!!c.data?.required,b=async e=>{await W.copy(e)&&n(t(`common.copied`))},x=e=>l.mutate(Nt[e],{onSuccess:e=>e.configuredHost!==e.host&&n(t(`settings.listen.saved`)),onError:e=>n(U(e),`error`)}),S=async e=>{if(e!==_){if(e===`lan`){if(!h.passwordSet){d(!0);return}if(!await r({title:t(`settings.listen.lanConfirm`),detail:t(`settings.listen.lanDetail`),confirmLabel:t(`settings.listen.lanAction`)}))return}x(e)}},C=async()=>{m(!0);let e=await W.restartService();if(m(!1),e){if(!e.ok){n(e.error??t(`common.error`),`error`);return}n(t(`settings.listen.restarted`)),o.invalidateQueries()}},w=h.hostFromEnvironment?t(`settings.listen.env`,{address:g}):y?t(`settings.listen.localOnly`,{address:g}):v?`${t(`settings.listen.pending`,{host:h.configuredHost})}${i?``:` · ${t(`settings.listen.restartHint`)}`}`:g;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.listen`),detail:w,children:!h.hostFromEnvironment&&!y&&(0,X.jsxs)(X.Fragment,{children:[v&&i&&(0,X.jsx)(L,{size:`sm`,loading:p,onClick:()=>void C(),children:t(`settings.listen.restart`)}),(0,X.jsx)(te,{ariaLabel:t(`settings.listen`),value:_,onChange:e=>void S(e),items:[{value:`local`,label:t(`settings.listen.local`)},{value:`lan`,label:t(`settings.listen.lan`)}]})]})}),h.networkUrls.map(e=>(0,X.jsx)(N,{label:t(`settings.listen.networkUrl`),detail:`${e}/v1`,children:(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(I,{className:`size-3.5`}),"aria-label":t(`common.copy`),onClick:()=>void b(`${e}/v1`)})},e)),(_===`lan`||h.networkUrls.length>0)&&(0,X.jsx)(kt,{passwordSet:h.passwordSet}),(0,X.jsx)(It,{open:u,onOpenChange:d,onSaved:()=>x(`lan`)})]})}function It({open:e,onOpenChange:t,onSaved:n}){let{t:r}=F(),{toast:i}=G(),a=o(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),d=l!==``&&l!==s,f=s.length>=8&&s===l,p=e=>{e||(c(``),u(``)),t(e)},m=()=>{f&&!a.isPending&&a.mutate(s,{onSuccess:()=>{i(r(`settings.remote.passwordSaved`)),p(!1),n()},onError:e=>i(U(e),`error`)})};return(0,X.jsx)(je,{open:e,onOpenChange:p,title:r(`settings.listen.passwordTitle`),description:r(`settings.listen.passwordDetail`),width:420,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:()=>p(!1),children:r(`common.cancel`)}),(0,X.jsx)(L,{variant:`primary`,disabled:!f,loading:a.isPending,onClick:m,children:r(`settings.listen.passwordAction`)})]}),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsx)(A,{type:`password`,autoComplete:`new-password`,autoFocus:!0,"aria-label":r(`settings.remote.passwordNew`),placeholder:r(`settings.remote.passwordNew`),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(A,{type:`password`,autoComplete:`new-password`,"aria-label":r(`settings.listen.passwordRepeat`),placeholder:r(`settings.listen.passwordRepeat`),invalid:d,value:l,onChange:e=>u(e.target.value)}),d&&(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:r(`settings.listen.passwordMismatch`)}),(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`settings.listen.lanDetail`)}),(0,X.jsx)(`button`,{type:`submit`,hidden:!0})]})})}var Lt=[`generic`,`feishu`,`dingtalk`,`wecom`,`slack`,`discord`],Rt={generic:`https://`,feishu:`https://open.feishu.cn/open-apis/bot/v2/hook/…`,dingtalk:`https://oapi.dingtalk.com/robot/send?access_token=…`,wecom:`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=…`,slack:`https://hooks.slack.com/services/…`,discord:`https://discord.com/api/webhooks/…`},zt=e=>e===`feishu`||e===`dingtalk`,Bt=(e,t)=>e(`alerts.event.${t}`),Vt=(e,t)=>e(`alerts.event.${t}.hint`);function Ht(){return(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(Ut,{}),(0,X.jsx)(Wt,{}),(0,X.jsx)(Yt,{})]})}function Ut(){let{t:e,locale:t}=F(),n=y(!0);return(0,X.jsxs)(R,{title:e(`alerts.firing`),children:[n.isLoading&&(0,X.jsx)(z,{}),n.data?.length===0&&(0,X.jsx)(N,{label:(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:e(`alerts.firing.empty`)})}),n.data?.map(n=>(0,X.jsx)(N,{icon:(0,X.jsx)(ot,{className:`size-4 text-[var(--danger)]`}),label:`${Bt(e,n.event)} · ${n.subjectName}`,detail:`${n.ruleName} · ${T(n.changedAt,t)}`},`${n.ruleId}:${n.subjectId}`))]})}function Wt(){let{t:e}=F(),{toast:t,confirm:n}=G(),r=ce(),i=ye(),a=E(),o=Se(),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),p=n=>a.mutate(n.id,{onSuccess:n=>n.status===`success`?t(e(`alerts.webhooks.testOk`,{status:n.httpStatus??``}),`success`):t(e(`alerts.webhooks.testFailed`,{error:n.error??n.status}),`error`),onError:e=>t(U(e),`error`)}),m=async r=>{await n({title:e(`alerts.webhooks.resetSecretConfirm`,{name:r.name}),detail:e(`alerts.webhooks.resetSecretDetail`),confirmLabel:e(`alerts.webhooks.resetSecret`),destructive:!0})&&o.mutate(r.id,{onSuccess:e=>f(e.secret??null),onError:e=>t(U(e),`error`)})},h=async r=>{await n({title:e(`alerts.webhooks.deleteConfirm`,{name:r.name}),detail:e(`alerts.webhooks.deleteDetail`),confirmLabel:e(`common.delete`),destructive:!0})&&i.mutate(r.id,{onSuccess:()=>t(e(`alerts.webhooks.deleted`,{name:r.name})),onError:e=>t(U(e),`error`)})};return(0,X.jsxs)(R,{title:e(`alerts.webhooks`),footer:e(`alerts.webhooks.hint`),children:[r.isLoading&&(0,X.jsx)(z,{}),r.data?.length===0&&(0,X.jsx)(N,{label:(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:e(`alerts.webhooks.empty`)})}),r.data?.map(t=>(0,X.jsxs)(N,{icon:(0,X.jsx)(vt,{className:`size-4 text-[var(--text-muted)]`}),label:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[t.name,!t.enabled&&(0,X.jsx)(P,{tone:`orange`,children:e(`alerts.webhooks.disabledBadge`)}),t.format!==`generic`&&(0,X.jsx)(P,{tone:`accent`,children:e(`alerts.webhooks.format.${t.format}`)}),!t.hasSecret&&(t.format===`generic`||zt(t.format))&&(0,X.jsx)(P,{children:e(`alerts.webhooks.unsigned`)})]}),detail:(0,X.jsx)(`span`,{className:`font-mono selectable`,children:t.url}),children:[(0,X.jsx)(L,{size:`sm`,icon:(0,X.jsx)(Re,{className:`size-3.5`}),loading:a.isPending&&a.variables===t.id,onClick:()=>p(t),children:e(`alerts.webhooks.test`)}),(0,X.jsx)(Me,{label:e(`common.more`),icon:(0,X.jsx)(Ie,{className:`size-4`}),items:[{id:`edit`,label:e(`alerts.webhooks.edit`),icon:(0,X.jsx)(Ue,{className:`size-3.5`}),onSelect:()=>c(t)},{id:`deliveries`,label:e(`alerts.webhooks.deliveries`),icon:(0,X.jsx)(ft,{className:`size-3.5`}),onSelect:()=>u(t)},{id:`secret`,label:e(`alerts.webhooks.resetSecret`),icon:(0,X.jsx)(Ge,{className:`size-3.5`}),onSelect:()=>void m(t)},{id:`delete`,label:e(`common.delete`),icon:(0,X.jsx)(Ye,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void h(t)}]})]},t.id)),(0,X.jsx)(`div`,{className:`px-4 py-2`,children:(0,X.jsx)(L,{size:`sm`,icon:(0,X.jsx)(J,{className:`size-3.5`}),onClick:()=>c(`new`),children:e(`alerts.webhooks.add`)})}),(0,X.jsx)(Gt,{hook:s,onClose:()=>c(null),onSecret:f}),(0,X.jsx)(qt,{hook:l,onClose:()=>u(null)}),(0,X.jsx)(Kt,{secret:d,onClose:()=>f(null)})]})}function Gt({hook:e,onClose:n,onSecret:r}){let{t:i}=F(),{toast:a}=G(),o=t(),s=ae(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(10),[m,h]=(0,Y.useState)(!0),[g,_]=(0,Y.useState)(!0),[v,y]=(0,Y.useState)(!0),[b,x]=(0,Y.useState)(`generic`),[S,C]=(0,Y.useState)(``),[w,T]=(0,Y.useState)([]),E=e===`new`;return(0,Y.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;l(t?.name??``),d(t?.url??``),p(t?.timeoutSec??10),h(t?.useProxy??!0),_(t?.enabled??!0),y(!t||t.hasSecret),x(t?.format??`generic`),C(``),T((t?.headerNames??[]).map(e=>({name:e,value:``,stored:!0})))},[e]),(0,X.jsx)(je,{open:e!==null,onOpenChange:e=>!e&&n(),title:i(E?`alerts.webhooks.add`:`alerts.webhooks.edit`),width:540,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:n,children:i(`common.cancel`)}),(0,X.jsx)(L,{variant:`primary`,disabled:!c.trim()||!u.trim(),loading:o.isPending||s.isPending,onClick:()=>{let t=Object.fromEntries(w.filter(e=>e.name.trim()).map(e=>[e.name.trim(),e.value])),l={name:c.trim(),url:u.trim(),timeoutSec:f??10,useProxy:m,enabled:g,headers:Object.keys(t).length>0?t:null},d={onError:e=>a(U(e),`error`)},p=!E&&e!==null&&e.format!==b,h=zt(b)?v?S.trim()||void 0:``:void 0;E?o.mutate({...l,format:b,...b===`generic`?{signed:v}:h?{secret:h}:{}},{...d,onSuccess:e=>{n(),e.secret&&r(e.secret)}}):e&&s.mutate({id:e.id,...l,...p?{format:b}:{},...b===`generic`?v||!e.hasSecret||p?{}:{signed:!1}:h===void 0?{}:{secret:h}},{...d,onSuccess:()=>{n(),a(i(`common.saved`),`success`)}})},children:i(`common.save`)})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(M,{label:i(`alerts.webhooks.name`),children:(0,X.jsx)(A,{value:c,maxLength:64,onChange:e=>l(e.target.value)})}),(0,X.jsx)(M,{label:i(`alerts.webhooks.format`),hint:i(`alerts.webhooks.format.${b}.hint`),children:(0,X.jsx)(K,{ariaLabel:i(`alerts.webhooks.format`),value:b,onChange:t=>{x(t),y(t===`generic`||e!==`new`&&e!==null&&e.format===t&&e.hasSecret||zt(t))},options:Lt.map(e=>({value:e,label:i(`alerts.webhooks.format.${e}`)}))})}),(0,X.jsx)(M,{label:i(`alerts.webhooks.url`),children:(0,X.jsx)(A,{mono:!0,value:u,placeholder:Rt[b],onChange:e=>d(e.target.value)})}),zt(b)&&v&&(0,X.jsx)(M,{label:i(`alerts.webhooks.botSecret`),hint:i(`alerts.webhooks.botSecretHint`),children:(0,X.jsx)(A,{mono:!0,type:`password`,autoComplete:`off`,value:S,placeholder:e!==`new`&&e!==null&&e.format===b&&e.hasSecret?i(`alerts.webhooks.headerKept`):`SEC…`,onChange:e=>C(e.target.value)})}),(0,X.jsx)(M,{label:i(`alerts.webhooks.timeout`),children:(0,X.jsx)(he,{value:f,min:1,step:1,label:i(`alerts.webhooks.timeout`),onChange:p})}),(0,X.jsx)(M,{label:i(`alerts.webhooks.headers`),hint:i(`alerts.webhooks.headersHint`),children:(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[w.map((e,t)=>(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto] items-center gap-2`,children:[(0,X.jsx)(A,{mono:!0,"aria-label":i(`alerts.webhooks.headerName`),placeholder:i(`alerts.webhooks.headerName`),value:e.name,onChange:e=>T(w.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,X.jsx)(A,{mono:!0,"aria-label":i(`alerts.webhooks.headerValue`),placeholder:e.stored?i(`alerts.webhooks.headerKept`):i(`alerts.webhooks.headerValue`),value:e.value,onChange:e=>T(w.map((n,r)=>r===t?{...n,value:e.target.value}:n))}),(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Ye,{className:`size-3.5`}),"aria-label":i(`common.delete`),onClick:()=>T(w.filter((e,n)=>n!==t))})]},t)),(0,X.jsx)(`div`,{children:(0,X.jsx)(L,{size:`sm`,icon:(0,X.jsx)(J,{className:`size-3.5`}),onClick:()=>T([...w,{name:``,value:``,stored:!1}]),children:i(`alerts.webhooks.addHeader`)})})]})}),(0,X.jsxs)(`div`,{className:`card divide-y divide-[var(--border)]`,children:[(0,X.jsx)(N,{label:i(`alerts.webhooks.enabled`),children:(0,X.jsx)(H,{checked:g,label:i(`alerts.webhooks.enabled`),onChange:_})}),(0,X.jsx)(N,{label:i(`alerts.webhooks.useProxy`),detail:i(`alerts.webhooks.useProxyHint`),children:(0,X.jsx)(H,{checked:m,label:i(`alerts.webhooks.useProxy`),onChange:h})}),(b===`generic`?E||e!==null&&e.format===`generic`&&e.hasSecret:zt(b))&&(0,X.jsx)(N,{label:i(`alerts.webhooks.signed`),detail:i(b===`generic`?`alerts.webhooks.signedHint`:`alerts.webhooks.botSignedHint`),children:(0,X.jsx)(H,{checked:v,label:i(`alerts.webhooks.signed`),onChange:y})})]})]})})}function Kt({secret:e,onClose:t}){let{t:n}=F(),{toast:r}=G();return(0,X.jsx)(je,{open:e!==null,onOpenChange:e=>!e&&t(),title:n(`alerts.webhooks.secretTitle`),description:n(`alerts.webhooks.secretShown`),footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:async()=>e&&await W.copy(e)&&r(n(`common.copied`)),children:n(`common.copy`)}),(0,X.jsx)(L,{variant:`primary`,onClick:t,children:n(`common.done`)})]}),children:(0,X.jsx)(`code`,{className:`block rounded-[var(--radius-control)] bg-[var(--surface-muted)] p-3 font-mono text-[12px] break-all selectable`,children:e})})}function qt({hook:e,onClose:t}){let{t:n,locale:r}=F(),{toast:i}=G(),a=de(e?.id),o=ne(),s={success:`green`,pending:`orange`,failed:`red`};return(0,X.jsxs)(je,{open:e!==null,onOpenChange:e=>!e&&t(),title:`${n(`alerts.webhooks.deliveries`)} · ${e?.name??``}`,width:640,children:[a.isLoading&&(0,X.jsx)(z,{lines:4}),a.data?.length===0&&(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`alerts.delivery.empty`)}),(0,X.jsx)(`div`,{className:`grid max-h-[60vh] gap-2 overflow-y-auto`,children:a.data?.map(e=>(0,X.jsxs)(`details`,{className:`rounded-[var(--radius-control)] bg-[var(--surface-muted)] px-3 py-2 text-[12px]`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-default flex-wrap items-center gap-2`,children:[(0,X.jsx)(P,{tone:s[e.status],children:n(`alerts.delivery.status.${e.status}`)}),(0,X.jsx)(`span`,{children:e.event===`test`?n(`alerts.webhooks.test`):Bt(n,e.event)}),(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:T(e.createdAt,r)}),(0,X.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[e.httpStatus?`HTTP ${e.httpStatus}`:``,` `,e.error&&e.status!==`success`?e.error:``]}),(0,X.jsx)(`span`,{className:`ml-auto text-[var(--text-muted)]`,children:e.status===`pending`&&e.nextAttemptAt?n(`alerts.delivery.next`,{time:T(e.nextAttemptAt,r)}):n(`alerts.delivery.attempts`,{count:e.attempts})})]}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:n(`alerts.delivery.payload`)}),(0,X.jsx)(le,{children:JSON.stringify(e.payload,null,2)}),e.responseSnippet&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:n(`alerts.delivery.response`)}),(0,X.jsx)(le,{language:`text`,children:e.responseSnippet})]}),e.status!==`pending`&&(0,X.jsx)(`div`,{children:(0,X.jsx)(L,{size:`sm`,loading:o.isPending&&o.variables===e.id,onClick:()=>o.mutate(e.id,{onSuccess:()=>i(n(`alerts.delivery.redelivered`)),onError:e=>i(U(e),`error`)}),children:n(`alerts.delivery.redeliver`)})})]})]},e.id))})]})}function Jt(e){let t=fe(),n=d(),r=(0,Y.useMemo)(()=>(t.data??[]).filter(e=>e.authScheme===`oauth-subscription`),[t.data]),i=q({queries:r.map(t=>({queryKey:s.providerAccounts(t.id),queryFn:()=>k(`GET`,`/api/providers/${Te(t.id)}/accounts`),enabled:e===`account`}))});return e===`provider`?(t.data??[]).filter(e=>e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`).map(e=>({value:e.id,label:e.name})):e===`token`?(n.data??[]).map(e=>({value:e.id,label:e.name})):e===`account`?r.flatMap((e,t)=>(i[t]?.data??[]).map(t=>({value:t.id,label:`${e.name} / ${t.displayName||t.id}`}))):[]}function Yt(){let{t:e}=F(),{toast:t,confirm:n}=G(),r=g(),i=ce(),a=b(),o=oe(),[s,c]=(0,Y.useState)(null),l=e=>i.data?.find(t=>t.id===e)?.name??e,u=async r=>{await n({title:e(`alerts.rules.deleteConfirm`,{name:r.name}),confirmLabel:e(`common.delete`),destructive:!0})&&o.mutate(r.id,{onSuccess:()=>t(e(`alerts.rules.deleted`,{name:r.name})),onError:e=>t(U(e),`error`)})};return(0,X.jsxs)(R,{title:e(`alerts.rules`),footer:e(`alerts.rules.hint`),children:[r.isLoading&&(0,X.jsx)(z,{}),r.data?.length===0&&(0,X.jsx)(N,{label:(0,X.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:e(`alerts.rules.empty`)})}),r.data?.map(n=>(0,X.jsxs)(N,{icon:(0,X.jsx)(ot,{className:`size-4 text-[var(--text-muted)]`}),label:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[n.name,n.firing>0&&(0,X.jsx)(P,{tone:`red`,children:e(`alerts.rules.firing`,{count:n.firing})}),!n.enabled&&(0,X.jsx)(P,{tone:`orange`,children:e(`alerts.rules.disabledBadge`)})]}),detail:`${Bt(e,n.event)} → ${n.webhookIds.map(l).join(`, `)||`—`}`,children:[(0,X.jsx)(H,{checked:n.enabled,label:e(`alerts.rules.enabled`),onChange:e=>a.mutate({id:n.id,enabled:e},{onError:e=>t(U(e),`error`)})}),(0,X.jsx)(Me,{label:e(`common.more`),icon:(0,X.jsx)(Ie,{className:`size-4`}),items:[{id:`edit`,label:e(`alerts.rules.edit`),icon:(0,X.jsx)(Ue,{className:`size-3.5`}),onSelect:()=>c(n)},{id:`delete`,label:e(`common.delete`),icon:(0,X.jsx)(Ye,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void u(n)}]})]},n.id)),(0,X.jsx)(`div`,{className:`px-4 py-2`,children:(0,X.jsx)(L,{size:`sm`,icon:(0,X.jsx)(J,{className:`size-3.5`}),onClick:()=>c(`new`),children:e(`alerts.rules.add`)})}),(0,X.jsx)(Zt,{rule:s,onClose:()=>c(null)})]})}function Xt(e){let t={};for(let n of e?.params??[])t[n.name]=n.kind===`choice`?n.choices?.[0]??``:n.kind===`number`?n.default??null:``;return t}function Zt({rule:e,onClose:t}){let{t:n}=F(),{toast:r}=G(),i=h(),a=ce(),o=D(),s=b(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)({}),[m,g]=(0,Y.useState)(`all`),[_,v]=(0,Y.useState)([]),[y,x]=(0,Y.useState)([]),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(null),[E,ee]=(0,Y.useState)(60),O=i.data?.find(e=>e.id===u),k=Jt(O?.subjectType),ne=e===`new`;return(0,Y.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e,n=i.data?.[0];l(t?.name??``),d(t?.event??n?.id??``),p(t?{...Xt(i.data?.find(e=>e.id===t.event)),...t.condition}:Xt(n)),g(t?.subjects?`only`:`all`),v(t?.subjects??[]),x(t?.webhookIds??(a.data??[]).map(e=>e.id)),C(t?.notifyResolved??!1),T(t?.repeatMinutes??null),ee(t?.cooldownMinutes??60)},[e]),(0,X.jsx)(je,{open:e!==null,onOpenChange:e=>!e&&t(),title:n(ne?`alerts.rules.add`:`alerts.rules.edit`),width:560,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{onClick:t,children:n(`common.cancel`)}),(0,X.jsx)(L,{variant:`primary`,disabled:!c.trim()||!u,loading:o.isPending||s.isPending,onClick:()=>{let i=Object.fromEntries(Object.entries(f).filter(([,e])=>e!==null&&e!==``)),a={name:c.trim(),event:u,condition:i,subjects:m===`all`?null:_,webhookIds:y,notifyResolved:S,repeatMinutes:w&&w>0?Math.floor(w):null,cooldownMinutes:Math.max(0,Math.floor(E??0))},l={onSuccess:()=>{t(),r(n(`common.saved`),`success`)},onError:e=>r(U(e),`error`)};ne?o.mutate(a,l):e&&s.mutate({id:e.id,...a},l)},children:n(`common.save`)})]}),children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(M,{label:n(`alerts.rules.name`),children:(0,X.jsx)(A,{value:c,maxLength:64,onChange:e=>l(e.target.value)})}),(0,X.jsx)(M,{label:n(`alerts.rules.event`),hint:u?Vt(n,u):void 0,children:(0,X.jsx)(K,{ariaLabel:n(`alerts.rules.event`),value:u,onChange:e=>{d(e),p(Xt(i.data?.find(t=>t.id===e))),v([])},options:(i.data??[]).map(e=>({value:e.id,label:Bt(n,e.id)}))})}),O?.params.map(e=>(0,X.jsx)(M,{label:n(`alerts.param.${e.name}`),children:e.kind===`number`?(0,X.jsx)(he,{value:typeof f[e.name]==`number`?f[e.name]:null,min:0,label:n(`alerts.param.${e.name}`),onChange:t=>p({...f,[e.name]:t})}):e.kind===`choice`?(0,X.jsx)(K,{ariaLabel:n(`alerts.param.${e.name}`),value:String(f[e.name]??``),onChange:t=>p({...f,[e.name]:t}),options:(e.choices??[]).map(t=>({value:t,label:n(`alerts.choice.${e.name}.${t}`)}))}):(0,X.jsx)(A,{mono:!0,value:String(f[e.name]??``),"aria-label":n(`alerts.param.${e.name}`),placeholder:n(`alerts.param.${e.name}.placeholder`),onChange:t=>p({...f,[e.name]:t.target.value})})},e.name)),O&&(0,X.jsx)(M,{label:`${n(`alerts.rules.subjects`)} · ${n(`alerts.subject.${O.subjectType}`)}`,children:(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(te,{ariaLabel:n(`alerts.rules.subjects`),value:m,onChange:g,items:[{value:`all`,label:n(`alerts.rules.subjectsAll`)},{value:`only`,label:n(`alerts.rules.subjectsOnly`)}]}),m===`only`&&(0,X.jsx)(tt,{label:n(`alerts.rules.subjects`),value:_,onValueChange:v,options:[...k,..._.filter(e=>!k.some(t=>t.value===e)).map(e=>({value:e,label:e}))]})]})}),(0,X.jsx)(M,{label:n(`alerts.rules.webhooks`),children:(a.data??[]).length===0?(0,X.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`alerts.rules.noWebhooks`)}):(0,X.jsx)(tt,{label:n(`alerts.rules.webhooks`),value:y,onValueChange:x,options:(a.data??[]).map(e=>({value:e.id,label:e.name}))})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,X.jsx)(M,{label:n(`alerts.rules.repeat`),hint:n(`alerts.rules.repeatHint`),children:(0,X.jsx)(he,{value:w,min:1,step:1,label:n(`alerts.rules.repeat`),onChange:T})}),(0,X.jsx)(M,{label:n(`alerts.rules.cooldown`),hint:n(`alerts.rules.cooldownHint`),children:(0,X.jsx)(he,{value:E,min:0,step:1,label:n(`alerts.rules.cooldown`),onChange:ee})})]}),(0,X.jsx)(`div`,{className:`card`,children:(0,X.jsx)(N,{label:n(`alerts.rules.notifyResolved`),children:(0,X.jsx)(H,{checked:S,label:n(`alerts.rules.notifyResolved`),onChange:C})})})]})})}function Qt(){let{t:e}=F(),t=p(),n=S()?.loginItem,r=t.data?.mechanism===`launchd`||!!n&&Ce;return(0,X.jsxs)(R,{title:e(`settings.startup`),footer:r?e(`settings.startup.macFooter`):void 0,children:[n&&(0,X.jsx)($t,{loginItem:n}),(0,X.jsx)(en,{})]})}function $t({loginItem:e}){let{t}=F(),{toast:n}=G(),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let t=!0;e.get().then(e=>{t&&i(e)});let n=e.onChanged(i);return()=>{t=!1,n()}},[e]),(0,X.jsx)(N,{label:t(`settings.startup.app`),detail:r&&!r.supported?t(`settings.startup.appUnsupported`):t(`settings.startup.appHint`),children:r?(0,X.jsx)(H,{checked:r.enabled,disabled:!r.supported||a,label:t(`settings.startup.app`),onChange:r=>{o(!0),e.set(r).then(e=>{i(e),e.enabled!==r&&n(t(`settings.startup.failed`),`error`)}).catch(e=>n(U(e),`error`)).finally(()=>o(!1))}}):(0,X.jsx)(z,{className:`size-3.5`})})}function en(){let{t:e}=F(),{toast:t}=G(),n=p(),r=we(),i=n.data;if(!i)return(0,X.jsx)(N,{label:e(`settings.startup.service`),detail:n.isError?U(n.error):void 0,children:n.isPending&&(0,X.jsx)(z,{className:`size-3.5`})});let a=!i.supported||i.mechanism===`none`?e(`settings.startup.unsupported.${i.unsupported??`platform`}`):i.canChange?i.enabled&&i.location?e(`settings.startup.entry`,{location:i.location}):e(`settings.startup.service.${i.mechanism}`):e(`settings.startup.localOnly`);return(0,X.jsx)(N,{label:e(`settings.startup.service`),detail:a,children:i.supported&&(0,X.jsx)(H,{checked:i.enabled,disabled:!i.canChange||r.isPending,label:e(`settings.startup.service`),onChange:n=>r.mutate(n,{onSuccess:n=>n.enabled&&t(e(`settings.startup.saved`)),onError:e=>t(U(e),`error`)})})})}var Z={field:`_field_bhhp1_1`,head:`_head_bhhp1_6`,label:`_label_bhhp1_7`,limit:`_limit_bhhp1_9`,control:`_control_bhhp1_14`,step:`_step_bhhp1_22`,icon:`_icon_bhhp1_23`,valueWrap:`_valueWrap_bhhp1_34`,value:`_value_bhhp1_34`,affix:`_affix_bhhp1_38`,char:`_char_bhhp1_39`,number:`_number_bhhp1_42`,display:`_display_bhhp1_43`,mirror:`_mirror_bhhp1_45`,input:`_input_bhhp1_46`,column:`_column_bhhp1_52`,sizer:`_sizer_bhhp1_53`,glyph:`_glyph_bhhp1_54`,symbol:`_symbol_bhhp1_55`,messageSlot:`_messageSlot_bhhp1_57`,hint:`_hint_bhhp1_58`,words:`_words_bhhp1_60`,wordSlot:`_wordSlot_bhhp1_61`,wordSizer:`_wordSizer_bhhp1_62`,word:`_word_bhhp1_60`,srOnly:`_srOnly_bhhp1_64`},{spring:Q,duration:$,blur:tn}=l,nn=[...l.ease.enter],rn=[...l.ease.standard],an=[0,1,2,3,4,5,6,7,8,9],on=6,sn=400,cn=40,ln=240,un=1500,dn=700,fn=700,pn=.22,mn=4,hn=130,gn=(()=>{let e=2*Math.PI/(Q.morph.visualDuration*1.2);return{type:`spring`,stiffness:e*e,damping:2*(1-Q.morph.bounce)*e}})(),_n=e=>(String(e).split(`.`)[1]??``).length,vn=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),yn=(e,t)=>typeof e==`function`?e(t):e??``,bn=(e,t=10)=>Math.sign(e)*(1-1/(Math.abs(e)*.55/t+1))*t;function xn(e,t){let n=t.formatToParts(e),r=n.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),i=0;return n.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--r}`,digit:Number(e)})):e.type===`fraction`?[...e.value].map(e=>({key:`f${i++}`,digit:Number(e)})):[{key:e.type===`group`?`g${r}`:e.type===`decimal`?`d`:e.type===`minusSign`?`m`:`${e.type}${t}`,text:e.value}])}var Sn={enter:e=>({width:0,scale:.6,opacity:0,y:`${e*.3}em`,filter:`blur(${tn.soft}px)`}),center:{width:`auto`,scale:1,opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{width:Q.morph,scale:Q.morph,opacity:Q.morph,y:Q.snappy,filter:{duration:.3,ease:rn}}},exit:e=>({width:0,scale:.6,opacity:0,y:`${e*-.3}em`,filter:`blur(${tn.subtle}px)`,transition:{width:Q.smooth,scale:Q.smooth,y:{duration:$.fast,ease:rn},opacity:{duration:$.instant},filter:{duration:$.instant}}})},Cn=e=>({width:`auto`,scale:1,opacity:e,y:0,filter:`none`}),wn={enter:Cn(0),center:{...Cn(1),transition:{duration:$.instant}},exit:{width:0,opacity:0,transition:{duration:0}}},Tn={enter:Cn(1),center:{...Cn(1),transition:{duration:0}},exit:{width:0,opacity:0,transition:{duration:0}}};function En({position:e,digit:t}){let n=e=>((t-e)%10+15)%10-5,r=rt(e,e=>`${n(e)*1.05}em`),i=rt(e,e=>Math.max(0,1-Math.abs(n(e))**1.5*1.1)),a=rt(e,e=>Math.abs(n(e))>=1?`hidden`:`visible`),o=rt(e,e=>{let t=Math.abs(n(e));return t<.02||t>=1?`none`:`blur(${(t*tn.soft*.75).toFixed(2)}px)`});return(0,X.jsx)(j.span,{className:Z.glyph,style:{y:r,opacity:i,filter:o,visibility:a},children:t})}function Dn({digit:e,direction:t,instant:r}){let i=ue(),a=m(e),o=(0,Y.useRef)({digit:e,target:e});return(0,Y.useLayoutEffect)(()=>{let s=o.current;if(s.digit===e)return;let c=t>0?(e-s.digit+10)%10:-((s.digit-e+10)%10);Math.abs(c)>5&&(c-=Math.sign(c)*10),s.target+=c,s.digit=e,r||i?a.jump(s.target):n(a,s.target,Q.snappy)},[e,t,r,a,i]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Z.sizer,children:`0`}),an.map(e=>(0,X.jsx)(En,{position:a,digit:e},e))]})}function On({value:e,format:t,direction:n,instant:r}){let i=ue(),a=r?Tn:i?wn:Sn;return(0,X.jsx)(v,{initial:!1,custom:n,children:xn(e,t).map(e=>(0,X.jsx)(j.span,{className:`digit`in e?Z.column:Z.symbol,custom:n,variants:a,initial:`enter`,animate:`center`,exit:`exit`,children:`digit`in e?(0,X.jsx)(Dn,{digit:e.digit,direction:n,instant:r}):e.text},e.key))})}function kn({text:e,direction:t,className:n}){let r=ue();return(0,X.jsx)(`span`,{className:n,children:(0,X.jsx)(v,{initial:!1,custom:t,children:[...e].map((e,n)=>(0,X.jsx)(j.span,{className:Z.char,custom:t,variants:r?wn:Sn,initial:`enter`,animate:`center`,exit:`exit`,children:e},`${n}:${e}`))})})}var An=e=>{let t=e?.replace(/[^\d.-]/g,``);return t&&/\d/.test(t)&&Number.isFinite(Number(t))?Number(t):null},jn=(e,t)=>{let n=e.split(` `);return t.split(` `).map((e,t)=>{let r=An(n[t]),i=An(e);return r!==null&&i!==null&&i<r?-1:1})},Mn={enter:e=>({opacity:0,y:`${e*.3}em`,filter:`blur(${tn.soft}px)`}),center:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`},transition:{duration:.22,ease:nn,opacity:Q.morph}},exit:e=>({opacity:0,y:`${e*-.3}em`,filter:`blur(${tn.subtle}px)`,transition:{duration:.14,ease:rn}})},Nn={enter:{opacity:0,y:0,filter:`none`},center:{opacity:1,y:0,filter:`none`,transition:{duration:$.instant}},exit:{opacity:0,transition:{duration:0}}};function Pn({word:e,direction:t}){let r=ue(),i=(0,Y.useRef)(null),a=m(`auto`),o=(0,Y.useRef)(!1);return(0,Y.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!o.current||r?a.jump(e.offsetWidth):n(a,e.offsetWidth,Q.morph),o.current=!0});return t.observe(e),()=>t.disconnect()},[r,a]),(0,X.jsxs)(j.span,{className:Z.wordSlot,style:{width:a},children:[(0,X.jsx)(`span`,{ref:i,className:Z.wordSizer,children:e}),(0,X.jsx)(v,{initial:!1,mode:`popLayout`,custom:t,children:(0,X.jsx)(j.span,{className:Z.word,custom:t,variants:r?Nn:Mn,initial:`enter`,animate:`center`,exit:`exit`,children:e},e)})]})}function Fn({text:e}){let[t,n]=(0,Y.useState)({text:e,directions:[]});t.text!==e&&n({text:e,directions:jn(t.text,e)});let r=t.text===e?t.directions:jn(t.text,e),i=e.split(` `);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Z.srOnly,children:e}),(0,X.jsx)(`span`,{className:Z.words,"aria-hidden":`true`,children:i.map((e,t)=>(0,X.jsxs)(Y.Fragment,{children:[t>0&&` `,(0,X.jsx)(Pn,{word:e,direction:r[t]??1})]},t))})]})}function In({id:e,text:t,className:n}){return(0,X.jsx)(v,{initial:!1,children:t?(0,X.jsx)(Ln,{id:e,text:t,className:n},`message`):null})}function Ln({id:e,text:t,className:n}){let r=ue(),i=(0,Y.useRef)(null),[a,o]=(0,Y.useState)(`auto`);return(0,Y.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([t])=>o(t.borderBoxSize?.[0]?.blockSize??e.offsetHeight));return t.observe(e),()=>t.disconnect()},[]),(0,X.jsx)(j.span,{className:Z.messageSlot,initial:{height:0,opacity:0},animate:{height:a,opacity:1},exit:{height:0,opacity:0,transition:r?{duration:0}:{height:Q.smooth,opacity:{duration:$.instant}}},transition:r?{duration:0}:{height:Q.smooth,opacity:{duration:$.fast}},children:(0,X.jsx)(j.span,{ref:i,id:e,className:n,initial:!r&&{y:`0.35em`,filter:`blur(${tn.soft}px)`},animate:{y:0,filter:`blur(0px)`},transition:{duration:r?0:$.standard,ease:nn},children:(0,X.jsx)(Fn,{text:t})})})}function Rn({id:e,edge:t,text:n}){let r=ue();return(0,X.jsx)(v,{initial:!1,children:t!==0&&(0,X.jsx)(j.span,{id:e,className:Z.limit,initial:r?{opacity:0}:{opacity:0,y:`${t*.45}em`,filter:`blur(${tn.subtle}px)`},animate:{opacity:1,y:0,filter:`blur(0px)`,transitionEnd:{filter:`none`}},exit:{opacity:0,transition:{duration:r?$.instant:$.standard,ease:rn}},transition:r?{duration:$.instant}:{y:Q.snappy,opacity:{duration:$.fast},filter:{duration:$.fast}},children:n},`limit`)})}function zn({toward:e,label:t,disabled:n,controls:r,limit:i,pressed:a,iconRef:o,onPress:s,onRelease:c,onActivate:l}){let u=e>0?J:He;return(0,X.jsx)(`button`,{type:`button`,className:Z.step,disabled:n,"aria-controls":r,"aria-label":`${e>0?`Increase`:`Decrease`} ${t}`,"aria-disabled":i||void 0,"data-pressed":a||void 0,onPointerDown:e=>{e.button===0&&s()},onPointerUp:c,onPointerLeave:c,onPointerCancel:c,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.detail===0&&l()},onContextMenu:e=>e.preventDefault(),children:(0,X.jsx)(`span`,{ref:o,className:Z.icon,children:(0,X.jsx)(u,{size:16,strokeWidth:1.75,"aria-hidden":`true`})})})}function Bn({label:e,value:t,defaultValue:r=0,onValueChange:i,min:a=0,max:o=2**53-1,step:s=1,largeStep:c,description:l,disabled:u,id:d,prefix:f,suffix:p,scrub:h=!1,locale:g=`en-US`,formatOptions:_,size:v=`md`,limitHint:y=!0}){let b=ue(),x=(0,Y.useId)(),S=d??x,C=l?`${S}-description`:void 0,w=`${S}-limit`,T=s>0?s:1,[E,ee]=(0,Y.useState)(r),D=t??E,[O,te]=(0,Y.useState)(``),[k,ne]=(0,Y.useState)(!1),[re,ie]=(0,Y.useState)(0),[A,ae]=(0,Y.useState)(!1),[oe,se]=(0,Y.useState)(``),[ce,le]=(0,Y.useState)(0),[M,N]=(0,Y.useState)(!1),de=(0,Y.useRef)(null),P=(0,Y.useRef)(null),fe=(0,Y.useRef)(null),pe=(0,Y.useRef)(void 0),me=(0,Y.useRef)(void 0),F=(0,Y.useRef)(void 0),he=(0,Y.useRef)({edge:0,count:0,at:0}),ge=(0,Y.useRef)(null),I=(0,Y.useRef)(null),L=(0,Y.useRef)(D),_e=(0,Y.useRef)(D),ve=(0,Y.useRef)(void 0),ye=(0,Y.useRef)(null),be=(0,Y.useRef)(!1),R=(0,Y.useRef)(null),xe=(0,Y.useRef)(!1),z=(0,Y.useRef)(()=>!1),Se=m(0),B=m(0),Ce=m(0),we=rt(()=>B.get()+Ce.get()),V=Number.isFinite(a)?a:0,H=Math.max(_n(T),_n(V)),Te=_?.minimumFractionDigits??H,Ee=Math.max(Te,_?.maximumFractionDigits??H),De=_?.useGrouping??!0,Oe=(0,Y.useMemo)(()=>new Intl.NumberFormat(g,{minimumFractionDigits:Te,maximumFractionDigits:Ee,useGrouping:De,numberingSystem:`latn`}),[g,Te,Ee,De]),ke=(0,Y.useMemo)(()=>{let e=new Intl.NumberFormat(g).formatToParts(-1234.5);return{group:e.find(e=>e.type===`group`)?.value??`,`,decimal:e.find(e=>e.type===`decimal`)?.value??`.`}},[g]),Ae=e=>Number(e.toFixed(H))||0,U=e=>Math.min(o,Math.max(a,e)),W=e=>Ae(V+Math.round((e-V)/T)*T),je=(e,t)=>{let n=(e-V)/T;return Ae(V+((t>0?Math.floor(n+1e-7):Math.ceil(n-1e-7))+t)*T)},Me=e=>`${yn(f,e)}${Oe.format(e)}${yn(p,e)}`.trim();function G(e){let t=e.split(ke.group).join(``).replace(ke.decimal,`.`).replace(/[^\d.-]/g,``);if(!/\d/.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}let K=k?G(O):null,q=K??D,[Ne,Pe]=(0,Y.useState)({value:q,direction:1});Ne.value!==q&&Pe({value:q,direction:q>Ne.value?1:-1});let Fe=Ne.value===q?Ne.direction:q>Ne.value?1:-1;(0,Y.useEffect)(()=>()=>{window.clearTimeout(ve.current),window.clearTimeout(pe.current),window.clearTimeout(me.current),window.clearTimeout(F.current)},[]);function Ie(e,t){let r=performance.now(),i=he.current;i.count=i.edge===e&&r-i.at<fn?i.count+1:1,i.edge=e,i.at=r;let a=de.current;if(a&&(a.dataset.strain=e>0?`max`:`min`,window.clearTimeout(F.current),F.current=window.setTimeout(()=>{delete a.dataset.strain},420)),!b){n(Se,0,{...gn,velocity:-e*hn*(1+Math.min(i.count-1,mn)*pn)});let r=(e>0?fe:P).current;r&&(t===`button`||t===`key`)&&n(r,{x:[0,-2.5,2.5,-1.5,1,0]},{duration:.32,ease:`easeOut`})}y&&(le(e),window.clearTimeout(pe.current),pe.current=window.setTimeout(()=>le(0),un))}function Le(e,n){if(!Number.isFinite(e))return!1;let r=U(e),a=Math.sign(e-r);return a&&n!==`scrub`?(Ie(a>0?1:-1,n),se(`${Me(r)}, ${a>0?`maximum`:`minimum`}`)):n===`button`&&r!==L.current&&se(Me(r)),r!==L.current&&(L.current=r,t===void 0&&ee(r),i?.(r),!0)}let Re=(e,t,n)=>Le(je(L.current,e*t),n);(0,Y.useLayoutEffect)(()=>{L.current=D,z.current=Re});function ze(){let e=I.current;e&&R.current===null&&(R.current=e.getBoundingClientRect().left-B.get()-Ce.get())}(0,Y.useLayoutEffect)(()=>{let e=R.current,t=I.current;if(R.current=null,xe.current){xe.current=!1;let e=ge.current;if(e&&document.activeElement===e){let t=e.value.length;e.setSelectionRange(t,t)}}if(e===null||!t)return;let r=e-(t.getBoundingClientRect().left-B.get()-Ce.get());Math.abs(r)<.5||(Ce.set(Ce.get()+r),b?Ce.jump(0):n(Ce,0,Q.morph))});function Be(){window.clearTimeout(me.current),N(!1)}function Ve(){if(!k)return;ze(),ne(!1),Be();let e=G(O);e!==null&&Le(W(e),`type`)}function He(){window.clearTimeout(ve.current),ve.current=void 0,ie(0)}function Ue(e,t,n){He(),Ve();let r=Math.max(1,Math.round(t/T));n===`button`&&ie(e);let i=0,a=()=>{let t=z.current(e,r,n);ve.current=window.setTimeout(a,t?Math.max(cn,150*.86**++i):ln)};ve.current=window.setTimeout(a,Re(e,r,n)?sn:360)}function We(e){let t=c??T*10,n={ArrowUp:[1,e.shiftKey?t:T],ArrowDown:[-1,e.shiftKey?t:T],PageUp:[1,t],PageDown:[-1,t]}[e.key];if(n){e.preventDefault(),e.repeat||Ue(n[0],n[1],`key`);return}if(!k&&(e.key===`Home`&&Number.isFinite(a)||e.key===`End`&&o<2**53-1)){e.preventDefault(),Le(e.key===`Home`?a:o,`key`);return}e.key===`Enter`&&(e.preventDefault(),k?(xe.current=!0,Ve()):e.currentTarget.select()),e.key===`Escape`&&k&&(e.preventDefault(),ze(),ne(!1),Be(),xe.current=!0,Le(_e.current,`type`))}function Ge(e){let t=RegExp(`[^0-9${vn(ke.group)}${H||Ee?vn(ke.decimal):``}${a<0?`\\-`:``}]`,`g`),n=e.replace(t,``);k||(_e.current=D),ze(),te(n),ne(!0);let r=G(n);r!==null&&r>=a&&r<=o&&W(r)===r&&Le(r,`type`),Be(),r!==null&&r<a&&(me.current=window.setTimeout(()=>N(!0),dn))}function Ke(e){be.current=!1,h&&!u&&e.button===0&&(Ve(),ye.current={pointer:e.pointerId,x:e.clientX,from:L.current,active:!1},e.currentTarget.setPointerCapture(e.pointerId))}function qe(e){let t=ye.current;if(!t||t.pointer!==e.pointerId)return;let n=e.clientX-t.x;if(!t.active){if(Math.abs(n)<3)return;t.active=!0,ae(!0)}let r=n/on,i=Math.trunc(r);Le(i?je(t.from,i):t.from,`scrub`);let s=t.from+r*T,c=s>o?(s-o)/T*on:s<a?(s-a)/T*on:0;B.set(b?0:bn(c))}function Je(e){let t=ye.current;t&&t.pointer===e.pointerId&&(ye.current=null,t.active&&(be.current=!0,ae(!1),n(B,0,b?{duration:0}:Q.snappy),se(Me(L.current))))}let Ye=t=>({toward:t,label:e,disabled:u,controls:S,limit:t>0?q>=o:q<=a,pressed:re===t}),Xe=K===null?0:K>o?1:K<a&&M?-1:0,J=y?Xe||ce:0,Ze=J>0?o:a,Qe=J?typeof y==`function`?y(J>0?`max`:`min`,Ze):`${J>0?`Max`:`Min`} ${Me(Ze)}`:``,$e=[C,Xe&&y?w:void 0].filter(Boolean).join(` `)||void 0;return(0,X.jsxs)(`div`,{className:Z.field,"data-size":v,children:[(0,X.jsxs)(`div`,{className:Z.head,children:[(0,X.jsx)(`label`,{htmlFor:S,className:Z.label,"data-scrub":h&&!u||void 0,onPointerDown:Ke,onPointerMove:qe,onPointerUp:Je,onPointerCancel:Je,onClick:e=>{be.current&&=(e.preventDefault(),!1)},children:e}),(0,X.jsx)(Rn,{id:w,edge:J,text:Qe})]}),(0,X.jsxs)(`div`,{ref:de,className:Z.control,"data-scrubbing":A||void 0,"data-disabled":u||void 0,"data-warn":Xe?Xe>0?`max`:`min`:void 0,children:[(0,X.jsx)(zn,{...Ye(-1),iconRef:P,onPress:()=>Ue(-1,T,`button`),onRelease:He,onActivate:()=>{Ve(),Re(-1,1,`button`)}}),(0,X.jsx)(`div`,{className:Z.valueWrap,onMouseDown:e=>{e.target!==ge.current&&e.preventDefault()},onClick:e=>{!u&&e.target!==ge.current&&(ge.current?.focus(),ge.current?.select())},children:(0,X.jsxs)(j.span,{ref:I,className:Z.value,style:{x:we,y:Se},children:[(0,X.jsx)(kn,{text:yn(f,q),direction:Fe,className:Z.affix}),(0,X.jsxs)(`span`,{className:Z.number,children:[(0,X.jsx)(`span`,{className:Z.display,"data-hidden":k||void 0,"aria-hidden":`true`,children:(0,X.jsx)(On,{value:q,format:Oe,direction:Fe,instant:k})}),k&&(0,X.jsx)(`span`,{className:Z.mirror,"aria-hidden":`true`,children:O}),(0,X.jsx)(`input`,{ref:ge,id:S,className:Z.input,type:`text`,role:`spinbutton`,inputMode:a<0?`text`:H||Ee?`decimal`:`numeric`,autoComplete:`off`,spellCheck:!1,value:k?O:Oe.format(D),disabled:u,"aria-describedby":$e,"aria-invalid":Xe?!0:void 0,"aria-valuenow":D,"aria-valuetext":Me(D),"aria-valuemin":Number.isFinite(a)?a:void 0,"aria-valuemax":o<2**53-1?o:void 0,onChange:e=>Ge(e.currentTarget.value),onKeyDown:We,onKeyUp:e=>{/^(Arrow(Up|Down)|Page(Up|Down))$/.test(e.key)&&He()},onBlur:()=>{He(),Ve()}})]}),(0,X.jsx)(kn,{text:yn(p,q),direction:Fe,className:Z.affix})]})}),(0,X.jsx)(zn,{...Ye(1),iconRef:fe,onPress:()=>Ue(1,T,`button`),onRelease:He,onActivate:()=>{Ve(),Re(1,1,`button`)}})]}),(0,X.jsx)(In,{id:C,text:l,className:Z.hint}),(0,X.jsx)(`span`,{className:Z.srOnly,"aria-live":`polite`,"aria-atomic":`true`,children:oe})]})}var Vn=[`overview`,`cost`,`chart`,`topModel`,`compareYesterday`,`cacheHitRate`,`quota`];function Hn(){let{t:e}=F(),t=V(),[n,r]=Ae(),i=Ne(),a=De(n,{enabled:i.running,background:!1,live:!0}),o=t=>(0,X.jsx)(N,{label:e(`settings.tray.section.${t}`),detail:e(`settings.tray.section.${t}.hint`),children:(0,X.jsx)(H,{checked:n.sections[t],label:e(`settings.tray.section.${t}`),onChange:e=>r(Ee(n,t,e))})},t);return(0,X.jsxs)(`div`,{className:`mx-auto grid max-w-[1120px] items-start gap-4 lg:grid-cols-[minmax(0,1fr)_392px]`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsx)(Un,{title:e(`settings.tray.titleHeading`),hint:e(`settings.tray.titleHint`),children:(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(ze,{"aria-label":e(`settings.tray.titleHeading`),minColumnWidth:150,value:n.title,onValueChange:e=>r({...n,title:e}),options:re.map(t=>({value:t,label:e(`settings.tray.title.${t}`),description:e(`settings.tray.title.${t}.hint`)}))})})}),(0,X.jsx)(Un,{title:e(`settings.tray.usageHeading`),children:(0,X.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:Vn.map(o)})}),(0,X.jsx)(Un,{title:e(`settings.tray.clientsHeading`),children:(0,X.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:o(`clients`)})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(We,{className:`size-3.5`}),onClick:()=>r(Oe),children:e(`settings.tray.reset`)})})]}),(0,X.jsx)(`div`,{className:`lg:sticky lg:top-0`,children:(0,X.jsxs)(Un,{title:e(`settings.tray.previewHeading`),hint:e(`settings.tray.previewHint`),children:[(0,X.jsx)(`div`,{className:`flex justify-center bg-[var(--surface-muted)] px-4 py-5`,children:(0,X.jsx)(Pe,{preview:!0,className:`w-[360px] max-w-full shadow-[0_12px_40px_rgb(0_0_0/0.25)]`,prefs:n,state:i,data:a,onRefresh:()=>void t.invalidateQueries({queryKey:[`stats`]})})}),(0,X.jsx)(`p`,{className:`border-t border-[var(--border)] px-4 py-2.5 text-[11px] text-[var(--text-muted)]`,children:e(`settings.tray.previewFooter`)})]})})]})}function Un({title:e,hint:t,children:n}){let{t:r}=F();return(0,X.jsxs)(`section`,{className:`card`,children:[(0,X.jsxs)(`header`,{className:`border-b border-[var(--border)] px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`settings.tab.tray`)}),(0,X.jsx)(`h3`,{className:`text-[14px] font-semibold`,children:e}),t&&(0,X.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t})]}),n]})}var Wn=[`general`,`notifications`,`remote`,`tray`],Gn=[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Singapore`,`Europe/London`,`Europe/Berlin`,`America/New_York`,`America/Los_Angeles`];function Kn(){let{t:e}=F(),{tab:t}=Xe(),n=Qe(),r=ke(),i=Wn.includes(t)&&(t!==`tray`||r)?t:`general`;return(0,X.jsx)($e,{title:e(`nav.settings`),children:(0,X.jsxs)(Ke,{value:i,onValueChange:e=>n(e===`general`?`/settings`:`/settings/${e}`,{replace:!0}),children:[(0,X.jsxs)(Ze,{"aria-label":e(`nav.settings`),children:[(0,X.jsx)(qe,{value:`general`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(gt,{className:`size-3.5`}),e(`settings.tab.general`)]})}),(0,X.jsx)(qe,{value:`notifications`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(ct,{className:`size-3.5`}),e(`settings.tab.notifications`)]})}),(0,X.jsx)(qe,{value:`remote`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(se,{className:`size-3.5`}),e(`settings.tab.remote`)]})}),r&&(0,X.jsx)(qe,{value:`tray`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(mt,{className:`size-3.5`}),e(`settings.tab.tray`)]})})]}),(0,X.jsx)(it,{value:`general`,className:`pt-5`,children:(0,X.jsx)(qn,{})}),(0,X.jsx)(it,{value:`notifications`,className:`pt-5`,children:(0,X.jsx)(Ht,{})}),(0,X.jsx)(it,{value:`remote`,className:`pt-5`,children:(0,X.jsx)(Tt,{})}),r&&(0,X.jsx)(it,{value:`tray`,className:`pt-5`,children:(0,X.jsx)(Hn,{})})]})})}function qn(){let{t:e,locale:t,setLocale:n}=F(),r=et(),a=_(),o=me(),l=V(),u=ge(),d=f(),p=c(),m=O(),{toast:h,confirm:g}=G(),v=a.data,y=m.data?.state===`connected`&&m.data.publicUrl?`${m.data.publicUrl}/v1`:null,b=e=>o.mutate(e,{onError:e=>h(U(e),`error`)}),x=e=>{n(e),b({locale:e})},C=async t=>{await W.copy(t)&&h(e(`common.copied`))};return(0,X.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[(0,X.jsxs)(R,{title:e(`settings.appearance`),children:[(0,X.jsx)(N,{label:e(`settings.theme`),children:(0,X.jsx)(te,{ariaLabel:e(`settings.theme`),value:r.theme,onChange:r.setTheme,items:[{value:`system`,label:e(`settings.theme.system`)},{value:`light`,label:e(`settings.theme.light`)},{value:`dark`,label:e(`settings.theme.dark`)}]})}),(0,X.jsx)(N,{label:e(`settings.accent`),detail:r.accentChoice===`system`?r.systemAccent?e(`settings.accent.followingSystem`):e(`settings.accent.systemUnavailable`):void 0,children:(0,X.jsx)(K,{className:`w-40`,ariaLabel:e(`settings.accent`),value:r.accentChoice,onChange:r.setAccentChoice,options:[{value:`system`,label:e(`settings.accent.system`)},...nt.map(t=>({value:t.color,label:e(`settings.accent.${t.id}`)}))]})}),(0,X.jsx)(N,{label:e(`settings.language`),detail:e(`settings.languageHint`),children:(0,X.jsx)(te,{ariaLabel:e(`settings.language`),value:t,onChange:x,items:[{value:`zh`,label:`中文`},{value:`en`,label:`English`}]})})]}),(0,X.jsx)(Qt,{}),v?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(R,{title:e(`settings.gateway`),footer:e(`settings.gatewayFooter`),children:[(0,X.jsx)(N,{label:e(`settings.gatewayUrl`),detail:`${v.gatewayBaseUrl}/v1`,children:(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(I,{className:`size-3.5`}),"aria-label":e(`common.copy`),onClick:()=>void C(`${v.gatewayBaseUrl}/v1`)})}),y&&(0,X.jsx)(N,{label:e(`settings.remote.publicUrl`),detail:y,children:(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(I,{className:`size-3.5`}),"aria-label":e(`common.copy`),onClick:()=>void C(y)})}),(0,X.jsx)(Ft,{}),(0,X.jsx)(N,{label:e(`settings.dataDir`),detail:v.dataDir,children:W.canOpenPaths?(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(Be,{className:`size-3.5`}),"aria-label":e(`settings.openFolder`),onClick:()=>void W.openPath(v.dataDir)}):(0,X.jsx)(L,{size:`sm`,variant:`plain`,icon:(0,X.jsx)(I,{className:`size-3.5`}),"aria-label":e(`common.copy`),onClick:()=>void C(v.dataDir)})}),(0,X.jsx)(N,{label:e(`settings.requireKey`),detail:e(`settings.requireKeyHint`),children:(0,X.jsx)(H,{checked:v.requireGatewayKey,label:e(`settings.requireKey`),onChange:async t=>{(t||await g({title:e(`settings.requireKeyOffConfirm`),detail:e(`settings.requireKeyOffDetail`),confirmLabel:e(`settings.requireKeyOff`),destructive:!0}))&&b({requireGatewayKey:t})}})}),(0,X.jsx)(N,{label:e(`settings.streamIdle`),detail:e(`settings.streamIdleHint`),children:(0,X.jsx)(Zn,{label:e(`settings.streamIdle`),value:v.streamIdleTimeoutSec,onCommit:e=>b({streamIdleTimeoutSec:e??300}),suffix:` s`})}),(0,X.jsx)(N,{label:e(`settings.requestCompression`),detail:e(`settings.requestCompressionHint`),children:(0,X.jsx)(K,{className:`w-40`,ariaLabel:e(`settings.requestCompression`),value:v.requestCompression,onChange:e=>b({requestCompression:e}),options:[{value:`default`,label:e(`settings.requestCompression.default`)},{value:`zstd`,label:`zstd`},{value:`gzip`,label:`gzip`},{value:`br`,label:`Brotli (br)`},{value:`deflate`,label:`deflate`},{value:`none`,label:e(`settings.requestCompression.none`)}]})})]}),(0,X.jsx)(Yn,{settings:v}),(0,X.jsx)(Xn,{settings:v}),(0,X.jsxs)(R,{title:e(`settings.quota`),footer:e(`settings.quota.autoIntervalHint`),children:[(0,X.jsx)(N,{label:e(`settings.quota.autoInterval`),children:(0,X.jsx)(Zn,{label:e(`settings.quota.autoInterval`),value:v.quotaAutoIntervalMinutes,onCommit:e=>o.mutate({quotaAutoIntervalMinutes:e??30},{onSuccess:()=>void l.invalidateQueries({queryKey:s.providers}),onError:e=>h(U(e),`error`)}),suffix:` ${e(`settings.minutes`)}`})}),(0,X.jsx)(N,{label:e(`settings.quota.subscriptionInterval`),detail:e(`settings.quota.subscriptionIntervalHint`),children:(0,X.jsx)(Zn,{label:e(`settings.quota.subscriptionInterval`),value:v.subscriptionQuotaIntervalMinutes,onCommit:e=>b({subscriptionQuotaIntervalMinutes:e??30}),suffix:` ${e(`settings.minutes`)}`})})]}),(0,X.jsx)(R,{footer:e(`settings.usageTimeZone.hint`),children:(0,X.jsx)(N,{label:e(`settings.usageTimeZone`),children:(0,X.jsx)(K,{className:`w-56`,ariaLabel:e(`settings.usageTimeZone`),value:v.usageTimeZone??``,onChange:e=>b({usageTimeZone:e||null}),options:[{value:``,label:e(`settings.usageTimeZone.system`,{zone:v.effectiveUsageTimeZone})},...[...new Set([...Gn,...v.usageTimeZone?[v.usageTimeZone]:[]])].map(e=>({value:e,label:e}))]})})}),(0,X.jsxs)(R,{title:e(`settings.logging`),footer:e(`settings.debugBodiesHint`),children:[(0,X.jsx)(N,{label:e(`settings.debugBodies`),children:(0,X.jsx)(H,{checked:v.debugBodies,label:e(`settings.debugBodies`),onChange:e=>b({debugBodies:e})})}),(0,X.jsx)(N,{label:e(`settings.bodyRetention`),children:(0,X.jsx)(Zn,{label:e(`settings.bodyRetention`),value:v.bodyRetentionDays,onCommit:e=>b({bodyRetentionDays:e??7}),suffix:` ${e(`settings.days`)}`})}),(0,X.jsxs)(N,{label:e(`settings.requestRetention`),detail:v.requestRetentionDays==null?e(`settings.keepForever`):void 0,children:[(0,X.jsx)(H,{checked:v.requestRetentionDays!=null,label:e(`settings.requestRetention`),onChange:e=>b({requestRetentionDays:e?90:null})}),v.requestRetentionDays!=null&&(0,X.jsx)(Zn,{label:e(`settings.requestRetention`),value:v.requestRetentionDays,onCommit:e=>b({requestRetentionDays:e??90}),suffix:` ${e(`settings.days`)}`})]})]}),(0,X.jsx)(R,{title:e(`settings.effort`),footer:e(`settings.effortHint`),children:[`low`,`medium`,`high`].map(t=>(0,X.jsx)(N,{label:e(`settings.effort.${t}`),children:(0,X.jsx)(Zn,{label:e(`settings.effort.${t}`),value:v.effortBudgets[t],onCommit:e=>b({effortBudgets:{...v.effortBudgets,[t]:e??v.effortBudgets[t]}}),suffix:` tokens`,step:1024})},t))})]}):a.isError?(0,X.jsx)(`div`,{className:`text-[12px] text-[var(--danger)]`,children:U(a.error)}):(0,X.jsx)(z,{className:`mx-auto my-8`}),(0,X.jsxs)(R,{title:e(`settings.about`),children:[(0,X.jsx)(N,{label:e(`settings.serverVersion`),detail:u.data?`${u.data.version} · API ${u.data.apiVersion}`:`—`}),i&&(0,X.jsx)(N,{label:e(`settings.desktopVersion`),detail:S()?.version||`—`}),(0,X.jsx)(Jn,{}),i&&(0,X.jsx)(N,{label:e(`settings.logs`),onClick:()=>void W.revealLogs(),children:(0,X.jsx)(Be,{className:`size-4 text-[var(--text-secondary)]`})}),d.data?.required&&(0,X.jsx)(N,{label:e(`settings.logout`),onClick:()=>p.mutate(),children:(0,X.jsx)(Ve,{className:`size-4 text-[var(--text-secondary)]`})})]})]})}function Jn(){let{t:e}=F(),{toast:t}=G(),n=V(),r=me(),i=_(),a=ve(),o=ee(),c=a.data,l=i.data?.updateChannel??c?.channel,u=S()?.updates??null,[d,f]=(0,Y.useState)(!1),p=()=>o.mutate(void 0,{onSuccess:n=>n.error?t(e(`settings.updateCheckFailed`,{error:n.error}),`error`):t(n.available?e(`settings.updateAvailable`,{version:n.available}):e(`settings.upToDate`)),onError:e=>t(U(e),`error`)}),m=()=>{u&&!d&&(f(!0),u.apply().then(r=>{r===`server`?(t(e(`settings.updateApplied`)),n.invalidateQueries({queryKey:s.version}),n.invalidateQueries({queryKey:s.update})):t(e(r===`desktop`?`settings.updateDesktopRelaunch`:r===`download`?`settings.updateDownloadOpened`:`settings.upToDate`))}).catch(e=>t(U(e),`error`)).finally(()=>f(!1)))},h=c?.lastCheckAt?new Date(c.lastCheckAt).toLocaleString():void 0,g=c?.available?u?e(`settings.updateAvailable`,{version:c.available}):`${e(`settings.updateAvailable`,{version:c.available})} ${e(`settings.updateApplyHint`)}`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:e(`settings.autoCheck`),detail:c&&!c.feedConfigured?e(`settings.updateCheckFailed`,{error:`feed-not-configured`}):void 0,children:(0,X.jsx)(H,{checked:c?.autoCheck??!0,label:e(`settings.autoCheck`),onChange:e=>r.mutate({updateAutoCheck:e},{onError:e=>t(U(e),`error`)})})}),(0,X.jsx)(N,{label:e(`settings.previewUpdates`),detail:e(`settings.previewUpdatesHint`),children:(0,X.jsx)(H,{checked:l===`preview`,label:e(`settings.previewUpdates`),disabled:!l||r.isPending,onChange:e=>r.mutate({updateChannel:e?`preview`:`stable`},{onSuccess:p,onError:e=>t(U(e),`error`)})})}),(0,X.jsxs)(N,{label:e(`settings.checkUpdates`),detail:o.isError?e(`settings.updateCheckFailed`,{error:U(o.error)}):c?.available?g:h?e(`settings.lastChecked`,{time:h}):void 0,children:[(0,X.jsx)(L,{size:`sm`,variant:`plain`,disabled:o.isPending,onClick:p,children:o.isPending?(0,X.jsx)(z,{className:`size-3.5`}):(0,X.jsx)(Je,{className:`size-3.5`})}),u&&c?.available&&(0,X.jsx)(L,{size:`sm`,variant:`plain`,disabled:d,"aria-label":e(`settings.updateApply`),onClick:m,children:d?(0,X.jsx)(z,{className:`size-3.5`}):(0,X.jsx)(Fe,{className:`size-3.5`})})]})]})}function Yn({settings:e}){let{t}=F(),{toast:n}=G(),r=me(),[i,a]=(0,Y.useState)(e.proxyMode),[o,s]=(0,Y.useState)({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``});(0,Y.useEffect)(()=>a(e.proxyMode),[e.proxyMode]),(0,Y.useEffect)(()=>s({url:e.proxyUrl??``,username:e.proxyUsername??``,password:``,bypass:e.proxyBypass??``}),[e.proxyUrl,e.proxyUsername,e.proxyBypass,e.hasProxyPassword]);let c=t=>{a(t),(t!==`custom`||e.proxyUrl)&&r.mutate({proxyMode:t},{onError:e=>n(U(e),`error`)})},l=()=>r.mutate({proxyMode:`custom`,proxyUrl:o.url.trim()||null,proxyUsername:o.username.trim()||null,proxyBypass:o.bypass.trim()||null,...o.password?{proxyPassword:o.password}:{}},{onSuccess:()=>n(t(`settings.proxy.saved`)),onError:e=>n(U(e),`error`)}),u=i!==e.proxyMode||o.url!==(e.proxyUrl??``)||o.username!==(e.proxyUsername??``)||o.password!==``||o.bypass!==(e.proxyBypass??``);return(0,X.jsxs)(R,{title:t(`settings.proxy`),footer:t(`settings.proxy.footer`),children:[(0,X.jsx)(N,{label:t(`settings.proxy.mode`),detail:t(`settings.proxy.mode.${i}.hint`),children:(0,X.jsx)(te,{ariaLabel:t(`settings.proxy.mode`),value:i,onChange:c,items:[{value:`system`,label:t(`settings.proxy.mode.system`)},{value:`custom`,label:t(`settings.proxy.mode.custom`)},{value:`direct`,label:t(`settings.proxy.mode.direct`)}]})}),i===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.proxy.url`),detail:t(`settings.proxy.urlHint`),children:(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.url`),placeholder:`http://127.0.0.1:7890`,value:o.url,onChange:e=>s({...o,url:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.proxy.username`),detail:t(`settings.proxy.optional`),children:(0,X.jsx)(A,{className:`w-64`,autoComplete:`off`,"aria-label":t(`settings.proxy.username`),value:o.username,onChange:e=>s({...o,username:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.proxy.password`),detail:e.hasProxyPassword?t(`settings.proxy.passwordSaved`):t(`settings.proxy.optional`),children:(0,X.jsx)(A,{className:`w-64`,type:`password`,autoComplete:`new-password`,"aria-label":t(`settings.proxy.password`),placeholder:e.hasProxyPassword?`••••••••`:void 0,value:o.password,onChange:e=>s({...o,password:e.target.value})})}),(0,X.jsx)(N,{label:t(`settings.proxy.bypass`),detail:t(`settings.proxy.bypassHint`),children:(0,X.jsx)(A,{className:`w-64`,mono:!0,"aria-label":t(`settings.proxy.bypass`),placeholder:`example.com, *.lan`,value:o.bypass,onChange:e=>s({...o,bypass:e.target.value})})}),(0,X.jsx)(`div`,{className:`flex justify-end px-4 py-2`,children:(0,X.jsx)(L,{size:`sm`,disabled:!u||!o.url.trim()||r.isPending,onClick:l,children:t(`common.save`)})})]})]})}function Xn({settings:e}){let{t}=F(),{toast:n}=G(),r=me(),i=e.pluginMarketUrl===``,[a,o]=(0,Y.useState)(e.pluginMarketUrl??``);(0,Y.useEffect)(()=>o(e.pluginMarketUrl??``),[e.pluginMarketUrl]);let s=(e,i=!1)=>r.mutate({pluginMarketUrl:e},{onSuccess:()=>i&&n(t(`settings.pluginMarket.saved`)),onError:e=>n(U(e),`error`)});return(0,X.jsxs)(R,{title:t(`settings.pluginMarket`),footer:t(`settings.pluginMarket.footer`),children:[(0,X.jsx)(N,{label:t(`settings.pluginMarket.offline`),detail:t(`settings.pluginMarket.offlineHint`),children:(0,X.jsx)(H,{checked:i,label:t(`settings.pluginMarket.offline`),onChange:e=>s(e?``:null)})}),!i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{label:t(`settings.pluginMarket.url`),detail:t(`settings.pluginMarket.urlHint`),children:(0,X.jsx)(A,{className:`w-80`,mono:!0,"aria-label":t(`settings.pluginMarket.url`),placeholder:e.pluginMarketDefaultUrl,value:a,onChange:e=>o(e.target.value)})}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-2`,children:[e.pluginMarketUrl!==null&&(0,X.jsx)(L,{size:`sm`,disabled:r.isPending,onClick:()=>s(null,!0),children:t(`settings.pluginMarket.reset`)}),(0,X.jsx)(L,{size:`sm`,disabled:r.isPending||a.trim()===(e.pluginMarketUrl??``),onClick:()=>s(a.trim()||null,!0),children:t(`common.save`)})]})]})]})}function Zn({label:e,value:t,onCommit:n,suffix:r,step:i=1}){let[a,o]=(0,Y.useState)(t);(0,Y.useEffect)(()=>o(t),[t]);let s=(0,Y.useRef)(n);return(0,Y.useEffect)(()=>{s.current=n}),(0,Y.useEffect)(()=>{if(a===t)return;let e=setTimeout(()=>s.current(a),600);return()=>clearTimeout(e)},[a,t]),(0,X.jsx)(`div`,{className:`astra-label-hidden w-36`,children:(0,X.jsx)(Bn,{label:e,size:`sm`,value:a,onValueChange:o,min:0,step:i,suffix:r})})}export{Kn as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ca as e,Ea as t,Hr as n,J as r,K as i,Kr as a,Nr as o,Sa as s,W as c,Wr as ee,Z as l,_ as u,c as d,mr as f,n as p,nr as m,ot as h,q as te,r as g,s as _,t as v,tr as y,v as b}from"./alert-BzjF81CS.js";import{a as ne,at as re,it as ie,nt as ae,ot as oe,rt as x}from"./overlays-8ByMRpma.js";import{t as S}from"./arrow-left-Bv8IR_At.js";import{D as C,I as w,O as T,Q as E,Y as D,Z as O,h as k,m as A}from"./index-D7HIE1TG.js";import{a as j,n as M}from"./TokenPoolEditor-D8mQHyNt.js";var N=t(e(),1),P=s();function F(){let{id:e=``}=E(),{t,locale:s}=h(),F=O(),[L,R]=(0,N.useState)(`7d`),z=ee(e),B=m(),V=o(L,void 0,e),H=n(L,L===`today`?`hour`:`day`,`token`,void 0,e),U=a(L,void 0,20,e),W=y(L,e),G=f({token:e,page:1,pageSize:10},!1),K=j(),q=(0,P.jsx)(g,{variant:`glass`,icon:(0,P.jsx)(S,{className:`size-4`}),"aria-label":t(`common.back`),onClick:()=>F(`/tokens`)}),J=t(`range.${L}`),se=(0,N.useMemo)(()=>re(ie(H.data??[],`requests`),oe(L)).map(e=>({key:e.bucket,label:x(e.bucket),axisLabel:ae(e.bucket),value:Math.round(e.value)})),[H.data,L]),Y=new Map((B.data??[]).map(e=>[e.id,e.name])),X=(W.data??[]).reduce((e,t)=>e+t.requests,0),ce=(W.data??[]).map(e=>({id:e.providerId,name:Y.get(e.providerId)??e.name??e.providerId,requests:e.requests,share:X?e.requests/X:0,success:e.successRate,ttft:e.avgTtftMs??null,cost:e.costUsd,out:e.failoversOut,in:e.failoversIn})),Z=[{key:`name`,label:t(`tokens.detail.provider`),sortable:!0},{key:`requests`,label:t(`overview.requests`),sortable:!0,numeric:!0,render:e=>r(e)},{key:`share`,label:t(`tokens.detail.share`),sortable:!0,numeric:!0,render:e=>i(e)},{key:`success`,label:t(`overview.successRate`),sortable:!0,numeric:!0,render:(e,t)=>t.requests?i(e):`—`},{key:`ttft`,label:t(`overview.avgTtft`),sortable:!0,numeric:!0,render:e=>c(e)},{key:`cost`,label:t(`overview.cost`),sortable:!0,numeric:!0,render:e=>l(e)},{key:`out`,label:t(`tokens.detail.failoversOut`),sortable:!0,numeric:!0},{key:`in`,label:t(`tokens.detail.failoversIn`),sortable:!0,numeric:!0}],le=(U.data??[]).map(e=>({model:e.model,requests:e.requests,tokens:e.tokens,cost:e.costUsd})),ue=[{key:`model`,label:t(`tokens.detail.model`),sortable:!0},{key:`requests`,label:t(`overview.requests`),sortable:!0,numeric:!0,render:e=>r(e)},{key:`tokens`,label:t(`overview.tokens`),sortable:!0,numeric:!0,render:e=>r(e,!0)},{key:`cost`,label:t(`overview.cost`),sortable:!0,numeric:!0,render:e=>l(e)}],de=(G.data?.items??[]).map(e=>({id:e.id,time:new Date(e.startedAtUtc).getTime(),model:e.requestedModel??`—`,provider:e.providerName??e.providerId??`—`,status:e.status,cost:e.costNanoUsd/1e9,r:e})),fe=[{key:`time`,label:t(`tokens.detail.time`),render:(e,t)=>te(t.r.startedAtUtc,s)},{key:`model`,label:t(`tokens.detail.model`)},{key:`provider`,label:t(`tokens.detail.provider`)},{key:`status`,label:t(`tokens.detail.status`),render:e=>(0,P.jsx)(p,{tone:e===`success`?`green`:`red`,children:t(`status.${e}`)})},{key:`cost`,label:t(`overview.cost`),numeric:!0,render:e=>l(e)}];if(z.isError)return(0,P.jsx)(k,{title:t(`nav.tokens`),leading:q,children:(0,P.jsx)(v,{tone:`danger`,title:t(`common.error`),children:ne(z.error)})});let Q=z.data,$=V.data;return(0,P.jsx)(k,{title:Q?.name??``,subtitle:Q?(0,P.jsx)(`code`,{className:`font-mono`,children:Q.keyMasked}):void 0,leading:q,actions:(0,P.jsx)(D,{to:`/requests?token=${encodeURIComponent(e)}`,children:(0,P.jsx)(g,{icon:(0,P.jsx)(w,{className:`size-3.5`}),children:t(`tokens.detail.viewLogs`)})}),children:(0,P.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4`,children:[(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(u,{ariaLabel:t(`overview.range`),value:L,onChange:R,items:[`today`,`7d`,`30d`,`90d`].map(e=>({value:e,label:t(`range.${e}`)}))})}),$?(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:[(0,P.jsx)(I,{label:t(`overview.totalCost`),value:l($.costUsd),context:J}),(0,P.jsx)(I,{label:t(`overview.totalRequests`),value:r($.requests),context:J}),(0,P.jsx)(I,{label:t(`overview.tokens`),value:r($.inputTokens+$.outputTokens,!0),context:t(`overview.tokensContext`,{input:r($.inputTokens,!0),output:r($.outputTokens,!0)})}),(0,P.jsx)(I,{label:t(`usage.hitRate`),value:i(A($.cacheReadTokens,$.inputTokens)??0),context:J}),(0,P.jsx)(I,{label:t(`overview.successRate`),value:$.requests?i($.successRate):`—`,context:c($.avgTtftMs)})]}):(0,P.jsx)(b,{lines:3}),Q?.pool&&(0,P.jsxs)(`section`,{className:`card p-5`,children:[(0,P.jsxs)(`h2`,{className:`mb-3 text-[13px] font-medium`,children:[t(`tokens.pool.title`),` · `,t(`tokens.strategy.${Q.pool.strategy}`)]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2 text-[13px]`,children:Q.pool.members.map(e=>(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,P.jsx)(_,{tone:M(e.health.state)}),Y.get(e.providerId)??e.providerId,(0,P.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:K(e.health)})]},e.providerId))})]}),$&&$.requests===0?(0,P.jsx)(`div`,{className:`card`,children:(0,P.jsx)(d,{title:t(`overview.tokenEmpty.title`,{token:Q?.name??``}),detail:t(`overview.tokenEmpty.detail`,{range:J})})}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`section`,{className:`card p-5`,children:[(0,P.jsxs)(`h2`,{className:`mb-3 text-[13px] font-medium`,children:[t(`overview.usageTrend`),` · `,J]}),H.isLoading?(0,P.jsx)(b,{lines:4}):(0,P.jsx)(T,{data:se,label:t(`overview.requests`),period:J,height:160,formatValue:e=>r(e),averageLabel:t(L===`today`?`overview.hourlyAverage`:`overview.dailyAverage`),valueLabel:t(`overview.total`),categoryLabel:t(L===`today`?`overview.hour`:`overview.day`)})]}),(0,P.jsxs)(`section`,{className:`card p-5`,children:[(0,P.jsx)(`h2`,{className:`mb-1 text-[13px] font-medium`,children:t(`tokens.detail.byProvider`)}),(0,P.jsx)(`p`,{className:`mb-3 text-[12px] text-[var(--text-muted)]`,children:t(`tokens.detail.byProviderHint`)}),(0,P.jsx)(C,{caption:t(`tokens.detail.byProvider`),rows:ce,columns:Z,rowKey:`id`,emptyMessage:t(`common.noData`)})]}),(0,P.jsxs)(`section`,{className:`card p-5`,children:[(0,P.jsx)(`h2`,{className:`mb-3 text-[13px] font-medium`,children:t(`tokens.detail.byModel`)}),(0,P.jsx)(C,{caption:t(`tokens.detail.byModel`),rows:le,columns:ue,rowKey:`model`,emptyMessage:t(`common.noData`)})]})]}),(0,P.jsxs)(`section`,{className:`card p-5`,children:[(0,P.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-[13px] font-medium`,children:t(`tokens.detail.recent`)}),(0,P.jsx)(D,{className:`text-[12px] text-[var(--accent)]`,to:`/requests?token=${encodeURIComponent(e)}`,children:t(`tokens.detail.viewLogs`)})]}),(0,P.jsx)(C,{caption:t(`tokens.detail.recent`),rows:de,columns:fe,rowKey:`id`,emptyMessage:t(`common.noData`)})]})]})})}function I({label:e,value:t,context:n}){return(0,P.jsxs)(`article`,{className:`card min-w-0 px-4 py-3`,children:[(0,P.jsx)(`div`,{className:`truncate text-[12px] text-[var(--text-secondary)]`,children:e}),(0,P.jsx)(`div`,{className:`num mt-1 truncate text-[22px] leading-tight font-semibold selectable`,title:t,children:t}),(0,P.jsx)(`div`,{className:`mt-1 truncate text-[11px] text-[var(--text-muted)]`,title:n,children:n})]})}export{F as TokenDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,Sa as t,_ as n,it as r,n as i,ot as a,p as o,q as s,r as c,y as l}from"./alert-BzjF81CS.js";import{r as u}from"./overlays-8ByMRpma.js";import{a as d,c as f,d as p,f as m,i as h,l as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./sortable.esm-BhxNcP2n.js";import{N as w,x as T}from"./index-D7HIE1TG.js";var E=t(),D=[`failover`,`round_robin`,`weighted`,`tiered`,`least_busy`];function O(e){return e.pool?{strategy:e.pool.strategy,sticky:e.pool.sticky,failover:e.pool.failover,maxAttempts:e.pool.maxAttempts,members:e.pool.members.map(e=>({providerId:e.providerId,accountId:e.accountId??null,weight:e.weight,tier:e.tier}))}:{strategy:`failover`,sticky:`session`,failover:!0,maxAttempts:3,members:e.providerId?[{providerId:e.providerId,accountId:e.accountId??null,weight:1,tier:1}]:[]}}function k(e,t){let n=new Set(t.map(e=>e.id));return{strategy:e.strategy,sticky:e.sticky,failover:e.failover,maxAttempts:Math.min(5,Math.max(1,Math.floor(e.maxAttempts||1))),members:e.members.filter(e=>n.has(e.providerId)).map(e=>({...e,weight:Math.max(1,Math.floor(e.weight||1))}))}}function A(e){let{members:t,strategy:n}=e;if(t.length===0)return[];let r=e=>e.reduce((e,t)=>e+Math.max(1,t.weight),0);switch(n){case`failover`:return t.map((e,t)=>+(t===0));case`weighted`:{let e=r(t);return t.map(t=>Math.max(1,t.weight)/e)}case`tiered`:{let e=Math.min(...t.map(e=>e.tier)),n=r(t.filter(t=>t.tier===e));return t.map(t=>t.tier===e?Math.max(1,t.weight)/n:0)}default:return t.map(()=>1/t.length)}}var j=[`var(--accent)`,`var(--success)`,`var(--warning)`,`#af52de`,`#5ac8fa`,`#ff2d55`],M=new Set([`oauth-subscription`,`plugin`]);function N(e){return e===`healthy`?`green`:e===`cooling`||e===`open`||e===`half_open`?`orange`:`red`}function P(){let{t:e,locale:t}=a();return n=>n.state===`cooling`||n.state===`open`?e(`tokens.health.${n.state}`,{time:n.until?s(n.until,t):`—`}):e(`tokens.health.${n.state}`)}function F({draft:e,onChange:t,providers:r,health:i}){let{t:s}=a(),c=new Map(r.map(e=>[e.id,e])),m=e.members.length>1,h=p(C(f,{activationConstraint:{distance:4}}),C(x,{coordinateGetter:b})),y=n=>t({...e,members:n}),w=(t,n)=>y(e.members.map((e,r)=>r===t?{...e,...n}:e)),T=({active:t,over:n})=>{if(!n||t.id===n.id)return;let r=e.members.findIndex(e=>e.providerId===t.id),i=e.members.findIndex(e=>e.providerId===n.id);r>=0&&i>=0&&y(_(e.members,r,i))},O=r.filter(t=>t.enabled&&!e.members.some(e=>e.providerId===t.id)),k=A(e),M=e.members.flatMap(e=>{let t=c.get(e.providerId);return t&&t.modelCount===0?[t.name]:[]});return(0,E.jsxs)(`div`,{className:`grid gap-3`,children:[m&&(0,E.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,E.jsx)(n,{ariaLabel:s(`tokens.pool.strategy`),value:e.strategy,onChange:n=>t({...e,strategy:n}),items:D.map(e=>({value:e,label:s(`tokens.strategy.${e}`)}))}),(0,E.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:s(`tokens.strategy.${e.strategy}.hint`)})]}),e.members.length===0?(0,E.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:s(`tokens.pool.empty`)}):(0,E.jsx)(`div`,{className:`overflow-hidden rounded-[var(--radius-control)] border border-[var(--border-subtle)]`,children:(0,E.jsx)(v,{sensors:h,collisionDetection:g,onDragEnd:T,children:(0,E.jsx)(S,{items:e.members.map(e=>e.providerId),strategy:d,children:e.members.map((t,n)=>(0,E.jsx)(I,{member:t,index:n,draft:e,provider:c.get(t.providerId),health:i?.get(t.providerId),onChange:e=>w(n,e),onRemove:()=>y(e.members.filter((e,t)=>t!==n))},t.providerId))})})}),O.length>0&&(0,E.jsx)(u,{ariaLabel:s(`tokens.pool.add`),placeholder:s(`tokens.pool.add`),value:null,onChange:t=>y([...e.members,{providerId:t,accountId:null,weight:1,tier:1}]),options:O.map(e=>({value:e.id,label:e.name}))}),M.length>0&&(0,E.jsx)(`p`,{className:`text-[12px] text-[var(--warning)]`,children:s(`tokens.pool.noModels`,{providers:M.join(`, `)})}),m&&(0,E.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2 text-[12px]`,children:[(0,E.jsx)(`span`,{className:`font-medium text-[var(--text-secondary)]`,children:s(`tokens.pool.share`)}),(0,E.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:s(`tokens.pool.shareHint`)})]}),(0,E.jsx)(`div`,{className:`flex h-2 gap-0.5 overflow-hidden rounded-full bg-[var(--fill-2)]`,"aria-hidden":`true`,children:e.members.map((e,t)=>k[t]>0?(0,E.jsx)(`span`,{style:{flex:k[t],background:j[t%j.length]}},e.providerId):null)}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-[12px] text-[var(--text-secondary)]`,children:e.members.map((e,t)=>(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`inline-block size-2 rounded-sm`,style:{background:j[t%j.length]}}),c.get(e.providerId)?.name??e.providerId,(0,E.jsxs)(`b`,{className:`tabular-nums text-[var(--text-primary)]`,children:[Math.round(k[t]*100),`%`]}),k[t]===0&&(0,E.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:s(`tokens.pool.standby`)})]},e.providerId))})]}),m&&(0,E.jsxs)(`div`,{className:`grid gap-2 text-[13px]`,children:[(0,E.jsxs)(`label`,{className:`flex items-start justify-between gap-3`,children:[(0,E.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,E.jsx)(`span`,{children:s(`tokens.pool.sticky`)}),(0,E.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:s(`tokens.pool.stickyHint`)})]}),(0,E.jsx)(l,{label:s(`tokens.pool.sticky`),checked:e.sticky===`session`,onChange:n=>t({...e,sticky:n?`session`:`off`})})]}),(0,E.jsxs)(`label`,{className:`flex items-start justify-between gap-3`,children:[(0,E.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,E.jsx)(`span`,{children:s(`tokens.pool.failover`)}),(0,E.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:s(`tokens.pool.failoverHint`)})]}),(0,E.jsx)(l,{label:s(`tokens.pool.failover`),checked:e.failover,onChange:n=>t({...e,failover:n})})]}),e.failover&&(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`span`,{children:s(`tokens.pool.maxAttempts`)}),(0,E.jsx)(`div`,{className:`w-20`,children:(0,E.jsx)(o,{label:s(`tokens.pool.maxAttempts`),value:e.maxAttempts,min:1,step:1,onChange:n=>t({...e,maxAttempts:n??1})})})]})]})]})}function I({member:t,index:n,draft:s,provider:l,health:d,onChange:f,onRemove:p}){let{t:g}=a(),_=P(),{attributes:v,listeners:b,setNodeRef:x,setActivatorNodeRef:S,transform:C,transition:D,isDragging:O}=h({id:t.providerId}),k=!!l&&M.has(l.authScheme),A=e(l?.id,k),j=l?.name??t.providerId,F=s.members.length>1,I=l?l.enabled?d:{state:`disabled`}:{state:`missing`};return(0,E.jsxs)(`div`,{ref:x,style:{transform:m.Transform.toString(C),transition:D},className:r(`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-[var(--border-subtle)] px-2.5 py-2 last:border-b-0`,O&&`relative z-10 bg-[var(--surface-solid)] shadow-lg`),children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-48 items-center gap-2`,children:[(0,E.jsx)(`button`,{ref:S,type:`button`,"aria-label":g(`clients.dragToReorder`,{provider:j}),title:g(`clients.dragToReorder`,{provider:j}),className:`inline-flex cursor-grab touch-none text-[var(--text-muted)] hover:text-[var(--text-secondary)] active:cursor-grabbing`,...v,...b,children:(0,E.jsx)(y,{className:`size-4`})}),l&&(0,E.jsx)(T,{name:l.name,icon:l.icon,colorKey:l.templateId,size:20}),(0,E.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:j}),F&&s.strategy===`failover`&&(0,E.jsx)(i,{tone:n===0?`accent`:`neutral`,children:n===0?g(`tokens.pool.primary`):g(`tokens.pool.backup`,{n})}),I&&(0,E.jsx)(i,{tone:N(I.state),children:_(I)})]}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[F&&(s.strategy===`weighted`||s.strategy===`tiered`)&&(0,E.jsx)(`div`,{className:`w-20`,children:(0,E.jsx)(o,{label:g(`tokens.pool.weight`),placeholder:g(`tokens.pool.weight`),value:t.weight,min:1,step:1,onChange:e=>f({weight:e??1})})}),F&&s.strategy===`tiered`&&(0,E.jsx)(u,{ariaLabel:g(`tokens.pool.tier`),value:String(t.tier),onChange:e=>f({tier:Number(e)}),options:[`1`,`2`,`3`].map(e=>({value:e,label:g(`tokens.pool.tierN`,{n:e})}))}),k&&(0,E.jsx)(u,{ariaLabel:g(`tokens.directAccount`),value:t.accountId??``,onChange:e=>f({accountId:e||null}),options:[{value:``,label:g(`clients.accountDefault`)},...(A.data??[]).map(e=>({value:e.id,label:e.displayName||e.id}))]}),(0,E.jsx)(c,{size:`sm`,variant:`plain`,icon:(0,E.jsx)(w,{className:`size-3.5`}),"aria-label":g(`tokens.pool.remove`,{provider:j}),title:g(`tokens.pool.remove`,{provider:j}),onClick:p})]})]})}export{P as a,k as i,N as n,O as r,F as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ca as e,Ea as t,Gr as n,J as r,K as i,Or as a,Qt as o,Sa as s,V as c,Y as l,Z as u,Zr as d,_ as f,_r as p,br as m,c as h,d as g,l as _,li as v,n as y,nr as b,on as x,ot as S,p as C,pt as w,q as T,r as E,s as D,t as O,v as k,vt as A}from"./alert-BzjF81CS.js";import{a as j,gt as M,i as N,n as ee,o as P,r as F}from"./overlays-8ByMRpma.js";import{t as te}from"./ellipsis-Br3iFNj9.js";import{t as ne}from"./pencil-o6T1_skE.js";import{t as re}from"./power-BJvJ4uzr.js";import{t as ie}from"./rotate-ccw-CqwU1cME.js";import{B as I,I as ae,N as L,R,V as oe,Y as z,_ as B,h as V,s as H,y as U}from"./index-D7HIE1TG.js";import{a as se,i as W,n as G,r as K,t as q}from"./TokenPoolEditor-D8mQHyNt.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 ce=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 le=A(Y),X=t(e(),1),Z=s();function ue(){let{t:e}=S(),t=n(),r=a(),i=d(),o=i.data?.state===`connected`?i.data.publicUrl:null,[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null);return(0,Z.jsxs)(V,{title:e(`nav.tokens`),subtitle:e(`tokens.subtitle`),actions:(0,Z.jsx)(E,{variant:`primary`,icon:(0,Z.jsx)(R,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`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:e(`tokens.directHint`,{url:`${r.data.gatewayBaseUrl}/v1`})}),(0,Z.jsx)(`p`,{className:`selectable`,children:e(`tokens.selfServiceHint`,{url:r.data.gatewayBaseUrl})}),o&&(0,Z.jsx)(`p`,{className:`selectable text-[var(--accent)]`,children:e(`tokens.remoteHint`,{url:`${o}/v1`,key:`${o}/key`})})]}),t.isLoading&&(0,Z.jsx)(k,{lines:4}),t.isError&&(0,Z.jsx)(O,{tone:`danger`,title:e(`common.error`),children:j(t.error)}),t.data?.length===0&&(0,Z.jsx)(`div`,{className:`card`,children:(0,Z.jsx)(h,{icon:(0,Z.jsx)(I,{className:`size-6`}),title:e(`tokens.empty`)})}),t.data&&t.data.length>0&&(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:t.data.map(e=>(0,Z.jsx)(de,{token:e,defaultOpen:t.data.length===1,onEdit:()=>u(e)},e.id))})]}),(0,Z.jsx)(ge,{open:s,onOpenChange:c}),(0,Z.jsx)(_e,{token:l,onClose:()=>u(null)})]})}function de({token:e,defaultOpen:t,onEdit:n}){let{t:i,locale:o}=S(),{toast:s,confirm:l}=P(),d=b(),f=a(),h=m(),g=v(),_=p(),C=x(),[O,k]=(0,X.useState)(t),A=(d.data??[]).find(t=>t.id===e.providerId),N=se(),F=`token-detail-${e.id}`,I=(e,t)=>{s(t,`success`),e.skipped.length>0&&s(i(`tokens.skipped`,{clients:e.skipped.map(e=>B[e]?.name??e).join(`, `)}),`error`)},R=()=>h.mutate(e.id,{onSuccess:async({token:e})=>{await M.copy(e)?s(i(`tokens.copied`)):s(i(`tokens.copyFailed`),`error`)},onError:e=>s(j(e),`error`)}),V=async()=>{let e=f.data?.gatewayBaseUrl;e&&(await M.copy(`${e}/v1`)?s(i(`tokens.urlCopied`)):s(i(`tokens.copyFailed`),`error`))},H=async()=>{(!e.enabled||await l({title:i(`tokens.disableConfirm`,{name:e.name}),detail:i(`tokens.disableDetail`),confirmLabel:i(`tokens.disable`),destructive:!0}))&&g.mutate({id:e.id,enabled:!e.enabled},{onError:e=>s(j(e),`error`)})},W=async()=>{await l({title:i(`tokens.resetConfirm`,{name:e.name}),detail:i(`tokens.resetDetail`),confirmLabel:i(`tokens.reset`),destructive:!0})&&_.mutate(e.id,{onSuccess:e=>I(e,i(`tokens.resetDone`,{count:e.rewritten.length})),onError:e=>s(j(e),`error`)})},K=async()=>{await l({title:i(`tokens.deleteConfirm`,{name:e.name}),detail:i(`tokens.deleteDetail`),confirmLabel:i(`common.delete`),destructive:!0})&&C.mutate(e.id,{onSuccess:t=>I(t,i(`tokens.deleted`,{name:e.name})),onError:e=>s(j(e),`error`)})},q=e.lastUsedAt?c(e.lastUsedAt,o):i(`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:()=>k(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":O,"aria-controls":F,"aria-label":i(`tokens.details`),onClick:e=>{e.stopPropagation(),k(e=>!e)},children:(0,Z.jsx)(oe,{className:`size-4 transition-transform ${O?`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)(y,{tone:`accent`,children:i(`tokens.default`)}),!e.enabled&&(0,Z.jsx)(y,{tone:`orange`,children:i(`tokens.disabledBadge`)}),e.limitUsage.some(e=>e.exhausted)&&(0,Z.jsx)(y,{tone:`orange`,children:i(`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)(y,{children:i(`tokens.pool.summary`,{count:e.pool.members.length,strategy:i(`tokens.strategy.${e.pool.strategy}`)})}),e.pool.members.map(e=>(0,Z.jsx)(D,{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)(E,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(w,{className:`size-3.5`}),"aria-label":i(`tokens.copy`),title:i(`tokens.copy`),loading:h.isPending,onClick:R}),(0,Z.jsx)(E,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(le,{className:`size-3.5`}),"aria-label":i(`tokens.copyUrl`),title:i(`tokens.copyUrl`),disabled:!f.data,onClick:()=>void V()})]})]})]}),(0,Z.jsx)(`div`,{className:`hidden w-16 items-center gap-1.5 md:flex`,title:e.clients.map(e=>B[e]?.name??e).join(`, `)||i(`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)(U,{kind:e,size:16},e))}),(0,Z.jsx)(Q,{label:i(`tokens.today`),value:u(e.today.costUsd),context:i(`tokens.requestsContext`,{count:r(e.today.requests)})}),(0,Z.jsx)(Q,{label:i(`tokens.total`),value:u(e.total.costUsd),context:`${r(e.total.totalTokens,!0)} Token`}),(0,Z.jsx)(Q,{label:i(`tokens.lastUsedTitle`),value:e.lastUsedAt?T(e.lastUsedAt,o):`—`,context:e.lastUsedAt?``:i(`tokens.neverUsed`),title:q}),(0,Z.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(ee,{label:i(`common.more`),icon:(0,Z.jsx)(te,{className:`size-4`}),items:[{id:`settings`,label:i(`tokens.settings`),icon:(0,Z.jsx)(ne,{className:`size-3.5`}),onSelect:n},{id:`toggle`,label:e.enabled?i(`tokens.disable`):i(`tokens.enable`),icon:(0,Z.jsx)(re,{className:`size-3.5`}),onSelect:()=>void H()},{id:`reset`,label:i(`tokens.reset`),icon:(0,Z.jsx)(ie,{className:`size-3.5`}),onSelect:()=>void W()},...e.isDefault?[]:[{id:`delete`,label:i(`tokens.delete`),icon:(0,Z.jsx)(L,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void K()}]]})})]}),O&&(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:i(`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?i(`tokens.noClients`):e.clients.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(U,{kind:e,size:14}),B[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?i(`tokens.pool.title`):i(`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)(D,{tone:G(e.health.state)}),(d.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:i(`tokens.directNone`))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.allowedClients`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:e.allowedClients==null?i(`tokens.allowedClientsAny`):e.allowedClients.length===0?i(`tokens.directOnly`):e.allowedClients.map(e=>B[e]?.name??e).join(`, `)})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--text-muted)]`,children:i(`tokens.lastUsedTitle`)}),(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate text-[var(--text-secondary)]`,children:q})]})]}),(0,Z.jsx)(fe,{token:e}),(0,Z.jsx)(me,{today:e.today,total:e.total}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,Z.jsx)(z,{to:`/tokens/${encodeURIComponent(e.id)}`,children:(0,Z.jsx)(E,{size:`sm`,icon:(0,Z.jsx)(ce,{className:`size-3.5`}),children:i(`tokens.detail.open`)})}),(0,Z.jsx)(z,{to:`/requests?token=${encodeURIComponent(e.id)}`,children:(0,Z.jsx)(E,{size:`sm`,icon:(0,Z.jsx)(ae,{className:`size-3.5`}),children:i(`tokens.detail.viewLogs`)})})]})]})]})}function fe({token:e}){let{t}=S(),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)(pe,{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 pe({usage:e}){let{t,locale:n}=S(),i=`${t(`tokens.period.${e.period}`)} · ${t(`tokens.metric.${e.metric}`)}`,a=t=>e.metric===`cost`?u(t):r(t,!0),o=Math.max(0,Math.min(100,Math.round(e.usedPercent))),s=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:t(`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:s}})}),e.resetsAt&&(0,Z.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[var(--text-muted)]`,children:t(`tokens.limitResets`,{time:c(e.resetsAt,n)})})]})}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 me({today:e,total:t}){let{t:n}=S(),a=[[n(`tokens.today`),e],[n(`tokens.total`),t]],o=`px-3 py-1.5 text-right font-normal whitespace-nowrap text-[var(--text-muted)]`,s=`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:`${o} text-left`}),(0,Z.jsx)(`th`,{className:o,children:n(`tokens.cost`)}),(0,Z.jsx)(`th`,{className:o,children:n(`tokens.requests`)}),(0,Z.jsx)(`th`,{className:o,children:n(`tokens.tokens`)}),(0,Z.jsx)(`th`,{className:o,children:n(`tokens.inOut`)}),(0,Z.jsx)(`th`,{className:o,children:n(`tokens.cacheHit`)}),(0,Z.jsx)(`th`,{className:o,title:n(`tokens.tpsContext`),children:n(`tokens.tps`)})]})}),(0,Z.jsx)(`tbody`,{children:a.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:`${s} font-semibold selectable`,children:u(t.costUsd)}),(0,Z.jsx)(`td`,{className:s,children:r(t.requests)}),(0,Z.jsx)(`td`,{className:s,children:r(t.totalTokens,!0)}),(0,Z.jsxs)(`td`,{className:`${s} text-[var(--text-secondary)]`,children:[r(t.inputTokens,!0),` / `,r(t.outputTokens,!0)]}),(0,Z.jsx)(`td`,{className:s,title:n(`usage.cacheAmounts`,{read:r(t.cacheReadTokens,!0),write:r(t.cacheWriteTokens,!0)}),children:t.cacheHitRate==null?`—`:i(t.cacheHitRate)}),(0,Z.jsx)(`td`,{className:s,children:t.tps==null?`—`:l(t.tps)})]},e))})]})})}function he(){let{t:e}=S(),t=(b().data??[]).filter(e=>e.enabled);return{providers:t,options:[{value:``,label:e(`tokens.directNone`)},...t.map(e=>({value:e.id,label:e.name}))]}}function ge({open:e,onOpenChange:t}){let{t:n}=S(),{toast:r}=P(),i=o(),{options:a}=he(),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(``);return(0,X.useEffect)(()=>{e&&(c(``),u(``))},[e]),(0,Z.jsx)(N,{open:e,onOpenChange:t,title:n(`tokens.createTitle`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(E,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,Z.jsx)(E,{variant:`primary`,disabled:!s.trim(),loading:i.isPending,onClick:()=>i.mutate({name:s.trim(),providerId:l||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)(_,{label:n(`tokens.name`),children:(0,Z.jsx)(g,{value:s,maxLength:64,placeholder:n(`tokens.namePlaceholder`),onChange:e=>c(e.target.value)})}),(0,Z.jsx)(_,{label:n(`tokens.directProvider`),children:(0,Z.jsx)(F,{value:l,onChange:u,options:a})})]})})}function _e({token:e,onClose:t}){let{t:n}=S(),{toast:r}=P(),i=v(),a=b(),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)([]),[p,m]=(0,X.useState)(null),[h,y]=(0,X.useState)(`any`),[x,w]=(0,X.useState)([]),T=new Set(u.map(e=>`${e.metric}:${e.period}`)).size<u.length,D=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`),w(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)(E,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(E,{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:h===`any`?null:x},{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)(_,{label:n(`tokens.name`),children:(0,Z.jsx)(g,{value:o,maxLength:64,onChange:e=>s(e.target.value)})}),(0,Z.jsx)(_,{label:n(`tokens.pool.title`),hint:n(`tokens.pool.hint`),children:c&&(0,Z.jsx)(q,{draft:c,onChange:l,providers:a.data??[],health:D})}),(0,Z.jsx)(_,{label:n(`tokens.limits`),hint:n(`tokens.limitsHint`),error:T?n(`tokens.limitDuplicate`):void 0,children:(0,Z.jsx)(ye,{budgets:u,onChange:d})}),(0,Z.jsx)(_,{label:n(`tokens.rpm`),hint:n(`tokens.rpmHint`),children:(0,Z.jsx)(C,{value:p,min:1,step:1,label:n(`tokens.rpm`),placeholder:n(`tokens.unlimited`),onChange:m})}),(0,Z.jsx)(_,{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:h,onChange:y,items:[{value:`any`,label:n(`tokens.allowedClientsAny`)},{value:`only`,label:n(`tokens.allowedClientsOnly`)}]}),h===`only`&&(0,Z.jsx)(H,{label:n(`tokens.allowedClients`),options:[...new Set([...Object.keys(B),...x])].map(e=>({value:e,label:B[e]?.name??e})),value:x,onValueChange:e=>w(e)})]})})]})})}var $=[`cost`,`requests`,`tokens`],ve=[`day`,`week`,`month`,`total`];function ye({budgets:e,onChange:t}){let{t:n}=S(),r=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),i=$.flatMap(e=>ve.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:ve.map(e=>({value:e,label:n(`tokens.period.${e}`)}))}),(0,Z.jsx)(C,{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)(E,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(L,{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)(E,{size:`sm`,icon:(0,Z.jsx)(R,{className:`size-3.5`}),onClick:()=>t([...e,{...i,limit:null}]),children:n(`tokens.addLimit`)})})]})}export{ue as TokensPage};
|
|
@@ -1 +0,0 @@
|
|
|
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-BzjF81CS.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-8ByMRpma.js";import{t as h}from"./TrayPanelView-daUwEIRH.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};
|