wi-chat 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/core/index.cjs +2 -0
  2. package/dist/core/index.d.ts +13 -0
  3. package/dist/core/index.js +454 -0
  4. package/dist/core/useAgent.d.ts +35 -0
  5. package/dist/core/useChat.d.ts +195 -0
  6. package/dist/core/useChatSession.d.ts +89 -0
  7. package/dist/core/useHistory.d.ts +63 -0
  8. package/dist/index.cjs +2 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +81 -0
  11. package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +129 -0
  12. package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +77 -0
  13. package/dist/mobile-ui/chat/types.d.ts +9 -0
  14. package/dist/mobile-ui/index.cjs +2 -0
  15. package/dist/mobile-ui/index.d.ts +7 -0
  16. package/dist/mobile-ui/index.js +225 -0
  17. package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +95 -0
  18. package/dist/mobile-ui/style.css +1 -0
  19. package/dist/parser/answer.d.ts +51 -0
  20. package/dist/parser/answerCom/iframePage/parseIframePage.d.ts +49 -0
  21. package/dist/parser/answerCom/iframePage/types.d.ts +11 -0
  22. package/dist/parser/answerCom/knowledgeStream/parseKnowledgeStream.d.ts +54 -0
  23. package/dist/parser/answerCom/knowledgeStream/types.d.ts +27 -0
  24. package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +43 -0
  25. package/dist/parser/answerCom/outputFile/types.d.ts +17 -0
  26. package/dist/parser/answerCom/recordset/parseRecordset.d.ts +48 -0
  27. package/dist/parser/answerCom/recordset/types.d.ts +36 -0
  28. package/dist/parser/attach/attachActions.d.ts +43 -0
  29. package/dist/parser/attach/index.d.ts +9 -0
  30. package/dist/parser/attach/parseAttach.d.ts +27 -0
  31. package/dist/parser/attach/types.d.ts +48 -0
  32. package/dist/parser/deepThinking/parseDeepThinking.d.ts +30 -0
  33. package/dist/parser/deepThinking/types.d.ts +14 -0
  34. package/dist/parser/history/history.d.ts +54 -0
  35. package/dist/parser/history/index.d.ts +7 -0
  36. package/dist/parser/index.cjs +3 -0
  37. package/dist/parser/index.d.ts +45 -0
  38. package/dist/parser/index.js +479 -0
  39. package/dist/parser/message.d.ts +60 -0
  40. package/dist/parser/registry.d.ts +81 -0
  41. package/dist/parser/sse.d.ts +34 -0
  42. package/dist/parser/stream.d.ts +8 -0
  43. package/dist/renderers/aiAnswer/AiAnswerBubble.vue.d.ts +58 -0
  44. package/dist/renderers/aiAnswer/contentMap.d.ts +13 -0
  45. package/dist/renderers/deepThinking/DeepThinkingSteps.vue.d.ts +21 -0
  46. package/dist/renderers/iframePage/IframePage.vue.d.ts +19 -0
  47. package/dist/renderers/iframePage/useIframePage.d.ts +64 -0
  48. package/dist/renderers/index.cjs +2 -0
  49. package/dist/renderers/index.d.ts +12 -0
  50. package/dist/renderers/index.js +609 -0
  51. package/dist/renderers/knowledgeStream/KnowledgeStreamResult.vue.d.ts +19 -0
  52. package/dist/renderers/outputFile/OutputFile.vue.d.ts +19 -0
  53. package/dist/renderers/outputFile/useOutputFile.d.ts +85 -0
  54. package/dist/renderers/style.css +1 -0
  55. package/dist/request/api.d.ts +132 -0
  56. package/dist/request/client.d.ts +30 -0
  57. package/dist/request/index.cjs +4 -0
  58. package/dist/request/index.d.ts +18 -0
  59. package/dist/request/index.js +264 -0
  60. package/dist/request/login.d.ts +37 -0
  61. package/dist/request/ws.d.ts +91 -0
  62. package/dist/style.css +24 -0
  63. package/dist/styles/github.css +2 -0
  64. package/dist/styles/katex.css +2 -0
  65. package/dist/theme/index.cjs +3 -0
  66. package/dist/theme/index.d.ts +3 -0
  67. package/dist/theme/index.js +37 -0
  68. package/dist/theme/theme.d.ts +40 -0
  69. package/dist/tools/attachDownload.d.ts +20 -0
  70. package/dist/tools/index.cjs +17 -0
  71. package/dist/tools/index.d.ts +8 -0
  72. package/dist/tools/index.js +251 -0
  73. package/dist/tools/markdown/MarkdownContent.vue.d.ts +36 -0
  74. package/dist/tools/markdown/imagePreview.d.ts +15 -0
  75. package/dist/tools/markdown/index.d.ts +5 -0
  76. package/dist/tools/markdown/renderMarkdown.d.ts +22 -0
  77. package/dist/tools/markdown/tableDownload.d.ts +14 -0
  78. package/dist/tools/stream.d.ts +9 -0
  79. package/dist/tools/style.css +1 -0
  80. package/dist/tools/useAutoScroll.d.ts +31 -0
  81. package/dist/web-ui/attach/AttachmentCard.vue.d.ts +91 -0
  82. package/dist/web-ui/attach/AttachmentList.vue.d.ts +94 -0
  83. package/dist/web-ui/attach/types.d.ts +5 -0
  84. package/dist/web-ui/chat/ChatContainer.vue.d.ts +165 -0
  85. package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +88 -0
  86. package/dist/web-ui/chat/types.d.ts +24 -0
  87. package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +67 -0
  88. package/dist/web-ui/envswitch/types.d.ts +22 -0
  89. package/dist/web-ui/index.cjs +2 -0
  90. package/dist/web-ui/index.d.ts +14 -0
  91. package/dist/web-ui/index.js +1048 -0
  92. package/dist/web-ui/inputbox/Inputbox.vue.d.ts +215 -0
  93. package/dist/web-ui/recordset/RecordsetTable.vue.d.ts +37 -0
  94. package/dist/web-ui/recordset/webAnswerContentMap.d.ts +9 -0
  95. package/dist/web-ui/style.css +1 -0
  96. package/package.json +124 -4
  97. package/styles/github.css +2 -0
  98. package/styles/katex.css +2 -0
  99. package/README.md +0 -3
@@ -0,0 +1,609 @@
1
+ import "wi-chat/style.css";
2
+ import { defineAsyncComponent as N, defineComponent as L, computed as I, openBlock as l, createElementBlock as d, createElementVNode as i, Fragment as M, renderList as B, createBlock as P, resolveDynamicComponent as ie, createCommentVNode as C, createTextVNode as le, pushScopeId as H, popScopeId as K, toDisplayString as S, withDirectives as ce, vShow as de, getCurrentInstance as te, inject as oe, toValue as O, ref as E, watch as ue, onBeforeUnmount as pe, provide as ne, withKeys as J, unref as n, withModifiers as D, normalizeClass as _e, Teleport as fe, createVNode as we, Transition as me, withCtx as ve } from "vue";
3
+ import { knowledgeStreamParser as he, iframePageParser as be, outputFileParser as ge, formatFileSize as ye, IFRAME_RESIZER_CHILD_SCRIPT as ke } from "wi-chat/parser";
4
+ import { renderMarkdown as se, downloadTableAsExcel as Se } from "wi-chat/tools";
5
+ import Z from "@iframe-resizer/vue/iframe-resizer.vue";
6
+ const Ie = [
7
+ { ...he, component: N(() => Promise.resolve().then(() => We)) },
8
+ { ...be, component: N(() => Promise.resolve().then(() => Xt)) },
9
+ { ...ge, component: N(() => Promise.resolve().then(() => jt)) }
10
+ ], Ee = (o) => {
11
+ const t = (r) => {
12
+ const s = {};
13
+ for (const e of r)
14
+ !e.answerType || !e.component || (s[e.answerType] = e.component);
15
+ return s;
16
+ };
17
+ return { ...t(Ie), ...t(o ?? []) };
18
+ }, Ce = (o) => (H("data-v-efad55c8"), o = o(), K(), o), Ue = { class: "flex justify-start" }, Oe = { class: "ai-answer-bubble" }, xe = {
19
+ key: 0,
20
+ class: "ai-answer-bubble__error"
21
+ }, Le = { class: "ai-answer-bubble__body" }, Te = {
22
+ key: 0,
23
+ class: "ai-answer-bubble__status"
24
+ }, $e = {
25
+ key: 2,
26
+ class: "ai-answer-bubble__status"
27
+ }, Re = {
28
+ key: 3,
29
+ class: "ai-answer-bubble__loading"
30
+ }, Me = /* @__PURE__ */ Ce(() => /* @__PURE__ */ i("span", { class: "ai-answer-bubble__pulse" }, null, -1)), Pe = /* @__PURE__ */ L({
31
+ __name: "AiAnswerBubble",
32
+ props: {
33
+ answer: {},
34
+ error: { type: Boolean, default: !1 },
35
+ stopped: { type: Boolean, default: !1 },
36
+ contentMap: { default: () => Ee() }
37
+ },
38
+ setup(o) {
39
+ const t = o, r = I(() => {
40
+ var e, c;
41
+ return ((c = (e = t.answer) == null ? void 0 : e.answer) == null ? void 0 : c.reports) ?? [];
42
+ }), s = I(() => r.value.filter((e) => t.contentMap[e.answer_type]));
43
+ return (e, c) => (l(), d("div", Ue, [
44
+ i("div", Oe, [
45
+ e.error ? (l(), d("div", xe, "回答加载失败")) : s.value.length ? (l(), d(M, { key: 1 }, [
46
+ i("div", Le, [
47
+ (l(!0), d(M, null, B(s.value, (_, p) => (l(), P(ie(e.contentMap[_.answer_type]), {
48
+ key: p,
49
+ report: _
50
+ }, null, 8, ["report"]))), 128))
51
+ ]),
52
+ e.stopped ? (l(), d("div", Te, "回答已停止")) : C("", !0)
53
+ ], 64)) : e.stopped ? (l(), d("div", $e, "回答已停止")) : r.value.length ? C("", !0) : (l(), d("div", Re, [
54
+ Me,
55
+ le("正在思考...")
56
+ ]))
57
+ ])
58
+ ]));
59
+ }
60
+ }), T = (o, t) => {
61
+ const r = o.__vccOpts || o;
62
+ for (const [s, e] of t)
63
+ r[s] = e;
64
+ return r;
65
+ }, Zt = /* @__PURE__ */ T(Pe, [["__scopeId", "data-v-efad55c8"]]), je = (o) => (H("data-v-c6f5cb64"), o = o(), K(), o), Fe = {
66
+ key: 0,
67
+ class: "deep-thinking"
68
+ }, Ne = ["aria-expanded"], De = /* @__PURE__ */ je(() => /* @__PURE__ */ i("span", { class: "deep-thinking__title" }, "深度思考", -1)), Ae = { class: "deep-thinking__count" }, ze = { class: "deep-thinking__list" }, Be = { class: "deep-thinking__index" }, He = ["innerHTML"], Ke = /* @__PURE__ */ L({
69
+ __name: "DeepThinkingSteps",
70
+ props: {
71
+ steps: {},
72
+ expanded: { type: Boolean }
73
+ },
74
+ emits: ["update:expanded"],
75
+ setup(o, { emit: t }) {
76
+ const r = o, s = t, e = { imageDownload: !1, tableDownload: !1 }, c = /* @__PURE__ */ new Map(), _ = (u) => {
77
+ let f = c.get(u);
78
+ return f === void 0 && (c.size > 500 && c.clear(), f = se(u, e), c.set(u, f)), f;
79
+ }, p = I(() => r.steps.map(_));
80
+ return (u, f) => p.value.length ? (l(), d("div", Fe, [
81
+ i("button", {
82
+ type: "button",
83
+ class: "deep-thinking__header",
84
+ "aria-expanded": u.expanded,
85
+ onClick: f[0] || (f[0] = (b) => s("update:expanded", !u.expanded))
86
+ }, [
87
+ De,
88
+ i("span", Ae, S(p.value.length), 1),
89
+ i("span", null, S(u.expanded ? "收起" : "展开"), 1)
90
+ ], 8, Ne),
91
+ ce(i("div", ze, [
92
+ (l(!0), d(M, null, B(p.value, (b, w) => (l(), d("div", {
93
+ key: w,
94
+ class: "deep-thinking__item"
95
+ }, [
96
+ i("span", Be, S(w + 1), 1),
97
+ i("div", {
98
+ class: "markdown-it",
99
+ innerHTML: b
100
+ }, null, 8, He)
101
+ ]))), 128))
102
+ ], 512), [
103
+ [de, u.expanded]
104
+ ])
105
+ ])) : C("", !0);
106
+ }
107
+ }), Qt = /* @__PURE__ */ T(Ke, [["__scopeId", "data-v-c6f5cb64"]]), Ve = ["innerHTML"], Xe = /* @__PURE__ */ L({
108
+ __name: "KnowledgeStreamResult",
109
+ props: {
110
+ report: {}
111
+ },
112
+ setup(o) {
113
+ const t = o, r = { imageDownload: !1, tableDownload: !0 }, s = (p) => {
114
+ var w;
115
+ const f = p.target.closest(".wi-md-table-download");
116
+ if (!f)
117
+ return;
118
+ p.preventDefault(), p.stopPropagation();
119
+ const b = (w = f.closest(".wi-md-table-wrap")) == null ? void 0 : w.querySelector("table");
120
+ b && Se(b);
121
+ }, e = /* @__PURE__ */ new Map(), c = (p) => {
122
+ let u = e.get(p);
123
+ return u === void 0 && (e.size > 300 && e.clear(), u = se(p, r), e.set(p, u)), u;
124
+ }, _ = I(() => (t.report.values || []).map((p) => c(p.answer || "")));
125
+ return (p, u) => (l(), d("div", {
126
+ class: "knowledge-result",
127
+ onClick: s
128
+ }, [
129
+ (l(!0), d(M, null, B(_.value, (f, b) => (l(), d("div", {
130
+ key: b,
131
+ class: "markdown-it",
132
+ innerHTML: f
133
+ }, null, 8, Ve))), 128))
134
+ ]));
135
+ }
136
+ }), Ge = /* @__PURE__ */ T(Xe, [["__scopeId", "data-v-1827e802"]]), We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
137
+ __proto__: null,
138
+ default: Ge
139
+ }, Symbol.toStringTag, { value: "Module" })), re = Symbol("wi-chat-output-file-config"), eo = (o) => {
140
+ ne(re, o);
141
+ }, qe = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "webp", "bmp", "svg", "ico"]), Ye = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "m4a", "aac", "flac"]), Je = /* @__PURE__ */ new Set(["mp4", "webm", "mov", "avi", "mkv"]), Ze = /* @__PURE__ */ new Set(["doc", "docx", "xls", "xlsx", "ppt", "pptx"]), Qe = /* @__PURE__ */ new Set(["html", "htm"]), et = /* @__PURE__ */ new Set([
142
+ "js",
143
+ "mjs",
144
+ "cjs",
145
+ "ts",
146
+ "tsx",
147
+ "jsx",
148
+ "vue",
149
+ "py",
150
+ "java",
151
+ "c",
152
+ "h",
153
+ "cpp",
154
+ "hpp",
155
+ "cs",
156
+ "go",
157
+ "rs",
158
+ "php",
159
+ "rb",
160
+ "sh",
161
+ "bash",
162
+ "bat",
163
+ "ps1",
164
+ "css",
165
+ "scss",
166
+ "less"
167
+ ]), tt = /* @__PURE__ */ new Set([
168
+ "txt",
169
+ "text",
170
+ "md",
171
+ "markdown",
172
+ "json",
173
+ "csv",
174
+ "log",
175
+ "xml",
176
+ "yaml",
177
+ "yml",
178
+ "ini",
179
+ "conf",
180
+ "env",
181
+ "toml",
182
+ "sql"
183
+ ]), Q = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), ot = (o) => {
184
+ const t = o.lastIndexOf(".");
185
+ return t >= 0 ? o.slice(t + 1).toLowerCase() : "";
186
+ }, nt = (o) => qe.has(o) ? "image" : o === "pdf" ? "pdf" : Qe.has(o) ? "html" : Ye.has(o) ? "audio" : Je.has(o) ? "video" : Ze.has(o) ? "office" : et.has(o) ? "code" : tt.has(o) ? "text" : "unknown", st = (o) => {
187
+ const t = te() ? oe(re, {}) : {}, r = I(() => {
188
+ var h;
189
+ const a = O(o);
190
+ return ((h = a == null ? void 0 : a.values) == null ? void 0 : h.file_id) ?? (a == null ? void 0 : a.file_id) ?? "";
191
+ }), s = I(() => {
192
+ var h;
193
+ const a = O(o);
194
+ return ((h = a == null ? void 0 : a.values) == null ? void 0 : h.file_name) ?? (a == null ? void 0 : a.file_name) ?? "未命名文件";
195
+ }), e = I(() => ot(s.value)), c = I(() => nt(e.value)), _ = E(!1), p = E(!1), u = E(""), f = E(!1), b = E(""), w = E(""), y = E(null), U = I(() => y.value ? ye(y.value.size) : ""), k = () => {
196
+ w.value && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(w.value), w.value = "";
197
+ }, $ = async () => {
198
+ const a = r.value, h = s.value;
199
+ if (!a)
200
+ throw new Error("缺少文件 id,无法加载文件");
201
+ const g = a || h, W = Q.get(g);
202
+ if (W)
203
+ return W;
204
+ let R = A.get(g);
205
+ return R || (R = (async () => {
206
+ var q, Y;
207
+ if (t.loadFile)
208
+ return t.loadFile(a);
209
+ const x = (q = t.getFileUrl) == null ? void 0 : q.call(t, a);
210
+ if (!x)
211
+ throw new Error("未配置文件加载方式(请提供 loadFile 或 getFileUrl)");
212
+ const F = await fetch(x, { headers: (Y = t.getHeaders) == null ? void 0 : Y.call(t) });
213
+ if (!F.ok)
214
+ throw new Error(`文件加载失败(HTTP ${F.status})`);
215
+ return F.blob();
216
+ })().then((x) => (Q.set(g, x), x)).finally(() => A.delete(g)), A.set(g, R)), R;
217
+ }, m = async () => {
218
+ p.value = !0, u.value = "", f.value = !1, b.value = "", k();
219
+ try {
220
+ const a = await $();
221
+ y.value = a;
222
+ const h = c.value;
223
+ if (h === "office") {
224
+ f.value = !0;
225
+ return;
226
+ }
227
+ if (h === "image" || h === "pdf" || h === "audio" || h === "video") {
228
+ typeof URL < "u" && typeof URL.createObjectURL == "function" && (w.value = URL.createObjectURL(a));
229
+ return;
230
+ }
231
+ const g = await a.text();
232
+ if (g.includes("\0")) {
233
+ f.value = !0;
234
+ return;
235
+ }
236
+ b.value = g;
237
+ } catch (a) {
238
+ u.value = a instanceof Error ? a.message : String(a);
239
+ } finally {
240
+ p.value = !1;
241
+ }
242
+ }, v = async () => {
243
+ if (t.openPreview) {
244
+ t.openPreview({
245
+ fileId: r.value,
246
+ fileName: s.value,
247
+ loadFile: $,
248
+ download: G
249
+ });
250
+ return;
251
+ }
252
+ _.value = !0, await m();
253
+ }, X = () => {
254
+ _.value = !1, p.value = !1, u.value = "", f.value = !1, b.value = "", k();
255
+ }, G = async () => {
256
+ try {
257
+ const a = y.value ?? await $();
258
+ if (y.value = a, t.downloadFile) {
259
+ t.downloadFile({ fileId: r.value, fileName: s.value, blob: a });
260
+ return;
261
+ }
262
+ if (typeof document > "u" || typeof URL > "u")
263
+ return;
264
+ const h = URL.createObjectURL(a), g = document.createElement("a");
265
+ g.href = h, g.download = s.value, document.body.appendChild(g), g.click(), g.remove(), URL.revokeObjectURL(h);
266
+ } catch (a) {
267
+ u.value = a instanceof Error ? a.message : String(a), !_.value && !t.openPreview && (_.value = !0);
268
+ }
269
+ }, j = (a) => {
270
+ a.key === "Escape" && _.value && X();
271
+ };
272
+ return ue(_, (a) => {
273
+ typeof window > "u" || (a ? window.addEventListener("keydown", j) : window.removeEventListener("keydown", j));
274
+ }), pe(() => {
275
+ typeof window < "u" && window.removeEventListener("keydown", j), k();
276
+ }), {
277
+ fileId: r,
278
+ fileName: s,
279
+ extension: e,
280
+ previewKind: c,
281
+ fileSize: U,
282
+ visible: _,
283
+ loading: p,
284
+ error: u,
285
+ unsupported: f,
286
+ textContent: b,
287
+ objectUrl: w,
288
+ open: v,
289
+ close: X,
290
+ download: G
291
+ };
292
+ }, V = (o) => (H("data-v-f61a91b5"), o = o(), K(), o), rt = { class: "wi-output-file" }, at = ["aria-label"], it = /* @__PURE__ */ V(() => /* @__PURE__ */ i("svg", {
293
+ viewBox: "0 0 24 24",
294
+ fill: "none",
295
+ stroke: "currentColor",
296
+ "stroke-width": "1.7",
297
+ "stroke-linecap": "round",
298
+ "stroke-linejoin": "round"
299
+ }, [
300
+ /* @__PURE__ */ i("path", { d: "M7 2.5h7l4 4V21.5H7z" }),
301
+ /* @__PURE__ */ i("path", { d: "M14 2.5v4h4" })
302
+ ], -1)), lt = [
303
+ it
304
+ ], ct = { class: "wi-output-file__info" }, dt = ["title"], ut = { class: "wi-output-file__meta" }, pt = { class: "wi-output-file__ext" }, _t = {
305
+ key: 0,
306
+ class: "wi-output-file__size"
307
+ }, ft = /* @__PURE__ */ V(() => /* @__PURE__ */ i("svg", {
308
+ viewBox: "0 0 24 24",
309
+ fill: "none",
310
+ stroke: "currentColor",
311
+ "stroke-width": "1.8",
312
+ "stroke-linecap": "round",
313
+ "stroke-linejoin": "round"
314
+ }, [
315
+ /* @__PURE__ */ i("path", { d: "M12 3v12" }),
316
+ /* @__PURE__ */ i("path", { d: "m7 10 5 5 5-5" }),
317
+ /* @__PURE__ */ i("path", { d: "M5 21h14" })
318
+ ], -1)), wt = [
319
+ ft
320
+ ], mt = ["aria-label"], vt = { class: "wi-output-file-drawer__head" }, ht = { class: "wi-output-file-drawer__title" }, bt = { class: "wi-output-file-drawer__ext" }, gt = ["title"], yt = {
321
+ key: 0,
322
+ class: "wi-output-file-drawer__size"
323
+ }, kt = { class: "wi-output-file-drawer__actions" }, St = { class: "wi-output-file-drawer__body" }, It = {
324
+ key: 0,
325
+ class: "wi-output-file-drawer__state"
326
+ }, Et = {
327
+ key: 1,
328
+ class: "wi-output-file-drawer__state is-error"
329
+ }, Ct = {
330
+ key: 2,
331
+ class: "wi-output-file-drawer__state"
332
+ }, Ut = /* @__PURE__ */ V(() => /* @__PURE__ */ i("p", null, "该文件类型暂不支持在线预览,请下载后查看。", -1)), Ot = ["src", "alt"], xt = ["src", "title"], Lt = ["srcdoc", "title"], Tt = ["src"], $t = ["src"], Rt = {
333
+ key: 8,
334
+ class: "wi-output-file-drawer__text"
335
+ }, Mt = /* @__PURE__ */ L({
336
+ __name: "OutputFile",
337
+ props: {
338
+ report: {}
339
+ },
340
+ setup(o) {
341
+ const t = o, {
342
+ fileName: r,
343
+ extension: s,
344
+ previewKind: e,
345
+ fileSize: c,
346
+ visible: _,
347
+ loading: p,
348
+ error: u,
349
+ unsupported: f,
350
+ textContent: b,
351
+ objectUrl: w,
352
+ open: y,
353
+ close: U,
354
+ download: k
355
+ } = st(() => t.report);
356
+ return ($, m) => (l(), d("div", rt, [
357
+ i("div", {
358
+ class: "wi-output-file__card",
359
+ role: "button",
360
+ tabindex: "0",
361
+ "aria-label": `预览文件 ${n(r)}`,
362
+ onClick: m[1] || (m[1] = //@ts-ignore
363
+ (...v) => n(y) && n(y)(...v)),
364
+ onKeydown: [
365
+ m[2] || (m[2] = J(
366
+ //@ts-ignore
367
+ (...v) => n(y) && n(y)(...v),
368
+ ["enter"]
369
+ )),
370
+ m[3] || (m[3] = J(D(
371
+ //@ts-ignore
372
+ (...v) => n(y) && n(y)(...v),
373
+ ["prevent"]
374
+ ), ["space"]))
375
+ ]
376
+ }, [
377
+ i("span", {
378
+ class: _e(["wi-output-file__icon", `is-${n(e)}`])
379
+ }, lt, 2),
380
+ i("div", ct, [
381
+ i("div", {
382
+ class: "wi-output-file__name",
383
+ title: n(r)
384
+ }, S(n(r)), 9, dt),
385
+ i("div", ut, [
386
+ i("span", pt, S(n(s).toUpperCase() || "FILE"), 1),
387
+ n(c) ? (l(), d("span", _t, S(n(c)), 1)) : C("", !0)
388
+ ])
389
+ ]),
390
+ i("button", {
391
+ type: "button",
392
+ class: "wi-output-file__download",
393
+ title: "下载文件",
394
+ "aria-label": "下载文件",
395
+ onClick: m[0] || (m[0] = D(
396
+ //@ts-ignore
397
+ (...v) => n(k) && n(k)(...v),
398
+ ["stop"]
399
+ ))
400
+ }, wt)
401
+ ], 40, at),
402
+ (l(), P(fe, { to: "body" }, [
403
+ we(me, { name: "wi-output-file-fade" }, {
404
+ default: ve(() => [
405
+ n(_) ? (l(), d("div", {
406
+ key: 0,
407
+ class: "wi-output-file-mask",
408
+ onClick: m[8] || (m[8] = D(
409
+ //@ts-ignore
410
+ (...v) => n(U) && n(U)(...v),
411
+ ["self"]
412
+ ))
413
+ }, [
414
+ i("aside", {
415
+ class: "wi-output-file-drawer",
416
+ role: "dialog",
417
+ "aria-modal": "true",
418
+ "aria-label": `预览文件 ${n(r)}`
419
+ }, [
420
+ i("header", vt, [
421
+ i("div", ht, [
422
+ i("span", bt, S(n(s).toUpperCase() || "FILE"), 1),
423
+ i("div", {
424
+ class: "wi-output-file-drawer__name",
425
+ title: n(r)
426
+ }, S(n(r)), 9, gt),
427
+ n(c) ? (l(), d("div", yt, S(n(c)), 1)) : C("", !0)
428
+ ]),
429
+ i("div", kt, [
430
+ i("button", {
431
+ type: "button",
432
+ class: "wi-output-file-drawer__btn",
433
+ onClick: m[4] || (m[4] = //@ts-ignore
434
+ (...v) => n(k) && n(k)(...v))
435
+ }, "下载"),
436
+ i("button", {
437
+ type: "button",
438
+ class: "wi-output-file-drawer__btn wi-output-file-drawer__btn--close",
439
+ title: "关闭",
440
+ "aria-label": "关闭预览",
441
+ onClick: m[5] || (m[5] = //@ts-ignore
442
+ (...v) => n(U) && n(U)(...v))
443
+ }, " × ")
444
+ ])
445
+ ]),
446
+ i("div", St, [
447
+ n(p) ? (l(), d("div", It, "文件加载中…")) : n(u) ? (l(), d("div", Et, [
448
+ i("p", null, S(n(u)), 1),
449
+ i("button", {
450
+ type: "button",
451
+ class: "wi-output-file-drawer__btn",
452
+ onClick: m[6] || (m[6] = //@ts-ignore
453
+ (...v) => n(k) && n(k)(...v))
454
+ }, "下载文件")
455
+ ])) : n(f) ? (l(), d("div", Ct, [
456
+ Ut,
457
+ i("button", {
458
+ type: "button",
459
+ class: "wi-output-file-drawer__btn",
460
+ onClick: m[7] || (m[7] = //@ts-ignore
461
+ (...v) => n(k) && n(k)(...v))
462
+ }, "下载文件")
463
+ ])) : n(e) === "image" && n(w) ? (l(), d("img", {
464
+ key: 3,
465
+ class: "wi-output-file-drawer__image",
466
+ src: n(w),
467
+ alt: n(r)
468
+ }, null, 8, Ot)) : n(e) === "pdf" && n(w) ? (l(), d("iframe", {
469
+ key: 4,
470
+ class: "wi-output-file-drawer__frame",
471
+ src: n(w),
472
+ title: n(r)
473
+ }, null, 8, xt)) : n(e) === "html" ? (l(), d("iframe", {
474
+ key: 5,
475
+ class: "wi-output-file-drawer__frame",
476
+ srcdoc: n(b),
477
+ sandbox: "allow-scripts allow-forms allow-modals",
478
+ title: n(r)
479
+ }, null, 8, Lt)) : n(e) === "audio" && n(w) ? (l(), d("audio", {
480
+ key: 6,
481
+ class: "wi-output-file-drawer__media",
482
+ src: n(w),
483
+ controls: ""
484
+ }, null, 8, Tt)) : n(e) === "video" && n(w) ? (l(), d("video", {
485
+ key: 7,
486
+ class: "wi-output-file-drawer__media",
487
+ src: n(w),
488
+ controls: ""
489
+ }, null, 8, $t)) : (l(), d("pre", Rt, S(n(b)), 1))
490
+ ])
491
+ ], 8, mt)
492
+ ])) : C("", !0)
493
+ ]),
494
+ _: 1
495
+ })
496
+ ]))
497
+ ]));
498
+ }
499
+ }), Pt = /* @__PURE__ */ T(Mt, [["__scopeId", "data-v-f61a91b5"]]), jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
500
+ __proto__: null,
501
+ default: Pt
502
+ }, Symbol.toStringTag, { value: "Module" })), Ft = () => {
503
+ var t, r;
504
+ const o = (r = (t = window == null ? void 0 : window.globalConfig) == null ? void 0 : t.WebApiUrl) == null ? void 0 : r.MainUrl;
505
+ return typeof o == "string" ? o : "";
506
+ }, Nt = () => window.location.origin + window.location.pathname, z = "access-session", Dt = () => {
507
+ const o = window.location.pathname.split("/").filter((t) => !!t).join("-");
508
+ return o ? `${o}-` : "";
509
+ }, At = () => {
510
+ const o = `${Dt()}${z}`, t = [];
511
+ for (let s = 0; s < localStorage.length; s++) {
512
+ const e = localStorage.key(s);
513
+ !e || !e.endsWith(z) || e.slice(0, e.lastIndexOf(":")) !== "wi admin" && (e.endsWith(`x-${z}`) || t.push(e));
514
+ }
515
+ const r = t.find((s) => s.endsWith(o)) ?? t[0];
516
+ if (!r)
517
+ return "";
518
+ try {
519
+ const s = localStorage.getItem(r);
520
+ if (!s || s === "undefined")
521
+ return "";
522
+ const e = JSON.parse(s);
523
+ return e == null ? "" : String(e);
524
+ } catch {
525
+ return "";
526
+ }
527
+ }, ae = Symbol("wi-chat-iframe-page-config"), to = (o) => {
528
+ ne(ae, o);
529
+ }, zt = (o, t) => {
530
+ const r = (t == null ? void 0 : t.mainUrl) !== void 0 ? String(O(t.mainUrl)) : Ft(), s = (t == null ? void 0 : t.token) !== void 0 ? String(O(t.token)) : At();
531
+ return o.replace(/\{\{\s*MAIN_URL\s*\}\}/g, r).replace(/\{\{\s*SERVE_URL\s*\}\}/g, Nt()).replace(/\{\{\s*token\s*\}\}/g, s);
532
+ }, Bt = (o) => {
533
+ const t = te() ? oe(ae, {}) : {}, r = I(() => {
534
+ var _;
535
+ const e = O(o), c = ((_ = e == null ? void 0 : e.values) == null ? void 0 : _.url) ?? (e == null ? void 0 : e.url) ?? "";
536
+ return c ? t.resolveUrl ? t.resolveUrl(c) : zt(c, t) : "";
537
+ }), s = I(() => {
538
+ var c;
539
+ const e = O(o);
540
+ return ((c = e == null ? void 0 : e.values) == null ? void 0 : c.srcdoc) ?? (e == null ? void 0 : e.srcdoc) ?? "";
541
+ });
542
+ return { url: r, srcdoc: s };
543
+ }, ee = "data-wi-iframe-resizer-child", Ht = (o) => {
544
+ if (!o)
545
+ return !1;
546
+ let t = null;
547
+ try {
548
+ t = o.contentDocument;
549
+ } catch {
550
+ return !1;
551
+ }
552
+ if (!t)
553
+ return !1;
554
+ const r = t.head || t.documentElement;
555
+ if (!r)
556
+ return !1;
557
+ const s = t.defaultView;
558
+ if (s != null && s.parentIframe || s != null && s.parentIFrame || t.querySelector(`script[${ee}]`))
559
+ return !1;
560
+ const e = t.createElement("script");
561
+ return e.textContent = ke, e.setAttribute(ee, ""), r.appendChild(e), !0;
562
+ }, Kt = /* @__PURE__ */ L({
563
+ __name: "IframePage",
564
+ props: {
565
+ report: {}
566
+ },
567
+ setup(o) {
568
+ const t = o, { url: r, srcdoc: s } = Bt(() => t.report), e = (c) => {
569
+ Ht(c.target);
570
+ };
571
+ return (c, _) => n(r) ? (l(), P(Z, {
572
+ key: 0,
573
+ class: "iframe-page__frame iframe-page__frame--url",
574
+ license: "GPLv3",
575
+ src: n(r),
576
+ width: "100%",
577
+ "warning-timeout": 0,
578
+ onLoad: e
579
+ }, null, 8, ["src"])) : n(s) ? (l(), P(Z, {
580
+ key: 1,
581
+ class: "iframe-page iframe-page--srcdoc",
582
+ license: "GPLv3",
583
+ srcdoc: n(s),
584
+ width: "100%",
585
+ frameborder: "no",
586
+ border: "0",
587
+ marginwidth: "0",
588
+ marginheight: "0",
589
+ scrolling: "no"
590
+ }, null, 8, ["srcdoc"])) : C("", !0);
591
+ }
592
+ }), Vt = /* @__PURE__ */ T(Kt, [["__scopeId", "data-v-f4c94a4e"]]), Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
593
+ __proto__: null,
594
+ default: Vt
595
+ }, Symbol.toStringTag, { value: "Module" }));
596
+ export {
597
+ Zt as AiAnswerBubble,
598
+ Qt as DeepThinkingSteps,
599
+ Vt as IframePage,
600
+ Ge as KnowledgeStreamResult,
601
+ Pt as OutputFile,
602
+ Ee as createAnswerContentMap,
603
+ Ht as injectIframeResizerChild,
604
+ to as provideIframePageConfig,
605
+ eo as provideOutputFileConfig,
606
+ zt as resolveIframePlaceholders,
607
+ Bt as useIframePage
608
+ };
609
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,19 @@
1
+ import { AiAnswerReport, KnowledgeStreamValue } from 'wi-chat/parser';
2
+
3
+ declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
4
+ /** 知识流报告(values 为已处理好的文本段) */
5
+ report: AiAnswerReport<KnowledgeStreamValue[]>;
6
+ }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
7
+ /** 知识流报告(values 为已处理好的文本段) */
8
+ report: AiAnswerReport<KnowledgeStreamValue[]>;
9
+ }>>>, {}, {}>;
10
+ export default _default;
11
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
12
+ type __VLS_TypePropsToRuntimeProps<T> = {
13
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
14
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
15
+ } : {
16
+ type: import('vue').PropType<T[K]>;
17
+ required: true;
18
+ };
19
+ };
@@ -0,0 +1,19 @@
1
+ import { AiAnswerReport, OutputFileValue } from 'wi-chat/parser';
2
+
3
+ declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
4
+ /** output_file 报告(values.file_id / values.file_name) */
5
+ report: AiAnswerReport<OutputFileValue>;
6
+ }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
7
+ /** output_file 报告(values.file_id / values.file_name) */
8
+ report: AiAnswerReport<OutputFileValue>;
9
+ }>>>, {}, {}>;
10
+ export default _default;
11
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
12
+ type __VLS_TypePropsToRuntimeProps<T> = {
13
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
14
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
15
+ } : {
16
+ type: import('vue').PropType<T[K]>;
17
+ required: true;
18
+ };
19
+ };