@chenpu17/cc-gw 0.7.19 → 0.7.21
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 +1 -1
- package/src/server/dist/index.js +42 -27
- package/src/web/dist/assets/{About-BA_VxEEw.js → About-Bjq70P_K.js} +2 -2
- package/src/web/dist/assets/ApiKeys-BHwlIBRG.js +16 -0
- package/src/web/dist/assets/{Dashboard-BV9q_ZEH.js → Dashboard-Bv6E5M2u.js} +1 -1
- package/src/web/dist/assets/{Events-CVDX7Sdl.js → Events-DyqUKr1b.js} +1 -1
- package/src/web/dist/assets/{Help-Q8aahW1e.js → Help-BNn_Zuo4.js} +1 -1
- package/src/web/dist/assets/{Login-Cc9PcXNz.js → Login-BHXuuVq3.js} +1 -1
- package/src/web/dist/assets/Logs-CRnJOy2J.js +6 -0
- package/src/web/dist/assets/{ModelManagement-Bb8NWZJD.js → ModelManagement-DAE8AYAE.js} +1 -1
- package/src/web/dist/assets/{PageHeader-DE87PlB_.js → PageHeader-D2u2opjK.js} +1 -1
- package/src/web/dist/assets/{PageSection-BW4UtaTE.js → PageSection-jfq2rgUu.js} +1 -1
- package/src/web/dist/assets/Settings-CssUPWdg.js +6 -0
- package/src/web/dist/assets/{Skeleton-DKmc2Oau.js → Skeleton-BwMNCVcg.js} +1 -1
- package/src/web/dist/assets/{card-B5QaMdIj.js → card-C9wVDhpJ.js} +1 -1
- package/src/web/dist/assets/{dialog-Bl93c96O.js → dialog-DbEoPxgf.js} +1 -1
- package/src/web/dist/assets/index-B1EJcuR-.css +1 -0
- package/src/web/dist/assets/{index-Bkl9YQUf.js → index-BjqieXJo.js} +1 -1
- package/src/web/dist/assets/{index-iaYfODK6.js → index-Blclkvp7.js} +4 -4
- package/src/web/dist/assets/{info-Dtepvi_0.js → info-BmVX8zJd.js} +1 -1
- package/src/web/dist/assets/{input-CRfONI49.js → input-CGgq_gCJ.js} +1 -1
- package/src/web/dist/assets/{label-sf3QNge5.js → label-BGUvZ4t2.js} +1 -1
- package/src/web/dist/assets/{refresh-cw-ZDTq8wum.js → refresh-cw-D7rJxbFV.js} +1 -1
- package/src/web/dist/assets/{select-DfAJfUCL.js → select-Chuh7X1A.js} +1 -1
- package/src/web/dist/assets/{shield-wbL9EF4o.js → shield-Beuqdf31.js} +1 -1
- package/src/web/dist/assets/{switch-DTxmu4vA.js → switch-XbPwmM_b.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-LZxVJXA3.js → useApiQuery-DiX6xcfY.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/src/web/dist/assets/ApiKeys-9iuHXiuE.js +0 -16
- package/src/web/dist/assets/Logs-EvCIbsmH.js +0 -6
- package/src/web/dist/assets/Settings-hk35KMN5.js +0 -6
- package/src/web/dist/assets/index-DDEa11GU.css +0 -1
package/package.json
CHANGED
package/src/server/dist/index.js
CHANGED
|
@@ -10102,6 +10102,11 @@ function parseConfig(raw) {
|
|
|
10102
10102
|
if (typeof data.logRetentionDays !== "number") {
|
|
10103
10103
|
data.logRetentionDays = 30;
|
|
10104
10104
|
}
|
|
10105
|
+
if (typeof data.logExportTimeoutSeconds !== "number" || !Number.isFinite(data.logExportTimeoutSeconds)) {
|
|
10106
|
+
data.logExportTimeoutSeconds = 60;
|
|
10107
|
+
} else {
|
|
10108
|
+
data.logExportTimeoutSeconds = Math.min(Math.max(Math.round(data.logExportTimeoutSeconds), 5), 600);
|
|
10109
|
+
}
|
|
10105
10110
|
const legacyStorePayloads = typeof data.storePayloads === "boolean" ? data.storePayloads : void 0;
|
|
10106
10111
|
const hasRequestFlag = typeof data.storeRequestPayloads === "boolean";
|
|
10107
10112
|
const hasResponseFlag = typeof data.storeResponsePayloads === "boolean";
|
|
@@ -12813,6 +12818,8 @@ async function ensureSchema(db) {
|
|
|
12813
12818
|
await maybeAddColumn(db, "request_logs", "api_key_id", "INTEGER");
|
|
12814
12819
|
await maybeAddColumn(db, "request_logs", "api_key_name", "TEXT");
|
|
12815
12820
|
await maybeAddColumn(db, "request_logs", "api_key_value", "TEXT");
|
|
12821
|
+
await maybeAddColumn(db, "request_payloads", "prompt", "BLOB");
|
|
12822
|
+
await maybeAddColumn(db, "request_payloads", "response", "BLOB");
|
|
12816
12823
|
const hasKeyHash = await columnExists(db, "api_keys", "key_hash");
|
|
12817
12824
|
if (!hasKeyHash) {
|
|
12818
12825
|
await run(db, "ALTER TABLE api_keys ADD COLUMN key_hash TEXT");
|
|
@@ -17231,33 +17238,41 @@ async function registerAdminRoutes(app) {
|
|
|
17231
17238
|
return { total, items: (items || []).map((item) => mapLogRecord(item)) };
|
|
17232
17239
|
});
|
|
17233
17240
|
app.post("/api/logs/export", async (request, reply) => {
|
|
17234
|
-
|
|
17235
|
-
|
|
17236
|
-
|
|
17237
|
-
|
|
17238
|
-
Object.
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
|
|
17243
|
-
|
|
17244
|
-
|
|
17245
|
-
|
|
17246
|
-
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
|
|
17257
|
-
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17241
|
+
try {
|
|
17242
|
+
const body = request.body ?? {};
|
|
17243
|
+
const { limit, filters } = buildLogOptions(body, { defaultLimit: 1e3, maxLimit: 5e3, includeOffset: false });
|
|
17244
|
+
const records = await exportLogs({ ...filters, limit });
|
|
17245
|
+
const filtersForExport = Object.fromEntries(
|
|
17246
|
+
Object.entries(filters).filter(([, value]) => value !== void 0 && value !== null && value !== "")
|
|
17247
|
+
);
|
|
17248
|
+
const payload = {
|
|
17249
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17250
|
+
count: records.length,
|
|
17251
|
+
limit,
|
|
17252
|
+
filters: filtersForExport,
|
|
17253
|
+
records: (records || []).map((record) => ({
|
|
17254
|
+
...mapLogRecord(record, { includeKeyValue: true }),
|
|
17255
|
+
payload: record.payload
|
|
17256
|
+
}))
|
|
17257
|
+
};
|
|
17258
|
+
const filename = `cc-gw-logs-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.zip`;
|
|
17259
|
+
const zip = new import_jszip.default();
|
|
17260
|
+
zip.file("logs.json", JSON.stringify(payload, null, 2));
|
|
17261
|
+
const buffer = await zip.generateAsync({
|
|
17262
|
+
type: "nodebuffer",
|
|
17263
|
+
compression: "DEFLATE",
|
|
17264
|
+
compressionOptions: { level: 9 }
|
|
17265
|
+
});
|
|
17266
|
+
reply.header("Content-Type", "application/zip");
|
|
17267
|
+
reply.header("Content-Disposition", `attachment; filename="${filename}"`);
|
|
17268
|
+
return reply.send(buffer);
|
|
17269
|
+
} catch (error) {
|
|
17270
|
+
request.log.error({ error }, "[logs] export failed");
|
|
17271
|
+
reply.code(500);
|
|
17272
|
+
return {
|
|
17273
|
+
error: error instanceof Error ? `\u5BFC\u51FA\u65E5\u5FD7\u5931\u8D25\uFF1A${error.message}` : "\u5BFC\u51FA\u65E5\u5FD7\u5931\u8D25"
|
|
17274
|
+
};
|
|
17275
|
+
}
|
|
17261
17276
|
});
|
|
17262
17277
|
app.get("/api/logs/:id", async (request, reply) => {
|
|
17263
17278
|
const id = Number(request.params.id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as j,u as g,b as v,r as i,j as e,e as d,aa as N}from"./index-
|
|
1
|
+
import{c as j,u as g,b as v,r as i,j as e,e as d,aa as N}from"./index-Blclkvp7.js";import{u as y}from"./useApiQuery-DiX6xcfY.js";import{P as E}from"./PageHeader-D2u2opjK.js";import{P as n}from"./PageSection-jfq2rgUu.js";import{C as m,a as p}from"./card-C9wVDhpJ.js";import{I}from"./info-BmVX8zJd.js";import{R as T}from"./refresh-cw-D7rJxbFV.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const k=j("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),_="0.7.
|
|
6
|
+
*/const k=j("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),_="0.7.21",w={version:_},L={VITE_BUILD_TIME:"2026-03-03T02:35:06.938Z",VITE_NODE_VERSION:"v22.16.0"};function u({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:t.map(a=>e.jsx(m,{children:e.jsxs(p,{className:"pt-4",children:[e.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a.label}),e.jsx("dd",{className:"mt-1 text-sm font-semibold",children:a.value}),a.hint&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.hint})]})},a.label))})}function D(){const{t}=g(),{pushToast:a}=v(),s=y(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});i.useEffect(()=>{s.isError&&s.error&&a({title:t("about.toast.statusError.title"),description:s.error.message,variant:"error"})},[s.isError,s.error,a,t]);const o=w.version,r=i.useMemo(()=>{const c=L,b=c.VITE_BUILD_TIME,f=c.VITE_NODE_VERSION;return{buildTime:b,nodeVersion:f}},[]),x=i.useMemo(()=>[{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",{className:"font-mono text-primary",children:["v",o]})},{label:t("about.app.labels.buildTime"),value:r.buildTime,hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.node"),value:e.jsx("span",{className:"font-mono",children:r.nodeVersion})}],[o,r.buildTime,r.nodeVersion,t]),l=i.useMemo(()=>s.data?[{label:t("about.status.labels.host"),value:s.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:s.data.port.toLocaleString()},{label:t("about.status.labels.providers"),value:s.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(s.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")}]:[],[s.data,t]),h=()=>{a({title:t("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{icon:e.jsx(I,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:`v${o}`,actions:e.jsxs(d,{onClick:h,children:[e.jsx(k,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(n,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(u,{items:x})}),e.jsx(n,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(d,{variant:"outline",size:"sm",onClick:()=>s.refetch(),disabled:s.isFetching,children:[e.jsx(T,{className:`mr-2 h-4 w-4 ${s.isFetching?"animate-spin":""}`,"aria-hidden":"true"}),s.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:s.isLoading?e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-2 text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.status.loading")})]}):l.length>0?e.jsx(u,{items:l}):e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-1 rounded-lg border border-dashed p-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:t("about.status.empty")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("common.actions.refresh")})]})})]}),e.jsx(n,{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(m,{children:e.jsxs(p,{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"flex-1 text-sm text-muted-foreground",children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-md bg-muted px-3 py-1.5 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}export{D as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{c as z,r as n,j as e,a as ne,u as q,b as Ne,W as be,e as c,Y as we,Z as ke,d as v,t as b}from"./index-Blclkvp7.js";import{E as Ee}from"./index-BjqieXJo.js";import{u as L}from"./useApiQuery-DiX6xcfY.js";import{P as Ce,B as C}from"./PageHeader-D2u2opjK.js";import{P as ee}from"./PageSection-jfq2rgUu.js";import{c as Se}from"./clipboard-CALi6bTW.js";import{I as De}from"./input-CGgq_gCJ.js";import{L as M}from"./label-BGUvZ4t2.js";import{C as H,a as U}from"./card-C9wVDhpJ.js";import{P as Te,D as O,a as W,b as P,c as R,d as se,e as F}from"./dialog-DbEoPxgf.js";import{C as ae,S as Ae}from"./shield-Beuqdf31.js";/**
|
|
2
|
+
* @license lucide-react v0.344.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Le=z("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
|
|
7
|
+
* @license lucide-react v0.344.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Me=z("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
12
|
+
* @license lucide-react v0.344.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Oe=z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),re=n.forwardRef(({className:s,...i},o)=>e.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:o,...i}));re.displayName="Textarea";function We(){const[s,i]=n.useState([]);return n.useEffect(()=>{const o=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}];v.get("/api/custom-endpoints").then(m=>{const u=(m.data.endpoints??[]).map(d=>({id:d.id,label:d.label}));i([...o,...u])}).catch(()=>{i(o)})},[]),s}function te({available:s,selected:i,onChange:o,hint:m}){const{t:u}=q(),d=i.length===0,w=()=>{o([])},f=l=>{i.includes(l)?o(i.filter(K=>K!==l)):o([...i,l])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 transition-colors hover:bg-muted/50",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:w,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:u("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:s.map(l=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 transition-colors hover:bg-muted/50",children:[e.jsx("input",{type:"checkbox",checked:!d&&i.includes(l.id),onChange:()=>f(l.id),className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm",children:l.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",l.id,")"]})]},l.id))})]})}const Pe=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function Be(){const{t:s}=q(),{pushToast:i}=Ne(),[o,m]=n.useState(!1),[u,d]=n.useState(""),[w,f]=n.useState(""),[l,K]=n.useState([]),[p,S]=n.useState(null),[le,V]=n.useState(null),[h,ce]=n.useState(7),[G,Q]=n.useState(new Map),[oe,$]=n.useState(null),[y,k]=n.useState(null),[D,B]=n.useState([]),Z=We(),g=L(["api-keys"],{url:"/api/keys",method:"GET"}),E=L(["api-keys","overview",h],{url:"/api/stats/api-keys/overview",method:"GET",params:{days:h}}),N=L(["api-keys","usage",h],{url:"/api/stats/api-keys/usage",method:"GET",params:{days:h,limit:10}}),T=g.data??[],j=E.data,x=N.data??[],de=T.some(a=>a.isWildcard),pe=j?j.totalKeys.toLocaleString():"-",me=j?j.enabledKeys.toLocaleString():"-",ue=j?j.activeKeys.toLocaleString():"-",Y=async()=>{if(!u.trim()){i({title:s("apiKeys.errors.nameRequired"),variant:"error"});return}try{const a=await v.post("/api/keys",{name:u.trim(),description:w.trim()||void 0,allowedEndpoints:l.length>0?l:void 0});S(a.data),m(!1),d(""),f(""),K([]),g.refetch(),E.refetch(),N.refetch(),i({title:s("apiKeys.toast.keyCreated"),variant:"success"})}catch(a){const t=b(a);i({title:s("apiKeys.toast.createFailure",{message:t.message}),variant:"error"})}},xe=async(a,t)=>{try{await v.patch(`/api/keys/${a}`,{enabled:!t}),g.refetch(),E.refetch(),i({title:s("apiKeys.toast.keyUpdated"),variant:"success"})}catch(r){const A=b(r);i({title:s("apiKeys.toast.updateFailure",{message:A.message}),variant:"error"})}},he=async a=>{if(confirm(s("apiKeys.confirmDelete"))){V(a);try{await v.delete(`/api/keys/${a}`),g.refetch(),E.refetch(),N.refetch(),i({title:s("apiKeys.toast.keyDeleted"),variant:"success"})}catch(t){const r=b(t);i({title:s("apiKeys.toast.deleteFailure",{message:r.message}),variant:"error"})}finally{V(null)}}},ye=async a=>{if(!G.has(a)){$(a);try{const t=await v.get(`/api/keys/${a}/reveal`);Q(r=>new Map(r).set(a,t.data.key))}catch(t){const r=b(t);i({title:s("apiKeys.toast.revealFailure"),description:r.message,variant:"error"})}finally{$(null)}}},ge=a=>{Q(t=>{const r=new Map(t);return r.delete(a),r})},_=async a=>{try{await Se(a),i({title:s("apiKeys.toast.keyCopied"),variant:"success"})}catch(t){i({title:s("apiKeys.toast.copyFailure"),description:t instanceof Error?t.message:s("common.unknownError"),variant:"error"})}},je=n.useCallback(a=>{k(a),B(a.allowedEndpoints??[])},[]),ve=async()=>{if(y)try{await v.patch(`/api/keys/${y.id}`,{allowedEndpoints:D.length>0?D:null}),k(null),g.refetch(),i({title:s("apiKeys.toast.keyUpdated"),variant:"success"})}catch(a){const t=b(a);i({title:s("apiKeys.toast.updateFailure",{message:t.message}),variant:"error"})}},J=a=>a?new Date(a).toLocaleString():s("common.noData"),fe=n.useMemo(()=>{const a=x.map(t=>t.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:a,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.requestsSeries"),type:"bar",data:x.map(t=>t.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[x,s]),Ke=n.useMemo(()=>{const a=x.map(t=>t.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[s("apiKeys.analytics.tokens.input"),s("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:a,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:x.map(t=>t.inputTokens)},{name:s("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:x.map(t=>t.outputTokens)}]}},[x,s]);return g.isLoading?e.jsx(be,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Ce,{icon:e.jsx(we,{className:"h-5 w-5","aria-hidden":"true"}),title:s("apiKeys.title"),description:s("apiKeys.description"),actions:e.jsxs(c,{onClick:()=>m(!0),children:[e.jsx(Te,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("apiKeys.createNew")]})}),e.jsx(ee,{title:s("apiKeys.analytics.title"),description:s("apiKeys.analytics.description",{days:h}),actions:e.jsx("div",{className:"flex items-center gap-1 rounded-lg border p-1",children:Pe.map(a=>{const t=h===a.value;return e.jsx("button",{type:"button",onClick:()=>ce(a.value),className:ne("inline-flex h-7 items-center rounded-md px-3 text-xs font-medium transition-colors",t?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:s(a.labelKey)},a.value)})}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(I,{label:s("apiKeys.analytics.cards.total"),value:pe}),e.jsx(I,{label:s("apiKeys.analytics.cards.enabled"),value:me}),e.jsx(I,{label:s("apiKeys.analytics.cards.active",{days:h}),value:ue})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(ie,{title:s("apiKeys.analytics.charts.requests"),loading:N.isLoading,empty:x.length===0,emptyText:s("apiKeys.analytics.empty"),option:fe}),e.jsx(ie,{title:s("apiKeys.analytics.charts.tokens"),loading:N.isLoading,empty:x.length===0,emptyText:s("apiKeys.analytics.empty"),option:Ke})]})]})}),e.jsx(ee,{title:s("apiKeys.list.title"),description:de?s("apiKeys.wildcardHint"):void 0,children:T.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:s("apiKeys.list.empty")})}):e.jsx("div",{className:"grid gap-4",children:T.map(a=>{const t=(a.totalInputTokens+a.totalOutputTokens).toLocaleString(),r=G.get(a.id),A=oe===a.id;return e.jsx(H,{children:e.jsx(U,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:a.name}),a.isWildcard&&e.jsx(C,{variant:"secondary",children:s("apiKeys.wildcard")}),e.jsx(C,{variant:a.enabled?"default":"outline",children:a.enabled?s("apiKeys.status.enabled"):s("apiKeys.status.disabled")}),!a.isWildcard&&a.allowedEndpoints&&a.allowedEndpoints.length>0?a.allowedEndpoints.map(X=>e.jsx(C,{variant:"outline",className:"text-xs",children:X},X)):a.isWildcard?null:e.jsx(C,{variant:"secondary",className:"text-xs opacity-60",children:s("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"rounded-md bg-muted px-3 py-1.5 font-mono text-sm",children:a.isWildcard?s("apiKeys.wildcard"):r??a.maskedKey??"********"}),!a.isWildcard&&e.jsx("div",{className:"flex items-center gap-1",children:r?e.jsxs(e.Fragment,{children:[e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void _(r),"aria-label":s("common.actions.copy"),title:s("common.actions.copy"),children:e.jsx(ae,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ge(a.id),"aria-label":s("apiKeys.actions.hide"),title:s("apiKeys.actions.hide"),children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void ye(a.id),disabled:A,"aria-label":s("apiKeys.actions.reveal"),title:s("apiKeys.actions.reveal"),children:e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"})})})]}),a.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("apiKeys.wildcardHint")}):a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null,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:s("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:J(a.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:J(a.lastUsedAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.requestCount")}),e.jsx("p",{className:"font-medium",children:a.requestCount.toLocaleString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.totalTokens")}),e.jsx("p",{className:"font-medium",children:t})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!a.isWildcard&&e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>je(a),children:[e.jsx(Ae,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),s("apiKeys.editEndpoints")]}),e.jsx(c,{variant:a.enabled?"outline":"default",size:"sm",onClick:()=>xe(a.id,a.enabled),children:a.enabled?s("apiKeys.actions.disable"):s("apiKeys.actions.enable")}),!a.isWildcard&&e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>he(a.id),disabled:le===a.id,"aria-label":s("apiKeys.actions.delete"),children:e.jsx(Oe,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})},a.id)})})}),e.jsx(O,{open:o,onOpenChange:m,children:e.jsxs(W,{children:[e.jsxs(P,{children:[e.jsx(R,{children:s("apiKeys.createNew")}),e.jsx(se,{children:s("apiKeys.createDescription")})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{htmlFor:"keyName",children:[s("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(De,{id:"keyName",value:u,onChange:a=>d(a.target.value),placeholder:s("apiKeys.keyNamePlaceholder"),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Y())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"keyDescription",children:s("apiKeys.descriptionLabel")}),e.jsx(re,{id:"keyDescription",value:w,onChange:a=>f(a.target.value),placeholder:s("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:s("apiKeys.allowedEndpoints")}),e.jsx(te,{available:Z,selected:l,onChange:K,hint:s("apiKeys.selectEndpoints")})]})]}),e.jsxs(F,{children:[e.jsx(c,{variant:"outline",onClick:()=>{m(!1),d(""),f(""),K([])},children:s("common.actions.cancel")}),e.jsx(c,{onClick:()=>void Y(),children:s("apiKeys.createAction")})]})]})}),e.jsx(O,{open:!!p,onOpenChange:()=>S(null),children:e.jsxs(W,{children:[e.jsx(P,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600",children:e.jsx(ke,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(R,{children:s("apiKeys.keyCreated")})]})}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:s("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-md bg-muted px-4 py-3 font-mono text-sm",children:p==null?void 0:p.key}),(p==null?void 0:p.description)&&e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:p.description}),e.jsxs(F,{children:[e.jsxs(c,{onClick:()=>void _((p==null?void 0:p.key)??""),children:[e.jsx(ae,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("common.actions.copy")]}),e.jsx(c,{variant:"outline",onClick:()=>S(null),children:s("common.actions.close")})]})]})}),e.jsx(O,{open:!!y,onOpenChange:a=>{a||k(null)},children:e.jsxs(W,{children:[e.jsxs(P,{children:[e.jsx(R,{children:s("apiKeys.editEndpoints")}),e.jsx(se,{children:y==null?void 0:y.name})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto",children:e.jsx(te,{available:Z,selected:D,onChange:B,hint:s("apiKeys.selectEndpoints")})}),e.jsxs(F,{children:[e.jsx(c,{variant:"outline",onClick:()=>k(null),children:s("common.actions.cancel")}),e.jsx(c,{onClick:()=>void ve(),children:s("common.save")})]})]})})]})}function I({label:s,value:i}){return e.jsx(H,{children:e.jsxs(U,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:i})]})})}function ie({title:s,option:i,loading:o,empty:m,emptyText:u}){const{t:d}=q();return e.jsx(H,{children:e.jsxs(U,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:s}),o?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:d("common.loadingShort")})}):m?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-lg border border-dashed",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u})}):e.jsx(Ee,{option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}export{Be as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as _,r as n,j as e,a as y,u as D,b as le,d as ce,t as me,B as I,e as he}from"./index-
|
|
1
|
+
import{c as _,r as n,j as e,a as y,u as D,b as le,d as ce,t as me,B as I,e as he}from"./index-Blclkvp7.js";import{E as ue}from"./index-BjqieXJo.js";import{S as xe,C as pe,T as be}from"./Skeleton-BwMNCVcg.js";import{P as X,B as w}from"./PageHeader-D2u2opjK.js";import{P as Z}from"./PageSection-jfq2rgUu.js";import{u as k}from"./useApiQuery-DiX6xcfY.js";import{C as G,a as Q}from"./card-C9wVDhpJ.js";import{S as ge,a as fe,b as ye,c as je,d as M}from"./select-Chuh7X1A.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as N,u as L,b as E,r as i,j as e,e as h,C as R,a as $,L as I,g as T,t as P}from"./index-
|
|
1
|
+
import{c as N,u as L,b as E,r as i,j as e,e as h,C as R,a as $,L as I,g as T,t as P}from"./index-Blclkvp7.js";import{P as z,B as j}from"./PageHeader-D2u2opjK.js";import{I as F}from"./input-CGgq_gCJ.js";import{C as w,a as C,b as V}from"./card-C9wVDhpJ.js";import{S as B,a as D,b as K,c as H,d as f}from"./select-Chuh7X1A.js";import{R as J}from"./refresh-cw-D7rJxbFV.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as x,u,r as g,j as e,e as h}from"./index-
|
|
1
|
+
import{c as x,u,r as g,j as e,e as h}from"./index-Blclkvp7.js";import{P as N}from"./PageHeader-D2u2opjK.js";import{P as d}from"./PageSection-jfq2rgUu.js";import{c as p}from"./clipboard-CALi6bTW.js";import{C as j,a as f}from"./card-C9wVDhpJ.js";import{I as v}from"./info-BmVX8zJd.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as C,an as E,ao as F,ap as S,r as n,j as e,W as L,e as k}from"./index-
|
|
1
|
+
import{u as C,an as E,ao as F,ap as S,r as n,j as e,W as L,e as k}from"./index-Blclkvp7.js";import{I as j}from"./input-CGgq_gCJ.js";import{L as b}from"./label-BGUvZ4t2.js";import{C as v,a as w,b as P,c as T,d as A,e as D}from"./card-C9wVDhpJ.js";function G(){const{t:s}=C(),l=E(),u=F(),{authEnabled:i,isAuthenticated:m,loading:o,login:N,error:x}=S(),[t,f]=n.useState({username:"",password:""}),[p,d]=n.useState(null),[h,g]=n.useState(!1),c=n.useMemo(()=>{var r;const a=u.state;return((r=a==null?void 0:a.from)==null?void 0:r.pathname)??"/"},[u.state]);n.useEffect(()=>{if(!i&&!o){l(c,{replace:!0});return}i&&m&&!o&&l(c,{replace:!0})},[i,m,o,l,c]);const y=async a=>{if(a.preventDefault(),d(null),!t.username.trim()||!t.password){d(s("login.validation.required"));return}g(!0);try{await N(t.username.trim(),t.password),l(c,{replace:!0})}catch(r){d(r instanceof Error?r.message:s("login.validation.failed"))}finally{g(!1)}};return o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx(v,{className:"w-full max-w-md",children:e.jsx(w,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(L,{})})})}):i?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsxs(v,{className:"w-full max-w-md",children:[e.jsxs(P,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-xl bg-primary text-lg font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-2xl",children:s("login.title")}),e.jsx(A,{className:"text-sm",children:s("login.description")})]}),e.jsx(w,{children:e.jsxs("form",{className:"space-y-4",onSubmit:y,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(j,{id:"username",value:t.username,autoComplete:"username",autoFocus:!0,onChange:a=>f(r=>({...r,username:a.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(j,{id:"password",type:"password",value:t.password,autoComplete:"current-password",onChange:a=>f(r=>({...r,password:a.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),(p||x)&&e.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:p||x}),e.jsx(k,{type:"submit",className:"w-full",disabled:h,children:s(h?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(D,{className:"justify-center",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})}):null}export{G as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as Ke,u as H,b as we,r as o,d as Ae,t as Pe,j as e,e as k,a as $,F as ze,X as ke,f as Oe}from"./index-Blclkvp7.js";import{u as D}from"./useApiQuery-DiX6xcfY.js";import{T as Ie,a as K}from"./Skeleton-BwMNCVcg.js";import{P as qe,B as ee}from"./PageHeader-D2u2opjK.js";import{c as Ue}from"./clipboard-CALi6bTW.js";import{I as Z}from"./input-CGgq_gCJ.js";import{L as C}from"./label-BGUvZ4t2.js";import{C as je,a as ye}from"./card-C9wVDhpJ.js";import{C as Be,e as He,S as I,a as q,b as U,c as B,d as w}from"./select-Chuh7X1A.js";import{R as Ge}from"./refresh-cw-D7rJxbFV.js";/**
|
|
2
|
+
* @license lucide-react v0.344.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Qe=Ke("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),ve=[20,50,100];function Ne(s,i=!1){if(!s)return;const d=i?`${s}T23:59:59.999`:`${s}T00:00:00.000`,g=Date.parse(d);return Number.isFinite(g)?g:void 0}function Se(s){const i=new Date(s);return`${i.getFullYear()}-${`${i.getMonth()+1}`.padStart(2,"0")}-${`${i.getDate()}`.padStart(2,"0")} ${`${i.getHours()}`.padStart(2,"0")}:${`${i.getMinutes()}`.padStart(2,"0")}:${`${i.getSeconds()}`.padStart(2,"0")}`}function _(s){return s==null?"-":s.toLocaleString()}function T(s,i){const d=_(s);return d==="-"?"-":`${d} ${i}`}function We(s){return s?"true":"false"}function be(s,i){if(!s||s.trim().length===0)return i;try{const d=JSON.parse(s);return JSON.stringify(d,null,2)}catch{return s}}function os(){var me,xe,ue,pe,he,fe;const{t:s}=H(),{pushToast:i}=we(),[d,g]=o.useState("all"),[p,l]=o.useState("all"),[c,j]=o.useState(""),[m,v]=o.useState("all"),[a,h]=o.useState(""),[n,u]=o.useState(""),[x,f]=o.useState(1),[N,G]=o.useState(ve[0]),[A,se]=o.useState(null),[_e,te]=o.useState(!1),[E,Q]=o.useState([]),[P,le]=o.useState(!1),[ae,Ee]=o.useState(!1),[Ce,Te]=o.useState(!1),W=o.useRef(null);o.useEffect(()=>{f(1)},[d,p,c,m,a,n,N,E]);const z=o.useMemo(()=>{const t={limit:N,offset:(x-1)*N};d!=="all"&&(t.provider=d),p!=="all"&&(t.endpoint=p),c.trim().length>0&&(t.model=c.trim()),m!=="all"&&(t.status=m);const r=Ne(a),S=Ne(n,!0);return r!==void 0&&(t.from=r),S!==void 0&&(t.to=S),E.length>0&&(t.apiKeys=E.join(",")),t},[d,p,c,m,a,n,x,N,E]),y=D(["logs",z],{url:"/api/logs",method:"GET",params:z}),L=D(["providers","all"],{url:"/api/providers",method:"GET"}),ne=D(["api-keys"],{url:"/api/keys",method:"GET"}),V=D(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"}),ie=D(["config","export-timeout"],{url:"/api/config",method:"GET"});o.useEffect(()=>{y.isError&&y.error&&i({title:s("logs.toast.listError.title"),description:s("logs.toast.listError.desc",{message:y.error.message}),variant:"error"})},[y.isError,y.error,i,s]),o.useEffect(()=>{L.isError&&L.error&&i({title:s("logs.toast.providerError.title"),description:s("logs.toast.providerError.desc",{message:L.error.message}),variant:"error"})},[L.isError,L.error,i,s]);const R=((me=y.data)==null?void 0:me.total)??0,b=R>0?Math.ceil(R/N):0,re=((xe=y.data)==null?void 0:xe.items)??[],oe=o.useMemo(()=>{var r;const t=(r=ie.data)==null?void 0:r.logExportTimeoutSeconds;return typeof t=="number"&&Number.isFinite(t)?Math.min(Math.max(Math.round(t),5),600)*1e3:6e4},[(ue=ie.data)==null?void 0:ue.logExportTimeoutSeconds]);o.useEffect(()=>{b>0&&x>b&&f(b)},[b,x]);const J=L.data??[],O=o.useMemo(()=>{const t=new Map;for(const r of J)r.id&&t.set(r.id,r.label??r.id);return t},[J]),de=o.useMemo(()=>{var r;const t=new Map;t.set("anthropic",s("logs.filters.endpointAnthropic")),t.set("openai",s("logs.filters.endpointOpenAI"));for(const S of((r=V.data)==null?void 0:r.endpoints)??[])t.set(S.id,S.label||S.id);return t},[(pe=V.data)==null?void 0:pe.endpoints,s]),X=o.useMemo(()=>{const t=[];if(d!=="all"){const r=O.get(d)??d;t.push({key:"provider",label:`${s("logs.filters.provider")}: ${r}`,onRemove:()=>g("all")})}if(p!=="all"){const r=de.get(p)??p;t.push({key:"endpoint",label:`${s("logs.filters.endpoint")}: ${r}`,onRemove:()=>l("all")})}if(c.trim()&&t.push({key:"model",label:`${s("logs.filters.modelId")}: ${c.trim()}`,onRemove:()=>j("")}),m!=="all"){const r=s(m==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");t.push({key:"status",label:`${s("logs.filters.status")}: ${r}`,onRemove:()=>v("all")})}return a&&t.push({key:"from",label:`${s("logs.filters.startDate")}: ${a}`,onRemove:()=>h("")}),n&&t.push({key:"to",label:`${s("logs.filters.endDate")}: ${n}`,onRemove:()=>u("")}),E.length>0&&t.push({key:"apiKeys",label:s("logs.filters.apiKeySelected",{count:E.length}),onRemove:()=>Q([])}),t},[d,O,p,de,c,m,a,n,E,s]),Y=ne.data??[],ce=o.useMemo(()=>{const t=new Map;for(const r of Y)t.set(r.id,r);return t},[Y]),Le=()=>{g("all"),j(""),l("all"),v("all"),h(""),u(""),Q([])},Re=o.useCallback(async()=>{if(!P){le(!0);try{const t=R>0?Math.min(R,5e3):1e3,r={...z,limit:t,offset:0},S=await Ae.post("/api/logs/export",r,{responseType:"blob",timeout:oe}),Fe=new Blob([S.data],{type:"application/zip"}),Me=new Date().toISOString().replace(/[:.]/g,"-"),ge=URL.createObjectURL(Fe),M=document.createElement("a");M.href=ge,M.download=`cc-gw-logs-${Me}.zip`,document.body.appendChild(M),M.click(),M.remove(),URL.revokeObjectURL(ge),i({title:s("logs.toast.exportSuccess.title"),description:s("logs.toast.exportSuccess.desc"),variant:"success"})}catch(t){const r=Pe(t);i({title:s("logs.toast.exportError.title"),description:s("logs.toast.exportError.desc",{message:r.message}),variant:"error"})}finally{le(!1)}}},[oe,P,i,z,s,R]),De=o.useCallback(t=>{se(t),te(!0)},[]),$e=o.useCallback(()=>{te(!1),se(null)},[]),F=o.useCallback(()=>{const t=W.current;if(!t)return;const r=t.scrollWidth-t.scrollLeft-t.clientWidth>1;Te(r)},[]);return o.useEffect(()=>{const t=W.current;if(!t)return;F(),t.addEventListener("scroll",F,{passive:!0});const r=new ResizeObserver(F);return r.observe(t),()=>{t.removeEventListener("scroll",F),r.disconnect()}},[F]),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(qe,{icon:e.jsx(ze,{className:"h-5 w-5","aria-hidden":"true"}),title:s("logs.title"),description:s("logs.description"),actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(k,{onClick:Re,disabled:P,children:[e.jsx(Qe,{className:"mr-2 h-4 w-4"}),s(P?"common.actions.loading":"logs.actions.export")]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.summary.total",{value:R.toLocaleString()})}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>y.refetch(),disabled:y.isFetching,children:[e.jsx(Ge,{className:$("mr-2 h-4 w-4",y.isFetching&&"animate-spin")}),y.isFetching?s("common.actions.refreshing"):s("logs.actions.manualRefresh")]})]})}),e.jsx(je,{children:e.jsxs(ye,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex flex-1 items-center gap-3 overflow-hidden",children:X.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:X.map(t=>e.jsxs(ee,{variant:"secondary",role:"button",tabIndex:0,className:"cursor-pointer gap-1 hover:bg-destructive/10 hover:text-destructive",onClick:t.onRemove,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.onRemove())},children:[t.label,e.jsx(ke,{className:"h-3 w-3","aria-hidden":"true"})]},t.key))}):e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.filters.allRequests")})}),e.jsxs("div",{className:"flex items-center gap-2 ml-3 flex-shrink-0",children:[X.length>0&&e.jsx(k,{variant:"ghost",size:"sm",onClick:Le,children:s("common.actions.reset")}),e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>Ee(t=>!t),children:ae?e.jsxs(e.Fragment,{children:[s("common.filters.collapse"),e.jsx(Be,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[s("common.filters.expand"),e.jsx(He,{className:"ml-1 h-4 w-4"})]})})]})]}),ae&&e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2 xl:grid-cols-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.provider")}),e.jsxs(I,{value:d,onValueChange:g,children:[e.jsx(q,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(w,{value:"all",children:s("logs.filters.providerAll")}),J.map(t=>e.jsx(w,{value:t.id,children:t.label??t.id},t.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.endpoint")}),e.jsxs(I,{value:p,onValueChange:l,children:[e.jsx(q,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(w,{value:"all",children:s("logs.filters.endpointAll")}),e.jsx(w,{value:"anthropic",children:s("logs.filters.endpointAnthropic")}),e.jsx(w,{value:"openai",children:s("logs.filters.endpointOpenAI")}),(fe=(he=V.data)==null?void 0:he.endpoints)==null?void 0:fe.map(t=>e.jsx(w,{value:t.id,children:t.label||t.id},t.id))]})]})]}),e.jsx(Xe,{className:"md:col-span-2",apiKeys:Y,selected:E,disabled:ne.isLoading,onChange:Q}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.modelId")}),e.jsx(Z,{value:c,onChange:t=>j(t.target.value),placeholder:s("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.status")}),e.jsxs(I,{value:m,onValueChange:t=>v(t),children:[e.jsx(q,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(w,{value:"all",children:s("logs.filters.statusAll")}),e.jsx(w,{value:"success",children:s("logs.filters.statusSuccess")}),e.jsx(w,{value:"error",children:s("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.startDate")}),e.jsx(Z,{type:"date",value:a,onChange:t=>h(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.endDate")}),e.jsx(Z,{type:"date",value:n,onChange:t=>u(t.target.value)})]})]})]})}),e.jsx(je,{children:e.jsxs(ye,{className:"p-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:W,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1200px] text-sm",children:[e.jsx("thead",{className:"border-b bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.time")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.endpoint")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.provider")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.requestedModel")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.routedModel")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.apiKey")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.inputTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.cacheReadTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.cacheCreationTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.outputTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.latency")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.ttft")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.tpot")}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium",children:s("logs.table.columns.status")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.error")}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium",children:s("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y",children:y.isPending?Array.from({length:8}).map((t,r)=>e.jsx(Ie,{columns:16},r)):re.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:16,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:s("logs.table.empty")})}):re.map((t,r)=>e.jsx(Ve,{record:t,providerLabelMap:O,apiKeyMap:ce,onSelect:De,isEven:r%2===0},t.id))})]})}),Ce&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-t p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.table.pagination.perPage")}),e.jsxs(I,{value:N.toString(),onValueChange:t=>G(Number(t)),children:[e.jsx(q,{className:"w-[80px]",children:e.jsx(U,{})}),e.jsx(B,{children:ve.map(t=>e.jsx(w,{value:t.toString(),children:t},t))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>f(t=>Math.max(t-1,1)),disabled:x<=1,children:s("logs.table.pagination.previous")}),e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.table.pagination.pageLabel",{page:b===0?0:x,total:b})}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>f(t=>b===0?t:Math.min(t+1,b)),disabled:b===0||x>=b,children:s("logs.table.pagination.next")})]})]})]})}),e.jsx(Je,{open:_e,logId:A,onClose:$e,providerLabelMap:O,apiKeyMap:ce})]})}function Ve({record:s,providerLabelMap:i,apiKeyMap:d,onSelect:g,isEven:p}){const{t:l}=H(),c=i.get(s.provider)??s.provider,j=s.endpoint||"-",m=!!s.error,v=s.status_code,a=s.client_model??l("logs.table.requestedModelFallback"),h=s.api_key_id!=null?d.get(s.api_key_id):void 0,n=s.api_key_id==null?l("logs.table.apiKeyUnknown"):h!=null&&h.isWildcard?l("apiKeys.wildcard"):h!=null&&h.name?h.name:s.api_key_name?s.api_key_name:l("logs.table.apiKeyUnknown");return e.jsxs("tr",{className:$("transition-colors",p?"bg-muted/30":"","hover:bg-muted/50"),children:[e.jsx("td",{className:"px-3 py-2 text-xs",children:Se(s.timestamp)}),e.jsx("td",{className:"px-3 py-2 text-xs",children:j}),e.jsx("td",{className:"px-3 py-2 text-xs",children:e.jsx("div",{className:"max-w-[100px] truncate",title:c,children:c})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:e.jsx("div",{className:"max-w-[120px] truncate",title:a,children:a})}),e.jsx("td",{className:"px-3 py-2 text-xs",children:e.jsx("div",{className:"max-w-[120px] truncate",title:s.model,children:s.model})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:e.jsx("div",{className:"max-w-[90px] truncate",title:n,children:n})}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:_(s.input_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:_(s.cache_read_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:_(s.cache_creation_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:_(s.output_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:T(s.latency_ms,"ms")}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:T(s.ttft_ms,"ms")}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:T(s.tpot_ms,"ms/tk")}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx(ee,{variant:m?"destructive":"default",className:"text-xs",children:v??(m?500:200)})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:e.jsx("div",{className:"max-w-[100px] truncate",title:s.error??"",children:s.error?s.error:"-"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx(k,{variant:"outline",size:"sm",onClick:()=>g(s.id),children:l("logs.actions.detail")})})]})}function Je({open:s,logId:i,onClose:d,providerLabelMap:g,apiKeyMap:p}){var u,x;const{t:l}=H(),{pushToast:c}=we(),j=o.useRef(null),m=D(["log-detail",i],{url:`/api/logs/${i}`,method:"GET"},{enabled:s&&i!==null,staleTime:3e4});o.useEffect(()=>{m.isError&&m.error&&c({title:l("logs.detail.loadError"),description:m.error.message,variant:"error"})},[m.isError,m.error,c,l]),o.useEffect(()=>{if(!s)return;const f=N=>{N.key==="Escape"&&d()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,d]),o.useEffect(()=>{s&&j.current&&j.current.focus()},[s,i]);const v=o.useCallback(async(f,N,G)=>{if(!N){c({title:l("logs.detail.copy.empty",{label:f}),variant:"info"});return}try{await Ue(N),c({title:l(G),variant:"success"})}catch(A){c({title:l("logs.detail.copy.failure"),description:A instanceof Error?A.message:l("logs.detail.copy.failureFallback"),variant:"error"})}},[c,l]);if(!s)return null;const a=m.data,h=a?g.get(a.provider)??a.provider:"",n=a&&a.api_key_id!=null?p.get(a.api_key_id):void 0;return typeof document>"u"?null:Oe.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm animate-in fade-in duration-200",onClick:d}),e.jsxs("aside",{role:"dialog","aria-modal":"true",className:"flex h-full w-full max-w-xl flex-col border-l bg-card shadow-xl animate-in slide-in-from-right duration-300",children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-6 py-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:l("logs.detail.title")}),a&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l("logs.detail.id",{id:a.id})})]}),e.jsxs(k,{ref:j,variant:"outline",size:"sm",onClick:d,children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),l("common.actions.close")]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:m.isPending?e.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[e.jsx(K,{className:"h-5 w-40"}),e.jsx(K,{className:"h-4 w-full"}),e.jsx(K,{className:"h-4 w-3/4"}),e.jsx(K,{className:"h-32 w-full"}),e.jsx(K,{className:"h-4 w-1/2"})]}):a?e.jsxs("div",{className:"flex flex-col gap-6 px-6 py-5 text-sm",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.infoSection")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md bg-muted p-3 text-xs",children:[e.jsx("span",{className:"font-medium",children:l("logs.detail.summary.route",{from:a.client_model??l("logs.detail.info.noRequestedModel"),to:a.model})}),e.jsx("span",{className:"text-muted-foreground",children:l("logs.detail.summary.latency",{value:T(a.latency_ms,l("common.units.ms"))})}),a.ttft_ms!==null&&e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",T(a.ttft_ms,l("common.units.ms"))]}),e.jsx(ee,{variant:a.error?"destructive":"default",children:(a.status_code??(a.error?500:200)).toString()})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.time")}),e.jsx("dd",{className:"font-medium",children:Se(a.timestamp)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.sessionId")}),e.jsx("dd",{className:"font-medium",children:a.session_id??"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.endpoint")}),e.jsx("dd",{className:"font-medium",children:a.endpoint||"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.provider")}),e.jsx("dd",{className:"font-medium",children:h})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.requestedModel")}),e.jsx("dd",{className:"font-medium",children:a.client_model??l("logs.detail.info.noRequestedModel")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.model")}),e.jsx("dd",{className:"font-medium",children:a.model})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.stream")}),e.jsx("dd",{className:"font-medium",children:We(a.stream)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.inputTokens")}),e.jsx("dd",{className:"font-medium",children:_(a.input_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.cacheReadTokens")}),e.jsx("dd",{className:"font-medium",children:_(a.cache_read_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.cacheCreationTokens")}),e.jsx("dd",{className:"font-medium",children:_(a.cache_creation_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.outputTokens")}),e.jsx("dd",{className:"font-medium",children:_(a.output_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.ttft")}),e.jsx("dd",{className:"font-medium",children:T(a.ttft_ms,l("common.units.ms"))})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.tpot")}),e.jsx("dd",{className:"font-medium",children:T(a.tpot_ms,l("common.units.msPerToken"))})]})]}),a.error&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.error")}),e.jsx("p",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:a.error})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.apiKey.title")}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.name")}),e.jsx("dd",{className:"font-medium",children:a.api_key_id==null&&!a.api_key_name?l("logs.detail.apiKey.missing"):n!=null&&n.isWildcard?l("apiKeys.wildcard"):(n==null?void 0:n.name)??a.api_key_name??l("logs.detail.apiKey.missing")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.identifier")}),e.jsx("dd",{className:"font-medium",children:a.api_key_id??l("common.noData")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.masked")}),e.jsx("dd",{className:"font-medium",children:n!=null&&n.isWildcard?l("apiKeys.wildcard"):(n==null?void 0:n.maskedKey)??a.api_key_name??l("logs.detail.apiKey.maskedUnavailable")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.lastUsed")}),e.jsx("dd",{className:"font-medium",children:n!=null&&n.lastUsedAt?new Date(n.lastUsedAt).toLocaleString():l("common.noData")})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:l("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:a.api_key_value_available?a.api_key_value_masked??l("logs.detail.apiKey.rawUnavailable"):l("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:l("logs.detail.apiKey.rawMaskedHint")})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.payload.request")}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>{var f;return v(l("logs.detail.payload.request"),(f=a.payload)==null?void 0:f.prompt,"logs.detail.copy.requestSuccess")},children:l("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap rounded-md border bg-muted p-3 text-xs",children:be((u=a.payload)==null?void 0:u.prompt,l("logs.detail.payload.emptyRequest"))})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.payload.response")}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>{var f;return v(l("logs.detail.payload.response"),(f=a.payload)==null?void 0:f.response,"logs.detail.copy.responseSuccess")},children:l("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap rounded-md border bg-muted p-3 text-xs",children:be((x=a.payload)==null?void 0:x.response,l("logs.detail.payload.emptyResponse"))})]})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:l("logs.detail.loadError")})})]})]}),document.body)}function Xe({apiKeys:s,selected:i,onChange:d,disabled:g,className:p}){const{t:l}=H(),[c,j]=o.useState(!1),m=o.useRef(null);o.useEffect(()=>{if(!c)return;const n=u=>{var x;(x=m.current)!=null&&x.contains(u.target)||j(!1)};return window.addEventListener("mousedown",n),()=>window.removeEventListener("mousedown",n)},[c]);const v=o.useMemo(()=>{if(i.length===0)return[];const n=new Map;for(const u of s)n.set(u.id,u);return i.map(u=>{const x=n.get(u);return x?x.isWildcard?l("apiKeys.wildcard"):x.name:null}).filter(u=>!!u)},[s,i,l]),a=i.length===0?l("logs.filters.apiKeyAll"):l("logs.filters.apiKeySelected",{count:i.length}),h=n=>{i.includes(n)?d(i.filter(u=>u!==n)):d([...i,n])};return e.jsxs("div",{className:$("relative space-y-2",p),ref:m,children:[e.jsx(C,{children:l("logs.filters.apiKey")}),e.jsxs("button",{type:"button",onClick:()=>j(n=>!n),disabled:g||s.length===0,title:l("logs.filters.apiKeyHint"),className:$("flex h-10 w-full items-center justify-between rounded-md border bg-background px-3 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",i.length>0&&"border-primary",c&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[a,v.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:v.join(", ")})]}),e.jsx("svg",{className:$("h-4 w-4 opacity-50 transition-transform",c&&"rotate-180"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.25a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z",clipRule:"evenodd"})})]}),c&&e.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border bg-popover p-2 shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-muted px-3 py-2 text-xs",children:[e.jsx("span",{children:a}),e.jsx("button",{type:"button",onClick:()=>d([]),disabled:i.length===0,className:"text-primary hover:underline disabled:opacity-40",children:l("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[s.map(n=>{const u=n.isWildcard?l("apiKeys.wildcard"):n.name,x=i.includes(n.id);return e.jsxs("label",{className:$("flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm transition hover:bg-muted",x&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border",checked:x,onChange:()=>h(n.id)}),e.jsx("span",{className:"truncate",children:u})]},n.id)}),s.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:l("logs.filters.apiKeyAll")})]})]})]})}export{os as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var dt=t=>{throw TypeError(t)};var Ve=(t,a,o)=>a.has(t)||dt("Cannot "+o);var O=(t,a,o)=>(Ve(t,a,"read from private field"),o?o.call(t):a.get(t)),ue=(t,a,o)=>a.has(t)?dt("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(t):a.set(t,o),me=(t,a,o,c)=>(Ve(t,a,"write to private field"),c?c.call(t,o):a.set(t,o),o),pe=(t,a,o)=>(Ve(t,a,"access private method"),o);import{c as vs,S as js,s as ys,h as ct,i as Ns,n as bt,k as vt,r as f,l as ks,m as ws,o as jt,p as Ms,j as e,R as Cs,q as Es,v as Ps,w as yt,P as Nt,x as Ne,A as kt,y as wt,z as Rs,D as Ss,E as Ds,G as Os,H as As,I as Ts,J as Is,K as Us,M as Fs,a as ke,u as ge,b as Mt,e as I,N as _s,X as Te,d as W,O as we,t as Ie,C as Ls,T as $s,Q as Ks,U as zs,V as Bs}from"./index-
|
|
1
|
+
var dt=t=>{throw TypeError(t)};var Ve=(t,a,o)=>a.has(t)||dt("Cannot "+o);var O=(t,a,o)=>(Ve(t,a,"read from private field"),o?o.call(t):a.get(t)),ue=(t,a,o)=>a.has(t)?dt("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(t):a.set(t,o),me=(t,a,o,c)=>(Ve(t,a,"write to private field"),c?c.call(t,o):a.set(t,o),o),pe=(t,a,o)=>(Ve(t,a,"access private method"),o);import{c as vs,S as js,s as ys,h as ct,i as Ns,n as bt,k as vt,r as f,l as ks,m as ws,o as jt,p as Ms,j as e,R as Cs,q as Es,v as Ps,w as yt,P as Nt,x as Ne,A as kt,y as wt,z as Rs,D as Ss,E as Ds,G as Os,H as As,I as Ts,J as Is,K as Us,M as Fs,a as ke,u as ge,b as Mt,e as I,N as _s,X as Te,d as W,O as we,t as Ie,C as Ls,T as $s,Q as Ks,U as zs,V as Bs}from"./index-Blclkvp7.js";import{u as Vs,a as qs}from"./useApiQuery-DiX6xcfY.js";import{P as Hs,B as Q}from"./PageHeader-D2u2opjK.js";import{I as xe}from"./input-CGgq_gCJ.js";import{L as de}from"./label-BGUvZ4t2.js";import{C as qe,a as He}from"./card-C9wVDhpJ.js";import{S as Ct}from"./switch-XbPwmM_b.js";import{S as Gs,a as Qs,b as Js,c as Xs,d as ut,e as Ws}from"./select-Chuh7X1A.js";import{P as Je,D as Et,a as Pt,b as Rt,c as St,d as Dt,e as Ot}from"./dialog-DbEoPxgf.js";import{R as Ys}from"./refresh-cw-D7rJxbFV.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,a as s,am as n}from"./index-
|
|
1
|
+
import{j as r,a as s,am as n}from"./index-Blclkvp7.js";const l=n("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 shadow-sm",{variants:{variant:{default:"border-primary/20 bg-primary/10 text-primary hover:bg-primary/15 dark:border-primary/30 dark:bg-primary/20 dark:text-primary-foreground",secondary:"border-slate-200 bg-slate-100 text-slate-700 hover:bg-slate-200 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300",destructive:"border-red-200 bg-gradient-to-r from-red-50 to-red-100 text-red-700 hover:from-red-100 hover:to-red-150 dark:border-red-800 dark:from-red-950 dark:to-red-900 dark:text-red-300",outline:"border-slate-300 bg-transparent text-slate-600 hover:bg-slate-50 dark:border-slate-600 dark:text-slate-400 dark:hover:bg-slate-800",success:"border-emerald-200 bg-gradient-to-r from-emerald-50 to-emerald-100 text-emerald-700 hover:from-emerald-100 hover:to-emerald-150 dark:border-emerald-800 dark:from-emerald-950 dark:to-emerald-900 dark:text-emerald-300",warning:"border-amber-200 bg-gradient-to-r from-amber-50 to-amber-100 text-amber-700 hover:from-amber-100 hover:to-amber-150 dark:border-amber-800 dark:from-amber-950 dark:to-amber-900 dark:text-amber-300",info:"border-cyan-200 bg-gradient-to-r from-cyan-50 to-cyan-100 text-cyan-700 hover:from-cyan-100 hover:to-cyan-150 dark:border-cyan-800 dark:from-cyan-950 dark:to-cyan-900 dark:text-cyan-300",purple:"border-violet-200 bg-gradient-to-r from-violet-50 to-violet-100 text-violet-700 hover:from-violet-100 hover:to-violet-150 dark:border-violet-800 dark:from-violet-950 dark:to-violet-900 dark:text-violet-300",pink:"border-pink-200 bg-gradient-to-r from-pink-50 to-pink-100 text-pink-700 hover:from-pink-100 hover:to-pink-150 dark:border-pink-800 dark:from-pink-950 dark:to-pink-900 dark:text-pink-300"}},defaultVariants:{variant:"default"}});function m({className:e,variant:t,...a}){return r.jsx("div",{className:s(l({variant:t}),e),...a})}function f({icon:e,title:t,description:a,badge:o,actions:d,className:i}){return r.jsxs("div",{className:s("flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",i),children:[r.jsxs("div",{className:"flex flex-1 flex-wrap items-start gap-4",children:[e&&r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t}),o&&r.jsx(m,{variant:"secondary",children:o})]}),a&&r.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:a})]})]}),d&&r.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:d})]})}export{m as B,f as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,a as d}from"./index-
|
|
1
|
+
import{j as s,a as d}from"./index-Blclkvp7.js";import{C as m,b as l,c as i,d as j,a as f}from"./card-C9wVDhpJ.js";function p({title:a,description:e,actions:r,className:n,contentClassName:x,children:c}){const t=a||e||r;return s.jsxs(m,{className:n,children:[t&&s.jsxs(l,{className:"flex flex-row items-start justify-between space-y-0",children:[s.jsxs("div",{className:"space-y-1.5",children:[typeof a=="string"?s.jsx(i,{className:"text-base",children:a}):a,e&&(typeof e=="string"?s.jsx(j,{children:e}):s.jsx("div",{className:"text-sm text-muted-foreground",children:e}))]}),r&&s.jsx("div",{className:"flex shrink-0 items-center gap-2",children:r})]}),s.jsx(f,{className:d(!t&&"pt-6",x),children:c})]})}export{p as P};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as Be,u as _e,b as Ge,r as h,j as e,e as E,a3 as Qe,W as be,a as We,d as O}from"./index-Blclkvp7.js";import{u as fe}from"./useApiQuery-DiX6xcfY.js";import{P as ze}from"./PageHeader-D2u2opjK.js";import{c as $e}from"./clipboard-CALi6bTW.js";import{I as f}from"./input-CGgq_gCJ.js";import{L as l}from"./label-BGUvZ4t2.js";import{C as R,a as T}from"./card-C9wVDhpJ.js";import{S as L}from"./switch-XbPwmM_b.js";import{S as Je,a as Ue,b as Xe,c as Ye,d as Ze}from"./select-Chuh7X1A.js";import{S as et,C as tt}from"./shield-Beuqdf31.js";/**
|
|
2
|
+
* @license lucide-react v0.344.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const z=Be("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),st=[{value:"fatal",labelKey:"fatal"},{value:"error",labelKey:"error"},{value:"warn",labelKey:"warn"},{value:"info",labelKey:"info"},{value:"debug",labelKey:"debug"},{value:"trace",labelKey:"trace"}],je=[{id:"section-basics",labelKey:"settings.sections.basics"},{id:"section-protocol",labelKey:"settings.sections.protocol"},{id:"section-security",labelKey:"settings.sections.security"},{id:"section-config-file",labelKey:"settings.sections.configFile"},{id:"section-cleanup",labelKey:"settings.sections.cleanup"}];function pt(){const{t}=_e(),{pushToast:g}=Ge(),[ye,ve]=h.useState(je[0].id),D=h.useRef(new Map),Ne=h.useCallback(s=>{const a=D.current.get(s);a&&a.scrollIntoView({behavior:"smooth",block:"start"})},[]),H=h.useCallback(s=>a=>{a?D.current.set(s,a):D.current.delete(s)},[]),j=fe(["config","info"],{url:"/api/config/info",method:"GET"}),y=fe(["auth","web"],{url:"/api/auth/web",method:"GET"}),[r,$]=h.useState(null),[B,Pe]=h.useState(""),[n,u]=h.useState({port:"",host:"",logRetentionDays:"",logExportTimeoutSeconds:"60",storeRequestPayloads:!0,storeResponsePayloads:!0,logLevel:"info",requestLogging:!0,responseLogging:!0,bodyLimitMb:"10",enableRoutingFallback:!1,httpEnabled:!0,httpPort:"4100",httpHost:"127.0.0.1",httpsEnabled:!1,httpsPort:"4443",httpsHost:"127.0.0.1",httpsKeyPath:"",httpsCertPath:"",httpsCaPath:""}),[p,J]=h.useState({}),[_,U]=h.useState(!1),[X,Y]=h.useState(!1),[Z,ee]=h.useState(!1),[d,te]=h.useState(null),[c,S]=h.useState({enabled:!1,username:"",password:"",confirmPassword:""}),[F,V]=h.useState({}),[G,se]=h.useState(!1),ke=h.useMemo(()=>{if(!r)return null;const s=r.defaults;if(!s)return null;const a=[];return s.completion&&a.push(t("settings.defaults.completion",{model:s.completion})),s.reasoning&&a.push(t("settings.defaults.reasoning",{model:s.reasoning})),s.background&&a.push(t("settings.defaults.background",{model:s.background})),a.length>0?a.join(" | "):t("settings.defaults.none")},[r,t]),ae=h.useMemo(()=>c.enabled?d!=null&&d.hasPassword?c.username.trim()!==((d==null?void 0:d.username)??""):!0:!1,[c.enabled,c.username,d]);h.useEffect(()=>{var s,a,i,m,v,b,k,w,C,N,A;if(j.data){$(j.data.config),Pe(j.data.path);const M=j.data.config.storePayloads,K=P=>typeof P=="boolean"?P:typeof M=="boolean"?M:!0,o=j.data.config;u({port:String(o.port??((s=o.http)==null?void 0:s.port)??""),host:o.host??((a=o.http)==null?void 0:a.host)??"127.0.0.1",logRetentionDays:String(o.logRetentionDays??30),logExportTimeoutSeconds:String(o.logExportTimeoutSeconds??60),storeRequestPayloads:K(o.storeRequestPayloads),storeResponsePayloads:K(o.storeResponsePayloads),logLevel:o.logLevel??"info",requestLogging:o.requestLogging!==!1,responseLogging:o.responseLogging??o.requestLogging!==!1,bodyLimitMb:(()=>{const P=o.bodyLimit;return typeof P=="number"&&Number.isFinite(P)&&P>0?String(Math.max(1,Math.round(P/(1024*1024)))):"10"})(),enableRoutingFallback:o.enableRoutingFallback===!0,httpEnabled:((i=o.http)==null?void 0:i.enabled)!==!1,httpPort:String(((m=o.http)==null?void 0:m.port)??o.port??4100),httpHost:((v=o.http)==null?void 0:v.host)??o.host??"127.0.0.1",httpsEnabled:((b=o.https)==null?void 0:b.enabled)===!0,httpsPort:String(((k=o.https)==null?void 0:k.port)??4443),httpsHost:((w=o.https)==null?void 0:w.host)??o.host??"127.0.0.1",httpsKeyPath:((C=o.https)==null?void 0:C.keyPath)??"",httpsCertPath:((N=o.https)==null?void 0:N.certPath)??"",httpsCaPath:((A=o.https)==null?void 0:A.caPath)??""})}},[j.data]),h.useEffect(()=>{y.data&&(te(y.data),S({enabled:y.data.enabled,username:y.data.username??"",password:"",confirmPassword:""}),V({}))},[y.data]),h.useEffect(()=>{j.isError&&j.error&&g({title:t("settings.toast.loadFailure",{message:j.error.message}),variant:"error"})},[j.isError,j.error,g,t]),h.useEffect(()=>{y.isError&&y.error&&g({title:t("settings.toast.authLoadFailure",{message:y.error.message}),variant:"error"})},[y.isError,y.error,g,t]);const q=s=>a=>{u(i=>({...i,[s]:a}))},we=()=>{const s={};if(!n.httpEnabled&&!n.httpsEnabled&&(s.protocol="至少需要启用 HTTP 或 HTTPS 协议"),n.httpEnabled){const b=Number(n.httpPort);(!Number.isFinite(b)||b<1||b>65535)&&(s.httpPort="HTTP 端口必须在 1-65535 之间")}if(n.httpsEnabled){const b=Number(n.httpsPort);(!Number.isFinite(b)||b<1||b>65535)&&(s.httpsPort="HTTPS 端口必须在 1-65535 之间"),(!n.httpsKeyPath||!n.httpsCertPath)&&(s.protocol="HTTPS 已启用但缺少证书路径,请手动配置受信任的证书")}const a=Number(n.port);(!Number.isFinite(a)||a<1||a>65535)&&(s.port=t("settings.validation.port"));const i=Number(n.logRetentionDays);(!Number.isFinite(i)||i<1||i>365)&&(s.logRetentionDays=t("settings.validation.retention"));const m=Number(n.logExportTimeoutSeconds);(!Number.isFinite(m)||m<5||m>600)&&(s.logExportTimeoutSeconds=t("settings.validation.logExportTimeout"));const v=Number(n.bodyLimitMb);return(!Number.isFinite(v)||v<1||v>2048)&&(s.bodyLimitMb=t("settings.validation.bodyLimit")),J(s),Object.keys(s).length===0},Ce=()=>{const s={},a=c.username.trim(),i=d?a!==(d.username??""):!0,m=c.enabled&&(!(d!=null&&d.hasPassword)||i);return c.enabled&&!a&&(s.username=t("settings.auth.validation.username")),c.password&&c.password.length<6&&(s.password=t("settings.auth.validation.minLength")),m&&!c.password&&(s.password=t("settings.auth.validation.passwordRequired")),(c.password||c.confirmPassword)&&c.password!==c.confirmPassword&&(s.confirmPassword=t("settings.auth.validation.confirmMismatch")),V(s),Object.keys(s).length===0},Le=async()=>{var s,a,i,m,v,b,k,w,C,N,A,M,K,o,P,re,ne,oe,ie,le,ce,de,me,he,pe,ue;if(!r){g({title:t("settings.toast.loadFailure",{message:t("settings.toast.missingConfig")}),variant:"error"});return}if(we()){U(!0);try{const I=Number(n.port),qe=Number(n.logRetentionDays),Ae=Number(n.logExportTimeoutSeconds),Me=Number(n.bodyLimitMb),x={...r,http:{enabled:n.httpEnabled,port:Number(n.httpPort),host:n.httpHost.trim()||"127.0.0.1"},https:{enabled:n.httpsEnabled,port:Number(n.httpsPort),host:n.httpsHost.trim()||"127.0.0.1",keyPath:n.httpsKeyPath.trim(),certPath:n.httpsCertPath.trim(),caPath:n.httpsCaPath.trim()||void 0},port:I,host:n.host.trim()||void 0,logRetentionDays:qe,logExportTimeoutSeconds:Math.min(Math.max(Math.round(Ae),5),600),storeRequestPayloads:n.storeRequestPayloads,storeResponsePayloads:n.storeResponsePayloads,logLevel:n.logLevel,requestLogging:n.requestLogging,responseLogging:n.responseLogging,bodyLimit:Math.max(1,Math.floor(Me*1024*1024)),enableRoutingFallback:n.enableRoutingFallback},ge={...x};delete ge.webAuth,await O.put("/api/config",ge),$({...x,webAuth:r.webAuth});const xe=W=>(W==null?void 0:W.trim())||void 0,Ke=r.port??((s=r.http)==null?void 0:s.port)??4100,De=x.port??((a=x.http)==null?void 0:a.port)??4100,Ve=((i=r.host)==null?void 0:i.trim())||((v=(m=r.http)==null?void 0:m.host)==null?void 0:v.trim())||"127.0.0.1",Ie=((b=x.host)==null?void 0:b.trim())||((w=(k=x.http)==null?void 0:k.host)==null?void 0:w.trim())||"127.0.0.1",Oe=Ke!==De||Ve!==Ie||((C=r.http)==null?void 0:C.enabled)!==((N=x.http)==null?void 0:N.enabled)||((A=r.http)==null?void 0:A.port)!==((M=x.http)==null?void 0:M.port)||(((K=r.http)==null?void 0:K.host)??r.host??"127.0.0.1")!==(((o=x.http)==null?void 0:o.host)??x.host??"127.0.0.1")||((P=r.https)==null?void 0:P.enabled)!==((re=x.https)==null?void 0:re.enabled)||((ne=r.https)==null?void 0:ne.port)!==((oe=x.https)==null?void 0:oe.port)||(((ie=r.https)==null?void 0:ie.host)??r.host??"127.0.0.1")!==(((le=x.https)==null?void 0:le.host)??x.host??"127.0.0.1")||((ce=r.https)==null?void 0:ce.keyPath)!==((de=x.https)==null?void 0:de.keyPath)||((me=r.https)==null?void 0:me.certPath)!==((he=x.https)==null?void 0:he.certPath)||xe((pe=r.https)==null?void 0:pe.caPath)!==xe((ue=x.https)==null?void 0:ue.caPath);g(Oe?{title:t("settings.toast.protocolRestartRequired"),variant:"success"}:{title:t("settings.toast.saveSuccess"),variant:"success"}),j.refetch()}catch(I){g({title:t("settings.toast.saveFailure",{message:I instanceof Error?I.message:"unknown"}),variant:"error"})}finally{U(!1)}}},Se=()=>{var s,a,i,m,v,b,k,w,C;r&&(u({port:String(r.port??""),host:r.host??"",logRetentionDays:String(r.logRetentionDays??30),logExportTimeoutSeconds:String(r.logExportTimeoutSeconds??60),storeRequestPayloads:typeof r.storeRequestPayloads=="boolean"?r.storeRequestPayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,storeResponsePayloads:typeof r.storeResponsePayloads=="boolean"?r.storeResponsePayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,logLevel:r.logLevel??"info",requestLogging:r.requestLogging!==!1,responseLogging:r.responseLogging??r.requestLogging!==!1,bodyLimitMb:(()=>{const N=r.bodyLimit;return typeof N=="number"&&Number.isFinite(N)&&N>0?String(Math.max(1,Math.round(N/(1024*1024)))):"10"})(),enableRoutingFallback:r.enableRoutingFallback===!0,httpEnabled:((s=r.http)==null?void 0:s.enabled)!==!1,httpPort:String(((a=r.http)==null?void 0:a.port)??r.port??4100),httpHost:((i=r.http)==null?void 0:i.host)??r.host??"127.0.0.1",httpsEnabled:((m=r.https)==null?void 0:m.enabled)===!0,httpsPort:String(((v=r.https)==null?void 0:v.port)??4443),httpsHost:((b=r.https)==null?void 0:b.host)??r.host??"127.0.0.1",httpsKeyPath:((k=r.https)==null?void 0:k.keyPath)??"",httpsCertPath:((w=r.https)==null?void 0:w.certPath)??"",httpsCaPath:((C=r.https)==null?void 0:C.caPath)??""}),J({}))},Ee=async()=>{var s;if(Ce()){se(!0);try{const a={enabled:c.enabled,username:c.username.trim()||void 0};c.password&&(a.password=c.password);const m=(s=(await O.post("/api/auth/web",a)).data)==null?void 0:s.auth;m&&(te(m),S({enabled:m.enabled,username:m.username??"",password:"",confirmPassword:""}),V({})),g({title:t("settings.auth.toast.success"),variant:"success"}),y.refetch()}catch(a){const i=a instanceof Error?a.message:"unknown";g({title:t("settings.auth.toast.failure",{message:i}),variant:"error"})}finally{se(!1)}}},Re=()=>{d&&(S({enabled:d.enabled,username:d.username??"",password:"",confirmPassword:""}),V({}))},Te=async()=>{if(!B){g({title:t("settings.toast.copyFailure",{message:t("settings.file.unknown")}),variant:"error"});return}try{await $e(B),g({title:t("settings.toast.copySuccess"),variant:"success"})}catch(s){g({title:t("settings.toast.copyFailure",{message:s instanceof Error?s.message:"unknown"}),variant:"error"})}},Fe=async()=>{Y(!0);try{const a=(await O.post("/api/logs/cleanup")).data.deleted??0;g({title:a>0?t("settings.toast.cleanupSuccess",{count:a}):t("settings.toast.cleanupNone"),variant:"success"})}catch(s){g({title:t("settings.toast.cleanupFailure",{message:s instanceof Error?s.message:"unknown"}),variant:"error"})}finally{Y(!1)}},He=async()=>{ee(!0);try{const s=await O.post("/api/logs/clear"),{deleted:a,metricsCleared:i}=s.data;g({title:t("settings.toast.clearAllSuccess",{logs:a,metrics:i}),variant:"success"})}catch(s){g({title:t("settings.toast.clearAllFailure",{message:s instanceof Error?s.message:"unknown"}),variant:"error"})}finally{ee(!1)}},Q=j.isPending||!r&&j.isFetching;return h.useEffect(()=>{if(Q)return;const s=Array.from(D.current.values());if(s.length===0)return;const a=new IntersectionObserver(i=>{for(const m of i)if(m.isIntersecting){ve(m.target.id);break}},{rootMargin:"-80px 0px -60% 0px",threshold:0});for(const i of s)a.observe(i);return()=>a.disconnect()},[Q]),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ze,{icon:e.jsx(Qe,{className:"h-5 w-5","aria-hidden":"true"}),title:t("settings.title"),description:t("settings.description"),actions:r?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"outline",onClick:Se,disabled:_,children:t("common.actions.reset")}),e.jsx(E,{onClick:()=>void Le(),disabled:_,children:t(_?"common.actions.saving":"common.actions.save")})]}):null}),Q?e.jsx(R,{children:e.jsx(T,{className:"flex min-h-[220px] items-center justify-center",children:e.jsx(be,{})})}):r?e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[200px_1fr] gap-6",children:[e.jsx("nav",{className:"hidden xl:block",children:e.jsxs("div",{className:"sticky top-20 space-y-1",children:[e.jsx("p",{className:"mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:t("settings.sections.jump")}),je.map(s=>e.jsx("button",{type:"button",onClick:()=>Ne(s.id),className:We("block w-full rounded-md px-3 py-2 text-left text-sm transition-colors",ye===s.id?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:t(s.labelKey)},s.id))]})}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(R,{id:"section-basics",ref:H("section-basics"),children:e.jsxs(T,{className:"pt-6",children:[e.jsx("h3",{className:"mb-4 text-sm font-semibold",children:t("settings.sections.basics")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.fields.port")}),e.jsx(f,{type:"number",min:1,max:65535,value:n.port,onChange:s=>q("port")(s.target.value),"aria-invalid":!!p.port}),p.port&&e.jsx("p",{className:"text-xs text-destructive",children:p.port})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.fields.host")}),e.jsx(f,{value:n.host,onChange:s=>q("host")(s.target.value),placeholder:t("settings.fields.hostPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.fields.retention")}),e.jsx(f,{type:"number",min:1,max:365,value:n.logRetentionDays,onChange:s=>q("logRetentionDays")(s.target.value),"aria-invalid":!!p.logRetentionDays}),p.logRetentionDays&&e.jsx("p",{className:"text-xs text-destructive",children:p.logRetentionDays})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.fields.logExportTimeout")}),e.jsx(f,{type:"number",min:5,max:600,value:n.logExportTimeoutSeconds,onChange:s=>q("logExportTimeoutSeconds")(s.target.value),"aria-invalid":!!p.logExportTimeoutSeconds}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.logExportTimeoutHint")}),p.logExportTimeoutSeconds&&e.jsx("p",{className:"text-xs text-destructive",children:p.logExportTimeoutSeconds})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.fields.bodyLimit")}),e.jsx(f,{type:"number",min:1,max:2048,value:n.bodyLimitMb,onChange:s=>q("bodyLimitMb")(s.target.value),"aria-invalid":!!p.bodyLimitMb}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.bodyLimitHint")}),p.bodyLimitMb&&e.jsx("p",{className:"text-xs text-destructive",children:p.bodyLimitMb})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.fields.logLevel")}),e.jsxs(Je,{value:n.logLevel,onValueChange:s=>u(a=>({...a,logLevel:s})),children:[e.jsx(Ue,{children:e.jsx(Xe,{})}),e.jsx(Ye,{children:st.map(s=>e.jsx(Ze,{value:s.value,children:t(`settings.fields.logLevelOption.${s.labelKey}`)},s.value))})]})]}),e.jsxs("div",{className:"md:col-span-2 grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{className:"text-sm font-medium",children:t("settings.fields.storeRequestPayloads")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.storeRequestPayloadsHint")})]}),e.jsx(L,{checked:n.storeRequestPayloads,onCheckedChange:s=>u(a=>({...a,storeRequestPayloads:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{className:"text-sm font-medium",children:t("settings.fields.storeResponsePayloads")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.storeResponsePayloadsHint")})]}),e.jsx(L,{checked:n.storeResponsePayloads,onCheckedChange:s=>u(a=>({...a,storeResponsePayloads:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{className:"text-sm font-medium",children:t("settings.fields.requestLogging")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.requestLoggingHint")})]}),e.jsx(L,{checked:n.requestLogging,onCheckedChange:s=>u(a=>({...a,requestLogging:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{className:"text-sm font-medium",children:t("settings.fields.responseLogging")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.responseLoggingHint")})]}),e.jsx(L,{checked:n.responseLogging,onCheckedChange:s=>u(a=>({...a,responseLogging:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-950",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{className:"text-sm font-medium text-amber-700 dark:text-amber-300",children:t("settings.fields.enableRoutingFallback")}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:t("settings.fields.enableRoutingFallbackHint")})]}),e.jsx(L,{checked:n.enableRoutingFallback,onCheckedChange:s=>u(a=>({...a,enableRoutingFallback:s}))})]})]}),e.jsxs("div",{className:"md:col-span-2 rounded-lg border bg-muted/50 p-4",children:[e.jsx(l,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:t("settings.fields.defaults")}),e.jsx("p",{className:"mt-2 text-sm",children:ke??t("settings.defaults.none")})]})]})]})}),e.jsx(R,{id:"section-protocol",ref:H("section-protocol"),children:e.jsxs(T,{className:"pt-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.protocol")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.protocol.description")})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-950",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(z,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t("settings.protocol.restartWarning")}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:t("settings.protocol.restartHint")}),e.jsx("code",{className:"block rounded-md bg-amber-100 px-3 py-2 text-xs font-mono text-amber-900 dark:bg-amber-900 dark:text-amber-100",children:"cc-gw restart --daemon"}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:t("settings.protocol.restartTip")})]})]})}),p.protocol&&e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:[e.jsx(z,{className:"inline h-4 w-4 mr-2"}),p.protocol]}),e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50/50 p-5 dark:border-blue-800 dark:bg-blue-950/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:t("settings.protocol.http.enable")}),e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:t("settings.protocol.http.hint")})]}),e.jsx(L,{checked:n.httpEnabled,onCheckedChange:s=>u(a=>({...a,httpEnabled:s}))})]}),n.httpEnabled&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 mt-4 pt-4 border-t border-blue-200 dark:border-blue-800",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.protocol.http.port")}),e.jsx(f,{type:"number",min:1,max:65535,value:n.httpPort,onChange:s=>u(a=>({...a,httpPort:s.target.value})),"aria-invalid":!!p.httpPort}),p.httpPort&&e.jsx("p",{className:"text-xs text-destructive",children:p.httpPort})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.protocol.http.host")}),e.jsx(f,{value:n.httpHost,onChange:s=>u(a=>({...a,httpHost:s.target.value})),placeholder:"127.0.0.1"})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50/50 p-5 dark:border-green-800 dark:bg-green-950/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"text-sm font-medium text-green-800 dark:text-green-200",children:t("settings.protocol.https.enable")}),e.jsx(et,{className:"h-4 w-4 text-green-600 dark:text-green-400"})]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:t("settings.protocol.https.hint")})]}),e.jsx(L,{checked:n.httpsEnabled,onCheckedChange:s=>u(a=>({...a,httpsEnabled:s}))})]}),n.httpsEnabled&&e.jsxs("div",{className:"space-y-4 mt-4 pt-4 border-t border-green-200 dark:border-green-800",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.protocol.https.port")}),e.jsx(f,{type:"number",min:1,max:65535,value:n.httpsPort,onChange:s=>u(a=>({...a,httpsPort:s.target.value})),"aria-invalid":!!p.httpsPort}),p.httpsPort&&e.jsx("p",{className:"text-xs text-destructive",children:p.httpsPort})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.protocol.https.host")}),e.jsx(f,{value:n.httpsHost,onChange:s=>u(a=>({...a,httpsHost:s.target.value})),placeholder:"127.0.0.1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.protocol.https.keyPath")}),e.jsx(f,{value:n.httpsKeyPath,onChange:s=>u(a=>({...a,httpsKeyPath:s.target.value})),placeholder:"~/.cc-gw/certs/key.pem",className:"font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.protocol.https.certPath")}),e.jsx(f,{value:n.httpsCertPath,onChange:s=>u(a=>({...a,httpsCertPath:s.target.value})),placeholder:"~/.cc-gw/certs/cert.pem",className:"font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.protocol.https.caPath")}),e.jsx(f,{value:n.httpsCaPath,onChange:s=>u(a=>({...a,httpsCaPath:s.target.value})),placeholder:"留空则不使用",className:"font-mono text-xs"})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-950",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(z,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t("settings.protocol.https.warning")}),e.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300 leading-relaxed",children:[e.jsx("strong",{children:t("settings.protocol.https.invalidCert")}),t("settings.protocol.https.invalidCertDetail")]}),e.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300 leading-relaxed",children:[e.jsx("strong",{children:t("settings.protocol.https.recommended")}),t("settings.protocol.https.recommendedDetail")]}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 leading-relaxed",children:t("settings.protocol.https.tip")})]})]})})]})]})]})}),e.jsx(R,{id:"section-security",ref:H("section-security"),children:e.jsxs(T,{className:"pt-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.security")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.auth.description")})]}),y.isPending&&!d?e.jsx("div",{className:"flex min-h-[120px] items-center justify-center",children:e.jsx(be,{})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{className:"text-sm font-medium",children:t("settings.auth.enable")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.auth.enableHint")}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"rounded-full bg-muted px-3 py-1",children:"/ui"}),e.jsx("span",{className:"rounded-full bg-muted px-3 py-1",children:"/api/*"}),e.jsx("span",{className:"rounded-full bg-muted px-3 py-1",children:"Cookie Session"})]})]}),e.jsx(L,{checked:c.enabled,onCheckedChange:s=>S(a=>({...a,enabled:s}))})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(l,{children:t("settings.auth.username")}),e.jsx(f,{value:c.username,onChange:s=>S(a=>({...a,username:s.target.value})),placeholder:t("settings.auth.usernamePlaceholder")}),F.username&&e.jsx("p",{className:"text-xs text-destructive",children:F.username})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.auth.password")}),e.jsx(f,{type:"password",value:c.password,disabled:!c.enabled,onChange:s=>S(a=>({...a,password:s.target.value})),placeholder:t("settings.auth.passwordPlaceholder")}),F.password?e.jsx("p",{className:"text-xs text-destructive",children:F.password}):e.jsx("p",{className:"text-xs text-muted-foreground",children:t(ae?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:t("settings.auth.confirmPassword")}),e.jsx(f,{type:"password",value:c.confirmPassword,disabled:!c.enabled,onChange:s=>S(a=>({...a,confirmPassword:s.target.value})),placeholder:t("settings.auth.confirmPasswordPlaceholder")}),F.confirmPassword&&e.jsx("p",{className:"text-xs text-destructive",children:F.confirmPassword})]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:t("settings.auth.status")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:d!=null&&d.enabled?t("settings.auth.statusEnabled"):t("settings.auth.statusDisabled")}),(d==null?void 0:d.username)&&e.jsxs("div",{className:"mt-3 rounded-md bg-primary/10 px-3 py-2 text-xs font-medium text-primary",children:[t("settings.auth.username"),": ",d.username]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 text-xs text-muted-foreground",children:t(ae?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(E,{onClick:()=>void Ee(),disabled:G,children:t(G?"common.actions.saving":"settings.auth.actions.save")}),e.jsx(E,{variant:"outline",onClick:Re,disabled:G,children:t("common.actions.reset")})]})]})]})}),e.jsx(R,{id:"section-config-file",ref:H("section-config-file"),children:e.jsxs(T,{className:"pt-6 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.configFile")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.file.description")})]}),e.jsxs(E,{variant:"outline",size:"sm",onClick:()=>void Te(),children:[e.jsx(tt,{className:"mr-2 h-4 w-4"}),t("common.actions.copy")]})]}),e.jsx("code",{className:"block break-all rounded-lg border bg-muted px-4 py-3 text-xs",children:B||t("settings.file.unknown")})]})}),e.jsx(R,{id:"section-cleanup",ref:H("section-cleanup"),children:e.jsxs(T,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.cleanup")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.cleanup.description")})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(E,{variant:"outline",onClick:()=>void Fe(),disabled:X,className:"border-destructive/50 text-destructive hover:bg-destructive/10",children:t(X?"common.actions.cleaning":"common.actions.cleanup")}),e.jsx(E,{variant:"destructive",onClick:()=>void He(),disabled:Z,children:t(Z?"settings.cleanup.clearingAll":"settings.cleanup.clearAll")})]}),e.jsx("p",{className:"text-xs text-destructive",children:t("settings.cleanup.clearAllWarning")})]})})]})]}):e.jsx(R,{children:e.jsx(T,{className:"pt-6",children:e.jsx("p",{className:"text-sm font-medium text-destructive",children:t("settings.toast.missingConfig")})})})]})}export{pt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,a as n}from"./index-
|
|
1
|
+
import{j as s,a as n}from"./index-Blclkvp7.js";function e({className:a}){return s.jsx("div",{role:"status","aria-label":"Loading",className:n("animate-pulse rounded-md bg-muted",a)})}function d(){return s.jsxs("div",{className:"rounded-xl border bg-card p-5 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(e,{className:"h-3 w-24"}),s.jsx(e,{className:"h-10 w-10 rounded-xl"})]}),s.jsx(e,{className:"h-8 w-32"})]})}function o(){return s.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(e,{className:"h-4 w-32"}),s.jsx(e,{className:"h-3 w-48"})]}),s.jsx(e,{className:"h-[320px] w-full rounded-lg"})]})}function m({columns:a=6}){const r=["w-24","w-16","w-20","w-28","w-14","w-12","w-20","w-16","w-14","w-12"];return s.jsx("tr",{className:"border-b",children:Array.from({length:a}).map((t,l)=>s.jsx("td",{className:"px-3 py-3",children:s.jsx(e,{className:n("h-4",r[l%r.length])})},l))})}export{o as C,d as S,m as T,e as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t,a as d,am as n}from"./index-
|
|
1
|
+
import{r as s,j as t,a as d,am as n}from"./index-Blclkvp7.js";const i=n("rounded-xl border bg-card text-card-foreground transition-all duration-200",{variants:{variant:{default:"shadow-sm hover:shadow-md",elevated:"shadow-md hover:shadow-lg",outline:"shadow-none border-2",ghost:"border-transparent shadow-none bg-transparent",interactive:"shadow-sm hover:shadow-lg hover:-translate-y-0.5 cursor-pointer"}},defaultVariants:{variant:"default"}}),l=s.forwardRef(({className:a,variant:e,...r},o)=>t.jsx("div",{ref:o,className:d(i({variant:e}),a),...r}));l.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-5",a),...e}));c.displayName="CardHeader";const m=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("text-lg font-semibold leading-none tracking-tight",a),...e}));m.displayName="CardTitle";const f=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("text-sm text-muted-foreground",a),...e}));f.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-5 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center p-5 pt-0",a),...e}));x.displayName="CardFooter";export{l as C,p as a,c as b,m as c,f as d,x as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as J,r as i,p as K,j as n,q as U,v as y,y as N,z as X,P as x,x as m,w as C,D as Y,E as Z,G as Q,H as ee,I as te,J as oe,a2 as ae,a as p,X as ne}from"./index-
|
|
1
|
+
import{c as J,r as i,p as K,j as n,q as U,v as y,y as N,z as X,P as x,x as m,w as C,D as Y,E as Z,G as Q,H as ee,I as te,J as oe,a2 as ae,a as p,X as ne}from"./index-Blclkvp7.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|