@glodon-aiot/agent-cli-ui 3.3.5-alpha.28 → 3.3.5-beta.30

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.
@@ -27,7 +27,7 @@ var p = (n, d, l) => new Promise((u, v) => {
27
27
  x((l = l.apply(n, d)).next());
28
28
  });
29
29
  import { jsxs as w, jsx as o, Fragment as ve } from "react/jsx-runtime";
30
- import { useState as h, useRef as Se, useContext as xe, useEffect as T } from "react";
30
+ import { useState as h, useRef as Se, useContext as xe, useEffect as N } from "react";
31
31
  import { Form as M, Collapse as _, Input as K, Button as be, message as C, notification as Pe } from "antd";
32
32
  import { PromptVariableType as y } from "@glodon-aiot/apis";
33
33
  import { v4 as pe } from "uuid";
@@ -45,7 +45,7 @@ const {
45
45
  sessionId: d,
46
46
  docViewerUrl: l
47
47
  }) => {
48
- const u = n.id, [v, q] = h(""), [S, x] = h(""), [f, b] = h(), [L, N] = h(!1), D = Se(null), [H, ee] = h([]), [A, O] = h([]), [te, Y] = h(0), [$, j] = h(), [c, R] = h(), [E] = M.useForm(), [U, re] = h({}), [B, se] = h({}), [ne, ae] = h(0), {
48
+ const u = n.id, [v, q] = h(""), [S, x] = h(""), [f, b] = h(), [L, T] = h(!1), D = Se(null), [H, ee] = h([]), [A, O] = h([]), [te, Y] = h(0), [$, j] = h(), [c, R] = h(), [E] = M.useForm(), [U, re] = h({}), [B, se] = h({}), [ne, ae] = h(0), {
49
49
  service: g,
50
50
  agentClient: I,
51
51
  popupContainer: P,
@@ -131,7 +131,7 @@ const {
131
131
  }
132
132
  });
133
133
  };
134
- T(() => {
134
+ N(() => {
135
135
  if (!(n != null && n.id))
136
136
  return;
137
137
  const e = n.arrange;
@@ -141,7 +141,7 @@ const {
141
141
  ee(i), Y(i.length);
142
142
  const t = i.map((r) => r.id);
143
143
  O(t);
144
- }, [n]), T(() => {
144
+ }, [n]), N(() => {
145
145
  if (!(n != null && n.id) || !I)
146
146
  return;
147
147
  const e = I.questionContextMaxLength || 4e3;
@@ -156,7 +156,7 @@ const {
156
156
  });
157
157
  j(e);
158
158
  });
159
- T(() => {
159
+ N(() => {
160
160
  !u || !g || Promise.all([g.getApplicationIdPromptVariables(u, {
161
161
  type: y.User,
162
162
  status: 1
@@ -173,7 +173,7 @@ const {
173
173
  }));
174
174
  R(r);
175
175
  });
176
- }, [g, u]), T(() => {
176
+ }, [g, u]), N(() => {
177
177
  if (!c)
178
178
  return;
179
179
  const e = c.filter((r) => r.type === y.User), a = c.filter((r) => r.type === y.System), i = {};
@@ -197,7 +197,7 @@ const {
197
197
  }, ue = () => p(void 0, null, function* () {
198
198
  if (!u || !g || !I)
199
199
  return;
200
- N(!0);
200
+ T(!0);
201
201
  for (const t in U)
202
202
  U[t] || (C.config({
203
203
  getContainer: () => (P == null ? void 0 : P.current) || document.body
@@ -224,8 +224,8 @@ const {
224
224
  return s.value = m[0].value, s;
225
225
  });
226
226
  yield Promise.all(r.map((s) => ie(s.id, s.value))), R(r);
227
- })).finally(() => {
228
- N(!1);
227
+ })).catch((t) => {
228
+ console.log(t), T(!1);
229
229
  });
230
230
  const i = {
231
231
  content: v,
@@ -236,21 +236,21 @@ const {
236
236
  };
237
237
  le(u, e.id, i, {
238
238
  onmessage: (t) => {
239
- N(!0), b(void 0), x(t.content);
239
+ b(void 0), x(t.content);
240
240
  },
241
241
  onclose: (t) => p(void 0, null, function* () {
242
- if (N(!1), t.code == 200) {
242
+ if (T(!1), t.code == 200) {
243
243
  x(t.content);
244
244
  const r = yield Promise.all(t.reference.map((s) => g.getKnowledgeIdFileId(s.knowledgeId, s.docId)));
245
245
  t.reference = t.reference.map((s, m) => V(V({}, s), r[m])), b(t);
246
246
  }
247
247
  }),
248
248
  onerror: () => {
249
- N(!1);
249
+ T(!1);
250
250
  }
251
251
  });
252
252
  });
253
- T(() => {
253
+ N(() => {
254
254
  if (!S)
255
255
  return;
256
256
  const e = D.current;
@@ -1,58 +1,76 @@
1
- import { jsxs as c, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as I, useState as r, useImperativeHandle as Q, useEffect as l } from "react";
3
- /* empty css */import { Space as g, Row as w, Col as N } from "antd";
4
- import q from "./tip.svg.mjs";
5
- import v from "./RecommendItem.mjs";
6
- const x = I((a, u) => {
1
+ import { jsxs as h, jsx as r } from "react/jsx-runtime";
2
+ import { forwardRef as N, useState as l, useImperativeHandle as q, useEffect as m } from "react";
3
+ /* empty css */import { Space as O, Row as b, Col as j } from "antd";
4
+ import k from "./tip.svg.mjs";
5
+ import B from "./RecommendItem.mjs";
6
+ const L = N((g, R) => {
7
7
  const {
8
- onItemClick: f,
8
+ onItemClick: v,
9
9
  data: s,
10
- isRecommendClearing: p
11
- } = a, [e, d] = r(), [h, i] = r(), [R, m] = r(!1);
12
- return Q(u, () => ({
10
+ isRecommendClearing: I,
11
+ layoutBreakpoints: a = [450]
12
+ // 默认临界值
13
+ } = g, [t, C] = l(), [x, u] = l(), [y, f] = l(!1), [z, Q] = l(2);
14
+ return q(R, () => ({
13
15
  clear() {
14
- i(void 0);
16
+ u(void 0);
15
17
  }
16
- })), l(() => {
18
+ })), m(() => {
19
+ const e = document.getElementById("dialog-modal");
20
+ if (!e)
21
+ return;
22
+ const n = (c) => {
23
+ const p = [...a].sort((d, E) => d - E), w = p.findIndex((d) => c < d);
24
+ return w === -1 ? p.length + 1 : w + 1;
25
+ }, i = () => {
26
+ const c = e.clientWidth;
27
+ Q(n(c));
28
+ };
29
+ i();
30
+ let o = null;
31
+ return window.ResizeObserver ? (o = new ResizeObserver(i), o.observe(e)) : window.addEventListener("resize", i), () => {
32
+ o == null || o.disconnect(), window.removeEventListener("resize", i);
33
+ };
34
+ }, [a]), m(() => {
17
35
  if (s != null && s.length) {
18
- d(s);
36
+ C(s);
19
37
  return;
20
38
  }
21
- }, [s]), l(() => {
22
- if (!e)
39
+ }, [s]), m(() => {
40
+ if (!t)
23
41
  return;
24
- const o = e.find((n) => n.file.url || n.icon || n.name);
25
- m(!o);
26
- }, [e]), /* @__PURE__ */ c("div", {
42
+ const e = t.find((n) => n.file.url || n.icon || n.name);
43
+ f(!e);
44
+ }, [t]), /* @__PURE__ */ h("div", {
27
45
  className: "questions",
28
- children: [/* @__PURE__ */ c(g, {
46
+ children: [/* @__PURE__ */ h(O, {
29
47
  size: 8,
30
48
  className: "question-tip",
31
- children: [/* @__PURE__ */ t("img", {
32
- src: q,
49
+ children: [/* @__PURE__ */ r("img", {
50
+ src: k,
33
51
  alt: ""
34
- }), /* @__PURE__ */ t("span", {
52
+ }), /* @__PURE__ */ r("span", {
35
53
  children: "请试试这样提问:"
36
54
  })]
37
- }), /* @__PURE__ */ t(w, {
55
+ }), /* @__PURE__ */ r(b, {
38
56
  gutter: [12, 12],
39
57
  wrap: !0,
40
58
  className: "question-row",
41
- children: e == null ? void 0 : e.map((o, n) => /* @__PURE__ */ t(N, {
42
- span: 12,
43
- children: /* @__PURE__ */ t(v, {
44
- item: o,
45
- isRecommendClearing: p,
46
- isOnlyQuestion: R,
47
- question: h,
48
- setQuestion: i,
49
- onItemClick: f
59
+ children: t == null ? void 0 : t.map((e, n) => /* @__PURE__ */ r(j, {
60
+ span: 24 / z,
61
+ children: /* @__PURE__ */ r(B, {
62
+ item: e,
63
+ isRecommendClearing: I,
64
+ isOnlyQuestion: y,
65
+ question: x,
66
+ setQuestion: u,
67
+ onItemClick: v
50
68
  })
51
69
  }, n))
52
70
  })]
53
71
  });
54
72
  });
55
- x.displayName = "Recommend";
73
+ L.displayName = "Recommend";
56
74
  export {
57
- x as default
75
+ L as default
58
76
  };
@@ -2,7 +2,7 @@ import e from "./assets/icon.svg.mjs";
2
2
  import t from "./assets/brand.svg.mjs";
3
3
  import o from "./assets/doc-icons/pdf.svg.mjs";
4
4
  import r from "./assets/doc-icons/doc.svg.mjs";
5
- import n from "./assets/doc-icons/docx.svg.mjs";
5
+ import s from "./assets/doc-icons/docx.svg.mjs";
6
6
  const u = {
7
7
  triggerButton: {
8
8
  visible: !0
@@ -52,7 +52,11 @@ const u = {
52
52
  promptVariables: !0
53
53
  },
54
54
  features: {
55
- greeting: !0,
55
+ greeting: {
56
+ questions: !0,
57
+ layoutBreakpoints: [450]
58
+ // 默认临界值
59
+ },
56
60
  sessionList: !0,
57
61
  newSession: !0,
58
62
  fileUpload: !0,
@@ -97,7 +101,7 @@ const u = {
97
101
  }
98
102
  }, c = "https://copilot.glodon.com/api/cvforcepd", f = "https://copilot.glodon.com/portal/_/aecpilot/fe/", m = 1024, d = 1024 * 1024, g = 1024 * 1024 * 1024, h = {
99
103
  doc: r,
100
- docx: n,
104
+ docx: s,
101
105
  pdf: o
102
106
  };
103
107
  export {
package/dist/es/index.mjs CHANGED
@@ -1,39 +1,40 @@
1
1
  var D = Object.defineProperty, j = Object.defineProperties;
2
2
  var F = Object.getOwnPropertyDescriptors;
3
- var A = Object.getOwnPropertySymbols;
4
- var P = Object.prototype.hasOwnProperty, O = 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, h = (m, s) => {
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
6
  for (var n in s || (s = {}))
7
7
  P.call(s, n) && L(m, n, s[n]);
8
- if (A)
9
- for (var n of A(s))
10
- O.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
11
  return m;
12
12
  }, C = (m, s) => j(m, F(s));
13
- var c = (m, s, n) => (L(m, typeof s != "symbol" ? s + "" : s, n), n);
14
- var B = (m, s, n) => new Promise((e, d) => {
15
- var f = (a) => {
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) => {
16
16
  try {
17
- u(n.next(a));
17
+ u(n.next(h));
18
18
  } catch (l) {
19
- d(l);
19
+ c(l);
20
20
  }
21
- }, g = (a) => {
21
+ }, g = (h) => {
22
22
  try {
23
- u(n.throw(a));
23
+ u(n.throw(h));
24
24
  } catch (l) {
25
- d(l);
25
+ c(l);
26
26
  }
27
- }, u = (a) => a.done ? e(a.value) : Promise.resolve(a.value).then(f, g);
27
+ }, u = (h) => h.done ? e(h.value) : Promise.resolve(h.value).then(d, g);
28
28
  u((n = n.apply(m, s)).next());
29
29
  });
30
- import { jsx as H, Fragment as $ } from "react/jsx-runtime";
31
- import K from "react";
32
- import b from "lodash/merge";
33
- import E from "react-dom";
34
- import W from "./AgentClientUI.mjs";
35
- import { notification as M } from "antd";
36
- import J from "axios";
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";
37
38
  import Q from "./packages/agent-cli-ui/package.json.mjs";
38
39
  import { defaultUIConfig as N, defaultApiUrl as G, defaultDovViewerUrl as X } from "./constant.mjs";
39
40
  import { ApiUrl as Y } from "./types.mjs";
@@ -41,37 +42,39 @@ import { ApiUrl as Y } from "./types.mjs";
41
42
  import { JWT as q, isExpired as ee } from "./utils/index.mjs";
42
43
  import { configuration as ie, configure as T, BotClient as te } from "@glodon-aiot/bot-client-sdk";
43
44
  import se from "./ReactTextGenerationUI/index.mjs";
44
- const V = {};
45
+ const M = {};
45
46
  class we {
46
47
  constructor(s) {
47
- c(this, "_token");
48
- c(this, "_activeSession", null);
49
- c(this, "_applicationId");
50
- c(this, "_defaultInputText", "");
51
- c(this, "_inputDisabled", !1);
52
- c(this, "_defatulSessionId", "");
53
- c(this, "_agentClientRef", K.createRef());
54
- c(this, "_config");
55
- c(this, "apiUrl");
56
- c(this, "docViewerUrl");
57
- c(this, "env", "prod");
58
- c(this, "stream", ie.stream);
59
- c(this, "service");
60
- c(this, "rId", 0);
61
- c(this, "_mode", "float");
62
- c(this, "uiConfig", N);
63
- c(this, "errorHandlers", {});
64
- c(this, "wrapper", document.createElement("div"));
65
- c(this, "botClient", null);
66
- var w, _, y, I, k;
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();
67
70
  const {
68
71
  env: n,
69
72
  token: e,
70
- mode: d = "float",
71
- triggerButton: f,
73
+ mode: c = "float",
74
+ triggerButton: d,
72
75
  size: g,
73
76
  apiUrl: u,
74
- docViewerUrl: a,
77
+ docViewerUrl: h,
75
78
  errorHandlers: l,
76
79
  features: t,
77
80
  sessionId: i,
@@ -79,31 +82,31 @@ class we {
79
82
  logo: r,
80
83
  stream: p
81
84
  } = s;
82
- 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(h({}, this.uiConfig.features), {
83
- greeting: h(h({}, typeof ((w = this.uiConfig.features) == null ? void 0 : w.greeting) != "object" ? {} : (_ = this.uiConfig.features) == null ? void 0 : _.greeting), t.greeting)
84
- }) : this.uiConfig.features = C(h({}, this.uiConfig.features), {
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), {
85
88
  greeting: t.greeting
86
- })), this._token = e, this.rId = 0, this._defatulSessionId = i, this.errorHandlers = h(h({}, this.errorHandlers), l), (k = (I = (y = t == null ? void 0 : t.botMessageBox) == null ? void 0 : y.footer) == null ? void 0 : I.items) == null || k.find((U) => U.componentName === "Copy");
87
- const v = {};
88
- s.header !== void 0 && (v.showHeader = !!s.header);
89
- const S = {
90
- triggerButton: b(this.uiConfig.triggerButton, f),
91
- size: b(this.uiConfig.size, h({}, g)),
92
- theme: b(this.uiConfig.theme, V)
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)
93
96
  };
94
- this.updateUIConfig(S, v), this.env = n || "prod", this.stream = p, T({
97
+ this.updateUIConfig(k, b), this.env = n || "prod", this.stream = p, T({
95
98
  stream: this.stream
96
- }), this._applicationId = q(e).rid, this.apiUrl = u || Y[this.env] || G, this.docViewerUrl = a || X, this.service = this.setService(), this.wrapper = document.createElement("div"), this.wrapper.style.height = "100%", this.wrapper.style.width = "100%", this.createBotClientSDK().then(() => {
97
- this.mode = d;
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;
98
101
  });
99
102
  }
100
103
  updateUIConfig(s, n) {
101
- var u, a, l, t, i, o, r, p, v, S, w, _, y, I, k, U, z;
104
+ var u, h, l, t, i, o, r, p, b, k, _, w, y, I, S, U, V;
102
105
  let e = this._config.features;
103
- const d = {
106
+ const c = {
104
107
  sessionOpen: this._mode === "float",
105
108
  sessionList: this._mode === "float"
106
- }, f = (l = (a = (u = e == null ? void 0 : e.botMessageBox) == null ? void 0 : u.footer) == null ? void 0 : a.items) == null ? void 0 : l.find((x) => x.componentName === "AnswerAgain"), g = {
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 = {
107
110
  sessionList: e == null ? void 0 : e.sessionList,
108
111
  sessionOpen: e == null ? void 0 : e.newSession,
109
112
  fileUpload: e == null ? void 0 : e.fileUpload,
@@ -112,26 +115,29 @@ class we {
112
115
  userPrompt: e == null ? void 0 : e.fileUpload,
113
116
  prompt: e == null ? void 0 : e.prompts,
114
117
  relate: (o = e == null ? void 0 : e.botMessageBox) == null ? void 0 : o.relatedQuesions,
115
- again: !(f && f.visible === !1),
118
+ again: !(d && d.visible === !1),
116
119
  reference: {
117
120
  iconVisible: (p = (r = e == null ? void 0 : e.botMessageBox) == null ? void 0 : r.reference) == null ? void 0 : p.file,
118
- referenceFirst: (v = e == null ? void 0 : e.botMessageBox) == null ? void 0 : v.referenceFirst,
119
- isExpand: (w = (S = e == null ? void 0 : e.botMessageBox) == null ? void 0 : S.reference) == null ? void 0 : w.itemExpanded
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
120
123
  },
121
- searchReference: (_ = e == null ? void 0 : e.botMessageBox) == null ? void 0 : _.searchReference,
124
+ searchReference: (w = e == null ? void 0 : e.botMessageBox) == null ? void 0 : w.searchReference,
122
125
  knowledges: !!(e != null && e.knowledges),
123
126
  metadata: e == null ? void 0 : e.metadata,
124
127
  greet: (e == null ? void 0 : e.greeting) !== !1,
125
128
  imageUpload: e == null ? void 0 : e.imageUpload,
126
- 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 ? (k = this.uiConfig.transform) == null ? void 0 : k.promptVariables : !1,
127
- 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 : (z = this.uiConfig.transform) == null ? void 0 : z.connectNetwork)
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)
128
131
  };
129
132
  Object.keys(g).forEach((x) => {
130
133
  g[x] === void 0 && delete g[x];
131
- }), this.uiConfig = C(h(h(h(h(h({}, this.uiConfig), this._config), s), n), g), {
132
- transform: h(h(h(h({}, this.uiConfig.transform), d), this._config.transform), g)
134
+ }), this.uiConfig = C(a(a(a(a(a({}, this.uiConfig), this._config), s), n), g), {
135
+ transform: a(a(a(a({}, this.uiConfig.transform), c), this._config.transform), g)
133
136
  });
134
137
  }
138
+ _initWrapper() {
139
+ this.wrapper.id !== this._uuid && (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
+ }
135
141
  get token() {
136
142
  return this._token;
137
143
  }
@@ -142,33 +148,35 @@ class we {
142
148
  return this._mode;
143
149
  }
144
150
  set mode(s) {
151
+ var e;
152
+ this._defatulSessionId = (e = this.activeSession) == null ? void 0 : e.id;
145
153
  const n = {
146
154
  sider: s === "inlay"
147
155
  };
148
156
  if (s === "inlay") {
149
- const e = {
150
- triggerButton: b({
157
+ const c = {
158
+ triggerButton: v({
151
159
  visible: !1
152
160
  }, this.uiConfig.triggerButton),
153
161
  open: !0,
154
162
  resizable: !1,
155
- size: b({
163
+ size: v({
156
164
  width: "100%",
157
165
  height: "100%",
158
166
  maxWidth: "100%",
159
167
  maxHeight: "100%",
160
168
  minWidth: "100%"
161
169
  }, this._config.size),
162
- theme: b(this.uiConfig.theme, V),
170
+ theme: v(this.uiConfig.theme, M),
163
171
  history: !0
164
172
  };
165
- this.updateUIConfig(e, n), this.uiConfig.getContainer().append(this.wrapper);
173
+ this.updateUIConfig(c, n);
166
174
  } else {
167
- const e = {
168
- size: h(h(h({}, this.uiConfig.size), N.size), this._config.size),
169
- theme: b(this.uiConfig.theme, V)
175
+ const c = {
176
+ size: a(a(a({}, this.uiConfig.size), N.size), this._config.size),
177
+ theme: v(this.uiConfig.theme, M)
170
178
  };
171
- this.updateUIConfig(e, n), this._mode === "inlay" && this.wrapper.remove(), this.uiConfig.getContainer().append(this.wrapper);
179
+ this.updateUIConfig(c, n);
172
180
  }
173
181
  this._mode = s, this.render();
174
182
  }
@@ -179,11 +187,11 @@ class we {
179
187
  return this._applicationId;
180
188
  }
181
189
  setService() {
182
- const s = this.apiUrl, n = (a) => {
190
+ const s = this.apiUrl, n = (h) => {
183
191
  var t;
184
192
  const l = this.token;
185
193
  if (!l)
186
- return a;
194
+ return h;
187
195
  if (ee(l)) {
188
196
  const i = "token is timeout";
189
197
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
@@ -196,18 +204,18 @@ class we {
196
204
  })
197
205
  ) : console.error("errorHandlers.token is not a function") : console.error(i);
198
206
  }
199
- return a.headers = (t = a.headers) != null ? t : {}, a.headers = C(h({}, a.headers), {
207
+ return h.headers = (t = h.headers) != null ? t : {}, h.headers = C(a({}, h.headers), {
200
208
  Authorization: l ? `Bearer ${l}` : ""
201
- }), a;
209
+ }), h;
202
210
  };
203
- function e(a, l = !0) {
204
- const t = `${s}${a}`, i = J.create({
211
+ function e(h, l = !0) {
212
+ const t = `${s}${h}`, i = K.create({
205
213
  baseURL: t
206
214
  });
207
215
  return l && i.interceptors.request.use(n), i;
208
216
  }
209
- const d = (a, l) => {
210
- if (a === 401) {
217
+ const c = (h, l) => {
218
+ if (h === 401) {
211
219
  const t = "token is invalid";
212
220
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
213
221
  // @ts-ignore
@@ -219,18 +227,18 @@ class we {
219
227
  })
220
228
  ) : console.error("errorHandlers.token is not a function") : console.error(t);
221
229
  }
222
- }, f = (a, l, t) => {
223
- a !== 10001 && a !== 10215 && (t || (M.config({
230
+ }, d = (h, l, t) => {
231
+ h !== 10001 && h !== 10215 && (t || (E.config({
224
232
  getContainer: this.uiConfig.getContainer
225
- }), M.error({
233
+ }), E.error({
226
234
  message: l
227
- }), M.config({
235
+ }), E.config({
228
236
  getContainer: void 0
229
237
  })));
230
238
  }, g = e("");
231
239
  return new Z(g, () => this.token, {
232
- onHttpStatusError: d,
233
- onAppStatusError: f
240
+ onHttpStatusError: c,
241
+ onAppStatusError: d
234
242
  });
235
243
  }
236
244
  reload() {
@@ -256,8 +264,8 @@ class we {
256
264
  }
257
265
  getSessionList() {
258
266
  return this._agentClientRef.current ? new Promise((n, e) => {
259
- var d, f;
260
- (f = (d = this._agentClientRef.current) == null ? void 0 : d.getSessionList()) == null || f.then((g) => {
267
+ var c, d;
268
+ (d = (c = this._agentClientRef.current) == null ? void 0 : c.getSessionList()) == null || d.then((g) => {
261
269
  n(g);
262
270
  }).catch((g) => {
263
271
  e(g);
@@ -265,14 +273,14 @@ class we {
265
273
  }) : Promise.reject(new Error("client is not loaded"));
266
274
  }
267
275
  createSession(s) {
268
- return this._agentClientRef.current ? new Promise((e, d) => {
269
- var f, g;
270
- (g = (f = this._agentClientRef.current) == null ? void 0 : f.createSession(h({
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({
271
279
  name: "新建会话"
272
280
  }, s))) == null || g.then((u) => {
273
281
  e(u);
274
282
  }).catch((u) => {
275
- d(u);
283
+ c(u);
276
284
  });
277
285
  }) : Promise.reject(new Error("client is not loaded"));
278
286
  }
@@ -308,10 +316,10 @@ class we {
308
316
  }
309
317
  render() {
310
318
  return B(this, null, function* () {
311
- var s, n, e, d, f, g, u, a, l;
319
+ var s, n, e, c, d, g, u, h, l;
312
320
  if (this.wrapper.style.height = "100%", !((s = this.botClient) != null && s.application))
313
321
  throw Error("application is required");
314
- this.botClient.application.type === R.Text ? E.render(/* @__PURE__ */ H(se, {
322
+ this.botClient.application.type === R.Text ? H.render(/* @__PURE__ */ A(se, {
315
323
  rId: this.rId,
316
324
  application: this.botClient.application,
317
325
  sessionId: this._defatulSessionId,
@@ -328,7 +336,7 @@ class we {
328
336
  theme: this.uiConfig.theme,
329
337
  greeting: this.uiConfig.greeting,
330
338
  size: this.uiConfig.size,
331
- triggerButton: h({
339
+ triggerButton: a({
332
340
  visible: !0
333
341
  }, this.uiConfig.triggerButton),
334
342
  history: this.uiConfig.history,
@@ -336,8 +344,8 @@ class we {
336
344
  docViewerUrl: this.docViewerUrl,
337
345
  plugins: this.uiConfig.plugins,
338
346
  mcp: this.uiConfig.mcp,
339
- transform: C(h({}, this.uiConfig.transform), {
340
- knowledges: ((n = this.uiConfig.features) == null ? void 0 : n.knowledges) === !0 || typeof ((e = this.uiConfig.features) == null ? void 0 : e.knowledges) == "object" && ((f = (d = this.uiConfig.features) == null ? void 0 : d.knowledges) == null ? void 0 : f.visible) !== !1
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
341
349
  }),
342
350
  features: this.uiConfig.features,
343
351
  disabled: this._inputDisabled,
@@ -407,7 +415,7 @@ class we {
407
415
  } : void 0,
408
416
  bodyStyle: this.uiConfig.bodyStyle,
409
417
  stream: this.stream
410
- }), this.wrapper) : E.render(/* @__PURE__ */ H(W, {
418
+ }), this.wrapper) : H.render(/* @__PURE__ */ A($, {
411
419
  ref: this._agentClientRef,
412
420
  rId: this.rId,
413
421
  application: this.botClient.application,
@@ -426,7 +434,7 @@ class we {
426
434
  theme: this.uiConfig.theme,
427
435
  greeting: this.uiConfig.greeting,
428
436
  size: this.uiConfig.size,
429
- triggerButton: h({
437
+ triggerButton: a({
430
438
  visible: !0
431
439
  }, this.uiConfig.triggerButton),
432
440
  history: this.uiConfig.history,
@@ -434,8 +442,8 @@ class we {
434
442
  docViewerUrl: this.docViewerUrl,
435
443
  plugins: this.uiConfig.plugins,
436
444
  mcp: this.uiConfig.mcp,
437
- transform: C(h({}, this.uiConfig.transform), {
438
- knowledges: ((g = this.uiConfig.features) == null ? void 0 : g.knowledges) === !0 || typeof ((u = this.uiConfig.features) == null ? void 0 : u.knowledges) == "object" && ((l = (a = this.uiConfig.features) == null ? void 0 : a.knowledges) == null ? void 0 : l.visible) !== !1
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
439
447
  }),
440
448
  features: this.uiConfig.features,
441
449
  disabled: this._inputDisabled,
@@ -508,7 +516,7 @@ class we {
508
516
  });
509
517
  }
510
518
  destroy(s) {
511
- E.render(/* @__PURE__ */ H($, {}), this.wrapper, s);
519
+ H.unmountComponentAtNode(this.wrapper), this.wrapper && this.wrapper.remove(), s == null || s();
512
520
  }
513
521
  }
514
522
  export {