@chenpu17/cc-gw 0.8.0-alpha.9 → 0.8.0-beta.2
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/README.md +18 -2
- package/package.json +9 -5
- package/src/cli/dist/index.js +0 -2
- package/src/web/dist/assets/About-bnb_BU6z.js +1 -0
- package/src/web/dist/assets/ApiKeys-DXJYgiYr.js +1 -0
- package/src/web/dist/assets/Dashboard-_T1jT56-.js +1 -0
- package/src/web/dist/assets/DialogShell-s3yKnQyp.js +1 -0
- package/src/web/dist/assets/EChart-Dqa_Xbrn.js +1 -0
- package/src/web/dist/assets/Events-B7l9cIhA.js +1 -0
- package/src/web/dist/assets/Help-M_B7c7Hj.js +8 -0
- package/src/web/dist/assets/Login-CXG8h1Xd.js +1 -0
- package/src/web/dist/assets/Logs-DVPaFD7W.js +1 -0
- package/src/web/dist/assets/ModelManagement-m4p97Xel.js +1 -0
- package/src/web/dist/assets/PageHeader-KQ9mjVAV.js +1 -0
- package/src/web/dist/assets/PageSection-C9Wb9Oe3.js +1 -0
- package/src/web/dist/assets/PageState-D-1-sNyq.js +1 -0
- package/src/web/dist/assets/Profiler-Bb-I7NR2.js +1 -0
- package/src/web/dist/assets/Settings-CdZ_GGjR.js +1 -0
- package/src/web/dist/assets/Skeleton-H3SErRWs.js +1 -0
- package/src/web/dist/assets/badge-3ORqzzzc.js +1 -0
- package/src/web/dist/assets/card-D1l7si2X.js +1 -0
- package/src/web/dist/assets/{charts-core-BE9sa9zn.js → charts-core-vuhzGmuT.js} +1 -1
- package/src/web/dist/assets/{charts-engine-DAwKT7Yg.js → charts-engine-BJQRnjQ_.js} +1 -1
- package/src/web/dist/assets/{charts-react-Dnkr-ZWt.js → charts-react-BeVWPrMt.js} +1 -1
- package/src/web/dist/assets/gateway-CFNtAOS2.js +1 -0
- package/src/web/dist/assets/{i18n-CZ1qKIdj.js → i18n-CfLThlXq.js} +1 -1
- package/src/web/dist/assets/index-8bCfrPhk.css +1 -0
- package/src/web/dist/assets/index-MqPrlTQ4.js +61 -0
- package/src/web/dist/assets/input-Bb_t6wr6.js +1 -0
- package/src/web/dist/assets/{label-V0fmEe3U.js → label-8HO4VSYV.js} +1 -1
- package/src/web/dist/assets/popover-5I-o07-i.js +1 -0
- package/src/web/dist/assets/{query-CDpWKdnY.js → query-D3IfCUhp.js} +1 -1
- package/src/web/dist/assets/queryKeys-BMvyDTQS.js +1 -0
- package/src/web/dist/assets/radix-54BMi3RD.js +5 -0
- package/src/web/dist/assets/{router-DjNibHfR.js → router-CmaL1NgV.js} +2 -2
- package/src/web/dist/assets/select-kdaAyzec.js +1 -0
- package/src/web/dist/assets/{switch-V4Qh3v7X.js → switch-DLCOPP-U.js} +1 -1
- package/src/web/dist/assets/useApiQuery-Bcqr7uHV.js +1 -0
- package/src/web/dist/assets/useAppMutation-CqHoYeK1.js +1 -0
- package/src/web/dist/assets/utils-DQfq7gRo.js +1 -0
- package/src/web/dist/assets/{vendor-C92xTG6Z.js → vendor-CjJPKsTb.js} +125 -65
- package/src/web/dist/index.html +7 -7
- package/src/web/dist/assets/About-COC-5-Wo.js +0 -1
- package/src/web/dist/assets/ApiKeys-G_iglpy4.js +0 -1
- package/src/web/dist/assets/ConfirmDialog-B6Hd3Eud.js +0 -1
- package/src/web/dist/assets/Dashboard-CDrlVQsE.js +0 -1
- package/src/web/dist/assets/EChart-C_zeFtIj.js +0 -1
- package/src/web/dist/assets/Events-BJ2HraCN.js +0 -1
- package/src/web/dist/assets/Help-CUSHbKKs.js +0 -8
- package/src/web/dist/assets/Login-BUlmZ2Fi.js +0 -1
- package/src/web/dist/assets/Logs-cCODXwO-.js +0 -1
- package/src/web/dist/assets/ModelManagement-D9av2Cfc.js +0 -1
- package/src/web/dist/assets/PageHeader-BIhjesDo.js +0 -1
- package/src/web/dist/assets/PageSection-CTHA3Yub.js +0 -1
- package/src/web/dist/assets/Settings-DF49sT5q.js +0 -1
- package/src/web/dist/assets/Skeleton-D7zoK-3P.js +0 -1
- package/src/web/dist/assets/card-DKAxXuqe.js +0 -1
- package/src/web/dist/assets/index-NGg4j8sr.css +0 -1
- package/src/web/dist/assets/index-zyFaDjL5.js +0 -61
- package/src/web/dist/assets/input-CKjvZhjf.js +0 -1
- package/src/web/dist/assets/popover-CSAdpdw2.js +0 -1
- package/src/web/dist/assets/radix-Ccu1urVd.js +0 -5
- package/src/web/dist/assets/select-B9GMWo4R.js +0 -1
- package/src/web/dist/assets/useApiQuery-HKJqYJso.js +0 -1
package/README.md
CHANGED
|
@@ -118,8 +118,8 @@ Linux 版本使用 `musl`,Windows 版本使用静态 CRT,目标是让用户
|
|
|
118
118
|
```bash
|
|
119
119
|
pnpm pack:dry-run
|
|
120
120
|
pnpm --dir packages/native/darwin-arm64 pack --pack-destination ../../../.pack/native
|
|
121
|
-
npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.0-alpha.
|
|
122
|
-
npm install -g ./.pack/chenpu17-cc-gw-0.8.0-alpha.
|
|
121
|
+
npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.0-alpha.12.tgz
|
|
122
|
+
npm install -g ./.pack/chenpu17-cc-gw-0.8.0-alpha.12.tgz
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
当前发布目标:
|
|
@@ -147,10 +147,26 @@ pnpm exec playwright install --with-deps chromium
|
|
|
147
147
|
pnpm test:e2e:web
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
+
如果只想跑分层回归,可直接用:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
pnpm test:e2e:web:core
|
|
154
|
+
pnpm test:e2e:web:hardening
|
|
155
|
+
pnpm test:e2e:web:visual
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
如需刷新页面级截图基线:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
pnpm test:e2e:web:update-snapshots
|
|
162
|
+
```
|
|
163
|
+
|
|
150
164
|
当前仓库已具备:
|
|
151
165
|
|
|
152
166
|
- Web UI 构建通过
|
|
153
167
|
- Web Playwright E2E 通过
|
|
168
|
+
- 页面级视觉截图基线回归
|
|
169
|
+
- 低频危险路径 E2E
|
|
154
170
|
- CLI smoke 流程可单独执行
|
|
155
171
|
- GitHub Actions CI 与 release workflow 已落地
|
|
156
172
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.8.0-
|
|
3
|
+
"version": "0.8.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Rust-backed local Claude Code compatible gateway with web console and CLI daemon.",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"@chenpu17/cc-gw-darwin-arm64": "0.8.0-
|
|
29
|
-
"@chenpu17/cc-gw-linux-
|
|
30
|
-
"@chenpu17/cc-gw-
|
|
31
|
-
"@chenpu17/cc-gw-
|
|
28
|
+
"@chenpu17/cc-gw-darwin-arm64": "0.8.0-beta.2",
|
|
29
|
+
"@chenpu17/cc-gw-linux-x64": "0.8.0-beta.2",
|
|
30
|
+
"@chenpu17/cc-gw-linux-arm64": "0.8.0-beta.2",
|
|
31
|
+
"@chenpu17/cc-gw-win32-x64": "0.8.0-beta.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"colorette": "^2.0.20",
|
|
@@ -54,6 +54,10 @@
|
|
|
54
54
|
"pack:dry-run": "pnpm run build:package && node scripts/pack-root-package.mjs",
|
|
55
55
|
"publish:packed": "node scripts/publish-artifacts.mjs",
|
|
56
56
|
"test:e2e:web": "pnpm build && playwright test",
|
|
57
|
+
"test:e2e:web:core": "pnpm build && playwright test tests/playwright/pages.spec.ts tests/playwright/auth.spec.ts tests/playwright/logs.spec.ts tests/playwright/model-management.spec.ts tests/playwright/settings.spec.ts tests/playwright/api-keys.spec.ts --reporter=line",
|
|
58
|
+
"test:e2e:web:visual": "pnpm build && playwright test tests/playwright/visual.spec.ts --reporter=line",
|
|
59
|
+
"test:e2e:web:hardening": "pnpm build && playwright test tests/playwright/hardening.spec.ts --reporter=line",
|
|
60
|
+
"test:e2e:web:update-snapshots": "pnpm build && playwright test tests/playwright/visual.spec.ts --update-snapshots --reporter=line",
|
|
57
61
|
"typecheck": "pnpm --filter @cc-gw/cli exec tsc --noEmit && pnpm --filter @cc-gw/web exec tsc --noEmit"
|
|
58
62
|
}
|
|
59
63
|
}
|
package/src/cli/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,j as e,ab as P,aA as T,aB as u,aj as B,Z as R}from"./vendor-CjJPKsTb.js";import{P as q}from"./PageHeader-KQ9mjVAV.js";import{P as m}from"./PageSection-C9Wb9Oe3.js";import{P as A,a as C}from"./PageState-D-1-sNyq.js";import{u as I}from"./useApiQuery-Bcqr7uHV.js";import{u as V,B as p}from"./index-MqPrlTQ4.js";import{q as F}from"./queryKeys-BMvyDTQS.js";import{B as o}from"./badge-3ORqzzzc.js";import{C as l,a as n}from"./card-D1l7si2X.js";import{u as G}from"./i18n-CfLThlXq.js";import"./query-D3IfCUhp.js";import"./router-CmaL1NgV.js";import"./radix-54BMi3RD.js";const z="0.8.0-beta.2",M={version:z};function ae(){var b,h,f,j,v,g,N,y,w,k;const{t:a}=G(),{pushToast:s}=V(),t=I(F.status.gateway(),{url:"/api/status",method:"GET"},{staleTime:6e4});c.useEffect(()=>{t.isError&&t.error&&s({title:a("about.toast.statusError.title"),description:t.error.message,variant:"error"})},[s,t.error,t.isError,a]);const i=M.version,d="2026-03-23T11:39:19.198Z",L=c.useMemo(()=>{var r,S;return[{label:a("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:a("about.app.labels.version"),value:e.jsxs("span",{"data-visual-volatile":"true",className:"font-mono text-primary",children:["v",i]})},{label:a("about.app.labels.buildTime"),value:e.jsx("span",{"data-visual-volatile":"true",children:d}),hint:a("about.app.hint.buildTime")},{label:a("about.app.labels.runtime"),value:e.jsx("span",{className:"font-mono",children:((r=t.data)==null?void 0:r.runtime)??"rust"})},{label:a("about.app.labels.backendVersion"),value:e.jsx("span",{"data-visual-volatile":"true",className:"font-mono",children:((S=t.data)==null?void 0:S.backendVersion)??"-"})}]},[i,d,(b=t.data)==null?void 0:b.backendVersion,(h=t.data)==null?void 0:h.runtime,a]),x=c.useMemo(()=>{var r;return t.data?[{label:a("about.status.labels.host"),value:t.data.host??"127.0.0.1"},{label:a("about.status.labels.port"),value:e.jsx("span",{"data-visual-volatile":"true",children:t.data.port.toLocaleString()})},{label:a("about.status.labels.providers"),value:t.data.providers.toLocaleString()},{label:a("about.status.labels.active"),value:(t.data.activeRequests??0).toLocaleString(),hint:a("about.status.hint.active")},{label:a("about.status.labels.platform"),value:t.data.platform??"-"},{label:a("about.status.labels.pid"),value:e.jsx("span",{"data-visual-volatile":"true",children:((r=t.data.pid)==null?void 0:r.toLocaleString())??"-"})}]:[]},[t.data,a]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(q,{icon:e.jsx(T,{className:"h-5 w-5","aria-hidden":"true"}),title:a("about.title"),description:a("about.description"),badge:e.jsxs("span",{"data-visual-volatile":"true",children:["v",i]}),eyebrow:"Runtime",breadcrumb:"Gateway / About",helper:a("about.support.description"),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("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:"manual refresh only"}),e.jsxs(p,{onClick:()=>s({title:a("about.toast.updatesPlanned"),variant:"info"}),className:"w-full sm:w-auto",children:[e.jsx(P,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("about.support.actions.checkUpdates")]})]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.9fr)]",children:[e.jsx(l,{className:"overflow-hidden",children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold uppercase tracking-wider text-primary",children:[e.jsx(u,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"text-3xl font-semibold tracking-tight text-foreground",children:[((f=t.data)==null?void 0:f.host)??"127.0.0.1",":",((j=t.data)==null?void 0:j.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("about.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(o,{variant:"outline",children:((v=t.data)==null?void 0:v.runtime)??"rust"}),e.jsx(o,{variant:"outline",children:((g=t.data)==null?void 0:g.platform)??"-"}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.providers"),": ",((y=(N=t.data)==null?void 0:N.providers)==null?void 0:y.toLocaleString())??"-"]}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.active"),": ",(((w=t.data)==null?void 0:w.activeRequests)??0).toLocaleString()]})]})]})})}),e.jsx(l,{className:"overflow-hidden",children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Build"}),e.jsxs("p",{"data-visual-volatile":"true",className:"font-mono text-lg text-primary",children:["v",i]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-sm text-muted-foreground",children:d}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-sm text-muted-foreground",children:a("about.support.tip")})]})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(m,{title:a("about.app.title"),description:a("about.app.subtitle"),children:e.jsx(E,{items:L})}),e.jsx(m,{title:a("about.status.title"),description:a("about.status.subtitle"),actions:e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>void t.refetch(),disabled:t.isFetching,children:[e.jsx(B,{className:Q(t.isFetching),"aria-hidden":"true"}),t.isFetching?a("common.actions.refreshing"):a("common.actions.refresh")]}),children:t.isLoading?e.jsx(A,{compact:!0,label:a("about.status.loading")}):t.isError?e.jsx(C,{compact:!0,tone:"danger",icon:e.jsx(u,{className:"h-5 w-5","aria-hidden":"true"}),title:a("common.status.error"),description:((k=t.error)==null?void 0:k.message)??a("common.unknownError"),action:e.jsx(p,{variant:"outline",size:"sm",onClick:()=>void t.refetch(),children:a("common.actions.refresh")})}):x.length>0?e.jsx(E,{items:x}):e.jsx(C,{compact:!0,tone:"primary",icon:e.jsx(u,{className:"h-5 w-5","aria-hidden":"true"}),title:a("about.status.empty"),description:a("common.actions.refresh")})})]}),e.jsx(m,{title:a("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:a("about.support.subtitle")}),e.jsx("span",{children:a("about.support.description")})]}),children:e.jsx(l,{children:e.jsxs(n,{className:"flex flex-col gap-4 pt-5 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:e.jsx(R,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:a("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-lg border border-border bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}function E({items:a}){return a.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:a.map(s=>e.jsx(l,{children:e.jsxs(n,{className:"pt-5",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s.label}),e.jsx("dd",{className:"mt-2 text-sm font-semibold text-foreground",children:s.value}),s.hint?e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.hint}):null]})},s.label))})}function Q(a){return`mr-2 h-4 w-4${a?" animate-spin":""}`}export{ae as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as d,j as e,a2 as _e,au as ge,W as be,av as fe,aw as je,ax as Je,ay as Xe,as as Ye}from"./vendor-CjJPKsTb.js";import{c as Z,r as Ze,h as H,b as V,B as v,u as es,a as G,s as B,L as ss}from"./index-MqPrlTQ4.js";import{P as ts}from"./PageHeader-KQ9mjVAV.js";import{C as as,u as P}from"./useAppMutation-CqHoYeK1.js";import{D as ee,A as se,a as te,b as ae,c as ve,d as ie,e as ne}from"./DialogShell-s3yKnQyp.js";import{I as Ke}from"./input-Bb_t6wr6.js";import{L as U}from"./label-8HO4VSYV.js";import{u as I}from"./useApiQuery-Bcqr7uHV.js";import{q as j}from"./queryKeys-BMvyDTQS.js";import{u as K}from"./i18n-CfLThlXq.js";import{E as is}from"./EChart-Dqa_Xbrn.js";import{P as re}from"./PageSection-C9Wb9Oe3.js";import{B as w}from"./badge-3ORqzzzc.js";import{C as le,a as oe}from"./card-D1l7si2X.js";import{e as ns}from"./charts-core-vuhzGmuT.js";import{c as rs}from"./clipboard-CALi6bTW.js";import"./query-D3IfCUhp.js";import"./router-CmaL1NgV.js";import"./radix-54BMi3RD.js";import"./charts-react-BeVWPrMt.js";import"./charts-engine-BJQRnjQ_.js";const we=d.forwardRef(({className:s,...t},r)=>e.jsx("textarea",{className:Z("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));we.displayName="Textarea";const E={listRequest(){return{url:"/api/keys",method:"GET"}},overviewRequest(s){return{url:"/api/stats/api-keys/overview",method:"GET",params:{days:s}}},usageRequest(s,t=10){return{url:"/api/stats/api-keys/usage",method:"GET",params:{days:s,limit:t}}},customEndpointOptionsRequest(){return{url:"/api/custom-endpoints",method:"GET"}},create:async s=>H(V.post("/api/keys",s)),update:async(s,t)=>{await H(V.patch(`/api/keys/${s}`,t))},delete:async s=>{await H(V.delete(`/api/keys/${s}`))},reveal:async s=>Ze({url:`/api/keys/${s}/reveal`,method:"GET"})},Ne=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function ls(){var r;const s=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}],t=I(j.customEndpoints.all(),E.customEndpointOptionsRequest());return d.useMemo(()=>{var l;const a=(((l=t.data)==null?void 0:l.endpoints)??[]).map(u=>({id:u.id,label:u.label||u.id}));return[...s,...a]},[(r=t.data)==null?void 0:r.endpoints])}function Ce({available:s,hint:t,onChange:r,selected:a}){const{t:l}=K(),u=a.length===0,m=()=>{r([])},g=c=>{if(a.includes(c)){r(a.filter(x=>x!==c));return}r([...a,c])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-3 text-xs text-muted-foreground",children:t}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:m,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:l("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:s.map(c=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:!u&&a.includes(c.id),onChange:()=>g(c.id),className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm",children:c.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",c.id,")"]})]},c.id))})]})}function os({availableEndpoints:s,isOpen:t,keyDescription:r,keyName:a,onDescriptionChange:l,onEndpointsChange:u,onKeyNameChange:m,onOpenChange:g,onSubmit:c,selectedEndpoints:x}){const{t:p}=K();return e.jsx(ee,{open:t,onOpenChange:g,children:e.jsxs(se,{className:"max-w-2xl",children:[e.jsxs(te,{children:[e.jsx(ae,{children:p("apiKeys.createNew")}),e.jsx(ve,{children:p("apiKeys.createDescription")})]}),e.jsxs(ie,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-primary/20 bg-accent px-4 py-3 text-xs text-primary",children:p("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[1rem] border border-blue-200 bg-blue-50/70 px-3 py-3 text-xs text-blue-900 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-100",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 text-blue-800/85 dark:text-blue-100/80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-[1rem] border border-amber-200 bg-amber-50/70 px-3 py-3 text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 text-amber-800/85 dark:text-amber-100/80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-[1rem] border border-rose-200 bg-rose-50/70 px-3 py-3 text-xs text-rose-900 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-100",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 text-rose-800/85 dark:text-rose-100/80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{htmlFor:"keyName",children:[p("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(Ke,{id:"keyName",value:a,onChange:n=>m(n.target.value),placeholder:p("apiKeys.keyNamePlaceholder"),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),c())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"keyDescription",children:p("apiKeys.descriptionLabel")}),e.jsx(we,{id:"keyDescription",value:r,onChange:n=>l(n.target.value),placeholder:p("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:p("apiKeys.allowedEndpoints")}),e.jsx(Ce,{available:s,selected:x,onChange:u,hint:p("apiKeys.selectEndpoints")})]})]}),e.jsxs(ne,{children:[e.jsx(v,{variant:"outline",onClick:()=>g(!1),children:p("common.actions.cancel")}),e.jsx(v,{onClick:c,children:p("apiKeys.createAction")})]})]})})}function ds({createdKey:s,onClose:t,onCopy:r}){const{t:a}=K();return e.jsx(ee,{open:!!s,onOpenChange:l=>{l||t()},children:e.jsxs(se,{className:"max-w-xl",children:[e.jsx(te,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600",children:e.jsx(_e,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(ae,{children:a("apiKeys.keyCreated")})]})}),e.jsxs(ie,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:a("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:s==null?void 0:s.key}),s!=null&&s.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:s.description}):null]}),e.jsxs(ne,{children:[e.jsxs(v,{onClick:()=>r((s==null?void 0:s.key)??""),children:[e.jsx(ge,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("common.actions.copy")]}),e.jsx(v,{variant:"outline",onClick:t,children:a("common.actions.close")})]})]})})}function cs({apiKey:s,availableEndpoints:t,onClose:r,onEndpointsChange:a,onSave:l,selectedEndpoints:u}){const{t:m}=K();return e.jsx(ee,{open:!!s,onOpenChange:g=>{g||r()},children:e.jsxs(se,{className:"max-w-2xl",children:[e.jsxs(te,{children:[e.jsx(ae,{children:m("apiKeys.editEndpoints")}),e.jsx(ve,{children:s==null?void 0:s.name})]}),e.jsxs(ie,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] px-4 py-3 text-xs text-[hsl(var(--warning)/1)]",children:m("apiKeys.allEndpoints")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:"Empty selection means unrestricted access. Only explicit selections create a restricted key scope."}),e.jsx(Ce,{available:t,selected:u,onChange:a,hint:m("apiKeys.selectEndpoints")})]}),e.jsxs(ne,{children:[e.jsx(v,{variant:"outline",onClick:r,children:m("common.actions.cancel")}),e.jsx(v,{onClick:l,children:m("common.save")})]})]})})}function ps({deleteTarget:s,isDeleting:t,onConfirm:r,onOpenChange:a}){const{t:l}=K();return e.jsx(as,{open:!!s,onOpenChange:a,title:l("apiKeys.deleteDialogTitle"),description:l("apiKeys.confirmDelete"),confirmLabel:s&&t===s.id?l("common.actions.loading"):l("apiKeys.actions.delete"),cancelLabel:l("common.actions.cancel"),loading:s?t===s.id:!1,onConfirm:r,children:s?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:s.name}):null})}function us(){const{t:s}=K();return e.jsx(re,{eyebrow:"Recommended",title:s("apiKeys.quickStart.title"),description:s("apiKeys.quickStart.description"),contentClassName:"pt-5",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(_,{icon:e.jsx(be,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(_,{icon:e.jsx(fe,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.restrict.title"),description:s("apiKeys.quickStart.restrict.description")}),e.jsx(_,{icon:e.jsx(je,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})}function xs({activeKeysValue:s,enabledKeysValue:t,loading:r,onRangeChange:a,rangeDays:l,requestsChartOption:u,totalKeysValue:m,tokensChartOption:g,usageLength:c}){const{t:x}=K();return e.jsx(re,{eyebrow:"Usage",title:x("apiKeys.analytics.title"),description:x("apiKeys.analytics.description",{days:l}),actions:e.jsx("div",{className:"flex w-full items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1 sm:w-auto",children:Ne.map(p=>{const n=l===p.value;return e.jsx("button",{type:"button",onClick:()=>a(p.value),className:Z("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:x(p.labelKey)},p.value)})}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(J,{label:x("apiKeys.analytics.cards.total"),value:m}),e.jsx(J,{label:x("apiKeys.analytics.cards.enabled"),value:t}),e.jsx(J,{label:x("apiKeys.analytics.cards.active",{days:l}),value:s})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(ye,{title:x("apiKeys.analytics.charts.requests"),loading:r,empty:c===0,emptyText:x("apiKeys.analytics.empty"),option:u}),e.jsx(ye,{title:x("apiKeys.analytics.charts.tokens"),loading:r,empty:c===0,emptyText:x("apiKeys.analytics.empty"),option:g})]})]})})}function ms({filteredKeys:s,formatDate:t,hasWildcard:r,isDeleting:a,isRevealing:l,keys:u,onCopy:m,onDelete:g,onEditEndpoints:c,onFilterChange:x,onHide:p,onReveal:n,onStatusFilterChange:F,onToggleEnabled:k,restrictedCount:f,revealedKeys:D,search:y,statusFilter:q,unrestrictedCount:O,wildcardCount:A}){const{t:h}=K();return e.jsx(re,{eyebrow:"Inventory",title:h("apiKeys.list.title"),description:r?h("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(w,{variant:"outline",children:`${s.length}/${u.length}`}),e.jsx(w,{variant:"outline",children:h("apiKeys.summary.wildcard",{count:A})}),e.jsx(w,{variant:"outline",children:h("apiKeys.summary.restricted",{count:f})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(X,{label:h("apiKeys.list.title"),value:`${s.length}/${u.length}`,helper:h("apiKeys.filters.searchPlaceholder")}),e.jsx(X,{label:h("apiKeys.summary.wildcard",{count:A}),value:String(A),helper:h("apiKeys.wildcardHint")}),e.jsx(X,{label:h("apiKeys.summary.restricted",{count:f}),value:String(f),helper:h("apiKeys.summary.unrestricted",{count:O})})]}),e.jsxs("div",{className:"grid gap-3 rounded-lg border border-border bg-secondary p-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,360px)] xl:grid-cols-[minmax(0,1fr)_180px_auto]",children:[e.jsx(Ke,{value:y,onChange:b=>x(b.target.value),placeholder:h("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1",children:["all","enabled","disabled"].map(b=>e.jsx("button",{type:"button",onClick:()=>F(b),className:Z("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",q===b?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:h(`apiKeys.filters.${b}`)},b))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:col-span-2 xl:col-span-1",children:[e.jsx(w,{variant:"secondary",children:h("apiKeys.summary.wildcard",{count:A})}),e.jsx(w,{variant:"secondary",children:h("apiKeys.summary.restricted",{count:f})})]})]}),u.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:h("apiKeys.list.empty")})}):s.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:h("apiKeys.list.emptyFiltered")})}):e.jsx("div",{className:"grid gap-4",children:s.map(b=>e.jsx(hs,{formatDate:t,isDeleting:a===b.id,isRevealing:l===b.id,keySummary:b,onCopy:m,onDelete:g,onEditEndpoints:c,onHide:p,onReveal:n,onToggleEnabled:k,revealedValue:D.get(b.id)},b.id))})]})})}function _({description:s,icon:t,title:r}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:t}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:r}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}function hs({formatDate:s,isDeleting:t,isRevealing:r,keySummary:a,onCopy:l,onDelete:u,onEditEndpoints:m,onHide:g,onReveal:c,onToggleEnabled:x,revealedValue:p}){var k,f,D,y;const{t:n}=K(),F=(a.totalInputTokens+a.totalOutputTokens).toLocaleString();return a.isWildcard||(((k=a.allowedEndpoints)==null?void 0:k.length)??0)>0,e.jsx(le,{"data-testid":"api-key-card",children:e.jsx(oe,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:a.name}),a.isWildcard?e.jsx(w,{variant:"secondary",children:n("apiKeys.wildcard")}):null,e.jsx(w,{variant:a.enabled?"default":"outline",children:a.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")}),a.isWildcard?null:e.jsx(w,{variant:"outline",className:"text-xs",children:(((f=a.allowedEndpoints)==null?void 0:f.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.allEndpoints")}),!a.isWildcard&&a.allowedEndpoints&&a.allowedEndpoints.length>0?a.allowedEndpoints.map(q=>e.jsx(w,{variant:"outline",className:"text-xs",children:q},q)):a.isWildcard?null:e.jsx(w,{variant:"secondary",className:"text-xs opacity-60",children:n("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(Y,{label:n("apiKeys.requestCount"),value:a.requestCount.toLocaleString()}),e.jsx(Y,{label:n("apiKeys.totalTokens"),value:F}),e.jsx(Y,{label:n("apiKeys.allowedEndpoints"),value:a.isWildcard?n("apiKeys.wildcard"):a.allowedEndpoints&&a.allowedEndpoints.length>0?a.allowedEndpoints.join(", "):n("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("code",{className:"block max-w-full break-all rounded-lg border border-border bg-secondary px-3 py-1.5 font-mono text-sm",children:a.isWildcard?n("apiKeys.wildcard"):p??a.maskedKey??"********"}),a.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:p?e.jsxs(e.Fragment,{children:[e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(p),"aria-label":n("common.actions.copy"),title:n("common.actions.copy"),children:e.jsx(ge,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>g(a.id),"aria-label":n("apiKeys.actions.hide"),title:n("apiKeys.actions.hide"),children:e.jsx(je,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(a.id),disabled:r,"aria-label":n("apiKeys.actions.reveal"),title:n("apiKeys.actions.reveal"),children:r?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Je,{className:"h-4 w-4","aria-hidden":"true"})})})]}),a.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("apiKeys.wildcardHint")}):a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null,a.isWildcard?null:e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((D=a.allowedEndpoints)==null?void 0:D.length)??0)>0?`${n("apiKeys.allowedEndpoints")}: ${(y=a.allowedEndpoints)==null?void 0:y.join(", ")}`:n("apiKeys.allEndpoints")}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:s(a.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:s(a.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[a.isWildcard?null:e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>m(a),className:"w-full lg:w-auto",children:[e.jsx(fe,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),n("apiKeys.editEndpoints")]}),e.jsx(v,{variant:a.enabled?"outline":"default",size:"sm",onClick:()=>x(a.id,a.enabled),className:"w-full lg:w-auto",children:a.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),a.isWildcard?null:e.jsx(v,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>u(a),disabled:t,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(Xe,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function J({label:s,value:t}){return e.jsx(le,{children:e.jsxs(oe,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-foreground",children:t})]})})}function X({helper:s,label:t,value:r}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 text-lg font-semibold text-foreground",children:r}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function Y({label:s,value:t}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:t})]})}function ye({empty:s,emptyText:t,loading:r,option:a,title:l}){const{t:u}=K();return e.jsx(le,{children:e.jsxs(oe,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:l}),r?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u("common.loadingShort")})}):s?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:t})}):e.jsx(is,{echarts:ns,option:a,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function ys(){const{t:s}=K(),{pushToast:t}=es(),[r,a]=d.useState(!1),[l,u]=d.useState(""),[m,g]=d.useState(""),[c,x]=d.useState([]),[p,n]=d.useState(null),[F,k]=d.useState(null),[f,D]=d.useState(null),[y,q]=G(B.apiKeys.rangeDays,7,{serialize:i=>String(i),deserialize:i=>{const o=Number(i);return Ne.some(N=>N.value===o)?o:7}}),[O,A]=d.useState(new Map),[h,b]=d.useState(null),[S,z]=d.useState(null),[W,de]=d.useState([]),[$,Ee]=G(B.apiKeys.search,""),[L,ke]=G(B.apiKeys.statusFilter,"all",{serialize:i=>i,deserialize:i=>i==="enabled"||i==="disabled"?i:"all"}),De=ls(),ce=I(j.apiKeys.all(),E.listRequest()),Ae=I(j.apiKeys.overview(y),E.overviewRequest(y)),pe=I(j.apiKeys.usage(y),E.usageRequest(y)),ue=P({mutationFn:E.create,invalidateKeys:[j.apiKeys.all(),j.apiKeys.overview(y),j.apiKeys.usage(y)],successToast:()=>({title:s("apiKeys.toast.keyCreated")}),errorToast:i=>({title:s("apiKeys.toast.createFailure",{message:i.message})})}),M=P({mutationFn:({id:i,...o})=>E.update(i,o),invalidateKeys:[j.apiKeys.all(),j.apiKeys.overview(y),j.apiKeys.usage(y)],successToast:()=>({title:s("apiKeys.toast.keyUpdated")}),errorToast:i=>({title:s("apiKeys.toast.updateFailure",{message:i.message})})}),xe=P({mutationFn:({id:i})=>E.delete(i),invalidateKeys:[j.apiKeys.all(),j.apiKeys.overview(y),j.apiKeys.usage(y)],successToast:()=>({title:s("apiKeys.toast.keyDeleted")}),errorToast:i=>({title:s("apiKeys.toast.deleteFailure",{message:i.message})})}),me=P({mutationFn:({id:i})=>E.reveal(i),errorToast:i=>({title:s("apiKeys.toast.revealFailure"),description:i.message})}),T=ce.data??[],R=Ae.data,C=pe.data??[],Te=T.some(i=>i.isWildcard),qe=T.filter(i=>i.isWildcard).length,Re=T.filter(i=>{var o;return!i.isWildcard&&(((o=i.allowedEndpoints)==null?void 0:o.length)??0)>0}).length,Fe=T.filter(i=>{var o;return!i.isWildcard&&(((o=i.allowedEndpoints)==null?void 0:o.length)??0)===0}).length,Oe=R?R.totalKeys.toLocaleString():"-",Se=R?R.enabledKeys.toLocaleString():"-",We=R?R.activeKeys.toLocaleString():"-",Le=d.useMemo(()=>T.filter(i=>{if(!(L==="all"||(L==="enabled"?i.enabled:!i.enabled)))return!1;const N=$.trim().toLowerCase();return N?[i.name,i.description??"",i.maskedKey??"",...i.allowedEndpoints??[]].join(" ").toLowerCase().includes(N):!0}),[T,$,L]),Me=d.useMemo(()=>{const i=C.map(o=>o.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:i,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.requestsSeries"),type:"bar",data:C.map(o=>o.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[s,C]),Pe=d.useMemo(()=>{const i=C.map(o=>o.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[s("apiKeys.analytics.tokens.input"),s("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:i,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:C.map(o=>o.inputTokens)},{name:s("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:C.map(o=>o.outputTokens)}]}},[s,C]),he=d.useCallback(()=>{u(""),g(""),x([])},[]),Q=d.useCallback(i=>{a(i),i||he()},[he]),Ie=d.useCallback(async()=>{if(!l.trim()){t({title:s("apiKeys.errors.nameRequired"),variant:"error"});return}try{const i=await ue.mutateAsync({name:l.trim(),description:m.trim()||void 0,allowedEndpoints:c.length>0?c:void 0});n(i),Q(!1)}catch{}},[ue,Q,m,c,l,t,s]),ze=d.useCallback(async(i,o)=>{try{await M.mutateAsync({id:i,enabled:!o})}catch{}},[M]),$e=d.useCallback(async()=>{if(f){k(f.id);try{await xe.mutateAsync({id:f.id}),D(null)}catch{}finally{k(null)}}},[f,xe]),Qe=d.useCallback(async i=>{if(!O.has(i)){b(i);try{const o=await me.mutateAsync({id:i});A(N=>new Map(N).set(i,o.key))}catch{}finally{b(null)}}},[me,O]),He=d.useCallback(i=>{A(o=>{const N=new Map(o);return N.delete(i),N})},[]),Ve=d.useCallback(async i=>{try{await rs(i),t({title:s("apiKeys.toast.keyCopied"),variant:"success"})}catch(o){t({title:s("apiKeys.toast.copyFailure"),description:o instanceof Error?o.message:s("common.unknownError"),variant:"error"})}},[t,s]),Ge=d.useCallback(i=>{z(i),de(i.allowedEndpoints??[])},[]),Be=d.useCallback(async()=>{if(S)try{await M.mutateAsync({id:S.id,allowedEndpoints:W.length>0?W:null}),z(null)}catch{}},[S,W,M]),Ue=d.useCallback(i=>i?new Date(i).toLocaleString():s("common.noData"),[s]);return{activeKeysValue:We,availableEndpoints:De,deleteTarget:f,editEndpointsKey:S,editEndpointsSelection:W,enabledKeysValue:Se,filteredKeys:Le,formatDate:Ue,handleCopyKey:Ve,handleCreateDialogChange:Q,handleCreateKey:Ie,handleDeleteKey:$e,handleHideKey:He,handleOpenEditEndpoints:Ge,handleRevealKey:Qe,handleSaveEndpoints:Be,handleToggleEnabled:ze,hasWildcard:Te,isCreateDialogOpen:r,isDeleting:F,isRevealing:h,keys:T,keysQuery:ce,newKeyDescription:m,newKeyEndpoints:c,newKeyName:l,newlyCreatedKey:p,rangeDays:y,requestsChartOption:Me,restrictedCount:Re,revealedKeys:O,search:$,setDeleteTarget:D,setEditEndpointsKey:z,setEditEndpointsSelection:de,setNewKeyDescription:g,setNewKeyEndpoints:x,setNewKeyName:u,setNewlyCreatedKey:n,setRangeDays:q,setSearch:Ee,setStatusFilter:ke,statusFilter:L,tokensChartOption:Pe,totalKeysValue:Oe,unrestrictedCount:Fe,usage:C,usageQuery:pe,wildcardCount:qe}}function Ms(){const{t:s}=K(),t=ys(),r=s("apiKeys.summary.totalCount",{count:t.keys.length});return t.keysQuery.isLoading?e.jsx(ss,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ts,{icon:e.jsx(be,{className:"h-5 w-5","aria-hidden":"true"}),title:s("apiKeys.title"),description:s("apiKeys.description"),eyebrow:"Access Control",breadcrumb:"Gateway / API Keys",helper:s("apiKeys.helper"),badge: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.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:[s("apiKeys.summary.wildcard",{count:t.wildcardCount})," / ",s("apiKeys.summary.restricted",{count:t.restrictedCount})," / ",s("apiKeys.summary.unrestricted",{count:t.unrestrictedCount})]}),e.jsxs(v,{onClick:()=>t.handleCreateDialogChange(!0),className:"w-full sm:w-auto",children:[e.jsx(Ye,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("apiKeys.createNew")]})]})}),e.jsx(us,{}),e.jsx(xs,{activeKeysValue:t.activeKeysValue,enabledKeysValue:t.enabledKeysValue,loading:t.usageQuery.isLoading,onRangeChange:t.setRangeDays,rangeDays:t.rangeDays,requestsChartOption:t.requestsChartOption,totalKeysValue:t.totalKeysValue,tokensChartOption:t.tokensChartOption,usageLength:t.usage.length}),e.jsx(ms,{filteredKeys:t.filteredKeys,formatDate:t.formatDate,hasWildcard:t.hasWildcard,isDeleting:t.isDeleting,isRevealing:t.isRevealing,keys:t.keys,onCopy:a=>void t.handleCopyKey(a),onDelete:t.setDeleteTarget,onEditEndpoints:t.handleOpenEditEndpoints,onFilterChange:t.setSearch,onHide:t.handleHideKey,onReveal:a=>void t.handleRevealKey(a),onStatusFilterChange:t.setStatusFilter,onToggleEnabled:(a,l)=>void t.handleToggleEnabled(a,l),restrictedCount:t.restrictedCount,revealedKeys:t.revealedKeys,search:t.search,statusFilter:t.statusFilter,unrestrictedCount:t.unrestrictedCount,wildcardCount:t.wildcardCount}),e.jsx(os,{availableEndpoints:t.availableEndpoints,isOpen:t.isCreateDialogOpen,keyDescription:t.newKeyDescription,keyName:t.newKeyName,onDescriptionChange:t.setNewKeyDescription,onEndpointsChange:t.setNewKeyEndpoints,onKeyNameChange:t.setNewKeyName,onOpenChange:t.handleCreateDialogChange,onSubmit:()=>void t.handleCreateKey(),selectedEndpoints:t.newKeyEndpoints}),e.jsx(ds,{createdKey:t.newlyCreatedKey,onClose:()=>t.setNewlyCreatedKey(null),onCopy:a=>void t.handleCopyKey(a)}),e.jsx(cs,{apiKey:t.editEndpointsKey,availableEndpoints:t.availableEndpoints,onClose:()=>t.setEditEndpointsKey(null),onEndpointsChange:t.setEditEndpointsSelection,onSave:()=>void t.handleSaveEndpoints(),selectedEndpoints:t.editEndpointsSelection}),e.jsx(ps,{deleteTarget:t.deleteTarget,isDeleting:t.isDeleting,onConfirm:()=>void t.handleDeleteKey(),onOpenChange:a=>{!a&&t.isDeleting===null&&t.setDeleteTarget(null)}})]})}export{Ms as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,j as e,ab as le,ac as Ie,ad as qe,ae as ie,af as Ae,X as ce,ag as Pe,ah as De,S as Q,ai as Me,aj as Be,V as Fe}from"./vendor-CjJPKsTb.js";import{P as Oe}from"./PageHeader-KQ9mjVAV.js";import{P as K,a as z}from"./PageState-D-1-sNyq.js";import{c as S,u as _e,a as $e,b as Ge,t as He,s as Qe,B as V}from"./index-MqPrlTQ4.js";import{S as ze,a as Ve,b as Ue,c as Ke,d as O}from"./select-kdaAyzec.js";import{E as Ye}from"./EChart-Dqa_Xbrn.js";import{P as me}from"./PageSection-C9Wb9Oe3.js";import{S as Xe,C as Ze,T as Je}from"./Skeleton-H3SErRWs.js";import{B as E}from"./badge-3ORqzzzc.js";import{C as M,a as B}from"./card-D1l7si2X.js";import{u as C}from"./i18n-CfLThlXq.js";import{e as We}from"./charts-core-vuhzGmuT.js";import{u as w}from"./useApiQuery-Bcqr7uHV.js";import{q as L}from"./queryKeys-BMvyDTQS.js";import"./query-D3IfCUhp.js";import"./router-CmaL1NgV.js";import"./radix-54BMi3RD.js";import"./charts-react-BeVWPrMt.js";import"./charts-engine-BJQRnjQ_.js";const Y=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-lg border border-border bg-background",children:e.jsx("table",{ref:a,className:S("w-full caption-bottom border-collapse text-sm",t),...s})}));Y.displayName="Table";const X=i.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:S("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",t),...s}));X.displayName="TableHeader";const Z=i.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:S("[&_tr:last-child]:border-0",t),...s}));Z.displayName="TableBody";const et=i.forwardRef(({className:t,...s},a)=>e.jsx("tfoot",{ref:a,className:S("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",t),...s}));et.displayName="TableFooter";const F=i.forwardRef(({className:t,...s},a)=>e.jsx("tr",{ref:a,className:S("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...s}));F.displayName="TableRow";const p=i.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:S("h-12 px-4 text-left align-middle text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...s}));p.displayName="TableHead";const b=i.forwardRef(({className:t,...s},a)=>e.jsx("td",{ref:a,className:S("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...s}));b.displayName="TableCell";const tt=i.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:S("mt-4 text-sm text-muted-foreground",t),...s}));tt.displayName="TableCaption";const _=15e3,U=6e4,T={requests:"#2563eb",input:"#059669",output:"#ea580c",cacheRead:"#7c3aed",cacheCreation:"#e11d48",latency:"#0891b2"};function D(t,s,a){return t==null?"-":`${t.toLocaleString(void 0,a)} ${s}`}function de(t){if(t==null)return"-";if(t<1024)return`${t} B`;const s=["KB","MB","GB","TB"];let a=t/1024,r=0;for(;a>=1024&&r<s.length-1;)a/=1024,r+=1;return`${a.toFixed(a>=100?0:a>=10?1:2)} ${s[r]}`}function st(t){return t==null?"-":`${t.toLocaleString(void 0,{maximumFractionDigits:t>=10?0:1})}%`}function at(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:6}).map((t,s)=>e.jsx(Xe,{},s))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((t,s)=>e.jsx(Ze,{},s))}),e.jsx("div",{className:"rounded-lg border border-border",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((t,s)=>e.jsx(Je,{columns:6},s))})})})]})}function rt({dbSizeDisplay:t,memoryDisplay:s,selectedEndpointLabel:a,status:r,todayRequests:d}){const{t:o}=C();return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(320px,0.9fr)]",children:[e.jsx(M,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"max-w-2xl space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold text-primary",children:[e.jsx(le,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Live Gateway"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:a}),e.jsx("p",{className:"max-w-xl text-sm text-muted-foreground",children:o("dashboard.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:o("dashboard.status.listeningLabel")}),e.jsx(E,{variant:"secondary",children:a}),e.jsxs(E,{variant:"outline",children:[o("dashboard.labels.todayRequests"),": ",d.toLocaleString()]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4 lg:min-w-[420px] lg:flex-1",children:[e.jsx($,{icon:e.jsx(Ie,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.activeRequests"),value:((r==null?void 0:r.activeRequests)??0).toLocaleString()}),e.jsx($,{icon:e.jsx(qe,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.cpu"),value:st(r==null?void 0:r.cpuUsagePercent)}),e.jsx($,{icon:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.database"),value:t}),e.jsx($,{icon:e.jsx(Ae,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.memory"),value:s})]})]})})}),e.jsx(M,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Gateway runtime"}),e.jsxs("p",{className:"mt-1.5 text-xl font-semibold text-foreground",children:[(r==null?void 0:r.host)??"0.0.0.0",":",(r==null?void 0:r.port)??"-"]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(P,{label:o("dashboard.labels.providers"),value:((r==null?void 0:r.providers)??0).toLocaleString()}),e.jsx(P,{label:o("dashboard.labels.activeClientAddresses"),value:((r==null?void 0:r.activeClientAddresses)??0).toLocaleString()}),e.jsx(P,{label:o("dashboard.labels.activeClientSessions"),value:((r==null?void 0:r.activeClientSessions)??0).toLocaleString()}),e.jsx(P,{label:o("dashboard.labels.uniqueClientAddressesLastHour"),value:((r==null?void 0:r.uniqueClientAddressesLastHour)??0).toLocaleString()}),e.jsx(P,{label:o("dashboard.labels.uniqueClientSessionsLastHour"),value:((r==null?void 0:r.uniqueClientSessionsLastHour)??0).toLocaleString()})]})]})})})]})}function ot({overview:t}){const{t:s}=C();return e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(I,{icon:e.jsx(ce,{className:"h-5 w-5"}),title:s("dashboard.cards.todayRequests"),value:(t==null?void 0:t.today.requests)??0,suffix:s("common.units.request"),iconClass:"bg-blue-50 text-blue-600 dark:bg-blue-950 dark:text-blue-400"}),e.jsx(I,{icon:e.jsx(Pe,{className:"h-5 w-5"}),title:s("dashboard.cards.todayInput"),value:(t==null?void 0:t.today.inputTokens)??0,suffix:s("common.units.token"),iconClass:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400"}),e.jsx(I,{icon:e.jsx(De,{className:"h-5 w-5"}),title:s("dashboard.cards.todayCacheRead"),value:(t==null?void 0:t.today.cacheReadTokens)??0,suffix:s("common.units.token"),iconClass:"bg-violet-50 text-violet-600 dark:bg-violet-950 dark:text-violet-400"}),e.jsx(I,{icon:e.jsx(le,{className:"h-5 w-5"}),title:s("dashboard.cards.todayCacheCreation"),value:(t==null?void 0:t.today.cacheCreationTokens)??0,suffix:s("common.units.token"),iconClass:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}),e.jsx(I,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:s("dashboard.cards.todayOutput"),value:(t==null?void 0:t.today.outputTokens)??0,suffix:s("common.units.token"),iconClass:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400"}),e.jsx(I,{icon:e.jsx(Me,{className:"h-5 w-5"}),title:s("dashboard.cards.avgLatency"),value:(t==null?void 0:t.today.avgLatencyMs)??0,suffix:s("common.units.ms"),iconClass:"bg-cyan-50 text-cyan-600 dark:bg-cyan-950 dark:text-cyan-400"})]})}function nt({busiestDay:t,fastestTtftModel:s,topModel:a,totalRequestsInRange:r}){const{t:d}=C();return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(G,{label:d("dashboard.insights.totalRequests"),value:r.toLocaleString(),hint:d("dashboard.insights.totalRequestsHint")}),e.jsx(G,{label:d("dashboard.insights.busiestDay"),value:t?t.date:"-",hint:t?d("dashboard.insights.busiestDayHint",{value:t.requestCount.toLocaleString()}):d("common.noData")}),e.jsx(G,{label:d("dashboard.insights.topModel"),value:a?`${a.provider}/${a.model}`:"-",hint:a?d("dashboard.insights.topModelHint",{value:a.requests.toLocaleString()}):d("common.noData")}),e.jsx(G,{label:d("dashboard.insights.fastestTtft"),value:s?`${s.provider}/${s.model}`:"-",hint:s?D(s.avgTtftMs,d("common.units.ms")):d("common.noData")})]})}function dt({dailyEmpty:t,dailyOption:s,dailyPending:a,models:r,modelRequestsOption:d,modelUsagePending:o,ttftOption:m,tpotOption:R}){const{t:l}=C();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:l("dashboard.charts.requestsTitle"),description:l("dashboard.charts.requestsDesc"),loading:a,option:s,empty:t,emptyText:l("dashboard.charts.empty")}),e.jsx(H,{title:l("dashboard.charts.modelTitle"),description:l("dashboard.charts.modelDesc"),loading:o,option:d,empty:!r.length,emptyText:l("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:l("dashboard.charts.ttftTitle"),description:l("dashboard.charts.ttftDesc"),loading:o,option:m,empty:!r.some(c=>c.avgTtftMs!=null&&c.avgTtftMs>0),emptyText:l("dashboard.charts.ttftEmpty")}),e.jsx(H,{title:l("dashboard.charts.tpotTitle"),description:l("dashboard.charts.tpotDesc"),loading:o,option:R,empty:!r.some(c=>c.avgTpotMs!=null&&c.avgTpotMs>0),emptyText:l("dashboard.charts.tpotEmpty")})]})]})}function lt({models:t,loading:s}){const{t:a}=C();return e.jsx(me,{title:a("dashboard.modelTable.title"),description:a("dashboard.modelTable.description"),children:s?e.jsx(K,{compact:!0,label:a("common.loadingShort")}):t.length===0?e.jsx(z,{compact:!0,icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:a("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto rounded-lg border border-border",children:e.jsxs(Y,{children:[e.jsx(X,{children:e.jsxs(F,{children:[e.jsx(p,{children:a("dashboard.modelTable.columns.model")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.requests")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.latency")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.ttft")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.tpot")})]})}),e.jsx(Z,{children:t.map(r=>e.jsxs(F,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:r.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r.model})]})}),e.jsx(b,{className:"text-right font-medium",children:r.requests.toLocaleString()}),e.jsx(b,{className:"text-right",children:D(r.avgLatencyMs,a("common.units.ms"))}),e.jsx(b,{className:"text-right",children:D(r.avgTtftMs,a("common.units.ms"))}),e.jsx(b,{className:"text-right",children:D(r.avgTpotMs,a("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${r.provider}/${r.model}`))})]})})})}function it({records:t,loading:s}){const{t:a}=C(),r=t.filter(o=>!o.error&&(o.status_code??200)<400).length,d=t.filter(o=>o.error||(o.status_code??200)>=400).length;return e.jsx(me,{title:a("dashboard.recent.title"),description:a("dashboard.recent.subtitle",{count:5}),actions:t.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{variant:"secondary",children:t.length}),e.jsxs(E,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:[a("common.status.success"),": ",r]}),e.jsxs(E,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[a("common.status.error"),": ",d]})]}):null,children:s?e.jsx(K,{compact:!0,label:a("dashboard.recent.loading")}):t.length===0?e.jsx(z,{compact:!0,icon:e.jsx(ce,{className:"h-5 w-5","aria-hidden":"true"}),title:a("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto rounded-lg border border-border",children:e.jsxs(Y,{children:[e.jsx(X,{children:e.jsxs(F,{children:[e.jsx(p,{children:a("dashboard.recent.columns.time")}),e.jsx(p,{children:a("dashboard.recent.columns.endpoint")}),e.jsx(p,{children:a("dashboard.recent.columns.provider")}),e.jsx(p,{children:a("dashboard.recent.columns.route")}),e.jsx(p,{className:"text-right",children:a("dashboard.recent.columns.latency")}),e.jsx(p,{children:a("dashboard.recent.columns.status")})]})}),e.jsx(Z,{children:t.map(o=>e.jsxs(F,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(o.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",o.id]})]})}),e.jsx(b,{children:e.jsx(E,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?a("logs.table.endpointAnthropic"):o.endpoint==="openai"?a("logs.table.endpointOpenAI"):o.endpoint})}),e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:o.stream?"stream":"sync"})]})}),e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx("span",{children:o.client_model??a("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"->"}),e.jsx("span",{className:"font-medium text-foreground",children:o.model})]}),o.error?e.jsx("span",{className:"truncate text-destructive",children:o.error}):null]})}),e.jsx(b,{className:"text-right font-medium",children:D(o.latency_ms,a("common.units.ms"))}),e.jsx(b,{children:e.jsx(E,{variant:o.error?"destructive":"default",className:"min-w-14 justify-center",children:(o.status_code??(o.error?500:200)).toString()})})]},o.id))})]})})})}function $({icon:t,label:s,value:a}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-primary/10 text-primary",children:t}),s]}),e.jsx("p",{className:"mt-2 text-lg font-semibold text-foreground",children:a})]})}function P({label:t,value:s}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-foreground",children:s})]})}function I({icon:t,iconClass:s,suffix:a,title:r,value:d}){return e.jsx(M,{children:e.jsxs(B,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:r}),t?e.jsx("div",{className:S("flex h-9 w-9 items-center justify-center rounded-lg",s),children:t}):null]}),e.jsxs("p",{className:"mt-3 text-2xl font-bold text-foreground",children:[d.toLocaleString(),a?e.jsx("span",{className:"ml-1.5 text-sm font-normal text-muted-foreground",children:a}):null]})]})})}function G({label:t,value:s,hint:a}){return e.jsx(M,{children:e.jsxs(B,{className:"pt-4",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold text-foreground",children:s}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a})]})})}function H({description:t,empty:s,emptyText:a,loading:r,option:d,title:o}){const{t:m}=C();return e.jsx(M,{children:e.jsxs(B,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:o}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),r?e.jsx(K,{compact:!0,className:"min-h-[320px]",label:m("common.loadingShort")}):s?e.jsx(z,{compact:!0,className:"min-h-[320px]",icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:a??m("dashboard.charts.empty")}):e.jsx(Ye,{echarts:We,option:d,className:"h-[40vh] min-h-[280px] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function ct(){var J,W,ee,te,se,ae,re,oe;const{t}=C(),{pushToast:s}=_e(),[a,r]=$e(Qe.dashboard.endpointFilter,"all"),[d,o]=i.useState(!1),m=a==="all"?void 0:a,R=w(L.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:U,refetchIntervalInBackground:!0}),l=w(L.stats.overview(a),{url:"/api/stats/overview",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:_,refetchIntervalInBackground:!0}),c=w(L.stats.daily(14,a),{url:"/api/stats/daily",method:"GET",params:{days:14,...m?{endpoint:m}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),y=w(L.stats.model(7,6,a),{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...m?{endpoint:m}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),g=w(L.status.byEndpoint(a),{url:"/api/status",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:_,refetchIntervalInBackground:!0}),x=w(L.db.info(),{url:"/api/db/info",method:"GET"},{refetchInterval:_,refetchIntervalInBackground:!0}),N=w(L.logs.recent(a),{url:"/api/logs",method:"GET",params:{limit:5,...m?{endpoint:m}:{}}},{refetchInterval:_,refetchIntervalInBackground:!0});i.useEffect(()=>{l.isError&&l.error&&s({title:t("dashboard.toast.overviewError"),description:l.error.message,variant:"error"})},[l.error,l.isError,s,t]),i.useEffect(()=>{c.isError&&c.error&&s({title:t("dashboard.toast.dailyError"),description:c.error.message,variant:"error"})},[c.error,c.isError,s,t]),i.useEffect(()=>{y.isError&&y.error&&s({title:t("dashboard.toast.modelError"),description:y.error.message,variant:"error"})},[y.error,y.isError,s,t]),i.useEffect(()=>{g.isError&&g.error&&s({title:t("dashboard.toast.statusError"),description:g.error.message,variant:"error"})},[g.error,g.isError,s,t]),i.useEffect(()=>{x.isError&&x.error&&s({title:t("dashboard.toast.dbError"),description:x.error.message,variant:"error"})},[x.error,x.isError,s,t]),i.useEffect(()=>{N.isError&&N.error&&s({title:t("dashboard.toast.recentError"),description:N.error.message,variant:"error"})},[N.error,N.isError,s,t]);const he=i.useCallback(async()=>{await Promise.all([R.refetch(),l.refetch(),c.refetch(),y.refetch(),g.refetch(),x.refetch(),N.refetch()])},[R,x,c,N,y,l,g]),ue=i.useCallback(async()=>{if(!d){o(!0);try{await Ge.post("/api/db/compact"),await x.refetch(),s({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(n){const h=He(n);s({title:t("dashboard.toast.compactError.title"),description:h.message,variant:"error"})}finally{o(!1)}}},[d,x,s,t]),xe=l.data,v=c.data??[],u=y.data??[],pe=g.data,k=x.data,be=((J=N.data)==null?void 0:J.items)??[],ge=a==="all"?t("dashboard.filters.endpointAll"):a==="anthropic"?t("dashboard.filters.endpointAnthropic"):a==="openai"?t("dashboard.filters.endpointOpenAI"):((te=(ee=(W=R.data)==null?void 0:W.endpoints)==null?void 0:ee.find(n=>n.id===a))==null?void 0:te.label)||a,fe=v.reduce((n,h)=>n+h.requestCount,0),je=v.reduce((n,h)=>!n||h.requestCount>n.requestCount?h:n,null),ye=u[0],Ne=u.filter(n=>n.avgTtftMs!=null&&n.avgTtftMs>0).sort((n,h)=>(n.avgTtftMs??Number.POSITIVE_INFINITY)-(h.avgTtftMs??Number.POSITIVE_INFINITY))[0],ve=R.isFetching||l.isFetching||c.isFetching||y.isFetching||g.isFetching||x.isFetching||N.isFetching,Te=l.isPending||g.isPending||x.isPending,Se=((se=l.error)==null?void 0:se.message)??((ae=g.error)==null?void 0:ae.message)??((re=x.error)==null?void 0:re.message)??null,Ce=k?de(k.totalBytes??k.sizeBytes):"-",Ee=de(k==null?void 0:k.memoryRssBytes),Re=i.useMemo(()=>{const n=v.map(j=>j.date),h=t("dashboard.charts.barRequests"),q=t("dashboard.charts.lineInput"),A=t("dashboard.charts.lineOutput"),f=t("dashboard.charts.lineCacheRead"),ne=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[h,q,A,f,ne]},grid:{left:56,right:28,top:56,bottom:54},xAxis:{type:"category",data:n},yAxis:{type:"value"},series:[{name:h,type:"bar",data:v.map(j=>j.requestCount),itemStyle:{color:T.requests,borderRadius:[6,6,0,0]}},{name:q,type:"line",smooth:!0,data:v.map(j=>j.inputTokens),itemStyle:{color:T.input},lineStyle:{width:2}},{name:A,type:"line",smooth:!0,data:v.map(j=>j.outputTokens),itemStyle:{color:T.output},lineStyle:{width:2}},{name:f,type:"line",smooth:!0,data:v.map(j=>j.cacheReadTokens),itemStyle:{color:T.cacheRead},lineStyle:{width:2}},{name:ne,type:"line",smooth:!0,data:v.map(j=>j.cacheCreationTokens),itemStyle:{color:T.cacheCreation},lineStyle:{width:2}}]}},[v,t]),ke=i.useMemo(()=>{const n=u.map(f=>`${f.provider}/${f.model}`),h=t("dashboard.charts.barRequests"),q=t("dashboard.charts.lineInput"),A=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[h,q,A]},grid:{left:72,right:52,top:56,bottom:96},xAxis:{type:"category",data:n,axisLabel:{rotate:28}},yAxis:[{type:"value",name:h},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:h,type:"bar",data:u.map(f=>f.requests),itemStyle:{color:T.requests,borderRadius:[6,6,0,0]}},{name:q,type:"line",yAxisIndex:1,smooth:!0,data:u.map(f=>f.inputTokens??0),itemStyle:{color:T.input}},{name:A,type:"line",yAxisIndex:1,smooth:!0,data:u.map(f=>f.outputTokens??0),itemStyle:{color:T.output}}]}},[u,t]),we=i.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:u.map(n=>`${n.provider}/${n.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:t("dashboard.charts.ttftLabel"),type:"bar",data:u.map(n=>n.avgTtftMs??0),itemStyle:{color:T.latency,borderRadius:[6,6,0,0]}}]}),[u,t]),Le=i.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:u.map(n=>`${n.provider}/${n.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:t("dashboard.charts.tpotLabel"),type:"bar",data:u.map(n=>n.avgTpotMs??0),itemStyle:{color:T.output,borderRadius:[6,6,0,0]}}]}),[u,t]);return{compacting:d,customEndpoints:((oe=R.data)==null?void 0:oe.endpoints)??[],daily:v,dailyOption:Re,dailyPending:c.isPending,dbInfo:k,dbSizeDisplay:Ce,endpointFilter:a,fastestTtftModel:Ne,handleCompact:ue,handleRefresh:he,bootstrapError:Se,isBootstrapping:Te,isRefreshing:ve,latestLogsPending:N.isPending,memoryDisplay:Ee,modelRequestsOption:ke,modelUsagePending:y.isPending,models:u,overview:xe,recentLogs:be,selectedEndpointLabel:ge,setEndpointFilter:r,status:pe,topModel:ye,totalRequestsInRange:fe,busiestDay:je,ttftOption:we,tpotOption:Le}}function Lt(){var a;const{t}=C(),s=ct();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Oe,{icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),badge:s.selectedEndpointLabel,eyebrow:"Operations",breadcrumb:"Gateway / Dashboard",helper:t("dashboard.charts.requestsDesc"),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:[t("dashboard.filters.endpoint")," · ",s.selectedEndpointLabel]}),e.jsxs(ze,{value:s.endpointFilter,onValueChange:s.setEndpointFilter,children:[e.jsx(Ve,{className:"w-full sm:w-[168px]",children:e.jsx(Ue,{})}),e.jsxs(Ke,{children:[e.jsx(O,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(O,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(O,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),s.customEndpoints.map(r=>e.jsx(O,{value:r.id,children:r.label||r.id},r.id))]})]}),e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>void s.handleRefresh(),disabled:s.isRefreshing,className:"w-full sm:w-auto",children:[e.jsx(Be,{className:S("mr-2 h-4 w-4",s.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),s.isRefreshing?t("common.actions.refreshing"):t("common.actions.refresh")]}),e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>void s.handleCompact(),disabled:s.compacting,className:"w-full sm:w-auto",children:[e.jsx(ie,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s.compacting?t("dashboard.actions.compacting"):t("dashboard.actions.compact")]})]})}),s.isBootstrapping?e.jsx(at,{}):s.bootstrapError?e.jsx(z,{icon:e.jsx(Fe,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:t("common.status.error"),description:s.bootstrapError,action:e.jsx(V,{variant:"outline",onClick:()=>void s.handleRefresh(),children:t("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[e.jsx(rt,{dbSizeDisplay:s.dbSizeDisplay,memoryDisplay:s.memoryDisplay,selectedEndpointLabel:s.selectedEndpointLabel,status:s.status,todayRequests:((a=s.overview)==null?void 0:a.today.requests)??0}),e.jsx(ot,{overview:s.overview}),e.jsx(nt,{busiestDay:s.busiestDay,fastestTtftModel:s.fastestTtftModel,topModel:s.topModel,totalRequestsInRange:s.totalRequestsInRange}),e.jsx(dt,{dailyEmpty:!s.daily.length,dailyOption:s.dailyOption,dailyPending:s.dailyPending,models:s.models,modelRequestsOption:s.modelRequestsOption,modelUsagePending:s.modelUsagePending,ttftOption:s.ttftOption,tpotOption:s.tpotOption}),e.jsx(lt,{models:s.models,loading:s.modelUsagePending}),e.jsx(it,{records:s.recentLogs,loading:s.latestLogsPending})]})]})}export{Lt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as t,a8 as g}from"./vendor-CjJPKsTb.js";import{F as u,G as n,H as d,J as b,K as l,M as y,O as i}from"./radix-54BMi3RD.js";import{c as o}from"./index-MqPrlTQ4.js";const k=u,N=b,c=r.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,className:o("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=i.displayName;const p=r.forwardRef(({className:a,children:e,...s},x)=>t.jsxs(N,{children:[t.jsx(c,{}),t.jsxs(l,{ref:x,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",a),...s,children:[e,t.jsxs(y,{className:"absolute right-4 top-4 rounded-2xl border border-transparent p-2 opacity-70 ring-offset-background transition-all hover:border-border hover:bg-accent hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(g,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>t.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",a),...e});m.displayName="DialogHeader";const f=({className:a,...e})=>t.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});f.displayName="DialogFooter";const j=r.forwardRef(({className:a,...e},s)=>t.jsx(n,{ref:s,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=n.displayName;const h=r.forwardRef(({className:a,...e},s)=>t.jsx(d,{ref:s,className:o("text-sm leading-6 text-muted-foreground",a),...e}));h.displayName=d.displayName;function R({children:a,className:e}){return t.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),children:a})}function A({children:a,className:e}){return t.jsx("div",{className:o("border-b border-border bg-secondary px-6 py-5",e),children:t.jsx(m,{children:a})})}function C({children:a,className:e}){return t.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return t.jsx(f,{className:o("border-t border-border bg-secondary px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,h as c,C as d,z as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as a}from"./charts-react-BeVWPrMt.js";import{u as s,i as l,a as t,b as i,c as n,d as o,f as r,g as $}from"./charts-core-vuhzGmuT.js";s([l,t,i,n,o,r,$]);const e=a;export{e as E};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as f,j as e,aj as R,an as M,ao as I,V as T,ap as V,aq as q,ar as B,a1 as D}from"./vendor-CjJPKsTb.js";import{P as K}from"./PageHeader-KQ9mjVAV.js";import{P as G}from"./PageSection-C9Wb9Oe3.js";import{P as Q,a as $}from"./PageState-D-1-sNyq.js";import{u as H}from"./useApiQuery-Bcqr7uHV.js";import{u as J,B as x,c as p}from"./index-MqPrlTQ4.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-3ORqzzzc.js";import{C as N,a as y}from"./card-D1l7si2X.js";import{I as U}from"./input-Bb_t6wr6.js";import{S as _,a as W,b as X,c as Y,d as g}from"./select-kdaAyzec.js";import{u as z}from"./i18n-CfLThlXq.js";import"./query-D3IfCUhp.js";import"./router-CmaL1NgV.js";import"./radix-54BMi3RD.js";function Z(s){const a=Date.now()-s,n=Math.abs(a),t=60*1e3,m=60*t,u=24*m;if(n<t){const o=Math.max(Math.round(n/1e3),1);return a>=0?`${o}s ago`:`in ${o}s`}if(n<m){const o=Math.round(n/t);return a>=0?`${o}m ago`:`in ${o}m`}if(n<u){const o=Math.round(n/m);return a>=0?`${o}h ago`:`in ${o}h`}const l=Math.round(n/u);return a>=0?`${l}d ago`:`in ${l}d`}function ee(s){return new Date(s).toLocaleString()}const se={info:"secondary",warn:"outline",error:"destructive"};function pe(){var L,A,P;const{t:s}=z(),{pushToast:i}=J(),[a,n]=f.useState(null),[t,m]=f.useState({level:"",type:""}),u=f.useMemo(()=>({limit:50,cursor:a??void 0,level:t.level||void 0,type:t.type.trim()||void 0}),[a,t.level,t.type]),l=H(O.events.list(u),{url:"/api/events",method:"GET",params:u});f.useEffect(()=>{l.isError&&l.error&&i({title:s("events.toast.loadFailure",{message:l.error.message}),variant:"error"})},[l.error,l.isError,i,s]);const o=()=>{n(null),m({level:"",type:""})},d=((L=l.data)==null?void 0:L.events)??[],k=((A=l.data)==null?void 0:A.nextCursor)??null,F=l.isLoading,j=l.isFetching&&!l.isLoading,h=f.useMemo(()=>{const r=[];return t.level&&r.push(s(`events.levels.${t.level}`)),t.type.trim()&&r.push(t.type.trim()),r},[t.level,t.type,s]),C=d.filter(r=>r.level==="info").length,S=d.filter(r=>r.level==="warn").length,E=d.filter(r=>r.level==="error").length;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(K,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),title:s("events.title"),description:s("events.description"),eyebrow:"Audit",breadcrumb:"Gateway / Events",helper:s("events.filters.title"),badge:d.length>0?`${d.length} events`:void 0,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("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:s(a?"events.actions.older":"events.actions.newest")}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),disabled:j,className:"w-full sm:w-auto",children:[e.jsx(R,{className:p("mr-2 h-4 w-4",j&&"animate-spin"),"aria-hidden":"true"}),s(j?"common.actions.refreshing":"common.actions.refresh")]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(I,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.info"),value:C.toLocaleString(),tone:"emerald"}),e.jsx(w,{icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.warn"),value:S.toLocaleString(),tone:"amber"}),e.jsx(w,{icon:e.jsx(V,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.error"),value:E.toLocaleString(),tone:"rose"})]}),e.jsx(N,{"data-testid":"events-filters-card",className:"overflow-hidden",children:e.jsx(y,{className:"pt-5",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(q,{className:"h-4 w-4 text-primary","aria-hidden":"true"}),s("events.filters.title"),e.jsx(c,{variant:"outline",children:d.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("events.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:flex sm:flex-wrap sm:items-center",children:[h.length>0?e.jsx(x,{variant:"ghost",size:"sm",onClick:o,className:"w-full sm:w-auto",children:s("common.actions.reset")}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!a,onClick:()=>n(null),className:"w-full sm:w-auto",children:[e.jsx(B,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!k,onClick:()=>n(k),className:"w-full sm:w-auto",children:[s("events.actions.older"),e.jsx(D,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center",children:[e.jsxs(_,{value:t.level,onValueChange:r=>{n(null),m(b=>({...b,level:r==="all"?"":r}))},children:[e.jsx(W,{className:"w-full md:w-[160px]",children:e.jsx(X,{placeholder:s("events.filters.allLevels")})}),e.jsxs(Y,{children:[e.jsx(g,{value:"all",children:s("events.filters.allLevels")}),e.jsx(g,{value:"info",children:s("events.levels.info")}),e.jsx(g,{value:"warn",children:s("events.levels.warn")}),e.jsx(g,{value:"error",children:s("events.levels.error")})]})]}),e.jsx(U,{className:"w-full md:w-[220px]",placeholder:s("events.filters.typePlaceholder"),value:t.type,onChange:r=>{n(null),m(b=>({...b,type:r.target.value}))}}),e.jsx(x,{variant:"ghost",size:"sm",onClick:o,disabled:h.length===0,className:"w-full md:w-auto",children:s("common.actions.reset")})]}),h.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(r=>e.jsx(c,{variant:"secondary",children:r},r))}):null]})})}),e.jsx(G,{title:s("events.title"),description:s(a?"events.actions.older":"events.actions.newest"),actions:d.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(c,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-300",children:[s("events.levels.info"),": ",C]}),e.jsxs(c,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:[s("events.levels.warn"),": ",S]}),e.jsxs(c,{variant:"outline",className:"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-300",children:[s("events.levels.error"),": ",E]})]}):null,children:F?e.jsx(Q,{label:s("common.loading")}):l.isError?e.jsx($,{icon:e.jsx(T,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((P=l.error)==null?void 0:P.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),children:s("common.actions.refresh")})}):d.length===0?e.jsx($,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:s("events.empty.title"),description:s("events.empty.subtitle"),action:h.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:o,children:s("common.actions.reset")}):void 0}):e.jsx("div",{className:"grid gap-4",children:d.map(r=>e.jsx(re,{event:r},r.id))})})]})}function w({icon:s,title:i,tone:a,value:n}){const t={emerald:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400",amber:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400",rose:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}[a];return e.jsx(N,{children:e.jsxs(y,{className:"flex items-center justify-between gap-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:i}),e.jsx("p",{className:"mt-2 text-3xl font-bold tracking-tight text-foreground",children:n})]}),e.jsx("div",{className:p("flex h-11 w-11 items-center justify-center rounded-xl",t),children:s})]})})}function re({event:s}){const{t:i}=z(),a=s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500";return e.jsx(N,{className:p("overflow-hidden border-l-4",a),children:e.jsxs(y,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(c,{variant:se[s.level]||"secondary",children:i(`events.levels.${s.level}`)}),e.jsxs(c,{variant:"outline",children:["#",s.id]}),s.mode?e.jsx(c,{variant:"secondary",children:s.mode}):null,s.endpoint?e.jsx(c,{variant:"outline",children:s.endpoint}):null]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold tracking-[-0.01em]",children:s.title||i("events.defaultTitle")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.message||i("events.defaultMessage")})]})]}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground xl:text-right",children:[e.jsx("p",{children:ee(s.createdAt)}),e.jsx("p",{children:Z(s.createdAt)})]})]}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(v,{label:"Type",value:s.type}),e.jsx(v,{label:"Source",value:s.source}),e.jsx(v,{label:"IP",value:s.ipAddress}),e.jsx(v,{label:"API Key",value:s.apiKeyName}),e.jsx(v,{label:"User Agent",value:s.userAgent,wide:!0})]}),s.details?e.jsxs("details",{className:"rounded-lg border border-border bg-secondary p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-primary",children:i("events.details")}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-lg border border-border bg-card p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})]}):null]})})}function v({label:s,value:i,wide:a=!1}){return i?e.jsxs("div",{className:p("rounded-lg border border-border bg-secondary px-3 py-3",a&&"sm:col-span-2 xl:col-span-2"),children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 break-all text-sm text-foreground",children:i})]}):null}export{pe as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{r as u,j as e,aD as b,aA as N,aE as v,aF as y}from"./vendor-CjJPKsTb.js";import{P as w}from"./PageHeader-KQ9mjVAV.js";import{P as a}from"./PageSection-C9Wb9Oe3.js";import{c as h}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-D1l7si2X.js";import{B as f}from"./index-MqPrlTQ4.js";import{u as x}from"./i18n-CfLThlXq.js";import"./badge-3ORqzzzc.js";import"./query-D3IfCUhp.js";import"./router-CmaL1NgV.js";import"./radix-54BMi3RD.js";function B(){const{t:s}=x(),t=u.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),c=s("help.sections.codexConfig.items",{returnObjects:!0}),d=s("help.sections.usage.items",{returnObjects:!0}),g=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:c},{title:s("help.sections.usage.title"),items:d},{title:s("help.sections.tips.title"),items:g}]},[s]),r=s("help.faq.items",{returnObjects:!0}),l=u.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:t[0].items[0]??""},{id:"claude",title:t[1].title,subtitle:t[1].items[0]??""},{id:"codex",title:t[2].title,subtitle:t[2].items[0]??""},{id:"faq",title:s("help.faq.title"),subtitle:`${r.length} FAQ`}],[r.length,t,s]);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w,{icon:e.jsx(b,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro"),eyebrow:"Guided Setup",breadcrumb:"Gateway / Help",helper:s("help.helper"),badge:`${t.length} guides`}),e.jsx(p,{children:e.jsxs(j,{className:"flex items-start gap-4 pt-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-accent text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.note")})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:l.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"rounded-lg border border-border bg-card px-4 py-4 transition hover:bg-accent/50",children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(a,{eyebrow:"01",title:t[0].title,children:e.jsx(o,{items:t[0].items})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(a,{eyebrow:"02",title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"IDE / Desktop workflow"})]})]}),e.jsx(o,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(a,{eyebrow:"03",title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-600 text-white",children:e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Codex CLI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terminal workflow"})]})]}),e.jsx(o,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(a,{eyebrow:"04",title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(a,{eyebrow:"05",title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(a,{eyebrow:"FAQ",title:s("help.faq.title"),children:e.jsx(q,{items:r})})})]})}function o({items:s}){return e.jsx("ol",{className:"flex flex-col gap-3",children:s.map((t,r)=>e.jsxs("li",{className:"flex gap-3 rounded-lg border border-border bg-card p-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-xl bg-primary text-xs font-medium text-primary-foreground",children:r+1}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:e.jsx(C,{content:t})})]},`${r}-${t}`))})}function C({content:s}){const{t}=x();if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:m(l)},i):null;{const[n,...c]=l.split(`
|
|
2
|
+
`),d=c.join(`
|
|
3
|
+
`);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>h(d),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg border border-border bg-secondary p-3 text-xs",children:e.jsx("code",{children:d})})]},i)}})})}return s.includes(`
|
|
4
|
+
`)?e.jsx("div",{className:"whitespace-pre-line",children:m(s)}):e.jsx("div",{children:m(s)})}function m(s){return s.split(/(\*\*[^*]+\*\*)/g).map((r,l)=>r.startsWith("**")&&r.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:r.slice(2,-2)},l):e.jsx("span",{children:r},l))}function q({items:s}){return s.length===0?null:e.jsx("dl",{className:"flex flex-col gap-3",children:s.map(t=>e.jsx(p,{children:e.jsxs(j,{className:"pt-4",children:[e.jsx("dt",{className:"text-sm font-medium",children:t.q}),e.jsx("dd",{className:"mt-2 text-sm text-muted-foreground",children:e.jsx(k,{content:t.a})})]})},t.q))})}function k({content:s}){const{t}=x();if(s.includes("1)")||s.includes("2)")){const r=s.split(`
|
|
5
|
+
`).filter(i=>i.trim());if(r.some(i=>/^\d+\)/.test(i.trim())))return e.jsx("div",{className:"space-y-1",children:r.map((i,n)=>{const c=i.match(/^\d+\)\s*(.*)/);return c?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{children:c[1]})]},n):e.jsx("div",{children:i},n)})})}if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:l},i):null;{const[n,...c]=l.split(`
|
|
6
|
+
`),d=c.join(`
|
|
7
|
+
`);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>h(d),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg border border-border bg-secondary p-3 text-xs",children:e.jsx("code",{children:d})})]},i)}})})}return s.includes(`
|
|
8
|
+
`)?e.jsx("div",{className:"whitespace-pre-line",children:s}):e.jsx("div",{children:s})}export{B as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n,j as e,ao as S,aG as E}from"./vendor-CjJPKsTb.js";import{i as k,L as F,B as L}from"./index-MqPrlTQ4.js";import{C as j,a as b,b as G,c as P,d as T,e as A}from"./card-D1l7si2X.js";import{I as N}from"./input-Bb_t6wr6.js";import{L as y}from"./label-8HO4VSYV.js";import{u as B}from"./i18n-CfLThlXq.js";import{c as D,u as I}from"./router-CmaL1NgV.js";import"./query-D3IfCUhp.js";import"./radix-54BMi3RD.js";function O(){const{t:s}=B(),a=D(),l=I(),{authEnabled:o,isAuthenticated:u,loading:d,login:w,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),c=n.useMemo(()=>{var t;const r=l.state;return((t=r==null?void 0:r.from)==null?void 0:t.pathname)??"/"},[l.state]);n.useEffect(()=>{if(!o&&!d){a(c,{replace:!0});return}o&&u&&!d&&a(c,{replace:!0})},[o,c,u,d,a]);const C=async r=>{if(r.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await w(i.username.trim(),i.password),a(c,{replace:!0})}catch(t){m(t instanceof Error?t.message:s("login.validation.failed"))}finally{g(!1)}};return d?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(j,{className:"w-full max-w-md",children:e.jsx(b,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(F,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4 py-10",children:e.jsxs("div",{className:"mx-auto grid w-full max-w-5xl items-center gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(400px,0.8fr)]",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsx("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold text-primary",children:"Secure Gateway Control"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-foreground",children:s("login.title")}),e.jsx("p",{className:"max-w-md text-base leading-7 text-muted-foreground",children:s("login.description")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(v,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(v,{icon:e.jsx(E,{className:"h-5 w-5","aria-hidden":"true"}),title:"Session protected",description:s("help.note")})]})]})}),e.jsxs(j,{className:"w-full",children:[e.jsxs(G,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(P,{className:"text-xl",children:s("login.title")}),e.jsx(T,{children:s("login.description")})]}),e.jsx(b,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(N,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:r=>p(t=>({...t,username:r.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(N,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:r=>p(t=>({...t,password:r.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(L,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(A,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function v({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:a}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as g,j as e,ak as Be,al as We,a8 as Ge,am as Je,aj as Xe,V as Ze,T as Ye}from"./vendor-CjJPKsTb.js";import{P as et}from"./PageHeader-KQ9mjVAV.js";import{c as w,B as E,b as tt,u as ge,s as _,t as st,a as R}from"./index-MqPrlTQ4.js";import{B as K}from"./badge-3ORqzzzc.js";import{C as _e,a as Ee}from"./card-D1l7si2X.js";import{I as ue}from"./input-Bb_t6wr6.js";import{L as I}from"./label-8HO4VSYV.js";import{S as ee,a as te,b as se,c as le,d as L}from"./select-kdaAyzec.js";import{u as M}from"./i18n-CfLThlXq.js";import{D as lt,A as at,a as rt,b as ot,c as it,d as nt}from"./DialogShell-s3yKnQyp.js";import{P as dt,a as xe}from"./PageState-D-1-sNyq.js";import{c as ct}from"./clipboard-CALi6bTW.js";import{u as $}from"./useApiQuery-Bcqr7uHV.js";import{q as U}from"./queryKeys-BMvyDTQS.js";import{f as O,a as De,b as mt,c as z,d as pt,g as ut}from"./utils-DQfq7gRo.js";import{P as xt,a as gt,b as ht}from"./popover-5I-o07-i.js";import{T as ft}from"./Skeleton-H3SErRWs.js";import{g as Se}from"./gateway-CFNtAOS2.js";import"./query-D3IfCUhp.js";import"./router-CmaL1NgV.js";import"./radix-54BMi3RD.js";function bt({apiKeys:l,selected:t,onChange:o,disabled:n,className:d}){const{t:s}=M(),[r,h]=g.useState(!1),c=g.useRef(null);g.useEffect(()=>{if(!r)return;const i=a=>{var p;(p=c.current)!=null&&p.contains(a.target)||h(!1)};return window.addEventListener("mousedown",i),()=>window.removeEventListener("mousedown",i)},[r]);const v=g.useMemo(()=>{if(t.length===0)return[];const i=new Map;for(const a of l)i.set(a.id,a);return t.map(a=>{const p=i.get(a);return p?p.isWildcard?s("apiKeys.wildcard"):p.name:null}).filter(a=>!!a)},[l,t,s]),u=t.length===0?s("logs.filters.apiKeyAll"):s("logs.filters.apiKeySelected",{count:t.length}),j=i=>{t.includes(i)?o(t.filter(a=>a!==i)):o([...t,i])};return e.jsxs("div",{className:w("relative space-y-2",d),ref:c,children:[e.jsx(I,{children:s("logs.filters.apiKey")}),e.jsxs("button",{type:"button",onClick:()=>h(i=>!i),disabled:n||l.length===0,title:s("logs.filters.apiKeyHint"),className:w("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 text-sm ring-offset-background transition-all focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t.length>0&&"border-primary",r&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[u,v.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:v.join(", ")})]}),e.jsx("svg",{className:w("h-4 w-4 opacity-50 transition-transform",r&&"rotate-180"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.25a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z",clipRule:"evenodd"})})]}),r&&e.jsxs("div",{className:"absolute left-0 top-full z-30 mt-2 w-64 rounded-md border bg-popover p-2 shadow-md",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-secondary px-3 py-2 text-xs",children:[e.jsx("span",{children:u}),e.jsx("button",{type:"button",onClick:()=>o([]),disabled:t.length===0,className:"text-primary hover:underline disabled:opacity-40",children:s("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[l.map(i=>{const a=i.isWildcard?s("apiKeys.wildcard"):i.name,p=t.includes(i.id);return e.jsxs("label",{className:w("flex cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",p&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:p,onChange:()=>j(i.id)}),e.jsx("span",{className:"truncate",children:a})]},i.id)}),l.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:s("logs.filters.apiKeyAll")})]})]})]})}function yt(l){const{t}=M(),{total:o,activeFilters:n,filtersExpanded:d,setFiltersExpanded:s,handleResetFilters:r,activeQuickView:h,applyQuickView:c,providerFilter:v,setProviderFilter:u,endpointFilter:j,setEndpointFilter:i,selectedApiKeys:a,setSelectedApiKeys:p,modelFilter:f,setModelFilter:S,statusFilter:b,setStatusFilter:D,fromDate:C,setFromDate:T,toDate:N,setToDate:y,providerOptions:B,apiKeys:re,apiKeysLoading:oe,customEndpoints:W}=l;return e.jsx(_e,{"data-testid":"logs-filters-card",className:"overflow-hidden",children:e.jsxs(Ee,{className:"pt-4",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:t("logs.filtersTitle")}),e.jsx(K,{variant:"outline",children:t("logs.summary.total",{value:o.toLocaleString()})}),n.length>0&&e.jsx(K,{variant:"secondary",children:t("common.filters.activeCount",{count:n.length})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.filtersDescription")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.length>0&&e.jsx(E,{variant:"ghost",size:"sm",onClick:r,children:t("common.actions.reset")}),e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>s(x=>!x),children:d?e.jsxs(e.Fragment,{children:[t("common.filters.collapse"),e.jsx(Be,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[t("common.filters.expand"),e.jsx(We,{className:"ml-1 h-4 w-4"})]})})]})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx("div",{className:"flex min-h-[52px] items-center rounded-lg border border-border bg-secondary px-3 py-2",children:n.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(x=>e.jsxs(K,{variant:"secondary",role:"button",tabIndex:0,className:"cursor-pointer gap-1 border border-transparent bg-primary/10 text-primary hover:bg-destructive/10 hover:text-destructive",onClick:x.onRemove,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),x.onRemove())},children:[x.label,e.jsx(Ge,{className:"h-3 w-3","aria-hidden":"true"})]},x.key))}):e.jsx("span",{className:"text-sm text-muted-foreground",children:t("common.filters.allRequests")})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 lg:min-w-[360px]",children:[e.jsx(Y,{label:t("common.filters.activeCount",{count:n.length}),value:n.length.toString()}),e.jsx(Y,{label:t("logs.filters.apiKey"),value:a.length.toString()}),e.jsx(Y,{label:t("logs.filters.provider"),value:v==="all"?t("common.noData"):"1"}),e.jsx(Y,{label:t("logs.filters.endpoint"),value:j==="all"?t("common.noData"):"1"})]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-border bg-secondary p-2",children:["all","errors","today","anthropic","openai"].map(x=>e.jsx(E,{variant:h===x?"default":"outline",size:"sm",className:w("rounded-full border-transparent",h===x&&x==="all"&&"bg-foreground text-background hover:bg-foreground/90",h===x&&x==="errors"&&"bg-rose-500 text-white hover:bg-rose-500/90",h===x&&x==="today"&&"bg-emerald-500 text-white hover:bg-emerald-500/90",h===x&&(x==="anthropic"||x==="openai")&&"bg-amber-500 text-white hover:bg-amber-500/90"),onClick:()=>c(x),children:t(`logs.quickViews.${x}`)},x))})]}),d&&e.jsxs("div",{className:"mt-4 grid gap-4 rounded-lg border border-border bg-secondary p-4 md:grid-cols-2 xl:grid-cols-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.provider")}),e.jsxs(ee,{value:v,onValueChange:u,children:[e.jsx(te,{children:e.jsx(se,{})}),e.jsxs(le,{children:[e.jsx(L,{value:"all",children:t("logs.filters.providerAll")}),B.map(x=>e.jsx(L,{value:x.id,children:x.label??x.id},x.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.endpoint")}),e.jsxs(ee,{value:j,onValueChange:i,children:[e.jsx(te,{children:e.jsx(se,{})}),e.jsxs(le,{children:[e.jsx(L,{value:"all",children:t("logs.filters.endpointAll")}),e.jsx(L,{value:"anthropic",children:t("logs.filters.endpointAnthropic")}),e.jsx(L,{value:"openai",children:t("logs.filters.endpointOpenAI")}),W==null?void 0:W.map(x=>e.jsx(L,{value:x.id,children:x.label||x.id},x.id))]})]})]}),e.jsx(bt,{className:"md:col-span-2",apiKeys:re,selected:a,disabled:oe,onChange:p}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.modelId")}),e.jsx(ue,{value:f,onChange:x=>S(x.target.value),placeholder:t("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.status")}),e.jsxs(ee,{value:b,onValueChange:x=>D(x),children:[e.jsx(te,{children:e.jsx(se,{})}),e.jsxs(le,{children:[e.jsx(L,{value:"all",children:t("logs.filters.statusAll")}),e.jsx(L,{value:"success",children:t("logs.filters.statusSuccess")}),e.jsx(L,{value:"error",children:t("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.startDate")}),e.jsx(ue,{type:"date",value:C,onChange:x=>T(x.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.endDate")}),e.jsx(ue,{type:"date",value:N,onChange:x=>y(x.target.value)})]})]})]})})}function Y({label:l,value:t}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-3 py-2",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-foreground",children:t})]})}const he={listRequest(l){return{url:"/api/logs",method:"GET",params:l}},detailRequest(l){return{url:l===null?"":`/api/logs/${l}`,method:"GET"}},async exportArchive(l,t){const o=await tt.post("/api/logs/export",l,{responseType:"blob",timeout:t});return new Blob([o.data],{type:"application/zip"})}};function jt({apiKeyMap:l,logId:t,open:o,providerLabelMap:n}){var i;const{t:d}=M(),{pushToast:s}=ge(),r=$(U.logs.detail(t),he.detailRequest(t),{enabled:o&&t!==null,staleTime:3e4});g.useEffect(()=>{!r.isError||!r.error||s({title:d("logs.detail.loadError"),description:r.error.message,variant:"error"})},[r.error,r.isError,s,d]);const h=g.useCallback(async(a,p,f)=>{if(!p){s({title:d("logs.detail.copy.empty",{label:a}),variant:"info"});return}try{await ct(p),s({title:d(f),variant:"success"})}catch(S){s({title:d("logs.detail.copy.failure"),description:S instanceof Error?S.message:d("logs.detail.copy.failureFallback"),variant:"error"})}},[s,d]),c=r.data,v=c?n.get(c.provider)??c.provider:"",u=c&&c.api_key_id!=null?l.get(c.api_key_id):void 0,j=c?c.status_code??(c.error?500:200):null;return{apiKeyMeta:u,errorMessage:r.isError?((i=r.error)==null?void 0:i.message)??null:null,handleCopy:h,isError:r.isError,isPending:r.isPending,providerLabel:v,refetch:r.refetch,record:c,statusCode:j}}function vt({open:l,logId:t,onClose:o,providerLabelMap:n,apiKeyMap:d}){var S,b,D,C,T,N;const{t:s}=M(),{apiKeyMeta:r,errorMessage:h,handleCopy:c,isError:v,isPending:u,providerLabel:j,refetch:i,record:a,statusCode:p}=jt({apiKeyMap:d,logId:t,open:l,providerLabelMap:n}),f=a?[{key:"client-request",title:s("logs.detail.payload.clientRequest"),value:((S=a.payload)==null?void 0:S.client_request)??null,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"},...(b=a.payload)!=null&&b.upstream_request?[{key:"upstream-request",title:s("logs.detail.payload.upstreamRequest"),value:a.payload.upstream_request,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}]:[],...(D=a.payload)!=null&&D.upstream_response?[{key:"upstream-response",title:s("logs.detail.payload.upstreamResponse"),value:a.payload.upstream_response,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}]:[],{key:"client-response",title:s("logs.detail.payload.clientResponse"),value:((C=a.payload)==null?void 0:C.client_response)??null,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}]:[];return e.jsx(lt,{open:l,onOpenChange:y=>{y||o()},children:e.jsxs(at,{className:"w-[min(96vw,1200px)] max-w-[1200px]",children:[e.jsxs(rt,{className:"pr-14",children:[e.jsx(ot,{children:s("logs.detail.title")}),e.jsx(it,{children:a?s("logs.detail.id",{id:a.id}):s("logs.detail.loadError")})]}),e.jsx(nt,{className:"max-h-[78vh]",children:u?e.jsx(dt,{compact:!0,className:"min-h-[240px]",label:s("common.loading")}):v?e.jsx(xe,{compact:!0,className:"min-h-[240px]",tone:"danger",title:s("logs.detail.loadError"),description:h??s("common.unknownError"),action:e.jsx(E,{variant:"outline",onClick:()=>void i(),children:s("common.actions.refresh")})}):a?e.jsxs("div",{className:"space-y-6 text-sm",children:[e.jsxs("section",{className:"space-y-4 rounded-lg border border-border bg-card p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.infoSection")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-border bg-secondary p-3 text-xs",children:[e.jsx("span",{className:"font-medium",children:s("logs.detail.summary.route",{from:a.client_model??s("logs.detail.info.noRequestedModel"),to:a.model})}),e.jsx("span",{className:"text-muted-foreground",children:s("logs.detail.summary.latency",{value:O(a.latency_ms,s("common.units.ms"))})}),a.ttft_ms!==null?e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",O(a.ttft_ms,s("common.units.ms"))]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{variant:a.error?"destructive":"default",children:p==null?void 0:p.toString()}),e.jsx(K,{variant:"outline",children:a.stream?s("logs.stream.streaming"):s("logs.stream.single")})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(A,{label:s("logs.detail.info.latency"),value:O(a.latency_ms,s("common.units.ms"))}),e.jsx(A,{label:s("logs.detail.info.ttft"),value:O(a.ttft_ms,s("common.units.ms"))}),e.jsx(A,{label:s("logs.detail.info.tpot"),value:O(a.tpot_ms,s("common.units.msPerToken"))}),e.jsx(A,{label:s("logs.detail.info.status"),value:(p==null?void 0:p.toString())??"-"})]}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(F,{label:s("logs.detail.info.time"),value:De(a.timestamp)}),e.jsx(F,{label:s("logs.detail.info.sessionId"),value:a.session_id??"-"}),e.jsx(F,{label:s("logs.detail.info.endpoint"),value:a.endpoint||"-"}),e.jsx(F,{label:s("logs.detail.info.provider"),value:j}),e.jsx(F,{label:s("logs.detail.info.requestedModel"),value:a.client_model??s("logs.detail.info.noRequestedModel")}),e.jsx(F,{label:s("logs.detail.info.model"),value:a.model}),e.jsx(F,{label:s("logs.detail.info.stream"),value:mt(a.stream)}),e.jsx(F,{label:s("logs.detail.info.status"),value:p})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(A,{label:s("logs.detail.info.inputTokens"),value:z(a.input_tokens)}),e.jsx(A,{label:s("logs.detail.info.cacheReadTokens"),value:z(a.cache_read_tokens)}),e.jsx(A,{label:s("logs.detail.info.cacheCreationTokens"),value:z(a.cache_creation_tokens)}),e.jsx(A,{label:s("logs.detail.info.outputTokens"),value:z(a.output_tokens)})]}),a.error?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("logs.detail.info.error")}),e.jsx("p",{className:"rounded-[1rem] border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:a.error})]}):null]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("section",{className:"space-y-3 rounded-lg border border-border bg-card p-5",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.apiKey.title")}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 sm:grid-cols-2",children:[e.jsx(F,{label:s("logs.detail.apiKey.name"),value:a.api_key_id==null&&!a.api_key_name?s("logs.detail.apiKey.missing"):r!=null&&r.isWildcard?s("apiKeys.wildcard"):(r==null?void 0:r.name)??a.api_key_name??s("logs.detail.apiKey.missing")}),e.jsx(F,{label:s("logs.detail.apiKey.identifier"),value:a.api_key_id??s("common.noData")}),e.jsx(F,{label:s("logs.detail.apiKey.masked"),value:r!=null&&r.isWildcard?s("apiKeys.wildcard"):(r==null?void 0:r.maskedKey)??a.api_key_name??s("logs.detail.apiKey.maskedUnavailable")}),e.jsx(F,{label:s("logs.detail.apiKey.lastUsed"),value:r!=null&&r.lastUsedAt?new Date(r.lastUsedAt).toLocaleString():s("common.noData")})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:s("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:a.api_key_value_available?a.api_key_value_masked??s("logs.detail.apiKey.rawUnavailable"):s("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:s("logs.detail.apiKey.rawMaskedHint")})]})]}),e.jsxs("section",{className:"space-y-4 rounded-lg border border-border bg-card p-5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.payload.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(T=a.payload)!=null&&T.upstream_request||(N=a.payload)!=null&&N.upstream_response?s("logs.detail.payload.helperWithUpstream"):s("logs.detail.payload.helperClientOnly")})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:f.map(y=>e.jsx(Nt,{title:y.title,value:y.value,emptyLabel:y.emptyLabel,onCopy:()=>c(y.title,y.value,y.copyToast),t:s},y.key))})]})]})]}):e.jsx(xe,{compact:!0,className:"min-h-[240px]",title:s("logs.detail.loadError"),description:s("common.noData")})})]})})}function A({label:l,value:t}){return e.jsxs("div",{className:"min-w-0 rounded-lg border border-border bg-secondary px-3 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:l}),e.jsx("p",{className:"mt-2 break-all text-sm font-semibold leading-6",children:t})]})}function F({label:l,value:t}){return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l}),e.jsx("dd",{className:"min-w-0 break-all whitespace-pre-wrap text-sm font-medium leading-6 text-foreground",children:t??"-"})]})}function Nt({emptyLabel:l,onCopy:t,title:o,value:n,t:d}){return e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-secondary/40 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),e.jsx(E,{variant:"outline",size:"sm",onClick:t,children:d("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap rounded-lg border border-border bg-secondary p-3 text-xs",children:pt(n,l)})]})}const H=[20,50,100],Q=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","cacheReadTokens","cacheCreationTokens","outputTokens","latency","ttft","tpot","status","error"],ae=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","cacheReadTokens","cacheCreationTokens","outputTokens","latency","ttft","tpot","status","error"];function wt(){if(typeof window>"u")return Q;try{const l=window.localStorage.getItem(_.logs.visibleColumns);if(!l)return Q;const t=JSON.parse(l);if(!Array.isArray(t))return Q;const o=t.filter(n=>ae.includes(n));return o.length>0?o:Q}catch{return Q}}function kt(){return typeof window>"u"?"comfortable":window.localStorage.getItem(_.logs.density)==="compact"?"compact":"comfortable"}function St(){if(typeof window>"u")return H[0];const l=window.localStorage.getItem(_.logs.pageSize),t=Number(l);return H.includes(t)?t:H[0]}function Ct(){if(typeof window>"u")return[];try{const l=window.localStorage.getItem(_.logs.selectedApiKeys);if(!l)return[];const t=JSON.parse(l);return Array.isArray(t)?t.map(o=>Number(o)).filter(o=>Number.isInteger(o)&&o>0):[]}catch{return[]}}function Ce(l,t=!1){if(!l)return;const o=t?`${l}T23:59:59.999`:`${l}T00:00:00.000`,n=Date.parse(o);return Number.isFinite(n)?n:void 0}function _t(l,t,o){return l===o&&t===o}function Et({columnOptions:l,exporting:t,onExport:o,onRefresh:n,onResetColumns:d,onSetDensity:s,onToggleColumn:r,refreshing:h,rowDensity:c,total:v,visibleColumns:u,visibleColumnSet:j}){const{t:i}=M(),a=JSON.stringify(u)===JSON.stringify(Q);return e.jsxs("div",{className:"flex w-full flex-col gap-3 xl:w-auto xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center xl:w-auto xl:flex-nowrap",children:[e.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1 sm:w-auto",children:[e.jsx("button",{type:"button",onClick:()=>s("comfortable"),className:w("inline-flex h-8 flex-1 items-center justify-center whitespace-nowrap rounded-full px-3.5 text-xs font-medium transition-all sm:flex-none",c==="comfortable"?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:i("logs.table.density.comfortable")}),e.jsx("button",{type:"button",onClick:()=>s("compact"),className:w("inline-flex h-8 flex-1 items-center justify-center whitespace-nowrap rounded-full px-3.5 text-xs font-medium transition-all sm:flex-none",c==="compact"?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:i("logs.table.density.compact")})]}),e.jsxs(xt,{children:[e.jsx(gt,{asChild:!0,children:e.jsx(E,{variant:"outline",size:"sm",className:"w-full sm:w-auto",children:i("logs.actions.columns")})}),e.jsxs(ht,{align:"end",className:"w-64 p-3",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:i("logs.actions.columns")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("logs.actions.visibleCount",{count:u.length})})]}),e.jsx(E,{variant:"ghost",size:"sm",onClick:d,disabled:a,children:i("common.actions.reset")})]}),e.jsx("div",{className:"grid gap-1.5",children:l.map(p=>{const f=j.has(p.id);return e.jsxs("label",{className:w("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",f&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",checked:f,onChange:()=>r(p.id),className:"h-4 w-4 rounded border-border"}),e.jsx("span",{children:p.label})]},p.id)})})]})]}),e.jsxs(E,{onClick:o,disabled:t,className:"w-full sm:w-auto",children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),i(t?"logs.actions.exporting":"logs.actions.export")]})]}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-3 xl:w-auto xl:justify-start",children:[e.jsx("span",{className:"text-xs text-muted-foreground sm:text-sm",children:i("logs.summary.total",{value:v.toLocaleString()})}),e.jsxs(E,{variant:"outline",size:"sm",onClick:n,disabled:h,className:"shrink-0",children:[e.jsx(Xe,{className:w("mr-2 h-4 w-4",h&&"animate-spin")}),i(h?"common.actions.refreshing":"logs.actions.manualRefresh")]})]})]})}function Dt({record:l,providerLabelMap:t,apiKeyMap:o,onSelect:n,isEven:d,density:s,visibleColumnSet:r}){const{t:h}=M(),c=t.get(l.provider)??l.provider,v=l.endpoint||"-",u=!!l.error,j=l.status_code,i=l.client_model??h("logs.table.requestedModelFallback"),a=l.api_key_id!=null?o.get(l.api_key_id):void 0,p=l.api_key_id==null?h("logs.table.apiKeyUnknown"):a!=null&&a.isWildcard?h("apiKeys.wildcard"):a!=null&&a.name?a.name:l.api_key_name?l.api_key_name:h("logs.table.apiKeyUnknown"),f=s==="compact"?"px-3 py-1.5":"px-3 py-2",S=d?"bg-muted/30":"bg-background",b=ut(l.session_id),D=b==null?void 0:b.rowStyle,C=b==null?void 0:b.stickyStyle,T=b?{...b.stickyStyle,...b.accentStyle}:void 0;return e.jsxs("tr",{"data-session-id":b==null?void 0:b.sessionId,"data-session-color":b==null?void 0:b.colorKey,className:w("transition-colors",b?"":d?"bg-muted/30":"",b?"":"hover:bg-muted/50"),style:D,onMouseEnter:N=>{b&&Object.assign(N.currentTarget.style,b.hoverStyle)},onMouseLeave:N=>{b&&Object.assign(N.currentTarget.style,b.rowStyle)},children:[e.jsx("td",{className:w("sticky left-0 z-10 text-xs",f,b?"":S),style:T,children:De(l.timestamp)}),r.has("endpoint")&&e.jsx("td",{className:w(f,"text-xs"),children:v}),r.has("provider")&&e.jsx("td",{className:w(f,"text-xs"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:c,children:c})}),r.has("requestedModel")&&e.jsx("td",{className:w(f,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:i,children:i})}),r.has("routedModel")&&e.jsx("td",{className:w(f,"text-xs"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:l.model,children:l.model})}),r.has("apiKey")&&e.jsx("td",{className:w(f,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[90px] truncate",title:p,children:p})}),r.has("inputTokens")&&e.jsx("td",{className:w(f,"text-right text-xs tabular-nums"),children:z(l.input_tokens)}),r.has("cacheReadTokens")&&e.jsx("td",{className:w(f,"text-right text-xs tabular-nums"),children:z(l.cache_read_tokens)}),r.has("cacheCreationTokens")&&e.jsx("td",{className:w(f,"text-right text-xs tabular-nums"),children:z(l.cache_creation_tokens)}),r.has("outputTokens")&&e.jsx("td",{className:w(f,"text-right text-xs tabular-nums"),children:z(l.output_tokens)}),r.has("latency")&&e.jsx("td",{className:w(f,"text-right text-xs tabular-nums"),children:O(l.latency_ms,"ms")}),r.has("ttft")&&e.jsx("td",{className:w(f,"text-right text-xs tabular-nums"),children:O(l.ttft_ms,"ms")}),r.has("tpot")&&e.jsx("td",{className:w(f,"text-right text-xs tabular-nums"),children:O(l.tpot_ms,"ms/tk")}),r.has("status")&&e.jsx("td",{className:w(f,"text-center"),children:e.jsx(K,{variant:u?"destructive":"default",className:"text-xs",children:j??(u?500:200)})}),r.has("error")&&e.jsx("td",{className:w(f,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:l.error??"",children:l.error?l.error:"-"})}),e.jsx("td",{className:w("sticky right-0 z-10 text-center",f,b?"":S),style:C,children:e.jsx(E,{variant:"outline",size:"sm",onClick:()=>n(l.id),children:h("logs.actions.detail")})})]})}function Ft(l){const{t}=M(),{tableScrollRef:o,visibleColumnSet:n,visibleColumnCount:d,logsError:s,logsPending:r,items:h,activeFiltersCount:c,handleResetFilters:v,handleRetry:u,providerLabelMap:j,apiKeyMap:i,handleOpenDetail:a,rowDensity:p,showScrollHint:f,pageSize:S,setPageSize:b,page:D,totalPages:C,setPage:T}=l;return e.jsx(_e,{className:"overflow-hidden",children:e.jsxs(Ee,{className:"p-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-border bg-secondary px-4 py-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:t("logs.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.actions.visibleCount",{count:d-2})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{variant:"secondary",children:"Wide Table"}),e.jsx(K,{variant:"outline",children:t(p==="compact"?"logs.table.density.compact":"logs.table.density.comfortable")}),f?e.jsx(K,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:"Scroll for more"}):null]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:o,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1480px] text-sm",children:[e.jsx("thead",{className:"border-b bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-muted/95 px-3 py-2 text-left text-xs font-medium backdrop-blur",children:t("logs.table.columns.time")}),n.has("endpoint")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.endpoint")}),n.has("provider")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.provider")}),n.has("requestedModel")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.requestedModel")}),n.has("routedModel")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.routedModel")}),n.has("apiKey")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.apiKey")}),n.has("inputTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.inputTokens")}),n.has("cacheReadTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.cacheReadTokens")}),n.has("cacheCreationTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.cacheCreationTokens")}),n.has("outputTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.outputTokens")}),n.has("latency")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.latency")}),n.has("ttft")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.ttft")}),n.has("tpot")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.tpot")}),n.has("status")&&e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium",children:t("logs.table.columns.status")}),n.has("error")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.error")}),e.jsx("th",{className:"sticky right-0 z-20 bg-muted/95 px-3 py-2 text-center text-xs font-medium backdrop-blur",children:t("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y",children:r?Array.from({length:8}).map((N,y)=>e.jsx(ft,{columns:d},y)):s&&h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:d,className:"px-3 py-6",children:e.jsx(xe,{compact:!0,tone:"danger",icon:e.jsx(Ze,{className:"h-5 w-5","aria-hidden":"true"}),title:t("logs.toast.listError.title"),description:s,action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[e.jsx(E,{variant:"outline",size:"sm",onClick:u,children:t("common.actions.refresh")}),c>0?e.jsx(E,{variant:"ghost",size:"sm",onClick:v,children:t("common.actions.reset")}):null]})})})}):h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:d,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[e.jsx("span",{children:t("logs.table.empty")}),c>0&&e.jsx(E,{variant:"outline",size:"sm",onClick:v,children:t("common.actions.reset")})]})})}):h.map((N,y)=>e.jsx(Dt,{record:N,providerLabelMap:j,apiKeyMap:i,onSelect:a,isEven:y%2===0,density:p,visibleColumnSet:n},N.id))})]})}),f&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-t p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t("logs.table.pagination.perPage")}),e.jsxs(ee,{value:S.toString(),onValueChange:N=>b(Number(N)),children:[e.jsx(te,{className:"w-[80px]",children:e.jsx(se,{})}),e.jsx(le,{children:H.map(N=>e.jsx(L,{value:N.toString(),children:N},N))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"outline",size:"sm",onClick:()=>T(N=>Math.max(N-1,1)),disabled:D<=1,children:t("logs.table.pagination.previous")}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("logs.table.pagination.pageLabel",{page:C===0?0:D,total:C})}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>T(N=>C===0?N:Math.min(N+1,C)),disabled:C===0||D>=C,children:t("logs.table.pagination.next")})]})]})]})})}function Tt({exportTimeoutMs:l,queryParams:t,total:o}){const{t:n}=M(),{pushToast:d}=ge(),[s,r]=g.useState(!1),h=g.useCallback(async()=>{if(!s){r(!0);try{const c=o>0?Math.min(o,5e3):1e3,v={...t,limit:c,offset:0},u=await he.exportArchive(v,l),j=new Date().toISOString().replace(/[:.]/g,"-"),i=URL.createObjectURL(u),a=document.createElement("a");a.href=i,a.download=`cc-gw-logs-${j}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i),d({title:n("logs.toast.exportSuccess.title"),description:n("logs.toast.exportSuccess.desc"),variant:"success"})}catch(c){const v=st(c);d({title:n("logs.toast.exportError.title"),description:n("logs.toast.exportError.desc",{message:v.message}),variant:"error"})}finally{r(!1)}}},[l,s,d,t,n,o]);return{exporting:s,handleExport:h}}function Rt(){const l=g.useRef(null),[t,o]=g.useState(!1),n=g.useCallback(()=>{const d=l.current;if(!d)return;const s=d.scrollWidth-d.scrollLeft-d.clientWidth>1;o(s)},[]);return g.useEffect(()=>{const d=l.current;if(!d)return;n(),d.addEventListener("scroll",n,{passive:!0});const s=new ResizeObserver(n);return s.observe(d),()=>{d.removeEventListener("scroll",n),s.disconnect()}},[n]),{scrollRef:l,showScrollHint:t,updateScrollHint:n}}function Lt(){const[l,t]=R(_.logs.density,kt,{serialize:u=>u,deserialize:u=>u==="compact"?"compact":"comfortable"}),[o,n]=R(_.logs.visibleColumns,wt),{scrollRef:d,showScrollHint:s}=Rt(),r=g.useMemo(()=>new Set(o),[o]),h=o.length+2,c=g.useCallback(u=>{n(j=>{if(j.includes(u))return j.length===1?j:j.filter(a=>a!==u);const i=[...j,u];return i.sort((a,p)=>ae.indexOf(a)-ae.indexOf(p)),i})},[]);return{resetVisibleColumns:g.useCallback(()=>{n(Q)},[]),rowDensity:l,setRowDensity:t,showScrollHint:s,tableScrollRef:d,toggleColumn:c,visibleColumnCount:h,visibleColumns:o,visibleColumnSet:r}}function Mt(){var je,ve,Ne,we,ke;const{t:l}=M(),{pushToast:t}=ge(),[o,n]=R(_.logs.providerFilter,"all"),[d,s]=R(_.logs.endpointFilter,"all"),[r,h]=R(_.logs.modelFilter,""),[c,v]=R(_.logs.statusFilter,"all"),[u,j]=R(_.logs.fromDate,""),[i,a]=R(_.logs.toDate,""),[p,f]=g.useState(1),[S,b]=R(_.logs.pageSize,St,{serialize:m=>String(m),deserialize:m=>{const k=Number(m);return H.includes(k)?k:H[0]}}),[D,C]=g.useState(null),[T,N]=g.useState(!1),[y,B]=R(_.logs.selectedApiKeys,Ct),[re,oe]=R(_.logs.filtersExpanded,!1),{resetVisibleColumns:W,rowDensity:x,setRowDensity:G,showScrollHint:Fe,tableScrollRef:Te,toggleColumn:Re,visibleColumnCount:Le,visibleColumns:Me,visibleColumnSet:Ke}=Lt();g.useEffect(()=>{f(1)},[o,d,r,c,u,i,S,y]);const ie=g.useMemo(()=>{const m={limit:S,offset:(p-1)*S};o!=="all"&&(m.provider=o),d!=="all"&&(m.endpoint=d),r.trim().length>0&&(m.model=r.trim()),c!=="all"&&(m.status=c);const k=Ce(u),q=Ce(i,!0);return k!==void 0&&(m.from=k),q!==void 0&&(m.to=q),y.length>0&&(m.apiKeys=y.join(",")),m},[d,u,r,p,S,o,y,c,i]),P=$(U.logs.list(ie),he.listRequest(ie)),V=$(U.providers.all(),Se.providersRequest()),fe=$(U.apiKeys.all(),{url:"/api/keys",method:"GET"}),ne=$(U.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"}),be=$(U.config.exportTimeout(),Se.configRequest());g.useEffect(()=>{!P.isError||!P.error||t({title:l("logs.toast.listError.title"),description:l("logs.toast.listError.desc",{message:P.error.message}),variant:"error"})},[P.error,P.isError,t,l]),g.useEffect(()=>{!V.isError||!V.error||t({title:l("logs.toast.providerError.title"),description:l("logs.toast.providerError.desc",{message:V.error.message}),variant:"error"})},[V.error,V.isError,t,l]);const Z=((je=P.data)==null?void 0:je.total)??0,J=Z>0?Math.ceil(Z/S):0,Pe=((ve=P.data)==null?void 0:ve.items)??[],Ae=g.useMemo(()=>{var k;const m=(k=be.data)==null?void 0:k.logExportTimeoutSeconds;return typeof m=="number"&&Number.isFinite(m)?Math.min(Math.max(Math.round(m),5),600)*1e3:6e4},[(Ne=be.data)==null?void 0:Ne.logExportTimeoutSeconds]);g.useEffect(()=>{J>0&&p>J&&f(J)},[p,J]);const de=V.data??[],ce=g.useMemo(()=>{const m=new Map;for(const k of de)k.id&&m.set(k.id,k.label??k.id);return m},[de]),ye=g.useMemo(()=>{var k;const m=new Map;m.set("anthropic",l("logs.filters.endpointAnthropic")),m.set("openai",l("logs.filters.endpointOpenAI"));for(const q of((k=ne.data)==null?void 0:k.endpoints)??[])m.set(q.id,q.label||q.id);return m},[(we=ne.data)==null?void 0:we.endpoints,l]),Oe=g.useMemo(()=>{const m=[];if(o!=="all"){const k=ce.get(o)??o;m.push({key:"provider",label:`${l("logs.filters.provider")}: ${k}`,onRemove:()=>n("all")})}if(d!=="all"){const k=ye.get(d)??d;m.push({key:"endpoint",label:`${l("logs.filters.endpoint")}: ${k}`,onRemove:()=>s("all")})}if(r.trim()&&m.push({key:"model",label:`${l("logs.filters.modelId")}: ${r.trim()}`,onRemove:()=>h("")}),c!=="all"){const k=l(c==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");m.push({key:"status",label:`${l("logs.filters.status")}: ${k}`,onRemove:()=>v("all")})}return u&&m.push({key:"from",label:`${l("logs.filters.startDate")}: ${u}`,onRemove:()=>j("")}),i&&m.push({key:"to",label:`${l("logs.filters.endDate")}: ${i}`,onRemove:()=>a("")}),y.length>0&&m.push({key:"apiKeys",label:l("logs.filters.apiKeySelected",{count:y.length}),onRemove:()=>B([])}),m},[d,ye,u,r,o,ce,y.length,c,l,i]),me=fe.data??[],ze=g.useMemo(()=>{const m=new Map;for(const k of me)m.set(k.id,k);return m},[me]),qe=g.useMemo(()=>ae.map(m=>({id:m,label:l(`logs.table.columns.${m}`)})),[l]),X=g.useMemo(()=>new Date().toISOString().slice(0,10),[]),Ie=g.useMemo(()=>o==="all"&&d==="all"&&r.trim()===""&&c==="all"&&u===""&&i===""&&y.length===0?"all":c==="error"&&d==="all"&&o==="all"&&r.trim()===""&&u===""&&i===""&&y.length===0?"errors":_t(u,i,X)&&d==="all"&&o==="all"&&r.trim()===""&&c==="all"&&y.length===0?"today":d==="anthropic"&&o==="all"&&r.trim()===""&&c==="all"&&u===""&&i===""&&y.length===0?"anthropic":d==="openai"&&o==="all"&&r.trim()===""&&c==="all"&&u===""&&i===""&&y.length===0?"openai":null,[d,u,r,o,y.length,c,i,X]),pe=g.useCallback(()=>{n("all"),h(""),s("all"),v("all"),j(""),a(""),B([])},[]),Qe=g.useCallback(m=>{if(f(1),pe(),m!=="all"){if(m==="errors"){v("error");return}if(m==="today"){j(X),a(X);return}if(m==="anthropic"){s("anthropic");return}m==="openai"&&s("openai")}},[pe,X]),{exporting:Ve,handleExport:$e}=Tt({exportTimeoutMs:Ae,queryParams:ie,total:Z}),Ue=g.useCallback(m=>{C(m),N(!0)},[]),He=g.useCallback(()=>{N(!1),C(null)},[]);return{activeFilters:Oe,activeQuickView:Ie,apiKeyMap:ze,apiKeys:me,apiKeysQuery:fe,applyQuickView:Qe,columnOptions:qe,customEndpoints:(ke=ne.data)==null?void 0:ke.endpoints,endpointFilter:d,exporting:Ve,filtersExpanded:re,fromDate:u,handleCloseDetail:He,handleExport:$e,handleOpenDetail:Ue,handleResetFilters:pe,isDetailOpen:T,items:Pe,logsQuery:P,modelFilter:r,page:p,pageSize:S,providerFilter:o,providerLabelMap:ce,providerOptions:de,rowDensity:x,resetVisibleColumns:W,selectedApiKeys:y,selectedLogId:D,setEndpointFilter:s,setFiltersExpanded:oe,setFromDate:j,setModelFilter:h,setPage:f,setPageSize:b,setProviderFilter:n,setRowDensity:G,setSelectedApiKeys:B,setStatusFilter:v,setToDate:a,showScrollHint:Fe,statusFilter:c,tableScrollRef:Te,toDate:i,toggleColumn:Re,total:Z,totalPages:J,visibleColumnCount:Le,visibleColumns:Me,visibleColumnSet:Ke}}function ss(){var o;const{t:l}=M(),t=Mt();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(et,{icon:e.jsx(Ye,{className:"h-5 w-5","aria-hidden":"true"}),title:l("logs.title"),description:l("logs.description"),eyebrow:"Traffic Explorer",breadcrumb:"Gateway / Logs",helper:l("logs.filtersDescription"),badge:t.total>0?l("logs.summary.total",{value:t.total.toLocaleString()}):void 0,actions:e.jsx(Et,{columnOptions:t.columnOptions,exporting:t.exporting,onExport:()=>void t.handleExport(),onRefresh:()=>void t.logsQuery.refetch(),onResetColumns:t.resetVisibleColumns,onSetDensity:t.setRowDensity,onToggleColumn:t.toggleColumn,refreshing:t.logsQuery.isFetching,rowDensity:t.rowDensity,total:t.total,visibleColumns:t.visibleColumns,visibleColumnSet:t.visibleColumnSet})}),e.jsx(yt,{total:t.total,activeFilters:t.activeFilters,filtersExpanded:t.filtersExpanded,setFiltersExpanded:t.setFiltersExpanded,handleResetFilters:t.handleResetFilters,activeQuickView:t.activeQuickView,applyQuickView:t.applyQuickView,providerFilter:t.providerFilter,setProviderFilter:t.setProviderFilter,endpointFilter:t.endpointFilter,setEndpointFilter:t.setEndpointFilter,selectedApiKeys:t.selectedApiKeys,setSelectedApiKeys:t.setSelectedApiKeys,modelFilter:t.modelFilter,setModelFilter:t.setModelFilter,statusFilter:t.statusFilter,setStatusFilter:t.setStatusFilter,fromDate:t.fromDate,setFromDate:t.setFromDate,toDate:t.toDate,setToDate:t.setToDate,providerOptions:t.providerOptions,apiKeys:t.apiKeys,apiKeysLoading:t.apiKeysQuery.isLoading,customEndpoints:t.customEndpoints}),e.jsx(Ft,{tableScrollRef:t.tableScrollRef,visibleColumnSet:t.visibleColumnSet,visibleColumnCount:t.visibleColumnCount,logsError:t.logsQuery.isError?((o=t.logsQuery.error)==null?void 0:o.message)??null:null,logsPending:t.logsQuery.isPending,items:t.items,activeFiltersCount:t.activeFilters.length,handleResetFilters:t.handleResetFilters,handleRetry:()=>void t.logsQuery.refetch(),providerLabelMap:t.providerLabelMap,apiKeyMap:t.apiKeyMap,handleOpenDetail:t.handleOpenDetail,rowDensity:t.rowDensity,showScrollHint:t.showScrollHint,pageSize:t.pageSize,setPageSize:t.setPageSize,page:t.page,totalPages:t.totalPages,setPage:t.setPage}),e.jsx(vt,{open:t.isDetailOpen,logId:t.selectedLogId,onClose:t.handleCloseDetail,providerLabelMap:t.providerLabelMap,apiKeyMap:t.apiKeyMap})]})}export{ss as default};
|