UNPKG

better-mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

1,650 lines (1,616 loc) 133 kB
import { cleanAndMerge, decodeEntities, encodeEntities, isDetailedError, removeDirectives, utils_default } from "./chunks/mermaid.core/chunk-5ISMJSEX.mjs"; import { version } from "./chunks/mermaid.core/chunk-M6H36LVX.mjs"; import { selectSvgElement } from "./chunks/mermaid.core/chunk-U27G4PW3.mjs"; import { UnknownDiagramError, __name, addDirective, configureSvgSize, defaultConfig, detectType, detectors, evaluate, frontMatterRegex, getConfig, getDiagram, getDiagramLoader, getSiteConfig, log, registerDiagram, registerLazyLoadedDiagrams, reset, saveConfigFromInitialize, setConfig, setLogLevel, setSiteConfig, styles_default, themes_default, updateSiteConfig } from "./chunks/mermaid.core/chunk-DTAZNO6D.mjs"; // src/mermaid.ts import { dedent } from "ts-dedent"; // src/mermaidAPI.ts import { select } from "d3"; import { compile, serialize, stringify } from "stylis"; // src/diagrams/c4/c4Detector.ts var id = "c4"; var detector = /* @__PURE__ */ __name((txt) => { return /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(txt); }, "detector"); var loader = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/c4Diagram-EHWOBBK7.mjs"); return { id, diagram: diagram2 }; }, "loader"); var plugin = { id, detector, loader }; var c4Detector_default = plugin; // src/diagrams/flowchart/flowDetector.ts var id2 = "flowchart"; var detector2 = /* @__PURE__ */ __name((txt, config) => { if (config?.flowchart?.defaultRenderer === "dagre-wrapper" || config?.flowchart?.defaultRenderer === "elk") { return false; } return /^\s*graph/.test(txt); }, "detector"); var loader2 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/flowDiagram-I5KKQ7JZ.mjs"); return { id: id2, diagram: diagram2 }; }, "loader"); var plugin2 = { id: id2, detector: detector2, loader: loader2 }; var flowDetector_default = plugin2; // src/diagrams/flowchart/flowDetector-v2.ts var id3 = "flowchart-v2"; var detector3 = /* @__PURE__ */ __name((txt, config) => { if (config?.flowchart?.defaultRenderer === "dagre-d3" || config?.flowchart?.defaultRenderer === "elk") { return false; } if (/^\s*graph/.test(txt) && config?.flowchart?.defaultRenderer === "dagre-wrapper") { return true; } return /^\s*flowchart/.test(txt); }, "detector"); var loader3 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/flowDiagram-v2-EFV7BTON.mjs"); return { id: id3, diagram: diagram2 }; }, "loader"); var plugin3 = { id: id3, detector: detector3, loader: loader3 }; var flowDetector_v2_default = plugin3; // src/diagrams/er/erDetector.ts var id4 = "er"; var detector4 = /* @__PURE__ */ __name((txt) => { return /^\s*erDiagram/.test(txt); }, "detector"); var loader4 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/erDiagram-US25ITTL.mjs"); return { id: id4, diagram: diagram2 }; }, "loader"); var plugin4 = { id: id4, detector: detector4, loader: loader4 }; var erDetector_default = plugin4; // src/diagrams/git/gitGraphDetector.ts var id5 = "gitGraph"; var detector5 = /* @__PURE__ */ __name((txt) => { return /^\s*gitGraph/.test(txt); }, "detector"); var loader5 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/gitGraphDiagram-P4N24C2V.mjs"); return { id: id5, diagram: diagram2 }; }, "loader"); var plugin5 = { id: id5, detector: detector5, loader: loader5 }; var gitGraphDetector_default = plugin5; // src/diagrams/gantt/ganttDetector.ts var id6 = "gantt"; var detector6 = /* @__PURE__ */ __name((txt) => { return /^\s*gantt/.test(txt); }, "detector"); var loader6 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/ganttDiagram-ALTVWHZ7.mjs"); return { id: id6, diagram: diagram2 }; }, "loader"); var plugin6 = { id: id6, detector: detector6, loader: loader6 }; var ganttDetector_default = plugin6; // src/diagrams/info/infoDetector.ts var id7 = "info"; var detector7 = /* @__PURE__ */ __name((txt) => { return /^\s*info/.test(txt); }, "detector"); var loader7 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/infoDiagram-4K5UVAES.mjs"); return { id: id7, diagram: diagram2 }; }, "loader"); var info = { id: id7, detector: detector7, loader: loader7 }; // src/diagrams/pie/pieDetector.ts var id8 = "pie"; var detector8 = /* @__PURE__ */ __name((txt) => { return /^\s*pie/.test(txt); }, "detector"); var loader8 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/pieDiagram-2REJ6GBU.mjs"); return { id: id8, diagram: diagram2 }; }, "loader"); var pie = { id: id8, detector: detector8, loader: loader8 }; // src/diagrams/quadrant-chart/quadrantDetector.ts var id9 = "quadrantChart"; var detector9 = /* @__PURE__ */ __name((txt) => { return /^\s*quadrantChart/.test(txt); }, "detector"); var loader9 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/quadrantDiagram-MUFKNVQL.mjs"); return { id: id9, diagram: diagram2 }; }, "loader"); var plugin7 = { id: id9, detector: detector9, loader: loader9 }; var quadrantDetector_default = plugin7; // src/diagrams/xychart/xychartDetector.ts var id10 = "xychart"; var detector10 = /* @__PURE__ */ __name((txt) => { return /^\s*xychart-beta/.test(txt); }, "detector"); var loader10 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/xychartDiagram-5DB4XQWV.mjs"); return { id: id10, diagram: diagram2 }; }, "loader"); var plugin8 = { id: id10, detector: detector10, loader: loader10 }; var xychartDetector_default = plugin8; // src/diagrams/requirement/requirementDetector.ts var id11 = "requirement"; var detector11 = /* @__PURE__ */ __name((txt) => { return /^\s*requirement(Diagram)?/.test(txt); }, "detector"); var loader11 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/requirementDiagram-TFQPO32E.mjs"); return { id: id11, diagram: diagram2 }; }, "loader"); var plugin9 = { id: id11, detector: detector11, loader: loader11 }; var requirementDetector_default = plugin9; // src/diagrams/sequence/sequenceDetector.ts var id12 = "sequence"; var detector12 = /* @__PURE__ */ __name((txt) => { return /^\s*sequenceDiagram/.test(txt); }, "detector"); var loader12 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/sequenceDiagram-PO7CLR5K.mjs"); return { id: id12, diagram: diagram2 }; }, "loader"); var plugin10 = { id: id12, detector: detector12, loader: loader12 }; var sequenceDetector_default = plugin10; // src/diagrams/class/classDetector.ts var id13 = "class"; var detector13 = /* @__PURE__ */ __name((txt, config) => { if (config?.class?.defaultRenderer === "dagre-wrapper") { return false; } return /^\s*classDiagram/.test(txt); }, "detector"); var loader13 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/classDiagram-VIKFGZEA.mjs"); return { id: id13, diagram: diagram2 }; }, "loader"); var plugin11 = { id: id13, detector: detector13, loader: loader13 }; var classDetector_default = plugin11; // src/diagrams/class/classDetector-V2.ts var id14 = "classDiagram"; var detector14 = /* @__PURE__ */ __name((txt, config) => { if (/^\s*classDiagram/.test(txt) && config?.class?.defaultRenderer === "dagre-wrapper") { return true; } return /^\s*classDiagram-v2/.test(txt); }, "detector"); var loader14 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/classDiagram-v2-CF7HCGLX.mjs"); return { id: id14, diagram: diagram2 }; }, "loader"); var plugin12 = { id: id14, detector: detector14, loader: loader14 }; var classDetector_V2_default = plugin12; // src/diagrams/state/stateDetector.ts var id15 = "state"; var detector15 = /* @__PURE__ */ __name((txt, config) => { if (config?.state?.defaultRenderer === "dagre-wrapper") { return false; } return /^\s*stateDiagram/.test(txt); }, "detector"); var loader15 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/stateDiagram-P2KRTXB7.mjs"); return { id: id15, diagram: diagram2 }; }, "loader"); var plugin13 = { id: id15, detector: detector15, loader: loader15 }; var stateDetector_default = plugin13; // src/diagrams/state/stateDetector-V2.ts var id16 = "stateDiagram"; var detector16 = /* @__PURE__ */ __name((txt, config) => { if (/^\s*stateDiagram-v2/.test(txt)) { return true; } if (/^\s*stateDiagram/.test(txt) && config?.state?.defaultRenderer === "dagre-wrapper") { return true; } return false; }, "detector"); var loader16 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/stateDiagram-v2-NNISETTN.mjs"); return { id: id16, diagram: diagram2 }; }, "loader"); var plugin14 = { id: id16, detector: detector16, loader: loader16 }; var stateDetector_V2_default = plugin14; // src/diagrams/user-journey/journeyDetector.ts var id17 = "journey"; var detector17 = /* @__PURE__ */ __name((txt) => { return /^\s*journey/.test(txt); }, "detector"); var loader17 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/journeyDiagram-SRDK2CHD.mjs"); return { id: id17, diagram: diagram2 }; }, "loader"); var plugin15 = { id: id17, detector: detector17, loader: loader17 }; var journeyDetector_default = plugin15; // src/diagrams/error/errorRenderer.ts var draw = /* @__PURE__ */ __name((_text, id24, version2) => { log.debug("rendering svg for syntax error\n"); const svg = selectSvgElement(id24); const g = svg.append("g"); svg.attr("viewBox", "0 0 2412 512"); configureSvgSize(svg, 100, 512, true); g.append("path").attr("class", "error-icon").attr( "d", "m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z" ); g.append("text").attr("class", "error-text").attr("x", 1440).attr("y", 250).attr("font-size", "150px").style("text-anchor", "middle").text("Syntax error in text"); g.append("text").attr("class", "error-text").attr("x", 1250).attr("y", 400).attr("font-size", "100px").style("text-anchor", "middle").text(`mermaid version ${version2}`); }, "draw"); var renderer = { draw }; var errorRenderer_default = renderer; // src/diagrams/error/errorDiagram.ts var diagram = { db: {}, renderer, parser: { parse: () => { return; } } }; var errorDiagram_default = diagram; // src/diagrams/flowchart/elk/detector.ts var id18 = "flowchart-elk"; var detector18 = /* @__PURE__ */ __name((txt, config) => { if ( // If diagram explicitly states flowchart-elk /^\s*flowchart-elk/.test(txt) || // If a flowchart/graph diagram has their default renderer set to elk /^\s*flowchart|graph/.test(txt) && config?.flowchart?.defaultRenderer === "elk" ) { setTimeout( () => log.warn( "flowchart-elk was moved to an external package in Mermaid v11. Please refer [release notes](link) for more details. This diagram will be rendered using `dagre` layout as a fallback." ), 500 ); return true; } return false; }, "detector"); var loader18 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/flowDiagram-v2-EFV7BTON.mjs"); return { id: id18, diagram: diagram2 }; }, "loader"); var plugin16 = { id: id18, detector: detector18, loader: loader18 }; var detector_default = plugin16; // src/diagrams/timeline/detector.ts var id19 = "timeline"; var detector19 = /* @__PURE__ */ __name((txt) => { return /^\s*timeline/.test(txt); }, "detector"); var loader19 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/timeline-definition-ABAJCFSY.mjs"); return { id: id19, diagram: diagram2 }; }, "loader"); var plugin17 = { id: id19, detector: detector19, loader: loader19 }; var detector_default2 = plugin17; // src/diagrams/mindmap/detector.ts var id20 = "mindmap"; var detector20 = /* @__PURE__ */ __name((txt) => { return /^\s*mindmap/.test(txt); }, "detector"); var loader20 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/mindmap-definition-FFTIYB2Z.mjs"); return { id: id20, diagram: diagram2 }; }, "loader"); var plugin18 = { id: id20, detector: detector20, loader: loader20 }; var detector_default3 = plugin18; // src/diagrams/sankey/sankeyDetector.ts var id21 = "sankey"; var detector21 = /* @__PURE__ */ __name((txt) => { return /^\s*sankey-beta/.test(txt); }, "detector"); var loader21 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/sankeyDiagram-3C3REL6Y.mjs"); return { id: id21, diagram: diagram2 }; }, "loader"); var plugin19 = { id: id21, detector: detector21, loader: loader21 }; var sankeyDetector_default = plugin19; // src/diagrams/packet/detector.ts var id22 = "packet"; var detector22 = /* @__PURE__ */ __name((txt) => { return /^\s*packet-beta/.test(txt); }, "detector"); var loader22 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/diagram-LN7W6M65.mjs"); return { id: id22, diagram: diagram2 }; }, "loader"); var packet = { id: id22, detector: detector22, loader: loader22 }; // src/diagrams/block/blockDetector.ts var id23 = "block"; var detector23 = /* @__PURE__ */ __name((txt) => { return /^\s*block-beta/.test(txt); }, "detector"); var loader23 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.core/blockDiagram-D2ORMMYJ.mjs"); return { id: id23, diagram: diagram2 }; }, "loader"); var plugin20 = { id: id23, detector: detector23, loader: loader23 }; var blockDetector_default = plugin20; // src/diagram-api/diagram-orchestration.ts var hasLoadedDiagrams = false; var addDiagrams = /* @__PURE__ */ __name(() => { if (hasLoadedDiagrams) { return; } hasLoadedDiagrams = true; registerDiagram("error", errorDiagram_default, (text) => { return text.toLowerCase().trim() === "error"; }); registerDiagram( "---", // --- diagram type may appear if YAML front-matter is not parsed correctly { db: { clear: () => { } }, styles: {}, // should never be used renderer: { draw: () => { } }, parser: { parse: () => { throw new Error( "Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks" ); } }, init: () => null // no op }, (text) => { return text.toLowerCase().trimStart().startsWith("---"); } ); registerLazyLoadedDiagrams( c4Detector_default, classDetector_V2_default, classDetector_default, erDetector_default, ganttDetector_default, info, pie, requirementDetector_default, sequenceDetector_default, detector_default, flowDetector_v2_default, flowDetector_default, detector_default3, detector_default2, gitGraphDetector_default, stateDetector_V2_default, stateDetector_default, journeyDetector_default, quadrantDetector_default, sankeyDetector_default, packet, xychartDetector_default, blockDetector_default ); }, "addDiagrams"); // src/Diagram.ts var Diagram = class _Diagram { constructor(type2, text, db, parser, renderer2) { this.type = type2; this.text = text; this.db = db; this.parser = parser; this.renderer = renderer2; } static { __name(this, "Diagram"); } static async fromText(text, metadata = {}) { const config = getConfig(); const type2 = detectType(text, config); text = encodeEntities(text) + "\n"; try { getDiagram(type2); } catch (e) { const loader25 = getDiagramLoader(type2); if (!loader25) { throw new UnknownDiagramError(`Diagram ${type2} not found.`); } const { id: id24, diagram: diagram2 } = await loader25(); registerDiagram(id24, diagram2); } const { db, parser, renderer: renderer2, init: init2 } = getDiagram(type2); if (parser.parser) { parser.parser.yy = db; } db.clear?.(); init2?.(config); if (metadata.title) { db.setDiagramTitle?.(metadata.title); } await parser.parse(text); return new _Diagram(type2, text, db, parser, renderer2); } async render(id24, version2) { await this.renderer.draw(this.text, id24, version2, this); } getParser() { return this.parser; } getType() { return this.type; } }; // src/interactionDb.ts var interactionFunctions = []; var attachFunctions = /* @__PURE__ */ __name(() => { interactionFunctions.forEach((f) => { f(); }); interactionFunctions = []; }, "attachFunctions"); // src/mermaidAPI.ts import DOMPurify from "dompurify"; import isEmpty from "lodash-es/isEmpty.js"; // src/accessibility.ts var SVG_ROLE = "graphics-document document"; function setA11yDiagramInfo(svg, diagramType) { svg.attr("role", SVG_ROLE); if (diagramType !== "") { svg.attr("aria-roledescription", diagramType); } } __name(setA11yDiagramInfo, "setA11yDiagramInfo"); function addSVGa11yTitleDescription(svg, a11yTitle, a11yDesc, baseId) { if (svg.insert === void 0) { return; } if (a11yDesc) { const descId = `chart-desc-${baseId}`; svg.attr("aria-describedby", descId); svg.insert("desc", ":first-child").attr("id", descId).text(a11yDesc); } if (a11yTitle) { const titleId = `chart-title-${baseId}`; svg.attr("aria-labelledby", titleId); svg.insert("title", ":first-child").attr("id", titleId).text(a11yTitle); } } __name(addSVGa11yTitleDescription, "addSVGa11yTitleDescription"); // src/diagram-api/comments.ts var cleanupComments = /* @__PURE__ */ __name((text) => { return text.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(); }, "cleanupComments"); // ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs function isNothing(subject) { return typeof subject === "undefined" || subject === null; } __name(isNothing, "isNothing"); function isObject(subject) { return typeof subject === "object" && subject !== null; } __name(isObject, "isObject"); function toArray(sequence) { if (Array.isArray(sequence)) return sequence; else if (isNothing(sequence)) return []; return [sequence]; } __name(toArray, "toArray"); function extend(target, source) { var index, length, key, sourceKeys; if (source) { sourceKeys = Object.keys(source); for (index = 0, length = sourceKeys.length; index < length; index += 1) { key = sourceKeys[index]; target[key] = source[key]; } } return target; } __name(extend, "extend"); function repeat(string, count) { var result = "", cycle; for (cycle = 0; cycle < count; cycle += 1) { result += string; } return result; } __name(repeat, "repeat"); function isNegativeZero(number) { return number === 0 && Number.NEGATIVE_INFINITY === 1 / number; } __name(isNegativeZero, "isNegativeZero"); var isNothing_1 = isNothing; var isObject_1 = isObject; var toArray_1 = toArray; var repeat_1 = repeat; var isNegativeZero_1 = isNegativeZero; var extend_1 = extend; var common = { isNothing: isNothing_1, isObject: isObject_1, toArray: toArray_1, repeat: repeat_1, isNegativeZero: isNegativeZero_1, extend: extend_1 }; function formatError(exception2, compact) { var where = "", message = exception2.reason || "(unknown reason)"; if (!exception2.mark) return message; if (exception2.mark.name) { where += 'in "' + exception2.mark.name + '" '; } where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")"; if (!compact && exception2.mark.snippet) { where += "\n\n" + exception2.mark.snippet; } return message + " " + where; } __name(formatError, "formatError"); function YAMLException$1(reason, mark) { Error.call(this); this.name = "YAMLException"; this.reason = reason; this.mark = mark; this.message = formatError(this, false); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { this.stack = new Error().stack || ""; } } __name(YAMLException$1, "YAMLException$1"); YAMLException$1.prototype = Object.create(Error.prototype); YAMLException$1.prototype.constructor = YAMLException$1; YAMLException$1.prototype.toString = /* @__PURE__ */ __name(function toString(compact) { return this.name + ": " + formatError(this, compact); }, "toString"); var exception = YAMLException$1; function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { var head = ""; var tail = ""; var maxHalfLength = Math.floor(maxLineLength / 2) - 1; if (position - lineStart > maxHalfLength) { head = " ... "; lineStart = position - maxHalfLength + head.length; } if (lineEnd - position > maxHalfLength) { tail = " ..."; lineEnd = position + maxHalfLength - tail.length; } return { str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail, pos: position - lineStart + head.length // relative position }; } __name(getLine, "getLine"); function padStart(string, max) { return common.repeat(" ", max - string.length) + string; } __name(padStart, "padStart"); function makeSnippet(mark, options) { options = Object.create(options || null); if (!mark.buffer) return null; if (!options.maxLength) options.maxLength = 79; if (typeof options.indent !== "number") options.indent = 1; if (typeof options.linesBefore !== "number") options.linesBefore = 3; if (typeof options.linesAfter !== "number") options.linesAfter = 2; var re = /\r?\n|\r|\0/g; var lineStarts = [0]; var lineEnds = []; var match; var foundLineNo = -1; while (match = re.exec(mark.buffer)) { lineEnds.push(match.index); lineStarts.push(match.index + match[0].length); if (mark.position <= match.index && foundLineNo < 0) { foundLineNo = lineStarts.length - 2; } } if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; var result = "", i, line; var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); for (i = 1; i <= options.linesBefore; i++) { if (foundLineNo - i < 0) break; line = getLine( mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength ); result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result; } line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n"; result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n"; for (i = 1; i <= options.linesAfter; i++) { if (foundLineNo + i >= lineEnds.length) break; line = getLine( mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength ); result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n"; } return result.replace(/\n$/, ""); } __name(makeSnippet, "makeSnippet"); var snippet = makeSnippet; var TYPE_CONSTRUCTOR_OPTIONS = [ "kind", "multi", "resolve", "construct", "instanceOf", "predicate", "represent", "representName", "defaultStyle", "styleAliases" ]; var YAML_NODE_KINDS = [ "scalar", "sequence", "mapping" ]; function compileStyleAliases(map2) { var result = {}; if (map2 !== null) { Object.keys(map2).forEach(function(style) { map2[style].forEach(function(alias) { result[String(alias)] = style; }); }); } return result; } __name(compileStyleAliases, "compileStyleAliases"); function Type$1(tag, options) { options = options || {}; Object.keys(options).forEach(function(name) { if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); } }); this.options = options; this.tag = tag; this.kind = options["kind"] || null; this.resolve = options["resolve"] || function() { return true; }; this.construct = options["construct"] || function(data) { return data; }; this.instanceOf = options["instanceOf"] || null; this.predicate = options["predicate"] || null; this.represent = options["represent"] || null; this.representName = options["representName"] || null; this.defaultStyle = options["defaultStyle"] || null; this.multi = options["multi"] || false; this.styleAliases = compileStyleAliases(options["styleAliases"] || null); if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); } } __name(Type$1, "Type$1"); var type = Type$1; function compileList(schema2, name) { var result = []; schema2[name].forEach(function(currentType) { var newIndex = result.length; result.forEach(function(previousType, previousIndex) { if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { newIndex = previousIndex; } }); result[newIndex] = currentType; }); return result; } __name(compileList, "compileList"); function compileMap() { var result = { scalar: {}, sequence: {}, mapping: {}, fallback: {}, multi: { scalar: [], sequence: [], mapping: [], fallback: [] } }, index, length; function collectType(type2) { if (type2.multi) { result.multi[type2.kind].push(type2); result.multi["fallback"].push(type2); } else { result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2; } } __name(collectType, "collectType"); for (index = 0, length = arguments.length; index < length; index += 1) { arguments[index].forEach(collectType); } return result; } __name(compileMap, "compileMap"); function Schema$1(definition) { return this.extend(definition); } __name(Schema$1, "Schema$1"); Schema$1.prototype.extend = /* @__PURE__ */ __name(function extend2(definition) { var implicit = []; var explicit = []; if (definition instanceof type) { explicit.push(definition); } else if (Array.isArray(definition)) { explicit = explicit.concat(definition); } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { if (definition.implicit) implicit = implicit.concat(definition.implicit); if (definition.explicit) explicit = explicit.concat(definition.explicit); } else { throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); } implicit.forEach(function(type$1) { if (!(type$1 instanceof type)) { throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); } if (type$1.loadKind && type$1.loadKind !== "scalar") { throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); } if (type$1.multi) { throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit."); } }); explicit.forEach(function(type$1) { if (!(type$1 instanceof type)) { throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); } }); var result = Object.create(Schema$1.prototype); result.implicit = (this.implicit || []).concat(implicit); result.explicit = (this.explicit || []).concat(explicit); result.compiledImplicit = compileList(result, "implicit"); result.compiledExplicit = compileList(result, "explicit"); result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); return result; }, "extend"); var schema = Schema$1; var str = new type("tag:yaml.org,2002:str", { kind: "scalar", construct: function(data) { return data !== null ? data : ""; } }); var seq = new type("tag:yaml.org,2002:seq", { kind: "sequence", construct: function(data) { return data !== null ? data : []; } }); var map = new type("tag:yaml.org,2002:map", { kind: "mapping", construct: function(data) { return data !== null ? data : {}; } }); var failsafe = new schema({ explicit: [ str, seq, map ] }); function resolveYamlNull(data) { if (data === null) return true; var max = data.length; return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL"); } __name(resolveYamlNull, "resolveYamlNull"); function constructYamlNull() { return null; } __name(constructYamlNull, "constructYamlNull"); function isNull(object) { return object === null; } __name(isNull, "isNull"); var _null = new type("tag:yaml.org,2002:null", { kind: "scalar", resolve: resolveYamlNull, construct: constructYamlNull, predicate: isNull, represent: { canonical: function() { return "~"; }, lowercase: function() { return "null"; }, uppercase: function() { return "NULL"; }, camelcase: function() { return "Null"; }, empty: function() { return ""; } }, defaultStyle: "lowercase" }); function resolveYamlBoolean(data) { if (data === null) return false; var max = data.length; return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE"); } __name(resolveYamlBoolean, "resolveYamlBoolean"); function constructYamlBoolean(data) { return data === "true" || data === "True" || data === "TRUE"; } __name(constructYamlBoolean, "constructYamlBoolean"); function isBoolean(object) { return Object.prototype.toString.call(object) === "[object Boolean]"; } __name(isBoolean, "isBoolean"); var bool = new type("tag:yaml.org,2002:bool", { kind: "scalar", resolve: resolveYamlBoolean, construct: constructYamlBoolean, predicate: isBoolean, represent: { lowercase: function(object) { return object ? "true" : "false"; }, uppercase: function(object) { return object ? "TRUE" : "FALSE"; }, camelcase: function(object) { return object ? "True" : "False"; } }, defaultStyle: "lowercase" }); function isHexCode(c) { return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102; } __name(isHexCode, "isHexCode"); function isOctCode(c) { return 48 <= c && c <= 55; } __name(isOctCode, "isOctCode"); function isDecCode(c) { return 48 <= c && c <= 57; } __name(isDecCode, "isDecCode"); function resolveYamlInteger(data) { if (data === null) return false; var max = data.length, index = 0, hasDigits = false, ch; if (!max) return false; ch = data[index]; if (ch === "-" || ch === "+") { ch = data[++index]; } if (ch === "0") { if (index + 1 === max) return true; ch = data[++index]; if (ch === "b") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (ch !== "0" && ch !== "1") return false; hasDigits = true; } return hasDigits && ch !== "_"; } if (ch === "x") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isHexCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== "_"; } if (ch === "o") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isOctCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== "_"; } } if (ch === "_") return false; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isDecCode(data.charCodeAt(index))) { return false; } hasDigits = true; } if (!hasDigits || ch === "_") return false; return true; } __name(resolveYamlInteger, "resolveYamlInteger"); function constructYamlInteger(data) { var value = data, sign = 1, ch; if (value.indexOf("_") !== -1) { value = value.replace(/_/g, ""); } ch = value[0]; if (ch === "-" || ch === "+") { if (ch === "-") sign = -1; value = value.slice(1); ch = value[0]; } if (value === "0") return 0; if (ch === "0") { if (value[1] === "b") return sign * parseInt(value.slice(2), 2); if (value[1] === "x") return sign * parseInt(value.slice(2), 16); if (value[1] === "o") return sign * parseInt(value.slice(2), 8); } return sign * parseInt(value, 10); } __name(constructYamlInteger, "constructYamlInteger"); function isInteger(object) { return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object)); } __name(isInteger, "isInteger"); var int = new type("tag:yaml.org,2002:int", { kind: "scalar", resolve: resolveYamlInteger, construct: constructYamlInteger, predicate: isInteger, represent: { binary: function(obj) { return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); }, octal: function(obj) { return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1); }, decimal: function(obj) { return obj.toString(10); }, /* eslint-disable max-len */ hexadecimal: function(obj) { return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); } }, defaultStyle: "decimal", styleAliases: { binary: [2, "bin"], octal: [8, "oct"], decimal: [10, "dec"], hexadecimal: [16, "hex"] } }); var YAML_FLOAT_PATTERN = new RegExp( // 2.5e4, 2.5 and integers "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" ); function resolveYamlFloat(data) { if (data === null) return false; if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` // Probably should update regexp & check speed data[data.length - 1] === "_") { return false; } return true; } __name(resolveYamlFloat, "resolveYamlFloat"); function constructYamlFloat(data) { var value, sign; value = data.replace(/_/g, "").toLowerCase(); sign = value[0] === "-" ? -1 : 1; if ("+-".indexOf(value[0]) >= 0) { value = value.slice(1); } if (value === ".inf") { return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; } else if (value === ".nan") { return NaN; } return sign * parseFloat(value, 10); } __name(constructYamlFloat, "constructYamlFloat"); var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; function representYamlFloat(object, style) { var res; if (isNaN(object)) { switch (style) { case "lowercase": return ".nan"; case "uppercase": return ".NAN"; case "camelcase": return ".NaN"; } } else if (Number.POSITIVE_INFINITY === object) { switch (style) { case "lowercase": return ".inf"; case "uppercase": return ".INF"; case "camelcase": return ".Inf"; } } else if (Number.NEGATIVE_INFINITY === object) { switch (style) { case "lowercase": return "-.inf"; case "uppercase": return "-.INF"; case "camelcase": return "-.Inf"; } } else if (common.isNegativeZero(object)) { return "-0.0"; } res = object.toString(10); return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; } __name(representYamlFloat, "representYamlFloat"); function isFloat(object) { return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object)); } __name(isFloat, "isFloat"); var float = new type("tag:yaml.org,2002:float", { kind: "scalar", resolve: resolveYamlFloat, construct: constructYamlFloat, predicate: isFloat, represent: representYamlFloat, defaultStyle: "lowercase" }); var json = failsafe.extend({ implicit: [ _null, bool, int, float ] }); var core = json; var YAML_DATE_REGEXP = new RegExp( "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$" ); var YAML_TIMESTAMP_REGEXP = new RegExp( "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$" ); function resolveYamlTimestamp(data) { if (data === null) return false; if (YAML_DATE_REGEXP.exec(data) !== null) return true; if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; return false; } __name(resolveYamlTimestamp, "resolveYamlTimestamp"); function constructYamlTimestamp(data) { var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date; match = YAML_DATE_REGEXP.exec(data); if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); if (match === null) throw new Error("Date resolve error"); year = +match[1]; month = +match[2] - 1; day = +match[3]; if (!match[4]) { return new Date(Date.UTC(year, month, day)); } hour = +match[4]; minute = +match[5]; second = +match[6]; if (match[7]) { fraction = match[7].slice(0, 3); while (fraction.length < 3) { fraction += "0"; } fraction = +fraction; } if (match[9]) { tz_hour = +match[10]; tz_minute = +(match[11] || 0); delta = (tz_hour * 60 + tz_minute) * 6e4; if (match[9] === "-") delta = -delta; } date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); if (delta) date.setTime(date.getTime() - delta); return date; } __name(constructYamlTimestamp, "constructYamlTimestamp"); function representYamlTimestamp(object) { return object.toISOString(); } __name(representYamlTimestamp, "representYamlTimestamp"); var timestamp = new type("tag:yaml.org,2002:timestamp", { kind: "scalar", resolve: resolveYamlTimestamp, construct: constructYamlTimestamp, instanceOf: Date, represent: representYamlTimestamp }); function resolveYamlMerge(data) { return data === "<<" || data === null; } __name(resolveYamlMerge, "resolveYamlMerge"); var merge = new type("tag:yaml.org,2002:merge", { kind: "scalar", resolve: resolveYamlMerge }); var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; function resolveYamlBinary(data) { if (data === null) return false; var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP; for (idx = 0; idx < max; idx++) { code = map2.indexOf(data.charAt(idx)); if (code > 64) continue; if (code < 0) return false; bitlen += 6; } return bitlen % 8 === 0; } __name(resolveYamlBinary, "resolveYamlBinary"); function constructYamlBinary(data) { var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = []; for (idx = 0; idx < max; idx++) { if (idx % 4 === 0 && idx) { result.push(bits >> 16 & 255); result.push(bits >> 8 & 255); result.push(bits & 255); } bits = bits << 6 | map2.indexOf(input.charAt(idx)); } tailbits = max % 4 * 6; if (tailbits === 0) { result.push(bits >> 16 & 255); result.push(bits >> 8 & 255); result.push(bits & 255); } else if (tailbits === 18) { result.push(bits >> 10 & 255); result.push(bits >> 2 & 255); } else if (tailbits === 12) { result.push(bits >> 4 & 255); } return new Uint8Array(result); } __name(constructYamlBinary, "constructYamlBinary"); function representYamlBinary(object) { var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP; for (idx = 0; idx < max; idx++) { if (idx % 3 === 0 && idx) { result += map2[bits >> 18 & 63]; result += map2[bits >> 12 & 63]; result += map2[bits >> 6 & 63]; result += map2[bits & 63]; } bits = (bits << 8) + object[idx]; } tail = max % 3; if (tail === 0) { result += map2[bits >> 18 & 63]; result += map2[bits >> 12 & 63]; result += map2[bits >> 6 & 63]; result += map2[bits & 63]; } else if (tail === 2) { result += map2[bits >> 10 & 63]; result += map2[bits >> 4 & 63]; result += map2[bits << 2 & 63]; result += map2[64]; } else if (tail === 1) { result += map2[bits >> 2 & 63]; result += map2[bits << 4 & 63]; result += map2[64]; result += map2[64]; } return result; } __name(representYamlBinary, "representYamlBinary"); function isBinary(obj) { return Object.prototype.toString.call(obj) === "[object Uint8Array]"; } __name(isBinary, "isBinary"); var binary = new type("tag:yaml.org,2002:binary", { kind: "scalar", resolve: resolveYamlBinary, construct: constructYamlBinary, predicate: isBinary, represent: representYamlBinary }); var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; var _toString$2 = Object.prototype.toString; function resolveYamlOmap(data) { if (data === null) return true; var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data; for (index = 0, length = object.length; index < length; index += 1) { pair = object[index]; pairHasKey = false; if (_toString$2.call(pair) !== "[object Object]") return false; for (pairKey in pair) { if (_hasOwnProperty$3.call(pair, pairKey)) { if (!pairHasKey) pairHasKey = true; else return false; } } if (!pairHasKey) return false; if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); else return false; } return true; } __name(resolveYamlOmap, "resolveYamlOmap"); function constructYamlOmap(data) { return data !== null ? data : []; } __name(constructYamlOmap, "constructYamlOmap"); var omap = new type("tag:yaml.org,2002:omap", { kind: "sequence", resolve: resolveYamlOmap, construct: constructYamlOmap }); var _toString$1 = Object.prototype.toString; function resolveYamlPairs(data) { if (data === null) return true; var index, length, pair, keys, result, object = data; result = new Array(object.length); for (index = 0, length = object.length; index < length; index += 1) { pair = object[index]; if (_toString$1.call(pair) !== "[object Object]") return false; keys = Object.keys(pair); if (keys.length !== 1) return false; result[index] = [keys[0], pair[keys[0]]]; } return true; } __name(resolveYamlPairs, "resolveYamlPairs"); function constructYamlPairs(data) { if (data === null) return []; var index, length, pair, keys, result, object = data; result = new Array(object.length); for (index = 0, length = object.length; index < length; index += 1) { pair = object[index]; keys = Object.keys(pair); result[index] = [keys[0], pair[keys[0]]]; } return result; } __name(constructYamlPairs, "constructYamlPairs"); var pairs = new type("tag:yaml.org,2002:pairs", { kind: "sequence", resolve: resolveYamlPairs, construct: constructYamlPairs }); var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; function resolveYamlSet(data) { if (data === null) return true; var key, object = data; for (key in object) { if (_hasOwnProperty$2.call(object, key)) { if (object[key] !== null) return false; } } return true; } __name(resolveYamlSet, "resolveYamlSet"); function constructYamlSet(data) { return data !== null ? data : {}; } __name(constructYamlSet, "constructYamlSet"); var set = new type("tag:yaml.org,2002:set", { kind: "mapping", resolve: resolveYamlSet, construct: constructYamlSet }); var _default = core.extend({ implicit: [ timestamp, merge ], explicit: [ binary, omap, pairs, set ] }); var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; var CONTEXT_FLOW_IN = 1; var CONTEXT_FLOW_OUT = 2; var CONTEXT_BLOCK_IN = 3; var CONTEXT_BLOCK_OUT = 4; var CHOMPING_CLIP = 1; var CHOMPING_STRIP = 2; var CHOMPING_KEEP = 3; var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; function _class(obj) { return Object.prototype.toString.call(obj); } __name(_class, "_class"); function is_EOL(c) { return c === 10 || c === 13; } __name(is_EOL, "is_EOL"); function is_WHITE_SPACE(c) { return c === 9 || c === 32; } __name(is_WHITE_SPACE, "is_WHITE_SPACE"); function is_WS_OR_EOL(c) { return c === 9 || c === 32 || c === 10 || c === 13; } __name(is_WS_OR_EOL, "is_WS_OR_EOL"); function is_FLOW_INDICATOR(c) { return c === 44 || c === 91 || c === 93 || c === 123 || c === 125; } __name(is_FLOW_INDICATOR, "is_FLOW_INDICATOR"); function fromHexCode(c) { var lc; if (48 <= c && c <= 57) { return c - 48; } lc = c | 32; if (97 <= lc && lc <= 102) { return lc - 97 + 10; } return -1; } __name(fromHexCode, "fromHexCode"); function escapedHexLen(c) { if (c === 120) { return 2; } if (c === 117) { return 4; } if (c === 85) { return 8; } return 0; } __name(escapedHexLen, "escapedHexLen"); function fromDecimalCode(c) { if (48 <= c && c <= 57) { return c - 48; } return -1; } __name(fromDecimalCode, "fromDecimalCode"); function simpleEscapeSequence(c) { return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : ""; } __name(simpleEscapeSequence, "simpleEscapeSequence"); function charFromCodepoint(c) { if (c <= 65535) { return String.fromCharCode(c); } return String.fromCharCode( (c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320 ); } __name(charFromCodepoint, "charFromCodepoint"); var simpleEscapeCheck = new Array(256); var simpleEscapeMap = new Array(256); for (i = 0; i < 256; i++) { simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; simpleEscapeMap[i] = simpleEscapeSequence(i); } var i; function State$1(input, options) { this.input = input; this.filename = options["filename"] || null; this.schema = options["schema"] || _default; this.onWarning = options["onWarning"] || null; this.legacy = options["legacy"] || false; this.json = options["json"] || false; this.listener = options["listener"] || null; this.implicitTypes = this.schema.