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