(() => {
var __defProp = Object.defineProperty;
var __export = (target, all2) => {
for (var name in all2)
__defProp(target, name, { get: all2[name], enumerable: !0 });
};
var MIN_PAGE_LENGTH_SETTING_DEFAULT = "3", AUTOLINK_RELATED_NOTES_SECTION_SETTING_DEFAULT = "false", MIN_PAGE_LENGTH_SETTING = `Min Page Name Length (default: ${MIN_PAGE_LENGTH_SETTING_DEFAULT})`, AUTOLINK_RELATED_NOTES_SECTION_SETTING = `Autolink Related Notes Section (default: ${AUTOLINK_RELATED_NOTES_SECTION_SETTING_DEFAULT})`;
var package_default = {
name: "amplenote-plugin-dev-env",
author: "debajandhar12",
version: "1.0.0",
type: "module",
repository: "https://github.com/debanjandhar12/my-amplenote-plugins-v2",
dependencies: {
"@debanjandhar12/markmap-lib": "0.17.0-mod.3",
"@debanjandhar12/markmap-toolbar": "0.17.0-mod.3",
"@debanjandhar12/markmap-view": "0.17.0-mod.3",
"date-fns": "^3.6.0",
"lodash-es": "^4.17.21",
luxon: "^3.4.4",
"markdown-escape": "^2.0.0",
"@omnivore-app/api": "^1.0.4",
"markdown-it": "^14.1.0",
"remark-gfm": "4.0.0",
"remark-parse": "11.0.0",
unified: "11.0.0",
"unist-util-visit": "^5.0.0",
"unist-util-visit-parents": "6.0.1",
"d3-svg-to-png": "^0.3.1",
"chart.js": "^4.4.3",
fparser: "^3.1.0",
nanoid: "^5.0.7",
zod: "^3.23.8"
},
devDependencies: {
"@types/jest": "^29.5.0",
cors: "^2.8.5",
"cross-fetch": "^4.0.0",
dotenv: "^16.0.3",
esbuild: "0.23.1",
"esbuild-jest2": "0.6.7",
"esbuild-plugins-node-modules-polyfill": "1.6.6",
express: "^4.19.2",
"isomorphic-fetch": "^3.0.0",
jest: "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
jsdom: "^24.1.0",
"make-synchronous": "^1.0.0",
playwright: "^1.47.2",
"core-js": "^3.38.1"
},
scripts: {
test: "jest --testPathPattern=src-autolink",
"test:watch": "jest --testPathPattern=src-autolink --watch",
"build:prod": "NODE_ENV=production node esbuild.js $(pwd)/src-autolink",
"build:dev": "node esbuild.js $(pwd)/src-autolink --watch --server"
}
};
var dynamicImportESM = async (pkg, pkgVersion = null) => {
if (0) {
try {
} catch (e) {
}
try {
} catch (e) {
}
}
let cdnList = ["https://esm.sh/", "https://esm.run/"], resolvedVersion = resolvePackageVersion(pkg, pkgVersion), importCompleted = !1, importPromises = cdnList.map(async (cdn) => {
let url = buildCDNUrl(cdn, pkg, resolvedVersion);
if (cdn !== "https://esm.sh/" && await new Promise((resolve) => setTimeout(resolve, 600)), importCompleted)
throw new Error(`Terminating as ${pkg} has already been imported`);
return import(url).then((module2) => ({ module: module2, url })).catch((e) => {
throw console.warn(`Failed to import ${pkg} from ${cdn}: ${e.message}`), e;
});
});
try {
let result = await Promise.any(importPromises);
return importCompleted = !0, console.log(`Imported ${pkg}@${resolvedVersion} from ${result.url}`), result.module;
} catch {
throw new Error(`Failed to import ${pkg} from all available CDNs`);
}
throw new Error(`Failed to import ${pkg} from all available CDNs`);
};
function getBasePackage(pkg) {
if (pkg.startsWith("@")) {
let [scope, name] = pkg.split("/");
return `${scope}/${name}`;
}
return pkg.split("/")[0];
}
function resolvePackageVersion(pkg, pkgVersion) {
let basePkg = getBasePackage(pkg), version = pkgVersion || package_default.dependencies[basePkg] || package_default.devDependencies[basePkg] || "latest";
return version.startsWith("^") || version.startsWith("~") ? version.substring(1) : version;
}
function buildCDNUrl(cdn, pkg, version) {
let folders = [];
pkg.startsWith("@") ? [, , ...folders] = pkg.split("/") : [, ...folders] = pkg.split("/");
let basePkg = getBasePackage(pkg), versionString = version !== "latest" ? `@${version}` : "", folderString = folders && folders.length > 0 ? `/${folders.join("/")}` : "", url = `${cdn}${basePkg}${versionString}${folderString}`;
return ["https://esm.sh/"].includes(cdn) ? url + "?bundle-deps" : url;
}
var dynamic_import_esm_default = dynamicImportESM;
var emptyOptions = {};
function toString(value, options) {
let settings = options || emptyOptions, includeImageAlt = typeof settings.includeImageAlt == "boolean" ? settings.includeImageAlt : !0, includeHtml = typeof settings.includeHtml == "boolean" ? settings.includeHtml : !0;
return one(value, includeImageAlt, includeHtml);
}
function one(value, includeImageAlt, includeHtml) {
if (node(value)) {
if ("value" in value)
return value.type === "html" && !includeHtml ? "" : value.value;
if (includeImageAlt && "alt" in value && value.alt)
return value.alt;
if ("children" in value)
return all(value.children, includeImageAlt, includeHtml);
}
return Array.isArray(value) ? all(value, includeImageAlt, includeHtml) : "";
}
function all(values, includeImageAlt, includeHtml) {
let result = [], index2 = -1;
for (; ++index2 < values.length; )
result[index2] = one(values[index2], includeImageAlt, includeHtml);
return result.join("");
}
function node(value) {
return !!(value && typeof value == "object");
}
var element = document.createElement("i");
function decodeNamedCharacterReference(value) {
let characterReference2 = "&" + value + ";";
element.innerHTML = characterReference2;
let char = element.textContent;
return char.charCodeAt(char.length - 1) === 59 && value !== "semi" || char === characterReference2 ? !1 : char;
}
function splice(list2, start, remove, items) {
let end = list2.length, chunkStart = 0, parameters;
if (start < 0 ? start = -start > end ? 0 : end + start : start = start > end ? end : start, remove = remove > 0 ? remove : 0, items.length < 1e4)
parameters = Array.from(items), parameters.unshift(start, remove), list2.splice(...parameters);
else
for (remove && list2.splice(start, remove); chunkStart < items.length; )
parameters = items.slice(chunkStart, chunkStart + 1e4), parameters.unshift(start, 0), list2.splice(...parameters), chunkStart += 1e4, start += 1e4;
}
function push(list2, items) {
return list2.length > 0 ? (splice(list2, list2.length, 0, items), list2) : items;
}
var hasOwnProperty = {}.hasOwnProperty;
function combineExtensions(extensions) {
let all2 = {}, index2 = -1;
for (; ++index2 < extensions.length; )
syntaxExtension(all2, extensions[index2]);
return all2;
}
function syntaxExtension(all2, extension2) {
let hook;
for (hook in extension2) {
let left = (hasOwnProperty.call(all2, hook) ? all2[hook] : void 0) || (all2[hook] = {}), right = extension2[hook], code;
if (right)
for (code in right) {
hasOwnProperty.call(left, code) || (left[code] = []);
let value = right[code];
constructs(
left[code],
Array.isArray(value) ? value : value ? [value] : []
);
}
}
}
function constructs(existing, list2) {
let index2 = -1, before = [];
for (; ++index2 < list2.length; )
(list2[index2].add === "after" ? existing : before).push(list2[index2]);
splice(existing, 0, 0, before);
}
function decodeNumericCharacterReference(value, base) {
let code = Number.parseInt(value, base);
return (
code < 9 || code === 11 || code > 13 && code < 32 ||
code > 126 && code < 160 ||
code > 55295 && code < 57344 ||
code > 64975 && code < 65008 ||
(code & 65535) === 65535 || (code & 65535) === 65534 ||
code > 1114111 ? "\uFFFD" : String.fromCodePoint(code)
);
}
function normalizeIdentifier(value) {
return value.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
}
var asciiAlpha = regexCheck(/[A-Za-z]/), asciiAlphanumeric = regexCheck(/[\dA-Za-z]/), asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
function asciiControl(code) {
return (
code !== null && (code < 32 || code === 127)
);
}
var asciiDigit = regexCheck(/\d/), asciiHexDigit = regexCheck(/[\dA-Fa-f]/), asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
function markdownLineEnding(code) {
return code !== null && code < -2;
}
function markdownLineEndingOrSpace(code) {
return code !== null && (code < 0 || code === 32);
}
function markdownSpace(code) {
return code === -2 || code === -1 || code === 32;
}
var unicodePunctuation = regexCheck(/\p{P}|\p{S}/u), unicodeWhitespace = regexCheck(/\s/);
function regexCheck(regex) {
return check;
function check(code) {
return code !== null && code > -1 && regex.test(String.fromCharCode(code));
}
}
function factorySpace(effects, ok2, type, max) {
let limit = max ? max - 1 : Number.POSITIVE_INFINITY, size = 0;
return start;
function start(code) {
return markdownSpace(code) ? (effects.enter(type), prefix(code)) : ok2(code);
}
function prefix(code) {
return markdownSpace(code) && size++ < limit ? (effects.consume(code), prefix) : (effects.exit(type), ok2(code));
}
}
var content = {
tokenize: initializeContent
};
function initializeContent(effects) {
let contentStart = effects.attempt(
this.parser.constructs.contentInitial,
afterContentStartConstruct,
paragraphInitial
), previous2;
return contentStart;
function afterContentStartConstruct(code) {
if (code === null) {
effects.consume(code);
return;
}
return effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), factorySpace(effects, contentStart, "linePrefix");
}
function paragraphInitial(code) {
return effects.enter("paragraph"), lineStart(code);
}
function lineStart(code) {
let token = effects.enter("chunkText", {
contentType: "text",
previous: previous2
});
return previous2 && (previous2.next = token), previous2 = token, data(code);
}
function data(code) {
if (code === null) {
effects.exit("chunkText"), effects.exit("paragraph"), effects.consume(code);
return;
}
return markdownLineEnding(code) ? (effects.consume(code), effects.exit("chunkText"), lineStart) : (effects.consume(code), data);
}
}
var document2 = {
tokenize: initializeDocument
}, containerConstruct = {
tokenize: tokenizeContainer
};
function initializeDocument(effects) {
let self2 = this, stack = [], continued = 0, childFlow, childToken, lineStartOffset;
return start;
function start(code) {
if (continued < stack.length) {
let item = stack[continued];
return self2.containerState = item[1], effects.attempt(
item[0].continuation,
documentContinue,
checkNewContainers
)(code);
}
return checkNewContainers(code);
}
function documentContinue(code) {
if (continued++, self2.containerState._closeFlow) {
self2.containerState._closeFlow = void 0, childFlow && closeFlow();
let indexBeforeExits = self2.events.length, indexBeforeFlow = indexBeforeExits, point3;
for (; indexBeforeFlow--; )
if (self2.events[indexBeforeFlow][0] === "exit" && self2.events[indexBeforeFlow][1].type === "chunkFlow") {
point3 = self2.events[indexBeforeFlow][1].end;
break;
}
exitContainers(continued);
let index2 = indexBeforeExits;
for (; index2 < self2.events.length; )
self2.events[index2][1].end = Object.assign({}, point3), index2++;
return splice(
self2.events,
indexBeforeFlow + 1,
0,
self2.events.slice(indexBeforeExits)
), self2.events.length = index2, checkNewContainers(code);
}
return start(code);
}
function checkNewContainers(code) {
if (continued === stack.length) {
if (!childFlow)
return documentContinued(code);
if (childFlow.currentConstruct && childFlow.currentConstruct.concrete)
return flowStart(code);
self2.interrupt = !!(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
}
return self2.containerState = {}, effects.check(
containerConstruct,
thereIsANewContainer,
thereIsNoNewContainer
)(code);
}
function thereIsANewContainer(code) {
return childFlow && closeFlow(), exitContainers(continued), documentContinued(code);
}
function thereIsNoNewContainer(code) {
return self2.parser.lazy[self2.now().line] = continued !== stack.length, lineStartOffset = self2.now().offset, flowStart(code);
}
function documentContinued(code) {
return self2.containerState = {}, effects.attempt(
containerConstruct,
containerContinue,
flowStart
)(code);
}
function containerContinue(code) {
return continued++, stack.push([self2.currentConstruct, self2.containerState]), documentContinued(code);
}
function flowStart(code) {
if (code === null) {
childFlow && closeFlow(), exitContainers(0), effects.consume(code);
return;
}
return childFlow = childFlow || self2.parser.flow(self2.now()), effects.enter("chunkFlow", {
contentType: "flow",
previous: childToken,
_tokenizer: childFlow
}), flowContinue(code);
}
function flowContinue(code) {
if (code === null) {
writeToChild(effects.exit("chunkFlow"), !0), exitContainers(0), effects.consume(code);
return;
}
return markdownLineEnding(code) ? (effects.consume(code), writeToChild(effects.exit("chunkFlow")), continued = 0, self2.interrupt = void 0, start) : (effects.consume(code), flowContinue);
}
function writeToChild(token, eof) {
let stream = self2.sliceStream(token);
if (eof && stream.push(null), token.previous = childToken, childToken && (childToken.next = token), childToken = token, childFlow.defineSkip(token.start), childFlow.write(stream), self2.parser.lazy[token.start.line]) {
let index2 = childFlow.events.length;
for (; index2--; )
if (
childFlow.events[index2][1].start.offset < lineStartOffset &&
(!childFlow.events[index2][1].end ||
childFlow.events[index2][1].end.offset > lineStartOffset)
)
return;
let indexBeforeExits = self2.events.length, indexBeforeFlow = indexBeforeExits, seen, point3;
for (; indexBeforeFlow--; )
if (self2.events[indexBeforeFlow][0] === "exit" && self2.events[indexBeforeFlow][1].type === "chunkFlow") {
if (seen) {
point3 = self2.events[indexBeforeFlow][1].end;
break;
}
seen = !0;
}
for (exitContainers(continued), index2 = indexBeforeExits; index2 < self2.events.length; )
self2.events[index2][1].end = Object.assign({}, point3), index2++;
splice(
self2.events,
indexBeforeFlow + 1,
0,
self2.events.slice(indexBeforeExits)
), self2.events.length = index2;
}
}
function exitContainers(size) {
let index2 = stack.length;
for (; index2-- > size; ) {
let entry = stack[index2];
self2.containerState = entry[1], entry[0].exit.call(self2, effects);
}
stack.length = size;
}
function closeFlow() {
childFlow.write([null]), childToken = void 0, childFlow = void 0, self2.containerState._closeFlow = void 0;
}
}
function tokenizeContainer(effects, ok2, nok) {
return factorySpace(
effects,
effects.attempt(this.parser.constructs.document, ok2, nok),
"linePrefix",
this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4
);
}
function classifyCharacter(code) {
if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code))
return 1;
if (unicodePunctuation(code))
return 2;
}
function resolveAll(constructs2, events, context) {
let called = [], index2 = -1;
for (; ++index2 < constructs2.length; ) {
let resolve = constructs2[index2].resolveAll;
resolve && !called.includes(resolve) && (events = resolve(events, context), called.push(resolve));
}
return events;
}
var attention = {
name: "attention",
tokenize: tokenizeAttention,
resolveAll: resolveAllAttention
};
function resolveAllAttention(events, context) {
let index2 = -1, open, group, text3, openingSequence, closingSequence, use, nextEvents, offset;
for (; ++index2 < events.length; )
if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
for (open = index2; open--; )
if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open &&
context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
if ((events[open][1]._close || events[index2][1]._open) && (events[index2][1].end.offset - events[index2][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index2][1].end.offset - events[index2][1].start.offset) % 3))
continue;
use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index2][1].end.offset - events[index2][1].start.offset > 1 ? 2 : 1;
let start = Object.assign({}, events[open][1].end), end = Object.assign({}, events[index2][1].start);
movePoint(start, -use), movePoint(end, use), openingSequence = {
type: use > 1 ? "strongSequence" : "emphasisSequence",
start,
end: Object.assign({}, events[open][1].end)
}, closingSequence = {
type: use > 1 ? "strongSequence" : "emphasisSequence",
start: Object.assign({}, events[index2][1].start),
end
}, text3 = {
type: use > 1 ? "strongText" : "emphasisText",
start: Object.assign({}, events[open][1].end),
end: Object.assign({}, events[index2][1].start)
}, group = {
type: use > 1 ? "strong" : "emphasis",
start: Object.assign({}, openingSequence.start),
end: Object.assign({}, closingSequence.end)
}, events[open][1].end = Object.assign({}, openingSequence.start), events[index2][1].start = Object.assign({}, closingSequence.end), nextEvents = [], events[open][1].end.offset - events[open][1].start.offset && (nextEvents = push(nextEvents, [["enter", events[open][1], context], ["exit", events[open][1], context]])), nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text3, context]]), nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index2), context)), nextEvents = push(nextEvents, [["exit", text3, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]), events[index2][1].end.offset - events[index2][1].start.offset ? (offset = 2, nextEvents = push(nextEvents, [["enter", events[index2][1], context], ["exit", events[index2][1], context]])) : offset = 0, splice(events, open - 1, index2 - open + 3, nextEvents), index2 = open + nextEvents.length - offset - 2;
break;
}
}
for (index2 = -1; ++index2 < events.length; )
events[index2][1].type === "attentionSequence" && (events[index2][1].type = "data");
return events;
}
function tokenizeAttention(effects, ok2) {
let attentionMarkers2 = this.parser.constructs.attentionMarkers.null, previous2 = this.previous, before = classifyCharacter(previous2), marker;
return start;
function start(code) {
return marker = code, effects.enter("attentionSequence"), inside(code);
}
function inside(code) {
if (code === marker)
return effects.consume(code), inside;
let token = effects.exit("attentionSequence"), after = classifyCharacter(code), open = !after || after === 2 && before || attentionMarkers2.includes(code), close = !before || before === 2 && after || attentionMarkers2.includes(previous2);
return token._open = !!(marker === 42 ? open : open && (before || !close)), token._close = !!(marker === 42 ? close : close && (after || !open)), ok2(code);
}
}
function movePoint(point3, offset) {
point3.column += offset, point3.offset += offset, point3._bufferIndex += offset;
}
var autolink = {
name: "autolink",
tokenize: tokenizeAutolink
};
function tokenizeAutolink(effects, ok2, nok) {
let size = 0;
return start;
function start(code) {
return effects.enter("autolink"), effects.enter("autolinkMarker"), effects.consume(code), effects.exit("autolinkMarker"), effects.enter("autolinkProtocol"), open;
}
function open(code) {
return asciiAlpha(code) ? (effects.consume(code), schemeOrEmailAtext) : code === 64 ? nok(code) : emailAtext(code);
}
function schemeOrEmailAtext(code) {
return code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code) ? (size = 1, schemeInsideOrEmailAtext(code)) : emailAtext(code);
}
function schemeInsideOrEmailAtext(code) {
return code === 58 ? (effects.consume(code), size = 0, urlInside) : (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32 ? (effects.consume(code), schemeInsideOrEmailAtext) : (size = 0, emailAtext(code));
}
function urlInside(code) {
return code === 62 ? (effects.exit("autolinkProtocol"), effects.enter("autolinkMarker"), effects.consume(code), effects.exit("autolinkMarker"), effects.exit("autolink"), ok2) : code === null || code === 32 || code === 60 || asciiControl(code) ? nok(code) : (effects.consume(code), urlInside);
}
function emailAtext(code) {
return code === 64 ? (effects.consume(code), emailAtSignOrDot) : asciiAtext(code) ? (effects.consume(code), emailAtext) : nok(code);
}
function emailAtSignOrDot(code) {
return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
}
function emailLabel(code) {
return code === 46 ? (effects.consume(code), size = 0, emailAtSignOrDot) : code === 62 ? (effects.exit("autolinkProtocol").type = "autolinkEmail", effects.enter("autolinkMarker"), effects.consume(code), effects.exit("autolinkMarker"), effects.exit("autolink"), ok2) : emailValue(code);
}
function emailValue(code) {
if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
let next = code === 45 ? emailValue : emailLabel;
return effects.consume(code), next;
}
return nok(code);
}
}
var blankLine = {
tokenize: tokenizeBlankLine,
partial: !0
};
function tokenizeBlankLine(effects, ok2, nok) {
return start;
function start(code) {
return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code);
}
function after(code) {
return code === null || markdownLineEnding(code) ? ok2(code) : nok(code);
}
}
var blockQuote = {
name: "blockQuote",
tokenize: tokenizeBlockQuoteStart,
continuation: {
tokenize: tokenizeBlockQuoteContinuation
},
exit
};
function tokenizeBlockQuoteStart(effects, ok2, nok) {
let self2 = this;
return start;
function start(code) {
if (code === 62) {
let state = self2.containerState;
return state.open || (effects.enter("blockQuote", {
_container: !0
}), state.open = !0), effects.enter("blockQuotePrefix"), effects.enter("blockQuoteMarker"), effects.consume(code), effects.exit("blockQuoteMarker"), after;
}
return nok(code);
}
function after(code) {
return markdownSpace(code) ? (effects.enter("blockQuotePrefixWhitespace"), effects.consume(code), effects.exit("blockQuotePrefixWhitespace"), effects.exit("blockQuotePrefix"), ok2) : (effects.exit("blockQuotePrefix"), ok2(code));
}
}
function tokenizeBlockQuoteContinuation(effects, ok2, nok) {
let self2 = this;
return contStart;
function contStart(code) {
return markdownSpace(code) ? factorySpace(effects, contBefore, "linePrefix", self2.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : contBefore(code);
}
function contBefore(code) {
return effects.attempt(blockQuote, ok2, nok)(code);
}
}
function exit(effects) {
effects.exit("blockQuote");
}
var characterEscape = {
name: "characterEscape",
tokenize: tokenizeCharacterEscape
};
function tokenizeCharacterEscape(effects, ok2, nok) {
return start;
function start(code) {
return effects.enter("characterEscape"), effects.enter("escapeMarker"), effects.consume(code), effects.exit("escapeMarker"), inside;
}
function inside(code) {
return asciiPunctuation(code) ? (effects.enter("characterEscapeValue"), effects.consume(code), effects.exit("characterEscapeValue"), effects.exit("characterEscape"), ok2) : nok(code);
}
}
var characterReference = {
name: "characterReference",
tokenize: tokenizeCharacterReference
};
function tokenizeCharacterReference(effects, ok2, nok) {
let self2 = this, size = 0, max, test;
return start;
function start(code) {
return effects.enter("characterReference"), effects.enter("characterReferenceMarker"), effects.consume(code), effects.exit("characterReferenceMarker"), open;
}
function open(code) {
return code === 35 ? (effects.enter("characterReferenceMarkerNumeric"), effects.consume(code), effects.exit("characterReferenceMarkerNumeric"), numeric) : (effects.enter("characterReferenceValue"), max = 31, test = asciiAlphanumeric, value(code));
}
function numeric(code) {
return code === 88 || code === 120 ? (effects.enter("characterReferenceMarkerHexadecimal"), effects.consume(code), effects.exit("characterReferenceMarkerHexadecimal"), effects.enter("characterReferenceValue"), max = 6, test = asciiHexDigit, value) : (effects.enter("characterReferenceValue"), max = 7, test = asciiDigit, value(code));
}
function value(code) {
if (code === 59 && size) {
let token = effects.exit("characterReferenceValue");
return test === asciiAlphanumeric && !decodeNamedCharacterReference(self2.sliceSerialize(token)) ? nok(code) : (effects.enter("characterReferenceMarker"), effects.consume(code), effects.exit("characterReferenceMarker"), effects.exit("characterReference"), ok2);
}
return test(code) && size++ < max ? (effects.consume(code), value) : nok(code);
}
}
var nonLazyContinuation = {
tokenize: tokenizeNonLazyContinuation,
partial: !0
}, codeFenced = {
name: "codeFenced",
tokenize: tokenizeCodeFenced,
concrete: !0
};
function tokenizeCodeFenced(effects, ok2, nok) {
let self2 = this, closeStart = {
tokenize: tokenizeCloseStart,
partial: !0
}, initialPrefix = 0, sizeOpen = 0, marker;
return start;
function start(code) {
return beforeSequenceOpen(code);
}
function beforeSequenceOpen(code) {
let tail = self2.events[self2.events.length - 1];
return initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], !0).length : 0, marker = code, effects.enter("codeFenced"), effects.enter("codeFencedFence"), effects.enter("codeFencedFenceSequence"), sequenceOpen(code);
}
function sequenceOpen(code) {
return code === marker ? (sizeOpen++, effects.consume(code), sequenceOpen) : sizeOpen < 3 ? nok(code) : (effects.exit("codeFencedFenceSequence"), markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code));
}
function infoBefore(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("codeFencedFence"), self2.interrupt ? ok2(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code)) : (effects.enter("codeFencedFenceInfo"), effects.enter("chunkString", {
contentType: "string"
}), info(code));
}
function info(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("chunkString"), effects.exit("codeFencedFenceInfo"), infoBefore(code)) : markdownSpace(code) ? (effects.exit("chunkString"), effects.exit("codeFencedFenceInfo"), factorySpace(effects, metaBefore, "whitespace")(code)) : code === 96 && code === marker ? nok(code) : (effects.consume(code), info);
}
function metaBefore(code) {
return code === null || markdownLineEnding(code) ? infoBefore(code) : (effects.enter("codeFencedFenceMeta"), effects.enter("chunkString", {
contentType: "string"
}), meta(code));
}
function meta(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("chunkString"), effects.exit("codeFencedFenceMeta"), infoBefore(code)) : code === 96 && code === marker ? nok(code) : (effects.consume(code), meta);
}
function atNonLazyBreak(code) {
return effects.attempt(closeStart, after, contentBefore)(code);
}
function contentBefore(code) {
return effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), contentStart;
}
function contentStart(code) {
return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code);
}
function beforeContentChunk(code) {
return code === null || markdownLineEnding(code) ? effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) : (effects.enter("codeFlowValue"), contentChunk(code));
}
function contentChunk(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("codeFlowValue"), beforeContentChunk(code)) : (effects.consume(code), contentChunk);
}
function after(code) {
return effects.exit("codeFenced"), ok2(code);
}
function tokenizeCloseStart(effects2, ok3, nok2) {
let size = 0;
return startBefore;
function startBefore(code) {
return effects2.enter("lineEnding"), effects2.consume(code), effects2.exit("lineEnding"), start2;
}
function start2(code) {
return effects2.enter("codeFencedFence"), markdownSpace(code) ? factorySpace(effects2, beforeSequenceClose, "linePrefix", self2.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : beforeSequenceClose(code);
}
function beforeSequenceClose(code) {
return code === marker ? (effects2.enter("codeFencedFenceSequence"), sequenceClose(code)) : nok2(code);
}
function sequenceClose(code) {
return code === marker ? (size++, effects2.consume(code), sequenceClose) : size >= sizeOpen ? (effects2.exit("codeFencedFenceSequence"), markdownSpace(code) ? factorySpace(effects2, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code)) : nok2(code);
}
function sequenceCloseAfter(code) {
return code === null || markdownLineEnding(code) ? (effects2.exit("codeFencedFence"), ok3(code)) : nok2(code);
}
}
}
function tokenizeNonLazyContinuation(effects, ok2, nok) {
let self2 = this;
return start;
function start(code) {
return code === null ? nok(code) : (effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), lineStart);
}
function lineStart(code) {
return self2.parser.lazy[self2.now().line] ? nok(code) : ok2(code);
}
}
var codeIndented = {
name: "codeIndented",
tokenize: tokenizeCodeIndented
}, furtherStart = {
tokenize: tokenizeFurtherStart,
partial: !0
};
function tokenizeCodeIndented(effects, ok2, nok) {
let self2 = this;
return start;
function start(code) {
return effects.enter("codeIndented"), factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
}
function afterPrefix(code) {
let tail = self2.events[self2.events.length - 1];
return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], !0).length >= 4 ? atBreak(code) : nok(code);
}
function atBreak(code) {
return code === null ? after(code) : markdownLineEnding(code) ? effects.attempt(furtherStart, atBreak, after)(code) : (effects.enter("codeFlowValue"), inside(code));
}
function inside(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("codeFlowValue"), atBreak(code)) : (effects.consume(code), inside);
}
function after(code) {
return effects.exit("codeIndented"), ok2(code);
}
}
function tokenizeFurtherStart(effects, ok2, nok) {
let self2 = this;
return furtherStart2;
function furtherStart2(code) {
return self2.parser.lazy[self2.now().line] ? nok(code) : markdownLineEnding(code) ? (effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), furtherStart2) : factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
}
function afterPrefix(code) {
let tail = self2.events[self2.events.length - 1];
return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], !0).length >= 4 ? ok2(code) : markdownLineEnding(code) ? furtherStart2(code) : nok(code);
}
}
var codeText = {
name: "codeText",
tokenize: tokenizeCodeText,
resolve: resolveCodeText,
previous
};
function resolveCodeText(events) {
let tailExitIndex = events.length - 4, headEnterIndex = 3, index2, enter;
if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
for (index2 = headEnterIndex; ++index2 < tailExitIndex; )
if (events[index2][1].type === "codeTextData") {
events[headEnterIndex][1].type = "codeTextPadding", events[tailExitIndex][1].type = "codeTextPadding", headEnterIndex += 2, tailExitIndex -= 2;
break;
}
}
for (index2 = headEnterIndex - 1, tailExitIndex++; ++index2 <= tailExitIndex; )
enter === void 0 ? index2 !== tailExitIndex && events[index2][1].type !== "lineEnding" && (enter = index2) : (index2 === tailExitIndex || events[index2][1].type === "lineEnding") && (events[enter][1].type = "codeTextData", index2 !== enter + 2 && (events[enter][1].end = events[index2 - 1][1].end, events.splice(enter + 2, index2 - enter - 2), tailExitIndex -= index2 - enter - 2, index2 = enter + 2), enter = void 0);
return events;
}
function previous(code) {
return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
}
function tokenizeCodeText(effects, ok2, nok) {
let self2 = this, sizeOpen = 0, size, token;
return start;
function start(code) {
return effects.enter("codeText"), effects.enter("codeTextSequence"), sequenceOpen(code);
}
function sequenceOpen(code) {
return code === 96 ? (effects.consume(code), sizeOpen++, sequenceOpen) : (effects.exit("codeTextSequence"), between(code));
}
function between(code) {
return code === null ? nok(code) : code === 32 ? (effects.enter("space"), effects.consume(code), effects.exit("space"), between) : code === 96 ? (token = effects.enter("codeTextSequence"), size = 0, sequenceClose(code)) : markdownLineEnding(code) ? (effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), between) : (effects.enter("codeTextData"), data(code));
}
function data(code) {
return code === null || code === 32 || code === 96 || markdownLineEnding(code) ? (effects.exit("codeTextData"), between(code)) : (effects.consume(code), data);
}
function sequenceClose(code) {
return code === 96 ? (effects.consume(code), size++, sequenceClose) : size === sizeOpen ? (effects.exit("codeTextSequence"), effects.exit("codeText"), ok2(code)) : (token.type = "codeTextData", data(code));
}
}
var SpliceBuffer = class {
constructor(initial) {
this.left = initial ? [...initial] : [], this.right = [];
}
get(index2) {
if (index2 < 0 || index2 >= this.left.length + this.right.length)
throw new RangeError("Cannot access index `" + index2 + "` in a splice buffer of size `" + (this.left.length + this.right.length) + "`");
return index2 < this.left.length ? this.left[index2] : this.right[this.right.length - index2 + this.left.length - 1];
}
get length() {
return this.left.length + this.right.length;
}
shift() {
return this.setCursor(0), this.right.pop();
}
slice(start, end) {
let stop = end == null ? Number.POSITIVE_INFINITY : end;
return stop < this.left.length ? this.left.slice(start, stop) : start > this.left.length ? this.right.slice(this.right.length - stop + this.left.length, this.right.length - start + this.left.length).reverse() : this.left.slice(start).concat(this.right.slice(this.right.length - stop + this.left.length).reverse());
}
splice(start, deleteCount, items) {
let count = deleteCount || 0;
this.setCursor(Math.trunc(start));
let removed = this.right.splice(this.right.length - count, Number.POSITIVE_INFINITY);
return items && chunkedPush(this.left, items), removed.reverse();
}
pop() {
return this.setCursor(Number.POSITIVE_INFINITY), this.left.pop();
}
push(item) {
this.setCursor(Number.POSITIVE_INFINITY), this.left.push(item);
}
pushMany(items) {
this.setCursor(Number.POSITIVE_INFINITY), chunkedPush(this.left, items);
}
unshift(item) {
this.setCursor(0), this.right.push(item);
}
unshiftMany(items) {
this.setCursor(0), chunkedPush(this.right, items.reverse());
}
setCursor(n) {
if (!(n === this.left.length || n > this.left.length && this.right.length === 0 || n < 0 && this.left.length === 0))
if (n < this.left.length) {
let removed = this.left.splice(n, Number.POSITIVE_INFINITY);
chunkedPush(this.right, removed.reverse());
} else {
let removed = this.right.splice(this.left.length + this.right.length - n, Number.POSITIVE_INFINITY);
chunkedPush(this.left, removed.reverse());
}
}
};
function chunkedPush(list2, right) {
let chunkStart = 0;
if (right.length < 1e4)
list2.push(...right);
else
for (; chunkStart < right.length; )
list2.push(...right.slice(chunkStart, chunkStart + 1e4)), chunkStart += 1e4;
}
function subtokenize(eventsArray) {
let jumps = {}, index2 = -1, event, lineIndex, otherIndex, otherEvent, parameters, subevents, more, events = new SpliceBuffer(eventsArray);
for (; ++index2 < events.length; ) {
for (; index2 in jumps; )
index2 = jumps[index2];
if (event = events.get(index2), index2 && event[1].type === "chunkFlow" && events.get(index2 - 1)[1].type === "listItemPrefix" && (subevents = event[1]._tokenizer.events, otherIndex = 0, otherIndex < subevents.length && subevents[otherIndex][1].type === "lineEndingBlank" && (otherIndex += 2), otherIndex < subevents.length && subevents[otherIndex][1].type === "content"))
for (; ++otherIndex < subevents.length && subevents[otherIndex][1].type !== "content"; )
subevents[otherIndex][1].type === "chunkText" && (subevents[otherIndex][1]._isInFirstContentOfListItem = !0, otherIndex++);
if (event[0] === "enter")
event[1].contentType && (Object.assign(jumps, subcontent(events, index2)), index2 = jumps[index2], more = !0);
else if (event[1]._container) {
for (otherIndex = index2, lineIndex = void 0; otherIndex-- && (otherEvent = events.get(otherIndex), otherEvent[1].type === "lineEnding" || otherEvent[1].type === "lineEndingBlank"); )
otherEvent[0] === "enter" && (lineIndex && (events.get(lineIndex)[1].type = "lineEndingBlank"), otherEvent[1].type = "lineEnding", lineIndex = otherIndex);
lineIndex && (event[1].end = Object.assign({}, events.get(lineIndex)[1].start), parameters = events.slice(lineIndex, index2), parameters.unshift(event), events.splice(lineIndex, index2 - lineIndex + 1, parameters));
}
}
return splice(eventsArray, 0, Number.POSITIVE_INFINITY, events.slice(0)), !more;
}
function subcontent(events, eventIndex) {
let token = events.get(eventIndex)[1], context = events.get(eventIndex)[2], startPosition = eventIndex - 1, startPositions = [], tokenizer = token._tokenizer || context.parser[token.contentType](token.start), childEvents = tokenizer.events, jumps = [], gaps = {}, stream, previous2, index2 = -1, current = token, adjust = 0, start = 0, breaks = [start];
for (; current; ) {
for (; events.get(++startPosition)[1] !== current; )
;
startPositions.push(startPosition), current._tokenizer || (stream = context.sliceStream(current), current.next || stream.push(null), previous2 && tokenizer.defineSkip(current.start), current._isInFirstContentOfListItem && (tokenizer._gfmTasklistFirstContentOfListItem = !0), tokenizer.write(stream), current._isInFirstContentOfListItem && (tokenizer._gfmTasklistFirstContentOfListItem = void 0)), previous2 = current, current = current.next;
}
for (current = token; ++index2 < childEvents.length; )
childEvents[index2][0] === "exit" && childEvents[index2 - 1][0] === "enter" && childEvents[index2][1].type === childEvents[index2 - 1][1].type && childEvents[index2][1].start.line !== childEvents[index2][1].end.line && (start = index2 + 1, breaks.push(start), current._tokenizer = void 0, current.previous = void 0, current = current.next);
for (tokenizer.events = [], current ? (current._tokenizer = void 0, current.previous = void 0) : breaks.pop(), index2 = breaks.length; index2--; ) {
let slice = childEvents.slice(breaks[index2], breaks[index2 + 1]), start2 = startPositions.pop();
jumps.push([start2, start2 + slice.length - 1]), events.splice(start2, 2, slice);
}
for (jumps.reverse(), index2 = -1; ++index2 < jumps.length; )
gaps[adjust + jumps[index2][0]] = adjust + jumps[index2][1], adjust += jumps[index2][1] - jumps[index2][0] - 1;
return gaps;
}
var content2 = {
tokenize: tokenizeContent,
resolve: resolveContent
}, continuationConstruct = {
tokenize: tokenizeContinuation,
partial: !0
};
function resolveContent(events) {
return subtokenize(events), events;
}
function tokenizeContent(effects, ok2) {
let previous2;
return chunkStart;
function chunkStart(code) {
return effects.enter("content"), previous2 = effects.enter("chunkContent", {
contentType: "content"
}), chunkInside(code);
}
function chunkInside(code) {
return code === null ? contentEnd(code) : markdownLineEnding(code) ? effects.check(continuationConstruct, contentContinue, contentEnd)(code) : (effects.consume(code), chunkInside);
}
function contentEnd(code) {
return effects.exit("chunkContent"), effects.exit("content"), ok2(code);
}
function contentContinue(code) {
return effects.consume(code), effects.exit("chunkContent"), previous2.next = effects.enter("chunkContent", {
contentType: "content",
previous: previous2
}), previous2 = previous2.next, chunkInside;
}
}
function tokenizeContinuation(effects, ok2, nok) {
let self2 = this;
return startLookahead;
function startLookahead(code) {
return effects.exit("chunkContent"), effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), factorySpace(effects, prefixed, "linePrefix");
}
function prefixed(code) {
if (code === null || markdownLineEnding(code))
return nok(code);
let tail = self2.events[self2.events.length - 1];
return !self2.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], !0).length >= 4 ? ok2(code) : effects.interrupt(self2.parser.constructs.flow, nok, ok2)(code);
}
}
function factoryDestination(effects, ok2, nok, type, literalType, literalMarkerType, rawType, stringType, max) {
let limit = max || Number.POSITIVE_INFINITY, balance = 0;
return start;
function start(code) {
return code === 60 ? (effects.enter(type), effects.enter(literalType), effects.enter(literalMarkerType), effects.consume(code), effects.exit(literalMarkerType), enclosedBefore) : code === null || code === 32 || code === 41 || asciiControl(code) ? nok(code) : (effects.enter(type), effects.enter(rawType), effects.enter(stringType), effects.enter("chunkString", {
contentType: "string"
}), raw(code));
}
function enclosedBefore(code) {
return code === 62 ? (effects.enter(literalMarkerType), effects.consume(code), effects.exit(literalMarkerType), effects.exit(literalType), effects.exit(type), ok2) : (effects.enter(stringType), effects.enter("chunkString", {
contentType: "string"
}), enclosed(code));
}
function enclosed(code) {
return code === 62 ? (effects.exit("chunkString"), effects.exit(stringType), enclosedBefore(code)) : code === null || code === 60 || markdownLineEnding(code) ? nok(code) : (effects.consume(code), code === 92 ? enclosedEscape : enclosed);
}
function enclosedEscape(code) {
return code === 60 || code === 62 || code === 92 ? (effects.consume(code), enclosed) : enclosed(code);
}
function raw(code) {
return !balance && (code === null || code === 41 || markdownLineEndingOrSpace(code)) ? (effects.exit("chunkString"), effects.exit(stringType), effects.exit(rawType), effects.exit(type), ok2(code)) : balance < limit && code === 40 ? (effects.consume(code), balance++, raw) : code === 41 ? (effects.consume(code), balance--, raw) : code === null || code === 32 || code === 40 || asciiControl(code) ? nok(code) : (effects.consume(code), code === 92 ? rawEscape : raw);
}
function rawEscape(code) {
return code === 40 || code === 41 || code === 92 ? (effects.consume(code), raw) : raw(code);
}
}
function factoryLabel(effects, ok2, nok, type, markerType, stringType) {
let self2 = this, size = 0, seen;
return start;
function start(code) {
return effects.enter(type), effects.enter(markerType), effects.consume(code), effects.exit(markerType), effects.enter(stringType), atBreak;
}
function atBreak(code) {
return size > 999 || code === null || code === 91 || code === 93 && !seen ||
code === 94 && !size && "_hiddenFootnoteSupport" in self2.parser.constructs ? nok(code) : code === 93 ? (effects.exit(stringType), effects.enter(markerType), effects.consume(code), effects.exit(markerType), effects.exit(type), ok2) : markdownLineEnding(code) ? (effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), atBreak) : (effects.enter("chunkString", {
contentType: "string"
}), labelInside(code));
}
function labelInside(code) {
return code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999 ? (effects.exit("chunkString"), atBreak(code)) : (effects.consume(code), seen || (seen = !markdownSpace(code)), code === 92 ? labelEscape : labelInside);
}
function labelEscape(code) {
return code === 91 || code === 92 || code === 93 ? (effects.consume(code), size++, labelInside) : labelInside(code);
}
}
function factoryTitle(effects, ok2, nok, type, markerType, stringType) {
let marker;
return start;
function start(code) {
return code === 34 || code === 39 || code === 40 ? (effects.enter(type), effects.enter(markerType), effects.consume(code), effects.exit(markerType), marker = code === 40 ? 41 : code, begin) : nok(code);
}
function begin(code) {
return code === marker ? (effects.enter(markerType), effects.consume(code), effects.exit(markerType), effects.exit(type), ok2) : (effects.enter(stringType), atBreak(code));
}
function atBreak(code) {
return code === marker ? (effects.exit(stringType), begin(marker)) : code === null ? nok(code) : markdownLineEnding(code) ? (effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), factorySpace(effects, atBreak, "linePrefix")) : (effects.enter("chunkString", {
contentType: "string"
}), inside(code));
}
function inside(code) {
return code === marker || code === null || markdownLineEnding(code) ? (effects.exit("chunkString"), atBreak(code)) : (effects.consume(code), code === 92 ? escape : inside);
}
function escape(code) {
return code === marker || code === 92 ? (effects.consume(code), inside) : inside(code);
}
}
function factoryWhitespace(effects, ok2) {
let seen;
return start;
function start(code) {
return markdownLineEnding(code) ? (effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), seen = !0, start) : markdownSpace(code) ? factorySpace(
effects,
start,
seen ? "linePrefix" : "lineSuffix"
)(code) : ok2(code);
}
}
var definition = {
name: "definition",
tokenize: tokenizeDefinition
}, titleBefore = {
tokenize: tokenizeTitleBefore,
partial: !0
};
function tokenizeDefinition(effects, ok2, nok) {
let self2 = this, identifier;
return start;
function start(code) {
return effects.enter("definition"), before(code);
}
function before(code) {
return factoryLabel.call(
self2,
effects,
labelAfter,
nok,
"definitionLabel",
"definitionLabelMarker",
"definitionLabelString"
)(code);
}
function labelAfter(code) {
return identifier = normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length - 1][1]).slice(1, -1)), code === 58 ? (effects.enter("definitionMarker"), effects.consume(code), effects.exit("definitionMarker"), markerAfter) : nok(code);
}
function markerAfter(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);
}
function destinationBefore(code) {
return factoryDestination(
effects,
destinationAfter,
nok,
"definitionDestination",
"definitionDestinationLiteral",
"definitionDestinationLiteralMarker",
"definitionDestinationRaw",
"definitionDestinationString"
)(code);
}
function destinationAfter(code) {
return effects.attempt(titleBefore, after, after)(code);
}
function after(code) {
return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code);
}
function afterWhitespace(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("definition"), self2.parser.defined.push(identifier), ok2(code)) : nok(code);
}
}
function tokenizeTitleBefore(effects, ok2, nok) {
return titleBefore2;
function titleBefore2(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);
}
function beforeMarker(code) {
return factoryTitle(effects, titleAfter, nok, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(code);
}
function titleAfter(code) {
return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code);
}
function titleAfterOptionalWhitespace(code) {
return code === null || markdownLineEnding(code) ? ok2(code) : nok(code);
}
}
var hardBreakEscape = {
name: "hardBreakEscape",
tokenize: tokenizeHardBreakEscape
};
function tokenizeHardBreakEscape(effects, ok2, nok) {
return start;
function start(code) {
return effects.enter("hardBreakEscape"), effects.consume(code), after;
}
function after(code) {
return markdownLineEnding(code) ? (effects.exit("hardBreakEscape"), ok2(code)) : nok(code);
}
}
var headingAtx = {
name: "headingAtx",
tokenize: tokenizeHeadingAtx,
resolve: resolveHeadingAtx
};
function resolveHeadingAtx(events, context) {
let contentEnd = events.length - 2, contentStart = 3, content3, text3;
return events[contentStart][1].type === "whitespace" && (contentStart += 2), contentEnd - 2 > contentStart && events[contentEnd][1].type === "whitespace" && (contentEnd -= 2), events[contentEnd][1].type === "atxHeadingSequence" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === "whitespace") && (contentEnd -= contentStart + 1 === contentEnd ? 2 : 4), contentEnd > contentStart && (content3 = {
type: "atxHeadingText",
start: events[contentStart][1].start,
end: events[contentEnd][1].end
}, text3 = {
type: "chunkText",
start: events[contentStart][1].start,
end: events[contentEnd][1].end,
contentType: "text"
}, splice(events, contentStart, contentEnd - contentStart + 1, [["enter", content3, context], ["enter", text3, context], ["exit", text3, context], ["exit", content3, context]])), events;
}
function tokenizeHeadingAtx(effects, ok2, nok) {
let size = 0;
return start;
function start(code) {
return effects.enter("atxHeading"), before(code);
}
function before(code) {
return effects.enter("atxHeadingSequence"), sequenceOpen(code);
}
function sequenceOpen(code) {
return code === 35 && size++ < 6 ? (effects.consume(code), sequenceOpen) : code === null || markdownLineEndingOrSpace(code) ? (effects.exit("atxHeadingSequence"), atBreak(code)) : nok(code);
}
function atBreak(code) {
return code === 35 ? (effects.enter("atxHeadingSequence"), sequenceFurther(code)) : code === null || markdownLineEnding(code) ? (effects.exit("atxHeading"), ok2(code)) : markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : (effects.enter("atxHeadingText"), data(code));
}
function sequenceFurther(code) {
return code === 35 ? (effects.consume(code), sequenceFurther) : (effects.exit("atxHeadingSequence"), atBreak(code));
}
function data(code) {
return code === null || code === 35 || markdownLineEndingOrSpace(code) ? (effects.exit("atxHeadingText"), atBreak(code)) : (effects.consume(code), data);
}
}
var htmlBlockNames = [
"address",
"article",
"aside",
"base",
"basefont",
"blockquote",
"body",
"caption",
"center",
"col",
"colgroup",
"dd",
"details",
"dialog",
"dir",
"div",
"dl",
"dt",
"fieldset",
"figcaption",
"figure",
"footer",
"form",
"frame",
"frameset",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"head",
"header",
"hr",
"html",
"iframe",
"legend",
"li",
"link",
"main",
"menu",
"menuitem",
"nav",
"noframes",
"ol",
"optgroup",
"option",
"p",
"param",
"search",
"section",
"summary",
"table",
"tbody",
"td",
"tfoot",
"th",
"thead",
"title",
"tr",
"track",
"ul"
], htmlRawNames = ["pre", "script", "style", "textarea"];
var htmlFlow = {
name: "htmlFlow",
tokenize: tokenizeHtmlFlow,
resolveTo: resolveToHtmlFlow,
concrete: !0
}, blankLineBefore = {
tokenize: tokenizeBlankLineBefore,
partial: !0
}, nonLazyContinuationStart = {
tokenize: tokenizeNonLazyContinuationStart,
partial: !0
};
function resolveToHtmlFlow(events) {
let index2 = events.length;
for (; index2-- && !(events[index2][0] === "enter" && events[index2][1].type === "htmlFlow"); )
;
return index2 > 1 && events[index2 - 2][1].type === "linePrefix" && (events[index2][1].start = events[index2 - 2][1].start, events[index2 + 1][1].start = events[index2 - 2][1].start, events.splice(index2 - 2, 2)), events;
}
function tokenizeHtmlFlow(effects, ok2, nok) {
let self2 = this, marker, closingTag, buffer, index2, markerB;
return start;
function start(code) {
return before(code);
}
function before(code) {
return effects.enter("htmlFlow"), effects.enter("htmlFlowData"), effects.consume(code), open;
}
function open(code) {
return code === 33 ? (effects.consume(code), declarationOpen) : code === 47 ? (effects.consume(code), closingTag = !0, tagCloseStart) : code === 63 ? (effects.consume(code), marker = 3, self2.interrupt ? ok2 : continuationDeclarationInside) : asciiAlpha(code) ? (effects.consume(code), buffer = String.fromCharCode(code), tagName) : nok(code);
}
function declarationOpen(code) {
return code === 45 ? (effects.consume(code), marker = 2, commentOpenInside) : code === 91 ? (effects.consume(code), marker = 5, index2 = 0, cdataOpenInside) : asciiAlpha(code) ? (effects.consume(code), marker = 4, self2.interrupt ? ok2 : continuationDeclarationInside) : nok(code);
}
function commentOpenInside(code) {
return code === 45 ? (effects.consume(code), self2.interrupt ? ok2 : continuationDeclarationInside) : nok(code);
}
function cdataOpenInside(code) {
let value = "CDATA[";
return code === value.charCodeAt(index2++) ? (effects.consume(code), index2 === value.length ? self2.interrupt ? ok2 : continuation : cdataOpenInside) : nok(code);
}
function tagCloseStart(code) {
return asciiAlpha(code) ? (effects.consume(code), buffer = String.fromCharCode(code), tagName) : nok(code);
}
function tagName(code) {
if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
let slash = code === 47, name = buffer.toLowerCase();
return !slash && !closingTag && htmlRawNames.includes(name) ? (marker = 1, self2.interrupt ? ok2(code) : continuation(code)) : htmlBlockNames.includes(buffer.toLowerCase()) ? (marker = 6, slash ? (effects.consume(code), basicSelfClosing) : self2.interrupt ? ok2(code) : continuation(code)) : (marker = 7, self2.interrupt && !self2.parser.lazy[self2.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code));
}
return code === 45 || asciiAlphanumeric(code) ? (effects.consume(code), buffer += String.fromCharCode(code), tagName) : nok(code);
}
function basicSelfClosing(code) {
return code === 62 ? (effects.consume(code), self2.interrupt ? ok2 : continuation) : nok(code);
}
function completeClosingTagAfter(code) {
return markdownSpace(code) ? (effects.consume(code), completeClosingTagAfter) : completeEnd(code);
}
function completeAttributeNameBefore(code) {
return code === 47 ? (effects.consume(code), completeEnd) : code === 58 || code === 95 || asciiAlpha(code) ? (effects.consume(code), completeAttributeName) : markdownSpace(code) ? (effects.consume(code), completeAttributeNameBefore) : completeEnd(code);
}
function completeAttributeName(code) {
return code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code) ? (effects.consume(code), completeAttributeName) : completeAttributeNameAfter(code);
}
function completeAttributeNameAfter(code) {
return code === 61 ? (effects.consume(code), completeAttributeValueBefore) : markdownSpace(code) ? (effects.consume(code), completeAttributeNameAfter) : completeAttributeNameBefore(code);
}
function completeAttributeValueBefore(code) {
return code === null || code === 60 || code === 61 || code === 62 || code === 96 ? nok(code) : code === 34 || code === 39 ? (effects.consume(code), markerB = code, completeAttributeValueQuoted) : markdownSpace(code) ? (effects.consume(code), completeAttributeValueBefore) : completeAttributeValueUnquoted(code);
}
function completeAttributeValueQuoted(code) {
return code === markerB ? (effects.consume(code), markerB = null, completeAttributeValueQuotedAfter) : code === null || markdownLineEnding(code) ? nok(code) : (effects.consume(code), completeAttributeValueQuoted);
}
function completeAttributeValueUnquoted(code) {
return code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code) ? completeAttributeNameAfter(code) : (effects.consume(code), completeAttributeValueUnquoted);
}
function completeAttributeValueQuotedAfter(code) {
return code === 47 || code === 62 || markdownSpace(code) ? completeAttributeNameBefore(code) : nok(code);
}
function completeEnd(code) {
return code === 62 ? (effects.consume(code), completeAfter) : nok(code);
}
function completeAfter(code) {
return code === null || markdownLineEnding(code) ? continuation(code) : markdownSpace(code) ? (effects.consume(code), completeAfter) : nok(code);
}
function continuation(code) {
return code === 45 && marker === 2 ? (effects.consume(code), continuationCommentInside) : code === 60 && marker === 1 ? (effects.consume(code), continuationRawTagOpen) : code === 62 && marker === 4 ? (effects.consume(code), continuationClose) : code === 63 && marker === 3 ? (effects.consume(code), continuationDeclarationInside) : code === 93 && marker === 5 ? (effects.consume(code), continuationCdataInside) : markdownLineEnding(code) && (marker === 6 || marker === 7) ? (effects.exit("htmlFlowData"), effects.check(blankLineBefore, continuationAfter, continuationStart)(code)) : code === null || markdownLineEnding(code) ? (effects.exit("htmlFlowData"), continuationStart(code)) : (effects.consume(code), continuation);
}
function continuationStart(code) {
return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
}
function continuationStartNonLazy(code) {
return effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), continuationBefore;
}
function continuationBefore(code) {
return code === null || markdownLineEnding(code) ? continuationStart(code) : (effects.enter("htmlFlowData"), continuation(code));
}
function continuationCommentInside(code) {
return code === 45 ? (effects.consume(code), continuationDeclarationInside) : continuation(code);
}
function continuationRawTagOpen(code) {
return code === 47 ? (effects.consume(code), buffer = "", continuationRawEndTag) : continuation(code);
}
function continuationRawEndTag(code) {
if (code === 62) {
let name = buffer.toLowerCase();
return htmlRawNames.includes(name) ? (effects.consume(code), continuationClose) : continuation(code);
}
return asciiAlpha(code) && buffer.length < 8 ? (effects.consume(code), buffer += String.fromCharCode(code), continuationRawEndTag) : continuation(code);
}
function continuationCdataInside(code) {
return code === 93 ? (effects.consume(code), continuationDeclarationInside) : continuation(code);
}
function continuationDeclarationInside(code) {
return code === 62 ? (effects.consume(code), continuationClose) : code === 45 && marker === 2 ? (effects.consume(code), continuationDeclarationInside) : continuation(code);
}
function continuationClose(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("htmlFlowData"), continuationAfter(code)) : (effects.consume(code), continuationClose);
}
function continuationAfter(code) {
return effects.exit("htmlFlow"), ok2(code);
}
}
function tokenizeNonLazyContinuationStart(effects, ok2, nok) {
let self2 = this;
return start;
function start(code) {
return markdownLineEnding(code) ? (effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), after) : nok(code);
}
function after(code) {
return self2.parser.lazy[self2.now().line] ? nok(code) : ok2(code);
}
}
function tokenizeBlankLineBefore(effects, ok2, nok) {
return start;
function start(code) {
return effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), effects.attempt(blankLine, ok2, nok);
}
}
var htmlText = {
name: "htmlText",
tokenize: tokenizeHtmlText
};
function tokenizeHtmlText(effects, ok2, nok) {
let self2 = this, marker, index2, returnState;
return start;
function start(code) {
return effects.enter("htmlText"), effects.enter("htmlTextData"), effects.consume(code), open;
}
function open(code) {
return code === 33 ? (effects.consume(code), declarationOpen) : code === 47 ? (effects.consume(code), tagCloseStart) : code === 63 ? (effects.consume(code), instruction) : asciiAlpha(code) ? (effects.consume(code), tagOpen) : nok(code);
}
function declarationOpen(code) {
return code === 45 ? (effects.consume(code), commentOpenInside) : code === 91 ? (effects.consume(code), index2 = 0, cdataOpenInside) : asciiAlpha(code) ? (effects.consume(code), declaration) : nok(code);
}
function commentOpenInside(code) {
return code === 45 ? (effects.consume(code), commentEnd) : nok(code);
}
function comment(code) {
return code === null ? nok(code) : code === 45 ? (effects.consume(code), commentClose) : markdownLineEnding(code) ? (returnState = comment, lineEndingBefore(code)) : (effects.consume(code), comment);
}
function commentClose(code) {
return code === 45 ? (effects.consume(code), commentEnd) : comment(code);
}
function commentEnd(code) {
return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
}
function cdataOpenInside(code) {
let value = "CDATA[";
return code === value.charCodeAt(index2++) ? (effects.consume(code), index2 === value.length ? cdata : cdataOpenInside) : nok(code);
}
function cdata(code) {
return code === null ? nok(code) : code === 93 ? (effects.consume(code), cdataClose) : markdownLineEnding(code) ? (returnState = cdata, lineEndingBefore(code)) : (effects.consume(code), cdata);
}
function cdataClose(code) {
return code === 93 ? (effects.consume(code), cdataEnd) : cdata(code);
}
function cdataEnd(code) {
return code === 62 ? end(code) : code === 93 ? (effects.consume(code), cdataEnd) : cdata(code);
}
function declaration(code) {
return code === null || code === 62 ? end(code) : markdownLineEnding(code) ? (returnState = declaration, lineEndingBefore(code)) : (effects.consume(code), declaration);
}
function instruction(code) {
return code === null ? nok(code) : code === 63 ? (effects.consume(code), instructionClose) : markdownLineEnding(code) ? (returnState = instruction, lineEndingBefore(code)) : (effects.consume(code), instruction);
}
function instructionClose(code) {
return code === 62 ? end(code) : instruction(code);
}
function tagCloseStart(code) {
return asciiAlpha(code) ? (effects.consume(code), tagClose) : nok(code);
}
function tagClose(code) {
return code === 45 || asciiAlphanumeric(code) ? (effects.consume(code), tagClose) : tagCloseBetween(code);
}
function tagCloseBetween(code) {
return markdownLineEnding(code) ? (returnState = tagCloseBetween, lineEndingBefore(code)) : markdownSpace(code) ? (effects.consume(code), tagCloseBetween) : end(code);
}
function tagOpen(code) {
return code === 45 || asciiAlphanumeric(code) ? (effects.consume(code), tagOpen) : code === 47 || code === 62 || markdownLineEndingOrSpace(code) ? tagOpenBetween(code) : nok(code);
}
function tagOpenBetween(code) {
return code === 47 ? (effects.consume(code), end) : code === 58 || code === 95 || asciiAlpha(code) ? (effects.consume(code), tagOpenAttributeName) : markdownLineEnding(code) ? (returnState = tagOpenBetween, lineEndingBefore(code)) : markdownSpace(code) ? (effects.consume(code), tagOpenBetween) : end(code);
}
function tagOpenAttributeName(code) {
return code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code) ? (effects.consume(code), tagOpenAttributeName) : tagOpenAttributeNameAfter(code);
}
function tagOpenAttributeNameAfter(code) {
return code === 61 ? (effects.consume(code), tagOpenAttributeValueBefore) : markdownLineEnding(code) ? (returnState = tagOpenAttributeNameAfter, lineEndingBefore(code)) : markdownSpace(code) ? (effects.consume(code), tagOpenAttributeNameAfter) : tagOpenBetween(code);
}
function tagOpenAttributeValueBefore(code) {
return code === null || code === 60 || code === 61 || code === 62 || code === 96 ? nok(code) : code === 34 || code === 39 ? (effects.consume(code), marker = code, tagOpenAttributeValueQuoted) : markdownLineEnding(code) ? (returnState = tagOpenAttributeValueBefore, lineEndingBefore(code)) : markdownSpace(code) ? (effects.consume(code), tagOpenAttributeValueBefore) : (effects.consume(code), tagOpenAttributeValueUnquoted);
}
function tagOpenAttributeValueQuoted(code) {
return code === marker ? (effects.consume(code), marker = void 0, tagOpenAttributeValueQuotedAfter) : code === null ? nok(code) : markdownLineEnding(code) ? (returnState = tagOpenAttributeValueQuoted, lineEndingBefore(code)) : (effects.consume(code), tagOpenAttributeValueQuoted);
}
function tagOpenAttributeValueUnquoted(code) {
return code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96 ? nok(code) : code === 47 || code === 62 || markdownLineEndingOrSpace(code) ? tagOpenBetween(code) : (effects.consume(code), tagOpenAttributeValueUnquoted);
}
function tagOpenAttributeValueQuotedAfter(code) {
return code === 47 || code === 62 || markdownLineEndingOrSpace(code) ? tagOpenBetween(code) : nok(code);
}
function end(code) {
return code === 62 ? (effects.consume(code), effects.exit("htmlTextData"), effects.exit("htmlText"), ok2) : nok(code);
}
function lineEndingBefore(code) {
return effects.exit("htmlTextData"), effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), lineEndingAfter;
}
function lineEndingAfter(code) {
return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self2.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : lineEndingAfterPrefix(code);
}
function lineEndingAfterPrefix(code) {
return effects.enter("htmlTextData"), returnState(code);
}
}
var labelEnd = {
name: "labelEnd",
tokenize: tokenizeLabelEnd,
resolveTo: resolveToLabelEnd,
resolveAll: resolveAllLabelEnd
}, resourceConstruct = {
tokenize: tokenizeResource
}, referenceFullConstruct = {
tokenize: tokenizeReferenceFull
}, referenceCollapsedConstruct = {
tokenize: tokenizeReferenceCollapsed
};
function resolveAllLabelEnd(events) {
let index2 = -1;
for (; ++index2 < events.length; ) {
let token = events[index2][1];
(token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") && (events.splice(index2 + 1, token.type === "labelImage" ? 4 : 2), token.type = "data", index2++);
}
return events;
}
function resolveToLabelEnd(events, context) {
let index2 = events.length, offset = 0, token, open, close, media;
for (; index2--; )
if (token = events[index2][1], open) {
if (token.type === "link" || token.type === "labelLink" && token._inactive)
break;
events[index2][0] === "enter" && token.type === "labelLink" && (token._inactive = !0);
} else if (close) {
if (events[index2][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced && (open = index2, token.type !== "labelLink")) {
offset = 2;
break;
}
} else token.type === "labelEnd" && (close = index2);
let group = {
type: events[open][1].type === "labelLink" ? "link" : "image",
start: Object.assign({}, events[open][1].start),
end: Object.assign({}, events[events.length - 1][1].end)
}, label = {
type: "label",
start: Object.assign({}, events[open][1].start),
end: Object.assign({}, events[close][1].end)
}, text3 = {
type: "labelText",
start: Object.assign({}, events[open + offset + 2][1].end),
end: Object.assign({}, events[close - 2][1].start)
};
return media = [["enter", group, context], ["enter", label, context]], media = push(media, events.slice(open + 1, open + offset + 3)), media = push(media, [["enter", text3, context]]), media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context)), media = push(media, [["exit", text3, context], events[close - 2], events[close - 1], ["exit", label, context]]), media = push(media, events.slice(close + 1)), media = push(media, [["exit", group, context]]), splice(events, open, events.length, media), events;
}
function tokenizeLabelEnd(effects, ok2, nok) {
let self2 = this, index2 = self2.events.length, labelStart, defined;
for (; index2--; )
if ((self2.events[index2][1].type === "labelImage" || self2.events[index2][1].type === "labelLink") && !self2.events[index2][1]._balanced) {
labelStart = self2.events[index2][1];
break;
}
return start;
function start(code) {
return labelStart ? labelStart._inactive ? labelEndNok(code) : (defined = self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize({
start: labelStart.end,
end: self2.now()
}))), effects.enter("labelEnd"), effects.enter("labelMarker"), effects.consume(code), effects.exit("labelMarker"), effects.exit("labelEnd"), after) : nok(code);
}
function after(code) {
return code === 40 ? effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code) : code === 91 ? effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code) : defined ? labelEndOk(code) : labelEndNok(code);
}
function referenceNotFull(code) {
return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);
}
function labelEndOk(code) {
return ok2(code);
}
function labelEndNok(code) {
return labelStart._balanced = !0, nok(code);
}
}
function tokenizeResource(effects, ok2, nok) {
return resourceStart;
function resourceStart(code) {
return effects.enter("resource"), effects.enter("resourceMarker"), effects.consume(code), effects.exit("resourceMarker"), resourceBefore;
}
function resourceBefore(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
}
function resourceOpen(code) {
return code === 41 ? resourceEnd(code) : factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(code);
}
function resourceDestinationAfter(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
}
function resourceDestinationMissing(code) {
return nok(code);
}
function resourceBetween(code) {
return code === 34 || code === 39 || code === 40 ? factoryTitle(effects, resourceTitleAfter, nok, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(code) : resourceEnd(code);
}
function resourceTitleAfter(code) {
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
}
function resourceEnd(code) {
return code === 41 ? (effects.enter("resourceMarker"), effects.consume(code), effects.exit("resourceMarker"), effects.exit("resource"), ok2) : nok(code);
}
}
function tokenizeReferenceFull(effects, ok2, nok) {
let self2 = this;
return referenceFull;
function referenceFull(code) {
return factoryLabel.call(self2, effects, referenceFullAfter, referenceFullMissing, "reference", "referenceMarker", "referenceString")(code);
}
function referenceFullAfter(code) {
return self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length - 1][1]).slice(1, -1))) ? ok2(code) : nok(code);
}
function referenceFullMissing(code) {
return nok(code);
}
}
function tokenizeReferenceCollapsed(effects, ok2, nok) {
return referenceCollapsedStart;
function referenceCollapsedStart(code) {
return effects.enter("reference"), effects.enter("referenceMarker"), effects.consume(code), effects.exit("referenceMarker"), referenceCollapsedOpen;
}
function referenceCollapsedOpen(code) {
return code === 93 ? (effects.enter("referenceMarker"), effects.consume(code), effects.exit("referenceMarker"), effects.exit("reference"), ok2) : nok(code);
}
}
var labelStartImage = {
name: "labelStartImage",
tokenize: tokenizeLabelStartImage,
resolveAll: labelEnd.resolveAll
};
function tokenizeLabelStartImage(effects, ok2, nok) {
let self2 = this;
return start;
function start(code) {
return effects.enter("labelImage"), effects.enter("labelImageMarker"), effects.consume(code), effects.exit("labelImageMarker"), open;
}
function open(code) {
return code === 91 ? (effects.enter("labelMarker"), effects.consume(code), effects.exit("labelMarker"), effects.exit("labelImage"), after) : nok(code);
}
function after(code) {
return code === 94 && "_hiddenFootnoteSupport" in self2.parser.constructs ? nok(code) : ok2(code);
}
}
var labelStartLink = {
name: "labelStartLink",
tokenize: tokenizeLabelStartLink,
resolveAll: labelEnd.resolveAll
};
function tokenizeLabelStartLink(effects, ok2, nok) {
let self2 = this;
return start;
function start(code) {
return effects.enter("labelLink"), effects.enter("labelMarker"), effects.consume(code), effects.exit("labelMarker"), effects.exit("labelLink"), after;
}
function after(code) {
return code === 94 && "_hiddenFootnoteSupport" in self2.parser.constructs ? nok(code) : ok2(code);
}
}
var lineEnding = {
name: "lineEnding",
tokenize: tokenizeLineEnding
};
function tokenizeLineEnding(effects, ok2) {
return start;
function start(code) {
return effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), factorySpace(effects, ok2, "linePrefix");
}
}
var thematicBreak = {
name: "thematicBreak",
tokenize: tokenizeThematicBreak
};
function tokenizeThematicBreak(effects, ok2, nok) {
let size = 0, marker;
return start;
function start(code) {
return effects.enter("thematicBreak"), before(code);
}
function before(code) {
return marker = code, atBreak(code);
}
function atBreak(code) {
return code === marker ? (effects.enter("thematicBreakSequence"), sequence(code)) : size >= 3 && (code === null || markdownLineEnding(code)) ? (effects.exit("thematicBreak"), ok2(code)) : nok(code);
}
function sequence(code) {
return code === marker ? (effects.consume(code), size++, sequence) : (effects.exit("thematicBreakSequence"), markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code));
}
}
var list = {
name: "list",
tokenize: tokenizeListStart,
continuation: {
tokenize: tokenizeListContinuation
},
exit: tokenizeListEnd
}, listItemPrefixWhitespaceConstruct = {
tokenize: tokenizeListItemPrefixWhitespace,
partial: !0
}, indentConstruct = {
tokenize: tokenizeIndent,
partial: !0
};
function tokenizeListStart(effects, ok2, nok) {
let self2 = this, tail = self2.events[self2.events.length - 1], initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], !0).length : 0, size = 0;
return start;
function start(code) {
let kind = self2.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered");
if (kind === "listUnordered" ? !self2.containerState.marker || code === self2.containerState.marker : asciiDigit(code)) {
if (self2.containerState.type || (self2.containerState.type = kind, effects.enter(kind, {
_container: !0
})), kind === "listUnordered")
return effects.enter("listItemPrefix"), code === 42 || code === 45 ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code);
if (!self2.interrupt || code === 49)
return effects.enter("listItemPrefix"), effects.enter("listItemValue"), inside(code);
}
return nok(code);
}
function inside(code) {
return asciiDigit(code) && ++size < 10 ? (effects.consume(code), inside) : (!self2.interrupt || size < 2) && (self2.containerState.marker ? code === self2.containerState.marker : code === 41 || code === 46) ? (effects.exit("listItemValue"), atMarker(code)) : nok(code);
}
function atMarker(code) {
return effects.enter("listItemMarker"), effects.consume(code), effects.exit("listItemMarker"), self2.containerState.marker = self2.containerState.marker || code, effects.check(
blankLine,
self2.interrupt ? nok : onBlank,
effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix)
);
}
function onBlank(code) {
return self2.containerState.initialBlankLine = !0, initialSize++, endOfPrefix(code);
}
function otherPrefix(code) {
return markdownSpace(code) ? (effects.enter("listItemPrefixWhitespace"), effects.consume(code), effects.exit("listItemPrefixWhitespace"), endOfPrefix) : nok(code);
}
function endOfPrefix(code) {
return self2.containerState.size = initialSize + self2.sliceSerialize(effects.exit("listItemPrefix"), !0).length, ok2(code);
}
}
function tokenizeListContinuation(effects, ok2, nok) {
let self2 = this;
return self2.containerState._closeFlow = void 0, effects.check(blankLine, onBlank, notBlank);
function onBlank(code) {
return self2.containerState.furtherBlankLines = self2.containerState.furtherBlankLines || self2.containerState.initialBlankLine, factorySpace(effects, ok2, "listItemIndent", self2.containerState.size + 1)(code);
}
function notBlank(code) {
return self2.containerState.furtherBlankLines || !markdownSpace(code) ? (self2.containerState.furtherBlankLines = void 0, self2.containerState.initialBlankLine = void 0, notInCurrentItem(code)) : (self2.containerState.furtherBlankLines = void 0, self2.containerState.initialBlankLine = void 0, effects.attempt(indentConstruct, ok2, notInCurrentItem)(code));
}
function notInCurrentItem(code) {
return self2.containerState._closeFlow = !0, self2.interrupt = void 0, factorySpace(effects, effects.attempt(list, ok2, nok), "linePrefix", self2.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
}
}
function tokenizeIndent(effects, ok2, nok) {
let self2 = this;
return factorySpace(effects, afterPrefix, "listItemIndent", self2.containerState.size + 1);
function afterPrefix(code) {
let tail = self2.events[self2.events.length - 1];
return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], !0).length === self2.containerState.size ? ok2(code) : nok(code);
}
}
function tokenizeListEnd(effects) {
effects.exit(this.containerState.type);
}
function tokenizeListItemPrefixWhitespace(effects, ok2, nok) {
let self2 = this;
return factorySpace(effects, afterPrefix, "listItemPrefixWhitespace", self2.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 5);
function afterPrefix(code) {
let tail = self2.events[self2.events.length - 1];
return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok2(code) : nok(code);
}
}
var setextUnderline = {
name: "setextUnderline",
tokenize: tokenizeSetextUnderline,
resolveTo: resolveToSetextUnderline
};
function resolveToSetextUnderline(events, context) {
let index2 = events.length, content3, text3, definition2;
for (; index2--; )
if (events[index2][0] === "enter") {
if (events[index2][1].type === "content") {
content3 = index2;
break;
}
events[index2][1].type === "paragraph" && (text3 = index2);
} else
events[index2][1].type === "content" && events.splice(index2, 1), !definition2 && events[index2][1].type === "definition" && (definition2 = index2);
let heading = {
type: "setextHeading",
start: Object.assign({}, events[text3][1].start),
end: Object.assign({}, events[events.length - 1][1].end)
};
return events[text3][1].type = "setextHeadingText", definition2 ? (events.splice(text3, 0, ["enter", heading, context]), events.splice(definition2 + 1, 0, ["exit", events[content3][1], context]), events[content3][1].end = Object.assign({}, events[definition2][1].end)) : events[content3][1] = heading, events.push(["exit", heading, context]), events;
}
function tokenizeSetextUnderline(effects, ok2, nok) {
let self2 = this, marker;
return start;
function start(code) {
let index2 = self2.events.length, paragraph;
for (; index2--; )
if (self2.events[index2][1].type !== "lineEnding" && self2.events[index2][1].type !== "linePrefix" && self2.events[index2][1].type !== "content") {
paragraph = self2.events[index2][1].type === "paragraph";
break;
}
return !self2.parser.lazy[self2.now().line] && (self2.interrupt || paragraph) ? (effects.enter("setextHeadingLine"), marker = code, before(code)) : nok(code);
}
function before(code) {
return effects.enter("setextHeadingLineSequence"), inside(code);
}
function inside(code) {
return code === marker ? (effects.consume(code), inside) : (effects.exit("setextHeadingLineSequence"), markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code));
}
function after(code) {
return code === null || markdownLineEnding(code) ? (effects.exit("setextHeadingLine"), ok2(code)) : nok(code);
}
}
var flow = {
tokenize: initializeFlow
};
function initializeFlow(effects) {
let self2 = this, initial = effects.attempt(
blankLine,
atBlankEnding,
effects.attempt(
this.parser.constructs.flowInitial,
afterConstruct,
factorySpace(
effects,
effects.attempt(
this.parser.constructs.flow,
afterConstruct,
effects.attempt(content2, afterConstruct)
),
"linePrefix"
)
)
);
return initial;
function atBlankEnding(code) {
if (code === null) {
effects.consume(code);
return;
}
return effects.enter("lineEndingBlank"), effects.consume(code), effects.exit("lineEndingBlank"), self2.currentConstruct = void 0, initial;
}
function afterConstruct(code) {
if (code === null) {
effects.consume(code);
return;
}
return effects.enter("lineEnding"), effects.consume(code), effects.exit("lineEnding"), self2.currentConstruct = void 0, initial;
}
}
var resolver = {
resolveAll: createResolver()
}, string = initializeFactory("string"), text = initializeFactory("text");
function initializeFactory(field) {
return {
tokenize: initializeText,
resolveAll: createResolver(
field === "text" ? resolveAllLineSuffixes : void 0
)
};
function initializeText(effects) {
let self2 = this, constructs2 = this.parser.constructs[field], text3 = effects.attempt(constructs2, start, notText);
return start;
function start(code) {
return atBreak(code) ? text3(code) : notText(code);
}
function notText(code) {
if (code === null) {
effects.consume(code);
return;
}
return effects.enter("data"), effects.consume(code), data;
}
function data(code) {
return atBreak(code) ? (effects.exit("data"), text3(code)) : (effects.consume(code), data);
}
function atBreak(code) {
if (code === null)
return !0;
let list2 = constructs2[code], index2 = -1;
if (list2)
for (; ++index2 < list2.length; ) {
let item = list2[index2];
if (!item.previous || item.previous.call(self2, self2.previous))
return !0;
}
return !1;
}
}
}
function createResolver(extraResolver) {
return resolveAllText;
function resolveAllText(events, context) {
let index2 = -1, enter;
for (; ++index2 <= events.length; )
enter === void 0 ? events[index2] && events[index2][1].type === "data" && (enter = index2, index2++) : (!events[index2] || events[index2][1].type !== "data") && (index2 !== enter + 2 && (events[enter][1].end = events[index2 - 1][1].end, events.splice(enter + 2, index2 - enter - 2), index2 = enter + 2), enter = void 0);
return extraResolver ? extraResolver(events, context) : events;
}
}
function resolveAllLineSuffixes(events, context) {
let eventIndex = 0;
for (; ++eventIndex <= events.length; )
if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
let data = events[eventIndex - 1][1], chunks = context.sliceStream(data), index2 = chunks.length, bufferIndex = -1, size = 0, tabs;
for (; index2--; ) {
let chunk = chunks[index2];
if (typeof chunk == "string") {
for (bufferIndex = chunk.length; chunk.charCodeAt(bufferIndex - 1) === 32; )
size++, bufferIndex--;
if (bufferIndex) break;
bufferIndex = -1;
} else if (chunk === -2)
tabs = !0, size++;
else if (chunk !== -1) {
index2++;
break;
}
}
if (size) {
let token = {
type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
start: {
line: data.end.line,
column: data.end.column - size,
offset: data.end.offset - size,
_index: data.start._index + index2,
_bufferIndex: index2 ? bufferIndex : data.start._bufferIndex + bufferIndex
},
end: Object.assign({}, data.end)
};
data.end = Object.assign({}, token.start), data.start.offset === data.end.offset ? Object.assign(data, token) : (events.splice(
eventIndex,
0,
["enter", token, context],
["exit", token, context]
), eventIndex += 2);
}
eventIndex++;
}
return events;
}
function createTokenizer(parser, initialize, from) {
let point3 = Object.assign(
from ? Object.assign({}, from) : {
line: 1,
column: 1,
offset: 0
},
{
_index: 0,
_bufferIndex: -1
}
), columnStart = {}, resolveAllConstructs = [], chunks = [], stack = [], consumed = !0, effects = {
consume,
enter,
exit: exit2,
attempt: constructFactory(onsuccessfulconstruct),
check: constructFactory(onsuccessfulcheck),
interrupt: constructFactory(onsuccessfulcheck, {
interrupt: !0
})
}, context = {
previous: null,
code: null,
containerState: {},
events: [],
parser,
sliceStream,
sliceSerialize,
now,
defineSkip,
write
}, state = initialize.tokenize.call(context, effects), expectedCode;
return initialize.resolveAll && resolveAllConstructs.push(initialize), context;
function write(slice) {
return chunks = push(chunks, slice), main(), chunks[chunks.length - 1] !== null ? [] : (addResult(initialize, 0), context.events = resolveAll(resolveAllConstructs, context.events, context), context.events);
}
function sliceSerialize(token, expandTabs) {
return serializeChunks(sliceStream(token), expandTabs);
}
function sliceStream(token) {
return sliceChunks(chunks, token);
}
function now() {
let { line, column, offset, _index, _bufferIndex } = point3;
return {
line,
column,
offset,
_index,
_bufferIndex
};
}
function defineSkip(value) {
columnStart[value.line] = value.column, accountForPotentialSkip();
}
function main() {
let chunkIndex;
for (; point3._index < chunks.length; ) {
let chunk = chunks[point3._index];
if (typeof chunk == "string")
for (chunkIndex = point3._index, point3._bufferIndex < 0 && (point3._bufferIndex = 0); point3._index === chunkIndex && point3._bufferIndex < chunk.length; )
go(chunk.charCodeAt(point3._bufferIndex));
else
go(chunk);
}
}
function go(code) {
consumed = void 0, expectedCode = code, state = state(code);
}
function consume(code) {
markdownLineEnding(code) ? (point3.line++, point3.column = 1, point3.offset += code === -3 ? 2 : 1, accountForPotentialSkip()) : code !== -1 && (point3.column++, point3.offset++), point3._bufferIndex < 0 ? point3._index++ : (point3._bufferIndex++, point3._bufferIndex === chunks[point3._index].length && (point3._bufferIndex = -1, point3._index++)), context.previous = code, consumed = !0;
}
function enter(type, fields) {
let token = fields || {};
return token.type = type, token.start = now(), context.events.push(["enter", token, context]), stack.push(token), token;
}
function exit2(type) {
let token = stack.pop();
return token.end = now(), context.events.push(["exit", token, context]), token;
}
function onsuccessfulconstruct(construct, info) {
addResult(construct, info.from);
}
function onsuccessfulcheck(_, info) {
info.restore();
}
function constructFactory(onreturn, fields) {
return hook;
function hook(constructs2, returnState, bogusState) {
let listOfConstructs, constructIndex, currentConstruct, info;
return Array.isArray(constructs2) ? handleListOfConstructs(constructs2) : "tokenize" in constructs2 ? (
handleListOfConstructs([constructs2])
) : handleMapOfConstructs(constructs2);
function handleMapOfConstructs(map) {
return start;
function start(code) {
let def = code !== null && map[code], all2 = code !== null && map.null, list2 = [
...Array.isArray(def) ? def : def ? [def] : [],
...Array.isArray(all2) ? all2 : all2 ? [all2] : []
];
return handleListOfConstructs(list2)(code);
}
}
function handleListOfConstructs(list2) {
return listOfConstructs = list2, constructIndex = 0, list2.length === 0 ? bogusState : handleConstruct(list2[constructIndex]);
}
function handleConstruct(construct) {
return start;
function start(code) {
return info = store(), currentConstruct = construct, construct.partial || (context.currentConstruct = construct), construct.name && context.parser.constructs.disable.null.includes(construct.name) ? nok(code) : construct.tokenize.call(
fields ? Object.assign(Object.create(context), fields) : context,
effects,
ok2,
nok
)(code);
}
}
function ok2(code) {
return consumed = !0, onreturn(currentConstruct, info), returnState;
}
function nok(code) {
return consumed = !0, info.restore(), ++constructIndex < listOfConstructs.length ? handleConstruct(listOfConstructs[constructIndex]) : bogusState;
}
}
}
function addResult(construct, from2) {
construct.resolveAll && !resolveAllConstructs.includes(construct) && resolveAllConstructs.push(construct), construct.resolve && splice(
context.events,
from2,
context.events.length - from2,
construct.resolve(context.events.slice(from2), context)
), construct.resolveTo && (context.events = construct.resolveTo(context.events, context));
}
function store() {
let startPoint = now(), startPrevious = context.previous, startCurrentConstruct = context.currentConstruct, startEventsIndex = context.events.length, startStack = Array.from(stack);
return {
restore,
from: startEventsIndex
};
function restore() {
point3 = startPoint, context.previous = startPrevious, context.currentConstruct = startCurrentConstruct, context.events.length = startEventsIndex, stack = startStack, accountForPotentialSkip();
}
}
function accountForPotentialSkip() {
point3.line in columnStart && point3.column < 2 && (point3.column = columnStart[point3.line], point3.offset += columnStart[point3.line] - 1);
}
}
function sliceChunks(chunks, token) {
let startIndex = token.start._index, startBufferIndex = token.start._bufferIndex, endIndex = token.end._index, endBufferIndex = token.end._bufferIndex, view;
if (startIndex === endIndex)
view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
else {
if (view = chunks.slice(startIndex, endIndex), startBufferIndex > -1) {
let head = view[0];
typeof head == "string" ? view[0] = head.slice(startBufferIndex) : view.shift();
}
endBufferIndex > 0 && view.push(chunks[endIndex].slice(0, endBufferIndex));
}
return view;
}
function serializeChunks(chunks, expandTabs) {
let index2 = -1, result = [], atTab;
for (; ++index2 < chunks.length; ) {
let chunk = chunks[index2], value;
if (typeof chunk == "string")
value = chunk;
else
switch (chunk) {
case -5: {
value = "\r";
break;
}
case -4: {
value = `
`;
break;
}
case -3: {
value = `\r
`;
break;
}
case -2: {
value = expandTabs ? " " : " ";
break;
}
case -1: {
if (!expandTabs && atTab) continue;
value = " ";
break;
}
default:
value = String.fromCharCode(chunk);
}
atTab = chunk === -2, result.push(value);
}
return result.join("");
}
var constructs_exports = {};
__export(constructs_exports, {
attentionMarkers: () => attentionMarkers,
contentInitial: () => contentInitial,
disable: () => disable,
document: () => document3,
flow: () => flow2,
flowInitial: () => flowInitial,
insideSpan: () => insideSpan,
string: () => string2,
text: () => text2
});
var document3 = {
42: list,
43: list,
45: list,
48: list,
49: list,
50: list,
51: list,
52: list,
53: list,
54: list,
55: list,
56: list,
57: list,
62: blockQuote
}, contentInitial = {
91: definition
}, flowInitial = {
[-2]: codeIndented,
[-1]: codeIndented,
32: codeIndented
}, flow2 = {
35: headingAtx,
42: thematicBreak,
45: [setextUnderline, thematicBreak],
60: htmlFlow,
61: setextUnderline,
95: thematicBreak,
96: codeFenced,
126: codeFenced
}, string2 = {
38: characterReference,
92: characterEscape
}, text2 = {
[-5]: lineEnding,
[-4]: lineEnding,
[-3]: lineEnding,
33: labelStartImage,
38: characterReference,
42: attention,
60: [autolink, htmlText],
91: labelStartLink,
92: [hardBreakEscape, characterEscape],
93: labelEnd,
95: attention,
96: codeText
}, insideSpan = {
null: [attention, resolver]
}, attentionMarkers = {
null: [42, 95]
}, disable = {
null: []
};
function parse(options) {
let constructs2 = (
combineExtensions([constructs_exports, ...(options || {}).extensions || []])
), parser = {
defined: [],
lazy: {},
constructs: constructs2,
content: create(content),
document: create(document2),
flow: create(flow),
string: create(string),
text: create(text)
};
return parser;
function create(initial) {
return creator;
function creator(from) {
return createTokenizer(parser, initial, from);
}
}
}
function postprocess(events) {
for (; !subtokenize(events); )
;
return events;
}
var search = /[\0\t\n\r]/g;
function preprocess() {
let column = 1, buffer = "", start = !0, atCarriageReturn;
return preprocessor;
function preprocessor(value, encoding, end) {
let chunks = [], match, next, startPosition, endPosition, code;
for (value = buffer + (typeof value == "string" ? value.toString() : new TextDecoder(encoding || void 0).decode(value)), startPosition = 0, buffer = "", start && (value.charCodeAt(0) === 65279 && startPosition++, start = void 0); startPosition < value.length; ) {
if (search.lastIndex = startPosition, match = search.exec(value), endPosition = match && match.index !== void 0 ? match.index : value.length, code = value.charCodeAt(endPosition), !match) {
buffer = value.slice(startPosition);
break;
}
if (code === 10 && startPosition === endPosition && atCarriageReturn)
chunks.push(-3), atCarriageReturn = void 0;
else
switch (atCarriageReturn && (chunks.push(-5), atCarriageReturn = void 0), startPosition < endPosition && (chunks.push(value.slice(startPosition, endPosition)), column += endPosition - startPosition), code) {
case 0: {
chunks.push(65533), column++;
break;
}
case 9: {
for (next = Math.ceil(column / 4) * 4, chunks.push(-2); column++ < next; ) chunks.push(-1);
break;
}
case 10: {
chunks.push(-4), column = 1;
break;
}
default:
atCarriageReturn = !0, column = 1;
}
startPosition = endPosition + 1;
}
return end && (atCarriageReturn && chunks.push(-5), buffer && chunks.push(buffer), chunks.push(null)), chunks;
}
}
var characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
function decodeString(value) {
return value.replace(characterEscapeOrReference, decode);
}
function decode($0, $1, $2) {
if ($1)
return $1;
if ($2.charCodeAt(0) === 35) {
let head2 = $2.charCodeAt(1), hex = head2 === 120 || head2 === 88;
return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);
}
return decodeNamedCharacterReference($2) || $0;
}
function stringifyPosition(value) {
return !value || typeof value != "object" ? "" : "position" in value || "type" in value ? position(value.position) : "start" in value || "end" in value ? position(value) : "line" in value || "column" in value ? point(value) : "";
}
function point(point3) {
return index(point3 && point3.line) + ":" + index(point3 && point3.column);
}
function position(pos) {
return point(pos && pos.start) + "-" + point(pos && pos.end);
}
function index(value) {
return value && typeof value == "number" ? value : 1;
}
var own = {}.hasOwnProperty;
function fromMarkdown(value, encoding, options) {
return typeof encoding != "string" && (options = encoding, encoding = void 0), compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, !0))));
}
function compiler(options) {
let config = {
transforms: [],
canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
enter: {
autolink: opener(link),
autolinkProtocol: onenterdata,
autolinkEmail: onenterdata,
atxHeading: opener(heading),
blockQuote: opener(blockQuote2),
characterEscape: onenterdata,
characterReference: onenterdata,
codeFenced: opener(codeFlow),
codeFencedFenceInfo: buffer,
codeFencedFenceMeta: buffer,
codeIndented: opener(codeFlow, buffer),
codeText: opener(codeText2, buffer),
codeTextData: onenterdata,
data: onenterdata,
codeFlowValue: onenterdata,
definition: opener(definition2),
definitionDestinationString: buffer,
definitionLabelString: buffer,
definitionTitleString: buffer,
emphasis: opener(emphasis),
hardBreakEscape: opener(hardBreak),
hardBreakTrailing: opener(hardBreak),
htmlFlow: opener(html, buffer),
htmlFlowData: onenterdata,
htmlText: opener(html, buffer),
htmlTextData: onenterdata,
image: opener(image),
label: buffer,
link: opener(link),
listItem: opener(listItem),
listItemValue: onenterlistitemvalue,
listOrdered: opener(list2, onenterlistordered),
listUnordered: opener(list2),
paragraph: opener(paragraph),
reference: onenterreference,
referenceString: buffer,
resourceDestinationString: buffer,
resourceTitleString: buffer,
setextHeading: opener(heading),
strong: opener(strong),
thematicBreak: opener(thematicBreak2)
},
exit: {
atxHeading: closer(),
atxHeadingSequence: onexitatxheadingsequence,
autolink: closer(),
autolinkEmail: onexitautolinkemail,
autolinkProtocol: onexitautolinkprotocol,
blockQuote: closer(),
characterEscapeValue: onexitdata,
characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,
characterReferenceMarkerNumeric: onexitcharacterreferencemarker,
characterReferenceValue: onexitcharacterreferencevalue,
characterReference: onexitcharacterreference,
codeFenced: closer(onexitcodefenced),
codeFencedFence: onexitcodefencedfence,
codeFencedFenceInfo: onexitcodefencedfenceinfo,
codeFencedFenceMeta: onexitcodefencedfencemeta,
codeFlowValue: onexitdata,
codeIndented: closer(onexitcodeindented),
codeText: closer(onexitcodetext),
codeTextData: onexitdata,
data: onexitdata,
definition: closer(),
definitionDestinationString: onexitdefinitiondestinationstring,
definitionLabelString: onexitdefinitionlabelstring,
definitionTitleString: onexitdefinitiontitlestring,
emphasis: closer(),
hardBreakEscape: closer(onexithardbreak),
hardBreakTrailing: closer(onexithardbreak),
htmlFlow: closer(onexithtmlflow),
htmlFlowData: onexitdata,
htmlText: closer(onexithtmltext),
htmlTextData: onexitdata,
image: closer(onexitimage),
label: onexitlabel,
labelText: onexitlabeltext,
lineEnding: onexitlineending,
link: closer(onexitlink),
listItem: closer(),
listOrdered: closer(),
listUnordered: closer(),
paragraph: closer(),
referenceString: onexitreferencestring,
resourceDestinationString: onexitresourcedestinationstring,
resourceTitleString: onexitresourcetitlestring,
resource: onexitresource,
setextHeading: closer(onexitsetextheading),
setextHeadingLineSequence: onexitsetextheadinglinesequence,
setextHeadingText: onexitsetextheadingtext,
strong: closer(),
thematicBreak: closer()
}
};
configure(config, (options || {}).mdastExtensions || []);
let data = {};
return compile;
function compile(events) {
let tree = {
type: "root",
children: []
}, context = {
stack: [tree],
tokenStack: [],
config,
enter,
exit: exit2,
buffer,
resume,
data
}, listStack = [], index2 = -1;
for (; ++index2 < events.length; )
if (events[index2][1].type === "listOrdered" || events[index2][1].type === "listUnordered")
if (events[index2][0] === "enter")
listStack.push(index2);
else {
let tail = listStack.pop();
index2 = prepareList(events, tail, index2);
}
for (index2 = -1; ++index2 < events.length; ) {
let handler = config[events[index2][0]];
own.call(handler, events[index2][1].type) && handler[events[index2][1].type].call(Object.assign({
sliceSerialize: events[index2][2].sliceSerialize
}, context), events[index2][1]);
}
if (context.tokenStack.length > 0) {
let tail = context.tokenStack[context.tokenStack.length - 1];
(tail[1] || defaultOnError).call(context, void 0, tail[0]);
}
for (tree.position = {
start: point2(events.length > 0 ? events[0][1].start : {
line: 1,
column: 1,
offset: 0
}),
end: point2(events.length > 0 ? events[events.length - 2][1].end : {
line: 1,
column: 1,
offset: 0
})
}, index2 = -1; ++index2 < config.transforms.length; )
tree = config.transforms[index2](tree) || tree;
return tree;
}
function prepareList(events, start, length) {
let index2 = start - 1, containerBalance = -1, listSpread = !1, listItem2, lineIndex, firstBlankLineIndex, atMarker;
for (; ++index2 <= length; ) {
let event = events[index2];
switch (event[1].type) {
case "listUnordered":
case "listOrdered":
case "blockQuote": {
event[0] === "enter" ? containerBalance++ : containerBalance--, atMarker = void 0;
break;
}
case "lineEndingBlank": {
event[0] === "enter" && (listItem2 && !atMarker && !containerBalance && !firstBlankLineIndex && (firstBlankLineIndex = index2), atMarker = void 0);
break;
}
case "linePrefix":
case "listItemValue":
case "listItemMarker":
case "listItemPrefix":
case "listItemPrefixWhitespace":
break;
default:
atMarker = void 0;
}
if (!containerBalance && event[0] === "enter" && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === "exit" && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) {
if (listItem2) {
let tailIndex = index2;
for (lineIndex = void 0; tailIndex--; ) {
let tailEvent = events[tailIndex];
if (tailEvent[1].type === "lineEnding" || tailEvent[1].type === "lineEndingBlank") {
if (tailEvent[0] === "exit") continue;
lineIndex && (events[lineIndex][1].type = "lineEndingBlank", listSpread = !0), tailEvent[1].type = "lineEnding", lineIndex = tailIndex;
} else if (!(tailEvent[1].type === "linePrefix" || tailEvent[1].type === "blockQuotePrefix" || tailEvent[1].type === "blockQuotePrefixWhitespace" || tailEvent[1].type === "blockQuoteMarker" || tailEvent[1].type === "listItemIndent"))
break;
}
firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex) && (listItem2._spread = !0), listItem2.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end), events.splice(lineIndex || index2, 0, ["exit", listItem2, event[2]]), index2++, length++;
}
if (event[1].type === "listItemPrefix") {
let item = {
type: "listItem",
_spread: !1,
start: Object.assign({}, event[1].start),
end: void 0
};
listItem2 = item, events.splice(index2, 0, ["enter", item, event[2]]), index2++, length++, firstBlankLineIndex = void 0, atMarker = !0;
}
}
}
return events[start][1]._spread = listSpread, length;
}
function opener(create, and) {
return open;
function open(token) {
enter.call(this, create(token), token), and && and.call(this, token);
}
}
function buffer() {
this.stack.push({
type: "fragment",
children: []
});
}
function enter(node2, token, errorHandler) {
this.stack[this.stack.length - 1].children.push(node2), this.stack.push(node2), this.tokenStack.push([token, errorHandler]), node2.position = {
start: point2(token.start),
end: void 0
};
}
function closer(and) {
return close;
function close(token) {
and && and.call(this, token), exit2.call(this, token);
}
}
function exit2(token, onExitError) {
let node2 = this.stack.pop(), open = this.tokenStack.pop();
if (open)
open[0].type !== token.type && (onExitError ? onExitError.call(this, token, open[0]) : (open[1] || defaultOnError).call(this, token, open[0]));
else throw new Error("Cannot close `" + token.type + "` (" + stringifyPosition({
start: token.start,
end: token.end
}) + "): it\u2019s not open");
node2.position.end = point2(token.end);
}
function resume() {
return toString(this.stack.pop());
}
function onenterlistordered() {
this.data.expectingFirstListItemValue = !0;
}
function onenterlistitemvalue(token) {
if (this.data.expectingFirstListItemValue) {
let ancestor = this.stack[this.stack.length - 2];
ancestor.start = Number.parseInt(this.sliceSerialize(token), 10), this.data.expectingFirstListItemValue = void 0;
}
}
function onexitcodefencedfenceinfo() {
let data2 = this.resume(), node2 = this.stack[this.stack.length - 1];
node2.lang = data2;
}
function onexitcodefencedfencemeta() {
let data2 = this.resume(), node2 = this.stack[this.stack.length - 1];
node2.meta = data2;
}
function onexitcodefencedfence() {
this.data.flowCodeInside || (this.buffer(), this.data.flowCodeInside = !0);
}
function onexitcodefenced() {
let data2 = this.resume(), node2 = this.stack[this.stack.length - 1];
node2.value = data2.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ""), this.data.flowCodeInside = void 0;
}
function onexitcodeindented() {
let data2 = this.resume(), node2 = this.stack[this.stack.length - 1];
node2.value = data2.replace(/(\r?\n|\r)$/g, "");
}
function onexitdefinitionlabelstring(token) {
let label = this.resume(), node2 = this.stack[this.stack.length - 1];
node2.label = label, node2.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
}
function onexitdefinitiontitlestring() {
let data2 = this.resume(), node2 = this.stack[this.stack.length - 1];
node2.title = data2;
}
function onexitdefinitiondestinationstring() {
let data2 = this.resume(), node2 = this.stack[this.stack.length - 1];
node2.url = data2;
}
function onexitatxheadingsequence(token) {
let node2 = this.stack[this.stack.length - 1];
if (!node2.depth) {
let depth = this.sliceSerialize(token).length;
node2.depth = depth;
}
}
function onexitsetextheadingtext() {
this.data.setextHeadingSlurpLineEnding = !0;
}
function onexitsetextheadinglinesequence(token) {
let node2 = this.stack[this.stack.length - 1];
node2.depth = this.sliceSerialize(token).codePointAt(0) === 61 ? 1 : 2;
}
function onexitsetextheading() {
this.data.setextHeadingSlurpLineEnding = void 0;
}
function onenterdata(token) {
let siblings = this.stack[this.stack.length - 1].children, tail = siblings[siblings.length - 1];
(!tail || tail.type !== "text") && (tail = text3(), tail.position = {
start: point2(token.start),
end: void 0
}, siblings.push(tail)), this.