{
  "version": 3,
  "sources": ["../src/diagrams/class/classRenderer.js", "../src/diagrams/class/classDiagram.ts"],
  "sourcesContent": ["import { select } from 'd3';\nimport { layout as dagreLayout } from 'dagre-d3-es/src/dagre/index.js';\nimport * as graphlib from 'dagre-d3-es/src/graphlib/index.js';\nimport { log } from '../../logger.js';\nimport svgDraw from './svgDraw.js';\nimport { configureSvgSize } from '../../setupGraphViewbox.js';\nimport { getConfig } from '../../config.js';\n\nlet idCache = {};\nconst padding = 20;\n\n/**\n * Gets the ID with the same label as in the cache\n *\n * @param {string} label The label to look for\n * @returns {string} The resulting ID\n */\nconst getGraphId = function (label) {\n  const foundEntry = Object.entries(idCache).find((entry) => entry[1].label === label);\n\n  if (foundEntry) {\n    return foundEntry[0];\n  }\n};\n\n/**\n * Setup arrow head and define the marker. The result is appended to the svg.\n *\n * @param {SVGSVGElement} elem The SVG element to append to\n */\nconst insertMarkers = function (elem) {\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'extensionStart')\n    .attr('class', 'extension')\n    .attr('refX', 0)\n    .attr('refY', 7)\n    .attr('markerWidth', 190)\n    .attr('markerHeight', 240)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 1,7 L18,13 V 1 Z');\n\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'extensionEnd')\n    .attr('refX', 19)\n    .attr('refY', 7)\n    .attr('markerWidth', 20)\n    .attr('markerHeight', 28)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 1,1 V 13 L18,7 Z'); // this is actual shape for arrowhead\n\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'compositionStart')\n    .attr('class', 'extension')\n    .attr('refX', 0)\n    .attr('refY', 7)\n    .attr('markerWidth', 190)\n    .attr('markerHeight', 240)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z');\n\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'compositionEnd')\n    .attr('refX', 19)\n    .attr('refY', 7)\n    .attr('markerWidth', 20)\n    .attr('markerHeight', 28)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z');\n\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'aggregationStart')\n    .attr('class', 'extension')\n    .attr('refX', 0)\n    .attr('refY', 7)\n    .attr('markerWidth', 190)\n    .attr('markerHeight', 240)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z');\n\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'aggregationEnd')\n    .attr('refX', 19)\n    .attr('refY', 7)\n    .attr('markerWidth', 20)\n    .attr('markerHeight', 28)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z');\n\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'dependencyStart')\n    .attr('class', 'extension')\n    .attr('refX', 0)\n    .attr('refY', 7)\n    .attr('markerWidth', 190)\n    .attr('markerHeight', 240)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 5,7 L9,13 L1,7 L9,1 Z');\n\n  elem\n    .append('defs')\n    .append('marker')\n    .attr('id', 'dependencyEnd')\n    .attr('refX', 19)\n    .attr('refY', 7)\n    .attr('markerWidth', 20)\n    .attr('markerHeight', 28)\n    .attr('orient', 'auto')\n    .append('path')\n    .attr('d', 'M 18,7 L9,13 L14,7 L9,1 Z');\n};\n\n/**\n * Draws a flowchart in the tag with id: id based on the graph definition in text.\n *\n * @param {string} text\n * @param {string} id\n * @param {any} _version\n * @param diagObj\n */\nexport const draw = function (text, id, _version, diagObj) {\n  const conf = getConfig().class;\n  idCache = {};\n\n  log.info('Rendering diagram ' + text);\n\n  const securityLevel = getConfig().securityLevel;\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  const root =\n    securityLevel === 'sandbox'\n      ? select(sandboxElement.nodes()[0].contentDocument.body)\n      : select('body');\n\n  // Fetch the default direction, use TD if none was found\n  const diagram = root.select(`[id='${id}']`);\n  insertMarkers(diagram);\n\n  // Layout graph, Create a new directed graph\n  const g = new graphlib.Graph({\n    multigraph: true,\n  });\n\n  // Set an object for the graph label\n  g.setGraph({\n    isMultiGraph: true,\n  });\n\n  // Default to assigning a new object as a label for each new edge.\n  g.setDefaultEdgeLabel(function () {\n    return {};\n  });\n\n  const classes = diagObj.db.getClasses();\n  const keys = Object.keys(classes);\n\n  for (const key of keys) {\n    const classDef = classes[key];\n    const node = svgDraw.drawClass(diagram, classDef, conf, diagObj);\n    idCache[node.id] = node;\n\n    // Add nodes to the graph. The first argument is the node id. The second is\n    // metadata about the node. In this case we're going to add labels to each of\n    // our nodes.\n    g.setNode(node.id, node);\n\n    log.info('Org height: ' + node.height);\n  }\n\n  const relations = diagObj.db.getRelations();\n  relations.forEach(function (relation) {\n    log.info(\n      'tjoho' + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation)\n    );\n    g.setEdge(\n      getGraphId(relation.id1),\n      getGraphId(relation.id2),\n      {\n        relation: relation,\n      },\n      relation.title || 'DEFAULT'\n    );\n  });\n\n  const notes = diagObj.db.getNotes();\n  notes.forEach(function (note) {\n    log.debug(`Adding note: ${JSON.stringify(note)}`);\n    const node = svgDraw.drawNote(diagram, note, conf, diagObj);\n    idCache[node.id] = node;\n\n    // Add nodes to the graph. The first argument is the node id. The second is\n    // metadata about the node. In this case we're going to add labels to each of\n    // our nodes.\n    g.setNode(node.id, node);\n    if (note.class && note.class in classes) {\n      g.setEdge(\n        note.id,\n        getGraphId(note.class),\n        {\n          relation: {\n            id1: note.id,\n            id2: note.class,\n            relation: {\n              type1: 'none',\n              type2: 'none',\n              lineType: 10,\n            },\n          },\n        },\n        'DEFAULT'\n      );\n    }\n  });\n\n  dagreLayout(g);\n  g.nodes().forEach(function (v) {\n    if (v !== undefined && g.node(v) !== undefined) {\n      log.debug('Node ' + v + ': ' + JSON.stringify(g.node(v)));\n      root\n        .select('#' + (diagObj.db.lookUpDomId(v) || v))\n        .attr(\n          'transform',\n          'translate(' +\n            (g.node(v).x - g.node(v).width / 2) +\n            ',' +\n            (g.node(v).y - g.node(v).height / 2) +\n            ' )'\n        );\n    }\n  });\n\n  g.edges().forEach(function (e) {\n    if (e !== undefined && g.edge(e) !== undefined) {\n      log.debug('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(g.edge(e)));\n      svgDraw.drawEdge(diagram, g.edge(e), g.edge(e).relation, conf, diagObj);\n    }\n  });\n\n  const svgBounds = diagram.node().getBBox();\n  const width = svgBounds.width + padding * 2;\n  const height = svgBounds.height + padding * 2;\n\n  configureSvgSize(diagram, height, width, conf.useMaxWidth);\n\n  // Ensure the viewBox includes the whole svgBounds area with extra space for padding\n  const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`;\n  log.debug(`viewBox ${vBox}`);\n  diagram.attr('viewBox', vBox);\n};\n\nexport default {\n  draw,\n};\n", "import { DiagramDefinition } from '../../diagram-api/types.js';\n// @ts-ignore: JISON doesn't support types\nimport parser from './parser/classDiagram.jison';\nimport db from './classDb.js';\nimport styles from './styles.js';\nimport renderer from './classRenderer.js';\n\nexport const diagram: DiagramDefinition = {\n  parser,\n  db,\n  renderer,\n  styles,\n  init: (cnf) => {\n    if (!cnf.class) {\n      cnf.class = {};\n    }\n    cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;\n    db.clear();\n  },\n};\n"],
  "mappings": "mWAQA,IAAIA,EAAU,CAAC,EACTC,EAAU,GAQVC,EAAaC,EAAA,SAAUC,EAAO,CAClC,IAAMC,EAAa,OAAO,QAAQL,CAAO,EAAE,KAAMM,GAAUA,EAAM,CAAC,EAAE,QAAUF,CAAK,EAEnF,GAAIC,EACF,OAAOA,EAAW,CAAC,CAEvB,EANmB,cAabE,EAAgBJ,EAAA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,CAAC,GAEfA,EAAI,MAAM,oBAAsBA,EAAI,oBACpCH,EAAG,MAAM,CACX,CACF",
  "names": ["idCache", "padding", "getGraphId", "__name", "label", "foundEntry", "entry", "insertMarkers", "elem", "draw", "text", "id", "_version", "diagObj", "conf", "getConfig", "log", "securityLevel", "sandboxElement", "select_default", "root", "diagram", "g", "Graph", "classes", "keys", "key", "classDef", "node", "svgDraw_default", "relation", "note", "layout", "v", "e", "svgBounds", "width", "height", "configureSvgSize", "vBox", "classRenderer_default", "diagram", "classDiagram_default", "classDb_default", "classRenderer_default", "styles_default", "cnf"]
}