@aidotnet/server-win32-arm64 0.14.3115 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/astra-server.exe +2 -2
- package/bin/wwwroot/assets/ClientsPage-_mSieiAF.js +11 -0
- package/bin/wwwroot/assets/KeyPage-DiCg0cvq.js +1 -0
- package/bin/wwwroot/assets/LibraryPage-Bi3eZBB3.js +2 -0
- package/bin/wwwroot/assets/McpPage-BJR1f5Yx.js +9 -0
- package/bin/wwwroot/assets/{ModelDetailPage-CRE3OFy5.js → ModelDetailPage-Blo8NpJB.js} +1 -1
- package/bin/wwwroot/assets/ModelsPage-CIPcz7uV.js +1 -0
- package/bin/wwwroot/assets/PluginsPage-Yk-F5aRL.js +2 -0
- package/bin/wwwroot/assets/PrivacyPage-5dgIl6jr.js +1 -0
- package/bin/wwwroot/assets/ProviderDetailPage-B6OTl3-U.js +3 -0
- package/bin/wwwroot/assets/ProvidersPage-Bq5OYlNx.js +3 -0
- package/bin/wwwroot/assets/RoutingGroupsPage-QhcSLWAs.js +3 -0
- package/bin/wwwroot/assets/SettingsPage-r0rejbMz.js +2 -0
- package/bin/wwwroot/assets/SkillsPage-CsmhaTU2.js +1 -0
- package/bin/wwwroot/assets/SmartRoutingPage-Db9T-e2A.js +2 -0
- package/bin/wwwroot/assets/TokenDetailPage-CcQECuzQ.js +1 -0
- package/bin/wwwroot/assets/{TokenPoolEditor-IS5Zwuqf.js → TokenPoolEditor-CGcyJlwx.js} +1 -1
- package/bin/wwwroot/assets/TokensPage-DMGwsYfH.js +1 -0
- package/bin/wwwroot/assets/ToolsPage-DOqVTZRE.js +1 -0
- package/bin/wwwroot/assets/{TracesPage-CgbFQFzA.js → TracesPage-D_2hw0_f.js} +3 -3
- package/bin/wwwroot/assets/{TrayPanelPage-Z4vWiyK-.js → TrayPanelPage-D6p9Iy8x.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-Cauh6r_o.js → TrayPanelView-DMtlmIFa.js} +1 -1
- package/bin/wwwroot/assets/TrayTitleSource-Byl3s-2T.js +41 -0
- package/bin/wwwroot/assets/{checkbox-29lSW_6h.js → checkbox-ux8EsZSf.js} +1 -1
- package/bin/wwwroot/assets/{confirm-morph-DpNjlFyg.js → confirm-morph-OQsP-uPd.js} +1 -1
- package/bin/wwwroot/assets/{format-CskGUFYy.js → format-BulNVEXk.js} +3 -3
- package/bin/wwwroot/assets/index-CnDnJaC3.js +124 -0
- package/bin/wwwroot/assets/{radio-cards-CNQWIuu8.js → radio-cards-BWCITGoJ.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-BvMId5KB.js → sortable.esm-DMdB93hD.js} +1 -1
- package/bin/wwwroot/assets/{use-transform-BPiFWEVF.js → use-transform-ZS0KHlh3.js} +1 -1
- package/bin/wwwroot/index.html +4 -4
- package/package.json +1 -1
- package/bin/wwwroot/assets/ClientsPage-BhnTX0ew.js +0 -11
- package/bin/wwwroot/assets/KeyPage-D8xcW85A.js +0 -1
- package/bin/wwwroot/assets/LibraryPage-BO51S5vR.js +0 -2
- package/bin/wwwroot/assets/McpPage-BFav-GE-.js +0 -9
- package/bin/wwwroot/assets/ModelsPage-BsRk0_yk.js +0 -1
- package/bin/wwwroot/assets/PluginsPage-blIrwXbf.js +0 -2
- package/bin/wwwroot/assets/PrivacyPage-bKxw2Y54.js +0 -1
- package/bin/wwwroot/assets/ProviderDetailPage-3YGtfo9v.js +0 -3
- package/bin/wwwroot/assets/ProvidersPage-B0XULeAs.js +0 -3
- package/bin/wwwroot/assets/RoutingGroupsPage-Dz-TTq1a.js +0 -3
- package/bin/wwwroot/assets/SettingsPage-CFVirZNv.js +0 -2
- package/bin/wwwroot/assets/SkillsPage-DI61DG2m.js +0 -1
- package/bin/wwwroot/assets/SmartRoutingPage-CpchDlXC.js +0 -2
- package/bin/wwwroot/assets/TokenDetailPage-PqVFcudk.js +0 -1
- package/bin/wwwroot/assets/TokensPage-CXK5_J6v.js +0 -1
- package/bin/wwwroot/assets/ToolsPage-B_JZpB1h.js +0 -1
- package/bin/wwwroot/assets/TrayTitleSource-B98nYas3.js +0 -41
- package/bin/wwwroot/assets/index-D2siu6xk.js +0 -124
package/bin/astra-server.exe
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bin/astra-server.exe
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 85750784 bytes
|
|
4
|
+
sha256: 83ea070362bb8351523ac175feb911db22d6a9859ffb339f91cfa7114baebc4f
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$a as n,$n as r,$s as i,$t as a,B as o,C as s,Ea as c,F as l,G as u,Hi as d,I as f,Ko as p,Kt as m,L as h,Mi as g,N as _,O as v,P as y,Qt as b,T as x,U as S,V as C,W as w,Wn as T,_i as E,da as D,dn as O,ec as k,ei as A,en as ee,f as j,fi as te,fn as ne,ft as M,in as re,jn as ie,k as N,li as ae,ln as P,o as F,pa as I,qn as oe,r as se,rn as ce,s as L,sa as le,ta as ue,ua as de,ui as fe,vo as R,wt as z}from"./format-BulNVEXk.js";import{B as pe,H as B,L as me,R as V,U as H,V as U,W}from"./TrayTitleSource-Byl3s-2T.js";import{t as he}from"./archive-CiVf7slo.js";import{t as G}from"./check-DKfsh0bQ.js";import{t as ge}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-DMdB93hD.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-CnDnJaC3.js";import{n as Qe}from"./ProvidersPage-Bq5OYlNx.js";var X=e(t(),1),Z=k(),$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}=x(),{toast:r}=W(),i=Ke(),a=ce(e),c=le(),[l,d]=(0,X.useState)(null),p=a.data?.mode??`gateway`,m=a.data?.accounts??[],h=a.data?.accountId??null??m.find(tt)?.id??null,g=m.find(e=>e.id===h),_=p===`direct`,v=t&&(_||a.data!=null),b=_&&g?.telemetryEnabled===!0,C=re(b?g?.id:null,b),T=c.isPending,E=e=>c.mutate(e,{onError:e=>r(H(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(f,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(o,{label:n(`clients.claudeDirect.mode`),detail:n(_?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(S,{ariaLabel:n(`clients.claudeDirect.mode`),value:p,onChange:e=>{if(e===p||T||!a.data)return;let t=h??m.find(tt)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}E({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)(s,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:H(a.error)})}),v&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(s,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),a.data&&(0,Z.jsx)(f,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:m.length===0?(0,Z.jsx)(y,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(N,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(o,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(U,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:h,onChange:e=>{T||e===h||E({mode:p,accountId:e})},options:m.map(e=>({value:e.id,label:nt(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!tt(e)}))})})}),a.data&&_&&g&&(0,Z.jsx)(f,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(it,{command:$e,copied:l,onCopy:async e=>{await V.copy(e)&&(d(e),r(n(`common.copied`)))}})}),a.data&&_&&g&&(0,Z.jsxs)(f,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(o,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(u,{label:n(`clients.claudeDirect.statsConsent`),checked:g.telemetryEnabled,disabled:T,onChange:e=>{g&&!T&&E({mode:p,accountId:g.id,telemetryEnabled:e})}})}),b&&(0,Z.jsx)(at,{requests:C})]})]})}function it({command:e,copied:t,onCopy:n}){let{t:r}=x();return(0,Z.jsx)(o,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(N,{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}=x(),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)(s,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:H(e.error)})}):r.length===0?(0,Z.jsx)(y,{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)(o,{label:t(`clients.claudeDirect.statsTotals`,{count:j(i.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:j(i.totalInputTokens),cache:j(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:j(i.outputTokens)})}),(0,Z.jsx)(o,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:L(r.some(e=>e.estimatedCostNanoUsd!=null)?i.estimatedCostNanoUsd:null)})}),i.failed>0&&(0,Z.jsx)(o,{label:t(`clients.claudeDirect.statsFailedCount`,{count:j(i.failed)}),children:(0,Z.jsx)(v,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(o,{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)(v,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(v,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[se(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:j(e.inputTokens),output:j(e.outputTokens)}),e.durationMs==null?null:F(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:L(e.estimatedCostNanoUsd)})},e.id))]})}function ot(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 st=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
|
|
2
|
+
`);function ct(e){return e>=1e6&&e%1e6==0?`${e/1e6}M`:e>=1e3&&e%1e3==0?`${e/1e3}K`:e.toLocaleString(`en-US`)}function lt(e,t,n){let r=[];for(let t of e.choices??[]){let e=Number.parseInt(t,10);Number.isFinite(e)&&e>0&&!r.includes(e)&&r.push(e)}return typeof t==`number`&&t>0&&!r.includes(t)&&(r.push(t),r.sort((e,t)=>e-t)),[{value:``,label:n},...r.map(e=>({value:String(e),label:ct(e)}))]}function ut({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=x(),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)(f,{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`),s=t[e.key];return(0,Z.jsxs)(o,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(u,{label:n,checked:s===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(e.choices?.length?(0,Z.jsx)(U,{ariaLabel:n,value:typeof s==`number`?String(s):``,onChange:t=>{let n=Number.parseInt(t,10);a(e.key,Number.isFinite(n)&&n>0?n:void 0)},options:lt(e,typeof s==`number`?s:void 0,i(`clients.options.unset`)),className:`w-44`}):(0,Z.jsx)(h,{className:`w-44`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof s==`number`?String(s):``,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)(U,{ariaLabel:n,value:typeof s==`string`?s:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-44`})]},e.key)})})}var dt=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],ft=e=>typeof e==`string`&&dt.includes(e);function pt(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))ft(r)&&(n[e]=r);return n}function mt(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(ft):[]})}return n}function ht(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var gt=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
|
|
3
|
+
`),_t=`auto`,vt=e=>Qe.find(t=>t.value===e)?.label??e;function yt({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=x(),s=(e,t)=>{let i={...n};t===_t?delete i[e]:i[e]=t,r(i)};return(0,Z.jsx)(f,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=ht(e,t),i=e.native.filter(e=>t.includes(e));return(0,Z.jsx)(o,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(vt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Z.jsx)(U,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:_t,onChange:t=>s(e.id,t),options:[{value:_t,label:a(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:vt(r.protocol)})},...t.map(e=>({value:e,label:vt(e)}))]})},e.id)})})}function bt(e){let t=e?.modelShortlist;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function xt({client:e}){let{t}=x(),{toast:n}=W(),r=O(e.kind,!0,!0),i=I(),a=bt(e.extras),s=a.join(`
|
|
4
|
+
`),[c,l]=(0,X.useState)(a),[d,p]=(0,X.useState)(``);(0,X.useEffect)(()=>l(bt(e.extras)),[e.kind,s]);let m=(0,X.useMemo)(()=>r.data??[],[r.data]),h=(0,X.useMemo)(()=>[...m,...c.filter(e=>!m.includes(e))],[m,c]),g=h.filter(e=>e.toLowerCase().includes(d.trim().toLowerCase())),_=c.join(`
|
|
5
|
+
`)!==s,v=(e,t)=>l(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(H(e),`error`)});return(0,Z.jsxs)(f,{title:t(`clients.shortlist.title`),footer:e.enabled?t(`clients.shortlist.footerEnabled`):t(`clients.shortlist.footer`),children:[(0,Z.jsxs)(o,{label:c.length===0?t(`clients.shortlist.empty`):t(`clients.shortlist.summary`,{count:c.length,total:h.length}),children:[c.length>0&&(0,Z.jsx)(N,{size:`sm`,onClick:()=>l([]),children:t(`clients.shortlist.clear`)}),_&&(0,Z.jsx)(N,{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})}),h.length>8&&(0,Z.jsx)(`div`,{className:`px-4 py-2`,children:(0,Z.jsx)(C,{value:d,onChange:p,placeholder:t(`clients.shortlist.filter`)})}),(0,Z.jsx)(`div`,{className:`max-h-[320px] overflow-y-auto`,children:g.map(e=>(0,Z.jsx)(o,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e}),detail:m.includes(e)?void 0:t(`clients.shortlist.missing`),children:(0,Z.jsx)(u,{checked:c.includes(e),onChange:t=>v(e,t),label:e})},e))})]})}var St={enable:`green`,update:`accent`,disable:`orange`,store:`neutral`,unchanged:`neutral`,skipped:`orange`,failed:`red`};function Ct(){let{t:e}=x(),{toast:t,confirm:n}=W(),r=fe(),i=ue(),a=R(),o=ie(),s=r.data??[],c=s.find(e=>e.active),[u,d]=(0,X.useState)(``),f=s.find(e=>e.id===u)??c??s[0],[p,m]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),y=()=>{if(!p)return;let n=p.name.trim();if(!n)return;let r=n=>{m(null),d(n.id),t(e(`profiles.saved`,{name:n.name}),`success`)};p.id===null?i.mutate(n,{onSuccess:r,onError:e=>t(H(e),`error`)}):a.mutate({id:p.id,name:n},{onSuccess:r,onError:e=>t(H(e),`error`)})},b=async r=>{await n({title:e(`profiles.overwriteConfirm`,{name:r.name}),confirmLabel:e(`profiles.overwrite`)})&&a.mutate({id:r.id,overwrite:!0},{onSuccess:()=>t(e(`profiles.saved`,{name:r.name}),`success`),onError:e=>t(H(e),`error`)})},S=async r=>{await n({title:e(`profiles.deleteConfirm`,{name:r.name}),confirmLabel:e(`profiles.delete`),destructive:!0})&&o.mutate(r.id,{onSuccess:()=>d(``),onError:e=>t(H(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`)}),s.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)(U,{className:`w-[220px]`,ariaLabel:e(`profiles.pick`),value:f?.id??``,onChange:d,options:s.map(t=>({value:t.id,label:t.name,detail:e(`profiles.clientCount`,{count:t.clients.length})}))}),f?.active&&!f.drifted&&(0,Z.jsx)(v,{tone:`green`,children:e(`profiles.active`)}),f?.active&&f.drifted&&(0,Z.jsxs)(v,{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:[f&&(0,Z.jsx)(N,{variant:`primary`,size:`sm`,onClick:()=>_(f.id),children:e(`profiles.apply`)}),(0,Z.jsx)(N,{size:`sm`,onClick:()=>m({id:null,name:``}),children:e(`profiles.save`)}),f&&(0,Z.jsx)(pe,{label:e(`profiles.title`),icon:(0,Z.jsx)(K,{className:`size-4`}),iconOnly:!0,items:[{id:`overwrite`,label:e(`profiles.overwrite`),onSelect:()=>void b(f)},{id:`rename`,label:e(`profiles.rename`),onSelect:()=>m({id:f.id,name:f.name})},{id:`delete`,label:e(`profiles.delete`),destructive:!0,separatorBefore:!0,onSelect:()=>void S(f)}]})]}),(0,Z.jsx)(B,{open:p!==null,onOpenChange:e=>!e&&m(null),width:420,title:p?.id===null?e(`profiles.saveTitle`):e(`profiles.rename`),description:p?.id===null?e(`profiles.subtitle`):void 0,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(N,{onClick:()=>m(null),children:e(`common.cancel`)}),(0,Z.jsx)(N,{variant:`primary`,disabled:!p?.name.trim(),loading:i.isPending||a.isPending,onClick:y,children:e(`common.save`)})]}),children:(0,Z.jsx)(l,{label:e(`profiles.name`),children:(0,Z.jsx)(h,{autoFocus:!0,maxLength:64,value:p?.name??``,onChange:e=>m(t=>t&&{...t,name:e.target.value}),onKeyDown:e=>e.key===`Enter`&&y()})})}),(0,Z.jsx)(Et,{profile:s.find(e=>e.id===g)??null,onClose:()=>_(null)})]})}function wt(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 Tt(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 Et({profile:e,onClose:t}){let{t:n}=x(),{toast:r}=W(),i=ae(e?.id,e!==null),a=m(),c=(i.data?.steps??[]).filter(e=>e.action!==`unchanged`);return(0,Z.jsxs)(B,{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)(N,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(N,{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(H(e),`error`)})},children:n(`profiles.apply`)})]}),children:[i.isPending&&(0,Z.jsx)(w,{lines:4}),i.isError&&(0,Z.jsx)(s,{tone:`danger`,title:n(`common.error`),children:H(i.error)}),i.data&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c.length===0&&(0,Z.jsx)(s,{tone:`info`,title:n(`profiles.nothing`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:c.map(e=>(0,Z.jsx)(o,{label:e.name,detail:wt(e,n)||void 0,children:(0,Z.jsx)(v,{tone:St[e.action],children:n(`profiles.action.${e.action}`)})},e.kind))}),i.data.dropped.length>0&&(0,Z.jsx)(s,{tone:`warning`,title:n(`profiles.dropped`),children:i.data.dropped.map((e,t)=>(0,Z.jsx)(`span`,{className:`block break-all`,children:Tt(e,n)},t))})]})]})}function Dt(e,t){if(!(e instanceof p)||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}var Ot=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`CLAUDE_CODE_SUBAGENT_MODEL`];function kt(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of Ot){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var At=e=>Ot.map(t=>e[t]??``).join(`
|
|
6
|
+
`),Q=[`sonnet`,`opus`,`haiku`];function jt(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
|
+
`),Mt=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function Nt(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!Mt.test(e))??e[0],r=e.find(e=>Mt.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function Pt(){let{t:e}=x(),t=Ke(),{toast:n}=W(),r=We(),i=ne(),a=ee(),o=(0,X.useMemo)(()=>new Map((i.data??[]).map(e=>[e.kind,e])),[i.data]),c=It(i.data).includes(r.kind)?r.kind:`codex`,l=o.get(c);return(0,X.useEffect)(()=>a.mutate(!1),[]),(0,Z.jsx)(Ye,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Z.jsx)(N,{icon:(0,Z.jsx)(Ee,{className:`size-3.5`}),loading:a.isPending,onClick:()=>a.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(H(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Z.jsxs)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:[(0,Z.jsx)(Ct,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Z.jsx)(Vt,{clients:i.data,loading:i.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:[i.isLoading&&(0,Z.jsx)(w,{lines:4}),i.isError&&(0,Z.jsx)(s,{tone:`danger`,title:e(`common.error`),children:H(i.error)}),l&&(0,Z.jsx)(Gt,{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 Ft=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.antigravity.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 It(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 Lt=[`installed`,`notInstalled`,`comingSoon`],Rt=new Set([`notInstalled`]);function zt(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function Bt(e){return e.install?.version??e.detection.version??null}function Vt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=x(),[a,o]=(0,X.useState)(new Set),s=new Map((e??[]).map(e=>[e.kind,e])),c=Lt.map(t=>({group:t,items:It(e).flatMap(e=>{let n=s.get(e);return n&&zt(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=Rt.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)(ge,{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)(Ht,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e)})})]})}function Ht({client:e,active:t,onSelect:n}){let{t:r}=x(),i=zt(e)!==`installed`,a=Bt(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)(Ut,{}),s&&!e.install?.busy&&(0,Z.jsx)(v,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Z.jsx)(v,{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)(_,{tone:`orange`})}):e.enabled?(0,Z.jsx)(G,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function Ut(){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 Wt(e,t){return e.availability===`coming_soon`?(0,Z.jsx)(v,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Z.jsx)(v,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Z.jsx)(v,{tone:`green`,children:t(`clients.enabled`)}):(0,Z.jsx)(v,{children:t(`clients.disabled`)})}function Gt({client:e}){let{t,locale:i}=x(),a=Ke(),{toast:c,confirm:l}=W(),u=E(),d=de(),p=T(),m=r(),h=g(),_=n(),y=O(e.kind,!!e.providerId),[b,S]=(0,X.useState)(e.selectedModel??null),[C,D]=(0,X.useState)(e.accountId??``),k=e.tokenId??`default`,[A,ee]=(0,X.useState)(k),j=(_.data??[]).filter(e=>e.enabled||e.id===k).map(e=>({value:e.id,label:e.enabled?e.name:t(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[ne,M]=(0,X.useState)(!1),[re,ie]=(0,X.useState)(!1),[ae,P]=(0,X.useState)(null),F=e.availability===`coming_soon`,I=Y(e.kind,e.name),oe=(u.data??[]).filter(e=>e.enabled),L=e.detection.configPaths[0],le=oe.find(t=>t.id===e.providerId),ue=le?.authScheme===`oauth-subscription`||le?.authScheme===`plugin`,fe=te(le?.id,ue),R=e.kind===`claude-desktop`,z=e.kind===`claude-code`,pe=ce(z),B=z&&pe.data?.mode===`direct`,G=jt(e.extras),[ge,_e]=(0,X.useState)(G),K=Q.some(e=>ge[e]),ye=$(ge)!==$(G),xe=kt(e.extras),[Ce,we]=(0,X.useState)(xe),Te=(b??null)!==(e.selectedModel??null)||At(Ce)!==At(xe),Ee=z?Ot.filter(e=>e!==`ANTHROPIC_MODEL`):[],De=z?e.enabled?t(`clients.modelSlotsFooterEnabled`):t(`clients.modelSlotsFooter`):e.enabled?t(`clients.modelFooterEnabled`):t(`clients.modelFooter`),q=e.options??[],J=ot(e.extras,q),[Oe,ke]=(0,X.useState)(J),Ae=st(Oe)!==st(J),je=e.protocols??[],Me=je.length>1?mt(e.extras):[],Ne=pt(e.extras),[Pe,Fe]=(0,X.useState)(Ne),Ie=gt(Pe)!==gt(Ne),Le=R?{...e.extras,roleMap:ge}:z?{...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)(()=>S(e.selectedModel??null),[e.kind,e.selectedModel]),(0,X.useEffect)(()=>D(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,X.useEffect)(()=>ee(k),[e.kind,k]),(0,X.useEffect)(()=>_e(jt(e.extras)),[e.kind,$(G)]);let Re=(0,X.useRef)({});(0,X.useEffect)(()=>{if(!R||e.enabled||Q.some(e=>G[e]))return;let t=Re.current,n=Nt(y.data??[]);Re.current=n,_e(e=>(!Q.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(G),(y.data??[]).join(`
|
|
8
|
+
`)]),(0,X.useEffect)(()=>we(kt(e.extras)),[e.kind,At(xe)]),(0,X.useEffect)(()=>ke(ot(e.extras,e.options)),[e.kind,st(J)]),(0,X.useEffect)(()=>Fe(pt(e.extras)),[e.kind,gt(Ne)]);let ze=()=>{e.providerId&&d.mutate({kind:e.kind,providerId:e.providerId,accountId:C},{onSuccess:()=>c(t(`common.saved`),`success`),onError:e=>c(H(e),`error`)})},Be=async()=>{await l({title:t(`clients.disableConfirm`,{name:I}),detail:t(`clients.disableDetail`),confirmLabel:t(`clients.disable`)})&&p.mutate(e.kind,{onSuccess:async n=>{if(n.drifted.length===0){c(t(`clients.disabledToast`,{name:I}),`success`);return}await l({title:t(`clients.driftTitle`),detail:t(`clients.driftDetail`,{keys:n.drifted.join(`, `)}),confirmLabel:t(`clients.forceRestore`),destructive:!0})&&m.mutate(e.kind,{onSuccess:()=>c(t(`clients.disabledToast`,{name:I}),`success`),onError:e=>c(H(e),`error`)})},onError:e=>c(H(e),`error`)})},Ve=async()=>{L&&(V.canOpenPaths?await V.openPath(me(L)):await V.copy(L)&&c(t(`common.copied`)))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(f,{children:[(0,Z.jsxs)(o,{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:I}),B?(0,Z.jsx)(v,{children:t(`clients.claudeDirect.direct`)}):Wt(e,t)]}),detail:F?e.availabilityReason??t(`clients.comingSoonDetail`):[zt(e)===`installed`?t(`clients.detected`,{version:Bt(e)??``}):t(`clients.notDetected`),B?null:L].filter(Boolean).join(` · `),className:`py-3`,children:[!F&&(0,Z.jsx)(Zt,{client:e,onOpen:P}),B?(0,Z.jsx)(N,{variant:`primary`,onClick:()=>document.getElementById($t)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.claudeDirect.configure`)}):e.enabled?(0,Z.jsx)(N,{onClick:()=>void Be(),loading:p.isPending,children:t(`clients.disableRestore`)}):(0,Z.jsx)(N,{variant:`primary`,disabled:F||!e.providerId||R&&!K,onClick:()=>M(!0),title:e.providerId?R&&!K?t(`clients.roleMapRequired`):void 0:t(`clients.pickProviderFirst`),children:t(`clients.enable`)})]}),!B&&e.appliedAt&&(0,Z.jsx)(o,{label:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`clients.appliedAt`,{time:se(e.appliedAt,i)})})})]}),!F&&!e.enabled&&R&&e.providerId&&!K&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsx)(s,{tone:`info`,className:`self-stretch`,title:t(`clients.roleMapHint`)}),(0,Z.jsx)(N,{onClick:()=>document.getElementById(en)?.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)(s,{tone:`danger`,className:`self-stretch`,title:t(`clients.repair.title`,{name:I}),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)(N,{variant:`primary`,loading:h.isPending,onClick:()=>h.mutate(e.kind,{onSuccess:()=>c(t(`clients.repair.done`,{name:I}),`success`),onError:e=>c(H(e),`error`)}),children:t(`clients.repair.action`)})]}),!B&&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)(s,{tone:`warning`,title:e},t))}),!B&&(0,Z.jsx)(Yt,{client:e,providers:u.data??[],loading:u.isLoading,soon:F}),!B&&ue&&(0,Z.jsx)(f,{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)(o,{label:t(`clients.account`),children:[(0,Z.jsx)(U,{className:`max-w-[300px]`,ariaLabel:t(`clients.account`),value:C,onChange:D,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}`)}`)}))]}),C!==(e.accountId??``)&&(0,Z.jsx)(N,{size:`sm`,variant:`primary`,loading:d.isPending,onClick:ze,children:t(`common.apply`)})]})}),!F&&!B&&(0,Z.jsxs)(f,{title:t(`clients.tokenTitle`),footer:e.enabled?t(`clients.tokenFooterEnabled`):t(`clients.tokenFooter`),children:[(0,Z.jsxs)(o,{label:t(`clients.token`),children:[(0,Z.jsx)(U,{className:`max-w-[300px]`,ariaLabel:t(`clients.token`),value:A,onChange:ee,options:j}),e.enabled&&A!==k&&(0,Z.jsx)(N,{size:`sm`,variant:`primary`,onClick:()=>M(!0),children:t(`common.apply`)})]}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(Se,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.manageTokens`),onClick:()=>a(`/tokens`)})]}),!F&&!B&&e.providerId&&R&&(0,Z.jsx)(`div`,{id:en,children:(0,Z.jsxs)(f,{title:t(`clients.roleMapTitle`),footer:e.enabled?t(`clients.roleMapFooterEnabled`):t(`clients.roleMapFooter`),children:[Q.map(e=>(0,Z.jsx)(o,{label:t(`clients.role.${e}`),children:(0,Z.jsx)(U,{ariaLabel:t(`clients.role.${e}`),value:ge[e]??``,onChange:t=>_e(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(y.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&ye&&(0,Z.jsx)(o,{label:K?``:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:t(`clients.roleMapRequired`)}),children:(0,Z.jsx)(N,{size:`sm`,variant:`primary`,disabled:!K,onClick:()=>M(!0),children:t(`common.apply`)})})]})}),!F&&!B&&e.providerId&&!R&&(0,Z.jsxs)(f,{title:t(`clients.modelTitle`),footer:De,children:[(0,Z.jsx)(o,{label:t(`clients.defaultModel`),children:(0,Z.jsx)(U,{value:b??``,onChange:e=>S(e||null),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(y.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),Ee.map(e=>(0,Z.jsx)(o,{label:t(`clients.modelSlot.${e}`),children:(0,Z.jsx)(U,{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`)},...(y.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&(z?Te:(b??null)!==(e.selectedModel??null))&&(0,Z.jsx)(o,{label:``,children:(0,Z.jsx)(N,{size:`sm`,variant:`primary`,onClick:()=>M(!0),children:t(`common.apply`)})})]}),!F&&!B&&e.providerId&&!R&&(0,Z.jsx)(xt,{client:e}),!F&&!B&&q.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ut,{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)(N,{size:`sm`,variant:`primary`,onClick:()=>M(!0),children:t(`common.apply`)})})]}),!F&&Me.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yt,{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)(N,{size:`sm`,variant:`primary`,onClick:()=>M(!0),children:t(`common.apply`)})})]}),!F&&e.install&&(0,Z.jsx)(nn,{client:e,onShowLog:()=>P(`log`),onUninstall:()=>P(`uninstall`)}),z&&(0,Z.jsx)(`div`,{id:$t,children:(0,Z.jsx)(rt,{enabled:z,gatewayEnabled:e.enabled})}),!F&&!B&&(0,Z.jsxs)(f,{title:t(`clients.maintenance`),children:[L&&(0,Z.jsx)(o,{icon:V.canOpenPaths?(0,Z.jsx)(be,{className:`size-4 text-[var(--text-secondary)]`}):(0,Z.jsx)(ve,{className:`size-4 text-[var(--text-secondary)]`}),label:V.canOpenPaths?t(`clients.openConfigDir`):t(`clients.copyConfigPath`),detail:L,onClick:()=>void Ve()}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(he,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.backups`),detail:t(`clients.backupsDetail`),onClick:()=>ie(!0)})]}),(0,Z.jsx)(an,{open:ne,onOpenChange:M,client:e,model:b,extras:Le,tokenId:A}),(0,Z.jsx)(cn,{open:re,onOpenChange:ie,client:e}),(0,Z.jsx)(rn,{mode:ae,onClose:()=>P(null),client:e})]})}var Kt={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},qt={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Jt(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function Yt({client:e,providers:t,loading:n,soon:r}){let{t:i}=x(),{toast:a}=W(),s=D(),c=(0,X.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[l,u]=(0,X.useState)(c);(0,X.useEffect)(()=>u(c),[c]);let d=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),p=l.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),m=t.filter(e=>e.enabled&&!l.some(t=>t.providerId===e.id)),h=Me(Ve(je,{activationConstraint:{distance:4}}),Ve(ze,{coordinateGetter:Re})),g=r||s.isPending,_=(t,n)=>{let r=l;u(t),s.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(Ft.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:Y(e.kind,e.name)}):n),onError:e=>{u(r),a(H(e),`error`)}})},v=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=l.findIndex(t=>t.providerId===e.id),r=l.findIndex(e=>e.providerId===t.id);n<0||r<0||_(Ie(l,n,r),i(`clients.providerOrderSaved`))},b=e=>_([...l,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),S=e=>_(l.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),C=m.map(e=>(0,Z.jsx)(o,{icon:(0,Z.jsx)(Xe,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Jt(e,i),onClick:g?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)(f,{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&&p.length===0&&m.length===0&&(0,Z.jsx)(y,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Z.jsx)(Ge,{to:`/providers?new=1`,children:(0,Z.jsx)(N,{variant:`primary`,icon:(0,Z.jsx)(Te,{className:`size-3.5`}),children:i(`providers.add`)})})}),p.length>0&&(0,Z.jsx)(Le,{sensors:h,collisionDetection:Fe,onDragEnd:v,children:(0,Z.jsx)(Be,{items:p.map(e=>e.provider.id),strategy:Ae,children:p.map(({provider:e},t)=>(0,Z.jsx)(Xt,{provider:e,primary:t===0,disabled:g,onRemove:p.length>1?()=>S(e):void 0},e.id))})}),!n&&p.length===0&&C]}),p.length>0&&m.length>0&&(0,Z.jsx)(f,{title:i(`clients.moreProvidersTitle`),children:C})]})}function Xt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=x(),{attributes:a,listeners:s,setNodeRef:c,setActivatorNodeRef:l,transform:u,transition:d,isDragging:f}=Pe({id:e.id,disabled:n});return(0,Z.jsx)(`div`,{ref:c,style:{transform:Ne.Transform.toString(u),transition:d},className:M(f&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Z.jsx)(o,{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,...s,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)(v,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Z.jsx)(v,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Jt(e,i),children:r&&(0,Z.jsx)(N,{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 Zt({client:e,onOpen:t}){let{t:n}=x(),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)(N,{icon:(0,Z.jsx)(Ut,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Z.jsxs)(N,{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)(N,{icon:(0,Z.jsx)(J,{className:`size-3.5`}),onClick:()=>document.getElementById(Qt)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Z.jsxs)(N,{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)(N,{icon:(0,Z.jsx)(ye,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var Qt=`client-shadowed-alert`,$t=`claude-direct-panel`,en=`client-role-map`;function tn(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 nn({client:e,onShowLog:t,onUninstall:n}){let{t:r,locale:i}=x(),a=e.install,c=P(e.kind),l=(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??[],p=d.find(e=>e.newer);return(0,Z.jsxs)(Z.Fragment,{children:[p&&(0,Z.jsx)(`div`,{id:Qt,className:`mb-3`,children:(0,Z.jsx)(s,{tone:`warning`,title:r(`clients.shadowed.title`,{version:p.version}),children:r(`clients.shadowed.detail`,{path:a.executable??``,version:a.version??``,other:p.path,dir:me(p.path)})})}),!p&&a.notOnPath&&a.executable&&(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(s,{tone:`warning`,title:r(`clients.notOnPath.title`),children:r(`clients.notOnPath.detail`,{dir:me(a.executable)})})}),(0,Z.jsxs)(f,{title:r(`clients.versionTitle`),footer:u,children:[(0,Z.jsx)(o,{label:r(`clients.currentVersion`),detail:a.installed?a.executable:void 0,children:a.installed?l(a.version??r(`clients.versionUnknown`),!a.version):l(r(`clients.notInstalled`),!0)}),d.map(e=>(0,Z.jsxs)(o,{label:r(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Z.jsx)(v,{tone:`orange`,children:r(`clients.otherCopyNewer`)}),l(e.version,!e.newer)]},e.path)),(a.method===`npm`||a.method===`script`)&&(0,Z.jsxs)(o,{label:r(`clients.latestVersion`),detail:a.latestError??(a.latestCheckedAt?r(`clients.checkedAt`,{time:se(a.latestCheckedAt,i)}):void 0),children:[a.updateAvailable&&(0,Z.jsx)(v,{tone:`orange`,children:r(`clients.updateBadge`)}),l(a.latestVersion??r(`clients.latestUnknown`),!a.latestVersion)]}),(0,Z.jsx)(o,{label:r(`clients.installMethod`),detail:r(`clients.method.${a.method}`,{package:a.package??``}),children:(0,Z.jsx)(N,{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)(o,{label:r(`clients.uninstall`),detail:a.uninstallCommand??tn(a,r),children:a.uninstallCommand&&(0,Z.jsx)(N,{size:`sm`,variant:`destructive`,icon:(0,Z.jsx)(Oe,{className:`size-3`}),disabled:a.busy,onClick:n,children:r(`clients.uninstall`)})}),c.data&&(0,Z.jsx)(o,{icon:(0,Z.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.installLog`),detail:`${c.data.command} · ${r(`clients.job.${c.data.state}`)}`,onClick:t})]})]})}function rn({mode:e,onClose:t,client:n}){let{t:r}=x(),{toast:o}=W(),l=i(),u=e!==null,d=P(n.kind,u||!!n.install?.busy),f=c(),p=a(),[m,h]=(0,X.useState)(!1),g=(0,X.useRef)(null),_=(0,X.useRef)(void 0),v=Y(n.kind,n.name),b=n.install,S=e===`log`?null:e,C=S===`install`?b?.installCommand:S===`update`?b?.updateCommand:S===`uninstall`?b?.uninstallCommand:null,T=S===`uninstall`,E=d.data,D=S!==null&&!m&&E?.state!==`running`,O=!!b?.needsAdmin,k=!!b?.adminAvailable,A=E?.state===`failed`&&E.hint===`permission-denied`&&!E.elevated&&k;(0,X.useEffect)(()=>{u&&h(!1)},[u,e]),(0,X.useEffect)(()=>{let e=E?.state;_.current===`running`&&e&&e!==`running`&&(l.invalidateQueries({queryKey:z.clients}),e===`succeeded`&&E.hint?o(r(`clients.notEffectiveToast`,{name:v})):e===`succeeded`&&o(r(qt[E.action],{name:v}),`success`)),_.current=e},[E?.state,E?.action,E?.hint,v,l,r,o]),(0,X.useEffect)(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)},[E?.log.length]);let ee=(e,t)=>f.mutate({kind:n.kind,action:e,elevated:t},{onSuccess:()=>h(!0),onError:e=>o(H(e),`error`)}),j=async e=>{await V.copy(e)&&o(r(`common.copied`))},te=r(Kt[S??E?.action??`install`],{name:v}),ne={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},re=`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`,ie=b?.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(re,`min-w-0 flex-1`),children:b.adminFixCommand}),(0,Z.jsx)(N,{size:`sm`,icon:(0,Z.jsx)(ve,{className:`size-3`}),"aria-label":r(`common.copy`),onClick:()=>void j(b.adminFixCommand)})]})]}):null;return(0,Z.jsx)(B,{open:u,onOpenChange:e=>!e&&t(),width:620,title:te,description:D?r(T?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:D?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(N,{onClick:t,children:r(`common.cancel`)}),O&&!k?(0,Z.jsx)(N,{variant:`primary`,icon:(0,Z.jsx)(ve,{className:`size-3.5`}),disabled:!C,onClick:()=>void j(`sudo ${C}`),children:r(`clients.admin.copyCommand`)}):(0,Z.jsx)(N,{variant:T?`destructive`:`primary`,icon:O?(0,Z.jsx)(J,{className:`size-3.5`}):void 0,disabled:!C,loading:f.isPending,onClick:()=>S&&ee(S,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)(N,{variant:`destructive`,loading:p.isPending,onClick:()=>p.mutate(n.kind,{onError:e=>o(H(e),`error`)}),children:r(`clients.installStop`)}),(0,Z.jsx)(N,{onClick:t,children:r(`common.close`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(N,{onClick:t,children:r(`common.done`)}),A&&(0,Z.jsx)(N,{variant:`primary`,icon:(0,Z.jsx)(J,{className:`size-3.5`}),loading:f.isPending,onClick:()=>ee(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)(s,{tone:`warning`,title:r(`clients.uninstallRestoreTitle`),children:r(`clients.uninstallRestoreDetail`,{name:v})}),O&&(0,Z.jsx)(s,{tone:`warning`,title:r(`clients.admin.title`),children:r(k?`clients.admin.prompt`:`clients.admin.manual`)}),C?(0,Z.jsx)(`pre`,{className:re,children:O?`sudo ${C}`:C}):(0,Z.jsx)(s,{tone:`warning`,title:r(`clients.installUnavailable`)}),T?(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`clients.uninstallKeepsData`)}):b?.method===`npm`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`clients.installNpmNote`)}),O&&ie]}):E?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(s,{tone:E.state===`succeeded`&&E.hint?`warning`:ne[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}`)+(A?r(`clients.admin.retryHint`):``):void 0}),(0,Z.jsx)(`pre`,{ref:g,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`&&ie]}):d.isLoading?(0,Z.jsx)(w,{lines:4}):(0,Z.jsx)(y,{icon:(0,Z.jsx)(q,{className:`size-6`}),title:r(`clients.noInstallLog`)})})}function an({open:e,onOpenChange:t,client:n,model:r,extras:i,tokenId:a}){let{t:o}=x(),{toast:c}=W(),l=A(),u=oe(),d=Y(n.kind,n.name),f=i?{providerId:n.providerId,model:r,extras:i,tokenId:a}:{providerId:n.providerId,model:r,tokenId:a};(0,X.useEffect)(()=>{e&&l.mutate({kind:n.kind,req:f})},[e]);let p=()=>u.mutate({kind:n.kind,req:f},{onSuccess:e=>{t(!1),c(e.requiresRestart?o(`clients.enabledRestart`,{name:d}):o(`clients.enabledToast`,{name:d}),`success`)},onError:e=>{let t=Dt(e,o);c(t?`${t.title} · ${t.hint}`:H(e),`error`)}}),m=l.isError?Dt(l.error,o):null;return(0,Z.jsxs)(B,{open:e,onOpenChange:t,width:620,title:o(`clients.enableTitle`,{name:d}),description:o(`clients.enableDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(N,{onClick:()=>t(!1),children:o(`common.cancel`)}),(0,Z.jsx)(N,{variant:`primary`,disabled:!l.data,loading:u.isPending,onClick:p,children:n.enabled?o(`common.apply`):o(`clients.enable`)})]}),children:[l.isPending&&(0,Z.jsx)(w,{lines:4}),m&&(0,Z.jsx)(s,{tone:`danger`,title:m.title,children:m.hint}),l.isError&&!m&&(0,Z.jsx)(s,{tone:`danger`,title:o(`common.error`),children:H(l.error)}),l.data&&(0,Z.jsx)(on,{preview:l.data})]})}function on({preview:e}){let{t}=x();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Z.jsx)(s,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Z.jsx)(s,{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)(sn,{diff:e.unifiedDiff})]},e.file))]})}function sn({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 cn({open:e,onOpenChange:t,client:n}){let{t:r,locale:i}=x(),{toast:a,confirm:c}=W(),l=b(n.kind,e),u=d();return(0,Z.jsxs)(B,{open:e,onOpenChange:t,width:520,title:r(`clients.backups`),description:r(`clients.backupsDetail`),footer:(0,Z.jsx)(N,{onClick:()=>t(!1),children:r(`common.done`)}),children:[l.isLoading&&(0,Z.jsx)(w,{lines:3}),l.isError&&(0,Z.jsx)(s,{tone:`danger`,title:r(`common.error`),children:H(l.error)}),l.data?.length===0&&(0,Z.jsx)(y,{icon:(0,Z.jsx)(he,{className:`size-6`}),title:r(`clients.noBackups`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:l.data?.map(e=>(0,Z.jsx)(o,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[se(e.createdAt,i),e.firstWrite&&(0,Z.jsx)(v,{tone:`accent`,children:r(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Z.jsx)(N,{size:`sm`,icon:(0,Z.jsx)(De,{className:`size-3`}),loading:u.isPending&&u.variables?.id===e.id,onClick:async()=>{await c({title:r(`clients.restoreConfirm`),detail:e.files.join(`
|
|
11
|
+
`),destructive:!0,confirmLabel:r(`clients.restore`)})&&u.mutate({kind:n.kind,id:e.id},{onSuccess:()=>a(r(`clients.restored`),`success`),onError:e=>a(H(e),`error`)})},children:r(`clients.restore`)})},e.id))})]})}export{Pt as ClientsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,Ct as r,O as i,St as a,T as o,U as s,bt as c,c as l,d as u,ec as d,f,h as p,k as m,o as h,r as g,xt as _}from"./format-BulNVEXk.js";import{M as v,N as y,b}from"./index-CnDnJaC3.js";var x=e(t(),1),S=d(),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}=o(),[t,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(null),[s,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),h=(0,x.useCallback)(async t=>{let n=t.trim();if(n){p(!0),d(null);try{a(await _(n)),l(n),T(n)}catch(t){a(null),T(null),d(t instanceof c&&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&&(r(t),h(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`)})]})]}),!i&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h(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=>r(e.target.value)}),u&&(0,S.jsx)(n,{tone:`danger`,title:u}),(0,S.jsx)(m,{type:`submit`,variant:`primary`,loading:f,disabled:!t.trim(),children:e(`key.submit`)})]}),i&&(0,S.jsx)(D,{info:i,apiKey:s,onForget:()=>{T(null),a(null),r(``)}})]})})}function D({info:e,apiKey:t,onForget:n}){let{t:r,locale:a}=o(),[c,l]=(0,x.useState)(`overview`),u=e.allowedClients==null?r(`key.clientsAny`):e.allowedClients.length===0?r(`key.directOnly`):e.allowedClients.map(e=>b[e]?.name??e).join(`, `),d=[[r(`key.today`),e.usage.today],[r(`key.week`),e.usage.week],[r(`key.month`),e.usage.month],[r(`key.total`),e.usage.total]],h=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)(i,{tone:`orange`,children:r(`key.disabled`)}),(0,S.jsx)(m,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:n,children:r(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[r(`key.clients`),`: `,u,` · `,r(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(s,{ariaLabel:r(`key.title`),value:c,onChange:l,items:[{value:`overview`,label:r(`key.tab.overview`)},{value:`stats`,label:r(`key.tab.stats`)},{value:`requests`,label:r(`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:r(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`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`?p(t):f(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),i=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,o=`${r(`tokens.period.${e.period}`)} · ${r(`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:o}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":o,"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:i}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?r(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?r(`key.resets`,{time:g(e.resetsAt,a)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:r(`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:r(`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:r(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:d.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:p(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:f(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:f(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:r(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":r(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${p(e.costUsd)} · ${f(e.requests)} ${r(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${h>0?Math.max(2,e.costUsd/h*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=o(),[a,c]=(0,x.useState)(`7d`),[u,d]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return g(null),r(e,a).then(e=>n&&d(e),e=>n&&g(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,a,t]);let _=u?.summary,v=Math.max(...(u?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(s,{ariaLabel:t(`overview.range`),value:a,onChange:c,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),m&&(0,S.jsx)(n,{tone:`danger`,title:m}),!u||!_?!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:f(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?l(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:p(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:h(_.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:u.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${f(e.requests)} ${t(`key.requests`)} · ${p(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:u.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:u.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`)}),u.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:u.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(i,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,f(e.count)]})},e.category))})]}),u.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:u.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}=o();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:f(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:f(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:p(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:r}=o(),[c,l]=(0,x.useState)(`all`),[d,_]=(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 a(e,{before:n,status:c===`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,c,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)(s,{ariaLabel:t(`key.requests.status`),value:c,onChange:l,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(n,{tone:`danger`,title:T}),d.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),d.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:d.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:g(e.time,r),children:u(e.time,r)}),(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)(i,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(i,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[f(e.inputTokens,!0),` / `,f(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:p(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[h(e.ttftMs),` / `,h(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(m,{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{B as n,C as r,F as i,G as a,In as o,K as s,L as c,Nt as l,O as u,P as d,T as f,U as p,Vi as m,W as h,_r as g,ec as _,k as v,qt as y,ra as b,wi as x,z as S}from"./format-BulNVEXk.js";import{H as C,U as w,V as T,W as E}from"./TrayTitleSource-Byl3s-2T.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-CnDnJaC3.js";import{t as N}from"./checkbox-ux8EsZSf.js";import{t as P}from"./clientNames-Bskc9G1M.js";var F=e(t(),1),I=_();function L(){let{t:e}=f(),{toast:t,confirm:i}=E(),a=g(),o=l(),s=x(),[p,m]=(0,F.useState)(``),_=()=>o.mutate({path:p.trim()},{onSuccess:n=>{m(``),t(e(`library.projects.added`,{name:n.name}),`success`)},onError:e=>t(w(e),`error`)}),y=async(n,r)=>{await i({title:e(`library.projects.forget.title`,{name:r}),detail:e(`library.projects.forget.detail`),confirmLabel:e(`library.projects.forget`)})&&s.mutate(n,{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)(c,{mono:!0,className:`flex-1`,value:p,placeholder:`/Users/me/code/app`,onChange:e=>m(e.target.value),"aria-label":e(`library.projects.path`)}),(0,I.jsx)(v,{variant:`primary`,icon:(0,I.jsx)(k,{className:`size-4`}),disabled:p.trim()===``,loading:o.isPending,onClick:_,children:e(`library.projects.add`)})]}),a.isError&&(0,I.jsx)(r,{tone:`danger`,title:w(a.error)}),a.isLoading&&(0,I.jsx)(h,{lines:2}),a.data&&a.data.length===0&&(0,I.jsx)(d,{icon:(0,I.jsx)(D,{className:`size-6`}),title:e(`library.projects.empty`)}),a.data&&a.data.length>0&&(0,I.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:a.data.map(t=>(0,I.jsx)(n,{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)(u,{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)(v,{size:`sm`,icon:(0,I.jsx)(j,{className:`size-3.5`}),"aria-label":e(`library.projects.forget`),onClick:()=>void y(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}=f(),{toast:n,confirm:i}=E(),a=R[e],s=m(e),c=y(e),l=o(e),[u,p]=(0,F.useState)(null),g=s.data,_=async(e,r)=>{try{await e(),r&&n(t(r),`success`)}catch(e){n(w(e),`error`)}},b=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 _(()=>c.mutateAsync({id:e.id,force:n}),`library.toast.applied`)},x=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 _(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)(v,{variant:`primary`,icon:(0,I.jsx)(k,{className:`size-4`}),onClick:()=>p(`new`),disabled:g?.canWrite===!1,children:t(`library.add`)})]}),s.isError&&(0,I.jsx)(r,{tone:`danger`,title:`${t(`library.error.load`)}: ${w(s.error)}`}),s.isLoading&&(0,I.jsx)(h,{lines:3}),g&&g.canWrite===!1&&(0,I.jsx)(r,{tone:`info`,title:t(`library.localOnly`)}),g&&g.items.length===0&&(0,I.jsx)(d,{title:t(`library.empty.title`),detail:t(`library.empty.${a}`),action:g.canWrite?(0,I.jsx)(v,{variant:`primary`,onClick:()=>p(`new`),children:t(`library.add`)}):void 0}),g&&g.items.length>0&&(0,I.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:g.items.map(e=>(0,I.jsx)(U,{item:e,canWrite:g.canWrite,onEdit:()=>p(e),onDelete:()=>void x(e),onRewrite:t=>void b(e,t)},e.id))}),g&&(0,I.jsx)(G,{segment:e,library:g,item:u,onClose:()=>p(null)})]})}function U({item:e,canWrite:t,onEdit:r,onDelete:i,onRewrite:a}){let{t:o}=f(),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)(n,{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)(u,{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)(v,{size:`sm`,icon:(0,I.jsx)(A,{className:`size-3.5`}),onClick:()=>a(!1),children:o(`library.rewrite`)}),c&&t&&(0,I.jsx)(v,{size:`sm`,onClick:()=>a(!0),children:o(`library.rewriteForce`)}),(0,I.jsx)(v,{size:`sm`,icon:(0,I.jsx)(O,{className:`size-3.5`}),"aria-label":o(`common.edit`),onClick:r,disabled:!t}),(0,I.jsx)(v,{size:`sm`,icon:(0,I.jsx)(j,{className:`size-3.5`}),"aria-label":o(`common.delete`),onClick:i,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}=f(),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)(u,{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:r,onClose:o}){let{t:l}=f(),{toast:d}=E(),p=b(e),m=R[e],h=r&&r!==`new`?r:null,[g,_]=(0,F.useState)(``),[y,x]=(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(r===null)return;let e=r===`new`?null:r;_(e?.name??``),x(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})):[])},[r]);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=m===`agent`,X=g.trim()!==``&&(m===`env`||D.trim()!==``)&&(!Y||y.trim()!==``),Z=k.includes(`:`),Q=m===`hook`&&(Z||k!==`turn-end`&&k!==`prompt`);return(0,I.jsx)(C,{open:r!==null,onOpenChange:e=>!e&&o(),width:580,title:h?l(`library.editTitle`,{name:h.name}):l(`library.addTitle.${m}`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{onClick:o,children:l(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:!X,loading:p.isPending,onClick:()=>{let e={name:g.trim(),body:D,enabled:U,targets:G};(m===`agent`||m===`command`||m===`hook`)&&(e.description=y.trim()),m===`agent`&&V.trim()!==``&&(e.model=V.trim()),m===`hook`&&(e.event=k,e.matcher=Q?j.trim():``,e.timeout=L??0),p.mutate({id:h?.id,body:e},{onSuccess:e=>{o(),e.targets.filter(e=>e.state===`conflict`||e.state===`drifted`).length>0||e.lastError&&Object.keys(e.lastError).length>0?d(l(`library.toast.savedWithProblems`),`error`):d(l(`library.toast.saved`,{name:e.name}),`success`)},onError:e=>d(w(e),`error`)})},children:l(`common.save`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(i,{label:l(`library.field.name`),hint:l(`library.nameHint.${m}`),children:(0,I.jsx)(c,{mono:!0,value:g,maxLength:64,onChange:e=>_(e.target.value)})}),(m===`agent`||m===`command`||m===`hook`)&&(0,I.jsx)(i,{label:l(`library.field.description`),children:(0,I.jsx)(c,{value:y,maxLength:200,onChange:e=>x(e.target.value)})}),m===`hook`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(i,{label:l(`library.field.event`),hint:l(`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:l(`library.event.${e}`)})),{value:`__own__`,label:l(`library.event.own`)}]}),Z&&(0,I.jsx)(c,{mono:!0,className:`mt-2`,value:k,onChange:e=>A(e.target.value),placeholder:`claude-code:PermissionRequest`})]}),Q&&(0,I.jsx)(i,{label:l(`library.field.matcher`),hint:l(Z?`library.field.matcherOwn`:k===`session-start`?`library.field.matcherStarts`:`library.field.matcherTools`),children:k===`session-start`||Z?(0,I.jsx)(c,{mono:!0,value:j,placeholder:`startup|resume`,onChange:e=>M(e.target.value)}):(0,I.jsx)(T,{value:j,onChange:M,options:[{value:``,label:l(`library.matcher.all`)},{value:`shell`,label:l(`library.matcher.shell`)},{value:`edit`,label:l(`library.matcher.edit`)}]})}),(0,I.jsx)(i,{label:l(`library.field.timeout`),children:(0,I.jsx)(S,{value:L,onChange:B,min:0,step:1})})]}),(0,I.jsx)(i,{label:l(`library.field.body.${m}`),hint:m===`command`?l(`library.field.commandArgsHint`):void 0,children:m===`hook`||m===`env`?(0,I.jsx)(c,{mono:!0,value:D,onChange:e=>O(e.target.value)}):(0,I.jsx)(s,{mono:!0,rows:m===`instruction`?8:6,value:D,onChange:e=>O(e.target.value)})}),m===`agent`&&(0,I.jsx)(i,{label:l(`library.field.model`),hint:l(`library.field.modelHint`),children:(0,I.jsx)(c,{mono:!0,value:V,onChange:e=>H(e.target.value),placeholder:`gpt-5`})}),(0,I.jsx)(i,{label:l(`library.targets`),hint:l(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)(n,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[P(e.kind),!e.detected&&(0,I.jsx)(u,{children:l(`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:l(`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)(n,{label:l(`library.enabled`),children:(0,I.jsx)(a,{checked:U,label:l(`library.enabled`),onChange:W})})]})})}function K(){let{t:e}=f(),[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)(p,{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{$a as n,B as r,C as i,Ci as a,Da as o,Dn as s,Dr as c,Er as l,F as u,G as d,Gt as f,Ha as p,I as m,K as h,L as g,O as _,On as v,Or as y,P as b,Sr as x,T as S,U as C,Ut as w,W as T,_n as E,_r as D,ec as O,er as k,fo as A,gn as ee,k as j,lr as M,mo as N,o as P,po as F,r as I,un as L,xr as R,z}from"./format-BulNVEXk.js";import{B,H as V,R as te,U as H,V as U,W}from"./TrayTitleSource-Byl3s-2T.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-CnDnJaC3.js";var Z=e(t(),1),Q=O(),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}=S(),t=L(),r=n(),i=(r.data??[]).filter(e=>e.enabled&&(e.mcpServers?.length??0)>0);return(0,Q.jsxs)(m,{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)(T,{lines:2}),t.data&&i.length===0&&r.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:i.map(e=>({value:e.id,label:e.name}))},e.kind):null})]})}function fe({name:e,entry:t,tokens:n}){let{t:o}=S(),{toast:s,confirm:c}=W(),l=w(),u=a(),[d,f]=(0,Z.useState)(null),p=d??(n.some(e=>e.value===t.tokenId)?t.tokenId??null:n[0]?.value??null),m=l.isPending||u.isPending,h=t.state===`applied`||t.state===`drifted`,g=n=>{p&&l.mutate({kind:t.kind,tokenId:p,force:n},{onSuccess:()=>s(o(`mcp.clients.applied`,{client:e}),`success`),onError:e=>s(H(e),`error`)})},v=async n=>{(!n||await c({title:o(`mcp.clients.forceRemove`),detail:t.file,destructive:!0,confirmLabel:o(`mcp.clients.forceRemove`)}))&&u.mutate({kind:t.kind,force:n},{onSuccess:()=>s(o(`mcp.clients.removed`,{client:e}),`success`),onError:e=>s(H(e),`error`)})},y=(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:o(`mcp.clients.usesToken`,{name:t.tokenName})}),t.error&&(0,Q.jsx)(`span`,{className:`block text-[var(--danger)]`,children:o(`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)(r,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(0,Q.jsx)(_,{tone:ue[t.state],children:o(`mcp.clients.state.${t.state}`)})]}),detail:y,children:[n.length>0&&(0,Q.jsx)(U,{className:`w-44`,ariaLabel:`${e} ${o(`mcp.clients.token`)}`,placeholder:o(`mcp.clients.pickToken`),value:p,onChange:f,options:n,disabled:m}),(0,Q.jsx)(j,{variant:`primary`,disabled:m||!p||t.state===`conflict`,onClick:()=>g(!1),children:o(h?`mcp.clients.replace`:`mcp.clients.apply`)}),h&&(0,Q.jsx)(j,{disabled:m,onClick:()=>void v(t.state===`drifted`),children:t.state===`drifted`?o(`mcp.clients.forceRemove`):o(`mcp.clients.remove`)})]}),!t.gatewayEnabled&&t.state!==`missing`&&(0,Q.jsx)(i,{tone:`warning`,className:`mx-4 mb-3`,title:o(`mcp.clients.gatewayOff`)}),!t.gatewayEnabled&&t.state===`missing`&&(0,Q.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:o(`mcp.clients.gatewayOff`)}),t.state===`conflict`&&!t.error&&(0,Q.jsx)(i,{tone:`warning`,className:`mx-4 mb-3`,title:o(`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:o(`mcp.clients.drifted`)}),(0,Q.jsx)(j,{size:`sm`,disabled:m||!p,onClick:()=>g(!0),children:o(`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}=S(),{toast:t,confirm:n}=W(),r=x(),i=f(),a=s(),[o,c]=(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`)})},p=(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)(j,{icon:(0,Q.jsx)(oe,{className:`size-4`}),onClick:()=>u(!0),children:e(`mcp.local.import`)}),(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(Y,{className:`size-4`}),onClick:()=>c(`new`),children:e(`mcp.local.add`)})]})]}),r.isLoading?(0,Q.jsx)(T,{}):!r.data||r.data.length===0?(0,Q.jsx)(b,{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:()=>c(e),onDelete:()=>void d(e),onRewrite:t=>p(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:()=>c(null)}),(0,Q.jsx)(we,{open:l,onClose:()=>u(!1)})]})}function xe({server:e,busy:t,onEdit:n,onDelete:i,onRewrite:a}){let{t:o}=S(),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)(r,{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)(_,{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)(j,{size:`sm`,disabled:t,onClick:()=>a(!1),children:o(`mcp.local.rewrite`)}),(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(q,{className:`size-3.5`}),onClick:n,"aria-label":o(`common.edit`)}),(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),disabled:t,onClick:i,"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}=S();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)(_,{tone:ge[e.state],children:n(`mcp.local.state.${e.state}`)}),e.state===`drifted`&&e.wanted&&(0,Q.jsx)(j,{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}=S(),{toast:a}=W(),o=ee(),s=A(),c=e&&e!==`new`?e:null,[l,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,w]=(0,Z.useState)(`stdio`),[T,E]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(``),[M,N]=(0,Z.useState)([]),[P,F]=(0,Z.useState)([]),I=D().data??[],[L,R]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;f(t?.name??``),m(t?.command??``),v((t?.args??[]).join(`
|
|
5
|
+
`)),b(``),k(``),w(t?.transport??`stdio`),E(t?.url??``),N(t?.clients??he),F(t?.projects??[]),R(t?.enabled??!0)},[e]);let z=x===`http`,B=c?.transport===`stdio`&&x===`stdio`&&c.envNames.length>0,te=c?.transport===`http`&&x===`http`&&c.headerNames.length>0,U=ve(y),G=ye(O),K=o.isPending||s.isPending,ne=l.trim()!==``&&(z?T.trim()!==``&&G!==null:p.trim()!==``&&U!==null),q=()=>{let e=z?{name:l.trim(),transport:x,url:T.trim(),enabled:L,clients:M,projects:P}:{name:l.trim(),transport:x,command:p.trim(),args:_e(_),enabled:L,clients:M,projects:P},r=c?.transport===x;z&&G&&(O.trim()!==``||!r)&&(e.headers=G),!z&&U&&(y.trim()!==``||!r)&&(e.env=U);let i={onSuccess:e=>{t(),a(n(c?`mcp.local.saved`:`mcp.local.created`,{name:e.name}),`success`)},onError:e=>a(H(e),`error`)};c?s.mutate({id:c.id,body:e},i):o.mutate(e,i)},J=(e,t)=>N(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e));return(0,Q.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:c?n(`mcp.local.editTitle`,{name:c.name}):n(`mcp.local.addTitle`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(j,{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)(u,{label:n(`mcp.local.name`),hint:n(`mcp.local.nameHint`),children:(0,Q.jsx)(g,{mono:!0,value:l,maxLength:32,placeholder:`filesystem`,onChange:e=>f(e.target.value)})}),(0,Q.jsx)(u,{label:n(`mcp.local.transport`),children:(0,Q.jsx)(C,{ariaLabel:n(`mcp.local.transport`),value:x,onChange:w,items:[{value:`stdio`,label:n(`mcp.local.transport.stdio`)},{value:`http`,label:n(`mcp.local.transport.http`)}]})}),z?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{label:n(`mcp.local.url`),hint:n(`mcp.local.urlHint`),children:(0,Q.jsx)(g,{mono:!0,value:T,placeholder:`https://mcp.example.com/mcp`,onChange:e=>E(e.target.value)})}),(0,Q.jsx)(u,{label:n(`mcp.local.headers`),hint:te?n(`mcp.local.headersKept`,{names:c.headerNames.join(`, `)}):n(`mcp.local.headersHint`),children:(0,Q.jsx)(h,{mono:!0,rows:3,value:O,placeholder:`Authorization: Bearer ...`,onChange:e=>k(e.target.value)})}),G===null&&(0,Q.jsx)(i,{tone:`warning`,title:n(`mcp.local.headersInvalid`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{label:n(`mcp.local.command`),children:(0,Q.jsx)(g,{mono:!0,value:p,placeholder:`npx`,onChange:e=>m(e.target.value)})}),(0,Q.jsx)(u,{label:n(`mcp.local.args`),hint:n(`mcp.local.argsHint`),children:(0,Q.jsx)(h,{mono:!0,rows:4,value:_,placeholder:`-y
|
|
6
|
+
@modelcontextprotocol/server-filesystem
|
|
7
|
+
/Users/me/docs`,onChange:e=>v(e.target.value)})}),(0,Q.jsx)(u,{label:n(`mcp.local.env`),hint:B?n(`mcp.local.envKept`,{names:c.envNames.join(`, `)}):n(`mcp.local.envHint`),children:(0,Q.jsx)(h,{mono:!0,rows:3,value:y,placeholder:`API_KEY=...`,onChange:e=>b(e.target.value)})}),U===null&&(0,Q.jsx)(i,{tone:`warning`,title:n(`mcp.local.envInvalid`)})]}),(0,Q.jsx)(u,{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)(r,{label:e.name,children:(0,Q.jsx)(d,{checked:M.includes(e.kind),label:e.name,onChange:t=>J(e.kind,t)})},e.kind))})}),(I.length>0||P.length>0)&&(0,Q.jsx)(u,{label:n(`mcp.local.projects`),hint:n(`mcp.local.projectsHint`,{clients:me.map($).join(`, `)}),children:(0,Q.jsx)(`div`,{className:`grid gap-1`,children:[...I.map(e=>e.path),...P.filter(e=>!I.some(t=>t.path===e))].map(e=>(0,Q.jsx)(r,{label:(0,Q.jsx)(`span`,{className:`font-mono text-[12px]`,children:e}),children:(0,Q.jsx)(d,{checked:P.includes(e),label:e,onChange:t=>F(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e))})},e))})}),(0,Q.jsx)(r,{label:n(`mcp.local.enabled`),children:(0,Q.jsx)(d,{checked:L,label:n(`mcp.local.enabled`),onChange:R})})]})})}function we({open:e,onClose:t}){let{t:n}=S(),{toast:i}=W(),a=R(e),o=M(),[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),f=(e,t)=>c(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,Q.jsx)(V,{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)(j,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(j,{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 r=n(`mcp.local.importDone`,{count:e.imported.length});i(e.skipped.length>0?`${r} ${n(`mcp.local.importSkipped`,{count:e.skipped.length,reasons:[...new Set(e.skipped.map(e=>e.reason))].join(`; `)})}`:r,e.imported.length>0?`success`:`error`),t()},onError:e=>i(H(e),`error`)})},children:n(`mcp.local.importRun`)})]}),children:a.isLoading?(0,Q.jsx)(T,{}):!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),i=!e.importable||e.taken;return(0,Q.jsx)(r,{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)(_,{tone:`neutral`,children:$(e.kind)})]}),detail:(0,Q.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:e.summary,children:i?e.taken?n(`mcp.local.importTaken`):e.reason??``:e.summary}),children:(0,Q.jsx)(d,{checked:s.has(t),disabled:i,label:`${e.name} ${$(e.kind)}`,onChange:e=>f(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}=S(),{toast:t}=W(),n=y(),i=N(),[a,o]=(0,Z.useState)(``),s=n.data?.allowedOrigins.join(`
|
|
8
|
+
`)??``;if((0,Z.useEffect)(()=>o(s),[s]),!n.data)return(0,Q.jsx)(T,{});let c=n.data,l=n=>i.mutate(n,{onSuccess:()=>t(e(`common.saved`),`success`),onError:e=>t(H(e),`error`)});return(0,Q.jsxs)(m,{title:e(`mcp.gateway.title`),children:[(0,Q.jsx)(r,{label:e(`mcp.gateway.enable`),detail:e(`mcp.gateway.enableHint`),children:(0,Q.jsx)(d,{checked:c.enabled,disabled:i.isPending,label:e(`mcp.gateway.enable`),onChange:e=>l({enabled:e})})}),(0,Q.jsx)(r,{label:e(`mcp.gateway.remoteAdmin`),detail:e(`mcp.gateway.remoteAdminHint`),children:(0,Q.jsx)(d,{checked:c.allowRemoteAdmin,disabled:i.isPending,label:e(`mcp.gateway.remoteAdmin`),onChange:e=>l({allowRemoteAdmin:e})})}),(0,Q.jsxs)(r,{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)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(G,{className:`size-3.5`}),"aria-label":e(`mcp.gateway.copyEndpoint`),onClick:()=>void te.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)(u,{label:e(`mcp.gateway.origins`),hint:e(`mcp.gateway.originsHint`),children:(0,Q.jsx)(h,{mono:!0,rows:3,value:a,placeholder:`https://app.example.com`,onChange:e=>o(e.target.value)})}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(j,{size:`sm`,disabled:a.trim()===s.trim()||i.isPending,onClick:()=>l({allowedOrigins:a.split(`
|
|
9
|
+
`).map(e=>e.trim()).filter(Boolean)}),children:e(`mcp.gateway.originsSave`)})})]})]})}function Oe(){let{t:e}=S(),{toast:t,confirm:n}=W(),r=c(),i=p(),a=o(),s=k(),l=v(),[u,d]=(0,Z.useState)(null),[f,m]=(0,Z.useState)(null),h=n=>i.mutate(n.id,{onSuccess:r=>{r.ok?m({server:n,result:r}):t(e(`mcp.server.testFailed`,{message:r.message??r.status}),`error`)},onError:e=>t(H(e),`error`)}),g=n=>a.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`)}),_=async r=>{await n({title:e(`mcp.server.forgetConfirm`,{name:r.name}),detail:e(`mcp.server.forgetDetail`),confirmLabel:e(`mcp.server.forget`),destructive:!0})&&s.mutate(r.id,{onSuccess:()=>t(e(`mcp.server.forgotten`),`success`),onError:e=>t(H(e),`error`)})},y=async r=>{await n({title:e(`mcp.server.deleteConfirm`,{name:r.name}),detail:e(`mcp.server.deleteDetail`),confirmLabel:e(`common.delete`),destructive:!0})&&l.mutate(r.id,{onSuccess:()=>t(e(`mcp.server.deleted`,{name:r.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)(j,{size:`sm`,variant:`primary`,icon:(0,Q.jsx)(Y,{className:`size-3.5`}),onClick:()=>d(`new`),children:e(`mcp.servers.add`)})]}),r.data===void 0?(0,Q.jsx)(T,{}):r.data.length===0?(0,Q.jsx)(b,{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:r.data.map(e=>(0,Q.jsx)(ke,{server:e,busy:i.isPending&&i.variables===e.id,onTest:()=>h(e),onEdit:()=>d(e),onAuthorize:()=>g(e),onForget:()=>void _(e),onDelete:()=>void y(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:u,onClose:()=>d(null)}),(0,Q.jsx)(V,{open:f!==null,onOpenChange:e=>!e&&m(null),title:e(`mcp.server.testToolsTitle`,{name:f?.server.name??``}),description:f?e(`mcp.server.testOk`,{count:f.result.toolCount}):void 0,footer:(0,Q.jsx)(j,{onClick:()=>m(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:f?.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:i,onAuthorize:a,onForget:o,onDelete:s}){let{t:c,locale:l}=S(),u=F(),f=e.id===`builtin-astra`,p=e.authType===`oauth`,m=e.oauth?.authorized===!0,h=[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)(r,{label:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),f&&(0,Q.jsx)(_,{tone:`accent`,children:c(`mcp.server.builtIn`)}),(0,Q.jsx)(_,{tone:Te[e.status],title:e.statusMessage??void 0,children:c(`mcp.status.${e.status}`)}),!e.enabled&&(0,Q.jsx)(_,{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:h}),p&&m&&e.oauth?.issuer&&(0,Q.jsx)(`span`,{className:`block`,children:c(`mcp.server.authorizedBy`,{issuer:e.oauth.issuer})})]}),children:[f&&(0,Q.jsx)(Ae,{}),p&&(0,Q.jsx)(j,{size:`sm`,variant:m?`glass`:`primary`,icon:(0,Q.jsx)(re,{className:`size-3.5`}),onClick:a,children:c(m?`mcp.server.reauthorize`:`mcp.server.authorize`)}),!f&&(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(ae,{className:`size-3.5`}),loading:t,onClick:n,children:c(`mcp.server.test`)}),f?(0,Q.jsx)(d,{checked:e.enabled,label:e.name,onChange:t=>u.mutate({id:e.id,body:{enabled:t}})}):(0,Q.jsx)(B,{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:i},...p&&m?[{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}=S(),t=se();return(0,Q.jsx)(j,{size:`sm`,onClick:()=>t(`/tools`),children:e(`mcp.server.builtInManage`)})}function je({server:e,onClose:t}){let{t:n}=S(),{toast:a}=W(),o=E(),s=F(),c=e&&e!==`new`?e:null,[l,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(`http`),[b,x]=(0,Z.useState)(`none`),[w,T]=(0,Z.useState)([]),[D,O]=(0,Z.useState)(60),[k,A]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;f(t?.name??``),m(t?.slug??``),_(t?.url??``),y(t?.transport??`http`),x(t?.authType??`none`),T((t?.headerNames??[]).map(e=>({name:e,value:``,kept:!0}))),O(t?.timeoutSeconds??60),A(t?.enabled??!0)},[e]);let ee=o.isPending||s.isPending,M=l.trim()!==``&&h.trim()!==``&&(b!==`header`||w.some(e=>e.name.trim()!==``&&(e.value!==``||e.kept))),N=()=>{let e={name:l.trim(),url:h.trim(),transport:v,authType:b,enabled:k,...D==null?{}:{timeoutSeconds:Math.floor(D)},...p.trim()?{slug:p.trim()}:{}};b===`header`&&(e.headers=Object.fromEntries(w.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.kept&&e.value===``?null:e.value])));let r={onSuccess:e=>{t(),a(n(c?`mcp.server.saved`:`mcp.server.created`,{name:e.name}),`success`)},onError:e=>a(H(e),`error`)};c?s.mutate({id:c.id,body:e},r):o.mutate(e,r)},P=(e,t)=>T(n=>n.map((n,r)=>r===e?{...n,...t}:n));return(0,Q.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:c?n(`mcp.server.editTitle`,{name:c.name}):n(`mcp.server.addTitle`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(j,{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)(u,{label:n(`mcp.server.name`),children:(0,Q.jsx)(g,{value:l,maxLength:64,onChange:e=>f(e.target.value)})}),(0,Q.jsx)(u,{label:n(`mcp.server.url`),hint:n(`mcp.server.urlHint`),children:(0,Q.jsx)(g,{mono:!0,value:h,placeholder:`https://mcp.example.com/mcp`,onChange:e=>_(e.target.value)})}),(0,Q.jsx)(u,{label:n(`mcp.server.transport`),hint:n(`mcp.server.transportHint`),children:(0,Q.jsx)(C,{ariaLabel:n(`mcp.server.transport`),value:v,onChange:y,items:[{value:`http`,label:n(`mcp.server.transport.http`)},{value:`sse`,label:n(`mcp.server.transport.sse`)}]})}),(0,Q.jsx)(u,{label:n(`mcp.server.auth`),children:(0,Q.jsx)(C,{ariaLabel:n(`mcp.server.auth`),value:b,onChange:x,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`)}]})}),b===`oauth`&&(0,Q.jsx)(i,{tone:`warning`,title:n(`mcp.server.oauthNote`)}),b===`header`&&(0,Q.jsx)(u,{label:n(`mcp.server.headers`),hint:n(`mcp.server.headersHint`),children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[w.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(g,{className:`w-40`,mono:!0,label:n(`mcp.server.headerName`),placeholder:`Authorization`,value:e.name,readOnly:e.kept&&c!==null,onChange:e=>P(t,{name:e.target.value})}),(0,Q.jsx)(g,{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)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),"aria-label":n(`mcp.server.removeHeader`),onClick:()=>T(e=>e.filter((e,n)=>n!==t))})]},t)),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(Y,{className:`size-3.5`}),onClick:()=>T(e=>[...e,{name:``,value:``,kept:!1}]),children:n(`mcp.server.addHeader`)})})]})}),(0,Q.jsx)(u,{label:n(`mcp.server.slug`),hint:n(`mcp.server.slugHint`),children:(0,Q.jsx)(g,{mono:!0,value:p,maxLength:32,placeholder:c?``:`github`,onChange:e=>m(e.target.value)})}),(0,Q.jsx)(u,{label:n(`mcp.server.timeout`),hint:n(`mcp.server.timeoutHint`),children:(0,Q.jsx)(z,{value:D,min:1,step:1,label:n(`mcp.server.timeout`),onChange:O})}),(0,Q.jsx)(r,{label:n(`mcp.server.enabled`),children:(0,Q.jsx)(d,{checked:k,label:n(`mcp.server.enabled`),onChange:A})})]})})}function Me(){let{t:e,locale:t}=S(),n=l(50);return(0,Q.jsx)(m,{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)(T,{})}):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}=S();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)(_,{tone:`green`,children:n(`mcp.calls.ok`)}):(0,Q.jsx)(_,{tone:`red`,children:n(`mcp.calls.error.${e.errorCategory??`protocol`}`)})})]})}function Pe(){let{t:e}=S();return(0,Q.jsx)(ce,{title:e(`nav.mcp`),subtitle:e(`mcp.subtitle`),children:(0,Q.jsx)(Ee,{})})}export{Pe as McpPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{An as n,B as r,C as i,F as a,G as o,H as s,I as c,L as l,O as u,Ri as d,Ro as f,T as p,W as m,b as h,ec as g,ho as _,jr as v,k as y,kn as b,r as x,ri as S,z as C}from"./format-BulNVEXk.js";import{H as w,U as T,V as E,W as D}from"./TrayTitleSource-Byl3s-2T.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-CnDnJaC3.js";import{t as I}from"./checkbox-ux8EsZSf.js";import{t as L}from"./confirm-morph-OQsP-uPd.js";var R=e(t(),1),z=g(),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}=p(),n=te(),{id:a=``}=N(),f=decodeURIComponent(a),g=v(f),S=_(f),w=d(f),E=b(),{toast:k}=D(),A=(0,R.useMemo)(()=>g.data?V(g.data):null,[g.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)(y,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>n(`/models`)});if(g.isError)return(0,z.jsx)(F,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(i,{tone:`danger`,title:e(`common.error`),children:T(g.error)})});let J=g.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=()=>S.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)(u,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(y,{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:x(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)(y,{onClick:()=>{L(A),G(A?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(y,{variant:`primary`,disabled:!Z,loading:S.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)(c,{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)(l,{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)(l,{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)(l,{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)(l,{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)(C,{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)(C,{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)(o,{checked:M.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(c,{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)(c,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(r,{label:(0,z.jsx)(ee,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${h(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(s,{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)(s,{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)(r,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=p(),i=n(e.id),[a,o]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(c,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(y,{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)(r,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(r,{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)(u,{tone:`orange`,children:t(`models.modified`)})]}),detail:[h(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)(y,{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:()=>i.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:a,onClose:()=>o(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:r}=p(),{toast:i}=D(),o=S(),s=f(e.id),c=t===`new`,[u,d]=(0,R.useState)(``),[m,h]=(0,R.useState)(``),[g,_]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(d(``),h(``),_(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(d(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:c?r(`models.addPrice`):r(`models.editPrice`,{key:u}),description:r(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(y,{onClick:n,children:r(`common.cancel`)}),(0,z.jsx)(y,{variant:`primary`,disabled:!u||!g,loading:s.isPending,onClick:()=>s.mutate({priceKey:u,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)(a,{label:r(`providers.priceKey`),children:c?(0,z.jsx)(E,{value:u,onChange:d,placeholder:r(`models.pickPriceKey`),options:(o.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:v.has(e.priceKey)}))}):(0,z.jsx)(l,{value:u,disabled:!0,className:`font-mono`})}),(0,z.jsx)(a,{label:r(`models.upstreamId`),hint:r(`models.upstreamIdHint`),children:(0,z.jsx)(l,{className:`font-mono`,value:m,onChange:e=>h(e.target.value),placeholder:e.id})})]}),c&&(0,z.jsx)(l,{className:`font-mono`,"aria-label":r(`models.customPriceKey`),placeholder:r(`models.customPriceKey`),value:u,onChange:e=>d(e.target.value.trim())}),(0,z.jsx)(P,{value:g,onChange:_})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=p();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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,F as r,Ia as i,L as a,Mr as o,O as s,P as c,Ra as l,T as u,V as d,W as f,ec as p,ft as m,k as h,m as g,n as _,vn as v,y,z as b}from"./format-BulNVEXk.js";import{H as x,U as S,V as C,W as w}from"./TrayTitleSource-Byl3s-2T.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-CnDnJaC3.js";import{t as P}from"./checkbox-ux8EsZSf.js";var F=e(t(),1),I=p();function L(){let{t:e}=u(),t=M(),[r,i]=(0,F.useState)(``),[a,s]=(0,F.useState)(``),[l,p]=(0,F.useState)(!1),[m,g]=(0,F.useState)(!1),_=(0,F.useRef)(null),v=j(r),y=o(),b=o(v,a),x=(0,F.useMemo)(()=>[...new Set((y.data??[]).map(e=>e.vendor))].sort(),[y.data]);return A(e=>{e===`find`&&_.current?.focus()}),(0,I.jsxs)(N,{title:e(`nav.models`),subtitle:b.data?e(`models.count`,{count:b.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{inputRef:_,className:`w-52`,value:r,onChange:i,placeholder:e(`models.search`)}),(0,I.jsx)(C,{value:a,onChange:s,options:[{value:``,label:e(`models.allVendors`)},...x.map(e=>({value:e,label:e}))]}),(0,I.jsx)(h,{icon:(0,I.jsx)(D,{className:`size-3.5`}),onClick:()=>g(!0),children:e(`models.sync`)}),(0,I.jsx)(h,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.new`)})]}),children:[b.isLoading&&(0,I.jsx)(f,{lines:5}),b.isError&&(0,I.jsx)(n,{tone:`danger`,title:e(`common.error`),children:S(b.error)}),b.data?.length===0&&(0,I.jsx)(c,{icon:(0,I.jsx)(T,{className:`size-6`}),title:e(`models.empty`)}),b.data&&b.data.length>0&&(0,I.jsx)(k,{caption:e(`nav.models`),rowKey:`id`,rows:b.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:l,onOpenChange:p,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:m,onOpenChange:g})]})}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:m(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(s,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(s,{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?`${g(n.input)} / ${g(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:i}=u(),{toast:o}=w(),s=v(),[c,l]=(0,F.useState)(``),[d,f]=(0,F.useState)(``),[p,m]=(0,F.useState)(``),[g,_]=(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:i(`models.new`),description:i(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,I.jsx)(h,{variant:`primary`,disabled:!c.trim()||!p.trim(),loading:s.isPending,onClick:()=>s.mutate({id:c.trim(),displayName:d.trim()||c.trim(),vendor:p.trim(),contextWindow:g,pricing:y!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:y,output:T}}:null},{onSuccess:e=>{t(!1),l(``),f(``),n(e.id)},onError:e=>o(S(e),`error`)}),children:i(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(r,{label:i(`models.field.id`),hint:i(`models.field.idHint`),children:(0,I.jsx)(a,{className:`font-mono`,value:c,onChange:e=>l(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(r,{label:i(`models.field.displayName`),children:(0,I.jsx)(a,{value:d,onChange:e=>f(e.target.value)})}),(0,I.jsx)(r,{label:i(`models.field.vendor`),children:(0,I.jsx)(a,{value:p,onChange:e=>m(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(r,{label:i(`models.field.contextWindow`),children:(0,I.jsx)(b,{value:g,onChange:_})}),(0,I.jsx)(r,{label:i(`models.field.inputPrice`),children:(0,I.jsx)(b,{value:y,onChange:C})}),(0,I.jsx)(r,{label:i(`models.field.outputPrice`),children:(0,I.jsx)(b,{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}=u(),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:i}=u(),[a,o]=(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`},d=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},f=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),p=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)(s,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(s,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),h=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(h),onCheckedChange:e=>d(h,e!==!1),"aria-label":i(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.selectedOf`,{n:n.size,total:h.length,models:c.length})})]}),c.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,c=!a.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(o),onCheckedChange:e=>d(o,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:()=>f(e),children:[(0,I.jsx)(E,{className:m(`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:i(`models.sync.groupCount`,{n:r.length})})]}),s&&p(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=>d([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),p(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:r}=u(),{toast:a}=w(),o=l(),s=i(),[c,d]=(0,F.useState)(new Set),p=()=>o.mutate(void 0,{onSuccess:e=>d(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),m=o.data?.changes??[];return(0,I.jsxs)(x,{open:e,onOpenChange:e=>{t(e),e&&!o.data&&p()},width:720,title:r(`models.sync`),description:r(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{className:`mr-auto`,variant:`plain`,onClick:p,loading:o.isPending,children:r(`common.refresh`)}),(0,I.jsx)(h,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(h,{variant:`primary`,disabled:c.size===0,loading:s.isPending,onClick:()=>s.mutate([...c],{onSuccess:e=>{a(r(`models.sync.applied`,{count:e.applied}),`success`),t(!1),o.reset()},onError:e=>a(S(e),`error`)}),children:r(`models.sync.apply`,{count:c.size})})]}),children:[e&&!o.data&&!o.isPending&&!o.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(h,{variant:`primary`,onClick:p,children:r(`models.sync.check`)})}),o.isPending&&(0,I.jsx)(f,{lines:4}),o.isError&&(0,I.jsx)(n,{tone:`danger`,title:r(`common.error`),children:S(o.error)}),o.data&&m.length===0&&(0,I.jsx)(n,{tone:`success`,title:r(`models.sync.none`)}),m.length>0&&(0,I.jsx)(K,{changes:m,label:e=>e.kind===`new_model`?r(`models.sync.newModel`):e.kind===`price`?r(`models.sync.price`,{key:e.priceKey??``}):r(`models.sync.field`,{field:e.field??``}),checked:c,onChange:d})]})}export{L as ModelsPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$r as n,A as r,Br as i,C as a,Di as o,F as s,G as c,K as l,L as u,Nr as d,O as f,P as p,Pt as m,R as h,T as g,Ti as _,Tr as v,U as y,V as b,Vr as x,W as S,Wr as C,Xr as w,ec as T,ft as E,go as D,k as O,mr as k,r as A,ur as j,zr as M}from"./format-BulNVEXk.js";import{B as N,H as P,U as F,W as I}from"./TrayTitleSource-Byl3s-2T.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-CnDnJaC3.js";var q=e(t(),1),J=T(),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}=g(),t=G(),{tab:n}=U(),r=n===`market`||n===`runtime`?n:`installed`,i=w(),o=D(),{toast:s}=I(),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(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)(O,{icon:(0,J.jsx)(z,{className:`size-3.5`}),onClick:()=>o.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>s(F(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(O,{variant:`primary`,icon:(0,J.jsx)(ae,{className:`size-3.5`}),onClick:()=>l(!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)(a,{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)(S,{lines:4}),i.isError&&(0,J.jsx)(a,{tone:`danger`,title:e(`common.error`),children:F(i.error)}),(0,J.jsx)(`div`,{className:`mb-4`,children:(0,J.jsx)(le,{onJob:p})}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins.filter(e=>!e.kinds.includes(`v2`)),preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(V,{value:`market`,className:`pt-1`,children:(0,J.jsx)(xe,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(V,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Se,{onJob:p})})]})]}),(0,J.jsx)(ve,{open:c,onOpenChange:l,onJob:p}),(0,J.jsx)(ye,{open:u,onOpenChange:d,onJob:p}),(0,J.jsx)(be,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=g(),s=M(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),c=v(),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)(O,{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)(p,{icon:(0,J.jsx)(R,{className:`size-6`}),title:a(`plugins.empty`),detail:a(`plugins.emptyDetail`),action:(0,J.jsx)(O,{variant:`primary`,onClick:r,children:a(`plugins.browseMarket`)})})})]});let f=(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?()=>f(i,-1):void 0,onDown:i<e.length-1?()=>f(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:r,onJob:i,onUp:o,onDown:s}){let{t:l}=g(),u=G(),{toast:p,confirm:m}=I(),h=d(),v=D(),y=_(),b=n(),[x,S]=(0,q.useState)(!1),C=t?.plugins.find(t=>t.spec===e.spec),w=e.middleware,T=e.kinds[0]??`provider`,k=async()=>{await m({title:l(`plugins.removeConfirm`,{name:e.shortName}),detail:l(`plugins.removeDetail`),confirmLabel:l(`common.delete`),destructive:!0})&&y.mutate(e.spec,{onSuccess:e=>i(e.id),onError:e=>p(F(e),`error`)})},A=[];return w&&!w.error&&A.push((0,J.jsxs)(Z,{label:l(`plugins.kind.middleware`),children:[l(`plugins.mw.stats`,{hooks:w.hooks.join(`, `),calls:w.calls,micros:w.avgMicros.toFixed(1),failures:w.failures}),w.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:l(`plugins.mw.lastError`,{error:w.lastError})})]},`mw`)),e.notice===`hooks-unsupported`&&A.push((0,J.jsx)(Z,{label:l(`plugins.kind.hooks`),children:l(`plugins.hooksUnsupported`)},`notice`)),e.agent?.kind&&A.push((0,J.jsx)(Z,{label:l(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>u(`/clients/${e.agent.kind}`),children:l(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),C&&C.provides.length>0&&A.push((0,J.jsxs)(Z,{label:l(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:l(`plugins.provides`,{providers:C.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>u(`/providers`),children:l(`plugins.openProviders`)}),Object.entries(C.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[l(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(O,{size:`sm`,onClick:()=>b.mutate({spec:e.spec,provider:t},{onError:e=>p(F(e),`error`)}),children:l(`plugins.useFor`,{provider:t})})]},t)),C.provides.some(t=>r[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:l(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:E(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:E(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:T})}),(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)(f,{tone:me[e],children:l(Y[e])},e)),e.isPath&&(0,J.jsx)(f,{tone:`orange`,children:l(`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:[w&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":l(`plugins.moveUp`),title:l(`plugins.moveUp`),disabled:!o,onClick:o,icon:(0,J.jsx)(L,{className:`size-3.5`})}),(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":l(`plugins.moveDown`),title:l(`plugins.moveDown`),disabled:!s,onClick:s,icon:(0,J.jsx)(te,{className:`size-3.5`})})]}),(0,J.jsx)(c,{checked:e.enabled,label:l(`plugins.enabled`),onChange:t=>h.mutate({spec:e.spec,enabled:t},{onError:e=>p(F(e),`error`)})}),(0,J.jsx)(N,{label:l(`common.more`),iconOnly:!0,icon:(0,J.jsx)(re,{className:`size-4`}),items:[{id:`options`,label:l(`plugins.options`),icon:(0,J.jsx)(oe,{className:`size-3.5`}),onSelect:()=>S(!0)},...e.isPath?[]:[{id:`update`,label:l(`plugins.update`),icon:(0,J.jsx)(z,{className:`size-3.5`}),onSelect:()=>v.mutate(e.spec,{onSuccess:e=>i(e.id),onError:e=>p(F(e),`error`)})}],{id:`remove`,label:l(`common.delete`),icon:(0,J.jsx)(ce,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void k()}]})]})]}),e.error&&(0,J.jsx)(a,{tone:`danger`,title:l(`plugins.cantLoad`),children:e.error}),C?.error&&(0,J.jsx)(a,{tone:`danger`,title:l(`plugins.hostCantLoad`),children:C.error}),w?.error&&(0,J.jsx)(a,{tone:`danger`,title:l(`plugins.cantLoad`),children:l(`plugins.mw.error`,{error:w.error})}),e.agent?.error&&(0,J.jsx)(a,{tone:`danger`,title:l(`plugins.cantLoad`),children:l(`plugins.agent.error`,{error:e.agent.error})}),A.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:A})]}),(0,J.jsx)(Q,{plugin:e,open:x,onOpenChange:S})]})}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}=g(),{toast:i}=I(),a=d(),[o,s]=(0,q.useState)(``),[c,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(s(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)(O,{onClick:()=>f(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(O,{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)(l,{mono:!0,rows:14,value:o,invalid:!!c,onChange:e=>(s(e.target.value),u(null)),label:r(`plugins.options`)}),c&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:c})]})}function ve({open:e,onOpenChange:t,onJob:n}){let{t:r}=g(),{toast:i}=I(),o=m(),[c,l]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&l(``)},[e]),(0,J.jsxs)(P,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(O,{variant:`primary`,disabled:!c.trim()||o.isPending,onClick:()=>o.mutate({spec:c.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(F(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(s,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(u,{mono:!0,value:c,onChange:e=>l(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(a,{tone:`warning`,title:r(`plugins.trustTitle`),className:`mt-4`,children:r(`plugins.trustDetail`)})]})}function ye({open:e,onOpenChange:t,onJob:n}){let{t:r}=g(),{toast:i}=I(),o=v(e),s=j(),[l,u]=(0,q.useState)(!1),d=o.data;return(0,J.jsxs)(P,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:d?.path,width:560,footer:(0,J.jsx)(O,{variant:`primary`,disabled:!d?.found||s.isPending,onClick:()=>s.mutate(l,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(F(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[o.isLoading&&(0,J.jsx)(S,{lines:3}),d?.error&&(0,J.jsx)(a,{tone:`danger`,title:r(`common.error`),children:d.error}),d&&(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:d.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)(f,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(f,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(f,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),d.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(c,{checked:l,onChange:u,label:r(`plugins.magpie.signIns`,{count:d.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}=g(),o=i(e).data;return(0,J.jsxs)(P,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:o?n(o.state===`running`?`plugins.job.running`:o.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:o.target}):void 0,width:620,footer:(0,J.jsx)(O,{onClick:t,children:n(`common.close`)}),children:[!o&&(0,J.jsx)(S,{lines:3}),o&&(0,J.jsx)(r,{language:`text`,children:o.log.length?o.log.join(`
|
|
2
|
+
`):`…`}),o?.state===`failed`&&o.error&&(0,J.jsx)(a,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:o.error})]})}function xe({installed:e,onJob:t}){let{t:n,locale:r}=g(),{toast:i,confirm:o}=I(),s=x(),c=m(),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(``),[h,_]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>f(l.trim()),400);return()=>clearTimeout(e)},[l]);let v=C(d),w=(0,q.useMemo)(()=>new Set(e.map(e=>e.name)),[e]),T=(t,n)=>w.has(n)||e.some(e=>e.spec===t),E=async(e,r)=>{await o({title:n(`plugins.installConfirm`,{name:e}),detail:n(`plugins.trustDetail`),confirmLabel:n(`plugins.install`)})&&c.mutate({spec:e,source:r},{onSuccess:e=>t(e.id),onError:e=>i(F(e),`error`)})},[D,O]=W(),k=D.get(`install`),A=(0,q.useRef)(null);(0,q.useEffect)(()=>{k&&A.current!==k&&(A.current=k,O({},{replace:!0}),pe.test(k)?E(k,`market`):i(n(`plugins.linkInvalid`),`error`))},[k]);let j=(s.data??[]).filter(e=>h===`all`||e.kind===h),M=e=>(s.data??[]).filter(t=>e===`all`||t.kind===e).length,N=d.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)(b,{className:`min-w-[220px] flex-1`,value:l,onChange:u,placeholder:n(`plugins.searchPlaceholder`)}),!N&&(0,J.jsx)(y,{ariaLabel:n(`plugins.kindFilter`),value:h,onChange:_,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:[v.isLoading&&(0,J.jsx)(S,{lines:3}),v.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(p,{icon:(0,J.jsx)(R,{className:`size-6`}),title:n(`plugins.noResults`)})}),v.data&&v.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:v.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:T(e.spec,e.name),onInstall:()=>void E(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:[s.isLoading&&(0,J.jsx)(S,{lines:4}),s.isError&&(0,J.jsx)(a,{tone:`danger`,title:n(`common.error`),children:F(s.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[r]??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:T(e.package,e.package),onInstall:()=>void E(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:a,onInstall:o}){let{t:s}=g();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)(f,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),a?(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`}),s(`plugins.installed`)]}):(0,J.jsx)(O,{size:`sm`,variant:`primary`,onClick:o,children:s(`plugins.install`)})]})]})}function Se({onJob:e}){let{t,locale:n}=g(),{toast:r}=I(),i=w(),o=M(),s=k(),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)(f,{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)(h,{label:t(`plugins.bunPath`),mono:!0,children:c.path}),c.version&&(0,J.jsx)(h,{label:t(`plugins.bunVersion`),mono:!0,children:c.version}),(0,J.jsx)(h,{label:t(`plugins.bunTarget`),mono:!0,children:c.target??t(`plugins.bunNoBuild`)})]}),c?.error&&(0,J.jsx)(a,{tone:`danger`,title:t(`plugins.bunFailed`),children:c.error}),c&&!c.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(O,{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)(f,{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)(a,{tone:`danger`,title:t(`plugins.hostStartFailed`),children:o.data.startError}),o.data?.goneReason&&(0,J.jsx)(a,{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)(h,{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)(f,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:A(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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{B as n,C as r,F as i,G as a,H as o,I as s,K as c,L as l,O as u,P as d,Q as f,T as p,U as m,V as h,W as g,_o as _,ai as v,cs as y,d as b,ec as x,f as S,fn as C,fs as w,ft as T,ii as E,k as D,ls as O,oi as k,ps as A,si as j,sn as M,ss as N,us as P}from"./format-BulNVEXk.js";import{H as F,U as I,V as L,W as R}from"./TrayTitleSource-Byl3s-2T.js";import{t as z}from"./use-transform-ZS0KHlh3.js";import{t as ee}from"./check-DKfsh0bQ.js";import{t as te}from"./chevron-left-EiWUqFxR.js";import{t as ne}from"./chevron-right-Bgtn3ze-.js";import{t as re}from"./plus-c3HzV6VX.js";import{t as ie}from"./refresh-cw-CoLAai2c.js";import{t as B}from"./shield-check-CD30JqBi.js";import{t as V}from"./shield-off-rW5EHy29.js";import{t as H}from"./trash-BHBJn5GS.js";import{t as ae}from"./x-AFrW8zH7.js";import{A as oe,D as U,E as W,G as se,I as G,O as ce,W as le,b as ue,d as de,k as fe,q as pe,r as me,v as he}from"./index-CnDnJaC3.js";var K=e(t(),1),q={toolbar:`_toolbar_xx43h_1`,leading:`_leading_xx43h_3`,frame:`_frame_xx43h_7`,chips:`_chips_xx43h_9`,slot:`_slot_xx43h_13`,chip:`_chip_xx43h_9`,chipLabel:`_chipLabel_xx43h_19`,value:`_value_xx43h_21`,separator:`_separator_xx43h_23`,morphText:`_morphText_xx43h_25`,morphValue:`_morphValue_xx43h_27`,measure:`_measure_xx43h_29`,empty:`_empty_xx43h_35`,actions:`_actions_xx43h_37`,clear:`_clear_xx43h_39`,clearText:`_clearText_xx43h_41`,srOnly:`_srOnly_xx43h_45`,menu:`_menu_xx43h_53`,trigger:`_trigger_xx43h_57`,face:`_face_xx43h_61`,surface:`_surface_xx43h_67`,panel:`_panel_xx43h_83`,head:`_head_xx43h_89`,back:`_back_xx43h_93`,title:`_title_xx43h_97`,titleText:`_titleText_xx43h_99`,stage:`_stage_xx43h_101`,step:`_step_xx43h_103`,list:`_list_xx43h_105`,highlight:`_highlight_xx43h_107`,item:`_item_xx43h_109`,itemIcon:`_itemIcon_xx43h_113`,itemLabel:`_itemLabel_xx43h_115`,itemMeta:`_itemMeta_xx43h_117`,metaValue:`_metaValue_xx43h_119`,hint:`_hint_xx43h_121`,check:`_check_xx43h_123`,noOptions:`_noOptions_xx43h_127`},J=x(),Y={duration:f.duration.standard,ease:[...f.ease.enter]},ge={duration:f.duration.instant,ease:[...f.ease.standard]},X={duration:0},_e={duration:f.duration.instant,ease:[...f.ease.standard]},Z=e=>`blur(${e}px)`,ve=e=>Math.min(1,Math.max(0,e)),ye=e=>typeof e==`string`?{value:e}:e,be=e=>e.label??e.value,xe=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:Z(f.blur.soft)},animate:{opacity:1,y:0,filter:Z(0)},exit:e?{opacity:0,transition:X}:{opacity:0,y:`-0.3em`,filter:Z(f.blur.subtle),transition:ge},transition:e?_e:Y});function Se({text:e}){let t=O()??!1,n=(0,K.useRef)(null),r=P(`auto`);return(0,K.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let i=null,a=new ResizeObserver(([n])=>{let a=Math.ceil(n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),o=i!==null&&i!==e.textContent;i=e.textContent,o&&!t?y(r,a,f.spring.morph):r.jump(a)});return a.observe(e),()=>a.disconnect()},[t,r]),(0,J.jsxs)(N.span,{className:q.morphText,style:{width:r},children:[(0,J.jsx)(`span`,{ref:n,className:q.measure,"aria-hidden":`true`,children:e}),(0,J.jsx)(w,{mode:`popLayout`,initial:!1,children:(0,J.jsx)(N.span,{className:q.morphValue,...xe(t),children:e},e)})]})}function Ce(e,t,n){let r=P(`auto`);return(0,K.useLayoutEffect)(()=>{let i=e.current;if(!i||typeof ResizeObserver>`u`)return;let a=!1,o=new ResizeObserver(()=>{let e=i.offsetHeight;if(!a||n||performance.now()>t.current){a=!0,r.jump(e);return}y(r,e,f.spring.smooth)});return o.observe(i),()=>o.disconnect()},[t,r,e,n]),r}function we(e,t,n){(0,K.useLayoutEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>`u`)return;let i=new Map,a=()=>{let e=performance.now();for(let a of Array.from(r.children)){let r=a.offsetLeft,o=a.offsetTop,s=i.get(a);if(!s){i.set(a,{x:r,y:o,dx:0,dy:0});continue}let c=s.x-r,l=s.y-o;if(s.x=r,s.y=o,n||e>t.current||Math.abs(l)<1&&Math.abs(c)<40)continue;s.stop?.();let u=s.dx+c,d=s.dy+l,p=e=>{s.dx=u*(1-e),s.dy=d*(1-e),a.style.translate=e>=1?``:`${s.dx}px ${s.dy}px`};p(0),s.stop=y(0,1,{...f.spring.smooth,onUpdate:p,onComplete:()=>p(1)}).stop}for(let e of i.keys())e.parentElement!==r&&i.delete(e)},o=new ResizeObserver(a),s=()=>{for(let e of Array.from(r.children))o.observe(e)},c=new MutationObserver(()=>{s(),a()});return o.observe(r),s(),c.observe(r,{childList:!0}),()=>{o.disconnect(),c.disconnect();for(let e of i.values())e.stop?.()}},[t,e,n])}var Te=e=>e.valueLabel??e.value,Ee=e=>Te(e)?`${e.label}: ${Te(e)}`:e.label,De={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${Ee(e)}`,added:e=>`Added ${Ee(e)}`,changed:e=>`Changed ${Ee(e)}`,removed:e=>`Removed ${Ee(e)}`};function Oe(e,t,n){let r=e.filter(e=>!t.some(t=>t.id===e.id));if(!t.length&&r.length>1)return n.cleared;let i=t.filter(t=>!e.some(e=>e.id===t.id)),a=t.filter(t=>e.some(e=>e.id===t.id&&e.value!==t.value));return[...i.map(n.added),...a.map(n.changed),...r.map(n.removed)].join(`. `)}function ke({rows:e,labelledBy:t,onChoose:n,onBack:r,onLeave:i,radio:a,emptyMessage:o}){let s=O()??!1,c=A(),l=(0,K.useRef)(null),u=(0,K.useRef)(!1),d=(0,K.useRef)({text:``,at:0}),[p,m]=(0,K.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[h,g]=(0,K.useState)(null),_=()=>Array.from(l.current?.querySelectorAll(`[data-row]`)??[]),v=e=>{let t=l.current;e&&t&&(e.focus({preventScroll:!0}),e.offsetTop<t.scrollTop?t.scrollTop=e.offsetTop:e.offsetTop+e.offsetHeight>t.scrollTop+t.clientHeight&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight))};function y(t){let i=_(),a=i.indexOf(document.activeElement),o=e=>{t.preventDefault(),u.current=!1,v(i[e])};if(t.key===`ArrowDown`)return o(a<0?0:(a+1)%i.length);if(t.key===`ArrowUp`)return o(a<0?i.length-1:(a-1+i.length)%i.length);if(t.key===`Home`)return o(0);if(t.key===`End`)return o(i.length-1);if(t.key===`ArrowRight`&&a>=0&&e[a]?.drill){t.preventDefault(),n(e[a],!0);return}if(t.key===`ArrowLeft`&&r){t.preventDefault(),r(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();d.current={text:e-d.current.at<700?d.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let n=[...i.slice(a+(d.current.text.length>1?0:1)),...i.slice(0,a+(d.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(d.current.text));n&&o(i.indexOf(n))}}function b(e){let t=e.target.closest(`[data-row]`);if(!t)return;m(_().indexOf(t));let n=u.current&&!s,r=!u.current&&t.matches(`:focus-visible`);g(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function x(e){l.current?.contains(e.relatedTarget)||g(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,J.jsxs)(`div`,{ref:l,className:q.list,role:`menu`,"aria-labelledby":t,"data-current":c?``:void 0,onKeyDown:y,onFocus:b,onBlur:x,onPointerLeave:()=>{u.current&&l.current?.contains(document.activeElement)&&i()},children:[(0,J.jsx)(N.span,{className:q.highlight,"data-ring":h?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:h?{y:h.top,height:h.height,opacity:+!!h.shown}:{opacity:0},transition:{default:h?.glide?f.spring.snappy:X,opacity:{duration:s?0:.08}}}),e.length===0?(0,J.jsx)(`p`,{className:q.noOptions,children:o}):null,e.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:q.item,role:a?`menuitemradio`:`menuitem`,"aria-checked":a?!!e.checked:void 0,tabIndex:t===p?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{u.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>n(e,t.detail===0),children:[e.icon?(0,J.jsx)(`span`,{className:q.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,J.jsx)(`span`,{className:q.itemLabel,children:e.label}),e.meta?(0,J.jsx)(`span`,{className:q.itemMeta,children:e.meta}):null]},e.key))]})}function Ae(e){let t={left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight};for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){let e=getComputedStyle(n);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let r=n.getBoundingClientRect();e.overflowX!==`visible`&&(t.left=Math.max(t.left,r.left),t.right=Math.min(t.right,r.right)),e.overflowY!==`visible`&&(t.top=Math.max(t.top,r.top),t.bottom=Math.min(t.bottom,r.bottom))}return t}function je({fields:e,onSelect:t,active:n=[],label:r=`Add filter`,align:i=`end`,messages:a}){let o={...De,...a},s=O()??!1,c=(0,K.useId)(),l=`${c}panel`,u=`${c}title`,d=(0,K.useRef)(null),p=(0,K.useRef)(null),m=(0,K.useRef)(null),h=(0,K.useRef)(`closed`),g=(0,K.useRef)(0),_=(0,K.useRef)(null),[v,b]=(0,K.useState)(`closed`),[x,S]=(0,K.useState)(null),[C,T]=(0,K.useState)(1),[E,D]=(0,K.useState)(!1),[k,A]=(0,K.useState)(`100% 0`),j=P(`100%`),M=P(`100%`),F=P(0),I=P(0),L=z(()=>I.get()-F.get()),R=P(0),ie=P(0),B=z(()=>{let e=j.get(),t=R.get(),n=ie.get();return typeof e==`number`?n>t?ve((e-t)/(n-t)):1:0}),V=z(()=>ve(B.get()/.35)),H=z(()=>ve((B.get()-.4)/.5)),ae={opacity:z(()=>1-V.get()),scale:z(()=>1-V.get()*.04),filter:z(()=>V.get()?Z(V.get()*f.blur.subtle):`none`)},oe={opacity:H,transformOrigin:k,scale:z(()=>.96+H.get()*.04),y:z(()=>(1-H.get())*(E?-6:6)),filter:z(()=>H.get()===1?`none`:Z((1-H.get())*f.blur.soft))},U=v===`open`,W=e.find(e=>e.id===x)??null,se=(0,K.useCallback)(e=>{let t=p.current,n=m.current;if(!t||!n)return;let r=t.getBoundingClientRect(),a=n.offsetWidth+2,o=n.offsetHeight+2,c=Ae(d.current??t),l=c.left+16-r.left,u=c.right-16-r.left-a,v=r.width-a,x=i===`end`?v>=l?v:0<=u?0:v:0<=u?0:v>=l?v:0;x=Math.round(Math.min(Math.max(x,l),Math.max(l,u)));let C=c.bottom-r.top,w=r.bottom-c.top,E=C<o+16&&w>C;h.current===`closed`&&(j.jump(r.width),M.jump(r.height),F.jump(0)),I.jump(x),R.jump(r.width),ie.jump(a),h.current=`open`,g.current+=1,_.current=e,b(`open`),D(E),S(null),T(-1),A(`${Math.round(r.width/2-x)}px ${E?`100%`:`0`}`);let O=s?X:f.spring.morph;y(F,x,O),y(j,a,O),y(M,o,O)},[i,R,M,F,s,I,ie,j]),G=(0,K.useCallback)(e=>{let t=p.current;if(h.current!==`open`||!t)return;h.current=`closing`;let n=g.current+=1;b(`closing`),e&&t.focus({preventScroll:!0,focusVisible:e===`keyboard`});let r=s?X:f.spring.snappy;y(F,0,r);let i=t.getBoundingClientRect();y(M,i.height,r),y(j,i.width,{...r,onComplete:()=>{n===g.current&&(h.current=`closed`,j.jump(`100%`),M.jump(`100%`),b(`closed`),S(null))}})},[M,F,s,j]);(0,K.useLayoutEffect)(()=>{let e=m.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{h.current===`open`&&y(M,e.offsetHeight+2,s?X:f.spring.smooth)});return t.observe(e),()=>t.disconnect()},[M,s]),(0,K.useLayoutEffect)(()=>{let e=_.current,t=m.current;if(!e||!t||v!==`open`)return;if(_.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[v,x]),(0,K.useEffect)(()=>{if(v!==`open`)return;let e=e=>{let t=d.current,n=e.target;!t||n&&t.contains(n)||(G(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&p.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[G,v]);function ce(e){if(e.defaultPrevented)return;let t=Array.from(m.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&W&&(e.preventDefault(),le(!0))}function le(e){W&&(_.current=e?{key:W.id}:`panel`,T(-1),S(null))}function ue(e,t){_.current=t?`checked`:`panel`,T(1),S(e.key)}function de(e,n){W&&(t({id:W.id,label:W.label,value:e.key,valueLabel:e.label},W),G(n?`keyboard`:`pointer`))}let fe=e=>n.find(t=>t.id===e.id),pe=e.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,J.jsxs)(J.Fragment,{children:[fe(e)?(0,J.jsx)(`span`,{className:q.metaValue,children:Te(fe(e))}):null,(0,J.jsx)(ne,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),me=W?W.options.map(ye).map(e=>{let t=be(e),n=fe(W)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,J.jsxs)(J.Fragment,{children:[e.hint==null?null:(0,J.jsx)(`span`,{className:q.hint,children:e.hint}),(0,J.jsx)(`span`,{className:q.check,"data-on":n||void 0,children:(0,J.jsx)(ee,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],he={enter:e=>s?{opacity:0}:{opacity:0,x:e*18,filter:Z(f.blur.soft)},center:{opacity:1,x:0,filter:Z(0),transition:s?_e:{...Y,x:f.spring.smooth}},exit:e=>s?{opacity:0,transition:X}:{opacity:0,x:e*-18,filter:Z(f.blur.subtle),transition:ge}};return(0,J.jsxs)(`div`,{ref:d,className:q.menu,"data-state":v,"data-y":E?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&h.current===`open`&&(e.preventDefault(),e.stopPropagation(),G(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;h.current===`open`&&t&&!d.current?.contains(t)&&G(!1)},children:[(0,J.jsx)(`button`,{ref:p,type:`button`,className:q.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":U,"aria-controls":l,tabIndex:U?-1:void 0,onClick:e=>{h.current!==`open`&&se(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),se(e.key===`ArrowDown`?`first`:`last`))},children:(0,J.jsxs)(N.span,{className:q.face,style:ae,children:[(0,J.jsx)(re,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),r]})}),(0,J.jsx)(N.div,{className:q.surface,style:{left:F,width:j,height:M},children:(0,J.jsx)(N.div,{ref:m,id:l,className:q.panel,role:`dialog`,"aria-labelledby":u,tabIndex:-1,inert:!U,style:{x:L},onKeyDown:ce,children:(0,J.jsxs)(N.div,{style:oe,children:[(0,J.jsxs)(`div`,{className:q.head,children:[(0,J.jsx)(w,{initial:!1,children:W?(0,J.jsx)(N.button,{type:`button`,className:q.back,"aria-label":o.back,onClick:e=>le(e.detail===0),initial:s?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:s?{opacity:0,transition:X}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...f.spring.snappy,opacity:ge}},transition:s?_e:{...f.spring.snappy,opacity:Y},children:(0,J.jsx)(te,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,J.jsx)(`span`,{className:q.title,id:u,children:(0,J.jsx)(w,{mode:`popLayout`,initial:!1,children:(0,J.jsx)(N.span,{className:q.titleText,...xe(s),children:W?W.label:r},W?.id??`fields`)})})]}),(0,J.jsx)(`div`,{className:q.stage,children:(0,J.jsx)(w,{mode:`popLayout`,initial:!1,custom:C,children:(0,J.jsx)(N.div,{className:q.step,custom:C,variants:he,initial:`enter`,animate:`center`,exit:`exit`,children:W?(0,J.jsx)(ke,{rows:me,labelledBy:u,emptyMessage:o.noOptions,radio:!0,onChoose:de,onBack:le,onLeave:()=>m.current?.focus({preventScroll:!0})}):(0,J.jsx)(ke,{rows:pe,labelledBy:u,emptyMessage:o.noOptions,onChoose:ue,onLeave:()=>m.current?.focus({preventScroll:!0})})},W?.id??`fields`)})})]})})})]})}function Me({filters:e,onRemove:t,onClearAll:n,leading:r,children:i,label:a=`Active filters`,addFilter:o,messages:s}){let c={...De,...s},l=O()??!1,u=(0,K.useRef)(null),d=(0,K.useRef)(null),p=(0,K.useRef)(0),m=(0,K.useRef)(null),[h,g]=(0,K.useState)(e),[_,v]=(0,K.useState)(``);if(h!==e){g(e);let t=Oe(h,e,c);t&&v(t)}let y=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,K.useLayoutEffect)(()=>{p.current=performance.now()+900},[y]);let b=Ce(d,p,l);we(d,p,l),(0,K.useLayoutEffect)(()=>{let t=m.current,n=u.current;if(t===null||!n)return;m.current=null;let r=e[Math.min(t,e.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[e]);let x={duration:0},S=e=>({initial:!l&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:l?{opacity:0,transition:x}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...f.spring.smooth,"--slot-moving":x}},transition:l?x:f.spring.smooth}),C={initial:!l&&{opacity:0,scale:.9,filter:Z(f.blur.soft)},animate:{opacity:1,scale:1,filter:Z(0)},exit:l?{opacity:0,transition:x}:{opacity:0,scale:.9,filter:Z(f.blur.subtle),transition:ge},transition:l?x:{...Y,scale:f.spring.snappy}},T=l?{...xe(!0),initial:!1}:xe(!1),E=l?T:{...T,transition:{...Y,delay:f.duration.instant*.75}};return(0,J.jsxs)(`div`,{ref:u,className:q.toolbar,role:`group`,"aria-label":a,children:[r?(0,J.jsx)(`div`,{className:q.leading,children:r}):null,(0,J.jsx)(N.div,{className:q.frame,style:{height:b},children:(0,J.jsxs)(`div`,{ref:d,className:q.chips,children:[(0,J.jsx)(w,{initial:!1,children:e.map((e,n)=>(0,J.jsx)(N.span,{className:q.slot,...S(8),children:(0,J.jsxs)(N.span,{className:q.chip,...C,children:[(0,J.jsxs)(`span`,{className:q.chipLabel,title:Ee(e),children:[e.label,Te(e)?(0,J.jsxs)(`span`,{className:q.value,children:[(0,J.jsx)(`span`,{className:q.separator,children:` · `}),(0,J.jsx)(Se,{text:Te(e)})]}):null]}),(0,J.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":c.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(m.current=n),t(e.id)},children:(0,J.jsx)(ae,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,J.jsx)(w,{initial:!1,children:e.length?null:(0,J.jsx)(N.span,{className:q.empty,...E,children:c.empty},`empty`)})]})}),(0,J.jsxs)(`div`,{className:q.actions,children:[o?(0,J.jsx)(je,{fields:o.fields,onSelect:o.onAdd,active:e,label:o.label,align:o.align,messages:c}):null,i,(0,J.jsx)(w,{initial:!1,children:e.length>0&&n?(0,J.jsx)(N.span,{className:q.slot,...S(12),children:(0,J.jsx)(`button`,{className:q.clear,type:`button`,onClick:()=>{m.current=-1,n?.()},children:(0,J.jsx)(N.span,{className:q.clearText,...T,children:c.clearAll})})},`clear`):null})]}),(0,J.jsx)(`span`,{className:q.srOnly,role:`status`,children:_})]})}var Ne={api_key:`settings.privacy.category.api_key`,aws_key:`settings.privacy.category.aws_key`,jwt:`settings.privacy.category.jwt`,private_key:`settings.privacy.category.private_key`,email:`settings.privacy.category.email`,phone:`settings.privacy.category.phone`,intranet:`settings.privacy.category.intranet`,credit_card:`settings.privacy.category.credit_card`,national_id:`settings.privacy.category.national_id`,credential:`settings.privacy.category.credential`,passport:`settings.privacy.category.passport`,iban:`settings.privacy.category.iban`,mac:`settings.privacy.category.mac`,ip:`settings.privacy.category.ip`,birthday:`settings.privacy.category.birthday`,serial:`settings.privacy.category.serial`,home_user:`settings.privacy.category.home_user`,custom:`settings.privacy.category.custom`},Pe=[`ip`,`home_user`],Fe={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Ie(){let{t:e}=p();return t=>{let n=Ne[t];return n?e(n):t}}function Le({action:e}){let{t}=p();return(0,J.jsx)(u,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Fe[e]??`settings.privacy.action.warn`)})}var Re=50,ze=[`block`,`redact`,`warn`];function Be(){let{t:e,locale:t}=p(),n=Ie(),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)({client:``,category:``,action:``,blocked:``}),[c,l]=(0,K.useState)(1),[u,f]=(0,K.useState)(null),m=G(i),_=C(),v=E(),{toast:y,confirm:x}=R(),w=M(),O={model:m,...o,page:c,pageSize:Re},k=j(O,c===1),A=k.data,N=A?Math.max(1,Math.ceil(A.total/Re)):1,P=e=>e?ue[e]?.name??e:`—`,F=[...new Set((v.data?.rules??[]).map(e=>e.category))],L={client:(_.data??[]).map(e=>({value:e.kind,label:e.name})),category:F.map(e=>({value:e,label:n(e)})),action:ze.map(t=>({value:t,label:e(`settings.privacy.action.${t}`)})),blocked:[{value:`true`,label:e(`privacy.logs.blockedOnly`)},{value:`false`,label:e(`privacy.logs.passedOnly`)}]},z={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},ee=Object.keys(L).map(e=>({id:e,label:z[e],options:L[e].map(e=>e.label)})),te=Object.keys(o).filter(e=>o[e]).map(e=>({id:e,label:z[e],value:L[e].find(t=>t.value===o[e])?.label??o[e]})),ne=(e,t)=>{s(n=>({...n,[e]:t})),l(1)},re=(A?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:P(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),B=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,J.jsx)(`span`,{className:`num`,children:b(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,J.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>f(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,J.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,J.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:P(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,J.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,J.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,J.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,J.jsx)(h,{className:`w-52`,value:i,onChange:e=>{a(e),l(1)},placeholder:e(`requests.searchModel`)}),(0,J.jsx)(D,{variant:`plain`,icon:(0,J.jsx)(ie,{className:T(`size-4`,k.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void k.refetch()}),(0,J.jsx)(D,{variant:`plain`,className:`ml-auto`,icon:(0,J.jsx)(H,{className:`size-4`}),disabled:w.isPending||!A||A.total===0,onClick:async()=>{await x({title:e(`privacy.logs.clearConfirm`),detail:e(`privacy.logs.clearDetail`),confirmLabel:e(`privacy.logs.clear`),destructive:!0})&&w.mutate(void 0,{onSuccess:t=>{l(1),y(e(`privacy.logs.cleared`,{count:S(t.cleared)}),`success`)},onError:e=>y(I(e),`error`)})},children:e(`privacy.logs.clear`)})]}),(0,J.jsx)(`div`,{className:`mb-3`,children:(0,J.jsx)(Me,{label:e(`requests.filters`),filters:te,onRemove:e=>ne(e,``),onClearAll:()=>{s({client:``,category:``,action:``,blocked:``}),l(1)},addFilter:{fields:ee,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=L[t].find(t=>t.label===e.value)?.value;n&&ne(t,n)}}})}),k.isLoading&&(0,J.jsx)(g,{lines:4,className:`py-6`}),k.isError&&(0,J.jsx)(r,{tone:`danger`,title:e(`common.error`),children:I(k.error)}),A&&A.items.length===0&&(0,J.jsx)(d,{icon:(0,J.jsx)(V,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),A&&A.items.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:S(A.total)})}),(0,J.jsx)(oe,{caption:e(`privacy.tab.logs`),rows:re,columns:B,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),A&&N>1&&(0,J.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,J.jsx)(de,{page:c,pageCount:N,onPageChange:l,label:e(`requests.page`,{page:c,pages:N})})}),(0,J.jsx)(me,{id:u,onClose:()=>f(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=p();return e.blocked?(0,J.jsx)(u,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,J.jsx)(u,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,J.jsx)(u,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,J.jsx)(u,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Ie(),{t:n}=p();if(e.hits.length===0)return(0,J.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,J.jsx)(Le,{action:e.action}),(0,J.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,J.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_fc0qq_1`,label:`_label_fc0qq_3`,value:`_value_fc0qq_7`,column:`_column_fc0qq_11`,sizer:`_sizer_fc0qq_13`,glyph:`_glyph_fc0qq_15`,labelText:`_labelText_fc0qq_17`,labelSwap:`_labelSwap_fc0qq_19`,symbol:`_symbol_fc0qq_21`,srOnly:`_srOnly_fc0qq_23`},We=[0,1,2,3,4,5,6,7,8,9],Ge={hidden:{opacity:0,y:`0.3em`,filter:`blur(${f.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:f.duration.standard,ease:[...f.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${f.blur.subtle}px)`,transition:{duration:f.duration.fast,ease:[...f.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:f.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:f.duration.instant}}},qe={...f.spring.smooth,visualDuration:f.duration.considered};function Je(e,t,n){let r=new Intl.NumberFormat(n,{minimumFractionDigits:t,maximumFractionDigits:t,numberingSystem:`latn`}).formatToParts(e),i=r.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),a=0,o=0;return r.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--i}`,digit:Number(e),order:o++})):e.type===`fraction`?[...e.value].map(e=>({key:`f${a++}`,digit:Number(e),order:o++})):[{key:e.type===`group`?`g${i}`:e.type===`decimal`?`d`:`${e.type}${t}`,text:e.value}])}function Ye({position:e,digit:t}){let n=z(e,e=>((t-e)%10+15)%10-5),r=z(n,e=>`${e}em`),i=z(n,e=>Math.max(0,1-Math.abs(e))),a=z(n,e=>Math.abs(e)>=1?`hidden`:`visible`),o=z(n,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*f.blur.subtle).toFixed(2)}px)`);return(0,J.jsx)(N.span,{className:Q.glyph,style:{y:r,opacity:i,filter:o,visibility:a},children:t})}var Xe={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Ze({digit:e,direction:t,armed:n,delay:r,reduceMotion:i}){let a=P(n?0:e),o=(0,K.useRef)({digit:n?0:e,target:n?0:e,revealed:!n});return(0,K.useEffect)(()=>{let s=o.current;if(n||s.digit===e){n||(s.revealed=!0);return}s.target+=t<0&&s.revealed?-((s.digit-e+10)%10):(e-s.digit+10)%10,s.digit=e,i?a.jump(s.target):y(a,s.target,s.revealed?f.spring.smooth:{...qe,delay:r}),s.revealed=!0},[n,r,e,t,a,i]),(0,J.jsxs)(N.span,{className:Q.column,...Xe,transition:i?{duration:0}:f.spring.morph,children:[(0,J.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,J.jsx)(Ye,{position:a,digit:e},e))]})}function Qe({value:e,label:t,prefix:n=``,suffix:r=``,decimals:i=0,animateOnView:a=!1,locale:o=`en-US`}){let s=(0,K.useRef)(null),c=pe(s,{once:!0,amount:.6}),l=!!O(),[u,d]=(0,K.useState)(e),[p,m]=(0,K.useState)(1);e!==u&&(d(e),m(e>u?1:-1));let h=Je(e,i,o),g=`${n}${h.map(e=>`text`in e?e.text:e.digit).join(``)}${r}`,_=a&&!c;return(0,J.jsxs)(`span`,{ref:s,className:Q.counter,children:[t&&(0,J.jsx)(`span`,{className:Q.label,children:(0,J.jsx)(`span`,{className:Q.labelSwap,children:(0,J.jsx)(w,{mode:`popLayout`,initial:!1,children:(0,J.jsx)(N.span,{className:Q.labelText,variants:l?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})})}),(0,J.jsx)(`span`,{className:Q.srOnly,children:g}),(0,J.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[n&&(0,J.jsx)(`span`,{className:Q.symbol,children:n}),(0,J.jsx)(w,{initial:!1,children:h.map(e=>`digit`in e?(0,J.jsx)(Ze,{digit:e.digit,direction:p,armed:_,delay:Math.min(e.order*f.stagger.item,.25),reduceMotion:l},e.key):(0,J.jsx)(N.span,{className:Q.symbol,...Xe,transition:l?{duration:0}:f.spring.morph,children:e.text},e.key))}),r&&(0,J.jsx)(`span`,{className:Q.symbol,children:r})]})]})}var $={card:`_card_m34o3_1`,top:`_top_m34o3_3`,swap:`_swap_m34o3_15`,swapBlock:`_swapBlock_m34o3_15`,text:`_text_m34o3_21`,sizer:`_sizer_m34o3_25`},$e={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${f.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:f.duration.standard,ease:[...f.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${f.blur.subtle}px)`,transition:{duration:f.duration.fast,ease:[...f.ease.standard]}})},et={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:f.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:f.duration.instant}}},tt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function nt({text:e,morph:t=!1,block:n=!1}){let r=!!O(),i=(0,K.useRef)(null),a=P(`auto`),[o,s]=(0,K.useState)({text:e,direction:1});return o.text!==e&&s({text:e,direction:tt(e)<tt(o.text)?-1:1}),(0,K.useEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,n=new ResizeObserver(([n])=>{let i=n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;i&&t!==null&&t!==e.textContent&&!r?y(a,i,f.spring.morph):a.jump(i||`auto`),t=i?e.textContent:null});return n.observe(e),()=>n.disconnect()},[t,r,a]),(0,J.jsxs)(N.span,{className:n?$.swapBlock:$.swap,style:t?{width:a}:void 0,children:[t&&(0,J.jsx)(`span`,{ref:i,className:$.sizer,"aria-hidden":`true`,children:e}),(0,J.jsx)(w,{mode:`popLayout`,initial:!1,custom:o.direction,children:(0,J.jsx)(N.span,{className:$.text,custom:o.direction,variants:r?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:e},e)})]})}function rt({label:e,value:t,suffix:n,context:r,change:i}){let a=!!O();return(0,J.jsxs)(`article`,{className:$.card,children:[(0,J.jsxs)(`div`,{className:$.top,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(nt,{text:e,block:!0})}),(0,J.jsx)(w,{initial:!1,children:i&&(0,J.jsx)(N.small,{"data-trend":/^[+]/.test(i)?`up`:/^[-−]/.test(i)?`down`:void 0,initial:{opacity:0,scale:a?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:a?1:.96,transition:{duration:f.duration.fast,ease:[...f.ease.standard]}},transition:a?{duration:0}:f.spring.snappy,children:(0,J.jsx)(nt,{text:i,morph:!0})},`change`)})]}),(0,J.jsx)(Qe,{value:t,suffix:n,animateOnView:!0}),(0,J.jsx)(`p`,{children:(0,J.jsx)(nt,{text:r,block:!0})})]})}var it=[{id:`ipv4-all`,nameKey:`settings.privacy.template.ipv4All`,hintKey:`settings.privacy.template.ipv4AllHint`,pattern:String.raw`(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])`},{id:`landline`,nameKey:`settings.privacy.template.landline`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<!\d)0\d{2,3}[- ]?\d{7,8}(?!\d)`},{id:`license-plate`,nameKey:`settings.privacy.template.licensePlate`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]`},{id:`passport-cn`,nameKey:`settings.privacy.template.passportCn`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])[EG]\d{8}(?!\d)`},{id:`uscc`,nameKey:`settings.privacy.template.uscc`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-HJ-NPQRTUWXY])[0-9A-HJ-NPQRTUWXY]{18}(?![0-9A-HJ-NPQRTUWXY])`},{id:`long-token`,nameKey:`settings.privacy.template.longToken`,hintKey:`settings.privacy.template.longTokenHint`,pattern:String.raw`(?<![A-Za-z0-9])[A-Za-z0-9_\-]{32,}(?![A-Za-z0-9])`},{id:`mac-address`,nameKey:`settings.privacy.template.macAddress`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-Fa-f:])(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}(?![0-9A-Fa-f:])`},{id:`unix-home`,nameKey:`settings.privacy.template.unixHome`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`/(?:Users|home)/[A-Za-z0-9_.\-]+`},{id:`windows-profile`,nameKey:`settings.privacy.template.windowsProfile`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`[A-Za-z]:\\+Users\\+[A-Za-z0-9_.\-]+`},{id:`cloud-accesskey`,nameKey:`settings.privacy.template.cloudAccessKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:LTAI[A-Za-z0-9]{12,20}|AKID[A-Za-z0-9]{13,40})(?![A-Za-z0-9])`},{id:`aws-secret-key`,nameKey:`settings.privacy.template.awsSecretKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=])`},{id:`im-webhook`,nameKey:`settings.privacy.template.imWebhook`,hintKey:`settings.privacy.template.imWebhookHint`,pattern:String.raw`oapi\.dingtalk\.com/robot/send\?access_token=[0-9a-f]{64}|qyapi\.weixin\.qq\.com/cgi-bin/webhook/send\?key=[0-9a-f]{32}|open\.feishu\.cn/open-apis/bot/v2/hook/[0-9a-f\-]{20,}|hooks\.slack\.com/services/T[A-Za-z0-9]+/B[A-Za-z0-9]+/[A-Za-z0-9]+`},{id:`internal-service`,nameKey:`settings.privacy.template.internalService`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:gitlab|jenkins|jira|confluence|wiki|nexus|harbor|grafana|kibana|sonarqube|oa|sso)\.[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)+`},{id:`jdbc-conn`,nameKey:`settings.privacy.template.jdbcConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`jdbc:[A-Za-z0-9]+:[^\s"']*(?:[Uu]ser(?:[ _]?[Ii][Dd])?|[Pp]assword)=[^\s"&';]+`},{id:`smtp-conn`,nameKey:`settings.privacy.template.smtpConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`(?:smtp|imap|pop3)s?://[^\s:@/]+:[^\s@]+@[^\s]+`},{id:`key-file-ref`,nameKey:`settings.privacy.template.keyFileRef`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[A-Za-z0-9_\-./\\]+\.(?:pem|key|pfx|p12|jks|keystore)\b`},{id:`confidential-marker`,nameKey:`settings.privacy.template.confidentialMarker`,hintKey:`settings.privacy.template.confidentialHint`,pattern:String.raw`(?:绝密|机密|商业秘密|内部资料|内部公开|仅限内部|请勿外传|Confidential|Internal Use Only|Internal Only|Company Private)`},{id:`employee-id`,nameKey:`settings.privacy.template.employeeId`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:[Ee][Mm][Pp]|工号)[::\- ]?\d{4,10}(?!\d)`},{id:`labeled-number`,nameKey:`settings.privacy.template.labeledNumber`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:合同|订单|采购单|工单|项目)编号[::]?\s*[A-Za-z0-9_\-]{4,32}`}],at=[`off`,`warn`,`block`,`redact`],ot=Fe;function st(){let{t:e}=p(),{toast:t}=R(),r=E(),i=_(),o=r.data?.settings,c=e=>{o&&i.mutate({...o,...e},{onError:e=>t(I(e),`error`)})},l=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,J.jsxs)(s,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[r.isLoading&&(0,J.jsx)(g,{className:`my-4`}),r.isError&&(0,J.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:I(r.error)}),o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(n,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,J.jsx)(a,{checked:o.enabled,label:e(`settings.privacy.enabled`),onChange:e=>c({enabled:e})})}),(0,J.jsx)(n,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,J.jsx)(a,{checked:o.dryRun,disabled:!o.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>c({dryRun:e})})}),(0,J.jsx)(n,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,J.jsx)(a,{checked:o.restoreResponses,disabled:!o.enabled,label:e(`settings.privacy.restore`),onChange:e=>c({restoreResponses:e})})}),(0,J.jsx)(n,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,J.jsx)(a,{checked:o.recordSamples,disabled:!o.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>c({recordSamples:e})})}),(0,J.jsx)(n,{label:e(`settings.privacy.recordFullSamples`),detail:e(`settings.privacy.recordFullSamplesHint`),children:(0,J.jsx)(a,{checked:o.recordFullSamples,disabled:!o.enabled||!o.recordSamples,label:e(`settings.privacy.recordFullSamples`),onChange:e=>c({recordFullSamples:e})})}),(0,J.jsx)(n,{label:e(`settings.privacy.defaultAction`),children:(0,J.jsx)(L,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:o.defaultAction,disabled:!o.enabled,onChange:e=>c({defaultAction:e}),options:l})})]})]})}function ct(){let{t:e}=p(),{toast:t}=R(),r=E(),i=_(),a=r.data?.settings,o=Ie(),c=e=>{a&&i.mutate({...a,...e},{onError:e=>t(I(e),`error`)})},l=(e,t)=>c({categoryActions:{...a?.categoryActions,[e]:t}}),d=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),f=[...new Set((r.data?.rules??[]).map(e=>e.category))],m=e=>r.data?.rules.find(t=>t.category===e)?.description;return r.isLoading?(0,J.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,J.jsx)(g,{className:`my-4`})}):a?(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,J.jsx)(s,{title:e(`settings.privacy.categories`),children:f.map(t=>{let r=a.categoryActions[t]??(Pe.includes(t)?`off`:a.defaultAction),i=!a.enabled||r===`off`;return(0,J.jsxs)(n,{label:o(t),detail:m(t),children:[r===`off`?(0,J.jsx)(u,{children:e(`settings.privacy.action.off`)}):(0,J.jsx)(L,{className:`w-36`,ariaLabel:o(t),value:r,disabled:!a.enabled,onChange:e=>l(t,e),options:d.filter(e=>e.value!==`off`)}),i&&(0,J.jsx)(D,{size:`sm`,variant:`plain`,disabled:!a.enabled,onClick:()=>l(t,a.defaultAction===`off`?`warn`:a.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,J.jsx)(lt,{s:a,onPatch:c})]}):null}function lt({s:e,onPatch:t}){let{t:r}=p(),{confirm:i}=R(),[o,c]=(0,K.useState)(!1),l=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),u=async n=>{await i({title:r(`settings.privacy.deleteRuleConfirm`,{name:n.name}),destructive:!0,confirmLabel:r(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==n.id)})};return(0,J.jsxs)(s,{title:r(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,J.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:r(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,J.jsxs)(n,{label:t.name,detail:t.pattern,children:[(0,J.jsx)(a,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>l(t,e)}),(0,J.jsx)(D,{size:`sm`,variant:`plain`,icon:(0,J.jsx)(H,{className:`size-3.5`}),"aria-label":`${r(`common.delete`)} ${t.name}`,onClick:()=>void u(t)})]},t.id)),(0,J.jsx)(`div`,{className:`px-4 py-2`,children:(0,J.jsx)(D,{size:`sm`,icon:(0,J.jsx)(re,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>c(!0),children:r(`settings.privacy.addRule`)})}),(0,J.jsx)(ut,{open:o,onOpenChange:c,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=p(),{toast:a}=R(),[o,s]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,m]=(0,K.useState)(``);return(0,J.jsx)(F,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(D,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,J.jsx)(D,{variant:`primary`,disabled:!o.trim()||!u.trim(),onClick:()=>{if(o.trim()&&u.trim()){try{new RegExp(u)}catch(e){a(`${r(`settings.privacy.invalidPattern`)}: ${I(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:o.trim(),pattern:u.trim(),enabled:!0}),s(``),d(``),m(``),t(!1)}},children:r(`common.create`)})]}),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(i,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,J.jsx)(L,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:f,onChange:e=>{m(e);let t=it.find(t=>t.id===e);t&&(s(r(t.nameKey)),d(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,J.jsx)(l,{label:r(`settings.privacy.ruleName`),value:o,onChange:e=>s(e.target.value),autoFocus:!0}),(0,J.jsx)(i,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,J.jsx)(c,{mono:!0,rows:3,value:u,onChange:e=>d(e.target.value)})})]})})}function dt(){let{t:e}=p(),{toast:t}=R(),n=Ie(),r=E(),i=v(),[a,o]=(0,K.useState)(``),l=i.data,d=r.data?.settings.enabled??!1;return(0,J.jsx)(s,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,J.jsx)(c,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>o(e.target.value)}),(0,J.jsx)(`div`,{children:(0,J.jsx)(D,{icon:(0,J.jsx)(B,{className:`size-3.5`}),disabled:!d||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(I(e),`error`)}),children:e(`settings.privacy.runTest`)})}),l&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l.blocked&&(0,J.jsx)(u,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),l.wouldRedact>0&&(0,J.jsx)(u,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:l.wouldRedact})}),!l.blocked&&l.wouldRedact===0&&(0,J.jsx)(u,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),l.maskedText&&(0,J.jsxs)(`div`,{className:`mt-2`,children:[(0,J.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:e(`settings.privacy.maskedText`)}),(0,J.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-[11px]`,children:l.maskedText})]}),l.hits.length>0&&(0,J.jsx)(`ul`,{className:`mt-2 space-y-1`,children:l.hits.map(t=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(u,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,J.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t:e}=p(),t=Ie(),[n,i]=(0,K.useState)(`7d`),a=k(n),s=a.data,c=[{key:`category`,label:e(`privacy.stats.col.category`),render:e=>t(String(e))},{key:`requests`,label:e(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:e(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:e(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:e(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:e(`privacy.stats.col.redact`),numeric:!0,width:84}],l=(s?.categories??[]).map(e=>({...e}));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`section`,{children:[(0,J.jsx)(o,{action:(0,J.jsx)(m,{ariaLabel:e(`overview.range`),value:n,onChange:i,items:ft.map(t=>({value:t,label:e(`range.${t}`)}))}),children:e(`privacy.stats`)}),a.isLoading&&(0,J.jsx)(g,{lines:3,className:`py-4`}),a.isError&&(0,J.jsx)(r,{tone:`danger`,title:e(`common.error`),children:I(a.error)}),s&&(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,J.jsx)(rt,{label:e(`privacy.stats.events`),value:s.events,context:e(`range.${n}`)}),(0,J.jsx)(rt,{label:e(`privacy.stats.blocked`),value:s.blocked,context:e(`range.${n}`)}),(0,J.jsx)(rt,{label:e(`privacy.stats.redactions`),value:s.redactions,context:e(`range.${n}`)}),(0,J.jsx)(rt,{label:e(`privacy.stats.dryRun`),value:s.dryRun,context:e(`range.${n}`)})]})]}),(0,J.jsxs)(`section`,{children:[(0,J.jsx)(o,{children:e(`privacy.stats.byCategory`)}),s&&s.categories.length===0&&(0,J.jsx)(`div`,{className:`card`,children:(0,J.jsx)(mt,{})}),s&&s.categories.length>0&&(0,J.jsx)(oe,{caption:e(`privacy.stats.byCategory`),rows:l,columns:c,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,J.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,J.jsx)(st,{})})]})}function mt(){let{t:e}=p();return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,J.jsx)(B,{className:`size-6 text-[var(--text-muted)]`}),(0,J.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,J.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=p(),{tab:t}=se(),n=le(),r=ht.includes(t)?t:`overview`;return(0,J.jsx)(he,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,J.jsxs)(W,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,J.jsx)(ce,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,J.jsx)(fe,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,J.jsx)(U,{value:`overview`,className:`pt-5`,children:(0,J.jsx)(pt,{})}),(0,J.jsx)(U,{value:`logs`,className:`pt-4`,children:(0,J.jsx)(Be,{})}),(0,J.jsx)(U,{value:`rules`,className:`pt-5`,children:(0,J.jsx)(ct,{})}),(0,J.jsx)(U,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,J.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
|