@glodon-aiot/agent-cli-ui 3.3.2-beta.8 → 3.3.2

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 (42) hide show
  1. package/dist/es/AgentClientUI.mjs +32 -34
  2. package/dist/es/Dialog/AgentChat/HistoryItem/index.mjs +142 -156
  3. package/dist/es/Dialog/AgentChat/index.mjs +147 -150
  4. package/dist/es/index.mjs +81 -87
  5. package/dist/es/packages/react-components/dist/es/components/Markdown/ATag/index.mjs +25 -27
  6. package/dist/es/packages/react-components/dist/es/components/Markdown/Image/index.mjs +27 -29
  7. package/dist/es/packages/react-components/dist/es/components/Markdown/index.mjs +48 -58
  8. package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
  9. package/dist/es/src/style10.css +1 -1
  10. package/dist/es/src/style11.css +1 -1
  11. package/dist/es/src/style12.css +1 -1
  12. package/dist/es/src/style13.css +1 -1
  13. package/dist/es/src/style14.css +1 -1
  14. package/dist/es/src/style15.css +1 -1
  15. package/dist/es/src/style16.css +1 -1
  16. package/dist/es/src/style17.css +1 -1
  17. package/dist/es/src/style19.css +1 -1
  18. package/dist/es/src/style20.css +1 -1
  19. package/dist/es/src/style23.css +1 -1
  20. package/dist/es/src/style24.css +1 -1
  21. package/dist/es/src/style26.css +1 -1
  22. package/dist/es/src/style27.css +1 -1
  23. package/dist/es/src/style28.css +1 -1
  24. package/dist/es/src/style4.css +1 -1
  25. package/dist/es/src/style5.css +1 -1
  26. package/dist/es/src/style7.css +1 -1
  27. package/dist/es/src/style8.css +1 -1
  28. package/dist/es/src/style9.css +1 -1
  29. package/dist/lib/index.js +51 -51
  30. package/dist/src/Dialog/AgentChat/HistoryItem/index.d.ts +0 -2
  31. package/dist/src/ReactTextGenerationUI/components/TextSiders/index.d.ts +22 -0
  32. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/fetch.d.ts +44 -0
  33. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/index.d.ts +1 -0
  34. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/parse.d.ts +36 -0
  35. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/fetch.d.ts +44 -0
  36. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/index.d.ts +1 -0
  37. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/parse.d.ts +36 -0
  38. package/dist/src/ReactTextGenerationUI/index.d.ts +4 -0
  39. package/dist/src/index.d.ts +0 -1
  40. package/dist/src/types.d.ts +0 -3
  41. package/dist/src/utils/reactCompatibility.d.ts +27 -0
  42. package/package.json +3 -3
package/dist/es/index.mjs CHANGED
@@ -2,71 +2,68 @@ var Z = Object.defineProperty, q = Object.defineProperties;
2
2
  var ee = Object.getOwnPropertyDescriptors;
3
3
  var J = Object.getOwnPropertySymbols;
4
4
  var ie = Object.prototype.hasOwnProperty, te = Object.prototype.propertyIsEnumerable;
5
- var k = (g, i, s) => i in g ? Z(g, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : g[i] = s, o = (g, i) => {
5
+ var w = (g, i, s) => i in g ? Z(g, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : g[i] = s, o = (g, i) => {
6
6
  for (var s in i || (i = {}))
7
- ie.call(i, s) && k(g, s, i[s]);
7
+ ie.call(i, s) && w(g, s, i[s]);
8
8
  if (J)
9
9
  for (var s of J(i))
10
- te.call(i, s) && k(g, s, i[s]);
10
+ te.call(i, s) && w(g, s, i[s]);
11
11
  return g;
12
12
  }, m = (g, i) => q(g, ee(i));
13
- var h = (g, i, s) => (k(g, typeof i != "symbol" ? i + "" : i, s), s);
13
+ var a = (g, i, s) => (w(g, typeof i != "symbol" ? i + "" : i, s), s);
14
14
  import { jsx as Q, Fragment as oe } from "react/jsx-runtime";
15
15
  import l from "lodash/merge";
16
16
  import G from "react-dom";
17
17
  import se from "./AgentClientUI.mjs";
18
18
  import { notification as K } from "antd";
19
- import re from "axios";
20
- import { defaultUIConfig as ne, defaultApiUrl as ae, defaultDovViewerUrl as he } from "./constant.mjs";
19
+ import ne from "axios";
20
+ import { defaultUIConfig as re, defaultApiUrl as he, defaultDovViewerUrl as ae } from "./constant.mjs";
21
21
  import { ApiUrl as ge } from "./types.mjs";
22
22
  /* empty css */import { BotClientApi as le } from "@glodon-aiot/apis";
23
23
  import { JWT as de, isExpired as fe } from "./utils/index.mjs";
24
- import { configuration as ce, configure as ue } from "@glodon-aiot/bot-client-sdk";
25
24
  const b = {};
26
- class Be {
25
+ class xe {
27
26
  constructor(i) {
28
- h(this, "_token");
29
- h(this, "_activeSession", null);
30
- h(this, "_applicationId");
31
- h(this, "_defaultInputText", "");
32
- h(this, "_inputDisabled", !1);
33
- h(this, "_defatulSessionId", "");
34
- h(this, "apiUrl");
35
- h(this, "docViewerUrl");
36
- h(this, "env", "prod");
37
- h(this, "stream", ce.stream);
38
- h(this, "service");
39
- h(this, "rId", 0);
40
- h(this, "_mode", "float");
41
- h(this, "uiConfig", ne);
42
- h(this, "errorHandlers", {});
43
- h(this, "wrapper", document.createElement("div"));
44
- var y, x, U, S, B, H, z, L, M, V, A, N, E, F, D, j, T, R, W, $, O, P;
27
+ a(this, "_token");
28
+ a(this, "_activeSession", null);
29
+ a(this, "_applicationId");
30
+ a(this, "_defaultInputText", "");
31
+ a(this, "_inputDisabled", !1);
32
+ a(this, "_defatulSessionId", "");
33
+ a(this, "apiUrl");
34
+ a(this, "docViewerUrl");
35
+ a(this, "env", "prod");
36
+ a(this, "service");
37
+ a(this, "rId", 0);
38
+ a(this, "_mode", "float");
39
+ a(this, "uiConfig", re);
40
+ a(this, "errorHandlers", {});
41
+ a(this, "wrapper", document.createElement("div"));
42
+ var _, y, x, U, S, B, H, z, L, M, V, A, N, E, F, D, j, T, R, W, $, O, P;
45
43
  const {
46
44
  env: s,
47
45
  token: d,
48
46
  mode: f = "float",
49
47
  triggerButton: p,
50
- size: a,
51
- apiUrl: r,
48
+ size: h,
49
+ apiUrl: n,
52
50
  docViewerUrl: t,
53
- errorHandlers: n,
51
+ errorHandlers: r,
54
52
  features: e,
55
53
  sessionId: u,
56
54
  icon: X,
57
- logo: Y,
55
+ logo: Y
58
56
  // greeting,
59
- stream: w
60
57
  } = i;
61
58
  this.uiConfig.icon = X || this.uiConfig.icon, this.uiConfig.logo = Y || this.uiConfig.logo, (e == null ? void 0 : e.greeting) !== void 0 && (typeof e.greeting == "object" ? this.uiConfig.features = m(o({}, this.uiConfig.features), {
62
- greeting: o(o({}, typeof ((y = this.uiConfig.features) == null ? void 0 : y.greeting) != "object" ? {} : (x = this.uiConfig.features) == null ? void 0 : x.greeting), e.greeting)
59
+ greeting: o(o({}, typeof ((_ = this.uiConfig.features) == null ? void 0 : _.greeting) != "object" ? {} : (y = this.uiConfig.features) == null ? void 0 : y.greeting), e.greeting)
63
60
  }) : this.uiConfig.features = m(o({}, this.uiConfig.features), {
64
61
  greeting: e.greeting
65
- })), this._token = d, this.rId = 0, this._defatulSessionId = u, this.errorHandlers = o(o({}, this.errorHandlers), n);
66
- const I = {
62
+ })), console.log("this.uiConfig.features?.greeting", (x = this.uiConfig.features) == null ? void 0 : x.greeting), this._token = d, this.rId = 0, this._defatulSessionId = u, this.errorHandlers = o(o({}, this.errorHandlers), r);
63
+ const k = {
67
64
  sessionOpen: f === "float",
68
65
  sessionList: f === "float"
69
- }, _ = (B = (S = (U = e == null ? void 0 : e.botMessageBox) == null ? void 0 : U.footer) == null ? void 0 : S.items) == null ? void 0 : B.find((c) => c.componentName === "AnswerAgain");
66
+ }, I = (B = (S = (U = e == null ? void 0 : e.botMessageBox) == null ? void 0 : U.footer) == null ? void 0 : S.items) == null ? void 0 : B.find((c) => c.componentName === "AnswerAgain");
70
67
  (L = (z = (H = e == null ? void 0 : e.botMessageBox) == null ? void 0 : H.footer) == null ? void 0 : z.items) == null || L.find((c) => c.componentName === "Copy");
71
68
  const C = {
72
69
  sessionList: e == null ? void 0 : e.sessionList,
@@ -77,7 +74,7 @@ class Be {
77
74
  userPrompt: e == null ? void 0 : e.fileUpload,
78
75
  prompt: e == null ? void 0 : e.prompts,
79
76
  relate: (A = e == null ? void 0 : e.botMessageBox) == null ? void 0 : A.relatedQuesions,
80
- again: !(_ && _.visible === !1),
77
+ again: !(I && I.visible === !1),
81
78
  reference: {
82
79
  iconVisible: (E = (N = e == null ? void 0 : e.botMessageBox) == null ? void 0 : N.reference) == null ? void 0 : E.file,
83
80
  referenceFirst: (F = e == null ? void 0 : e.botMessageBox) == null ? void 0 : F.referenceFirst,
@@ -108,26 +105,24 @@ class Be {
108
105
  maxWidth: "100%",
109
106
  maxHeight: "100%",
110
107
  minWidth: "100%"
111
- }, a),
108
+ }, h),
112
109
  theme: l(this.uiConfig.theme, b),
113
110
  history: !0
114
111
  };
115
112
  this.uiConfig = m(o(o(o(o({}, this.uiConfig), i), c), v), {
116
- transform: o(o(o(o({}, this.uiConfig.transform), I), i.transform), C)
113
+ transform: o(o(o(o({}, this.uiConfig.transform), k), i.transform), C)
117
114
  }), this.wrapper = this.uiConfig.getContainer();
118
115
  } else {
119
116
  const c = {
120
117
  triggerButton: l(this.uiConfig.triggerButton, p),
121
- size: l(this.uiConfig.size, o({}, a)),
118
+ size: l(this.uiConfig.size, o({}, h)),
122
119
  theme: l(this.uiConfig.theme, b)
123
120
  };
124
121
  this.uiConfig = m(o(o(o(o(o({}, this.uiConfig), i), c), v), C), {
125
- transform: o(o(o(o({}, this.uiConfig.transform), I), i.transform), C)
122
+ transform: o(o(o(o({}, this.uiConfig.transform), k), i.transform), C)
126
123
  }), this.uiConfig.getContainer().append(this.wrapper);
127
124
  }
128
- this._mode = f, this.env = s || "prod", this.stream = w != null ? w : !0, ue({
129
- stream: this.stream
130
- }), this._applicationId = de(d).rid, this.apiUrl = r || ge[this.env] || ae, this.docViewerUrl = t || he, this.service = this.setService(), this.render();
125
+ this._mode = f, this.env = s || "prod", this._applicationId = de(d).rid, this.apiUrl = n || ge[this.env] || he, this.docViewerUrl = t || ae, this.service = this.setService(), this.render();
131
126
  }
132
127
  get token() {
133
128
  return this._token;
@@ -176,10 +171,10 @@ class Be {
176
171
  setService() {
177
172
  const i = this.apiUrl, s = (t) => {
178
173
  var e;
179
- const n = this.token;
180
- if (!n)
174
+ const r = this.token;
175
+ if (!r)
181
176
  return t;
182
- if (fe(n)) {
177
+ if (fe(r)) {
183
178
  const u = "token is timeout";
184
179
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
185
180
  // @ts-ignore
@@ -192,16 +187,16 @@ class Be {
192
187
  ) : console.error("errorHandlers.token is not a function") : console.error(u);
193
188
  }
194
189
  return t.headers = (e = t.headers) != null ? e : {}, t.headers = m(o({}, t.headers), {
195
- Authorization: n ? `Bearer ${n}` : ""
190
+ Authorization: r ? `Bearer ${r}` : ""
196
191
  }), t;
197
192
  };
198
- function d(t, n = !0) {
199
- const e = `${i}${t}`, u = re.create({
193
+ function d(t, r = !0) {
194
+ const e = `${i}${t}`, u = ne.create({
200
195
  baseURL: e
201
196
  });
202
- return n && u.interceptors.request.use(s), u;
197
+ return r && u.interceptors.request.use(s), u;
203
198
  }
204
- const f = (t, n) => {
199
+ const f = (t, r) => {
205
200
  if (t === 401) {
206
201
  const e = "token is invalid";
207
202
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
@@ -214,14 +209,14 @@ class Be {
214
209
  })
215
210
  ) : console.error("errorHandlers.token is not a function") : console.error(e);
216
211
  }
217
- }, p = (t, n, e) => {
212
+ }, p = (t, r, e) => {
218
213
  t !== 10001 && t !== 10215 && (e || (K.config({
219
214
  getContainer: this.uiConfig.getContainer
220
215
  }), K.error({
221
- message: n
216
+ message: r
222
217
  })));
223
- }, a = d("");
224
- return new le(a, () => this.token, {
218
+ }, h = d("");
219
+ return new le(h, () => this.token, {
225
220
  onHttpStatusError: f,
226
221
  onAppStatusError: p
227
222
  });
@@ -279,60 +274,60 @@ class Be {
279
274
  disabled: this._inputDisabled,
280
275
  sider: this.uiConfig.sider,
281
276
  footer: this.uiConfig.footer,
282
- onComment: (a) => {
283
- var r, t;
277
+ onComment: (h) => {
278
+ var n, t;
284
279
  try {
285
- (t = (r = this.uiConfig.eventListeners) == null ? void 0 : r.comment) == null || t.call(r, a);
286
- } catch (n) {
287
- console.error(n);
280
+ (t = (n = this.uiConfig.eventListeners) == null ? void 0 : n.comment) == null || t.call(n, h);
281
+ } catch (r) {
282
+ console.error(r);
288
283
  }
289
284
  },
290
- onMessage: (a) => {
291
- var r, t;
292
- if (a.message.messageId)
285
+ onMessage: (h) => {
286
+ var n, t;
287
+ if (h.message.messageId)
293
288
  try {
294
- (t = (r = this.uiConfig.eventListeners) == null ? void 0 : r.message) == null || t.call(r, a);
295
- } catch (n) {
296
- console.error(n);
289
+ (t = (n = this.uiConfig.eventListeners) == null ? void 0 : n.message) == null || t.call(n, h);
290
+ } catch (r) {
291
+ console.error(r);
297
292
  }
298
293
  },
299
- beforeMessageSend: (a) => {
300
- var r, t, n;
301
- if (!((r = this.uiConfig.eventListeners) != null && r.beforemessagesend))
294
+ beforeMessageSend: (h) => {
295
+ var n, t, r;
296
+ if (!((n = this.uiConfig.eventListeners) != null && n.beforemessagesend))
302
297
  return !0;
303
298
  try {
304
- return ((n = (t = this.uiConfig.eventListeners) == null ? void 0 : t.beforemessagesend) == null ? void 0 : n.call(t, a)) || !1;
299
+ return ((r = (t = this.uiConfig.eventListeners) == null ? void 0 : t.beforemessagesend) == null ? void 0 : r.call(t, h)) || !1;
305
300
  } catch (e) {
306
301
  return console.error(e), !1;
307
302
  }
308
303
  },
309
- onSessionUnload: (a) => {
310
- var r, t;
304
+ onSessionUnload: (h) => {
305
+ var n, t;
311
306
  this._activeSession = null;
312
307
  try {
313
- (t = (r = this.uiConfig.eventListeners) == null ? void 0 : r.sessionunload) == null || t.call(r, a);
314
- } catch (n) {
315
- console.error(n);
308
+ (t = (n = this.uiConfig.eventListeners) == null ? void 0 : n.sessionunload) == null || t.call(n, h);
309
+ } catch (r) {
310
+ console.error(r);
316
311
  }
317
312
  },
318
- onSessionLoad: (a) => {
319
- var r, t, n;
320
- if (((r = this._activeSession) == null ? void 0 : r.id) === a.sessionId)
321
- this._activeSession = a.session;
313
+ onSessionLoad: (h) => {
314
+ var n, t, r;
315
+ if (((n = this._activeSession) == null ? void 0 : n.id) === h.sessionId)
316
+ this._activeSession = h.session;
322
317
  else {
323
- this._activeSession = a.session;
318
+ this._activeSession = h.session;
324
319
  try {
325
- (n = (t = this.uiConfig.eventListeners) == null ? void 0 : t.sessionload) == null || n.call(t, a);
320
+ (r = (t = this.uiConfig.eventListeners) == null ? void 0 : t.sessionload) == null || r.call(t, h);
326
321
  } catch (e) {
327
322
  console.error(e);
328
323
  }
329
324
  }
330
325
  },
331
- onHistoryLoad: (a) => {
332
- var r, t, n;
333
- if (((r = this._activeSession) == null ? void 0 : r.id) === a.sessionId)
326
+ onHistoryLoad: (h) => {
327
+ var n, t, r;
328
+ if (((n = this._activeSession) == null ? void 0 : n.id) === h.sessionId)
334
329
  try {
335
- (n = (t = this.uiConfig.eventListeners) == null ? void 0 : t.historyload) == null || n.call(t, a);
330
+ (r = (t = this.uiConfig.eventListeners) == null ? void 0 : t.historyload) == null || r.call(t, h);
336
331
  } catch (e) {
337
332
  console.error(e);
338
333
  }
@@ -340,8 +335,7 @@ class Be {
340
335
  defaultInput: this._defaultInputText !== void 0 ? {
341
336
  text: this._defaultInputText
342
337
  } : void 0,
343
- bodyStyle: this.uiConfig.bodyStyle,
344
- stream: this.stream
338
+ bodyStyle: this.uiConfig.bodyStyle
345
339
  }), this.wrapper), this._defaultInputText = "";
346
340
  }
347
341
  destroy(i) {
@@ -349,5 +343,5 @@ class Be {
349
343
  }
350
344
  }
351
345
  export {
352
- Be as default
346
+ xe as default
353
347
  };
@@ -1,44 +1,42 @@
1
1
  import { jsx as f, jsxs as h, Fragment as O } from "react/jsx-runtime";
2
- var g = Object.defineProperty, m = Object.defineProperties, j = Object.getOwnPropertyDescriptors, l = Object.getOwnPropertySymbols, u = Object.prototype.hasOwnProperty, d = Object.prototype.propertyIsEnumerable, v = (r, e, n) => e in r ? g(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, w = (r, e) => {
3
- for (var n in e || (e = {}))
4
- u.call(e, n) && v(r, n, e[n]);
2
+ var m = Object.defineProperty, g = Object.defineProperties, j = Object.getOwnPropertyDescriptors, l = Object.getOwnPropertySymbols, u = Object.prototype.hasOwnProperty, d = Object.prototype.propertyIsEnumerable, s = (r, e, a) => e in r ? m(r, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[e] = a, p = (r, e) => {
3
+ for (var a in e || (e = {}))
4
+ u.call(e, a) && s(r, a, e[a]);
5
5
  if (l)
6
- for (var n of l(e))
7
- d.call(e, n) && v(r, n, e[n]);
6
+ for (var a of l(e))
7
+ d.call(e, a) && s(r, a, e[a]);
8
8
  return r;
9
- }, y = (r, e) => m(r, j(e)), x = (r, e) => {
10
- var n = {};
11
- for (var a in r)
12
- u.call(r, a) && e.indexOf(a) < 0 && (n[a] = r[a]);
9
+ }, y = (r, e) => g(r, j(e)), x = (r, e) => {
10
+ var a = {};
11
+ for (var t in r)
12
+ u.call(r, t) && e.indexOf(t) < 0 && (a[t] = r[t]);
13
13
  if (r != null && l)
14
- for (var a of l(r))
15
- e.indexOf(a) < 0 && d.call(r, a) && (n[a] = r[a]);
16
- return n;
14
+ for (var t of l(r))
15
+ e.indexOf(t) < 0 && d.call(r, t) && (a[t] = r[t]);
16
+ return a;
17
17
  };
18
18
  const P = (r) => {
19
- var e, n;
20
- const a = r, {
19
+ var e, a;
20
+ const t = r, {
21
21
  node: o
22
- } = a, i = x(a, [
22
+ } = t, i = x(t, [
23
23
  "node"
24
24
  ]);
25
25
  if (o.tagName === "a" && ((e = o.children) == null ? void 0 : e.length) > 0) {
26
- const p = ((n = o.children[0]) == null ? void 0 : n.value) || "";
27
- let s = /(^https?:\/\/|^www\.)(?:www\.)?[\w\-]+(\.[\w\-]+)+(\/[\w\- .\/?%&=]*)?/g, c = p.match(s), b = p.replace(s, "").trim();
26
+ const v = ((a = o.children[0]) == null ? void 0 : a.value) || "";
27
+ let w = /(^https?:\/\/|^www\.)(?:www\.)?[\w\-]+(\.[\w\-]+)+(\/[\w\- .\/?%&=]*)?/g, c = v.match(w), b = v.replace(w, "").trim();
28
28
  if (!(c != null && c.length))
29
- return /* @__PURE__ */ f("a", w({}, i));
30
- const t = c[0];
29
+ return /* @__PURE__ */ f("a", p({}, i));
30
+ const n = c[0];
31
31
  return /* @__PURE__ */ h(O, {
32
- children: [/* @__PURE__ */ f("a", y(w({
33
- href: /^www\./.test(t) ? "//" + t : t,
34
- onClick: () => window.open(r.href, r.target || "_blank")
35
- }, i), {
36
- children: t
32
+ children: [/* @__PURE__ */ f("a", y(p({}, i), {
33
+ href: /^www\./.test(n) ? "//" + n : n,
34
+ children: n
37
35
  })), b]
38
36
  });
39
37
  }
40
- return /* @__PURE__ */ f("a", w({}, i));
41
- }, A = P;
38
+ return /* @__PURE__ */ f("a", p({}, i));
39
+ }, k = P;
42
40
  export {
43
- A as default
41
+ k as default
44
42
  };
@@ -1,28 +1,28 @@
1
- import { jsx as e, jsxs as v, Fragment as d } from "react/jsx-runtime";
2
- import { Image as g } from "antd";
1
+ import { jsx as e, jsxs as p, Fragment as f } from "react/jsx-runtime";
2
+ import { Image as b } from "antd";
3
3
  import "../../../../../../../node_modules/antd-mobile/es/global/index.mjs";
4
- import y from "../../../../../../../node_modules/antd-mobile/es/components/image-viewer/index.mjs";
5
- import { useState as i, useEffect as O } from "react";
6
- import { isMobile as j } from "../../../../../../../node_modules/react-device-detect/dist/lib.mjs";
7
- import h from "../Video/index.mjs";
8
- import { checkMediaType as w } from "../../../utils/markdown/index.mjs";
9
- var P = Object.defineProperty, k = Object.defineProperties, x = Object.getOwnPropertyDescriptors, m = Object.getOwnPropertySymbols, C = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable, p = (r, o, t) => o in r ? P(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t, l = (r, o) => {
4
+ import u from "../../../../../../../node_modules/antd-mobile/es/components/image-viewer/index.mjs";
5
+ import { useState as c, useEffect as v } from "react";
6
+ import { isMobile as y } from "../../../../../../../node_modules/react-device-detect/dist/lib.mjs";
7
+ import d from "../Video/index.mjs";
8
+ import { checkMediaType as g } from "../../../utils/markdown/index.mjs";
9
+ var j = Object.defineProperty, O = Object.defineProperties, w = Object.getOwnPropertyDescriptors, l = Object.getOwnPropertySymbols, h = Object.prototype.hasOwnProperty, k = Object.prototype.propertyIsEnumerable, a = (r, o, t) => o in r ? j(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t, x = (r, o) => {
10
10
  for (var t in o || (o = {}))
11
- C.call(o, t) && p(r, t, o[t]);
12
- if (m)
13
- for (var t of m(o))
14
- E.call(o, t) && p(r, t, o[t]);
11
+ h.call(o, t) && a(r, t, o[t]);
12
+ if (l)
13
+ for (var t of l(o))
14
+ k.call(o, t) && a(r, t, o[t]);
15
15
  return r;
16
- }, f = (r, o) => k(r, x(o));
17
- const M = (r) => {
18
- const [o, t] = i(!1), [b, u] = i();
19
- return O(() => {
20
- r.src && u(w(r.src));
21
- }, [r.src]), b == "video" ? /* @__PURE__ */ e(h, {
16
+ }, P = (r, o) => O(r, w(o));
17
+ const C = (r) => {
18
+ const [o, t] = c(!1), [n, i] = c();
19
+ return v(() => {
20
+ r.src && i(g(r.src));
21
+ }, [r.src]), n == "video" ? /* @__PURE__ */ e(d, {
22
22
  src: r.src,
23
23
  controls: !0
24
- }) : j ? /* @__PURE__ */ v(d, {
25
- children: [/* @__PURE__ */ e("img", l({
24
+ }) : y ? /* @__PURE__ */ p(f, {
25
+ children: [/* @__PURE__ */ e("img", {
26
26
  style: {
27
27
  maxWidth: "100%"
28
28
  },
@@ -30,29 +30,27 @@ const M = (r) => {
30
30
  onClick: () => {
31
31
  t(!0);
32
32
  }
33
- }, r)), /* @__PURE__ */ e(y, {
33
+ }), /* @__PURE__ */ e(u, {
34
34
  image: (r == null ? void 0 : r.src) || "",
35
35
  visible: o,
36
36
  onClose: () => {
37
37
  t(!1);
38
38
  }
39
39
  })]
40
- }) : /* @__PURE__ */ e(g, f(l({
40
+ }) : /* @__PURE__ */ e(b, P(x({
41
41
  style: {
42
42
  maxWidth: "100%"
43
43
  }
44
44
  }, r), {
45
- onClick: (s) => {
46
- var a, n, c;
47
- (c = r.onClick) == null || c.call(r, f(l({}, s), {
48
- target: (n = (a = s.target) == null ? void 0 : a.offsetParent) == null ? void 0 : n.children[0]
49
- }));
45
+ onClick: (m) => {
46
+ var s;
47
+ return (s = r.onClick) == null ? void 0 : s.call(r, m);
50
48
  },
51
49
  onError: () => {
52
50
  console.log(r), console.warn("图片加载失败");
53
51
  }
54
52
  }));
55
- }, _ = M;
53
+ }, T = C;
56
54
  export {
57
- _ as default
55
+ T as default
58
56
  };
@@ -1,78 +1,68 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { useRef as w } from "react";
3
- /* empty css */import y from "./Image/index.mjs";
4
- import h from "./Code/index.mjs";
5
- import { replaceLatexDelimiters as k } from "../../utils/markdown/index.mjs";
6
- import b from "./ATag/index.mjs";
7
- import g from "./Video/index.mjs";
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { useRef as u } from "react";
3
+ /* empty css */import v from "./Image/index.mjs";
4
+ import y from "./Code/index.mjs";
5
+ import { replaceLatexDelimiters as b } from "../../utils/markdown/index.mjs";
6
+ import h from "./ATag/index.mjs";
7
+ import w from "./Video/index.mjs";
8
8
  import { Markdown as O } from "../../../../../../node_modules/react-markdown/lib/index.mjs";
9
- import x from "../../../../../../node_modules/rehype-katex/lib/index.mjs";
10
- import M from "../../../../../../node_modules/rehype-raw/lib/index.mjs";
11
- import P from "../../../../../../node_modules/rehype-external-links/lib/index.mjs";
9
+ import k from "../../../../../../node_modules/rehype-katex/lib/index.mjs";
10
+ import g from "../../../../../../node_modules/rehype-raw/lib/index.mjs";
11
+ import x from "../../../../../../node_modules/rehype-external-links/lib/index.mjs";
12
12
  import j from "../../../../../../node_modules/remark-math/lib/index.mjs";
13
- import L from "../../../../../../node_modules/remark-gfm/lib/index.mjs";
14
- var R = Object.defineProperty, $ = Object.defineProperties, C = Object.getOwnPropertyDescriptors, i = Object.getOwnPropertySymbols, c = Object.prototype.hasOwnProperty, f = Object.prototype.propertyIsEnumerable, s = (r, e, o) => e in r ? R(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o, n = (r, e) => {
15
- for (var o in e || (e = {}))
16
- c.call(e, o) && s(r, o, e[o]);
17
- if (i)
18
- for (var o of i(e))
19
- f.call(e, o) && s(r, o, e[o]);
13
+ import P from "../../../../../../node_modules/remark-gfm/lib/index.mjs";
14
+ var L = Object.defineProperty, M = Object.defineProperties, $ = Object.getOwnPropertyDescriptors, n = Object.getOwnPropertySymbols, f = Object.prototype.hasOwnProperty, c = Object.prototype.propertyIsEnumerable, l = (r, e, t) => e in r ? L(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, i = (r, e) => {
15
+ for (var t in e || (e = {}))
16
+ f.call(e, t) && l(r, t, e[t]);
17
+ if (n)
18
+ for (var t of n(e))
19
+ c.call(e, t) && l(r, t, e[t]);
20
20
  return r;
21
- }, D = (r, e) => $(r, C(e)), E = (r, e) => {
22
- var o = {};
23
- for (var t in r)
24
- c.call(r, t) && e.indexOf(t) < 0 && (o[t] = r[t]);
25
- if (r != null && i)
26
- for (var t of i(r))
27
- e.indexOf(t) < 0 && f.call(r, t) && (o[t] = r[t]);
28
- return o;
21
+ }, D = (r, e) => M(r, $(e)), E = (r, e) => {
22
+ var t = {};
23
+ for (var o in r)
24
+ f.call(r, o) && e.indexOf(o) < 0 && (t[o] = r[o]);
25
+ if (r != null && n)
26
+ for (var o of n(r))
27
+ e.indexOf(o) < 0 && c.call(r, o) && (t[o] = r[o]);
28
+ return t;
29
29
  };
30
- const J = (r) => {
30
+ const H = (r) => {
31
31
  var e = r, {
32
- showLatex: o = !0,
33
- components: t = {},
34
- componentProps: a,
32
+ showLatex: t = !0,
33
+ components: o = {},
35
34
  children: p
36
- } = e, d = E(e, [
35
+ } = e, s = E(e, [
37
36
  "showLatex",
38
37
  "components",
39
- "componentProps",
40
38
  "children"
41
39
  ]);
42
- const u = w(null), v = n({
43
- img(m) {
44
- return /* @__PURE__ */ l(y, n(n({}, m), a == null ? void 0 : a.img));
45
- },
46
- code(m) {
47
- return /* @__PURE__ */ l(h, n(n({}, m), a == null ? void 0 : a.code));
48
- },
49
- video(m) {
50
- return /* @__PURE__ */ l(g, n(n({}, m), a == null ? void 0 : a.video));
51
- },
52
- a(m) {
53
- return /* @__PURE__ */ l(b, n(n({}, m), a == null ? void 0 : a.a));
54
- }
55
- }, t);
56
- return /* @__PURE__ */ l("div", {
57
- ref: u,
58
- children: /* @__PURE__ */ l(O, D(n({
40
+ const d = u(null);
41
+ return /* @__PURE__ */ a("div", {
42
+ ref: d,
43
+ children: /* @__PURE__ */ a(O, D(i({
59
44
  className: "markdown",
60
- rehypePlugins: [x, M, [P, {
45
+ rehypePlugins: [k, g, [x, {
61
46
  target: "_blank"
62
47
  }]],
63
- remarkPlugins: [j, [L, {
48
+ remarkPlugins: [j, [P, {
64
49
  singleTilde: !1
65
50
  }]]
66
- }, d), {
67
- children: o ? k(p) : p,
68
- components: v
51
+ }, s), {
52
+ children: t ? b(p) : p,
53
+ components: i({
54
+ img(m) {
55
+ return /* @__PURE__ */ a(v, i({}, m));
56
+ },
57
+ code(m) {
58
+ return /* @__PURE__ */ a(y, i({}, m));
59
+ },
60
+ video: w,
61
+ a: h
62
+ }, o)
69
63
  }))
70
64
  });
71
65
  };
72
66
  export {
73
- J as Markdown,
74
- b as MarkdownATag,
75
- h as MarkdownCode,
76
- y as MarkdownImage,
77
- g as MarkdownVideo
67
+ H as Markdown
78
68
  };