@somecat/ai-assist-sdk 1.0.1 → 1.1.1

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