@somecat/ai-assist-sdk 1.1.25 → 1.2.0

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