@chenpu17/cc-gw 0.7.5 → 0.7.11

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/src/server/dist/index.js +160 -60
  3. package/src/web/dist/assets/About-DCvCA-EN.js +6 -0
  4. package/src/web/dist/assets/ApiKeys-chBAE4F4.js +16 -0
  5. package/src/web/dist/assets/Dashboard-B4kvSkr7.js +16 -0
  6. package/src/web/dist/assets/{Events-DjHvrNLA.js → Events-D9F6cmSK.js} +1 -1
  7. package/src/web/dist/assets/{Help-B4aI51F7.js → Help-WBFjl1uQ.js} +6 -6
  8. package/src/web/dist/assets/{Login-D2mlt6E4.js → Login-C2ITDdIa.js} +1 -1
  9. package/src/web/dist/assets/Logs-Cb_N4UAX.js +6 -0
  10. package/src/web/dist/assets/{ModelManagement-BBL4JPx_.js → ModelManagement-IWXiEI0s.js} +1 -1
  11. package/src/web/dist/assets/{PageHeader-CArgoeOl.js → PageHeader-xFKpGYn6.js} +1 -1
  12. package/src/web/dist/assets/{PageSection-B9KNzbSh.js → PageSection-Vn4S3q9j.js} +1 -1
  13. package/src/web/dist/assets/Settings-DJ0_2N3_.js +11 -0
  14. package/src/web/dist/assets/{card-Hot3HWFO.js → card-C20_HqC6.js} +1 -1
  15. package/src/web/dist/assets/clipboard-CALi6bTW.js +1 -0
  16. package/src/web/dist/assets/{copy-DXxd_I6B.js → copy-CUEQDKMx.js} +1 -1
  17. package/src/web/dist/assets/{dialog-DOFVjgLV.js → dialog-Cx1HX_hR.js} +1 -1
  18. package/src/web/dist/assets/{index-DgZMz9ou.js → index-DgjUxG8I.js} +1 -1
  19. package/src/web/dist/assets/{index-DSWEYKFg.js → index-UV1Qa96f.js} +2 -2
  20. package/src/web/dist/assets/{info-C3Uvuy3w.js → info-CewFzdVp.js} +1 -1
  21. package/src/web/dist/assets/{input-CSRYqyMm.js → input-CBGvcnZr.js} +1 -1
  22. package/src/web/dist/assets/{label-sxZdAo5j.js → label-BqSverDm.js} +1 -1
  23. package/src/web/dist/assets/{refresh-cw-Cm_OQO9a.js → refresh-cw-ISOSG1Po.js} +1 -1
  24. package/src/web/dist/assets/{select-qZIYkE-k.js → select-C8rWWJbl.js} +1 -1
  25. package/src/web/dist/assets/{switch-DDvmmBlT.js → switch-ODrypdNp.js} +1 -1
  26. package/src/web/dist/assets/{useApiQuery-CDChhTqt.js → useApiQuery-C2OD7H7U.js} +1 -1
  27. package/src/web/dist/index.html +1 -1
  28. package/src/web/dist/assets/About-BH1K5IKD.js +0 -6
  29. package/src/web/dist/assets/ApiKeys-B5xWItFi.js +0 -16
  30. package/src/web/dist/assets/Dashboard-3H13REtP.js +0 -16
  31. package/src/web/dist/assets/Logs-mTxHOg7D.js +0 -6
  32. package/src/web/dist/assets/Settings-CzKp7gwN.js +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenpu17/cc-gw",
3
- "version": "0.7.5",
3
+ "version": "0.7.11",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13778,6 +13778,44 @@ async function registerMessagesRoute(app) {
13778
13778
  providerHeaders = collected;
13779
13779
  }
13780
13780
  } else {
13781
+ const collected = {};
13782
+ const excludedHeaders = /* @__PURE__ */ new Set([
13783
+ "host",
13784
+ "connection",
13785
+ "content-length",
13786
+ "transfer-encoding",
13787
+ "keep-alive",
13788
+ "upgrade",
13789
+ "proxy-connection",
13790
+ "proxy-authenticate",
13791
+ "proxy-authorization",
13792
+ "te",
13793
+ "trailer",
13794
+ "upgrade-insecure-requests",
13795
+ "authorization",
13796
+ "x-api-key"
13797
+ ]);
13798
+ const sourceHeaders = request.raw?.headers ?? request.headers;
13799
+ for (const [headerKey, headerValue] of Object.entries(sourceHeaders)) {
13800
+ const lower = headerKey.toLowerCase();
13801
+ if (excludedHeaders.has(lower))
13802
+ continue;
13803
+ let value;
13804
+ if (typeof headerValue === "string") {
13805
+ value = headerValue;
13806
+ } else if (Array.isArray(headerValue)) {
13807
+ value = headerValue.find((item) => typeof item === "string" && item.length > 0);
13808
+ }
13809
+ if (value && value.length > 0) {
13810
+ collected[lower] = value;
13811
+ }
13812
+ }
13813
+ if (!("content-type" in collected)) {
13814
+ collected["content-type"] = "application/json";
13815
+ }
13816
+ if (Object.keys(collected).length > 0) {
13817
+ providerHeaders = collected;
13818
+ }
13781
13819
  providerBody = buildProviderBody(normalizedForProvider, {
13782
13820
  maxTokens: maxTokensOverride,
13783
13821
  temperature: payload.temperature,
@@ -15041,12 +15079,27 @@ function filterForwardedAnthropicHeaders(headers) {
15041
15079
  if (!headers)
15042
15080
  return {};
15043
15081
  const result = {};
15044
- const allowContentHeaders = /* @__PURE__ */ new Set(["content-type", "accept"]);
15082
+ const excludedHeaders = /* @__PURE__ */ new Set([
15083
+ "host",
15084
+ "connection",
15085
+ "content-length",
15086
+ "transfer-encoding",
15087
+ "keep-alive",
15088
+ "upgrade",
15089
+ "proxy-connection",
15090
+ "proxy-authenticate",
15091
+ "proxy-authorization",
15092
+ "te",
15093
+ "trailer",
15094
+ "upgrade-insecure-requests",
15095
+ "authorization",
15096
+ "x-api-key"
15097
+ ]);
15045
15098
  for (const [key, value] of Object.entries(headers)) {
15046
15099
  if (!value)
15047
15100
  continue;
15048
15101
  const lower = key.toLowerCase();
15049
- if (lower.startsWith("anthropic-") || allowContentHeaders.has(lower)) {
15102
+ if (!excludedHeaders.has(lower)) {
15050
15103
  result[lower] = value;
15051
15104
  }
15052
15105
  }
@@ -15409,6 +15462,21 @@ async function registerOpenAiRoutes(app) {
15409
15462
  "forwarding anthropic headers (responses)"
15410
15463
  );
15411
15464
  } else {
15465
+ const rawHeaders = request.raw?.headers ?? request.headers;
15466
+ const forwarded = collectAnthropicForwardHeaders(rawHeaders);
15467
+ providerHeaders = filterForwardedAnthropicHeaders(forwarded);
15468
+ if (OPENAI_DEBUG) {
15469
+ debugLog("responses non-anthropic forwarded headers", providerHeaders);
15470
+ }
15471
+ request.log.info(
15472
+ {
15473
+ event: "responses.forward_headers",
15474
+ provider: target.providerId,
15475
+ model: target.modelId,
15476
+ headers: providerHeaders
15477
+ },
15478
+ "forwarding headers (responses, non-anthropic provider)"
15479
+ );
15412
15480
  providerBody = { ...payload };
15413
15481
  providerBody.model = target.modelId;
15414
15482
  if (Object.prototype.hasOwnProperty.call(payload, "stream")) {
@@ -15990,6 +16058,21 @@ async function registerOpenAiRoutes(app) {
15990
16058
  "forwarding anthropic headers (chat completions)"
15991
16059
  );
15992
16060
  } else {
16061
+ const rawHeaders = request.raw?.headers ?? request.headers;
16062
+ const forwarded = collectAnthropicForwardHeaders(rawHeaders);
16063
+ providerHeaders = filterForwardedAnthropicHeaders(forwarded);
16064
+ if (OPENAI_DEBUG) {
16065
+ debugLog("chat completions non-anthropic forwarded headers", providerHeaders);
16066
+ }
16067
+ request.log.info(
16068
+ {
16069
+ event: "chat.completions.forward_headers",
16070
+ provider: target.providerId,
16071
+ model: target.modelId,
16072
+ headers: providerHeaders
16073
+ },
16074
+ "forwarding headers (chat completions, non-anthropic provider)"
16075
+ );
15993
16076
  providerBody = buildProviderBody(normalized, {
15994
16077
  maxTokens: typeof payload.max_tokens === "number" ? payload.max_tokens : void 0,
15995
16078
  temperature: typeof payload.temperature === "number" ? payload.temperature : void 0,
@@ -16964,7 +17047,7 @@ async function registerAdminRoutes(app) {
16964
17047
  const model = typeof raw.model === "string" && raw.model.length > 0 ? raw.model : void 0;
16965
17048
  const statusParam = typeof raw.status === "string" ? raw.status : void 0;
16966
17049
  const status = statusParam === "success" || statusParam === "error" ? statusParam : void 0;
16967
- const endpoint = isEndpoint(raw.endpoint) ? raw.endpoint : void 0;
17050
+ const endpoint = typeof raw.endpoint === "string" && raw.endpoint.length > 0 ? raw.endpoint : void 0;
16968
17051
  const from = parseTimestamp(raw.from);
16969
17052
  const to = parseTimestamp(raw.to);
16970
17053
  const apiKeyIdsRaw = parseApiKeyIds(raw.apiKeys ?? raw.apiKeyIds ?? raw.apiKey);
@@ -17672,14 +17755,14 @@ async function registerAdminRoutes(app) {
17672
17755
  });
17673
17756
  app.get("/api/stats/overview", async (request) => {
17674
17757
  const query = request.query ?? {};
17675
- const endpoint = isEndpoint(query.endpoint) ? query.endpoint : void 0;
17758
+ const endpoint = typeof query.endpoint === "string" && query.endpoint.length > 0 ? query.endpoint : void 0;
17676
17759
  return getMetricsOverview(endpoint);
17677
17760
  });
17678
17761
  app.get("/api/stats/daily", async (request) => {
17679
17762
  const query = request.query ?? {};
17680
17763
  const daysRaw = Number(query.days ?? 7);
17681
17764
  const days = Number.isFinite(daysRaw) ? Math.max(1, Math.min(daysRaw, 30)) : 7;
17682
- const endpoint = isEndpoint(query.endpoint) ? query.endpoint : void 0;
17765
+ const endpoint = typeof query.endpoint === "string" && query.endpoint.length > 0 ? query.endpoint : void 0;
17683
17766
  return getDailyMetrics(days, endpoint);
17684
17767
  });
17685
17768
  app.get("/api/stats/model", async (request) => {
@@ -17688,14 +17771,14 @@ async function registerAdminRoutes(app) {
17688
17771
  const limitRaw = Number(query.limit ?? 10);
17689
17772
  const days = Number.isFinite(daysRaw) ? Math.max(1, Math.min(daysRaw, 90)) : 7;
17690
17773
  const limit = Number.isFinite(limitRaw) ? Math.max(1, Math.min(limitRaw, 50)) : 10;
17691
- const endpoint = isEndpoint(query.endpoint) ? query.endpoint : void 0;
17774
+ const endpoint = typeof query.endpoint === "string" && query.endpoint.length > 0 ? query.endpoint : void 0;
17692
17775
  return getModelUsageMetrics(days, limit, endpoint);
17693
17776
  });
17694
17777
  app.get("/api/stats/api-keys/overview", async (request) => {
17695
17778
  const query = request.query ?? {};
17696
17779
  const daysRaw = Number(query.days ?? 7);
17697
17780
  const rangeDays = Number.isFinite(daysRaw) ? Math.max(1, Math.min(daysRaw, 90)) : 7;
17698
- const endpoint = isEndpoint(query.endpoint) ? query.endpoint : void 0;
17781
+ const endpoint = typeof query.endpoint === "string" && query.endpoint.length > 0 ? query.endpoint : void 0;
17699
17782
  return getApiKeyOverviewMetrics(rangeDays, endpoint);
17700
17783
  });
17701
17784
  app.get("/api/stats/api-keys/usage", async (request) => {
@@ -17704,7 +17787,7 @@ async function registerAdminRoutes(app) {
17704
17787
  const limitRaw = Number(query.limit ?? 10);
17705
17788
  const days = Number.isFinite(daysRaw) ? Math.max(1, Math.min(daysRaw, 90)) : 7;
17706
17789
  const limit = Number.isFinite(limitRaw) ? Math.max(1, Math.min(limitRaw, 50)) : 10;
17707
- const endpoint = isEndpoint(query.endpoint) ? query.endpoint : void 0;
17790
+ const endpoint = typeof query.endpoint === "string" && query.endpoint.length > 0 ? query.endpoint : void 0;
17708
17791
  return getApiKeyUsageMetrics(days, limit, endpoint);
17709
17792
  });
17710
17793
  app.get("/api/keys", async () => {
@@ -18003,7 +18086,6 @@ async function registerAdminRoutes(app) {
18003
18086
  }
18004
18087
  });
18005
18088
  }
18006
- var isEndpoint = (value) => value === "anthropic" || value === "openai";
18007
18089
 
18008
18090
  // routes/events.ts
18009
18091
  async function registerEventsRoutes(app) {
@@ -18402,23 +18484,29 @@ async function handleAnthropicProtocol(request, reply, endpoint, endpointId, app
18402
18484
  const validationConfig = endpoint.routing?.validation ?? configSnapshot.endpointRouting?.anthropic?.validation;
18403
18485
  const validationMode = validationConfig?.mode ?? "off";
18404
18486
  const providerHeaders = {};
18405
- const headersToForward = [
18406
- "anthropic-version",
18407
- "anthropic-beta",
18408
- "x-stainless-arch",
18409
- "x-stainless-async",
18410
- "x-stainless-lang",
18411
- "x-stainless-os",
18412
- "x-stainless-package-version",
18413
- "x-stainless-runtime",
18414
- "x-stainless-runtime-version"
18415
- ];
18416
- for (const key of headersToForward) {
18417
- const value = request.headers[key];
18418
- if (typeof value === "string" && value.length > 0) {
18419
- providerHeaders[key] = value;
18420
- } else if (Array.isArray(value) && value.length > 0 && typeof value[0] === "string") {
18421
- providerHeaders[key] = value[0];
18487
+ const excludedHeaders = /* @__PURE__ */ new Set([
18488
+ "host",
18489
+ "connection",
18490
+ "content-length",
18491
+ "transfer-encoding",
18492
+ "keep-alive",
18493
+ "upgrade",
18494
+ "proxy-connection",
18495
+ "proxy-authenticate",
18496
+ "proxy-authorization",
18497
+ "te",
18498
+ "trailer",
18499
+ "upgrade-insecure-requests",
18500
+ "authorization",
18501
+ "x-api-key"
18502
+ ]);
18503
+ for (const [key, rawValue] of Object.entries(request.headers)) {
18504
+ const lower = key.toLowerCase();
18505
+ if (excludedHeaders.has(lower))
18506
+ continue;
18507
+ const value = typeof rawValue === "string" ? rawValue : Array.isArray(rawValue) ? rawValue[0] : void 0;
18508
+ if (value && value.length > 0) {
18509
+ providerHeaders[lower] = value;
18422
18510
  }
18423
18511
  }
18424
18512
  const providedApiKey = extractApiKeyFromRequest2(request);
@@ -18871,23 +18959,29 @@ async function handleOpenAIChatProtocol(request, reply, endpoint, endpointId, ap
18871
18959
  querySuffix = request.querystring || null;
18872
18960
  }
18873
18961
  const providerHeaders = {};
18874
- const headersToForward = [
18875
- "anthropic-version",
18876
- "anthropic-beta",
18877
- "x-stainless-arch",
18878
- "x-stainless-async",
18879
- "x-stainless-lang",
18880
- "x-stainless-os",
18881
- "x-stainless-package-version",
18882
- "x-stainless-runtime",
18883
- "x-stainless-runtime-version"
18884
- ];
18885
- for (const key of headersToForward) {
18886
- const value = request.headers[key];
18887
- if (typeof value === "string" && value.length > 0) {
18888
- providerHeaders[key] = value;
18889
- } else if (Array.isArray(value) && value.length > 0 && typeof value[0] === "string") {
18890
- providerHeaders[key] = value[0];
18962
+ const excludedHeaders = /* @__PURE__ */ new Set([
18963
+ "host",
18964
+ "connection",
18965
+ "content-length",
18966
+ "transfer-encoding",
18967
+ "keep-alive",
18968
+ "upgrade",
18969
+ "proxy-connection",
18970
+ "proxy-authenticate",
18971
+ "proxy-authorization",
18972
+ "te",
18973
+ "trailer",
18974
+ "upgrade-insecure-requests",
18975
+ "authorization",
18976
+ "x-api-key"
18977
+ ]);
18978
+ for (const [key, rawValue] of Object.entries(request.headers)) {
18979
+ const lower = key.toLowerCase();
18980
+ if (excludedHeaders.has(lower))
18981
+ continue;
18982
+ const value = typeof rawValue === "string" ? rawValue : Array.isArray(rawValue) ? rawValue[0] : void 0;
18983
+ if (value && value.length > 0) {
18984
+ providerHeaders[lower] = value;
18891
18985
  }
18892
18986
  }
18893
18987
  const providedApiKey = extractApiKeyFromRequest2(request);
@@ -19224,23 +19318,29 @@ async function handleOpenAIResponsesProtocol(request, reply, endpoint, endpointI
19224
19318
  querySuffix = request.querystring || null;
19225
19319
  }
19226
19320
  const providerHeaders = {};
19227
- const headersToForward = [
19228
- "anthropic-version",
19229
- "anthropic-beta",
19230
- "x-stainless-arch",
19231
- "x-stainless-async",
19232
- "x-stainless-lang",
19233
- "x-stainless-os",
19234
- "x-stainless-package-version",
19235
- "x-stainless-runtime",
19236
- "x-stainless-runtime-version"
19237
- ];
19238
- for (const key of headersToForward) {
19239
- const value = request.headers[key];
19240
- if (typeof value === "string" && value.length > 0) {
19241
- providerHeaders[key] = value;
19242
- } else if (Array.isArray(value) && value.length > 0 && typeof value[0] === "string") {
19243
- providerHeaders[key] = value[0];
19321
+ const excludedHeaders = /* @__PURE__ */ new Set([
19322
+ "host",
19323
+ "connection",
19324
+ "content-length",
19325
+ "transfer-encoding",
19326
+ "keep-alive",
19327
+ "upgrade",
19328
+ "proxy-connection",
19329
+ "proxy-authenticate",
19330
+ "proxy-authorization",
19331
+ "te",
19332
+ "trailer",
19333
+ "upgrade-insecure-requests",
19334
+ "authorization",
19335
+ "x-api-key"
19336
+ ]);
19337
+ for (const [key, rawValue] of Object.entries(request.headers)) {
19338
+ const lower = key.toLowerCase();
19339
+ if (excludedHeaders.has(lower))
19340
+ continue;
19341
+ const value = typeof rawValue === "string" ? rawValue : Array.isArray(rawValue) ? rawValue[0] : void 0;
19342
+ if (value && value.length > 0) {
19343
+ providerHeaders[lower] = value;
19244
19344
  }
19245
19345
  }
19246
19346
  const providedApiKey = extractApiKeyFromRequest2(request);
@@ -0,0 +1,6 @@
1
+ import{c as j,u as g,b as v,r as i,j as e,e as d,a5 as N}from"./index-UV1Qa96f.js";import{u as y}from"./useApiQuery-C2OD7H7U.js";import{P as E}from"./PageHeader-xFKpGYn6.js";import{P as n}from"./PageSection-Vn4S3q9j.js";import{C as m,a as p}from"./card-C20_HqC6.js";import{I}from"./info-CewFzdVp.js";import{R as T}from"./refresh-cw-ISOSG1Po.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 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.11",w={version:_},L={VITE_BUILD_TIME:"2025-12-15T01:57:09.233Z",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 D,r as c,j as e,a as $,u as Z,b as de,L as pe,e as o,K as me,v as ue,d as K}from"./index-UV1Qa96f.js";import{E as ye}from"./index-DgjUxG8I.js";import{u as w}from"./useApiQuery-C2OD7H7U.js";import{P as xe,B as q}from"./PageHeader-xFKpGYn6.js";import{P as z}from"./PageSection-Vn4S3q9j.js";import{c as he}from"./clipboard-CALi6bTW.js";import{I as ge}from"./input-CBGvcnZr.js";import{L as I}from"./label-BqSverDm.js";import{C as T,a as S}from"./card-C20_HqC6.js";import{P as fe,D as W,a as H,b as V,c as G,d as je,e as Q}from"./dialog-Cx1HX_hR.js";import{C as U}from"./copy-CUEQDKMx.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 ve=D("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 Ke=D("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 Ne=D("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"}]]),_=c.forwardRef(({className:a,...r},y)=>e.jsx("textarea",{className:$("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",a),ref:y,...r}));_.displayName="Textarea";const be=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function Pe(){const{t:a}=Z(),{pushToast:r}=de(),[y,m]=c.useState(!1),[x,h]=c.useState(""),[L,N]=c.useState(""),[l,b]=c.useState(null),[J,E]=c.useState(null),[p,X]=c.useState(7),[M,A]=c.useState(new Map),[Y,O]=c.useState(null),g=w(["api-keys"],{url:"/api/keys",method:"GET"}),j=w(["api-keys","overview",p],{url:"/api/stats/api-keys/overview",method:"GET",params:{days:p}}),f=w(["api-keys","usage",p],{url:"/api/stats/api-keys/usage",method:"GET",params:{days:p,limit:10}}),k=g.data??[],u=j.data,d=f.data??[],ee=k.some(s=>s.isWildcard),ae=u?u.totalKeys.toLocaleString():"-",se=u?u.enabledKeys.toLocaleString():"-",te=u?u.activeKeys.toLocaleString():"-",P=async()=>{var s,t;if(!x.trim()){r({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}try{const i=await K.post("/api/keys",{name:x.trim(),description:L.trim()||void 0});b(i.data),m(!1),h(""),N(""),g.refetch(),j.refetch(),f.refetch(),r({title:a("apiKeys.toast.keyCreated"),variant:"success"})}catch(i){r({title:a("apiKeys.toast.createFailure",{message:((t=(s=i.response)==null?void 0:s.data)==null?void 0:t.error)||i.message}),variant:"error"})}},ie=async(s,t)=>{var i,n;try{await K.patch(`/api/keys/${s}`,{enabled:!t}),g.refetch(),j.refetch(),r({title:a("apiKeys.toast.keyUpdated"),variant:"success"})}catch(v){r({title:a("apiKeys.toast.updateFailure",{message:((n=(i=v.response)==null?void 0:i.data)==null?void 0:n.error)||v.message}),variant:"error"})}},re=async s=>{var t,i;if(confirm(a("apiKeys.confirmDelete"))){E(s);try{await K.delete(`/api/keys/${s}`),g.refetch(),j.refetch(),f.refetch(),r({title:a("apiKeys.toast.keyDeleted"),variant:"success"})}catch(n){r({title:a("apiKeys.toast.deleteFailure",{message:((i=(t=n.response)==null?void 0:t.data)==null?void 0:i.error)||n.message}),variant:"error"})}finally{E(null)}}},ne=async s=>{var t,i;if(!M.has(s)){O(s);try{const n=await K.get(`/api/keys/${s}/reveal`);A(v=>new Map(v).set(s,n.data.key))}catch(n){r({title:a("apiKeys.toast.revealFailure"),description:((i=(t=n.response)==null?void 0:t.data)==null?void 0:i.error)||n.message,variant:"error"})}finally{O(null)}}},le=s=>{A(t=>{const i=new Map(t);return i.delete(s),i})},R=async s=>{try{await he(s),r({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(t){r({title:a("apiKeys.toast.copyFailure"),description:t instanceof Error?t.message:a("common.unknownError"),variant:"error"})}},F=s=>s?new Date(s).toLocaleString():a("common.noData"),ce=c.useMemo(()=>{const s=d.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:d.map(t=>t.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[d,a]),oe=c.useMemo(()=>{const s=d.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:d.map(t=>t.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:d.map(t=>t.outputTokens)}]}},[d,a]);return g.isLoading?e.jsx(pe,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(xe,{icon:e.jsx(me,{className:"h-5 w-5","aria-hidden":"true"}),title:a("apiKeys.title"),description:a("apiKeys.description"),actions:e.jsxs(o,{onClick:()=>m(!0),children:[e.jsx(fe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),e.jsx(z,{title:a("apiKeys.analytics.title"),description:a("apiKeys.analytics.description",{days:p}),actions:e.jsx("div",{className:"flex items-center gap-1 rounded-lg border p-1",children:be.map(s=>{const t=p===s.value;return e.jsx("button",{type:"button",onClick:()=>X(s.value),className:$("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:a(s.labelKey)},s.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(C,{label:a("apiKeys.analytics.cards.total"),value:ae}),e.jsx(C,{label:a("apiKeys.analytics.cards.enabled"),value:se}),e.jsx(C,{label:a("apiKeys.analytics.cards.active",{days:p}),value:te})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(B,{title:a("apiKeys.analytics.charts.requests"),loading:f.isLoading,empty:d.length===0,emptyText:a("apiKeys.analytics.empty"),option:ce}),e.jsx(B,{title:a("apiKeys.analytics.charts.tokens"),loading:f.isLoading,empty:d.length===0,emptyText:a("apiKeys.analytics.empty"),option:oe})]})]})}),e.jsx(z,{title:a("apiKeys.list.title"),description:ee?a("apiKeys.wildcardHint"):void 0,children:k.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:a("apiKeys.list.empty")})}):e.jsx("div",{className:"grid gap-4",children:k.map(s=>{const t=(s.totalInputTokens+s.totalOutputTokens).toLocaleString(),i=M.get(s.id),n=Y===s.id;return e.jsx(T,{children:e.jsx(S,{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:s.name}),s.isWildcard&&e.jsx(q,{variant:"secondary",children:a("apiKeys.wildcard")}),e.jsx(q,{variant:s.enabled?"default":"outline",children:s.enabled?a("apiKeys.status.enabled"):a("apiKeys.status.disabled")})]}),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:s.isWildcard?a("apiKeys.wildcard"):i??s.maskedKey??"********"}),!s.isWildcard&&e.jsx("div",{className:"flex items-center gap-1",children:i?e.jsxs(e.Fragment,{children:[e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void R(i),"aria-label":a("common.actions.copy"),title:a("common.actions.copy"),children:e.jsx(U,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(s.id),"aria-label":a("apiKeys.actions.hide"),title:a("apiKeys.actions.hide"),children:e.jsx(ve,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void ne(s.id),disabled:n,"aria-label":a("apiKeys.actions.reveal"),title:a("apiKeys.actions.reveal"),children:e.jsx(Ke,{className:"h-4 w-4","aria-hidden":"true"})})})]}),s.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.wildcardHint")}):s.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:s.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:a("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:F(s.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:F(s.lastUsedAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.requestCount")}),e.jsx("p",{className:"font-medium",children:s.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:a("apiKeys.totalTokens")}),e.jsx("p",{className:"font-medium",children:t})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{variant:s.enabled?"outline":"default",size:"sm",onClick:()=>ie(s.id,s.enabled),children:s.enabled?a("apiKeys.actions.disable"):a("apiKeys.actions.enable")}),!s.isWildcard&&e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>re(s.id),disabled:J===s.id,"aria-label":a("apiKeys.actions.delete"),children:e.jsx(Ne,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})},s.id)})})}),e.jsx(W,{open:y,onOpenChange:m,children:e.jsxs(H,{children:[e.jsxs(V,{children:[e.jsx(G,{children:a("apiKeys.createNew")}),e.jsx(je,{children:a("apiKeys.createDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"keyName",children:[a("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(ge,{id:"keyName",value:x,onChange:s=>h(s.target.value),placeholder:a("apiKeys.keyNamePlaceholder"),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),P())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"keyDescription",children:a("apiKeys.descriptionLabel")}),e.jsx(_,{id:"keyDescription",value:L,onChange:s=>N(s.target.value),placeholder:a("apiKeys.keyDescriptionPlaceholder"),rows:3})]})]}),e.jsxs(Q,{children:[e.jsx(o,{variant:"outline",onClick:()=>{m(!1),h(""),N("")},children:a("common.actions.cancel")}),e.jsx(o,{onClick:()=>void P(),children:a("apiKeys.createAction")})]})]})}),e.jsx(W,{open:!!l,onOpenChange:()=>b(null),children:e.jsxs(H,{children:[e.jsx(V,{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(ue,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(G,{children:a("apiKeys.keyCreated")})]})}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:a("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-md bg-muted px-4 py-3 font-mono text-sm",children:l==null?void 0:l.key}),(l==null?void 0:l.description)&&e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:l.description}),e.jsxs(Q,{children:[e.jsxs(o,{onClick:()=>void R((l==null?void 0:l.key)??""),children:[e.jsx(U,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("common.actions.copy")]}),e.jsx(o,{variant:"outline",onClick:()=>b(null),children:a("common.actions.close")})]})]})})]})}function C({label:a,value:r}){return e.jsx(T,{children:e.jsxs(S,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:r})]})})}function B({title:a,option:r,loading:y,empty:m,emptyText:x}){const{t:h}=Z();return e.jsx(T,{children:e.jsxs(S,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:a}),y?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:h("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:x})}):e.jsx(ye,{option:r,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}export{Pe as default};
@@ -0,0 +1,16 @@
1
+ import{c as O,r as d,j as e,a as f,u as I,b as ne,d as ie,t as le,L as ce,B as D,e as me}from"./index-UV1Qa96f.js";import{E as he}from"./index-DgjUxG8I.js";import{P as ue,B as k}from"./PageHeader-xFKpGYn6.js";import{P as X}from"./PageSection-Vn4S3q9j.js";import{u as S}from"./useApiQuery-C2OD7H7U.js";import{C as G,a as Q}from"./card-C20_HqC6.js";import{S as xe,a as pe,b as be,c as ge,d as q}from"./select-C8rWWJbl.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 $=O("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/**
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 fe=O("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
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 ye=O("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),F=d.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-lg",children:e.jsx("table",{ref:a,className:f("w-full caption-bottom text-sm border-collapse",t),...s})}));F.displayName="Table";const H=d.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:f("bg-muted/40 [&_tr]:border-b [&_tr]:border-border/60",t),...s}));H.displayName="TableHeader";const _=d.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:f("[&_tr:last-child]:border-0",t),...s}));_.displayName="TableBody";const je=d.forwardRef(({className:t,...s},a)=>e.jsx("tfoot",{ref:a,className:f("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));je.displayName="TableFooter";const A=d.forwardRef(({className:t,...s},a)=>e.jsx("tr",{ref:a,className:f("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...s}));A.displayName="TableRow";const h=d.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:f("h-11 px-4 text-left align-middle text-xs font-semibold uppercase tracking-wider text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...s}));h.displayName="TableHead";const u=d.forwardRef(({className:t,...s},a)=>e.jsx("td",{ref:a,className:f("px-4 py-3 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...s}));u.displayName="TableCell";const ve=d.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:f("mt-4 text-sm text-muted-foreground",t),...s}));ve.displayName="TableCaption";function P(t,s,a){return t==null?"-":`${t.toLocaleString(void 0,a)} ${s}`}function W(t){if(t==null)return"-";if(t<1024)return`${t} B`;const s=["KB","MB","GB","TB"];let a=t/1024,r=0;for(;a>=1024&&r<s.length-1;)a/=1024,r+=1;return`${a.toFixed(a>=100?0:a>=10?1:2)} ${s[r]}`}function Ae(){var U,V,K;const{t}=I(),{pushToast:s}=ne(),[a,r]=d.useState("all"),[i,y]=d.useState(!1),x=a==="all"?void 0:a,Y=S(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"}),N=S(["stats","overview",a],{url:"/api/stats/overview",method:"GET",params:x?{endpoint:x}:void 0}),T=S(["stats","daily",14,a],{url:"/api/stats/daily",method:"GET",params:{days:14,...x?{endpoint:x}:{}}}),g=S(["stats","model",7,6,a],{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...x?{endpoint:x}:{}}}),E=S(["status"],{url:"/api/status",method:"GET"}),j=S(["db","info"],{url:"/api/db/info",method:"GET"}),z=j.refetch??(async()=>{}),C=S(["logs","recent",a],{url:"/api/logs",method:"GET",params:{limit:5,...x?{endpoint:x}:{}}},{refetchInterval:3e4});d.useEffect(()=>{N.isError&&N.error&&s({title:t("dashboard.toast.overviewError"),description:N.error.message,variant:"error"})},[N.isError,N.error,s,t]),d.useEffect(()=>{T.isError&&T.error&&s({title:t("dashboard.toast.dailyError"),description:T.error.message,variant:"error"})},[T.isError,T.error,s,t]),d.useEffect(()=>{g.isError&&g.error&&s({title:t("dashboard.toast.modelError"),description:g.error.message,variant:"error"})},[g.isError,g.error,s,t]),d.useEffect(()=>{E.isError&&E.error&&s({title:t("dashboard.toast.statusError"),description:E.error.message,variant:"error"})},[E.isError,E.error,s,t]),d.useEffect(()=>{j.isError&&j.error&&s({title:t("dashboard.toast.dbError"),description:j.error.message,variant:"error"})},[j.isError,j.error,s,t]);const Z=d.useCallback(async()=>{if(!i){y(!0);try{await ie.post("/api/db/compact"),await z(),s({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(n){const m=le(n);s({title:t("dashboard.toast.compactError.title"),description:m.message,variant:"error"})}finally{y(!1)}}},[i,s,z,t]);d.useEffect(()=>{C.isError&&C.error&&s({title:t("dashboard.toast.recentError"),description:C.error.message,variant:"error"})},[C.isError,C.error,s,t]);const o=N.data,v=T.data??[],l=g.data??[],L=E.data,R=j.data,ee=((U=C.data)==null?void 0:U.items)??[],te=R?W(R.totalBytes??R.sizeBytes):"-",ae=R?W(R.memoryRssBytes??0):"-",se=d.useMemo(()=>{const n=v.map(b=>b.date),m=t("dashboard.charts.barRequests"),c=t("dashboard.charts.lineInput"),B=t("dashboard.charts.lineOutput"),p=t("dashboard.charts.lineCacheRead"),J=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[m,c,B,p,J]},grid:{left:60,right:40,top:60,bottom:60},xAxis:{type:"category",data:n},yAxis:{type:"value"},series:[{name:m,type:"bar",data:v.map(b=>b.requestCount),itemStyle:{color:"hsl(var(--primary))",borderRadius:[4,4,0,0]}},{name:c,type:"line",data:v.map(b=>b.inputTokens),smooth:!0,itemStyle:{color:"#10b981"},lineStyle:{width:2}},{name:B,type:"line",data:v.map(b=>b.outputTokens),smooth:!0,itemStyle:{color:"#f59e0b"},lineStyle:{width:2}},{name:p,type:"line",data:v.map(b=>b.cacheReadTokens),smooth:!0,itemStyle:{color:"#8b5cf6"},lineStyle:{width:2}},{name:J,type:"line",data:v.map(b=>b.cacheCreationTokens),smooth:!0,itemStyle:{color:"#ec4899"},lineStyle:{width:2}}]}},[v,t]),re=d.useMemo(()=>{const n=l.map(p=>`${p.provider}/${p.model}`),m=t("dashboard.charts.barRequests"),c=t("dashboard.charts.lineInput"),B=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[m,c,B]},grid:{left:80,right:60,top:60,bottom:100},xAxis:{type:"category",data:n,axisLabel:{rotate:30}},yAxis:[{type:"value",name:m},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:m,type:"bar",data:l.map(p=>p.requests),itemStyle:{color:"#6366f1",borderRadius:[4,4,0,0]}},{name:c,type:"line",yAxisIndex:1,smooth:!0,data:l.map(p=>p.inputTokens??0),itemStyle:{color:"#10b981"}},{name:B,type:"line",yAxisIndex:1,smooth:!0,data:l.map(p=>p.outputTokens??0),itemStyle:{color:"#f59e0b"}}]}},[l,t]),oe=d.useMemo(()=>{const n=l.map(c=>`${c.provider}/${c.model}`),m=t("dashboard.charts.ttftLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:n,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:m,type:"bar",data:l.map(c=>c.avgTtftMs??0),itemStyle:{color:"hsl(var(--primary))",borderRadius:[4,4,0,0]}}]}},[l,t]),de=d.useMemo(()=>{const n=l.map(c=>`${c.provider}/${c.model}`),m=t("dashboard.charts.tpotLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:n,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:m,type:"bar",data:l.map(c=>c.avgTpotMs??0),itemStyle:{color:"#f59e0b",borderRadius:[4,4,0,0]}}]}},[l,t]);return N.isPending||E.isPending||j.isPending?e.jsx(ce,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ue,{icon:e.jsx(D,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("dashboard.filters.endpoint")}),e.jsxs(xe,{value:a,onValueChange:r,children:[e.jsx(pe,{className:"w-[140px]",children:e.jsx(be,{})}),e.jsxs(ge,{children:[e.jsx(q,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(q,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(q,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),(K=(V=Y.data)==null?void 0:V.endpoints)==null?void 0:K.map(n=>e.jsx(q,{value:n.id,children:n.label||n.id},n.id))]})]})]})}),L&&e.jsx(G,{children:e.jsxs(Q,{className:"flex flex-wrap items-center gap-3 pt-4",children:[e.jsx(k,{variant:"default",className:"bg-emerald-500",children:t("dashboard.status.listening",{host:L.host??"0.0.0.0",port:L.port})}),e.jsx(k,{variant:"secondary",children:t("dashboard.status.providers",{value:L.providers.toLocaleString()})}),e.jsx(k,{variant:"secondary",children:t("dashboard.status.todayRequests",{value:((o==null?void 0:o.today.requests)??0).toLocaleString()})}),e.jsx(k,{variant:"outline",children:t("dashboard.status.active",{value:(L.activeRequests??0).toLocaleString()})}),e.jsx(k,{variant:"outline",children:t("dashboard.status.dbSize",{value:te})}),e.jsx(k,{variant:"outline",children:t("dashboard.status.memory",{value:ae})}),e.jsx(me,{variant:"outline",size:"sm",onClick:Z,disabled:i,children:t(i?"dashboard.actions.compacting":"dashboard.actions.compact")})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(w,{icon:e.jsx($,{className:"h-5 w-5"}),title:t("dashboard.cards.todayRequests"),value:(o==null?void 0:o.today.requests)??0,suffix:t("common.units.request"),color:"blue"}),e.jsx(w,{icon:e.jsx(ye,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(o==null?void 0:o.today.inputTokens)??0,suffix:t("common.units.token"),color:"emerald"}),e.jsx(w,{icon:e.jsx($,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheRead"),value:(o==null?void 0:o.today.cacheReadTokens)??0,suffix:t("common.units.token"),color:"violet"}),e.jsx(w,{icon:e.jsx($,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheCreation"),value:(o==null?void 0:o.today.cacheCreationTokens)??0,suffix:t("common.units.token"),color:"rose"}),e.jsx(w,{icon:e.jsx(D,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(o==null?void 0:o.today.outputTokens)??0,suffix:t("common.units.token"),color:"amber"}),e.jsx(w,{icon:e.jsx(fe,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(o==null?void 0:o.today.avgLatencyMs)??0,suffix:t("common.units.ms"),color:"cyan"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(M,{title:t("dashboard.charts.requestsTitle"),description:t("dashboard.charts.requestsDesc"),loading:T.isPending,option:se,empty:!v.length,emptyText:t("dashboard.charts.empty")}),e.jsx(M,{title:t("dashboard.charts.modelTitle"),description:t("dashboard.charts.modelDesc"),loading:g.isPending,option:re,empty:!l.length,emptyText:t("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(M,{title:t("dashboard.charts.ttftTitle"),description:t("dashboard.charts.ttftDesc"),loading:g.isPending,option:oe,empty:!l.some(n=>n.avgTtftMs!=null&&n.avgTtftMs>0),emptyText:t("dashboard.charts.ttftEmpty")}),e.jsx(M,{title:t("dashboard.charts.tpotTitle"),description:t("dashboard.charts.tpotDesc"),loading:g.isPending,option:de,empty:!l.some(n=>n.avgTpotMs!=null&&n.avgTpotMs>0),emptyText:t("dashboard.charts.tpotEmpty")})]}),e.jsx(Te,{models:l,loading:g.isPending}),e.jsx(Ee,{loading:C.isPending,records:ee})]})}const Ne={blue:{gradient:"bg-gradient-to-br from-blue-500/10 via-blue-500/5 to-transparent",iconBg:"bg-blue-500/15",iconColor:"text-blue-600 dark:text-blue-400"},emerald:{gradient:"bg-gradient-to-br from-emerald-500/10 via-emerald-500/5 to-transparent",iconBg:"bg-emerald-500/15",iconColor:"text-emerald-600 dark:text-emerald-400"},amber:{gradient:"bg-gradient-to-br from-amber-500/10 via-amber-500/5 to-transparent",iconBg:"bg-amber-500/15",iconColor:"text-amber-600 dark:text-amber-400"},violet:{gradient:"bg-gradient-to-br from-violet-500/10 via-violet-500/5 to-transparent",iconBg:"bg-violet-500/15",iconColor:"text-violet-600 dark:text-violet-400"},rose:{gradient:"bg-gradient-to-br from-rose-500/10 via-rose-500/5 to-transparent",iconBg:"bg-rose-500/15",iconColor:"text-rose-600 dark:text-rose-400"},cyan:{gradient:"bg-gradient-to-br from-cyan-500/10 via-cyan-500/5 to-transparent",iconBg:"bg-cyan-500/15",iconColor:"text-cyan-600 dark:text-cyan-400"}};function w({icon:t,title:s,value:a,suffix:r,color:i="blue"}){const y=Ne[i];return e.jsx(G,{variant:"interactive",className:f("overflow-hidden",y.gradient),children:e.jsxs(Q,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:s}),t&&e.jsx("div",{className:f("flex h-10 w-10 items-center justify-center rounded-xl",y.iconBg,y.iconColor),children:t})]}),e.jsxs("p",{className:"text-3xl font-bold tracking-tight",children:[a.toLocaleString(),r&&e.jsx("span",{className:"ml-1.5 text-sm font-medium text-muted-foreground",children:r})]})]})})}function M({title:t,description:s,option:a,loading:r,empty:i,emptyText:y}){const{t:x}=I();return e.jsx(G,{children:e.jsxs(Q,{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold",children:t}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]}),r?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:x("common.loadingShort")})}):i?e.jsxs("div",{className:"flex h-[320px] flex-col items-center justify-center rounded-lg border border-dashed",children:[e.jsx(D,{className:"mb-2 h-10 w-10 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:y??x("dashboard.charts.empty")})]}):e.jsx(he,{option:a,style:{height:320},notMerge:!0,lazyUpdate:!0})]})})}function Te({models:t,loading:s}){const{t:a}=I(),r=t.length>0;return e.jsx(X,{title:a("dashboard.modelTable.title"),description:a("dashboard.modelTable.description"),children:s?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("common.loadingShort")})}):r?e.jsx("div",{className:"max-h-80 overflow-auto rounded-md border",children:e.jsxs(F,{children:[e.jsx(H,{children:e.jsxs(A,{children:[e.jsx(h,{children:a("dashboard.modelTable.columns.model")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.requests")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.latency")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.ttft")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.tpot")})]})}),e.jsx(_,{children:t.map(i=>e.jsxs(A,{children:[e.jsx(u,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:i.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.model})]})}),e.jsx(u,{className:"text-right font-medium",children:i.requests.toLocaleString()}),e.jsx(u,{className:"text-right",children:P(i.avgLatencyMs,a("common.units.ms"))}),e.jsx(u,{className:"text-right",children:P(i.avgTtftMs,a("common.units.ms"))}),e.jsx(u,{className:"text-right",children:P(i.avgTpotMs,a("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${i.provider}/${i.model}`))})]})}):e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("dashboard.modelTable.empty")})})})}function Ee({records:t,loading:s}){const{t:a}=I();return e.jsx(X,{title:a("dashboard.recent.title"),description:a("dashboard.recent.subtitle",{count:5}),children:s?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("dashboard.recent.loading")})}):t.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("dashboard.recent.empty")})}):e.jsx("div",{className:"max-h-80 overflow-auto rounded-md border",children:e.jsxs(F,{children:[e.jsx(H,{children:e.jsxs(A,{children:[e.jsx(h,{children:a("dashboard.recent.columns.time")}),e.jsx(h,{children:a("dashboard.recent.columns.endpoint")}),e.jsx(h,{children:a("dashboard.recent.columns.provider")}),e.jsx(h,{children:a("dashboard.recent.columns.route")}),e.jsx(h,{className:"text-right",children:a("dashboard.recent.columns.latency")}),e.jsx(h,{children:a("dashboard.recent.columns.status")})]})}),e.jsx(_,{children:t.map(r=>e.jsxs(A,{children:[e.jsx(u,{className:"text-xs",children:new Date(r.timestamp).toLocaleString()}),e.jsx(u,{className:"text-xs text-muted-foreground",children:r.endpoint==="anthropic"?a("logs.table.endpointAnthropic"):r.endpoint==="openai"?a("logs.table.endpointOpenAI"):r.endpoint}),e.jsx(u,{className:"font-medium",children:r.provider}),e.jsx(u,{children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:r.client_model??a("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"→"}),e.jsx("span",{className:"font-medium text-foreground",children:r.model})]})}),e.jsx(u,{className:"text-right font-medium",children:P(r.latency_ms,a("common.units.ms"))}),e.jsx(u,{children:e.jsx(k,{variant:r.error?"destructive":"default",children:(r.status_code??(r.error?500:200)).toString()})})]},r.id))})]})})})}export{Ae as default};
@@ -1,4 +1,4 @@
1
- import{c as N,u as E,b as L,r as i,j as e,e as h,C as R,a as $,g as I,h as T,t as P}from"./index-DSWEYKFg.js";import{P as z,B as j}from"./PageHeader-CArgoeOl.js";import{I as F}from"./input-CSRYqyMm.js";import{C as w,a as C,b as V}from"./card-Hot3HWFO.js";import{S as B,a as D,b as K,c as H,d as f}from"./select-qZIYkE-k.js";import{R as J}from"./refresh-cw-Cm_OQO9a.js";/**
1
+ import{c as N,u as E,b as L,r as i,j as e,e as h,C as R,a as $,g as I,h as T,t as P}from"./index-UV1Qa96f.js";import{P as z,B as j}from"./PageHeader-xFKpGYn6.js";import{I as F}from"./input-CBGvcnZr.js";import{C as w,a as C,b as V}from"./card-C20_HqC6.js";import{S as B,a as D,b as K,c as H,d as f}from"./select-C8rWWJbl.js";import{R as J}from"./refresh-cw-ISOSG1Po.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,9 +1,9 @@
1
- import{c as x,u,r as f,j as e,e as h}from"./index-DSWEYKFg.js";import{P as g}from"./PageHeader-CArgoeOl.js";import{P as d}from"./PageSection-B9KNzbSh.js";import{C as p,a as j}from"./card-Hot3HWFO.js";import{I as N}from"./info-C3Uvuy3w.js";/**
1
+ import{c as x,u,r as g,j as e,e as h}from"./index-UV1Qa96f.js";import{P as N}from"./PageHeader-xFKpGYn6.js";import{P as d}from"./PageSection-Vn4S3q9j.js";import{c as p}from"./clipboard-CALi6bTW.js";import{C as j,a as f}from"./card-C20_HqC6.js";import{I as v}from"./info-CewFzdVp.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 v=x("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/**
6
+ */const y=x("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/**
7
7
  * @license lucide-react v0.344.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
@@ -13,11 +13,11 @@ import{c as x,u,r as f,j as e,e as h}from"./index-DSWEYKFg.js";import{P as g}fro
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const y=x("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);function T(){const{t:s}=u(),t=f.useMemo(()=>{const r=s("help.sections.configuration.items",{returnObjects:!0}),l=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),n=s("help.sections.codexConfig.items",{returnObjects:!0}),c=s("help.sections.usage.items",{returnObjects:!0}),a=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:r},{title:s("help.sections.claudeCodeConfig.title"),items:l},{title:s("help.sections.codexConfig.title"),items:n},{title:s("help.sections.usage.title"),items:c},{title:s("help.sections.tips.title"),items:a}]},[s]),i=s("help.faq.items",{returnObjects:!0});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(g,{icon:e.jsx(v,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro")}),e.jsx(p,{children:e.jsxs(j,{className:"flex items-start gap-4 pt-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.note")})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(d,{title:t[0].title,children:e.jsx(o,{items:t[0].items})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(d,{title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg bg-primary/5 p-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"IDE 插件配置"})]})]}),e.jsx(o,{items:t[1].items})]}),e.jsxs(d,{title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg bg-emerald-500/5 p-3 dark:bg-emerald-500/10",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-emerald-500 text-white",children:e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Codex CLI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"命令行工具配置"})]})]}),e.jsx(o,{items:t[2].items})]})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(d,{title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(d,{title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx(d,{title:s("help.faq.title"),children:e.jsx(C,{items:i})})]})}function o({items:s}){return e.jsx("ol",{className:"flex flex-col gap-3",children:s.map((t,i)=>e.jsxs("li",{className:"flex gap-3 rounded-lg border p-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-primary text-xs font-medium text-primary-foreground",children:i+1}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:e.jsx(w,{content:t})})]},`${i}-${t}`))})}function w({content:s}){const{t}=u();if(s.includes("```")){const i=s.split("```");return e.jsx("div",{className:"space-y-2",children:i.map((r,l)=>{if(l%2===0)return r?e.jsx("div",{className:"whitespace-pre-line",children:m(r)},l):null;{const[n,...c]=r.split(`
16
+ */const C=x("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);function T(){const{t:s}=u(),t=g.useMemo(()=>{const r=s("help.sections.configuration.items",{returnObjects:!0}),l=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),n=s("help.sections.codexConfig.items",{returnObjects:!0}),c=s("help.sections.usage.items",{returnObjects:!0}),a=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:r},{title:s("help.sections.claudeCodeConfig.title"),items:l},{title:s("help.sections.codexConfig.title"),items:n},{title:s("help.sections.usage.title"),items:c},{title:s("help.sections.tips.title"),items:a}]},[s]),i=s("help.faq.items",{returnObjects:!0});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(N,{icon:e.jsx(y,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro")}),e.jsx(j,{children:e.jsxs(f,{className:"flex items-start gap-4 pt-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e.jsx(v,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.note")})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(d,{title:t[0].title,children:e.jsx(o,{items:t[0].items})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(d,{title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg bg-primary/5 p-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"IDE 插件配置"})]})]}),e.jsx(o,{items:t[1].items})]}),e.jsxs(d,{title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg bg-emerald-500/5 p-3 dark:bg-emerald-500/10",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-emerald-500 text-white",children:e.jsx(C,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Codex CLI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"命令行工具配置"})]})]}),e.jsx(o,{items:t[2].items})]})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(d,{title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(d,{title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx(d,{title:s("help.faq.title"),children:e.jsx(k,{items:i})})]})}function o({items:s}){return e.jsx("ol",{className:"flex flex-col gap-3",children:s.map((t,i)=>e.jsxs("li",{className:"flex gap-3 rounded-lg border p-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-primary text-xs font-medium text-primary-foreground",children:i+1}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:e.jsx(w,{content:t})})]},`${i}-${t}`))})}function w({content:s}){const{t}=u();if(s.includes("```")){const i=s.split("```");return e.jsx("div",{className:"space-y-2",children:i.map((r,l)=>{if(l%2===0)return r?e.jsx("div",{className:"whitespace-pre-line",children:m(r)},l):null;{const[n,...c]=r.split(`
17
17
  `),a=c.join(`
18
- `);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>navigator.clipboard.writeText(a),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted p-3 text-xs",children:e.jsx("code",{children:a})})]},l)}})})}return s.includes(`
19
- `)?e.jsx("div",{className:"whitespace-pre-line",children:m(s)}):e.jsx("div",{children:m(s)})}function m(s){return s.split(/(\*\*[^*]+\*\*)/g).map((i,r)=>i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:i.slice(2,-2)},r):e.jsx("span",{children:i},r))}function C({items:s}){return s.length===0?null:e.jsx("dl",{className:"flex flex-col gap-3",children:s.map(t=>e.jsx(p,{children:e.jsxs(j,{className:"pt-4",children:[e.jsx("dt",{className:"text-sm font-medium",children:t.q}),e.jsx("dd",{className:"mt-2 text-sm text-muted-foreground",children:e.jsx(k,{content:t.a})})]})},t.q))})}function k({content:s}){const{t}=u();if(s.includes("1)")||s.includes("2)")){const i=s.split(`
18
+ `);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>p(a),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted p-3 text-xs",children:e.jsx("code",{children:a})})]},l)}})})}return s.includes(`
19
+ `)?e.jsx("div",{className:"whitespace-pre-line",children:m(s)}):e.jsx("div",{children:m(s)})}function m(s){return s.split(/(\*\*[^*]+\*\*)/g).map((i,r)=>i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:i.slice(2,-2)},r):e.jsx("span",{children:i},r))}function k({items:s}){return s.length===0?null:e.jsx("dl",{className:"flex flex-col gap-3",children:s.map(t=>e.jsx(j,{children:e.jsxs(f,{className:"pt-4",children:[e.jsx("dt",{className:"text-sm font-medium",children:t.q}),e.jsx("dd",{className:"mt-2 text-sm text-muted-foreground",children:e.jsx(q,{content:t.a})})]})},t.q))})}function q({content:s}){const{t}=u();if(s.includes("1)")||s.includes("2)")){const i=s.split(`
20
20
  `).filter(l=>l.trim());if(i.some(l=>/^\d+\)/.test(l.trim())))return e.jsx("div",{className:"space-y-1",children:i.map((l,n)=>{const c=l.match(/^\d+\)\s*(.*)/);return c?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{children:c[1]})]},n):e.jsx("div",{children:l},n)})})}if(s.includes("```")){const i=s.split("```");return e.jsx("div",{className:"space-y-2",children:i.map((r,l)=>{if(l%2===0)return r?e.jsx("div",{className:"whitespace-pre-line",children:r},l):null;{const[n,...c]=r.split(`
21
21
  `),a=c.join(`
22
- `);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>navigator.clipboard.writeText(a),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted p-3 text-xs",children:e.jsx("code",{children:a})})]},l)}})})}return s.includes(`
22
+ `);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>p(a),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted p-3 text-xs",children:e.jsx("code",{children:a})})]},l)}})})}return s.includes(`
23
23
  `)?e.jsx("div",{className:"whitespace-pre-line",children:s}):e.jsx("div",{children:s})}export{T as default};
@@ -1 +1 @@
1
- import{u as C,ai as E,aj as F,ak as L,r as n,j as e,L as S,e as k}from"./index-DSWEYKFg.js";import{I as j}from"./input-CSRYqyMm.js";import{L as b}from"./label-sxZdAo5j.js";import{C as v,a as w,b as P,c as T,d as A,e as D}from"./card-Hot3HWFO.js";function H(){const{t:s}=C(),i=E(),u=F(),{authEnabled:l,isAuthenticated:m,loading:o,login:N,error:x}=L(),[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(!l&&!o){i(c,{replace:!0});return}l&&m&&!o&&i(c,{replace:!0})},[l,m,o,i,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),i(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(S,{})})})}):l?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{H as default};
1
+ import{u as C,ai as E,aj as F,ak as L,r as n,j as e,L as S,e as k}from"./index-UV1Qa96f.js";import{I as j}from"./input-CBGvcnZr.js";import{L as b}from"./label-BqSverDm.js";import{C as v,a as w,b as P,c as T,d as A,e as D}from"./card-C20_HqC6.js";function H(){const{t:s}=C(),i=E(),u=F(),{authEnabled:l,isAuthenticated:m,loading:o,login:N,error:x}=L(),[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(!l&&!o){i(c,{replace:!0});return}l&&m&&!o&&i(c,{replace:!0})},[l,m,o,i,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),i(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(S,{})})})}):l?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{H as default};