UNPKG

mermaid

Version:

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

4 lines 166 kB
{ "version": 3, "sources": ["../../../src/diagrams/flowchart/flowDb.ts", "../../../src/diagrams/flowchart/flowRenderer-v3-unified.ts", "../../../src/diagrams/flowchart/parser/flow.jison", "../../../src/diagrams/flowchart/styles.ts", "../../../src/diagrams/flowchart/flowDiagram.ts"], "sourcesContent": ["import { select } from 'd3';\nimport utils, { getEdgeId } from '../../utils.js';\nimport { getConfig, defaultConfig } from '../../diagram-api/diagramAPI.js';\nimport common from '../common/common.js';\nimport type { Node, Edge } from '../../rendering-util/types.js';\nimport { log } from '../../logger.js';\nimport {\n setAccTitle,\n getAccTitle,\n getAccDescription,\n setAccDescription,\n clear as commonClear,\n setDiagramTitle,\n getDiagramTitle,\n} from '../common/commonDb.js';\nimport type { FlowVertex, FlowClass, FlowSubGraph, FlowText, FlowEdge, FlowLink } from './types.js';\n\nconst MERMAID_DOM_ID_PREFIX = 'flowchart-';\nlet vertexCounter = 0;\nlet config = getConfig();\nlet vertices = new Map<string, FlowVertex>();\nlet edges: FlowEdge[] & { defaultInterpolate?: string; defaultStyle?: string[] } = [];\nlet classes = new Map<string, FlowClass>();\nlet subGraphs: FlowSubGraph[] = [];\nlet subGraphLookup = new Map<string, FlowSubGraph>();\nlet tooltips = new Map<string, string>();\nlet subCount = 0;\nlet firstGraphFlag = true;\nlet direction: string;\n\nlet version: string; // As in graph\n\n// Functions to be run after graph rendering\nlet funs: ((element: Element) => void)[] = []; // cspell:ignore funs\n\nconst sanitizeText = (txt: string) => common.sanitizeText(txt, config);\n\n/**\n * Function to lookup domId from id in the graph definition.\n *\n * @param id - id of the node\n */\nexport const lookUpDomId = function (id: string) {\n for (const vertex of vertices.values()) {\n if (vertex.id === id) {\n return vertex.domId;\n }\n }\n return id;\n};\n\n/**\n * Function called by parser when a node definition has been found\n *\n */\nexport const addVertex = function (\n id: string,\n textObj: FlowText,\n type: 'group',\n style: string[],\n classes: string[],\n dir: string,\n props = {}\n) {\n if (!id || id.trim().length === 0) {\n return;\n }\n let txt;\n\n let vertex = vertices.get(id);\n if (vertex === undefined) {\n vertex = {\n id,\n labelType: 'text',\n domId: MERMAID_DOM_ID_PREFIX + id + '-' + vertexCounter,\n styles: [],\n classes: [],\n };\n vertices.set(id, vertex);\n }\n vertexCounter++;\n\n if (textObj !== undefined) {\n config = getConfig();\n txt = sanitizeText(textObj.text.trim());\n vertex.labelType = textObj.type;\n // strip quotes if string starts and ends with a quote\n if (txt.startsWith('\"') && txt.endsWith('\"')) {\n txt = txt.substring(1, txt.length - 1);\n }\n vertex.text = txt;\n } else {\n if (vertex.text === undefined) {\n vertex.text = id;\n }\n }\n if (type !== undefined) {\n vertex.type = type;\n }\n if (style !== undefined && style !== null) {\n style.forEach(function (s) {\n vertex.styles.push(s);\n });\n }\n if (classes !== undefined && classes !== null) {\n classes.forEach(function (s) {\n vertex.classes.push(s);\n });\n }\n if (dir !== undefined) {\n vertex.dir = dir;\n }\n if (vertex.props === undefined) {\n vertex.props = props;\n } else if (props !== undefined) {\n Object.assign(vertex.props, props);\n }\n};\n\n/**\n * Function called by parser when a link/edge definition has been found\n *\n */\nexport const addSingleLink = function (_start: string, _end: string, type: any) {\n const start = _start;\n const end = _end;\n\n const edge: FlowEdge = { start: start, end: end, type: undefined, text: '', labelType: 'text' };\n log.info('abc78 Got edge...', edge);\n const linkTextObj = type.text;\n\n if (linkTextObj !== undefined) {\n edge.text = sanitizeText(linkTextObj.text.trim());\n\n // strip quotes if string starts and ends with a quote\n if (edge.text.startsWith('\"') && edge.text.endsWith('\"')) {\n edge.text = edge.text.substring(1, edge.text.length - 1);\n }\n edge.labelType = linkTextObj.type;\n }\n\n if (type !== undefined) {\n edge.type = type.type;\n edge.stroke = type.stroke;\n edge.length = type.length > 10 ? 10 : type.length;\n }\n\n if (edges.length < (config.maxEdges ?? 500)) {\n log.info('Pushing edge...');\n edges.push(edge);\n } else {\n throw new Error(\n `Edge limit exceeded. ${edges.length} edges found, but the limit is ${config.maxEdges}.\n\nInitialize mermaid with maxEdges set to a higher number to allow more edges.\nYou cannot set this config via configuration inside the diagram as it is a secure config.\nYou have to call mermaid.initialize.`\n );\n }\n};\n\nexport const addLink = function (_start: string[], _end: string[], type: unknown) {\n log.info('addLink', _start, _end, type);\n for (const start of _start) {\n for (const end of _end) {\n addSingleLink(start, end, type);\n }\n }\n};\n\n/**\n * Updates a link's line interpolation algorithm\n *\n */\nexport const updateLinkInterpolate = function (\n positions: ('default' | number)[],\n interpolate: string\n) {\n positions.forEach(function (pos) {\n if (pos === 'default') {\n edges.defaultInterpolate = interpolate;\n } else {\n edges[pos].interpolate = interpolate;\n }\n });\n};\n\n/**\n * Updates a link with a style\n *\n */\nexport const updateLink = function (positions: ('default' | number)[], style: string[]) {\n positions.forEach(function (pos) {\n if (typeof pos === 'number' && pos >= edges.length) {\n throw new Error(\n `The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${\n edges.length - 1\n }. (Help: Ensure that the index is within the range of existing edges.)`\n );\n }\n if (pos === 'default') {\n edges.defaultStyle = style;\n } else {\n // if (utils.isSubstringInArray('fill', style) === -1) {\n // style.push('fill:none');\n // }\n edges[pos].style = style;\n // if edges[pos].style does have fill not set, set it to none\n if (\n (edges[pos]?.style?.length ?? 0) > 0 &&\n !edges[pos]?.style?.some((s) => s?.startsWith('fill'))\n ) {\n edges[pos]?.style?.push('fill:none');\n }\n }\n });\n};\n\nexport const addClass = function (ids: string, style: string[]) {\n ids.split(',').forEach(function (id) {\n let classNode = classes.get(id);\n if (classNode === undefined) {\n classNode = { id, styles: [], textStyles: [] };\n classes.set(id, classNode);\n }\n\n if (style !== undefined && style !== null) {\n style.forEach(function (s) {\n if (/color/.exec(s)) {\n const newStyle = s.replace('fill', 'bgFill'); // .replace('color', 'fill');\n classNode.textStyles.push(newStyle);\n }\n classNode.styles.push(s);\n });\n }\n });\n};\n\n/**\n * Called by parser when a graph definition is found, stores the direction of the chart.\n *\n */\nexport const setDirection = function (dir: string) {\n direction = dir;\n if (/.*</.exec(direction)) {\n direction = 'RL';\n }\n if (/.*\\^/.exec(direction)) {\n direction = 'BT';\n }\n if (/.*>/.exec(direction)) {\n direction = 'LR';\n }\n if (/.*v/.exec(direction)) {\n direction = 'TB';\n }\n if (direction === 'TD') {\n direction = 'TB';\n }\n};\n\n/**\n * Called by parser when a special node is found, e.g. a clickable element.\n *\n * @param ids - Comma separated list of ids\n * @param className - Class to add\n */\nexport const setClass = function (ids: string, className: string) {\n for (const id of ids.split(',')) {\n const vertex = vertices.get(id);\n if (vertex) {\n vertex.classes.push(className);\n }\n const subGraph = subGraphLookup.get(id);\n if (subGraph) {\n subGraph.classes.push(className);\n }\n }\n};\n\nconst setTooltip = function (ids: string, tooltip: string) {\n if (tooltip === undefined) {\n return;\n }\n tooltip = sanitizeText(tooltip);\n for (const id of ids.split(',')) {\n tooltips.set(version === 'gen-1' ? lookUpDomId(id) : id, tooltip);\n }\n};\n\nconst setClickFun = function (id: string, functionName: string, functionArgs: string) {\n const domId = lookUpDomId(id);\n // if (_id[0].match(/\\d/)) id = MERMAID_DOM_ID_PREFIX + id;\n if (getConfig().securityLevel !== 'loose') {\n return;\n }\n if (functionName === undefined) {\n return;\n }\n let argList: string[] = [];\n if (typeof functionArgs === 'string') {\n /* Splits functionArgs by ',', ignoring all ',' in double quoted strings */\n argList = functionArgs.split(/,(?=(?:(?:[^\"]*\"){2})*[^\"]*$)/);\n for (let i = 0; i < argList.length; i++) {\n let item = argList[i].trim();\n /* Removes all double quotes at the start and end of an argument */\n /* This preserves all starting and ending whitespace inside */\n if (item.startsWith('\"') && item.endsWith('\"')) {\n item = item.substr(1, item.length - 2);\n }\n argList[i] = item;\n }\n }\n\n /* if no arguments passed into callback, default to passing in id */\n if (argList.length === 0) {\n argList.push(id);\n }\n\n const vertex = vertices.get(id);\n if (vertex) {\n vertex.haveCallback = true;\n funs.push(function () {\n const elem = document.querySelector(`[id=\"${domId}\"]`);\n if (elem !== null) {\n elem.addEventListener(\n 'click',\n function () {\n utils.runFunc(functionName, ...argList);\n },\n false\n );\n }\n });\n }\n};\n\n/**\n * Called by parser when a link is found. Adds the URL to the vertex data.\n *\n * @param ids - Comma separated list of ids\n * @param linkStr - URL to create a link for\n * @param target - Target attribute for the link\n */\nexport const setLink = function (ids: string, linkStr: string, target: string) {\n ids.split(',').forEach(function (id) {\n const vertex = vertices.get(id);\n if (vertex !== undefined) {\n vertex.link = utils.formatUrl(linkStr, config);\n vertex.linkTarget = target;\n }\n });\n setClass(ids, 'clickable');\n};\n\nexport const getTooltip = function (id: string) {\n return tooltips.get(id);\n};\n\n/**\n * Called by parser when a click definition is found. Registers an event handler.\n *\n * @param ids - Comma separated list of ids\n * @param functionName - Function to be called on click\n * @param functionArgs - Arguments to be passed to the function\n */\nexport const setClickEvent = function (ids: string, functionName: string, functionArgs: string) {\n ids.split(',').forEach(function (id) {\n setClickFun(id, functionName, functionArgs);\n });\n setClass(ids, 'clickable');\n};\n\nexport const bindFunctions = function (element: Element) {\n funs.forEach(function (fun) {\n fun(element);\n });\n};\nexport const getDirection = function () {\n return direction.trim();\n};\n/**\n * Retrieval function for fetching the found nodes after parsing has completed.\n *\n */\nexport const getVertices = function () {\n return vertices;\n};\n\n/**\n * Retrieval function for fetching the found links after parsing has completed.\n *\n */\nexport const getEdges = function () {\n return edges;\n};\n\n/**\n * Retrieval function for fetching the found class definitions after parsing has completed.\n *\n */\nexport const getClasses = function () {\n return classes;\n};\n\nconst setupToolTips = function (element: Element) {\n let tooltipElem = select('.mermaidTooltip');\n // @ts-ignore TODO: fix this\n if ((tooltipElem._groups || tooltipElem)[0][0] === null) {\n // @ts-ignore TODO: fix this\n tooltipElem = select('body').append('div').attr('class', 'mermaidTooltip').style('opacity', 0);\n }\n\n const svg = select(element).select('svg');\n\n const nodes = svg.selectAll('g.node');\n nodes\n .on('mouseover', function () {\n const el = select(this);\n const title = el.attr('title');\n\n // Don't try to draw a tooltip if no data is provided\n if (title === null) {\n return;\n }\n const rect = (this as Element)?.getBoundingClientRect();\n\n // @ts-ignore TODO: fix this\n tooltipElem.transition().duration(200).style('opacity', '.9');\n tooltipElem\n .text(el.attr('title'))\n .style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')\n .style('top', window.scrollY + rect.bottom + 'px');\n tooltipElem.html(tooltipElem.html().replace(/&lt;br\\/&gt;/g, '<br/>'));\n el.classed('hover', true);\n })\n .on('mouseout', function () {\n // @ts-ignore TODO: fix this\n tooltipElem.transition().duration(500).style('opacity', 0);\n const el = select(this);\n el.classed('hover', false);\n });\n};\nfuns.push(setupToolTips);\n\n/**\n * Clears the internal graph db so that a new graph can be parsed.\n *\n */\nexport const clear = function (ver = 'gen-1') {\n vertices = new Map();\n classes = new Map();\n edges = [];\n funs = [setupToolTips];\n subGraphs = [];\n subGraphLookup = new Map();\n subCount = 0;\n tooltips = new Map();\n firstGraphFlag = true;\n version = ver;\n config = getConfig();\n commonClear();\n};\n\nexport const setGen = (ver: string) => {\n version = ver || 'gen-2';\n};\n\nexport const defaultStyle = function () {\n return 'fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;';\n};\n\nexport const addSubGraph = function (\n _id: { text: string },\n list: string[],\n _title: { text: string; type: string }\n) {\n let id: string | undefined = _id.text.trim();\n let title = _title.text;\n if (_id === _title && /\\s/.exec(_title.text)) {\n id = undefined;\n }\n\n function uniq(a: any[]) {\n const prims: any = { boolean: {}, number: {}, string: {} };\n const objs: any[] = [];\n\n let dir; // = undefined; direction.trim();\n const nodeList = a.filter(function (item) {\n const type = typeof item;\n if (item.stmt && item.stmt === 'dir') {\n dir = item.value;\n return false;\n }\n if (item.trim() === '') {\n return false;\n }\n if (type in prims) {\n return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);\n } else {\n return objs.includes(item) ? false : objs.push(item);\n }\n });\n return { nodeList, dir };\n }\n\n const { nodeList, dir } = uniq(list.flat());\n if (version === 'gen-1') {\n for (let i = 0; i < nodeList.length; i++) {\n nodeList[i] = lookUpDomId(nodeList[i]);\n }\n }\n\n id = id ?? 'subGraph' + subCount;\n title = title || '';\n title = sanitizeText(title);\n subCount = subCount + 1;\n const subGraph = {\n id: id,\n nodes: nodeList,\n title: title.trim(),\n classes: [],\n dir,\n labelType: _title.type,\n };\n\n log.info('Adding', subGraph.id, subGraph.nodes, subGraph.dir);\n\n // Remove the members in the new subgraph if they already belong to another subgraph\n subGraph.nodes = makeUniq(subGraph, subGraphs).nodes;\n subGraphs.push(subGraph);\n subGraphLookup.set(id, subGraph);\n return id;\n};\n\nconst getPosForId = function (id: string) {\n for (const [i, subGraph] of subGraphs.entries()) {\n if (subGraph.id === id) {\n return i;\n }\n }\n return -1;\n};\nlet secCount = -1;\nconst posCrossRef: number[] = [];\nconst indexNodes2 = function (id: string, pos: number): { result: boolean; count: number } {\n const nodes = subGraphs[pos].nodes;\n secCount = secCount + 1;\n if (secCount > 2000) {\n return {\n result: false,\n count: 0,\n };\n }\n posCrossRef[secCount] = pos;\n // Check if match\n if (subGraphs[pos].id === id) {\n return {\n result: true,\n count: 0,\n };\n }\n\n let count = 0;\n let posCount = 1;\n while (count < nodes.length) {\n const childPos = getPosForId(nodes[count]);\n // Ignore regular nodes (pos will be -1)\n if (childPos >= 0) {\n const res = indexNodes2(id, childPos);\n if (res.result) {\n return {\n result: true,\n count: posCount + res.count,\n };\n } else {\n posCount = posCount + res.count;\n }\n }\n count = count + 1;\n }\n\n return {\n result: false,\n count: posCount,\n };\n};\n\nexport const getDepthFirstPos = function (pos: number) {\n return posCrossRef[pos];\n};\nexport const indexNodes = function () {\n secCount = -1;\n if (subGraphs.length > 0) {\n indexNodes2('none', subGraphs.length - 1);\n }\n};\n\nexport const getSubGraphs = function () {\n return subGraphs;\n};\n\nexport const firstGraph = () => {\n if (firstGraphFlag) {\n firstGraphFlag = false;\n return true;\n }\n return false;\n};\n\nconst destructStartLink = (_str: string): FlowLink => {\n let str = _str.trim();\n let type = 'arrow_open';\n\n switch (str[0]) {\n case '<':\n type = 'arrow_point';\n str = str.slice(1);\n break;\n case 'x':\n type = 'arrow_cross';\n str = str.slice(1);\n break;\n case 'o':\n type = 'arrow_circle';\n str = str.slice(1);\n break;\n }\n\n let stroke = 'normal';\n\n if (str.includes('=')) {\n stroke = 'thick';\n }\n\n if (str.includes('.')) {\n stroke = 'dotted';\n }\n\n return { type, stroke };\n};\n\nconst countChar = (char: string, str: string) => {\n const length = str.length;\n let count = 0;\n for (let i = 0; i < length; ++i) {\n if (str[i] === char) {\n ++count;\n }\n }\n return count;\n};\n\nconst destructEndLink = (_str: string) => {\n const str = _str.trim();\n let line = str.slice(0, -1);\n let type = 'arrow_open';\n\n switch (str.slice(-1)) {\n case 'x':\n type = 'arrow_cross';\n if (str.startsWith('x')) {\n type = 'double_' + type;\n line = line.slice(1);\n }\n break;\n case '>':\n type = 'arrow_point';\n if (str.startsWith('<')) {\n type = 'double_' + type;\n line = line.slice(1);\n }\n break;\n case 'o':\n type = 'arrow_circle';\n if (str.startsWith('o')) {\n type = 'double_' + type;\n line = line.slice(1);\n }\n break;\n }\n\n let stroke = 'normal';\n let length = line.length - 1;\n\n if (line.startsWith('=')) {\n stroke = 'thick';\n }\n\n if (line.startsWith('~')) {\n stroke = 'invisible';\n }\n\n const dots = countChar('.', line);\n\n if (dots) {\n stroke = 'dotted';\n length = dots;\n }\n\n return { type, stroke, length };\n};\n\nexport const destructLink = (_str: string, _startStr: string) => {\n const info = destructEndLink(_str);\n let startInfo;\n if (_startStr) {\n startInfo = destructStartLink(_startStr);\n\n if (startInfo.stroke !== info.stroke) {\n return { type: 'INVALID', stroke: 'INVALID' };\n }\n\n if (startInfo.type === 'arrow_open') {\n // -- xyz --> - take arrow type from ending\n startInfo.type = info.type;\n } else {\n // x-- xyz --> - not supported\n if (startInfo.type !== info.type) {\n return { type: 'INVALID', stroke: 'INVALID' };\n }\n\n startInfo.type = 'double_' + startInfo.type;\n }\n\n if (startInfo.type === 'double_arrow') {\n startInfo.type = 'double_arrow_point';\n }\n\n startInfo.length = info.length;\n return startInfo;\n }\n\n return info;\n};\n\n// Todo optimizer this by caching existing nodes\nconst exists = (allSgs: FlowSubGraph[], _id: string) => {\n for (const sg of allSgs) {\n if (sg.nodes.includes(_id)) {\n return true;\n }\n }\n return false;\n};\n/**\n * Deletes an id from all subgraphs\n *\n */\nconst makeUniq = (sg: FlowSubGraph, allSubgraphs: FlowSubGraph[]) => {\n const res: string[] = [];\n sg.nodes.forEach((_id, pos) => {\n if (!exists(allSubgraphs, _id)) {\n res.push(sg.nodes[pos]);\n }\n });\n return { nodes: res };\n};\n\nexport const lex = {\n firstGraph,\n};\n\nconst getTypeFromVertex = (vertex: FlowVertex) => {\n if (vertex.type === 'square') {\n return 'squareRect';\n }\n if (vertex.type === 'round') {\n return 'roundedRect';\n }\n\n return vertex.type ?? 'squareRect';\n};\n\nconst findNode = (nodes: Node[], id: string) => nodes.find((node) => node.id === id);\nconst destructEdgeType = (type: string | undefined) => {\n let arrowTypeStart = 'none';\n let arrowTypeEnd = 'arrow_point';\n switch (type) {\n case 'arrow_point':\n case 'arrow_circle':\n case 'arrow_cross':\n arrowTypeEnd = type;\n break;\n\n case 'double_arrow_point':\n case 'double_arrow_circle':\n case 'double_arrow_cross':\n arrowTypeStart = type.replace('double_', '');\n arrowTypeEnd = arrowTypeStart;\n break;\n }\n return { arrowTypeStart, arrowTypeEnd };\n};\n\nconst addNodeFromVertex = (\n vertex: FlowVertex,\n nodes: Node[],\n parentDB: Map<string, string>,\n subGraphDB: Map<string, boolean>,\n config: any,\n look: string\n) => {\n const parentId = parentDB.get(vertex.id);\n const isGroup = subGraphDB.get(vertex.id) ?? false;\n\n const node = findNode(nodes, vertex.id);\n if (node) {\n node.cssStyles = vertex.styles;\n node.cssCompiledStyles = getCompiledStyles(vertex.classes);\n node.cssClasses = vertex.classes.join(' ');\n } else {\n nodes.push({\n id: vertex.id,\n label: vertex.text,\n labelStyle: '',\n parentId,\n padding: config.flowchart?.padding || 8,\n cssStyles: vertex.styles,\n cssCompiledStyles: getCompiledStyles(['default', 'node', ...vertex.classes]),\n cssClasses: 'default ' + vertex.classes.join(' '),\n shape: getTypeFromVertex(vertex),\n dir: vertex.dir,\n domId: vertex.domId,\n isGroup,\n look,\n link: vertex.link,\n linkTarget: vertex.linkTarget,\n tooltip: getTooltip(vertex.id),\n });\n }\n};\n\nfunction getCompiledStyles(classDefs: string[]) {\n let compiledStyles: string[] = [];\n for (const customClass of classDefs) {\n const cssClass = classes.get(customClass);\n if (cssClass?.styles) {\n compiledStyles = [...compiledStyles, ...(cssClass.styles ?? [])].map((s) => s.trim());\n }\n if (cssClass?.textStyles) {\n compiledStyles = [...compiledStyles, ...(cssClass.textStyles ?? [])].map((s) => s.trim());\n }\n }\n return compiledStyles;\n}\n\nexport const getData = () => {\n const config = getConfig();\n const nodes: Node[] = [];\n const edges: Edge[] = [];\n\n const subGraphs = getSubGraphs();\n const parentDB = new Map<string, string>();\n const subGraphDB = new Map<string, boolean>();\n\n // Setup the subgraph data for adding nodes\n for (let i = subGraphs.length - 1; i >= 0; i--) {\n const subGraph = subGraphs[i];\n if (subGraph.nodes.length > 0) {\n subGraphDB.set(subGraph.id, true);\n }\n for (const id of subGraph.nodes) {\n parentDB.set(id, subGraph.id);\n }\n }\n\n // Data is setup, add the nodes\n for (let i = subGraphs.length - 1; i >= 0; i--) {\n const subGraph = subGraphs[i];\n nodes.push({\n id: subGraph.id,\n label: subGraph.title,\n labelStyle: '',\n parentId: parentDB.get(subGraph.id),\n padding: 8,\n cssCompiledStyles: getCompiledStyles(subGraph.classes),\n cssClasses: subGraph.classes.join(' '),\n shape: 'rect',\n dir: subGraph.dir,\n isGroup: true,\n look: config.look,\n });\n }\n\n const n = getVertices();\n n.forEach((vertex) => {\n addNodeFromVertex(vertex, nodes, parentDB, subGraphDB, config, config.look || 'classic');\n });\n\n const e = getEdges();\n e.forEach((rawEdge, index) => {\n const { arrowTypeStart, arrowTypeEnd } = destructEdgeType(rawEdge.type);\n const styles = [...(e.defaultStyle ?? [])];\n\n if (rawEdge.style) {\n styles.push(...rawEdge.style);\n }\n const edge: Edge = {\n id: getEdgeId(rawEdge.start, rawEdge.end, { counter: index, prefix: 'L' }),\n start: rawEdge.start,\n end: rawEdge.end,\n type: rawEdge.type ?? 'normal',\n label: rawEdge.text,\n labelpos: 'c',\n thickness: rawEdge.stroke,\n minlen: rawEdge.length,\n classes:\n rawEdge?.stroke === 'invisible'\n ? ''\n : 'edge-thickness-normal edge-pattern-solid flowchart-link',\n arrowTypeStart: rawEdge?.stroke === 'invisible' ? 'none' : arrowTypeStart,\n arrowTypeEnd: rawEdge?.stroke === 'invisible' ? 'none' : arrowTypeEnd,\n arrowheadStyle: 'fill: #333',\n labelStyle: styles,\n style: styles,\n pattern: rawEdge.stroke,\n look: config.look,\n };\n edges.push(edge);\n });\n\n return { nodes, edges, other: {}, config };\n};\n\nexport default {\n defaultConfig: () => defaultConfig.flowchart,\n setAccTitle,\n getAccTitle,\n getAccDescription,\n getData,\n setAccDescription,\n addVertex,\n lookUpDomId,\n addLink,\n updateLinkInterpolate,\n updateLink,\n addClass,\n setDirection,\n setClass,\n setTooltip,\n getTooltip,\n setClickEvent,\n setLink,\n bindFunctions,\n getDirection,\n getVertices,\n getEdges,\n getClasses,\n clear,\n setGen,\n defaultStyle,\n addSubGraph,\n getDepthFirstPos,\n indexNodes,\n getSubGraphs,\n destructLink,\n lex,\n exists,\n makeUniq,\n setDiagramTitle,\n getDiagramTitle,\n};\n", "import { select } from 'd3';\nimport { getConfig } from '../../diagram-api/diagramAPI.js';\nimport type { DiagramStyleClassDef } from '../../diagram-api/types.js';\nimport { log } from '../../logger.js';\nimport { getDiagramElement } from '../../rendering-util/insertElementsForSize.js';\nimport { getRegisteredLayoutAlgorithm, render } from '../../rendering-util/render.js';\nimport { setupViewPortForSVG } from '../../rendering-util/setupViewPortForSVG.js';\nimport type { LayoutData } from '../../rendering-util/types.js';\nimport utils from '../../utils.js';\nimport { getDirection } from './flowDb.js';\n\nexport const getClasses = function (\n text: string,\n diagramObj: any\n): Map<string, DiagramStyleClassDef> {\n return diagramObj.db.getClasses();\n};\n\nexport const draw = async function (text: string, id: string, _version: string, diag: any) {\n log.info('REF0:');\n log.info('Drawing state diagram (v2)', id);\n const { securityLevel, flowchart: conf, layout } = getConfig();\n\n // Handle root and document for when rendering in sandbox mode\n let sandboxElement;\n if (securityLevel === 'sandbox') {\n sandboxElement = select('#i' + id);\n }\n\n // @ts-ignore - document is always available\n const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;\n\n // The getData method provided in all supported diagrams is used to extract the data from the parsed structure\n // into the Layout data format\n log.debug('Before getData: ');\n const data4Layout = diag.db.getData() as LayoutData;\n log.debug('Data: ', data4Layout);\n // Create the root SVG\n const svg = getDiagramElement(id, securityLevel);\n const direction = getDirection();\n\n data4Layout.type = diag.type;\n data4Layout.layoutAlgorithm = getRegisteredLayoutAlgorithm(layout);\n if (data4Layout.layoutAlgorithm === 'dagre' && layout === 'elk') {\n log.warn(\n 'flowchart-elk was moved to an external package in Mermaid v11. Please refer [release notes](https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0) for more details. This diagram will be rendered using `dagre` layout as a fallback.'\n );\n }\n data4Layout.direction = direction;\n data4Layout.nodeSpacing = conf?.nodeSpacing || 50;\n data4Layout.rankSpacing = conf?.rankSpacing || 50;\n data4Layout.markers = ['point', 'circle', 'cross'];\n\n data4Layout.diagramId = id;\n log.debug('REF1:', data4Layout);\n await render(data4Layout, svg);\n const padding = data4Layout.config.flowchart?.diagramPadding ?? 8;\n utils.insertTitle(\n svg,\n 'flowchartTitleText',\n conf?.titleTopMargin || 0,\n diag.db.getDiagramTitle()\n );\n setupViewPortForSVG(svg, padding, 'flowchart', conf?.useMaxWidth || false);\n\n // If node has a link, wrap it in an anchor SVG object.\n for (const vertex of data4Layout.nodes) {\n const node = select(`#${id} [id=\"${vertex.id}\"]`);\n if (!node || !vertex.link) {\n continue;\n }\n const link = doc.createElementNS('http://www.w3.org/2000/svg', 'a');\n link.setAttributeNS('http://www.w3.org/2000/svg', 'class', vertex.cssClasses);\n link.setAttributeNS('http://www.w3.org/2000/svg', 'rel', 'noopener');\n if (securityLevel === 'sandbox') {\n link.setAttributeNS('http://www.w3.org/2000/svg', 'target', '_top');\n } else if (vertex.linkTarget) {\n link.setAttributeNS('http://www.w3.org/2000/svg', 'target', vertex.linkTarget);\n }\n\n const linkNode = node.insert(function () {\n return link;\n }, ':first-child');\n\n const shape = node.select('.label-container');\n if (shape) {\n linkNode.append(function () {\n return shape.node();\n });\n }\n\n const label = node.select('.label');\n if (label) {\n linkNode.append(function () {\n return label.node();\n });\n }\n }\n};\n\nexport default {\n getClasses,\n draw,\n};\n", "/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function(){\nvar o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,4],$V1=[1,3],$V2=[1,5],$V3=[1,8,9,10,11,27,34,36,38,42,58,81,82,83,84,85,86,99,102,103,106,108,111,112,113,118,119,120,121],$V4=[2,2],$V5=[1,13],$V6=[1,14],$V7=[1,15],$V8=[1,16],$V9=[1,23],$Va=[1,25],$Vb=[1,26],$Vc=[1,27],$Vd=[1,49],$Ve=[1,48],$Vf=[1,29],$Vg=[1,30],$Vh=[1,31],$Vi=[1,32],$Vj=[1,33],$Vk=[1,44],$Vl=[1,46],$Vm=[1,42],$Vn=[1,47],$Vo=[1,43],$Vp=[1,50],$Vq=[1,45],$Vr=[1,51],$Vs=[1,52],$Vt=[1,34],$Vu=[1,35],$Vv=[1,36],$Vw=[1,37],$Vx=[1,57],$Vy=[1,8,9,10,11,27,32,34,36,38,42,58,81,82,83,84,85,86,99,102,103,106,108,111,112,113,118,119,120,121],$Vz=[1,61],$VA=[1,60],$VB=[1,62],$VC=[8,9,11,73,75],$VD=[1,88],$VE=[1,93],$VF=[1,92],$VG=[1,89],$VH=[1,85],$VI=[1,91],$VJ=[1,87],$VK=[1,94],$VL=[1,90],$VM=[1,95],$VN=[1,86],$VO=[8,9,10,11,73,75],$VP=[8,9,10,11,44,73,75],$VQ=[8,9,10,11,29,42,44,46,48,50,52,54,56,58,61,63,65,66,68,73,75,86,99,102,103,106,108,111,112,113],$VR=[8,9,11,42,58,73,75,86,99,102,103,106,108,111,112,113],$VS=[42,58,86,99,102,103,106,108,111,112,113],$VT=[1,121],$VU=[1,120],$VV=[1,128],$VW=[1,142],$VX=[1,143],$VY=[1,144],$VZ=[1,145],$V_=[1,130],$V$=[1,132],$V01=[1,136],$V11=[1,137],$V21=[1,138],$V31=[1,139],$V41=[1,140],$V51=[1,141],$V61=[1,146],$V71=[1,147],$V81=[1,126],$V91=[1,127],$Va1=[1,134],$Vb1=[1,129],$Vc1=[1,133],$Vd1=[1,131],$Ve1=[8,9,10,11,27,32,34,36,38,42,58,81,82,83,84,85,86,99,102,103,106,108,111,112,113,118,119,120,121],$Vf1=[1,149],$Vg1=[8,9,11],$Vh1=[8,9,10,11,14,42,58,86,102,103,106,108,111,112,113],$Vi1=[1,169],$Vj1=[1,165],$Vk1=[1,166],$Vl1=[1,170],$Vm1=[1,167],$Vn1=[1,168],$Vo1=[75,113,116],$Vp1=[8,9,10,11,12,14,27,29,32,42,58,73,81,82,83,84,85,86,87,102,106,108,111,112,113],$Vq1=[10,103],$Vr1=[31,47,49,51,53,55,60,62,64,65,67,69,113,114,115],$Vs1=[1,235],$Vt1=[1,233],$Vu1=[1,237],$Vv1=[1,231],$Vw1=[1,232],$Vx1=[1,234],$Vy1=[1,236],$Vz1=[1,238],$VA1=[1,255],$VB1=[8,9,11,103],$VC1=[8,9,10,11,58,81,102,103,106,107,108,109];\nvar parser = {trace: function trace () { },\nyy: {},\nsymbols_: {\"error\":2,\"start\":3,\"graphConfig\":4,\"document\":5,\"line\":6,\"statement\":7,\"SEMI\":8,\"NEWLINE\":9,\"SPACE\":10,\"EOF\":11,\"GRAPH\":12,\"NODIR\":13,\"DIR\":14,\"FirstStmtSeparator\":15,\"ending\":16,\"endToken\":17,\"spaceList\":18,\"spaceListNewline\":19,\"vertexStatement\":20,\"separator\":21,\"styleStatement\":22,\"linkStyleStatement\":23,\"classDefStatement\":24,\"classStatement\":25,\"clickStatement\":26,\"subgraph\":27,\"textNoTags\":28,\"SQS\":29,\"text\":30,\"SQE\":31,\"end\":32,\"direction\":33,\"acc_title\":34,\"acc_title_value\":35,\"acc_descr\":36,\"acc_descr_value\":37,\"acc_descr_multiline_value\":38,\"link\":39,\"node\":40,\"styledVertex\":41,\"AMP\":42,\"vertex\":43,\"STYLE_SEPARATOR\":44,\"idString\":45,\"DOUBLECIRCLESTART\":46,\"DOUBLECIRCLEEND\":47,\"PS\":48,\"PE\":49,\"(-\":50,\"-)\":51,\"STADIUMSTART\":52,\"STADIUMEND\":53,\"SUBROUTINESTART\":54,\"SUBROUTINEEND\":55,\"VERTEX_WITH_PROPS_START\":56,\"NODE_STRING[field]\":57,\"COLON\":58,\"NODE_STRING[value]\":59,\"PIPE\":60,\"CYLINDERSTART\":61,\"CYLINDEREND\":62,\"DIAMOND_START\":63,\"DIAMOND_STOP\":64,\"TAGEND\":65,\"TRAPSTART\":66,\"TRAPEND\":67,\"INVTRAPSTART\":68,\"INVTRAPEND\":69,\"linkStatement\":70,\"arrowText\":71,\"TESTSTR\":72,\"START_LINK\":73,\"edgeText\":74,\"LINK\":75,\"edgeTextToken\":76,\"STR\":77,\"MD_STR\":78,\"textToken\":79,\"keywords\":80,\"STYLE\":81,\"LINKSTYLE\":82,\"CLASSDEF\":83,\"CLASS\":84,\"CLICK\":85,\"DOWN\":86,\"UP\":87,\"textNoTagsToken\":88,\"stylesOpt\":89,\"idString[vertex]\":90,\"idString[class]\":91,\"CALLBACKNAME\":92,\"CALLBACKARGS\":93,\"HREF\":94,\"LINK_TARGET\":95,\"STR[link]\":96,\"STR[tooltip]\":97,\"alphaNum\":98,\"DEFAULT\":99,\"numList\":100,\"INTERPOLATE\":101,\"NUM\":102,\"COMMA\":103,\"style\":104,\"styleComponent\":105,\"NODE_STRING\":106,\"UNIT\":107,\"BRKT\":108,\"PCT\":109,\"idStringToken\":110,\"MINUS\":111,\"MULT\":112,\"UNICODE_TEXT\":113,\"TEXT\":114,\"TAGSTART\":115,\"EDGE_TEXT\":116,\"alphaNumToken\":117,\"direction_tb\":118,\"direction_bt\":119,\"direction_rl\":120,\"direction_lr\":121,\"$accept\":0,\"$end\":1},\nterminals_: {2:\"error\",8:\"SEMI\",9:\"NEWLINE\",10:\"SPACE\",11:\"EOF\",12:\"GRAPH\",13:\"NODIR\",14:\"DIR\",27:\"subgraph\",29:\"SQS\",31:\"SQE\",32:\"end\",34:\"acc_title\",35:\"acc_title_value\",36:\"acc_descr\",37:\"acc_descr_value\",38:\"acc_descr_multiline_value\",42:\"AMP\",44:\"STYLE_SEPARATOR\",46:\"DOUBLECIRCLESTART\",47:\"DOUBLECIRCLEEND\",48:\"PS\",49:\"PE\",50:\"(-\",51:\"-)\",52:\"STADIUMSTART\",53:\"STADIUMEND\",54:\"SUBROUTINESTART\",55:\"SUBROUTINEEND\",56:\"VERTEX_WITH_PROPS_START\",57:\"NODE_STRING[field]\",58:\"COLON\",59:\"NODE_STRING[value]\",60:\"PIPE\",61:\"CYLINDERSTART\",62:\"CYLINDEREND\",63:\"DIAMOND_START\",64:\"DIAMOND_STOP\",65:\"TAGEND\",66:\"TRAPSTART\",67:\"TRAPEND\",68:\"INVTRAPSTART\",69:\"INVTRAPEND\",72:\"TESTSTR\",73:\"START_LINK\",75:\"LINK\",77:\"STR\",78:\"MD_STR\",81:\"STYLE\",82:\"LINKSTYLE\",83:\"CLASSDEF\",84:\"CLASS\",85:\"CLICK\",86:\"DOWN\",87:\"UP\",90:\"idString[vertex]\",91:\"idString[class]\",92:\"CALLBACKNAME\",93:\"CALLBACKARGS\",94:\"HREF\",95:\"LINK_TARGET\",96:\"STR[link]\",97:\"STR[tooltip]\",99:\"DEFAULT\",101:\"INTERPOLATE\",102:\"NUM\",103:\"COMMA\",106:\"NODE_STRING\",107:\"UNIT\",108:\"BRKT\",109:\"PCT\",111:\"MINUS\",112:\"MULT\",113:\"UNICODE_TEXT\",114:\"TEXT\",115:\"TAGSTART\",116:\"EDGE_TEXT\",118:\"direction_tb\",119:\"direction_bt\",120:\"direction_rl\",121:\"direction_lr\"},\nproductions_: [0,[3,2],[5,0],[5,2],[6,1],[6,1],[6,1],[6,1],[6,1],[4,2],[4,2],[4,2],[4,3],[16,2],[16,1],[17,1],[17,1],[17,1],[15,1],[15,1],[15,2],[19,2],[19,2],[19,1],[19,1],[18,2],[18,1],[7,2],[7,2],[7,2],[7,2],[7,2],[7,2],[7,9],[7,6],[7,4],[7,1],[7,2],[7,2],[7,1],[21,1],[21,1],[21,1],[20,3],[20,4],[20,2],[20,1],[40,1],[40,5],[41,1],[41,3],[43,4],[43,4],[43,6],[43,4],[43,4],[43,4],[43,8],[43,4],[43,4],[43,4],[43,6],[43,4],[43,4],[43,4],[43,4],[43,4],[43,1],[39,2],[39,3],[39,3],[39,1],[39,3],[74,1],[74,2],[74,1],[74,1],[70,1],[71,3],[30,1],[30,2],[30,1],[30,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[28,1],[28,2],[28,1],[28,1],[24,5],[25,5],[26,2],[26,4],[26,3],[26,5],[26,3],[26,5],[26,5],[26,7],[26,2],[26,4],[26,2],[26,4],[26,4],[26,6],[22,5],[23,5],[23,5],[23,9],[23,9],[23,7],[23,7],[100,1],[100,3],[89,1],[89,3],[104,1],[104,2],[105,1],[105,1],[105,1],[105,1],[105,1],[105,1],[105,1],[105,1],[110,1],[110,1],[110,1],[110,1],[110,1],[110,1],[110,1],[110,1],[110,1],[110,1],[110,1],[79,1],[79,1],[79,1],[79,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[76,1],[76,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[45,1],[45,2],[98,1],[98,2],[33,1],[33,1],[33,1],[33,1]],\nperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n/* this == yyval */\n\nvar $0 = $$.length - 1;\nswitch (yystate) {\ncase 2:\n this.$ = [];\nbreak;\ncase 3:\n\n\t if(!Array.isArray($$[$0]) || $$[$0].length > 0){\n\t $$[$0-1].push($$[$0]);\n\t }\n\t this.$=$$[$0-1];\nbreak;\ncase 4: case 176:\nthis.$=$$[$0];\nbreak;\ncase 11:\n yy.setDirection('TB');this.$ = 'TB';\nbreak;\ncase 12:\n yy.setDirection($$[$0-1]);this.$ = $$[$0-1];\nbreak;\ncase 27:\n /* console.warn('finat vs', $$[$0-1].nodes); */ this.$=$$[$0-1].nodes\nbreak;\ncase 28: case 29: case 30: case 31: case 32:\nthis.$=[];\nbreak;\ncase 33:\nthis.$=yy.addSubGraph($$[$0-6],$$[$0-1],$$[$0-4]);\nbreak;\ncase 34:\nthis.$=yy.addSubGraph($$[$0-3],$$[$0-1],$$[$0-3]);\nbreak;\ncase 35:\nthis.$=yy.addSubGraph(undefined,$$[$0-1],undefined);\nbreak;\ncase 37:\n this.$=$$[$0].trim();yy.setAccTitle(this.$); \nbreak;\ncase 38: case 39:\n this.$=$$[$0].trim();yy.setAccDescription(this.$); \nbreak;\ncase 43:\n /* console.warn('vs',$$[$0-2].stmt,$$[$0]); */ yy.addLink($$[$0-2].stmt,$$[$0],$$[$0-1]); this.$ = { stmt: $$[$0], nodes: $$[$0].concat($$[$0-2].nodes) } \nbreak;\ncase 44:\n /* console.warn('vs',$$[$0-3].stmt,$$[$0-1]); */ yy.addLink($$[$0-3].stmt,$$[$0-1],$$[$0-2]); this.$ = { stmt: $$[$0-1], nodes: $$[$0-1].concat($$[$0-3].nodes) } \nbreak;\ncase 45:\n/*console.warn('noda', $$[$0-1]);*/ this.$ = {stmt: $$[$0-1], nodes:$$[$0-1] }\nbreak;\ncase 46:\n /*console.warn('noda', $$[$0]);*/ this.$ = {stmt: $$[$0], nodes:$$[$0] }\nbreak;\ncase 47:\n /* console.warn('nod', $$[$0]); */ this.$ = [$$[$0]];\nbreak;\ncase 48:\n this.$ = $$[$0-4].concat($$[$0]); /* console.warn('pip', $$[$0-4][0], $$[$0], this.$); */ \nbreak;\ncase 49:\n /* console.warn('nod', $$[$0]); */ this.$ = $$[$0];\nbreak;\ncase 50:\nthis.$ = $$[$0-2];yy.setClass($$[$0-2],$$[$0])\nbreak;\ncase 51:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'square');\nbreak;\ncase 52:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'doublecircle');\nbreak;\ncase 53:\nthis.$ = $$[$0-5];yy.addVertex($$[$0-5],$$[$0-2],'circle');\nbreak;\ncase 54:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'ellipse');\nbreak;\ncase 55:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'stadium');\nbreak;\ncase 56:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'subroutine');\nbreak;\ncase 57:\nthis.$ = $$[$0-7];yy.addVertex($$[$0-7],$$[$0-1],'rect',undefined,undefined,undefined, Object.fromEntries([[$$[$0-5], $$[$0-3]]]));\nbreak;\ncase 58:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'cylinder');\nbreak;\ncase 59:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'round');\nbreak;\ncase 60:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'diamond');\nbreak;\ncase 61:\nthis.$ = $$[$0-5];yy.addVertex($$[$0-5],$$[$0-2],'hexagon');\nbreak;\ncase 62:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'odd');\nbreak;\ncase 63:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'trapezoid');\nbreak;\ncase 64:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'inv_trapezoid');\nbreak;\ncase 65:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'lean_right');\nbreak;\ncase 66:\nthis.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'lean_left');\nbreak;\ncase 67:\n /*console.warn('h: ', $$[$0]);*/this.$ = $$[$0];yy.addVertex($$[$0]);\nbreak;\ncase 68:\n$$[$0-1].text = $$[$0];this.$ = $$[$0-1];\nbreak;\ncase 69: case 70:\n$$[$0-2].text = $$[$0-1];this.$ = $$[$0-2];\nbreak;\ncase 71:\nthis.$ = $$[$0];\nbreak;\ncase 72:\nvar inf = yy.destructLink($$[$0], $$[$0-2]); this.$ = {\"type\":inf.type,\"stroke\":inf.stroke,\"length\":inf.length,\"text\":$$[$0-1]};\nbreak;\ncase 73:\nthis.$={text:$$[$0], type:'text'};\nbreak;\ncase 74:\nthis.$={text:$$[$0-1].text+''+$$[$0], type:$$[$0-1].type};\nbreak;\ncase 75:\nthis.$={text: $$[$0], type: 'string'};\nbreak;\ncase 76:\nthis.$={text:$$[$0], type:'markdown'};\nbreak;\ncase 77:\nvar inf = yy.destructLink($$[$0]);this.$ = {\"type\":inf.type,\"stroke\":inf.stroke,\"length\":inf.length};\nbreak;\ncase 78:\nthis.$ = $$[$0-1];\nbreak;\ncase 79:\n this.$={text:$$[$0], type: 'text'};\nbreak;\ncase 80:\n this.$={text:$$[$0-1].text+''+$$[$0], type: $$[$0-1].type};\nbreak;\ncase 81:\n this.$ = {text: $$[$0], type: 'string'};\nbreak;\ncase 82: case 97:\n this.$={text: $$[$0], type: 'markdown'};\nbreak;\ncase 94:\nthis.$={text:$$[$0], type: 'text'};\nbreak;\ncase 95:\nthis.$={text:$$[$0-1].text+''+$$[$0], type: $$[$0-1].type};\nbreak;\ncase 96:\n this.$={text: $$[$0], type: 'text'};\nbreak;\ncase 98:\nthis.$ = $$[$0-4];yy.addClass($$[$0-2],$$[$0]);\nbreak;\ncase 99:\nthis.$ = $$[$0-4];yy.setClass($$[$0-2], $$[$0]);\nbreak;\ncase 100: case 108:\nthis.$ = $$[$0-1];yy.setClickEvent($$[$0-1], $$[$0]);\nbreak;\ncase 101: case 109:\nthis.$ = $$[$0-3];yy.setClickEvent($$[$0-3], $$[$0-2]);yy.setTooltip($$[$0-3], $$[$0]);\nbreak;\ncase 102:\nthis.$ = $$[$0-2];yy.setClickEvent($$[$0-2], $$[$0-1], $$[$0]);\nbreak;\ncase 103:\nthis.$ = $$[$0-4];yy.setClickEvent($$[$0-4], $$[$0-3], $$[$0-2]);yy.setTooltip($$[$0-4], $$[$0]);\nbreak;\ncase 104:\nthis.$ = $$[$0-2];yy.setLink($$[$0-2], $$[$0]);\nbreak;\ncase 105:\nthis.$ = $$[$0-4];yy.setLink($$[$0-4], $$[$0-2]);yy.setTooltip($$[$0-4], $$[$0]);\nbreak;\ncase 106:\nthis.$ = $$[$0-4];yy.setLink($$[$0-4], $$[$0-2], $$[$0]);\nbreak;\ncase 107:\nthis.$ = $$[$0-6];yy.setLink($$[$0-6], $$[$0-4], $$[$0]);yy.setTooltip($$[$0-6], $$[$0-2]);\nbreak;\ncase 110:\nthis.$ = $$[$0-1];yy.setLink($$[$0-1], $$[$0]);\nbreak;\ncase 111:\nthis.$ = $$[$0-3];yy.setLink($$[$0-3], $$[$0-2]);yy.setTooltip($$[$0-3], $$[$0]);\nbreak;\ncase 112:\nthis.$ = $$[$0-3];yy.setLink($$[$0-3], $$[$0-2], $$[$0]);\nbreak;\ncase 113:\nthis.$ = $$[$0-5];yy.setLink($$[$0-5], $$[$0-4], $$[$0]);yy.setTooltip($$[$0-5], $$[$0-2]);\nbreak;\ncase 114:\nthis.$ = $$[$0-4];yy.addVertex($$[$0-2],undefined,undefined,$$[$0]);\nbreak;\ncase 115:\nthis.$ = $$[$0-4];yy.updateLink([$$[$0-2]],$$[$0]);\nbreak;\ncase 116:\nthis.$ = $$[$0-4];yy.updateLink($$[$0-2],$$[$0]);\nbreak;\ncase 117:\nthis.$ = $$[$0-8];yy.updateLinkInterpolate([$$[$0-6]],$$[$0-2]);yy.updateLink([$$[$0-6]],$$[$0]);\nbreak;\ncase 118:\nthis.$ = $$[$0-8];yy.updateLinkInterpolate($$[$0-6],$$[$0-2]);yy.updateLink($$[$0-6],$$[$0]);\nbreak;\ncase 119:\nthis.$ = $$[$0-6];yy.updateLinkInterpolate([$$[$0-4]],$$[$0]);\nbreak;\ncase 120:\nthis.$ = $$[$0-6];yy.updateLinkInterpolate($$[$0-4],$$[$0]);\nbreak;\ncase 121: case 123:\nthis.$ = [$$[$0]]\nbreak;\ncase 122: case 124:\n$$[$0-2].push($$[$0]);this.$ = $$[$0-2];\nbreak;\ncase 126:\nthis.$ = $$[$0-1] + $$[$0];\nbreak;\ncase 174:\nthis.$=$$[$0]\nbreak;\ncase 175:\nthis.$=$$[$0-1]+''+$$[$0]\nbreak;\ncase 177:\nthis.$=$$[$0-1]+''+$$[$0];\nbreak;\ncase 178:\n this.$={stmt:'dir', value:'TB'};\nbreak;\ncase 179:\n this.$={stmt:'dir', value:'BT'};\nbreak;\ncase 180:\n this.$={stmt:'dir', value:'RL'};\nbreak;\ncase 181:\n this.$={stmt:'dir', value:'LR'};\nbreak;\n}\n},\ntable: [{3:1,4:2,9:$V0,10:$V1,12:$V2},{1:[3]},o($V3,$V4,{5:6}),{4:7,9:$V0,10:$V1,12:$V2},{4:8,9:$V0,10:$V1,12:$V2},{13:[1,9],14:[1,10]},{1:[2,1],6:11,7:12,8:$V5,9:$V6,10:$V7,11:$V8,20:17,22:18,23:19,24:20,25:21,26:22,27:$V9,33:24,34:$Va,36:$Vb,38:$Vc,40:28,41:38,42:$Vd,43:39,45:40,58:$Ve,81:$Vf,82:$Vg,83:$Vh,84:$Vi,85:$Vj,86:$Vk,99:$Vl,102:$Vm,103:$Vn,106:$Vo,108:$Vp,110:41,111:$Vq,112:$Vr,113:$Vs,118:$Vt,119:$Vu,120:$Vv,121:$Vw},o($V3,[2,9]),o($V3,[2,10]),o($V3,[2,11]),{8:[1,54],9:[1,55],10:$Vx,15:53,18:56},o($Vy,[2,3]),o($Vy,[2,4]),o($Vy,[2,5]),o($Vy,[2,6]),o($Vy,[2,7]),o($Vy,[2,8]),{8:$Vz,9:$VA,11:$VB,21:58,39:59,70:63,73:[1,64],75:[1,65]},{8:$Vz,9:$VA,11:$VB,21:66},{8:$Vz,9:$VA,11:$VB,21:67},{8:$Vz,9:$VA,11:$VB,21:68},{8:$Vz,9:$VA,11:$VB,21:69},{8:$Vz,9:$VA,11:$VB,21:70},{8:$Vz,9:$VA,10:[1,71],11:$VB,21:72},o($Vy,[2,36]),{35:[1,73]},{37:[1,74]},o($Vy,[2,39]),o($VC,[2,46],{18:75,10:$Vx}),{10:[1,76]},{10:[1,77]},{10:[1,78]},{10:[1,79]},{14:$VD,42:$VE,58:$VF,77:[1,83],86:$VG,92:[1,80],94:[1,81],98:82,102:$VH,103:$VI,106:$VJ,108:$VK,111:$VL,112:$VM,113:$VN,117:84},o($Vy,[2,178]),o($Vy,[2,179]),o($Vy,[2,180]),o($Vy,[2,181]),o($VO,[2,47]),o($VO,[2,49],{44:[1,96]}),o($VP,[2,67],{110:109,29:[1,97],42:$Vd,46:[1,98],48:[1,99],50:[1,100],52:[1,101],54:[1,102],56:[1,103],58:$Ve,61:[1,104],63:[1,105],65:[1,106],66:[1,107],68:[1,108],86:$Vk,99:$Vl,102:$Vm,103:$Vn,106:$Vo,108:$Vp,111:$Vq,112:$Vr,113:$Vs}),o($VQ,[2,174]),o($VQ,[2,135]),o($VQ,[2,136]),o($VQ,[2,137]),o($VQ,[2,138]),o($VQ,[2,139]),o($VQ,[2,140]),o($VQ,[2,141]),o($VQ,[2,142]),o($VQ,[2,143]),o($VQ,[2,144]),o($VQ,[2,145]),o($V3,[2,12]),o($V3,[2,18]),o($V3,[2,19]),{9:[1,110]},o($VR,[2,26],{18:111,10:$Vx}),o($Vy,[2,27]),{40:112,41:38,42:$Vd,43:39,45:40,58:$Ve,86:$Vk,99:$Vl,102:$Vm,103:$Vn,106:$Vo,108:$Vp,110:41,111:$Vq,112:$Vr,113:$Vs},o($Vy,[2,40]),o($Vy,[2,41]),o($Vy,[2,42]),o($VS,[2,71],{71:113,60:[1,115],72:[1,114]}),{74:116,76:117,77:[1,118],78:[1,119],113:$VT,116:$VU},o([42,58,60,72,86,99,102,103,106,108,111,112,113],[2,77]),o($Vy,[2,28]),o($Vy,[2,29]),o($Vy,[2,30]),o($Vy,[2,31]),o($Vy,[2,32]),{10:$VV,12:$VW,14:$VX,27:$VY,28:122,32:$VZ,42:$V_,58:$V$,73:$V01,77:[1,124],78:[1,125],80:135,81:$V11,82:$V21,83:$V31,84:$V41,85:$V51,86:$V61,87:$V71,88:123,102:$V81,106:$V91,108:$Va1,111:$Vb1,112:$Vc1,113:$Vd1},o($Ve1,$V4,{5:148}),o($Vy,[2,37]),o($Vy,[2,38]),o($VC,[2,45],{42:$Vf1}),{42:$Vd,45:150,58:$Ve,86:$Vk,99:$Vl,102:$Vm,103:$Vn,106:$Vo,108:$Vp,110:41,111:$Vq,112:$Vr,113:$Vs},{99:[1,151],100:152,102:[1,153]},{42:$Vd,45:154,58:$Ve,86:$Vk,99:$Vl,102:$Vm,103:$Vn,106:$Vo,108:$Vp,110:41,111:$Vq,112:$Vr,113:$Vs},{42:$Vd,45:155,58:$Ve,86:$Vk,99:$Vl,102:$Vm,103:$Vn,106:$Vo,108:$Vp,110:41,111:$Vq,112:$Vr,113:$Vs},o($Vg1,[2,100],{10:[1,156],93:[1,157]}),{77:[1,158]},o($Vg1,[2,108],{117:160,10:[1,159],14:$VD,42:$VE,58:$VF,86:$VG,102:$VH,103:$VI,106:$VJ,108:$VK,111:$VL,112:$VM,113:$VN}),o($Vg1,[2,110],{10:[1,161]}),o($Vh1,[2,176]),o($Vh1,[2,163]),o($Vh1,[2,164]),o($Vh1,[2,165]),o($Vh1,[2,166]),o($Vh1,[2,167]),o($Vh1,[2,168]),o($Vh1,[2,169]),o($Vh1,[2,170]),o($Vh1,[2,171]),o($Vh1,[2,172]),o($Vh1,[2,173]),{42:$Vd,45:162,58:$Ve,86:$Vk,99:$Vl,102:$Vm,103:$Vn,106:$Vo,108:$Vp,110:41,111:$Vq,112:$Vr,113:$Vs},{30:163,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:171,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:173,48:[1,172],65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:174,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:175,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:176,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{106:[1,177]},{30:178,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:179,63:[1,180],65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:181,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:182,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},{30:183,65:$Vi1,77:$Vj1,78:$Vk1,79:164,113:$Vl1,114:$Vm1,115:$Vn1},o($VQ,[2,175]),o($V3,[2,20]),o($VR,[2,25]),o($VC,[2,43],{18:18