@somecat/ai-assist-sdk 1.1.24 → 1.1.26

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.
@@ -1,79 +1,79 @@
1
- import { defineComponent as nt, ref as C, watch as Ct, onUnmounted as At, openBlock as w, createElementBlock as S, normalizeClass as J, createElementVNode as s, toDisplayString as F, createVNode as X, Transition as Ft, withCtx as Vt, createTextVNode as Xt, createCommentVNode as V, reactive as I, Fragment as K, createStaticVNode as Gt, renderList as ut, unref as O, createBlock as tt, withKeys as Jt, nextTick as Z, computed as _, onMounted as et, normalizeStyle as Mt, withModifiers as Ht, Teleport as qt, withDirectives as rt, vShow as gt, vModelText as _t, createApp as Ut } from "vue";
2
- import { r as Ot, p as $t, u as jt, c as Pt, g as Kt, s as zt, a as Nt, e as Zt, b as It, d as ft, f as te, h as ee, i as ne, j as se, k as oe, l as Tt, w as ae, m as ie, n as Lt } from "../chunks/index-CWRmx9Cv.mjs";
3
- import { f as le, s as ct, a as xt, b as re, c as ce } from "../chunks/index-DBik4Gma.mjs";
4
- import { SearchOutlined as ue, CheckOutlined as ve, CopyOutlined as de, RedoOutlined as ge } from "@ant-design/icons-vue";
5
- import { Icon as j } from "@iconify/vue";
6
- const he = "data:image/png;base64,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", me = { class: "thinking-block__title" }, fe = {
1
+ import { defineComponent as ee, ref as C, watch as se, onUnmounted as Ae, openBlock as m, createElementBlock as k, normalizeClass as X, createElementVNode as n, toDisplayString as V, createVNode as Y, Transition as Ge, withCtx as Xe, createTextVNode as Je, createCommentVNode as _, reactive as ne, Fragment as I, createStaticVNode as qe, renderList as ve, unref as D, createBlock as Z, Teleport as Le, withModifiers as be, computed as F, onMounted as j, onBeforeUnmount as Ne, nextTick as K, normalizeStyle as Se, withKeys as Ue, withDirectives as re, vShow as he, vModelText as je, createApp as ze } from "vue";
2
+ import { u as De, E as He, C as Ke, l as de, a as _e, f as Oe, n as Ze, z as Ie, e as Pe, h as et, B as tt, j as nt, F as st, m as ot, g as at, p as it, c as $e, D as lt, w as ct, G as rt, x as Ve } from "../chunks/engine-DxdqzC3A.mjs";
3
+ import { f as ut, s as ue, b as We, a as vt, c as dt } from "../chunks/index-CgnkZbtP.mjs";
4
+ import { SearchOutlined as gt, CheckOutlined as mt, CopyOutlined as ht, RedoOutlined as pt, CloseOutlined as ft } from "@ant-design/icons-vue";
5
+ import { Icon as J } from "@iconify/vue";
6
+ const yt = "data:image/png;base64,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", wt = { class: "thinking-block__title" }, kt = {
7
7
  key: 0,
8
8
  class: "thinking-block__content"
9
- }, pe = {
9
+ }, Ct = {
10
10
  key: 0,
11
11
  class: "streaming-cursor"
12
- }, ye = /* @__PURE__ */ nt({
12
+ }, At = /* @__PURE__ */ ee({
13
13
  __name: "ThinkingBlock",
14
14
  props: {
15
15
  content: {},
16
16
  isStreaming: { type: Boolean }
17
17
  },
18
- setup(t) {
19
- const u = t, r = C(!1);
20
- function v() {
21
- r.value = !r.value;
18
+ setup(e) {
19
+ const p = e, h = C(!1);
20
+ function u() {
21
+ h.value = !h.value;
22
22
  }
23
- const o = C(u.content), c = C(u.content.length), a = C(0);
24
- let n = 0, f = 0;
25
- function M() {
26
- if (n) return;
27
- const h = 80, g = (E) => {
28
- if (f === 0) {
29
- f = E, n = requestAnimationFrame(g);
23
+ const l = C(p.content), c = C(p.content.length), i = C(0);
24
+ let s = 0, a = 0;
25
+ function d() {
26
+ if (s) return;
27
+ const v = 80, y = ($) => {
28
+ if (a === 0) {
29
+ a = $, s = requestAnimationFrame(y);
30
30
  return;
31
31
  }
32
- const b = Math.min(E - f, 100);
33
- f = E;
34
- const L = u.content, e = L.length - c.value;
35
- if (e > 0) {
36
- const x = h + e;
37
- a.value += x * b / 1e3;
38
- const D = Math.floor(a.value);
39
- D > 0 && (a.value -= D, c.value = Math.min(c.value + D, L.length), o.value = L.slice(0, c.value));
32
+ const M = Math.min($ - a, 100);
33
+ a = $;
34
+ const P = p.content, t = P.length - c.value;
35
+ if (t > 0) {
36
+ const E = v + t;
37
+ i.value += E * M / 1e3;
38
+ const x = Math.floor(i.value);
39
+ x > 0 && (i.value -= x, c.value = Math.min(c.value + x, P.length), l.value = P.slice(0, c.value));
40
40
  } else
41
- a.value = 0;
42
- n = requestAnimationFrame(g);
41
+ i.value = 0;
42
+ s = requestAnimationFrame(y);
43
43
  };
44
- f = 0, n = requestAnimationFrame(g);
44
+ a = 0, s = requestAnimationFrame(y);
45
45
  }
46
- function B() {
47
- n && (cancelAnimationFrame(n), n = 0);
46
+ function f() {
47
+ s && (cancelAnimationFrame(s), s = 0);
48
48
  }
49
- function R() {
50
- B(), o.value = u.content, c.value = u.content.length, a.value = 0;
49
+ function A() {
50
+ f(), l.value = p.content, c.value = p.content.length, i.value = 0;
51
51
  }
52
- return Ct(
53
- () => u.content,
52
+ return se(
53
+ () => p.content,
54
54
  () => {
55
- u.isStreaming || R();
55
+ p.isStreaming || A();
56
56
  }
57
- ), Ct(
58
- () => u.isStreaming,
59
- (h) => {
60
- h ? M() : R();
57
+ ), se(
58
+ () => p.isStreaming,
59
+ (v) => {
60
+ v ? d() : A();
61
61
  },
62
62
  { immediate: !0 }
63
- ), At(B), (h, g) => (w(), S("div", {
64
- class: J(["thinking-block", {
65
- "thinking-block--expanded": r.value,
66
- "thinking-block--active": t.isStreaming
63
+ ), Ae(f), (v, y) => (m(), k("div", {
64
+ class: X(["thinking-block", {
65
+ "thinking-block--expanded": h.value,
66
+ "thinking-block--active": e.isStreaming
67
67
  }])
68
68
  }, [
69
- s("div", {
69
+ n("div", {
70
70
  class: "thinking-block__header",
71
- onClick: v
71
+ onClick: u
72
72
  }, [
73
- g[1] || (g[1] = s("span", { class: "thinking-block__indicator" }, null, -1)),
74
- s("span", me, F(t.isStreaming ? "深度思考中" : "深度思考"), 1),
75
- (w(), S("svg", {
76
- class: J(["thinking-block__arrow", { "thinking-block__arrow--down": r.value }]),
73
+ y[1] || (y[1] = n("span", { class: "thinking-block__indicator" }, null, -1)),
74
+ n("span", wt, V(e.isStreaming ? "深度思考中" : "深度思考"), 1),
75
+ (m(), k("svg", {
76
+ class: X(["thinking-block__arrow", { "thinking-block__arrow--down": h.value }]),
77
77
  viewBox: "0 0 24 24",
78
78
  width: "14",
79
79
  height: "14",
@@ -82,43 +82,43 @@ const he = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
82
82
  "stroke-width": "2.5",
83
83
  "stroke-linecap": "round",
84
84
  "stroke-linejoin": "round"
85
- }, [...g[0] || (g[0] = [
86
- s("polyline", { points: "6 9 12 15 18 9" }, null, -1)
85
+ }, [...y[0] || (y[0] = [
86
+ n("polyline", { points: "6 9 12 15 18 9" }, null, -1)
87
87
  ])], 2))
88
88
  ]),
89
- X(Ft, { name: "thinking-expand" }, {
90
- default: Vt(() => [
91
- r.value ? (w(), S("div", fe, [
92
- Xt(F(o.value), 1),
93
- t.isStreaming ? (w(), S("span", pe)) : V("", !0)
94
- ])) : V("", !0)
89
+ Y(Ge, { name: "thinking-expand" }, {
90
+ default: Xe(() => [
91
+ h.value ? (m(), k("div", kt, [
92
+ Je(V(l.value), 1),
93
+ e.isStreaming ? (m(), k("span", Ct)) : _("", !0)
94
+ ])) : _("", !0)
95
95
  ]),
96
96
  _: 1
97
97
  })
98
98
  ], 2));
99
99
  }
100
- }), we = {
100
+ }), bt = {
101
101
  key: 0,
102
102
  class: "message-content ba-markdown"
103
- }, ke = { class: "agent-thought__spinner" }, Ce = { class: "agent-thought__text" }, Ae = { key: 2 }, Se = ["innerHTML"], be = {
103
+ }, St = { class: "agent-thought__spinner" }, Tt = { class: "agent-thought__text" }, Et = { key: 2 }, Rt = ["innerHTML"], Mt = {
104
104
  key: 0,
105
105
  class: "streaming-cursor"
106
- }, Re = ["innerHTML"], Ee = {
106
+ }, $t = ["innerHTML"], xt = {
107
107
  key: 0,
108
108
  class: "streaming-cursor"
109
- }, Me = {
109
+ }, Dt = {
110
110
  key: 3,
111
111
  class: "message-error"
112
- }, Te = {
112
+ }, Ht = {
113
113
  key: 4,
114
114
  class: "message-toolbar"
115
- }, De = ["data-tooltip"], He = {
115
+ }, Ot = ["data-tooltip"], Pt = {
116
116
  class: "tooltip-enhanced",
117
117
  "data-tooltip": "重新回答"
118
- }, Oe = {
118
+ }, Bt = {
119
119
  key: 1,
120
120
  class: "message-content"
121
- }, $e = /* @__PURE__ */ nt({
121
+ }, Lt = ["src"], Nt = /* @__PURE__ */ ee({
122
122
  __name: "MessageItem",
123
123
  props: {
124
124
  msg: {},
@@ -129,100 +129,147 @@ const he = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
129
129
  setMessageRef: { type: Function }
130
130
  },
131
131
  emits: ["regenerate"],
132
- setup(t, { emit: u }) {
133
- const r = I(/* @__PURE__ */ new Map());
134
- function v(o, c) {
135
- var a;
132
+ setup(e, { emit: p }) {
133
+ const h = ne(/* @__PURE__ */ new Map()), u = C("");
134
+ function l(s) {
135
+ const a = s.target;
136
+ a.tagName === "IMG" && (u.value = a.src);
137
+ }
138
+ function c() {
139
+ u.value = "";
140
+ }
141
+ function i(s, a) {
142
+ var d;
136
143
  try {
137
- let n = o.content;
138
- if (!n && ((a = o.segments) != null && a.length) && (n = o.segments.filter((f) => f.type !== "thinking" && f.type !== "agent_thought").map((f) => f.content).join(`
139
- `)), n) {
140
- const { copy: f } = jt();
141
- f(n), r.set(c, !0), setTimeout(() => r.set(c, !1), 2e3);
144
+ let f = s.content;
145
+ if (!f && ((d = s.segments) != null && d.length) && (f = s.segments.filter((A) => A.type !== "thinking" && A.type !== "agent_thought").map((A) => A.content).join(`
146
+ `)), f) {
147
+ const { copy: A } = Ke();
148
+ A(f), h.set(a, !0), setTimeout(() => h.set(a, !1), 2e3);
142
149
  }
143
150
  } catch {
144
151
  }
145
152
  }
146
- return (o, c) => {
147
- var a;
148
- return w(), S("div", {
149
- class: J(["message", `${t.msg.type}-message`])
153
+ return (s, a) => {
154
+ var d;
155
+ return m(), k("div", {
156
+ class: X(["message", `${e.msg.type}-message`])
150
157
  }, [
151
- t.msg.type === "ai" ? (w(), S(K, { key: 0 }, [
152
- (t.msg.status === t.STATUS.THINKING || t.msg.status === t.STATUS.RETHINKING) && !t.msg.thinkingContent && !t.msg.content ? (w(), S("div", we, [...c[2] || (c[2] = [
153
- Gt('<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)
154
- ])])) : V("", !0),
155
- t.msg.segments && t.msg.segments.length ? (w(), S("div", {
158
+ e.msg.type === "ai" ? (m(), k(I, { key: 0 }, [
159
+ (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING) && !e.msg.thinkingContent && !e.msg.content ? (m(), k("div", bt, [...a[3] || (a[3] = [
160
+ qe('<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)
161
+ ])])) : _("", !0),
162
+ e.msg.segments && e.msg.segments.length ? (m(), k("div", {
156
163
  key: 1,
157
164
  class: "message-content ba-markdown",
158
- ref: (n) => t.setMessageRef(n, t.index)
165
+ ref: (f) => e.setMessageRef(f, e.index),
166
+ onClick: l
159
167
  }, [
160
- (w(!0), S(K, null, ut(t.msg.segments, (n, f) => (w(), S(K, { key: f }, [
161
- n.type === "agent_thought" ? (w(), S("div", {
168
+ (m(!0), k(I, null, ve(e.msg.segments, (f, A) => (m(), k(I, { key: A }, [
169
+ f.type === "agent_thought" ? (m(), k("div", {
162
170
  key: 0,
163
- class: J(["agent-thought", { "agent-thought--done": n.duration != null }])
171
+ class: X(["agent-thought", { "agent-thought--done": f.duration != null }])
164
172
  }, [
165
- s("span", ke, [
166
- X(O(ue))
173
+ n("span", St, [
174
+ Y(D(gt))
167
175
  ]),
168
- s("span", Ce, F(n.duration != null ? "工具调用" : "工具调用中..."), 1)
169
- ], 2)) : n.type === "thinking" ? (w(), tt(ye, {
176
+ n("span", Tt, V(f.duration != null ? "工具调用" : "工具调用中..."), 1)
177
+ ], 2)) : f.type === "thinking" ? (m(), Z(At, {
170
178
  key: 1,
171
- content: n.content,
172
- "is-streaming": n.duration == null && (t.msg.status === t.STATUS.THINKING || t.msg.status === t.STATUS.RETHINKING)
173
- }, null, 8, ["content", "is-streaming"])) : (w(), S("div", Ae, [
174
- s("div", {
175
- innerHTML: O(Ot)(O($t)(t.getSegmentDisplayContent(t.index, f, n, t.msg)))
176
- }, null, 8, Se)
179
+ content: f.content,
180
+ "is-streaming": f.duration == null && (e.msg.status === e.STATUS.THINKING || e.msg.status === e.STATUS.RETHINKING)
181
+ }, null, 8, ["content", "is-streaming"])) : (m(), k("div", Et, [
182
+ n("div", {
183
+ innerHTML: D(De)(D(He)(e.getSegmentDisplayContent(e.index, A, f, e.msg)))
184
+ }, null, 8, Rt)
177
185
  ]))
178
186
  ], 64))), 128)),
179
- t.msg.status === t.STATUS.ANSWERING ? (w(), S("span", be)) : V("", !0)
180
- ], 512)) : V("", !0),
181
- !((a = t.msg.segments) != null && a.length) && t.msg.content ? (w(), S("div", {
187
+ e.msg.status === e.STATUS.ANSWERING ? (m(), k("span", Mt)) : _("", !0)
188
+ ], 512)) : _("", !0),
189
+ !((d = e.msg.segments) != null && d.length) && e.msg.content ? (m(), k("div", {
182
190
  key: 2,
183
191
  class: "message-content ba-markdown",
184
- ref: (n) => t.setMessageRef(n, t.index)
192
+ ref: (f) => e.setMessageRef(f, e.index),
193
+ onClick: l
185
194
  }, [
186
- s("div", {
187
- innerHTML: O(Ot)(O($t)(t.displayedContent.get(t.index) ?? t.msg.content))
188
- }, null, 8, Re),
189
- t.msg.status === t.STATUS.ANSWERING ? (w(), S("span", Ee)) : V("", !0)
190
- ], 512)) : V("", !0),
191
- t.msg.errorMessage ? (w(), S("div", Me, [
192
- c[3] || (c[3] = s("span", { class: "message-error__icon" }, "⚠️", -1)),
193
- s("span", null, F(t.msg.errorMessage), 1)
194
- ])) : V("", !0),
195
- t.msg.status === t.STATUS.COMPLETED || t.msg.status === t.STATUS.STOP ? (w(), S("div", Te, [
196
- s("div", {
195
+ n("div", {
196
+ innerHTML: D(De)(D(He)(e.displayedContent.get(e.index) ?? e.msg.content))
197
+ }, null, 8, $t),
198
+ e.msg.status === e.STATUS.ANSWERING ? (m(), k("span", xt)) : _("", !0)
199
+ ], 512)) : _("", !0),
200
+ e.msg.errorMessage ? (m(), k("div", Dt, [
201
+ a[4] || (a[4] = n("span", { class: "message-error__icon" }, "⚠️", -1)),
202
+ n("span", null, V(e.msg.errorMessage), 1)
203
+ ])) : _("", !0),
204
+ e.msg.status === e.STATUS.COMPLETED || e.msg.status === e.STATUS.STOP ? (m(), k("div", Ht, [
205
+ n("div", {
197
206
  class: "tooltip-enhanced",
198
- "data-tooltip": r.get(t.index) ? "已复制" : "复制回答"
207
+ "data-tooltip": h.get(e.index) ? "已复制" : "复制回答"
199
208
  }, [
200
- r.get(t.index) ? (w(), tt(O(ve), {
209
+ h.get(e.index) ? (m(), Z(D(mt), {
201
210
  key: 0,
202
211
  class: "message-toolbar__check"
203
- })) : (w(), tt(O(de), {
212
+ })) : (m(), Z(D(ht), {
204
213
  key: 1,
205
- onClick: c[0] || (c[0] = (n) => v(t.msg, t.index))
214
+ onClick: a[0] || (a[0] = (f) => i(e.msg, e.index))
206
215
  }))
207
- ], 8, De),
208
- s("div", He, [
209
- X(O(ge), {
210
- onClick: c[1] || (c[1] = (n) => o.$emit("regenerate"))
216
+ ], 8, Ot),
217
+ n("div", Pt, [
218
+ Y(D(pt), {
219
+ onClick: a[1] || (a[1] = (f) => s.$emit("regenerate"))
211
220
  })
212
221
  ])
213
- ])) : V("", !0)
214
- ], 64)) : (w(), S("div", Oe, F(t.msg.content), 1))
222
+ ])) : _("", !0)
223
+ ], 64)) : (m(), k("div", Bt, V(e.msg.content), 1)),
224
+ (m(), Z(Le, { to: "#ai-assist-root" }, [
225
+ u.value ? (m(), k("div", {
226
+ key: 0,
227
+ class: "ai-image-preview-overlay",
228
+ onClick: c
229
+ }, [
230
+ n("img", {
231
+ src: u.value,
232
+ class: "ai-image-preview-overlay__img",
233
+ onClick: a[2] || (a[2] = be(() => {
234
+ }, ["stop"]))
235
+ }, null, 8, Lt),
236
+ n("button", {
237
+ class: "ai-image-preview-overlay__close",
238
+ onClick: be(c, ["stop"])
239
+ }, [
240
+ Y(D(ft))
241
+ ])
242
+ ])) : _("", !0)
243
+ ]))
215
244
  ], 2);
216
245
  };
217
246
  }
218
- }), Pe = { class: "input-container" }, Ne = ["value", "disabled"], Be = {
247
+ }), _t = {
248
+ key: 0,
249
+ class: "input-container voice-mode"
250
+ }, Vt = {
251
+ key: 0,
252
+ class: "final"
253
+ }, Wt = {
254
+ key: 1,
255
+ class: "interim"
256
+ }, Yt = {
257
+ key: 2,
258
+ class: "placeholder"
259
+ }, Ft = ["data-tooltip"], Qt = {
260
+ key: 0,
261
+ class: "moveTB"
262
+ }, Gt = {
263
+ key: 1,
264
+ class: "input-container"
265
+ }, Xt = ["value", "disabled"], Jt = {
219
266
  key: 0,
220
267
  class: "tooltip-enhanced stop",
221
268
  "data-tooltip": "停止生成"
222
- }, Le = ["data-tooltip"], xe = {
223
- key: 2,
269
+ }, qt = ["data-tooltip"], Ut = {
270
+ key: 3,
224
271
  class: "moveTB"
225
- }, We = /* @__PURE__ */ nt({
272
+ }, jt = /* @__PURE__ */ ee({
226
273
  __name: "ChatInput",
227
274
  props: {
228
275
  modelValue: {},
@@ -232,561 +279,673 @@ const he = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAA
232
279
  isAtBottom: { type: Boolean }
233
280
  },
234
281
  emits: ["update:modelValue", "send", "stop", "scroll-to-bottom"],
235
- setup(t) {
236
- return (u, r) => (w(), S("div", Pe, [
237
- s("input", {
238
- value: t.modelValue,
282
+ setup(e, { emit: p }) {
283
+ const h = e, u = p, c = de().voice, i = C(!1), s = C(""), a = C(""), d = C("idle"), f = C(0), A = C(null);
284
+ let v = null;
285
+ const y = F(() => d.value === "connecting"), $ = F(
286
+ () => d.value === "recording" || d.value === "stopping"
287
+ ), M = F(
288
+ () => !!(s.value.trim() || a.value.trim())
289
+ ), P = F(
290
+ () => !!c && !h.modelValue.trim() && !h.isGenerating
291
+ );
292
+ function t() {
293
+ c && (v = new _e(c, {
294
+ onStatusChange: (o) => {
295
+ d.value = o;
296
+ },
297
+ onInterim: (o) => {
298
+ a.value = o;
299
+ },
300
+ onFinal: (o) => {
301
+ s.value += o, a.value = "";
302
+ },
303
+ onLevel: (o) => {
304
+ f.value = o;
305
+ },
306
+ onError: () => {
307
+ i.value = !1;
308
+ }
309
+ }));
310
+ }
311
+ j(t), Ne(() => {
312
+ v == null || v.destroy(), v = null;
313
+ }), se(
314
+ () => [c == null ? void 0 : c.appId, c == null ? void 0 : c.appKey, c == null ? void 0 : c.devPid],
315
+ () => {
316
+ v == null || v.destroy(), t();
317
+ }
318
+ ), se([s, a], () => {
319
+ K(() => {
320
+ A.value && (A.value.scrollTop = A.value.scrollHeight);
321
+ });
322
+ });
323
+ async function E() {
324
+ if (v) {
325
+ s.value = "", a.value = "", f.value = 0, i.value = !0;
326
+ try {
327
+ await v.start();
328
+ } catch {
329
+ i.value = !1;
330
+ }
331
+ }
332
+ }
333
+ function x() {
334
+ v == null || v.cancel(), i.value = !1, s.value = "", a.value = "", f.value = 0;
335
+ }
336
+ function H() {
337
+ const o = (s.value + a.value).trim();
338
+ o && (v == null || v.stop(), i.value = !1, u("update:modelValue", o), setTimeout(() => u("send"), 0));
339
+ }
340
+ return (o, g) => i.value ? (m(), k("div", _t, [
341
+ n("div", {
342
+ class: "voice-visual",
343
+ style: Se({
344
+ transform: `scale(${1 + f.value * 1.2})`,
345
+ opacity: 0.35 + f.value * 0.65,
346
+ background: $.value ? `rgb(${74 + f.value * 181}, ${172 - f.value * 128}, ${178 - f.value * 128})` : "var(--ai-accent)"
347
+ })
348
+ }, null, 4),
349
+ n("div", {
350
+ class: "voice-text",
351
+ ref_key: "voiceTextEl",
352
+ ref: A
353
+ }, [
354
+ s.value ? (m(), k("span", Vt, V(s.value), 1)) : _("", !0),
355
+ a.value ? (m(), k("span", Wt, V(a.value), 1)) : _("", !0),
356
+ !s.value && !a.value ? (m(), k("span", Yt, V(y.value ? "连接中…" : "正在聆听…"), 1)) : _("", !0)
357
+ ], 512),
358
+ n("div", {
359
+ class: "tooltip-enhanced voice-close",
360
+ "data-tooltip": "关闭",
361
+ onClick: x
362
+ }, [
363
+ Y(D(J), {
364
+ class: "op-icon",
365
+ icon: "heroicons-solid:x-mark"
366
+ })
367
+ ]),
368
+ n("div", {
369
+ class: X(["tooltip-enhanced voice-send", { disabled: !M.value }]),
370
+ "data-tooltip": M.value ? "发送" : "未识别到文字",
371
+ onClick: g[0] || (g[0] = (S) => M.value && H())
372
+ }, [
373
+ Y(D(J), {
374
+ class: "op-icon",
375
+ icon: "fluent-color:send-16"
376
+ })
377
+ ], 10, Ft),
378
+ e.hasScroll && !e.isAtBottom ? (m(), k("div", Qt, [
379
+ Y(D(J), {
380
+ class: "op-icon",
381
+ icon: "ep:bottom",
382
+ onClick: g[1] || (g[1] = (S) => o.$emit("scroll-to-bottom"))
383
+ })
384
+ ])) : _("", !0)
385
+ ])) : (m(), k("div", Gt, [
386
+ n("input", {
387
+ value: e.modelValue,
239
388
  type: "text",
240
389
  placeholder: "给AI助手发送消息...",
241
- onInput: r[0] || (r[0] = (v) => u.$emit("update:modelValue", v.target.value)),
242
- onKeyup: r[1] || (r[1] = Jt((v) => t.modelValue.trim() && u.$emit("send"), ["enter"])),
243
- disabled: t.isGenerating
244
- }, null, 40, Ne),
245
- t.isGenerating && t.lastUserMessage ? (w(), S("div", Be, [
246
- X(O(j), {
390
+ onInput: g[2] || (g[2] = (S) => o.$emit("update:modelValue", S.target.value)),
391
+ onKeyup: g[3] || (g[3] = Ue((S) => e.modelValue.trim() && o.$emit("send"), ["enter"])),
392
+ disabled: e.isGenerating
393
+ }, null, 40, Xt),
394
+ e.isGenerating && e.lastUserMessage ? (m(), k("div", Jt, [
395
+ Y(D(J), {
247
396
  class: "op-icon stop-icon",
248
397
  icon: "heroicons-solid:stop",
249
- onClick: r[2] || (r[2] = (v) => u.$emit("stop"))
398
+ onClick: g[4] || (g[4] = (S) => o.$emit("stop"))
250
399
  })
251
- ])) : (w(), S("div", {
400
+ ])) : P.value ? (m(), k("div", {
252
401
  key: 1,
253
- class: J(["tooltip-enhanced send", { disabled: !t.modelValue.trim() }]),
254
- "data-tooltip": t.modelValue.trim() ? "开始回答" : "请输入你的问题"
402
+ class: "tooltip-enhanced send voice",
403
+ "data-tooltip": "语音输入",
404
+ onClick: E
255
405
  }, [
256
- X(O(j), {
406
+ Y(D(J), {
407
+ class: "op-icon",
408
+ icon: "mingcute:voice-line"
409
+ })
410
+ ])) : (m(), k("div", {
411
+ key: 2,
412
+ class: X(["tooltip-enhanced send", { disabled: !e.modelValue.trim() }]),
413
+ "data-tooltip": e.modelValue.trim() ? "开始回答" : "请输入你的问题"
414
+ }, [
415
+ Y(D(J), {
257
416
  class: "op-icon",
258
417
  icon: "fluent-color:send-16",
259
- onClick: r[3] || (r[3] = (v) => t.modelValue.trim() && u.$emit("send"))
418
+ onClick: g[5] || (g[5] = (S) => e.modelValue.trim() && o.$emit("send"))
260
419
  })
261
- ], 10, Le)),
262
- t.hasScroll && !t.isAtBottom ? (w(), S("div", xe, [
263
- X(O(j), {
420
+ ], 10, qt)),
421
+ e.hasScroll && !e.isAtBottom ? (m(), k("div", Ut, [
422
+ Y(D(J), {
264
423
  class: "op-icon",
265
424
  icon: "ep:bottom",
266
- onClick: r[4] || (r[4] = (v) => u.$emit("scroll-to-bottom"))
425
+ onClick: g[6] || (g[6] = (S) => o.$emit("scroll-to-bottom"))
267
426
  })
268
- ])) : V("", !0)
427
+ ])) : _("", !0)
269
428
  ]));
270
429
  }
271
430
  });
272
- function Ye(t) {
273
- const u = C(!0), r = C(!1);
274
- function v() {
275
- Z(() => {
276
- t.value && (t.value.scrollTop = t.value.scrollHeight);
431
+ function zt(e) {
432
+ const p = C(!0), h = C(!1);
433
+ function u() {
434
+ K(() => {
435
+ e.value && (e.value.scrollTop = e.value.scrollHeight);
277
436
  });
278
437
  }
279
- function o() {
280
- if (!t.value) return;
281
- const c = t.value, a = c.scrollTop + c.clientHeight >= c.scrollHeight - 1, n = c.scrollHeight > c.clientHeight;
282
- u.value = a, r.value = n;
438
+ function l() {
439
+ if (!e.value) return;
440
+ const c = e.value, i = c.scrollTop + c.clientHeight >= c.scrollHeight - 1, s = c.scrollHeight > c.clientHeight;
441
+ p.value = i, h.value = s;
283
442
  }
284
- return { isAtBottom: u, hasScroll: r, scrollToBottom: v, checkScrollStatus: o };
443
+ return { isAtBottom: p, hasScroll: h, scrollToBottom: u, checkScrollStatus: l };
285
444
  }
286
- function Qe() {
287
- function t(u) {
288
- u.querySelectorAll("pre").forEach((v) => {
289
- if (v.querySelector(".copy-button")) return;
290
- const o = v.querySelector("code");
291
- if (!o) return;
292
- const a = (Array.from(o.classList).find((f) => f.startsWith("language-")) || "").replace("language-", "");
293
- if (a) {
294
- const f = document.createElement("span");
295
- f.className = "code-lang", f.textContent = a, v.appendChild(f);
445
+ function Kt() {
446
+ function e(p) {
447
+ p.querySelectorAll("pre").forEach((u) => {
448
+ if (u.querySelector(".copy-button")) return;
449
+ const l = u.querySelector("code");
450
+ if (!l) return;
451
+ const i = (Array.from(l.classList).find((a) => a.startsWith("language-")) || "").replace("language-", "");
452
+ if (i) {
453
+ const a = document.createElement("span");
454
+ a.className = "code-lang", a.textContent = i, u.appendChild(a);
296
455
  }
297
- const n = document.createElement("button");
298
- n.className = "copy-button", n.textContent = "复制", n.onclick = () => {
299
- navigator.clipboard.writeText(o.textContent || "").then(() => {
300
- n.textContent = "已复制", setTimeout(() => {
301
- n.textContent = "复制";
456
+ const s = document.createElement("button");
457
+ s.className = "copy-button", s.textContent = "复制", s.onclick = () => {
458
+ navigator.clipboard.writeText(l.textContent || "").then(() => {
459
+ s.textContent = "已复制", setTimeout(() => {
460
+ s.textContent = "复制";
302
461
  }, 2e3);
303
462
  });
304
- }, v.appendChild(n);
463
+ }, u.appendChild(s);
305
464
  });
306
465
  }
307
- return { enhanceCodeBlocks: t };
466
+ return { enhanceCodeBlocks: e };
308
467
  }
309
- function Fe(t) {
310
- let u = null, r = 0;
311
- function v(c) {
312
- u = c(u || [...t.value]), r || (r = requestAnimationFrame(() => {
313
- r = 0, u && (t.value = u, u = null);
468
+ function Zt(e) {
469
+ let p = null, h = 0;
470
+ function u(c) {
471
+ p = c(p || [...e.value]), h || (h = requestAnimationFrame(() => {
472
+ h = 0, p && (e.value = p, p = null);
314
473
  }));
315
474
  }
316
- function o() {
317
- r && (cancelAnimationFrame(r), r = 0), u && (t.value = u, u = null);
475
+ function l() {
476
+ h && (cancelAnimationFrame(h), h = 0), p && (e.value = p, p = null);
318
477
  }
319
- return { batchMessagesUpdate: v, flushMessagesBatch: o };
478
+ return { batchMessagesUpdate: u, flushMessagesBatch: l };
320
479
  }
321
- function Ve(t, u, r) {
322
- const v = I(/* @__PURE__ */ new Map()), o = C(/* @__PURE__ */ new Map()), c = C(/* @__PURE__ */ new Map());
323
- let a = 0, n = 0;
324
- function f() {
325
- if (a) return;
326
- const h = 50, g = 100, E = (b) => {
327
- if (n === 0) {
328
- n = b, a = requestAnimationFrame(E);
480
+ function It(e, p, h) {
481
+ const u = ne(/* @__PURE__ */ new Map()), l = C(/* @__PURE__ */ new Map()), c = C(/* @__PURE__ */ new Map());
482
+ let i = 0, s = 0;
483
+ function a() {
484
+ if (i) return;
485
+ const v = 50, y = 100, $ = (M) => {
486
+ if (s === 0) {
487
+ s = M, i = requestAnimationFrame($);
329
488
  return;
330
489
  }
331
- const L = Math.min(b - n, 100);
332
- n = b;
333
- let e = !1;
334
- if (t.value.forEach((D, H) => {
335
- if (D.type !== "ai" || D.status !== r) return;
336
- const l = D.content, p = o.value.get(H) ?? 0, A = l.length - p;
337
- if (A > 0) {
338
- e = !0;
339
- const y = Math.min(h + A, g), i = (c.value.get(H) ?? 0) + y * L / 1e3, m = Math.floor(i);
340
- if (m > 0) {
341
- c.value.set(H, i - m);
342
- const k = Math.min(p + m, l.length);
343
- o.value.set(H, k), v.set(H, l.slice(0, k));
490
+ const P = Math.min(M - s, 100);
491
+ s = M;
492
+ let t = !1;
493
+ if (e.value.forEach((x, H) => {
494
+ if (x.type !== "ai" || x.status !== h) return;
495
+ const o = x.content, g = l.value.get(H) ?? 0, S = o.length - g;
496
+ if (S > 0) {
497
+ t = !0;
498
+ const T = Math.min(v + S, y), r = (c.value.get(H) ?? 0) + T * P / 1e3, b = Math.floor(r);
499
+ if (b > 0) {
500
+ c.value.set(H, r - b);
501
+ const R = Math.min(g + b, o.length);
502
+ l.value.set(H, R), u.set(H, o.slice(0, R));
344
503
  } else
345
- c.value.set(H, i);
504
+ c.value.set(H, r);
346
505
  } else
347
506
  c.value.set(H, 0);
348
- }), e && u(), !t.value.some((D) => D.type === "ai" && D.status === r)) {
349
- a = 0;
507
+ }), t && p(), !e.value.some((x) => x.type === "ai" && x.status === h)) {
508
+ i = 0;
350
509
  return;
351
510
  }
352
- a = requestAnimationFrame(E);
511
+ i = requestAnimationFrame($);
353
512
  };
354
- n = 0, a = requestAnimationFrame(E);
513
+ s = 0, i = requestAnimationFrame($);
355
514
  }
356
- function M() {
357
- a && (cancelAnimationFrame(a), a = 0), t.value.forEach((h, g) => {
358
- h.type === "ai" && (v.set(g, h.content), o.value.set(g, h.content.length), c.value.set(g, 0));
515
+ function d() {
516
+ i && (cancelAnimationFrame(i), i = 0), e.value.forEach((v, y) => {
517
+ v.type === "ai" && (u.set(y, v.content), l.value.set(y, v.content.length), c.value.set(y, 0));
359
518
  });
360
519
  }
361
- function B() {
362
- a && (cancelAnimationFrame(a), a = 0);
520
+ function f() {
521
+ i && (cancelAnimationFrame(i), i = 0);
363
522
  }
364
- function R(h, g, E, b) {
365
- if (E.type !== "answer" || b.status !== r) return E.content;
366
- const L = b.segments || [];
367
- if (L.slice(g + 1).some((l) => l.type === "answer")) return E.content;
368
- const x = o.value.get(h);
369
- if (x == null) return E.content;
370
- let D = 0;
371
- for (let l = 0; l < g; l++)
372
- L[l].type === "answer" && (D += L[l].content.length);
373
- const H = D + E.content.length;
374
- return x >= H ? E.content : x <= D ? "" : E.content.slice(0, x - D);
523
+ function A(v, y, $, M) {
524
+ if ($.type !== "answer" || M.status !== h) return $.content;
525
+ const P = M.segments || [];
526
+ if (P.slice(y + 1).some((o) => o.type === "answer")) return $.content;
527
+ const E = l.value.get(v);
528
+ if (E == null) return $.content;
529
+ let x = 0;
530
+ for (let o = 0; o < y; o++)
531
+ P[o].type === "answer" && (x += P[o].content.length);
532
+ const H = x + $.content.length;
533
+ return E >= H ? $.content : E <= x ? "" : $.content.slice(0, E - x);
375
534
  }
376
- return { displayedContent: v, streamingIndexRef: o, startTypewriter: f, flushTypewriter: M, getSegmentDisplayContent: R, stopTypewriter: B };
535
+ return { displayedContent: u, streamingIndexRef: l, startTypewriter: a, flushTypewriter: d, getSegmentDisplayContent: A, stopTypewriter: f };
377
536
  }
378
- function Xe({
379
- messages: t,
380
- isGenerating: u,
381
- lastUserMessage: r,
382
- batchMessagesUpdate: v,
383
- flushMessagesBatch: o,
537
+ function en({
538
+ messages: e,
539
+ isGenerating: p,
540
+ lastUserMessage: h,
541
+ batchMessagesUpdate: u,
542
+ flushMessagesBatch: l,
384
543
  STATUS: c,
385
- cfg: a
544
+ cfg: i
386
545
  }) {
387
- const n = C(/* @__PURE__ */ new Map()), f = C(/* @__PURE__ */ new Map()), M = C(/* @__PURE__ */ new Map()), B = C(/* @__PURE__ */ new Map()), R = C(!1);
388
- function h(b) {
389
- const L = n.value.get(b) || [];
390
- v((e) => {
391
- if (e[b]) {
392
- const x = [...e];
393
- return x[b] = { ...x[b], segments: L.map((D) => ({ ...D })) }, x;
546
+ const s = C(/* @__PURE__ */ new Map()), a = C(/* @__PURE__ */ new Map()), d = C(/* @__PURE__ */ new Map()), f = C(/* @__PURE__ */ new Map()), A = C(!1);
547
+ function v(M) {
548
+ const P = s.value.get(M) || [];
549
+ u((t) => {
550
+ if (t[M]) {
551
+ const E = [...t];
552
+ return E[M] = { ...E[M], segments: P.map((x) => ({ ...x })) }, E;
394
553
  }
395
- return e;
554
+ return t;
396
555
  });
397
556
  }
398
- function g(b) {
399
- const L = n.value.get(b) || [], e = M.value.get(b);
400
- let x = 0, D = !1;
401
- L.forEach((H) => {
557
+ function y(M) {
558
+ const P = s.value.get(M) || [], t = d.value.get(M);
559
+ let E = 0, x = !1;
560
+ P.forEach((H) => {
402
561
  if (H.type === "thinking" && H.duration == null) {
403
- const l = e ? Math.round((Date.now() - e) / 1e3 * 10) / 10 : 0;
404
- H.duration = l, x += l, D = !0;
562
+ const o = t ? Math.round((Date.now() - t) / 1e3 * 10) / 10 : 0;
563
+ H.duration = o, E += o, x = !0;
405
564
  }
406
- }), D && (n.value.set(b, L), v((H) => {
407
- if (H[b]) {
408
- const l = [...H];
409
- return l[b] = {
410
- ...l[b],
411
- segments: L.map((p) => ({ ...p })),
412
- thinkingDuration: (l[b].thinkingDuration || 0) + x
413
- }, l;
565
+ }), x && (s.value.set(M, P), u((H) => {
566
+ if (H[M]) {
567
+ const o = [...H];
568
+ return o[M] = {
569
+ ...o[M],
570
+ segments: P.map((g) => ({ ...g })),
571
+ thinkingDuration: (o[M].thinkingDuration || 0) + E
572
+ }, o;
414
573
  }
415
574
  return H;
416
575
  }));
417
576
  }
418
- async function E(b, L, e, x, D = !1) {
419
- R.value = !1, n.value.set(e, []), u.value = !0;
577
+ async function $(M, P, t, E, x = !1) {
578
+ A.value = !1, s.value.set(t, []), p.value = !0;
420
579
  try {
421
- const H = a.baseUrl.replace(/\/+$/, "") + "/" + b.replace(/^\/+/, "");
422
- await le(H, {
580
+ const H = i.baseUrl.replace(/\/+$/, "") + "/" + M.replace(/^\/+/, "");
581
+ await ut(H, {
423
582
  method: "POST",
424
583
  headers: { "Content-Type": "application/json" },
425
- body: JSON.stringify({ app: a.app ?? 1, data: L }),
426
- signal: x,
584
+ body: JSON.stringify({ app: i.app ?? 1, data: P }),
585
+ signal: E,
427
586
  openWhenHidden: !0,
428
- async onopen(l) {
429
- l.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", l.status, l.statusText);
587
+ async onopen(o) {
588
+ o.ok || console.error("[ai-assist-sdk] ❌ SSE 连接失败:", o.status, o.statusText);
430
589
  },
431
- onmessage(l) {
432
- var p;
590
+ onmessage(o) {
591
+ var g;
433
592
  try {
434
- let A = l.data || "";
435
- for (; A.startsWith("data:"); )
436
- A = A.replace(/^data:\s*/, "");
437
- if (!A) return;
438
- let y;
593
+ let S = o.data || "";
594
+ for (; S.startsWith("data:"); )
595
+ S = S.replace(/^data:\s*/, "");
596
+ if (!S) return;
597
+ let T;
439
598
  try {
440
- y = JSON.parse(A);
599
+ T = JSON.parse(S);
441
600
  } catch {
442
601
  return;
443
602
  }
444
- switch (y.event) {
603
+ switch (T.event) {
445
604
  case "message_start":
446
- D || (r.value = y.id), f.value.set(e, "answer");
605
+ x || (h.value = T.id), a.value.set(t, "answer");
447
606
  break;
448
607
  case "think_message_output_start": {
449
- M.value.set(e, Date.now()), f.value.set(e, "thinking");
450
- const i = n.value.get(e) || [];
451
- n.value.set(e, [...i, { type: "thinking", content: "" }]), h(e);
608
+ d.value.set(t, Date.now()), a.value.set(t, "thinking");
609
+ const r = s.value.get(t) || [];
610
+ s.value.set(t, [...r, { type: "thinking", content: "" }]), v(t);
452
611
  break;
453
612
  }
454
613
  case "agent_thought": {
455
- const i = y.thought || y.thinking || "", m = n.value.get(e) || [], k = m[m.length - 1];
456
- k && k.type === "agent_thought" ? k.content += i : (f.value.set(e, "agent_thought"), m.push({ type: "agent_thought", content: i }), B.value.set(e, Date.now())), n.value.set(e, m), v(($) => {
457
- if ($[e]) {
458
- const P = [...$];
459
- return P[e] = {
460
- ...P[e],
461
- segments: m.map((N) => ({ ...N })),
462
- thinkingContent: (P[e].thinkingContent || "") + i,
614
+ const r = T.thought || T.thinking || "", b = s.value.get(t) || [], R = b[b.length - 1];
615
+ R && R.type === "agent_thought" ? R.content += r : (a.value.set(t, "agent_thought"), b.push({ type: "agent_thought", content: r }), f.value.set(t, Date.now())), s.value.set(t, b), u((B) => {
616
+ if (B[t]) {
617
+ const L = [...B];
618
+ return L[t] = {
619
+ ...L[t],
620
+ segments: b.map((N) => ({ ...N })),
621
+ thinkingContent: (L[t].thinkingContent || "") + r,
463
622
  status: c.THINKING
464
- }, P;
623
+ }, L;
465
624
  }
466
- return $;
625
+ return B;
467
626
  });
468
627
  break;
469
628
  }
470
629
  case "think_message": {
471
- const i = y.thinking || y.answer || y.text || "", m = n.value.get(e) || [], k = m[m.length - 1];
472
- k && k.type === "thinking" ? k.content += i : (m.push({ type: "thinking", content: i }), M.value.set(e, Date.now())), n.value.set(e, m), v(($) => {
473
- if ($[e]) {
474
- const P = [...$];
475
- return P[e] = {
476
- ...P[e],
477
- segments: m.map((N) => ({ ...N })),
478
- thinkingContent: (P[e].thinkingContent || "") + i,
630
+ const r = T.thinking || T.answer || T.text || "", b = s.value.get(t) || [], R = b[b.length - 1];
631
+ R && R.type === "thinking" ? R.content += r : (b.push({ type: "thinking", content: r }), d.value.set(t, Date.now())), s.value.set(t, b), u((B) => {
632
+ if (B[t]) {
633
+ const L = [...B];
634
+ return L[t] = {
635
+ ...L[t],
636
+ segments: b.map((N) => ({ ...N })),
637
+ thinkingContent: (L[t].thinkingContent || "") + r,
479
638
  status: c.THINKING
480
- }, P;
639
+ }, L;
481
640
  }
482
- return $;
641
+ return B;
483
642
  });
484
643
  break;
485
644
  }
486
645
  case "agent_thought_end": {
487
- const i = B.value.get(e), m = i ? Math.round((Date.now() - i) / 1e3 * 10) / 10 : 0, k = n.value.get(e) || [], $ = k[k.length - 1];
488
- $ && $.type === "agent_thought" && ($.duration = m), n.value.set(e, k), v((P) => {
489
- if (P[e]) {
490
- const N = [...P];
491
- return N[e] = {
492
- ...N[e],
493
- segments: k.map((G) => ({ ...G })),
494
- thinkingDuration: (N[e].thinkingDuration || 0) + m
646
+ const r = f.value.get(t), b = r ? Math.round((Date.now() - r) / 1e3 * 10) / 10 : 0, R = s.value.get(t) || [], B = R[R.length - 1];
647
+ B && B.type === "agent_thought" && (B.duration = b), s.value.set(t, R), u((L) => {
648
+ if (L[t]) {
649
+ const N = [...L];
650
+ return N[t] = {
651
+ ...N[t],
652
+ segments: R.map((q) => ({ ...q })),
653
+ thinkingDuration: (N[t].thinkingDuration || 0) + b
495
654
  }, N;
496
655
  }
497
- return P;
656
+ return L;
498
657
  });
499
658
  break;
500
659
  }
501
660
  case "think_message_output_end": {
502
- const i = M.value.get(e), m = i ? Math.round((Date.now() - i) / 1e3 * 10) / 10 : 0, k = n.value.get(e) || [], $ = k[k.length - 1];
503
- $ && $.type === "thinking" && ($.duration = m), n.value.set(e, k), v((P) => {
504
- if (P[e]) {
505
- const N = [...P];
506
- return N[e] = {
507
- ...N[e],
508
- segments: k.map((G) => ({ ...G })),
509
- thinkingDuration: (N[e].thinkingDuration || 0) + m
661
+ const r = d.value.get(t), b = r ? Math.round((Date.now() - r) / 1e3 * 10) / 10 : 0, R = s.value.get(t) || [], B = R[R.length - 1];
662
+ B && B.type === "thinking" && (B.duration = b), s.value.set(t, R), u((L) => {
663
+ if (L[t]) {
664
+ const N = [...L];
665
+ return N[t] = {
666
+ ...N[t],
667
+ segments: R.map((q) => ({ ...q })),
668
+ thinkingDuration: (N[t].thinkingDuration || 0) + b
510
669
  }, N;
511
670
  }
512
- return P;
671
+ return L;
513
672
  });
514
673
  break;
515
674
  }
516
675
  case "tool_message": {
517
- const i = y.answer || y.text || y.content || "";
518
- if (!i) break;
519
- const m = n.value.get(e) || [];
520
- m.push({ type: "answer", content: i }), n.value.set(e, m), h(e);
676
+ const r = T.answer || T.text || T.content || "";
677
+ if (!r) break;
678
+ const b = s.value.get(t) || [];
679
+ b.push({ type: "answer", content: r }), s.value.set(t, b), v(t);
521
680
  break;
522
681
  }
523
682
  case "message_output_start":
524
- f.value.set(e, "answer"), g(e);
683
+ a.value.set(t, "answer"), y(t);
525
684
  break;
526
685
  case "message": {
527
- const i = y.answer || "", m = f.value.get(e), k = n.value.get(e) || [], $ = k[k.length - 1];
528
- m === "answer" && $ && $.type === "answer" ? $.content += i : (g(e), f.value.set(e, "answer"), k.push({ type: "answer", content: i })), n.value.set(e, k);
529
- const P = k.filter((N) => N.type === "answer").map((N) => N.content).join("");
530
- v((N) => {
531
- if (N[e]) {
532
- const G = [...N];
533
- return G[e] = {
534
- ...G[e],
535
- segments: k.map((vt) => ({ ...vt })),
536
- content: P,
537
- status: R.value ? c.STOP : c.ANSWERING
538
- }, G;
686
+ const r = T.answer || "", b = a.value.get(t), R = s.value.get(t) || [], B = R[R.length - 1];
687
+ b === "answer" && B && B.type === "answer" ? B.content += r : (y(t), a.value.set(t, "answer"), R.push({ type: "answer", content: r })), s.value.set(t, R);
688
+ const L = R.filter((N) => N.type === "answer").map((N) => N.content).join("");
689
+ u((N) => {
690
+ if (N[t]) {
691
+ const q = [...N];
692
+ return q[t] = {
693
+ ...q[t],
694
+ segments: R.map((ge) => ({ ...ge })),
695
+ content: L,
696
+ status: A.value ? c.STOP : c.ANSWERING
697
+ }, q;
539
698
  }
540
699
  return N;
541
700
  });
542
701
  break;
543
702
  }
544
703
  case "message_end": {
545
- o();
546
- const i = [...t.value];
547
- i[e] && (i[e] = { ...i[e], status: R.value ? c.STOP : c.COMPLETED }), t.value = i, u.value = !1;
704
+ l();
705
+ const r = [...e.value];
706
+ r[t] && (r[t] = { ...r[t], status: A.value ? c.STOP : c.COMPLETED }), e.value = r, p.value = !1;
548
707
  break;
549
708
  }
550
709
  case "agent_error":
551
710
  case "message_failed": {
552
- o();
553
- const i = [...t.value];
554
- i[e] && (i[e] = {
555
- ...i[e],
711
+ l();
712
+ const r = [...e.value];
713
+ r[t] && (r[t] = {
714
+ ...r[t],
556
715
  status: c.ERROR,
557
- content: y.error_msg || y.message || "请求失败",
558
- errorMessage: y.error_msg || y.message || "请求失败"
559
- }, t.value = i), u.value = !1;
716
+ content: T.error_msg || T.message || "请求失败",
717
+ errorMessage: T.error_msg || T.message || "请求失败"
718
+ }, e.value = r), p.value = !1;
560
719
  break;
561
720
  }
562
721
  case "message_replace": {
563
- const i = y.answer || "", m = n.value.get(e) || [], k = (p = m.map(($, P) => ({ s: $, i: P })).reverse().find(($) => $.s.type === "answer")) == null ? void 0 : p.i;
564
- k != null ? m[k] = { ...m[k], content: i } : m.push({ type: "answer", content: i }), n.value.set(e, m), v(($) => {
565
- if ($[e]) {
566
- const P = [...$];
567
- return P[e] = {
568
- ...P[e],
569
- segments: m.map((N) => ({ ...N })),
570
- content: i
571
- }, P;
722
+ const r = T.answer || "", b = s.value.get(t) || [], R = (g = b.map((B, L) => ({ s: B, i: L })).reverse().find((B) => B.s.type === "answer")) == null ? void 0 : g.i;
723
+ R != null ? b[R] = { ...b[R], content: r } : b.push({ type: "answer", content: r }), s.value.set(t, b), u((B) => {
724
+ if (B[t]) {
725
+ const L = [...B];
726
+ return L[t] = {
727
+ ...L[t],
728
+ segments: b.map((N) => ({ ...N })),
729
+ content: r
730
+ }, L;
572
731
  }
573
- return $;
732
+ return B;
574
733
  });
575
734
  break;
576
735
  }
577
736
  case "message_cost": {
578
- const i = {
579
- inputTokens: y.input_tokens || 0,
580
- outputTokens: y.output_tokens || 0,
581
- latency: y.latency || 0,
582
- latencyFirstResp: y.latency_first_resp
737
+ const r = {
738
+ inputTokens: T.input_tokens || 0,
739
+ outputTokens: T.output_tokens || 0,
740
+ latency: T.latency || 0,
741
+ latencyFirstResp: T.latency_first_resp
583
742
  };
584
- v((m) => {
585
- if (m[e]) {
586
- const k = [...m];
587
- return k[e] = { ...k[e], cost: i }, k;
743
+ u((b) => {
744
+ if (b[t]) {
745
+ const R = [...b];
746
+ return R[t] = { ...R[t], cost: r }, R;
588
747
  }
589
- return m;
748
+ return b;
590
749
  });
591
750
  break;
592
751
  }
593
752
  default:
594
753
  }
595
- } catch (A) {
596
- console.error("[ai-assist-sdk] onmessage 解析失败:", A);
754
+ } catch (S) {
755
+ console.error("[ai-assist-sdk] onmessage 解析失败:", S);
597
756
  }
598
757
  },
599
758
  onclose() {
600
- o(), g(e), o();
601
- const p = (n.value.get(e) || []).filter((y) => y.type === "answer").map((y) => y.content).join(""), A = [...t.value];
602
- A[e] && A[e].status !== c.ERROR && (A[e] = {
603
- ...A[e],
604
- content: R.value && !p ? "已停止回答" : p,
605
- status: R.value ? c.STOP : c.COMPLETED
606
- }), t.value = A, u.value = !1;
759
+ l(), y(t), l();
760
+ const g = (s.value.get(t) || []).filter((T) => T.type === "answer").map((T) => T.content).join(""), S = [...e.value];
761
+ S[t] && S[t].status !== c.ERROR && (S[t] = {
762
+ ...S[t],
763
+ content: A.value && !g ? "已停止回答" : g,
764
+ status: A.value ? c.STOP : c.COMPLETED
765
+ }), e.value = S, p.value = !1;
607
766
  },
608
- onerror(l) {
609
- console.error("[ai-assist-sdk] ❌ 连接错误:", l), o();
610
- const p = [...t.value];
611
- p[e] && (p[e] = { ...p[e], content: `
612
- ⚠️ 请求异常,已终止`, status: c.ERROR }), t.value = p, u.value = !1;
767
+ onerror(o) {
768
+ console.error("[ai-assist-sdk] ❌ 连接错误:", o), l();
769
+ const g = [...e.value];
770
+ g[t] && (g[t] = { ...g[t], content: `
771
+ ⚠️ 请求异常,已终止`, status: c.ERROR }), e.value = g, p.value = !1;
613
772
  }
614
773
  });
615
774
  } catch (H) {
616
- if (console.error("[ai-assist-sdk] doStreamRequest error:", H), !R.value) {
617
- o();
618
- const l = [...t.value];
619
- l[e] && (l[e] = { ...l[e], content: "服务连接失败,请稍后重试", status: c.ERROR }), t.value = l, u.value = !1;
775
+ if (console.error("[ai-assist-sdk] doStreamRequest error:", H), !A.value) {
776
+ l();
777
+ const o = [...e.value];
778
+ o[t] && (o[t] = { ...o[t], content: "服务连接失败,请稍后重试", status: c.ERROR }), e.value = o, p.value = !1;
620
779
  }
621
780
  }
622
781
  }
623
- return { doStreamRequest: E, issTop: R };
782
+ return { doStreamRequest: $, issTop: A };
624
783
  }
625
- function Bt(t) {
626
- var u;
627
- if (t && typeof t == "object" && typeof t.data == "string" && (t = t.data), typeof t == "string") {
628
- const r = t.split(`
784
+ function Be(e) {
785
+ var p;
786
+ if (e && typeof e == "object" && typeof e.data == "string" && (e = e.data), typeof e == "string") {
787
+ const h = e.split(`
629
788
  `);
630
- let v = "";
631
- for (const o of r) {
632
- const c = o.startsWith("data:") ? o.slice(5).trim() : "";
789
+ let u = "";
790
+ for (const l of h) {
791
+ const c = l.startsWith("data:") ? l.slice(5).trim() : "";
633
792
  if (c)
634
793
  try {
635
- const a = JSON.parse(c);
636
- a.event === "message" && a.answer !== void 0 && (v += a.answer);
794
+ const i = JSON.parse(c);
795
+ i.event === "message" && i.answer !== void 0 && (u += i.answer);
637
796
  } catch {
638
797
  }
639
798
  }
640
- return v || t;
799
+ return u || e;
641
800
  }
642
- return (t == null ? void 0 : t.answer) || ((u = t == null ? void 0 : t.data) == null ? void 0 : u.answer) || String(t || "");
801
+ return (e == null ? void 0 : e.answer) || ((p = e == null ? void 0 : e.data) == null ? void 0 : p.answer) || String(e || "");
643
802
  }
644
- function Ge(t) {
645
- return t.queryAgainStreamApi || t.queryAgainApi || t.chatQueryStreamApi || t.chatQueryApi;
803
+ function tn(e) {
804
+ return e.queryAgainStreamApi || e.queryAgainApi || e.chatQueryStreamApi || e.chatQueryApi;
646
805
  }
647
- function Je({
648
- messages: t,
649
- userInput: u,
650
- isGenerating: r,
651
- lastUserMessage: v,
652
- conversationId: o,
806
+ function nn({
807
+ messages: e,
808
+ userInput: p,
809
+ isGenerating: h,
810
+ lastUserMessage: u,
811
+ conversationId: l,
653
812
  doStreamRequest: c,
654
- issTop: a,
655
- scrollToBottom: n,
656
- STATUS: f,
657
- cfg: M,
658
- onTitleGenerated: B
813
+ issTop: i,
814
+ scrollToBottom: s,
815
+ STATUS: a,
816
+ cfg: d,
817
+ onTitleGenerated: f
659
818
  }) {
660
- const R = M.apis, h = I({
819
+ const A = d.apis, v = ne({
661
820
  first: new AbortController(),
662
821
  again: new AbortController()
663
- }), g = C(!1);
664
- async function E(l, p) {
665
- var y;
666
- if (!M.titleGenerateApp || !R.updateConversationApi || g.value) return;
667
- let A = o.value;
668
- if (!A)
822
+ }), y = C(!1);
823
+ async function $(o, g) {
824
+ var T;
825
+ if (!d.titleGenerateApp || !A.updateConversationApi || y.value) return;
826
+ let S = l.value;
827
+ if (!S)
669
828
  try {
670
- const i = await Pt(R);
671
- (y = i == null ? void 0 : i.conversation) != null && y.appConversationID && (A = i.conversation.appConversationID, o.value = A);
672
- } catch (i) {
673
- console.error("[ai-assist-sdk] 创建会话失败:", i);
829
+ const r = await Oe(A);
830
+ (T = r == null ? void 0 : r.conversation) != null && T.appConversationID && (S = r.conversation.appConversationID, l.value = S);
831
+ } catch (r) {
832
+ console.error("[ai-assist-sdk] 创建会话失败:", r);
674
833
  return;
675
834
  }
676
- if (A)
835
+ if (S)
677
836
  try {
678
- const i = await Zt(R, M.titleGenerateApp);
679
- if (!i) return;
680
- const m = p.length > 500 ? p.slice(0, 500) : p, k = `用户提问:${l}
681
- AI回答:${m}`, P = await Nt().post(R.chatQueryApi, {
682
- app: M.titleGenerateApp,
683
- data: { Query: k, AppConversationID: i }
684
- }), N = Bt(P.data.data);
685
- N && (await It(R, A, N), g.value = !0, B == null || B(N));
686
- } catch (i) {
687
- console.error("[ai-assist-sdk] 生成对话标题失败:", i);
837
+ const r = await et(A, d.titleGenerateApp);
838
+ if (!r) return;
839
+ const b = g.length > 500 ? g.slice(0, 500) : g, R = `用户提问:${o}
840
+ AI回答:${b}`, L = await Pe().post(A.chatQueryApi, {
841
+ app: d.titleGenerateApp,
842
+ data: { Query: R, AppConversationID: r }
843
+ }), N = Be(L.data.data);
844
+ N && (await tt(A, S, N), y.value = !0, f == null || f(N));
845
+ } catch (r) {
846
+ console.error("[ai-assist-sdk] 生成对话标题失败:", r);
688
847
  }
689
848
  }
690
- async function b() {
691
- const l = u.value.trim();
692
- if (!l || r.value) return;
693
- if (!o.value && (await D(), !o.value)) {
694
- ct("创建会话失败,请重试");
849
+ async function M() {
850
+ const o = p.value.trim();
851
+ if (!o || h.value) return;
852
+ if (!l.value && (await x(), !l.value)) {
853
+ ue("创建会话失败,请重试");
695
854
  return;
696
855
  }
697
- const p = t.value.length === 0, A = [
698
- ...t.value,
699
- { type: "user", content: l },
700
- { type: "ai", content: "", status: f.THINKING }
856
+ const g = e.value.length === 0, S = [
857
+ ...e.value,
858
+ { type: "user", content: o },
859
+ { type: "ai", content: "", status: a.THINKING }
701
860
  ];
702
- t.value = A, u.value = "", n();
703
- const y = A.length - 1;
704
- if (R.chatQueryStreamApi) {
705
- if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", R.chatQueryStreamApi), await c(R.chatQueryStreamApi, {
706
- Query: l,
707
- AppConversationID: o.value,
861
+ e.value = S, p.value = "", s();
862
+ const T = S.length - 1;
863
+ if (A.chatQueryStreamApi) {
864
+ if (console.log("[ai-assist-sdk] ✅ 使用流式 SSE:", A.chatQueryStreamApi), await c(A.chatQueryStreamApi, {
865
+ Query: o,
866
+ AppConversationID: l.value,
708
867
  ResponseMode: "streaming"
709
- }, y, h.first.signal), p && !g.value) {
710
- const i = t.value[y];
711
- i && i.status !== f.ERROR && E(l, i.content);
868
+ }, T, v.first.signal), g && !y.value) {
869
+ const r = e.value[T];
870
+ r && r.status !== a.ERROR && $(o, r.content);
712
871
  }
713
872
  return;
714
873
  }
715
874
  console.warn("[ai-assist-sdk] ⚠️ 未配置 chatQueryStreamApi,降级为非流式请求");
716
875
  try {
717
- const m = await Nt().post(R.chatQueryApi, {
718
- app: M.app ?? 1,
719
- data: { Query: l, AppConversationID: o.value }
720
- }), k = Bt(m.data);
721
- t.value = [...t.value.slice(0, -1), { type: "ai", content: k, status: f.COMPLETED }], p && !g.value && E(l, k);
722
- } catch (i) {
723
- t.value = [...t.value.slice(0, -1), { type: "ai", content: (i == null ? void 0 : i.message) || "服务连接失败,请稍后重试", status: f.ERROR }];
876
+ const b = await Pe().post(A.chatQueryApi, {
877
+ app: d.app ?? 1,
878
+ data: { Query: o, AppConversationID: l.value }
879
+ }), R = Be(b.data);
880
+ e.value = [...e.value.slice(0, -1), { type: "ai", content: R, status: a.COMPLETED }], g && !y.value && $(o, R);
881
+ } catch (r) {
882
+ e.value = [...e.value.slice(0, -1), { type: "ai", content: (r == null ? void 0 : r.message) || "服务连接失败,请稍后重试", status: a.ERROR }];
724
883
  }
725
884
  }
726
- async function L() {
727
- if (!v.value || r.value) return;
728
- h.again.abort(), h.again = new AbortController();
729
- const l = [...t.value];
730
- l.length > 0 && l[l.length - 1].type === "ai" && l.pop(), l.push({ type: "ai", content: "", status: f.RETHINKING }), t.value = l, n();
731
- const p = t.value.length - 1, A = Ge(R);
732
- await c(A, {
733
- MessageID: v.value,
734
- AppConversationID: o.value,
885
+ async function P() {
886
+ if (!u.value || h.value) return;
887
+ v.again.abort(), v.again = new AbortController();
888
+ const o = [...e.value];
889
+ o.length > 0 && o[o.length - 1].type === "ai" && o.pop(), o.push({ type: "ai", content: "", status: a.RETHINKING }), e.value = o, s();
890
+ const g = e.value.length - 1, S = tn(A);
891
+ await c(S, {
892
+ MessageID: u.value,
893
+ AppConversationID: l.value,
735
894
  ResponseMode: "streaming"
736
- }, p, h.again.signal, !0);
895
+ }, g, v.again.signal, !0);
737
896
  }
738
- async function e() {
739
- if (!R.stopMessageApi || !r.value) return;
740
- const l = t.value.length - 1 - 1;
897
+ async function t() {
898
+ if (!A.stopMessageApi || !h.value) return;
899
+ const o = e.value.length - 1 - 1;
741
900
  try {
742
- await zt(R, v.value);
743
- const p = [...t.value];
744
- p[l] && (p[l] = { ...p[l], content: p[l].content || "已停止回答", status: f.STOP }), t.value = p, r.value = !1, h.first.abort(), h.first = new AbortController(), h.again.abort(), h.again = new AbortController(), a.value = !0;
745
- } catch (p) {
746
- const A = [...t.value];
747
- A[l] && (A[l] = { ...A[l], content: (p == null ? void 0 : p.message) || "系统繁忙,请稍后再试", status: f.ERROR }), t.value = A;
901
+ await Ie(A, u.value);
902
+ const g = [...e.value];
903
+ g[o] && (g[o] = { ...g[o], content: g[o].content || "已停止回答", status: a.STOP }), e.value = g, h.value = !1, v.first.abort(), v.first = new AbortController(), v.again.abort(), v.again = new AbortController(), i.value = !0;
904
+ } catch (g) {
905
+ const S = [...e.value];
906
+ S[o] && (S[o] = { ...S[o], content: (g == null ? void 0 : g.message) || "系统繁忙,请稍后再试", status: a.ERROR }), e.value = S;
748
907
  }
749
908
  }
750
- async function x(l) {
751
- var p, A;
752
- o.value = l, g.value = !0;
909
+ async function E(o) {
910
+ var g, S;
911
+ l.value = o, y.value = !0;
753
912
  try {
754
- const y = await Kt(R, l), i = [];
755
- if ((p = y == null ? void 0 : y.messages) != null && p.length)
756
- for (const m of y.messages)
757
- m.query && i.push({ type: "user", content: m.query }), (A = m.answerInfo) != null && A.answer && i.push({ type: "ai", content: m.answerInfo.answer, status: f.COMPLETED });
758
- t.value = i, n();
759
- } catch (y) {
760
- ct((y == null ? void 0 : y.message) || "加载历史会话失败");
913
+ const T = await Ze(A, o), r = [];
914
+ if ((g = T == null ? void 0 : T.messages) != null && g.length)
915
+ for (const b of T.messages)
916
+ b.query && r.push({ type: "user", content: b.query }), (S = b.answerInfo) != null && S.answer && r.push({ type: "ai", content: b.answerInfo.answer, status: a.COMPLETED });
917
+ e.value = r, s();
918
+ } catch (T) {
919
+ ue((T == null ? void 0 : T.message) || "加载历史会话失败");
761
920
  }
762
921
  }
763
- async function D() {
764
- var l;
765
- g.value = !1;
922
+ async function x() {
923
+ var o;
924
+ y.value = !1;
766
925
  try {
767
- const p = await Pt(R);
768
- (l = p == null ? void 0 : p.conversation) != null && l.appConversationID && (o.value = p.conversation.appConversationID);
769
- } catch (p) {
770
- ct((p == null ? void 0 : p.message) || "创建会话失败");
926
+ const g = await Oe(A);
927
+ (o = g == null ? void 0 : g.conversation) != null && o.appConversationID && (l.value = g.conversation.appConversationID);
928
+ } catch (g) {
929
+ ue((g == null ? void 0 : g.message) || "创建会话失败");
771
930
  }
772
931
  }
773
932
  function H() {
774
- o.value = "", g.value = !1;
933
+ l.value = "", y.value = !1;
775
934
  }
776
- return { sendMessage: b, regenerateResponse: L, toggleStop: e, goHistoryMessage: x, initConversation: D, resetConversation: H, controllers: h };
935
+ return { sendMessage: M, regenerateResponse: P, toggleStop: t, goHistoryMessage: E, initConversation: x, resetConversation: H, controllers: v };
777
936
  }
778
- const qe = { class: "container" }, _e = { class: "message ai-message greet-message" }, Ue = { class: "ai-greet" }, je = ["src"], Ke = {
937
+ const sn = { class: "container" }, on = { class: "message ai-message greet-message" }, an = { class: "ai-greet" }, ln = ["src"], cn = {
779
938
  key: 0,
780
939
  class: "message ai-message recommend-message"
781
- }, ze = { class: "ai-recommend" }, Ze = { class: "recommend-header" }, Ie = ["src"], tn = ["onClick"], en = /* @__PURE__ */ nt({
940
+ }, rn = { class: "ai-recommend" }, un = { class: "recommend-header" }, vn = ["src"], dn = ["onClick"], gn = /* @__PURE__ */ ee({
782
941
  __name: "Answer",
783
942
  props: {
784
943
  defaultSayhello: {},
785
944
  defaultRecommend: {}
786
945
  },
787
946
  emits: ["title-generated"],
788
- setup(t, { expose: u, emit: r }) {
789
- const v = {
947
+ setup(e, { expose: p, emit: h }) {
948
+ const u = {
790
949
  THINKING: "thinking",
791
950
  RETHINKING: "rethinking",
792
951
  ANSWERING: "answering",
@@ -794,358 +953,358 @@ const qe = { class: "container" }, _e = { class: "message ai-message greet-messa
794
953
  COMPLETED: "completed",
795
954
  STOP: "stop",
796
955
  ERROR: "error"
797
- }, o = t, c = r, a = ft(), n = C([]), f = C(""), M = C(!1), B = C(""), R = C(""), h = C(null), g = I({ text1: "", text2: "" }), E = C([]), b = C(0), L = _(
798
- () => E.value[b.value % (E.value.length || 1)]
956
+ }, l = e, c = h, i = de(), s = C([]), a = C(""), d = C(!1), f = C(""), A = C(""), v = C(null), y = ne({ text1: "", text2: "" }), $ = C([]), M = C(0), P = F(
957
+ () => $.value[M.value % ($.value.length || 1)]
799
958
  );
800
- function e() {
801
- b.value++;
959
+ function t() {
960
+ M.value++;
802
961
  }
803
- function x(Y) {
804
- f.value = Y;
962
+ function E(Q) {
963
+ a.value = Q;
805
964
  }
806
- const { isAtBottom: D, hasScroll: H, scrollToBottom: l, checkScrollStatus: p } = Ye(h), { enhanceCodeBlocks: A } = Qe(), { batchMessagesUpdate: y, flushMessagesBatch: i } = Fe(n), { displayedContent: m, streamingIndexRef: k, startTypewriter: $, stopTypewriter: P, getSegmentDisplayContent: N } = Ve(
807
- n,
808
- l,
809
- v.ANSWERING
810
- ), { doStreamRequest: G, issTop: vt } = Xe({
811
- messages: n,
812
- isGenerating: M,
813
- lastUserMessage: B,
814
- batchMessagesUpdate: y,
815
- flushMessagesBatch: i,
816
- STATUS: v,
817
- cfg: a
818
- }), { sendMessage: dt, regenerateResponse: pt, toggleStop: yt, goHistoryMessage: St, resetConversation: bt } = Je({
819
- messages: n,
820
- userInput: f,
821
- isGenerating: M,
822
- lastUserMessage: B,
823
- conversationId: R,
824
- doStreamRequest: G,
825
- issTop: vt,
826
- scrollToBottom: l,
827
- STATUS: v,
828
- cfg: a,
829
- onTitleGenerated: (Y) => c("title-generated", Y)
965
+ const { isAtBottom: x, hasScroll: H, scrollToBottom: o, checkScrollStatus: g } = zt(v), { enhanceCodeBlocks: S } = Kt(), { batchMessagesUpdate: T, flushMessagesBatch: r } = Zt(s), { displayedContent: b, streamingIndexRef: R, startTypewriter: B, stopTypewriter: L, getSegmentDisplayContent: N } = It(
966
+ s,
967
+ o,
968
+ u.ANSWERING
969
+ ), { doStreamRequest: q, issTop: ge } = en({
970
+ messages: s,
971
+ isGenerating: d,
972
+ lastUserMessage: f,
973
+ batchMessagesUpdate: T,
974
+ flushMessagesBatch: r,
975
+ STATUS: u,
976
+ cfg: i
977
+ }), { sendMessage: me, regenerateResponse: ye, toggleStop: we, goHistoryMessage: Te, resetConversation: Ee } = nn({
978
+ messages: s,
979
+ userInput: a,
980
+ isGenerating: d,
981
+ lastUserMessage: f,
982
+ conversationId: A,
983
+ doStreamRequest: q,
984
+ issTop: ge,
985
+ scrollToBottom: o,
986
+ STATUS: u,
987
+ cfg: i,
988
+ onTitleGenerated: (Q) => c("title-generated", Q)
830
989
  });
831
- function st() {
832
- n.value = [], B.value = "", bt();
990
+ function oe() {
991
+ s.value = [], f.value = "", Ee();
833
992
  }
834
- const ot = _(() => n.value.length === 0);
835
- u({ goHistoryMessage: St, createNewConversation: st, isEmptyConversation: ot });
836
- const at = C(/* @__PURE__ */ new Map());
837
- function Rt(Y, Q) {
838
- Y ? at.value.set(Q, Y) : at.value.delete(Q);
993
+ const ae = F(() => s.value.length === 0);
994
+ p({ goHistoryMessage: Te, createNewConversation: oe, isEmptyConversation: ae });
995
+ const ie = C(/* @__PURE__ */ new Map());
996
+ function Re(Q, G) {
997
+ Q ? ie.value.set(G, Q) : ie.value.delete(G);
839
998
  }
840
- Ct(n, () => {
841
- Z(() => {
842
- n.value.forEach((Y, Q) => {
843
- Y.type === "ai" && Y.status !== v.ANSWERING && (m.set(Q, Y.content), k.value.set(Q, Y.content.length));
844
- }), $(), at.value.forEach((Y) => {
845
- A(Y);
999
+ se(s, () => {
1000
+ K(() => {
1001
+ s.value.forEach((Q, G) => {
1002
+ Q.type === "ai" && Q.status !== u.ANSWERING && (b.set(G, Q.content), R.value.set(G, Q.content.length));
1003
+ }), B(), ie.value.forEach((Q) => {
1004
+ S(Q);
846
1005
  });
847
1006
  });
848
1007
  }, { deep: !0 });
849
- let z = null;
850
- return et(() => {
851
- o.defaultSayhello && (g.text1 = o.defaultSayhello.text1, g.text2 = o.defaultSayhello.text2), o.defaultRecommend && (E.value = te(o.defaultRecommend));
852
- }), et(() => {
853
- h.value && (z = () => p(), h.value.addEventListener("scroll", z));
854
- }), At(() => {
855
- P(), h.value && z && h.value.removeEventListener("scroll", z);
856
- }), (Y, Q) => {
857
- var wt;
858
- return w(), S("div", qe, [
859
- s("div", {
1008
+ let te = null;
1009
+ return j(() => {
1010
+ l.defaultSayhello && (y.text1 = l.defaultSayhello.text1, y.text2 = l.defaultSayhello.text2), l.defaultRecommend && ($.value = nt(l.defaultRecommend));
1011
+ }), j(() => {
1012
+ v.value && (te = () => g(), v.value.addEventListener("scroll", te));
1013
+ }), Ae(() => {
1014
+ L(), v.value && te && v.value.removeEventListener("scroll", te);
1015
+ }), (Q, G) => {
1016
+ var ke;
1017
+ return m(), k("div", sn, [
1018
+ n("div", {
860
1019
  class: "chat-box scrollWrap",
861
1020
  ref_key: "chatBoxRef",
862
- ref: h
1021
+ ref: v
863
1022
  }, [
864
- s("div", _e, [
865
- s("div", Ue, [
866
- s("img", { src: O(xt) }, null, 8, je),
867
- s("h1", null, F(g.text1), 1),
868
- s("p", null, F(g.text2), 1)
1023
+ n("div", on, [
1024
+ n("div", an, [
1025
+ n("img", { src: D(We) }, null, 8, ln),
1026
+ n("h1", null, V(y.text1), 1),
1027
+ n("p", null, V(y.text2), 1)
869
1028
  ])
870
1029
  ]),
871
- (wt = L.value) != null && wt.length ? (w(), S("div", Ke, [
872
- s("div", ze, [
873
- s("div", Ze, [
874
- Q[2] || (Q[2] = s("span", null, "你可以尝试这样问我:", -1)),
875
- s("p", {
1030
+ (ke = P.value) != null && ke.length ? (m(), k("div", cn, [
1031
+ n("div", rn, [
1032
+ n("div", un, [
1033
+ G[2] || (G[2] = n("span", null, "你可以尝试这样问我:", -1)),
1034
+ n("p", {
876
1035
  class: "refresh-btn",
877
- onClick: e
1036
+ onClick: t
878
1037
  }, [
879
- s("img", { src: O(he) }, null, 8, Ie),
880
- Q[1] || (Q[1] = s("span", null, "换一换", -1))
1038
+ n("img", { src: D(yt) }, null, 8, vn),
1039
+ G[1] || (G[1] = n("span", null, "换一换", -1))
881
1040
  ])
882
1041
  ]),
883
- s("ul", null, [
884
- (w(!0), S(K, null, ut(L.value, (U, it) => (w(), S("li", {
885
- key: it,
886
- onClick: (lt) => x(U)
887
- }, F(U), 9, tn))), 128))
1042
+ n("ul", null, [
1043
+ (m(!0), k(I, null, ve(P.value, (z, le) => (m(), k("li", {
1044
+ key: le,
1045
+ onClick: (ce) => E(z)
1046
+ }, V(z), 9, dn))), 128))
888
1047
  ])
889
1048
  ])
890
- ])) : V("", !0),
891
- (w(!0), S(K, null, ut(n.value, (U, it) => (w(), tt($e, {
892
- key: it,
893
- msg: U,
894
- index: it,
895
- STATUS: v,
896
- displayedContent: O(m),
897
- getSegmentDisplayContent: O(N),
898
- setMessageRef: Rt,
899
- onRegenerate: O(pt)
1049
+ ])) : _("", !0),
1050
+ (m(!0), k(I, null, ve(s.value, (z, le) => (m(), Z(Nt, {
1051
+ key: le,
1052
+ msg: z,
1053
+ index: le,
1054
+ STATUS: u,
1055
+ displayedContent: D(b),
1056
+ getSegmentDisplayContent: D(N),
1057
+ setMessageRef: Re,
1058
+ onRegenerate: D(ye)
900
1059
  }, null, 8, ["msg", "index", "displayedContent", "getSegmentDisplayContent", "onRegenerate"]))), 128))
901
1060
  ], 512),
902
- X(We, {
903
- modelValue: f.value,
904
- "onUpdate:modelValue": Q[0] || (Q[0] = (U) => f.value = U),
905
- isGenerating: M.value,
906
- lastUserMessage: B.value,
907
- hasScroll: O(H),
908
- isAtBottom: O(D),
909
- onSend: O(dt),
910
- onRegenerate: O(pt),
911
- onStop: O(yt),
912
- onScrollToBottom: O(l)
1061
+ Y(jt, {
1062
+ modelValue: a.value,
1063
+ "onUpdate:modelValue": G[0] || (G[0] = (z) => a.value = z),
1064
+ isGenerating: d.value,
1065
+ lastUserMessage: f.value,
1066
+ hasScroll: D(H),
1067
+ isAtBottom: D(x),
1068
+ onSend: D(me),
1069
+ onRegenerate: D(ye),
1070
+ onStop: D(we),
1071
+ onScrollToBottom: D(o)
913
1072
  }, null, 8, ["modelValue", "isGenerating", "lastUserMessage", "hasScroll", "isAtBottom", "onSend", "onRegenerate", "onStop", "onScrollToBottom"]),
914
- Q[3] || (Q[3] = s("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
1073
+ G[3] || (G[3] = n("div", { class: "ai-mistake-tip" }, "AI也会犯错,请核实重要信息", -1))
915
1074
  ]);
916
1075
  };
917
1076
  }
918
- }), nn = { class: "ai-history" }, sn = { class: "content" }, on = {
1077
+ }), mn = { class: "ai-history" }, hn = { class: "content" }, pn = {
919
1078
  key: 0,
920
1079
  class: "ai-history-loading"
921
- }, an = { class: "ai-history-group-title" }, ln = ["onClick"], rn = { class: "ai-history-item-title" }, cn = ["onClick"], un = {
1080
+ }, fn = { class: "ai-history-group-title" }, yn = ["onClick"], wn = { class: "ai-history-item-title" }, kn = ["onClick"], Cn = {
922
1081
  key: 2,
923
1082
  class: "ai-history-empty"
924
- }, vn = ["src"], dn = { class: "ai-modal" }, gn = { class: "ai-modal-footer" }, hn = /* @__PURE__ */ nt({
1083
+ }, An = ["src"], bn = { class: "ai-modal" }, Sn = { class: "ai-modal-footer" }, Tn = /* @__PURE__ */ ee({
925
1084
  __name: "History",
926
1085
  emits: ["history-detail", "new-conversation"],
927
- setup(t, { emit: u }) {
928
- const v = ft().apis, o = C([]), c = C(!0), a = C(!1), n = C(""), f = _(() => ee(o.value));
929
- async function M() {
1086
+ setup(e, { emit: p }) {
1087
+ const u = de().apis, l = C([]), c = C(!0), i = C(!1), s = C(""), a = F(() => st(l.value));
1088
+ async function d() {
930
1089
  try {
931
- const h = await ne(v);
932
- h != null && h.conversationList && (o.value = h.conversationList.filter((g) => g !== null).map((g) => ({ ...g, selected: !1 })));
933
- } catch (h) {
934
- ct((h == null ? void 0 : h.message) || "获取历史记录失败");
1090
+ const v = await ot(u);
1091
+ v != null && v.conversationList && (l.value = v.conversationList.filter((y) => y !== null).map((y) => ({ ...y, selected: !1 })));
1092
+ } catch (v) {
1093
+ ue((v == null ? void 0 : v.message) || "获取历史记录失败");
935
1094
  } finally {
936
1095
  c.value = !1;
937
1096
  }
938
1097
  }
939
- function B(h) {
940
- n.value = h, a.value = !0;
1098
+ function f(v) {
1099
+ s.value = v, i.value = !0;
941
1100
  }
942
- async function R() {
943
- a.value = !1;
1101
+ async function A() {
1102
+ i.value = !1;
944
1103
  try {
945
- await se(v, n.value), await M();
946
- } catch (h) {
947
- ct((h == null ? void 0 : h.message) || "删除失败"), await M();
1104
+ await at(u, s.value), await d();
1105
+ } catch (v) {
1106
+ ue((v == null ? void 0 : v.message) || "删除失败"), await d();
948
1107
  }
949
1108
  }
950
- return et(() => {
951
- M();
952
- }), (h, g) => (w(), S("div", nn, [
953
- s("div", sn, [
954
- c.value ? (w(), S("div", on, [...g[3] || (g[3] = [
955
- s("div", { class: "ai-history-spinner" }, null, -1)
956
- ])])) : f.value.length > 0 ? (w(!0), S(K, { key: 1 }, ut(f.value, (E) => (w(), S("div", {
957
- key: E.label,
1109
+ return j(() => {
1110
+ d();
1111
+ }), (v, y) => (m(), k("div", mn, [
1112
+ n("div", hn, [
1113
+ c.value ? (m(), k("div", pn, [...y[3] || (y[3] = [
1114
+ n("div", { class: "ai-history-spinner" }, null, -1)
1115
+ ])])) : a.value.length > 0 ? (m(!0), k(I, { key: 1 }, ve(a.value, ($) => (m(), k("div", {
1116
+ key: $.label,
958
1117
  class: "ai-history-group"
959
1118
  }, [
960
- s("div", an, F(E.label), 1),
961
- (w(!0), S(K, null, ut(E.items, (b, L) => (w(), S("div", {
962
- key: b.appConversationID,
1119
+ n("div", fn, V($.label), 1),
1120
+ (m(!0), k(I, null, ve($.items, (M, P) => (m(), k("div", {
1121
+ key: M.appConversationID,
963
1122
  class: "ai-history-item",
964
- style: Mt({ "--i": L }),
965
- onClick: (e) => h.$emit("history-detail", b.appConversationID)
1123
+ style: Se({ "--i": P }),
1124
+ onClick: (t) => v.$emit("history-detail", M.appConversationID)
966
1125
  }, [
967
- s("div", rn, F(b.conversationName), 1),
968
- s("div", {
1126
+ n("div", wn, V(M.conversationName), 1),
1127
+ n("div", {
969
1128
  class: "ai-history-item-delete",
970
- onClick: Ht((e) => B(b.appConversationID), ["stop"])
971
- }, "删除", 8, cn)
972
- ], 12, ln))), 128))
973
- ]))), 128)) : (w(), S("div", un, "暂无历史记录"))
1129
+ onClick: be((t) => f(M.appConversationID), ["stop"])
1130
+ }, "删除", 8, kn)
1131
+ ], 12, yn))), 128))
1132
+ ]))), 128)) : (m(), k("div", Cn, "暂无历史记录"))
974
1133
  ]),
975
- s("div", {
1134
+ n("div", {
976
1135
  class: "ai-add",
977
- onClick: g[0] || (g[0] = (E) => h.$emit("new-conversation"))
1136
+ onClick: y[0] || (y[0] = ($) => v.$emit("new-conversation"))
978
1137
  }, [
979
- s("img", { src: O(re) }, null, 8, vn),
980
- g[4] || (g[4] = s("span", null, "新建AI对话", -1))
1138
+ n("img", { src: D(vt) }, null, 8, An),
1139
+ y[4] || (y[4] = n("span", null, "新建AI对话", -1))
981
1140
  ]),
982
- (w(), tt(qt, { to: "#ai-assist-root" }, [
983
- a.value ? (w(), S("div", {
1141
+ (m(), Z(Le, { to: "#ai-assist-root" }, [
1142
+ i.value ? (m(), k("div", {
984
1143
  key: 0,
985
1144
  class: "ai-modal-overlay",
986
- onClick: g[2] || (g[2] = Ht((E) => a.value = !1, ["self"]))
1145
+ onClick: y[2] || (y[2] = be(($) => i.value = !1, ["self"]))
987
1146
  }, [
988
- s("div", dn, [
989
- g[5] || (g[5] = s("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
990
- g[6] || (g[6] = s("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
991
- s("div", gn, [
992
- s("button", {
1147
+ n("div", bn, [
1148
+ y[5] || (y[5] = n("div", { class: "ai-modal-header" }, "确定要删除该历史记录吗?", -1)),
1149
+ y[6] || (y[6] = n("div", { class: "ai-modal-body" }, "一旦删除,数据将无法恢复。", -1)),
1150
+ n("div", Sn, [
1151
+ n("button", {
993
1152
  class: "ai-modal-btn cancel",
994
- onClick: g[1] || (g[1] = (E) => a.value = !1)
1153
+ onClick: y[1] || (y[1] = ($) => i.value = !1)
995
1154
  }, "取消"),
996
- s("button", {
1155
+ n("button", {
997
1156
  class: "ai-modal-btn confirm",
998
- onClick: R
1157
+ onClick: A
999
1158
  }, "确定")
1000
1159
  ])
1001
1160
  ])
1002
- ])) : V("", !0)
1161
+ ])) : _("", !0)
1003
1162
  ]))
1004
1163
  ]));
1005
1164
  }
1006
- }), mn = { class: "container info" }, fn = { class: "info-item" }, pn = { class: "basic-content" }, yn = { class: "basic-content-text" }, wn = { class: "basic-content" }, kn = { class: "basic-content-text" }, Cn = { class: "info-item" }, An = { class: "permission-content" }, Sn = { class: "info-item" }, bn = { class: "basic-content" }, Rn = { class: "basic-content-text" }, En = { class: "basic-content" }, Mn = { class: "basic-content-text" }, Tn = /* @__PURE__ */ nt({
1165
+ }), En = { class: "container info" }, Rn = { class: "info-item" }, Mn = { class: "basic-content" }, $n = { class: "basic-content-text" }, xn = { class: "basic-content" }, Dn = { class: "basic-content-text" }, Hn = { class: "info-item" }, On = { class: "permission-content" }, Pn = { class: "info-item" }, Bn = { class: "basic-content" }, Ln = { class: "basic-content-text" }, Nn = { class: "basic-content" }, _n = { class: "basic-content-text" }, Vn = /* @__PURE__ */ ee({
1007
1166
  __name: "Info",
1008
- setup(t) {
1009
- const u = ft(), r = C(null);
1010
- return et(async () => {
1167
+ setup(e) {
1168
+ const p = de(), h = C(null);
1169
+ return j(async () => {
1011
1170
  try {
1012
- r.value = await oe(u.apis);
1013
- } catch (v) {
1014
- ct((v == null ? void 0 : v.message) || "获取个人信息失败");
1171
+ h.value = await it(p.apis);
1172
+ } catch (u) {
1173
+ ue((u == null ? void 0 : u.message) || "获取个人信息失败");
1015
1174
  }
1016
- }), (v, o) => {
1017
- var c, a, n, f, M;
1018
- return w(), S("div", mn, [
1019
- s("div", fn, [
1020
- o[2] || (o[2] = s("div", { class: "heading" }, [
1021
- s("div", { class: "heading-column" }),
1022
- s("div", { class: "heading-title" }, "基本信息")
1175
+ }), (u, l) => {
1176
+ var c, i, s, a, d;
1177
+ return m(), k("div", En, [
1178
+ n("div", Rn, [
1179
+ l[2] || (l[2] = n("div", { class: "heading" }, [
1180
+ n("div", { class: "heading-column" }),
1181
+ n("div", { class: "heading-title" }, "基本信息")
1023
1182
  ], -1)),
1024
- s("div", pn, [
1025
- o[0] || (o[0] = s("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
1026
- s("div", yn, F(((c = r.value) == null ? void 0 : c.name) || ""), 1)
1183
+ n("div", Mn, [
1184
+ l[0] || (l[0] = n("div", { class: "basic-content-text basic-content-key" }, "姓名", -1)),
1185
+ n("div", $n, V(((c = h.value) == null ? void 0 : c.name) || ""), 1)
1027
1186
  ]),
1028
- s("div", wn, [
1029
- o[1] || (o[1] = s("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
1030
- s("div", kn, F(((a = r.value) == null ? void 0 : a.userName) || ""), 1)
1187
+ n("div", xn, [
1188
+ l[1] || (l[1] = n("div", { class: "basic-content-text basic-content-key" }, "用户名", -1)),
1189
+ n("div", Dn, V(((i = h.value) == null ? void 0 : i.userName) || ""), 1)
1031
1190
  ])
1032
1191
  ]),
1033
- s("div", Cn, [
1034
- o[3] || (o[3] = s("div", { class: "heading" }, [
1035
- s("div", { class: "heading-column" }),
1036
- s("div", { class: "heading-title" }, "数据权限")
1192
+ n("div", Hn, [
1193
+ l[3] || (l[3] = n("div", { class: "heading" }, [
1194
+ n("div", { class: "heading-column" }),
1195
+ n("div", { class: "heading-title" }, "数据权限")
1037
1196
  ], -1)),
1038
- s("div", An, [
1039
- (w(!0), S(K, null, ut((n = r.value) == null ? void 0 : n.ptnameList, (B, R) => (w(), S("div", {
1040
- key: R,
1197
+ n("div", On, [
1198
+ (m(!0), k(I, null, ve((s = h.value) == null ? void 0 : s.ptnameList, (f, A) => (m(), k("div", {
1199
+ key: A,
1041
1200
  class: "permission-content-text"
1042
- }, F(B), 1))), 128))
1201
+ }, V(f), 1))), 128))
1043
1202
  ])
1044
1203
  ]),
1045
- s("div", Sn, [
1046
- o[6] || (o[6] = s("div", { class: "heading" }, [
1047
- s("div", { class: "heading-column" }),
1048
- s("div", { class: "heading-title" }, "帮助信息")
1204
+ n("div", Pn, [
1205
+ l[6] || (l[6] = n("div", { class: "heading" }, [
1206
+ n("div", { class: "heading-column" }),
1207
+ n("div", { class: "heading-title" }, "帮助信息")
1049
1208
  ], -1)),
1050
- s("div", bn, [
1051
- o[4] || (o[4] = s("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
1052
- s("div", Rn, F(((f = r.value) == null ? void 0 : f.dept) || ""), 1)
1209
+ n("div", Bn, [
1210
+ l[4] || (l[4] = n("div", { class: "basic-content-text basic-content-key" }, "部门", -1)),
1211
+ n("div", Ln, V(((a = h.value) == null ? void 0 : a.dept) || ""), 1)
1053
1212
  ]),
1054
- s("div", En, [
1055
- o[5] || (o[5] = s("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
1056
- s("div", Mn, F(((M = r.value) == null ? void 0 : M.email) || ""), 1)
1213
+ n("div", Nn, [
1214
+ l[5] || (l[5] = n("div", { class: "basic-content-text basic-content-key" }, "邮箱", -1)),
1215
+ n("div", _n, V(((d = h.value) == null ? void 0 : d.email) || ""), 1)
1057
1216
  ])
1058
1217
  ])
1059
1218
  ]);
1060
1219
  };
1061
1220
  }
1062
- }), Dn = { class: "header" }, Hn = { key: 1 }, On = ["src"], $n = { class: "header-title" }, Pn = ["title"], Nn = { class: "ai-history-drawer-panel" }, Bn = { class: "ai-history-drawer-header" }, Ln = { class: "setTitle" }, xn = { class: "content" }, Wn = { class: "main" }, Yn = { class: "btn" }, Qn = ["src"], Fn = 78, ht = 78, Wt = /* @__PURE__ */ nt({
1221
+ }), Wn = { class: "header" }, Yn = { key: 1 }, Fn = ["src"], Qn = { class: "header-title" }, Gn = ["title"], Xn = { class: "ai-history-drawer-panel" }, Jn = { class: "ai-history-drawer-header" }, qn = { class: "setTitle" }, Un = { class: "content" }, jn = { class: "main" }, zn = { class: "btn" }, Kn = ["src"], Zn = 78, pe = 78, Ye = /* @__PURE__ */ ee({
1063
1222
  __name: "AiAssist",
1064
- setup(t) {
1065
- const u = Fn / 2, r = ft(), v = C(!1), o = C("idle"), c = C(!1), a = I({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), n = C(!1), f = C(window.innerWidth < 768), M = C(window.innerWidth < 768), B = C("answer"), R = C(!1), h = C(""), g = C(""), E = C(""), b = C(!1), L = C(!1), e = I({
1066
- x: window.innerWidth - u,
1067
- y: window.innerHeight / 2 - ht / 2
1068
- }), x = C(!1), D = C(!1), H = C("right"), l = C("left"), p = I({ x: 0, y: 0 }), A = C(!1), y = C(null);
1069
- let i = null, m = null;
1070
- const k = _(() => {
1071
- const d = window.innerWidth / 2;
1072
- return e.x + u < d ? 5 : -5;
1073
- }), $ = _(() => M.value ? "" : `panel-${H.value}`), P = _(() => {
1074
- var d;
1075
- return !((d = y.value) != null && d.isEmptyConversation);
1076
- }), N = _(() => ({
1077
- left: `${e.x}px`,
1078
- top: `${e.y}px`,
1079
- transition: x.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
1080
- "--direction": String(k.value)
1081
- })), G = _(() => r.characterImage || ce), vt = _(() => o.value === "idle" ? {} : {
1082
- left: `${a.x}px`,
1083
- top: `${a.y}px`,
1084
- width: `${a.w}px`,
1085
- height: `${a.h}px`,
1086
- borderRadius: a.radius
1223
+ setup(e) {
1224
+ const p = Zn / 2, h = de(), u = C(!1), l = C("idle"), c = C(!1), i = ne({ x: 0, y: 0, w: 78, h: 78, radius: "14px" }), s = C(!1), a = C(window.innerWidth < 768), d = C(window.innerWidth < 768), f = C("answer"), A = C(!1), v = C(""), y = C(""), $ = C(""), M = C(!1), P = C(!1), t = ne({
1225
+ x: window.innerWidth - p,
1226
+ y: window.innerHeight / 2 - pe / 2
1227
+ }), E = C(!1), x = C(!1), H = C("right"), o = C("left"), g = ne({ x: 0, y: 0 }), S = C(!1), T = C(null);
1228
+ let r = null, b = null;
1229
+ const R = F(() => {
1230
+ const w = window.innerWidth / 2;
1231
+ return t.x + p < w ? 5 : -5;
1232
+ }), B = F(() => d.value ? "" : `panel-${H.value}`), L = F(() => {
1233
+ var w;
1234
+ return !((w = T.value) != null && w.isEmptyConversation);
1235
+ }), N = F(() => ({
1236
+ left: `${t.x}px`,
1237
+ top: `${t.y}px`,
1238
+ transition: E.value ? "none" : "all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)",
1239
+ "--direction": String(R.value)
1240
+ })), q = F(() => h.characterImage || dt), ge = F(() => l.value === "idle" ? {} : {
1241
+ left: `${i.x}px`,
1242
+ top: `${i.y}px`,
1243
+ width: `${i.w}px`,
1244
+ height: `${i.h}px`,
1245
+ borderRadius: i.radius
1087
1246
  });
1088
- function dt() {
1089
- const d = window.innerWidth / 2;
1090
- e.x + u < d ? (H.value = "left", l.value = "right") : (H.value = "right", l.value = "left");
1247
+ function me() {
1248
+ const w = window.innerWidth / 2;
1249
+ t.x + p < w ? (H.value = "left", o.value = "right") : (H.value = "right", o.value = "left");
1091
1250
  }
1092
- function pt() {
1093
- const d = window.innerWidth, T = Math.max(0, Math.min(e.y, window.innerHeight - ht));
1094
- return { x: e.x + u >= d / 2 ? d - u : -u, y: T };
1251
+ function ye() {
1252
+ const w = window.innerWidth, O = Math.max(0, Math.min(t.y, window.innerHeight - pe));
1253
+ return { x: t.x + p >= w / 2 ? w - p : -p, y: O };
1095
1254
  }
1096
- function yt() {
1097
- D.value = !0;
1098
- const d = pt();
1099
- e.x = d.x, e.y = d.y, setTimeout(() => {
1100
- D.value = !1, dt(), St();
1255
+ function we() {
1256
+ x.value = !0;
1257
+ const w = ye();
1258
+ t.x = w.x, t.y = w.y, setTimeout(() => {
1259
+ x.value = !1, me(), Te();
1101
1260
  }, 400);
1102
1261
  }
1103
- function St() {
1262
+ function Te() {
1104
1263
  try {
1105
- localStorage.setItem("characterPosition", JSON.stringify({ x: e.x, y: e.y })), localStorage.setItem("panelPosition", H.value), localStorage.setItem("backPosition", l.value);
1264
+ localStorage.setItem("characterPosition", JSON.stringify({ x: t.x, y: t.y })), localStorage.setItem("panelPosition", H.value), localStorage.setItem("backPosition", o.value);
1106
1265
  } catch {
1107
1266
  }
1108
1267
  }
1109
- function bt() {
1110
- const d = localStorage.getItem("characterPosition");
1111
- if (d) {
1112
- const q = JSON.parse(d);
1113
- e.x = q.x, e.y = Math.min(Math.max(q.y, 0), window.innerHeight - ht);
1268
+ function Ee() {
1269
+ const w = localStorage.getItem("characterPosition");
1270
+ if (w) {
1271
+ const U = JSON.parse(w);
1272
+ t.x = U.x, t.y = Math.min(Math.max(U.y, 0), window.innerHeight - pe);
1114
1273
  } else
1115
- e.x = window.innerWidth - u, e.y = window.innerHeight / 2 - ht / 2;
1116
- const T = localStorage.getItem("panelPosition"), W = localStorage.getItem("backPosition");
1117
- T && (H.value = T), W && (l.value = W);
1274
+ t.x = window.innerWidth - p, t.y = window.innerHeight / 2 - pe / 2;
1275
+ const O = localStorage.getItem("panelPosition"), W = localStorage.getItem("backPosition");
1276
+ O && (H.value = O), W && (o.value = W);
1118
1277
  }
1119
- function st(d) {
1120
- if (!x.value) return;
1121
- const T = "touches" in d ? d.touches[0].clientX : d.clientX, W = "touches" in d ? d.touches[0].clientY : d.clientY, q = T - p.x, Et = Math.max(0, Math.min(W - p.y, window.innerHeight - ht)), kt = Math.abs(q - e.x), Qt = Math.abs(Et - e.y);
1122
- kt + Qt > 5 && (A.value = !0), e.x = q, e.y = Et;
1278
+ function oe(w) {
1279
+ if (!E.value) return;
1280
+ const O = "touches" in w ? w.touches[0].clientX : w.clientX, W = "touches" in w ? w.touches[0].clientY : w.clientY, U = O - g.x, Me = Math.max(0, Math.min(W - g.y, window.innerHeight - pe)), Ce = Math.abs(U - t.x), Qe = Math.abs(Me - t.y);
1281
+ Ce + Qe > 5 && (S.value = !0), t.x = U, t.y = Me;
1123
1282
  }
1124
- function ot() {
1125
- x.value && (x.value = !1, A.value && (yt(), A.value = !1));
1283
+ function ae() {
1284
+ E.value && (E.value = !1, S.value && (we(), S.value = !1));
1126
1285
  }
1127
- function at(d) {
1128
- D.value = !1, x.value = !0, A.value = !1;
1129
- const T = "touches" in d ? d.touches[0].clientX : d.clientX, W = "touches" in d ? d.touches[0].clientY : d.clientY;
1130
- p.x = T - e.x, p.y = W - e.y;
1286
+ function ie(w) {
1287
+ x.value = !1, E.value = !0, S.value = !1;
1288
+ const O = "touches" in w ? w.touches[0].clientX : w.clientX, W = "touches" in w ? w.touches[0].clientY : w.clientY;
1289
+ g.x = O - t.x, g.y = W - t.y;
1131
1290
  }
1132
- function Rt() {
1133
- if (!A.value && !D.value) {
1134
- dt();
1135
- const d = z();
1136
- a.x = Math.max(0, Math.min(window.innerWidth - 53, e.x + k.value * 3)), a.y = e.y - k.value * 2, a.w = 53, a.h = 53, a.radius = "50%", c.value = !0, o.value = "expanding", v.value = !0, Z(() => {
1291
+ function Re() {
1292
+ if (!S.value && !x.value) {
1293
+ me();
1294
+ const w = te();
1295
+ i.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + R.value * 3)), i.y = t.y - R.value * 2, i.w = 53, i.h = 53, i.radius = "50%", c.value = !0, l.value = "expanding", u.value = !0, K(() => {
1137
1296
  requestAnimationFrame(() => {
1138
- c.value = !1, a.x = d.x, a.y = d.y, a.w = d.w, a.h = d.h, a.radius = d.radius;
1297
+ c.value = !1, i.x = w.x, i.y = w.y, i.w = w.w, i.h = w.h, i.radius = w.radius;
1139
1298
  });
1140
1299
  }), setTimeout(() => {
1141
- o.value = "idle";
1300
+ l.value = "idle";
1142
1301
  }, 400);
1143
1302
  } else
1144
- A.value = !1;
1303
+ S.value = !1;
1145
1304
  }
1146
- function z() {
1305
+ function te() {
1147
1306
  if (window.innerWidth < 768)
1148
- return M.value ? {
1307
+ return d.value ? {
1149
1308
  x: 0,
1150
1309
  y: 0,
1151
1310
  w: window.innerWidth,
@@ -1158,219 +1317,358 @@ const qe = { class: "container" }, _e = { class: "message ai-message greet-messa
1158
1317
  h: window.innerHeight - 16,
1159
1318
  radius: "14px"
1160
1319
  };
1161
- const T = window.innerHeight - 78, W = 54;
1162
- if (M.value) {
1163
- const kt = window.innerWidth * 0.8;
1320
+ const O = window.innerHeight - 78, W = 54;
1321
+ if (d.value) {
1322
+ const Ce = window.innerWidth * 0.8;
1164
1323
  return {
1165
- x: (window.innerWidth - kt) / 2,
1324
+ x: (window.innerWidth - Ce) / 2,
1166
1325
  y: W,
1167
- w: kt,
1168
- h: T,
1326
+ w: Ce,
1327
+ h: O,
1169
1328
  radius: "14px"
1170
1329
  };
1171
1330
  }
1172
- const q = 490;
1173
- return { x: H.value === "left" ? 24 : window.innerWidth - q - 24, y: W, w: q, h: T, radius: "14px" };
1331
+ const U = 490;
1332
+ return { x: H.value === "left" ? 24 : window.innerWidth - U - 24, y: W, w: U, h: O, radius: "14px" };
1174
1333
  }
1175
- function Y() {
1176
- if (o.value !== "idle") return;
1177
- const d = z();
1178
- a.x = d.x, a.y = d.y, a.w = d.w, a.h = d.h, a.radius = d.radius, c.value = !0, o.value = "collapsing", Z(() => {
1334
+ function Q() {
1335
+ if (l.value !== "idle") return;
1336
+ const w = te();
1337
+ i.x = w.x, i.y = w.y, i.w = w.w, i.h = w.h, i.radius = w.radius, c.value = !0, l.value = "collapsing", K(() => {
1179
1338
  requestAnimationFrame(() => {
1180
- c.value = !1, a.x = Math.max(0, Math.min(window.innerWidth - 53, e.x + k.value * 3)), a.y = e.y + Math.abs(k.value) * 2, a.w = 53, a.h = 53, a.radius = "50%";
1339
+ c.value = !1, i.x = Math.max(0, Math.min(window.innerWidth - 53, t.x + R.value * 3)), i.y = t.y + Math.abs(R.value) * 2, i.w = 53, i.h = 53, i.radius = "50%";
1181
1340
  });
1182
1341
  }), setTimeout(() => {
1183
- v.value = !1, o.value = "idle", n.value = !0;
1342
+ u.value = !1, l.value = "idle", s.value = !0;
1184
1343
  }, 400), setTimeout(() => {
1185
- n.value = !1;
1344
+ s.value = !1;
1186
1345
  }, 1400);
1187
1346
  }
1188
- function Q(d) {
1189
- lt(), B.value = "answer", Z(() => {
1190
- var T;
1191
- (T = y.value) == null || T.goHistoryMessage(d);
1347
+ function G(w) {
1348
+ ce(), f.value = "answer", K(() => {
1349
+ var O;
1350
+ (O = T.value) == null || O.goHistoryMessage(w);
1192
1351
  });
1193
1352
  }
1194
- function wt() {
1195
- E.value = "", B.value = "answer", Z(() => {
1196
- var d;
1197
- (d = y.value) == null || d.createNewConversation();
1353
+ function ke() {
1354
+ $.value = "", f.value = "answer", K(() => {
1355
+ var w;
1356
+ (w = T.value) == null || w.createNewConversation();
1198
1357
  });
1199
1358
  }
1200
- function U() {
1201
- lt(), E.value = "", Z(() => {
1202
- var d;
1203
- (d = y.value) == null || d.createNewConversation();
1359
+ function z() {
1360
+ ce(), $.value = "", K(() => {
1361
+ var w;
1362
+ (w = T.value) == null || w.createNewConversation();
1204
1363
  });
1205
1364
  }
1206
- function it() {
1207
- L.value = !1, b.value = !0;
1365
+ function le() {
1366
+ P.value = !1, M.value = !0;
1208
1367
  }
1209
- function lt() {
1210
- L.value = !0, setTimeout(() => {
1211
- b.value = !1, L.value = !1;
1368
+ function ce() {
1369
+ P.value = !0, setTimeout(() => {
1370
+ M.value = !1, P.value = !1;
1212
1371
  }, 300);
1213
1372
  }
1214
- function Yt() {
1215
- g.value = h.value, R.value = !1;
1373
+ function Fe() {
1374
+ y.value = v.value, A.value = !1;
1216
1375
  }
1217
- Ct(M, (d) => {
1218
- d ? H.value = "center" : dt();
1219
- }), et(() => {
1220
- bt();
1221
- const d = r.theme || "light";
1222
- Tt(d), d === "auto" && (m = ae(() => Tt("auto")));
1376
+ se(d, (w) => {
1377
+ w ? H.value = "center" : me();
1378
+ }), j(() => {
1379
+ Ee();
1380
+ const w = h.theme || "light";
1381
+ $e(w), w === "auto" && (b = lt(() => $e("auto")));
1223
1382
  });
1224
- function Dt() {
1225
- i && clearTimeout(i), i = setTimeout(() => {
1226
- const d = window.innerWidth < 768;
1227
- f.value = d, d && (M.value = !0), yt();
1383
+ function xe() {
1384
+ r && clearTimeout(r), r = setTimeout(() => {
1385
+ const w = window.innerWidth < 768;
1386
+ a.value = w, w && (d.value = !0), we();
1228
1387
  }, 100);
1229
1388
  }
1230
- return et(() => {
1231
- window.addEventListener("resize", Dt);
1232
- }), At(() => {
1233
- window.removeEventListener("resize", Dt), i && clearTimeout(i), m == null || m();
1234
- }), et(() => {
1235
- document.addEventListener("mousemove", st), document.addEventListener("touchmove", st, { passive: !0 }), document.addEventListener("mouseup", ot), document.addEventListener("touchend", ot);
1236
- }), At(() => {
1237
- document.removeEventListener("mousemove", st), document.removeEventListener("touchmove", st), document.removeEventListener("mouseup", ot), document.removeEventListener("touchend", ot);
1238
- }), (d, T) => (w(), S("div", null, [
1239
- rt(s("div", {
1240
- class: J(["ai-panel", M.value ? "maxWrap" : "minWrap", $.value, o.value !== "idle" ? o.value : "", { morphing: o.value !== "idle", "morph-instant": c.value }]),
1241
- style: Mt(vt.value)
1389
+ return j(() => {
1390
+ window.addEventListener("resize", xe);
1391
+ }), Ae(() => {
1392
+ window.removeEventListener("resize", xe), r && clearTimeout(r), b == null || b();
1393
+ }), j(() => {
1394
+ document.addEventListener("mousemove", oe), document.addEventListener("touchmove", oe, { passive: !0 }), document.addEventListener("mouseup", ae), document.addEventListener("touchend", ae);
1395
+ }), Ae(() => {
1396
+ document.removeEventListener("mousemove", oe), document.removeEventListener("touchmove", oe), document.removeEventListener("mouseup", ae), document.removeEventListener("touchend", ae);
1397
+ }), (w, O) => (m(), k("div", null, [
1398
+ re(n("div", {
1399
+ class: X(["ai-panel", d.value ? "maxWrap" : "minWrap", B.value, l.value !== "idle" ? l.value : "", { morphing: l.value !== "idle", "morph-instant": c.value }]),
1400
+ style: Se(ge.value)
1242
1401
  }, [
1243
- s("div", Dn, [
1244
- B.value === "info" ? (w(), S("span", {
1402
+ n("div", Wn, [
1403
+ f.value === "info" ? (m(), k("span", {
1245
1404
  key: 0,
1246
- class: J(["back", l.value]),
1247
- onClick: T[0] || (T[0] = (W) => B.value = "answer")
1248
- }, [...T[6] || (T[6] = [
1249
- s("span", { style: { "font-size": "14px" } }, "←", -1)
1250
- ])], 2)) : (w(), S("p", Hn, [
1251
- s("img", { src: O(xt) }, null, 8, On)
1405
+ class: X(["back", o.value]),
1406
+ onClick: O[0] || (O[0] = (W) => f.value = "answer")
1407
+ }, [...O[6] || (O[6] = [
1408
+ n("span", { style: { "font-size": "14px" } }, "←", -1)
1409
+ ])], 2)) : (m(), k("p", Yn, [
1410
+ n("img", { src: D(We) }, null, 8, Fn)
1252
1411
  ])),
1253
- s("div", $n, [
1254
- s("span", {
1255
- title: B.value === "info" ? "个人信息" : E.value || O(r).name
1256
- }, F(B.value === "info" ? "个人信息" : E.value || O(r).name), 9, Pn)
1412
+ n("div", Qn, [
1413
+ n("span", {
1414
+ title: f.value === "info" ? "个人信息" : $.value || D(h).name
1415
+ }, V(f.value === "info" ? "个人信息" : $.value || D(h).name), 9, Gn)
1257
1416
  ]),
1258
- s("p", null, [
1259
- rt(X(O(j), {
1417
+ n("p", null, [
1418
+ re(Y(D(J), {
1260
1419
  class: "op-icon",
1261
1420
  icon: "ic:round-add",
1262
- onClick: wt
1421
+ onClick: ke
1263
1422
  }, null, 512), [
1264
- [gt, P.value]
1423
+ [he, L.value]
1265
1424
  ]),
1266
- X(O(j), {
1267
- class: J(["mute", { active: b.value }]),
1425
+ Y(D(J), {
1426
+ class: X(["mute", { active: M.value }]),
1268
1427
  icon: "ic:round-history",
1269
- onClick: T[1] || (T[1] = (W) => b.value ? lt() : it())
1428
+ onClick: O[1] || (O[1] = (W) => M.value ? ce() : le())
1270
1429
  }, null, 8, ["class"]),
1271
- f.value ? V("", !0) : (w(), tt(O(j), {
1430
+ a.value ? _("", !0) : (m(), Z(D(J), {
1272
1431
  key: 0,
1273
- onClick: T[2] || (T[2] = (W) => M.value = !M.value),
1274
- icon: M.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
1432
+ onClick: O[2] || (O[2] = (W) => d.value = !d.value),
1433
+ icon: d.value ? "ic:round-fullscreen-exit" : "ic:round-fullscreen"
1275
1434
  }, null, 8, ["icon"])),
1276
- X(O(j), {
1277
- onClick: Y,
1435
+ Y(D(J), {
1436
+ onClick: Q,
1278
1437
  icon: "ic:round-close"
1279
1438
  })
1280
1439
  ])
1281
1440
  ]),
1282
- rt(X(en, {
1441
+ re(Y(gn, {
1283
1442
  ref_key: "answerRef",
1284
- ref: y,
1285
- defaultSayhello: O(r).defaultSayhello,
1286
- defaultRecommend: O(r).defaultRecommend,
1287
- onTitleGenerated: T[3] || (T[3] = (W) => E.value = W)
1443
+ ref: T,
1444
+ defaultSayhello: D(h).defaultSayhello,
1445
+ defaultRecommend: D(h).defaultRecommend,
1446
+ onTitleGenerated: O[3] || (O[3] = (W) => $.value = W)
1288
1447
  }, null, 8, ["defaultSayhello", "defaultRecommend"]), [
1289
- [gt, B.value === "answer"]
1448
+ [he, f.value === "answer"]
1290
1449
  ]),
1291
- B.value === "info" ? (w(), tt(Tn, { key: 0 })) : V("", !0),
1292
- b.value ? (w(), S("div", {
1450
+ f.value === "info" ? (m(), Z(Vn, { key: 0 })) : _("", !0),
1451
+ M.value ? (m(), k("div", {
1293
1452
  key: 1,
1294
- class: J(["ai-history-drawer", { closing: L.value }])
1453
+ class: X(["ai-history-drawer", { closing: P.value }])
1295
1454
  }, [
1296
- s("div", {
1455
+ n("div", {
1297
1456
  class: "ai-history-backdrop",
1298
- onClick: lt
1457
+ onClick: ce
1299
1458
  }),
1300
- s("div", Nn, [
1301
- s("div", Bn, [
1302
- T[7] || (T[7] = s("span", null, "对话记录", -1)),
1303
- X(O(j), {
1459
+ n("div", Xn, [
1460
+ n("div", Jn, [
1461
+ O[7] || (O[7] = n("span", null, "对话记录", -1)),
1462
+ Y(D(J), {
1304
1463
  icon: "ic:round-close",
1305
1464
  class: "ai-history-drawer-close",
1306
- onClick: lt
1465
+ onClick: ce
1307
1466
  })
1308
1467
  ]),
1309
- X(hn, {
1310
- onHistoryDetail: Q,
1311
- onNewConversation: U
1468
+ Y(Tn, {
1469
+ onHistoryDetail: G,
1470
+ onNewConversation: z
1312
1471
  })
1313
1472
  ])
1314
- ], 2)) : V("", !0),
1315
- rt(s("div", Ln, [
1316
- s("div", xn, [
1317
- s("div", Wn, [
1318
- T[8] || (T[8] = s("p", { class: "title" }, "修改标题", -1)),
1319
- rt(s("textarea", {
1320
- "onUpdate:modelValue": T[4] || (T[4] = (W) => h.value = W),
1473
+ ], 2)) : _("", !0),
1474
+ re(n("div", qn, [
1475
+ n("div", Un, [
1476
+ n("div", jn, [
1477
+ O[8] || (O[8] = n("p", { class: "title" }, "修改标题", -1)),
1478
+ re(n("textarea", {
1479
+ "onUpdate:modelValue": O[4] || (O[4] = (W) => v.value = W),
1321
1480
  placeholder: "请输入新标题"
1322
1481
  }, null, 512), [
1323
- [_t, h.value]
1482
+ [je, v.value]
1324
1483
  ]),
1325
- s("p", Yn, [
1326
- s("span", {
1327
- onClick: T[5] || (T[5] = (W) => R.value = !1)
1484
+ n("p", zn, [
1485
+ n("span", {
1486
+ onClick: O[5] || (O[5] = (W) => A.value = !1)
1328
1487
  }, "取消"),
1329
- s("span", { onClick: Yt }, "确定")
1488
+ n("span", { onClick: Fe }, "确定")
1330
1489
  ])
1331
1490
  ])
1332
1491
  ])
1333
1492
  ], 512), [
1334
- [gt, R.value]
1493
+ [he, A.value]
1335
1494
  ])
1336
1495
  ], 6), [
1337
- [gt, v.value || o.value !== "idle"]
1496
+ [he, u.value || l.value !== "idle"]
1338
1497
  ]),
1339
- rt(s("div", {
1340
- class: J(["character", { dragging: x.value, recycling: D.value, "hover-preview": n.value }]),
1341
- style: Mt(N.value),
1342
- onMousedown: at,
1343
- onTouchstart: at,
1344
- onClick: Rt
1498
+ re(n("div", {
1499
+ class: X(["character", { dragging: E.value, recycling: x.value, "hover-preview": s.value }]),
1500
+ style: Se(N.value),
1501
+ onMousedown: ie,
1502
+ onTouchstart: ie,
1503
+ onClick: Re
1345
1504
  }, [
1346
- s("img", { src: G.value }, null, 8, Qn)
1505
+ n("img", { src: q.value }, null, 8, Kn)
1347
1506
  ], 38), [
1348
- [gt, !v.value]
1507
+ [he, !u.value]
1349
1508
  ])
1350
1509
  ]));
1351
1510
  }
1352
- });
1353
- let mt = null;
1354
- const _n = (t) => {
1355
- Lt(t);
1356
- }, Un = (t) => {
1357
- const u = t || document.body, r = document.createElement("div");
1358
- r.id = "ai-assist-root";
1359
- const v = ft();
1360
- Tt(v.theme), ie(), u.appendChild(r), mt = Ut(Wt), mt.mount(r);
1361
- }, jn = () => {
1362
- mt && (mt.unmount(), mt = null);
1363
- const t = document.getElementById("ai-assist-root");
1364
- t && t.remove();
1365
- }, Kn = {
1366
- install(t, u) {
1367
- Lt(u), t.component("AiAssist", Wt);
1511
+ }), In = ["data-theme"], es = {
1512
+ key: 0,
1513
+ class: "ai-voice-input-final"
1514
+ }, ts = {
1515
+ key: 1,
1516
+ class: "ai-voice-input-interim"
1517
+ }, ns = {
1518
+ key: 2,
1519
+ class: "ai-voice-input-cursor"
1520
+ }, ss = {
1521
+ key: 3,
1522
+ class: "ai-voice-input-placeholder"
1523
+ }, os = ["disabled"], as = {
1524
+ key: 0,
1525
+ class: "ai-voice-input-pulse"
1526
+ }, is = {
1527
+ key: 1,
1528
+ class: "ai-voice-input-wave"
1529
+ }, ls = {
1530
+ key: 2,
1531
+ class: "ai-voice-input-btn-icon",
1532
+ viewBox: "0 0 24 24",
1533
+ fill: "currentColor",
1534
+ width: "16",
1535
+ height: "16"
1536
+ }, cs = /* @__PURE__ */ ee({
1537
+ __name: "VoiceInput",
1538
+ props: {
1539
+ config: {},
1540
+ placeholder: {},
1541
+ startText: {},
1542
+ stopText: {},
1543
+ connectingText: {},
1544
+ stoppingText: {},
1545
+ className: {}
1546
+ },
1547
+ emits: ["result", "final", "error", "statusChange", "complete"],
1548
+ setup(e, { expose: p, emit: h }) {
1549
+ const u = e, l = h, c = {
1550
+ idle: "开始录音",
1551
+ connecting: "连接中…",
1552
+ recording: "停止录音",
1553
+ stopping: "识别中…",
1554
+ error: "重试"
1555
+ }, i = C(""), s = C(""), a = C("idle");
1556
+ let d = null;
1557
+ const f = F(() => ct(u.config.theme ?? "light")), A = () => {
1558
+ d = new _e(u.config, {
1559
+ onStatusChange: (E) => {
1560
+ a.value = E, l("statusChange", E), E === "idle" && l("complete", i.value);
1561
+ },
1562
+ onInterim: (E) => {
1563
+ s.value = E;
1564
+ },
1565
+ onFinal: (E, x) => {
1566
+ i.value += E, s.value = "", l("final", E, x);
1567
+ },
1568
+ onResult: (E) => l("result", E),
1569
+ onError: (E) => l("error", E)
1570
+ });
1571
+ };
1572
+ j(A), Ne(() => {
1573
+ d == null || d.destroy(), d = null;
1574
+ }), se(
1575
+ () => [u.config.appId, u.config.appKey, u.config.devPid, u.config.url],
1576
+ () => {
1577
+ d == null || d.destroy(), A();
1578
+ }
1579
+ );
1580
+ const v = async () => {
1581
+ if (d)
1582
+ if (a.value === "idle" || a.value === "error")
1583
+ try {
1584
+ await d.start();
1585
+ } catch {
1586
+ }
1587
+ else a.value === "recording" && d.stop();
1588
+ }, y = () => {
1589
+ i.value = "", s.value = "";
1590
+ }, $ = F(() => !i.value && !s.value), M = F(() => a.value === "connecting" ? u.connectingText || c.connecting : a.value === "recording" ? u.stopText || c.recording : a.value === "stopping" ? u.stoppingText || c.stopping : a.value === "error" ? c.error : u.startText || c.idle), P = F(() => {
1591
+ const E = ["ai-voice-input-btn"];
1592
+ return a.value === "recording" && E.push("is-recording"), a.value === "connecting" && E.push("is-connecting"), a.value === "stopping" && E.push("is-stopping"), E.join(" ");
1593
+ }), t = F(() => a.value === "connecting" || a.value === "stopping");
1594
+ return p({
1595
+ start: async () => {
1596
+ await (d == null ? void 0 : d.start());
1597
+ },
1598
+ stop: () => d == null ? void 0 : d.stop(),
1599
+ cancel: () => d == null ? void 0 : d.cancel(),
1600
+ getText: () => i.value + s.value,
1601
+ clear: () => {
1602
+ i.value = "", s.value = "";
1603
+ },
1604
+ getStatus: () => (d == null ? void 0 : d.getStatus()) ?? "idle"
1605
+ }), (E, x) => (m(), k("div", {
1606
+ class: X(["ai-voice-input", e.className]),
1607
+ "data-theme": f.value
1608
+ }, [
1609
+ n("div", {
1610
+ class: X(["ai-voice-input-display", { "is-empty": $.value }])
1611
+ }, [
1612
+ i.value ? (m(), k("span", es, V(i.value), 1)) : _("", !0),
1613
+ s.value ? (m(), k("span", ts, V(s.value), 1)) : _("", !0),
1614
+ a.value === "recording" && !s.value ? (m(), k("span", ns)) : _("", !0),
1615
+ $.value ? (m(), k("span", ss, V(e.placeholder), 1)) : _("", !0)
1616
+ ], 2),
1617
+ n("button", {
1618
+ type: "button",
1619
+ class: X(P.value),
1620
+ disabled: t.value,
1621
+ onClick: v
1622
+ }, [
1623
+ a.value === "recording" ? (m(), k("span", as)) : a.value === "connecting" || a.value === "stopping" ? (m(), k("span", is, [...x[0] || (x[0] = [
1624
+ n("span", null, null, -1),
1625
+ n("span", null, null, -1),
1626
+ n("span", null, null, -1),
1627
+ n("span", null, null, -1),
1628
+ n("span", null, null, -1)
1629
+ ])])) : (m(), k("svg", ls, [...x[1] || (x[1] = [
1630
+ n("path", { d: "M12 14a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v5a3 3 0 0 0 3 3z" }, null, -1),
1631
+ n("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)
1632
+ ])])),
1633
+ n("span", null, V(M.value), 1)
1634
+ ], 10, os),
1635
+ $.value ? _("", !0) : (m(), k("button", {
1636
+ key: 0,
1637
+ type: "button",
1638
+ class: "ai-voice-input-btn ai-voice-input-clear-btn",
1639
+ title: "清空",
1640
+ onClick: y
1641
+ }, " 清空 "))
1642
+ ], 10, In));
1643
+ }
1644
+ }), rs = (e, p) => {
1645
+ const h = e.__vccOpts || e;
1646
+ for (const [u, l] of p)
1647
+ h[u] = l;
1648
+ return h;
1649
+ }, us = /* @__PURE__ */ rs(cs, [["__scopeId", "data-v-5b959b70"]]);
1650
+ let fe = null;
1651
+ const ps = (e) => {
1652
+ Ve(e);
1653
+ }, fs = (e) => {
1654
+ const p = e || document.body, h = document.createElement("div");
1655
+ h.id = "ai-assist-root";
1656
+ const u = de();
1657
+ $e(u.theme), rt(), p.appendChild(h), fe = ze(Ye), fe.mount(h);
1658
+ }, ys = () => {
1659
+ fe && (fe.unmount(), fe = null);
1660
+ const e = document.getElementById("ai-assist-root");
1661
+ e && e.remove();
1662
+ }, ws = {
1663
+ install(e, p) {
1664
+ Ve(p), e.component("AiAssist", Ye), e.component("VoiceInput", us);
1368
1665
  }
1369
1666
  };
1370
1667
  export {
1371
- Wt as AiAssist,
1372
- Kn as default,
1373
- _n as initAiAssist,
1374
- Un as mountAiAssist,
1375
- jn as unmountAiAssist
1668
+ Ye as AiAssist,
1669
+ us as VoiceInput,
1670
+ ws as default,
1671
+ ps as initAiAssist,
1672
+ fs as mountAiAssist,
1673
+ ys as unmountAiAssist
1376
1674
  };