@fgbg/mdocs 1.3.18 → 1.3.20

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 (63) hide show
  1. package/README.md +1 -1
  2. package/agent-skills/changelog/SKILL.md +17 -0
  3. package/agent-skills/index.json +1 -1
  4. package/agent-skills/usage-my-documents/SKILL.md +2 -5
  5. package/agent-skills/usage-search/SKILL.md +34 -12
  6. package/agent-skills/usage-settings/SKILL.md +2 -1
  7. package/dist/server/agent/Agent/tools-documents.js +57 -5
  8. package/dist/server/agent/Agent/tools-documents.js.map +1 -1
  9. package/dist/server/agent/Agent/tools-registry.test.js +2 -0
  10. package/dist/server/agent/Agent/tools-registry.test.js.map +1 -1
  11. package/dist/server/agent/Agent/tools-template.js +3 -1
  12. package/dist/server/agent/Agent/tools-template.js.map +1 -1
  13. package/dist/server/app.js +3 -0
  14. package/dist/server/app.js.map +1 -1
  15. package/dist/server/db/schema.js +11 -0
  16. package/dist/server/db/schema.js.map +1 -1
  17. package/dist/server/documents/document.service.js +9 -1
  18. package/dist/server/documents/document.service.js.map +1 -1
  19. package/dist/server/routes/documents.routes.js +43 -5
  20. package/dist/server/routes/documents.routes.js.map +1 -1
  21. package/dist/server/search/document-index-manager.js +66 -22
  22. package/dist/server/search/document-index-manager.js.map +1 -1
  23. package/dist/server/search/document-index-manager.test.js +24 -17
  24. package/dist/server/search/document-index-manager.test.js.map +1 -1
  25. package/dist/server/search/embedding-admin.js +158 -0
  26. package/dist/server/search/embedding-admin.js.map +1 -0
  27. package/dist/server/search/embedding-model.js +209 -0
  28. package/dist/server/search/embedding-model.js.map +1 -0
  29. package/dist/server/search/embedding-store.js +146 -0
  30. package/dist/server/search/embedding-store.js.map +1 -0
  31. package/dist/server/search/embedding-store.test.js +293 -0
  32. package/dist/server/search/embedding-store.test.js.map +1 -0
  33. package/dist/server/search/search.service.js +126 -48
  34. package/dist/server/search/search.service.js.map +1 -1
  35. package/dist/web/assets/{AgentChatPanel-DTj8Nz0Z.js → AgentChatPanel-BZlAgyrV.js} +3 -3
  36. package/dist/web/assets/{AgentSkillFormCard-DTgxybJh.js → AgentSkillFormCard-CzJG8FK4.js} +3 -3
  37. package/dist/web/assets/AiWriteWorkbench-DiSDDAee.js +7 -0
  38. package/dist/web/assets/{DiagramEditor-NtNY3sZL-B2Aeu79R.js → DiagramEditor-NtNY3sZL-DfkpQX3P.js} +1 -1
  39. package/dist/web/assets/{DocChrome-4qmjr6wa.js → DocChrome-QTGER_Af.js} +1 -1
  40. package/dist/web/assets/{DocumentEditor-KEURMFDp.js → DocumentEditor-DYSRZnJa.js} +1 -1
  41. package/dist/web/assets/{HtmlEditor-jCKtKOCT.js → HtmlEditor-oDPrhq3o.js} +1 -1
  42. package/dist/web/assets/{MergeView-eRcs-x1s.js → MergeView-CbFSN3Bi.js} +4 -4
  43. package/dist/web/assets/{PlaygroundPage-M7fqYn4Z.js → PlaygroundPage-DuMH_V-7.js} +1 -1
  44. package/dist/web/assets/SettingsPage-C_RMO-5M.js +1 -0
  45. package/dist/web/assets/{Toolbar-F3tR5o7R.js → Toolbar-D9FcRwg3.js} +1 -1
  46. package/dist/web/assets/{VisitorPickerModal-CPjKg8ox.js → VisitorPickerModal-CM13Y6jQ.js} +1 -1
  47. package/dist/web/assets/{check-CQSGOkW1.js → check-Bf8YbzH7.js} +1 -1
  48. package/dist/web/assets/{copy-BMAJ--_Y.js → copy-SBghRY2T.js} +1 -1
  49. package/dist/web/assets/{diagram-Bk84WZto.js → diagram-CgEd0hrk.js} +3 -3
  50. package/dist/web/assets/index-CIgmAX2Q.css +1 -0
  51. package/dist/web/assets/index-Cwy87sZC.js +293 -0
  52. package/dist/web/assets/{meta2dEngine-BD2XbzaV-BAZUiXoN.js → meta2dEngine-BD2XbzaV-ulfRZEvk.js} +1 -1
  53. package/dist/web/assets/{motion-DFABYlwt.js → motion-Dyy8pB0Q.js} +1 -1
  54. package/dist/web/assets/{plus-C3uXIATM.js → plus-CEapsZwl.js} +1 -1
  55. package/dist/web/assets/{react-BXGUMaBS.js → react-BkX5Koku.js} +3 -3
  56. package/dist/web/assets/ui-ZPt_BNBg.js +3165 -0
  57. package/dist/web/index.html +5 -5
  58. package/package.json +4 -2
  59. package/dist/web/assets/AiWriteWorkbench-D2RzXzty.js +0 -7
  60. package/dist/web/assets/SettingsPage-mS3g_vBq.js +0 -1
  61. package/dist/web/assets/index-C8iEyMxp.css +0 -1
  62. package/dist/web/assets/index-DUu4Is5p.js +0 -293
  63. package/dist/web/assets/ui-CvA4pq3d.js +0 -3116
@@ -3,35 +3,61 @@ import { dict } from "@node-rs/jieba/dict.js";
3
3
  import { getDb } from "../db/connection.js";
4
4
  import { findDomainById, isDomainMember } from "../db/repositories/domain.repo.js";
5
5
  import { canReadDocument } from "../access/access-control.js";
6
+ import { querySemanticNeighbors } from "./embedding-store.js";
6
7
  /** 与索引写入侧一致:查询也先 jieba,再交给 FTS5 */
7
8
  const JIEBA = Jieba.withDict(dict);
8
9
  /** 标题命中权重(相对正文) */
9
10
  const W_TITLE = 3.0;
10
11
  /** 正文命中权重 */
11
12
  const W_BODY = 1.0;
13
+ /** 仅语义命中时的权重(低于标题) */
14
+ const W_SEMANTIC = 0.8;
12
15
  /**
13
- * 在全文索引中搜索文档。
14
- *
15
- * 流程:
16
- * 1. 标题索引 MATCH → 正文索引 MATCH
17
- * 2. 按 document_id 合并,final = W_TITLE * title_rank + W_BODY * body_rank
18
- * 3. 按 domainId 过滤(若传入,已在 SQL 下推)
19
- * 4. 对每个匹配文档执行 canReadDocument 权限检查
20
- * 5. 截取 topN 条结果
21
- *
22
- * @param visitorId 当前访客 ID(未登录为 null)
16
+ * 查询分词:与索引写入/FTS MATCH 同一套 jieba 切词。
17
+ * 供前端在标题/摘要中做命中高亮。
23
18
  */
24
- export function searchDocuments(params) {
19
+ export function tokenizeQuery(query) {
20
+ const trimmed = query.trim().replace(/"/g, "");
21
+ if (!trimmed)
22
+ return [];
23
+ const words = JIEBA.cutForSearch(trimmed, true)
24
+ .map((w) => w.trim())
25
+ .filter((w) => w.length > 0);
26
+ return Array.from(new Set(words));
27
+ }
28
+ function escapeFts5Query(query) {
29
+ return tokenizeQuery(query).map((w) => `"${w}"`).join(" ");
30
+ }
31
+ /**
32
+ * 在全文索引中搜索文档(按 mode 选择检索路)。
33
+ */
34
+ export async function searchDocuments(params) {
25
35
  const db = getDb();
26
36
  const topN = params.topN ?? 10;
27
- // 标题路少取一些即可;正文路多取供权限过滤后仍够
28
- const titleRows = queryTitleFts(db, params.query, topN * 2, params.domainId);
29
- const bodyRows = queryBodyFts(db, params.query, topN * 4, params.domainId);
30
- const merged = mergeFtsHits(titleRows, bodyRows);
37
+ const mode = params.mode === "keyword" || params.mode === "semantic" ? params.mode : "auto";
38
+ let merged;
39
+ if (mode === "semantic") {
40
+ // 仅语义:不查 FTS;模型未就绪时 trySemanticHits 返回空
41
+ const semanticHits = await trySemanticHits(params.query, params.domainId, topN * 3);
42
+ merged = mergeFtsAndSemantic([], semanticHits);
43
+ }
44
+ else {
45
+ const titleRows = queryTitleFts(db, params.query, topN * 2, params.domainId);
46
+ const bodyRows = queryBodyFts(db, params.query, topN * 4, params.domainId);
47
+ const ftsMerged = mergeFtsHits(titleRows, bodyRows);
48
+ if (mode === "keyword") {
49
+ merged = ftsMerged;
50
+ }
51
+ else {
52
+ const semanticHits = await trySemanticHits(params.query, params.domainId, topN * 3);
53
+ merged = mergeFtsAndSemantic(ftsMerged, semanticHits);
54
+ }
55
+ }
31
56
  if (merged.length === 0)
32
57
  return [];
33
58
  const metaById = loadDocumentSearchMeta(db, merged.map((r) => r.document_id));
34
- // ---- 权限过滤 ----
59
+ // 语义-only 命中可能缺少 FTS 里的 display/path;从主表补
60
+ fillMissingDocFields(db, merged);
35
61
  const domainIds = Array.from(new Set(merged.map((r) => r.domain_id)));
36
62
  const domainCache = new Map();
37
63
  for (const did of domainIds) {
@@ -63,7 +89,7 @@ export function searchDocuments(params) {
63
89
  continue;
64
90
  const snippet = row.bodyContent.length > 0
65
91
  ? extractSnippet(row.bodyContent, params.query, 200)
66
- : row.display_name || "标题命中";
92
+ : row.semanticSnippet || row.display_name || "标题命中";
67
93
  const meta = metaById.get(row.document_id);
68
94
  results.push({
69
95
  documentId: row.document_id,
@@ -74,13 +100,32 @@ export function searchDocuments(params) {
74
100
  bm25Score: row.finalScore,
75
101
  ownerVisitorName: meta?.ownerVisitorName ?? "",
76
102
  updatedAt: meta?.updatedAt ?? "",
103
+ createdAt: meta?.createdAt,
104
+ matchSource: row.matchSource,
105
+ titleHit: row.titleHit,
106
+ bodyHit: row.bodyHit,
107
+ semanticHit: row.semanticHit,
77
108
  });
78
109
  if (results.length >= topN)
79
110
  break;
80
111
  }
81
112
  return results;
82
113
  }
83
- /** 从主表批量取作者名与更新时间(不冗余进 FTS) */
114
+ async function trySemanticHits(query, domainId, topK) {
115
+ try {
116
+ const hits = await querySemanticNeighbors({ query, domainId, topK });
117
+ return hits.map((h) => ({
118
+ document_id: h.documentId,
119
+ domain_id: h.domainId,
120
+ score: h.score,
121
+ snippet: h.snippet,
122
+ }));
123
+ }
124
+ catch {
125
+ return [];
126
+ }
127
+ }
128
+ /** 从主表批量取作者名与更新/创建时间(不冗余进 FTS) */
84
129
  function loadDocumentSearchMeta(db, documentIds) {
85
130
  const out = new Map();
86
131
  const ids = Array.from(new Set(documentIds.filter(Boolean)));
@@ -88,7 +133,7 @@ function loadDocumentSearchMeta(db, documentIds) {
88
133
  return out;
89
134
  const placeholders = ids.map(() => "?").join(",");
90
135
  const rows = db
91
- .prepare(`SELECT d.document_id, d.updated_at,
136
+ .prepare(`SELECT d.document_id, d.updated_at, d.created_at,
92
137
  COALESCE(v.visitor_name, '') AS owner_visitor_name
93
138
  FROM documents d
94
139
  LEFT JOIN visitors v ON v.visitor_id = d.owner_visitor_id
@@ -98,13 +143,35 @@ function loadDocumentSearchMeta(db, documentIds) {
98
143
  out.set(row.document_id, {
99
144
  ownerVisitorName: row.owner_visitor_name,
100
145
  updatedAt: row.updated_at,
146
+ createdAt: row.created_at,
101
147
  });
102
148
  }
103
149
  return out;
104
150
  }
151
+ function fillMissingDocFields(db, merged) {
152
+ const need = merged.filter((r) => !r.display_name || !r.relative_path || !r.owner_visitor_id);
153
+ if (need.length === 0)
154
+ return;
155
+ const ids = need.map((r) => r.document_id);
156
+ const placeholders = ids.map(() => "?").join(",");
157
+ const rows = db
158
+ .prepare(`SELECT document_id, display_name, relative_path, domain_id, owner_visitor_id, permission
159
+ FROM documents WHERE document_id IN (${placeholders})`)
160
+ .all(...ids);
161
+ const byId = new Map(rows.map((r) => [r.document_id, r]));
162
+ for (const hit of need) {
163
+ const row = byId.get(hit.document_id);
164
+ if (!row)
165
+ continue;
166
+ hit.display_name = hit.display_name || row.display_name;
167
+ hit.relative_path = hit.relative_path || row.relative_path;
168
+ hit.domain_id = hit.domain_id || row.domain_id;
169
+ hit.owner_visitor_id = hit.owner_visitor_id || row.owner_visitor_id;
170
+ hit.permission = hit.permission || row.permission;
171
+ }
172
+ }
105
173
  /**
106
174
  * FTS5 bm25:越小(越负)越好。映射到 (0, 1],越大越好。
107
- * 使用 sigmoid,避免负分被 max(0,·) 压扁成同一档。
108
175
  */
109
176
  function rankFromBm25(bm25) {
110
177
  return 1 / (1 + Math.exp(bm25));
@@ -157,10 +224,49 @@ function mergeFtsHits(titleRows, bodyRows) {
157
224
  owner_visitor_id: row.owner_visitor_id,
158
225
  permission: row.permission,
159
226
  bodyContent: row.bodyContent,
227
+ semanticSnippet: "",
160
228
  finalScore: W_TITLE * row.titleRank + W_BODY * row.bodyRank,
229
+ titleHit: row.titleRank > 0,
230
+ bodyHit: row.bodyRank > 0,
231
+ semanticHit: false,
232
+ matchSource: "fts",
161
233
  }))
162
234
  .sort((a, b) => b.finalScore - a.finalScore);
163
235
  }
236
+ function mergeFtsAndSemantic(fts, semantic) {
237
+ const map = new Map();
238
+ for (const row of fts) {
239
+ map.set(row.document_id, { ...row });
240
+ }
241
+ for (const hit of semantic) {
242
+ const existing = map.get(hit.document_id);
243
+ if (existing) {
244
+ existing.matchSource = "both";
245
+ existing.semanticHit = true;
246
+ if (!existing.semanticSnippet)
247
+ existing.semanticSnippet = hit.snippet;
248
+ // FTS 分保留;不抬升语义以免压过标题命中
249
+ }
250
+ else {
251
+ map.set(hit.document_id, {
252
+ document_id: hit.document_id,
253
+ display_name: "",
254
+ relative_path: "",
255
+ domain_id: hit.domain_id,
256
+ owner_visitor_id: "",
257
+ permission: 1,
258
+ bodyContent: "",
259
+ semanticSnippet: hit.snippet,
260
+ finalScore: W_SEMANTIC * Math.max(0, hit.score),
261
+ titleHit: false,
262
+ bodyHit: false,
263
+ semanticHit: true,
264
+ matchSource: "semantic",
265
+ });
266
+ }
267
+ }
268
+ return Array.from(map.values()).sort((a, b) => b.finalScore - a.finalScore);
269
+ }
164
270
  function queryTitleFts(db, query, limit, domainIdPattern) {
165
271
  const safeQuery = escapeFts5Query(query);
166
272
  if (!safeQuery)
@@ -198,36 +304,9 @@ function queryBodyFts(db, query, limit, domainIdPattern) {
198
304
  .all(...params);
199
305
  }
200
306
  catch {
201
- // FTS5 语法异常或表尚未就绪时返回空(降级:标题路仍可能有结果)
202
307
  return [];
203
308
  }
204
309
  }
205
- /**
206
- * 将用户查询分词并转义为 FTS5 MATCH 表达式。
207
- *
208
- * 索引写入侧对中文做了 jieba cutForSearch;查询必须同样分词,否则整句
209
- * `"恢复码"` 无法命中已拆成 `恢复` / `码` 的索引。
210
- * 每个 token 用双引号包裹,避免 FTS5 特殊字符被解释为操作符。
211
- */
212
- function escapeFts5Query(query) {
213
- const trimmed = query.trim().replace(/"/g, "");
214
- if (!trimmed)
215
- return "";
216
- const words = JIEBA.cutForSearch(trimmed, true)
217
- .map((w) => w.trim())
218
- .filter((w) => w.length > 0);
219
- if (words.length === 0)
220
- return "";
221
- // 去重:cutForSearch 会产出重叠 token
222
- return Array.from(new Set(words)).map((w) => `"${w}"`).join(" ");
223
- }
224
- /**
225
- * 从文档内容中提取包含查询词的片段。
226
- *
227
- * @param text 文档全文(索引侧可能是分词后文本)
228
- * @param query 用户查询
229
- * @param maxLen 片段最大长度,默认 200 字符
230
- */
231
310
  function extractSnippet(text, query, maxLen = 200) {
232
311
  if (text.length <= maxLen)
233
312
  return text;
@@ -235,7 +314,6 @@ function extractSnippet(text, query, maxLen = 200) {
235
314
  const lowerQuery = query.toLowerCase();
236
315
  const idx = lowerText.indexOf(lowerQuery);
237
316
  if (idx === -1) {
238
- // 未找到精确匹配(FTS 可能匹配了词干变体),返回开头
239
317
  return text.slice(0, maxLen) + "…";
240
318
  }
241
319
  const start = Math.max(0, idx - Math.floor(maxLen / 4));
@@ -1 +1 @@
1
- {"version":3,"file":"search.service.js","sourceRoot":"","sources":["../../../src/server/search/search.service.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAI9D,mCAAmC;AACnC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEnC,mBAAmB;AACnB,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,aAAa;AACb,MAAM,MAAM,GAAG,GAAG,CAAC;AAgBnB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,MAK/B;IACC,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;IAE/B,0BAA0B;IAC1B,MAAM,SAAS,GAAG,aAAa,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,MAAM,CAAC,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AAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,OAAO,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAClD,CAAC"}
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram-Bk84WZto.js","assets/ui-CvA4pq3d.js","assets/react-vendor-BuABiQkA.js","assets/motion-DFABYlwt.js"])))=>i.map(i=>d[i]);
2
- import{r as i,j as e,_ as ct,b as dt}from"./react-vendor-BuABiQkA.js";import{o as ae,N as Ke,C as ut,an as Xe,Y as ne,ao as qe,ap as mt,q as Fe,aq as Pe,ar as pt,as as ft,at as ht,au as gt,av as xt,aw as yt,ax as Ue,ay as jt,az as kt,aA as Nt}from"./index-DUu4Is5p.js";import{H as bt,S as vt,A as wt,a as Ct}from"./AgentSkillFormCard-DTgxybJh.js";import{C as Ye}from"./check-CQSGOkW1.js";import{C as Ge}from"./copy-BMAJ--_Y.js";import{P as St}from"./plus-C3uXIATM.js";import{ae as At,af as _t}from"./ui-CvA4pq3d.js";import"./diagram-Bk84WZto.js";import"./motion-DFABYlwt.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram-CgEd0hrk.js","assets/ui-ZPt_BNBg.js","assets/react-vendor-BuABiQkA.js","assets/motion-Dyy8pB0Q.js"])))=>i.map(i=>d[i]);
2
+ import{r as i,j as e,_ as ct,b as dt}from"./react-vendor-BuABiQkA.js";import{o as ae,N as Ke,C as ut,aq as Xe,Y as ne,ar as qe,as as mt,q as Fe,at as Pe,au as pt,av as ft,aw as ht,ax as gt,ay as xt,az as yt,aA as Ue,aB as jt,aC as kt,aD as Nt}from"./index-Cwy87sZC.js";import{H as bt,S as vt,A as wt,a as Ct}from"./AgentSkillFormCard-CzJG8FK4.js";import{C as Ye}from"./check-Bf8YbzH7.js";import{C as Ge}from"./copy-SBghRY2T.js";import{P as St}from"./plus-CEapsZwl.js";import{an as At,ao as _t}from"./ui-ZPt_BNBg.js";import"./diagram-CgEd0hrk.js";import"./motion-Dyy8pB0Q.js";/**
3
3
  * @license lucide-react v0.562.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -19,4 +19,4 @@ import{r as i,j as e,_ as ct,b as dt}from"./react-vendor-BuABiQkA.js";import{o a
19
19
  *
20
20
  * This source code is licensed under the ISC license.
21
21
  * See the LICENSE file in the root directory of this source tree.
22
- */const zt=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Dt=ae("zoom-out",zt);function je(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(je).join(""):typeof s=="object"&&"props"in s?je((n=s.props)==null?void 0:n.children):""}function qt(s){return s?/\blanguage-mermaid\b|\bmermaid\b/i.test(s):!1}function Ft(s){const n=Array.isArray(s)?s:[s];for(const a of n){if(a==null||typeof a!="object"||!("props"in a))continue;const c=a.props;if(!(!c||!qt(c.className)))return je(c.children).replace(/\n$/,"")}return null}const Pt=.4,Lt=4,se=.2;let xe=null;function Bt(){return xe||(xe=ct(()=>import("./diagram-Bk84WZto.js").then(s=>s.z),__vite__mapDeps([0,1,2,3])).then(s=>{const n=s.default;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral",fontFamily:"ui-sans-serif, system-ui, sans-serif"}),n})),xe}const Ot=32,W=new Map;function Le(s){return W.get(s)??null}function Wt(s,n){for(W.has(s)&&W.delete(s),W.set(s,n);W.size>Ot;){const a=W.keys().next().value;if(a==null)break;W.delete(a)}}function ye(s){return Math.min(Lt,Math.max(Pt,s))}function Ht(s){const[n,a]=i.useState(1),[c,b]=i.useState({x:0,y:0}),h=i.useRef(null),[A,y]=i.useState(!1);i.useEffect(()=>{const u=I=>{I.key==="Escape"&&s.onClose()};window.addEventListener("keydown",u);const m=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",u),document.body.style.overflow=m}},[s.onClose]);function _(u){u.button===0&&(u.currentTarget.setPointerCapture(u.pointerId),h.current={pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,originX:c.x,originY:c.y},y(!0))}function C(u){const m=h.current;!m||m.pointerId!==u.pointerId||b({x:m.originX+(u.clientX-m.startX),y:m.originY+(u.clientY-m.startY)})}function E(u){const m=h.current;if(!(!m||m.pointerId!==u.pointerId)){h.current=null,y(!1);try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}}}function N(u){u.preventDefault();const m=u.deltaY>0?-se:se;a(I=>ye(Number((I+m).toFixed(2))))}return dt.createPortal(e.jsxs("div",{className:"mdocs-agent-mermaid-float",role:"dialog","aria-modal":"true","aria-label":"Mermaid 图预览",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-backdrop","aria-label":"关闭预览",onClick:s.onClose}),e.jsxs("div",{className:"mdocs-agent-mermaid-float-chrome",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-float-tools",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u-se).toFixed(2)))),title:"缩小","aria-label":"缩小",children:e.jsx(Dt,{size:16,"aria-hidden":!0})}),e.jsxs("span",{className:"mdocs-agent-mermaid-float-scale",children:[Math.round(n*100),"%"]}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u+se).toFixed(2)))),title:"放大","aria-label":"放大",children:e.jsx(Tt,{size:16,"aria-hidden":!0})}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>{a(1),b({x:0,y:0})},title:"重置",children:"重置"}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:s.onClose,title:"关闭","aria-label":"关闭",children:e.jsx(ne,{size:16,"aria-hidden":!0})})]}),e.jsx("div",{className:A?"mdocs-agent-mermaid-float-stage is-dragging":"mdocs-agent-mermaid-float-stage",onPointerDown:_,onPointerMove:C,onPointerUp:E,onPointerCancel:E,onWheel:N,children:e.jsx("div",{className:"mdocs-agent-mermaid-float-canvas",style:{transform:`translate(calc(-50% + ${c.x}px), calc(-50% + ${c.y}px)) scale(${n})`},dangerouslySetInnerHTML:{__html:s.svg}})}),e.jsx("p",{className:"mdocs-agent-mermaid-float-hint",children:"拖动平移 · 滚轮缩放 · Esc 关闭"})]})]}),document.body)}function Kt(s){const n=i.useId().replace(/:/g,""),[a,c]=i.useState("diagram"),[b,h]=i.useState(()=>Le(s.source.trim())),[A,y]=i.useState(null),[_,C]=i.useState(!1),[E,N]=i.useState(!1),u=i.useRef(null),m=s.source.trim(),I=i.useMemo(()=>m,[m]);i.useEffect(()=>()=>{u.current!=null&&window.clearTimeout(u.current)},[]),i.useEffect(()=>{if(a!=="diagram")return;if(!I){h(null),y(null);return}const j=Le(I);if(j){h(j),y(null);return}let M=!1;const P=window.setTimeout(()=>{(async()=>{try{const F=await Bt();if(M)return;const T=`mdocs-agent-mmd-${n}-${Date.now()}`,{svg:R}=await F.render(T,I);if(M)return;Wt(I,R),h(R),y(null)}catch(F){if(M)return;h(null),y(F instanceof Error?F.message:"Mermaid 渲染失败")}})()},200);return()=>{M=!0,window.clearTimeout(P)}},[a,I,n]);async function H(){!m||!await Xe(m)||(C(!0),u.current!=null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>C(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-mermaid",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toolbar",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toggle",role:"group","aria-label":"Mermaid 显示模式",children:[e.jsxs("button",{type:"button",className:a==="diagram"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("diagram"),"aria-pressed":a==="diagram",title:"图谱",children:[e.jsx(Ke,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"图谱"})]}),e.jsxs("button",{type:"button",className:a==="code"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("code"),"aria-pressed":a==="code",title:"代码",children:[e.jsx(ut,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"代码"})]})]}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy mdocs-agent-mermaid-copy",onClick:()=>void H(),"aria-label":_?"已复制":"复制代码",title:_?"已复制":"复制",children:_?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})})]}),a==="diagram"?e.jsx("div",{className:"mdocs-agent-mermaid-diagram",children:A?e.jsxs("div",{className:"mdocs-agent-mermaid-error",role:"alert",children:[e.jsx("p",{children:"无法渲染该图,可切换到代码查看源码。"}),e.jsx("pre",{children:A})]}):b?e.jsx("div",{className:"mdocs-agent-mermaid-svg mdocs-agent-mermaid-svg-hit",role:"button",tabIndex:0,onClick:()=>N(!0),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),N(!0))},title:"点击放大预览","aria-label":"点击放大预览 Mermaid 图",children:e.jsx("span",{className:"mdocs-agent-mermaid-svg-inner",dangerouslySetInnerHTML:{__html:b}})}):e.jsx("div",{className:"mdocs-agent-mermaid-loading",children:"渲染中…"})}):e.jsx("div",{className:"mdocs-agent-panel-md-pre-wrap mdocs-agent-mermaid-code",children:e.jsx("pre",{children:s.codeChildren??e.jsx("code",{className:"language-mermaid",children:m})})}),E&&b?e.jsx(Ht,{svg:b,onClose:()=>N(!1)}):null]})}const Xt=i.memo(Kt,(s,n)=>s.source===n.source);function ke(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(ke).join(""):typeof s=="object"&&"props"in s?ke((n=s.props)==null?void 0:n.children):""}function Ut(s){const[n,a]=i.useState(!1),c=i.useRef(null),b=i.useRef(null),h=ke(s.children).replace(/\n$/,"");i.useEffect(()=>()=>{c.current!=null&&window.clearTimeout(c.current)},[]);async function A(y){var N,u,m;y.preventDefault(),y.stopPropagation();const C=(((m=(u=(N=b.current)==null?void 0:N.querySelector("pre"))==null?void 0:u.innerText)==null?void 0:m.replace(/\n$/,""))??"")||h;!C||!await Xe(C)||(a(!0),c.current!=null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",ref:b,children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:y=>void A(y),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:s.children})]})}function Yt(s){const n=Ft(s.children);return n!=null?e.jsx(Xt,{source:n,codeChildren:s.children}):e.jsx(Ut,{children:s.children})}const Gt={pre:({children:s})=>e.jsx(Yt,{children:s})},Be=i.memo(function(n){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(At,{remarkPlugins:[_t],components:Gt,children:n.children})})}),Vt=["如何发布文档?","草稿是什么?","如何创建工作空间?"];function Oe(s,n){return n.map((a,c)=>{const b=a.skillNames&&a.skillNames.length>0?a.skillNames:a.skillIds&&a.skillIds.length>0?a.skillIds:void 0;return{id:`h-${s}-${c}-${a.role}`,role:a.role,content:a.content,skillNames:b}})}function Jt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="text"?a[a.length-1]={type:"text",text:c.text+n}:a.push({type:"text",text:n}),a}function Zt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="thinking"?a[a.length-1]={type:"thinking",text:c.text+n}:a.push({type:"thinking",text:n}),a}function We(s){return s!=null&&s.length?s.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Qt(s){return!!(s!=null&&s.some(n=>n.type==="thinking"&&n.text.length>0))}function es(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return"";const a=new Date;return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function He(s){if(s>=1e3){const n=s/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(s)}function ts(s){const{block:n,onResolved:a}=s,[c,b]=i.useState(""),[h,A]=i.useState(!1),[y,_]=i.useState(1),C=i.useRef(!1),E=i.useRef(a);E.current=a;const N=n.status==="open",u=i.useRef(0);i.useEffect(()=>{if(!N)return;C.current=!1;const j=new Date(n.expiresAt).getTime(),M=Date.now(),P=Math.max(j-M,1);u.current=P,_(1);const F=()=>{const R=j-Date.now(),p=Math.max(0,Math.min(1,R/P));_(p),R<=0&&!C.current&&(C.current=!0,kt(n.requestId).catch(()=>{}).finally(()=>{E.current(n.requestId,"","expired")}))};F();const T=window.setInterval(F,100);return()=>window.clearInterval(T)},[N,n.expiresAt,n.requestId]);async function m(j){const M=j.trim();if(!(!M||h||!N)){A(!0);try{await Nt(n.requestId,M),a(n.requestId,M,"selected")}catch{a(n.requestId,M,"failed")}finally{A(!1)}}}async function I(){if(!(h||!N)){A(!0),C.current=!0;try{await Ue(n.requestId),a(n.requestId,"","cancelled")}catch{a(n.requestId,"","failed")}finally{A(!1)}}}const H=Math.max(0,Math.ceil(y*u.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(N?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),N?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[H,"s"]}):null]}),N?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(y*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${y})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,N?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(j=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:h,onClick:()=>void m(j),children:j},j))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:c,disabled:h,placeholder:"或输入自己的内容…",onChange:j=>b(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),m(c))}}),e.jsx("button",{type:"button",disabled:h||!c.trim(),onClick:()=>void m(c),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:h,onClick:()=>void I(),children:"取消"})})]}):null]})}function ss(s){const b=2*Math.PI*8.75,h=Math.min(100,Math.max(0,s.percent)),A=b*(1-h/100),y=h>=90?"danger":h>=70?"warn":"ok",_=`上下文 ${h}% · 已用 ${He(s.used)} / ${He(s.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+y,"data-tooltip":_,"aria-label":_,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:A,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function ns(s){var n;for(const a of s)if(!(a.role!=="assistant"||!((n=a.blocks)!=null&&n.length))){for(const c of a.blocks)if((c.type==="choice_card"||c.type==="skill_form_card")&&c.status==="open")return!0}return!1}const ps=i.forwardRef(function(n,a){const{open:c,onClose:b,visitorName:h,anchorStyle:A,fullscreen:y,onToggleFullscreen:_,domainId:C,documentId:E,documentTitle:N,documentPath:u,graphFileId:m,graphLabel:I,onOpenDocument:H,onTreeChanged:j,onDocumentOverwritten:M,onOpenCoding:P}=n,F=((h==null?void 0:h.trim().charAt(0))||"我").toUpperCase(),[T,R]=i.useState(!1),[p,U]=i.useState(null),[Ve,Y]=i.useState(null),[z,w]=i.useState([]),[re,G]=i.useState(null),[Ne,Je]=i.useState([]),[Ze,be]=i.useState(!1),[V,J]=i.useState(""),[X,ve]=i.useState([]),[we,ie]=i.useState(!1),[v,Z]=i.useState(!1),[Ce,L]=i.useState(null),[Q,Se]=i.useState(null),[oe,O]=i.useState(!1),[B,Ae]=i.useState(!1),Qe=i.useRef(null),ee=i.useRef(null),D=i.useRef(null),_e=i.useRef(0),K=i.useRef(!0),[et,le]=i.useState(!1),ce=i.useRef(z);ce.current=z;const Ie=!!(E!=null&&E.trim())&&!we,tt=(N==null?void 0:N.trim())||"当前文档",Me=(u==null?void 0:u.trim())||"",de=!!(m!=null&&m.trim())&&!we,st=(I==null?void 0:I.trim())||"当前图谱";i.useEffect(()=>{ie(!1)},[E,m]);function Ee(t){return _e.current+=1,`${t}-${_e.current}`}const Re=120;function $e(t){return t.scrollHeight-t.scrollTop-t.clientHeight}function te(){const t=ee.current;t&&(t.scrollTop=t.scrollHeight,le(!1))}function q(){K.current&&te()}function nt(){const t=ee.current;if(!t)return;const f=$e(t);K.current=f<=48,le(f>Re)}function at(){K.current=!0,te()}i.useLayoutEffect(()=>{q();const t=ee.current;t&&le($e(t)>Re)},[z]);async function rt(){be(!0);try{const t=await ht();Je(t.sessions),re||G(t.lastOpenedSessionId)}catch{}finally{be(!1)}}async function ue(){try{const t=await ft();Se(t)}catch{}}async function Te(){try{const t=await qe();U(t),Y(null)}catch(t){U(null),Y(t instanceof Error?t.message:String(t))}}i.useEffect(()=>{var f;if(!c){R(!1),(f=D.current)==null||f.abort(),D.current=null,Z(!1);return}let t=!1;return(async()=>{try{const o=await qe();t||(U(o),Y(null))}catch(o){t||(U(null),Y(o instanceof Error?o.message:String(o)))}})(),ue(),()=>{t=!0}},[c]),i.useEffect(()=>{if(!c)return;let t=!1;return(async()=>{try{const f=await mt();if(t)return;G(f.sessionId),w(o=>o.length>0?o:Oe(f.sessionId,f.messages))}catch{}})(),()=>{t=!0}},[c]),i.useEffect(()=>{!c||!T||rt()},[c,T]);function me(){if(!B){if(ns(ce.current)){O(!0);return}O(!1),b()}}async function it(){var o;if(B)return;Ae(!0);const t=ce.current,f=[];for(const S of t)if(!(S.role!=="assistant"||!S.blocks))for(const g of S.blocks)g.type==="choice_card"&&g.status==="open"&&f.push(Ue(g.requestId).catch(()=>{})),g.type==="skill_form_card"&&g.status==="open"&&f.push(jt(g.requestId).catch(()=>{}));await Promise.all(f),(o=D.current)==null||o.abort(),w(S=>S.map(g=>g.role!=="assistant"||!g.blocks?g:{...g,blocks:g.blocks.map(x=>x.type==="choice_card"&&x.status==="open"?{...x,status:"cancelled"}:x.type==="skill_form_card"&&x.status==="open"?{...x,status:"cancelled"}:x)})),O(!1),Ae(!1),b()}const pe=i.useRef(me);pe.current=me,i.useImperativeHandle(a,()=>({requestClose:()=>pe.current()}),[]),i.useEffect(()=>{if(!c){O(!1);return}const t=f=>{if(f.key==="Escape"){if(oe){B||O(!1);return}if(T){R(!1);return}pe.current()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[c,T,oe,B]);async function fe(t){var x;const f=t.trim();if(!f||v)return;if(!(p!=null&&p.enabled)){L((p==null?void 0:p.reason)==="missing_api_key"?"请先配置 API Key":(p==null?void 0:p.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(x=D.current)==null||x.abort();const o=new AbortController;D.current=o;const S={id:Ee("u"),role:"user",content:f,skillNames:X.length>0?[...X]:void 0},g=Ee("a");K.current=!0,w($=>[...$,S,{id:g,role:"assistant",content:""}]),J(""),Z(!0),L(null),R(!1),requestAnimationFrame(()=>{te(),requestAnimationFrame(te)});try{let $=!1;await yt(f,{skillNames:X.length>0?X:void 0,references:{domainId:(C==null?void 0:C.trim())||void 0,documentId:!de&&Ie?E.trim():void 0,graphFileId:de?m.trim():void 0},signal:o.signal,onEvent:l=>{l.type==="text_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Jt(r.blocks??[],l.text);return{...r,blocks:d,content:We(d)}})),requestAnimationFrame(()=>q())):l.type==="thinking_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Zt(r.blocks??[],l.text);return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="sources"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=(r.blocks??[]).slice(),ge=d[d.length-1];return(ge==null?void 0:ge.type)==="sources"?d[d.length-1]={type:"sources",items:l.items}:d.push({type:"sources",items:l.items}),{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_table"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_table",title:l.title,rows:l.rows}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_card",documentId:l.documentId,title:l.title,path:l.path,preview:l.preview}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="tool_notice"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"tool_notice",toolName:l.toolName,text:l.text}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"choice_card",requestId:l.requestId,title:l.title,options:l.options,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="skill_form_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"skill_form_card",requestId:l.requestId,mode:l.mode,title:l.title,currentName:l.currentName,initialName:l.initialName,initialDescription:l.initialDescription,initialBody:l.initialBody,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="skill_form_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="tree_changed"?j==null||j():l.type==="document_overwritten"?M==null||M({documentId:l.documentId,headCommitId:l.headCommitId}):l.type==="open_coding"?P==null||P({documentId:l.documentId,displayName:l.displayName}):l.type==="context_usage"?Se({percent:l.percent,used:l.used,limit:l.limit}):l.type==="error"&&($=!0,L(l.message))}}),!o.signal.aborted&&!$&&ve([])}catch($){if(o.signal.aborted)return;L($ instanceof Error?$.message:String($))}finally{D.current===o&&(D.current=null),Z(!1)}}async function ot(){var t;if(!v){(t=D.current)==null||t.abort(),L(null),R(!1),Z(!1);try{const f=await gt();G(f.sessionId),w([]),J(""),K.current=!0,ue()}catch(f){L(f instanceof Error?f.message:String(f))}}}async function lt(t){var f;if(!v){if(t===re){R(!1);return}(f=D.current)==null||f.abort(),L(null);try{const o=await xt(t);G(o.sessionId),w(Oe(o.sessionId,o.messages)),J(""),R(!1),K.current=!0,requestAnimationFrame(()=>q()),ue()}catch(o){L(o instanceof Error?o.message:String(o))}}}function ze(t){!t||!H||H(t)}if(!c)return null;const he=(p==null?void 0:p.reason)==="missing_api_key",De=Ve??(p&&!p.enabled&&!he?p.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:Qe,className:"mdocs-agent-panel"+(y?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":y?!0:void 0,style:y?void 0:A,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:Fe,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:v,onClick:()=>void ot(),children:e.jsx(St,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(T?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>R(t=>!t),children:e.jsx(bt,{size:16,strokeWidth:1.8})}),_?e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:y?"退出全屏":"全屏","aria-label":y?"退出全屏":"全屏",onClick:_,children:y?e.jsx(Rt,{size:16,strokeWidth:1.8}):e.jsx(Mt,{size:16,strokeWidth:1.8})}):null,e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:me,children:e.jsx(ne,{size:16,strokeWidth:1.8})})]})]}),T?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>R(!1),children:"返回对话"})]}),Ze?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):Ne.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:Ne.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===re?" active":""),disabled:v,onClick:()=>void lt(t.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:t.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:es(t.updatedAt)})]})},t.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsxs("div",{className:"mdocs-agent-panel-scroll-wrap",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:ee,onScroll:nt,children:z.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),he?e.jsx(Pe,{onConfigured:Te}):De?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:De}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Vt.map(t=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void fe(t),disabled:v||!(p!=null&&p.enabled),children:t},t))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:z.map(t=>{var f;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(t.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[t.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:Fe,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[t.role==="user"&&t.skillNames&&t.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",t.skillNames.length]}):null,t.role==="assistant"?t.blocks&&t.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[t.blocks.map((o,S)=>{var g;return o.type==="thinking"?o.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:v&&t.id===((g=z[z.length-1])==null?void 0:g.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:o.text})]},`${t.id}-th-${S}`):null:o.type==="text"?o.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Be,{children:o.text})},`${t.id}-t-${S}`):null:o.type==="sources"?o.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",o.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:o.items.map(x=>e.jsx("li",{children:e.jsx("a",{href:x.url,target:"_blank",rel:"noreferrer",children:x.name})},x.id))})]})},`${t.id}-s-${S}`):o.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:o.text})},`${t.id}-n-${S}`):o.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(ts,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===x?{...d,status:l,selected:l==="selected"?$:d.selected}:d)}))}})},`${t.id}-ch-${S}`):o.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(vt,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===x?{...d,status:$,submittedName:$==="submitted"?l:d.submittedName}:d)}))}})},`${t.id}-sf-${S}`):o.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:x=>{x.preventDefault(),x.stopPropagation(),ze(o.documentId)},children:["《",o.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[o.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:o.path}):null,o.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:o.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${t.id}-c-${S}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[o.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:o.rows.length===0?"无结果":`${o.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:o.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:o.rows.map(x=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>ze(x.documentId),children:x.title})}),e.jsx("td",{children:x.summary||"-"})]},x.documentId))})]})})]})},`${t.id}-d-${S}`)}),v&&t.id===((f=z[z.length-1])==null?void 0:f.id)&&!We(t.blocks)&&!Qt(t.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):t.content?e.jsx(Be,{children:t.content}):v?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:t.content]}),t.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:F}):null]},t.id)})})}),et?e.jsxs("button",{type:"button",className:"mdocs-chat-jump-bottom",onClick:at,title:"回到底部","aria-label":"回到底部",children:[e.jsx(wt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:"置底"})]}):null]}),Ce?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Ce}):null,he&&z.length>0?e.jsx(Pe,{onConfigured:Te}):null,e.jsx(Ct,{selectedNames:X,onChange:ve,disabled:v||!(p!=null&&p.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[de?e.jsxs("div",{className:"mdocs-agent-doc-ref mdocs-agent-graph-ref",children:[e.jsx(Ke,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:st}),e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:"图谱(只读)"})]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前图谱",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):Ie?e.jsxs("div",{className:"mdocs-agent-doc-ref",children:[e.jsx(pt,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:tt}),Me?e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:Me}):null]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前文档",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-body",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:p!=null&&p.enabled?"把你的问题告诉我…":"请先配置 API Key",value:V,disabled:v||!(p!=null&&p.enabled),onChange:t=>J(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),fe(V))}}),Q?e.jsx(ss,{percent:Q.percent,used:Q.used,limit:Q.limit}):null,e.jsx("button",{type:"button",className:v?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:v?!1:!(p!=null&&p.enabled)||!V.trim(),onClick:()=>{var t;if(v){(t=D.current)==null||t.abort();return}fe(V)},title:v?"停止":"发送","aria-label":v?"停止":"发送",children:v?"■":"↑"})]})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),oe?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{B||O(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:B,onClick:()=>O(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:B,onClick:()=>void it(),children:B?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{ps as AgentChatPanel};
22
+ */const zt=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Dt=ae("zoom-out",zt);function je(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(je).join(""):typeof s=="object"&&"props"in s?je((n=s.props)==null?void 0:n.children):""}function qt(s){return s?/\blanguage-mermaid\b|\bmermaid\b/i.test(s):!1}function Ft(s){const n=Array.isArray(s)?s:[s];for(const a of n){if(a==null||typeof a!="object"||!("props"in a))continue;const c=a.props;if(!(!c||!qt(c.className)))return je(c.children).replace(/\n$/,"")}return null}const Pt=.4,Bt=4,se=.2;let xe=null;function Lt(){return xe||(xe=ct(()=>import("./diagram-CgEd0hrk.js").then(s=>s.z),__vite__mapDeps([0,1,2,3])).then(s=>{const n=s.default;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral",fontFamily:"ui-sans-serif, system-ui, sans-serif"}),n})),xe}const Ot=32,W=new Map;function Be(s){return W.get(s)??null}function Wt(s,n){for(W.has(s)&&W.delete(s),W.set(s,n);W.size>Ot;){const a=W.keys().next().value;if(a==null)break;W.delete(a)}}function ye(s){return Math.min(Bt,Math.max(Pt,s))}function Ht(s){const[n,a]=i.useState(1),[c,b]=i.useState({x:0,y:0}),h=i.useRef(null),[A,y]=i.useState(!1);i.useEffect(()=>{const u=I=>{I.key==="Escape"&&s.onClose()};window.addEventListener("keydown",u);const m=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",u),document.body.style.overflow=m}},[s.onClose]);function _(u){u.button===0&&(u.currentTarget.setPointerCapture(u.pointerId),h.current={pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,originX:c.x,originY:c.y},y(!0))}function C(u){const m=h.current;!m||m.pointerId!==u.pointerId||b({x:m.originX+(u.clientX-m.startX),y:m.originY+(u.clientY-m.startY)})}function E(u){const m=h.current;if(!(!m||m.pointerId!==u.pointerId)){h.current=null,y(!1);try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}}}function N(u){u.preventDefault();const m=u.deltaY>0?-se:se;a(I=>ye(Number((I+m).toFixed(2))))}return dt.createPortal(e.jsxs("div",{className:"mdocs-agent-mermaid-float",role:"dialog","aria-modal":"true","aria-label":"Mermaid 图预览",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-backdrop","aria-label":"关闭预览",onClick:s.onClose}),e.jsxs("div",{className:"mdocs-agent-mermaid-float-chrome",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-float-tools",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u-se).toFixed(2)))),title:"缩小","aria-label":"缩小",children:e.jsx(Dt,{size:16,"aria-hidden":!0})}),e.jsxs("span",{className:"mdocs-agent-mermaid-float-scale",children:[Math.round(n*100),"%"]}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u+se).toFixed(2)))),title:"放大","aria-label":"放大",children:e.jsx(Tt,{size:16,"aria-hidden":!0})}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>{a(1),b({x:0,y:0})},title:"重置",children:"重置"}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:s.onClose,title:"关闭","aria-label":"关闭",children:e.jsx(ne,{size:16,"aria-hidden":!0})})]}),e.jsx("div",{className:A?"mdocs-agent-mermaid-float-stage is-dragging":"mdocs-agent-mermaid-float-stage",onPointerDown:_,onPointerMove:C,onPointerUp:E,onPointerCancel:E,onWheel:N,children:e.jsx("div",{className:"mdocs-agent-mermaid-float-canvas",style:{transform:`translate(calc(-50% + ${c.x}px), calc(-50% + ${c.y}px)) scale(${n})`},dangerouslySetInnerHTML:{__html:s.svg}})}),e.jsx("p",{className:"mdocs-agent-mermaid-float-hint",children:"拖动平移 · 滚轮缩放 · Esc 关闭"})]})]}),document.body)}function Kt(s){const n=i.useId().replace(/:/g,""),[a,c]=i.useState("diagram"),[b,h]=i.useState(()=>Be(s.source.trim())),[A,y]=i.useState(null),[_,C]=i.useState(!1),[E,N]=i.useState(!1),u=i.useRef(null),m=s.source.trim(),I=i.useMemo(()=>m,[m]);i.useEffect(()=>()=>{u.current!=null&&window.clearTimeout(u.current)},[]),i.useEffect(()=>{if(a!=="diagram")return;if(!I){h(null),y(null);return}const j=Be(I);if(j){h(j),y(null);return}let M=!1;const P=window.setTimeout(()=>{(async()=>{try{const F=await Lt();if(M)return;const T=`mdocs-agent-mmd-${n}-${Date.now()}`,{svg:R}=await F.render(T,I);if(M)return;Wt(I,R),h(R),y(null)}catch(F){if(M)return;h(null),y(F instanceof Error?F.message:"Mermaid 渲染失败")}})()},200);return()=>{M=!0,window.clearTimeout(P)}},[a,I,n]);async function H(){!m||!await Xe(m)||(C(!0),u.current!=null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>C(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-mermaid",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toolbar",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toggle",role:"group","aria-label":"Mermaid 显示模式",children:[e.jsxs("button",{type:"button",className:a==="diagram"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("diagram"),"aria-pressed":a==="diagram",title:"图谱",children:[e.jsx(Ke,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"图谱"})]}),e.jsxs("button",{type:"button",className:a==="code"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("code"),"aria-pressed":a==="code",title:"代码",children:[e.jsx(ut,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"代码"})]})]}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy mdocs-agent-mermaid-copy",onClick:()=>void H(),"aria-label":_?"已复制":"复制代码",title:_?"已复制":"复制",children:_?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})})]}),a==="diagram"?e.jsx("div",{className:"mdocs-agent-mermaid-diagram",children:A?e.jsxs("div",{className:"mdocs-agent-mermaid-error",role:"alert",children:[e.jsx("p",{children:"无法渲染该图,可切换到代码查看源码。"}),e.jsx("pre",{children:A})]}):b?e.jsx("div",{className:"mdocs-agent-mermaid-svg mdocs-agent-mermaid-svg-hit",role:"button",tabIndex:0,onClick:()=>N(!0),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),N(!0))},title:"点击放大预览","aria-label":"点击放大预览 Mermaid 图",children:e.jsx("span",{className:"mdocs-agent-mermaid-svg-inner",dangerouslySetInnerHTML:{__html:b}})}):e.jsx("div",{className:"mdocs-agent-mermaid-loading",children:"渲染中…"})}):e.jsx("div",{className:"mdocs-agent-panel-md-pre-wrap mdocs-agent-mermaid-code",children:e.jsx("pre",{children:s.codeChildren??e.jsx("code",{className:"language-mermaid",children:m})})}),E&&b?e.jsx(Ht,{svg:b,onClose:()=>N(!1)}):null]})}const Xt=i.memo(Kt,(s,n)=>s.source===n.source);function ke(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(ke).join(""):typeof s=="object"&&"props"in s?ke((n=s.props)==null?void 0:n.children):""}function Ut(s){const[n,a]=i.useState(!1),c=i.useRef(null),b=i.useRef(null),h=ke(s.children).replace(/\n$/,"");i.useEffect(()=>()=>{c.current!=null&&window.clearTimeout(c.current)},[]);async function A(y){var N,u,m;y.preventDefault(),y.stopPropagation();const C=(((m=(u=(N=b.current)==null?void 0:N.querySelector("pre"))==null?void 0:u.innerText)==null?void 0:m.replace(/\n$/,""))??"")||h;!C||!await Xe(C)||(a(!0),c.current!=null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",ref:b,children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:y=>void A(y),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:s.children})]})}function Yt(s){const n=Ft(s.children);return n!=null?e.jsx(Xt,{source:n,codeChildren:s.children}):e.jsx(Ut,{children:s.children})}const Gt={pre:({children:s})=>e.jsx(Yt,{children:s})},Le=i.memo(function(n){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(At,{remarkPlugins:[_t],components:Gt,children:n.children})})}),Vt=["如何发布文档?","草稿是什么?","如何创建工作空间?"];function Oe(s,n){return n.map((a,c)=>{const b=a.skillNames&&a.skillNames.length>0?a.skillNames:a.skillIds&&a.skillIds.length>0?a.skillIds:void 0;return{id:`h-${s}-${c}-${a.role}`,role:a.role,content:a.content,skillNames:b}})}function Jt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="text"?a[a.length-1]={type:"text",text:c.text+n}:a.push({type:"text",text:n}),a}function Zt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="thinking"?a[a.length-1]={type:"thinking",text:c.text+n}:a.push({type:"thinking",text:n}),a}function We(s){return s!=null&&s.length?s.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Qt(s){return!!(s!=null&&s.some(n=>n.type==="thinking"&&n.text.length>0))}function es(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return"";const a=new Date;return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function He(s){if(s>=1e3){const n=s/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(s)}function ts(s){const{block:n,onResolved:a}=s,[c,b]=i.useState(""),[h,A]=i.useState(!1),[y,_]=i.useState(1),C=i.useRef(!1),E=i.useRef(a);E.current=a;const N=n.status==="open",u=i.useRef(0);i.useEffect(()=>{if(!N)return;C.current=!1;const j=new Date(n.expiresAt).getTime(),M=Date.now(),P=Math.max(j-M,1);u.current=P,_(1);const F=()=>{const R=j-Date.now(),p=Math.max(0,Math.min(1,R/P));_(p),R<=0&&!C.current&&(C.current=!0,kt(n.requestId).catch(()=>{}).finally(()=>{E.current(n.requestId,"","expired")}))};F();const T=window.setInterval(F,100);return()=>window.clearInterval(T)},[N,n.expiresAt,n.requestId]);async function m(j){const M=j.trim();if(!(!M||h||!N)){A(!0);try{await Nt(n.requestId,M),a(n.requestId,M,"selected")}catch{a(n.requestId,M,"failed")}finally{A(!1)}}}async function I(){if(!(h||!N)){A(!0),C.current=!0;try{await Ue(n.requestId),a(n.requestId,"","cancelled")}catch{a(n.requestId,"","failed")}finally{A(!1)}}}const H=Math.max(0,Math.ceil(y*u.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(N?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),N?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[H,"s"]}):null]}),N?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(y*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${y})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,N?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(j=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:h,onClick:()=>void m(j),children:j},j))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:c,disabled:h,placeholder:"或输入自己的内容…",onChange:j=>b(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),m(c))}}),e.jsx("button",{type:"button",disabled:h||!c.trim(),onClick:()=>void m(c),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:h,onClick:()=>void I(),children:"取消"})})]}):null]})}function ss(s){const b=2*Math.PI*8.75,h=Math.min(100,Math.max(0,s.percent)),A=b*(1-h/100),y=h>=90?"danger":h>=70?"warn":"ok",_=`上下文 ${h}% · 已用 ${He(s.used)} / ${He(s.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+y,"data-tooltip":_,"aria-label":_,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:A,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function ns(s){var n;for(const a of s)if(!(a.role!=="assistant"||!((n=a.blocks)!=null&&n.length))){for(const c of a.blocks)if((c.type==="choice_card"||c.type==="skill_form_card")&&c.status==="open")return!0}return!1}const ps=i.forwardRef(function(n,a){const{open:c,onClose:b,visitorName:h,anchorStyle:A,fullscreen:y,onToggleFullscreen:_,domainId:C,documentId:E,documentTitle:N,documentPath:u,graphFileId:m,graphLabel:I,onOpenDocument:H,onTreeChanged:j,onDocumentOverwritten:M,onOpenCoding:P}=n,F=((h==null?void 0:h.trim().charAt(0))||"我").toUpperCase(),[T,R]=i.useState(!1),[p,U]=i.useState(null),[Ve,Y]=i.useState(null),[z,w]=i.useState([]),[re,G]=i.useState(null),[Ne,Je]=i.useState([]),[Ze,be]=i.useState(!1),[V,J]=i.useState(""),[X,ve]=i.useState([]),[we,ie]=i.useState(!1),[v,Z]=i.useState(!1),[Ce,B]=i.useState(null),[Q,Se]=i.useState(null),[oe,O]=i.useState(!1),[L,Ae]=i.useState(!1),Qe=i.useRef(null),ee=i.useRef(null),D=i.useRef(null),_e=i.useRef(0),K=i.useRef(!0),[et,le]=i.useState(!1),ce=i.useRef(z);ce.current=z;const Ie=!!(E!=null&&E.trim())&&!we,tt=(N==null?void 0:N.trim())||"当前文档",Me=(u==null?void 0:u.trim())||"",de=!!(m!=null&&m.trim())&&!we,st=(I==null?void 0:I.trim())||"当前图谱";i.useEffect(()=>{ie(!1)},[E,m]);function Ee(t){return _e.current+=1,`${t}-${_e.current}`}const Re=120;function $e(t){return t.scrollHeight-t.scrollTop-t.clientHeight}function te(){const t=ee.current;t&&(t.scrollTop=t.scrollHeight,le(!1))}function q(){K.current&&te()}function nt(){const t=ee.current;if(!t)return;const f=$e(t);K.current=f<=48,le(f>Re)}function at(){K.current=!0,te()}i.useLayoutEffect(()=>{q();const t=ee.current;t&&le($e(t)>Re)},[z]);async function rt(){be(!0);try{const t=await ht();Je(t.sessions),re||G(t.lastOpenedSessionId)}catch{}finally{be(!1)}}async function ue(){try{const t=await ft();Se(t)}catch{}}async function Te(){try{const t=await qe();U(t),Y(null)}catch(t){U(null),Y(t instanceof Error?t.message:String(t))}}i.useEffect(()=>{var f;if(!c){R(!1),(f=D.current)==null||f.abort(),D.current=null,Z(!1);return}let t=!1;return(async()=>{try{const o=await qe();t||(U(o),Y(null))}catch(o){t||(U(null),Y(o instanceof Error?o.message:String(o)))}})(),ue(),()=>{t=!0}},[c]),i.useEffect(()=>{if(!c)return;let t=!1;return(async()=>{try{const f=await mt();if(t)return;G(f.sessionId),w(o=>o.length>0?o:Oe(f.sessionId,f.messages))}catch{}})(),()=>{t=!0}},[c]),i.useEffect(()=>{!c||!T||rt()},[c,T]);function me(){if(!L){if(ns(ce.current)){O(!0);return}O(!1),b()}}async function it(){var o;if(L)return;Ae(!0);const t=ce.current,f=[];for(const S of t)if(!(S.role!=="assistant"||!S.blocks))for(const g of S.blocks)g.type==="choice_card"&&g.status==="open"&&f.push(Ue(g.requestId).catch(()=>{})),g.type==="skill_form_card"&&g.status==="open"&&f.push(jt(g.requestId).catch(()=>{}));await Promise.all(f),(o=D.current)==null||o.abort(),w(S=>S.map(g=>g.role!=="assistant"||!g.blocks?g:{...g,blocks:g.blocks.map(x=>x.type==="choice_card"&&x.status==="open"?{...x,status:"cancelled"}:x.type==="skill_form_card"&&x.status==="open"?{...x,status:"cancelled"}:x)})),O(!1),Ae(!1),b()}const pe=i.useRef(me);pe.current=me,i.useImperativeHandle(a,()=>({requestClose:()=>pe.current()}),[]),i.useEffect(()=>{if(!c){O(!1);return}const t=f=>{if(f.key==="Escape"){if(oe){L||O(!1);return}if(T){R(!1);return}pe.current()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[c,T,oe,L]);async function fe(t){var x;const f=t.trim();if(!f||v)return;if(!(p!=null&&p.enabled)){B((p==null?void 0:p.reason)==="missing_api_key"?"请先配置 API Key":(p==null?void 0:p.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(x=D.current)==null||x.abort();const o=new AbortController;D.current=o;const S={id:Ee("u"),role:"user",content:f,skillNames:X.length>0?[...X]:void 0},g=Ee("a");K.current=!0,w($=>[...$,S,{id:g,role:"assistant",content:""}]),J(""),Z(!0),B(null),R(!1),requestAnimationFrame(()=>{te(),requestAnimationFrame(te)});try{let $=!1;await yt(f,{skillNames:X.length>0?X:void 0,references:{domainId:(C==null?void 0:C.trim())||void 0,documentId:!de&&Ie?E.trim():void 0,graphFileId:de?m.trim():void 0},signal:o.signal,onEvent:l=>{l.type==="text_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Jt(r.blocks??[],l.text);return{...r,blocks:d,content:We(d)}})),requestAnimationFrame(()=>q())):l.type==="thinking_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Zt(r.blocks??[],l.text);return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="sources"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=(r.blocks??[]).slice(),ge=d[d.length-1];return(ge==null?void 0:ge.type)==="sources"?d[d.length-1]={type:"sources",items:l.items}:d.push({type:"sources",items:l.items}),{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_table"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_table",title:l.title,rows:l.rows}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_card",documentId:l.documentId,title:l.title,path:l.path,preview:l.preview}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="tool_notice"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"tool_notice",toolName:l.toolName,text:l.text}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"choice_card",requestId:l.requestId,title:l.title,options:l.options,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="skill_form_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"skill_form_card",requestId:l.requestId,mode:l.mode,title:l.title,currentName:l.currentName,initialName:l.initialName,initialDescription:l.initialDescription,initialBody:l.initialBody,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="skill_form_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="tree_changed"?j==null||j():l.type==="document_overwritten"?M==null||M({documentId:l.documentId,headCommitId:l.headCommitId}):l.type==="open_coding"?P==null||P({documentId:l.documentId,displayName:l.displayName}):l.type==="context_usage"?Se({percent:l.percent,used:l.used,limit:l.limit}):l.type==="error"&&($=!0,B(l.message))}}),!o.signal.aborted&&!$&&ve([])}catch($){if(o.signal.aborted)return;B($ instanceof Error?$.message:String($))}finally{D.current===o&&(D.current=null),Z(!1)}}async function ot(){var t;if(!v){(t=D.current)==null||t.abort(),B(null),R(!1),Z(!1);try{const f=await gt();G(f.sessionId),w([]),J(""),K.current=!0,ue()}catch(f){B(f instanceof Error?f.message:String(f))}}}async function lt(t){var f;if(!v){if(t===re){R(!1);return}(f=D.current)==null||f.abort(),B(null);try{const o=await xt(t);G(o.sessionId),w(Oe(o.sessionId,o.messages)),J(""),R(!1),K.current=!0,requestAnimationFrame(()=>q()),ue()}catch(o){B(o instanceof Error?o.message:String(o))}}}function ze(t){!t||!H||H(t)}if(!c)return null;const he=(p==null?void 0:p.reason)==="missing_api_key",De=Ve??(p&&!p.enabled&&!he?p.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:Qe,className:"mdocs-agent-panel"+(y?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":y?!0:void 0,style:y?void 0:A,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:Fe,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:v,onClick:()=>void ot(),children:e.jsx(St,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(T?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>R(t=>!t),children:e.jsx(bt,{size:16,strokeWidth:1.8})}),_?e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:y?"退出全屏":"全屏","aria-label":y?"退出全屏":"全屏",onClick:_,children:y?e.jsx(Rt,{size:16,strokeWidth:1.8}):e.jsx(Mt,{size:16,strokeWidth:1.8})}):null,e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:me,children:e.jsx(ne,{size:16,strokeWidth:1.8})})]})]}),T?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>R(!1),children:"返回对话"})]}),Ze?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):Ne.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:Ne.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===re?" active":""),disabled:v,onClick:()=>void lt(t.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:t.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:es(t.updatedAt)})]})},t.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsxs("div",{className:"mdocs-agent-panel-scroll-wrap",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:ee,onScroll:nt,children:z.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),he?e.jsx(Pe,{onConfigured:Te}):De?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:De}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Vt.map(t=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void fe(t),disabled:v||!(p!=null&&p.enabled),children:t},t))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:z.map(t=>{var f;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(t.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[t.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:Fe,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[t.role==="user"&&t.skillNames&&t.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",t.skillNames.length]}):null,t.role==="assistant"?t.blocks&&t.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[t.blocks.map((o,S)=>{var g;return o.type==="thinking"?o.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:v&&t.id===((g=z[z.length-1])==null?void 0:g.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:o.text})]},`${t.id}-th-${S}`):null:o.type==="text"?o.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Le,{children:o.text})},`${t.id}-t-${S}`):null:o.type==="sources"?o.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",o.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:o.items.map(x=>e.jsx("li",{children:e.jsx("a",{href:x.url,target:"_blank",rel:"noreferrer",children:x.name})},x.id))})]})},`${t.id}-s-${S}`):o.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:o.text})},`${t.id}-n-${S}`):o.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(ts,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===x?{...d,status:l,selected:l==="selected"?$:d.selected}:d)}))}})},`${t.id}-ch-${S}`):o.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(vt,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===x?{...d,status:$,submittedName:$==="submitted"?l:d.submittedName}:d)}))}})},`${t.id}-sf-${S}`):o.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:x=>{x.preventDefault(),x.stopPropagation(),ze(o.documentId)},children:["《",o.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[o.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:o.path}):null,o.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:o.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${t.id}-c-${S}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[o.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:o.rows.length===0?"无结果":`${o.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:o.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:o.rows.map(x=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>ze(x.documentId),children:x.title})}),e.jsx("td",{children:x.summary||"-"})]},x.documentId))})]})})]})},`${t.id}-d-${S}`)}),v&&t.id===((f=z[z.length-1])==null?void 0:f.id)&&!We(t.blocks)&&!Qt(t.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):t.content?e.jsx(Le,{children:t.content}):v?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:t.content]}),t.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:F}):null]},t.id)})})}),et?e.jsxs("button",{type:"button",className:"mdocs-chat-jump-bottom",onClick:at,title:"回到底部","aria-label":"回到底部",children:[e.jsx(wt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:"置底"})]}):null]}),Ce?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Ce}):null,he&&z.length>0?e.jsx(Pe,{onConfigured:Te}):null,e.jsx(Ct,{selectedNames:X,onChange:ve,disabled:v||!(p!=null&&p.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[de?e.jsxs("div",{className:"mdocs-agent-doc-ref mdocs-agent-graph-ref",children:[e.jsx(Ke,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:st}),e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:"图谱(只读)"})]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前图谱",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):Ie?e.jsxs("div",{className:"mdocs-agent-doc-ref",children:[e.jsx(pt,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:tt}),Me?e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:Me}):null]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前文档",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-body",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:p!=null&&p.enabled?"把你的问题告诉我…":"请先配置 API Key",value:V,disabled:v||!(p!=null&&p.enabled),onChange:t=>J(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),fe(V))}}),Q?e.jsx(ss,{percent:Q.percent,used:Q.used,limit:Q.limit}):null,e.jsx("button",{type:"button",className:v?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:v?!1:!(p!=null&&p.enabled)||!V.trim(),onClick:()=>{var t;if(v){(t=D.current)==null||t.abort();return}fe(V)},title:v?"停止":"发送","aria-label":v?"停止":"发送",children:v?"■":"↑"})]})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),oe?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{L||O(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:L,onClick:()=>O(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:L,onClick:()=>void it(),children:L?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{ps as AgentChatPanel};
@@ -1,11 +1,11 @@
1
- import{o as E,a8 as D,aC as L,ay as _,aD as F}from"./index-DUu4Is5p.js";import{r as a,j as e}from"./react-vendor-BuABiQkA.js";/**
1
+ import{o as E,a8 as L,aF as D,aB as _,aG as F}from"./index-Cwy87sZC.js";import{r as a,j as e}from"./react-vendor-BuABiQkA.js";/**
2
2
  * @license lucide-react v0.562.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 $=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],X=E("arrow-down",$);/**
6
+ */const B=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],X=E("arrow-down",B);/**
7
7
  * @license lucide-react v0.562.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const B=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],K=E("history",B),j=5;function P(i){const t=a.useRef(!0),r=a.useRef(null),[d,k]=a.useState([]),[u,p]=a.useState(!1),[h,v]=a.useState(null);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const s=await D();if(!t.current)return;k(s)}catch(s){if(!t.current)return;v(s instanceof Error?s.message:String(s))}})()},[]),a.useEffect(()=>{if(!u)return;function s(o){const g=r.current;!g||g.contains(o.target)||p(!1)}function n(o){o.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n)}},[u]);const c=d.filter(s=>i.selectedNames.includes(s.name));function f(s){if(i.disabled)return;const n=new Set(i.selectedNames);if(n.has(s))n.delete(s);else{if(n.size>=j)return;n.add(s)}i.onChange([...n])}return d.length===0&&!h?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:r,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[u&&d.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",j," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:d.map(s=>{const n=i.selectedNames.includes(s.name),o=!n&&i.selectedNames.length>=j;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":n,className:"mdocs-agent-skill-popover-item"+(n?" mdocs-agent-skill-popover-item-on":""),disabled:i.disabled||o,onClick:()=>f(s.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:n?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:s.name}),s.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:s.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},s.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(u?" mdocs-agent-skill-ref-toggle-open":""),disabled:i.disabled||d.length===0,onClick:()=>p(s=>!s),"aria-expanded":u,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(s=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:i.disabled,onClick:()=>f(s.name),title:"移除引用",children:[s.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},s.name))]}),h?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:h}):null]})}const z=/^[A-Za-z0-9_]+$/;function T(i){const{block:t,onResolved:r}=i,[d,k]=a.useState(t.initialName),[u,p]=a.useState(t.initialDescription),[h,v]=a.useState(t.initialBody),[c,f]=a.useState(!1),[s,n]=a.useState(null),[o,g]=a.useState(1),x=a.useRef(!1),N=a.useRef(r);N.current=r;const m=t.status==="open",b=a.useRef(0);a.useEffect(()=>{if(!m)return;x.current=!1;const l=new Date(t.expiresAt).getTime(),M=Date.now(),y=Math.max(l-M,1);b.current=y,g(1);const S=()=>{const w=l-Date.now(),q=Math.max(0,Math.min(1,w/y));g(q),w<=0&&!x.current&&(x.current=!0,L(t.requestId).catch(()=>{}).finally(()=>{N.current(t.requestId,"expired")}))};S();const I=window.setInterval(S,100);return()=>window.clearInterval(I)},[m,t.expiresAt,t.requestId]);async function R(){if(c||!m)return;const l=d.trim();if(!l){n("名称不能为空");return}if(!z.test(l)){n("名称仅允许英文、数字、下划线");return}if(!h.trim()){n("正文不能为空");return}f(!0),n(null);try{await F(t.requestId,{name:l,description:u.trim(),body:h}),r(t.requestId,"submitted",l)}catch{r(t.requestId,"failed")}finally{f(!1)}}async function A(){if(!(c||!m)){f(!0),n(null),x.current=!0;try{await _(t.requestId),r(t.requestId,"cancelled")}catch{r(t.requestId,"failed")}finally{f(!1)}}}const C=Math.max(0,Math.ceil(o*b.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card mdocs-agent-skill-form-card"+(m?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:t.title}),m?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[C,"s"]}):null]}),m?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${o})`}})}):null,t.status==="submitted"?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已提交",t.submittedName?`:${t.submittedName}`:""]}):null,t.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,t.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,表单已失效"}):null,t.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,m?e.jsxs("div",{className:"mdocs-agent-skill-form-fields",children:[e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"名称(英文数字下划线)"}),e.jsx("input",{type:"text",value:d,onChange:l=>k(l.target.value),maxLength:64,disabled:c,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"简介"}),e.jsx("input",{type:"text",value:u,onChange:l=>p(l.target.value),maxLength:200,disabled:c})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:h,onChange:l=>v(l.target.value),rows:8,disabled:c})]}),s?e.jsx("p",{className:"mdocs-agent-skill-form-error",children:s}):null,e.jsxs("div",{className:"mdocs-agent-skill-form-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-skill-form-cancel",disabled:c,onClick:()=>void A(),children:"取消"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>void R(),children:c?"提交中…":t.mode==="create"?"创建":"保存"})]})]}):null]})}export{X as A,K as H,T as S,P as a};
11
+ */const $=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],G=E("history",$),j=5;function K(i){const t=a.useRef(!0),r=a.useRef(null),[d,k]=a.useState([]),[u,p]=a.useState(!1),[h,v]=a.useState(null);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const s=await L();if(!t.current)return;k(s)}catch(s){if(!t.current)return;v(s instanceof Error?s.message:String(s))}})()},[]),a.useEffect(()=>{if(!u)return;function s(o){const g=r.current;!g||g.contains(o.target)||p(!1)}function n(o){o.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n)}},[u]);const c=d.filter(s=>i.selectedNames.includes(s.name));function f(s){if(i.disabled)return;const n=new Set(i.selectedNames);if(n.has(s))n.delete(s);else{if(n.size>=j)return;n.add(s)}i.onChange([...n])}return d.length===0&&!h?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:r,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[u&&d.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",j," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:d.map(s=>{const n=i.selectedNames.includes(s.name),o=!n&&i.selectedNames.length>=j;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":n,className:"mdocs-agent-skill-popover-item"+(n?" mdocs-agent-skill-popover-item-on":""),disabled:i.disabled||o,onClick:()=>f(s.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:n?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:s.name}),s.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:s.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},s.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(u?" mdocs-agent-skill-ref-toggle-open":""),disabled:i.disabled||d.length===0,onClick:()=>p(s=>!s),"aria-expanded":u,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(s=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:i.disabled,onClick:()=>f(s.name),title:"移除引用",children:[s.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},s.name))]}),h?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:h}):null]})}const z=/^[A-Za-z0-9_]+$/;function P(i){const{block:t,onResolved:r}=i,[d,k]=a.useState(t.initialName),[u,p]=a.useState(t.initialDescription),[h,v]=a.useState(t.initialBody),[c,f]=a.useState(!1),[s,n]=a.useState(null),[o,g]=a.useState(1),x=a.useRef(!1),N=a.useRef(r);N.current=r;const m=t.status==="open",b=a.useRef(0);a.useEffect(()=>{if(!m)return;x.current=!1;const l=new Date(t.expiresAt).getTime(),C=Date.now(),y=Math.max(l-C,1);b.current=y,g(1);const S=()=>{const w=l-Date.now(),q=Math.max(0,Math.min(1,w/y));g(q),w<=0&&!x.current&&(x.current=!0,D(t.requestId).catch(()=>{}).finally(()=>{N.current(t.requestId,"expired")}))};S();const I=window.setInterval(S,100);return()=>window.clearInterval(I)},[m,t.expiresAt,t.requestId]);async function R(){if(c||!m)return;const l=d.trim();if(!l){n("名称不能为空");return}if(!z.test(l)){n("名称仅允许英文、数字、下划线");return}if(!h.trim()){n("正文不能为空");return}f(!0),n(null);try{await F(t.requestId,{name:l,description:u.trim(),body:h}),r(t.requestId,"submitted",l)}catch{r(t.requestId,"failed")}finally{f(!1)}}async function A(){if(!(c||!m)){f(!0),n(null),x.current=!0;try{await _(t.requestId),r(t.requestId,"cancelled")}catch{r(t.requestId,"failed")}finally{f(!1)}}}const M=Math.max(0,Math.ceil(o*b.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card mdocs-agent-skill-form-card"+(m?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:t.title}),m?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[M,"s"]}):null]}),m?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${o})`}})}):null,t.status==="submitted"?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已提交",t.submittedName?`:${t.submittedName}`:""]}):null,t.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,t.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,表单已失效"}):null,t.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,m?e.jsxs("div",{className:"mdocs-agent-skill-form-fields",children:[e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"名称(英文数字下划线)"}),e.jsx("input",{type:"text",value:d,onChange:l=>k(l.target.value),maxLength:64,disabled:c,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"简介"}),e.jsx("input",{type:"text",value:u,onChange:l=>p(l.target.value),maxLength:200,disabled:c})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:h,onChange:l=>v(l.target.value),rows:8,disabled:c})]}),s?e.jsx("p",{className:"mdocs-agent-skill-form-error",children:s}):null,e.jsxs("div",{className:"mdocs-agent-skill-form-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-skill-form-cancel",disabled:c,onClick:()=>void A(),children:"取消"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>void R(),children:c?"提交中…":t.mode==="create"?"创建":"保存"})]})]}):null]})}export{X as A,G as H,P as S,K as a};