nizel 0.1.0 → 0.1.2

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.
@@ -0,0 +1,4723 @@
1
+ // src/html-to-markdown.ts
2
+ var blockTags = /* @__PURE__ */ new Set([
3
+ "address",
4
+ "article",
5
+ "aside",
6
+ "blockquote",
7
+ "details",
8
+ "dialog",
9
+ "div",
10
+ "dl",
11
+ "fieldset",
12
+ "figcaption",
13
+ "figure",
14
+ "footer",
15
+ "form",
16
+ "header",
17
+ "hr",
18
+ "main",
19
+ "nav",
20
+ "ol",
21
+ "p",
22
+ "pre",
23
+ "section",
24
+ "table",
25
+ "ul",
26
+ "h1",
27
+ "h2",
28
+ "h3",
29
+ "h4",
30
+ "h5",
31
+ "h6"
32
+ ]);
33
+ var passthroughInlineTags = /* @__PURE__ */ new Set(["abbr", "bdi", "bdo", "cite", "data", "dfn", "kbd", "mark", "q", "samp", "small", "sub", "sup", "time", "u", "var"]);
34
+ function htmlToMarkdown(html, options = {}) {
35
+ const root = parseHtml(html);
36
+ return normalizeDocument(renderChildren(root.children, { unsupported: options.unsupported ?? "preserve" }, 0));
37
+ }
38
+ function parseHtml(html) {
39
+ const root = { type: "root", children: [] };
40
+ const stack = [{ node: root, start: 0 }];
41
+ const tokenPattern = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<![^>]*>|<\?[\s\S]*?\?>|<\/?[A-Za-z][^>]*>/g;
42
+ let lastIndex = 0;
43
+ let match;
44
+ while ((match = tokenPattern.exec(html)) !== null) {
45
+ appendText(html.slice(lastIndex, match.index));
46
+ const token = match[0];
47
+ lastIndex = tokenPattern.lastIndex;
48
+ if (token.startsWith("<!--")) {
49
+ current().children.push({ type: "comment", value: token });
50
+ continue;
51
+ }
52
+ if (/^<\//.test(token)) {
53
+ const tag2 = token.slice(2, -1).trim().toLowerCase();
54
+ closeTag(tag2, tokenPattern.lastIndex);
55
+ continue;
56
+ }
57
+ const open = /^<([A-Za-z][^\s/>]*)([\s\S]*?)\/?>$/.exec(token);
58
+ if (!open) {
59
+ appendText(token);
60
+ continue;
61
+ }
62
+ const tag = open[1].toLowerCase();
63
+ const element = {
64
+ type: "element",
65
+ tag,
66
+ attrs: parseAttrs(open[2] ?? ""),
67
+ children: [],
68
+ raw: token
69
+ };
70
+ current().children.push(element);
71
+ if (!isVoidTag(tag) && !/\/>$/.test(token)) {
72
+ stack.push({ node: element, start: match.index });
73
+ } else {
74
+ element.raw = html.slice(match.index, tokenPattern.lastIndex);
75
+ }
76
+ }
77
+ appendText(html.slice(lastIndex));
78
+ for (let index = 1; index < stack.length; index += 1) {
79
+ const entry = stack[index];
80
+ if (entry.node.type === "element") {
81
+ entry.node.raw = html.slice(entry.start);
82
+ }
83
+ }
84
+ return root;
85
+ function current() {
86
+ return stack[stack.length - 1].node;
87
+ }
88
+ function appendText(value) {
89
+ if (value) current().children.push({ type: "text", value });
90
+ }
91
+ function closeTag(tag, end) {
92
+ for (let index = stack.length - 1; index > 0; index -= 1) {
93
+ const entry = stack[index];
94
+ if (entry.node.type === "element" && entry.node.tag === tag) {
95
+ entry.node.raw = html.slice(entry.start, end);
96
+ stack.length = index;
97
+ return;
98
+ }
99
+ }
100
+ appendText(html.slice(end - tag.length - 3, end));
101
+ }
102
+ }
103
+ function parseAttrs(input) {
104
+ const attrs = {};
105
+ const attrPattern = /([^\s"'=<>`]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
106
+ let match;
107
+ while ((match = attrPattern.exec(input)) !== null) {
108
+ attrs[match[1].toLowerCase()] = decodeEntities(match[2] ?? match[3] ?? match[4] ?? "");
109
+ }
110
+ return attrs;
111
+ }
112
+ function hasUnsupportedAttrs(node) {
113
+ const names = Object.keys(node.attrs);
114
+ if (names.length === 0) return false;
115
+ if (node.tag === "a") return names.some((name) => name !== "href" && name !== "title");
116
+ if (node.tag === "img") return names.some((name) => name !== "src" && name !== "alt" && name !== "title");
117
+ if (node.tag === "ol") return names.some((name) => name !== "start");
118
+ if (node.tag === "code" || node.tag === "pre") {
119
+ return names.some((name) => name !== "class") || !/\blanguage-[A-Za-z0-9_-]+/.test(node.attrs.class ?? "");
120
+ }
121
+ if (/^h[1-6]$/.test(node.tag)) {
122
+ return names.some((name) => {
123
+ if (name !== "id") return true;
124
+ return node.attrs.id !== slugifyText(textContent(node));
125
+ });
126
+ }
127
+ return true;
128
+ }
129
+ function slugifyText(value) {
130
+ return value.toLowerCase().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
131
+ }
132
+ function renderChildren(nodes, options, depth) {
133
+ return nodes.map((node) => renderNode(node, options, depth)).join("");
134
+ }
135
+ function renderNode(node, options, depth) {
136
+ if (node.type === "text") return collapseText(decodeEntities(node.value));
137
+ if (node.type === "comment") return options.unsupported === "preserve" ? node.value : " ";
138
+ if (node.type === "root") return renderChildren(node.children, options, depth);
139
+ const inline = () => normalizeInline(renderChildren(node.children, options, depth));
140
+ const block = () => normalizeDocument(renderChildren(node.children, options, depth));
141
+ if (options.unsupported === "preserve" && hasUnsupportedAttrs(node)) {
142
+ return blockTags.has(node.tag) ? blockWrap(node.raw) : node.raw;
143
+ }
144
+ if (/^h[1-6]$/.test(node.tag)) return blockWrap(`${"#".repeat(Number(node.tag[1]))} ${inline()}`);
145
+ if (node.tag === "p") return blockWrap(normalizeParagraph(renderChildren(node.children, options, depth)));
146
+ if (node.tag === "br") return " \n";
147
+ if (node.tag === "hr") return blockWrap("---");
148
+ if (node.tag === "strong" || node.tag === "b") return inlineWrap("**", inline());
149
+ if (node.tag === "em" || node.tag === "i") return inlineWrap("*", inline());
150
+ if (node.tag === "del" || node.tag === "s" || node.tag === "strike") return inlineWrap("~~", inline());
151
+ if (node.tag === "code") return renderInlineCode(textContent(node));
152
+ if (node.tag === "pre") return blockWrap(renderCodeBlock(node));
153
+ if (node.tag === "a") return renderLink(node, inline());
154
+ if (node.tag === "img") return renderImage(node);
155
+ if (node.tag === "blockquote") return blockWrap(prefixLines(block(), "> "));
156
+ if (node.tag === "ul" || node.tag === "ol") return blockWrap(renderList(node, options, depth));
157
+ if (node.tag === "li") return inline();
158
+ if (node.tag === "table") {
159
+ if (options.unsupported === "preserve" && tableHasUnsupportedStructure(node)) return blockWrap(node.raw);
160
+ return blockWrap(renderTable(node, options));
161
+ }
162
+ if (node.tag === "thead" || node.tag === "tbody" || node.tag === "tr" || node.tag === "th" || node.tag === "td") return inline();
163
+ if (node.tag === "div" || node.tag === "section" || node.tag === "article" || node.tag === "main" || node.tag === "header" || node.tag === "footer" || node.tag === "nav") return blockWrap(block());
164
+ if (node.tag === "span") return inline();
165
+ if (passthroughInlineTags.has(node.tag) || blockTags.has(node.tag)) {
166
+ return options.unsupported === "preserve" ? node.raw : block();
167
+ }
168
+ return options.unsupported === "preserve" ? node.raw : inline();
169
+ }
170
+ function renderLink(node, text) {
171
+ const href = node.attrs.href;
172
+ if (!href) return text;
173
+ const title = node.attrs.title ? ` "${escapeTitle(node.attrs.title)}"` : "";
174
+ return `[${escapeLinkText(text)}](${escapeUrl(href)}${title})`;
175
+ }
176
+ function renderImage(node) {
177
+ const src = node.attrs.src;
178
+ if (!src) return "";
179
+ const alt = escapeLinkText(node.attrs.alt ?? "");
180
+ const title = node.attrs.title ? ` "${escapeTitle(node.attrs.title)}"` : "";
181
+ return `![${alt}](${escapeUrl(src)}${title})`;
182
+ }
183
+ function renderInlineCode(value) {
184
+ const ticks = longestRun(value, "`") + 1;
185
+ const fence = "`".repeat(Math.max(1, ticks));
186
+ const padding = value.startsWith("`") || value.endsWith("`") ? " " : "";
187
+ return `${fence}${padding}${value}${padding}${fence}`;
188
+ }
189
+ function renderCodeBlock(node) {
190
+ const codeElement = node.children.find((child) => child.type === "element" && child.tag === "code");
191
+ const className = codeElement?.attrs.class ?? node.attrs.class ?? "";
192
+ const lang = /\blanguage-([A-Za-z0-9_-]+)/.exec(className)?.[1] ?? "";
193
+ const code = textContent(codeElement ?? node).replace(/\n$/, "");
194
+ const fence = "`".repeat(Math.max(3, longestRun(code, "`") + 1));
195
+ return `${fence}${lang}
196
+ ${code}
197
+ ${fence}`;
198
+ }
199
+ function renderList(node, options, depth) {
200
+ return node.children.filter((child) => child.type === "element" && child.tag === "li").map((item, index) => {
201
+ const marker = node.tag === "ol" ? `${Number(node.attrs.start ?? 1) + index}. ` : "- ";
202
+ const body = normalizeListItemBody(renderChildren(item.children, options, depth + 1));
203
+ return indentContinuation(`${marker}${body}`, marker.length);
204
+ }).join("\n");
205
+ }
206
+ function renderTable(node, options) {
207
+ const rows = collectRows(node).map((row) => row.children.filter((cell) => cell.type === "element" && (cell.tag === "th" || cell.tag === "td"))).filter((row) => row.length > 0);
208
+ if (rows.length === 0) return "";
209
+ const width = Math.max(...rows.map((row) => row.length));
210
+ const values = rows.map((row) => Array.from({ length: width }, (_, index) => normalizeInline(renderChildren(row[index]?.children ?? [], options, 0))));
211
+ const header = values[0];
212
+ const separator = Array.from({ length: width }, () => "---");
213
+ const body = values.slice(1);
214
+ return [header, separator, ...body].map((row) => `| ${row.join(" | ")} |`).join("\n");
215
+ }
216
+ function tableHasUnsupportedStructure(node) {
217
+ return collectRows(node).some(
218
+ (row) => row.children.some(
219
+ (cell) => cell.type === "element" && (cell.tag === "th" || cell.tag === "td") && Object.keys(cell.attrs).length > 0
220
+ )
221
+ );
222
+ }
223
+ function collectRows(node) {
224
+ const rows = [];
225
+ for (const child of node.children) {
226
+ if (child.type !== "element") continue;
227
+ if (child.tag === "tr") rows.push(child);
228
+ if (child.tag === "thead" || child.tag === "tbody" || child.tag === "tfoot") rows.push(...collectRows(child));
229
+ }
230
+ return rows;
231
+ }
232
+ function textContent(node) {
233
+ if (node.type === "text") return decodeEntities(node.value);
234
+ if ("children" in node) return node.children.map(textContent).join("");
235
+ return "";
236
+ }
237
+ function inlineWrap(marker, value) {
238
+ return value ? `${marker}${value}${marker}` : "";
239
+ }
240
+ function blockWrap(value) {
241
+ const trimmed = value.trim();
242
+ return trimmed ? `
243
+
244
+ ${trimmed}
245
+
246
+ ` : "";
247
+ }
248
+ function normalizeDocument(value) {
249
+ return value.replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
250
+ }
251
+ function normalizeInline(value) {
252
+ return value.replace(/[ \t\r\n]+/g, " ").trim();
253
+ }
254
+ function normalizeParagraph(value) {
255
+ return value.split("\n").map((line) => normalizeInline(line)).join("\n").replace(/ * \n */g, " \n").trim();
256
+ }
257
+ function normalizeListItemBody(value) {
258
+ return normalizeDocument(value).replace(/\n\n(?=(?:[-*+]|\d+[.)]) )/g, "\n");
259
+ }
260
+ function collapseText(value) {
261
+ return value.replace(/\s+/g, " ");
262
+ }
263
+ function prefixLines(value, prefix) {
264
+ return value.split("\n").map((line) => line ? `${prefix}${line}` : prefix.trimEnd()).join("\n");
265
+ }
266
+ function indentContinuation(value, size) {
267
+ const indent = " ".repeat(size);
268
+ return value.split("\n").map((line, index) => index === 0 ? line : `${indent}${line}`).join("\n");
269
+ }
270
+ function isVoidTag(tag) {
271
+ return /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(tag);
272
+ }
273
+ function decodeEntities(value) {
274
+ return value.replace(/&#x([0-9a-f]+);?/gi, (_, hex) => String.fromCodePoint(Number.parseInt(hex, 16))).replace(/&#([0-9]+);?/g, (_, decimal) => String.fromCodePoint(Number.parseInt(decimal, 10))).replace(/&([a-z]+);/gi, (entity, name) => namedEntities[name.toLowerCase()] ?? entity);
275
+ }
276
+ var namedEntities = {
277
+ amp: "&",
278
+ apos: "'",
279
+ gt: ">",
280
+ lt: "<",
281
+ nbsp: " ",
282
+ quot: '"'
283
+ };
284
+ function escapeLinkText(value) {
285
+ return value.replace(/([\\\]])/g, "\\$1");
286
+ }
287
+ function escapeTitle(value) {
288
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
289
+ }
290
+ function escapeUrl(value) {
291
+ return value.replace(/\s/g, "%20").replace(/\)/g, "%29");
292
+ }
293
+ function longestRun(value, char) {
294
+ let longest = 0;
295
+ let current = 0;
296
+ for (const part of value) {
297
+ if (part === char) {
298
+ current += 1;
299
+ longest = Math.max(longest, current);
300
+ } else {
301
+ current = 0;
302
+ }
303
+ }
304
+ return longest;
305
+ }
306
+
307
+ // src/collect.ts
308
+ function collect(ast) {
309
+ const headings = [];
310
+ const links = [];
311
+ const images = [];
312
+ const text = blockText(ast.children, { headings, links, images }).trim();
313
+ const words = text ? text.split(/\s+/).length : 0;
314
+ return {
315
+ text,
316
+ headings,
317
+ links,
318
+ images,
319
+ excerpt: text ? text.slice(0, 160).trim() : void 0,
320
+ readingTime: {
321
+ words,
322
+ minutes: Math.max(1, Math.ceil(words / 200))
323
+ }
324
+ };
325
+ }
326
+ function blockText(nodes, state) {
327
+ return nodes.map((node) => {
328
+ if (node.type === "heading") {
329
+ const text = inlineText(node.children, state);
330
+ state.headings.push({
331
+ id: node.id ?? "",
332
+ slug: node.id ?? "",
333
+ text,
334
+ depth: node.depth,
335
+ level: node.depth
336
+ });
337
+ return text;
338
+ }
339
+ if (node.type === "paragraph") return inlineText(node.children, state);
340
+ if (node.type === "code") return node.code;
341
+ if (node.type === "list") {
342
+ return node.children.map((item) => blockText(item.children, state)).join("\n");
343
+ }
344
+ if (node.type === "blockquote") return blockText(node.children, state);
345
+ if (node.type === "table") {
346
+ return node.children.map((row) => row.children.map((cell) => inlineText(cell.children, state)).join(" ")).join("\n");
347
+ }
348
+ if (node.type === "html") return node.value;
349
+ if (node.type === "customBlock") return nestedText(node.children ?? [], state);
350
+ return "";
351
+ }).filter(Boolean).join("\n");
352
+ }
353
+ function inlineText(nodes, state) {
354
+ if (nodes.length === 0) return "";
355
+ if (nodes.length === 1) return inlineNodeText(nodes[0], state);
356
+ return nodes.map((node) => inlineNodeText(node, state)).join("");
357
+ }
358
+ function inlineNodeText(node, state) {
359
+ if (node.type === "text") return node.value;
360
+ if (node.type === "inlineHtml") return "";
361
+ if (node.type === "lineBreak") return " ";
362
+ if (node.type === "inlineCode") return node.code;
363
+ if (node.type === "image") {
364
+ state.images.push({
365
+ src: node.src,
366
+ alt: node.alt,
367
+ title: node.title
368
+ });
369
+ return node.alt ?? "";
370
+ }
371
+ if (node.type === "link") {
372
+ const text = inlineText(node.children, state);
373
+ state.links.push({
374
+ href: node.href,
375
+ text,
376
+ title: node.title,
377
+ external: Boolean(node.external)
378
+ });
379
+ return text;
380
+ }
381
+ return inlineText(node.children, state);
382
+ }
383
+ function nestedText(nodes, state) {
384
+ return nodes.map((node) => {
385
+ if (node.type === "root") return blockText(node.children, state);
386
+ if (isBlock(node)) return blockText([node], state);
387
+ if (isInline(node)) return inlineText([node], state);
388
+ if (node.type === "listItem") return blockText(node.children, state);
389
+ if (node.type === "tableRow") {
390
+ return node.children.map((cell) => inlineText(cell.children, state)).join(" ");
391
+ }
392
+ if (node.type === "tableCell") return inlineText(node.children, state);
393
+ return "";
394
+ }).join("\n");
395
+ }
396
+ function isInline(node) {
397
+ return [
398
+ "text",
399
+ "emphasis",
400
+ "strong",
401
+ "delete",
402
+ "lineBreak",
403
+ "inlineCode",
404
+ "link",
405
+ "image",
406
+ "inlineHtml"
407
+ ].includes(node.type);
408
+ }
409
+ function isBlock(node) {
410
+ return ![
411
+ "root",
412
+ "text",
413
+ "emphasis",
414
+ "strong",
415
+ "delete",
416
+ "lineBreak",
417
+ "inlineCode",
418
+ "link",
419
+ "image"
420
+ ].includes(node.type);
421
+ }
422
+
423
+ // src/frontmatter.ts
424
+ var extractFrontmatter = (markdown) => {
425
+ if (!markdown.startsWith("---\n")) {
426
+ return { markdown, frontmatter: {} };
427
+ }
428
+ const end = markdown.indexOf("\n---", 4);
429
+ if (end === -1) {
430
+ return { markdown, frontmatter: {} };
431
+ }
432
+ const raw = markdown.slice(4, end).trim();
433
+ const rest = markdown.slice(end).replace(/^\n---\n?/, "").replace(/^\n/, "");
434
+ return {
435
+ markdown: rest,
436
+ frontmatter: parseSimpleYaml(raw)
437
+ };
438
+ };
439
+ var parseSimpleYaml = (raw) => {
440
+ const result = {};
441
+ const lines = raw.split("\n");
442
+ let currentKey = null;
443
+ let currentArray = null;
444
+ for (const line of lines) {
445
+ const listMatch = /^\s+-\s+(.*)$/.exec(line);
446
+ if (listMatch && currentKey !== null) {
447
+ if (!currentArray) currentArray = [];
448
+ currentArray.push(parseValue(listMatch[1]));
449
+ continue;
450
+ }
451
+ if (currentKey !== null && currentArray !== null) {
452
+ result[currentKey] = currentArray;
453
+ currentArray = null;
454
+ currentKey = null;
455
+ }
456
+ const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line.trim());
457
+ if (!match) continue;
458
+ const [, key, rawValue] = match;
459
+ if (rawValue.trim() === "") {
460
+ currentKey = key;
461
+ currentArray = null;
462
+ } else {
463
+ result[key] = parseValue(rawValue);
464
+ currentKey = null;
465
+ }
466
+ }
467
+ if (currentKey !== null && currentArray !== null) {
468
+ result[currentKey] = currentArray;
469
+ }
470
+ return result;
471
+ };
472
+ var parseValue = (value) => {
473
+ const trimmed = value.trim();
474
+ if (trimmed === "true") return true;
475
+ if (trimmed === "false") return false;
476
+ if (trimmed === "null") return null;
477
+ if (/^-?\d+(\.\d+)?$/.test(trimmed)) return Number(trimmed);
478
+ return trimmed.replace(/^["']|["']$/g, "");
479
+ };
480
+
481
+ // ../../node_modules/@sil/case/dist/index.mjs
482
+ var h = { a: ["\xE4", "\xE1", "\xE0", "\xE2", "\xE3", "\u0101", "\u01CE", "\xE5", "\u0103", "\u0105", "\u01DF", "\u01E1", "\u01FB", "\u0201", "\u0203", "\u0227", "\u1EA1", "\u1EA3", "\u1EA5", "\u1EA7", "\u1EA9", "\u1EAB", "\u1EAD", "\u1EAF", "\u1EB1", "\u1EB3", "\u1EB5", "\u1EB7"], b: ["\xDF", "\u0180", "\u0183", "\u0253", "\u1D6C", "\u1D80", "\u1E03", "\u1E05", "\u1E07"], c: ["\u0107", "\u010D", "\xE7", "\u0109", "\u010B", "\u0188", "\u023C", "\u0255", "\u1E09"], d: ["\u0111", "\u010F", "\u1E0B", "\u1E0D", "\u1E0F", "\u1E11", "\u1E13"], e: ["\xEB", "\xE9", "\xE8", "\xEA", "\u0113", "\u011B", "\u0117", "\u0119", "\u01DD", "\u0205", "\u0207", "\u0229", "\u025B", "\u0258", "\u1EB9", "\u1EBB", "\u1EBD", "\u1EBF", "\u1EC1", "\u1EC3", "\u1EC5", "\u1EC7"], f: ["\u0192", "\u1E1F"], g: ["\u011F", "\u011D", "\u0121", "\u0123", "\u01E7", "\u01F5", "\u0260", "\u1E21", "\u1D79"], h: ["\u0125", "\u021F", "\u1E29", "\u1E25", "\u1E2B", "\u1E96", "\u0127", "\u2C68", "\u0266"], i: ["\xEF", "\xED", "\xEC", "\xEE", "\u012B", "\u01D0", "\u012F", "\u0131", "\u0268", "\u1EC9", "\u1ECB", "\u026A", "\u0269"], j: ["\u0135", "\u01F0", "\u0237"], k: ["\u0137", "\u0199", "\u1E33", "\u1E35", "\u2C6A"], l: ["\u0142", "\u013A", "\u013E", "\u013C", "\u0140", "\u1E37", "\u1E39", "\u1E3B", "\u1E3D", "\u0234"], m: ["\u1E41", "\u1E43", "\u1D6F", "\u0271", "\u1D86", "\u1E3F", "\u1E41", "\u1E43", "\u1E47", "\u1E45", "\u1E49", "\u1E4B"], n: ["\xF1", "\u0144", "\u01F9", "\u0148", "\u0146", "\u014B", "\u0272", "\u1E45", "\u1E47", "\u1E49", "\u1E4B", "\u207F"], o: ["\xF6", "\xF3", "\xF2", "\xF4", "\xF5", "\u014D", "\u01D2", "\xF8", "\u0151", "\u01A1", "\u01EB", "\u020D", "\u020F", "\u022B", "\u022D", "\u022F", "\u1ECD", "\u1ECF", "\u1ED1", "\u1ED3", "\u1ED5", "\u1ED7", "\u1ED9", "\u1EDB", "\u1EDD", "\u1EDF", "\u1EE1", "\u1EE3"], p: ["\xFE", "\u01A5", "\u1D7D", "\u1D88", "\u1E57"], q: ["\u02A0", "\u024B"], r: ["\u0159", "\u0155", "\u1E59", "\u1E5B", "\u1E5D", "\u1E5F"], s: ["\u015B", "\u0161", "\u015F", "\u015D", "\u0219", "\u1E61", "\u1E63", "\u1E65", "\u1E67", "\u1E69"], t: ["\u0163", "\u0165", "\u1E6B", "\u1E6D", "\u1E6F", "\u1E71", "\u1E97", "\u01AD", "\u0236"], u: ["\xFC", "\xFA", "\xF9", "\xFB", "\u016B", "\u01D4", "\u016F", "\u0171", "\u0173", "\u01B0", "\u01D8", "\u01DC", "\u01D6", "\u01DA", "\u0215", "\u0217", "\u1EE5", "\u1EE7", "\u1EE9", "\u1EEB", "\u1EED", "\u1EEF", "\u1EF1"], v: ["\u028B", "\u1E7F", "\u2C71", "\u028C"], w: ["\u1E85", "\u1E83", "\u1E81", "\u0175", "\u1E87", "\u1E89", "\u2C73", "\u1E98"], x: ["\u1E8D", "\u1E8B", "\u2093", "\u2715"], y: ["\xFF", "\xFD", "\u1EF3", "\u0177", "\xFF", "\u1EF9", "\u0233", "\u024F", "\u01B4", "\u028E", "\u1E99", "\u1EF7", "\u1EF5"], z: ["\u017E", "\u017A", "\u017C", "\u1E91", "\u1E93", "\u1E95"] };
483
+ var A = (e) => e === e.toUpperCase();
484
+ var u = (e, t) => e.split("").map((s) => {
485
+ if (t && t.has(s)) return s;
486
+ if (!s.match(/([a-zA-Z0-9 -])/g)) {
487
+ let a = Object.keys(h).find((o) => h[o].indexOf(s.toLowerCase()) > -1) || "_";
488
+ return A(s) ? a.toUpperCase() : a;
489
+ }
490
+ return s;
491
+ }).join("");
492
+ var $ = (e, t = {}) => {
493
+ if (!e) return "";
494
+ let r = t.exclude ? new Set(t.exclude) : void 0, n = u(e, r);
495
+ if (t.exclude && t.exclude.length > 0) {
496
+ let l = e.split(/[-_\s]+/), c = "";
497
+ for (let i = 0; i < l.length; i++) {
498
+ let x = l[i];
499
+ if (!x) continue;
500
+ let f = "", w = c === "" || i > 0;
501
+ for (let p = 0; p < x.length; p++) {
502
+ let d = x[p];
503
+ if (r.has(d)) {
504
+ if (f) {
505
+ let S = u(f, r);
506
+ c += w ? S.charAt(0).toUpperCase() + S.slice(1).toLowerCase() : S.toLowerCase(), f = "";
507
+ }
508
+ c += d, w = !/[a-zA-ZÀ-ÿ]/i.test(d);
509
+ } else f += d;
510
+ }
511
+ if (f) {
512
+ let p = u(f, r);
513
+ c += w ? p.charAt(0).toUpperCase() + p.slice(1).toLowerCase() : p.toLowerCase();
514
+ }
515
+ }
516
+ return c;
517
+ }
518
+ let s = "A-Za-z0-9", a = `^[^${s}]*|[^${s}]*$`, o = new RegExp(a, "g"), g = `[^${s}]+`, C = new RegExp(g, "g");
519
+ return String(n).replace(o, "$").replace(C, "$").replace(/([a-z])([A-Z])/g, (l, c, i) => c + "$" + i).toLowerCase().replace(/(\$)(\w?)/g, (l, c, i) => i.toUpperCase());
520
+ };
521
+ var j = (e, t = {}) => {
522
+ if (!e) return "";
523
+ let r = $(e, t);
524
+ return r.charAt(0).toLowerCase() + r.substring(1);
525
+ };
526
+ var L = (e = "", t = {}) => {
527
+ if (!e) return "";
528
+ let r = t.exclude ? new Set(t.exclude) : void 0, s = u(e, r).replace(/[-_]/g, " ");
529
+ if (s = s.replace(/([a-z])([A-Z])/g, "$1 $2"), s = s.replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2"), t.exclude && t.exclude.length > 0) {
530
+ let a = e.split(/[-_\s]+/), o = [];
531
+ for (let g = 0; g < a.length; g++) {
532
+ let C = a[g];
533
+ if (!C) continue;
534
+ g > 0 && o.push("-");
535
+ let l = "";
536
+ for (let c = 0; c < C.length; c++) {
537
+ let i = C[c];
538
+ if (r.has(i)) {
539
+ if (l) {
540
+ let x = u(l, r);
541
+ o.push(x.toLowerCase()), l = "";
542
+ }
543
+ o.push(i);
544
+ } else l += i;
545
+ }
546
+ if (l) {
547
+ let c = u(l, r);
548
+ o.push(c.toLowerCase());
549
+ }
550
+ }
551
+ return o.join("");
552
+ }
553
+ return s.split(" ").filter((a) => a.length > 0).map((a) => a.toLowerCase()).join("-");
554
+ };
555
+ var m = (e, t = {}) => e ? L(e, t).replace(/-/g, "_") : "";
556
+ var b = (e, t = {}) => {
557
+ if (!e) return "";
558
+ if (!t.exclude || t.exclude.length === 0) return m(e, t).toUpperCase();
559
+ let r = new Set(t.exclude), n = m(e, t), s = "";
560
+ for (let a = 0; a < n.length; a++) {
561
+ let o = n[a];
562
+ r.has(o) || r.has(o.toLowerCase()), s += o.toUpperCase();
563
+ }
564
+ return s;
565
+ };
566
+ var P = (e, t = {}) => e ? L(e, t) : "";
567
+ var I = (e, t = {}) => {
568
+ if (!e || !e.trim()) return "";
569
+ let n = (t.exclude ? e : u(e)).replace(/([a-z])([A-Z])/g, "$1 $2");
570
+ return n = n.trim(), n ? (n = n.replace(/[-_]/g, " ").toLowerCase(), n.replace(/^./, (s) => s.toUpperCase())) : "";
571
+ };
572
+
573
+ // ../../node_modules/@sil/format/dist/index.mjs
574
+ var __defProp = Object.defineProperty;
575
+ var __defProps = Object.defineProperties;
576
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
577
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
578
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
579
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
580
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
581
+ var __spreadValues = (a, b2) => {
582
+ for (var prop in b2 || (b2 = {}))
583
+ if (__hasOwnProp.call(b2, prop))
584
+ __defNormalProp(a, prop, b2[prop]);
585
+ if (__getOwnPropSymbols)
586
+ for (var prop of __getOwnPropSymbols(b2)) {
587
+ if (__propIsEnum.call(b2, prop))
588
+ __defNormalProp(a, prop, b2[prop]);
589
+ }
590
+ return a;
591
+ };
592
+ var __spreadProps = (a, b2) => __defProps(a, __getOwnPropDescs(b2));
593
+ var pad = (value) => `${value}`.padStart(2, "0");
594
+ var flattenObject = (obj, parentKey) => {
595
+ let result = {};
596
+ Object.entries(obj).forEach(([key, value]) => {
597
+ const _key = parentKey ? parentKey + "." + key : key;
598
+ if (typeof value === "object") {
599
+ result = __spreadValues(__spreadValues({}, result), flattenObject(value, _key));
600
+ } else {
601
+ result[_key] = value;
602
+ }
603
+ });
604
+ return result;
605
+ };
606
+ var Language = {
607
+ AM: "Armenian",
608
+ AR: "Arabic",
609
+ BG: "Bulgarian",
610
+ CY: "Welsh",
611
+ DE: "German",
612
+ DK: "Danish",
613
+ EN: "English",
614
+ ES: "Spanish",
615
+ ET: "Estonian",
616
+ FI: "Finnish",
617
+ FR: "French",
618
+ GR: "Greek",
619
+ HU: "Hungarian",
620
+ IR: "Irish",
621
+ IT: "Italian",
622
+ LA: "Latvian",
623
+ LT: "Lithuanian",
624
+ MT: "Maltese",
625
+ NL: "Dutch",
626
+ NO: "Norwegian",
627
+ PE: "Persian",
628
+ PL: "Polish",
629
+ PT: "Portuguese",
630
+ RO: "Romanian",
631
+ RU: "Russian",
632
+ SV: "SWEDISH"
633
+ };
634
+ var defaultOptions = {
635
+ language: Language.EN,
636
+ index: -1,
637
+ padded: false,
638
+ template: "YY-MM-DD hh:mm:ss",
639
+ replace: {}
640
+ };
641
+ var copy = {
642
+ "month": [
643
+ "\u0540\u0578\u0582\u0576\u057E\u0561\u0580",
644
+ "\u0553\u0565\u057F\u0580\u057E\u0561\u0580",
645
+ "\u0544\u0561\u0580\u057F",
646
+ "\u0531\u057A\u0580\u056B\u056C",
647
+ "\u0544\u0561\u0575\u056B\u057D",
648
+ "\u0540\u0578\u0582\u0576\u056B\u057D",
649
+ "\u0540\u0578\u0582\u056C\u056B\u057D",
650
+ "\u0555\u0563\u0578\u057D\u057F\u0578\u057D",
651
+ "\u054D\u0565\u057A\u057F\u0565\u0574\u0562\u0565\u0580",
652
+ "\u0540\u0578\u056F\u057F\u0565\u0574\u0562\u0565\u0580",
653
+ "\u0546\u0578\u0575\u0565\u0574\u0562\u0565\u0580",
654
+ "\u0534\u0565\u056F\u057F\u0565\u0574\u0562\u0565\u0580"
655
+ ],
656
+ "month_short": [
657
+ "\u0540\u0578\u0582\u0576",
658
+ "\u0553\u0565\u057F",
659
+ "\u0544\u0561\u0580",
660
+ "\u0531\u057A\u0580",
661
+ "\u0544\u0561\u0575",
662
+ "\u0540\u0578\u0582\u0576",
663
+ "\u0540\u0578\u0582\u056C",
664
+ "\u0555\u0563\u057D",
665
+ "\u054D\u0565\u057A",
666
+ "\u0540\u0578\u056F",
667
+ "\u0546\u0578\u0575",
668
+ "\u0534\u0565\u056F"
669
+ ],
670
+ "day": [
671
+ "\u053F\u056B\u0580\u0561\u056F\u056B",
672
+ "\u0535\u0580\u056F\u0578\u0582\u0577\u0561\u0562\u0569\u056B",
673
+ "\u0535\u0580\u0565\u0584\u0577\u0561\u0562\u0569\u056B",
674
+ "\u0549\u0578\u0580\u0565\u0584\u0577\u0561\u0562\u0569\u056B",
675
+ "\u0540\u056B\u0576\u0563\u0577\u0561\u0562\u0569\u056B",
676
+ "\u0548\u0582\u0580\u0562\u0561\u0569",
677
+ "\u0547\u0561\u0562\u0561\u0569"
678
+ ],
679
+ "day_short": [
680
+ "\u053F\u056B\u0580",
681
+ "\u0535\u0580\u056F",
682
+ "\u0535\u0580\u0584",
683
+ "\u0549\u0578\u0580",
684
+ "\u0540\u0576\u0563",
685
+ "\u0548\u0582\u0580\u0562",
686
+ "\u0547\u0562\u0569"
687
+ ],
688
+ "ordinal": {
689
+ "one": "{n}\u056B\u0576",
690
+ "two": "{n}\u0580\u0564",
691
+ "few": "{n}\u0580\u0564",
692
+ "other": "{n}\u0580\u0564"
693
+ }
694
+ };
695
+ var am_default = copy;
696
+ var copy2 = {
697
+ "month": [
698
+ "\u064A\u0646\u0627\u064A\u0631",
699
+ "\u0641\u0628\u0631\u0627\u064A\u0631",
700
+ "\u0645\u0627\u0631\u0633",
701
+ "\u0623\u0628\u0631\u064A\u0644",
702
+ "\u0645\u0627\u064A\u0648",
703
+ "\u064A\u0648\u0646\u064A\u0648",
704
+ "\u064A\u0648\u0644\u064A\u0648",
705
+ "\u0623\u063A\u0633\u0637\u0633",
706
+ "\u0633\u0628\u062A\u0645\u0628\u0631",
707
+ "\u0623\u0643\u062A\u0648\u0628\u0631",
708
+ "\u0646\u0648\u0641\u0645\u0628\u0631",
709
+ "\u062F\u064A\u0633\u0645\u0628\u0631"
710
+ ],
711
+ "month_short": [
712
+ "\u064A\u0646\u0627",
713
+ "\u0641\u0628\u0631",
714
+ "\u0645\u0627\u0631",
715
+ "\u0623\u0628\u0631",
716
+ "\u0645\u0627\u064A",
717
+ "\u064A\u0648\u0646",
718
+ "\u064A\u0648\u0644",
719
+ "\u0623\u063A\u0633",
720
+ "\u0633\u0628\u062A",
721
+ "\u0623\u0643\u062A",
722
+ "\u0646\u0648\u0641",
723
+ "\u062F\u064A\u0633"
724
+ ],
725
+ "day": [
726
+ "\u0627\u0644\u0623\u062D\u062F",
727
+ "\u0627\u0644\u0627\u062B\u0646\u064A\u0646",
728
+ "\u0627\u0644\u062B\u0644\u0627\u062B\u0627\u0621",
729
+ "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621",
730
+ "\u0627\u0644\u062E\u0645\u064A\u0633",
731
+ "\u0627\u0644\u062C\u0645\u0639\u0629",
732
+ "\u0627\u0644\u0633\u0628\u062A"
733
+ ],
734
+ "day_short": [
735
+ "\u0627\u0644\u0623\u062D",
736
+ "\u0627\u0644\u0627\u062B",
737
+ "\u0627\u0644\u062B\u0644",
738
+ "\u0627\u0644\u0623\u0631",
739
+ "\u0627\u0644\u062E\u0645",
740
+ "\u0627\u0644\u062C\u0645",
741
+ "\u0627\u0644\u0633\u0628"
742
+ ],
743
+ "ordinal": {
744
+ "one": "{n}\u0627\u0644\u0623\u0648\u0644",
745
+ "two": "{n}\u0627\u0644\u062B\u0627\u0646\u064A",
746
+ "few": "{n}\u0627\u0644\u062B\u0627\u0644\u062B",
747
+ "other": "{n}\u0627\u0644\u062B\u0627\u0644\u062B"
748
+ }
749
+ };
750
+ var ar_default = copy2;
751
+ var copy3 = {
752
+ "month": [
753
+ "\u044F\u043D\u0443\u0430\u0440\u0438",
754
+ "\u0444\u0435\u0432\u0440\u0443\u0430\u0440\u0438",
755
+ "\u043C\u0430\u0440\u0442",
756
+ "\u0430\u043F\u0440\u0438\u043B",
757
+ "\u043C\u0430\u0439",
758
+ "\u044E\u043D\u0438",
759
+ "\u044E\u043B\u0438",
760
+ "\u0430\u0432\u0433\u0443\u0441\u0442",
761
+ "\u0441\u0435\u043F\u0442\u0435\u043C\u0432\u0440\u0438",
762
+ "\u043E\u043A\u0442\u043E\u043C\u0432\u0440\u0438",
763
+ "\u043D\u043E\u0435\u043C\u0432\u0440\u0438",
764
+ "\u0434\u0435\u043A\u0435\u043C\u0432\u0440\u0438"
765
+ ],
766
+ "month_short": [
767
+ "\u044F\u043D\u0443",
768
+ "\u0444\u0435\u0432",
769
+ "\u043C\u0430\u0440",
770
+ "\u0430\u043F\u0440",
771
+ "\u043C\u0430\u0439",
772
+ "\u044E\u043D\u0438",
773
+ "\u044E\u043B\u0438",
774
+ "\u0430\u0432\u0433",
775
+ "\u0441\u0435\u043F",
776
+ "\u043E\u043A\u0442",
777
+ "\u043D\u043E\u0435",
778
+ "\u0434\u0435\u043A"
779
+ ],
780
+ "day": [
781
+ "\u043D\u0435\u0434\u0435\u043B\u044F",
782
+ "\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u043D\u0438\u043A",
783
+ "\u0432\u0442\u043E\u0440\u043D\u0438\u043A",
784
+ "\u0441\u0440\u044F\u0434\u0430",
785
+ "\u0447\u0435\u0442\u0432\u044A\u0440\u0442\u044A\u043A",
786
+ "\u043F\u0435\u0442\u044A\u043A",
787
+ "\u0441\u044A\u0431\u043E\u0442\u0430"
788
+ ],
789
+ "day_short": [
790
+ "\u043D\u0435\u0434",
791
+ "\u043F\u043E\u043D",
792
+ "\u0432\u0442\u043E",
793
+ "\u0441\u0440\u044F",
794
+ "\u0447\u0435\u0442",
795
+ "\u043F\u0435\u0442",
796
+ "\u0441\u044A\u0431"
797
+ ],
798
+ ordinal: {
799
+ one: "\u0432\u0438",
800
+ two: "\u0440\u0438",
801
+ few: "\u0442\u0438",
802
+ other: "\u0442\u0438"
803
+ }
804
+ };
805
+ var bg_default = copy3;
806
+ var copy4 = {
807
+ "month": [
808
+ "Ionawr",
809
+ "Chwefror",
810
+ "Mawrth",
811
+ "Ebrill",
812
+ "Mai",
813
+ "Mehefin",
814
+ "Gorffennaf",
815
+ "Awst",
816
+ "Medi",
817
+ "Hydref",
818
+ "Tachwedd",
819
+ "Rhagfyr"
820
+ ],
821
+ "month_short": [
822
+ "Ion",
823
+ "Chwef",
824
+ "Maw",
825
+ "Ebr",
826
+ "Mai",
827
+ "Meh",
828
+ "Gorff",
829
+ "Awst",
830
+ "Medi",
831
+ "Hyd",
832
+ "Tach",
833
+ "Rhag"
834
+ ],
835
+ "day": [
836
+ "Dydd Sul",
837
+ "Dydd Llun",
838
+ "Dydd Mawrth",
839
+ "Dydd Mercher",
840
+ "Dydd Iau",
841
+ "Dydd Gwener",
842
+ "Dydd Sadwrn"
843
+ ],
844
+ "day_short": [
845
+ "Sul",
846
+ "Llun",
847
+ "Maw",
848
+ "Mer",
849
+ "Iau",
850
+ "Gwen",
851
+ "Sad"
852
+ ],
853
+ "ordinal": {
854
+ "one": "{n}fed",
855
+ "two": "{n}fed",
856
+ "few": "{n}ydd",
857
+ "other": "{n}ed"
858
+ }
859
+ };
860
+ var cy_default = copy4;
861
+ var copy5 = {
862
+ month: [
863
+ "Januar",
864
+ "Februar",
865
+ "M\xE4rz",
866
+ "April",
867
+ "Mai",
868
+ "Juni",
869
+ "Juli",
870
+ "August",
871
+ "September",
872
+ "Oktober",
873
+ "November",
874
+ "Dezember"
875
+ ],
876
+ month_short: [
877
+ "Jan",
878
+ "Feb",
879
+ "M\xE4r",
880
+ "Apr",
881
+ "Mai",
882
+ "Jun",
883
+ "Jul",
884
+ "Aug",
885
+ "Sep",
886
+ "Okt",
887
+ "Nov",
888
+ "Dez"
889
+ ],
890
+ day: [
891
+ "Sonntag",
892
+ "Montag",
893
+ "Dienstag",
894
+ "Mittwoch",
895
+ "Donnerstag",
896
+ "Freitag",
897
+ "Samstag"
898
+ ],
899
+ day_short: [
900
+ "So",
901
+ "Mo",
902
+ "Di",
903
+ "Mi",
904
+ "Do",
905
+ "Fr",
906
+ "Sa"
907
+ ],
908
+ ordinal: {
909
+ "one": "{n}ste",
910
+ "two": "{n}de",
911
+ "few": "{n}de",
912
+ "other": "{n}de"
913
+ }
914
+ };
915
+ var de_default = copy5;
916
+ var copy6 = {
917
+ "month": [
918
+ "januar",
919
+ "februar",
920
+ "marts",
921
+ "april",
922
+ "maj",
923
+ "juni",
924
+ "juli",
925
+ "august",
926
+ "september",
927
+ "oktober",
928
+ "november",
929
+ "december"
930
+ ],
931
+ "month_short": [
932
+ "jan",
933
+ "feb",
934
+ "mar",
935
+ "apr",
936
+ "maj",
937
+ "jun",
938
+ "jul",
939
+ "aug",
940
+ "sep",
941
+ "okt",
942
+ "nov",
943
+ "dec"
944
+ ],
945
+ "day": [
946
+ "s\xF8ndag",
947
+ "mandag",
948
+ "tirsdag",
949
+ "onsdag",
950
+ "torsdag",
951
+ "fredag",
952
+ "l\xF8rdag"
953
+ ],
954
+ "day_short": [
955
+ "s\xF8n",
956
+ "man",
957
+ "tir",
958
+ "ons",
959
+ "tor",
960
+ "fre",
961
+ "l\xF8r"
962
+ ],
963
+ "ordinal": {
964
+ "one": "{n}st",
965
+ "two": "{n}nd",
966
+ "few": "{n}rd",
967
+ "other": "{n}th"
968
+ }
969
+ };
970
+ var dk_default = copy6;
971
+ var copy7 = {
972
+ month: [
973
+ "January",
974
+ "February",
975
+ "March",
976
+ "April",
977
+ "May",
978
+ "June",
979
+ "July",
980
+ "August",
981
+ "September",
982
+ "October",
983
+ "November",
984
+ "December"
985
+ ],
986
+ month_short: [
987
+ "jan",
988
+ "feb",
989
+ "mar",
990
+ "apr",
991
+ "may",
992
+ "jun",
993
+ "jul",
994
+ "aug",
995
+ "sep",
996
+ "oct",
997
+ "nov",
998
+ "dec"
999
+ ],
1000
+ day: [
1001
+ "Sunday",
1002
+ "Monday",
1003
+ "Tuesday",
1004
+ "Wednesday",
1005
+ "Thursday",
1006
+ "Friday",
1007
+ "Saturday"
1008
+ ],
1009
+ day_short: ["sun", "mon", "tue", "wed", "thu", "fri", "sat"],
1010
+ ordinal: {
1011
+ one: "{n}st",
1012
+ two: "{n}nd",
1013
+ few: "{n}rd",
1014
+ other: "{n}th"
1015
+ }
1016
+ };
1017
+ var en_default = copy7;
1018
+ var copy8 = {
1019
+ "month": [
1020
+ "enero",
1021
+ "febrero",
1022
+ "marzo",
1023
+ "abril",
1024
+ "mayo",
1025
+ "junio",
1026
+ "julio",
1027
+ "agosto",
1028
+ "septiembre",
1029
+ "octubre",
1030
+ "noviembre",
1031
+ "diciembre"
1032
+ ],
1033
+ "month_short": [
1034
+ "ene",
1035
+ "feb",
1036
+ "mar",
1037
+ "abr",
1038
+ "may",
1039
+ "jun",
1040
+ "jul",
1041
+ "ago",
1042
+ "sep",
1043
+ "oct",
1044
+ "nov",
1045
+ "dic"
1046
+ ],
1047
+ "day": [
1048
+ "domingo",
1049
+ "lunes",
1050
+ "martes",
1051
+ "mi\xE9rcoles",
1052
+ "jueves",
1053
+ "viernes",
1054
+ "s\xE1bado"
1055
+ ],
1056
+ "day_short": [
1057
+ "dom",
1058
+ "lun",
1059
+ "mar",
1060
+ "mi\xE9",
1061
+ "jue",
1062
+ "vie",
1063
+ "s\xE1b"
1064
+ ],
1065
+ "ordinal": {
1066
+ "one": "{n}ro",
1067
+ "two": "{n}do",
1068
+ "few": "{n}ro",
1069
+ "other": "{n}to"
1070
+ }
1071
+ };
1072
+ var es_default = copy8;
1073
+ var copy9 = {
1074
+ "month": [
1075
+ "jaanuar",
1076
+ "veebruar",
1077
+ "m\xE4rts",
1078
+ "aprill",
1079
+ "mai",
1080
+ "juuni",
1081
+ "juuli",
1082
+ "august",
1083
+ "september",
1084
+ "oktoober",
1085
+ "november",
1086
+ "detsember"
1087
+ ],
1088
+ "month_short": [
1089
+ "jaan",
1090
+ "veebr",
1091
+ "m\xE4rts",
1092
+ "apr",
1093
+ "mai",
1094
+ "juuni",
1095
+ "juuli",
1096
+ "aug",
1097
+ "sept",
1098
+ "okt",
1099
+ "nov",
1100
+ "dets"
1101
+ ],
1102
+ "day": [
1103
+ "p\xFChap\xE4ev",
1104
+ "esmasp\xE4ev",
1105
+ "teisip\xE4ev",
1106
+ "kolmap\xE4ev",
1107
+ "neljap\xE4ev",
1108
+ "reede",
1109
+ "laup\xE4ev"
1110
+ ],
1111
+ "day_short": [
1112
+ "P",
1113
+ "E",
1114
+ "T",
1115
+ "K",
1116
+ "N",
1117
+ "R",
1118
+ "L"
1119
+ ],
1120
+ "ordinal": {
1121
+ "one": "{n}esimene",
1122
+ "two": "{n}teine",
1123
+ "few": "{n}kolmas",
1124
+ "other": "{n}esimene"
1125
+ }
1126
+ };
1127
+ var et_default = copy9;
1128
+ var copy10 = {
1129
+ "month": [
1130
+ "tammikuu",
1131
+ "helmikuu",
1132
+ "maaliskuu",
1133
+ "huhtikuu",
1134
+ "toukokuu",
1135
+ "kes\xE4kuu",
1136
+ "hein\xE4kuu",
1137
+ "elokuu",
1138
+ "syyskuu",
1139
+ "lokakuu",
1140
+ "marraskuu",
1141
+ "joulukuu"
1142
+ ],
1143
+ "month_short": [
1144
+ "tammi",
1145
+ "helmi",
1146
+ "maalis",
1147
+ "huhti",
1148
+ "touko",
1149
+ "kes\xE4",
1150
+ "hein\xE4",
1151
+ "elo",
1152
+ "syys",
1153
+ "loka",
1154
+ "marras",
1155
+ "joulu"
1156
+ ],
1157
+ "day": [
1158
+ "sunnuntai",
1159
+ "maanantai",
1160
+ "tiistai",
1161
+ "keskiviikko",
1162
+ "torstai",
1163
+ "perjantai",
1164
+ "lauantai"
1165
+ ],
1166
+ "day_short": [
1167
+ "su",
1168
+ "ma",
1169
+ "ti",
1170
+ "ke",
1171
+ "to",
1172
+ "pe",
1173
+ "la"
1174
+ ],
1175
+ "ordinal": {
1176
+ "one": "{n}ensimm\xE4inen",
1177
+ "two": "{n}toinen",
1178
+ "few": "{n}kolmas",
1179
+ "other": "{n}kolmas"
1180
+ }
1181
+ };
1182
+ var fi_default = copy10;
1183
+ var copy11 = {
1184
+ "month": [
1185
+ "janvier",
1186
+ "f\xE9vrier",
1187
+ "mars",
1188
+ "avril",
1189
+ "mai",
1190
+ "juin",
1191
+ "juillet",
1192
+ "ao\xFBt",
1193
+ "septembre",
1194
+ "octobre",
1195
+ "novembre",
1196
+ "d\xE9cembre"
1197
+ ],
1198
+ "month_short": [
1199
+ "janv",
1200
+ "f\xE9vr",
1201
+ "mars",
1202
+ "avr",
1203
+ "mai",
1204
+ "juin",
1205
+ "juil",
1206
+ "ao\xFBt",
1207
+ "sept",
1208
+ "oct",
1209
+ "nov",
1210
+ "d\xE9c"
1211
+ ],
1212
+ "day": [
1213
+ "dimanche",
1214
+ "lundi",
1215
+ "mardi",
1216
+ "mercredi",
1217
+ "jeudi",
1218
+ "vendredi",
1219
+ "samedi"
1220
+ ],
1221
+ "day_short": [
1222
+ "dim",
1223
+ "lun",
1224
+ "mar",
1225
+ "mer",
1226
+ "jeu",
1227
+ "ven",
1228
+ "sam"
1229
+ ],
1230
+ "ordinal": {
1231
+ "one": "{n}er",
1232
+ "two": "{n}do",
1233
+ "few": "{n}do",
1234
+ "other": "{n}to"
1235
+ }
1236
+ };
1237
+ var fr_default = copy11;
1238
+ var copy12 = {
1239
+ "month": [
1240
+ "\u0399\u03B1\u03BD\u03BF\u03C5\u03AC\u03C1\u03B9\u03BF\u03C2",
1241
+ "\u03A6\u03B5\u03B2\u03C1\u03BF\u03C5\u03AC\u03C1\u03B9\u03BF\u03C2",
1242
+ "\u039C\u03AC\u03C1\u03C4\u03B9\u03BF\u03C2",
1243
+ "\u0391\u03C0\u03C1\u03AF\u03BB\u03B9\u03BF\u03C2",
1244
+ "\u039C\u03AC\u03B9\u03BF\u03C2",
1245
+ "\u0399\u03BF\u03CD\u03BD\u03B9\u03BF\u03C2",
1246
+ "\u0399\u03BF\u03CD\u03BB\u03B9\u03BF\u03C2",
1247
+ "\u0391\u03CD\u03B3\u03BF\u03C5\u03C3\u03C4\u03BF\u03C2",
1248
+ "\u03A3\u03B5\u03C0\u03C4\u03AD\u03BC\u03B2\u03C1\u03B9\u03BF\u03C2",
1249
+ "\u039F\u03BA\u03C4\u03CE\u03B2\u03C1\u03B9\u03BF\u03C2",
1250
+ "\u039D\u03BF\u03AD\u03BC\u03B2\u03C1\u03B9\u03BF\u03C2",
1251
+ "\u0394\u03B5\u03BA\u03AD\u03BC\u03B2\u03C1\u03B9\u03BF\u03C2"
1252
+ ],
1253
+ "month_short": [
1254
+ "\u0399\u03B1\u03BD",
1255
+ "\u03A6\u03B5\u03B2",
1256
+ "\u039C\u03AC\u03C1",
1257
+ "\u0391\u03C0\u03C1",
1258
+ "\u039C\u03AC\u03B9",
1259
+ "\u0399\u03BF\u03CD\u03BD",
1260
+ "\u0399\u03BF\u03CD\u03BB",
1261
+ "\u0391\u03CD\u03B3",
1262
+ "\u03A3\u03B5\u03C0",
1263
+ "\u039F\u03BA\u03C4",
1264
+ "\u039D\u03BF\u03AD",
1265
+ "\u0394\u03B5\u03BA"
1266
+ ],
1267
+ "day": [
1268
+ "\u039A\u03C5\u03C1\u03B9\u03B1\u03BA\u03AE",
1269
+ "\u0394\u03B5\u03C5\u03C4\u03AD\u03C1\u03B1",
1270
+ "\u03A4\u03C1\u03AF\u03C4\u03B7",
1271
+ "\u03A4\u03B5\u03C4\u03AC\u03C1\u03C4\u03B7",
1272
+ "\u03A0\u03AD\u03BC\u03C0\u03C4\u03B7",
1273
+ "\u03A0\u03B1\u03C1\u03B1\u03C3\u03BA\u03B5\u03C5\u03AE",
1274
+ "\u03A3\u03AC\u03B2\u03B2\u03B1\u03C4\u03BF"
1275
+ ],
1276
+ "day_short": [
1277
+ "\u039A\u03C5\u03C1",
1278
+ "\u0394\u03B5\u03C5",
1279
+ "\u03A4\u03C1\u03B9",
1280
+ "\u03A4\u03B5\u03C4",
1281
+ "\u03A0\u03B5\u03BC",
1282
+ "\u03A0\u03B1\u03C1",
1283
+ "\u03A3\u03B1\u03B2"
1284
+ ],
1285
+ "ordinal": {
1286
+ "one": "{n}\u03B7",
1287
+ "two": "{n}\u03B7",
1288
+ "few": "{n}\u03B7",
1289
+ "other": "{n}\u03B7"
1290
+ }
1291
+ };
1292
+ var gr_default = copy12;
1293
+ var copy13 = {
1294
+ "month": [
1295
+ "janu\xE1r",
1296
+ "febru\xE1r",
1297
+ "m\xE1rcius",
1298
+ "\xE1prilis",
1299
+ "m\xE1jus",
1300
+ "j\xFAnius",
1301
+ "j\xFAlius",
1302
+ "augusztus",
1303
+ "szeptember",
1304
+ "okt\xF3ber",
1305
+ "november",
1306
+ "december"
1307
+ ],
1308
+ "month_short": [
1309
+ "jan",
1310
+ "feb",
1311
+ "m\xE1r",
1312
+ "\xE1pr",
1313
+ "m\xE1j",
1314
+ "j\xFAn",
1315
+ "j\xFAl",
1316
+ "aug",
1317
+ "szept",
1318
+ "okt",
1319
+ "nov",
1320
+ "dec"
1321
+ ],
1322
+ "day": [
1323
+ "vas\xE1rnap",
1324
+ "h\xE9tf\u0151",
1325
+ "kedd",
1326
+ "szerda",
1327
+ "cs\xFCt\xF6rt\xF6k",
1328
+ "p\xE9ntek",
1329
+ "szombat"
1330
+ ],
1331
+ "day_short": [
1332
+ "v",
1333
+ "h",
1334
+ "k",
1335
+ "sze",
1336
+ "cs",
1337
+ "p",
1338
+ "szo"
1339
+ ],
1340
+ "ordinal": {
1341
+ "one": "{n}ik",
1342
+ "two": "{n}ik",
1343
+ "few": "{n}ik",
1344
+ "other": "{n}ik"
1345
+ }
1346
+ };
1347
+ var hu_default = copy13;
1348
+ var copy14 = {
1349
+ "month": [
1350
+ "Ean\xE1ir",
1351
+ "Feabhra",
1352
+ "M\xE1rta",
1353
+ "Aibre\xE1n",
1354
+ "Bealtaine",
1355
+ "Meitheamh",
1356
+ "I\xFAil",
1357
+ "L\xFAnasa",
1358
+ "Me\xE1n F\xF3mhair",
1359
+ "Deireadh F\xF3mhair",
1360
+ "Samhain",
1361
+ "Nollaig"
1362
+ ],
1363
+ "month_short": [
1364
+ "Ean",
1365
+ "Feabh",
1366
+ "M\xE1r",
1367
+ "Aib",
1368
+ "Beal",
1369
+ "Meith",
1370
+ "I\xFAil",
1371
+ "L\xFAn",
1372
+ "MF\xF3mh",
1373
+ "DF\xF3mh",
1374
+ "Samh",
1375
+ "Noll"
1376
+ ],
1377
+ "day": [
1378
+ "D\xE9 Domhnaigh",
1379
+ "D\xE9 Luain",
1380
+ "D\xE9 M\xE1irt",
1381
+ "D\xE9 C\xE9adaoin",
1382
+ "D\xE9ardaoin",
1383
+ "D\xE9 hAoine",
1384
+ "D\xE9 Sathairn"
1385
+ ],
1386
+ "day_short": [
1387
+ "Domh",
1388
+ "Luan",
1389
+ "M\xE1irt",
1390
+ "C\xE9ad",
1391
+ "D\xE9ar",
1392
+ "Aoine",
1393
+ "Sath"
1394
+ ],
1395
+ "ordinal": {
1396
+ "one": "{n}\xFA",
1397
+ "two": "{n}\xFA",
1398
+ "few": "{n}\xFA",
1399
+ "other": "{n}\xFA"
1400
+ }
1401
+ };
1402
+ var ir_default = copy14;
1403
+ var copy15 = {
1404
+ "month": [
1405
+ "gennaio",
1406
+ "febbraio",
1407
+ "marzo",
1408
+ "aprile",
1409
+ "maggio",
1410
+ "giugno",
1411
+ "luglio",
1412
+ "agosto",
1413
+ "settembre",
1414
+ "ottobre",
1415
+ "novembre",
1416
+ "dicembre"
1417
+ ],
1418
+ "month_short": [
1419
+ "gen",
1420
+ "feb",
1421
+ "mar",
1422
+ "apr",
1423
+ "mag",
1424
+ "giu",
1425
+ "lug",
1426
+ "ago",
1427
+ "set",
1428
+ "ott",
1429
+ "nov",
1430
+ "dic"
1431
+ ],
1432
+ "day": [
1433
+ "domenica",
1434
+ "luned\xEC",
1435
+ "marted\xEC",
1436
+ "mercoled\xEC",
1437
+ "gioved\xEC",
1438
+ "venerd\xEC",
1439
+ "sabato"
1440
+ ],
1441
+ "day_short": [
1442
+ "dom",
1443
+ "lun",
1444
+ "mar",
1445
+ "mer",
1446
+ "gio",
1447
+ "ven",
1448
+ "sab"
1449
+ ],
1450
+ "ordinal": {
1451
+ "one": "{n}ro",
1452
+ "two": "{n}do",
1453
+ "few": "{n}ro",
1454
+ "other": "{n}to"
1455
+ }
1456
+ };
1457
+ var it_default = copy15;
1458
+ var copy16 = {
1459
+ "month": [
1460
+ "janv\u0101ris",
1461
+ "febru\u0101ris",
1462
+ "marts",
1463
+ "apr\u012Blis",
1464
+ "maijs",
1465
+ "j\u016Bnijs",
1466
+ "j\u016Blijs",
1467
+ "augusts",
1468
+ "septembris",
1469
+ "oktobris",
1470
+ "novembris",
1471
+ "decembris"
1472
+ ],
1473
+ "month_short": [
1474
+ "jan",
1475
+ "feb",
1476
+ "mar",
1477
+ "apr",
1478
+ "mai",
1479
+ "j\u016Bn",
1480
+ "j\u016Bl",
1481
+ "aug",
1482
+ "sep",
1483
+ "okt",
1484
+ "nov",
1485
+ "dec"
1486
+ ],
1487
+ "day": [
1488
+ "sv\u0113tdiena",
1489
+ "pirmdiena",
1490
+ "otrdiena",
1491
+ "tre\u0161diena",
1492
+ "ceturtdiena",
1493
+ "piektdiena",
1494
+ "sestdiena"
1495
+ ],
1496
+ "day_short": [
1497
+ "sv\u0113t",
1498
+ "pir",
1499
+ "otr",
1500
+ "tre",
1501
+ "cet",
1502
+ "pie",
1503
+ "ses"
1504
+ ],
1505
+ "ordinal": {
1506
+ "one": "{n}ais",
1507
+ "two": "{n}ais",
1508
+ "few": "{n}ais",
1509
+ "other": "{n}ais"
1510
+ }
1511
+ };
1512
+ var la_default = copy16;
1513
+ var copy17 = {
1514
+ "month": [
1515
+ "sausis",
1516
+ "vasaris",
1517
+ "kovas",
1518
+ "balandis",
1519
+ "gegu\u017E\u0117",
1520
+ "bir\u017Eelis",
1521
+ "liepa",
1522
+ "rugpj\u016Btis",
1523
+ "rugs\u0117jis",
1524
+ "spalis",
1525
+ "lapkritis",
1526
+ "gruodis"
1527
+ ],
1528
+ "month_short": [
1529
+ "sau",
1530
+ "vas",
1531
+ "kov",
1532
+ "bal",
1533
+ "geg",
1534
+ "bir",
1535
+ "lie",
1536
+ "rugp",
1537
+ "rugs",
1538
+ "spa",
1539
+ "lap",
1540
+ "gru"
1541
+ ],
1542
+ "day": [
1543
+ "sekmadienis",
1544
+ "pirmadienis",
1545
+ "antradienis",
1546
+ "tre\u010Diadienis",
1547
+ "ketvirtadienis",
1548
+ "penktadienis",
1549
+ "\u0161e\u0161tadienis"
1550
+ ],
1551
+ "day_short": [
1552
+ "sek",
1553
+ "pir",
1554
+ "ant",
1555
+ "tre",
1556
+ "ket",
1557
+ "pen",
1558
+ "\u0161e\u0161"
1559
+ ],
1560
+ "ordinal": {
1561
+ "one": "{n}as",
1562
+ "two": "{n}as",
1563
+ "few": "{n}as",
1564
+ "other": "{n}as"
1565
+ }
1566
+ };
1567
+ var lt_default = copy17;
1568
+ var copy18 = {
1569
+ "month": [
1570
+ "Jannar",
1571
+ "Frar",
1572
+ "Marzu",
1573
+ "April",
1574
+ "Mejju",
1575
+ "\u0120unju",
1576
+ "Lulju",
1577
+ "Awissu",
1578
+ "Settembru",
1579
+ "Ottubru",
1580
+ "Novembru",
1581
+ "Di\u010Bembru"
1582
+ ],
1583
+ "month_short": [
1584
+ "Jan",
1585
+ "Fra",
1586
+ "Mar",
1587
+ "Apr",
1588
+ "Mej",
1589
+ "\u0120un",
1590
+ "Lul",
1591
+ "Awi",
1592
+ "Set",
1593
+ "Ott",
1594
+ "Nov",
1595
+ "Di\u010B"
1596
+ ],
1597
+ "day": [
1598
+ "Il-\u0126add",
1599
+ "It-Tnejn",
1600
+ "It-Tlieta",
1601
+ "L-Erbg\u0127a",
1602
+ "Il-\u0126amis",
1603
+ "Il-\u0120img\u0127a",
1604
+ "Is-Sibt"
1605
+ ],
1606
+ "day_short": [
1607
+ "\u0126ad",
1608
+ "Tne",
1609
+ "Tli",
1610
+ "Erb",
1611
+ "\u0126am",
1612
+ "\u0120im",
1613
+ "Sib"
1614
+ ],
1615
+ "ordinal": {
1616
+ "one": "il{n}",
1617
+ "two": "il{n}",
1618
+ "few": "il{n}",
1619
+ "other": "il{n}"
1620
+ }
1621
+ };
1622
+ var mt_default = copy18;
1623
+ var copy19 = {
1624
+ month: [
1625
+ "januari",
1626
+ "februari",
1627
+ "maart",
1628
+ "april",
1629
+ "mei",
1630
+ "juni",
1631
+ "juli",
1632
+ "augustus",
1633
+ "september",
1634
+ "oktober",
1635
+ "november",
1636
+ "december"
1637
+ ],
1638
+ month_short: [
1639
+ "jan",
1640
+ "feb",
1641
+ "mrt",
1642
+ "apr",
1643
+ "mei",
1644
+ "jun",
1645
+ "jul",
1646
+ "aug",
1647
+ "sep",
1648
+ "okt",
1649
+ "nov",
1650
+ "dec"
1651
+ ],
1652
+ day: [
1653
+ "zondag",
1654
+ "maandag",
1655
+ "dinsdag",
1656
+ "woensdag",
1657
+ "donderdag",
1658
+ "vrijdag",
1659
+ "zaterdag"
1660
+ ],
1661
+ day_short: ["zo", "ma", "di", "wo", "do", "vr", "za"],
1662
+ ordinal: {
1663
+ one: "{n}ste",
1664
+ two: "{n}de",
1665
+ few: "{n}de",
1666
+ other: "{n}de"
1667
+ }
1668
+ };
1669
+ var nl_default = copy19;
1670
+ var copy20 = {
1671
+ "month": [
1672
+ "januar",
1673
+ "februar",
1674
+ "mars",
1675
+ "april",
1676
+ "mai",
1677
+ "juni",
1678
+ "juli",
1679
+ "august",
1680
+ "september",
1681
+ "oktober",
1682
+ "november",
1683
+ "desember"
1684
+ ],
1685
+ "month_short": [
1686
+ "jan",
1687
+ "feb",
1688
+ "mar",
1689
+ "apr",
1690
+ "mai",
1691
+ "jun",
1692
+ "jul",
1693
+ "aug",
1694
+ "sep",
1695
+ "okt",
1696
+ "nov",
1697
+ "des"
1698
+ ],
1699
+ "day": [
1700
+ "s\xF8ndag",
1701
+ "mandag",
1702
+ "tirsdag",
1703
+ "onsdag",
1704
+ "torsdag",
1705
+ "fredag",
1706
+ "l\xF8rdag"
1707
+ ],
1708
+ "day_short": [
1709
+ "s\xF8n",
1710
+ "man",
1711
+ "tir",
1712
+ "ons",
1713
+ "tor",
1714
+ "fre",
1715
+ "l\xF8r"
1716
+ ],
1717
+ "ordinal": {
1718
+ "one": "{n}ste",
1719
+ "two": "{n}de",
1720
+ "few": "{n}de",
1721
+ "other": "{n}de"
1722
+ }
1723
+ };
1724
+ var no_default = copy20;
1725
+ var copy21 = {
1726
+ "month": [
1727
+ "\u0698\u0627\u0646\u0648\u06CC\u0647",
1728
+ "\u0641\u0648\u0631\u06CC\u0647",
1729
+ "\u0645\u0627\u0631\u0633",
1730
+ "\u0622\u0648\u0631\u06CC\u0644",
1731
+ "\u0645\u0647",
1732
+ "\u0698\u0648\u0626\u0646",
1733
+ "\u0698\u0648\u0626\u06CC\u0647",
1734
+ "\u0627\u0648\u062A",
1735
+ "\u0633\u067E\u062A\u0627\u0645\u0628\u0631",
1736
+ "\u0627\u06A9\u062A\u0628\u0631",
1737
+ "\u0646\u0648\u0627\u0645\u0628\u0631",
1738
+ "\u062F\u0633\u0627\u0645\u0628\u0631"
1739
+ ],
1740
+ "month_short": [
1741
+ "\u0698\u0627\u0646",
1742
+ "\u0641\u0648\u0631",
1743
+ "\u0645\u0627\u0631",
1744
+ "\u0622\u0648\u0631",
1745
+ "\u0645\u0647",
1746
+ "\u0698\u0648\u0646",
1747
+ "\u0698\u0648\u06CC",
1748
+ "\u0627\u0648\u062A",
1749
+ "\u0633\u067E\u062A",
1750
+ "\u0627\u06A9\u062A",
1751
+ "\u0646\u0648\u0627",
1752
+ "\u062F\u0633\u0627"
1753
+ ],
1754
+ "day": [
1755
+ "\u06CC\u06A9\u0634\u0646\u0628\u0647",
1756
+ "\u062F\u0648\u0634\u0646\u0628\u0647",
1757
+ "\u0633\u0647\u200C\u0634\u0646\u0628\u0647",
1758
+ "\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647",
1759
+ "\u067E\u0646\u062C\u0634\u0646\u0628\u0647",
1760
+ "\u062C\u0645\u0639\u0647",
1761
+ "\u0634\u0646\u0628\u0647"
1762
+ ],
1763
+ "day_short": [
1764
+ "\u06CC\u06A9",
1765
+ "\u062F\u0648",
1766
+ "\u0633\u0647",
1767
+ "\u0686\u0647\u0627\u0631",
1768
+ "\u067E\u0646\u062C",
1769
+ "\u062C\u0645\u0639\u0647",
1770
+ "\u0634\u0646\u0628\u0647"
1771
+ ],
1772
+ "ordinal": {
1773
+ "one": "{n}\u0645",
1774
+ "two": "{n}\u0645",
1775
+ "few": "{n}\u0645",
1776
+ "other": "{n}\u0645"
1777
+ }
1778
+ };
1779
+ var pe_default = copy21;
1780
+ var copy22 = {
1781
+ "month": [
1782
+ "stycze\u0144",
1783
+ "luty",
1784
+ "marzec",
1785
+ "kwiecie\u0144",
1786
+ "maj",
1787
+ "czerwiec",
1788
+ "lipiec",
1789
+ "sierpie\u0144",
1790
+ "wrzesie\u0144",
1791
+ "pa\u017Adziernik",
1792
+ "listopad",
1793
+ "grudzie\u0144"
1794
+ ],
1795
+ "month_short": [
1796
+ "sty",
1797
+ "lut",
1798
+ "mar",
1799
+ "kwi",
1800
+ "maj",
1801
+ "cze",
1802
+ "lip",
1803
+ "sie",
1804
+ "wrz",
1805
+ "pa\u017A",
1806
+ "lis",
1807
+ "gru"
1808
+ ],
1809
+ "day": [
1810
+ "niedziela",
1811
+ "poniedzia\u0142ek",
1812
+ "wtorek",
1813
+ "\u015Broda",
1814
+ "czwartek",
1815
+ "pi\u0105tek",
1816
+ "sobota"
1817
+ ],
1818
+ "day_short": [
1819
+ "niedz",
1820
+ "pon",
1821
+ "wt",
1822
+ "\u015Br",
1823
+ "czw",
1824
+ "pt",
1825
+ "sob"
1826
+ ],
1827
+ "ordinal": {
1828
+ "one": "{n}szy",
1829
+ "two": "{n}gi",
1830
+ "few": "{n}gi",
1831
+ "other": "{n}gi"
1832
+ }
1833
+ };
1834
+ var pl_default = copy22;
1835
+ var copy23 = {
1836
+ "month": [
1837
+ "janeiro",
1838
+ "fevereiro",
1839
+ "mar\xE7o",
1840
+ "abril",
1841
+ "maio",
1842
+ "junho",
1843
+ "julho",
1844
+ "agosto",
1845
+ "setembro",
1846
+ "outubro",
1847
+ "novembro",
1848
+ "dezembro"
1849
+ ],
1850
+ "month_short": [
1851
+ "jan",
1852
+ "fev",
1853
+ "mar",
1854
+ "abr",
1855
+ "mai",
1856
+ "jun",
1857
+ "jul",
1858
+ "ago",
1859
+ "set",
1860
+ "out",
1861
+ "nov",
1862
+ "dez"
1863
+ ],
1864
+ "day": [
1865
+ "domingo",
1866
+ "segunda-feira",
1867
+ "ter\xE7a-feira",
1868
+ "quarta-feira",
1869
+ "quinta-feira",
1870
+ "sexta-feira",
1871
+ "s\xE1bado"
1872
+ ],
1873
+ "day_short": [
1874
+ "dom",
1875
+ "seg",
1876
+ "ter",
1877
+ "qua",
1878
+ "qui",
1879
+ "sex",
1880
+ "s\xE1b"
1881
+ ],
1882
+ "ordinal": {
1883
+ "one": "{n}ro",
1884
+ "two": "{n}do",
1885
+ "few": "{n}ro",
1886
+ "other": "{n}to"
1887
+ }
1888
+ };
1889
+ var pt_default = copy23;
1890
+ var copy24 = {
1891
+ "month": [
1892
+ "ianuarie",
1893
+ "februarie",
1894
+ "martie",
1895
+ "aprilie",
1896
+ "mai",
1897
+ "iunie",
1898
+ "iulie",
1899
+ "august",
1900
+ "septembrie",
1901
+ "octombrie",
1902
+ "noiembrie",
1903
+ "decembrie"
1904
+ ],
1905
+ "month_short": [
1906
+ "ian",
1907
+ "feb",
1908
+ "mar",
1909
+ "apr",
1910
+ "mai",
1911
+ "iun",
1912
+ "iul",
1913
+ "aug",
1914
+ "sept",
1915
+ "oct",
1916
+ "nov",
1917
+ "dec"
1918
+ ],
1919
+ "day": [
1920
+ "duminic\u0103",
1921
+ "luni",
1922
+ "mar\u021Bi",
1923
+ "miercuri",
1924
+ "joi",
1925
+ "vineri",
1926
+ "s\xE2mb\u0103t\u0103"
1927
+ ],
1928
+ "day_short": [
1929
+ "dum",
1930
+ "lun",
1931
+ "mar",
1932
+ "mie",
1933
+ "joi",
1934
+ "vin",
1935
+ "s\xE2m"
1936
+ ],
1937
+ "ordinal": {
1938
+ "one": "{n}st",
1939
+ "two": "{n}nd",
1940
+ "few": "{n}rd",
1941
+ "other": "{n}th"
1942
+ }
1943
+ };
1944
+ var ro_default = copy24;
1945
+ var copy25 = {
1946
+ "month": [
1947
+ "\u042F\u043D\u0432\u0430\u0440\u044C",
1948
+ "\u0424\u0435\u0432\u0440\u0430\u043B\u044C",
1949
+ "\u041C\u0430\u0440\u0442",
1950
+ "\u0410\u043F\u0440\u0435\u043B\u044C",
1951
+ "\u041C\u0430\u0439",
1952
+ "\u0418\u044E\u043D\u044C",
1953
+ "\u0418\u044E\u043B\u044C",
1954
+ "\u0410\u0432\u0433\u0443\u0441\u0442",
1955
+ "\u0421\u0435\u043D\u0442\u044F\u0431\u0440\u044C",
1956
+ "\u041E\u043A\u0442\u044F\u0431\u0440\u044C",
1957
+ "\u041D\u043E\u044F\u0431\u0440\u044C",
1958
+ "\u0414\u0435\u043A\u0430\u0431\u0440\u044C"
1959
+ ],
1960
+ "month_short": [
1961
+ "\u044F\u043D\u0432",
1962
+ "\u0444\u0435\u0432",
1963
+ "\u043C\u0430\u0440",
1964
+ "\u0430\u043F\u0440",
1965
+ "\u043C\u0430\u0439",
1966
+ "\u0438\u044E\u043D",
1967
+ "\u0438\u044E\u043B",
1968
+ "\u0430\u0432\u0433",
1969
+ "\u0441\u0435\u043D",
1970
+ "\u043E\u043A\u0442",
1971
+ "\u043D\u043E\u044F",
1972
+ "\u0434\u0435\u043A"
1973
+ ],
1974
+ "day": [
1975
+ "\u0412\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435",
1976
+ "\u041F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A",
1977
+ "\u0412\u0442\u043E\u0440\u043D\u0438\u043A",
1978
+ "\u0421\u0440\u0435\u0434\u0430",
1979
+ "\u0427\u0435\u0442\u0432\u0435\u0440\u0433",
1980
+ "\u041F\u044F\u0442\u043D\u0438\u0446\u0430",
1981
+ "\u0421\u0443\u0431\u0431\u043E\u0442\u0430"
1982
+ ],
1983
+ "day_short": [
1984
+ "\u0432\u0441",
1985
+ "\u043F\u043D",
1986
+ "\u0432\u0442",
1987
+ "\u0441\u0440",
1988
+ "\u0447\u0442",
1989
+ "\u043F\u0442",
1990
+ "\u0441\u0431"
1991
+ ],
1992
+ "ordinal": {
1993
+ "one": "{n}\u044B\u0439",
1994
+ "two": "{n}\u043E\u0439",
1995
+ "few": "{n}\u043E\u0439",
1996
+ "other": "{n}\u044B\u0439"
1997
+ }
1998
+ };
1999
+ var ru_default = copy25;
2000
+ var copy26 = {
2001
+ "month": [
2002
+ "januari",
2003
+ "februari",
2004
+ "mars",
2005
+ "april",
2006
+ "maj",
2007
+ "juni",
2008
+ "juli",
2009
+ "augusti",
2010
+ "september",
2011
+ "oktober",
2012
+ "november",
2013
+ "december"
2014
+ ],
2015
+ "month_short": [
2016
+ "jan",
2017
+ "feb",
2018
+ "mar",
2019
+ "apr",
2020
+ "maj",
2021
+ "jun",
2022
+ "jul",
2023
+ "aug",
2024
+ "sep",
2025
+ "okt",
2026
+ "nov",
2027
+ "dec"
2028
+ ],
2029
+ "day": [
2030
+ "s\xF6ndag",
2031
+ "m\xE5ndag",
2032
+ "tisdag",
2033
+ "onsdag",
2034
+ "torsdag",
2035
+ "fredag",
2036
+ "l\xF6rdag"
2037
+ ],
2038
+ "day_short": [
2039
+ "s\xF6n",
2040
+ "m\xE5n",
2041
+ "tis",
2042
+ "ons",
2043
+ "tors",
2044
+ "fre",
2045
+ "l\xF6r"
2046
+ ],
2047
+ "ordinal": {
2048
+ "one": "{n}ste",
2049
+ "two": "{n}de",
2050
+ "few": "{n}de",
2051
+ "other": "{n}de"
2052
+ }
2053
+ };
2054
+ var sv_default = copy26;
2055
+ var copy27 = {
2056
+ [Language.AM]: am_default,
2057
+ [Language.AR]: ar_default,
2058
+ [Language.BG]: bg_default,
2059
+ [Language.CY]: cy_default,
2060
+ [Language.DE]: de_default,
2061
+ [Language.DK]: dk_default,
2062
+ [Language.EN]: en_default,
2063
+ [Language.ES]: es_default,
2064
+ [Language.ET]: et_default,
2065
+ [Language.FI]: fi_default,
2066
+ [Language.FR]: fr_default,
2067
+ [Language.GR]: gr_default,
2068
+ [Language.HU]: hu_default,
2069
+ [Language.IR]: ir_default,
2070
+ [Language.IT]: it_default,
2071
+ [Language.LA]: la_default,
2072
+ [Language.LT]: lt_default,
2073
+ [Language.MT]: mt_default,
2074
+ [Language.NL]: nl_default,
2075
+ [Language.NO]: no_default,
2076
+ [Language.PE]: pe_default,
2077
+ [Language.PL]: pl_default,
2078
+ [Language.PT]: pt_default,
2079
+ [Language.RO]: ro_default,
2080
+ [Language.RU]: ru_default,
2081
+ [Language.SV]: sv_default
2082
+ };
2083
+ var getCopy = (value, options) => {
2084
+ const opts = __spreadValues(__spreadValues({}, defaultOptions), options);
2085
+ const langData = flattenObject(copy27[opts.language]);
2086
+ if (!isNaN(opts.index) && opts.index > -1) {
2087
+ const key = `${value}.${opts.index}`;
2088
+ return langData[key];
2089
+ }
2090
+ return copy27[opts.language][value];
2091
+ };
2092
+ var formatOrdinal = (day, options = {}) => {
2093
+ const opts = __spreadValues(__spreadValues({}, defaultOptions), options);
2094
+ const pr = new Intl.PluralRules(opts.language, { type: "ordinal" });
2095
+ const suffixes = copy27[opts.language].ordinal;
2096
+ if (!suffixes) {
2097
+ throw new Error(`Unsupported language: ${opts.language}`);
2098
+ }
2099
+ const suffix = suffixes[pr.select(day)];
2100
+ return suffix.replace("{n}", `${day}`);
2101
+ };
2102
+ var getDateObject = (value, options = {}) => {
2103
+ const opts = __spreadValues(__spreadValues({}, defaultOptions), options);
2104
+ return {
2105
+ day: opts.padded ? pad(value.getDate()) : value.getDate(),
2106
+ day_nth: formatOrdinal(value.getDate(), options),
2107
+ weekday: opts.padded ? pad(value.getDay()) : value.getDay(),
2108
+ weekday_name: getCopy("day", __spreadProps(__spreadValues({}, opts), { index: value.getDay() })),
2109
+ weekday_abbr: getCopy("day_short", __spreadProps(__spreadValues({}, opts), {
2110
+ index: value.getDay()
2111
+ })),
2112
+ month: opts.padded ? pad(value.getMonth() + 1) : value.getMonth() + 1,
2113
+ month_index: opts.padded ? pad(value.getMonth()) : value.getMonth(),
2114
+ month_name: getCopy("month", __spreadProps(__spreadValues({}, opts), { index: value.getMonth() })),
2115
+ month_abbr: getCopy("month_short", __spreadProps(__spreadValues({}, opts), {
2116
+ index: value.getMonth()
2117
+ })),
2118
+ year: opts.padded ? `${value.getFullYear()}` : value.getFullYear(),
2119
+ hours: opts.padded ? pad(value.getHours()) : value.getHours(),
2120
+ minutes: opts.padded ? pad(value.getMinutes()) : value.getMinutes(),
2121
+ seconds: opts.padded ? pad(value.getSeconds()) : value.getSeconds()
2122
+ };
2123
+ };
2124
+ var toDateFormat = (value) => {
2125
+ if (value instanceof Date)
2126
+ return value;
2127
+ else {
2128
+ const yrs = value.year || 1970;
2129
+ const mon = value.month || 1;
2130
+ const day = value.day || 1;
2131
+ const hrs = value.hrs || 0;
2132
+ const min = value.min || 0;
2133
+ const sec = value.sec || 0;
2134
+ return /* @__PURE__ */ new Date(`${yrs} ${mon} ${day} ${hrs}:${min}:${sec}`);
2135
+ }
2136
+ };
2137
+ var format = (date, options = {}) => {
2138
+ const d = toDateFormat(date);
2139
+ const opts = __spreadValues(__spreadValues({}, defaultOptions), options);
2140
+ const obj_padded = getDateObject(d, __spreadProps(__spreadValues({}, opts), { padded: true }));
2141
+ const obj = getDateObject(d, __spreadProps(__spreadValues({}, opts), { padded: true }));
2142
+ const replacers = __spreadValues({
2143
+ DD: obj_padded.day,
2144
+ DT: obj_padded.day_nth,
2145
+ Day: obj.weekday_name,
2146
+ Da: obj.weekday_abbr,
2147
+ D: obj.day,
2148
+ MM: obj_padded.month,
2149
+ Month: obj.month_name,
2150
+ Mo: obj.month_abbr,
2151
+ M: obj.month,
2152
+ mm: obj_padded.minutes,
2153
+ m: obj.minutes,
2154
+ ss: obj_padded.seconds,
2155
+ s: obj.seconds,
2156
+ hh: obj_padded.hours,
2157
+ h: obj.hours,
2158
+ YY: obj.year,
2159
+ Y: obj_padded.year.substring(2, 4)
2160
+ }, opts.replace);
2161
+ let template = opts.template;
2162
+ Object.entries(replacers).forEach(([key, value]) => {
2163
+ if (template.indexOf(key) < 0)
2164
+ return;
2165
+ const regex = new RegExp(key, "g");
2166
+ template = template.replace(regex, `${value}`);
2167
+ });
2168
+ return template;
2169
+ };
2170
+
2171
+ // src/utils.ts
2172
+ var escapeHtml = (value) => {
2173
+ const text = String(value);
2174
+ return /[&<>"]/.test(text) ? text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;") : text;
2175
+ };
2176
+ var slugify = (value, style = "github") => {
2177
+ if (style === "classic") {
2178
+ return value.toLowerCase().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
2179
+ }
2180
+ return P(value);
2181
+ };
2182
+ var textFromUnknown = (value) => {
2183
+ if (value === null || value === void 0) return "";
2184
+ if (value instanceof Date) return value.toISOString();
2185
+ return String(value);
2186
+ };
2187
+ var getPath = (source, path) => {
2188
+ return path.split(".").reduce((value, part) => {
2189
+ if (value && typeof value === "object" && part in value) {
2190
+ return value[part];
2191
+ }
2192
+ return void 0;
2193
+ }, source);
2194
+ };
2195
+ var uniqueSlug = (base, seen) => {
2196
+ const fallback = base || "section";
2197
+ const count = seen.get(fallback) ?? 0;
2198
+ seen.set(fallback, count + 1);
2199
+ return count === 0 ? fallback : `${fallback}-${count + 1}`;
2200
+ };
2201
+
2202
+ // src/defaults.ts
2203
+ var lowerFilter = (value) => textFromUnknown(value).toLowerCase();
2204
+ var upperFilter = (value) => textFromUnknown(value).toUpperCase();
2205
+ var titleFilter = (value) => I(textFromUnknown(value)).replace(/\w\S*/g, (word) => {
2206
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
2207
+ });
2208
+ var kebabFilter = L;
2209
+ var camelFilter = j;
2210
+ var pascalFilter = $;
2211
+ var snakeFilter = m;
2212
+ var constantFilter = b;
2213
+ var capitalFilter = (value) => {
2214
+ const text = textFromUnknown(value);
2215
+ return text.charAt(0).toUpperCase() + text.slice(1);
2216
+ };
2217
+ var dotFilter = (value) => textFromUnknown(value).toLowerCase().replace(/[\s_-]+/g, ".").replace(/^\.+|\.+$/g, "");
2218
+ var headerFilter = (value) => textFromUnknown(value).replace(/\w+/g, (word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
2219
+ var pathFilter = (value) => textFromUnknown(value).toLowerCase().replace(/[\s_-]+/g, "/").replace(/^\/+|\/+$/g, "");
2220
+ var sentenceFilter = (value) => I(textFromUnknown(value));
2221
+ var formatFilter = (value, kind, localeOrCurrency = "en-US") => {
2222
+ if (kind === "currency") {
2223
+ return new Intl.NumberFormat("en-US", {
2224
+ style: "currency",
2225
+ currency: textFromUnknown(localeOrCurrency)
2226
+ }).format(Number(value));
2227
+ }
2228
+ if (kind === "number") {
2229
+ const pattern = textFromUnknown(localeOrCurrency);
2230
+ return formatNumber(Number(value), pattern);
2231
+ }
2232
+ if (kind === "date") {
2233
+ const date = new Date(textFromUnknown(value));
2234
+ const template = textFromUnknown(localeOrCurrency);
2235
+ const dateObject = getDateObject(date);
2236
+ return format(date, {
2237
+ template: normalizeDateTemplate(template === "en-US" ? "YY-MM-DD" : template),
2238
+ replace: {
2239
+ "\xA7\xA7\xA7": String(dateObject.month_name)
2240
+ }
2241
+ });
2242
+ }
2243
+ return textFromUnknown(value);
2244
+ };
2245
+ var formatNumber = (value, pattern) => {
2246
+ const digits = (pattern.match(/0/g) || []).length;
2247
+ const [intPart, decPart] = pattern.split(".");
2248
+ const decimals = decPart ? decPart.length : 0;
2249
+ return new Intl.NumberFormat("en-US", {
2250
+ minimumFractionDigits: decimals,
2251
+ maximumFractionDigits: decimals
2252
+ }).format(value);
2253
+ };
2254
+ var normalizeDateTemplate = (template) => {
2255
+ return template.replaceAll("yyyy", "YY").replaceAll("MMM", "\xA7\xA7\xA7").replaceAll("dd", "DD");
2256
+ };
2257
+ var defaultFilters = {
2258
+ lower: lowerFilter,
2259
+ upper: upperFilter,
2260
+ title: titleFilter,
2261
+ capital: capitalFilter,
2262
+ capitalize: capitalFilter,
2263
+ kebab: kebabFilter,
2264
+ camel: camelFilter,
2265
+ pascal: pascalFilter,
2266
+ snake: snakeFilter,
2267
+ constant: constantFilter,
2268
+ dot: dotFilter,
2269
+ header: headerFilter,
2270
+ path: pathFilter,
2271
+ sentence: sentenceFilter,
2272
+ format: formatFilter
2273
+ };
2274
+ var defaultOptions2 = {
2275
+ output: "html",
2276
+ frontmatter: true,
2277
+ template: { missing: "keep", raw: false, filters: defaultFilters },
2278
+ toc: true,
2279
+ anchors: true,
2280
+ autolinks: { enabled: true },
2281
+ safe: true,
2282
+ unwrapStandaloneImages: false,
2283
+ elements: {},
2284
+ blocks: {},
2285
+ data: {},
2286
+ plugins: [],
2287
+ transforms: []
2288
+ };
2289
+
2290
+ // src/options.ts
2291
+ function resolveOptions(baseOptions = {}, runtimeOptions = {}) {
2292
+ const plugins = [
2293
+ ...baseOptions.plugins ?? [],
2294
+ ...runtimeOptions.plugins ?? []
2295
+ ];
2296
+ const pluginOptions = plugins.reduce((merged, plugin) => {
2297
+ const pluginTemplate = plugin.template ?? (plugin.filters ? { filters: plugin.filters } : void 0);
2298
+ return mergeOptions(merged, {
2299
+ ...plugin.options,
2300
+ elements: plugin.elements,
2301
+ blocks: plugin.blocks,
2302
+ transforms: plugin.transforms,
2303
+ template: pluginTemplate
2304
+ });
2305
+ }, {});
2306
+ return mergeOptions(
2307
+ mergeOptions(mergeOptions(defaultOptions2, pluginOptions), baseOptions),
2308
+ runtimeOptions
2309
+ );
2310
+ }
2311
+ function mergeOptions(left, right) {
2312
+ if (!right) return left;
2313
+ return {
2314
+ ...left,
2315
+ ...right,
2316
+ data: {
2317
+ ...left.data ?? {},
2318
+ ...right.data ?? {}
2319
+ },
2320
+ variables: {
2321
+ ...left.variables ?? {},
2322
+ ...right.variables ?? {}
2323
+ },
2324
+ elements: {
2325
+ ...left.elements ?? {},
2326
+ ...right.elements ?? {}
2327
+ },
2328
+ blocks: {
2329
+ ...left.blocks ?? {},
2330
+ ...right.blocks ?? {}
2331
+ },
2332
+ transforms: [...left.transforms ?? [], ...right.transforms ?? []],
2333
+ template: mergeTemplateOptions(left.template, right.template)
2334
+ };
2335
+ }
2336
+ function mergeTemplateOptions(left, right) {
2337
+ if (right === false) return false;
2338
+ if (left === false && right === void 0) return false;
2339
+ if (left === false && right === true) return {};
2340
+ if (left === false) left = {};
2341
+ if (right === true || right === void 0) right = {};
2342
+ if (left === true || left === void 0) left = {};
2343
+ return {
2344
+ ...left,
2345
+ ...right,
2346
+ filters: {
2347
+ ...defaultFilters,
2348
+ ...left.filters,
2349
+ ...right.filters
2350
+ }
2351
+ };
2352
+ }
2353
+
2354
+ // src/parse/block.ts
2355
+ var isRawHtmlBlockLine = (line) => {
2356
+ return /^<\/?[A-Za-z][A-Za-z0-9-]*(?=[\s>/])[\s\S]*>$/.test(line.trim());
2357
+ };
2358
+ var isThematicBreak = (line) => {
2359
+ return /^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/.test(line);
2360
+ };
2361
+ var isSetextUnderline = (line) => {
2362
+ return /^ {0,3}(=+|-+)\s*$/.exec(line);
2363
+ };
2364
+ var trimClosingHeadingHashes = (source) => {
2365
+ if (/^#+\s*$/.test(source)) return "";
2366
+ return source.replace(/\s+#+\s*$/, "").trim();
2367
+ };
2368
+ var normalizeParagraphLine = (line) => {
2369
+ return line.replace(/^ {0,3}/, "").trimStart();
2370
+ };
2371
+ var normalizeParagraphSource = (lines) => {
2372
+ return lines.join("\n").replace(/[ \t]+$/, "");
2373
+ };
2374
+
2375
+ // src/parse/html.ts
2376
+ var htmlBlockTags = /* @__PURE__ */ new Set([
2377
+ "address",
2378
+ "article",
2379
+ "aside",
2380
+ "base",
2381
+ "basefont",
2382
+ "blockquote",
2383
+ "body",
2384
+ "caption",
2385
+ "center",
2386
+ "col",
2387
+ "colgroup",
2388
+ "dd",
2389
+ "details",
2390
+ "dialog",
2391
+ "dir",
2392
+ "div",
2393
+ "dl",
2394
+ "dt",
2395
+ "fieldset",
2396
+ "figcaption",
2397
+ "figure",
2398
+ "footer",
2399
+ "form",
2400
+ "frame",
2401
+ "frameset",
2402
+ "h1",
2403
+ "h2",
2404
+ "h3",
2405
+ "h4",
2406
+ "h5",
2407
+ "h6",
2408
+ "head",
2409
+ "header",
2410
+ "hr",
2411
+ "html",
2412
+ "iframe",
2413
+ "legend",
2414
+ "li",
2415
+ "link",
2416
+ "main",
2417
+ "menu",
2418
+ "menuitem",
2419
+ "nav",
2420
+ "noframes",
2421
+ "ol",
2422
+ "optgroup",
2423
+ "option",
2424
+ "p",
2425
+ "param",
2426
+ "search",
2427
+ "section",
2428
+ "summary",
2429
+ "table",
2430
+ "tbody",
2431
+ "td",
2432
+ "tfoot",
2433
+ "th",
2434
+ "thead",
2435
+ "title",
2436
+ "tr",
2437
+ "track",
2438
+ "ul"
2439
+ ]);
2440
+ var readHtmlBlock = (lines, startIndex) => {
2441
+ const line = lines[startIndex];
2442
+ if (!/^ {0,3}</.test(line)) return null;
2443
+ const trimmed = line.trimStart();
2444
+ const closedBy = htmlBlockClosingPattern(trimmed);
2445
+ if (closedBy) {
2446
+ return readHtmlBlockUntil(lines, startIndex, closedBy);
2447
+ }
2448
+ if (isBlankTerminatedHtmlBlockStart(trimmed)) {
2449
+ return readHtmlBlockUntilBlank(lines, startIndex);
2450
+ }
2451
+ return null;
2452
+ };
2453
+ var isInterruptingHtmlBlockStart = (line) => {
2454
+ if (!/^ {0,3}</.test(line)) return false;
2455
+ const trimmed = line.trimStart();
2456
+ return htmlBlockClosingPattern(trimmed) !== null || isBlockTagHtmlBlockStart(trimmed);
2457
+ };
2458
+ var isValidInlineHtmlToken = (source) => {
2459
+ if (/^(?:<!-->|<!--->|<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<![A-Z][^>]*>|<!\[CDATA\[[\s\S]*?\]\]>)$/u.test(source)) {
2460
+ return true;
2461
+ }
2462
+ if (isValidInlineHtmlTag(source)) return true;
2463
+ return /\n/.test(source) && /^<[A-Za-z][A-Za-z0-9-]*(?:\s|>)/.test(source) && !/[A-Za-z0-9_.:-]![A-Za-z0-9_.:-]/.test(source);
2464
+ };
2465
+ var htmlBlockClosingPattern = (trimmed) => {
2466
+ if (/^<(script|pre|style|textarea)(?:\s|>|$)/i.test(trimmed)) {
2467
+ return new RegExp(`</${/^<([A-Za-z][A-Za-z0-9-]*)/.exec(trimmed)?.[1]}>`, "i");
2468
+ }
2469
+ if (/^<!--/.test(trimmed)) return /-->/;
2470
+ if (/^<\?/.test(trimmed)) return /\?>/;
2471
+ if (/^<![A-Z]/.test(trimmed)) return />/;
2472
+ if (/^<!\[CDATA\[/.test(trimmed)) return /\]\]>/;
2473
+ return null;
2474
+ };
2475
+ var readHtmlBlockUntil = (lines, startIndex, close) => {
2476
+ const html = [];
2477
+ let index = startIndex;
2478
+ while (index < lines.length) {
2479
+ html.push(lines[index]);
2480
+ if (close.test(lines[index])) break;
2481
+ index += 1;
2482
+ }
2483
+ return { value: html.join("\n"), endIndex: index };
2484
+ };
2485
+ var isBlankTerminatedHtmlBlockStart = (trimmed) => {
2486
+ if (isBlockTagHtmlBlockStart(trimmed)) return true;
2487
+ return isValidInlineHtmlTag(trimmed);
2488
+ };
2489
+ var isValidInlineHtmlTag = (source) => {
2490
+ return /^<[A-Za-z][A-Za-z0-9-]*(?:\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>\s*$/.test(source) || /^<\/[A-Za-z][A-Za-z0-9-]*\s*>\s*$/.test(source);
2491
+ };
2492
+ var isBlockTagHtmlBlockStart = (trimmed) => {
2493
+ if (!/^<\/?([A-Za-z][A-Za-z0-9-]*)(?:\s|\/?>|$)/.test(trimmed)) return false;
2494
+ const tag = /^<\/?([A-Za-z][A-Za-z0-9-]*)/.exec(trimmed)?.[1].toLowerCase();
2495
+ return tag !== void 0 && htmlBlockTags.has(tag);
2496
+ };
2497
+ var readHtmlBlockUntilBlank = (lines, startIndex) => {
2498
+ const html = [];
2499
+ let index = startIndex;
2500
+ while (index < lines.length && lines[index].trim()) {
2501
+ html.push(lines[index]);
2502
+ index += 1;
2503
+ }
2504
+ return { value: html.join("\n"), endIndex: index - 1 };
2505
+ };
2506
+
2507
+ // src/parse/list.ts
2508
+ var parseListMarker = (line) => {
2509
+ const expanded = line.includes(" ") ? expandListMarkerTabs(line) : line;
2510
+ const unordered = /^( {0,3})([-*+])([ \t]*)(.*)$/.exec(expanded);
2511
+ if (unordered && (unordered[3].length > 0 || unordered[4] === "")) {
2512
+ return {
2513
+ body: listMarkerBody(unordered[3], unordered[4]),
2514
+ contentIndent: listContentIndent(unordered[1].length, unordered[2].length, unordered[3].length),
2515
+ marker: unordered[2],
2516
+ ordered: false
2517
+ };
2518
+ }
2519
+ const ordered = /^( {0,3})(\d{1,9})([.)])([ \t]*)(.*)$/.exec(expanded);
2520
+ if (ordered && (ordered[4].length > 0 || ordered[5] === "")) {
2521
+ return {
2522
+ body: listMarkerBody(ordered[4], ordered[5]),
2523
+ contentIndent: listContentIndent(ordered[1].length, ordered[2].length + 1, ordered[4].length),
2524
+ marker: ordered[3],
2525
+ ordered: true,
2526
+ start: Number(ordered[2])
2527
+ };
2528
+ }
2529
+ return null;
2530
+ };
2531
+ var listMarkerBody = (padding, body) => {
2532
+ return padding.length > 4 ? `${padding.slice(1)}${body}` : body;
2533
+ };
2534
+ var expandListMarkerTabs = (line) => {
2535
+ let result = "";
2536
+ let cursor = 0;
2537
+ let inMarkerPadding = false;
2538
+ while (cursor < line.length) {
2539
+ const character = line[cursor];
2540
+ if (character === " " && (inMarkerPadding || /^ {0,3}(?:[-*+]|\d{1,9}[.)])$/.test(result))) {
2541
+ const column = result.length;
2542
+ result += " ".repeat(4 - column % 4);
2543
+ inMarkerPadding = true;
2544
+ cursor += 1;
2545
+ continue;
2546
+ }
2547
+ result += character;
2548
+ if (/^ {0,3}(?:[-*+]|\d{1,9}[.)])$/.test(result)) {
2549
+ inMarkerPadding = true;
2550
+ } else if (inMarkerPadding && character !== " ") {
2551
+ inMarkerPadding = false;
2552
+ }
2553
+ cursor += 1;
2554
+ }
2555
+ return result;
2556
+ };
2557
+ var isSameListMarker = (opening, current) => {
2558
+ return opening.ordered ? current.marker === opening.marker : current.marker === opening.marker;
2559
+ };
2560
+ var isParagraphInterruptingListMarker = (line) => {
2561
+ const marker = parseListMarker(line);
2562
+ return marker !== null && marker.body !== "" && (!marker.ordered || marker.start === 1);
2563
+ };
2564
+ var listContentIndent = (indent, markerLength, padding) => {
2565
+ return indent + markerLength + (padding > 0 && padding <= 4 ? padding : 1);
2566
+ };
2567
+
2568
+ // src/parse/table.ts
2569
+ var isTableStart = (lines, index) => {
2570
+ return Boolean(
2571
+ lines[index]?.includes("|") && lines[index + 1] && /^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(lines[index + 1])
2572
+ );
2573
+ };
2574
+ var readTable = (lines, startIndex, options, parseInline2) => {
2575
+ const headers = splitTableRow(lines[startIndex]);
2576
+ const align = splitTableRow(lines[startIndex + 1]).map((cell) => {
2577
+ const trimmed = cell.trim();
2578
+ if (trimmed.startsWith(":") && trimmed.endsWith(":")) return "center";
2579
+ if (trimmed.endsWith(":")) return "right";
2580
+ if (trimmed.startsWith(":")) return "left";
2581
+ return null;
2582
+ });
2583
+ const rows = [
2584
+ {
2585
+ type: "tableRow",
2586
+ children: headers.map((cell) => ({
2587
+ type: "tableCell",
2588
+ children: parseInline2(cell.trim(), options)
2589
+ }))
2590
+ }
2591
+ ];
2592
+ let index = startIndex + 2;
2593
+ while (index < lines.length && lines[index].includes("|") && lines[index].trim()) {
2594
+ rows.push({
2595
+ type: "tableRow",
2596
+ children: splitTableRow(lines[index]).map((cell) => ({
2597
+ type: "tableCell",
2598
+ children: parseInline2(cell.trim(), options)
2599
+ }))
2600
+ });
2601
+ index += 1;
2602
+ }
2603
+ return { table: { type: "table", align, children: rows }, endIndex: index - 1 };
2604
+ };
2605
+ var splitTableRow = (line) => {
2606
+ return line.trim().replace(/^\||\|$/g, "").split("|");
2607
+ };
2608
+
2609
+ // src/parse/blockquote.ts
2610
+ var canContinueBlockquoteLazily = (line, options, lines, index) => {
2611
+ return Boolean(
2612
+ line.trim() && !/^ {0,3}> ?/.test(line) && !/^ {0,3}(`{3,}|~{3,})/.test(line) && !isThematicBreak(line) && !parseListMarker(line) && !isTableStart(lines, index) && !(options.safe === false && isInterruptingHtmlBlockStart(line))
2613
+ );
2614
+ };
2615
+ var canStartLazyBlockquoteContinuation = (line, options, lines, index, isBlockStart2) => {
2616
+ const candidate = lazyContinuationCandidate(line);
2617
+ return Boolean(
2618
+ candidate.trim() && !/^ {0,3}(`{3,}|~{3,})/.test(candidate) && !/^ {4}/.test(candidate) && !isBlockStart2(candidate, options, lines, index)
2619
+ );
2620
+ };
2621
+ var lazyContinuationCandidate = (line) => {
2622
+ let candidate = line;
2623
+ while (true) {
2624
+ const quoteMarker = /^ {0,3}> ?(.*)$/.exec(candidate);
2625
+ if (quoteMarker) {
2626
+ candidate = quoteMarker[1];
2627
+ continue;
2628
+ }
2629
+ const marker = parseListMarker(candidate);
2630
+ if (marker && /^ {0,3}> ?/.test(marker.body)) {
2631
+ candidate = marker.body;
2632
+ continue;
2633
+ }
2634
+ return candidate;
2635
+ }
2636
+ };
2637
+
2638
+ // src/parse/common.ts
2639
+ var normalizeReference = (label) => {
2640
+ return label.trim().replace(/\s+/g, " ").replace(/[ẞß]/g, "ss").toLowerCase();
2641
+ };
2642
+ var normalizeReferenceLabelForLookup = (label) => {
2643
+ return normalizeReference(label.replace(/\\([\[\]])/g, "$1"));
2644
+ };
2645
+ var normalizeHref = (destination) => {
2646
+ try {
2647
+ return encodeURI(destination).replace(/%25([0-9A-Fa-f]{2})/g, "%$1");
2648
+ } catch {
2649
+ return destination;
2650
+ }
2651
+ };
2652
+ var decodeStringContent = (source) => {
2653
+ return source.replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, "$1").replace(
2654
+ /&([A-Za-z][A-Za-z0-9]+|#[0-9]+|#[xX][0-9A-Fa-f]+);/g,
2655
+ (_, entity) => decodeEntity(entity)
2656
+ );
2657
+ };
2658
+ var decodeEntity = (entity) => {
2659
+ if (/^#[xX]/.test(entity)) return decodeCodePoint(entity, Number.parseInt(entity.slice(2), 16));
2660
+ if (entity.startsWith("#")) return decodeCodePoint(entity, Number.parseInt(entity.slice(1), 10));
2661
+ const named = {
2662
+ amp: "&",
2663
+ lt: "<",
2664
+ gt: ">",
2665
+ quot: '"',
2666
+ apos: "'",
2667
+ nbsp: "\xA0",
2668
+ AElig: "\xC6",
2669
+ auml: "\xE4",
2670
+ ClockwiseContourIntegral: "\u2232",
2671
+ copy: "\xA9",
2672
+ Dcaron: "\u010E",
2673
+ DifferentialD: "\u2146",
2674
+ frac34: "\xBE",
2675
+ HilbertSpace: "\u210B",
2676
+ ngE: "\u2267\u0338",
2677
+ ouml: "\xF6"
2678
+ };
2679
+ return named[entity] ?? `&${entity};`;
2680
+ };
2681
+ var decodeCodePoint = (entity, codePoint) => {
2682
+ if (!Number.isFinite(codePoint) || codePoint === 0 || codePoint >= 55296 && codePoint <= 57343) {
2683
+ return "\uFFFD";
2684
+ }
2685
+ if (codePoint < 0 || codePoint > 1114111) {
2686
+ return `&${entity};`;
2687
+ }
2688
+ return String.fromCodePoint(codePoint);
2689
+ };
2690
+
2691
+ // src/parse/code.ts
2692
+ var openingFenceClosePattern = (line) => {
2693
+ const fence = /^( {0,3})(`{3,}|~{3,})[ \t]*(.*)$/.exec(line);
2694
+ if (!fence) return null;
2695
+ const marker = fence[2][0];
2696
+ return new RegExp(`^ {0,3}\\${marker}{${fence[2].length},}\\s*$`);
2697
+ };
2698
+ var normalizeCodeSpan = (code) => {
2699
+ const normalized = code.replace(/\r?\n/g, " ");
2700
+ return normalized.startsWith(" ") && normalized.endsWith(" ") && /[^ ]/.test(normalized) ? normalized.slice(1, -1) : normalized;
2701
+ };
2702
+ var parseFenceInfo = (info, marker) => {
2703
+ const meta = decodeStringContent(info.trim());
2704
+ if (marker === "`" && meta.includes("`")) return { meta: "", valid: false };
2705
+ if (!meta) return { meta: "", valid: true };
2706
+ const [lang] = meta.split(/\s+/, 1);
2707
+ return { lang, meta, valid: true };
2708
+ };
2709
+ var stripFenceIndent = (line, indent) => {
2710
+ let removed = 0;
2711
+ while (removed < indent && line.startsWith(" ")) {
2712
+ line = line.slice(1);
2713
+ removed += 1;
2714
+ }
2715
+ return line;
2716
+ };
2717
+ var parseCodeMeta = (meta) => {
2718
+ const filename = /filename=(?:"([^"]+)"|'([^']+)'|(\S+))/.exec(meta);
2719
+ const highlight = /\{([^}]+)\}/.exec(meta);
2720
+ return {
2721
+ filename: filename?.[1] ?? filename?.[2] ?? filename?.[3],
2722
+ highlightLines: highlight ? expandLineRanges(highlight[1]) : void 0
2723
+ };
2724
+ };
2725
+ var expandLineRanges = (source) => {
2726
+ const lines = /* @__PURE__ */ new Set();
2727
+ for (const part of source.split(",")) {
2728
+ const [start, end] = part.trim().split("-").map(Number);
2729
+ if (!Number.isFinite(start)) continue;
2730
+ if (Number.isFinite(end)) {
2731
+ for (let line = start; line <= end; line += 1) lines.add(line);
2732
+ } else {
2733
+ lines.add(start);
2734
+ }
2735
+ }
2736
+ return [...lines].sort((a, b2) => a - b2);
2737
+ };
2738
+
2739
+ // src/parse/custom.ts
2740
+ var readCustomBlock = (lines, startIndex) => {
2741
+ const firstDelimiter = findDelimiter(lines, startIndex + 1);
2742
+ if (firstDelimiter === -1) {
2743
+ return {
2744
+ props: {},
2745
+ content: lines.slice(startIndex + 1).join("\n"),
2746
+ endIndex: lines.length - 1
2747
+ };
2748
+ }
2749
+ const beforeDelimiter = lines.slice(startIndex + 1, firstDelimiter);
2750
+ if (beforeDelimiter.length > 0 && beforeDelimiter.every(isPropOrBlank)) {
2751
+ const closingDelimiter = findDelimiter(lines, firstDelimiter + 1);
2752
+ return {
2753
+ props: parseProps(beforeDelimiter),
2754
+ content: lines.slice(firstDelimiter + 1, closingDelimiter === -1 ? lines.length : closingDelimiter).join("\n"),
2755
+ endIndex: closingDelimiter === -1 ? lines.length - 1 : closingDelimiter
2756
+ };
2757
+ }
2758
+ return {
2759
+ props: {},
2760
+ content: beforeDelimiter.join("\n"),
2761
+ endIndex: firstDelimiter
2762
+ };
2763
+ };
2764
+ var findDelimiter = (lines, startIndex) => {
2765
+ for (let index = startIndex; index < lines.length; index += 1) {
2766
+ if (lines[index].trim() === "::") return index;
2767
+ }
2768
+ return -1;
2769
+ };
2770
+ var isPropOrBlank = (line) => {
2771
+ return !line.trim() || /^[A-Za-z0-9_-]+:\s*.*$/.test(line.trim());
2772
+ };
2773
+ var parseProps = (lines) => {
2774
+ const props = {};
2775
+ for (const line of lines) {
2776
+ const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line.trim());
2777
+ if (!match) continue;
2778
+ props[match[1]] = parsePrimitive(match[2]);
2779
+ }
2780
+ return props;
2781
+ };
2782
+ var parsePrimitive = (value) => {
2783
+ const trimmed = value.trim();
2784
+ if (trimmed === "true") return true;
2785
+ if (trimmed === "false") return false;
2786
+ if (trimmed === "null") return null;
2787
+ if (/^-?\d+(\.\d+)?$/.test(trimmed)) return Number(trimmed);
2788
+ return trimmed.replace(/^["']|["']$/g, "");
2789
+ };
2790
+ var splitWords = (source) => {
2791
+ return source.trim() ? source.trim().split(/\s+/) : [];
2792
+ };
2793
+
2794
+ // src/parse/autolink.ts
2795
+ var trimTrailingPunctuation = (source) => {
2796
+ return source.replace(/[),.;:!?]+$/g, "");
2797
+ };
2798
+ var getAutolinkOptions = (options) => {
2799
+ return typeof options === "object" ? options : { enabled: options !== false };
2800
+ };
2801
+ var isExternalHref = (href) => {
2802
+ return /^(?:https?:)?\/\//.test(href);
2803
+ };
2804
+
2805
+ // src/parse/emphasis.ts
2806
+ var resolveRemainingEmphasis = (nodes) => {
2807
+ const tokens = tokenizeEmphasisDelimiters(nodes);
2808
+ let changed = true;
2809
+ while (changed) {
2810
+ changed = false;
2811
+ for (let closeIndex = 0; closeIndex < tokens.length; closeIndex += 1) {
2812
+ const closer = tokens[closeIndex];
2813
+ if (closer.type !== "delimiter" || !closer.close || closer.length === 0) continue;
2814
+ for (let openIndex = closeIndex - 1; openIndex >= 0; openIndex -= 1) {
2815
+ const opener = tokens[openIndex];
2816
+ if (opener.type !== "delimiter" || !opener.open || opener.char !== closer.char || opener.length === 0) {
2817
+ continue;
2818
+ }
2819
+ if (isForbiddenDelimiterMatch(opener, closer)) continue;
2820
+ const size = opener.length >= 2 && closer.length >= 2 ? 2 : 1;
2821
+ const children = inlineTokensToNodes(tokens.slice(openIndex + 1, closeIndex));
2822
+ const wrapped = size === 2 ? { type: "strong", children: resolveRemainingEmphasis(children) } : { type: "emphasis", children: resolveRemainingEmphasis(children) };
2823
+ const replacement = [];
2824
+ if (opener.length > size) {
2825
+ replacement.push({ ...opener, length: opener.length - size });
2826
+ }
2827
+ replacement.push({ type: "node", node: wrapped });
2828
+ if (closer.length > size) {
2829
+ replacement.push({ ...closer, length: closer.length - size });
2830
+ }
2831
+ tokens.splice(openIndex, closeIndex - openIndex + 1, ...replacement);
2832
+ changed = true;
2833
+ closeIndex = -1;
2834
+ break;
2835
+ }
2836
+ }
2837
+ }
2838
+ return inlineTokensToNodes(tokens);
2839
+ };
2840
+ var tokenizeEmphasisDelimiters = (nodes) => {
2841
+ const tokens = [];
2842
+ for (let nodeIndex = 0; nodeIndex < nodes.length; nodeIndex += 1) {
2843
+ const node = nodes[nodeIndex];
2844
+ if (node.type !== "text") {
2845
+ tokens.push({ type: "node", node });
2846
+ continue;
2847
+ }
2848
+ if (node.escaped === true) {
2849
+ tokens.push({ type: "node", node });
2850
+ continue;
2851
+ }
2852
+ let cursor = 0;
2853
+ while (cursor < node.value.length) {
2854
+ const character = node.value[cursor];
2855
+ if (character !== "*" && character !== "_") {
2856
+ const nextDelimiter = nextEmphasisDelimiter(node.value, cursor + 1);
2857
+ tokens.push({
2858
+ type: "node",
2859
+ node: { type: "text", value: node.value.slice(cursor, nextDelimiter) }
2860
+ });
2861
+ cursor = nextDelimiter;
2862
+ continue;
2863
+ }
2864
+ const runStart = cursor;
2865
+ while (cursor < node.value.length && node.value[cursor] === character) cursor += 1;
2866
+ const runLength = cursor - runStart;
2867
+ const before = previousCharacter(tokens);
2868
+ const after = node.value[cursor] ?? nextInlineCharacter(nodes, nodeIndex + 1);
2869
+ const { open, close } = classifyDelimiterRun(character, before, after);
2870
+ tokens.push({
2871
+ type: "delimiter",
2872
+ char: character,
2873
+ close,
2874
+ length: runLength,
2875
+ open
2876
+ });
2877
+ }
2878
+ }
2879
+ return tokens;
2880
+ };
2881
+ var nextInlineCharacter = (nodes, startIndex) => {
2882
+ for (let index = startIndex; index < nodes.length; index += 1) {
2883
+ const character = firstInlineCharacter(nodes[index]);
2884
+ if (character) return character;
2885
+ }
2886
+ return "";
2887
+ };
2888
+ var firstInlineCharacter = (node) => {
2889
+ if (node.type === "text" && node.value) return node.value[0];
2890
+ if (node.type === "lineBreak") return "\n";
2891
+ if (node.type === "inlineCode" && node.code) return node.code[0];
2892
+ if (node.type === "image" && node.alt) return node.alt[0];
2893
+ if ("children" in node && node.children.length > 0) {
2894
+ for (const child of node.children) {
2895
+ const character = firstInlineCharacter(child);
2896
+ if (character) return character;
2897
+ }
2898
+ }
2899
+ return "";
2900
+ };
2901
+ var isForbiddenDelimiterMatch = (opener, closer) => {
2902
+ if (opener.char !== closer.char) return true;
2903
+ if (!(opener.close || closer.open)) return false;
2904
+ return (opener.length + closer.length) % 3 === 0 && opener.length % 3 !== 0 && closer.length % 3 !== 0;
2905
+ };
2906
+ var nextEmphasisDelimiter = (source, startIndex) => {
2907
+ let index = startIndex;
2908
+ while (index < source.length && source[index] !== "*" && source[index] !== "_") index += 1;
2909
+ return index;
2910
+ };
2911
+ var previousCharacter = (tokens) => {
2912
+ for (let index = tokens.length - 1; index >= 0; index -= 1) {
2913
+ const token = tokens[index];
2914
+ if (token.type === "delimiter" && token.length > 0) return token.char;
2915
+ if (token.type === "node") {
2916
+ const character = lastInlineCharacter(token.node);
2917
+ if (character) return character;
2918
+ }
2919
+ }
2920
+ return "";
2921
+ };
2922
+ var lastInlineCharacter = (node) => {
2923
+ if (node.type === "text" && node.value) return node.value[node.value.length - 1];
2924
+ if (node.type === "lineBreak") return "\n";
2925
+ if (node.type === "inlineCode" && node.code) return node.code[node.code.length - 1];
2926
+ if (node.type === "image" && node.alt) return node.alt[node.alt.length - 1];
2927
+ if ("children" in node && node.children.length > 0) {
2928
+ for (let index = node.children.length - 1; index >= 0; index -= 1) {
2929
+ const character = lastInlineCharacter(node.children[index]);
2930
+ if (character) return character;
2931
+ }
2932
+ }
2933
+ return "";
2934
+ };
2935
+ var classifyDelimiterRun = (char, before, after) => {
2936
+ const beforeWhitespace = before === "" || /\s/u.test(before);
2937
+ const afterWhitespace = after === "" || /\s/u.test(after);
2938
+ const beforePunctuation = isUnicodePunctuation(before);
2939
+ const afterPunctuation = isUnicodePunctuation(after);
2940
+ const leftFlanking = !afterWhitespace && (!afterPunctuation || beforeWhitespace || beforePunctuation);
2941
+ const rightFlanking = !beforeWhitespace && (!beforePunctuation || afterWhitespace || afterPunctuation);
2942
+ if (char === "_") {
2943
+ return {
2944
+ open: leftFlanking && (!rightFlanking || beforePunctuation),
2945
+ close: rightFlanking && (!leftFlanking || afterPunctuation)
2946
+ };
2947
+ }
2948
+ return { open: leftFlanking, close: rightFlanking };
2949
+ };
2950
+ var isUnicodePunctuation = (character) => {
2951
+ return character !== "" && /[\p{P}\p{S}]/u.test(character);
2952
+ };
2953
+ var inlineTokensToNodes = (tokens) => {
2954
+ const nodes = [];
2955
+ for (const token of tokens) {
2956
+ if (token.type === "delimiter") {
2957
+ appendTextNode(nodes, token.char.repeat(token.length));
2958
+ continue;
2959
+ }
2960
+ if (token.node.type === "text") {
2961
+ appendTextNode(nodes, token.node.value);
2962
+ } else {
2963
+ nodes.push(token.node);
2964
+ }
2965
+ }
2966
+ return nodes;
2967
+ };
2968
+ var appendTextNode = (nodes, value) => {
2969
+ if (!value) return;
2970
+ const previous = nodes[nodes.length - 1];
2971
+ if (previous?.type === "text") {
2972
+ previous.value += value;
2973
+ return;
2974
+ }
2975
+ nodes.push({ type: "text", value });
2976
+ };
2977
+
2978
+ // src/parse/inline-links.ts
2979
+ var nextInlineLabelOpener = (source, startIndex) => {
2980
+ for (let index = startIndex; index < source.length; index += 1) {
2981
+ if (source[index] === "\\") {
2982
+ index += 1;
2983
+ continue;
2984
+ }
2985
+ if (source[index] === "[") return index;
2986
+ if (source[index] === "!" && source[index + 1] === "[") return index;
2987
+ }
2988
+ return -1;
2989
+ };
2990
+ var findBalancedLabelEnd = (source, startIndex) => {
2991
+ let depth = 0;
2992
+ for (let index = startIndex; index < source.length; index += 1) {
2993
+ if (source[index] === "\\") {
2994
+ index += 1;
2995
+ continue;
2996
+ }
2997
+ if (source[index] === "`") {
2998
+ const ticks = /^`+/.exec(source.slice(index))?.[0] ?? "`";
2999
+ const close = source.indexOf(ticks, index + ticks.length);
3000
+ if (close !== -1) {
3001
+ index = close + ticks.length - 1;
3002
+ continue;
3003
+ }
3004
+ }
3005
+ if (source[index] === "<") {
3006
+ const close = source.indexOf(">", index + 1);
3007
+ if (close !== -1) {
3008
+ const token = source.slice(index, close + 1);
3009
+ if (isAutolinkToken(token) || isValidInlineHtmlToken(token)) {
3010
+ index = close;
3011
+ continue;
3012
+ }
3013
+ }
3014
+ }
3015
+ if (source[index] === "[") {
3016
+ depth += 1;
3017
+ continue;
3018
+ }
3019
+ if (source[index] === "]") {
3020
+ if (depth === 0) return index;
3021
+ depth -= 1;
3022
+ }
3023
+ }
3024
+ return -1;
3025
+ };
3026
+ var containsInlineLink = (label) => {
3027
+ return new RegExp("(?<!!)\\[[^\\]]+\\](?:\\(|\\[)").test(label);
3028
+ };
3029
+ var isAutolinkToken = (token) => {
3030
+ return /^<[A-Za-z][A-Za-z0-9+.-]{1,31}:[^<>\s]*>$/.test(token) || /^<[A-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?(?:\.[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?)*>$/i.test(token);
3031
+ };
3032
+ var readInlineReferenceDestination = (source, labelEnd, label, state) => {
3033
+ if (source[labelEnd + 1] !== "[") return null;
3034
+ const referenceEnd = findReferenceLabelEnd(source, labelEnd + 2);
3035
+ if (referenceEnd === -1) return null;
3036
+ const referenceLabel = source.slice(labelEnd + 2, referenceEnd);
3037
+ const reference = state.references.get(normalizeReferenceLabelForLookup(referenceLabel || label));
3038
+ if (!reference) return null;
3039
+ return {
3040
+ href: reference.href,
3041
+ title: reference.title,
3042
+ endIndex: referenceEnd
3043
+ };
3044
+ };
3045
+ var readUnresolvedInlineReferenceEnd = (source, labelEnd) => {
3046
+ if (source[labelEnd + 1] !== "[") return -1;
3047
+ return findReferenceLabelEnd(source, labelEnd + 2);
3048
+ };
3049
+ var canTailBecomeReferenceLink = (source, unresolvedReferenceEnd, referenceLabel, state) => {
3050
+ return readInlineReferenceDestination(source, unresolvedReferenceEnd, referenceLabel, state) !== null;
3051
+ };
3052
+ var findReferenceLabelEnd = (source, startIndex) => {
3053
+ for (let index = startIndex; index < source.length; index += 1) {
3054
+ if (source[index] === "\\") {
3055
+ index += 1;
3056
+ continue;
3057
+ }
3058
+ if (source[index] === "[") return -1;
3059
+ if (source[index] === "]") return index;
3060
+ }
3061
+ return -1;
3062
+ };
3063
+ var readInlineDestination = (source, openParenIndex) => {
3064
+ if (source[openParenIndex] !== "(") return null;
3065
+ let cursor = openParenIndex + 1;
3066
+ while (/[ \t\n]/.test(source[cursor] ?? "")) cursor += 1;
3067
+ let href = "";
3068
+ if (source[cursor] === "<") {
3069
+ const close = source.indexOf(">", cursor + 1);
3070
+ if (close === -1) return null;
3071
+ href = source.slice(cursor + 1, close);
3072
+ if (/[<>\\\n]/.test(href)) return null;
3073
+ cursor = close + 1;
3074
+ } else {
3075
+ let depth = 0;
3076
+ while (cursor < source.length) {
3077
+ const character = source[cursor];
3078
+ if (character === "\\" && source[cursor + 1]) {
3079
+ if (/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/.test(source[cursor + 1])) {
3080
+ href += source[cursor + 1];
3081
+ cursor += 2;
3082
+ } else {
3083
+ href += character;
3084
+ cursor += 1;
3085
+ }
3086
+ continue;
3087
+ }
3088
+ if (character === "(") {
3089
+ depth += 1;
3090
+ href += character;
3091
+ cursor += 1;
3092
+ continue;
3093
+ }
3094
+ if (character === ")") {
3095
+ if (depth === 0) break;
3096
+ depth -= 1;
3097
+ href += character;
3098
+ cursor += 1;
3099
+ continue;
3100
+ }
3101
+ if (/[ \t\n]/.test(character) && depth === 0) break;
3102
+ href += character;
3103
+ cursor += 1;
3104
+ }
3105
+ if (depth !== 0) return null;
3106
+ }
3107
+ let title;
3108
+ const beforeTitle = cursor;
3109
+ while (/[ \t\n]/.test(source[cursor] ?? "")) cursor += 1;
3110
+ if (cursor > beforeTitle && ['"', "'", "("].includes(source[cursor])) {
3111
+ const opener = source[cursor];
3112
+ const closer = opener === "(" ? ")" : opener;
3113
+ cursor += 1;
3114
+ let value = "";
3115
+ while (cursor < source.length) {
3116
+ if (source[cursor] === "\\" && source[cursor + 1]) {
3117
+ value += source[cursor + 1];
3118
+ cursor += 2;
3119
+ continue;
3120
+ }
3121
+ if (source[cursor] === closer) break;
3122
+ value += source[cursor];
3123
+ cursor += 1;
3124
+ }
3125
+ if (source[cursor] !== closer) return null;
3126
+ title = value;
3127
+ cursor += 1;
3128
+ while (/[ \t\n]/.test(source[cursor] ?? "")) cursor += 1;
3129
+ }
3130
+ if (source[cursor] !== ")") return null;
3131
+ return { href, title, endIndex: cursor };
3132
+ };
3133
+ var normalizeInlineDestination = (destination) => {
3134
+ return destination.startsWith("<") && destination.endsWith(">") ? destination.slice(1, -1) : destination;
3135
+ };
3136
+ var inlineTitleFromGroups = (groups, prefix) => {
3137
+ const title = groups[prefix] ?? groups[`${prefix}Single`] ?? groups[`${prefix}Paren`];
3138
+ return title === void 0 ? void 0 : decodeStringContent(title);
3139
+ };
3140
+
3141
+ // src/parse/inline-text.ts
3142
+ var stripInlineNodes = (nodes) => {
3143
+ return nodes.map((node) => {
3144
+ if (node.type === "text") return node.value;
3145
+ if (node.type === "lineBreak") return "\n";
3146
+ if (node.type === "inlineCode") return node.code;
3147
+ if (node.type === "image") return node.alt ?? "";
3148
+ if ("children" in node) return stripInlineNodes(node.children);
3149
+ return "";
3150
+ }).join("");
3151
+ };
3152
+ var trimTrailingSoftBreakSpace = (nodes) => {
3153
+ const previous = nodes[nodes.length - 1];
3154
+ if (previous?.type === "text" && new RegExp("(?<! ) $").test(previous.value)) {
3155
+ previous.value = previous.value.slice(0, -1);
3156
+ }
3157
+ };
3158
+
3159
+ // src/parse/inline.ts
3160
+ var parseInline = (source, options = { autolinks: true }) => parseInlineWithState(source, options, { references: /* @__PURE__ */ new Map() });
3161
+ var parseInlineWithState = (source, options = { autolinks: true }, state, extractNestedLinks = true) => {
3162
+ const autolinks = options.autolinks !== false && getAutolinkOptions(options.autolinks).enabled !== false;
3163
+ if (!hasInlineSyntax(source, autolinks)) {
3164
+ return source ? [{ type: "text", value: source }] : [];
3165
+ }
3166
+ if (extractNestedLinks && hasBalancedLinkCandidate(source)) {
3167
+ const scanned = scanBalancedInlineLinks(source, options, state);
3168
+ if (scanned) return resolveRemainingEmphasis(scanned);
3169
+ }
3170
+ const nodes = [];
3171
+ const safe = options.safe !== false;
3172
+ const pattern = new RegExp("(?<inlineHtml><!-->|<!--->|<!--[\\s\\S]*?-->|<\\?[\\s\\S]*?\\?>|<![A-Z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|<\\/?[A-Za-z][A-Za-z0-9-]*(?:\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s\"'=<>`]+))?)*\\s*\\/?>)|(?<hardSpaces> {2,}\\n)|(?<hardBackslash>\\\\\\n)|(?<softBreak>\\n)|(?<!`)(?<codeTicks>`+)(?!`)(?<codeValue>[\\s\\S]*?)(?<!`)\\k<codeTicks>(?!`)|\\\\(?<escaped>[!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_`{|}~])|&(?<entity>[A-Za-z][A-Za-z0-9]+|#[0-9]+|#[xX][0-9A-Fa-f]+);|!\\[(?<refImageAlt>[^\\]]*)\\]\\[(?<refImageLabel>[^\\]]*)\\]|\\[(?<refLinkText>[^\\]`<\\[]+)\\]\\[(?<refLinkLabel>[^\\]]*)\\]|!\\[(?<inlineImageAlt>[^\\]`<]*)\\]\\([ \\t\\n]*(?<inlineImageHref><[^<>\\n\\\\]*>|(?!<)(?:\\\\.|[^() \\t\\n`\\\\]|\\([^()\\n]*(?:\\([^()\\n]*\\)[^()\\n]*)*\\))*)(?:[ \\t\\n]+(?:\"(?<inlineImageTitle>(?:\\\\.|[^\"`])*)\"|'(?<inlineImageTitleSingle>[^']*)'|\\((?<inlineImageTitleParen>[^)]*)\\)))?[ \\t\\n]*\\)|\\[(?<inlineLinkText>[^\\]`<]*)\\]\\([ \\t\\n]*(?<inlineLinkHref><[^<>\\n\\\\]*>|(?!<)(?:\\\\.|[^() \\t\\n`\\\\]|\\([^()\\n]*(?:\\([^()\\n]*\\)[^()\\n]*)*\\))*)(?:[ \\t\\n]+(?:\"(?<inlineLinkTitle>(?:\\\\.|[^\"`])*)\"|'(?<inlineLinkTitleSingle>[^']*)'|\\((?<inlineLinkTitleParen>[^)]*)\\)))?[ \\t\\n]*\\)|<(?<angleUrl>[A-Za-z][A-Za-z0-9+.-]{1,31}:[^<>\\s]*)>|<(?<angleEmail>[A-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?(?:\\.[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?)*)>|!\\[(?<shortcutImageAlt>(?:\\\\\\]|[^\\]`<\\[])+)\\]|\\[(?<shortcutLinkText>(?:\\\\\\]|[^\\]`<\\[])+)\\]|~~(?<deleteValue>[^~`]+)~~|(?<bareUrl>https?:\\/\\/[^\\s<`]+)|(?<bareEmail>[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,})", "giu");
3173
+ let lastIndex = 0;
3174
+ let match;
3175
+ while (match = pattern.exec(source)) {
3176
+ if (match.index > lastIndex) {
3177
+ nodes.push({ type: "text", value: source.slice(lastIndex, match.index) });
3178
+ }
3179
+ const groups = match.groups ?? {};
3180
+ if (groups.inlineHtml !== void 0) {
3181
+ nodes.push(
3182
+ safe || !isValidInlineHtmlToken(groups.inlineHtml) ? { type: "text", value: groups.inlineHtml } : { type: "inlineHtml", value: groups.inlineHtml }
3183
+ );
3184
+ } else if (groups.hardSpaces !== void 0 || groups.hardBackslash !== void 0) {
3185
+ nodes.push({ type: "lineBreak", hard: true });
3186
+ } else if (groups.softBreak !== void 0) {
3187
+ trimTrailingSoftBreakSpace(nodes);
3188
+ nodes.push({ type: "lineBreak", value: " " });
3189
+ } else if (groups.codeValue !== void 0) {
3190
+ nodes.push({ type: "inlineCode", code: normalizeCodeSpan(groups.codeValue) });
3191
+ } else if (groups.escaped !== void 0) {
3192
+ nodes.push({ type: "text", value: groups.escaped, escaped: true });
3193
+ } else if (groups.entity !== void 0) {
3194
+ nodes.push({ type: "text", value: decodeEntity(groups.entity), escaped: true });
3195
+ } else if (groups.refImageAlt !== void 0) {
3196
+ const reference = state.references.get(normalizeReferenceLabelForLookup(groups.refImageLabel || groups.refImageAlt));
3197
+ if (reference) {
3198
+ nodes.push({
3199
+ type: "image",
3200
+ alt: stripInlineMarkdown(groups.refImageAlt, options),
3201
+ src: reference.href,
3202
+ title: reference.title
3203
+ });
3204
+ } else {
3205
+ nodes.push({ type: "text", value: decodeStringContent(match[0]) });
3206
+ }
3207
+ } else if (groups.refLinkText !== void 0) {
3208
+ const reference = state.references.get(normalizeReferenceLabelForLookup(groups.refLinkLabel || groups.refLinkText));
3209
+ if (reference) {
3210
+ nodes.push({
3211
+ type: "link",
3212
+ href: reference.href,
3213
+ title: reference.title,
3214
+ external: isExternalHref(reference.href),
3215
+ children: parseInlineWithState(groups.refLinkText, options, state)
3216
+ });
3217
+ } else {
3218
+ nodes.push({ type: "text", value: decodeStringContent(match[0]) });
3219
+ }
3220
+ } else if (groups.inlineImageAlt !== void 0) {
3221
+ nodes.push({
3222
+ type: "image",
3223
+ alt: stripInlineMarkdown(groups.inlineImageAlt, options),
3224
+ src: normalizeHref(decodeStringContent(normalizeInlineDestination(groups.inlineImageHref))),
3225
+ title: inlineTitleFromGroups(groups, "inlineImageTitle")
3226
+ });
3227
+ } else if (groups.inlineLinkText !== void 0) {
3228
+ const href = normalizeHref(decodeStringContent(normalizeInlineDestination(groups.inlineLinkHref)));
3229
+ nodes.push({
3230
+ type: "link",
3231
+ href,
3232
+ title: inlineTitleFromGroups(groups, "inlineLinkTitle"),
3233
+ external: isExternalHref(href),
3234
+ children: parseInlineWithState(groups.inlineLinkText, options, state)
3235
+ });
3236
+ } else if (groups.angleUrl !== void 0) {
3237
+ const href = normalizeHref(groups.angleUrl);
3238
+ nodes.push({
3239
+ type: "link",
3240
+ href,
3241
+ external: isExternalHref(href),
3242
+ children: [{ type: "text", value: groups.angleUrl }]
3243
+ });
3244
+ } else if (groups.angleEmail !== void 0) {
3245
+ nodes.push({
3246
+ type: "link",
3247
+ href: `mailto:${groups.angleEmail}`,
3248
+ external: false,
3249
+ children: [{ type: "text", value: groups.angleEmail }]
3250
+ });
3251
+ } else if (groups.shortcutImageAlt !== void 0) {
3252
+ const alt = decodeStringContent(groups.shortcutImageAlt);
3253
+ const reference = state.references.get(normalizeReference(alt));
3254
+ if (reference) {
3255
+ nodes.push({
3256
+ type: "image",
3257
+ alt: stripInlineMarkdown(alt, options),
3258
+ src: reference.href,
3259
+ title: reference.title
3260
+ });
3261
+ } else {
3262
+ nodes.push({ type: "text", value: decodeStringContent(match[0]) });
3263
+ }
3264
+ } else if (groups.shortcutLinkText !== void 0) {
3265
+ const text = decodeStringContent(groups.shortcutLinkText);
3266
+ const reference = state.references.get(normalizeReference(text));
3267
+ if (reference) {
3268
+ nodes.push({
3269
+ type: "link",
3270
+ href: reference.href,
3271
+ title: reference.title,
3272
+ external: isExternalHref(reference.href),
3273
+ children: parseInlineWithState(text, options, state)
3274
+ });
3275
+ } else {
3276
+ nodes.push({ type: "text", value: decodeStringContent(match[0]) });
3277
+ }
3278
+ } else if (groups.deleteValue !== void 0) {
3279
+ nodes.push({ type: "delete", children: parseInlineWithState(groups.deleteValue, options, state) });
3280
+ } else if (groups.strongStarValue !== void 0 || groups.strongUnderscoreValue !== void 0) {
3281
+ nodes.push({
3282
+ type: "strong",
3283
+ children: parseInlineWithState(groups.strongStarValue ?? groups.strongUnderscoreValue, options, state)
3284
+ });
3285
+ } else if (groups.emStarValue !== void 0 || groups.emUnderscoreValue !== void 0) {
3286
+ nodes.push({
3287
+ type: "emphasis",
3288
+ children: parseInlineWithState(groups.emStarValue ?? groups.emUnderscoreValue, options, state)
3289
+ });
3290
+ } else if (groups.bareUrl !== void 0 && autolinks) {
3291
+ const href = trimTrailingPunctuation(groups.bareUrl);
3292
+ nodes.push({
3293
+ type: "link",
3294
+ href,
3295
+ external: true,
3296
+ children: [{ type: "text", value: href }]
3297
+ });
3298
+ const trailing = groups.bareUrl.slice(href.length);
3299
+ if (trailing) nodes.push({ type: "text", value: trailing });
3300
+ } else if (groups.bareEmail !== void 0 && autolinks) {
3301
+ nodes.push({
3302
+ type: "link",
3303
+ href: `mailto:${groups.bareEmail}`,
3304
+ external: false,
3305
+ children: [{ type: "text", value: groups.bareEmail }]
3306
+ });
3307
+ } else {
3308
+ nodes.push({ type: "text", value: match[0] });
3309
+ }
3310
+ lastIndex = pattern.lastIndex;
3311
+ }
3312
+ if (lastIndex < source.length) nodes.push({ type: "text", value: source.slice(lastIndex) });
3313
+ return resolveRemainingEmphasis(nodes);
3314
+ };
3315
+ var hasInlineSyntax = (source, autolinks) => {
3316
+ if (!source) return false;
3317
+ if (/[\\`<&\n\[\]*_~]/.test(source)) return true;
3318
+ return autolinks && (source.includes("http://") || source.includes("https://") || source.includes("@"));
3319
+ };
3320
+ var hasBalancedLinkCandidate = (source) => {
3321
+ return source.includes("[");
3322
+ };
3323
+ var scanBalancedInlineLinks = (source, options, state) => {
3324
+ const nodes = [];
3325
+ let cursor = 0;
3326
+ let searchStart = 0;
3327
+ let found = false;
3328
+ while (cursor < source.length) {
3329
+ const opener = nextInlineLabelOpener(source, searchStart);
3330
+ if (opener === -1) break;
3331
+ const image = source[opener] === "!";
3332
+ const labelStart = opener + (image ? 2 : 1);
3333
+ const labelEnd = findBalancedLabelEnd(source, labelStart);
3334
+ if (labelEnd === -1) {
3335
+ searchStart = opener + 1;
3336
+ continue;
3337
+ }
3338
+ const label = source.slice(labelStart, labelEnd);
3339
+ if (!image && containsInlineLink(label)) {
3340
+ searchStart = opener + 1;
3341
+ continue;
3342
+ }
3343
+ const inlineDestination = source[labelEnd + 1] === "(" ? readInlineDestination(source, labelEnd + 1) : null;
3344
+ const referenceDestination = inlineDestination ? null : readInlineReferenceDestination(source, labelEnd, label, state);
3345
+ const href = inlineDestination?.href ?? referenceDestination?.href;
3346
+ if (href === void 0) {
3347
+ const unresolvedReferenceEnd = inlineDestination ? -1 : readUnresolvedInlineReferenceEnd(source, labelEnd);
3348
+ if (!image && unresolvedReferenceEnd !== -1) {
3349
+ const referenceLabel = source.slice(labelEnd + 2, unresolvedReferenceEnd);
3350
+ if (opener > cursor) {
3351
+ nodes.push(...parseInlineWithState(source.slice(cursor, opener), options, state, false));
3352
+ }
3353
+ nodes.push({ type: "text", value: "[" });
3354
+ nodes.push(...parseInlineWithState(label, options, state, false));
3355
+ nodes.push({ type: "text", value: "]" });
3356
+ if (!canTailBecomeReferenceLink(source, unresolvedReferenceEnd, referenceLabel, state)) {
3357
+ nodes.push({ type: "text", value: "[" });
3358
+ nodes.push(...parseInlineWithState(referenceLabel, options, state, false));
3359
+ nodes.push({ type: "text", value: "]" });
3360
+ cursor = unresolvedReferenceEnd + 1;
3361
+ } else {
3362
+ cursor = labelEnd + 1;
3363
+ }
3364
+ found = true;
3365
+ searchStart = unresolvedReferenceEnd + 1;
3366
+ continue;
3367
+ }
3368
+ searchStart = opener + 1;
3369
+ continue;
3370
+ }
3371
+ const title = inlineDestination?.title ?? referenceDestination?.title;
3372
+ const endIndex = inlineDestination?.endIndex ?? referenceDestination?.endIndex;
3373
+ if (endIndex === void 0) {
3374
+ searchStart = opener + 1;
3375
+ continue;
3376
+ }
3377
+ if (opener > cursor) {
3378
+ nodes.push(...parseInlineWithState(source.slice(cursor, opener), options, state, false));
3379
+ }
3380
+ if (image) {
3381
+ nodes.push({
3382
+ type: "image",
3383
+ alt: stripInlineMarkdown(label, options),
3384
+ src: normalizeHref(decodeStringContent(href)),
3385
+ title: title === void 0 ? void 0 : decodeStringContent(title)
3386
+ });
3387
+ } else {
3388
+ const normalizedHref = normalizeHref(decodeStringContent(href));
3389
+ nodes.push({
3390
+ type: "link",
3391
+ href: normalizedHref,
3392
+ title: title === void 0 ? void 0 : decodeStringContent(title),
3393
+ external: isExternalHref(normalizedHref),
3394
+ children: parseInlineWithState(label, options, state, false)
3395
+ });
3396
+ }
3397
+ found = true;
3398
+ cursor = endIndex + 1;
3399
+ searchStart = cursor;
3400
+ }
3401
+ if (!found) return null;
3402
+ if (cursor < source.length) {
3403
+ nodes.push(...parseInlineWithState(source.slice(cursor), options, state, false));
3404
+ }
3405
+ return nodes;
3406
+ };
3407
+ var stripInlineMarkdown = (source, options = { autolinks: true }) => stripInlineNodes(parseInline(source, options));
3408
+
3409
+ // src/parse/lines.ts
3410
+ var expandLeadingTabsToLines = (markdown) => {
3411
+ return markdown.split("\n").map((line) => expandLeadingTabsInLine(line));
3412
+ };
3413
+ var expandLeadingTabsInLine = (line) => {
3414
+ let result = "";
3415
+ let column = 0;
3416
+ let cursor = 0;
3417
+ while (cursor < line.length) {
3418
+ const character = line[cursor];
3419
+ if (character === " ") {
3420
+ const spaces = 4 - column % 4;
3421
+ result += " ".repeat(spaces);
3422
+ column += spaces;
3423
+ cursor += 1;
3424
+ continue;
3425
+ }
3426
+ result += character;
3427
+ column += 1;
3428
+ cursor += 1;
3429
+ if (character !== " ") break;
3430
+ }
3431
+ return result + line.slice(cursor);
3432
+ };
3433
+ var expandLeadingTabsFromColumn = (line, startColumn) => {
3434
+ let result = "";
3435
+ let column = startColumn;
3436
+ let inLeadingIndent = true;
3437
+ for (const character of line) {
3438
+ if (character === " " && inLeadingIndent) {
3439
+ const spaces = 4 - column % 4;
3440
+ result += " ".repeat(spaces);
3441
+ column += spaces;
3442
+ continue;
3443
+ }
3444
+ result += character;
3445
+ column += 1;
3446
+ if (character !== " ") inLeadingIndent = false;
3447
+ }
3448
+ return result;
3449
+ };
3450
+ var nextNonBlankLine = (lines, startIndex) => {
3451
+ for (let index = startIndex; index < lines.length; index += 1) {
3452
+ if (lines[index].trim()) return index;
3453
+ }
3454
+ return -1;
3455
+ };
3456
+ var countLeadingSpaces = (line) => {
3457
+ let count = 0;
3458
+ while (line[count] === " ") {
3459
+ count += 1;
3460
+ }
3461
+ return count;
3462
+ };
3463
+ var trimTrailingBlankLines = (lines) => {
3464
+ const result = [...lines];
3465
+ while (result.length > 0 && !result[result.length - 1].trim()) result.pop();
3466
+ return result;
3467
+ };
3468
+
3469
+ // src/parse/list-items.ts
3470
+ var parseListItemBlocks = (firstLine, lines, index, openingListMarker, contentIndent, options, seenSlugs, state, parseBlocks2, isBlockStart2) => {
3471
+ const itemLines = [firstLine];
3472
+ let cursor = index + 1;
3473
+ let loose = false;
3474
+ let sawBlank = false;
3475
+ let openFence = openingFenceClosePattern(firstLine);
3476
+ while (cursor < lines.length) {
3477
+ const marker = parseListMarker(lines[cursor]);
3478
+ if (marker && marker.ordered === openingListMarker.ordered && isSameListMarker(openingListMarker, marker) && countLeadingSpaces(lines[cursor]) < contentIndent) {
3479
+ break;
3480
+ }
3481
+ if (!lines[cursor].trim()) {
3482
+ if (openFence) {
3483
+ itemLines.push("");
3484
+ cursor += 1;
3485
+ continue;
3486
+ }
3487
+ const nextContentIndex = nextNonBlankLine(lines, cursor + 1);
3488
+ if (nextContentIndex === -1) break;
3489
+ const nextMarker = parseListMarker(lines[nextContentIndex]);
3490
+ if (nextMarker && nextMarker.ordered === openingListMarker.ordered && isSameListMarker(openingListMarker, nextMarker) && countLeadingSpaces(lines[nextContentIndex]) < contentIndent) {
3491
+ itemLines.push("");
3492
+ loose = true;
3493
+ sawBlank = true;
3494
+ cursor += 1;
3495
+ continue;
3496
+ }
3497
+ if (cursor === index + 1 && firstLine === "") break;
3498
+ const nextIndent = countLeadingSpaces(lines[nextContentIndex]);
3499
+ if (nextIndent < contentIndent) break;
3500
+ itemLines.push("");
3501
+ loose = !hasNestedListMarkerBeforeBlank(itemLines, nextIndent - contentIndent);
3502
+ sawBlank = true;
3503
+ cursor += 1;
3504
+ continue;
3505
+ }
3506
+ if (countLeadingSpaces(lines[cursor]) >= contentIndent) {
3507
+ const itemLine = lines[cursor].slice(contentIndent);
3508
+ itemLines.push(itemLine);
3509
+ openFence = updateOpenFence(openFence, itemLine);
3510
+ cursor += 1;
3511
+ continue;
3512
+ }
3513
+ if (!sawBlank && !isBlockStart2(lines[cursor], options, lines, cursor)) {
3514
+ itemLines.push(lines[cursor]);
3515
+ openFence = updateOpenFence(openFence, lines[cursor]);
3516
+ cursor += 1;
3517
+ continue;
3518
+ }
3519
+ break;
3520
+ }
3521
+ while (itemLines.length > 0 && itemLines[itemLines.length - 1] === "") {
3522
+ itemLines.pop();
3523
+ }
3524
+ return {
3525
+ children: parseBlocks2(itemLines, options, seenSlugs, state),
3526
+ endIndex: cursor - 1,
3527
+ loose
3528
+ };
3529
+ };
3530
+ var hasNestedListMarkerBeforeBlank = (itemLines, relativeNextIndent) => {
3531
+ return itemLines.some((itemLine) => {
3532
+ const marker = parseListMarker(itemLine);
3533
+ return marker !== null && countLeadingSpaces(itemLine) < relativeNextIndent;
3534
+ });
3535
+ };
3536
+ var updateOpenFence = (openFence, line) => {
3537
+ if (openFence) return openFence.test(line) ? null : openFence;
3538
+ return openingFenceClosePattern(line);
3539
+ };
3540
+
3541
+ // src/parse/references.ts
3542
+ var extractReferenceDefinitions = (lines) => {
3543
+ const references = /* @__PURE__ */ new Map();
3544
+ const contentLines = [];
3545
+ let previousWasReference = false;
3546
+ for (let index = 0; index < lines.length; index += 1) {
3547
+ const htmlBlock = readHtmlBlock(lines, index);
3548
+ if (htmlBlock) {
3549
+ contentLines.push(...lines.slice(index, htmlBlock.endIndex + 1));
3550
+ index = htmlBlock.endIndex;
3551
+ previousWasReference = false;
3552
+ continue;
3553
+ }
3554
+ const fence = /^ {0,3}(`{3,}|~{3,})/.exec(lines[index]);
3555
+ if (fence) {
3556
+ const marker = fence[1][0];
3557
+ const close = new RegExp(`^ {0,3}\\${marker}{${fence[1].length},}\\s*$`);
3558
+ contentLines.push(lines[index]);
3559
+ index += 1;
3560
+ while (index < lines.length) {
3561
+ contentLines.push(lines[index]);
3562
+ if (close.test(lines[index])) break;
3563
+ index += 1;
3564
+ }
3565
+ previousWasReference = false;
3566
+ continue;
3567
+ }
3568
+ if (/^ {4}/.test(lines[index])) {
3569
+ contentLines.push(lines[index]);
3570
+ previousWasReference = false;
3571
+ continue;
3572
+ }
3573
+ const blockquoteReference = /^>\s?(.*)$/.exec(lines[index]);
3574
+ if (blockquoteReference) {
3575
+ const parsed2 = readReferenceDefinition([blockquoteReference[1]], 0);
3576
+ if (parsed2) {
3577
+ const label2 = normalizeReference(parsed2.label);
3578
+ if (!references.has(label2)) references.set(label2, parsed2.reference);
3579
+ contentLines.push(">");
3580
+ previousWasReference = true;
3581
+ continue;
3582
+ }
3583
+ }
3584
+ const canStartReference = index === 0 || !lines[index - 1].trim() || previousWasReference || isReferenceStartAfterBlock(lines[index - 1]);
3585
+ if (!canStartReference) {
3586
+ contentLines.push(lines[index]);
3587
+ previousWasReference = false;
3588
+ continue;
3589
+ }
3590
+ const parsed = readReferenceDefinition(lines, index);
3591
+ if (!parsed) {
3592
+ contentLines.push(lines[index]);
3593
+ previousWasReference = false;
3594
+ continue;
3595
+ }
3596
+ const label = normalizeReference(parsed.label);
3597
+ if (!references.has(label)) references.set(label, parsed.reference);
3598
+ index = parsed.endIndex;
3599
+ previousWasReference = true;
3600
+ }
3601
+ return { contentLines, references };
3602
+ };
3603
+ var readReferenceDefinition = (lines, startIndex) => {
3604
+ const multiline = readMultilineReferenceDefinition(lines, startIndex);
3605
+ if (multiline) return multiline;
3606
+ const opener = /^ {0,3}\[((?:\\[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]|[^\[\]\n]){1,999})\]:[ \t]*(.*)$/.exec(lines[startIndex]);
3607
+ if (!opener) return null;
3608
+ const parts = [opener[2]];
3609
+ let cursor = startIndex + 1;
3610
+ while (cursor < lines.length && lines[cursor].trim() && canContinueReferenceDefinition(parts, lines[cursor])) {
3611
+ parts.push(lines[cursor]);
3612
+ cursor += 1;
3613
+ }
3614
+ const reference = parseReferenceDefinitionContent(parts.join("\n"));
3615
+ if (!reference) return null;
3616
+ return {
3617
+ label: decodeStringContent(opener[1]),
3618
+ reference,
3619
+ endIndex: cursor - 1
3620
+ };
3621
+ };
3622
+ var readMultilineReferenceDefinition = (lines, startIndex) => {
3623
+ const opener = /^ {0,3}\[((?:\\[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]|[^\[\]\n])*)$/.exec(lines[startIndex]);
3624
+ if (!opener) return null;
3625
+ const labelParts = [opener[1]];
3626
+ for (let cursor = startIndex + 1; cursor < lines.length; cursor += 1) {
3627
+ const closer = /^ {0,3}((?:\\[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]|[^\[\]\n])*)\]:[ \t]*(.*)$/.exec(lines[cursor]);
3628
+ if (!closer) {
3629
+ if (!lines[cursor].trim()) return null;
3630
+ labelParts.push(lines[cursor]);
3631
+ continue;
3632
+ }
3633
+ const label = labelParts.concat(closer[1]).join("\n");
3634
+ if (!label.trim() || label.length > 999) return null;
3635
+ const parts = [closer[2]];
3636
+ let contentCursor = cursor + 1;
3637
+ while (contentCursor < lines.length && lines[contentCursor].trim() && canContinueReferenceDefinition(parts, lines[contentCursor])) {
3638
+ parts.push(lines[contentCursor]);
3639
+ contentCursor += 1;
3640
+ }
3641
+ const reference = parseReferenceDefinitionContent(parts.join("\n"));
3642
+ if (!reference) return null;
3643
+ return {
3644
+ label: decodeStringContent(label),
3645
+ reference,
3646
+ endIndex: contentCursor - 1
3647
+ };
3648
+ }
3649
+ return null;
3650
+ };
3651
+ var canContinueReferenceDefinition = (parts, line) => {
3652
+ const collected = parts.join("\n").trim();
3653
+ if (!collected) return true;
3654
+ if (/^ {1,}/.test(line)) return true;
3655
+ if (hasOpenReferenceTitle(parts)) return true;
3656
+ const parsed = parseReferenceDefinitionContent(collected);
3657
+ return parsed?.title === void 0 && /^["'(]/.test(line.trim()) && parseReferenceDefinitionContent(`${collected}
3658
+ ${line}`) !== null;
3659
+ };
3660
+ var isReferenceStartAfterBlock = (line) => {
3661
+ return /^ {0,3}(#{1,6})(?:\s|$)/.test(line) || isThematicBreak2(line);
3662
+ };
3663
+ var parseReferenceDefinitionContent = (content) => {
3664
+ let rest = content.trim();
3665
+ if (!rest) return null;
3666
+ let destination = "";
3667
+ if (rest.startsWith("<")) {
3668
+ const closeIndex = rest.indexOf(">");
3669
+ if (closeIndex === -1) return null;
3670
+ destination = rest.slice(1, closeIndex);
3671
+ rest = rest.slice(closeIndex + 1);
3672
+ if (rest && !/^\s/.test(rest)) return null;
3673
+ } else {
3674
+ const destinationMatch = /^\S+/.exec(rest);
3675
+ if (!destinationMatch) return null;
3676
+ destination = destinationMatch[0];
3677
+ rest = rest.slice(destination.length);
3678
+ }
3679
+ const title = parseReferenceTitle(rest);
3680
+ if (title === null) return null;
3681
+ return {
3682
+ href: normalizeHref(decodeStringContent(destination)),
3683
+ title: title === void 0 ? void 0 : decodeStringContent(title)
3684
+ };
3685
+ };
3686
+ var parseReferenceTitle = (source) => {
3687
+ const rest = source.trim();
3688
+ if (!rest) return void 0;
3689
+ const opener = rest[0];
3690
+ const closer = opener === "(" ? ")" : opener;
3691
+ if (!['"', "'", "("].includes(opener)) return null;
3692
+ if (!rest.endsWith(closer)) return null;
3693
+ return rest.slice(1, -1);
3694
+ };
3695
+ var hasOpenReferenceTitle = (parts) => {
3696
+ const content = parts.join("\n").trim();
3697
+ const destination = /^<?\S+>?/.exec(content);
3698
+ if (!destination) return false;
3699
+ const rest = content.slice(destination[0].length).trimStart();
3700
+ if (!rest) return false;
3701
+ const opener = rest[0];
3702
+ const closer = opener === "(" ? ")" : opener;
3703
+ return ['"', "'", "("].includes(opener) && (rest.length === 1 || !rest.endsWith(closer));
3704
+ };
3705
+ var isThematicBreak2 = (line) => {
3706
+ return /^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/.test(line);
3707
+ };
3708
+
3709
+ // src/parse.ts
3710
+ function parseMarkdown(markdown, options) {
3711
+ const normalizedMarkdown = markdown.includes("\r") ? markdown.replace(/\r\n?/g, "\n") : markdown;
3712
+ const lines = normalizedMarkdown.includes(" ") ? expandLeadingTabsToLines(normalizedMarkdown) : normalizedMarkdown.split("\n");
3713
+ const { contentLines, references } = normalizedMarkdown.includes("[") && hasPossibleReferenceDefinitionStart(normalizedMarkdown) ? extractReferenceDefinitions(lines) : { contentLines: lines, references: /* @__PURE__ */ new Map() };
3714
+ const children = parseBlocks(contentLines, options, /* @__PURE__ */ new Map(), { references });
3715
+ return { type: "root", children };
3716
+ }
3717
+ var hasPossibleReferenceDefinitionStart = (markdown) => {
3718
+ return /(^|\n)(?: {0,3}> ?| {0,3})\[/.test(markdown);
3719
+ };
3720
+ function parseBlocks(lines, options, seenSlugs, state) {
3721
+ const children = [];
3722
+ for (let index = 0; index < lines.length; index += 1) {
3723
+ const line = lines[index];
3724
+ if (!line.trim()) continue;
3725
+ if (!options.safe) {
3726
+ const htmlBlock = readHtmlBlock(lines, index);
3727
+ if (htmlBlock) {
3728
+ children.push({ type: "html", value: htmlBlock.value });
3729
+ index = htmlBlock.endIndex;
3730
+ continue;
3731
+ }
3732
+ }
3733
+ const customBlock = /^::([A-Za-z][\w-]*)(?:\s+(.*))?$/.exec(line.trim());
3734
+ if (customBlock) {
3735
+ const parsed = readCustomBlock(lines, index);
3736
+ const args = splitWords(customBlock[2] ?? "");
3737
+ const definition = options.blocks[customBlock[1]];
3738
+ const value = definition?.parse?.({
3739
+ name: customBlock[1],
3740
+ args,
3741
+ props: parsed.props,
3742
+ content: parsed.content
3743
+ });
3744
+ children.push({
3745
+ type: "customBlock",
3746
+ name: customBlock[1],
3747
+ args,
3748
+ props: parsed.props,
3749
+ value,
3750
+ children: parseBlocks(parsed.content.split("\n"), options, seenSlugs, state)
3751
+ });
3752
+ index = parsed.endIndex;
3753
+ continue;
3754
+ }
3755
+ const fence = /^( {0,3})(`{3,}|~{3,})[ \t]*(.*)$/.exec(line);
3756
+ if (fence) {
3757
+ const code = [];
3758
+ const indent = fence[1].length;
3759
+ const markerRun = fence[2];
3760
+ const marker = markerRun[0];
3761
+ const close = new RegExp(`^ {0,3}\\${marker}{${markerRun.length},}\\s*$`);
3762
+ const info = parseFenceInfo(fence[3] ?? "", marker);
3763
+ if (!info.valid) {
3764
+ } else {
3765
+ index += 1;
3766
+ while (index < lines.length && !close.test(lines[index])) {
3767
+ code.push(stripFenceIndent(lines[index], indent));
3768
+ index += 1;
3769
+ }
3770
+ if (index >= lines.length && code[code.length - 1] === "") code.pop();
3771
+ const metadata = parseCodeMeta(info.meta);
3772
+ children.push({
3773
+ type: "code",
3774
+ code: code.length > 0 ? `${code.join("\n")}
3775
+ ` : "",
3776
+ lang: info.lang,
3777
+ meta: info.meta || void 0,
3778
+ filename: metadata.filename,
3779
+ highlightLines: metadata.highlightLines
3780
+ });
3781
+ continue;
3782
+ }
3783
+ }
3784
+ if (/^ {4}/.test(line)) {
3785
+ const code = [];
3786
+ while (index < lines.length && (/^ {4}/.test(lines[index]) || !lines[index].trim())) {
3787
+ code.push(lines[index].replace(/^ {0,4}/, ""));
3788
+ index += 1;
3789
+ }
3790
+ index -= 1;
3791
+ const trimmedCode = trimTrailingBlankLines(code);
3792
+ children.push({ type: "code", code: trimmedCode.length > 0 ? `${trimmedCode.join("\n")}
3793
+ ` : "" });
3794
+ continue;
3795
+ }
3796
+ if (isThematicBreak(line)) {
3797
+ children.push({ type: "thematicBreak" });
3798
+ continue;
3799
+ }
3800
+ const heading = /^ {0,3}(#{1,6})(?:\s+(.*?))?\s*$/.exec(line);
3801
+ if (heading) {
3802
+ const source = trimClosingHeadingHashes(heading[2] ?? "");
3803
+ const inlineChildren = parseInlineWithState(source, options, state);
3804
+ const text = stripInlineNodes(inlineChildren);
3805
+ const node = {
3806
+ type: "heading",
3807
+ depth: heading[1].length,
3808
+ text,
3809
+ children: inlineChildren
3810
+ };
3811
+ if (options.anchors && text) node.id = uniqueSlug(slugify(text, options.slugStyle), seenSlugs);
3812
+ children.push(node);
3813
+ continue;
3814
+ }
3815
+ const setext = lines[index + 1] && isSetextUnderline(lines[index + 1]);
3816
+ if (setext && line.trim() && !isBlockStart(line, options, lines, index)) {
3817
+ const source = line.trim();
3818
+ const inlineChildren = parseInlineWithState(source, options, state);
3819
+ const text = stripInlineNodes(inlineChildren);
3820
+ const node = {
3821
+ type: "heading",
3822
+ depth: setext[1][0] === "=" ? 1 : 2,
3823
+ text,
3824
+ children: inlineChildren
3825
+ };
3826
+ if (options.anchors && text) node.id = uniqueSlug(slugify(text, options.slugStyle), seenSlugs);
3827
+ children.push(node);
3828
+ index += 1;
3829
+ continue;
3830
+ }
3831
+ if (isTableStart(lines, index)) {
3832
+ const parsed = readTable(lines, index, options, parseInline);
3833
+ children.push(parsed.table);
3834
+ index = parsed.endIndex;
3835
+ continue;
3836
+ }
3837
+ if (/^ {0,3}> ?/.test(line)) {
3838
+ const quoteLines = [];
3839
+ let allowLazyContinuation = false;
3840
+ while (index < lines.length) {
3841
+ const quoteMarker = /^( {0,3}> ?)(.*)$/.exec(lines[index]);
3842
+ if (quoteMarker) {
3843
+ const markerColumn = quoteMarker[1].endsWith(" ") ? quoteMarker[1].length : quoteMarker[1].length + 1;
3844
+ const quoteLine = expandLeadingTabsFromColumn(quoteMarker[2], markerColumn);
3845
+ quoteLines.push(quoteLine);
3846
+ allowLazyContinuation = canStartLazyBlockquoteContinuation(
3847
+ quoteLine,
3848
+ options,
3849
+ quoteLines,
3850
+ quoteLines.length - 1,
3851
+ isBlockStart
3852
+ );
3853
+ index += 1;
3854
+ continue;
3855
+ }
3856
+ if (allowLazyContinuation && canContinueBlockquoteLazily(lines[index], options, lines, index)) {
3857
+ quoteLines.push(isSetextUnderline(lines[index]) ? `\\${lines[index]}` : lines[index]);
3858
+ allowLazyContinuation = true;
3859
+ index += 1;
3860
+ continue;
3861
+ }
3862
+ break;
3863
+ }
3864
+ if (quoteLines[quoteLines.length - 1] === "") {
3865
+ quoteLines.pop();
3866
+ }
3867
+ if (index > 0) {
3868
+ index -= 1;
3869
+ } else {
3870
+ index += 1;
3871
+ }
3872
+ children.push({
3873
+ type: "blockquote",
3874
+ children: parseBlocks(quoteLines, options, seenSlugs, state)
3875
+ });
3876
+ continue;
3877
+ }
3878
+ const openingListMarker = parseListMarker(line);
3879
+ if (openingListMarker) {
3880
+ const items = [];
3881
+ const ordered = openingListMarker.ordered;
3882
+ const start = openingListMarker.start;
3883
+ let tight = true;
3884
+ while (index < lines.length) {
3885
+ if (items.length > 0 && isThematicBreak(lines[index])) break;
3886
+ const marker = parseListMarker(lines[index]);
3887
+ if (!marker || marker.ordered !== ordered || !isSameListMarker(openingListMarker, marker)) {
3888
+ break;
3889
+ }
3890
+ const body = marker.body;
3891
+ const checked = /^\[[ xX]\]\s+/.test(body) ? /^\[[xX]\]\s+/.test(body) : void 0;
3892
+ const cleanBody = body.replace(/^\[[ xX]\]\s+/, "");
3893
+ const parsedItem = parseListItemBlocks(
3894
+ cleanBody,
3895
+ lines,
3896
+ index,
3897
+ openingListMarker,
3898
+ marker.contentIndent,
3899
+ options,
3900
+ seenSlugs,
3901
+ state,
3902
+ parseBlocks,
3903
+ isBlockStart
3904
+ );
3905
+ if (parsedItem.loose) tight = false;
3906
+ items.push({
3907
+ type: "listItem",
3908
+ checked,
3909
+ children: parsedItem.children
3910
+ });
3911
+ index = parsedItem.endIndex + 1;
3912
+ }
3913
+ index -= 1;
3914
+ children.push({ type: "list", ordered, start, tight, children: items });
3915
+ continue;
3916
+ }
3917
+ const paragraph = [normalizeParagraphLine(line)];
3918
+ while (index + 1 < lines.length && canContinueParagraph(lines[index + 1], lines, index + 1, options)) {
3919
+ index += 1;
3920
+ paragraph.push(normalizeParagraphLine(lines[index]));
3921
+ }
3922
+ const paragraphSetext = lines[index + 1] && isSetextUnderline(lines[index + 1]);
3923
+ if (paragraphSetext) {
3924
+ const source = normalizeParagraphSource(paragraph);
3925
+ const inlineChildren = parseInlineWithState(source, options, state);
3926
+ const text = stripInlineNodes(inlineChildren);
3927
+ const node = {
3928
+ type: "heading",
3929
+ depth: paragraphSetext[1][0] === "=" ? 1 : 2,
3930
+ text,
3931
+ children: inlineChildren
3932
+ };
3933
+ if (options.anchors && text) node.id = uniqueSlug(slugify(text, options.slugStyle), seenSlugs);
3934
+ children.push(node);
3935
+ index += 1;
3936
+ continue;
3937
+ }
3938
+ children.push({
3939
+ type: "paragraph",
3940
+ children: parseInlineWithState(normalizeParagraphSource(paragraph), options, state)
3941
+ });
3942
+ }
3943
+ return children;
3944
+ }
3945
+ function canContinueParagraph(line, lines, index, options) {
3946
+ if (!line.trim()) return false;
3947
+ if (!hasParagraphInterruptCandidate(line, options)) return true;
3948
+ return Boolean(
3949
+ !isSetextUnderline(line) && !isThematicBreak(line) && !/^(#{1,6})\s+/.test(line) && !/^ {0,3}(`{3,}|~{3,})/.test(line) && !/^::[A-Za-z][\w-]*/.test(line.trim()) && !isParagraphInterruptingListMarker(line) && !/^ {0,3}> ?/.test(line) && !(options.safe === false && isInterruptingHtmlBlockStart(line)) && !isTableStart(lines, index)
3950
+ );
3951
+ }
3952
+ function hasParagraphInterruptCandidate(line, options) {
3953
+ const trimmedStart = line.trimStart();
3954
+ const first = trimmedStart[0];
3955
+ if (line.includes("|")) return true;
3956
+ if (options.safe === false && first === "<") return true;
3957
+ return first !== void 0 && "#`~:->*+=0123456789".includes(first);
3958
+ }
3959
+ function isBlockStart(line, options, lines, index) {
3960
+ return Boolean(
3961
+ /^ {0,3}(#{1,6})(?:\s|$)/.test(line) || /^ {0,3}(`{3,}|~{3,})/.test(line) || isThematicBreak(line) || /^ {0,3}> ?/.test(line) || parseListMarker(line) || isTableStart(lines, index) || !options.safe && isRawHtmlBlockLine(line)
3962
+ );
3963
+ }
3964
+
3965
+ // src/render.ts
3966
+ function renderHtml(ast, elements, blocks = {}, options = {}) {
3967
+ if (isEmptyObject(elements) && isEmptyObject(blocks) && options.unwrapStandaloneImages !== true) {
3968
+ return ast.children.map(renderBlockFast).join("\n");
3969
+ }
3970
+ return ast.children.map((node) => renderBlock(node, elements, blocks, options)).join("\n");
3971
+ }
3972
+ function isEmptyObject(value) {
3973
+ for (const _key in value) return false;
3974
+ return true;
3975
+ }
3976
+ function renderBlockFast(node) {
3977
+ if (node.type === "heading") {
3978
+ return wrap(`h${node.depth}`, renderInlineFast(node.children), { id: node.id });
3979
+ }
3980
+ if (node.type === "paragraph") return wrap("p", renderInlineFast(node.children));
3981
+ if (node.type === "code") {
3982
+ const code = wrap("code", escapeHtml(node.code), {
3983
+ class: node.lang ? `language-${node.lang}` : void 0,
3984
+ "data-filename": node.filename,
3985
+ "data-highlight-lines": node.highlightLines?.join(",")
3986
+ });
3987
+ return wrap("pre", code);
3988
+ }
3989
+ if (node.type === "list") {
3990
+ const tag = node.ordered ? "ol" : "ul";
3991
+ const items = node.children.map(
3992
+ (item) => wrap(
3993
+ "li",
3994
+ renderListItemChildrenFast(item.children, node.tight === true),
3995
+ { "data-checked": item.checked }
3996
+ )
3997
+ ).join("\n");
3998
+ return wrap(tag, `
3999
+ ${items}
4000
+ `, { start: node.start !== void 0 && node.start !== 1 ? node.start : void 0 });
4001
+ }
4002
+ if (node.type === "blockquote") {
4003
+ const body = node.children.length > 0 ? `
4004
+ ${node.children.map(renderBlockFast).join("\n")}
4005
+ ` : "\n";
4006
+ return wrap("blockquote", body);
4007
+ }
4008
+ if (node.type === "table") {
4009
+ const [header, ...rows] = node.children;
4010
+ const head = header ? wrap(
4011
+ "thead",
4012
+ wrap(
4013
+ "tr",
4014
+ header.children.map((cell, index) => wrap("th", renderInlineFast(cell.children), tableCellAttrs(node.align?.[index]))).join("")
4015
+ )
4016
+ ) : "";
4017
+ const body = wrap(
4018
+ "tbody",
4019
+ rows.map(
4020
+ (row) => wrap(
4021
+ "tr",
4022
+ row.children.map((cell, index) => wrap("td", renderInlineFast(cell.children), tableCellAttrs(node.align?.[index]))).join("")
4023
+ )
4024
+ ).join("")
4025
+ );
4026
+ return wrap("table", head + body);
4027
+ }
4028
+ if (node.type === "thematicBreak") return "<hr />";
4029
+ if (node.type === "html") return node.value;
4030
+ if (node.type === "customBlock") {
4031
+ return wrap(
4032
+ "div",
4033
+ (node.children ?? []).map(renderBlockFast).join("\n"),
4034
+ { "data-nizel-block": node.name }
4035
+ );
4036
+ }
4037
+ return "";
4038
+ }
4039
+ function renderBlock(node, elements, blocks, options) {
4040
+ if (node.type === "heading") {
4041
+ const tag = `h${node.depth}`;
4042
+ return wrap(resolveTag(tag, node, elements), renderInline(node.children, elements), {
4043
+ id: node.id,
4044
+ ...attrsFor(tag, node, elements)
4045
+ });
4046
+ }
4047
+ if (node.type === "paragraph") {
4048
+ if (options.unwrapStandaloneImages && isStandaloneImageParagraph(node.children)) {
4049
+ return renderInline(node.children, elements);
4050
+ }
4051
+ return wrap(resolveTag("p", node, elements), renderInline(node.children, elements), attrsFor("p", node, elements));
4052
+ }
4053
+ if (node.type === "code") {
4054
+ const renderer = blocks.code?.formats?.html;
4055
+ if (renderer) {
4056
+ return renderer(node, {
4057
+ render(nodes) {
4058
+ return Array.isArray(nodes) && nodes[0] && isInline2(nodes[0]) ? renderInline(nodes, elements) : nodes.map((child) => renderBlock(child, elements, blocks, options)).join("\n");
4059
+ },
4060
+ escape: escapeHtml
4061
+ });
4062
+ }
4063
+ const code = wrap(resolveTag("code", node, elements), escapeHtml(node.code), {
4064
+ class: node.lang ? `language-${node.lang}` : void 0,
4065
+ "data-filename": node.filename,
4066
+ "data-highlight-lines": node.highlightLines?.join(",")
4067
+ });
4068
+ return wrap(resolveTag("pre", node, elements), code, attrsFor("pre", node, elements));
4069
+ }
4070
+ if (node.type === "list") {
4071
+ const tag = node.ordered ? "ol" : "ul";
4072
+ const items = node.children.map(
4073
+ (item) => wrap(
4074
+ resolveTag("li", item, elements),
4075
+ renderListItemChildren(item.children, node.tight === true, elements, blocks, options),
4076
+ {
4077
+ "data-checked": item.checked,
4078
+ ...attrsFor("li", item, elements)
4079
+ }
4080
+ )
4081
+ ).join("\n");
4082
+ return wrap(
4083
+ resolveTag(tag, node, elements),
4084
+ `
4085
+ ${items}
4086
+ `,
4087
+ {
4088
+ start: node.start !== void 0 && node.start !== 1 ? node.start : void 0,
4089
+ ...attrsFor(tag, node, elements)
4090
+ }
4091
+ );
4092
+ }
4093
+ if (node.type === "blockquote") {
4094
+ return wrap(
4095
+ resolveTag("blockquote", node, elements),
4096
+ node.children.length > 0 ? `
4097
+ ${node.children.map((child) => renderBlock(child, elements, blocks, options)).join("\n")}
4098
+ ` : "\n",
4099
+ attrsFor("blockquote", node, elements)
4100
+ );
4101
+ }
4102
+ if (node.type === "table") {
4103
+ const [header, ...rows] = node.children;
4104
+ const head = header ? wrap(
4105
+ resolveTag("thead", header, elements),
4106
+ wrap(
4107
+ resolveTag("tr", header, elements),
4108
+ header.children.map(
4109
+ (cell, index) => wrap(resolveTag("th", cell, elements), renderInline(cell.children, elements), tableCellAttrs(node.align?.[index]))
4110
+ ).join("")
4111
+ )
4112
+ ) : "";
4113
+ const body = wrap(
4114
+ resolveTag("tbody", node, elements),
4115
+ rows.map(
4116
+ (row) => wrap(
4117
+ resolveTag("tr", row, elements),
4118
+ row.children.map(
4119
+ (cell, index) => wrap(resolveTag("td", cell, elements), renderInline(cell.children, elements), tableCellAttrs(node.align?.[index]))
4120
+ ).join("")
4121
+ )
4122
+ ).join("")
4123
+ );
4124
+ return wrap(resolveTag("table", node, elements), head + body, attrsFor("table", node, elements));
4125
+ }
4126
+ if (node.type === "thematicBreak") return `<hr${serializeAttrs(attrsFor("hr", node, elements))} />`;
4127
+ if (node.type === "html") return node.value;
4128
+ if (node.type === "customBlock") {
4129
+ const renderer = blocks[node.name]?.formats?.html;
4130
+ if (renderer) {
4131
+ return renderer(node, {
4132
+ render(nodes) {
4133
+ return Array.isArray(nodes) && nodes[0] && isInline2(nodes[0]) ? renderInline(nodes, elements) : nodes.map((child) => renderBlock(child, elements, blocks, options)).join("\n");
4134
+ },
4135
+ escape: escapeHtml
4136
+ });
4137
+ }
4138
+ return wrap(
4139
+ resolveTag("div", node, elements),
4140
+ (node.children ?? []).map((child) => renderBlock(child, elements, blocks, options)).join("\n"),
4141
+ {
4142
+ "data-nizel-block": node.name,
4143
+ ...attrsFor(node.name, node, elements)
4144
+ }
4145
+ );
4146
+ }
4147
+ return "";
4148
+ }
4149
+ function isStandaloneImageParagraph(nodes) {
4150
+ return nodes.length === 1 && nodes[0].type === "image";
4151
+ }
4152
+ function renderListItemChildren(children, tight, elements, blocks, options) {
4153
+ if (children.length === 0) return "";
4154
+ if (!tight) {
4155
+ return `
4156
+ ${children.map((child) => renderBlock(child, elements, blocks, options)).join("\n")}
4157
+ `;
4158
+ }
4159
+ const hasBlockChild = children.some((child) => child.type !== "paragraph");
4160
+ const body = children.map((child) => {
4161
+ if (child.type === "paragraph") return renderInline(child.children, elements);
4162
+ return renderBlock(child, elements, blocks, options);
4163
+ }).join("\n");
4164
+ if (!hasBlockChild) return body;
4165
+ if (children[children.length - 1]?.type === "paragraph") return `
4166
+ ${body}`;
4167
+ return children[0]?.type === "paragraph" ? `${body}
4168
+ ` : `
4169
+ ${body}
4170
+ `;
4171
+ }
4172
+ function renderListItemChildrenFast(children, tight) {
4173
+ if (children.length === 0) return "";
4174
+ if (!tight) {
4175
+ return `
4176
+ ${children.map(renderBlockFast).join("\n")}
4177
+ `;
4178
+ }
4179
+ const hasBlockChild = children.some((child) => child.type !== "paragraph");
4180
+ const body = children.map((child) => {
4181
+ if (child.type === "paragraph") return renderInlineFast(child.children);
4182
+ return renderBlockFast(child);
4183
+ }).join("\n");
4184
+ if (!hasBlockChild) return body;
4185
+ if (children[children.length - 1]?.type === "paragraph") return `
4186
+ ${body}`;
4187
+ return children[0]?.type === "paragraph" ? `${body}
4188
+ ` : `
4189
+ ${body}
4190
+ `;
4191
+ }
4192
+ function renderInline(nodes, elements) {
4193
+ if (nodes.length === 0) return "";
4194
+ if (nodes.length === 1) return renderInlineNode(nodes[0], elements);
4195
+ return nodes.map((node) => renderInlineNode(node, elements)).join("");
4196
+ }
4197
+ function renderInlineNode(node, elements) {
4198
+ if (node.type === "text") return escapeHtml(node.value);
4199
+ if (node.type === "inlineHtml") return node.value;
4200
+ if (node.type === "lineBreak") {
4201
+ if (!node.hard) return "\n";
4202
+ const brAttrs = attrsFor("br", node, elements);
4203
+ return `<br${serializeAttrs(brAttrs)} />
4204
+ `;
4205
+ }
4206
+ if (node.type === "inlineCode") {
4207
+ return wrap(resolveTag("code", node, elements), escapeHtml(node.code), attrsFor("code", node, elements));
4208
+ }
4209
+ if (node.type === "strong") {
4210
+ return wrap(resolveTag("strong", node, elements), renderInline(node.children, elements), attrsFor("strong", node, elements));
4211
+ }
4212
+ if (node.type === "emphasis") {
4213
+ return wrap(resolveTag("em", node, elements), renderInline(node.children, elements), attrsFor("em", node, elements));
4214
+ }
4215
+ if (node.type === "delete") {
4216
+ return wrap(resolveTag("del", node, elements), renderInline(node.children, elements), attrsFor("del", node, elements));
4217
+ }
4218
+ if (node.type === "image") {
4219
+ return `<img${serializeAttrs({
4220
+ src: node.src,
4221
+ alt: node.alt ?? "",
4222
+ title: node.title,
4223
+ ...attrsFor("img", node, elements)
4224
+ })} />`;
4225
+ }
4226
+ if (node.type === "link") {
4227
+ const href = node.href?.toLowerCase().trim().startsWith("javascript:") ? void 0 : node.href;
4228
+ return wrap(resolveTag("a", node, elements), renderInline(node.children, elements), {
4229
+ href,
4230
+ title: node.title,
4231
+ ...attrsFor("a", node, elements)
4232
+ });
4233
+ }
4234
+ return "";
4235
+ }
4236
+ function renderInlineFast(nodes) {
4237
+ if (nodes.length === 0) return "";
4238
+ if (nodes.length === 1) return renderInlineNodeFast(nodes[0]);
4239
+ return nodes.map(renderInlineNodeFast).join("");
4240
+ }
4241
+ function renderInlineNodeFast(node) {
4242
+ if (node.type === "text") return escapeHtml(node.value);
4243
+ if (node.type === "inlineHtml") return node.value;
4244
+ if (node.type === "lineBreak") return node.hard ? "<br />\n" : "\n";
4245
+ if (node.type === "inlineCode") return wrap("code", escapeHtml(node.code));
4246
+ if (node.type === "strong") return wrap("strong", renderInlineFast(node.children));
4247
+ if (node.type === "emphasis") return wrap("em", renderInlineFast(node.children));
4248
+ if (node.type === "delete") return wrap("del", renderInlineFast(node.children));
4249
+ if (node.type === "image") {
4250
+ return `<img${serializeAttrs({
4251
+ src: node.src,
4252
+ alt: node.alt ?? "",
4253
+ title: node.title
4254
+ })} />`;
4255
+ }
4256
+ if (node.type === "link") {
4257
+ const href = node.href?.toLowerCase().trim().startsWith("javascript:") ? void 0 : node.href;
4258
+ return wrap("a", renderInlineFast(node.children), {
4259
+ href,
4260
+ title: node.title
4261
+ });
4262
+ }
4263
+ return "";
4264
+ }
4265
+ function resolveTag(defaultTag, node, elements) {
4266
+ const rule = elements[defaultTag];
4267
+ if (!rule) return defaultTag;
4268
+ const descriptor = typeof rule === "function" ? rule(node) : rule;
4269
+ return descriptor?.tag ?? defaultTag;
4270
+ }
4271
+ function attrsFor(tag, node, elements) {
4272
+ const rule = elements[tag];
4273
+ if (!rule) return {};
4274
+ const descriptor = typeof rule === "function" ? rule(node) : rule;
4275
+ if (!descriptor) return {};
4276
+ const { tag: _t, class: _c, attr, attrs, ...rest } = descriptor;
4277
+ return { class: _c, ...attr ?? attrs, ...rest };
4278
+ }
4279
+ function tableCellAttrs(align) {
4280
+ return { align: align ?? void 0 };
4281
+ }
4282
+ function wrap(tag, content, attrs = {}) {
4283
+ return `<${tag}${serializeAttrs(attrs)}>${content}</${tag}>`;
4284
+ }
4285
+ function serializeAttrs(attrs) {
4286
+ let serialized = "";
4287
+ for (const key in attrs) {
4288
+ const value = attrs[key];
4289
+ if (value === void 0 || value === false) continue;
4290
+ if (isEventAttribute(key)) continue;
4291
+ serialized += value === true ? ` ${key}` : ` ${key}="${escapeHtml(value)}"`;
4292
+ }
4293
+ return serialized;
4294
+ }
4295
+ function isEventAttribute(key) {
4296
+ return key.length > 2 && key[0].toLowerCase() === "o" && key[1].toLowerCase() === "n" && /^on[a-z]+$/i.test(key);
4297
+ }
4298
+ function isInline2(node) {
4299
+ return [
4300
+ "text",
4301
+ "emphasis",
4302
+ "strong",
4303
+ "delete",
4304
+ "lineBreak",
4305
+ "inlineCode",
4306
+ "link",
4307
+ "image",
4308
+ "inlineHtml"
4309
+ ].includes(node.type);
4310
+ }
4311
+
4312
+ // src/template.ts
4313
+ var renderTemplate = (markdown, data, options) => {
4314
+ const filters = options.filters ?? {};
4315
+ const missing = options.missing ?? "keep";
4316
+ const rawEnabled = options.raw ?? false;
4317
+ return markdown.replace(
4318
+ /\{\{\{\s*([^}]+)\s*\}\}\}|\{\{\s*([^}]+)\s*\}\}/g,
4319
+ (match, rawExpression, escapedExpression) => {
4320
+ const isRaw = rawExpression !== void 0;
4321
+ if (isRaw && !rawEnabled) return match;
4322
+ const expression = (rawExpression ?? escapedExpression).trim();
4323
+ const value = evaluateExpression(expression, data, filters);
4324
+ if (value === void 0) {
4325
+ if (missing === "error") {
4326
+ throw new Error(`Missing template value: ${expression}`);
4327
+ }
4328
+ return missing === "empty" ? "" : match;
4329
+ }
4330
+ const text = textFromUnknown(value);
4331
+ return isRaw ? text : escapeHtml(text);
4332
+ }
4333
+ );
4334
+ };
4335
+ var evaluateExpression = (expression, data, filters) => {
4336
+ const [path, ...filterParts] = expression.split("|").map((part) => part.trim());
4337
+ let value = getPath(data, path);
4338
+ for (const part of filterParts) {
4339
+ const { name, args } = parseFilter(part);
4340
+ const filter = filters[name];
4341
+ if (!filter) continue;
4342
+ value = filter(textFromUnknown(value), ...args);
4343
+ }
4344
+ return value;
4345
+ };
4346
+ var parseFilter = (source) => {
4347
+ const call = /^([A-Za-z0-9_-]+)\((.*)\)$/.exec(source);
4348
+ if (!call) return { name: source, args: [] };
4349
+ return {
4350
+ name: call[1],
4351
+ args: splitArgs(call[2]).map((arg) => {
4352
+ const trimmed = arg.trim();
4353
+ if (/^['"].*['"]$/.test(trimmed)) return trimmed.slice(1, -1);
4354
+ if (/^-?\d+(\.\d+)?$/.test(trimmed)) return Number(trimmed);
4355
+ return trimmed;
4356
+ })
4357
+ };
4358
+ };
4359
+ var splitArgs = (source) => {
4360
+ if (!source.trim()) return [];
4361
+ const args = [];
4362
+ let current = "";
4363
+ let quote;
4364
+ for (const char of source) {
4365
+ if ((char === '"' || char === "'") && !quote) {
4366
+ quote = char;
4367
+ } else if (char === quote) {
4368
+ quote = void 0;
4369
+ }
4370
+ if (char === "," && !quote) {
4371
+ args.push(current);
4372
+ current = "";
4373
+ continue;
4374
+ }
4375
+ current += char;
4376
+ }
4377
+ args.push(current);
4378
+ return args;
4379
+ };
4380
+
4381
+ // src/use-nizel.ts
4382
+ function createNizel(options = {}) {
4383
+ const presetOptions = options.preset ? resolvePreset(options.preset) : {};
4384
+ const effectiveOptions = { ...presetOptions, ...options, preset: void 0 };
4385
+ const baseResolved = resolveOptions(effectiveOptions, {});
4386
+ async function process(markdown, runtimeOptions = {}) {
4387
+ const { ast, meta, resolved } = prepareMarkdown(markdown, runtimeOptions);
4388
+ const collected = collect(ast);
4389
+ const finalHtml = renderPreparedHtml(ast, resolved);
4390
+ const output = resolved.output ?? "html";
4391
+ const result = output === "text" ? collected.text : output === "ast" ? ast : finalHtml;
4392
+ return {
4393
+ result,
4394
+ html: finalHtml,
4395
+ text: collected.text,
4396
+ ast,
4397
+ meta,
4398
+ frontmatter: meta,
4399
+ title: stringMeta(meta.title) ?? collected.headings[0]?.text,
4400
+ description: stringMeta(meta.description),
4401
+ excerpt: collected.excerpt,
4402
+ toc: resolved.toc === false ? [] : collected.headings,
4403
+ headings: collected.headings,
4404
+ links: collected.links,
4405
+ images: collected.images,
4406
+ readingTime: collected.readingTime
4407
+ };
4408
+ }
4409
+ const nizel = process;
4410
+ nizel.html = async (markdown, runtimeOptions) => {
4411
+ const { ast, resolved } = prepareMarkdown(markdown, runtimeOptions);
4412
+ return renderPreparedHtml(ast, resolved);
4413
+ };
4414
+ nizel.text = async (markdown, runtimeOptions) => {
4415
+ const { ast } = prepareMarkdown(markdown, runtimeOptions);
4416
+ return collect(ast).text;
4417
+ };
4418
+ nizel.ast = async (markdown, runtimeOptions) => {
4419
+ return prepareMarkdown(markdown, runtimeOptions).ast;
4420
+ };
4421
+ nizel.meta = async (markdown, runtimeOptions) => {
4422
+ return prepareMeta(markdown, runtimeOptions).meta;
4423
+ };
4424
+ nizel.preset = (name) => createNizel(resolvePreset(name));
4425
+ nizel.parse = async (markdown, runtimeOptions) => {
4426
+ const resolved = resolveRuntime(runtimeOptions);
4427
+ const extracted = resolved.frontmatter === false ? { markdown, frontmatter: {} } : extractFrontmatter(markdown);
4428
+ let preparedMarkdown = extracted.markdown;
4429
+ for (const plugin of resolved.plugins ?? []) {
4430
+ const next = plugin.hooks?.beforeParse?.(preparedMarkdown, resolved);
4431
+ if (next !== void 0) preparedMarkdown = next;
4432
+ }
4433
+ return parseMarkdown(preparedMarkdown, {
4434
+ anchors: resolved.anchors !== false,
4435
+ autolinks: resolved.autolinks,
4436
+ blocks: resolved.blocks ?? {},
4437
+ safe: resolved.safe !== false,
4438
+ slugStyle: resolved.slugStyle
4439
+ });
4440
+ };
4441
+ nizel.render = (ast, runtimeOptions) => {
4442
+ const resolved = resolveRuntime(runtimeOptions);
4443
+ return renderHtml(ast, withAutolinkElements(resolved.elements ?? {}, resolved.autolinks), resolved.blocks ?? {}, {
4444
+ unwrapStandaloneImages: resolved.unwrapStandaloneImages === true
4445
+ });
4446
+ };
4447
+ return nizel;
4448
+ function prepareMarkdown(markdown, runtimeOptions = {}) {
4449
+ const preparedMeta = prepareMeta(markdown, runtimeOptions);
4450
+ let preparedMarkdown = preparedMeta.markdown;
4451
+ for (const plugin of preparedMeta.resolved.plugins ?? []) {
4452
+ const nextMarkdown = plugin.hooks?.beforeParse?.(preparedMarkdown, preparedMeta.resolved);
4453
+ if (nextMarkdown !== void 0) {
4454
+ preparedMarkdown = nextMarkdown;
4455
+ }
4456
+ }
4457
+ let ast = parseMarkdown(preparedMarkdown, {
4458
+ anchors: preparedMeta.resolved.anchors !== false,
4459
+ autolinks: preparedMeta.resolved.autolinks,
4460
+ blocks: preparedMeta.resolved.blocks ?? {},
4461
+ safe: preparedMeta.resolved.safe !== false,
4462
+ slugStyle: preparedMeta.resolved.slugStyle
4463
+ });
4464
+ for (const plugin of preparedMeta.resolved.plugins ?? []) {
4465
+ const afterResult = plugin.hooks?.afterParse?.(ast, preparedMeta.resolved);
4466
+ if (afterResult) ast = afterResult;
4467
+ }
4468
+ for (const transform of preparedMeta.resolved.transforms ?? []) {
4469
+ const transformResult = transform(ast);
4470
+ if (transformResult) ast = transformResult;
4471
+ }
4472
+ return {
4473
+ ast,
4474
+ meta: preparedMeta.meta,
4475
+ resolved: preparedMeta.resolved
4476
+ };
4477
+ }
4478
+ function prepareMeta(markdown, runtimeOptions = {}) {
4479
+ const resolved = resolvePreparedRuntime(runtimeOptions);
4480
+ const extracted = resolved.frontmatter === false ? { markdown, frontmatter: {} } : extractFrontmatter(markdown);
4481
+ let meta = {
4482
+ ...extracted.frontmatter,
4483
+ ...resolved.meta
4484
+ };
4485
+ let data = {
4486
+ ...resolved.data ?? {},
4487
+ meta,
4488
+ frontmatter: extracted.frontmatter
4489
+ };
4490
+ if (resolved.template !== false) {
4491
+ meta = renderObjectTemplates(meta, data, resolved.template);
4492
+ data = {
4493
+ ...resolved.data ?? {},
4494
+ meta,
4495
+ frontmatter: meta
4496
+ };
4497
+ }
4498
+ const templated = resolved.template === false || !hasTemplateSyntax(extracted.markdown) ? extracted.markdown : renderTemplate(
4499
+ extracted.markdown,
4500
+ data,
4501
+ resolved.template
4502
+ );
4503
+ return {
4504
+ markdown: templated,
4505
+ meta,
4506
+ resolved
4507
+ };
4508
+ }
4509
+ function resolveRuntime(runtimeOptions) {
4510
+ return hasRuntimeOptions(runtimeOptions) ? resolveOptions(effectiveOptions, runtimeOptions) : baseResolved;
4511
+ }
4512
+ function resolvePreparedRuntime(runtimeOptions) {
4513
+ const resolved = resolveRuntime(runtimeOptions);
4514
+ return {
4515
+ ...resolved,
4516
+ data: { ...resolved.variables ?? {}, ...resolved.data ?? {} }
4517
+ };
4518
+ }
4519
+ }
4520
+ function renderPreparedHtml(ast, resolved) {
4521
+ const html = renderHtml(
4522
+ ast,
4523
+ withAutolinkElements(resolved.elements ?? {}, resolved.autolinks),
4524
+ resolved.blocks ?? {},
4525
+ {
4526
+ unwrapStandaloneImages: resolved.unwrapStandaloneImages === true
4527
+ }
4528
+ );
4529
+ let finalHtml = html;
4530
+ for (const plugin of resolved.plugins ?? []) {
4531
+ const modified = plugin.hooks?.afterRender?.(finalHtml, resolved);
4532
+ if (modified !== void 0) finalHtml = modified;
4533
+ }
4534
+ return finalHtml;
4535
+ }
4536
+ function renderObjectTemplates(object, data, options) {
4537
+ return Object.fromEntries(
4538
+ Object.entries(object).map(([key, value]) => [
4539
+ key,
4540
+ typeof value === "string" && hasTemplateSyntax(value) ? renderTemplate(value, data, options) : value
4541
+ ])
4542
+ );
4543
+ }
4544
+ function hasTemplateSyntax(value) {
4545
+ return value.includes("{{");
4546
+ }
4547
+ function hasRuntimeOptions(runtimeOptions) {
4548
+ return Boolean(runtimeOptions && Object.keys(runtimeOptions).length > 0);
4549
+ }
4550
+ var useNizel = createNizel;
4551
+ useNizel.preset = (name) => createNizel(resolvePreset(name));
4552
+ function stringMeta(value) {
4553
+ return typeof value === "string" ? value : void 0;
4554
+ }
4555
+ function resolvePreset(name) {
4556
+ if (name === "minimal") {
4557
+ return { frontmatter: false, template: false, toc: false, anchors: false, autolinks: false };
4558
+ }
4559
+ if (name === "blog") {
4560
+ return {
4561
+ frontmatter: true,
4562
+ toc: true,
4563
+ anchors: true,
4564
+ elements: {
4565
+ time: { class: "nizel-date" }
4566
+ }
4567
+ };
4568
+ }
4569
+ if (name === "email") {
4570
+ return {
4571
+ safe: true,
4572
+ anchors: false,
4573
+ autolinks: { enabled: true },
4574
+ elements: {
4575
+ a: { attr: { target: void 0, rel: void 0 } },
4576
+ table: { attr: { role: "presentation", cellpadding: "0", cellspacing: "0", border: "0" } }
4577
+ }
4578
+ };
4579
+ }
4580
+ if (name === "docs") {
4581
+ return {
4582
+ toc: true,
4583
+ anchors: true,
4584
+ elements: {
4585
+ h2: { class: "nizel-docs-heading" },
4586
+ code: { class: "nizel-code" }
4587
+ }
4588
+ };
4589
+ }
4590
+ return {};
4591
+ }
4592
+ function withAutolinkElements(elements, autolinks) {
4593
+ if (!autolinks || typeof autolinks !== "object" || !autolinks.target && !autolinks.rel) {
4594
+ return elements;
4595
+ }
4596
+ const existing = elements.a;
4597
+ return {
4598
+ ...elements,
4599
+ a(node) {
4600
+ const base = typeof existing === "function" ? existing(node) : existing;
4601
+ return {
4602
+ ...base,
4603
+ attrs: {
4604
+ target: autolinks.target,
4605
+ rel: autolinks.rel,
4606
+ ...base?.attrs
4607
+ }
4608
+ };
4609
+ }
4610
+ };
4611
+ }
4612
+
4613
+ // src/plugins/define-nizel-plugin.ts
4614
+ var defineNizelPlugin = (plugin) => {
4615
+ return plugin;
4616
+ };
4617
+
4618
+ // src/blocks/define-block.ts
4619
+ var defineBlock = (block) => {
4620
+ return block;
4621
+ };
4622
+
4623
+ // src/browser.ts
4624
+ function useBrowserNizel(options = {}) {
4625
+ const processor = useNizel(options);
4626
+ processor.markdownToHtml = (markdown, runtimeOptions) => processor.html(markdown, runtimeOptions);
4627
+ processor.mount = async (target, markdown, runtimeOptions) => mountMarkdown(target, markdown, runtimeOptions, processor);
4628
+ processor.htmlToMarkdown = htmlToMarkdown2;
4629
+ processor.nodeToMarkdown = nodeToMarkdown;
4630
+ processor.selectionToMarkdown = selectionToMarkdown;
4631
+ return processor;
4632
+ }
4633
+ async function markdownToHtml(markdown, runtimeOptions) {
4634
+ return useNizel().html(markdown, runtimeOptions);
4635
+ }
4636
+ async function mountMarkdown(target, markdown, runtimeOptions, processor = useNizel()) {
4637
+ const element = resolveMountTarget(target);
4638
+ element.innerHTML = await processor.html(markdown, runtimeOptions);
4639
+ return element;
4640
+ }
4641
+ function htmlToMarkdown2(source, options) {
4642
+ return htmlToMarkdown(sourceToHtml(source), options);
4643
+ }
4644
+ function nodeToMarkdown(source, options) {
4645
+ return htmlToMarkdown2(source, options);
4646
+ }
4647
+ function selectionToMarkdown(selection = currentSelection(), options) {
4648
+ if (!selection || selection.rangeCount === 0) return "";
4649
+ return htmlToMarkdown2(selection, options);
4650
+ }
4651
+ function sourceToHtml(source) {
4652
+ if (typeof source === "string") return source;
4653
+ if (isSelection(source)) return serializeSelection(source);
4654
+ if (isRange(source)) return serializeNode(source.cloneContents());
4655
+ if (isNodeList(source)) return Array.from(source, serializeNode).join("");
4656
+ return serializeNode(source);
4657
+ }
4658
+ function serializeNode(node) {
4659
+ if (isElement(node) && typeof node.outerHTML === "string") return node.outerHTML;
4660
+ switch (node.nodeType) {
4661
+ case 3:
4662
+ case 4:
4663
+ return escapeHtml2(node.nodeValue ?? "");
4664
+ case 8:
4665
+ return `<!--${node.nodeValue ?? ""}-->`;
4666
+ case 9: {
4667
+ const documentNode = node;
4668
+ return documentNode.documentElement?.outerHTML ?? serializeChildren(node);
4669
+ }
4670
+ case 11:
4671
+ return serializeChildren(node);
4672
+ default:
4673
+ return "childNodes" in node ? serializeChildren(node) : "";
4674
+ }
4675
+ }
4676
+ function serializeChildren(node) {
4677
+ return Array.from(node.childNodes, serializeNode).join("");
4678
+ }
4679
+ function serializeSelection(selection) {
4680
+ const fragments = [];
4681
+ for (let index = 0; index < selection.rangeCount; index += 1) {
4682
+ fragments.push(serializeNode(selection.getRangeAt(index).cloneContents()));
4683
+ }
4684
+ return fragments.join("");
4685
+ }
4686
+ function resolveMountTarget(target) {
4687
+ if (typeof target !== "string") return target;
4688
+ if (typeof document === "undefined") {
4689
+ throw new Error("nizel/browser mountMarkdown() needs a browser document when target is a selector.");
4690
+ }
4691
+ const element = document.querySelector(target);
4692
+ if (!element) throw new Error(`nizel/browser could not find mount target: ${target}`);
4693
+ return element;
4694
+ }
4695
+ function currentSelection() {
4696
+ return typeof globalThis.getSelection === "function" ? globalThis.getSelection() : null;
4697
+ }
4698
+ function isSelection(value) {
4699
+ return "rangeCount" in value && "getRangeAt" in value;
4700
+ }
4701
+ function isRange(value) {
4702
+ return "cloneContents" in value && "startContainer" in value && "endContainer" in value;
4703
+ }
4704
+ function isNodeList(value) {
4705
+ return "length" in value && !("nodeType" in value);
4706
+ }
4707
+ function isElement(value) {
4708
+ return value.nodeType === 1 && "outerHTML" in value;
4709
+ }
4710
+ function escapeHtml2(value) {
4711
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
4712
+ }
4713
+ export {
4714
+ defineBlock,
4715
+ defineNizelPlugin,
4716
+ htmlToMarkdown2 as htmlToMarkdown,
4717
+ markdownToHtml,
4718
+ mountMarkdown,
4719
+ nodeToMarkdown,
4720
+ selectionToMarkdown,
4721
+ useBrowserNizel,
4722
+ useNizel
4723
+ };