@somecat/ai-assist-sdk 1.3.0 → 1.3.1

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