@chenpu17/cc-gw 0.9.0-beta.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/web/dist/assets/{About-WPCkWxkz.js → About-DhB_6utk.js} +1 -1
- package/src/web/dist/assets/{ApiKeys-Q-EteBox.js → ApiKeys-Cx4kYUfE.js} +1 -1
- package/src/web/dist/assets/{ConfirmDialog-CvC_VLb2.js → ConfirmDialog-CgKijCNt.js} +1 -1
- package/src/web/dist/assets/Dashboard-CyjVgsnF.js +1 -0
- package/src/web/dist/assets/{Events-CBVp1fVz.js → Events-CWvgjYnj.js} +1 -1
- package/src/web/dist/assets/{Help-M3pIEoJN.js → Help-CLGrjSta.js} +1 -1
- package/src/web/dist/assets/{Login-DtAkFJMT.js → Login-j6M7LsIk.js} +1 -1
- package/src/web/dist/assets/{Logs-CIPbrHMJ.js → Logs-lC0QWlZz.js} +1 -1
- package/src/web/dist/assets/{ProvidersWorkbench-DvlPlloy.js → ProvidersWorkbench-CXS-UBtR.js} +1 -1
- package/src/web/dist/assets/Settings-bJkZ6l1O.js +1 -0
- package/src/web/dist/assets/{Setup-CfD6U8Nf.js → Setup-BIEy_Ywx.js} +1 -1
- package/src/web/dist/assets/{apiKeys-CoQ69TK_.js → apiKeys-DngGSX7O.js} +1 -1
- package/src/web/dist/assets/app-vWIA9Pq_.js +61 -0
- package/src/web/dist/assets/{gateway-Dxoj2rj4.js → gateway-B7Y2AqSU.js} +1 -1
- package/src/web/dist/assets/{landing-DBrU8FIr.js → landing-Dj8Ojphq.js} +1 -1
- package/src/web/dist/assets/package-BBDLwVNt.js +1 -0
- package/src/web/dist/assets/{shared-HT9X1BTy.js → shared-D9r3kFnp.js} +1 -1
- package/src/web/dist/assets/{useAppMutation-DbIs5qvT.js → useAppMutation-DJ2QsEsU.js} +1 -1
- package/src/web/dist/assets/{useProviderForm-BiVzWP3H.js → useProviderForm-eK2SFp4F.js} +1 -1
- package/src/web/dist/index.html +1 -1
- package/src/web/dist/landing.html +2 -2
- package/src/web/dist/assets/Dashboard-Q99L2W8N.js +0 -1
- package/src/web/dist/assets/Settings-CNI4qHrl.js +0 -1
- package/src/web/dist/assets/app-czRBzLXv.js +0 -61
- package/src/web/dist/assets/package-BXeeAB6b.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.9.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Local-first AI gateway for personal developers and small software teams, with web console and CLI daemon.",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@chenpu17/cc-gw-darwin-arm64": "0.9.0
|
|
38
|
-
"@chenpu17/cc-gw-linux-
|
|
39
|
-
"@chenpu17/cc-gw-
|
|
40
|
-
"@chenpu17/cc-gw-
|
|
37
|
+
"@chenpu17/cc-gw-darwin-arm64": "0.9.0",
|
|
38
|
+
"@chenpu17/cc-gw-linux-arm64": "0.9.0",
|
|
39
|
+
"@chenpu17/cc-gw-win32-x64": "0.9.0",
|
|
40
|
+
"@chenpu17/cc-gw-linux-x64": "0.9.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"colorette": "^2.0.20",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e,aX as q,aY as m,aq as B,W as R}from"./vendor-CITafuNQ.js";import{P as F}from"./PageToolbar-CWw40AFL.js";import{P as p}from"./PageSection-N34Nu8NO.js";import{P as M,a as C}from"./PageState-CFLrRswm.js";import{u as z}from"./useAppMutation-
|
|
1
|
+
import{r as n,j as e,aX as q,aY as m,aq as B,W as R}from"./vendor-CITafuNQ.js";import{P as F}from"./PageToolbar-CWw40AFL.js";import{P as p}from"./PageSection-N34Nu8NO.js";import{P as M,a as C}from"./PageState-CFLrRswm.js";import{u as z}from"./useAppMutation-DJ2QsEsU.js";import{a as D,c as G,B as x,q as I,r as $}from"./app-vWIA9Pq_.js";import{B as P}from"./badge-DpUlf_NW.js";import{C as d,a as c}from"./card-D4YOc5eB.js";import{p as J}from"./package-BBDLwVNt.js";import{u as Q}from"./i18n-PeX9kBVO.js";import"./global-BCehxTGJ.js";import"./query-DZF7K6hv.js";import"./router-BoBrmro7.js";import"./radix-Bux_1C5J.js";function oe(){var h,g,f,v,j,N,y,w,k,S;const{t}=Q(),{pushToast:r}=D(),[i,A]=n.useState(null),a=G(I.status.gateway(),{url:"/api/status",method:"GET"},{staleTime:6e4});n.useEffect(()=>{a.isError&&a.error&&r({title:t("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[r,a.error,a.isError,t]);const o=z({mutationFn:async()=>$({url:"/api/version/check",method:"GET"}),successToast:s=>s.updateAvailable?{title:t("about.toast.updateAvailable.title",{version:s.latestVersion}),description:t("about.toast.updateAvailable.description",{packageName:s.packageName})}:{title:t("about.toast.upToDate.title",{version:s.currentVersion}),description:t("about.toast.upToDate.description")},errorToast:s=>({title:t("about.toast.updateError.title"),description:s.message}),onSuccess:async s=>{A(s)}}),l=J.version,u="2026-07-30T02:56:10.611Z",V=n.useMemo(()=>{var s,T;return[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{"data-visual-volatile":"true",className:"font-mono text-primary",children:["v",l]})},{label:t("about.app.labels.buildTime"),value:e.jsx("span",{"data-visual-volatile":"true",children:u}),hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.runtime"),value:e.jsx("span",{className:"font-mono",children:((s=a.data)==null?void 0:s.runtime)??"rust"})},{label:t("about.app.labels.backendVersion"),value:e.jsx("span",{"data-visual-volatile":"true",className:"font-mono",children:((T=a.data)==null?void 0:T.backendVersion)??"-"})}]},[l,u,(h=a.data)==null?void 0:h.backendVersion,(g=a.data)==null?void 0:g.runtime,t]),b=n.useMemo(()=>{var s;return a.data?[{label:t("about.status.labels.host"),value:a.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:e.jsx("span",{"data-visual-volatile":"true",children:a.data.port.toLocaleString()})},{label:t("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")},{label:t("about.status.labels.platform"),value:a.data.platform??"-"},{label:t("about.status.labels.pid"),value:e.jsx("span",{"data-visual-volatile":"true",children:((s=a.data.pid)==null?void 0:s.toLocaleString())??"-"})}]:[]},[a.data,t]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(F,{info:e.jsxs("span",{className:"rounded-lg bg-secondary px-2.5 py-1 text-xs text-muted-foreground","data-visual-volatile":"true",children:["v",l]}),status:e.jsx("span",{className:"rounded-lg bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:"manual refresh only"}),actions:e.jsxs(x,{onClick:()=>o.mutate(),disabled:o.isPending,size:"sm",children:[e.jsx(q,{className:`mr-2 h-4 w-4${o.isPending?" animate-spin":""}`,"aria-hidden":"true"}),o.isPending?t("about.support.actions.checkingUpdates"):t("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(320px,0.85fr)]",children:[e.jsx(d,{className:"overflow-hidden",children:e.jsx(c,{className:"p-5",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg bg-secondary px-3 py-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[e.jsx(m,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"metric-number truncate text-4xl font-semibold tracking-tight text-foreground",children:[((f=a.data)==null?void 0:f.host)??"127.0.0.1",":",((v=a.data)==null?void 0:v.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.description")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs sm:w-56",children:[e.jsx(L,{label:t("about.status.labels.providers"),value:((N=(j=a.data)==null?void 0:j.providers)==null?void 0:N.toLocaleString())??"-"}),e.jsx(L,{label:t("about.status.labels.active"),value:(((y=a.data)==null?void 0:y.activeRequests)??0).toLocaleString()})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{variant:"outline",children:((w=a.data)==null?void 0:w.runtime)??"rust"}),e.jsx(P,{variant:"outline",children:((k=a.data)==null?void 0:k.platform)??"-"})]})]})})}),e.jsx(d,{className:"overflow-hidden",children:e.jsx(c,{className:"p-5",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("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"font-mono text-xl font-semibold text-primary",children:["v",l]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-xs text-muted-foreground",children:u})]}),i?e.jsxs("div",{className:"rounded-lg bg-secondary px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:i.updateAvailable?t("about.update.available",{version:i.latestVersion}):t("about.update.current",{version:i.currentVersion})}),e.jsxs("p",{className:"mt-1",children:[t("about.update.channel",{channel:i.channel}),i.publishedAt?` · ${new Date(i.publishedAt).toLocaleString()}`:""]})]}):null,e.jsx("div",{className:"rounded-lg bg-secondary px-3.5 py-3 text-sm text-muted-foreground",children:t("about.support.tip")})]})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(p,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(E,{items:V})}),e.jsx(p,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),disabled:a.isFetching,children:[e.jsx(B,{className:U(a.isFetching),"aria-hidden":"true"}),a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:a.isLoading?e.jsx(M,{compact:!0,label:t("about.status.loading")}):a.isError?e.jsx(C,{compact:!0,tone:"danger",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("common.status.error"),description:((S=a.error)==null?void 0:S.message)??t("common.unknownError"),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:t("common.actions.refresh")})}):b.length>0?e.jsx(E,{items:b}):e.jsx(C,{compact:!0,tone:"primary",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.status.empty"),description:t("common.actions.refresh")})})]}),e.jsx(p,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),children:e.jsx(d,{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(c,{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 rounded-lg bg-secondary p-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl 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:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-lg bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}function E({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-3 sm:grid-cols-2",children:t.map(r=>e.jsx(d,{className:"rounded-xl border border-border bg-secondary shadow-none",children:e.jsxs(c,{className:"p-4",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:r.label}),e.jsx("dd",{className:"metric-number mt-2 text-sm font-semibold text-foreground",children:r.value}),r.hint?e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r.hint}):null]})},r.label))})}function L({label:t,value:r}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2 text-right",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"metric-number mt-1 text-sm font-semibold text-foreground",children:r})]})}function U(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as e,$ as xs,ak as te,U as Ce,aP as B,aQ as ie,as as us,aR as ve,aS as ms,aT as Ee,aA as De,ay as hs}from"./vendor-CITafuNQ.js";import{a as ae,P as gs}from"./PageState-CFLrRswm.js";import{P as ys}from"./PageToolbar-CWw40AFL.js";import{B as u,a as js,b as L,c as Y,s as O,q as N}from"./app-czRBzLXv.js";import{T as bs,a as vs,b as fe,c as Ke}from"./tabs-UWyz9J_W.js";import{C as fs}from"./ConfirmDialog-CvC_VLb2.js";import{D as ne,A as le,a as re,b as ce,c as Te,d as oe,e as de}from"./DialogShell-CM92wXHo.js";import{L as P,I as U}from"./label-DSVzZIex.js";import{c as ke}from"./global-BCehxTGJ.js";import{E as Ae,R as Me,u as Ks}from"./shared-HT9X1BTy.js";import{u as w}from"./i18n-PeX9kBVO.js";import{L as Ns}from"./router-BoBrmro7.js";import{T as ws,a as Cs,b as Ne,c as W,d as Es,e as z,E as Ds}from"./table-CVuTTP1s.js";import{P as We}from"./PageSection-N34Nu8NO.js";import{B as A}from"./badge-DpUlf_NW.js";import{C as S,a as ze}from"./card-D4YOc5eB.js";import{M as Z}from"./metric-card-G1bbpbiR.js";import{S as qe}from"./segmented-control-13KTib6k.js";import{e as Ts}from"./charts-core-BTTtAoo-.js";import{u as H}from"./useAppMutation-DbIs5qvT.js";import{a as q}from"./apiKeys-CoQ69TK_.js";import{c as ks}from"./clipboard-BnAnBk_-.js";import"./query-DZF7K6hv.js";import"./radix-Bux_1C5J.js";import"./charts-react-BQP6-BFp.js";import"./charts-engine-CFhx8nba.js";const Fe=o.forwardRef(({className:a,...s},p)=>e.jsx("textarea",{className:ke("flex min-h-[80px] w-full rounded-xl border border-border bg-card px-3 py-2.5 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:p,...s}));Fe.displayName="Textarea";function As({availableEndpoints:a,isOpen:s,keyDescription:p,keyName:i,maxConcurrency:r,onDescriptionChange:m,onEndpointsChange:y,onKeyNameChange:v,onMaxConcurrencyChange:x,onOpenChange:d,onSubmit:g,selectedEndpoints:n}){const{t:l}=w();return e.jsx(ne,{open:s,onOpenChange:d,children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:l("apiKeys.createNew")}),e.jsx(Te,{children:l("apiKeys.createDescription")})]}),e.jsxs(oe,{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:l("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-3 text-xs text-primary",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-lg border border-warning/30 bg-warning-bg px-3 py-3 text-xs text-warning",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-3 text-xs text-destructive",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(P,{htmlFor:"keyName",children:[l("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(U,{id:"keyName",value:i,onChange:h=>v(h.target.value),placeholder:l("apiKeys.keyNamePlaceholder"),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),g())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"keyDescription",children:l("apiKeys.descriptionLabel")}),e.jsx(Fe,{id:"keyDescription",value:p,onChange:h=>m(h.target.value),placeholder:l("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:l("apiKeys.allowedEndpoints")}),e.jsx(Ae,{available:a,selected:n,onChange:y,hint:l("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"maxConcurrency",children:l("apiKeys.maxConcurrency")}),e.jsx(U,{id:"maxConcurrency",type:"number",min:"0",value:r,onChange:h=>x(h.target.value),placeholder:l("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:()=>d(!1),children:l("common.actions.cancel")}),e.jsx(u,{onClick:g,children:l("apiKeys.createAction")})]})]})})}function Ms({createdKey:a,onClose:s,onCopy:p}){const{t:i}=w();return e.jsx(ne,{open:!!a,onOpenChange:r=>{r||s()},children:e.jsxs(le,{className:"max-w-xl",children:[e.jsx(re,{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-lg bg-success-bg text-success",children:e.jsx(xs,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(ce,{children:i("apiKeys.keyCreated")})]})}),e.jsxs(oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-warning",children:i("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:a==null?void 0:a.key}),a!=null&&a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null]}),e.jsxs(de,{children:[e.jsxs(u,{onClick:()=>p((a==null?void 0:a.key)??""),children:[e.jsx(te,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),i("common.actions.copy")]}),e.jsx(u,{variant:"outline",onClick:s,children:i("common.actions.close")})]})]})})}function Ws({apiKey:a,availableEndpoints:s,maxConcurrency:p,onClose:i,onEndpointsChange:r,onMaxConcurrencyChange:m,onSave:y,selectedEndpoints:v}){const{t:x}=w();return e.jsx(ne,{open:!!a,onOpenChange:d=>{d||i()},children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:x("apiKeys.editEndpoints")}),e.jsx(Te,{children:a==null?void 0:a.name})]}),e.jsxs(oe,{className:"space-y-4",children:[!(a!=null&&a.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-warning/30 bg-warning-bg px-4 py-3 text-xs text-warning",children:x("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(Ae,{available:s,selected:v,onChange:r,hint:x("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"editMaxConcurrency",children:x("apiKeys.maxConcurrency")}),e.jsx(U,{id:"editMaxConcurrency",type:"number",min:"0",value:p,onChange:d=>m(d.target.value),placeholder:x("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:i,children:x("common.actions.cancel")}),e.jsx(u,{onClick:y,children:x("common.save")})]})]})})}function zs({deleteTarget:a,isDeleting:s,onConfirm:p,onOpenChange:i}){const{t:r}=w();return e.jsx(fs,{open:!!a,onOpenChange:i,title:r("apiKeys.deleteDialogTitle"),description:r("apiKeys.confirmDelete"),confirmLabel:a&&s===a.id?r("common.actions.loading"):r("apiKeys.actions.delete"),cancelLabel:r("common.actions.cancel"),loading:a?s===a.id:!1,onConfirm:p,children:a?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:a.name}):null})}function qs({onDismiss:a}){const{t:s}=w();return e.jsxs(S,{className:"relative p-3 sm:p-3.5",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"max-w-md space-y-1 pr-8",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary/75",children:"Recommended"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s("apiKeys.quickStart.title")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("apiKeys.quickStart.description")})]}),e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1 lg:mx-0 lg:overflow-visible lg:pb-0",children:e.jsxs("div",{className:"flex gap-2 px-1 md:grid md:grid-cols-3 md:px-0 lg:max-w-3xl",children:[e.jsx(ee,{icon:e.jsx(Ce,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(ee,{icon:e.jsx(B,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.restrict.title"),description:s("apiKeys.quickStart.restrict.description")}),e.jsx(ee,{icon:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})]}),a?e.jsx(u,{variant:"ghost",size:"icon",className:"absolute right-1.5 top-1.5 h-7 w-7 text-muted-foreground hover:bg-secondary hover:text-foreground",onClick:a,"aria-label":s("common.actions.close"),children:e.jsx(us,{className:"h-4 w-4","aria-hidden":"true"})}):null]})}function Fs({activeKeysValue:a,enabledKeysValue:s,loading:p,onRangeChange:i,rangeDays:r,requestsChartOption:m,totalKeysValue:y,tokensChartOption:v,usageLength:x}){const{t:d}=w();return e.jsx(We,{title:d("apiKeys.analytics.title"),description:d("apiKeys.analytics.description",{days:r}),actions:e.jsx(qe,{className:"w-full overflow-x-auto sm:w-auto",value:r,onChange:i,options:Me.map(g=>({value:g.value,label:d(g.labelKey)}))}),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(Z,{label:d("apiKeys.analytics.cards.total"),value:y,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.enabled"),value:s,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.active",{days:r}),value:a,size:"sm"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(we,{title:d("apiKeys.analytics.charts.requests"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:m}),e.jsx(we,{title:d("apiKeys.analytics.charts.tokens"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:v})]})]})})}function Ls({filteredKeys:a,formatDate:s,hasWildcard:p,isDeleting:i,isRevealing:r,keys:m,onCopy:y,onDelete:v,onEditEndpoints:x,onFilterChange:d,onHide:g,onReveal:n,onStatusFilterChange:l,onToggleEnabled:h,revealedKeys:E,search:C,statusFilter:K,viewMode:T,onViewModeChange:j,onCreateKey:$}){const{t:b}=w();return e.jsx(We,{title:b("apiKeys.list.title"),description:p?b("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[e.jsx(qe,{value:T,onChange:j,options:[{value:"cards",label:b("apiKeys.views.cards"),icon:e.jsx(ve,{className:"h-3.5 w-3.5","aria-hidden":"true"})},{value:"compact",label:b("apiKeys.views.compact"),icon:e.jsx(ms,{className:"h-3.5 w-3.5","aria-hidden":"true"})}]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx(A,{variant:"outline",children:`${a.length}/${m.length}`})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary p-4 sm:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(U,{value:C,onChange:f=>d(f.target.value),placeholder:b("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex min-w-max items-center gap-1 overflow-x-auto rounded-full bg-background p-1 sm:justify-self-end",children:["all","enabled","disabled"].map(f=>e.jsx("button",{type:"button",onClick:()=>l(f),className:ke("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",K===f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:b(`apiKeys.filters.${f}`)},f))})]}),m.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(Ce,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyTitle"),description:b("apiKeys.list.empty"),action:e.jsx(u,{size:"sm",onClick:$,children:b("apiKeys.createNew")})}):a.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(ve,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyFilteredTitle"),description:b("apiKeys.list.emptyFiltered"),action:e.jsx(u,{variant:"outline",size:"sm",onClick:()=>{d(""),l("all")},children:b("common.actions.reset")})}):T==="compact"?e.jsx(Os,{filteredKeys:a,formatDate:s,isDeleting:i,isRevealing:r,onCopy:y,onDelete:v,onEditEndpoints:x,onHide:g,onReveal:n,onToggleEnabled:h,revealedKeys:E}):e.jsx("div",{className:"grid gap-4",children:a.map(f=>e.jsx(Rs,{formatDate:s,isDeleting:i===f.id,isRevealing:r===f.id,keySummary:f,onCopy:y,onDelete:v,onEditEndpoints:x,onHide:g,onReveal:n,onToggleEnabled:h,revealedValue:E.get(f.id)},f.id))})]})})}function Os({filteredKeys:a,formatDate:s,isDeleting:p,isRevealing:i,onCopy:r,onDelete:m,onEditEndpoints:y,onHide:v,onReveal:x,onToggleEnabled:d,revealedKeys:g}){const{t:n}=w();return e.jsx(S,{className:"overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ws,{className:"min-w-[980px]",children:[e.jsx(Cs,{children:e.jsxs(Ne,{className:"bg-secondary/45 hover:bg-secondary/45",children:[e.jsx(W,{children:n("apiKeys.table.name")}),e.jsx(W,{children:n("apiKeys.table.access")}),e.jsx(W,{className:"text-right",children:n("apiKeys.requestCount")}),e.jsx(W,{className:"text-right",children:n("apiKeys.totalTokens")}),e.jsx(W,{className:"text-right",children:n("apiKeys.maxConcurrency")}),e.jsx(W,{children:n("apiKeys.lastUsed")}),e.jsx(W,{className:"w-[132px] text-right",children:n("apiKeys.table.actions")})]})}),e.jsx(Es,{children:a.map(l=>{var K,T,j;const h=g.get(l.id),E=(l.totalInputTokens+l.totalOutputTokens).toLocaleString(),C=l.isWildcard?n("apiKeys.wildcard"):(((K=l.allowedEndpoints)==null?void 0:K.length)??0)>0?(T=l.allowedEndpoints)==null?void 0:T.join(", "):n("apiKeys.allEndpoints");return e.jsxs(Ne,{children:[e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:l.name}),l.isWildcard?e.jsx(A,{variant:"secondary",className:"text-[11px]",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:l.enabled?"default":"outline",className:"text-[11px]",children:l.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")})]}),l.isWildcard?null:e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"max-w-[220px] truncate rounded-md bg-secondary px-2 py-1 font-mono text-xs",children:h??l.maskedKey??"********"}),h?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>r(h),"aria-label":n("common.actions.copy"),children:e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(l.id),"aria-label":n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x(l.id),disabled:i===l.id,"aria-label":n("apiKeys.actions.reveal"),children:i===l.id?e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}),e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"max-w-[180px]",children:[e.jsx("div",{className:"truncate text-sm text-foreground",title:C,children:C}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.isWildcard?n("apiKeys.table.accessWildcard"):(((j=l.allowedEndpoints)==null?void 0:j.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.table.accessOpen")})]})}),e.jsx(z,{className:"py-3 text-right font-medium",children:l.requestCount.toLocaleString()}),e.jsx(z,{className:"py-3 text-right font-medium",children:E}),e.jsx(z,{className:"py-3 text-right font-medium",children:l.maxConcurrency?String(l.maxConcurrency):"—"}),e.jsxs(z,{className:"py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s(l.lastUsedAt)}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s(l.createdAt)})]}),e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(u,{variant:"outline",size:"icon",onClick:()=>y(l),className:"h-8 w-8","aria-label":l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),title:l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),children:e.jsx(B,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:l.enabled?"outline":"default",size:"sm",onClick:()=>d(l.id,l.enabled),className:"h-8 px-2.5 text-xs",children:l.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),l.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>m(l),disabled:p===l.id,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})})]},l.id)})})]})})})}function ee({description:a,icon:s,title:p}){return e.jsxs("div",{className:"w-[220px] shrink-0 rounded-xl border border-border bg-secondary p-3 md:w-auto",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-background text-primary sm:h-8 sm:w-8 sm:rounded-lg",children:s}),e.jsx("p",{className:"mt-2 text-[12px] font-semibold leading-5 text-foreground sm:mt-2.5 sm:text-[13px]",children:p}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground sm:text-xs sm:leading-5",children:a})]})}function Rs({formatDate:a,isDeleting:s,isRevealing:p,keySummary:i,onCopy:r,onDelete:m,onEditEndpoints:y,onHide:v,onReveal:x,onToggleEnabled:d,revealedValue:g}){var h,E,C;const{t:n}=w(),l=(i.totalInputTokens+i.totalOutputTokens).toLocaleString();return e.jsx(S,{"data-testid":"api-key-card",className:"overflow-hidden",children:e.jsx(ze,{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:i.name}),i.isWildcard?e.jsx(A,{variant:"secondary",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:i.enabled?"default":"outline",children:i.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")}),i.isWildcard?null:e.jsx(A,{variant:"outline",className:"text-xs",children:(((h=i.allowedEndpoints)==null?void 0:h.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.allEndpoints")}),!i.isWildcard&&i.allowedEndpoints&&i.allowedEndpoints.length>0?i.allowedEndpoints.map(K=>e.jsx(A,{variant:"outline",className:"text-xs",children:K},K)):i.isWildcard?null:e.jsx(A,{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(se,{label:n("apiKeys.requestCount"),value:i.requestCount.toLocaleString()}),e.jsx(se,{label:n("apiKeys.totalTokens"),value:l}),e.jsx(se,{label:n("apiKeys.maxConcurrency"),value:i.maxConcurrency?String(i.maxConcurrency):n("apiKeys.maxConcurrencyPlaceholder")})]}),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 bg-secondary px-3 py-1.5 font-mono text-sm",children:i.isWildcard?n("apiKeys.wildcard"):g??i.maskedKey??"********"}),i.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:g?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r(g),"aria-label":n("common.actions.copy"),title:n("common.actions.copy"),children:e.jsx(te,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>v(i.id),"aria-label":n("apiKeys.actions.hide"),title:n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(i.id),disabled:p,"aria-label":n("apiKeys.actions.reveal"),title:n("apiKeys.actions.reveal"),children:p?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-4 w-4","aria-hidden":"true"})})})]}),i.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("apiKeys.wildcardHint")}):i.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:i.description}):null,i.isWildcard?null:e.jsx("div",{className:"rounded-lg bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((E=i.allowedEndpoints)==null?void 0:E.length)??0)>0?`${n("apiKeys.allowedEndpoints")}: ${(C=i.allowedEndpoints)==null?void 0:C.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:a(i.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:a(i.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>y(i),className:"w-full lg:w-auto",children:[e.jsx(B,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),i.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints")]}),e.jsx(u,{variant:i.enabled?"outline":"default",size:"sm",onClick:()=>d(i.id,i.enabled),className:"w-full lg:w-auto",children:i.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),i.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>m(i),disabled:s,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function se({label:a,value:s}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:s})]})}function we({empty:a,emptyText:s,loading:p,option:i,title:r}){const{t:m}=w();return e.jsx(S,{children:e.jsxs(ze,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:r}),p?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:m("common.loadingShort")})}):a?e.jsx(ae,{compact:!0,className:"min-h-[280px] rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(B,{className:"h-5 w-5","aria-hidden":"true"}),title:s,description:m("apiKeys.analytics.emptyHint"),action:e.jsx(u,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(Ns,{to:"/logs",children:m("apiKeys.analytics.actions.logs")})})}):e.jsx(Ds,{echarts:Ts,option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function Ps(){const{t:a}=w(),{pushToast:s}=js(),[p,i]=o.useState(!1),[r,m]=o.useState(""),[y,v]=o.useState(""),[x,d]=o.useState([]),[g,n]=o.useState(""),[l,h]=o.useState(null),[E,C]=o.useState(null),[K,T]=o.useState(null),[j,$]=L(O.apiKeys.rangeDays,7,{serialize:t=>String(t),deserialize:t=>{const c=Number(t);return Me.some(D=>D.value===c)?c:7}}),[b,f]=o.useState(new Map),[Le,pe]=o.useState(null),[R,G]=o.useState(null),[I,xe]=o.useState([]),[_,ue]=o.useState(""),[X,Oe]=L(O.apiKeys.search,""),[V,Re]=L(O.apiKeys.statusFilter,"all",{serialize:t=>t,deserialize:t=>t==="enabled"||t==="disabled"?t:"all"}),[Pe,Ie]=L(O.apiKeys.viewMode,"compact",{serialize:t=>t,deserialize:t=>t==="cards"?"cards":"compact"}),[Ve,Qe]=L(O.apiKeys.activeTab,"inventory",{serialize:t=>t,deserialize:t=>t==="analytics"?"analytics":"inventory"}),[He,Ue]=L(O.apiKeys.quickStartDismissed,!1),Be=Ks(),me=Y(N.apiKeys.all(),q.listRequest()),Se=Y(N.apiKeys.overview(j),q.overviewRequest(j)),he=Y(N.apiKeys.usage(j),q.usageRequest(j)),ge=H({mutationFn:q.create,invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyCreated")}),errorToast:t=>({title:a("apiKeys.toast.createFailure",{message:t.message})})}),Q=H({mutationFn:({id:t,...c})=>q.update(t,c),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyUpdated")}),errorToast:t=>({title:a("apiKeys.toast.updateFailure",{message:t.message})})}),ye=H({mutationFn:({id:t})=>q.delete(t),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyDeleted")}),errorToast:t=>({title:a("apiKeys.toast.deleteFailure",{message:t.message})})}),je=H({mutationFn:({id:t})=>q.reveal(t),errorToast:t=>({title:a("apiKeys.toast.revealFailure"),description:t.message})}),M=me.data??[],F=Se.data,k=he.data??[],$e=M.some(t=>t.isWildcard),Ge=M.filter(t=>t.isWildcard).length,_e=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)>0}).length,Xe=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)===0}).length,Je=F?F.totalKeys.toLocaleString():"-",Ye=F?F.enabledKeys.toLocaleString():"-",Ze=F?F.activeKeys.toLocaleString():"-",es=o.useMemo(()=>M.filter(t=>{if(!(V==="all"||(V==="enabled"?t.enabled:!t.enabled)))return!1;const D=X.trim().toLowerCase();return D?[t.name,t.description??"",t.maskedKey??"",...t.allowedEndpoints??[]].join(" ").toLowerCase().includes(D):!0}),[M,X,V]),ss=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:k.map(c=>c.requests),itemStyle:{color:"var(--primary)"}}]}},[a,k]),as=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:k.map(c=>c.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:k.map(c=>c.outputTokens)}]}},[a,k]),be=o.useCallback(()=>{m(""),v(""),d([]),n("")},[]),J=o.useCallback(t=>{i(t),t||be()},[be]),ts=o.useCallback(async()=>{if(!r.trim()){s({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}const t=g.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<1)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{const c=await ge.mutateAsync({name:r.trim(),description:y.trim()||void 0,allowedEndpoints:x.length>0?x:void 0,maxConcurrency:t?Number(t):null});h(c),J(!1)}catch{}},[ge,J,y,x,g,r,s,a]),is=o.useCallback(async(t,c)=>{try{await Q.mutateAsync({id:t,enabled:!c})}catch{}},[Q]),ns=o.useCallback(async()=>{if(K){C(K.id);try{await ye.mutateAsync({id:K.id}),T(null)}catch{}finally{C(null)}}},[K,ye]),ls=o.useCallback(async t=>{if(!b.has(t)){pe(t);try{const c=await je.mutateAsync({id:t});f(D=>new Map(D).set(t,c.key))}catch{}finally{pe(null)}}},[je,b]),rs=o.useCallback(t=>{f(c=>{const D=new Map(c);return D.delete(t),D})},[]),cs=o.useCallback(async t=>{try{await ks(t),s({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(c){s({title:a("apiKeys.toast.copyFailure"),description:c instanceof Error?c.message:a("common.unknownError"),variant:"error"})}},[s,a]),os=o.useCallback(t=>{G(t),xe(t.allowedEndpoints??[]),ue(t.maxConcurrency?String(t.maxConcurrency):"")},[]),ds=o.useCallback(async()=>{if(!R)return;const t=_.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<1)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{await Q.mutateAsync({id:R.id,...R.isWildcard?{}:{allowedEndpoints:I.length>0?I:null},maxConcurrency:t?Number(t):null}),G(null)}catch{}},[R,I,_,s,a,Q]),ps=o.useCallback(t=>t?new Date(t).toLocaleString():a("common.noData"),[a]);return{activeKeysValue:Ze,activeTab:Ve,availableEndpoints:Be,deleteTarget:K,editEndpointsKey:R,editEndpointsSelection:I,editMaxConcurrency:_,enabledKeysValue:Ye,filteredKeys:es,formatDate:ps,handleCopyKey:cs,handleCreateDialogChange:J,handleCreateKey:ts,handleDeleteKey:ns,handleHideKey:rs,handleOpenEditEndpoints:os,handleRevealKey:ls,handleSaveEndpoints:ds,handleToggleEnabled:is,hasWildcard:$e,isCreateDialogOpen:p,isDeleting:E,isRevealing:Le,keys:M,keysQuery:me,newKeyDescription:y,newKeyEndpoints:x,newKeyMaxConcurrency:g,newKeyName:r,newlyCreatedKey:l,quickStartDismissed:He,rangeDays:j,requestsChartOption:ss,restrictedCount:_e,revealedKeys:b,search:X,setQuickStartDismissed:Ue,setActiveTab:Qe,setDeleteTarget:T,setEditEndpointsKey:G,setEditEndpointsSelection:xe,setEditMaxConcurrency:ue,setNewKeyDescription:v,setNewKeyEndpoints:d,setNewKeyMaxConcurrency:n,setNewKeyName:m,setNewlyCreatedKey:h,setRangeDays:$,setSearch:Oe,setStatusFilter:Re,statusFilter:V,tokensChartOption:as,totalKeysValue:Je,unrestrictedCount:Xe,usage:k,usageQuery:he,viewMode:Pe,wildcardCount:Ge,setViewMode:Ie}}function xa(){const{t:a}=w(),s=Ps();if(s.keysQuery.isLoading)return e.jsx(gs,{label:a("common.loading")});const i=s.keys.filter(r=>!r.isWildcard).length===0&&!s.quickStartDismissed;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ys,{status:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a("apiKeys.summary.wildcard",{count:s.wildcardCount})," / ",a("apiKeys.summary.restricted",{count:s.restrictedCount})," / ",a("apiKeys.summary.unrestricted",{count:s.unrestrictedCount})]}),actions:e.jsxs(u,{size:"sm",onClick:()=>s.handleCreateDialogChange(!0),children:[e.jsx(hs,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),i?e.jsx(qs,{onDismiss:()=>s.setQuickStartDismissed(!0)}):null,e.jsxs(bs,{value:s.activeTab,onValueChange:r=>s.setActiveTab(r),children:[e.jsxs(vs,{children:[e.jsx(fe,{value:"inventory",children:a("apiKeys.tabs.inventory")}),e.jsx(fe,{value:"analytics",children:a("apiKeys.tabs.analytics")})]}),e.jsx(Ke,{value:"inventory",className:"mt-4",children:e.jsx(Ls,{filteredKeys:s.filteredKeys,formatDate:s.formatDate,hasWildcard:s.hasWildcard,isDeleting:s.isDeleting,isRevealing:s.isRevealing,keys:s.keys,onCopy:r=>void s.handleCopyKey(r),onDelete:s.setDeleteTarget,onEditEndpoints:s.handleOpenEditEndpoints,onFilterChange:s.setSearch,onHide:s.handleHideKey,onReveal:r=>void s.handleRevealKey(r),onStatusFilterChange:s.setStatusFilter,onToggleEnabled:(r,m)=>void s.handleToggleEnabled(r,m),revealedKeys:s.revealedKeys,search:s.search,statusFilter:s.statusFilter,viewMode:s.viewMode,onViewModeChange:s.setViewMode,onCreateKey:()=>s.handleCreateDialogChange(!0)})}),e.jsx(Ke,{value:"analytics",className:"mt-4",children:e.jsx(Fs,{activeKeysValue:s.activeKeysValue,enabledKeysValue:s.enabledKeysValue,loading:s.usageQuery.isLoading,onRangeChange:s.setRangeDays,rangeDays:s.rangeDays,requestsChartOption:s.requestsChartOption,totalKeysValue:s.totalKeysValue,tokensChartOption:s.tokensChartOption,usageLength:s.usage.length})})]}),e.jsx(As,{availableEndpoints:s.availableEndpoints,isOpen:s.isCreateDialogOpen,keyDescription:s.newKeyDescription,keyName:s.newKeyName,maxConcurrency:s.newKeyMaxConcurrency,onDescriptionChange:s.setNewKeyDescription,onEndpointsChange:s.setNewKeyEndpoints,onKeyNameChange:s.setNewKeyName,onMaxConcurrencyChange:s.setNewKeyMaxConcurrency,onOpenChange:s.handleCreateDialogChange,onSubmit:()=>void s.handleCreateKey(),selectedEndpoints:s.newKeyEndpoints}),e.jsx(Ms,{createdKey:s.newlyCreatedKey,onClose:()=>s.setNewlyCreatedKey(null),onCopy:r=>void s.handleCopyKey(r)}),e.jsx(Ws,{apiKey:s.editEndpointsKey,availableEndpoints:s.availableEndpoints,maxConcurrency:s.editMaxConcurrency,onClose:()=>s.setEditEndpointsKey(null),onEndpointsChange:s.setEditEndpointsSelection,onMaxConcurrencyChange:s.setEditMaxConcurrency,onSave:()=>void s.handleSaveEndpoints(),selectedEndpoints:s.editEndpointsSelection}),e.jsx(zs,{deleteTarget:s.deleteTarget,isDeleting:s.isDeleting,onConfirm:()=>void s.handleDeleteKey(),onOpenChange:r=>{!r&&s.isDeleting===null&&s.setDeleteTarget(null)}})]})}export{xa as default};
|
|
1
|
+
import{r as o,j as e,$ as xs,ak as te,U as Ce,aP as B,aQ as ie,as as us,aR as ve,aS as ms,aT as Ee,aA as De,ay as hs}from"./vendor-CITafuNQ.js";import{a as ae,P as gs}from"./PageState-CFLrRswm.js";import{P as ys}from"./PageToolbar-CWw40AFL.js";import{B as u,a as js,b as L,c as Y,s as O,q as N}from"./app-vWIA9Pq_.js";import{T as bs,a as vs,b as fe,c as Ke}from"./tabs-UWyz9J_W.js";import{C as fs}from"./ConfirmDialog-CgKijCNt.js";import{D as ne,A as le,a as re,b as ce,c as Te,d as oe,e as de}from"./DialogShell-CM92wXHo.js";import{L as P,I as U}from"./label-DSVzZIex.js";import{c as ke}from"./global-BCehxTGJ.js";import{E as Ae,R as Me,u as Ks}from"./shared-D9r3kFnp.js";import{u as w}from"./i18n-PeX9kBVO.js";import{L as Ns}from"./router-BoBrmro7.js";import{T as ws,a as Cs,b as Ne,c as W,d as Es,e as z,E as Ds}from"./table-CVuTTP1s.js";import{P as We}from"./PageSection-N34Nu8NO.js";import{B as A}from"./badge-DpUlf_NW.js";import{C as S,a as ze}from"./card-D4YOc5eB.js";import{M as Z}from"./metric-card-G1bbpbiR.js";import{S as qe}from"./segmented-control-13KTib6k.js";import{e as Ts}from"./charts-core-BTTtAoo-.js";import{u as H}from"./useAppMutation-DJ2QsEsU.js";import{a as q}from"./apiKeys-DngGSX7O.js";import{c as ks}from"./clipboard-BnAnBk_-.js";import"./query-DZF7K6hv.js";import"./radix-Bux_1C5J.js";import"./charts-react-BQP6-BFp.js";import"./charts-engine-CFhx8nba.js";const Fe=o.forwardRef(({className:a,...s},p)=>e.jsx("textarea",{className:ke("flex min-h-[80px] w-full rounded-xl border border-border bg-card px-3 py-2.5 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:p,...s}));Fe.displayName="Textarea";function As({availableEndpoints:a,isOpen:s,keyDescription:p,keyName:i,maxConcurrency:r,onDescriptionChange:m,onEndpointsChange:y,onKeyNameChange:v,onMaxConcurrencyChange:x,onOpenChange:d,onSubmit:g,selectedEndpoints:n}){const{t:l}=w();return e.jsx(ne,{open:s,onOpenChange:d,children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:l("apiKeys.createNew")}),e.jsx(Te,{children:l("apiKeys.createDescription")})]}),e.jsxs(oe,{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:l("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-3 text-xs text-primary",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-lg border border-warning/30 bg-warning-bg px-3 py-3 text-xs text-warning",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-3 text-xs text-destructive",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(P,{htmlFor:"keyName",children:[l("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(U,{id:"keyName",value:i,onChange:h=>v(h.target.value),placeholder:l("apiKeys.keyNamePlaceholder"),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),g())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"keyDescription",children:l("apiKeys.descriptionLabel")}),e.jsx(Fe,{id:"keyDescription",value:p,onChange:h=>m(h.target.value),placeholder:l("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:l("apiKeys.allowedEndpoints")}),e.jsx(Ae,{available:a,selected:n,onChange:y,hint:l("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"maxConcurrency",children:l("apiKeys.maxConcurrency")}),e.jsx(U,{id:"maxConcurrency",type:"number",min:"0",value:r,onChange:h=>x(h.target.value),placeholder:l("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:()=>d(!1),children:l("common.actions.cancel")}),e.jsx(u,{onClick:g,children:l("apiKeys.createAction")})]})]})})}function Ms({createdKey:a,onClose:s,onCopy:p}){const{t:i}=w();return e.jsx(ne,{open:!!a,onOpenChange:r=>{r||s()},children:e.jsxs(le,{className:"max-w-xl",children:[e.jsx(re,{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-lg bg-success-bg text-success",children:e.jsx(xs,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(ce,{children:i("apiKeys.keyCreated")})]})}),e.jsxs(oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-warning",children:i("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:a==null?void 0:a.key}),a!=null&&a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null]}),e.jsxs(de,{children:[e.jsxs(u,{onClick:()=>p((a==null?void 0:a.key)??""),children:[e.jsx(te,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),i("common.actions.copy")]}),e.jsx(u,{variant:"outline",onClick:s,children:i("common.actions.close")})]})]})})}function Ws({apiKey:a,availableEndpoints:s,maxConcurrency:p,onClose:i,onEndpointsChange:r,onMaxConcurrencyChange:m,onSave:y,selectedEndpoints:v}){const{t:x}=w();return e.jsx(ne,{open:!!a,onOpenChange:d=>{d||i()},children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:x("apiKeys.editEndpoints")}),e.jsx(Te,{children:a==null?void 0:a.name})]}),e.jsxs(oe,{className:"space-y-4",children:[!(a!=null&&a.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-warning/30 bg-warning-bg px-4 py-3 text-xs text-warning",children:x("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(Ae,{available:s,selected:v,onChange:r,hint:x("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"editMaxConcurrency",children:x("apiKeys.maxConcurrency")}),e.jsx(U,{id:"editMaxConcurrency",type:"number",min:"0",value:p,onChange:d=>m(d.target.value),placeholder:x("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:i,children:x("common.actions.cancel")}),e.jsx(u,{onClick:y,children:x("common.save")})]})]})})}function zs({deleteTarget:a,isDeleting:s,onConfirm:p,onOpenChange:i}){const{t:r}=w();return e.jsx(fs,{open:!!a,onOpenChange:i,title:r("apiKeys.deleteDialogTitle"),description:r("apiKeys.confirmDelete"),confirmLabel:a&&s===a.id?r("common.actions.loading"):r("apiKeys.actions.delete"),cancelLabel:r("common.actions.cancel"),loading:a?s===a.id:!1,onConfirm:p,children:a?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:a.name}):null})}function qs({onDismiss:a}){const{t:s}=w();return e.jsxs(S,{className:"relative p-3 sm:p-3.5",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"max-w-md space-y-1 pr-8",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary/75",children:"Recommended"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s("apiKeys.quickStart.title")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("apiKeys.quickStart.description")})]}),e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1 lg:mx-0 lg:overflow-visible lg:pb-0",children:e.jsxs("div",{className:"flex gap-2 px-1 md:grid md:grid-cols-3 md:px-0 lg:max-w-3xl",children:[e.jsx(ee,{icon:e.jsx(Ce,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(ee,{icon:e.jsx(B,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.restrict.title"),description:s("apiKeys.quickStart.restrict.description")}),e.jsx(ee,{icon:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})]}),a?e.jsx(u,{variant:"ghost",size:"icon",className:"absolute right-1.5 top-1.5 h-7 w-7 text-muted-foreground hover:bg-secondary hover:text-foreground",onClick:a,"aria-label":s("common.actions.close"),children:e.jsx(us,{className:"h-4 w-4","aria-hidden":"true"})}):null]})}function Fs({activeKeysValue:a,enabledKeysValue:s,loading:p,onRangeChange:i,rangeDays:r,requestsChartOption:m,totalKeysValue:y,tokensChartOption:v,usageLength:x}){const{t:d}=w();return e.jsx(We,{title:d("apiKeys.analytics.title"),description:d("apiKeys.analytics.description",{days:r}),actions:e.jsx(qe,{className:"w-full overflow-x-auto sm:w-auto",value:r,onChange:i,options:Me.map(g=>({value:g.value,label:d(g.labelKey)}))}),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(Z,{label:d("apiKeys.analytics.cards.total"),value:y,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.enabled"),value:s,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.active",{days:r}),value:a,size:"sm"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(we,{title:d("apiKeys.analytics.charts.requests"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:m}),e.jsx(we,{title:d("apiKeys.analytics.charts.tokens"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:v})]})]})})}function Ls({filteredKeys:a,formatDate:s,hasWildcard:p,isDeleting:i,isRevealing:r,keys:m,onCopy:y,onDelete:v,onEditEndpoints:x,onFilterChange:d,onHide:g,onReveal:n,onStatusFilterChange:l,onToggleEnabled:h,revealedKeys:E,search:C,statusFilter:K,viewMode:T,onViewModeChange:j,onCreateKey:$}){const{t:b}=w();return e.jsx(We,{title:b("apiKeys.list.title"),description:p?b("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[e.jsx(qe,{value:T,onChange:j,options:[{value:"cards",label:b("apiKeys.views.cards"),icon:e.jsx(ve,{className:"h-3.5 w-3.5","aria-hidden":"true"})},{value:"compact",label:b("apiKeys.views.compact"),icon:e.jsx(ms,{className:"h-3.5 w-3.5","aria-hidden":"true"})}]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx(A,{variant:"outline",children:`${a.length}/${m.length}`})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary p-4 sm:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(U,{value:C,onChange:f=>d(f.target.value),placeholder:b("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex min-w-max items-center gap-1 overflow-x-auto rounded-full bg-background p-1 sm:justify-self-end",children:["all","enabled","disabled"].map(f=>e.jsx("button",{type:"button",onClick:()=>l(f),className:ke("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",K===f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:b(`apiKeys.filters.${f}`)},f))})]}),m.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(Ce,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyTitle"),description:b("apiKeys.list.empty"),action:e.jsx(u,{size:"sm",onClick:$,children:b("apiKeys.createNew")})}):a.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(ve,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyFilteredTitle"),description:b("apiKeys.list.emptyFiltered"),action:e.jsx(u,{variant:"outline",size:"sm",onClick:()=>{d(""),l("all")},children:b("common.actions.reset")})}):T==="compact"?e.jsx(Os,{filteredKeys:a,formatDate:s,isDeleting:i,isRevealing:r,onCopy:y,onDelete:v,onEditEndpoints:x,onHide:g,onReveal:n,onToggleEnabled:h,revealedKeys:E}):e.jsx("div",{className:"grid gap-4",children:a.map(f=>e.jsx(Rs,{formatDate:s,isDeleting:i===f.id,isRevealing:r===f.id,keySummary:f,onCopy:y,onDelete:v,onEditEndpoints:x,onHide:g,onReveal:n,onToggleEnabled:h,revealedValue:E.get(f.id)},f.id))})]})})}function Os({filteredKeys:a,formatDate:s,isDeleting:p,isRevealing:i,onCopy:r,onDelete:m,onEditEndpoints:y,onHide:v,onReveal:x,onToggleEnabled:d,revealedKeys:g}){const{t:n}=w();return e.jsx(S,{className:"overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ws,{className:"min-w-[980px]",children:[e.jsx(Cs,{children:e.jsxs(Ne,{className:"bg-secondary/45 hover:bg-secondary/45",children:[e.jsx(W,{children:n("apiKeys.table.name")}),e.jsx(W,{children:n("apiKeys.table.access")}),e.jsx(W,{className:"text-right",children:n("apiKeys.requestCount")}),e.jsx(W,{className:"text-right",children:n("apiKeys.totalTokens")}),e.jsx(W,{className:"text-right",children:n("apiKeys.maxConcurrency")}),e.jsx(W,{children:n("apiKeys.lastUsed")}),e.jsx(W,{className:"w-[132px] text-right",children:n("apiKeys.table.actions")})]})}),e.jsx(Es,{children:a.map(l=>{var K,T,j;const h=g.get(l.id),E=(l.totalInputTokens+l.totalOutputTokens).toLocaleString(),C=l.isWildcard?n("apiKeys.wildcard"):(((K=l.allowedEndpoints)==null?void 0:K.length)??0)>0?(T=l.allowedEndpoints)==null?void 0:T.join(", "):n("apiKeys.allEndpoints");return e.jsxs(Ne,{children:[e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:l.name}),l.isWildcard?e.jsx(A,{variant:"secondary",className:"text-[11px]",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:l.enabled?"default":"outline",className:"text-[11px]",children:l.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")})]}),l.isWildcard?null:e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"max-w-[220px] truncate rounded-md bg-secondary px-2 py-1 font-mono text-xs",children:h??l.maskedKey??"********"}),h?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>r(h),"aria-label":n("common.actions.copy"),children:e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(l.id),"aria-label":n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x(l.id),disabled:i===l.id,"aria-label":n("apiKeys.actions.reveal"),children:i===l.id?e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}),e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"max-w-[180px]",children:[e.jsx("div",{className:"truncate text-sm text-foreground",title:C,children:C}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.isWildcard?n("apiKeys.table.accessWildcard"):(((j=l.allowedEndpoints)==null?void 0:j.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.table.accessOpen")})]})}),e.jsx(z,{className:"py-3 text-right font-medium",children:l.requestCount.toLocaleString()}),e.jsx(z,{className:"py-3 text-right font-medium",children:E}),e.jsx(z,{className:"py-3 text-right font-medium",children:l.maxConcurrency?String(l.maxConcurrency):"—"}),e.jsxs(z,{className:"py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s(l.lastUsedAt)}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s(l.createdAt)})]}),e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(u,{variant:"outline",size:"icon",onClick:()=>y(l),className:"h-8 w-8","aria-label":l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),title:l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),children:e.jsx(B,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:l.enabled?"outline":"default",size:"sm",onClick:()=>d(l.id,l.enabled),className:"h-8 px-2.5 text-xs",children:l.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),l.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>m(l),disabled:p===l.id,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})})]},l.id)})})]})})})}function ee({description:a,icon:s,title:p}){return e.jsxs("div",{className:"w-[220px] shrink-0 rounded-xl border border-border bg-secondary p-3 md:w-auto",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-background text-primary sm:h-8 sm:w-8 sm:rounded-lg",children:s}),e.jsx("p",{className:"mt-2 text-[12px] font-semibold leading-5 text-foreground sm:mt-2.5 sm:text-[13px]",children:p}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground sm:text-xs sm:leading-5",children:a})]})}function Rs({formatDate:a,isDeleting:s,isRevealing:p,keySummary:i,onCopy:r,onDelete:m,onEditEndpoints:y,onHide:v,onReveal:x,onToggleEnabled:d,revealedValue:g}){var h,E,C;const{t:n}=w(),l=(i.totalInputTokens+i.totalOutputTokens).toLocaleString();return e.jsx(S,{"data-testid":"api-key-card",className:"overflow-hidden",children:e.jsx(ze,{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:i.name}),i.isWildcard?e.jsx(A,{variant:"secondary",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:i.enabled?"default":"outline",children:i.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")}),i.isWildcard?null:e.jsx(A,{variant:"outline",className:"text-xs",children:(((h=i.allowedEndpoints)==null?void 0:h.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.allEndpoints")}),!i.isWildcard&&i.allowedEndpoints&&i.allowedEndpoints.length>0?i.allowedEndpoints.map(K=>e.jsx(A,{variant:"outline",className:"text-xs",children:K},K)):i.isWildcard?null:e.jsx(A,{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(se,{label:n("apiKeys.requestCount"),value:i.requestCount.toLocaleString()}),e.jsx(se,{label:n("apiKeys.totalTokens"),value:l}),e.jsx(se,{label:n("apiKeys.maxConcurrency"),value:i.maxConcurrency?String(i.maxConcurrency):n("apiKeys.maxConcurrencyPlaceholder")})]}),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 bg-secondary px-3 py-1.5 font-mono text-sm",children:i.isWildcard?n("apiKeys.wildcard"):g??i.maskedKey??"********"}),i.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:g?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r(g),"aria-label":n("common.actions.copy"),title:n("common.actions.copy"),children:e.jsx(te,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>v(i.id),"aria-label":n("apiKeys.actions.hide"),title:n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(i.id),disabled:p,"aria-label":n("apiKeys.actions.reveal"),title:n("apiKeys.actions.reveal"),children:p?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-4 w-4","aria-hidden":"true"})})})]}),i.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("apiKeys.wildcardHint")}):i.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:i.description}):null,i.isWildcard?null:e.jsx("div",{className:"rounded-lg bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((E=i.allowedEndpoints)==null?void 0:E.length)??0)>0?`${n("apiKeys.allowedEndpoints")}: ${(C=i.allowedEndpoints)==null?void 0:C.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:a(i.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:a(i.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>y(i),className:"w-full lg:w-auto",children:[e.jsx(B,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),i.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints")]}),e.jsx(u,{variant:i.enabled?"outline":"default",size:"sm",onClick:()=>d(i.id,i.enabled),className:"w-full lg:w-auto",children:i.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),i.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>m(i),disabled:s,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function se({label:a,value:s}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:s})]})}function we({empty:a,emptyText:s,loading:p,option:i,title:r}){const{t:m}=w();return e.jsx(S,{children:e.jsxs(ze,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:r}),p?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:m("common.loadingShort")})}):a?e.jsx(ae,{compact:!0,className:"min-h-[280px] rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(B,{className:"h-5 w-5","aria-hidden":"true"}),title:s,description:m("apiKeys.analytics.emptyHint"),action:e.jsx(u,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(Ns,{to:"/logs",children:m("apiKeys.analytics.actions.logs")})})}):e.jsx(Ds,{echarts:Ts,option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function Ps(){const{t:a}=w(),{pushToast:s}=js(),[p,i]=o.useState(!1),[r,m]=o.useState(""),[y,v]=o.useState(""),[x,d]=o.useState([]),[g,n]=o.useState(""),[l,h]=o.useState(null),[E,C]=o.useState(null),[K,T]=o.useState(null),[j,$]=L(O.apiKeys.rangeDays,7,{serialize:t=>String(t),deserialize:t=>{const c=Number(t);return Me.some(D=>D.value===c)?c:7}}),[b,f]=o.useState(new Map),[Le,pe]=o.useState(null),[R,G]=o.useState(null),[I,xe]=o.useState([]),[_,ue]=o.useState(""),[X,Oe]=L(O.apiKeys.search,""),[V,Re]=L(O.apiKeys.statusFilter,"all",{serialize:t=>t,deserialize:t=>t==="enabled"||t==="disabled"?t:"all"}),[Pe,Ie]=L(O.apiKeys.viewMode,"compact",{serialize:t=>t,deserialize:t=>t==="cards"?"cards":"compact"}),[Ve,Qe]=L(O.apiKeys.activeTab,"inventory",{serialize:t=>t,deserialize:t=>t==="analytics"?"analytics":"inventory"}),[He,Ue]=L(O.apiKeys.quickStartDismissed,!1),Be=Ks(),me=Y(N.apiKeys.all(),q.listRequest()),Se=Y(N.apiKeys.overview(j),q.overviewRequest(j)),he=Y(N.apiKeys.usage(j),q.usageRequest(j)),ge=H({mutationFn:q.create,invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyCreated")}),errorToast:t=>({title:a("apiKeys.toast.createFailure",{message:t.message})})}),Q=H({mutationFn:({id:t,...c})=>q.update(t,c),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyUpdated")}),errorToast:t=>({title:a("apiKeys.toast.updateFailure",{message:t.message})})}),ye=H({mutationFn:({id:t})=>q.delete(t),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyDeleted")}),errorToast:t=>({title:a("apiKeys.toast.deleteFailure",{message:t.message})})}),je=H({mutationFn:({id:t})=>q.reveal(t),errorToast:t=>({title:a("apiKeys.toast.revealFailure"),description:t.message})}),M=me.data??[],F=Se.data,k=he.data??[],$e=M.some(t=>t.isWildcard),Ge=M.filter(t=>t.isWildcard).length,_e=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)>0}).length,Xe=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)===0}).length,Je=F?F.totalKeys.toLocaleString():"-",Ye=F?F.enabledKeys.toLocaleString():"-",Ze=F?F.activeKeys.toLocaleString():"-",es=o.useMemo(()=>M.filter(t=>{if(!(V==="all"||(V==="enabled"?t.enabled:!t.enabled)))return!1;const D=X.trim().toLowerCase();return D?[t.name,t.description??"",t.maskedKey??"",...t.allowedEndpoints??[]].join(" ").toLowerCase().includes(D):!0}),[M,X,V]),ss=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:k.map(c=>c.requests),itemStyle:{color:"var(--primary)"}}]}},[a,k]),as=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:k.map(c=>c.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:k.map(c=>c.outputTokens)}]}},[a,k]),be=o.useCallback(()=>{m(""),v(""),d([]),n("")},[]),J=o.useCallback(t=>{i(t),t||be()},[be]),ts=o.useCallback(async()=>{if(!r.trim()){s({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}const t=g.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<1)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{const c=await ge.mutateAsync({name:r.trim(),description:y.trim()||void 0,allowedEndpoints:x.length>0?x:void 0,maxConcurrency:t?Number(t):null});h(c),J(!1)}catch{}},[ge,J,y,x,g,r,s,a]),is=o.useCallback(async(t,c)=>{try{await Q.mutateAsync({id:t,enabled:!c})}catch{}},[Q]),ns=o.useCallback(async()=>{if(K){C(K.id);try{await ye.mutateAsync({id:K.id}),T(null)}catch{}finally{C(null)}}},[K,ye]),ls=o.useCallback(async t=>{if(!b.has(t)){pe(t);try{const c=await je.mutateAsync({id:t});f(D=>new Map(D).set(t,c.key))}catch{}finally{pe(null)}}},[je,b]),rs=o.useCallback(t=>{f(c=>{const D=new Map(c);return D.delete(t),D})},[]),cs=o.useCallback(async t=>{try{await ks(t),s({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(c){s({title:a("apiKeys.toast.copyFailure"),description:c instanceof Error?c.message:a("common.unknownError"),variant:"error"})}},[s,a]),os=o.useCallback(t=>{G(t),xe(t.allowedEndpoints??[]),ue(t.maxConcurrency?String(t.maxConcurrency):"")},[]),ds=o.useCallback(async()=>{if(!R)return;const t=_.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<1)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{await Q.mutateAsync({id:R.id,...R.isWildcard?{}:{allowedEndpoints:I.length>0?I:null},maxConcurrency:t?Number(t):null}),G(null)}catch{}},[R,I,_,s,a,Q]),ps=o.useCallback(t=>t?new Date(t).toLocaleString():a("common.noData"),[a]);return{activeKeysValue:Ze,activeTab:Ve,availableEndpoints:Be,deleteTarget:K,editEndpointsKey:R,editEndpointsSelection:I,editMaxConcurrency:_,enabledKeysValue:Ye,filteredKeys:es,formatDate:ps,handleCopyKey:cs,handleCreateDialogChange:J,handleCreateKey:ts,handleDeleteKey:ns,handleHideKey:rs,handleOpenEditEndpoints:os,handleRevealKey:ls,handleSaveEndpoints:ds,handleToggleEnabled:is,hasWildcard:$e,isCreateDialogOpen:p,isDeleting:E,isRevealing:Le,keys:M,keysQuery:me,newKeyDescription:y,newKeyEndpoints:x,newKeyMaxConcurrency:g,newKeyName:r,newlyCreatedKey:l,quickStartDismissed:He,rangeDays:j,requestsChartOption:ss,restrictedCount:_e,revealedKeys:b,search:X,setQuickStartDismissed:Ue,setActiveTab:Qe,setDeleteTarget:T,setEditEndpointsKey:G,setEditEndpointsSelection:xe,setEditMaxConcurrency:ue,setNewKeyDescription:v,setNewKeyEndpoints:d,setNewKeyMaxConcurrency:n,setNewKeyName:m,setNewlyCreatedKey:h,setRangeDays:$,setSearch:Oe,setStatusFilter:Re,statusFilter:V,tokensChartOption:as,totalKeysValue:Je,unrestrictedCount:Xe,usage:k,usageQuery:he,viewMode:Pe,wildcardCount:Ge,setViewMode:Ie}}function xa(){const{t:a}=w(),s=Ps();if(s.keysQuery.isLoading)return e.jsx(gs,{label:a("common.loading")});const i=s.keys.filter(r=>!r.isWildcard).length===0&&!s.quickStartDismissed;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ys,{status:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a("apiKeys.summary.wildcard",{count:s.wildcardCount})," / ",a("apiKeys.summary.restricted",{count:s.restrictedCount})," / ",a("apiKeys.summary.unrestricted",{count:s.unrestrictedCount})]}),actions:e.jsxs(u,{size:"sm",onClick:()=>s.handleCreateDialogChange(!0),children:[e.jsx(hs,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),i?e.jsx(qs,{onDismiss:()=>s.setQuickStartDismissed(!0)}):null,e.jsxs(bs,{value:s.activeTab,onValueChange:r=>s.setActiveTab(r),children:[e.jsxs(vs,{children:[e.jsx(fe,{value:"inventory",children:a("apiKeys.tabs.inventory")}),e.jsx(fe,{value:"analytics",children:a("apiKeys.tabs.analytics")})]}),e.jsx(Ke,{value:"inventory",className:"mt-4",children:e.jsx(Ls,{filteredKeys:s.filteredKeys,formatDate:s.formatDate,hasWildcard:s.hasWildcard,isDeleting:s.isDeleting,isRevealing:s.isRevealing,keys:s.keys,onCopy:r=>void s.handleCopyKey(r),onDelete:s.setDeleteTarget,onEditEndpoints:s.handleOpenEditEndpoints,onFilterChange:s.setSearch,onHide:s.handleHideKey,onReveal:r=>void s.handleRevealKey(r),onStatusFilterChange:s.setStatusFilter,onToggleEnabled:(r,m)=>void s.handleToggleEnabled(r,m),revealedKeys:s.revealedKeys,search:s.search,statusFilter:s.statusFilter,viewMode:s.viewMode,onViewModeChange:s.setViewMode,onCreateKey:()=>s.handleCreateDialogChange(!0)})}),e.jsx(Ke,{value:"analytics",className:"mt-4",children:e.jsx(Fs,{activeKeysValue:s.activeKeysValue,enabledKeysValue:s.enabledKeysValue,loading:s.usageQuery.isLoading,onRangeChange:s.setRangeDays,rangeDays:s.rangeDays,requestsChartOption:s.requestsChartOption,totalKeysValue:s.totalKeysValue,tokensChartOption:s.tokensChartOption,usageLength:s.usage.length})})]}),e.jsx(As,{availableEndpoints:s.availableEndpoints,isOpen:s.isCreateDialogOpen,keyDescription:s.newKeyDescription,keyName:s.newKeyName,maxConcurrency:s.newKeyMaxConcurrency,onDescriptionChange:s.setNewKeyDescription,onEndpointsChange:s.setNewKeyEndpoints,onKeyNameChange:s.setNewKeyName,onMaxConcurrencyChange:s.setNewKeyMaxConcurrency,onOpenChange:s.handleCreateDialogChange,onSubmit:()=>void s.handleCreateKey(),selectedEndpoints:s.newKeyEndpoints}),e.jsx(Ms,{createdKey:s.newlyCreatedKey,onClose:()=>s.setNewlyCreatedKey(null),onCopy:r=>void s.handleCopyKey(r)}),e.jsx(Ws,{apiKey:s.editEndpointsKey,availableEndpoints:s.availableEndpoints,maxConcurrency:s.editMaxConcurrency,onClose:()=>s.setEditEndpointsKey(null),onEndpointsChange:s.setEditEndpointsSelection,onMaxConcurrencyChange:s.setEditMaxConcurrency,onSave:()=>void s.handleSaveEndpoints(),selectedEndpoints:s.editEndpointsSelection}),e.jsx(zs,{deleteTarget:s.deleteTarget,isDeleting:s.isDeleting,onConfirm:()=>void s.handleDeleteKey(),onOpenChange:r=>{!r&&s.isDeleting===null&&s.setDeleteTarget(null)}})]})}export{xa as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-CITafuNQ.js";import{D as m,A as p,a as j,b as u,c as D,d as f,e as g}from"./DialogShell-CM92wXHo.js";import{B as o}from"./app-
|
|
1
|
+
import{j as s}from"./vendor-CITafuNQ.js";import{D as m,A as p,a as j,b as u,c as D,d as f,e as g}from"./DialogShell-CM92wXHo.js";import{B as o}from"./app-vWIA9Pq_.js";function C({open:r,onOpenChange:a,title:t,description:i,confirmLabel:n,cancelLabel:d,onConfirm:c,loading:e=!1,confirmVariant:x="destructive",children:l}){return s.jsx(m,{open:r,onOpenChange:a,children:s.jsxs(p,{className:"max-w-md",children:[s.jsxs(j,{children:[s.jsx(u,{children:t}),i?s.jsx(D,{children:i}):null]}),s.jsx(f,{className:"space-y-4",children:l?s.jsx("div",{className:"text-sm text-muted-foreground",children:l}):null}),s.jsxs(g,{children:[s.jsx(o,{variant:"outline",onClick:()=>a(!1),disabled:e,children:d}),s.jsx(o,{variant:x,onClick:()=>void c(),disabled:e,children:n})]})]})})}export{C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,an as Se,ao as we,ap as ae,ac as Ce,O as H,r as b,aq as Le,T as Re}from"./vendor-CITafuNQ.js";import{P as Ie}from"./PageToolbar-CWw40AFL.js";import{P as _,a as M}from"./PageState-CFLrRswm.js";import{B as R,u as Me,a as qe,b as Ee,c as E,q as P,s as Pe}from"./app-vWIA9Pq_.js";import{S as ke,a as Ae,b as De,c as Oe,d as k}from"./select-sOwKYsgI.js";import{c as ze}from"./global-BCehxTGJ.js";import{L as I}from"./router-BoBrmro7.js";import{T as re,a as oe,b as D,c as T,d as ne,e as S,E as ie}from"./table-CVuTTP1s.js";import{P as $}from"./PageSection-N34Nu8NO.js";import{S as Fe,C as Be,T as Ve,g as ee}from"./utils-B_Q3Hhgb.js";import{B as L}from"./badge-DpUlf_NW.js";import{C as le,a as de}from"./card-D4YOc5eB.js";import{D as ce}from"./disclosure-l5qsWhr7.js";import{M as g}from"./metric-card-G1bbpbiR.js";import{f as He,a as te,b as A,L as _e,T as $e,c as se}from"./types-DYz12j32.js";import{u as x}from"./i18n-PeX9kBVO.js";import{e as ue}from"./charts-core-BTTtAoo-.js";import{u as Ke}from"./useEventStream-BYg6oKvQ.js";import{a as Qe}from"./apiKeys-DngGSX7O.js";import{g as Ge}from"./gateway-B7Y2AqSU.js";import"./query-DZF7K6hv.js";import"./radix-Bux_1C5J.js";import"./charts-react-BQP6-BFp.js";import"./charts-engine-CFhx8nba.js";function Ue(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:Array.from({length:4}).map((s,a)=>e.jsx(Fe,{},a))}),e.jsx(Be,{}),e.jsx("div",{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((s,a)=>e.jsx(Ve,{columns:6},a))})})})]})}function We({status:s}){const{t:a}=x();return e.jsxs("div",{className:"space-y-3","data-testid":"dashboard-spotlight-grid",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm","data-testid":"dashboard-overview-panel",children:[e.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-success-bg px-1.5 py-0.5 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse",children:a("dashboard.status.listeningLabel")}),e.jsxs("span",{"data-testid":"dashboard-runtime-address",className:"metric-number text-sm font-semibold tracking-tight text-foreground",children:[(s==null?void 0:s.host)??"0.0.0.0",":",(s==null?void 0:s.port)??"-"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a("dashboard.status.providers",{value:(s==null?void 0:s.providers)??0})})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(g,{size:"md",label:a("dashboard.labels.activeRequests"),value:((s==null?void 0:s.activeRequests)??0).toLocaleString(),rawValue:(s==null?void 0:s.activeRequests)??0,valueTestId:"dashboard-spotlight-value-active"}),e.jsx(g,{size:"md",label:a("dashboard.labels.requestsPerMinute"),value:((s==null?void 0:s.requestsPerMinute)??0).toLocaleString(),rawValue:(s==null?void 0:s.requestsPerMinute)??0,valueTestId:"dashboard-spotlight-value-rpm"}),e.jsx(g,{size:"md",label:a("dashboard.labels.uniqueClientAddressesLastHour"),value:((s==null?void 0:s.uniqueClientAddressesLastHour)??0).toLocaleString(),rawValue:(s==null?void 0:s.uniqueClientAddressesLastHour)??0}),e.jsx(g,{size:"md",label:a("dashboard.labels.cpu"),value:He(s==null?void 0:s.cpuUsagePercent),valueTestId:"dashboard-spotlight-value-cpu"})]})]})}function Ye(s){switch(s){case"error":return e.jsx(L,{variant:"destructive",children:"error"});case"warn":return e.jsx(L,{variant:"warning",children:"warn"});default:return e.jsx(L,{variant:"secondary",children:"info"})}}function Je({overview:s}){const{t:a}=x(),t=s==null?void 0:s.today,r=s==null?void 0:s.yesterday,o=(t==null?void 0:t.requests)??0,n=(t==null?void 0:t.inputTokens)??0,l=(t==null?void 0:t.outputTokens)??0,i=(t==null?void 0:t.cacheReadTokens)??0,d=(t==null?void 0:t.errorCount)??0,h=o>0?d/o*100:0,O=r&&(r.requests??0)>0?r.errorCount/r.requests*100:void 0,c=i+n,z=c>0?i/c*100:0,w=(v,y)=>y!==void 0&&y>0?((v??0)-y)/y*100:void 0,f=v=>`${v>0?"+":""}${v.toFixed(1)}%`,C=(v,y=!1)=>v!==void 0&&Math.abs(v)>=.05?{value:v,invertColor:y,format:f}:void 0,F=o>0?w(h,O):void 0;return e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-5","data-testid":"dashboard-today-grid",children:[e.jsx(g,{size:"md",label:a("dashboard.cards.todayRequests"),value:o.toLocaleString(),rawValue:o,delta:C(w(o,r==null?void 0:r.requests)),hint:r&&r.requests>0?a("dashboard.cards.yesterdayHint",{value:r.requests.toLocaleString()}):void 0,valueTestId:"dashboard-today-value-requests"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayInput"),value:n.toLocaleString(),rawValue:n,suffix:a("common.units.token"),delta:C(w(n,r==null?void 0:r.inputTokens)),valueTestId:"dashboard-today-value-input"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayOutput"),value:l.toLocaleString(),rawValue:l,suffix:a("common.units.token"),delta:C(w(l,r==null?void 0:r.outputTokens)),valueTestId:"dashboard-today-value-output"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayCacheRead"),value:i.toLocaleString(),rawValue:i,suffix:a("common.units.token"),hint:c>0?a("dashboard.cards.cacheHitHint",{value:z.toFixed(1)}):void 0,valueTestId:"dashboard-today-value-cache-read"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayErrorRate"),value:h>0?e.jsxs("span",{className:"text-destructive",children:[h.toFixed(1),"%"]}):`${h.toFixed(1)}%`,delta:C(F,!0),hint:d>0?a("dashboard.cards.errorCountHint",{value:d}):void 0,valueTestId:"dashboard-today-value-error-rate"})]})}function Xe({connected:s,failed:a,events:t}){const{t:r}=x();return t.length===0?null:e.jsx($,{title:r("dashboard.attention.title"),description:r("dashboard.attention.subtitle"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:a?"inline-flex items-center gap-1 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":s?"inline-flex items-center gap-1 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse":"inline-flex items-center gap-1 text-[11px] font-medium text-warning before:h-1.5 before:w-1.5 before:rounded-full before:bg-warning",children:r(a?"dashboard.attention.failed":s?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(R,{asChild:!0,variant:"ghost",size:"sm",className:"h-7",children:e.jsx(I,{to:"/events",children:r("dashboard.attention.viewAll")})})]}),children:e.jsx("ul",{className:"divide-y divide-border",children:e.jsx(we,{initial:!1,children:t.map(o=>e.jsxs(ae.li,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.18},className:"flex items-start gap-3 py-2.5 first:pt-0 last:pb-0",children:[e.jsx("div",{className:"pt-0.5",children:Ye(o.level)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title??o.type}),o.message?e.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:o.message}):null]}),e.jsx("span",{className:"shrink-0 pt-0.5 text-[11px] tabular-nums text-muted-foreground/70",children:new Date(o.createdAt).toLocaleTimeString()})]},o.id))})})})}function Ze({connected:s,failed:a}){const{t}=x();return e.jsxs(ae.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.18},"data-testid":"dashboard-all-clear",className:"flex h-8 flex-wrap items-center gap-x-2 gap-y-1 rounded-full bg-success-bg px-3 text-xs text-success",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium",children:t("dashboard.attention.allClear")}),e.jsx("span",{className:a?"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":s?"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse":"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium text-warning before:h-1.5 before:w-1.5 before:rounded-full before:bg-warning",children:t(a?"dashboard.attention.failed":s?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(I,{to:"/events",className:"shrink-0 underline-offset-2 hover:underline",children:t("dashboard.attention.viewAll")})]})}function et({empty:s,loading:a,option:t}){const{t:r}=x();return e.jsx(lt,{title:r("dashboard.charts.trendTitle"),description:r("dashboard.charts.trendDesc"),loading:a,option:t,empty:s,emptyText:r("dashboard.charts.empty")})}function tt({daily:s,models:a}){const{t}=x();if(s.length===0&&a.length===0)return null;const r=s.reduce((d,h)=>d+h.requestCount,0),o=s.length>0?s.reduce((d,h)=>h.requestCount>d.requestCount?h:d,s[0]):null,n=a.length>0?a.reduce((d,h)=>h.requests>d.requests?h:d,a[0]):null,l=a.filter(d=>d.avgTtftMs!=null&&d.avgTtftMs>0).sort((d,h)=>(d.avgTtftMs??Number.POSITIVE_INFINITY)-(h.avgTtftMs??Number.POSITIVE_INFINITY))[0],i=[{label:t("dashboard.insights.totalRequests"),value:r>0?r.toLocaleString():"—",hint:r>0?t("dashboard.insights.totalRequestsHint"):void 0},{label:t("dashboard.insights.busiestDay"),value:o?o.date.slice(5):"—",hint:o?t("dashboard.insights.busiestDayHint",{value:o.requestCount.toLocaleString()}):void 0},{label:t("dashboard.insights.topModel"),value:n?n.model:"—",hint:n?t("dashboard.insights.topModelHint",{value:n.requests.toLocaleString()}):void 0},{label:t("dashboard.insights.fastestTtft"),value:l?l.model:"—",hint:l?t("dashboard.insights.fastestTtftHint",{value:Math.round(l.avgTtftMs??0)}):void 0}];return e.jsx("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","data-testid":"dashboard-insights-grid",children:i.map(d=>e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-[0.06em] text-muted-foreground",children:d.label}),e.jsx("div",{className:"metric-number mt-2 truncate text-base font-bold tracking-tight text-foreground",children:d.value}),d.hint?e.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:d.hint}):null]},d.label))})}function st({modelRequestsOption:s,models:a,ttftOption:t,tpotOption:r}){const{t:o}=x();return e.jsxs(ce,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:o("dashboard.sections.performance")}),children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(V,{title:o("dashboard.charts.modelTitle"),option:s,empty:!a.length}),e.jsx(V,{title:o("dashboard.charts.ttftTitle"),option:t,empty:!a.some(n=>n.avgTtftMs!=null&&n.avgTtftMs>0)}),e.jsx(V,{title:o("dashboard.charts.tpotTitle"),option:r,empty:!a.some(n=>n.avgTpotMs!=null&&n.avgTpotMs>0)})]}),e.jsx("div",{className:"mt-4",children:e.jsx(nt,{models:a,embedded:!0})})]})}function at({dbInfo:s,dbSizeDisplay:a,memoryDisplay:t,status:r}){const{t:o}=x();return e.jsx(ce,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:o("dashboard.cards.systemResources")}),badge:e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[a," · ",t]}),children:e.jsxs("div",{className:"grid gap-2.5 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(g,{size:"sm",label:o("dashboard.labels.networkIngress"),value:te(r==null?void 0:r.networkIngressBytesPerSecond),valueTestId:"dashboard-spotlight-value-ingress"}),e.jsx(g,{size:"sm",label:o("dashboard.labels.networkEgress"),value:te(r==null?void 0:r.networkEgressBytesPerSecond),valueTestId:"dashboard-spotlight-value-egress"}),e.jsx(g,{size:"sm",label:o("dashboard.labels.database"),value:a,valueTestId:"dashboard-spotlight-value-database"}),e.jsx(g,{size:"sm",label:o("dashboard.labels.memory"),value:t,valueTestId:"dashboard-spotlight-value-memory"})]})})}function rt({doneCount:s,total:a}){const{t}=x(),r=Math.min(100,Math.round(s/a*100));return e.jsxs("div",{"data-testid":"dashboard-setup-progress",className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-full bg-secondary/60 px-4 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:t("dashboard.setupProgress.label",{done:s,total:a})}),e.jsx("div",{className:"h-1.5 min-w-24 flex-1 overflow-hidden rounded-full bg-border/60",children:e.jsx("div",{className:"h-1.5 rounded-full bg-primary transition-all",style:{width:`${r}%`}})}),e.jsx(I,{to:"/setup",className:"shrink-0 text-xs font-medium text-primary underline-offset-2 hover:underline",children:t("dashboard.setupProgress.cta")})]})}function ot({endpointCount:s,providerCount:a}){const{t}=x(),r=[{title:t("dashboard.guide.step1Title"),description:a>0?t("dashboard.guide.step1DescDone",{count:a}):t("dashboard.guide.step1Desc"),href:"/providers",cta:t("dashboard.guide.step1Cta")},{title:t("dashboard.guide.step2Title"),description:s>0?t("dashboard.guide.step2DescDone",{count:s}):t("dashboard.guide.step2Desc"),href:"/providers",cta:t("dashboard.guide.step2Cta")},{title:t("dashboard.guide.step3Title"),description:t("dashboard.guide.step3Desc"),href:"/api-keys",cta:t("dashboard.guide.step3Cta")}];return e.jsx(le,{className:"relative overflow-hidden",children:e.jsxs(de,{className:"space-y-5 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:t("dashboard.guide.title")}),e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t("dashboard.guide.subtitle")})]}),e.jsx(R,{asChild:!0,size:"sm",children:e.jsx(I,{to:"/setup",children:t("dashboard.guide.startWizard")})})]}),e.jsx("ol",{className:"grid gap-3 lg:grid-cols-3",children:r.map((o,n)=>e.jsxs("li",{className:"rounded-lg border border-border p-4",children:[e.jsx("span",{className:"metric-number text-xs font-semibold text-muted-foreground",children:String(n+1).padStart(2,"0")}),e.jsx("h4",{className:"mt-2 text-sm font-semibold text-foreground",children:o.title}),e.jsx("p",{className:"mt-1.5 text-xs leading-6 text-muted-foreground",children:o.description}),e.jsx(R,{asChild:!0,variant:"ghost",size:"sm",className:"mt-2 h-8 px-0 text-primary hover:bg-transparent hover:text-primary/80",children:e.jsx(I,{to:o.href,children:o.cta})})]},o.title))})]})})}function nt({models:s,loading:a,embedded:t}){const{t:r}=x(),o=a?e.jsx(_,{compact:!0,label:r("common.loadingShort")}):s.length===0?e.jsx(M,{compact:!0,icon:e.jsx(H,{className:"h-5 w-5","aria-hidden":"true"}),title:r("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(re,{children:[e.jsx(oe,{children:e.jsxs(D,{children:[e.jsx(T,{children:r("dashboard.modelTable.columns.model")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.requests")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.latency")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.ttft")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.tpot")})]})}),e.jsx(ne,{children:s.map(n=>e.jsxs(D,{children:[e.jsx(S,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:n.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.model})]})}),e.jsx(S,{className:"text-right font-medium",children:n.requests.toLocaleString()}),e.jsx(S,{className:"text-right",children:A(n.avgLatencyMs,r("common.units.ms"))}),e.jsx(S,{className:"text-right",children:A(n.avgTtftMs,r("common.units.ms"))}),e.jsx(S,{className:"text-right",children:A(n.avgTpotMs,r("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${n.provider}/${n.model}`))})]})});return t?o:e.jsx($,{title:r("dashboard.modelTable.title"),description:r("dashboard.modelTable.description"),children:o})}function it({records:s,loading:a}){const{t}=x(),r=s.map(i=>ee(i,t)),o=r.filter(i=>i.tone==="success").length,n=r.filter(i=>i.tone==="error").length,l=r.filter(i=>i.tone==="pending").length;return e.jsx($,{title:t("dashboard.recent.title"),description:t("dashboard.recent.subtitle",{count:5}),actions:s.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:s.length}),e.jsxs(L,{variant:"success",children:[t("common.status.success"),": ",o]}),e.jsxs(L,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[t("common.status.error"),": ",n]}),l>0?e.jsxs(L,{variant:"warning",children:[t("common.status.pending"),": ",l]}):null]}):null,children:a?e.jsx(_,{compact:!0,label:t("dashboard.recent.loading")}):s.length===0?e.jsx(M,{compact:!0,icon:e.jsx(Se,{className:"h-5 w-5","aria-hidden":"true"}),title:t("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(re,{children:[e.jsx(oe,{children:e.jsxs(D,{children:[e.jsx(T,{children:t("dashboard.recent.columns.time")}),e.jsx(T,{children:t("dashboard.recent.columns.endpoint")}),e.jsx(T,{children:t("dashboard.recent.columns.provider")}),e.jsx(T,{children:t("dashboard.recent.columns.route")}),e.jsx(T,{className:"text-right",children:t("dashboard.recent.columns.latency")}),e.jsx(T,{children:t("dashboard.recent.columns.status")})]})}),e.jsx(ne,{children:s.map(i=>{const d=ee(i,t);return e.jsxs(D,{children:[e.jsx(S,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(i.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",i.id]})]})}),e.jsx(S,{children:e.jsx(L,{variant:"outline",className:"text-[11px]",children:i.endpoint==="anthropic"?t("logs.endpointAnthropic"):i.endpoint==="openai"?t("logs.endpointOpenAI"):i.endpoint})}),e.jsx(S,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:i.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:i.stream?"stream":"sync"})]})}),e.jsx(S,{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:i.client_model??t("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"->"}),e.jsx("span",{className:"font-medium text-foreground",children:i.model})]}),i.error?e.jsx("span",{className:"truncate text-destructive",children:i.error}):null]})}),e.jsx(S,{className:"text-right font-medium",children:A(i.latency_ms,t("common.units.ms"))}),e.jsx(S,{children:e.jsx(L,{variant:d.variant,className:"min-w-14 justify-center",children:d.label})})]},i.id)})})]})})})}function V({empty:s,option:a,title:t}){const{t:r}=x();return e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:t}),s?e.jsx(M,{compact:!0,className:"min-h-[160px]",icon:e.jsx(H,{className:"h-4 w-4","aria-hidden":"true"}),title:r("dashboard.charts.empty")}):e.jsx(ie,{echarts:ue,option:a,className:"h-[220px]",notMerge:!0,lazyUpdate:!0})]})}function lt({description:s,empty:a,emptyText:t,loading:r,option:o,title:n}){const{t:l}=x();return e.jsx(le,{children:e.jsxs(de,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:n}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground/70",children:s})]}),r?e.jsx(_,{compact:!0,className:"min-h-[220px]",label:l("common.loadingShort")}):a?e.jsx(M,{compact:!0,className:"min-h-[188px] rounded-xl border border-dashed border-border/45 bg-muted",icon:e.jsx(H,{className:"h-5 w-5","aria-hidden":"true"}),title:t??l("dashboard.charts.empty"),description:s}):e.jsx("div",{className:"pt-2",children:e.jsx(ie,{echarts:ue,option:o,className:"h-[36vh] min-h-[260px] max-h-[400px]",notMerge:!0,lazyUpdate:!0})})]})})}function j(s,a){return typeof window>"u"?a:getComputedStyle(document.documentElement).getPropertyValue(s).trim()||a}function dt(){const{resolved:s}=Me();return b.useMemo(()=>{const a=j("--foreground","#201e1d"),t=j("--muted-foreground","#605d5d"),r=j("--border","#d7d3d3"),o=j("--card","#ffffff");return{palette:[j("--chart-1","#ec3013"),j("--chart-2","#ae1800"),j("--chart-3","#ff9783"),j("--chart-4","#444141"),j("--chart-5","#9b9797")],success:j("--success","#444141"),warning:j("--warning","#ae1800"),error:j("--error","#dd2b0f"),axis:t,splitLine:r,base:{textStyle:{color:t,fontSize:11},grid:{left:8,right:8,top:32,bottom:4,containLabel:!0},tooltip:{backgroundColor:o,borderColor:r,textStyle:{color:a,fontSize:12}},legend:{textStyle:{color:t,fontSize:11}}}}},[s])}const ct=4;function ut(s){var t;if(!s)return 0;let a=Object.keys(s.modelRoutes??{}).length;for(const r of Object.values(s.endpointRouting??{}))a+=Object.keys((r==null?void 0:r.modelRoutes)??{}).length;for(const r of s.customEndpoints??[])a+=Object.keys(((t=r.routing)==null?void 0:t.modelRoutes)??{}).length;return a}function ht(){var U,W,Y,J,X,Z;const{t:s}=x(),{pushToast:a}=qe(),t=dt(),[r,o]=Ee(Pe.dashboard.endpointFilter,"all"),n=r==="all"?void 0:r,l=E(P.dashboard.summary(r),{url:"/api/dashboard/summary",method:"GET",params:n?{endpoint:n}:void 0},{refetchInterval:_e}),i=E(P.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:$e}),d=Ke({level:"warn,error",maxEvents:20}),h=b.useRef(!1);b.useEffect(()=>{var m;const u=l.error!=null;u&&!h.current&&(h.current=!0,a({title:s("dashboard.toast.overviewError"),description:((m=l.error)==null?void 0:m.message)??"",variant:"error"})),u||(h.current=!1)},[l.error,a,s]);const O=b.useCallback(async()=>{await Promise.all([l.refetch(),i.refetch()])},[l,i]),c=l.data,z=c==null?void 0:c.overview,w=b.useMemo(()=>(c==null?void 0:c.daily)??[],[c]),f=b.useMemo(()=>(c==null?void 0:c.modelStats)??[],[c]),C=c==null?void 0:c.status,F=c==null?void 0:c.dbInfo,v=(c==null?void 0:c.recentRequests.items)??[],y=((C==null?void 0:C.providers)??0)>0,K=v.length>0,Q=E(P.config.full(),Ge.configRequest(),{enabled:y}),B=b.useMemo(()=>ut(Q.data),[Q.data])>0,G=(((U=E(P.apiKeys.all(),Qe.listRequest(),{enabled:y&&B}).data)==null?void 0:U.length)??0)>0,he=y&&B&&G&&K,me=[y,B,G,K].filter(Boolean).length,xe=b.useMemo(()=>{const u=(c==null?void 0:c.recentErrors)??[],m=new Set;return[...d.events,...u].filter(p=>!(m.has(p.id)||(m.add(p.id),n&&p.endpoint!==n))).slice(0,10)},[d.events,c,n]),pe=r==="all"?s("dashboard.filters.endpointAll"):r==="anthropic"?s("dashboard.filters.endpointAnthropic"):r==="openai"?s("dashboard.filters.endpointOpenAI"):((J=(Y=(W=i.data)==null?void 0:W.endpoints)==null?void 0:Y.find(u=>u.id===r))==null?void 0:J.label)||r,be=f.filter(u=>u.avgTtftMs!=null&&u.avgTtftMs>0).sort((u,m)=>(u.avgTtftMs??Number.POSITIVE_INFINITY)-(m.avgTtftMs??Number.POSITIVE_INFINITY))[0],ge=l.isFetching||i.isFetching,fe=l.isPending,je=((X=l.error)==null?void 0:X.message)??null,ve=b.useMemo(()=>{const u=s("dashboard.charts.barRequests"),m=s("dashboard.charts.latencyLabel");return{...t.base,color:t.palette,tooltip:{trigger:"axis",...t.base.tooltip},legend:{data:[u,m],...t.base.legend},grid:t.base.grid,xAxis:{type:"category",data:w.map(N=>N.date.slice(5)),axisLabel:{color:t.axis},axisLine:{lineStyle:{color:t.splitLine}}},yAxis:[{type:"value",name:u,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{lineStyle:{color:t.splitLine}}},{type:"value",name:m,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{show:!1}}],series:[{name:u,type:"bar",data:w.map(N=>N.requestCount),itemStyle:{color:t.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:m,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:w.map(N=>Math.round(N.avgLatencyMs)),itemStyle:{color:t.palette[3]},lineStyle:{width:2}}]}},[w,t,s]),q=b.useCallback((u,m,N)=>({...t.base,tooltip:{trigger:"axis",...t.base.tooltip},grid:{...t.base.grid,bottom:24},xAxis:{type:"category",data:f.map(p=>`${p.provider}/${p.model}`),axisLabel:{color:t.axis,rotate:28},axisLine:{lineStyle:{color:t.splitLine}}},yAxis:{type:"value",name:u,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{lineStyle:{color:t.splitLine}}},series:[{name:u,type:"bar",data:f.map(m),itemStyle:{color:N,borderRadius:[4,4,0,0]},barMaxWidth:32}]}),[f,t]),ye=b.useMemo(()=>q(s("dashboard.charts.ttftAxis"),u=>u.avgTtftMs??0,t.palette[2]),[q,t,s]),Ne=b.useMemo(()=>q(s("dashboard.charts.tpotAxis"),u=>u.avgTpotMs??0,t.palette[4]),[q,t,s]),Te=b.useMemo(()=>{const u=s("dashboard.charts.barRequests"),m=s("dashboard.charts.lineInput"),N=s("dashboard.charts.lineOutput");return{...t.base,color:t.palette,tooltip:{trigger:"axis",...t.base.tooltip},legend:{data:[u,m,N],...t.base.legend},grid:{...t.base.grid,bottom:24},xAxis:{type:"category",data:f.map(p=>`${p.provider}/${p.model}`),axisLabel:{color:t.axis,rotate:28},axisLine:{lineStyle:{color:t.splitLine}}},yAxis:[{type:"value",name:u,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{lineStyle:{color:t.splitLine}}},{type:"value",name:s("dashboard.charts.axisTokens"),position:"right",nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{show:!1}}],series:[{name:u,type:"bar",data:f.map(p=>p.requests),itemStyle:{color:t.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:m,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:f.map(p=>p.inputTokens??0),itemStyle:{color:t.palette[1]},lineStyle:{width:2}},{name:N,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:f.map(p=>p.outputTokens??0),itemStyle:{color:t.palette[2]},lineStyle:{width:2}}]}},[f,t,s]);return{attentionEvents:xe,customEndpoints:((Z=i.data)==null?void 0:Z.endpoints)??[],daily:w,dbInfo:F,endpointFilter:r,fastestTtftModel:be,handleRefresh:O,bootstrapError:je,isBootstrapping:fe,isRefreshing:ge,liveConnected:d.connected,liveFailed:d.failed,modelRequestsOption:Te,models:f,overview:z,recentLogs:v,selectedEndpointLabel:pe,setEndpointFilter:o,setupComplete:he,setupDoneCount:me,status:C,summaryPending:l.isPending,trendOption:ve,ttftOption:ye,tpotOption:Ne}}function Ft(){var o,n;const{t:s}=x(),a=ht(),t=a.dbInfo?se(a.dbInfo.totalBytes??a.dbInfo.sizeBytes):"-",r=se((o=a.dbInfo)==null?void 0:o.memoryRssBytes);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Ie,{actions:e.jsxs(e.Fragment,{children:[e.jsxs(ke,{value:a.endpointFilter,onValueChange:a.setEndpointFilter,children:[e.jsx(Ae,{className:"h-8 w-[168px]",children:e.jsx(De,{})}),e.jsxs(Oe,{children:[e.jsx(k,{value:"all",children:s("dashboard.filters.endpointAll")}),e.jsx(k,{value:"anthropic",children:s("dashboard.filters.endpointAnthropic")}),e.jsx(k,{value:"openai",children:s("dashboard.filters.endpointOpenAI")}),a.customEndpoints.map(l=>e.jsx(k,{value:l.id,children:l.label||l.id},l.id))]})]}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>void a.handleRefresh(),disabled:a.isRefreshing,children:[e.jsx(Le,{className:ze("mr-2 h-4 w-4",a.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),a.isRefreshing?s("common.actions.refreshing"):s("common.actions.refresh")]})]})}),a.isBootstrapping?e.jsx(Ue,{}):a.bootstrapError?e.jsx(M,{icon:e.jsx(Re,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:a.bootstrapError,action:e.jsx(R,{variant:"outline",onClick:()=>void a.handleRefresh(),children:s("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[a.setupComplete?null:e.jsx(ot,{endpointCount:a.customEndpoints.length,providerCount:((n=a.status)==null?void 0:n.providers)??0}),e.jsx(We,{status:a.status}),e.jsx(Je,{overview:a.overview}),a.setupComplete?null:e.jsx(rt,{doneCount:a.setupDoneCount,total:ct}),e.jsx(et,{empty:!a.daily.length,loading:a.summaryPending,option:a.trendOption}),e.jsx(tt,{daily:a.daily,models:a.models}),e.jsx(st,{modelRequestsOption:a.modelRequestsOption,models:a.models,ttftOption:a.ttftOption,tpotOption:a.tpotOption}),e.jsx(at,{dbInfo:a.dbInfo,dbSizeDisplay:t,memoryDisplay:r,status:a.status}),e.jsx(it,{records:a.recentLogs,loading:a.summaryPending}),a.attentionEvents.length>0?e.jsx(Xe,{connected:a.liveConnected,failed:a.liveFailed,events:a.attentionEvents}):e.jsx(Ze,{connected:a.liveConnected,failed:a.liveFailed})]})]})}export{Ft as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,av as J,Z as U,T as Z,aw as _,ao as H,ap as W}from"./vendor-CITafuNQ.js";import{L as X}from"./router-BoBrmro7.js";import{P as Y}from"./PageToolbar-CWw40AFL.js";import{P as ee}from"./PageSection-N34Nu8NO.js";import{P as se,a as B}from"./PageState-CFLrRswm.js";import{a as te,c as q,B as x,q as K}from"./app-
|
|
1
|
+
import{r as c,j as e,av as J,Z as U,T as Z,aw as _,ao as H,ap as W}from"./vendor-CITafuNQ.js";import{L as X}from"./router-BoBrmro7.js";import{P as Y}from"./PageToolbar-CWw40AFL.js";import{P as ee}from"./PageSection-N34Nu8NO.js";import{P as se,a as B}from"./PageState-CFLrRswm.js";import{a as te,c as q,B as x,q as K}from"./app-vWIA9Pq_.js";import{u as ae}from"./useEventStream-BYg6oKvQ.js";import{c as S}from"./global-BCehxTGJ.js";import{i as re,u as G}from"./i18n-PeX9kBVO.js";import{B as y}from"./badge-DpUlf_NW.js";import{C as ne,a as le}from"./card-D4YOc5eB.js";import{D as oe}from"./disclosure-l5qsWhr7.js";import{M as b}from"./metric-card-G1bbpbiR.js";import{S as ie}from"./segmented-control-13KTib6k.js";import{S as ce,a as de,b as ue,c as me,d as Q}from"./select-sOwKYsgI.js";import"./query-DZF7K6hv.js";import"./radix-Bux_1C5J.js";function xe(s){const r=Date.now()-s,l=Math.abs(r),o=60*1e3,f=60*o,d=24*f,m=new Intl.RelativeTimeFormat(re.language||"en",{numeric:"auto"});if(l<o){const a=Math.max(Math.round(l/1e3),1);return m.format(r>=0?-a:a,"second")}if(l<f){const a=Math.round(l/o);return m.format(r>=0?-a:a,"minute")}if(l<d){const a=Math.round(l/f);return m.format(r>=0?-a:a,"hour")}const p=Math.round(l/d);return m.format(r>=0?-p:p,"day")}function fe(s){return new Date(s).toLocaleString()}const ve={info:"secondary",warn:"outline",error:"destructive"};function Ie(){var z,k,I,R,V,F,D;const{t:s}=G(),{pushToast:n}=te(),[r,l]=c.useState(null),[o,f]=c.useState(""),[d,m]=c.useState(""),p=c.useMemo(()=>({limit:50,cursor:r??void 0,level:o||void 0,type:d||void 0}),[r,o,d]),a=q(K.events.list(p),{url:"/api/events",method:"GET",params:p}),u=q(K.events.stats(),{url:"/api/events/stats",method:"GET"},{refetchInterval:15e3}),T=((z=u.data)==null?void 0:z.error)??0,E=((k=u.data)==null?void 0:k.warn)??0,L=((I=u.data)==null?void 0:I.info)??0,M=((R=u.data)==null?void 0:R.total)??0,i=ae({level:o||void 0,type:d||void 0,maxEvents:50,enabled:r===null}),N=c.useRef(!1);c.useEffect(()=>{const t=a.isError;t&&a.error&&!N.current&&(N.current=!0,n({title:s("events.toast.loadFailure",{message:a.error.message}),variant:"error"})),t||(N.current=!1)},[a.error,a.isError,n,s]);const C=c.useRef(!1);c.useEffect(()=>{const t=u.isError;t&&u.error&&!C.current&&(C.current=!0,n({title:s("events.toast.statsLoadFailure",{message:u.error.message}),variant:"error"})),t||(C.current=!1)},[u.error,u.isError,n,s]);const A=()=>{l(null),f(""),m("")},h=((V=a.data)==null?void 0:V.events)??[],P=((F=a.data)==null?void 0:F.nextCursor)??null,O=a.isLoading,w=c.useMemo(()=>{if(r!==null)return h;const t=new Set;return[...i.events,...h].filter(v=>t.has(v.id)?!1:(t.add(v.id),!0)).slice(0,50)},[r,i.events,h]),$=c.useMemo(()=>{const t=new Set;return h.forEach(v=>t.add(v.type)),i.events.forEach(v=>t.add(v.type)),Array.from(t).sort()},[h,i.events]),g=c.useMemo(()=>{const t=[];return o&&t.push(s(`events.levels.${o}`)),d&&t.push(d),t},[o,d,s]);return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(Y,{info:w.length>0?e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:[w.length," events"]}):null,status:r===null?e.jsxs("span",{className:S("inline-flex items-center gap-1.5 text-xs font-medium",i.connected?"text-success":i.failed?"text-destructive":"text-warning"),children:[e.jsx("span",{"aria-hidden":"true",className:S("h-1.5 w-1.5 rounded-full",i.connected?"bg-success animate-live-pulse":i.failed?"bg-destructive":"bg-warning")}),i.connected?s("events.live"):i.failed?s("events.failed"):s("events.reconnecting")]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:s("events.actions.older")}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[!i.connected&&r===null?e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:s("common.actions.refresh")}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!r,onClick:()=>l(null),children:[e.jsx(J,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!P,onClick:()=>l(P),children:[s("events.actions.older"),e.jsx(U,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"events-stats-grid",children:[e.jsx(b,{size:"sm",dotClassName:"bg-destructive",label:s("events.levels.error"),value:T.toLocaleString(),rawValue:T,valueTestId:"events-stat-error"}),e.jsx(b,{size:"sm",dotClassName:"bg-warning",label:s("events.levels.warn"),value:E.toLocaleString(),rawValue:E,valueTestId:"events-stat-warn"}),e.jsx(b,{size:"sm",dotClassName:"bg-muted-foreground",label:s("events.levels.info"),value:L.toLocaleString(),rawValue:L,valueTestId:"events-stat-info"}),e.jsx(b,{size:"sm",dotClassName:"bg-foreground",label:s("events.stats.total"),value:M.toLocaleString(),rawValue:M,valueTestId:"events-stat-total"})]}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:flex-wrap md:items-center","data-testid":"events-filters-card",children:[e.jsx(ie,{value:o,onChange:t=>{l(null),f(t)},options:[{value:"",label:s("events.filters.allLevels")},{value:"info",label:s("events.levels.info")},{value:"warn",label:s("events.levels.warn")},{value:"error",label:s("events.levels.error")}],"aria-label":s("events.filters.title")}),e.jsxs(ce,{value:d||"all",onValueChange:t=>{l(null),m(t==="all"?"":t)},children:[e.jsx(de,{className:"h-8 w-full md:w-[200px]",children:e.jsx(ue,{})}),e.jsxs(me,{children:[e.jsx(Q,{value:"all",children:s("events.filters.allTypes")}),$.map(t=>e.jsx(Q,{value:t,children:t},t))]})]}),g.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(t=>e.jsx(y,{variant:"secondary",children:t},t))}),e.jsx(x,{variant:"ghost",size:"sm",onClick:A,className:"h-8 px-3 text-xs",children:s("common.actions.reset")})]}):null]}),e.jsx(ee,{title:s("events.title"),description:s(r?"events.actions.older":"events.actions.newest"),children:O?e.jsx(se,{label:s("common.loading")}):a.isError?e.jsx(B,{icon:e.jsx(Z,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((D=a.error)==null?void 0:D.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:s("common.actions.refresh")})}):w.length===0?e.jsx(B,{icon:e.jsx(_,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:g.length>0?s("events.empty.filteredTitle"):s("events.empty.title"),description:g.length>0?s("events.empty.filteredSubtitle"):s("events.empty.subtitle"),action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[g.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:A,children:s("common.actions.reset")}):null,e.jsx(x,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(X,{to:"/logs",children:s("events.empty.actions.logs")})})]})}):e.jsx("div",{className:"grid gap-3",children:e.jsx(H,{initial:!1,children:w.map(t=>e.jsx(W.div,{layout:!0,initial:{opacity:0,y:-12},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.18},children:e.jsx(pe,{event:t})},t.id))})})})]})}function pe({event:s}){const{t:n}=G(),r=s.level==="error"?"border-l-error":s.level==="warn"?"border-l-warning":"border-l-success";return e.jsx(ne,{className:S("overflow-hidden border-l-2 hover:bg-muted/30",r),children:e.jsxs(le,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:ve[s.level]||"secondary",className:"rounded-full text-[10px]",children:n(`events.levels.${s.level}`)}),e.jsxs(y,{variant:"outline",className:"rounded-full text-[10px]",children:["#",s.id]}),s.mode?e.jsx(y,{variant:"secondary",className:"rounded-full text-[10px]",children:s.mode}):null,s.endpoint?e.jsx(y,{variant:"outline",className:"rounded-full text-[10px]",children:s.endpoint}):null]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-[-0.01em]",children:s.title||n("events.defaultTitle")}),e.jsx("p",{className:"mt-1 line-clamp-2 text-sm leading-5 text-muted-foreground",children:s.message||n("events.defaultMessage")})]})]}),e.jsxs("div",{className:"shrink-0 space-y-0.5 text-xs text-muted-foreground lg:text-right",children:[e.jsx("p",{children:fe(s.createdAt)}),e.jsx("p",{children:xe(s.createdAt)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm",children:[e.jsx(j,{label:"Type",value:s.type}),e.jsx(j,{label:"Source",value:s.source}),e.jsx(j,{label:"IP",value:s.ipAddress}),e.jsx(j,{label:"API Key",value:s.apiKeyName}),e.jsx(j,{label:"User Agent",value:s.userAgent})]}),s.details?e.jsx(oe,{summary:n("events.details"),className:"rounded-lg bg-secondary px-3 py-2 text-sm",summaryClassName:"px-0 py-0 text-xs font-medium text-primary hover:text-primary",contentClassName:"mt-2.5",children:e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-secondary p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})}):null]})})}function j({label:s,value:n}){return n?e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-secondary/55 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"font-medium",children:[s,":"]}),e.jsx("span",{className:"truncate text-foreground",title:n,children:n})]}):null}export{Ie as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as u,j as e}from"./vendor-CITafuNQ.js";import{P as g}from"./PageToolbar-CWw40AFL.js";import{P as o}from"./PageSection-N34Nu8NO.js";import{c as j}from"./clipboard-BnAnBk_-.js";import{c as x}from"./global-BCehxTGJ.js";import{B as b}from"./app-
|
|
1
|
+
import{r as u,j as e}from"./vendor-CITafuNQ.js";import{P as g}from"./PageToolbar-CWw40AFL.js";import{P as o}from"./PageSection-N34Nu8NO.js";import{c as j}from"./clipboard-BnAnBk_-.js";import{c as x}from"./global-BCehxTGJ.js";import{B as b}from"./app-vWIA9Pq_.js";import{u as h}from"./i18n-PeX9kBVO.js";import"./card-D4YOc5eB.js";import"./query-DZF7K6hv.js";import"./router-BoBrmro7.js";import"./radix-Bux_1C5J.js";function E(){const{t}=h(),s=u.useMemo(()=>[{id:"tour",title:t("help.sections.consoleTour.title"),items:t("help.sections.consoleTour.items",{returnObjects:!0})},{id:"configuration",title:t("help.sections.configuration.title"),items:t("help.sections.configuration.items",{returnObjects:!0})},{id:"claude",title:t("help.sections.claudeCodeConfig.title"),items:t("help.sections.claudeCodeConfig.items",{returnObjects:!0})},{id:"codex",title:t("help.sections.codexConfig.title"),items:t("help.sections.codexConfig.items",{returnObjects:!0})},{id:"usage",title:t("help.sections.usage.title"),items:t("help.sections.usage.items",{returnObjects:!0})},{id:"tips",title:t("help.sections.tips.title"),items:t("help.sections.tips.items",{returnObjects:!0})}],[t]),i=t("help.faq.items",{returnObjects:!0}),n=u.useMemo(()=>[...s.map(l=>({id:l.id,title:l.title})),{id:"faq",title:t("help.faq.title")}],[s,t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{info:e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:t("help.meta.guides",{count:s.length})})}),e.jsxs("div",{className:"rounded-lg border border-border/60 bg-card px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("help.note")}),e.jsx("p",{className:"mt-1 text-xs leading-5",children:t("help.helper")})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[208px_minmax(0,1fr)] xl:items-start",children:[e.jsx("aside",{className:"hidden xl:sticky xl:top-4 xl:block",children:e.jsxs("nav",{"aria-label":t("help.meta.tocTitle"),className:"rounded-lg border border-border/60 bg-card p-3",children:[e.jsx("p",{className:"mb-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:t("help.meta.tocTitle")}),e.jsx("ol",{className:"space-y-0.5 text-sm",children:n.map(l=>e.jsx("li",{children:e.jsx("a",{href:`#help-${l.id}`,className:"block truncate rounded-md px-2 py-1.5 text-muted-foreground transition hover:bg-accent hover:text-foreground",children:l.title})},l.id))})]})}),e.jsxs("div",{className:"min-w-0 space-y-5",children:[e.jsx("div",{id:"help-tour",children:e.jsx(o,{title:s[0].title,children:e.jsx(c,{items:s[0].items,compact:!0})})}),e.jsx("div",{id:"help-configuration",children:e.jsx(o,{title:s[1].title,children:e.jsx(c,{items:s[1].items})})}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsx(o,{title:s[2].title,description:t("help.meta.claudeWorkflow"),children:e.jsx(c,{items:s[2].items})})}),e.jsx("div",{id:"help-codex",children:e.jsx(o,{title:s[3].title,description:t("help.meta.codexWorkflow"),children:e.jsx(c,{items:s[3].items})})})]}),e.jsx("div",{id:"help-usage",children:e.jsx(o,{title:s[4].title,children:e.jsx(c,{items:s[4].items})})}),e.jsx("div",{id:"help-tips",children:e.jsx(o,{title:s[5].title,children:e.jsx(c,{items:s[5].items})})}),e.jsx("div",{id:"help-faq",children:e.jsx(o,{title:t("help.faq.title"),children:e.jsx(y,{items:i})})})]})]})]})}function c({items:t,compact:s=!1}){return e.jsx("ol",{className:x("flex flex-col",s?"gap-2":"gap-2.5"),children:t.map((i,n)=>e.jsxs("li",{className:x("flex gap-3 rounded-lg border border-border/50 bg-card",s?"p-3":"p-3.5"),children:[e.jsx("span",{className:x("flex shrink-0 items-center justify-center rounded-md bg-primary text-xs font-semibold text-primary-foreground",s?"h-6 w-6 text-[11px]":"h-7 w-7"),children:n+1}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:e.jsx(f,{content:i})})]},`${n}-${i}`))})}function f({content:t}){const{t:s}=h(),i=t.split("```");return e.jsx("div",{className:"space-y-3",children:i.map((n,l)=>{if(!n.trim())return null;if(l%2===1){const[a,...m]=n.split(`
|
|
2
2
|
`),r=m.join(`
|
|
3
3
|
`).trim();return e.jsxs("div",{className:"overflow-hidden rounded-md border border-border/55 bg-secondary",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/55 px-3 py-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:a||"bash"}),e.jsx(b,{variant:"ghost",size:"sm",className:"h-6 rounded px-2 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>j(r),children:s("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-2.5 font-mono text-[12px] leading-6 text-foreground",children:e.jsx("code",{className:"block min-w-full whitespace-pre",children:r})})]},l)}return e.jsx(N,{content:n},l)})})}function N({content:t}){const s=t.split(`
|
|
4
4
|
`).map(r=>r.trimEnd()).filter(r=>r.trim().length>0);if(s.length===0)return null;const i=s.filter(r=>/^[-•*]\s+/.test(r.trim())),n=s.filter(r=>/^\d+[).]\s+/.test(r.trim())),l=s.filter(r=>!/^([-•*]|\d+[).])\s+/.test(r.trim())),a=i.map(r=>r.replace(/^[-•*]\s+/,"")),m=n.map(r=>{const d=r.trim().match(/^(\d+)[).]\s+(.*)$/);return{index:(d==null?void 0:d[1])??"",text:(d==null?void 0:d[2])??r.trim()}});return e.jsxs("div",{className:"space-y-2",children:[l.length>0?e.jsx("div",{className:"space-y-1.5",children:l.map((r,d)=>e.jsx("p",{className:"leading-6",children:p(r)},`${r}-${d}`))}):null,a.length>0?e.jsx("ul",{className:"space-y-1.5 rounded-md bg-secondary px-3 py-2",children:a.map((r,d)=>e.jsxs("li",{className:"flex gap-2 text-sm leading-6",children:[e.jsx("span",{className:"mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-primary"}),e.jsx("span",{children:p(r)})]},`${r}-${d}`))}):null,m.length>0?e.jsx("ol",{className:"space-y-1.5 rounded-md bg-secondary px-3 py-2",children:m.map(r=>e.jsxs("li",{className:"flex gap-2.5 text-sm leading-6",children:[e.jsx("span",{className:"mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary/15 px-1.5 text-[11px] font-semibold text-primary",children:r.index}),e.jsx("span",{children:p(r.text)})]},`${r.index}-${r.text}`))}):null]})}function p(t){return t.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((i,n)=>i.startsWith("`")&&i.endsWith("`")?e.jsx("code",{className:"rounded bg-secondary px-1.5 py-0.5 text-[0.95em] text-foreground",children:i.slice(1,-1)},n):i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:i.slice(2,-2)},n):e.jsx("span",{children:i},n))}function y({items:t}){return t.length===0?null:e.jsx("dl",{className:"space-y-2",children:t.map((s,i)=>e.jsxs("details",{className:"group overflow-hidden rounded-lg border border-border/50 bg-card",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-2.5 text-sm font-medium text-foreground",children:[e.jsx("span",{children:s.q}),e.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[11px] text-muted-foreground transition group-open:bg-primary/10 group-open:text-primary",children:i+1})]}),e.jsx("div",{className:"border-t border-border/50 px-4 py-3",children:e.jsx("dd",{className:"text-sm text-muted-foreground",children:e.jsx(f,{content:s.a})})})]},s.q))})}export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e,aZ as S,a_ as E}from"./vendor-CITafuNQ.js";import{j as k,L as F,B as L}from"./app-
|
|
1
|
+
import{r as n,j as e,aZ as S,a_ as E}from"./vendor-CITafuNQ.js";import{j as k,L as F,B as L}from"./app-vWIA9Pq_.js";import{C as j,a as N,b as P,d as T,e as A,f as B}from"./card-D4YOc5eB.js";import{L as b,I as y}from"./label-DSVzZIex.js";import{u as D}from"./i18n-PeX9kBVO.js";import{u as G,a as I}from"./router-BoBrmro7.js";import"./global-BCehxTGJ.js";import"./query-DZF7K6hv.js";import"./radix-Bux_1C5J.js";function J(){const{t:s}=D(),a=G(),l=I(),{authEnabled:o,isAuthenticated:u,loading:d,login:v,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),c=n.useMemo(()=>{var r;const t=l.state;return((r=t==null?void 0:t.from)==null?void 0:r.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 t=>{if(t.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await v(i.username.trim(),i.password),a(c,{replace:!0})}catch(r){m(r instanceof Error?r.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(N,{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-lg bg-primary/10 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(w,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(w,{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(P,{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(T,{className:"text-xl",children:s("login.title")}),e.jsx(A,{children:s("login.description")})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(y,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:t=>p(r=>({...r,username:t.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(y,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:t=>p(r=>({...r,password:t.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg 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(B,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function w({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg bg-card px-4 py-4 shadow-[var(--surface-shadow)]",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{J as default};
|