@somecat/ai-assist-sdk 1.3.3 → 1.3.5

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