@somecat/ai-assist-sdk 1.2.2 → 1.2.4

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