markdown-flow-ui 0.2.29 → 0.2.31

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 (94) hide show
  1. package/README.md +28 -0
  2. package/dist/_virtual/index.es5.js +5 -3
  3. package/dist/_virtual/index.es5.js.map +1 -1
  4. package/dist/_virtual/index.es6.js +3 -5
  5. package/dist/_virtual/index.es6.js.map +1 -1
  6. package/dist/_virtual/index.es7.js +4 -4
  7. package/dist/_virtual/index5.cjs +1 -1
  8. package/dist/_virtual/index6.cjs +1 -1
  9. package/dist/_virtual/index7.cjs +1 -1
  10. package/dist/components/ContentRender/ContentRender.cjs +2 -2
  11. package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
  12. package/dist/components/ContentRender/ContentRender.d.ts +2 -0
  13. package/dist/components/ContentRender/ContentRender.es.js +595 -374
  14. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  15. package/dist/components/ContentRender/index.cjs +1 -1
  16. package/dist/components/ContentRender/index.es.js +1 -0
  17. package/dist/components/ContentRender/index.es.js.map +1 -1
  18. package/dist/components/ContentRender/utils/escape-typed-metadata.cjs +2 -0
  19. package/dist/components/ContentRender/utils/escape-typed-metadata.cjs.map +1 -0
  20. package/dist/components/ContentRender/utils/escape-typed-metadata.d.ts +9 -0
  21. package/dist/components/ContentRender/utils/escape-typed-metadata.es.js +47 -0
  22. package/dist/components/ContentRender/utils/escape-typed-metadata.es.js.map +1 -0
  23. package/dist/components/ContentRender/utils/escape-typed-metadata.test.d.ts +1 -0
  24. package/dist/components/ContentRender/utils/html-block-end.cjs +2 -0
  25. package/dist/components/ContentRender/utils/html-block-end.cjs.map +1 -0
  26. package/dist/components/ContentRender/utils/html-block-end.d.ts +20 -0
  27. package/dist/components/ContentRender/utils/html-block-end.es.js +111 -0
  28. package/dist/components/ContentRender/utils/html-block-end.es.js.map +1 -0
  29. package/dist/components/ContentRender/utils/html-block-end.test.d.ts +1 -0
  30. package/dist/components/ContentRender/utils/inline-code-ranges.cache.test.d.ts +1 -0
  31. package/dist/components/ContentRender/utils/inline-code-ranges.cjs +10 -0
  32. package/dist/components/ContentRender/utils/inline-code-ranges.cjs.map +1 -0
  33. package/dist/components/ContentRender/utils/inline-code-ranges.d.ts +39 -0
  34. package/dist/components/ContentRender/utils/inline-code-ranges.es.js +336 -0
  35. package/dist/components/ContentRender/utils/inline-code-ranges.es.js.map +1 -0
  36. package/dist/components/ContentRender/utils/inline-code-ranges.test.d.ts +1 -0
  37. package/dist/components/ContentRender/utils/markdown-plugins.cjs +2 -0
  38. package/dist/components/ContentRender/utils/markdown-plugins.cjs.map +1 -0
  39. package/dist/components/ContentRender/utils/markdown-plugins.d.ts +2 -0
  40. package/dist/components/ContentRender/utils/markdown-plugins.es.js +14 -0
  41. package/dist/components/ContentRender/utils/markdown-plugins.es.js.map +1 -0
  42. package/dist/components/ContentRender/utils/mermaid-parse.cjs +4 -3
  43. package/dist/components/ContentRender/utils/mermaid-parse.cjs.map +1 -1
  44. package/dist/components/ContentRender/utils/mermaid-parse.es.js +86 -67
  45. package/dist/components/ContentRender/utils/mermaid-parse.es.js.map +1 -1
  46. package/dist/components/ContentRender/utils/mermaid-parse.test.d.ts +1 -0
  47. package/dist/components/ContentRender/utils/normalize-inline-html.cjs +4 -2
  48. package/dist/components/ContentRender/utils/normalize-inline-html.cjs.map +1 -1
  49. package/dist/components/ContentRender/utils/normalize-inline-html.d.ts +4 -1
  50. package/dist/components/ContentRender/utils/normalize-inline-html.es.js +15 -7
  51. package/dist/components/ContentRender/utils/normalize-inline-html.es.js.map +1 -1
  52. package/dist/components/ContentRender/utils/normalize-inline-html.test.d.ts +1 -0
  53. package/dist/components/ContentRender/utils/resumed-prose-fence.cjs +5 -0
  54. package/dist/components/ContentRender/utils/resumed-prose-fence.cjs.map +1 -0
  55. package/dist/components/ContentRender/utils/resumed-prose-fence.d.ts +5 -0
  56. package/dist/components/ContentRender/utils/resumed-prose-fence.es.js +60 -0
  57. package/dist/components/ContentRender/utils/resumed-prose-fence.es.js.map +1 -0
  58. package/dist/components/ContentRender/utils/split-content.cjs +6 -3
  59. package/dist/components/ContentRender/utils/split-content.cjs.map +1 -1
  60. package/dist/components/ContentRender/utils/split-content.d.ts +7 -1
  61. package/dist/components/ContentRender/utils/split-content.es.js +475 -140
  62. package/dist/components/ContentRender/utils/split-content.es.js.map +1 -1
  63. package/dist/components/ContentRender/utils/split-content.image-alt.test.d.ts +1 -0
  64. package/dist/components/ContentRender/utils/split-content.resumed-fences.test.d.ts +1 -0
  65. package/dist/components/ContentRender/utils/video-markdown-run.cjs +14 -0
  66. package/dist/components/ContentRender/utils/video-markdown-run.cjs.map +1 -0
  67. package/dist/components/ContentRender/utils/video-markdown-run.d.ts +47 -0
  68. package/dist/components/ContentRender/utils/video-markdown-run.es.js +462 -0
  69. package/dist/components/ContentRender/utils/video-markdown-run.es.js.map +1 -0
  70. package/dist/components/ContentRender/utils/video-markdown-run.test.d.ts +1 -0
  71. package/dist/components/ContentRender/utils/wrapped-content.test.d.ts +1 -0
  72. package/dist/components/MarkdownFlow/MarkdownFlow.cjs +1 -1
  73. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.map +1 -1
  74. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +9 -8
  75. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  76. package/dist/components/Slide/Slide.cjs +1 -1
  77. package/dist/components/Slide/Slide.cjs.map +1 -1
  78. package/dist/components/Slide/Slide.es.js +3 -2
  79. package/dist/components/Slide/Slide.es.js.map +1 -1
  80. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
  81. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
  82. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.cjs +1 -1
  83. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.es.js +1 -1
  84. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.cjs +1 -1
  85. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.es.js +1 -1
  86. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.cjs +1 -1
  87. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.es.js +1 -1
  88. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.cjs +1 -1
  89. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.es.js +1 -1
  90. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.cjs +1 -1
  91. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.es.js +1 -1
  92. package/dist/node_modules/unified/lib/index.cjs +1 -1
  93. package/dist/node_modules/unified/lib/index.es.js +1 -1
  94. package/package.json +6 -1
@@ -1,378 +1,586 @@
1
- import { jsx as r, jsxs as He } from "react/jsx-runtime";
2
- import Q, { useMemo as C, useState as be, useRef as v, useEffect as P } from "react";
3
- import qe from "../../_virtual/index.es.js";
4
- import { sanitizeInvalidTagName as Pe } from "./utils/sanitize-invalid-tag-name.es.js";
5
- import { stripSvgTextLineBreaks as Qe } from "./utils/strip-svg-text-line-breaks.es.js";
1
+ import { jsx as r, jsxs as ze, Fragment as ut } from "react/jsx-runtime";
2
+ import Z, { useMemo as h, useState as Fe, useRef as b, useEffect as te } from "react";
3
+ import { sanitizeInvalidTagName as lt } from "./utils/sanitize-invalid-tag-name.es.js";
4
+ import { stripSvgTextLineBreaks as dt } from "./utils/strip-svg-text-line-breaks.es.js";
6
5
  /* empty css */
7
6
  /* empty css */
8
7
  /* empty css */
9
8
  /* empty css */
10
- import je, { CodeBlockContext as Ue } from "./CodeBlock.es.js";
11
- import Ke from "./plugins/CustomVariable.es.js";
12
- import ie from "./plugins/MermaidChart.es.js";
13
- import { preserveCustomVariableProperties as Oe, restoreCustomVariableProperties as Xe } from "./utils/custom-variable-props.es.js";
14
- import { subsetLanguages as Ye, highlightLanguages as Ze } from "./utils/highlight-languages.es.js";
15
- import { parseMarkdownSegments as Be, mermaidBlockIsComplete as Je } from "./utils/mermaid-parse.es.js";
16
- import { normalizeInlineHtml as Se } from "./utils/normalize-inline-html.es.js";
17
- import et from "./IframeSandbox.es.js";
18
- import { getTrailingTypewriterGrapheme as ae, appendContentAwareTypewriterQueue as Re, consumeContentAwareTypewriterQueue as tt, CONTENT_AWARE_TYPEWRITER_TICK_BUDGET as rt, isContentAwareTypewriterQueueEmpty as nt } from "./utils/typewriter-pacing.es.js";
19
- import { splitContentSegments as ot } from "./utils/split-content.es.js";
20
- import { getInteractionDefaultValues as st } from "../../lib/interaction-defaults.es.js";
21
- import { getMarkdownFlowDirection as at, getMarkdownFlowLanguage as it } from "../../lib/locale.es.js";
22
- import { getContentRenderLocaleTexts as Le } from "./contentRenderI18n.es.js";
23
- import { Markdown as ct } from "../../node_modules/react-markdown/lib/index.es.js";
24
- import lt from "../../node_modules/rehype-raw/lib/index.es.js";
25
- import ut from "../../node_modules/rehype-highlight/lib/index.es.js";
26
- import dt from "../../node_modules/rehype-katex/lib/index.es.js";
27
- import mt from "../../node_modules/remark-gfm/lib/index.es.js";
28
- import pt from "../../node_modules/remark-math/lib/index.es.js";
29
- import ht from "../../node_modules/remark-breaks/lib/index.es.js";
30
- const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i, gt = 2, Ne = ({ svg: t }) => {
31
- const n = v(null);
32
- return P(() => {
33
- const o = n.current;
34
- if (!o) return;
35
- const s = o.shadowRoot ?? o.attachShadow({ mode: "open" }), k = "content-render-svg-style";
36
- let u = s.getElementById(k);
37
- u || (u = document.createElement("style"), u.id = k, u.textContent = `
9
+ import mt, { CodeBlockContext as pt } from "./CodeBlock.es.js";
10
+ import ft from "./plugins/CustomVariable.es.js";
11
+ import Ce from "./plugins/MermaidChart.es.js";
12
+ import { preserveCustomVariableProperties as ht, restoreCustomVariableProperties as gt } from "./utils/custom-variable-props.es.js";
13
+ import { subsetLanguages as vt, highlightLanguages as xt } from "./utils/highlight-languages.es.js";
14
+ import { parseMarkdownSegments as Ge, mermaidBlockIsComplete as yt } from "./utils/mermaid-parse.es.js";
15
+ import { getMarkdownSourceAnalysis as wt, getInlineCodeRanges as Ct } from "./utils/inline-code-ranges.es.js";
16
+ import { remarkPlugins as Qe } from "./utils/markdown-plugins.es.js";
17
+ import { normalizeInlineHtml as ye } from "./utils/normalize-inline-html.es.js";
18
+ import { escapeTypedMarkdownMetadata as ke } from "./utils/escape-typed-metadata.es.js";
19
+ import kt from "./IframeSandbox.es.js";
20
+ import { getTrailingTypewriterGrapheme as we, appendContentAwareTypewriterQueue as _e, consumeContentAwareTypewriterQueue as Tt, CONTENT_AWARE_TYPEWRITER_TICK_BUDGET as bt, isContentAwareTypewriterQueueEmpty as St } from "./utils/typewriter-pacing.es.js";
21
+ import { normalizeWrappedSandboxContent as Rt, splitContentSegments as Bt } from "./utils/split-content.es.js";
22
+ import { getInteractionDefaultValues as Nt } from "../../lib/interaction-defaults.es.js";
23
+ import { getMarkdownFlowDirection as Mt, getMarkdownFlowLanguage as Lt } from "../../lib/locale.es.js";
24
+ import { getContentRenderLocaleTexts as be } from "./contentRenderI18n.es.js";
25
+ import { createVideoMarkdownRunPlan as At, cloneVideoMarkdownSourceTree as Vt, prepareVideoMarkdownRun as $t, projectVideoMarkdownRun as Et, getVideoMarkdownNodeState as It } from "./utils/video-markdown-run.es.js";
26
+ import { unified as je } from "../../node_modules/unified/lib/index.es.js";
27
+ import Pt from "../../node_modules/remark-rehype/lib/index.es.js";
28
+ import Dt from "../../node_modules/rehype-raw/lib/index.es.js";
29
+ import Wt from "../../node_modules/rehype-highlight/lib/index.es.js";
30
+ import zt from "../../node_modules/rehype-katex/lib/index.es.js";
31
+ import { Markdown as Oe } from "../../node_modules/react-markdown/lib/index.es.js";
32
+ const Ft = 2, Te = ({
33
+ svg: t,
34
+ inline: o = !1
35
+ }) => {
36
+ const s = b(null), a = o ? "span" : "div";
37
+ return te(() => {
38
+ const i = s.current;
39
+ if (!i) return;
40
+ const l = i.shadowRoot ?? i.attachShadow({ mode: "open" }), x = "content-render-svg-style";
41
+ let g = l.getElementById(x);
42
+ g || (g = document.createElement("style"), g.id = x, g.textContent = `
38
43
  svg { height: auto; display: inline-block; }
39
44
  svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
40
45
  svg.content-render-svg-el--fixed { max-width: none; }
41
- `, s.appendChild(u)), Array.from(s.childNodes).filter(
42
- (a) => a !== u
43
- ).forEach((a) => s.removeChild(a));
44
- const G = document.createElement("template"), D = Qe(t);
45
- G.innerHTML = D, s.append(G.content.cloneNode(!0));
46
- let d = !1, F = !1;
47
- s.querySelectorAll("svg").forEach((a) => {
48
- const z = a.getAttribute("viewBox");
49
- if (!z) return;
50
- const W = z.trim().split(/[\s,]+/).map((T) => Number(T));
51
- if (W.length !== 4 || W.some(Number.isNaN)) return;
52
- const [, , E, S] = W, L = a.getAttribute("width"), V = a.getAttribute("height"), j = (T) => {
53
- if (!T) return !1;
54
- const c = T.trim().toLowerCase();
55
- return c === "auto" || c.endsWith("%");
56
- }, U = (T) => {
57
- if (!T) return null;
58
- const c = T.trim().toLowerCase();
59
- if (c === "auto" || c.endsWith("%"))
46
+ `, l.appendChild(g)), Array.from(l.childNodes).filter(
47
+ (u) => u !== g
48
+ ).forEach((u) => l.removeChild(u));
49
+ const y = document.createElement("template"), S = dt(t);
50
+ y.innerHTML = S, l.append(y.content.cloneNode(!0));
51
+ let R = !1, k = !1;
52
+ l.querySelectorAll("svg").forEach((u) => {
53
+ const P = u.getAttribute("viewBox");
54
+ if (!P) return;
55
+ const D = P.trim().split(/[\s,]+/).map((M) => Number(M));
56
+ if (D.length !== 4 || D.some(Number.isNaN)) return;
57
+ const [, , W, w] = D, O = u.getAttribute("width"), z = u.getAttribute("height"), U = (M) => {
58
+ if (!M) return !1;
59
+ const L = M.trim().toLowerCase();
60
+ return L === "auto" || L.endsWith("%");
61
+ }, ne = (M) => {
62
+ if (!M) return null;
63
+ const L = M.trim().toLowerCase();
64
+ if (L === "auto" || L.endsWith("%"))
60
65
  return null;
61
- const M = Number.parseFloat(c);
62
- return Number.isNaN(M) ? null : M;
63
- }, Y = j(L), Z = j(V), K = !L || L === "0", O = !V || V === "0", J = U(L), ee = U(V);
64
- if (Y || Z || K && O || J === E && ee === S) {
65
- d = !0, a.classList.add("content-render-svg-el--responsive"), a.classList.remove("content-render-svg-el--fixed"), a.style.width = "100%", a.style.height = "auto", !a.style.aspectRatio && S > 0 && (a.style.aspectRatio = `${E} / ${S}`);
66
+ const H = Number.parseFloat(L);
67
+ return Number.isNaN(H) ? null : H;
68
+ }, ue = U(O), le = U(z), re = !O || O === "0", oe = !z || z === "0", de = ne(O), se = ne(z);
69
+ if (ue || le || re && oe || de === W && se === w) {
70
+ R = !0, u.classList.add("content-render-svg-el--responsive"), u.classList.remove("content-render-svg-el--fixed"), u.style.width = "100%", u.style.height = "auto", !u.style.aspectRatio && w > 0 && (u.style.aspectRatio = `${W} / ${w}`);
66
71
  return;
67
72
  }
68
- F = !0, a.classList.add("content-render-svg-el--fixed"), a.classList.remove("content-render-svg-el--responsive"), K && E > 0 && a.setAttribute("width", `${E}`), O && S > 0 && a.setAttribute("height", `${S}`);
73
+ k = !0, u.classList.add("content-render-svg-el--fixed"), u.classList.remove("content-render-svg-el--responsive"), re && W > 0 && u.setAttribute("width", `${W}`), oe && w > 0 && u.setAttribute("height", `${w}`);
69
74
  });
70
- const _ = d && !F;
71
- o.classList.toggle("content-render-svg--responsive", _), o.classList.toggle("content-render-svg--fixed", !_);
72
- }, [t]), /* @__PURE__ */ r("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ r("div", { className: "content-render-svg", ref: n }) });
73
- }, ce = Q.createContext(
75
+ const p = R && !k;
76
+ i.classList.toggle("content-render-svg--responsive", p), i.classList.toggle("content-render-svg--fixed", !p);
77
+ }, [t]), /* @__PURE__ */ r(a, { className: "content-render-svg-scroll", children: /* @__PURE__ */ r(
78
+ a,
79
+ {
80
+ className: "content-render-svg",
81
+ ref: (i) => {
82
+ s.current = i;
83
+ }
84
+ }
85
+ ) });
86
+ }, ie = Z.createContext(
74
87
  null
75
- ), xt = (t) => {
76
- const n = Q.useContext(ce), o = Q.useContext(Ue);
77
- if (!n)
88
+ ), Ue = (t) => {
89
+ const { receivedTree: o, ...s } = t, a = Z.useContext(ie), i = Z.useContext(pt);
90
+ if (!a)
78
91
  throw new Error("Markdown code renderer requires ContentRender context.");
79
- const { className: s, children: k, ...u } = t;
80
- if (/language-(\w+)/.exec(s || "")?.[1] === "mermaid") {
81
- const D = k?.toString().replace(/\n$/, "") || "", d = Je(
82
- n.current.renderContent,
83
- D
92
+ const { className: l, children: x, ...g } = s;
93
+ if (/language-(\w+)/.exec(l || "")?.[1] === "mermaid") {
94
+ const S = x?.toString().replace(/\n$/, "") || "", R = yt(
95
+ a.current.renderContent,
96
+ S
84
97
  );
85
98
  return /* @__PURE__ */ r(
86
- ie,
99
+ Ce,
87
100
  {
88
- chart: D,
89
- frozen: d,
90
- messages: n.current.mermaidMessages
101
+ chart: S,
102
+ frozen: o ? !R : R,
103
+ messages: a.current.mermaidMessages
91
104
  }
92
105
  );
93
106
  }
94
107
  return /* @__PURE__ */ r(
95
108
  "code",
96
109
  {
97
- className: s,
98
- ...u,
99
- dir: u.dir ?? (o ? void 0 : "ltr"),
100
- children: k
110
+ className: l,
111
+ ...g,
112
+ dir: g.dir ?? (i ? void 0 : "ltr"),
113
+ children: x
101
114
  }
102
115
  );
103
- }, vt = [
104
- mt,
105
- pt,
106
- qe,
107
- ht
108
- ], Tt = [
109
- Oe,
116
+ }, Ke = [
117
+ ht,
118
+ Dt,
110
119
  lt,
111
- Pe,
112
- Xe,
113
- [ut, { languages: Ze, subset: Ye }],
114
- dt
115
- ], Ae = ({ content: t, components: n, locale: o }) => {
116
- const s = Le(o);
120
+ gt
121
+ ], Ye = [
122
+ [Wt, { languages: xt, subset: vt }],
123
+ zt
124
+ ], Gt = [
125
+ ...Ke,
126
+ ...Ye
127
+ ], He = ({ content: t, components: o, locale: s }) => {
128
+ const a = be(s);
117
129
  return /* @__PURE__ */ r("div", { className: "markdown-renderer", children: /* @__PURE__ */ r(
118
- ct,
130
+ Oe,
119
131
  {
120
- remarkPlugins: vt,
121
- rehypePlugins: Tt,
132
+ remarkPlugins: Qe,
133
+ rehypePlugins: Gt,
122
134
  remarkRehypeOptions: {
123
- footnoteLabel: s.footnoteLabel,
124
- footnoteBackLabel: (k, u) => {
125
- const A = String(k + 1) + (u > 1 ? `-${u}` : "");
126
- return s.footnoteBackLabel.replace("{reference}", A);
135
+ footnoteLabel: a.footnoteLabel,
136
+ footnoteBackLabel: (i, l) => {
137
+ const x = String(i + 1) + (l > 1 ? `-${l}` : "");
138
+ return a.footnoteBackLabel.replace("{reference}", x);
127
139
  }
128
140
  },
129
- components: n,
141
+ components: o,
130
142
  children: t
131
143
  }
132
144
  ) });
133
- }, yt = (t) => {
145
+ }, _t = function() {
146
+ this.parser = () => ({ type: "root", children: [] });
147
+ }, jt = ({ plan: t, renderedSegments: o, components: s, locale: a }) => {
148
+ const i = h(() => {
149
+ const S = be(a), R = je().use(Qe).use(Pt, {
150
+ allowDangerousHtml: !0,
151
+ footnoteLabel: S.footnoteLabel,
152
+ footnoteBackLabel: (u, P) => S.footnoteBackLabel.replace(
153
+ "{reference}",
154
+ String(u + 1) + (P > 1 ? `-${P}` : "")
155
+ )
156
+ }).use(Ke), k = je().use(Ye), p = R.runSync(
157
+ Vt(t),
158
+ t.markdownSource
159
+ );
160
+ return $t(
161
+ t,
162
+ p,
163
+ (u) => k.runSync(u, t.fullSource)
164
+ );
165
+ }, [t, a]), l = h(
166
+ () => Et(i, o),
167
+ [i, o]
168
+ ), x = b(s);
169
+ x.current = s;
170
+ const g = b(
171
+ /* @__PURE__ */ new Map()
172
+ ), ee = h(() => {
173
+ const S = /* @__PURE__ */ new Set(), R = (p) => {
174
+ p.type === "element" && S.add(p.tagName), "children" in p && p.children.forEach(R);
175
+ };
176
+ R(i.tree);
177
+ const k = {};
178
+ for (const p of S) {
179
+ if (!g.current.has(p)) {
180
+ const u = ({
181
+ node: P,
182
+ children: D,
183
+ ...W
184
+ }) => {
185
+ const w = It(P);
186
+ if (w?.svg)
187
+ return w.svgSource ? /* @__PURE__ */ r(Te, { svg: w.svgSource, inline: !0 }) : null;
188
+ if (w?.atomic)
189
+ return w.active ? /* @__PURE__ */ r(ut, { children: D }) : null;
190
+ if (w?.active === !1 && p !== "a") return null;
191
+ const z = x.current[p], U = w?.active === !1 ? { ...W, href: void 0, tabIndex: -1 } : W;
192
+ return z ? Z.createElement(
193
+ z,
194
+ {
195
+ ...U,
196
+ node: P,
197
+ ...z === Ue ? { receivedTree: !0 } : {}
198
+ },
199
+ D
200
+ ) : Z.createElement(p, U, D);
201
+ };
202
+ u.displayName = `StableMarkdown(${p})`, g.current.set(p, u);
203
+ }
204
+ k[p] = g.current.get(p);
205
+ }
206
+ return k;
207
+ }, [i]), y = h(
208
+ () => [() => () => l],
209
+ [l]
210
+ );
211
+ return /* @__PURE__ */ r("div", { className: "markdown-renderer", children: /* @__PURE__ */ r(
212
+ Oe,
213
+ {
214
+ remarkPlugins: [_t],
215
+ rehypePlugins: y,
216
+ components: ee,
217
+ children: ""
218
+ }
219
+ ) });
220
+ }, j = (t) => t.type === "markdown" && t.immediate === !0, Ht = (t) => {
134
221
  if (t.length <= 1) return t;
135
- const n = [];
136
- return t.forEach((o) => {
137
- if (o.type === "sandbox") {
138
- n.push(o);
222
+ const o = [];
223
+ return t.forEach((s) => {
224
+ if (s.type === "sandbox" || j(s)) {
225
+ o.push(s);
139
226
  return;
140
227
  }
141
- const s = n[n.length - 1];
142
- if (s && s.type !== "sandbox") {
143
- n[n.length - 1] = {
228
+ const a = o[o.length - 1];
229
+ if (a && a.type !== "sandbox" && !j(a)) {
230
+ o[o.length - 1] = {
144
231
  type: "markdown",
145
- value: `${s.value}${o.value}`
232
+ value: `${a.value}${s.value}`
146
233
  };
147
234
  return;
148
235
  }
149
- n.push({ type: "markdown", value: o.value });
150
- }), n;
151
- }, Ct = (t, n) => {
152
- const o = Math.max(1, n), s = Array.from(t);
236
+ o.push({ type: "markdown", value: s.value });
237
+ }), o;
238
+ }, qt = (t, o, s) => {
239
+ if (t.length >= o.length) return t;
240
+ const a = s.find(
241
+ ({ start: x, end: g }) => x < t.length && t.length < g
242
+ );
243
+ if (!a) return t;
244
+ const i = /^`+/.exec(o.slice(a.start))?.[0];
245
+ if (!i || t.length < a.start + i.length)
246
+ return t;
247
+ const l = a.end - i.length;
248
+ return t.length > l ? t + i.slice(t.length - l) : t + (t.endsWith("`") ? " " : "") + i;
249
+ }, qe = (t, o, s, a, i = 0) => {
250
+ const l = qt(t, o, s);
251
+ return ke(t, a, i) + l.slice(t.length);
252
+ }, Qt = (t, o) => {
253
+ const s = Math.max(1, o), a = Array.from(t);
153
254
  return {
154
- chunk: s.slice(0, o).join(""),
155
- rest: s.slice(o).join("")
255
+ chunk: a.slice(0, s).join(""),
256
+ rest: a.slice(s).join("")
156
257
  };
157
- }, kt = (t, n) => t === n ? !0 : !t || !n || t.length !== n.length ? !1 : t.every((o, s) => o === n[s]), wt = (t) => {
158
- const n = v(t);
159
- return kt(n.current, t) || (n.current = t), n.current;
160
- }, tr = ({
258
+ }, Ot = (t, o) => t === o ? !0 : !t || !o || t.length !== o.length ? !1 : t.every((s, a) => s === o[a]), Ut = (t) => {
259
+ const o = b(t);
260
+ return Ot(o.current, t) || (o.current = t), o.current;
261
+ }, Mn = ({
161
262
  content: t,
162
- contentType: n,
163
- locale: o,
164
- lang: s,
165
- dir: k,
166
- customRenderBar: u,
167
- onSend: A,
168
- typingSpeed: G = 30,
169
- enableTypewriter: D = !1,
170
- typewriterPacing: d = "fixed",
171
- onTypeFinished: F,
172
- onTypewriterStateChange: _,
173
- userInput: a,
174
- interactionDefaultValueOptions: z,
175
- defaultButtonText: W,
176
- defaultInputText: E,
177
- defaultSelectedValues: S,
178
- readonly: L = !1,
179
- confirmButtonText: V,
180
- copyButtonText: j,
181
- copiedButtonText: U,
182
- sandboxLoadingText: Y,
183
- sandboxStyleLoadingText: Z,
184
- sandboxScriptLoadingText: K,
185
- disableSandboxLoadingOverlay: O = !1,
186
- sandboxFullscreenButtonText: J,
187
- sandboxExitFullscreenButtonText: ee,
188
- sandboxMode: le = "content",
189
- onClickCustomButtonAfterContent: te,
190
- beforeSend: T
263
+ contentType: o,
264
+ locale: s,
265
+ lang: a,
266
+ dir: i,
267
+ customRenderBar: l,
268
+ onSend: x,
269
+ typingSpeed: g = 30,
270
+ enableTypewriter: ee = !1,
271
+ typewriterPacing: y = "fixed",
272
+ onTypeFinished: S,
273
+ onTypewriterStateChange: R,
274
+ userInput: k,
275
+ interactionDefaultValueOptions: p,
276
+ defaultButtonText: u,
277
+ defaultInputText: P,
278
+ defaultSelectedValues: D,
279
+ readonly: W = !1,
280
+ confirmButtonText: w,
281
+ copyButtonText: O,
282
+ copiedButtonText: z,
283
+ sandboxLoadingText: U,
284
+ sandboxStyleLoadingText: ne,
285
+ sandboxScriptLoadingText: ue,
286
+ disableSandboxLoadingOverlay: le = !1,
287
+ sandboxFullscreenButtonText: re,
288
+ sandboxExitFullscreenButtonText: oe,
289
+ sandboxMode: de = "content",
290
+ onClickCustomButtonAfterContent: se,
291
+ beforeSend: me
191
292
  // tooltipMinLength,
192
293
  }) => {
193
- const c = Le(o), M = C(
294
+ const F = be(s), M = h(
194
295
  () => ({
195
- loading: c.mermaidLoadingText,
196
- emptyChart: c.mermaidEmptyChartText,
197
- error: c.mermaidErrorText
296
+ loading: F.mermaidLoadingText,
297
+ emptyChart: F.mermaidEmptyChartText,
298
+ error: F.mermaidErrorText
198
299
  }),
199
- [c]
200
- ), H = k ?? at(o), q = s ?? it(o), ue = V || c.confirmButtonText, de = j || c.copyButtonText, me = U || c.copiedButtonText, Me = J || c.sandboxFullscreenButtonText, $e = ee || c.sandboxExitFullscreenButtonText, m = !!D && (!n || n === "text"), pe = Math.max(0, G), De = d === "fixed" ? t : void 0, [w, he] = be(
201
- () => m ? "" : t
202
- ), X = v(w), h = v(""), g = v({
300
+ [F]
301
+ ), L = i ?? Mt(s), H = a ?? Lt(s), Se = w || F.confirmButtonText, Re = O || F.copyButtonText, Be = z || F.copiedButtonText, Xe = re || F.sandboxFullscreenButtonText, Ze = oe || F.sandboxExitFullscreenButtonText, m = !!ee && (!o || o === "text"), B = h(
302
+ () => Rt(t),
303
+ [t]
304
+ ), A = h(
305
+ () => wt(B),
306
+ [B]
307
+ ), T = h(() => {
308
+ const e = Ht(
309
+ Bt(B, !0, !0, A)
310
+ );
311
+ return B !== t && e.length && (e[0].type === "sandbox" || j(e[0])) ? [{ type: "text", value: "" }, ...e] : e;
312
+ }, [t, B, A]), K = T.some(
313
+ (e) => e.type === "sandbox" || j(e)
314
+ ), f = K ? T.filter(
315
+ (e) => e.type !== "sandbox" && !j(e)
316
+ ).map((e) => e.value).join("") : B, Ne = Math.max(0, g), Je = y === "fixed" ? f : void 0, [E, Me] = Fe(
317
+ () => m ? "" : f
318
+ ), ae = b(E), V = b(""), I = b({
203
319
  tokens: [],
204
320
  head: 0,
205
321
  trailingGrapheme: ""
206
- }), R = v(0), fe = v(m), ge = v(d), xe = v(t), re = v(!1), [Ee, Ve] = be(0);
207
- P(() => {
208
- const e = fe.current, i = ge.current, p = xe.current, b = !!h.current;
209
- fe.current = m, ge.current = d, xe.current = t, (t !== p || m !== e) && (re.current = !1);
210
- const f = () => {
211
- h.current = "", g.current = {
322
+ }), q = b(0), Le = b(m), Ae = b(y), Ve = b(f), pe = b(t), fe = b(!1), [et, tt] = Fe(0);
323
+ te(() => {
324
+ const e = Le.current, n = Ae.current, c = Ve.current, d = !!V.current, C = pe.current !== t, xe = C && t.startsWith(pe.current);
325
+ pe.current = t, Le.current = m, Ae.current = y, Ve.current = f, (C || m !== e) && (fe.current = !1);
326
+ const X = () => {
327
+ V.current = "", I.current = {
212
328
  tokens: [],
213
329
  head: 0,
214
330
  trailingGrapheme: ""
215
- }, R.current = 0;
216
- }, $ = (I) => {
217
- X.current = I, he(I);
331
+ }, q.current = 0;
332
+ }, J = (N) => {
333
+ ae.current = N, Me(N);
218
334
  };
219
335
  if (!m) {
220
- f(), $(t);
336
+ X(), J(f);
221
337
  return;
222
338
  }
223
- e || (f(), $(""));
224
- const x = e ? X.current : "";
225
- if (!t.startsWith(x)) {
226
- f(), $(t), d === "content-aware" && (g.current = {
227
- tokens: [],
228
- head: 0,
229
- trailingGrapheme: ae(t)
230
- });
231
- return;
339
+ e || (X(), J(""));
340
+ let $ = e ? ae.current : "";
341
+ if (!f.startsWith($)) {
342
+ if (X(), !xe) {
343
+ J(f), y === "content-aware" && (I.current = {
344
+ tokens: [],
345
+ head: 0,
346
+ trailingGrapheme: we(f)
347
+ });
348
+ return;
349
+ }
350
+ let N = 0;
351
+ for (; N < $.length && N < f.length && $[N] === f[N]; )
352
+ N += 1;
353
+ $ = $.slice(0, N), J($);
232
354
  }
233
- let N = t.slice(x.length);
234
- if (!N) {
235
- h.current = "", R.current = 0, g.current = d === "content-aware" ? {
355
+ let Q = f.slice($.length);
356
+ if (!Q) {
357
+ V.current = "", q.current = 0, I.current = y === "content-aware" ? {
236
358
  tokens: [],
237
359
  head: 0,
238
- trailingGrapheme: ae(x)
360
+ trailingGrapheme: we($)
239
361
  } : { tokens: [], head: 0, trailingGrapheme: "" };
240
362
  return;
241
363
  }
242
- if (d === "content-aware") {
243
- const I = p.slice(
244
- x.length
364
+ if (y === "content-aware") {
365
+ const N = c.slice(
366
+ $.length
245
367
  );
246
- if (e && i === "content-aware" && t.startsWith(p) && h.current === I) {
247
- const B = Re(
248
- g.current,
249
- t.slice(p.length)
368
+ if (e && n === "content-aware" && f.startsWith(c) && V.current === N) {
369
+ const _ = _e(
370
+ I.current,
371
+ f.slice(c.length)
250
372
  );
251
- g.current = B.queue, B.immediateChunk && (N = N.slice(
252
- B.immediateChunk.length
253
- ), $(`${x}${B.immediateChunk}`));
373
+ I.current = _.queue, _.immediateChunk && (Q = Q.slice(
374
+ _.immediateChunk.length
375
+ ), J(`${$}${_.immediateChunk}`));
254
376
  } else {
255
- const B = Re(
377
+ const _ = _e(
256
378
  {
257
379
  tokens: [],
258
380
  head: 0,
259
- trailingGrapheme: ae(x)
381
+ trailingGrapheme: we($)
260
382
  },
261
- N
383
+ Q
262
384
  );
263
- g.current = B.queue, B.immediateChunk && (N = N.slice(
264
- B.immediateChunk.length
265
- ), $(`${x}${B.immediateChunk}`)), R.current = 0;
385
+ I.current = _.queue, _.immediateChunk && (Q = Q.slice(
386
+ _.immediateChunk.length
387
+ ), J(`${$}${_.immediateChunk}`)), q.current = 0;
266
388
  }
267
389
  } else
268
- g.current = {
390
+ I.current = {
269
391
  tokens: [],
270
392
  head: 0,
271
393
  trailingGrapheme: ""
272
- }, R.current = 0;
273
- h.current = N, !b && N && Ve((I) => I + 1);
274
- }, [t, m, d]), P(() => {
275
- m && (re.current || h.current || w !== t || (re.current = !0, F?.()));
276
- }, [t, w, m, F]), P(() => {
277
- if (!m || !h.current)
394
+ }, q.current = 0;
395
+ V.current = Q, !d && Q && tt((N) => N + 1);
396
+ }, [t, f, m, y]), te(() => {
397
+ m && (fe.current || V.current || E !== f || (fe.current = !0, S?.()));
398
+ }, [
399
+ t,
400
+ f,
401
+ E,
402
+ m,
403
+ S
404
+ ]), te(() => {
405
+ if (!m || !V.current)
278
406
  return;
279
407
  const e = window.setTimeout(() => {
280
- if (!h.current)
408
+ if (!V.current)
281
409
  return;
282
- let i = "";
283
- if (d === "content-aware") {
284
- const b = tt(
285
- g.current,
286
- R.current + rt
410
+ let n = "";
411
+ if (y === "content-aware") {
412
+ const d = Tt(
413
+ I.current,
414
+ q.current + bt
287
415
  );
288
- i = b.chunk, g.current = b.queue, nt(b.queue) ? R.current = 0 : R.current = b.remainingBudget;
416
+ n = d.chunk, I.current = d.queue, St(d.queue) ? q.current = 0 : q.current = d.remainingBudget;
289
417
  } else
290
- i = Ct(
291
- h.current,
292
- gt
418
+ n = Qt(
419
+ V.current,
420
+ Ft
293
421
  ).chunk;
294
- if (!i)
422
+ if (!n)
295
423
  return;
296
- h.current = h.current.slice(i.length), h.current || (g.current = d === "content-aware" ? {
424
+ V.current = V.current.slice(n.length), V.current || (I.current = y === "content-aware" ? {
297
425
  tokens: [],
298
426
  head: 0,
299
- trailingGrapheme: g.current.trailingGrapheme
300
- } : { tokens: [], head: 0, trailingGrapheme: "" }, R.current = 0);
301
- const p = `${X.current}${i}`;
302
- X.current = p, he(p);
303
- }, pe);
427
+ trailingGrapheme: I.current.trailingGrapheme
428
+ } : { tokens: [], head: 0, trailingGrapheme: "" }, q.current = 0);
429
+ const c = `${ae.current}${n}`;
430
+ ae.current = c, Me(c);
431
+ }, Ne);
304
432
  return () => window.clearTimeout(e);
305
433
  }, [
306
- w,
307
- De,
434
+ E,
435
+ Je,
308
436
  m,
309
- d,
310
- pe,
311
- Ee
437
+ y,
438
+ Ne,
439
+ et
312
440
  ]);
313
- const ve = C(
441
+ const $e = h(
314
442
  () => ({
315
443
  isTypewriterEnabled: m,
316
- isTyping: m && w !== t,
317
- isComplete: w === t,
318
- renderedLength: w.length,
444
+ isTyping: m && E !== f,
445
+ isComplete: E === f,
446
+ renderedLength: t.length - Math.max(0, f.length - E.length),
319
447
  totalLength: t.length
320
448
  }),
321
- [t, w, m]
449
+ [t, f, E, m]
322
450
  );
323
- P(() => {
324
- _?.(ve);
325
- }, [_, ve]);
326
- const y = m ? w : t, ne = C(
327
- () => Se(y),
328
- [y]
329
- ), oe = C(
330
- () => st(
331
- y,
332
- a,
333
- z
451
+ te(() => {
452
+ R?.($e);
453
+ }, [R, $e]);
454
+ const Y = h(() => {
455
+ let e = 0;
456
+ return T.map((n) => {
457
+ if (n.type === "sandbox" || j(n) || !m)
458
+ return n;
459
+ const c = E.slice(
460
+ e,
461
+ e + n.value.length
462
+ );
463
+ return e += n.value.length, { ...n, value: c };
464
+ });
465
+ }, [T, E, m]), he = h(() => {
466
+ let e = 0;
467
+ return T.map((n) => {
468
+ const c = e;
469
+ return e += n.value.length, c;
470
+ });
471
+ }, [T]), ce = h(
472
+ () => m ? T.map(
473
+ (e) => e.type === "sandbox" || j(e) ? [] : e.value === B ? A.inline : Ct(e.value)
474
+ ) : [],
475
+ [m, T, B, A]
476
+ ), nt = h(
477
+ () => K ? Y.map(
478
+ (e, n) => e.type === "sandbox" || j(e) ? e.value : m ? qe(
479
+ e.value,
480
+ T[n].value,
481
+ ce[n] ?? [],
482
+ A.metadata,
483
+ he[n]
484
+ ) : ke(
485
+ e.value,
486
+ A.metadata,
487
+ he[n]
488
+ )
489
+ ) : [],
490
+ [
491
+ K,
492
+ m,
493
+ Y,
494
+ ce,
495
+ T,
496
+ A.metadata,
497
+ he
498
+ ]
499
+ ), rt = h(() => {
500
+ const e = [];
501
+ T.forEach((n, c) => {
502
+ const d = e.at(-1);
503
+ n.type !== "sandbox" && d && !d.sandbox ? d.indices.push(c) : e.push({ indices: [c], sandbox: n.type === "sandbox" });
504
+ });
505
+ for (const n of e)
506
+ if (!n.sandbox && n.indices.some((c) => j(T[c]))) {
507
+ const c = n.indices.map((C) => T[C]), d = c.map((C) => C.value).join("");
508
+ n.plan = At(
509
+ c,
510
+ d === B ? A : void 0
511
+ );
512
+ }
513
+ return e;
514
+ }, [T, B, A]), G = K ? Y.map((e) => e.value).join("") : m ? E : B, ot = h(
515
+ () => l ? ye(G) : "",
516
+ [l, G]
517
+ ), Ee = h(
518
+ () => K ? "" : ye(
519
+ m ? qe(
520
+ G,
521
+ B,
522
+ ce[0] ?? [],
523
+ A.metadata
524
+ ) : ke(
525
+ G,
526
+ A.metadata
527
+ )
528
+ ),
529
+ [
530
+ B,
531
+ K,
532
+ m,
533
+ G,
534
+ ce,
535
+ A.metadata
536
+ ]
537
+ ), ge = h(
538
+ () => Nt(
539
+ G,
540
+ k,
541
+ p
334
542
  ),
335
- [z, y, a]
336
- ), Te = W?.trim() || oe.buttonText, ye = E?.trim() || oe.inputText, Ie = C(
337
- () => a ? a.split(",").map((e) => e.trim()).filter(Boolean) : void 0,
338
- [a]
339
- ), Ge = S?.length ? S : oe.selectedValues || Ie, Ce = wt(
340
- Ge
341
- ), l = v({
342
- direction: H,
343
- language: q,
543
+ [p, G, k]
544
+ ), Ie = u?.trim() || ge.buttonText, Pe = P?.trim() || ge.inputText, st = h(
545
+ () => k ? k.split(",").map((e) => e.trim()).filter(Boolean) : void 0,
546
+ [k]
547
+ ), at = D?.length ? D : ge.selectedValues || st, De = Ut(
548
+ at
549
+ ), v = b({
550
+ direction: L,
551
+ language: H,
344
552
  mermaidMessages: M,
345
- beforeSend: T,
346
- locale: o,
347
- onClickCustomButtonAfterContent: te,
348
- onSend: A,
349
- readonly: L,
350
- renderContent: y,
351
- resolvedConfirmButtonText: ue,
352
- resolvedCopiedButtonText: me,
353
- resolvedCopyButtonText: de,
354
- resolvedDefaultButtonText: Te,
355
- resolvedDefaultInputText: ye,
356
- resolvedDefaultSelectedValues: Ce
553
+ beforeSend: me,
554
+ locale: s,
555
+ onClickCustomButtonAfterContent: se,
556
+ onSend: x,
557
+ readonly: W,
558
+ renderContent: G,
559
+ resolvedConfirmButtonText: Se,
560
+ resolvedCopiedButtonText: Be,
561
+ resolvedCopyButtonText: Re,
562
+ resolvedDefaultButtonText: Ie,
563
+ resolvedDefaultInputText: Pe,
564
+ resolvedDefaultSelectedValues: De
357
565
  });
358
- l.current = {
359
- direction: H,
360
- language: q,
566
+ v.current = {
567
+ direction: L,
568
+ language: H,
361
569
  mermaidMessages: M,
362
- beforeSend: T,
363
- locale: o,
364
- onClickCustomButtonAfterContent: te,
365
- onSend: A,
366
- readonly: L,
367
- renderContent: y,
368
- resolvedConfirmButtonText: ue,
369
- resolvedCopiedButtonText: me,
370
- resolvedCopyButtonText: de,
371
- resolvedDefaultButtonText: Te,
372
- resolvedDefaultInputText: ye,
373
- resolvedDefaultSelectedValues: Ce
570
+ beforeSend: me,
571
+ locale: s,
572
+ onClickCustomButtonAfterContent: se,
573
+ onSend: x,
574
+ readonly: W,
575
+ renderContent: G,
576
+ resolvedConfirmButtonText: Se,
577
+ resolvedCopiedButtonText: Be,
578
+ resolvedCopyButtonText: Re,
579
+ resolvedDefaultButtonText: Ie,
580
+ resolvedDefaultInputText: Pe,
581
+ resolvedDefaultSelectedValues: De
374
582
  };
375
- const ke = C(
583
+ const ve = h(
376
584
  () => ({
377
585
  "custom-button-after-content": ({
378
586
  children: e
@@ -380,34 +588,34 @@ const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|d
380
588
  "button",
381
589
  {
382
590
  className: "content-render-custom-button-after-content",
383
- onClick: l.current.onClickCustomButtonAfterContent,
591
+ onClick: v.current.onClickCustomButtonAfterContent,
384
592
  children: /* @__PURE__ */ r("span", { className: "content-render-custom-button-after-content-inner", children: e })
385
593
  }
386
594
  ),
387
595
  "custom-variable": (e) => /* @__PURE__ */ r(
388
- Ke,
596
+ ft,
389
597
  {
390
598
  ...e,
391
- readonly: l.current.readonly,
392
- defaultButtonText: l.current.resolvedDefaultButtonText,
393
- defaultInputText: l.current.resolvedDefaultInputText,
394
- defaultSelectedValues: l.current.resolvedDefaultSelectedValues,
395
- onSend: l.current.onSend,
396
- beforeSend: l.current.beforeSend,
397
- locale: l.current.locale,
398
- dir: l.current.direction,
399
- lang: l.current.language,
400
- confirmButtonText: l.current.resolvedConfirmButtonText
599
+ readonly: v.current.readonly,
600
+ defaultButtonText: v.current.resolvedDefaultButtonText,
601
+ defaultInputText: v.current.resolvedDefaultInputText,
602
+ defaultSelectedValues: v.current.resolvedDefaultSelectedValues,
603
+ onSend: v.current.onSend,
604
+ beforeSend: v.current.beforeSend,
605
+ locale: v.current.locale,
606
+ dir: v.current.direction,
607
+ lang: v.current.language,
608
+ confirmButtonText: v.current.resolvedConfirmButtonText
401
609
  }
402
610
  ),
403
- code: xt,
611
+ code: Ue,
404
612
  table: ({ ...e }) => /* @__PURE__ */ r("div", { className: "content-render-table-container", children: /* @__PURE__ */ r("table", { className: "content-render-table", ...e }) }),
405
613
  th: ({ ...e }) => /* @__PURE__ */ r("th", { className: "content-render-th", ...e }),
406
614
  td: ({ ...e }) => /* @__PURE__ */ r("td", { className: "content-render-td", ...e }),
407
615
  tr: ({ ...e }) => /* @__PURE__ */ r("tr", { className: "content-render-tr", ...e }),
408
- li: ({ node: e, ...i }) => {
409
- const p = e?.properties?.className;
410
- return typeof p == "string" && p.includes("task-list-item") || Array.isArray(p) && p.includes("task-list-item") ? /* @__PURE__ */ r("li", { className: "content-render-task-list-item", ...i }) : /* @__PURE__ */ r("li", { ...i });
616
+ li: ({ node: e, ...n }) => {
617
+ const c = e?.properties?.className;
618
+ return typeof c == "string" && c.includes("task-list-item") || Array.isArray(c) && c.includes("task-list-item") ? /* @__PURE__ */ r("li", { className: "content-render-task-list-item", ...n }) : /* @__PURE__ */ r("li", { ...n });
411
619
  },
412
620
  ol: ({ ...e }) => /* @__PURE__ */ r("ol", { className: "content-render-ol", ...e }),
413
621
  ul: ({ ...e }) => /* @__PURE__ */ r("ul", { className: "content-render-ul", ...e }),
@@ -420,137 +628,150 @@ const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|d
420
628
  ...e
421
629
  }
422
630
  ) : /* @__PURE__ */ r("input", { ...e }),
423
- a: ({ children: e, ...i }) => /* @__PURE__ */ r("a", { target: "_blank", rel: "noopener noreferrer", ...i, children: e }),
631
+ a: ({ children: e, ...n }) => /* @__PURE__ */ r("a", { target: "_blank", rel: "noopener noreferrer", ...n, children: e }),
424
632
  pre: (e) => /* @__PURE__ */ r(
425
- je,
633
+ mt,
426
634
  {
427
635
  ...e,
428
- copyButtonText: l.current.resolvedCopyButtonText,
429
- copiedButtonText: l.current.resolvedCopiedButtonText
636
+ copyButtonText: v.current.resolvedCopyButtonText,
637
+ copiedButtonText: v.current.resolvedCopiedButtonText
430
638
  }
431
639
  )
432
640
  }),
433
641
  []
434
- ), we = C(
435
- () => ft.test(y),
436
- [y]
437
- ), se = C(
438
- () => we ? ot(y, !0) : [],
439
- [y, we]
440
- ), Fe = se.some(
441
- (e) => e.type === "sandbox"
442
- ), _e = C(
443
- () => yt(se),
444
- [se]
445
- ), ze = C(
446
- () => Be(ne),
447
- [ne]
448
- ), We = (e, i) => {
449
- const p = Se(e);
450
- return Be(p).map((f, $) => {
451
- const x = `${i}-${f.type}-${$}`;
452
- return f.type === "text" ? /* @__PURE__ */ r(
453
- ce.Provider,
642
+ ), ct = h(
643
+ () => Ge(Ee),
644
+ [Ee]
645
+ ), it = (e, n) => {
646
+ const c = ye(e);
647
+ return Ge(c).map((C, xe) => {
648
+ const X = `${n}-${C.type}-${xe}`;
649
+ return C.type === "text" ? /* @__PURE__ */ r(
650
+ ie.Provider,
454
651
  {
455
- value: l,
652
+ value: v,
456
653
  children: /* @__PURE__ */ r(
457
- Ae,
654
+ He,
458
655
  {
459
- locale: o,
460
- components: ke,
461
- content: f.value
656
+ locale: s,
657
+ components: ve,
658
+ content: C.value
462
659
  }
463
660
  )
464
661
  },
465
- x
466
- ) : f.type === "mermaid" ? /* @__PURE__ */ r(
467
- ie,
662
+ X
663
+ ) : C.type === "mermaid" ? /* @__PURE__ */ r(
664
+ Ce,
468
665
  {
469
- chart: f.value,
470
- frozen: !f.complete,
666
+ chart: C.value,
667
+ frozen: !C.complete,
471
668
  messages: M
472
669
  },
473
- x
474
- ) : f.type === "svg" ? /* @__PURE__ */ r(Ne, { svg: f.value }, x) : null;
670
+ X
671
+ ) : C.type === "svg" ? /* @__PURE__ */ r(Te, { svg: C.value }, X) : null;
475
672
  });
476
- };
477
- return Fe ? /* @__PURE__ */ r(
673
+ }, We = l ? /* @__PURE__ */ r("div", { className: "content-render-custom-bar", children: Z.createElement(l, {
674
+ content: t,
675
+ displayContent: ot,
676
+ onSend: x
677
+ }) }) : null;
678
+ return K ? /* @__PURE__ */ ze(
478
679
  "div",
479
680
  {
480
681
  className: "content-render markdown-body",
481
- dir: H,
482
- lang: q,
483
- children: _e.map(
484
- (e, i) => e.type === "sandbox" ? /* @__PURE__ */ r(
485
- et,
486
- {
487
- hideFullScreen: !0,
488
- type: "sandbox",
489
- content: e.value,
490
- className: "content-render-iframe",
491
- locale: o,
492
- dir: H,
493
- lang: q,
494
- loadingText: Y,
495
- styleLoadingText: Z,
496
- scriptLoadingText: K,
497
- disableLoadingOverlay: O,
498
- fullScreenButtonText: Me,
499
- exitFullScreenButtonText: $e,
500
- mode: le
501
- },
502
- `sandbox-${i}`
503
- ) : /* @__PURE__ */ r(Q.Fragment, { children: We(e.value, `md-${i}`) }, `md-${i}`)
504
- )
682
+ dir: L,
683
+ lang: H,
684
+ children: [
685
+ rt.map((e) => {
686
+ const n = e.indices[0], c = Y[n];
687
+ return e.sandbox ? /* @__PURE__ */ r(
688
+ kt,
689
+ {
690
+ hideFullScreen: !0,
691
+ type: "sandbox",
692
+ content: c.value,
693
+ className: "content-render-iframe",
694
+ locale: s,
695
+ dir: L,
696
+ lang: H,
697
+ loadingText: U,
698
+ styleLoadingText: ne,
699
+ scriptLoadingText: ue,
700
+ disableLoadingOverlay: le,
701
+ fullScreenButtonText: Xe,
702
+ exitFullScreenButtonText: Ze,
703
+ mode: de
704
+ },
705
+ `sandbox-${n}`
706
+ ) : e.plan ? /* @__PURE__ */ r(
707
+ ie.Provider,
708
+ {
709
+ value: v,
710
+ children: /* @__PURE__ */ r(
711
+ jt,
712
+ {
713
+ locale: s,
714
+ components: ve,
715
+ plan: e.plan,
716
+ renderedSegments: e.indices.map(
717
+ (d) => Y[d]
718
+ )
719
+ }
720
+ )
721
+ },
722
+ `md-${n}`
723
+ ) : e.indices.map((d) => /* @__PURE__ */ r(Z.Fragment, { children: Y[d].type === "markdown" && Y[d].pending ? null : it(
724
+ nt[d],
725
+ `md-${d}`
726
+ ) }, `md-${d}`));
727
+ }),
728
+ We
729
+ ]
505
730
  }
506
- ) : /* @__PURE__ */ He(
731
+ ) : /* @__PURE__ */ ze(
507
732
  "div",
508
733
  {
509
734
  className: "content-render markdown-body",
510
- dir: H,
511
- lang: q,
735
+ dir: L,
736
+ lang: H,
512
737
  children: [
513
- ze.map((e, i) => {
738
+ ct.map((e, n) => {
514
739
  if (e.type === "text")
515
740
  return /* @__PURE__ */ r(
516
- ce.Provider,
741
+ ie.Provider,
517
742
  {
518
- value: l,
743
+ value: v,
519
744
  children: /* @__PURE__ */ r(
520
- Ae,
745
+ He,
521
746
  {
522
- locale: o,
523
- components: ke,
747
+ locale: s,
748
+ components: ve,
524
749
  content: e.value
525
750
  }
526
751
  )
527
752
  },
528
- i
753
+ n
529
754
  );
530
755
  if (e.type === "mermaid")
531
756
  return /* @__PURE__ */ r(
532
- ie,
757
+ Ce,
533
758
  {
534
759
  chart: e.value,
535
760
  frozen: !e.complete,
536
761
  messages: M
537
762
  },
538
- i
763
+ n
539
764
  );
540
765
  if (e.type === "svg")
541
- return /* @__PURE__ */ r(Ne, { svg: e.value }, i);
766
+ return /* @__PURE__ */ r(Te, { svg: e.value }, n);
542
767
  }),
543
- u && /* @__PURE__ */ r("div", { className: "content-render-custom-bar", children: Q.createElement(u, {
544
- content: t,
545
- displayContent: ne,
546
- onSend: A
547
- }) })
768
+ We
548
769
  ]
549
770
  }
550
771
  );
551
772
  };
552
773
  export {
553
- Ae as MarkdownRenderer,
554
- tr as default
774
+ He as MarkdownRenderer,
775
+ Mn as default
555
776
  };
556
777
  //# sourceMappingURL=ContentRender.es.js.map