markdown-flow-ui 0.2.30 → 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 (92) hide show
  1. package/README.md +25 -2
  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.es.js +603 -392
  13. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  14. package/dist/components/ContentRender/index.cjs +1 -1
  15. package/dist/components/ContentRender/index.es.js +1 -0
  16. package/dist/components/ContentRender/index.es.js.map +1 -1
  17. package/dist/components/ContentRender/utils/escape-typed-metadata.cjs +2 -0
  18. package/dist/components/ContentRender/utils/escape-typed-metadata.cjs.map +1 -0
  19. package/dist/components/ContentRender/utils/escape-typed-metadata.d.ts +9 -0
  20. package/dist/components/ContentRender/utils/escape-typed-metadata.es.js +47 -0
  21. package/dist/components/ContentRender/utils/escape-typed-metadata.es.js.map +1 -0
  22. package/dist/components/ContentRender/utils/escape-typed-metadata.test.d.ts +1 -0
  23. package/dist/components/ContentRender/utils/html-block-end.cjs +1 -1
  24. package/dist/components/ContentRender/utils/html-block-end.cjs.map +1 -1
  25. package/dist/components/ContentRender/utils/html-block-end.d.ts +20 -6
  26. package/dist/components/ContentRender/utils/html-block-end.es.js +63 -56
  27. package/dist/components/ContentRender/utils/html-block-end.es.js.map +1 -1
  28. package/dist/components/ContentRender/utils/inline-code-ranges.cache.test.d.ts +1 -0
  29. package/dist/components/ContentRender/utils/inline-code-ranges.cjs +10 -0
  30. package/dist/components/ContentRender/utils/inline-code-ranges.cjs.map +1 -0
  31. package/dist/components/ContentRender/utils/inline-code-ranges.d.ts +39 -0
  32. package/dist/components/ContentRender/utils/inline-code-ranges.es.js +336 -0
  33. package/dist/components/ContentRender/utils/inline-code-ranges.es.js.map +1 -0
  34. package/dist/components/ContentRender/utils/inline-code-ranges.test.d.ts +1 -0
  35. package/dist/components/ContentRender/utils/markdown-plugins.cjs +2 -0
  36. package/dist/components/ContentRender/utils/markdown-plugins.cjs.map +1 -0
  37. package/dist/components/ContentRender/utils/markdown-plugins.d.ts +2 -0
  38. package/dist/components/ContentRender/utils/markdown-plugins.es.js +14 -0
  39. package/dist/components/ContentRender/utils/markdown-plugins.es.js.map +1 -0
  40. package/dist/components/ContentRender/utils/mermaid-parse.cjs +4 -3
  41. package/dist/components/ContentRender/utils/mermaid-parse.cjs.map +1 -1
  42. package/dist/components/ContentRender/utils/mermaid-parse.es.js +86 -67
  43. package/dist/components/ContentRender/utils/mermaid-parse.es.js.map +1 -1
  44. package/dist/components/ContentRender/utils/mermaid-parse.test.d.ts +1 -0
  45. package/dist/components/ContentRender/utils/normalize-inline-html.cjs +4 -2
  46. package/dist/components/ContentRender/utils/normalize-inline-html.cjs.map +1 -1
  47. package/dist/components/ContentRender/utils/normalize-inline-html.d.ts +4 -1
  48. package/dist/components/ContentRender/utils/normalize-inline-html.es.js +15 -7
  49. package/dist/components/ContentRender/utils/normalize-inline-html.es.js.map +1 -1
  50. package/dist/components/ContentRender/utils/normalize-inline-html.test.d.ts +1 -0
  51. package/dist/components/ContentRender/utils/resumed-prose-fence.cjs +5 -0
  52. package/dist/components/ContentRender/utils/resumed-prose-fence.cjs.map +1 -0
  53. package/dist/components/ContentRender/utils/resumed-prose-fence.d.ts +5 -0
  54. package/dist/components/ContentRender/utils/resumed-prose-fence.es.js +60 -0
  55. package/dist/components/ContentRender/utils/resumed-prose-fence.es.js.map +1 -0
  56. package/dist/components/ContentRender/utils/split-content.cjs +6 -3
  57. package/dist/components/ContentRender/utils/split-content.cjs.map +1 -1
  58. package/dist/components/ContentRender/utils/split-content.d.ts +7 -1
  59. package/dist/components/ContentRender/utils/split-content.es.js +460 -216
  60. package/dist/components/ContentRender/utils/split-content.es.js.map +1 -1
  61. package/dist/components/ContentRender/utils/split-content.image-alt.test.d.ts +1 -0
  62. package/dist/components/ContentRender/utils/split-content.resumed-fences.test.d.ts +1 -0
  63. package/dist/components/ContentRender/utils/video-markdown-run.cjs +14 -0
  64. package/dist/components/ContentRender/utils/video-markdown-run.cjs.map +1 -0
  65. package/dist/components/ContentRender/utils/video-markdown-run.d.ts +47 -0
  66. package/dist/components/ContentRender/utils/video-markdown-run.es.js +462 -0
  67. package/dist/components/ContentRender/utils/video-markdown-run.es.js.map +1 -0
  68. package/dist/components/ContentRender/utils/video-markdown-run.test.d.ts +1 -0
  69. package/dist/components/ContentRender/utils/wrapped-content.test.d.ts +1 -0
  70. package/dist/components/MarkdownFlow/MarkdownFlow.cjs +1 -1
  71. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.map +1 -1
  72. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +9 -8
  73. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  74. package/dist/components/Slide/Slide.cjs +1 -1
  75. package/dist/components/Slide/Slide.cjs.map +1 -1
  76. package/dist/components/Slide/Slide.es.js +3 -2
  77. package/dist/components/Slide/Slide.es.js.map +1 -1
  78. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
  79. package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
  80. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.cjs +1 -1
  81. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.es.js +1 -1
  82. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.cjs +1 -1
  83. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.es.js +1 -1
  84. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.cjs +1 -1
  85. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.es.js +1 -1
  86. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.cjs +1 -1
  87. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.es.js +1 -1
  88. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.cjs +1 -1
  89. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.es.js +1 -1
  90. package/dist/node_modules/unified/lib/index.cjs +1 -1
  91. package/dist/node_modules/unified/lib/index.es.js +1 -1
  92. package/package.json +6 -1
@@ -1,263 +1,507 @@
1
- import { findStreamingHtmlBlockEnd as U } from "./html-block-end.es.js";
2
- const K = /<(?:!doctype\b|(?:script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s>])/i, H = [
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 = [
3
64
  /<svg[\s\S]*?<\/svg>/i,
4
65
  /<img\b[^>]*?>/i,
5
66
  /```mermaid[\s\S]*?```/i,
6
67
  /```[a-zA-Z0-9]+[\s\S]*?```/i
7
- ], $ = /!\[[^\]]*]\([^\s)\n]+(?:\s+"[^"]*")?\)/i, B = /<iframe\b[^>]*\bdata-tag\s*=\s*(["'])video\1[^>]*>[\s\S]*?<\/iframe>/i, F = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi, w = /<custom-button-after-content\b[\s\S]*?<\/custom-button-after-content>/gi, Q = /^"[\s\S]*"$/, X = /```mermaid[\s\S]*?```/i, z = (s) => s.split(/\r?\n/).map((n) => n.trim()).find(Boolean) ?? "", j = (s) => {
8
- const n = s.indexOf("```");
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("```");
9
73
  if (n === -1) return null;
10
- const e = s.indexOf("```", n + 3);
11
- return e === -1 ? {
74
+ const s = e.indexOf("```", n + 3);
75
+ return s === -1 ? {
12
76
  start: n,
13
- block: s.slice(n),
77
+ block: e.slice(n),
14
78
  complete: !1
15
79
  } : {
16
80
  start: n,
17
- end: e + 3,
18
- block: s.slice(n, e + 3),
81
+ end: s + 3,
82
+ block: e.slice(n, s + 3),
19
83
  complete: !0
20
84
  };
21
- }, G = (s) => {
22
- const n = /^ {0,3}(`{3,}|~{3,})([^\r\n]*)\r?$/gm;
23
- let e;
24
- for (; (e = n.exec(s)) !== null; ) {
25
- const t = e[1][0];
26
- if (t === "`" && e[2].includes("`")) continue;
27
- const o = e.index, c = new RegExp(
28
- `^ {0,3}${t}{${e[1].length},}[ \\t]*\\r?$`,
29
- "gm"
30
- );
31
- c.lastIndex = o + e[0].length;
32
- const l = c.exec(s);
33
- if (!l)
34
- return { start: o, block: s.slice(o), complete: !1 };
35
- const r = l.index + l[0].length;
36
- return { start: o, end: r, block: s.slice(o, r), complete: !0 };
37
- }
38
- return null;
39
- }, Z = (s) => {
40
- const n = s.split(/\r?\n/).map((e) => e.trim()).filter(Boolean);
41
- return n.length <= 1 ? s : n[0];
42
- }, q = (s, n) => {
43
- if (!Q.test(s)) return s;
44
- const e = s.slice(1, -1);
45
- if (!n) return e;
46
- const t = e.match(X);
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);
47
93
  if (!t || typeof t.index != "number")
48
- return e;
49
- const o = e.slice(0, t.index), c = e.slice(t.index + t[0].length), l = z(o), r = z(c);
50
- return !l || !r ? e : `${l}${t[0]}${r}`;
51
- }, J = (s) => {
52
- const n = [], e = /```/g;
53
- let t;
54
- for (; (t = e.exec(s)) !== null; ) {
55
- const o = t.index, c = e.exec(s);
56
- if (!c) {
57
- n.push({ start: o, end: s.length });
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 });
58
108
  break;
59
109
  }
60
- n.push({ start: o, end: c.index + 3 });
110
+ n.push({ start: t, end: l.index + 3 });
61
111
  }
62
112
  return n;
63
- }, M = (s, n) => {
64
- let e = 0;
65
- for (let t = n - 1; t >= 0 && s[t] === "\\"; t--) e++;
66
- return e % 2 === 1;
67
- }, Y = (s, n) => {
68
- const e = [], t = /\r?\n[ \t]*\r?\n/g;
69
- let o = 0;
70
- do {
71
- const c = t.exec(s), l = c?.index ?? s.length, r = s.slice(o, l), d = /`+/g;
72
- let a;
73
- for (; (a = d.exec(r)) !== null; ) {
74
- if (M(r, a.index)) continue;
75
- const b = o + a.index, g = a[0];
76
- let p;
77
- for (; (p = d.exec(r)) !== null; )
78
- if (p[0] === g) {
79
- e.push({
80
- start: b,
81
- end: o + p.index + g.length
82
- });
83
- break;
84
- }
85
- if (!p) {
86
- n && l === s.length && e.push({ start: b, end: l });
87
- break;
88
- }
89
- }
90
- if (!c) break;
91
- o = t.lastIndex;
92
- } while (o < s.length);
93
- return e;
94
- }, C = (s, n) => n.some(({ start: e, end: t }) => s >= e && s < t), S = (s, n, e) => {
95
- const t = n.flags.includes("g") ? n.flags : `${n.flags}g`, o = new RegExp(n.source, t);
96
- let c;
97
- for (; (c = o.exec(s)) !== null; )
98
- if (!M(s, c.index) && !C(c.index, e))
99
- return c.index;
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;
100
123
  return -1;
101
- }, tt = (s, n) => {
102
- let e = s.length, t;
103
- for (F.lastIndex = 0; t = F.exec(s); )
104
- if (!(t.index <= n)) {
105
- e = t.index + t[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;
106
129
  break;
107
130
  }
108
- return e;
109
- }, et = (s) => {
110
- if (!s.length) return s;
131
+ return s;
132
+ }, re = (e) => {
133
+ if (!e.length) return e;
111
134
  const n = [];
112
- return s.forEach((e) => {
113
- if (e.type !== "sandbox") {
114
- n.push(e);
135
+ return e.forEach((s) => {
136
+ if (s.type !== "sandbox") {
137
+ n.push(s);
115
138
  return;
116
139
  }
117
- w.lastIndex = 0;
118
- let t = 0, o;
119
- for (; (o = w.exec(e.value)) !== null; ) {
120
- const l = e.value.slice(t, o.index);
121
- l.trim() && n.push({ type: "sandbox", value: l }), n.push({ type: "markdown", value: o[0] }), t = o.index + o[0].length;
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;
122
145
  }
123
- const c = e.value.slice(t);
124
- c.trim() && n.push({ type: "sandbox", value: c });
125
- }), n;
126
- }, nt = (s) => {
127
- let n = null;
128
- return H.forEach((e) => {
129
- const t = e.exec(s);
130
- if (!t || typeof t.index != "number") return;
131
- const o = t.index, c = t.index + t[0].length;
132
- (!n || o < n.start) && (n = { start: o, end: c });
146
+ const l = s.value.slice(i);
147
+ l.trim() && n.push({ type: "sandbox", value: l });
133
148
  }), n;
134
- }, st = (...s) => s.reduce((n, e) => e && (!n || e.start < n.start) ? e : n, null), L = (s, n) => {
135
- const e = S(
136
- s,
137
- $,
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,
138
163
  n
139
164
  );
140
- if (e === -1) return null;
141
- const t = s.slice(e).match($);
142
- return t ? { start: e, end: e + t[0].length } : null;
143
- }, ot = (s, n) => {
144
- const e = S(
145
- s,
146
- B,
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,
147
172
  n
148
173
  );
149
- if (e === -1) return null;
150
- const t = s.slice(e).match(B);
151
- return t ? { start: e, end: e + t[0].length } : null;
152
- }, ct = (s) => B.test(s.trim()), lt = (s) => {
153
- const n = s.match(/^\s*\|.+\|\s*$/m);
154
- if (!n || typeof n.index != "number") return null;
155
- const e = n[0].match(/^\s*/)?.[0].length ?? 0, t = n.index + e, o = s.slice(t).split(`
156
- `), c = [];
157
- for (const r of o) {
158
- if (!r.trim().startsWith("|")) break;
159
- c.push(r);
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
+ }
229
+ if (t === -1) return null;
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);
160
272
  }
161
- const l = c.join(`
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;
279
+ }
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(`
162
337
  `);
163
- return { start: t, block: l, end: t + l.length };
164
- }, h = (s, n = !1, e = !1) => {
165
- const t = e ? s : q(s, n), o = (i) => et(i), c = (i) => e ? i.length > 0 : !!i.trim(), l = e ? G(t) : j(t), r = [
166
- ...e ? l ? [
167
- {
168
- start: l.start,
169
- end: l.complete ? l.end : t.length
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;
170
395
  }
171
- ] : [] : J(t),
172
- ...Y(t, e)
173
- ];
174
- let d = S(
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);
433
+ }
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(
175
453
  t,
176
- K,
177
- r
454
+ Y,
455
+ d
178
456
  );
179
- if (l && (!e || d === -1 || l.start < d)) {
180
- if (!l.complete)
181
- return n && e && l.start > 0 ? o([
182
- ...h(
183
- t.slice(0, l.start),
184
- !0,
185
- e
186
- ),
187
- { type: "markdown", value: t.slice(l.start) }
188
- ]) : o(n ? [{ type: "markdown", value: t }] : [{ type: "markdown", value: l.block }]);
457
+ if (c) {
458
+ if (!c.complete)
459
+ return l([
460
+ { type: "markdown", value: n ? t : c.block }
461
+ ]);
189
462
  if (!n)
190
- return o([{ type: "markdown", value: l.block }]);
191
- const i = [], u = t.slice(0, l.start), f = e ? u : Z(u);
192
- c(f) && (e ? i.push(
193
- ...h(f, !0, e)
194
- ) : i.push({ type: "text", value: f })), i.push({ type: "markdown", value: l.block });
195
- const m = t.slice(l.end);
196
- return c(m) && i.push(...h(m, !0, e)), o(i);
197
- }
198
- if (e && d === -1) {
199
- const i = /<(!?[a-z]*)$/i.exec(t), u = [
200
- "!doctype",
201
- "script",
202
- "style",
203
- "link",
204
- "iframe",
205
- "html",
206
- "head",
207
- "body",
208
- "meta",
209
- "title",
210
- "base",
211
- "template",
212
- "div",
213
- "section",
214
- "article",
215
- "main"
216
- ];
217
- i && !M(t, i.index) && !C(i.index, r) && u.some((f) => f.startsWith(i[1].toLowerCase())) && (d = i.index);
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);
218
468
  }
219
- const a = S(
469
+ const u = N(
220
470
  t,
221
471
  /<svg\b/i,
222
- r
223
- ), b = d !== -1 && a !== -1 && d < a, g = L(t, r), p = !!g && a !== -1 && g.start < a;
224
- if (a !== -1 && !b && !p) {
225
- const i = t.slice(0, a), u = t.indexOf("</svg>", a), f = u === -1 ? e ? t.slice(a) : `${t.slice(a)}</svg>` : t.slice(a, u + 6), m = u === -1 ? "" : t.slice(u + 6);
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);
226
476
  if (n) {
227
- const I = [];
228
- return c(i) && I.push({ type: "text", value: i }), I.push({ type: "markdown", value: f }), c(m) && I.push(...h(m, !0, e)), o(I);
477
+ const _ = [];
478
+ return a(h) && _.push({ type: "text", value: h }), _.push({ type: "markdown", value: k }), a(z) && _.push(...w(z, !0)), l(_);
229
479
  }
230
- if (u === -1)
231
- return o([{ type: "markdown", value: f }]);
480
+ if (b === -1)
481
+ return l([{ type: "markdown", value: k }]);
232
482
  }
233
- const k = lt(t);
234
- if (k) {
235
- const i = [], u = t.slice(0, k.start);
236
- n && c(u) && i.push(...h(u, !0, e)), i.push({ type: "markdown", value: k.block });
237
- const f = t.slice(k.end), m = f.length < t.length;
238
- return c(f) && m && i.push(
239
- ...n ? h(f, !0, e) : h(f, !1, e)
240
- ), o(i);
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);
241
489
  }
242
- const D = nt(t), V = L(t, r), W = ot(
243
- t,
244
- r
245
- ), x = st(
246
- D,
247
- V,
248
- W
490
+ const S = fe(
491
+ de(t),
492
+ V(t, d),
493
+ me(t, d)
249
494
  );
250
- if (d === -1 && !x)
251
- return n && c(t) ? o([{ type: "text", value: t }]) : [];
252
- const v = !!x && (d === -1 || x.start <= d), y = v ? x.start : d, R = v ? x.end : e ? U(t, y) : tt(t, y), E = [], A = t.slice(0, y), T = t.slice(y, R), N = v && ct(T), _ = N && !e ? A.trimEnd() : A, O = t.slice(R), P = N && !e ? O.trimStart() : O;
253
- return n && c(_) && E.push({ type: "text", value: _ }), E.push({
254
- type: v ? "markdown" : "sandbox",
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",
255
500
  value: T
256
- }), c(P) && E.push(
257
- ...h(P, n, e)
258
- ), o(E);
501
+ }), a(E) && R.push(...w(E, n)), l(R);
259
502
  };
260
503
  export {
261
- h as splitContentSegments
504
+ Ie as normalizeWrappedSandboxContent,
505
+ w as splitContentSegments
262
506
  };
263
507
  //# sourceMappingURL=split-content.es.js.map