@somecat/ai-assist-sdk 1.3.1 → 1.3.3
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/dist/chunks/{index-BZPlXfol.mjs → index-2loQl224.mjs} +2 -2
- package/dist/chunks/{index-Da2hiup1.mjs → index-5fjEwBkV.mjs} +2174 -2141
- package/dist/core/voice/engine.d.ts +16 -1
- package/dist/core/voice/index.d.ts +1 -1
- package/dist/core/voice/types.d.ts +7 -0
- package/dist/index.mjs +1 -1
- package/dist/react/components/answer/components/ChatInput.d.ts +0 -1
- package/dist/react/index.mjs +7753 -7697
- package/dist/vue/index.mjs +1364 -1303
- package/package.json +1 -1
package/dist/vue/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { a as Xt, r as vt, p as dt, u as _n, V as
|
|
3
|
-
import { t as
|
|
4
|
-
import { BulbOutlined as
|
|
5
|
-
import { Icon as
|
|
6
|
-
const Un = "data:image/png;base64,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", Zn = { class: "thinking-block__title" }, In = ["innerHTML"],
|
|
1
|
+
import { defineComponent as Ee, ref as g, watch as ve, nextTick as me, onUnmounted as Pe, openBlock as v, createElementBlock as m, normalizeClass as se, createElementVNode as o, toDisplayString as z, createVNode as ie, Transition as yn, withCtx as wn, unref as O, createCommentVNode as J, computed as B, Fragment as we, renderList as xe, reactive as ye, createStaticVNode as kn, withModifiers as fe, createBlock as pe, Teleport as Yt, onMounted as be, onBeforeUnmount as Nt, withDirectives as Me, withKeys as ct, vModelText as Vt, normalizeStyle as it, vShow as Ve, createApp as Cn } from "vue";
|
|
2
|
+
import { a as Xt, r as vt, p as dt, u as _n, V as Qe, c as Mt, g as bn, o as An, s as Sn, b as Rt, e as En, d as Tn, f as qe, h as xn, i as Dn, j as Mn, k as Rn, l as Hn, m as ht, w as $n, n as Ln, q as Pn, t as Ft } from "../chunks/index-5fjEwBkV.mjs";
|
|
3
|
+
import { t as Ht, r as On, f as Bn, i as Wn, s as Yn, a as Nn, b as Vn, c as Te, d as Xn, e as Qt, g as Fn, h as Qn, m as Jn } from "../chunks/index-2loQl224.mjs";
|
|
4
|
+
import { BulbOutlined as qn, SearchOutlined as $t, CheckOutlined as zn, CopyOutlined as Kn, RedoOutlined as Gn, CloseOutlined as jn } from "@ant-design/icons-vue";
|
|
5
|
+
import { Icon as ce } from "@iconify/vue";
|
|
6
|
+
const Un = "data:image/png;base64,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", Zn = { class: "thinking-block__title" }, In = ["innerHTML"], eo = /* @__PURE__ */ Ee({
|
|
7
7
|
__name: "ThinkingBlock",
|
|
8
8
|
props: {
|
|
9
9
|
content: {},
|
|
@@ -11,67 +11,67 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
11
11
|
messageDone: { type: Boolean }
|
|
12
12
|
},
|
|
13
13
|
setup(t) {
|
|
14
|
-
const
|
|
15
|
-
let
|
|
16
|
-
function l(
|
|
17
|
-
clearTimeout(
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
() =>
|
|
29
|
-
(
|
|
30
|
-
|
|
14
|
+
const w = t, i = g(!!w.isStreaming || !!w.messageDone);
|
|
15
|
+
let u = 0;
|
|
16
|
+
function l(p = 600) {
|
|
17
|
+
clearTimeout(u), u = window.setTimeout(() => {
|
|
18
|
+
u = 0, i.value = !1;
|
|
19
|
+
}, p);
|
|
20
|
+
}
|
|
21
|
+
function h() {
|
|
22
|
+
u && (clearTimeout(u), u = 0);
|
|
23
|
+
}
|
|
24
|
+
function s() {
|
|
25
|
+
h(), i.value = !i.value;
|
|
26
|
+
}
|
|
27
|
+
ve(
|
|
28
|
+
() => w.isStreaming,
|
|
29
|
+
(p) => {
|
|
30
|
+
p ? (h(), i.value = !0) : w.messageDone || l();
|
|
31
31
|
},
|
|
32
32
|
{ immediate: !0 }
|
|
33
|
-
),
|
|
34
|
-
() =>
|
|
35
|
-
(
|
|
36
|
-
|
|
33
|
+
), ve(
|
|
34
|
+
() => w.messageDone,
|
|
35
|
+
(p) => {
|
|
36
|
+
p && (h(), i.value = !0);
|
|
37
37
|
},
|
|
38
38
|
{ immediate: !0 }
|
|
39
39
|
);
|
|
40
|
-
const a =
|
|
41
|
-
let
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
function
|
|
48
|
-
const
|
|
49
|
-
!
|
|
50
|
-
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
return
|
|
55
|
-
() =>
|
|
40
|
+
const a = g(null);
|
|
41
|
+
let r = !1;
|
|
42
|
+
function f() {
|
|
43
|
+
const p = a.value;
|
|
44
|
+
if (!p) return;
|
|
45
|
+
r = p.scrollHeight - p.scrollTop - p.clientHeight > 12;
|
|
46
|
+
}
|
|
47
|
+
function k() {
|
|
48
|
+
const p = a.value;
|
|
49
|
+
!p || !i.value || r || (p.scrollTop = p.scrollHeight);
|
|
50
|
+
}
|
|
51
|
+
function V() {
|
|
52
|
+
w.isStreaming && k();
|
|
53
|
+
}
|
|
54
|
+
return ve(
|
|
55
|
+
() => w.content,
|
|
56
56
|
() => {
|
|
57
|
-
|
|
57
|
+
w.isStreaming && me(k);
|
|
58
58
|
}
|
|
59
|
-
),
|
|
60
|
-
|
|
61
|
-
}), (
|
|
62
|
-
class:
|
|
59
|
+
), Pe(() => {
|
|
60
|
+
h();
|
|
61
|
+
}), (p, R) => (v(), m("div", {
|
|
62
|
+
class: se(["thinking-block", {
|
|
63
63
|
"thinking-block--expanded": i.value,
|
|
64
64
|
"thinking-block--active": t.isStreaming
|
|
65
65
|
}])
|
|
66
66
|
}, [
|
|
67
|
-
|
|
67
|
+
o("div", {
|
|
68
68
|
class: "thinking-block__header",
|
|
69
|
-
onClick:
|
|
69
|
+
onClick: s
|
|
70
70
|
}, [
|
|
71
|
-
R[1] || (R[1] =
|
|
72
|
-
|
|
73
|
-
(v(),
|
|
74
|
-
class:
|
|
71
|
+
R[1] || (R[1] = o("span", { class: "thinking-block__indicator" }, null, -1)),
|
|
72
|
+
o("span", Zn, z(t.isStreaming ? "深度思考中" : "深度思考"), 1),
|
|
73
|
+
(v(), m("svg", {
|
|
74
|
+
class: se(["thinking-block__arrow", { "thinking-block__arrow--down": i.value }]),
|
|
75
75
|
viewBox: "0 0 24 24",
|
|
76
76
|
width: "14",
|
|
77
77
|
height: "14",
|
|
@@ -81,41 +81,41 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
81
81
|
"stroke-linecap": "round",
|
|
82
82
|
"stroke-linejoin": "round"
|
|
83
83
|
}, [...R[0] || (R[0] = [
|
|
84
|
-
|
|
84
|
+
o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
|
|
85
85
|
])], 2))
|
|
86
86
|
]),
|
|
87
|
-
|
|
87
|
+
ie(yn, {
|
|
88
88
|
name: "thinking-expand",
|
|
89
|
-
onAfterEnter:
|
|
89
|
+
onAfterEnter: V
|
|
90
90
|
}, {
|
|
91
91
|
default: wn(() => [
|
|
92
|
-
i.value ? (v(),
|
|
92
|
+
i.value ? (v(), m("div", {
|
|
93
93
|
key: 0,
|
|
94
94
|
ref_key: "contentRef",
|
|
95
95
|
ref: a,
|
|
96
96
|
class: "thinking-block__content",
|
|
97
|
-
onScroll:
|
|
97
|
+
onScroll: f
|
|
98
98
|
}, [
|
|
99
|
-
|
|
99
|
+
o("div", {
|
|
100
100
|
class: "thinking-block__markdown",
|
|
101
|
-
innerHTML: O(Xt)(O(vt)(O(dt)(
|
|
101
|
+
innerHTML: O(Xt)(O(vt)(O(dt)(w.content)), t.isStreaming)
|
|
102
102
|
}, null, 8, In)
|
|
103
|
-
], 544)) :
|
|
103
|
+
], 544)) : J("", !0)
|
|
104
104
|
]),
|
|
105
105
|
_: 1
|
|
106
106
|
})
|
|
107
107
|
], 2));
|
|
108
108
|
}
|
|
109
|
-
}),
|
|
109
|
+
}), to = {
|
|
110
110
|
key: 0,
|
|
111
111
|
class: "step-block__header"
|
|
112
|
-
},
|
|
112
|
+
}, no = {
|
|
113
113
|
key: 0,
|
|
114
114
|
class: "step-block__count"
|
|
115
|
-
},
|
|
115
|
+
}, oo = {
|
|
116
116
|
key: 1,
|
|
117
117
|
class: "step-block__duration"
|
|
118
|
-
},
|
|
118
|
+
}, so = { class: "step-block__list" }, ao = { class: "step-item__icon" }, io = {
|
|
119
119
|
key: 0,
|
|
120
120
|
viewBox: "0 0 24 24",
|
|
121
121
|
width: "12",
|
|
@@ -125,7 +125,7 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
125
125
|
"stroke-width": "3",
|
|
126
126
|
"stroke-linecap": "round",
|
|
127
127
|
"stroke-linejoin": "round"
|
|
128
|
-
},
|
|
128
|
+
}, lo = {
|
|
129
129
|
key: 1,
|
|
130
130
|
class: "step-item__spinner",
|
|
131
131
|
viewBox: "0 0 24 24",
|
|
@@ -135,147 +135,147 @@ const Un = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
|
|
|
135
135
|
stroke: "currentColor",
|
|
136
136
|
"stroke-width": "2.5",
|
|
137
137
|
"stroke-linecap": "round"
|
|
138
|
-
},
|
|
138
|
+
}, uo = {
|
|
139
139
|
key: 2,
|
|
140
140
|
class: "step-item__dot"
|
|
141
|
-
},
|
|
141
|
+
}, ro = { class: "step-item__body" }, co = { class: "step-item__head" }, vo = { class: "step-item__title" }, ho = {
|
|
142
142
|
key: 0,
|
|
143
143
|
class: "step-item__duration"
|
|
144
|
-
},
|
|
144
|
+
}, po = {
|
|
145
145
|
key: 0,
|
|
146
146
|
class: "step-item__content"
|
|
147
|
-
},
|
|
147
|
+
}, mo = /* @__PURE__ */ Ee({
|
|
148
148
|
__name: "StepBlock",
|
|
149
149
|
props: {
|
|
150
150
|
steps: {}
|
|
151
151
|
},
|
|
152
152
|
setup(t) {
|
|
153
|
-
const
|
|
154
|
-
() =>
|
|
153
|
+
const w = t, i = B(() => w.steps.some((h) => h.state !== "done")), u = B(
|
|
154
|
+
() => w.steps.reduce((h, s) => h + (s.duration ?? 0), 0)
|
|
155
155
|
);
|
|
156
|
-
function l(
|
|
157
|
-
return
|
|
156
|
+
function l(h) {
|
|
157
|
+
return h == null || h <= 0 ? "" : h < 1 ? `${Math.round(h * 1e3)}ms` : h < 60 ? `${h.toFixed(1)}s` : `${Math.floor(h / 60)}m${Math.round(h % 60)}s`;
|
|
158
158
|
}
|
|
159
|
-
return (
|
|
160
|
-
class:
|
|
159
|
+
return (h, s) => (v(), m("div", {
|
|
160
|
+
class: se(["step-block", { "step-block--active": i.value }])
|
|
161
161
|
}, [
|
|
162
|
-
t.steps.length > 1 ? (v(),
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
i.value ?
|
|
166
|
-
!i.value &&
|
|
167
|
-
])) :
|
|
168
|
-
|
|
169
|
-
(v(!0),
|
|
170
|
-
key:
|
|
171
|
-
class:
|
|
162
|
+
t.steps.length > 1 ? (v(), m("div", to, [
|
|
163
|
+
s[0] || (s[0] = o("span", { class: "step-block__indicator" }, null, -1)),
|
|
164
|
+
s[1] || (s[1] = o("span", { class: "step-block__title" }, "执行步骤", -1)),
|
|
165
|
+
i.value ? J("", !0) : (v(), m("span", no, z(t.steps.length) + " 步", 1)),
|
|
166
|
+
!i.value && u.value > 0 ? (v(), m("span", oo, z(l(u.value)), 1)) : J("", !0)
|
|
167
|
+
])) : J("", !0),
|
|
168
|
+
o("ul", so, [
|
|
169
|
+
(v(!0), m(we, null, xe(t.steps, (a, r) => (v(), m("li", {
|
|
170
|
+
key: r,
|
|
171
|
+
class: se(["step-item", `step-item--${a.state}`])
|
|
172
172
|
}, [
|
|
173
|
-
|
|
174
|
-
a.state === "done" ? (v(),
|
|
175
|
-
|
|
176
|
-
])])) : a.state === "active" ? (v(),
|
|
177
|
-
|
|
173
|
+
o("span", ao, [
|
|
174
|
+
a.state === "done" ? (v(), m("svg", io, [...s[2] || (s[2] = [
|
|
175
|
+
o("polyline", { points: "20 6 9 17 4 12" }, null, -1)
|
|
176
|
+
])])) : a.state === "active" ? (v(), m("svg", lo, [...s[3] || (s[3] = [
|
|
177
|
+
o("circle", {
|
|
178
178
|
cx: "12",
|
|
179
179
|
cy: "12",
|
|
180
180
|
r: "9",
|
|
181
181
|
"stroke-dasharray": "42",
|
|
182
182
|
"stroke-dashoffset": "14"
|
|
183
183
|
}, null, -1)
|
|
184
|
-
])])) : (v(),
|
|
184
|
+
])])) : (v(), m("span", uo))
|
|
185
185
|
]),
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
a.state === "done" && a.duration != null && a.duration > 0 ? (v(),
|
|
186
|
+
o("div", ro, [
|
|
187
|
+
o("div", co, [
|
|
188
|
+
o("span", vo, z(a.title || "处理中"), 1),
|
|
189
|
+
a.state === "done" && a.duration != null && a.duration > 0 ? (v(), m("span", ho, z(l(a.duration)), 1)) : J("", !0)
|
|
190
190
|
]),
|
|
191
|
-
a.content ? (v(),
|
|
191
|
+
a.content ? (v(), m("div", po, z(a.content), 1)) : J("", !0)
|
|
192
192
|
])
|
|
193
193
|
], 2))), 128))
|
|
194
194
|
])
|
|
195
195
|
], 2));
|
|
196
196
|
}
|
|
197
197
|
});
|
|
198
|
-
function
|
|
199
|
-
const i = B(() => t().segments),
|
|
200
|
-
const
|
|
201
|
-
return
|
|
202
|
-
}),
|
|
203
|
-
let
|
|
204
|
-
function
|
|
205
|
-
|
|
198
|
+
function fo(t, w) {
|
|
199
|
+
const i = B(() => t().segments), u = B(() => Ht(i.value)), l = B(() => !!t().streamed), h = B(() => {
|
|
200
|
+
const _ = t().status;
|
|
201
|
+
return _ === "stop" || _ === "error";
|
|
202
|
+
}), s = g(t().streamed ? 0 : Ht(t().segments)), a = g(0);
|
|
203
|
+
let r = 0, f = 0;
|
|
204
|
+
function k(_) {
|
|
205
|
+
s.value !== _ && (s.value = _);
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
211
|
-
|
|
207
|
+
function V() {
|
|
208
|
+
if (r) return;
|
|
209
|
+
const _ = (E) => {
|
|
210
|
+
if (f === 0) {
|
|
211
|
+
f = E, r = requestAnimationFrame(_);
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
const n =
|
|
217
|
-
if (a.value =
|
|
218
|
-
|
|
214
|
+
const te = Math.min(E - f, 100);
|
|
215
|
+
f = E;
|
|
216
|
+
const n = u.value, d = Yn(i.value, s.value), C = Nn(s.value, n, a.value, te, d);
|
|
217
|
+
if (a.value = C.frac, C.reveal !== s.value && (s.value = C.reveal, w == null || w()), s.value >= n) {
|
|
218
|
+
r = 0, f = 0;
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
|
|
221
|
+
r = requestAnimationFrame(_);
|
|
222
222
|
};
|
|
223
|
-
|
|
223
|
+
f = 0, r = requestAnimationFrame(_);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
|
|
225
|
+
function p() {
|
|
226
|
+
r && (cancelAnimationFrame(r), r = 0);
|
|
227
227
|
}
|
|
228
|
-
|
|
229
|
-
[l,
|
|
228
|
+
ve(
|
|
229
|
+
[l, u],
|
|
230
230
|
() => {
|
|
231
|
-
if (!l.value ||
|
|
232
|
-
|
|
231
|
+
if (!l.value || h.value) {
|
|
232
|
+
k(u.value);
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
|
-
|
|
235
|
+
s.value < u.value && V();
|
|
236
236
|
},
|
|
237
237
|
{ immediate: !0 }
|
|
238
|
-
),
|
|
239
|
-
|
|
240
|
-
}),
|
|
238
|
+
), ve(h, (_) => {
|
|
239
|
+
_ && l.value && k(u.value);
|
|
240
|
+
}), ve(
|
|
241
241
|
() => t().status,
|
|
242
|
-
(
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
),
|
|
246
|
-
const R = B(() => On(i.value,
|
|
247
|
-
() => l.value ? Bn(i.value,
|
|
248
|
-
),
|
|
249
|
-
function
|
|
250
|
-
return Wn(i.value,
|
|
242
|
+
(_, E) => {
|
|
243
|
+
_ === "rethinking" && E !== "rethinking" && (a.value = 0, k(0), u.value > 0 && V());
|
|
244
|
+
}
|
|
245
|
+
), Pe(p);
|
|
246
|
+
const R = B(() => On(i.value, s.value)), X = B(
|
|
247
|
+
() => l.value ? Bn(i.value, s.value) : -1
|
|
248
|
+
), K = B(() => !l.value || s.value >= u.value);
|
|
249
|
+
function G(_) {
|
|
250
|
+
return Wn(i.value, _, s.value);
|
|
251
251
|
}
|
|
252
|
-
return { reveal:
|
|
252
|
+
return { reveal: s, segmentContents: R, frontier: X, revealDone: K, isSegRevealed: G, stopLoop: p };
|
|
253
253
|
}
|
|
254
|
-
const
|
|
254
|
+
const go = {
|
|
255
255
|
key: 0,
|
|
256
256
|
class: "message-content ba-markdown"
|
|
257
|
-
},
|
|
257
|
+
}, yo = { class: "thought-collapse-bar__text" }, wo = {
|
|
258
258
|
key: 2,
|
|
259
259
|
class: "thought-collapse-bar__duration"
|
|
260
|
-
},
|
|
260
|
+
}, ko = { class: "thought-collapse-bar__action" }, Co = { class: "agent-thought__spinner" }, _o = { class: "agent-thought__text" }, bo = {
|
|
261
261
|
key: 0,
|
|
262
262
|
class: "agent-thought__duration"
|
|
263
|
-
},
|
|
263
|
+
}, Ao = {
|
|
264
264
|
key: 1,
|
|
265
265
|
class: "agent-thought__duration"
|
|
266
|
-
},
|
|
266
|
+
}, So = { key: 0 }, Eo = ["innerHTML"], To = ["innerHTML"], xo = {
|
|
267
267
|
key: 3,
|
|
268
268
|
class: "message-error"
|
|
269
|
-
},
|
|
269
|
+
}, Do = {
|
|
270
270
|
key: 4,
|
|
271
271
|
class: "message-toolbar"
|
|
272
|
-
},
|
|
272
|
+
}, Mo = ["data-tooltip"], Ro = {
|
|
273
273
|
class: "tooltip-enhanced",
|
|
274
274
|
"data-tooltip": "重新回答"
|
|
275
|
-
},
|
|
275
|
+
}, Ho = {
|
|
276
276
|
key: 1,
|
|
277
277
|
class: "message-content"
|
|
278
|
-
}, $
|
|
278
|
+
}, $o = ["src"], Lo = /* @__PURE__ */ Ee({
|
|
279
279
|
__name: "MessageItem",
|
|
280
280
|
props: {
|
|
281
281
|
msg: {},
|
|
@@ -285,86 +285,86 @@ const gs = {
|
|
|
285
285
|
scrollToBottom: { type: Function }
|
|
286
286
|
},
|
|
287
287
|
emits: ["regenerate"],
|
|
288
|
-
setup(t, { emit:
|
|
289
|
-
const i = t, { reveal:
|
|
288
|
+
setup(t, { emit: w }) {
|
|
289
|
+
const i = t, { reveal: u, segmentContents: l, frontier: h, revealDone: s } = fo(
|
|
290
290
|
() => i.msg,
|
|
291
291
|
() => i.scrollToBottom()
|
|
292
292
|
), a = B(
|
|
293
293
|
() => i.msg.status === i.STATUS.COMPLETED || i.msg.status === i.STATUS.STOP
|
|
294
|
-
),
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
), r = B(() => a.value && s.value), f = g(!1);
|
|
295
|
+
ve(r, (y) => {
|
|
296
|
+
y && (f.value = !1);
|
|
297
297
|
});
|
|
298
|
-
const
|
|
299
|
-
const
|
|
300
|
-
return
|
|
301
|
-
}),
|
|
298
|
+
const k = B(() => Vn(i.msg.segments, u.value)), V = B(() => k.value.length > 0), p = B(() => k.value.some((y) => y.kind === "thinking")), R = B(() => k.value.some((y) => y.kind === "tools")), X = B(() => k.value.some((y) => y.kind === "steps")), K = B(() => {
|
|
299
|
+
const y = [];
|
|
300
|
+
return p.value && y.push("深度思考"), R.value && y.push("工具调用"), X.value && y.push("执行步骤"), y.join(" · ") || "思考过程";
|
|
301
|
+
}), G = B(() => !r.value || f.value), _ = B(
|
|
302
302
|
() => (i.msg.segments ?? []).reduce(
|
|
303
|
-
(
|
|
303
|
+
(y, L) => L.type === "thinking" || L.type === "agent_thought" || L.type === "step" ? y + (L.duration ?? 0) : y,
|
|
304
304
|
0
|
|
305
305
|
)
|
|
306
|
-
),
|
|
306
|
+
), E = B(
|
|
307
307
|
() => (i.msg.segments ?? []).some(
|
|
308
|
-
(
|
|
308
|
+
(y, L) => y.type === "answer" && (l.value[L] || "").length > 0
|
|
309
309
|
)
|
|
310
|
-
),
|
|
311
|
-
() => !
|
|
310
|
+
), te = B(
|
|
311
|
+
() => !r.value && i.msg.status !== i.STATUS.ERROR && i.msg.status !== i.STATUS.PAUSED && k.value.length === 0 && !E.value
|
|
312
312
|
);
|
|
313
|
-
function n(
|
|
314
|
-
return
|
|
313
|
+
function n(y) {
|
|
314
|
+
return y == null || y <= 0 ? "" : y < 1 ? `${Math.round(y * 1e3)}ms` : y < 60 ? `${y.toFixed(1)}s` : `${Math.floor(y / 60)}m${Math.round(y % 60)}s`;
|
|
315
315
|
}
|
|
316
|
-
const
|
|
317
|
-
function y
|
|
318
|
-
const L =
|
|
319
|
-
L.tagName === "IMG" && (
|
|
316
|
+
const d = ye(/* @__PURE__ */ new Map()), C = g("");
|
|
317
|
+
function D(y) {
|
|
318
|
+
const L = y.target;
|
|
319
|
+
L.tagName === "IMG" && (C.value = L.src);
|
|
320
320
|
}
|
|
321
|
-
function
|
|
322
|
-
|
|
321
|
+
function T() {
|
|
322
|
+
C.value = "";
|
|
323
323
|
}
|
|
324
|
-
function
|
|
325
|
-
var
|
|
324
|
+
function W(y, L) {
|
|
325
|
+
var ne;
|
|
326
326
|
try {
|
|
327
|
-
let
|
|
328
|
-
if (!
|
|
329
|
-
`)),
|
|
330
|
-
const { copy:
|
|
331
|
-
|
|
327
|
+
let S = y.content;
|
|
328
|
+
if (!S && ((ne = y.segments) != null && ne.length) && (S = y.segments.filter((q) => q.type === "answer").map((q) => q.content).join(`
|
|
329
|
+
`)), S) {
|
|
330
|
+
const { copy: q } = _n();
|
|
331
|
+
q(S), d.set(L, !0), setTimeout(() => d.set(L, !1), 2e3);
|
|
332
332
|
}
|
|
333
333
|
} catch {
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
return (
|
|
337
|
-
var
|
|
338
|
-
return v(),
|
|
339
|
-
class:
|
|
336
|
+
return (y, L) => {
|
|
337
|
+
var ne;
|
|
338
|
+
return v(), m("div", {
|
|
339
|
+
class: se(["message", `${t.msg.type}-message`])
|
|
340
340
|
}, [
|
|
341
|
-
t.msg.type === "ai" ? (v(),
|
|
342
|
-
|
|
341
|
+
t.msg.type === "ai" ? (v(), m(we, { key: 0 }, [
|
|
342
|
+
te.value ? (v(), m("div", go, [...L[4] || (L[4] = [
|
|
343
343
|
kn('<div class="scale-animation-container"><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span><span class="scale-dot"></span></div>', 1)
|
|
344
|
-
])])) :
|
|
345
|
-
t.msg.segments && t.msg.segments.length ? (v(),
|
|
344
|
+
])])) : J("", !0),
|
|
345
|
+
t.msg.segments && t.msg.segments.length ? (v(), m("div", {
|
|
346
346
|
key: 1,
|
|
347
347
|
class: "message-content ba-markdown",
|
|
348
|
-
ref: (
|
|
349
|
-
onClick:
|
|
348
|
+
ref: (S) => t.setMessageRef(S, t.index),
|
|
349
|
+
onClick: D
|
|
350
350
|
}, [
|
|
351
|
-
|
|
351
|
+
r.value && V.value ? (v(), m("div", {
|
|
352
352
|
key: 0,
|
|
353
|
-
class:
|
|
354
|
-
onClick: L[0] || (L[0] =
|
|
353
|
+
class: se(["thought-collapse-bar", { "thought-collapse-bar--expanded": f.value }]),
|
|
354
|
+
onClick: L[0] || (L[0] = fe((S) => f.value = !f.value, ["stop"]))
|
|
355
355
|
}, [
|
|
356
|
-
|
|
356
|
+
p.value ? (v(), pe(O(qn), {
|
|
357
357
|
key: 0,
|
|
358
358
|
class: "thought-collapse-bar__icon"
|
|
359
|
-
})) : (v(),
|
|
359
|
+
})) : (v(), pe(O($t), {
|
|
360
360
|
key: 1,
|
|
361
361
|
class: "thought-collapse-bar__icon"
|
|
362
362
|
})),
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
(v(),
|
|
367
|
-
class:
|
|
363
|
+
o("span", yo, z(K.value), 1),
|
|
364
|
+
_.value > 0 ? (v(), m("span", wo, z(n(_.value)), 1)) : J("", !0),
|
|
365
|
+
o("span", ko, z(f.value ? "收起" : "查看"), 1),
|
|
366
|
+
(v(), m("svg", {
|
|
367
|
+
class: se(["thought-collapse-bar__arrow", { "thought-collapse-bar__arrow--down": f.value }]),
|
|
368
368
|
viewBox: "0 0 24 24",
|
|
369
369
|
width: "12",
|
|
370
370
|
height: "12",
|
|
@@ -374,326 +374,386 @@ const gs = {
|
|
|
374
374
|
"stroke-linecap": "round",
|
|
375
375
|
"stroke-linejoin": "round"
|
|
376
376
|
}, [...L[5] || (L[5] = [
|
|
377
|
-
|
|
377
|
+
o("polyline", { points: "6 9 12 15 18 9" }, null, -1)
|
|
378
378
|
])], 2))
|
|
379
|
-
], 2)) :
|
|
380
|
-
|
|
381
|
-
|
|
379
|
+
], 2)) : J("", !0),
|
|
380
|
+
G.value ? (v(!0), m(we, { key: 1 }, xe(k.value, (S, q) => (v(), m(we, { key: q }, [
|
|
381
|
+
S.kind === "steps" ? (v(), pe(mo, {
|
|
382
382
|
key: 0,
|
|
383
|
-
steps:
|
|
384
|
-
}, null, 8, ["steps"])) :
|
|
383
|
+
steps: S.items
|
|
384
|
+
}, null, 8, ["steps"])) : S.kind === "thinking" ? (v(), pe(eo, {
|
|
385
385
|
key: 1,
|
|
386
|
-
content:
|
|
387
|
-
"is-streaming":
|
|
388
|
-
"message-done":
|
|
389
|
-
}, null, 8, ["content", "is-streaming", "message-done"])) : (v(),
|
|
386
|
+
content: S.content,
|
|
387
|
+
"is-streaming": S.streaming,
|
|
388
|
+
"message-done": r.value
|
|
389
|
+
}, null, 8, ["content", "is-streaming", "message-done"])) : (v(), m("div", {
|
|
390
390
|
key: 2,
|
|
391
|
-
class:
|
|
391
|
+
class: se(["agent-thought", { "agent-thought--done": !S.calling }])
|
|
392
392
|
}, [
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
o("span", Co, [
|
|
394
|
+
ie(O($t))
|
|
395
395
|
]),
|
|
396
|
-
|
|
397
|
-
!
|
|
398
|
-
!
|
|
396
|
+
o("span", _o, z(S.calling ? "工具调用中" : "工具调用"), 1),
|
|
397
|
+
!S.calling && S.count > 1 ? (v(), m("span", bo, " 已调用 " + z(S.count) + " 次 ", 1)) : J("", !0),
|
|
398
|
+
!S.calling && S.duration > 0 ? (v(), m("span", Ao, z(n(S.duration)), 1)) : J("", !0)
|
|
399
399
|
], 2))
|
|
400
|
-
], 64))), 128)) :
|
|
401
|
-
(v(!0),
|
|
402
|
-
|
|
403
|
-
|
|
400
|
+
], 64))), 128)) : J("", !0),
|
|
401
|
+
(v(!0), m(we, null, xe(t.msg.segments, (S, q) => (v(), m(we, { key: q }, [
|
|
402
|
+
S.type === "answer" ? (v(), m("div", So, [
|
|
403
|
+
o("div", {
|
|
404
404
|
innerHTML: O(Xt)(
|
|
405
|
-
O(vt)(O(dt)(O(l)[
|
|
406
|
-
!O(
|
|
405
|
+
O(vt)(O(dt)(O(l)[q] ?? "")),
|
|
406
|
+
!O(s) && O(h) === q && t.msg.status !== t.STATUS.STOP
|
|
407
407
|
)
|
|
408
|
-
}, null, 8,
|
|
409
|
-
])) :
|
|
408
|
+
}, null, 8, Eo)
|
|
409
|
+
])) : J("", !0)
|
|
410
410
|
], 64))), 128))
|
|
411
|
-
], 512)) :
|
|
412
|
-
!((
|
|
411
|
+
], 512)) : J("", !0),
|
|
412
|
+
!((ne = t.msg.segments) != null && ne.length) && t.msg.content ? (v(), m("div", {
|
|
413
413
|
key: 2,
|
|
414
414
|
class: "message-content ba-markdown",
|
|
415
|
-
ref: (
|
|
416
|
-
onClick:
|
|
415
|
+
ref: (S) => t.setMessageRef(S, t.index),
|
|
416
|
+
onClick: D
|
|
417
417
|
}, [
|
|
418
|
-
|
|
418
|
+
o("div", {
|
|
419
419
|
innerHTML: O(vt)(O(dt)(t.msg.content))
|
|
420
|
-
}, null, 8,
|
|
421
|
-
], 512)) :
|
|
422
|
-
t.msg.errorMessage ? (v(),
|
|
423
|
-
L[6] || (L[6] =
|
|
424
|
-
|
|
425
|
-
])) :
|
|
426
|
-
|
|
427
|
-
|
|
420
|
+
}, null, 8, To)
|
|
421
|
+
], 512)) : J("", !0),
|
|
422
|
+
t.msg.errorMessage ? (v(), m("div", xo, [
|
|
423
|
+
L[6] || (L[6] = o("span", { class: "message-error__icon" }, "⚠️", -1)),
|
|
424
|
+
o("span", null, z(t.msg.errorMessage), 1)
|
|
425
|
+
])) : J("", !0),
|
|
426
|
+
r.value ? (v(), m("div", Do, [
|
|
427
|
+
o("div", {
|
|
428
428
|
class: "tooltip-enhanced",
|
|
429
|
-
"data-tooltip":
|
|
429
|
+
"data-tooltip": d.get(t.index) ? "已复制" : "复制回答"
|
|
430
430
|
}, [
|
|
431
|
-
|
|
431
|
+
d.get(t.index) ? (v(), pe(O(zn), {
|
|
432
432
|
key: 0,
|
|
433
433
|
class: "message-toolbar__check"
|
|
434
|
-
})) : (v(),
|
|
434
|
+
})) : (v(), pe(O(Kn), {
|
|
435
435
|
key: 1,
|
|
436
|
-
onClick: L[1] || (L[1] = (
|
|
436
|
+
onClick: L[1] || (L[1] = (S) => W(t.msg, t.index))
|
|
437
437
|
}))
|
|
438
|
-
], 8,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
onClick: L[2] || (L[2] = (
|
|
438
|
+
], 8, Mo),
|
|
439
|
+
o("div", Ro, [
|
|
440
|
+
ie(O(Gn), {
|
|
441
|
+
onClick: L[2] || (L[2] = (S) => y.$emit("regenerate"))
|
|
442
442
|
})
|
|
443
443
|
])
|
|
444
|
-
])) :
|
|
445
|
-
], 64)) : (v(),
|
|
446
|
-
(v(),
|
|
447
|
-
|
|
444
|
+
])) : J("", !0)
|
|
445
|
+
], 64)) : (v(), m("div", Ho, z(t.msg.content), 1)),
|
|
446
|
+
(v(), pe(Yt, { to: "#ai-assist-root" }, [
|
|
447
|
+
C.value ? (v(), m("div", {
|
|
448
448
|
key: 0,
|
|
449
449
|
class: "ai-image-preview-overlay",
|
|
450
|
-
onClick:
|
|
450
|
+
onClick: T
|
|
451
451
|
}, [
|
|
452
|
-
|
|
453
|
-
src:
|
|
452
|
+
o("img", {
|
|
453
|
+
src: C.value,
|
|
454
454
|
class: "ai-image-preview-overlay__img",
|
|
455
|
-
onClick: L[3] || (L[3] =
|
|
455
|
+
onClick: L[3] || (L[3] = fe(() => {
|
|
456
456
|
}, ["stop"]))
|
|
457
|
-
}, null, 8, $
|
|
458
|
-
|
|
457
|
+
}, null, 8, $o),
|
|
458
|
+
o("button", {
|
|
459
459
|
class: "ai-image-preview-overlay__close",
|
|
460
|
-
onClick:
|
|
460
|
+
onClick: fe(T, ["stop"])
|
|
461
461
|
}, [
|
|
462
|
-
|
|
462
|
+
ie(O(jn))
|
|
463
463
|
])
|
|
464
|
-
])) :
|
|
464
|
+
])) : J("", !0)
|
|
465
465
|
]))
|
|
466
466
|
], 2);
|
|
467
467
|
};
|
|
468
468
|
}
|
|
469
|
-
}),
|
|
469
|
+
}), Po = {
|
|
470
470
|
key: 0,
|
|
471
471
|
class: "input-container voice-mode"
|
|
472
|
-
},
|
|
472
|
+
}, Oo = {
|
|
473
473
|
key: 0,
|
|
474
474
|
class: "final"
|
|
475
|
-
},
|
|
475
|
+
}, Bo = {
|
|
476
476
|
key: 1,
|
|
477
477
|
class: "interim"
|
|
478
|
-
},
|
|
478
|
+
}, Wo = {
|
|
479
479
|
key: 2,
|
|
480
480
|
class: "placeholder"
|
|
481
|
-
},
|
|
481
|
+
}, Yo = ["onKeydown"], No = ["data-tooltip"], Vo = {
|
|
482
482
|
key: 2,
|
|
483
483
|
class: "moveTB"
|
|
484
|
-
},
|
|
484
|
+
}, Xo = {
|
|
485
485
|
key: 1,
|
|
486
486
|
class: "input-container"
|
|
487
|
-
},
|
|
487
|
+
}, Fo = ["value", "placeholder", "disabled"], Qo = {
|
|
488
488
|
key: 0,
|
|
489
489
|
class: "tooltip-enhanced stop",
|
|
490
490
|
"data-tooltip": "停止生成"
|
|
491
|
-
},
|
|
491
|
+
}, Jo = ["data-tooltip"], qo = {
|
|
492
492
|
key: 3,
|
|
493
493
|
class: "moveTB"
|
|
494
|
-
},
|
|
494
|
+
}, zo = 400, Ko = 10, Go = /* @__PURE__ */ Ee({
|
|
495
495
|
__name: "ChatInput",
|
|
496
496
|
props: {
|
|
497
497
|
modelValue: {},
|
|
498
498
|
isGenerating: { type: Boolean },
|
|
499
|
-
lastUserMessage: {},
|
|
500
499
|
hasScroll: { type: Boolean },
|
|
501
500
|
isAtBottom: { type: Boolean }
|
|
502
501
|
},
|
|
503
502
|
emits: ["update:modelValue", "send", "stop", "scroll-to-bottom"],
|
|
504
|
-
setup(t, { emit:
|
|
505
|
-
const i = t,
|
|
506
|
-
let
|
|
507
|
-
const
|
|
503
|
+
setup(t, { emit: w }) {
|
|
504
|
+
const i = t, u = w, l = g(!1), h = g(""), s = g(""), a = g("idle"), r = g(""), f = g(null), k = g(null), V = g(!1), p = g(!1);
|
|
505
|
+
let R = !1, X = null, K = null, G = !1, _ = !1, E = null;
|
|
506
|
+
const te = B(() => a.value === "connecting"), n = B(
|
|
508
507
|
() => a.value === "recording" || a.value === "stopping"
|
|
509
|
-
),
|
|
508
|
+
), d = B(
|
|
510
509
|
() => a.value === "connecting" || a.value === "recording" || a.value === "stopping"
|
|
511
|
-
),
|
|
512
|
-
() =>
|
|
513
|
-
),
|
|
514
|
-
() =>
|
|
510
|
+
), C = B(() => l.value && !d.value), D = B(
|
|
511
|
+
() => C.value ? !!r.value.trim() : !!(h.value.trim() || s.value.trim())
|
|
512
|
+
), T = B(
|
|
513
|
+
() => Qe.isSupported() && !i.modelValue.trim() && !i.isGenerating
|
|
514
|
+
), W = g(!1);
|
|
515
|
+
function y(P) {
|
|
516
|
+
P.pointerType === "mouse" && (W.value = !0);
|
|
517
|
+
}
|
|
518
|
+
function L(P) {
|
|
519
|
+
P.pointerType === "mouse" && (W.value = !1);
|
|
520
|
+
}
|
|
521
|
+
const ne = B(() => p.value ? "正在请求麦克风权限…" : W.value && T.value ? "发消息...(按住可语音输入)" : "发消息..."), S = B(
|
|
522
|
+
() => V.value ? "正在聆听…松手结束" : "正在聆听…点击结束"
|
|
515
523
|
);
|
|
516
|
-
function
|
|
517
|
-
|
|
518
|
-
onStatusChange: (
|
|
519
|
-
a.value =
|
|
524
|
+
function q() {
|
|
525
|
+
E = new Qe({}, {
|
|
526
|
+
onStatusChange: (P) => {
|
|
527
|
+
a.value = P;
|
|
520
528
|
},
|
|
521
|
-
onInterim: (
|
|
522
|
-
|
|
529
|
+
onInterim: (P) => {
|
|
530
|
+
s.value = P;
|
|
523
531
|
},
|
|
524
|
-
onFinal: (
|
|
525
|
-
|
|
532
|
+
onFinal: (P) => {
|
|
533
|
+
h.value += P, s.value = "";
|
|
526
534
|
},
|
|
527
535
|
onError: () => {
|
|
528
536
|
l.value = !1;
|
|
529
537
|
}
|
|
530
538
|
});
|
|
531
539
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}),
|
|
535
|
-
|
|
536
|
-
|
|
540
|
+
be(q), Nt(() => {
|
|
541
|
+
x(), E == null || E.destroy(), E = null;
|
|
542
|
+
}), ve([h, s], () => {
|
|
543
|
+
me(() => {
|
|
544
|
+
f.value && (f.value.scrollTop = f.value.scrollHeight);
|
|
537
545
|
});
|
|
538
|
-
}),
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
return
|
|
546
|
+
}), ve(a, (P) => {
|
|
547
|
+
if (P === "recording" && _) {
|
|
548
|
+
_ = !1, E == null || E.stop();
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
P === "idle" && l.value && (r.value = (h.value + s.value).trim(), me(() => {
|
|
552
|
+
var Q;
|
|
553
|
+
return (Q = k.value) == null ? void 0 : Q.focus();
|
|
542
554
|
}));
|
|
543
555
|
});
|
|
544
|
-
function
|
|
545
|
-
|
|
556
|
+
function N() {
|
|
557
|
+
d.value && (E == null || E.stop());
|
|
546
558
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
559
|
+
function b() {
|
|
560
|
+
window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H), window.removeEventListener("pointermove", Y), window.removeEventListener("blur", F);
|
|
561
|
+
}
|
|
562
|
+
function x() {
|
|
563
|
+
X !== null && (clearTimeout(X), X = null), K = null, b();
|
|
564
|
+
}
|
|
565
|
+
function M() {
|
|
566
|
+
a.value === "recording" ? E == null || E.stop() : (a.value === "connecting" || a.value === "stopping") && (_ = !0);
|
|
567
|
+
}
|
|
568
|
+
function $() {
|
|
569
|
+
const P = G;
|
|
570
|
+
G = !1, x(), P && M();
|
|
571
|
+
}
|
|
572
|
+
function Y(P) {
|
|
573
|
+
if (!K) return;
|
|
574
|
+
if (G) {
|
|
575
|
+
P.buttons === 0 && $();
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const Q = P.clientX - K.x, I = P.clientY - K.y;
|
|
579
|
+
Math.hypot(Q, I) > Ko && x();
|
|
580
|
+
}
|
|
581
|
+
function H() {
|
|
582
|
+
$();
|
|
583
|
+
}
|
|
584
|
+
function F() {
|
|
585
|
+
G && $();
|
|
586
|
+
}
|
|
587
|
+
function oe(P) {
|
|
588
|
+
T.value && (P.pointerType === "mouse" && P.button !== 0 || (K = { x: P.clientX, y: P.clientY }, G = !1, _ = !1, X !== null && clearTimeout(X), X = setTimeout(() => {
|
|
589
|
+
var I, ue, ge;
|
|
590
|
+
X = null, G = !0;
|
|
591
|
+
const Q = P.target;
|
|
592
|
+
Q && typeof Q.blur == "function" && Q.blur(), (ge = (ue = (I = window.getSelection) == null ? void 0 : I.call(window)) == null ? void 0 : ue.removeAllRanges) == null || ge.call(ue), le(!0);
|
|
593
|
+
}, zo), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H), window.addEventListener("pointermove", Y), window.addEventListener("blur", F)));
|
|
594
|
+
}
|
|
595
|
+
async function le(P = !1) {
|
|
596
|
+
if (!E || R) return;
|
|
597
|
+
p.value = !0, R = !0;
|
|
598
|
+
const { granted: Q, prompted: I } = await Qe.ensurePermission();
|
|
599
|
+
if (p.value = !1, R = !1, !Q) {
|
|
600
|
+
Te("麦克风不可用,请允许浏览器使用麦克风后重试");
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (P && !G) {
|
|
604
|
+
I && Te("麦克风已开启,请重新按住输入框开始说话", "info");
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
V.value = P, h.value = "", s.value = "", r.value = "", l.value = !0;
|
|
608
|
+
try {
|
|
609
|
+
await E.start();
|
|
610
|
+
} catch {
|
|
611
|
+
l.value = !1;
|
|
555
612
|
}
|
|
556
613
|
}
|
|
557
|
-
function
|
|
558
|
-
|
|
614
|
+
function de() {
|
|
615
|
+
E == null || E.cancel(), l.value = !1, V.value = !1, _ = !1, h.value = "", s.value = "", r.value = "";
|
|
559
616
|
}
|
|
560
|
-
function
|
|
561
|
-
const
|
|
562
|
-
|
|
617
|
+
function ke() {
|
|
618
|
+
const P = (C.value ? r.value : h.value + s.value).trim();
|
|
619
|
+
P && (E == null || E.stop(), l.value = !1, V.value = !1, _ = !1, u("update:modelValue", P), setTimeout(() => u("send"), 0));
|
|
563
620
|
}
|
|
564
|
-
return (
|
|
565
|
-
|
|
566
|
-
class:
|
|
621
|
+
return (P, Q) => l.value ? (v(), m("div", Po, [
|
|
622
|
+
o("div", {
|
|
623
|
+
class: se(["voice-visual", { recording: n.value }])
|
|
567
624
|
}, null, 2),
|
|
568
|
-
|
|
625
|
+
d.value ? (v(), m("div", {
|
|
569
626
|
key: 0,
|
|
570
627
|
class: "voice-text",
|
|
571
628
|
ref_key: "voiceTextEl",
|
|
572
|
-
ref:
|
|
573
|
-
onClick:
|
|
629
|
+
ref: f,
|
|
630
|
+
onClick: N
|
|
574
631
|
}, [
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
!
|
|
578
|
-
], 512)) :
|
|
632
|
+
h.value ? (v(), m("span", Oo, z(h.value), 1)) : J("", !0),
|
|
633
|
+
s.value ? (v(), m("span", Bo, z(s.value), 1)) : J("", !0),
|
|
634
|
+
!h.value && !s.value ? (v(), m("span", Wo, z(te.value ? "启动中…" : S.value), 1)) : J("", !0)
|
|
635
|
+
], 512)) : Me((v(), m("input", {
|
|
579
636
|
key: 1,
|
|
580
637
|
ref_key: "editorEl",
|
|
581
|
-
ref:
|
|
582
|
-
"onUpdate:modelValue":
|
|
638
|
+
ref: k,
|
|
639
|
+
"onUpdate:modelValue": Q[0] || (Q[0] = (I) => r.value = I),
|
|
583
640
|
type: "text",
|
|
584
641
|
class: "voice-editor",
|
|
585
642
|
placeholder: "识别结果,可点击直接修改…",
|
|
586
|
-
onKeydown: ct(
|
|
587
|
-
onKeyup:
|
|
588
|
-
}, null, 40,
|
|
589
|
-
[Vt,
|
|
643
|
+
onKeydown: ct(fe(de, ["prevent"]), ["esc"]),
|
|
644
|
+
onKeyup: Q[1] || (Q[1] = ct((I) => D.value && ke(), ["enter"]))
|
|
645
|
+
}, null, 40, Yo)), [
|
|
646
|
+
[Vt, r.value]
|
|
590
647
|
]),
|
|
591
|
-
|
|
648
|
+
o("div", {
|
|
592
649
|
class: "tooltip-enhanced voice-close",
|
|
593
650
|
"data-tooltip": "关闭",
|
|
594
|
-
onClick:
|
|
651
|
+
onClick: de
|
|
595
652
|
}, [
|
|
596
|
-
|
|
653
|
+
ie(O(ce), {
|
|
597
654
|
class: "op-icon",
|
|
598
655
|
icon: "heroicons-solid:x-mark"
|
|
599
656
|
})
|
|
600
657
|
]),
|
|
601
|
-
|
|
602
|
-
class:
|
|
603
|
-
"data-tooltip":
|
|
604
|
-
onClick:
|
|
658
|
+
o("div", {
|
|
659
|
+
class: se(["tooltip-enhanced voice-send", { disabled: !D.value }]),
|
|
660
|
+
"data-tooltip": D.value ? "发送" : "未识别到文字",
|
|
661
|
+
onClick: Q[2] || (Q[2] = (I) => D.value && ke())
|
|
605
662
|
}, [
|
|
606
|
-
|
|
663
|
+
ie(O(ce), {
|
|
607
664
|
class: "op-icon",
|
|
608
665
|
icon: "fluent-color:send-16"
|
|
609
666
|
})
|
|
610
|
-
], 10,
|
|
611
|
-
t.hasScroll && !t.isAtBottom ? (v(),
|
|
612
|
-
|
|
667
|
+
], 10, No),
|
|
668
|
+
t.hasScroll && !t.isAtBottom ? (v(), m("div", Vo, [
|
|
669
|
+
ie(O(ce), {
|
|
613
670
|
class: "op-icon",
|
|
614
671
|
icon: "ep:bottom",
|
|
615
|
-
onClick:
|
|
672
|
+
onClick: Q[3] || (Q[3] = (I) => P.$emit("scroll-to-bottom"))
|
|
616
673
|
})
|
|
617
|
-
])) :
|
|
618
|
-
])) : (v(),
|
|
619
|
-
|
|
674
|
+
])) : J("", !0)
|
|
675
|
+
])) : (v(), m("div", Xo, [
|
|
676
|
+
o("input", {
|
|
620
677
|
value: t.modelValue,
|
|
621
678
|
type: "text",
|
|
622
|
-
placeholder:
|
|
623
|
-
onInput:
|
|
624
|
-
onKeyup:
|
|
625
|
-
disabled: t.isGenerating
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
679
|
+
placeholder: ne.value,
|
|
680
|
+
onInput: Q[4] || (Q[4] = (I) => P.$emit("update:modelValue", I.target.value)),
|
|
681
|
+
onKeyup: Q[5] || (Q[5] = ct((I) => t.modelValue.trim() && P.$emit("send"), ["enter"])),
|
|
682
|
+
disabled: t.isGenerating,
|
|
683
|
+
onPointerdown: oe,
|
|
684
|
+
onPointerenter: y,
|
|
685
|
+
onPointerleave: L
|
|
686
|
+
}, null, 40, Fo),
|
|
687
|
+
t.isGenerating ? (v(), m("div", Qo, [
|
|
688
|
+
ie(O(ce), {
|
|
629
689
|
class: "op-icon stop-icon",
|
|
630
690
|
icon: "heroicons-solid:stop",
|
|
631
|
-
onClick:
|
|
691
|
+
onClick: Q[6] || (Q[6] = (I) => P.$emit("stop"))
|
|
632
692
|
})
|
|
633
|
-
])) :
|
|
693
|
+
])) : T.value ? (v(), m("div", {
|
|
634
694
|
key: 1,
|
|
635
695
|
class: "tooltip-enhanced send voice",
|
|
636
|
-
"data-tooltip": "
|
|
637
|
-
onClick:
|
|
696
|
+
"data-tooltip": "语音输入(也可按住输入框说话)",
|
|
697
|
+
onClick: Q[7] || (Q[7] = (I) => le())
|
|
638
698
|
}, [
|
|
639
|
-
|
|
699
|
+
ie(O(ce), {
|
|
640
700
|
class: "op-icon",
|
|
641
701
|
icon: "mingcute:voice-line"
|
|
642
702
|
})
|
|
643
|
-
])) : (v(),
|
|
703
|
+
])) : (v(), m("div", {
|
|
644
704
|
key: 2,
|
|
645
|
-
class:
|
|
705
|
+
class: se(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
|
|
646
706
|
"data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
|
|
647
707
|
}, [
|
|
648
|
-
|
|
708
|
+
ie(O(ce), {
|
|
649
709
|
class: "op-icon",
|
|
650
710
|
icon: "fluent-color:send-16",
|
|
651
|
-
onClick:
|
|
711
|
+
onClick: Q[8] || (Q[8] = (I) => t.modelValue.trim() && P.$emit("send"))
|
|
652
712
|
})
|
|
653
|
-
], 10,
|
|
654
|
-
t.hasScroll && !t.isAtBottom ? (v(),
|
|
655
|
-
|
|
713
|
+
], 10, Jo)),
|
|
714
|
+
t.hasScroll && !t.isAtBottom ? (v(), m("div", qo, [
|
|
715
|
+
ie(O(ce), {
|
|
656
716
|
class: "op-icon",
|
|
657
717
|
icon: "ep:bottom",
|
|
658
|
-
onClick:
|
|
718
|
+
onClick: Q[9] || (Q[9] = (I) => P.$emit("scroll-to-bottom"))
|
|
659
719
|
})
|
|
660
|
-
])) :
|
|
720
|
+
])) : J("", !0)
|
|
661
721
|
]));
|
|
662
722
|
}
|
|
663
723
|
});
|
|
664
|
-
function
|
|
665
|
-
const
|
|
666
|
-
function
|
|
667
|
-
const a =
|
|
668
|
-
if (
|
|
724
|
+
function jo(t) {
|
|
725
|
+
const w = g(!0), i = g(!1);
|
|
726
|
+
function u(s) {
|
|
727
|
+
const a = s.closest(".chat-wrap") || s, r = s.scrollHeight, f = s.clientHeight;
|
|
728
|
+
if (r <= f) {
|
|
669
729
|
a.style.setProperty("--ai-thumb-height", "0px"), a.style.setProperty("--ai-thumb-top", "0px");
|
|
670
730
|
return;
|
|
671
731
|
}
|
|
672
|
-
const
|
|
673
|
-
a.style.setProperty("--ai-thumb-height", `${
|
|
732
|
+
const k = Math.max(f * f / r, 32), V = f - k, p = s.scrollTop / (r - f);
|
|
733
|
+
a.style.setProperty("--ai-thumb-height", `${k}px`), a.style.setProperty("--ai-thumb-top", `${p * V}px`);
|
|
674
734
|
}
|
|
675
735
|
function l() {
|
|
676
|
-
|
|
736
|
+
me(() => {
|
|
677
737
|
t.value && (t.value.scrollTop = t.value.scrollHeight);
|
|
678
738
|
});
|
|
679
739
|
}
|
|
680
|
-
function
|
|
740
|
+
function h() {
|
|
681
741
|
if (!t.value) return;
|
|
682
|
-
const
|
|
683
|
-
|
|
742
|
+
const s = t.value, a = s.scrollTop + s.clientHeight >= s.scrollHeight - 1, r = s.scrollHeight > s.clientHeight;
|
|
743
|
+
w.value = a, i.value = r, u(s);
|
|
684
744
|
}
|
|
685
|
-
return { isAtBottom:
|
|
745
|
+
return { isAtBottom: w, hasScroll: i, scrollToBottom: l, checkScrollStatus: h };
|
|
686
746
|
}
|
|
687
|
-
function
|
|
688
|
-
function t(
|
|
689
|
-
|
|
690
|
-
if (
|
|
691
|
-
const l =
|
|
747
|
+
function Uo() {
|
|
748
|
+
function t(w) {
|
|
749
|
+
w.querySelectorAll("pre").forEach((u) => {
|
|
750
|
+
if (u.querySelector(".copy-button")) return;
|
|
751
|
+
const l = u.querySelector("code");
|
|
692
752
|
if (!l) return;
|
|
693
|
-
const
|
|
694
|
-
if (
|
|
695
|
-
const
|
|
696
|
-
|
|
753
|
+
const s = (Array.from(l.classList).find((r) => r.startsWith("language-")) || "").replace("language-", "");
|
|
754
|
+
if (s) {
|
|
755
|
+
const r = document.createElement("span");
|
|
756
|
+
r.className = "code-lang", r.textContent = s, u.appendChild(r);
|
|
697
757
|
}
|
|
698
758
|
const a = document.createElement("button");
|
|
699
759
|
a.className = "copy-button", a.textContent = "复制", a.onclick = () => {
|
|
@@ -702,165 +762,165 @@ function qs() {
|
|
|
702
762
|
a.textContent = "复制";
|
|
703
763
|
}, 2e3);
|
|
704
764
|
});
|
|
705
|
-
},
|
|
765
|
+
}, u.appendChild(a);
|
|
706
766
|
});
|
|
707
767
|
}
|
|
708
768
|
return { enhanceCodeBlocks: t };
|
|
709
769
|
}
|
|
710
|
-
function
|
|
711
|
-
let
|
|
712
|
-
function
|
|
713
|
-
|
|
714
|
-
i = 0,
|
|
770
|
+
function Zo(t) {
|
|
771
|
+
let w = null, i = 0;
|
|
772
|
+
function u(h) {
|
|
773
|
+
w = h(w || [...t.value]), i || (i = requestAnimationFrame(() => {
|
|
774
|
+
i = 0, w && (t.value = w, w = null);
|
|
715
775
|
}));
|
|
716
776
|
}
|
|
717
777
|
function l() {
|
|
718
|
-
i && (cancelAnimationFrame(i), i = 0),
|
|
778
|
+
i && (cancelAnimationFrame(i), i = 0), w && (t.value = w, w = null);
|
|
719
779
|
}
|
|
720
|
-
return { batchMessagesUpdate:
|
|
780
|
+
return { batchMessagesUpdate: u, flushMessagesBatch: l };
|
|
721
781
|
}
|
|
722
|
-
function
|
|
782
|
+
function Io({
|
|
723
783
|
messages: t,
|
|
724
|
-
isGenerating:
|
|
784
|
+
isGenerating: w,
|
|
725
785
|
lastUserMessage: i,
|
|
726
|
-
batchMessagesUpdate:
|
|
786
|
+
batchMessagesUpdate: u,
|
|
727
787
|
flushMessagesBatch: l,
|
|
728
|
-
STATUS:
|
|
729
|
-
cfg:
|
|
788
|
+
STATUS: h,
|
|
789
|
+
cfg: s
|
|
730
790
|
}) {
|
|
731
|
-
const a =
|
|
732
|
-
function
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
if (n[
|
|
736
|
-
const
|
|
737
|
-
return
|
|
791
|
+
const a = g(/* @__PURE__ */ new Map()), r = g(/* @__PURE__ */ new Map()), f = g(/* @__PURE__ */ new Map()), k = g(/* @__PURE__ */ new Map()), V = g(!1), p = g(/* @__PURE__ */ new Map()), R = g(/* @__PURE__ */ new Map()), X = g(!1);
|
|
792
|
+
function K(E) {
|
|
793
|
+
const te = a.value.get(E) || [];
|
|
794
|
+
u((n) => {
|
|
795
|
+
if (n[E]) {
|
|
796
|
+
const d = [...n];
|
|
797
|
+
return d[E] = { ...d[E], segments: te.map((C) => ({ ...C })) }, d;
|
|
738
798
|
}
|
|
739
799
|
return n;
|
|
740
800
|
});
|
|
741
801
|
}
|
|
742
|
-
function
|
|
743
|
-
const
|
|
744
|
-
let
|
|
745
|
-
|
|
746
|
-
if ((
|
|
747
|
-
const
|
|
748
|
-
|
|
802
|
+
function G(E) {
|
|
803
|
+
const te = a.value.get(E) || [], n = f.value.get(E), d = R.value.get(E);
|
|
804
|
+
let C = 0, D = !1;
|
|
805
|
+
te.forEach((T) => {
|
|
806
|
+
if ((T.type === "thinking" || T.type === "step") && T.duration == null) {
|
|
807
|
+
const y = (T.id != null ? d == null ? void 0 : d.get(T.id) : void 0) ?? n, L = y ? Math.round((Date.now() - y) / 1e3 * 10) / 10 : 0;
|
|
808
|
+
T.duration = L, T.type === "thinking" && (C += L), D = !0;
|
|
749
809
|
}
|
|
750
|
-
}),
|
|
751
|
-
if (
|
|
752
|
-
const
|
|
753
|
-
return
|
|
754
|
-
|
|
755
|
-
segments:
|
|
756
|
-
thinkingDuration: (
|
|
757
|
-
},
|
|
810
|
+
}), D && (a.value.set(E, te), u((T) => {
|
|
811
|
+
if (T[E]) {
|
|
812
|
+
const W = [...T];
|
|
813
|
+
return W[E] = {
|
|
814
|
+
...W[E],
|
|
815
|
+
segments: te.map((y) => ({ ...y })),
|
|
816
|
+
thinkingDuration: (W[E].thinkingDuration || 0) + C
|
|
817
|
+
}, W;
|
|
758
818
|
}
|
|
759
|
-
return
|
|
819
|
+
return T;
|
|
760
820
|
}));
|
|
761
821
|
}
|
|
762
|
-
async function
|
|
763
|
-
X.value = !1,
|
|
822
|
+
async function _(E, te, n, d, C = !1) {
|
|
823
|
+
X.value = !1, V.value = !1, a.value.set(n, []), p.value.set(n, /* @__PURE__ */ new Map()), R.value.set(n, /* @__PURE__ */ new Map()), w.value = !0;
|
|
764
824
|
try {
|
|
765
|
-
const
|
|
766
|
-
await Xn(
|
|
825
|
+
const D = s.baseUrl.replace(/\/+$/, "") + "/" + E.replace(/^\/+/, "");
|
|
826
|
+
await Xn(D, {
|
|
767
827
|
method: "POST",
|
|
768
828
|
headers: {
|
|
769
829
|
"Content-Type": "application/json",
|
|
770
|
-
Authorization: `Bearer ${
|
|
830
|
+
Authorization: `Bearer ${s.token}`
|
|
771
831
|
},
|
|
772
|
-
body: JSON.stringify({ app:
|
|
773
|
-
signal:
|
|
832
|
+
body: JSON.stringify({ app: s.app ?? 1, data: te }),
|
|
833
|
+
signal: d,
|
|
774
834
|
openWhenHidden: !0,
|
|
775
|
-
async onopen(
|
|
776
|
-
|
|
835
|
+
async onopen(T) {
|
|
836
|
+
T.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", T.status, T.statusText);
|
|
777
837
|
},
|
|
778
|
-
onmessage(
|
|
779
|
-
var
|
|
838
|
+
onmessage(T) {
|
|
839
|
+
var W, y, L, ne, S;
|
|
780
840
|
try {
|
|
781
|
-
let
|
|
782
|
-
for (;
|
|
783
|
-
|
|
784
|
-
if (!
|
|
785
|
-
let
|
|
841
|
+
let q = T.data || "";
|
|
842
|
+
for (; q.startsWith("data:"); )
|
|
843
|
+
q = q.replace(/^data:\s*/, "");
|
|
844
|
+
if (!q) return;
|
|
845
|
+
let N;
|
|
786
846
|
try {
|
|
787
|
-
|
|
847
|
+
N = JSON.parse(q);
|
|
788
848
|
} catch {
|
|
789
849
|
return;
|
|
790
850
|
}
|
|
791
|
-
switch (
|
|
851
|
+
switch (N.event) {
|
|
792
852
|
case "message_start":
|
|
793
|
-
|
|
853
|
+
C || (i.value = N.id), r.value.set(n, "answer");
|
|
794
854
|
break;
|
|
795
855
|
// ── 对话流型智能体:流程开始,标记进入 flow 协议 ──
|
|
796
856
|
case "flow_start":
|
|
797
|
-
|
|
857
|
+
V.value = !0;
|
|
798
858
|
break;
|
|
799
859
|
case "think_message_output_start": {
|
|
800
|
-
|
|
801
|
-
const
|
|
802
|
-
a.value.set(n, [...
|
|
860
|
+
f.value.set(n, Date.now()), r.value.set(n, "thinking");
|
|
861
|
+
const b = a.value.get(n) || [];
|
|
862
|
+
a.value.set(n, [...b, { type: "thinking", content: "" }]), K(n);
|
|
803
863
|
break;
|
|
804
864
|
}
|
|
805
865
|
case "agent_thought": {
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
if (
|
|
809
|
-
const
|
|
810
|
-
return
|
|
811
|
-
...
|
|
812
|
-
segments:
|
|
813
|
-
thinkingContent: (
|
|
814
|
-
status:
|
|
815
|
-
},
|
|
866
|
+
const b = N.thought || N.thinking || "", x = a.value.get(n) || [], M = x[x.length - 1];
|
|
867
|
+
M && M.type === "agent_thought" && M.duration == null ? M.content += b : (r.value.set(n, "agent_thought"), x.push({ type: "agent_thought", content: b }), k.value.set(n, Date.now())), a.value.set(n, x), u(($) => {
|
|
868
|
+
if ($[n]) {
|
|
869
|
+
const Y = [...$];
|
|
870
|
+
return Y[n] = {
|
|
871
|
+
...Y[n],
|
|
872
|
+
segments: x.map((H) => ({ ...H })),
|
|
873
|
+
thinkingContent: (Y[n].thinkingContent || "") + b,
|
|
874
|
+
status: h.THINKING
|
|
875
|
+
}, Y;
|
|
816
876
|
}
|
|
817
|
-
return
|
|
877
|
+
return $;
|
|
818
878
|
});
|
|
819
879
|
break;
|
|
820
880
|
}
|
|
821
881
|
case "think_message": {
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
if (
|
|
825
|
-
const
|
|
826
|
-
return
|
|
827
|
-
...
|
|
828
|
-
segments:
|
|
829
|
-
thinkingContent: (
|
|
830
|
-
status:
|
|
831
|
-
},
|
|
882
|
+
const b = N.thinking || N.answer || N.text || "", x = a.value.get(n) || [], M = x[x.length - 1];
|
|
883
|
+
M && M.type === "thinking" ? M.content += b : (x.push({ type: "thinking", content: b }), f.value.set(n, Date.now())), a.value.set(n, x), u(($) => {
|
|
884
|
+
if ($[n]) {
|
|
885
|
+
const Y = [...$];
|
|
886
|
+
return Y[n] = {
|
|
887
|
+
...Y[n],
|
|
888
|
+
segments: x.map((H) => ({ ...H })),
|
|
889
|
+
thinkingContent: (Y[n].thinkingContent || "") + b,
|
|
890
|
+
status: h.THINKING
|
|
891
|
+
}, Y;
|
|
832
892
|
}
|
|
833
|
-
return
|
|
893
|
+
return $;
|
|
834
894
|
});
|
|
835
895
|
break;
|
|
836
896
|
}
|
|
837
897
|
case "agent_thought_end": {
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
if (
|
|
841
|
-
const H = [...
|
|
898
|
+
const b = k.value.get(n), x = b ? Math.round((Date.now() - b) / 1e3 * 10) / 10 : 0, M = a.value.get(n) || [], $ = M[M.length - 1];
|
|
899
|
+
$ && $.type === "agent_thought" && ($.duration = x), a.value.set(n, M), u((Y) => {
|
|
900
|
+
if (Y[n]) {
|
|
901
|
+
const H = [...Y];
|
|
842
902
|
return H[n] = {
|
|
843
903
|
...H[n],
|
|
844
|
-
segments:
|
|
845
|
-
thinkingDuration: (H[n].thinkingDuration || 0) +
|
|
904
|
+
segments: M.map((F) => ({ ...F })),
|
|
905
|
+
thinkingDuration: (H[n].thinkingDuration || 0) + x
|
|
846
906
|
}, H;
|
|
847
907
|
}
|
|
848
|
-
return
|
|
908
|
+
return Y;
|
|
849
909
|
});
|
|
850
910
|
break;
|
|
851
911
|
}
|
|
852
912
|
case "think_message_output_end": {
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
if (
|
|
856
|
-
const H = [...
|
|
913
|
+
const b = f.value.get(n), x = b ? Math.round((Date.now() - b) / 1e3 * 10) / 10 : 0, M = a.value.get(n) || [], $ = M[M.length - 1];
|
|
914
|
+
$ && $.type === "thinking" && ($.duration = x), a.value.set(n, M), u((Y) => {
|
|
915
|
+
if (Y[n]) {
|
|
916
|
+
const H = [...Y];
|
|
857
917
|
return H[n] = {
|
|
858
918
|
...H[n],
|
|
859
|
-
segments:
|
|
860
|
-
thinkingDuration: (H[n].thinkingDuration || 0) +
|
|
919
|
+
segments: M.map((F) => ({ ...F })),
|
|
920
|
+
thinkingDuration: (H[n].thinkingDuration || 0) + x
|
|
861
921
|
}, H;
|
|
862
922
|
}
|
|
863
|
-
return
|
|
923
|
+
return Y;
|
|
864
924
|
});
|
|
865
925
|
break;
|
|
866
926
|
}
|
|
@@ -868,105 +928,105 @@ function js({
|
|
|
868
928
|
// message_config.reasoning === true 的步骤(如「正在思考」)归入深度思考,
|
|
869
929
|
// 其余(執行準備/資料獲取/...)归入流程步骤。
|
|
870
930
|
case "tool_message_output_start": {
|
|
871
|
-
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
type:
|
|
875
|
-
title:
|
|
876
|
-
id:
|
|
931
|
+
V.value = !0;
|
|
932
|
+
const b = ((W = N.message_config) == null ? void 0 : W.reasoning) === !0 || N.reasoning === !0, x = Date.now(), M = a.value.get(n) || [];
|
|
933
|
+
M.push({
|
|
934
|
+
type: b ? "thinking" : "step",
|
|
935
|
+
title: N.message_title || "",
|
|
936
|
+
id: N.id,
|
|
877
937
|
content: "",
|
|
878
|
-
reasoning:
|
|
938
|
+
reasoning: b
|
|
879
939
|
});
|
|
880
|
-
const
|
|
881
|
-
if (a.value.set(n,
|
|
882
|
-
const
|
|
883
|
-
|
|
940
|
+
const $ = M.length - 1;
|
|
941
|
+
if (a.value.set(n, M), r.value.set(n, b ? "thinking" : "step"), N.id != null) {
|
|
942
|
+
const Y = p.value.get(n) || /* @__PURE__ */ new Map();
|
|
943
|
+
Y.set(String(N.id), $), p.value.set(n, Y);
|
|
884
944
|
const H = R.value.get(n) || /* @__PURE__ */ new Map();
|
|
885
|
-
H.set(String(
|
|
945
|
+
H.set(String(N.id), x), R.value.set(n, H);
|
|
886
946
|
}
|
|
887
|
-
|
|
947
|
+
b && f.value.set(n, x), K(n);
|
|
888
948
|
break;
|
|
889
949
|
}
|
|
890
950
|
case "tool_message": {
|
|
891
|
-
const
|
|
892
|
-
if (!
|
|
893
|
-
const
|
|
894
|
-
if (
|
|
895
|
-
const
|
|
896
|
-
let
|
|
897
|
-
if (
|
|
898
|
-
const H = ((
|
|
899
|
-
if (
|
|
951
|
+
const b = N.answer || N.text || N.content || "";
|
|
952
|
+
if (!b) break;
|
|
953
|
+
const x = a.value.get(n) || [];
|
|
954
|
+
if (V.value) {
|
|
955
|
+
const M = N.id != null ? String(N.id) : null, $ = p.value.get(n);
|
|
956
|
+
let Y = M != null ? $ == null ? void 0 : $.get(M) : void 0;
|
|
957
|
+
if (Y == null || !x[Y]) {
|
|
958
|
+
const H = ((y = N.message_config) == null ? void 0 : y.reasoning) === !0 || N.reasoning === !0;
|
|
959
|
+
if (x.push({
|
|
900
960
|
type: H ? "thinking" : "step",
|
|
901
|
-
title:
|
|
902
|
-
id:
|
|
903
|
-
content:
|
|
961
|
+
title: N.message_title || "",
|
|
962
|
+
id: N.id,
|
|
963
|
+
content: b,
|
|
904
964
|
reasoning: H
|
|
905
|
-
}),
|
|
906
|
-
const
|
|
907
|
-
|
|
965
|
+
}), Y = x.length - 1, M != null) {
|
|
966
|
+
const F = $ || /* @__PURE__ */ new Map();
|
|
967
|
+
F.set(M, Y), p.value.set(n, F), H && f.value.set(n, Date.now());
|
|
908
968
|
}
|
|
909
969
|
} else {
|
|
910
|
-
const H =
|
|
911
|
-
|
|
970
|
+
const H = x[Y];
|
|
971
|
+
x[Y] = { ...H, content: H.content + b };
|
|
912
972
|
}
|
|
913
|
-
a.value.set(n,
|
|
973
|
+
a.value.set(n, x), u((H) => {
|
|
914
974
|
if (H[n]) {
|
|
915
|
-
const
|
|
916
|
-
return
|
|
917
|
-
...
|
|
918
|
-
segments:
|
|
919
|
-
status:
|
|
920
|
-
},
|
|
975
|
+
const F = [...H];
|
|
976
|
+
return F[n] = {
|
|
977
|
+
...F[n],
|
|
978
|
+
segments: x.map((oe) => ({ ...oe })),
|
|
979
|
+
status: h.THINKING
|
|
980
|
+
}, F;
|
|
921
981
|
}
|
|
922
982
|
return H;
|
|
923
983
|
});
|
|
924
984
|
break;
|
|
925
985
|
}
|
|
926
|
-
|
|
986
|
+
x.push({ type: "answer", content: b }), a.value.set(n, x), K(n);
|
|
927
987
|
break;
|
|
928
988
|
}
|
|
929
989
|
// ── 对话流型智能体:步骤/推理消息结束,记录该步骤耗时 ──
|
|
930
990
|
case "tool_message_output_end": {
|
|
931
|
-
const
|
|
932
|
-
let
|
|
933
|
-
(
|
|
934
|
-
const
|
|
991
|
+
const b = a.value.get(n) || [], x = N.id != null ? String(N.id) : null;
|
|
992
|
+
let M = x != null ? (L = p.value.get(n)) == null ? void 0 : L.get(x) : b.length - 1;
|
|
993
|
+
(M == null || !b[M]) && (M = b.length - 1);
|
|
994
|
+
const $ = (x != null ? (ne = R.value.get(n)) == null ? void 0 : ne.get(x) : void 0) ?? f.value.get(n), Y = $ ? Math.round((Date.now() - $) / 1e3 * 10) / 10 : 0;
|
|
935
995
|
let H = 0;
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
if (
|
|
939
|
-
const
|
|
940
|
-
return
|
|
941
|
-
...
|
|
942
|
-
segments:
|
|
943
|
-
...H ? { thinkingDuration: (
|
|
944
|
-
},
|
|
996
|
+
const F = b[M];
|
|
997
|
+
F && F.duration == null && (b[M] = { ...F, duration: Y }, F.type === "thinking" && (H = Y)), a.value.set(n, b), u((oe) => {
|
|
998
|
+
if (oe[n]) {
|
|
999
|
+
const le = [...oe];
|
|
1000
|
+
return le[n] = {
|
|
1001
|
+
...le[n],
|
|
1002
|
+
segments: b.map((de) => ({ ...de })),
|
|
1003
|
+
...H ? { thinkingDuration: (le[n].thinkingDuration || 0) + H } : {}
|
|
1004
|
+
}, le;
|
|
945
1005
|
}
|
|
946
|
-
return
|
|
1006
|
+
return oe;
|
|
947
1007
|
});
|
|
948
1008
|
break;
|
|
949
1009
|
}
|
|
950
1010
|
case "message_output_start":
|
|
951
|
-
|
|
1011
|
+
r.value.set(n, "answer"), G(n);
|
|
952
1012
|
break;
|
|
953
1013
|
// 对话流型智能体:回答输出结束 / 流程结束(状态统一由 message_end 收尾)
|
|
954
1014
|
case "message_output_end":
|
|
955
1015
|
case "flow_end":
|
|
956
1016
|
break;
|
|
957
1017
|
case "message": {
|
|
958
|
-
const
|
|
959
|
-
|
|
960
|
-
const
|
|
961
|
-
|
|
1018
|
+
const b = N.answer || "", x = r.value.get(n), M = a.value.get(n) || [], $ = M[M.length - 1];
|
|
1019
|
+
x === "answer" && $ && $.type === "answer" ? $.content += b : (G(n), r.value.set(n, "answer"), M.push({ type: "answer", content: b })), a.value.set(n, M);
|
|
1020
|
+
const Y = M.filter((H) => H.type === "answer").map((H) => H.content).join("");
|
|
1021
|
+
u((H) => {
|
|
962
1022
|
if (H[n]) {
|
|
963
|
-
const
|
|
964
|
-
return
|
|
965
|
-
...
|
|
966
|
-
segments:
|
|
967
|
-
content:
|
|
968
|
-
status: X.value ?
|
|
969
|
-
},
|
|
1023
|
+
const F = [...H];
|
|
1024
|
+
return F[n] = {
|
|
1025
|
+
...F[n],
|
|
1026
|
+
segments: M.map((oe) => ({ ...oe })),
|
|
1027
|
+
content: Y,
|
|
1028
|
+
status: X.value ? h.STOP : h.ANSWERING
|
|
1029
|
+
}, F;
|
|
970
1030
|
}
|
|
971
1031
|
return H;
|
|
972
1032
|
});
|
|
@@ -974,256 +1034,258 @@ function js({
|
|
|
974
1034
|
}
|
|
975
1035
|
case "message_end": {
|
|
976
1036
|
l();
|
|
977
|
-
const
|
|
978
|
-
|
|
1037
|
+
const b = [...t.value];
|
|
1038
|
+
b[n] && (b[n] = { ...b[n], status: X.value ? h.STOP : h.COMPLETED }), t.value = b, w.value = !1;
|
|
979
1039
|
break;
|
|
980
1040
|
}
|
|
981
1041
|
case "agent_error":
|
|
982
1042
|
case "message_failed": {
|
|
983
1043
|
l();
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
...
|
|
987
|
-
status:
|
|
988
|
-
content:
|
|
989
|
-
errorMessage:
|
|
990
|
-
}, t.value =
|
|
1044
|
+
const b = [...t.value];
|
|
1045
|
+
b[n] && (b[n] = {
|
|
1046
|
+
...b[n],
|
|
1047
|
+
status: h.ERROR,
|
|
1048
|
+
content: N.error_msg || N.message || "请求失败",
|
|
1049
|
+
errorMessage: N.error_msg || N.message || "请求失败"
|
|
1050
|
+
}, t.value = b), w.value = !1;
|
|
991
1051
|
break;
|
|
992
1052
|
}
|
|
993
1053
|
case "message_replace": {
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
if (
|
|
997
|
-
const
|
|
998
|
-
return
|
|
999
|
-
...
|
|
1000
|
-
segments:
|
|
1001
|
-
content:
|
|
1002
|
-
},
|
|
1054
|
+
const b = N.answer || "", x = a.value.get(n) || [], M = (S = x.map(($, Y) => ({ s: $, i: Y })).reverse().find(($) => $.s.type === "answer")) == null ? void 0 : S.i;
|
|
1055
|
+
M != null ? x[M] = { ...x[M], content: b } : x.push({ type: "answer", content: b }), a.value.set(n, x), u(($) => {
|
|
1056
|
+
if ($[n]) {
|
|
1057
|
+
const Y = [...$];
|
|
1058
|
+
return Y[n] = {
|
|
1059
|
+
...Y[n],
|
|
1060
|
+
segments: x.map((H) => ({ ...H })),
|
|
1061
|
+
content: b
|
|
1062
|
+
}, Y;
|
|
1003
1063
|
}
|
|
1004
|
-
return
|
|
1064
|
+
return $;
|
|
1005
1065
|
});
|
|
1006
1066
|
break;
|
|
1007
1067
|
}
|
|
1008
1068
|
case "message_cost": {
|
|
1009
|
-
const
|
|
1010
|
-
inputTokens:
|
|
1011
|
-
outputTokens:
|
|
1012
|
-
latency:
|
|
1013
|
-
latencyFirstResp:
|
|
1069
|
+
const b = {
|
|
1070
|
+
inputTokens: N.input_tokens || 0,
|
|
1071
|
+
outputTokens: N.output_tokens || 0,
|
|
1072
|
+
latency: N.latency || 0,
|
|
1073
|
+
latencyFirstResp: N.latency_first_resp
|
|
1014
1074
|
};
|
|
1015
|
-
|
|
1016
|
-
if (
|
|
1017
|
-
const
|
|
1018
|
-
return
|
|
1075
|
+
u((x) => {
|
|
1076
|
+
if (x[n]) {
|
|
1077
|
+
const M = [...x];
|
|
1078
|
+
return M[n] = { ...M[n], cost: b }, M;
|
|
1019
1079
|
}
|
|
1020
|
-
return
|
|
1080
|
+
return x;
|
|
1021
1081
|
});
|
|
1022
1082
|
break;
|
|
1023
1083
|
}
|
|
1024
1084
|
default:
|
|
1025
1085
|
}
|
|
1026
|
-
} catch (
|
|
1027
|
-
console.error("[ai-assist-sdk] onmessage 解析失败:",
|
|
1086
|
+
} catch (q) {
|
|
1087
|
+
console.error("[ai-assist-sdk] onmessage 解析失败:", q);
|
|
1028
1088
|
}
|
|
1029
1089
|
},
|
|
1030
1090
|
onclose() {
|
|
1031
|
-
l(),
|
|
1032
|
-
const
|
|
1033
|
-
|
|
1034
|
-
...
|
|
1035
|
-
content: X.value &&
|
|
1036
|
-
status: X.value ?
|
|
1037
|
-
}), t.value =
|
|
1091
|
+
l(), G(n), l();
|
|
1092
|
+
const W = (a.value.get(n) || []).filter((L) => L.type === "answer").map((L) => L.content).join(""), y = [...t.value];
|
|
1093
|
+
y[n] && y[n].status !== h.ERROR && (y[n] = {
|
|
1094
|
+
...y[n],
|
|
1095
|
+
content: X.value && !W ? "已停止回答" : W,
|
|
1096
|
+
status: X.value ? h.STOP : h.COMPLETED
|
|
1097
|
+
}), t.value = y, w.value = !1;
|
|
1038
1098
|
},
|
|
1039
|
-
onerror(
|
|
1040
|
-
console.error("[ai-assist-sdk] ❌ 连接错误:",
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
⚠️ 请求异常,已终止`, status:
|
|
1099
|
+
onerror(T) {
|
|
1100
|
+
console.error("[ai-assist-sdk] ❌ 连接错误:", T), l();
|
|
1101
|
+
const W = [...t.value];
|
|
1102
|
+
W[n] && (W[n] = { ...W[n], content: `
|
|
1103
|
+
⚠️ 请求异常,已终止`, status: h.ERROR }), t.value = W, w.value = !1;
|
|
1044
1104
|
}
|
|
1045
1105
|
});
|
|
1046
|
-
} catch (
|
|
1047
|
-
if (console.error("[ai-assist-sdk] doStreamRequest error:",
|
|
1106
|
+
} catch (D) {
|
|
1107
|
+
if (console.error("[ai-assist-sdk] doStreamRequest error:", D), !X.value) {
|
|
1048
1108
|
l();
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1109
|
+
const T = [...t.value];
|
|
1110
|
+
T[n] && (T[n] = { ...T[n], content: "服务连接失败,请稍后重试", status: h.ERROR }), t.value = T, w.value = !1;
|
|
1051
1111
|
}
|
|
1052
1112
|
}
|
|
1053
1113
|
}
|
|
1054
|
-
return { doStreamRequest:
|
|
1114
|
+
return { doStreamRequest: _, issTop: X };
|
|
1055
1115
|
}
|
|
1056
1116
|
function Lt(t) {
|
|
1057
|
-
var
|
|
1117
|
+
var w;
|
|
1058
1118
|
if (t && typeof t == "object" && typeof t.data == "string" && (t = t.data), typeof t == "string") {
|
|
1059
1119
|
const i = t.split(`
|
|
1060
1120
|
`);
|
|
1061
|
-
let
|
|
1121
|
+
let u = "";
|
|
1062
1122
|
for (const l of i) {
|
|
1063
|
-
const
|
|
1064
|
-
if (
|
|
1123
|
+
const h = l.startsWith("data:") ? l.slice(5).trim() : "";
|
|
1124
|
+
if (h)
|
|
1065
1125
|
try {
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1126
|
+
const s = JSON.parse(h);
|
|
1127
|
+
s.event === "message" && s.answer !== void 0 && (u += s.answer);
|
|
1068
1128
|
} catch {
|
|
1069
1129
|
}
|
|
1070
1130
|
}
|
|
1071
|
-
return
|
|
1131
|
+
return u || t;
|
|
1072
1132
|
}
|
|
1073
|
-
return (t == null ? void 0 : t.answer) || ((
|
|
1133
|
+
return (t == null ? void 0 : t.answer) || ((w = t == null ? void 0 : t.data) == null ? void 0 : w.answer) || String(t || "");
|
|
1074
1134
|
}
|
|
1075
|
-
function
|
|
1135
|
+
function es(t) {
|
|
1076
1136
|
return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
|
|
1077
1137
|
}
|
|
1078
|
-
function
|
|
1138
|
+
function ts({
|
|
1079
1139
|
messages: t,
|
|
1080
|
-
userInput:
|
|
1140
|
+
userInput: w,
|
|
1081
1141
|
isGenerating: i,
|
|
1082
|
-
lastUserMessage:
|
|
1142
|
+
lastUserMessage: u,
|
|
1083
1143
|
conversationId: l,
|
|
1084
|
-
doStreamRequest:
|
|
1085
|
-
issTop:
|
|
1144
|
+
doStreamRequest: h,
|
|
1145
|
+
issTop: s,
|
|
1086
1146
|
scrollToBottom: a,
|
|
1087
|
-
STATUS:
|
|
1088
|
-
cfg:
|
|
1089
|
-
onTitleGenerated:
|
|
1147
|
+
STATUS: r,
|
|
1148
|
+
cfg: f,
|
|
1149
|
+
onTitleGenerated: k
|
|
1090
1150
|
}) {
|
|
1091
|
-
const
|
|
1151
|
+
const V = f.apis, p = ye({
|
|
1092
1152
|
first: new AbortController(),
|
|
1093
1153
|
again: new AbortController()
|
|
1094
|
-
}), R =
|
|
1095
|
-
async function X(
|
|
1096
|
-
var
|
|
1097
|
-
if (!
|
|
1098
|
-
let
|
|
1099
|
-
if (!
|
|
1154
|
+
}), R = g(!1);
|
|
1155
|
+
async function X(d, C) {
|
|
1156
|
+
var T;
|
|
1157
|
+
if (!f.titleGenerateApp || !V.updateConversationApi || R.value) return;
|
|
1158
|
+
let D = l.value;
|
|
1159
|
+
if (!D)
|
|
1100
1160
|
try {
|
|
1101
|
-
const
|
|
1102
|
-
(
|
|
1103
|
-
} catch (
|
|
1104
|
-
console.error("[ai-assist-sdk] 创建会话失败:",
|
|
1161
|
+
const W = await Mt(V);
|
|
1162
|
+
(T = W == null ? void 0 : W.conversation) != null && T.appConversationID && (D = W.conversation.appConversationID, l.value = D);
|
|
1163
|
+
} catch (W) {
|
|
1164
|
+
console.error("[ai-assist-sdk] 创建会话失败:", W);
|
|
1105
1165
|
return;
|
|
1106
1166
|
}
|
|
1107
|
-
if (
|
|
1167
|
+
if (D)
|
|
1108
1168
|
try {
|
|
1109
|
-
const
|
|
1110
|
-
if (
|
|
1111
|
-
const
|
|
1112
|
-
AI回答:${
|
|
1113
|
-
app:
|
|
1114
|
-
data: { Query: L, AppConversationID:
|
|
1115
|
-
}),
|
|
1116
|
-
|
|
1117
|
-
} catch (
|
|
1118
|
-
console.error("[ai-assist-sdk] 生成对话标题失败:",
|
|
1169
|
+
const W = await En(V, f.titleGenerateApp);
|
|
1170
|
+
if (!W) return;
|
|
1171
|
+
const y = C.length > 500 ? C.slice(0, 500) : C, L = `用户提问:${d}
|
|
1172
|
+
AI回答:${y}`, S = await Rt().post(V.chatQueryApi, {
|
|
1173
|
+
app: f.titleGenerateApp,
|
|
1174
|
+
data: { Query: L, AppConversationID: W }
|
|
1175
|
+
}), q = Lt(S.data.data);
|
|
1176
|
+
q && (await Tn(V, D, q), R.value = !0, k == null || k(q));
|
|
1177
|
+
} catch (W) {
|
|
1178
|
+
console.error("[ai-assist-sdk] 生成对话标题失败:", W);
|
|
1119
1179
|
}
|
|
1120
1180
|
}
|
|
1121
|
-
async function
|
|
1122
|
-
var
|
|
1123
|
-
const
|
|
1124
|
-
if (!
|
|
1125
|
-
if (!l.value && (await
|
|
1126
|
-
|
|
1181
|
+
async function K() {
|
|
1182
|
+
var W;
|
|
1183
|
+
const d = w.value.trim();
|
|
1184
|
+
if (!d || i.value) return;
|
|
1185
|
+
if (!l.value && (await te(), !l.value)) {
|
|
1186
|
+
Te("创建会话失败,请重试");
|
|
1127
1187
|
return;
|
|
1128
1188
|
}
|
|
1129
|
-
const
|
|
1189
|
+
const C = t.value.length === 0;
|
|
1130
1190
|
try {
|
|
1131
|
-
(
|
|
1191
|
+
(W = f.onMessageSend) == null || W.call(f, { text: d, isFirstMessage: C, conversationId: l.value });
|
|
1132
1192
|
} catch {
|
|
1133
1193
|
}
|
|
1134
|
-
const
|
|
1194
|
+
const D = [
|
|
1135
1195
|
...t.value,
|
|
1136
|
-
{ type: "user", content:
|
|
1196
|
+
{ type: "user", content: d },
|
|
1137
1197
|
// streamed:标记该条由实时流产生,前端按序逐字揭示(后端批量转发,终态可能早于渲染)
|
|
1138
|
-
{ type: "ai", content: "", status:
|
|
1198
|
+
{ type: "ai", content: "", status: r.THINKING, streamed: !0 }
|
|
1139
1199
|
];
|
|
1140
|
-
t.value =
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:",
|
|
1144
|
-
Query:
|
|
1200
|
+
t.value = D, w.value = "", a();
|
|
1201
|
+
const T = D.length - 1;
|
|
1202
|
+
if (V.chatQueryStreamApi) {
|
|
1203
|
+
if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", V.chatQueryStreamApi), await h(V.chatQueryStreamApi, {
|
|
1204
|
+
Query: d,
|
|
1145
1205
|
AppConversationID: l.value,
|
|
1146
1206
|
ResponseMode: "streaming"
|
|
1147
|
-
},
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1207
|
+
}, T, p.first.signal), C && !R.value) {
|
|
1208
|
+
const y = t.value[T];
|
|
1209
|
+
y && y.status !== r.ERROR && X(d, y.content);
|
|
1150
1210
|
}
|
|
1151
1211
|
return;
|
|
1152
1212
|
}
|
|
1153
1213
|
console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
|
|
1154
1214
|
try {
|
|
1155
|
-
const L = await Rt().post(
|
|
1156
|
-
app:
|
|
1157
|
-
data: { Query:
|
|
1158
|
-
}),
|
|
1159
|
-
t.value = [...t.value.slice(0, -1), { type: "ai", content:
|
|
1160
|
-
} catch (
|
|
1161
|
-
t.value = [...t.value.slice(0, -1), { type: "ai", content: (
|
|
1215
|
+
const L = await Rt().post(V.chatQueryApi, {
|
|
1216
|
+
app: f.app ?? 1,
|
|
1217
|
+
data: { Query: d, AppConversationID: l.value }
|
|
1218
|
+
}), ne = Lt(L.data);
|
|
1219
|
+
t.value = [...t.value.slice(0, -1), { type: "ai", content: ne, status: r.COMPLETED }], C && !R.value && X(d, ne);
|
|
1220
|
+
} catch (y) {
|
|
1221
|
+
t.value = [...t.value.slice(0, -1), { type: "ai", content: (y == null ? void 0 : y.message) || "服务连接失败,请稍后重试", status: r.ERROR }];
|
|
1162
1222
|
}
|
|
1163
1223
|
}
|
|
1164
|
-
async function
|
|
1165
|
-
if (!
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
const
|
|
1170
|
-
await
|
|
1171
|
-
MessageID:
|
|
1224
|
+
async function G() {
|
|
1225
|
+
if (!u.value || i.value) return;
|
|
1226
|
+
p.again.abort(), p.again = new AbortController();
|
|
1227
|
+
const d = [...t.value];
|
|
1228
|
+
d.length > 0 && d[d.length - 1].type === "ai" && d.pop(), d.push({ type: "ai", content: "", status: r.RETHINKING, streamed: !0 }), t.value = d, a();
|
|
1229
|
+
const C = t.value.length - 1, D = es(V);
|
|
1230
|
+
await h(D, {
|
|
1231
|
+
MessageID: u.value,
|
|
1172
1232
|
AppConversationID: l.value,
|
|
1173
1233
|
ResponseMode: "streaming"
|
|
1174
|
-
},
|
|
1234
|
+
}, C, p.again.signal, !0);
|
|
1175
1235
|
}
|
|
1176
|
-
async function
|
|
1177
|
-
if (!
|
|
1178
|
-
const
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1236
|
+
async function _() {
|
|
1237
|
+
if (!i.value) return;
|
|
1238
|
+
const d = t.value.length - 1 - 1;
|
|
1239
|
+
if (u.value && V.stopMessageApi)
|
|
1240
|
+
try {
|
|
1241
|
+
await Sn(V, u.value);
|
|
1242
|
+
} catch (D) {
|
|
1243
|
+
const T = [...t.value];
|
|
1244
|
+
T[d] && (T[d] = { ...T[d], content: (D == null ? void 0 : D.message) || "系统繁忙,请稍后再试", status: r.ERROR }), t.value = T;
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
const C = [...t.value];
|
|
1248
|
+
C[d] && (C[d] = { ...C[d], content: C[d].content || "已停止回答", status: r.STOP }), t.value = C, i.value = !1, p.first.abort(), p.first = new AbortController(), p.again.abort(), p.again = new AbortController(), s.value = !0;
|
|
1187
1249
|
}
|
|
1188
|
-
async function
|
|
1189
|
-
var
|
|
1190
|
-
l.value =
|
|
1250
|
+
async function E(d) {
|
|
1251
|
+
var C;
|
|
1252
|
+
l.value = d, R.value = !0;
|
|
1191
1253
|
try {
|
|
1192
|
-
const
|
|
1193
|
-
for (const
|
|
1194
|
-
|
|
1195
|
-
t.value =
|
|
1196
|
-
} catch (
|
|
1197
|
-
|
|
1254
|
+
const D = await bn(V, d), T = [], W = An(D == null ? void 0 : D.messages);
|
|
1255
|
+
for (const y of W)
|
|
1256
|
+
y.query && T.push({ type: "user", content: y.query }), (C = y.answerInfo) != null && C.answer && T.push({ type: "ai", content: y.answerInfo.answer, status: r.COMPLETED });
|
|
1257
|
+
t.value = T, a();
|
|
1258
|
+
} catch (D) {
|
|
1259
|
+
Te((D == null ? void 0 : D.message) || "加载历史会话失败");
|
|
1198
1260
|
}
|
|
1199
1261
|
}
|
|
1200
|
-
async function
|
|
1201
|
-
var
|
|
1262
|
+
async function te() {
|
|
1263
|
+
var d;
|
|
1202
1264
|
R.value = !1;
|
|
1203
1265
|
try {
|
|
1204
|
-
const
|
|
1205
|
-
(
|
|
1206
|
-
} catch (
|
|
1207
|
-
|
|
1266
|
+
const C = await Mt(V);
|
|
1267
|
+
(d = C == null ? void 0 : C.conversation) != null && d.appConversationID && (l.value = C.conversation.appConversationID);
|
|
1268
|
+
} catch (C) {
|
|
1269
|
+
Te((C == null ? void 0 : C.message) || "创建会话失败");
|
|
1208
1270
|
}
|
|
1209
1271
|
}
|
|
1210
1272
|
function n() {
|
|
1211
1273
|
l.value = "", R.value = !1;
|
|
1212
1274
|
}
|
|
1213
|
-
return { sendMessage:
|
|
1275
|
+
return { sendMessage: K, regenerateResponse: G, toggleStop: _, goHistoryMessage: E, initConversation: te, resetConversation: n, controllers: p };
|
|
1214
1276
|
}
|
|
1215
|
-
const
|
|
1277
|
+
const ns = { class: "container" }, os = { class: "chat-wrap" }, ss = { class: "message ai-message greet-message" }, as = { class: "ai-greet" }, is = ["src"], ls = {
|
|
1216
1278
|
key: 0,
|
|
1217
1279
|
class: "message ai-message recommend-message"
|
|
1218
|
-
},
|
|
1280
|
+
}, us = { class: "ai-recommend" }, rs = { class: "recommend-header" }, cs = ["src"], vs = ["onClick"], ds = /* @__PURE__ */ Ee({
|
|
1219
1281
|
__name: "Answer",
|
|
1220
1282
|
props: {
|
|
1221
1283
|
defaultSayhello: {},
|
|
1222
1284
|
defaultRecommend: {}
|
|
1223
1285
|
},
|
|
1224
1286
|
emits: ["title-generated"],
|
|
1225
|
-
setup(t, { expose:
|
|
1226
|
-
const
|
|
1287
|
+
setup(t, { expose: w, emit: i }) {
|
|
1288
|
+
const u = {
|
|
1227
1289
|
THINKING: "thinking",
|
|
1228
1290
|
RETHINKING: "rethinking",
|
|
1229
1291
|
ANSWERING: "answering",
|
|
@@ -1231,448 +1293,447 @@ const Is = { class: "container" }, eo = { class: "chat-wrap" }, to = { class: "m
|
|
|
1231
1293
|
COMPLETED: "completed",
|
|
1232
1294
|
STOP: "stop",
|
|
1233
1295
|
ERROR: "error"
|
|
1234
|
-
}, l = t,
|
|
1235
|
-
() => X.value[
|
|
1296
|
+
}, l = t, h = i, s = qe(), a = g([]), r = g(""), f = g(!1), k = g(""), V = g(""), p = g(null), R = ye({ text1: "", text2: "" }), X = g([]), K = g(0), G = B(
|
|
1297
|
+
() => X.value[K.value % (X.value.length || 1)]
|
|
1236
1298
|
);
|
|
1237
|
-
function
|
|
1238
|
-
|
|
1299
|
+
function _() {
|
|
1300
|
+
K.value++;
|
|
1239
1301
|
}
|
|
1240
|
-
function
|
|
1241
|
-
|
|
1302
|
+
function E(j) {
|
|
1303
|
+
r.value = j;
|
|
1242
1304
|
}
|
|
1243
|
-
const { isAtBottom:
|
|
1305
|
+
const { isAtBottom: te, hasScroll: n, scrollToBottom: d, checkScrollStatus: C } = jo(p), { enhanceCodeBlocks: D } = Uo(), { batchMessagesUpdate: T, flushMessagesBatch: W } = Zo(a), { doStreamRequest: y, issTop: L } = Io({
|
|
1244
1306
|
messages: a,
|
|
1245
|
-
isGenerating:
|
|
1246
|
-
lastUserMessage:
|
|
1247
|
-
batchMessagesUpdate:
|
|
1248
|
-
flushMessagesBatch:
|
|
1249
|
-
STATUS:
|
|
1250
|
-
cfg:
|
|
1251
|
-
}), { sendMessage:
|
|
1307
|
+
isGenerating: f,
|
|
1308
|
+
lastUserMessage: k,
|
|
1309
|
+
batchMessagesUpdate: T,
|
|
1310
|
+
flushMessagesBatch: W,
|
|
1311
|
+
STATUS: u,
|
|
1312
|
+
cfg: s
|
|
1313
|
+
}), { sendMessage: ne, regenerateResponse: S, toggleStop: q, goHistoryMessage: N, resetConversation: b } = ts({
|
|
1252
1314
|
messages: a,
|
|
1253
|
-
userInput:
|
|
1254
|
-
isGenerating:
|
|
1255
|
-
lastUserMessage:
|
|
1256
|
-
conversationId:
|
|
1257
|
-
doStreamRequest:
|
|
1315
|
+
userInput: r,
|
|
1316
|
+
isGenerating: f,
|
|
1317
|
+
lastUserMessage: k,
|
|
1318
|
+
conversationId: V,
|
|
1319
|
+
doStreamRequest: y,
|
|
1258
1320
|
issTop: L,
|
|
1259
|
-
scrollToBottom:
|
|
1260
|
-
STATUS:
|
|
1261
|
-
cfg:
|
|
1262
|
-
onTitleGenerated: (
|
|
1321
|
+
scrollToBottom: d,
|
|
1322
|
+
STATUS: u,
|
|
1323
|
+
cfg: s,
|
|
1324
|
+
onTitleGenerated: (j) => h("title-generated", j)
|
|
1263
1325
|
});
|
|
1264
|
-
function
|
|
1265
|
-
a.value = [],
|
|
1266
|
-
}
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
const
|
|
1270
|
-
function
|
|
1271
|
-
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
}),
|
|
1326
|
+
function x() {
|
|
1327
|
+
a.value = [], k.value = "", b();
|
|
1328
|
+
}
|
|
1329
|
+
const M = B(() => a.value.length === 0);
|
|
1330
|
+
w({ goHistoryMessage: N, createNewConversation: x, isEmptyConversation: M });
|
|
1331
|
+
const $ = g(/* @__PURE__ */ new Map());
|
|
1332
|
+
function Y(j, Z) {
|
|
1333
|
+
j ? $.value.set(Z, j) : $.value.delete(Z);
|
|
1334
|
+
}
|
|
1335
|
+
ve(a, () => {
|
|
1336
|
+
me(() => {
|
|
1337
|
+
$.value.forEach((j) => {
|
|
1338
|
+
D(j);
|
|
1339
|
+
}), C();
|
|
1278
1340
|
});
|
|
1279
1341
|
}, { deep: !0 });
|
|
1280
1342
|
let H = null;
|
|
1281
|
-
|
|
1343
|
+
be(() => {
|
|
1282
1344
|
l.defaultSayhello && (R.text1 = l.defaultSayhello.text1, R.text2 = l.defaultSayhello.text2), l.defaultRecommend && (X.value = xn(l.defaultRecommend));
|
|
1283
|
-
}),
|
|
1284
|
-
|
|
1345
|
+
}), be(() => {
|
|
1346
|
+
p.value && (H = () => C(), p.value.addEventListener("scroll", H), C());
|
|
1285
1347
|
});
|
|
1286
|
-
const
|
|
1287
|
-
let
|
|
1288
|
-
function
|
|
1289
|
-
var
|
|
1290
|
-
const
|
|
1291
|
-
return parseFloat((
|
|
1292
|
-
}
|
|
1293
|
-
function
|
|
1294
|
-
return "touches" in
|
|
1295
|
-
}
|
|
1296
|
-
function
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
function
|
|
1301
|
-
const
|
|
1302
|
-
if (!
|
|
1303
|
-
|
|
1304
|
-
const
|
|
1305
|
-
|
|
1306
|
-
}
|
|
1307
|
-
function
|
|
1308
|
-
|
|
1309
|
-
}
|
|
1310
|
-
function
|
|
1311
|
-
const
|
|
1312
|
-
if (!
|
|
1313
|
-
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
return
|
|
1318
|
-
|
|
1319
|
-
}), (
|
|
1320
|
-
var
|
|
1321
|
-
return v(),
|
|
1322
|
-
|
|
1323
|
-
|
|
1348
|
+
const F = g(null);
|
|
1349
|
+
let oe = !1, le = 0, de = 0;
|
|
1350
|
+
function ke(j) {
|
|
1351
|
+
var ae;
|
|
1352
|
+
const Z = (ae = p.value) == null ? void 0 : ae.closest(".chat-wrap");
|
|
1353
|
+
return parseFloat((Z == null ? void 0 : Z.style.getPropertyValue(j)) ?? "") || 0;
|
|
1354
|
+
}
|
|
1355
|
+
function P(j) {
|
|
1356
|
+
return "touches" in j ? j.touches[0].clientY : j.clientY;
|
|
1357
|
+
}
|
|
1358
|
+
function Q(j) {
|
|
1359
|
+
const Z = p.value;
|
|
1360
|
+
Z && (j.preventDefault(), oe = !0, le = P(j), Z.scrollTop, de = ke("--ai-thumb-top"), window.addEventListener("mousemove", I), window.addEventListener("mouseup", ue), window.addEventListener("touchmove", I, { passive: !1 }), window.addEventListener("touchend", ue));
|
|
1361
|
+
}
|
|
1362
|
+
function I(j) {
|
|
1363
|
+
const Z = p.value;
|
|
1364
|
+
if (!oe || !Z) return;
|
|
1365
|
+
j.preventDefault();
|
|
1366
|
+
const ae = P(j) - le, ee = Z.clientHeight, Ce = Z.scrollHeight, Re = ke("--ai-thumb-height"), ze = ee - Re, lt = Math.min(Math.max(de + ae, 0), ze);
|
|
1367
|
+
Z.scrollTop = lt / ze * (Ce - ee);
|
|
1368
|
+
}
|
|
1369
|
+
function ue() {
|
|
1370
|
+
oe = !1, window.removeEventListener("mousemove", I), window.removeEventListener("mouseup", ue), window.removeEventListener("touchmove", I), window.removeEventListener("touchend", ue);
|
|
1371
|
+
}
|
|
1372
|
+
function ge(j) {
|
|
1373
|
+
const Z = p.value, ae = F.value;
|
|
1374
|
+
if (!Z || !ae) return;
|
|
1375
|
+
j.preventDefault();
|
|
1376
|
+
const ee = ae.getBoundingClientRect(), Re = (P(j) - ee.top) / ee.height;
|
|
1377
|
+
Z.scrollTop = Re * (Z.scrollHeight - Z.clientHeight);
|
|
1378
|
+
}
|
|
1379
|
+
return Pe(() => {
|
|
1380
|
+
p.value && H && p.value.removeEventListener("scroll", H), ue();
|
|
1381
|
+
}), (j, Z) => {
|
|
1382
|
+
var ae;
|
|
1383
|
+
return v(), m("div", ns, [
|
|
1384
|
+
o("div", os, [
|
|
1385
|
+
o("div", {
|
|
1324
1386
|
class: "chat-box scrollWrap",
|
|
1325
1387
|
ref_key: "chatBoxRef",
|
|
1326
|
-
ref:
|
|
1388
|
+
ref: p
|
|
1327
1389
|
}, [
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1390
|
+
o("div", ss, [
|
|
1391
|
+
o("div", as, [
|
|
1392
|
+
o("img", { src: O(Qt) }, null, 8, is),
|
|
1393
|
+
o("h1", null, z(R.text1), 1),
|
|
1394
|
+
o("p", null, z(R.text2), 1)
|
|
1333
1395
|
])
|
|
1334
1396
|
]),
|
|
1335
|
-
(
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1397
|
+
(ae = G.value) != null && ae.length ? (v(), m("div", ls, [
|
|
1398
|
+
o("div", us, [
|
|
1399
|
+
o("div", rs, [
|
|
1400
|
+
Z[2] || (Z[2] = o("span", null, "你可以尝试这样问我:", -1)),
|
|
1401
|
+
o("p", {
|
|
1340
1402
|
class: "refresh-btn",
|
|
1341
|
-
onClick:
|
|
1403
|
+
onClick: _
|
|
1342
1404
|
}, [
|
|
1343
|
-
|
|
1344
|
-
|
|
1405
|
+
o("img", { src: O(Un) }, null, 8, cs),
|
|
1406
|
+
Z[1] || (Z[1] = o("span", null, "换一换", -1))
|
|
1345
1407
|
])
|
|
1346
1408
|
]),
|
|
1347
|
-
|
|
1348
|
-
(v(!0),
|
|
1349
|
-
key:
|
|
1350
|
-
onClick: (
|
|
1351
|
-
},
|
|
1409
|
+
o("ul", null, [
|
|
1410
|
+
(v(!0), m(we, null, xe(G.value, (ee, Ce) => (v(), m("li", {
|
|
1411
|
+
key: Ce,
|
|
1412
|
+
onClick: (Re) => E(ee)
|
|
1413
|
+
}, z(ee), 9, vs))), 128))
|
|
1352
1414
|
])
|
|
1353
1415
|
])
|
|
1354
|
-
])) :
|
|
1355
|
-
(v(!0),
|
|
1356
|
-
key:
|
|
1357
|
-
msg:
|
|
1358
|
-
index:
|
|
1359
|
-
STATUS:
|
|
1360
|
-
setMessageRef:
|
|
1361
|
-
scrollToBottom: O(
|
|
1362
|
-
onRegenerate: O(
|
|
1416
|
+
])) : J("", !0),
|
|
1417
|
+
(v(!0), m(we, null, xe(a.value, (ee, Ce) => (v(), pe(Lo, {
|
|
1418
|
+
key: Ce,
|
|
1419
|
+
msg: ee,
|
|
1420
|
+
index: Ce,
|
|
1421
|
+
STATUS: u,
|
|
1422
|
+
setMessageRef: Y,
|
|
1423
|
+
scrollToBottom: O(d),
|
|
1424
|
+
onRegenerate: O(S)
|
|
1363
1425
|
}, null, 8, ["msg", "index", "scrollToBottom", "onRegenerate"]))), 128))
|
|
1364
1426
|
], 512),
|
|
1365
|
-
|
|
1427
|
+
o("div", {
|
|
1366
1428
|
ref_key: "scrollbarRef",
|
|
1367
|
-
ref:
|
|
1429
|
+
ref: F,
|
|
1368
1430
|
class: "chat-box__scrollbar",
|
|
1369
|
-
onMousedown:
|
|
1370
|
-
onTouchstart:
|
|
1431
|
+
onMousedown: fe(ge, ["prevent"]),
|
|
1432
|
+
onTouchstart: fe(ge, ["prevent"])
|
|
1371
1433
|
}, [
|
|
1372
|
-
|
|
1434
|
+
o("div", {
|
|
1373
1435
|
class: "chat-box__scrollbar-thumb",
|
|
1374
|
-
onMousedown:
|
|
1375
|
-
onTouchstart:
|
|
1436
|
+
onMousedown: fe(Q, ["stop", "prevent"]),
|
|
1437
|
+
onTouchstart: fe(Q, ["stop", "prevent"])
|
|
1376
1438
|
}, null, 32)
|
|
1377
1439
|
], 544)
|
|
1378
1440
|
]),
|
|
1379
|
-
|
|
1380
|
-
modelValue:
|
|
1381
|
-
"onUpdate:modelValue":
|
|
1382
|
-
isGenerating:
|
|
1383
|
-
lastUserMessage: C.value,
|
|
1441
|
+
ie(Go, {
|
|
1442
|
+
modelValue: r.value,
|
|
1443
|
+
"onUpdate:modelValue": Z[0] || (Z[0] = (ee) => r.value = ee),
|
|
1444
|
+
isGenerating: f.value,
|
|
1384
1445
|
hasScroll: O(n),
|
|
1385
|
-
isAtBottom: O(
|
|
1386
|
-
onSend: O(
|
|
1387
|
-
onRegenerate: O(
|
|
1388
|
-
onStop: O(
|
|
1389
|
-
onScrollToBottom: O(
|
|
1390
|
-
}, null, 8, ["modelValue", "isGenerating", "
|
|
1391
|
-
|
|
1446
|
+
isAtBottom: O(te),
|
|
1447
|
+
onSend: O(ne),
|
|
1448
|
+
onRegenerate: O(S),
|
|
1449
|
+
onStop: O(q),
|
|
1450
|
+
onScrollToBottom: O(d)
|
|
1451
|
+
}, null, 8, ["modelValue", "isGenerating", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
|
|
1452
|
+
Z[3] || (Z[3] = o("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
|
|
1392
1453
|
]);
|
|
1393
1454
|
};
|
|
1394
1455
|
}
|
|
1395
|
-
}),
|
|
1456
|
+
}), hs = { class: "ai-history" }, ps = { class: "content" }, ms = {
|
|
1396
1457
|
key: 0,
|
|
1397
1458
|
class: "ai-history-loading"
|
|
1398
|
-
},
|
|
1459
|
+
}, fs = { class: "ai-history-group-title" }, gs = ["onClick"], ys = { class: "ai-history-item-title" }, ws = ["onClick"], ks = {
|
|
1399
1460
|
key: 2,
|
|
1400
1461
|
class: "ai-history-empty"
|
|
1401
|
-
},
|
|
1462
|
+
}, Cs = ["src"], _s = { class: "ai-modal" }, bs = { class: "ai-modal-footer" }, As = /* @__PURE__ */ Ee({
|
|
1402
1463
|
__name: "History",
|
|
1403
1464
|
emits: ["history-detail", "new-conversation"],
|
|
1404
|
-
setup(t, { emit:
|
|
1405
|
-
const
|
|
1406
|
-
async function
|
|
1465
|
+
setup(t, { emit: w }) {
|
|
1466
|
+
const u = qe().apis, l = g([]), h = g(!0), s = g(!1), a = g(""), r = B(() => Dn(l.value));
|
|
1467
|
+
async function f() {
|
|
1407
1468
|
try {
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1410
|
-
} catch (
|
|
1411
|
-
|
|
1469
|
+
const p = await Mn(u);
|
|
1470
|
+
p != null && p.conversationList && (l.value = p.conversationList.filter((R) => R !== null).map((R) => ({ ...R, selected: !1 })));
|
|
1471
|
+
} catch (p) {
|
|
1472
|
+
Te((p == null ? void 0 : p.message) || "获取历史记录失败");
|
|
1412
1473
|
} finally {
|
|
1413
|
-
|
|
1474
|
+
h.value = !1;
|
|
1414
1475
|
}
|
|
1415
1476
|
}
|
|
1416
|
-
function
|
|
1417
|
-
a.value =
|
|
1477
|
+
function k(p) {
|
|
1478
|
+
a.value = p, s.value = !0;
|
|
1418
1479
|
}
|
|
1419
|
-
async function
|
|
1420
|
-
|
|
1480
|
+
async function V() {
|
|
1481
|
+
s.value = !1;
|
|
1421
1482
|
try {
|
|
1422
|
-
await Rn(
|
|
1423
|
-
} catch (
|
|
1424
|
-
|
|
1483
|
+
await Rn(u, a.value), await f();
|
|
1484
|
+
} catch (p) {
|
|
1485
|
+
Te((p == null ? void 0 : p.message) || "删除失败"), await f();
|
|
1425
1486
|
}
|
|
1426
1487
|
}
|
|
1427
|
-
return
|
|
1428
|
-
|
|
1429
|
-
}), (
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
])])) :
|
|
1488
|
+
return be(() => {
|
|
1489
|
+
f();
|
|
1490
|
+
}), (p, R) => (v(), m("div", hs, [
|
|
1491
|
+
o("div", ps, [
|
|
1492
|
+
h.value ? (v(), m("div", ms, [...R[3] || (R[3] = [
|
|
1493
|
+
o("div", { class: "ai-history-spinner" }, null, -1)
|
|
1494
|
+
])])) : r.value.length > 0 ? (v(!0), m(we, { key: 1 }, xe(r.value, (X) => (v(), m("div", {
|
|
1434
1495
|
key: X.label,
|
|
1435
1496
|
class: "ai-history-group"
|
|
1436
1497
|
}, [
|
|
1437
|
-
|
|
1438
|
-
(v(!0),
|
|
1439
|
-
key:
|
|
1498
|
+
o("div", fs, z(X.label), 1),
|
|
1499
|
+
(v(!0), m(we, null, xe(X.items, (K, G) => (v(), m("div", {
|
|
1500
|
+
key: K.appConversationID,
|
|
1440
1501
|
class: "ai-history-item",
|
|
1441
|
-
style:
|
|
1442
|
-
onClick: (
|
|
1502
|
+
style: it({ "--i": G }),
|
|
1503
|
+
onClick: (_) => p.$emit("history-detail", K.appConversationID)
|
|
1443
1504
|
}, [
|
|
1444
|
-
|
|
1445
|
-
|
|
1505
|
+
o("div", ys, z(K.conversationName), 1),
|
|
1506
|
+
o("div", {
|
|
1446
1507
|
class: "ai-history-item-delete",
|
|
1447
|
-
onClick:
|
|
1448
|
-
}, "删除", 8,
|
|
1449
|
-
], 12,
|
|
1450
|
-
]))), 128)) : (v(),
|
|
1508
|
+
onClick: fe((_) => k(K.appConversationID), ["stop"])
|
|
1509
|
+
}, "删除", 8, ws)
|
|
1510
|
+
], 12, gs))), 128))
|
|
1511
|
+
]))), 128)) : (v(), m("div", ks, "暂无历史记录"))
|
|
1451
1512
|
]),
|
|
1452
|
-
|
|
1513
|
+
o("div", {
|
|
1453
1514
|
class: "ai-add",
|
|
1454
|
-
onClick: R[0] || (R[0] = (X) =>
|
|
1515
|
+
onClick: R[0] || (R[0] = (X) => p.$emit("new-conversation"))
|
|
1455
1516
|
}, [
|
|
1456
|
-
|
|
1457
|
-
R[4] || (R[4] =
|
|
1517
|
+
o("img", { src: O(Fn) }, null, 8, Cs),
|
|
1518
|
+
R[4] || (R[4] = o("span", null, "新建AI对话", -1))
|
|
1458
1519
|
]),
|
|
1459
|
-
(v(),
|
|
1460
|
-
|
|
1520
|
+
(v(), pe(Yt, { to: "#ai-assist-root" }, [
|
|
1521
|
+
s.value ? (v(), m("div", {
|
|
1461
1522
|
key: 0,
|
|
1462
1523
|
class: "ai-modal-overlay",
|
|
1463
|
-
onClick: R[2] || (R[2] =
|
|
1524
|
+
onClick: R[2] || (R[2] = fe((X) => s.value = !1, ["self"]))
|
|
1464
1525
|
}, [
|
|
1465
|
-
|
|
1466
|
-
R[5] || (R[5] =
|
|
1467
|
-
R[6] || (R[6] =
|
|
1468
|
-
|
|
1469
|
-
|
|
1526
|
+
o("div", _s, [
|
|
1527
|
+
R[5] || (R[5] = o("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
|
|
1528
|
+
R[6] || (R[6] = o("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
|
|
1529
|
+
o("div", bs, [
|
|
1530
|
+
o("button", {
|
|
1470
1531
|
class: "ai-modal-btn cancel",
|
|
1471
|
-
onClick: R[1] || (R[1] = (X) =>
|
|
1532
|
+
onClick: R[1] || (R[1] = (X) => s.value = !1)
|
|
1472
1533
|
}, "取消"),
|
|
1473
|
-
|
|
1534
|
+
o("button", {
|
|
1474
1535
|
class: "ai-modal-btn confirm",
|
|
1475
|
-
onClick:
|
|
1536
|
+
onClick: V
|
|
1476
1537
|
}, "确定")
|
|
1477
1538
|
])
|
|
1478
1539
|
])
|
|
1479
|
-
])) :
|
|
1540
|
+
])) : J("", !0)
|
|
1480
1541
|
]))
|
|
1481
1542
|
]));
|
|
1482
1543
|
}
|
|
1483
|
-
}),
|
|
1544
|
+
}), Ss = { class: "container info" }, Es = { class: "info-item" }, Ts = { class: "basic-content" }, xs = { class: "basic-content-text" }, Ds = { class: "basic-content" }, Ms = { class: "basic-content-text" }, Rs = { class: "info-item" }, Hs = { class: "permission-content" }, $s = { class: "info-item" }, Ls = { class: "basic-content" }, Ps = { class: "basic-content-text" }, Os = { class: "basic-content" }, Bs = { class: "basic-content-text" }, Ws = /* @__PURE__ */ Ee({
|
|
1484
1545
|
__name: "Info",
|
|
1485
1546
|
setup(t) {
|
|
1486
|
-
const
|
|
1487
|
-
return
|
|
1547
|
+
const w = qe(), i = g(null);
|
|
1548
|
+
return be(async () => {
|
|
1488
1549
|
try {
|
|
1489
|
-
i.value = await
|
|
1490
|
-
} catch (
|
|
1491
|
-
|
|
1550
|
+
i.value = await Hn(w.apis);
|
|
1551
|
+
} catch (u) {
|
|
1552
|
+
Te((u == null ? void 0 : u.message) || "获取个人信息失败");
|
|
1492
1553
|
}
|
|
1493
|
-
}), (
|
|
1494
|
-
var
|
|
1495
|
-
return v(),
|
|
1496
|
-
|
|
1497
|
-
l[2] || (l[2] =
|
|
1498
|
-
|
|
1499
|
-
|
|
1554
|
+
}), (u, l) => {
|
|
1555
|
+
var h, s, a, r, f;
|
|
1556
|
+
return v(), m("div", Ss, [
|
|
1557
|
+
o("div", Es, [
|
|
1558
|
+
l[2] || (l[2] = o("div", { class: "heading" }, [
|
|
1559
|
+
o("div", { class: "heading-column" }),
|
|
1560
|
+
o("div", { class: "heading-title" }, "基本信息")
|
|
1500
1561
|
], -1)),
|
|
1501
|
-
|
|
1502
|
-
l[0] || (l[0] =
|
|
1503
|
-
|
|
1562
|
+
o("div", Ts, [
|
|
1563
|
+
l[0] || (l[0] = o("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
|
|
1564
|
+
o("div", xs, z(((h = i.value) == null ? void 0 : h.name) || ""), 1)
|
|
1504
1565
|
]),
|
|
1505
|
-
|
|
1506
|
-
l[1] || (l[1] =
|
|
1507
|
-
|
|
1566
|
+
o("div", Ds, [
|
|
1567
|
+
l[1] || (l[1] = o("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
|
|
1568
|
+
o("div", Ms, z(((s = i.value) == null ? void 0 : s.userName) || ""), 1)
|
|
1508
1569
|
])
|
|
1509
1570
|
]),
|
|
1510
|
-
|
|
1511
|
-
l[3] || (l[3] =
|
|
1512
|
-
|
|
1513
|
-
|
|
1571
|
+
o("div", Rs, [
|
|
1572
|
+
l[3] || (l[3] = o("div", { class: "heading" }, [
|
|
1573
|
+
o("div", { class: "heading-column" }),
|
|
1574
|
+
o("div", { class: "heading-title" }, "数据权限")
|
|
1514
1575
|
], -1)),
|
|
1515
|
-
|
|
1516
|
-
(v(!0),
|
|
1517
|
-
key:
|
|
1576
|
+
o("div", Hs, [
|
|
1577
|
+
(v(!0), m(we, null, xe((a = i.value) == null ? void 0 : a.ptnameList, (k, V) => (v(), m("div", {
|
|
1578
|
+
key: V,
|
|
1518
1579
|
class: "permission-content-text"
|
|
1519
|
-
},
|
|
1580
|
+
}, z(k), 1))), 128))
|
|
1520
1581
|
])
|
|
1521
1582
|
]),
|
|
1522
|
-
|
|
1523
|
-
l[6] || (l[6] =
|
|
1524
|
-
|
|
1525
|
-
|
|
1583
|
+
o("div", $s, [
|
|
1584
|
+
l[6] || (l[6] = o("div", { class: "heading" }, [
|
|
1585
|
+
o("div", { class: "heading-column" }),
|
|
1586
|
+
o("div", { class: "heading-title" }, "帮助信息")
|
|
1526
1587
|
], -1)),
|
|
1527
|
-
|
|
1528
|
-
l[4] || (l[4] =
|
|
1529
|
-
|
|
1588
|
+
o("div", Ls, [
|
|
1589
|
+
l[4] || (l[4] = o("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
|
|
1590
|
+
o("div", Ps, z(((r = i.value) == null ? void 0 : r.dept) || ""), 1)
|
|
1530
1591
|
]),
|
|
1531
|
-
|
|
1532
|
-
l[5] || (l[5] =
|
|
1533
|
-
|
|
1592
|
+
o("div", Os, [
|
|
1593
|
+
l[5] || (l[5] = o("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
|
|
1594
|
+
o("div", Bs, z(((f = i.value) == null ? void 0 : f.email) || ""), 1)
|
|
1534
1595
|
])
|
|
1535
1596
|
])
|
|
1536
1597
|
]);
|
|
1537
1598
|
};
|
|
1538
1599
|
}
|
|
1539
|
-
}),
|
|
1600
|
+
}), Ys = { key: 1 }, Ns = ["src"], Vs = { class: "header-title" }, Xs = ["title"], Fs = { class: "ai-history-drawer-panel" }, Qs = { class: "ai-history-drawer-header" }, Js = { class: "setTitle" }, qs = { class: "content" }, zs = { class: "main" }, Ks = { class: "btn" }, Gs = ["src"], js = 78, Xe = 78, he = 8, Fe = 26, Le = 490, Pt = "aiPanelPosition", Ot = "aiPanelDocked", Bt = "aiDockWidth", Us = 60, Zs = 150, Wt = 400, Is = 320, Jt = /* @__PURE__ */ Ee({
|
|
1540
1601
|
__name: "AiAssist",
|
|
1541
1602
|
setup(t) {
|
|
1542
1603
|
var xt;
|
|
1543
|
-
const
|
|
1544
|
-
x: window.innerWidth -
|
|
1604
|
+
const w = js / 2, i = qe(), u = g(!1), l = g("idle"), h = g(!1), s = ye({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), a = g(!1), r = g(window.innerWidth < 768), f = g(window.innerWidth < 768), k = g("answer"), V = g(!1), p = g(""), R = g(""), X = g(""), K = g(!1), G = g(!1), _ = ye({
|
|
1605
|
+
x: window.innerWidth - w,
|
|
1545
1606
|
y: window.innerHeight / 2 - Xe / 2
|
|
1546
|
-
}),
|
|
1547
|
-
let
|
|
1548
|
-
const
|
|
1549
|
-
let
|
|
1550
|
-
const
|
|
1551
|
-
let
|
|
1552
|
-
const
|
|
1607
|
+
}), E = g(!1), te = g(!1), n = g("right"), d = g("left"), C = g(null), D = ye({ x: 0, y: 0 }), T = g(!1), W = g(!1), y = ye({ x: 0, y: 0 }), L = g(!1), ne = ye({ x: 0, y: 0 }), S = g(!1), q = g(!1), N = g(!1), b = ye({ x: 0, width: 0 }), x = g(!1);
|
|
1608
|
+
let M = 0;
|
|
1609
|
+
const $ = g("idle"), Y = g(!1), H = g("none"), F = ye({ x: 0, y: 0, w: Le, h: 0, radius: "14px" });
|
|
1610
|
+
let oe = null, le = !1, de = !1;
|
|
1611
|
+
const ke = ye({ x: 0, y: 0 }), P = g(!1), Q = g(null);
|
|
1612
|
+
let I = null, ue = null, ge = null;
|
|
1613
|
+
const j = B(() => {
|
|
1553
1614
|
const e = window.innerWidth / 2;
|
|
1554
|
-
return
|
|
1555
|
-
}),
|
|
1615
|
+
return _.x + w < e ? 5 : -5;
|
|
1616
|
+
}), Z = B(() => f.value || S.value || $.value !== "idle" ? "" : `panel-${n.value}`), ae = B(() => {
|
|
1556
1617
|
var e;
|
|
1557
|
-
return !!((e = i.dock) != null && e.containerId) && !
|
|
1558
|
-
}),
|
|
1618
|
+
return !!((e = i.dock) != null && e.containerId) && !r.value;
|
|
1619
|
+
}), ee = g(((xt = i.dock) == null ? void 0 : xt.width) || Le), Ce = B(() => i.panelDraggable !== !1), Re = B(() => {
|
|
1559
1620
|
var e;
|
|
1560
|
-
return !((e =
|
|
1621
|
+
return !((e = Q.value) != null && e.isEmptyConversation);
|
|
1561
1622
|
}), ze = B(() => ({
|
|
1562
|
-
left: `${
|
|
1563
|
-
top: `${
|
|
1564
|
-
transition:
|
|
1565
|
-
"--direction": String(
|
|
1566
|
-
})), lt = B(() => i.characterImage || Qn),
|
|
1567
|
-
left: `${
|
|
1568
|
-
top: `${
|
|
1569
|
-
width: `${
|
|
1570
|
-
height: `${
|
|
1571
|
-
borderRadius:
|
|
1572
|
-
}),
|
|
1623
|
+
left: `${_.x}px`,
|
|
1624
|
+
top: `${_.y}px`,
|
|
1625
|
+
transition: E.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
|
|
1626
|
+
"--direction": String(j.value)
|
|
1627
|
+
})), lt = B(() => i.characterImage || Qn), qt = B(() => l.value === "idle" ? {} : {
|
|
1628
|
+
left: `${s.x}px`,
|
|
1629
|
+
top: `${s.y}px`,
|
|
1630
|
+
width: `${s.w}px`,
|
|
1631
|
+
height: `${s.h}px`,
|
|
1632
|
+
borderRadius: s.radius
|
|
1633
|
+
}), zt = B(() => {
|
|
1573
1634
|
const e = {};
|
|
1574
|
-
return
|
|
1575
|
-
}),
|
|
1576
|
-
left: `${
|
|
1577
|
-
top: `${
|
|
1578
|
-
width: `${
|
|
1579
|
-
height: `${
|
|
1580
|
-
borderRadius:
|
|
1635
|
+
return T.value && !f.value && !r.value && !S.value && (e["--ai-panel-x"] = `${D.x}px`, e["--ai-panel-y"] = `${D.y}px`), S.value && (e["--ai-dock-width"] = `${ee.value}px`), e;
|
|
1636
|
+
}), Kt = B(() => $.value === "idle" ? {} : {
|
|
1637
|
+
left: `${F.x}px`,
|
|
1638
|
+
top: `${F.y}px`,
|
|
1639
|
+
width: `${F.w}px`,
|
|
1640
|
+
height: `${F.h}px`,
|
|
1641
|
+
borderRadius: F.radius
|
|
1581
1642
|
});
|
|
1582
1643
|
function Ke() {
|
|
1583
1644
|
const e = window.innerWidth / 2;
|
|
1584
|
-
|
|
1645
|
+
_.x + w < e ? (n.value = "left", d.value = "right") : (n.value = "right", d.value = "left");
|
|
1585
1646
|
}
|
|
1586
1647
|
function Gt() {
|
|
1587
|
-
const e = window.innerWidth,
|
|
1588
|
-
return { x:
|
|
1648
|
+
const e = window.innerWidth, c = Math.max(0, Math.min(_.y, window.innerHeight - Xe));
|
|
1649
|
+
return { x: _.x + w >= e / 2 ? e - w : -w, y: c };
|
|
1589
1650
|
}
|
|
1590
|
-
function
|
|
1591
|
-
|
|
1651
|
+
function pt() {
|
|
1652
|
+
te.value = !0;
|
|
1592
1653
|
const e = Gt();
|
|
1593
|
-
|
|
1594
|
-
|
|
1654
|
+
_.x = e.x, _.y = e.y, setTimeout(() => {
|
|
1655
|
+
te.value = !1, Ke(), jt();
|
|
1595
1656
|
}, 400);
|
|
1596
1657
|
}
|
|
1597
1658
|
function jt() {
|
|
1598
1659
|
try {
|
|
1599
|
-
localStorage.setItem("characterPosition", JSON.stringify({ x:
|
|
1660
|
+
localStorage.setItem("characterPosition", JSON.stringify({ x: _.x, y: _.y })), localStorage.setItem("panelPosition", n.value), localStorage.setItem("backPosition", d.value);
|
|
1600
1661
|
} catch {
|
|
1601
1662
|
}
|
|
1602
1663
|
}
|
|
1603
1664
|
function Ut() {
|
|
1604
1665
|
const e = localStorage.getItem("characterPosition");
|
|
1605
1666
|
if (e) {
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1667
|
+
const U = JSON.parse(e);
|
|
1668
|
+
_.x = U.x, _.y = Math.min(Math.max(U.y, 0), window.innerHeight - Xe);
|
|
1608
1669
|
} else
|
|
1609
|
-
|
|
1610
|
-
const
|
|
1611
|
-
|
|
1670
|
+
_.x = window.innerWidth - w, _.y = window.innerHeight / 2 - Xe / 2;
|
|
1671
|
+
const c = localStorage.getItem("panelPosition"), A = localStorage.getItem("backPosition");
|
|
1672
|
+
c && (n.value = c), A && (d.value = A);
|
|
1612
1673
|
}
|
|
1613
|
-
function
|
|
1614
|
-
if (!
|
|
1615
|
-
const
|
|
1616
|
-
|
|
1674
|
+
function Ge(e) {
|
|
1675
|
+
if (!E.value) return;
|
|
1676
|
+
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY, U = c - ke.x, re = Math.max(0, Math.min(A - ke.y, window.innerHeight - Xe)), _e = Math.abs(U - _.x), Ae = Math.abs(re - _.y);
|
|
1677
|
+
_e + Ae > 5 && (P.value = !0), _.x = U, _.y = re;
|
|
1617
1678
|
}
|
|
1618
|
-
function
|
|
1619
|
-
|
|
1679
|
+
function je() {
|
|
1680
|
+
E.value && (E.value = !1, P.value && (pt(), P.value = !1));
|
|
1620
1681
|
}
|
|
1621
|
-
function
|
|
1622
|
-
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1682
|
+
function mt(e) {
|
|
1683
|
+
te.value = !1, E.value = !0, P.value = !1;
|
|
1684
|
+
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
1685
|
+
ke.x = c - _.x, ke.y = A - _.y;
|
|
1625
1686
|
}
|
|
1626
1687
|
function Zt() {
|
|
1627
|
-
const e =
|
|
1688
|
+
const e = C.value, c = (e == null ? void 0 : e.offsetWidth) || Le, A = (e == null ? void 0 : e.offsetHeight) || window.innerHeight - 78;
|
|
1628
1689
|
return {
|
|
1629
|
-
maxX: Math.max(
|
|
1630
|
-
maxY: Math.max(Fe, window.innerHeight - A -
|
|
1690
|
+
maxX: Math.max(he, window.innerWidth - c - he),
|
|
1691
|
+
maxY: Math.max(Fe, window.innerHeight - A - he)
|
|
1631
1692
|
};
|
|
1632
1693
|
}
|
|
1633
|
-
function
|
|
1634
|
-
const A =
|
|
1635
|
-
|
|
1694
|
+
function Ue(e, c) {
|
|
1695
|
+
const A = C.value, U = e ?? (A == null ? void 0 : A.offsetWidth) ?? Le, re = c ?? (A == null ? void 0 : A.offsetHeight) ?? window.innerHeight - 78, _e = Math.max(he, window.innerWidth - U - he), Ae = Math.max(Fe, window.innerHeight - re - he);
|
|
1696
|
+
D.x = Math.min(Math.max(D.x, he), _e), D.y = Math.min(Math.max(D.y, Fe), Ae);
|
|
1636
1697
|
}
|
|
1637
|
-
function
|
|
1638
|
-
if (!
|
|
1639
|
-
if (
|
|
1640
|
-
const
|
|
1641
|
-
if (
|
|
1642
|
-
const
|
|
1643
|
-
|
|
1698
|
+
function ft(e) {
|
|
1699
|
+
if (!Ce.value || f.value || r.value || S.value || l.value !== "idle") return;
|
|
1700
|
+
if (de = !1, W.value = !0, L.value = !1, !T.value) {
|
|
1701
|
+
const U = C.value;
|
|
1702
|
+
if (U) {
|
|
1703
|
+
const re = U.getBoundingClientRect();
|
|
1704
|
+
D.x = re.left, D.y = re.top, T.value = !0;
|
|
1644
1705
|
}
|
|
1645
1706
|
}
|
|
1646
|
-
const
|
|
1647
|
-
|
|
1707
|
+
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
1708
|
+
ne.x = c, ne.y = A, y.x = c - D.x, y.y = A - D.y;
|
|
1648
1709
|
}
|
|
1649
|
-
function
|
|
1650
|
-
var
|
|
1651
|
-
if (
|
|
1652
|
-
const
|
|
1710
|
+
function Ze(e) {
|
|
1711
|
+
var Se, Dt;
|
|
1712
|
+
if (!W.value) return;
|
|
1713
|
+
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
1653
1714
|
if (!L.value) {
|
|
1654
|
-
const
|
|
1655
|
-
if (
|
|
1715
|
+
const fn = Math.abs(c - ne.x), gn = Math.abs(A - ne.y);
|
|
1716
|
+
if (fn + gn <= 5) return;
|
|
1656
1717
|
L.value = !0;
|
|
1657
1718
|
}
|
|
1658
|
-
const { maxX:
|
|
1659
|
-
|
|
1719
|
+
const { maxX: U, maxY: re } = Zt(), _e = ae.value ? U + Zs : U, Ae = Math.min(Math.max(c - y.x, he), _e), $e = Math.min(Math.max(A - y.y, Fe), re), De = ae.value && Ae > U + Us;
|
|
1720
|
+
De !== de && (de = De, (Dt = (Se = i.dock) == null ? void 0 : Se.onDockChange) == null || Dt.call(Se, De)), q.value = De, D.x = Ae, D.y = $e;
|
|
1660
1721
|
}
|
|
1661
|
-
function
|
|
1662
|
-
var
|
|
1663
|
-
if (
|
|
1664
|
-
|
|
1722
|
+
function Ie() {
|
|
1723
|
+
var c, A;
|
|
1724
|
+
if (!W.value) return;
|
|
1725
|
+
W.value = !1;
|
|
1665
1726
|
let e = !1;
|
|
1666
|
-
L.value && (L.value = !1,
|
|
1667
|
-
|
|
1668
|
-
}, 0),
|
|
1727
|
+
L.value && (L.value = !1, le = !0, setTimeout(() => {
|
|
1728
|
+
le = !1;
|
|
1729
|
+
}, 0), q.value && ae.value ? (kt(), e = !0) : (Ue(), It())), de && !e && (de = !1, (A = (c = i.dock) == null ? void 0 : c.onDockChange) == null || A.call(c, !1)), q.value = !1;
|
|
1669
1730
|
}
|
|
1670
|
-
function
|
|
1671
|
-
|
|
1731
|
+
function gt(e) {
|
|
1732
|
+
le && (e.preventDefault(), e.stopPropagation(), le = !1);
|
|
1672
1733
|
}
|
|
1673
1734
|
function It() {
|
|
1674
1735
|
try {
|
|
1675
|
-
localStorage.setItem(Pt, JSON.stringify({ x:
|
|
1736
|
+
localStorage.setItem(Pt, JSON.stringify({ x: D.x, y: D.y }));
|
|
1676
1737
|
} catch {
|
|
1677
1738
|
}
|
|
1678
1739
|
}
|
|
@@ -1680,41 +1741,41 @@ const Is = { class: "container" }, eo = { class: "chat-wrap" }, to = { class: "m
|
|
|
1680
1741
|
try {
|
|
1681
1742
|
const e = localStorage.getItem(Pt);
|
|
1682
1743
|
if (e) {
|
|
1683
|
-
const
|
|
1684
|
-
typeof
|
|
1744
|
+
const c = JSON.parse(e);
|
|
1745
|
+
typeof c.x == "number" && typeof c.y == "number" && (D.x = c.x, D.y = c.y, T.value = !0);
|
|
1685
1746
|
}
|
|
1686
1747
|
} catch {
|
|
1687
1748
|
}
|
|
1688
1749
|
}
|
|
1689
1750
|
function yt() {
|
|
1690
1751
|
try {
|
|
1691
|
-
localStorage.setItem(Ot,
|
|
1752
|
+
localStorage.setItem(Ot, S.value ? "1" : "0");
|
|
1692
1753
|
} catch {
|
|
1693
1754
|
}
|
|
1694
1755
|
}
|
|
1695
1756
|
function tn() {
|
|
1696
1757
|
var e;
|
|
1697
1758
|
try {
|
|
1698
|
-
if (localStorage.getItem(Ot) === "1" &&
|
|
1759
|
+
if (localStorage.getItem(Ot) === "1" && ae.value) {
|
|
1699
1760
|
const A = (e = i.dock) == null ? void 0 : e.containerId;
|
|
1700
|
-
A && document.getElementById(A) && (
|
|
1761
|
+
A && document.getElementById(A) && (S.value = !0);
|
|
1701
1762
|
}
|
|
1702
1763
|
} catch {
|
|
1703
1764
|
}
|
|
1704
1765
|
}
|
|
1705
|
-
function
|
|
1766
|
+
function et() {
|
|
1706
1767
|
return {
|
|
1707
|
-
x: window.innerWidth -
|
|
1768
|
+
x: window.innerWidth - ee.value,
|
|
1708
1769
|
y: 0,
|
|
1709
|
-
w:
|
|
1770
|
+
w: ee.value,
|
|
1710
1771
|
h: window.innerHeight,
|
|
1711
1772
|
radius: "0px"
|
|
1712
1773
|
};
|
|
1713
1774
|
}
|
|
1714
1775
|
function nn() {
|
|
1715
1776
|
return {
|
|
1716
|
-
x: Math.max(0, Math.min(window.innerWidth - 53,
|
|
1717
|
-
y:
|
|
1777
|
+
x: Math.max(0, Math.min(window.innerWidth - 53, _.x + j.value * 3)),
|
|
1778
|
+
y: _.y,
|
|
1718
1779
|
w: 53,
|
|
1719
1780
|
h: 53,
|
|
1720
1781
|
radius: "50%"
|
|
@@ -1730,45 +1791,45 @@ const Is = { class: "container" }, eo = { class: "chat-wrap" }, to = { class: "m
|
|
|
1730
1791
|
radius: "14px"
|
|
1731
1792
|
};
|
|
1732
1793
|
}
|
|
1733
|
-
function
|
|
1734
|
-
|
|
1794
|
+
function on() {
|
|
1795
|
+
f.value ? (He(wt(), bt()), f.value = !1) : (He(Oe(), wt()), f.value = !0);
|
|
1735
1796
|
}
|
|
1736
|
-
function
|
|
1737
|
-
|
|
1797
|
+
function He(e, c, A, U = "none") {
|
|
1798
|
+
oe && clearTimeout(oe), $.value = "switching", Y.value = !0, H.value = U, F.x = e.x, F.y = e.y, F.w = e.w, F.h = e.h, F.radius = e.radius, me(() => {
|
|
1738
1799
|
requestAnimationFrame(() => {
|
|
1739
|
-
|
|
1800
|
+
Y.value = !1, F.x = c.x, F.y = c.y, F.w = c.w, F.h = c.h, F.radius = c.radius;
|
|
1740
1801
|
});
|
|
1741
|
-
}),
|
|
1742
|
-
|
|
1802
|
+
}), oe = setTimeout(() => {
|
|
1803
|
+
$.value = "idle", H.value = "none", oe = null, A == null || A();
|
|
1743
1804
|
}, 400);
|
|
1744
1805
|
}
|
|
1745
1806
|
function kt() {
|
|
1746
|
-
var
|
|
1747
|
-
if (!
|
|
1748
|
-
|
|
1749
|
-
const e = (
|
|
1807
|
+
var re, _e, Ae, $e, De;
|
|
1808
|
+
if (!ae.value || S.value) return;
|
|
1809
|
+
f.value && (f.value = !1);
|
|
1810
|
+
const e = (re = i.dock) == null ? void 0 : re.containerId;
|
|
1750
1811
|
if (e && !document.getElementById(e)) {
|
|
1751
1812
|
console.warn(`[ai-assist-sdk] dock container "#${e}" not found, dock feature disabled`);
|
|
1752
1813
|
return;
|
|
1753
1814
|
}
|
|
1754
|
-
const
|
|
1815
|
+
const c = C.value;
|
|
1755
1816
|
let A = Oe();
|
|
1756
|
-
if (
|
|
1757
|
-
const
|
|
1758
|
-
A = { x:
|
|
1817
|
+
if (c) {
|
|
1818
|
+
const Se = c.getBoundingClientRect();
|
|
1819
|
+
A = { x: Se.left, y: Se.top, w: Se.width, h: Se.height, radius: getComputedStyle(c).borderRadius };
|
|
1759
1820
|
}
|
|
1760
|
-
const
|
|
1761
|
-
|
|
1821
|
+
const U = et();
|
|
1822
|
+
He(A, U), S.value = !0, l.value = "idle", q.value = !1, yt(), (Ae = (_e = i.dock) == null ? void 0 : _e.onDockChange) == null || Ae.call(_e, !0), (De = ($e = i.dock) == null ? void 0 : $e.onDockWidthChange) == null || De.call($e, ee.value);
|
|
1762
1823
|
}
|
|
1763
|
-
function
|
|
1764
|
-
return Math.max(Wt, window.innerWidth -
|
|
1824
|
+
function sn() {
|
|
1825
|
+
return Math.max(Wt, window.innerWidth - Is);
|
|
1765
1826
|
}
|
|
1766
1827
|
function ut(e) {
|
|
1767
|
-
return Math.min(Math.max(e, Wt),
|
|
1828
|
+
return Math.min(Math.max(e, Wt), sn());
|
|
1768
1829
|
}
|
|
1769
1830
|
function an() {
|
|
1770
1831
|
try {
|
|
1771
|
-
localStorage.setItem(Bt, String(
|
|
1832
|
+
localStorage.setItem(Bt, String(ee.value));
|
|
1772
1833
|
} catch {
|
|
1773
1834
|
}
|
|
1774
1835
|
}
|
|
@@ -1776,61 +1837,61 @@ const Is = { class: "container" }, eo = { class: "chat-wrap" }, to = { class: "m
|
|
|
1776
1837
|
try {
|
|
1777
1838
|
const e = localStorage.getItem(Bt);
|
|
1778
1839
|
if (e) {
|
|
1779
|
-
const
|
|
1780
|
-
Number.isFinite(
|
|
1840
|
+
const c = parseFloat(e);
|
|
1841
|
+
Number.isFinite(c) && (ee.value = ut(c));
|
|
1781
1842
|
}
|
|
1782
1843
|
} catch {
|
|
1783
1844
|
}
|
|
1784
1845
|
}
|
|
1785
1846
|
function Ct(e) {
|
|
1786
|
-
if (!
|
|
1787
|
-
|
|
1788
|
-
const
|
|
1789
|
-
|
|
1790
|
-
}
|
|
1791
|
-
function
|
|
1792
|
-
if (!
|
|
1793
|
-
const
|
|
1794
|
-
Math.abs(A -
|
|
1795
|
-
var
|
|
1796
|
-
|
|
1847
|
+
if (!S.value) return;
|
|
1848
|
+
N.value = !0, x.value = !1;
|
|
1849
|
+
const c = "touches" in e ? e.touches[0].clientX : e.clientX;
|
|
1850
|
+
b.x = c, b.width = ee.value;
|
|
1851
|
+
}
|
|
1852
|
+
function tt(e) {
|
|
1853
|
+
if (!N.value) return;
|
|
1854
|
+
const c = "touches" in e ? e.touches[0].clientX : e.clientX, A = ut(b.width + (b.x - c));
|
|
1855
|
+
Math.abs(A - b.width) > 3 && (x.value = !0), ee.value = A, M || (M = requestAnimationFrame(() => {
|
|
1856
|
+
var U, re;
|
|
1857
|
+
M = 0, (re = (U = i.dock) == null ? void 0 : U.onDockWidthChange) == null || re.call(U, ee.value);
|
|
1797
1858
|
}));
|
|
1798
1859
|
}
|
|
1799
|
-
function
|
|
1800
|
-
var e,
|
|
1801
|
-
|
|
1860
|
+
function nt() {
|
|
1861
|
+
var e, c;
|
|
1862
|
+
N.value && (N.value = !1, x.value && (x.value = !1, an(), (c = (e = i.dock) == null ? void 0 : e.onDockWidthChange) == null || c.call(e, ee.value)));
|
|
1802
1863
|
}
|
|
1803
1864
|
function _t() {
|
|
1804
|
-
var e,
|
|
1805
|
-
|
|
1865
|
+
var e, c;
|
|
1866
|
+
S.value && (T.value ? Ue(Le, window.innerHeight - 78) : Ke(), He(et(), Oe()), S.value = !1, yt(), (c = (e = i.dock) == null ? void 0 : e.onDockChange) == null || c.call(e, !1));
|
|
1806
1867
|
}
|
|
1807
1868
|
function un() {
|
|
1808
|
-
var e,
|
|
1809
|
-
if (!
|
|
1810
|
-
if (
|
|
1811
|
-
|
|
1812
|
-
{ x: window.innerWidth, y: 0, w:
|
|
1813
|
-
|
|
1869
|
+
var e, c;
|
|
1870
|
+
if (!P.value && !te.value) {
|
|
1871
|
+
if (S.value) {
|
|
1872
|
+
He(
|
|
1873
|
+
{ x: window.innerWidth, y: 0, w: ee.value, h: window.innerHeight, radius: "0px" },
|
|
1874
|
+
et(),
|
|
1814
1875
|
void 0,
|
|
1815
1876
|
"in"
|
|
1816
|
-
),
|
|
1877
|
+
), u.value = !0, l.value = "idle", (c = (e = i.dock) == null ? void 0 : e.onDockChange) == null || c.call(e, !0);
|
|
1817
1878
|
return;
|
|
1818
1879
|
}
|
|
1819
1880
|
Ke();
|
|
1820
1881
|
const A = Oe();
|
|
1821
|
-
|
|
1882
|
+
s.x = Math.max(0, Math.min(window.innerWidth - 53, _.x + j.value * 3)), s.y = _.y - j.value * 2, s.w = 53, s.h = 53, s.radius = "50%", h.value = !0, l.value = "expanding", u.value = !0, me(() => {
|
|
1822
1883
|
requestAnimationFrame(() => {
|
|
1823
|
-
|
|
1884
|
+
h.value = !1, s.x = A.x, s.y = A.y, s.w = A.w, s.h = A.h, s.radius = A.radius;
|
|
1824
1885
|
});
|
|
1825
1886
|
}), setTimeout(() => {
|
|
1826
1887
|
l.value = "idle";
|
|
1827
1888
|
}, 400);
|
|
1828
1889
|
} else
|
|
1829
|
-
|
|
1890
|
+
P.value = !1;
|
|
1830
1891
|
}
|
|
1831
1892
|
function Oe() {
|
|
1832
1893
|
if (window.innerWidth < 768)
|
|
1833
|
-
return
|
|
1894
|
+
return f.value ? {
|
|
1834
1895
|
x: 0,
|
|
1835
1896
|
y: 0,
|
|
1836
1897
|
w: window.innerWidth,
|
|
@@ -1843,333 +1904,333 @@ const Is = { class: "container" }, eo = { class: "chat-wrap" }, to = { class: "m
|
|
|
1843
1904
|
h: window.innerHeight - 16,
|
|
1844
1905
|
radius: "14px"
|
|
1845
1906
|
};
|
|
1846
|
-
const
|
|
1907
|
+
const c = window.innerHeight - 78;
|
|
1847
1908
|
let A = 54;
|
|
1848
|
-
if (
|
|
1849
|
-
const
|
|
1909
|
+
if (f.value) {
|
|
1910
|
+
const U = window.innerWidth * 0.8;
|
|
1850
1911
|
return {
|
|
1851
|
-
x: (window.innerWidth -
|
|
1912
|
+
x: (window.innerWidth - U) / 2,
|
|
1852
1913
|
y: A,
|
|
1853
|
-
w:
|
|
1854
|
-
h:
|
|
1914
|
+
w: U,
|
|
1915
|
+
h: c,
|
|
1855
1916
|
radius: "14px"
|
|
1856
1917
|
};
|
|
1857
1918
|
}
|
|
1858
1919
|
return bt();
|
|
1859
1920
|
}
|
|
1860
1921
|
function bt() {
|
|
1861
|
-
const e =
|
|
1862
|
-
let A = 54,
|
|
1863
|
-
return
|
|
1922
|
+
const e = Le, c = window.innerHeight - 78;
|
|
1923
|
+
let A = 54, U;
|
|
1924
|
+
return T.value ? (U = Math.min(Math.max(D.x, he), Math.max(he, window.innerWidth - e - he)), A = Math.min(Math.max(D.y, Fe), Math.max(he, c - he))) : U = n.value === "left" ? 24 : window.innerWidth - e - 24, { x: U, y: A, w: e, h: c, radius: "14px" };
|
|
1864
1925
|
}
|
|
1865
1926
|
function rn() {
|
|
1866
|
-
var
|
|
1867
|
-
if (
|
|
1868
|
-
|
|
1869
|
-
|
|
1927
|
+
var c, A;
|
|
1928
|
+
if (S.value) {
|
|
1929
|
+
He(et(), nn(), () => {
|
|
1930
|
+
u.value = !1, l.value = "idle", a.value = !0, setTimeout(() => {
|
|
1870
1931
|
a.value = !1;
|
|
1871
1932
|
}, 1400);
|
|
1872
|
-
}, "out"), (A = (
|
|
1933
|
+
}, "out"), (A = (c = i.dock) == null ? void 0 : c.onDockChange) == null || A.call(c, !1);
|
|
1873
1934
|
return;
|
|
1874
1935
|
}
|
|
1875
1936
|
if (l.value !== "idle") return;
|
|
1876
1937
|
const e = Oe();
|
|
1877
|
-
|
|
1938
|
+
s.x = e.x, s.y = e.y, s.w = e.w, s.h = e.h, s.radius = e.radius, h.value = !0, l.value = "collapsing", me(() => {
|
|
1878
1939
|
requestAnimationFrame(() => {
|
|
1879
|
-
|
|
1940
|
+
h.value = !1, s.x = Math.max(0, Math.min(window.innerWidth - 53, _.x + j.value * 3)), s.y = _.y + Math.abs(j.value) * 2, s.w = 53, s.h = 53, s.radius = "50%";
|
|
1880
1941
|
});
|
|
1881
1942
|
}), setTimeout(() => {
|
|
1882
|
-
|
|
1943
|
+
u.value = !1, l.value = "idle", a.value = !0;
|
|
1883
1944
|
}, 400), setTimeout(() => {
|
|
1884
1945
|
a.value = !1;
|
|
1885
1946
|
}, 1400);
|
|
1886
1947
|
}
|
|
1887
1948
|
function cn(e) {
|
|
1888
|
-
Be(),
|
|
1889
|
-
var
|
|
1890
|
-
(
|
|
1949
|
+
Be(), k.value = "answer", me(() => {
|
|
1950
|
+
var c;
|
|
1951
|
+
(c = Q.value) == null || c.goHistoryMessage(e);
|
|
1891
1952
|
});
|
|
1892
1953
|
}
|
|
1893
1954
|
function vn() {
|
|
1894
|
-
X.value = "",
|
|
1955
|
+
X.value = "", k.value = "answer", me(() => {
|
|
1895
1956
|
var e;
|
|
1896
|
-
(e =
|
|
1957
|
+
(e = Q.value) == null || e.createNewConversation();
|
|
1897
1958
|
});
|
|
1898
1959
|
}
|
|
1899
1960
|
function dn() {
|
|
1900
|
-
Be(), X.value = "",
|
|
1961
|
+
Be(), X.value = "", me(() => {
|
|
1901
1962
|
var e;
|
|
1902
|
-
(e =
|
|
1963
|
+
(e = Q.value) == null || e.createNewConversation();
|
|
1903
1964
|
});
|
|
1904
1965
|
}
|
|
1905
1966
|
function hn() {
|
|
1906
|
-
|
|
1967
|
+
G.value = !1, K.value = !0;
|
|
1907
1968
|
}
|
|
1908
1969
|
function Be() {
|
|
1909
|
-
|
|
1910
|
-
|
|
1970
|
+
G.value = !0, setTimeout(() => {
|
|
1971
|
+
K.value = !1, G.value = !1;
|
|
1911
1972
|
}, 300);
|
|
1912
1973
|
}
|
|
1913
|
-
function
|
|
1914
|
-
R.value =
|
|
1974
|
+
function pn() {
|
|
1975
|
+
R.value = p.value, V.value = !1;
|
|
1915
1976
|
}
|
|
1916
|
-
|
|
1977
|
+
ve(f, (e) => {
|
|
1917
1978
|
e ? n.value = "center" : Ke();
|
|
1918
|
-
}),
|
|
1919
|
-
e &&
|
|
1979
|
+
}), ve(u, (e) => {
|
|
1980
|
+
e && T.value && me(() => Ue());
|
|
1920
1981
|
});
|
|
1921
|
-
const
|
|
1922
|
-
let
|
|
1923
|
-
function
|
|
1982
|
+
const mn = Math.max(1e3, Number(i.activityInterval) || 3e4);
|
|
1983
|
+
let ot = null, We = 0, st = 0, at = 0;
|
|
1984
|
+
function Ye(e) {
|
|
1924
1985
|
if (typeof i.onPanelActive == "function")
|
|
1925
1986
|
try {
|
|
1926
1987
|
if (e === "open") {
|
|
1927
|
-
We = Date.now(), st = 0,
|
|
1988
|
+
We = Date.now(), st = 0, at = 0, i.onPanelActive({ phase: e, docked: S.value, durationMs: 0, totalMs: 0 });
|
|
1928
1989
|
return;
|
|
1929
1990
|
}
|
|
1930
1991
|
if (document.visibilityState !== "hidden") {
|
|
1931
1992
|
const A = Date.now();
|
|
1932
1993
|
st += Math.max(0, A - We), We = A;
|
|
1933
1994
|
}
|
|
1934
|
-
const
|
|
1935
|
-
if (
|
|
1936
|
-
st = 0,
|
|
1995
|
+
const c = Math.round(st);
|
|
1996
|
+
if (c <= 0 && e !== "close") return;
|
|
1997
|
+
st = 0, at += c, i.onPanelActive({ phase: e, docked: S.value, durationMs: c, totalMs: at }), e === "close" && (at = 0);
|
|
1937
1998
|
} catch {
|
|
1938
1999
|
}
|
|
1939
2000
|
}
|
|
1940
2001
|
function rt() {
|
|
1941
|
-
|
|
1942
|
-
!
|
|
1943
|
-
},
|
|
2002
|
+
Ne(), ot = window.setInterval(() => {
|
|
2003
|
+
!u.value || document.visibilityState === "hidden" || Ye("heartbeat");
|
|
2004
|
+
}, mn);
|
|
1944
2005
|
}
|
|
1945
|
-
function
|
|
1946
|
-
|
|
2006
|
+
function Ne() {
|
|
2007
|
+
ot !== null && (clearInterval(ot), ot = null);
|
|
1947
2008
|
}
|
|
1948
2009
|
function At() {
|
|
1949
|
-
|
|
2010
|
+
u.value && (document.visibilityState === "hidden" ? (Ne(), Ye("hidden")) : (We = Date.now(), rt()));
|
|
1950
2011
|
}
|
|
1951
2012
|
function St() {
|
|
1952
|
-
|
|
1953
|
-
}
|
|
1954
|
-
function
|
|
1955
|
-
!
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
e ? (
|
|
1959
|
-
}),
|
|
1960
|
-
document.addEventListener("visibilitychange", At), window.addEventListener("pagehide", St), window.addEventListener("pageshow",
|
|
1961
|
-
}),
|
|
1962
|
-
|
|
1963
|
-
}),
|
|
2013
|
+
u.value && (Ne(), Ye("hidden"));
|
|
2014
|
+
}
|
|
2015
|
+
function Et() {
|
|
2016
|
+
!u.value || document.visibilityState === "hidden" || (We = Date.now(), rt());
|
|
2017
|
+
}
|
|
2018
|
+
ve(u, (e) => {
|
|
2019
|
+
e ? (Ye("open"), document.visibilityState !== "hidden" && rt()) : (Ne(), Ye("close"));
|
|
2020
|
+
}), be(() => {
|
|
2021
|
+
document.addEventListener("visibilitychange", At), window.addEventListener("pagehide", St), window.addEventListener("pageshow", Et);
|
|
2022
|
+
}), Pe(() => {
|
|
2023
|
+
Ne(), document.removeEventListener("visibilitychange", At), window.removeEventListener("pagehide", St), window.removeEventListener("pageshow", Et);
|
|
2024
|
+
}), be(() => {
|
|
1964
2025
|
Ut(), en(), tn(), ln();
|
|
1965
2026
|
const e = i.theme || "light";
|
|
1966
|
-
ht(e), e === "auto" && (
|
|
2027
|
+
ht(e), e === "auto" && (ue = $n(() => ht("auto"))), ge = Jn(() => C.value);
|
|
1967
2028
|
});
|
|
1968
2029
|
function Tt() {
|
|
1969
|
-
|
|
2030
|
+
I && clearTimeout(I), I = setTimeout(() => {
|
|
1970
2031
|
const e = window.innerWidth < 768;
|
|
1971
|
-
|
|
2032
|
+
r.value = e, e && (f.value = !0, S.value && _t()), pt(), T.value && Ue(), S.value && (ee.value = ut(ee.value));
|
|
1972
2033
|
}, 100);
|
|
1973
2034
|
}
|
|
1974
|
-
return
|
|
2035
|
+
return be(() => {
|
|
1975
2036
|
window.addEventListener("resize", Tt);
|
|
1976
|
-
}),
|
|
1977
|
-
window.removeEventListener("resize", Tt),
|
|
1978
|
-
}),
|
|
1979
|
-
document.addEventListener("mousemove",
|
|
1980
|
-
}),
|
|
1981
|
-
document.removeEventListener("mousemove",
|
|
1982
|
-
}), (e,
|
|
1983
|
-
|
|
2037
|
+
}), Pe(() => {
|
|
2038
|
+
window.removeEventListener("resize", Tt), I && clearTimeout(I), ue == null || ue(), ge == null || ge(), ge = null;
|
|
2039
|
+
}), be(() => {
|
|
2040
|
+
document.addEventListener("mousemove", Ge), document.addEventListener("touchmove", Ge, { passive: !0 }), document.addEventListener("mouseup", je), document.addEventListener("touchend", je), document.addEventListener("mousemove", Ze), document.addEventListener("touchmove", Ze, { passive: !0 }), document.addEventListener("mouseup", Ie), document.addEventListener("touchend", Ie), document.addEventListener("click", gt, !0), document.addEventListener("mousemove", tt), document.addEventListener("touchmove", tt, { passive: !0 }), document.addEventListener("mouseup", nt), document.addEventListener("touchend", nt);
|
|
2041
|
+
}), Pe(() => {
|
|
2042
|
+
document.removeEventListener("mousemove", Ge), document.removeEventListener("touchmove", Ge), document.removeEventListener("mouseup", je), document.removeEventListener("touchend", je), document.removeEventListener("mousemove", Ze), document.removeEventListener("touchmove", Ze), document.removeEventListener("mouseup", Ie), document.removeEventListener("touchend", Ie), document.removeEventListener("click", gt, !0), document.removeEventListener("mousemove", tt), document.removeEventListener("touchmove", tt), document.removeEventListener("mouseup", nt), document.removeEventListener("touchend", nt), oe && clearTimeout(oe), M && cancelAnimationFrame(M);
|
|
2043
|
+
}), (e, c) => (v(), m("div", null, [
|
|
2044
|
+
Me(o("div", {
|
|
1984
2045
|
ref_key: "panelRef",
|
|
1985
|
-
ref:
|
|
1986
|
-
class:
|
|
2046
|
+
ref: C,
|
|
2047
|
+
class: se([
|
|
1987
2048
|
"ai-panel",
|
|
1988
|
-
|
|
1989
|
-
|
|
2049
|
+
f.value ? "maxWrap" : "minWrap",
|
|
2050
|
+
Z.value,
|
|
1990
2051
|
{
|
|
1991
|
-
"panel-custom":
|
|
1992
|
-
dragging:
|
|
1993
|
-
"dock-preview":
|
|
1994
|
-
docked:
|
|
1995
|
-
"dock-resizing":
|
|
1996
|
-
"dock-switching":
|
|
1997
|
-
"dock-switch-instant":
|
|
2052
|
+
"panel-custom": T.value && !f.value && !r.value && !S.value && $.value === "idle",
|
|
2053
|
+
dragging: W.value,
|
|
2054
|
+
"dock-preview": q.value,
|
|
2055
|
+
docked: S.value,
|
|
2056
|
+
"dock-resizing": N.value,
|
|
2057
|
+
"dock-switching": $.value !== "idle",
|
|
2058
|
+
"dock-switch-instant": Y.value,
|
|
1998
2059
|
"dock-switch-fade-in": H.value === "in",
|
|
1999
2060
|
"dock-switch-fade-out": H.value === "out",
|
|
2000
|
-
"no-drag": !
|
|
2061
|
+
"no-drag": !Ce.value
|
|
2001
2062
|
},
|
|
2002
2063
|
l.value !== "idle" ? l.value : "",
|
|
2003
|
-
{ morphing: l.value !== "idle", "morph-instant":
|
|
2064
|
+
{ morphing: l.value !== "idle", "morph-instant": h.value }
|
|
2004
2065
|
]),
|
|
2005
|
-
style:
|
|
2066
|
+
style: it([zt.value, qt.value, Kt.value])
|
|
2006
2067
|
}, [
|
|
2007
|
-
|
|
2068
|
+
S.value ? (v(), m("div", {
|
|
2008
2069
|
key: 0,
|
|
2009
2070
|
class: "ai-dock-resizer",
|
|
2010
|
-
onMousedown:
|
|
2011
|
-
onTouchstart:
|
|
2012
|
-
}, null, 32)) :
|
|
2013
|
-
|
|
2071
|
+
onMousedown: fe(Ct, ["stop"]),
|
|
2072
|
+
onTouchstart: fe(Ct, ["stop"])
|
|
2073
|
+
}, null, 32)) : J("", !0),
|
|
2074
|
+
o("div", {
|
|
2014
2075
|
class: "header",
|
|
2015
|
-
onMousedown:
|
|
2016
|
-
onTouchstart:
|
|
2076
|
+
onMousedown: ft,
|
|
2077
|
+
onTouchstart: ft
|
|
2017
2078
|
}, [
|
|
2018
|
-
|
|
2079
|
+
k.value === "info" ? (v(), m("span", {
|
|
2019
2080
|
key: 0,
|
|
2020
|
-
class:
|
|
2021
|
-
onClick:
|
|
2022
|
-
}, [...
|
|
2023
|
-
|
|
2024
|
-
])], 2)) : (v(),
|
|
2025
|
-
|
|
2081
|
+
class: se(["back", d.value]),
|
|
2082
|
+
onClick: c[0] || (c[0] = (A) => k.value = "answer")
|
|
2083
|
+
}, [...c[5] || (c[5] = [
|
|
2084
|
+
o("span", { style: { "font-size": "14px" } }, "←", -1)
|
|
2085
|
+
])], 2)) : (v(), m("p", Ys, [
|
|
2086
|
+
o("img", {
|
|
2026
2087
|
src: O(Qt),
|
|
2027
2088
|
draggable: "false"
|
|
2028
|
-
}, null, 8,
|
|
2089
|
+
}, null, 8, Ns)
|
|
2029
2090
|
])),
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
title:
|
|
2033
|
-
},
|
|
2091
|
+
o("div", Vs, [
|
|
2092
|
+
o("span", {
|
|
2093
|
+
title: k.value === "info" ? "个人信息" : X.value || O(i).name
|
|
2094
|
+
}, z(k.value === "info" ? "个人信息" : X.value || O(i).name), 9, Xs)
|
|
2034
2095
|
]),
|
|
2035
|
-
|
|
2036
|
-
|
|
2096
|
+
o("p", null, [
|
|
2097
|
+
Me(ie(O(ce), {
|
|
2037
2098
|
class: "op-icon",
|
|
2038
2099
|
icon: "ic:round-add",
|
|
2039
2100
|
onClick: vn
|
|
2040
2101
|
}, null, 512), [
|
|
2041
|
-
[Ve,
|
|
2102
|
+
[Ve, Re.value]
|
|
2042
2103
|
]),
|
|
2043
|
-
|
|
2044
|
-
class:
|
|
2104
|
+
ie(O(ce), {
|
|
2105
|
+
class: se(["mute", { active: K.value }]),
|
|
2045
2106
|
icon: "ic:round-history",
|
|
2046
|
-
onClick:
|
|
2107
|
+
onClick: c[1] || (c[1] = (A) => K.value ? Be() : hn())
|
|
2047
2108
|
}, null, 8, ["class"]),
|
|
2048
|
-
!
|
|
2109
|
+
!r.value && !S.value ? (v(), pe(O(ce), {
|
|
2049
2110
|
key: 0,
|
|
2050
|
-
onClick:
|
|
2051
|
-
icon:
|
|
2052
|
-
}, null, 8, ["icon"])) :
|
|
2053
|
-
|
|
2111
|
+
onClick: on,
|
|
2112
|
+
icon: f.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
|
|
2113
|
+
}, null, 8, ["icon"])) : J("", !0),
|
|
2114
|
+
S.value ? (v(), pe(O(ce), {
|
|
2054
2115
|
key: 1,
|
|
2055
2116
|
icon: "material-symbols:float-landscape-2-outline-rounded",
|
|
2056
2117
|
onClick: _t
|
|
2057
|
-
})) :
|
|
2058
|
-
|
|
2118
|
+
})) : J("", !0),
|
|
2119
|
+
ae.value && !S.value ? (v(), pe(O(ce), {
|
|
2059
2120
|
key: 2,
|
|
2060
2121
|
icon: "boxicons:arrow-in-up-right-stroke-square",
|
|
2061
2122
|
onClick: kt,
|
|
2062
2123
|
class: "__minimize"
|
|
2063
|
-
})) :
|
|
2064
|
-
|
|
2124
|
+
})) : J("", !0),
|
|
2125
|
+
ie(O(ce), {
|
|
2065
2126
|
onClick: rn,
|
|
2066
2127
|
icon: "ic:round-close"
|
|
2067
2128
|
})
|
|
2068
2129
|
])
|
|
2069
2130
|
], 32),
|
|
2070
|
-
|
|
2131
|
+
Me(ie(ds, {
|
|
2071
2132
|
ref_key: "answerRef",
|
|
2072
|
-
ref:
|
|
2133
|
+
ref: Q,
|
|
2073
2134
|
defaultSayhello: O(i).defaultSayhello,
|
|
2074
2135
|
defaultRecommend: O(i).defaultRecommend,
|
|
2075
|
-
onTitleGenerated:
|
|
2136
|
+
onTitleGenerated: c[2] || (c[2] = (A) => X.value = A)
|
|
2076
2137
|
}, null, 8, ["defaultSayhello", "defaultRecommend"]), [
|
|
2077
|
-
[Ve,
|
|
2138
|
+
[Ve, k.value === "answer"]
|
|
2078
2139
|
]),
|
|
2079
|
-
|
|
2080
|
-
|
|
2140
|
+
k.value === "info" ? (v(), pe(Ws, { key: 1 })) : J("", !0),
|
|
2141
|
+
K.value ? (v(), m("div", {
|
|
2081
2142
|
key: 2,
|
|
2082
|
-
class:
|
|
2143
|
+
class: se(["ai-history-drawer", { closing: G.value }])
|
|
2083
2144
|
}, [
|
|
2084
|
-
|
|
2145
|
+
o("div", {
|
|
2085
2146
|
class: "ai-history-backdrop",
|
|
2086
2147
|
onClick: Be
|
|
2087
2148
|
}),
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2149
|
+
o("div", Fs, [
|
|
2150
|
+
o("div", Qs, [
|
|
2151
|
+
c[6] || (c[6] = o("span", null, "对话记录", -1)),
|
|
2152
|
+
ie(O(ce), {
|
|
2092
2153
|
icon: "ic:round-close",
|
|
2093
2154
|
class: "ai-history-drawer-close",
|
|
2094
2155
|
onClick: Be
|
|
2095
2156
|
})
|
|
2096
2157
|
]),
|
|
2097
|
-
|
|
2158
|
+
ie(As, {
|
|
2098
2159
|
onHistoryDetail: cn,
|
|
2099
2160
|
onNewConversation: dn
|
|
2100
2161
|
})
|
|
2101
2162
|
])
|
|
2102
|
-
], 2)) :
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
"onUpdate:modelValue":
|
|
2163
|
+
], 2)) : J("", !0),
|
|
2164
|
+
Me(o("div", Js, [
|
|
2165
|
+
o("div", qs, [
|
|
2166
|
+
o("div", zs, [
|
|
2167
|
+
c[7] || (c[7] = o("p", { class: "title" }, "修改标题", -1)),
|
|
2168
|
+
Me(o("textarea", {
|
|
2169
|
+
"onUpdate:modelValue": c[3] || (c[3] = (A) => p.value = A),
|
|
2109
2170
|
placeholder: "请输入新标题"
|
|
2110
2171
|
}, null, 512), [
|
|
2111
|
-
[Vt,
|
|
2172
|
+
[Vt, p.value]
|
|
2112
2173
|
]),
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
onClick:
|
|
2174
|
+
o("p", Ks, [
|
|
2175
|
+
o("span", {
|
|
2176
|
+
onClick: c[4] || (c[4] = (A) => V.value = !1)
|
|
2116
2177
|
}, "取消"),
|
|
2117
|
-
|
|
2178
|
+
o("span", { onClick: pn }, "确定")
|
|
2118
2179
|
])
|
|
2119
2180
|
])
|
|
2120
2181
|
])
|
|
2121
2182
|
], 512), [
|
|
2122
|
-
[Ve,
|
|
2183
|
+
[Ve, V.value]
|
|
2123
2184
|
])
|
|
2124
2185
|
], 6), [
|
|
2125
|
-
[Ve,
|
|
2186
|
+
[Ve, u.value || l.value !== "idle"]
|
|
2126
2187
|
]),
|
|
2127
|
-
|
|
2188
|
+
q.value && ae.value ? (v(), m("div", {
|
|
2128
2189
|
key: 0,
|
|
2129
2190
|
class: "ai-dock-preview",
|
|
2130
|
-
style:
|
|
2131
|
-
}, [...
|
|
2132
|
-
|
|
2133
|
-
])], 4)) :
|
|
2134
|
-
|
|
2135
|
-
class:
|
|
2136
|
-
style:
|
|
2137
|
-
onMousedown:
|
|
2138
|
-
onTouchstart:
|
|
2191
|
+
style: it({ width: ee.value + "px" })
|
|
2192
|
+
}, [...c[8] || (c[8] = [
|
|
2193
|
+
o("span", { class: "ai-dock-preview__text" }, "松开以停靠到右侧", -1)
|
|
2194
|
+
])], 4)) : J("", !0),
|
|
2195
|
+
Me(o("div", {
|
|
2196
|
+
class: se(["character", { dragging: E.value, recycling: te.value, "hover-preview": a.value }]),
|
|
2197
|
+
style: it(ze.value),
|
|
2198
|
+
onMousedown: mt,
|
|
2199
|
+
onTouchstart: mt,
|
|
2139
2200
|
onClick: un
|
|
2140
2201
|
}, [
|
|
2141
|
-
|
|
2202
|
+
o("img", { src: lt.value }, null, 8, Gs)
|
|
2142
2203
|
], 38), [
|
|
2143
|
-
[Ve, !
|
|
2204
|
+
[Ve, !u.value]
|
|
2144
2205
|
])
|
|
2145
2206
|
]));
|
|
2146
2207
|
}
|
|
2147
|
-
}),
|
|
2208
|
+
}), ea = ["data-theme"], ta = {
|
|
2148
2209
|
key: 0,
|
|
2149
2210
|
class: "ai-voice-input-final"
|
|
2150
|
-
},
|
|
2211
|
+
}, na = {
|
|
2151
2212
|
key: 1,
|
|
2152
2213
|
class: "ai-voice-input-interim"
|
|
2153
|
-
},
|
|
2214
|
+
}, oa = {
|
|
2154
2215
|
key: 2,
|
|
2155
2216
|
class: "ai-voice-input-cursor"
|
|
2156
|
-
},
|
|
2217
|
+
}, sa = {
|
|
2157
2218
|
key: 3,
|
|
2158
2219
|
class: "ai-voice-input-placeholder"
|
|
2159
|
-
},
|
|
2220
|
+
}, aa = ["disabled"], ia = {
|
|
2160
2221
|
key: 0,
|
|
2161
2222
|
class: "ai-voice-input-pulse"
|
|
2162
|
-
},
|
|
2223
|
+
}, la = {
|
|
2163
2224
|
key: 1,
|
|
2164
2225
|
class: "ai-voice-input-wave"
|
|
2165
|
-
},
|
|
2226
|
+
}, ua = {
|
|
2166
2227
|
key: 2,
|
|
2167
2228
|
class: "ai-voice-input-btn-icon",
|
|
2168
2229
|
viewBox: "0 0 24 24",
|
|
2169
2230
|
fill: "currentColor",
|
|
2170
2231
|
width: "16",
|
|
2171
2232
|
height: "16"
|
|
2172
|
-
},
|
|
2233
|
+
}, ra = /* @__PURE__ */ Ee({
|
|
2173
2234
|
__name: "VoiceInput",
|
|
2174
2235
|
props: {
|
|
2175
2236
|
lang: {},
|
|
@@ -2184,138 +2245,138 @@ const Is = { class: "container" }, eo = { class: "chat-wrap" }, to = { class: "m
|
|
|
2184
2245
|
className: {}
|
|
2185
2246
|
},
|
|
2186
2247
|
emits: ["result", "final", "error", "statusChange", "complete"],
|
|
2187
|
-
setup(t, { expose:
|
|
2188
|
-
const
|
|
2248
|
+
setup(t, { expose: w, emit: i }) {
|
|
2249
|
+
const u = t, l = i, h = {
|
|
2189
2250
|
idle: "开始录音",
|
|
2190
2251
|
connecting: "启动中…",
|
|
2191
2252
|
recording: "停止录音",
|
|
2192
2253
|
stopping: "识别中…",
|
|
2193
2254
|
error: "重试"
|
|
2194
|
-
},
|
|
2195
|
-
let
|
|
2196
|
-
const
|
|
2197
|
-
lang:
|
|
2198
|
-
continuous:
|
|
2199
|
-
interimResults:
|
|
2255
|
+
}, s = g(""), a = g(""), r = g("idle"), f = Qe.isSupported();
|
|
2256
|
+
let k = null;
|
|
2257
|
+
const V = B(() => Ln(u.theme)), p = () => ({
|
|
2258
|
+
lang: u.lang,
|
|
2259
|
+
continuous: u.continuous,
|
|
2260
|
+
interimResults: u.interimResults
|
|
2200
2261
|
}), R = () => {
|
|
2201
|
-
|
|
2202
|
-
onStatusChange: (
|
|
2203
|
-
|
|
2262
|
+
f && (k = new Qe(p(), {
|
|
2263
|
+
onStatusChange: (d) => {
|
|
2264
|
+
r.value = d, l("statusChange", d), d === "idle" && l("complete", s.value);
|
|
2204
2265
|
},
|
|
2205
|
-
onInterim: (
|
|
2206
|
-
a.value =
|
|
2266
|
+
onInterim: (d) => {
|
|
2267
|
+
a.value = d;
|
|
2207
2268
|
},
|
|
2208
|
-
onFinal: (
|
|
2209
|
-
|
|
2269
|
+
onFinal: (d, C) => {
|
|
2270
|
+
s.value += d, a.value = "", l("final", d, C);
|
|
2210
2271
|
},
|
|
2211
|
-
onResult: (
|
|
2212
|
-
onError: (
|
|
2272
|
+
onResult: (d) => l("result", d),
|
|
2273
|
+
onError: (d) => l("error", d)
|
|
2213
2274
|
}));
|
|
2214
2275
|
};
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
}),
|
|
2218
|
-
() => [
|
|
2276
|
+
be(R), Nt(() => {
|
|
2277
|
+
k == null || k.destroy(), k = null;
|
|
2278
|
+
}), ve(
|
|
2279
|
+
() => [u.lang, u.continuous, u.interimResults],
|
|
2219
2280
|
() => {
|
|
2220
|
-
|
|
2281
|
+
k == null || k.destroy(), R();
|
|
2221
2282
|
}
|
|
2222
2283
|
);
|
|
2223
2284
|
const X = async () => {
|
|
2224
|
-
if (
|
|
2225
|
-
if (
|
|
2285
|
+
if (k)
|
|
2286
|
+
if (r.value === "idle" || r.value === "error")
|
|
2226
2287
|
try {
|
|
2227
|
-
await
|
|
2288
|
+
await k.start();
|
|
2228
2289
|
} catch {
|
|
2229
2290
|
}
|
|
2230
|
-
else
|
|
2231
|
-
},
|
|
2232
|
-
|
|
2233
|
-
},
|
|
2234
|
-
() =>
|
|
2235
|
-
),
|
|
2236
|
-
const
|
|
2237
|
-
return
|
|
2291
|
+
else r.value === "recording" && k.stop();
|
|
2292
|
+
}, K = () => {
|
|
2293
|
+
s.value = "", a.value = "";
|
|
2294
|
+
}, G = B(() => !s.value && !a.value), _ = B(
|
|
2295
|
+
() => f ? u.placeholder || "点击按钮开始语音输入…" : "当前浏览器不支持语音识别"
|
|
2296
|
+
), E = B(() => f ? r.value === "connecting" ? u.connectingText || h.connecting : r.value === "recording" ? u.stopText || h.recording : r.value === "stopping" ? u.stoppingText || h.stopping : r.value === "error" ? h.error : u.startText || h.idle : "不支持"), te = B(() => {
|
|
2297
|
+
const d = ["ai-voice-input-btn"];
|
|
2298
|
+
return r.value === "recording" && d.push("is-recording"), r.value === "connecting" && d.push("is-connecting"), r.value === "stopping" && d.push("is-stopping"), d.join(" ");
|
|
2238
2299
|
}), n = B(
|
|
2239
|
-
() => !
|
|
2300
|
+
() => !f || r.value === "connecting" || r.value === "stopping"
|
|
2240
2301
|
);
|
|
2241
|
-
return
|
|
2302
|
+
return w({
|
|
2242
2303
|
start: async () => {
|
|
2243
|
-
await (
|
|
2304
|
+
await (k == null ? void 0 : k.start());
|
|
2244
2305
|
},
|
|
2245
|
-
stop: () =>
|
|
2246
|
-
cancel: () =>
|
|
2247
|
-
getText: () =>
|
|
2306
|
+
stop: () => k == null ? void 0 : k.stop(),
|
|
2307
|
+
cancel: () => k == null ? void 0 : k.cancel(),
|
|
2308
|
+
getText: () => s.value + a.value,
|
|
2248
2309
|
clear: () => {
|
|
2249
|
-
|
|
2310
|
+
s.value = "", a.value = "";
|
|
2250
2311
|
},
|
|
2251
|
-
getStatus: () => (
|
|
2252
|
-
}), (
|
|
2253
|
-
class:
|
|
2254
|
-
"data-theme":
|
|
2312
|
+
getStatus: () => (k == null ? void 0 : k.getStatus()) ?? "idle"
|
|
2313
|
+
}), (d, C) => (v(), m("div", {
|
|
2314
|
+
class: se(["ai-voice-input", t.className]),
|
|
2315
|
+
"data-theme": V.value
|
|
2255
2316
|
}, [
|
|
2256
|
-
|
|
2257
|
-
class:
|
|
2317
|
+
o("div", {
|
|
2318
|
+
class: se(["ai-voice-input-display", { "is-empty": G.value }])
|
|
2258
2319
|
}, [
|
|
2259
|
-
|
|
2260
|
-
a.value ? (v(),
|
|
2261
|
-
|
|
2262
|
-
|
|
2320
|
+
s.value ? (v(), m("span", ta, z(s.value), 1)) : J("", !0),
|
|
2321
|
+
a.value ? (v(), m("span", na, z(a.value), 1)) : J("", !0),
|
|
2322
|
+
r.value === "recording" && !a.value ? (v(), m("span", oa)) : J("", !0),
|
|
2323
|
+
G.value ? (v(), m("span", sa, z(_.value), 1)) : J("", !0)
|
|
2263
2324
|
], 2),
|
|
2264
|
-
|
|
2325
|
+
o("button", {
|
|
2265
2326
|
type: "button",
|
|
2266
|
-
class:
|
|
2327
|
+
class: se(te.value),
|
|
2267
2328
|
disabled: n.value,
|
|
2268
2329
|
onClick: X
|
|
2269
2330
|
}, [
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
])])) : (v(),
|
|
2277
|
-
|
|
2278
|
-
|
|
2331
|
+
r.value === "recording" ? (v(), m("span", ia)) : r.value === "connecting" || r.value === "stopping" ? (v(), m("span", la, [...C[0] || (C[0] = [
|
|
2332
|
+
o("span", null, null, -1),
|
|
2333
|
+
o("span", null, null, -1),
|
|
2334
|
+
o("span", null, null, -1),
|
|
2335
|
+
o("span", null, null, -1),
|
|
2336
|
+
o("span", null, null, -1)
|
|
2337
|
+
])])) : (v(), m("svg", ua, [...C[1] || (C[1] = [
|
|
2338
|
+
o("path", { d: "M12 14a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v5a3 3 0 0 0 3 3z" }, null, -1),
|
|
2339
|
+
o("path", { d: "M19 11a7 7 0 0 1-14 0H3a9 9 0 0 0 8 8.94V23h2v-3.06A9 9 0 0 0 21 11h-2z" }, null, -1)
|
|
2279
2340
|
])])),
|
|
2280
|
-
|
|
2281
|
-
], 10,
|
|
2282
|
-
|
|
2341
|
+
o("span", null, z(E.value), 1)
|
|
2342
|
+
], 10, aa),
|
|
2343
|
+
G.value ? J("", !0) : (v(), m("button", {
|
|
2283
2344
|
key: 0,
|
|
2284
2345
|
type: "button",
|
|
2285
2346
|
class: "ai-voice-input-btn ai-voice-input-clear-btn",
|
|
2286
2347
|
title: "清空",
|
|
2287
|
-
onClick:
|
|
2348
|
+
onClick: K
|
|
2288
2349
|
}, " 清空 "))
|
|
2289
|
-
], 10,
|
|
2350
|
+
], 10, ea));
|
|
2290
2351
|
}
|
|
2291
|
-
}),
|
|
2352
|
+
}), ca = (t, w) => {
|
|
2292
2353
|
const i = t.__vccOpts || t;
|
|
2293
|
-
for (const [
|
|
2294
|
-
i[
|
|
2354
|
+
for (const [u, l] of w)
|
|
2355
|
+
i[u] = l;
|
|
2295
2356
|
return i;
|
|
2296
|
-
},
|
|
2297
|
-
let
|
|
2298
|
-
const
|
|
2357
|
+
}, va = /* @__PURE__ */ ca(ra, [["__scopeId", "data-v-53d3cc6e"]]);
|
|
2358
|
+
let Je = null;
|
|
2359
|
+
const ga = (t) => {
|
|
2299
2360
|
Ft(t);
|
|
2300
|
-
},
|
|
2301
|
-
const
|
|
2361
|
+
}, ya = (t) => {
|
|
2362
|
+
const w = t || document.body, i = document.createElement("div");
|
|
2302
2363
|
i.id = "ai-assist-root";
|
|
2303
|
-
const
|
|
2304
|
-
ht(
|
|
2305
|
-
},
|
|
2306
|
-
|
|
2364
|
+
const u = qe();
|
|
2365
|
+
ht(u.theme), Pn(), w.appendChild(i), Je = Cn(Jt), Je.mount(i);
|
|
2366
|
+
}, wa = () => {
|
|
2367
|
+
Je && (Je.unmount(), Je = null);
|
|
2307
2368
|
const t = document.getElementById("ai-assist-root");
|
|
2308
2369
|
t && t.remove();
|
|
2309
|
-
},
|
|
2310
|
-
install(t,
|
|
2311
|
-
Ft(
|
|
2370
|
+
}, ka = {
|
|
2371
|
+
install(t, w) {
|
|
2372
|
+
Ft(w), t.component("AiAssist", Jt), t.component("VoiceInput", va);
|
|
2312
2373
|
}
|
|
2313
2374
|
};
|
|
2314
2375
|
export {
|
|
2315
2376
|
Jt as AiAssist,
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2377
|
+
va as VoiceInput,
|
|
2378
|
+
ka as default,
|
|
2379
|
+
ga as initAiAssist,
|
|
2380
|
+
ya as mountAiAssist,
|
|
2381
|
+
wa as unmountAiAssist
|
|
2321
2382
|
};
|