@chenpu17/cc-gw 0.8.11 → 0.8.14
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/package.json +5 -5
- package/src/web/dist/assets/{About-BXBR_bL5.js → About-pcECYYVj.js} +1 -1
- package/src/web/dist/assets/{ApiKeys-Bc7INW0n.js → ApiKeys-IDt4ZfLj.js} +1 -1
- package/src/web/dist/assets/{ConfirmDialog-CPNJmevF.js → ConfirmDialog-oYHVEpGJ.js} +1 -1
- package/src/web/dist/assets/{Dashboard-DdisKH--.js → Dashboard-BiCTswfM.js} +1 -1
- package/src/web/dist/assets/{DialogShell-C0EfvzaN.js → DialogShell-DcOGCV8m.js} +1 -1
- package/src/web/dist/assets/{Events-ChrSkBPR.js → Events-CCYCOF1f.js} +1 -1
- package/src/web/dist/assets/{Help-CsahUtl5.js → Help-BW1R1cf1.js} +2 -2
- package/src/web/dist/assets/{Login-B-oy31QU.js → Login-Dn8fbfFq.js} +1 -1
- package/src/web/dist/assets/{Logs-L88mrDoR.js → Logs-D2FFPpBP.js} +1 -1
- package/src/web/dist/assets/{ModelManagement-BEeket-Z.js → ModelManagement-BHSUJ4Dg.js} +1 -1
- package/src/web/dist/assets/{PageHeader-bDiw2pSJ.js → PageHeader-DCqHI67a.js} +1 -1
- package/src/web/dist/assets/{PageSection-WDuhqLCi.js → PageSection-CuZMzA0E.js} +1 -1
- package/src/web/dist/assets/{PageState-KEq7s0Bk.js → PageState-B03H5AV0.js} +1 -1
- package/src/web/dist/assets/Profiler-CEpu2dMu.js +1 -0
- package/src/web/dist/assets/RoutingManagement-DahJxjA7.js +1 -0
- package/src/web/dist/assets/{Settings-B8oJpE9S.js → Settings-Vp7jGxIW.js} +1 -1
- package/src/web/dist/assets/{Skeleton-BRLpX8rl.js → Skeleton-i1PjWApN.js} +1 -1
- package/src/web/dist/assets/app-COiQeF3y.js +61 -0
- package/src/web/dist/assets/{card-7EdLPk_C.js → card-ChFVaqLf.js} +1 -1
- package/src/web/dist/assets/{charts-core-D9OugzV_.js → charts-core-DzWzxST6.js} +1 -1
- package/src/web/dist/assets/{charts-engine-DleyglMn.js → charts-engine-Ds7lwC51.js} +1 -1
- package/src/web/dist/assets/{charts-react-BqhUp1x_.js → charts-react-D0nWbUCA.js} +1 -1
- package/src/web/dist/assets/{gateway-mlUZb7iD.js → gateway-BU3dR2tm.js} +1 -1
- package/src/web/dist/assets/{global-NDOUShP9.js → global-B-NXh5qD.js} +1 -1
- package/src/web/dist/assets/global-B_hBylxt.css +1 -0
- package/src/web/dist/assets/{i18n-B3N4Df3E.js → i18n-Bl2BcCDG.js} +1 -1
- package/src/web/dist/assets/{input-BjD2rjIj.js → input-DW7jGTgj.js} +1 -1
- package/src/web/dist/assets/{label-DPJWPvWM.js → label-Ci1io7XA.js} +1 -1
- package/src/web/dist/assets/landing-BMe5-cHU.js +17 -0
- package/src/web/dist/assets/live-en-api-keys-Bx8N-eoh.png +0 -0
- package/src/web/dist/assets/live-en-dashboard-CJoX7IQT.png +0 -0
- package/src/web/dist/assets/live-en-events-DJwaP-WW.png +0 -0
- package/src/web/dist/assets/live-en-logs-BGGL53ab.png +0 -0
- package/src/web/dist/assets/live-en-model-management-BpjNblfR.png +0 -0
- package/src/web/dist/assets/package-D5lk1iqk.js +1 -0
- package/src/web/dist/assets/{popover-CMRfoAfg.js → popover-CQHCVE2z.js} +1 -1
- package/src/web/dist/assets/{query-Cpxr1dul.js → query-BbGWgOFk.js} +1 -1
- package/src/web/dist/assets/{queryKeys-CsNzv19i.js → queryKeys-ucXCzh0P.js} +1 -1
- package/src/web/dist/assets/{radix-bG5h1Ymq.js → radix-mHySgtou.js} +1 -1
- package/src/web/dist/assets/{router-DspBTS8b.js → router-CL3rf_uf.js} +1 -1
- package/src/web/dist/assets/{select-UI4HSm85.js → select-BchX45jJ.js} +1 -1
- package/src/web/dist/assets/{switch-_3mhCfFY.js → switch-CT24uL_Q.js} +1 -1
- package/src/web/dist/assets/{table-C1ufAZAv.js → table-DdvG93mx.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-Y63AiXYK.js → useApiQuery-tbd4JJaZ.js} +1 -1
- package/src/web/dist/assets/{useAppMutation-wWyqqlf8.js → useAppMutation-SONU2xFC.js} +1 -1
- package/src/web/dist/assets/useModelManagementState-DcQ0Ac-x.js +1 -0
- package/src/web/dist/assets/{vendor-LWJeAdU1.js → vendor-z22RpOY0.js} +86 -66
- package/src/web/dist/index.html +8 -8
- package/src/web/dist/landing.html +11 -11
- package/src/web/dist/assets/Profiler--DIXdL38.js +0 -1
- package/src/web/dist/assets/RoutingManagement-DgkHoHvd.js +0 -1
- package/src/web/dist/assets/app-BxSHC5_o.js +0 -61
- package/src/web/dist/assets/global-BOV4QSBB.css +0 -1
- package/src/web/dist/assets/landing-DV2hroBA.js +0 -5
- package/src/web/dist/assets/package-CVSxn1pM.js +0 -1
- package/src/web/dist/assets/useModelManagementState-BroT3Cj7.js +0 -1
package/src/web/dist/index.html
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
<link rel="apple-touch-icon" href="/cc-gw-mark.svg" />
|
|
9
9
|
<link rel="manifest" href="/site.webmanifest" />
|
|
10
10
|
<title>cc-gw 控制台</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/app-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/global-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/query-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/i18n-
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/router-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/radix-
|
|
18
|
-
<link rel="stylesheet" crossorigin href="/assets/global-
|
|
11
|
+
<script type="module" crossorigin src="/assets/app-COiQeF3y.js"></script>
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-z22RpOY0.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/global-B-NXh5qD.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/query-BbGWgOFk.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/i18n-Bl2BcCDG.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/router-CL3rf_uf.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/radix-mHySgtou.js">
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/global-B_hBylxt.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body class="bg-slate-50 text-slate-900 dark:bg-slate-900 dark:text-slate-50">
|
|
21
21
|
<div id="root"></div>
|
|
@@ -8,25 +8,25 @@
|
|
|
8
8
|
<meta name="apple-mobile-web-app-title" content="cc-gw" />
|
|
9
9
|
<meta
|
|
10
10
|
name="description"
|
|
11
|
-
content="cc-gw
|
|
11
|
+
content="cc-gw is a local-first AI gateway. 把 Claude Code、OpenAI SDK、Anthropic SDK 全部指向同一个本地入口,换模型、换 provider、查日志,再也不用翻业务代码。"
|
|
12
12
|
/>
|
|
13
13
|
<meta name="theme-color" content="#0f172a" />
|
|
14
14
|
<link rel="icon" type="image/svg+xml" href="/cc-gw-mark.svg" />
|
|
15
15
|
<link rel="apple-touch-icon" href="/cc-gw-mark.svg" />
|
|
16
16
|
<link rel="manifest" href="/site.webmanifest" />
|
|
17
|
-
<meta property="og:title" content="cc-gw |
|
|
17
|
+
<meta property="og:title" content="cc-gw | 你的 API Key 不该躺在 30 个 .env 里" />
|
|
18
18
|
<meta
|
|
19
19
|
property="og:description"
|
|
20
|
-
content="
|
|
20
|
+
content="A local-first AI gateway. One endpoint for Claude Code, OpenAI SDK, and Anthropic SDK. Switch models, swap providers, and trace requests without touching your code."
|
|
21
21
|
/>
|
|
22
22
|
<meta property="og:type" content="website" />
|
|
23
23
|
<meta property="og:image" content="/cc-gw-social-card.png" />
|
|
24
24
|
<meta property="og:image:alt" content="cc-gw landing share card showing a local-first AI gateway and daily control console" />
|
|
25
25
|
<meta name="twitter:card" content="summary_large_image" />
|
|
26
|
-
<meta name="twitter:title" content="cc-gw |
|
|
26
|
+
<meta name="twitter:title" content="cc-gw | 你的 API Key 不该躺在 30 个 .env 里" />
|
|
27
27
|
<meta
|
|
28
28
|
name="twitter:description"
|
|
29
|
-
content="
|
|
29
|
+
content="A local-first AI gateway. One endpoint for Claude Code, OpenAI SDK, and Anthropic SDK. Switch models, swap providers, and trace requests without touching your code."
|
|
30
30
|
/>
|
|
31
31
|
<meta name="twitter:image" content="/cc-gw-social-card.png" />
|
|
32
32
|
<meta name="twitter:image:alt" content="cc-gw landing share card showing a local-first AI gateway and daily control console" />
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"description": "Local-first AI gateway for personal developers and small teams who want to centralize provider configuration, routing, logs, profiler, and API key management."
|
|
42
42
|
}
|
|
43
43
|
</script>
|
|
44
|
-
<title>cc-gw |
|
|
45
|
-
<script type="module" crossorigin src="/assets/landing-
|
|
46
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-
|
|
47
|
-
<link rel="modulepreload" crossorigin href="/assets/global-
|
|
44
|
+
<title>cc-gw | 你的 API Key 不该躺在 30 个 .env 里 · local-first AI gateway</title>
|
|
45
|
+
<script type="module" crossorigin src="/assets/landing-BMe5-cHU.js"></script>
|
|
46
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-z22RpOY0.js">
|
|
47
|
+
<link rel="modulepreload" crossorigin href="/assets/global-B-NXh5qD.js">
|
|
48
48
|
<link rel="modulepreload" crossorigin href="/assets/clipboard-CALi6bTW.js">
|
|
49
|
-
<link rel="modulepreload" crossorigin href="/assets/package-
|
|
50
|
-
<link rel="stylesheet" crossorigin href="/assets/global-
|
|
49
|
+
<link rel="modulepreload" crossorigin href="/assets/package-D5lk1iqk.js">
|
|
50
|
+
<link rel="stylesheet" crossorigin href="/assets/global-B_hBylxt.css">
|
|
51
51
|
</head>
|
|
52
52
|
<body class="bg-slate-50 text-slate-900">
|
|
53
53
|
<div id="landing-root"></div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as b,j as e,av as de,aK as ee,W as te,aS as ce,aT as me,O as xe,aA as ue,a0 as pe,af as fe}from"./vendor-LWJeAdU1.js";import{u as he,a as K,b as I}from"./query-Cpxr1dul.js";import{L as be}from"./router-DspBTS8b.js";import{P as ge}from"./PageHeader-bDiw2pSJ.js";import{P as re,a as C}from"./PageState-KEq7s0Bk.js";import{B as se,q as j}from"./queryKeys-CsNzv19i.js";import{g as L,b as D,r as Q,B as T}from"./app-BxSHC5_o.js";import{c as u}from"./global-NDOUShP9.js";import{f as je}from"./utils-DSaa7c6v.js";import{u as q}from"./i18n-B3N4Df3E.js";import"./radix-bG5h1Ymq.js";const v={getStatus:()=>Q({url:"/api/profiler/status",method:"GET"}),start:()=>L(D.post("/api/profiler/start")),stop:()=>L(D.post("/api/profiler/stop")),listSessions:t=>Q({url:"/api/profiler/sessions",method:"GET",params:t}),getSession:t=>Q({url:`/api/profiler/sessions/${t}`,method:"GET"}),deleteSession:t=>L(D.delete(`/api/profiler/sessions/${t}`)),clearAll:()=>L(D.post("/api/profiler/sessions/clear"))};function y(t){return t==null?"-":t>=1e3?`${(t/1e3).toFixed(2)}s`:`${Math.round(t)}ms`}function R(t){return t==null?"-":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function S(t){return t==null?"-":t.toLocaleString()}function G(t){return t==null?"-":t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function $(t){return t.endedAt==null||t.turnCount===0?t.totalLatencyMs??0:t.endedAt-t.startedAt}function ye(t){const s=t.sessionId;return s.length>18?`${s.slice(0,8)}…${s.slice(-6)}`:s}function Ne(t,s){const n=Math.max(0,Date.now()-t),r=Math.floor(n/6e4);if(r<1)return s("profiler.relativeTime.justNow");if(r<60)return s("profiler.relativeTime.minutesAgo",{count:r});const l=Math.floor(r/60);if(l<24)return s("profiler.relativeTime.hoursAgo",{count:l});const o=Math.floor(l/24);return s("profiler.relativeTime.daysAgo",{count:o})}function ve(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}function z(t,s){if(Array.isArray(t)){for(const n of t)z(n,s);return}if(t&&typeof t=="object"){const n=t,r=n.tool_calls;Array.isArray(r)&&s.push(...r);const l=n.content;if(Array.isArray(l)){for(const o of l)if(o&&typeof o=="object"){const d=o;d.type==="tool_use"&&s.push(d)}}for(const o of Object.values(n))z(o,s)}}function _(t){const s=[];return z(ve(t.clientResponse),s),s}function oe(t,s){const n=t.timestamp-s,r=n+(t.latencyMs??0);return`${(n/1e3).toFixed(3)}s → ${(r/1e3).toFixed(3)}s`}function U(t,s){return je(t??null,s)}function we(t,s){const n=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),r=URL.createObjectURL(n),l=document.createElement("a");l.href=r,l.download=t,l.click(),URL.revokeObjectURL(r)}function B({tone:t="default",children:s}){return e.jsx("span",{className:u("inline-flex items-center rounded-full px-2.5 py-1 text-[11px] font-medium",t==="accent"?"bg-primary/10 text-primary":"bg-secondary text-muted-foreground"),children:s})}function ke({session:t,selected:s,index:n,onClick:r}){const{t:l}=q(),o=["bg-indigo-500","bg-emerald-500","bg-amber-500"],d=s?"bg-indigo-500":o[n%o.length],a=(t.totalInputTokens??0)+(t.totalOutputTokens??0);return e.jsxs("button",{type:"button",onClick:r,className:u("w-full border-b border-border/45 px-4 py-3 text-left transition-colors",s?"bg-secondary":"hover:bg-secondary/50"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:u("h-2 w-2 flex-shrink-0 rounded-full",d)}),e.jsx("span",{className:u("truncate text-sm font-semibold",s?"text-primary":"text-foreground"),children:ye(t)})]}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:Ne(t.startedAt,l)})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 pl-4",children:[e.jsx(B,{tone:s?"accent":"default",children:l("profiler.metricTurns",{count:t.turnCount})}),e.jsx(B,{children:R($(t))}),e.jsx(B,{children:l("profiler.metricTokens",{value:G(a)})})]})]})}function ne({active:t,icon:s,label:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:u("inline-flex h-8 items-center gap-1.5 rounded-full border px-3 text-xs font-medium transition-all",t?"border-primary/20 bg-primary/10 text-primary":"border-transparent bg-secondary text-muted-foreground hover:bg-secondary/80 hover:text-foreground"),children:[e.jsx(s,{className:"h-3.5 w-3.5"}),n]})}function J({active:t,label:s,count:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:u("inline-flex h-7 items-center gap-1.5 rounded-full border px-3 text-[11px] font-medium transition-all",t?"border-primary/20 bg-primary/10 text-primary":"border-transparent bg-transparent text-muted-foreground hover:bg-secondary hover:text-foreground"),children:[e.jsx("span",{children:s}),typeof n=="number"&&e.jsx("span",{className:"rounded-full bg-amber-100 px-1.5 py-0.5 text-[11px] font-semibold text-amber-700",children:n})]})}function Te({detail:t,selectedTurn:s,onSelectTurn:n}){const{t:r}=q(),l=t.records;if(l.length===0)return e.jsx(C,{compact:!0,className:"min-h-[220px]",title:r("profiler.empty.noTurnsTitle"),description:r("profiler.empty.noTurnsDescription")});const o=$(t),d=Math.max(1,...l.map(a=>Math.max(a.latencyMs??0,a.ttftMs??0,1)));return Math.max(1,...l.map(a=>_(a).length)),e.jsxs("div",{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-border/45 px-5 py-3.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:r("profiler.timeline.summary")}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-muted-foreground",children:r("profiler.timeline.mode")}),e.jsx("span",{className:"rounded-full border border-border bg-secondary/70 px-2.5 py-1 font-medium text-foreground",children:r("profiler.timeline.compressed")}),e.jsx("span",{className:"rounded-full border border-border bg-card px-2.5 py-1 font-medium text-foreground",children:r("profiler.timeline.sessionDuration",{duration:R(o)})})]})]}),e.jsxs("div",{className:"px-5 pb-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between text-[11px] text-muted-foreground/70",children:[e.jsx("span",{children:r("profiler.timeline.start")}),e.jsxs("span",{children:[(o/1e3).toFixed(1),"s"]})]}),e.jsx("div",{className:"grid gap-x-2 gap-y-5",style:{gridTemplateColumns:"repeat(10, minmax(0, 1fr))"},children:l.map((a,p)=>{const f=p===s,w=Math.max(a.latencyMs??0,1),i=`${Math.max(28,Math.min(100,w/d*100))}%`,x=a.ttftMs!=null?`${Math.max(0,Math.min(100,Math.min(a.ttftMs,d)/d*100))}%`:null,F=Math.max(0,a.timestamp-t.startedAt),k=_(a);return e.jsxs("button",{type:"button",onClick:()=>n(p),className:u("rounded-xl border border-transparent bg-card px-2 py-2 text-left shadow-sm transition-all",f?"border-primary/20 bg-primary/5":"hover:bg-secondary/50"),title:r("profiler.turn.title",{index:a.turnIndex+1}),children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:u("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1.5 text-[11px] font-semibold",f?"border-primary/30 bg-primary/10 text-primary":"border-border bg-card text-foreground"),children:a.turnIndex+1}),e.jsx("span",{className:"truncate text-[15px] font-semibold text-foreground",children:R(a.latencyMs)})]})}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:r("profiler.timeline.startAt",{time:(F/1e3).toFixed(1)})}),e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground",children:e.jsxs("span",{children:[y(a.ttftMs)," TTFT"]})}),e.jsxs("div",{className:"relative mt-1 h-4 rounded-sm bg-secondary",children:[e.jsx("div",{className:"h-4 rounded-sm bg-primary/20",style:{width:i}}),x!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute top-[-3px] h-5 w-[3px] -translate-x-1/2 rounded-full bg-violet-500 ring-1 ring-white",style:{left:x}}),e.jsx("span",{className:"absolute top-[-6px] h-2.5 w-2.5 -translate-x-1/2 rounded-full border border-white bg-violet-500",style:{left:x}})]})]})]}),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-[11px] text-muted-foreground",children:[e.jsx("span",{children:r("profiler.timeline.tools")}),e.jsx("span",{children:k.length})]}),e.jsx("div",{className:"flex h-5 items-center gap-1",children:e.jsx("span",{className:u("inline-flex h-5 min-w-5 items-center justify-center rounded-md border text-[11px] font-semibold",k.length>0?"border-amber-400 bg-amber-200 text-amber-900":"border-border bg-card text-muted-foreground"),children:k.length})})]})]},a.id)})}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-4 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-sm bg-blue-200"}),r("profiler.timeline.legend.totalLatency")]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"relative inline-block h-2.5 w-2.5 rounded-full border border-white bg-violet-500 ring-1 ring-violet-500/35"}),r("profiler.timeline.legend.firstToken")]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-sm border border-amber-400 bg-amber-200"}),r("profiler.timeline.legend.toolExecuting")]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-sm border border-rose-300 bg-rose-50"}),r("profiler.timeline.legend.selectedTurn")]})]})]})]})}function Me({detail:t,selectedTurn:s,detailTab:n,onDetailTabChange:r,onSelectTurn:l}){const{t:o}=q(),d=t.records[s];if(!d)return null;const a=_(d),p=(d.inputTokens??0)+(d.outputTokens??0),f=n==="request"?U(d.clientRequest,o("profiler.payload.emptyRequest")):n==="response"?U(d.clientResponse,o("profiler.payload.emptyResponse")):a.length>0?JSON.stringify(a,null,2):o("profiler.payload.noToolCalls");return e.jsxs("div",{"data-testid":"profiler-turn-detail",className:"mt-3 shrink-0 rounded-xl bg-card shadow-[var(--surface-shadow)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-border px-5 py-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{className:"rounded-full bg-primary px-2 py-1 font-semibold text-primary-foreground",children:o("profiler.turn.title",{index:d.turnIndex+1})}),e.jsx("span",{className:"text-muted-foreground",children:oe(d,t.startedAt)}),e.jsxs("span",{className:"rounded-full bg-violet-50 border border-violet-200 px-2 py-1 font-semibold text-violet-700 dark:bg-violet-500/16 dark:border-violet-400/20 dark:text-violet-200",children:["TTFT ",y(d.ttftMs)]}),e.jsxs("span",{className:"rounded-full bg-sky-50 border border-sky-200 px-2 py-1 font-semibold text-sky-700 dark:bg-sky-500/16 dark:border-sky-400/20 dark:text-sky-200",children:[G(p)," tokens"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("button",{type:"button",onClick:()=>l(Math.max(0,s-1)),disabled:s===0,className:"rounded-full p-1.5 transition-colors hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-40","aria-label":o("profiler.turn.previous"),children:e.jsx(ue,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-10 text-center font-medium text-muted-foreground",children:[s+1," / ",t.records.length]}),e.jsx("button",{type:"button",onClick:()=>l(Math.min(t.records.length-1,s+1)),disabled:s===t.records.length-1,className:"rounded-full p-1.5 transition-colors hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-40","aria-label":o("profiler.turn.next"),children:e.jsx(pe,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border-b border-border bg-secondary/30 px-5 py-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(J,{active:n==="request",label:o("profiler.payload.request"),onClick:()=>r("request")}),e.jsx(J,{active:n==="response",label:o("profiler.payload.response"),onClick:()=>r("response")}),e.jsx(J,{active:n==="tools",label:o("profiler.payload.toolCalls"),count:a.length,onClick:()=>r("tools")})]})}),e.jsxs("div",{className:"bg-secondary/30 p-5",children:[e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-xl bg-[#1E1E2E] p-4 text-xs leading-5 text-slate-200",children:f}),d.error&&e.jsx("p",{className:"mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:d.error})]})]})}function Ce({detail:t,selectedTurn:s,detailTab:n,onSelectTurn:r,onDetailTabChange:l}){return e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(Te,{detail:t,selectedTurn:s,onSelectTurn:r}),e.jsx(Me,{detail:t,selectedTurn:s,detailTab:n,onDetailTabChange:l,onSelectTurn:r})]})}function le({title:t,payload:s,accentClass:n,emptyLabel:r}){return e.jsxs("div",{className:"rounded-xl border border-white/45 bg-white/88 p-3 shadow-[0_12px_28px_rgba(15,23,42,0.06)] dark:border-white/10 dark:bg-slate-950/[0.58] dark:shadow-[0_12px_28px_rgba(0,0,0,0.28)]",children:[e.jsx("p",{className:u("mb-2 text-[11px] font-semibold uppercase tracking-wider",n),children:t}),e.jsx("pre",{className:"max-h-64 overflow-auto rounded-lg bg-slate-950/95 p-3 text-xs leading-5 text-slate-200",children:U(s,r)})]})}function M({label:t,value:s,sub:n,accentClass:r}){return e.jsxs("div",{className:"rounded-xl bg-card p-4 shadow-sm",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:u("metric-number mt-2 text-2xl font-semibold text-foreground",r),children:s}),n&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n})]})}function Se({record:t,sessionStart:s,expanded:n,onToggle:r}){const{t:l}=q(),o=_(t);return e.jsxs("div",{className:"overflow-hidden rounded-xl bg-card shadow-sm",children:[e.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center gap-4 px-4 py-3 text-left transition-colors hover:bg-secondary/50",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"rounded-full bg-primary px-2 py-0.5 text-[11px] font-semibold text-primary-foreground",children:["T",t.turnIndex+1]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:oe(t,s)}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:l("profiler.breakdown.total",{value:y(t.latencyMs)})}),e.jsxs("span",{children:["TTFT ",y(t.ttftMs)]}),e.jsxs("span",{children:["TPOT ",t.tpotMs!=null?`${t.tpotMs.toFixed(1)} ms/tok`:"-"]}),e.jsxs("span",{children:["↑ ",S(t.inputTokens)]}),e.jsxs("span",{children:["↓ ",S(t.outputTokens)]}),e.jsx("span",{children:l("profiler.breakdown.toolCallsCount",{count:o.length})}),t.error&&e.jsx("span",{className:"rounded-full bg-red-50 px-2 py-0.5 font-medium text-red-600 dark:bg-red-500/14 dark:text-red-300",children:l("profiler.breakdown.error")})]})]})]}),e.jsx(fe,{className:u("h-4 w-4 flex-shrink-0 text-muted-foreground/70 transition-transform",n&&"rotate-180")})]}),n&&e.jsxs("div",{className:"border-t border-border bg-secondary/30 p-4",children:[e.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[e.jsx(le,{title:l("profiler.payload.request"),payload:t.clientRequest,accentClass:"text-blue-600",emptyLabel:l("profiler.payload.empty")}),e.jsx(le,{title:l("profiler.payload.response"),payload:t.clientResponse,accentClass:"text-violet-600",emptyLabel:l("profiler.payload.empty")})]}),e.jsxs("div",{className:"mt-3 grid gap-3 xl:grid-cols-[minmax(0,1fr)_280px]",children:[e.jsxs("div",{className:"rounded-xl bg-card p-3 shadow-sm",children:[e.jsx("p",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-amber-600",children:l("profiler.payload.toolCalls")}),e.jsx("pre",{className:"max-h-64 overflow-auto rounded-lg bg-slate-950/95 p-3 text-xs leading-5 text-slate-200",children:o.length>0?JSON.stringify(o,null,2):l("profiler.payload.noToolCalls")})]}),e.jsxs("div",{className:"rounded-xl bg-card p-3 shadow-sm",children:[e.jsx("p",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:l("profiler.breakdown.turnMetrics")}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-3 gap-y-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:l("profiler.breakdown.duration")}),e.jsx("dd",{className:"mt-0.5 font-medium text-foreground",children:y(t.latencyMs)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"TTFT"}),e.jsx("dd",{className:"mt-0.5 font-medium text-foreground",children:y(t.ttftMs)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"TPOT"}),e.jsx("dd",{className:"mt-0.5 font-medium text-foreground",children:t.tpotMs!=null?`${t.tpotMs.toFixed(1)} ms/tok`:"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:l("profiler.breakdown.status")}),e.jsx("dd",{className:"mt-0.5 font-medium text-foreground",children:t.statusCode??"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:l("profiler.breakdown.input")}),e.jsx("dd",{className:"mt-0.5 font-medium text-foreground",children:S(t.inputTokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:l("profiler.breakdown.output")}),e.jsx("dd",{className:"mt-0.5 font-medium text-foreground",children:S(t.outputTokens)})]})]}),t.error&&e.jsx("p",{className:"mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:t.error})]})]})]})]})}function qe({detail:t,expandedTurn:s,onToggleTurn:n}){const{t:r}=q();if(t.records.length===0)return e.jsx(C,{compact:!0,className:"min-h-[220px]",title:r("profiler.empty.noTurnsTitle"),description:r("profiler.empty.noTurnsDescription")});const l=$(t),o=t.records.reduce((i,x)=>{const F=x.latencyMs??0,k=x.ttftMs??0;return i+Math.max(F-k,0)},0),d=l>0?(o/l*100).toFixed(1):"-",a=t.records.map(i=>i.ttftMs).filter(i=>i!=null),p=t.records.map(i=>i.tpotMs).filter(i=>i!=null),f=a.length>0?a.reduce((i,x)=>i+x,0)/a.length:null,w=p.length>0?p.reduce((i,x)=>i+x,0)/p.length:null;return e.jsxs("div",{className:"space-y-5 p-5",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-6",children:[e.jsx(M,{label:r("profiler.breakdown.totalDuration"),value:y(l),sub:r("profiler.breakdown.turnsSub",{count:t.records.length})}),e.jsx(M,{label:r("profiler.breakdown.llmTime"),value:y(o),sub:r("profiler.breakdown.sessionShare",{value:d}),accentClass:"text-violet-700"}),e.jsx(M,{label:r("profiler.breakdown.avgTtft"),value:y(f)}),e.jsx(M,{label:r("profiler.breakdown.avgTpot"),value:w!=null?`${w.toFixed(1)} ms/tok`:"-"}),e.jsx(M,{label:r("profiler.breakdown.inputTokens"),value:S(t.totalInputTokens)}),e.jsx(M,{label:r("profiler.breakdown.outputTokens"),value:S(t.totalOutputTokens)})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:r("profiler.breakdown.perTurnTitle")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("profiler.breakdown.perTurnDescription")})]})}),t.records.map(i=>e.jsx(Se,{record:i,sessionStart:t.startedAt,expanded:s===i.turnIndex,onToggle:()=>n(i.turnIndex)},i.id))]})]})}function Ke(){var Y,Z;const{t}=q(),s=he(),[n,r]=b.useState(null),[l,o]=b.useState("timeline"),[d,a]=b.useState("request"),[p,f]=b.useState(0),[w,i]=b.useState(0),[x,F]=b.useState(""),h=((Y=K({queryKey:j.profiler.status(),queryFn:()=>v.getStatus(),refetchInterval:3e3}).data)==null?void 0:Y.active)??!1,V=K({queryKey:j.profiler.sessions({}),queryFn:()=>v.listSessions({limit:100}),refetchInterval:h?2e3:!1}),g=((Z=V.data)==null?void 0:Z.items)??[],E=K({queryKey:j.profiler.session(n),queryFn:()=>v.getSession(n),enabled:n!=null,refetchInterval:h&&n!=null?2e3:!1}),A=I({mutationFn:()=>v.start(),onSuccess:()=>{s.invalidateQueries({queryKey:j.profiler.status()}),s.invalidateQueries({queryKey:j.profiler.sessions({})})}}),W=I({mutationFn:()=>v.stop(),onSuccess:()=>{s.invalidateQueries({queryKey:j.profiler.status()}),s.invalidateQueries({queryKey:j.profiler.sessions({})})}}),H=I({mutationFn:c=>v.deleteSession(c),onSuccess:(c,N)=>{n===N&&r(null),s.invalidateQueries({queryKey:j.profiler.sessions({})})}}),ae=I({mutationFn:()=>v.clearAll(),onSuccess:()=>{r(null),s.invalidateQueries({queryKey:j.profiler.sessions({})})}}),P=b.useMemo(()=>{const c=x.trim().toLowerCase();return c?g.filter(N=>N.sessionId.toLowerCase().includes(c)):g},[x,g]),m=E.data,O=g.find(c=>c.id===n)??null,X=(m==null?void 0:m.records[p])??null;b.useEffect(()=>{n&&!g.some(c=>c.id===n)&&r(null)},[n,g]),b.useEffect(()=>{!n&&P.length>0&&r(P[0].id)},[P,n]),b.useEffect(()=>{f(0),i(0),a("request")},[n]),b.useEffect(()=>{if(!m){f(0),i(0);return}f(c=>Math.min(c,Math.max(m.records.length-1,0))),i(c=>c==null?0:Math.min(c,Math.max(m.records.length-1,0)))},[m]);const ie=()=>{m&&we(`profiler-${m.sessionId}.json`,m)};return e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 lg:h-[calc(100vh-64px)]",children:[e.jsx(ge,{className:"flex-none",icon:e.jsx(te,{className:"h-5 w-5","aria-hidden":"true"}),title:t("profiler.title"),description:t("profiler.description"),eyebrow:t("profiler.eyebrow"),breadcrumb:t("profiler.breadcrumb"),helper:n?t("profiler.empty.selectDescription"):void 0,badge:e.jsxs("span",{className:u("inline-flex items-center gap-1.5",h?"text-red-600 dark:text-red-300":"text-muted-foreground"),children:[e.jsx("span",{className:u("inline-block h-1.5 w-1.5 rounded-full",h?"bg-red-500":"bg-muted-foreground/70")}),t(h?"profiler.status.recording":"profiler.status.idle")]}),actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(se,{variant:"secondary",className:"rounded-full px-3 py-1 text-[11px]",children:t("profiler.sessionsCount",{count:g.length})}),e.jsx(T,{size:"sm",variant:h?"destructive":"default",onClick:()=>h?W.mutate():A.mutate(),disabled:A.isPending||W.isPending,children:t(h?"profiler.actions.stop":"profiler.actions.start")}),e.jsxs(T,{size:"sm",variant:"outline",onClick:ie,disabled:!m,children:[e.jsx(de,{className:"mr-1.5 h-3.5 w-3.5"}),t("profiler.actions.export")]}),e.jsxs(T,{size:"sm",variant:"outline",onClick:()=>ae.mutate(),disabled:g.length===0,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800 dark:border-red-400/20 dark:bg-red-500/14 dark:text-red-300 dark:hover:bg-red-500/20 dark:hover:text-red-200",children:[e.jsx(ee,{className:"mr-1.5 h-3.5 w-3.5"}),t("profiler.actions.clear")]})]})}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 bg-background lg:flex-row lg:gap-0 lg:overflow-hidden",children:[e.jsxs("div",{className:"flex w-full flex-shrink-0 flex-col overflow-hidden rounded-[1.2rem] border border-white/70 bg-card/96 shadow-[0_20px_48px_-42px_rgba(15,23,42,0.26)] lg:w-[300px]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/45 px-4 py-3",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:t("profiler.sessionsTitle")}),e.jsx(se,{variant:"secondary",className:"rounded-full px-2 py-0.5",children:g.length})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-secondary/50 px-3 py-2.5",children:[e.jsx(ce,{className:"h-3.5 w-3.5 text-muted-foreground/70"}),e.jsx("input",{className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/70",placeholder:t("profiler.searchPlaceholder"),value:x,onChange:c=>F(c.target.value)})]}),e.jsx("div",{className:"max-h-[240px] overflow-y-auto lg:min-h-0 lg:max-h-none lg:flex-1",children:V.isPending?e.jsx(re,{compact:!0,className:"min-h-[160px]",label:t("common.loading")}):P.length===0?e.jsx(C,{compact:!0,className:"m-4 min-h-[160px]",title:t(h?"profiler.empty.waitingTitle":"profiler.empty.idleTitle"),description:t(h?"profiler.empty.waitingDescription":"profiler.empty.idleDescription"),action:h?e.jsx(T,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(be,{to:"/logs",children:t("profiler.empty.actions.logs")})}):e.jsx(T,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending,children:t("profiler.actions.start")})}):P.map((c,N)=>e.jsx(ke,{session:c,selected:n===c.id,index:N,onClick:()=>r(c.id)},c.id))})]}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden rounded-[1.2rem] border border-white/70 bg-card/96 shadow-[0_20px_48px_-42px_rgba(15,23,42,0.26)] lg:ml-3",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-border bg-card px-5 py-3.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full bg-indigo-500"}),e.jsx("span",{className:"truncate text-sm font-semibold text-foreground",children:(m==null?void 0:m.sessionId)??(O==null?void 0:O.sessionId)??n}),e.jsx("span",{className:"text-muted-foreground/70",children:"·"}),e.jsx("span",{className:"truncate text-sm text-muted-foreground",children:m?t("profiler.sessionSummary",{turns:m.turnCount,duration:R($(m)),tokens:G((m.totalInputTokens??0)+(m.totalOutputTokens??0))}):t("profiler.loadingSession")})]}),e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n&&H.mutate(n),disabled:!n||H.isPending,className:"text-muted-foreground hover:text-red-700",children:e.jsx(ee,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"border-b border-border bg-secondary/30 px-5 py-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ne,{active:l==="timeline",icon:me,label:t("profiler.tabs.timeline"),onClick:()=>o("timeline")}),e.jsx(ne,{active:l==="breakdown",icon:xe,label:t("profiler.tabs.breakdown"),onClick:()=>o("breakdown")})]})}),e.jsx("div",{"data-testid":"profiler-session-content",className:"min-h-0 flex-1 overflow-auto bg-secondary/20",children:E.isPending?e.jsx(re,{compact:!0,className:"min-h-[240px]",label:t("profiler.loadingSession")}):E.isError?e.jsx(C,{compact:!0,className:"m-5 min-h-[220px]",tone:"danger",title:t("profiler.errors.loadFailed")}):m?l==="timeline"?e.jsx(Ce,{detail:m,selectedTurn:p,detailTab:d,onSelectTurn:f,onDetailTabChange:a}):e.jsx(qe,{detail:m,expandedTurn:w,onToggleTurn:c=>i(N=>N===c?null:c)}):e.jsx(C,{compact:!0,className:"m-5 min-h-[220px]",title:t("profiler.errors.notFound")})}),X&&e.jsxs("span",{className:"sr-only",children:["Selected turn ",X.turnIndex+1]})]}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(C,{title:t("profiler.empty.selectTitle"),description:t("profiler.empty.selectDescription"),icon:e.jsx(te,{className:"h-5 w-5"})})})})]})]})}export{Ke as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as A,j as e,a7 as T,aD as me,aE as H,aa as P,af as xe,a0 as pe,S as ue,T as he}from"./vendor-LWJeAdU1.js";import{L as ge}from"./router-DspBTS8b.js";import{C as fe}from"./ConfirmDialog-CPNJmevF.js";import{P as je}from"./PageHeader-bDiw2pSJ.js";import{B as v,c as K,T as be,d as ve,e as Ne,f as ye}from"./app-BxSHC5_o.js";import{u as U}from"./useAppMutation-wWyqqlf8.js";import{I as S}from"./input-BjD2rjIj.js";import{L as M}from"./label-DPJWPvWM.js";import{S as W,a as X,b as J,c as Y,d as R}from"./select-UI4HSm85.js";import{S as we}from"./switch-_3mhCfFY.js";import{q as Q,B as w}from"./queryKeys-CsNzv19i.js";import{u as E}from"./i18n-B3N4Df3E.js";import{C as Z,a as ee}from"./card-7EdLPk_C.js";import{c as O}from"./global-NDOUShP9.js";import{D as ke,A as Me,a as Ce,b as Ee,c as De,d as Pe,e as Ae}from"./DialogShell-C0EfvzaN.js";import{P as Se,a as Te,b as Oe}from"./popover-CMRfoAfg.js";import{i as Re,g as _e,C as Le,O as $e,u as Ve}from"./useModelManagementState-BroT3Cj7.js";import"./query-Cpxr1dul.js";import"./radix-bG5h1Ymq.js";import"./gateway-mlUZb7iD.js";import"./useApiQuery-Y63AiXYK.js";const Be=["anthropic","openai-auto","openai-chat","openai-responses"];function ze({open:l,endpoint:s,onClose:g,onSuccess:r}){const{t:a}=E(),[p,m]=A.useState({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0});A.useEffect(()=>{if(s){const t=s.paths&&s.paths.length>0?s.paths:s.path&&s.protocol?[{path:s.path,protocol:s.protocol}]:[{path:"",protocol:"openai-auto"}];m({id:s.id,label:s.label,paths:t,enabled:s.enabled!==!1});return}m({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0})},[s,l]);const n=U({mutationFn:K.create,invalidateKeys:[Q.customEndpoints.all()],successToast:()=>({title:a("modelManagement.createEndpointSuccess")}),errorToast:t=>({title:a("modelManagement.createEndpointError",{error:t.message})}),onSuccess:async()=>{r(),g()}}),x=U({mutationFn:t=>K.update(t.id,t.updates),invalidateKeys:[Q.customEndpoints.all()],successToast:()=>({title:a("modelManagement.updateEndpointSuccess")}),errorToast:t=>({title:a("modelManagement.updateEndpointError",{error:t.message})}),onSuccess:async()=>{r(),g()}}),N=()=>{m(t=>({...t,paths:[...t.paths,{path:"",protocol:"anthropic"}]}))},d=t=>{p.paths.length!==1&&m(u=>({...u,paths:u.paths.filter((f,k)=>k!==t)}))},b=(t,u,f)=>{m(k=>{const C=[...k.paths];return C[t]={...C[t],[u]:f},{...k,paths:C}})},o=t=>{if(t==null||t.preventDefault(),!p.id.trim()||!p.label.trim())return;for(const f of p.paths)if(!f.path.trim())return;const u=p.paths.map(f=>({path:f.path.trim(),protocol:f.protocol}));if(s){x.mutate({id:s.id,updates:{label:p.label.trim(),paths:u,enabled:p.enabled}});return}n.mutate({id:p.id.trim(),label:p.label.trim(),paths:u,enabled:p.enabled})},c=n.isPending||x.isPending,i=p.paths.length===0?a("modelManagement.atLeastOnePath"):!p.id.trim()||!p.label.trim()?a("modelManagement.endpointValidationError"):p.paths.some(t=>!t.path.trim())?a("modelManagement.pathValidationError"):null;return l?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-background/80 backdrop-blur-sm",onClick:g}),e.jsx("div",{className:"fixed inset-y-0 right-0 z-50 w-full max-w-md border-l border-border/45 bg-background/96 shadow-[var(--surface-shadow-lg)] backdrop-blur",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/45 bg-secondary/45 p-6 backdrop-blur-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-[-0.02em]",children:a(s?"modelManagement.editEndpoint":"modelManagement.createEndpoint")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s?s.id:a("modelManagement.endpointRoutingHint")})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:g,className:"rounded-2xl bg-white/70",children:e.jsx(T,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:o,className:"flex-1 space-y-6 overflow-y-auto p-6",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary/50 p-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:a("modelManagement.endpointId")}),e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:(s==null?void 0:s.id)||"new-endpoint"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:a("modelManagement.endpointEnabled")}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:p.enabled?a("common.status.enabled"):a("common.status.disabled")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{children:[a("modelManagement.endpointId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(S,{value:p.id,onChange:t=>m(u=>({...u,id:t.target.value})),placeholder:a("modelManagement.endpointIdPlaceholder"),disabled:!!s,required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("modelManagement.endpointIdHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{children:[a("modelManagement.endpointLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(S,{value:p.label,onChange:t=>m(u=>({...u,label:t.target.value})),placeholder:a("modelManagement.endpointLabelPlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(M,{children:[a("modelManagement.endpointPaths")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(v,{type:"button",variant:"ghost",size:"sm",onClick:N,children:[e.jsx(me,{className:"mr-1 h-3 w-3"}),a("modelManagement.addPath")]})]}),e.jsx("div",{className:"space-y-3",children:p.paths.map((t,u)=>e.jsxs("div",{className:"space-y-2 rounded-xl border border-transparent bg-card p-3 shadow-[var(--surface-shadow)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(S,{value:t.path,onChange:f=>b(u,"path",f.target.value),placeholder:a("modelManagement.endpointPathPlaceholder"),required:!0}),e.jsxs(W,{value:t.protocol,onValueChange:f=>b(u,"protocol",f),children:[e.jsx(X,{children:e.jsx(J,{})}),e.jsx(Y,{children:Be.map(f=>e.jsx(R,{value:f,children:a(f==="anthropic"?"modelManagement.protocolAnthropic":f==="openai-auto"?"modelManagement.protocolOpenAI":f==="openai-chat"?"modelManagement.protocolOpenAIChat":"modelManagement.protocolOpenAIResponses")},f))})]})]}),p.paths.length>1?e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(u),className:"text-destructive",children:e.jsx(T,{className:"h-4 w-4"})}):null]}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[u===0?e.jsx("p",{children:a("modelManagement.endpointPathHint")}):null,e.jsx("p",{children:a(`modelManagement.protocolHints.${t.protocol}`)})]})]},`${t.protocol}-${u}`))}),i?e.jsx("p",{className:"text-xs text-destructive",children:i}):null]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(we,{id:"enabled",checked:p.enabled,onCheckedChange:t=>m(u=>({...u,enabled:t}))}),e.jsx(M,{htmlFor:"enabled",children:a("modelManagement.endpointEnabled")})]}),s?null:e.jsx("div",{className:"rounded-xl bg-accent p-4",children:e.jsx("p",{className:"text-sm text-primary",children:a("modelManagement.endpointRoutingHint")})})]}),e.jsxs("div",{className:"flex gap-3 border-t border-border/45 bg-secondary/45 p-6 backdrop-blur-sm",children:[e.jsx(v,{variant:"outline",className:"flex-1",onClick:g,disabled:c,children:a("common.cancel")}),e.jsx(v,{className:"flex-1",onClick:()=>o(),disabled:c,children:a(c?"common.saving":s?"common.save":"common.create")})]})]})})]}):null}function _(l,s){return s(l==="anthropic"?"modelManagement.protocolAnthropic":l==="openai-chat"?"modelManagement.protocolOpenAIChat":l==="openai-responses"?"modelManagement.protocolOpenAIResponses":"modelManagement.protocolOpenAI")}function He({activeTab:l,customEndpoints:s,customTabs:g,isDirtyByEndpoint:r,onDeleteEndpoint:a,onEditEndpoint:p,onSelectTab:m,systemTabs:n}){const{t:x}=E(),N=[...n,...g].find(d=>d.key===l)??null;return e.jsx(Z,{className:"overflow-hidden rounded-[1.35rem] border border-white/70 bg-card/95 shadow-[0_22px_56px_-46px_rgba(15,23,42,0.22)]",children:e.jsxs(ee,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.6fr)]",children:[e.jsxs("div",{className:"rounded-[1.1rem] bg-secondary/60 p-2.5",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between px-1",children:e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/75",children:x("modelManagement.overview.providerAndSystem")})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3",children:n.map(d=>{const b=l===d.key,o=d.key!=="providers"&&r[d.key];return e.jsxs("button",{type:"button",onClick:()=>m(d.key),"aria-pressed":b,className:O("group flex min-h-[76px] flex-col justify-between rounded-[0.95rem] px-3 py-3 text-left transition-all",b?"bg-card text-foreground shadow-[0_14px_34px_-28px_rgba(15,23,42,0.3)] ring-1 ring-primary/10":"bg-transparent text-muted-foreground hover:bg-card/58 hover:text-foreground"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[15px] font-semibold text-foreground",children:d.label}),e.jsx("div",{className:"mt-0.5 text-[10px] uppercase tracking-[0.14em] text-muted-foreground/70",children:d.key==="providers"?x("modelManagement.overview.providerPoolTag"):x("modelManagement.overview.systemEndpointTag")})]}),o?e.jsx("span",{className:"mt-1 h-2.5 w-2.5 rounded-full bg-amber-500"}):null]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[e.jsx("span",{className:"line-clamp-1 text-xs text-muted-foreground/70",children:d.description}),b?e.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:e.jsx(H,{className:"h-3.5 w-3.5"})}):null]})]},d.key)})})]}),N?e.jsxs("div",{className:"flex min-h-[116px] flex-col justify-between rounded-[1.1rem] bg-[linear-gradient(135deg,hsl(var(--primary)/0.1),rgba(255,255,255,0.78))] p-4 ring-1 ring-primary/10 dark:bg-[linear-gradient(135deg,rgba(14,165,233,0.14),rgba(15,23,42,0.72))] dark:ring-white/10",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(H,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/75",children:"Active workspace"}),e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:N.label})]})]}),e.jsx("p",{className:"mt-3 line-clamp-2 text-xs leading-5 text-muted-foreground",children:N.description})]}):null]}),g.length>0?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/75",children:x("modelManagement.overview.customEndpoints")}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 2xl:grid-cols-3",children:g.map(d=>{const b=l===d.key,o=r[d.key],c=s.find(i=>i.id===d.key);return e.jsxs("div",{className:O("group relative flex min-w-0 flex-col gap-2.5 overflow-hidden rounded-[1.05rem] border px-3 py-3 text-left transition-all sm:px-3.5",b?"border-primary/20 bg-secondary/80 text-foreground shadow-[0_14px_34px_-30px_rgba(59,130,246,0.32)]":"border-border/55 bg-background/42 hover:bg-secondary/50"),children:[e.jsxs("button",{type:"button",onClick:()=>m(d.key),"aria-pressed":b,className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-foreground sm:text-[15px]",title:d.label,children:d.label}),o?e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"}):null]}),e.jsxs("div",{className:"mt-1.5 flex items-end justify-between gap-3",children:[e.jsx("p",{className:"line-clamp-2 text-[11px] leading-4.5 text-muted-foreground/72 sm:line-clamp-1 sm:text-xs",children:d.description}),b?e.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:e.jsx(H,{className:"h-3.5 w-3.5"})}):null]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(w,{variant:(c==null?void 0:c.enabled)===!1?"secondary":"success",className:"rounded-full border-0 px-2 py-0.5 text-[10px]",children:(c==null?void 0:c.enabled)===!1?x("modelManagement.overview.endpointDisabled"):x("modelManagement.overview.endpointEnabled")}),(d.protocols??[]).slice(0,2).map(i=>e.jsx(w,{variant:"outline",className:"max-w-[130px] truncate rounded-full text-[10px]",title:_(i,x),children:_(i,x)},`${d.key}-${i}`))]}),e.jsxs("div",{className:"min-w-0 rounded-[0.8rem] bg-secondary/55 px-2.5 py-2",children:[e.jsx("p",{className:"mb-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground/70",children:x("modelManagement.overview.endpointPaths")}),e.jsx("div",{className:"space-y-1",children:Fe(c,x).map(i=>e.jsx("p",{className:"truncate text-xs font-medium text-foreground",title:i,children:i},i))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",className:"h-7 justify-start rounded-full px-2 text-[11px]",disabled:!c,onClick:()=>{c&&p(c)},children:x("common.edit")}),d.canDelete?e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),c&&a({kind:"endpoint",endpoint:c})},className:"flex h-7 w-full items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive sm:w-7",title:x("common.delete"),children:e.jsx(T,{className:"h-3.5 w-3.5"})}):null]}),d.canDelete?null:e.jsx("div",{className:"text-[11px] text-muted-foreground/70",children:x("modelManagement.overview.endpointManagedExternally")})]},d.key)})})]}):null]})})}function Fe(l,s){var g;if(!l)return[s("common.noData")];if((g=l.paths)!=null&&g.length){const r=l.paths.slice(0,2).map(a=>`${a.path} · ${_(a.protocol,s)}`);return l.paths.length>2&&r.push(s("modelManagement.overview.endpointMorePaths",{count:l.paths.length-2})),r}return l.path?[`${l.path} · ${_(l.protocol??"anthropic",s)}`]:[s("common.noData")]}function Ie({dialog:l,currentRoutes:s,onConfirm:g,onClose:r}){const{t:a}=E();if(!l)return null;const{endpoint:p,preset:m}=l,n=m.modelRoutes??{},x={};for(const i of s){const t=i.source.trim(),u=i.target.trim();t&&u&&(x[t]=u)}const N=new Set([...Object.keys(x),...Object.keys(n)]),d=[],b=[],o=[];for(const i of N){const t=i in x,u=i in n;u&&!t?d.push([i,n[i]]):t&&!u?b.push([i,x[i]]):t&&u&&x[i]!==n[i]&&o.push([i,x[i],n[i]])}const c=d.length>0||b.length>0||o.length>0;return e.jsx(ke,{open:!0,onOpenChange:i=>!i&&r(),children:e.jsxs(Me,{className:"max-w-2xl",children:[e.jsxs(Ce,{children:[e.jsx(Ee,{children:a("modelManagement.presets.diffTitle")}),e.jsx(De,{children:a("modelManagement.presets.diffDescription",{name:m.name})})]}),e.jsx(Pe,{children:c?e.jsxs("div",{className:"max-h-80 space-y-2 rounded-xl bg-secondary/50 p-3 text-sm",children:[d.map(([i,t])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-2 py-1.5 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200",children:[e.jsx(w,{variant:"outline",className:"border-emerald-300 text-xs dark:border-emerald-700",children:a("modelManagement.presets.diffAdded")}),e.jsx("span",{className:"truncate",children:i}),e.jsx(P,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:t})]},`add-${i}`)),b.map(([i,t])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-red-50 px-2 py-1.5 text-red-800 dark:bg-red-950 dark:text-red-200",children:[e.jsx(w,{variant:"outline",className:"border-red-300 text-xs dark:border-red-700",children:a("modelManagement.presets.diffRemoved")}),e.jsx("span",{className:"truncate",children:i}),e.jsx(P,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:t})]},`rm-${i}`)),o.map(([i,t,u])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-amber-50 px-2 py-1.5 text-amber-800 dark:bg-amber-950 dark:text-amber-200",children:[e.jsx(w,{variant:"outline",className:"border-amber-300 text-xs dark:border-amber-700",children:a("modelManagement.presets.diffChanged")}),e.jsx("span",{className:"truncate",children:i}),e.jsx(P,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate line-through opacity-60",children:t}),e.jsx(P,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:u})]},`chg-${i}`))]}):e.jsx("p",{className:"rounded-xl bg-secondary/50 py-8 text-center text-sm text-muted-foreground",children:a("modelManagement.presets.diffEmpty")})}),e.jsxs(Ae,{children:[e.jsx(v,{variant:"outline",onClick:r,children:a("common.cancel")}),e.jsx(v,{onClick:()=>g(p,m),disabled:!c,children:a("modelManagement.presets.diffConfirm")})]})]})})}function qe({value:l,onChange:s,options:g,disabled:r,placeholder:a}){const{t:p}=E(),[m,n]=A.useState(!1),[x,N]=A.useState(""),d=A.useMemo(()=>{if(!x.trim())return g;const o=x.toLowerCase();return g.filter(c=>c.label.toLowerCase().includes(o)||c.value.toLowerCase().includes(o))},[g,x]),b=o=>{s(o),N(""),n(!1)};return e.jsxs(Se,{open:m,onOpenChange:o=>{n(o),o&&N("")},children:[e.jsx(Te,{asChild:!0,children:e.jsx(S,{value:l,onChange:o=>{s(o.target.value),N(o.target.value),m||n(!0)},onFocus:()=>{N(""),n(!0)},onClick:()=>{m||n(!0)},placeholder:a,disabled:r,autoComplete:"off"})}),e.jsx(Oe,{className:"max-h-60 w-[var(--radix-popover-trigger-width)] overflow-y-auto rounded-xl border border-[color:var(--surface-border)] bg-popover/96 p-1.5 shadow-[var(--surface-shadow-lg)] backdrop-blur",align:"start",onOpenAutoFocus:o=>o.preventDefault(),children:d.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:p("common.noMatches")}):d.map(o=>e.jsx("button",{type:"button",className:O("flex w-full items-center rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-accent/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",o.value===l.trim()&&"bg-accent/90 text-accent-foreground"),onMouseDown:c=>{c.preventDefault(),b(o.value)},children:e.jsx("span",{className:"truncate",children:o.label})},o.value))})]})}function Ge({endpoint:l,tabs:s,customEndpoints:g,config:r,routes:a,routeError:p,savingRoute:m,isDirty:n,presets:x,presetName:N,presetError:d,savingPreset:b,applyingPreset:o,deletingPreset:c,presetsExpanded:i,savingClaudeValidation:t,providerModelOptions:u,onTogglePresetsExpanded:f,onPresetNameChange:k,onSavePreset:C,onRequestPresetDiff:se,onRequestDeletePreset:ae,onValidationModeChange:te,onRouteChange:F,onRemoveRoute:I,onAddSuggestion:ne,onAddRoute:re,onResetRoutes:le,onSaveRoutes:ie}){var G;const{t:h}=E(),y=s.find(j=>j.key===l),L=((G=y==null?void 0:y.protocols)==null?void 0:G.includes("anthropic"))??l==="anthropic"?Le:$e,oe=(y==null?void 0:y.label)??l;(y==null?void 0:y.isSystem)===!1?y.description:h(`settings.routing.descriptionByEndpoint.${l}`);const $=`route-source-${l}`,q=Re(l,g),V=_e(l,r,g),B=q?(V==null?void 0:V.mode)??"off":"off",de=new Set(a.map(j=>j.source.trim()).filter(Boolean)),ce=`modelManagement.claudeValidation.options.${B}.description`;return e.jsx(Z,{children:e.jsxs(ee,{className:"space-y-6 pt-6",children:[e.jsx("div",{className:"rounded-full bg-secondary px-4 py-3 text-xs text-muted-foreground",children:h("settings.routing.wildcardHint")}),q?e.jsx("div",{className:"rounded-xl border border-primary/12 bg-[linear-gradient(135deg,hsl(var(--primary)/0.08),hsl(var(--accent)/0.72))] p-4 shadow-[var(--surface-shadow)] dark:border-sky-300/12 dark:bg-[linear-gradient(135deg,rgba(14,165,233,0.12),rgba(15,23,42,0.72))]",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-primary dark:text-sky-100",children:h("modelManagement.claudeValidation.title")}),e.jsx("p",{className:"max-w-2xl text-xs leading-5 text-muted-foreground dark:text-slate-300",children:h("modelManagement.claudeValidation.description")})]}),e.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-2 self-start sm:self-auto",children:[e.jsx(M,{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/70 dark:text-sky-200/75",children:h("modelManagement.claudeValidation.modeLabel")}),e.jsxs(W,{value:B,onValueChange:j=>te(j),disabled:t,children:[e.jsx(X,{className:"border-primary/15 bg-card/90 dark:border-white/10 dark:bg-slate-950/50",children:e.jsx(J,{})}),e.jsxs(Y,{children:[e.jsx(R,{value:"off",children:h("modelManagement.claudeValidation.options.off.label")}),e.jsx(R,{value:"anthropic-strict",children:h("modelManagement.claudeValidation.options.anthropic-strict.label")}),e.jsx(R,{value:"claude-code",children:h("modelManagement.claudeValidation.options.claude-code.label")})]})]}),e.jsx("span",{className:O("text-xs",B==="off"?"text-muted-foreground dark:text-slate-400":"text-primary/80 dark:text-sky-200/80"),children:h(ce)})]})]})}):null,p?e.jsx("p",{className:"text-sm text-destructive",children:p}):null,e.jsx(Ke,{presets:x,presetName:N,presetError:d,savingPreset:b,applyingPreset:o,deletingPreset:c,expanded:i,onToggleExpanded:f,onPresetNameChange:k,onSavePreset:C,onRequestPresetDiff:se,onRequestDeletePreset:ae}),e.jsxs("div",{className:"space-y-3 rounded-xl bg-secondary/50 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(M,{className:"text-sm font-semibold text-foreground",children:h("modelManagement.routesEditorTitle")}),e.jsxs(w,{variant:"outline",children:[a.length," active"]})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:h("modelManagement.overview.routesEditorHint")})]}),e.jsxs("div",{className:"self-start rounded-full bg-card px-3 py-2 text-[11px] font-medium text-muted-foreground",children:["Active workspace · ",oe]})]}),a.length===0?e.jsxs("div",{className:"rounded-xl border-2 border-dashed border-border/30 bg-background/60 p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:h("settings.routing.empty")}),e.jsx("p",{className:"mt-2 text-xs",children:h("modelManagement.emptyRoutesHint")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"hidden grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] items-center gap-3 px-1 text-xs font-medium text-muted-foreground md:grid",children:[e.jsx("span",{children:h("settings.routing.source")}),e.jsx("span",{}),e.jsx("span",{children:h("settings.routing.target")}),e.jsx("span",{})]}),a.map((j,D)=>e.jsxs("div",{className:"rounded-xl bg-card p-3 shadow-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between md:hidden",children:[e.jsxs(w,{variant:"outline",className:"text-[11px]",children:["#",D+1]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>I(j.id),disabled:m,children:e.jsx(T,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{className:"text-[11px] uppercase tracking-[0.16em] text-muted-foreground md:hidden",children:h("settings.routing.source")}),e.jsx(S,{value:j.source,onChange:z=>F(j.id,"source",z.target.value),placeholder:h("settings.routing.sourcePlaceholder"),list:$,disabled:m,"aria-label":`route-source-${D+1}`})]}),e.jsx(P,{className:"hidden h-4 w-4 flex-shrink-0 text-muted-foreground md:block"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{className:"text-[11px] uppercase tracking-[0.16em] text-muted-foreground md:hidden",children:h("settings.routing.target")}),e.jsx(qe,{value:j.target,onChange:z=>F(j.id,"target",z),options:u,disabled:m,placeholder:h("settings.routing.targetPlaceholder")})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 text-muted-foreground hover:text-destructive md:inline-flex",onClick:()=>I(j.id),disabled:m,children:e.jsx(T,{className:"h-4 w-4"})})]})]},j.id))]})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl bg-card p-4 shadow-[var(--surface-shadow)] md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:h("modelManagement.actions.footerTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h(n?"modelManagement.actions.footerDirtyHint":"modelManagement.actions.footerSavedHint")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3 md:flex md:flex-wrap md:items-center",children:[e.jsx(v,{variant:"outline",size:"sm",onClick:re,disabled:m,className:"w-full",children:h("settings.routing.add")}),e.jsx(v,{variant:"outline",size:"sm",onClick:le,disabled:m||!n,className:"w-full",children:h("common.actions.reset")}),e.jsxs(v,{size:"sm",onClick:ie,disabled:m,className:"relative w-full",children:[h(m?"common.actions.saving":"modelManagement.actions.saveRoutes"),n?e.jsx("span",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-amber-500"}):null]})]})]}),e.jsxs("div",{className:"space-y-3 rounded-xl bg-secondary/50 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(M,{className:"text-sm font-medium text-foreground",children:h("settings.routing.suggested")}),e.jsx(w,{variant:"outline",className:"text-[11px]",children:L.length})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:h("modelManagement.overview.suggestionHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:L.map(j=>{const D=de.has(j);return e.jsx(v,{variant:D?"ghost":"outline",size:"sm",onClick:()=>ne(j),disabled:m||D,className:O("h-7 rounded-md px-2.5 text-[11px] font-normal",D?"opacity-45":"bg-background/70"),children:j},`${l}-${j}`)})})]}),e.jsx("datalist",{id:$,children:L.map(j=>e.jsx("option",{value:j},`${$}-${j}`))})]})})}function Ke({presets:l,presetName:s,presetError:g,savingPreset:r,applyingPreset:a,deletingPreset:p,expanded:m,onToggleExpanded:n,onPresetNameChange:x,onSavePreset:N,onRequestPresetDiff:d,onRequestDeletePreset:b}){const{t:o}=E();return e.jsxs("div",{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:[e.jsx("button",{type:"button",className:"flex w-full items-center justify-between gap-3 rounded-xl p-4 text-left transition-colors hover:bg-accent",onClick:n,children:e.jsxs("div",{className:"flex items-center gap-2",children:[m?e.jsx(xe,{className:"h-4 w-4"}):e.jsx(pe,{className:"h-4 w-4"}),e.jsx("h3",{className:"font-medium",children:o("modelManagement.presets.title")}),e.jsx(w,{variant:"secondary",className:"text-xs",children:l.length})]})}),m?e.jsxs("div",{className:"space-y-4 border-t border-border/45 px-4 pb-4 pt-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:o("modelManagement.presets.description")}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center",children:[e.jsx(S,{value:s,onChange:c=>x(c.target.value),placeholder:o("modelManagement.presets.namePlaceholder"),disabled:r,className:"w-full md:w-48"}),e.jsx(v,{onClick:N,disabled:r,className:"w-full md:w-auto",children:o(r?"modelManagement.presets.saving":"modelManagement.presets.save")})]}),g?e.jsx("p",{className:"text-sm text-destructive",children:g}):null,l.length===0?e.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:o("modelManagement.presets.empty")}):e.jsx(be,{children:e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(c=>{const i=a===c.name,t=p===c.name,u=Object.entries(c.modelRoutes??{}),f=u.length;return e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl bg-secondary/50 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs(ve,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs("div",{className:"min-w-0 flex-1 cursor-default",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:c.name}),e.jsx(w,{variant:"outline",className:"mt-1 text-xs",children:f>0?o("modelManagement.presets.rulesCount",{count:f}):o("modelManagement.presets.noRules")})]})}),f>0?e.jsx(ye,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[u.slice(0,5).map(([k,C])=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"truncate",children:k}),e.jsx(P,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:C})]},k)),f>5?e.jsxs("div",{className:"text-muted-foreground",children:["…+",f-5]}):null]})}):null]}),e.jsxs("div",{className:"grid flex-shrink-0 gap-2 sm:flex sm:items-center",children:[e.jsx(v,{size:"sm",onClick:()=>d(c),disabled:i||t,className:"w-full sm:w-auto",children:o(i?"modelManagement.presets.applying":"modelManagement.presets.apply")}),e.jsx(v,{variant:"destructive",size:"sm",onClick:()=>b(c),disabled:t||i,className:"w-full sm:w-auto",children:o(t?"modelManagement.presets.deleting":"modelManagement.presets.delete")})]})]},c.name)})})})]}):null]})}function hs(){var p,m;const{t:l}=E(),s=Ve(),g=s.systemTabs.filter(n=>n.key!=="providers"),r=s.activeTab==="providers"?"anthropic":s.activeTab,a=s.tabs.find(n=>n.key===r)??null;return A.useEffect(()=>{s.activeTab==="providers"&&s.setActiveTab("anthropic")},[s.activeTab,s.setActiveTab]),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(je,{icon:e.jsx(he,{className:"h-5 w-5","aria-hidden":"true"}),title:l("routingManagement.title"),description:l("routingManagement.description"),eyebrow:l("routingManagement.eyebrow"),breadcrumb:"Gateway / Routing",badge:(a==null?void 0:a.label)??r,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx(v,{asChild:!0,variant:"outline",className:"w-full sm:w-auto",children:e.jsxs(ge,{to:"/models",children:[e.jsx(ue,{className:"h-4 w-4","aria-hidden":"true"}),l("nav.models")]})}),e.jsx(v,{onClick:s.handleOpenCreateEndpoint,className:"w-full sm:w-auto",children:l("modelManagement.addEndpoint")})]})}),e.jsx(He,{activeTab:r,customEndpoints:s.customEndpoints,customTabs:s.customTabs,isDirtyByEndpoint:s.isDirtyByEndpoint,onDeleteEndpoint:s.setConfirmAction,onEditEndpoint:s.handleOpenEditEndpoint,onSelectTab:s.setActiveTab,systemTabs:g}),e.jsx(Ge,{endpoint:r,applyingPreset:((p=s.applyingPreset)==null?void 0:p.endpoint)===r?s.applyingPreset.name:null,config:s.config,customEndpoints:s.customEndpoints,deletingPreset:((m=s.deletingPreset)==null?void 0:m.endpoint)===r?s.deletingPreset.name:null,isDirty:s.isDirtyByEndpoint[r]??!1,onAddRoute:()=>s.handleAddRoute(r),onAddSuggestion:n=>s.handleAddSuggestion(r,n),onPresetNameChange:n=>s.handlePresetNameChange(r,n),onRequestDeletePreset:n=>s.setConfirmAction({kind:"preset",endpoint:r,preset:n}),onRequestPresetDiff:n=>s.setPresetDiffDialog({endpoint:r,preset:n}),onRemoveRoute:n=>s.handleRemoveRoute(r,n),onResetRoutes:()=>s.handleResetRoutes(r),onRouteChange:(n,x,N)=>s.handleRouteChange(r,n,x,N),onSavePreset:()=>void s.handleSavePreset(r),onSaveRoutes:()=>void s.handleSaveRoutes(r),onValidationModeChange:n=>void s.handleValidationModeChange(r,n),onTogglePresetsExpanded:()=>s.setPresetsExpanded(n=>({...n,[r]:!n[r]})),presetError:s.presetErrorByEndpoint[r],presetName:s.presetNameByEndpoint[r]??"",presets:s.presetsByEndpoint[r]??[],presetsExpanded:s.presetsExpanded[r]===!0,providerModelOptions:s.providerModelOptions,routeError:s.routeError[r],routes:s.routesByEndpoint[r]||[],savingClaudeValidation:s.savingClaudeValidation,savingPreset:s.savingPresetFor===r,savingRoute:s.savingRouteFor===r,tabs:s.tabs.filter(n=>n.key!=="providers")}),e.jsx(ze,{open:s.endpointDrawerOpen,endpoint:s.editingEndpoint,onClose:()=>{s.setEndpointDrawerOpen(!1),s.setEditingEndpoint(void 0)},onSuccess:()=>{s.configQuery.refetch()}}),e.jsx(Ie,{dialog:s.presetDiffDialog,currentRoutes:s.presetDiffDialog?s.routesByEndpoint[s.presetDiffDialog.endpoint]||[]:[],onConfirm:(n,x)=>{s.setPresetDiffDialog(null),s.handleApplyPreset(n,x)},onClose:()=>s.setPresetDiffDialog(null)}),e.jsx(fe,{open:!!s.confirmAction,onOpenChange:n=>{!n&&!s.confirmingAction&&s.setConfirmAction(null)},title:s.confirmDialogTitle,description:s.confirmDialogDescription,confirmLabel:s.confirmingAction?l("common.actions.loading"):l("common.delete"),cancelLabel:l("common.actions.cancel"),loading:s.confirmingAction,onConfirm:s.handleConfirmDialog,children:s.confirmDialogName?e.jsx("div",{className:"rounded-lg bg-destructive/5 px-3 py-2 font-mono text-xs text-foreground ring-1 ring-destructive/20",children:s.confirmDialogName}):null})]})}export{hs as default};
|