@superlc/md-vue 0.1.1 → 0.2.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.
package/dist/index.js CHANGED
@@ -1,63 +1,63 @@
1
- import { defineComponent as A, ref as h, h as f, watch as w, computed as B, onUnmounted as U } from "vue";
2
- import { parseToHast as P, createStreamingParser as F, OutputRateController as O } from "@superlc/md-core";
3
- let T = !1, x = null;
4
- async function D() {
5
- if (!T)
6
- return x || (x = (async () => {
7
- await import("katex/dist/katex.min.css"), T = !0;
8
- })(), x);
1
+ import { defineComponent as C, ref as y, h as t, computed as N, onMounted as $, onUnmounted as E, watch as T } from "vue";
2
+ import { detectColorScheme as te, observeColorScheme as ae, downloadAsPng as ne, MermaidRenderer as le, parseToHast as j, createStreamingParser as P, OutputRateController as U } from "@superlc/md-core";
3
+ let R = !1, F = null;
4
+ async function oe() {
5
+ if (!R)
6
+ return F || (F = (async () => {
7
+ await import("katex/dist/katex.min.css"), R = !0;
8
+ })(), F);
9
9
  }
10
- function ne() {
11
- return T;
10
+ function Ne() {
11
+ return R;
12
12
  }
13
- function R() {
14
- return D();
13
+ function Y() {
14
+ return oe();
15
15
  }
16
- async function G(e) {
16
+ async function re(e) {
17
17
  try {
18
18
  return await navigator.clipboard.writeText(e), !0;
19
19
  } catch {
20
- return J(e);
20
+ return se(e);
21
21
  }
22
22
  }
23
- function J(e) {
24
- const t = document.createElement("textarea");
25
- t.value = e, t.style.position = "fixed", t.style.left = "-9999px", document.body.appendChild(t), t.select();
23
+ function se(e) {
24
+ const n = document.createElement("textarea");
25
+ n.value = e, n.style.position = "fixed", n.style.left = "-9999px", document.body.appendChild(n), n.select();
26
26
  try {
27
27
  return document.execCommand("copy"), !0;
28
28
  } catch {
29
29
  return !1;
30
30
  } finally {
31
- document.body.removeChild(t);
31
+ document.body.removeChild(n);
32
32
  }
33
33
  }
34
- const Q = () => f(
34
+ const ue = () => t(
35
35
  "svg",
36
36
  {
37
37
  viewBox: "0 0 24 24",
38
38
  fill: "currentColor"
39
39
  },
40
40
  [
41
- f("path", {
41
+ t("path", {
42
42
  d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
43
43
  })
44
44
  ]
45
- ), X = () => f(
45
+ ), ce = () => t(
46
46
  "svg",
47
47
  {
48
48
  viewBox: "0 0 24 24",
49
49
  fill: "currentColor"
50
50
  },
51
51
  [
52
- f("path", {
52
+ t("path", {
53
53
  d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
54
54
  })
55
55
  ]
56
56
  );
57
- function I(e) {
58
- return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => typeof t == "string" ? t : t && typeof t == "object" && "children" in t ? I(t.children) : "").join("") : "";
57
+ function X(e) {
58
+ return typeof e == "string" ? e : Array.isArray(e) ? e.map((n) => typeof n == "string" ? n : n && typeof n == "object" && "children" in n ? X(n.children) : "").join("") : "";
59
59
  }
60
- const L = A({
60
+ const q = C({
61
61
  name: "CodeBlock",
62
62
  props: {
63
63
  showCopyButton: {
@@ -66,34 +66,708 @@ const L = A({
66
66
  }
67
67
  },
68
68
  emits: ["copy"],
69
- setup(e, { slots: t, emit: l }) {
70
- const a = h(!1), u = async () => {
71
- var o;
72
- const r = (o = t.default) == null ? void 0 : o.call(t), n = r ? I(r) : "";
73
- await G(n) && (a.value = !0, l("copy", n), setTimeout(() => {
74
- a.value = !1;
69
+ setup(e, { slots: n, emit: l }) {
70
+ const r = y(!1), o = async () => {
71
+ var u;
72
+ const a = (u = n.default) == null ? void 0 : u.call(n), s = a ? X(a) : "";
73
+ await re(s) && (r.value = !0, l("copy", s), setTimeout(() => {
74
+ r.value = !1;
75
75
  }, 2e3));
76
76
  };
77
77
  return () => {
78
- var n;
79
- const r = (n = t.default) == null ? void 0 : n.call(t);
80
- return f("div", { class: "md-code-block-wrapper" }, [
81
- f("pre", {}, r),
82
- e.showCopyButton && f(
78
+ var s;
79
+ const a = (s = n.default) == null ? void 0 : s.call(n);
80
+ return t("div", { class: "md-code-block-wrapper" }, [
81
+ t("pre", {}, a),
82
+ e.showCopyButton && t(
83
83
  "button",
84
84
  {
85
85
  type: "button",
86
- class: `md-copy-button${a.value ? " md-copy-button--copied" : ""}`,
87
- onClick: u,
88
- title: a.value ? "已复制" : "复制代码",
89
- "aria-label": a.value ? "已复制" : "复制代码"
86
+ class: `md-copy-button${r.value ? " md-copy-button--copied" : ""}`,
87
+ onClick: o,
88
+ title: r.value ? "已复制" : "复制代码",
89
+ "aria-label": r.value ? "已复制" : "复制代码"
90
90
  },
91
- [a.value ? f(X) : f(Q)]
91
+ [r.value ? t(ce) : t(ue)]
92
92
  )
93
93
  ]);
94
94
  };
95
95
  }
96
- }), z = A({
96
+ }), ie = {
97
+ min: 0.25,
98
+ max: 4,
99
+ step: 0.25,
100
+ default: 1
101
+ };
102
+ function W(e = {}) {
103
+ const {
104
+ config: n,
105
+ enableDrag: l = !1,
106
+ enableWheelZoom: r = !1
107
+ } = e, o = { ...ie, ...n }, a = y({
108
+ scale: o.default,
109
+ translateX: 0,
110
+ translateY: 0
111
+ }), s = y(!1), i = y({ x: 0, y: 0 }), u = y({ x: 0, y: 0 }), c = (m) => Math.max(o.min, Math.min(o.max, m)), f = N(() => a.value.scale < o.max), g = N(() => a.value.scale > o.min), v = () => {
112
+ a.value = {
113
+ ...a.value,
114
+ scale: c(a.value.scale + o.step)
115
+ };
116
+ }, d = () => {
117
+ a.value = {
118
+ ...a.value,
119
+ scale: c(a.value.scale - o.step)
120
+ };
121
+ }, p = () => {
122
+ a.value = {
123
+ scale: o.default,
124
+ translateX: 0,
125
+ translateY: 0
126
+ };
127
+ }, M = (m) => {
128
+ a.value = {
129
+ ...a.value,
130
+ scale: c(m)
131
+ };
132
+ }, h = (m, b) => {
133
+ const k = m.width / b.width, z = m.height / b.height, V = Math.min(k, z) * 0.95;
134
+ a.value = {
135
+ scale: c(V),
136
+ translateX: 0,
137
+ translateY: 0
138
+ };
139
+ }, x = (m) => {
140
+ l && (m.preventDefault(), s.value = !0, i.value = { x: m.clientX, y: m.clientY }, u.value = { x: a.value.translateX, y: a.value.translateY });
141
+ }, w = (m) => {
142
+ if (!s.value) return;
143
+ const b = m.clientX - i.value.x, k = m.clientY - i.value.y;
144
+ a.value = {
145
+ ...a.value,
146
+ translateX: u.value.x + b,
147
+ translateY: u.value.y + k
148
+ };
149
+ }, B = () => {
150
+ s.value = !1;
151
+ }, I = (m) => {
152
+ if (!r) return;
153
+ m.preventDefault();
154
+ const b = m.deltaY > 0 ? -o.step : o.step;
155
+ a.value = {
156
+ ...a.value,
157
+ scale: c(a.value.scale + b)
158
+ };
159
+ }, L = () => {
160
+ p();
161
+ }, S = N(() => ({
162
+ transform: `translate(${a.value.translateX}px, ${a.value.translateY}px) scale(${a.value.scale})`,
163
+ transformOrigin: "center center",
164
+ transition: s.value ? "none" : "transform 0.2s ease-out",
165
+ cursor: l ? s.value ? "grabbing" : "grab" : "default"
166
+ }));
167
+ return $(() => {
168
+ l && (document.addEventListener("mousemove", w), document.addEventListener("mouseup", B));
169
+ }), E(() => {
170
+ l && (document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", B));
171
+ }), {
172
+ state: a,
173
+ zoomIn: v,
174
+ zoomOut: d,
175
+ reset: p,
176
+ fitToContainer: h,
177
+ setScale: M,
178
+ canZoomIn: f,
179
+ canZoomOut: g,
180
+ contentStyle: S,
181
+ onMouseDown: x,
182
+ onWheel: I,
183
+ onDoubleClick: L
184
+ };
185
+ }
186
+ const de = C({
187
+ name: "ImageIcon",
188
+ setup() {
189
+ return () => t(
190
+ "svg",
191
+ { viewBox: "0 0 24 24", fill: "currentColor" },
192
+ t("path", {
193
+ d: "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"
194
+ })
195
+ );
196
+ }
197
+ }), me = C({
198
+ name: "CodeIcon",
199
+ setup() {
200
+ return () => t(
201
+ "svg",
202
+ { viewBox: "0 0 24 24", fill: "currentColor" },
203
+ t("path", {
204
+ d: "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"
205
+ })
206
+ );
207
+ }
208
+ }), _ = C({
209
+ name: "ZoomInIcon",
210
+ setup() {
211
+ return () => t(
212
+ "svg",
213
+ { viewBox: "0 0 24 24", fill: "currentColor" },
214
+ t("path", {
215
+ d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2V7z"
216
+ })
217
+ );
218
+ }
219
+ }), K = C({
220
+ name: "ZoomOutIcon",
221
+ setup() {
222
+ return () => t(
223
+ "svg",
224
+ { viewBox: "0 0 24 24", fill: "currentColor" },
225
+ t("path", {
226
+ d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7V9z"
227
+ })
228
+ );
229
+ }
230
+ }), G = C({
231
+ name: "ResetIcon",
232
+ setup() {
233
+ return () => t(
234
+ "svg",
235
+ { viewBox: "0 0 24 24", fill: "currentColor" },
236
+ t("path", {
237
+ d: "M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"
238
+ })
239
+ );
240
+ }
241
+ }), ve = C({
242
+ name: "FullscreenIcon",
243
+ setup() {
244
+ return () => t(
245
+ "svg",
246
+ { viewBox: "0 0 24 24", fill: "currentColor" },
247
+ t("path", {
248
+ d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"
249
+ })
250
+ );
251
+ }
252
+ }), fe = C({
253
+ name: "FullscreenExitIcon",
254
+ setup() {
255
+ return () => t(
256
+ "svg",
257
+ { viewBox: "0 0 24 24", fill: "currentColor" },
258
+ t("path", {
259
+ d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"
260
+ })
261
+ );
262
+ }
263
+ }), J = C({
264
+ name: "DownloadIcon",
265
+ setup() {
266
+ return () => t(
267
+ "svg",
268
+ { viewBox: "0 0 24 24", fill: "currentColor" },
269
+ t("path", {
270
+ d: "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"
271
+ })
272
+ );
273
+ }
274
+ }), pe = C({
275
+ name: "CloseIcon",
276
+ setup() {
277
+ return () => t(
278
+ "svg",
279
+ { viewBox: "0 0 24 24", fill: "currentColor" },
280
+ t("path", {
281
+ d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
282
+ })
283
+ );
284
+ }
285
+ }), he = C({
286
+ name: "CopyIcon",
287
+ setup() {
288
+ return () => t(
289
+ "svg",
290
+ { viewBox: "0 0 24 24", fill: "currentColor" },
291
+ t("path", {
292
+ d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
293
+ })
294
+ );
295
+ }
296
+ }), ye = C({
297
+ name: "CheckIcon",
298
+ setup() {
299
+ return () => t(
300
+ "svg",
301
+ { viewBox: "0 0 24 24", fill: "currentColor" },
302
+ t("path", {
303
+ d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
304
+ })
305
+ );
306
+ }
307
+ });
308
+ C({
309
+ name: "FitIcon",
310
+ setup() {
311
+ return () => t(
312
+ "svg",
313
+ { viewBox: "0 0 24 24", fill: "currentColor" },
314
+ t("path", {
315
+ d: "M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2zm2 10H3v4c0 1.1.9 2 2 2h4v-2H5v-4zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2z"
316
+ })
317
+ );
318
+ }
319
+ });
320
+ const ge = C({
321
+ name: "MermaidFullscreenViewer",
322
+ props: {
323
+ svg: {
324
+ type: String,
325
+ required: !0
326
+ },
327
+ open: {
328
+ type: Boolean,
329
+ required: !0
330
+ }
331
+ },
332
+ emits: ["close", "download"],
333
+ setup(e, { emit: n }) {
334
+ const l = y(null), r = y(null), o = y(null), a = y(!1), {
335
+ state: s,
336
+ zoomIn: i,
337
+ zoomOut: u,
338
+ reset: c,
339
+ fitToContainer: f,
340
+ canZoomIn: g,
341
+ canZoomOut: v,
342
+ contentStyle: d,
343
+ onMouseDown: p,
344
+ onWheel: M,
345
+ onDoubleClick: h
346
+ } = W({
347
+ enableDrag: !0,
348
+ enableWheelZoom: !0
349
+ }), x = async () => {
350
+ if (l.value)
351
+ try {
352
+ await l.value.requestFullscreen(), a.value = !0;
353
+ } catch {
354
+ a.value = !0;
355
+ }
356
+ }, w = () => {
357
+ document.fullscreenElement && document.exitFullscreen().catch(() => {
358
+ }), a.value = !1, n("close");
359
+ };
360
+ T(
361
+ () => e.open,
362
+ (S) => {
363
+ S ? x() : a.value && w();
364
+ }
365
+ );
366
+ const B = () => {
367
+ !document.fullscreenElement && a.value && (a.value = !1, n("close"));
368
+ }, I = (S) => {
369
+ if (a.value)
370
+ switch (S.key) {
371
+ case "+":
372
+ case "=":
373
+ i();
374
+ break;
375
+ case "-":
376
+ u();
377
+ break;
378
+ case "0":
379
+ c();
380
+ break;
381
+ }
382
+ };
383
+ $(() => {
384
+ document.addEventListener("fullscreenchange", B), document.addEventListener("keydown", I);
385
+ }), E(() => {
386
+ document.removeEventListener("fullscreenchange", B), document.removeEventListener("keydown", I);
387
+ });
388
+ const L = () => {
389
+ if (!r.value || !o.value) return;
390
+ const S = r.value.getBoundingClientRect(), m = o.value.querySelector("svg");
391
+ if (m) {
392
+ const b = m.getBoundingClientRect();
393
+ f(S, b);
394
+ }
395
+ };
396
+ return () => t(
397
+ "div",
398
+ {
399
+ ref: l,
400
+ class: [
401
+ "md-mermaid-fullscreen-wrapper",
402
+ a.value && "md-mermaid-fullscreen-wrapper--active"
403
+ ],
404
+ role: "dialog",
405
+ "aria-modal": "true",
406
+ "aria-label": "Mermaid 图表全屏预览",
407
+ "aria-hidden": !a.value
408
+ },
409
+ a.value ? [
410
+ // 工具栏
411
+ t("div", { class: "md-mermaid-fullscreen-toolbar" }, [
412
+ t("div", { class: "md-mermaid-toolbar-group" }, [
413
+ t(
414
+ "button",
415
+ {
416
+ type: "button",
417
+ class: "md-mermaid-toolbar-btn",
418
+ onClick: u,
419
+ disabled: !v.value,
420
+ title: "缩小 (-)",
421
+ "aria-label": "缩小"
422
+ },
423
+ t(K)
424
+ ),
425
+ t(
426
+ "span",
427
+ { class: "md-mermaid-zoom-label" },
428
+ `${Math.round(s.value.scale * 100)}%`
429
+ ),
430
+ t(
431
+ "button",
432
+ {
433
+ type: "button",
434
+ class: "md-mermaid-toolbar-btn",
435
+ onClick: i,
436
+ disabled: !g.value,
437
+ title: "放大 (+)",
438
+ "aria-label": "放大"
439
+ },
440
+ t(_)
441
+ ),
442
+ t(
443
+ "button",
444
+ {
445
+ type: "button",
446
+ class: "md-mermaid-toolbar-btn",
447
+ onClick: c,
448
+ title: "重置 (0)",
449
+ "aria-label": "重置"
450
+ },
451
+ t(G)
452
+ ),
453
+ t(
454
+ "button",
455
+ {
456
+ type: "button",
457
+ class: "md-mermaid-toolbar-btn",
458
+ onClick: L,
459
+ title: "适应窗口",
460
+ "aria-label": "适应窗口"
461
+ },
462
+ t(fe)
463
+ )
464
+ ]),
465
+ t("div", { class: "md-mermaid-toolbar-group" }, [
466
+ t(
467
+ "button",
468
+ {
469
+ type: "button",
470
+ class: "md-mermaid-toolbar-btn",
471
+ onClick: () => n("download"),
472
+ title: "下载 PNG",
473
+ "aria-label": "下载"
474
+ },
475
+ t(J)
476
+ ),
477
+ t(
478
+ "button",
479
+ {
480
+ type: "button",
481
+ class: "md-mermaid-toolbar-btn",
482
+ onClick: w,
483
+ title: "退出全屏 (Esc)",
484
+ "aria-label": "退出全屏"
485
+ },
486
+ t(pe)
487
+ )
488
+ ])
489
+ ]),
490
+ // 内容区域
491
+ t(
492
+ "div",
493
+ {
494
+ ref: r,
495
+ class: "md-mermaid-fullscreen-content",
496
+ onWheel: M
497
+ },
498
+ t("div", {
499
+ ref: o,
500
+ class: "md-mermaid-fullscreen-svg",
501
+ style: d.value,
502
+ onMousedown: p,
503
+ onDblclick: h,
504
+ innerHTML: e.svg
505
+ })
506
+ )
507
+ ] : void 0
508
+ );
509
+ }
510
+ }), be = 150;
511
+ let A = null;
512
+ function Ce(e = "auto") {
513
+ return A ? A.setTheme(e ?? "auto") : A = new le({ theme: e }), A;
514
+ }
515
+ async function we(e) {
516
+ try {
517
+ return await navigator.clipboard.writeText(e), !0;
518
+ } catch {
519
+ const n = document.createElement("textarea");
520
+ n.value = e, n.style.position = "fixed", n.style.left = "-9999px", document.body.appendChild(n), n.select();
521
+ try {
522
+ return document.execCommand("copy"), !0;
523
+ } catch {
524
+ return !1;
525
+ } finally {
526
+ document.body.removeChild(n);
527
+ }
528
+ }
529
+ }
530
+ const ke = C({
531
+ name: "MermaidBlock",
532
+ props: {
533
+ code: {
534
+ type: String,
535
+ required: !0
536
+ },
537
+ theme: {
538
+ type: String,
539
+ default: "auto"
540
+ },
541
+ showToolbar: {
542
+ type: Boolean,
543
+ default: !0
544
+ },
545
+ streamStatus: {
546
+ type: String,
547
+ default: "done"
548
+ }
549
+ },
550
+ emits: ["copy"],
551
+ setup(e, { emit: n }) {
552
+ const l = y("preview"), r = y(null), o = y(!0), a = y(!1), s = y(!1), i = y(te());
553
+ let u = null, c = null;
554
+ const {
555
+ state: f,
556
+ zoomIn: g,
557
+ zoomOut: v,
558
+ reset: d,
559
+ canZoomIn: p,
560
+ canZoomOut: M,
561
+ contentStyle: h
562
+ } = W(), x = N(
563
+ () => {
564
+ var m;
565
+ return ((m = r.value) == null ? void 0 : m.success) && r.value.svg;
566
+ }
567
+ );
568
+ let w = null;
569
+ $(() => {
570
+ e.theme === "auto" && (w = ae((m) => {
571
+ i.value = m;
572
+ }));
573
+ }), E(() => {
574
+ w == null || w(), c && (clearTimeout(c), c = null);
575
+ });
576
+ let B = e.code, I = e.streamStatus;
577
+ T(
578
+ () => [e.code, e.theme, i.value, e.streamStatus],
579
+ async () => {
580
+ B = e.code, I = e.streamStatus;
581
+ const m = async () => {
582
+ I === "loading" && u || (o.value = !0);
583
+ const k = await Ce(e.theme).render(B);
584
+ k.success && k.svg ? (u = k.svg, r.value = k, o.value = !1, l.value = "preview") : I === "loading" ? u && (r.value = {
585
+ success: !0,
586
+ svg: u
587
+ }, o.value = !1) : (r.value = k, o.value = !1, l.value = "code");
588
+ };
589
+ e.streamStatus === "loading" ? c || (c = setTimeout(() => {
590
+ c = null, m();
591
+ }, be)) : (c && (clearTimeout(c), c = null), m());
592
+ },
593
+ { immediate: !0 }
594
+ );
595
+ const L = async () => {
596
+ await we(e.code) && (s.value = !0, n("copy", e.code), setTimeout(() => s.value = !1, 2e3));
597
+ }, S = async () => {
598
+ var m, b;
599
+ if ((m = r.value) != null && m.svg)
600
+ try {
601
+ const k = ((b = window.matchMedia) == null ? void 0 : b.call(window, "(prefers-color-scheme: dark)").matches) ?? !1;
602
+ await ne(r.value.svg, {
603
+ backgroundColor: k ? "#1a1a2e" : "#ffffff",
604
+ padding: 20,
605
+ scale: 2
606
+ });
607
+ } catch (k) {
608
+ console.error("Download failed:", k);
609
+ }
610
+ };
611
+ return () => {
612
+ const m = e.showToolbar ? t("div", { class: "md-mermaid-toolbar" }, [
613
+ // 模式切换
614
+ t("div", { class: "md-mermaid-toolbar-group md-mermaid-mode-switch" }, [
615
+ t(
616
+ "button",
617
+ {
618
+ type: "button",
619
+ class: `md-mermaid-toolbar-btn${l.value === "preview" ? " md-mermaid-toolbar-btn--active" : ""}`,
620
+ onClick: () => l.value = "preview",
621
+ disabled: !x.value,
622
+ title: "图片模式",
623
+ "aria-label": "图片模式"
624
+ },
625
+ t(de)
626
+ ),
627
+ t(
628
+ "button",
629
+ {
630
+ type: "button",
631
+ class: `md-mermaid-toolbar-btn${l.value === "code" ? " md-mermaid-toolbar-btn--active" : ""}`,
632
+ onClick: () => l.value = "code",
633
+ title: "代码模式",
634
+ "aria-label": "代码模式"
635
+ },
636
+ t(me)
637
+ )
638
+ ]),
639
+ // 缩放控制 - 仅图片模式显示
640
+ l.value === "preview" && x.value ? t("div", { class: "md-mermaid-toolbar-group" }, [
641
+ t(
642
+ "button",
643
+ {
644
+ type: "button",
645
+ class: "md-mermaid-toolbar-btn",
646
+ onClick: v,
647
+ disabled: !M.value,
648
+ title: "缩小",
649
+ "aria-label": "缩小"
650
+ },
651
+ t(K)
652
+ ),
653
+ t(
654
+ "span",
655
+ { class: "md-mermaid-zoom-label" },
656
+ `${Math.round(f.value.scale * 100)}%`
657
+ ),
658
+ t(
659
+ "button",
660
+ {
661
+ type: "button",
662
+ class: "md-mermaid-toolbar-btn",
663
+ onClick: g,
664
+ disabled: !p.value,
665
+ title: "放大",
666
+ "aria-label": "放大"
667
+ },
668
+ t(_)
669
+ ),
670
+ t(
671
+ "button",
672
+ {
673
+ type: "button",
674
+ class: "md-mermaid-toolbar-btn",
675
+ onClick: d,
676
+ title: "重置",
677
+ "aria-label": "重置缩放"
678
+ },
679
+ t(G)
680
+ )
681
+ ]) : null,
682
+ // 操作按钮
683
+ t("div", { class: "md-mermaid-toolbar-group" }, [
684
+ l.value === "preview" && x.value ? [
685
+ t(
686
+ "button",
687
+ {
688
+ type: "button",
689
+ class: "md-mermaid-toolbar-btn",
690
+ onClick: () => a.value = !0,
691
+ title: "全屏",
692
+ "aria-label": "全屏查看"
693
+ },
694
+ t(ve)
695
+ ),
696
+ t(
697
+ "button",
698
+ {
699
+ type: "button",
700
+ class: "md-mermaid-toolbar-btn",
701
+ onClick: S,
702
+ title: "下载 PNG",
703
+ "aria-label": "下载"
704
+ },
705
+ t(J)
706
+ )
707
+ ] : null,
708
+ l.value === "code" ? t(
709
+ "button",
710
+ {
711
+ type: "button",
712
+ class: `md-mermaid-toolbar-btn${s.value ? " md-mermaid-toolbar-btn--success" : ""}`,
713
+ onClick: L,
714
+ title: s.value ? "已复制" : "复制代码",
715
+ "aria-label": s.value ? "已复制" : "复制代码"
716
+ },
717
+ s.value ? t(ye) : t(he)
718
+ ) : null
719
+ ])
720
+ ]) : null;
721
+ let b;
722
+ return o.value ? b = t("div", { class: "md-mermaid-skeleton" }, [
723
+ t("div", { class: "md-mermaid-skeleton-box" })
724
+ ]) : l.value === "preview" && x.value ? b = t("div", { class: "md-mermaid-preview", style: { overflow: "hidden" } }, [
725
+ t("div", {
726
+ class: "md-mermaid-svg-container",
727
+ style: h.value,
728
+ innerHTML: r.value.svg
729
+ })
730
+ ]) : b = t("div", { class: "md-mermaid-code" }, [
731
+ t("pre", [t("code", { class: "language-mermaid" }, e.code)]),
732
+ // 错误提示 - 仅在非流式或流式完成时显示
733
+ r.value && !r.value.success && e.streamStatus === "done" ? t("div", { class: "md-mermaid-error" }, [
734
+ t("span", "渲染失败: "),
735
+ t("span", r.value.error)
736
+ ]) : null
737
+ ]), t("div", { class: "md-mermaid-block" }, [
738
+ m,
739
+ t("div", { class: "md-mermaid-content" }, [b]),
740
+ // 全屏查看器
741
+ x.value ? t(ge, {
742
+ svg: r.value.svg,
743
+ open: a.value,
744
+ onClose: () => a.value = !1,
745
+ onDownload: S
746
+ }) : null
747
+ ]);
748
+ };
749
+ }
750
+ });
751
+ function xe(e) {
752
+ var r;
753
+ if (e.tagName !== "pre") return !1;
754
+ const n = e.children.find(
755
+ (o) => o.type === "element" && o.tagName === "code"
756
+ );
757
+ if (!n) return !1;
758
+ const l = (r = n.properties) == null ? void 0 : r.className;
759
+ return Array.isArray(l) ? l.some((o) => typeof o == "string" && o.includes("language-mermaid")) : typeof l == "string" && l.includes("language-mermaid");
760
+ }
761
+ function Me(e) {
762
+ const n = e.children.find(
763
+ (l) => l.type === "element" && l.tagName === "code"
764
+ );
765
+ return n ? n.children.map((l) => l.type === "text" ? l.value : "").join("") : "";
766
+ }
767
+ function Se(e) {
768
+ return e ? e === !0 ? { enabled: !0 } : e.enabled !== !1 ? e : null : null;
769
+ }
770
+ const Q = C({
97
771
  name: "Markdown",
98
772
  props: {
99
773
  content: {
@@ -131,177 +805,190 @@ const L = A({
131
805
  copyButton: {
132
806
  type: Boolean,
133
807
  default: !0
808
+ },
809
+ mermaid: {
810
+ type: [Boolean, Object],
811
+ default: !1
134
812
  }
135
813
  },
136
814
  emits: ["codeCopy"],
137
- setup(e, { emit: t }) {
138
- w(
815
+ setup(e, { emit: n }) {
816
+ T(
139
817
  () => e.math,
140
- (u) => {
141
- u && R();
818
+ (o) => {
819
+ o && Y();
142
820
  },
143
821
  { immediate: !0 }
144
822
  );
145
- function l(u, r = {}) {
146
- if (u.type === "text")
147
- return u.value;
148
- if (u.type === "comment")
823
+ function l(o, a = {}, s = null) {
824
+ if (o.type === "text")
825
+ return o.value;
826
+ if (o.type === "comment")
149
827
  return null;
150
- if (u.type === "root") {
151
- const n = u.children.map((s) => l(s, r)).filter((s) => s !== null);
152
- return f("div", { class: e.class }, n);
828
+ if (o.type === "root") {
829
+ const i = o.children.map((u) => l(u, a, s)).filter((u) => u !== null);
830
+ return t("div", { class: e.class }, i);
153
831
  }
154
- if (u.type === "element") {
155
- const { tagName: n, properties: s, children: o } = u, m = r[n] || n, d = {};
156
- if (s)
157
- for (const [i, c] of Object.entries(s))
158
- i === "className" ? d.class = Array.isArray(c) ? c.join(" ") : c : d[i] = c;
159
- const v = o.map((i) => l(i, r)).filter((i) => i !== null);
160
- return typeof m == "string" ? f(m, d, v) : f(m, d, () => v);
832
+ if (o.type === "element") {
833
+ const { tagName: i, properties: u, children: c } = o;
834
+ if (s && xe(o)) {
835
+ const d = Me(o);
836
+ return t(ke, {
837
+ code: d,
838
+ theme: s.theme,
839
+ onCopy: (p) => n("codeCopy", p)
840
+ });
841
+ }
842
+ const f = a[i] || i, g = {};
843
+ if (u)
844
+ for (const [d, p] of Object.entries(u))
845
+ d === "className" ? g.class = Array.isArray(p) ? p.join(" ") : p : g[d] = p;
846
+ const v = c.map((d) => l(d, a, s)).filter((d) => d !== null);
847
+ return typeof f == "string" ? t(f, g, v) : t(f, g, () => v);
161
848
  }
162
849
  return null;
163
850
  }
164
- const a = B(() => {
851
+ const r = N(() => {
165
852
  if (!e.content) return null;
166
- const u = P(e.content, {
853
+ const o = j(e.content, {
167
854
  gfm: e.gfm,
168
855
  highlight: e.highlight,
169
856
  math: e.math,
170
857
  remarkPlugins: e.remarkPlugins,
171
858
  rehypePlugins: e.rehypePlugins
172
- }), r = {
859
+ }), a = Se(e.mermaid), s = {
173
860
  ...e.copyButton ? {
174
- pre: A({
175
- setup(n, { slots: s }) {
176
- return () => f(
177
- L,
861
+ pre: C({
862
+ setup(i, { slots: u }) {
863
+ return () => t(
864
+ q,
178
865
  {
179
866
  showCopyButton: e.copyButton,
180
- onCopy: (o) => t("codeCopy", o)
867
+ onCopy: (c) => n("codeCopy", c)
181
868
  },
182
- s.default
869
+ u.default
183
870
  );
184
871
  }
185
872
  })
186
873
  } : {},
187
874
  ...e.components
188
875
  };
189
- return l(u, r);
876
+ return l(o, s, a);
190
877
  });
191
- return () => a.value ? a.value : null;
878
+ return () => r.value ? r.value : null;
192
879
  }
193
880
  });
194
- function j(e, t) {
881
+ function D(e, n) {
195
882
  if (e.type === "text")
196
883
  return e.value;
197
884
  if (e.type === "root") {
198
- const l = e.children.map((a) => j(a, t)).filter((a) => a !== null);
199
- return f("div", {}, l);
885
+ const l = e.children.map((r) => D(r, n)).filter((r) => r !== null);
886
+ return t("div", {}, l);
200
887
  }
201
888
  if (e.type === "element") {
202
- const l = e, a = l.tagName, u = t == null ? void 0 : t[a], r = { ...l.properties };
203
- r.className && (r.class = Array.isArray(r.className) ? r.className.join(" ") : r.className, delete r.className);
204
- const n = l.children.map((s) => j(s, t)).filter((s) => s !== null);
205
- return u ? f(u, r, () => n) : f(a, r, n);
889
+ const l = e, r = l.tagName, o = n == null ? void 0 : n[r], a = { ...l.properties };
890
+ a.className && (a.class = Array.isArray(a.className) ? a.className.join(" ") : a.className, delete a.className);
891
+ const s = l.children.map((i) => D(i, n)).filter((i) => i !== null);
892
+ return o ? t(o, a, () => s) : t(r, a, s);
206
893
  }
207
894
  return null;
208
895
  }
209
- function ae(e = {}) {
896
+ function Ve(e = {}) {
210
897
  const {
211
- components: t,
898
+ components: n,
212
899
  minUpdateInterval: l = 16,
213
- immediate: a = !1,
214
- outputRate: u = "medium",
215
- ...r
216
- } = e, n = F(r), s = new O(u), o = h(0), m = h(!1), d = h(0), v = h("idle");
217
- let i = 0, c = null;
218
- const y = () => {
219
- const g = performance.now(), N = g - i;
220
- a || N >= l ? (i = g, o.value++) : c === null && (c = requestAnimationFrame(() => {
221
- c = null, i = performance.now(), o.value++;
900
+ immediate: r = !1,
901
+ outputRate: o = "medium",
902
+ ...a
903
+ } = e, s = P(a), i = new U(o), u = y(0), c = y(!1), f = y(0), g = y("idle");
904
+ let v = 0, d = null;
905
+ const p = () => {
906
+ const z = performance.now(), V = z - v;
907
+ r || V >= l ? (v = z, u.value++) : d === null && (d = requestAnimationFrame(() => {
908
+ d = null, v = performance.now(), u.value++;
222
909
  }));
223
- }, k = (g) => {
224
- n.append(g), y();
225
- }, p = (g) => {
226
- n.reset(), m.value = !1, d.value = 0, v.value = "running", s.start(
227
- g,
228
- (N) => {
229
- N && n.append(N), d.value = s.progress, y();
910
+ }, M = (z) => {
911
+ s.append(z), p();
912
+ }, h = (z) => {
913
+ s.reset(), c.value = !1, f.value = 0, g.value = "running", i.start(
914
+ z,
915
+ (V) => {
916
+ V && s.append(V), f.value = i.progress, p();
230
917
  },
231
918
  () => {
232
- n.finish(), m.value = !0, d.value = 1, v.value = "complete", y();
919
+ s.finish(), c.value = !0, f.value = 1, g.value = "complete", p();
233
920
  }
234
921
  );
235
- }, S = () => {
236
- s.pause(), v.value = s.status;
237
- }, b = () => {
238
- s.resume(), v.value = s.status;
239
- }, H = () => {
240
- s.skipToEnd(), v.value = s.status, d.value = 1;
241
- }, q = () => {
242
- s.stop(), n.finish(), m.value = !0, v.value = "complete", c !== null && (cancelAnimationFrame(c), c = null), o.value++;
243
- }, K = () => {
244
- s.stop(), n.reset(), m.value = !1, d.value = 0, v.value = "idle", c !== null && (cancelAnimationFrame(c), c = null), o.value++;
922
+ }, x = () => {
923
+ i.pause(), g.value = i.status;
924
+ }, w = () => {
925
+ i.resume(), g.value = i.status;
926
+ }, B = () => {
927
+ i.skipToEnd(), g.value = i.status, f.value = 1;
928
+ }, I = () => {
929
+ i.stop(), s.finish(), c.value = !0, g.value = "complete", d !== null && (cancelAnimationFrame(d), d = null), u.value++;
930
+ }, L = () => {
931
+ i.stop(), s.reset(), c.value = !1, f.value = 0, g.value = "idle", d !== null && (cancelAnimationFrame(d), d = null), u.value++;
245
932
  };
246
- U(() => {
247
- s.stop(), c !== null && cancelAnimationFrame(c);
933
+ E(() => {
934
+ i.stop(), d !== null && cancelAnimationFrame(d);
248
935
  });
249
- const $ = B(() => (o.value, n.getState().blocks)), W = B(() => (o.value, n.getStats())), _ = B(() => (o.value, n.getContent()));
936
+ const S = N(() => (u.value, s.getState().blocks)), m = N(() => (u.value, s.getStats())), b = N(() => (u.value, s.getContent()));
250
937
  return {
251
- vnode: B(() => {
252
- o.value;
253
- const g = n.getState();
254
- if (g.blocks.length === 0)
938
+ vnode: N(() => {
939
+ u.value;
940
+ const z = s.getState();
941
+ if (z.blocks.length === 0)
255
942
  return null;
256
- const N = g.blocks.map((C) => C.hast ? f(
943
+ const V = z.blocks.map((H) => H.hast ? t(
257
944
  "div",
258
945
  {
259
- key: C.key,
260
- "data-block-key": C.key,
261
- "data-pending": !C.stable || void 0
946
+ key: H.key,
947
+ "data-block-key": H.key,
948
+ "data-pending": !H.stable || void 0
262
949
  },
263
- [j(C.hast, t)]
264
- ) : null).filter((C) => C !== null);
265
- return f("div", { "data-streaming": !m.value }, N);
950
+ [D(H.hast, n)]
951
+ ) : null).filter((H) => H !== null);
952
+ return t("div", { "data-streaming": !c.value }, V);
266
953
  }),
267
- append: k,
268
- start: p,
269
- pause: S,
270
- resume: b,
271
- skipToEnd: H,
272
- reset: K,
273
- finish: q,
274
- blocks: $,
275
- stats: W,
276
- isComplete: m,
277
- content: _,
278
- progress: d,
279
- outputStatus: v
954
+ append: M,
955
+ start: h,
956
+ pause: x,
957
+ resume: w,
958
+ skipToEnd: B,
959
+ reset: L,
960
+ finish: I,
961
+ blocks: S,
962
+ stats: m,
963
+ isComplete: c,
964
+ content: b,
965
+ progress: f,
966
+ outputStatus: g
280
967
  };
281
968
  }
282
- function V(e, t, l, a, u) {
969
+ function O(e, n, l, r, o) {
283
970
  if (e.type === "text")
284
971
  return e.value;
285
972
  if (e.type === "root") {
286
- const r = e.children.map((n) => V(n, t, l, a, u)).filter((n) => n !== null);
287
- return f("div", {}, r);
973
+ const a = e.children.map((s) => O(s, n, l, r, o)).filter((s) => s !== null);
974
+ return t("div", {}, a);
288
975
  }
289
976
  if (e.type === "element") {
290
- const r = e, n = r.tagName, s = t == null ? void 0 : t[n], o = { ...r.properties };
291
- o.className && (o.class = Array.isArray(o.className) ? o.className.join(" ") : o.className, delete o.className);
292
- const m = r.children.map((d) => V(d, t, l, a, u)).filter((d) => d !== null);
293
- return n === "pre" && l && !s ? f(
294
- L,
977
+ const a = e, s = a.tagName, i = n == null ? void 0 : n[s], u = { ...a.properties };
978
+ u.className && (u.class = Array.isArray(u.className) ? u.className.join(" ") : u.className, delete u.className);
979
+ const c = a.children.map((f) => O(f, n, l, r, o)).filter((f) => f !== null);
980
+ return s === "pre" && l && !i ? t(
981
+ q,
295
982
  {
296
- showCopyButton: u && l,
297
- onCopy: a
983
+ showCopyButton: o && l,
984
+ onCopy: r
298
985
  },
299
- () => m
300
- ) : s ? f(s, o, () => m) : f(n, o, m);
986
+ () => c
987
+ ) : i ? t(i, u, () => c) : t(s, u, c);
301
988
  }
302
989
  return null;
303
990
  }
304
- const E = A({
991
+ const ee = C({
305
992
  name: "StreamingMarkdown",
306
993
  props: {
307
994
  content: {
@@ -354,139 +1041,142 @@ const E = A({
354
1041
  }
355
1042
  },
356
1043
  emits: ["complete", "blockStable", "progress", "codeCopy"],
357
- setup(e, { emit: t }) {
358
- w(
1044
+ setup(e, { emit: n }) {
1045
+ T(
359
1046
  () => e.math,
360
- (i) => {
361
- i && R();
1047
+ (v) => {
1048
+ v && Y();
362
1049
  },
363
1050
  { immediate: !0 }
364
1051
  );
365
- const l = F({
1052
+ const l = P({
366
1053
  gfm: e.gfm,
367
1054
  highlight: e.highlight,
368
1055
  math: e.math
369
- }), a = new O(e.outputRate), u = h(0), r = h(""), n = h(void 0), s = h([]), o = h(!1);
370
- let m = 0, d = null;
371
- const v = () => {
372
- const i = performance.now();
373
- i - m >= e.minUpdateInterval ? (m = i, u.value++) : d === null && (d = requestAnimationFrame(() => {
374
- d = null, m = performance.now(), u.value++;
1056
+ }), r = new U(e.outputRate), o = y(0), a = y(""), s = y(void 0), i = y([]), u = y(!1);
1057
+ let c = 0, f = null;
1058
+ const g = () => {
1059
+ const v = performance.now();
1060
+ v - c >= e.minUpdateInterval ? (c = v, o.value++) : f === null && (f = requestAnimationFrame(() => {
1061
+ f = null, c = performance.now(), o.value++;
375
1062
  }));
376
1063
  };
377
- return w(
1064
+ return T(
378
1065
  () => e.source,
379
- (i) => {
380
- i !== void 0 && i !== n.value && (n.value = i, e.autoStart && i && (l.reset(), r.value = "", o.value = !1, a.start(
381
- i,
382
- (c) => {
383
- c && (l.append(c), r.value += c), t("progress", a.progress), v();
1066
+ (v) => {
1067
+ v !== void 0 && v !== s.value && (s.value = v, e.autoStart && v && (l.reset(), a.value = "", u.value = !1, r.start(
1068
+ v,
1069
+ (d) => {
1070
+ d && (l.append(d), a.value += d), n("progress", r.progress), g();
384
1071
  },
385
1072
  () => {
386
- l.finish(), o.value = !0, t("complete"), v();
1073
+ l.finish(), u.value = !0, n("complete"), g();
387
1074
  }
388
1075
  )));
389
1076
  },
390
1077
  { immediate: !0 }
391
- ), w(
1078
+ ), T(
392
1079
  () => e.content,
393
- (i) => {
1080
+ (v) => {
394
1081
  if (e.source !== void 0)
395
1082
  return;
396
- const c = r.value, y = i || "";
397
- if (y !== c) {
398
- if (y.startsWith(c)) {
399
- const p = y.slice(c.length);
400
- p && l.append(p);
1083
+ const d = a.value, p = v || "";
1084
+ if (p !== d) {
1085
+ if (p.startsWith(d)) {
1086
+ const h = p.slice(d.length);
1087
+ h && l.append(h);
401
1088
  } else
402
- l.reset(), y && l.append(y);
403
- r.value = y, v();
404
- const k = l.getState().blocks;
405
- k.forEach((p, S) => {
406
- const b = s.value[S];
407
- p.stable && (!b || !b.stable) && t("blockStable", p);
408
- }), s.value = k;
1089
+ l.reset(), p && l.append(p);
1090
+ a.value = p, g();
1091
+ const M = l.getState().blocks;
1092
+ M.forEach((h, x) => {
1093
+ const w = i.value[x];
1094
+ h.stable && (!w || !w.stable) && n("blockStable", h);
1095
+ }), i.value = M;
409
1096
  }
410
1097
  },
411
1098
  { immediate: !0 }
412
- ), w(
1099
+ ), T(
413
1100
  () => e.isComplete,
414
- (i) => {
415
- e.source === void 0 && i && (l.finish(), d !== null && (cancelAnimationFrame(d), d = null), u.value++, t("complete"));
1101
+ (v) => {
1102
+ e.source === void 0 && v && (l.finish(), f !== null && (cancelAnimationFrame(f), f = null), o.value++, n("complete"));
416
1103
  }
417
- ), w(
1104
+ ), T(
418
1105
  () => e.outputRate,
419
- (i) => {
420
- a.setRate(i);
1106
+ (v) => {
1107
+ r.setRate(v);
421
1108
  }
422
- ), U(() => {
423
- a.stop(), d !== null && cancelAnimationFrame(d);
1109
+ ), E(() => {
1110
+ r.stop(), f !== null && cancelAnimationFrame(f);
424
1111
  }), () => {
425
- u.value;
426
- const i = l.getState(), c = e.source !== void 0 ? o.value : e.isComplete, y = (p) => t("codeCopy", p), k = i.blocks.map((p) => p.hast ? f(
1112
+ o.value;
1113
+ const v = l.getState(), d = e.source !== void 0 ? u.value : e.isComplete, p = (h) => n("codeCopy", h), M = v.blocks.map((h) => h.hast ? t(
427
1114
  "div",
428
1115
  {
429
- key: p.key,
430
- "data-block-key": p.key,
431
- "data-pending": !p.stable || void 0
1116
+ key: h.key,
1117
+ "data-block-key": h.key,
1118
+ "data-pending": !h.stable || void 0
432
1119
  },
433
- [V(p.hast, e.components, e.copyButton, y, p.stable)]
434
- ) : null).filter((p) => p !== null);
435
- return f(
1120
+ [O(h.hast, e.components, e.copyButton, p, h.stable)]
1121
+ ) : null).filter((h) => h !== null);
1122
+ return t(
436
1123
  "div",
437
1124
  {
438
1125
  class: e.class,
439
- "data-streaming": !c
1126
+ "data-streaming": !d
440
1127
  },
441
- k
1128
+ M
442
1129
  );
443
1130
  };
444
1131
  }
445
1132
  });
446
- function M(e, t = {}) {
1133
+ function Z(e, n = {}) {
447
1134
  if (e.type === "text")
448
1135
  return e.value;
449
1136
  if (e.type === "comment")
450
1137
  return null;
451
1138
  if (e.type === "root") {
452
- const l = e.children.map((a) => M(a, t)).filter((a) => a !== null);
453
- return f("div", {}, l);
1139
+ const l = e.children.map((r) => Z(r, n)).filter((r) => r !== null);
1140
+ return t("div", {}, l);
454
1141
  }
455
1142
  if (e.type === "element") {
456
- const { tagName: l, properties: a, children: u } = e, r = t[l] || l, n = {};
457
- if (a)
458
- for (const [o, m] of Object.entries(a))
459
- o === "className" ? n.class = Array.isArray(m) ? m.join(" ") : m : n[o] = m;
460
- const s = u.map((o) => M(o, t)).filter((o) => o !== null);
461
- return f(r, n, () => s);
1143
+ const { tagName: l, properties: r, children: o } = e, a = n[l] || l, s = {};
1144
+ if (r)
1145
+ for (const [u, c] of Object.entries(r))
1146
+ u === "className" ? s.class = Array.isArray(c) ? c.join(" ") : c : s[u] = c;
1147
+ const i = o.map((u) => Z(u, n)).filter((u) => u !== null);
1148
+ return t(a, s, () => i);
462
1149
  }
463
1150
  return null;
464
1151
  }
465
- function re(e, t = {}) {
466
- const { components: l = {}, ...a } = t;
467
- return B(() => {
468
- const u = e();
469
- if (!u) return null;
470
- const r = P(u, a);
471
- return M(r, l);
1152
+ function Te(e, n = {}) {
1153
+ const { components: l = {}, ...r } = n;
1154
+ return N(() => {
1155
+ const o = e();
1156
+ if (!o) return null;
1157
+ const a = j(o, r);
1158
+ return Z(a, l);
472
1159
  });
473
1160
  }
474
- function Y(e) {
475
- e.component("Markdown", z), e.component("StreamingMarkdown", E);
1161
+ function ze(e) {
1162
+ e.component("Markdown", Q), e.component("StreamingMarkdown", ee);
476
1163
  }
477
- const le = {
478
- install: Y,
479
- Markdown: z,
480
- StreamingMarkdown: E
1164
+ const Le = {
1165
+ install: ze,
1166
+ Markdown: Q,
1167
+ StreamingMarkdown: ee
481
1168
  };
482
1169
  export {
483
- L as CodeBlock,
484
- z as Markdown,
485
- E as StreamingMarkdown,
486
- le as default,
487
- Y as install,
488
- ne as isKatexCssLoaded,
489
- R as preloadKatexCss,
490
- re as useMarkdown,
491
- ae as useStreamingMarkdown
1170
+ q as CodeBlock,
1171
+ Q as Markdown,
1172
+ ke as MermaidBlock,
1173
+ ge as MermaidFullscreenViewer,
1174
+ ee as StreamingMarkdown,
1175
+ Le as default,
1176
+ ze as install,
1177
+ Ne as isKatexCssLoaded,
1178
+ Y as preloadKatexCss,
1179
+ Te as useMarkdown,
1180
+ Ve as useStreamingMarkdown,
1181
+ W as useZoom
492
1182
  };