rt-chat-messages 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -22
- package/dist/chat-messages.es.js +1019 -687
- package/dist/chat-messages.umd.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/ChatMessageList.vue.d.ts +22 -1
- package/dist/types/components/MultimodalMessage.vue.d.ts +10 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +9 -0
- package/package.json +4 -2
package/dist/chat-messages.es.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { defineComponent as be, ref as w, onMounted as Ve, computed as Q, createBlock as oe, createCommentVNode as z, openBlock as u, Teleport as st, createElementBlock as f, withModifiers as fe, normalizeClass as he, createElementVNode as o, normalizeStyle as Ie, renderSlot as Oe, h as Fe, watch as ge, nextTick as ne, onUnmounted as Ue, createVNode as k, withCtx as R, unref as E, createTextVNode as We, toDisplayString as K, Fragment as Ee, renderList as Te, resolveDynamicComponent as Ke, withDirectives as nt, vShow as ot, createStaticVNode as lt, Transition as rt, getCurrentInstance as it } from "vue";
|
|
2
|
+
import { useMessageProcessor as ct, A2UISurface as ut, useA2UIConfig as dt, provideA2UI as mt, defaultTheme as vt, DEFAULT_CATALOG as ft } from "a2ui-vue";
|
|
3
|
+
import gt from "markdown-it";
|
|
4
|
+
import ht from "@vscode/markdown-it-katex";
|
|
5
|
+
import je from "mermaid";
|
|
6
|
+
const pt = { class: "cm-dialog__body" }, yt = /* @__PURE__ */ be({
|
|
6
7
|
__name: "Dialog",
|
|
7
8
|
props: {
|
|
8
9
|
visible: { type: Boolean, default: !1 },
|
|
@@ -13,63 +14,63 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
13
14
|
appendToBody: { type: Boolean, default: !0 }
|
|
14
15
|
},
|
|
15
16
|
emits: ["update:visible", "close"],
|
|
16
|
-
setup(
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
setup(r, { emit: h }) {
|
|
18
|
+
const b = r, p = h, d = w(!1);
|
|
19
|
+
Ve(() => {
|
|
20
|
+
d.value = !0;
|
|
20
21
|
});
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
22
|
+
const S = Q(() => b.fullscreen ? { width: "100%", height: "100%", margin: 0 } : { width: b.width }), C = () => {
|
|
23
|
+
p("update:visible", !1), p("close");
|
|
24
|
+
}, A = () => {
|
|
25
|
+
b.closeOnClickModal && C();
|
|
25
26
|
};
|
|
26
|
-
return (
|
|
27
|
+
return (x, _) => d.value ? (u(), oe(st, {
|
|
27
28
|
key: 0,
|
|
28
29
|
to: "body"
|
|
29
30
|
}, [
|
|
30
|
-
|
|
31
|
+
r.visible ? (u(), f("div", {
|
|
31
32
|
key: 0,
|
|
32
|
-
class:
|
|
33
|
-
onClick:
|
|
33
|
+
class: he(["cm-dialog-overlay", { "is-fullscreen": r.fullscreen }]),
|
|
34
|
+
onClick: fe(A, ["self"])
|
|
34
35
|
}, [
|
|
35
|
-
|
|
36
|
+
o("div", {
|
|
36
37
|
class: "cm-dialog",
|
|
37
|
-
style:
|
|
38
|
+
style: Ie(S.value),
|
|
38
39
|
role: "dialog",
|
|
39
40
|
"aria-modal": "true"
|
|
40
41
|
}, [
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
o("div", pt, [
|
|
43
|
+
Oe(x.$slots, "default", {}, void 0, !0)
|
|
43
44
|
]),
|
|
44
|
-
|
|
45
|
+
r.showClose ? (u(), f("button", {
|
|
45
46
|
key: 0,
|
|
46
47
|
class: "cm-dialog__close",
|
|
47
|
-
onClick:
|
|
48
|
+
onClick: C
|
|
48
49
|
}, [..._[0] || (_[0] = [
|
|
49
|
-
|
|
50
|
+
o("svg", {
|
|
50
51
|
viewBox: "0 0 1024 1024",
|
|
51
52
|
width: "16",
|
|
52
53
|
height: "16"
|
|
53
54
|
}, [
|
|
54
|
-
|
|
55
|
+
o("path", {
|
|
55
56
|
fill: "currentColor",
|
|
56
57
|
d: "M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
|
|
57
58
|
})
|
|
58
59
|
], -1)
|
|
59
|
-
])])) :
|
|
60
|
+
])])) : z("", !0)
|
|
60
61
|
], 4)
|
|
61
|
-
], 2)) :
|
|
62
|
-
])) :
|
|
62
|
+
], 2)) : z("", !0)
|
|
63
|
+
])) : z("", !0);
|
|
63
64
|
}
|
|
64
|
-
}),
|
|
65
|
-
const
|
|
66
|
-
for (const [
|
|
67
|
-
|
|
68
|
-
return
|
|
69
|
-
},
|
|
65
|
+
}), _e = (r, h) => {
|
|
66
|
+
const b = r.__vccOpts || r;
|
|
67
|
+
for (const [p, d] of h)
|
|
68
|
+
b[p] = d;
|
|
69
|
+
return b;
|
|
70
|
+
}, Pe = /* @__PURE__ */ _e(yt, [["__scopeId", "data-v-efdf0259"]]), wt = ["disabled"], kt = {
|
|
70
71
|
key: 0,
|
|
71
72
|
class: "cm-icon-loading"
|
|
72
|
-
},
|
|
73
|
+
}, bt = /* @__PURE__ */ be({
|
|
73
74
|
__name: "Button",
|
|
74
75
|
props: {
|
|
75
76
|
type: { default: "default" },
|
|
@@ -79,37 +80,37 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
79
80
|
loading: { type: Boolean, default: !1 }
|
|
80
81
|
},
|
|
81
82
|
emits: ["click"],
|
|
82
|
-
setup(
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
setup(r, { emit: h }) {
|
|
84
|
+
const b = r, p = h, d = (S) => {
|
|
85
|
+
b.disabled || b.loading || p("click", S);
|
|
85
86
|
};
|
|
86
|
-
return (
|
|
87
|
-
class:
|
|
88
|
-
`cm-button--${
|
|
89
|
-
`cm-button--${
|
|
90
|
-
{ "is-circle":
|
|
87
|
+
return (S, C) => (u(), f("button", {
|
|
88
|
+
class: he(["cm-button", [
|
|
89
|
+
`cm-button--${r.type}`,
|
|
90
|
+
`cm-button--${r.size}`,
|
|
91
|
+
{ "is-circle": r.circle, "is-disabled": r.disabled, "is-loading": r.loading }
|
|
91
92
|
]]),
|
|
92
|
-
disabled:
|
|
93
|
-
onClick:
|
|
93
|
+
disabled: r.disabled || r.loading,
|
|
94
|
+
onClick: d
|
|
94
95
|
}, [
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
r.loading ? (u(), f("span", kt, [...C[0] || (C[0] = [
|
|
97
|
+
o("svg", {
|
|
97
98
|
viewBox: "0 0 1024 1024",
|
|
98
99
|
width: "1em",
|
|
99
100
|
height: "1em"
|
|
100
101
|
}, [
|
|
101
|
-
|
|
102
|
+
o("path", {
|
|
102
103
|
fill: "currentColor",
|
|
103
104
|
d: "M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"
|
|
104
105
|
})
|
|
105
106
|
], -1)
|
|
106
|
-
])])) :
|
|
107
|
-
], 10,
|
|
107
|
+
])])) : Oe(S.$slots, "default", { key: 1 }, void 0, !0)
|
|
108
|
+
], 10, wt));
|
|
108
109
|
}
|
|
109
|
-
}),
|
|
110
|
-
name:
|
|
110
|
+
}), Y = /* @__PURE__ */ _e(bt, [["__scopeId", "data-v-bab126c7"]]), X = (r, h) => be({
|
|
111
|
+
name: r,
|
|
111
112
|
render() {
|
|
112
|
-
return
|
|
113
|
+
return Fe(
|
|
113
114
|
"svg",
|
|
114
115
|
{
|
|
115
116
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -119,76 +120,76 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
119
120
|
fill: "currentColor",
|
|
120
121
|
style: "vertical-align: middle"
|
|
121
122
|
},
|
|
122
|
-
[
|
|
123
|
+
[Fe("path", { d: h })]
|
|
123
124
|
);
|
|
124
125
|
}
|
|
125
|
-
}),
|
|
126
|
+
}), He = X(
|
|
126
127
|
"Close",
|
|
127
128
|
"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
|
|
128
|
-
),
|
|
129
|
+
), Ye = X(
|
|
129
130
|
"ZoomIn",
|
|
130
131
|
"M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm268.48-154.56a32 32 0 0 0-32 32v90.496h-90.56a32 32 0 0 0 0 64h90.56v90.56a32 32 0 0 0 64 0v-90.496h90.496a32 32 0 0 0 0-64H373.632v-90.56a32 32 0 0 0-32-32z"
|
|
131
|
-
),
|
|
132
|
+
), Ne = X(
|
|
132
133
|
"ZoomOut",
|
|
133
134
|
"M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm145.92-58.56a32 32 0 0 0 0 64h245.12a32 32 0 0 0 0-64H219.072z"
|
|
134
|
-
),
|
|
135
|
+
), Mt = X(
|
|
135
136
|
"Document",
|
|
136
137
|
"M854.6 288.7c0.4 0 0.7 0 1 0v431.5c0 17.6-14.4 32-32 32H200.4c-17.6 0-32-14.4-32-32l0-575.2c0-17.6 14.4-32 32-32h391.5c0 0.3 0 0.7 0 1l0 142.1c0 17.6 14.4 32.1 32 32.1h142.6c0-0.4 0-0.7 0-1.1L854.6 288.7zM790.2 220.2L668 97.9v122.3h122.2zM240 448h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h384a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64z"
|
|
137
|
-
),
|
|
138
|
+
), Xe = X(
|
|
138
139
|
"Download",
|
|
139
140
|
"M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2 0.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"
|
|
140
|
-
),
|
|
141
|
+
), St = X(
|
|
141
142
|
"VideoPlay",
|
|
142
143
|
"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-48-247.616L668.608 512 464 375.616v272.768zm10.656-340.32a32 32 0 0 1 32 32V673.92a32 32 0 0 1-50.208 26.24l-236.8-161.92a32 32 0 0 1 0-52.48l236.8-161.92a32 32 0 0 1 18.208-5.632z"
|
|
143
|
-
),
|
|
144
|
+
), Ct = X(
|
|
144
145
|
"VideoPause",
|
|
145
146
|
"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-96-544a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32zm192 0a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32z"
|
|
146
|
-
),
|
|
147
|
+
), At = X(
|
|
147
148
|
"ArrowLeft",
|
|
148
149
|
"M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"
|
|
149
|
-
),
|
|
150
|
+
), $t = X(
|
|
150
151
|
"ArrowRight",
|
|
151
152
|
"M340.864 149.312a29.12 29.12 0 0 0-41.728 0 30.592 30.592 0 0 0 0 42.752L611.072 511.936 299.136 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L672.448 534.272a32 32 0 0 0 0-44.672L340.864 149.312z"
|
|
152
|
-
),
|
|
153
|
+
), qe = X(
|
|
153
154
|
"Spinner",
|
|
154
155
|
"M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"
|
|
155
|
-
),
|
|
156
|
+
), Ze = X(
|
|
156
157
|
"Check",
|
|
157
158
|
"M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"
|
|
158
|
-
),
|
|
159
|
+
), It = X(
|
|
159
160
|
"ChevronUp",
|
|
160
161
|
"M854.6 642.5l-320-320c-12.5-12.5-32.8-12.5-45.3 0l-320 320c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L512 390.6l297.4 297.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3z"
|
|
161
|
-
),
|
|
162
|
+
), _t = X(
|
|
162
163
|
"ChevronDown",
|
|
163
164
|
"M854.6 381.5l-320 320c-12.5 12.5-32.8 12.5-45.3 0l-320-320c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L512 633.4l297.4-297.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3z"
|
|
164
|
-
),
|
|
165
|
+
), xt = ["src", "alt"], Lt = { class: "preview-controls" }, zt = { class: "cm-button-group" }, Et = {
|
|
165
166
|
key: 0,
|
|
166
167
|
class: "mobile-close-hint"
|
|
167
|
-
},
|
|
168
|
+
}, Tt = ["innerHTML"], Bt = { class: "preview-controls" }, Ut = { class: "cm-button-group" }, Ht = {
|
|
168
169
|
key: 0,
|
|
169
170
|
class: "mobile-close-hint"
|
|
170
|
-
},
|
|
171
|
+
}, Dt = /* @__PURE__ */ be({
|
|
171
172
|
__name: "MarkdownMessage",
|
|
172
173
|
props: {
|
|
173
174
|
content: {},
|
|
174
175
|
isStreaming: { type: Boolean, default: !1 }
|
|
175
176
|
},
|
|
176
|
-
setup(
|
|
177
|
-
const
|
|
178
|
-
let
|
|
179
|
-
|
|
177
|
+
setup(r) {
|
|
178
|
+
const h = r, b = w(), p = w(), d = w(!1), S = w(""), C = w(""), A = w(!1), x = w(""), _ = w(!1), m = w(1), V = w({ x: 0, y: 0 }), L = w(!1), P = w({ x: 0, y: 0 }), T = w(1), W = w({ x: 0, y: 0 }), B = w(!1), pe = w({ x: 0, y: 0 }), I = w(""), te = w(/* @__PURE__ */ new Map()), le = w(!1);
|
|
179
|
+
let ye = 0;
|
|
180
|
+
je.initialize({
|
|
180
181
|
startOnLoad: !1,
|
|
181
182
|
theme: "default",
|
|
182
183
|
securityLevel: "loose",
|
|
183
184
|
fontFamily: "inherit"
|
|
184
185
|
});
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
e.renderer.rules.fence = (
|
|
188
|
-
const
|
|
189
|
-
return (
|
|
186
|
+
const xe = (e) => {
|
|
187
|
+
const a = e.renderer.rules.fence;
|
|
188
|
+
e.renderer.rules.fence = (s, n, c, l, y) => {
|
|
189
|
+
const M = s[n], j = M.content.trim();
|
|
190
|
+
return (M.info ? M.info.trim() : "") === "mermaid" ? (ye++, `<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${ye}`}">${j}</pre></div>`) : a(s, n, c, l, y);
|
|
190
191
|
};
|
|
191
|
-
},
|
|
192
|
+
}, N = new gt({
|
|
192
193
|
html: !0,
|
|
193
194
|
// 允许HTML标签,以便markdown渲染的标签能正常显示
|
|
194
195
|
xhtmlOut: !1,
|
|
@@ -202,685 +203,737 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
202
203
|
// 启用一些语言中性的替换 + 引号美化
|
|
203
204
|
quotes: `""''`,
|
|
204
205
|
// 双引号和单引号的替换对,中文环境
|
|
205
|
-
highlight: function(e,
|
|
206
|
-
return
|
|
206
|
+
highlight: function(e, a) {
|
|
207
|
+
return a && a.trim() ? `<pre class="hljs language-${a}"><code>${((n) => n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"))(e)}</code></pre>` : `<pre class="hljs"><code>${e}</code></pre>`;
|
|
207
208
|
}
|
|
208
|
-
}),
|
|
209
|
-
return
|
|
209
|
+
}), U = N.renderer.rules.image || function(e, a, s, n, c) {
|
|
210
|
+
return c.renderToken(e, a, s);
|
|
210
211
|
};
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
let
|
|
216
|
-
for (let
|
|
217
|
-
const
|
|
218
|
-
|
|
212
|
+
N.renderer.rules.image = function(e, a, s, n, c) {
|
|
213
|
+
const l = e[a], y = l.attrIndex("src");
|
|
214
|
+
if (y >= 0) {
|
|
215
|
+
const M = l.attrs[y][1], D = "img-" + ((G) => {
|
|
216
|
+
let F = 0;
|
|
217
|
+
for (let Z = 0; Z < G.length; Z++) {
|
|
218
|
+
const ve = G.charCodeAt(Z);
|
|
219
|
+
F = (F << 5) - F + ve, F = F & F;
|
|
219
220
|
}
|
|
220
|
-
return Math.abs(
|
|
221
|
-
})(
|
|
222
|
-
|
|
221
|
+
return Math.abs(F).toString(36);
|
|
222
|
+
})(M);
|
|
223
|
+
l.attrSet("id", D), l.attrSet("data-image-id", D), l.attrSet("key", D), l.attrSet("loading", "eager"), l.attrSet("decoding", "async"), l.attrSet("fetchpriority", "high"), l.attrSet("data-src", M), l.attrSet("data-cached", "true");
|
|
223
224
|
}
|
|
224
|
-
return
|
|
225
|
-
},
|
|
225
|
+
return U(e, a, s, n, c);
|
|
226
|
+
}, N.use(ht, {
|
|
226
227
|
throwOnError: !1,
|
|
227
228
|
errorColor: "#cc0000"
|
|
228
|
-
}),
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
return
|
|
232
|
-
},
|
|
229
|
+
}), N.use(xe);
|
|
230
|
+
const Me = (e) => {
|
|
231
|
+
const a = e.match(/```[\w]*\n/g), s = e.match(/\n```/g), n = (a == null ? void 0 : a.length) || 0, c = (s == null ? void 0 : s.length) || 0;
|
|
232
|
+
return n > c && (e += "\n```"), e;
|
|
233
|
+
}, we = (e) => {
|
|
233
234
|
if (!e) return "";
|
|
234
235
|
e = e.replace(/;;\s*$/g, ""), e = e.replace(/;;\s*$/g, "");
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
e =
|
|
236
|
+
const a = /^```(?:markdown|md)\s*\n([\s\S]*?)\n```$/, s = e.match(a);
|
|
237
|
+
if (s)
|
|
238
|
+
e = s[1];
|
|
238
239
|
else {
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
(/^#{1,6}\s/.test(
|
|
240
|
+
const n = /^```\s*\n([\s\S]*?)\n```$/, c = e.match(n);
|
|
241
|
+
if (c) {
|
|
242
|
+
const l = c[1];
|
|
243
|
+
(/^#{1,6}\s/.test(l) || /^\*{1,2}[^*]+\*{1,2}/.test(l) || /^[-*+]\s/.test(l) || /^\d+\.\s/.test(l) || /!\[.*?\]\(.*?\)/.test(l) || /\[.*?\]\(.*?\)/.test(l) || /^\|.+\|/.test(l) || /^\|[\s-:]+\|/m.test(l)) && (e = l);
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
|
-
if (
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
(/^#{1,6}\s/.test(
|
|
246
|
+
if (h.isStreaming) {
|
|
247
|
+
const n = /^```(?:markdown|md)?\s*\n/;
|
|
248
|
+
if (n.test(e)) {
|
|
249
|
+
const l = e.replace(n, "");
|
|
250
|
+
(/^#{1,6}\s/.test(l) || /^\|.+\|/.test(l) || /^\|[\s-:]+\|/m.test(l) || /!\[.*?\]\(.*?\)/.test(l) || /\[.*?\]\(.*?\)/.test(l)) && (e = e.replace(n, ""));
|
|
250
251
|
}
|
|
251
|
-
if (/^```(?:markdown|md)?\s*\n/.test(
|
|
252
|
-
const
|
|
253
|
-
|
|
252
|
+
if (/^```(?:markdown|md)?\s*\n/.test(h.content)) {
|
|
253
|
+
const l = /\n```\s*$/;
|
|
254
|
+
l.test(e) && (e = e.replace(l, ""));
|
|
254
255
|
}
|
|
255
256
|
}
|
|
256
257
|
return e = e.replace(
|
|
257
258
|
/```(?:markdown|md)\s*\n([\s\S]*?)\n```/g,
|
|
258
|
-
(
|
|
259
|
-
),
|
|
260
|
-
},
|
|
259
|
+
(n, c) => c
|
|
260
|
+
), h.isStreaming && (e = Me(e)), e;
|
|
261
|
+
}, re = (e) => {
|
|
261
262
|
if (!e.includes("<img"))
|
|
262
263
|
return e;
|
|
263
|
-
const
|
|
264
|
-
let
|
|
265
|
-
const
|
|
266
|
-
for (; (
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
const
|
|
270
|
-
|
|
264
|
+
const a = /<img[^>]*?src="([^"]*)"[^>]*?>/g;
|
|
265
|
+
let s, n = e;
|
|
266
|
+
const c = [];
|
|
267
|
+
for (; (s = a.exec(e)) !== null; ) {
|
|
268
|
+
const l = s[0], y = s[1];
|
|
269
|
+
if (te.value.has(y)) {
|
|
270
|
+
const M = te.value.get(y);
|
|
271
|
+
l !== M && c.push({ original: l, cached: M });
|
|
271
272
|
} else
|
|
272
|
-
|
|
273
|
+
te.value.set(y, l);
|
|
273
274
|
}
|
|
274
|
-
for (const { original:
|
|
275
|
-
|
|
276
|
-
return
|
|
277
|
-
},
|
|
278
|
-
if (!
|
|
275
|
+
for (const { original: l, cached: y } of c)
|
|
276
|
+
n = n.replace(l, y);
|
|
277
|
+
return n;
|
|
278
|
+
}, ie = (e) => {
|
|
279
|
+
if (!p.value)
|
|
279
280
|
return;
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
const a = p.value, s = /* @__PURE__ */ new Map();
|
|
282
|
+
if (h.isStreaming && a.children.length > 0 && a.querySelectorAll("img[data-image-id]").forEach((n) => {
|
|
283
|
+
const c = n.getAttribute("data-image-id");
|
|
284
|
+
c && s.set(c, n);
|
|
285
|
+
}), a.innerHTML = e, !h.isStreaming) {
|
|
286
|
+
ne(() => {
|
|
287
|
+
t(), g();
|
|
284
288
|
});
|
|
285
289
|
return;
|
|
286
290
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
v && g.set(v, s);
|
|
293
|
-
}), l.querySelectorAll("img[data-image-id]").forEach((s) => {
|
|
294
|
-
const v = s.getAttribute("data-image-id");
|
|
295
|
-
if (v && g.has(v)) {
|
|
296
|
-
const w = g.get(v);
|
|
297
|
-
s.parentNode && s.parentNode.replaceChild(w, s);
|
|
291
|
+
s.size > 0 && a.querySelectorAll("img[data-image-id]").forEach((n) => {
|
|
292
|
+
const c = n.getAttribute("data-image-id");
|
|
293
|
+
if (c && s.has(c)) {
|
|
294
|
+
const l = s.get(c);
|
|
295
|
+
n.parentNode && l !== n && n.parentNode.replaceChild(l, n);
|
|
298
296
|
}
|
|
299
297
|
});
|
|
300
|
-
|
|
301
|
-
for (; l.firstChild; )
|
|
302
|
-
r.appendChild(l.firstChild);
|
|
303
|
-
t.innerHTML = "", t.appendChild(r);
|
|
304
|
-
}, K = () => {
|
|
298
|
+
}, J = () => {
|
|
305
299
|
try {
|
|
306
|
-
if (!
|
|
307
|
-
|
|
300
|
+
if (!h.content) {
|
|
301
|
+
I.value = "", p.value && (p.value.innerHTML = ""), h.isStreaming || te.value.clear();
|
|
308
302
|
return;
|
|
309
303
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
304
|
+
if (document.hidden && h.isStreaming) {
|
|
305
|
+
le.value = !0;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const e = we(h.content);
|
|
309
|
+
let a = N.render(e);
|
|
310
|
+
h.isStreaming && a.includes("<img") && (a = re(a)), a !== I.value && (I.value = a, ie(a)), h.isStreaming || te.value.clear();
|
|
313
311
|
} catch (e) {
|
|
314
|
-
console.error("Markdown rendering error:", e),
|
|
312
|
+
console.error("Markdown rendering error:", e), p.value && (p.value.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word;">${h.content}</pre>`);
|
|
315
313
|
}
|
|
316
314
|
};
|
|
317
|
-
|
|
318
|
-
() =>
|
|
319
|
-
(e,
|
|
320
|
-
|
|
321
|
-
|
|
315
|
+
ge(() => h.content, J), ge(
|
|
316
|
+
() => h.isStreaming,
|
|
317
|
+
(e, a) => {
|
|
318
|
+
a && !e && ne(() => {
|
|
319
|
+
J();
|
|
322
320
|
});
|
|
323
321
|
}
|
|
324
322
|
);
|
|
325
|
-
const
|
|
323
|
+
const ce = () => {
|
|
324
|
+
!document.hidden && le.value && (le.value = !1, ne(() => {
|
|
325
|
+
J();
|
|
326
|
+
}));
|
|
327
|
+
};
|
|
328
|
+
document.addEventListener("visibilitychange", ce), Ue(() => {
|
|
329
|
+
document.removeEventListener("visibilitychange", ce);
|
|
330
|
+
});
|
|
331
|
+
const i = () => {
|
|
326
332
|
_.value = window.innerWidth < 768;
|
|
327
|
-
},
|
|
328
|
-
let
|
|
329
|
-
return
|
|
333
|
+
}, v = (e) => {
|
|
334
|
+
let a = e;
|
|
335
|
+
return a = a.replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1"), [
|
|
330
336
|
/([A-Za-z0-9_]+)\[([^\]]*[\u4e00-\u9fa5]+[^\]]*)\]/g,
|
|
331
337
|
/([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,
|
|
332
338
|
/([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g
|
|
333
|
-
].forEach((
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
return
|
|
337
|
-
let
|
|
338
|
-
return
|
|
339
|
+
].forEach((n) => {
|
|
340
|
+
a = a.replace(n, (c, l, y) => {
|
|
341
|
+
if (y.startsWith('"') && y.endsWith('"'))
|
|
342
|
+
return c;
|
|
343
|
+
let M = y.replace(/^["']+|["']+$/g, "").replace(/["]/g, '\\"');
|
|
344
|
+
return c.includes("[") ? `${l}["${M}"]` : c.includes("(") ? `${l}("${M}")` : c.includes("{") ? `${l}{"${M}"}` : c;
|
|
339
345
|
});
|
|
340
|
-
}),
|
|
341
|
-
},
|
|
342
|
-
var
|
|
343
|
-
if (
|
|
344
|
-
const e =
|
|
346
|
+
}), a;
|
|
347
|
+
}, g = async () => {
|
|
348
|
+
var a, s;
|
|
349
|
+
if (h.isStreaming || (await ne(), !b.value)) return;
|
|
350
|
+
const e = b.value.querySelectorAll(".mermaid");
|
|
345
351
|
if (e.length !== 0)
|
|
346
|
-
for (const
|
|
347
|
-
const
|
|
348
|
-
let
|
|
349
|
-
if (
|
|
352
|
+
for (const n of Array.from(e)) {
|
|
353
|
+
const c = n;
|
|
354
|
+
let l = (a = c.textContent) == null ? void 0 : a.trim();
|
|
355
|
+
if (l && c.getAttribute("data-processed") !== "true")
|
|
350
356
|
try {
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
if (
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}),
|
|
357
|
+
c.setAttribute("data-processed", "true"), l = v(l);
|
|
358
|
+
const y = c.getAttribute("data-mermaid-id") || `mermaid-${Date.now()}-${Math.random()}`, { svg: M } = await je.render(y, l), j = c.parentElement;
|
|
359
|
+
if (j) {
|
|
360
|
+
const D = document.createElement("div");
|
|
361
|
+
D.className = "mermaid-svg", D.innerHTML = M, D.setAttribute("data-mermaid-svg", "true"), D.style.cursor = "pointer", D.title = "Click to zoom", D.addEventListener("click", (G) => {
|
|
362
|
+
G.preventDefault(), G.stopPropagation(), x.value = M, T.value = 1, W.value = { x: 0, y: 0 }, A.value = !0;
|
|
363
|
+
}), j.replaceChild(D, c);
|
|
358
364
|
}
|
|
359
|
-
} catch (
|
|
360
|
-
console.error("Mermaid render failure:",
|
|
361
|
-
const
|
|
362
|
-
|
|
365
|
+
} catch (y) {
|
|
366
|
+
console.error("Mermaid render failure:", y);
|
|
367
|
+
const M = document.createElement("div");
|
|
368
|
+
M.className = "mermaid-error", M.textContent = `Mermaid render error: ${y}`, (s = c.parentElement) == null || s.replaceChild(M, c);
|
|
363
369
|
}
|
|
364
370
|
}
|
|
365
|
-
},
|
|
371
|
+
}, $ = (e) => {
|
|
366
372
|
e.preventDefault(), e.stopPropagation();
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
},
|
|
370
|
-
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
},
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
},
|
|
373
|
+
const a = e.target;
|
|
374
|
+
S.value = a.src, C.value = a.alt || "Image Preview", m.value = 1, V.value = { x: 0, y: 0 }, d.value = !0;
|
|
375
|
+
}, H = () => {
|
|
376
|
+
m.value <= 1 && (V.value = { x: 0, y: 0 });
|
|
377
|
+
}, ue = () => {
|
|
378
|
+
m.value = Math.min(m.value + 1, 10), H();
|
|
379
|
+
}, ae = () => {
|
|
380
|
+
m.value = Math.max(m.value - 1, 0.5), H();
|
|
381
|
+
}, de = () => {
|
|
382
|
+
m.value = 1, V.value = { x: 0, y: 0 };
|
|
383
|
+
}, Se = () => {
|
|
384
|
+
m.value <= 1 && (d.value = !1);
|
|
385
|
+
}, me = (e) => {
|
|
380
386
|
e.preventDefault();
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
var
|
|
385
|
-
if (
|
|
386
|
-
e.preventDefault(),
|
|
387
|
-
x: e.clientX -
|
|
388
|
-
y: e.clientY -
|
|
387
|
+
const a = e.deltaY > 0 ? -0.5 : 0.5, s = Math.max(0.5, Math.min(10, m.value + a));
|
|
388
|
+
m.value = s, H();
|
|
389
|
+
}, ee = (e) => {
|
|
390
|
+
var l;
|
|
391
|
+
if (m.value <= 1) return;
|
|
392
|
+
e.preventDefault(), L.value = !0, P.value = {
|
|
393
|
+
x: e.clientX - V.value.x,
|
|
394
|
+
y: e.clientY - V.value.y
|
|
389
395
|
};
|
|
390
|
-
const
|
|
391
|
-
if (!
|
|
392
|
-
let
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
},
|
|
396
|
-
|
|
396
|
+
const a = e.target, s = (l = a.parentElement) == null ? void 0 : l.getBoundingClientRect(), n = (y) => {
|
|
397
|
+
if (!L.value || !s) return;
|
|
398
|
+
let M = y.clientX - P.value.x, j = y.clientY - P.value.y;
|
|
399
|
+
const D = a.offsetWidth, G = a.offsetHeight, F = D * m.value, Z = G * m.value, ve = 0.3, De = s.width * (1 - ve - 0.5) - F / 2, Le = F / 2 - s.width * (1 - ve - 0.5), ze = s.height * (1 - ve - 0.5) - Z / 2, $e = Z / 2 - s.height * (1 - ve - 0.5);
|
|
400
|
+
F > s.width ? M = Math.max(De, Math.min(Le, M)) : M = 0, Z > s.height ? j = Math.max(ze, Math.min($e, j)) : j = 0, V.value = { x: M, y: j };
|
|
401
|
+
}, c = () => {
|
|
402
|
+
L.value = !1, document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", c);
|
|
397
403
|
};
|
|
398
|
-
document.addEventListener("mousemove",
|
|
399
|
-
},
|
|
400
|
-
var
|
|
404
|
+
document.addEventListener("mousemove", n), document.addEventListener("mouseup", c);
|
|
405
|
+
}, O = (e) => {
|
|
406
|
+
var j;
|
|
401
407
|
if (e.touches.length !== 1) return;
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
|
|
405
|
-
x:
|
|
406
|
-
y:
|
|
408
|
+
const a = e.touches[0], s = a.clientX, n = a.clientY;
|
|
409
|
+
if (m.value <= 1) return;
|
|
410
|
+
L.value = !0, P.value = {
|
|
411
|
+
x: s - V.value.x,
|
|
412
|
+
y: n - V.value.y
|
|
407
413
|
};
|
|
408
|
-
const
|
|
409
|
-
if (!
|
|
414
|
+
const c = e.target, l = (j = c.parentElement) == null ? void 0 : j.getBoundingClientRect(), y = (D) => {
|
|
415
|
+
if (!L.value || D.touches.length !== 1 || !l)
|
|
410
416
|
return;
|
|
411
|
-
const
|
|
412
|
-
let
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
},
|
|
416
|
-
|
|
417
|
+
const G = D.touches[0];
|
|
418
|
+
let F = G.clientX - P.value.x, Z = G.clientY - P.value.y;
|
|
419
|
+
const ve = c.offsetWidth, De = c.offsetHeight, Le = ve * m.value, ze = De * m.value, $e = 0.3, Qe = l.width * (1 - $e - 0.5) - Le / 2, et = Le / 2 - l.width * (1 - $e - 0.5), tt = l.height * (1 - $e - 0.5) - ze / 2, at = ze / 2 - l.height * (1 - $e - 0.5);
|
|
420
|
+
Le > l.width ? F = Math.max(Qe, Math.min(et, F)) : F = 0, ze > l.height ? Z = Math.max(tt, Math.min(at, Z)) : Z = 0, V.value = { x: F, y: Z };
|
|
421
|
+
}, M = () => {
|
|
422
|
+
L.value = !1, document.removeEventListener("touchmove", y), document.removeEventListener("touchend", M);
|
|
417
423
|
};
|
|
418
|
-
document.addEventListener("touchmove",
|
|
419
|
-
},
|
|
420
|
-
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
},
|
|
424
|
-
|
|
425
|
-
},
|
|
424
|
+
document.addEventListener("touchmove", y, { passive: !1 }), document.addEventListener("touchend", M);
|
|
425
|
+
}, q = () => {
|
|
426
|
+
T.value = Math.min(T.value + 1, 10);
|
|
427
|
+
}, ke = () => {
|
|
428
|
+
T.value = Math.max(T.value - 1, 0.5);
|
|
429
|
+
}, se = () => {
|
|
430
|
+
T.value = 1, W.value = { x: 0, y: 0 };
|
|
431
|
+
}, Ce = (e) => {
|
|
426
432
|
e.preventDefault();
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
},
|
|
430
|
-
var
|
|
431
|
-
if (
|
|
432
|
-
e.preventDefault(),
|
|
433
|
-
x: e.clientX -
|
|
434
|
-
y: e.clientY -
|
|
433
|
+
const a = e.deltaY > 0 ? -0.5 : 0.5;
|
|
434
|
+
T.value = Math.max(0.5, Math.min(10, T.value + a));
|
|
435
|
+
}, Be = (e) => {
|
|
436
|
+
var l, y;
|
|
437
|
+
if (T.value <= 1) return;
|
|
438
|
+
e.preventDefault(), B.value = !0, pe.value = {
|
|
439
|
+
x: e.clientX - W.value.x,
|
|
440
|
+
y: e.clientY - W.value.y
|
|
435
441
|
};
|
|
436
|
-
const
|
|
437
|
-
if (!
|
|
438
|
-
let
|
|
439
|
-
|
|
440
|
-
},
|
|
441
|
-
|
|
442
|
+
const s = (y = (l = e.target.closest(".mermaid-preview-content")) == null ? void 0 : l.parentElement) == null ? void 0 : y.getBoundingClientRect(), n = (M) => {
|
|
443
|
+
if (!B.value || !s) return;
|
|
444
|
+
let j = M.clientX - pe.value.x, D = M.clientY - pe.value.y;
|
|
445
|
+
W.value = { x: j, y: D };
|
|
446
|
+
}, c = () => {
|
|
447
|
+
B.value = !1, document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", c);
|
|
442
448
|
};
|
|
443
|
-
document.addEventListener("mousemove",
|
|
444
|
-
},
|
|
445
|
-
},
|
|
446
|
-
|
|
447
|
-
if (!
|
|
448
|
-
|
|
449
|
+
document.addEventListener("mousemove", n), document.addEventListener("mouseup", c);
|
|
450
|
+
}, Ae = (e) => {
|
|
451
|
+
}, t = () => {
|
|
452
|
+
h.isStreaming || ne(() => {
|
|
453
|
+
if (!b.value) return;
|
|
454
|
+
b.value.querySelectorAll(
|
|
449
455
|
".markdown-content img"
|
|
450
|
-
).forEach((
|
|
451
|
-
const
|
|
452
|
-
|
|
456
|
+
).forEach((a) => {
|
|
457
|
+
const s = a;
|
|
458
|
+
s.getAttribute("data-processed") !== "true" && (s.setAttribute("data-processed", "true"), s.style.cursor = "pointer", s.addEventListener("click", $));
|
|
453
459
|
});
|
|
454
460
|
});
|
|
455
461
|
};
|
|
456
|
-
return
|
|
457
|
-
|
|
458
|
-
}),
|
|
459
|
-
|
|
462
|
+
return Ve(() => {
|
|
463
|
+
i(), window.addEventListener("resize", i), J(), t(), g();
|
|
464
|
+
}), Ue(() => {
|
|
465
|
+
b.value && b.value.querySelectorAll(
|
|
460
466
|
".markdown-content img"
|
|
461
|
-
).forEach((
|
|
462
|
-
|
|
467
|
+
).forEach((a) => {
|
|
468
|
+
a.removeEventListener("click", $);
|
|
463
469
|
});
|
|
464
|
-
}), (e,
|
|
470
|
+
}), (e, a) => (u(), f("div", {
|
|
465
471
|
class: "markdown-message",
|
|
466
472
|
ref_key: "markdownContainer",
|
|
467
|
-
ref:
|
|
473
|
+
ref: b
|
|
468
474
|
}, [
|
|
469
|
-
|
|
475
|
+
o("div", {
|
|
470
476
|
ref_key: "markdownContent",
|
|
471
|
-
ref:
|
|
477
|
+
ref: p,
|
|
472
478
|
class: "markdown-content"
|
|
473
479
|
}, null, 512),
|
|
474
|
-
|
|
475
|
-
visible:
|
|
476
|
-
"onUpdate:visible":
|
|
480
|
+
k(Pe, {
|
|
481
|
+
visible: d.value,
|
|
482
|
+
"onUpdate:visible": a[2] || (a[2] = (s) => d.value = s),
|
|
477
483
|
width: _.value ? "95vw" : "80vw",
|
|
478
484
|
fullscreen: _.value,
|
|
479
485
|
class: "image-preview-dialog",
|
|
480
486
|
"close-on-click-modal": !1,
|
|
481
487
|
"append-to-body": ""
|
|
482
488
|
}, {
|
|
483
|
-
default:
|
|
484
|
-
|
|
489
|
+
default: R(() => [
|
|
490
|
+
o("div", {
|
|
485
491
|
class: "image-preview-container",
|
|
486
|
-
onClick:
|
|
492
|
+
onClick: a[1] || (a[1] = fe((s) => d.value = !1, ["self"]))
|
|
487
493
|
}, [
|
|
488
|
-
|
|
489
|
-
src:
|
|
490
|
-
alt:
|
|
494
|
+
o("img", {
|
|
495
|
+
src: S.value,
|
|
496
|
+
alt: C.value,
|
|
491
497
|
class: "preview-image",
|
|
492
|
-
style:
|
|
493
|
-
transform: `translate(${
|
|
498
|
+
style: Ie({
|
|
499
|
+
transform: `translate(${V.value.x}px, ${V.value.y}px) scale(${m.value})`
|
|
494
500
|
}),
|
|
495
|
-
onWheel:
|
|
496
|
-
onDblclick:
|
|
497
|
-
onMousedown:
|
|
498
|
-
onTouchstart:
|
|
499
|
-
onClick:
|
|
500
|
-
}, null, 44,
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
501
|
+
onWheel: fe(me, ["prevent"]),
|
|
502
|
+
onDblclick: de,
|
|
503
|
+
onMousedown: ee,
|
|
504
|
+
onTouchstart: fe(O, ["prevent"]),
|
|
505
|
+
onClick: Se
|
|
506
|
+
}, null, 44, xt),
|
|
507
|
+
o("div", Lt, [
|
|
508
|
+
o("div", zt, [
|
|
509
|
+
k(Y, {
|
|
504
510
|
size: "small",
|
|
505
|
-
onClick:
|
|
506
|
-
disabled:
|
|
511
|
+
onClick: ae,
|
|
512
|
+
disabled: m.value <= 0.5
|
|
507
513
|
}, {
|
|
508
|
-
default:
|
|
509
|
-
|
|
514
|
+
default: R(() => [
|
|
515
|
+
k(E(Ne))
|
|
510
516
|
]),
|
|
511
517
|
_: 1
|
|
512
518
|
}, 8, ["disabled"]),
|
|
513
|
-
|
|
519
|
+
k(Y, {
|
|
514
520
|
size: "small",
|
|
515
|
-
onClick:
|
|
521
|
+
onClick: de
|
|
516
522
|
}, {
|
|
517
|
-
default:
|
|
518
|
-
|
|
523
|
+
default: R(() => [
|
|
524
|
+
We(K(Math.round(m.value * 100)) + "% ", 1)
|
|
519
525
|
]),
|
|
520
526
|
_: 1
|
|
521
527
|
}),
|
|
522
|
-
|
|
528
|
+
k(Y, {
|
|
523
529
|
size: "small",
|
|
524
|
-
onClick:
|
|
525
|
-
disabled:
|
|
530
|
+
onClick: ue,
|
|
531
|
+
disabled: m.value >= 10
|
|
526
532
|
}, {
|
|
527
|
-
default:
|
|
528
|
-
|
|
533
|
+
default: R(() => [
|
|
534
|
+
k(E(Ye))
|
|
529
535
|
]),
|
|
530
536
|
_: 1
|
|
531
537
|
}, 8, ["disabled"])
|
|
532
538
|
]),
|
|
533
|
-
|
|
539
|
+
k(Y, {
|
|
534
540
|
size: "small",
|
|
535
|
-
onClick:
|
|
541
|
+
onClick: a[0] || (a[0] = (s) => d.value = !1),
|
|
536
542
|
type: "danger"
|
|
537
543
|
}, {
|
|
538
|
-
default:
|
|
539
|
-
|
|
544
|
+
default: R(() => [
|
|
545
|
+
k(E(He))
|
|
540
546
|
]),
|
|
541
547
|
_: 1
|
|
542
548
|
})
|
|
543
549
|
]),
|
|
544
|
-
_.value ? (
|
|
550
|
+
_.value ? (u(), f("div", Et, "双击重置 · 轻触关闭")) : z("", !0)
|
|
545
551
|
])
|
|
546
552
|
]),
|
|
547
553
|
_: 1
|
|
548
554
|
}, 8, ["visible", "width", "fullscreen"]),
|
|
549
|
-
|
|
550
|
-
visible:
|
|
551
|
-
"onUpdate:visible":
|
|
555
|
+
k(Pe, {
|
|
556
|
+
visible: A.value,
|
|
557
|
+
"onUpdate:visible": a[5] || (a[5] = (s) => A.value = s),
|
|
552
558
|
width: _.value ? "95vw" : "90vw",
|
|
553
559
|
fullscreen: _.value,
|
|
554
560
|
class: "mermaid-preview-dialog",
|
|
555
561
|
"close-on-click-modal": !1,
|
|
556
562
|
"append-to-body": ""
|
|
557
563
|
}, {
|
|
558
|
-
default:
|
|
559
|
-
|
|
564
|
+
default: R(() => [
|
|
565
|
+
o("div", {
|
|
560
566
|
class: "mermaid-preview-container",
|
|
561
|
-
onClick:
|
|
567
|
+
onClick: a[4] || (a[4] = fe((s) => A.value = !1, ["self"]))
|
|
562
568
|
}, [
|
|
563
|
-
|
|
569
|
+
o("div", {
|
|
564
570
|
class: "mermaid-preview-content",
|
|
565
|
-
innerHTML:
|
|
566
|
-
style:
|
|
567
|
-
transform: `translate(${
|
|
571
|
+
innerHTML: x.value,
|
|
572
|
+
style: Ie({
|
|
573
|
+
transform: `translate(${W.value.x}px, ${W.value.y}px) scale(${T.value})`
|
|
568
574
|
}),
|
|
569
|
-
onWheel:
|
|
570
|
-
onDblclick:
|
|
571
|
-
onMousedown:
|
|
572
|
-
onTouchstart:
|
|
573
|
-
}, null, 44,
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
575
|
+
onWheel: fe(Ce, ["prevent"]),
|
|
576
|
+
onDblclick: se,
|
|
577
|
+
onMousedown: Be,
|
|
578
|
+
onTouchstart: fe(Ae, ["prevent"])
|
|
579
|
+
}, null, 44, Tt),
|
|
580
|
+
o("div", Bt, [
|
|
581
|
+
o("div", Ut, [
|
|
582
|
+
k(Y, {
|
|
577
583
|
size: "small",
|
|
578
|
-
onClick:
|
|
579
|
-
disabled:
|
|
584
|
+
onClick: ke,
|
|
585
|
+
disabled: T.value <= 0.5
|
|
580
586
|
}, {
|
|
581
|
-
default:
|
|
582
|
-
|
|
587
|
+
default: R(() => [
|
|
588
|
+
k(E(Ne))
|
|
583
589
|
]),
|
|
584
590
|
_: 1
|
|
585
591
|
}, 8, ["disabled"]),
|
|
586
|
-
|
|
592
|
+
k(Y, {
|
|
587
593
|
size: "small",
|
|
588
|
-
onClick:
|
|
594
|
+
onClick: se
|
|
589
595
|
}, {
|
|
590
|
-
default:
|
|
591
|
-
|
|
596
|
+
default: R(() => [
|
|
597
|
+
We(K(Math.round(T.value * 100)) + "% ", 1)
|
|
592
598
|
]),
|
|
593
599
|
_: 1
|
|
594
600
|
}),
|
|
595
|
-
|
|
601
|
+
k(Y, {
|
|
596
602
|
size: "small",
|
|
597
|
-
onClick:
|
|
598
|
-
disabled:
|
|
603
|
+
onClick: q,
|
|
604
|
+
disabled: T.value >= 10
|
|
599
605
|
}, {
|
|
600
|
-
default:
|
|
601
|
-
|
|
606
|
+
default: R(() => [
|
|
607
|
+
k(E(Ye))
|
|
602
608
|
]),
|
|
603
609
|
_: 1
|
|
604
610
|
}, 8, ["disabled"])
|
|
605
611
|
]),
|
|
606
|
-
|
|
612
|
+
k(Y, {
|
|
607
613
|
size: "small",
|
|
608
|
-
onClick:
|
|
614
|
+
onClick: a[3] || (a[3] = (s) => A.value = !1),
|
|
609
615
|
type: "danger"
|
|
610
616
|
}, {
|
|
611
|
-
default:
|
|
612
|
-
|
|
617
|
+
default: R(() => [
|
|
618
|
+
k(E(He))
|
|
613
619
|
]),
|
|
614
620
|
_: 1
|
|
615
621
|
})
|
|
616
622
|
]),
|
|
617
|
-
_.value ? (
|
|
623
|
+
_.value ? (u(), f("div", Ht, "双击重置 · 轻触关闭")) : z("", !0)
|
|
618
624
|
])
|
|
619
625
|
]),
|
|
620
626
|
_: 1
|
|
621
627
|
}, 8, ["visible", "width", "fullscreen"])
|
|
622
628
|
], 512));
|
|
623
629
|
}
|
|
624
|
-
}),
|
|
630
|
+
}), Je = /* @__PURE__ */ _e(Dt, [["__scopeId", "data-v-6028683a"]]), Pt = {
|
|
625
631
|
key: 0,
|
|
626
632
|
class: "text-content"
|
|
627
|
-
},
|
|
633
|
+
}, Rt = {
|
|
628
634
|
key: 1,
|
|
629
635
|
class: "images-content"
|
|
630
|
-
},
|
|
636
|
+
}, Vt = ["onClick"], Ot = ["src", "alt", "onError"], Ft = {
|
|
631
637
|
key: 0,
|
|
632
638
|
class: "more-images"
|
|
633
|
-
},
|
|
639
|
+
}, Wt = {
|
|
634
640
|
key: 2,
|
|
635
|
-
class: "attachments-content"
|
|
636
|
-
}, At = { class: "file-icon-wrapper" }, Tt = { class: "attachment-info" }, Ht = { class: "attachment-name" }, Dt = { class: "attachment-size" }, Rt = {
|
|
637
|
-
key: 3,
|
|
638
641
|
class: "files-content"
|
|
639
|
-
},
|
|
640
|
-
key:
|
|
642
|
+
}, jt = ["onClick"], Yt = { class: "file-icon-wrapper-small" }, Nt = ["title"], Xt = { class: "file-name" }, qt = { class: "file-type" }, Zt = { class: "file-actions" }, Kt = {
|
|
643
|
+
key: 3,
|
|
641
644
|
class: "audio-content"
|
|
642
|
-
},
|
|
645
|
+
}, Jt = { class: "audio-player" }, Gt = { class: "audio-info" }, Qt = { class: "audio-progress" }, ea = { class: "progress-bar" }, ta = { class: "audio-time" }, aa = { class: "image-preview-container" }, sa = ["src"], na = {
|
|
643
646
|
key: 0,
|
|
644
647
|
class: "image-nav"
|
|
645
|
-
},
|
|
648
|
+
}, oa = { class: "image-counter" }, la = /* @__PURE__ */ be({
|
|
646
649
|
__name: "MultimodalMessage",
|
|
647
650
|
props: {
|
|
648
651
|
message: {},
|
|
649
652
|
isUser: { type: Boolean, default: !1 },
|
|
650
|
-
isStreaming: { type: Boolean, default: !1 }
|
|
653
|
+
isStreaming: { type: Boolean, default: !1 },
|
|
654
|
+
apiBaseUrl: { default: "" },
|
|
655
|
+
onDownload: {}
|
|
651
656
|
},
|
|
652
|
-
setup(
|
|
653
|
-
const
|
|
657
|
+
setup(r) {
|
|
658
|
+
const h = r, b = Q(() => {
|
|
654
659
|
try {
|
|
655
|
-
return
|
|
660
|
+
return h.message.metadata ? JSON.parse(h.message.metadata) : {};
|
|
656
661
|
} catch {
|
|
657
662
|
return {};
|
|
658
663
|
}
|
|
659
|
-
}),
|
|
660
|
-
() =>
|
|
661
|
-
),
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
664
|
+
}), p = Q(
|
|
665
|
+
() => b.value.imageUrls || []
|
|
666
|
+
), d = Q(() => b.value.audioUrl), S = w(/* @__PURE__ */ new Set()), C = Q(
|
|
667
|
+
() => b.value.fileUrls || []
|
|
668
|
+
), A = Q(() => C.value), x = Q(() => h.message.attachments && h.message.attachments.length > 0 ? h.message.attachments : b.value.attachments && Array.isArray(b.value.attachments) ? b.value.attachments : []), _ = Q(() => {
|
|
669
|
+
const i = [];
|
|
670
|
+
return x.value && x.value.length > 0 ? x.value.forEach((v) => {
|
|
671
|
+
var $, H;
|
|
672
|
+
(($ = v.type) == null ? void 0 : $.startsWith("image/")) || ((H = v.name) == null ? void 0 : H.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i)) || i.push({
|
|
673
|
+
url: v.url || v.download_url || v.file_url || "",
|
|
674
|
+
name: v.original_name || v.name || "Unknown File",
|
|
675
|
+
type: U(v.original_name || v.name || "Unknown File")
|
|
676
|
+
});
|
|
677
|
+
}) : A.value && A.value.length > 0 && A.value.forEach((v) => {
|
|
678
|
+
i.push({
|
|
679
|
+
url: v,
|
|
680
|
+
name: N(v),
|
|
681
|
+
type: U(v)
|
|
682
|
+
});
|
|
683
|
+
}), i;
|
|
684
|
+
}), m = w(!1), V = w(""), L = w(0), P = w(!1), T = w(!1), W = w(0), B = w(0), pe = Q(() => B.value > 0 ? W.value / B.value * 100 : 0);
|
|
685
|
+
let I = null;
|
|
686
|
+
const te = (i, v) => {
|
|
687
|
+
V.value = i, L.value = v, m.value = !0;
|
|
688
|
+
}, le = () => {
|
|
689
|
+
L.value > 0 && (L.value--, V.value = p.value[L.value]);
|
|
690
|
+
}, ye = () => {
|
|
691
|
+
L.value < p.value.length - 1 && (L.value++, V.value = p.value[L.value]);
|
|
692
|
+
}, xe = (i, v) => {
|
|
693
|
+
console.error("Image load failed:", v);
|
|
694
|
+
const g = i.target;
|
|
695
|
+
g.style.display = "none";
|
|
696
|
+
}, N = (i) => {
|
|
697
|
+
if (!i) return "Unknown File";
|
|
698
|
+
if (!i.includes("/"))
|
|
699
|
+
return decodeURIComponent(i) || "Unknown File";
|
|
674
700
|
try {
|
|
675
|
-
const
|
|
676
|
-
return decodeURIComponent(
|
|
701
|
+
const v = i.lastIndexOf("/"), g = v >= 0 ? i.substring(v + 1) : i;
|
|
702
|
+
return decodeURIComponent(g) || "Unknown File";
|
|
677
703
|
} catch {
|
|
678
704
|
return "Unknown File";
|
|
679
705
|
}
|
|
680
|
-
},
|
|
681
|
-
var
|
|
682
|
-
return ((
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
}, ie = (m) => {
|
|
706
|
+
}, U = (i) => {
|
|
707
|
+
var $;
|
|
708
|
+
return (($ = N(i).split(".").pop()) == null ? void 0 : $.toUpperCase()) || "FILE";
|
|
709
|
+
}, Me = (i, v) => {
|
|
710
|
+
re(i, v);
|
|
711
|
+
}, we = (i) => !i || i.startsWith("http://") || i.startsWith("https://") || i.startsWith("blob:") ? i : (h.apiBaseUrl ? h.apiBaseUrl.replace(/\/$/, "") : "") + (i.startsWith("/") ? i : "/" + i), re = async (i, v) => {
|
|
687
712
|
try {
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
713
|
+
const g = we(i);
|
|
714
|
+
if (console.log("正在下载文件...", g), h.onDownload && (S.value = /* @__PURE__ */ new Set([...S.value, i]), await h.onDownload(i, v) !== !1)) {
|
|
715
|
+
const q = new Set(S.value);
|
|
716
|
+
q.delete(i), S.value = q;
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
S.value = /* @__PURE__ */ new Set([...S.value, i]);
|
|
720
|
+
const $ = localStorage.getItem("token"), H = {};
|
|
721
|
+
if ($ && (H.Authorization = $.startsWith("Bearer ") ? $ : `Bearer ${$}`), typeof window < "u" && typeof window.plus < "u") {
|
|
722
|
+
const O = window.plus, q = O.downloader.createDownload(
|
|
723
|
+
g,
|
|
724
|
+
{
|
|
725
|
+
method: "GET",
|
|
726
|
+
filename: "_downloads/" + (v || N(i))
|
|
727
|
+
},
|
|
728
|
+
(ke, se) => {
|
|
729
|
+
const Ce = new Set(S.value);
|
|
730
|
+
Ce.delete(i), S.value = Ce, se === 200 || se === 206 ? O.runtime.openFile(ke.filename) : console.error("App 环境原生下载失败, status:", se);
|
|
731
|
+
}
|
|
732
|
+
);
|
|
733
|
+
H.Authorization && q.setRequestHeader(
|
|
734
|
+
"Authorization",
|
|
735
|
+
H.Authorization
|
|
736
|
+
), q.start();
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
const ue = await fetch(g, { headers: H });
|
|
740
|
+
if (!ue.ok)
|
|
741
|
+
throw new Error(`下载失败: ${ue.status}`);
|
|
742
|
+
let ae = v;
|
|
743
|
+
const de = ue.headers.get("Content-Disposition");
|
|
744
|
+
if (de) {
|
|
745
|
+
const O = de.match(/filename\*=UTF-8''(.+)/i);
|
|
746
|
+
if (O)
|
|
747
|
+
ae = decodeURIComponent(O[1]);
|
|
748
|
+
else {
|
|
749
|
+
const q = de.match(/filename="?([^";\n]+)"?/i);
|
|
750
|
+
q && (ae = q[1]);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
const Se = await ue.blob(), me = URL.createObjectURL(Se), ee = document.createElement("a");
|
|
754
|
+
ee.href = me, ee.download = ae || v || N(i), document.body.appendChild(ee), ee.click(), document.body.removeChild(ee), URL.revokeObjectURL(me);
|
|
755
|
+
} catch (g) {
|
|
756
|
+
console.error("下载文件失败:", g);
|
|
757
|
+
} finally {
|
|
758
|
+
const g = new Set(S.value);
|
|
759
|
+
g.delete(i), S.value = g;
|
|
692
760
|
}
|
|
693
|
-
},
|
|
694
|
-
if (
|
|
761
|
+
}, ie = async () => {
|
|
762
|
+
if (d.value)
|
|
695
763
|
try {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}),
|
|
699
|
-
|
|
700
|
-
}),
|
|
701
|
-
|
|
702
|
-
}),
|
|
703
|
-
console.error("Audio playback error:",
|
|
704
|
-
})),
|
|
705
|
-
} catch (
|
|
706
|
-
console.error("Audio playback failed:",
|
|
764
|
+
I || (I = new Audio(), I.src = we(d.value), I.addEventListener("loadedmetadata", () => {
|
|
765
|
+
B.value = (I == null ? void 0 : I.duration) || 0;
|
|
766
|
+
}), I.addEventListener("timeupdate", () => {
|
|
767
|
+
W.value = (I == null ? void 0 : I.currentTime) || 0;
|
|
768
|
+
}), I.addEventListener("ended", () => {
|
|
769
|
+
P.value = !1, W.value = 0;
|
|
770
|
+
}), I.addEventListener("error", (i) => {
|
|
771
|
+
console.error("Audio playback error:", i), T.value = !1, P.value = !1;
|
|
772
|
+
})), P.value ? (I.pause(), P.value = !1) : (T.value = !0, await I.play(), P.value = !0, T.value = !1);
|
|
773
|
+
} catch (i) {
|
|
774
|
+
console.error("Audio playback failed:", i), T.value = !1, P.value = !1;
|
|
707
775
|
}
|
|
708
|
-
},
|
|
709
|
-
const
|
|
710
|
-
return `${
|
|
711
|
-
},
|
|
712
|
-
|
|
713
|
-
const h = 1024, y = ["B", "KB", "MB", "GB"], B = Math.floor(Math.log(m) / Math.log(h));
|
|
714
|
-
return (m / Math.pow(h, B)).toFixed(2) + y[B];
|
|
715
|
-
}, we = (m) => {
|
|
716
|
-
var y;
|
|
717
|
-
return ((y = m.split(".").pop()) == null ? void 0 : y.toUpperCase()) || "FILE";
|
|
718
|
-
}, K = (m) => {
|
|
719
|
-
x.value && (m.key === "ArrowLeft" ? te() : m.key === "ArrowRight" ? se() : m.key === "Escape" && (x.value = !1));
|
|
776
|
+
}, J = (i) => {
|
|
777
|
+
const v = Math.floor(i / 60), g = Math.floor(i % 60);
|
|
778
|
+
return `${v}:${g.toString().padStart(2, "0")}`;
|
|
779
|
+
}, ce = (i) => {
|
|
780
|
+
m.value && (i.key === "ArrowLeft" ? le() : i.key === "ArrowRight" ? ye() : i.key === "Escape" && (m.value = !1));
|
|
720
781
|
};
|
|
721
|
-
return
|
|
722
|
-
|
|
723
|
-
}),
|
|
724
|
-
|
|
725
|
-
}), (
|
|
726
|
-
class:
|
|
782
|
+
return ge(m, (i) => {
|
|
783
|
+
i ? document.addEventListener("keydown", ce) : document.removeEventListener("keydown", ce);
|
|
784
|
+
}), Ue(() => {
|
|
785
|
+
I && (I.pause(), I = null), document.removeEventListener("keydown", ce);
|
|
786
|
+
}), (i, v) => (u(), f("div", {
|
|
787
|
+
class: he(["multimodal-message", { "is-user": r.isUser, "is-assistant": !r.isUser }])
|
|
727
788
|
}, [
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
content:
|
|
731
|
-
"is-streaming":
|
|
789
|
+
r.message.content ? (u(), f("div", Pt, [
|
|
790
|
+
k(Je, {
|
|
791
|
+
content: r.message.content,
|
|
792
|
+
"is-streaming": r.isStreaming
|
|
732
793
|
}, null, 8, ["content", "is-streaming"])
|
|
733
|
-
])) :
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
class:
|
|
794
|
+
])) : z("", !0),
|
|
795
|
+
p.value && p.value.length > 0 ? (u(), f("div", Rt, [
|
|
796
|
+
o("div", {
|
|
797
|
+
class: he(["images-grid", `grid-${Math.min(p.value.length, 4)}`])
|
|
737
798
|
}, [
|
|
738
|
-
(
|
|
739
|
-
key:
|
|
799
|
+
(u(!0), f(Ee, null, Te(p.value.slice(0, 4), (g, $) => (u(), f("div", {
|
|
800
|
+
key: $,
|
|
740
801
|
class: "image-item",
|
|
741
|
-
onClick: (
|
|
802
|
+
onClick: (H) => te(g, $)
|
|
742
803
|
}, [
|
|
743
|
-
|
|
744
|
-
src:
|
|
745
|
-
alt: `图片 ${
|
|
746
|
-
onError: (
|
|
804
|
+
o("img", {
|
|
805
|
+
src: g,
|
|
806
|
+
alt: `图片 ${$ + 1}`,
|
|
807
|
+
onError: (H) => xe(H, g),
|
|
747
808
|
loading: "lazy"
|
|
748
|
-
}, null, 40,
|
|
749
|
-
|
|
750
|
-
], 8,
|
|
809
|
+
}, null, 40, Ot),
|
|
810
|
+
$ === 3 && p.value.length > 4 ? (u(), f("div", Ft, " +" + K(p.value.length - 4), 1)) : z("", !0)
|
|
811
|
+
], 8, Vt))), 128))
|
|
751
812
|
], 2)
|
|
752
|
-
])) :
|
|
753
|
-
|
|
754
|
-
(
|
|
755
|
-
key:
|
|
756
|
-
class: "attachment-item"
|
|
757
|
-
}, [
|
|
758
|
-
a("div", At, [
|
|
759
|
-
f(I(Be), { class: "file-icon" })
|
|
760
|
-
]),
|
|
761
|
-
a("div", Tt, [
|
|
762
|
-
a("span", Ht, F(y.name), 1),
|
|
763
|
-
a("span", Dt, F(we(y.name)) + " " + F(ye(y.size)), 1)
|
|
764
|
-
])
|
|
765
|
-
]))), 128))
|
|
766
|
-
])) : D("", !0),
|
|
767
|
-
z.value && z.value.length > 0 ? (o(), u("div", Rt, [
|
|
768
|
-
(o(!0), u(ue, null, me(z.value, (y, B) => (o(), u("div", {
|
|
769
|
-
key: B,
|
|
813
|
+
])) : z("", !0),
|
|
814
|
+
_.value && _.value.length > 0 ? (u(), f("div", Wt, [
|
|
815
|
+
(u(!0), f(Ee, null, Te(_.value, (g, $) => (u(), f("div", {
|
|
816
|
+
key: $,
|
|
770
817
|
class: "file-item",
|
|
771
|
-
onClick: (
|
|
818
|
+
onClick: (H) => Me(g.url, g.name)
|
|
772
819
|
}, [
|
|
773
|
-
|
|
774
|
-
|
|
820
|
+
o("div", Yt, [
|
|
821
|
+
k(E(Mt), { class: "file-icon" })
|
|
775
822
|
]),
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
823
|
+
o("div", {
|
|
824
|
+
class: "file-info",
|
|
825
|
+
title: g.name
|
|
826
|
+
}, [
|
|
827
|
+
o("span", Xt, K(g.name), 1),
|
|
828
|
+
o("span", qt, K(g.type), 1)
|
|
829
|
+
], 8, Nt),
|
|
830
|
+
o("div", Zt, [
|
|
831
|
+
k(Y, {
|
|
782
832
|
size: "small",
|
|
783
833
|
type: "text",
|
|
784
|
-
|
|
834
|
+
disabled: S.value.has(g.url),
|
|
835
|
+
onClick: fe((H) => re(g.url, g.name), ["stop"])
|
|
785
836
|
}, {
|
|
786
|
-
default:
|
|
787
|
-
|
|
837
|
+
default: R(() => [
|
|
838
|
+
k(E(Xe), {
|
|
839
|
+
class: he({ "icon-spin": S.value.has(g.url) })
|
|
840
|
+
}, null, 8, ["class"])
|
|
788
841
|
]),
|
|
789
|
-
_:
|
|
790
|
-
},
|
|
842
|
+
_: 2
|
|
843
|
+
}, 1032, ["disabled", "onClick"])
|
|
791
844
|
])
|
|
792
|
-
], 8,
|
|
793
|
-
])) :
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
onClick:
|
|
798
|
-
loading:
|
|
845
|
+
], 8, jt))), 128))
|
|
846
|
+
])) : z("", !0),
|
|
847
|
+
d.value ? (u(), f("div", Kt, [
|
|
848
|
+
o("div", Jt, [
|
|
849
|
+
k(Y, {
|
|
850
|
+
onClick: ie,
|
|
851
|
+
loading: T.value,
|
|
799
852
|
circle: "",
|
|
800
853
|
size: "small",
|
|
801
854
|
class: "play-btn"
|
|
802
855
|
}, {
|
|
803
|
-
default:
|
|
804
|
-
(
|
|
856
|
+
default: R(() => [
|
|
857
|
+
(u(), oe(Ke(P.value ? E(Ct) : E(St))))
|
|
805
858
|
]),
|
|
806
859
|
_: 1
|
|
807
860
|
}, 8, ["loading"]),
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
861
|
+
o("div", Gt, [
|
|
862
|
+
o("div", Qt, [
|
|
863
|
+
o("div", ea, [
|
|
864
|
+
o("div", {
|
|
812
865
|
class: "progress-fill",
|
|
813
|
-
style:
|
|
866
|
+
style: Ie({ width: pe.value + "%" })
|
|
814
867
|
}, null, 4)
|
|
815
868
|
])
|
|
816
869
|
]),
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
870
|
+
o("div", ta, [
|
|
871
|
+
o("span", null, K(J(W.value)), 1),
|
|
872
|
+
v[4] || (v[4] = o("span", null, "/", -1)),
|
|
873
|
+
o("span", null, K(J(B.value)), 1)
|
|
821
874
|
])
|
|
822
875
|
]),
|
|
823
|
-
|
|
824
|
-
onClick:
|
|
876
|
+
k(Y, {
|
|
877
|
+
onClick: v[0] || (v[0] = (g) => re(d.value)),
|
|
825
878
|
size: "small",
|
|
826
879
|
type: "text",
|
|
827
880
|
class: "download-btn"
|
|
828
881
|
}, {
|
|
829
|
-
default:
|
|
830
|
-
|
|
882
|
+
default: R(() => [
|
|
883
|
+
k(E(Xe))
|
|
831
884
|
]),
|
|
832
885
|
_: 1
|
|
833
886
|
})
|
|
834
887
|
])
|
|
835
|
-
])) :
|
|
836
|
-
|
|
837
|
-
visible:
|
|
838
|
-
"onUpdate:visible":
|
|
888
|
+
])) : z("", !0),
|
|
889
|
+
k(Pe, {
|
|
890
|
+
visible: m.value,
|
|
891
|
+
"onUpdate:visible": v[3] || (v[3] = (g) => m.value = g),
|
|
839
892
|
width: "90%",
|
|
840
893
|
"show-close": !1,
|
|
841
894
|
"append-to-body": "",
|
|
842
895
|
class: "image-preview-dialog-wrapper"
|
|
843
896
|
}, {
|
|
844
|
-
default:
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
src:
|
|
897
|
+
default: R(() => [
|
|
898
|
+
o("div", aa, [
|
|
899
|
+
o("img", {
|
|
900
|
+
src: V.value,
|
|
848
901
|
alt: "预览图片",
|
|
849
902
|
class: "preview-image",
|
|
850
|
-
onClick:
|
|
851
|
-
}, null, 8,
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
onClick:
|
|
855
|
-
disabled:
|
|
903
|
+
onClick: v[1] || (v[1] = (g) => m.value = !1)
|
|
904
|
+
}, null, 8, sa),
|
|
905
|
+
p.value && p.value.length > 1 ? (u(), f("div", na, [
|
|
906
|
+
k(Y, {
|
|
907
|
+
onClick: le,
|
|
908
|
+
disabled: L.value === 0,
|
|
856
909
|
circle: "",
|
|
857
910
|
class: "nav-btn"
|
|
858
911
|
}, {
|
|
859
|
-
default:
|
|
860
|
-
|
|
912
|
+
default: R(() => [
|
|
913
|
+
k(E(At))
|
|
861
914
|
]),
|
|
862
915
|
_: 1
|
|
863
916
|
}, 8, ["disabled"]),
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
onClick:
|
|
867
|
-
disabled:
|
|
917
|
+
o("span", oa, K(L.value + 1) + " / " + K(p.value.length), 1),
|
|
918
|
+
k(Y, {
|
|
919
|
+
onClick: ye,
|
|
920
|
+
disabled: L.value === p.value.length - 1,
|
|
868
921
|
circle: "",
|
|
869
922
|
class: "nav-btn"
|
|
870
923
|
}, {
|
|
871
|
-
default:
|
|
872
|
-
|
|
924
|
+
default: R(() => [
|
|
925
|
+
k(E($t))
|
|
873
926
|
]),
|
|
874
927
|
_: 1
|
|
875
928
|
}, 8, ["disabled"])
|
|
876
|
-
])) :
|
|
877
|
-
|
|
878
|
-
onClick:
|
|
929
|
+
])) : z("", !0),
|
|
930
|
+
k(Y, {
|
|
931
|
+
onClick: v[2] || (v[2] = (g) => m.value = !1),
|
|
879
932
|
class: "close-btn",
|
|
880
933
|
circle: ""
|
|
881
934
|
}, {
|
|
882
|
-
default:
|
|
883
|
-
|
|
935
|
+
default: R(() => [
|
|
936
|
+
k(E(He))
|
|
884
937
|
]),
|
|
885
938
|
_: 1
|
|
886
939
|
})
|
|
@@ -890,104 +943,115 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
890
943
|
}, 8, ["visible"])
|
|
891
944
|
], 2));
|
|
892
945
|
}
|
|
893
|
-
}),
|
|
946
|
+
}), Re = /* @__PURE__ */ _e(la, [["__scopeId", "data-v-3f270644"]]), ra = {
|
|
894
947
|
key: 0,
|
|
895
948
|
class: "agent-steps"
|
|
896
|
-
},
|
|
949
|
+
}, ia = { class: "steps-indicator" }, ca = {
|
|
897
950
|
key: 0,
|
|
898
951
|
class: "icon-running"
|
|
899
|
-
},
|
|
952
|
+
}, ua = {
|
|
900
953
|
key: 1,
|
|
901
954
|
class: "icon-completed"
|
|
902
|
-
},
|
|
955
|
+
}, da = { class: "steps-summary" }, ma = { class: "icon-chevron" }, va = { class: "steps-list" }, fa = { class: "step-icon" }, ga = {
|
|
903
956
|
key: 3,
|
|
904
957
|
class: "icon-dot"
|
|
905
|
-
},
|
|
958
|
+
}, ha = { class: "step-name" }, pa = /* @__PURE__ */ be({
|
|
906
959
|
__name: "AgentSteps",
|
|
907
960
|
props: {
|
|
908
961
|
steps: {}
|
|
909
962
|
},
|
|
910
963
|
emits: ["resize"],
|
|
911
|
-
setup(
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
964
|
+
setup(r, { emit: h }) {
|
|
965
|
+
const b = r, p = w(!0), d = h, S = () => {
|
|
966
|
+
p.value = !p.value, setTimeout(() => {
|
|
967
|
+
d("resize");
|
|
915
968
|
}, 300);
|
|
916
|
-
},
|
|
917
|
-
() =>
|
|
918
|
-
),
|
|
919
|
-
const
|
|
920
|
-
if (
|
|
921
|
-
return `正在${
|
|
922
|
-
const _ =
|
|
923
|
-
(
|
|
969
|
+
}, C = Q(
|
|
970
|
+
() => b.steps.some((x) => x.status === "running")
|
|
971
|
+
), A = Q(() => {
|
|
972
|
+
const x = b.steps.find((m) => m.status === "running");
|
|
973
|
+
if (x)
|
|
974
|
+
return `正在${x.displayName}...`;
|
|
975
|
+
const _ = b.steps.filter(
|
|
976
|
+
(m) => m.status === "completed"
|
|
924
977
|
).length;
|
|
925
|
-
return _ ===
|
|
978
|
+
return _ === b.steps.length ? "处理完成" : `已完成 ${_}/${b.steps.length} 个步骤`;
|
|
926
979
|
});
|
|
927
|
-
return (
|
|
928
|
-
|
|
980
|
+
return (x, _) => r.steps.length > 0 ? (u(), f("div", ra, [
|
|
981
|
+
o("div", {
|
|
929
982
|
class: "steps-header",
|
|
930
|
-
onClick:
|
|
983
|
+
onClick: S
|
|
931
984
|
}, [
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
])) : (
|
|
936
|
-
|
|
985
|
+
o("div", ia, [
|
|
986
|
+
C.value ? (u(), f("div", ca, [
|
|
987
|
+
k(E(qe))
|
|
988
|
+
])) : (u(), f("div", ua, [
|
|
989
|
+
k(E(Ze))
|
|
937
990
|
]))
|
|
938
991
|
]),
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
(
|
|
992
|
+
o("span", da, K(A.value), 1),
|
|
993
|
+
o("div", ma, [
|
|
994
|
+
(u(), oe(Ke(p.value ? E(It) : E(_t))))
|
|
942
995
|
])
|
|
943
996
|
]),
|
|
944
|
-
|
|
945
|
-
(
|
|
946
|
-
key:
|
|
947
|
-
class:
|
|
948
|
-
"is-running":
|
|
949
|
-
"is-completed":
|
|
950
|
-
"is-error":
|
|
997
|
+
nt(o("div", va, [
|
|
998
|
+
(u(!0), f(Ee, null, Te(r.steps, (m) => (u(), f("div", {
|
|
999
|
+
key: m.name,
|
|
1000
|
+
class: he(["step-item", {
|
|
1001
|
+
"is-running": m.status === "running",
|
|
1002
|
+
"is-completed": m.status === "completed",
|
|
1003
|
+
"is-error": m.status === "error"
|
|
951
1004
|
}])
|
|
952
1005
|
}, [
|
|
953
|
-
|
|
954
|
-
|
|
1006
|
+
o("div", fa, [
|
|
1007
|
+
m.status === "running" ? (u(), oe(E(qe), {
|
|
955
1008
|
key: 0,
|
|
956
1009
|
class: "icon-spin"
|
|
957
|
-
})) :
|
|
1010
|
+
})) : m.status === "completed" ? (u(), oe(E(Ze), { key: 1 })) : m.status === "error" ? (u(), oe(E(He), { key: 2 })) : (u(), f("div", ga))
|
|
958
1011
|
]),
|
|
959
|
-
|
|
1012
|
+
o("span", ha, K(m.displayName), 1)
|
|
960
1013
|
], 2))), 128))
|
|
961
1014
|
], 512), [
|
|
962
|
-
[
|
|
1015
|
+
[ot, p.value]
|
|
963
1016
|
])
|
|
964
|
-
])) :
|
|
1017
|
+
])) : z("", !0);
|
|
965
1018
|
}
|
|
966
|
-
}),
|
|
1019
|
+
}), Ge = /* @__PURE__ */ _e(pa, [["__scopeId", "data-v-181f5844"]]), ya = { class: "chat-message-list-root" }, wa = {
|
|
967
1020
|
key: 0,
|
|
968
1021
|
class: "bg-grid"
|
|
969
|
-
},
|
|
1022
|
+
}, ka = {
|
|
970
1023
|
key: 0,
|
|
971
1024
|
class: "welcome-screen"
|
|
972
|
-
},
|
|
1025
|
+
}, ba = { class: "welcome-content" }, Ma = { class: "welcome-logo" }, Sa = ["src"], Ca = {
|
|
973
1026
|
key: 1,
|
|
974
1027
|
class: "default-logo"
|
|
975
|
-
},
|
|
1028
|
+
}, Aa = { class: "welcome-title" }, $a = {
|
|
976
1029
|
key: 1,
|
|
977
1030
|
class: "messages-container"
|
|
978
|
-
},
|
|
1031
|
+
}, Ia = {
|
|
979
1032
|
key: 0,
|
|
980
|
-
class: "message-
|
|
981
|
-
},
|
|
1033
|
+
class: "user-message-wrapper"
|
|
1034
|
+
}, _a = { class: "message-bubble user-bubble" }, xa = {
|
|
1035
|
+
key: 0,
|
|
1036
|
+
class: "message-actions user-actions"
|
|
1037
|
+
}, La = ["onClick"], za = {
|
|
982
1038
|
key: 1,
|
|
983
1039
|
class: "message-content assistant-content"
|
|
984
|
-
},
|
|
1040
|
+
}, Ea = { class: "message-bubble assistant-bubble" }, Ta = {
|
|
1041
|
+
key: 1,
|
|
1042
|
+
class: "a2ui-card-skeleton",
|
|
1043
|
+
"aria-hidden": "true"
|
|
1044
|
+
}, Ba = {
|
|
985
1045
|
key: 1,
|
|
986
1046
|
class: "message-actions"
|
|
987
|
-
},
|
|
1047
|
+
}, Ua = ["onClick"], Ha = {
|
|
988
1048
|
key: 0,
|
|
989
1049
|
class: "message-row message-assistant"
|
|
990
|
-
},
|
|
1050
|
+
}, Da = {
|
|
1051
|
+
key: 0,
|
|
1052
|
+
class: "loading-ring",
|
|
1053
|
+
viewBox: "0 0 36 36"
|
|
1054
|
+
}, Pa = /* @__PURE__ */ be({
|
|
991
1055
|
__name: "ChatMessageList",
|
|
992
1056
|
props: {
|
|
993
1057
|
messages: { default: () => [] },
|
|
@@ -1001,173 +1065,441 @@ const it = { class: "cm-dialog__body" }, rt = /* @__PURE__ */ Q({
|
|
|
1001
1065
|
autoScroll: { type: Boolean, default: !0 },
|
|
1002
1066
|
contentPaddingTop: { default: "80px" },
|
|
1003
1067
|
contentPaddingBottom: { default: "140px" },
|
|
1004
|
-
showBackground: { type: Boolean, default: !0 }
|
|
1068
|
+
showBackground: { type: Boolean, default: !0 },
|
|
1069
|
+
apiBaseUrl: { default: "" },
|
|
1070
|
+
enableA2UI: { type: Boolean, default: !0 },
|
|
1071
|
+
autoProvideA2UI: { type: Boolean, default: !0 },
|
|
1072
|
+
hideA2UIRawContent: { type: Boolean, default: !0 },
|
|
1073
|
+
showA2UISkeleton: { type: Boolean, default: !0 },
|
|
1074
|
+
a2uiActionHandler: {}
|
|
1005
1075
|
},
|
|
1006
|
-
emits: [
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1076
|
+
emits: [
|
|
1077
|
+
"copy",
|
|
1078
|
+
"scroll",
|
|
1079
|
+
"scroll-bottom",
|
|
1080
|
+
"a2ui-action",
|
|
1081
|
+
"a2ui-error"
|
|
1082
|
+
],
|
|
1083
|
+
setup(r, { expose: h, emit: b }) {
|
|
1084
|
+
const p = /* @__PURE__ */ new WeakSet(), d = r, S = b, C = w(null), A = w(!1), x = w(!0), _ = w({}), m = w({});
|
|
1085
|
+
(() => {
|
|
1086
|
+
var e;
|
|
1087
|
+
if (!d.autoProvideA2UI) return;
|
|
1088
|
+
try {
|
|
1089
|
+
dt();
|
|
1090
|
+
return;
|
|
1091
|
+
} catch {
|
|
1092
|
+
}
|
|
1093
|
+
const t = (e = it()) == null ? void 0 : e.appContext.app;
|
|
1094
|
+
!t || p.has(t) || (mt({
|
|
1095
|
+
app: t,
|
|
1096
|
+
catalog: ft,
|
|
1097
|
+
theme: vt
|
|
1098
|
+
}), p.add(t));
|
|
1099
|
+
})();
|
|
1100
|
+
const L = ct(), P = () => {
|
|
1101
|
+
if (!C.value) return !0;
|
|
1102
|
+
const { scrollTop: t, scrollHeight: e, clientHeight: a } = C.value;
|
|
1103
|
+
return e - t - a < 50;
|
|
1104
|
+
}, T = () => {
|
|
1105
|
+
x.value = P();
|
|
1106
|
+
}, W = (t) => {
|
|
1107
|
+
var a, s;
|
|
1108
|
+
return !t || typeof t != "object" || t.version !== "v0.9" || [
|
|
1109
|
+
t.createSurface,
|
|
1110
|
+
t.updateComponents,
|
|
1111
|
+
t.updateDataModel,
|
|
1112
|
+
t.deleteSurface
|
|
1113
|
+
].filter(Boolean).length !== 1 ? !1 : t.createSurface ? pe(t.createSurface) : t.updateComponents ? xe(t.updateComponents) : t.updateDataModel ? typeof ((a = B(t.updateDataModel)) == null ? void 0 : a.surfaceId) == "string" : t.deleteSurface ? typeof ((s = B(t.deleteSurface)) == null ? void 0 : s.surfaceId) == "string" : !1;
|
|
1114
|
+
}, B = (t) => t && typeof t == "object" && !Array.isArray(t) ? t : null, pe = (t) => {
|
|
1115
|
+
const e = B(t);
|
|
1116
|
+
if (!e) return !1;
|
|
1117
|
+
const a = Object.keys(e);
|
|
1118
|
+
return typeof e.surfaceId == "string" && typeof e.catalogId == "string" && a.every((s) => s === "surfaceId" || s === "catalogId");
|
|
1119
|
+
}, I = (t) => Array.isArray(t) ? t.every((e) => {
|
|
1120
|
+
const a = B(e);
|
|
1121
|
+
return !!(a && typeof a.label == "string" && typeof a.value == "string");
|
|
1122
|
+
}) : !1, te = (t) => Array.isArray(t) && t.every((e) => typeof e == "string"), le = (t) => Array.isArray(t) ? t.every((e) => {
|
|
1123
|
+
const a = B(e);
|
|
1124
|
+
return !!(a && typeof a.label == "string" && typeof a.value == "string");
|
|
1125
|
+
}) : !1, ye = (t) => {
|
|
1126
|
+
const e = B(t);
|
|
1127
|
+
return !(!e || typeof e.id != "string" || typeof e.component != "string" || Object.prototype.hasOwnProperty.call(e, "props") || Object.prototype.hasOwnProperty.call(e, "componentType") || Object.prototype.hasOwnProperty.call(e, "component_type") || e.facts !== void 0 && !I(e.facts) || e.tags !== void 0 && !te(e.tags) || ["policyOptions", "audienceOptions", "detailOptions"].some(
|
|
1128
|
+
(s) => e[s] !== void 0 && !le(e[s])
|
|
1129
|
+
));
|
|
1130
|
+
}, xe = (t) => {
|
|
1131
|
+
const e = B(t);
|
|
1132
|
+
return !e || typeof e.surfaceId != "string" || !Array.isArray(e.components) || e.components.length === 0 ? !1 : e.components.every(ye);
|
|
1133
|
+
}, N = (t) => {
|
|
1134
|
+
const e = t.trim();
|
|
1135
|
+
if (!e) return null;
|
|
1136
|
+
const a = e.match(/^```(?:json|a2ui|agui|ag-ui)?\s*([\s\S]*?)\s*```$/i), s = a ? a[1].trim() : e;
|
|
1137
|
+
if (!s.startsWith("{") && !s.startsWith("[")) return null;
|
|
1138
|
+
try {
|
|
1139
|
+
return JSON.parse(s);
|
|
1140
|
+
} catch {
|
|
1141
|
+
return null;
|
|
1142
|
+
}
|
|
1143
|
+
}, U = (t) => {
|
|
1144
|
+
if (!t) return [];
|
|
1145
|
+
if (typeof t == "string") {
|
|
1146
|
+
const s = N(t);
|
|
1147
|
+
return s ? U(s) : Array.from(
|
|
1148
|
+
t.matchAll(/```(?:agui|ag-ui|a2ui|json)\s*\n([\s\S]*?)\n```/gi)
|
|
1149
|
+
).flatMap((n) => {
|
|
1150
|
+
const c = N(n[1]);
|
|
1151
|
+
return c ? U(c) : [];
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
if (Array.isArray(t)) {
|
|
1155
|
+
const s = t.map((n) => B(n)).filter((n) => !!n);
|
|
1156
|
+
return s.length === t.length && s.every(W) ? s : [];
|
|
1157
|
+
}
|
|
1158
|
+
if (typeof t != "object") return [];
|
|
1159
|
+
const e = t;
|
|
1160
|
+
if (W(e)) return [e];
|
|
1161
|
+
const a = Me(e);
|
|
1162
|
+
return a.length > 0 ? a : [];
|
|
1163
|
+
}, Me = (t) => {
|
|
1164
|
+
if (!t || typeof t != "object") return [];
|
|
1165
|
+
if (Array.isArray(t)) {
|
|
1166
|
+
const a = t.map((s) => B(s)).filter((s) => !!s);
|
|
1167
|
+
return a.length !== t.length || !a.every(we) ? [] : a.flatMap(re);
|
|
1168
|
+
}
|
|
1169
|
+
const e = t;
|
|
1170
|
+
return e.protocol === "ag-ui" ? Me(e.aguiEvents || e.agui_events) : we(e) ? re(e) : [];
|
|
1171
|
+
}, we = (t) => {
|
|
1172
|
+
const e = String(t.type || "").toUpperCase();
|
|
1173
|
+
return e ? e === "STATE_SNAPSHOT" ? ie(t.state).length > 0 : e === "STATE_DELTA" ? ie(t.delta).length > 0 : !0 : !1;
|
|
1174
|
+
}, re = (t) => {
|
|
1175
|
+
const e = String(t.type || "").toUpperCase();
|
|
1176
|
+
return e === "STATE_SNAPSHOT" ? ie(t.state) : e === "STATE_DELTA" ? ie(t.delta) : [];
|
|
1177
|
+
}, ie = (t) => {
|
|
1178
|
+
const e = B(t);
|
|
1179
|
+
return e ? U(e.a2uiMessages) : [];
|
|
1180
|
+
}, J = (t) => [
|
|
1181
|
+
...U(t.a2ui),
|
|
1182
|
+
...U(t.a2uiMessage),
|
|
1183
|
+
...U(t.a2uiMessages),
|
|
1184
|
+
...U(t.a2ui_message),
|
|
1185
|
+
...U(t.a2ui_messages),
|
|
1186
|
+
...U(t.agui),
|
|
1187
|
+
...U(t.aguiEvents),
|
|
1188
|
+
...U(t.agui_events),
|
|
1189
|
+
...U(t.metadata),
|
|
1190
|
+
...U(t.content)
|
|
1191
|
+
], ce = (t) => {
|
|
1192
|
+
var e, a, s, n;
|
|
1193
|
+
return ((e = t == null ? void 0 : t.createSurface) == null ? void 0 : e.surfaceId) || ((a = t == null ? void 0 : t.updateComponents) == null ? void 0 : a.surfaceId) || ((s = t == null ? void 0 : t.updateDataModel) == null ? void 0 : s.surfaceId) || ((n = t == null ? void 0 : t.deleteSurface) == null ? void 0 : n.surfaceId) || null;
|
|
1194
|
+
}, i = (t, e) => String(t.id || `index-${e}`), v = (t, e, a = !1) => {
|
|
1195
|
+
const s = { ...m.value }, n = { ..._.value }, c = a ? new Set(n[t] || []) : /* @__PURE__ */ new Set();
|
|
1196
|
+
for (const l of e) {
|
|
1197
|
+
const y = ce(l);
|
|
1198
|
+
y && (s[y] = t, c.add(y));
|
|
1199
|
+
}
|
|
1200
|
+
n[t] = Array.from(c), m.value = s, _.value = n;
|
|
1201
|
+
}, g = () => {
|
|
1202
|
+
if (L.clearSurfaces(), _.value = {}, m.value = {}, !d.enableA2UI) return;
|
|
1203
|
+
const t = [];
|
|
1204
|
+
if (d.messages.forEach((e, a) => {
|
|
1205
|
+
const s = J(e);
|
|
1206
|
+
if (s.length === 0) return;
|
|
1207
|
+
const n = i(e, a);
|
|
1208
|
+
v(n, s), t.push(...s);
|
|
1209
|
+
}), t.length !== 0)
|
|
1210
|
+
try {
|
|
1211
|
+
L.processMessages(t);
|
|
1212
|
+
} catch (e) {
|
|
1213
|
+
console.warn("[rt-chat-messages] A2UI payload render failed", e), S("a2ui-error", e);
|
|
1214
|
+
}
|
|
1215
|
+
}, $ = (t, e) => {
|
|
1216
|
+
if (!d.enableA2UI) return [];
|
|
1217
|
+
const a = i(t, e);
|
|
1218
|
+
return (_.value[a] || []).filter(
|
|
1219
|
+
(s) => m.value[s] === a
|
|
1220
|
+
);
|
|
1221
|
+
}, H = (t) => {
|
|
1222
|
+
const e = typeof t.content == "string" ? t.content.trimStart() : "";
|
|
1223
|
+
if (!e || J(t).length > 0) return !1;
|
|
1224
|
+
const a = e.match(/^```([^\s\n`]*)?/);
|
|
1225
|
+
if (!a) return !1;
|
|
1226
|
+
const s = (a[1] || "").toLowerCase();
|
|
1227
|
+
return s ? ["a", "ag", "agu", "agui", "ag-", "ag-u", "ag-ui", "a2", "a2u", "a2ui"].includes(s) : !1;
|
|
1228
|
+
}, ue = (t, e) => !!(d.enableA2UI && d.showA2UISkeleton && d.isStreaming && e === d.messages.length - 1 && $(t, e).length === 0 && H(t)), ae = (t) => !d.hideA2UIRawContent || t.attachments && t.attachments.length > 0 ? !0 : H(t) || !t.content ? !1 : J(t).length === 0, de = async (t) => {
|
|
1229
|
+
var a;
|
|
1230
|
+
const e = (a = t == null ? void 0 : t.message) == null ? void 0 : a.action;
|
|
1231
|
+
S("a2ui-action", e, t);
|
|
1232
|
+
try {
|
|
1233
|
+
const s = d.a2uiActionHandler ? await d.a2uiActionHandler(t) : [], n = U(s);
|
|
1234
|
+
if (n.length > 0) {
|
|
1235
|
+
const c = m.value[e == null ? void 0 : e.surfaceId];
|
|
1236
|
+
c && v(c, n, !0), L.processMessages(n), d.autoScroll && !A.value && (await ne(), O("smooth"));
|
|
1237
|
+
}
|
|
1238
|
+
t.resolve(n);
|
|
1239
|
+
} catch (s) {
|
|
1240
|
+
S("a2ui-error", s), t.reject(s instanceof Error ? s : new Error(String(s)));
|
|
1241
|
+
}
|
|
1019
1242
|
};
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1243
|
+
let Se = 0, me = !1;
|
|
1244
|
+
const ee = () => {
|
|
1245
|
+
P() || (x.value = !1, A.value = !0);
|
|
1246
|
+
}, O = async (t = "smooth", e = !1) => {
|
|
1247
|
+
if (await ne(), C.value) {
|
|
1248
|
+
if (e && (A.value = !1), A.value) return;
|
|
1249
|
+
x.value = !0, me = !0, C.value.scrollTo({
|
|
1250
|
+
top: C.value.scrollHeight,
|
|
1251
|
+
behavior: t
|
|
1252
|
+
}), setTimeout(() => {
|
|
1253
|
+
me = !1;
|
|
1254
|
+
}, 50);
|
|
1024
1255
|
}
|
|
1025
|
-
|
|
1026
|
-
()
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1256
|
+
}, q = (t) => {
|
|
1257
|
+
if (S("scroll", t), !C.value) return;
|
|
1258
|
+
const e = C.value.scrollTop, a = e < Se;
|
|
1259
|
+
Se = e, !me && a && (A.value = !0, x.value = !1), P() && (x.value = !0, A.value = !1, S("scroll-bottom"));
|
|
1260
|
+
};
|
|
1261
|
+
ge(
|
|
1262
|
+
() => d.messages.length,
|
|
1263
|
+
async (t, e) => {
|
|
1264
|
+
t > (e || 0) && (A.value = !1, d.autoScroll && O("instant"));
|
|
1265
|
+
}
|
|
1266
|
+
), ge(
|
|
1267
|
+
() => [d.messages, d.enableA2UI],
|
|
1268
|
+
g,
|
|
1269
|
+
{ deep: !0, immediate: !0 }
|
|
1270
|
+
);
|
|
1271
|
+
let ke = null;
|
|
1272
|
+
ge(
|
|
1273
|
+
() => d.messages,
|
|
1274
|
+
async () => {
|
|
1275
|
+
if (!d.isStreaming || !d.autoScroll || A.value || document.hidden)
|
|
1276
|
+
return;
|
|
1277
|
+
const t = d.messages[d.messages.length - 1];
|
|
1278
|
+
!t || t.role !== "assistant" || (ke && cancelAnimationFrame(ke), ke = requestAnimationFrame(async () => {
|
|
1279
|
+
await ne(), C.value && !A.value && C.value.scrollTo({
|
|
1280
|
+
top: C.value.scrollHeight,
|
|
1035
1281
|
behavior: "instant"
|
|
1036
1282
|
});
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
(
|
|
1042
|
-
|
|
1283
|
+
}));
|
|
1284
|
+
},
|
|
1285
|
+
{ deep: !0 }
|
|
1286
|
+
), ge(
|
|
1287
|
+
() => d.isTyping,
|
|
1288
|
+
(t) => {
|
|
1289
|
+
t && d.autoScroll && O("instant");
|
|
1043
1290
|
}
|
|
1044
1291
|
);
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1292
|
+
const se = (t) => {
|
|
1293
|
+
S("copy", t), navigator.clipboard && t.content && navigator.clipboard.writeText(t.content);
|
|
1047
1294
|
};
|
|
1048
|
-
|
|
1049
|
-
() =>
|
|
1295
|
+
ge(
|
|
1296
|
+
() => d.agentSteps,
|
|
1050
1297
|
() => {
|
|
1051
|
-
|
|
1298
|
+
d.autoScroll && !A.value && O();
|
|
1052
1299
|
},
|
|
1053
1300
|
{ deep: !0 }
|
|
1054
1301
|
);
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1302
|
+
const Ce = () => {
|
|
1303
|
+
d.autoScroll && !A.value && O();
|
|
1304
|
+
}, Be = () => {
|
|
1305
|
+
!document.hidden && d.isStreaming && d.autoScroll && !A.value && ne(() => {
|
|
1306
|
+
C.value && (C.value.scrollTo({
|
|
1307
|
+
top: C.value.scrollHeight,
|
|
1308
|
+
behavior: "instant"
|
|
1309
|
+
}), x.value = !0);
|
|
1310
|
+
});
|
|
1057
1311
|
};
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}), (
|
|
1062
|
-
|
|
1063
|
-
|
|
1312
|
+
let Ae;
|
|
1313
|
+
return Ve(() => {
|
|
1314
|
+
T(), Ae = L.onEvent(de), document.addEventListener("visibilitychange", Be);
|
|
1315
|
+
}), Ue(() => {
|
|
1316
|
+
Ae == null || Ae(), document.removeEventListener("visibilitychange", Be);
|
|
1317
|
+
}), h({
|
|
1318
|
+
scrollToBottom: O,
|
|
1319
|
+
containerRef: C
|
|
1320
|
+
}), (t, e) => (u(), f("div", ya, [
|
|
1321
|
+
r.showBackground ? (u(), f("div", wa)) : z("", !0),
|
|
1322
|
+
o("div", {
|
|
1064
1323
|
class: "chat-message-list",
|
|
1065
1324
|
ref_key: "containerRef",
|
|
1066
|
-
ref:
|
|
1067
|
-
onScroll:
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1325
|
+
ref: C,
|
|
1326
|
+
onScroll: q,
|
|
1327
|
+
onWheel: ee,
|
|
1328
|
+
onTouchmove: ee,
|
|
1329
|
+
style: Ie({
|
|
1330
|
+
paddingTop: r.contentPaddingTop,
|
|
1331
|
+
paddingBottom: r.contentPaddingBottom
|
|
1071
1332
|
})
|
|
1072
1333
|
}, [
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1334
|
+
r.showWelcome && r.messages.length === 0 ? (u(), f("div", ka, [
|
|
1335
|
+
Oe(t.$slots, "welcome", {}, () => [
|
|
1336
|
+
o("div", ba, [
|
|
1337
|
+
o("div", Ma, [
|
|
1338
|
+
r.appLogo ? (u(), f("img", {
|
|
1078
1339
|
key: 0,
|
|
1079
|
-
src:
|
|
1340
|
+
src: r.appLogo,
|
|
1080
1341
|
alt: "Logo"
|
|
1081
|
-
}, null, 8,
|
|
1082
|
-
|
|
1342
|
+
}, null, 8, Sa)) : (u(), f("div", Ca, [...e[1] || (e[1] = [
|
|
1343
|
+
o("svg", {
|
|
1083
1344
|
viewBox: "0 0 1024 1024",
|
|
1084
1345
|
width: "32",
|
|
1085
1346
|
height: "32"
|
|
1086
1347
|
}, [
|
|
1087
|
-
|
|
1348
|
+
o("path", {
|
|
1088
1349
|
fill: "currentColor",
|
|
1089
1350
|
d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
|
1090
1351
|
})
|
|
1091
1352
|
], -1)
|
|
1092
1353
|
])]))
|
|
1093
1354
|
]),
|
|
1094
|
-
|
|
1095
|
-
|
|
1355
|
+
o("h2", Aa, K(r.appName), 1),
|
|
1356
|
+
e[2] || (e[2] = o("p", { class: "welcome-desc" }, "今天有什么可以帮您?", -1))
|
|
1096
1357
|
])
|
|
1097
1358
|
], !0)
|
|
1098
|
-
])) : (
|
|
1099
|
-
(
|
|
1100
|
-
key:
|
|
1101
|
-
class:
|
|
1359
|
+
])) : (u(), f("div", $a, [
|
|
1360
|
+
(u(!0), f(Ee, null, Te(r.messages, (a, s) => (u(), f("div", {
|
|
1361
|
+
key: a.id || s,
|
|
1362
|
+
class: he([
|
|
1102
1363
|
"message-row",
|
|
1103
|
-
|
|
1364
|
+
a.role === "user" ? "message-user" : "message-assistant"
|
|
1104
1365
|
])
|
|
1105
1366
|
}, [
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1367
|
+
a.role === "user" ? (u(), f("div", Ia, [
|
|
1368
|
+
o("div", _a, [
|
|
1369
|
+
k(Re, {
|
|
1370
|
+
message: a,
|
|
1371
|
+
"is-user": !0,
|
|
1372
|
+
"api-base-url": r.apiBaseUrl
|
|
1373
|
+
}, null, 8, ["message", "api-base-url"])
|
|
1374
|
+
]),
|
|
1375
|
+
a.content ? (u(), f("div", xa, [
|
|
1376
|
+
o("button", {
|
|
1377
|
+
class: "action-btn",
|
|
1378
|
+
onClick: (n) => se(a),
|
|
1379
|
+
title: "复制"
|
|
1380
|
+
}, [...e[3] || (e[3] = [
|
|
1381
|
+
o("svg", {
|
|
1382
|
+
viewBox: "0 0 1024 1024",
|
|
1383
|
+
width: "12",
|
|
1384
|
+
height: "12"
|
|
1385
|
+
}, [
|
|
1386
|
+
o("path", {
|
|
1387
|
+
fill: "currentColor",
|
|
1388
|
+
d: "M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"
|
|
1389
|
+
})
|
|
1390
|
+
], -1),
|
|
1391
|
+
o("span", null, "复制", -1)
|
|
1392
|
+
])], 8, La)
|
|
1393
|
+
])) : z("", !0)
|
|
1394
|
+
])) : (u(), f("div", za, [
|
|
1395
|
+
r.showAgentSteps && s === r.messages.length - 1 && r.agentSteps && r.agentSteps.length > 0 ? (u(), oe(Ge, {
|
|
1113
1396
|
key: 0,
|
|
1114
|
-
steps:
|
|
1115
|
-
onResize:
|
|
1116
|
-
}, null, 8, ["steps"])) :
|
|
1117
|
-
|
|
1118
|
-
f(
|
|
1119
|
-
|
|
1397
|
+
steps: r.agentSteps,
|
|
1398
|
+
onResize: Ce
|
|
1399
|
+
}, null, 8, ["steps"])) : z("", !0),
|
|
1400
|
+
o("div", Ea, [
|
|
1401
|
+
$(a, s).length > 0 ? (u(), f("div", {
|
|
1402
|
+
key: 0,
|
|
1403
|
+
class: he(["a2ui-surfaces", { "a2ui-surfaces-with-content": ae(a) }])
|
|
1404
|
+
}, [
|
|
1405
|
+
(u(!0), f(Ee, null, Te($(a, s), (n) => (u(), oe(E(ut), {
|
|
1406
|
+
key: n,
|
|
1407
|
+
"surface-id": n
|
|
1408
|
+
}, null, 8, ["surface-id"]))), 128))
|
|
1409
|
+
], 2)) : z("", !0),
|
|
1410
|
+
ue(a, s) ? (u(), f("div", Ta, [...e[4] || (e[4] = [
|
|
1411
|
+
lt('<div class="skeleton-header" data-v-a459a823><div class="skeleton-avatar skeleton-shimmer" data-v-a459a823></div><div class="skeleton-title-group" data-v-a459a823><div class="skeleton-line skeleton-title skeleton-shimmer" data-v-a459a823></div><div class="skeleton-line skeleton-subtitle skeleton-shimmer" data-v-a459a823></div></div></div><div class="skeleton-line skeleton-summary skeleton-shimmer" data-v-a459a823></div><div class="skeleton-line skeleton-summary short skeleton-shimmer" data-v-a459a823></div><div class="skeleton-facts" data-v-a459a823><div class="skeleton-fact skeleton-shimmer" data-v-a459a823></div><div class="skeleton-fact skeleton-shimmer" data-v-a459a823></div><div class="skeleton-fact skeleton-shimmer" data-v-a459a823></div></div>', 4)
|
|
1412
|
+
])])) : z("", !0),
|
|
1413
|
+
ae(a) ? (u(), oe(Re, {
|
|
1414
|
+
key: 2,
|
|
1415
|
+
message: a,
|
|
1120
1416
|
"is-user": !1,
|
|
1121
|
-
"
|
|
1122
|
-
|
|
1417
|
+
"api-base-url": r.apiBaseUrl,
|
|
1418
|
+
"is-streaming": r.isStreaming && s === r.messages.length - 1
|
|
1419
|
+
}, null, 8, ["message", "api-base-url", "is-streaming"])) : z("", !0)
|
|
1123
1420
|
]),
|
|
1124
|
-
|
|
1125
|
-
|
|
1421
|
+
ae(a) && a.content && !(r.isStreaming && s === r.messages.length - 1) ? (u(), f("div", Ba, [
|
|
1422
|
+
o("button", {
|
|
1126
1423
|
class: "action-btn",
|
|
1127
|
-
onClick: (
|
|
1424
|
+
onClick: (n) => se(a),
|
|
1128
1425
|
title: "复制"
|
|
1129
|
-
}, [...
|
|
1130
|
-
|
|
1426
|
+
}, [...e[5] || (e[5] = [
|
|
1427
|
+
o("svg", {
|
|
1131
1428
|
viewBox: "0 0 1024 1024",
|
|
1132
1429
|
width: "12",
|
|
1133
1430
|
height: "12"
|
|
1134
1431
|
}, [
|
|
1135
|
-
|
|
1432
|
+
o("path", {
|
|
1136
1433
|
fill: "currentColor",
|
|
1137
1434
|
d: "M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"
|
|
1138
1435
|
})
|
|
1139
1436
|
], -1),
|
|
1140
|
-
|
|
1141
|
-
])], 8,
|
|
1142
|
-
])) :
|
|
1437
|
+
o("span", null, "复制", -1)
|
|
1438
|
+
])], 8, Ua)
|
|
1439
|
+
])) : z("", !0)
|
|
1143
1440
|
]))
|
|
1144
1441
|
], 2))), 128)),
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1442
|
+
r.isTyping ? (u(), f("div", Ha, [...e[6] || (e[6] = [
|
|
1443
|
+
o("div", { class: "typing-indicator" }, [
|
|
1444
|
+
o("div", { class: "typing-dot" }),
|
|
1445
|
+
o("div", {
|
|
1149
1446
|
class: "typing-dot",
|
|
1150
1447
|
style: { "animation-delay": "0.2s" }
|
|
1151
1448
|
}),
|
|
1152
|
-
|
|
1449
|
+
o("div", {
|
|
1153
1450
|
class: "typing-dot",
|
|
1154
1451
|
style: { "animation-delay": "0.4s" }
|
|
1155
1452
|
})
|
|
1156
1453
|
], -1)
|
|
1157
|
-
])])) :
|
|
1454
|
+
])])) : z("", !0)
|
|
1158
1455
|
]))
|
|
1159
|
-
], 36)
|
|
1456
|
+
], 36),
|
|
1457
|
+
k(rt, { name: "fade-slide" }, {
|
|
1458
|
+
default: R(() => [
|
|
1459
|
+
x.value ? z("", !0) : (u(), f("button", {
|
|
1460
|
+
key: 0,
|
|
1461
|
+
class: "scroll-to-bottom-btn",
|
|
1462
|
+
style: Ie({ bottom: `calc(${r.contentPaddingBottom || "140px"} + 20px)` }),
|
|
1463
|
+
onClick: e[0] || (e[0] = (a) => O("smooth", !0))
|
|
1464
|
+
}, [
|
|
1465
|
+
e[8] || (e[8] = o("div", { class: "btn-inner" }, [
|
|
1466
|
+
o("svg", {
|
|
1467
|
+
class: "arrow-icon",
|
|
1468
|
+
viewBox: "0 0 24 24",
|
|
1469
|
+
fill: "none",
|
|
1470
|
+
stroke: "currentColor"
|
|
1471
|
+
}, [
|
|
1472
|
+
o("path", {
|
|
1473
|
+
"stroke-linecap": "round",
|
|
1474
|
+
"stroke-linejoin": "round",
|
|
1475
|
+
"stroke-width": "2.5",
|
|
1476
|
+
d: "M19 9l-7 7-7-7"
|
|
1477
|
+
})
|
|
1478
|
+
])
|
|
1479
|
+
], -1)),
|
|
1480
|
+
r.isStreaming ? (u(), f("svg", Da, [...e[7] || (e[7] = [
|
|
1481
|
+
o("circle", {
|
|
1482
|
+
class: "loading-circle",
|
|
1483
|
+
cx: "18",
|
|
1484
|
+
cy: "18",
|
|
1485
|
+
r: "16"
|
|
1486
|
+
}, null, -1)
|
|
1487
|
+
])])) : z("", !0)
|
|
1488
|
+
], 4))
|
|
1489
|
+
]),
|
|
1490
|
+
_: 1
|
|
1491
|
+
})
|
|
1160
1492
|
]));
|
|
1161
1493
|
}
|
|
1162
|
-
}),
|
|
1163
|
-
install(
|
|
1164
|
-
|
|
1494
|
+
}), Ra = /* @__PURE__ */ _e(Pa, [["__scopeId", "data-v-a459a823"]]), Ya = {
|
|
1495
|
+
install(r) {
|
|
1496
|
+
r.component("ChatMessageList", Ra), r.component("MultimodalMessage", Re), r.component("MarkdownMessage", Je), r.component("AgentSteps", Ge);
|
|
1165
1497
|
}
|
|
1166
1498
|
};
|
|
1167
1499
|
export {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1500
|
+
Ge as AgentSteps,
|
|
1501
|
+
Ra as ChatMessageList,
|
|
1502
|
+
Je as MarkdownMessage,
|
|
1503
|
+
Re as MultimodalMessage,
|
|
1504
|
+
Ya as default
|
|
1173
1505
|
};
|