@chenpu17/cc-gw 0.8.0-beta.1 → 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/package.json +5 -5
- package/src/web/dist/assets/{About--y9YE6K4.js → About-bnb_BU6z.js} +1 -1
- package/src/web/dist/assets/{ApiKeys-Cq26DYhq.js → ApiKeys-DXJYgiYr.js} +1 -1
- package/src/web/dist/assets/{Dashboard-DPK1vZIh.js → Dashboard-_T1jT56-.js} +1 -1
- package/src/web/dist/assets/{DialogShell-DfNF-aGB.js → DialogShell-s3yKnQyp.js} +1 -1
- package/src/web/dist/assets/{Events-CBybr6NR.js → Events-B7l9cIhA.js} +1 -1
- package/src/web/dist/assets/{Help-B_Gv6fxg.js → Help-M_B7c7Hj.js} +1 -1
- package/src/web/dist/assets/{Login-b0UTBvLE.js → Login-CXG8h1Xd.js} +1 -1
- package/src/web/dist/assets/{Logs-Cee9IbYJ.js → Logs-DVPaFD7W.js} +1 -1
- package/src/web/dist/assets/{ModelManagement-ToEpbTSg.js → ModelManagement-m4p97Xel.js} +1 -1
- package/src/web/dist/assets/{PageHeader-C2dWqrhL.js → PageHeader-KQ9mjVAV.js} +1 -1
- package/src/web/dist/assets/{PageSection-Bo342pqO.js → PageSection-C9Wb9Oe3.js} +1 -1
- package/src/web/dist/assets/{PageState-CwdRJgzr.js → PageState-D-1-sNyq.js} +1 -1
- package/src/web/dist/assets/Profiler-Bb-I7NR2.js +1 -0
- package/src/web/dist/assets/{Settings-vkbX-roP.js → Settings-CdZ_GGjR.js} +1 -1
- package/src/web/dist/assets/{Skeleton--dmlcnAs.js → Skeleton-H3SErRWs.js} +1 -1
- package/src/web/dist/assets/{badge-C0zaY90P.js → badge-3ORqzzzc.js} +1 -1
- package/src/web/dist/assets/{card-trgtgeo-.js → card-D1l7si2X.js} +1 -1
- package/src/web/dist/assets/{gateway-CBqZtiXq.js → gateway-CFNtAOS2.js} +1 -1
- package/src/web/dist/assets/index-8bCfrPhk.css +1 -0
- package/src/web/dist/assets/{index-Bit1YrKY.js → index-MqPrlTQ4.js} +2 -2
- package/src/web/dist/assets/{input-qaoXek91.js → input-Bb_t6wr6.js} +1 -1
- package/src/web/dist/assets/{label-BnaA-bMD.js → label-8HO4VSYV.js} +1 -1
- package/src/web/dist/assets/{popover-BHvlazWa.js → popover-5I-o07-i.js} +1 -1
- package/src/web/dist/assets/{select-9XUksDWE.js → select-kdaAyzec.js} +1 -1
- package/src/web/dist/assets/{switch-C6QFLGRv.js → switch-DLCOPP-U.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-RQCL-J9v.js → useApiQuery-Bcqr7uHV.js} +1 -1
- package/src/web/dist/assets/{useAppMutation-hYRpzVBg.js → useAppMutation-CqHoYeK1.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/src/web/dist/assets/Profiler-BL-Ksg3a.js +0 -1
- package/src/web/dist/assets/index-DkFxUocM.css +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.8.0-beta.
|
|
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-beta.
|
|
29
|
-
"@chenpu17/cc-gw-linux-
|
|
30
|
-
"@chenpu17/cc-gw-linux-
|
|
31
|
-
"@chenpu17/cc-gw-win32-x64": "0.8.0-beta.
|
|
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",
|
|
@@ -1 +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-
|
|
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};
|
|
@@ -1 +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-Bit1YrKY.js";import{P as ts}from"./PageHeader-C2dWqrhL.js";import{C as as,u as P}from"./useAppMutation-hYRpzVBg.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-DfNF-aGB.js";import{I as Ke}from"./input-qaoXek91.js";import{L as U}from"./label-BnaA-bMD.js";import{u as I}from"./useApiQuery-RQCL-J9v.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-Bo342pqO.js";import{B as w}from"./badge-C0zaY90P.js";import{C as le,a as oe}from"./card-trgtgeo-.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};
|
|
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};
|
|
@@ -1 +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-C2dWqrhL.js";import{P as K,a as z}from"./PageState-CwdRJgzr.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-Bit1YrKY.js";import{S as ze,a as Ve,b as Ue,c as Ke,d as O}from"./select-9XUksDWE.js";import{E as Ye}from"./EChart-Dqa_Xbrn.js";import{P as me}from"./PageSection-Bo342pqO.js";import{S as Xe,C as Ze,T as Je}from"./Skeleton--dmlcnAs.js";import{B as E}from"./badge-C0zaY90P.js";import{C as M,a as B}from"./card-trgtgeo-.js";import{u as C}from"./i18n-CfLThlXq.js";import{e as We}from"./charts-core-vuhzGmuT.js";import{u as w}from"./useApiQuery-RQCL-J9v.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};
|
|
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};
|
|
@@ -1 +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-
|
|
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};
|
|
@@ -1 +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-C2dWqrhL.js";import{P as G}from"./PageSection-Bo342pqO.js";import{P as Q,a as $}from"./PageState-CwdRJgzr.js";import{u as H}from"./useApiQuery-RQCL-J9v.js";import{u as J,B as x,c as p}from"./index-Bit1YrKY.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-C0zaY90P.js";import{C as N,a as y}from"./card-trgtgeo-.js";import{I as U}from"./input-qaoXek91.js";import{S as _,a as W,b as X,c as Y,d as g}from"./select-9XUksDWE.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};
|
|
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};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
2
|
`),d=c.join(`
|
|
3
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
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(`
|
|
@@ -1 +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-
|
|
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};
|