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