@glodon-aiot/agent-cli-ui 3.3.7-beta.1 → 3.3.8-alpha.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.
Files changed (46) hide show
  1. package/dist/es/AgentClientUI.mjs +107 -94
  2. package/dist/es/Dialog/AgentChat/HistoryItem/SessionRefer/index.mjs +46 -59
  3. package/dist/es/Dialog/AgentChat/HistoryItem/index.mjs +46 -47
  4. package/dist/es/Dialog/AgentChat/index.mjs +378 -376
  5. package/dist/es/Dialog/SessionList/index.mjs +115 -119
  6. package/dist/es/Dialog/index.mjs +26 -30
  7. package/dist/es/QuillEditor/index.mjs +59 -70
  8. package/dist/es/components/Recommend/index.mjs +34 -52
  9. package/dist/es/constant.mjs +3 -11
  10. package/dist/es/index.mjs +293 -285
  11. package/dist/es/packages/agent-cli-ui/package.json.mjs +26 -27
  12. package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
  13. package/dist/es/src/style.css +1 -1
  14. package/dist/es/src/style11.css +1 -1
  15. package/dist/es/src/style12.css +1 -1
  16. package/dist/es/src/style13.css +1 -1
  17. package/dist/es/src/style14.css +1 -1
  18. package/dist/es/src/style16.css +1 -1
  19. package/dist/es/src/style17.css +1 -1
  20. package/dist/es/src/style18.css +1 -1
  21. package/dist/es/src/style19.css +1 -1
  22. package/dist/es/src/style25.css +1 -1
  23. package/dist/es/src/style26.css +1 -1
  24. package/dist/es/src/style27.css +1 -1
  25. package/dist/es/src/style28.css +1 -1
  26. package/dist/es/src/style29.css +1 -1
  27. package/dist/es/src/style30.css +1 -1
  28. package/dist/es/src/style4.css +1 -1
  29. package/dist/es/src/style5.css +1 -1
  30. package/dist/es/src/style8.css +1 -1
  31. package/dist/es/src/style9.css +1 -1
  32. package/dist/lib/index.css +1 -1
  33. package/dist/lib/index.js +54 -54
  34. package/dist/src/AgentClientUI.d.ts +1 -1
  35. package/dist/src/Dialog/AgentChat/HistoryItem/SessionRefer/index.d.ts +0 -2
  36. package/dist/src/Dialog/index.d.ts +1 -1
  37. package/dist/src/Footer/index.d.ts +1 -2
  38. package/dist/src/components/Greeting/index.d.ts +1 -2
  39. package/dist/src/components/Header/index.d.ts +1 -2
  40. package/dist/src/components/Recommend/index.d.ts +0 -1
  41. package/dist/src/constant.d.ts +0 -4
  42. package/dist/src/index.d.ts +1 -5
  43. package/dist/src/types.d.ts +2 -3
  44. package/dist/src/utils/antdConfig.d.ts +7 -0
  45. package/dist/src/utils/testAntdPrefix.d.ts +3 -0
  46. package/package.json +10 -11
package/dist/es/index.mjs CHANGED
@@ -1,184 +1,193 @@
1
- var D = Object.defineProperty, j = Object.defineProperties;
2
- var F = Object.getOwnPropertyDescriptors;
3
- var z = Object.getOwnPropertySymbols;
4
- var P = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
5
- var L = (m, s, n) => s in m ? D(m, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : m[s] = n, a = (m, s) => {
6
- for (var n in s || (s = {}))
7
- P.call(s, n) && L(m, n, s[n]);
8
- if (z)
9
- for (var n of z(s))
10
- W.call(s, n) && L(m, n, s[n]);
11
- return m;
12
- }, C = (m, s) => j(m, F(s));
13
- var f = (m, s, n) => (L(m, typeof s != "symbol" ? s + "" : s, n), n);
14
- var B = (m, s, n) => new Promise((e, c) => {
15
- var d = (h) => {
1
+ var ie = Object.defineProperty, te = Object.defineProperties;
2
+ var se = Object.getOwnPropertyDescriptors;
3
+ var Z = Object.getOwnPropertySymbols;
4
+ var oe = Object.prototype.hasOwnProperty, ne = Object.prototype.propertyIsEnumerable;
5
+ var S = (p, i, n) => i in p ? ie(p, i, { enumerable: !0, configurable: !0, writable: !0, value: n }) : p[i] = n, r = (p, i) => {
6
+ for (var n in i || (i = {}))
7
+ oe.call(i, n) && S(p, n, i[n]);
8
+ if (Z)
9
+ for (var n of Z(i))
10
+ ne.call(i, n) && S(p, n, i[n]);
11
+ return p;
12
+ }, w = (p, i) => te(p, se(i));
13
+ var l = (p, i, n) => (S(p, typeof i != "symbol" ? i + "" : i, n), n);
14
+ var k = (p, i, n) => new Promise((g, f) => {
15
+ var c = (h) => {
16
16
  try {
17
- u(n.next(h));
18
- } catch (l) {
19
- c(l);
17
+ C(n.next(h));
18
+ } catch (d) {
19
+ f(d);
20
20
  }
21
- }, g = (h) => {
21
+ }, u = (h) => {
22
22
  try {
23
- u(n.throw(h));
24
- } catch (l) {
25
- c(l);
23
+ C(n.throw(h));
24
+ } catch (d) {
25
+ f(d);
26
26
  }
27
- }, u = (h) => h.done ? e(h.value) : Promise.resolve(h.value).then(d, g);
28
- u((n = n.apply(m, s)).next());
27
+ }, C = (h) => h.done ? g(h.value) : Promise.resolve(h.value).then(c, u);
28
+ C((n = n.apply(p, i)).next());
29
29
  });
30
- import { jsx as A } from "react/jsx-runtime";
31
- import O from "react";
32
- import v from "lodash/merge";
33
- import H from "react-dom";
34
- import $ from "./AgentClientUI.mjs";
35
- import { notification as E } from "antd";
36
- import K from "axios";
37
- import { v4 as J } from "uuid";
38
- import Q from "./packages/agent-cli-ui/package.json.mjs";
39
- import { defaultUIConfig as N, defaultApiUrl as G, defaultDovViewerUrl as X } from "./constant.mjs";
40
- import { ApiUrl as Y } from "./types.mjs";
41
- /* empty css */import { BotClientApi as Z, ApplicationTypes as R } from "@glodon-aiot/apis";
42
- import { JWT as q, isExpired as ee } from "./utils/index.mjs";
43
- import { configuration as ie, configure as T, BotClient as te } from "@glodon-aiot/bot-client-sdk";
44
- import se from "./ReactTextGenerationUI/index.mjs";
45
- const M = {};
46
- class we {
47
- constructor(s) {
48
- f(this, "_token");
49
- f(this, "_activeSession", null);
50
- f(this, "_applicationId");
51
- f(this, "_defaultInputText", "");
52
- f(this, "_inputDisabled", !1);
53
- f(this, "_defatulSessionId", "");
54
- f(this, "_agentClientRef", O.createRef());
55
- f(this, "_config");
56
- f(this, "_uuid", "");
57
- f(this, "apiUrl");
58
- f(this, "docViewerUrl");
59
- f(this, "env", "prod");
60
- f(this, "stream", ie.stream);
61
- f(this, "service");
62
- f(this, "rId", 0);
63
- f(this, "_mode", "float");
64
- f(this, "uiConfig", N);
65
- f(this, "errorHandlers", {});
66
- f(this, "wrapper", document.createElement("div"));
67
- f(this, "botClient", null);
68
- var _, w, y, I, S;
69
- this._uuid = J();
30
+ import { jsx as U, Fragment as re } from "react/jsx-runtime";
31
+ import ae from "react";
32
+ import b from "lodash/merge";
33
+ import x from "react-dom";
34
+ import he from "./AgentClientUI.mjs";
35
+ import { notification as B } from "antd";
36
+ import ge from "axios";
37
+ import le from "./packages/agent-cli-ui/package.json.mjs";
38
+ import { defaultUIConfig as fe, defaultApiUrl as de, defaultDovViewerUrl as ue } from "./constant.mjs";
39
+ import { ApiUrl as ce } from "./types.mjs";
40
+ /* empty css */import { BotClientApi as pe, ApplicationTypes as q } from "@glodon-aiot/apis";
41
+ import { JWT as me, isExpired as Ce } from "./utils/index.mjs";
42
+ import { configuration as be, configure as ee, BotClient as ve } from "@glodon-aiot/bot-client-sdk";
43
+ import we from "./ReactTextGenerationUI/index.mjs";
44
+ const I = {};
45
+ class Ne {
46
+ constructor(i) {
47
+ l(this, "_token");
48
+ l(this, "_activeSession", null);
49
+ l(this, "_applicationId");
50
+ l(this, "_defaultInputText", "");
51
+ l(this, "_inputDisabled", !1);
52
+ l(this, "_defatulSessionId", "");
53
+ l(this, "_agentClientRef", ae.createRef());
54
+ l(this, "apiUrl");
55
+ l(this, "docViewerUrl");
56
+ l(this, "env", "prod");
57
+ l(this, "stream", be.stream);
58
+ l(this, "service");
59
+ l(this, "rId", 0);
60
+ l(this, "_mode", "float");
61
+ l(this, "uiConfig", fe);
62
+ l(this, "errorHandlers", {});
63
+ l(this, "wrapper", document.createElement("div"));
64
+ l(this, "botClient", null);
65
+ var H, z, M, V, E, R, A, N, T, D, j, F, P, W, $, O, J, K, Q, G, X, Y;
70
66
  const {
71
67
  env: n,
72
- token: e,
73
- mode: c = "float",
74
- triggerButton: d,
75
- size: g,
76
- apiUrl: u,
68
+ token: g,
69
+ mode: f = "float",
70
+ triggerButton: c,
71
+ size: u,
72
+ apiUrl: C,
77
73
  docViewerUrl: h,
78
- errorHandlers: l,
79
- features: t,
80
- sessionId: i,
81
- icon: o,
82
- logo: r,
83
- stream: p
84
- } = s;
85
- this._config = s, this.uiConfig.icon = o || this.uiConfig.icon, this.uiConfig.logo = r || this.uiConfig.logo, (t == null ? void 0 : t.greeting) !== void 0 && (typeof t.greeting == "object" ? this.uiConfig.features = C(a({}, this.uiConfig.features), {
86
- greeting: a(a({}, typeof ((_ = this.uiConfig.features) == null ? void 0 : _.greeting) != "object" ? {} : (w = this.uiConfig.features) == null ? void 0 : w.greeting), t.greeting)
87
- }) : this.uiConfig.features = C(a({}, this.uiConfig.features), {
88
- greeting: t.greeting
89
- })), this._token = e, this.rId = 0, this._defatulSessionId = i, this.errorHandlers = a(a({}, this.errorHandlers), l), (S = (I = (y = t == null ? void 0 : t.botMessageBox) == null ? void 0 : y.footer) == null ? void 0 : I.items) == null || S.find((U) => U.componentName === "Copy");
90
- const b = {};
91
- s.header !== void 0 && (b.showHeader = !!s.header);
92
- const k = {
93
- triggerButton: v(this.uiConfig.triggerButton, d),
94
- size: v(this.uiConfig.size, a({}, g)),
95
- theme: v(this.uiConfig.theme, M)
96
- };
97
- this.updateUIConfig(k, b), this.env = n || "prod", this.stream = p, T({
98
- stream: this.stream
99
- }), this._applicationId = q(e).rid, this.apiUrl = u || Y[this.env] || G, this.docViewerUrl = h || X, this.service = this.setService(), this._initWrapper(), this.createBotClientSDK().then(() => {
100
- this.mode = c;
101
- });
102
- }
103
- updateUIConfig(s, n) {
104
- var u, h, l, t, i, o, r, p, b, k, _, w, y, I, S, U, V;
105
- let e = this._config.features;
106
- const c = {
107
- sessionOpen: this._mode === "float",
108
- sessionList: this._mode === "float"
109
- }, d = (l = (h = (u = e == null ? void 0 : e.botMessageBox) == null ? void 0 : u.footer) == null ? void 0 : h.items) == null ? void 0 : l.find((x) => x.componentName === "AnswerAgain"), g = {
74
+ errorHandlers: d,
75
+ features: e,
76
+ sessionId: o,
77
+ icon: t,
78
+ logo: s,
79
+ stream: a
80
+ } = i;
81
+ this.uiConfig.icon = t || this.uiConfig.icon, this.uiConfig.logo = s || this.uiConfig.logo, (e == null ? void 0 : e.greeting) !== void 0 && (typeof e.greeting == "object" ? this.uiConfig.features = w(r({}, this.uiConfig.features), {
82
+ greeting: r(r({}, typeof ((H = this.uiConfig.features) == null ? void 0 : H.greeting) != "object" ? {} : (z = this.uiConfig.features) == null ? void 0 : z.greeting), e.greeting)
83
+ }) : this.uiConfig.features = w(r({}, this.uiConfig.features), {
84
+ greeting: e.greeting
85
+ })), this._token = g, this.rId = 0, this._defatulSessionId = o, this.errorHandlers = r(r({}, this.errorHandlers), d);
86
+ const m = {
87
+ sessionOpen: f === "float",
88
+ sessionList: f === "float"
89
+ }, L = (E = (V = (M = e == null ? void 0 : e.botMessageBox) == null ? void 0 : M.footer) == null ? void 0 : V.items) == null ? void 0 : E.find((v) => v.componentName === "AnswerAgain");
90
+ (N = (A = (R = e == null ? void 0 : e.botMessageBox) == null ? void 0 : R.footer) == null ? void 0 : A.items) == null || N.find((v) => v.componentName === "Copy");
91
+ const y = {
110
92
  sessionList: e == null ? void 0 : e.sessionList,
111
93
  sessionOpen: e == null ? void 0 : e.newSession,
112
94
  fileUpload: e == null ? void 0 : e.fileUpload,
113
- userCopy: (t = e == null ? void 0 : e.userMessageBox) == null ? void 0 : t.copy,
114
- userEdit: (i = e == null ? void 0 : e.userMessageBox) == null ? void 0 : i.editAgain,
95
+ userCopy: (T = e == null ? void 0 : e.userMessageBox) == null ? void 0 : T.copy,
96
+ userEdit: (D = e == null ? void 0 : e.userMessageBox) == null ? void 0 : D.editAgain,
115
97
  userPrompt: e == null ? void 0 : e.fileUpload,
116
98
  prompt: e == null ? void 0 : e.prompts,
117
- relate: (o = e == null ? void 0 : e.botMessageBox) == null ? void 0 : o.relatedQuesions,
118
- again: !(d && d.visible === !1),
99
+ relate: (j = e == null ? void 0 : e.botMessageBox) == null ? void 0 : j.relatedQuesions,
100
+ again: !(L && L.visible === !1),
119
101
  reference: {
120
- iconVisible: (p = (r = e == null ? void 0 : e.botMessageBox) == null ? void 0 : r.reference) == null ? void 0 : p.file,
121
- referenceFirst: (b = e == null ? void 0 : e.botMessageBox) == null ? void 0 : b.referenceFirst,
122
- isExpand: (_ = (k = e == null ? void 0 : e.botMessageBox) == null ? void 0 : k.reference) == null ? void 0 : _.itemExpanded
102
+ iconVisible: (P = (F = e == null ? void 0 : e.botMessageBox) == null ? void 0 : F.reference) == null ? void 0 : P.file,
103
+ referenceFirst: (W = e == null ? void 0 : e.botMessageBox) == null ? void 0 : W.referenceFirst,
104
+ isExpand: (O = ($ = e == null ? void 0 : e.botMessageBox) == null ? void 0 : $.reference) == null ? void 0 : O.itemExpanded
123
105
  },
124
- searchReference: (w = e == null ? void 0 : e.botMessageBox) == null ? void 0 : w.searchReference,
106
+ searchReference: (J = e == null ? void 0 : e.botMessageBox) == null ? void 0 : J.searchReference,
125
107
  knowledges: !!(e != null && e.knowledges),
126
108
  metadata: e == null ? void 0 : e.metadata,
127
109
  greet: (e == null ? void 0 : e.greeting) !== !1,
128
110
  imageUpload: e == null ? void 0 : e.imageUpload,
129
- promptVariables: (e == null ? void 0 : e.promptVariables) === void 0 ? (y = this.uiConfig.transform) == null ? void 0 : y.promptVariables : (e == null ? void 0 : e.promptVariables) === !0 || typeof (e == null ? void 0 : e.promptVariables) == "object" && ((I = e == null ? void 0 : e.promptVariables) == null ? void 0 : I.visible) !== !1 ? (S = this.uiConfig.transform) == null ? void 0 : S.promptVariables : !1,
130
- connectNetwork: (e == null ? void 0 : e.connectNetwork) === void 0 ? (U = this.uiConfig.transform) == null ? void 0 : U.connectNetwork : (e == null ? void 0 : e.connectNetwork) === !0 || (typeof (e == null ? void 0 : e.connectNetwork) == "object" && typeof (e == null ? void 0 : e.connectNetwork.visible) == "boolean" ? e == null ? void 0 : e.connectNetwork.visible : (V = this.uiConfig.transform) == null ? void 0 : V.connectNetwork)
111
+ promptVariables: (e == null ? void 0 : e.promptVariables) === void 0 ? (K = this.uiConfig.transform) == null ? void 0 : K.promptVariables : (e == null ? void 0 : e.promptVariables) === !0 || typeof (e == null ? void 0 : e.promptVariables) == "object" && ((Q = e == null ? void 0 : e.promptVariables) == null ? void 0 : Q.visible) !== !1 ? (G = this.uiConfig.transform) == null ? void 0 : G.promptVariables : !1,
112
+ connectNetwork: (e == null ? void 0 : e.connectNetwork) === void 0 ? (X = this.uiConfig.transform) == null ? void 0 : X.connectNetwork : (e == null ? void 0 : e.connectNetwork) === !0 || (typeof (e == null ? void 0 : e.connectNetwork) == "object" && typeof (e == null ? void 0 : e.connectNetwork.visible) == "boolean" ? e == null ? void 0 : e.connectNetwork.visible : (Y = this.uiConfig.transform) == null ? void 0 : Y.connectNetwork)
113
+ }, _ = {
114
+ sider: f === "inlay"
131
115
  };
132
- Object.keys(g).forEach((x) => {
133
- g[x] === void 0 && delete g[x];
134
- }), this.uiConfig = C(a(a(a(a(a({}, this.uiConfig), n), this._config), s), g), {
135
- transform: a(a(a(a({}, this.uiConfig.transform), c), this._config.transform), g)
116
+ if (i.header !== void 0 && (_.showHeader = !!i.header), i.sider !== void 0 && (_.sider = !!i.sider), Object.keys(y).forEach((v) => {
117
+ y[v] === void 0 && delete y[v];
118
+ }), f === "inlay") {
119
+ const v = {
120
+ triggerButton: b({
121
+ visible: !1
122
+ }, c),
123
+ open: !0,
124
+ resizable: !1,
125
+ size: b({
126
+ width: "100%",
127
+ height: "100%",
128
+ maxWidth: "100%",
129
+ maxHeight: "100%",
130
+ minWidth: "100%"
131
+ }, u),
132
+ theme: b(this.uiConfig.theme, I),
133
+ history: !0
134
+ };
135
+ this.uiConfig = w(r(r(r(r({}, this.uiConfig), i), v), _), {
136
+ transform: r(r(r(r({}, this.uiConfig.transform), m), i.transform), y)
137
+ }), this.wrapper = this.uiConfig.getContainer();
138
+ } else {
139
+ const v = {
140
+ triggerButton: b(this.uiConfig.triggerButton, c),
141
+ size: b(this.uiConfig.size, r({}, u)),
142
+ theme: b(this.uiConfig.theme, I)
143
+ };
144
+ this.uiConfig = w(r(r(r(r(r({}, this.uiConfig), i), v), _), y), {
145
+ transform: r(r(r(r({}, this.uiConfig.transform), m), i.transform), y)
146
+ }), this.uiConfig.getContainer().append(this.wrapper);
147
+ }
148
+ this._mode = f, this.env = n || "prod", this.stream = a, ee({
149
+ stream: this.stream
150
+ }), this._applicationId = me(g).rid, this.apiUrl = C || ce[this.env] || de, this.docViewerUrl = h || ue, this.service = this.setService(), this.createBotClientSDK().then(() => {
151
+ this.render();
136
152
  });
137
153
  }
138
- _initWrapper() {
139
- this.wrapper.id === this._uuid && this.wrapper.isConnected || (this.wrapper = document.createElement("div"), this.wrapper.style.height = "100%", this.wrapper.style.width = "100%", this.wrapper.id = this._uuid, this.uiConfig.getContainer().appendChild(this.wrapper));
140
- }
141
154
  get token() {
142
155
  return this._token;
143
156
  }
144
- set token(s) {
145
- this._token = s, this.reload();
157
+ set token(i) {
158
+ this._token = i, this.reload();
146
159
  }
147
160
  get mode() {
148
161
  return this._mode;
149
162
  }
150
- set mode(s) {
151
- var e;
152
- this._mode = s, this._defatulSessionId = (e = this.activeSession) == null ? void 0 : e.id;
153
- const n = {
154
- sider: s === "inlay"
155
- };
156
- if (s === "inlay") {
157
- const c = {
158
- triggerButton: v({
163
+ set mode(i) {
164
+ if (i === "inlay") {
165
+ const n = {
166
+ triggerButton: b({
159
167
  visible: !1
160
168
  }, this.uiConfig.triggerButton),
161
169
  open: !0,
162
170
  resizable: !1,
163
- size: v({
171
+ size: b({
164
172
  width: "100%",
165
173
  height: "100%",
166
174
  maxWidth: "100%",
167
175
  maxHeight: "100%",
168
176
  minWidth: "100%"
169
- }, this._config.size),
170
- theme: v(this.uiConfig.theme, M),
177
+ }, this.uiConfig.size),
178
+ theme: b(this.uiConfig.theme, I),
171
179
  history: !0
172
180
  };
173
- this.updateUIConfig(c, n);
181
+ this.uiConfig = r(r({}, this.uiConfig), n), this.wrapper = this.uiConfig.getContainer();
174
182
  } else {
175
- const c = {
176
- size: a(a(a({}, this.uiConfig.size), N.size), this._config.size),
177
- theme: v(this.uiConfig.theme, M)
183
+ const n = {
184
+ triggerButton: b(this.uiConfig.triggerButton, this.uiConfig.triggerButton),
185
+ size: b(this.uiConfig.size, r({}, this.uiConfig.size)),
186
+ theme: b(this.uiConfig.theme, I)
178
187
  };
179
- this.updateUIConfig(c, n);
188
+ this.uiConfig = r(r({}, this.uiConfig), n), this._mode === "inlay" && this.wrapper.remove(), this.uiConfig.getContainer().append(this.wrapper);
180
189
  }
181
- this.render();
190
+ this._mode = i, this.render();
182
191
  }
183
192
  get activeSession() {
184
193
  return this._activeSession;
@@ -187,74 +196,72 @@ class we {
187
196
  return this._applicationId;
188
197
  }
189
198
  setService() {
190
- const s = this.apiUrl, n = (h) => {
191
- var t;
192
- const l = this.token;
193
- if (!l)
199
+ const i = this.apiUrl, n = (h) => {
200
+ var e;
201
+ const d = this.token;
202
+ if (!d)
194
203
  return h;
195
- if (ee(l)) {
196
- const i = "token is timeout";
204
+ if (Ce(d)) {
205
+ const o = "token is timeout";
197
206
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
198
207
  // @ts-ignore
199
- new Error(i, {
208
+ new Error(o, {
200
209
  cause: {
201
210
  status: 401,
202
- message: i
211
+ message: o
203
212
  }
204
213
  })
205
- ) : console.error("errorHandlers.token is not a function") : console.error(i);
214
+ ) : console.error("errorHandlers.token is not a function") : console.error(o);
206
215
  }
207
- return h.headers = (t = h.headers) != null ? t : {}, h.headers = C(a({}, h.headers), {
208
- Authorization: l ? `Bearer ${l}` : ""
216
+ return h.headers = (e = h.headers) != null ? e : {}, h.headers = w(r({}, h.headers), {
217
+ Authorization: d ? `Bearer ${d}` : ""
209
218
  }), h;
210
219
  };
211
- function e(h, l = !0) {
212
- const t = `${s}${h}`, i = K.create({
213
- baseURL: t
220
+ function g(h, d = !0) {
221
+ const e = `${i}${h}`, o = ge.create({
222
+ baseURL: e
214
223
  });
215
- return l && i.interceptors.request.use(n), i;
224
+ return d && o.interceptors.request.use(n), o;
216
225
  }
217
- const c = (h, l) => {
226
+ const f = (h, d) => {
218
227
  if (h === 401) {
219
- const t = "token is invalid";
228
+ const e = "token is invalid";
220
229
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
221
230
  // @ts-ignore
222
- new Error(t, {
231
+ new Error(e, {
223
232
  cause: {
224
233
  status: 401,
225
- message: t
234
+ message: e
226
235
  }
227
236
  })
228
- ) : console.error("errorHandlers.token is not a function") : console.error(t);
237
+ ) : console.error("errorHandlers.token is not a function") : console.error(e);
229
238
  }
230
- }, d = (h, l, t) => {
231
- h !== 10001 && h !== 10215 && (t || (E.config({
239
+ }, c = (h, d, e) => {
240
+ h !== 10001 && h !== 10215 && (e || (B.config({
232
241
  getContainer: this.uiConfig.getContainer
233
- }), E.error({
234
- message: l
235
- }), E.config({
242
+ }), B.error({
243
+ message: d
244
+ }), B.config({
236
245
  getContainer: void 0
237
246
  })));
238
- }, g = e("");
239
- return new Z(g, () => this.token, {
240
- onHttpStatusError: c,
241
- onAppStatusError: d
247
+ }, u = g("");
248
+ return new pe(u, () => this.token, {
249
+ onHttpStatusError: f,
250
+ onAppStatusError: c
242
251
  });
243
252
  }
244
253
  reload() {
245
- var s;
246
- this._defatulSessionId = (s = this.activeSession) == null ? void 0 : s.id, this.destroy(() => {
247
- this.service = this.setService(), this.rId = this.rId + 1, this._initWrapper(), this.createBotClientSDK().then(() => {
248
- this.render();
249
- });
254
+ var i;
255
+ this._defatulSessionId = (i = this.activeSession) == null ? void 0 : i.id, this.destroy(() => {
256
+ this.service = this.setService(), this.rId = this.rId + 1, this.render();
250
257
  });
251
258
  }
252
- getMessageList(s) {
253
- var n, e;
254
- return s || (s = (n = this.activeSession) == null ? void 0 : n.id), !this.applicationId || !s ? Promise.resolve([]) : (e = this.service) == null ? void 0 : e.getChatHistorySessionId(this.applicationId, s);
259
+ getMessageList(i) {
260
+ var n, g;
261
+ return i || (i = (n = this.activeSession) == null ? void 0 : n.id), !this.applicationId || !i ? Promise.resolve([]) : (g = this.service) == null ? void 0 : g.getChatHistorySessionId(this.applicationId, i);
255
262
  }
256
- input(s) {
257
- this._defaultInputText = s, this.render();
263
+ input(i) {
264
+ this._defaultInputText = i, this.render();
258
265
  }
259
266
  disable() {
260
267
  this._inputDisabled = !0, this.render();
@@ -263,36 +270,36 @@ class we {
263
270
  this._inputDisabled = !1, this.render();
264
271
  }
265
272
  getSessionList() {
266
- return this._agentClientRef.current ? new Promise((n, e) => {
267
- var c, d;
268
- (d = (c = this._agentClientRef.current) == null ? void 0 : c.getSessionList()) == null || d.then((g) => {
269
- n(g);
270
- }).catch((g) => {
271
- e(g);
273
+ return this._agentClientRef.current ? new Promise((n, g) => {
274
+ var f, c;
275
+ (c = (f = this._agentClientRef.current) == null ? void 0 : f.getSessionList()) == null || c.then((u) => {
276
+ n(u);
277
+ }).catch((u) => {
278
+ g(u);
272
279
  });
273
280
  }) : Promise.reject(new Error("client is not loaded"));
274
281
  }
275
- createSession(s) {
276
- return this._agentClientRef.current ? new Promise((e, c) => {
277
- var d, g;
278
- (g = (d = this._agentClientRef.current) == null ? void 0 : d.createSession(a({
282
+ sessionCreate(i) {
283
+ return this._agentClientRef.current ? new Promise((g, f) => {
284
+ var c, u;
285
+ (u = (c = this._agentClientRef.current) == null ? void 0 : c.sessionCreate(r({
279
286
  name: "新建会话"
280
- }, s))) == null || g.then((u) => {
281
- e(u);
282
- }).catch((u) => {
283
- c(u);
287
+ }, i))) == null || u.then((C) => {
288
+ g(C);
289
+ }).catch((C) => {
290
+ f(C);
284
291
  });
285
292
  }) : Promise.reject(new Error("client is not loaded"));
286
293
  }
287
294
  createBotClientSDK() {
288
- return B(this, null, function* () {
289
- return new Promise((s, n) => {
295
+ return k(this, null, function* () {
296
+ return new Promise((i, n) => {
290
297
  if (this.token)
291
- T({
298
+ ee({
292
299
  debug: this.uiConfig.debug,
293
300
  env: this.uiConfig.env,
294
301
  apiRoot: this.apiUrl
295
- }), this.botClient = new te(this.token, {
302
+ }), this.botClient = new ve(this.token, {
296
303
  plugins: this.uiConfig.plugins,
297
304
  mcp: this.uiConfig.mcp,
298
305
  stream: this.uiConfig.stream
@@ -303,11 +310,11 @@ class we {
303
310
  // 这里记录应用的名称和版本,以便后期数据分析
304
311
  ui: {
305
312
  name: "bot-client-ui",
306
- version: Q.version
313
+ version: le.version
307
314
  }
308
- }), this.botClient.ready ? s(this.botClient) : this.botClient.addEventListener("ready", () => B(this, null, function* () {
309
- var e;
310
- this.botClient ? (((e = this.botClient.application) == null ? void 0 : e.type) === R.Text && (this.mode = "inlay"), s(this.botClient)) : n(this.botClient);
315
+ }), this.botClient.ready ? i(this.botClient) : this.botClient.addEventListener("ready", () => k(this, null, function* () {
316
+ var g;
317
+ this.botClient ? (((g = this.botClient.application) == null ? void 0 : g.type) === q.Text && (this.mode = "inlay"), i(this.botClient)) : n(this.botClient);
311
318
  }), !0);
312
319
  else
313
320
  throw Error("token is required");
@@ -315,11 +322,12 @@ class we {
315
322
  });
316
323
  }
317
324
  render() {
318
- return B(this, null, function* () {
319
- var s, n, e, c, d, g, u, h, l;
320
- if (this.wrapper.style.height = "100%", !((s = this.botClient) != null && s.application))
325
+ return k(this, null, function* () {
326
+ var n, g, f, c, u, C, h, d, e;
327
+ let i = this.wrapper.getBoundingClientRect().height;
328
+ if (this.wrapper.style.height = `${i}px`, !((n = this.botClient) != null && n.application))
321
329
  throw Error("application is required");
322
- this.botClient.application.type === R.Text ? H.render(/* @__PURE__ */ A(se, {
330
+ this.botClient.application.type === q.Text ? x.render(/* @__PURE__ */ U(we, {
323
331
  rId: this.rId,
324
332
  application: this.botClient.application,
325
333
  sessionId: this._defatulSessionId,
@@ -336,7 +344,7 @@ class we {
336
344
  theme: this.uiConfig.theme,
337
345
  greeting: this.uiConfig.greeting,
338
346
  size: this.uiConfig.size,
339
- triggerButton: a({
347
+ triggerButton: r({
340
348
  visible: !0
341
349
  }, this.uiConfig.triggerButton),
342
350
  history: this.uiConfig.history,
@@ -344,70 +352,70 @@ class we {
344
352
  docViewerUrl: this.docViewerUrl,
345
353
  plugins: this.uiConfig.plugins,
346
354
  mcp: this.uiConfig.mcp,
347
- transform: C(a({}, this.uiConfig.transform), {
348
- knowledges: ((n = this.uiConfig.features) == null ? void 0 : n.knowledges) === !0 || typeof ((e = this.uiConfig.features) == null ? void 0 : e.knowledges) == "object" && ((d = (c = this.uiConfig.features) == null ? void 0 : c.knowledges) == null ? void 0 : d.visible) !== !1
355
+ transform: w(r({}, this.uiConfig.transform), {
356
+ knowledges: ((g = this.uiConfig.features) == null ? void 0 : g.knowledges) === !0 || typeof ((f = this.uiConfig.features) == null ? void 0 : f.knowledges) == "object" && ((u = (c = this.uiConfig.features) == null ? void 0 : c.knowledges) == null ? void 0 : u.visible) !== !1
349
357
  }),
350
358
  features: this.uiConfig.features,
351
359
  disabled: this._inputDisabled,
352
360
  sider: this.uiConfig.sider,
353
361
  footer: this.uiConfig.footer,
354
- onComment: (t) => {
355
- var i, o;
362
+ onComment: (o) => {
363
+ var t, s;
356
364
  try {
357
- (o = (i = this.uiConfig.eventListeners) == null ? void 0 : i.comment) == null || o.call(i, t);
358
- } catch (r) {
359
- console.error(r);
365
+ (s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.comment) == null || s.call(t, o);
366
+ } catch (a) {
367
+ console.error(a);
360
368
  }
361
369
  },
362
370
  agentClient: this.botClient,
363
- onMessage: (t) => {
364
- var i, o;
365
- if (t.message.messageId)
371
+ onMessage: (o) => {
372
+ var t, s;
373
+ if (o.message.messageId)
366
374
  try {
367
- (o = (i = this.uiConfig.eventListeners) == null ? void 0 : i.message) == null || o.call(i, t);
368
- } catch (r) {
369
- console.error(r);
375
+ (s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.message) == null || s.call(t, o);
376
+ } catch (a) {
377
+ console.error(a);
370
378
  }
371
379
  },
372
- beforeMessageSend: (t) => {
373
- var i, o, r;
374
- if (!((i = this.uiConfig.eventListeners) != null && i.beforemessagesend))
380
+ beforeMessageSend: (o) => {
381
+ var t, s, a;
382
+ if (!((t = this.uiConfig.eventListeners) != null && t.beforemessagesend))
375
383
  return !0;
376
384
  try {
377
- return ((r = (o = this.uiConfig.eventListeners) == null ? void 0 : o.beforemessagesend) == null ? void 0 : r.call(o, t)) || !1;
378
- } catch (p) {
379
- return console.error(p), !1;
385
+ return ((a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : a.call(s, o)) || !1;
386
+ } catch (m) {
387
+ return console.error(m), !1;
380
388
  }
381
389
  },
382
- onSessionUnload: (t) => {
383
- var i, o;
390
+ onSessionUnload: (o) => {
391
+ var t, s;
384
392
  this._activeSession = null;
385
393
  try {
386
- (o = (i = this.uiConfig.eventListeners) == null ? void 0 : i.sessionunload) == null || o.call(i, t);
387
- } catch (r) {
388
- console.error(r);
394
+ (s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.sessionunload) == null || s.call(t, o);
395
+ } catch (a) {
396
+ console.error(a);
389
397
  }
390
398
  },
391
- onSessionLoad: (t) => {
392
- var i, o, r;
393
- if (((i = this._activeSession) == null ? void 0 : i.id) === t.sessionId)
394
- this._activeSession = t.session;
399
+ onSessionLoad: (o) => {
400
+ var t, s, a;
401
+ if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
402
+ this._activeSession = o.session;
395
403
  else {
396
- this._activeSession = t.session;
404
+ this._activeSession = o.session;
397
405
  try {
398
- (r = (o = this.uiConfig.eventListeners) == null ? void 0 : o.sessionload) == null || r.call(o, t);
399
- } catch (p) {
400
- console.error(p);
406
+ (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || a.call(s, o);
407
+ } catch (m) {
408
+ console.error(m);
401
409
  }
402
410
  }
403
411
  },
404
- onHistoryLoad: (t) => {
405
- var i, o, r;
406
- if (((i = this._activeSession) == null ? void 0 : i.id) === t.sessionId)
412
+ onHistoryLoad: (o) => {
413
+ var t, s, a;
414
+ if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
407
415
  try {
408
- (r = (o = this.uiConfig.eventListeners) == null ? void 0 : o.historyload) == null || r.call(o, t);
409
- } catch (p) {
410
- console.error(p);
416
+ (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || a.call(s, o);
417
+ } catch (m) {
418
+ console.error(m);
411
419
  }
412
420
  },
413
421
  defaultInput: this._defaultInputText !== void 0 ? {
@@ -415,7 +423,7 @@ class we {
415
423
  } : void 0,
416
424
  bodyStyle: this.uiConfig.bodyStyle,
417
425
  stream: this.stream
418
- }), this.wrapper) : H.render(/* @__PURE__ */ A($, {
426
+ }), this.wrapper) : x.render(/* @__PURE__ */ U(he, {
419
427
  ref: this._agentClientRef,
420
428
  rId: this.rId,
421
429
  application: this.botClient.application,
@@ -434,7 +442,7 @@ class we {
434
442
  theme: this.uiConfig.theme,
435
443
  greeting: this.uiConfig.greeting,
436
444
  size: this.uiConfig.size,
437
- triggerButton: a({
445
+ triggerButton: r({
438
446
  visible: !0
439
447
  }, this.uiConfig.triggerButton),
440
448
  history: this.uiConfig.history,
@@ -442,69 +450,69 @@ class we {
442
450
  docViewerUrl: this.docViewerUrl,
443
451
  plugins: this.uiConfig.plugins,
444
452
  mcp: this.uiConfig.mcp,
445
- transform: C(a({}, this.uiConfig.transform), {
446
- knowledges: ((g = this.uiConfig.features) == null ? void 0 : g.knowledges) === !0 || typeof ((u = this.uiConfig.features) == null ? void 0 : u.knowledges) == "object" && ((l = (h = this.uiConfig.features) == null ? void 0 : h.knowledges) == null ? void 0 : l.visible) !== !1
453
+ transform: w(r({}, this.uiConfig.transform), {
454
+ knowledges: ((C = this.uiConfig.features) == null ? void 0 : C.knowledges) === !0 || typeof ((h = this.uiConfig.features) == null ? void 0 : h.knowledges) == "object" && ((e = (d = this.uiConfig.features) == null ? void 0 : d.knowledges) == null ? void 0 : e.visible) !== !1
447
455
  }),
448
456
  features: this.uiConfig.features,
449
457
  disabled: this._inputDisabled,
450
458
  sider: this.uiConfig.sider,
451
459
  footer: this.uiConfig.footer,
452
- onComment: (t) => {
453
- var i, o;
460
+ onComment: (o) => {
461
+ var t, s;
454
462
  try {
455
- (o = (i = this.uiConfig.eventListeners) == null ? void 0 : i.comment) == null || o.call(i, t);
456
- } catch (r) {
457
- console.error(r);
463
+ (s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.comment) == null || s.call(t, o);
464
+ } catch (a) {
465
+ console.error(a);
458
466
  }
459
467
  },
460
- onMessage: (t) => {
461
- var i, o;
462
- if (t.message.messageId)
468
+ onMessage: (o) => {
469
+ var t, s;
470
+ if (o.message.messageId)
463
471
  try {
464
- (o = (i = this.uiConfig.eventListeners) == null ? void 0 : i.message) == null || o.call(i, t);
465
- } catch (r) {
466
- console.error(r);
472
+ (s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.message) == null || s.call(t, o);
473
+ } catch (a) {
474
+ console.error(a);
467
475
  }
468
476
  },
469
- beforeMessageSend: (t) => {
470
- var i, o, r;
471
- if (!((i = this.uiConfig.eventListeners) != null && i.beforemessagesend))
477
+ beforeMessageSend: (o) => {
478
+ var t, s, a;
479
+ if (!((t = this.uiConfig.eventListeners) != null && t.beforemessagesend))
472
480
  return !0;
473
481
  try {
474
- return ((r = (o = this.uiConfig.eventListeners) == null ? void 0 : o.beforemessagesend) == null ? void 0 : r.call(o, t)) || !1;
475
- } catch (p) {
476
- return console.error(p), !1;
482
+ return ((a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : a.call(s, o)) || !1;
483
+ } catch (m) {
484
+ return console.error(m), !1;
477
485
  }
478
486
  },
479
- onSessionUnload: (t) => {
480
- var i, o;
487
+ onSessionUnload: (o) => {
488
+ var t, s;
481
489
  this._activeSession = null;
482
490
  try {
483
- (o = (i = this.uiConfig.eventListeners) == null ? void 0 : i.sessionunload) == null || o.call(i, t);
484
- } catch (r) {
485
- console.error(r);
491
+ (s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.sessionunload) == null || s.call(t, o);
492
+ } catch (a) {
493
+ console.error(a);
486
494
  }
487
495
  },
488
- onSessionLoad: (t) => {
489
- var i, o, r;
490
- if (((i = this._activeSession) == null ? void 0 : i.id) === t.sessionId)
491
- this._activeSession = t.session;
496
+ onSessionLoad: (o) => {
497
+ var t, s, a;
498
+ if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
499
+ this._activeSession = o.session;
492
500
  else {
493
- this._activeSession = t.session;
501
+ this._activeSession = o.session;
494
502
  try {
495
- (r = (o = this.uiConfig.eventListeners) == null ? void 0 : o.sessionload) == null || r.call(o, t);
496
- } catch (p) {
497
- console.error(p);
503
+ (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || a.call(s, o);
504
+ } catch (m) {
505
+ console.error(m);
498
506
  }
499
507
  }
500
508
  },
501
- onHistoryLoad: (t) => {
502
- var i, o, r;
503
- if (((i = this._activeSession) == null ? void 0 : i.id) === t.sessionId)
509
+ onHistoryLoad: (o) => {
510
+ var t, s, a;
511
+ if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
504
512
  try {
505
- (r = (o = this.uiConfig.eventListeners) == null ? void 0 : o.historyload) == null || r.call(o, t);
506
- } catch (p) {
507
- console.error(p);
513
+ (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || a.call(s, o);
514
+ } catch (m) {
515
+ console.error(m);
508
516
  }
509
517
  },
510
518
  defaultInput: this._defaultInputText !== void 0 ? {
@@ -515,10 +523,10 @@ class we {
515
523
  }), this.wrapper), this._defaultInputText = "";
516
524
  });
517
525
  }
518
- destroy(s) {
519
- H.unmountComponentAtNode(this.wrapper), this.wrapper && this.wrapper.remove(), s == null || s();
526
+ destroy(i) {
527
+ x.render(/* @__PURE__ */ U(re, {}), this.wrapper, i);
520
528
  }
521
529
  }
522
530
  export {
523
- we as default
531
+ Ne as default
524
532
  };