@aidotnet/server-win32-x64 0.14.3112 → 0.14.3114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/bin/astra-server.exe +2 -2
  2. package/bin/wwwroot/assets/ClientsPage-BhnTX0ew.js +11 -0
  3. package/bin/wwwroot/assets/{KeyPage-Db9tYWgA.js → KeyPage-D8xcW85A.js} +1 -1
  4. package/bin/wwwroot/assets/LibraryPage-BO51S5vR.js +2 -0
  5. package/bin/wwwroot/assets/McpPage-BFav-GE-.js +9 -0
  6. package/bin/wwwroot/assets/ModelDetailPage-CRE3OFy5.js +1 -0
  7. package/bin/wwwroot/assets/{ModelsPage-Dc1KK7-3.js → ModelsPage-BsRk0_yk.js} +1 -1
  8. package/bin/wwwroot/assets/PluginsPage-blIrwXbf.js +2 -0
  9. package/bin/wwwroot/assets/{PrivacyPage-Dsaaw5Ko.js → PrivacyPage-bKxw2Y54.js} +1 -1
  10. package/bin/wwwroot/assets/ProviderDetailPage-3YGtfo9v.js +3 -0
  11. package/bin/wwwroot/assets/ProvidersPage-B0XULeAs.js +3 -0
  12. package/bin/wwwroot/assets/{RoutingGroupsPage-B-7FNn_B.js → RoutingGroupsPage-Dz-TTq1a.js} +3 -3
  13. package/bin/wwwroot/assets/SettingsPage-CFVirZNv.js +2 -0
  14. package/bin/wwwroot/assets/{SkillsPage-BdZSd_hw.js → SkillsPage-DI61DG2m.js} +1 -1
  15. package/bin/wwwroot/assets/SmartRoutingPage-CpchDlXC.js +2 -0
  16. package/bin/wwwroot/assets/TokenDetailPage-PqVFcudk.js +1 -0
  17. package/bin/wwwroot/assets/{TokenPoolEditor-CISTyNzC.js → TokenPoolEditor-IS5Zwuqf.js} +1 -1
  18. package/bin/wwwroot/assets/TokensPage-CXK5_J6v.js +1 -0
  19. package/bin/wwwroot/assets/ToolsPage-B_JZpB1h.js +1 -0
  20. package/bin/wwwroot/assets/{TracesPage-f3hY7JcZ.js → TracesPage-CgbFQFzA.js} +3 -3
  21. package/bin/wwwroot/assets/{TrayPanelPage-HGV5ST-e.js → TrayPanelPage-Z4vWiyK-.js} +1 -1
  22. package/bin/wwwroot/assets/{TrayPanelView-BhyK24F_.js → TrayPanelView-Cauh6r_o.js} +1 -1
  23. package/bin/wwwroot/assets/TrayTitleSource-B98nYas3.js +41 -0
  24. package/bin/wwwroot/assets/{checkbox-CZ-rG7I2.js → checkbox-29lSW_6h.js} +1 -1
  25. package/bin/wwwroot/assets/confirm-morph-DpNjlFyg.js +1 -0
  26. package/bin/wwwroot/assets/{format-CmXxTS5M.js → format-CskGUFYy.js} +4 -4
  27. package/bin/wwwroot/assets/{index-BW8keTkg.js → index-D2siu6xk.js} +16 -16
  28. package/bin/wwwroot/assets/{radio-cards-BTn8kpAx.js → radio-cards-CNQWIuu8.js} +1 -1
  29. package/bin/wwwroot/assets/{sortable.esm-Cj5-STJU.js → sortable.esm-BvMId5KB.js} +1 -1
  30. package/bin/wwwroot/assets/use-transform-BPiFWEVF.js +1 -0
  31. package/bin/wwwroot/index.html +4 -4
  32. package/package.json +1 -1
  33. package/bin/wwwroot/assets/ClientsPage-CE9QdKbh.js +0 -11
  34. package/bin/wwwroot/assets/LibraryPage-Djro5zZa.js +0 -2
  35. package/bin/wwwroot/assets/McpPage-BJ7D5vt6.js +0 -9
  36. package/bin/wwwroot/assets/ModelDetailPage-DuyD1_Ei.js +0 -1
  37. package/bin/wwwroot/assets/PluginsPage-Dn1IYmlm.js +0 -2
  38. package/bin/wwwroot/assets/ProviderDetailPage-C5YbB46r.js +0 -3
  39. package/bin/wwwroot/assets/ProvidersPage-BzICHtxh.js +0 -3
  40. package/bin/wwwroot/assets/SettingsPage-CCOHxf9s.js +0 -2
  41. package/bin/wwwroot/assets/SmartRoutingPage-DIkU4HND.js +0 -2
  42. package/bin/wwwroot/assets/TokenDetailPage-DA6q9gbd.js +0 -1
  43. package/bin/wwwroot/assets/TokensPage-CUJXAz7I.js +0 -1
  44. package/bin/wwwroot/assets/ToolsPage-DOHJoH86.js +0 -1
  45. package/bin/wwwroot/assets/TrayTitleSource-DN10ruw2.js +0 -41
  46. package/bin/wwwroot/assets/confirm-morph-Cakq9Lho.js +0 -1
  47. package/bin/wwwroot/assets/use-transform-BcmlojQJ.js +0 -1
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/astra-server.exe
3
- size: 84733440 bytes
4
- sha256: 0e8fc372d06eaf31b57db703c1c545f149adf820008006888fac735f5eea9f2d
3
+ size: 84813312 bytes
4
+ sha256: 783cc02a553f53001e2d9e9424e4262bb33bcf3dae43a54ebd1a0711540a166e
@@ -0,0 +1,11 @@
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$r as n,$s as r,$t as i,An as a,B as o,Ct as s,D as c,F as l,Go as u,Gt as d,H as f,I as p,Kn as m,M as h,N as g,O as _,P as v,Qa as y,Qn as b,Qs as x,Qt as S,S as C,Ta as ee,U as w,Un as T,Vi as E,W as D,Zt as O,_o as k,ci as te,cn as ne,d as A,di as re,dn as j,dt as M,ea as N,fa as ie,gi as ae,ji as oe,la as se,li as P,nn as ce,o as le,oa as ue,r as de,rn as fe,s as F,ua as I,un as pe,w as L,z as R}from"./format-CskGUFYy.js";import{B as me,H as z,L as he,R as B,U as V,V as H,W as U}from"./TrayTitleSource-B98nYas3.js";import{t as ge}from"./archive-CiVf7slo.js";import{t as W}from"./check-DKfsh0bQ.js";import{t as G}from"./chevron-right-Bgtn3ze-.js";import{t as _e}from"./circle-arrow-up-x7NR55Yx.js";import{t as ve}from"./copy-48gwhhDO.js";import{t as K}from"./ellipsis-CidyZaW2.js";import{t as ye}from"./external-link-D6jQM2CZ.js";import{t as be}from"./folder-open-z1RXMZa1.js";import{t as xe}from"./grip-vertical-DFI2_ajd.js";import{t as Se}from"./key-round-m9ps8ZDi.js";import{t as Ce}from"./layers-lBgMUT4n.js";import{t as we}from"./loader-circle-D-RkwQwX.js";import{t as Te}from"./plus-c3HzV6VX.js";import{t as Ee}from"./refresh-cw-CoLAai2c.js";import{t as De}from"./rotate-ccw-fsXoCwyv.js";import{t as q}from"./scroll-text-DjXe21uH.js";import{t as J}from"./shield-alert-psW-CN8y.js";import{t as Oe}from"./trash-BHBJn5GS.js";import{t as ke}from"./x-AFrW8zH7.js";import{a as Ae,c as je,d as Me,f as Ne,i as Pe,l as Fe,n as Ie,o as Le,r as Re,s as ze,t as Be,u as Ve}from"./sortable.esm-BvMId5KB.js";import{B as He,C as Ue,G as We,H as Ge,T as Y,W as Ke,i as qe,o as Je,v as Ye,w as Xe,x as Ze}from"./index-D2siu6xk.js";import{n as Qe}from"./ProvidersPage-B0XULeAs.js";var X=e(t(),1),Z=r(),$e=`astra claude`;function et(e){return e.reduce((e,t)=>({requests:e.requests+1,inputTokens:e.inputTokens+t.inputTokens,totalInputTokens:e.totalInputTokens+t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,outputTokens:e.outputTokens+t.outputTokens,failed:e.failed+ +(t.status===`error`),estimatedCostNanoUsd:e.estimatedCostNanoUsd+(t.estimatedCostNanoUsd??0)}),{requests:0,inputTokens:0,totalInputTokens:0,outputTokens:0,failed:0,estimatedCostNanoUsd:0})}var tt=e=>e.status===`active`&&e.enabled;function nt(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return tt(e)?n:`${n} · ${t}`}function rt({enabled:e,gatewayEnabled:t}){let{t:n}=L(),{toast:r}=U(),i=Ke(),a=ce(e),o=ue(),[s,c]=(0,X.useState)(null),u=a.data?.mode??`gateway`,d=a.data?.accounts??[],p=a.data?.accountId??null??d.find(tt)?.id??null,m=d.find(e=>e.id===p),h=u===`direct`,v=t&&(h||a.data!=null),y=h&&m?.telemetryEnabled===!0,b=fe(y?m?.id:null,y),x=o.isPending,S=e=>o.mutate(e,{onError:e=>r(V(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(l,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(R,{label:n(`clients.claudeDirect.mode`),detail:n(h?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(f,{ariaLabel:n(`clients.claudeDirect.mode`),value:u,onChange:e=>{if(e===u||x||!a.data)return;let t=p??d.find(tt)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}S({mode:e,accountId:t})},items:[{value:`gateway`,label:n(`clients.claudeDirect.gateway`)},{value:`direct`,label:n(`clients.claudeDirect.direct`)}]})}),(0,Z.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`clients.claudeDirect.modeNote`)})]}),a.isLoading&&(0,Z.jsx)(w,{lines:3}),a.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(C,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:V(a.error)})}),v&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(C,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),a.data&&(0,Z.jsx)(l,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:d.length===0?(0,Z.jsx)(g,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(_,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(R,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(H,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:p,onChange:e=>{x||e===p||S({mode:u,accountId:e})},options:d.map(e=>({value:e.id,label:nt(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!tt(e)}))})})}),a.data&&h&&m&&(0,Z.jsx)(l,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(it,{command:$e,copied:s,onCopy:async e=>{await B.copy(e)&&(c(e),r(n(`common.copied`)))}})}),a.data&&h&&m&&(0,Z.jsxs)(l,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(R,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(D,{label:n(`clients.claudeDirect.statsConsent`),checked:m.telemetryEnabled,disabled:x,onChange:e=>{m&&!x&&S({mode:u,accountId:m.id,telemetryEnabled:e})}})}),y&&(0,Z.jsx)(at,{requests:b})]})]})}function it({command:e,copied:t,onCopy:n}){let{t:r}=L();return(0,Z.jsx)(R,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(_,{size:`sm`,icon:(0,Z.jsx)(ve,{className:`size-3`}),variant:t===e?`primary`:`glass`,"aria-label":r(`common.copy`),title:r(`common.copy`),onClick:()=>void n(e),children:r(t===e?`common.copied`:`common.copy`)})})}function at({requests:e}){let{t,locale:n}=L(),r=e.data??[],i=et(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(w,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(C,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:V(e.error)})}):r.length===0?(0,Z.jsx)(g,{icon:(0,Z.jsx)(Se,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{label:t(`clients.claudeDirect.statsTotals`,{count:A(i.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:A(i.totalInputTokens),cache:A(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:A(i.outputTokens)})}),(0,Z.jsx)(R,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:F(r.some(e=>e.estimatedCostNanoUsd!=null)?i.estimatedCostNanoUsd:null)})}),i.failed>0&&(0,Z.jsx)(R,{label:t(`clients.claudeDirect.statsFailedCount`,{count:A(i.failed)}),children:(0,Z.jsx)(c,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(R,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Z.jsx)(c,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(c,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[de(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:A(e.inputTokens),output:A(e.outputTokens)}),e.durationMs==null?null:le(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:F(e.estimatedCostNanoUsd)})},e.id))]})}function ot({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=L(),a=(e,r)=>{let i={...t};r===void 0||r===!1||r===0||r==="default"||r===``?delete i[e]:i[e]=r,n(i)};return(0,Z.jsx)(l,{title:i(`clients.options.title`),footer:i(r?`clients.options.footerEnabled`:`clients.options.footer`),children:e.map(e=>{let n=i(`clients.option.${e.key}`),r=i(`clients.option.${e.key}.hint`),o=t[e.key];return(0,Z.jsxs)(R,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(D,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Z.jsx)(p,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof o==`number`?String(o):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);a(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Z.jsx)(H,{ariaLabel:n,value:typeof o==`string`?o:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var st=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],ct=e=>typeof e==`string`&&st.includes(e);function lt(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))ct(r)&&(n[e]=r);return n}function ut(e){let t=e?.models;if(!t||typeof t!=`object`)return[];let n=[];for(let e of Object.values(t)){if(!e||typeof e!=`object`)continue;let t=e;typeof t.id==`string`&&t.id&&!n.some(e=>e.id===t.id)&&n.push({id:t.id,name:typeof t.name==`string`&&t.name?t.name:t.id,native:Array.isArray(t.protocols)?t.protocols.filter(ct):[]})}return n}function dt(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var ft=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
2
+ `),pt=`auto`,mt=e=>Qe.find(t=>t.value===e)?.label??e;function ht({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=L(),o=(e,t)=>{let i={...n};t===pt?delete i[e]:i[e]=t,r(i)};return(0,Z.jsx)(l,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=dt(e,t),i=e.native.filter(e=>t.includes(e));return(0,Z.jsx)(R,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(mt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Z.jsx)(H,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:pt,onChange:t=>o(e.id,t),options:[{value:pt,label:a(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:mt(r.protocol)})},...t.map(e=>({value:e,label:mt(e)}))]})},e.id)})})}function gt(e){let t=e?.modelShortlist;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function _t({client:e}){let{t}=L(),{toast:n}=U(),r=pe(e.kind,!0,!0),i=ie(),a=gt(e.extras),s=a.join(`
3
+ `),[c,u]=(0,X.useState)(a),[d,f]=(0,X.useState)(``);(0,X.useEffect)(()=>u(gt(e.extras)),[e.kind,s]);let p=(0,X.useMemo)(()=>r.data??[],[r.data]),m=(0,X.useMemo)(()=>[...p,...c.filter(e=>!p.includes(e))],[p,c]),h=m.filter(e=>e.toLowerCase().includes(d.trim().toLowerCase())),g=c.join(`
4
+ `)!==s,v=(e,t)=>u(n=>t?[...n,e]:n.filter(t=>t!==e)),y=r=>i.mutate({kind:e.kind,models:r},{onSuccess:()=>n(t(`common.saved`),`success`),onError:e=>n(V(e),`error`)});return(0,Z.jsxs)(l,{title:t(`clients.shortlist.title`),footer:e.enabled?t(`clients.shortlist.footerEnabled`):t(`clients.shortlist.footer`),children:[(0,Z.jsxs)(R,{label:c.length===0?t(`clients.shortlist.empty`):t(`clients.shortlist.summary`,{count:c.length,total:m.length}),children:[c.length>0&&(0,Z.jsx)(_,{size:`sm`,onClick:()=>u([]),children:t(`clients.shortlist.clear`)}),g&&(0,Z.jsx)(_,{size:`sm`,variant:`primary`,loading:i.isPending,onClick:()=>y(c),children:t(`common.apply`)})]}),r.isLoading&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(w,{lines:2})}),m.length>8&&(0,Z.jsx)(`div`,{className:`px-4 py-2`,children:(0,Z.jsx)(o,{value:d,onChange:f,placeholder:t(`clients.shortlist.filter`)})}),(0,Z.jsx)(`div`,{className:`max-h-[320px] overflow-y-auto`,children:h.map(e=>(0,Z.jsx)(R,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e}),detail:p.includes(e)?void 0:t(`clients.shortlist.missing`),children:(0,Z.jsx)(D,{checked:c.includes(e),onChange:t=>v(e,t),label:e})},e))})]})}var vt={enable:`green`,update:`accent`,disable:`orange`,store:`neutral`,unchanged:`neutral`,skipped:`orange`,failed:`red`};function yt(){let{t:e}=L(),{toast:t,confirm:n}=U(),r=P(),i=N(),o=k(),s=a(),l=r.data??[],u=l.find(e=>e.active),[d,f]=(0,X.useState)(``),m=l.find(e=>e.id===d)??u??l[0],[h,g]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),x=()=>{if(!h)return;let n=h.name.trim();if(!n)return;let r=n=>{g(null),f(n.id),t(e(`profiles.saved`,{name:n.name}),`success`)};h.id===null?i.mutate(n,{onSuccess:r,onError:e=>t(V(e),`error`)}):o.mutate({id:h.id,name:n},{onSuccess:r,onError:e=>t(V(e),`error`)})},S=async r=>{await n({title:e(`profiles.overwriteConfirm`,{name:r.name}),confirmLabel:e(`profiles.overwrite`)})&&o.mutate({id:r.id,overwrite:!0},{onSuccess:()=>t(e(`profiles.saved`,{name:r.name}),`success`),onError:e=>t(V(e),`error`)})},C=async r=>{await n({title:e(`profiles.deleteConfirm`,{name:r.name}),confirmLabel:e(`profiles.delete`),destructive:!0})&&s.mutate(r.id,{onSuccess:()=>f(``),onError:e=>t(V(e),`error`)})};return(0,Z.jsxs)(`div`,{className:`card mb-4 flex flex-wrap items-center gap-3 px-4 py-2.5`,children:[(0,Z.jsx)(Ce,{className:`size-4 text-[var(--text-secondary)]`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-[13px] font-medium`,children:e(`profiles.title`)}),l.length===0?(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`profiles.none`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{className:`w-[220px]`,ariaLabel:e(`profiles.pick`),value:m?.id??``,onChange:f,options:l.map(t=>({value:t.id,label:t.name,detail:e(`profiles.clientCount`,{count:t.clients.length})}))}),m?.active&&!m.drifted&&(0,Z.jsx)(c,{tone:`green`,children:e(`profiles.active`)}),m?.active&&m.drifted&&(0,Z.jsxs)(c,{tone:`orange`,title:e(`profiles.driftedHint`),children:[e(`profiles.active`),` · `,e(`profiles.drifted`)]})]}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[m&&(0,Z.jsx)(_,{variant:`primary`,size:`sm`,onClick:()=>b(m.id),children:e(`profiles.apply`)}),(0,Z.jsx)(_,{size:`sm`,onClick:()=>g({id:null,name:``}),children:e(`profiles.save`)}),m&&(0,Z.jsx)(me,{label:e(`profiles.title`),icon:(0,Z.jsx)(K,{className:`size-4`}),iconOnly:!0,items:[{id:`overwrite`,label:e(`profiles.overwrite`),onSelect:()=>void S(m)},{id:`rename`,label:e(`profiles.rename`),onSelect:()=>g({id:m.id,name:m.name})},{id:`delete`,label:e(`profiles.delete`),destructive:!0,separatorBefore:!0,onSelect:()=>void C(m)}]})]}),(0,Z.jsx)(z,{open:h!==null,onOpenChange:e=>!e&&g(null),width:420,title:h?.id===null?e(`profiles.saveTitle`):e(`profiles.rename`),description:h?.id===null?e(`profiles.subtitle`):void 0,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{onClick:()=>g(null),children:e(`common.cancel`)}),(0,Z.jsx)(_,{variant:`primary`,disabled:!h?.name.trim(),loading:i.isPending||o.isPending,onClick:x,children:e(`common.save`)})]}),children:(0,Z.jsx)(v,{label:e(`profiles.name`),children:(0,Z.jsx)(p,{autoFocus:!0,maxLength:64,value:h?.name??``,onChange:e=>g(t=>t&&{...t,name:e.target.value}),onKeyDown:e=>e.key===`Enter`&&x()})})}),(0,Z.jsx)(St,{profile:l.find(e=>e.id===y)??null,onClose:()=>b(null)})]})}function bt(e,t){let n=[];e.reason&&n.push(e.action===`failed`?e.reason:t(`profiles.reason.${e.reason}`)),e.changes.length>0&&n.push(e.changes.map(e=>e.keyPath).join(`, `));for(let r of e.notes)n.push(r.startsWith(`drifted:`)?t(`profiles.drift`,{key:r.slice(8)}):r);return n.join(` · `)}function xt(e,t){let n=e.what===`provider`?t(`profiles.drop.provider.${e.reason}`,{id:e.id}):t(`profiles.drop.${e.what}`,{id:e.id});return`${e.kind}: ${n}`}function St({profile:e,onClose:t}){let{t:n}=L(),{toast:r}=U(),i=te(e?.id,e!==null),a=d(),o=(i.data?.steps??[]).filter(e=>e.action!==`unchanged`);return(0,Z.jsxs)(z,{open:e!==null,onOpenChange:e=>!e&&t(),width:620,title:n(`profiles.previewTitle`,{name:e?.name??``}),description:n(`profiles.previewDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(_,{variant:`primary`,disabled:!i.data,loading:a.isPending,onClick:()=>{e&&a.mutate(e.id,{onSuccess:i=>{let a=i.steps.filter(e=>e.action===`skipped`||e.action===`failed`).length;r(a>0?n(`profiles.appliedPartial`,{name:e.name,count:a}):n(`profiles.applied`,{name:e.name}),a>0?void 0:`success`),t()},onError:e=>r(V(e),`error`)})},children:n(`profiles.apply`)})]}),children:[i.isPending&&(0,Z.jsx)(w,{lines:4}),i.isError&&(0,Z.jsx)(C,{tone:`danger`,title:n(`common.error`),children:V(i.error)}),i.data&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.length===0&&(0,Z.jsx)(C,{tone:`info`,title:n(`profiles.nothing`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:o.map(e=>(0,Z.jsx)(R,{label:e.name,detail:bt(e,n)||void 0,children:(0,Z.jsx)(c,{tone:vt[e.action],children:n(`profiles.action.${e.action}`)})},e.kind))}),i.data.dropped.length>0&&(0,Z.jsx)(C,{tone:`warning`,title:n(`profiles.dropped`),children:i.data.dropped.map((e,t)=>(0,Z.jsx)(`span`,{className:`block break-all`,children:xt(e,n)},t))})]})]})}function Ct(e,t){if(!(e instanceof u)||e.status!==409)return null;let n=e.details;return n?.providerName?{title:t(`clients.providerDisabledTitle`,{name:n.providerName}),hint:t(n.pluginOff?`clients.providerDisabledPluginHint`:`clients.providerDisabledHint`)}:null}function wt(e,t){let n=e?.options,r={};if(!n||typeof n!=`object`)return r;for(let e of t??[]){let t=n[e.key];e.type===`bool`&&t===!0?r[e.key]=!0:(e.type===`int`&&typeof t==`number`&&t>0||e.type===`enum`&&typeof t==`string`&&t!=="default"&&e.choices?.includes(t))&&(r[e.key]=t)}return r}var Tt=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
5
+ `),Et=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`CLAUDE_CODE_SUBAGENT_MODEL`];function Dt(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of Et){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var Ot=e=>Et.map(t=>e[t]??``).join(`
6
+ `),Q=[`sonnet`,`opus`,`haiku`];function kt(e){let t=e?.roleMap,n={};if(!t||typeof t!=`object`)return n;for(let e of Q){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var $=e=>Q.map(t=>e[t]??``).join(`
7
+ `),At=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function jt(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!At.test(e))??e[0],r=e.find(e=>At.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function Mt(){let{t:e}=L(),t=Ke(),{toast:n}=U(),r=We(),a=j(),o=i(),s=(0,X.useMemo)(()=>new Map((a.data??[]).map(e=>[e.kind,e])),[a.data]),c=Pt(a.data).includes(r.kind)?r.kind:`codex`,l=s.get(c);return(0,X.useEffect)(()=>o.mutate(!1),[]),(0,Z.jsx)(Ye,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Z.jsx)(_,{icon:(0,Z.jsx)(Ee,{className:`size-3.5`}),loading:o.isPending,onClick:()=>o.mutate(!0,{onSuccess:t=>{let r=t.filter(e=>e.install?.updateAvailable&&e.install.blocker!==`shadowed`).length;n(r>0?e(`clients.updatesFound`,{count:r}):e(`clients.allUpToDate`),r>0?void 0:`success`)},onError:e=>n(V(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Z.jsxs)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:[(0,Z.jsx)(yt,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Z.jsx)(zt,{clients:a.data,loading:a.isLoading,selected:c,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[a.isLoading&&(0,Z.jsx)(w,{lines:4}),a.isError&&(0,Z.jsx)(C,{tone:`danger`,title:e(`common.error`),children:V(a.error)}),l&&(0,Z.jsx)(Ut,{client:l}),l&&(0,Z.jsxs)(`div`,{className:`mt-6`,children:[(0,Z.jsx)(qe,{menu:`client.row`,args:{clientKind:l.kind}}),(0,Z.jsx)(Je,{name:`client.detail.sections`,params:{clientKind:l.kind}})]})]})]})]})})}var Nt=new Set(`opencode.pi.minimax-code.copilot-cli.vscode-copilot.crush.qwen-code.droid.kimi-code.zed.vscode-insiders.vscodium.omp.mimo-code.deepseek-harness.workbuddy.workbuddy-ai.nextcowork.paseo.zcode.tkcode.muse-code.codex.grok-build.hermes-agent.openchamber.deveco-code.stepcode.aside.omo.prime-agent.mu.mothx.penguin-harness.antigravity-cli.dim.command-code.fx.goose.zoo-code.jetbrains-air.air-ide.copilot-jetbrains.codebuddy.qoder.qoder-cn.t3code.pencil.openpencil.raycast.obsidian.reasonix.morph.jcode.vibe.empryo.nanobot.miniq.paimon.cline.grok-app.atomcode.snow.ante.craft-agents.tuanjie-cowork.liveagent.openmausbot.astrbot.qwenpaw.openclaw.openbot`.split(`.`));function Pt(e){let t=(e??[]).filter(e=>!Ze.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Ze,...t.map(e=>e.kind)]}var Ft=[`installed`,`notInstalled`,`comingSoon`],It=new Set([`notInstalled`]);function Lt(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function Rt(e){return e.install?.version??e.detection.version??null}function zt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=L(),[a,o]=(0,X.useState)(new Set),s=new Map((e??[]).map(e=>[e.kind,e])),c=Ft.map(t=>({group:t,items:Pt(e).flatMap(e=>{let n=s.get(e);return n&&Lt(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Z.jsxs)(`nav`,{"aria-label":i(`nav.clients`),className:`card shrink-0 p-1.5 @3xl:sticky @3xl:top-0 @3xl:w-[232px]`,children:[t&&(0,Z.jsx)(w,{lines:6,className:`p-2`}),(0,Z.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:c.map(({group:e,items:t})=>{let s=It.has(e),c=!s||a.has(e)||t.some(e=>e.kind===n),l=`${i(`clients.group.${e}`)} · ${t.length}`;return(0,Z.jsxs)(`div`,{className:`contents @3xl:block`,children:[s?(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":c,"aria-label":i(c?`clients.group.collapse`:`clients.group.expand`,{group:l}),onClick:()=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),className:`flex shrink-0 items-center gap-1 rounded-[var(--radius-control)] px-2.5 py-1.5 text-[11px] font-medium whitespace-nowrap text-[var(--text-muted)] hover:bg-[var(--surface-muted)] @3xl:w-full @3xl:pt-2 @3xl:pb-1`,children:[(0,Z.jsx)(G,{size:12,className:M(`transition-transform`,c&&`rotate-90`)}),l]}):(0,Z.jsx)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:l}),c&&t.map(e=>(0,Z.jsx)(Bt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e)})})]})}function Bt({client:e,active:t,onSelect:n}){let{t:r}=L(),i=Lt(e)!==`installed`,a=Rt(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Z.jsxs)(`button`,{type:`button`,"aria-label":Y(e.kind,e.name),"aria-current":t?`page`:void 0,onClick:n,className:M(`flex shrink-0 items-center gap-2.5 rounded-[var(--radius-control)] px-2.5 py-1.5 text-left transition-colors @3xl:w-full`,t?`bg-[var(--accent-subtle)]`:`hover:bg-[var(--surface-muted)]`),children:[(0,Z.jsx)(`span`,{className:M(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Z.jsx)(Ue,{kind:e.kind,size:24})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:M(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:Y(e.kind,e.name)}),a&&(0,Z.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Z.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Z.jsx)(Vt,{}),s&&!e.install?.busy&&(0,Z.jsx)(c,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Z.jsx)(c,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Z.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Z.jsx)(h,{tone:`orange`})}):e.enabled?(0,Z.jsx)(W,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function Vt(){return(0,Z.jsx)(we,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function Ht(e,t){return e.availability===`coming_soon`?(0,Z.jsx)(c,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Z.jsx)(c,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Z.jsx)(c,{tone:`green`,children:t(`clients.enabled`)}):(0,Z.jsx)(c,{children:t(`clients.disabled`)})}function Ut({client:e}){let{t,locale:n}=L(),r=Ke(),{toast:i,confirm:a}=U(),o=ae(),s=se(),u=T(),d=b(),f=oe(),p=y(),m=pe(e.kind,!!e.providerId),[h,g]=(0,X.useState)(e.selectedModel??null),[v,x]=(0,X.useState)(e.accountId??``),S=e.tokenId??`default`,[ee,E]=(0,X.useState)(S),D=(p.data??[]).filter(e=>e.enabled||e.id===S).map(e=>({value:e.id,label:e.enabled?e.name:t(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[O,k]=(0,X.useState)(!1),[te,ne]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),M=e.availability===`coming_soon`,N=Y(e.kind,e.name),ie=(o.data??[]).filter(e=>e.enabled),P=e.detection.configPaths[0],le=ie.find(t=>t.id===e.providerId),ue=le?.authScheme===`oauth-subscription`||le?.authScheme===`plugin`,fe=re(le?.id,ue),F=e.kind===`claude-desktop`,I=e.kind===`claude-code`,me=ce(I),z=I&&me.data?.mode===`direct`,W=kt(e.extras),[G,_e]=(0,X.useState)(W),K=Q.some(e=>G[e]),ye=$(G)!==$(W),xe=Dt(e.extras),[Ce,we]=(0,X.useState)(xe),Te=(h??null)!==(e.selectedModel??null)||Ot(Ce)!==Ot(xe),Ee=I?Et.filter(e=>e!==`ANTHROPIC_MODEL`):[],De=I?e.enabled?t(`clients.modelSlotsFooterEnabled`):t(`clients.modelSlotsFooter`):e.enabled?t(`clients.modelFooterEnabled`):t(`clients.modelFooter`),q=e.options??[],J=wt(e.extras,q),[Oe,ke]=(0,X.useState)(J),Ae=Tt(Oe)!==Tt(J),je=e.protocols??[],Me=je.length>1?ut(e.extras):[],Ne=lt(e.extras),[Pe,Fe]=(0,X.useState)(Ne),Ie=ft(Pe)!==ft(Ne),Le=F?{...e.extras,roleMap:G}:I?{...e.extras,models:Ce,options:Oe}:q.length>0||je.length>1?{...e.extras,...q.length>0?{options:Oe}:{},...je.length>1?{protocolOverrides:Pe}:{}}:void 0;(0,X.useEffect)(()=>g(e.selectedModel??null),[e.kind,e.selectedModel]),(0,X.useEffect)(()=>x(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,X.useEffect)(()=>E(S),[e.kind,S]),(0,X.useEffect)(()=>_e(kt(e.extras)),[e.kind,$(W)]);let Re=(0,X.useRef)({});(0,X.useEffect)(()=>{if(!F||e.enabled||Q.some(e=>W[e]))return;let t=Re.current,n=jt(m.data??[]);Re.current=n,_e(e=>(!Q.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(W),(m.data??[]).join(`
8
+ `)]),(0,X.useEffect)(()=>we(Dt(e.extras)),[e.kind,Ot(xe)]),(0,X.useEffect)(()=>ke(wt(e.extras,e.options)),[e.kind,Tt(J)]),(0,X.useEffect)(()=>Fe(lt(e.extras)),[e.kind,ft(Ne)]);let ze=()=>{e.providerId&&s.mutate({kind:e.kind,providerId:e.providerId,accountId:v},{onSuccess:()=>i(t(`common.saved`),`success`),onError:e=>i(V(e),`error`)})},Be=async()=>{await a({title:t(`clients.disableConfirm`,{name:N}),detail:t(`clients.disableDetail`),confirmLabel:t(`clients.disable`)})&&u.mutate(e.kind,{onSuccess:async n=>{if(n.drifted.length===0){i(t(`clients.disabledToast`,{name:N}),`success`);return}await a({title:t(`clients.driftTitle`),detail:t(`clients.driftDetail`,{keys:n.drifted.join(`, `)}),confirmLabel:t(`clients.forceRestore`),destructive:!0})&&d.mutate(e.kind,{onSuccess:()=>i(t(`clients.disabledToast`,{name:N}),`success`),onError:e=>i(V(e),`error`)})},onError:e=>i(V(e),`error`)})},Ve=async()=>{P&&(B.canOpenPaths?await B.openPath(he(P)):await B.copy(P)&&i(t(`common.copied`)))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(l,{children:[(0,Z.jsxs)(R,{icon:(0,Z.jsx)(Ue,{kind:e.kind,size:36}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[15px] font-medium`,children:N}),z?(0,Z.jsx)(c,{children:t(`clients.claudeDirect.direct`)}):Ht(e,t)]}),detail:M?e.availabilityReason??t(`clients.comingSoonDetail`):[Lt(e)===`installed`?t(`clients.detected`,{version:Rt(e)??``}):t(`clients.notDetected`),z?null:P].filter(Boolean).join(` · `),className:`py-3`,children:[!M&&(0,Z.jsx)(Yt,{client:e,onOpen:j}),z?(0,Z.jsx)(_,{variant:`primary`,onClick:()=>document.getElementById(Zt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.claudeDirect.configure`)}):e.enabled?(0,Z.jsx)(_,{onClick:()=>void Be(),loading:u.isPending,children:t(`clients.disableRestore`)}):(0,Z.jsx)(_,{variant:`primary`,disabled:M||!e.providerId||F&&!K,onClick:()=>k(!0),title:e.providerId?F&&!K?t(`clients.roleMapRequired`):void 0:t(`clients.pickProviderFirst`),children:t(`clients.enable`)})]}),!z&&e.appliedAt&&(0,Z.jsx)(R,{label:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`clients.appliedAt`,{time:de(e.appliedAt,n)})})})]}),!M&&!e.enabled&&F&&e.providerId&&!K&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsx)(C,{tone:`info`,className:`self-stretch`,title:t(`clients.roleMapHint`)}),(0,Z.jsx)(_,{onClick:()=>document.getElementById(Qt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.roleMapGoto`)})]}),(e.repairs?.length??0)>0&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsxs)(C,{tone:`danger`,className:`self-stretch`,title:t(`clients.repair.title`,{name:N}),children:[e.repairs?.map(e=>(0,Z.jsxs)(`span`,{className:`block break-all`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,t(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Z.jsx)(`span`,{className:`block`,children:t(`clients.repair.hint`)})]}),(0,Z.jsx)(_,{variant:`primary`,loading:f.isPending,onClick:()=>f.mutate(e.kind,{onSuccess:()=>i(t(`clients.repair.done`,{name:N}),`success`),onError:e=>i(V(e),`error`)}),children:t(`clients.repair.action`)})]}),!z&&e.warnings.length>0&&(0,Z.jsx)(`div`,{className:`mb-5 flex flex-col gap-2`,children:e.warnings.map((e,t)=>(0,Z.jsx)(C,{tone:`warning`,title:e},t))}),!z&&(0,Z.jsx)(qt,{client:e,providers:o.data??[],loading:o.isLoading,soon:M}),!z&&ue&&(0,Z.jsx)(l,{title:t(`clients.accountTitle`),footer:t(`clients.accountFooter`),children:fe.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(w,{lines:2})}):(0,Z.jsxs)(R,{label:t(`clients.account`),children:[(0,Z.jsx)(H,{className:`max-w-[300px]`,ariaLabel:t(`clients.account`),value:v,onChange:x,options:[{value:``,label:t(`clients.accountDefault`)},...(fe.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${t(`providers.subscription.status.${e.status}`)}`)}))]}),v!==(e.accountId??``)&&(0,Z.jsx)(_,{size:`sm`,variant:`primary`,loading:s.isPending,onClick:ze,children:t(`common.apply`)})]})}),!M&&!z&&(0,Z.jsxs)(l,{title:t(`clients.tokenTitle`),footer:e.enabled?t(`clients.tokenFooterEnabled`):t(`clients.tokenFooter`),children:[(0,Z.jsxs)(R,{label:t(`clients.token`),children:[(0,Z.jsx)(H,{className:`max-w-[300px]`,ariaLabel:t(`clients.token`),value:ee,onChange:E,options:D}),e.enabled&&ee!==S&&(0,Z.jsx)(_,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:t(`common.apply`)})]}),(0,Z.jsx)(R,{icon:(0,Z.jsx)(Se,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.manageTokens`),onClick:()=>r(`/tokens`)})]}),!M&&!z&&e.providerId&&F&&(0,Z.jsx)(`div`,{id:Qt,children:(0,Z.jsxs)(l,{title:t(`clients.roleMapTitle`),footer:e.enabled?t(`clients.roleMapFooterEnabled`):t(`clients.roleMapFooter`),children:[Q.map(e=>(0,Z.jsx)(R,{label:t(`clients.role.${e}`),children:(0,Z.jsx)(H,{ariaLabel:t(`clients.role.${e}`),value:G[e]??``,onChange:t=>_e(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(m.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&ye&&(0,Z.jsx)(R,{label:K?``:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:t(`clients.roleMapRequired`)}),children:(0,Z.jsx)(_,{size:`sm`,variant:`primary`,disabled:!K,onClick:()=>k(!0),children:t(`common.apply`)})})]})}),!M&&!z&&e.providerId&&!F&&(0,Z.jsxs)(l,{title:t(`clients.modelTitle`),footer:De,children:[(0,Z.jsx)(R,{label:t(`clients.defaultModel`),children:(0,Z.jsx)(H,{value:h??``,onChange:e=>g(e||null),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(m.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),Ee.map(e=>(0,Z.jsx)(R,{label:t(`clients.modelSlot.${e}`),children:(0,Z.jsx)(H,{ariaLabel:t(`clients.modelSlot.${e}`),value:Ce[e]??``,onChange:t=>we(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(m.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&(I?Te:(h??null)!==(e.selectedModel??null))&&(0,Z.jsx)(R,{label:``,children:(0,Z.jsx)(_,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:t(`common.apply`)})})]}),!M&&!z&&e.providerId&&!F&&(0,Z.jsx)(_t,{client:e}),!M&&!z&&q.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ot,{descriptors:q,values:Oe,onChange:ke,enabled:e.enabled}),e.enabled&&Ae&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(_,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:t(`common.apply`)})})]}),!M&&Me.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ht,{models:Me,supported:je,values:Pe,onChange:Fe,enabled:e.enabled}),e.enabled&&Ie&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(_,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:t(`common.apply`)})})]}),!M&&e.install&&(0,Z.jsx)(en,{client:e,onShowLog:()=>j(`log`),onUninstall:()=>j(`uninstall`)}),I&&(0,Z.jsx)(`div`,{id:Zt,children:(0,Z.jsx)(rt,{enabled:I,gatewayEnabled:e.enabled})}),!M&&!z&&(0,Z.jsxs)(l,{title:t(`clients.maintenance`),children:[P&&(0,Z.jsx)(R,{icon:B.canOpenPaths?(0,Z.jsx)(be,{className:`size-4 text-[var(--text-secondary)]`}):(0,Z.jsx)(ve,{className:`size-4 text-[var(--text-secondary)]`}),label:B.canOpenPaths?t(`clients.openConfigDir`):t(`clients.copyConfigPath`),detail:P,onClick:()=>void Ve()}),(0,Z.jsx)(R,{icon:(0,Z.jsx)(ge,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.backups`),detail:t(`clients.backupsDetail`),onClick:()=>ne(!0)})]}),(0,Z.jsx)(nn,{open:O,onOpenChange:k,client:e,model:h,extras:Le,tokenId:ee}),(0,Z.jsx)(on,{open:te,onOpenChange:ne,client:e}),(0,Z.jsx)(tn,{mode:A,onClose:()=>j(null),client:e})]})}var Wt={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},Gt={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Kt(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function qt({client:e,providers:t,loading:n,soon:r}){let{t:i}=L(),{toast:a}=U(),o=I(),s=(0,X.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[c,u]=(0,X.useState)(s);(0,X.useEffect)(()=>u(s),[s]);let d=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),f=c.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=t.filter(e=>e.enabled&&!c.some(t=>t.providerId===e.id)),m=Me(Ve(je,{activationConstraint:{distance:4}}),Ve(ze,{coordinateGetter:Re})),h=r||o.isPending,v=(t,n)=>{let r=c;u(t),o.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(Nt.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:Y(e.kind,e.name)}):n),onError:e=>{u(r),a(V(e),`error`)}})},y=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=c.findIndex(t=>t.providerId===e.id),r=c.findIndex(e=>e.providerId===t.id);n<0||r<0||v(Ie(c,n,r),i(`clients.providerOrderSaved`))},b=e=>v([...c,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),x=e=>v(c.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),S=p.map(e=>(0,Z.jsx)(R,{icon:(0,Z.jsx)(Xe,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Kt(e,i),onClick:h?void 0:()=>b(e),children:!r&&(0,Z.jsx)(Te,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":i(`common.add`)})},e.id));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(l,{title:i(`clients.providerTitle`),footer:i(`clients.providerFooter`),children:[n&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(w,{lines:2})}),!n&&f.length===0&&p.length===0&&(0,Z.jsx)(g,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Z.jsx)(Ge,{to:`/providers?new=1`,children:(0,Z.jsx)(_,{variant:`primary`,icon:(0,Z.jsx)(Te,{className:`size-3.5`}),children:i(`providers.add`)})})}),f.length>0&&(0,Z.jsx)(Le,{sensors:m,collisionDetection:Fe,onDragEnd:y,children:(0,Z.jsx)(Be,{items:f.map(e=>e.provider.id),strategy:Ae,children:f.map(({provider:e},t)=>(0,Z.jsx)(Jt,{provider:e,primary:t===0,disabled:h,onRemove:f.length>1?()=>x(e):void 0},e.id))})}),!n&&f.length===0&&S]}),f.length>0&&p.length>0&&(0,Z.jsx)(l,{title:i(`clients.moreProvidersTitle`),children:S})]})}function Jt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=L(),{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:l,transform:u,transition:d,isDragging:f}=Pe({id:e.id,disabled:n});return(0,Z.jsx)(`div`,{ref:s,style:{transform:Ne.Transform.toString(u),transition:d},className:M(f&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Z.jsx)(R,{icon:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`button`,{ref:l,type:`button`,"aria-label":i(`clients.dragToReorder`,{provider:e.name}),title:i(`clients.dragToReorder`,{provider:e.name}),className:`-ml-1 inline-flex cursor-grab touch-none text-[var(--text-muted)] hover:text-[var(--text-secondary)] active:cursor-grabbing disabled:cursor-default disabled:opacity-50`,...a,...o,children:(0,Z.jsx)(xe,{className:`size-4`})}),(0,Z.jsx)(Xe,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})]}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,Z.jsx)(c,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Z.jsx)(c,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Kt(e,i),children:r&&(0,Z.jsx)(_,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(ke,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function Yt({client:e,onOpen:t}){let{t:n}=L(),r=e.install;if(!r)return null;let i=r.needsAdmin?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-[var(--warning)]`,children:[(0,Z.jsx)(J,{className:`size-3`,"aria-hidden":!0}),n(`clients.admin.badge`)]}):null,a=r.needsAdmin?n(r.adminAvailable?`clients.admin.tip`:`clients.admin.tipManual`):void 0;return r.busy?(0,Z.jsx)(_,{icon:(0,Z.jsx)(Vt,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Z.jsxs)(_,{icon:(0,Z.jsx)(_e,{className:`size-3.5`}),title:a,onClick:()=>t(`update`),children:[n(`clients.updateTo`,{version:r.latestVersion}),i]}):r.updateAvailable&&r.blocker===`shadowed`?(0,Z.jsx)(_,{icon:(0,Z.jsx)(J,{className:`size-3.5`}),onClick:()=>document.getElementById(Xt)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Z.jsxs)(_,{icon:(0,Z.jsx)(He,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Z.jsx)(_,{icon:(0,Z.jsx)(ye,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var Xt=`client-shadowed-alert`,Zt=`claude-direct-panel`,Qt=`client-role-map`;function $t(e,t){return!e.installed||e.uninstallCommand?null:e.method===`npm`?t(`clients.uninstallExternal`,{path:e.executable??``}):e.method===`vscode-extension`?t(`clients.uninstallBuiltIn`):t(`clients.uninstallManual`)}function en({client:e,onShowLog:t,onUninstall:n}){let{t:r,locale:i}=L(),a=e.install,o=ne(e.kind),s=(e,t=!1)=>(0,Z.jsx)(`span`,{className:M(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),u=a.blocker===`external-install`?r(`clients.blocker.external-install`,{path:a.executable??``}):a.blocker?r(`clients.blocker.${a.blocker}`):void 0,d=a.otherCopies??[],f=d.find(e=>e.newer);return(0,Z.jsxs)(Z.Fragment,{children:[f&&(0,Z.jsx)(`div`,{id:Xt,className:`mb-3`,children:(0,Z.jsx)(C,{tone:`warning`,title:r(`clients.shadowed.title`,{version:f.version}),children:r(`clients.shadowed.detail`,{path:a.executable??``,version:a.version??``,other:f.path,dir:he(f.path)})})}),!f&&a.notOnPath&&a.executable&&(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(C,{tone:`warning`,title:r(`clients.notOnPath.title`),children:r(`clients.notOnPath.detail`,{dir:he(a.executable)})})}),(0,Z.jsxs)(l,{title:r(`clients.versionTitle`),footer:u,children:[(0,Z.jsx)(R,{label:r(`clients.currentVersion`),detail:a.installed?a.executable:void 0,children:a.installed?s(a.version??r(`clients.versionUnknown`),!a.version):s(r(`clients.notInstalled`),!0)}),d.map(e=>(0,Z.jsxs)(R,{label:r(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Z.jsx)(c,{tone:`orange`,children:r(`clients.otherCopyNewer`)}),s(e.version,!e.newer)]},e.path)),(a.method===`npm`||a.method===`script`)&&(0,Z.jsxs)(R,{label:r(`clients.latestVersion`),detail:a.latestError??(a.latestCheckedAt?r(`clients.checkedAt`,{time:de(a.latestCheckedAt,i)}):void 0),children:[a.updateAvailable&&(0,Z.jsx)(c,{tone:`orange`,children:r(`clients.updateBadge`)}),s(a.latestVersion??r(`clients.latestUnknown`),!a.latestVersion)]}),(0,Z.jsx)(R,{label:r(`clients.installMethod`),detail:r(`clients.method.${a.method}`,{package:a.package??``}),children:(0,Z.jsx)(_,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(ye,{className:`size-3`}),onClick:()=>window.open(a.homepageUrl,`_blank`,`noreferrer`),children:r(`clients.homepage`)})}),a.installed&&(0,Z.jsx)(R,{label:r(`clients.uninstall`),detail:a.uninstallCommand??$t(a,r),children:a.uninstallCommand&&(0,Z.jsx)(_,{size:`sm`,variant:`destructive`,icon:(0,Z.jsx)(Oe,{className:`size-3`}),disabled:a.busy,onClick:n,children:r(`clients.uninstall`)})}),o.data&&(0,Z.jsx)(R,{icon:(0,Z.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.installLog`),detail:`${o.data.command} · ${r(`clients.job.${o.data.state}`)}`,onClick:t})]})]})}function tn({mode:e,onClose:t,client:n}){let{t:r}=L(),{toast:i}=U(),a=x(),o=e!==null,c=ne(n.kind,o||!!n.install?.busy),l=ee(),u=S(),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(null),m=(0,X.useRef)(void 0),h=Y(n.kind,n.name),v=n.install,y=e===`log`?null:e,b=y===`install`?v?.installCommand:y===`update`?v?.updateCommand:y===`uninstall`?v?.uninstallCommand:null,T=y===`uninstall`,E=c.data,D=y!==null&&!d&&E?.state!==`running`,O=!!v?.needsAdmin,k=!!v?.adminAvailable,te=E?.state===`failed`&&E.hint===`permission-denied`&&!E.elevated&&k;(0,X.useEffect)(()=>{o&&f(!1)},[o,e]),(0,X.useEffect)(()=>{let e=E?.state;m.current===`running`&&e&&e!==`running`&&(a.invalidateQueries({queryKey:s.clients}),e===`succeeded`&&E.hint?i(r(`clients.notEffectiveToast`,{name:h})):e===`succeeded`&&i(r(Gt[E.action],{name:h}),`success`)),m.current=e},[E?.state,E?.action,E?.hint,h,a,r,i]),(0,X.useEffect)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[E?.log.length]);let A=(e,t)=>l.mutate({kind:n.kind,action:e,elevated:t},{onSuccess:()=>f(!0),onError:e=>i(V(e),`error`)}),re=async e=>{await B.copy(e)&&i(r(`common.copied`))},j=r(Wt[y??E?.action??`install`],{name:h}),N={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},ie=`rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[12px] break-all whitespace-pre-wrap selectable`,ae=v?.adminFixCommand?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:r(`clients.admin.fixTip`)}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`pre`,{className:M(ie,`min-w-0 flex-1`),children:v.adminFixCommand}),(0,Z.jsx)(_,{size:`sm`,icon:(0,Z.jsx)(ve,{className:`size-3`}),"aria-label":r(`common.copy`),onClick:()=>void re(v.adminFixCommand)})]})]}):null;return(0,Z.jsx)(z,{open:o,onOpenChange:e=>!e&&t(),width:620,title:j,description:D?r(T?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:D?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{onClick:t,children:r(`common.cancel`)}),O&&!k?(0,Z.jsx)(_,{variant:`primary`,icon:(0,Z.jsx)(ve,{className:`size-3.5`}),disabled:!b,onClick:()=>void re(`sudo ${b}`),children:r(`clients.admin.copyCommand`)}):(0,Z.jsx)(_,{variant:T?`destructive`:`primary`,icon:O?(0,Z.jsx)(J,{className:`size-3.5`}):void 0,disabled:!b,loading:l.isPending,onClick:()=>y&&A(y,O),children:r(O?`clients.admin.start`:T?`clients.uninstall`:`clients.installStart`)})]}):E?.state===`running`?(0,Z.jsxs)(Z.Fragment,{children:[!E.elevated&&(0,Z.jsx)(_,{variant:`destructive`,loading:u.isPending,onClick:()=>u.mutate(n.kind,{onError:e=>i(V(e),`error`)}),children:r(`clients.installStop`)}),(0,Z.jsx)(_,{onClick:t,children:r(`common.close`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{onClick:t,children:r(`common.done`)}),te&&(0,Z.jsx)(_,{variant:`primary`,icon:(0,Z.jsx)(J,{className:`size-3.5`}),loading:l.isPending,onClick:()=>A(E.action,!0),children:r(`clients.admin.retry`)})]}),children:D?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[T&&n.enabled&&(0,Z.jsx)(C,{tone:`warning`,title:r(`clients.uninstallRestoreTitle`),children:r(`clients.uninstallRestoreDetail`,{name:h})}),O&&(0,Z.jsx)(C,{tone:`warning`,title:r(`clients.admin.title`),children:r(k?`clients.admin.prompt`:`clients.admin.manual`)}),b?(0,Z.jsx)(`pre`,{className:ie,children:O?`sudo ${b}`:b}):(0,Z.jsx)(C,{tone:`warning`,title:r(`clients.installUnavailable`)}),T?(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`clients.uninstallKeepsData`)}):v?.method===`npm`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`clients.installNpmNote`)}),O&&ae]}):E?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(C,{tone:E.state===`succeeded`&&E.hint?`warning`:N[E.state],title:r(E.state===`succeeded`&&E.hint?`clients.job.notEffective`:`clients.job.${E.state}`),children:E.state===`running`&&E.elevated?r(`clients.admin.running`):E.hint?r(`clients.hint.${E.hint}`)+(te?r(`clients.admin.retryHint`):``):void 0}),(0,Z.jsx)(`pre`,{ref:p,className:`scroll max-h-[340px] min-h-[160px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[11px] leading-relaxed break-all whitespace-pre-wrap selectable`,children:E.log.join(`
9
+ `)}),E.hint===`permission-denied`&&ae]}):c.isLoading?(0,Z.jsx)(w,{lines:4}):(0,Z.jsx)(g,{icon:(0,Z.jsx)(q,{className:`size-6`}),title:r(`clients.noInstallLog`)})})}function nn({open:e,onOpenChange:t,client:r,model:i,extras:a,tokenId:o}){let{t:s}=L(),{toast:c}=U(),l=n(),u=m(),d=Y(r.kind,r.name),f=a?{providerId:r.providerId,model:i,extras:a,tokenId:o}:{providerId:r.providerId,model:i,tokenId:o};(0,X.useEffect)(()=>{e&&l.mutate({kind:r.kind,req:f})},[e]);let p=()=>u.mutate({kind:r.kind,req:f},{onSuccess:e=>{t(!1),c(e.requiresRestart?s(`clients.enabledRestart`,{name:d}):s(`clients.enabledToast`,{name:d}),`success`)},onError:e=>{let t=Ct(e,s);c(t?`${t.title} · ${t.hint}`:V(e),`error`)}}),h=l.isError?Ct(l.error,s):null;return(0,Z.jsxs)(z,{open:e,onOpenChange:t,width:620,title:s(`clients.enableTitle`,{name:d}),description:s(`clients.enableDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{onClick:()=>t(!1),children:s(`common.cancel`)}),(0,Z.jsx)(_,{variant:`primary`,disabled:!l.data,loading:u.isPending,onClick:p,children:r.enabled?s(`common.apply`):s(`clients.enable`)})]}),children:[l.isPending&&(0,Z.jsx)(w,{lines:4}),h&&(0,Z.jsx)(C,{tone:`danger`,title:h.title,children:h.hint}),l.isError&&!h&&(0,Z.jsx)(C,{tone:`danger`,title:s(`common.error`),children:V(l.error)}),l.data&&(0,Z.jsx)(rn,{preview:l.data})]})}function rn({preview:e}){let{t}=L();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Z.jsx)(C,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Z.jsx)(C,{tone:`info`,title:t(`clients.noChanges`)}),e.diffs.map(e=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`mb-2 font-mono text-[11px] text-[var(--text-secondary)]`,children:e.file}),(0,Z.jsx)(an,{diff:e.unifiedDiff})]},e.file))]})}function an({diff:e}){return(0,Z.jsx)(`pre`,{className:`scroll max-h-[300px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] py-2 font-mono text-[11px] leading-relaxed selectable`,children:e.split(`
10
+ `).map((e,t)=>(0,Z.jsx)(`div`,{className:M(`px-3 whitespace-pre-wrap break-all`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-[color-mix(in_oklab,var(--success)_12%,transparent)] text-[var(--success)]`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-[color-mix(in_oklab,var(--danger)_10%,transparent)] text-[var(--danger)]`,e.startsWith(`@@`)&&`text-[var(--text-muted)]`),children:e||` `},t))})}function on({open:e,onOpenChange:t,client:n}){let{t:r,locale:i}=L(),{toast:a,confirm:o}=U(),s=O(n.kind,e),l=E();return(0,Z.jsxs)(z,{open:e,onOpenChange:t,width:520,title:r(`clients.backups`),description:r(`clients.backupsDetail`),footer:(0,Z.jsx)(_,{onClick:()=>t(!1),children:r(`common.done`)}),children:[s.isLoading&&(0,Z.jsx)(w,{lines:3}),s.isError&&(0,Z.jsx)(C,{tone:`danger`,title:r(`common.error`),children:V(s.error)}),s.data?.length===0&&(0,Z.jsx)(g,{icon:(0,Z.jsx)(ge,{className:`size-6`}),title:r(`clients.noBackups`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:s.data?.map(e=>(0,Z.jsx)(R,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[de(e.createdAt,i),e.firstWrite&&(0,Z.jsx)(c,{tone:`accent`,children:r(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Z.jsx)(_,{size:`sm`,icon:(0,Z.jsx)(De,{className:`size-3`}),loading:l.isPending&&l.variables?.id===e.id,onClick:async()=>{await o({title:r(`clients.restoreConfirm`),detail:e.files.join(`
11
+ `),destructive:!0,confirmLabel:r(`clients.restore`)})&&l.mutate({kind:n.kind,id:e.id},{onSuccess:()=>a(r(`clients.restored`),`success`),onError:e=>a(V(e),`error`)})},children:r(`clients.restore`)})},e.id))})]})}export{Mt as ClientsPage};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{D as n,H as r,O as i,Qs as a,S as o,St as s,bt as c,c as l,d as u,m as d,o as f,r as p,u as m,w as h,xt as g,yt as _}from"./format-CmXxTS5M.js";import{M as v,N as y,b}from"./index-BW8keTkg.js";var x=e(t(),1),S=a(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t:e}=h(),[t,n]=(0,x.useState)(``),[r,a]=(0,x.useState)(null),[s,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),m=(0,x.useCallback)(async t=>{let n=t.trim();if(n){p(!0),d(null);try{a(await c(n)),l(n),T(n)}catch(t){a(null),T(null),d(t instanceof _&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{p(!1)}}},[e]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(n(t),m(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(y,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:e(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:e(`key.subtitle`)})]})]}),!r&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m(t)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(v,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:t,"aria-invalid":u?!0:void 0,onChange:e=>n(e.target.value)}),u&&(0,S.jsx)(o,{tone:`danger`,title:u}),(0,S.jsx)(i,{type:`submit`,variant:`primary`,loading:f,disabled:!t.trim(),children:e(`key.submit`)})]}),r&&(0,S.jsx)(D,{info:r,apiKey:s,onForget:()=>{T(null),a(null),n(``)}})]})})}function D({info:e,apiKey:t,onForget:a}){let{t:o,locale:s}=h(),[c,l]=(0,x.useState)(`overview`),f=e.allowedClients==null?o(`key.clientsAny`):e.allowedClients.length===0?o(`key.directOnly`):e.allowedClients.map(e=>b[e]?.name??e).join(`, `),m=[[o(`key.today`),e.usage.today],[o(`key.week`),e.usage.week],[o(`key.month`),e.usage.month],[o(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(n,{tone:`orange`,children:o(`key.disabled`)}),(0,S.jsx)(i,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:a,children:o(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[o(`key.clients`),`: `,f,` · `,o(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(r,{ariaLabel:o(`key.title`),value:c,onChange:l,items:[{value:`overview`,label:o(`key.tab.overview`)},{value:`stats`,label:o(`key.tab.stats`)},{value:`requests`,label:o(`key.tab.requests`)}]})]}),c===`stats`&&(0,S.jsx)(k,{apiKey:t}),c===`requests`&&(0,S.jsx)(M,{apiKey:t}),c===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:o(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:o(`key.unlimited`)}),(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.limits.map(e=>{let t=t=>e.metric===`cost`?d(t):u(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),r=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,i=`${o(`tokens.period.${e.period}`)} · ${o(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:i}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,background:r}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?o(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?o(`key.resets`,{time:p(e.resetsAt,s)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:o(`key.rpm`,{used:e.rpm.used,limit:e.rpm.limit})})]}),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:o(`key.usage`)}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:m.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:d(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:o(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":o(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${d(e.costUsd)} · ${u(e.requests)} ${o(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=h(),[i,a]=(0,x.useState)(`7d`),[c,p]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return g(null),s(e,i).then(e=>n&&p(e),e=>n&&g(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,i,t]);let _=c?.summary,v=Math.max(...(c?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(r,{ariaLabel:t(`overview.range`),value:i,onChange:a,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),m&&(0,S.jsx)(o,{tone:`danger`,title:m}),!c||!_?!m&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:u(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?l(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:d(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:f(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:c.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${u(e.requests)} ${t(`key.requests`)} · ${d(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:c.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:c.clients.map(e=>({name:e.client?b[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),c.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:c.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(n,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,u(e.count)]})},e.category))})]}),c.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:c.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:n}=h();return t.length===0?null:(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`caption`,{className:`mb-1 text-left text-[12px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.cost`)})]})}),(0,S.jsx)(`tbody`,{children:t.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`max-w-[240px] truncate py-1 text-left font-medium text-[var(--text-secondary)]`,children:e.name}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?l(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:d(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:a}=h(),[s,c]=(0,x.useState)(`all`),[l,_]=(0,x.useState)([]),[v,y]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await g(e,{before:n,status:s===`failed`?N:void 0});_(e=>n?[...e,...t.items]:t.items),y(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(r,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(o,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:l.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:p(e.time,a),children:m(e.time,a)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?b[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(n,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(n,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[u(e.inputTokens,!0),` / `,u(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:d(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[f(e.ttftMs),` / `,f(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(i,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$s as n,D as r,H as i,O as a,S as o,St as s,bt as c,c as l,d as u,m as d,o as f,r as p,u as m,w as h,xt as g,yt as _}from"./format-CskGUFYy.js";import{M as v,N as y,b}from"./index-D2siu6xk.js";var x=e(t(),1),S=n(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t:e}=h(),[t,n]=(0,x.useState)(``),[r,i]=(0,x.useState)(null),[s,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),m=(0,x.useCallback)(async t=>{let n=t.trim();if(n){p(!0),d(null);try{i(await c(n)),l(n),T(n)}catch(t){i(null),T(null),d(t instanceof _&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{p(!1)}}},[e]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(n(t),m(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(y,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:e(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:e(`key.subtitle`)})]})]}),!r&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m(t)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(v,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:t,"aria-invalid":u?!0:void 0,onChange:e=>n(e.target.value)}),u&&(0,S.jsx)(o,{tone:`danger`,title:u}),(0,S.jsx)(a,{type:`submit`,variant:`primary`,loading:f,disabled:!t.trim(),children:e(`key.submit`)})]}),r&&(0,S.jsx)(D,{info:r,apiKey:s,onForget:()=>{T(null),i(null),n(``)}})]})})}function D({info:e,apiKey:t,onForget:n}){let{t:o,locale:s}=h(),[c,l]=(0,x.useState)(`overview`),f=e.allowedClients==null?o(`key.clientsAny`):e.allowedClients.length===0?o(`key.directOnly`):e.allowedClients.map(e=>b[e]?.name??e).join(`, `),m=[[o(`key.today`),e.usage.today],[o(`key.week`),e.usage.week],[o(`key.month`),e.usage.month],[o(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(r,{tone:`orange`,children:o(`key.disabled`)}),(0,S.jsx)(a,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:n,children:o(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[o(`key.clients`),`: `,f,` · `,o(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(i,{ariaLabel:o(`key.title`),value:c,onChange:l,items:[{value:`overview`,label:o(`key.tab.overview`)},{value:`stats`,label:o(`key.tab.stats`)},{value:`requests`,label:o(`key.tab.requests`)}]})]}),c===`stats`&&(0,S.jsx)(k,{apiKey:t}),c===`requests`&&(0,S.jsx)(M,{apiKey:t}),c===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:o(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:o(`key.unlimited`)}),(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.limits.map(e=>{let t=t=>e.metric===`cost`?d(t):u(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),r=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,i=`${o(`tokens.period.${e.period}`)} · ${o(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:i}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,background:r}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?o(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?o(`key.resets`,{time:p(e.resetsAt,s)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:o(`key.rpm`,{used:e.rpm.used,limit:e.rpm.limit})})]}),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:o(`key.usage`)}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:m.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:d(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:o(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":o(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${d(e.costUsd)} · ${u(e.requests)} ${o(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=h(),[n,a]=(0,x.useState)(`7d`),[c,p]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let r=!0;return g(null),s(e,n).then(e=>r&&p(e),e=>r&&g(t(`key.error`,{error:e.message}))),()=>{r=!1}},[e,n,t]);let _=c?.summary,v=Math.max(...(c?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(i,{ariaLabel:t(`overview.range`),value:n,onChange:a,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),m&&(0,S.jsx)(o,{tone:`danger`,title:m}),!c||!_?!m&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:u(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?l(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:d(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:f(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:c.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${u(e.requests)} ${t(`key.requests`)} · ${d(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:c.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:c.clients.map(e=>({name:e.client?b[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),c.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:c.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(r,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,u(e.count)]})},e.category))})]}),c.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:c.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:n}=h();return t.length===0?null:(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`caption`,{className:`mb-1 text-left text-[12px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.cost`)})]})}),(0,S.jsx)(`tbody`,{children:t.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`max-w-[240px] truncate py-1 text-left font-medium text-[var(--text-secondary)]`,children:e.name}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?l(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:d(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:n}=h(),[s,c]=(0,x.useState)(`all`),[l,_]=(0,x.useState)([]),[v,y]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await g(e,{before:n,status:s===`failed`?N:void 0});_(e=>n?[...e,...t.items]:t.items),y(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(i,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(o,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:l.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:p(e.time,n),children:m(e.time,n)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?b[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(r,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(r,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[u(e.inputTokens,!0),` / `,u(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:d(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[f(e.ttftMs),` / `,f(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(a,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
@@ -0,0 +1,2 @@
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$s as n,Bi as r,Ci as i,D as a,Fn as o,G as s,H as c,I as l,Kt as u,Mt as d,N as f,O as p,P as m,R as h,S as g,U as _,W as v,gr as y,na as b,w as x,z as S}from"./format-CskGUFYy.js";import{H as C,U as w,V as T,W as E}from"./TrayTitleSource-B98nYas3.js";import{t as D}from"./folder-open-z1RXMZa1.js";import{t as O}from"./pencil-CpF9MxGZ.js";import{t as k}from"./plus-c3HzV6VX.js";import{t as A}from"./refresh-cw-CoLAai2c.js";import{t as j}from"./trash-BHBJn5GS.js";import{v as M}from"./index-D2siu6xk.js";import{t as N}from"./checkbox-29lSW_6h.js";import{t as P}from"./clientNames-Bskc9G1M.js";var F=e(t(),1),I=n();function L(){let{t:e}=x(),{toast:t,confirm:n}=E(),r=y(),o=d(),s=i(),[c,u]=(0,F.useState)(``),m=()=>o.mutate({path:c.trim()},{onSuccess:n=>{u(``),t(e(`library.projects.added`,{name:n.name}),`success`)},onError:e=>t(w(e),`error`)}),h=async(r,i)=>{await n({title:e(`library.projects.forget.title`,{name:i}),detail:e(`library.projects.forget.detail`),confirmLabel:e(`library.projects.forget`)})&&s.mutate(r,{onError:e=>t(w(e),`error`)})};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`mb-3 text-[12px] text-[var(--text-secondary)]`,children:e(`library.projects.hint`)}),(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,I.jsx)(l,{mono:!0,className:`flex-1`,value:c,placeholder:`/Users/me/code/app`,onChange:e=>u(e.target.value),"aria-label":e(`library.projects.path`)}),(0,I.jsx)(p,{variant:`primary`,icon:(0,I.jsx)(k,{className:`size-4`}),disabled:c.trim()===``,loading:o.isPending,onClick:m,children:e(`library.projects.add`)})]}),r.isError&&(0,I.jsx)(g,{tone:`danger`,title:w(r.error)}),r.isLoading&&(0,I.jsx)(_,{lines:2}),r.data&&r.data.length===0&&(0,I.jsx)(f,{icon:(0,I.jsx)(D,{className:`size-6`}),title:e(`library.projects.empty`)}),r.data&&r.data.length>0&&(0,I.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:r.data.map(t=>(0,I.jsx)(S,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:t.name}),!t.exists&&(0,I.jsx)(a,{tone:`orange`,children:e(`library.state.project-missing`)})]}),detail:(0,I.jsx)(`span`,{className:`font-mono text-[11px]`,children:t.path}),children:(0,I.jsx)(p,{size:`sm`,icon:(0,I.jsx)(j,{className:`size-3.5`}),"aria-label":e(`library.projects.forget`),onClick:()=>void h(t.path,t.name)})},t.path))})]})}var R={instructions:`instruction`,agents:`agent`,commands:`command`,hooks:`hook`,env:`env`},z=[`turn-end`,`after-tool`,`before-tool`,`prompt`,`session-start`],B={applied:`green`,drifted:`orange`,missing:`orange`,conflict:`red`,"project-missing":`orange`,unsupported:`neutral`,pending:`neutral`,off:`neutral`},V=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function H({segment:e}){let{t}=x(),{toast:n,confirm:i}=E(),a=R[e],s=r(e),c=u(e),l=o(e),[d,m]=(0,F.useState)(null),h=s.data,v=async(e,r)=>{try{await e(),r&&n(t(r),`success`)}catch(e){n(w(e),`error`)}},y=async(e,n)=>{(!n||await i({title:t(`library.confirm.force.title`,{name:e.name}),detail:t(`library.confirm.force.detail`),confirmLabel:t(`library.rewriteForce`),destructive:!0}))&&await v(()=>c.mutateAsync({id:e.id,force:n}),`library.toast.applied`)},b=async e=>{await i({title:t(`library.confirm.delete.title`,{name:e.name}),detail:t(`library.confirm.delete.detail`),confirmLabel:t(`common.delete`),destructive:!0})&&await v(async()=>{try{await l.mutateAsync({id:e.id})}catch(n){if(!await i({title:t(`library.confirm.deleteForce.title`,{name:e.name}),detail:`${w(n)}\n\n${t(`library.confirm.deleteForce.detail`)}`,confirmLabel:t(`common.delete`),destructive:!0}))return;await l.mutateAsync({id:e.id,force:!0})}},`library.toast.deleted`)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:t(`library.hint.${a}`)}),(0,I.jsx)(p,{variant:`primary`,icon:(0,I.jsx)(k,{className:`size-4`}),onClick:()=>m(`new`),disabled:h?.canWrite===!1,children:t(`library.add`)})]}),s.isError&&(0,I.jsx)(g,{tone:`danger`,title:`${t(`library.error.load`)}: ${w(s.error)}`}),s.isLoading&&(0,I.jsx)(_,{lines:3}),h&&h.canWrite===!1&&(0,I.jsx)(g,{tone:`info`,title:t(`library.localOnly`)}),h&&h.items.length===0&&(0,I.jsx)(f,{title:t(`library.empty.title`),detail:t(`library.empty.${a}`),action:h.canWrite?(0,I.jsx)(p,{variant:`primary`,onClick:()=>m(`new`),children:t(`library.add`)}):void 0}),h&&h.items.length>0&&(0,I.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:h.items.map(e=>(0,I.jsx)(U,{item:e,canWrite:h.canWrite,onEdit:()=>m(e),onDelete:()=>void b(e),onRewrite:t=>void y(e,t)},e.id))}),h&&(0,I.jsx)(G,{segment:e,library:h,item:d,onClose:()=>m(null)})]})}function U({item:e,canWrite:t,onEdit:n,onDelete:r,onRewrite:i}){let{t:o}=x(),s=e.targets.some(e=>e.state===`drifted`||e.state===`conflict`||e.state===`missing`),c=e.targets.some(e=>e.state===`drifted`||e.state===`conflict`),l=(e.kind===`hook`?`${e.event??``}${e.matcher?` · ${e.matcher}`:``} — `:``)+(e.description||e.body).split(`
2
+ `)[0];return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(S,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e.name}),!e.enabled&&(0,I.jsx)(a,{children:o(`library.state.off`)})]}),detail:(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:l,children:l}),children:[s&&t&&(0,I.jsx)(p,{size:`sm`,icon:(0,I.jsx)(A,{className:`size-3.5`}),onClick:()=>i(!1),children:o(`library.rewrite`)}),c&&t&&(0,I.jsx)(p,{size:`sm`,onClick:()=>i(!0),children:o(`library.rewriteForce`)}),(0,I.jsx)(p,{size:`sm`,icon:(0,I.jsx)(O,{className:`size-3.5`}),"aria-label":o(`common.edit`),onClick:n,disabled:!t}),(0,I.jsx)(p,{size:`sm`,icon:(0,I.jsx)(j,{className:`size-3.5`}),"aria-label":o(`common.delete`),onClick:r,disabled:!t})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 px-4 pb-3`,children:[e.targets.map(t=>(0,I.jsx)(W,{target:t,error:e.lastError?.[t.project?`${t.client}@${t.project}`:t.client]},t.client+t.project)),e.targets.length===0&&(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:o(`library.noTargets`)})]})]})}function W({target:e,error:t}){let{t:n}=x(),r=t??e.message??void 0;return(0,I.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px]`,title:e.path??void 0,children:[P(e.client),e.project&&(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,title:e.project,children:V(e.project)}),(0,I.jsx)(a,{tone:B[e.state],children:n(`library.state.${e.state}`)})]}),r&&(0,I.jsx)(`span`,{className:`max-w-md whitespace-normal text-[11px] text-[var(--danger)]`,children:r})]})}function G({segment:e,library:t,item:n,onClose:r}){let{t:i}=x(),{toast:o}=E(),c=b(e),u=R[e],d=n&&n!==`new`?n:null,[f,g]=(0,F.useState)(``),[_,y]=(0,F.useState)(``),[D,O]=(0,F.useState)(``),[k,A]=(0,F.useState)(`turn-end`),[j,M]=(0,F.useState)(``),[L,B]=(0,F.useState)(null),[V,H]=(0,F.useState)(``),[U,W]=(0,F.useState)(!0),[G,K]=(0,F.useState)([]);(0,F.useEffect)(()=>{if(n===null)return;let e=n===`new`?null:n;g(e?.name??``),y(e?.description??``),O(e?.body??``),A(e?.event??`turn-end`),M(e?.matcher??``),B(e&&e.timeout>0?e.timeout:null),H(e?.model??``),W(e?.enabled??!0),K(e?e.targets.map(e=>({client:e.client,project:e.project})):[])},[n]);let q=(e,t)=>G.some(n=>n.client===e&&n.project===t),J=(e,t,n)=>K(r=>n?[...r.filter(n=>n.client!==e||n.project!==t),{client:e,project:t}]:r.filter(n=>n.client!==e||n.project!==t)),Y=u===`agent`,X=f.trim()!==``&&(u===`env`||D.trim()!==``)&&(!Y||_.trim()!==``),Z=k.includes(`:`),Q=u===`hook`&&(Z||k!==`turn-end`&&k!==`prompt`);return(0,I.jsx)(C,{open:n!==null,onOpenChange:e=>!e&&r(),width:580,title:d?i(`library.editTitle`,{name:d.name}):i(`library.addTitle.${u}`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(p,{onClick:r,children:i(`common.cancel`)}),(0,I.jsx)(p,{variant:`primary`,disabled:!X,loading:c.isPending,onClick:()=>{let e={name:f.trim(),body:D,enabled:U,targets:G};(u===`agent`||u===`command`||u===`hook`)&&(e.description=_.trim()),u===`agent`&&V.trim()!==``&&(e.model=V.trim()),u===`hook`&&(e.event=k,e.matcher=Q?j.trim():``,e.timeout=L??0),c.mutate({id:d?.id,body:e},{onSuccess:e=>{r(),e.targets.filter(e=>e.state===`conflict`||e.state===`drifted`).length>0||e.lastError&&Object.keys(e.lastError).length>0?o(i(`library.toast.savedWithProblems`),`error`):o(i(`library.toast.saved`,{name:e.name}),`success`)},onError:e=>o(w(e),`error`)})},children:i(`common.save`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(m,{label:i(`library.field.name`),hint:i(`library.nameHint.${u}`),children:(0,I.jsx)(l,{mono:!0,value:f,maxLength:64,onChange:e=>g(e.target.value)})}),(u===`agent`||u===`command`||u===`hook`)&&(0,I.jsx)(m,{label:i(`library.field.description`),children:(0,I.jsx)(l,{value:_,maxLength:200,onChange:e=>y(e.target.value)})}),u===`hook`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(m,{label:i(`library.field.event`),hint:i(`library.field.eventHint`),children:[(0,I.jsx)(T,{value:Z?`__own__`:k,onChange:e=>A(e===`__own__`?`claude-code:PermissionRequest`:e),options:[...z.map(e=>({value:e,label:i(`library.event.${e}`)})),{value:`__own__`,label:i(`library.event.own`)}]}),Z&&(0,I.jsx)(l,{mono:!0,className:`mt-2`,value:k,onChange:e=>A(e.target.value),placeholder:`claude-code:PermissionRequest`})]}),Q&&(0,I.jsx)(m,{label:i(`library.field.matcher`),hint:i(Z?`library.field.matcherOwn`:k===`session-start`?`library.field.matcherStarts`:`library.field.matcherTools`),children:k===`session-start`||Z?(0,I.jsx)(l,{mono:!0,value:j,placeholder:`startup|resume`,onChange:e=>M(e.target.value)}):(0,I.jsx)(T,{value:j,onChange:M,options:[{value:``,label:i(`library.matcher.all`)},{value:`shell`,label:i(`library.matcher.shell`)},{value:`edit`,label:i(`library.matcher.edit`)}]})}),(0,I.jsx)(m,{label:i(`library.field.timeout`),children:(0,I.jsx)(h,{value:L,onChange:B,min:0,step:1})})]}),(0,I.jsx)(m,{label:i(`library.field.body.${u}`),hint:u===`command`?i(`library.field.commandArgsHint`):void 0,children:u===`hook`||u===`env`?(0,I.jsx)(l,{mono:!0,value:D,onChange:e=>O(e.target.value)}):(0,I.jsx)(s,{mono:!0,rows:u===`instruction`?8:6,value:D,onChange:e=>O(e.target.value)})}),u===`agent`&&(0,I.jsx)(m,{label:i(`library.field.model`),hint:i(`library.field.modelHint`),children:(0,I.jsx)(l,{mono:!0,value:V,onChange:e=>H(e.target.value),placeholder:`gpt-5`})}),(0,I.jsx)(m,{label:i(`library.targets`),hint:i(t.projects.length>0?`library.targetsHint`:`library.targetsHintNoProjects`),children:(0,I.jsx)(`div`,{className:`grid gap-1`,children:t.clients.map(e=>(0,I.jsx)(S,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[P(e.kind),!e.detected&&(0,I.jsx)(a,{children:i(`library.undetected`)})]}),detail:e.path?(0,I.jsx)(`span`,{className:`font-mono text-[11px]`,title:e.path,children:e.path}):void 0,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[(0,I.jsx)(N,{label:i(`library.userWide`),checked:q(e.kind,``),onCheckedChange:t=>J(e.kind,``,t===!0)}),e.project&&t.projects.map(t=>(0,I.jsx)(N,{label:t.name,checked:q(e.kind,t.path),disabled:!t.exists,onCheckedChange:n=>J(e.kind,t.path,n===!0)},t.path))]})},e.kind))})}),(0,I.jsx)(S,{label:i(`library.enabled`),children:(0,I.jsx)(v,{checked:U,label:i(`library.enabled`),onChange:W})})]})})}function K(){let{t:e}=x(),[t,n]=(0,F.useState)(`instructions`);return(0,I.jsxs)(M,{title:e(`nav.library`),subtitle:e(`library.subtitle`),children:[(0,I.jsx)(`div`,{className:`mb-3`,children:(0,I.jsx)(c,{ariaLabel:e(`nav.library`),value:t,onChange:n,items:[{value:`instructions`,label:e(`library.tab.instruction`)},{value:`agents`,label:e(`library.tab.agent`)},{value:`commands`,label:e(`library.tab.command`)},{value:`hooks`,label:e(`library.tab.hook`)},{value:`env`,label:e(`library.tab.env`)},{value:`projects`,label:e(`library.tab.projects`)}]})}),t===`projects`?(0,I.jsx)(L,{}):(0,I.jsx)(H,{segment:t},t)]})}export{K as LibraryPage};
@@ -0,0 +1,9 @@
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$n as n,$s as r,D as i,Dn as a,Dr as o,Ea as s,En as c,Er as l,F as u,G as d,H as f,Ht as p,I as m,N as h,O as g,P as _,Qa as v,R as y,S as b,Si as x,Tr as S,U as C,Va as w,W as T,Wt as E,br as D,cr as O,do as k,fo as A,gn as j,gr as ee,hn as M,ln as N,o as P,po as F,r as I,w as L,xr as R,z}from"./format-CskGUFYy.js";import{B as te,H as B,R as V,U as H,V as U,W}from"./TrayTitleSource-B98nYas3.js";import{t as G}from"./copy-48gwhhDO.js";import{t as K}from"./ellipsis-CidyZaW2.js";import{t as ne}from"./key-round-m9ps8ZDi.js";import{t as q}from"./pencil-CpF9MxGZ.js";import{t as J}from"./plug-DKn7uRWT.js";import{t as Y}from"./plus-c3HzV6VX.js";import{t as re}from"./shield-check-CD30JqBi.js";import{t as ie}from"./terminal-B-mEYDi0.js";import{t as X}from"./trash-BHBJn5GS.js";import{t as ae}from"./zap-BiWUNaKt.js";import{B as oe,W as se,v as ce}from"./index-D2siu6xk.js";var Z=e(t(),1),Q=r(),le=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`}],ue={missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`};function de(){let{t:e}=L(),t=N(),n=v(),r=(n.data??[]).filter(e=>e.enabled&&(e.mcpServers?.length??0)>0);return(0,Q.jsxs)(u,{title:e(`mcp.clients.title`),footer:e(`mcp.clients.stdio`),children:[(0,Q.jsx)(`p`,{className:`px-4 pt-3 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.hint`)}),t.isLoading&&(0,Q.jsx)(C,{lines:2}),t.data&&r.length===0&&n.data&&(0,Q.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.noToken`)}),t.data&&le.map(e=>{let n=t.data.find(t=>t.kind===e.kind);return n?(0,Q.jsx)(fe,{name:e.name,entry:n,tokens:r.map(e=>({value:e.id,label:e.name}))},e.kind):null})]})}function fe({name:e,entry:t,tokens:n}){let{t:r}=L(),{toast:a,confirm:o}=W(),s=p(),c=x(),[l,u]=(0,Z.useState)(null),d=l??(n.some(e=>e.value===t.tokenId)?t.tokenId??null:n[0]?.value??null),f=s.isPending||c.isPending,m=t.state===`applied`||t.state===`drifted`,h=n=>{d&&s.mutate({kind:t.kind,tokenId:d,force:n},{onSuccess:()=>a(r(`mcp.clients.applied`,{client:e}),`success`),onError:e=>a(H(e),`error`)})},_=async n=>{(!n||await o({title:r(`mcp.clients.forceRemove`),detail:t.file,destructive:!0,confirmLabel:r(`mcp.clients.forceRemove`)}))&&c.mutate({kind:t.kind,force:n},{onSuccess:()=>a(r(`mcp.clients.removed`,{client:e}),`success`),onError:e=>a(H(e),`error`)})},v=(0,Q.jsxs)(`span`,{className:`block whitespace-normal`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:t.file,children:t.file}),t.state===`applied`&&t.tokenName&&(0,Q.jsx)(`span`,{className:`block`,children:r(`mcp.clients.usesToken`,{name:t.tokenName})}),t.error&&(0,Q.jsx)(`span`,{className:`block text-[var(--danger)]`,children:r(`mcp.clients.unreadable`,{error:t.error})})]});return(0,Q.jsxs)(`div`,{className:`border-t border-[var(--border)] first:border-t-0`,children:[(0,Q.jsxs)(z,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(0,Q.jsx)(i,{tone:ue[t.state],children:r(`mcp.clients.state.${t.state}`)})]}),detail:v,children:[n.length>0&&(0,Q.jsx)(U,{className:`w-44`,ariaLabel:`${e} ${r(`mcp.clients.token`)}`,placeholder:r(`mcp.clients.pickToken`),value:d,onChange:u,options:n,disabled:f}),(0,Q.jsx)(g,{variant:`primary`,disabled:f||!d||t.state===`conflict`,onClick:()=>h(!1),children:r(m?`mcp.clients.replace`:`mcp.clients.apply`)}),m&&(0,Q.jsx)(g,{disabled:f,onClick:()=>void _(t.state===`drifted`),children:t.state===`drifted`?r(`mcp.clients.forceRemove`):r(`mcp.clients.remove`)})]}),!t.gatewayEnabled&&t.state!==`missing`&&(0,Q.jsx)(b,{tone:`warning`,className:`mx-4 mb-3`,title:r(`mcp.clients.gatewayOff`)}),!t.gatewayEnabled&&t.state===`missing`&&(0,Q.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:r(`mcp.clients.gatewayOff`)}),t.state===`conflict`&&!t.error&&(0,Q.jsx)(b,{tone:`warning`,className:`mx-4 mb-3`,title:r(`mcp.clients.conflict`)}),t.state===`drifted`&&(0,Q.jsxs)(`div`,{className:`mx-4 mb-3 flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`mcp.clients.drifted`)}),(0,Q.jsx)(g,{size:`sm`,disabled:f||!d,onClick:()=>h(!0),children:r(`mcp.clients.force`)})]})]})}var pe=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`},{kind:`gemini-cli`,name:`Gemini CLI`},{kind:`qwen-code`,name:`Qwen Code`},{kind:`opencode`,name:`OpenCode`},{kind:`droid`,name:`Droid`},{kind:`crush`,name:`Crush`},{kind:`copilot-cli`,name:`Copilot CLI`}],me=[`claude-code`,`codex`,`gemini-cli`,`qwen-code`,`opencode`,`droid`],he=[`claude-code`,`codex`,`gemini-cli`,`qwen-code`,`opencode`],ge={"project-missing":`orange`,missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`},$=e=>pe.find(t=>t.kind===e)?.name??e,_e=e=>e.split(`
2
+ `).map(e=>e.replace(/\r$/,``)).filter(e=>e.trim()!==``);function ve(e){let t={};for(let n of e.split(`
3
+ `)){let e=n.replace(/\r$/,``);if(e.trim()===``)continue;let r=e.indexOf(`=`);if(r<=0)return null;t[e.slice(0,r).trim()]=e.slice(r+1)}return t}function ye(e){let t={};for(let n of e.split(`
4
+ `)){let e=n.replace(/\r$/,``);if(e.trim()===``)continue;let r=e.indexOf(`:`);if(r<=0)return null;t[e.slice(0,r).trim()]=e.slice(r+1).trim()}return t}function be(){let{t:e}=L(),{toast:t,confirm:n}=W(),r=R(),i=E(),a=c(),[o,s]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),d=async r=>{await n({title:e(`mcp.local.deleteTitle`,{name:r.name}),detail:e(`mcp.local.deleteDetail`),destructive:!0,confirmLabel:e(`common.delete`)})&&a.mutate({id:r.id},{onSuccess:()=>t(e(`mcp.local.deleted`,{name:r.name}),`success`),onError:e=>t(H(e),`error`)})},f=(n,r)=>i.mutate({id:n.id,force:r},{onSuccess:()=>t(e(`mcp.local.applied`,{name:n.name}),`success`),onError:e=>t(H(e),`error`)});return(0,Q.jsxs)(`section`,{className:`mt-6`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 px-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold`,children:e(`mcp.local.title`)}),(0,Q.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:e(`mcp.local.hint`)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(g,{icon:(0,Q.jsx)(oe,{className:`size-4`}),onClick:()=>u(!0),children:e(`mcp.local.import`)}),(0,Q.jsx)(g,{variant:`primary`,icon:(0,Q.jsx)(Y,{className:`size-4`}),onClick:()=>s(`new`),children:e(`mcp.local.add`)})]})]}),r.isLoading?(0,Q.jsx)(C,{}):!r.data||r.data.length===0?(0,Q.jsx)(h,{icon:(0,Q.jsx)(ie,{className:`size-6`}),title:e(`mcp.local.emptyTitle`),detail:e(`mcp.local.emptyDetail`)}):(0,Q.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:r.data.map(e=>(0,Q.jsx)(xe,{server:e,busy:i.isPending||a.isPending,onEdit:()=>s(e),onDelete:()=>void d(e),onRewrite:t=>f(e,t)},e.id))}),(0,Q.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:e(`mcp.local.footer`)}),(0,Q.jsx)(Ce,{server:o,onClose:()=>s(null)}),(0,Q.jsx)(we,{open:l,onClose:()=>u(!1)})]})}function xe({server:e,busy:t,onEdit:n,onDelete:r,onRewrite:a}){let{t:o}=L(),s=e.transport===`http`,c=s?e.url:[e.command,...e.args].join(` `),l=s?e.headerNames.length:e.envNames.length,u=e.placements.some(e=>e.wanted&&e.state!==`applied`);return(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsxs)(z,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),!e.enabled&&(0,Q.jsx)(i,{tone:`neutral`,children:o(`mcp.local.off`)})]}),detail:(0,Q.jsxs)(`span`,{className:`block truncate font-mono text-[11px]`,title:c,children:[c,l>0&&(0,Q.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` · `,o(s?`mcp.local.headerCount`:`mcp.local.envCount`,{count:l})]})]}),children:[u&&(0,Q.jsx)(g,{size:`sm`,disabled:t,onClick:()=>a(!1),children:o(`mcp.local.rewrite`)}),(0,Q.jsx)(g,{size:`sm`,icon:(0,Q.jsx)(q,{className:`size-3.5`}),onClick:n,"aria-label":o(`common.edit`)}),(0,Q.jsx)(g,{size:`sm`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),disabled:t,onClick:r,"aria-label":o(`common.delete`)})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-3 px-4 pb-3`,children:e.placements.map(e=>(0,Q.jsx)(Se,{placement:e,onForce:()=>a(!0)},e.kind+(e.project??``)))})]})}function Se({placement:e,onForce:t}){let{t:n}=L();return!e.wanted&&e.state===`missing`?null:(0,Q.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px]`,title:e.file,children:[$(e.kind),e.project&&(0,Q.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.project.split(/[\\/]/).filter(Boolean).pop()}),(0,Q.jsx)(i,{tone:ge[e.state],children:n(`mcp.local.state.${e.state}`)}),e.state===`drifted`&&e.wanted&&(0,Q.jsx)(g,{size:`sm`,onClick:t,children:n(`mcp.clients.force`)})]}),e.error&&(0,Q.jsx)(`span`,{className:`max-w-md whitespace-normal text-[11px] text-[var(--danger)]`,children:e.error})]})}function Ce({server:e,onClose:t}){let{t:n}=L(),{toast:r}=W(),i=M(),a=k(),o=e&&e!==`new`?e:null,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[p,h]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(`stdio`),[C,w]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,A]=(0,Z.useState)([]),[j,N]=(0,Z.useState)([]),P=ee().data??[],[F,I]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;c(t?.name??``),u(t?.command??``),h((t?.args??[]).join(`
5
+ `)),y(``),D(``),S(t?.transport??`stdio`),w(t?.url??``),A(t?.clients??he),N(t?.projects??[]),I(t?.enabled??!0)},[e]);let R=x===`http`,te=o?.transport===`stdio`&&x===`stdio`&&o.envNames.length>0,V=o?.transport===`http`&&x===`http`&&o.headerNames.length>0,U=ve(v),G=ye(E),K=i.isPending||a.isPending,ne=s.trim()!==``&&(R?C.trim()!==``&&G!==null:l.trim()!==``&&U!==null),q=()=>{let e=R?{name:s.trim(),transport:x,url:C.trim(),enabled:F,clients:O,projects:j}:{name:s.trim(),transport:x,command:l.trim(),args:_e(p),enabled:F,clients:O,projects:j},c=o?.transport===x;R&&G&&(E.trim()!==``||!c)&&(e.headers=G),!R&&U&&(v.trim()!==``||!c)&&(e.env=U);let u={onSuccess:e=>{t(),r(n(o?`mcp.local.saved`:`mcp.local.created`,{name:e.name}),`success`)},onError:e=>r(H(e),`error`)};o?a.mutate({id:o.id,body:e},u):i.mutate(e,u)},J=(e,t)=>A(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e));return(0,Q.jsx)(B,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:o?n(`mcp.local.editTitle`,{name:o.name}):n(`mcp.local.addTitle`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(g,{variant:`primary`,disabled:!ne,loading:K,onClick:q,children:n(`common.save`)})]}),children:(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsx)(_,{label:n(`mcp.local.name`),hint:n(`mcp.local.nameHint`),children:(0,Q.jsx)(m,{mono:!0,value:s,maxLength:32,placeholder:`filesystem`,onChange:e=>c(e.target.value)})}),(0,Q.jsx)(_,{label:n(`mcp.local.transport`),children:(0,Q.jsx)(f,{ariaLabel:n(`mcp.local.transport`),value:x,onChange:S,items:[{value:`stdio`,label:n(`mcp.local.transport.stdio`)},{value:`http`,label:n(`mcp.local.transport.http`)}]})}),R?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{label:n(`mcp.local.url`),hint:n(`mcp.local.urlHint`),children:(0,Q.jsx)(m,{mono:!0,value:C,placeholder:`https://mcp.example.com/mcp`,onChange:e=>w(e.target.value)})}),(0,Q.jsx)(_,{label:n(`mcp.local.headers`),hint:V?n(`mcp.local.headersKept`,{names:o.headerNames.join(`, `)}):n(`mcp.local.headersHint`),children:(0,Q.jsx)(d,{mono:!0,rows:3,value:E,placeholder:`Authorization: Bearer ...`,onChange:e=>D(e.target.value)})}),G===null&&(0,Q.jsx)(b,{tone:`warning`,title:n(`mcp.local.headersInvalid`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{label:n(`mcp.local.command`),children:(0,Q.jsx)(m,{mono:!0,value:l,placeholder:`npx`,onChange:e=>u(e.target.value)})}),(0,Q.jsx)(_,{label:n(`mcp.local.args`),hint:n(`mcp.local.argsHint`),children:(0,Q.jsx)(d,{mono:!0,rows:4,value:p,placeholder:`-y
6
+ @modelcontextprotocol/server-filesystem
7
+ /Users/me/docs`,onChange:e=>h(e.target.value)})}),(0,Q.jsx)(_,{label:n(`mcp.local.env`),hint:te?n(`mcp.local.envKept`,{names:o.envNames.join(`, `)}):n(`mcp.local.envHint`),children:(0,Q.jsx)(d,{mono:!0,rows:3,value:v,placeholder:`API_KEY=...`,onChange:e=>y(e.target.value)})}),U===null&&(0,Q.jsx)(b,{tone:`warning`,title:n(`mcp.local.envInvalid`)})]}),(0,Q.jsx)(_,{label:n(`mcp.local.clients`),hint:n(`mcp.local.clientsHint`),children:(0,Q.jsx)(`div`,{className:`grid gap-1`,children:pe.map(e=>(0,Q.jsx)(z,{label:e.name,children:(0,Q.jsx)(T,{checked:O.includes(e.kind),label:e.name,onChange:t=>J(e.kind,t)})},e.kind))})}),(P.length>0||j.length>0)&&(0,Q.jsx)(_,{label:n(`mcp.local.projects`),hint:n(`mcp.local.projectsHint`,{clients:me.map($).join(`, `)}),children:(0,Q.jsx)(`div`,{className:`grid gap-1`,children:[...P.map(e=>e.path),...j.filter(e=>!P.some(t=>t.path===e))].map(e=>(0,Q.jsx)(z,{label:(0,Q.jsx)(`span`,{className:`font-mono text-[12px]`,children:e}),children:(0,Q.jsx)(T,{checked:j.includes(e),label:e,onChange:t=>N(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e))})},e))})}),(0,Q.jsx)(z,{label:n(`mcp.local.enabled`),children:(0,Q.jsx)(T,{checked:F,label:n(`mcp.local.enabled`),onChange:I})})]})})}function we({open:e,onClose:t}){let{t:n}=L(),{toast:r}=W(),a=D(e),o=O(),[s,c]=(0,Z.useState)(new Set),l=e=>`${e.kind}\u0000${e.name}`;(0,Z.useEffect)(()=>{e&&c(new Set)},[e]);let u=(a.data??[]).filter(e=>e.importable&&!e.taken),d=(e,t)=>c(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,Q.jsx)(B,{open:e,onOpenChange:e=>!e&&t(),width:560,title:n(`mcp.local.importTitle`),description:n(`mcp.local.importHint`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(g,{variant:`primary`,disabled:s.size===0,loading:o.isPending,onClick:()=>{let e=u.filter(e=>s.has(l(e))).map(e=>({kind:e.kind,name:e.name}));o.mutate(e,{onSuccess:e=>{let i=n(`mcp.local.importDone`,{count:e.imported.length});r(e.skipped.length>0?`${i} ${n(`mcp.local.importSkipped`,{count:e.skipped.length,reasons:[...new Set(e.skipped.map(e=>e.reason))].join(`; `)})}`:i,e.imported.length>0?`success`:`error`),t()},onError:e=>r(H(e),`error`)})},children:n(`mcp.local.importRun`)})]}),children:a.isLoading?(0,Q.jsx)(C,{}):!a.data||a.data.length===0?(0,Q.jsx)(`p`,{className:`text-[13px] text-[var(--text-muted)]`,children:n(`mcp.local.importEmpty`)}):(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[a.data.map(e=>{let t=l(e),r=!e.importable||e.taken;return(0,Q.jsx)(z,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,Q.jsx)(i,{tone:`neutral`,children:$(e.kind)})]}),detail:(0,Q.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:e.summary,children:r?e.taken?n(`mcp.local.importTaken`):e.reason??``:e.summary}),children:(0,Q.jsx)(T,{checked:s.has(t),disabled:r,label:`${e.name} ${$(e.kind)}`,onChange:e=>d(t,e)})},t)}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:n(`mcp.local.importSecrets`)})]})})}var Te={unknown:`neutral`,ok:`green`,needs_auth:`orange`,auth_error:`red`,unreachable:`red`,version_unsupported:`red`};function Ee(){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(De,{}),(0,Q.jsx)(de,{}),(0,Q.jsx)(be,{}),(0,Q.jsx)(Oe,{}),(0,Q.jsx)(Me,{})]})}function De(){let{t:e}=L(),{toast:t}=W(),n=o(),r=F(),[i,a]=(0,Z.useState)(``),s=n.data?.allowedOrigins.join(`
8
+ `)??``;if((0,Z.useEffect)(()=>a(s),[s]),!n.data)return(0,Q.jsx)(C,{});let c=n.data,l=n=>r.mutate(n,{onSuccess:()=>t(e(`common.saved`),`success`),onError:e=>t(H(e),`error`)});return(0,Q.jsxs)(u,{title:e(`mcp.gateway.title`),children:[(0,Q.jsx)(z,{label:e(`mcp.gateway.enable`),detail:e(`mcp.gateway.enableHint`),children:(0,Q.jsx)(T,{checked:c.enabled,disabled:r.isPending,label:e(`mcp.gateway.enable`),onChange:e=>l({enabled:e})})}),(0,Q.jsx)(z,{label:e(`mcp.gateway.remoteAdmin`),detail:e(`mcp.gateway.remoteAdminHint`),children:(0,Q.jsx)(T,{checked:c.allowRemoteAdmin,disabled:r.isPending,label:e(`mcp.gateway.remoteAdmin`),onChange:e=>l({allowRemoteAdmin:e})})}),(0,Q.jsxs)(z,{label:e(`mcp.gateway.endpoint`),detail:(0,Q.jsx)(`span`,{className:`block whitespace-normal`,children:e(`mcp.gateway.endpointHint`)}),children:[(0,Q.jsx)(`code`,{className:`max-w-[22rem] truncate rounded bg-[var(--surface-muted,transparent)] px-1.5 py-0.5 font-mono text-[12px]`,title:c.endpoint,children:c.endpoint}),(0,Q.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(G,{className:`size-3.5`}),"aria-label":e(`mcp.gateway.copyEndpoint`),onClick:()=>void V.copy(c.endpoint).then(n=>n&&t(e(`mcp.gateway.copied`),`success`))})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2 px-4 py-3`,children:[(0,Q.jsx)(_,{label:e(`mcp.gateway.origins`),hint:e(`mcp.gateway.originsHint`),children:(0,Q.jsx)(d,{mono:!0,rows:3,value:i,placeholder:`https://app.example.com`,onChange:e=>a(e.target.value)})}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(g,{size:`sm`,disabled:i.trim()===s.trim()||r.isPending,onClick:()=>l({allowedOrigins:i.split(`
9
+ `).map(e=>e.trim()).filter(Boolean)}),children:e(`mcp.gateway.originsSave`)})})]})]})}function Oe(){let{t:e}=L(),{toast:t,confirm:r}=W(),i=l(),o=w(),c=s(),u=n(),d=a(),[f,p]=(0,Z.useState)(null),[m,_]=(0,Z.useState)(null),v=n=>o.mutate(n.id,{onSuccess:r=>{r.ok?_({server:n,result:r}):t(e(`mcp.server.testFailed`,{message:r.message??r.status}),`error`)},onError:e=>t(H(e),`error`)}),y=n=>c.mutate(n.id,{onSuccess:n=>{n.authorizationUrl?(window.open(n.authorizationUrl,`_blank`,`noopener`),t(e(`mcp.server.authorizeOpened`),`success`)):t(n.message??e(`mcp.server.authorizeNotNeeded`),`success`)},onError:e=>t(H(e),`error`)}),b=async n=>{await r({title:e(`mcp.server.forgetConfirm`,{name:n.name}),detail:e(`mcp.server.forgetDetail`),confirmLabel:e(`mcp.server.forget`),destructive:!0})&&u.mutate(n.id,{onSuccess:()=>t(e(`mcp.server.forgotten`),`success`),onError:e=>t(H(e),`error`)})},x=async n=>{await r({title:e(`mcp.server.deleteConfirm`,{name:n.name}),detail:e(`mcp.server.deleteDetail`),confirmLabel:e(`common.delete`),destructive:!0})&&d.mutate(n.id,{onSuccess:()=>t(e(`mcp.server.deleted`,{name:n.name}),`success`),onError:e=>t(H(e),`error`)})};return(0,Q.jsxs)(`section`,{className:`mb-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,Q.jsx)(`h3`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:e(`mcp.servers.title`)}),(0,Q.jsx)(g,{size:`sm`,variant:`primary`,icon:(0,Q.jsx)(Y,{className:`size-3.5`}),onClick:()=>p(`new`),children:e(`mcp.servers.add`)})]}),i.data===void 0?(0,Q.jsx)(C,{}):i.data.length===0?(0,Q.jsx)(h,{icon:(0,Q.jsx)(J,{className:`size-6`}),title:e(`mcp.servers.emptyTitle`),detail:e(`mcp.servers.emptyDetail`)}):(0,Q.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:i.data.map(e=>(0,Q.jsx)(ke,{server:e,busy:o.isPending&&o.variables===e.id,onTest:()=>v(e),onEdit:()=>p(e),onAuthorize:()=>y(e),onForget:()=>void b(e),onDelete:()=>void x(e)},e.id))}),(0,Q.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:e(`mcp.servers.localOnly`)}),(0,Q.jsx)(je,{server:f,onClose:()=>p(null)}),(0,Q.jsx)(B,{open:m!==null,onOpenChange:e=>!e&&_(null),title:e(`mcp.server.testToolsTitle`,{name:m?.server.name??``}),description:m?e(`mcp.server.testOk`,{count:m.result.toolCount}):void 0,footer:(0,Q.jsx)(g,{onClick:()=>_(null),children:e(`common.close`)}),children:(0,Q.jsx)(`ul`,{className:`max-h-72 overflow-auto font-mono text-[12px] text-[var(--text-secondary)]`,children:m?.result.tools.map(e=>(0,Q.jsx)(`li`,{className:`truncate py-0.5`,children:e},e))})})]})}function ke({server:e,busy:t,onTest:n,onEdit:r,onAuthorize:a,onForget:o,onDelete:s}){let{t:c,locale:l}=L(),u=A(),d=e.id===`builtin-astra`,f=e.authType===`oauth`,p=e.oauth?.authorized===!0,m=[e.slug,e.protocolVersion?c(`mcp.server.protocol`,{version:e.protocolVersion}):null,c(`mcp.server.boundTokens`,{count:e.boundTokens}),e.checkedAt?I(e.checkedAt,l):null].filter(Boolean).join(` · `);return(0,Q.jsxs)(z,{label:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),d&&(0,Q.jsx)(i,{tone:`accent`,children:c(`mcp.server.builtIn`)}),(0,Q.jsx)(i,{tone:Te[e.status],title:e.statusMessage??void 0,children:c(`mcp.status.${e.status}`)}),!e.enabled&&(0,Q.jsx)(i,{children:c(`mcp.server.disabledBadge`)})]}),detail:(0,Q.jsxs)(`span`,{className:`block whitespace-normal`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.url}),(0,Q.jsx)(`span`,{className:`block`,children:m}),f&&p&&e.oauth?.issuer&&(0,Q.jsx)(`span`,{className:`block`,children:c(`mcp.server.authorizedBy`,{issuer:e.oauth.issuer})})]}),children:[d&&(0,Q.jsx)(Ae,{}),f&&(0,Q.jsx)(g,{size:`sm`,variant:p?`glass`:`primary`,icon:(0,Q.jsx)(re,{className:`size-3.5`}),onClick:a,children:c(p?`mcp.server.reauthorize`:`mcp.server.authorize`)}),!d&&(0,Q.jsx)(g,{size:`sm`,icon:(0,Q.jsx)(ae,{className:`size-3.5`}),loading:t,onClick:n,children:c(`mcp.server.test`)}),d?(0,Q.jsx)(T,{checked:e.enabled,label:e.name,onChange:t=>u.mutate({id:e.id,body:{enabled:t}})}):(0,Q.jsx)(te,{label:e.name,iconOnly:!0,icon:(0,Q.jsx)(K,{className:`size-4`}),items:[{id:`edit`,label:c(`common.edit`),icon:(0,Q.jsx)(q,{className:`size-3.5`}),onSelect:r},...f&&p?[{id:`forget`,label:c(`mcp.server.forget`),icon:(0,Q.jsx)(ne,{className:`size-3.5`}),onSelect:o}]:[],{id:`delete`,label:c(`common.delete`),icon:(0,Q.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:s}]})]})}function Ae(){let{t:e}=L(),t=se();return(0,Q.jsx)(g,{size:`sm`,onClick:()=>t(`/tools`),children:e(`mcp.server.builtInManage`)})}function je({server:e,onClose:t}){let{t:n}=L(),{toast:r}=W(),i=j(),a=A(),o=e&&e!==`new`?e:null,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(``),[h,v]=(0,Z.useState)(`http`),[x,S]=(0,Z.useState)(`none`),[C,w]=(0,Z.useState)([]),[E,D]=(0,Z.useState)(60),[O,k]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;c(t?.name??``),u(t?.slug??``),p(t?.url??``),v(t?.transport??`http`),S(t?.authType??`none`),w((t?.headerNames??[]).map(e=>({name:e,value:``,kept:!0}))),D(t?.timeoutSeconds??60),k(t?.enabled??!0)},[e]);let ee=i.isPending||a.isPending,M=s.trim()!==``&&d.trim()!==``&&(x!==`header`||C.some(e=>e.name.trim()!==``&&(e.value!==``||e.kept))),N=()=>{let e={name:s.trim(),url:d.trim(),transport:h,authType:x,enabled:O,...E==null?{}:{timeoutSeconds:Math.floor(E)},...l.trim()?{slug:l.trim()}:{}};x===`header`&&(e.headers=Object.fromEntries(C.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.kept&&e.value===``?null:e.value])));let c={onSuccess:e=>{t(),r(n(o?`mcp.server.saved`:`mcp.server.created`,{name:e.name}),`success`)},onError:e=>r(H(e),`error`)};o?a.mutate({id:o.id,body:e},c):i.mutate(e,c)},P=(e,t)=>w(n=>n.map((n,r)=>r===e?{...n,...t}:n));return(0,Q.jsx)(B,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:o?n(`mcp.server.editTitle`,{name:o.name}):n(`mcp.server.addTitle`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(g,{variant:`primary`,disabled:!M,loading:ee,onClick:N,children:n(`common.save`)})]}),children:(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsx)(_,{label:n(`mcp.server.name`),children:(0,Q.jsx)(m,{value:s,maxLength:64,onChange:e=>c(e.target.value)})}),(0,Q.jsx)(_,{label:n(`mcp.server.url`),hint:n(`mcp.server.urlHint`),children:(0,Q.jsx)(m,{mono:!0,value:d,placeholder:`https://mcp.example.com/mcp`,onChange:e=>p(e.target.value)})}),(0,Q.jsx)(_,{label:n(`mcp.server.transport`),hint:n(`mcp.server.transportHint`),children:(0,Q.jsx)(f,{ariaLabel:n(`mcp.server.transport`),value:h,onChange:v,items:[{value:`http`,label:n(`mcp.server.transport.http`)},{value:`sse`,label:n(`mcp.server.transport.sse`)}]})}),(0,Q.jsx)(_,{label:n(`mcp.server.auth`),children:(0,Q.jsx)(f,{ariaLabel:n(`mcp.server.auth`),value:x,onChange:S,items:[{value:`none`,label:n(`mcp.server.auth.none`)},{value:`header`,label:n(`mcp.server.auth.header`)},{value:`oauth`,label:n(`mcp.server.auth.oauth`)}]})}),x===`oauth`&&(0,Q.jsx)(b,{tone:`warning`,title:n(`mcp.server.oauthNote`)}),x===`header`&&(0,Q.jsx)(_,{label:n(`mcp.server.headers`),hint:n(`mcp.server.headersHint`),children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[C.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{className:`w-40`,mono:!0,label:n(`mcp.server.headerName`),placeholder:`Authorization`,value:e.name,readOnly:e.kept&&o!==null,onChange:e=>P(t,{name:e.target.value})}),(0,Q.jsx)(m,{className:`flex-1`,mono:!0,type:`password`,label:n(`mcp.server.headerValue`),placeholder:e.kept?n(`mcp.server.headerKept`):`Bearer …`,value:e.value,onChange:e=>P(t,{value:e.target.value})}),(0,Q.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),"aria-label":n(`mcp.server.removeHeader`),onClick:()=>w(e=>e.filter((e,n)=>n!==t))})]},t)),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(g,{size:`sm`,icon:(0,Q.jsx)(Y,{className:`size-3.5`}),onClick:()=>w(e=>[...e,{name:``,value:``,kept:!1}]),children:n(`mcp.server.addHeader`)})})]})}),(0,Q.jsx)(_,{label:n(`mcp.server.slug`),hint:n(`mcp.server.slugHint`),children:(0,Q.jsx)(m,{mono:!0,value:l,maxLength:32,placeholder:o?``:`github`,onChange:e=>u(e.target.value)})}),(0,Q.jsx)(_,{label:n(`mcp.server.timeout`),hint:n(`mcp.server.timeoutHint`),children:(0,Q.jsx)(y,{value:E,min:1,step:1,label:n(`mcp.server.timeout`),onChange:D})}),(0,Q.jsx)(z,{label:n(`mcp.server.enabled`),children:(0,Q.jsx)(T,{checked:O,label:n(`mcp.server.enabled`),onChange:k})})]})})}function Me(){let{t:e,locale:t}=L(),n=S(50);return(0,Q.jsx)(u,{title:e(`mcp.calls.title`),footer:e(`mcp.calls.hint`),children:n.data===void 0?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(C,{})}):n.data.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:e(`mcp.calls.empty`)}):(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsxs)(`table`,{className:`w-full text-left text-[12px]`,children:[(0,Q.jsx)(`thead`,{className:`text-[var(--text-muted)]`,children:(0,Q.jsx)(`tr`,{children:[`time`,`token`,`tool`,`duration`,`result`].map(t=>(0,Q.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:e(`mcp.calls.${t}`)},t))})}),(0,Q.jsx)(`tbody`,{children:n.data.map(e=>(0,Q.jsx)(Ne,{call:e,locale:t},e.id))})]})})})}function Ne({call:e,locale:t}){let{t:n}=L();return(0,Q.jsxs)(`tr`,{className:`border-t border-[var(--border)]`,children:[(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-4 py-1.5 text-[var(--text-secondary)]`,children:I(e.at,t)}),(0,Q.jsx)(`td`,{className:`px-4 py-1.5`,children:e.tokenName??e.tokenId}),(0,Q.jsxs)(`td`,{className:`px-4 py-1.5 font-mono`,children:[e.serverSlug,(0,Q.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`/`}),e.tool,e.frontEra&&(0,Q.jsx)(`span`,{className:`ml-2 text-[10.5px] text-[var(--text-muted)]`,children:n(`mcp.calls.era.${e.frontEra}`)})]}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-4 py-1.5 tabular-nums text-[var(--text-secondary)]`,children:P(e.durationMs)}),(0,Q.jsx)(`td`,{className:`px-4 py-1.5`,children:e.ok?(0,Q.jsx)(i,{tone:`green`,children:n(`mcp.calls.ok`)}):(0,Q.jsx)(i,{tone:`red`,children:n(`mcp.calls.error.${e.errorCategory??`protocol`}`)})})]})}function Pe(){let{t:e}=L();return(0,Q.jsx)(ce,{title:e(`nav.mcp`),subtitle:e(`mcp.subtitle`),children:(0,Q.jsx)(Ee,{})})}export{Pe as McpPage};
@@ -0,0 +1 @@
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$s as n,Ar as r,D as i,F as a,I as o,Li as s,Lo as c,O as l,On as u,P as d,R as f,S as p,U as m,V as h,W as g,kn as _,mo as v,ni as y,r as b,w as x,y as S,z as C}from"./format-CskGUFYy.js";import{H as w,U as T,V as E,W as D}from"./TrayTitleSource-B98nYas3.js";import{t as O}from"./arrow-left-DhPqlXf4.js";import{t as k}from"./pencil-CpF9MxGZ.js";import{t as A}from"./plus-c3HzV6VX.js";import{t as j}from"./rotate-ccw-fsXoCwyv.js";import{t as M}from"./trash-BHBJn5GS.js";import{G as N,H as ee,W as te,l as P,s as ne,v as F}from"./index-D2siu6xk.js";import{t as I}from"./checkbox-29lSW_6h.js";import{t as L}from"./confirm-morph-DpNjlFyg.js";var R=e(t(),1),z=n(),B=[{key:`vision`,label:`cap.vision`},{key:`tools`,label:`cap.tools`},{key:`reasoning`,label:`cap.reasoning`},{key:`promptCache`,label:`cap.promptCache`},{key:`audio`,label:`cap.audio`},{key:`pdf`,label:`cap.pdf`},{key:`structuredOutput`,label:`cap.structuredOutput`}];function V(e){return{displayName:e.displayName,vendor:e.vendor,family:e.family??null,aliases:e.aliases,contextWindow:e.contextWindow??null,maxOutputTokens:e.maxOutputTokens??null,capabilities:e.capabilities,pricing:e.pricing??null,enabled:e.enabled}}function H(){let{t:e,locale:t}=x(),n=te(),{id:c=``}=N(),d=decodeURIComponent(c),_=r(d),y=v(d),w=s(d),E=u(),{toast:k}=D(),A=(0,R.useMemo)(()=>_.data?V(_.data):null,[_.data]),[M,L]=(0,R.useState)(A),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(A),G(A?.aliases?.join(`, `)??``)},[A]);let q=(0,z.jsx)(l,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>n(`/models`)});if(_.isError)return(0,z.jsx)(F,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(p,{tone:`danger`,title:e(`common.error`),children:T(_.error)})});let J=_.data;if(!J||!M)return(0,z.jsx)(F,{title:``,leading:q,children:(0,z.jsx)(m,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...M,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(A),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>y.mutate(X,{onSuccess:()=>k(e(`common.saved`),`success`),onError:e=>k(T(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(i,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(j,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>w.mutate(t,{onSuccess:()=>k(e(`models.fieldReset`)),onError:e=>k(T(e),`error`)})})]}):null;return(0,z.jsx)(F,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:b(J.updatedAt,t)})}`,leading:q,actions:(0,z.jsxs)(z.Fragment,{children:[J.source===`user`&&(0,z.jsx)(K,{label:e(`common.delete`),prompt:e(`models.deleteConfirm`,{id:J.id}),onConfirm:async()=>{await E.mutateAsync(J.id),n(`/models`)}}),Z&&(0,z.jsx)(l,{onClick:()=>{L(A),G(A?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(l,{variant:`primary`,disabled:!Z,loading:y.isPending,onClick:ie,children:e(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`mx-auto grid max-w-[1100px] gap-x-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(a,{title:e(`models.section.basic`),footer:Q?e(`models.modifiedFooter`):void 0,children:[(0,z.jsx)(U,{label:e(`models.field.displayName`),marker:$(`displayName`),children:(0,z.jsx)(o,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:M.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(o,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:M.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(o,{className:`w-60`,"aria-label":e(`models.field.family`),value:M.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(o,{className:`w-60 font-mono`,"aria-label":e(`models.field.aliases`),value:H,onChange:e=>G(e.target.value),placeholder:`a, b, c`})}),(0,z.jsx)(U,{label:e(`models.field.contextWindow`),marker:$(`contextWindow`),children:(0,z.jsx)(f,{className:`w-36`,label:e(`models.field.contextWindow`),value:M.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(f,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:M.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(g,{checked:M.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(a,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e(`models.section.capabilities`),` `,$(`capabilities`)]}),children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 px-4 py-4`,children:B.map(t=>(0,z.jsx)(I,{label:e(t.label),checked:!!M.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...M.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(a,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(C,{label:(0,z.jsx)(ee,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${S(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(h,{action:$(`pricing`),children:e(`models.section.pricing`)}),(0,z.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--text-secondary)]`,children:e(`models.pricingHint`)}),(0,z.jsx)(`div`,{className:`card p-4`,children:(0,z.jsx)(P,{value:M.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(h,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(ne,{modelId:Z?void 0:J.id,pricing:Z?X.pricing:null}),Z&&(0,z.jsx)(`p`,{className:`mt-3 text-[12px] text-[var(--text-muted)]`,children:e(`models.simulatorUnsaved`)})]})]})]})]})})}function U({label:e,marker:t,children:n}){return(0,z.jsx)(C,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=x(),n=_(e.id),[r,o]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(a,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3.5`}),onClick:()=>o(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(C,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(C,{label:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.priceKey}),e.userModified&&(0,z.jsx)(i,{tone:`orange`,children:t(`models.modified`)})]}),detail:[S(e.pricing),e.upstreamModelId,e.pricing.time_windows?.length?t(`models.hasTimeWindows`):null,e.pricing.context_tiers?.length?t(`models.hasTiers`):null].filter(Boolean).join(` · `),children:[(0,z.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>o(e)}),(0,z.jsx)(K,{label:t(`common.delete`),prompt:t(`models.deletePrice`,{key:e.priceKey}),onConfirm:()=>n.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:r,onClose:()=>o(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:r}=x(),{toast:i}=D(),a=y(),s=c(e.id),u=t===`new`,[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(``),[g,_]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(p(``),h(``),_(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(p(t.priceKey),h(t.upstreamModelId??``),_(structuredClone(t.pricing))))},[t,e.pricing]);let v=new Set(e.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(w,{open:t!==null,onOpenChange:e=>!e&&n(),width:680,title:u?r(`models.addPrice`):r(`models.editPrice`,{key:f}),description:r(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(l,{onClick:n,children:r(`common.cancel`)}),(0,z.jsx)(l,{variant:`primary`,disabled:!f||!g,loading:s.isPending,onClick:()=>s.mutate({priceKey:f,upstreamModelId:m||null,pricing:g},{onSuccess:()=>{i(r(`common.saved`),`success`),n()},onError:e=>i(T(e),`error`)}),children:r(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsx)(d,{label:r(`providers.priceKey`),children:u?(0,z.jsx)(E,{value:f,onChange:p,placeholder:r(`models.pickPriceKey`),options:(a.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:v.has(e.priceKey)}))}):(0,z.jsx)(o,{value:f,disabled:!0,className:`font-mono`})}),(0,z.jsx)(d,{label:r(`models.upstreamId`),hint:r(`models.upstreamIdHint`),children:(0,z.jsx)(o,{className:`font-mono`,value:m,onChange:e=>h(e.target.value),placeholder:e.id})})]}),u&&(0,z.jsx)(o,{className:`font-mono`,"aria-label":r(`models.customPriceKey`),placeholder:r(`models.customPriceKey`),value:f,onChange:e=>p(e.target.value.trim())}),(0,z.jsx)(P,{value:g,onChange:_})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=x();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(M,{className:`size-4`}),prompt:t,confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{Ar as n,B as r,D as i,I as a,Ia as o,N as s,O as c,P as l,Pa as u,Qs as d,R as f,S as p,U as m,dt as h,gn as g,n as _,p as v,v as y,w as b}from"./format-CmXxTS5M.js";import{H as x,U as S,V as C,W as w}from"./TrayTitleSource-DN10ruw2.js";import{t as T}from"./boxes-BLn3utsF.js";import{t as E}from"./chevron-right-Bgtn3ze-.js";import{t as D}from"./cloud-download-l1GjuXcO.js";import{t as O}from"./plus-c3HzV6VX.js";import{A as k,F as A,I as j,W as M,v as N}from"./index-BW8keTkg.js";import{t as P}from"./checkbox-CZ-rG7I2.js";var F=e(t(),1),I=d();function L(){let{t:e}=b(),t=M(),[i,a]=(0,F.useState)(``),[o,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1),[f,h]=(0,F.useState)(!1),g=(0,F.useRef)(null),_=j(i),v=n(),y=n(_,o),x=(0,F.useMemo)(()=>[...new Set((v.data??[]).map(e=>e.vendor))].sort(),[v.data]);return A(e=>{e===`find`&&g.current?.focus()}),(0,I.jsxs)(N,{title:e(`nav.models`),subtitle:y.data?e(`models.count`,{count:y.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{inputRef:g,className:`w-52`,value:i,onChange:a,placeholder:e(`models.search`)}),(0,I.jsx)(C,{value:o,onChange:l,options:[{value:``,label:e(`models.allVendors`)},...x.map(e=>({value:e,label:e}))]}),(0,I.jsx)(c,{icon:(0,I.jsx)(D,{className:`size-3.5`}),onClick:()=>h(!0),children:e(`models.sync`)}),(0,I.jsx)(c,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>d(!0),children:e(`models.new`)})]}),children:[y.isLoading&&(0,I.jsx)(m,{lines:5}),y.isError&&(0,I.jsx)(p,{tone:`danger`,title:e(`common.error`),children:S(y.error)}),y.data?.length===0&&(0,I.jsx)(s,{icon:(0,I.jsx)(T,{className:`size-6`}),title:e(`models.empty`)}),y.data&&y.data.length>0&&(0,I.jsx)(k,{caption:e(`nav.models`),rowKey:`id`,rows:y.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:u,onOpenChange:d,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:f,onOpenChange:h})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:h(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(i,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(i,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,t)=>_(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${v(n.input)} / ${v(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:e,onOpenChange:t,onCreated:n}){let{t:r}=b(),{toast:i}=w(),o=g(),[s,u]=(0,F.useState)(``),[d,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[_,v]=(0,F.useState)(null),[y,C]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(x,{open:e,onOpenChange:t,title:r(`models.new`),description:r(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(c,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(c,{variant:`primary`,disabled:!s.trim()||!m.trim(),loading:o.isPending,onClick:()=>o.mutate({id:s.trim(),displayName:d.trim()||s.trim(),vendor:m.trim(),contextWindow:_,pricing:y!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:y,output:T}}:null},{onSuccess:e=>{t(!1),u(``),p(``),n(e.id)},onError:e=>i(S(e),`error`)}),children:r(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(l,{label:r(`models.field.id`),hint:r(`models.field.idHint`),children:(0,I.jsx)(a,{className:`font-mono`,value:s,onChange:e=>u(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(l,{label:r(`models.field.displayName`),children:(0,I.jsx)(a,{value:d,onChange:e=>p(e.target.value)})}),(0,I.jsx)(l,{label:r(`models.field.vendor`),children:(0,I.jsx)(a,{value:m,onChange:e=>h(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(l,{label:r(`models.field.contextWindow`),children:(0,I.jsx)(f,{value:_,onChange:v})}),(0,I.jsx)(l,{label:r(`models.field.inputPrice`),children:(0,I.jsx)(f,{value:y,onChange:C})}),(0,I.jsx)(l,{label:r(`models.field.outputPrice`),children:(0,I.jsx)(f,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=b(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${y(e)||`∅`}\n→\n${y(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:a}=b(),[o,s]=(0,F.useState)(new Set),c=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),l=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},u=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},d=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(i,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(i,{tone:`orange`,children:a(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:l(p),onCheckedChange:e=>u(p,e!==!1),"aria-label":a(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`models.sync.selectedOf`,{n:n.size,total:p.length,models:c.length})})]}),c.map(([e,r])=>{let i=r.map(e=>e.id),s=r.length===1?r[0]:void 0,c=!o.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:l(i),onCheckedChange:e=>u(i,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":c,onClick:()=>d(e),children:[(0,I.jsx)(E,{className:h(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,c&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:a(`models.sync.groupCount`,{n:r.length})})]}),s&&f(s)]})]}),!s&&c&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>u([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),f(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:n}=b(),{toast:r}=w(),i=o(),a=u(),[s,l]=(0,F.useState)(new Set),d=()=>i.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),f=i.data?.changes??[];return(0,I.jsxs)(x,{open:e,onOpenChange:e=>{t(e),e&&!i.data&&d()},width:720,title:n(`models.sync`),description:n(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(c,{className:`mr-auto`,variant:`plain`,onClick:d,loading:i.isPending,children:n(`common.refresh`)}),(0,I.jsx)(c,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,I.jsx)(c,{variant:`primary`,disabled:s.size===0,loading:a.isPending,onClick:()=>a.mutate([...s],{onSuccess:e=>{r(n(`models.sync.applied`,{count:e.applied}),`success`),t(!1),i.reset()},onError:e=>r(S(e),`error`)}),children:n(`models.sync.apply`,{count:s.size})})]}),children:[e&&!i.data&&!i.isPending&&!i.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(c,{variant:`primary`,onClick:d,children:n(`models.sync.check`)})}),i.isPending&&(0,I.jsx)(m,{lines:4}),i.isError&&(0,I.jsx)(p,{tone:`danger`,title:n(`common.error`),children:S(i.error)}),i.data&&f.length===0&&(0,I.jsx)(p,{tone:`success`,title:n(`models.sync.none`)}),f.length>0&&(0,I.jsx)(K,{changes:f,label:e=>e.kind===`new_model`?n(`models.sync.newModel`):e.kind===`price`?n(`models.sync.price`,{key:e.priceKey??``}):n(`models.sync.field`,{field:e.field??``}),checked:s,onChange:l})]})}export{L as ModelsPage};
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$s as n,B as r,D as i,Fa as a,I as o,La as s,N as c,O as l,P as u,R as d,S as f,U as p,_n as m,dt as h,jr as g,n as _,p as v,v as y,w as b}from"./format-CskGUFYy.js";import{H as x,U as S,V as C,W as w}from"./TrayTitleSource-B98nYas3.js";import{t as T}from"./boxes-BLn3utsF.js";import{t as E}from"./chevron-right-Bgtn3ze-.js";import{t as D}from"./cloud-download-l1GjuXcO.js";import{t as O}from"./plus-c3HzV6VX.js";import{A as k,F as A,I as j,W as M,v as N}from"./index-D2siu6xk.js";import{t as P}from"./checkbox-29lSW_6h.js";var F=e(t(),1),I=n();function L(){let{t:e}=b(),t=M(),[n,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,u]=(0,F.useState)(!1),[d,m]=(0,F.useState)(!1),h=(0,F.useRef)(null),_=j(n),v=g(),y=g(_,a),x=(0,F.useMemo)(()=>[...new Set((v.data??[]).map(e=>e.vendor))].sort(),[v.data]);return A(e=>{e===`find`&&h.current?.focus()}),(0,I.jsxs)(N,{title:e(`nav.models`),subtitle:y.data?e(`models.count`,{count:y.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{inputRef:h,className:`w-52`,value:n,onChange:i,placeholder:e(`models.search`)}),(0,I.jsx)(C,{value:a,onChange:o,options:[{value:``,label:e(`models.allVendors`)},...x.map(e=>({value:e,label:e}))]}),(0,I.jsx)(l,{icon:(0,I.jsx)(D,{className:`size-3.5`}),onClick:()=>m(!0),children:e(`models.sync`)}),(0,I.jsx)(l,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>u(!0),children:e(`models.new`)})]}),children:[y.isLoading&&(0,I.jsx)(p,{lines:5}),y.isError&&(0,I.jsx)(f,{tone:`danger`,title:e(`common.error`),children:S(y.error)}),y.data?.length===0&&(0,I.jsx)(c,{icon:(0,I.jsx)(T,{className:`size-6`}),title:e(`models.empty`)}),y.data&&y.data.length>0&&(0,I.jsx)(k,{caption:e(`nav.models`),rowKey:`id`,rows:y.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:s,onOpenChange:u,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:d,onOpenChange:m})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:h(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(i,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(i,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,t)=>_(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${v(n.input)} / ${v(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:e,onOpenChange:t,onCreated:n}){let{t:r}=b(),{toast:i}=w(),a=m(),[s,c]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[h,g]=(0,F.useState)(``),[_,v]=(0,F.useState)(null),[y,C]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(x,{open:e,onOpenChange:t,title:r(`models.new`),description:r(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(l,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(l,{variant:`primary`,disabled:!s.trim()||!h.trim(),loading:a.isPending,onClick:()=>a.mutate({id:s.trim(),displayName:f.trim()||s.trim(),vendor:h.trim(),contextWindow:_,pricing:y!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:y,output:T}}:null},{onSuccess:e=>{t(!1),c(``),p(``),n(e.id)},onError:e=>i(S(e),`error`)}),children:r(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(u,{label:r(`models.field.id`),hint:r(`models.field.idHint`),children:(0,I.jsx)(o,{className:`font-mono`,value:s,onChange:e=>c(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(u,{label:r(`models.field.displayName`),children:(0,I.jsx)(o,{value:f,onChange:e=>p(e.target.value)})}),(0,I.jsx)(u,{label:r(`models.field.vendor`),children:(0,I.jsx)(o,{value:h,onChange:e=>g(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(u,{label:r(`models.field.contextWindow`),children:(0,I.jsx)(d,{value:_,onChange:v})}),(0,I.jsx)(u,{label:r(`models.field.inputPrice`),children:(0,I.jsx)(d,{value:y,onChange:C})}),(0,I.jsx)(u,{label:r(`models.field.outputPrice`),children:(0,I.jsx)(d,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=b(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${y(e)||`∅`}\n→\n${y(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:a}=b(),[o,s]=(0,F.useState)(new Set),c=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),l=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},u=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},d=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(i,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(i,{tone:`orange`,children:a(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:l(p),onCheckedChange:e=>u(p,e!==!1),"aria-label":a(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`models.sync.selectedOf`,{n:n.size,total:p.length,models:c.length})})]}),c.map(([e,r])=>{let i=r.map(e=>e.id),s=r.length===1?r[0]:void 0,c=!o.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:l(i),onCheckedChange:e=>u(i,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":c,onClick:()=>d(e),children:[(0,I.jsx)(E,{className:h(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,c&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:a(`models.sync.groupCount`,{n:r.length})})]}),s&&f(s)]})]}),!s&&c&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>u([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),f(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:n}=b(),{toast:r}=w(),i=s(),o=a(),[c,u]=(0,F.useState)(new Set),d=()=>i.mutate(void 0,{onSuccess:e=>u(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),m=i.data?.changes??[];return(0,I.jsxs)(x,{open:e,onOpenChange:e=>{t(e),e&&!i.data&&d()},width:720,title:n(`models.sync`),description:n(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(l,{className:`mr-auto`,variant:`plain`,onClick:d,loading:i.isPending,children:n(`common.refresh`)}),(0,I.jsx)(l,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,I.jsx)(l,{variant:`primary`,disabled:c.size===0,loading:o.isPending,onClick:()=>o.mutate([...c],{onSuccess:e=>{r(n(`models.sync.applied`,{count:e.applied}),`success`),t(!1),i.reset()},onError:e=>r(S(e),`error`)}),children:n(`models.sync.apply`,{count:c.size})})]}),children:[e&&!i.data&&!i.isPending&&!i.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(l,{variant:`primary`,onClick:d,children:n(`models.sync.check`)})}),i.isPending&&(0,I.jsx)(p,{lines:4}),i.isError&&(0,I.jsx)(f,{tone:`danger`,title:n(`common.error`),children:S(i.error)}),i.data&&m.length===0&&(0,I.jsx)(f,{tone:`success`,title:n(`models.sync.none`)}),m.length>0&&(0,I.jsx)(K,{changes:m,label:e=>e.kind===`new_model`?n(`models.sync.newModel`):e.kind===`price`?n(`models.sync.price`,{key:e.priceKey??``}):n(`models.sync.field`,{field:e.field??``}),checked:c,onChange:u})]})}export{L as ModelsPage};
@@ -0,0 +1,2 @@
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$s as n,B as r,Br as i,D as a,Ei as o,G as s,H as c,I as l,L as u,Mr as d,N as f,Nt as p,O as m,P as h,Qr as g,Rr as _,S as v,U as y,Ur as b,W as x,Yr as S,dt as C,ho as w,k as T,lr as E,pr as D,r as O,w as k,wi as A,wr as j,zr as M}from"./format-CskGUFYy.js";import{B as N,H as P,U as F,W as I}from"./TrayTitleSource-B98nYas3.js";import{t as ee}from"./app-window-C13qqwdi.js";import{t as te}from"./arrow-down-Def8Fl70.js";import{t as L}from"./arrow-up-DE65OgjV.js";import{t as ne}from"./check-DKfsh0bQ.js";import{t as re}from"./ellipsis-CidyZaW2.js";import{t as ie}from"./external-link-D6jQM2CZ.js";import{t as ae}from"./plus-c3HzV6VX.js";import{t as R}from"./puzzle-Eesuewfj.js";import{t as z}from"./refresh-cw-CoLAai2c.js";import{t as oe}from"./settings-2-CSrxJ7TH.js";import{t as se}from"./shield-check-CD30JqBi.js";import{t as ce}from"./trash-BHBJn5GS.js";import{B,D as V,E as H,G as U,K as W,L as le,O as ue,W as G,k as K,v as de,w as fe}from"./index-D2siu6xk.js";var q=e(t(),1),J=n(),pe=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`,v2:`plugins.kind.v2`,ui:`plugins.kind.ui`,hooks:`plugins.kind.hooks`},me={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`,v2:`accent`,ui:`neutral`,hooks:`accent`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?se:ee,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function he(){let{t:e}=k(),t=G(),{tab:n}=U(),r=n===`market`||n===`runtime`?n:`installed`,i=S(),a=w(),{toast:o}=I(),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null);return(0,J.jsxs)(de,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{icon:(0,J.jsx)(z,{className:`size-3.5`}),onClick:()=>a.mutate(void 0,{onSuccess:e=>f(e.id),onError:e=>o(F(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(m,{variant:`primary`,icon:(0,J.jsx)(ae,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[i.data?.off&&(0,J.jsx)(v,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(H,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(ue,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(K,{value:`installed`,children:[e(`plugins.tab.installed`),i.data&&i.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:i.data.plugins.length})]}),(0,J.jsx)(K,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(K,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(V,{value:`installed`,className:`pt-1`,children:[i.isLoading&&(0,J.jsx)(y,{lines:4}),i.isError&&(0,J.jsx)(v,{tone:`danger`,title:e(`common.error`),children:F(i.error)}),(0,J.jsx)(`div`,{className:`mb-4`,children:(0,J.jsx)(le,{onJob:f})}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins.filter(e=>!e.kinds.includes(`v2`)),preferences:i.data.preferences,onJob:f,onBrowse:()=>t(`/plugins/market`),onImport:()=>u(!0)})]}),(0,J.jsx)(V,{value:`market`,className:`pt-1`,children:(0,J.jsx)(xe,{installed:i.data?.plugins??[],onJob:f})}),(0,J.jsx)(V,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Se,{onJob:f})})]})]}),(0,J.jsx)(ve,{open:s,onOpenChange:c,onJob:f}),(0,J.jsx)(ye,{open:l,onOpenChange:u,onJob:f}),(0,J.jsx)(be,{id:d,onClose:()=>f(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=k(),s=_(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),c=j(),l=o(),{toast:u}=I(),d=!!(c.data?.found&&c.data.plugins.some(e=>!e.installed))&&(0,J.jsxs)(`div`,{className:`card flex flex-wrap items-center gap-3 p-4`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a(`plugins.magpie.banner`,{count:c.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(m,{size:`sm`,icon:(0,J.jsx)(B,{className:`size-3.5`}),onClick:i,children:a(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(f,{icon:(0,J.jsx)(R,{className:`size-6`}),title:a(`plugins.empty`),detail:a(`plugins.emptyDetail`),action:(0,J.jsx)(m,{variant:`primary`,onClick:r,children:a(`plugins.browseMarket`)})})})]});let p=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),l.mutate(r,{onError:e=>u(F(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:s.data,preferences:t,onJob:n,onUp:i>0?()=>p(i,-1):void 0,onDown:i<e.length-1?()=>p(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:r,onUp:i,onDown:o}){let{t:s}=k(),c=G(),{toast:l,confirm:u}=I(),f=d(),p=w(),h=A(),_=g(),[y,b]=(0,q.useState)(!1),S=t?.plugins.find(t=>t.spec===e.spec),T=e.middleware,E=e.kinds[0]??`provider`,D=async()=>{await u({title:s(`plugins.removeConfirm`,{name:e.shortName}),detail:s(`plugins.removeDetail`),confirmLabel:s(`common.delete`),destructive:!0})&&h.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>l(F(e),`error`)})},O=[];return T&&!T.error&&O.push((0,J.jsxs)(Z,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:T.hooks.join(`, `),calls:T.calls,micros:T.avgMicros.toFixed(1),failures:T.failures}),T.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:T.lastError})})]},`mw`)),e.notice===`hooks-unsupported`&&O.push((0,J.jsx)(Z,{label:s(`plugins.kind.hooks`),children:s(`plugins.hooksUnsupported`)},`notice`)),e.agent?.kind&&O.push((0,J.jsx)(Z,{label:s(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),S&&S.provides.length>0&&O.push((0,J.jsxs)(Z,{label:s(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:s(`plugins.provides`,{providers:S.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/providers`),children:s(`plugins.openProviders`)}),Object.entries(S.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[s(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(m,{size:`sm`,onClick:()=>_.mutate({spec:e.spec,provider:t},{onError:e=>l(F(e),`error`)}),children:s(`plugins.useFor`,{provider:t})})]},t)),S.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:s(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:C(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:C(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:E})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(a,{tone:me[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(a,{tone:`orange`,children:s(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[T&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveUp`),title:s(`plugins.moveUp`),disabled:!i,onClick:i,icon:(0,J.jsx)(L,{className:`size-3.5`})}),(0,J.jsx)(m,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveDown`),title:s(`plugins.moveDown`),disabled:!o,onClick:o,icon:(0,J.jsx)(te,{className:`size-3.5`})})]}),(0,J.jsx)(x,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>f.mutate({spec:e.spec,enabled:t},{onError:e=>l(F(e),`error`)})}),(0,J.jsx)(N,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(re,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(oe,{className:`size-3.5`}),onSelect:()=>b(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(z,{className:`size-3.5`}),onSelect:()=>p.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>l(F(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(ce,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void D()}]})]})]}),e.error&&(0,J.jsx)(v,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),S?.error&&(0,J.jsx)(v,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:S.error}),T?.error&&(0,J.jsx)(v,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:T.error})}),e.agent?.error&&(0,J.jsx)(v,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.agent.error`,{error:e.agent.error})}),O.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:O})]}),(0,J.jsx)(Q,{plugin:e,open:y,onOpenChange:b})]})}function Z({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function Q({plugin:e,open:t,onOpenChange:n}){let{t:r}=k(),{toast:i}=I(),a=d(),[o,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(c(JSON.stringify(e.options??e.optionsExample??{},null,2)),u(null))},[t,e.options,e.optionsExample]);let f=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(F(e),`error`)});return(0,J.jsxs)(P,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(m,{onClick:()=>f(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(m,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));f(e)}catch(e){u(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(s,{mono:!0,rows:14,value:o,invalid:!!l,onChange:e=>(c(e.target.value),u(null)),label:r(`plugins.options`)}),l&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:l})]})}function ve({open:e,onOpenChange:t,onJob:n}){let{t:r}=k(),{toast:i}=I(),a=p(),[o,s]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&s(``)},[e]),(0,J.jsxs)(P,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(m,{variant:`primary`,disabled:!o.trim()||a.isPending,onClick:()=>a.mutate({spec:o.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(F(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(h,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(l,{mono:!0,value:o,onChange:e=>s(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(v,{tone:`warning`,title:r(`plugins.trustTitle`),className:`mt-4`,children:r(`plugins.trustDetail`)})]})}function ye({open:e,onOpenChange:t,onJob:n}){let{t:r}=k(),{toast:i}=I(),o=j(e),s=E(),[c,l]=(0,q.useState)(!1),u=o.data;return(0,J.jsxs)(P,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:u?.path,width:560,footer:(0,J.jsx)(m,{variant:`primary`,disabled:!u?.found||s.isPending,onClick:()=>s.mutate(c,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(F(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[o.isLoading&&(0,J.jsx)(y,{lines:3}),u?.error&&(0,J.jsx)(v,{tone:`danger`,title:r(`common.error`),children:u.error}),u&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:u.plugins.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.spec}),e.off&&(0,J.jsx)(a,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(a,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(a,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),u.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(x,{checked:c,onChange:l,label:r(`plugins.magpie.signIns`,{count:u.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function be({id:e,onClose:t}){let{t:n}=k(),r=M(e).data;return(0,J.jsxs)(P,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(m,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(y,{lines:3}),r&&(0,J.jsx)(T,{language:`text`,children:r.log.length?r.log.join(`
2
+ `):`…`}),r?.state===`failed`&&r.error&&(0,J.jsx)(v,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:r.error})]})}function xe({installed:e,onJob:t}){let{t:n,locale:a}=k(),{toast:o,confirm:s}=I(),l=i(),u=p(),[d,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),[_,x]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>g(d.trim()),400);return()=>clearTimeout(e)},[d]);let S=b(h),C=(0,q.useMemo)(()=>new Set(e.map(e=>e.name)),[e]),w=(t,n)=>C.has(n)||e.some(e=>e.spec===t),T=async(e,r)=>{await s({title:n(`plugins.installConfirm`,{name:e}),detail:n(`plugins.trustDetail`),confirmLabel:n(`plugins.install`)})&&u.mutate({spec:e,source:r},{onSuccess:e=>t(e.id),onError:e=>o(F(e),`error`)})},[E,D]=W(),O=E.get(`install`),A=(0,q.useRef)(null);(0,q.useEffect)(()=>{O&&A.current!==O&&(A.current=O,D({},{replace:!0}),pe.test(O)?T(O,`market`):o(n(`plugins.linkInvalid`),`error`))},[O]);let j=(l.data??[]).filter(e=>_===`all`||e.kind===_),M=e=>(l.data??[]).filter(t=>e===`all`||t.kind===e).length,N=h.length>=2;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(r,{className:`min-w-[220px] flex-1`,value:d,onChange:m,placeholder:n(`plugins.searchPlaceholder`)}),!N&&(0,J.jsx)(c,{ariaLabel:n(`plugins.kindFilter`),value:_,onChange:x,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${n(e===`all`?`plugins.kind.all`:Y[e])} ${M(e)}`}))})]}),N?(0,J.jsxs)(J.Fragment,{children:[S.isLoading&&(0,J.jsx)(y,{lines:3}),S.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(f,{icon:(0,J.jsx)(R,{className:`size-6`}),title:n(`plugins.noResults`)})}),S.data&&S.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:S.data.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.spec,icon:(0,J.jsx)(X,{name:e.name,kind:e.kind}),detail:e.description??void 0,tags:[n(Y[e.kind]),e.source===`github`?`★ ${e.stars}`:e.version?`v${e.version}`:``,e.source===`astra`?n(`plugins.origin.astra`):``],installed:w(e.spec,e.name),onInstall:()=>void T(e.spec,e.source===`github`?`github`:e.source===`astra`?`market`:`npm`)},e.spec))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:n(`plugins.searchNote`)})]}):(0,J.jsxs)(J.Fragment,{children:[l.isLoading&&(0,J.jsx)(y,{lines:4}),l.isError&&(0,J.jsx)(v,{tone:`danger`,title:n(`common.error`),children:F(l.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:j.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.package,icon:(0,J.jsx)(X,{name:e.name,icon:e.icon,kind:e.kind}),detail:e.summary[a]??e.summary.en??e.description??void 0,tags:[n(Y[e.kind]),e.latest?`v${e.latest}`:``,e.origin===`astra`?n(`plugins.origin.astra`):``,e.minAstraVersion?n(`plugins.minVersion`,{version:e.minAstraVersion}):``].filter(Boolean),installed:w(e.package,e.package),onInstall:()=>void T(e.package,`market`)},e.package))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:n(`plugins.marketNote`)})]})]})}function $({title:e,subtitle:t,icon:n,detail:r,tags:i,installed:o,onInstall:s}){let{t:c}=k();return(0,J.jsxs)(`div`,{className:`card flex flex-col gap-3 p-4 transition-colors hover:border-[var(--border)]`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[n,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e,children:e}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:t,children:t})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 min-h-[2lh] text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:r??``}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-center gap-1.5`,children:[i.filter(Boolean).map(e=>(0,J.jsx)(a,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),o?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(ne,{className:`size-3.5`}),c(`plugins.installed`)]}):(0,J.jsx)(m,{size:`sm`,variant:`primary`,onClick:s,children:c(`plugins.install`)})]})]})}function Se({onJob:e}){let{t,locale:n}=k(),{toast:r}=I(),i=S(),o=_(),s=D(),c=i.data?.runtime;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:`Bun`}),c&&(0,J.jsx)(a,{tone:c.path?`green`:`neutral`,children:c.path?t(`plugins.bunReady`):t(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.bunDetail`)}),c&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c.path&&(0,J.jsx)(u,{label:t(`plugins.bunPath`),mono:!0,children:c.path}),c.version&&(0,J.jsx)(u,{label:t(`plugins.bunVersion`),mono:!0,children:c.version}),(0,J.jsx)(u,{label:t(`plugins.bunTarget`),mono:!0,children:c.target??t(`plugins.bunNoBuild`)})]}),c?.error&&(0,J.jsx)(v,{tone:`danger`,title:t(`plugins.bunFailed`),children:c.error}),c&&!c.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(m,{variant:`primary`,disabled:c.downloading||s.isPending||!c.target,onClick:()=>s.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>r(F(e),`error`)}),children:c.downloading?t(`plugins.bunDownloading`):t(`plugins.bunDownload`,{version:c.version??``})})})]}),(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:t(`plugins.host`)}),o.data&&(0,J.jsx)(a,{tone:o.data.running?`green`:`neutral`,children:o.data.running?t(`plugins.hostRunning`):t(`plugins.hostStopped`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.hostDetail`)}),o.data?.startError&&(0,J.jsx)(v,{tone:`danger`,title:t(`plugins.hostStartFailed`),children:o.data.startError}),o.data?.goneReason&&(0,J.jsx)(v,{tone:`warning`,title:t(`plugins.hostGone`),children:o.data.goneReason}),o.data&&o.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.data.plugins.map(e=>(0,J.jsx)(u,{label:e.spec,mono:!0,children:e.error?t(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),o.data?.recent&&o.data.recent.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-[var(--border-subtle)] pt-3`,children:[(0,J.jsx)(`h4`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:t(`plugins.hostRecent`)}),o.data.recent.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(a,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:O(e.at,n)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.title&&(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.title,` `]}),e.message]})]},t))]})]}),(0,J.jsxs)(`a`,{className:`flex items-center gap-1 px-1 text-[12px] text-[var(--text-muted)] hover:text-[var(--accent)] lg:col-span-2`,href:`https://github.com/astragate-community/astra-gate-plugins`,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(ie,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{he as PluginsPage};