react-docs-ui 0.6.13 → 0.6.15

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 (70) hide show
  1. package/README.md +13 -0
  2. package/dist/AIChatDialog-W60DtiEW.js +418 -0
  3. package/dist/AIProvider-C1_b1iKH.js +1066 -0
  4. package/dist/AISelectionTrigger-MaBGhxTE.js +86 -0
  5. package/dist/AISettingsPanel-aiMnncnQ.js +524 -0
  6. package/dist/DocsApp-BBNDiw8A.js +23556 -0
  7. package/dist/GlobalContextMenu-DG6x5Y5w.js +278 -0
  8. package/dist/MdxContent-CMB8ZbXo.js +850 -0
  9. package/dist/MdxContent.lazy-C4rcCv4v.js +1768 -0
  10. package/dist/SearchDialog-tUSKKsxW.js +403 -0
  11. package/dist/SearchRuntime-5fXpxDsi.js +23 -0
  12. package/dist/context-menu-CB7erSoV.js +73 -0
  13. package/dist/dialog-DQ6nkP0y.js +97 -0
  14. package/dist/docs-app.es.d.ts +1 -0
  15. package/dist/docs-app.es.js +7 -9
  16. package/dist/react-docs-ui.css +2 -1
  17. package/dist/react-docs-ui.es.js +66 -195
  18. package/dist/shiki-highlighter-BmQSSJpS.js +7194 -0
  19. package/dist/theme-provider-fNhx9xK0.js +37 -0
  20. package/dist/types/components/DocsLayout.d.ts +1 -31
  21. package/dist/types/components/DocsLayout.d.ts.map +1 -1
  22. package/dist/types/components/Footer.d.ts +3 -28
  23. package/dist/types/components/Footer.d.ts.map +1 -1
  24. package/dist/types/components/HeaderNav.d.ts.map +1 -1
  25. package/dist/types/components/MdxContent.d.ts.map +1 -1
  26. package/dist/types/components/MobileSidebar.d.ts +1 -1
  27. package/dist/types/components/MobileSidebar.d.ts.map +1 -1
  28. package/dist/types/components/PageNavigation.d.ts +1 -1
  29. package/dist/types/components/PageNavigation.d.ts.map +1 -1
  30. package/dist/types/components/SidebarNav.d.ts +1 -1
  31. package/dist/types/components/SidebarNav.d.ts.map +1 -1
  32. package/dist/types/components/TableOfContents.d.ts +1 -1
  33. package/dist/types/components/TableOfContents.d.ts.map +1 -1
  34. package/dist/types/components/ai/AIChatDialog.d.ts +1 -1
  35. package/dist/types/components/ai/AIChatDialog.d.ts.map +1 -1
  36. package/dist/types/components/ai/AISelectionTrigger.d.ts +1 -1
  37. package/dist/types/components/ai/AISelectionTrigger.d.ts.map +1 -1
  38. package/dist/types/components/ai/AISettingsPanel.d.ts +1 -1
  39. package/dist/types/components/ai/AISettingsPanel.d.ts.map +1 -1
  40. package/dist/types/components/search/SearchItem.d.ts +1 -2
  41. package/dist/types/components/search/SearchItem.d.ts.map +1 -1
  42. package/dist/types/components/ui/button.d.ts +4 -4
  43. package/dist/types/components/ui/button.d.ts.map +1 -1
  44. package/dist/types/components/ui/toast.d.ts +3 -3
  45. package/dist/types/components/ui/toast.d.ts.map +1 -1
  46. package/dist/types/external-modules.d.ts +38 -0
  47. package/dist/types/generated/shiki-bundle.d.ts +1 -0
  48. package/dist/types/generated/shiki-bundle.d.ts.map +1 -1
  49. package/dist/types/lib/ai/crypto.d.ts.map +1 -1
  50. package/dist/types/lib/config.d.ts +0 -4
  51. package/dist/types/lib/config.d.ts.map +1 -1
  52. package/dist/types/lib/export-utils.d.ts.map +1 -1
  53. package/dist/types/lib/frontmatter.d.ts +6 -0
  54. package/dist/types/lib/frontmatter.d.ts.map +1 -0
  55. package/dist/types/lib/rehype-toc.d.ts.map +1 -1
  56. package/dist/types/lib/search/search-index-plugin.d.ts.map +1 -1
  57. package/dist/types/lib/shiki-highlighter.d.ts.map +1 -1
  58. package/dist/types/mdast.d.ts +53 -0
  59. package/dist/use-toast-d9VPBjMn.js +98 -0
  60. package/dist/utils-Ct96Mtjw.js +8 -0
  61. package/package.json +23 -24
  62. package/dist/AISettingsPanel-KzfonkeY.js +0 -1171
  63. package/dist/DocsApp-DTFpyBOl.js +0 -35170
  64. package/dist/GlobalContextMenu-hGNTKw3S.js +0 -210
  65. package/dist/MdxContent-B664V_Hk.js +0 -812
  66. package/dist/MdxContent.lazy-DsQt7MZQ.js +0 -1512
  67. package/dist/SearchDialog-Cfam5kUW.js +0 -406
  68. package/dist/SearchRuntime-Dk265vam.js +0 -31
  69. package/dist/context-menu-CBGG4zJl.js +0 -140
  70. package/dist/index-ByXnCzVt.js +0 -12
@@ -0,0 +1,86 @@
1
+ import { h as e } from "./shiki-highlighter-BmQSSJpS.js";
2
+ import { t } from "./utils-Ct96Mtjw.js";
3
+ import { n } from "./AIProvider-C1_b1iKH.js";
4
+ import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
5
+ import { Bot as s } from "lucide-react";
6
+ import { jsx as c } from "react/jsx-runtime";
7
+ //#region src/components/ai/AISelectionTrigger.tsx
8
+ var l = /* @__PURE__ */ e({ AISelectionTrigger: () => d });
9
+ function u(e, t) {
10
+ let n = a(null);
11
+ return r((...r) => {
12
+ n.current && clearTimeout(n.current), n.current = setTimeout(() => e(...r), t);
13
+ }, [e, t]);
14
+ }
15
+ function d() {
16
+ let { openDialog: e, isConfigured: l, isDialogOpen: d, openSettings: f } = n(), [p, m] = o(""), [h, g] = o(!1), [_, v] = o(!1), [y, b] = o({
17
+ top: 0,
18
+ left: 0
19
+ }), x = a(null), S = a(null), C = r(() => {
20
+ if (d) {
21
+ g(!1);
22
+ return;
23
+ }
24
+ let e = window.getSelection(), t = e?.toString().trim() || "";
25
+ if (t.length < 5) {
26
+ m(""), g(!1);
27
+ return;
28
+ }
29
+ if (m(t), e && e.rangeCount > 0) {
30
+ let t = e.getRangeAt(0).getBoundingClientRect();
31
+ b({
32
+ top: t.bottom + window.scrollY + 8,
33
+ left: t.right + window.scrollX - 40
34
+ }), v(!0), g(!0);
35
+ }
36
+ }, [d]), w = u(C, 150);
37
+ i(() => {
38
+ let e = !1, t = () => {
39
+ e = !0, x.current &&= (clearTimeout(x.current), null);
40
+ }, n = () => {
41
+ e = !1, setTimeout(() => {
42
+ C();
43
+ }, 10);
44
+ }, r = () => {
45
+ e || w();
46
+ }, i = (e) => {
47
+ S.current && !S.current.contains(e.target) && (x.current = setTimeout(() => {
48
+ g(!1);
49
+ }, 200));
50
+ };
51
+ return document.addEventListener("mousedown", t), document.addEventListener("mouseup", n), document.addEventListener("selectionchange", r), document.addEventListener("click", i), () => {
52
+ document.removeEventListener("mousedown", t), document.removeEventListener("mouseup", n), document.removeEventListener("selectionchange", r), document.removeEventListener("click", i), x.current && clearTimeout(x.current);
53
+ };
54
+ }, [C, w]);
55
+ let T = r(() => {
56
+ if (p) {
57
+ if (!l) {
58
+ f();
59
+ return;
60
+ }
61
+ e({
62
+ selectedText: p,
63
+ pageTitle: document.title,
64
+ pageUrl: window.location.href
65
+ }), window.getSelection()?.removeAllRanges(), g(!1), m("");
66
+ }
67
+ }, [
68
+ p,
69
+ l,
70
+ e,
71
+ f
72
+ ]);
73
+ return !h || d ? null : /* @__PURE__ */ c("button", {
74
+ ref: S,
75
+ onClick: T,
76
+ className: t("fixed z-50 flex items-center justify-center w-10 h-10 rounded-full", "bg-primary text-primary-foreground shadow-lg", "hover:bg-primary/90 transition-all duration-200 hover:scale-110", _ && "animate-in zoom-in-50 duration-200"),
77
+ style: {
78
+ top: y.top,
79
+ left: y.left
80
+ },
81
+ title: "向AI询问选中内容",
82
+ children: /* @__PURE__ */ c(s, { className: "w-5 h-5" })
83
+ });
84
+ }
85
+ //#endregion
86
+ export { l as n, d as t };
@@ -0,0 +1,524 @@
1
+ import { h as e } from "./shiki-highlighter-BmQSSJpS.js";
2
+ import { t } from "./utils-Ct96Mtjw.js";
3
+ import { n } from "./use-toast-d9VPBjMn.js";
4
+ import { S as r, d as i, h as ee, l as te, n as a, p as o, s, u as c, v as l } from "./AIProvider-C1_b1iKH.js";
5
+ import { useEffect as u, useState as d } from "react";
6
+ import { Check as f, ExternalLink as p, Eye as m, EyeOff as ne, Info as re, Loader2 as h, Plus as g, Save as ie, Star as ae, Trash2 as _, X as v } from "lucide-react";
7
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
8
+ //#region src/components/ai/AISettingsPanel.tsx
9
+ var S = /* @__PURE__ */ e({ AISettingsPanel: () => C });
10
+ function C() {
11
+ let { isSettingsOpen: e, closeSettings: S, config: C, updateConfig: w } = a(), { toast: T } = n(), [E, D] = d("openai"), [O, k] = d(l("openai")), [A, j] = d(""), [M, N] = d("providers"), [P, F] = d(!1), [I, L] = d(""), [R, z] = d({
12
+ modelId: "",
13
+ apiKey: "",
14
+ baseUrl: "",
15
+ maxTokens: 4096,
16
+ temperature: .7,
17
+ enabled: !0
18
+ }), [B, V] = d(!1), [H, U] = d(!1), [W, G] = d(null), [K, q] = d(!1), [oe, se] = d([
19
+ "openai",
20
+ "claude",
21
+ "gemini"
22
+ ]), ce = [
23
+ "openai",
24
+ "claude",
25
+ "gemini"
26
+ ], J = (e) => ce.includes(e);
27
+ u(() => {
28
+ if (C) {
29
+ let e = C.provider || "openai";
30
+ D(e), k(C.models[e] || l("openai")), j(C.systemPrompt || ""), Y();
31
+ }
32
+ }, [C]);
33
+ let Y = async () => {
34
+ se(await ee());
35
+ }, le = (e) => {
36
+ if (!e) return;
37
+ D(e);
38
+ let t = C?.models[e];
39
+ k(t || l(e)), G(null);
40
+ }, X = (e) => {
41
+ k((t) => ({
42
+ ...t,
43
+ ...e
44
+ })), G(null);
45
+ }, ue = async () => {
46
+ U(!0), G(null);
47
+ try {
48
+ let e = await s(E, O);
49
+ G(e), e.success ? T({
50
+ title: "连接成功",
51
+ description: e.message
52
+ }) : T({
53
+ title: "连接失败",
54
+ description: e.message,
55
+ variant: "destructive"
56
+ });
57
+ } catch (e) {
58
+ let t = e instanceof Error ? e.message : "测试失败";
59
+ G({
60
+ success: !1,
61
+ message: t
62
+ }), T({
63
+ title: "连接失败",
64
+ description: t,
65
+ variant: "destructive"
66
+ });
67
+ } finally {
68
+ U(!1);
69
+ }
70
+ }, de = async () => {
71
+ q(!0);
72
+ try {
73
+ await w({
74
+ provider: E,
75
+ systemPrompt: A,
76
+ models: {
77
+ ...C?.models || {},
78
+ [E]: O
79
+ }
80
+ }), T({
81
+ title: "保存成功",
82
+ description: "配置已保存"
83
+ }), S();
84
+ } catch (e) {
85
+ console.error("Failed to save config:", e), T({
86
+ title: "保存失败",
87
+ description: e instanceof Error ? e.message : "未知错误",
88
+ variant: "destructive"
89
+ });
90
+ } finally {
91
+ q(!1);
92
+ }
93
+ }, Z = async () => {
94
+ if (!I.trim()) {
95
+ T({
96
+ title: "请输入 Provider 名称",
97
+ variant: "destructive"
98
+ });
99
+ return;
100
+ }
101
+ if (J(I)) {
102
+ T({
103
+ title: "不能使用预定义的 Provider 名称",
104
+ variant: "destructive"
105
+ });
106
+ return;
107
+ }
108
+ if (C?.models[I]) {
109
+ T({
110
+ title: "Provider 名称已存在",
111
+ variant: "destructive"
112
+ });
113
+ return;
114
+ }
115
+ let e = r(R);
116
+ if (!e.valid) {
117
+ T({
118
+ title: "配置无效",
119
+ description: e.message,
120
+ variant: "destructive"
121
+ });
122
+ return;
123
+ }
124
+ try {
125
+ await w({ models: {
126
+ ...C?.models || {},
127
+ [I]: R
128
+ } }), F(!1), L(""), z({
129
+ modelId: "",
130
+ apiKey: "",
131
+ baseUrl: "",
132
+ maxTokens: 4096,
133
+ temperature: .7,
134
+ enabled: !0
135
+ }), await Y(), D(I), k(R), T({
136
+ title: "添加成功",
137
+ description: `Provider "${I}" 已添加`
138
+ });
139
+ } catch (e) {
140
+ console.error("Failed to add provider:", e), T({
141
+ title: "添加失败",
142
+ description: e instanceof Error ? e.message : "未知错误",
143
+ variant: "destructive"
144
+ });
145
+ }
146
+ }, fe = async (e) => {
147
+ if (J(e)) {
148
+ T({
149
+ title: "不能删除预定义的 Provider",
150
+ variant: "destructive"
151
+ });
152
+ return;
153
+ }
154
+ if (confirm(`确定要删除 "${e}" 吗?`)) try {
155
+ await o(e), await Y(), E === e && (D("openai"), k(C?.models.openai || l("openai"))), T({
156
+ title: "删除成功",
157
+ description: `Provider "${e}" 已删除`
158
+ });
159
+ } catch (e) {
160
+ console.error("Failed to delete provider:", e), T({
161
+ title: "删除失败",
162
+ description: e instanceof Error ? e.message : "未知错误",
163
+ variant: "destructive"
164
+ });
165
+ }
166
+ }, pe = async () => {
167
+ q(!0);
168
+ try {
169
+ await w({ systemPrompt: A }), T({
170
+ title: "保存成功",
171
+ description: "系统提示词已更新"
172
+ });
173
+ } catch (e) {
174
+ console.error("Failed to save system prompt:", e), T({
175
+ title: "保存失败",
176
+ description: e instanceof Error ? e.message : "未知错误",
177
+ variant: "destructive"
178
+ });
179
+ } finally {
180
+ q(!1);
181
+ }
182
+ };
183
+ if (!e) return null;
184
+ let Q = i(E), $ = te(E), me = J(E);
185
+ return /* @__PURE__ */ x("div", {
186
+ className: "fixed inset-0 z-50 flex items-center justify-center",
187
+ children: [/* @__PURE__ */ b("div", {
188
+ className: "absolute inset-0 bg-black/50",
189
+ onClick: S
190
+ }), /* @__PURE__ */ x("div", {
191
+ className: t("relative bg-background border rounded-xl shadow-2xl", "w-full max-w-2xl mx-4 max-h-[90vh] overflow-hidden", "flex flex-col", "animate-in zoom-in-95 duration-200"),
192
+ children: [
193
+ /* @__PURE__ */ x("div", {
194
+ className: "flex items-center justify-between p-4 border-b",
195
+ children: [/* @__PURE__ */ b("h2", {
196
+ className: "text-lg font-semibold",
197
+ children: "AI 设置"
198
+ }), /* @__PURE__ */ b("button", {
199
+ onClick: S,
200
+ className: "p-1.5 rounded hover:bg-muted transition-colors",
201
+ children: /* @__PURE__ */ b(v, { className: "w-4 h-4" })
202
+ })]
203
+ }),
204
+ /* @__PURE__ */ x("div", {
205
+ className: "flex border-b",
206
+ children: [/* @__PURE__ */ b("button", {
207
+ onClick: () => N("providers"),
208
+ className: t("flex-1 px-4 py-3 text-sm font-medium transition-colors", M === "providers" ? "border-b-2 border-primary text-primary" : "text-muted-foreground hover:text-foreground"),
209
+ children: "Provider 配置"
210
+ }), /* @__PURE__ */ b("button", {
211
+ onClick: () => N("settings"),
212
+ className: t("flex-1 px-4 py-3 text-sm font-medium transition-colors", M === "settings" ? "border-b-2 border-primary text-primary" : "text-muted-foreground hover:text-foreground"),
213
+ children: "系统设置"
214
+ })]
215
+ }),
216
+ /* @__PURE__ */ x("div", {
217
+ className: "flex-1 overflow-y-auto",
218
+ children: [M === "providers" && /* @__PURE__ */ x("div", {
219
+ className: "p-4 space-y-6",
220
+ children: [
221
+ /* @__PURE__ */ x("div", {
222
+ className: "space-y-3",
223
+ children: [/* @__PURE__ */ x("div", {
224
+ className: "flex items-center justify-between",
225
+ children: [/* @__PURE__ */ b("label", {
226
+ className: "text-sm font-medium",
227
+ children: "选择 Provider"
228
+ }), /* @__PURE__ */ x("button", {
229
+ onClick: () => F(!0),
230
+ className: "flex items-center gap-1 px-3 py-1.5 rounded-lg text-sm bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",
231
+ children: [/* @__PURE__ */ b(g, { className: "w-4 h-4" }), "添加"]
232
+ })]
233
+ }), /* @__PURE__ */ b("div", {
234
+ className: "grid grid-cols-2 gap-2",
235
+ children: oe.map((e) => /* @__PURE__ */ x("div", {
236
+ className: t("relative flex items-center justify-between p-3 rounded-lg border transition-colors", E === e ? "bg-primary/10 border-primary" : "bg-background hover:bg-muted border-border"),
237
+ children: [/* @__PURE__ */ x("button", {
238
+ onClick: () => le(e),
239
+ className: "flex-1 text-left",
240
+ children: [/* @__PURE__ */ b("div", {
241
+ className: "font-medium text-sm",
242
+ children: c(e)
243
+ }), C?.provider === e && /* @__PURE__ */ x("div", {
244
+ className: "text-xs text-primary flex items-center gap-1",
245
+ children: [/* @__PURE__ */ b(ae, { className: "w-3 h-3" }), "当前使用"]
246
+ })]
247
+ }), !me && /* @__PURE__ */ b("button", {
248
+ onClick: () => fe(e),
249
+ className: "p-1.5 rounded hover:bg-muted text-destructive",
250
+ title: "删除",
251
+ children: /* @__PURE__ */ b(_, { className: "w-4 h-4" })
252
+ })]
253
+ }, e))
254
+ })]
255
+ }),
256
+ !P && /* @__PURE__ */ x("div", {
257
+ className: "space-y-4",
258
+ children: [
259
+ /* @__PURE__ */ x("h3", {
260
+ className: "text-sm font-medium",
261
+ children: [c(E), " 配置"]
262
+ }),
263
+ /* @__PURE__ */ x("div", {
264
+ className: "space-y-2",
265
+ children: [/* @__PURE__ */ x("div", {
266
+ className: "flex items-center justify-between",
267
+ children: [/* @__PURE__ */ b("label", {
268
+ className: "text-sm font-medium",
269
+ children: "API 密钥"
270
+ }), Q.apiKeyUrl && /* @__PURE__ */ x("a", {
271
+ href: Q.apiKeyUrl,
272
+ target: "_blank",
273
+ rel: "noopener noreferrer",
274
+ className: "text-xs text-primary hover:underline flex items-center gap-1",
275
+ children: ["获取密钥", /* @__PURE__ */ b(p, { className: "w-3 h-3" })]
276
+ })]
277
+ }), /* @__PURE__ */ x("div", {
278
+ className: "relative",
279
+ children: [/* @__PURE__ */ b("input", {
280
+ type: B ? "text" : "password",
281
+ value: O.apiKey,
282
+ onChange: (e) => X({ apiKey: e.target.value }),
283
+ placeholder: "sk-...",
284
+ className: "w-full px-3 py-2 pr-10 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
285
+ }), /* @__PURE__ */ b("button", {
286
+ type: "button",
287
+ onClick: () => V(!B),
288
+ className: "absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground",
289
+ children: b(B ? ne : m, { className: "w-4 h-4" })
290
+ })]
291
+ })]
292
+ }),
293
+ /* @__PURE__ */ x("div", {
294
+ className: "space-y-2",
295
+ children: [/* @__PURE__ */ b("label", {
296
+ className: "text-sm font-medium",
297
+ children: "API 地址"
298
+ }), /* @__PURE__ */ b("input", {
299
+ type: "text",
300
+ value: O.baseUrl,
301
+ onChange: (e) => X({ baseUrl: e.target.value }),
302
+ placeholder: "https://api.openai.com/v1",
303
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
304
+ })]
305
+ }),
306
+ /* @__PURE__ */ x("div", {
307
+ className: "space-y-2",
308
+ children: [/* @__PURE__ */ b("label", {
309
+ className: "text-sm font-medium",
310
+ children: "模型"
311
+ }), $.length > 0 ? /* @__PURE__ */ x("select", {
312
+ value: O.modelId,
313
+ onChange: (e) => X({ modelId: e.target.value }),
314
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring",
315
+ children: [/* @__PURE__ */ b("option", {
316
+ value: "",
317
+ children: "选择模型"
318
+ }), $.map((e) => /* @__PURE__ */ b("option", {
319
+ value: e,
320
+ children: e
321
+ }, e))]
322
+ }) : /* @__PURE__ */ b("input", {
323
+ type: "text",
324
+ value: O.modelId,
325
+ onChange: (e) => X({ modelId: e.target.value }),
326
+ placeholder: "gpt-4o-mini",
327
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
328
+ })]
329
+ }),
330
+ /* @__PURE__ */ x("details", {
331
+ className: "group",
332
+ children: [/* @__PURE__ */ x("summary", {
333
+ className: "cursor-pointer text-sm font-medium flex items-center gap-1",
334
+ children: [/* @__PURE__ */ b("span", { children: "高级设置" }), /* @__PURE__ */ b("span", {
335
+ className: "text-muted-foreground group-open:rotate-90 transition-transform",
336
+ children: "▶"
337
+ })]
338
+ }), /* @__PURE__ */ x("div", {
339
+ className: "mt-4 space-y-4 pl-2",
340
+ children: [/* @__PURE__ */ x("div", {
341
+ className: "space-y-2",
342
+ children: [/* @__PURE__ */ x("div", {
343
+ className: "flex items-center justify-between",
344
+ children: [/* @__PURE__ */ b("label", {
345
+ className: "text-sm",
346
+ children: "温度 (Temperature)"
347
+ }), /* @__PURE__ */ b("span", {
348
+ className: "text-sm text-muted-foreground",
349
+ children: O.temperature.toFixed(1)
350
+ })]
351
+ }), /* @__PURE__ */ b("input", {
352
+ type: "range",
353
+ min: "0",
354
+ max: "2",
355
+ step: "0.1",
356
+ value: O.temperature,
357
+ onChange: (e) => X({ temperature: parseFloat(e.target.value) }),
358
+ className: "w-full"
359
+ })]
360
+ }), /* @__PURE__ */ x("div", {
361
+ className: "space-y-2",
362
+ children: [/* @__PURE__ */ b("label", {
363
+ className: "text-sm",
364
+ children: "最大输出长度 (Max Tokens)"
365
+ }), /* @__PURE__ */ b("input", {
366
+ type: "number",
367
+ min: "1",
368
+ max: "128000",
369
+ value: O.maxTokens,
370
+ onChange: (e) => X({ maxTokens: parseInt(e.target.value) || 4096 }),
371
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
372
+ })]
373
+ })]
374
+ })]
375
+ }),
376
+ W && /* @__PURE__ */ x("div", {
377
+ className: t("flex items-center gap-2 p-3 rounded-lg text-sm", W.success ? "bg-green-500/10 text-green-600 dark:text-green-400" : "bg-destructive/10 text-destructive"),
378
+ children: [W.success ? /* @__PURE__ */ b(f, { className: "w-4 h-4 shrink-0" }) : /* @__PURE__ */ b(re, { className: "w-4 h-4 shrink-0" }), /* @__PURE__ */ b("span", { children: W.message })]
379
+ }),
380
+ /* @__PURE__ */ x("div", {
381
+ className: "flex items-center gap-2 pt-4 border-t",
382
+ children: [/* @__PURE__ */ b("button", {
383
+ onClick: ue,
384
+ disabled: !O.apiKey || !O.modelId || H,
385
+ className: t("flex items-center gap-2 px-4 py-2 rounded-lg text-sm", "border border-border hover:bg-muted transition-colors", "disabled:opacity-50 disabled:cursor-not-allowed"),
386
+ children: H ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(h, { className: "w-4 h-4 animate-spin" }), "测试中..."] }) : "测试连接"
387
+ }), /* @__PURE__ */ b("button", {
388
+ onClick: de,
389
+ disabled: K,
390
+ className: t("flex items-center gap-2 px-4 py-2 rounded-lg text-sm ml-auto", "bg-primary text-primary-foreground hover:bg-primary/90 transition-colors", "disabled:opacity-50 disabled:cursor-not-allowed"),
391
+ children: K ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(h, { className: "w-4 h-4 animate-spin" }), "保存中..."] }) : "保存设置"
392
+ })]
393
+ })
394
+ ]
395
+ }),
396
+ P && /* @__PURE__ */ x("div", {
397
+ className: "space-y-4",
398
+ children: [
399
+ /* @__PURE__ */ b("h3", {
400
+ className: "text-sm font-medium",
401
+ children: "添加自定义 Provider"
402
+ }),
403
+ /* @__PURE__ */ x("div", {
404
+ className: "space-y-2",
405
+ children: [
406
+ /* @__PURE__ */ b("label", {
407
+ className: "text-sm font-medium",
408
+ children: "Provider 名称"
409
+ }),
410
+ /* @__PURE__ */ b("input", {
411
+ type: "text",
412
+ value: I,
413
+ onChange: (e) => L(e.target.value),
414
+ placeholder: "deepseek",
415
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
416
+ }),
417
+ /* @__PURE__ */ b("p", {
418
+ className: "text-xs text-muted-foreground",
419
+ children: "名称将用于标识此 Provider,不能与预定义 Provider 重复"
420
+ })
421
+ ]
422
+ }),
423
+ /* @__PURE__ */ x("div", {
424
+ className: "space-y-2",
425
+ children: [/* @__PURE__ */ b("label", {
426
+ className: "text-sm font-medium",
427
+ children: "API 密钥"
428
+ }), /* @__PURE__ */ b("input", {
429
+ type: B ? "text" : "password",
430
+ value: R.apiKey,
431
+ onChange: (e) => z((t) => ({
432
+ ...t,
433
+ apiKey: e.target.value
434
+ })),
435
+ placeholder: "sk-...",
436
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
437
+ })]
438
+ }),
439
+ /* @__PURE__ */ x("div", {
440
+ className: "space-y-2",
441
+ children: [/* @__PURE__ */ b("label", {
442
+ className: "text-sm font-medium",
443
+ children: "API 地址"
444
+ }), /* @__PURE__ */ b("input", {
445
+ type: "text",
446
+ value: R.baseUrl,
447
+ onChange: (e) => z((t) => ({
448
+ ...t,
449
+ baseUrl: e.target.value
450
+ })),
451
+ placeholder: "https://api.deepseek.com",
452
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
453
+ })]
454
+ }),
455
+ /* @__PURE__ */ x("div", {
456
+ className: "space-y-2",
457
+ children: [/* @__PURE__ */ b("label", {
458
+ className: "text-sm font-medium",
459
+ children: "模型"
460
+ }), /* @__PURE__ */ b("input", {
461
+ type: "text",
462
+ value: R.modelId,
463
+ onChange: (e) => z((t) => ({
464
+ ...t,
465
+ modelId: e.target.value
466
+ })),
467
+ placeholder: "deepseek-chat",
468
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
469
+ })]
470
+ }),
471
+ /* @__PURE__ */ x("div", {
472
+ className: "flex items-center gap-2 pt-4 border-t",
473
+ children: [/* @__PURE__ */ b("button", {
474
+ onClick: () => F(!1),
475
+ className: "px-4 py-2 rounded-lg text-sm border border-border hover:bg-muted transition-colors",
476
+ children: "取消"
477
+ }), /* @__PURE__ */ b("button", {
478
+ onClick: Z,
479
+ disabled: K,
480
+ className: t("flex items-center gap-2 px-4 py-2 rounded-lg text-sm ml-auto", "bg-primary text-primary-foreground hover:bg-primary/90 transition-colors", "disabled:opacity-50 disabled:cursor-not-allowed"),
481
+ children: K ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(h, { className: "w-4 h-4 animate-spin" }), "添加中..."] }) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(g, { className: "w-4 h-4" }), "添加"] })
482
+ })]
483
+ })
484
+ ]
485
+ })
486
+ ]
487
+ }), M === "settings" && /* @__PURE__ */ x("div", {
488
+ className: "p-4 space-y-6",
489
+ children: [/* @__PURE__ */ x("div", {
490
+ className: "space-y-2",
491
+ children: [
492
+ /* @__PURE__ */ b("label", {
493
+ className: "text-sm font-medium",
494
+ children: "系统提示词"
495
+ }),
496
+ /* @__PURE__ */ b("textarea", {
497
+ value: A,
498
+ onChange: (e) => j(e.target.value),
499
+ rows: 6,
500
+ placeholder: "你是一个专业的文档助手,请根据用户的问题,提供准确、有帮助的回答。",
501
+ className: "w-full px-3 py-2 rounded-lg border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-none"
502
+ }),
503
+ /* @__PURE__ */ b("p", {
504
+ className: "text-xs text-muted-foreground",
505
+ children: "系统提示词用于定义 AI 助手的行为和角色"
506
+ })
507
+ ]
508
+ }), /* @__PURE__ */ b("div", {
509
+ className: "flex items-center gap-2 pt-4 border-t",
510
+ children: /* @__PURE__ */ b("button", {
511
+ onClick: pe,
512
+ disabled: K,
513
+ className: t("flex items-center gap-2 px-4 py-2 rounded-lg text-sm ml-auto", "bg-primary text-primary-foreground hover:bg-primary/90 transition-colors", "disabled:opacity-50 disabled:cursor-not-allowed"),
514
+ children: K ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(h, { className: "w-4 h-4 animate-spin" }), "保存中..."] }) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(ie, { className: "w-4 h-4" }), "保存提示词"] })
515
+ })
516
+ })]
517
+ })]
518
+ })
519
+ ]
520
+ })]
521
+ });
522
+ }
523
+ //#endregion
524
+ export { S as n, C as t };