@intlayer/design-system 6.1.3 → 6.1.5

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 (99) hide show
  1. package/dist/.vite/manifest.json +63 -7
  2. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +2 -2
  3. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
  4. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +1 -1
  5. package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.cjs +2 -1
  6. package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.cjs.map +1 -1
  7. package/dist/components/ExpandCollapse/expandCollapse.content.cjs +2 -1
  8. package/dist/components/ExpandCollapse/expandCollapse.content.cjs.map +1 -1
  9. package/dist/components/Headers/index.cjs +12 -0
  10. package/dist/components/Headers/index.cjs.map +1 -1
  11. package/dist/components/Headers/index.d.ts +1 -0
  12. package/dist/components/Headers/index.d.ts.map +1 -1
  13. package/dist/components/Headers/index.mjs +13 -1
  14. package/dist/components/Headers/index.mjs.map +1 -1
  15. package/dist/components/IDE/Code.cjs +1 -1
  16. package/dist/components/IDE/Code.cjs.map +1 -1
  17. package/dist/components/IDE/Code.mjs +1 -1
  18. package/dist/components/IDE/Code.mjs.map +1 -1
  19. package/dist/components/IDE/MarkDownRender.cjs +2 -2
  20. package/dist/components/IDE/MarkDownRender.cjs.map +1 -1
  21. package/dist/components/IDE/MarkDownRender.d.ts.map +1 -1
  22. package/dist/components/IDE/MarkDownRender.mjs +2 -2
  23. package/dist/components/IDE/MarkDownRender.mjs.map +1 -1
  24. package/dist/components/IDE/code.content.cjs +2 -1
  25. package/dist/components/IDE/code.content.cjs.map +1 -1
  26. package/dist/components/IDE/copyCode.content.cjs +2 -1
  27. package/dist/components/IDE/copyCode.content.cjs.map +1 -1
  28. package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.cjs +2 -1
  29. package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.cjs.map +1 -1
  30. package/dist/components/LocaleSwitcherDropDown/localeSwitcher.content.cjs +2 -1
  31. package/dist/components/LocaleSwitcherDropDown/localeSwitcher.content.cjs.map +1 -1
  32. package/dist/components/MarkDownRender/MarkDownRender.cjs +189 -0
  33. package/dist/components/MarkDownRender/MarkDownRender.cjs.map +1 -0
  34. package/dist/components/MarkDownRender/MarkDownRender.d.ts +12 -0
  35. package/dist/components/MarkDownRender/MarkDownRender.d.ts.map +1 -0
  36. package/dist/components/MarkDownRender/MarkDownRender.mjs +189 -0
  37. package/dist/components/MarkDownRender/MarkDownRender.mjs.map +1 -0
  38. package/dist/components/MarkDownRender/index.cjs +2 -150
  39. package/dist/components/MarkDownRender/index.cjs.map +1 -1
  40. package/dist/components/MarkDownRender/index.d.ts +1 -11
  41. package/dist/components/MarkDownRender/index.d.ts.map +1 -1
  42. package/dist/components/MarkDownRender/index.mjs +1 -149
  43. package/dist/components/MarkDownRender/index.mjs.map +1 -1
  44. package/dist/components/MarkDownRender/processor.cjs +1819 -0
  45. package/dist/components/MarkDownRender/processor.cjs.map +1 -0
  46. package/dist/components/MarkDownRender/processor.d.ts +368 -0
  47. package/dist/components/MarkDownRender/processor.d.ts.map +1 -0
  48. package/dist/components/MarkDownRender/processor.mjs +1819 -0
  49. package/dist/components/MarkDownRender/processor.mjs.map +1 -0
  50. package/dist/components/Tab/Tab.cjs +171 -0
  51. package/dist/components/Tab/Tab.cjs.map +1 -0
  52. package/dist/components/Tab/Tab.d.ts +24 -0
  53. package/dist/components/Tab/Tab.d.ts.map +1 -0
  54. package/dist/components/Tab/Tab.mjs +171 -0
  55. package/dist/components/Tab/Tab.mjs.map +1 -0
  56. package/dist/components/Tab/TabContext.cjs +28 -0
  57. package/dist/components/Tab/TabContext.cjs.map +1 -0
  58. package/dist/components/Tab/TabContext.d.ts +19 -0
  59. package/dist/components/Tab/TabContext.d.ts.map +1 -0
  60. package/dist/components/Tab/TabContext.mjs +28 -0
  61. package/dist/components/Tab/TabContext.mjs.map +1 -0
  62. package/dist/components/Tab/index.cjs +5 -0
  63. package/dist/components/Tab/index.cjs.map +1 -0
  64. package/dist/components/Tab/index.d.ts +2 -0
  65. package/dist/components/Tab/index.d.ts.map +1 -0
  66. package/dist/components/Tab/index.mjs +5 -0
  67. package/dist/components/Tab/index.mjs.map +1 -0
  68. package/dist/components/TabSelector/TabSelector.cjs +6 -1
  69. package/dist/components/TabSelector/TabSelector.cjs.map +1 -1
  70. package/dist/components/TabSelector/TabSelector.d.ts +1 -1
  71. package/dist/components/TabSelector/TabSelector.d.ts.map +1 -1
  72. package/dist/components/TabSelector/TabSelector.mjs +6 -1
  73. package/dist/components/TabSelector/TabSelector.mjs.map +1 -1
  74. package/dist/components/Table/Table.cjs +15 -8
  75. package/dist/components/Table/Table.cjs.map +1 -1
  76. package/dist/components/Table/Table.d.ts.map +1 -1
  77. package/dist/components/Table/Table.mjs +15 -8
  78. package/dist/components/Table/Table.mjs.map +1 -1
  79. package/dist/components/Table/table.content.cjs +2 -1
  80. package/dist/components/Table/table.content.cjs.map +1 -1
  81. package/dist/components/index.cjs +5 -2
  82. package/dist/components/index.cjs.map +1 -1
  83. package/dist/components/index.d.ts +1 -0
  84. package/dist/components/index.d.ts.map +1 -1
  85. package/dist/components/index.mjs +5 -2
  86. package/dist/components/index.mjs.map +1 -1
  87. package/dist/hooks/index.cjs +2 -0
  88. package/dist/hooks/index.cjs.map +1 -1
  89. package/dist/hooks/index.d.ts +1 -0
  90. package/dist/hooks/index.d.ts.map +1 -1
  91. package/dist/hooks/index.mjs +2 -0
  92. package/dist/hooks/index.mjs.map +1 -1
  93. package/dist/hooks/useHorizontalSwipe.cjs +144 -0
  94. package/dist/hooks/useHorizontalSwipe.cjs.map +1 -0
  95. package/dist/hooks/useHorizontalSwipe.d.ts +26 -0
  96. package/dist/hooks/useHorizontalSwipe.d.ts.map +1 -0
  97. package/dist/hooks/useHorizontalSwipe.mjs +144 -0
  98. package/dist/hooks/useHorizontalSwipe.mjs.map +1 -0
  99. package/package.json +44 -20
@@ -0,0 +1,1819 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { createElement, cloneElement } from "react";
3
+ var define_process_env_default = {};
4
+ const RuleType = {
5
+ blockQuote: "0",
6
+ breakLine: "1",
7
+ breakThematic: "2",
8
+ codeBlock: "3",
9
+ codeFenced: "4",
10
+ codeInline: "5",
11
+ footnote: "6",
12
+ footnoteReference: "7",
13
+ gfmTask: "8",
14
+ heading: "9",
15
+ headingSetext: "10",
16
+ /** only available if not `disableHTMLParsing` */
17
+ htmlBlock: "11",
18
+ htmlComment: "12",
19
+ /** only available if not `disableHTMLParsing` */
20
+ htmlSelfClosing: "13",
21
+ /** Custom components like <Tabs>, <TabItem> */
22
+ customComponent: "34",
23
+ image: "14",
24
+ link: "15",
25
+ /** emits a `link` 'node', does not render directly */
26
+ linkAngleBraceStyleDetector: "16",
27
+ /** emits a `link` 'node', does not render directly */
28
+ linkBareUrlDetector: "17",
29
+ /** emits a `link` 'node', does not render directly */
30
+ linkMailtoDetector: "18",
31
+ newlineCoalescer: "19",
32
+ orderedList: "20",
33
+ paragraph: "21",
34
+ ref: "22",
35
+ refImage: "23",
36
+ refLink: "24",
37
+ table: "25",
38
+ tableSeparator: "26",
39
+ text: "27",
40
+ textBolded: "28",
41
+ textEmphasized: "29",
42
+ textEscaped: "30",
43
+ textMarked: "31",
44
+ textStrikethroughed: "32",
45
+ unorderedList: "33"
46
+ };
47
+ if (define_process_env_default.NODE_ENV === "test") {
48
+ Object.keys(RuleType).forEach((key) => RuleType[key] = key);
49
+ }
50
+ const Priority = {
51
+ /**
52
+ * anything that must scan the tree before everything else
53
+ */
54
+ MAX: 0,
55
+ /**
56
+ * scans for block-level constructs
57
+ */
58
+ HIGH: 1,
59
+ /**
60
+ * inline w/ more priority than other inline
61
+ */
62
+ MED: 2,
63
+ /**
64
+ * inline elements
65
+ */
66
+ LOW: 3,
67
+ /**
68
+ * bare text and stuff that is considered leftovers
69
+ */
70
+ MIN: 4
71
+ };
72
+ const ATTRIBUTE_TO_JSX_PROP_MAP = [
73
+ "allowFullScreen",
74
+ "allowTransparency",
75
+ "autoComplete",
76
+ "autoFocus",
77
+ "autoPlay",
78
+ "cellPadding",
79
+ "cellSpacing",
80
+ "charSet",
81
+ "classId",
82
+ "colSpan",
83
+ "contentEditable",
84
+ "contextMenu",
85
+ "crossOrigin",
86
+ "encType",
87
+ "formAction",
88
+ "formEncType",
89
+ "formMethod",
90
+ "formNoValidate",
91
+ "formTarget",
92
+ "frameBorder",
93
+ "hrefLang",
94
+ "inputMode",
95
+ "keyParams",
96
+ "keyType",
97
+ "marginHeight",
98
+ "marginWidth",
99
+ "maxLength",
100
+ "mediaGroup",
101
+ "minLength",
102
+ "noValidate",
103
+ "radioGroup",
104
+ "readOnly",
105
+ "rowSpan",
106
+ "spellCheck",
107
+ "srcDoc",
108
+ "srcLang",
109
+ "srcSet",
110
+ "tabIndex",
111
+ "useMap"
112
+ ].reduce(
113
+ (obj, x) => {
114
+ obj[x.toLowerCase()] = x;
115
+ return obj;
116
+ },
117
+ { class: "className", for: "htmlFor" }
118
+ );
119
+ const namedCodesToUnicode = {
120
+ amp: "&",
121
+ apos: "'",
122
+ gt: ">",
123
+ lt: "<",
124
+ nbsp: " ",
125
+ quot: "“"
126
+ };
127
+ const DO_NOT_PROCESS_HTML_ELEMENTS = ["style", "script", "pre"];
128
+ const ATTRIBUTES_TO_SANITIZE = [
129
+ "src",
130
+ "href",
131
+ "data",
132
+ "formAction",
133
+ "srcDoc",
134
+ "action"
135
+ ];
136
+ const ATTR_EXTRACTOR_R = /([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi;
137
+ const AUTOLINK_MAILTO_CHECK_R = /mailto:/i;
138
+ const BLOCK_END_R = /\n{2,}$/;
139
+ const BLOCKQUOTE_R = /^(\s*>[\s\S]*?)(?=\n\n|$)/;
140
+ const BLOCKQUOTE_TRIM_LEFT_MULTILINE_R = /^ *> ?/gm;
141
+ const BLOCKQUOTE_ALERT_R = /^(?:\[!([^\]]*)\]\n)?([\s\S]*)/;
142
+ const BREAK_LINE_R = /^ {2,}\n/;
143
+ const BREAK_THEMATIC_R = /^(?:( *[-*_])){3,} *(?:\n *)+\n/;
144
+ const CODE_BLOCK_FENCED_R = /^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/;
145
+ const CODE_BLOCK_R = /^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/;
146
+ const CODE_INLINE_R = /^(`+)((?:\\`|(?!\1)`|[^`])+)\1/;
147
+ const CONSECUTIVE_NEWLINE_R = /^(?:\n *)*\n/;
148
+ const CR_NEWLINE_R = /\r\n?/g;
149
+ const FOOTNOTE_R = /^\[\^([^\]]+)](:(.*)((\n+ {4,}.*)|(\n(?!\[\^).+))*)/;
150
+ const FOOTNOTE_REFERENCE_R = /^\[\^([^\]]+)]/;
151
+ const FORMFEED_R = /\f/g;
152
+ const FRONT_MATTER_R = /^---[ \t]*\n(.|\n)*\n---[ \t]*\n/;
153
+ const GFM_TASK_R = /^\s*?\[(x|\s)\]/;
154
+ const HEADING_R = /^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/;
155
+ const HEADING_ATX_COMPLIANT_R = /^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/;
156
+ const HEADING_SETEXT_R = /^([^\n]+)\n *(=|-){3,} *\n/;
157
+ const HTML_BLOCK_ELEMENT_R = /^ *(?!<[a-zA-Z][^ >/]* ?\/>)<([a-zA-Z][^ >/]*) ?((?:[^>]*[^/])?)>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/i;
158
+ const HTML_CHAR_CODE_R = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi;
159
+ const HTML_COMMENT_R = /^<!--[\s\S]*?(?:-->)/;
160
+ const HTML_CUSTOM_ATTR_R = /^(data|aria|x)-[a-z_][a-z\d_.-]*$/;
161
+ const HTML_SELF_CLOSING_ELEMENT_R = /^ *<([a-zA-Z][a-zA-Z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i;
162
+ const CUSTOM_COMPONENT_R = /^ *<([A-Z][a-zA-Z0-9]*)(?:\s+((?:<.*?>|[^>])*))?>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/;
163
+ const INTERPOLATION_R = /^\{.*\}$/;
164
+ const LINK_AUTOLINK_BARE_URL_R = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/;
165
+ const LINK_AUTOLINK_MAILTO_R = /^<([^ >]+@[^ >]+)>/;
166
+ const LINK_AUTOLINK_R = /^<([^ >]+:\/[^ >]+)>/;
167
+ const CAPTURE_LETTER_AFTER_HYPHEN = /-([a-z])?/gi;
168
+ const NP_TABLE_R = /^(\|.*)\n(?: *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*))?\n?/;
169
+ const PARAGRAPH_R = /^[^\n]+(?: \n|\n{2,})/;
170
+ const REFERENCE_IMAGE_OR_LINK = /^\[([^\]]*)\]:\s+<?([^\s>]+)>?\s*("([^"]*)")?/;
171
+ const REFERENCE_IMAGE_R = /^!\[([^\]]*)\] ?\[([^\]]*)\]/;
172
+ const REFERENCE_LINK_R = /^\[([^\]]*)\] ?\[([^\]]*)\]/;
173
+ const SHOULD_RENDER_AS_BLOCK_R = /(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/;
174
+ const TAB_R = /\t/g;
175
+ const TABLE_TRIM_PIPES = /(^ *\||\| *$)/g;
176
+ const TABLE_CENTER_ALIGN = /^ *:-+: *$/;
177
+ const TABLE_LEFT_ALIGN = /^ *:-+ *$/;
178
+ const TABLE_RIGHT_ALIGN = /^ *-+: *$/;
179
+ const LOOKAHEAD = (double) => `(?=[\\s\\S]+?\\1${double ? "\\1" : ""})`;
180
+ const INLINE_SKIP_R = "((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\\\1|[\\s\\S])+?)";
181
+ const TEXT_BOLD_R = new RegExp(
182
+ `^([*_])\\1${LOOKAHEAD(1)}${INLINE_SKIP_R}\\1\\1(?!\\1)`
183
+ );
184
+ const TEXT_EMPHASIZED_R = new RegExp(
185
+ `^([*_])${LOOKAHEAD(0)}${INLINE_SKIP_R}\\1(?!\\1)`
186
+ );
187
+ const TEXT_MARKED_R = new RegExp(`^(==)${LOOKAHEAD(0)}${INLINE_SKIP_R}\\1`);
188
+ const TEXT_STRIKETHROUGHED_R = new RegExp(
189
+ `^(~~)${LOOKAHEAD(0)}${INLINE_SKIP_R}\\1`
190
+ );
191
+ const SHORTCODE_R = /^(:[a-zA-Z0-9-_]+:)/;
192
+ const TEXT_ESCAPED_R = /^\\([^0-9A-Za-z\s])/;
193
+ const UNESCAPE_R = /\\([^0-9A-Za-z\s])/g;
194
+ const TEXT_PLAIN_R = /^[\s\S](?:(?! \n|[0-9]\.|http)[^=*_~\-\n:<`\\\[!])*/;
195
+ const TRIM_STARTING_NEWLINES = /^\n+/;
196
+ const HTML_LEFT_TRIM_AMOUNT_R = /^([ \t]*)/;
197
+ const ORDERED = 1;
198
+ const UNORDERED = 2;
199
+ const LIST_LOOKBEHIND_R = /(?:^|\n)( *)$/;
200
+ const ORDERED_LIST_BULLET = "(?:\\d+\\.)";
201
+ const UNORDERED_LIST_BULLET = "(?:[*+-])";
202
+ const generateListItemPrefix = (type) => {
203
+ return "( *)(" + (type === ORDERED ? ORDERED_LIST_BULLET : UNORDERED_LIST_BULLET) + ") +";
204
+ };
205
+ const ORDERED_LIST_ITEM_PREFIX = generateListItemPrefix(ORDERED);
206
+ const UNORDERED_LIST_ITEM_PREFIX = generateListItemPrefix(UNORDERED);
207
+ const generateListItemPrefixRegex = (type) => {
208
+ return new RegExp(
209
+ "^" + (type === ORDERED ? ORDERED_LIST_ITEM_PREFIX : UNORDERED_LIST_ITEM_PREFIX)
210
+ );
211
+ };
212
+ const ORDERED_LIST_ITEM_PREFIX_R = generateListItemPrefixRegex(ORDERED);
213
+ const UNORDERED_LIST_ITEM_PREFIX_R = generateListItemPrefixRegex(UNORDERED);
214
+ const generateListItemRegex = (type) => {
215
+ return new RegExp(
216
+ "^" + (type === ORDERED ? ORDERED_LIST_ITEM_PREFIX : UNORDERED_LIST_ITEM_PREFIX) + "[^\\n]*(?:\\n(?!\\1" + (type === ORDERED ? ORDERED_LIST_BULLET : UNORDERED_LIST_BULLET) + " )[^\\n]*)*(\\n|$)",
217
+ "gm"
218
+ );
219
+ };
220
+ const ORDERED_LIST_ITEM_R = generateListItemRegex(ORDERED);
221
+ const UNORDERED_LIST_ITEM_R = generateListItemRegex(UNORDERED);
222
+ const generateListRegex = (type) => {
223
+ const bullet = type === ORDERED ? ORDERED_LIST_BULLET : UNORDERED_LIST_BULLET;
224
+ return new RegExp(
225
+ "^( *)(" + bullet + ") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1" + bullet + " (?!" + bullet + " ))\\n*|\\s*\\n*$)"
226
+ );
227
+ };
228
+ const ORDERED_LIST_R = generateListRegex(ORDERED);
229
+ const UNORDERED_LIST_R = generateListRegex(UNORDERED);
230
+ const generateListRule = (type, factory) => {
231
+ const ordered = type === ORDERED;
232
+ const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R;
233
+ const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R;
234
+ const LIST_ITEM_PREFIX_R = ordered ? ORDERED_LIST_ITEM_PREFIX_R : UNORDERED_LIST_ITEM_PREFIX_R;
235
+ return {
236
+ _qualify: (source) => LIST_ITEM_PREFIX_R.test(source),
237
+ _match: allowInline((source, state) => {
238
+ const isStartOfLine = LIST_LOOKBEHIND_R.exec(state.prevCapture ?? "");
239
+ const isListAllowed = state.list ?? (!state.inline && !state.simple);
240
+ if (isStartOfLine && isListAllowed) {
241
+ source = isStartOfLine[1] + source;
242
+ return LIST_R.exec(source);
243
+ } else {
244
+ return null;
245
+ }
246
+ }),
247
+ _order: Priority.HIGH,
248
+ _parse(capture, parse, state) {
249
+ const bullet = capture[2];
250
+ const start = ordered ? +bullet : void 0;
251
+ const items = capture[0].replace(BLOCK_END_R, "\n").match(LIST_ITEM_R);
252
+ if (!items) return { items: [], ordered, start };
253
+ let lastItemWasAParagraph = false;
254
+ const itemContent = items.map((item, i) => {
255
+ const spaceMatch = LIST_ITEM_PREFIX_R.exec(item);
256
+ if (!spaceMatch) return [];
257
+ const space = spaceMatch[0].length;
258
+ const spaceRegex = new RegExp("^ {1," + space + "}", "gm");
259
+ const content = item.replace(spaceRegex, "").replace(LIST_ITEM_PREFIX_R, "");
260
+ const isLastItem = i === items.length - 1;
261
+ const containsBlocks = content.indexOf("\n\n") !== -1;
262
+ const thisItemIsAParagraph = containsBlocks || isLastItem && lastItemWasAParagraph;
263
+ lastItemWasAParagraph = thisItemIsAParagraph;
264
+ const oldStateInline = state.inline;
265
+ const oldStateList = state.list;
266
+ state.list = true;
267
+ let adjustedContent;
268
+ if (thisItemIsAParagraph) {
269
+ state.inline = false;
270
+ adjustedContent = trimEnd(content) + "\n\n";
271
+ } else {
272
+ state.inline = true;
273
+ adjustedContent = trimEnd(content);
274
+ }
275
+ const result = parse(adjustedContent, state);
276
+ state.inline = oldStateInline;
277
+ state.list = oldStateList;
278
+ return result;
279
+ });
280
+ return {
281
+ items: itemContent,
282
+ ordered,
283
+ start
284
+ };
285
+ },
286
+ _render(node, _output, state = {}) {
287
+ const Tag = node.ordered ? "ol" : "ul";
288
+ const props = { key: state.key };
289
+ if (node.ordered && node.start != null) props.start = node.start;
290
+ if (factory) {
291
+ return factory(
292
+ Tag,
293
+ props,
294
+ ...node.items.map(
295
+ (item, i) => factory("li", { key: i }, _output(item, state))
296
+ )
297
+ );
298
+ }
299
+ return /* @__PURE__ */ jsx(
300
+ Tag,
301
+ {
302
+ start: node.type === RuleType.orderedList ? node.start : void 0,
303
+ children: node.items.map((item, i) => {
304
+ return /* @__PURE__ */ jsx("li", { children: _output(item, state) }, i);
305
+ })
306
+ },
307
+ state.key
308
+ );
309
+ }
310
+ };
311
+ };
312
+ const LINK_INSIDE = "(?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*";
313
+ const LINK_HREF_AND_TITLE = `\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['"]([\\s\\S]*?)['"])?\\s*`;
314
+ const LINK_R = new RegExp(
315
+ "^\\[(" + LINK_INSIDE + ")\\]\\(" + LINK_HREF_AND_TITLE + "\\)"
316
+ );
317
+ const IMAGE_R = /^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;
318
+ const trimEnd = (str) => {
319
+ let end = str.length;
320
+ while (end > 0 && str[end - 1] <= " ") end--;
321
+ return str.slice(0, end);
322
+ };
323
+ const startsWith = (str, prefix) => {
324
+ return str.startsWith(prefix);
325
+ };
326
+ const qualifies = (source, state, qualify) => {
327
+ if (Array.isArray(qualify)) {
328
+ for (let i = 0; i < qualify.length; i++) {
329
+ if (startsWith(source, qualify[i])) return true;
330
+ }
331
+ return false;
332
+ }
333
+ return qualify(source, state);
334
+ };
335
+ const unquote = (str) => {
336
+ const first = str[0];
337
+ if ((first === '"' || first === "'") && str.length >= 2 && str[str.length - 1] === first) {
338
+ return str.slice(1, -1);
339
+ }
340
+ return str;
341
+ };
342
+ const slugify = (str) => str.replace(/[ÀÁÂÃÄÅàáâãä忯]/g, "a").replace(/[çÇ]/g, "c").replace(/[ðÐ]/g, "d").replace(/[ÈÉÊËéèêë]/g, "e").replace(/[ÏïÎîÍíÌì]/g, "i").replace(/[Ññ]/g, "n").replace(/[øØœŒÕõÔôÓóÒò]/g, "o").replace(/[ÜüÛûÚúÙù]/g, "u").replace(/[ŸÿÝý]/g, "y").replace(/[^a-z0-9- ]/gi, "").replace(/ /gi, "-").toLowerCase();
343
+ const parseTableAlignCapture = (alignCapture) => {
344
+ if (TABLE_RIGHT_ALIGN.test(alignCapture)) {
345
+ return "right";
346
+ } else if (TABLE_CENTER_ALIGN.test(alignCapture)) {
347
+ return "center";
348
+ } else if (TABLE_LEFT_ALIGN.test(alignCapture)) {
349
+ return "left";
350
+ }
351
+ return "left";
352
+ };
353
+ const parseTableRow = (source, parse, state, tableOutput) => {
354
+ const start = performance.now();
355
+ const prevInTable = state.inTable;
356
+ state.inTable = true;
357
+ let cells = [[]];
358
+ let acc = "";
359
+ const flush = () => {
360
+ if (!acc) return;
361
+ const cell = cells[cells.length - 1];
362
+ cell.push.apply(cell, parse(acc, state));
363
+ acc = "";
364
+ };
365
+ source.trim().split(/(`[^`]*`|\\\||\|)/).filter(Boolean).forEach((fragment, i, arr) => {
366
+ if (fragment.trim() === "|") {
367
+ flush();
368
+ if (tableOutput) {
369
+ if (i !== 0 && i !== arr.length - 1) {
370
+ cells.push([]);
371
+ }
372
+ return;
373
+ }
374
+ }
375
+ acc += fragment;
376
+ });
377
+ flush();
378
+ state.inTable = prevInTable;
379
+ const duration = performance.now() - start;
380
+ if (duration > 1) {
381
+ console.log(
382
+ `parseTableRow: ${duration.toFixed(3)}ms, source length: ${source.length}, cells count: ${cells.length}`
383
+ );
384
+ }
385
+ return cells;
386
+ };
387
+ const parseTableAlign = (source) => {
388
+ const alignText = source.replace(TABLE_TRIM_PIPES, "").split("|");
389
+ return alignText.map(parseTableAlignCapture);
390
+ };
391
+ const parseTableCells = (source, parse, state) => {
392
+ const start = performance.now();
393
+ const rowsText = source.trim().split("\n");
394
+ const result = rowsText.map((rowText) => {
395
+ return parseTableRow(rowText, parse, state, true);
396
+ });
397
+ const duration = performance.now() - start;
398
+ if (duration > 1) {
399
+ console.log(
400
+ `parseTableCells: ${duration.toFixed(3)}ms, source length: ${source.length}, rows count: ${rowsText.length}`
401
+ );
402
+ }
403
+ return result;
404
+ };
405
+ const parseTable = (capture, parse, state) => {
406
+ state.inline = true;
407
+ const align = capture[2] ? parseTableAlign(capture[2]) : [];
408
+ const cells = capture[3] ? parseTableCells(capture[3], parse, state) : [];
409
+ const header = parseTableRow(capture[1], parse, state, !!cells.length);
410
+ state.inline = false;
411
+ return cells.length ? {
412
+ align,
413
+ cells,
414
+ header,
415
+ type: RuleType.table
416
+ } : {
417
+ children: header.flat(),
418
+ type: RuleType.paragraph
419
+ };
420
+ };
421
+ const getTableStyle = (node, colIndex) => node.align[colIndex] == null ? {} : {
422
+ textAlign: node.align[colIndex]
423
+ };
424
+ const normalizeAttributeKey = (key) => {
425
+ const hyphenIndex = key.indexOf("-");
426
+ if (hyphenIndex !== -1 && key.match(HTML_CUSTOM_ATTR_R) === null) {
427
+ key = key.replace(CAPTURE_LETTER_AFTER_HYPHEN, (_, letter) => {
428
+ return letter.toUpperCase();
429
+ });
430
+ }
431
+ return key;
432
+ };
433
+ const parseStyleAttribute = (styleString) => {
434
+ const start = performance.now();
435
+ const styles = [];
436
+ let buffer = "";
437
+ let inUrl = false;
438
+ let inQuotes = false;
439
+ let quoteChar = "";
440
+ if (!styleString) return styles;
441
+ for (let i = 0; i < styleString.length; i++) {
442
+ const char = styleString[i];
443
+ if ((char === '"' || char === "'") && !inUrl) {
444
+ if (!inQuotes) {
445
+ inQuotes = true;
446
+ quoteChar = char;
447
+ } else if (char === quoteChar) {
448
+ inQuotes = false;
449
+ quoteChar = "";
450
+ }
451
+ }
452
+ if (char === "(" && buffer.endsWith("url")) {
453
+ inUrl = true;
454
+ } else if (char === ")" && inUrl) {
455
+ inUrl = false;
456
+ }
457
+ if (char === ";" && !inQuotes && !inUrl) {
458
+ const declaration2 = buffer.trim();
459
+ if (declaration2) {
460
+ const colonIndex = declaration2.indexOf(":");
461
+ if (colonIndex > 0) {
462
+ const key = declaration2.slice(0, colonIndex).trim();
463
+ const value = declaration2.slice(colonIndex + 1).trim();
464
+ styles.push([key, value]);
465
+ }
466
+ }
467
+ buffer = "";
468
+ } else {
469
+ buffer += char;
470
+ }
471
+ }
472
+ const declaration = buffer.trim();
473
+ if (declaration) {
474
+ const colonIndex = declaration.indexOf(":");
475
+ if (colonIndex > 0) {
476
+ const key = declaration.slice(0, colonIndex).trim();
477
+ const value = declaration.slice(colonIndex + 1).trim();
478
+ styles.push([key, value]);
479
+ }
480
+ }
481
+ const duration = performance.now() - start;
482
+ if (duration > 1) {
483
+ console.log(
484
+ `parseStyleAttribute: ${duration.toFixed(3)}ms, styleString length: ${styleString.length}, styles count: ${styles.length}`
485
+ );
486
+ }
487
+ return styles;
488
+ };
489
+ const trimLeadingWhitespaceOutsideFences = (text, whitespace) => {
490
+ const start = performance.now();
491
+ if (!whitespace) return text;
492
+ const lines = text.split("\n");
493
+ let inFence = false;
494
+ let fenceToken = null;
495
+ const isFenceLine = (line) => line.match(/^\s*(`{3,}|~{3,})/);
496
+ const maybeToggleFence = (line) => {
497
+ const m = isFenceLine(line);
498
+ if (!m) return;
499
+ const token = m[1];
500
+ if (!inFence) {
501
+ inFence = true;
502
+ fenceToken = token;
503
+ } else if (fenceToken && line.includes(fenceToken)) {
504
+ inFence = false;
505
+ fenceToken = null;
506
+ }
507
+ };
508
+ const out = lines.map((line) => {
509
+ const fenceMatch = isFenceLine(line);
510
+ if (fenceMatch) {
511
+ const trimmedFenceLine = line.startsWith(whitespace) ? line.slice(whitespace.length) : line;
512
+ maybeToggleFence(line);
513
+ return trimmedFenceLine;
514
+ }
515
+ if (inFence) {
516
+ return line;
517
+ }
518
+ return line.startsWith(whitespace) ? line.slice(whitespace.length) : line;
519
+ });
520
+ const result = out.join("\n");
521
+ const duration = performance.now() - start;
522
+ if (duration > 1) {
523
+ console.log(
524
+ `trimLeadingWhitespaceOutsideFences: ${duration.toFixed(3)}ms, text length: ${text.length}, lines count: ${lines.length}`
525
+ );
526
+ }
527
+ return result;
528
+ };
529
+ const attributeValueToJSXPropValue = (tag, key, value, sanitizeUrlFn) => {
530
+ if (key === "style") {
531
+ return parseStyleAttribute(value).reduce(
532
+ (styles, [key2, value2]) => {
533
+ const camelCasedKey = key2.replace(
534
+ /(-[a-z])/g,
535
+ (substr) => substr[1].toUpperCase()
536
+ );
537
+ styles[camelCasedKey] = sanitizeUrlFn(
538
+ value2,
539
+ tag,
540
+ key2
541
+ );
542
+ return styles;
543
+ },
544
+ {}
545
+ );
546
+ } else if (ATTRIBUTES_TO_SANITIZE.indexOf(key) !== -1) {
547
+ return sanitizeUrlFn(unescape(value), tag, key);
548
+ } else if (value.match(INTERPOLATION_R)) {
549
+ value = unescape(value.slice(1, value.length - 1));
550
+ }
551
+ if (value === "true") {
552
+ return true;
553
+ } else if (value === "false") {
554
+ return false;
555
+ }
556
+ return value;
557
+ };
558
+ const normalizeWhitespace = (source) => {
559
+ const start = performance.now();
560
+ const result = source.replace(CR_NEWLINE_R, "\n").replace(FORMFEED_R, "").replace(TAB_R, " ");
561
+ const duration = performance.now() - start;
562
+ if (duration > 1) {
563
+ console.log(
564
+ `normalizeWhitespace: ${duration.toFixed(3)}ms, source length: ${source.length}`
565
+ );
566
+ }
567
+ return result;
568
+ };
569
+ const parserFor = (rules) => {
570
+ const start = performance.now();
571
+ var ruleList = Object.keys(rules);
572
+ if (define_process_env_default.NODE_ENV !== "production") {
573
+ ruleList.forEach((type) => {
574
+ const order = rules[type]._order;
575
+ if (typeof order !== "number" || !isFinite(order)) {
576
+ console.warn(
577
+ "intlayer: Invalid order for rule `" + type + "`: " + order
578
+ );
579
+ }
580
+ });
581
+ }
582
+ ruleList.sort((a, b) => {
583
+ return rules[a]._order - rules[b]._order || (a < b ? -1 : 1);
584
+ });
585
+ const nestedParse = (source, state = {}) => {
586
+ const parseStart = performance.now();
587
+ var result = [];
588
+ state.prevCapture = state.prevCapture || "";
589
+ if (source.trim()) {
590
+ while (source) {
591
+ var i = 0;
592
+ while (i < ruleList.length) {
593
+ var ruleType = ruleList[i];
594
+ var rule = rules[ruleType];
595
+ if (rule._qualify && !qualifies(source, state, rule._qualify)) {
596
+ i++;
597
+ continue;
598
+ }
599
+ const matchStart = performance.now();
600
+ var capture = rule._match(source, state);
601
+ const matchDuration = performance.now() - matchStart;
602
+ if (matchDuration > 1) {
603
+ console.log(
604
+ `${ruleType}._match: ${matchDuration.toFixed(3)}ms, source length: ${source.length}`
605
+ );
606
+ }
607
+ if (capture && capture[0]) {
608
+ source = source.substring(capture[0].length);
609
+ const ruleParseStart = performance.now();
610
+ const parsedAny = rule._parse(capture, nestedParse, state);
611
+ const ruleParseDuration = performance.now() - ruleParseStart;
612
+ if (ruleParseDuration > 1) {
613
+ console.log(
614
+ `${ruleType}._parse: ${ruleParseDuration.toFixed(3)}ms, capture length: ${capture[0].length}`
615
+ );
616
+ }
617
+ state.prevCapture += capture[0];
618
+ if (!parsedAny.type)
619
+ parsedAny.type = ruleType;
620
+ result.push(parsedAny);
621
+ break;
622
+ }
623
+ i++;
624
+ }
625
+ }
626
+ }
627
+ state.prevCapture = "";
628
+ const parseDuration = performance.now() - parseStart;
629
+ if (parseDuration > 1) {
630
+ console.log(
631
+ `nestedParse: ${parseDuration.toFixed(3)}ms, source length: ${source.length}, result count: ${result.length}`
632
+ );
633
+ }
634
+ return result;
635
+ };
636
+ const duration = performance.now() - start;
637
+ if (duration > 1) {
638
+ console.log(
639
+ `parserFor: ${duration.toFixed(3)}ms, rules count: ${ruleList.length}`
640
+ );
641
+ }
642
+ return (source, state) => nestedParse(normalizeWhitespace(source), state);
643
+ };
644
+ const allowInline = (fn) => {
645
+ fn.inline = 1;
646
+ return fn;
647
+ };
648
+ const inlineRegex = (regex) => allowInline((source, state) => {
649
+ if (state.inline) {
650
+ return regex.exec(source);
651
+ } else {
652
+ return null;
653
+ }
654
+ });
655
+ const simpleInlineRegex = (regex) => allowInline((source, state) => {
656
+ if (state.inline || state.simple) {
657
+ return regex.exec(source);
658
+ } else {
659
+ return null;
660
+ }
661
+ });
662
+ const blockRegex = (regex) => (source, state) => {
663
+ if (state.inline || state.simple) {
664
+ return null;
665
+ } else {
666
+ return regex.exec(source);
667
+ }
668
+ };
669
+ const anyScopeRegex = (regex) => allowInline(
670
+ (source) => regex.exec(source)
671
+ );
672
+ const SANITIZE_R = /(javascript|vbscript|data(?!:image)):/i;
673
+ const sanitizer = (input) => {
674
+ try {
675
+ const decoded = decodeURIComponent(input).replace(/[^A-Za-z0-9/:]/g, "");
676
+ if (SANITIZE_R.test(decoded)) {
677
+ if (define_process_env_default.NODE_ENV !== "production") {
678
+ console.warn(
679
+ "Input contains an unsafe JavaScript/VBScript/data expression, it will not be rendered.",
680
+ decoded
681
+ );
682
+ }
683
+ return null;
684
+ }
685
+ } catch (e) {
686
+ if (define_process_env_default.NODE_ENV !== "production") {
687
+ console.warn(
688
+ "Input could not be decoded due to malformed syntax or characters, it will not be rendered.",
689
+ input
690
+ );
691
+ }
692
+ return null;
693
+ }
694
+ return input;
695
+ };
696
+ const unescape = (rawString) => rawString ? rawString.replace(UNESCAPE_R, "$1") : rawString;
697
+ const parseInline = (parse, children, state) => {
698
+ const start = performance.now();
699
+ const isCurrentlyInline = state.inline ?? false;
700
+ const isCurrentlySimple = state.simple ?? false;
701
+ state.inline = true;
702
+ state.simple = true;
703
+ const result = parse(children, state);
704
+ state.inline = isCurrentlyInline;
705
+ state.simple = isCurrentlySimple;
706
+ const duration = performance.now() - start;
707
+ if (duration > 1) {
708
+ console.log(
709
+ `parseInline: ${duration.toFixed(3)}ms, children length: ${children.length}, result count: ${result.length}`
710
+ );
711
+ }
712
+ return result;
713
+ };
714
+ const parseSimpleInline = (parse, children, state) => {
715
+ const start = performance.now();
716
+ const isCurrentlyInline = state.inline ?? false;
717
+ const isCurrentlySimple = state.simple ?? false;
718
+ state.inline = false;
719
+ state.simple = true;
720
+ const result = parse(children, state);
721
+ state.inline = isCurrentlyInline;
722
+ state.simple = isCurrentlySimple;
723
+ const duration = performance.now() - start;
724
+ if (duration > 1) {
725
+ console.log(
726
+ `parseSimpleInline: ${duration.toFixed(3)}ms, children length: ${children.length}, result count: ${result.length}`
727
+ );
728
+ }
729
+ return result;
730
+ };
731
+ const parseBlock = (parse, children, state = {}) => {
732
+ const start = performance.now();
733
+ const isCurrentlyInline = state.inline || false;
734
+ state.inline = false;
735
+ const result = parse(children, state);
736
+ state.inline = isCurrentlyInline;
737
+ const duration = performance.now() - start;
738
+ if (duration > 1) {
739
+ console.log(
740
+ `parseBlock: ${duration.toFixed(3)}ms, children length: ${children.length}, result count: ${result.length}`
741
+ );
742
+ }
743
+ return result;
744
+ };
745
+ const parseCaptureInline = (capture, parse, state) => {
746
+ return {
747
+ children: parseInline(parse, capture[2], state)
748
+ };
749
+ };
750
+ const captureNothing = () => ({});
751
+ const renderNothing = () => null;
752
+ const reactFor = (render) => (ast, state = {}) => {
753
+ const start = performance.now();
754
+ const patchedRender = (ast2, state2 = {}) => reactFor(render)(ast2, state2);
755
+ if (Array.isArray(ast)) {
756
+ const oldKey = state.key;
757
+ const result2 = [];
758
+ let lastWasString = false;
759
+ for (let i = 0; i < ast.length; i++) {
760
+ state.key = i;
761
+ const nodeOut = patchedRender(ast[i], state);
762
+ const isString = typeof nodeOut === "string";
763
+ if (isString && lastWasString) {
764
+ result2[result2.length - 1] = result2[result2.length - 1] + nodeOut;
765
+ } else if (nodeOut !== null) {
766
+ result2.push(nodeOut);
767
+ }
768
+ lastWasString = isString;
769
+ }
770
+ state.key = oldKey;
771
+ const duration2 = performance.now() - start;
772
+ if (duration2 > 1) {
773
+ console.log(
774
+ `reactFor (array): ${duration2.toFixed(3)}ms, ast length: ${ast.length}`
775
+ );
776
+ }
777
+ return result2;
778
+ }
779
+ const result = render(
780
+ ast,
781
+ patchedRender,
782
+ state
783
+ );
784
+ const duration = performance.now() - start;
785
+ if (duration > 1) {
786
+ console.log(
787
+ `reactFor (single): ${duration.toFixed(3)}ms, ast type: ${ast.type}`
788
+ );
789
+ }
790
+ return result;
791
+ };
792
+ const createRenderer = (rules, userRender) => (ast, render, state) => {
793
+ const start = performance.now();
794
+ const renderer = rules[ast.type]._render;
795
+ const result = userRender ? userRender(() => renderer?.(ast, render, state), ast, render, state) : renderer?.(ast, render, state);
796
+ const duration = performance.now() - start;
797
+ if (duration > 1) {
798
+ console.log(
799
+ `createRenderer: ${duration.toFixed(3)}ms, ast type: ${ast.type}, hasUserRender: ${!!userRender}`
800
+ );
801
+ }
802
+ return result;
803
+ };
804
+ const cx = (...args) => args.filter(Boolean).join(" ");
805
+ const get = (src, path, fb) => {
806
+ let ptr = src;
807
+ const frags = path.split(".");
808
+ while (frags.length) {
809
+ ptr = ptr[frags[0]];
810
+ if (ptr === void 0) break;
811
+ else frags.shift();
812
+ }
813
+ return ptr ?? fb;
814
+ };
815
+ const getTag = (tag, overrides) => {
816
+ const override = get(overrides, tag);
817
+ if (!override) return tag;
818
+ return typeof override === "function" || typeof override === "object" && "render" in override ? override : get(overrides, `${tag}.component`, tag);
819
+ };
820
+ const compiler = (markdown = "", options = {}) => {
821
+ options.overrides = options.overrides ?? {};
822
+ options.namedCodesToUnicode = options.namedCodesToUnicode ? { ...namedCodesToUnicode, ...options.namedCodesToUnicode } : namedCodesToUnicode;
823
+ const slug = options.slugify ?? slugify;
824
+ const sanitize = options.sanitizer ?? sanitizer;
825
+ const createElementFn = options.createElement ?? createElement;
826
+ const NON_PARAGRAPH_BLOCK_SYNTAXES = [
827
+ BLOCKQUOTE_R,
828
+ CODE_BLOCK_FENCED_R,
829
+ CODE_BLOCK_R,
830
+ options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R,
831
+ HEADING_SETEXT_R,
832
+ NP_TABLE_R,
833
+ ORDERED_LIST_R,
834
+ UNORDERED_LIST_R
835
+ ];
836
+ const BLOCK_SYNTAXES = [
837
+ ...NON_PARAGRAPH_BLOCK_SYNTAXES,
838
+ PARAGRAPH_R,
839
+ HTML_BLOCK_ELEMENT_R,
840
+ HTML_COMMENT_R,
841
+ HTML_SELF_CLOSING_ELEMENT_R,
842
+ CUSTOM_COMPONENT_R
843
+ ];
844
+ const containsBlockSyntax = (input) => {
845
+ const cleaned = input.replace(TRIM_STARTING_NEWLINES, "");
846
+ const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;
847
+ const syntaxes = options.disableParsingRawHTML ? [...NON_PARAGRAPH_BLOCK_SYNTAXES, PARAGRAPH_R, CUSTOM_COMPONENT_R] : BLOCK_SYNTAXES;
848
+ return syntaxes.some((r) => r.test(slice));
849
+ };
850
+ const matchParagraph = (source, state) => {
851
+ if (state.inline || state.simple || state.inHTML && source.indexOf("\n\n") === -1 && state.prevCapture?.indexOf("\n\n") === -1) {
852
+ return null;
853
+ }
854
+ let match = "";
855
+ source.split("\n").every((line) => {
856
+ line += "\n";
857
+ if (NON_PARAGRAPH_BLOCK_SYNTAXES.some((regex) => regex.test(line))) {
858
+ return false;
859
+ }
860
+ match += line;
861
+ return !!line.trim();
862
+ });
863
+ const captured = trimEnd(match);
864
+ if (captured === "") {
865
+ return null;
866
+ }
867
+ return [match, , captured];
868
+ };
869
+ const h = (tag, props, ...children) => {
870
+ const overrideProps = get(
871
+ options.overrides ?? {},
872
+ `${tag}.props`,
873
+ {}
874
+ );
875
+ return createElementFn(
876
+ getTag(tag, options.overrides ?? {}),
877
+ {
878
+ ...props,
879
+ ...overrideProps,
880
+ className: cx(props?.className, overrideProps.className) ?? void 0
881
+ },
882
+ ...children
883
+ );
884
+ };
885
+ const compile = (input) => {
886
+ const start = performance.now();
887
+ const result = input.replace(FRONT_MATTER_R, "");
888
+ let inline = false;
889
+ if (options.forceInline) {
890
+ inline = true;
891
+ } else if (!options.forceBlock) {
892
+ inline = SHOULD_RENDER_AS_BLOCK_R.test(result) === false;
893
+ }
894
+ const arr = emitter(
895
+ parser(
896
+ inline ? result : `${trimEnd(result).replace(TRIM_STARTING_NEWLINES, "")}
897
+
898
+ `,
899
+ {
900
+ inline
901
+ }
902
+ )
903
+ );
904
+ while (typeof arr[arr.length - 1] === "string" && !arr[arr.length - 1].trim()) {
905
+ arr.pop();
906
+ }
907
+ if (options.wrapper === null) {
908
+ const duration2 = performance.now() - start;
909
+ if (duration2 > 1) {
910
+ console.log(
911
+ `compile: ${duration2.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
912
+ );
913
+ }
914
+ return arr;
915
+ }
916
+ const wrapper = options.wrapper ?? (inline ? "span" : "div");
917
+ let jsx3;
918
+ if (arr.length > 1 || options.forceWrapper) {
919
+ jsx3 = arr;
920
+ } else if (arr.length === 1) {
921
+ jsx3 = arr[0];
922
+ if (typeof jsx3 === "string") {
923
+ const duration2 = performance.now() - start;
924
+ if (duration2 > 1) {
925
+ console.log(
926
+ `compile: ${duration2.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
927
+ );
928
+ }
929
+ return /* @__PURE__ */ jsx("span", { children: jsx3 }, "outer");
930
+ } else {
931
+ const duration2 = performance.now() - start;
932
+ if (duration2 > 1) {
933
+ console.log(
934
+ `compile: ${duration2.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
935
+ );
936
+ }
937
+ return jsx3;
938
+ }
939
+ } else {
940
+ jsx3 = null;
941
+ }
942
+ const duration = performance.now() - start;
943
+ if (duration > 1) {
944
+ console.log(
945
+ `compile: ${duration.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
946
+ );
947
+ }
948
+ return createElementFn(wrapper, { key: "outer" }, jsx3);
949
+ };
950
+ const attrStringToMap = (tag, str) => {
951
+ const start = performance.now();
952
+ if (!str || !str.trim()) {
953
+ return null;
954
+ }
955
+ const attributes = str.match(ATTR_EXTRACTOR_R);
956
+ if (!attributes) {
957
+ return null;
958
+ }
959
+ const result = attributes.reduce((map, raw) => {
960
+ const delimiterIdx = raw.indexOf("=");
961
+ if (delimiterIdx !== -1) {
962
+ const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();
963
+ const value = unquote(raw.slice(delimiterIdx + 1).trim());
964
+ const mappedKey = ATTRIBUTE_TO_JSX_PROP_MAP[key] ?? key;
965
+ if (mappedKey === "ref") return map;
966
+ const normalizedValue = map[mappedKey] = attributeValueToJSXPropValue(
967
+ tag,
968
+ key,
969
+ value,
970
+ sanitize
971
+ );
972
+ if (typeof normalizedValue === "string" && (HTML_BLOCK_ELEMENT_R.test(normalizedValue) || HTML_SELF_CLOSING_ELEMENT_R.test(normalizedValue))) {
973
+ map[mappedKey] = compile(normalizedValue.trim());
974
+ }
975
+ } else if (raw !== "style") {
976
+ map[ATTRIBUTE_TO_JSX_PROP_MAP[raw] ?? raw] = true;
977
+ }
978
+ return map;
979
+ }, {});
980
+ const duration = performance.now() - start;
981
+ if (duration > 1) {
982
+ console.log(
983
+ `attrStringToMap: ${duration.toFixed(3)}ms, str length: ${str.length}, attributes count: ${attributes.length}`
984
+ );
985
+ }
986
+ return result;
987
+ };
988
+ if (define_process_env_default.NODE_ENV !== "production") {
989
+ if (typeof markdown !== "string") {
990
+ throw new Error(`intlayer: the first argument must be
991
+ a string`);
992
+ }
993
+ if (Object.prototype.toString.call(options.overrides) !== "[object Object]") {
994
+ throw new Error(`intlayer: options.overrides (second argument property) must be
995
+ undefined or an object literal with shape:
996
+ {
997
+ htmltagname: {
998
+ component: string|ReactComponent(optional),
999
+ props: object(optional)
1000
+ }
1001
+ }`);
1002
+ }
1003
+ }
1004
+ const footnotes = [];
1005
+ const refs = {};
1006
+ const rules = {
1007
+ [RuleType.blockQuote]: {
1008
+ _qualify: [">"],
1009
+ _match: blockRegex(BLOCKQUOTE_R),
1010
+ _order: Priority.HIGH,
1011
+ _parse(capture, parse, state) {
1012
+ const start = performance.now();
1013
+ const matchAlert = capture[0].replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, "").match(BLOCKQUOTE_ALERT_R);
1014
+ const alert = matchAlert?.[1];
1015
+ const content = matchAlert?.[2] ?? "";
1016
+ const result = {
1017
+ alert,
1018
+ children: parse(content, state)
1019
+ };
1020
+ const duration = performance.now() - start;
1021
+ if (duration > 1) {
1022
+ console.log(
1023
+ `blockQuote._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}`
1024
+ );
1025
+ }
1026
+ return result;
1027
+ },
1028
+ _render(node, _output, state = {}) {
1029
+ const start = performance.now();
1030
+ const props = {
1031
+ key: state?.key
1032
+ };
1033
+ if (node.alert) {
1034
+ props.className = "markdown-alert-" + slug(node.alert.toLowerCase(), slugify);
1035
+ node.children.unshift({
1036
+ attrs: {},
1037
+ children: [{ type: RuleType.text, text: node.alert }],
1038
+ noInnerParse: true,
1039
+ type: RuleType.htmlBlock,
1040
+ tag: "header"
1041
+ });
1042
+ }
1043
+ const result = h(
1044
+ "blockquote",
1045
+ props,
1046
+ _output(node.children, state)
1047
+ );
1048
+ const duration = performance.now() - start;
1049
+ if (duration > 1) {
1050
+ console.log(
1051
+ `blockQuote._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}, has alert: ${!!node.alert}`
1052
+ );
1053
+ }
1054
+ return result;
1055
+ }
1056
+ },
1057
+ [RuleType.breakLine]: {
1058
+ _match: anyScopeRegex(BREAK_LINE_R),
1059
+ _order: Priority.HIGH,
1060
+ _parse: captureNothing,
1061
+ _render(_, __, state = {}) {
1062
+ return /* @__PURE__ */ jsx("br", {}, state.key);
1063
+ }
1064
+ },
1065
+ [RuleType.breakThematic]: {
1066
+ _qualify: (source) => {
1067
+ const char = source[0];
1068
+ return char === "-" || char === "*" || char === "_";
1069
+ },
1070
+ _match: blockRegex(BREAK_THEMATIC_R),
1071
+ _order: Priority.HIGH,
1072
+ _parse: captureNothing,
1073
+ _render(_, __, state = {}) {
1074
+ return /* @__PURE__ */ jsx("hr", {}, state.key);
1075
+ }
1076
+ },
1077
+ [RuleType.codeBlock]: {
1078
+ _qualify: [" "],
1079
+ _match: blockRegex(CODE_BLOCK_R),
1080
+ _order: Priority.MAX,
1081
+ _parse(capture) {
1082
+ return {
1083
+ type: RuleType.codeBlock,
1084
+ lang: void 0,
1085
+ text: unescape(trimEnd(capture[0].replace(/^ {4}/gm, "")))
1086
+ };
1087
+ },
1088
+ _render(node, _output, state = {}) {
1089
+ const start = performance.now();
1090
+ const attrs = { ...node.attrs ?? {} };
1091
+ const langClass = node.lang ? `lang-${node.lang}` : "lang-plaintext";
1092
+ attrs.className = attrs.className ? `${attrs.className} ${langClass}` : langClass;
1093
+ if (node.lang && !attrs.lang) attrs.lang = node.lang;
1094
+ const result = h(
1095
+ "pre",
1096
+ { key: state.key },
1097
+ h("code", attrs, node.text)
1098
+ );
1099
+ const duration = performance.now() - start;
1100
+ if (duration > 1) {
1101
+ console.log(
1102
+ `codeBlock._render: ${duration.toFixed(3)}ms, text length: ${node.text.length}, lang: ${node.lang || "none"}`
1103
+ );
1104
+ }
1105
+ return result;
1106
+ }
1107
+ },
1108
+ [RuleType.codeFenced]: {
1109
+ _qualify: ["```", "~~~"],
1110
+ _match: blockRegex(CODE_BLOCK_FENCED_R),
1111
+ _order: Priority.MAX,
1112
+ _parse(capture) {
1113
+ const rawText = capture[4];
1114
+ const text = rawText;
1115
+ return {
1116
+ // if capture[3] it's additional metadata
1117
+ attrs: attrStringToMap("code", capture[3] ?? ""),
1118
+ lang: capture[2] || void 0,
1119
+ text,
1120
+ type: RuleType.codeBlock
1121
+ };
1122
+ }
1123
+ },
1124
+ [RuleType.codeInline]: {
1125
+ _qualify: ["`"],
1126
+ _match: simpleInlineRegex(CODE_INLINE_R),
1127
+ _order: Priority.LOW,
1128
+ _parse(capture) {
1129
+ return {
1130
+ text: unescape(capture[2])
1131
+ };
1132
+ },
1133
+ _render(node, _output, state = {}) {
1134
+ const start = performance.now();
1135
+ const result = h("code", { key: state.key }, node.text);
1136
+ const duration = performance.now() - start;
1137
+ if (duration > 1) {
1138
+ console.log(
1139
+ `codeInline._render: ${duration.toFixed(3)}ms, text length: ${node.text.length}`
1140
+ );
1141
+ }
1142
+ return result;
1143
+ }
1144
+ },
1145
+ /**
1146
+ * footnotes are emitted at the end of compilation in a special <footer> block
1147
+ */
1148
+ [RuleType.footnote]: {
1149
+ _qualify: ["[^"],
1150
+ _match: blockRegex(FOOTNOTE_R),
1151
+ _order: Priority.MAX,
1152
+ _parse(capture) {
1153
+ footnotes.push({
1154
+ footnote: capture[2],
1155
+ identifier: capture[1]
1156
+ });
1157
+ return {};
1158
+ },
1159
+ _render: renderNothing
1160
+ },
1161
+ [RuleType.footnoteReference]: {
1162
+ _qualify: ["[^"],
1163
+ _match: inlineRegex(FOOTNOTE_REFERENCE_R),
1164
+ _order: Priority.HIGH,
1165
+ _parse(capture) {
1166
+ return {
1167
+ target: `#${slug(capture[1], slugify)}`,
1168
+ text: capture[1]
1169
+ };
1170
+ },
1171
+ _render(node, _output, state = {}) {
1172
+ return /* @__PURE__ */ jsx(
1173
+ "a",
1174
+ {
1175
+ href: sanitize(node.target, "a", "href") ?? void 0,
1176
+ children: /* @__PURE__ */ jsx("sup", { children: node.text }, state.key)
1177
+ },
1178
+ state.key
1179
+ );
1180
+ }
1181
+ },
1182
+ [RuleType.gfmTask]: {
1183
+ _qualify: ["[ ]", "[x]"],
1184
+ _match: inlineRegex(GFM_TASK_R),
1185
+ _order: Priority.HIGH,
1186
+ _parse(capture) {
1187
+ return {
1188
+ completed: capture[1].toLowerCase() === "x"
1189
+ };
1190
+ },
1191
+ _render(node, _output, state = {}) {
1192
+ return /* @__PURE__ */ jsx(
1193
+ "input",
1194
+ {
1195
+ checked: node.completed,
1196
+ readOnly: true,
1197
+ type: "checkbox"
1198
+ },
1199
+ state.key
1200
+ );
1201
+ }
1202
+ },
1203
+ [RuleType.heading]: {
1204
+ _qualify: ["#"],
1205
+ _match: blockRegex(
1206
+ options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R
1207
+ ),
1208
+ _order: Priority.HIGH,
1209
+ _parse(capture, parse, state) {
1210
+ const start = performance.now();
1211
+ const result = {
1212
+ children: parseInline(parse, capture[2], state),
1213
+ id: slug(capture[2], slugify),
1214
+ level: capture[1].length
1215
+ };
1216
+ const duration = performance.now() - start;
1217
+ if (duration > 1) {
1218
+ console.log(
1219
+ `heading._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}, level: ${capture[1].length}`
1220
+ );
1221
+ }
1222
+ return result;
1223
+ },
1224
+ _render(node, _output, state = {}) {
1225
+ const start = performance.now();
1226
+ const result = h(
1227
+ `h${node.level}`,
1228
+ { id: node.id, key: state.key },
1229
+ _output(node.children, state)
1230
+ );
1231
+ const duration = performance.now() - start;
1232
+ if (duration > 1) {
1233
+ console.log(
1234
+ `heading._render: ${duration.toFixed(3)}ms, level: ${node.level}, children count: ${node.children.length}, id: ${node.id}`
1235
+ );
1236
+ }
1237
+ return result;
1238
+ }
1239
+ },
1240
+ [RuleType.headingSetext]: {
1241
+ _match: blockRegex(HEADING_SETEXT_R),
1242
+ _order: Priority.MAX,
1243
+ _parse(capture, parse, state) {
1244
+ return {
1245
+ children: parseInline(parse, capture[1], state),
1246
+ level: capture[2] === "=" ? 1 : 2,
1247
+ type: RuleType.heading
1248
+ };
1249
+ }
1250
+ },
1251
+ [RuleType.htmlBlock]: {
1252
+ _qualify: (source) => {
1253
+ if (options.disableParsingRawHTML) return false;
1254
+ if (source[0] !== "<") return false;
1255
+ if (!/^<([a-z][a-z0-9:-]*)\b/.test(source)) return false;
1256
+ const tag = source.match(/^<([a-z][a-z0-9:-]*)\b/)?.[1];
1257
+ return tag ? source.indexOf(`</${tag}>`) !== -1 : false;
1258
+ },
1259
+ /**
1260
+ * find the first matching end tag and process the interior
1261
+ */
1262
+ _match: anyScopeRegex(HTML_BLOCK_ELEMENT_R),
1263
+ _order: Priority.HIGH,
1264
+ _parse(capture, parse, state) {
1265
+ const m = capture[3].match(
1266
+ HTML_LEFT_TRIM_AMOUNT_R
1267
+ );
1268
+ const whitespace = m?.[1] ?? "";
1269
+ const trimmed = trimLeadingWhitespaceOutsideFences(
1270
+ capture[3],
1271
+ whitespace
1272
+ );
1273
+ const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;
1274
+ const tagName = capture[1].toLowerCase();
1275
+ const noInnerParse = DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(tagName) !== -1;
1276
+ const tag = (noInnerParse ? tagName : capture[1]).trim();
1277
+ const ast = {
1278
+ attrs: attrStringToMap(tag, capture[2] ?? ""),
1279
+ noInnerParse,
1280
+ tag
1281
+ };
1282
+ state.inAnchor = state.inAnchor || tagName === "a";
1283
+ if (noInnerParse) {
1284
+ ast.text = capture[3];
1285
+ } else {
1286
+ const prevInHTML = state.inHTML;
1287
+ state.inHTML = true;
1288
+ ast.children = parseFunc(parse, trimmed, state);
1289
+ state.inHTML = prevInHTML;
1290
+ }
1291
+ state.inAnchor = false;
1292
+ return ast;
1293
+ },
1294
+ _render(node, _output, state = {}) {
1295
+ const start = performance.now();
1296
+ const result = h(
1297
+ node.tag,
1298
+ { key: state.key, ...node.attrs ?? {} },
1299
+ node.text ?? (node.children ? _output(node.children, state) : "")
1300
+ );
1301
+ const duration = performance.now() - start;
1302
+ if (duration > 1) {
1303
+ console.log(
1304
+ `htmlBlock._render: ${duration.toFixed(3)}ms, tag: ${node.tag}, has text: ${!!node.text}, has children: ${!!node.children}`
1305
+ );
1306
+ }
1307
+ return result;
1308
+ }
1309
+ },
1310
+ [RuleType.htmlSelfClosing]: {
1311
+ _qualify: (source) => {
1312
+ if (options.disableParsingRawHTML) return false;
1313
+ if (source[0] !== "<") return false;
1314
+ return /^<([a-zA-Z][a-zA-Z0-9:]*)[\s>/]/.test(source);
1315
+ },
1316
+ /**
1317
+ * find the first matching end tag and process the interior
1318
+ */
1319
+ _match: anyScopeRegex(HTML_SELF_CLOSING_ELEMENT_R),
1320
+ _order: Priority.HIGH,
1321
+ _parse(capture) {
1322
+ const tag = capture[1].trim();
1323
+ return {
1324
+ attrs: attrStringToMap(tag, capture[2] || ""),
1325
+ tag
1326
+ };
1327
+ },
1328
+ _render(node, _output, state = {}) {
1329
+ const start = performance.now();
1330
+ const result = h(node.tag, {
1331
+ key: state.key,
1332
+ ...node.attrs ?? {}
1333
+ });
1334
+ const duration = performance.now() - start;
1335
+ if (duration > 1) {
1336
+ console.log(
1337
+ `htmlSelfClosing._render: ${duration.toFixed(3)}ms, tag: ${node.tag}`
1338
+ );
1339
+ }
1340
+ return result;
1341
+ }
1342
+ },
1343
+ [RuleType.htmlComment]: {
1344
+ _qualify: ["<!--"],
1345
+ _match: anyScopeRegex(HTML_COMMENT_R),
1346
+ _order: Priority.HIGH,
1347
+ _parse() {
1348
+ return {};
1349
+ },
1350
+ _render: renderNothing
1351
+ },
1352
+ [RuleType.customComponent]: {
1353
+ _qualify: (source) => {
1354
+ const match = source.match(/^ *<([A-Z][a-zA-Z0-9]*)/);
1355
+ return !!match;
1356
+ },
1357
+ _match: blockRegex(CUSTOM_COMPONENT_R),
1358
+ _order: Priority.MAX,
1359
+ _parse(capture, parse, state) {
1360
+ const m = capture[3].match(
1361
+ HTML_LEFT_TRIM_AMOUNT_R
1362
+ );
1363
+ const whitespace = m?.[1] ?? "";
1364
+ const trimmed = trimLeadingWhitespaceOutsideFences(
1365
+ capture[3],
1366
+ whitespace
1367
+ );
1368
+ const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;
1369
+ const tagName = capture[1];
1370
+ const noInnerParse = false;
1371
+ const ast = {
1372
+ attrs: attrStringToMap(tagName, capture[2] ?? ""),
1373
+ noInnerParse,
1374
+ tag: tagName
1375
+ };
1376
+ {
1377
+ const prevInHTML = state.inHTML;
1378
+ state.inHTML = true;
1379
+ const parsedChildren = parseFunc(parse, trimmed, state);
1380
+ ast.children = parsedChildren;
1381
+ state.inHTML = prevInHTML;
1382
+ }
1383
+ return ast;
1384
+ },
1385
+ _render(node, _output, state = {}) {
1386
+ const customComponent = getTag(node.tag, options.overrides ?? {});
1387
+ if (typeof customComponent === "function") {
1388
+ const renderedChildren = node.children ? _output(node.children, state) : null;
1389
+ return customComponent({
1390
+ key: state.key,
1391
+ ...node.attrs,
1392
+ children: renderedChildren
1393
+ });
1394
+ }
1395
+ return createElementFn(
1396
+ node.tag,
1397
+ { key: state.key, ...node.attrs },
1398
+ node.text ?? (node.children ? _output(node.children, state) : "")
1399
+ );
1400
+ }
1401
+ },
1402
+ [RuleType.image]: {
1403
+ _qualify: ["!["],
1404
+ _match: simpleInlineRegex(IMAGE_R),
1405
+ _order: Priority.HIGH,
1406
+ _parse(capture) {
1407
+ return {
1408
+ alt: unescape(capture[1]),
1409
+ target: unescape(capture[2]),
1410
+ title: unescape(capture[3])
1411
+ };
1412
+ },
1413
+ _render(node, _output, state = {}) {
1414
+ return /* @__PURE__ */ jsx(
1415
+ "img",
1416
+ {
1417
+ alt: node.alt ?? void 0,
1418
+ title: node.title ?? void 0,
1419
+ src: sanitize(node.target, "img", "src") ?? void 0
1420
+ },
1421
+ state.key
1422
+ );
1423
+ }
1424
+ },
1425
+ [RuleType.link]: {
1426
+ _qualify: ["["],
1427
+ _match: inlineRegex(LINK_R),
1428
+ _order: Priority.LOW,
1429
+ _parse(capture, parse, state) {
1430
+ return {
1431
+ children: parseSimpleInline(parse, capture[1], state),
1432
+ target: unescape(capture[2]),
1433
+ title: unescape(capture[3])
1434
+ };
1435
+ },
1436
+ _render(node, _output, state = {}) {
1437
+ return /* @__PURE__ */ jsx(
1438
+ "a",
1439
+ {
1440
+ href: sanitize(node.target, "a", "href") ?? void 0,
1441
+ title: node.title,
1442
+ children: _output(node.children, state)
1443
+ },
1444
+ state.key
1445
+ );
1446
+ }
1447
+ },
1448
+ // https://daringfireball.net/projects/markdown/syntax#autolink
1449
+ [RuleType.linkAngleBraceStyleDetector]: {
1450
+ _qualify: ["<"],
1451
+ _match: inlineRegex(LINK_AUTOLINK_R),
1452
+ _order: Priority.MAX,
1453
+ _parse(capture) {
1454
+ return {
1455
+ children: [
1456
+ {
1457
+ text: capture[1],
1458
+ type: RuleType.text
1459
+ }
1460
+ ],
1461
+ target: capture[1],
1462
+ type: RuleType.link
1463
+ };
1464
+ }
1465
+ },
1466
+ [RuleType.linkBareUrlDetector]: {
1467
+ _qualify: (source, state) => {
1468
+ if (state.inAnchor || options.disableAutoLink) return false;
1469
+ return startsWith(source, "http://") || startsWith(source, "https://");
1470
+ },
1471
+ _match: inlineRegex(LINK_AUTOLINK_BARE_URL_R),
1472
+ _order: Priority.MAX,
1473
+ _parse(capture) {
1474
+ return {
1475
+ children: [
1476
+ {
1477
+ text: capture[1],
1478
+ type: RuleType.text
1479
+ }
1480
+ ],
1481
+ target: capture[1],
1482
+ title: void 0,
1483
+ type: RuleType.link
1484
+ };
1485
+ }
1486
+ },
1487
+ [RuleType.linkMailtoDetector]: {
1488
+ _qualify: ["<"],
1489
+ _match: inlineRegex(LINK_AUTOLINK_MAILTO_R),
1490
+ _order: Priority.MAX,
1491
+ _parse(capture) {
1492
+ let address = capture[1];
1493
+ let target = capture[1];
1494
+ if (!AUTOLINK_MAILTO_CHECK_R.test(target)) {
1495
+ target = "mailto:" + target;
1496
+ }
1497
+ return {
1498
+ children: [
1499
+ {
1500
+ text: address.replace("mailto:", ""),
1501
+ type: RuleType.text
1502
+ }
1503
+ ],
1504
+ target,
1505
+ type: RuleType.link
1506
+ };
1507
+ }
1508
+ },
1509
+ [RuleType.orderedList]: generateListRule(
1510
+ ORDERED,
1511
+ (tag, props, ...children) => h(tag, props, ...children)
1512
+ ),
1513
+ [RuleType.unorderedList]: generateListRule(
1514
+ UNORDERED,
1515
+ (tag, props, ...children) => h(tag, props, ...children)
1516
+ ),
1517
+ [RuleType.newlineCoalescer]: {
1518
+ _match: blockRegex(CONSECUTIVE_NEWLINE_R),
1519
+ _order: Priority.LOW,
1520
+ _parse: captureNothing,
1521
+ _render() {
1522
+ return "\n";
1523
+ }
1524
+ },
1525
+ [RuleType.paragraph]: {
1526
+ _match: allowInline(matchParagraph),
1527
+ _order: Priority.LOW,
1528
+ _parse(capture, parse, state) {
1529
+ const start = performance.now();
1530
+ const result = parseCaptureInline(capture, parse, state);
1531
+ const duration = performance.now() - start;
1532
+ if (duration > 1) {
1533
+ console.log(
1534
+ `paragraph._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}`
1535
+ );
1536
+ }
1537
+ return result;
1538
+ },
1539
+ _render(node, _output, state = {}) {
1540
+ const start = performance.now();
1541
+ const result = /* @__PURE__ */ jsx("p", { children: _output(node.children, state) }, state.key);
1542
+ const duration = performance.now() - start;
1543
+ if (duration > 1) {
1544
+ console.log(
1545
+ `paragraph._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}`
1546
+ );
1547
+ }
1548
+ return result;
1549
+ }
1550
+ },
1551
+ [RuleType.ref]: {
1552
+ _qualify: ["["],
1553
+ _match: inlineRegex(REFERENCE_IMAGE_OR_LINK),
1554
+ _order: Priority.MAX,
1555
+ _parse(capture) {
1556
+ refs[capture[1]] = {
1557
+ target: capture[2],
1558
+ title: capture[4]
1559
+ };
1560
+ return {};
1561
+ },
1562
+ _render: renderNothing
1563
+ },
1564
+ [RuleType.refImage]: {
1565
+ _qualify: ["!["],
1566
+ _match: simpleInlineRegex(REFERENCE_IMAGE_R),
1567
+ _order: Priority.MAX,
1568
+ _parse(capture) {
1569
+ return {
1570
+ alt: capture[1] ? unescape(capture[1]) : void 0,
1571
+ ref: capture[2]
1572
+ };
1573
+ },
1574
+ _render(node, _output, state = {}) {
1575
+ return refs[node.ref] ? /* @__PURE__ */ jsx(
1576
+ "img",
1577
+ {
1578
+ alt: node.alt,
1579
+ src: sanitize(refs[node.ref].target, "img", "src") ?? void 0,
1580
+ title: refs[node.ref].title
1581
+ },
1582
+ state.key
1583
+ ) : null;
1584
+ }
1585
+ },
1586
+ [RuleType.refLink]: {
1587
+ _qualify: (source) => source[0] === "[" && source.indexOf("](") === -1,
1588
+ _match: inlineRegex(REFERENCE_LINK_R),
1589
+ _order: Priority.MAX,
1590
+ _parse(capture, parse, state) {
1591
+ return {
1592
+ children: parse(capture[1], state),
1593
+ fallbackChildren: capture[0],
1594
+ ref: capture[2]
1595
+ };
1596
+ },
1597
+ _render(node, _output, state = {}) {
1598
+ return refs[node.ref] ? /* @__PURE__ */ jsx(
1599
+ "a",
1600
+ {
1601
+ href: sanitize(refs[node.ref].target, "a", "href") ?? void 0,
1602
+ title: refs[node.ref].title,
1603
+ children: _output(node.children, state)
1604
+ },
1605
+ state.key
1606
+ ) : /* @__PURE__ */ jsx("span", { children: node.fallbackChildren }, state.key);
1607
+ }
1608
+ },
1609
+ [RuleType.table]: {
1610
+ _qualify: ["|"],
1611
+ _match: blockRegex(NP_TABLE_R),
1612
+ _order: Priority.HIGH,
1613
+ _parse(capture, parse, state) {
1614
+ const start = performance.now();
1615
+ const result = parseTable(capture, parse, state);
1616
+ const duration = performance.now() - start;
1617
+ if (duration > 1) {
1618
+ console.log(
1619
+ `table._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}`
1620
+ );
1621
+ }
1622
+ return result;
1623
+ },
1624
+ _render(node, _output, state = {}) {
1625
+ const start = performance.now();
1626
+ const table = node;
1627
+ const result = h(
1628
+ "table",
1629
+ { key: state.key },
1630
+ h(
1631
+ "thead",
1632
+ {},
1633
+ h(
1634
+ "tr",
1635
+ {},
1636
+ ...table.header.map(
1637
+ (content, i) => h(
1638
+ "th",
1639
+ { key: i, style: getTableStyle(table, i) },
1640
+ _output(content, state)
1641
+ )
1642
+ )
1643
+ )
1644
+ ),
1645
+ h(
1646
+ "tbody",
1647
+ {},
1648
+ ...table.cells.map(
1649
+ (row, i) => h(
1650
+ "tr",
1651
+ { key: i },
1652
+ ...row.map(
1653
+ (content, c) => h(
1654
+ "td",
1655
+ { key: c, style: getTableStyle(table, c) },
1656
+ _output(content, state)
1657
+ )
1658
+ )
1659
+ )
1660
+ )
1661
+ )
1662
+ );
1663
+ const duration = performance.now() - start;
1664
+ if (duration > 1) {
1665
+ console.log(
1666
+ `table._render: ${duration.toFixed(3)}ms, header count: ${table.header.length}, rows count: ${table.cells.length}`
1667
+ );
1668
+ }
1669
+ return result;
1670
+ }
1671
+ },
1672
+ [RuleType.text]: {
1673
+ // Here we look for anything followed by non-symbols,
1674
+ // double newlines, or double-space-newlines
1675
+ // We break on any symbol characters so that this grammar
1676
+ // is easy to extend without needing to modify this regex
1677
+ _match: allowInline((source, _state) => {
1678
+ let ret;
1679
+ if (startsWith(source, ":")) ret = SHORTCODE_R.exec(source);
1680
+ if (ret) return ret;
1681
+ return TEXT_PLAIN_R.exec(source);
1682
+ }),
1683
+ _order: Priority.MIN,
1684
+ _parse(capture) {
1685
+ const text = capture[0];
1686
+ return {
1687
+ text: text.indexOf("&") === -1 ? text : text.replace(
1688
+ HTML_CHAR_CODE_R,
1689
+ (full, inner) => options.namedCodesToUnicode?.[inner] ?? full
1690
+ )
1691
+ };
1692
+ },
1693
+ _render(node) {
1694
+ return node.text;
1695
+ }
1696
+ },
1697
+ [RuleType.textBolded]: {
1698
+ _qualify: ["**", "__"],
1699
+ _match: simpleInlineRegex(TEXT_BOLD_R),
1700
+ _order: Priority.MED,
1701
+ _parse(capture, parse, state) {
1702
+ return {
1703
+ // capture[1] -> the syntax control character
1704
+ // capture[2] -> inner content
1705
+ children: parse(capture[2], state)
1706
+ };
1707
+ },
1708
+ _render(node, _output, state = {}) {
1709
+ const start = performance.now();
1710
+ const result = /* @__PURE__ */ jsx("strong", { children: _output(node.children, state) }, state.key);
1711
+ const duration = performance.now() - start;
1712
+ if (duration > 1) {
1713
+ console.log(
1714
+ `textBolded._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}`
1715
+ );
1716
+ }
1717
+ return result;
1718
+ }
1719
+ },
1720
+ [RuleType.textEmphasized]: {
1721
+ _qualify: (source) => {
1722
+ const char = source[0];
1723
+ return (char === "*" || char === "_") && source[1] !== char;
1724
+ },
1725
+ _match: simpleInlineRegex(TEXT_EMPHASIZED_R),
1726
+ _order: Priority.LOW,
1727
+ _parse(capture, parse, state) {
1728
+ return {
1729
+ // capture[1] -> opening * or _
1730
+ // capture[2] -> inner content
1731
+ children: parse(capture[2], state)
1732
+ };
1733
+ },
1734
+ _render(node, _output, state = {}) {
1735
+ const start = performance.now();
1736
+ const result = /* @__PURE__ */ jsx("em", { children: _output(node.children, state) }, state.key);
1737
+ const duration = performance.now() - start;
1738
+ if (duration > 1) {
1739
+ console.log(
1740
+ `textEmphasized._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}`
1741
+ );
1742
+ }
1743
+ return result;
1744
+ }
1745
+ },
1746
+ [RuleType.textEscaped]: {
1747
+ _qualify: ["\\"],
1748
+ // We don't allow escaping numbers, letters, or spaces here so that
1749
+ // backslashes used in plain text still get rendered. But allowing
1750
+ // escaping anything else provides a very flexible escape mechanism,
1751
+ // regardless of how this grammar is extended.
1752
+ _match: simpleInlineRegex(TEXT_ESCAPED_R),
1753
+ _order: Priority.HIGH,
1754
+ _parse(capture) {
1755
+ return {
1756
+ text: capture[1],
1757
+ type: RuleType.text
1758
+ };
1759
+ }
1760
+ },
1761
+ [RuleType.textMarked]: {
1762
+ _qualify: ["=="],
1763
+ _match: simpleInlineRegex(TEXT_MARKED_R),
1764
+ _order: Priority.LOW,
1765
+ _parse: parseCaptureInline,
1766
+ _render(node, _output, state = {}) {
1767
+ return /* @__PURE__ */ jsx("mark", { children: _output(node.children, state) }, state.key);
1768
+ }
1769
+ },
1770
+ [RuleType.textStrikethroughed]: {
1771
+ _qualify: ["~~"],
1772
+ _match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),
1773
+ _order: Priority.LOW,
1774
+ _parse: parseCaptureInline,
1775
+ _render(node, _output, state = {}) {
1776
+ return /* @__PURE__ */ jsx("del", { children: _output(node.children, state) }, state.key);
1777
+ }
1778
+ }
1779
+ };
1780
+ if (options.disableParsingRawHTML === true) {
1781
+ delete rules[RuleType.htmlBlock];
1782
+ delete rules[RuleType.htmlSelfClosing];
1783
+ }
1784
+ const parser = parserFor(rules);
1785
+ const emitter = reactFor(createRenderer(rules, options.renderRule));
1786
+ const jsx2 = compile(markdown);
1787
+ if (footnotes.length) {
1788
+ return /* @__PURE__ */ jsxs("div", { children: [
1789
+ jsx2,
1790
+ /* @__PURE__ */ jsx("footer", { children: footnotes.map((def) => /* @__PURE__ */ jsxs("div", { id: slug(def.identifier, slugify), children: [
1791
+ def.identifier,
1792
+ emitter(
1793
+ parser(def.footnote, { inline: true })
1794
+ )
1795
+ ] }, def.identifier)) }, "footer")
1796
+ ] });
1797
+ }
1798
+ return jsx2;
1799
+ };
1800
+ const MarkdownProcessor = ({ children = "", options, ...props }) => {
1801
+ if (define_process_env_default.NODE_ENV !== "production" && typeof children !== "string") {
1802
+ console.error(
1803
+ "intlayer: <Markdown> component only accepts a single string as a child, received:",
1804
+ children
1805
+ );
1806
+ }
1807
+ return cloneElement(
1808
+ compiler(children, options),
1809
+ props
1810
+ );
1811
+ };
1812
+ export {
1813
+ MarkdownProcessor,
1814
+ RuleType,
1815
+ compiler,
1816
+ sanitizer,
1817
+ slugify
1818
+ };
1819
+ //# sourceMappingURL=processor.mjs.map