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,172 +1,507 @@
1
- const $ = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s>]/i, C = [
1
+ import { getMarkdownSourceAnalysis as Q, getInlineCodeRanges as j } from "./inline-code-ranges.es.js";
2
+ import { findResumedProseFence as Z } from "./resumed-prose-fence.es.js";
3
+ import { readHtmlMarkup as P, findStreamingHtmlElementEnd as A, findStreamingHtmlBlockEnd as J, isHtmlRawTextTag as $ } from "./html-block-end.es.js";
4
+ const Y = /<(?:!doctype(?=[\s>])|(?:script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s/>])/i, ee = /* @__PURE__ */ new Set([
5
+ "div",
6
+ "style",
7
+ "script",
8
+ "iframe",
9
+ "section",
10
+ "article",
11
+ "header",
12
+ "footer",
13
+ "nav",
14
+ "main",
15
+ "aside",
16
+ "figure",
17
+ "details",
18
+ "summary",
19
+ "form",
20
+ "table",
21
+ "canvas",
22
+ "video",
23
+ "audio",
24
+ "pre",
25
+ "blockquote",
26
+ "ul",
27
+ "ol",
28
+ "dl",
29
+ "fieldset",
30
+ "address",
31
+ "hgroup",
32
+ "center",
33
+ "link",
34
+ "html",
35
+ "head",
36
+ "body",
37
+ "meta",
38
+ "title",
39
+ "base",
40
+ "template"
41
+ ]), te = /* @__PURE__ */ new Set([
42
+ "pre",
43
+ "details",
44
+ "summary",
45
+ "aside",
46
+ "blockquote",
47
+ "ul",
48
+ "ol",
49
+ "dl",
50
+ "table"
51
+ ]), ne = /* @__PURE__ */ new Set([
52
+ "script",
53
+ "style",
54
+ "link",
55
+ "iframe",
56
+ "html",
57
+ "head",
58
+ "body",
59
+ "meta",
60
+ "title",
61
+ "base",
62
+ "template"
63
+ ]), ie = [
2
64
  /<svg[\s\S]*?<\/svg>/i,
3
65
  /<img\b[^>]*?>/i,
4
66
  /```mermaid[\s\S]*?```/i,
5
67
  /```[a-zA-Z0-9]+[\s\S]*?```/i
6
- ], _ = /!\[[^\]]*]\([^\s)\n]+(?:\s+"[^"]*")?\)/i, k = /<iframe\b[^>]*\bdata-tag\s*=\s*(["'])video\1[^>]*>[\s\S]*?<\/iframe>/i, O = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi, T = /<custom-button-after-content\b[\s\S]*?<\/custom-button-after-content>/gi, V = /^"[\s\S]*"$/, U = /```mermaid[\s\S]*?```/i, w = (s) => s.split(/\r?\n/).map((e) => e.trim()).find(Boolean) ?? "", W = (s) => {
7
- const e = s.indexOf("```");
8
- if (e === -1) return null;
9
- const t = s.indexOf("```", e + 3);
10
- return t === -1 ? {
11
- start: e,
12
- block: s.slice(e),
68
+ ], O = /!\[[^\]]*]\([^\s)\n]+(?:\s+"[^"]*")?\)/i, D = new RegExp(
69
+ O.source,
70
+ "iy"
71
+ ), L = /<iframe\b[^>]*\bdata-tag\s*=\s*(["'])video\1[^>]*>[\s\S]*?<\/iframe>/i, W = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi, F = /<custom-button-after-content\b[\s\S]*?<\/custom-button-after-content>/gi, K = /^"[\s\S]*"$/, se = /```mermaid[\s\S]*?```/i, H = (e) => e.split(/\r?\n/).map((n) => n.trim()).find(Boolean) ?? "", oe = (e) => {
72
+ const n = e.indexOf("```");
73
+ if (n === -1) return null;
74
+ const s = e.indexOf("```", n + 3);
75
+ return s === -1 ? {
76
+ start: n,
77
+ block: e.slice(n),
13
78
  complete: !1
14
79
  } : {
15
- start: e,
16
- end: t + 3,
17
- block: s.slice(e, t + 3),
80
+ start: n,
81
+ end: s + 3,
82
+ block: e.slice(n, s + 3),
18
83
  complete: !0
19
84
  };
20
- }, K = (s) => {
21
- const e = s.split(/\r?\n/).map((t) => t.trim()).filter(Boolean);
22
- return e.length <= 1 ? s : e[0];
23
- }, Q = (s, e) => {
24
- if (!V.test(s)) return s;
25
- const t = s.slice(1, -1);
26
- if (!e) return t;
27
- const n = t.match(U);
28
- if (!n || typeof n.index != "number")
29
- return t;
30
- const o = t.slice(0, n.index), c = t.slice(n.index + n[0].length), r = w(o), i = w(c);
31
- return !r || !i ? t : `${r}${n[0]}${i}`;
32
- }, X = (s) => {
33
- const e = [], t = /```/g;
34
- let n;
35
- for (; (n = t.exec(s)) !== null; ) {
36
- const o = n.index, c = t.exec(s);
37
- if (!c) {
38
- e.push({ start: o, end: s.length });
85
+ }, le = (e) => {
86
+ const n = e.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
87
+ return n.length <= 1 ? e : n[0];
88
+ }, U = (e, n, s = !1) => {
89
+ if (!K.test(e)) return e;
90
+ const i = e.slice(1, -1);
91
+ if (!n) return i;
92
+ const t = i.match(se);
93
+ if (!t || typeof t.index != "number")
94
+ return i;
95
+ const l = i.slice(0, t.index), a = i.slice(t.index + t[0].length), r = H(l), c = H(a);
96
+ if (!r || !c)
97
+ return i;
98
+ const d = s ? `
99
+ ` : "";
100
+ return `${r}${d}${t[0]}${d}${c}`;
101
+ }, Ie = (e) => K.test(e) && w(e, !0).some((s) => s.type === "sandbox") ? U(e, !0, !0) : e, ae = (e) => {
102
+ const n = [], s = /```/g;
103
+ let i;
104
+ for (; (i = s.exec(e)) !== null; ) {
105
+ const t = i.index, l = s.exec(e);
106
+ if (!l) {
107
+ n.push({ start: t, end: e.length });
39
108
  break;
40
109
  }
41
- e.push({ start: o, end: c.index + 3 });
110
+ n.push({ start: t, end: l.index + 3 });
42
111
  }
43
- return e;
44
- }, j = (s, e) => e.some(({ start: t, end: n }) => s >= t && s < n), x = (s, e, t) => {
45
- const n = e.flags.includes("g") ? e.flags : `${e.flags}g`, o = new RegExp(e.source, n);
46
- let c;
47
- for (; (c = o.exec(s)) !== null; )
48
- if (!j(c.index, t))
49
- return c.index;
112
+ return n;
113
+ }, B = (e, n) => {
114
+ let s = 0;
115
+ for (let i = n - 1; i >= 0 && e[i] === "\\"; i--) s++;
116
+ return s % 2 === 1;
117
+ }, q = (e, n) => n.some(({ start: s, end: i }) => e >= s && e < i), N = (e, n, s) => {
118
+ const i = n.flags.includes("g") ? n.flags : `${n.flags}g`, t = new RegExp(n.source, i);
119
+ let l;
120
+ for (; (l = t.exec(e)) !== null; )
121
+ if (!B(e, l.index) && !q(l.index, s))
122
+ return l.index;
50
123
  return -1;
51
- }, G = (s, e) => {
52
- let t = s.length, n;
53
- for (O.lastIndex = 0; n = O.exec(s); )
54
- if (!(n.index <= e)) {
55
- t = n.index + n[0].length;
124
+ }, ce = (e, n) => {
125
+ let s = e.length, i;
126
+ for (W.lastIndex = 0; i = W.exec(e); )
127
+ if (!(i.index <= n)) {
128
+ s = i.index + i[0].length;
56
129
  break;
57
130
  }
58
- return t;
59
- }, H = (s) => {
60
- if (!s.length) return s;
61
- const e = [];
62
- return s.forEach((t) => {
63
- if (t.type !== "sandbox") {
64
- e.push(t);
131
+ return s;
132
+ }, re = (e) => {
133
+ if (!e.length) return e;
134
+ const n = [];
135
+ return e.forEach((s) => {
136
+ if (s.type !== "sandbox") {
137
+ n.push(s);
65
138
  return;
66
139
  }
67
- T.lastIndex = 0;
68
- let n = 0, o;
69
- for (; (o = T.exec(t.value)) !== null; ) {
70
- const r = t.value.slice(n, o.index);
71
- r.trim() && e.push({ type: "sandbox", value: r }), e.push({ type: "markdown", value: o[0] }), n = o.index + o[0].length;
72
- }
73
- const c = t.value.slice(n);
74
- c.trim() && e.push({ type: "sandbox", value: c });
75
- }), e;
76
- }, Z = (s) => {
77
- let e = null;
78
- return C.forEach((t) => {
79
- const n = t.exec(s);
80
- if (!n || typeof n.index != "number") return;
81
- const o = n.index, c = n.index + n[0].length;
82
- (!e || o < e.start) && (e = { start: o, end: c });
83
- }), e;
84
- }, q = (...s) => s.reduce((e, t) => t && (!e || t.start < e.start) ? t : e, null), P = (s, e) => {
85
- const t = x(
86
- s,
87
- _,
88
- e
140
+ F.lastIndex = 0;
141
+ let i = 0, t;
142
+ for (; (t = F.exec(s.value)) !== null; ) {
143
+ const a = s.value.slice(i, t.index);
144
+ a.trim() && n.push({ type: "sandbox", value: a }), n.push({ type: "markdown", value: t[0] }), i = t.index + t[0].length;
145
+ }
146
+ const l = s.value.slice(i);
147
+ l.trim() && n.push({ type: "sandbox", value: l });
148
+ }), n;
149
+ }, de = (e, n) => {
150
+ let s = null;
151
+ return ie.forEach((i) => {
152
+ const t = i.exec(e)?.index ?? -1;
153
+ if (t === -1) return;
154
+ const l = i.exec(e.slice(t));
155
+ if (!l) return;
156
+ const a = t + l[0].length;
157
+ (!s || t < s.start) && (s = { start: t, end: a });
158
+ }), s;
159
+ }, fe = (...e) => e.reduce((n, s) => s && (!n || s.start < n.start) ? s : n, null), V = (e, n) => {
160
+ const s = N(
161
+ e,
162
+ O,
163
+ n
89
164
  );
90
- if (t === -1) return null;
91
- const n = s.slice(t).match(_);
92
- return n ? { start: t, end: t + n[0].length } : null;
93
- }, J = (s, e) => {
94
- const t = x(
95
- s,
96
- k,
97
- e
165
+ if (s === -1) return null;
166
+ const i = e.slice(s).match(O);
167
+ return i ? { start: s, end: s + i[0].length } : null;
168
+ }, me = (e, n) => {
169
+ const s = N(
170
+ e,
171
+ L,
172
+ n
98
173
  );
174
+ if (s === -1) return null;
175
+ const i = e.slice(s).match(L);
176
+ return i ? { start: s, end: s + i[0].length } : null;
177
+ }, ue = (e) => L.test(e.trim()), C = (e, n) => {
178
+ if (n === -1) return null;
179
+ const s = e.slice(n), i = /^<([a-z]+)/i.exec(s);
180
+ if (!i) return null;
181
+ const t = i[1].toLowerCase(), l = () => ({
182
+ start: n,
183
+ end: e.length,
184
+ immediate: !0,
185
+ pending: !0
186
+ });
187
+ if (i[0].length === s.length && "iframe".startsWith(t))
188
+ return l();
189
+ if (t !== "iframe" || !/[\s/>]/.test(s[i[0].length] ?? ""))
190
+ return null;
191
+ const a = n + i[0].length;
192
+ let r = "", c = -1;
193
+ for (let v = a; v < e.length; v += 1) {
194
+ const p = e[v];
195
+ if (r)
196
+ p === r && (r = "");
197
+ else if (p === '"' || p === "'")
198
+ r = p;
199
+ else if (p === ">") {
200
+ c = v + 1;
201
+ break;
202
+ }
203
+ }
204
+ if (c === -1) return l();
205
+ const d = e.slice(a, c - 1), o = /([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]*)))?/g;
206
+ let u, x = !1;
207
+ for (; (u = o.exec(d)) !== null; )
208
+ if (u[1].toLowerCase() === "data-tag") {
209
+ x = (u[2] ?? u[3] ?? u[4] ?? "").toLowerCase() === "video";
210
+ break;
211
+ }
212
+ if (!x) return null;
213
+ const I = /<\/iframe\s*>/i.exec(e.slice(c));
214
+ return {
215
+ start: n,
216
+ end: I ? c + I.index + I[0].length : e.length,
217
+ immediate: !0
218
+ };
219
+ }, he = (e, n) => {
220
+ const s = /^\s*\|.+\|\s*$/gm;
221
+ let i, t = -1;
222
+ for (; (i = s.exec(e)) !== null; ) {
223
+ const c = i[0].match(/^\s*/)?.[0].length ?? 0, d = i.index + c;
224
+ if (!q(d, n)) {
225
+ t = d;
226
+ break;
227
+ }
228
+ }
99
229
  if (t === -1) return null;
100
- const n = s.slice(t).match(k);
101
- return n ? { start: t, end: t + n[0].length } : null;
102
- }, Y = (s) => k.test(s.trim()), tt = (s) => {
103
- const e = s.match(/^\s*\|.+\|\s*$/m);
104
- if (!e || typeof e.index != "number") return null;
105
- const t = e[0].match(/^\s*/)?.[0].length ?? 0, n = e.index + t, o = s.slice(n).split(`
106
- `), c = [];
107
- for (const i of o) {
108
- if (!i.trim().startsWith("|")) break;
109
- c.push(i);
230
+ const l = e.slice(t).split(`
231
+ `), a = [];
232
+ for (const c of l) {
233
+ if (!c.trim().startsWith("|")) break;
234
+ a.push(c);
235
+ }
236
+ const r = a.join(`
237
+ `);
238
+ return { start: t, block: r, end: t + r.length };
239
+ }, X = (e, n) => {
240
+ const s = /^<([a-z][a-z0-9:-]*)(?=[\s/>])/i.exec(e.slice(n));
241
+ return s ? ee.has(s[1].toLowerCase()) : /^<!doctype(?=[\s>])/i.test(e.slice(n));
242
+ }, G = (e, n) => {
243
+ const s = /^<([a-z][a-z0-9:-]*)(?=[\s/>])/i.exec(e.slice(n));
244
+ return !!(s && te.has(s[1].toLowerCase()));
245
+ }, ge = (e, n, s) => {
246
+ let i = n;
247
+ for (; i < s; ) {
248
+ if (e[i] !== "<") {
249
+ i += 1;
250
+ continue;
251
+ }
252
+ const t = P(e, i), l = t.kind === "tag" ? t.closing ? void 0 : t.name : /^<([a-z][a-z0-9:-]*)(?=[\s/>])/i.exec(e.slice(i))?.[1].toLowerCase();
253
+ if (l && ne.has(l) && !(l === "iframe" && C(e, i)))
254
+ return !0;
255
+ if (t.kind === "incomplete" || t.kind === "invalid") {
256
+ if (t.kind === "incomplete") break;
257
+ i += 1;
258
+ continue;
259
+ }
260
+ if (t.kind === "tag" && !t.closing && $(t.name)) {
261
+ i = A(e, i);
262
+ continue;
263
+ }
264
+ i = t.end;
265
+ }
266
+ return !1;
267
+ }, pe = (e) => {
268
+ const n = /* @__PURE__ */ new Map(), s = [...e.matchAll(/`+|\$+/g)], i = /* @__PURE__ */ new Map();
269
+ for (let a = s.length - 1; a >= 0; a -= 1) {
270
+ const r = s[a], c = r[0], d = i.get(c);
271
+ d !== void 0 && n.set(r.index, d + c.length), (c[0] === "`" || !B(e, r.index)) && i.set(c, r.index);
272
+ }
273
+ const t = [];
274
+ let l = 0;
275
+ for (const a of e.split(`
276
+ `)) {
277
+ const r = l + (a.match(/^[ \t]*/)?.[0].length ?? 0);
278
+ (!a.trim() || X(e, r)) && t.push(l), l += a.length + 1;
110
279
  }
111
- const r = c.join(`
280
+ return { nextClosing: n, boundaries: t };
281
+ }, be = (e, n, s) => {
282
+ const i = e[n];
283
+ if (i !== "`" && i !== "$" || B(e, n)) return;
284
+ let t = 1;
285
+ for (; e[n + t] === i; ) t += 1;
286
+ const l = n + t, a = i === "$" && t > 2 ? void 0 : s.nextClosing.get(n);
287
+ if (a === void 0) return { markerEnd: l };
288
+ if (i === "$" && t === 2) return { markerEnd: l, end: a };
289
+ let r = 0, c = s.boundaries.length;
290
+ for (; r < c; ) {
291
+ const d = r + c >>> 1;
292
+ s.boundaries[d] <= n ? r = d + 1 : c = d;
293
+ }
294
+ return a <= (s.boundaries[r] ?? e.length) ? { markerEnd: l, end: a } : { markerEnd: l };
295
+ }, xe = (e, n, s) => {
296
+ let i = n.start, t = i;
297
+ for (; t < n.end; ) {
298
+ if (e[t] !== "<") {
299
+ t += 1;
300
+ continue;
301
+ }
302
+ const l = P(e, t);
303
+ if (l.kind === "incomplete") break;
304
+ if (l.kind === "invalid") {
305
+ t += 1;
306
+ continue;
307
+ }
308
+ if (l.kind === "tag" && !l.closing) {
309
+ if (l.name === "custom-button-after-content") {
310
+ const a = Math.min(
311
+ A(e, t),
312
+ n.end
313
+ );
314
+ if (/<\/custom-button-after-content\s*>$/i.test(
315
+ e.slice(t, a)
316
+ )) {
317
+ t > i && s.push({
318
+ type: "sandbox",
319
+ value: e.slice(i, t)
320
+ }), s.push({
321
+ type: "markdown",
322
+ value: e.slice(t, a)
323
+ }), i = a, t = a;
324
+ continue;
325
+ }
326
+ }
327
+ if ($(l.name)) {
328
+ t = A(e, t);
329
+ continue;
330
+ }
331
+ }
332
+ t = l.end;
333
+ }
334
+ i < n.end && s.push({ type: "sandbox", value: e.slice(i, n.end) });
335
+ }, ke = (e, n, s) => {
336
+ const i = [], t = e.split(`
112
337
  `);
113
- return { start: n, block: r, end: n + r.length };
114
- }, f = (s, e = !1) => {
115
- const t = Q(s, e), n = (l) => H(l), o = W(t);
116
- if (o) {
117
- if (!o.complete)
118
- return n(e ? [{ type: "markdown", value: t }] : [{ type: "markdown", value: o.block }]);
119
- if (!e)
120
- return n([{ type: "markdown", value: o.block }]);
121
- const l = [], a = t.slice(0, o.start), u = K(a);
122
- u.trim() && l.push({ type: "text", value: u }), l.push({ type: "markdown", value: o.block });
123
- const d = t.slice(o.end);
124
- return d.trim() && l.push(...f(d, !0)), n(l);
338
+ let l = 0, a = 0, r = 0;
339
+ for (let c = 0; c < t.length; c += 1) {
340
+ const d = t[c], o = l + (d.match(/^[ \t]*/)?.[0].length ?? 0);
341
+ for (; n[a]?.end <= o; ) a += 1;
342
+ const u = n[a];
343
+ if (/^[ \t]*\|.+\|[ \t]*\r?$/.test(d) && !(u && u.start <= o)) {
344
+ let x = l + d.length;
345
+ for (; c + 1 < t.length && t[c + 1].trim().startsWith("|"); )
346
+ l += t[c].length + 1, c += 1, x = l + t[c].length;
347
+ for (; s[r]?.end <= o; ) r += 1;
348
+ s[r]?.start < x || i.push({ start: o, end: x, type: "markdown" });
349
+ }
350
+ l += t[c].length + 1;
351
+ }
352
+ return i;
353
+ }, ve = (e, n, s) => {
354
+ const i = [], t = new Set(s.comments), l = s.literal.filter((f) => !t.has(f)), a = [];
355
+ let r = 0, c = 0, d = 0, o = 0, u = !1, x;
356
+ for (; o < e.length; ) {
357
+ for (; s.fences[c]?.end <= o; ) c += 1;
358
+ const f = s.fences[c];
359
+ if (f?.start === o) {
360
+ i.push({ ...f, type: "markdown" }), a.push(f), o = f.end;
361
+ continue;
362
+ }
363
+ for (; l[r]?.end <= o; ) r += 1;
364
+ const M = l[r];
365
+ if (M && M.start <= o) {
366
+ a.push(M), o = M.end;
367
+ continue;
368
+ }
369
+ for (; s.html[d]?.end <= o; ) d += 1;
370
+ const T = s.html[d];
371
+ if (u && T && T.start <= o) {
372
+ const m = Z(e, o);
373
+ if (m) {
374
+ for (i.push(m), a.push(m); l[r]?.start < m.end; ) r += 1;
375
+ o = m.end;
376
+ continue;
377
+ }
378
+ (e[o] === "`" || e[o] === "$") && (x ??= pe(e));
379
+ const E = x && be(e, o, x);
380
+ if (E) {
381
+ E.end !== void 0 && a.push({ start: o, end: E.end }), o = E.end ?? E.markerEnd;
382
+ continue;
383
+ }
384
+ }
385
+ if (e[o] === "!" && !B(e, o)) {
386
+ D.lastIndex = o;
387
+ const m = D.exec(e);
388
+ if (m) {
389
+ i.push({
390
+ start: o,
391
+ end: o + m[0].length,
392
+ type: "markdown"
393
+ }), o += m[0].length;
394
+ continue;
395
+ }
396
+ }
397
+ if (e[o] !== "<" || B(e, o)) {
398
+ o += 1;
399
+ continue;
400
+ }
401
+ const g = P(e, o);
402
+ if (X(e, o)) {
403
+ const m = C(e, o), E = G(e, o), R = m?.end ?? (E ? A(e, o) : J(e, o, (b) => {
404
+ const k = C(e, b);
405
+ return !!(k && !k.pending) || G(e, b);
406
+ })), h = E && !ge(e, o, R);
407
+ i.push({
408
+ start: o,
409
+ end: R,
410
+ type: m || h ? "markdown" : "sandbox",
411
+ ...m?.immediate || h ? { immediate: !0 } : {},
412
+ ...m?.pending || h && g.kind === "incomplete" ? { pending: !0 } : {}
413
+ }), o = R, u = !0;
414
+ continue;
415
+ }
416
+ if (g.kind === "tag")
417
+ if (!g.closing && (g.name === "svg" || g.name === "img")) {
418
+ const m = g.name === "img" ? g.end : A(e, o);
419
+ i.push({ start: o, end: m, type: "markdown" }), o = m;
420
+ } else if (!g.closing && $(g.name)) {
421
+ const m = A(e, o);
422
+ a.push({ start: o, end: m }), o = m;
423
+ } else
424
+ o = g.end;
425
+ else g.kind === "comment" || g.kind === "declaration" ? (g.kind === "comment" && a.push({ start: o, end: g.end }), o = g.end) : g.kind === "incomplete" ? (/^<svg(?=[\s/>])/i.test(e.slice(o)) && i.push({ start: o, end: e.length, type: "markdown" }), o = e.length) : o += 1;
426
+ }
427
+ const I = ke(e, a, i), v = [];
428
+ let p = 0;
429
+ for (const f of i) {
430
+ for (; I[p]?.start < f.start; )
431
+ v.push(I[p++]);
432
+ v.push(f);
125
433
  }
126
- const c = X(t), r = x(
434
+ v.push(...I.slice(p));
435
+ const S = [];
436
+ let y = 0;
437
+ for (const f of v)
438
+ f.start < y || (n && f.start > y && S.push({ type: "text", value: e.slice(y, f.start) }), f.type === "sandbox" ? xe(e, f, S) : S.push({
439
+ type: "markdown",
440
+ value: e.slice(f.start, f.end),
441
+ ...f.immediate ? { immediate: !0 } : {},
442
+ ...f.pending ? { pending: !0 } : {}
443
+ }), y = f.end);
444
+ return n && y < e.length && S.push({ type: "text", value: e.slice(y) }), S;
445
+ }, w = (e, n = !1, s = !1, i) => {
446
+ if (s)
447
+ return ve(
448
+ e,
449
+ n,
450
+ i ?? Q(e)
451
+ );
452
+ const t = U(e, n), l = (h) => re(h), a = (h) => !!h.trim(), r = j(t), c = oe(t), d = [...ae(t), ...r], o = N(
127
453
  t,
128
- $,
129
- c
130
- ), i = x(
454
+ Y,
455
+ d
456
+ );
457
+ if (c) {
458
+ if (!c.complete)
459
+ return l([
460
+ { type: "markdown", value: n ? t : c.block }
461
+ ]);
462
+ if (!n)
463
+ return l([{ type: "markdown", value: c.block }]);
464
+ const h = [], b = le(t.slice(0, c.start));
465
+ a(b) && h.push({ type: "text", value: b }), h.push({ type: "markdown", value: c.block });
466
+ const k = t.slice(c.end);
467
+ return a(k) && h.push(...w(k, !0)), l(h);
468
+ }
469
+ const u = N(
131
470
  t,
132
471
  /<svg\b/i,
133
- c
134
- ), I = r !== -1 && i !== -1 && r < i, S = P(t, c), z = !!S && i !== -1 && S.start < i;
135
- if (i !== -1 && !I && !z) {
136
- const l = t.slice(0, i), a = t.indexOf("</svg>", i), u = a === -1 ? `${t.slice(i)}</svg>` : t.slice(i, a + 6), d = a === -1 ? "" : t.slice(a + 6);
137
- if (e) {
138
- const b = [];
139
- return l.trim() && b.push({ type: "text", value: l }), b.push({ type: "markdown", value: u }), d.trim() && b.push(...f(d, !0)), n(b);
140
- }
141
- if (a === -1)
142
- return n([{ type: "markdown", value: u }]);
472
+ d
473
+ ), x = o !== -1 && u !== -1 && o < u, I = V(t, d), v = !!I && u !== -1 && I.start < u;
474
+ if (u !== -1 && !x && !v) {
475
+ const h = t.slice(0, u), b = t.indexOf("</svg>", u), k = b === -1 ? `${t.slice(u)}</svg>` : t.slice(u, b + 6), z = b === -1 ? "" : t.slice(b + 6);
476
+ if (n) {
477
+ const _ = [];
478
+ return a(h) && _.push({ type: "text", value: h }), _.push({ type: "markdown", value: k }), a(z) && _.push(...w(z, !0)), l(_);
479
+ }
480
+ if (b === -1)
481
+ return l([{ type: "markdown", value: k }]);
143
482
  }
144
- const h = tt(t);
145
- if (h) {
146
- const l = [], a = t.slice(0, h.start);
147
- e && a.trim() && l.push(...f(a, !0)), l.push({ type: "markdown", value: h.block });
148
- const u = t.slice(h.end), d = u.length < t.length;
149
- return u.trim() && d && l.push(
150
- ...e ? f(u, !0) : f(u)
151
- ), n(l);
483
+ const p = he(t, []);
484
+ if (p) {
485
+ const h = [], b = t.slice(0, p.start);
486
+ n && a(b) && h.push(...w(b, !0)), h.push({ type: "markdown", value: p.block });
487
+ const k = t.slice(p.end);
488
+ return a(k) && k.length < t.length && h.push(...w(k, n)), l(h);
152
489
  }
153
- const F = Z(t), D = P(t, c), L = J(
154
- t,
155
- c
156
- ), m = q(
157
- F,
158
- D,
159
- L
490
+ const S = fe(
491
+ de(t),
492
+ V(t, d),
493
+ me(t, d)
160
494
  );
161
- if (r === -1 && !m)
162
- return e && t.trim() ? n([{ type: "text", value: t }]) : [];
163
- const g = !!m && (r === -1 || m.start <= r), v = g ? m.start : r, y = g ? m.end : G(t, v), p = [], E = t.slice(0, v), M = t.slice(v, y), B = g && Y(M), A = B ? E.trimEnd() : E, R = t.slice(y), N = B ? R.trimStart() : R;
164
- return e && A.trim() && p.push({ type: "text", value: A }), p.push({
165
- type: g ? "markdown" : "sandbox",
166
- value: M
167
- }), N.trim() && p.push(...f(N, e)), n(p);
495
+ if (o === -1 && !S)
496
+ return n && a(t) ? [{ type: "text", value: t }] : [];
497
+ const y = !!S && (o === -1 || S.start <= o), f = y ? S.start : o, M = y ? S.end : ce(t, f), T = t.slice(f, M), g = y && ue(T), m = g ? t.slice(0, f).trimEnd() : t.slice(0, f), E = g ? t.slice(M).trimStart() : t.slice(M), R = [];
498
+ return n && a(m) && R.push({ type: "text", value: m }), R.push({
499
+ type: y ? "markdown" : "sandbox",
500
+ value: T
501
+ }), a(E) && R.push(...w(E, n)), l(R);
168
502
  };
169
503
  export {
170
- f as splitContentSegments
504
+ Ie as normalizeWrappedSandboxContent,
505
+ w as splitContentSegments
171
506
  };
172
507
  //# sourceMappingURL=split-content.es.js.map