UNPKG

1.11 MBSource Map (JSON)View Raw
1{"version":3,"file":"vis-network.min.js","sources":["../../lib/network/shapes.ts","../../lib/network/dotparser.js","../../lib/network/gephiParser.ts","../../lib/network/locales.ts","../../lib/network/CachedImage.js","../../lib/network/Images.js","../../lib/network/modules/Groups.js","../../lib/network/modules/components/shared/ComponentUtil.js","../../lib/network/modules/components/shared/LabelAccumulator.js","../../lib/network/modules/components/shared/LabelSplitter.js","../../lib/network/modules/components/shared/Label.js","../../lib/network/modules/components/nodes/util/NodeBase.js","../../lib/network/modules/components/nodes/shapes/Box.js","../../lib/network/modules/components/nodes/util/CircleImageBase.js","../../lib/network/modules/components/nodes/shapes/Circle.js","../../lib/network/modules/components/nodes/shapes/CircularImage.js","../../lib/network/modules/components/nodes/util/ShapeBase.js","../../lib/network/modules/components/nodes/shapes/CustomShape.js","../../lib/network/modules/components/nodes/shapes/Database.js","../../lib/network/modules/components/nodes/shapes/Diamond.js","../../lib/network/modules/components/nodes/shapes/Dot.js","../../lib/network/modules/components/nodes/shapes/Ellipse.js","../../lib/network/modules/components/nodes/shapes/Icon.js","../../lib/network/modules/components/nodes/shapes/Image.js","../../lib/network/modules/components/nodes/shapes/Square.js","../../lib/network/modules/components/nodes/shapes/Hexagon.js","../../lib/network/modules/components/nodes/shapes/Star.js","../../lib/network/modules/components/nodes/shapes/Text.js","../../lib/network/modules/components/nodes/shapes/Triangle.js","../../lib/network/modules/components/nodes/shapes/TriangleDown.js","../../lib/network/modules/components/Node.js","../../lib/network/modules/NodesHandler.js","../../lib/network/modules/components/edges/util/end-points.ts","../../lib/network/modules/components/edges/util/edge-base.ts","../../lib/network/modules/components/edges/util/bezier-edge-base.ts","../../lib/network/modules/components/edges/bezier-edge-dynamic.ts","../../lib/network/modules/components/edges/bezier-edge-static.ts","../../lib/network/modules/components/edges/util/cubic-bezier-edge-base.ts","../../lib/network/modules/components/edges/cubic-bezier-edge.ts","../../lib/network/modules/components/edges/straight-edge.ts","../../lib/network/modules/components/Edge.js","../../lib/network/modules/EdgesHandler.js","../../lib/network/modules/components/physics/BarnesHutSolver.js","../../lib/network/modules/components/physics/RepulsionSolver.js","../../lib/network/modules/components/physics/HierarchicalRepulsionSolver.js","../../lib/network/modules/components/physics/SpringSolver.js","../../lib/network/modules/components/physics/HierarchicalSpringSolver.js","../../lib/network/modules/components/physics/CentralGravitySolver.js","../../lib/network/modules/components/physics/FA2BasedRepulsionSolver.js","../../lib/network/modules/components/physics/FA2BasedCentralGravitySolver.js","../../lib/network/modules/PhysicsEngine.js","../../lib/network/NetworkUtil.js","../../lib/network/modules/components/nodes/Cluster.js","../../lib/network/modules/Clustering.js","../../lib/network/modules/CanvasRenderer.js","../../lib/hammerUtil.js","../../lib/network/modules/Canvas.js","../../lib/network/modules/View.js","../../lib/network/modules/view-handler/index.ts","../../lib/network/modules/components/NavigationHandler.js","../../lib/network/modules/InteractionHandler.js","../../lib/network/modules/selection/selection-accumulator.ts","../../lib/network/modules/SelectionHandler.js","../../lib/network/modules/components/DirectionStrategy.js","../../lib/network/modules/layout-engine/index.ts","../../lib/network/modules/LayoutEngine.js","../../lib/network/modules/ManipulationSystem.js","../../lib/network/options.ts","../../lib/network/modules/components/algorithms/FloydWarshall.js","../../lib/network/modules/KamadaKawai.js","../../lib/network/Network.js","../../lib/network/locale-utils.ts","../../lib/entry-esnext.ts"],"sourcesContent":["/**\n * Draw a circle.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param r - The radius of the circle.\n */\nexport function drawCircle(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number\n): void {\n ctx.beginPath();\n ctx.arc(x, y, r, 0, 2 * Math.PI, false);\n ctx.closePath();\n}\n\n/**\n * Draw a square.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param r - Half of the width and height of the square.\n */\nexport function drawSquare(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number\n): void {\n ctx.beginPath();\n ctx.rect(x - r, y - r, r * 2, r * 2);\n ctx.closePath();\n}\n\n/**\n * Draw an equilateral triangle standing on a side.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param r - Half of the length of the sides.\n *\n * @remarks\n * http://en.wikipedia.org/wiki/Equilateral_triangle\n */\nexport function drawTriangle(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number\n): void {\n ctx.beginPath();\n\n // the change in radius and the offset is here to center the shape\n r *= 1.15;\n y += 0.275 * r;\n\n const s = r * 2;\n const s2 = s / 2;\n const ir = (Math.sqrt(3) / 6) * s; // radius of inner circle\n const h = Math.sqrt(s * s - s2 * s2); // height\n\n ctx.moveTo(x, y - (h - ir));\n ctx.lineTo(x + s2, y + ir);\n ctx.lineTo(x - s2, y + ir);\n ctx.lineTo(x, y - (h - ir));\n ctx.closePath();\n}\n\n/**\n * Draw an equilateral triangle standing on a vertex.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param r - Half of the length of the sides.\n *\n * @remarks\n * http://en.wikipedia.org/wiki/Equilateral_triangle\n */\nexport function drawTriangleDown(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number\n): void {\n ctx.beginPath();\n\n // the change in radius and the offset is here to center the shape\n r *= 1.15;\n y -= 0.275 * r;\n\n const s = r * 2;\n const s2 = s / 2;\n const ir = (Math.sqrt(3) / 6) * s; // radius of inner circle\n const h = Math.sqrt(s * s - s2 * s2); // height\n\n ctx.moveTo(x, y + (h - ir));\n ctx.lineTo(x + s2, y - ir);\n ctx.lineTo(x - s2, y - ir);\n ctx.lineTo(x, y + (h - ir));\n ctx.closePath();\n}\n\n/**\n * Draw a star.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param r - The outer radius of the star.\n */\nexport function drawStar(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number\n): void {\n // http://www.html5canvastutorials.com/labs/html5-canvas-star-spinner/\n ctx.beginPath();\n\n // the change in radius and the offset is here to center the shape\n r *= 0.82;\n y += 0.1 * r;\n\n for (let n = 0; n < 10; n++) {\n const radius = n % 2 === 0 ? r * 1.3 : r * 0.5;\n ctx.lineTo(\n x + radius * Math.sin((n * 2 * Math.PI) / 10),\n y - radius * Math.cos((n * 2 * Math.PI) / 10)\n );\n }\n\n ctx.closePath();\n}\n\n/**\n * Draw a diamond.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param r - Half of the width and height of the diamond.\n *\n * @remarks\n * http://www.html5canvastutorials.com/labs/html5-canvas-star-spinner/\n */\nexport function drawDiamond(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number\n): void {\n ctx.beginPath();\n\n ctx.lineTo(x, y + r);\n ctx.lineTo(x + r, y);\n ctx.lineTo(x, y - r);\n ctx.lineTo(x - r, y);\n\n ctx.closePath();\n}\n\n/**\n * Draw a rectangle with rounded corners.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param w - The width of the rectangle.\n * @param h - The height of the rectangle.\n * @param r - The radius of the corners.\n *\n * @remarks\n * http://stackoverflow.com/questions/1255512/how-to-draw-a-rounded-rectangle-on-html-canvas\n */\nexport function drawRoundRect(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number\n): void {\n const r2d = Math.PI / 180;\n if (w - 2 * r < 0) {\n r = w / 2;\n } //ensure that the radius isn't too large for x\n if (h - 2 * r < 0) {\n r = h / 2;\n } //ensure that the radius isn't too large for y\n ctx.beginPath();\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arc(x + w - r, y + r, r, r2d * 270, r2d * 360, false);\n ctx.lineTo(x + w, y + h - r);\n ctx.arc(x + w - r, y + h - r, r, 0, r2d * 90, false);\n ctx.lineTo(x + r, y + h);\n ctx.arc(x + r, y + h - r, r, r2d * 90, r2d * 180, false);\n ctx.lineTo(x, y + r);\n ctx.arc(x + r, y + r, r, r2d * 180, r2d * 270, false);\n ctx.closePath();\n}\n\n/**\n * Draw an ellipse.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param w - The width of the ellipse.\n * @param h - The height of the ellipse.\n *\n * @remarks\n * http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas\n *\n * Postfix '_vis' added to discern it from standard method ellipse().\n */\nexport function drawEllipse(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number\n): void {\n const kappa = 0.5522848,\n ox = (w / 2) * kappa, // control point offset horizontal\n oy = (h / 2) * kappa, // control point offset vertical\n xe = x + w, // x-end\n ye = y + h, // y-end\n xm = x + w / 2, // x-middle\n ym = y + h / 2; // y-middle\n\n ctx.beginPath();\n ctx.moveTo(x, ym);\n ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);\n ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);\n ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);\n ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);\n ctx.closePath();\n}\n\n/**\n * Draw an isometric cylinder.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param w - The width of the database.\n * @param h - The height of the database.\n *\n * @remarks\n * http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas\n */\nexport function drawDatabase(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number\n): void {\n const f = 1 / 3;\n const wEllipse = w;\n const hEllipse = h * f;\n\n const kappa = 0.5522848,\n ox = (wEllipse / 2) * kappa, // control point offset horizontal\n oy = (hEllipse / 2) * kappa, // control point offset vertical\n xe = x + wEllipse, // x-end\n ye = y + hEllipse, // y-end\n xm = x + wEllipse / 2, // x-middle\n ym = y + hEllipse / 2, // y-middle\n ymb = y + (h - hEllipse / 2), // y-midlle, bottom ellipse\n yeb = y + h; // y-end, bottom ellipse\n\n ctx.beginPath();\n ctx.moveTo(xe, ym);\n\n ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);\n ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);\n\n ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);\n ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);\n\n ctx.lineTo(xe, ymb);\n\n ctx.bezierCurveTo(xe, ymb + oy, xm + ox, yeb, xm, yeb);\n ctx.bezierCurveTo(xm - ox, yeb, x, ymb + oy, x, ymb);\n\n ctx.lineTo(x, ym);\n}\n\n/**\n * Draw a dashed line.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The start position on the x axis.\n * @param y - The start position on the y axis.\n * @param x2 - The end position on the x axis.\n * @param y2 - The end position on the y axis.\n * @param pattern - List of lengths starting with line and then alternating between space and line.\n *\n * @author David Jordan\n * @remarks\n * date 2012-08-08\n * http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas\n */\nexport function drawDashedLine(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n x2: number,\n y2: number,\n pattern: number[]\n): void {\n ctx.beginPath();\n ctx.moveTo(x, y);\n\n const patternLength = pattern.length;\n const dx = x2 - x;\n const dy = y2 - y;\n const slope = dy / dx;\n let distRemaining = Math.sqrt(dx * dx + dy * dy);\n let patternIndex = 0;\n let draw = true;\n let xStep = 0;\n let dashLength = +pattern[0];\n\n while (distRemaining >= 0.1) {\n dashLength = +pattern[patternIndex++ % patternLength];\n if (dashLength > distRemaining) {\n dashLength = distRemaining;\n }\n\n xStep = Math.sqrt((dashLength * dashLength) / (1 + slope * slope));\n xStep = dx < 0 ? -xStep : xStep;\n x += xStep;\n y += slope * xStep;\n\n if (draw === true) {\n ctx.lineTo(x, y);\n } else {\n ctx.moveTo(x, y);\n }\n\n distRemaining -= dashLength;\n draw = !draw;\n }\n}\n\n/**\n * Draw a hexagon.\n *\n * @param ctx - The context this shape will be rendered to.\n * @param x - The position of the center on the x axis.\n * @param y - The position of the center on the y axis.\n * @param r - The radius of the hexagon.\n */\nexport function drawHexagon(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number\n): void {\n ctx.beginPath();\n const sides = 6;\n const a = (Math.PI * 2) / sides;\n ctx.moveTo(x + r, y);\n for (let i = 1; i < sides; i++) {\n ctx.lineTo(x + r * Math.cos(a * i), y + r * Math.sin(a * i));\n }\n ctx.closePath();\n}\n\nconst shapeMap = {\n circle: drawCircle,\n dashedLine: drawDashedLine,\n database: drawDatabase,\n diamond: drawDiamond,\n ellipse: drawEllipse,\n ellipse_vis: drawEllipse,\n hexagon: drawHexagon,\n roundRect: drawRoundRect,\n square: drawSquare,\n star: drawStar,\n triangle: drawTriangle,\n triangleDown: drawTriangleDown,\n};\n\n/**\n * Returns either custom or native drawing function base on supplied name.\n *\n * @param name - The name of the function. Either the name of a\n * CanvasRenderingContext2D property or an export from shapes.ts without the\n * draw prefix.\n *\n * @returns The function that can be used for rendering. In case of native\n * CanvasRenderingContext2D function the API is normalized to\n * `(ctx: CanvasRenderingContext2D, ...originalArgs) => void`.\n */\nexport function getShape(\n name: keyof CanvasRenderingContext2D | keyof typeof shapeMap\n): any {\n if (Object.prototype.hasOwnProperty.call(shapeMap, name)) {\n return (shapeMap as any)[name];\n } else {\n return function (ctx: CanvasRenderingContext2D, ...args: any[]): void {\n (CanvasRenderingContext2D.prototype as any)[name].call(ctx, args);\n };\n }\n}\n","/* eslint-disable no-prototype-builtins */\n/* eslint-disable no-unused-vars */\n/* eslint-disable no-var */\n\n/**\n * Parse a text source containing data in DOT language into a JSON object.\n * The object contains two lists: one with nodes and one with edges.\n *\n * DOT language reference: http://www.graphviz.org/doc/info/lang.html\n *\n * DOT language attributes: http://graphviz.org/content/attrs\n *\n * @param {string} data Text containing a graph in DOT-notation\n * @returns {object} graph An object containing two parameters:\n * {Object[]} nodes\n * {Object[]} edges\n *\n * -------------------------------------------\n * TODO\n * ====\n *\n * For label handling, this is an incomplete implementation. From docs (quote #3015):\n *\n * > the escape sequences \"\\n\", \"\\l\" and \"\\r\" divide the label into lines, centered,\n * > left-justified, and right-justified, respectively.\n *\n * Source: http://www.graphviz.org/content/attrs#kescString\n *\n * > As another aid for readability, dot allows double-quoted strings to span multiple physical\n * > lines using the standard C convention of a backslash immediately preceding a newline\n * > character\n * > In addition, double-quoted strings can be concatenated using a '+' operator.\n * > As HTML strings can contain newline characters, which are used solely for formatting,\n * > the language does not allow escaped newlines or concatenation operators to be used\n * > within them.\n *\n * - Currently, only '\\\\n' is handled\n * - Note that text explicitly says 'labels'; the dot parser currently handles escape\n * sequences in **all** strings.\n */\nexport function parseDOT(data) {\n dot = data;\n return parseGraph();\n}\n\n// mapping of attributes from DOT (the keys) to vis.js (the values)\nvar NODE_ATTR_MAPPING = {\n fontsize: \"font.size\",\n fontcolor: \"font.color\",\n labelfontcolor: \"font.color\",\n fontname: \"font.face\",\n color: [\"color.border\", \"color.background\"],\n fillcolor: \"color.background\",\n tooltip: \"title\",\n labeltooltip: \"title\",\n};\nvar EDGE_ATTR_MAPPING = Object.create(NODE_ATTR_MAPPING);\nEDGE_ATTR_MAPPING.color = \"color.color\";\nEDGE_ATTR_MAPPING.style = \"dashes\";\n\n// token types enumeration\nvar TOKENTYPE = {\n NULL: 0,\n DELIMITER: 1,\n IDENTIFIER: 2,\n UNKNOWN: 3,\n};\n\n// map with all delimiters\nvar DELIMITERS = {\n \"{\": true,\n \"}\": true,\n \"[\": true,\n \"]\": true,\n \";\": true,\n \"=\": true,\n \",\": true,\n\n \"->\": true,\n \"--\": true,\n};\n\nvar dot = \"\"; // current dot file\nvar index = 0; // current index in dot file\nvar c = \"\"; // current token character in expr\nvar token = \"\"; // current token\nvar tokenType = TOKENTYPE.NULL; // type of the token\n\n/**\n * Get the first character from the dot file.\n * The character is stored into the char c. If the end of the dot file is\n * reached, the function puts an empty string in c.\n */\nfunction first() {\n index = 0;\n c = dot.charAt(0);\n}\n\n/**\n * Get the next character from the dot file.\n * The character is stored into the char c. If the end of the dot file is\n * reached, the function puts an empty string in c.\n */\nfunction next() {\n index++;\n c = dot.charAt(index);\n}\n\n/**\n * Preview the next character from the dot file.\n *\n * @returns {string} cNext\n */\nfunction nextPreview() {\n return dot.charAt(index + 1);\n}\n\n/**\n * Test whether given character is alphabetic or numeric ( a-zA-Z_0-9.:# )\n *\n * @param {string} c\n * @returns {boolean} isAlphaNumeric\n */\nfunction isAlphaNumeric(c) {\n var charCode = c.charCodeAt(0);\n\n if (charCode < 47) {\n // #.\n return charCode === 35 || charCode === 46;\n }\n if (charCode < 59) {\n // 0-9 and :\n return charCode > 47;\n }\n if (charCode < 91) {\n // A-Z\n return charCode > 64;\n }\n if (charCode < 96) {\n // _\n return charCode === 95;\n }\n if (charCode < 123) {\n // a-z\n return charCode > 96;\n }\n\n return false;\n}\n\n/**\n * Merge all options of object b into object b\n *\n * @param {object} a\n * @param {object} b\n * @returns {object} a\n */\nfunction merge(a, b) {\n if (!a) {\n a = {};\n }\n\n if (b) {\n for (var name in b) {\n if (b.hasOwnProperty(name)) {\n a[name] = b[name];\n }\n }\n }\n return a;\n}\n\n/**\n * Set a value in an object, where the provided parameter name can be a\n * path with nested parameters. For example:\n *\n * var obj = {a: 2};\n * setValue(obj, 'b.c', 3); // obj = {a: 2, b: {c: 3}}\n *\n * @param {object} obj\n * @param {string} path A parameter name or dot-separated parameter path,\n * like \"color.highlight.border\".\n * @param {*} value\n */\nfunction setValue(obj, path, value) {\n var keys = path.split(\".\");\n var o = obj;\n while (keys.length) {\n var key = keys.shift();\n if (keys.length) {\n // this isn't the end point\n if (!o[key]) {\n o[key] = {};\n }\n o = o[key];\n } else {\n // this is the end point\n o[key] = value;\n }\n }\n}\n\n/**\n * Add a node to a graph object. If there is already a node with\n * the same id, their attributes will be merged.\n *\n * @param {object} graph\n * @param {object} node\n */\nfunction addNode(graph, node) {\n var i, len;\n var current = null;\n\n // find root graph (in case of subgraph)\n var graphs = [graph]; // list with all graphs from current graph to root graph\n var root = graph;\n while (root.parent) {\n graphs.push(root.parent);\n root = root.parent;\n }\n\n // find existing node (at root level) by its id\n if (root.nodes) {\n for (i = 0, len = root.nodes.length; i < len; i++) {\n if (node.id === root.nodes[i].id) {\n current = root.nodes[i];\n break;\n }\n }\n }\n\n if (!current) {\n // this is a new node\n current = {\n id: node.id,\n };\n if (graph.node) {\n // clone default attributes\n current.attr = merge(current.attr, graph.node);\n }\n }\n\n // add node to this (sub)graph and all its parent graphs\n for (i = graphs.length - 1; i >= 0; i--) {\n var g = graphs[i];\n\n if (!g.nodes) {\n g.nodes = [];\n }\n if (g.nodes.indexOf(current) === -1) {\n g.nodes.push(current);\n }\n }\n\n // merge attributes\n if (node.attr) {\n current.attr = merge(current.attr, node.attr);\n }\n}\n\n/**\n * Add an edge to a graph object\n *\n * @param {object} graph\n * @param {object} edge\n */\nfunction addEdge(graph, edge) {\n if (!graph.edges) {\n graph.edges = [];\n }\n graph.edges.push(edge);\n if (graph.edge) {\n var attr = merge({}, graph.edge); // clone default attributes\n edge.attr = merge(attr, edge.attr); // merge attributes\n }\n}\n\n/**\n * Create an edge to a graph object\n *\n * @param {object} graph\n * @param {string | number | object} from\n * @param {string | number | object} to\n * @param {string} type\n * @param {object | null} attr\n * @returns {object} edge\n */\nfunction createEdge(graph, from, to, type, attr) {\n var edge = {\n from: from,\n to: to,\n type: type,\n };\n\n if (graph.edge) {\n edge.attr = merge({}, graph.edge); // clone default attributes\n }\n edge.attr = merge(edge.attr || {}, attr); // merge attributes\n\n // Move arrows attribute from attr to edge temporally created in\n // parseAttributeList().\n if (attr != null) {\n if (attr.hasOwnProperty(\"arrows\") && attr[\"arrows\"] != null) {\n edge[\"arrows\"] = { to: { enabled: true, type: attr.arrows.type } };\n attr[\"arrows\"] = null;\n }\n }\n return edge;\n}\n\n/**\n * Get next token in the current dot file.\n * The token and token type are available as token and tokenType\n */\nfunction getToken() {\n tokenType = TOKENTYPE.NULL;\n token = \"\";\n\n // skip over whitespaces\n while (c === \" \" || c === \"\\t\" || c === \"\\n\" || c === \"\\r\") {\n // space, tab, enter\n next();\n }\n\n do {\n var isComment = false;\n\n // skip comment\n if (c === \"#\") {\n // find the previous non-space character\n var i = index - 1;\n while (dot.charAt(i) === \" \" || dot.charAt(i) === \"\\t\") {\n i--;\n }\n if (dot.charAt(i) === \"\\n\" || dot.charAt(i) === \"\") {\n // the # is at the start of a line, this is indeed a line comment\n while (c != \"\" && c != \"\\n\") {\n next();\n }\n isComment = true;\n }\n }\n if (c === \"/\" && nextPreview() === \"/\") {\n // skip line comment\n while (c != \"\" && c != \"\\n\") {\n next();\n }\n isComment = true;\n }\n if (c === \"/\" && nextPreview() === \"*\") {\n // skip block comment\n while (c != \"\") {\n if (c === \"*\" && nextPreview() === \"/\") {\n // end of block comment found. skip these last two characters\n next();\n next();\n break;\n } else {\n next();\n }\n }\n isComment = true;\n }\n\n // skip over whitespaces\n while (c === \" \" || c === \"\\t\" || c === \"\\n\" || c === \"\\r\") {\n // space, tab, enter\n next();\n }\n } while (isComment);\n\n // check for end of dot file\n if (c === \"\") {\n // token is still empty\n tokenType = TOKENTYPE.DELIMITER;\n return;\n }\n\n // check for delimiters consisting of 2 characters\n var c2 = c + nextPreview();\n if (DELIMITERS[c2]) {\n tokenType = TOKENTYPE.DELIMITER;\n token = c2;\n next();\n next();\n return;\n }\n\n // check for delimiters consisting of 1 character\n if (DELIMITERS[c]) {\n tokenType = TOKENTYPE.DELIMITER;\n token = c;\n next();\n return;\n }\n\n // check for an identifier (number or string)\n // TODO: more precise parsing of numbers/strings (and the port separator ':')\n if (isAlphaNumeric(c) || c === \"-\") {\n token += c;\n next();\n\n while (isAlphaNumeric(c)) {\n token += c;\n next();\n }\n if (token === \"false\") {\n token = false; // convert to boolean\n } else if (token === \"true\") {\n token = true; // convert to boolean\n } else if (!isNaN(Number(token))) {\n token = Number(token); // convert to number\n }\n tokenType = TOKENTYPE.IDENTIFIER;\n return;\n }\n\n // check for a string enclosed by double quotes\n if (c === '\"') {\n next();\n while (c != \"\" && (c != '\"' || (c === '\"' && nextPreview() === '\"'))) {\n if (c === '\"') {\n // skip the escape character\n token += c;\n next();\n } else if (c === \"\\\\\" && nextPreview() === \"n\") {\n // Honor a newline escape sequence\n token += \"\\n\";\n next();\n } else {\n token += c;\n }\n next();\n }\n if (c != '\"') {\n throw newSyntaxError('End of string \" expected');\n }\n next();\n tokenType = TOKENTYPE.IDENTIFIER;\n return;\n }\n\n // something unknown is found, wrong characters, a syntax error\n tokenType = TOKENTYPE.UNKNOWN;\n while (c != \"\") {\n token += c;\n next();\n }\n throw new SyntaxError('Syntax error in part \"' + chop(token, 30) + '\"');\n}\n\n/**\n * Parse a graph.\n *\n * @returns {object} graph\n */\nfunction parseGraph() {\n var graph = {};\n\n first();\n getToken();\n\n // optional strict keyword\n if (token === \"strict\") {\n graph.strict = true;\n getToken();\n }\n\n // graph or digraph keyword\n if (token === \"graph\" || token === \"digraph\") {\n graph.type = token;\n getToken();\n }\n\n // optional graph id\n if (tokenType === TOKENTYPE.IDENTIFIER) {\n graph.id = token;\n getToken();\n }\n\n // open angle bracket\n if (token != \"{\") {\n throw newSyntaxError(\"Angle bracket { expected\");\n }\n getToken();\n\n // statements\n parseStatements(graph);\n\n // close angle bracket\n if (token != \"}\") {\n throw newSyntaxError(\"Angle bracket } expected\");\n }\n getToken();\n\n // end of file\n if (token !== \"\") {\n throw newSyntaxError(\"End of file expected\");\n }\n getToken();\n\n // remove temporary default options\n delete graph.node;\n delete graph.edge;\n delete graph.graph;\n\n return graph;\n}\n\n/**\n * Parse a list with statements.\n *\n * @param {object} graph\n */\nfunction parseStatements(graph) {\n while (token !== \"\" && token != \"}\") {\n parseStatement(graph);\n if (token === \";\") {\n getToken();\n }\n }\n}\n\n/**\n * Parse a single statement. Can be a an attribute statement, node\n * statement, a series of node statements and edge statements, or a\n * parameter.\n *\n * @param {object} graph\n */\nfunction parseStatement(graph) {\n // parse subgraph\n var subgraph = parseSubgraph(graph);\n if (subgraph) {\n // edge statements\n parseEdge(graph, subgraph);\n\n return;\n }\n\n // parse an attribute statement\n var attr = parseAttributeStatement(graph);\n if (attr) {\n return;\n }\n\n // parse node\n if (tokenType != TOKENTYPE.IDENTIFIER) {\n throw newSyntaxError(\"Identifier expected\");\n }\n var id = token; // id can be a string or a number\n getToken();\n\n if (token === \"=\") {\n // id statement\n getToken();\n if (tokenType != TOKENTYPE.IDENTIFIER) {\n throw newSyntaxError(\"Identifier expected\");\n }\n graph[id] = token;\n getToken();\n // TODO: implement comma separated list with \"a_list: ID=ID [','] [a_list] \"\n } else {\n parseNodeStatement(graph, id);\n }\n}\n\n/**\n * Parse a subgraph\n *\n * @param {object} graph parent graph object\n * @returns {object | null} subgraph\n */\nfunction parseSubgraph(graph) {\n var subgraph = null;\n\n // optional subgraph keyword\n if (token === \"subgraph\") {\n subgraph = {};\n subgraph.type = \"subgraph\";\n getToken();\n\n // optional graph id\n if (tokenType === TOKENTYPE.IDENTIFIER) {\n subgraph.id = token;\n getToken();\n }\n }\n\n // open angle bracket\n if (token === \"{\") {\n getToken();\n\n if (!subgraph) {\n subgraph = {};\n }\n subgraph.parent = graph;\n subgraph.node = graph.node;\n subgraph.edge = graph.edge;\n subgraph.graph = graph.graph;\n\n // statements\n parseStatements(subgraph);\n\n // close angle bracket\n if (token != \"}\") {\n throw newSyntaxError(\"Angle bracket } expected\");\n }\n getToken();\n\n // remove temporary default options\n delete subgraph.node;\n delete subgraph.edge;\n delete subgraph.graph;\n delete subgraph.parent;\n\n // register at the parent graph\n if (!graph.subgraphs) {\n graph.subgraphs = [];\n }\n graph.subgraphs.push(subgraph);\n }\n\n return subgraph;\n}\n\n/**\n * parse an attribute statement like \"node [shape=circle fontSize=16]\".\n * Available keywords are 'node', 'edge', 'graph'.\n * The previous list with default attributes will be replaced\n *\n * @param {object} graph\n * @returns {string | null} keyword Returns the name of the parsed attribute\n * (node, edge, graph), or null if nothing\n * is parsed.\n */\nfunction parseAttributeStatement(graph) {\n // attribute statements\n if (token === \"node\") {\n getToken();\n\n // node attributes\n graph.node = parseAttributeList();\n return \"node\";\n } else if (token === \"edge\") {\n getToken();\n\n // edge attributes\n graph.edge = parseAttributeList();\n return \"edge\";\n } else if (token === \"graph\") {\n getToken();\n\n // graph attributes\n graph.graph = parseAttributeList();\n return \"graph\";\n }\n\n return null;\n}\n\n/**\n * parse a node statement\n *\n * @param {object} graph\n * @param {string | number} id\n */\nfunction parseNodeStatement(graph, id) {\n // node statement\n var node = {\n id: id,\n };\n var attr = parseAttributeList();\n if (attr) {\n node.attr = attr;\n }\n addNode(graph, node);\n\n // edge statements\n parseEdge(graph, id);\n}\n\n/**\n * Parse an edge or a series of edges\n *\n * @param {object} graph\n * @param {string | number} from Id of the from node\n */\nfunction parseEdge(graph, from) {\n while (token === \"->\" || token === \"--\") {\n var to;\n var type = token;\n getToken();\n\n var subgraph = parseSubgraph(graph);\n if (subgraph) {\n to = subgraph;\n } else {\n if (tokenType != TOKENTYPE.IDENTIFIER) {\n throw newSyntaxError(\"Identifier or subgraph expected\");\n }\n to = token;\n addNode(graph, {\n id: to,\n });\n getToken();\n }\n\n // parse edge attributes\n var attr = parseAttributeList();\n\n // create edge\n var edge = createEdge(graph, from, to, type, attr);\n addEdge(graph, edge);\n\n from = to;\n }\n}\n\n/**\n * As explained in [1], graphviz has limitations for combination of\n * arrow[head|tail] and dir. If attribute list includes 'dir',\n * following cases just be supported.\n * 1. both or none + arrowhead, arrowtail\n * 2. forward + arrowhead (arrowtail is not affedted)\n * 3. back + arrowtail (arrowhead is not affected)\n * [1] https://www.graphviz.org/doc/info/attrs.html#h:undir_note\n *\n * This function is called from parseAttributeList() to parse 'dir'\n * attribute with given 'attr_names' and 'attr_list'.\n *\n * @param {object} attr_names Array of attribute names\n * @param {object} attr_list Array of objects of attribute set\n * @returns {object} attr_list Updated attr_list\n */\nfunction parseDirAttribute(attr_names, attr_list) {\n var i;\n if (attr_names.includes(\"dir\")) {\n var idx = {}; // get index of 'arrows' and 'dir'\n idx.arrows = {};\n for (i = 0; i < attr_list.length; i++) {\n if (attr_list[i].name === \"arrows\") {\n if (attr_list[i].value.to != null) {\n idx.arrows.to = i;\n } else if (attr_list[i].value.from != null) {\n idx.arrows.from = i;\n } else {\n throw newSyntaxError(\"Invalid value of arrows\");\n }\n } else if (attr_list[i].name === \"dir\") {\n idx.dir = i;\n }\n }\n\n // first, add default arrow shape if it is not assigned to avoid error\n var dir_type = attr_list[idx.dir].value;\n if (!attr_names.includes(\"arrows\")) {\n if (dir_type === \"both\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { to: { enabled: true } },\n });\n idx.arrows.to = attr_list.length - 1;\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { from: { enabled: true } },\n });\n idx.arrows.from = attr_list.length - 1;\n } else if (dir_type === \"forward\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { to: { enabled: true } },\n });\n idx.arrows.to = attr_list.length - 1;\n } else if (dir_type === \"back\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { from: { enabled: true } },\n });\n idx.arrows.from = attr_list.length - 1;\n } else if (dir_type === \"none\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: \"\",\n });\n idx.arrows.to = attr_list.length - 1;\n } else {\n throw newSyntaxError('Invalid dir type \"' + dir_type + '\"');\n }\n }\n\n var from_type;\n var to_type;\n // update 'arrows' attribute from 'dir'.\n if (dir_type === \"both\") {\n // both of shapes of 'from' and 'to' are given\n if (idx.arrows.to && idx.arrows.from) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n attr_list.splice(idx.arrows.from, 1);\n\n // shape of 'to' is assigned and use default to 'from'\n } else if (idx.arrows.to) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = \"arrow\";\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // only shape of 'from' is assigned and use default for 'to'\n } else if (idx.arrows.from) {\n to_type = \"arrow\";\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n }\n } else if (dir_type === \"back\") {\n // given both of shapes, but use only 'from'\n if (idx.arrows.to && idx.arrows.from) {\n to_type = \"\";\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // given shape of 'to', but does not use it\n } else if (idx.arrows.to) {\n to_type = \"\";\n from_type = \"arrow\";\n idx.arrows.from = idx.arrows.to;\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // assign given 'from' shape\n } else if (idx.arrows.from) {\n to_type = \"\";\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n }\n\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n from: {\n enabled: true,\n type: attr_list[idx.arrows.from].value.from.type,\n },\n },\n };\n } else if (dir_type === \"none\") {\n var idx_arrow;\n if (idx.arrows.to) {\n idx_arrow = idx.arrows.to;\n } else {\n idx_arrow = idx.arrows.from;\n }\n\n attr_list[idx_arrow] = {\n attr: attr_list[idx_arrow].attr,\n name: attr_list[idx_arrow].name,\n value: \"\",\n };\n } else if (dir_type === \"forward\") {\n // given both of shapes, but use only 'to'\n if (idx.arrows.to && idx.arrows.from) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = \"\";\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // assign given 'to' shape\n } else if (idx.arrows.to) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = \"\";\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // given shape of 'from', but does not use it\n } else if (idx.arrows.from) {\n to_type = \"arrow\";\n from_type = \"\";\n idx.arrows.to = idx.arrows.from;\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n }\n\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: {\n enabled: true,\n type: attr_list[idx.arrows.to].value.to.type,\n },\n },\n };\n } else {\n throw newSyntaxError('Invalid dir type \"' + dir_type + '\"');\n }\n\n // remove 'dir' attribute no need anymore\n attr_list.splice(idx.dir, 1);\n }\n return attr_list;\n}\n\n/**\n * Parse a set with attributes,\n * for example [label=\"1.000\", shape=solid]\n *\n * @returns {object | null} attr\n */\nfunction parseAttributeList() {\n var i;\n var attr = null;\n\n // edge styles of dot and vis\n var edgeStyles = {\n dashed: true,\n solid: false,\n dotted: [1, 5],\n };\n\n /**\n * Define arrow types.\n * vis currently supports types defined in 'arrowTypes'.\n * Details of arrow shapes are described in\n * http://www.graphviz.org/content/arrow-shapes\n */\n var arrowTypes = {\n dot: \"circle\",\n box: \"box\",\n crow: \"crow\",\n curve: \"curve\",\n icurve: \"inv_curve\",\n normal: \"triangle\",\n inv: \"inv_triangle\",\n diamond: \"diamond\",\n tee: \"bar\",\n vee: \"vee\",\n };\n\n /**\n * 'attr_list' contains attributes for checking if some of them are affected\n * later. For instance, both of 'arrowhead' and 'dir' (edge style defined\n * in DOT) make changes to 'arrows' attribute in vis.\n */\n var attr_list = new Array();\n var attr_names = new Array(); // used for checking the case.\n\n // parse attributes\n while (token === \"[\") {\n getToken();\n attr = {};\n while (token !== \"\" && token != \"]\") {\n if (tokenType != TOKENTYPE.IDENTIFIER) {\n throw newSyntaxError(\"Attribute name expected\");\n }\n var name = token;\n\n getToken();\n if (token != \"=\") {\n throw newSyntaxError(\"Equal sign = expected\");\n }\n getToken();\n\n if (tokenType != TOKENTYPE.IDENTIFIER) {\n throw newSyntaxError(\"Attribute value expected\");\n }\n var value = token;\n\n // convert from dot style to vis\n if (name === \"style\") {\n value = edgeStyles[value];\n }\n\n var arrowType;\n if (name === \"arrowhead\") {\n arrowType = arrowTypes[value];\n name = \"arrows\";\n value = { to: { enabled: true, type: arrowType } };\n }\n\n if (name === \"arrowtail\") {\n arrowType = arrowTypes[value];\n name = \"arrows\";\n value = { from: { enabled: true, type: arrowType } };\n }\n\n attr_list.push({ attr: attr, name: name, value: value });\n attr_names.push(name);\n\n getToken();\n if (token == \",\") {\n getToken();\n }\n }\n\n if (token != \"]\") {\n throw newSyntaxError(\"Bracket ] expected\");\n }\n getToken();\n }\n\n /**\n * As explained in [1], graphviz has limitations for combination of\n * arrow[head|tail] and dir. If attribute list includes 'dir',\n * following cases just be supported.\n * 1. both or none + arrowhead, arrowtail\n * 2. forward + arrowhead (arrowtail is not affedted)\n * 3. back + arrowtail (arrowhead is not affected)\n * [1] https://www.graphviz.org/doc/info/attrs.html#h:undir_note\n */\n if (attr_names.includes(\"dir\")) {\n var idx = {}; // get index of 'arrows' and 'dir'\n idx.arrows = {};\n for (i = 0; i < attr_list.length; i++) {\n if (attr_list[i].name === \"arrows\") {\n if (attr_list[i].value.to != null) {\n idx.arrows.to = i;\n } else if (attr_list[i].value.from != null) {\n idx.arrows.from = i;\n } else {\n throw newSyntaxError(\"Invalid value of arrows\");\n }\n } else if (attr_list[i].name === \"dir\") {\n idx.dir = i;\n }\n }\n\n // first, add default arrow shape if it is not assigned to avoid error\n var dir_type = attr_list[idx.dir].value;\n if (!attr_names.includes(\"arrows\")) {\n if (dir_type === \"both\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { to: { enabled: true } },\n });\n idx.arrows.to = attr_list.length - 1;\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { from: { enabled: true } },\n });\n idx.arrows.from = attr_list.length - 1;\n } else if (dir_type === \"forward\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { to: { enabled: true } },\n });\n idx.arrows.to = attr_list.length - 1;\n } else if (dir_type === \"back\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: { from: { enabled: true } },\n });\n idx.arrows.from = attr_list.length - 1;\n } else if (dir_type === \"none\") {\n attr_list.push({\n attr: attr_list[idx.dir].attr,\n name: \"arrows\",\n value: \"\",\n });\n idx.arrows.to = attr_list.length - 1;\n } else {\n throw newSyntaxError('Invalid dir type \"' + dir_type + '\"');\n }\n }\n\n var from_type;\n var to_type;\n // update 'arrows' attribute from 'dir'.\n if (dir_type === \"both\") {\n // both of shapes of 'from' and 'to' are given\n if (idx.arrows.to && idx.arrows.from) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n attr_list.splice(idx.arrows.from, 1);\n\n // shape of 'to' is assigned and use default to 'from'\n } else if (idx.arrows.to) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = \"arrow\";\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // only shape of 'from' is assigned and use default for 'to'\n } else if (idx.arrows.from) {\n to_type = \"arrow\";\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n }\n } else if (dir_type === \"back\") {\n // given both of shapes, but use only 'from'\n if (idx.arrows.to && idx.arrows.from) {\n to_type = \"\";\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // given shape of 'to', but does not use it\n } else if (idx.arrows.to) {\n to_type = \"\";\n from_type = \"arrow\";\n idx.arrows.from = idx.arrows.to;\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // assign given 'from' shape\n } else if (idx.arrows.from) {\n to_type = \"\";\n from_type = attr_list[idx.arrows.from].value.from.type;\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n }\n\n attr_list[idx.arrows.from] = {\n attr: attr_list[idx.arrows.from].attr,\n name: attr_list[idx.arrows.from].name,\n value: {\n from: {\n enabled: true,\n type: attr_list[idx.arrows.from].value.from.type,\n },\n },\n };\n } else if (dir_type === \"none\") {\n var idx_arrow;\n if (idx.arrows.to) {\n idx_arrow = idx.arrows.to;\n } else {\n idx_arrow = idx.arrows.from;\n }\n\n attr_list[idx_arrow] = {\n attr: attr_list[idx_arrow].attr,\n name: attr_list[idx_arrow].name,\n value: \"\",\n };\n } else if (dir_type === \"forward\") {\n // given both of shapes, but use only 'to'\n if (idx.arrows.to && idx.arrows.from) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = \"\";\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // assign given 'to' shape\n } else if (idx.arrows.to) {\n to_type = attr_list[idx.arrows.to].value.to.type;\n from_type = \"\";\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n\n // given shape of 'from', but does not use it\n } else if (idx.arrows.from) {\n to_type = \"arrow\";\n from_type = \"\";\n idx.arrows.to = idx.arrows.from;\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: to_type },\n from: { enabled: true, type: from_type },\n },\n };\n }\n\n attr_list[idx.arrows.to] = {\n attr: attr_list[idx.arrows.to].attr,\n name: attr_list[idx.arrows.to].name,\n value: {\n to: { enabled: true, type: attr_list[idx.arrows.to].value.to.type },\n },\n };\n } else {\n throw newSyntaxError('Invalid dir type \"' + dir_type + '\"');\n }\n\n // remove 'dir' attribute no need anymore\n attr_list.splice(idx.dir, 1);\n }\n\n // parse 'penwidth'\n var nof_attr_list;\n if (attr_names.includes(\"penwidth\")) {\n var tmp_attr_list = [];\n\n nof_attr_list = attr_list.length;\n for (i = 0; i < nof_attr_list; i++) {\n // exclude 'width' from attr_list if 'penwidth' exists\n if (attr_list[i].name !== \"width\") {\n if (attr_list[i].name === \"penwidth\") {\n attr_list[i].name = \"width\";\n }\n tmp_attr_list.push(attr_list[i]);\n }\n }\n attr_list = tmp_attr_list;\n }\n\n nof_attr_list = attr_list.length;\n for (i = 0; i < nof_attr_list; i++) {\n setValue(attr_list[i].attr, attr_list[i].name, attr_list[i].value);\n }\n\n return attr;\n}\n\n/**\n * Create a syntax error with extra information on current token and index.\n *\n * @param {string} message\n * @returns {SyntaxError} err\n */\nfunction newSyntaxError(message) {\n return new SyntaxError(\n message + ', got \"' + chop(token, 30) + '\" (char ' + index + \")\"\n );\n}\n\n/**\n * Chop off text after a maximum length\n *\n * @param {string} text\n * @param {number} maxLength\n * @returns {string}\n */\nfunction chop(text, maxLength) {\n return text.length <= maxLength ? text : text.substr(0, 27) + \"...\";\n}\n\n/**\n * Execute a function fn for each pair of elements in two arrays\n *\n * @param {Array | *} array1\n * @param {Array | *} array2\n * @param {Function} fn\n */\nfunction forEach2(array1, array2, fn) {\n if (Array.isArray(array1)) {\n array1.forEach(function (elem1) {\n if (Array.isArray(array2)) {\n array2.forEach(function (elem2) {\n fn(elem1, elem2);\n });\n } else {\n fn(elem1, array2);\n }\n });\n } else {\n if (Array.isArray(array2)) {\n array2.forEach(function (elem2) {\n fn(array1, elem2);\n });\n } else {\n fn(array1, array2);\n }\n }\n}\n\n/**\n * Set a nested property on an object\n * When nested objects are missing, they will be created.\n * For example setProp({}, 'font.color', 'red') will return {font: {color: 'red'}}\n *\n * @param {object} object\n * @param {string} path A dot separated string like 'font.color'\n * @param {*} value Value for the property\n * @returns {object} Returns the original object, allows for chaining.\n */\nfunction setProp(object, path, value) {\n var names = path.split(\".\");\n var prop = names.pop();\n\n // traverse over the nested objects\n var obj = object;\n for (var i = 0; i < names.length; i++) {\n var name = names[i];\n if (!(name in obj)) {\n obj[name] = {};\n }\n obj = obj[name];\n }\n\n // set the property value\n obj[prop] = value;\n\n return object;\n}\n\n/**\n * Convert an object with DOT attributes to their vis.js equivalents.\n *\n * @param {object} attr Object with DOT attributes\n * @param {object} mapping\n * @returns {object} Returns an object with vis.js attributes\n */\nfunction convertAttr(attr, mapping) {\n var converted = {};\n\n for (var prop in attr) {\n if (attr.hasOwnProperty(prop)) {\n var visProp = mapping[prop];\n if (Array.isArray(visProp)) {\n visProp.forEach(function (visPropI) {\n setProp(converted, visPropI, attr[prop]);\n });\n } else if (typeof visProp === \"string\") {\n setProp(converted, visProp, attr[prop]);\n } else {\n setProp(converted, prop, attr[prop]);\n }\n }\n }\n\n return converted;\n}\n\n/**\n * Convert a string containing a graph in DOT language into a map containing\n * with nodes and edges in the format of graph.\n *\n * @param {string} data Text containing a graph in DOT-notation\n * @returns {object} graphData\n */\nexport function DOTToGraph(data) {\n // parse the DOT file\n var dotData = parseDOT(data);\n var graphData = {\n nodes: [],\n edges: [],\n options: {},\n };\n\n // copy the nodes\n if (dotData.nodes) {\n dotData.nodes.forEach(function (dotNode) {\n var graphNode = {\n id: dotNode.id,\n label: String(dotNode.label || dotNode.id),\n };\n merge(graphNode, convertAttr(dotNode.attr, NODE_ATTR_MAPPING));\n if (graphNode.image) {\n graphNode.shape = \"image\";\n }\n graphData.nodes.push(graphNode);\n });\n }\n\n // copy the edges\n if (dotData.edges) {\n /**\n * Convert an edge in DOT format to an edge with VisGraph format\n *\n * @param {object} dotEdge\n * @returns {object} graphEdge\n */\n var convertEdge = function (dotEdge) {\n var graphEdge = {\n from: dotEdge.from,\n to: dotEdge.to,\n };\n merge(graphEdge, convertAttr(dotEdge.attr, EDGE_ATTR_MAPPING));\n\n // Add arrows attribute to default styled arrow.\n // The reason why default style is not added in parseAttributeList() is\n // because only default is cleared before here.\n if (graphEdge.arrows == null && dotEdge.type === \"->\") {\n graphEdge.arrows = \"to\";\n }\n\n return graphEdge;\n };\n\n dotData.edges.forEach(function (dotEdge) {\n var from, to;\n if (dotEdge.from instanceof Object) {\n from = dotEdge.from.nodes;\n } else {\n from = {\n id: dotEdge.from,\n };\n }\n\n if (dotEdge.to instanceof Object) {\n to = dotEdge.to.nodes;\n } else {\n to = {\n id: dotEdge.to,\n };\n }\n\n if (dotEdge.from instanceof Object && dotEdge.from.edges) {\n dotEdge.from.edges.forEach(function (subEdge) {\n var graphEdge = convertEdge(subEdge);\n graphData.edges.push(graphEdge);\n });\n }\n\n forEach2(from, to, function (from, to) {\n var subEdge = createEdge(\n graphData,\n from.id,\n to.id,\n dotEdge.type,\n dotEdge.attr\n );\n var graphEdge = convertEdge(subEdge);\n graphData.edges.push(graphEdge);\n });\n\n if (dotEdge.to instanceof Object && dotEdge.to.edges) {\n dotEdge.to.edges.forEach(function (subEdge) {\n var graphEdge = convertEdge(subEdge);\n graphData.edges.push(graphEdge);\n });\n }\n });\n }\n\n // copy the options\n if (dotData.attr) {\n graphData.options = dotData.attr;\n }\n\n return graphData;\n}\n\n/* eslint-enable no-var */\n/* eslint-enable no-unused-vars */\n/* eslint-enable no-prototype-builtins */\n","export type Id = number | string;\n\nexport interface ColorObject {\n background: string;\n border: string;\n highlight: {\n background: string;\n border: string;\n };\n hover: {\n background: string;\n border: string;\n };\n}\n\nexport interface GephiData {\n nodes: GephiNode[];\n edges: GephiEdge[];\n}\nexport interface GephiParseOptions {\n fixed?: boolean;\n inheritColor?: boolean;\n parseColor?: boolean;\n}\n\nexport interface GephiNode {\n id: Id;\n\n attributes?: { title?: string };\n color?: string;\n label?: string;\n size?: number;\n title?: string;\n x?: number;\n y?: number;\n}\nexport interface GephiEdge {\n id: Id;\n source: Id;\n target: Id;\n\n attributes?: { title?: string };\n color?: string;\n label?: string;\n type?: string;\n}\n\nexport interface VisData {\n nodes: VisNode[];\n edges: VisEdge[];\n}\n\nexport interface VisNode {\n id: Id;\n fixed: boolean;\n\n color?: string | ColorObject;\n label?: string;\n size?: number;\n title?: string;\n x?: number;\n y?: number;\n\n attributes?: unknown;\n}\nexport interface VisEdge {\n id: Id;\n from: Id;\n to: Id;\n\n arrows?: \"to\";\n color?: string;\n label?: string;\n title?: string;\n\n attributes?: unknown;\n}\n\n/**\n * Convert Gephi to Vis.\n *\n * @param gephiJSON - The parsed JSON data in Gephi format.\n * @param optionsObj - Additional options.\n *\n * @returns The converted data ready to be used in Vis.\n */\nexport function parseGephi(\n gephiJSON: GephiData,\n optionsObj?: GephiParseOptions\n): VisData {\n const options = {\n edges: {\n inheritColor: false,\n },\n nodes: {\n fixed: false,\n parseColor: false,\n },\n };\n\n if (optionsObj != null) {\n if (optionsObj.fixed != null) {\n options.nodes.fixed = optionsObj.fixed;\n }\n if (optionsObj.parseColor != null) {\n options.nodes.parseColor = optionsObj.parseColor;\n }\n if (optionsObj.inheritColor != null) {\n options.edges.inheritColor = optionsObj.inheritColor;\n }\n }\n\n const gEdges = gephiJSON.edges;\n const vEdges = gEdges.map((gEdge): VisEdge => {\n const vEdge: VisEdge = {\n from: gEdge.source,\n id: gEdge.id,\n to: gEdge.target,\n };\n\n if (gEdge.attributes != null) {\n vEdge.attributes = gEdge.attributes;\n }\n if (gEdge.label != null) {\n vEdge.label = gEdge.label;\n }\n if (gEdge.attributes != null && gEdge.attributes.title != null) {\n vEdge.title = gEdge.attributes.title;\n }\n if (gEdge.type === \"Directed\") {\n vEdge.arrows = \"to\";\n }\n // edge['value'] = gEdge.attributes != null ? gEdge.attributes.Weight : undefined;\n // edge['width'] = edge['value'] != null ? undefined : edgegEdge.size;\n if (gEdge.color && options.edges.inheritColor === false) {\n vEdge.color = gEdge.color;\n }\n\n return vEdge;\n });\n\n const vNodes = gephiJSON.nodes.map((gNode): VisNode => {\n const vNode: VisNode = {\n id: gNode.id,\n fixed: options.nodes.fixed && gNode.x != null && gNode.y != null,\n };\n\n if (gNode.attributes != null) {\n vNode.attributes = gNode.attributes;\n }\n if (gNode.label != null) {\n vNode.label = gNode.label;\n }\n if (gNode.size != null) {\n vNode.size = gNode.size;\n }\n if (gNode.attributes != null && gNode.attributes.title != null) {\n vNode.title = gNode.attributes.title;\n }\n if (gNode.title != null) {\n vNode.title = gNode.title;\n }\n if (gNode.x != null) {\n vNode.x = gNode.x;\n }\n if (gNode.y != null) {\n vNode.y = gNode.y;\n }\n if (gNode.color != null) {\n if (options.nodes.parseColor === true) {\n vNode.color = gNode.color;\n } else {\n vNode.color = {\n background: gNode.color,\n border: gNode.color,\n highlight: {\n background: gNode.color,\n border: gNode.color,\n },\n hover: {\n background: gNode.color,\n border: gNode.color,\n },\n };\n }\n }\n\n return vNode;\n });\n\n return { nodes: vNodes, edges: vEdges };\n}\n","export interface Locale {\n addDescription: string;\n addEdge: string;\n addNode: string;\n back: string;\n close: string;\n createEdgeError: string;\n del: string;\n deleteClusterError: string;\n edgeDescription: string;\n edit: string;\n editClusterError: string;\n editEdge: string;\n editEdgeDescription: string;\n editNode: string;\n}\nexport type Locales = Record<string, Locale>;\n\n// English\nexport const en: Locale = {\n addDescription: \"Click in an empty space to place a new node.\",\n addEdge: \"Add Edge\",\n addNode: \"Add Node\",\n back: \"Back\",\n close: \"Close\",\n createEdgeError: \"Cannot link edges to a cluster.\",\n del: \"Delete selected\",\n deleteClusterError: \"Clusters cannot be deleted.\",\n edgeDescription:\n \"Click on a node and drag the edge to another node to connect them.\",\n edit: \"Edit\",\n editClusterError: \"Clusters cannot be edited.\",\n editEdge: \"Edit Edge\",\n editEdgeDescription:\n \"Click on the control points and drag them to a node to connect to it.\",\n editNode: \"Edit Node\",\n};\n\n// German\nexport const de: Locale = {\n addDescription:\n \"Klicke auf eine freie Stelle, um einen neuen Knoten zu plazieren.\",\n addEdge: \"Kante hinzuf\\u00fcgen\",\n addNode: \"Knoten hinzuf\\u00fcgen\",\n back: \"Zur\\u00fcck\",\n close: \"Schließen\",\n createEdgeError:\n \"Es ist nicht m\\u00f6glich, Kanten mit Clustern zu verbinden.\",\n del: \"L\\u00f6sche Auswahl\",\n deleteClusterError: \"Cluster k\\u00f6nnen nicht gel\\u00f6scht werden.\",\n edgeDescription:\n \"Klicke auf einen Knoten und ziehe die Kante zu einem anderen Knoten, um diese zu verbinden.\",\n edit: \"Editieren\",\n editClusterError: \"Cluster k\\u00f6nnen nicht editiert werden.\",\n editEdge: \"Kante editieren\",\n editEdgeDescription:\n \"Klicke auf die Verbindungspunkte und ziehe diese auf einen Knoten, um sie zu verbinden.\",\n editNode: \"Knoten editieren\",\n};\n\n// Spanish\nexport const es: Locale = {\n addDescription:\n \"Haga clic en un lugar vac\\u00edo para colocar un nuevo nodo.\",\n addEdge: \"A\\u00f1adir arista\",\n addNode: \"A\\u00f1adir nodo\",\n back: \"Atr\\u00e1s\",\n close: \"Cerrar\",\n createEdgeError: \"No se puede conectar una arista a un grupo.\",\n del: \"Eliminar selecci\\u00f3n\",\n deleteClusterError: \"No es posible eliminar grupos.\",\n edgeDescription:\n \"Haga clic en un nodo y arrastre la arista hacia otro nodo para conectarlos.\",\n edit: \"Editar\",\n editClusterError: \"No es posible editar grupos.\",\n editEdge: \"Editar arista\",\n editEdgeDescription:\n \"Haga clic en un punto de control y arrastrelo a un nodo para conectarlo.\",\n editNode: \"Editar nodo\",\n};\n\n//Italiano\nexport const it: Locale = {\n addDescription: \"Clicca per aggiungere un nuovo nodo\",\n addEdge: \"Aggiungi un vertice\",\n addNode: \"Aggiungi un nodo\",\n back: \"Indietro\",\n close: \"Chiudere\",\n createEdgeError: \"Non si possono collegare vertici ad un cluster\",\n del: \"Cancella la selezione\",\n deleteClusterError: \"I cluster non possono essere cancellati\",\n edgeDescription:\n \"Clicca su un nodo e trascinalo ad un altro nodo per connetterli.\",\n edit: \"Modifica\",\n editClusterError: \"I clusters non possono essere modificati.\",\n editEdge: \"Modifica il vertice\",\n editEdgeDescription:\n \"Clicca sui Punti di controllo e trascinali ad un nodo per connetterli.\",\n editNode: \"Modifica il nodo\",\n};\n\n// Dutch\nexport const nl: Locale = {\n addDescription: \"Klik op een leeg gebied om een nieuwe node te maken.\",\n addEdge: \"Link toevoegen\",\n addNode: \"Node toevoegen\",\n back: \"Terug\",\n close: \"Sluiten\",\n createEdgeError: \"Kan geen link maken naar een cluster.\",\n del: \"Selectie verwijderen\",\n deleteClusterError: \"Clusters kunnen niet worden verwijderd.\",\n edgeDescription:\n \"Klik op een node en sleep de link naar een andere node om ze te verbinden.\",\n edit: \"Wijzigen\",\n editClusterError: \"Clusters kunnen niet worden aangepast.\",\n editEdge: \"Link wijzigen\",\n editEdgeDescription:\n \"Klik op de verbindingspunten en sleep ze naar een node om daarmee te verbinden.\",\n editNode: \"Node wijzigen\",\n};\n\n// Portuguese Brazil\nexport const pt: Locale = {\n addDescription: \"Clique em um espaço em branco para adicionar um novo nó\",\n addEdge: \"Adicionar aresta\",\n addNode: \"Adicionar nó\",\n back: \"Voltar\",\n close: \"Fechar\",\n createEdgeError: \"Não foi possível linkar arestas a um cluster.\",\n del: \"Remover selecionado\",\n deleteClusterError: \"Clusters não puderam ser removidos.\",\n edgeDescription:\n \"Clique em um nó e arraste a aresta até outro nó para conectá-los\",\n edit: \"Editar\",\n editClusterError: \"Clusters não puderam ser editados.\",\n editEdge: \"Editar aresta\",\n editEdgeDescription:\n \"Clique nos pontos de controle e os arraste para um nó para conectá-los\",\n editNode: \"Editar nó\",\n};\n\n// Russian\nexport const ru: Locale = {\n addDescription: \"Кликните в свободное место, чтобы добавить новый узел.\",\n addEdge: \"Добавить ребро\",\n addNode: \"Добавить узел\",\n back: \"Назад\",\n close: \"Закрывать\",\n createEdgeError: \"Невозможно соединить ребра в кластер.\",\n del: \"Удалить выбранное\",\n deleteClusterError: \"Кластеры не могут быть удалены\",\n edgeDescription:\n \"Кликните на узел и протяните ребро к другому узлу, чтобы соединить их.\",\n edit: \"Редактировать\",\n editClusterError: \"Кластеры недоступны для редактирования.\",\n editEdge: \"Редактировать ребро\",\n editEdgeDescription:\n \"Кликните на контрольные точки и перетащите их в узел, чтобы подключиться к нему.\",\n editNode: \"Редактировать узел\",\n};\n\n// Chinese\nexport const cn: Locale = {\n addDescription: \"单击空白处放置新节点。\",\n addEdge: \"添加连接线\",\n addNode: \"添加节点\",\n back: \"返回\",\n close: \"關閉\",\n createEdgeError: \"无法将连接线连接到群集。\",\n del: \"删除选定\",\n deleteClusterError: \"无法删除群集。\",\n edgeDescription: \"单击某个节点并将该连接线拖动到另一个节点以连接它们。\",\n edit: \"编辑\",\n editClusterError: \"无法编辑群集。\",\n editEdge: \"编辑连接线\",\n editEdgeDescription: \"单击控制节点并将它们拖到节点上连接。\",\n editNode: \"编辑节点\",\n};\n\n// Ukrainian\nexport const uk: Locale = {\n addDescription: \"Kлікніть на вільне місце, щоб додати новий вузол.\",\n addEdge: \"Додати край\",\n addNode: \"Додати вузол\",\n back: \"Назад\",\n close: \"Закрити\",\n createEdgeError: \"Не можливо об'єднати краї в групу.\",\n del: \"Видалити обране\",\n deleteClusterError: \"Групи не можуть бути видалені.\",\n edgeDescription:\n \"Клікніть на вузол і перетягніть край до іншого вузла, щоб їх з'єднати.\",\n edit: \"Редагувати\",\n editClusterError: \"Групи недоступні для редагування.\",\n editEdge: \"Редагувати край\",\n editEdgeDescription:\n \"Клікніть на контрольні точки і перетягніть їх у вузол, щоб підключитися до нього.\",\n editNode: \"Редагувати вузол\",\n};\n\n// French\nexport const fr: Locale = {\n addDescription: \"Cliquez dans un endroit vide pour placer un nœud.\",\n addEdge: \"Ajouter un lien\",\n addNode: \"Ajouter un nœud\",\n back: \"Retour\",\n close: \"Fermer\",\n createEdgeError: \"Impossible de créer un lien vers un cluster.\",\n del: \"Effacer la sélection\",\n deleteClusterError: \"Les clusters ne peuvent pas être effacés.\",\n edgeDescription:\n \"Cliquez sur un nœud et glissez le lien vers un autre nœud pour les connecter.\",\n edit: \"Éditer\",\n editClusterError: \"Les clusters ne peuvent pas être édités.\",\n editEdge: \"Éditer le lien\",\n editEdgeDescription:\n \"Cliquez sur les points de contrôle et glissez-les pour connecter un nœud.\",\n editNode: \"Éditer le nœud\",\n};\n\n// Czech\nexport const cs: Locale = {\n addDescription: \"Kluknutím do prázdného prostoru můžete přidat nový vrchol.\",\n addEdge: \"Přidat hranu\",\n addNode: \"Přidat vrchol\",\n back: \"Zpět\",\n close: \"Zavřít\",\n createEdgeError: \"Nelze připojit hranu ke shluku.\",\n del: \"Smazat výběr\",\n deleteClusterError: \"Nelze mazat shluky.\",\n edgeDescription:\n \"Přetažením z jednoho vrcholu do druhého můžete spojit tyto vrcholy novou hranou.\",\n edit: \"Upravit\",\n editClusterError: \"Nelze upravovat shluky.\",\n editEdge: \"Upravit hranu\",\n editEdgeDescription:\n \"Přetažením kontrolního vrcholu hrany ji můžete připojit k jinému vrcholu.\",\n editNode: \"Upravit vrchol\",\n};\n","/**\n * Associates a canvas to a given image, containing a number of renderings\n * of the image at various sizes.\n *\n * This technique is known as 'mipmapping'.\n *\n * NOTE: Images can also be of type 'data:svg+xml`. This code also works\n * for svg, but the mipmapping may not be necessary.\n *\n * @param {Image} image\n */\nclass CachedImage {\n /**\n * @ignore\n */\n constructor() {\n this.NUM_ITERATIONS = 4; // Number of items in the coordinates array\n\n this.image = new Image();\n this.canvas = document.createElement(\"canvas\");\n }\n\n /**\n * Called when the image has been successfully loaded.\n */\n init() {\n if (this.initialized()) return;\n\n this.src = this.image.src; // For same interface with Image\n const w = this.image.width;\n const h = this.image.height;\n\n // Ease external access\n this.width = w;\n this.height = h;\n\n const h2 = Math.floor(h / 2);\n const h4 = Math.floor(h / 4);\n const h8 = Math.floor(h / 8);\n const h16 = Math.floor(h / 16);\n\n const w2 = Math.floor(w / 2);\n const w4 = Math.floor(w / 4);\n const w8 = Math.floor(w / 8);\n const w16 = Math.floor(w / 16);\n\n // Make canvas as small as possible\n this.canvas.width = 3 * w4;\n this.canvas.height = h2;\n\n // Coordinates and sizes of images contained in the canvas\n // Values per row: [top x, left y, width, height]\n\n this.coordinates = [\n [0, 0, w2, h2],\n [w2, 0, w4, h4],\n [w2, h4, w8, h8],\n [5 * w8, h4, w16, h16],\n ];\n\n this._fillMipMap();\n }\n\n /**\n * @returns {boolean} true if init() has been called, false otherwise.\n */\n initialized() {\n return this.coordinates !== undefined;\n }\n\n /**\n * Redraw main image in various sizes to the context.\n *\n * The rationale behind this is to reduce artefacts due to interpolation\n * at differing zoom levels.\n *\n * Source: http://stackoverflow.com/q/18761404/1223531\n *\n * This methods takes the resizing out of the drawing loop, in order to\n * reduce performance overhead.\n *\n * TODO: The code assumes that a 2D context can always be gotten. This is\n * not necessarily true! OTOH, if not true then usage of this class\n * is senseless.\n *\n * @private\n */\n _fillMipMap() {\n const ctx = this.canvas.getContext(\"2d\");\n\n // First zoom-level comes from the image\n const to = this.coordinates[0];\n ctx.drawImage(this.image, to[0], to[1], to[2], to[3]);\n\n // The rest are copy actions internal to the canvas/context\n for (let iterations = 1; iterations < this.NUM_ITERATIONS; iterations++) {\n const from = this.coordinates[iterations - 1];\n const to = this.coordinates[iterations];\n\n ctx.drawImage(\n this.canvas,\n from[0],\n from[1],\n from[2],\n from[3],\n to[0],\n to[1],\n to[2],\n to[3]\n );\n }\n }\n\n /**\n * Draw the image, using the mipmap if necessary.\n *\n * MipMap is only used if param factor > 2; otherwise, original bitmap\n * is resized. This is also used to skip mipmap usage, e.g. by setting factor = 1\n *\n * Credits to 'Alex de Mulder' for original implementation.\n *\n * @param {CanvasRenderingContext2D} ctx context on which to draw zoomed image\n * @param {Float} factor scale factor at which to draw\n * @param {number} left\n * @param {number} top\n * @param {number} width\n * @param {number} height\n */\n drawImageAtPosition(ctx, factor, left, top, width, height) {\n if (!this.initialized()) return; //can't draw image yet not intialized\n\n if (factor > 2) {\n // Determine which zoomed image to use\n factor *= 0.5;\n let iterations = 0;\n while (factor > 2 && iterations < this.NUM_ITERATIONS) {\n factor *= 0.5;\n iterations += 1;\n }\n\n if (iterations >= this.NUM_ITERATIONS) {\n iterations = this.NUM_ITERATIONS - 1;\n }\n //console.log(\"iterations: \" + iterations);\n\n const from = this.coordinates[iterations];\n ctx.drawImage(\n this.canvas,\n from[0],\n from[1],\n from[2],\n from[3],\n left,\n top,\n width,\n height\n );\n } else {\n // Draw image directly\n ctx.drawImage(this.image, left, top, width, height);\n }\n }\n}\n\nexport default CachedImage;\n","import CachedImage from \"./CachedImage\";\n\n/**\n * This callback is a callback that accepts an Image.\n *\n * @callback ImageCallback\n * @param {Image} image\n */\n\n/**\n * This class loads images and keeps them stored.\n *\n * @param {ImageCallback} callback\n */\nclass Images {\n /**\n * @param {ImageCallback} callback\n */\n constructor(callback) {\n this.images = {};\n this.imageBroken = {};\n this.callback = callback;\n }\n\n /**\n * @param {string} url The original Url that failed to load, if the broken image is successfully loaded it will be added to the cache using this Url as the key so that subsequent requests for this Url will return the broken image\n * @param {string} brokenUrl Url the broken image to try and load\n * @param {Image} imageToLoadBrokenUrlOn The image object\n */\n _tryloadBrokenUrl(url, brokenUrl, imageToLoadBrokenUrlOn) {\n //If these parameters aren't specified then exit the function because nothing constructive can be done\n if (url === undefined || imageToLoadBrokenUrlOn === undefined) return;\n if (brokenUrl === undefined) {\n console.warn(\"No broken url image defined\");\n return;\n }\n\n //Clear the old subscription to the error event and put a new in place that only handle errors in loading the brokenImageUrl\n imageToLoadBrokenUrlOn.image.onerror = () => {\n console.error(\"Could not load brokenImage:\", brokenUrl);\n // cache item will contain empty image, this should be OK for default\n };\n\n //Set the source of the image to the brokenUrl, this is actually what kicks off the loading of the broken image\n imageToLoadBrokenUrlOn.image.src = brokenUrl;\n }\n\n /**\n *\n * @param {vis.Image} imageToRedrawWith\n * @private\n */\n _redrawWithImage(imageToRedrawWith) {\n if (this.callback) {\n this.callback(imageToRedrawWith);\n }\n }\n\n /**\n * @param {string} url Url of the image\n * @param {string} brokenUrl Url of an image to use if the url image is not found\n * @returns {Image} img The image object\n */\n load(url, brokenUrl) {\n //Try and get the image from the cache, if successful then return the cached image\n const cachedImage = this.images[url];\n if (cachedImage) return cachedImage;\n\n //Create a new image\n const img = new CachedImage();\n\n // Need to add to cache here, otherwise final return will spawn different copies of the same image,\n // Also, there will be multiple loads of the same image.\n this.images[url] = img;\n\n //Subscribe to the event that is raised if the image loads successfully\n img.image.onload = () => {\n // Properly init the cached item and then request a redraw\n this._fixImageCoordinates(img.image);\n img.init();\n this._redrawWithImage(img);\n };\n\n //Subscribe to the event that is raised if the image fails to load\n img.image.onerror = () => {\n console.error(\"Could not load image:\", url);\n //Try and load the image specified by the brokenUrl using\n this._tryloadBrokenUrl(url, brokenUrl, img);\n };\n\n //Set the source of the image to the url, this is what actually kicks off the loading of the image\n img.image.src = url;\n\n //Return the new image\n return img;\n }\n\n /**\n * IE11 fix -- thanks dponch!\n *\n * Local helper function\n *\n * @param {vis.Image} imageToCache\n * @private\n */\n _fixImageCoordinates(imageToCache) {\n if (imageToCache.width === 0) {\n document.body.appendChild(imageToCache);\n imageToCache.width = imageToCache.offsetWidth;\n imageToCache.height = imageToCache.offsetHeight;\n document.body.removeChild(imageToCache);\n }\n }\n}\n\nexport default Images;\n","/**\n * This class can store groups and options specific for groups.\n */\nexport class Groups {\n /**\n * @ignore\n */\n constructor() {\n this.clear();\n this._defaultIndex = 0;\n this._groupIndex = 0;\n\n this._defaultGroups = [\n {\n border: \"#2B7CE9\",\n background: \"#97C2FC\",\n highlight: { border: \"#2B7CE9\", background: \"#D2E5FF\" },\n hover: { border: \"#2B7CE9\", background: \"#D2E5FF\" },\n }, // 0: blue\n {\n border: \"#FFA500\",\n background: \"#FFFF00\",\n highlight: { border: \"#FFA500\", background: \"#FFFFA3\" },\n hover: { border: \"#FFA500\", background: \"#FFFFA3\" },\n }, // 1: yellow\n {\n border: \"#FA0A10\",\n background: \"#FB7E81\",\n highlight: { border: \"#FA0A10\", background: \"#FFAFB1\" },\n hover: { border: \"#FA0A10\", background: \"#FFAFB1\" },\n }, // 2: red\n {\n border: \"#41A906\",\n background: \"#7BE141\",\n highlight: { border: \"#41A906\", background: \"#A1EC76\" },\n hover: { border: \"#41A906\", background: \"#A1EC76\" },\n }, // 3: green\n {\n border: \"#E129F0\",\n background: \"#EB7DF4\",\n highlight: { border: \"#E129F0\", background: \"#F0B3F5\" },\n hover: { border: \"#E129F0\", background: \"#F0B3F5\" },\n }, // 4: magenta\n {\n border: \"#7C29F0\",\n background: \"#AD85E4\",\n highlight: { border: \"#7C29F0\", background: \"#D3BDF0\" },\n hover: { border: \"#7C29F0\", background: \"#D3BDF0\" },\n }, // 5: purple\n {\n border: \"#C37F00\",\n background: \"#FFA807\",\n highlight: { border: \"#C37F00\", background: \"#FFCA66\" },\n hover: { border: \"#C37F00\", background: \"#FFCA66\" },\n }, // 6: orange\n {\n border: \"#4220FB\",\n background: \"#6E6EFD\",\n highlight: { border: \"#4220FB\", background: \"#9B9BFD\" },\n hover: { border: \"#4220FB\", background: \"#9B9BFD\" },\n }, // 7: darkblue\n {\n border: \"#FD5A77\",\n background: \"#FFC0CB\",\n highlight: { border: \"#FD5A77\", background: \"#FFD1D9\" },\n hover: { border: \"#FD5A77\", background: \"#FFD1D9\" },\n }, // 8: pink\n {\n border: \"#4AD63A\",\n background: \"#C2FABC\",\n highlight: { border: \"#4AD63A\", background: \"#E6FFE3\" },\n hover: { border: \"#4AD63A\", background: \"#E6FFE3\" },\n }, // 9: mint\n\n {\n border: \"#990000\",\n background: \"#EE0000\",\n highlight: { border: \"#BB0000\", background: \"#FF3333\" },\n hover: { border: \"#BB0000\", background: \"#FF3333\" },\n }, // 10:bright red\n\n {\n border: \"#FF6000\",\n background: \"#FF6000\",\n highlight: { border: \"#FF6000\", background: \"#FF6000\" },\n hover: { border: \"#FF6000\", background: \"#FF6000\" },\n }, // 12: real orange\n {\n border: \"#97C2FC\",\n background: \"#2B7CE9\",\n highlight: { border: \"#D2E5FF\", background: \"#2B7CE9\" },\n hover: { border: \"#D2E5FF\", background: \"#2B7CE9\" },\n }, // 13: blue\n {\n border: \"#399605\",\n background: \"#255C03\",\n highlight: { border: \"#399605\", background: \"#255C03\" },\n hover: { border: \"#399605\", background: \"#255C03\" },\n }, // 14: green\n {\n border: \"#B70054\",\n background: \"#FF007E\",\n highlight: { border: \"#B70054\", background: \"#FF007E\" },\n hover: { border: \"#B70054\", background: \"#FF007E\" },\n }, // 15: magenta\n {\n border: \"#AD85E4\",\n background: \"#7C29F0\",\n highlight: { border: \"#D3BDF0\", background: \"#7C29F0\" },\n hover: { border: \"#D3BDF0\", background: \"#7C29F0\" },\n }, // 16: purple\n {\n border: \"#4557FA\",\n background: \"#000EA1\",\n highlight: { border: \"#6E6EFD\", background: \"#000EA1\" },\n hover: { border: \"#6E6EFD\", background: \"#000EA1\" },\n }, // 17: darkblue\n {\n border: \"#FFC0CB\",\n background: \"#FD5A77\",\n highlight: { border: \"#FFD1D9\", background: \"#FD5A77\" },\n hover: { border: \"#FFD1D9\", background: \"#FD5A77\" },\n }, // 18: pink\n {\n border: \"#C2FABC\",\n background: \"#74D66A\",\n highlight: { border: \"#E6FFE3\", background: \"#74D66A\" },\n hover: { border: \"#E6FFE3\", background: \"#74D66A\" },\n }, // 19: mint\n\n {\n border: \"#EE0000\",\n background: \"#990000\",\n highlight: { border: \"#FF3333\", background: \"#BB0000\" },\n hover: { border: \"#FF3333\", background: \"#BB0000\" },\n }, // 20:bright red\n ];\n\n this.options = {};\n this.defaultOptions = {\n useDefaultGroups: true,\n };\n Object.assign(this.options, this.defaultOptions);\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n const optionFields = [\"useDefaultGroups\"];\n\n if (options !== undefined) {\n for (const groupName in options) {\n if (Object.prototype.hasOwnProperty.call(options, groupName)) {\n if (optionFields.indexOf(groupName) === -1) {\n const group = options[groupName];\n this.add(groupName, group);\n }\n }\n }\n }\n }\n\n /**\n * Clear all groups\n */\n clear() {\n this._groups = new Map();\n this._groupNames = [];\n }\n\n /**\n * Get group options of a groupname.\n * If groupname is not found, a new group may be created.\n *\n * @param {*} groupname Can be a number, string, Date, etc.\n * @param {boolean} [shouldCreate=true] If true, create a new group\n * @returns {object} The found or created group\n */\n get(groupname, shouldCreate = true) {\n let group = this._groups.get(groupname);\n\n if (group === undefined && shouldCreate) {\n if (\n this.options.useDefaultGroups === false &&\n this._groupNames.length > 0\n ) {\n // create new group\n const index = this._groupIndex % this._groupNames.length;\n ++this._groupIndex;\n group = {};\n group.color = this._groups.get(this._groupNames[index]);\n this._groups.set(groupname, group);\n } else {\n // create new group\n const index = this._defaultIndex % this._defaultGroups.length;\n this._defaultIndex++;\n group = {};\n group.color = this._defaultGroups[index];\n this._groups.set(groupname, group);\n }\n }\n\n return group;\n }\n\n /**\n * Add custom group style.\n *\n * @param {string} groupName - The name of the group, a new group will be\n * created if a group with the same name doesn't exist, otherwise the old\n * groups style will be overwritten.\n * @param {object} style - An object containing borderColor, backgroundColor,\n * etc.\n * @returns {object} The created group object.\n */\n add(groupName, style) {\n // Only push group name once to prevent duplicates which would consume more\n // RAM and also skew the distribution towards more often updated groups,\n // neither of which is desirable.\n if (!this._groups.has(groupName)) {\n this._groupNames.push(groupName);\n }\n this._groups.set(groupName, style);\n return style;\n }\n}\n","import { topMost } from \"vis-util/esnext\";\n\n/**\n * Helper functions for components\n */\n\n/**\n * Determine values to use for (sub)options of 'chosen'.\n *\n * This option is either a boolean or an object whose values should be examined further.\n * The relevant structures are:\n *\n * - chosen: <boolean value>\n * - chosen: { subOption: <boolean or function> }\n *\n * Where subOption is 'node', 'edge' or 'label'.\n *\n * The intention of this method appears to be to set a specific priority to the options;\n * Since most properties are either bridged or merged into the local options objects, there\n * is not much point in handling them separately.\n * TODO: examine if 'most' in previous sentence can be replaced with 'all'. In that case, we\n * should be able to get rid of this method.\n *\n * @param {string} subOption option within object 'chosen' to consider; either 'node', 'edge' or 'label'\n * @param {object} pile array of options objects to consider\n *\n * @returns {boolean | Function} value for passed subOption of 'chosen' to use\n */\nexport function choosify(subOption, pile) {\n // allowed values for subOption\n const allowed = [\"node\", \"edge\", \"label\"];\n let value = true;\n\n const chosen = topMost(pile, \"chosen\");\n if (typeof chosen === \"boolean\") {\n value = chosen;\n } else if (typeof chosen === \"object\") {\n if (allowed.indexOf(subOption) === -1) {\n throw new Error(\n \"choosify: subOption '\" +\n subOption +\n \"' should be one of \" +\n \"'\" +\n allowed.join(\"', '\") +\n \"'\"\n );\n }\n\n const chosenEdge = topMost(pile, [\"chosen\", subOption]);\n if (typeof chosenEdge === \"boolean\" || typeof chosenEdge === \"function\") {\n value = chosenEdge;\n }\n }\n\n return value;\n}\n\n/**\n * Check if the point falls within the given rectangle.\n *\n * @param {rect} rect\n * @param {point} point\n * @param {rotationPoint} [rotationPoint] if specified, the rotation that applies to the rectangle.\n * @returns {boolean} true if point within rectangle, false otherwise\n */\nexport function pointInRect(rect, point, rotationPoint) {\n if (rect.width <= 0 || rect.height <= 0) {\n return false; // early out\n }\n\n if (rotationPoint !== undefined) {\n // Rotate the point the same amount as the rectangle\n const tmp = {\n x: point.x - rotationPoint.x,\n y: point.y - rotationPoint.y,\n };\n\n if (rotationPoint.angle !== 0) {\n // In order to get the coordinates the same, you need to\n // rotate in the reverse direction\n const angle = -rotationPoint.angle;\n\n const tmp2 = {\n x: Math.cos(angle) * tmp.x - Math.sin(angle) * tmp.y,\n y: Math.sin(angle) * tmp.x + Math.cos(angle) * tmp.y,\n };\n point = tmp2;\n } else {\n point = tmp;\n }\n\n // Note that if a rotation is specified, the rectangle coordinates\n // are **not* the full canvas coordinates. They are relative to the\n // rotationPoint. Hence, the point coordinates need not be translated\n // back in this case.\n }\n\n const right = rect.x + rect.width;\n const bottom = rect.y + rect.width;\n\n return (\n rect.left < point.x &&\n right > point.x &&\n rect.top < point.y &&\n bottom > point.y\n );\n}\n\n/**\n * Check if given value is acceptable as a label text.\n *\n * @param {*} text value to check; can be anything at this point\n * @returns {boolean} true if valid label value, false otherwise\n */\nexport function isValidLabel(text) {\n // Note that this is quite strict: types that *might* be converted to string are disallowed\n return typeof text === \"string\" && text !== \"\";\n}\n\n/**\n * Returns x, y of self reference circle based on provided angle\n *\n * @param {object} ctx\n * @param {number} angle\n * @param {number} radius\n * @param {VisNode} node\n *\n * @returns {object} x and y coordinates\n */\nexport function getSelfRefCoordinates(ctx, angle, radius, node) {\n let x = node.x;\n let y = node.y;\n\n if (typeof node.distanceToBorder === \"function\") {\n //calculating opposite and adjacent\n //distaneToBorder becomes Hypotenuse.\n //Formulas sin(a) = Opposite / Hypotenuse and cos(a) = Adjacent / Hypotenuse\n const toBorderDist = node.distanceToBorder(ctx, angle);\n const yFromNodeCenter = Math.sin(angle) * toBorderDist;\n const xFromNodeCenter = Math.cos(angle) * toBorderDist;\n //xFromNodeCenter is basically x and if xFromNodeCenter equals to the distance to border then it means\n //that y does not need calculation because it is equal node.height / 2 or node.y\n //same thing with yFromNodeCenter and if yFromNodeCenter equals to the distance to border then it means\n //that x is equal node.width / 2 or node.x\n if (xFromNodeCenter === toBorderDist) {\n x += toBorderDist;\n y = node.y;\n } else if (yFromNodeCenter === toBorderDist) {\n x = node.x;\n y -= toBorderDist;\n } else {\n x += xFromNodeCenter;\n y -= yFromNodeCenter;\n }\n } else if (node.shape.width > node.shape.height) {\n x = node.x + node.shape.width * 0.5;\n y = node.y - radius;\n } else {\n x = node.x + radius;\n y = node.y - node.shape.height * 0.5;\n }\n\n return { x, y };\n}\n","/**\n * Callback to determine text dimensions, using the parent label settings.\n *\n * @callback MeasureText\n * @param {text} text\n * @param {text} mod\n * @returns {object} { width, values} width in pixels and font attributes\n */\n\n/**\n * Helper class for Label which collects results of splitting labels into lines and blocks.\n *\n * @private\n */\nclass LabelAccumulator {\n /**\n * @param {MeasureText} measureText\n */\n constructor(measureText) {\n this.measureText = measureText;\n this.current = 0;\n this.width = 0;\n this.height = 0;\n this.lines = [];\n }\n\n /**\n * Append given text to the given line.\n *\n * @param {number} l index of line to add to\n * @param {string} text string to append to line\n * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal']\n * @private\n */\n _add(l, text, mod = \"normal\") {\n if (this.lines[l] === undefined) {\n this.lines[l] = {\n width: 0,\n height: 0,\n blocks: [],\n };\n }\n\n // We still need to set a block for undefined and empty texts, hence return at this point\n // This is necessary because we don't know at this point if we're at the\n // start of an empty line or not.\n // To compensate, empty blocks are removed in `finalize()`.\n //\n // Empty strings should still have a height\n let tmpText = text;\n if (text === undefined || text === \"\") tmpText = \" \";\n\n // Determine width and get the font properties\n const result = this.measureText(tmpText, mod);\n const block = Object.assign({}, result.values);\n block.text = text;\n block.width = result.width;\n block.mod = mod;\n\n if (text === undefined || text === \"\") {\n block.width = 0;\n }\n\n this.lines[l].blocks.push(block);\n\n // Update the line width. We need this for determining if a string goes over max width\n this.lines[l].width += block.width;\n }\n\n /**\n * Returns the width in pixels of the current line.\n *\n * @returns {number}\n */\n curWidth() {\n const line = this.lines[this.current];\n if (line === undefined) return 0;\n\n return line.width;\n }\n\n /**\n * Add text in block to current line\n *\n * @param {string} text\n * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal']\n */\n append(text, mod = \"normal\") {\n this._add(this.current, text, mod);\n }\n\n /**\n * Add text in block to current line and start a new line\n *\n * @param {string} text\n * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal']\n */\n newLine(text, mod = \"normal\") {\n this._add(this.current, text, mod);\n this.current++;\n }\n\n /**\n * Determine and set the heights of all the lines currently contained in this instance\n *\n * Note that width has already been set.\n *\n * @private\n */\n determineLineHeights() {\n for (let k = 0; k < this.lines.length; k++) {\n const line = this.lines[k];\n\n // Looking for max height of blocks in line\n let height = 0;\n\n if (line.blocks !== undefined) {\n // Can happen if text contains e.g. '\\n '\n for (let l = 0; l < line.blocks.length; l++) {\n const block = line.blocks[l];\n\n if (height < block.height) {\n height = block.height;\n }\n }\n }\n\n line.height = height;\n }\n }\n\n /**\n * Determine the full size of the label text, as determined by current lines and blocks\n *\n * @private\n */\n determineLabelSize() {\n let width = 0;\n let height = 0;\n for (let k = 0; k < this.lines.length; k++) {\n const line = this.lines[k];\n\n if (line.width > width) {\n width = line.width;\n }\n height += line.height;\n }\n\n this.width = width;\n this.height = height;\n }\n\n /**\n * Remove all empty blocks and empty lines we don't need\n *\n * This must be done after the width/height determination,\n * so that these are set properly for processing here.\n *\n * @returns {Array<Line>} Lines with empty blocks (and some empty lines) removed\n * @private\n */\n removeEmptyBlocks() {\n const tmpLines = [];\n for (let k = 0; k < this.lines.length; k++) {\n const line = this.lines[k];\n\n // Note: an empty line in between text has width zero but is still relevant to layout.\n // So we can't use width for testing empty line here\n if (line.blocks.length === 0) continue;\n\n // Discard final empty line always\n if (k === this.lines.length - 1) {\n if (line.width === 0) continue;\n }\n\n const tmpLine = {};\n Object.assign(tmpLine, line);\n tmpLine.blocks = [];\n\n let firstEmptyBlock;\n const tmpBlocks = [];\n for (let l = 0; l < line.blocks.length; l++) {\n const block = line.blocks[l];\n if (block.width !== 0) {\n tmpBlocks.push(block);\n } else {\n if (firstEmptyBlock === undefined) {\n firstEmptyBlock = block;\n }\n }\n }\n\n // Ensure that there is *some* text present\n if (tmpBlocks.length === 0 && firstEmptyBlock !== undefined) {\n tmpBlocks.push(firstEmptyBlock);\n }\n\n tmpLine.blocks = tmpBlocks;\n\n tmpLines.push(tmpLine);\n }\n\n return tmpLines;\n }\n\n /**\n * Set the sizes for all lines and the whole thing.\n *\n * @returns {{width: (number|*), height: (number|*), lines: Array}}\n */\n finalize() {\n //console.log(JSON.stringify(this.lines, null, 2));\n\n this.determineLineHeights();\n this.determineLabelSize();\n const tmpLines = this.removeEmptyBlocks();\n\n // Return a simple hash object for further processing.\n return {\n width: this.width,\n height: this.height,\n lines: tmpLines,\n };\n }\n}\n\nexport default LabelAccumulator;\n","import LabelAccumulator from \"./LabelAccumulator\";\nimport { isValidLabel } from \"./ComponentUtil\";\n\n// Hash of prepared regexp's for tags\nconst tagPattern = {\n // HTML\n \"<b>\": /<b>/,\n \"<i>\": /<i>/,\n \"<code>\": /<code>/,\n \"</b>\": /<\\/b>/,\n \"</i>\": /<\\/i>/,\n \"</code>\": /<\\/code>/,\n // Markdown\n \"*\": /\\*/, // bold\n _: /_/, // ital\n \"`\": /`/, // mono\n afterBold: /[^*]/,\n afterItal: /[^_]/,\n afterMono: /[^`]/,\n};\n\n/**\n * Internal helper class for parsing the markup tags for HTML and Markdown.\n *\n * NOTE: Sequences of tabs and spaces are reduced to single space.\n * Scan usage of `this.spacing` within method\n */\nclass MarkupAccumulator {\n /**\n * Create an instance\n *\n * @param {string} text text to parse for markup\n */\n constructor(text) {\n this.text = text;\n this.bold = false;\n this.ital = false;\n this.mono = false;\n this.spacing = false;\n this.position = 0;\n this.buffer = \"\";\n this.modStack = [];\n\n this.blocks = [];\n }\n\n /**\n * Return the mod label currently on the top of the stack\n *\n * @returns {string} label of topmost mod\n * @private\n */\n mod() {\n return this.modStack.length === 0 ? \"normal\" : this.modStack[0];\n }\n\n /**\n * Return the mod label currently active\n *\n * @returns {string} label of active mod\n * @private\n */\n modName() {\n if (this.modStack.length === 0) return \"normal\";\n else if (this.modStack[0] === \"mono\") return \"mono\";\n else {\n if (this.bold && this.ital) {\n return \"boldital\";\n } else if (this.bold) {\n return \"bold\";\n } else if (this.ital) {\n return \"ital\";\n }\n }\n }\n\n /**\n * @private\n */\n emitBlock() {\n if (this.spacing) {\n this.add(\" \");\n this.spacing = false;\n }\n if (this.buffer.length > 0) {\n this.blocks.push({ text: this.buffer, mod: this.modName() });\n this.buffer = \"\";\n }\n }\n\n /**\n * Output text to buffer\n *\n * @param {string} text text to add\n * @private\n */\n add(text) {\n if (text === \" \") {\n this.spacing = true;\n }\n if (this.spacing) {\n this.buffer += \" \";\n this.spacing = false;\n }\n if (text != \" \") {\n this.buffer += text;\n }\n }\n\n /**\n * Handle parsing of whitespace\n *\n * @param {string} ch the character to check\n * @returns {boolean} true if the character was processed as whitespace, false otherwise\n */\n parseWS(ch) {\n if (/[ \\t]/.test(ch)) {\n if (!this.mono) {\n this.spacing = true;\n } else {\n this.add(ch);\n }\n return true;\n }\n\n return false;\n }\n\n /**\n * @param {string} tagName label for block type to set\n * @private\n */\n setTag(tagName) {\n this.emitBlock();\n this[tagName] = true;\n this.modStack.unshift(tagName);\n }\n\n /**\n * @param {string} tagName label for block type to unset\n * @private\n */\n unsetTag(tagName) {\n this.emitBlock();\n this[tagName] = false;\n this.modStack.shift();\n }\n\n /**\n * @param {string} tagName label for block type we are currently processing\n * @param {string|RegExp} tag string to match in text\n * @returns {boolean} true if the tag was processed, false otherwise\n */\n parseStartTag(tagName, tag) {\n // Note: if 'mono' passed as tagName, there is a double check here. This is OK\n if (!this.mono && !this[tagName] && this.match(tag)) {\n this.setTag(tagName);\n return true;\n }\n\n return false;\n }\n\n /**\n * @param {string|RegExp} tag\n * @param {number} [advance=true] if set, advance current position in text\n * @returns {boolean} true if match at given position, false otherwise\n * @private\n */\n match(tag, advance = true) {\n const [regExp, length] = this.prepareRegExp(tag);\n const matched = regExp.test(this.text.substr(this.position, length));\n\n if (matched && advance) {\n this.position += length - 1;\n }\n\n return matched;\n }\n\n /**\n * @param {string} tagName label for block type we are currently processing\n * @param {string|RegExp} tag string to match in text\n * @param {RegExp} [nextTag] regular expression to match for characters *following* the current tag\n * @returns {boolean} true if the tag was processed, false otherwise\n */\n parseEndTag(tagName, tag, nextTag) {\n let checkTag = this.mod() === tagName;\n if (tagName === \"mono\") {\n // special handling for 'mono'\n checkTag = checkTag && this.mono;\n } else {\n checkTag = checkTag && !this.mono;\n }\n\n if (checkTag && this.match(tag)) {\n if (nextTag !== undefined) {\n // Purpose of the following match is to prevent a direct unset/set of a given tag\n // E.g. '*bold **still bold*' => '*bold still bold*'\n if (\n this.position === this.text.length - 1 ||\n this.match(nextTag, false)\n ) {\n this.unsetTag(tagName);\n }\n } else {\n this.unsetTag(tagName);\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * @param {string|RegExp} tag string to match in text\n * @param {value} value string to replace tag with, if found at current position\n * @returns {boolean} true if the tag was processed, false otherwise\n */\n replace(tag, value) {\n if (this.match(tag)) {\n this.add(value);\n this.position += length - 1;\n return true;\n }\n\n return false;\n }\n\n /**\n * Create a regular expression for the tag if it isn't already one.\n *\n * The return value is an array `[RegExp, number]`, with exactly two value, where:\n * - RegExp is the regular expression to use\n * - number is the lenth of the input string to match\n *\n * @param {string|RegExp} tag string to match in text\n * @returns {Array} regular expression to use and length of input string to match\n * @private\n */\n prepareRegExp(tag) {\n let length;\n let regExp;\n if (tag instanceof RegExp) {\n regExp = tag;\n length = 1; // ASSUMPTION: regexp only tests one character\n } else {\n // use prepared regexp if present\n const prepared = tagPattern[tag];\n if (prepared !== undefined) {\n regExp = prepared;\n } else {\n regExp = new RegExp(tag);\n }\n\n length = tag.length;\n }\n\n return [regExp, length];\n }\n}\n\n/**\n * Helper class for Label which explodes the label text into lines and blocks within lines\n *\n * @private\n */\nclass LabelSplitter {\n /**\n * @param {CanvasRenderingContext2D} ctx Canvas rendering context\n * @param {Label} parent reference to the Label instance using current instance\n * @param {boolean} selected\n * @param {boolean} hover\n */\n constructor(ctx, parent, selected, hover) {\n this.ctx = ctx;\n this.parent = parent;\n this.selected = selected;\n this.hover = hover;\n\n /**\n * Callback to determine text width; passed to LabelAccumulator instance\n *\n * @param {string} text string to determine width of\n * @param {string} mod font type to use for this text\n * @returns {object} { width, values} width in pixels and font attributes\n */\n const textWidth = (text, mod) => {\n if (text === undefined) return 0;\n\n // TODO: This can be done more efficiently with caching\n // This will set the ctx.font correctly, depending on selected/hover and mod - so that ctx.measureText() will be accurate.\n const values = this.parent.getFormattingValues(ctx, selected, hover, mod);\n\n let width = 0;\n if (text !== \"\") {\n const measure = this.ctx.measureText(text);\n width = measure.width;\n }\n\n return { width, values: values };\n };\n\n this.lines = new LabelAccumulator(textWidth);\n }\n\n /**\n * Split passed text of a label into lines and blocks.\n *\n * # NOTE\n *\n * The handling of spacing is option dependent:\n *\n * - if `font.multi : false`, all spaces are retained\n * - if `font.multi : true`, every sequence of spaces is compressed to a single space\n *\n * This might not be the best way to do it, but this is as it has been working till now.\n * In order not to break existing functionality, for the time being this behaviour will\n * be retained in any code changes.\n *\n * @param {string} text text to split\n * @returns {Array<line>}\n */\n process(text) {\n if (!isValidLabel(text)) {\n return this.lines.finalize();\n }\n\n const font = this.parent.fontOptions;\n\n // Normalize the end-of-line's to a single representation - order important\n text = text.replace(/\\r\\n/g, \"\\n\"); // Dos EOL's\n text = text.replace(/\\r/g, \"\\n\"); // Mac EOL's\n\n // Note that at this point, there can be no \\r's in the text.\n // This is used later on splitStringIntoLines() to split multifont texts.\n\n const nlLines = String(text).split(\"\\n\");\n const lineCount = nlLines.length;\n\n if (font.multi) {\n // Multi-font case: styling tags active\n for (let i = 0; i < lineCount; i++) {\n const blocks = this.splitBlocks(nlLines[i], font.multi);\n // Post: Sequences of tabs and spaces are reduced to single space\n\n if (blocks === undefined) continue;\n\n if (blocks.length === 0) {\n this.lines.newLine(\"\");\n continue;\n }\n\n if (font.maxWdt > 0) {\n // widthConstraint.maximum defined\n //console.log('Running widthConstraint multi, max: ' + this.fontOptions.maxWdt);\n for (let j = 0; j < blocks.length; j++) {\n const mod = blocks[j].mod;\n const text = blocks[j].text;\n this.splitStringIntoLines(text, mod, true);\n }\n } else {\n // widthConstraint.maximum NOT defined\n for (let j = 0; j < blocks.length; j++) {\n const mod = blocks[j].mod;\n const text = blocks[j].text;\n this.lines.append(text, mod);\n }\n }\n\n this.lines.newLine();\n }\n } else {\n // Single-font case\n if (font.maxWdt > 0) {\n // widthConstraint.maximum defined\n // console.log('Running widthConstraint normal, max: ' + this.fontOptions.maxWdt);\n for (let i = 0; i < lineCount; i++) {\n this.splitStringIntoLines(nlLines[i]);\n }\n } else {\n // widthConstraint.maximum NOT defined\n for (let i = 0; i < lineCount; i++) {\n this.lines.newLine(nlLines[i]);\n }\n }\n }\n\n return this.lines.finalize();\n }\n\n /**\n * normalize the markup system\n *\n * @param {boolean|'md'|'markdown'|'html'} markupSystem\n * @returns {string}\n */\n decodeMarkupSystem(markupSystem) {\n let system = \"none\";\n if (markupSystem === \"markdown\" || markupSystem === \"md\") {\n system = \"markdown\";\n } else if (markupSystem === true || markupSystem === \"html\") {\n system = \"html\";\n }\n return system;\n }\n\n /**\n *\n * @param {string} text\n * @returns {Array}\n */\n splitHtmlBlocks(text) {\n const s = new MarkupAccumulator(text);\n\n const parseEntities = (ch) => {\n if (/&/.test(ch)) {\n const parsed =\n s.replace(s.text, \"&lt;\", \"<\") || s.replace(s.text, \"&amp;\", \"&\");\n\n if (!parsed) {\n s.add(\"&\");\n }\n\n return true;\n }\n\n return false;\n };\n\n while (s.position < s.text.length) {\n const ch = s.text.charAt(s.position);\n\n const parsed =\n s.parseWS(ch) ||\n (/</.test(ch) &&\n (s.parseStartTag(\"bold\", \"<b>\") ||\n s.parseStartTag(\"ital\", \"<i>\") ||\n s.parseStartTag(\"mono\", \"<code>\") ||\n s.parseEndTag(\"bold\", \"</b>\") ||\n s.parseEndTag(\"ital\", \"</i>\") ||\n s.parseEndTag(\"mono\", \"</code>\"))) ||\n parseEntities(ch);\n\n if (!parsed) {\n s.add(ch);\n }\n s.position++;\n }\n s.emitBlock();\n return s.blocks;\n }\n\n /**\n *\n * @param {string} text\n * @returns {Array}\n */\n splitMarkdownBlocks(text) {\n const s = new MarkupAccumulator(text);\n let beginable = true;\n\n const parseOverride = (ch) => {\n if (/\\\\/.test(ch)) {\n if (s.position < this.text.length + 1) {\n s.position++;\n ch = this.text.charAt(s.position);\n if (/ \\t/.test(ch)) {\n s.spacing = true;\n } else {\n s.add(ch);\n beginable = false;\n }\n }\n\n return true;\n }\n\n return false;\n };\n\n while (s.position < s.text.length) {\n const ch = s.text.charAt(s.position);\n\n const parsed =\n s.parseWS(ch) ||\n parseOverride(ch) ||\n ((beginable || s.spacing) &&\n (s.parseStartTag(\"bold\", \"*\") ||\n s.parseStartTag(\"ital\", \"_\") ||\n s.parseStartTag(\"mono\", \"`\"))) ||\n s.parseEndTag(\"bold\", \"*\", \"afterBold\") ||\n s.parseEndTag(\"ital\", \"_\", \"afterItal\") ||\n s.parseEndTag(\"mono\", \"`\", \"afterMono\");\n\n if (!parsed) {\n s.add(ch);\n beginable = false;\n }\n s.position++;\n }\n s.emitBlock();\n return s.blocks;\n }\n\n /**\n * Explodes a piece of text into single-font blocks using a given markup\n *\n * @param {string} text\n * @param {boolean|'md'|'markdown'|'html'} markupSystem\n * @returns {Array.<{text: string, mod: string}>}\n * @private\n */\n splitBlocks(text, markupSystem) {\n const system = this.decodeMarkupSystem(markupSystem);\n if (system === \"none\") {\n return [\n {\n text: text,\n mod: \"normal\",\n },\n ];\n } else if (system === \"markdown\") {\n return this.splitMarkdownBlocks(text);\n } else if (system === \"html\") {\n return this.splitHtmlBlocks(text);\n }\n }\n\n /**\n * @param {string} text\n * @returns {boolean} true if text length over the current max with\n * @private\n */\n overMaxWidth(text) {\n const width = this.ctx.measureText(text).width;\n return this.lines.curWidth() + width > this.parent.fontOptions.maxWdt;\n }\n\n /**\n * Determine the longest part of the sentence which still fits in the\n * current max width.\n *\n * @param {Array} words Array of strings signifying a text lines\n * @returns {number} index of first item in string making string go over max\n * @private\n */\n getLongestFit(words) {\n let text = \"\";\n let w = 0;\n\n while (w < words.length) {\n const pre = text === \"\" ? \"\" : \" \";\n const newText = text + pre + words[w];\n\n if (this.overMaxWidth(newText)) break;\n text = newText;\n w++;\n }\n\n return w;\n }\n\n /**\n * Determine the longest part of the string which still fits in the\n * current max width.\n *\n * @param {Array} words Array of strings signifying a text lines\n * @returns {number} index of first item in string making string go over max\n */\n getLongestFitWord(words) {\n let w = 0;\n\n while (w < words.length) {\n if (this.overMaxWidth(words.slice(0, w))) break;\n w++;\n }\n\n return w;\n }\n\n /**\n * Split the passed text into lines, according to width constraint (if any).\n *\n * The method assumes that the input string is a single line, i.e. without lines break.\n *\n * This method retains spaces, if still present (case `font.multi: false`).\n * A space which falls on an internal line break, will be replaced by a newline.\n * There is no special handling of tabs; these go along with the flow.\n *\n * @param {string} str\n * @param {string} [mod='normal']\n * @param {boolean} [appendLast=false]\n * @private\n */\n splitStringIntoLines(str, mod = \"normal\", appendLast = false) {\n // Set the canvas context font, based upon the current selected/hover state\n // and the provided mod, so the text measurement performed by getLongestFit\n // will be accurate - and not just use the font of whoever last used the canvas.\n this.parent.getFormattingValues(this.ctx, this.selected, this.hover, mod);\n\n // Still-present spaces are relevant, retain them\n str = str.replace(/^( +)/g, \"$1\\r\");\n str = str.replace(/([^\\r][^ ]*)( +)/g, \"$1\\r$2\\r\");\n let words = str.split(\"\\r\");\n\n while (words.length > 0) {\n let w = this.getLongestFit(words);\n\n if (w === 0) {\n // Special case: the first word is already larger than the max width.\n const word = words[0];\n\n // Break the word to the largest part that fits the line\n const x = this.getLongestFitWord(word);\n this.lines.newLine(word.slice(0, x), mod);\n\n // Adjust the word, so that the rest will be done next iteration\n words[0] = word.slice(x);\n } else {\n // skip any space that is replaced by a newline\n let newW = w;\n if (words[w - 1] === \" \") {\n w--;\n } else if (words[newW] === \" \") {\n newW++;\n }\n\n const text = words.slice(0, w).join(\"\");\n\n if (w == words.length && appendLast) {\n this.lines.append(text, mod);\n } else {\n this.lines.newLine(text, mod);\n }\n\n // Adjust the word, so that the rest will be done next iteration\n words = words.slice(newW);\n }\n }\n }\n}\n\nexport default LabelSplitter;\n","import { deepExtend, forEach, overrideOpacity, topMost } from \"vis-util/esnext\";\nimport { choosify, isValidLabel } from \"./ComponentUtil\";\nimport LabelSplitter from \"./LabelSplitter\";\n\n/**\n * List of special styles for multi-fonts\n *\n * @private\n */\nconst multiFontStyle = [\"bold\", \"ital\", \"boldital\", \"mono\"];\n\n/**\n * A Label to be used for Nodes or Edges.\n */\nclass Label {\n /**\n * @param {object} body\n * @param {object} options\n * @param {boolean} [edgelabel=false]\n */\n constructor(body, options, edgelabel = false) {\n this.body = body;\n this.pointToSelf = false;\n this.baseSize = undefined;\n this.fontOptions = {}; // instance variable containing the *instance-local* font options\n this.setOptions(options);\n this.size = { top: 0, left: 0, width: 0, height: 0, yLine: 0 };\n this.isEdgeLabel = edgelabel;\n }\n\n /**\n * @param {object} options the options of the parent Node-instance\n */\n setOptions(options) {\n this.elementOptions = options; // Reference to the options of the parent Node-instance\n\n this.initFontOptions(options.font);\n\n if (isValidLabel(options.label)) {\n this.labelDirty = true;\n } else {\n // Bad label! Change the option value to prevent bad stuff happening\n options.label = undefined;\n }\n\n if (options.font !== undefined && options.font !== null) {\n // font options can be deleted at various levels\n if (typeof options.font === \"string\") {\n this.baseSize = this.fontOptions.size;\n } else if (typeof options.font === \"object\") {\n const size = options.font.size;\n\n if (size !== undefined) {\n this.baseSize = size;\n }\n }\n }\n }\n\n /**\n * Init the font Options structure.\n *\n * Member fontOptions serves as an accumulator for the current font options.\n * As such, it needs to be completely separated from the node options.\n *\n * @param {object} newFontOptions the new font options to process\n * @private\n */\n initFontOptions(newFontOptions) {\n // Prepare the multi-font option objects.\n // These will be filled in propagateFonts(), if required\n forEach(multiFontStyle, (style) => {\n this.fontOptions[style] = {};\n });\n\n // Handle shorthand option, if present\n if (Label.parseFontString(this.fontOptions, newFontOptions)) {\n this.fontOptions.vadjust = 0;\n return;\n }\n\n // Copy over the non-multifont options, if specified\n forEach(newFontOptions, (prop, n) => {\n if (prop !== undefined && prop !== null && typeof prop !== \"object\") {\n this.fontOptions[n] = prop;\n }\n });\n }\n\n /**\n * If in-variable is a string, parse it as a font specifier.\n *\n * Note that following is not done here and have to be done after the call:\n * - Not all font options are set (vadjust, mod)\n *\n * @param {object} outOptions out-parameter, object in which to store the parse results (if any)\n * @param {object} inOptions font options to parse\n * @returns {boolean} true if font parsed as string, false otherwise\n * @static\n */\n static parseFontString(outOptions, inOptions) {\n if (!inOptions || typeof inOptions !== \"string\") return false;\n\n const newOptionsArray = inOptions.split(\" \");\n\n outOptions.size = +newOptionsArray[0].replace(\"px\", \"\");\n outOptions.face = newOptionsArray[1];\n outOptions.color = newOptionsArray[2];\n\n return true;\n }\n\n /**\n * Set the width and height constraints based on 'nearest' value\n *\n * @param {Array} pile array of option objects to consider\n * @returns {object} the actual constraint values to use\n * @private\n */\n constrain(pile) {\n // NOTE: constrainWidth and constrainHeight never set!\n // NOTE: for edge labels, only 'maxWdt' set\n // Node labels can set all the fields\n const fontOptions = {\n constrainWidth: false,\n maxWdt: -1,\n minWdt: -1,\n constrainHeight: false,\n minHgt: -1,\n valign: \"middle\",\n };\n\n const widthConstraint = topMost(pile, \"widthConstraint\");\n if (typeof widthConstraint === \"number\") {\n fontOptions.maxWdt = Number(widthConstraint);\n fontOptions.minWdt = Number(widthConstraint);\n } else if (typeof widthConstraint === \"object\") {\n const widthConstraintMaximum = topMost(pile, [\n \"widthConstraint\",\n \"maximum\",\n ]);\n if (typeof widthConstraintMaximum === \"number\") {\n fontOptions.maxWdt = Number(widthConstraintMaximum);\n }\n const widthConstraintMinimum = topMost(pile, [\n \"widthConstraint\",\n \"minimum\",\n ]);\n if (typeof widthConstraintMinimum === \"number\") {\n fontOptions.minWdt = Number(widthConstraintMinimum);\n }\n }\n\n const heightConstraint = topMost(pile, \"heightConstraint\");\n if (typeof heightConstraint === \"number\") {\n fontOptions.minHgt = Number(heightConstraint);\n } else if (typeof heightConstraint === \"object\") {\n const heightConstraintMinimum = topMost(pile, [\n \"heightConstraint\",\n \"minimum\",\n ]);\n if (typeof heightConstraintMinimum === \"number\") {\n fontOptions.minHgt = Number(heightConstraintMinimum);\n }\n const heightConstraintValign = topMost(pile, [\n \"heightConstraint\",\n \"valign\",\n ]);\n if (typeof heightConstraintValign === \"string\") {\n if (\n heightConstraintValign === \"top\" ||\n heightConstraintValign === \"bottom\"\n ) {\n fontOptions.valign = heightConstraintValign;\n }\n }\n }\n\n return fontOptions;\n }\n\n /**\n * Set options and update internal state\n *\n * @param {object} options options to set\n * @param {Array} pile array of option objects to consider for option 'chosen'\n */\n update(options, pile) {\n this.setOptions(options, true);\n this.propagateFonts(pile);\n deepExtend(this.fontOptions, this.constrain(pile));\n this.fontOptions.chooser = choosify(\"label\", pile);\n }\n\n /**\n * When margins are set in an element, adjust sizes is called to remove them\n * from the width/height constraints. This must be done prior to label sizing.\n *\n * @param {{top: number, right: number, bottom: number, left: number}} margins\n */\n adjustSizes(margins) {\n const widthBias = margins ? margins.right + margins.left : 0;\n if (this.fontOptions.constrainWidth) {\n this.fontOptions.maxWdt -= widthBias;\n this.fontOptions.minWdt -= widthBias;\n }\n const heightBias = margins ? margins.top + margins.bottom : 0;\n if (this.fontOptions.constrainHeight) {\n this.fontOptions.minHgt -= heightBias;\n }\n }\n\n /////////////////////////////////////////////////////////\n // Methods for handling options piles\n // Eventually, these will be moved to a separate class\n /////////////////////////////////////////////////////////\n\n /**\n * Add the font members of the passed list of option objects to the pile.\n *\n * @param {Pile} dstPile pile of option objects add to\n * @param {Pile} srcPile pile of option objects to take font options from\n * @private\n */\n addFontOptionsToPile(dstPile, srcPile) {\n for (let i = 0; i < srcPile.length; ++i) {\n this.addFontToPile(dstPile, srcPile[i]);\n }\n }\n\n /**\n * Add given font option object to the list of objects (the 'pile') to consider for determining\n * multi-font option values.\n *\n * @param {Pile} pile pile of option objects to use\n * @param {object} options instance to add to pile\n * @private\n */\n addFontToPile(pile, options) {\n if (options === undefined) return;\n if (options.font === undefined || options.font === null) return;\n\n const item = options.font;\n pile.push(item);\n }\n\n /**\n * Collect all own-property values from the font pile that aren't multi-font option objectss.\n *\n * @param {Pile} pile pile of option objects to use\n * @returns {object} object with all current own basic font properties\n * @private\n */\n getBasicOptions(pile) {\n const ret = {};\n\n // Scans the whole pile to get all options present\n for (let n = 0; n < pile.length; ++n) {\n let fontOptions = pile[n];\n\n // Convert shorthand if necessary\n const tmpShorthand = {};\n if (Label.parseFontString(tmpShorthand, fontOptions)) {\n fontOptions = tmpShorthand;\n }\n\n forEach(fontOptions, (opt, name) => {\n if (opt === undefined) return; // multi-font option need not be present\n if (Object.prototype.hasOwnProperty.call(ret, name)) return; // Keep first value we encounter\n\n if (multiFontStyle.indexOf(name) !== -1) {\n // Skip multi-font properties but we do need the structure\n ret[name] = {};\n } else {\n ret[name] = opt;\n }\n });\n }\n\n return ret;\n }\n\n /**\n * Return the value for given option for the given multi-font.\n *\n * All available option objects are trawled in the set order to construct the option values.\n *\n * ---------------------------------------------------------------------\n * ## Traversal of pile for multi-fonts\n *\n * The determination of multi-font option values is a special case, because any values not\n * present in the multi-font options should by definition be taken from the main font options,\n * i.e. from the current 'parent' object of the multi-font option.\n *\n * ### Search order for multi-fonts\n *\n * 'bold' used as example:\n *\n * - search in option group 'bold' in local properties\n * - search in main font option group in local properties\n *\n * ---------------------------------------------------------------------\n *\n * @param {Pile} pile pile of option objects to use\n * @param {MultiFontStyle} multiName sub path for the multi-font\n * @param {string} option the option to search for, for the given multi-font\n * @returns {string|number} the value for the given option\n * @private\n */\n getFontOption(pile, multiName, option) {\n let multiFont;\n\n // Search multi font in local properties\n for (let n = 0; n < pile.length; ++n) {\n const fontOptions = pile[n];\n\n if (Object.prototype.hasOwnProperty.call(fontOptions, multiName)) {\n multiFont = fontOptions[multiName];\n if (multiFont === undefined || multiFont === null) continue;\n\n // Convert shorthand if necessary\n // TODO: inefficient to do this conversion every time; find a better way.\n const tmpShorthand = {};\n if (Label.parseFontString(tmpShorthand, multiFont)) {\n multiFont = tmpShorthand;\n }\n\n if (Object.prototype.hasOwnProperty.call(multiFont, option)) {\n return multiFont[option];\n }\n }\n }\n\n // Option is not mentioned in the multi font options; take it from the parent font options.\n // These have already been converted with getBasicOptions(), so use the converted values.\n if (Object.prototype.hasOwnProperty.call(this.fontOptions, option)) {\n return this.fontOptions[option];\n }\n\n // A value **must** be found; you should never get here.\n throw new Error(\n \"Did not find value for multi-font for property: '\" + option + \"'\"\n );\n }\n\n /**\n * Return all options values for the given multi-font.\n *\n * All available option objects are trawled in the set order to construct the option values.\n *\n * @param {Pile} pile pile of option objects to use\n * @param {MultiFontStyle} multiName sub path for the mod-font\n * @returns {MultiFontOptions}\n * @private\n */\n getFontOptions(pile, multiName) {\n const result = {};\n const optionNames = [\"color\", \"size\", \"face\", \"mod\", \"vadjust\"]; // List of allowed options per multi-font\n\n for (let i = 0; i < optionNames.length; ++i) {\n const mod = optionNames[i];\n result[mod] = this.getFontOption(pile, multiName, mod);\n }\n\n return result;\n }\n\n /////////////////////////////////////////////////////////\n // End methods for handling options piles\n /////////////////////////////////////////////////////////\n\n /**\n * Collapse the font options for the multi-font to single objects, from\n * the chain of option objects passed (the 'pile').\n *\n * @param {Pile} pile sequence of option objects to consider.\n * First item in list assumed to be the newly set options.\n */\n propagateFonts(pile) {\n const fontPile = []; // sequence of font objects to consider, order important\n\n // Note that this.elementOptions is not used here.\n this.addFontOptionsToPile(fontPile, pile);\n this.fontOptions = this.getBasicOptions(fontPile);\n\n // We set multifont values even if multi === false, for consistency (things break otherwise)\n for (let i = 0; i < multiFontStyle.length; ++i) {\n const mod = multiFontStyle[i];\n const modOptions = this.fontOptions[mod];\n const tmpMultiFontOptions = this.getFontOptions(fontPile, mod);\n\n // Copy over found values\n forEach(tmpMultiFontOptions, (option, n) => {\n modOptions[n] = option;\n });\n\n modOptions.size = Number(modOptions.size);\n modOptions.vadjust = Number(modOptions.vadjust);\n }\n }\n\n /**\n * Main function. This is called from anything that wants to draw a label.\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x\n * @param {number} y\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {string} [baseline='middle']\n */\n draw(ctx, x, y, selected, hover, baseline = \"middle\") {\n // if no label, return\n if (this.elementOptions.label === undefined) return;\n\n // check if we have to render the label\n let viewFontSize = this.fontOptions.size * this.body.view.scale;\n if (\n this.elementOptions.label &&\n viewFontSize < this.elementOptions.scaling.label.drawThreshold - 1\n )\n return;\n\n // This ensures that there will not be HUGE letters on screen\n // by setting an upper limit on the visible text size (regardless of zoomLevel)\n if (viewFontSize >= this.elementOptions.scaling.label.maxVisible) {\n viewFontSize =\n Number(this.elementOptions.scaling.label.maxVisible) /\n this.body.view.scale;\n }\n\n // update the size cache if required\n this.calculateLabelSize(ctx, selected, hover, x, y, baseline);\n this._drawBackground(ctx);\n this._drawText(ctx, x, this.size.yLine, baseline, viewFontSize);\n }\n\n /**\n * Draws the label background\n *\n * @param {CanvasRenderingContext2D} ctx\n * @private\n */\n _drawBackground(ctx) {\n if (\n this.fontOptions.background !== undefined &&\n this.fontOptions.background !== \"none\"\n ) {\n ctx.fillStyle = this.fontOptions.background;\n const size = this.getSize();\n ctx.fillRect(size.left, size.top, size.width, size.height);\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x\n * @param {number} y\n * @param {string} [baseline='middle']\n * @param {number} viewFontSize\n * @private\n */\n _drawText(ctx, x, y, baseline = \"middle\", viewFontSize) {\n [x, y] = this._setAlignment(ctx, x, y, baseline);\n\n ctx.textAlign = \"left\";\n x = x - this.size.width / 2; // Shift label 1/2-distance to the left\n if (this.fontOptions.valign && this.size.height > this.size.labelHeight) {\n if (this.fontOptions.valign === \"top\") {\n y -= (this.size.height - this.size.labelHeight) / 2;\n }\n if (this.fontOptions.valign === \"bottom\") {\n y += (this.size.height - this.size.labelHeight) / 2;\n }\n }\n\n // draw the text\n for (let i = 0; i < this.lineCount; i++) {\n const line = this.lines[i];\n if (line && line.blocks) {\n let width = 0;\n if (this.isEdgeLabel || this.fontOptions.align === \"center\") {\n width += (this.size.width - line.width) / 2;\n } else if (this.fontOptions.align === \"right\") {\n width += this.size.width - line.width;\n }\n for (let j = 0; j < line.blocks.length; j++) {\n const block = line.blocks[j];\n ctx.font = block.font;\n const [fontColor, strokeColor] = this._getColor(\n block.color,\n viewFontSize,\n block.strokeColor\n );\n if (block.strokeWidth > 0) {\n ctx.lineWidth = block.strokeWidth;\n ctx.strokeStyle = strokeColor;\n ctx.lineJoin = \"round\";\n }\n ctx.fillStyle = fontColor;\n\n if (block.strokeWidth > 0) {\n ctx.strokeText(block.text, x + width, y + block.vadjust);\n }\n ctx.fillText(block.text, x + width, y + block.vadjust);\n width += block.width;\n }\n y += line.height;\n }\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x\n * @param {number} y\n * @param {string} baseline\n * @returns {Array.<number>}\n * @private\n */\n _setAlignment(ctx, x, y, baseline) {\n // check for label alignment (for edges)\n // TODO: make alignment for nodes\n if (\n this.isEdgeLabel &&\n this.fontOptions.align !== \"horizontal\" &&\n this.pointToSelf === false\n ) {\n x = 0;\n y = 0;\n\n const lineMargin = 2;\n if (this.fontOptions.align === \"top\") {\n ctx.textBaseline = \"alphabetic\";\n y -= 2 * lineMargin; // distance from edge, required because we use alphabetic. Alphabetic has less difference between browsers\n } else if (this.fontOptions.align === \"bottom\") {\n ctx.textBaseline = \"hanging\";\n y += 2 * lineMargin; // distance from edge, required because we use hanging. Hanging has less difference between browsers\n } else {\n ctx.textBaseline = \"middle\";\n }\n } else {\n ctx.textBaseline = baseline;\n }\n return [x, y];\n }\n\n /**\n * fade in when relative scale is between threshold and threshold - 1.\n * If the relative scale would be smaller than threshold -1 the draw function would have returned before coming here.\n *\n * @param {string} color The font color to use\n * @param {number} viewFontSize\n * @param {string} initialStrokeColor\n * @returns {Array.<string>} An array containing the font color and stroke color\n * @private\n */\n _getColor(color, viewFontSize, initialStrokeColor) {\n let fontColor = color || \"#000000\";\n let strokeColor = initialStrokeColor || \"#ffffff\";\n if (viewFontSize <= this.elementOptions.scaling.label.drawThreshold) {\n const opacity = Math.max(\n 0,\n Math.min(\n 1,\n 1 - (this.elementOptions.scaling.label.drawThreshold - viewFontSize)\n )\n );\n fontColor = overrideOpacity(fontColor, opacity);\n strokeColor = overrideOpacity(strokeColor, opacity);\n }\n return [fontColor, strokeColor];\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n * @returns {{width: number, height: number}}\n */\n getTextSize(ctx, selected = false, hover = false) {\n this._processLabel(ctx, selected, hover);\n return {\n width: this.size.width,\n height: this.size.height,\n lineCount: this.lineCount,\n };\n }\n\n /**\n * Get the current dimensions of the label\n *\n * @returns {rect}\n */\n getSize() {\n const lineMargin = 2;\n let x = this.size.left; // default values which might be overridden below\n let y = this.size.top - 0.5 * lineMargin; // idem\n\n if (this.isEdgeLabel) {\n const x2 = -this.size.width * 0.5;\n\n switch (this.fontOptions.align) {\n case \"middle\":\n x = x2;\n y = -this.size.height * 0.5;\n break;\n case \"top\":\n x = x2;\n y = -(this.size.height + lineMargin);\n break;\n case \"bottom\":\n x = x2;\n y = lineMargin;\n break;\n }\n }\n\n const ret = {\n left: x,\n top: y,\n width: this.size.width,\n height: this.size.height,\n };\n\n return ret;\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {number} [x=0]\n * @param {number} [y=0]\n * @param {'middle'|'hanging'} [baseline='middle']\n */\n calculateLabelSize(ctx, selected, hover, x = 0, y = 0, baseline = \"middle\") {\n this._processLabel(ctx, selected, hover);\n this.size.left = x - this.size.width * 0.5;\n this.size.top = y - this.size.height * 0.5;\n this.size.yLine = y + (1 - this.lineCount) * 0.5 * this.fontOptions.size;\n if (baseline === \"hanging\") {\n this.size.top += 0.5 * this.fontOptions.size;\n this.size.top += 4; // distance from node, required because we use hanging. Hanging has less difference between browsers\n this.size.yLine += 4; // distance from node\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {string} mod\n * @returns {{color, size, face, mod, vadjust, strokeWidth: *, strokeColor: (*|string|allOptions.edges.font.strokeColor|{string}|allOptions.nodes.font.strokeColor|Array)}}\n */\n getFormattingValues(ctx, selected, hover, mod) {\n const getValue = function (fontOptions, mod, option) {\n if (mod === \"normal\") {\n if (option === \"mod\") return \"\";\n return fontOptions[option];\n }\n\n if (fontOptions[mod][option] !== undefined) {\n // Grumbl leaving out test on undefined equals false for \"\"\n return fontOptions[mod][option];\n } else {\n // Take from parent font option\n return fontOptions[option];\n }\n };\n\n const values = {\n color: getValue(this.fontOptions, mod, \"color\"),\n size: getValue(this.fontOptions, mod, \"size\"),\n face: getValue(this.fontOptions, mod, \"face\"),\n mod: getValue(this.fontOptions, mod, \"mod\"),\n vadjust: getValue(this.fontOptions, mod, \"vadjust\"),\n strokeWidth: this.fontOptions.strokeWidth,\n strokeColor: this.fontOptions.strokeColor,\n };\n if (selected || hover) {\n if (\n mod === \"normal\" &&\n this.fontOptions.chooser === true &&\n this.elementOptions.labelHighlightBold\n ) {\n values.mod = \"bold\";\n } else {\n if (typeof this.fontOptions.chooser === \"function\") {\n this.fontOptions.chooser(\n values,\n this.elementOptions.id,\n selected,\n hover\n );\n }\n }\n }\n\n let fontString = \"\";\n if (values.mod !== undefined && values.mod !== \"\") {\n // safeguard for undefined - this happened\n fontString += values.mod + \" \";\n }\n fontString += values.size + \"px \" + values.face;\n\n ctx.font = fontString.replace(/\"/g, \"\");\n values.font = ctx.font;\n values.height = values.size;\n return values;\n }\n\n /**\n *\n * @param {boolean} selected\n * @param {boolean} hover\n * @returns {boolean}\n */\n differentState(selected, hover) {\n return selected !== this.selectedState || hover !== this.hoverState;\n }\n\n /**\n * This explodes the passed text into lines and determines the width, height and number of lines.\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {string} inText the text to explode\n * @returns {{width, height, lines}|*}\n * @private\n */\n _processLabelText(ctx, selected, hover, inText) {\n const splitter = new LabelSplitter(ctx, this, selected, hover);\n return splitter.process(inText);\n }\n\n /**\n * This explodes the label string into lines and sets the width, height and number of lines.\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n * @private\n */\n _processLabel(ctx, selected, hover) {\n if (this.labelDirty === false && !this.differentState(selected, hover))\n return;\n\n const state = this._processLabelText(\n ctx,\n selected,\n hover,\n this.elementOptions.label\n );\n\n if (this.fontOptions.minWdt > 0 && state.width < this.fontOptions.minWdt) {\n state.width = this.fontOptions.minWdt;\n }\n\n this.size.labelHeight = state.height;\n if (this.fontOptions.minHgt > 0 && state.height < this.fontOptions.minHgt) {\n state.height = this.fontOptions.minHgt;\n }\n\n this.lines = state.lines;\n this.lineCount = state.lines.length;\n this.size.width = state.width;\n this.size.height = state.height;\n this.selectedState = selected;\n this.hoverState = hover;\n\n this.labelDirty = false;\n }\n\n /**\n * Check if this label is visible\n *\n * @returns {boolean} true if this label will be show, false otherwise\n */\n visible() {\n if (\n this.size.width === 0 ||\n this.size.height === 0 ||\n this.elementOptions.label === undefined\n ) {\n return false; // nothing to display\n }\n\n const viewFontSize = this.fontOptions.size * this.body.view.scale;\n if (viewFontSize < this.elementOptions.scaling.label.drawThreshold - 1) {\n return false; // Too small or too far away to show\n }\n\n return true;\n }\n}\n\nexport default Label;\n","/**\n * The Base class for all Nodes.\n */\nclass NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n this.body = body;\n this.labelModule = labelModule;\n this.setOptions(options);\n this.top = undefined;\n this.left = undefined;\n this.height = undefined;\n this.width = undefined;\n this.radius = undefined;\n this.margin = undefined;\n this.refreshNeeded = true;\n this.boundingBox = { top: 0, left: 0, right: 0, bottom: 0 };\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n *\n * @param {Label} labelModule\n * @private\n */\n _setMargins(labelModule) {\n this.margin = {};\n if (this.options.margin) {\n if (typeof this.options.margin == \"object\") {\n this.margin.top = this.options.margin.top;\n this.margin.right = this.options.margin.right;\n this.margin.bottom = this.options.margin.bottom;\n this.margin.left = this.options.margin.left;\n } else {\n this.margin.top = this.options.margin;\n this.margin.right = this.options.margin;\n this.margin.bottom = this.options.margin;\n this.margin.left = this.options.margin;\n }\n }\n labelModule.adjustSizes(this.margin);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n * @private\n */\n _distanceToBorder(ctx, angle) {\n const borderWidth = this.options.borderWidth;\n if (ctx) {\n this.resize(ctx);\n }\n return (\n Math.min(\n Math.abs(this.width / 2 / Math.cos(angle)),\n Math.abs(this.height / 2 / Math.sin(angle))\n ) + borderWidth\n );\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n */\n enableShadow(ctx, values) {\n if (values.shadow) {\n ctx.shadowColor = values.shadowColor;\n ctx.shadowBlur = values.shadowSize;\n ctx.shadowOffsetX = values.shadowX;\n ctx.shadowOffsetY = values.shadowY;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n */\n disableShadow(ctx, values) {\n if (values.shadow) {\n ctx.shadowColor = \"rgba(0,0,0,0)\";\n ctx.shadowBlur = 0;\n ctx.shadowOffsetX = 0;\n ctx.shadowOffsetY = 0;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n */\n enableBorderDashes(ctx, values) {\n if (values.borderDashes !== false) {\n if (ctx.setLineDash !== undefined) {\n let dashes = values.borderDashes;\n if (dashes === true) {\n dashes = [5, 15];\n }\n ctx.setLineDash(dashes);\n } else {\n console.warn(\n \"setLineDash is not supported in this browser. The dashed borders cannot be used.\"\n );\n this.options.shapeProperties.borderDashes = false;\n values.borderDashes = false;\n }\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n */\n disableBorderDashes(ctx, values) {\n if (values.borderDashes !== false) {\n if (ctx.setLineDash !== undefined) {\n ctx.setLineDash([0]);\n } else {\n console.warn(\n \"setLineDash is not supported in this browser. The dashed borders cannot be used.\"\n );\n this.options.shapeProperties.borderDashes = false;\n values.borderDashes = false;\n }\n }\n }\n\n /**\n * Determine if the shape of a node needs to be recalculated.\n *\n * @param {boolean} selected\n * @param {boolean} hover\n * @returns {boolean}\n * @protected\n */\n needsRefresh(selected, hover) {\n if (this.refreshNeeded === true) {\n // This is probably not the best location to reset this member.\n // However, in the current logic, it is the most convenient one.\n this.refreshNeeded = false;\n return true;\n }\n\n return (\n this.width === undefined ||\n this.labelModule.differentState(selected, hover)\n );\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n */\n initContextForDraw(ctx, values) {\n const borderWidth = values.borderWidth / this.body.view.scale;\n\n ctx.lineWidth = Math.min(this.width, borderWidth);\n ctx.strokeStyle = values.borderColor;\n ctx.fillStyle = values.color;\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n */\n performStroke(ctx, values) {\n const borderWidth = values.borderWidth / this.body.view.scale;\n\n //draw dashed border if enabled, save and restore is required for firefox not to crash on unix.\n ctx.save();\n // if borders are zero width, they will be drawn with width 1 by default. This prevents that\n if (borderWidth > 0) {\n this.enableBorderDashes(ctx, values);\n //draw the border\n ctx.stroke();\n //disable dashed border for other elements\n this.disableBorderDashes(ctx, values);\n }\n ctx.restore();\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n */\n performFill(ctx, values) {\n ctx.save();\n ctx.fillStyle = values.color;\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n // draw the background\n ctx.fill();\n // disable shadows for other elements.\n this.disableShadow(ctx, values);\n\n ctx.restore();\n this.performStroke(ctx, values);\n }\n\n /**\n *\n * @param {number} margin\n * @private\n */\n _addBoundingBoxMargin(margin) {\n this.boundingBox.left -= margin;\n this.boundingBox.top -= margin;\n this.boundingBox.bottom += margin;\n this.boundingBox.right += margin;\n }\n\n /**\n * Actual implementation of this method call.\n *\n * Doing it like this makes it easier to override\n * in the child classes.\n *\n * @param {number} x width\n * @param {number} y height\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n * @private\n */\n _updateBoundingBox(x, y, ctx, selected, hover) {\n if (ctx !== undefined) {\n this.resize(ctx, selected, hover);\n }\n\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n\n this.boundingBox.left = this.left;\n this.boundingBox.top = this.top;\n this.boundingBox.bottom = this.top + this.height;\n this.boundingBox.right = this.left + this.width;\n }\n\n /**\n * Default implementation of this method call.\n * This acts as a stub which can be overridden.\n *\n * @param {number} x width\n * @param {number} y height\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n */\n updateBoundingBox(x, y, ctx, selected, hover) {\n this._updateBoundingBox(x, y, ctx, selected, hover);\n }\n\n /**\n * Determine the dimensions to use for nodes with an internal label\n *\n * Currently, these are: Circle, Ellipse, Database, Box\n * The other nodes have external labels, and will not call this method\n *\n * If there is no label, decent default values are supplied.\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n * @returns {{width:number, height:number}}\n */\n getDimensionsFromLabel(ctx, selected, hover) {\n // NOTE: previously 'textSize' was not put in 'this' for Ellipse\n // TODO: examine the consequences.\n this.textSize = this.labelModule.getTextSize(ctx, selected, hover);\n let width = this.textSize.width;\n let height = this.textSize.height;\n\n const DEFAULT_SIZE = 14;\n if (width === 0) {\n // This happens when there is no label text set\n width = DEFAULT_SIZE; // use a decent default\n height = DEFAULT_SIZE; // if width zero, then height also always zero\n }\n\n return { width: width, height: height };\n }\n}\n\nexport default NodeBase;\n","\"use strict\";\n\nimport NodeBase from \"../util/NodeBase\";\nimport { drawRoundRect } from \"../util/shapes\";\n\n/**\n * A Box Node/Cluster shape.\n *\n * @augments NodeBase\n */\nclass Box extends NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n this._setMargins(labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n */\n resize(ctx, selected = this.selected, hover = this.hover) {\n if (this.needsRefresh(selected, hover)) {\n const dimensions = this.getDimensionsFromLabel(ctx, selected, hover);\n\n this.width = dimensions.width + this.margin.right + this.margin.left;\n this.height = dimensions.height + this.margin.top + this.margin.bottom;\n this.radius = this.width / 2;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n */\n draw(ctx, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover);\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n\n this.initContextForDraw(ctx, values);\n drawRoundRect(\n ctx,\n this.left,\n this.top,\n this.width,\n this.height,\n values.borderRadius\n );\n this.performFill(ctx, values);\n\n this.updateBoundingBox(x, y, ctx, selected, hover);\n this.labelModule.draw(\n ctx,\n this.left + this.textSize.width / 2 + this.margin.left,\n this.top + this.textSize.height / 2 + this.margin.top,\n selected,\n hover\n );\n }\n\n /**\n *\n * @param {number} x width\n * @param {number} y height\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n */\n updateBoundingBox(x, y, ctx, selected, hover) {\n this._updateBoundingBox(x, y, ctx, selected, hover);\n\n const borderRadius = this.options.shapeProperties.borderRadius; // only effective for box\n this._addBoundingBoxMargin(borderRadius);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n if (ctx) {\n this.resize(ctx);\n }\n const borderWidth = this.options.borderWidth;\n\n return (\n Math.min(\n Math.abs(this.width / 2 / Math.cos(angle)),\n Math.abs(this.height / 2 / Math.sin(angle))\n ) + borderWidth\n );\n }\n}\n\nexport default Box;\n","import NodeBase from \"./NodeBase\";\nimport { drawCircle } from \"./shapes\";\n\n/**\n * NOTE: This is a bad base class\n *\n * Child classes are:\n *\n * Image - uses *only* image methods\n * Circle - uses *only* _drawRawCircle\n * CircleImage - uses all\n *\n * TODO: Refactor, move _drawRawCircle to different module, derive Circle from NodeBase\n * Rename this to ImageBase\n * Consolidate common code in Image and CircleImage to base class\n *\n * @augments NodeBase\n */\nclass CircleImageBase extends NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n this.labelOffset = 0;\n this.selected = false;\n }\n\n /**\n *\n * @param {object} options\n * @param {object} [imageObj]\n * @param {object} [imageObjAlt]\n */\n setOptions(options, imageObj, imageObjAlt) {\n this.options = options;\n\n if (!(imageObj === undefined && imageObjAlt === undefined)) {\n this.setImages(imageObj, imageObjAlt);\n }\n }\n\n /**\n * Set the images for this node.\n *\n * The images can be updated after the initial setting of options;\n * therefore, this method needs to be reentrant.\n *\n * For correct working in error cases, it is necessary to properly set\n * field 'nodes.brokenImage' in the options.\n *\n * @param {Image} imageObj required; main image to show for this node\n * @param {Image|undefined} imageObjAlt optional; image to show when node is selected\n */\n setImages(imageObj, imageObjAlt) {\n if (imageObjAlt && this.selected) {\n this.imageObj = imageObjAlt;\n this.imageObjAlt = imageObj;\n } else {\n this.imageObj = imageObj;\n this.imageObjAlt = imageObjAlt;\n }\n }\n\n /**\n * Set selection and switch between the base and the selected image.\n *\n * Do the switch only if imageObjAlt exists.\n *\n * @param {boolean} selected value of new selected state for current node\n */\n switchImages(selected) {\n const selection_changed =\n (selected && !this.selected) || (!selected && this.selected);\n this.selected = selected; // Remember new selection\n\n if (this.imageObjAlt !== undefined && selection_changed) {\n const imageTmp = this.imageObj;\n this.imageObj = this.imageObjAlt;\n this.imageObjAlt = imageTmp;\n }\n }\n\n /**\n * Returns Image Padding from node options\n *\n * @returns {{top: number,left: number,bottom: number,right: number}} image padding inside this shape\n * @private\n */\n _getImagePadding() {\n const imgPadding = { top: 0, right: 0, bottom: 0, left: 0 };\n if (this.options.imagePadding) {\n const optImgPadding = this.options.imagePadding;\n if (typeof optImgPadding == \"object\") {\n imgPadding.top = optImgPadding.top;\n imgPadding.right = optImgPadding.right;\n imgPadding.bottom = optImgPadding.bottom;\n imgPadding.left = optImgPadding.left;\n } else {\n imgPadding.top = optImgPadding;\n imgPadding.right = optImgPadding;\n imgPadding.bottom = optImgPadding;\n imgPadding.left = optImgPadding;\n }\n }\n\n return imgPadding;\n }\n\n /**\n * Adjust the node dimensions for a loaded image.\n *\n * Pre: this.imageObj is valid\n */\n _resizeImage() {\n let width, height;\n\n if (this.options.shapeProperties.useImageSize === false) {\n // Use the size property\n let ratio_width = 1;\n let ratio_height = 1;\n\n // Only calculate the proper ratio if both width and height not zero\n if (this.imageObj.width && this.imageObj.height) {\n if (this.imageObj.width > this.imageObj.height) {\n ratio_width = this.imageObj.width / this.imageObj.height;\n } else {\n ratio_height = this.imageObj.height / this.imageObj.width;\n }\n }\n\n width = this.options.size * 2 * ratio_width;\n height = this.options.size * 2 * ratio_height;\n } else {\n // Use the image size with image padding\n const imgPadding = this._getImagePadding();\n width = this.imageObj.width + imgPadding.left + imgPadding.right;\n height = this.imageObj.height + imgPadding.top + imgPadding.bottom;\n }\n\n this.width = width;\n this.height = height;\n this.radius = 0.5 * this.width;\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {ArrowOptions} values\n * @private\n */\n _drawRawCircle(ctx, x, y, values) {\n this.initContextForDraw(ctx, values);\n drawCircle(ctx, x, y, values.size);\n this.performFill(ctx, values);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {ArrowOptions} values\n * @private\n */\n _drawImageAtPosition(ctx, values) {\n if (this.imageObj.width != 0) {\n // draw the image\n ctx.globalAlpha = values.opacity !== undefined ? values.opacity : 1;\n\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n\n let factor = 1;\n if (this.options.shapeProperties.interpolation === true) {\n factor = this.imageObj.width / this.width / this.body.view.scale;\n }\n\n const imgPadding = this._getImagePadding();\n\n const imgPosLeft = this.left + imgPadding.left;\n const imgPosTop = this.top + imgPadding.top;\n const imgWidth = this.width - imgPadding.left - imgPadding.right;\n const imgHeight = this.height - imgPadding.top - imgPadding.bottom;\n this.imageObj.drawImageAtPosition(\n ctx,\n factor,\n imgPosLeft,\n imgPosTop,\n imgWidth,\n imgHeight\n );\n\n // disable shadows for other elements.\n this.disableShadow(ctx, values);\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @private\n */\n _drawImageLabel(ctx, x, y, selected, hover) {\n let offset = 0;\n\n if (this.height !== undefined) {\n offset = this.height * 0.5;\n const labelDimensions = this.labelModule.getTextSize(\n ctx,\n selected,\n hover\n );\n if (labelDimensions.lineCount >= 1) {\n offset += labelDimensions.height / 2;\n }\n }\n\n const yLabel = y + offset;\n\n if (this.options.label) {\n this.labelOffset = offset;\n }\n this.labelModule.draw(ctx, x, yLabel, selected, hover, \"hanging\");\n }\n}\n\nexport default CircleImageBase;\n","\"use strict\";\n\nimport CircleImageBase from \"../util/CircleImageBase\";\n\n/**\n * A Circle Node/Cluster shape.\n *\n * @augments CircleImageBase\n */\nclass Circle extends CircleImageBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n this._setMargins(labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n */\n resize(ctx, selected = this.selected, hover = this.hover) {\n if (this.needsRefresh(selected, hover)) {\n const dimensions = this.getDimensionsFromLabel(ctx, selected, hover);\n\n const diameter = Math.max(\n dimensions.width + this.margin.right + this.margin.left,\n dimensions.height + this.margin.top + this.margin.bottom\n );\n\n this.options.size = diameter / 2; // NOTE: this size field only set here, not in Ellipse, Database, Box\n this.width = diameter;\n this.height = diameter;\n this.radius = this.width / 2;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n */\n draw(ctx, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover);\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n\n this._drawRawCircle(ctx, x, y, values);\n\n this.updateBoundingBox(x, y);\n this.labelModule.draw(\n ctx,\n this.left + this.textSize.width / 2 + this.margin.left,\n y,\n selected,\n hover\n );\n }\n\n /**\n *\n * @param {number} x width\n * @param {number} y height\n */\n updateBoundingBox(x, y) {\n this.boundingBox.top = y - this.options.size;\n this.boundingBox.left = x - this.options.size;\n this.boundingBox.right = x + this.options.size;\n this.boundingBox.bottom = y + this.options.size;\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @returns {number}\n */\n distanceToBorder(ctx) {\n if (ctx) {\n this.resize(ctx);\n }\n return this.width * 0.5;\n }\n}\n\nexport default Circle;\n","\"use strict\";\n\nimport CircleImageBase from \"../util/CircleImageBase\";\n\n/**\n * A CircularImage Node/Cluster shape.\n *\n * @augments CircleImageBase\n */\nclass CircularImage extends CircleImageBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n * @param {Image} imageObj\n * @param {Image} imageObjAlt\n */\n constructor(options, body, labelModule, imageObj, imageObjAlt) {\n super(options, body, labelModule);\n\n this.setImages(imageObj, imageObjAlt);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n */\n resize(ctx, selected = this.selected, hover = this.hover) {\n const imageAbsent =\n this.imageObj.src === undefined ||\n this.imageObj.width === undefined ||\n this.imageObj.height === undefined;\n\n if (imageAbsent) {\n const diameter = this.options.size * 2;\n this.width = diameter;\n this.height = diameter;\n this.radius = 0.5 * this.width;\n return;\n }\n\n // At this point, an image is present, i.e. this.imageObj is valid.\n if (this.needsRefresh(selected, hover)) {\n this._resizeImage();\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n */\n draw(ctx, x, y, selected, hover, values) {\n this.switchImages(selected);\n this.resize();\n\n let labelX = x,\n labelY = y;\n\n if (this.options.shapeProperties.coordinateOrigin === \"top-left\") {\n this.left = x;\n this.top = y;\n labelX += this.width / 2;\n labelY += this.height / 2;\n } else {\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n }\n\n // draw the background circle. IMPORTANT: the stroke in this method is used by the clip method below.\n this._drawRawCircle(ctx, labelX, labelY, values);\n\n // now we draw in the circle, we save so we can revert the clip operation after drawing.\n ctx.save();\n // clip is used to use the stroke in drawRawCircle as an area that we can draw in.\n ctx.clip();\n // draw the image\n this._drawImageAtPosition(ctx, values);\n // restore so we can again draw on the full canvas\n ctx.restore();\n\n this._drawImageLabel(ctx, labelX, labelY, selected, hover);\n\n this.updateBoundingBox(x, y);\n }\n\n // TODO: compare with Circle.updateBoundingBox(), consolidate? More stuff is happening here\n /**\n *\n * @param {number} x width\n * @param {number} y height\n */\n updateBoundingBox(x, y) {\n if (this.options.shapeProperties.coordinateOrigin === \"top-left\") {\n this.boundingBox.top = y;\n this.boundingBox.left = x;\n this.boundingBox.right = x + this.options.size * 2;\n this.boundingBox.bottom = y + this.options.size * 2;\n } else {\n this.boundingBox.top = y - this.options.size;\n this.boundingBox.left = x - this.options.size;\n this.boundingBox.right = x + this.options.size;\n this.boundingBox.bottom = y + this.options.size;\n }\n\n // TODO: compare with Image.updateBoundingBox(), consolidate?\n this.boundingBox.left = Math.min(\n this.boundingBox.left,\n this.labelModule.size.left\n );\n this.boundingBox.right = Math.max(\n this.boundingBox.right,\n this.labelModule.size.left + this.labelModule.size.width\n );\n this.boundingBox.bottom = Math.max(\n this.boundingBox.bottom,\n this.boundingBox.bottom + this.labelOffset\n );\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @returns {number}\n */\n distanceToBorder(ctx) {\n if (ctx) {\n this.resize(ctx);\n }\n return this.width * 0.5;\n }\n}\n\nexport default CircularImage;\n","import NodeBase from \"../util/NodeBase\";\nimport { getShape } from \"./shapes\";\n\n/**\n * Base class for constructing Node/Cluster Shapes.\n *\n * @augments NodeBase\n */\nclass ShapeBase extends NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n * @param {object} [values={size: this.options.size}]\n */\n resize(\n ctx,\n selected = this.selected,\n hover = this.hover,\n values = { size: this.options.size }\n ) {\n if (this.needsRefresh(selected, hover)) {\n this.labelModule.getTextSize(ctx, selected, hover);\n const size = 2 * values.size;\n this.width = this.customSizeWidth ?? size;\n this.height = this.customSizeHeight ?? size;\n this.radius = 0.5 * this.width;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {string} shape\n * @param {number} sizeMultiplier - Unused! TODO: Remove next major release\n * @param {number} x\n * @param {number} y\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n * @private\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n _drawShape(ctx, shape, sizeMultiplier, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover, values);\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n\n this.initContextForDraw(ctx, values);\n getShape(shape)(ctx, x, y, values.size);\n this.performFill(ctx, values);\n\n if (this.options.icon !== undefined) {\n if (this.options.icon.code !== undefined) {\n ctx.font =\n (selected ? \"bold \" : \"\") +\n this.height / 2 +\n \"px \" +\n (this.options.icon.face || \"FontAwesome\");\n ctx.fillStyle = this.options.icon.color || \"black\";\n ctx.textAlign = \"center\";\n ctx.textBaseline = \"middle\";\n ctx.fillText(this.options.icon.code, x, y);\n }\n }\n\n return {\n drawExternalLabel: () => {\n if (this.options.label !== undefined) {\n // Need to call following here in order to ensure value for\n // `this.labelModule.size.height`.\n this.labelModule.calculateLabelSize(\n ctx,\n selected,\n hover,\n x,\n y,\n \"hanging\"\n );\n const yLabel =\n y + 0.5 * this.height + 0.5 * this.labelModule.size.height;\n this.labelModule.draw(ctx, x, yLabel, selected, hover, \"hanging\");\n }\n\n this.updateBoundingBox(x, y);\n },\n };\n }\n\n /**\n *\n * @param {number} x\n * @param {number} y\n */\n updateBoundingBox(x, y) {\n this.boundingBox.top = y - this.options.size;\n this.boundingBox.left = x - this.options.size;\n this.boundingBox.right = x + this.options.size;\n this.boundingBox.bottom = y + this.options.size;\n\n if (this.options.label !== undefined && this.labelModule.size.width > 0) {\n this.boundingBox.left = Math.min(\n this.boundingBox.left,\n this.labelModule.size.left\n );\n this.boundingBox.right = Math.max(\n this.boundingBox.right,\n this.labelModule.size.left + this.labelModule.size.width\n );\n this.boundingBox.bottom = Math.max(\n this.boundingBox.bottom,\n this.boundingBox.bottom + this.labelModule.size.height\n );\n }\n }\n}\n\nexport default ShapeBase;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A CustomShape Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass CustomShape extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n * @param {Function} ctxRenderer\n \n */\n constructor(options, body, labelModule, ctxRenderer) {\n super(options, body, labelModule, ctxRenderer);\n this.ctxRenderer = ctxRenderer;\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on different layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover, values);\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n\n // Guard right away because someone may just draw in the function itself.\n ctx.save();\n const drawLater = this.ctxRenderer({\n ctx,\n id: this.options.id,\n x,\n y,\n state: { selected, hover },\n style: { ...values },\n label: this.options.label,\n });\n // Render the node shape bellow arrows.\n if (drawLater.drawNode != null) {\n drawLater.drawNode();\n }\n ctx.restore();\n\n if (drawLater.drawExternalLabel) {\n // Guard the external label (above arrows) drawing function.\n const drawExternalLabel = drawLater.drawExternalLabel;\n drawLater.drawExternalLabel = () => {\n ctx.save();\n drawExternalLabel();\n ctx.restore();\n };\n }\n\n if (drawLater.nodeDimensions) {\n this.customSizeWidth = drawLater.nodeDimensions.width;\n this.customSizeHeight = drawLater.nodeDimensions.height;\n }\n\n return drawLater;\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default CustomShape;\n","\"use strict\";\n\nimport NodeBase from \"../util/NodeBase\";\nimport { drawDatabase } from \"../util/shapes\";\n\n/**\n * A Database Node/Cluster shape.\n *\n * @augments NodeBase\n */\nclass Database extends NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n this._setMargins(labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n */\n resize(ctx, selected, hover) {\n if (this.needsRefresh(selected, hover)) {\n const dimensions = this.getDimensionsFromLabel(ctx, selected, hover);\n const size = dimensions.width + this.margin.right + this.margin.left;\n\n this.width = size;\n this.height = size;\n this.radius = this.width / 2;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n */\n draw(ctx, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover);\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n\n this.initContextForDraw(ctx, values);\n drawDatabase(\n ctx,\n x - this.width / 2,\n y - this.height / 2,\n this.width,\n this.height\n );\n this.performFill(ctx, values);\n\n this.updateBoundingBox(x, y, ctx, selected, hover);\n this.labelModule.draw(\n ctx,\n this.left + this.textSize.width / 2 + this.margin.left,\n this.top + this.textSize.height / 2 + this.margin.top,\n selected,\n hover\n );\n }\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Database;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A Diamond Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass Diamond extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n return this._drawShape(ctx, \"diamond\", 4, x, y, selected, hover, values);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Diamond;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A Dot Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass Dot extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n return this._drawShape(ctx, \"circle\", 2, x, y, selected, hover, values);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @returns {number}\n */\n distanceToBorder(ctx) {\n if (ctx) {\n this.resize(ctx);\n }\n return this.options.size;\n }\n}\n\nexport default Dot;\n","\"use strict\";\n\nimport NodeBase from \"../util/NodeBase\";\nimport { drawEllipse } from \"../util/shapes\";\n\n/**\n * Am Ellipse Node/Cluster shape.\n *\n * @augments NodeBase\n */\nclass Ellipse extends NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n */\n resize(ctx, selected = this.selected, hover = this.hover) {\n if (this.needsRefresh(selected, hover)) {\n const dimensions = this.getDimensionsFromLabel(ctx, selected, hover);\n\n this.height = dimensions.height * 2;\n this.width = dimensions.width + dimensions.height;\n this.radius = 0.5 * this.width;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n */\n draw(ctx, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover);\n this.left = x - this.width * 0.5;\n this.top = y - this.height * 0.5;\n\n this.initContextForDraw(ctx, values);\n drawEllipse(ctx, this.left, this.top, this.width, this.height);\n this.performFill(ctx, values);\n\n this.updateBoundingBox(x, y, ctx, selected, hover);\n this.labelModule.draw(ctx, x, y, selected, hover);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n if (ctx) {\n this.resize(ctx);\n }\n const a = this.width * 0.5;\n const b = this.height * 0.5;\n const w = Math.sin(angle) * a;\n const h = Math.cos(angle) * b;\n return (a * b) / Math.sqrt(w * w + h * h);\n }\n}\n\nexport default Ellipse;\n","\"use strict\";\n\nimport NodeBase from \"../util/NodeBase\";\n\n/**\n * An icon replacement for the default Node shape.\n *\n * @augments NodeBase\n */\nclass Icon extends NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n this._setMargins(labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx - Unused.\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n */\n resize(ctx, selected, hover) {\n if (this.needsRefresh(selected, hover)) {\n this.iconSize = {\n width: Number(this.options.icon.size),\n height: Number(this.options.icon.size),\n };\n this.width = this.iconSize.width + this.margin.right + this.margin.left;\n this.height = this.iconSize.height + this.margin.top + this.margin.bottom;\n this.radius = 0.5 * this.width;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover);\n this.options.icon.size = this.options.icon.size || 50;\n\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n this._icon(ctx, x, y, selected, hover, values);\n\n return {\n drawExternalLabel: () => {\n if (this.options.label !== undefined) {\n const iconTextSpacing = 5;\n this.labelModule.draw(\n ctx,\n this.left + this.iconSize.width / 2 + this.margin.left,\n y + this.height / 2 + iconTextSpacing,\n selected\n );\n }\n\n this.updateBoundingBox(x, y);\n },\n };\n }\n\n /**\n *\n * @param {number} x\n * @param {number} y\n */\n updateBoundingBox(x, y) {\n this.boundingBox.top = y - this.options.icon.size * 0.5;\n this.boundingBox.left = x - this.options.icon.size * 0.5;\n this.boundingBox.right = x + this.options.icon.size * 0.5;\n this.boundingBox.bottom = y + this.options.icon.size * 0.5;\n\n if (this.options.label !== undefined && this.labelModule.size.width > 0) {\n const iconTextSpacing = 5;\n this.boundingBox.left = Math.min(\n this.boundingBox.left,\n this.labelModule.size.left\n );\n this.boundingBox.right = Math.max(\n this.boundingBox.right,\n this.labelModule.size.left + this.labelModule.size.width\n );\n this.boundingBox.bottom = Math.max(\n this.boundingBox.bottom,\n this.boundingBox.bottom + this.labelModule.size.height + iconTextSpacing\n );\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover - Unused\n * @param {ArrowOptions} values\n */\n _icon(ctx, x, y, selected, hover, values) {\n const iconSize = Number(this.options.icon.size);\n\n if (this.options.icon.code !== undefined) {\n ctx.font = [\n this.options.icon.weight != null\n ? this.options.icon.weight\n : selected\n ? \"bold\"\n : \"\",\n // If the weight is forced (for example to make Font Awesome 5 work\n // properly) substitute slightly bigger size for bold font face.\n (this.options.icon.weight != null && selected ? 5 : 0) +\n iconSize +\n \"px\",\n this.options.icon.face,\n ].join(\" \");\n\n // draw icon\n ctx.fillStyle = this.options.icon.color || \"black\";\n ctx.textAlign = \"center\";\n ctx.textBaseline = \"middle\";\n\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n ctx.fillText(this.options.icon.code, x, y);\n\n // disable shadows for other elements.\n this.disableShadow(ctx, values);\n } else {\n console.error(\n \"When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.\"\n );\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Icon;\n","\"use strict\";\n\nimport CircleImageBase from \"../util/CircleImageBase\";\nimport { overrideOpacity } from \"vis-util/esnext\";\n\n/**\n * An image-based replacement for the default Node shape.\n *\n * @augments CircleImageBase\n */\nclass Image extends CircleImageBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n * @param {Image} imageObj\n * @param {Image} imageObjAlt\n */\n constructor(options, body, labelModule, imageObj, imageObjAlt) {\n super(options, body, labelModule);\n\n this.setImages(imageObj, imageObjAlt);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx - Unused.\n * @param {boolean} [selected]\n * @param {boolean} [hover]\n */\n resize(ctx, selected = this.selected, hover = this.hover) {\n const imageAbsent =\n this.imageObj.src === undefined ||\n this.imageObj.width === undefined ||\n this.imageObj.height === undefined;\n\n if (imageAbsent) {\n const side = this.options.size * 2;\n this.width = side;\n this.height = side;\n return;\n }\n\n if (this.needsRefresh(selected, hover)) {\n this._resizeImage();\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n */\n draw(ctx, x, y, selected, hover, values) {\n ctx.save();\n this.switchImages(selected);\n this.resize();\n\n let labelX = x,\n labelY = y;\n\n if (this.options.shapeProperties.coordinateOrigin === \"top-left\") {\n this.left = x;\n this.top = y;\n labelX += this.width / 2;\n labelY += this.height / 2;\n } else {\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n }\n\n if (this.options.shapeProperties.useBorderWithImage === true) {\n const neutralborderWidth = this.options.borderWidth;\n const selectionLineWidth =\n this.options.borderWidthSelected || 2 * this.options.borderWidth;\n const borderWidth =\n (selected ? selectionLineWidth : neutralborderWidth) /\n this.body.view.scale;\n ctx.lineWidth = Math.min(this.width, borderWidth);\n\n ctx.beginPath();\n let strokeStyle = selected\n ? this.options.color.highlight.border\n : hover\n ? this.options.color.hover.border\n : this.options.color.border;\n let fillStyle = selected\n ? this.options.color.highlight.background\n : hover\n ? this.options.color.hover.background\n : this.options.color.background;\n\n if (values.opacity !== undefined) {\n strokeStyle = overrideOpacity(strokeStyle, values.opacity);\n fillStyle = overrideOpacity(fillStyle, values.opacity);\n }\n // setup the line properties.\n ctx.strokeStyle = strokeStyle;\n\n // set a fillstyle\n ctx.fillStyle = fillStyle;\n\n // draw a rectangle to form the border around. This rectangle is filled so the opacity of a picture (in future vis releases?) can be used to tint the image\n ctx.rect(\n this.left - 0.5 * ctx.lineWidth,\n this.top - 0.5 * ctx.lineWidth,\n this.width + ctx.lineWidth,\n this.height + ctx.lineWidth\n );\n ctx.fill();\n\n this.performStroke(ctx, values);\n\n ctx.closePath();\n }\n\n this._drawImageAtPosition(ctx, values);\n\n this._drawImageLabel(ctx, labelX, labelY, selected, hover);\n\n this.updateBoundingBox(x, y);\n ctx.restore();\n }\n\n /**\n *\n * @param {number} x\n * @param {number} y\n */\n updateBoundingBox(x, y) {\n this.resize();\n\n if (this.options.shapeProperties.coordinateOrigin === \"top-left\") {\n this.left = x;\n this.top = y;\n } else {\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n }\n\n this.boundingBox.left = this.left;\n this.boundingBox.top = this.top;\n this.boundingBox.bottom = this.top + this.height;\n this.boundingBox.right = this.left + this.width;\n\n if (this.options.label !== undefined && this.labelModule.size.width > 0) {\n this.boundingBox.left = Math.min(\n this.boundingBox.left,\n this.labelModule.size.left\n );\n this.boundingBox.right = Math.max(\n this.boundingBox.right,\n this.labelModule.size.left + this.labelModule.size.width\n );\n this.boundingBox.bottom = Math.max(\n this.boundingBox.bottom,\n this.boundingBox.bottom + this.labelOffset\n );\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Image;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A Square Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass Square extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n return this._drawShape(ctx, \"square\", 2, x, y, selected, hover, values);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Square;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A Hexagon Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass Hexagon extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n return this._drawShape(ctx, \"hexagon\", 4, x, y, selected, hover, values);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Hexagon;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A Star Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass Star extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n return this._drawShape(ctx, \"star\", 4, x, y, selected, hover, values);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Star;\n","\"use strict\";\n\nimport NodeBase from \"../util/NodeBase\";\n\n/**\n * A text-based replacement for the default Node shape.\n *\n * @augments NodeBase\n */\nclass Text extends NodeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n this._setMargins(labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n */\n resize(ctx, selected, hover) {\n if (this.needsRefresh(selected, hover)) {\n this.textSize = this.labelModule.getTextSize(ctx, selected, hover);\n this.width = this.textSize.width + this.margin.right + this.margin.left;\n this.height = this.textSize.height + this.margin.top + this.margin.bottom;\n this.radius = 0.5 * this.width;\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x width\n * @param {number} y height\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n */\n draw(ctx, x, y, selected, hover, values) {\n this.resize(ctx, selected, hover);\n this.left = x - this.width / 2;\n this.top = y - this.height / 2;\n\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n this.labelModule.draw(\n ctx,\n this.left + this.textSize.width / 2 + this.margin.left,\n this.top + this.textSize.height / 2 + this.margin.top,\n selected,\n hover\n );\n\n // disable shadows for other elements.\n this.disableShadow(ctx, values);\n\n this.updateBoundingBox(x, y, ctx, selected, hover);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Text;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A Triangle Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass Triangle extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x\n * @param {number} y\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n return this._drawShape(ctx, \"triangle\", 3, x, y, selected, hover, values);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default Triangle;\n","\"use strict\";\n\nimport ShapeBase from \"../util/ShapeBase\";\n\n/**\n * A downward facing Triangle Node/Cluster shape.\n *\n * @augments ShapeBase\n */\nclass TriangleDown extends ShapeBase {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Label} labelModule\n */\n constructor(options, body, labelModule) {\n super(options, body, labelModule);\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} x\n * @param {number} y\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {ArrowOptions} values\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx, x, y, selected, hover, values) {\n return this._drawShape(\n ctx,\n \"triangleDown\",\n 3,\n x,\n y,\n selected,\n hover,\n values\n );\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle\n * @returns {number}\n */\n distanceToBorder(ctx, angle) {\n return this._distanceToBorder(ctx, angle);\n }\n}\n\nexport default TriangleDown;\n","import {\n VALIDATOR_PRINT_STYLE,\n bridgeObject,\n fillIfDefined,\n mergeOptions,\n overrideOpacity,\n parseColor,\n selectiveNotDeepExtend,\n} from \"vis-util/esnext\";\n\nimport Label from \"./shared/Label\";\nimport { choosify, pointInRect } from \"./shared/ComponentUtil\";\nimport Box from \"./nodes/shapes/Box\";\nimport Circle from \"./nodes/shapes/Circle\";\nimport CircularImage from \"./nodes/shapes/CircularImage\";\nimport CustomShape from \"./nodes/shapes/CustomShape\";\nimport Database from \"./nodes/shapes/Database\";\nimport Diamond from \"./nodes/shapes/Diamond\";\nimport Dot from \"./nodes/shapes/Dot\";\nimport Ellipse from \"./nodes/shapes/Ellipse\";\nimport Icon from \"./nodes/shapes/Icon\";\nimport Image from \"./nodes/shapes/Image\";\nimport Square from \"./nodes/shapes/Square\";\nimport Hexagon from \"./nodes/shapes/Hexagon\";\nimport Star from \"./nodes/shapes/Star\";\nimport Text from \"./nodes/shapes/Text\";\nimport Triangle from \"./nodes/shapes/Triangle\";\nimport TriangleDown from \"./nodes/shapes/TriangleDown\";\n\n/**\n * A node. A node can be connected to other nodes via one or multiple edges.\n */\nclass Node {\n /**\n *\n * @param {object} options An object containing options for the node. All\n * options are optional, except for the id.\n * {number} id Id of the node. Required\n * {string} label Text label for the node\n * {number} x Horizontal position of the node\n * {number} y Vertical position of the node\n * {string} shape Node shape\n * {string} image An image url\n * {string} title A title text, can be HTML\n * {anytype} group A group name or number\n *\n * @param {object} body Shared state of current network instance\n * @param {Network.Images} imagelist A list with images. Only needed when the node has an image\n * @param {Groups} grouplist A list with groups. Needed for retrieving group options\n * @param {object} globalOptions Current global node options; these serve as defaults for the node instance\n * @param {object} defaultOptions Global default options for nodes; note that this is also the prototype\n * for parameter `globalOptions`.\n */\n constructor(\n options,\n body,\n imagelist,\n grouplist,\n globalOptions,\n defaultOptions\n ) {\n this.options = bridgeObject(globalOptions);\n this.globalOptions = globalOptions;\n this.defaultOptions = defaultOptions;\n this.body = body;\n\n this.edges = []; // all edges connected to this node\n\n // set defaults for the options\n this.id = undefined;\n this.imagelist = imagelist;\n this.grouplist = grouplist;\n\n // state options\n this.x = undefined;\n this.y = undefined;\n this.baseSize = this.options.size;\n this.baseFontSize = this.options.font.size;\n this.predefinedPosition = false; // used to check if initial fit should just take the range or approximate\n this.selected = false;\n this.hover = false;\n\n this.labelModule = new Label(\n this.body,\n this.options,\n false /* Not edge label */\n );\n this.setOptions(options);\n }\n\n /**\n * Attach a edge to the node\n *\n * @param {Edge} edge\n */\n attachEdge(edge) {\n if (this.edges.indexOf(edge) === -1) {\n this.edges.push(edge);\n }\n }\n\n /**\n * Detach a edge from the node\n *\n * @param {Edge} edge\n */\n detachEdge(edge) {\n const index = this.edges.indexOf(edge);\n if (index != -1) {\n this.edges.splice(index, 1);\n }\n }\n\n /**\n * Set or overwrite options for the node\n *\n * @param {object} options an object with options\n * @returns {null|boolean}\n */\n setOptions(options) {\n const currentShape = this.options.shape;\n\n if (!options) {\n return; // Note that the return value will be 'undefined'! This is OK.\n }\n\n // Save the color for later.\n // This is necessary in order to prevent local color from being overwritten by group color.\n // TODO: To prevent such workarounds the way options are handled should be rewritten from scratch.\n // This is not the only problem with current options handling.\n if (typeof options.color !== \"undefined\") {\n this._localColor = options.color;\n }\n\n // basic options\n if (options.id !== undefined) {\n this.id = options.id;\n }\n\n if (this.id === undefined) {\n throw new Error(\"Node must have an id\");\n }\n\n Node.checkMass(options, this.id);\n\n // set these options locally\n // clear x and y positions\n if (options.x !== undefined) {\n if (options.x === null) {\n this.x = undefined;\n this.predefinedPosition = false;\n } else {\n this.x = parseInt(options.x);\n this.predefinedPosition = true;\n }\n }\n if (options.y !== undefined) {\n if (options.y === null) {\n this.y = undefined;\n this.predefinedPosition = false;\n } else {\n this.y = parseInt(options.y);\n this.predefinedPosition = true;\n }\n }\n if (options.size !== undefined) {\n this.baseSize = options.size;\n }\n if (options.value !== undefined) {\n options.value = parseFloat(options.value);\n }\n\n // this transforms all shorthands into fully defined options\n Node.parseOptions(\n this.options,\n options,\n true,\n this.globalOptions,\n this.grouplist\n );\n\n const pile = [options, this.options, this.defaultOptions];\n this.chooser = choosify(\"node\", pile);\n\n this._load_images();\n this.updateLabelModule(options);\n\n // Need to set local opacity after `this.updateLabelModule(options);` because `this.updateLabelModule(options);` overrites local opacity with group opacity\n if (options.opacity !== undefined && Node.checkOpacity(options.opacity)) {\n this.options.opacity = options.opacity;\n }\n\n this.updateShape(currentShape);\n\n return options.hidden !== undefined || options.physics !== undefined;\n }\n\n /**\n * Load the images from the options, for the nodes that need them.\n *\n * Images are always loaded, even if they are not used in the current shape.\n * The user may switch to an image shape later on.\n *\n * @private\n */\n _load_images() {\n if (\n this.options.shape === \"circularImage\" ||\n this.options.shape === \"image\"\n ) {\n if (this.options.image === undefined) {\n throw new Error(\n \"Option image must be defined for node type '\" +\n this.options.shape +\n \"'\"\n );\n }\n }\n\n if (this.options.image === undefined) {\n return;\n }\n\n if (this.imagelist === undefined) {\n throw new Error(\"Internal Error: No images provided\");\n }\n\n if (typeof this.options.image === \"string\") {\n this.imageObj = this.imagelist.load(\n this.options.image,\n this.options.brokenImage,\n this.id\n );\n } else {\n if (this.options.image.unselected === undefined) {\n throw new Error(\"No unselected image provided\");\n }\n\n this.imageObj = this.imagelist.load(\n this.options.image.unselected,\n this.options.brokenImage,\n this.id\n );\n\n if (this.options.image.selected !== undefined) {\n this.imageObjAlt = this.imagelist.load(\n this.options.image.selected,\n this.options.brokenImage,\n this.id\n );\n } else {\n this.imageObjAlt = undefined;\n }\n }\n }\n\n /**\n * Check that opacity is only between 0 and 1\n *\n * @param {number} opacity\n * @returns {boolean}\n */\n static checkOpacity(opacity) {\n return 0 <= opacity && opacity <= 1;\n }\n\n /**\n * Check that origin is 'center' or 'top-left'\n *\n * @param {string} origin\n * @returns {boolean}\n */\n static checkCoordinateOrigin(origin) {\n return origin === undefined || origin === \"center\" || origin === \"top-left\";\n }\n\n /**\n * Copy group option values into the node options.\n *\n * The group options override the global node options, so the copy of group options\n * must happen *after* the global node options have been set.\n *\n * This method must also be called also if the global node options have changed and the group options did not.\n *\n * @param {object} parentOptions\n * @param {object} newOptions new values for the options, currently only passed in for check\n * @param {object} groupList\n */\n static updateGroupOptions(parentOptions, newOptions, groupList) {\n if (groupList === undefined) return; // No groups, nothing to do\n\n const group = parentOptions.group;\n\n // paranoia: the selected group is already merged into node options, check.\n if (\n newOptions !== undefined &&\n newOptions.group !== undefined &&\n group !== newOptions.group\n ) {\n throw new Error(\n \"updateGroupOptions: group values in options don't match.\"\n );\n }\n\n const hasGroup =\n typeof group === \"number\" || (typeof group === \"string\" && group != \"\");\n if (!hasGroup) return; // current node has no group, no need to merge\n\n const groupObj = groupList.get(group);\n\n if (groupObj.opacity !== undefined && newOptions.opacity === undefined) {\n if (!Node.checkOpacity(groupObj.opacity)) {\n console.error(\n \"Invalid option for node opacity. Value must be between 0 and 1, found: \" +\n groupObj.opacity\n );\n groupObj.opacity = undefined;\n }\n }\n\n // Skip any new option to avoid them being overridden by the group options.\n const skipProperties = Object.getOwnPropertyNames(newOptions).filter(\n (p) => newOptions[p] != null\n );\n // Always skip merging group font options into parent; these are required to be distinct for labels\n skipProperties.push(\"font\");\n selectiveNotDeepExtend(skipProperties, parentOptions, groupObj);\n\n // the color object needs to be completely defined.\n // Since groups can partially overwrite the colors, we parse it again, just in case.\n parentOptions.color = parseColor(parentOptions.color);\n }\n\n /**\n * This process all possible shorthands in the new options and makes sure that the parentOptions are fully defined.\n * Static so it can also be used by the handler.\n *\n * @param {object} parentOptions\n * @param {object} newOptions\n * @param {boolean} [allowDeletion=false]\n * @param {object} [globalOptions={}]\n * @param {object} [groupList]\n * @static\n */\n static parseOptions(\n parentOptions,\n newOptions,\n allowDeletion = false,\n globalOptions = {},\n groupList\n ) {\n const fields = [\"color\", \"fixed\", \"shadow\"];\n selectiveNotDeepExtend(fields, parentOptions, newOptions, allowDeletion);\n\n Node.checkMass(newOptions);\n\n if (parentOptions.opacity !== undefined) {\n if (!Node.checkOpacity(parentOptions.opacity)) {\n console.error(\n \"Invalid option for node opacity. Value must be between 0 and 1, found: \" +\n parentOptions.opacity\n );\n parentOptions.opacity = undefined;\n }\n }\n\n if (newOptions.opacity !== undefined) {\n if (!Node.checkOpacity(newOptions.opacity)) {\n console.error(\n \"Invalid option for node opacity. Value must be between 0 and 1, found: \" +\n newOptions.opacity\n );\n newOptions.opacity = undefined;\n }\n }\n\n if (\n newOptions.shapeProperties &&\n !Node.checkCoordinateOrigin(newOptions.shapeProperties.coordinateOrigin)\n ) {\n console.error(\n \"Invalid option for node coordinateOrigin, found: \" +\n newOptions.shapeProperties.coordinateOrigin\n );\n }\n\n // merge the shadow options into the parent.\n mergeOptions(parentOptions, newOptions, \"shadow\", globalOptions);\n\n // individual shape newOptions\n if (newOptions.color !== undefined && newOptions.color !== null) {\n const parsedColor = parseColor(newOptions.color);\n fillIfDefined(parentOptions.color, parsedColor);\n } else if (allowDeletion === true && newOptions.color === null) {\n parentOptions.color = bridgeObject(globalOptions.color); // set the object back to the global options\n }\n\n // handle the fixed options\n if (newOptions.fixed !== undefined && newOptions.fixed !== null) {\n if (typeof newOptions.fixed === \"boolean\") {\n parentOptions.fixed.x = newOptions.fixed;\n parentOptions.fixed.y = newOptions.fixed;\n } else {\n if (\n newOptions.fixed.x !== undefined &&\n typeof newOptions.fixed.x === \"boolean\"\n ) {\n parentOptions.fixed.x = newOptions.fixed.x;\n }\n if (\n newOptions.fixed.y !== undefined &&\n typeof newOptions.fixed.y === \"boolean\"\n ) {\n parentOptions.fixed.y = newOptions.fixed.y;\n }\n }\n }\n\n if (allowDeletion === true && newOptions.font === null) {\n parentOptions.font = bridgeObject(globalOptions.font); // set the object back to the global options\n }\n\n Node.updateGroupOptions(parentOptions, newOptions, groupList);\n\n // handle the scaling options, specifically the label part\n if (newOptions.scaling !== undefined) {\n mergeOptions(\n parentOptions.scaling,\n newOptions.scaling,\n \"label\",\n globalOptions.scaling\n );\n }\n }\n\n /**\n *\n * @returns {{color: *, borderWidth: *, borderColor: *, size: *, borderDashes: (boolean|Array|allOptions.nodes.shapeProperties.borderDashes|{boolean, array}), borderRadius: (number|allOptions.nodes.shapeProperties.borderRadius|{number}|Array), shadow: *, shadowColor: *, shadowSize: *, shadowX: *, shadowY: *}}\n */\n getFormattingValues() {\n const values = {\n color: this.options.color.background,\n opacity: this.options.opacity,\n borderWidth: this.options.borderWidth,\n borderColor: this.options.color.border,\n size: this.options.size,\n borderDashes: this.options.shapeProperties.borderDashes,\n borderRadius: this.options.shapeProperties.borderRadius,\n shadow: this.options.shadow.enabled,\n shadowColor: this.options.shadow.color,\n shadowSize: this.options.shadow.size,\n shadowX: this.options.shadow.x,\n shadowY: this.options.shadow.y,\n };\n if (this.selected || this.hover) {\n if (this.chooser === true) {\n if (this.selected) {\n if (this.options.borderWidthSelected != null) {\n values.borderWidth = this.options.borderWidthSelected;\n } else {\n values.borderWidth *= 2;\n }\n values.color = this.options.color.highlight.background;\n values.borderColor = this.options.color.highlight.border;\n values.shadow = this.options.shadow.enabled;\n } else if (this.hover) {\n values.color = this.options.color.hover.background;\n values.borderColor = this.options.color.hover.border;\n values.shadow = this.options.shadow.enabled;\n }\n } else if (typeof this.chooser === \"function\") {\n this.chooser(values, this.options.id, this.selected, this.hover);\n if (values.shadow === false) {\n if (\n values.shadowColor !== this.options.shadow.color ||\n values.shadowSize !== this.options.shadow.size ||\n values.shadowX !== this.options.shadow.x ||\n values.shadowY !== this.options.shadow.y\n ) {\n values.shadow = true;\n }\n }\n }\n } else {\n values.shadow = this.options.shadow.enabled;\n }\n if (this.options.opacity !== undefined) {\n const opacity = this.options.opacity;\n values.borderColor = overrideOpacity(values.borderColor, opacity);\n values.color = overrideOpacity(values.color, opacity);\n values.shadowColor = overrideOpacity(values.shadowColor, opacity);\n }\n return values;\n }\n\n /**\n *\n * @param {object} options\n */\n updateLabelModule(options) {\n if (this.options.label === undefined || this.options.label === null) {\n this.options.label = \"\";\n }\n\n Node.updateGroupOptions(\n this.options,\n {\n ...options,\n color: (options && options.color) || this._localColor || undefined,\n },\n this.grouplist\n );\n\n //\n // Note:The prototype chain for this.options is:\n //\n // this.options -> NodesHandler.options -> NodesHandler.defaultOptions\n // (also: this.globalOptions)\n //\n // Note that the prototypes are mentioned explicitly in the pile list below;\n // WE DON'T WANT THE ORDER OF THE PROTOTYPES!!!! At least, not for font handling of labels.\n // This is a good indication that the prototype usage of options is deficient.\n //\n const currentGroup = this.grouplist.get(this.options.group, false);\n const pile = [\n options, // new options\n this.options, // current node options, see comment above for prototype\n currentGroup, // group options, if any\n this.globalOptions, // Currently set global node options\n this.defaultOptions, // Default global node options\n ];\n this.labelModule.update(this.options, pile);\n\n if (this.labelModule.baseSize !== undefined) {\n this.baseFontSize = this.labelModule.baseSize;\n }\n }\n\n /**\n *\n * @param {string} currentShape\n */\n updateShape(currentShape) {\n if (currentShape === this.options.shape && this.shape) {\n this.shape.setOptions(this.options, this.imageObj, this.imageObjAlt);\n } else {\n // choose draw method depending on the shape\n switch (this.options.shape) {\n case \"box\":\n this.shape = new Box(this.options, this.body, this.labelModule);\n break;\n case \"circle\":\n this.shape = new Circle(this.options, this.body, this.labelModule);\n break;\n case \"circularImage\":\n this.shape = new CircularImage(\n this.options,\n this.body,\n this.labelModule,\n this.imageObj,\n this.imageObjAlt\n );\n break;\n case \"custom\":\n this.shape = new CustomShape(\n this.options,\n this.body,\n this.labelModule,\n this.options.ctxRenderer\n );\n break;\n case \"database\":\n this.shape = new Database(this.options, this.body, this.labelModule);\n break;\n case \"diamond\":\n this.shape = new Diamond(this.options, this.body, this.labelModule);\n break;\n case \"dot\":\n this.shape = new Dot(this.options, this.body, this.labelModule);\n break;\n case \"ellipse\":\n this.shape = new Ellipse(this.options, this.body, this.labelModule);\n break;\n case \"icon\":\n this.shape = new Icon(this.options, this.body, this.labelModule);\n break;\n case \"image\":\n this.shape = new Image(\n this.options,\n this.body,\n this.labelModule,\n this.imageObj,\n this.imageObjAlt\n );\n break;\n case \"square\":\n this.shape = new Square(this.options, this.body, this.labelModule);\n break;\n case \"hexagon\":\n this.shape = new Hexagon(this.options, this.body, this.labelModule);\n break;\n case \"star\":\n this.shape = new Star(this.options, this.body, this.labelModule);\n break;\n case \"text\":\n this.shape = new Text(this.options, this.body, this.labelModule);\n break;\n case \"triangle\":\n this.shape = new Triangle(this.options, this.body, this.labelModule);\n break;\n case \"triangleDown\":\n this.shape = new TriangleDown(\n this.options,\n this.body,\n this.labelModule\n );\n break;\n default:\n this.shape = new Ellipse(this.options, this.body, this.labelModule);\n break;\n }\n }\n this.needsRefresh();\n }\n\n /**\n * select this node\n */\n select() {\n this.selected = true;\n this.needsRefresh();\n }\n\n /**\n * unselect this node\n */\n unselect() {\n this.selected = false;\n this.needsRefresh();\n }\n\n /**\n * Reset the calculated size of the node, forces it to recalculate its size\n */\n needsRefresh() {\n this.shape.refreshNeeded = true;\n }\n\n /**\n * get the title of this node.\n *\n * @returns {string} title The title of the node, or undefined when no title\n * has been set.\n */\n getTitle() {\n return this.options.title;\n }\n\n /**\n * Calculate the distance to the border of the Node\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {number} angle Angle in radians\n * @returns {number} distance Distance to the border in pixels\n */\n distanceToBorder(ctx, angle) {\n return this.shape.distanceToBorder(ctx, angle);\n }\n\n /**\n * Check if this node has a fixed x and y position\n *\n * @returns {boolean} true if fixed, false if not\n */\n isFixed() {\n return this.options.fixed.x && this.options.fixed.y;\n }\n\n /**\n * check if this node is selecte\n *\n * @returns {boolean} selected True if node is selected, else false\n */\n isSelected() {\n return this.selected;\n }\n\n /**\n * Retrieve the value of the node. Can be undefined\n *\n * @returns {number} value\n */\n getValue() {\n return this.options.value;\n }\n\n /**\n * Get the current dimensions of the label\n *\n * @returns {rect}\n */\n getLabelSize() {\n return this.labelModule.size();\n }\n\n /**\n * Adjust the value range of the node. The node will adjust it's size\n * based on its value.\n *\n * @param {number} min\n * @param {number} max\n * @param {number} total\n */\n setValueRange(min, max, total) {\n if (this.options.value !== undefined) {\n const scale = this.options.scaling.customScalingFunction(\n min,\n max,\n total,\n this.options.value\n );\n const sizeDiff = this.options.scaling.max - this.options.scaling.min;\n if (this.options.scaling.label.enabled === true) {\n const fontDiff =\n this.options.scaling.label.max - this.options.scaling.label.min;\n this.options.font.size =\n this.options.scaling.label.min + scale * fontDiff;\n }\n this.options.size = this.options.scaling.min + scale * sizeDiff;\n } else {\n this.options.size = this.baseSize;\n this.options.font.size = this.baseFontSize;\n }\n\n this.updateLabelModule();\n }\n\n /**\n * Draw this node in the given canvas\n * The 2d context of a HTML canvas can be retrieved by canvas.getContext(\"2d\");\n *\n * @param {CanvasRenderingContext2D} ctx\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n draw(ctx) {\n const values = this.getFormattingValues();\n return (\n this.shape.draw(ctx, this.x, this.y, this.selected, this.hover, values) ||\n {}\n );\n }\n\n /**\n * Update the bounding box of the shape\n *\n * @param {CanvasRenderingContext2D} ctx\n */\n updateBoundingBox(ctx) {\n this.shape.updateBoundingBox(this.x, this.y, ctx);\n }\n\n /**\n * Recalculate the size of this node in the given canvas\n * The 2d context of a HTML canvas can be retrieved by canvas.getContext(\"2d\");\n *\n * @param {CanvasRenderingContext2D} ctx\n */\n resize(ctx) {\n const values = this.getFormattingValues();\n this.shape.resize(ctx, this.selected, this.hover, values);\n }\n\n /**\n * Determine all visual elements of this node instance, in which the given\n * point falls within the bounding shape.\n *\n * @param {point} point\n * @returns {Array.<nodeClickItem|nodeLabelClickItem>} list with the items which are on the point\n */\n getItemsOnPoint(point) {\n const ret = [];\n\n if (this.labelModule.visible()) {\n if (pointInRect(this.labelModule.getSize(), point)) {\n ret.push({ nodeId: this.id, labelId: 0 });\n }\n }\n\n if (pointInRect(this.shape.boundingBox, point)) {\n ret.push({ nodeId: this.id });\n }\n\n return ret;\n }\n\n /**\n * Check if this object is overlapping with the provided object\n *\n * @param {object} obj an object with parameters left, top, right, bottom\n * @returns {boolean} True if location is located on node\n */\n isOverlappingWith(obj) {\n return (\n this.shape.left < obj.right &&\n this.shape.left + this.shape.width > obj.left &&\n this.shape.top < obj.bottom &&\n this.shape.top + this.shape.height > obj.top\n );\n }\n\n /**\n * Check if this object is overlapping with the provided object\n *\n * @param {object} obj an object with parameters left, top, right, bottom\n * @returns {boolean} True if location is located on node\n */\n isBoundingBoxOverlappingWith(obj) {\n return (\n this.shape.boundingBox.left < obj.right &&\n this.shape.boundingBox.right > obj.left &&\n this.shape.boundingBox.top < obj.bottom &&\n this.shape.boundingBox.bottom > obj.top\n );\n }\n\n /**\n * Check valid values for mass\n *\n * The mass may not be negative or zero. If it is, reset to 1\n *\n * @param {object} options\n * @param {Node.id} id\n * @static\n */\n static checkMass(options, id) {\n if (options.mass !== undefined && options.mass <= 0) {\n let strId = \"\";\n if (id !== undefined) {\n strId = \" in node id: \" + id;\n }\n console.error(\n \"%cNegative or zero mass disallowed\" + strId + \", setting mass to 1.\",\n VALIDATOR_PRINT_STYLE\n );\n options.mass = 1;\n }\n }\n}\n\nexport default Node;\n","import { bridgeObject, forEach } from \"vis-util/esnext\";\nimport { DataSet, isDataViewLike } from \"vis-data/esnext\";\nimport Node from \"./components/Node\";\n\n/**\n * Handler for Nodes\n */\nclass NodesHandler {\n /**\n * @param {object} body\n * @param {Images} images\n * @param {Array.<Group>} groups\n * @param {LayoutEngine} layoutEngine\n */\n constructor(body, images, groups, layoutEngine) {\n this.body = body;\n this.images = images;\n this.groups = groups;\n this.layoutEngine = layoutEngine;\n\n // create the node API in the body container\n this.body.functions.createNode = this.create.bind(this);\n\n this.nodesListeners = {\n add: (event, params) => {\n this.add(params.items);\n },\n update: (event, params) => {\n this.update(params.items, params.data, params.oldData);\n },\n remove: (event, params) => {\n this.remove(params.items);\n },\n };\n\n this.defaultOptions = {\n borderWidth: 1,\n borderWidthSelected: undefined,\n brokenImage: undefined,\n color: {\n border: \"#2B7CE9\",\n background: \"#97C2FC\",\n highlight: {\n border: \"#2B7CE9\",\n background: \"#D2E5FF\",\n },\n hover: {\n border: \"#2B7CE9\",\n background: \"#D2E5FF\",\n },\n },\n opacity: undefined, // number between 0 and 1\n fixed: {\n x: false,\n y: false,\n },\n font: {\n color: \"#343434\",\n size: 14, // px\n face: \"arial\",\n background: \"none\",\n strokeWidth: 0, // px\n strokeColor: \"#ffffff\",\n align: \"center\",\n vadjust: 0,\n multi: false,\n bold: {\n mod: \"bold\",\n },\n boldital: {\n mod: \"bold italic\",\n },\n ital: {\n mod: \"italic\",\n },\n mono: {\n mod: \"\",\n size: 15, // px\n face: \"monospace\",\n vadjust: 2,\n },\n },\n group: undefined,\n hidden: false,\n icon: {\n face: \"FontAwesome\", //'FontAwesome',\n code: undefined, //'\\uf007',\n size: 50, //50,\n color: \"#2B7CE9\", //'#aa00ff'\n },\n image: undefined, // --> URL\n imagePadding: {\n // only for image shape\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n },\n label: undefined,\n labelHighlightBold: true,\n level: undefined,\n margin: {\n top: 5,\n right: 5,\n bottom: 5,\n left: 5,\n },\n mass: 1,\n physics: true,\n scaling: {\n min: 10,\n max: 30,\n label: {\n enabled: false,\n min: 14,\n max: 30,\n maxVisible: 30,\n drawThreshold: 5,\n },\n customScalingFunction: function (min, max, total, value) {\n if (max === min) {\n return 0.5;\n } else {\n const scale = 1 / (max - min);\n return Math.max(0, (value - min) * scale);\n }\n },\n },\n shadow: {\n enabled: false,\n color: \"rgba(0,0,0,0.5)\",\n size: 10,\n x: 5,\n y: 5,\n },\n shape: \"ellipse\",\n shapeProperties: {\n borderDashes: false, // only for borders\n borderRadius: 6, // only for box shape\n interpolation: true, // only for image and circularImage shapes\n useImageSize: false, // only for image and circularImage shapes\n useBorderWithImage: false, // only for image shape\n coordinateOrigin: \"center\", // only for image and circularImage shapes\n },\n size: 25,\n title: undefined,\n value: undefined,\n x: undefined,\n y: undefined,\n };\n\n // Protect from idiocy\n if (this.defaultOptions.mass <= 0) {\n throw \"Internal error: mass in defaultOptions of NodesHandler may not be zero or negative\";\n }\n\n this.options = bridgeObject(this.defaultOptions);\n\n this.bindEventListeners();\n }\n\n /**\n * Binds event listeners\n */\n bindEventListeners() {\n // refresh the nodes. Used when reverting from hierarchical layout\n this.body.emitter.on(\"refreshNodes\", this.refresh.bind(this));\n this.body.emitter.on(\"refresh\", this.refresh.bind(this));\n this.body.emitter.on(\"destroy\", () => {\n forEach(this.nodesListeners, (callback, event) => {\n if (this.body.data.nodes) this.body.data.nodes.off(event, callback);\n });\n delete this.body.functions.createNode;\n delete this.nodesListeners.add;\n delete this.nodesListeners.update;\n delete this.nodesListeners.remove;\n delete this.nodesListeners;\n });\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n if (options !== undefined) {\n Node.parseOptions(this.options, options);\n\n // Need to set opacity here because Node.parseOptions is also used for groups,\n // if you set opacity in Node.parseOptions it overwrites group opacity.\n if (options.opacity !== undefined) {\n if (\n Number.isNaN(options.opacity) ||\n !Number.isFinite(options.opacity) ||\n options.opacity < 0 ||\n options.opacity > 1\n ) {\n console.error(\n \"Invalid option for node opacity. Value must be between 0 and 1, found: \" +\n options.opacity\n );\n } else {\n this.options.opacity = options.opacity;\n }\n }\n\n // update the shape in all nodes\n if (options.shape !== undefined) {\n for (const nodeId in this.body.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId)) {\n this.body.nodes[nodeId].updateShape();\n }\n }\n }\n\n // Update the labels of nodes if any relevant options changed.\n if (\n typeof options.font !== \"undefined\" ||\n typeof options.widthConstraint !== \"undefined\" ||\n typeof options.heightConstraint !== \"undefined\"\n ) {\n for (const nodeId of Object.keys(this.body.nodes)) {\n this.body.nodes[nodeId].updateLabelModule();\n this.body.nodes[nodeId].needsRefresh();\n }\n }\n\n // update the shape size in all nodes\n if (options.size !== undefined) {\n for (const nodeId in this.body.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId)) {\n this.body.nodes[nodeId].needsRefresh();\n }\n }\n }\n\n // update the state of the variables if needed\n if (options.hidden !== undefined || options.physics !== undefined) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n }\n\n /**\n * Set a data set with nodes for the network\n *\n * @param {Array | DataSet | DataView} nodes The data containing the nodes.\n * @param {boolean} [doNotEmit=false] - Suppress data changed event.\n * @private\n */\n setData(nodes, doNotEmit = false) {\n const oldNodesData = this.body.data.nodes;\n\n if (isDataViewLike(\"id\", nodes)) {\n this.body.data.nodes = nodes;\n } else if (Array.isArray(nodes)) {\n this.body.data.nodes = new DataSet();\n this.body.data.nodes.add(nodes);\n } else if (!nodes) {\n this.body.data.nodes = new DataSet();\n } else {\n throw new TypeError(\"Array or DataSet expected\");\n }\n\n if (oldNodesData) {\n // unsubscribe from old dataset\n forEach(this.nodesListeners, function (callback, event) {\n oldNodesData.off(event, callback);\n });\n }\n\n // remove drawn nodes\n this.body.nodes = {};\n\n if (this.body.data.nodes) {\n // subscribe to new dataset\n const me = this;\n forEach(this.nodesListeners, function (callback, event) {\n me.body.data.nodes.on(event, callback);\n });\n\n // draw all new nodes\n const ids = this.body.data.nodes.getIds();\n this.add(ids, true);\n }\n\n if (doNotEmit === false) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n * Add nodes\n *\n * @param {number[] | string[]} ids\n * @param {boolean} [doNotEmit=false]\n * @private\n */\n add(ids, doNotEmit = false) {\n let id;\n const newNodes = [];\n for (let i = 0; i < ids.length; i++) {\n id = ids[i];\n const properties = this.body.data.nodes.get(id);\n const node = this.create(properties);\n newNodes.push(node);\n this.body.nodes[id] = node; // note: this may replace an existing node\n }\n\n this.layoutEngine.positionInitially(newNodes);\n\n if (doNotEmit === false) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n * Update existing nodes, or create them when not yet existing\n *\n * @param {number[] | string[]} ids id's of changed nodes\n * @param {Array} changedData array with changed data\n * @param {Array|undefined} oldData optional; array with previous data\n * @private\n */\n update(ids, changedData, oldData) {\n const nodes = this.body.nodes;\n let dataChanged = false;\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i];\n let node = nodes[id];\n const data = changedData[i];\n if (node !== undefined) {\n // update node\n if (node.setOptions(data)) {\n dataChanged = true;\n }\n } else {\n dataChanged = true;\n // create node\n node = this.create(data);\n nodes[id] = node;\n }\n }\n\n if (!dataChanged && oldData !== undefined) {\n // Check for any changes which should trigger a layout recalculation\n // For now, this is just 'level' for hierarchical layout\n // Assumption: old and new data arranged in same order; at time of writing, this holds.\n dataChanged = changedData.some(function (newValue, index) {\n const oldValue = oldData[index];\n return oldValue && oldValue.level !== newValue.level;\n });\n }\n\n if (dataChanged === true) {\n this.body.emitter.emit(\"_dataChanged\");\n } else {\n this.body.emitter.emit(\"_dataUpdated\");\n }\n }\n\n /**\n * Remove existing nodes. If nodes do not exist, the method will just ignore it.\n *\n * @param {number[] | string[]} ids\n * @private\n */\n remove(ids) {\n const nodes = this.body.nodes;\n\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i];\n delete nodes[id];\n }\n\n this.body.emitter.emit(\"_dataChanged\");\n }\n\n /**\n * create a node\n *\n * @param {object} properties\n * @param {class} [constructorClass=Node.default]\n * @returns {*}\n */\n create(properties, constructorClass = Node) {\n return new constructorClass(\n properties,\n this.body,\n this.images,\n this.groups,\n this.options,\n this.defaultOptions\n );\n }\n\n /**\n *\n * @param {boolean} [clearPositions=false]\n */\n refresh(clearPositions = false) {\n forEach(this.body.nodes, (node, nodeId) => {\n const data = this.body.data.nodes.get(nodeId);\n if (data !== undefined) {\n if (clearPositions === true) {\n node.setOptions({ x: null, y: null });\n }\n node.setOptions({ fixed: false });\n node.setOptions(data);\n }\n });\n }\n\n /**\n * Returns the positions of the nodes.\n *\n * @param {Array.<Node.id> | string} [ids] --> optional, can be array of nodeIds, can be string\n * @returns {{}}\n */\n getPositions(ids) {\n const dataArray = {};\n if (ids !== undefined) {\n if (Array.isArray(ids) === true) {\n for (let i = 0; i < ids.length; i++) {\n if (this.body.nodes[ids[i]] !== undefined) {\n const node = this.body.nodes[ids[i]];\n dataArray[ids[i]] = {\n x: Math.round(node.x),\n y: Math.round(node.y),\n };\n }\n }\n } else {\n if (this.body.nodes[ids] !== undefined) {\n const node = this.body.nodes[ids];\n dataArray[ids] = { x: Math.round(node.x), y: Math.round(node.y) };\n }\n }\n } else {\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n const node = this.body.nodes[this.body.nodeIndices[i]];\n dataArray[this.body.nodeIndices[i]] = {\n x: Math.round(node.x),\n y: Math.round(node.y),\n };\n }\n }\n return dataArray;\n }\n\n /**\n * Retrieves the x y position of a specific id.\n *\n * @param {string} id The id to retrieve.\n *\n * @throws {TypeError} If no id is included.\n * @throws {ReferenceError} If an invalid id is provided.\n *\n * @returns {{ x: number, y: number }} Returns X, Y canvas position of the node with given id.\n */\n getPosition(id) {\n if (id == undefined) {\n throw new TypeError(\"No id was specified for getPosition method.\");\n } else if (this.body.nodes[id] == undefined) {\n throw new ReferenceError(\n `NodeId provided for getPosition does not exist. Provided: ${id}`\n );\n } else {\n return {\n x: Math.round(this.body.nodes[id].x),\n y: Math.round(this.body.nodes[id].y),\n };\n }\n }\n\n /**\n * Load the XY positions of the nodes into the dataset.\n */\n storePositions() {\n // todo: add support for clusters and hierarchical.\n const dataArray = [];\n const dataset = this.body.data.nodes.getDataSet();\n\n for (const dsNode of dataset.get()) {\n const id = dsNode.id;\n const bodyNode = this.body.nodes[id];\n const x = Math.round(bodyNode.x);\n const y = Math.round(bodyNode.y);\n\n if (dsNode.x !== x || dsNode.y !== y) {\n dataArray.push({ id, x, y });\n }\n }\n\n dataset.update(dataArray);\n }\n\n /**\n * get the bounding box of a node.\n *\n * @param {Node.id} nodeId\n * @returns {j|*}\n */\n getBoundingBox(nodeId) {\n if (this.body.nodes[nodeId] !== undefined) {\n return this.body.nodes[nodeId].shape.boundingBox;\n }\n }\n\n /**\n * Get the Ids of nodes connected to this node.\n *\n * @param {Node.id} nodeId\n * @param {'to'|'from'|undefined} direction values 'from' and 'to' select respectively parent and child nodes only.\n * Any other value returns both parent and child nodes.\n * @returns {Array}\n */\n getConnectedNodes(nodeId, direction) {\n const nodeList = [];\n if (this.body.nodes[nodeId] !== undefined) {\n const node = this.body.nodes[nodeId];\n const nodeObj = {}; // used to quickly check if node already exists\n for (let i = 0; i < node.edges.length; i++) {\n const edge = node.edges[i];\n if (direction !== \"to\" && edge.toId == node.id) {\n // these are double equals since ids can be numeric or string\n if (nodeObj[edge.fromId] === undefined) {\n nodeList.push(edge.fromId);\n nodeObj[edge.fromId] = true;\n }\n } else if (direction !== \"from\" && edge.fromId == node.id) {\n // these are double equals since ids can be numeric or string\n if (nodeObj[edge.toId] === undefined) {\n nodeList.push(edge.toId);\n nodeObj[edge.toId] = true;\n }\n }\n }\n }\n return nodeList;\n }\n\n /**\n * Get the ids of the edges connected to this node.\n *\n * @param {Node.id} nodeId\n * @returns {*}\n */\n getConnectedEdges(nodeId) {\n const edgeList = [];\n if (this.body.nodes[nodeId] !== undefined) {\n const node = this.body.nodes[nodeId];\n for (let i = 0; i < node.edges.length; i++) {\n edgeList.push(node.edges[i].id);\n }\n } else {\n console.error(\n \"NodeId provided for getConnectedEdges does not exist. Provided: \",\n nodeId\n );\n }\n return edgeList;\n }\n\n /**\n * Move a node.\n *\n * @param {Node.id} nodeId\n * @param {number} x\n * @param {number} y\n */\n moveNode(nodeId, x, y) {\n if (this.body.nodes[nodeId] !== undefined) {\n this.body.nodes[nodeId].x = Number(x);\n this.body.nodes[nodeId].y = Number(y);\n setTimeout(() => {\n this.body.emitter.emit(\"startSimulation\");\n }, 0);\n } else {\n console.error(\n \"Node id supplied to moveNode does not exist. Provided: \",\n nodeId\n );\n }\n }\n}\n\nexport default NodesHandler;\n","/** ============================================================================\n * Location of all the endpoint drawing routines.\n *\n * Every endpoint has its own drawing routine, which contains an endpoint definition.\n *\n * The endpoint definitions must have the following properies:\n *\n * - (0,0) is the connection point to the node it attaches to\n * - The endpoints are orientated to the positive x-direction\n * - The length of the endpoint is at most 1\n *\n * As long as the endpoint classes remain simple and not too numerous, they will\n * be contained within this module.\n * All classes here except `EndPoints` should be considered as private to this module.\n *\n * -----------------------------------------------------------------------------\n * ### Further Actions\n *\n * After adding a new endpoint here, you also need to do the following things:\n *\n * - Add the new endpoint name to `network/options.js` in array `endPoints`.\n * - Add the new endpoint name to the documentation.\n * Scan for 'arrows.to.type` and add it to the description.\n * - Add the endpoint to the examples. At the very least, add it to example\n * `edgeStyles/arrowTypes`.\n * ============================================================================= */\n\nimport { ArrowData, Point } from \"./types\";\nimport { drawCircle } from \"./shapes\";\n\n/**\n * Common methods for endpoints\n *\n * @class\n */\nclass EndPoint {\n /**\n * Apply transformation on points for display.\n *\n * The following is done:\n * - rotate by the specified angle\n * - multiply the (normalized) coordinates by the passed length\n * - offset by the target coordinates\n *\n * @param points - The point(s) to be transformed.\n * @param arrowData - The data determining the result of the transformation.\n */\n public static transform(points: Point | Point[], arrowData: ArrowData): void {\n if (!Array.isArray(points)) {\n points = [points];\n }\n\n const x = arrowData.point.x;\n const y = arrowData.point.y;\n const angle = arrowData.angle;\n const length = arrowData.length;\n\n for (let i = 0; i < points.length; ++i) {\n const p = points[i];\n const xt = p.x * Math.cos(angle) - p.y * Math.sin(angle);\n const yt = p.x * Math.sin(angle) + p.y * Math.cos(angle);\n\n p.x = x + length * xt;\n p.y = y + length * yt;\n }\n }\n\n /**\n * Draw a closed path using the given real coordinates.\n *\n * @param ctx - The path will be rendered into this context.\n * @param points - The points of the path.\n */\n public static drawPath(ctx: CanvasRenderingContext2D, points: Point[]): void {\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; ++i) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.closePath();\n }\n}\n\n/**\n * Drawing methods for the arrow endpoint.\n */\nclass Image extends EndPoint {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns False as there is no way to fill an image.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): false {\n if (arrowData.image) {\n ctx.save();\n\n ctx.translate(arrowData.point.x, arrowData.point.y);\n ctx.rotate(Math.PI / 2 + arrowData.angle);\n\n const width =\n arrowData.imageWidth != null\n ? arrowData.imageWidth\n : arrowData.image.width;\n const height =\n arrowData.imageHeight != null\n ? arrowData.imageHeight\n : arrowData.image.height;\n\n arrowData.image.drawImageAtPosition(\n ctx,\n 1, // scale\n -width / 2, // x\n 0, // y\n width,\n height\n );\n\n ctx.restore();\n }\n\n return false;\n }\n}\n\n/**\n * Drawing methods for the arrow endpoint.\n */\nclass Arrow extends EndPoint {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n // Normalized points of closed path, in the order that they should be drawn.\n // (0, 0) is the attachment point, and the point around which should be rotated\n const points = [\n { x: 0, y: 0 },\n { x: -1, y: 0.3 },\n { x: -0.9, y: 0 },\n { x: -1, y: -0.3 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the crow endpoint.\n */\nclass Crow {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n // Normalized points of closed path, in the order that they should be drawn.\n // (0, 0) is the attachment point, and the point around which should be rotated\n const points = [\n { x: -1, y: 0 },\n { x: 0, y: 0.3 },\n { x: -0.4, y: 0 },\n { x: 0, y: -0.3 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the curve endpoint.\n */\nclass Curve {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n // Normalized points of closed path, in the order that they should be drawn.\n // (0, 0) is the attachment point, and the point around which should be rotated\n const point = { x: -0.4, y: 0 };\n EndPoint.transform(point, arrowData);\n\n // Update endpoint style for drawing transparent arc.\n ctx.strokeStyle = ctx.fillStyle;\n ctx.fillStyle = \"rgba(0, 0, 0, 0)\";\n\n // Define curve endpoint as semicircle.\n const pi = Math.PI;\n const startAngle = arrowData.angle - pi / 2;\n const endAngle = arrowData.angle + pi / 2;\n ctx.beginPath();\n ctx.arc(\n point.x,\n point.y,\n arrowData.length * 0.4,\n startAngle,\n endAngle,\n false\n );\n ctx.stroke();\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the inverted curve endpoint.\n */\nclass InvertedCurve {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n // Normalized points of closed path, in the order that they should be drawn.\n // (0, 0) is the attachment point, and the point around which should be rotated\n const point = { x: -0.3, y: 0 };\n EndPoint.transform(point, arrowData);\n\n // Update endpoint style for drawing transparent arc.\n ctx.strokeStyle = ctx.fillStyle;\n ctx.fillStyle = \"rgba(0, 0, 0, 0)\";\n\n // Define inverted curve endpoint as semicircle.\n const pi = Math.PI;\n const startAngle = arrowData.angle + pi / 2;\n const endAngle = arrowData.angle + (3 * pi) / 2;\n ctx.beginPath();\n ctx.arc(\n point.x,\n point.y,\n arrowData.length * 0.4,\n startAngle,\n endAngle,\n false\n );\n ctx.stroke();\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the trinagle endpoint.\n */\nclass Triangle {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n // Normalized points of closed path, in the order that they should be drawn.\n // (0, 0) is the attachment point, and the point around which should be rotated\n const points = [\n { x: 0.02, y: 0 },\n { x: -1, y: 0.3 },\n { x: -1, y: -0.3 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the inverted trinagle endpoint.\n */\nclass InvertedTriangle {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n // Normalized points of closed path, in the order that they should be drawn.\n // (0, 0) is the attachment point, and the point around which should be rotated\n const points = [\n { x: 0, y: 0.3 },\n { x: 0, y: -0.3 },\n { x: -1, y: 0 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the circle endpoint.\n */\nclass Circle {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n const point = { x: -0.4, y: 0 };\n\n EndPoint.transform(point, arrowData);\n drawCircle(ctx, point.x, point.y, arrowData.length * 0.4);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the bar endpoint.\n */\nclass Bar {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n /*\n var points = [\n {x:0, y:0.5},\n {x:0, y:-0.5}\n ];\n\n EndPoint.transform(points, arrowData);\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n ctx.lineTo(points[1].x, points[1].y);\n ctx.stroke();\n*/\n\n const points = [\n { x: 0, y: 0.5 },\n { x: 0, y: -0.5 },\n { x: -0.15, y: -0.5 },\n { x: -0.15, y: 0.5 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the box endpoint.\n */\nclass Box {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n const points = [\n { x: 0, y: 0.3 },\n { x: 0, y: -0.3 },\n { x: -0.6, y: -0.3 },\n { x: -0.6, y: 0.3 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the diamond endpoint.\n */\nclass Diamond {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n const points = [\n { x: 0, y: 0 },\n { x: -0.5, y: -0.3 },\n { x: -1, y: 0 },\n { x: -0.5, y: 0.3 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the vee endpoint.\n */\nclass Vee {\n /**\n * Draw this shape at the end of a line.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True because ctx.fill() can be used to fill the arrow.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): true {\n // Normalized points of closed path, in the order that they should be drawn.\n // (0, 0) is the attachment point, and the point around which should be rotated\n const points = [\n { x: -1, y: 0.3 },\n { x: -0.5, y: 0 },\n { x: -1, y: -0.3 },\n { x: 0, y: 0 },\n ];\n\n EndPoint.transform(points, arrowData);\n EndPoint.drawPath(ctx, points);\n\n return true;\n }\n}\n\n/**\n * Drawing methods for the endpoints.\n */\nexport class EndPoints {\n /**\n * Draw an endpoint.\n *\n * @param ctx - The shape will be rendered into this context.\n * @param arrowData - The data determining the shape.\n *\n * @returns True if ctx.fill() can be used to fill the arrow, false otherwise.\n */\n public static draw(\n ctx: CanvasRenderingContext2D,\n arrowData: ArrowData\n ): boolean {\n let type;\n if (arrowData.type) {\n type = arrowData.type.toLowerCase();\n }\n\n switch (type) {\n case \"image\":\n return Image.draw(ctx, arrowData);\n case \"circle\":\n return Circle.draw(ctx, arrowData);\n case \"box\":\n return Box.draw(ctx, arrowData);\n case \"crow\":\n return Crow.draw(ctx, arrowData);\n case \"curve\":\n return Curve.draw(ctx, arrowData);\n case \"diamond\":\n return Diamond.draw(ctx, arrowData);\n case \"inv_curve\":\n return InvertedCurve.draw(ctx, arrowData);\n case \"triangle\":\n return Triangle.draw(ctx, arrowData);\n case \"inv_triangle\":\n return InvertedTriangle.draw(ctx, arrowData);\n case \"bar\":\n return Bar.draw(ctx, arrowData);\n case \"vee\":\n return Vee.draw(ctx, arrowData);\n case \"arrow\": // fall-through\n default:\n return Arrow.draw(ctx, arrowData);\n }\n }\n}\n","import { overrideOpacity } from \"vis-util/esnext\";\nimport { EndPoints } from \"./end-points\";\nimport {\n ArrowData,\n ArrowDataWithCore,\n ArrowType,\n EdgeFormattingValues,\n EdgeType,\n Id,\n Label,\n EdgeOptions,\n Point,\n PointT,\n SelectiveRequired,\n VBody,\n VNode,\n} from \"./types\";\nimport { drawDashedLine } from \"./shapes\";\nimport { getSelfRefCoordinates } from \"../../shared/ComponentUtil\";\n\nexport interface FindBorderPositionOptions<Via> {\n via: Via;\n}\nexport interface FindBorderPositionCircleOptions {\n x: number;\n y: number;\n low: number;\n high: number;\n direction: number;\n}\n\n/**\n * The Base Class for all edges.\n */\nexport abstract class EdgeBase<Via = undefined> implements EdgeType {\n public from!: VNode; // Initialized in setOptions\n public fromPoint: Point;\n public to!: VNode; // Initialized in setOptions\n public toPoint: Point;\n public via?: VNode;\n\n public color: unknown = {};\n public colorDirty = true;\n public id!: Id; // Initialized in setOptions\n public options!: EdgeOptions; // Initialized in setOptions\n public hoverWidth = 1.5;\n public selectionWidth = 2;\n\n /**\n * Create a new instance.\n *\n * @param options - The options object of given edge.\n * @param _body - The body of the network.\n * @param _labelModule - Label module.\n */\n public constructor(\n options: EdgeOptions,\n protected _body: VBody,\n protected _labelModule: Label\n ) {\n this.setOptions(options);\n\n this.fromPoint = this.from;\n this.toPoint = this.to;\n }\n\n /**\n * Find the intersection between the border of the node and the edge.\n *\n * @param node - The node (either from or to node of the edge).\n * @param ctx - The context that will be used for rendering.\n * @param options - Additional options.\n *\n * @returns Cartesian coordinates of the intersection between the border of the node and the edge.\n */\n protected abstract _findBorderPosition(\n node: VNode,\n ctx: CanvasRenderingContext2D,\n options?: FindBorderPositionOptions<Via>\n ): PointT;\n\n /**\n * Return additional point(s) the edge passes through.\n *\n * @returns Cartesian coordinates of the point(s) the edge passes through.\n */\n public abstract getViaNode(): Via;\n\n /** @inheritDoc */\n public abstract getPoint(position: number, viaNode?: Via): Point;\n\n /** @inheritDoc */\n public connect(): void {\n this.from = this._body.nodes[this.options.from];\n this.to = this._body.nodes[this.options.to];\n }\n\n /** @inheritDoc */\n public cleanup(): boolean {\n return false;\n }\n\n /**\n * Set new edge options.\n *\n * @param options - The new edge options object.\n */\n public setOptions(options: EdgeOptions): void {\n this.options = options;\n\n this.from = this._body.nodes[this.options.from];\n this.to = this._body.nodes[this.options.to];\n this.id = this.options.id;\n }\n\n /** @inheritDoc */\n public drawLine(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n | \"color\"\n | \"opacity\"\n | \"shadowColor\"\n | \"shadowSize\"\n | \"shadowX\"\n | \"shadowY\"\n | \"width\"\n >,\n _selected?: boolean,\n _hover?: boolean,\n viaNode: Via = this.getViaNode()\n ): void {\n // set style\n ctx.strokeStyle = this.getColor(ctx, values);\n ctx.lineWidth = values.width;\n\n if (values.dashes !== false) {\n this._drawDashedLine(ctx, values, viaNode);\n } else {\n this._drawLine(ctx, values, viaNode);\n }\n }\n\n /**\n * Draw a line with given style between two nodes through supplied node(s).\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values like color, opacity or shadow.\n * @param viaNode - Additional control point(s) for the edge.\n * @param fromPoint - TODO: Seems ignored, remove?\n * @param toPoint - TODO: Seems ignored, remove?\n */\n private _drawLine(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"shadowColor\" | \"shadowSize\" | \"shadowX\" | \"shadowY\"\n >,\n viaNode: Via,\n fromPoint?: Point,\n toPoint?: Point\n ): void {\n if (this.from != this.to) {\n // draw line\n this._line(ctx, values, viaNode, fromPoint, toPoint);\n } else {\n const [x, y, radius] = this._getCircleData(ctx);\n this._circle(ctx, values, x, y, radius);\n }\n }\n\n /**\n * Draw a dashed line with given style between two nodes through supplied node(s).\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values like color, opacity or shadow.\n * @param viaNode - Additional control point(s) for the edge.\n * @param _fromPoint - Ignored (TODO: remove in the future).\n * @param _toPoint - Ignored (TODO: remove in the future).\n */\n private _drawDashedLine(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"shadowColor\" | \"shadowSize\" | \"shadowX\" | \"shadowY\"\n >,\n viaNode: Via,\n _fromPoint?: Point,\n _toPoint?: Point\n ): void {\n ctx.lineCap = \"round\";\n const pattern = Array.isArray(values.dashes) ? values.dashes : [5, 5];\n\n // only firefox and chrome support this method, else we use the legacy one.\n if (ctx.setLineDash !== undefined) {\n ctx.save();\n\n // set dash settings for chrome or firefox\n ctx.setLineDash(pattern);\n ctx.lineDashOffset = 0;\n\n // draw the line\n if (this.from != this.to) {\n // draw line\n this._line(ctx, values, viaNode);\n } else {\n const [x, y, radius] = this._getCircleData(ctx);\n this._circle(ctx, values, x, y, radius);\n }\n\n // restore the dash settings.\n ctx.setLineDash([0]);\n ctx.lineDashOffset = 0;\n ctx.restore();\n } else {\n // unsupporting smooth lines\n if (this.from != this.to) {\n // draw line\n drawDashedLine(\n ctx,\n this.from.x,\n this.from.y,\n this.to.x,\n this.to.y,\n pattern\n );\n } else {\n const [x, y, radius] = this._getCircleData(ctx);\n this._circle(ctx, values, x, y, radius);\n }\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n\n ctx.stroke();\n\n // disable shadows for other elements.\n this.disableShadow(ctx, values);\n }\n }\n\n /**\n * Draw a line with given style between two nodes through supplied node(s).\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values like color, opacity or shadow.\n * @param viaNode - Additional control point(s) for the edge.\n * @param fromPoint - TODO: Seems ignored, remove?\n * @param toPoint - TODO: Seems ignored, remove?\n */\n protected abstract _line(\n ctx: CanvasRenderingContext2D,\n values: EdgeFormattingValues,\n viaNode: Via,\n fromPoint?: Point,\n toPoint?: Point\n ): void;\n\n /**\n * Find the intersection between the border of the node and the edge.\n *\n * @param node - The node (either from or to node of the edge).\n * @param ctx - The context that will be used for rendering.\n * @param options - Additional options.\n *\n * @returns Cartesian coordinates of the intersection between the border of the node and the edge.\n */\n public findBorderPosition(\n node: VNode,\n ctx: CanvasRenderingContext2D,\n options?: FindBorderPositionOptions<Via> | FindBorderPositionCircleOptions\n ): PointT {\n if (this.from != this.to) {\n return this._findBorderPosition(node, ctx, options as any);\n } else {\n return this._findBorderPositionCircle(node, ctx, options as any);\n }\n }\n\n /** @inheritDoc */\n public findBorderPositions(ctx: CanvasRenderingContext2D): {\n from: Point;\n to: Point;\n } {\n if (this.from != this.to) {\n return {\n from: this._findBorderPosition(this.from, ctx),\n to: this._findBorderPosition(this.to, ctx),\n };\n } else {\n const [x, y] = this._getCircleData(ctx).slice(0, 2);\n\n return {\n from: this._findBorderPositionCircle(this.from, ctx, {\n x,\n y,\n low: 0.25,\n high: 0.6,\n direction: -1,\n }),\n to: this._findBorderPositionCircle(this.from, ctx, {\n x,\n y,\n low: 0.6,\n high: 0.8,\n direction: 1,\n }),\n };\n }\n }\n\n /**\n * Compute the center point and radius of an edge connected to the same node at both ends.\n *\n * @param ctx - The context that will be used for rendering.\n *\n * @returns `[x, y, radius]`\n */\n protected _getCircleData(\n ctx?: CanvasRenderingContext2D\n ): [number, number, number] {\n const radius = this.options.selfReference.size;\n\n if (ctx !== undefined) {\n if (this.from.shape.width === undefined) {\n this.from.shape.resize(ctx);\n }\n }\n\n // get circle coordinates\n const coordinates = getSelfRefCoordinates(\n ctx,\n this.options.selfReference.angle,\n radius,\n this.from\n );\n\n return [coordinates.x, coordinates.y, radius];\n }\n\n /**\n * Get a point on a circle.\n *\n * @param x - Center of the circle on the x axis.\n * @param y - Center of the circle on the y axis.\n * @param radius - Radius of the circle.\n * @param position - Value between 0 (line start) and 1 (line end).\n *\n * @returns Cartesian coordinates of requested point on the circle.\n */\n private _pointOnCircle(\n x: number,\n y: number,\n radius: number,\n position: number\n ): Point {\n const angle = position * 2 * Math.PI;\n return {\n x: x + radius * Math.cos(angle),\n y: y - radius * Math.sin(angle),\n };\n }\n\n /**\n * Find the intersection between the border of the node and the edge.\n *\n * @remarks\n * This function uses binary search to look for the point where the circle crosses the border of the node.\n *\n * @param nearNode - The node (either from or to node of the edge).\n * @param ctx - The context that will be used for rendering.\n * @param options - Additional options.\n *\n * @returns Cartesian coordinates of the intersection between the border of the node and the edge.\n */\n private _findBorderPositionCircle(\n nearNode: VNode,\n ctx: CanvasRenderingContext2D,\n options: FindBorderPositionCircleOptions\n ): PointT {\n const x = options.x;\n const y = options.y;\n let low = options.low;\n let high = options.high;\n const direction = options.direction;\n\n const maxIterations = 10;\n const radius = this.options.selfReference.size;\n const threshold = 0.05;\n let pos: Point;\n\n let middle = (low + high) * 0.5;\n\n let endPointOffset = 0;\n if (this.options.arrowStrikethrough === true) {\n if (direction === -1) {\n endPointOffset = this.options.endPointOffset.from;\n } else if (direction === 1) {\n endPointOffset = this.options.endPointOffset.to;\n }\n }\n\n let iteration = 0;\n do {\n middle = (low + high) * 0.5;\n\n pos = this._pointOnCircle(x, y, radius, middle);\n const angle = Math.atan2(nearNode.y - pos.y, nearNode.x - pos.x);\n\n const distanceToBorder =\n nearNode.distanceToBorder(ctx, angle) + endPointOffset;\n\n const distanceToPoint = Math.sqrt(\n Math.pow(pos.x - nearNode.x, 2) + Math.pow(pos.y - nearNode.y, 2)\n );\n const difference = distanceToBorder - distanceToPoint;\n if (Math.abs(difference) < threshold) {\n break; // found\n } else if (difference > 0) {\n // distance to nodes is larger than distance to border --> t needs to be bigger if we're looking at the to node.\n if (direction > 0) {\n low = middle;\n } else {\n high = middle;\n }\n } else {\n if (direction > 0) {\n high = middle;\n } else {\n low = middle;\n }\n }\n\n ++iteration;\n } while (low <= high && iteration < maxIterations);\n\n return {\n ...pos,\n t: middle,\n };\n }\n\n /**\n * Get the line width of the edge. Depends on width and whether one of the connected nodes is selected.\n *\n * @param selected - Determines wheter the line is selected.\n * @param hover - Determines wheter the line is being hovered, only applies if selected is false.\n *\n * @returns The width of the line.\n */\n public getLineWidth(selected: boolean, hover: boolean): number {\n if (selected === true) {\n return Math.max(this.selectionWidth, 0.3 / this._body.view.scale);\n } else if (hover === true) {\n return Math.max(this.hoverWidth, 0.3 / this._body.view.scale);\n } else {\n return Math.max(this.options.width, 0.3 / this._body.view.scale);\n }\n }\n\n /**\n * Compute the color or gradient for given edge.\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values like color, opacity or shadow.\n * @param _selected - Ignored (TODO: remove in the future).\n * @param _hover - Ignored (TODO: remove in the future).\n *\n * @returns Color string if single color is inherited or gradient if two.\n */\n public getColor(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<EdgeFormattingValues, \"color\" | \"opacity\">\n ): string | CanvasGradient {\n if (values.inheritsColor !== false) {\n // when this is a loop edge, just use the 'from' method\n if (values.inheritsColor === \"both\" && this.from.id !== this.to.id) {\n const grd = ctx.createLinearGradient(\n this.from.x,\n this.from.y,\n this.to.x,\n this.to.y\n );\n let fromColor = this.from.options.color.highlight.border;\n let toColor = this.to.options.color.highlight.border;\n\n if (this.from.selected === false && this.to.selected === false) {\n fromColor = overrideOpacity(\n this.from.options.color.border,\n values.opacity\n );\n toColor = overrideOpacity(\n this.to.options.color.border,\n values.opacity\n );\n } else if (this.from.selected === true && this.to.selected === false) {\n toColor = this.to.options.color.border;\n } else if (this.from.selected === false && this.to.selected === true) {\n fromColor = this.from.options.color.border;\n }\n grd.addColorStop(0, fromColor);\n grd.addColorStop(1, toColor);\n\n // -------------------- this returns -------------------- //\n return grd;\n }\n\n if (values.inheritsColor === \"to\") {\n return overrideOpacity(this.to.options.color.border, values.opacity);\n } else {\n // \"from\"\n return overrideOpacity(this.from.options.color.border, values.opacity);\n }\n } else {\n return overrideOpacity(values.color, values.opacity);\n }\n }\n\n /**\n * Draw a line from a node to itself, a circle.\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values like color, opacity or shadow.\n * @param x - Center of the circle on the x axis.\n * @param y - Center of the circle on the y axis.\n * @param radius - Radius of the circle.\n */\n private _circle(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"shadowColor\" | \"shadowSize\" | \"shadowX\" | \"shadowY\"\n >,\n x: number,\n y: number,\n radius: number\n ): void {\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n\n //full circle\n let angleFrom = 0;\n let angleTo = Math.PI * 2;\n\n if (!this.options.selfReference.renderBehindTheNode) {\n //render only parts which are not overlaping with parent node\n //need to find x,y of from point and x,y to point\n //calculating radians\n const low = this.options.selfReference.angle;\n const high = this.options.selfReference.angle + Math.PI;\n const pointTFrom = this._findBorderPositionCircle(this.from, ctx, {\n x,\n y,\n low,\n high,\n direction: -1,\n });\n const pointTTo = this._findBorderPositionCircle(this.from, ctx, {\n x,\n y,\n low,\n high,\n direction: 1,\n });\n angleFrom = Math.atan2(pointTFrom.y - y, pointTFrom.x - x);\n angleTo = Math.atan2(pointTTo.y - y, pointTTo.x - x);\n }\n\n // draw a circle\n ctx.beginPath();\n ctx.arc(x, y, radius, angleFrom, angleTo, false);\n ctx.stroke();\n\n // disable shadows for other elements.\n this.disableShadow(ctx, values);\n }\n\n /**\n * @inheritDoc\n *\n * @remarks\n * http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment\n */\n public getDistanceToEdge(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): number {\n if (this.from != this.to) {\n return this._getDistanceToEdge(x1, y1, x2, y2, x3, y3);\n } else {\n const [x, y, radius] = this._getCircleData(undefined);\n const dx = x - x3;\n const dy = y - y3;\n return Math.abs(Math.sqrt(dx * dx + dy * dy) - radius);\n }\n }\n\n /**\n * Calculate the distance between a point (x3, y3) and a line segment from (x1, y1) to (x2, y2).\n *\n * @remarks\n * http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment\n *\n * @param x1 - First end of the line segment on the x axis.\n * @param y1 - First end of the line segment on the y axis.\n * @param x2 - Second end of the line segment on the x axis.\n * @param y2 - Second end of the line segment on the y axis.\n * @param x3 - Position of the point on the x axis.\n * @param y3 - Position of the point on the y axis.\n * @param via - Additional control point(s) for the edge.\n *\n * @returns The distance between the line segment and the point.\n */\n protected abstract _getDistanceToEdge(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n via?: Via\n ): number;\n\n /**\n * Calculate the distance between a point (x3, y3) and a line segment from (x1, y1) to (x2, y2).\n *\n * @param x1 - First end of the line segment on the x axis.\n * @param y1 - First end of the line segment on the y axis.\n * @param x2 - Second end of the line segment on the x axis.\n * @param y2 - Second end of the line segment on the y axis.\n * @param x3 - Position of the point on the x axis.\n * @param y3 - Position of the point on the y axis.\n *\n * @returns The distance between the line segment and the point.\n */\n protected _getDistanceToLine(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): number {\n const px = x2 - x1;\n const py = y2 - y1;\n const something = px * px + py * py;\n let u = ((x3 - x1) * px + (y3 - y1) * py) / something;\n\n if (u > 1) {\n u = 1;\n } else if (u < 0) {\n u = 0;\n }\n\n const x = x1 + u * px;\n const y = y1 + u * py;\n const dx = x - x3;\n const dy = y - y3;\n\n //# Note: If the actual distance does not matter,\n //# if you only want to compare what this function\n //# returns to other results of this function, you\n //# can just return the squared distance instead\n //# (i.e. remove the sqrt) to gain a little performance\n\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /** @inheritDoc */\n public getArrowData(\n ctx: CanvasRenderingContext2D,\n position: \"middle\",\n viaNode: VNode,\n selected: boolean,\n hover: boolean,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"middleArrowType\" | \"middleArrowScale\" | \"width\"\n >\n ): ArrowDataWithCore;\n /** @inheritDoc */\n public getArrowData(\n ctx: CanvasRenderingContext2D,\n position: \"to\",\n viaNode: VNode,\n selected: boolean,\n hover: boolean,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"toArrowType\" | \"toArrowScale\" | \"width\"\n >\n ): ArrowDataWithCore;\n /** @inheritDoc */\n public getArrowData(\n ctx: CanvasRenderingContext2D,\n position: \"from\",\n viaNode: VNode,\n selected: boolean,\n hover: boolean,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"fromArrowType\" | \"fromArrowScale\" | \"width\"\n >\n ): ArrowDataWithCore;\n /** @inheritDoc */\n public getArrowData(\n ctx: CanvasRenderingContext2D,\n position: \"from\" | \"to\" | \"middle\",\n viaNode: VNode,\n _selected: boolean,\n _hover: boolean,\n values: SelectiveRequired<EdgeFormattingValues, \"width\">\n ): ArrowDataWithCore {\n // set lets\n let angle: number;\n let arrowPoint: Point;\n let node1: VNode;\n let node2: VNode;\n let reversed: boolean;\n let scaleFactor: number;\n let type: ArrowType;\n const lineWidth: number = values.width;\n\n if (position === \"from\") {\n node1 = this.from;\n node2 = this.to;\n reversed = values.fromArrowScale! < 0;\n scaleFactor = Math.abs(values.fromArrowScale!);\n type = values.fromArrowType!;\n } else if (position === \"to\") {\n node1 = this.to;\n node2 = this.from;\n reversed = values.toArrowScale! < 0;\n scaleFactor = Math.abs(values.toArrowScale!);\n type = values.toArrowType!;\n } else {\n node1 = this.to;\n node2 = this.from;\n reversed = values.middleArrowScale! < 0;\n scaleFactor = Math.abs(values.middleArrowScale!);\n type = values.middleArrowType!;\n }\n\n const length = 15 * scaleFactor + 3 * lineWidth; // 3* lineWidth is the width of the edge.\n\n // if not connected to itself\n if (node1 != node2) {\n const approximateEdgeLength = Math.hypot(\n node1.x - node2.x,\n node1.y - node2.y\n );\n const relativeLength = length / approximateEdgeLength;\n\n if (position !== \"middle\") {\n // draw arrow head\n if (this.options.smooth.enabled === true) {\n const pointT = this._findBorderPosition(node1, ctx, { via: viaNode });\n const guidePos = this.getPoint(\n pointT.t + relativeLength * (position === \"from\" ? 1 : -1),\n viaNode\n );\n angle = Math.atan2(pointT.y - guidePos.y, pointT.x - guidePos.x);\n arrowPoint = pointT;\n } else {\n angle = Math.atan2(node1.y - node2.y, node1.x - node2.x);\n arrowPoint = this._findBorderPosition(node1, ctx);\n }\n } else {\n // Negative half length reverses arrow direction.\n const halfLength = (reversed ? -relativeLength : relativeLength) / 2;\n const guidePos1 = this.getPoint(0.5 + halfLength, viaNode);\n const guidePos2 = this.getPoint(0.5 - halfLength, viaNode);\n angle = Math.atan2(\n guidePos1.y - guidePos2.y,\n guidePos1.x - guidePos2.x\n );\n arrowPoint = this.getPoint(0.5, viaNode);\n }\n } else {\n // draw circle\n const [x, y, radius] = this._getCircleData(ctx);\n\n if (position === \"from\") {\n const low = this.options.selfReference.angle;\n const high = this.options.selfReference.angle + Math.PI;\n\n const pointT = this._findBorderPositionCircle(this.from, ctx, {\n x,\n y,\n low,\n high,\n direction: -1,\n });\n angle = pointT.t * -2 * Math.PI + 1.5 * Math.PI + 0.1 * Math.PI;\n arrowPoint = pointT;\n } else if (position === \"to\") {\n const low = this.options.selfReference.angle;\n const high = this.options.selfReference.angle + Math.PI;\n\n const pointT = this._findBorderPositionCircle(this.from, ctx, {\n x,\n y,\n low,\n high,\n direction: 1,\n });\n angle = pointT.t * -2 * Math.PI + 1.5 * Math.PI - 1.1 * Math.PI;\n arrowPoint = pointT;\n } else {\n const pos = this.options.selfReference.angle / (2 * Math.PI);\n arrowPoint = this._pointOnCircle(x, y, radius, pos);\n angle = pos * -2 * Math.PI + 1.5 * Math.PI + 0.1 * Math.PI;\n }\n }\n\n const xi = arrowPoint.x - length * 0.9 * Math.cos(angle);\n const yi = arrowPoint.y - length * 0.9 * Math.sin(angle);\n const arrowCore = { x: xi, y: yi };\n\n return {\n point: arrowPoint,\n core: arrowCore,\n angle: angle,\n length: length,\n type: type,\n };\n }\n\n /** @inheritDoc */\n public drawArrowHead(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n | \"color\"\n | \"opacity\"\n | \"shadowColor\"\n | \"shadowSize\"\n | \"shadowX\"\n | \"shadowY\"\n | \"width\"\n >,\n _selected: boolean,\n _hover: boolean,\n arrowData: ArrowData\n ): void {\n // set style\n ctx.strokeStyle = this.getColor(ctx, values);\n ctx.fillStyle = ctx.strokeStyle;\n ctx.lineWidth = values.width;\n\n const canFill = EndPoints.draw(ctx, arrowData);\n\n if (canFill) {\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n ctx.fill();\n // disable shadows for other elements.\n this.disableShadow(ctx, values);\n }\n }\n\n /**\n * Set the shadow formatting values in the context if enabled, do nothing otherwise.\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values for the shadow.\n */\n public enableShadow(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"shadowColor\" | \"shadowSize\" | \"shadowX\" | \"shadowY\"\n >\n ): void {\n if (values.shadow === true) {\n ctx.shadowColor = values.shadowColor;\n ctx.shadowBlur = values.shadowSize;\n ctx.shadowOffsetX = values.shadowX;\n ctx.shadowOffsetY = values.shadowY;\n }\n }\n\n /**\n * Reset the shadow formatting values in the context if enabled, do nothing otherwise.\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values for the shadow.\n */\n public disableShadow(\n ctx: CanvasRenderingContext2D,\n values: EdgeFormattingValues\n ): void {\n if (values.shadow === true) {\n ctx.shadowColor = \"rgba(0,0,0,0)\";\n ctx.shadowBlur = 0;\n ctx.shadowOffsetX = 0;\n ctx.shadowOffsetY = 0;\n }\n }\n\n /**\n * Render the background according to the formatting values.\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Formatting values for the background.\n */\n public drawBackground(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"backgroundColor\" | \"backgroundSize\"\n >\n ): void {\n if (values.background !== false) {\n // save original line attrs\n const origCtxAttr = {\n strokeStyle: ctx.strokeStyle,\n lineWidth: ctx.lineWidth,\n dashes: (ctx as any).dashes,\n };\n\n ctx.strokeStyle = values.backgroundColor;\n ctx.lineWidth = values.backgroundSize;\n this.setStrokeDashed(ctx, values.backgroundDashes);\n\n ctx.stroke();\n\n // restore original line attrs\n ctx.strokeStyle = origCtxAttr.strokeStyle;\n ctx.lineWidth = origCtxAttr.lineWidth;\n (ctx as any).dashes = origCtxAttr.dashes;\n this.setStrokeDashed(ctx, values.dashes);\n }\n }\n\n /**\n * Set the line dash pattern if supported. Logs a warning to the console if it isn't supported.\n *\n * @param ctx - The context that will be used for rendering.\n * @param dashes - The pattern [line, space, line…], true for default dashed line or false for normal line.\n */\n public setStrokeDashed(\n ctx: CanvasRenderingContext2D,\n dashes?: boolean | number[]\n ): void {\n if (dashes !== false) {\n if (ctx.setLineDash !== undefined) {\n const pattern = Array.isArray(dashes) ? dashes : [5, 5];\n ctx.setLineDash(pattern);\n } else {\n console.warn(\n \"setLineDash is not supported in this browser. The dashed stroke cannot be used.\"\n );\n }\n } else {\n if (ctx.setLineDash !== undefined) {\n ctx.setLineDash([]);\n } else {\n console.warn(\n \"setLineDash is not supported in this browser. The dashed stroke cannot be used.\"\n );\n }\n }\n }\n}\n","import { EdgeBase } from \"./edge-base\";\nimport {\n EdgeFormattingValues,\n Label,\n EdgeOptions,\n Point,\n PointT,\n SelectiveRequired,\n VBody,\n VNode,\n} from \"./types\";\n\n/**\n * The Base Class for all Bezier edges.\n * Bezier curves are used to model smooth gradual curves in paths between nodes.\n */\nexport abstract class BezierEdgeBase<Via> extends EdgeBase<Via> {\n /**\n * Create a new instance.\n *\n * @param options - The options object of given edge.\n * @param body - The body of the network.\n * @param labelModule - Label module.\n */\n public constructor(options: EdgeOptions, body: VBody, labelModule: Label) {\n super(options, body, labelModule);\n }\n\n /**\n * Compute additional point(s) the edge passes through.\n *\n * @returns Cartesian coordinates of the point(s) the edge passes through.\n */\n protected abstract _getViaCoordinates(): Via;\n\n /**\n * Find the intersection between the border of the node and the edge.\n *\n * @remarks\n * This function uses binary search to look for the point where the bezier curve crosses the border of the node.\n *\n * @param nearNode - The node (either from or to node of the edge).\n * @param ctx - The context that will be used for rendering.\n * @param viaNode - Additional node(s) the edge passes through.\n *\n * @returns Cartesian coordinates of the intersection between the border of the node and the edge.\n */\n protected _findBorderPositionBezier(\n nearNode: VNode,\n ctx: CanvasRenderingContext2D,\n viaNode: Via = this._getViaCoordinates()\n ): PointT {\n const maxIterations = 10;\n const threshold = 0.2;\n let from = false;\n let high = 1;\n let low = 0;\n let node = this.to;\n let pos: Point;\n let middle: number;\n\n let endPointOffset = this.options.endPointOffset\n ? this.options.endPointOffset.to\n : 0;\n\n if (nearNode.id === this.from.id) {\n node = this.from;\n from = true;\n\n endPointOffset = this.options.endPointOffset\n ? this.options.endPointOffset.from\n : 0;\n }\n\n if (this.options.arrowStrikethrough === false) {\n endPointOffset = 0;\n }\n\n let iteration = 0;\n do {\n middle = (low + high) * 0.5;\n\n pos = this.getPoint(middle, viaNode);\n const angle = Math.atan2(node.y - pos.y, node.x - pos.x);\n\n const distanceToBorder =\n node.distanceToBorder(ctx, angle) + endPointOffset;\n\n const distanceToPoint = Math.sqrt(\n Math.pow(pos.x - node.x, 2) + Math.pow(pos.y - node.y, 2)\n );\n const difference = distanceToBorder - distanceToPoint;\n if (Math.abs(difference) < threshold) {\n break; // found\n } else if (difference < 0) {\n // distance to nodes is larger than distance to border --> t needs to be bigger if we're looking at the to node.\n if (from === false) {\n low = middle;\n } else {\n high = middle;\n }\n } else {\n if (from === false) {\n high = middle;\n } else {\n low = middle;\n }\n }\n\n ++iteration;\n } while (low <= high && iteration < maxIterations);\n\n return {\n ...pos,\n t: middle,\n };\n }\n\n /**\n * Calculate the distance between a point (x3,y3) and a line segment from (x1,y1) to (x2,y2).\n *\n * @remarks\n * http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment\n *\n * @param x1 - First end of the line segment on the x axis.\n * @param y1 - First end of the line segment on the y axis.\n * @param x2 - Second end of the line segment on the x axis.\n * @param y2 - Second end of the line segment on the y axis.\n * @param x3 - Position of the point on the x axis.\n * @param y3 - Position of the point on the y axis.\n * @param via - The control point for the edge.\n *\n * @returns The distance between the line segment and the point.\n */\n protected _getDistanceToBezierEdge(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n via: Point\n ): number {\n // x3,y3 is the point\n let minDistance = 1e9;\n let distance;\n let i, t, x, y;\n let lastX = x1;\n let lastY = y1;\n for (i = 1; i < 10; i++) {\n t = 0.1 * i;\n x =\n Math.pow(1 - t, 2) * x1 + 2 * t * (1 - t) * via.x + Math.pow(t, 2) * x2;\n y =\n Math.pow(1 - t, 2) * y1 + 2 * t * (1 - t) * via.y + Math.pow(t, 2) * y2;\n if (i > 0) {\n distance = this._getDistanceToLine(lastX, lastY, x, y, x3, y3);\n minDistance = distance < minDistance ? distance : minDistance;\n }\n lastX = x;\n lastY = y;\n }\n\n return minDistance;\n }\n\n /**\n * Render a bezier curve between two nodes.\n *\n * @remarks\n * The method accepts zero, one or two control points.\n * Passing zero control points just draws a straight line.\n *\n * @param ctx - The context that will be used for rendering.\n * @param values - Style options for edge drawing.\n * @param viaNode1 - First control point for curve drawing.\n * @param viaNode2 - Second control point for curve drawing.\n */\n protected _bezierCurve(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n | \"backgroundColor\"\n | \"backgroundSize\"\n | \"shadowColor\"\n | \"shadowSize\"\n | \"shadowX\"\n | \"shadowY\"\n >,\n viaNode1?: Point,\n viaNode2?: Point\n ): void {\n ctx.beginPath();\n ctx.moveTo(this.fromPoint.x, this.fromPoint.y);\n\n if (viaNode1 != null && viaNode1.x != null) {\n if (viaNode2 != null && viaNode2.x != null) {\n ctx.bezierCurveTo(\n viaNode1.x,\n viaNode1.y,\n viaNode2.x,\n viaNode2.y,\n this.toPoint.x,\n this.toPoint.y\n );\n } else {\n ctx.quadraticCurveTo(\n viaNode1.x,\n viaNode1.y,\n this.toPoint.x,\n this.toPoint.y\n );\n }\n } else {\n // fallback to normal straight edge\n ctx.lineTo(this.toPoint.x, this.toPoint.y);\n }\n\n // draw a background\n this.drawBackground(ctx, values);\n\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n ctx.stroke();\n this.disableShadow(ctx, values);\n }\n\n /** @inheritDoc */\n public getViaNode(): Via {\n return this._getViaCoordinates();\n }\n}\n","import { BezierEdgeBase } from \"./util/bezier-edge-base\";\nimport {\n EdgeFormattingValues,\n Label,\n EdgeOptions,\n Point,\n PointT,\n SelectiveRequired,\n VBody,\n VNode,\n} from \"./util/types\";\n\n/**\n * A Dynamic Bezier Edge. Bezier curves are used to model smooth gradual\n * curves in paths between nodes. The Dynamic piece refers to how the curve\n * reacts to physics changes.\n *\n * @augments BezierEdgeBase\n */\nexport class BezierEdgeDynamic extends BezierEdgeBase<Point> {\n public via: VNode = this.via; // constructor → super → super → setOptions → setupSupportNode\n private readonly _boundFunction: () => void;\n\n /**\n * Create a new instance.\n *\n * @param options - The options object of given edge.\n * @param body - The body of the network.\n * @param labelModule - Label module.\n */\n public constructor(options: EdgeOptions, body: VBody, labelModule: Label) {\n //this.via = undefined; // Here for completeness but not allowed to defined before super() is invoked.\n super(options, body, labelModule); // --> this calls the setOptions below\n this._boundFunction = (): void => {\n this.positionBezierNode();\n };\n this._body.emitter.on(\"_repositionBezierNodes\", this._boundFunction);\n }\n\n /** @inheritDoc */\n public setOptions(options: EdgeOptions): void {\n super.setOptions(options);\n\n // check if the physics has changed.\n let physicsChange = false;\n if (this.options.physics !== options.physics) {\n physicsChange = true;\n }\n\n // set the options and the to and from nodes\n this.options = options;\n this.id = this.options.id;\n this.from = this._body.nodes[this.options.from];\n this.to = this._body.nodes[this.options.to];\n\n // setup the support node and connect\n this.setupSupportNode();\n this.connect();\n\n // when we change the physics state of the edge, we reposition the support node.\n if (physicsChange === true) {\n this.via.setOptions({ physics: this.options.physics });\n this.positionBezierNode();\n }\n }\n\n /** @inheritDoc */\n public connect(): void {\n this.from = this._body.nodes[this.options.from];\n this.to = this._body.nodes[this.options.to];\n if (\n this.from === undefined ||\n this.to === undefined ||\n this.options.physics === false\n ) {\n this.via.setOptions({ physics: false });\n } else {\n // fix weird behaviour where a self referencing node has physics enabled\n if (this.from.id === this.to.id) {\n this.via.setOptions({ physics: false });\n } else {\n this.via.setOptions({ physics: true });\n }\n }\n }\n\n /** @inheritDoc */\n public cleanup(): boolean {\n this._body.emitter.off(\"_repositionBezierNodes\", this._boundFunction);\n if (this.via !== undefined) {\n delete this._body.nodes[this.via.id];\n this.via = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Create and add a support node if not already present.\n *\n * @remarks\n * Bezier curves require an anchor point to calculate the smooth flow.\n * These points are nodes.\n * These nodes are invisible but are used for the force calculation.\n *\n * The changed data is not called, if needed, it is returned by the main edge constructor.\n */\n public setupSupportNode(): void {\n if (this.via === undefined) {\n const nodeId = \"edgeId:\" + this.id;\n const node = this._body.functions.createNode({\n id: nodeId,\n shape: \"circle\",\n physics: true,\n hidden: true,\n });\n this._body.nodes[nodeId] = node;\n this.via = node;\n this.via.parentEdgeId = this.id;\n this.positionBezierNode();\n }\n }\n\n /**\n * Position bezier node.\n */\n public positionBezierNode(): void {\n if (\n this.via !== undefined &&\n this.from !== undefined &&\n this.to !== undefined\n ) {\n this.via.x = 0.5 * (this.from.x + this.to.x);\n this.via.y = 0.5 * (this.from.y + this.to.y);\n } else if (this.via !== undefined) {\n this.via.x = 0;\n this.via.y = 0;\n }\n }\n\n /** @inheritDoc */\n protected _line(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n | \"backgroundColor\"\n | \"backgroundSize\"\n | \"shadowColor\"\n | \"shadowSize\"\n | \"shadowX\"\n | \"shadowY\"\n >,\n viaNode: VNode\n ): void {\n this._bezierCurve(ctx, values, viaNode);\n }\n\n /** @inheritDoc */\n protected _getViaCoordinates(): Point {\n return this.via;\n }\n\n /** @inheritDoc */\n public getViaNode(): Point {\n return this.via;\n }\n\n /** @inheritDoc */\n public getPoint(position: number, viaNode: Point = this.via): Point {\n if (this.from === this.to) {\n const [cx, cy, cr] = this._getCircleData();\n const a = 2 * Math.PI * (1 - position);\n return {\n x: cx + cr * Math.sin(a),\n y: cy + cr - cr * (1 - Math.cos(a)),\n };\n } else {\n return {\n x:\n Math.pow(1 - position, 2) * this.fromPoint.x +\n 2 * position * (1 - position) * viaNode.x +\n Math.pow(position, 2) * this.toPoint.x,\n y:\n Math.pow(1 - position, 2) * this.fromPoint.y +\n 2 * position * (1 - position) * viaNode.y +\n Math.pow(position, 2) * this.toPoint.y,\n };\n }\n }\n\n /** @inheritDoc */\n protected _findBorderPosition(\n nearNode: VNode,\n ctx: CanvasRenderingContext2D\n ): PointT {\n return this._findBorderPositionBezier(nearNode, ctx, this.via);\n }\n\n /** @inheritDoc */\n protected _getDistanceToEdge(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): number {\n // x3,y3 is the point\n return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, this.via);\n }\n}\n","import { BezierEdgeBase } from \"./util/bezier-edge-base\";\nimport {\n EdgeFormattingValues,\n Label,\n EdgeOptions,\n Point,\n PointT,\n SelectiveRequired,\n VBody,\n VNode,\n} from \"./util/types\";\n\n/**\n * A Static Bezier Edge. Bezier curves are used to model smooth gradual curves in paths between nodes.\n */\nexport class BezierEdgeStatic extends BezierEdgeBase<Point> {\n /**\n * Create a new instance.\n *\n * @param options - The options object of given edge.\n * @param body - The body of the network.\n * @param labelModule - Label module.\n */\n public constructor(options: EdgeOptions, body: VBody, labelModule: Label) {\n super(options, body, labelModule);\n }\n\n /** @inheritDoc */\n protected _line(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n | \"backgroundColor\"\n | \"backgroundSize\"\n | \"shadowColor\"\n | \"shadowSize\"\n | \"shadowX\"\n | \"shadowY\"\n >,\n viaNode: Point\n ): void {\n this._bezierCurve(ctx, values, viaNode);\n }\n\n /** @inheritDoc */\n public getViaNode(): Point {\n return this._getViaCoordinates();\n }\n\n /**\n * Compute the coordinates of the via node.\n *\n * @remarks\n * We do not use the to and fromPoints here to make the via nodes the same as edges without arrows.\n *\n * @returns Cartesian coordinates of the via node.\n */\n protected _getViaCoordinates(): Point {\n // Assumption: x/y coordinates in from/to always defined\n const factor = this.options.smooth.roundness;\n const type = this.options.smooth.type;\n let dx = Math.abs(this.from.x - this.to.x);\n let dy = Math.abs(this.from.y - this.to.y);\n if (type === \"discrete\" || type === \"diagonalCross\") {\n let stepX;\n let stepY;\n\n if (dx <= dy) {\n stepX = stepY = factor * dy;\n } else {\n stepX = stepY = factor * dx;\n }\n\n if (this.from.x > this.to.x) {\n stepX = -stepX;\n }\n if (this.from.y >= this.to.y) {\n stepY = -stepY;\n }\n\n let xVia = this.from.x + stepX;\n let yVia = this.from.y + stepY;\n\n if (type === \"discrete\") {\n if (dx <= dy) {\n xVia = dx < factor * dy ? this.from.x : xVia;\n } else {\n yVia = dy < factor * dx ? this.from.y : yVia;\n }\n }\n\n return { x: xVia, y: yVia };\n } else if (type === \"straightCross\") {\n let stepX = (1 - factor) * dx;\n let stepY = (1 - factor) * dy;\n\n if (dx <= dy) {\n // up - down\n stepX = 0;\n if (this.from.y < this.to.y) {\n stepY = -stepY;\n }\n } else {\n // left - right\n if (this.from.x < this.to.x) {\n stepX = -stepX;\n }\n stepY = 0;\n }\n\n return {\n x: this.to.x + stepX,\n y: this.to.y + stepY,\n };\n } else if (type === \"horizontal\") {\n let stepX = (1 - factor) * dx;\n if (this.from.x < this.to.x) {\n stepX = -stepX;\n }\n\n return {\n x: this.to.x + stepX,\n y: this.from.y,\n };\n } else if (type === \"vertical\") {\n let stepY = (1 - factor) * dy;\n if (this.from.y < this.to.y) {\n stepY = -stepY;\n }\n\n return {\n x: this.from.x,\n y: this.to.y + stepY,\n };\n } else if (type === \"curvedCW\") {\n dx = this.to.x - this.from.x;\n dy = this.from.y - this.to.y;\n const radius = Math.sqrt(dx * dx + dy * dy);\n const pi = Math.PI;\n\n const originalAngle = Math.atan2(dy, dx);\n const myAngle = (originalAngle + (factor * 0.5 + 0.5) * pi) % (2 * pi);\n\n return {\n x: this.from.x + (factor * 0.5 + 0.5) * radius * Math.sin(myAngle),\n y: this.from.y + (factor * 0.5 + 0.5) * radius * Math.cos(myAngle),\n };\n } else if (type === \"curvedCCW\") {\n dx = this.to.x - this.from.x;\n dy = this.from.y - this.to.y;\n const radius = Math.sqrt(dx * dx + dy * dy);\n const pi = Math.PI;\n\n const originalAngle = Math.atan2(dy, dx);\n const myAngle = (originalAngle + (-factor * 0.5 + 0.5) * pi) % (2 * pi);\n\n return {\n x: this.from.x + (factor * 0.5 + 0.5) * radius * Math.sin(myAngle),\n y: this.from.y + (factor * 0.5 + 0.5) * radius * Math.cos(myAngle),\n };\n } else {\n // continuous\n let stepX;\n let stepY;\n\n if (dx <= dy) {\n stepX = stepY = factor * dy;\n } else {\n stepX = stepY = factor * dx;\n }\n\n if (this.from.x > this.to.x) {\n stepX = -stepX;\n }\n if (this.from.y >= this.to.y) {\n stepY = -stepY;\n }\n\n let xVia = this.from.x + stepX;\n let yVia = this.from.y + stepY;\n\n if (dx <= dy) {\n if (this.from.x <= this.to.x) {\n xVia = this.to.x < xVia ? this.to.x : xVia;\n } else {\n xVia = this.to.x > xVia ? this.to.x : xVia;\n }\n } else {\n if (this.from.y >= this.to.y) {\n yVia = this.to.y > yVia ? this.to.y : yVia;\n } else {\n yVia = this.to.y < yVia ? this.to.y : yVia;\n }\n }\n\n return { x: xVia, y: yVia };\n }\n }\n\n /** @inheritDoc */\n protected _findBorderPosition(\n nearNode: VNode,\n ctx: CanvasRenderingContext2D,\n options: { via?: Point } = {}\n ): PointT {\n return this._findBorderPositionBezier(nearNode, ctx, options.via);\n }\n\n /** @inheritDoc */\n protected _getDistanceToEdge(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n viaNode = this._getViaCoordinates()\n ) {\n // x3,y3 is the point\n return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, viaNode);\n }\n\n /** @inheritDoc */\n public getPoint(\n position: number,\n viaNode: Point = this._getViaCoordinates()\n ): Point {\n const t = position;\n const x =\n Math.pow(1 - t, 2) * this.fromPoint.x +\n 2 * t * (1 - t) * viaNode.x +\n Math.pow(t, 2) * this.toPoint.x;\n const y =\n Math.pow(1 - t, 2) * this.fromPoint.y +\n 2 * t * (1 - t) * viaNode.y +\n Math.pow(t, 2) * this.toPoint.y;\n\n return { x: x, y: y };\n }\n}\n","import { BezierEdgeBase } from \"./bezier-edge-base\";\nimport { Label, EdgeOptions, Point, VBody } from \"./types\";\n\n/**\n * A Base Class for all Cubic Bezier Edges. Bezier curves are used to model\n * smooth gradual curves in paths between nodes.\n *\n * @augments BezierEdgeBase\n */\nexport abstract class CubicBezierEdgeBase<Via> extends BezierEdgeBase<Via> {\n /**\n * Create a new instance.\n *\n * @param options - The options object of given edge.\n * @param body - The body of the network.\n * @param labelModule - Label module.\n */\n public constructor(options: EdgeOptions, body: VBody, labelModule: Label) {\n super(options, body, labelModule);\n }\n\n /**\n * Calculate the distance between a point (x3,y3) and a line segment from (x1,y1) to (x2,y2).\n *\n * @remarks\n * http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment\n * https://en.wikipedia.org/wiki/B%C3%A9zier_curve\n *\n * @param x1 - First end of the line segment on the x axis.\n * @param y1 - First end of the line segment on the y axis.\n * @param x2 - Second end of the line segment on the x axis.\n * @param y2 - Second end of the line segment on the y axis.\n * @param x3 - Position of the point on the x axis.\n * @param y3 - Position of the point on the y axis.\n * @param via1 - The first point this edge passes through.\n * @param via2 - The second point this edge passes through.\n *\n * @returns The distance between the line segment and the point.\n */\n protected _getDistanceToBezierEdge2(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n via1: Point,\n via2: Point\n ): number {\n // x3,y3 is the point\n let minDistance = 1e9;\n let lastX = x1;\n let lastY = y1;\n const vec = [0, 0, 0, 0];\n for (let i = 1; i < 10; i++) {\n const t = 0.1 * i;\n vec[0] = Math.pow(1 - t, 3);\n vec[1] = 3 * t * Math.pow(1 - t, 2);\n vec[2] = 3 * Math.pow(t, 2) * (1 - t);\n vec[3] = Math.pow(t, 3);\n const x = vec[0] * x1 + vec[1] * via1.x + vec[2] * via2.x + vec[3] * x2;\n const y = vec[0] * y1 + vec[1] * via1.y + vec[2] * via2.y + vec[3] * y2;\n if (i > 0) {\n const distance = this._getDistanceToLine(lastX, lastY, x, y, x3, y3);\n minDistance = distance < minDistance ? distance : minDistance;\n }\n lastX = x;\n lastY = y;\n }\n\n return minDistance;\n }\n}\n","import { CubicBezierEdgeBase } from \"./util/cubic-bezier-edge-base\";\nimport {\n EdgeFormattingValues,\n Label,\n EdgeOptions,\n Point,\n PointT,\n SelectiveRequired,\n VBody,\n VNode,\n} from \"./util/types\";\n\n/**\n * A Cubic Bezier Edge. Bezier curves are used to model smooth gradual curves in paths between nodes.\n */\nexport class CubicBezierEdge extends CubicBezierEdgeBase<[Point, Point]> {\n /**\n * Create a new instance.\n *\n * @param options - The options object of given edge.\n * @param body - The body of the network.\n * @param labelModule - Label module.\n */\n public constructor(options: EdgeOptions, body: VBody, labelModule: Label) {\n super(options, body, labelModule);\n }\n\n /** @inheritDoc */\n protected _line(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n | \"backgroundColor\"\n | \"backgroundSize\"\n | \"shadowColor\"\n | \"shadowSize\"\n | \"shadowX\"\n | \"shadowY\"\n >,\n viaNodes: [Point, Point]\n ): void {\n // get the coordinates of the support points.\n const via1 = viaNodes[0];\n const via2 = viaNodes[1];\n this._bezierCurve(ctx, values, via1, via2);\n }\n\n /**\n * Compute the additional points the edge passes through.\n *\n * @returns Cartesian coordinates of the points the edge passes through.\n */\n protected _getViaCoordinates(): [Point, Point] {\n const dx = this.from.x - this.to.x;\n const dy = this.from.y - this.to.y;\n\n let x1: number;\n let y1: number;\n let x2: number;\n let y2: number;\n const roundness = this.options.smooth.roundness;\n\n // horizontal if x > y or if direction is forced or if direction is horizontal\n if (\n (Math.abs(dx) > Math.abs(dy) ||\n this.options.smooth.forceDirection === true ||\n this.options.smooth.forceDirection === \"horizontal\") &&\n this.options.smooth.forceDirection !== \"vertical\"\n ) {\n y1 = this.from.y;\n y2 = this.to.y;\n x1 = this.from.x - roundness * dx;\n x2 = this.to.x + roundness * dx;\n } else {\n y1 = this.from.y - roundness * dy;\n y2 = this.to.y + roundness * dy;\n x1 = this.from.x;\n x2 = this.to.x;\n }\n\n return [\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ];\n }\n\n /** @inheritDoc */\n public getViaNode(): [Point, Point] {\n return this._getViaCoordinates();\n }\n\n /** @inheritDoc */\n protected _findBorderPosition(\n nearNode: VNode,\n ctx: CanvasRenderingContext2D\n ): PointT {\n return this._findBorderPositionBezier(nearNode, ctx);\n }\n\n /** @inheritDoc */\n protected _getDistanceToEdge(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n [via1, via2]: [Point, Point] = this._getViaCoordinates()\n ): number {\n // x3,y3 is the point\n return this._getDistanceToBezierEdge2(x1, y1, x2, y2, x3, y3, via1, via2);\n }\n\n /** @inheritDoc */\n public getPoint(\n position: number,\n [via1, via2]: [Point, Point] = this._getViaCoordinates()\n ): Point {\n const t = position;\n const vec: [number, number, number, number] = [\n Math.pow(1 - t, 3),\n 3 * t * Math.pow(1 - t, 2),\n 3 * Math.pow(t, 2) * (1 - t),\n Math.pow(t, 3),\n ];\n const x =\n vec[0] * this.fromPoint.x +\n vec[1] * via1.x +\n vec[2] * via2.x +\n vec[3] * this.toPoint.x;\n const y =\n vec[0] * this.fromPoint.y +\n vec[1] * via1.y +\n vec[2] * via2.y +\n vec[3] * this.toPoint.y;\n\n return { x: x, y: y };\n }\n}\n","import { EdgeBase } from \"./util/edge-base\";\nimport {\n EdgeFormattingValues,\n Label,\n EdgeOptions,\n Point,\n PointT,\n SelectiveRequired,\n VBody,\n VNode,\n} from \"./util/types\";\n\n/**\n * A Straight Edge.\n */\nexport class StraightEdge extends EdgeBase {\n /**\n * Create a new instance.\n *\n * @param options - The options object of given edge.\n * @param body - The body of the network.\n * @param labelModule - Label module.\n */\n public constructor(options: EdgeOptions, body: VBody, labelModule: Label) {\n super(options, body, labelModule);\n }\n\n /** @inheritDoc */\n protected _line(\n ctx: CanvasRenderingContext2D,\n values: SelectiveRequired<\n EdgeFormattingValues,\n \"shadowColor\" | \"shadowSize\" | \"shadowX\" | \"shadowY\"\n >\n ): void {\n // draw a straight line\n ctx.beginPath();\n ctx.moveTo(this.fromPoint.x, this.fromPoint.y);\n ctx.lineTo(this.toPoint.x, this.toPoint.y);\n // draw shadow if enabled\n this.enableShadow(ctx, values);\n ctx.stroke();\n this.disableShadow(ctx, values);\n }\n\n /** @inheritDoc */\n public getViaNode(): undefined {\n return undefined;\n }\n\n /** @inheritDoc */\n public getPoint(position: number): Point {\n return {\n x: (1 - position) * this.fromPoint.x + position * this.toPoint.x,\n y: (1 - position) * this.fromPoint.y + position * this.toPoint.y,\n };\n }\n\n /** @inheritDoc */\n protected _findBorderPosition(\n nearNode: VNode,\n ctx: CanvasRenderingContext2D\n ): PointT {\n let node1 = this.to;\n let node2 = this.from;\n if (nearNode.id === this.from.id) {\n node1 = this.from;\n node2 = this.to;\n }\n\n const angle = Math.atan2(node1.y - node2.y, node1.x - node2.x);\n const dx = node1.x - node2.x;\n const dy = node1.y - node2.y;\n const edgeSegmentLength = Math.sqrt(dx * dx + dy * dy);\n const toBorderDist = nearNode.distanceToBorder(ctx, angle);\n const toBorderPoint =\n (edgeSegmentLength - toBorderDist) / edgeSegmentLength;\n\n return {\n x: (1 - toBorderPoint) * node2.x + toBorderPoint * node1.x,\n y: (1 - toBorderPoint) * node2.y + toBorderPoint * node1.y,\n t: 0,\n };\n }\n\n /** @inheritDoc */\n protected _getDistanceToEdge(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): number {\n // x3,y3 is the point\n return this._getDistanceToLine(x1, y1, x2, y2, x3, y3);\n }\n}\n","import {\n bridgeObject,\n deepExtend,\n isString,\n mergeOptions,\n selectiveDeepExtend,\n} from \"vis-util/esnext\";\nimport Label from \"./shared/Label\";\nimport {\n choosify,\n getSelfRefCoordinates,\n isValidLabel,\n pointInRect,\n} from \"./shared/ComponentUtil\";\nimport {\n BezierEdgeDynamic,\n BezierEdgeStatic,\n CubicBezierEdge,\n StraightEdge,\n} from \"./edges\";\n\n/**\n * An edge connects two nodes and has a specific direction.\n */\nclass Edge {\n /**\n * @param {object} options values specific to this edge, must contain at least 'from' and 'to'\n * @param {object} body shared state from Network instance\n * @param {Network.Images} imagelist A list with images. Only needed when the edge has image arrows.\n * @param {object} globalOptions options from the EdgesHandler instance\n * @param {object} defaultOptions default options from the EdgeHandler instance. Value and reference are constant\n */\n constructor(options, body, imagelist, globalOptions, defaultOptions) {\n if (body === undefined) {\n throw new Error(\"No body provided\");\n }\n\n // Since globalOptions is constant in values as well as reference,\n // Following needs to be done only once.\n\n this.options = bridgeObject(globalOptions);\n this.globalOptions = globalOptions;\n this.defaultOptions = defaultOptions;\n this.body = body;\n this.imagelist = imagelist;\n\n // initialize variables\n this.id = undefined;\n this.fromId = undefined;\n this.toId = undefined;\n this.selected = false;\n this.hover = false;\n this.labelDirty = true;\n\n this.baseWidth = this.options.width;\n this.baseFontSize = this.options.font.size;\n\n this.from = undefined; // a node\n this.to = undefined; // a node\n\n this.edgeType = undefined;\n\n this.connected = false;\n\n this.labelModule = new Label(\n this.body,\n this.options,\n true /* It's an edge label */\n );\n this.setOptions(options);\n }\n\n /**\n * Set or overwrite options for the edge\n *\n * @param {object} options an object with options\n * @returns {undefined|boolean} undefined if no options, true if layout affecting data changed, false otherwise.\n */\n setOptions(options) {\n if (!options) {\n return;\n }\n\n // Following options if changed affect the layout.\n let affectsLayout =\n (typeof options.physics !== \"undefined\" &&\n this.options.physics !== options.physics) ||\n (typeof options.hidden !== \"undefined\" &&\n (this.options.hidden || false) !== (options.hidden || false)) ||\n (typeof options.from !== \"undefined\" &&\n this.options.from !== options.from) ||\n (typeof options.to !== \"undefined\" && this.options.to !== options.to);\n\n Edge.parseOptions(this.options, options, true, this.globalOptions);\n\n if (options.id !== undefined) {\n this.id = options.id;\n }\n if (options.from !== undefined) {\n this.fromId = options.from;\n }\n if (options.to !== undefined) {\n this.toId = options.to;\n }\n if (options.title !== undefined) {\n this.title = options.title;\n }\n if (options.value !== undefined) {\n options.value = parseFloat(options.value);\n }\n\n const pile = [options, this.options, this.defaultOptions];\n this.chooser = choosify(\"edge\", pile);\n\n // update label Module\n this.updateLabelModule(options);\n\n // Update edge type, this if changed affects the layout.\n affectsLayout = this.updateEdgeType() || affectsLayout;\n\n // if anything has been updates, reset the selection width and the hover width\n this._setInteractionWidths();\n\n // A node is connected when it has a from and to node that both exist in the network.body.nodes.\n this.connect();\n\n return affectsLayout;\n }\n\n /**\n *\n * @param {object} parentOptions\n * @param {object} newOptions\n * @param {boolean} [allowDeletion=false]\n * @param {object} [globalOptions={}]\n * @param {boolean} [copyFromGlobals=false]\n */\n static parseOptions(\n parentOptions,\n newOptions,\n allowDeletion = false,\n globalOptions = {},\n copyFromGlobals = false\n ) {\n const fields = [\n \"endPointOffset\",\n \"arrowStrikethrough\",\n \"id\",\n \"from\",\n \"hidden\",\n \"hoverWidth\",\n \"labelHighlightBold\",\n \"length\",\n \"line\",\n \"opacity\",\n \"physics\",\n \"scaling\",\n \"selectionWidth\",\n \"selfReferenceSize\",\n \"selfReference\",\n \"to\",\n \"title\",\n \"value\",\n \"width\",\n \"font\",\n \"chosen\",\n \"widthConstraint\",\n ];\n\n // only deep extend the items in the field array. These do not have shorthand.\n selectiveDeepExtend(fields, parentOptions, newOptions, allowDeletion);\n\n // Only use endPointOffset values (from and to) if it's valid values\n if (\n newOptions.endPointOffset !== undefined &&\n newOptions.endPointOffset.from !== undefined\n ) {\n if (Number.isFinite(newOptions.endPointOffset.from)) {\n parentOptions.endPointOffset.from = newOptions.endPointOffset.from;\n } else {\n parentOptions.endPointOffset.from =\n globalOptions.endPointOffset.from !== undefined\n ? globalOptions.endPointOffset.from\n : 0;\n console.error(\"endPointOffset.from is not a valid number\");\n }\n }\n\n if (\n newOptions.endPointOffset !== undefined &&\n newOptions.endPointOffset.to !== undefined\n ) {\n if (Number.isFinite(newOptions.endPointOffset.to)) {\n parentOptions.endPointOffset.to = newOptions.endPointOffset.to;\n } else {\n parentOptions.endPointOffset.to =\n globalOptions.endPointOffset.to !== undefined\n ? globalOptions.endPointOffset.to\n : 0;\n console.error(\"endPointOffset.to is not a valid number\");\n }\n }\n\n // Only copy label if it's a legal value.\n if (isValidLabel(newOptions.label)) {\n parentOptions.label = newOptions.label;\n } else if (!isValidLabel(parentOptions.label)) {\n parentOptions.label = undefined;\n }\n\n mergeOptions(parentOptions, newOptions, \"smooth\", globalOptions);\n mergeOptions(parentOptions, newOptions, \"shadow\", globalOptions);\n mergeOptions(parentOptions, newOptions, \"background\", globalOptions);\n\n if (newOptions.dashes !== undefined && newOptions.dashes !== null) {\n parentOptions.dashes = newOptions.dashes;\n } else if (allowDeletion === true && newOptions.dashes === null) {\n parentOptions.dashes = Object.create(globalOptions.dashes); // this sets the pointer of the option back to the global option.\n }\n\n // set the scaling newOptions\n if (newOptions.scaling !== undefined && newOptions.scaling !== null) {\n if (newOptions.scaling.min !== undefined) {\n parentOptions.scaling.min = newOptions.scaling.min;\n }\n if (newOptions.scaling.max !== undefined) {\n parentOptions.scaling.max = newOptions.scaling.max;\n }\n mergeOptions(\n parentOptions.scaling,\n newOptions.scaling,\n \"label\",\n globalOptions.scaling\n );\n } else if (allowDeletion === true && newOptions.scaling === null) {\n parentOptions.scaling = Object.create(globalOptions.scaling); // this sets the pointer of the option back to the global option.\n }\n\n // handle multiple input cases for arrows\n if (newOptions.arrows !== undefined && newOptions.arrows !== null) {\n if (typeof newOptions.arrows === \"string\") {\n const arrows = newOptions.arrows.toLowerCase();\n parentOptions.arrows.to.enabled = arrows.indexOf(\"to\") != -1;\n parentOptions.arrows.middle.enabled = arrows.indexOf(\"middle\") != -1;\n parentOptions.arrows.from.enabled = arrows.indexOf(\"from\") != -1;\n } else if (typeof newOptions.arrows === \"object\") {\n mergeOptions(\n parentOptions.arrows,\n newOptions.arrows,\n \"to\",\n globalOptions.arrows\n );\n mergeOptions(\n parentOptions.arrows,\n newOptions.arrows,\n \"middle\",\n globalOptions.arrows\n );\n mergeOptions(\n parentOptions.arrows,\n newOptions.arrows,\n \"from\",\n globalOptions.arrows\n );\n } else {\n throw new Error(\n \"The arrow newOptions can only be an object or a string. Refer to the documentation. You used:\" +\n JSON.stringify(newOptions.arrows)\n );\n }\n } else if (allowDeletion === true && newOptions.arrows === null) {\n parentOptions.arrows = Object.create(globalOptions.arrows); // this sets the pointer of the option back to the global option.\n }\n\n // handle multiple input cases for color\n if (newOptions.color !== undefined && newOptions.color !== null) {\n const fromColor = isString(newOptions.color)\n ? {\n color: newOptions.color,\n highlight: newOptions.color,\n hover: newOptions.color,\n inherit: false,\n opacity: 1,\n }\n : newOptions.color;\n const toColor = parentOptions.color;\n\n // If passed, fill in values from default options - required in the case of no prototype bridging\n if (copyFromGlobals) {\n deepExtend(toColor, globalOptions.color, false, allowDeletion);\n } else {\n // Clear local properties - need to do it like this in order to retain prototype bridges\n for (const i in toColor) {\n if (Object.prototype.hasOwnProperty.call(toColor, i)) {\n delete toColor[i];\n }\n }\n }\n\n if (isString(toColor)) {\n toColor.color = toColor;\n toColor.highlight = toColor;\n toColor.hover = toColor;\n toColor.inherit = false;\n if (fromColor.opacity === undefined) {\n toColor.opacity = 1.0; // set default\n }\n } else {\n let colorsDefined = false;\n if (fromColor.color !== undefined) {\n toColor.color = fromColor.color;\n colorsDefined = true;\n }\n if (fromColor.highlight !== undefined) {\n toColor.highlight = fromColor.highlight;\n colorsDefined = true;\n }\n if (fromColor.hover !== undefined) {\n toColor.hover = fromColor.hover;\n colorsDefined = true;\n }\n if (fromColor.inherit !== undefined) {\n toColor.inherit = fromColor.inherit;\n }\n if (fromColor.opacity !== undefined) {\n toColor.opacity = Math.min(1, Math.max(0, fromColor.opacity));\n }\n\n if (colorsDefined === true) {\n toColor.inherit = false;\n } else {\n if (toColor.inherit === undefined) {\n toColor.inherit = \"from\"; // Set default\n }\n }\n }\n } else if (allowDeletion === true && newOptions.color === null) {\n parentOptions.color = bridgeObject(globalOptions.color); // set the object back to the global options\n }\n\n if (allowDeletion === true && newOptions.font === null) {\n parentOptions.font = bridgeObject(globalOptions.font); // set the object back to the global options\n }\n\n if (Object.prototype.hasOwnProperty.call(newOptions, \"selfReferenceSize\")) {\n console.warn(\n \"The selfReferenceSize property has been deprecated. Please use selfReference property instead. The selfReference can be set like thise selfReference:{size:30, angle:Math.PI / 4}\"\n );\n parentOptions.selfReference.size = newOptions.selfReferenceSize;\n }\n }\n\n /**\n *\n * @returns {ArrowOptions}\n */\n getFormattingValues() {\n const toArrow =\n this.options.arrows.to === true ||\n this.options.arrows.to.enabled === true;\n const fromArrow =\n this.options.arrows.from === true ||\n this.options.arrows.from.enabled === true;\n const middleArrow =\n this.options.arrows.middle === true ||\n this.options.arrows.middle.enabled === true;\n const inheritsColor = this.options.color.inherit;\n const values = {\n toArrow: toArrow,\n toArrowScale: this.options.arrows.to.scaleFactor,\n toArrowType: this.options.arrows.to.type,\n toArrowSrc: this.options.arrows.to.src,\n toArrowImageWidth: this.options.arrows.to.imageWidth,\n toArrowImageHeight: this.options.arrows.to.imageHeight,\n middleArrow: middleArrow,\n middleArrowScale: this.options.arrows.middle.scaleFactor,\n middleArrowType: this.options.arrows.middle.type,\n middleArrowSrc: this.options.arrows.middle.src,\n middleArrowImageWidth: this.options.arrows.middle.imageWidth,\n middleArrowImageHeight: this.options.arrows.middle.imageHeight,\n fromArrow: fromArrow,\n fromArrowScale: this.options.arrows.from.scaleFactor,\n fromArrowType: this.options.arrows.from.type,\n fromArrowSrc: this.options.arrows.from.src,\n fromArrowImageWidth: this.options.arrows.from.imageWidth,\n fromArrowImageHeight: this.options.arrows.from.imageHeight,\n arrowStrikethrough: this.options.arrowStrikethrough,\n color: inheritsColor ? undefined : this.options.color.color,\n inheritsColor: inheritsColor,\n opacity: this.options.color.opacity,\n hidden: this.options.hidden,\n length: this.options.length,\n shadow: this.options.shadow.enabled,\n shadowColor: this.options.shadow.color,\n shadowSize: this.options.shadow.size,\n shadowX: this.options.shadow.x,\n shadowY: this.options.shadow.y,\n dashes: this.options.dashes,\n width: this.options.width,\n background: this.options.background.enabled,\n backgroundColor: this.options.background.color,\n backgroundSize: this.options.background.size,\n backgroundDashes: this.options.background.dashes,\n };\n if (this.selected || this.hover) {\n if (this.chooser === true) {\n if (this.selected) {\n const selectedWidth = this.options.selectionWidth;\n if (typeof selectedWidth === \"function\") {\n values.width = selectedWidth(values.width);\n } else if (typeof selectedWidth === \"number\") {\n values.width += selectedWidth;\n }\n values.width = Math.max(values.width, 0.3 / this.body.view.scale);\n values.color = this.options.color.highlight;\n values.shadow = this.options.shadow.enabled;\n } else if (this.hover) {\n const hoverWidth = this.options.hoverWidth;\n if (typeof hoverWidth === \"function\") {\n values.width = hoverWidth(values.width);\n } else if (typeof hoverWidth === \"number\") {\n values.width += hoverWidth;\n }\n values.width = Math.max(values.width, 0.3 / this.body.view.scale);\n values.color = this.options.color.hover;\n values.shadow = this.options.shadow.enabled;\n }\n } else if (typeof this.chooser === \"function\") {\n this.chooser(values, this.options.id, this.selected, this.hover);\n if (values.color !== undefined) {\n values.inheritsColor = false;\n }\n if (values.shadow === false) {\n if (\n values.shadowColor !== this.options.shadow.color ||\n values.shadowSize !== this.options.shadow.size ||\n values.shadowX !== this.options.shadow.x ||\n values.shadowY !== this.options.shadow.y\n ) {\n values.shadow = true;\n }\n }\n }\n } else {\n values.shadow = this.options.shadow.enabled;\n values.width = Math.max(values.width, 0.3 / this.body.view.scale);\n }\n return values;\n }\n\n /**\n * update the options in the label module\n *\n * @param {object} options\n */\n updateLabelModule(options) {\n const pile = [\n options,\n this.options,\n this.globalOptions, // Currently set global edge options\n this.defaultOptions,\n ];\n\n this.labelModule.update(this.options, pile);\n\n if (this.labelModule.baseSize !== undefined) {\n this.baseFontSize = this.labelModule.baseSize;\n }\n }\n\n /**\n * update the edge type, set the options\n *\n * @returns {boolean}\n */\n updateEdgeType() {\n const smooth = this.options.smooth;\n let dataChanged = false;\n let changeInType = true;\n if (this.edgeType !== undefined) {\n if (\n (this.edgeType instanceof BezierEdgeDynamic &&\n smooth.enabled === true &&\n smooth.type === \"dynamic\") ||\n (this.edgeType instanceof CubicBezierEdge &&\n smooth.enabled === true &&\n smooth.type === \"cubicBezier\") ||\n (this.edgeType instanceof BezierEdgeStatic &&\n smooth.enabled === true &&\n smooth.type !== \"dynamic\" &&\n smooth.type !== \"cubicBezier\") ||\n (this.edgeType instanceof StraightEdge && smooth.type.enabled === false)\n ) {\n changeInType = false;\n }\n if (changeInType === true) {\n dataChanged = this.cleanup();\n }\n }\n if (changeInType === true) {\n if (smooth.enabled === true) {\n if (smooth.type === \"dynamic\") {\n dataChanged = true;\n this.edgeType = new BezierEdgeDynamic(\n this.options,\n this.body,\n this.labelModule\n );\n } else if (smooth.type === \"cubicBezier\") {\n this.edgeType = new CubicBezierEdge(\n this.options,\n this.body,\n this.labelModule\n );\n } else {\n this.edgeType = new BezierEdgeStatic(\n this.options,\n this.body,\n this.labelModule\n );\n }\n } else {\n this.edgeType = new StraightEdge(\n this.options,\n this.body,\n this.labelModule\n );\n }\n } else {\n // if nothing changes, we just set the options.\n this.edgeType.setOptions(this.options);\n }\n return dataChanged;\n }\n\n /**\n * Connect an edge to its nodes\n */\n connect() {\n this.disconnect();\n\n this.from = this.body.nodes[this.fromId] || undefined;\n this.to = this.body.nodes[this.toId] || undefined;\n this.connected = this.from !== undefined && this.to !== undefined;\n\n if (this.connected === true) {\n this.from.attachEdge(this);\n this.to.attachEdge(this);\n } else {\n if (this.from) {\n this.from.detachEdge(this);\n }\n if (this.to) {\n this.to.detachEdge(this);\n }\n }\n\n this.edgeType.connect();\n }\n\n /**\n * Disconnect an edge from its nodes\n */\n disconnect() {\n if (this.from) {\n this.from.detachEdge(this);\n this.from = undefined;\n }\n if (this.to) {\n this.to.detachEdge(this);\n this.to = undefined;\n }\n\n this.connected = false;\n }\n\n /**\n * get the title of this edge.\n *\n * @returns {string} title The title of the edge, or undefined when no title\n * has been set.\n */\n getTitle() {\n return this.title;\n }\n\n /**\n * check if this node is selecte\n *\n * @returns {boolean} selected True if node is selected, else false\n */\n isSelected() {\n return this.selected;\n }\n\n /**\n * Retrieve the value of the edge. Can be undefined\n *\n * @returns {number} value\n */\n getValue() {\n return this.options.value;\n }\n\n /**\n * Adjust the value range of the edge. The edge will adjust it's width\n * based on its value.\n *\n * @param {number} min\n * @param {number} max\n * @param {number} total\n */\n setValueRange(min, max, total) {\n if (this.options.value !== undefined) {\n const scale = this.options.scaling.customScalingFunction(\n min,\n max,\n total,\n this.options.value\n );\n const widthDiff = this.options.scaling.max - this.options.scaling.min;\n if (this.options.scaling.label.enabled === true) {\n const fontDiff =\n this.options.scaling.label.max - this.options.scaling.label.min;\n this.options.font.size =\n this.options.scaling.label.min + scale * fontDiff;\n }\n this.options.width = this.options.scaling.min + scale * widthDiff;\n } else {\n this.options.width = this.baseWidth;\n this.options.font.size = this.baseFontSize;\n }\n\n this._setInteractionWidths();\n this.updateLabelModule();\n }\n\n /**\n *\n * @private\n */\n _setInteractionWidths() {\n if (typeof this.options.hoverWidth === \"function\") {\n this.edgeType.hoverWidth = this.options.hoverWidth(this.options.width);\n } else {\n this.edgeType.hoverWidth = this.options.hoverWidth + this.options.width;\n }\n if (typeof this.options.selectionWidth === \"function\") {\n this.edgeType.selectionWidth = this.options.selectionWidth(\n this.options.width\n );\n } else {\n this.edgeType.selectionWidth =\n this.options.selectionWidth + this.options.width;\n }\n }\n\n /**\n * Redraw a edge\n * Draw this edge in the given canvas\n * The 2d context of a HTML canvas can be retrieved by canvas.getContext(\"2d\");\n *\n * @param {CanvasRenderingContext2D} ctx\n */\n draw(ctx) {\n const values = this.getFormattingValues();\n if (values.hidden) {\n return;\n }\n\n // get the via node from the edge type\n const viaNode = this.edgeType.getViaNode();\n\n // draw line and label\n this.edgeType.drawLine(ctx, values, this.selected, this.hover, viaNode);\n this.drawLabel(ctx, viaNode);\n }\n\n /**\n * Redraw arrows\n * Draw this arrows in the given canvas\n * The 2d context of a HTML canvas can be retrieved by canvas.getContext(\"2d\");\n *\n * @param {CanvasRenderingContext2D} ctx\n */\n drawArrows(ctx) {\n const values = this.getFormattingValues();\n if (values.hidden) {\n return;\n }\n\n // get the via node from the edge type\n const viaNode = this.edgeType.getViaNode();\n const arrowData = {};\n\n // restore edge targets to defaults\n this.edgeType.fromPoint = this.edgeType.from;\n this.edgeType.toPoint = this.edgeType.to;\n\n // from and to arrows give a different end point for edges. we set them here\n if (values.fromArrow) {\n arrowData.from = this.edgeType.getArrowData(\n ctx,\n \"from\",\n viaNode,\n this.selected,\n this.hover,\n values\n );\n if (values.arrowStrikethrough === false)\n this.edgeType.fromPoint = arrowData.from.core;\n if (values.fromArrowSrc) {\n arrowData.from.image = this.imagelist.load(values.fromArrowSrc);\n }\n if (values.fromArrowImageWidth) {\n arrowData.from.imageWidth = values.fromArrowImageWidth;\n }\n if (values.fromArrowImageHeight) {\n arrowData.from.imageHeight = values.fromArrowImageHeight;\n }\n }\n if (values.toArrow) {\n arrowData.to = this.edgeType.getArrowData(\n ctx,\n \"to\",\n viaNode,\n this.selected,\n this.hover,\n values\n );\n if (values.arrowStrikethrough === false)\n this.edgeType.toPoint = arrowData.to.core;\n if (values.toArrowSrc) {\n arrowData.to.image = this.imagelist.load(values.toArrowSrc);\n }\n if (values.toArrowImageWidth) {\n arrowData.to.imageWidth = values.toArrowImageWidth;\n }\n if (values.toArrowImageHeight) {\n arrowData.to.imageHeight = values.toArrowImageHeight;\n }\n }\n\n // the middle arrow depends on the line, which can depend on the to and from arrows so we do this one lastly.\n if (values.middleArrow) {\n arrowData.middle = this.edgeType.getArrowData(\n ctx,\n \"middle\",\n viaNode,\n this.selected,\n this.hover,\n values\n );\n\n if (values.middleArrowSrc) {\n arrowData.middle.image = this.imagelist.load(values.middleArrowSrc);\n }\n if (values.middleArrowImageWidth) {\n arrowData.middle.imageWidth = values.middleArrowImageWidth;\n }\n if (values.middleArrowImageHeight) {\n arrowData.middle.imageHeight = values.middleArrowImageHeight;\n }\n }\n\n if (values.fromArrow) {\n this.edgeType.drawArrowHead(\n ctx,\n values,\n this.selected,\n this.hover,\n arrowData.from\n );\n }\n if (values.middleArrow) {\n this.edgeType.drawArrowHead(\n ctx,\n values,\n this.selected,\n this.hover,\n arrowData.middle\n );\n }\n if (values.toArrow) {\n this.edgeType.drawArrowHead(\n ctx,\n values,\n this.selected,\n this.hover,\n arrowData.to\n );\n }\n }\n\n /**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {Node} viaNode\n */\n drawLabel(ctx, viaNode) {\n if (this.options.label !== undefined) {\n // set style\n const node1 = this.from;\n const node2 = this.to;\n\n if (this.labelModule.differentState(this.selected, this.hover)) {\n this.labelModule.getTextSize(ctx, this.selected, this.hover);\n }\n\n let point;\n if (node1.id != node2.id) {\n this.labelModule.pointToSelf = false;\n point = this.edgeType.getPoint(0.5, viaNode);\n ctx.save();\n\n const rotationPoint = this._getRotation(ctx);\n if (rotationPoint.angle != 0) {\n ctx.translate(rotationPoint.x, rotationPoint.y);\n ctx.rotate(rotationPoint.angle);\n }\n\n // draw the label\n this.labelModule.draw(ctx, point.x, point.y, this.selected, this.hover);\n\n /*\n // Useful debug code: draw a border around the label\n // This should **not** be enabled in production!\n var size = this.labelModule.getSize();; // ;; intentional so lint catches it\n ctx.strokeStyle = \"#ff0000\";\n ctx.strokeRect(size.left, size.top, size.width, size.height);\n // End debug code\n*/\n\n ctx.restore();\n } else {\n // Ignore the orientations.\n this.labelModule.pointToSelf = true;\n\n // get circle coordinates\n const coordinates = getSelfRefCoordinates(\n ctx,\n this.options.selfReference.angle,\n this.options.selfReference.size,\n node1\n );\n\n point = this._pointOnCircle(\n coordinates.x,\n coordinates.y,\n this.options.selfReference.size,\n this.options.selfReference.angle\n );\n\n this.labelModule.draw(ctx, point.x, point.y, this.selected, this.hover);\n }\n }\n }\n\n /**\n * Determine all visual elements of this edge instance, in which the given\n * point falls within the bounding shape.\n *\n * @param {point} point\n * @returns {Array.<edgeClickItem|edgeLabelClickItem>} list with the items which are on the point\n */\n getItemsOnPoint(point) {\n const ret = [];\n\n if (this.labelModule.visible()) {\n const rotationPoint = this._getRotation();\n if (pointInRect(this.labelModule.getSize(), point, rotationPoint)) {\n ret.push({ edgeId: this.id, labelId: 0 });\n }\n }\n\n const obj = {\n left: point.x,\n top: point.y,\n };\n\n if (this.isOverlappingWith(obj)) {\n ret.push({ edgeId: this.id });\n }\n\n return ret;\n }\n\n /**\n * Check if this object is overlapping with the provided object\n *\n * @param {object} obj an object with parameters left, top\n * @returns {boolean} True if location is located on the edge\n */\n isOverlappingWith(obj) {\n if (this.connected) {\n const distMax = 10;\n const xFrom = this.from.x;\n const yFrom = this.from.y;\n const xTo = this.to.x;\n const yTo = this.to.y;\n const xObj = obj.left;\n const yObj = obj.top;\n\n const dist = this.edgeType.getDistanceToEdge(\n xFrom,\n yFrom,\n xTo,\n yTo,\n xObj,\n yObj\n );\n\n return dist < distMax;\n } else {\n return false;\n }\n }\n\n /**\n * Determine the rotation point, if any.\n *\n * @param {CanvasRenderingContext2D} [ctx] if passed, do a recalculation of the label size\n * @returns {rotationPoint} the point to rotate around and the angle in radians to rotate\n * @private\n */\n _getRotation(ctx) {\n const viaNode = this.edgeType.getViaNode();\n const point = this.edgeType.getPoint(0.5, viaNode);\n\n if (ctx !== undefined) {\n this.labelModule.calculateLabelSize(\n ctx,\n this.selected,\n this.hover,\n point.x,\n point.y\n );\n }\n\n const ret = {\n x: point.x,\n y: this.labelModule.size.yLine,\n angle: 0,\n };\n\n if (!this.labelModule.visible()) {\n return ret; // Don't even bother doing the atan2, there's nothing to draw\n }\n\n if (this.options.font.align === \"horizontal\") {\n return ret; // No need to calculate angle\n }\n\n const dy = this.from.y - this.to.y;\n const dx = this.from.x - this.to.x;\n let angle = Math.atan2(dy, dx); // radians\n\n // rotate so that label is readable\n if ((angle < -1 && dx < 0) || (angle > 0 && dx < 0)) {\n angle += Math.PI;\n }\n ret.angle = angle;\n\n return ret;\n }\n\n /**\n * Get a point on a circle\n *\n * @param {number} x\n * @param {number} y\n * @param {number} radius\n * @param {number} angle\n * @returns {object} point\n * @private\n */\n _pointOnCircle(x, y, radius, angle) {\n return {\n x: x + radius * Math.cos(angle),\n y: y - radius * Math.sin(angle),\n };\n }\n\n /**\n * Sets selected state to true\n */\n select() {\n this.selected = true;\n }\n\n /**\n * Sets selected state to false\n */\n unselect() {\n this.selected = false;\n }\n\n /**\n * cleans all required things on delete\n *\n * @returns {*}\n */\n cleanup() {\n return this.edgeType.cleanup();\n }\n\n /**\n * Remove edge from the list and perform necessary cleanup.\n */\n remove() {\n this.cleanup();\n this.disconnect();\n delete this.body.edges[this.id];\n }\n\n /**\n * Check if both connecting nodes exist\n *\n * @returns {boolean}\n */\n endPointsValid() {\n return (\n this.body.nodes[this.fromId] !== undefined &&\n this.body.nodes[this.toId] !== undefined\n );\n }\n}\n\nexport default Edge;\n","import { deepExtend, forEach } from \"vis-util/esnext\";\nimport { DataSet, isDataViewLike } from \"vis-data/esnext\";\nimport Edge from \"./components/Edge\";\n\n/**\n * Handler for Edges\n */\nclass EdgesHandler {\n /**\n * @param {object} body\n * @param {Array.<Image>} images\n * @param {Array.<Group>} groups\n */\n constructor(body, images, groups) {\n this.body = body;\n this.images = images;\n this.groups = groups;\n\n // create the edge API in the body container\n this.body.functions.createEdge = this.create.bind(this);\n\n this.edgesListeners = {\n add: (event, params) => {\n this.add(params.items);\n },\n update: (event, params) => {\n this.update(params.items);\n },\n remove: (event, params) => {\n this.remove(params.items);\n },\n };\n\n this.options = {};\n this.defaultOptions = {\n arrows: {\n to: { enabled: false, scaleFactor: 1, type: \"arrow\" }, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}\n middle: { enabled: false, scaleFactor: 1, type: \"arrow\" },\n from: { enabled: false, scaleFactor: 1, type: \"arrow\" },\n },\n endPointOffset: {\n from: 0,\n to: 0,\n },\n arrowStrikethrough: true,\n color: {\n color: \"#848484\",\n highlight: \"#848484\",\n hover: \"#848484\",\n inherit: \"from\",\n opacity: 1.0,\n },\n dashes: false,\n font: {\n color: \"#343434\",\n size: 14, // px\n face: \"arial\",\n background: \"none\",\n strokeWidth: 2, // px\n strokeColor: \"#ffffff\",\n align: \"horizontal\",\n multi: false,\n vadjust: 0,\n bold: {\n mod: \"bold\",\n },\n boldital: {\n mod: \"bold italic\",\n },\n ital: {\n mod: \"italic\",\n },\n mono: {\n mod: \"\",\n size: 15, // px\n face: \"courier new\",\n vadjust: 2,\n },\n },\n hidden: false,\n hoverWidth: 1.5,\n label: undefined,\n labelHighlightBold: true,\n length: undefined,\n physics: true,\n scaling: {\n min: 1,\n max: 15,\n label: {\n enabled: true,\n min: 14,\n max: 30,\n maxVisible: 30,\n drawThreshold: 5,\n },\n customScalingFunction: function (min, max, total, value) {\n if (max === min) {\n return 0.5;\n } else {\n const scale = 1 / (max - min);\n return Math.max(0, (value - min) * scale);\n }\n },\n },\n selectionWidth: 1.5,\n selfReference: {\n size: 20,\n angle: Math.PI / 4,\n renderBehindTheNode: true,\n },\n shadow: {\n enabled: false,\n color: \"rgba(0,0,0,0.5)\",\n size: 10,\n x: 5,\n y: 5,\n },\n background: {\n enabled: false,\n color: \"rgba(111,111,111,1)\",\n size: 10,\n dashes: false,\n },\n smooth: {\n enabled: true,\n type: \"dynamic\",\n forceDirection: \"none\",\n roundness: 0.5,\n },\n title: undefined,\n width: 1,\n value: undefined,\n };\n\n deepExtend(this.options, this.defaultOptions);\n\n this.bindEventListeners();\n }\n\n /**\n * Binds event listeners\n */\n bindEventListeners() {\n // this allows external modules to force all dynamic curves to turn static.\n this.body.emitter.on(\"_forceDisableDynamicCurves\", (type, emit = true) => {\n if (type === \"dynamic\") {\n type = \"continuous\";\n }\n let dataChanged = false;\n for (const edgeId in this.body.edges) {\n if (Object.prototype.hasOwnProperty.call(this.body.edges, edgeId)) {\n const edge = this.body.edges[edgeId];\n const edgeData = this.body.data.edges.get(edgeId);\n\n // only forcibly remove the smooth curve if the data has been set of the edge has the smooth curves defined.\n // this is because a change in the global would not affect these curves.\n if (edgeData != null) {\n const smoothOptions = edgeData.smooth;\n if (smoothOptions !== undefined) {\n if (\n smoothOptions.enabled === true &&\n smoothOptions.type === \"dynamic\"\n ) {\n if (type === undefined) {\n edge.setOptions({ smooth: false });\n } else {\n edge.setOptions({ smooth: { type: type } });\n }\n dataChanged = true;\n }\n }\n }\n }\n }\n if (emit === true && dataChanged === true) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n });\n\n // this is called when options of EXISTING nodes or edges have changed.\n //\n // NOTE: Not true, called when options have NOT changed, for both existing as well as new nodes.\n // See update() for logic.\n // TODO: Verify and examine the consequences of this. It might still trigger when\n // non-option fields have changed, but then reconnecting edges is still useless.\n // Alternatively, it might also be called when edges are removed.\n //\n this.body.emitter.on(\"_dataUpdated\", () => {\n this.reconnectEdges();\n });\n\n // refresh the edges. Used when reverting from hierarchical layout\n this.body.emitter.on(\"refreshEdges\", this.refresh.bind(this));\n this.body.emitter.on(\"refresh\", this.refresh.bind(this));\n this.body.emitter.on(\"destroy\", () => {\n forEach(this.edgesListeners, (callback, event) => {\n if (this.body.data.edges) this.body.data.edges.off(event, callback);\n });\n delete this.body.functions.createEdge;\n delete this.edgesListeners.add;\n delete this.edgesListeners.update;\n delete this.edgesListeners.remove;\n delete this.edgesListeners;\n });\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n if (options !== undefined) {\n // use the parser from the Edge class to fill in all shorthand notations\n Edge.parseOptions(this.options, options, true, this.defaultOptions, true);\n\n // update smooth settings in all edges\n let dataChanged = false;\n if (options.smooth !== undefined) {\n for (const edgeId in this.body.edges) {\n if (Object.prototype.hasOwnProperty.call(this.body.edges, edgeId)) {\n dataChanged =\n this.body.edges[edgeId].updateEdgeType() || dataChanged;\n }\n }\n }\n\n // update fonts in all edges\n if (options.font !== undefined) {\n for (const edgeId in this.body.edges) {\n if (Object.prototype.hasOwnProperty.call(this.body.edges, edgeId)) {\n this.body.edges[edgeId].updateLabelModule();\n }\n }\n }\n\n // update the state of the variables if needed\n if (\n options.hidden !== undefined ||\n options.physics !== undefined ||\n dataChanged === true\n ) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n }\n\n /**\n * Load edges by reading the data table\n *\n * @param {Array | DataSet | DataView} edges The data containing the edges.\n * @param {boolean} [doNotEmit=false] - Suppress data changed event.\n * @private\n */\n setData(edges, doNotEmit = false) {\n const oldEdgesData = this.body.data.edges;\n\n if (isDataViewLike(\"id\", edges)) {\n this.body.data.edges = edges;\n } else if (Array.isArray(edges)) {\n this.body.data.edges = new DataSet();\n this.body.data.edges.add(edges);\n } else if (!edges) {\n this.body.data.edges = new DataSet();\n } else {\n throw new TypeError(\"Array or DataSet expected\");\n }\n\n // TODO: is this null or undefined or false?\n if (oldEdgesData) {\n // unsubscribe from old dataset\n forEach(this.edgesListeners, (callback, event) => {\n oldEdgesData.off(event, callback);\n });\n }\n\n // remove drawn edges\n this.body.edges = {};\n\n // TODO: is this null or undefined or false?\n if (this.body.data.edges) {\n // subscribe to new dataset\n forEach(this.edgesListeners, (callback, event) => {\n this.body.data.edges.on(event, callback);\n });\n\n // draw all new nodes\n const ids = this.body.data.edges.getIds();\n this.add(ids, true);\n }\n\n this.body.emitter.emit(\"_adjustEdgesForHierarchicalLayout\");\n if (doNotEmit === false) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n * Add edges\n *\n * @param {number[] | string[]} ids\n * @param {boolean} [doNotEmit=false]\n * @private\n */\n add(ids, doNotEmit = false) {\n const edges = this.body.edges;\n const edgesData = this.body.data.edges;\n\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i];\n\n const oldEdge = edges[id];\n if (oldEdge) {\n oldEdge.disconnect();\n }\n\n const data = edgesData.get(id, { showInternalIds: true });\n edges[id] = this.create(data);\n }\n\n this.body.emitter.emit(\"_adjustEdgesForHierarchicalLayout\");\n\n if (doNotEmit === false) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n * Update existing edges, or create them when not yet existing\n *\n * @param {number[] | string[]} ids\n * @private\n */\n update(ids) {\n const edges = this.body.edges;\n const edgesData = this.body.data.edges;\n let dataChanged = false;\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i];\n const data = edgesData.get(id);\n const edge = edges[id];\n if (edge !== undefined) {\n // update edge\n edge.disconnect();\n dataChanged = edge.setOptions(data) || dataChanged; // if a support node is added, data can be changed.\n edge.connect();\n } else {\n // create edge\n this.body.edges[id] = this.create(data);\n dataChanged = true;\n }\n }\n\n if (dataChanged === true) {\n this.body.emitter.emit(\"_adjustEdgesForHierarchicalLayout\");\n this.body.emitter.emit(\"_dataChanged\");\n } else {\n this.body.emitter.emit(\"_dataUpdated\");\n }\n }\n\n /**\n * Remove existing edges. Non existing ids will be ignored\n *\n * @param {number[] | string[]} ids\n * @param {boolean} [emit=true]\n * @private\n */\n remove(ids, emit = true) {\n if (ids.length === 0) return; // early out\n\n const edges = this.body.edges;\n forEach(ids, (id) => {\n const edge = edges[id];\n if (edge !== undefined) {\n edge.remove();\n }\n });\n\n if (emit) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n * Refreshes Edge Handler\n */\n refresh() {\n forEach(this.body.edges, (edge, edgeId) => {\n const data = this.body.data.edges.get(edgeId);\n if (data !== undefined) {\n edge.setOptions(data);\n }\n });\n }\n\n /**\n *\n * @param {object} properties\n * @returns {Edge}\n */\n create(properties) {\n return new Edge(\n properties,\n this.body,\n this.images,\n this.options,\n this.defaultOptions\n );\n }\n\n /**\n * Reconnect all edges\n *\n * @private\n */\n reconnectEdges() {\n let id;\n const nodes = this.body.nodes;\n const edges = this.body.edges;\n\n for (id in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, id)) {\n nodes[id].edges = [];\n }\n }\n\n for (id in edges) {\n if (Object.prototype.hasOwnProperty.call(edges, id)) {\n const edge = edges[id];\n edge.from = null;\n edge.to = null;\n edge.connect();\n }\n }\n }\n\n /**\n *\n * @param {Edge.id} edgeId\n * @returns {Array}\n */\n getConnectedNodes(edgeId) {\n const nodeList = [];\n if (this.body.edges[edgeId] !== undefined) {\n const edge = this.body.edges[edgeId];\n if (edge.fromId !== undefined) {\n nodeList.push(edge.fromId);\n }\n if (edge.toId !== undefined) {\n nodeList.push(edge.toId);\n }\n }\n return nodeList;\n }\n\n /**\n * There is no direct relation between the nodes and the edges DataSet,\n * so the right place to do call this is in the handler for event `_dataUpdated`.\n */\n _updateState() {\n this._addMissingEdges();\n this._removeInvalidEdges();\n }\n\n /**\n * Scan for missing nodes and remove corresponding edges, if any.\n *\n * @private\n */\n _removeInvalidEdges() {\n const edgesToDelete = [];\n\n forEach(this.body.edges, (edge, id) => {\n const toNode = this.body.nodes[edge.toId];\n const fromNode = this.body.nodes[edge.fromId];\n\n // Skip clustering edges here, let the Clustering module handle those\n if (\n (toNode !== undefined && toNode.isCluster === true) ||\n (fromNode !== undefined && fromNode.isCluster === true)\n ) {\n return;\n }\n\n if (toNode === undefined || fromNode === undefined) {\n edgesToDelete.push(id);\n }\n });\n\n this.remove(edgesToDelete, false);\n }\n\n /**\n * add all edges from dataset that are not in the cached state\n *\n * @private\n */\n _addMissingEdges() {\n const edgesData = this.body.data.edges;\n if (edgesData === undefined || edgesData === null) {\n return; // No edges DataSet yet; can happen on startup\n }\n\n const edges = this.body.edges;\n const addIds = [];\n\n edgesData.forEach((edgeData, edgeId) => {\n const edge = edges[edgeId];\n if (edge === undefined) {\n addIds.push(edgeId);\n }\n });\n\n this.add(addIds, true);\n }\n}\n\nexport default EdgesHandler;\n","import { Alea } from \"vis-util/esnext\";\n\n/**\n * Barnes Hut Solver\n */\nclass BarnesHutSolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n this.body = body;\n this.physicsBody = physicsBody;\n this.barnesHutTree;\n this.setOptions(options);\n this._rng = Alea(\"BARNES HUT SOLVER\");\n\n // debug: show grid\n // this.body.emitter.on(\"afterDrawing\", (ctx) => {this._debug(ctx,'#ff0000')})\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n this.options = options;\n this.thetaInversed = 1 / this.options.theta;\n\n // if 1 then min distance = 0.5, if 0.5 then min distance = 0.5 + 0.5*node.shape.radius\n this.overlapAvoidanceFactor =\n 1 - Math.max(0, Math.min(1, this.options.avoidOverlap));\n }\n\n /**\n * This function calculates the forces the nodes apply on each other based on a gravitational model.\n * The Barnes Hut method is used to speed up this N-body simulation.\n *\n * @private\n */\n solve() {\n if (\n this.options.gravitationalConstant !== 0 &&\n this.physicsBody.physicsNodeIndices.length > 0\n ) {\n let node;\n const nodes = this.body.nodes;\n const nodeIndices = this.physicsBody.physicsNodeIndices;\n const nodeCount = nodeIndices.length;\n\n // create the tree\n const barnesHutTree = this._formBarnesHutTree(nodes, nodeIndices);\n\n // for debugging\n this.barnesHutTree = barnesHutTree;\n\n // place the nodes one by one recursively\n for (let i = 0; i < nodeCount; i++) {\n node = nodes[nodeIndices[i]];\n if (node.options.mass > 0) {\n // starting with root is irrelevant, it never passes the BarnesHutSolver condition\n this._getForceContributions(barnesHutTree.root, node);\n }\n }\n }\n }\n\n /**\n * @param {object} parentBranch\n * @param {Node} node\n * @private\n */\n _getForceContributions(parentBranch, node) {\n this._getForceContribution(parentBranch.children.NW, node);\n this._getForceContribution(parentBranch.children.NE, node);\n this._getForceContribution(parentBranch.children.SW, node);\n this._getForceContribution(parentBranch.children.SE, node);\n }\n\n /**\n * This function traverses the barnesHutTree. It checks when it can approximate distant nodes with their center of mass.\n * If a region contains a single node, we check if it is not itself, then we apply the force.\n *\n * @param {object} parentBranch\n * @param {Node} node\n * @private\n */\n _getForceContribution(parentBranch, node) {\n // we get no force contribution from an empty region\n if (parentBranch.childrenCount > 0) {\n // get the distance from the center of mass to the node.\n const dx = parentBranch.centerOfMass.x - node.x;\n const dy = parentBranch.centerOfMass.y - node.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n // BarnesHutSolver condition\n // original condition : s/d < theta = passed === d/s > 1/theta = passed\n // calcSize = 1/s --> d * 1/s > 1/theta = passed\n if (distance * parentBranch.calcSize > this.thetaInversed) {\n this._calculateForces(distance, dx, dy, node, parentBranch);\n } else {\n // Did not pass the condition, go into children if available\n if (parentBranch.childrenCount === 4) {\n this._getForceContributions(parentBranch, node);\n } else {\n // parentBranch must have only one node, if it was empty we wouldnt be here\n if (parentBranch.children.data.id != node.id) {\n // if it is not self\n this._calculateForces(distance, dx, dy, node, parentBranch);\n }\n }\n }\n }\n }\n\n /**\n * Calculate the forces based on the distance.\n *\n * @param {number} distance\n * @param {number} dx\n * @param {number} dy\n * @param {Node} node\n * @param {object} parentBranch\n * @private\n */\n _calculateForces(distance, dx, dy, node, parentBranch) {\n if (distance === 0) {\n distance = 0.1;\n dx = distance;\n }\n\n if (this.overlapAvoidanceFactor < 1 && node.shape.radius) {\n distance = Math.max(\n 0.1 + this.overlapAvoidanceFactor * node.shape.radius,\n distance - node.shape.radius\n );\n }\n\n // the dividing by the distance cubed instead of squared allows us to get the fx and fy components without sines and cosines\n // it is shorthand for gravityforce with distance squared and fx = dx/distance * gravityForce\n const gravityForce =\n (this.options.gravitationalConstant *\n parentBranch.mass *\n node.options.mass) /\n Math.pow(distance, 3);\n const fx = dx * gravityForce;\n const fy = dy * gravityForce;\n\n this.physicsBody.forces[node.id].x += fx;\n this.physicsBody.forces[node.id].y += fy;\n }\n\n /**\n * This function constructs the barnesHut tree recursively. It creates the root, splits it and starts placing the nodes.\n *\n * @param {Array.<Node>} nodes\n * @param {Array.<number>} nodeIndices\n * @returns {{root: {centerOfMass: {x: number, y: number}, mass: number, range: {minX: number, maxX: number, minY: number, maxY: number}, size: number, calcSize: number, children: {data: null}, maxWidth: number, level: number, childrenCount: number}}} BarnesHutTree\n * @private\n */\n _formBarnesHutTree(nodes, nodeIndices) {\n let node;\n const nodeCount = nodeIndices.length;\n\n let minX = nodes[nodeIndices[0]].x;\n let minY = nodes[nodeIndices[0]].y;\n let maxX = nodes[nodeIndices[0]].x;\n let maxY = nodes[nodeIndices[0]].y;\n\n // get the range of the nodes\n for (let i = 1; i < nodeCount; i++) {\n const node = nodes[nodeIndices[i]];\n const x = node.x;\n const y = node.y;\n if (node.options.mass > 0) {\n if (x < minX) {\n minX = x;\n }\n if (x > maxX) {\n maxX = x;\n }\n if (y < minY) {\n minY = y;\n }\n if (y > maxY) {\n maxY = y;\n }\n }\n }\n // make the range a square\n const sizeDiff = Math.abs(maxX - minX) - Math.abs(maxY - minY); // difference between X and Y\n if (sizeDiff > 0) {\n minY -= 0.5 * sizeDiff;\n maxY += 0.5 * sizeDiff;\n } // xSize > ySize\n else {\n minX += 0.5 * sizeDiff;\n maxX -= 0.5 * sizeDiff;\n } // xSize < ySize\n\n const minimumTreeSize = 1e-5;\n const rootSize = Math.max(minimumTreeSize, Math.abs(maxX - minX));\n const halfRootSize = 0.5 * rootSize;\n const centerX = 0.5 * (minX + maxX),\n centerY = 0.5 * (minY + maxY);\n\n // construct the barnesHutTree\n const barnesHutTree = {\n root: {\n centerOfMass: { x: 0, y: 0 },\n mass: 0,\n range: {\n minX: centerX - halfRootSize,\n maxX: centerX + halfRootSize,\n minY: centerY - halfRootSize,\n maxY: centerY + halfRootSize,\n },\n size: rootSize,\n calcSize: 1 / rootSize,\n children: { data: null },\n maxWidth: 0,\n level: 0,\n childrenCount: 4,\n },\n };\n this._splitBranch(barnesHutTree.root);\n\n // place the nodes one by one recursively\n for (let i = 0; i < nodeCount; i++) {\n node = nodes[nodeIndices[i]];\n if (node.options.mass > 0) {\n this._placeInTree(barnesHutTree.root, node);\n }\n }\n\n // make global\n return barnesHutTree;\n }\n\n /**\n * this updates the mass of a branch. this is increased by adding a node.\n *\n * @param {object} parentBranch\n * @param {Node} node\n * @private\n */\n _updateBranchMass(parentBranch, node) {\n const centerOfMass = parentBranch.centerOfMass;\n const totalMass = parentBranch.mass + node.options.mass;\n const totalMassInv = 1 / totalMass;\n\n centerOfMass.x =\n centerOfMass.x * parentBranch.mass + node.x * node.options.mass;\n centerOfMass.x *= totalMassInv;\n\n centerOfMass.y =\n centerOfMass.y * parentBranch.mass + node.y * node.options.mass;\n centerOfMass.y *= totalMassInv;\n\n parentBranch.mass = totalMass;\n const biggestSize = Math.max(\n Math.max(node.height, node.radius),\n node.width\n );\n parentBranch.maxWidth =\n parentBranch.maxWidth < biggestSize ? biggestSize : parentBranch.maxWidth;\n }\n\n /**\n * determine in which branch the node will be placed.\n *\n * @param {object} parentBranch\n * @param {Node} node\n * @param {boolean} skipMassUpdate\n * @private\n */\n _placeInTree(parentBranch, node, skipMassUpdate) {\n if (skipMassUpdate != true || skipMassUpdate === undefined) {\n // update the mass of the branch.\n this._updateBranchMass(parentBranch, node);\n }\n\n const range = parentBranch.children.NW.range;\n let region;\n if (range.maxX > node.x) {\n // in NW or SW\n if (range.maxY > node.y) {\n region = \"NW\";\n } else {\n region = \"SW\";\n }\n } else {\n // in NE or SE\n if (range.maxY > node.y) {\n region = \"NE\";\n } else {\n region = \"SE\";\n }\n }\n\n this._placeInRegion(parentBranch, node, region);\n }\n\n /**\n * actually place the node in a region (or branch)\n *\n * @param {object} parentBranch\n * @param {Node} node\n * @param {'NW'| 'NE' | 'SW' | 'SE'} region\n * @private\n */\n _placeInRegion(parentBranch, node, region) {\n const children = parentBranch.children[region];\n\n switch (children.childrenCount) {\n case 0: // place node here\n children.children.data = node;\n children.childrenCount = 1;\n this._updateBranchMass(children, node);\n break;\n case 1: // convert into children\n // if there are two nodes exactly overlapping (on init, on opening of cluster etc.)\n // we move one node a little bit and we do not put it in the tree.\n if (\n children.children.data.x === node.x &&\n children.children.data.y === node.y\n ) {\n node.x += this._rng();\n node.y += this._rng();\n } else {\n this._splitBranch(children);\n this._placeInTree(children, node);\n }\n break;\n case 4: // place in branch\n this._placeInTree(children, node);\n break;\n }\n }\n\n /**\n * this function splits a branch into 4 sub branches. If the branch contained a node, we place it in the subbranch\n * after the split is complete.\n *\n * @param {object} parentBranch\n * @private\n */\n _splitBranch(parentBranch) {\n // if the branch is shaded with a node, replace the node in the new subset.\n let containedNode = null;\n if (parentBranch.childrenCount === 1) {\n containedNode = parentBranch.children.data;\n parentBranch.mass = 0;\n parentBranch.centerOfMass.x = 0;\n parentBranch.centerOfMass.y = 0;\n }\n parentBranch.childrenCount = 4;\n parentBranch.children.data = null;\n this._insertRegion(parentBranch, \"NW\");\n this._insertRegion(parentBranch, \"NE\");\n this._insertRegion(parentBranch, \"SW\");\n this._insertRegion(parentBranch, \"SE\");\n\n if (containedNode != null) {\n this._placeInTree(parentBranch, containedNode);\n }\n }\n\n /**\n * This function subdivides the region into four new segments.\n * Specifically, this inserts a single new segment.\n * It fills the children section of the parentBranch\n *\n * @param {object} parentBranch\n * @param {'NW'| 'NE' | 'SW' | 'SE'} region\n * @private\n */\n _insertRegion(parentBranch, region) {\n let minX, maxX, minY, maxY;\n const childSize = 0.5 * parentBranch.size;\n switch (region) {\n case \"NW\":\n minX = parentBranch.range.minX;\n maxX = parentBranch.range.minX + childSize;\n minY = parentBranch.range.minY;\n maxY = parentBranch.range.minY + childSize;\n break;\n case \"NE\":\n minX = parentBranch.range.minX + childSize;\n maxX = parentBranch.range.maxX;\n minY = parentBranch.range.minY;\n maxY = parentBranch.range.minY + childSize;\n break;\n case \"SW\":\n minX = parentBranch.range.minX;\n maxX = parentBranch.range.minX + childSize;\n minY = parentBranch.range.minY + childSize;\n maxY = parentBranch.range.maxY;\n break;\n case \"SE\":\n minX = parentBranch.range.minX + childSize;\n maxX = parentBranch.range.maxX;\n minY = parentBranch.range.minY + childSize;\n maxY = parentBranch.range.maxY;\n break;\n }\n\n parentBranch.children[region] = {\n centerOfMass: { x: 0, y: 0 },\n mass: 0,\n range: { minX: minX, maxX: maxX, minY: minY, maxY: maxY },\n size: 0.5 * parentBranch.size,\n calcSize: 2 * parentBranch.calcSize,\n children: { data: null },\n maxWidth: 0,\n level: parentBranch.level + 1,\n childrenCount: 0,\n };\n }\n\n //--------------------------- DEBUGGING BELOW ---------------------------//\n\n /**\n * This function is for debugging purposed, it draws the tree.\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {string} color\n * @private\n */\n _debug(ctx, color) {\n if (this.barnesHutTree !== undefined) {\n ctx.lineWidth = 1;\n\n this._drawBranch(this.barnesHutTree.root, ctx, color);\n }\n }\n\n /**\n * This function is for debugging purposes. It draws the branches recursively.\n *\n * @param {object} branch\n * @param {CanvasRenderingContext2D} ctx\n * @param {string} color\n * @private\n */\n _drawBranch(branch, ctx, color) {\n if (color === undefined) {\n color = \"#FF0000\";\n }\n\n if (branch.childrenCount === 4) {\n this._drawBranch(branch.children.NW, ctx);\n this._drawBranch(branch.children.NE, ctx);\n this._drawBranch(branch.children.SE, ctx);\n this._drawBranch(branch.children.SW, ctx);\n }\n ctx.strokeStyle = color;\n ctx.beginPath();\n ctx.moveTo(branch.range.minX, branch.range.minY);\n ctx.lineTo(branch.range.maxX, branch.range.minY);\n ctx.stroke();\n\n ctx.beginPath();\n ctx.moveTo(branch.range.maxX, branch.range.minY);\n ctx.lineTo(branch.range.maxX, branch.range.maxY);\n ctx.stroke();\n\n ctx.beginPath();\n ctx.moveTo(branch.range.maxX, branch.range.maxY);\n ctx.lineTo(branch.range.minX, branch.range.maxY);\n ctx.stroke();\n\n ctx.beginPath();\n ctx.moveTo(branch.range.minX, branch.range.maxY);\n ctx.lineTo(branch.range.minX, branch.range.minY);\n ctx.stroke();\n\n /*\n if (branch.mass > 0) {\n ctx.circle(branch.centerOfMass.x, branch.centerOfMass.y, 3*branch.mass);\n ctx.stroke();\n }\n */\n }\n}\n\nexport default BarnesHutSolver;\n","import { Alea } from \"vis-util/esnext\";\n\n/**\n * Repulsion Solver\n */\nclass RepulsionSolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n this._rng = Alea(\"REPULSION SOLVER\");\n\n this.body = body;\n this.physicsBody = physicsBody;\n this.setOptions(options);\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n * Calculate the forces the nodes apply on each other based on a repulsion field.\n * This field is linearly approximated.\n *\n * @private\n */\n solve() {\n let dx, dy, distance, fx, fy, repulsingForce, node1, node2;\n\n const nodes = this.body.nodes;\n const nodeIndices = this.physicsBody.physicsNodeIndices;\n const forces = this.physicsBody.forces;\n\n // repulsing forces between nodes\n const nodeDistance = this.options.nodeDistance;\n\n // approximation constants\n const a = -2 / 3 / nodeDistance;\n const b = 4 / 3;\n\n // we loop from i over all but the last entree in the array\n // j loops from i+1 to the last. This way we do not double count any of the indices, nor i === j\n for (let i = 0; i < nodeIndices.length - 1; i++) {\n node1 = nodes[nodeIndices[i]];\n for (let j = i + 1; j < nodeIndices.length; j++) {\n node2 = nodes[nodeIndices[j]];\n\n dx = node2.x - node1.x;\n dy = node2.y - node1.y;\n distance = Math.sqrt(dx * dx + dy * dy);\n\n // same condition as BarnesHutSolver, making sure nodes are never 100% overlapping.\n if (distance === 0) {\n distance = 0.1 * this._rng();\n dx = distance;\n }\n\n if (distance < 2 * nodeDistance) {\n if (distance < 0.5 * nodeDistance) {\n repulsingForce = 1.0;\n } else {\n repulsingForce = a * distance + b; // linear approx of 1 / (1 + Math.exp((distance / nodeDistance - 1) * steepness))\n }\n repulsingForce = repulsingForce / distance;\n\n fx = dx * repulsingForce;\n fy = dy * repulsingForce;\n\n forces[node1.id].x -= fx;\n forces[node1.id].y -= fy;\n forces[node2.id].x += fx;\n forces[node2.id].y += fy;\n }\n }\n }\n }\n}\n\nexport default RepulsionSolver;\n","/**\n * Hierarchical Repulsion Solver\n */\nclass HierarchicalRepulsionSolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n this.body = body;\n this.physicsBody = physicsBody;\n this.setOptions(options);\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n this.options = options;\n this.overlapAvoidanceFactor = Math.max(\n 0,\n Math.min(1, this.options.avoidOverlap || 0)\n );\n }\n\n /**\n * Calculate the forces the nodes apply on each other based on a repulsion field.\n * This field is linearly approximated.\n *\n * @private\n */\n solve() {\n const nodes = this.body.nodes;\n const nodeIndices = this.physicsBody.physicsNodeIndices;\n const forces = this.physicsBody.forces;\n\n // repulsing forces between nodes\n const nodeDistance = this.options.nodeDistance;\n\n // we loop from i over all but the last entree in the array\n // j loops from i+1 to the last. This way we do not double count any of the indices, nor i === j\n for (let i = 0; i < nodeIndices.length - 1; i++) {\n const node1 = nodes[nodeIndices[i]];\n for (let j = i + 1; j < nodeIndices.length; j++) {\n const node2 = nodes[nodeIndices[j]];\n\n // nodes only affect nodes on their level\n if (node1.level === node2.level) {\n const theseNodesDistance =\n nodeDistance +\n this.overlapAvoidanceFactor *\n ((node1.shape.radius || 0) / 2 + (node2.shape.radius || 0) / 2);\n\n const dx = node2.x - node1.x;\n const dy = node2.y - node1.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n const steepness = 0.05;\n let repulsingForce;\n if (distance < theseNodesDistance) {\n repulsingForce =\n -Math.pow(steepness * distance, 2) +\n Math.pow(steepness * theseNodesDistance, 2);\n } else {\n repulsingForce = 0;\n }\n // normalize force with\n if (distance !== 0) {\n repulsingForce = repulsingForce / distance;\n }\n const fx = dx * repulsingForce;\n const fy = dy * repulsingForce;\n\n forces[node1.id].x -= fx;\n forces[node1.id].y -= fy;\n forces[node2.id].x += fx;\n forces[node2.id].y += fy;\n }\n }\n }\n }\n}\n\nexport default HierarchicalRepulsionSolver;\n","/**\n * Spring Solver\n */\nclass SpringSolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n this.body = body;\n this.physicsBody = physicsBody;\n this.setOptions(options);\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n * This function calculates the springforces on the nodes, accounting for the support nodes.\n *\n * @private\n */\n solve() {\n let edgeLength, edge;\n const edgeIndices = this.physicsBody.physicsEdgeIndices;\n const edges = this.body.edges;\n let node1, node2, node3;\n\n // forces caused by the edges, modelled as springs\n for (let i = 0; i < edgeIndices.length; i++) {\n edge = edges[edgeIndices[i]];\n if (edge.connected === true && edge.toId !== edge.fromId) {\n // only calculate forces if nodes are in the same sector\n if (\n this.body.nodes[edge.toId] !== undefined &&\n this.body.nodes[edge.fromId] !== undefined\n ) {\n if (edge.edgeType.via !== undefined) {\n edgeLength =\n edge.options.length === undefined\n ? this.options.springLength\n : edge.options.length;\n node1 = edge.to;\n node2 = edge.edgeType.via;\n node3 = edge.from;\n\n this._calculateSpringForce(node1, node2, 0.5 * edgeLength);\n this._calculateSpringForce(node2, node3, 0.5 * edgeLength);\n } else {\n // the * 1.5 is here so the edge looks as large as a smooth edge. It does not initially because the smooth edges use\n // the support nodes which exert a repulsive force on the to and from nodes, making the edge appear larger.\n edgeLength =\n edge.options.length === undefined\n ? this.options.springLength * 1.5\n : edge.options.length;\n this._calculateSpringForce(edge.from, edge.to, edgeLength);\n }\n }\n }\n }\n }\n\n /**\n * This is the code actually performing the calculation for the function above.\n *\n * @param {Node} node1\n * @param {Node} node2\n * @param {number} edgeLength\n * @private\n */\n _calculateSpringForce(node1, node2, edgeLength) {\n const dx = node1.x - node2.x;\n const dy = node1.y - node2.y;\n const distance = Math.max(Math.sqrt(dx * dx + dy * dy), 0.01);\n\n // the 1/distance is so the fx and fy can be calculated without sine or cosine.\n const springForce =\n (this.options.springConstant * (edgeLength - distance)) / distance;\n\n const fx = dx * springForce;\n const fy = dy * springForce;\n\n // handle the case where one node is not part of the physcis\n if (this.physicsBody.forces[node1.id] !== undefined) {\n this.physicsBody.forces[node1.id].x += fx;\n this.physicsBody.forces[node1.id].y += fy;\n }\n\n if (this.physicsBody.forces[node2.id] !== undefined) {\n this.physicsBody.forces[node2.id].x -= fx;\n this.physicsBody.forces[node2.id].y -= fy;\n }\n }\n}\n\nexport default SpringSolver;\n","/**\n * Hierarchical Spring Solver\n */\nclass HierarchicalSpringSolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n this.body = body;\n this.physicsBody = physicsBody;\n this.setOptions(options);\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n * This function calculates the springforces on the nodes, accounting for the support nodes.\n *\n * @private\n */\n solve() {\n let edgeLength, edge;\n let dx, dy, fx, fy, springForce, distance;\n const edges = this.body.edges;\n const factor = 0.5;\n\n const edgeIndices = this.physicsBody.physicsEdgeIndices;\n const nodeIndices = this.physicsBody.physicsNodeIndices;\n const forces = this.physicsBody.forces;\n\n // initialize the spring force counters\n for (let i = 0; i < nodeIndices.length; i++) {\n const nodeId = nodeIndices[i];\n forces[nodeId].springFx = 0;\n forces[nodeId].springFy = 0;\n }\n\n // forces caused by the edges, modelled as springs\n for (let i = 0; i < edgeIndices.length; i++) {\n edge = edges[edgeIndices[i]];\n if (edge.connected === true) {\n edgeLength =\n edge.options.length === undefined\n ? this.options.springLength\n : edge.options.length;\n\n dx = edge.from.x - edge.to.x;\n dy = edge.from.y - edge.to.y;\n distance = Math.sqrt(dx * dx + dy * dy);\n distance = distance === 0 ? 0.01 : distance;\n\n // the 1/distance is so the fx and fy can be calculated without sine or cosine.\n springForce =\n (this.options.springConstant * (edgeLength - distance)) / distance;\n\n fx = dx * springForce;\n fy = dy * springForce;\n\n if (edge.to.level != edge.from.level) {\n if (forces[edge.toId] !== undefined) {\n forces[edge.toId].springFx -= fx;\n forces[edge.toId].springFy -= fy;\n }\n if (forces[edge.fromId] !== undefined) {\n forces[edge.fromId].springFx += fx;\n forces[edge.fromId].springFy += fy;\n }\n } else {\n if (forces[edge.toId] !== undefined) {\n forces[edge.toId].x -= factor * fx;\n forces[edge.toId].y -= factor * fy;\n }\n if (forces[edge.fromId] !== undefined) {\n forces[edge.fromId].x += factor * fx;\n forces[edge.fromId].y += factor * fy;\n }\n }\n }\n }\n\n // normalize spring forces\n springForce = 1;\n let springFx, springFy;\n for (let i = 0; i < nodeIndices.length; i++) {\n const nodeId = nodeIndices[i];\n springFx = Math.min(\n springForce,\n Math.max(-springForce, forces[nodeId].springFx)\n );\n springFy = Math.min(\n springForce,\n Math.max(-springForce, forces[nodeId].springFy)\n );\n\n forces[nodeId].x += springFx;\n forces[nodeId].y += springFy;\n }\n\n // retain energy balance\n let totalFx = 0;\n let totalFy = 0;\n for (let i = 0; i < nodeIndices.length; i++) {\n const nodeId = nodeIndices[i];\n totalFx += forces[nodeId].x;\n totalFy += forces[nodeId].y;\n }\n const correctionFx = totalFx / nodeIndices.length;\n const correctionFy = totalFy / nodeIndices.length;\n\n for (let i = 0; i < nodeIndices.length; i++) {\n const nodeId = nodeIndices[i];\n forces[nodeId].x -= correctionFx;\n forces[nodeId].y -= correctionFy;\n }\n }\n}\n\nexport default HierarchicalSpringSolver;\n","/**\n * Central Gravity Solver\n */\nclass CentralGravitySolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n this.body = body;\n this.physicsBody = physicsBody;\n this.setOptions(options);\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n * Calculates forces for each node\n */\n solve() {\n let dx, dy, distance, node;\n const nodes = this.body.nodes;\n const nodeIndices = this.physicsBody.physicsNodeIndices;\n const forces = this.physicsBody.forces;\n\n for (let i = 0; i < nodeIndices.length; i++) {\n const nodeId = nodeIndices[i];\n node = nodes[nodeId];\n dx = -node.x;\n dy = -node.y;\n distance = Math.sqrt(dx * dx + dy * dy);\n\n this._calculateForces(distance, dx, dy, forces, node);\n }\n }\n\n /**\n * Calculate the forces based on the distance.\n *\n * @param {number} distance\n * @param {number} dx\n * @param {number} dy\n * @param {object<Node.id, vis.Node>} forces\n * @param {Node} node\n * @private\n */\n _calculateForces(distance, dx, dy, forces, node) {\n const gravityForce =\n distance === 0 ? 0 : this.options.centralGravity / distance;\n forces[node.id].x = dx * gravityForce;\n forces[node.id].y = dy * gravityForce;\n }\n}\n\nexport default CentralGravitySolver;\n","import BarnesHutSolver from \"./BarnesHutSolver\";\nimport { Alea } from \"vis-util/esnext\";\n\n/**\n * @augments BarnesHutSolver\n */\nclass ForceAtlas2BasedRepulsionSolver extends BarnesHutSolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n super(body, physicsBody, options);\n\n this._rng = Alea(\"FORCE ATLAS 2 BASED REPULSION SOLVER\");\n }\n\n /**\n * Calculate the forces based on the distance.\n *\n * @param {number} distance\n * @param {number} dx\n * @param {number} dy\n * @param {Node} node\n * @param {object} parentBranch\n * @private\n */\n _calculateForces(distance, dx, dy, node, parentBranch) {\n if (distance === 0) {\n distance = 0.1 * this._rng();\n dx = distance;\n }\n\n if (this.overlapAvoidanceFactor < 1 && node.shape.radius) {\n distance = Math.max(\n 0.1 + this.overlapAvoidanceFactor * node.shape.radius,\n distance - node.shape.radius\n );\n }\n\n const degree = node.edges.length + 1;\n // the dividing by the distance cubed instead of squared allows us to get the fx and fy components without sines and cosines\n // it is shorthand for gravityforce with distance squared and fx = dx/distance * gravityForce\n const gravityForce =\n (this.options.gravitationalConstant *\n parentBranch.mass *\n node.options.mass *\n degree) /\n Math.pow(distance, 2);\n const fx = dx * gravityForce;\n const fy = dy * gravityForce;\n\n this.physicsBody.forces[node.id].x += fx;\n this.physicsBody.forces[node.id].y += fy;\n }\n}\n\nexport default ForceAtlas2BasedRepulsionSolver;\n","import CentralGravitySolver from \"./CentralGravitySolver\";\n\n/**\n * @augments CentralGravitySolver\n */\nclass ForceAtlas2BasedCentralGravitySolver extends CentralGravitySolver {\n /**\n * @param {object} body\n * @param {{physicsNodeIndices: Array, physicsEdgeIndices: Array, forces: {}, velocities: {}}} physicsBody\n * @param {object} options\n */\n constructor(body, physicsBody, options) {\n super(body, physicsBody, options);\n }\n\n /**\n * Calculate the forces based on the distance.\n *\n * @param {number} distance\n * @param {number} dx\n * @param {number} dy\n * @param {object<Node.id, Node>} forces\n * @param {Node} node\n * @private\n */\n _calculateForces(distance, dx, dy, forces, node) {\n if (distance > 0) {\n const degree = node.edges.length + 1;\n const gravityForce =\n this.options.centralGravity * degree * node.options.mass;\n forces[node.id].x = dx * gravityForce;\n forces[node.id].y = dy * gravityForce;\n }\n }\n}\n\nexport default ForceAtlas2BasedCentralGravitySolver;\n","import BarnesHutSolver from \"./components/physics/BarnesHutSolver\";\nimport Repulsion from \"./components/physics/RepulsionSolver\";\nimport HierarchicalRepulsion from \"./components/physics/HierarchicalRepulsionSolver\";\nimport SpringSolver from \"./components/physics/SpringSolver\";\nimport HierarchicalSpringSolver from \"./components/physics/HierarchicalSpringSolver\";\nimport CentralGravitySolver from \"./components/physics/CentralGravitySolver\";\nimport ForceAtlas2BasedRepulsionSolver from \"./components/physics/FA2BasedRepulsionSolver\";\nimport ForceAtlas2BasedCentralGravitySolver from \"./components/physics/FA2BasedCentralGravitySolver\";\nimport {\n HSVToHex,\n mergeOptions,\n selectiveNotDeepExtend,\n} from \"vis-util/esnext\";\nimport { EndPoints } from \"./components/edges\"; // for debugging with _drawForces()\n\n/**\n * The physics engine\n */\nclass PhysicsEngine {\n /**\n * @param {object} body\n */\n constructor(body) {\n this.body = body;\n this.physicsBody = {\n physicsNodeIndices: [],\n physicsEdgeIndices: [],\n forces: {},\n velocities: {},\n };\n\n this.physicsEnabled = true;\n this.simulationInterval = 1000 / 60;\n this.requiresTimeout = true;\n this.previousStates = {};\n this.referenceState = {};\n this.freezeCache = {};\n this.renderTimer = undefined;\n\n // parameters for the adaptive timestep\n this.adaptiveTimestep = false;\n this.adaptiveTimestepEnabled = false;\n this.adaptiveCounter = 0;\n this.adaptiveInterval = 3;\n\n this.stabilized = false;\n this.startedStabilization = false;\n this.stabilizationIterations = 0;\n this.ready = false; // will be set to true if the stabilize\n\n // default options\n this.options = {};\n this.defaultOptions = {\n enabled: true,\n barnesHut: {\n theta: 0.5,\n gravitationalConstant: -2000,\n centralGravity: 0.3,\n springLength: 95,\n springConstant: 0.04,\n damping: 0.09,\n avoidOverlap: 0,\n },\n forceAtlas2Based: {\n theta: 0.5,\n gravitationalConstant: -50,\n centralGravity: 0.01,\n springConstant: 0.08,\n springLength: 100,\n damping: 0.4,\n avoidOverlap: 0,\n },\n repulsion: {\n centralGravity: 0.2,\n springLength: 200,\n springConstant: 0.05,\n nodeDistance: 100,\n damping: 0.09,\n avoidOverlap: 0,\n },\n hierarchicalRepulsion: {\n centralGravity: 0.0,\n springLength: 100,\n springConstant: 0.01,\n nodeDistance: 120,\n damping: 0.09,\n },\n maxVelocity: 50,\n minVelocity: 0.75, // px/s\n solver: \"barnesHut\",\n stabilization: {\n enabled: true,\n iterations: 1000, // maximum number of iteration to stabilize\n updateInterval: 50,\n onlyDynamicEdges: false,\n fit: true,\n },\n timestep: 0.5,\n adaptiveTimestep: true,\n wind: { x: 0, y: 0 },\n };\n Object.assign(this.options, this.defaultOptions);\n this.timestep = 0.5;\n this.layoutFailed = false;\n\n this.bindEventListeners();\n }\n\n /**\n * Binds event listeners\n */\n bindEventListeners() {\n this.body.emitter.on(\"initPhysics\", () => {\n this.initPhysics();\n });\n this.body.emitter.on(\"_layoutFailed\", () => {\n this.layoutFailed = true;\n });\n this.body.emitter.on(\"resetPhysics\", () => {\n this.stopSimulation();\n this.ready = false;\n });\n this.body.emitter.on(\"disablePhysics\", () => {\n this.physicsEnabled = false;\n this.stopSimulation();\n });\n this.body.emitter.on(\"restorePhysics\", () => {\n this.setOptions(this.options);\n if (this.ready === true) {\n this.startSimulation();\n }\n });\n this.body.emitter.on(\"startSimulation\", () => {\n if (this.ready === true) {\n this.startSimulation();\n }\n });\n this.body.emitter.on(\"stopSimulation\", () => {\n this.stopSimulation();\n });\n this.body.emitter.on(\"destroy\", () => {\n this.stopSimulation(false);\n this.body.emitter.off();\n });\n this.body.emitter.on(\"_dataChanged\", () => {\n // Nodes and/or edges have been added or removed, update shortcut lists.\n this.updatePhysicsData();\n });\n\n // debug: show forces\n // this.body.emitter.on(\"afterDrawing\", (ctx) => {this._drawForces(ctx);});\n }\n\n /**\n * set the physics options\n *\n * @param {object} options\n */\n setOptions(options) {\n if (options !== undefined) {\n if (options === false) {\n this.options.enabled = false;\n this.physicsEnabled = false;\n this.stopSimulation();\n } else if (options === true) {\n this.options.enabled = true;\n this.physicsEnabled = true;\n this.startSimulation();\n } else {\n this.physicsEnabled = true;\n selectiveNotDeepExtend([\"stabilization\"], this.options, options);\n mergeOptions(this.options, options, \"stabilization\");\n\n if (options.enabled === undefined) {\n this.options.enabled = true;\n }\n\n if (this.options.enabled === false) {\n this.physicsEnabled = false;\n this.stopSimulation();\n }\n\n const wind = this.options.wind;\n if (wind) {\n if (typeof wind.x !== \"number\" || Number.isNaN(wind.x)) {\n wind.x = 0;\n }\n if (typeof wind.y !== \"number\" || Number.isNaN(wind.y)) {\n wind.y = 0;\n }\n }\n\n // set the timestep\n this.timestep = this.options.timestep;\n }\n }\n this.init();\n }\n\n /**\n * configure the engine.\n */\n init() {\n let options;\n if (this.options.solver === \"forceAtlas2Based\") {\n options = this.options.forceAtlas2Based;\n this.nodesSolver = new ForceAtlas2BasedRepulsionSolver(\n this.body,\n this.physicsBody,\n options\n );\n this.edgesSolver = new SpringSolver(this.body, this.physicsBody, options);\n this.gravitySolver = new ForceAtlas2BasedCentralGravitySolver(\n this.body,\n this.physicsBody,\n options\n );\n } else if (this.options.solver === \"repulsion\") {\n options = this.options.repulsion;\n this.nodesSolver = new Repulsion(this.body, this.physicsBody, options);\n this.edgesSolver = new SpringSolver(this.body, this.physicsBody, options);\n this.gravitySolver = new CentralGravitySolver(\n this.body,\n this.physicsBody,\n options\n );\n } else if (this.options.solver === \"hierarchicalRepulsion\") {\n options = this.options.hierarchicalRepulsion;\n this.nodesSolver = new HierarchicalRepulsion(\n this.body,\n this.physicsBody,\n options\n );\n this.edgesSolver = new HierarchicalSpringSolver(\n this.body,\n this.physicsBody,\n options\n );\n this.gravitySolver = new CentralGravitySolver(\n this.body,\n this.physicsBody,\n options\n );\n } else {\n // barnesHut\n options = this.options.barnesHut;\n this.nodesSolver = new BarnesHutSolver(\n this.body,\n this.physicsBody,\n options\n );\n this.edgesSolver = new SpringSolver(this.body, this.physicsBody, options);\n this.gravitySolver = new CentralGravitySolver(\n this.body,\n this.physicsBody,\n options\n );\n }\n\n this.modelOptions = options;\n }\n\n /**\n * initialize the engine\n */\n initPhysics() {\n if (this.physicsEnabled === true && this.options.enabled === true) {\n if (this.options.stabilization.enabled === true) {\n this.stabilize();\n } else {\n this.stabilized = false;\n this.ready = true;\n this.body.emitter.emit(\"fit\", {}, this.layoutFailed); // if the layout failed, we use the approximation for the zoom\n this.startSimulation();\n }\n } else {\n this.ready = true;\n this.body.emitter.emit(\"fit\");\n }\n }\n\n /**\n * Start the simulation\n */\n startSimulation() {\n if (this.physicsEnabled === true && this.options.enabled === true) {\n this.stabilized = false;\n\n // when visible, adaptivity is disabled.\n this.adaptiveTimestep = false;\n\n // this sets the width of all nodes initially which could be required for the avoidOverlap\n this.body.emitter.emit(\"_resizeNodes\");\n if (this.viewFunction === undefined) {\n this.viewFunction = this.simulationStep.bind(this);\n this.body.emitter.on(\"initRedraw\", this.viewFunction);\n this.body.emitter.emit(\"_startRendering\");\n }\n } else {\n this.body.emitter.emit(\"_redraw\");\n }\n }\n\n /**\n * Stop the simulation, force stabilization.\n *\n * @param {boolean} [emit=true]\n */\n stopSimulation(emit = true) {\n this.stabilized = true;\n if (emit === true) {\n this._emitStabilized();\n }\n if (this.viewFunction !== undefined) {\n this.body.emitter.off(\"initRedraw\", this.viewFunction);\n this.viewFunction = undefined;\n if (emit === true) {\n this.body.emitter.emit(\"_stopRendering\");\n }\n }\n }\n\n /**\n * The viewFunction inserts this step into each render loop. It calls the physics tick and handles the cleanup at stabilized.\n *\n */\n simulationStep() {\n // check if the physics have settled\n const startTime = Date.now();\n this.physicsTick();\n const physicsTime = Date.now() - startTime;\n\n // run double speed if it is a little graph\n if (\n (physicsTime < 0.4 * this.simulationInterval ||\n this.runDoubleSpeed === true) &&\n this.stabilized === false\n ) {\n this.physicsTick();\n\n // this makes sure there is no jitter. The decision is taken once to run it at double speed.\n this.runDoubleSpeed = true;\n }\n\n if (this.stabilized === true) {\n this.stopSimulation();\n }\n }\n\n /**\n * trigger the stabilized event.\n *\n * @param {number} [amountOfIterations=this.stabilizationIterations]\n * @private\n */\n _emitStabilized(amountOfIterations = this.stabilizationIterations) {\n if (\n this.stabilizationIterations > 1 ||\n this.startedStabilization === true\n ) {\n setTimeout(() => {\n this.body.emitter.emit(\"stabilized\", {\n iterations: amountOfIterations,\n });\n this.startedStabilization = false;\n this.stabilizationIterations = 0;\n }, 0);\n }\n }\n\n /**\n * Calculate the forces for one physics iteration and move the nodes.\n *\n * @private\n */\n physicsStep() {\n this.gravitySolver.solve();\n this.nodesSolver.solve();\n this.edgesSolver.solve();\n this.moveNodes();\n }\n\n /**\n * Make dynamic adjustments to the timestep, based on current state.\n *\n * Helper function for physicsTick().\n *\n * @private\n */\n adjustTimeStep() {\n const factor = 1.2; // Factor for increasing the timestep on success.\n\n // we compare the two steps. if it is acceptable we double the step.\n if (this._evaluateStepQuality() === true) {\n this.timestep = factor * this.timestep;\n } else {\n // if not, we decrease the step to a minimum of the options timestep.\n // if the decreased timestep is smaller than the options step, we do not reset the counter\n // we assume that the options timestep is stable enough.\n if (this.timestep / factor < this.options.timestep) {\n this.timestep = this.options.timestep;\n } else {\n // if the timestep was larger than 2 times the option one we check the adaptivity again to ensure\n // that large instabilities do not form.\n this.adaptiveCounter = -1; // check again next iteration\n this.timestep = Math.max(this.options.timestep, this.timestep / factor);\n }\n }\n }\n\n /**\n * A single simulation step (or 'tick') in the physics simulation\n *\n * @private\n */\n physicsTick() {\n this._startStabilizing(); // this ensures that there is no start event when the network is already stable.\n if (this.stabilized === true) return;\n\n // adaptivity means the timestep adapts to the situation, only applicable for stabilization\n if (\n this.adaptiveTimestep === true &&\n this.adaptiveTimestepEnabled === true\n ) {\n // timestep remains stable for \"interval\" iterations.\n const doAdaptive = this.adaptiveCounter % this.adaptiveInterval === 0;\n\n if (doAdaptive) {\n // first the big step and revert.\n this.timestep = 2 * this.timestep;\n this.physicsStep();\n this.revert(); // saves the reference state\n\n // now the normal step. Since this is the last step, it is the more stable one and we will take this.\n this.timestep = 0.5 * this.timestep;\n\n // since it's half the step, we do it twice.\n this.physicsStep();\n this.physicsStep();\n\n this.adjustTimeStep();\n } else {\n this.physicsStep(); // normal step, keeping timestep constant\n }\n\n this.adaptiveCounter += 1;\n } else {\n // case for the static timestep, we reset it to the one in options and take a normal step.\n this.timestep = this.options.timestep;\n this.physicsStep();\n }\n\n if (this.stabilized === true) this.revert();\n this.stabilizationIterations++;\n }\n\n /**\n * Nodes and edges can have the physics toggles on or off. A collection of indices is created here so we can skip the check all the time.\n *\n * @private\n */\n updatePhysicsData() {\n this.physicsBody.forces = {};\n this.physicsBody.physicsNodeIndices = [];\n this.physicsBody.physicsEdgeIndices = [];\n const nodes = this.body.nodes;\n const edges = this.body.edges;\n\n // get node indices for physics\n for (const nodeId in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, nodeId)) {\n if (nodes[nodeId].options.physics === true) {\n this.physicsBody.physicsNodeIndices.push(nodes[nodeId].id);\n }\n }\n }\n\n // get edge indices for physics\n for (const edgeId in edges) {\n if (Object.prototype.hasOwnProperty.call(edges, edgeId)) {\n if (edges[edgeId].options.physics === true) {\n this.physicsBody.physicsEdgeIndices.push(edges[edgeId].id);\n }\n }\n }\n\n // get the velocity and the forces vector\n for (let i = 0; i < this.physicsBody.physicsNodeIndices.length; i++) {\n const nodeId = this.physicsBody.physicsNodeIndices[i];\n this.physicsBody.forces[nodeId] = { x: 0, y: 0 };\n\n // forces can be reset because they are recalculated. Velocities have to persist.\n if (this.physicsBody.velocities[nodeId] === undefined) {\n this.physicsBody.velocities[nodeId] = { x: 0, y: 0 };\n }\n }\n\n // clean deleted nodes from the velocity vector\n for (const nodeId in this.physicsBody.velocities) {\n if (nodes[nodeId] === undefined) {\n delete this.physicsBody.velocities[nodeId];\n }\n }\n }\n\n /**\n * Revert the simulation one step. This is done so after stabilization, every new start of the simulation will also say stabilized.\n */\n revert() {\n const nodeIds = Object.keys(this.previousStates);\n const nodes = this.body.nodes;\n const velocities = this.physicsBody.velocities;\n this.referenceState = {};\n\n for (let i = 0; i < nodeIds.length; i++) {\n const nodeId = nodeIds[i];\n if (nodes[nodeId] !== undefined) {\n if (nodes[nodeId].options.physics === true) {\n this.referenceState[nodeId] = {\n positions: { x: nodes[nodeId].x, y: nodes[nodeId].y },\n };\n velocities[nodeId].x = this.previousStates[nodeId].vx;\n velocities[nodeId].y = this.previousStates[nodeId].vy;\n nodes[nodeId].x = this.previousStates[nodeId].x;\n nodes[nodeId].y = this.previousStates[nodeId].y;\n }\n } else {\n delete this.previousStates[nodeId];\n }\n }\n }\n\n /**\n * This compares the reference state to the current state\n *\n * @returns {boolean}\n * @private\n */\n _evaluateStepQuality() {\n let dx, dy, dpos;\n const nodes = this.body.nodes;\n const reference = this.referenceState;\n const posThreshold = 0.3;\n\n for (const nodeId in this.referenceState) {\n if (\n Object.prototype.hasOwnProperty.call(this.referenceState, nodeId) &&\n nodes[nodeId] !== undefined\n ) {\n dx = nodes[nodeId].x - reference[nodeId].positions.x;\n dy = nodes[nodeId].y - reference[nodeId].positions.y;\n\n dpos = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n\n if (dpos > posThreshold) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * move the nodes one timestep and check if they are stabilized\n */\n moveNodes() {\n const nodeIndices = this.physicsBody.physicsNodeIndices;\n let maxNodeVelocity = 0;\n let averageNodeVelocity = 0;\n\n // the velocity threshold (energy in the system) for the adaptivity toggle\n const velocityAdaptiveThreshold = 5;\n\n for (let i = 0; i < nodeIndices.length; i++) {\n const nodeId = nodeIndices[i];\n const nodeVelocity = this._performStep(nodeId);\n // stabilized is true if stabilized is true and velocity is smaller than vmin --> all nodes must be stabilized\n maxNodeVelocity = Math.max(maxNodeVelocity, nodeVelocity);\n averageNodeVelocity += nodeVelocity;\n }\n\n // evaluating the stabilized and adaptiveTimestepEnabled conditions\n this.adaptiveTimestepEnabled =\n averageNodeVelocity / nodeIndices.length < velocityAdaptiveThreshold;\n this.stabilized = maxNodeVelocity < this.options.minVelocity;\n }\n\n /**\n * Calculate new velocity for a coordinate direction\n *\n * @param {number} v velocity for current coordinate\n * @param {number} f regular force for current coordinate\n * @param {number} m mass of current node\n * @returns {number} new velocity for current coordinate\n * @private\n */\n calculateComponentVelocity(v, f, m) {\n const df = this.modelOptions.damping * v; // damping force\n const a = (f - df) / m; // acceleration\n\n v += a * this.timestep;\n\n // Put a limit on the velocities if it is really high\n const maxV = this.options.maxVelocity || 1e9;\n if (Math.abs(v) > maxV) {\n v = v > 0 ? maxV : -maxV;\n }\n\n return v;\n }\n\n /**\n * Perform the actual step\n *\n * @param {Node.id} nodeId\n * @returns {number} the new velocity of given node\n * @private\n */\n _performStep(nodeId) {\n const node = this.body.nodes[nodeId];\n const force = this.physicsBody.forces[nodeId];\n\n if (this.options.wind) {\n force.x += this.options.wind.x;\n force.y += this.options.wind.y;\n }\n\n const velocity = this.physicsBody.velocities[nodeId];\n\n // store the state so we can revert\n this.previousStates[nodeId] = {\n x: node.x,\n y: node.y,\n vx: velocity.x,\n vy: velocity.y,\n };\n\n if (node.options.fixed.x === false) {\n velocity.x = this.calculateComponentVelocity(\n velocity.x,\n force.x,\n node.options.mass\n );\n node.x += velocity.x * this.timestep;\n } else {\n force.x = 0;\n velocity.x = 0;\n }\n\n if (node.options.fixed.y === false) {\n velocity.y = this.calculateComponentVelocity(\n velocity.y,\n force.y,\n node.options.mass\n );\n node.y += velocity.y * this.timestep;\n } else {\n force.y = 0;\n velocity.y = 0;\n }\n\n const totalVelocity = Math.sqrt(\n Math.pow(velocity.x, 2) + Math.pow(velocity.y, 2)\n );\n return totalVelocity;\n }\n\n /**\n * When initializing and stabilizing, we can freeze nodes with a predefined position.\n * This greatly speeds up stabilization because only the supportnodes for the smoothCurves have to settle.\n *\n * @private\n */\n _freezeNodes() {\n const nodes = this.body.nodes;\n for (const id in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, id)) {\n if (nodes[id].x && nodes[id].y) {\n const fixed = nodes[id].options.fixed;\n this.freezeCache[id] = { x: fixed.x, y: fixed.y };\n fixed.x = true;\n fixed.y = true;\n }\n }\n }\n }\n\n /**\n * Unfreezes the nodes that have been frozen by _freezeDefinedNodes.\n *\n * @private\n */\n _restoreFrozenNodes() {\n const nodes = this.body.nodes;\n for (const id in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, id)) {\n if (this.freezeCache[id] !== undefined) {\n nodes[id].options.fixed.x = this.freezeCache[id].x;\n nodes[id].options.fixed.y = this.freezeCache[id].y;\n }\n }\n }\n this.freezeCache = {};\n }\n\n /**\n * Find a stable position for all nodes\n *\n * @param {number} [iterations=this.options.stabilization.iterations]\n */\n stabilize(iterations = this.options.stabilization.iterations) {\n if (typeof iterations !== \"number\") {\n iterations = this.options.stabilization.iterations;\n console.error(\n \"The stabilize method needs a numeric amount of iterations. Switching to default: \",\n iterations\n );\n }\n\n if (this.physicsBody.physicsNodeIndices.length === 0) {\n this.ready = true;\n return;\n }\n\n // enable adaptive timesteps\n this.adaptiveTimestep = true && this.options.adaptiveTimestep;\n\n // this sets the width of all nodes initially which could be required for the avoidOverlap\n this.body.emitter.emit(\"_resizeNodes\");\n\n this.stopSimulation(); // stop the render loop\n this.stabilized = false;\n\n // block redraw requests\n this.body.emitter.emit(\"_blockRedraw\");\n this.targetIterations = iterations;\n\n // start the stabilization\n if (this.options.stabilization.onlyDynamicEdges === true) {\n this._freezeNodes();\n }\n this.stabilizationIterations = 0;\n\n setTimeout(() => this._stabilizationBatch(), 0);\n }\n\n /**\n * If not already stabilizing, start it and emit a start event.\n *\n * @returns {boolean} true if stabilization started with this call\n * @private\n */\n _startStabilizing() {\n if (this.startedStabilization === true) return false;\n\n this.body.emitter.emit(\"startStabilizing\");\n this.startedStabilization = true;\n return true;\n }\n\n /**\n * One batch of stabilization\n *\n * @private\n */\n _stabilizationBatch() {\n const running = () =>\n this.stabilized === false &&\n this.stabilizationIterations < this.targetIterations;\n\n const sendProgress = () => {\n this.body.emitter.emit(\"stabilizationProgress\", {\n iterations: this.stabilizationIterations,\n total: this.targetIterations,\n });\n };\n\n if (this._startStabilizing()) {\n sendProgress(); // Ensure that there is at least one start event.\n }\n\n let count = 0;\n while (running() && count < this.options.stabilization.updateInterval) {\n this.physicsTick();\n count++;\n }\n\n sendProgress();\n\n if (running()) {\n setTimeout(this._stabilizationBatch.bind(this), 0);\n } else {\n this._finalizeStabilization();\n }\n }\n\n /**\n * Wrap up the stabilization, fit and emit the events.\n *\n * @private\n */\n _finalizeStabilization() {\n this.body.emitter.emit(\"_allowRedraw\");\n if (this.options.stabilization.fit === true) {\n this.body.emitter.emit(\"fit\");\n }\n\n if (this.options.stabilization.onlyDynamicEdges === true) {\n this._restoreFrozenNodes();\n }\n\n this.body.emitter.emit(\"stabilizationIterationsDone\");\n this.body.emitter.emit(\"_requestRedraw\");\n\n if (this.stabilized === true) {\n this._emitStabilized();\n } else {\n this.startSimulation();\n }\n\n this.ready = true;\n }\n\n //--------------------------- DEBUGGING BELOW ---------------------------//\n\n /**\n * Debug function that display arrows for the forces currently active in the network.\n *\n * Use this when debugging only.\n *\n * @param {CanvasRenderingContext2D} ctx\n * @private\n */\n _drawForces(ctx) {\n for (let i = 0; i < this.physicsBody.physicsNodeIndices.length; i++) {\n const index = this.physicsBody.physicsNodeIndices[i];\n const node = this.body.nodes[index];\n const force = this.physicsBody.forces[index];\n const factor = 20;\n const colorFactor = 0.03;\n const forceSize = Math.sqrt(Math.pow(force.x, 2) + Math.pow(force.x, 2));\n\n const size = Math.min(Math.max(5, forceSize), 15);\n const arrowSize = 3 * size;\n\n const color = HSVToHex(\n (180 - Math.min(1, Math.max(0, colorFactor * forceSize)) * 180) / 360,\n 1,\n 1\n );\n\n const point = {\n x: node.x + factor * force.x,\n y: node.y + factor * force.y,\n };\n\n ctx.lineWidth = size;\n ctx.strokeStyle = color;\n ctx.beginPath();\n ctx.moveTo(node.x, node.y);\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n\n const angle = Math.atan2(force.y, force.x);\n ctx.fillStyle = color;\n EndPoints.draw(ctx, {\n type: \"arrow\",\n point: point,\n angle: angle,\n length: arrowSize,\n });\n ctx.fill();\n }\n }\n}\n\nexport default PhysicsEngine;\n","import { deepExtend } from \"vis-util/esnext\";\n\n/**\n * Utility Class\n */\nclass NetworkUtil {\n /**\n * @ignore\n */\n constructor() {}\n\n /**\n * Find the center position of the network considering the bounding boxes\n *\n * @param {Array.<Node>} allNodes\n * @param {Array.<Node>} [specificNodes=[]]\n * @returns {{minX: number, maxX: number, minY: number, maxY: number}}\n * @static\n */\n static getRange(allNodes, specificNodes = []) {\n let minY = 1e9,\n maxY = -1e9,\n minX = 1e9,\n maxX = -1e9,\n node;\n if (specificNodes.length > 0) {\n for (let i = 0; i < specificNodes.length; i++) {\n node = allNodes[specificNodes[i]];\n if (minX > node.shape.boundingBox.left) {\n minX = node.shape.boundingBox.left;\n }\n if (maxX < node.shape.boundingBox.right) {\n maxX = node.shape.boundingBox.right;\n }\n if (minY > node.shape.boundingBox.top) {\n minY = node.shape.boundingBox.top;\n } // top is negative, bottom is positive\n if (maxY < node.shape.boundingBox.bottom) {\n maxY = node.shape.boundingBox.bottom;\n } // top is negative, bottom is positive\n }\n }\n\n if (minX === 1e9 && maxX === -1e9 && minY === 1e9 && maxY === -1e9) {\n (minY = 0), (maxY = 0), (minX = 0), (maxX = 0);\n }\n return { minX: minX, maxX: maxX, minY: minY, maxY: maxY };\n }\n\n /**\n * Find the center position of the network\n *\n * @param {Array.<Node>} allNodes\n * @param {Array.<Node>} [specificNodes=[]]\n * @returns {{minX: number, maxX: number, minY: number, maxY: number}}\n * @static\n */\n static getRangeCore(allNodes, specificNodes = []) {\n let minY = 1e9,\n maxY = -1e9,\n minX = 1e9,\n maxX = -1e9,\n node;\n if (specificNodes.length > 0) {\n for (let i = 0; i < specificNodes.length; i++) {\n node = allNodes[specificNodes[i]];\n if (minX > node.x) {\n minX = node.x;\n }\n if (maxX < node.x) {\n maxX = node.x;\n }\n if (minY > node.y) {\n minY = node.y;\n } // top is negative, bottom is positive\n if (maxY < node.y) {\n maxY = node.y;\n } // top is negative, bottom is positive\n }\n }\n\n if (minX === 1e9 && maxX === -1e9 && minY === 1e9 && maxY === -1e9) {\n (minY = 0), (maxY = 0), (minX = 0), (maxX = 0);\n }\n return { minX: minX, maxX: maxX, minY: minY, maxY: maxY };\n }\n\n /**\n * @param {object} range = {minX: minX, maxX: maxX, minY: minY, maxY: maxY};\n * @returns {{x: number, y: number}}\n * @static\n */\n static findCenter(range) {\n return {\n x: 0.5 * (range.maxX + range.minX),\n y: 0.5 * (range.maxY + range.minY),\n };\n }\n\n /**\n * This returns a clone of the options or options of the edge or node to be used for construction of new edges or check functions for new nodes.\n *\n * @param {vis.Item} item\n * @param {'node'|undefined} type\n * @returns {{}}\n * @static\n */\n static cloneOptions(item, type) {\n const clonedOptions = {};\n if (type === undefined || type === \"node\") {\n deepExtend(clonedOptions, item.options, true);\n clonedOptions.x = item.x;\n clonedOptions.y = item.y;\n clonedOptions.amountOfConnections = item.edges.length;\n } else {\n deepExtend(clonedOptions, item.options, true);\n }\n return clonedOptions;\n }\n}\n\nexport default NetworkUtil;\n","import { forEach } from \"vis-util/esnext\";\nimport Node from \"../Node\";\n\n/**\n * A Cluster is a special Node that allows a group of Nodes positioned closely together\n * to be represented by a single Cluster Node.\n *\n * @augments Node\n */\nclass Cluster extends Node {\n /**\n * @param {object} options\n * @param {object} body\n * @param {Array.<HTMLImageElement>}imagelist\n * @param {Array} grouplist\n * @param {object} globalOptions\n * @param {object} defaultOptions Global default options for nodes\n */\n constructor(\n options,\n body,\n imagelist,\n grouplist,\n globalOptions,\n defaultOptions\n ) {\n super(options, body, imagelist, grouplist, globalOptions, defaultOptions);\n\n this.isCluster = true;\n this.containedNodes = {};\n this.containedEdges = {};\n }\n\n /**\n * Transfer child cluster data to current and disconnect the child cluster.\n *\n * Please consult the header comment in 'Clustering.js' for the fields set here.\n *\n * @param {string|number} childClusterId id of child cluster to open\n */\n _openChildCluster(childClusterId) {\n const childCluster = this.body.nodes[childClusterId];\n if (this.containedNodes[childClusterId] === undefined) {\n throw new Error(\n \"node with id: \" + childClusterId + \" not in current cluster\"\n );\n }\n if (!childCluster.isCluster) {\n throw new Error(\"node with id: \" + childClusterId + \" is not a cluster\");\n }\n\n // Disconnect child cluster from current cluster\n delete this.containedNodes[childClusterId];\n forEach(childCluster.edges, (edge) => {\n delete this.containedEdges[edge.id];\n });\n\n // Transfer nodes and edges\n forEach(childCluster.containedNodes, (node, nodeId) => {\n this.containedNodes[nodeId] = node;\n });\n childCluster.containedNodes = {};\n\n forEach(childCluster.containedEdges, (edge, edgeId) => {\n this.containedEdges[edgeId] = edge;\n });\n childCluster.containedEdges = {};\n\n // Transfer edges within cluster edges which are clustered\n forEach(childCluster.edges, (clusterEdge) => {\n forEach(this.edges, (parentClusterEdge) => {\n // Assumption: a clustered edge can only be present in a single clustering edge\n // Not tested here\n const index = parentClusterEdge.clusteringEdgeReplacingIds.indexOf(\n clusterEdge.id\n );\n if (index === -1) return;\n\n forEach(clusterEdge.clusteringEdgeReplacingIds, (srcId) => {\n parentClusterEdge.clusteringEdgeReplacingIds.push(srcId);\n\n // Maintain correct bookkeeping for transferred edge\n this.body.edges[srcId].edgeReplacedById = parentClusterEdge.id;\n });\n\n // Remove cluster edge from parent cluster edge\n parentClusterEdge.clusteringEdgeReplacingIds.splice(index, 1);\n });\n });\n childCluster.edges = [];\n }\n}\n\nexport default Cluster;\n","/* ===========================================================================\n\n# TODO\n\n- `edgeReplacedById` not cleaned up yet on cluster edge removal\n- allowSingleNodeCluster could be a global option as well; currently needs to always\n be passed to clustering methods\n\n----------------------------------------------\n\n# State Model for Clustering\n\nThe total state for clustering is non-trivial. It is useful to have a model\navailable as to how it works. The following documents the relevant state items.\n\n\n## Network State\n\nThe following `network`-members are relevant to clustering:\n\n- `body.nodes` - all nodes actively participating in the network\n- `body.edges` - same for edges\n- `body.nodeIndices` - id's of nodes that are visible at a given moment\n- `body.edgeIndices` - same for edges\n\nThis includes:\n\n- helper nodes for dragging in `manipulation`\n- helper nodes for edge type `dynamic`\n- cluster nodes and edges\n- there may be more than this.\n\nA node/edge may be missing in the `Indices` member if:\n\n- it is a helper node\n- the node or edge state has option `hidden` set\n- It is not visible due to clustering\n\n\n## Clustering State\n\nFor the hashes, the id's of the nodes/edges are used as key.\n\nMember `network.clustering` contains the following items:\n\n- `clusteredNodes` - hash with values: { clusterId: <id of cluster>, node: <node instance>}\n- `clusteredEdges` - hash with values: restore information for given edge\n\n\nDue to nesting of clusters, these members can contain cluster nodes and edges as well.\n\nThe important thing to note here, is that the clustered nodes and edges also\nappear in the members of the cluster nodes. For data update, it is therefore\nimportant to scan these lists as well as the cluster nodes.\n\n\n### Cluster Node\n\nA cluster node has the following extra fields:\n\n- `isCluster : true` - indication that this is a cluster node\n- `containedNodes` - hash of nodes contained in this cluster\n- `containedEdges` - same for edges\n- `edges` - array of cluster edges for this node\n\n\n**NOTE:**\n\n- `containedEdges` can also contain edges which are not clustered; e.g. an edge\n connecting two nodes in the same cluster.\n\n\n### Cluster Edge\n\nThese are the items in the `edges` member of a clustered node. They have the\nfollowing relevant members:\n\n- 'clusteringEdgeReplacingIds` - array of id's of edges replaced by this edge\n\nNote that it's possible to nest clusters, so that `clusteringEdgeReplacingIds`\ncan contain edge id's of other clusters.\n\n\n### Clustered Edge\n\nThis is any edge contained by a cluster edge. It gets the following additional\nmember:\n\n- `edgeReplacedById` - id of the cluster edge in which current edge is clustered\n\n\n =========================================================================== */\nimport { deepExtend, forEach } from \"vis-util/esnext\";\nimport { v4 as randomUUID } from \"uuid\";\nimport NetworkUtil from \"../NetworkUtil\";\nimport Cluster from \"./components/nodes/Cluster\";\nimport Edge from \"./components/Edge\"; // Only needed for check on type!\nimport Node from \"./components/Node\"; // Only needed for check on type!\n\n/**\n * The clustering engine\n */\nclass ClusterEngine {\n /**\n * @param {object} body\n */\n constructor(body) {\n this.body = body;\n this.clusteredNodes = {}; // key: node id, value: { clusterId: <id of cluster>, node: <node instance>}\n this.clusteredEdges = {}; // key: edge id, value: restore information for given edge\n\n this.options = {};\n this.defaultOptions = {};\n Object.assign(this.options, this.defaultOptions);\n\n this.body.emitter.on(\"_resetData\", () => {\n this.clusteredNodes = {};\n this.clusteredEdges = {};\n });\n }\n\n /**\n *\n * @param {number} hubsize\n * @param {object} options\n */\n clusterByHubsize(hubsize, options) {\n if (hubsize === undefined) {\n hubsize = this._getHubSize();\n } else if (typeof hubsize === \"object\") {\n options = this._checkOptions(hubsize);\n hubsize = this._getHubSize();\n }\n\n const nodesToCluster = [];\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n const node = this.body.nodes[this.body.nodeIndices[i]];\n if (node.edges.length >= hubsize) {\n nodesToCluster.push(node.id);\n }\n }\n\n for (let i = 0; i < nodesToCluster.length; i++) {\n this.clusterByConnection(nodesToCluster[i], options, true);\n }\n\n this.body.emitter.emit(\"_dataChanged\");\n }\n\n /**\n * loop over all nodes, check if they adhere to the condition and cluster if needed.\n *\n * @param {object} options\n * @param {boolean} [refreshData=true]\n */\n cluster(options = {}, refreshData = true) {\n if (options.joinCondition === undefined) {\n throw new Error(\n \"Cannot call clusterByNodeData without a joinCondition function in the options.\"\n );\n }\n\n // check if the options object is fine, append if needed\n options = this._checkOptions(options);\n\n const childNodesObj = {};\n const childEdgesObj = {};\n\n // collect the nodes that will be in the cluster\n forEach(this.body.nodes, (node, nodeId) => {\n if (node.options && options.joinCondition(node.options) === true) {\n childNodesObj[nodeId] = node;\n\n // collect the edges that will be in the cluster\n forEach(node.edges, (edge) => {\n if (this.clusteredEdges[edge.id] === undefined) {\n childEdgesObj[edge.id] = edge;\n }\n });\n }\n });\n\n this._cluster(childNodesObj, childEdgesObj, options, refreshData);\n }\n\n /**\n * Cluster all nodes in the network that have only X edges\n *\n * @param {number} edgeCount\n * @param {object} options\n * @param {boolean} [refreshData=true]\n */\n clusterByEdgeCount(edgeCount, options, refreshData = true) {\n options = this._checkOptions(options);\n const clusters = [];\n const usedNodes = {};\n let edge, edges, relevantEdgeCount;\n // collect the nodes that will be in the cluster\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n const childNodesObj = {};\n const childEdgesObj = {};\n const nodeId = this.body.nodeIndices[i];\n const node = this.body.nodes[nodeId];\n\n // if this node is already used in another cluster this session, we do not have to re-evaluate it.\n if (usedNodes[nodeId] === undefined) {\n relevantEdgeCount = 0;\n edges = [];\n for (let j = 0; j < node.edges.length; j++) {\n edge = node.edges[j];\n if (this.clusteredEdges[edge.id] === undefined) {\n if (edge.toId !== edge.fromId) {\n relevantEdgeCount++;\n }\n edges.push(edge);\n }\n }\n\n // this node qualifies, we collect its neighbours to start the clustering process.\n if (relevantEdgeCount === edgeCount) {\n const checkJoinCondition = function (node) {\n if (\n options.joinCondition === undefined ||\n options.joinCondition === null\n ) {\n return true;\n }\n\n const clonedOptions = NetworkUtil.cloneOptions(node);\n return options.joinCondition(clonedOptions);\n };\n\n let gatheringSuccessful = true;\n for (let j = 0; j < edges.length; j++) {\n edge = edges[j];\n const childNodeId = this._getConnectedId(edge, nodeId);\n // add the nodes to the list by the join condition.\n if (checkJoinCondition(node)) {\n childEdgesObj[edge.id] = edge;\n childNodesObj[nodeId] = node;\n childNodesObj[childNodeId] = this.body.nodes[childNodeId];\n usedNodes[nodeId] = true;\n } else {\n // this node does not qualify after all.\n gatheringSuccessful = false;\n break;\n }\n }\n\n // add to the cluster queue\n if (\n Object.keys(childNodesObj).length > 0 &&\n Object.keys(childEdgesObj).length > 0 &&\n gatheringSuccessful === true\n ) {\n /**\n * Search for cluster data that contains any of the node id's\n *\n * @returns {boolean} true if no joinCondition, otherwise return value of joinCondition\n */\n const findClusterData = function () {\n for (let n = 0; n < clusters.length; ++n) {\n // Search for a cluster containing any of the node id's\n for (const m in childNodesObj) {\n if (clusters[n].nodes[m] !== undefined) {\n return clusters[n];\n }\n }\n }\n\n return undefined;\n };\n\n // If any of the found nodes is part of a cluster found in this method,\n // add the current values to that cluster\n const foundCluster = findClusterData();\n if (foundCluster !== undefined) {\n // Add nodes to found cluster if not present\n for (const m in childNodesObj) {\n if (foundCluster.nodes[m] === undefined) {\n foundCluster.nodes[m] = childNodesObj[m];\n }\n }\n\n // Add edges to found cluster, if not present\n for (const m in childEdgesObj) {\n if (foundCluster.edges[m] === undefined) {\n foundCluster.edges[m] = childEdgesObj[m];\n }\n }\n } else {\n // Create a new cluster group\n clusters.push({ nodes: childNodesObj, edges: childEdgesObj });\n }\n }\n }\n }\n }\n\n for (let i = 0; i < clusters.length; i++) {\n this._cluster(clusters[i].nodes, clusters[i].edges, options, false);\n }\n\n if (refreshData === true) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n * Cluster all nodes in the network that have only 1 edge\n *\n * @param {object} options\n * @param {boolean} [refreshData=true]\n */\n clusterOutliers(options, refreshData = true) {\n this.clusterByEdgeCount(1, options, refreshData);\n }\n\n /**\n * Cluster all nodes in the network that have only 2 edge\n *\n * @param {object} options\n * @param {boolean} [refreshData=true]\n */\n clusterBridges(options, refreshData = true) {\n this.clusterByEdgeCount(2, options, refreshData);\n }\n\n /**\n * suck all connected nodes of a node into the node.\n *\n * @param {Node.id} nodeId\n * @param {object} options\n * @param {boolean} [refreshData=true]\n */\n clusterByConnection(nodeId, options, refreshData = true) {\n // kill conditions\n if (nodeId === undefined) {\n throw new Error(\"No nodeId supplied to clusterByConnection!\");\n }\n if (this.body.nodes[nodeId] === undefined) {\n throw new Error(\n \"The nodeId given to clusterByConnection does not exist!\"\n );\n }\n\n const node = this.body.nodes[nodeId];\n options = this._checkOptions(options, node);\n if (options.clusterNodeProperties.x === undefined) {\n options.clusterNodeProperties.x = node.x;\n }\n if (options.clusterNodeProperties.y === undefined) {\n options.clusterNodeProperties.y = node.y;\n }\n if (options.clusterNodeProperties.fixed === undefined) {\n options.clusterNodeProperties.fixed = {};\n options.clusterNodeProperties.fixed.x = node.options.fixed.x;\n options.clusterNodeProperties.fixed.y = node.options.fixed.y;\n }\n\n const childNodesObj = {};\n const childEdgesObj = {};\n const parentNodeId = node.id;\n const parentClonedOptions = NetworkUtil.cloneOptions(node);\n childNodesObj[parentNodeId] = node;\n\n // collect the nodes that will be in the cluster\n for (let i = 0; i < node.edges.length; i++) {\n const edge = node.edges[i];\n if (this.clusteredEdges[edge.id] === undefined) {\n const childNodeId = this._getConnectedId(edge, parentNodeId);\n\n // if the child node is not in a cluster\n if (this.clusteredNodes[childNodeId] === undefined) {\n if (childNodeId !== parentNodeId) {\n if (options.joinCondition === undefined) {\n childEdgesObj[edge.id] = edge;\n childNodesObj[childNodeId] = this.body.nodes[childNodeId];\n } else {\n // clone the options and insert some additional parameters that could be interesting.\n const childClonedOptions = NetworkUtil.cloneOptions(\n this.body.nodes[childNodeId]\n );\n if (\n options.joinCondition(\n parentClonedOptions,\n childClonedOptions\n ) === true\n ) {\n childEdgesObj[edge.id] = edge;\n childNodesObj[childNodeId] = this.body.nodes[childNodeId];\n }\n }\n } else {\n // swallow the edge if it is self-referencing.\n childEdgesObj[edge.id] = edge;\n }\n }\n }\n }\n const childNodeIDs = Object.keys(childNodesObj).map(function (childNode) {\n return childNodesObj[childNode].id;\n });\n\n for (const childNodeKey in childNodesObj) {\n if (!Object.prototype.hasOwnProperty.call(childNodesObj, childNodeKey))\n continue;\n\n const childNode = childNodesObj[childNodeKey];\n for (let y = 0; y < childNode.edges.length; y++) {\n const childEdge = childNode.edges[y];\n if (\n childNodeIDs.indexOf(this._getConnectedId(childEdge, childNode.id)) >\n -1\n ) {\n childEdgesObj[childEdge.id] = childEdge;\n }\n }\n }\n this._cluster(childNodesObj, childEdgesObj, options, refreshData);\n }\n\n /**\n * This function creates the edges that will be attached to the cluster\n * It looks for edges that are connected to the nodes from the \"outside' of the cluster.\n *\n * @param {{Node.id: vis.Node}} childNodesObj\n * @param {{vis.Edge.id: vis.Edge}} childEdgesObj\n * @param {object} clusterNodeProperties\n * @param {object} clusterEdgeProperties\n * @private\n */\n _createClusterEdges(\n childNodesObj,\n childEdgesObj,\n clusterNodeProperties,\n clusterEdgeProperties\n ) {\n let edge, childNodeId, childNode, toId, fromId, otherNodeId;\n\n // loop over all child nodes and their edges to find edges going out of the cluster\n // these edges will be replaced by clusterEdges.\n const childKeys = Object.keys(childNodesObj);\n const createEdges = [];\n for (let i = 0; i < childKeys.length; i++) {\n childNodeId = childKeys[i];\n childNode = childNodesObj[childNodeId];\n\n // construct new edges from the cluster to others\n for (let j = 0; j < childNode.edges.length; j++) {\n edge = childNode.edges[j];\n // we only handle edges that are visible to the system, not the disabled ones from the clustering process.\n if (this.clusteredEdges[edge.id] === undefined) {\n // self-referencing edges will be added to the \"hidden\" list\n if (edge.toId == edge.fromId) {\n childEdgesObj[edge.id] = edge;\n } else {\n // set up the from and to.\n if (edge.toId == childNodeId) {\n // this is a double equals because ints and strings can be interchanged here.\n toId = clusterNodeProperties.id;\n fromId = edge.fromId;\n otherNodeId = fromId;\n } else {\n toId = edge.toId;\n fromId = clusterNodeProperties.id;\n otherNodeId = toId;\n }\n }\n\n // Only edges from the cluster outwards are being replaced.\n if (childNodesObj[otherNodeId] === undefined) {\n createEdges.push({ edge: edge, fromId: fromId, toId: toId });\n }\n }\n }\n }\n\n //\n // Here we actually create the replacement edges.\n //\n // We could not do this in the loop above as the creation process\n // would add an edge to the edges array we are iterating over.\n //\n // NOTE: a clustered edge can have multiple base edges!\n //\n const newEdges = [];\n\n /**\n * Find a cluster edge which matches the given created edge.\n *\n * @param {vis.Edge} createdEdge\n * @returns {vis.Edge}\n */\n const getNewEdge = function (createdEdge) {\n for (let j = 0; j < newEdges.length; j++) {\n const newEdge = newEdges[j];\n\n // We replace both to and from edges with a single cluster edge\n const matchToDirection =\n createdEdge.fromId === newEdge.fromId &&\n createdEdge.toId === newEdge.toId;\n const matchFromDirection =\n createdEdge.fromId === newEdge.toId &&\n createdEdge.toId === newEdge.fromId;\n\n if (matchToDirection || matchFromDirection) {\n return newEdge;\n }\n }\n\n return null;\n };\n\n for (let j = 0; j < createEdges.length; j++) {\n const createdEdge = createEdges[j];\n const edge = createdEdge.edge;\n let newEdge = getNewEdge(createdEdge);\n\n if (newEdge === null) {\n // Create a clustered edge for this connection\n newEdge = this._createClusteredEdge(\n createdEdge.fromId,\n createdEdge.toId,\n edge,\n clusterEdgeProperties\n );\n\n newEdges.push(newEdge);\n } else {\n newEdge.clusteringEdgeReplacingIds.push(edge.id);\n }\n\n // also reference the new edge in the old edge\n this.body.edges[edge.id].edgeReplacedById = newEdge.id;\n\n // hide the replaced edge\n this._backupEdgeOptions(edge);\n edge.setOptions({ physics: false });\n }\n }\n\n /**\n * This function checks the options that can be supplied to the different cluster functions\n * for certain fields and inserts defaults if needed\n *\n * @param {object} options\n * @returns {*}\n * @private\n */\n _checkOptions(options = {}) {\n if (options.clusterEdgeProperties === undefined) {\n options.clusterEdgeProperties = {};\n }\n if (options.clusterNodeProperties === undefined) {\n options.clusterNodeProperties = {};\n }\n\n return options;\n }\n\n /**\n *\n * @param {object} childNodesObj | object with node objects, id as keys, same as childNodes except it also contains a source node\n * @param {object} childEdgesObj | object with edge objects, id as keys\n * @param {Array} options | object with {clusterNodeProperties, clusterEdgeProperties, processProperties}\n * @param {boolean} refreshData | when true, do not wrap up\n * @private\n */\n _cluster(childNodesObj, childEdgesObj, options, refreshData = true) {\n // Remove nodes which are already clustered\n const tmpNodesToRemove = [];\n for (const nodeId in childNodesObj) {\n if (Object.prototype.hasOwnProperty.call(childNodesObj, nodeId)) {\n if (this.clusteredNodes[nodeId] !== undefined) {\n tmpNodesToRemove.push(nodeId);\n }\n }\n }\n\n for (let n = 0; n < tmpNodesToRemove.length; ++n) {\n delete childNodesObj[tmpNodesToRemove[n]];\n }\n\n // kill condition: no nodes don't bother\n if (Object.keys(childNodesObj).length == 0) {\n return;\n }\n\n // allow clusters of 1 if options allow\n if (\n Object.keys(childNodesObj).length == 1 &&\n options.clusterNodeProperties.allowSingleNodeCluster != true\n ) {\n return;\n }\n\n let clusterNodeProperties = deepExtend({}, options.clusterNodeProperties);\n\n // construct the clusterNodeProperties\n if (options.processProperties !== undefined) {\n // get the childNode options\n const childNodesOptions = [];\n for (const nodeId in childNodesObj) {\n if (Object.prototype.hasOwnProperty.call(childNodesObj, nodeId)) {\n const clonedOptions = NetworkUtil.cloneOptions(childNodesObj[nodeId]);\n childNodesOptions.push(clonedOptions);\n }\n }\n\n // get cluster properties based on childNodes\n const childEdgesOptions = [];\n for (const edgeId in childEdgesObj) {\n if (Object.prototype.hasOwnProperty.call(childEdgesObj, edgeId)) {\n // these cluster edges will be removed on creation of the cluster.\n if (edgeId.substr(0, 12) !== \"clusterEdge:\") {\n const clonedOptions = NetworkUtil.cloneOptions(\n childEdgesObj[edgeId],\n \"edge\"\n );\n childEdgesOptions.push(clonedOptions);\n }\n }\n }\n\n clusterNodeProperties = options.processProperties(\n clusterNodeProperties,\n childNodesOptions,\n childEdgesOptions\n );\n if (!clusterNodeProperties) {\n throw new Error(\n \"The processProperties function does not return properties!\"\n );\n }\n }\n\n // check if we have an unique id;\n if (clusterNodeProperties.id === undefined) {\n clusterNodeProperties.id = \"cluster:\" + randomUUID();\n }\n const clusterId = clusterNodeProperties.id;\n\n if (clusterNodeProperties.label === undefined) {\n clusterNodeProperties.label = \"cluster\";\n }\n\n // give the clusterNode a position if it does not have one.\n let pos = undefined;\n if (clusterNodeProperties.x === undefined) {\n pos = this._getClusterPosition(childNodesObj);\n clusterNodeProperties.x = pos.x;\n }\n if (clusterNodeProperties.y === undefined) {\n if (pos === undefined) {\n pos = this._getClusterPosition(childNodesObj);\n }\n clusterNodeProperties.y = pos.y;\n }\n\n // force the ID to remain the same\n clusterNodeProperties.id = clusterId;\n\n // create the cluster Node\n // Note that allowSingleNodeCluster, if present, is stored in the options as well\n const clusterNode = this.body.functions.createNode(\n clusterNodeProperties,\n Cluster\n );\n clusterNode.containedNodes = childNodesObj;\n clusterNode.containedEdges = childEdgesObj;\n // cache a copy from the cluster edge properties if we have to reconnect others later on\n clusterNode.clusterEdgeProperties = options.clusterEdgeProperties;\n\n // finally put the cluster node into global\n this.body.nodes[clusterNodeProperties.id] = clusterNode;\n\n this._clusterEdges(\n childNodesObj,\n childEdgesObj,\n clusterNodeProperties,\n options.clusterEdgeProperties\n );\n\n // set ID to undefined so no duplicates arise\n clusterNodeProperties.id = undefined;\n\n // wrap up\n if (refreshData === true) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n *\n * @param {Edge} edge\n * @private\n */\n _backupEdgeOptions(edge) {\n if (this.clusteredEdges[edge.id] === undefined) {\n this.clusteredEdges[edge.id] = { physics: edge.options.physics };\n }\n }\n\n /**\n *\n * @param {Edge} edge\n * @private\n */\n _restoreEdge(edge) {\n const originalOptions = this.clusteredEdges[edge.id];\n if (originalOptions !== undefined) {\n edge.setOptions({ physics: originalOptions.physics });\n delete this.clusteredEdges[edge.id];\n }\n }\n\n /**\n * Check if a node is a cluster.\n *\n * @param {Node.id} nodeId\n * @returns {*}\n */\n isCluster(nodeId) {\n if (this.body.nodes[nodeId] !== undefined) {\n return this.body.nodes[nodeId].isCluster === true;\n } else {\n console.error(\"Node does not exist.\");\n return false;\n }\n }\n\n /**\n * get the position of the cluster node based on what's inside\n *\n * @param {object} childNodesObj | object with node objects, id as keys\n * @returns {{x: number, y: number}}\n * @private\n */\n _getClusterPosition(childNodesObj) {\n const childKeys = Object.keys(childNodesObj);\n let minX = childNodesObj[childKeys[0]].x;\n let maxX = childNodesObj[childKeys[0]].x;\n let minY = childNodesObj[childKeys[0]].y;\n let maxY = childNodesObj[childKeys[0]].y;\n let node;\n for (let i = 1; i < childKeys.length; i++) {\n node = childNodesObj[childKeys[i]];\n minX = node.x < minX ? node.x : minX;\n maxX = node.x > maxX ? node.x : maxX;\n minY = node.y < minY ? node.y : minY;\n maxY = node.y > maxY ? node.y : maxY;\n }\n\n return { x: 0.5 * (minX + maxX), y: 0.5 * (minY + maxY) };\n }\n\n /**\n * Open a cluster by calling this function.\n *\n * @param {vis.Edge.id} clusterNodeId | the ID of the cluster node\n * @param {object} options\n * @param {boolean} refreshData | wrap up afterwards if not true\n */\n openCluster(clusterNodeId, options, refreshData = true) {\n // kill conditions\n if (clusterNodeId === undefined) {\n throw new Error(\"No clusterNodeId supplied to openCluster.\");\n }\n\n const clusterNode = this.body.nodes[clusterNodeId];\n\n if (clusterNode === undefined) {\n throw new Error(\n \"The clusterNodeId supplied to openCluster does not exist.\"\n );\n }\n if (\n clusterNode.isCluster !== true ||\n clusterNode.containedNodes === undefined ||\n clusterNode.containedEdges === undefined\n ) {\n throw new Error(\"The node:\" + clusterNodeId + \" is not a valid cluster.\");\n }\n\n // Check if current cluster is clustered itself\n const stack = this.findNode(clusterNodeId);\n const parentIndex = stack.indexOf(clusterNodeId) - 1;\n if (parentIndex >= 0) {\n // Current cluster is clustered; transfer contained nodes and edges to parent\n const parentClusterNodeId = stack[parentIndex];\n const parentClusterNode = this.body.nodes[parentClusterNodeId];\n\n // clustering.clusteredNodes and clustering.clusteredEdges remain unchanged\n parentClusterNode._openChildCluster(clusterNodeId);\n\n // All components of child cluster node have been transferred. It can die now.\n delete this.body.nodes[clusterNodeId];\n if (refreshData === true) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n\n return;\n }\n\n // main body\n const containedNodes = clusterNode.containedNodes;\n const containedEdges = clusterNode.containedEdges;\n\n // allow the user to position the nodes after release.\n if (\n options !== undefined &&\n options.releaseFunction !== undefined &&\n typeof options.releaseFunction === \"function\"\n ) {\n const positions = {};\n const clusterPosition = { x: clusterNode.x, y: clusterNode.y };\n for (const nodeId in containedNodes) {\n if (Object.prototype.hasOwnProperty.call(containedNodes, nodeId)) {\n const containedNode = this.body.nodes[nodeId];\n positions[nodeId] = { x: containedNode.x, y: containedNode.y };\n }\n }\n const newPositions = options.releaseFunction(clusterPosition, positions);\n\n for (const nodeId in containedNodes) {\n if (Object.prototype.hasOwnProperty.call(containedNodes, nodeId)) {\n const containedNode = this.body.nodes[nodeId];\n if (newPositions[nodeId] !== undefined) {\n containedNode.x =\n newPositions[nodeId].x === undefined\n ? clusterNode.x\n : newPositions[nodeId].x;\n containedNode.y =\n newPositions[nodeId].y === undefined\n ? clusterNode.y\n : newPositions[nodeId].y;\n }\n }\n }\n } else {\n // copy the position from the cluster\n forEach(containedNodes, function (containedNode) {\n // inherit position\n if (containedNode.options.fixed.x === false) {\n containedNode.x = clusterNode.x;\n }\n if (containedNode.options.fixed.y === false) {\n containedNode.y = clusterNode.y;\n }\n });\n }\n\n // release nodes\n for (const nodeId in containedNodes) {\n if (Object.prototype.hasOwnProperty.call(containedNodes, nodeId)) {\n const containedNode = this.body.nodes[nodeId];\n\n // inherit speed\n containedNode.vx = clusterNode.vx;\n containedNode.vy = clusterNode.vy;\n\n containedNode.setOptions({ physics: true });\n\n delete this.clusteredNodes[nodeId];\n }\n }\n\n // copy the clusterNode edges because we cannot iterate over an object that we add or remove from.\n const edgesToBeDeleted = [];\n for (let i = 0; i < clusterNode.edges.length; i++) {\n edgesToBeDeleted.push(clusterNode.edges[i]);\n }\n\n // actually handling the deleting.\n for (let i = 0; i < edgesToBeDeleted.length; i++) {\n const edge = edgesToBeDeleted[i];\n const otherNodeId = this._getConnectedId(edge, clusterNodeId);\n const otherNode = this.clusteredNodes[otherNodeId];\n\n for (let j = 0; j < edge.clusteringEdgeReplacingIds.length; j++) {\n const transferId = edge.clusteringEdgeReplacingIds[j];\n const transferEdge = this.body.edges[transferId];\n if (transferEdge === undefined) continue;\n\n // if the other node is in another cluster, we transfer ownership of this edge to the other cluster\n if (otherNode !== undefined) {\n // transfer ownership:\n const otherCluster = this.body.nodes[otherNode.clusterId];\n otherCluster.containedEdges[transferEdge.id] = transferEdge;\n\n // delete local reference\n delete containedEdges[transferEdge.id];\n\n // get to and from\n let fromId = transferEdge.fromId;\n let toId = transferEdge.toId;\n if (transferEdge.toId == otherNodeId) {\n toId = otherNode.clusterId;\n } else {\n fromId = otherNode.clusterId;\n }\n\n // create new cluster edge from the otherCluster\n this._createClusteredEdge(\n fromId,\n toId,\n transferEdge,\n otherCluster.clusterEdgeProperties,\n { hidden: false, physics: true }\n );\n } else {\n this._restoreEdge(transferEdge);\n }\n }\n\n edge.remove();\n }\n\n // handle the releasing of the edges\n for (const edgeId in containedEdges) {\n if (Object.prototype.hasOwnProperty.call(containedEdges, edgeId)) {\n this._restoreEdge(containedEdges[edgeId]);\n }\n }\n\n // remove clusterNode\n delete this.body.nodes[clusterNodeId];\n\n if (refreshData === true) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n\n /**\n *\n * @param {Cluster.id} clusterId\n * @returns {Array.<Node.id>}\n */\n getNodesInCluster(clusterId) {\n const nodesArray = [];\n if (this.isCluster(clusterId) === true) {\n const containedNodes = this.body.nodes[clusterId].containedNodes;\n for (const nodeId in containedNodes) {\n if (Object.prototype.hasOwnProperty.call(containedNodes, nodeId)) {\n nodesArray.push(this.body.nodes[nodeId].id);\n }\n }\n }\n\n return nodesArray;\n }\n\n /**\n * Get the stack clusterId's that a certain node resides in. cluster A -> cluster B -> cluster C -> node\n *\n * If a node can't be found in the chain, return an empty array.\n *\n * @param {string|number} nodeId\n * @returns {Array}\n */\n findNode(nodeId) {\n const stack = [];\n const max = 100;\n let counter = 0;\n let node;\n\n while (this.clusteredNodes[nodeId] !== undefined && counter < max) {\n node = this.body.nodes[nodeId];\n if (node === undefined) return [];\n stack.push(node.id);\n\n nodeId = this.clusteredNodes[nodeId].clusterId;\n counter++;\n }\n\n node = this.body.nodes[nodeId];\n if (node === undefined) return [];\n stack.push(node.id);\n\n stack.reverse();\n return stack;\n }\n\n /**\n * Using a clustered nodeId, update with the new options\n *\n * @param {Node.id} clusteredNodeId\n * @param {object} newOptions\n */\n updateClusteredNode(clusteredNodeId, newOptions) {\n if (clusteredNodeId === undefined) {\n throw new Error(\"No clusteredNodeId supplied to updateClusteredNode.\");\n }\n if (newOptions === undefined) {\n throw new Error(\"No newOptions supplied to updateClusteredNode.\");\n }\n if (this.body.nodes[clusteredNodeId] === undefined) {\n throw new Error(\n \"The clusteredNodeId supplied to updateClusteredNode does not exist.\"\n );\n }\n\n this.body.nodes[clusteredNodeId].setOptions(newOptions);\n this.body.emitter.emit(\"_dataChanged\");\n }\n\n /**\n * Using a base edgeId, update all related clustered edges with the new options\n *\n * @param {vis.Edge.id} startEdgeId\n * @param {object} newOptions\n */\n updateEdge(startEdgeId, newOptions) {\n if (startEdgeId === undefined) {\n throw new Error(\"No startEdgeId supplied to updateEdge.\");\n }\n if (newOptions === undefined) {\n throw new Error(\"No newOptions supplied to updateEdge.\");\n }\n if (this.body.edges[startEdgeId] === undefined) {\n throw new Error(\"The startEdgeId supplied to updateEdge does not exist.\");\n }\n\n const allEdgeIds = this.getClusteredEdges(startEdgeId);\n for (let i = 0; i < allEdgeIds.length; i++) {\n const edge = this.body.edges[allEdgeIds[i]];\n edge.setOptions(newOptions);\n }\n this.body.emitter.emit(\"_dataChanged\");\n }\n\n /**\n * Get a stack of clusterEdgeId's (+base edgeid) that a base edge is the same as. cluster edge C -> cluster edge B -> cluster edge A -> base edge(edgeId)\n *\n * @param {vis.Edge.id} edgeId\n * @returns {Array.<vis.Edge.id>}\n */\n getClusteredEdges(edgeId) {\n const stack = [];\n const max = 100;\n let counter = 0;\n\n while (\n edgeId !== undefined &&\n this.body.edges[edgeId] !== undefined &&\n counter < max\n ) {\n stack.push(this.body.edges[edgeId].id);\n edgeId = this.body.edges[edgeId].edgeReplacedById;\n counter++;\n }\n stack.reverse();\n return stack;\n }\n\n /**\n * Get the base edge id of clusterEdgeId. cluster edge (clusteredEdgeId) -> cluster edge B -> cluster edge C -> base edge\n *\n * @param {vis.Edge.id} clusteredEdgeId\n * @returns {vis.Edge.id} baseEdgeId\n *\n * TODO: deprecate in 5.0.0. Method getBaseEdges() is the correct one to use.\n */\n getBaseEdge(clusteredEdgeId) {\n // Just kludge this by returning the first base edge id found\n return this.getBaseEdges(clusteredEdgeId)[0];\n }\n\n /**\n * Get all regular edges for this clustered edge id.\n *\n * @param {vis.Edge.id} clusteredEdgeId\n * @returns {Array.<vis.Edge.id>} all baseEdgeId's under this clustered edge\n */\n getBaseEdges(clusteredEdgeId) {\n const IdsToHandle = [clusteredEdgeId];\n const doneIds = [];\n const foundIds = [];\n const max = 100;\n let counter = 0;\n\n while (IdsToHandle.length > 0 && counter < max) {\n const nextId = IdsToHandle.pop();\n if (nextId === undefined) continue; // Paranoia here and onwards\n const nextEdge = this.body.edges[nextId];\n if (nextEdge === undefined) continue;\n counter++;\n\n const replacingIds = nextEdge.clusteringEdgeReplacingIds;\n if (replacingIds === undefined) {\n // nextId is a base id\n foundIds.push(nextId);\n } else {\n // Another cluster edge, unravel this one as well\n for (let i = 0; i < replacingIds.length; ++i) {\n const replacingId = replacingIds[i];\n\n // Don't add if already handled\n // TODO: never triggers; find a test-case which does\n if (\n IdsToHandle.indexOf(replacingIds) !== -1 ||\n doneIds.indexOf(replacingIds) !== -1\n ) {\n continue;\n }\n\n IdsToHandle.push(replacingId);\n }\n }\n\n doneIds.push(nextId);\n }\n\n return foundIds;\n }\n\n /**\n * Get the Id the node is connected to\n *\n * @param {vis.Edge} edge\n * @param {Node.id} nodeId\n * @returns {*}\n * @private\n */\n _getConnectedId(edge, nodeId) {\n if (edge.toId != nodeId) {\n return edge.toId;\n } else if (edge.fromId != nodeId) {\n return edge.fromId;\n } else {\n return edge.fromId;\n }\n }\n\n /**\n * We determine how many connections denote an important hub.\n * We take the mean + 2*std as the important hub size. (Assuming a normal distribution of data, ~2.2%)\n *\n * @returns {number}\n * @private\n */\n _getHubSize() {\n let average = 0;\n let averageSquared = 0;\n let hubCounter = 0;\n let largestHub = 0;\n\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n const node = this.body.nodes[this.body.nodeIndices[i]];\n if (node.edges.length > largestHub) {\n largestHub = node.edges.length;\n }\n average += node.edges.length;\n averageSquared += Math.pow(node.edges.length, 2);\n hubCounter += 1;\n }\n average = average / hubCounter;\n averageSquared = averageSquared / hubCounter;\n\n const variance = averageSquared - Math.pow(average, 2);\n const standardDeviation = Math.sqrt(variance);\n\n let hubThreshold = Math.floor(average + 2 * standardDeviation);\n\n // always have at least one to cluster\n if (hubThreshold > largestHub) {\n hubThreshold = largestHub;\n }\n\n return hubThreshold;\n }\n\n /**\n * Create an edge for the cluster representation.\n *\n * @param {Node.id} fromId\n * @param {Node.id} toId\n * @param {vis.Edge} baseEdge\n * @param {object} clusterEdgeProperties\n * @param {object} extraOptions\n * @returns {Edge} newly created clustered edge\n * @private\n */\n _createClusteredEdge(\n fromId,\n toId,\n baseEdge,\n clusterEdgeProperties,\n extraOptions\n ) {\n // copy the options of the edge we will replace\n const clonedOptions = NetworkUtil.cloneOptions(baseEdge, \"edge\");\n // make sure the properties of clusterEdges are superimposed on it\n deepExtend(clonedOptions, clusterEdgeProperties);\n\n // set up the edge\n clonedOptions.from = fromId;\n clonedOptions.to = toId;\n clonedOptions.id = \"clusterEdge:\" + randomUUID();\n\n // apply the edge specific options to it if specified\n if (extraOptions !== undefined) {\n deepExtend(clonedOptions, extraOptions);\n }\n\n const newEdge = this.body.functions.createEdge(clonedOptions);\n newEdge.clusteringEdgeReplacingIds = [baseEdge.id];\n newEdge.connect();\n\n // Register the new edge\n this.body.edges[newEdge.id] = newEdge;\n\n return newEdge;\n }\n\n /**\n * Add the passed child nodes and edges to the given cluster node.\n *\n * @param {object | Node} childNodes hash of nodes or single node to add in cluster\n * @param {object | Edge} childEdges hash of edges or single edge to take into account when clustering\n * @param {Node} clusterNode cluster node to add nodes and edges to\n * @param {object} [clusterEdgeProperties]\n * @private\n */\n _clusterEdges(childNodes, childEdges, clusterNode, clusterEdgeProperties) {\n if (childEdges instanceof Edge) {\n const edge = childEdges;\n const obj = {};\n obj[edge.id] = edge;\n childEdges = obj;\n }\n\n if (childNodes instanceof Node) {\n const node = childNodes;\n const obj = {};\n obj[node.id] = node;\n childNodes = obj;\n }\n\n if (clusterNode === undefined || clusterNode === null) {\n throw new Error(\"_clusterEdges: parameter clusterNode required\");\n }\n\n if (clusterEdgeProperties === undefined) {\n // Take the required properties from the cluster node\n clusterEdgeProperties = clusterNode.clusterEdgeProperties;\n }\n\n // create the new edges that will connect to the cluster.\n // All self-referencing edges will be added to childEdges here.\n this._createClusterEdges(\n childNodes,\n childEdges,\n clusterNode,\n clusterEdgeProperties\n );\n\n // disable the childEdges\n for (const edgeId in childEdges) {\n if (Object.prototype.hasOwnProperty.call(childEdges, edgeId)) {\n if (this.body.edges[edgeId] !== undefined) {\n const edge = this.body.edges[edgeId];\n // cache the options before changing\n this._backupEdgeOptions(edge);\n // disable physics and hide the edge\n edge.setOptions({ physics: false });\n }\n }\n }\n\n // disable the childNodes\n for (const nodeId in childNodes) {\n if (Object.prototype.hasOwnProperty.call(childNodes, nodeId)) {\n this.clusteredNodes[nodeId] = {\n clusterId: clusterNode.id,\n node: this.body.nodes[nodeId],\n };\n this.body.nodes[nodeId].setOptions({ physics: false });\n }\n }\n }\n\n /**\n * Determine in which cluster given nodeId resides.\n *\n * If not in cluster, return undefined.\n *\n * NOTE: If you know a cleaner way to do this, please enlighten me (wimrijnders).\n *\n * @param {Node.id} nodeId\n * @returns {Node|undefined} Node instance for cluster, if present\n * @private\n */\n _getClusterNodeForNode(nodeId) {\n if (nodeId === undefined) return undefined;\n const clusteredNode = this.clusteredNodes[nodeId];\n\n // NOTE: If no cluster info found, it should actually be an error\n if (clusteredNode === undefined) return undefined;\n const clusterId = clusteredNode.clusterId;\n if (clusterId === undefined) return undefined;\n\n return this.body.nodes[clusterId];\n }\n\n /**\n * Internal helper function for conditionally removing items in array\n *\n * Done like this because Array.filter() is not fully supported by all IE's.\n *\n * @param {Array} arr\n * @param {Function} callback\n * @returns {Array}\n * @private\n */\n _filter(arr, callback) {\n const ret = [];\n\n forEach(arr, (item) => {\n if (callback(item)) {\n ret.push(item);\n }\n });\n\n return ret;\n }\n\n /**\n * Scan all edges for changes in clustering and adjust this if necessary.\n *\n * Call this (internally) after there has been a change in node or edge data.\n *\n * Pre: States of this.body.nodes and this.body.edges consistent\n * Pre: this.clusteredNodes and this.clusteredEdge consistent with containedNodes and containedEdges\n * of cluster nodes.\n */\n _updateState() {\n let nodeId;\n const deletedNodeIds = [];\n const deletedEdgeIds = {};\n\n /**\n * Utility function to iterate over clustering nodes only\n *\n * @param {Function} callback function to call for each cluster node\n */\n const eachClusterNode = (callback) => {\n forEach(this.body.nodes, (node) => {\n if (node.isCluster === true) {\n callback(node);\n }\n });\n };\n\n //\n // Remove deleted regular nodes from clustering\n //\n\n // Determine the deleted nodes\n for (nodeId in this.clusteredNodes) {\n if (!Object.prototype.hasOwnProperty.call(this.clusteredNodes, nodeId))\n continue;\n const node = this.body.nodes[nodeId];\n\n if (node === undefined) {\n deletedNodeIds.push(nodeId);\n }\n }\n\n // Remove nodes from cluster nodes\n eachClusterNode(function (clusterNode) {\n for (let n = 0; n < deletedNodeIds.length; n++) {\n delete clusterNode.containedNodes[deletedNodeIds[n]];\n }\n });\n\n // Remove nodes from cluster list\n for (let n = 0; n < deletedNodeIds.length; n++) {\n delete this.clusteredNodes[deletedNodeIds[n]];\n }\n\n //\n // Remove deleted edges from clustering\n //\n\n // Add the deleted clustered edges to the list\n forEach(this.clusteredEdges, (edgeId) => {\n const edge = this.body.edges[edgeId];\n if (edge === undefined || !edge.endPointsValid()) {\n deletedEdgeIds[edgeId] = edgeId;\n }\n });\n\n // Cluster nodes can also contain edges which are not clustered,\n // i.e. nodes 1-2 within cluster with an edge in between.\n // So the cluster nodes also need to be scanned for invalid edges\n eachClusterNode(function (clusterNode) {\n forEach(clusterNode.containedEdges, (edge, edgeId) => {\n if (!edge.endPointsValid() && !deletedEdgeIds[edgeId]) {\n deletedEdgeIds[edgeId] = edgeId;\n }\n });\n });\n\n // Also scan for cluster edges which need to be removed in the active list.\n // Regular edges have been removed beforehand, so this only picks up the cluster edges.\n forEach(this.body.edges, (edge, edgeId) => {\n // Explicitly scan the contained edges for validity\n let isValid = true;\n const replacedIds = edge.clusteringEdgeReplacingIds;\n if (replacedIds !== undefined) {\n let numValid = 0;\n\n forEach(replacedIds, (containedEdgeId) => {\n const containedEdge = this.body.edges[containedEdgeId];\n\n if (containedEdge !== undefined && containedEdge.endPointsValid()) {\n numValid += 1;\n }\n });\n\n isValid = numValid > 0;\n }\n\n if (!edge.endPointsValid() || !isValid) {\n deletedEdgeIds[edgeId] = edgeId;\n }\n });\n\n // Remove edges from cluster nodes\n eachClusterNode((clusterNode) => {\n forEach(deletedEdgeIds, (deletedEdgeId) => {\n delete clusterNode.containedEdges[deletedEdgeId];\n\n forEach(clusterNode.edges, (edge, m) => {\n if (edge.id === deletedEdgeId) {\n clusterNode.edges[m] = null; // Don't want to directly delete here, because in the loop\n return;\n }\n\n edge.clusteringEdgeReplacingIds = this._filter(\n edge.clusteringEdgeReplacingIds,\n function (id) {\n return !deletedEdgeIds[id];\n }\n );\n });\n\n // Clean up the nulls\n clusterNode.edges = this._filter(clusterNode.edges, function (item) {\n return item !== null;\n });\n });\n });\n\n // Remove from cluster list\n forEach(deletedEdgeIds, (edgeId) => {\n delete this.clusteredEdges[edgeId];\n });\n\n // Remove cluster edges from active list (this.body.edges).\n // deletedEdgeIds still contains id of regular edges, but these should all\n // be gone when you reach here.\n forEach(deletedEdgeIds, (edgeId) => {\n delete this.body.edges[edgeId];\n });\n\n //\n // Check changed cluster state of edges\n //\n\n // Iterating over keys here, because edges may be removed in the loop\n const ids = Object.keys(this.body.edges);\n forEach(ids, (edgeId) => {\n const edge = this.body.edges[edgeId];\n\n const shouldBeClustered =\n this._isClusteredNode(edge.fromId) || this._isClusteredNode(edge.toId);\n if (shouldBeClustered === this._isClusteredEdge(edge.id)) {\n return; // all is well\n }\n\n if (shouldBeClustered) {\n // add edge to clustering\n const clusterFrom = this._getClusterNodeForNode(edge.fromId);\n if (clusterFrom !== undefined) {\n this._clusterEdges(this.body.nodes[edge.fromId], edge, clusterFrom);\n }\n\n const clusterTo = this._getClusterNodeForNode(edge.toId);\n if (clusterTo !== undefined) {\n this._clusterEdges(this.body.nodes[edge.toId], edge, clusterTo);\n }\n\n // TODO: check that it works for both edges clustered\n // (This might be paranoia)\n } else {\n delete this._clusterEdges[edgeId];\n this._restoreEdge(edge);\n // This should not be happening, the state should\n // be properly updated at this point.\n //\n // If it *is* reached during normal operation, then we have to implement\n // undo clustering for this edge here.\n // throw new Error('remove edge from clustering not implemented!')\n }\n });\n\n // Clusters may be nested to any level. Keep on opening until nothing to open\n let changed = false;\n let continueLoop = true;\n while (continueLoop) {\n const clustersToOpen = [];\n\n // Determine the id's of clusters that need opening\n eachClusterNode(function (clusterNode) {\n const numNodes = Object.keys(clusterNode.containedNodes).length;\n const allowSingle = clusterNode.options.allowSingleNodeCluster === true;\n if ((allowSingle && numNodes < 1) || (!allowSingle && numNodes < 2)) {\n clustersToOpen.push(clusterNode.id);\n }\n });\n\n // Open them\n for (let n = 0; n < clustersToOpen.length; ++n) {\n this.openCluster(\n clustersToOpen[n],\n {},\n false /* Don't refresh, we're in an refresh/update already */\n );\n }\n\n continueLoop = clustersToOpen.length > 0;\n changed = changed || continueLoop;\n }\n\n if (changed) {\n this._updateState(); // Redo this method (recursion possible! should be safe)\n }\n }\n\n /**\n * Determine if node with given id is part of a cluster.\n *\n * @param {Node.id} nodeId\n * @returns {boolean} true if part of a cluster.\n */\n _isClusteredNode(nodeId) {\n return this.clusteredNodes[nodeId] !== undefined;\n }\n\n /**\n * Determine if edge with given id is not visible due to clustering.\n *\n * An edge is considered clustered if:\n * - it is directly replaced by a clustering edge\n * - any of its connecting nodes is in a cluster\n *\n * @param {vis.Edge.id} edgeId\n * @returns {boolean} true if part of a cluster.\n */\n _isClusteredEdge(edgeId) {\n return this.clusteredEdges[edgeId] !== undefined;\n }\n}\n\nexport default ClusterEngine;\n","import { selectiveDeepExtend } from \"vis-util/esnext\";\n\n/**\n * Initializes window.requestAnimationFrame() to a usable form.\n *\n * Specifically, set up this method for the case of running on node.js with jsdom enabled.\n *\n * NOTES:\n *\n * * On node.js, when calling this directly outside of this class, `window` is not defined.\n * This happens even if jsdom is used.\n * * For node.js + jsdom, `window` is available at the moment the constructor is called.\n * For this reason, the called is placed within the constructor.\n * * Even then, `window.requestAnimationFrame()` is not defined, so it still needs to be added.\n * * During unit testing, it happens that the window object is reset during execution, causing\n * a runtime error due to missing `requestAnimationFrame()`. This needs to be compensated for,\n * see `_requestNextFrame()`.\n * * Since this is a global object, it may affect other modules besides `Network`. With normal\n * usage, this does not cause any problems. During unit testing, errors may occur. These have\n * been compensated for, see comment block in _requestNextFrame().\n *\n * @private\n */\nfunction _initRequestAnimationFrame() {\n let func;\n\n if (window !== undefined) {\n func =\n window.requestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.msRequestAnimationFrame;\n }\n\n if (func === undefined) {\n // window or method not present, setting mock requestAnimationFrame\n window.requestAnimationFrame = function (callback) {\n //console.log(\"Called mock requestAnimationFrame\");\n callback();\n };\n } else {\n window.requestAnimationFrame = func;\n }\n}\n\n/**\n * The canvas renderer\n */\nclass CanvasRenderer {\n /**\n * @param {object} body\n * @param {Canvas} canvas\n */\n constructor(body, canvas) {\n _initRequestAnimationFrame();\n this.body = body;\n this.canvas = canvas;\n\n this.redrawRequested = false;\n this.renderTimer = undefined;\n this.requiresTimeout = true;\n this.renderingActive = false;\n this.renderRequests = 0;\n this.allowRedraw = true;\n\n this.dragging = false;\n this.zooming = false;\n this.options = {};\n this.defaultOptions = {\n hideEdgesOnDrag: false,\n hideEdgesOnZoom: false,\n hideNodesOnDrag: false,\n };\n Object.assign(this.options, this.defaultOptions);\n\n this._determineBrowserMethod();\n this.bindEventListeners();\n }\n\n /**\n * Binds event listeners\n */\n bindEventListeners() {\n this.body.emitter.on(\"dragStart\", () => {\n this.dragging = true;\n });\n this.body.emitter.on(\"dragEnd\", () => {\n this.dragging = false;\n });\n this.body.emitter.on(\"zoom\", () => {\n this.zooming = true;\n window.clearTimeout(this.zoomTimeoutId);\n this.zoomTimeoutId = window.setTimeout(() => {\n this.zooming = false;\n this._requestRedraw.bind(this)();\n }, 250);\n });\n this.body.emitter.on(\"_resizeNodes\", () => {\n this._resizeNodes();\n });\n this.body.emitter.on(\"_redraw\", () => {\n if (this.renderingActive === false) {\n this._redraw();\n }\n });\n this.body.emitter.on(\"_blockRedraw\", () => {\n this.allowRedraw = false;\n });\n this.body.emitter.on(\"_allowRedraw\", () => {\n this.allowRedraw = true;\n this.redrawRequested = false;\n });\n this.body.emitter.on(\"_requestRedraw\", this._requestRedraw.bind(this));\n this.body.emitter.on(\"_startRendering\", () => {\n this.renderRequests += 1;\n this.renderingActive = true;\n this._startRendering();\n });\n this.body.emitter.on(\"_stopRendering\", () => {\n this.renderRequests -= 1;\n this.renderingActive = this.renderRequests > 0;\n this.renderTimer = undefined;\n });\n this.body.emitter.on(\"destroy\", () => {\n this.renderRequests = 0;\n this.allowRedraw = false;\n this.renderingActive = false;\n if (this.requiresTimeout === true) {\n clearTimeout(this.renderTimer);\n } else {\n window.cancelAnimationFrame(this.renderTimer);\n }\n this.body.emitter.off();\n });\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n if (options !== undefined) {\n const fields = [\"hideEdgesOnDrag\", \"hideEdgesOnZoom\", \"hideNodesOnDrag\"];\n selectiveDeepExtend(fields, this.options, options);\n }\n }\n\n /**\n * Prepare the drawing of the next frame.\n *\n * Calls the callback when the next frame can or will be drawn.\n *\n * @param {Function} callback\n * @param {number} delay - timeout case only, wait this number of milliseconds\n * @returns {Function | undefined}\n * @private\n */\n _requestNextFrame(callback, delay) {\n // During unit testing, it happens that the mock window object is reset while\n // the next frame is still pending. Then, either 'window' is not present, or\n // 'requestAnimationFrame()' is not present because it is not defined on the\n // mock window object.\n //\n // As a consequence, unrelated unit tests may appear to fail, even if the problem\n // described happens in the current unit test.\n //\n // This is not something that will happen in normal operation, but we still need\n // to take it into account.\n //\n if (typeof window === \"undefined\") return; // Doing `if (window === undefined)` does not work here!\n\n let timer;\n\n const myWindow = window; // Grab a reference to reduce the possibility that 'window' is reset\n // while running this method.\n\n if (this.requiresTimeout === true) {\n // wait given number of milliseconds and perform the animation step function\n timer = myWindow.setTimeout(callback, delay);\n } else {\n if (myWindow.requestAnimationFrame) {\n timer = myWindow.requestAnimationFrame(callback);\n }\n }\n\n return timer;\n }\n\n /**\n *\n * @private\n */\n _startRendering() {\n if (this.renderingActive === true) {\n if (this.renderTimer === undefined) {\n this.renderTimer = this._requestNextFrame(\n this._renderStep.bind(this),\n this.simulationInterval\n );\n }\n }\n }\n\n /**\n *\n * @private\n */\n _renderStep() {\n if (this.renderingActive === true) {\n // reset the renderTimer so a new scheduled animation step can be set\n this.renderTimer = undefined;\n\n if (this.requiresTimeout === true) {\n // this schedules a new simulation step\n this._startRendering();\n }\n\n this._redraw();\n\n if (this.requiresTimeout === false) {\n // this schedules a new simulation step\n this._startRendering();\n }\n }\n }\n\n /**\n * Redraw the network with the current data\n * chart will be resized too.\n */\n redraw() {\n this.body.emitter.emit(\"setSize\");\n this._redraw();\n }\n\n /**\n * Redraw the network with the current data\n *\n * @private\n */\n _requestRedraw() {\n if (\n this.redrawRequested !== true &&\n this.renderingActive === false &&\n this.allowRedraw === true\n ) {\n this.redrawRequested = true;\n this._requestNextFrame(() => {\n this._redraw(false);\n }, 0);\n }\n }\n\n /**\n * Redraw the network with the current data\n *\n * @param {boolean} [hidden=false] | Used to get the first estimate of the node sizes.\n * Only the nodes are drawn after which they are quickly drawn over.\n * @private\n */\n _redraw(hidden = false) {\n if (this.allowRedraw === true) {\n this.body.emitter.emit(\"initRedraw\");\n\n this.redrawRequested = false;\n\n const drawLater = {\n drawExternalLabels: null,\n };\n\n // when the container div was hidden, this fixes it back up!\n if (\n this.canvas.frame.canvas.width === 0 ||\n this.canvas.frame.canvas.height === 0\n ) {\n this.canvas.setSize();\n }\n\n this.canvas.setTransform();\n\n const ctx = this.canvas.getContext();\n\n // clear the canvas\n const w = this.canvas.frame.canvas.clientWidth;\n const h = this.canvas.frame.canvas.clientHeight;\n ctx.clearRect(0, 0, w, h);\n\n // if the div is hidden, we stop the redraw here for performance.\n if (this.canvas.frame.clientWidth === 0) {\n return;\n }\n\n // set scaling and translation\n ctx.save();\n ctx.translate(this.body.view.translation.x, this.body.view.translation.y);\n ctx.scale(this.body.view.scale, this.body.view.scale);\n\n ctx.beginPath();\n this.body.emitter.emit(\"beforeDrawing\", ctx);\n ctx.closePath();\n\n if (hidden === false) {\n if (\n (this.dragging === false ||\n (this.dragging === true &&\n this.options.hideEdgesOnDrag === false)) &&\n (this.zooming === false ||\n (this.zooming === true && this.options.hideEdgesOnZoom === false))\n ) {\n this._drawEdges(ctx);\n }\n }\n\n if (\n this.dragging === false ||\n (this.dragging === true && this.options.hideNodesOnDrag === false)\n ) {\n const { drawExternalLabels } = this._drawNodes(ctx, hidden);\n drawLater.drawExternalLabels = drawExternalLabels;\n }\n\n // draw the arrows last so they will be at the top\n if (hidden === false) {\n if (\n (this.dragging === false ||\n (this.dragging === true &&\n this.options.hideEdgesOnDrag === false)) &&\n (this.zooming === false ||\n (this.zooming === true && this.options.hideEdgesOnZoom === false))\n ) {\n this._drawArrows(ctx);\n }\n }\n\n if (drawLater.drawExternalLabels != null) {\n drawLater.drawExternalLabels();\n }\n\n if (hidden === false) {\n this._drawSelectionBox(ctx);\n }\n\n ctx.beginPath();\n this.body.emitter.emit(\"afterDrawing\", ctx);\n ctx.closePath();\n\n // restore original scaling and translation\n ctx.restore();\n if (hidden === true) {\n ctx.clearRect(0, 0, w, h);\n }\n }\n }\n\n /**\n * Redraw all nodes\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} [alwaysShow]\n * @private\n */\n _resizeNodes() {\n this.canvas.setTransform();\n const ctx = this.canvas.getContext();\n ctx.save();\n ctx.translate(this.body.view.translation.x, this.body.view.translation.y);\n ctx.scale(this.body.view.scale, this.body.view.scale);\n\n const nodes = this.body.nodes;\n let node;\n\n // resize all nodes\n for (const nodeId in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, nodeId)) {\n node = nodes[nodeId];\n node.resize(ctx);\n node.updateBoundingBox(ctx, node.selected);\n }\n }\n\n // restore original scaling and translation\n ctx.restore();\n }\n\n /**\n * Redraw all nodes\n *\n * @param {CanvasRenderingContext2D} ctx 2D context of a HTML canvas\n * @param {boolean} [alwaysShow]\n * @private\n *\n * @returns {object} Callbacks to draw later on higher layers.\n */\n _drawNodes(ctx, alwaysShow = false) {\n const nodes = this.body.nodes;\n const nodeIndices = this.body.nodeIndices;\n let node;\n const selected = [];\n const hovered = [];\n const margin = 20;\n const topLeft = this.canvas.DOMtoCanvas({ x: -margin, y: -margin });\n const bottomRight = this.canvas.DOMtoCanvas({\n x: this.canvas.frame.canvas.clientWidth + margin,\n y: this.canvas.frame.canvas.clientHeight + margin,\n });\n const viewableArea = {\n top: topLeft.y,\n left: topLeft.x,\n bottom: bottomRight.y,\n right: bottomRight.x,\n };\n\n const drawExternalLabels = [];\n\n // draw unselected nodes;\n for (let i = 0; i < nodeIndices.length; i++) {\n node = nodes[nodeIndices[i]];\n // set selected and hovered nodes aside\n if (node.hover) {\n hovered.push(nodeIndices[i]);\n } else if (node.isSelected()) {\n selected.push(nodeIndices[i]);\n } else {\n if (alwaysShow === true) {\n const drawLater = node.draw(ctx);\n if (drawLater.drawExternalLabel != null) {\n drawExternalLabels.push(drawLater.drawExternalLabel);\n }\n } else if (node.isBoundingBoxOverlappingWith(viewableArea) === true) {\n const drawLater = node.draw(ctx);\n if (drawLater.drawExternalLabel != null) {\n drawExternalLabels.push(drawLater.drawExternalLabel);\n }\n } else {\n node.updateBoundingBox(ctx, node.selected);\n }\n }\n }\n\n let i;\n const selectedLength = selected.length;\n const hoveredLength = hovered.length;\n\n // draw the selected nodes on top\n for (i = 0; i < selectedLength; i++) {\n node = nodes[selected[i]];\n const drawLater = node.draw(ctx);\n if (drawLater.drawExternalLabel != null) {\n drawExternalLabels.push(drawLater.drawExternalLabel);\n }\n }\n\n // draw hovered nodes above everything else: fixes https://github.com/visjs/vis-network/issues/226\n for (i = 0; i < hoveredLength; i++) {\n node = nodes[hovered[i]];\n const drawLater = node.draw(ctx);\n if (drawLater.drawExternalLabel != null) {\n drawExternalLabels.push(drawLater.drawExternalLabel);\n }\n }\n\n return {\n drawExternalLabels: () => {\n for (const draw of drawExternalLabels) {\n draw();\n }\n },\n };\n }\n\n /**\n * Redraw all edges\n *\n * @param {CanvasRenderingContext2D} ctx 2D context of a HTML canvas\n * @private\n */\n _drawEdges(ctx) {\n const edges = this.body.edges;\n const edgeIndices = this.body.edgeIndices;\n\n for (let i = 0; i < edgeIndices.length; i++) {\n const edge = edges[edgeIndices[i]];\n if (edge.connected === true) {\n edge.draw(ctx);\n }\n }\n }\n\n /**\n * Redraw all arrows\n *\n * @param {CanvasRenderingContext2D} ctx 2D context of a HTML canvas\n * @private\n */\n _drawArrows(ctx) {\n const edges = this.body.edges;\n const edgeIndices = this.body.edgeIndices;\n\n for (let i = 0; i < edgeIndices.length; i++) {\n const edge = edges[edgeIndices[i]];\n if (edge.connected === true) {\n edge.drawArrows(ctx);\n }\n }\n }\n\n /**\n * Determine if the browser requires a setTimeout or a requestAnimationFrame. This was required because\n * some implementations (safari and IE9) did not support requestAnimationFrame\n *\n * @private\n */\n _determineBrowserMethod() {\n if (typeof window !== \"undefined\") {\n const browserType = navigator.userAgent.toLowerCase();\n this.requiresTimeout = false;\n if (browserType.indexOf(\"msie 9.0\") != -1) {\n // IE 9\n this.requiresTimeout = true;\n } else if (browserType.indexOf(\"safari\") != -1) {\n // safari\n if (browserType.indexOf(\"chrome\") <= -1) {\n this.requiresTimeout = true;\n }\n }\n } else {\n this.requiresTimeout = true;\n }\n }\n\n /**\n * Redraw selection box\n *\n * @param {CanvasRenderingContext2D} ctx 2D context of a HTML canvas\n * @private\n */\n _drawSelectionBox(ctx) {\n if (this.body.selectionBox.show) {\n ctx.beginPath();\n const width =\n this.body.selectionBox.position.end.x -\n this.body.selectionBox.position.start.x;\n const height =\n this.body.selectionBox.position.end.y -\n this.body.selectionBox.position.start.y;\n ctx.rect(\n this.body.selectionBox.position.start.x,\n this.body.selectionBox.position.start.y,\n width,\n height\n );\n ctx.fillStyle = \"rgba(151, 194, 252, 0.2)\";\n ctx.fillRect(\n this.body.selectionBox.position.start.x,\n this.body.selectionBox.position.start.y,\n width,\n height\n );\n ctx.strokeStyle = \"rgba(151, 194, 252, 1)\";\n ctx.stroke();\n } else {\n ctx.closePath();\n }\n }\n}\n\nexport default CanvasRenderer;\n","/**\n * Register a touch event, taking place before a gesture\n *\n * @param {Hammer} hammer A hammer instance\n * @param {Function} callback Callback, called as callback(event)\n */\nexport function onTouch(hammer, callback) {\n callback.inputHandler = function (event) {\n if (event.isFirst) {\n callback(event);\n }\n };\n\n hammer.on(\"hammer.input\", callback.inputHandler);\n}\n\n/**\n * Register a release event, taking place after a gesture\n *\n * @param {Hammer} hammer A hammer instance\n * @param {Function} callback Callback, called as callback(event)\n * @returns {*}\n */\nexport function onRelease(hammer, callback) {\n callback.inputHandler = function (event) {\n if (event.isFinal) {\n callback(event);\n }\n };\n\n return hammer.on(\"hammer.input\", callback.inputHandler);\n}\n\n/**\n * Unregister a touch event, taking place before a gesture\n *\n * @param {Hammer} hammer A hammer instance\n * @param {Function} callback Callback, called as callback(event)\n */\nexport function offTouch(hammer, callback) {\n hammer.off(\"hammer.input\", callback.inputHandler);\n}\n\n/**\n * Unregister a release event, taking place before a gesture\n *\n * @param {Hammer} hammer A hammer instance\n * @param {Function} callback Callback, called as callback(event)\n */\nexport const offRelease = offTouch;\n\n/**\n * Hack the PinchRecognizer such that it doesn't prevent default behavior\n * for vertical panning.\n *\n * Yeah ... this is quite a hack ... see https://github.com/hammerjs/hammer.js/issues/932\n *\n * @param {Hammer.Pinch} pinchRecognizer\n * @returns {Hammer.Pinch} returns the pinchRecognizer\n */\nexport function disablePreventDefaultVertically(pinchRecognizer) {\n const TOUCH_ACTION_PAN_Y = \"pan-y\";\n\n pinchRecognizer.getTouchAction = function () {\n // default method returns [TOUCH_ACTION_NONE]\n return [TOUCH_ACTION_PAN_Y];\n };\n\n return pinchRecognizer;\n}\n","import { onRelease, onTouch } from \"../../hammerUtil\";\n\nimport {\n Hammer,\n addEventListener,\n removeEventListener,\n selectiveDeepExtend,\n} from \"vis-util/esnext\";\n\n/**\n * Create the main frame for the Network.\n * This function is executed once when a Network object is created. The frame\n * contains a canvas, and this canvas contains all objects like the axis and\n * nodes.\n */\nclass Canvas {\n /**\n * @param {object} body\n */\n constructor(body) {\n this.body = body;\n this.pixelRatio = 1;\n this.cameraState = {};\n this.initialized = false;\n this.canvasViewCenter = {};\n this._cleanupCallbacks = [];\n\n this.options = {};\n this.defaultOptions = {\n autoResize: true,\n height: \"100%\",\n width: \"100%\",\n };\n Object.assign(this.options, this.defaultOptions);\n\n this.bindEventListeners();\n }\n\n /**\n * Binds event listeners\n */\n bindEventListeners() {\n // bind the events\n this.body.emitter.once(\"resize\", (obj) => {\n if (obj.width !== 0) {\n this.body.view.translation.x = obj.width * 0.5;\n }\n if (obj.height !== 0) {\n this.body.view.translation.y = obj.height * 0.5;\n }\n });\n this.body.emitter.on(\"setSize\", this.setSize.bind(this));\n this.body.emitter.on(\"destroy\", () => {\n this.hammerFrame.destroy();\n this.hammer.destroy();\n this._cleanUp();\n });\n }\n\n /**\n * @param {object} options\n */\n setOptions(options) {\n if (options !== undefined) {\n const fields = [\"width\", \"height\", \"autoResize\"];\n selectiveDeepExtend(fields, this.options, options);\n }\n\n // Automatically adapt to changing size of the container element.\n this._cleanUp();\n if (this.options.autoResize === true) {\n if (window.ResizeObserver) {\n // decent browsers, immediate reactions\n const observer = new ResizeObserver(() => {\n const changed = this.setSize();\n if (changed === true) {\n this.body.emitter.emit(\"_requestRedraw\");\n }\n });\n const { frame } = this;\n\n observer.observe(frame);\n this._cleanupCallbacks.push(() => {\n observer.unobserve(frame);\n });\n } else {\n // IE11, continous polling\n const resizeTimer = setInterval(() => {\n const changed = this.setSize();\n if (changed === true) {\n this.body.emitter.emit(\"_requestRedraw\");\n }\n }, 1000);\n this._cleanupCallbacks.push(() => {\n clearInterval(resizeTimer);\n });\n }\n\n // Automatically adapt to changing size of the browser.\n const resizeFunction = this._onResize.bind(this);\n addEventListener(window, \"resize\", resizeFunction);\n this._cleanupCallbacks.push(() => {\n removeEventListener(window, \"resize\", resizeFunction);\n });\n }\n }\n\n /**\n * @private\n */\n _cleanUp() {\n this._cleanupCallbacks\n .splice(0)\n .reverse()\n .forEach((callback) => {\n try {\n callback();\n } catch (error) {\n console.error(error);\n }\n });\n }\n\n /**\n * @private\n */\n _onResize() {\n this.setSize();\n this.body.emitter.emit(\"_redraw\");\n }\n\n /**\n * Get and store the cameraState\n *\n * @param {number} [pixelRatio=this.pixelRatio]\n * @private\n */\n _getCameraState(pixelRatio = this.pixelRatio) {\n if (this.initialized === true) {\n this.cameraState.previousWidth = this.frame.canvas.width / pixelRatio;\n this.cameraState.previousHeight = this.frame.canvas.height / pixelRatio;\n this.cameraState.scale = this.body.view.scale;\n this.cameraState.position = this.DOMtoCanvas({\n x: (0.5 * this.frame.canvas.width) / pixelRatio,\n y: (0.5 * this.frame.canvas.height) / pixelRatio,\n });\n }\n }\n\n /**\n * Set the cameraState\n *\n * @private\n */\n _setCameraState() {\n if (\n this.cameraState.scale !== undefined &&\n this.frame.canvas.clientWidth !== 0 &&\n this.frame.canvas.clientHeight !== 0 &&\n this.pixelRatio !== 0 &&\n this.cameraState.previousWidth > 0 &&\n this.cameraState.previousHeight > 0\n ) {\n const widthRatio =\n this.frame.canvas.width /\n this.pixelRatio /\n this.cameraState.previousWidth;\n const heightRatio =\n this.frame.canvas.height /\n this.pixelRatio /\n this.cameraState.previousHeight;\n let newScale = this.cameraState.scale;\n\n if (widthRatio != 1 && heightRatio != 1) {\n newScale = this.cameraState.scale * 0.5 * (widthRatio + heightRatio);\n } else if (widthRatio != 1) {\n newScale = this.cameraState.scale * widthRatio;\n } else if (heightRatio != 1) {\n newScale = this.cameraState.scale * heightRatio;\n }\n\n this.body.view.scale = newScale;\n // this comes from the view module.\n const currentViewCenter = this.DOMtoCanvas({\n x: 0.5 * this.frame.canvas.clientWidth,\n y: 0.5 * this.frame.canvas.clientHeight,\n });\n\n const distanceFromCenter = {\n // offset from view, distance view has to change by these x and y to center the node\n x: currentViewCenter.x - this.cameraState.position.x,\n y: currentViewCenter.y - this.cameraState.position.y,\n };\n this.body.view.translation.x +=\n distanceFromCenter.x * this.body.view.scale;\n this.body.view.translation.y +=\n distanceFromCenter.y * this.body.view.scale;\n }\n }\n\n /**\n *\n * @param {number|string} value\n * @returns {string}\n * @private\n */\n _prepareValue(value) {\n if (typeof value === \"number\") {\n return value + \"px\";\n } else if (typeof value === \"string\") {\n if (value.indexOf(\"%\") !== -1 || value.indexOf(\"px\") !== -1) {\n return value;\n } else if (value.indexOf(\"%\") === -1) {\n return value + \"px\";\n }\n }\n throw new Error(\n \"Could not use the value supplied for width or height:\" + value\n );\n }\n\n /**\n * Create the HTML\n */\n _create() {\n // remove all elements from the container element.\n while (this.body.container.hasChildNodes()) {\n this.body.container.removeChild(this.body.container.firstChild);\n }\n\n this.frame = document.createElement(\"div\");\n this.frame.className = \"vis-network\";\n this.frame.style.position = \"relative\";\n this.frame.style.overflow = \"hidden\";\n this.frame.tabIndex = 0; // tab index is required for keycharm to bind keystrokes to the div instead of the window\n\n //////////////////////////////////////////////////////////////////\n\n this.frame.canvas = document.createElement(\"canvas\");\n this.frame.canvas.style.position = \"relative\";\n this.frame.appendChild(this.frame.canvas);\n\n if (!this.frame.canvas.getContext) {\n const noCanvas = document.createElement(\"DIV\");\n noCanvas.style.color = \"red\";\n noCanvas.style.fontWeight = \"bold\";\n noCanvas.style.padding = \"10px\";\n noCanvas.innerText = \"Error: your browser does not support HTML canvas\";\n this.frame.canvas.appendChild(noCanvas);\n } else {\n this._setPixelRatio();\n this.setTransform();\n }\n\n // add the frame to the container element\n this.body.container.appendChild(this.frame);\n\n this.body.view.scale = 1;\n this.body.view.translation = {\n x: 0.5 * this.frame.canvas.clientWidth,\n y: 0.5 * this.frame.canvas.clientHeight,\n };\n\n this._bindHammer();\n }\n\n /**\n * This function binds hammer, it can be repeated over and over due to the uniqueness check.\n *\n * @private\n */\n _bindHammer() {\n if (this.hammer !== undefined) {\n this.hammer.destroy();\n }\n this.drag = {};\n this.pinch = {};\n\n // init hammer\n this.hammer = new Hammer(this.frame.canvas);\n this.hammer.get(\"pinch\").set({ enable: true });\n // enable to get better response, todo: test on mobile.\n this.hammer\n .get(\"pan\")\n .set({ threshold: 5, direction: Hammer.DIRECTION_ALL });\n\n onTouch(this.hammer, (event) => {\n this.body.eventListeners.onTouch(event);\n });\n this.hammer.on(\"tap\", (event) => {\n this.body.eventListeners.onTap(event);\n });\n this.hammer.on(\"doubletap\", (event) => {\n this.body.eventListeners.onDoubleTap(event);\n });\n this.hammer.on(\"press\", (event) => {\n this.body.eventListeners.onHold(event);\n });\n this.hammer.on(\"panstart\", (event) => {\n this.body.eventListeners.onDragStart(event);\n });\n this.hammer.on(\"panmove\", (event) => {\n this.body.eventListeners.onDrag(event);\n });\n this.hammer.on(\"panend\", (event) => {\n this.body.eventListeners.onDragEnd(event);\n });\n this.hammer.on(\"pinch\", (event) => {\n this.body.eventListeners.onPinch(event);\n });\n\n // TODO: neatly cleanup these handlers when re-creating the Canvas, IF these are done with hammer, event.stopPropagation will not work?\n this.frame.canvas.addEventListener(\"wheel\", (event) => {\n this.body.eventListeners.onMouseWheel(event);\n });\n\n this.frame.canvas.addEventListener(\"mousemove\", (event) => {\n this.body.eventListeners.onMouseMove(event);\n });\n this.frame.canvas.addEventListener(\"contextmenu\", (event) => {\n this.body.eventListeners.onContext(event);\n });\n\n this.hammerFrame = new Hammer(this.frame);\n onRelease(this.hammerFrame, (event) => {\n this.body.eventListeners.onRelease(event);\n });\n }\n\n /**\n * Set a new size for the network\n *\n * @param {string} width Width in pixels or percentage (for example '800px'\n * or '50%')\n * @param {string} height Height in pixels or percentage (for example '400px'\n * or '30%')\n * @returns {boolean}\n */\n setSize(width = this.options.width, height = this.options.height) {\n width = this._prepareValue(width);\n height = this._prepareValue(height);\n\n let emitEvent = false;\n const oldWidth = this.frame.canvas.width;\n const oldHeight = this.frame.canvas.height;\n\n // update the pixel ratio\n //\n // NOTE: Comment in following is rather inconsistent; this is the ONLY place in the code\n // where it is assumed that the pixel ratio could change at runtime.\n // The only way I can think of this happening is a rotating screen or tablet; but then\n // there should be a mechanism for reloading the data (TODO: check if this is present).\n //\n // If the assumption is true (i.e. pixel ratio can change at runtime), then *all* usage\n // of pixel ratio must be overhauled for this.\n //\n // For the time being, I will humor the assumption here, and in the rest of the code assume it is\n // constant.\n const previousRatio = this.pixelRatio; // we cache this because the camera state storage needs the old value\n this._setPixelRatio();\n\n if (\n width != this.options.width ||\n height != this.options.height ||\n this.frame.style.width != width ||\n this.frame.style.height != height\n ) {\n this._getCameraState(previousRatio);\n\n this.frame.style.width = width;\n this.frame.style.height = height;\n\n this.frame.canvas.style.width = \"100%\";\n this.frame.canvas.style.height = \"100%\";\n\n this.frame.canvas.width = Math.round(\n this.frame.canvas.clientWidth * this.pixelRatio\n );\n this.frame.canvas.height = Math.round(\n this.frame.canvas.clientHeight * this.pixelRatio\n );\n\n this.options.width = width;\n this.options.height = height;\n\n this.canvasViewCenter = {\n x: 0.5 * this.frame.clientWidth,\n y: 0.5 * this.frame.clientHeight,\n };\n\n emitEvent = true;\n } else {\n // this would adapt the width of the canvas to the width from 100% if and only if\n // there is a change.\n\n const newWidth = Math.round(\n this.frame.canvas.clientWidth * this.pixelRatio\n );\n const newHeight = Math.round(\n this.frame.canvas.clientHeight * this.pixelRatio\n );\n\n // store the camera if there is a change in size.\n if (\n this.frame.canvas.width !== newWidth ||\n this.frame.canvas.height !== newHeight\n ) {\n this._getCameraState(previousRatio);\n }\n\n if (this.frame.canvas.width !== newWidth) {\n this.frame.canvas.width = newWidth;\n emitEvent = true;\n }\n if (this.frame.canvas.height !== newHeight) {\n this.frame.canvas.height = newHeight;\n emitEvent = true;\n }\n }\n\n if (emitEvent === true) {\n this.body.emitter.emit(\"resize\", {\n width: Math.round(this.frame.canvas.width / this.pixelRatio),\n height: Math.round(this.frame.canvas.height / this.pixelRatio),\n oldWidth: Math.round(oldWidth / this.pixelRatio),\n oldHeight: Math.round(oldHeight / this.pixelRatio),\n });\n\n // restore the camera on change.\n this._setCameraState();\n }\n\n // set initialized so the get and set camera will work from now on.\n this.initialized = true;\n return emitEvent;\n }\n\n /**\n *\n * @returns {CanvasRenderingContext2D}\n */\n getContext() {\n return this.frame.canvas.getContext(\"2d\");\n }\n\n /**\n * Determine the pixel ratio for various browsers.\n *\n * @returns {number}\n * @private\n */\n _determinePixelRatio() {\n const ctx = this.getContext();\n if (ctx === undefined) {\n throw new Error(\"Could not get canvax context\");\n }\n\n let numerator = 1;\n if (typeof window !== \"undefined\") {\n // (window !== undefined) doesn't work here!\n // Protection during unit tests, where 'window' can be missing\n numerator = window.devicePixelRatio || 1;\n }\n\n const denominator =\n ctx.webkitBackingStorePixelRatio ||\n ctx.mozBackingStorePixelRatio ||\n ctx.msBackingStorePixelRatio ||\n ctx.oBackingStorePixelRatio ||\n ctx.backingStorePixelRatio ||\n 1;\n\n return numerator / denominator;\n }\n\n /**\n * Lazy determination of pixel ratio.\n *\n * @private\n */\n _setPixelRatio() {\n this.pixelRatio = this._determinePixelRatio();\n }\n\n /**\n * Set the transform in the contained context, based on its pixelRatio\n */\n setTransform() {\n const ctx = this.getContext();\n if (ctx === undefined) {\n throw new Error(\"Could not get canvax context\");\n }\n\n ctx.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);\n }\n\n /**\n * Convert the X coordinate in DOM-space (coordinate point in browser relative to the container div) to\n * the X coordinate in canvas-space (the simulation sandbox, which the camera looks upon)\n *\n * @param {number} x\n * @returns {number}\n * @private\n */\n _XconvertDOMtoCanvas(x) {\n return (x - this.body.view.translation.x) / this.body.view.scale;\n }\n\n /**\n * Convert the X coordinate in canvas-space (the simulation sandbox, which the camera looks upon) to\n * the X coordinate in DOM-space (coordinate point in browser relative to the container div)\n *\n * @param {number} x\n * @returns {number}\n * @private\n */\n _XconvertCanvasToDOM(x) {\n return x * this.body.view.scale + this.body.view.translation.x;\n }\n\n /**\n * Convert the Y coordinate in DOM-space (coordinate point in browser relative to the container div) to\n * the Y coordinate in canvas-space (the simulation sandbox, which the camera looks upon)\n *\n * @param {number} y\n * @returns {number}\n * @private\n */\n _YconvertDOMtoCanvas(y) {\n return (y - this.body.view.translation.y) / this.body.view.scale;\n }\n\n /**\n * Convert the Y coordinate in canvas-space (the simulation sandbox, which the camera looks upon) to\n * the Y coordinate in DOM-space (coordinate point in browser relative to the container div)\n *\n * @param {number} y\n * @returns {number}\n * @private\n */\n _YconvertCanvasToDOM(y) {\n return y * this.body.view.scale + this.body.view.translation.y;\n }\n\n /**\n * @param {point} pos\n * @returns {point}\n */\n canvasToDOM(pos) {\n return {\n x: this._XconvertCanvasToDOM(pos.x),\n y: this._YconvertCanvasToDOM(pos.y),\n };\n }\n\n /**\n *\n * @param {point} pos\n * @returns {point}\n */\n DOMtoCanvas(pos) {\n return {\n x: this._XconvertDOMtoCanvas(pos.x),\n y: this._YconvertDOMtoCanvas(pos.y),\n };\n }\n}\n\nexport default Canvas;\n","import { easingFunctions } from \"vis-util/esnext\";\n\nimport NetworkUtil from \"../NetworkUtil\";\nimport { normalizeFitOptions } from \"./view-handler\";\n\n/**\n * The view\n */\nclass View {\n /**\n * @param {object} body\n * @param {Canvas} canvas\n */\n constructor(body, canvas) {\n this.body = body;\n this.canvas = canvas;\n\n this.animationSpeed = 1 / this.renderRefreshRate;\n this.animationEasingFunction = \"easeInOutQuint\";\n this.easingTime = 0;\n this.sourceScale = 0;\n this.targetScale = 0;\n this.sourceTranslation = 0;\n this.targetTranslation = 0;\n this.lockedOnNodeId = undefined;\n this.lockedOnNodeOffset = undefined;\n this.touchTime = 0;\n\n this.viewFunction = undefined;\n\n this.body.emitter.on(\"fit\", this.fit.bind(this));\n this.body.emitter.on(\"animationFinished\", () => {\n this.body.emitter.emit(\"_stopRendering\");\n });\n this.body.emitter.on(\"unlockNode\", this.releaseNode.bind(this));\n }\n\n /**\n *\n * @param {object} [options={}]\n */\n setOptions(options = {}) {\n this.options = options;\n }\n\n /**\n * This function zooms out to fit all data on screen based on amount of nodes\n *\n * @param {object} [options={{nodes=Array}}]\n * @param options\n * @param {boolean} [initialZoom=false] | zoom based on fitted formula or range, true = fitted, default = false;\n */\n fit(options, initialZoom = false) {\n options = normalizeFitOptions(options, this.body.nodeIndices);\n\n const canvasWidth = this.canvas.frame.canvas.clientWidth;\n const canvasHeight = this.canvas.frame.canvas.clientHeight;\n\n let range;\n let zoomLevel;\n if (canvasWidth === 0 || canvasHeight === 0) {\n // There's no point in trying to fit into zero sized canvas. This could\n // potentially even result in invalid values being computed. For example\n // for network without nodes and zero sized canvas the zoom level would\n // end up being computed as 0/0 which results in NaN. In any other case\n // this would be 0/something which is again pointless to compute.\n zoomLevel = 1;\n\n range = NetworkUtil.getRange(this.body.nodes, options.nodes);\n } else if (initialZoom === true) {\n // check if more than half of the nodes have a predefined position. If so, we use the range, not the approximation.\n let positionDefined = 0;\n for (const nodeId in this.body.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId)) {\n const node = this.body.nodes[nodeId];\n if (node.predefinedPosition === true) {\n positionDefined += 1;\n }\n }\n }\n if (positionDefined > 0.5 * this.body.nodeIndices.length) {\n this.fit(options, false);\n return;\n }\n\n range = NetworkUtil.getRange(this.body.nodes, options.nodes);\n\n const numberOfNodes = this.body.nodeIndices.length;\n zoomLevel = 12.662 / (numberOfNodes + 7.4147) + 0.0964822; // this is obtained from fitting a dataset from 5 points with scale levels that looked good.\n\n // correct for larger canvasses.\n const factor = Math.min(canvasWidth / 600, canvasHeight / 600);\n zoomLevel *= factor;\n } else {\n this.body.emitter.emit(\"_resizeNodes\");\n range = NetworkUtil.getRange(this.body.nodes, options.nodes);\n\n const xDistance = Math.abs(range.maxX - range.minX) * 1.1;\n const yDistance = Math.abs(range.maxY - range.minY) * 1.1;\n\n const xZoomLevel = canvasWidth / xDistance;\n const yZoomLevel = canvasHeight / yDistance;\n\n zoomLevel = xZoomLevel <= yZoomLevel ? xZoomLevel : yZoomLevel;\n }\n\n if (zoomLevel > options.maxZoomLevel) {\n zoomLevel = options.maxZoomLevel;\n } else if (zoomLevel < options.minZoomLevel) {\n zoomLevel = options.minZoomLevel;\n }\n\n const center = NetworkUtil.findCenter(range);\n const animationOptions = {\n position: center,\n scale: zoomLevel,\n animation: options.animation,\n };\n this.moveTo(animationOptions);\n }\n\n // animation\n\n /**\n * Center a node in view.\n *\n * @param {number} nodeId\n * @param {number} [options]\n */\n focus(nodeId, options = {}) {\n if (this.body.nodes[nodeId] !== undefined) {\n const nodePosition = {\n x: this.body.nodes[nodeId].x,\n y: this.body.nodes[nodeId].y,\n };\n options.position = nodePosition;\n options.lockedOnNode = nodeId;\n\n this.moveTo(options);\n } else {\n console.error(\"Node: \" + nodeId + \" cannot be found.\");\n }\n }\n\n /**\n *\n * @param {object} options | options.offset = {x:number, y:number} // offset from the center in DOM pixels\n * | options.scale = number // scale to move to\n * | options.position = {x:number, y:number} // position to move to\n * | options.animation = {duration:number, easingFunction:String} || Boolean // position to move to\n */\n moveTo(options) {\n if (options === undefined) {\n options = {};\n return;\n }\n\n if (options.offset != null) {\n if (options.offset.x != null) {\n // Coerce and verify that x is valid.\n options.offset.x = +options.offset.x;\n if (!Number.isFinite(options.offset.x)) {\n throw new TypeError(\n 'The option \"offset.x\" has to be a finite number.'\n );\n }\n } else {\n options.offset.x = 0;\n }\n\n if (options.offset.y != null) {\n // Coerce and verify that y is valid.\n options.offset.y = +options.offset.y;\n if (!Number.isFinite(options.offset.y)) {\n throw new TypeError(\n 'The option \"offset.y\" has to be a finite number.'\n );\n }\n } else {\n options.offset.x = 0;\n }\n } else {\n options.offset = {\n x: 0,\n y: 0,\n };\n }\n\n if (options.position != null) {\n if (options.position.x != null) {\n // Coerce and verify that x is valid.\n options.position.x = +options.position.x;\n if (!Number.isFinite(options.position.x)) {\n throw new TypeError(\n 'The option \"position.x\" has to be a finite number.'\n );\n }\n } else {\n options.position.x = 0;\n }\n\n if (options.position.y != null) {\n // Coerce and verify that y is valid.\n options.position.y = +options.position.y;\n if (!Number.isFinite(options.position.y)) {\n throw new TypeError(\n 'The option \"position.y\" has to be a finite number.'\n );\n }\n } else {\n options.position.x = 0;\n }\n } else {\n options.position = this.getViewPosition();\n }\n\n if (options.scale != null) {\n // Coerce and verify that the scale is valid.\n options.scale = +options.scale;\n if (!(options.scale > 0)) {\n throw new TypeError(\n 'The option \"scale\" has to be a number greater than zero.'\n );\n }\n } else {\n options.scale = this.body.view.scale;\n }\n\n if (options.animation === undefined) {\n options.animation = { duration: 0 };\n }\n if (options.animation === false) {\n options.animation = { duration: 0 };\n }\n if (options.animation === true) {\n options.animation = {};\n }\n if (options.animation.duration === undefined) {\n options.animation.duration = 1000;\n } // default duration\n if (options.animation.easingFunction === undefined) {\n options.animation.easingFunction = \"easeInOutQuad\";\n } // default easing function\n\n this.animateView(options);\n }\n\n /**\n *\n * @param {object} options | options.offset = {x:number, y:number} // offset from the center in DOM pixels\n * | options.time = number // animation time in milliseconds\n * | options.scale = number // scale to animate to\n * | options.position = {x:number, y:number} // position to animate to\n * | options.easingFunction = String // linear, easeInQuad, easeOutQuad, easeInOutQuad,\n * // easeInCubic, easeOutCubic, easeInOutCubic,\n * // easeInQuart, easeOutQuart, easeInOutQuart,\n * // easeInQuint, easeOutQuint, easeInOutQuint\n */\n animateView(options) {\n if (options === undefined) {\n return;\n }\n this.animationEasingFunction = options.animation.easingFunction;\n // release if something focussed on the node\n this.releaseNode();\n if (options.locked === true) {\n this.lockedOnNodeId = options.lockedOnNode;\n this.lockedOnNodeOffset = options.offset;\n }\n\n // forcefully complete the old animation if it was still running\n if (this.easingTime != 0) {\n this._transitionRedraw(true); // by setting easingtime to 1, we finish the animation.\n }\n\n this.sourceScale = this.body.view.scale;\n this.sourceTranslation = this.body.view.translation;\n this.targetScale = options.scale;\n\n // set the scale so the viewCenter is based on the correct zoom level. This is overridden in the transitionRedraw\n // but at least then we'll have the target transition\n this.body.view.scale = this.targetScale;\n const viewCenter = this.canvas.DOMtoCanvas({\n x: 0.5 * this.canvas.frame.canvas.clientWidth,\n y: 0.5 * this.canvas.frame.canvas.clientHeight,\n });\n\n const distanceFromCenter = {\n // offset from view, distance view has to change by these x and y to center the node\n x: viewCenter.x - options.position.x,\n y: viewCenter.y - options.position.y,\n };\n this.targetTranslation = {\n x:\n this.sourceTranslation.x +\n distanceFromCenter.x * this.targetScale +\n options.offset.x,\n y:\n this.sourceTranslation.y +\n distanceFromCenter.y * this.targetScale +\n options.offset.y,\n };\n\n // if the time is set to 0, don't do an animation\n if (options.animation.duration === 0) {\n if (this.lockedOnNodeId != undefined) {\n this.viewFunction = this._lockedRedraw.bind(this);\n this.body.emitter.on(\"initRedraw\", this.viewFunction);\n } else {\n this.body.view.scale = this.targetScale;\n this.body.view.translation = this.targetTranslation;\n this.body.emitter.emit(\"_requestRedraw\");\n }\n } else {\n this.animationSpeed =\n 1 / (60 * options.animation.duration * 0.001) || 1 / 60; // 60 for 60 seconds, 0.001 for milli's\n this.animationEasingFunction = options.animation.easingFunction;\n\n this.viewFunction = this._transitionRedraw.bind(this);\n this.body.emitter.on(\"initRedraw\", this.viewFunction);\n this.body.emitter.emit(\"_startRendering\");\n }\n }\n\n /**\n * used to animate smoothly by hijacking the redraw function.\n *\n * @private\n */\n _lockedRedraw() {\n const nodePosition = {\n x: this.body.nodes[this.lockedOnNodeId].x,\n y: this.body.nodes[this.lockedOnNodeId].y,\n };\n const viewCenter = this.canvas.DOMtoCanvas({\n x: 0.5 * this.canvas.frame.canvas.clientWidth,\n y: 0.5 * this.canvas.frame.canvas.clientHeight,\n });\n const distanceFromCenter = {\n // offset from view, distance view has to change by these x and y to center the node\n x: viewCenter.x - nodePosition.x,\n y: viewCenter.y - nodePosition.y,\n };\n const sourceTranslation = this.body.view.translation;\n const targetTranslation = {\n x:\n sourceTranslation.x +\n distanceFromCenter.x * this.body.view.scale +\n this.lockedOnNodeOffset.x,\n y:\n sourceTranslation.y +\n distanceFromCenter.y * this.body.view.scale +\n this.lockedOnNodeOffset.y,\n };\n\n this.body.view.translation = targetTranslation;\n }\n\n /**\n * Resets state of a locked on Node\n */\n releaseNode() {\n if (this.lockedOnNodeId !== undefined && this.viewFunction !== undefined) {\n this.body.emitter.off(\"initRedraw\", this.viewFunction);\n this.lockedOnNodeId = undefined;\n this.lockedOnNodeOffset = undefined;\n }\n }\n\n /**\n * @param {boolean} [finished=false]\n * @private\n */\n _transitionRedraw(finished = false) {\n this.easingTime += this.animationSpeed;\n this.easingTime = finished === true ? 1.0 : this.easingTime;\n\n const progress = easingFunctions[this.animationEasingFunction](\n this.easingTime\n );\n\n this.body.view.scale =\n this.sourceScale + (this.targetScale - this.sourceScale) * progress;\n this.body.view.translation = {\n x:\n this.sourceTranslation.x +\n (this.targetTranslation.x - this.sourceTranslation.x) * progress,\n y:\n this.sourceTranslation.y +\n (this.targetTranslation.y - this.sourceTranslation.y) * progress,\n };\n\n // cleanup\n if (this.easingTime >= 1.0) {\n this.body.emitter.off(\"initRedraw\", this.viewFunction);\n this.easingTime = 0;\n if (this.lockedOnNodeId != undefined) {\n this.viewFunction = this._lockedRedraw.bind(this);\n this.body.emitter.on(\"initRedraw\", this.viewFunction);\n }\n this.body.emitter.emit(\"animationFinished\");\n }\n }\n\n /**\n *\n * @returns {number}\n */\n getScale() {\n return this.body.view.scale;\n }\n\n /**\n *\n * @returns {{x: number, y: number}}\n */\n getViewPosition() {\n return this.canvas.DOMtoCanvas({\n x: 0.5 * this.canvas.frame.canvas.clientWidth,\n y: 0.5 * this.canvas.frame.canvas.clientHeight,\n });\n }\n}\n\nexport default View;\n","type IdType = string | number;\n\nexport interface ViewFitOptions {\n nodes: IdType[];\n minZoomLevel: number;\n maxZoomLevel: number;\n}\n\n/**\n * Validate the fit options, replace missing optional values by defaults etc.\n *\n * @param rawOptions - The raw options.\n * @param allNodeIds - All node ids that will be used if nodes are omitted in\n * the raw options.\n *\n * @returns Options with everything filled in and validated.\n */\nexport function normalizeFitOptions(\n rawOptions: Partial<ViewFitOptions>,\n allNodeIds: IdType[]\n): ViewFitOptions {\n const options = Object.assign<ViewFitOptions, Partial<ViewFitOptions>>(\n {\n nodes: allNodeIds,\n minZoomLevel: Number.MIN_VALUE,\n maxZoomLevel: 1,\n },\n rawOptions ?? {}\n );\n\n if (!Array.isArray(options.nodes)) {\n throw new TypeError(\"Nodes has to be an array of ids.\");\n }\n if (options.nodes.length === 0) {\n options.nodes = allNodeIds;\n }\n\n if (!(typeof options.minZoomLevel === \"number\" && options.minZoomLevel > 0)) {\n throw new TypeError(\"Min zoom level has to be a number higher than zero.\");\n }\n\n if (\n !(\n typeof options.maxZoomLevel === \"number\" &&\n options.minZoomLevel <= options.maxZoomLevel\n )\n ) {\n throw new TypeError(\n \"Max zoom level has to be a number higher than min zoom level.\"\n );\n }\n\n return options;\n}\n","import \"./NavigationHandler.css\";\n\nimport { Hammer } from \"vis-util/esnext\";\nimport { onRelease, onTouch } from \"../../../hammerUtil\";\nimport keycharm from \"keycharm\";\n\n/**\n * Navigation Handler\n */\nclass NavigationHandler {\n /**\n * @param {object} body\n * @param {Canvas} canvas\n */\n constructor(body, canvas) {\n this.body = body;\n this.canvas = canvas;\n\n this.iconsCreated = false;\n this.navigationHammers = [];\n this.boundFunctions = {};\n this.touchTime = 0;\n this.activated = false;\n\n this.body.emitter.on(\"activate\", () => {\n this.activated = true;\n this.configureKeyboardBindings();\n });\n this.body.emitter.on(\"deactivate\", () => {\n this.activated = false;\n this.configureKeyboardBindings();\n });\n this.body.emitter.on(\"destroy\", () => {\n if (this.keycharm !== undefined) {\n this.keycharm.destroy();\n }\n });\n\n this.options = {};\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n if (options !== undefined) {\n this.options = options;\n this.create();\n }\n }\n\n /**\n * Creates or refreshes navigation and sets key bindings\n */\n create() {\n if (this.options.navigationButtons === true) {\n if (this.iconsCreated === false) {\n this.loadNavigationElements();\n }\n } else if (this.iconsCreated === true) {\n this.cleanNavigation();\n }\n\n this.configureKeyboardBindings();\n }\n\n /**\n * Cleans up previous navigation items\n */\n cleanNavigation() {\n // clean hammer bindings\n if (this.navigationHammers.length != 0) {\n for (let i = 0; i < this.navigationHammers.length; i++) {\n this.navigationHammers[i].destroy();\n }\n this.navigationHammers = [];\n }\n\n // clean up previous navigation items\n if (\n this.navigationDOM &&\n this.navigationDOM[\"wrapper\"] &&\n this.navigationDOM[\"wrapper\"].parentNode\n ) {\n this.navigationDOM[\"wrapper\"].parentNode.removeChild(\n this.navigationDOM[\"wrapper\"]\n );\n }\n\n this.iconsCreated = false;\n }\n\n /**\n * Creation of the navigation controls nodes. They are drawn over the rest of the nodes and are not affected by scale and translation\n * they have a triggerFunction which is called on click. If the position of the navigation controls is dependent\n * on this.frame.canvas.clientWidth or this.frame.canvas.clientHeight, we flag horizontalAlignLeft and verticalAlignTop false.\n * This means that the location will be corrected by the _relocateNavigation function on a size change of the canvas.\n *\n * @private\n */\n loadNavigationElements() {\n this.cleanNavigation();\n\n this.navigationDOM = {};\n const navigationDivs = [\n \"up\",\n \"down\",\n \"left\",\n \"right\",\n \"zoomIn\",\n \"zoomOut\",\n \"zoomExtends\",\n ];\n const navigationDivActions = [\n \"_moveUp\",\n \"_moveDown\",\n \"_moveLeft\",\n \"_moveRight\",\n \"_zoomIn\",\n \"_zoomOut\",\n \"_fit\",\n ];\n\n this.navigationDOM[\"wrapper\"] = document.createElement(\"div\");\n this.navigationDOM[\"wrapper\"].className = \"vis-navigation\";\n this.canvas.frame.appendChild(this.navigationDOM[\"wrapper\"]);\n\n for (let i = 0; i < navigationDivs.length; i++) {\n this.navigationDOM[navigationDivs[i]] = document.createElement(\"div\");\n this.navigationDOM[navigationDivs[i]].className =\n \"vis-button vis-\" + navigationDivs[i];\n this.navigationDOM[\"wrapper\"].appendChild(\n this.navigationDOM[navigationDivs[i]]\n );\n\n const hammer = new Hammer(this.navigationDOM[navigationDivs[i]]);\n if (navigationDivActions[i] === \"_fit\") {\n onTouch(hammer, this._fit.bind(this));\n } else {\n onTouch(hammer, this.bindToRedraw.bind(this, navigationDivActions[i]));\n }\n\n this.navigationHammers.push(hammer);\n }\n\n // use a hammer for the release so we do not require the one used in the rest of the network\n // the one the rest uses can be overloaded by the manipulation system.\n const hammerFrame = new Hammer(this.canvas.frame);\n onRelease(hammerFrame, () => {\n this._stopMovement();\n });\n this.navigationHammers.push(hammerFrame);\n\n this.iconsCreated = true;\n }\n\n /**\n *\n * @param {string} action\n */\n bindToRedraw(action) {\n if (this.boundFunctions[action] === undefined) {\n this.boundFunctions[action] = this[action].bind(this);\n this.body.emitter.on(\"initRedraw\", this.boundFunctions[action]);\n this.body.emitter.emit(\"_startRendering\");\n }\n }\n\n /**\n *\n * @param {string} action\n */\n unbindFromRedraw(action) {\n if (this.boundFunctions[action] !== undefined) {\n this.body.emitter.off(\"initRedraw\", this.boundFunctions[action]);\n this.body.emitter.emit(\"_stopRendering\");\n delete this.boundFunctions[action];\n }\n }\n\n /**\n * this stops all movement induced by the navigation buttons\n *\n * @private\n */\n _fit() {\n if (new Date().valueOf() - this.touchTime > 700) {\n // TODO: fix ugly hack to avoid hammer's double fireing of event (because we use release?)\n this.body.emitter.emit(\"fit\", { duration: 700 });\n this.touchTime = new Date().valueOf();\n }\n }\n\n /**\n * this stops all movement induced by the navigation buttons\n *\n * @private\n */\n _stopMovement() {\n for (const boundAction in this.boundFunctions) {\n if (\n Object.prototype.hasOwnProperty.call(this.boundFunctions, boundAction)\n ) {\n this.body.emitter.off(\"initRedraw\", this.boundFunctions[boundAction]);\n this.body.emitter.emit(\"_stopRendering\");\n }\n }\n this.boundFunctions = {};\n }\n /**\n *\n * @private\n */\n _moveUp() {\n this.body.view.translation.y += this.options.keyboard.speed.y;\n }\n /**\n *\n * @private\n */\n _moveDown() {\n this.body.view.translation.y -= this.options.keyboard.speed.y;\n }\n /**\n *\n * @private\n */\n _moveLeft() {\n this.body.view.translation.x += this.options.keyboard.speed.x;\n }\n /**\n *\n * @private\n */\n _moveRight() {\n this.body.view.translation.x -= this.options.keyboard.speed.x;\n }\n /**\n *\n * @private\n */\n _zoomIn() {\n const scaleOld = this.body.view.scale;\n const scale = this.body.view.scale * (1 + this.options.keyboard.speed.zoom);\n const translation = this.body.view.translation;\n const scaleFrac = scale / scaleOld;\n const tx =\n (1 - scaleFrac) * this.canvas.canvasViewCenter.x +\n translation.x * scaleFrac;\n const ty =\n (1 - scaleFrac) * this.canvas.canvasViewCenter.y +\n translation.y * scaleFrac;\n\n this.body.view.scale = scale;\n this.body.view.translation = { x: tx, y: ty };\n this.body.emitter.emit(\"zoom\", {\n direction: \"+\",\n scale: this.body.view.scale,\n pointer: null,\n });\n }\n\n /**\n *\n * @private\n */\n _zoomOut() {\n const scaleOld = this.body.view.scale;\n const scale = this.body.view.scale / (1 + this.options.keyboard.speed.zoom);\n const translation = this.body.view.translation;\n const scaleFrac = scale / scaleOld;\n const tx =\n (1 - scaleFrac) * this.canvas.canvasViewCenter.x +\n translation.x * scaleFrac;\n const ty =\n (1 - scaleFrac) * this.canvas.canvasViewCenter.y +\n translation.y * scaleFrac;\n\n this.body.view.scale = scale;\n this.body.view.translation = { x: tx, y: ty };\n this.body.emitter.emit(\"zoom\", {\n direction: \"-\",\n scale: this.body.view.scale,\n pointer: null,\n });\n }\n\n /**\n * bind all keys using keycharm.\n */\n configureKeyboardBindings() {\n if (this.keycharm !== undefined) {\n this.keycharm.destroy();\n }\n\n if (this.options.keyboard.enabled === true) {\n if (this.options.keyboard.bindToWindow === true) {\n this.keycharm = keycharm({ container: window, preventDefault: true });\n } else {\n this.keycharm = keycharm({\n container: this.canvas.frame,\n preventDefault: true,\n });\n }\n\n this.keycharm.reset();\n\n if (this.activated === true) {\n this.keycharm.bind(\n \"up\",\n () => {\n this.bindToRedraw(\"_moveUp\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"down\",\n () => {\n this.bindToRedraw(\"_moveDown\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"left\",\n () => {\n this.bindToRedraw(\"_moveLeft\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"right\",\n () => {\n this.bindToRedraw(\"_moveRight\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"=\",\n () => {\n this.bindToRedraw(\"_zoomIn\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"num+\",\n () => {\n this.bindToRedraw(\"_zoomIn\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"num-\",\n () => {\n this.bindToRedraw(\"_zoomOut\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"-\",\n () => {\n this.bindToRedraw(\"_zoomOut\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"[\",\n () => {\n this.bindToRedraw(\"_zoomOut\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"]\",\n () => {\n this.bindToRedraw(\"_zoomIn\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"pageup\",\n () => {\n this.bindToRedraw(\"_zoomIn\");\n },\n \"keydown\"\n );\n this.keycharm.bind(\n \"pagedown\",\n () => {\n this.bindToRedraw(\"_zoomOut\");\n },\n \"keydown\"\n );\n\n this.keycharm.bind(\n \"up\",\n () => {\n this.unbindFromRedraw(\"_moveUp\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"down\",\n () => {\n this.unbindFromRedraw(\"_moveDown\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"left\",\n () => {\n this.unbindFromRedraw(\"_moveLeft\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"right\",\n () => {\n this.unbindFromRedraw(\"_moveRight\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"=\",\n () => {\n this.unbindFromRedraw(\"_zoomIn\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"num+\",\n () => {\n this.unbindFromRedraw(\"_zoomIn\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"num-\",\n () => {\n this.unbindFromRedraw(\"_zoomOut\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"-\",\n () => {\n this.unbindFromRedraw(\"_zoomOut\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"[\",\n () => {\n this.unbindFromRedraw(\"_zoomOut\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"]\",\n () => {\n this.unbindFromRedraw(\"_zoomIn\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"pageup\",\n () => {\n this.unbindFromRedraw(\"_zoomIn\");\n },\n \"keyup\"\n );\n this.keycharm.bind(\n \"pagedown\",\n () => {\n this.unbindFromRedraw(\"_zoomOut\");\n },\n \"keyup\"\n );\n }\n }\n }\n}\n\nexport default NavigationHandler;\n","import {\n Popup,\n getAbsoluteLeft,\n getAbsoluteTop,\n mergeOptions,\n parseColor,\n selectiveNotDeepExtend,\n} from \"vis-util/esnext\";\nimport NavigationHandler from \"./components/NavigationHandler\";\n\n/**\n * Handler for interactions\n */\nclass InteractionHandler {\n /**\n * @param {object} body\n * @param {Canvas} canvas\n * @param {SelectionHandler} selectionHandler\n */\n constructor(body, canvas, selectionHandler) {\n this.body = body;\n this.canvas = canvas;\n this.selectionHandler = selectionHandler;\n this.navigationHandler = new NavigationHandler(body, canvas);\n\n // bind the events from hammer to functions in this object\n this.body.eventListeners.onTap = this.onTap.bind(this);\n this.body.eventListeners.onTouch = this.onTouch.bind(this);\n this.body.eventListeners.onDoubleTap = this.onDoubleTap.bind(this);\n this.body.eventListeners.onHold = this.onHold.bind(this);\n this.body.eventListeners.onDragStart = this.onDragStart.bind(this);\n this.body.eventListeners.onDrag = this.onDrag.bind(this);\n this.body.eventListeners.onDragEnd = this.onDragEnd.bind(this);\n this.body.eventListeners.onMouseWheel = this.onMouseWheel.bind(this);\n this.body.eventListeners.onPinch = this.onPinch.bind(this);\n this.body.eventListeners.onMouseMove = this.onMouseMove.bind(this);\n this.body.eventListeners.onRelease = this.onRelease.bind(this);\n this.body.eventListeners.onContext = this.onContext.bind(this);\n\n this.touchTime = 0;\n this.drag = {};\n this.pinch = {};\n this.popup = undefined;\n this.popupObj = undefined;\n this.popupTimer = undefined;\n\n this.body.functions.getPointer = this.getPointer.bind(this);\n\n this.options = {};\n this.defaultOptions = {\n dragNodes: true,\n dragView: true,\n hover: false,\n keyboard: {\n enabled: false,\n speed: { x: 10, y: 10, zoom: 0.02 },\n bindToWindow: true,\n autoFocus: true,\n },\n navigationButtons: false,\n tooltipDelay: 300,\n zoomView: true,\n zoomSpeed: 1,\n };\n Object.assign(this.options, this.defaultOptions);\n\n this.bindEventListeners();\n }\n\n /**\n * Binds event listeners\n */\n bindEventListeners() {\n this.body.emitter.on(\"destroy\", () => {\n clearTimeout(this.popupTimer);\n delete this.body.functions.getPointer;\n });\n }\n\n /**\n *\n * @param {object} options\n */\n setOptions(options) {\n if (options !== undefined) {\n // extend all but the values in fields\n const fields = [\n \"hideEdgesOnDrag\",\n \"hideEdgesOnZoom\",\n \"hideNodesOnDrag\",\n \"keyboard\",\n \"multiselect\",\n \"selectable\",\n \"selectConnectedEdges\",\n ];\n selectiveNotDeepExtend(fields, this.options, options);\n\n // merge the keyboard options in.\n mergeOptions(this.options, options, \"keyboard\");\n\n if (options.tooltip) {\n Object.assign(this.options.tooltip, options.tooltip);\n if (options.tooltip.color) {\n this.options.tooltip.color = parseColor(options.tooltip.color);\n }\n }\n }\n\n this.navigationHandler.setOptions(this.options);\n }\n\n /**\n * Get the pointer location from a touch location\n *\n * @param {{x: number, y: number}} touch\n * @returns {{x: number, y: number}} pointer\n * @private\n */\n getPointer(touch) {\n return {\n x: touch.x - getAbsoluteLeft(this.canvas.frame.canvas),\n y: touch.y - getAbsoluteTop(this.canvas.frame.canvas),\n };\n }\n\n /**\n * On start of a touch gesture, store the pointer\n *\n * @param {Event} event The event\n * @private\n */\n onTouch(event) {\n if (new Date().valueOf() - this.touchTime > 50) {\n this.drag.pointer = this.getPointer(event.center);\n this.drag.pinched = false;\n this.pinch.scale = this.body.view.scale;\n // to avoid double fireing of this event because we have two hammer instances. (on canvas and on frame)\n this.touchTime = new Date().valueOf();\n }\n }\n\n /**\n * handle tap/click event: select/unselect a node\n *\n * @param {Event} event\n * @private\n */\n onTap(event) {\n const pointer = this.getPointer(event.center);\n const multiselect =\n this.selectionHandler.options.multiselect &&\n (event.changedPointers[0].ctrlKey || event.changedPointers[0].metaKey);\n\n this.checkSelectionChanges(pointer, multiselect);\n\n this.selectionHandler.commitAndEmit(pointer, event);\n this.selectionHandler.generateClickEvent(\"click\", event, pointer);\n }\n\n /**\n * handle doubletap event\n *\n * @param {Event} event\n * @private\n */\n onDoubleTap(event) {\n const pointer = this.getPointer(event.center);\n this.selectionHandler.generateClickEvent(\"doubleClick\", event, pointer);\n }\n\n /**\n * handle long tap event: multi select nodes\n *\n * @param {Event} event\n * @private\n */\n onHold(event) {\n const pointer = this.getPointer(event.center);\n const multiselect = this.selectionHandler.options.multiselect;\n\n this.checkSelectionChanges(pointer, multiselect);\n\n this.selectionHandler.commitAndEmit(pointer, event);\n this.selectionHandler.generateClickEvent(\"click\", event, pointer);\n this.selectionHandler.generateClickEvent(\"hold\", event, pointer);\n }\n\n /**\n * handle the release of the screen\n *\n * @param {Event} event\n * @private\n */\n onRelease(event) {\n if (new Date().valueOf() - this.touchTime > 10) {\n const pointer = this.getPointer(event.center);\n this.selectionHandler.generateClickEvent(\"release\", event, pointer);\n // to avoid double fireing of this event because we have two hammer instances. (on canvas and on frame)\n this.touchTime = new Date().valueOf();\n }\n }\n\n /**\n *\n * @param {Event} event\n */\n onContext(event) {\n const pointer = this.getPointer({ x: event.clientX, y: event.clientY });\n this.selectionHandler.generateClickEvent(\"oncontext\", event, pointer);\n }\n\n /**\n * Select and deselect nodes depending current selection change.\n *\n * @param {{x: number, y: number}} pointer\n * @param {boolean} [add=false]\n */\n checkSelectionChanges(pointer, add = false) {\n if (add === true) {\n this.selectionHandler.selectAdditionalOnPoint(pointer);\n } else {\n this.selectionHandler.selectOnPoint(pointer);\n }\n }\n\n /**\n * Remove all node and edge id's from the first set that are present in the second one.\n *\n * @param {{nodes: Array.<Node>, edges: Array.<vis.Edge>}} firstSet\n * @param {{nodes: Array.<Node>, edges: Array.<vis.Edge>}} secondSet\n * @returns {{nodes: Array.<Node>, edges: Array.<vis.Edge>}}\n * @private\n */\n _determineDifference(firstSet, secondSet) {\n const arrayDiff = function (firstArr, secondArr) {\n const result = [];\n\n for (let i = 0; i < firstArr.length; i++) {\n const value = firstArr[i];\n if (secondArr.indexOf(value) === -1) {\n result.push(value);\n }\n }\n\n return result;\n };\n\n return {\n nodes: arrayDiff(firstSet.nodes, secondSet.nodes),\n edges: arrayDiff(firstSet.edges, secondSet.edges),\n };\n }\n\n /**\n * This function is called by onDragStart.\n * It is separated out because we can then overload it for the datamanipulation system.\n *\n * @param {Event} event\n * @private\n */\n onDragStart(event) {\n // if already dragging, do not start\n // this can happen on touch screens with multiple fingers\n if (this.drag.dragging) {\n return;\n }\n\n //in case the touch event was triggered on an external div, do the initial touch now.\n if (this.drag.pointer === undefined) {\n this.onTouch(event);\n }\n\n // note: drag.pointer is set in onTouch to get the initial touch location\n const node = this.selectionHandler.getNodeAt(this.drag.pointer);\n\n this.drag.dragging = true;\n this.drag.selection = [];\n this.drag.translation = Object.assign({}, this.body.view.translation); // copy the object\n this.drag.nodeId = undefined;\n\n if (event.srcEvent.shiftKey) {\n this.body.selectionBox.show = true;\n const pointer = this.getPointer(event.center);\n\n this.body.selectionBox.position.start = {\n x: this.canvas._XconvertDOMtoCanvas(pointer.x),\n y: this.canvas._YconvertDOMtoCanvas(pointer.y),\n };\n this.body.selectionBox.position.end = {\n x: this.canvas._XconvertDOMtoCanvas(pointer.x),\n y: this.canvas._YconvertDOMtoCanvas(pointer.y),\n };\n }\n\n if (node !== undefined && this.options.dragNodes === true) {\n this.drag.nodeId = node.id;\n // select the clicked node if not yet selected\n if (node.isSelected() === false) {\n this.selectionHandler.unselectAll();\n this.selectionHandler.selectObject(node);\n }\n\n // after select to contain the node\n this.selectionHandler.generateClickEvent(\n \"dragStart\",\n event,\n this.drag.pointer\n );\n\n // create an array with the selected nodes and their original location and status\n for (const node of this.selectionHandler.getSelectedNodes()) {\n const s = {\n id: node.id,\n node: node,\n\n // store original x, y, xFixed and yFixed, make the node temporarily Fixed\n x: node.x,\n y: node.y,\n xFixed: node.options.fixed.x,\n yFixed: node.options.fixed.y,\n };\n\n node.options.fixed.x = true;\n node.options.fixed.y = true;\n\n this.drag.selection.push(s);\n }\n } else {\n // fallback if no node is selected and thus the view is dragged.\n this.selectionHandler.generateClickEvent(\n \"dragStart\",\n event,\n this.drag.pointer,\n undefined,\n true\n );\n }\n }\n\n /**\n * handle drag event\n *\n * @param {Event} event\n * @private\n */\n onDrag(event) {\n if (this.drag.pinched === true) {\n return;\n }\n\n // remove the focus on node if it is focussed on by the focusOnNode\n this.body.emitter.emit(\"unlockNode\");\n\n const pointer = this.getPointer(event.center);\n\n const selection = this.drag.selection;\n if (selection && selection.length && this.options.dragNodes === true) {\n this.selectionHandler.generateClickEvent(\"dragging\", event, pointer);\n\n // calculate delta's and new location\n const deltaX = pointer.x - this.drag.pointer.x;\n const deltaY = pointer.y - this.drag.pointer.y;\n\n // update position of all selected nodes\n selection.forEach((selection) => {\n const node = selection.node;\n // only move the node if it was not fixed initially\n if (selection.xFixed === false) {\n node.x = this.canvas._XconvertDOMtoCanvas(\n this.canvas._XconvertCanvasToDOM(selection.x) + deltaX\n );\n }\n // only move the node if it was not fixed initially\n if (selection.yFixed === false) {\n node.y = this.canvas._YconvertDOMtoCanvas(\n this.canvas._YconvertCanvasToDOM(selection.y) + deltaY\n );\n }\n });\n\n // start the simulation of the physics\n this.body.emitter.emit(\"startSimulation\");\n } else {\n // create selection box\n if (event.srcEvent.shiftKey) {\n this.selectionHandler.generateClickEvent(\n \"dragging\",\n event,\n pointer,\n undefined,\n true\n );\n\n // if the drag was not started properly because the click started outside the network div, start it now.\n if (this.drag.pointer === undefined) {\n this.onDragStart(event);\n return;\n }\n\n this.body.selectionBox.position.end = {\n x: this.canvas._XconvertDOMtoCanvas(pointer.x),\n y: this.canvas._YconvertDOMtoCanvas(pointer.y),\n };\n this.body.emitter.emit(\"_requestRedraw\");\n }\n\n // move the network\n if (this.options.dragView === true && !event.srcEvent.shiftKey) {\n this.selectionHandler.generateClickEvent(\n \"dragging\",\n event,\n pointer,\n undefined,\n true\n );\n\n // if the drag was not started properly because the click started outside the network div, start it now.\n if (this.drag.pointer === undefined) {\n this.onDragStart(event);\n return;\n }\n\n const diffX = pointer.x - this.drag.pointer.x;\n const diffY = pointer.y - this.drag.pointer.y;\n\n this.body.view.translation = {\n x: this.drag.translation.x + diffX,\n y: this.drag.translation.y + diffY,\n };\n this.body.emitter.emit(\"_requestRedraw\");\n }\n }\n }\n\n /**\n * handle drag start event\n *\n * @param {Event} event\n * @private\n */\n onDragEnd(event) {\n this.drag.dragging = false;\n\n if (this.body.selectionBox.show) {\n this.body.selectionBox.show = false;\n const selectionBoxPosition = this.body.selectionBox.position;\n const selectionBoxPositionMinMax = {\n minX: Math.min(\n selectionBoxPosition.start.x,\n selectionBoxPosition.end.x\n ),\n minY: Math.min(\n selectionBoxPosition.start.y,\n selectionBoxPosition.end.y\n ),\n maxX: Math.max(\n selectionBoxPosition.start.x,\n selectionBoxPosition.end.x\n ),\n maxY: Math.max(\n selectionBoxPosition.start.y,\n selectionBoxPosition.end.y\n ),\n };\n\n const toBeSelectedNodes = this.body.nodeIndices.filter((nodeId) => {\n const node = this.body.nodes[nodeId];\n return (\n node.x >= selectionBoxPositionMinMax.minX &&\n node.x <= selectionBoxPositionMinMax.maxX &&\n node.y >= selectionBoxPositionMinMax.minY &&\n node.y <= selectionBoxPositionMinMax.maxY\n );\n });\n\n toBeSelectedNodes.forEach((nodeId) =>\n this.selectionHandler.selectObject(this.body.nodes[nodeId])\n );\n\n const pointer = this.getPointer(event.center);\n this.selectionHandler.commitAndEmit(pointer, event);\n this.selectionHandler.generateClickEvent(\n \"dragEnd\",\n event,\n this.getPointer(event.center),\n undefined,\n true\n );\n this.body.emitter.emit(\"_requestRedraw\");\n } else {\n const selection = this.drag.selection;\n if (selection && selection.length) {\n selection.forEach(function (s) {\n // restore original xFixed and yFixed\n s.node.options.fixed.x = s.xFixed;\n s.node.options.fixed.y = s.yFixed;\n });\n this.selectionHandler.generateClickEvent(\n \"dragEnd\",\n event,\n this.getPointer(event.center)\n );\n this.body.emitter.emit(\"startSimulation\");\n } else {\n this.selectionHandler.generateClickEvent(\n \"dragEnd\",\n event,\n this.getPointer(event.center),\n undefined,\n true\n );\n this.body.emitter.emit(\"_requestRedraw\");\n }\n }\n }\n\n /**\n * Handle pinch event\n *\n * @param {Event} event The event\n * @private\n */\n onPinch(event) {\n const pointer = this.getPointer(event.center);\n\n this.drag.pinched = true;\n if (this.pinch[\"scale\"] === undefined) {\n this.pinch.scale = 1;\n }\n\n // TODO: enabled moving while pinching?\n const scale = this.pinch.scale * event.scale;\n this.zoom(scale, pointer);\n }\n\n /**\n * Zoom the network in or out\n *\n * @param {number} scale a number around 1, and between 0.01 and 10\n * @param {{x: number, y: number}} pointer Position on screen\n * @private\n */\n zoom(scale, pointer) {\n if (this.options.zoomView === true) {\n const scaleOld = this.body.view.scale;\n if (scale < 0.00001) {\n scale = 0.00001;\n }\n if (scale > 10) {\n scale = 10;\n }\n\n let preScaleDragPointer = undefined;\n if (this.drag !== undefined) {\n if (this.drag.dragging === true) {\n preScaleDragPointer = this.canvas.DOMtoCanvas(this.drag.pointer);\n }\n }\n // + this.canvas.frame.canvas.clientHeight / 2\n const translation = this.body.view.translation;\n\n const scaleFrac = scale / scaleOld;\n const tx = (1 - scaleFrac) * pointer.x + translation.x * scaleFrac;\n const ty = (1 - scaleFrac) * pointer.y + translation.y * scaleFrac;\n\n this.body.view.scale = scale;\n this.body.view.translation = { x: tx, y: ty };\n\n if (preScaleDragPointer != undefined) {\n const postScaleDragPointer =\n this.canvas.canvasToDOM(preScaleDragPointer);\n this.drag.pointer.x = postScaleDragPointer.x;\n this.drag.pointer.y = postScaleDragPointer.y;\n }\n\n this.body.emitter.emit(\"_requestRedraw\");\n\n if (scaleOld < scale) {\n this.body.emitter.emit(\"zoom\", {\n direction: \"+\",\n scale: this.body.view.scale,\n pointer: pointer,\n });\n } else {\n this.body.emitter.emit(\"zoom\", {\n direction: \"-\",\n scale: this.body.view.scale,\n pointer: pointer,\n });\n }\n }\n }\n\n /**\n * Event handler for mouse wheel event, used to zoom the timeline\n * See http://adomas.org/javascript-mouse-wheel/\n * https://github.com/EightMedia/hammer.js/issues/256\n *\n * @param {MouseEvent} event\n * @private\n */\n onMouseWheel(event) {\n if (this.options.zoomView === true) {\n // If delta is nonzero, handle it.\n // Basically, delta is now positive if wheel was scrolled up,\n // and negative, if wheel was scrolled down.\n if (event.deltaY !== 0) {\n // calculate the new scale\n let scale = this.body.view.scale;\n scale *=\n 1 + (event.deltaY < 0 ? 1 : -1) * (this.options.zoomSpeed * 0.1);\n\n // calculate the pointer location\n const pointer = this.getPointer({ x: event.clientX, y: event.clientY });\n\n // apply the new scale\n this.zoom(scale, pointer);\n }\n\n // Prevent default actions caused by mouse wheel.\n event.preventDefault();\n }\n }\n\n /**\n * Mouse move handler for checking whether the title moves over a node with a title.\n *\n * @param {Event} event\n * @private\n */\n onMouseMove(event) {\n const pointer = this.getPointer({ x: event.clientX, y: event.clientY });\n let popupVisible = false;\n\n // check if the previously selected node is still selected\n if (this.popup !== undefined) {\n if (this.popup.hidden === false) {\n this._checkHidePopup(pointer);\n }\n\n // if the popup was not hidden above\n if (this.popup.hidden === false) {\n popupVisible = true;\n this.popup.setPosition(pointer.x + 3, pointer.y - 5);\n this.popup.show();\n }\n }\n\n // if we bind the keyboard to the div, we have to highlight it to use it. This highlights it on mouse over.\n if (\n this.options.keyboard.autoFocus &&\n this.options.keyboard.bindToWindow === false &&\n this.options.keyboard.enabled === true\n ) {\n this.canvas.frame.focus();\n }\n\n // start a timeout that will check if the mouse is positioned above an element\n if (popupVisible === false) {\n if (this.popupTimer !== undefined) {\n clearInterval(this.popupTimer); // stop any running calculationTimer\n this.popupTimer = undefined;\n }\n if (!this.drag.dragging) {\n this.popupTimer = setTimeout(\n () => this._checkShowPopup(pointer),\n this.options.tooltipDelay\n );\n }\n }\n\n // adding hover highlights\n if (this.options.hover === true) {\n this.selectionHandler.hoverObject(event, pointer);\n }\n }\n\n /**\n * Check if there is an element on the given position in the network\n * (a node or edge). If so, and if this element has a title,\n * show a popup window with its title.\n *\n * @param {{x:number, y:number}} pointer\n * @private\n */\n _checkShowPopup(pointer) {\n const x = this.canvas._XconvertDOMtoCanvas(pointer.x);\n const y = this.canvas._YconvertDOMtoCanvas(pointer.y);\n const pointerObj = {\n left: x,\n top: y,\n right: x,\n bottom: y,\n };\n\n const previousPopupObjId =\n this.popupObj === undefined ? undefined : this.popupObj.id;\n let nodeUnderCursor = false;\n let popupType = \"node\";\n\n // check if a node is under the cursor.\n if (this.popupObj === undefined) {\n // search the nodes for overlap, select the top one in case of multiple nodes\n const nodeIndices = this.body.nodeIndices;\n const nodes = this.body.nodes;\n let node;\n const overlappingNodes = [];\n for (let i = 0; i < nodeIndices.length; i++) {\n node = nodes[nodeIndices[i]];\n if (node.isOverlappingWith(pointerObj) === true) {\n nodeUnderCursor = true;\n if (node.getTitle() !== undefined) {\n overlappingNodes.push(nodeIndices[i]);\n }\n }\n }\n\n if (overlappingNodes.length > 0) {\n // if there are overlapping nodes, select the last one, this is the one which is drawn on top of the others\n this.popupObj = nodes[overlappingNodes[overlappingNodes.length - 1]];\n // if you hover over a node, the title of the edge is not supposed to be shown.\n nodeUnderCursor = true;\n }\n }\n\n if (this.popupObj === undefined && nodeUnderCursor === false) {\n // search the edges for overlap\n const edgeIndices = this.body.edgeIndices;\n const edges = this.body.edges;\n let edge;\n const overlappingEdges = [];\n for (let i = 0; i < edgeIndices.length; i++) {\n edge = edges[edgeIndices[i]];\n if (edge.isOverlappingWith(pointerObj) === true) {\n if (edge.connected === true && edge.getTitle() !== undefined) {\n overlappingEdges.push(edgeIndices[i]);\n }\n }\n }\n\n if (overlappingEdges.length > 0) {\n this.popupObj = edges[overlappingEdges[overlappingEdges.length - 1]];\n popupType = \"edge\";\n }\n }\n\n if (this.popupObj !== undefined) {\n // show popup message window\n if (this.popupObj.id !== previousPopupObjId) {\n if (this.popup === undefined) {\n this.popup = new Popup(this.canvas.frame);\n }\n\n this.popup.popupTargetType = popupType;\n this.popup.popupTargetId = this.popupObj.id;\n\n // adjust a small offset such that the mouse cursor is located in the\n // bottom left location of the popup, and you can easily move over the\n // popup area\n this.popup.setPosition(pointer.x + 3, pointer.y - 5);\n this.popup.setText(this.popupObj.getTitle());\n this.popup.show();\n this.body.emitter.emit(\"showPopup\", this.popupObj.id);\n }\n } else {\n if (this.popup !== undefined) {\n this.popup.hide();\n this.body.emitter.emit(\"hidePopup\");\n }\n }\n }\n\n /**\n * Check if the popup must be hidden, which is the case when the mouse is no\n * longer hovering on the object\n *\n * @param {{x:number, y:number}} pointer\n * @private\n */\n _checkHidePopup(pointer) {\n const pointerObj = this.selectionHandler._pointerToPositionObject(pointer);\n\n let stillOnObj = false;\n if (this.popup.popupTargetType === \"node\") {\n if (this.body.nodes[this.popup.popupTargetId] !== undefined) {\n stillOnObj =\n this.body.nodes[this.popup.popupTargetId].isOverlappingWith(\n pointerObj\n );\n\n // if the mouse is still one the node, we have to check if it is not also on one that is drawn on top of it.\n // we initially only check stillOnObj because this is much faster.\n if (stillOnObj === true) {\n const overNode = this.selectionHandler.getNodeAt(pointer);\n stillOnObj =\n overNode === undefined\n ? false\n : overNode.id === this.popup.popupTargetId;\n }\n }\n } else {\n if (this.selectionHandler.getNodeAt(pointer) === undefined) {\n if (this.body.edges[this.popup.popupTargetId] !== undefined) {\n stillOnObj =\n this.body.edges[this.popup.popupTargetId].isOverlappingWith(\n pointerObj\n );\n }\n }\n }\n\n if (stillOnObj === false) {\n this.popupObj = undefined;\n this.popup.hide();\n this.body.emitter.emit(\"hidePopup\");\n }\n }\n}\n\nexport default InteractionHandler;\n","export interface Selectable {\n select(): void;\n unselect(): void;\n}\n\ninterface SingleTypeSelectionAccumulatorChanges<T> {\n added: T[];\n deleted: T[];\n previous: T[];\n current: T[];\n}\n\n/**\n * @param prev\n * @param next\n */\nfunction diffSets<T>(prev: ReadonlySet<T>, next: ReadonlySet<T>): Set<T> {\n const diff = new Set<T>();\n for (const item of next) {\n if (!prev.has(item)) {\n diff.add(item);\n }\n }\n return diff;\n}\n\nclass SingleTypeSelectionAccumulator<T extends Selectable> {\n #previousSelection: ReadonlySet<T> = new Set();\n #selection: Set<T> = new Set();\n\n public get size(): number {\n return this.#selection.size;\n }\n\n public add(...items: readonly T[]): void {\n for (const item of items) {\n this.#selection.add(item);\n }\n }\n public delete(...items: readonly T[]): void {\n for (const item of items) {\n this.#selection.delete(item);\n }\n }\n public clear(): void {\n this.#selection.clear();\n }\n\n public getSelection(): T[] {\n return [...this.#selection];\n }\n\n public getChanges(): SingleTypeSelectionAccumulatorChanges<T> {\n return {\n added: [...diffSets(this.#previousSelection, this.#selection)],\n deleted: [...diffSets(this.#selection, this.#previousSelection)],\n previous: [...new Set<T>(this.#previousSelection)],\n current: [...new Set<T>(this.#selection)],\n };\n }\n\n public commit(): SingleTypeSelectionAccumulatorChanges<T> {\n const changes = this.getChanges();\n\n this.#previousSelection = this.#selection;\n this.#selection = new Set(this.#previousSelection);\n\n for (const item of changes.added) {\n item.select();\n }\n for (const item of changes.deleted) {\n item.unselect();\n }\n\n return changes;\n }\n}\n\n// TODO: These should be real types imported from node.ts and edge.ts that don't\n// exist yet.\ninterface Node extends Selectable {\n $: \"node\";\n}\ninterface Edge extends Selectable {\n $: \"edge\";\n}\n\nexport interface SelectionAccumulatorCommitSummary {\n nodes: SingleTypeSelectionAccumulatorChanges<Node>;\n edges: SingleTypeSelectionAccumulatorChanges<Edge>;\n}\n\nexport type SelectionAccumulatorCommitHandler<\n CommitArgs extends readonly any[]\n> = (summary: SelectionAccumulatorCommitSummary, ...rest: CommitArgs) => void;\n\nexport class SelectionAccumulator<CommitArgs extends readonly any[]> {\n #nodes = new SingleTypeSelectionAccumulator<Node>();\n #edges = new SingleTypeSelectionAccumulator<Edge>();\n\n readonly #commitHandler: SelectionAccumulatorCommitHandler<CommitArgs>;\n\n public constructor(\n commitHandler: SelectionAccumulatorCommitHandler<CommitArgs> = (): void => {}\n ) {\n this.#commitHandler = commitHandler;\n }\n\n public get sizeNodes(): number {\n return this.#nodes.size;\n }\n public get sizeEdges(): number {\n return this.#edges.size;\n }\n\n public getNodes(): Node[] {\n return this.#nodes.getSelection();\n }\n public getEdges(): Edge[] {\n return this.#edges.getSelection();\n }\n\n public addNodes(...nodes: readonly Node[]): void {\n this.#nodes.add(...nodes);\n }\n public addEdges(...edges: readonly Edge[]): void {\n this.#edges.add(...edges);\n }\n\n public deleteNodes(node: Node): void {\n this.#nodes.delete(node);\n }\n public deleteEdges(edge: Edge): void {\n this.#edges.delete(edge);\n }\n\n public clear(): void {\n this.#nodes.clear();\n this.#edges.clear();\n }\n\n public commit(...rest: CommitArgs): SelectionAccumulatorCommitSummary {\n const summary = {\n nodes: this.#nodes.commit(),\n edges: this.#edges.commit(),\n };\n this.#commitHandler(summary, ...rest);\n return summary;\n }\n}\n","import Node from \"./components/Node\";\nimport Edge from \"./components/Edge\";\nimport { SelectionAccumulator } from \"./selection\";\n\nimport { selectiveDeepExtend } from \"vis-util/esnext\";\n\n/**\n * The handler for selections\n */\nclass SelectionHandler {\n /**\n * @param {object} body\n * @param {Canvas} canvas\n */\n constructor(body, canvas) {\n this.body = body;\n this.canvas = canvas;\n // TODO: Consider firing an event on any change to the selection, not\n // only those caused by clicks and taps. It would be easy to implement\n // now and (at least to me) it seems like something that could be\n // quite useful.\n this._selectionAccumulator = new SelectionAccumulator();\n this.hoverObj = { nodes: {}, edges: {} };\n\n this.options = {};\n this.defaultOptions = {\n multiselect: false,\n selectable: true,\n selectConnectedEdges: true,\n hoverConnectedEdges: true,\n };\n Object.assign(this.options, this.defaultOptions);\n\n this.body.emitter.on(\"_dataChanged\", () => {\n this.updateSelection();\n });\n }\n\n /**\n *\n * @param {object} [options]\n */\n setOptions(options) {\n if (options !== undefined) {\n const fields = [\n \"multiselect\",\n \"hoverConnectedEdges\",\n \"selectable\",\n \"selectConnectedEdges\",\n ];\n selectiveDeepExtend(fields, this.options, options);\n }\n }\n\n /**\n * handles the selection part of the tap;\n *\n * @param {{x: number, y: number}} pointer\n * @returns {boolean}\n */\n selectOnPoint(pointer) {\n let selected = false;\n if (this.options.selectable === true) {\n const obj = this.getNodeAt(pointer) || this.getEdgeAt(pointer);\n\n // unselect after getting the objects in order to restore width and height.\n this.unselectAll();\n\n if (obj !== undefined) {\n selected = this.selectObject(obj);\n }\n this.body.emitter.emit(\"_requestRedraw\");\n }\n return selected;\n }\n\n /**\n *\n * @param {{x: number, y: number}} pointer\n * @returns {boolean}\n */\n selectAdditionalOnPoint(pointer) {\n let selectionChanged = false;\n if (this.options.selectable === true) {\n const obj = this.getNodeAt(pointer) || this.getEdgeAt(pointer);\n\n if (obj !== undefined) {\n selectionChanged = true;\n if (obj.isSelected() === true) {\n this.deselectObject(obj);\n } else {\n this.selectObject(obj);\n }\n\n this.body.emitter.emit(\"_requestRedraw\");\n }\n }\n return selectionChanged;\n }\n\n /**\n * Create an object containing the standard fields for an event.\n *\n * @param {Event} event\n * @param {{x: number, y: number}} pointer Object with the x and y screen coordinates of the mouse\n * @returns {{}}\n * @private\n */\n _initBaseEvent(event, pointer) {\n const properties = {};\n\n properties[\"pointer\"] = {\n DOM: { x: pointer.x, y: pointer.y },\n canvas: this.canvas.DOMtoCanvas(pointer),\n };\n properties[\"event\"] = event;\n\n return properties;\n }\n\n /**\n * Generate an event which the user can catch.\n *\n * This adds some extra data to the event with respect to cursor position and\n * selected nodes and edges.\n *\n * @param {string} eventType Name of event to send\n * @param {Event} event\n * @param {{x: number, y: number}} pointer Object with the x and y screen coordinates of the mouse\n * @param {object | undefined} oldSelection If present, selection state before event occured\n * @param {boolean|undefined} [emptySelection=false] Indicate if selection data should be passed\n */\n generateClickEvent(\n eventType,\n event,\n pointer,\n oldSelection,\n emptySelection = false\n ) {\n const properties = this._initBaseEvent(event, pointer);\n\n if (emptySelection === true) {\n properties.nodes = [];\n properties.edges = [];\n } else {\n const tmp = this.getSelection();\n properties.nodes = tmp.nodes;\n properties.edges = tmp.edges;\n }\n\n if (oldSelection !== undefined) {\n properties[\"previousSelection\"] = oldSelection;\n }\n\n if (eventType == \"click\") {\n // For the time being, restrict this functionality to\n // just the click event.\n properties.items = this.getClickedItems(pointer);\n }\n\n if (event.controlEdge !== undefined) {\n properties.controlEdge = event.controlEdge;\n }\n\n this.body.emitter.emit(eventType, properties);\n }\n\n /**\n *\n * @param {object} obj\n * @param {boolean} [highlightEdges=this.options.selectConnectedEdges]\n * @returns {boolean}\n */\n selectObject(obj, highlightEdges = this.options.selectConnectedEdges) {\n if (obj !== undefined) {\n if (obj instanceof Node) {\n if (highlightEdges === true) {\n this._selectionAccumulator.addEdges(...obj.edges);\n }\n this._selectionAccumulator.addNodes(obj);\n } else {\n this._selectionAccumulator.addEdges(obj);\n }\n return true;\n }\n return false;\n }\n\n /**\n *\n * @param {object} obj\n */\n deselectObject(obj) {\n if (obj.isSelected() === true) {\n obj.selected = false;\n this._removeFromSelection(obj);\n }\n }\n\n /**\n * retrieve all nodes overlapping with given object\n *\n * @param {object} object An object with parameters left, top, right, bottom\n * @returns {number[]} An array with id's of the overlapping nodes\n * @private\n */\n _getAllNodesOverlappingWith(object) {\n const overlappingNodes = [];\n const nodes = this.body.nodes;\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n const nodeId = this.body.nodeIndices[i];\n if (nodes[nodeId].isOverlappingWith(object)) {\n overlappingNodes.push(nodeId);\n }\n }\n return overlappingNodes;\n }\n\n /**\n * Return a position object in canvasspace from a single point in screenspace\n *\n * @param {{x: number, y: number}} pointer\n * @returns {{left: number, top: number, right: number, bottom: number}}\n * @private\n */\n _pointerToPositionObject(pointer) {\n const canvasPos = this.canvas.DOMtoCanvas(pointer);\n return {\n left: canvasPos.x - 1,\n top: canvasPos.y + 1,\n right: canvasPos.x + 1,\n bottom: canvasPos.y - 1,\n };\n }\n\n /**\n * Get the top node at the passed point (like a click)\n *\n * @param {{x: number, y: number}} pointer\n * @param {boolean} [returnNode=true]\n * @returns {Node | undefined} node\n */\n getNodeAt(pointer, returnNode = true) {\n // we first check if this is an navigation controls element\n const positionObject = this._pointerToPositionObject(pointer);\n const overlappingNodes = this._getAllNodesOverlappingWith(positionObject);\n // if there are overlapping nodes, select the last one, this is the\n // one which is drawn on top of the others\n if (overlappingNodes.length > 0) {\n if (returnNode === true) {\n return this.body.nodes[overlappingNodes[overlappingNodes.length - 1]];\n } else {\n return overlappingNodes[overlappingNodes.length - 1];\n }\n } else {\n return undefined;\n }\n }\n\n /**\n * retrieve all edges overlapping with given object, selector is around center\n *\n * @param {object} object An object with parameters left, top, right, bottom\n * @param {number[]} overlappingEdges An array with id's of the overlapping nodes\n * @private\n */\n _getEdgesOverlappingWith(object, overlappingEdges) {\n const edges = this.body.edges;\n for (let i = 0; i < this.body.edgeIndices.length; i++) {\n const edgeId = this.body.edgeIndices[i];\n if (edges[edgeId].isOverlappingWith(object)) {\n overlappingEdges.push(edgeId);\n }\n }\n }\n\n /**\n * retrieve all nodes overlapping with given object\n *\n * @param {object} object An object with parameters left, top, right, bottom\n * @returns {number[]} An array with id's of the overlapping nodes\n * @private\n */\n _getAllEdgesOverlappingWith(object) {\n const overlappingEdges = [];\n this._getEdgesOverlappingWith(object, overlappingEdges);\n return overlappingEdges;\n }\n\n /**\n * Get the edges nearest to the passed point (like a click)\n *\n * @param {{x: number, y: number}} pointer\n * @param {boolean} [returnEdge=true]\n * @returns {Edge | undefined} node\n */\n getEdgeAt(pointer, returnEdge = true) {\n // Iterate over edges, pick closest within 10\n const canvasPos = this.canvas.DOMtoCanvas(pointer);\n let mindist = 10;\n let overlappingEdge = null;\n const edges = this.body.edges;\n for (let i = 0; i < this.body.edgeIndices.length; i++) {\n const edgeId = this.body.edgeIndices[i];\n const edge = edges[edgeId];\n if (edge.connected) {\n const xFrom = edge.from.x;\n const yFrom = edge.from.y;\n const xTo = edge.to.x;\n const yTo = edge.to.y;\n const dist = edge.edgeType.getDistanceToEdge(\n xFrom,\n yFrom,\n xTo,\n yTo,\n canvasPos.x,\n canvasPos.y\n );\n if (dist < mindist) {\n overlappingEdge = edgeId;\n mindist = dist;\n }\n }\n }\n if (overlappingEdge !== null) {\n if (returnEdge === true) {\n return this.body.edges[overlappingEdge];\n } else {\n return overlappingEdge;\n }\n } else {\n return undefined;\n }\n }\n\n /**\n * Add object to the selection array.\n *\n * @param {object} obj\n * @private\n */\n _addToHover(obj) {\n if (obj instanceof Node) {\n this.hoverObj.nodes[obj.id] = obj;\n } else {\n this.hoverObj.edges[obj.id] = obj;\n }\n }\n\n /**\n * Remove a single option from selection.\n *\n * @param {object} obj\n * @private\n */\n _removeFromSelection(obj) {\n if (obj instanceof Node) {\n this._selectionAccumulator.deleteNodes(obj);\n this._selectionAccumulator.deleteEdges(...obj.edges);\n } else {\n this._selectionAccumulator.deleteEdges(obj);\n }\n }\n\n /**\n * Unselect all nodes and edges.\n */\n unselectAll() {\n this._selectionAccumulator.clear();\n }\n\n /**\n * return the number of selected nodes\n *\n * @returns {number}\n */\n getSelectedNodeCount() {\n return this._selectionAccumulator.sizeNodes;\n }\n\n /**\n * return the number of selected edges\n *\n * @returns {number}\n */\n getSelectedEdgeCount() {\n return this._selectionAccumulator.sizeEdges;\n }\n\n /**\n * select the edges connected to the node that is being selected\n *\n * @param {Node} node\n * @private\n */\n _hoverConnectedEdges(node) {\n for (let i = 0; i < node.edges.length; i++) {\n const edge = node.edges[i];\n edge.hover = true;\n this._addToHover(edge);\n }\n }\n\n /**\n * Remove the highlight from a node or edge, in response to mouse movement\n *\n * @param {Event} event\n * @param {{x: number, y: number}} pointer object with the x and y screen coordinates of the mouse\n * @param {Node|vis.Edge} object\n * @private\n */\n emitBlurEvent(event, pointer, object) {\n const properties = this._initBaseEvent(event, pointer);\n\n if (object.hover === true) {\n object.hover = false;\n if (object instanceof Node) {\n properties.node = object.id;\n this.body.emitter.emit(\"blurNode\", properties);\n } else {\n properties.edge = object.id;\n this.body.emitter.emit(\"blurEdge\", properties);\n }\n }\n }\n\n /**\n * Create the highlight for a node or edge, in response to mouse movement\n *\n * @param {Event} event\n * @param {{x: number, y: number}} pointer object with the x and y screen coordinates of the mouse\n * @param {Node|vis.Edge} object\n * @returns {boolean} hoverChanged\n * @private\n */\n emitHoverEvent(event, pointer, object) {\n const properties = this._initBaseEvent(event, pointer);\n let hoverChanged = false;\n\n if (object.hover === false) {\n object.hover = true;\n this._addToHover(object);\n hoverChanged = true;\n if (object instanceof Node) {\n properties.node = object.id;\n this.body.emitter.emit(\"hoverNode\", properties);\n } else {\n properties.edge = object.id;\n this.body.emitter.emit(\"hoverEdge\", properties);\n }\n }\n\n return hoverChanged;\n }\n\n /**\n * Perform actions in response to a mouse movement.\n *\n * @param {Event} event\n * @param {{x: number, y: number}} pointer | object with the x and y screen coordinates of the mouse\n */\n hoverObject(event, pointer) {\n let object = this.getNodeAt(pointer);\n if (object === undefined) {\n object = this.getEdgeAt(pointer);\n }\n\n let hoverChanged = false;\n // remove all node hover highlights\n for (const nodeId in this.hoverObj.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.hoverObj.nodes, nodeId)) {\n if (\n object === undefined ||\n (object instanceof Node && object.id != nodeId) ||\n object instanceof Edge\n ) {\n this.emitBlurEvent(event, pointer, this.hoverObj.nodes[nodeId]);\n delete this.hoverObj.nodes[nodeId];\n hoverChanged = true;\n }\n }\n }\n\n // removing all edge hover highlights\n for (const edgeId in this.hoverObj.edges) {\n if (Object.prototype.hasOwnProperty.call(this.hoverObj.edges, edgeId)) {\n // if the hover has been changed here it means that the node has been hovered over or off\n // we then do not use the emitBlurEvent method here.\n if (hoverChanged === true) {\n this.hoverObj.edges[edgeId].hover = false;\n delete this.hoverObj.edges[edgeId];\n }\n // if the blur remains the same and the object is undefined (mouse off) or another\n // edge has been hovered, or another node has been hovered we blur the edge.\n else if (\n object === undefined ||\n (object instanceof Edge && object.id != edgeId) ||\n (object instanceof Node && !object.hover)\n ) {\n this.emitBlurEvent(event, pointer, this.hoverObj.edges[edgeId]);\n delete this.hoverObj.edges[edgeId];\n hoverChanged = true;\n }\n }\n }\n\n if (object !== undefined) {\n const hoveredEdgesCount = Object.keys(this.hoverObj.edges).length;\n const hoveredNodesCount = Object.keys(this.hoverObj.nodes).length;\n const newOnlyHoveredEdge =\n object instanceof Edge &&\n hoveredEdgesCount === 0 &&\n hoveredNodesCount === 0;\n const newOnlyHoveredNode =\n object instanceof Node &&\n hoveredEdgesCount === 0 &&\n hoveredNodesCount === 0;\n\n if (hoverChanged || newOnlyHoveredEdge || newOnlyHoveredNode) {\n hoverChanged = this.emitHoverEvent(event, pointer, object);\n }\n\n if (object instanceof Node && this.options.hoverConnectedEdges === true) {\n this._hoverConnectedEdges(object);\n }\n }\n\n if (hoverChanged === true) {\n this.body.emitter.emit(\"_requestRedraw\");\n }\n }\n\n /**\n * Commit the selection changes but don't emit any events.\n */\n commitWithoutEmitting() {\n this._selectionAccumulator.commit();\n }\n\n /**\n * Select and deselect nodes depending current selection change.\n *\n * For changing nodes, select/deselect events are fired.\n *\n * NOTE: For a given edge, if one connecting node is deselected and with the\n * same click the other node is selected, no events for the edge will fire. It\n * was selected and it will remain selected.\n *\n * @param {{x: number, y: number}} pointer - The x and y coordinates of the\n * click, tap, dragend… that triggered this.\n * @param {UIEvent} event - The event that triggered this.\n */\n commitAndEmit(pointer, event) {\n let selected = false;\n\n const selectionChanges = this._selectionAccumulator.commit();\n const previousSelection = {\n nodes: selectionChanges.nodes.previous,\n edges: selectionChanges.edges.previous,\n };\n\n if (selectionChanges.edges.deleted.length > 0) {\n this.generateClickEvent(\n \"deselectEdge\",\n event,\n pointer,\n previousSelection\n );\n selected = true;\n }\n\n if (selectionChanges.nodes.deleted.length > 0) {\n this.generateClickEvent(\n \"deselectNode\",\n event,\n pointer,\n previousSelection\n );\n selected = true;\n }\n\n if (selectionChanges.nodes.added.length > 0) {\n this.generateClickEvent(\"selectNode\", event, pointer);\n selected = true;\n }\n\n if (selectionChanges.edges.added.length > 0) {\n this.generateClickEvent(\"selectEdge\", event, pointer);\n selected = true;\n }\n\n // fire the select event if anything has been selected or deselected\n if (selected === true) {\n // select or unselect\n this.generateClickEvent(\"select\", event, pointer);\n }\n }\n\n /**\n * Retrieve the currently selected node and edge ids.\n *\n * @returns {{nodes: Array.<string>, edges: Array.<string>}} Arrays with the\n * ids of the selected nodes and edges.\n */\n getSelection() {\n return {\n nodes: this.getSelectedNodeIds(),\n edges: this.getSelectedEdgeIds(),\n };\n }\n\n /**\n * Retrieve the currently selected nodes.\n *\n * @returns {Array} An array with selected nodes.\n */\n getSelectedNodes() {\n return this._selectionAccumulator.getNodes();\n }\n\n /**\n * Retrieve the currently selected edges.\n *\n * @returns {Array} An array with selected edges.\n */\n getSelectedEdges() {\n return this._selectionAccumulator.getEdges();\n }\n\n /**\n * Retrieve the currently selected node ids.\n *\n * @returns {Array} An array with the ids of the selected nodes.\n */\n getSelectedNodeIds() {\n return this._selectionAccumulator.getNodes().map((node) => node.id);\n }\n\n /**\n * Retrieve the currently selected edge ids.\n *\n * @returns {Array} An array with the ids of the selected edges.\n */\n getSelectedEdgeIds() {\n return this._selectionAccumulator.getEdges().map((edge) => edge.id);\n }\n\n /**\n * Updates the current selection\n *\n * @param {{nodes: Array.<string>, edges: Array.<string>}} selection\n * @param {object} options Options\n */\n setSelection(selection, options = {}) {\n if (!selection || (!selection.nodes && !selection.edges)) {\n throw new TypeError(\n \"Selection must be an object with nodes and/or edges properties\"\n );\n }\n\n // first unselect any selected node, if option is true or undefined\n if (options.unselectAll || options.unselectAll === undefined) {\n this.unselectAll();\n }\n if (selection.nodes) {\n for (const id of selection.nodes) {\n const node = this.body.nodes[id];\n if (!node) {\n throw new RangeError('Node with id \"' + id + '\" not found');\n }\n // don't select edges with it\n this.selectObject(node, options.highlightEdges);\n }\n }\n\n if (selection.edges) {\n for (const id of selection.edges) {\n const edge = this.body.edges[id];\n if (!edge) {\n throw new RangeError('Edge with id \"' + id + '\" not found');\n }\n this.selectObject(edge);\n }\n }\n this.body.emitter.emit(\"_requestRedraw\");\n this._selectionAccumulator.commit();\n }\n\n /**\n * select zero or more nodes with the option to highlight edges\n *\n * @param {number[] | string[]} selection An array with the ids of the\n * selected nodes.\n * @param {boolean} [highlightEdges]\n */\n selectNodes(selection, highlightEdges = true) {\n if (!selection || selection.length === undefined)\n throw \"Selection must be an array with ids\";\n\n this.setSelection({ nodes: selection }, { highlightEdges: highlightEdges });\n }\n\n /**\n * select zero or more edges\n *\n * @param {number[] | string[]} selection An array with the ids of the\n * selected nodes.\n */\n selectEdges(selection) {\n if (!selection || selection.length === undefined)\n throw \"Selection must be an array with ids\";\n\n this.setSelection({ edges: selection });\n }\n\n /**\n * Validate the selection: remove ids of nodes which no longer exist\n *\n * @private\n */\n updateSelection() {\n for (const node in this._selectionAccumulator.getNodes()) {\n if (!Object.prototype.hasOwnProperty.call(this.body.nodes, node.id)) {\n this._selectionAccumulator.deleteNodes(node);\n }\n }\n for (const edge in this._selectionAccumulator.getEdges()) {\n if (!Object.prototype.hasOwnProperty.call(this.body.edges, edge.id)) {\n this._selectionAccumulator.deleteEdges(edge);\n }\n }\n }\n\n /**\n * Determine all the visual elements clicked which are on the given point.\n *\n * All elements are returned; this includes nodes, edges and their labels.\n * The order returned is from highest to lowest, i.e. element 0 of the return\n * value is the topmost item clicked on.\n *\n * The return value consists of an array of the following possible elements:\n *\n * - `{nodeId:number}` - node with given id clicked on\n * - `{nodeId:number, labelId:0}` - label of node with given id clicked on\n * - `{edgeId:number}` - edge with given id clicked on\n * - `{edge:number, labelId:0}` - label of edge with given id clicked on\n *\n * ## NOTES\n *\n * - Currently, there is only one label associated with a node or an edge,\n * but this is expected to change somewhere in the future.\n * - Since there is no z-indexing yet, it is not really possible to set the nodes and\n * edges in the correct order. For the time being, nodes come first.\n *\n * @param {point} pointer mouse position in screen coordinates\n * @returns {Array.<nodeClickItem|nodeLabelClickItem|edgeClickItem|edgeLabelClickItem>}\n * @private\n */\n getClickedItems(pointer) {\n const point = this.canvas.DOMtoCanvas(pointer);\n const items = [];\n\n // Note reverse order; we want the topmost clicked items to be first in the array\n // Also note that selected nodes are disregarded here; these normally display on top\n const nodeIndices = this.body.nodeIndices;\n const nodes = this.body.nodes;\n for (let i = nodeIndices.length - 1; i >= 0; i--) {\n const node = nodes[nodeIndices[i]];\n const ret = node.getItemsOnPoint(point);\n items.push.apply(items, ret); // Append the return value to the running list.\n }\n\n const edgeIndices = this.body.edgeIndices;\n const edges = this.body.edges;\n for (let i = edgeIndices.length - 1; i >= 0; i--) {\n const edge = edges[edgeIndices[i]];\n const ret = edge.getItemsOnPoint(point);\n items.push.apply(items, ret); // Append the return value to the running list.\n }\n\n return items;\n }\n}\n\nexport default SelectionHandler;\n","/**\n * Helper classes for LayoutEngine.\n *\n * Strategy pattern for usage of direction methods for hierarchical layouts.\n */\n\nimport { sort as timsort } from \"timsort\";\n\n/**\n * Interface definition for direction strategy classes.\n *\n * This class describes the interface for the Strategy\n * pattern classes used to differentiate horizontal and vertical\n * direction of hierarchical results.\n *\n * For a given direction, one coordinate will be 'fixed', meaning that it is\n * determined by level.\n * The other coordinate is 'unfixed', meaning that the nodes on a given level\n * can still move along that coordinate. So:\n *\n * - `vertical` layout: `x` unfixed, `y` fixed per level\n * - `horizontal` layout: `x` fixed per level, `y` unfixed\n *\n * The local methods are stubs and should be regarded as abstract.\n * Derived classes **must** implement all the methods themselves.\n *\n * @private\n */\nclass DirectionInterface {\n /**\n * @ignore\n */\n abstract() {\n throw new Error(\"Can't instantiate abstract class!\");\n }\n\n /**\n * This is a dummy call which is used to suppress the jsdoc errors of type:\n *\n * \"'param' is assigned a value but never used\"\n *\n * @ignore\n **/\n fake_use() {\n // Do nothing special\n }\n\n /**\n * Type to use to translate dynamic curves to, in the case of hierarchical layout.\n * Dynamic curves do not work for these.\n *\n * The value should be perpendicular to the actual direction of the layout.\n *\n * @returns {string} Direction, either 'vertical' or 'horizontal'\n */\n curveType() {\n return this.abstract();\n }\n\n /**\n * Return the value of the coordinate that is not fixed for this direction.\n *\n * @param {Node} node The node to read\n * @returns {number} Value of the unfixed coordinate\n */\n getPosition(node) {\n this.fake_use(node);\n return this.abstract();\n }\n\n /**\n * Set the value of the coordinate that is not fixed for this direction.\n *\n * @param {Node} node The node to adjust\n * @param {number} position\n * @param {number} [level] if specified, the hierarchy level that this node should be fixed to\n */\n setPosition(node, position, level = undefined) {\n this.fake_use(node, position, level);\n this.abstract();\n }\n\n /**\n * Get the width of a tree.\n *\n * A `tree` here is a subset of nodes within the network which are not connected to other nodes,\n * only among themselves. In essence, it is a sub-network.\n *\n * @param {number} index The index number of a tree\n * @returns {number} the width of a tree in the view coordinates\n */\n getTreeSize(index) {\n this.fake_use(index);\n return this.abstract();\n }\n\n /**\n * Sort array of nodes on the unfixed coordinates.\n *\n * **Note:** chrome has non-stable sorting implementation, which\n * has a tendency to change the order of the array items,\n * even if the custom sort function returns 0.\n *\n * For this reason, an external sort implementation is used,\n * which has the added benefit of being faster than the standard\n * platforms implementation. This has been verified on `node.js`,\n * `firefox` and `chrome` (all linux).\n *\n * @param {Array.<Node>} nodeArray array of nodes to sort\n */\n sort(nodeArray) {\n this.fake_use(nodeArray);\n this.abstract();\n }\n\n /**\n * Assign the fixed coordinate of the node to the given level\n *\n * @param {Node} node The node to adjust\n * @param {number} level The level to fix to\n */\n fix(node, level) {\n this.fake_use(node, level);\n this.abstract();\n }\n\n /**\n * Add an offset to the unfixed coordinate of the given node.\n *\n * @param {NodeId} nodeId Id of the node to adjust\n * @param {number} diff Offset to add to the unfixed coordinate\n */\n shift(nodeId, diff) {\n this.fake_use(nodeId, diff);\n this.abstract();\n }\n}\n\n/**\n * Vertical Strategy\n *\n * Coordinate `y` is fixed on levels, coordinate `x` is unfixed.\n *\n * @augments DirectionInterface\n * @private\n */\nclass VerticalStrategy extends DirectionInterface {\n /**\n * Constructor\n *\n * @param {object} layout reference to the parent LayoutEngine instance.\n */\n constructor(layout) {\n super();\n this.layout = layout;\n }\n\n /** @inheritDoc */\n curveType() {\n return \"horizontal\";\n }\n\n /** @inheritDoc */\n getPosition(node) {\n return node.x;\n }\n\n /** @inheritDoc */\n setPosition(node, position, level = undefined) {\n if (level !== undefined) {\n this.layout.hierarchical.addToOrdering(node, level);\n }\n node.x = position;\n }\n\n /** @inheritDoc */\n getTreeSize(index) {\n const res = this.layout.hierarchical.getTreeSize(\n this.layout.body.nodes,\n index\n );\n return { min: res.min_x, max: res.max_x };\n }\n\n /** @inheritDoc */\n sort(nodeArray) {\n timsort(nodeArray, function (a, b) {\n return a.x - b.x;\n });\n }\n\n /** @inheritDoc */\n fix(node, level) {\n node.y = this.layout.options.hierarchical.levelSeparation * level;\n node.options.fixed.y = true;\n }\n\n /** @inheritDoc */\n shift(nodeId, diff) {\n this.layout.body.nodes[nodeId].x += diff;\n }\n}\n\n/**\n * Horizontal Strategy\n *\n * Coordinate `x` is fixed on levels, coordinate `y` is unfixed.\n *\n * @augments DirectionInterface\n * @private\n */\nclass HorizontalStrategy extends DirectionInterface {\n /**\n * Constructor\n *\n * @param {object} layout reference to the parent LayoutEngine instance.\n */\n constructor(layout) {\n super();\n this.layout = layout;\n }\n\n /** @inheritDoc */\n curveType() {\n return \"vertical\";\n }\n\n /** @inheritDoc */\n getPosition(node) {\n return node.y;\n }\n\n /** @inheritDoc */\n setPosition(node, position, level = undefined) {\n if (level !== undefined) {\n this.layout.hierarchical.addToOrdering(node, level);\n }\n node.y = position;\n }\n\n /** @inheritDoc */\n getTreeSize(index) {\n const res = this.layout.hierarchical.getTreeSize(\n this.layout.body.nodes,\n index\n );\n return { min: res.min_y, max: res.max_y };\n }\n\n /** @inheritDoc */\n sort(nodeArray) {\n timsort(nodeArray, function (a, b) {\n return a.y - b.y;\n });\n }\n\n /** @inheritDoc */\n fix(node, level) {\n node.x = this.layout.options.hierarchical.levelSeparation * level;\n node.options.fixed.x = true;\n }\n\n /** @inheritDoc */\n shift(nodeId, diff) {\n this.layout.body.nodes[nodeId].y += diff;\n }\n}\n\nexport { HorizontalStrategy, VerticalStrategy };\n","type Levels = Record<string | number, number>;\ntype Id = string | number;\ninterface Edge {\n connected: boolean;\n from: Node;\n fromId: Id;\n to: Node;\n toId: Id;\n}\ninterface Node {\n id: Id;\n edges: Edge[];\n}\n\n/**\n * Try to assign levels to nodes according to their positions in the cyclic “hierarchy”.\n *\n * @param nodes - Visible nodes of the graph.\n * @param levels - If present levels will be added to it, if not a new object will be created.\n *\n * @returns Populated node levels.\n */\nfunction fillLevelsByDirectionCyclic(\n nodes: Map<Id, Node>,\n levels: Levels\n): Levels {\n const edges = new Set<Edge>();\n nodes.forEach((node): void => {\n node.edges.forEach((edge): void => {\n if (edge.connected) {\n edges.add(edge);\n }\n });\n });\n\n edges.forEach((edge): void => {\n const fromId = edge.from.id;\n const toId = edge.to.id;\n\n if (levels[fromId] == null) {\n levels[fromId] = 0;\n }\n\n if (levels[toId] == null || levels[fromId] >= levels[toId]) {\n levels[toId] = levels[fromId] + 1;\n }\n });\n\n return levels;\n}\n\n/**\n * Assign levels to nodes according to their positions in the hierarchy. Leaves will be lined up at the bottom and all other nodes as close to their children as possible.\n *\n * @param nodes - Visible nodes of the graph.\n *\n * @returns Populated node levels.\n */\nexport function fillLevelsByDirectionLeaves(nodes: Map<Id, Node>): Levels {\n return fillLevelsByDirection(\n // Pick only leaves (nodes without children).\n (node): boolean =>\n node.edges\n // Take only visible nodes into account.\n .filter((edge): boolean => nodes.has(edge.toId))\n // Check that all edges lead to this node (leaf).\n .every((edge): boolean => edge.to === node),\n // Use the lowest level.\n (newLevel, oldLevel): boolean => oldLevel > newLevel,\n // Go against the direction of the edges.\n \"from\",\n nodes\n );\n}\n\n/**\n * Assign levels to nodes according to their positions in the hierarchy. Roots will be lined up at the top and all nodes as close to their parents as possible.\n *\n * @param nodes - Visible nodes of the graph.\n *\n * @returns Populated node levels.\n */\nexport function fillLevelsByDirectionRoots(nodes: Map<Id, Node>): Levels {\n return fillLevelsByDirection(\n // Pick only roots (nodes without parents).\n (node): boolean =>\n node.edges\n // Take only visible nodes into account.\n .filter((edge): boolean => nodes.has(edge.toId))\n // Check that all edges lead from this node (root).\n .every((edge): boolean => edge.from === node),\n // Use the highest level.\n (newLevel, oldLevel): boolean => oldLevel < newLevel,\n // Go in the direction of the edges.\n \"to\",\n nodes\n );\n}\n\n/**\n * Assign levels to nodes according to their positions in the hierarchy.\n *\n * @param isEntryNode - Checks and return true if the graph should be traversed from this node.\n * @param shouldLevelBeReplaced - Checks and returns true if the level of given node should be updated to the new value.\n * @param direction - Wheter the graph should be traversed in the direction of the edges `\"to\"` or in the other way `\"from\"`.\n * @param nodes - Visible nodes of the graph.\n *\n * @returns Populated node levels.\n */\nfunction fillLevelsByDirection(\n isEntryNode: (node: Node) => boolean,\n shouldLevelBeReplaced: (newLevel: number, oldLevel: number) => boolean,\n direction: \"to\" | \"from\",\n nodes: Map<Id, Node>\n): Levels {\n const levels = Object.create(null);\n\n // If acyclic, the graph can be walked through with (most likely way) fewer\n // steps than the number bellow. The exact value isn't too important as long\n // as it's quick to compute (doesn't impact acyclic graphs too much), is\n // higher than the number of steps actually needed (doesn't cut off before\n // acyclic graph is walked through) and prevents infinite loops (cuts off for\n // cyclic graphs).\n const limit = [...nodes.values()].reduce<number>(\n (acc, node): number => acc + 1 + node.edges.length,\n 0\n );\n\n const edgeIdProp: \"fromId\" | \"toId\" = (direction + \"Id\") as \"fromId\" | \"toId\";\n const newLevelDiff = direction === \"to\" ? 1 : -1;\n\n for (const [entryNodeId, entryNode] of nodes) {\n if (\n // Skip if the node is not visible.\n !nodes.has(entryNodeId) ||\n // Skip if the node is not an entry node.\n !isEntryNode(entryNode)\n ) {\n continue;\n }\n\n // Line up all the entry nodes on level 0.\n levels[entryNodeId] = 0;\n\n const stack: Node[] = [entryNode];\n let done = 0;\n let node: Node | undefined;\n while ((node = stack.pop())) {\n if (!nodes.has(entryNodeId)) {\n // Skip if the node is not visible.\n continue;\n }\n\n const newLevel = levels[node.id] + newLevelDiff;\n\n node.edges\n .filter(\n (edge): boolean =>\n // Ignore disconnected edges.\n edge.connected &&\n // Ignore circular edges.\n edge.to !== edge.from &&\n // Ignore edges leading to the node that's currently being processed.\n edge[direction] !== node &&\n // Ignore edges connecting to an invisible node.\n nodes.has(edge.toId) &&\n // Ignore edges connecting from an invisible node.\n nodes.has(edge.fromId)\n )\n .forEach((edge): void => {\n const targetNodeId = edge[edgeIdProp];\n const oldLevel = levels[targetNodeId];\n\n if (oldLevel == null || shouldLevelBeReplaced(newLevel, oldLevel)) {\n levels[targetNodeId] = newLevel;\n stack.push(edge[direction]);\n }\n });\n\n if (done > limit) {\n // This would run forever on a cyclic graph.\n return fillLevelsByDirectionCyclic(nodes, levels);\n } else {\n ++done;\n }\n }\n }\n\n return levels;\n}\n","/**\n * There's a mix-up with terms in the code. Following are the formal definitions:\n *\n * tree - a strict hierarchical network, i.e. every node has at most one parent\n * forest - a collection of trees. These distinct trees are thus not connected.\n *\n * So:\n * - in a network that is not a tree, there exist nodes with multiple parents.\n * - a network consisting of unconnected sub-networks, of which at least one\n * is not a tree, is not a forest.\n *\n * In the code, the definitions are:\n *\n * tree - any disconnected sub-network, strict hierarchical or not.\n * forest - a bunch of these sub-networks\n *\n * The difference between tree and not-tree is important in the code, notably within\n * to the block-shifting algorithm. The algorithm assumes formal trees and fails\n * for not-trees, often in a spectacular manner (search for 'exploding network' in the issues).\n *\n * In order to distinguish the definitions in the following code, the adjective 'formal' is\n * used. If 'formal' is absent, you must assume the non-formal definition.\n *\n * ----------------------------------------------------------------------------------\n * NOTES\n * =====\n *\n * A hierarchical layout is a different thing from a hierarchical network.\n * The layout is a way to arrange the nodes in the view; this can be done\n * on non-hierarchical networks as well. The converse is also possible.\n */\n\"use strict\";\nimport TimSort from \"timsort\";\nimport {\n Alea,\n deepExtend,\n forEach,\n mergeOptions,\n selectiveDeepExtend,\n} from \"vis-util/esnext\";\nimport NetworkUtil from \"../NetworkUtil\";\nimport {\n HorizontalStrategy,\n VerticalStrategy,\n} from \"./components/DirectionStrategy.js\";\nimport {\n fillLevelsByDirectionLeaves,\n fillLevelsByDirectionRoots,\n} from \"./layout-engine\";\n\n/**\n * Container for derived data on current network, relating to hierarchy.\n *\n * @private\n */\nclass HierarchicalStatus {\n /**\n * @ignore\n */\n constructor() {\n this.childrenReference = {}; // child id's per node id\n this.parentReference = {}; // parent id's per node id\n this.trees = {}; // tree id per node id; i.e. to which tree does given node id belong\n\n this.distributionOrdering = {}; // The nodes per level, in the display order\n this.levels = {}; // hierarchy level per node id\n this.distributionIndex = {}; // The position of the node in the level sorting order, per node id.\n\n this.isTree = false; // True if current network is a formal tree\n this.treeIndex = -1; // Highest tree id in current network.\n }\n\n /**\n * Add the relation between given nodes to the current state.\n *\n * @param {Node.id} parentNodeId\n * @param {Node.id} childNodeId\n */\n addRelation(parentNodeId, childNodeId) {\n if (this.childrenReference[parentNodeId] === undefined) {\n this.childrenReference[parentNodeId] = [];\n }\n this.childrenReference[parentNodeId].push(childNodeId);\n\n if (this.parentReference[childNodeId] === undefined) {\n this.parentReference[childNodeId] = [];\n }\n this.parentReference[childNodeId].push(parentNodeId);\n }\n\n /**\n * Check if the current state is for a formal tree or formal forest.\n *\n * This is the case if every node has at most one parent.\n *\n * Pre: parentReference init'ed properly for current network\n */\n checkIfTree() {\n for (const i in this.parentReference) {\n if (this.parentReference[i].length > 1) {\n this.isTree = false;\n return;\n }\n }\n\n this.isTree = true;\n }\n\n /**\n * Return the number of separate trees in the current network.\n *\n * @returns {number}\n */\n numTrees() {\n return this.treeIndex + 1; // This assumes the indexes are assigned consecitively\n }\n\n /**\n * Assign a tree id to a node\n *\n * @param {Node} node\n * @param {string|number} treeId\n */\n setTreeIndex(node, treeId) {\n if (treeId === undefined) return; // Don't bother\n\n if (this.trees[node.id] === undefined) {\n this.trees[node.id] = treeId;\n this.treeIndex = Math.max(treeId, this.treeIndex);\n }\n }\n\n /**\n * Ensure level for given id is defined.\n *\n * Sets level to zero for given node id if not already present\n *\n * @param {Node.id} nodeId\n */\n ensureLevel(nodeId) {\n if (this.levels[nodeId] === undefined) {\n this.levels[nodeId] = 0;\n }\n }\n\n /**\n * get the maximum level of a branch.\n *\n * TODO: Never entered; find a test case to test this!\n *\n * @param {Node.id} nodeId\n * @returns {number}\n */\n getMaxLevel(nodeId) {\n const accumulator = {};\n\n const _getMaxLevel = (nodeId) => {\n if (accumulator[nodeId] !== undefined) {\n return accumulator[nodeId];\n }\n let level = this.levels[nodeId];\n if (this.childrenReference[nodeId]) {\n const children = this.childrenReference[nodeId];\n if (children.length > 0) {\n for (let i = 0; i < children.length; i++) {\n level = Math.max(level, _getMaxLevel(children[i]));\n }\n }\n }\n accumulator[nodeId] = level;\n return level;\n };\n\n return _getMaxLevel(nodeId);\n }\n\n /**\n *\n * @param {Node} nodeA\n * @param {Node} nodeB\n */\n levelDownstream(nodeA, nodeB) {\n if (this.levels[nodeB.id] === undefined) {\n // set initial level\n if (this.levels[nodeA.id] === undefined) {\n this.levels[nodeA.id] = 0;\n }\n // set level\n this.levels[nodeB.id] = this.levels[nodeA.id] + 1;\n }\n }\n\n /**\n * Small util method to set the minimum levels of the nodes to zero.\n *\n * @param {Array.<Node>} nodes\n */\n setMinLevelToZero(nodes) {\n let minLevel = 1e9;\n // get the minimum level\n for (const nodeId in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, nodeId)) {\n if (this.levels[nodeId] !== undefined) {\n minLevel = Math.min(this.levels[nodeId], minLevel);\n }\n }\n }\n\n // subtract the minimum from the set so we have a range starting from 0\n for (const nodeId in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, nodeId)) {\n if (this.levels[nodeId] !== undefined) {\n this.levels[nodeId] -= minLevel;\n }\n }\n }\n }\n\n /**\n * Get the min and max xy-coordinates of a given tree\n *\n * @param {Array.<Node>} nodes\n * @param {number} index\n * @returns {{min_x: number, max_x: number, min_y: number, max_y: number}}\n */\n getTreeSize(nodes, index) {\n let min_x = 1e9;\n let max_x = -1e9;\n let min_y = 1e9;\n let max_y = -1e9;\n\n for (const nodeId in this.trees) {\n if (Object.prototype.hasOwnProperty.call(this.trees, nodeId)) {\n if (this.trees[nodeId] === index) {\n const node = nodes[nodeId];\n min_x = Math.min(node.x, min_x);\n max_x = Math.max(node.x, max_x);\n min_y = Math.min(node.y, min_y);\n max_y = Math.max(node.y, max_y);\n }\n }\n }\n\n return {\n min_x: min_x,\n max_x: max_x,\n min_y: min_y,\n max_y: max_y,\n };\n }\n\n /**\n * Check if two nodes have the same parent(s)\n *\n * @param {Node} node1\n * @param {Node} node2\n * @returns {boolean} true if the two nodes have a same ancestor node, false otherwise\n */\n hasSameParent(node1, node2) {\n const parents1 = this.parentReference[node1.id];\n const parents2 = this.parentReference[node2.id];\n if (parents1 === undefined || parents2 === undefined) {\n return false;\n }\n\n for (let i = 0; i < parents1.length; i++) {\n for (let j = 0; j < parents2.length; j++) {\n if (parents1[i] == parents2[j]) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if two nodes are in the same tree.\n *\n * @param {Node} node1\n * @param {Node} node2\n * @returns {boolean} true if this is so, false otherwise\n */\n inSameSubNetwork(node1, node2) {\n return this.trees[node1.id] === this.trees[node2.id];\n }\n\n /**\n * Get a list of the distinct levels in the current network\n *\n * @returns {Array}\n */\n getLevels() {\n return Object.keys(this.distributionOrdering);\n }\n\n /**\n * Add a node to the ordering per level\n *\n * @param {Node} node\n * @param {number} level\n */\n addToOrdering(node, level) {\n if (this.distributionOrdering[level] === undefined) {\n this.distributionOrdering[level] = [];\n }\n\n let isPresent = false;\n const curLevel = this.distributionOrdering[level];\n for (const n in curLevel) {\n //if (curLevel[n].id === node.id) {\n if (curLevel[n] === node) {\n isPresent = true;\n break;\n }\n }\n\n if (!isPresent) {\n this.distributionOrdering[level].push(node);\n this.distributionIndex[node.id] =\n this.distributionOrdering[level].length - 1;\n }\n }\n}\n\n/**\n * The Layout Engine\n */\nclass LayoutEngine {\n /**\n * @param {object} body\n */\n constructor(body) {\n this.body = body;\n\n // Make sure there always is some RNG because the setOptions method won't\n // set it unless there's a seed for it.\n this._resetRNG(Math.random() + \":\" + Date.now());\n\n this.setPhysics = false;\n this.options = {};\n this.optionsBackup = { physics: {} };\n\n this.defaultOptions = {\n randomSeed: undefined,\n improvedLayout: true,\n clusterThreshold: 150,\n hierarchical: {\n enabled: false,\n levelSeparation: 150,\n nodeSpacing: 100,\n treeSpacing: 200,\n blockShifting: true,\n edgeMinimization: true,\n parentCentralization: true,\n direction: \"UD\", // UD, DU, LR, RL\n sortMethod: \"hubsize\", // hubsize, directed\n },\n };\n Object.assign(this.options, this.defaultOptions);\n this.bindEventListeners();\n }\n\n /**\n * Binds event listeners\n */\n bindEventListeners() {\n this.body.emitter.on(\"_dataChanged\", () => {\n this.setupHierarchicalLayout();\n });\n this.body.emitter.on(\"_dataLoaded\", () => {\n this.layoutNetwork();\n });\n this.body.emitter.on(\"_resetHierarchicalLayout\", () => {\n this.setupHierarchicalLayout();\n });\n this.body.emitter.on(\"_adjustEdgesForHierarchicalLayout\", () => {\n if (this.options.hierarchical.enabled !== true) {\n return;\n }\n // get the type of static smooth curve in case it is required\n const type = this.direction.curveType();\n\n // force all edges into static smooth curves.\n this.body.emitter.emit(\"_forceDisableDynamicCurves\", type, false);\n });\n }\n\n /**\n *\n * @param {object} options\n * @param {object} allOptions\n * @returns {object}\n */\n setOptions(options, allOptions) {\n if (options !== undefined) {\n const hierarchical = this.options.hierarchical;\n const prevHierarchicalState = hierarchical.enabled;\n selectiveDeepExtend(\n [\"randomSeed\", \"improvedLayout\", \"clusterThreshold\"],\n this.options,\n options\n );\n mergeOptions(this.options, options, \"hierarchical\");\n\n if (options.randomSeed !== undefined) {\n this._resetRNG(options.randomSeed);\n }\n\n if (hierarchical.enabled === true) {\n if (prevHierarchicalState === true) {\n // refresh the overridden options for nodes and edges.\n this.body.emitter.emit(\"refresh\", true);\n }\n\n // make sure the level separation is the right way up\n if (\n hierarchical.direction === \"RL\" ||\n hierarchical.direction === \"DU\"\n ) {\n if (hierarchical.levelSeparation > 0) {\n hierarchical.levelSeparation *= -1;\n }\n } else {\n if (hierarchical.levelSeparation < 0) {\n hierarchical.levelSeparation *= -1;\n }\n }\n\n this.setDirectionStrategy();\n\n this.body.emitter.emit(\"_resetHierarchicalLayout\");\n // because the hierarchical system needs it's own physics and smooth curve settings,\n // we adapt the other options if needed.\n return this.adaptAllOptionsForHierarchicalLayout(allOptions);\n } else {\n if (prevHierarchicalState === true) {\n // refresh the overridden options for nodes and edges.\n this.body.emitter.emit(\"refresh\");\n return deepExtend(allOptions, this.optionsBackup);\n }\n }\n }\n return allOptions;\n }\n\n /**\n * Reset the random number generator with given seed.\n *\n * @param {any} seed - The seed that will be forwarded the the RNG.\n */\n _resetRNG(seed) {\n this.initialRandomSeed = seed;\n this._rng = Alea(this.initialRandomSeed);\n }\n\n /**\n *\n * @param {object} allOptions\n * @returns {object}\n */\n adaptAllOptionsForHierarchicalLayout(allOptions) {\n if (this.options.hierarchical.enabled === true) {\n const backupPhysics = this.optionsBackup.physics;\n\n // set the physics\n if (allOptions.physics === undefined || allOptions.physics === true) {\n allOptions.physics = {\n enabled:\n backupPhysics.enabled === undefined ? true : backupPhysics.enabled,\n solver: \"hierarchicalRepulsion\",\n };\n backupPhysics.enabled =\n backupPhysics.enabled === undefined ? true : backupPhysics.enabled;\n backupPhysics.solver = backupPhysics.solver || \"barnesHut\";\n } else if (typeof allOptions.physics === \"object\") {\n backupPhysics.enabled =\n allOptions.physics.enabled === undefined\n ? true\n : allOptions.physics.enabled;\n backupPhysics.solver = allOptions.physics.solver || \"barnesHut\";\n allOptions.physics.solver = \"hierarchicalRepulsion\";\n } else if (allOptions.physics !== false) {\n backupPhysics.solver = \"barnesHut\";\n allOptions.physics = { solver: \"hierarchicalRepulsion\" };\n }\n\n // get the type of static smooth curve in case it is required\n let type = this.direction.curveType();\n\n // disable smooth curves if nothing is defined. If smooth curves have been turned on,\n // turn them into static smooth curves.\n if (allOptions.edges === undefined) {\n this.optionsBackup.edges = {\n smooth: { enabled: true, type: \"dynamic\" },\n };\n allOptions.edges = { smooth: false };\n } else if (allOptions.edges.smooth === undefined) {\n this.optionsBackup.edges = {\n smooth: { enabled: true, type: \"dynamic\" },\n };\n allOptions.edges.smooth = false;\n } else {\n if (typeof allOptions.edges.smooth === \"boolean\") {\n this.optionsBackup.edges = { smooth: allOptions.edges.smooth };\n allOptions.edges.smooth = {\n enabled: allOptions.edges.smooth,\n type: type,\n };\n } else {\n const smooth = allOptions.edges.smooth;\n\n // allow custom types except for dynamic\n if (smooth.type !== undefined && smooth.type !== \"dynamic\") {\n type = smooth.type;\n }\n\n // TODO: this is options merging; see if the standard routines can be used here.\n this.optionsBackup.edges = {\n smooth: {\n enabled: smooth.enabled === undefined ? true : smooth.enabled,\n type: smooth.type === undefined ? \"dynamic\" : smooth.type,\n roundness:\n smooth.roundness === undefined ? 0.5 : smooth.roundness,\n forceDirection:\n smooth.forceDirection === undefined\n ? false\n : smooth.forceDirection,\n },\n };\n\n // NOTE: Copying an object to self; this is basically setting defaults for undefined variables\n allOptions.edges.smooth = {\n enabled: smooth.enabled === undefined ? true : smooth.enabled,\n type: type,\n roundness: smooth.roundness === undefined ? 0.5 : smooth.roundness,\n forceDirection:\n smooth.forceDirection === undefined\n ? false\n : smooth.forceDirection,\n };\n }\n }\n\n // Force all edges into static smooth curves.\n // Only applies to edges that do not use the global options for smooth.\n this.body.emitter.emit(\"_forceDisableDynamicCurves\", type);\n }\n\n return allOptions;\n }\n\n /**\n *\n * @param {Array.<Node>} nodesArray\n */\n positionInitially(nodesArray) {\n if (this.options.hierarchical.enabled !== true) {\n this._resetRNG(this.initialRandomSeed);\n const radius = nodesArray.length + 50;\n for (let i = 0; i < nodesArray.length; i++) {\n const node = nodesArray[i];\n const angle = 2 * Math.PI * this._rng();\n if (node.x === undefined) {\n node.x = radius * Math.cos(angle);\n }\n if (node.y === undefined) {\n node.y = radius * Math.sin(angle);\n }\n }\n }\n }\n\n /**\n * Use Kamada Kawai to position nodes. This is quite a heavy algorithm so if there are a lot of nodes we\n * cluster them first to reduce the amount.\n */\n layoutNetwork() {\n if (\n this.options.hierarchical.enabled !== true &&\n this.options.improvedLayout === true\n ) {\n const indices = this.body.nodeIndices;\n\n // first check if we should Kamada Kawai to layout. The threshold is if less than half of the visible\n // nodes have predefined positions we use this.\n let positionDefined = 0;\n for (let i = 0; i < indices.length; i++) {\n const node = this.body.nodes[indices[i]];\n if (node.predefinedPosition === true) {\n positionDefined += 1;\n }\n }\n\n // if less than half of the nodes have a predefined position we continue\n if (positionDefined < 0.5 * indices.length) {\n const MAX_LEVELS = 10;\n let level = 0;\n const clusterThreshold = this.options.clusterThreshold;\n\n //\n // Define the options for the hidden cluster nodes\n // These options don't propagate outside the clustering phase.\n //\n // Some options are explicitly disabled, because they may be set in group or default node options.\n // The clusters are never displayed, so most explicit settings here serve as performance optimizations.\n //\n // The explicit setting of 'shape' is to avoid `shape: 'image'`; images are not passed to the hidden\n // cluster nodes, leading to an exception on creation.\n //\n // All settings here are performance related, except when noted otherwise.\n //\n const clusterOptions = {\n clusterNodeProperties: {\n shape: \"ellipse\", // Bugfix: avoid type 'image', no images supplied\n label: \"\", // avoid label handling\n group: \"\", // avoid group handling\n font: { multi: false }, // avoid font propagation\n },\n clusterEdgeProperties: {\n label: \"\", // avoid label handling\n font: { multi: false }, // avoid font propagation\n smooth: {\n enabled: false, // avoid drawing penalty for complex edges\n },\n },\n };\n\n // if there are a lot of nodes, we cluster before we run the algorithm.\n // NOTE: this part fails to find clusters for large scale-free networks, which should\n // be easily clusterable.\n // TODO: examine why this is so\n if (indices.length > clusterThreshold) {\n const startLength = indices.length;\n while (indices.length > clusterThreshold && level <= MAX_LEVELS) {\n //console.time(\"clustering\")\n level += 1;\n const before = indices.length;\n // if there are many nodes we do a hubsize cluster\n if (level % 3 === 0) {\n this.body.modules.clustering.clusterBridges(clusterOptions);\n } else {\n this.body.modules.clustering.clusterOutliers(clusterOptions);\n }\n const after = indices.length;\n if (before == after && level % 3 !== 0) {\n this._declusterAll();\n this.body.emitter.emit(\"_layoutFailed\");\n console.info(\n \"This network could not be positioned by this version of the improved layout algorithm.\" +\n \" Please disable improvedLayout for better performance.\"\n );\n return;\n }\n //console.timeEnd(\"clustering\")\n //console.log(before,level,after);\n }\n // increase the size of the edges\n this.body.modules.kamadaKawai.setOptions({\n springLength: Math.max(150, 2 * startLength),\n });\n }\n if (level > MAX_LEVELS) {\n console.info(\n \"The clustering didn't succeed within the amount of interations allowed,\" +\n \" progressing with partial result.\"\n );\n }\n\n // position the system for these nodes and edges\n this.body.modules.kamadaKawai.solve(\n indices,\n this.body.edgeIndices,\n true\n );\n\n // shift to center point\n this._shiftToCenter();\n\n // perturb the nodes a little bit to force the physics to kick in\n const offset = 70;\n for (let i = 0; i < indices.length; i++) {\n // Only perturb the nodes that aren't fixed\n const node = this.body.nodes[indices[i]];\n if (node.predefinedPosition === false) {\n node.x += (0.5 - this._rng()) * offset;\n node.y += (0.5 - this._rng()) * offset;\n }\n }\n\n // uncluster all clusters\n this._declusterAll();\n\n // reposition all bezier nodes.\n this.body.emitter.emit(\"_repositionBezierNodes\");\n }\n }\n }\n\n /**\n * Move all the nodes towards to the center so gravitational pull wil not move the nodes away from view\n *\n * @private\n */\n _shiftToCenter() {\n const range = NetworkUtil.getRangeCore(\n this.body.nodes,\n this.body.nodeIndices\n );\n const center = NetworkUtil.findCenter(range);\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n const node = this.body.nodes[this.body.nodeIndices[i]];\n node.x -= center.x;\n node.y -= center.y;\n }\n }\n\n /**\n * Expands all clusters\n *\n * @private\n */\n _declusterAll() {\n let clustersPresent = true;\n while (clustersPresent === true) {\n clustersPresent = false;\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n if (this.body.nodes[this.body.nodeIndices[i]].isCluster === true) {\n clustersPresent = true;\n this.body.modules.clustering.openCluster(\n this.body.nodeIndices[i],\n {},\n false\n );\n }\n }\n if (clustersPresent === true) {\n this.body.emitter.emit(\"_dataChanged\");\n }\n }\n }\n\n /**\n *\n * @returns {number|*}\n */\n getSeed() {\n return this.initialRandomSeed;\n }\n\n /**\n * This is the main function to layout the nodes in a hierarchical way.\n * It checks if the node details are supplied correctly\n *\n * @private\n */\n setupHierarchicalLayout() {\n if (\n this.options.hierarchical.enabled === true &&\n this.body.nodeIndices.length > 0\n ) {\n // get the size of the largest hubs and check if the user has defined a level for a node.\n let node, nodeId;\n let definedLevel = false;\n let undefinedLevel = false;\n this.lastNodeOnLevel = {};\n this.hierarchical = new HierarchicalStatus();\n\n for (nodeId in this.body.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId)) {\n node = this.body.nodes[nodeId];\n if (node.options.level !== undefined) {\n definedLevel = true;\n this.hierarchical.levels[nodeId] = node.options.level;\n } else {\n undefinedLevel = true;\n }\n }\n }\n\n // if the user defined some levels but not all, alert and run without hierarchical layout\n if (undefinedLevel === true && definedLevel === true) {\n throw new Error(\n \"To use the hierarchical layout, nodes require either no predefined levels\" +\n \" or levels have to be defined for all nodes.\"\n );\n } else {\n // define levels if undefined by the users. Based on hubsize.\n if (undefinedLevel === true) {\n const sortMethod = this.options.hierarchical.sortMethod;\n if (sortMethod === \"hubsize\") {\n this._determineLevelsByHubsize();\n } else if (sortMethod === \"directed\") {\n this._determineLevelsDirected();\n } else if (sortMethod === \"custom\") {\n this._determineLevelsCustomCallback();\n }\n }\n\n // fallback for cases where there are nodes but no edges\n for (const nodeId in this.body.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId)) {\n this.hierarchical.ensureLevel(nodeId);\n }\n }\n // check the distribution of the nodes per level.\n const distribution = this._getDistribution();\n\n // get the parent children relations.\n this._generateMap();\n\n // place the nodes on the canvas.\n this._placeNodesByHierarchy(distribution);\n\n // condense the whitespace.\n this._condenseHierarchy();\n\n // shift to center so gravity does not have to do much\n this._shiftToCenter();\n }\n }\n }\n\n /**\n * @private\n */\n _condenseHierarchy() {\n // Global var in this scope to define when the movement has stopped.\n let stillShifting = false;\n const branches = {};\n // first we have some methods to help shifting trees around.\n // the main method to shift the trees\n const shiftTrees = () => {\n const treeSizes = getTreeSizes();\n let shiftBy = 0;\n for (let i = 0; i < treeSizes.length - 1; i++) {\n const diff = treeSizes[i].max - treeSizes[i + 1].min;\n shiftBy += diff + this.options.hierarchical.treeSpacing;\n shiftTree(i + 1, shiftBy);\n }\n };\n\n // shift a single tree by an offset\n const shiftTree = (index, offset) => {\n const trees = this.hierarchical.trees;\n\n for (const nodeId in trees) {\n if (Object.prototype.hasOwnProperty.call(trees, nodeId)) {\n if (trees[nodeId] === index) {\n this.direction.shift(nodeId, offset);\n }\n }\n }\n };\n\n // get the width of all trees\n const getTreeSizes = () => {\n const treeWidths = [];\n for (let i = 0; i < this.hierarchical.numTrees(); i++) {\n treeWidths.push(this.direction.getTreeSize(i));\n }\n return treeWidths;\n };\n\n // get a map of all nodes in this branch\n const getBranchNodes = (source, map) => {\n if (map[source.id]) {\n return;\n }\n map[source.id] = true;\n if (this.hierarchical.childrenReference[source.id]) {\n const children = this.hierarchical.childrenReference[source.id];\n if (children.length > 0) {\n for (let i = 0; i < children.length; i++) {\n getBranchNodes(this.body.nodes[children[i]], map);\n }\n }\n }\n };\n\n // get a min max width as well as the maximum movement space it has on either sides\n // we use min max terminology because width and height can interchange depending on the direction of the layout\n const getBranchBoundary = (branchMap, maxLevel = 1e9) => {\n let minSpace = 1e9;\n let maxSpace = 1e9;\n let min = 1e9;\n let max = -1e9;\n for (const branchNode in branchMap) {\n if (Object.prototype.hasOwnProperty.call(branchMap, branchNode)) {\n const node = this.body.nodes[branchNode];\n const level = this.hierarchical.levels[node.id];\n const position = this.direction.getPosition(node);\n\n // get the space around the node.\n const [minSpaceNode, maxSpaceNode] = this._getSpaceAroundNode(\n node,\n branchMap\n );\n minSpace = Math.min(minSpaceNode, minSpace);\n maxSpace = Math.min(maxSpaceNode, maxSpace);\n\n // the width is only relevant for the levels two nodes have in common. This is why we filter on this.\n if (level <= maxLevel) {\n min = Math.min(position, min);\n max = Math.max(position, max);\n }\n }\n }\n\n return [min, max, minSpace, maxSpace];\n };\n\n // check what the maximum level is these nodes have in common.\n const getCollisionLevel = (node1, node2) => {\n const maxLevel1 = this.hierarchical.getMaxLevel(node1.id);\n const maxLevel2 = this.hierarchical.getMaxLevel(node2.id);\n return Math.min(maxLevel1, maxLevel2);\n };\n\n /**\n * Condense elements. These can be nodes or branches depending on the callback.\n *\n * @param {Function} callback\n * @param {Array.<number>} levels\n * @param {*} centerParents\n */\n const shiftElementsCloser = (callback, levels, centerParents) => {\n const hier = this.hierarchical;\n\n for (let i = 0; i < levels.length; i++) {\n const level = levels[i];\n const levelNodes = hier.distributionOrdering[level];\n if (levelNodes.length > 1) {\n for (let j = 0; j < levelNodes.length - 1; j++) {\n const node1 = levelNodes[j];\n const node2 = levelNodes[j + 1];\n\n // NOTE: logic maintained as it was; if nodes have same ancestor,\n // then of course they are in the same sub-network.\n if (\n hier.hasSameParent(node1, node2) &&\n hier.inSameSubNetwork(node1, node2)\n ) {\n callback(node1, node2, centerParents);\n }\n }\n }\n }\n };\n\n // callback for shifting branches\n const branchShiftCallback = (node1, node2, centerParent = false) => {\n //window.CALLBACKS.push(() => {\n const pos1 = this.direction.getPosition(node1);\n const pos2 = this.direction.getPosition(node2);\n const diffAbs = Math.abs(pos2 - pos1);\n const nodeSpacing = this.options.hierarchical.nodeSpacing;\n //console.log(\"NOW CHECKING:\", node1.id, node2.id, diffAbs);\n if (diffAbs > nodeSpacing) {\n const branchNodes1 = {};\n const branchNodes2 = {};\n\n getBranchNodes(node1, branchNodes1);\n getBranchNodes(node2, branchNodes2);\n\n // check the largest distance between the branches\n const maxLevel = getCollisionLevel(node1, node2);\n const branchNodeBoundary1 = getBranchBoundary(branchNodes1, maxLevel);\n const branchNodeBoundary2 = getBranchBoundary(branchNodes2, maxLevel);\n const max1 = branchNodeBoundary1[1];\n const min2 = branchNodeBoundary2[0];\n const minSpace2 = branchNodeBoundary2[2];\n\n //console.log(node1.id, getBranchBoundary(branchNodes1, maxLevel), node2.id,\n // getBranchBoundary(branchNodes2, maxLevel), maxLevel);\n const diffBranch = Math.abs(max1 - min2);\n if (diffBranch > nodeSpacing) {\n let offset = max1 - min2 + nodeSpacing;\n if (offset < -minSpace2 + nodeSpacing) {\n offset = -minSpace2 + nodeSpacing;\n //console.log(\"RESETTING OFFSET\", max1 - min2 + this.options.hierarchical.nodeSpacing, -minSpace2, offset);\n }\n if (offset < 0) {\n //console.log(\"SHIFTING\", node2.id, offset);\n this._shiftBlock(node2.id, offset);\n stillShifting = true;\n\n if (centerParent === true) this._centerParent(node2);\n }\n }\n }\n //this.body.emitter.emit(\"_redraw\");})\n };\n\n const minimizeEdgeLength = (iterations, node) => {\n //window.CALLBACKS.push(() => {\n // console.log(\"ts\",node.id);\n const nodeId = node.id;\n const allEdges = node.edges;\n const nodeLevel = this.hierarchical.levels[node.id];\n\n // gather constants\n const C2 =\n this.options.hierarchical.levelSeparation *\n this.options.hierarchical.levelSeparation;\n const referenceNodes = {};\n const aboveEdges = [];\n for (let i = 0; i < allEdges.length; i++) {\n const edge = allEdges[i];\n if (edge.toId != edge.fromId) {\n const otherNode = edge.toId == nodeId ? edge.from : edge.to;\n referenceNodes[allEdges[i].id] = otherNode;\n if (this.hierarchical.levels[otherNode.id] < nodeLevel) {\n aboveEdges.push(edge);\n }\n }\n }\n\n // differentiated sum of lengths based on only moving one node over one axis\n const getFx = (point, edges) => {\n let sum = 0;\n for (let i = 0; i < edges.length; i++) {\n if (referenceNodes[edges[i].id] !== undefined) {\n const a =\n this.direction.getPosition(referenceNodes[edges[i].id]) - point;\n sum += a / Math.sqrt(a * a + C2);\n }\n }\n return sum;\n };\n\n // doubly differentiated sum of lengths based on only moving one node over one axis\n const getDFx = (point, edges) => {\n let sum = 0;\n for (let i = 0; i < edges.length; i++) {\n if (referenceNodes[edges[i].id] !== undefined) {\n const a =\n this.direction.getPosition(referenceNodes[edges[i].id]) - point;\n sum -= C2 * Math.pow(a * a + C2, -1.5);\n }\n }\n return sum;\n };\n\n const getGuess = (iterations, edges) => {\n let guess = this.direction.getPosition(node);\n // Newton's method for optimization\n const guessMap = {};\n for (let i = 0; i < iterations; i++) {\n const fx = getFx(guess, edges);\n const dfx = getDFx(guess, edges);\n\n // we limit the movement to avoid instability.\n const limit = 40;\n const ratio = Math.max(-limit, Math.min(limit, Math.round(fx / dfx)));\n guess = guess - ratio;\n // reduce duplicates\n if (guessMap[guess] !== undefined) {\n break;\n }\n guessMap[guess] = i;\n }\n return guess;\n };\n\n const moveBranch = (guess) => {\n // position node if there is space\n const nodePosition = this.direction.getPosition(node);\n\n // check movable area of the branch\n if (branches[node.id] === undefined) {\n const branchNodes = {};\n getBranchNodes(node, branchNodes);\n branches[node.id] = branchNodes;\n }\n const branchBoundary = getBranchBoundary(branches[node.id]);\n const minSpaceBranch = branchBoundary[2];\n const maxSpaceBranch = branchBoundary[3];\n\n const diff = guess - nodePosition;\n\n // check if we are allowed to move the node:\n let branchOffset = 0;\n if (diff > 0) {\n branchOffset = Math.min(\n diff,\n maxSpaceBranch - this.options.hierarchical.nodeSpacing\n );\n } else if (diff < 0) {\n branchOffset = -Math.min(\n -diff,\n minSpaceBranch - this.options.hierarchical.nodeSpacing\n );\n }\n\n if (branchOffset != 0) {\n //console.log(\"moving branch:\",branchOffset, maxSpaceBranch, minSpaceBranch)\n this._shiftBlock(node.id, branchOffset);\n //this.body.emitter.emit(\"_redraw\");\n stillShifting = true;\n }\n };\n\n const moveNode = (guess) => {\n const nodePosition = this.direction.getPosition(node);\n\n // position node if there is space\n const [minSpace, maxSpace] = this._getSpaceAroundNode(node);\n const diff = guess - nodePosition;\n // check if we are allowed to move the node:\n let newPosition = nodePosition;\n if (diff > 0) {\n newPosition = Math.min(\n nodePosition + (maxSpace - this.options.hierarchical.nodeSpacing),\n guess\n );\n } else if (diff < 0) {\n newPosition = Math.max(\n nodePosition - (minSpace - this.options.hierarchical.nodeSpacing),\n guess\n );\n }\n\n if (newPosition !== nodePosition) {\n //console.log(\"moving Node:\",diff, minSpace, maxSpace);\n this.direction.setPosition(node, newPosition);\n //this.body.emitter.emit(\"_redraw\");\n stillShifting = true;\n }\n };\n\n let guess = getGuess(iterations, aboveEdges);\n moveBranch(guess);\n guess = getGuess(iterations, allEdges);\n moveNode(guess);\n //})\n };\n\n // method to remove whitespace between branches. Because we do bottom up, we can center the parents.\n const minimizeEdgeLengthBottomUp = (iterations) => {\n let levels = this.hierarchical.getLevels();\n levels = levels.reverse();\n for (let i = 0; i < iterations; i++) {\n stillShifting = false;\n for (let j = 0; j < levels.length; j++) {\n const level = levels[j];\n const levelNodes = this.hierarchical.distributionOrdering[level];\n for (let k = 0; k < levelNodes.length; k++) {\n minimizeEdgeLength(1000, levelNodes[k]);\n }\n }\n if (stillShifting !== true) {\n //console.log(\"FINISHED minimizeEdgeLengthBottomUp IN \" + i);\n break;\n }\n }\n };\n\n // method to remove whitespace between branches. Because we do bottom up, we can center the parents.\n const shiftBranchesCloserBottomUp = (iterations) => {\n let levels = this.hierarchical.getLevels();\n levels = levels.reverse();\n for (let i = 0; i < iterations; i++) {\n stillShifting = false;\n shiftElementsCloser(branchShiftCallback, levels, true);\n if (stillShifting !== true) {\n //console.log(\"FINISHED shiftBranchesCloserBottomUp IN \" + (i+1));\n break;\n }\n }\n };\n\n // center all parents\n const centerAllParents = () => {\n for (const nodeId in this.body.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId))\n this._centerParent(this.body.nodes[nodeId]);\n }\n };\n\n // center all parents\n const centerAllParentsBottomUp = () => {\n let levels = this.hierarchical.getLevels();\n levels = levels.reverse();\n for (let i = 0; i < levels.length; i++) {\n const level = levels[i];\n const levelNodes = this.hierarchical.distributionOrdering[level];\n for (let j = 0; j < levelNodes.length; j++) {\n this._centerParent(levelNodes[j]);\n }\n }\n };\n\n // the actual work is done here.\n if (this.options.hierarchical.blockShifting === true) {\n shiftBranchesCloserBottomUp(5);\n centerAllParents();\n }\n\n // minimize edge length\n if (this.options.hierarchical.edgeMinimization === true) {\n minimizeEdgeLengthBottomUp(20);\n }\n\n if (this.options.hierarchical.parentCentralization === true) {\n centerAllParentsBottomUp();\n }\n\n shiftTrees();\n }\n\n /**\n * This gives the space around the node. IF a map is supplied, it will only check against nodes NOT in the map.\n * This is used to only get the distances to nodes outside of a branch.\n *\n * @param {Node} node\n * @param {{Node.id: vis.Node}} map\n * @returns {number[]}\n * @private\n */\n _getSpaceAroundNode(node, map) {\n let useMap = true;\n if (map === undefined) {\n useMap = false;\n }\n const level = this.hierarchical.levels[node.id];\n if (level !== undefined) {\n const index = this.hierarchical.distributionIndex[node.id];\n const position = this.direction.getPosition(node);\n const ordering = this.hierarchical.distributionOrdering[level];\n let minSpace = 1e9;\n let maxSpace = 1e9;\n if (index !== 0) {\n const prevNode = ordering[index - 1];\n if (\n (useMap === true && map[prevNode.id] === undefined) ||\n useMap === false\n ) {\n const prevPos = this.direction.getPosition(prevNode);\n minSpace = position - prevPos;\n }\n }\n\n if (index != ordering.length - 1) {\n const nextNode = ordering[index + 1];\n if (\n (useMap === true && map[nextNode.id] === undefined) ||\n useMap === false\n ) {\n const nextPos = this.direction.getPosition(nextNode);\n maxSpace = Math.min(maxSpace, nextPos - position);\n }\n }\n\n return [minSpace, maxSpace];\n } else {\n return [0, 0];\n }\n }\n\n /**\n * We use this method to center a parent node and check if it does not cross other nodes when it does.\n *\n * @param {Node} node\n * @private\n */\n _centerParent(node) {\n if (this.hierarchical.parentReference[node.id]) {\n const parents = this.hierarchical.parentReference[node.id];\n for (let i = 0; i < parents.length; i++) {\n const parentId = parents[i];\n const parentNode = this.body.nodes[parentId];\n const children = this.hierarchical.childrenReference[parentId];\n\n if (children !== undefined) {\n // get the range of the children\n const newPosition = this._getCenterPosition(children);\n\n const position = this.direction.getPosition(parentNode);\n const [minSpace, maxSpace] = this._getSpaceAroundNode(parentNode);\n const diff = position - newPosition;\n if (\n (diff < 0 &&\n Math.abs(diff) <\n maxSpace - this.options.hierarchical.nodeSpacing) ||\n (diff > 0 &&\n Math.abs(diff) < minSpace - this.options.hierarchical.nodeSpacing)\n ) {\n this.direction.setPosition(parentNode, newPosition);\n }\n }\n }\n }\n }\n\n /**\n * This function places the nodes on the canvas based on the hierarchial distribution.\n *\n * @param {object} distribution | obtained by the function this._getDistribution()\n * @private\n */\n _placeNodesByHierarchy(distribution) {\n this.positionedNodes = {};\n // start placing all the level 0 nodes first. Then recursively position their branches.\n for (const level in distribution) {\n if (Object.prototype.hasOwnProperty.call(distribution, level)) {\n // sort nodes in level by position:\n let nodeArray = Object.keys(distribution[level]);\n nodeArray = this._indexArrayToNodes(nodeArray);\n this.direction.sort(nodeArray);\n let handledNodeCount = 0;\n\n for (let i = 0; i < nodeArray.length; i++) {\n const node = nodeArray[i];\n if (this.positionedNodes[node.id] === undefined) {\n const spacing = this.options.hierarchical.nodeSpacing;\n let pos = spacing * handledNodeCount;\n // We get the X or Y values we need and store them in pos and previousPos.\n // The get and set make sure we get X or Y\n if (handledNodeCount > 0) {\n pos = this.direction.getPosition(nodeArray[i - 1]) + spacing;\n }\n this.direction.setPosition(node, pos, level);\n this._validatePositionAndContinue(node, level, pos);\n\n handledNodeCount++;\n }\n }\n }\n }\n }\n\n /**\n * This is a recursively called function to enumerate the branches from the largest hubs and place the nodes\n * on a X position that ensures there will be no overlap.\n *\n * @param {Node.id} parentId\n * @param {number} parentLevel\n * @private\n */\n _placeBranchNodes(parentId, parentLevel) {\n const childRef = this.hierarchical.childrenReference[parentId];\n\n // if this is not a parent, cancel the placing. This can happen with multiple parents to one child.\n if (childRef === undefined) {\n return;\n }\n\n // get a list of childNodes\n const childNodes = [];\n for (let i = 0; i < childRef.length; i++) {\n childNodes.push(this.body.nodes[childRef[i]]);\n }\n\n // use the positions to order the nodes.\n this.direction.sort(childNodes);\n\n // position the childNodes\n for (let i = 0; i < childNodes.length; i++) {\n const childNode = childNodes[i];\n const childNodeLevel = this.hierarchical.levels[childNode.id];\n // check if the child node is below the parent node and if it has already been positioned.\n if (\n childNodeLevel > parentLevel &&\n this.positionedNodes[childNode.id] === undefined\n ) {\n // get the amount of space required for this node. If parent the width is based on the amount of children.\n const spacing = this.options.hierarchical.nodeSpacing;\n let pos;\n\n // we get the X or Y values we need and store them in pos and previousPos.\n // The get and set make sure we get X or Y\n if (i === 0) {\n pos = this.direction.getPosition(this.body.nodes[parentId]);\n } else {\n pos = this.direction.getPosition(childNodes[i - 1]) + spacing;\n }\n this.direction.setPosition(childNode, pos, childNodeLevel);\n this._validatePositionAndContinue(childNode, childNodeLevel, pos);\n } else {\n return;\n }\n }\n\n // center the parent nodes.\n const center = this._getCenterPosition(childNodes);\n this.direction.setPosition(this.body.nodes[parentId], center, parentLevel);\n }\n\n /**\n * This method checks for overlap and if required shifts the branch. It also keeps records of positioned nodes.\n * Finally it will call _placeBranchNodes to place the branch nodes.\n *\n * @param {Node} node\n * @param {number} level\n * @param {number} pos\n * @private\n */\n _validatePositionAndContinue(node, level, pos) {\n // This method only works for formal trees and formal forests\n // Early exit if this is not the case\n if (!this.hierarchical.isTree) return;\n\n // if overlap has been detected, we shift the branch\n if (this.lastNodeOnLevel[level] !== undefined) {\n const previousPos = this.direction.getPosition(\n this.body.nodes[this.lastNodeOnLevel[level]]\n );\n if (pos - previousPos < this.options.hierarchical.nodeSpacing) {\n const diff = previousPos + this.options.hierarchical.nodeSpacing - pos;\n const sharedParent = this._findCommonParent(\n this.lastNodeOnLevel[level],\n node.id\n );\n this._shiftBlock(sharedParent.withChild, diff);\n }\n }\n\n this.lastNodeOnLevel[level] = node.id; // store change in position.\n this.positionedNodes[node.id] = true;\n this._placeBranchNodes(node.id, level);\n }\n\n /**\n * Receives an array with node indices and returns an array with the actual node references.\n * Used for sorting based on node properties.\n *\n * @param {Array.<Node.id>} idArray\n * @returns {Array.<Node>}\n */\n _indexArrayToNodes(idArray) {\n const array = [];\n for (let i = 0; i < idArray.length; i++) {\n array.push(this.body.nodes[idArray[i]]);\n }\n return array;\n }\n\n /**\n * This function get the distribution of levels based on hubsize\n *\n * @returns {object}\n * @private\n */\n _getDistribution() {\n const distribution = {};\n let nodeId, node;\n\n // we fix Y because the hierarchy is vertical,\n // we fix X so we do not give a node an x position for a second time.\n // the fix of X is removed after the x value has been set.\n for (nodeId in this.body.nodes) {\n if (Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId)) {\n node = this.body.nodes[nodeId];\n const level =\n this.hierarchical.levels[nodeId] === undefined\n ? 0\n : this.hierarchical.levels[nodeId];\n this.direction.fix(node, level);\n if (distribution[level] === undefined) {\n distribution[level] = {};\n }\n distribution[level][nodeId] = node;\n }\n }\n return distribution;\n }\n\n /**\n * Return the active (i.e. visible) edges for this node\n *\n * @param {Node} node\n * @returns {Array.<vis.Edge>} Array of edge instances\n * @private\n */\n _getActiveEdges(node) {\n const result = [];\n\n forEach(node.edges, (edge) => {\n if (this.body.edgeIndices.indexOf(edge.id) !== -1) {\n result.push(edge);\n }\n });\n\n return result;\n }\n\n /**\n * Get the hubsizes for all active nodes.\n *\n * @returns {number}\n * @private\n */\n _getHubSizes() {\n const hubSizes = {};\n const nodeIds = this.body.nodeIndices;\n\n forEach(nodeIds, (nodeId) => {\n const node = this.body.nodes[nodeId];\n const hubSize = this._getActiveEdges(node).length;\n hubSizes[hubSize] = true;\n });\n\n // Make an array of the size sorted descending\n const result = [];\n forEach(hubSizes, (size) => {\n result.push(Number(size));\n });\n\n TimSort.sort(result, function (a, b) {\n return b - a;\n });\n\n return result;\n }\n\n /**\n * this function allocates nodes in levels based on the recursive branching from the largest hubs.\n *\n * @private\n */\n _determineLevelsByHubsize() {\n const levelDownstream = (nodeA, nodeB) => {\n this.hierarchical.levelDownstream(nodeA, nodeB);\n };\n\n const hubSizes = this._getHubSizes();\n\n for (let i = 0; i < hubSizes.length; ++i) {\n const hubSize = hubSizes[i];\n if (hubSize === 0) break;\n\n forEach(this.body.nodeIndices, (nodeId) => {\n const node = this.body.nodes[nodeId];\n\n if (hubSize === this._getActiveEdges(node).length) {\n this._crawlNetwork(levelDownstream, nodeId);\n }\n });\n }\n }\n\n /**\n * TODO: release feature\n * TODO: Determine if this feature is needed at all\n *\n * @private\n */\n _determineLevelsCustomCallback() {\n const minLevel = 100000;\n\n // TODO: this should come from options.\n // eslint-disable-next-line no-unused-vars -- This should eventually be implemented with these parameters used.\n const customCallback = function (nodeA, nodeB, edge) {};\n\n // TODO: perhaps move to HierarchicalStatus.\n // But I currently don't see the point, this method is not used.\n const levelByDirection = (nodeA, nodeB, edge) => {\n let levelA = this.hierarchical.levels[nodeA.id];\n // set initial level\n if (levelA === undefined) {\n levelA = this.hierarchical.levels[nodeA.id] = minLevel;\n }\n\n const diff = customCallback(\n NetworkUtil.cloneOptions(nodeA, \"node\"),\n NetworkUtil.cloneOptions(nodeB, \"node\"),\n NetworkUtil.cloneOptions(edge, \"edge\")\n );\n\n this.hierarchical.levels[nodeB.id] = levelA + diff;\n };\n\n this._crawlNetwork(levelByDirection);\n this.hierarchical.setMinLevelToZero(this.body.nodes);\n }\n\n /**\n * Allocate nodes in levels based on the direction of the edges.\n *\n * @private\n */\n _determineLevelsDirected() {\n const nodes = this.body.nodeIndices.reduce((acc, id) => {\n acc.set(id, this.body.nodes[id]);\n return acc;\n }, new Map());\n\n if (this.options.hierarchical.shakeTowards === \"roots\") {\n this.hierarchical.levels = fillLevelsByDirectionRoots(nodes);\n } else {\n this.hierarchical.levels = fillLevelsByDirectionLeaves(nodes);\n }\n\n this.hierarchical.setMinLevelToZero(this.body.nodes);\n }\n\n /**\n * Update the bookkeeping of parent and child.\n *\n * @private\n */\n _generateMap() {\n const fillInRelations = (parentNode, childNode) => {\n if (\n this.hierarchical.levels[childNode.id] >\n this.hierarchical.levels[parentNode.id]\n ) {\n this.hierarchical.addRelation(parentNode.id, childNode.id);\n }\n };\n\n this._crawlNetwork(fillInRelations);\n this.hierarchical.checkIfTree();\n }\n\n /**\n * Crawl over the entire network and use a callback on each node couple that is connected to each other.\n *\n * @param {Function} [callback=function(){}] | will receive nodeA, nodeB and the connecting edge. A and B are distinct.\n * @param {Node.id} startingNodeId\n * @private\n */\n _crawlNetwork(callback = function () {}, startingNodeId) {\n const progress = {};\n\n const crawler = (node, tree) => {\n if (progress[node.id] === undefined) {\n this.hierarchical.setTreeIndex(node, tree);\n\n progress[node.id] = true;\n let childNode;\n const edges = this._getActiveEdges(node);\n for (let i = 0; i < edges.length; i++) {\n const edge = edges[i];\n if (edge.connected === true) {\n if (edge.toId == node.id) {\n // Not '===' because id's can be string and numeric\n childNode = edge.from;\n } else {\n childNode = edge.to;\n }\n\n if (node.id != childNode.id) {\n // Not '!==' because id's can be string and numeric\n callback(node, childNode, edge);\n crawler(childNode, tree);\n }\n }\n }\n }\n };\n\n if (startingNodeId === undefined) {\n // Crawl over all nodes\n let treeIndex = 0; // Serves to pass a unique id for the current distinct tree\n\n for (let i = 0; i < this.body.nodeIndices.length; i++) {\n const nodeId = this.body.nodeIndices[i];\n\n if (progress[nodeId] === undefined) {\n const node = this.body.nodes[nodeId];\n crawler(node, treeIndex);\n treeIndex += 1;\n }\n }\n } else {\n // Crawl from the given starting node\n const node = this.body.nodes[startingNodeId];\n if (node === undefined) {\n console.error(\"Node not found:\", startingNodeId);\n return;\n }\n crawler(node);\n }\n }\n\n /**\n * Shift a branch a certain distance\n *\n * @param {Node.id} parentId\n * @param {number} diff\n * @private\n */\n _shiftBlock(parentId, diff) {\n const progress = {};\n const shifter = (parentId) => {\n if (progress[parentId]) {\n return;\n }\n progress[parentId] = true;\n this.direction.shift(parentId, diff);\n\n const childRef = this.hierarchical.childrenReference[parentId];\n if (childRef !== undefined) {\n for (let i = 0; i < childRef.length; i++) {\n shifter(childRef[i]);\n }\n }\n };\n shifter(parentId);\n }\n\n /**\n * Find a common parent between branches.\n *\n * @param {Node.id} childA\n * @param {Node.id} childB\n * @returns {{foundParent, withChild}}\n * @private\n */\n _findCommonParent(childA, childB) {\n const parents = {};\n const iterateParents = (parents, child) => {\n const parentRef = this.hierarchical.parentReference[child];\n if (parentRef !== undefined) {\n for (let i = 0; i < parentRef.length; i++) {\n const parent = parentRef[i];\n parents[parent] = true;\n iterateParents(parents, parent);\n }\n }\n };\n const findParent = (parents, child) => {\n const parentRef = this.hierarchical.parentReference[child];\n if (parentRef !== undefined) {\n for (let i = 0; i < parentRef.length; i++) {\n const parent = parentRef[i];\n if (parents[parent] !== undefined) {\n return { foundParent: parent, withChild: child };\n }\n const branch = findParent(parents, parent);\n if (branch.foundParent !== null) {\n return branch;\n }\n }\n }\n return { foundParent: null, withChild: child };\n };\n\n iterateParents(parents, childA);\n return findParent(parents, childB);\n }\n\n /**\n * Set the strategy pattern for handling the coordinates given the current direction.\n *\n * The individual instances contain all the operations and data specific to a layout direction.\n *\n * @param {Node} node\n * @param {{x: number, y: number}} position\n * @param {number} level\n * @param {boolean} [doNotUpdate=false]\n * @private\n */\n setDirectionStrategy() {\n const isVertical =\n this.options.hierarchical.direction === \"UD\" ||\n this.options.hierarchical.direction === \"DU\";\n\n if (isVertical) {\n this.direction = new VerticalStrategy(this);\n } else {\n this.direction = new HorizontalStrategy(this);\n }\n }\n\n /**\n * Determine the center position of a branch from the passed list of child nodes\n *\n * This takes into account the positions of all the child nodes.\n *\n * @param {Array.<Node|vis.Node.id>} childNodes Array of either child nodes or node id's\n * @returns {number}\n * @private\n */\n _getCenterPosition(childNodes) {\n let minPos = 1e9;\n let maxPos = -1e9;\n\n for (let i = 0; i < childNodes.length; i++) {\n let childNode;\n if (childNodes[i].id !== undefined) {\n childNode = childNodes[i];\n } else {\n const childNodeId = childNodes[i];\n childNode = this.body.nodes[childNodeId];\n }\n\n const position = this.direction.getPosition(childNode);\n minPos = Math.min(minPos, position);\n maxPos = Math.max(maxPos, position);\n }\n\n return 0.5 * (minPos + maxPos);\n }\n}\n\nexport default LayoutEngine;\n","import \"./ManipulationSystem.css\";\n\nimport { Hammer, deepExtend, recursiveDOMDelete } from \"vis-util/esnext\";\nimport { v4 as randomUUID } from \"uuid\";\nimport { onTouch } from \"../../hammerUtil\";\n\n/**\n * Clears the toolbar div element of children\n *\n * @private\n */\nclass ManipulationSystem {\n /**\n * @param {object} body\n * @param {Canvas} canvas\n * @param {SelectionHandler} selectionHandler\n * @param {InteractionHandler} interactionHandler\n */\n constructor(body, canvas, selectionHandler, interactionHandler) {\n this.body = body;\n this.canvas = canvas;\n this.selectionHandler = selectionHandler;\n this.interactionHandler = interactionHandler;\n\n this.editMode = false;\n this.manipulationDiv = undefined;\n this.editModeDiv = undefined;\n this.closeDiv = undefined;\n\n this._domEventListenerCleanupQueue = [];\n this.temporaryUIFunctions = {};\n this.temporaryEventFunctions = [];\n\n this.touchTime = 0;\n this.temporaryIds = { nodes: [], edges: [] };\n this.guiEnabled = false;\n this.inMode = false;\n this.selectedControlNode = undefined;\n\n this.options = {};\n this.defaultOptions = {\n enabled: false,\n initiallyActive: false,\n addNode: true,\n addEdge: true,\n editNode: undefined,\n editEdge: true,\n deleteNode: true,\n deleteEdge: true,\n controlNodeStyle: {\n shape: \"dot\",\n size: 6,\n color: {\n background: \"#ff0000\",\n border: \"#3c3c3c\",\n highlight: { background: \"#07f968\", border: \"#3c3c3c\" },\n },\n borderWidth: 2,\n borderWidthSelected: 2,\n },\n };\n Object.assign(this.options, this.defaultOptions);\n\n this.body.emitter.on(\"destroy\", () => {\n this._clean();\n });\n this.body.emitter.on(\"_dataChanged\", this._restore.bind(this));\n this.body.emitter.on(\"_resetData\", this._restore.bind(this));\n }\n\n /**\n * If something changes in the data during editing, switch back to the initial datamanipulation state and close all edit modes.\n *\n * @private\n */\n _restore() {\n if (this.inMode !== false) {\n if (this.options.initiallyActive === true) {\n this.enableEditMode();\n } else {\n this.disableEditMode();\n }\n }\n }\n\n /**\n * Set the Options\n *\n * @param {object} options\n * @param {object} allOptions\n * @param {object} globalOptions\n */\n setOptions(options, allOptions, globalOptions) {\n if (allOptions !== undefined) {\n if (allOptions.locale !== undefined) {\n this.options.locale = allOptions.locale;\n } else {\n this.options.locale = globalOptions.locale;\n }\n if (allOptions.locales !== undefined) {\n this.options.locales = allOptions.locales;\n } else {\n this.options.locales = globalOptions.locales;\n }\n }\n\n if (options !== undefined) {\n if (typeof options === \"boolean\") {\n this.options.enabled = options;\n } else {\n this.options.enabled = true;\n deepExtend(this.options, options);\n }\n if (this.options.initiallyActive === true) {\n this.editMode = true;\n }\n this._setup();\n }\n }\n\n /**\n * Enable or disable edit-mode. Draws the DOM required and cleans up after itself.\n *\n * @private\n */\n toggleEditMode() {\n if (this.editMode === true) {\n this.disableEditMode();\n } else {\n this.enableEditMode();\n }\n }\n\n /**\n * Enables Edit Mode\n */\n enableEditMode() {\n this.editMode = true;\n\n this._clean();\n if (this.guiEnabled === true) {\n this.manipulationDiv.style.display = \"block\";\n this.closeDiv.style.display = \"block\";\n this.editModeDiv.style.display = \"none\";\n this.showManipulatorToolbar();\n }\n }\n\n /**\n * Disables Edit Mode\n */\n disableEditMode() {\n this.editMode = false;\n\n this._clean();\n if (this.guiEnabled === true) {\n this.manipulationDiv.style.display = \"none\";\n this.closeDiv.style.display = \"none\";\n this.editModeDiv.style.display = \"block\";\n this._createEditButton();\n }\n }\n\n /**\n * Creates the main toolbar. Removes functions bound to the select event. Binds all the buttons of the toolbar.\n *\n * @private\n */\n showManipulatorToolbar() {\n // restore the state of any bound functions or events, remove control nodes, restore physics\n this._clean();\n\n // reset global variables\n this.manipulationDOM = {};\n\n // if the gui is enabled, draw all elements.\n if (this.guiEnabled === true) {\n // a _restore will hide these menus\n this.editMode = true;\n this.manipulationDiv.style.display = \"block\";\n this.closeDiv.style.display = \"block\";\n\n const selectedNodeCount = this.selectionHandler.getSelectedNodeCount();\n const selectedEdgeCount = this.selectionHandler.getSelectedEdgeCount();\n const selectedTotalCount = selectedNodeCount + selectedEdgeCount;\n const locale = this.options.locales[this.options.locale];\n let needSeperator = false;\n\n if (this.options.addNode !== false) {\n this._createAddNodeButton(locale);\n needSeperator = true;\n }\n if (this.options.addEdge !== false) {\n if (needSeperator === true) {\n this._createSeperator(1);\n } else {\n needSeperator = true;\n }\n this._createAddEdgeButton(locale);\n }\n\n if (\n selectedNodeCount === 1 &&\n typeof this.options.editNode === \"function\"\n ) {\n if (needSeperator === true) {\n this._createSeperator(2);\n } else {\n needSeperator = true;\n }\n this._createEditNodeButton(locale);\n } else if (\n selectedEdgeCount === 1 &&\n selectedNodeCount === 0 &&\n this.options.editEdge !== false\n ) {\n if (needSeperator === true) {\n this._createSeperator(3);\n } else {\n needSeperator = true;\n }\n this._createEditEdgeButton(locale);\n }\n\n // remove buttons\n if (selectedTotalCount !== 0) {\n if (selectedNodeCount > 0 && this.options.deleteNode !== false) {\n if (needSeperator === true) {\n this._createSeperator(4);\n }\n this._createDeleteButton(locale);\n } else if (\n selectedNodeCount === 0 &&\n this.options.deleteEdge !== false\n ) {\n if (needSeperator === true) {\n this._createSeperator(4);\n }\n this._createDeleteButton(locale);\n }\n }\n\n // bind the close button\n this._bindElementEvents(this.closeDiv, this.toggleEditMode.bind(this));\n\n // refresh this bar based on what has been selected\n this._temporaryBindEvent(\n \"select\",\n this.showManipulatorToolbar.bind(this)\n );\n }\n\n // redraw to show any possible changes\n this.body.emitter.emit(\"_redraw\");\n }\n\n /**\n * Create the toolbar for adding Nodes\n */\n addNodeMode() {\n // when using the gui, enable edit mode if it wasnt already.\n if (this.editMode !== true) {\n this.enableEditMode();\n }\n\n // restore the state of any bound functions or events, remove control nodes, restore physics\n this._clean();\n\n this.inMode = \"addNode\";\n if (this.guiEnabled === true) {\n const locale = this.options.locales[this.options.locale];\n this.manipulationDOM = {};\n this._createBackButton(locale);\n this._createSeperator();\n this._createDescription(\n locale[\"addDescription\"] || this.options.locales[\"en\"][\"addDescription\"]\n );\n\n // bind the close button\n this._bindElementEvents(this.closeDiv, this.toggleEditMode.bind(this));\n }\n\n this._temporaryBindEvent(\"click\", this._performAddNode.bind(this));\n }\n\n /**\n * call the bound function to handle the editing of the node. The node has to be selected.\n */\n editNode() {\n // when using the gui, enable edit mode if it wasnt already.\n if (this.editMode !== true) {\n this.enableEditMode();\n }\n\n // restore the state of any bound functions or events, remove control nodes, restore physics\n this._clean();\n const node = this.selectionHandler.getSelectedNodes()[0];\n if (node !== undefined) {\n this.inMode = \"editNode\";\n if (typeof this.options.editNode === \"function\") {\n if (node.isCluster !== true) {\n const data = deepExtend({}, node.options, false);\n data.x = node.x;\n data.y = node.y;\n\n if (this.options.editNode.length === 2) {\n this.options.editNode(data, (finalizedData) => {\n if (\n finalizedData !== null &&\n finalizedData !== undefined &&\n this.inMode === \"editNode\"\n ) {\n // if for whatever reason the mode has changes (due to dataset change) disregard the callback) {\n this.body.data.nodes.getDataSet().update(finalizedData);\n }\n this.showManipulatorToolbar();\n });\n } else {\n throw new Error(\n \"The function for edit does not support two arguments (data, callback)\"\n );\n }\n } else {\n alert(\n this.options.locales[this.options.locale][\"editClusterError\"] ||\n this.options.locales[\"en\"][\"editClusterError\"]\n );\n }\n } else {\n throw new Error(\n \"No function has been configured to handle the editing of nodes.\"\n );\n }\n } else {\n this.showManipulatorToolbar();\n }\n }\n\n /**\n * create the toolbar to connect nodes\n */\n addEdgeMode() {\n // when using the gui, enable edit mode if it wasnt already.\n if (this.editMode !== true) {\n this.enableEditMode();\n }\n\n // restore the state of any bound functions or events, remove control nodes, restore physics\n this._clean();\n\n this.inMode = \"addEdge\";\n if (this.guiEnabled === true) {\n const locale = this.options.locales[this.options.locale];\n this.manipulationDOM = {};\n this._createBackButton(locale);\n this._createSeperator();\n this._createDescription(\n locale[\"edgeDescription\"] ||\n this.options.locales[\"en\"][\"edgeDescription\"]\n );\n\n // bind the close button\n this._bindElementEvents(this.closeDiv, this.toggleEditMode.bind(this));\n }\n\n // temporarily overload functions\n this._temporaryBindUI(\"onTouch\", this._handleConnect.bind(this));\n this._temporaryBindUI(\"onDragEnd\", this._finishConnect.bind(this));\n this._temporaryBindUI(\"onDrag\", this._dragControlNode.bind(this));\n this._temporaryBindUI(\"onRelease\", this._finishConnect.bind(this));\n this._temporaryBindUI(\"onDragStart\", this._dragStartEdge.bind(this));\n this._temporaryBindUI(\"onHold\", () => {});\n }\n\n /**\n * create the toolbar to edit edges\n */\n editEdgeMode() {\n // when using the gui, enable edit mode if it wasn't already.\n if (this.editMode !== true) {\n this.enableEditMode();\n }\n\n // restore the state of any bound functions or events, remove control nodes, restore physics\n this._clean();\n\n this.inMode = \"editEdge\";\n if (\n typeof this.options.editEdge === \"object\" &&\n typeof this.options.editEdge.editWithoutDrag === \"function\"\n ) {\n this.edgeBeingEditedId = this.selectionHandler.getSelectedEdgeIds()[0];\n if (this.edgeBeingEditedId !== undefined) {\n const edge = this.body.edges[this.edgeBeingEditedId];\n this._performEditEdge(edge.from.id, edge.to.id);\n return;\n }\n }\n if (this.guiEnabled === true) {\n const locale = this.options.locales[this.options.locale];\n this.manipulationDOM = {};\n this._createBackButton(locale);\n this._createSeperator();\n this._createDescription(\n locale[\"editEdgeDescription\"] ||\n this.options.locales[\"en\"][\"editEdgeDescription\"]\n );\n\n // bind the close button\n this._bindElementEvents(this.closeDiv, this.toggleEditMode.bind(this));\n }\n\n this.edgeBeingEditedId = this.selectionHandler.getSelectedEdgeIds()[0];\n if (this.edgeBeingEditedId !== undefined) {\n const edge = this.body.edges[this.edgeBeingEditedId];\n\n // create control nodes\n const controlNodeFrom = this._getNewTargetNode(edge.from.x, edge.from.y);\n const controlNodeTo = this._getNewTargetNode(edge.to.x, edge.to.y);\n\n this.temporaryIds.nodes.push(controlNodeFrom.id);\n this.temporaryIds.nodes.push(controlNodeTo.id);\n\n this.body.nodes[controlNodeFrom.id] = controlNodeFrom;\n this.body.nodeIndices.push(controlNodeFrom.id);\n this.body.nodes[controlNodeTo.id] = controlNodeTo;\n this.body.nodeIndices.push(controlNodeTo.id);\n\n // temporarily overload UI functions, cleaned up automatically because of _temporaryBindUI\n this._temporaryBindUI(\"onTouch\", this._controlNodeTouch.bind(this)); // used to get the position\n this._temporaryBindUI(\"onTap\", () => {}); // disabled\n this._temporaryBindUI(\"onHold\", () => {}); // disabled\n this._temporaryBindUI(\n \"onDragStart\",\n this._controlNodeDragStart.bind(this)\n ); // used to select control node\n this._temporaryBindUI(\"onDrag\", this._controlNodeDrag.bind(this)); // used to drag control node\n this._temporaryBindUI(\"onDragEnd\", this._controlNodeDragEnd.bind(this)); // used to connect or revert control nodes\n this._temporaryBindUI(\"onMouseMove\", () => {}); // disabled\n\n // create function to position control nodes correctly on movement\n // automatically cleaned up because we use the temporary bind\n this._temporaryBindEvent(\"beforeDrawing\", (ctx) => {\n const positions = edge.edgeType.findBorderPositions(ctx);\n if (controlNodeFrom.selected === false) {\n controlNodeFrom.x = positions.from.x;\n controlNodeFrom.y = positions.from.y;\n }\n if (controlNodeTo.selected === false) {\n controlNodeTo.x = positions.to.x;\n controlNodeTo.y = positions.to.y;\n }\n });\n\n this.body.emitter.emit(\"_redraw\");\n } else {\n this.showManipulatorToolbar();\n }\n }\n\n /**\n * delete everything in the selection\n */\n deleteSelected() {\n // when using the gui, enable edit mode if it wasnt already.\n if (this.editMode !== true) {\n this.enableEditMode();\n }\n\n // restore the state of any bound functions or events, remove control nodes, restore physics\n this._clean();\n\n this.inMode = \"delete\";\n const selectedNodes = this.selectionHandler.getSelectedNodeIds();\n const selectedEdges = this.selectionHandler.getSelectedEdgeIds();\n let deleteFunction = undefined;\n if (selectedNodes.length > 0) {\n for (let i = 0; i < selectedNodes.length; i++) {\n if (this.body.nodes[selectedNodes[i]].isCluster === true) {\n alert(\n this.options.locales[this.options.locale][\"deleteClusterError\"] ||\n this.options.locales[\"en\"][\"deleteClusterError\"]\n );\n return;\n }\n }\n\n if (typeof this.options.deleteNode === \"function\") {\n deleteFunction = this.options.deleteNode;\n }\n } else if (selectedEdges.length > 0) {\n if (typeof this.options.deleteEdge === \"function\") {\n deleteFunction = this.options.deleteEdge;\n }\n }\n\n if (typeof deleteFunction === \"function\") {\n const data = { nodes: selectedNodes, edges: selectedEdges };\n if (deleteFunction.length === 2) {\n deleteFunction(data, (finalizedData) => {\n if (\n finalizedData !== null &&\n finalizedData !== undefined &&\n this.inMode === \"delete\"\n ) {\n // if for whatever reason the mode has changes (due to dataset change) disregard the callback) {\n this.body.data.edges.getDataSet().remove(finalizedData.edges);\n this.body.data.nodes.getDataSet().remove(finalizedData.nodes);\n this.body.emitter.emit(\"startSimulation\");\n this.showManipulatorToolbar();\n } else {\n this.body.emitter.emit(\"startSimulation\");\n this.showManipulatorToolbar();\n }\n });\n } else {\n throw new Error(\n \"The function for delete does not support two arguments (data, callback)\"\n );\n }\n } else {\n this.body.data.edges.getDataSet().remove(selectedEdges);\n this.body.data.nodes.getDataSet().remove(selectedNodes);\n this.body.emitter.emit(\"startSimulation\");\n this.showManipulatorToolbar();\n }\n }\n\n //********************************************** PRIVATE ***************************************//\n\n /**\n * draw or remove the DOM\n *\n * @private\n */\n _setup() {\n if (this.options.enabled === true) {\n // Enable the GUI\n this.guiEnabled = true;\n\n this._createWrappers();\n if (this.editMode === false) {\n this._createEditButton();\n } else {\n this.showManipulatorToolbar();\n }\n } else {\n this._removeManipulationDOM();\n\n // disable the gui\n this.guiEnabled = false;\n }\n }\n\n /**\n * create the div overlays that contain the DOM\n *\n * @private\n */\n _createWrappers() {\n // load the manipulator HTML elements. All styling done in css.\n if (this.manipulationDiv === undefined) {\n this.manipulationDiv = document.createElement(\"div\");\n this.manipulationDiv.className = \"vis-manipulation\";\n if (this.editMode === true) {\n this.manipulationDiv.style.display = \"block\";\n } else {\n this.manipulationDiv.style.display = \"none\";\n }\n this.canvas.frame.appendChild(this.manipulationDiv);\n }\n\n // container for the edit button.\n if (this.editModeDiv === undefined) {\n this.editModeDiv = document.createElement(\"div\");\n this.editModeDiv.className = \"vis-edit-mode\";\n if (this.editMode === true) {\n this.editModeDiv.style.display = \"none\";\n } else {\n this.editModeDiv.style.display = \"block\";\n }\n this.canvas.frame.appendChild(this.editModeDiv);\n }\n\n // container for the close div button\n if (this.closeDiv === undefined) {\n this.closeDiv = document.createElement(\"button\");\n this.closeDiv.className = \"vis-close\";\n this.closeDiv.setAttribute(\n \"aria-label\",\n this.options.locales[this.options.locale]?.[\"close\"] ??\n this.options.locales[\"en\"][\"close\"]\n );\n this.closeDiv.style.display = this.manipulationDiv.style.display;\n this.canvas.frame.appendChild(this.closeDiv);\n }\n }\n\n /**\n * generate a new target node. Used for creating new edges and editing edges\n *\n * @param {number} x\n * @param {number} y\n * @returns {Node}\n * @private\n */\n _getNewTargetNode(x, y) {\n const controlNodeStyle = deepExtend({}, this.options.controlNodeStyle);\n\n controlNodeStyle.id = \"targetNode\" + randomUUID();\n controlNodeStyle.hidden = false;\n controlNodeStyle.physics = false;\n controlNodeStyle.x = x;\n controlNodeStyle.y = y;\n\n // we have to define the bounding box in order for the nodes to be drawn immediately\n const node = this.body.functions.createNode(controlNodeStyle);\n node.shape.boundingBox = { left: x, right: x, top: y, bottom: y };\n\n return node;\n }\n\n /**\n * Create the edit button\n */\n _createEditButton() {\n // restore everything to it's original state (if applicable)\n this._clean();\n\n // reset the manipulationDOM\n this.manipulationDOM = {};\n\n // empty the editModeDiv\n recursiveDOMDelete(this.editModeDiv);\n\n // create the contents for the editMode button\n const locale = this.options.locales[this.options.locale];\n const button = this._createButton(\n \"editMode\",\n \"vis-edit vis-edit-mode\",\n locale[\"edit\"] || this.options.locales[\"en\"][\"edit\"]\n );\n this.editModeDiv.appendChild(button);\n\n // bind a hammer listener to the button, calling the function toggleEditMode.\n this._bindElementEvents(button, this.toggleEditMode.bind(this));\n }\n\n /**\n * this function cleans up after everything this module does. Temporary elements, functions and events are removed, physics restored, hammers removed.\n *\n * @private\n */\n _clean() {\n // not in mode\n this.inMode = false;\n\n // _clean the divs\n if (this.guiEnabled === true) {\n recursiveDOMDelete(this.editModeDiv);\n recursiveDOMDelete(this.manipulationDiv);\n\n // removes all the bindings and overloads\n this._cleanupDOMEventListeners();\n }\n\n // remove temporary nodes and edges\n this._cleanupTemporaryNodesAndEdges();\n\n // restore overloaded UI functions\n this._unbindTemporaryUIs();\n\n // remove the temporaryEventFunctions\n this._unbindTemporaryEvents();\n\n // restore the physics if required\n this.body.emitter.emit(\"restorePhysics\");\n }\n\n /**\n * Each dom element has it's own hammer. They are stored in this.manipulationHammers. This cleans them up.\n *\n * @private\n */\n _cleanupDOMEventListeners() {\n // _clean DOM event listener bindings\n for (const callback of this._domEventListenerCleanupQueue.splice(0)) {\n callback();\n }\n }\n\n /**\n * Remove all DOM elements created by this module.\n *\n * @private\n */\n _removeManipulationDOM() {\n // removes all the bindings and overloads\n this._clean();\n\n // empty the manipulation divs\n recursiveDOMDelete(this.manipulationDiv);\n recursiveDOMDelete(this.editModeDiv);\n recursiveDOMDelete(this.closeDiv);\n\n // remove the manipulation divs\n if (this.manipulationDiv) {\n this.canvas.frame.removeChild(this.manipulationDiv);\n }\n if (this.editModeDiv) {\n this.canvas.frame.removeChild(this.editModeDiv);\n }\n if (this.closeDiv) {\n this.canvas.frame.removeChild(this.closeDiv);\n }\n\n // set the references to undefined\n this.manipulationDiv = undefined;\n this.editModeDiv = undefined;\n this.closeDiv = undefined;\n }\n\n /**\n * create a seperator line. the index is to differentiate in the manipulation dom\n *\n * @param {number} [index=1]\n * @private\n */\n _createSeperator(index = 1) {\n this.manipulationDOM[\"seperatorLineDiv\" + index] =\n document.createElement(\"div\");\n this.manipulationDOM[\"seperatorLineDiv\" + index].className =\n \"vis-separator-line\";\n this.manipulationDiv.appendChild(\n this.manipulationDOM[\"seperatorLineDiv\" + index]\n );\n }\n\n // ---------------------- DOM functions for buttons --------------------------//\n\n /**\n *\n * @param {Locale} locale\n * @private\n */\n _createAddNodeButton(locale) {\n const button = this._createButton(\n \"addNode\",\n \"vis-add\",\n locale[\"addNode\"] || this.options.locales[\"en\"][\"addNode\"]\n );\n this.manipulationDiv.appendChild(button);\n this._bindElementEvents(button, this.addNodeMode.bind(this));\n }\n\n /**\n *\n * @param {Locale} locale\n * @private\n */\n _createAddEdgeButton(locale) {\n const button = this._createButton(\n \"addEdge\",\n \"vis-connect\",\n locale[\"addEdge\"] || this.options.locales[\"en\"][\"addEdge\"]\n );\n this.manipulationDiv.appendChild(button);\n this._bindElementEvents(button, this.addEdgeMode.bind(this));\n }\n\n /**\n *\n * @param {Locale} locale\n * @private\n */\n _createEditNodeButton(locale) {\n const button = this._createButton(\n \"editNode\",\n \"vis-edit\",\n locale[\"editNode\"] || this.options.locales[\"en\"][\"editNode\"]\n );\n this.manipulationDiv.appendChild(button);\n this._bindElementEvents(button, this.editNode.bind(this));\n }\n\n /**\n *\n * @param {Locale} locale\n * @private\n */\n _createEditEdgeButton(locale) {\n const button = this._createButton(\n \"editEdge\",\n \"vis-edit\",\n locale[\"editEdge\"] || this.options.locales[\"en\"][\"editEdge\"]\n );\n this.manipulationDiv.appendChild(button);\n this._bindElementEvents(button, this.editEdgeMode.bind(this));\n }\n\n /**\n *\n * @param {Locale} locale\n * @private\n */\n _createDeleteButton(locale) {\n let deleteBtnClass;\n if (this.options.rtl) {\n deleteBtnClass = \"vis-delete-rtl\";\n } else {\n deleteBtnClass = \"vis-delete\";\n }\n const button = this._createButton(\n \"delete\",\n deleteBtnClass,\n locale[\"del\"] || this.options.locales[\"en\"][\"del\"]\n );\n this.manipulationDiv.appendChild(button);\n this._bindElementEvents(button, this.deleteSelected.bind(this));\n }\n\n /**\n *\n * @param {Locale} locale\n * @private\n */\n _createBackButton(locale) {\n const button = this._createButton(\n \"back\",\n \"vis-back\",\n locale[\"back\"] || this.options.locales[\"en\"][\"back\"]\n );\n this.manipulationDiv.appendChild(button);\n this._bindElementEvents(button, this.showManipulatorToolbar.bind(this));\n }\n\n /**\n *\n * @param {number|string} id\n * @param {string} className\n * @param {label} label\n * @param {string} labelClassName\n * @returns {HTMLElement}\n * @private\n */\n _createButton(id, className, label, labelClassName = \"vis-label\") {\n this.manipulationDOM[id + \"Div\"] = document.createElement(\"button\");\n this.manipulationDOM[id + \"Div\"].className = \"vis-button \" + className;\n this.manipulationDOM[id + \"Label\"] = document.createElement(\"div\");\n this.manipulationDOM[id + \"Label\"].className = labelClassName;\n this.manipulationDOM[id + \"Label\"].innerText = label;\n this.manipulationDOM[id + \"Div\"].appendChild(\n this.manipulationDOM[id + \"Label\"]\n );\n return this.manipulationDOM[id + \"Div\"];\n }\n\n /**\n *\n * @param {Label} label\n * @private\n */\n _createDescription(label) {\n this.manipulationDOM[\"descriptionLabel\"] = document.createElement(\"div\");\n this.manipulationDOM[\"descriptionLabel\"].className = \"vis-none\";\n this.manipulationDOM[\"descriptionLabel\"].innerText = label;\n this.manipulationDiv.appendChild(this.manipulationDOM[\"descriptionLabel\"]);\n }\n\n // -------------------------- End of DOM functions for buttons ------------------------------//\n\n /**\n * this binds an event until cleanup by the clean functions.\n *\n * @param {Event} event The event\n * @param {Function} newFunction\n * @private\n */\n _temporaryBindEvent(event, newFunction) {\n this.temporaryEventFunctions.push({\n event: event,\n boundFunction: newFunction,\n });\n this.body.emitter.on(event, newFunction);\n }\n\n /**\n * this overrides an UI function until cleanup by the clean function\n *\n * @param {string} UIfunctionName\n * @param {Function} newFunction\n * @private\n */\n _temporaryBindUI(UIfunctionName, newFunction) {\n if (this.body.eventListeners[UIfunctionName] !== undefined) {\n this.temporaryUIFunctions[UIfunctionName] =\n this.body.eventListeners[UIfunctionName];\n this.body.eventListeners[UIfunctionName] = newFunction;\n } else {\n throw new Error(\n \"This UI function does not exist. Typo? You tried: \" +\n UIfunctionName +\n \" possible are: \" +\n JSON.stringify(Object.keys(this.body.eventListeners))\n );\n }\n }\n\n /**\n * Restore the overridden UI functions to their original state.\n *\n * @private\n */\n _unbindTemporaryUIs() {\n for (const functionName in this.temporaryUIFunctions) {\n if (\n Object.prototype.hasOwnProperty.call(\n this.temporaryUIFunctions,\n functionName\n )\n ) {\n this.body.eventListeners[functionName] =\n this.temporaryUIFunctions[functionName];\n delete this.temporaryUIFunctions[functionName];\n }\n }\n this.temporaryUIFunctions = {};\n }\n\n /**\n * Unbind the events created by _temporaryBindEvent\n *\n * @private\n */\n _unbindTemporaryEvents() {\n for (let i = 0; i < this.temporaryEventFunctions.length; i++) {\n const eventName = this.temporaryEventFunctions[i].event;\n const boundFunction = this.temporaryEventFunctions[i].boundFunction;\n this.body.emitter.off(eventName, boundFunction);\n }\n this.temporaryEventFunctions = [];\n }\n\n /**\n * Bind an hammer instance to a DOM element.\n *\n * @param {Element} domElement\n * @param {Function} boundFunction\n */\n _bindElementEvents(domElement, boundFunction) {\n // Bind touch events.\n const hammer = new Hammer(domElement, {});\n onTouch(hammer, boundFunction);\n this._domEventListenerCleanupQueue.push(() => {\n hammer.destroy();\n });\n\n // Bind keyboard events.\n const keyupListener = ({ keyCode, key }) => {\n if (key === \"Enter\" || key === \" \" || keyCode === 13 || keyCode === 32) {\n boundFunction();\n }\n };\n domElement.addEventListener(\"keyup\", keyupListener, false);\n this._domEventListenerCleanupQueue.push(() => {\n domElement.removeEventListener(\"keyup\", keyupListener, false);\n });\n }\n\n /**\n * Neatly clean up temporary edges and nodes\n *\n * @private\n */\n _cleanupTemporaryNodesAndEdges() {\n // _clean temporary edges\n for (let i = 0; i < this.temporaryIds.edges.length; i++) {\n this.body.edges[this.temporaryIds.edges[i]].disconnect();\n delete this.body.edges[this.temporaryIds.edges[i]];\n const indexTempEdge = this.body.edgeIndices.indexOf(\n this.temporaryIds.edges[i]\n );\n if (indexTempEdge !== -1) {\n this.body.edgeIndices.splice(indexTempEdge, 1);\n }\n }\n\n // _clean temporary nodes\n for (let i = 0; i < this.temporaryIds.nodes.length; i++) {\n delete this.body.nodes[this.temporaryIds.nodes[i]];\n const indexTempNode = this.body.nodeIndices.indexOf(\n this.temporaryIds.nodes[i]\n );\n if (indexTempNode !== -1) {\n this.body.nodeIndices.splice(indexTempNode, 1);\n }\n }\n\n this.temporaryIds = { nodes: [], edges: [] };\n }\n\n // ------------------------------------------ EDIT EDGE FUNCTIONS -----------------------------------------//\n\n /**\n * the touch is used to get the position of the initial click\n *\n * @param {Event} event The event\n * @private\n */\n _controlNodeTouch(event) {\n this.selectionHandler.unselectAll();\n this.lastTouch = this.body.functions.getPointer(event.center);\n this.lastTouch.translation = Object.assign({}, this.body.view.translation); // copy the object\n }\n\n /**\n * the drag start is used to mark one of the control nodes as selected.\n *\n * @private\n */\n _controlNodeDragStart() {\n const pointer = this.lastTouch;\n const pointerObj = this.selectionHandler._pointerToPositionObject(pointer);\n const from = this.body.nodes[this.temporaryIds.nodes[0]];\n const to = this.body.nodes[this.temporaryIds.nodes[1]];\n const edge = this.body.edges[this.edgeBeingEditedId];\n this.selectedControlNode = undefined;\n\n const fromSelect = from.isOverlappingWith(pointerObj);\n const toSelect = to.isOverlappingWith(pointerObj);\n\n if (fromSelect === true) {\n this.selectedControlNode = from;\n edge.edgeType.from = from;\n } else if (toSelect === true) {\n this.selectedControlNode = to;\n edge.edgeType.to = to;\n }\n\n // we use the selection to find the node that is being dragged. We explicitly select it here.\n if (this.selectedControlNode !== undefined) {\n this.selectionHandler.selectObject(this.selectedControlNode);\n }\n\n this.body.emitter.emit(\"_redraw\");\n }\n\n /**\n * dragging the control nodes or the canvas\n *\n * @param {Event} event The event\n * @private\n */\n _controlNodeDrag(event) {\n this.body.emitter.emit(\"disablePhysics\");\n const pointer = this.body.functions.getPointer(event.center);\n const pos = this.canvas.DOMtoCanvas(pointer);\n if (this.selectedControlNode !== undefined) {\n this.selectedControlNode.x = pos.x;\n this.selectedControlNode.y = pos.y;\n } else {\n this.interactionHandler.onDrag(event);\n }\n this.body.emitter.emit(\"_redraw\");\n }\n\n /**\n * connecting or restoring the control nodes.\n *\n * @param {Event} event The event\n * @private\n */\n _controlNodeDragEnd(event) {\n const pointer = this.body.functions.getPointer(event.center);\n const pointerObj = this.selectionHandler._pointerToPositionObject(pointer);\n const edge = this.body.edges[this.edgeBeingEditedId];\n // if the node that was dragged is not a control node, return\n if (this.selectedControlNode === undefined) {\n return;\n }\n\n // we use the selection to find the node that is being dragged. We explicitly DEselect the control node here.\n this.selectionHandler.unselectAll();\n const overlappingNodeIds =\n this.selectionHandler._getAllNodesOverlappingWith(pointerObj);\n let node = undefined;\n for (let i = overlappingNodeIds.length - 1; i >= 0; i--) {\n if (overlappingNodeIds[i] !== this.selectedControlNode.id) {\n node = this.body.nodes[overlappingNodeIds[i]];\n break;\n }\n }\n // perform the connection\n if (node !== undefined && this.selectedControlNode !== undefined) {\n if (node.isCluster === true) {\n alert(\n this.options.locales[this.options.locale][\"createEdgeError\"] ||\n this.options.locales[\"en\"][\"createEdgeError\"]\n );\n } else {\n const from = this.body.nodes[this.temporaryIds.nodes[0]];\n if (this.selectedControlNode.id === from.id) {\n this._performEditEdge(node.id, edge.to.id);\n } else {\n this._performEditEdge(edge.from.id, node.id);\n }\n }\n } else {\n edge.updateEdgeType();\n this.body.emitter.emit(\"restorePhysics\");\n }\n\n this.body.emitter.emit(\"_redraw\");\n }\n\n // ------------------------------------ END OF EDIT EDGE FUNCTIONS -----------------------------------------//\n\n // ------------------------------------------- ADD EDGE FUNCTIONS -----------------------------------------//\n /**\n * the function bound to the selection event. It checks if you want to connect a cluster and changes the description\n * to walk the user through the process.\n *\n * @param {Event} event\n * @private\n */\n _handleConnect(event) {\n // check to avoid double fireing of this function.\n if (new Date().valueOf() - this.touchTime > 100) {\n this.lastTouch = this.body.functions.getPointer(event.center);\n this.lastTouch.translation = Object.assign(\n {},\n this.body.view.translation\n ); // copy the object\n\n this.interactionHandler.drag.pointer = this.lastTouch; // Drag pointer is not updated when adding edges\n this.interactionHandler.drag.translation = this.lastTouch.translation;\n\n const pointer = this.lastTouch;\n const node = this.selectionHandler.getNodeAt(pointer);\n\n if (node !== undefined) {\n if (node.isCluster === true) {\n alert(\n this.options.locales[this.options.locale][\"createEdgeError\"] ||\n this.options.locales[\"en\"][\"createEdgeError\"]\n );\n } else {\n // create a node the temporary line can look at\n const targetNode = this._getNewTargetNode(node.x, node.y);\n this.body.nodes[targetNode.id] = targetNode;\n this.body.nodeIndices.push(targetNode.id);\n\n // create a temporary edge\n const connectionEdge = this.body.functions.createEdge({\n id: \"connectionEdge\" + randomUUID(),\n from: node.id,\n to: targetNode.id,\n physics: false,\n smooth: {\n enabled: true,\n type: \"continuous\",\n roundness: 0.5,\n },\n });\n this.body.edges[connectionEdge.id] = connectionEdge;\n this.body.edgeIndices.push(connectionEdge.id);\n\n this.temporaryIds.nodes.push(targetNode.id);\n this.temporaryIds.edges.push(connectionEdge.id);\n }\n }\n this.touchTime = new Date().valueOf();\n }\n }\n\n /**\n *\n * @param {Event} event\n * @private\n */\n _dragControlNode(event) {\n const pointer = this.body.functions.getPointer(event.center);\n\n const pointerObj = this.selectionHandler._pointerToPositionObject(pointer);\n // remember the edge id\n let connectFromId = undefined;\n if (this.temporaryIds.edges[0] !== undefined) {\n connectFromId = this.body.edges[this.temporaryIds.edges[0]].fromId;\n }\n\n // get the overlapping node but NOT the temporary node;\n const overlappingNodeIds =\n this.selectionHandler._getAllNodesOverlappingWith(pointerObj);\n let node = undefined;\n for (let i = overlappingNodeIds.length - 1; i >= 0; i--) {\n // if the node id is NOT a temporary node, accept the node.\n if (this.temporaryIds.nodes.indexOf(overlappingNodeIds[i]) === -1) {\n node = this.body.nodes[overlappingNodeIds[i]];\n break;\n }\n }\n\n event.controlEdge = { from: connectFromId, to: node ? node.id : undefined };\n this.selectionHandler.generateClickEvent(\n \"controlNodeDragging\",\n event,\n pointer\n );\n\n if (this.temporaryIds.nodes[0] !== undefined) {\n const targetNode = this.body.nodes[this.temporaryIds.nodes[0]]; // there is only one temp node in the add edge mode.\n targetNode.x = this.canvas._XconvertDOMtoCanvas(pointer.x);\n targetNode.y = this.canvas._YconvertDOMtoCanvas(pointer.y);\n this.body.emitter.emit(\"_redraw\");\n } else {\n this.interactionHandler.onDrag(event);\n }\n }\n\n /**\n * Connect the new edge to the target if one exists, otherwise remove temp line\n *\n * @param {Event} event The event\n * @private\n */\n _finishConnect(event) {\n const pointer = this.body.functions.getPointer(event.center);\n const pointerObj = this.selectionHandler._pointerToPositionObject(pointer);\n\n // remember the edge id\n let connectFromId = undefined;\n if (this.temporaryIds.edges[0] !== undefined) {\n connectFromId = this.body.edges[this.temporaryIds.edges[0]].fromId;\n }\n\n // get the overlapping node but NOT the temporary node;\n const overlappingNodeIds =\n this.selectionHandler._getAllNodesOverlappingWith(pointerObj);\n let node = undefined;\n for (let i = overlappingNodeIds.length - 1; i >= 0; i--) {\n // if the node id is NOT a temporary node, accept the node.\n if (this.temporaryIds.nodes.indexOf(overlappingNodeIds[i]) === -1) {\n node = this.body.nodes[overlappingNodeIds[i]];\n break;\n }\n }\n\n // clean temporary nodes and edges.\n this._cleanupTemporaryNodesAndEdges();\n\n // perform the connection\n if (node !== undefined) {\n if (node.isCluster === true) {\n alert(\n this.options.locales[this.options.locale][\"createEdgeError\"] ||\n this.options.locales[\"en\"][\"createEdgeError\"]\n );\n } else {\n if (\n this.body.nodes[connectFromId] !== undefined &&\n this.body.nodes[node.id] !== undefined\n ) {\n this._performAddEdge(connectFromId, node.id);\n }\n }\n }\n\n event.controlEdge = { from: connectFromId, to: node ? node.id : undefined };\n this.selectionHandler.generateClickEvent(\n \"controlNodeDragEnd\",\n event,\n pointer\n );\n\n // No need to do _generateclickevent('dragEnd') here, the regular dragEnd event fires.\n this.body.emitter.emit(\"_redraw\");\n }\n\n /**\n *\n * @param {Event} event\n * @private\n */\n _dragStartEdge(event) {\n const pointer = this.lastTouch;\n this.selectionHandler.generateClickEvent(\n \"dragStart\",\n event,\n pointer,\n undefined,\n true\n );\n }\n\n // --------------------------------------- END OF ADD EDGE FUNCTIONS -------------------------------------//\n\n // ------------------------------ Performing all the actual data manipulation ------------------------//\n\n /**\n * Adds a node on the specified location\n *\n * @param {object} clickData\n * @private\n */\n _performAddNode(clickData) {\n const defaultData = {\n id: randomUUID(),\n x: clickData.pointer.canvas.x,\n y: clickData.pointer.canvas.y,\n label: \"new\",\n };\n\n if (typeof this.options.addNode === \"function\") {\n if (this.options.addNode.length === 2) {\n this.options.addNode(defaultData, (finalizedData) => {\n if (\n finalizedData !== null &&\n finalizedData !== undefined &&\n this.inMode === \"addNode\"\n ) {\n // if for whatever reason the mode has changes (due to dataset change) disregard the callback\n this.body.data.nodes.getDataSet().add(finalizedData);\n }\n this.showManipulatorToolbar();\n });\n } else {\n this.showManipulatorToolbar();\n throw new Error(\n \"The function for add does not support two arguments (data,callback)\"\n );\n }\n } else {\n this.body.data.nodes.getDataSet().add(defaultData);\n this.showManipulatorToolbar();\n }\n }\n\n /**\n * connect two nodes with a new edge.\n *\n * @param {Node.id} sourceNodeId\n * @param {Node.id} targetNodeId\n * @private\n */\n _performAddEdge(sourceNodeId, targetNodeId) {\n const defaultData = { from: sourceNodeId, to: targetNodeId };\n if (typeof this.options.addEdge === \"function\") {\n if (this.options.addEdge.length === 2) {\n this.options.addEdge(defaultData, (finalizedData) => {\n if (\n finalizedData !== null &&\n finalizedData !== undefined &&\n this.inMode === \"addEdge\"\n ) {\n // if for whatever reason the mode has changes (due to dataset change) disregard the callback\n this.body.data.edges.getDataSet().add(finalizedData);\n this.selectionHandler.unselectAll();\n this.showManipulatorToolbar();\n }\n });\n } else {\n throw new Error(\n \"The function for connect does not support two arguments (data,callback)\"\n );\n }\n } else {\n this.body.data.edges.getDataSet().add(defaultData);\n this.selectionHandler.unselectAll();\n this.showManipulatorToolbar();\n }\n }\n\n /**\n * connect two nodes with a new edge.\n *\n * @param {Node.id} sourceNodeId\n * @param {Node.id} targetNodeId\n * @private\n */\n _performEditEdge(sourceNodeId, targetNodeId) {\n const defaultData = {\n id: this.edgeBeingEditedId,\n from: sourceNodeId,\n to: targetNodeId,\n label: this.body.data.edges.get(this.edgeBeingEditedId).label,\n };\n let eeFunct = this.options.editEdge;\n if (typeof eeFunct === \"object\") {\n eeFunct = eeFunct.editWithoutDrag;\n }\n if (typeof eeFunct === \"function\") {\n if (eeFunct.length === 2) {\n eeFunct(defaultData, (finalizedData) => {\n if (\n finalizedData === null ||\n finalizedData === undefined ||\n this.inMode !== \"editEdge\"\n ) {\n // if for whatever reason the mode has changes (due to dataset change) disregard the callback) {\n this.body.edges[defaultData.id].updateEdgeType();\n this.body.emitter.emit(\"_redraw\");\n this.showManipulatorToolbar();\n } else {\n this.body.data.edges.getDataSet().update(finalizedData);\n this.selectionHandler.unselectAll();\n this.showManipulatorToolbar();\n }\n });\n } else {\n throw new Error(\n \"The function for edit does not support two arguments (data, callback)\"\n );\n }\n } else {\n this.body.data.edges.getDataSet().update(defaultData);\n this.selectionHandler.unselectAll();\n this.showManipulatorToolbar();\n }\n }\n}\n\nexport default ManipulationSystem;\n","import {\n ConfiguratorConfig,\n ConfiguratorHideOption,\n OptionsConfig,\n} from \"vis-util/esnext\";\n\n/**\n * This object contains all possible options. It will check if the types are correct, if required if the option is one\n * of the allowed values.\n *\n * __any__ means that the name of the property does not matter.\n * __type__ is a required field for all objects and contains the allowed types of all objects\n */\nconst string = \"string\";\nconst bool = \"boolean\";\nconst number = \"number\";\nconst array = \"array\";\nconst object = \"object\"; // should only be in a __type__ property\nconst dom = \"dom\";\nconst any = \"any\";\n\n// List of endpoints\nconst endPoints = [\n \"arrow\",\n \"bar\",\n \"box\",\n \"circle\",\n \"crow\",\n \"curve\",\n \"diamond\",\n \"image\",\n \"inv_curve\",\n \"inv_triangle\",\n \"triangle\",\n \"vee\",\n];\n\n/* eslint-disable @typescript-eslint/naming-convention -- The __*__ format is used to prevent collisions with actual option names. */\nconst nodeOptions: OptionsConfig = {\n borderWidth: { number },\n borderWidthSelected: { number, undefined: \"undefined\" },\n brokenImage: { string, undefined: \"undefined\" },\n chosen: {\n label: { boolean: bool, function: \"function\" },\n node: { boolean: bool, function: \"function\" },\n __type__: { object, boolean: bool },\n },\n color: {\n border: { string },\n background: { string },\n highlight: {\n border: { string },\n background: { string },\n __type__: { object, string },\n },\n hover: {\n border: { string },\n background: { string },\n __type__: { object, string },\n },\n __type__: { object, string },\n },\n opacity: { number, undefined: \"undefined\" },\n fixed: {\n x: { boolean: bool },\n y: { boolean: bool },\n __type__: { object, boolean: bool },\n },\n font: {\n align: { string },\n color: { string },\n size: { number }, // px\n face: { string },\n background: { string },\n strokeWidth: { number }, // px\n strokeColor: { string },\n vadjust: { number },\n multi: { boolean: bool, string },\n bold: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n boldital: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n ital: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n mono: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n __type__: { object, string },\n },\n group: { string, number, undefined: \"undefined\" },\n heightConstraint: {\n minimum: { number },\n valign: { string },\n __type__: { object, boolean: bool, number },\n },\n hidden: { boolean: bool },\n icon: {\n face: { string },\n code: { string }, //'\\uf007',\n size: { number }, //50,\n color: { string },\n weight: { string, number },\n __type__: { object },\n },\n id: { string, number },\n image: {\n selected: { string, undefined: \"undefined\" }, // --> URL\n unselected: { string, undefined: \"undefined\" }, // --> URL\n __type__: { object, string },\n },\n imagePadding: {\n top: { number },\n right: { number },\n bottom: { number },\n left: { number },\n __type__: { object, number },\n },\n label: { string, undefined: \"undefined\" },\n labelHighlightBold: { boolean: bool },\n level: { number, undefined: \"undefined\" },\n margin: {\n top: { number },\n right: { number },\n bottom: { number },\n left: { number },\n __type__: { object, number },\n },\n mass: { number },\n physics: { boolean: bool },\n scaling: {\n min: { number },\n max: { number },\n label: {\n enabled: { boolean: bool },\n min: { number },\n max: { number },\n maxVisible: { number },\n drawThreshold: { number },\n __type__: { object, boolean: bool },\n },\n customScalingFunction: { function: \"function\" },\n __type__: { object },\n },\n shadow: {\n enabled: { boolean: bool },\n color: { string },\n size: { number },\n x: { number },\n y: { number },\n __type__: { object, boolean: bool },\n },\n shape: {\n string: [\n \"custom\",\n \"ellipse\",\n \"circle\",\n \"database\",\n \"box\",\n \"text\",\n \"image\",\n \"circularImage\",\n \"diamond\",\n \"dot\",\n \"star\",\n \"triangle\",\n \"triangleDown\",\n \"square\",\n \"icon\",\n \"hexagon\",\n ],\n },\n ctxRenderer: { function: \"function\" },\n shapeProperties: {\n borderDashes: { boolean: bool, array },\n borderRadius: { number },\n interpolation: { boolean: bool },\n useImageSize: { boolean: bool },\n useBorderWithImage: { boolean: bool },\n coordinateOrigin: { string: [\"center\", \"top-left\"] },\n __type__: { object },\n },\n size: { number },\n title: { string, dom, undefined: \"undefined\" },\n value: { number, undefined: \"undefined\" },\n widthConstraint: {\n minimum: { number },\n maximum: { number },\n __type__: { object, boolean: bool, number },\n },\n x: { number },\n y: { number },\n __type__: { object },\n};\nconst allOptions: OptionsConfig = {\n configure: {\n enabled: { boolean: bool },\n filter: { boolean: bool, string, array, function: \"function\" },\n container: { dom },\n showButton: { boolean: bool },\n __type__: { object, boolean: bool, string, array, function: \"function\" },\n },\n edges: {\n arrows: {\n to: {\n enabled: { boolean: bool },\n scaleFactor: { number },\n type: { string: endPoints },\n imageHeight: { number },\n imageWidth: { number },\n src: { string },\n __type__: { object, boolean: bool },\n },\n middle: {\n enabled: { boolean: bool },\n scaleFactor: { number },\n type: { string: endPoints },\n imageWidth: { number },\n imageHeight: { number },\n src: { string },\n __type__: { object, boolean: bool },\n },\n from: {\n enabled: { boolean: bool },\n scaleFactor: { number },\n type: { string: endPoints },\n imageWidth: { number },\n imageHeight: { number },\n src: { string },\n __type__: { object, boolean: bool },\n },\n __type__: { string: [\"from\", \"to\", \"middle\"], object },\n },\n endPointOffset: {\n from: {\n number: number,\n },\n to: {\n number: number,\n },\n __type__: {\n object: object,\n number: number,\n },\n },\n arrowStrikethrough: { boolean: bool },\n background: {\n enabled: { boolean: bool },\n color: { string },\n size: { number },\n dashes: { boolean: bool, array },\n __type__: { object, boolean: bool },\n },\n chosen: {\n label: { boolean: bool, function: \"function\" },\n edge: { boolean: bool, function: \"function\" },\n __type__: { object, boolean: bool },\n },\n color: {\n color: { string },\n highlight: { string },\n hover: { string },\n inherit: { string: [\"from\", \"to\", \"both\"], boolean: bool },\n opacity: { number },\n __type__: { object, string },\n },\n dashes: { boolean: bool, array },\n font: {\n color: { string },\n size: { number }, // px\n face: { string },\n background: { string },\n strokeWidth: { number }, // px\n strokeColor: { string },\n align: { string: [\"horizontal\", \"top\", \"middle\", \"bottom\"] },\n vadjust: { number },\n multi: { boolean: bool, string },\n bold: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n boldital: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n ital: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n mono: {\n color: { string },\n size: { number }, // px\n face: { string },\n mod: { string },\n vadjust: { number },\n __type__: { object, string },\n },\n __type__: { object, string },\n },\n hidden: { boolean: bool },\n hoverWidth: { function: \"function\", number },\n label: { string, undefined: \"undefined\" },\n labelHighlightBold: { boolean: bool },\n length: { number, undefined: \"undefined\" },\n physics: { boolean: bool },\n scaling: {\n min: { number },\n max: { number },\n label: {\n enabled: { boolean: bool },\n min: { number },\n max: { number },\n maxVisible: { number },\n drawThreshold: { number },\n __type__: { object, boolean: bool },\n },\n customScalingFunction: { function: \"function\" },\n __type__: { object },\n },\n selectionWidth: { function: \"function\", number },\n selfReferenceSize: { number },\n selfReference: {\n size: { number },\n angle: { number },\n renderBehindTheNode: { boolean: bool },\n __type__: { object },\n },\n shadow: {\n enabled: { boolean: bool },\n color: { string },\n size: { number },\n x: { number },\n y: { number },\n __type__: { object, boolean: bool },\n },\n smooth: {\n enabled: { boolean: bool },\n type: {\n string: [\n \"dynamic\",\n \"continuous\",\n \"discrete\",\n \"diagonalCross\",\n \"straightCross\",\n \"horizontal\",\n \"vertical\",\n \"curvedCW\",\n \"curvedCCW\",\n \"cubicBezier\",\n ],\n },\n roundness: { number },\n forceDirection: {\n string: [\"horizontal\", \"vertical\", \"none\"],\n boolean: bool,\n },\n __type__: { object, boolean: bool },\n },\n title: { string, undefined: \"undefined\" },\n width: { number },\n widthConstraint: {\n maximum: { number },\n __type__: { object, boolean: bool, number },\n },\n value: { number, undefined: \"undefined\" },\n __type__: { object },\n },\n groups: {\n useDefaultGroups: { boolean: bool },\n __any__: nodeOptions,\n __type__: { object },\n },\n interaction: {\n dragNodes: { boolean: bool },\n dragView: { boolean: bool },\n hideEdgesOnDrag: { boolean: bool },\n hideEdgesOnZoom: { boolean: bool },\n hideNodesOnDrag: { boolean: bool },\n hover: { boolean: bool },\n keyboard: {\n enabled: { boolean: bool },\n speed: {\n x: { number },\n y: { number },\n zoom: { number },\n __type__: { object },\n },\n bindToWindow: { boolean: bool },\n autoFocus: { boolean: bool },\n __type__: { object, boolean: bool },\n },\n multiselect: { boolean: bool },\n navigationButtons: { boolean: bool },\n selectable: { boolean: bool },\n selectConnectedEdges: { boolean: bool },\n hoverConnectedEdges: { boolean: bool },\n tooltipDelay: { number },\n zoomView: { boolean: bool },\n zoomSpeed: { number },\n __type__: { object },\n },\n layout: {\n randomSeed: { undefined: \"undefined\", number, string },\n improvedLayout: { boolean: bool },\n clusterThreshold: { number },\n hierarchical: {\n enabled: { boolean: bool },\n levelSeparation: { number },\n nodeSpacing: { number },\n treeSpacing: { number },\n blockShifting: { boolean: bool },\n edgeMinimization: { boolean: bool },\n parentCentralization: { boolean: bool },\n direction: { string: [\"UD\", \"DU\", \"LR\", \"RL\"] }, // UD, DU, LR, RL\n sortMethod: { string: [\"hubsize\", \"directed\"] }, // hubsize, directed\n shakeTowards: { string: [\"leaves\", \"roots\"] }, // leaves, roots\n __type__: { object, boolean: bool },\n },\n __type__: { object },\n },\n manipulation: {\n enabled: { boolean: bool },\n initiallyActive: { boolean: bool },\n addNode: { boolean: bool, function: \"function\" },\n addEdge: { boolean: bool, function: \"function\" },\n editNode: { function: \"function\" },\n editEdge: {\n editWithoutDrag: { function: \"function\" },\n __type__: { object, boolean: bool, function: \"function\" },\n },\n deleteNode: { boolean: bool, function: \"function\" },\n deleteEdge: { boolean: bool, function: \"function\" },\n controlNodeStyle: nodeOptions,\n __type__: { object, boolean: bool },\n },\n nodes: nodeOptions,\n physics: {\n enabled: { boolean: bool },\n barnesHut: {\n theta: { number },\n gravitationalConstant: { number },\n centralGravity: { number },\n springLength: { number },\n springConstant: { number },\n damping: { number },\n avoidOverlap: { number },\n __type__: { object },\n },\n forceAtlas2Based: {\n theta: { number },\n gravitationalConstant: { number },\n centralGravity: { number },\n springLength: { number },\n springConstant: { number },\n damping: { number },\n avoidOverlap: { number },\n __type__: { object },\n },\n repulsion: {\n centralGravity: { number },\n springLength: { number },\n springConstant: { number },\n nodeDistance: { number },\n damping: { number },\n __type__: { object },\n },\n hierarchicalRepulsion: {\n centralGravity: { number },\n springLength: { number },\n springConstant: { number },\n nodeDistance: { number },\n damping: { number },\n avoidOverlap: { number },\n __type__: { object },\n },\n maxVelocity: { number },\n minVelocity: { number }, // px/s\n solver: {\n string: [\n \"barnesHut\",\n \"repulsion\",\n \"hierarchicalRepulsion\",\n \"forceAtlas2Based\",\n ],\n },\n stabilization: {\n enabled: { boolean: bool },\n iterations: { number }, // maximum number of iteration to stabilize\n updateInterval: { number },\n onlyDynamicEdges: { boolean: bool },\n fit: { boolean: bool },\n __type__: { object, boolean: bool },\n },\n timestep: { number },\n adaptiveTimestep: { boolean: bool },\n wind: {\n x: { number },\n y: { number },\n __type__: { object },\n },\n __type__: { object, boolean: bool },\n },\n\n //globals :\n autoResize: { boolean: bool },\n clickToUse: { boolean: bool },\n locale: { string },\n locales: {\n __any__: { any },\n __type__: { object },\n },\n height: { string },\n width: { string },\n __type__: { object },\n};\n/* eslint-enable @typescript-eslint/naming-convention */\n\n/**\n * This provides ranges, initial values, steps and dropdown menu choices for the\n * configuration.\n *\n * @remarks\n * Checkbox: `boolean`\n * The value supllied will be used as the initial value.\n *\n * Text field: `string`\n * The passed text will be used as the initial value. Any text will be\n * accepted afterwards.\n *\n * Number range: `[number, number, number, number]`\n * The meanings are `[initial value, min, max, step]`.\n *\n * Dropdown: `[Exclude<string, \"color\">, ...(string | number | boolean)[]]`\n * Translations for people with poor understanding of TypeScript: the first\n * value always has to be a string but never `\"color\"`, the rest can be any\n * combination of strings, numbers and booleans.\n *\n * Color picker: `[\"color\", string]`\n * The first value says this will be a color picker not a dropdown menu. The\n * next value is the initial color.\n */\nconst configureOptions: ConfiguratorConfig = {\n nodes: {\n borderWidth: [1, 0, 10, 1],\n borderWidthSelected: [2, 0, 10, 1],\n color: {\n border: [\"color\", \"#2B7CE9\"],\n background: [\"color\", \"#97C2FC\"],\n highlight: {\n border: [\"color\", \"#2B7CE9\"],\n background: [\"color\", \"#D2E5FF\"],\n },\n hover: {\n border: [\"color\", \"#2B7CE9\"],\n background: [\"color\", \"#D2E5FF\"],\n },\n },\n opacity: [0, 0, 1, 0.1],\n fixed: {\n x: false,\n y: false,\n },\n font: {\n color: [\"color\", \"#343434\"],\n size: [14, 0, 100, 1], // px\n face: [\"arial\", \"verdana\", \"tahoma\"],\n background: [\"color\", \"none\"],\n strokeWidth: [0, 0, 50, 1], // px\n strokeColor: [\"color\", \"#ffffff\"],\n },\n //group: 'string',\n hidden: false,\n labelHighlightBold: true,\n //icon: {\n // face: 'string', //'FontAwesome',\n // code: 'string', //'\\uf007',\n // size: [50, 0, 200, 1], //50,\n // color: ['color','#2B7CE9'] //'#aa00ff'\n //},\n //image: 'string', // --> URL\n physics: true,\n scaling: {\n min: [10, 0, 200, 1],\n max: [30, 0, 200, 1],\n label: {\n enabled: false,\n min: [14, 0, 200, 1],\n max: [30, 0, 200, 1],\n maxVisible: [30, 0, 200, 1],\n drawThreshold: [5, 0, 20, 1],\n },\n },\n shadow: {\n enabled: false,\n color: \"rgba(0,0,0,0.5)\",\n size: [10, 0, 20, 1],\n x: [5, -30, 30, 1],\n y: [5, -30, 30, 1],\n },\n shape: [\n \"ellipse\",\n \"box\",\n \"circle\",\n \"database\",\n \"diamond\",\n \"dot\",\n \"square\",\n \"star\",\n \"text\",\n \"triangle\",\n \"triangleDown\",\n \"hexagon\",\n ],\n shapeProperties: {\n borderDashes: false,\n borderRadius: [6, 0, 20, 1],\n interpolation: true,\n useImageSize: false,\n },\n size: [25, 0, 200, 1],\n },\n edges: {\n arrows: {\n to: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: \"arrow\" },\n middle: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: \"arrow\" },\n from: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: \"arrow\" },\n },\n endPointOffset: {\n from: [0, -10, 10, 1],\n to: [0, -10, 10, 1],\n },\n arrowStrikethrough: true,\n color: {\n color: [\"color\", \"#848484\"],\n highlight: [\"color\", \"#848484\"],\n hover: [\"color\", \"#848484\"],\n inherit: [\"from\", \"to\", \"both\", true, false],\n opacity: [1, 0, 1, 0.05],\n },\n dashes: false,\n font: {\n color: [\"color\", \"#343434\"],\n size: [14, 0, 100, 1], // px\n face: [\"arial\", \"verdana\", \"tahoma\"],\n background: [\"color\", \"none\"],\n strokeWidth: [2, 0, 50, 1], // px\n strokeColor: [\"color\", \"#ffffff\"],\n align: [\"horizontal\", \"top\", \"middle\", \"bottom\"],\n },\n hidden: false,\n hoverWidth: [1.5, 0, 5, 0.1],\n labelHighlightBold: true,\n physics: true,\n scaling: {\n min: [1, 0, 100, 1],\n max: [15, 0, 100, 1],\n label: {\n enabled: true,\n min: [14, 0, 200, 1],\n max: [30, 0, 200, 1],\n maxVisible: [30, 0, 200, 1],\n drawThreshold: [5, 0, 20, 1],\n },\n },\n selectionWidth: [1.5, 0, 5, 0.1],\n selfReferenceSize: [20, 0, 200, 1],\n selfReference: {\n size: [20, 0, 200, 1],\n angle: [Math.PI / 2, -6 * Math.PI, 6 * Math.PI, Math.PI / 8],\n renderBehindTheNode: true,\n },\n shadow: {\n enabled: false,\n color: \"rgba(0,0,0,0.5)\",\n size: [10, 0, 20, 1],\n x: [5, -30, 30, 1],\n y: [5, -30, 30, 1],\n },\n smooth: {\n enabled: true,\n type: [\n \"dynamic\",\n \"continuous\",\n \"discrete\",\n \"diagonalCross\",\n \"straightCross\",\n \"horizontal\",\n \"vertical\",\n \"curvedCW\",\n \"curvedCCW\",\n \"cubicBezier\",\n ],\n forceDirection: [\"horizontal\", \"vertical\", \"none\"],\n roundness: [0.5, 0, 1, 0.05],\n },\n width: [1, 0, 30, 1],\n },\n layout: {\n //randomSeed: [0, 0, 500, 1],\n //improvedLayout: true,\n hierarchical: {\n enabled: false,\n levelSeparation: [150, 20, 500, 5],\n nodeSpacing: [100, 20, 500, 5],\n treeSpacing: [200, 20, 500, 5],\n blockShifting: true,\n edgeMinimization: true,\n parentCentralization: true,\n direction: [\"UD\", \"DU\", \"LR\", \"RL\"], // UD, DU, LR, RL\n sortMethod: [\"hubsize\", \"directed\"], // hubsize, directed\n shakeTowards: [\"leaves\", \"roots\"], // leaves, roots\n },\n },\n interaction: {\n dragNodes: true,\n dragView: true,\n hideEdgesOnDrag: false,\n hideEdgesOnZoom: false,\n hideNodesOnDrag: false,\n hover: false,\n keyboard: {\n enabled: false,\n speed: {\n x: [10, 0, 40, 1],\n y: [10, 0, 40, 1],\n zoom: [0.02, 0, 0.1, 0.005],\n },\n bindToWindow: true,\n autoFocus: true,\n },\n multiselect: false,\n navigationButtons: false,\n selectable: true,\n selectConnectedEdges: true,\n hoverConnectedEdges: true,\n tooltipDelay: [300, 0, 1000, 25],\n zoomView: true,\n zoomSpeed: [1, 0.1, 2, 0.1],\n },\n manipulation: {\n enabled: false,\n initiallyActive: false,\n },\n physics: {\n enabled: true,\n barnesHut: {\n theta: [0.5, 0.1, 1, 0.05],\n gravitationalConstant: [-2000, -30000, 0, 50],\n centralGravity: [0.3, 0, 10, 0.05],\n springLength: [95, 0, 500, 5],\n springConstant: [0.04, 0, 1.2, 0.005],\n damping: [0.09, 0, 1, 0.01],\n avoidOverlap: [0, 0, 1, 0.01],\n },\n forceAtlas2Based: {\n theta: [0.5, 0.1, 1, 0.05],\n gravitationalConstant: [-50, -500, 0, 1],\n centralGravity: [0.01, 0, 1, 0.005],\n springLength: [95, 0, 500, 5],\n springConstant: [0.08, 0, 1.2, 0.005],\n damping: [0.4, 0, 1, 0.01],\n avoidOverlap: [0, 0, 1, 0.01],\n },\n repulsion: {\n centralGravity: [0.2, 0, 10, 0.05],\n springLength: [200, 0, 500, 5],\n springConstant: [0.05, 0, 1.2, 0.005],\n nodeDistance: [100, 0, 500, 5],\n damping: [0.09, 0, 1, 0.01],\n },\n hierarchicalRepulsion: {\n centralGravity: [0.2, 0, 10, 0.05],\n springLength: [100, 0, 500, 5],\n springConstant: [0.01, 0, 1.2, 0.005],\n nodeDistance: [120, 0, 500, 5],\n damping: [0.09, 0, 1, 0.01],\n avoidOverlap: [0, 0, 1, 0.01],\n },\n maxVelocity: [50, 0, 150, 1],\n minVelocity: [0.1, 0.01, 0.5, 0.01],\n solver: [\n \"barnesHut\",\n \"forceAtlas2Based\",\n \"repulsion\",\n \"hierarchicalRepulsion\",\n ],\n timestep: [0.5, 0.01, 1, 0.01],\n wind: {\n x: [0, -10, 10, 0.1],\n y: [0, -10, 10, 0.1],\n },\n //adaptiveTimestep: true\n },\n} as const;\n\nexport const configuratorHideOption: ConfiguratorHideOption = (\n parentPath,\n optionName,\n options\n): boolean => {\n if (\n parentPath.includes(\"physics\") &&\n (configureOptions as any).physics.solver.includes(optionName) &&\n options.physics.solver !== optionName &&\n optionName !== \"wind\"\n ) {\n return true;\n }\n\n return false;\n};\n\nexport { allOptions, configureOptions };\n","/**\n * The Floyd–Warshall algorithm is an algorithm for finding shortest paths in\n * a weighted graph with positive or negative edge weights (but with no negative\n * cycles). - https://en.wikipedia.org/wiki/Floyd–Warshall_algorithm\n */\nclass FloydWarshall {\n /**\n * @ignore\n */\n constructor() {}\n\n /**\n *\n * @param {object} body\n * @param {Array.<Node>} nodesArray\n * @param {Array.<Edge>} edgesArray\n * @returns {{}}\n */\n getDistances(body, nodesArray, edgesArray) {\n const D_matrix = {};\n const edges = body.edges;\n\n // prepare matrix with large numbers\n for (let i = 0; i < nodesArray.length; i++) {\n const node = nodesArray[i];\n const cell = {};\n D_matrix[node] = cell;\n for (let j = 0; j < nodesArray.length; j++) {\n cell[nodesArray[j]] = i == j ? 0 : 1e9;\n }\n }\n\n // put the weights for the edges in. This assumes unidirectionality.\n for (let i = 0; i < edgesArray.length; i++) {\n const edge = edges[edgesArray[i]];\n // edge has to be connected if it counts to the distances. If it is connected to inner clusters it will crash so we also check if it is in the D_matrix\n if (\n edge.connected === true &&\n D_matrix[edge.fromId] !== undefined &&\n D_matrix[edge.toId] !== undefined\n ) {\n D_matrix[edge.fromId][edge.toId] = 1;\n D_matrix[edge.toId][edge.fromId] = 1;\n }\n }\n\n const nodeCount = nodesArray.length;\n\n // Adapted FloydWarshall based on unidirectionality to greatly reduce complexity.\n for (let k = 0; k < nodeCount; k++) {\n const knode = nodesArray[k];\n const kcolm = D_matrix[knode];\n for (let i = 0; i < nodeCount - 1; i++) {\n const inode = nodesArray[i];\n const icolm = D_matrix[inode];\n for (let j = i + 1; j < nodeCount; j++) {\n const jnode = nodesArray[j];\n const jcolm = D_matrix[jnode];\n\n const val = Math.min(icolm[jnode], icolm[knode] + kcolm[jnode]);\n icolm[jnode] = val;\n jcolm[inode] = val;\n }\n }\n }\n\n return D_matrix;\n }\n}\n\nexport default FloydWarshall;\n","// distance finding algorithm\nimport FloydWarshall from \"./components/algorithms/FloydWarshall.js\";\n\n/**\n * KamadaKawai positions the nodes initially based on\n *\n * \"AN ALGORITHM FOR DRAWING GENERAL UNDIRECTED GRAPHS\"\n * -- Tomihisa KAMADA and Satoru KAWAI in 1989\n *\n * Possible optimizations in the distance calculation can be implemented.\n */\nclass KamadaKawai {\n /**\n * @param {object} body\n * @param {number} edgeLength\n * @param {number} edgeStrength\n */\n constructor(body, edgeLength, edgeStrength) {\n this.body = body;\n this.springLength = edgeLength;\n this.springConstant = edgeStrength;\n this.distanceSolver = new FloydWarshall();\n }\n\n /**\n * Not sure if needed but can be used to update the spring length and spring constant\n *\n * @param {object} options\n */\n setOptions(options) {\n if (options) {\n if (options.springLength) {\n this.springLength = options.springLength;\n }\n if (options.springConstant) {\n this.springConstant = options.springConstant;\n }\n }\n }\n\n /**\n * Position the system\n *\n * @param {Array.<Node>} nodesArray\n * @param {Array.<vis.Edge>} edgesArray\n * @param {boolean} [ignoreClusters=false]\n */\n solve(nodesArray, edgesArray, ignoreClusters = false) {\n // get distance matrix\n const D_matrix = this.distanceSolver.getDistances(\n this.body,\n nodesArray,\n edgesArray\n ); // distance matrix\n\n // get the L Matrix\n this._createL_matrix(D_matrix);\n\n // get the K Matrix\n this._createK_matrix(D_matrix);\n\n // initial E Matrix\n this._createE_matrix();\n\n // calculate positions\n const threshold = 0.01;\n const innerThreshold = 1;\n let iterations = 0;\n const maxIterations = Math.max(\n 1000,\n Math.min(10 * this.body.nodeIndices.length, 6000)\n );\n const maxInnerIterations = 5;\n\n let maxEnergy = 1e9;\n let highE_nodeId = 0,\n dE_dx = 0,\n dE_dy = 0,\n delta_m = 0,\n subIterations = 0;\n\n while (maxEnergy > threshold && iterations < maxIterations) {\n iterations += 1;\n [highE_nodeId, maxEnergy, dE_dx, dE_dy] =\n this._getHighestEnergyNode(ignoreClusters);\n delta_m = maxEnergy;\n subIterations = 0;\n while (delta_m > innerThreshold && subIterations < maxInnerIterations) {\n subIterations += 1;\n this._moveNode(highE_nodeId, dE_dx, dE_dy);\n [delta_m, dE_dx, dE_dy] = this._getEnergy(highE_nodeId);\n }\n }\n }\n\n /**\n * get the node with the highest energy\n *\n * @param {boolean} ignoreClusters\n * @returns {number[]}\n * @private\n */\n _getHighestEnergyNode(ignoreClusters) {\n const nodesArray = this.body.nodeIndices;\n const nodes = this.body.nodes;\n let maxEnergy = 0;\n let maxEnergyNodeId = nodesArray[0];\n let dE_dx_max = 0,\n dE_dy_max = 0;\n\n for (let nodeIdx = 0; nodeIdx < nodesArray.length; nodeIdx++) {\n const m = nodesArray[nodeIdx];\n // by not evaluating nodes with predefined positions we should only move nodes that have no positions.\n if (\n nodes[m].predefinedPosition !== true ||\n (nodes[m].isCluster === true && ignoreClusters === true) ||\n nodes[m].options.fixed.x !== true ||\n nodes[m].options.fixed.y !== true\n ) {\n const [delta_m, dE_dx, dE_dy] = this._getEnergy(m);\n if (maxEnergy < delta_m) {\n maxEnergy = delta_m;\n maxEnergyNodeId = m;\n dE_dx_max = dE_dx;\n dE_dy_max = dE_dy;\n }\n }\n }\n\n return [maxEnergyNodeId, maxEnergy, dE_dx_max, dE_dy_max];\n }\n\n /**\n * calculate the energy of a single node\n *\n * @param {Node.id} m\n * @returns {number[]}\n * @private\n */\n _getEnergy(m) {\n const [dE_dx, dE_dy] = this.E_sums[m];\n const delta_m = Math.sqrt(dE_dx ** 2 + dE_dy ** 2);\n return [delta_m, dE_dx, dE_dy];\n }\n\n /**\n * move the node based on it's energy\n * the dx and dy are calculated from the linear system proposed by Kamada and Kawai\n *\n * @param {number} m\n * @param {number} dE_dx\n * @param {number} dE_dy\n * @private\n */\n _moveNode(m, dE_dx, dE_dy) {\n const nodesArray = this.body.nodeIndices;\n const nodes = this.body.nodes;\n let d2E_dx2 = 0;\n let d2E_dxdy = 0;\n let d2E_dy2 = 0;\n\n const x_m = nodes[m].x;\n const y_m = nodes[m].y;\n const km = this.K_matrix[m];\n const lm = this.L_matrix[m];\n\n for (let iIdx = 0; iIdx < nodesArray.length; iIdx++) {\n const i = nodesArray[iIdx];\n if (i !== m) {\n const x_i = nodes[i].x;\n const y_i = nodes[i].y;\n const kmat = km[i];\n const lmat = lm[i];\n const denominator = 1.0 / ((x_m - x_i) ** 2 + (y_m - y_i) ** 2) ** 1.5;\n d2E_dx2 += kmat * (1 - lmat * (y_m - y_i) ** 2 * denominator);\n d2E_dxdy += kmat * (lmat * (x_m - x_i) * (y_m - y_i) * denominator);\n d2E_dy2 += kmat * (1 - lmat * (x_m - x_i) ** 2 * denominator);\n }\n }\n // make the variable names easier to make the solving of the linear system easier to read\n const A = d2E_dx2,\n B = d2E_dxdy,\n C = dE_dx,\n D = d2E_dy2,\n E = dE_dy;\n\n // solve the linear system for dx and dy\n const dy = (C / A + E / B) / (B / A - D / B);\n const dx = -(B * dy + C) / A;\n\n // move the node\n nodes[m].x += dx;\n nodes[m].y += dy;\n\n // Recalculate E_matrix (should be incremental)\n this._updateE_matrix(m);\n }\n\n /**\n * Create the L matrix: edge length times shortest path\n *\n * @param {object} D_matrix\n * @private\n */\n _createL_matrix(D_matrix) {\n const nodesArray = this.body.nodeIndices;\n const edgeLength = this.springLength;\n\n this.L_matrix = [];\n for (let i = 0; i < nodesArray.length; i++) {\n this.L_matrix[nodesArray[i]] = {};\n for (let j = 0; j < nodesArray.length; j++) {\n this.L_matrix[nodesArray[i]][nodesArray[j]] =\n edgeLength * D_matrix[nodesArray[i]][nodesArray[j]];\n }\n }\n }\n\n /**\n * Create the K matrix: spring constants times shortest path\n *\n * @param {object} D_matrix\n * @private\n */\n _createK_matrix(D_matrix) {\n const nodesArray = this.body.nodeIndices;\n const edgeStrength = this.springConstant;\n\n this.K_matrix = [];\n for (let i = 0; i < nodesArray.length; i++) {\n this.K_matrix[nodesArray[i]] = {};\n for (let j = 0; j < nodesArray.length; j++) {\n this.K_matrix[nodesArray[i]][nodesArray[j]] =\n edgeStrength * D_matrix[nodesArray[i]][nodesArray[j]] ** -2;\n }\n }\n }\n\n /**\n * Create matrix with all energies between nodes\n *\n * @private\n */\n _createE_matrix() {\n const nodesArray = this.body.nodeIndices;\n const nodes = this.body.nodes;\n this.E_matrix = {};\n this.E_sums = {};\n for (let mIdx = 0; mIdx < nodesArray.length; mIdx++) {\n this.E_matrix[nodesArray[mIdx]] = [];\n }\n for (let mIdx = 0; mIdx < nodesArray.length; mIdx++) {\n const m = nodesArray[mIdx];\n const x_m = nodes[m].x;\n const y_m = nodes[m].y;\n let dE_dx = 0;\n let dE_dy = 0;\n for (let iIdx = mIdx; iIdx < nodesArray.length; iIdx++) {\n const i = nodesArray[iIdx];\n if (i !== m) {\n const x_i = nodes[i].x;\n const y_i = nodes[i].y;\n const denominator =\n 1.0 / Math.sqrt((x_m - x_i) ** 2 + (y_m - y_i) ** 2);\n this.E_matrix[m][iIdx] = [\n this.K_matrix[m][i] *\n (x_m - x_i - this.L_matrix[m][i] * (x_m - x_i) * denominator),\n this.K_matrix[m][i] *\n (y_m - y_i - this.L_matrix[m][i] * (y_m - y_i) * denominator),\n ];\n this.E_matrix[i][mIdx] = this.E_matrix[m][iIdx];\n dE_dx += this.E_matrix[m][iIdx][0];\n dE_dy += this.E_matrix[m][iIdx][1];\n }\n }\n //Store sum\n this.E_sums[m] = [dE_dx, dE_dy];\n }\n }\n\n /**\n * Update method, just doing single column (rows are auto-updated) (update all sums)\n *\n * @param {number} m\n * @private\n */\n _updateE_matrix(m) {\n const nodesArray = this.body.nodeIndices;\n const nodes = this.body.nodes;\n const colm = this.E_matrix[m];\n const kcolm = this.K_matrix[m];\n const lcolm = this.L_matrix[m];\n const x_m = nodes[m].x;\n const y_m = nodes[m].y;\n let dE_dx = 0;\n let dE_dy = 0;\n for (let iIdx = 0; iIdx < nodesArray.length; iIdx++) {\n const i = nodesArray[iIdx];\n if (i !== m) {\n //Keep old energy value for sum modification below\n const cell = colm[iIdx];\n const oldDx = cell[0];\n const oldDy = cell[1];\n\n //Calc new energy:\n const x_i = nodes[i].x;\n const y_i = nodes[i].y;\n const denominator =\n 1.0 / Math.sqrt((x_m - x_i) ** 2 + (y_m - y_i) ** 2);\n const dx =\n kcolm[i] * (x_m - x_i - lcolm[i] * (x_m - x_i) * denominator);\n const dy =\n kcolm[i] * (y_m - y_i - lcolm[i] * (y_m - y_i) * denominator);\n colm[iIdx] = [dx, dy];\n dE_dx += dx;\n dE_dy += dy;\n\n //add new energy to sum of each column\n const sum = this.E_sums[i];\n sum[0] += dx - oldDx;\n sum[1] += dy - oldDy;\n }\n }\n //Store sum at -1 index\n this.E_sums[m] = [dE_dx, dE_dy];\n }\n}\n\nexport default KamadaKawai;\n","// Load custom shapes into CanvasRenderingContext2D\nimport \"./shapes\";\n\nimport \"vis-util/esnext/styles/activator.css\";\nimport \"vis-util/esnext/styles/bootstrap.css\";\nimport \"vis-util/esnext/styles/color-picker.css\";\nimport \"vis-util/esnext/styles/configurator.css\";\nimport \"vis-util/esnext/styles/popup.css\";\n\nimport Emitter from \"component-emitter\";\nimport {\n Activator,\n Configurator,\n VALIDATOR_PRINT_STYLE,\n Validator,\n deepExtend,\n recursiveDOMDelete,\n selectiveDeepExtend,\n} from \"vis-util/esnext\";\nimport { DOTToGraph } from \"./dotparser\";\nimport { parseGephi } from \"./gephiParser\";\nimport * as locales from \"./locales\";\nimport { normalizeLanguageCode } from \"./locale-utils\";\n\nimport Images from \"./Images\";\nimport { Groups } from \"./modules/Groups\";\nimport NodesHandler from \"./modules/NodesHandler\";\nimport EdgesHandler from \"./modules/EdgesHandler\";\nimport PhysicsEngine from \"./modules/PhysicsEngine\";\nimport ClusterEngine from \"./modules/Clustering\";\nimport CanvasRenderer from \"./modules/CanvasRenderer\";\nimport Canvas from \"./modules/Canvas\";\nimport View from \"./modules/View\";\nimport InteractionHandler from \"./modules/InteractionHandler\";\nimport SelectionHandler from \"./modules/SelectionHandler\";\nimport LayoutEngine from \"./modules/LayoutEngine\";\nimport ManipulationSystem from \"./modules/ManipulationSystem\";\nimport {\n allOptions,\n configureOptions,\n configuratorHideOption,\n} from \"./options\";\nimport KamadaKawai from \"./modules/KamadaKawai.js\";\n\n/**\n * Create a network visualization, displaying nodes and edges.\n *\n * @param {Element} container The DOM element in which the Network will\n * be created. Normally a div element.\n * @param {object} data An object containing parameters\n * {Array} nodes\n * {Array} edges\n * @param {object} options Options\n * @class Network\n */\nexport function Network(container, data, options) {\n if (!(this instanceof Network)) {\n throw new SyntaxError(\"Constructor must be called with the new operator\");\n }\n\n // set constant values\n this.options = {};\n this.defaultOptions = {\n locale: \"en\",\n locales: locales,\n clickToUse: false,\n };\n Object.assign(this.options, this.defaultOptions);\n\n /**\n * Containers for nodes and edges.\n *\n * 'edges' and 'nodes' contain the full definitions of all the network elements.\n * 'nodeIndices' and 'edgeIndices' contain the id's of the active elements.\n *\n * The distinction is important, because a defined node need not be active, i.e.\n * visible on the canvas. This happens in particular when clusters are defined, in\n * that case there will be nodes and edges not displayed.\n * The bottom line is that all code with actions related to visibility, *must* use\n * 'nodeIndices' and 'edgeIndices', not 'nodes' and 'edges' directly.\n */\n this.body = {\n container: container,\n\n // See comment above for following fields\n nodes: {},\n nodeIndices: [],\n edges: {},\n edgeIndices: [],\n\n emitter: {\n on: this.on.bind(this),\n off: this.off.bind(this),\n emit: this.emit.bind(this),\n once: this.once.bind(this),\n },\n eventListeners: {\n onTap: function () {},\n onTouch: function () {},\n onDoubleTap: function () {},\n onHold: function () {},\n onDragStart: function () {},\n onDrag: function () {},\n onDragEnd: function () {},\n onMouseWheel: function () {},\n onPinch: function () {},\n onMouseMove: function () {},\n onRelease: function () {},\n onContext: function () {},\n },\n data: {\n nodes: null, // A DataSet or DataView\n edges: null, // A DataSet or DataView\n },\n functions: {\n createNode: function () {},\n createEdge: function () {},\n getPointer: function () {},\n },\n modules: {},\n view: {\n scale: 1,\n translation: { x: 0, y: 0 },\n },\n selectionBox: {\n show: false,\n position: {\n start: { x: 0, y: 0 },\n end: { x: 0, y: 0 },\n },\n },\n };\n\n // bind the event listeners\n this.bindEventListeners();\n\n // setting up all modules\n this.images = new Images(() => this.body.emitter.emit(\"_requestRedraw\")); // object with images\n this.groups = new Groups(); // object with groups\n this.canvas = new Canvas(this.body); // DOM handler\n this.selectionHandler = new SelectionHandler(this.body, this.canvas); // Selection handler\n this.interactionHandler = new InteractionHandler(\n this.body,\n this.canvas,\n this.selectionHandler\n ); // Interaction handler handles all the hammer bindings (that are bound by canvas), key\n this.view = new View(this.body, this.canvas); // camera handler, does animations and zooms\n this.renderer = new CanvasRenderer(this.body, this.canvas); // renderer, starts renderloop, has events that modules can hook into\n this.physics = new PhysicsEngine(this.body); // physics engine, does all the simulations\n this.layoutEngine = new LayoutEngine(this.body); // layout engine for inital layout and hierarchical layout\n this.clustering = new ClusterEngine(this.body); // clustering api\n this.manipulation = new ManipulationSystem(\n this.body,\n this.canvas,\n this.selectionHandler,\n this.interactionHandler\n ); // data manipulation system\n\n this.nodesHandler = new NodesHandler(\n this.body,\n this.images,\n this.groups,\n this.layoutEngine\n ); // Handle adding, deleting and updating of nodes as well as global options\n this.edgesHandler = new EdgesHandler(this.body, this.images, this.groups); // Handle adding, deleting and updating of edges as well as global options\n\n this.body.modules[\"kamadaKawai\"] = new KamadaKawai(this.body, 150, 0.05); // Layouting algorithm.\n this.body.modules[\"clustering\"] = this.clustering;\n\n // create the DOM elements\n this.canvas._create();\n\n // apply options\n this.setOptions(options);\n\n // load data (the disable start variable will be the same as the enabled clustering)\n this.setData(data);\n}\n\n// Extend Network with an Emitter mixin\nEmitter(Network.prototype);\n\n/**\n * Set options\n *\n * @param {object} options\n */\nNetwork.prototype.setOptions = function (options) {\n if (options === null) {\n options = undefined; // This ensures that options handling doesn't crash in the handling\n }\n\n if (options !== undefined) {\n const errorFound = Validator.validate(options, allOptions);\n if (errorFound === true) {\n console.error(\n \"%cErrors have been found in the supplied options object.\",\n VALIDATOR_PRINT_STYLE\n );\n }\n\n // copy the global fields over\n const fields = [\"locale\", \"locales\", \"clickToUse\"];\n selectiveDeepExtend(fields, this.options, options);\n\n // normalize the locale or use English\n if (options.locale !== undefined) {\n options.locale = normalizeLanguageCode(\n options.locales || this.options.locales,\n options.locale\n );\n }\n\n // the hierarchical system can adapt the edges and the physics to it's own options because not all combinations work with the hierarichical system.\n options = this.layoutEngine.setOptions(options.layout, options);\n\n this.canvas.setOptions(options); // options for canvas are in globals\n\n // pass the options to the modules\n this.groups.setOptions(options.groups);\n this.nodesHandler.setOptions(options.nodes);\n this.edgesHandler.setOptions(options.edges);\n this.physics.setOptions(options.physics);\n this.manipulation.setOptions(options.manipulation, options, this.options); // manipulation uses the locales in the globals\n\n this.interactionHandler.setOptions(options.interaction);\n this.renderer.setOptions(options.interaction); // options for rendering are in interaction\n this.selectionHandler.setOptions(options.interaction); // options for selection are in interaction\n\n // reload the settings of the nodes to apply changes in groups that are not referenced by pointer.\n if (options.groups !== undefined) {\n this.body.emitter.emit(\"refreshNodes\");\n }\n // these two do not have options at the moment, here for completeness\n //this.view.setOptions(options.view);\n //this.clustering.setOptions(options.clustering);\n\n if (\"configure\" in options) {\n if (!this.configurator) {\n this.configurator = new Configurator(\n this,\n this.body.container,\n configureOptions,\n this.canvas.pixelRatio,\n configuratorHideOption\n );\n }\n\n this.configurator.setOptions(options.configure);\n }\n\n // if the configuration system is enabled, copy all options and put them into the config system\n if (this.configurator && this.configurator.options.enabled === true) {\n const networkOptions = {\n nodes: {},\n edges: {},\n layout: {},\n interaction: {},\n manipulation: {},\n physics: {},\n global: {},\n };\n deepExtend(networkOptions.nodes, this.nodesHandler.options);\n deepExtend(networkOptions.edges, this.edgesHandler.options);\n deepExtend(networkOptions.layout, this.layoutEngine.options);\n // load the selectionHandler and render default options in to the interaction group\n deepExtend(networkOptions.interaction, this.selectionHandler.options);\n deepExtend(networkOptions.interaction, this.renderer.options);\n\n deepExtend(networkOptions.interaction, this.interactionHandler.options);\n deepExtend(networkOptions.manipulation, this.manipulation.options);\n deepExtend(networkOptions.physics, this.physics.options);\n\n // load globals into the global object\n deepExtend(networkOptions.global, this.canvas.options);\n deepExtend(networkOptions.global, this.options);\n\n this.configurator.setModuleOptions(networkOptions);\n }\n\n // handle network global options\n if (options.clickToUse !== undefined) {\n if (options.clickToUse === true) {\n if (this.activator === undefined) {\n this.activator = new Activator(this.canvas.frame);\n this.activator.on(\"change\", () => {\n this.body.emitter.emit(\"activate\");\n });\n }\n } else {\n if (this.activator !== undefined) {\n this.activator.destroy();\n delete this.activator;\n }\n this.body.emitter.emit(\"activate\");\n }\n } else {\n this.body.emitter.emit(\"activate\");\n }\n\n this.canvas.setSize();\n // start the physics simulation. Can be safely called multiple times.\n this.body.emitter.emit(\"startSimulation\");\n }\n};\n\n/**\n * Update the visible nodes and edges list with the most recent node state.\n *\n * Visible nodes are stored in this.body.nodeIndices.\n * Visible edges are stored in this.body.edgeIndices.\n * A node or edges is visible if it is not hidden or clustered.\n *\n * @private\n */\nNetwork.prototype._updateVisibleIndices = function () {\n const nodes = this.body.nodes;\n const edges = this.body.edges;\n this.body.nodeIndices = [];\n this.body.edgeIndices = [];\n\n for (const nodeId in nodes) {\n if (Object.prototype.hasOwnProperty.call(nodes, nodeId)) {\n if (\n !this.clustering._isClusteredNode(nodeId) &&\n nodes[nodeId].options.hidden === false\n ) {\n this.body.nodeIndices.push(nodes[nodeId].id);\n }\n }\n }\n\n for (const edgeId in edges) {\n if (Object.prototype.hasOwnProperty.call(edges, edgeId)) {\n const edge = edges[edgeId];\n\n // It can happen that this is executed *after* a node edge has been removed,\n // but *before* the edge itself has been removed. Taking this into account.\n const fromNode = nodes[edge.fromId];\n const toNode = nodes[edge.toId];\n const edgeNodesPresent = fromNode !== undefined && toNode !== undefined;\n\n const isVisible =\n !this.clustering._isClusteredEdge(edgeId) &&\n edge.options.hidden === false &&\n edgeNodesPresent &&\n fromNode.options.hidden === false && // Also hidden if any of its connecting nodes are hidden\n toNode.options.hidden === false; // idem\n\n if (isVisible) {\n this.body.edgeIndices.push(edge.id);\n }\n }\n }\n};\n\n/**\n * Bind all events\n */\nNetwork.prototype.bindEventListeners = function () {\n // This event will trigger a rebuilding of the cache everything.\n // Used when nodes or edges have been added or removed.\n this.body.emitter.on(\"_dataChanged\", () => {\n this.edgesHandler._updateState();\n this.body.emitter.emit(\"_dataUpdated\");\n });\n\n // this is called when options of EXISTING nodes or edges have changed.\n this.body.emitter.on(\"_dataUpdated\", () => {\n // Order important in following block\n this.clustering._updateState();\n this._updateVisibleIndices();\n\n this._updateValueRange(this.body.nodes);\n this._updateValueRange(this.body.edges);\n // start simulation (can be called safely, even if already running)\n this.body.emitter.emit(\"startSimulation\");\n this.body.emitter.emit(\"_requestRedraw\");\n });\n};\n\n/**\n * Set nodes and edges, and optionally options as well.\n *\n * @param {object} data Object containing parameters:\n * {Array | DataSet | DataView} [nodes] Array with nodes\n * {Array | DataSet | DataView} [edges] Array with edges\n * {String} [dot] String containing data in DOT format\n * {String} [gephi] String containing data in gephi JSON format\n * {Options} [options] Object with options\n */\nNetwork.prototype.setData = function (data) {\n // reset the physics engine.\n this.body.emitter.emit(\"resetPhysics\");\n this.body.emitter.emit(\"_resetData\");\n\n // unselect all to ensure no selections from old data are carried over.\n this.selectionHandler.unselectAll();\n\n if (data && data.dot && (data.nodes || data.edges)) {\n throw new SyntaxError(\n 'Data must contain either parameter \"dot\" or ' +\n ' parameter pair \"nodes\" and \"edges\", but not both.'\n );\n }\n\n // set options\n this.setOptions(data && data.options);\n // set all data\n if (data && data.dot) {\n console.warn(\n \"The dot property has been deprecated. Please use the static convertDot method to convert DOT into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertDot(dotString);\"\n );\n // parse DOT file\n const dotData = DOTToGraph(data.dot);\n this.setData(dotData);\n return;\n } else if (data && data.gephi) {\n // parse DOT file\n console.warn(\n \"The gephi property has been deprecated. Please use the static convertGephi method to convert gephi into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertGephi(gephiJson);\"\n );\n const gephiData = parseGephi(data.gephi);\n this.setData(gephiData);\n return;\n } else {\n this.nodesHandler.setData(data && data.nodes, true);\n this.edgesHandler.setData(data && data.edges, true);\n }\n\n // emit change in data\n this.body.emitter.emit(\"_dataChanged\");\n\n // emit data loaded\n this.body.emitter.emit(\"_dataLoaded\");\n\n // find a stable position or start animating to a stable position\n this.body.emitter.emit(\"initPhysics\");\n};\n\n/**\n * Cleans up all bindings of the network, removing it fully from the memory IF the variable is set to null after calling this function.\n * var network = new vis.Network(..);\n * network.destroy();\n * network = null;\n */\nNetwork.prototype.destroy = function () {\n this.body.emitter.emit(\"destroy\");\n // clear events\n this.body.emitter.off();\n this.off();\n\n // delete modules\n delete this.groups;\n delete this.canvas;\n delete this.selectionHandler;\n delete this.interactionHandler;\n delete this.view;\n delete this.renderer;\n delete this.physics;\n delete this.layoutEngine;\n delete this.clustering;\n delete this.manipulation;\n delete this.nodesHandler;\n delete this.edgesHandler;\n delete this.configurator;\n delete this.images;\n\n for (const nodeId in this.body.nodes) {\n if (!Object.prototype.hasOwnProperty.call(this.body.nodes, nodeId))\n continue;\n delete this.body.nodes[nodeId];\n }\n\n for (const edgeId in this.body.edges) {\n if (!Object.prototype.hasOwnProperty.call(this.body.edges, edgeId))\n continue;\n delete this.body.edges[edgeId];\n }\n\n // remove the container and everything inside it recursively\n recursiveDOMDelete(this.body.container);\n};\n\n/**\n * Update the values of all object in the given array according to the current\n * value range of the objects in the array.\n *\n * @param {object} obj An object containing a set of Edges or Nodes\n * The objects must have a method getValue() and\n * setValueRange(min, max).\n * @private\n */\nNetwork.prototype._updateValueRange = function (obj) {\n let id;\n\n // determine the range of the objects\n let valueMin = undefined;\n let valueMax = undefined;\n let valueTotal = 0;\n for (id in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, id)) {\n const value = obj[id].getValue();\n if (value !== undefined) {\n valueMin = valueMin === undefined ? value : Math.min(value, valueMin);\n valueMax = valueMax === undefined ? value : Math.max(value, valueMax);\n valueTotal += value;\n }\n }\n }\n\n // adjust the range of all objects\n if (valueMin !== undefined && valueMax !== undefined) {\n for (id in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, id)) {\n obj[id].setValueRange(valueMin, valueMax, valueTotal);\n }\n }\n }\n};\n\n/**\n * Returns true when the Network is active.\n *\n * @returns {boolean}\n */\nNetwork.prototype.isActive = function () {\n return !this.activator || this.activator.active;\n};\n\nNetwork.prototype.setSize = function () {\n return this.canvas.setSize.apply(this.canvas, arguments);\n};\nNetwork.prototype.canvasToDOM = function () {\n return this.canvas.canvasToDOM.apply(this.canvas, arguments);\n};\nNetwork.prototype.DOMtoCanvas = function () {\n return this.canvas.DOMtoCanvas.apply(this.canvas, arguments);\n};\n\n/**\n * Nodes can be in clusters. Clusters can also be in clusters. This function returns and array of\n * nodeIds showing where the node is.\n *\n * If any nodeId in the chain, especially the first passed in as a parameter, is not present in\n * the current nodes list, an empty array is returned.\n *\n * Example:\n * cluster 'A' contains cluster 'B',\n * cluster 'B' contains cluster 'C',\n * cluster 'C' contains node 'fred'.\n * `jsnetwork.clustering.findNode('fred')` will return `['A','B','C','fred']`.\n *\n * @param {string|number} nodeId\n * @returns {Array}\n */\nNetwork.prototype.findNode = function () {\n return this.clustering.findNode.apply(this.clustering, arguments);\n};\n\nNetwork.prototype.isCluster = function () {\n return this.clustering.isCluster.apply(this.clustering, arguments);\n};\nNetwork.prototype.openCluster = function () {\n return this.clustering.openCluster.apply(this.clustering, arguments);\n};\nNetwork.prototype.cluster = function () {\n return this.clustering.cluster.apply(this.clustering, arguments);\n};\nNetwork.prototype.getNodesInCluster = function () {\n return this.clustering.getNodesInCluster.apply(this.clustering, arguments);\n};\nNetwork.prototype.clusterByConnection = function () {\n return this.clustering.clusterByConnection.apply(this.clustering, arguments);\n};\nNetwork.prototype.clusterByHubsize = function () {\n return this.clustering.clusterByHubsize.apply(this.clustering, arguments);\n};\nNetwork.prototype.updateClusteredNode = function () {\n return this.clustering.updateClusteredNode.apply(this.clustering, arguments);\n};\nNetwork.prototype.getClusteredEdges = function () {\n return this.clustering.getClusteredEdges.apply(this.clustering, arguments);\n};\nNetwork.prototype.getBaseEdge = function () {\n return this.clustering.getBaseEdge.apply(this.clustering, arguments);\n};\nNetwork.prototype.getBaseEdges = function () {\n return this.clustering.getBaseEdges.apply(this.clustering, arguments);\n};\nNetwork.prototype.updateEdge = function () {\n return this.clustering.updateEdge.apply(this.clustering, arguments);\n};\n\n/**\n * This method will cluster all nodes with 1 edge with their respective connected node.\n * The options object is explained in full <a data-scroll=\"\" data-options=\"{ &quot;easing&quot;: &quot;easeInCubic&quot; }\" href=\"#optionsObject\">below</a>.\n *\n * @param {object} [options]\n * @returns {undefined}\n */\nNetwork.prototype.clusterOutliers = function () {\n return this.clustering.clusterOutliers.apply(this.clustering, arguments);\n};\n\nNetwork.prototype.getSeed = function () {\n return this.layoutEngine.getSeed.apply(this.layoutEngine, arguments);\n};\nNetwork.prototype.enableEditMode = function () {\n return this.manipulation.enableEditMode.apply(this.manipulation, arguments);\n};\nNetwork.prototype.disableEditMode = function () {\n return this.manipulation.disableEditMode.apply(this.manipulation, arguments);\n};\nNetwork.prototype.addNodeMode = function () {\n return this.manipulation.addNodeMode.apply(this.manipulation, arguments);\n};\nNetwork.prototype.editNode = function () {\n return this.manipulation.editNode.apply(this.manipulation, arguments);\n};\nNetwork.prototype.editNodeMode = function () {\n console.warn(\"Deprecated: Please use editNode instead of editNodeMode.\");\n return this.manipulation.editNode.apply(this.manipulation, arguments);\n};\nNetwork.prototype.addEdgeMode = function () {\n return this.manipulation.addEdgeMode.apply(this.manipulation, arguments);\n};\nNetwork.prototype.editEdgeMode = function () {\n return this.manipulation.editEdgeMode.apply(this.manipulation, arguments);\n};\nNetwork.prototype.deleteSelected = function () {\n return this.manipulation.deleteSelected.apply(this.manipulation, arguments);\n};\nNetwork.prototype.getPositions = function () {\n return this.nodesHandler.getPositions.apply(this.nodesHandler, arguments);\n};\nNetwork.prototype.getPosition = function () {\n return this.nodesHandler.getPosition.apply(this.nodesHandler, arguments);\n};\nNetwork.prototype.storePositions = function () {\n return this.nodesHandler.storePositions.apply(this.nodesHandler, arguments);\n};\nNetwork.prototype.moveNode = function () {\n return this.nodesHandler.moveNode.apply(this.nodesHandler, arguments);\n};\nNetwork.prototype.getBoundingBox = function () {\n return this.nodesHandler.getBoundingBox.apply(this.nodesHandler, arguments);\n};\nNetwork.prototype.getConnectedNodes = function (objectId) {\n if (this.body.nodes[objectId] !== undefined) {\n return this.nodesHandler.getConnectedNodes.apply(\n this.nodesHandler,\n arguments\n );\n } else {\n return this.edgesHandler.getConnectedNodes.apply(\n this.edgesHandler,\n arguments\n );\n }\n};\nNetwork.prototype.getConnectedEdges = function () {\n return this.nodesHandler.getConnectedEdges.apply(\n this.nodesHandler,\n arguments\n );\n};\nNetwork.prototype.startSimulation = function () {\n return this.physics.startSimulation.apply(this.physics, arguments);\n};\nNetwork.prototype.stopSimulation = function () {\n return this.physics.stopSimulation.apply(this.physics, arguments);\n};\nNetwork.prototype.stabilize = function () {\n return this.physics.stabilize.apply(this.physics, arguments);\n};\nNetwork.prototype.getSelection = function () {\n return this.selectionHandler.getSelection.apply(\n this.selectionHandler,\n arguments\n );\n};\nNetwork.prototype.setSelection = function () {\n return this.selectionHandler.setSelection.apply(\n this.selectionHandler,\n arguments\n );\n};\nNetwork.prototype.getSelectedNodes = function () {\n return this.selectionHandler.getSelectedNodeIds.apply(\n this.selectionHandler,\n arguments\n );\n};\nNetwork.prototype.getSelectedEdges = function () {\n return this.selectionHandler.getSelectedEdgeIds.apply(\n this.selectionHandler,\n arguments\n );\n};\nNetwork.prototype.getNodeAt = function () {\n const node = this.selectionHandler.getNodeAt.apply(\n this.selectionHandler,\n arguments\n );\n if (node !== undefined && node.id !== undefined) {\n return node.id;\n }\n return node;\n};\nNetwork.prototype.getEdgeAt = function () {\n const edge = this.selectionHandler.getEdgeAt.apply(\n this.selectionHandler,\n arguments\n );\n if (edge !== undefined && edge.id !== undefined) {\n return edge.id;\n }\n return edge;\n};\nNetwork.prototype.selectNodes = function () {\n return this.selectionHandler.selectNodes.apply(\n this.selectionHandler,\n arguments\n );\n};\nNetwork.prototype.selectEdges = function () {\n return this.selectionHandler.selectEdges.apply(\n this.selectionHandler,\n arguments\n );\n};\nNetwork.prototype.unselectAll = function () {\n this.selectionHandler.unselectAll.apply(this.selectionHandler, arguments);\n this.selectionHandler.commitWithoutEmitting.apply(this.selectionHandler);\n this.redraw();\n};\nNetwork.prototype.redraw = function () {\n return this.renderer.redraw.apply(this.renderer, arguments);\n};\nNetwork.prototype.getScale = function () {\n return this.view.getScale.apply(this.view, arguments);\n};\nNetwork.prototype.getViewPosition = function () {\n return this.view.getViewPosition.apply(this.view, arguments);\n};\nNetwork.prototype.fit = function () {\n return this.view.fit.apply(this.view, arguments);\n};\nNetwork.prototype.moveTo = function () {\n return this.view.moveTo.apply(this.view, arguments);\n};\nNetwork.prototype.focus = function () {\n return this.view.focus.apply(this.view, arguments);\n};\nNetwork.prototype.releaseNode = function () {\n return this.view.releaseNode.apply(this.view, arguments);\n};\nNetwork.prototype.getOptionsFromConfigurator = function () {\n let options = {};\n if (this.configurator) {\n options = this.configurator.getOptions.apply(this.configurator);\n }\n return options;\n};\n\nexport default Network;\n","/**\n * Normalizes language code into the format used internally.\n *\n * @param locales - All the available locales.\n * @param rawCode - The original code as supplied by the user.\n *\n * @returns Language code in the format language-COUNTRY or language, eventually\n * fallbacks to en.\n */\nexport function normalizeLanguageCode(\n locales: Record<string, undefined | object>,\n rawCode: string\n): string {\n try {\n const [rawLanguage, rawCountry] = rawCode.split(/[-_ /]/, 2);\n const language = rawLanguage != null ? rawLanguage.toLowerCase() : null;\n const country = rawCountry != null ? rawCountry.toUpperCase() : null;\n\n if (language && country) {\n const code = language + \"-\" + country;\n if (Object.prototype.hasOwnProperty.call(locales, code)) {\n return code;\n } else {\n console.warn(`Unknown variant ${country} of language ${language}.`);\n }\n }\n\n if (language) {\n const code = language;\n if (Object.prototype.hasOwnProperty.call(locales, code)) {\n return code;\n } else {\n console.warn(`Unknown language ${language}`);\n }\n }\n\n console.warn(`Unknown locale ${rawCode}, falling back to English.`);\n\n return \"en\";\n } catch (error) {\n console.error(error);\n console.warn(\n `Unexpected error while normalizing locale ${rawCode}, falling back to English.`\n );\n\n return \"en\";\n }\n}\n","export * from \"./network/Network\";\n\nexport { default as NetworkImages } from \"./network/Images\";\n\nimport * as dotparser from \"./network/dotparser\";\nexport { dotparser as networkDOTParser };\nexport const parseDOTNetwork = dotparser.DOTToGraph;\n\nimport * as gephiParser from \"./network/gephiParser\";\nexport { parseGephi as parseGephiNetwork } from \"./network/gephiParser\";\nexport { gephiParser as networkGephiParser };\n\nimport * as allOptions from \"./network/options\";\nexport { allOptions as networkOptions };\n\n// DataSet, utils etc. can't be reexported here because that would cause stack\n// overflow in UMD builds. They all export vis namespace therefore reexporting\n// leads to loading vis to load vis to load vis…\n"],"names":["drawCircle","ctx","x","y","r","beginPath","arc","Math","PI","closePath","drawRoundRect","w","h","r2d","moveTo","lineTo","drawEllipse","kappa","ox","oy","xe","ye","xm","ym","bezierCurveTo","drawDatabase","hEllipse","ymb","yeb","drawDashedLine","x2","y2","pattern","patternLength","length","dx","dy","slope","distRemaining","sqrt","patternIndex","draw","xStep","dashLength","shapeMap","circle","dashedLine","database","diamond","ellipse","ellipse_vis","hexagon","a","i","cos","sin","roundRect","square","rect","star","n","radius","triangle","s","s2","ir","triangleDown","parseDOT","data","dot","graph","index","c","charAt","getToken","token","strict","type","tokenType","TOKENTYPE","id","newSyntaxError","parseStatements","node","edge","parseGraph","NODE_ATTR_MAPPING","fontsize","fontcolor","labelfontcolor","fontname","color","fillcolor","tooltip","labeltooltip","EDGE_ATTR_MAPPING","Object","create","style","DELIMITERS","next","nextPreview","isAlphaNumeric","charCode","charCodeAt","merge","b","name","hasOwnProperty","setValue","obj","path","value","keys","split","o","key","shift","addNode","len","current","graphs","root","parent","push","nodes","attr","g","indexOf","addEdge","edges","createEdge","from","to","enabled","arrows","isComment","c2","isNaN","Number","SyntaxError","chop","parseStatement","subgraph","parseSubgraph","parseEdge","parseAttributeList","parseAttributeStatement","parseNodeStatement","subgraphs","nof_attr_list","edgeStyles","dashed","solid","dotted","arrowTypes","box","crow","curve","icurve","normal","inv","tee","vee","attr_list","Array","attr_names","includes","idx","dir","from_type","to_type","dir_type","splice","idx_arrow","tmp_attr_list","message","text","maxLength","substr","setProp","object","names","prop","pop","convertAttr","mapping","converted","visProp","isArray","forEach","visPropI","DOTToGraph","dotData","graphData","options","dotNode","graphNode","label","String","image","shape","convertEdge","dotEdge","graphEdge","array1","array2","fn","subEdge","elem1","elem2","parseGephi","gephiJSON","optionsObj","inheritColor","fixed","parseColor","vEdges","map","gEdge","vEdge","source","target","attributes","title","gNode","vNode","size","background","border","highlight","hover","addDescription","back","close","createEdgeError","del","deleteClusterError","edgeDescription","edit","editClusterError","editEdge","editEdgeDescription","editNode","CachedImage","constructor","this","NUM_ITERATIONS","Image","canvas","document","createElement","init","initialized","src","width","height","h2","floor","h4","h8","h16","w2","w4","w8","w16","coordinates","_fillMipMap","undefined","getContext","drawImage","iterations","drawImageAtPosition","factor","left","top","Images","callback","images","imageBroken","_tryloadBrokenUrl","url","brokenUrl","imageToLoadBrokenUrlOn","onerror","console","error","warn","_redrawWithImage","imageToRedrawWith","load","cachedImage","img","onload","_fixImageCoordinates","imageToCache","body","appendChild","offsetWidth","offsetHeight","removeChild","Groups","clear","_defaultIndex","_groupIndex","_defaultGroups","defaultOptions","useDefaultGroups","assign","setOptions","optionFields","groupName","prototype","call","group","add","_groups","Map","_groupNames","get","groupname","shouldCreate","set","has","choosify","subOption","pile","allowed","chosen","topMost","Error","join","chosenEdge","pointInRect","point","rotationPoint","tmp","angle","right","bottom","isValidLabel","getSelfRefCoordinates","distanceToBorder","toBorderDist","yFromNodeCenter","xFromNodeCenter","LabelAccumulator","measureText","lines","_add","l","mod","blocks","tmpText","result","block","values","curWidth","line","append","newLine","determineLineHeights","k","determineLabelSize","removeEmptyBlocks","tmpLines","tmpLine","firstEmptyBlock","tmpBlocks","finalize","tagPattern","_","afterBold","afterItal","afterMono","MarkupAccumulator","bold","ital","mono","spacing","position","buffer","modStack","modName","emitBlock","parseWS","ch","test","setTag","tagName","unshift","unsetTag","parseStartTag","tag","match","advance","regExp","prepareRegExp","matched","parseEndTag","nextTag","checkTag","replace","RegExp","prepared","LabelSplitter","selected","getFormattingValues","process","font","fontOptions","nlLines","lineCount","multi","splitBlocks","maxWdt","j","splitStringIntoLines","decodeMarkupSystem","markupSystem","system","splitHtmlBlocks","parseEntities","splitMarkdownBlocks","beginable","parseOverride","overMaxWidth","getLongestFit","words","newText","getLongestFitWord","slice","str","appendLast","word","newW","multiFontStyle","Label","edgelabel","pointToSelf","baseSize","yLine","isEdgeLabel","elementOptions","initFontOptions","labelDirty","newFontOptions","parseFontString","vadjust","outOptions","inOptions","newOptionsArray","face","constrain","constrainWidth","minWdt","constrainHeight","minHgt","valign","widthConstraint","widthConstraintMaximum","widthConstraintMinimum","heightConstraint","heightConstraintMinimum","heightConstraintValign","update","propagateFonts","deepExtend","chooser","adjustSizes","margins","widthBias","heightBias","addFontOptionsToPile","dstPile","srcPile","addFontToPile","item","getBasicOptions","ret","tmpShorthand","opt","getFontOption","multiName","option","multiFont","getFontOptions","optionNames","fontPile","modOptions","tmpMultiFontOptions","baseline","viewFontSize","view","scale","scaling","drawThreshold","maxVisible","calculateLabelSize","_drawBackground","_drawText","fillStyle","getSize","fillRect","_setAlignment","textAlign","labelHeight","align","fontColor","strokeColor","_getColor","strokeWidth","lineWidth","strokeStyle","lineJoin","strokeText","fillText","lineMargin","textBaseline","initialStrokeColor","opacity","max","min","overrideOpacity","getTextSize","_processLabel","getValue","labelHighlightBold","fontString","differentState","selectedState","hoverState","_processLabelText","inText","state","visible","NodeBase","labelModule","margin","refreshNeeded","boundingBox","_setMargins","_distanceToBorder","borderWidth","resize","abs","enableShadow","shadow","shadowColor","shadowBlur","shadowSize","shadowOffsetX","shadowX","shadowOffsetY","shadowY","disableShadow","enableBorderDashes","borderDashes","setLineDash","dashes","shapeProperties","disableBorderDashes","needsRefresh","initContextForDraw","borderColor","performStroke","save","stroke","restore","performFill","fill","_addBoundingBoxMargin","_updateBoundingBox","updateBoundingBox","getDimensionsFromLabel","textSize","Box","super","dimensions","borderRadius","CircleImageBase","labelOffset","imageObj","imageObjAlt","setImages","switchImages","selection_changed","imageTmp","_getImagePadding","imgPadding","imagePadding","optImgPadding","_resizeImage","useImageSize","ratio_width","ratio_height","_drawRawCircle","_drawImageAtPosition","globalAlpha","interpolation","imgPosLeft","imgPosTop","imgWidth","imgHeight","_drawImageLabel","offset","labelDimensions","yLabel","Circle","diameter","CircularImage","labelX","labelY","coordinateOrigin","clip","ShapeBase","customSizeWidth","customSizeHeight","_drawShape","sizeMultiplier","args","CanvasRenderingContext2D","icon","code","drawExternalLabel","CustomShape","ctxRenderer","drawLater","drawNode","nodeDimensions","Database","Diamond","Dot","Ellipse","Icon","iconSize","_icon","iconTextSpacing","weight","side","useBorderWithImage","neutralborderWidth","selectionLineWidth","borderWidthSelected","Square","Hexagon","Star","Text","Triangle","TriangleDown","Node","imagelist","grouplist","globalOptions","bridgeObject","baseFontSize","predefinedPosition","attachEdge","detachEdge","currentShape","_localColor","checkMass","parseInt","parseFloat","parseOptions","_load_images","updateLabelModule","checkOpacity","updateShape","hidden","physics","brokenImage","unselected","checkCoordinateOrigin","origin","updateGroupOptions","parentOptions","newOptions","groupList","groupObj","skipProperties","getOwnPropertyNames","filter","p","selectiveNotDeepExtend","allowDeletion","mergeOptions","parsedColor","fillIfDefined","currentGroup","select","unselect","getTitle","isFixed","isSelected","getLabelSize","setValueRange","total","customScalingFunction","sizeDiff","fontDiff","getItemsOnPoint","nodeId","labelId","isOverlappingWith","isBoundingBoxOverlappingWith","mass","strId","VALIDATOR_PRINT_STYLE","NodesHandler","groups","layoutEngine","functions","createNode","bind","nodesListeners","event","params","items","oldData","remove","boldital","level","bindEventListeners","emitter","on","refresh","off","isFinite","emit","setData","doNotEmit","oldNodesData","isDataViewLike","DataSet","TypeError","me","ids","getIds","newNodes","properties","positionInitially","changedData","dataChanged","some","newValue","oldValue","constructorClass","clearPositions","getPositions","dataArray","round","nodeIndices","getPosition","ReferenceError","storePositions","dataset","getDataSet","dsNode","bodyNode","getBoundingBox","getConnectedNodes","direction","nodeList","nodeObj","toId","fromId","getConnectedEdges","edgeList","moveNode","setTimeout","EndPoint","transform","points","arrowData","xt","yt","drawPath","translate","rotate","imageWidth","imageHeight","Arrow","EndPoints","toLowerCase","pi","startAngle","endAngle","EdgeBase","_body","_labelModule","fromPoint","toPoint","connect","cleanup","drawLine","_selected","_hover","viaNode","getViaNode","getColor","_drawDashedLine","_drawLine","_line","_getCircleData","_circle","_fromPoint","_toPoint","lineCap","lineDashOffset","findBorderPosition","_findBorderPosition","_findBorderPositionCircle","findBorderPositions","low","high","selfReference","_pointOnCircle","nearNode","pos","middle","endPointOffset","arrowStrikethrough","iteration","atan2","difference","pow","t","getLineWidth","selectionWidth","hoverWidth","inheritsColor","grd","createLinearGradient","fromColor","toColor","addColorStop","angleFrom","angleTo","renderBehindTheNode","pointTFrom","pointTTo","getDistanceToEdge","x1","y1","x3","y3","_getDistanceToEdge","_getDistanceToLine","px","py","u","getArrowData","arrowPoint","node1","node2","reversed","scaleFactor","fromArrowScale","fromArrowType","toArrowScale","toArrowType","middleArrowScale","middleArrowType","relativeLength","hypot","smooth","pointT","via","guidePos","getPoint","halfLength","guidePos1","guidePos2","core","drawArrowHead","drawBackground","origCtxAttr","backgroundColor","backgroundSize","setStrokeDashed","backgroundDashes","BezierEdgeBase","_findBorderPositionBezier","_getViaCoordinates","_getDistanceToBezierEdge","distance","minDistance","lastX","lastY","_bezierCurve","viaNode1","viaNode2","quadraticCurveTo","BezierEdgeDynamic","_boundFunction","positionBezierNode","physicsChange","setupSupportNode","parentEdgeId","cx","cy","cr","BezierEdgeStatic","roundness","stepX","stepY","xVia","yVia","myAngle","CubicBezierEdgeBase","_getDistanceToBezierEdge2","via1","via2","vec","CubicBezierEdge","viaNodes","forceDirection","StraightEdge","edgeSegmentLength","toBorderPoint","Edge","baseWidth","edgeType","connected","affectsLayout","updateEdgeType","_setInteractionWidths","copyFromGlobals","selectiveDeepExtend","JSON","stringify","isString","inherit","colorsDefined","selfReferenceSize","toArrow","fromArrow","middleArrow","toArrowSrc","toArrowImageWidth","toArrowImageHeight","middleArrowSrc","middleArrowImageWidth","middleArrowImageHeight","fromArrowSrc","fromArrowImageWidth","fromArrowImageHeight","selectedWidth","changeInType","disconnect","widthDiff","drawLabel","drawArrows","_getRotation","edgeId","distMax","xFrom","yFrom","xTo","yTo","xObj","yObj","endPointsValid","EdgesHandler","edgesListeners","edgeData","smoothOptions","reconnectEdges","oldEdgesData","edgesData","oldEdge","showInternalIds","_updateState","_addMissingEdges","_removeInvalidEdges","edgesToDelete","toNode","fromNode","isCluster","addIds","BarnesHutSolver","physicsBody","barnesHutTree","_rng","Alea","thetaInversed","theta","overlapAvoidanceFactor","avoidOverlap","solve","gravitationalConstant","physicsNodeIndices","nodeCount","_formBarnesHutTree","_getForceContributions","parentBranch","_getForceContribution","children","NW","NE","SW","SE","childrenCount","centerOfMass","calcSize","_calculateForces","gravityForce","fx","fy","forces","minX","minY","maxX","maxY","rootSize","halfRootSize","centerX","centerY","range","maxWidth","_splitBranch","_placeInTree","_updateBranchMass","totalMass","totalMassInv","biggestSize","skipMassUpdate","region","_placeInRegion","containedNode","_insertRegion","childSize","_debug","_drawBranch","branch","RepulsionSolver","repulsingForce","nodeDistance","HierarchicalRepulsionSolver","theseNodesDistance","steepness","SpringSolver","edgeLength","edgeIndices","physicsEdgeIndices","node3","springLength","_calculateSpringForce","springForce","springConstant","HierarchicalSpringSolver","springFx","springFy","totalFx","totalFy","correctionFx","correctionFy","CentralGravitySolver","centralGravity","ForceAtlas2BasedRepulsionSolver","degree","ForceAtlas2BasedCentralGravitySolver","PhysicsEngine","velocities","physicsEnabled","simulationInterval","requiresTimeout","previousStates","referenceState","freezeCache","renderTimer","adaptiveTimestep","adaptiveTimestepEnabled","adaptiveCounter","adaptiveInterval","stabilized","startedStabilization","stabilizationIterations","ready","barnesHut","damping","forceAtlas2Based","repulsion","hierarchicalRepulsion","maxVelocity","minVelocity","solver","stabilization","updateInterval","onlyDynamicEdges","fit","timestep","wind","layoutFailed","initPhysics","stopSimulation","startSimulation","updatePhysicsData","nodesSolver","edgesSolver","gravitySolver","Repulsion","HierarchicalRepulsion","modelOptions","stabilize","viewFunction","simulationStep","_emitStabilized","startTime","Date","now","physicsTick","runDoubleSpeed","amountOfIterations","physicsStep","moveNodes","adjustTimeStep","_evaluateStepQuality","_startStabilizing","revert","nodeIds","positions","vx","vy","dpos","reference","maxNodeVelocity","averageNodeVelocity","nodeVelocity","_performStep","calculateComponentVelocity","v","f","m","maxV","force","velocity","_freezeNodes","_restoreFrozenNodes","targetIterations","_stabilizationBatch","running","sendProgress","count","_finalizeStabilization","_drawForces","colorFactor","forceSize","arrowSize","HSVToHex","NetworkUtil","getRange","allNodes","specificNodes","getRangeCore","findCenter","cloneOptions","clonedOptions","amountOfConnections","Cluster","containedNodes","containedEdges","_openChildCluster","childClusterId","childCluster","clusterEdge","parentClusterEdge","clusteringEdgeReplacingIds","srcId","edgeReplacedById","ClusterEngine","clusteredNodes","clusteredEdges","clusterByHubsize","hubsize","_getHubSize","_checkOptions","nodesToCluster","clusterByConnection","cluster","refreshData","joinCondition","childNodesObj","childEdgesObj","_cluster","clusterByEdgeCount","edgeCount","clusters","usedNodes","relevantEdgeCount","checkJoinCondition","gatheringSuccessful","childNodeId","_getConnectedId","foundCluster","findClusterData","clusterOutliers","clusterBridges","clusterNodeProperties","parentNodeId","parentClonedOptions","childClonedOptions","childNodeIDs","childNode","childNodeKey","childEdge","_createClusterEdges","clusterEdgeProperties","otherNodeId","childKeys","createEdges","newEdges","getNewEdge","createdEdge","newEdge","matchToDirection","matchFromDirection","_createClusteredEdge","_backupEdgeOptions","tmpNodesToRemove","allowSingleNodeCluster","processProperties","childNodesOptions","childEdgesOptions","randomUUID","clusterId","_getClusterPosition","clusterNode","_clusterEdges","_restoreEdge","originalOptions","openCluster","clusterNodeId","stack","findNode","parentIndex","parentClusterNodeId","releaseFunction","clusterPosition","newPositions","edgesToBeDeleted","otherNode","transferId","transferEdge","otherCluster","getNodesInCluster","nodesArray","counter","reverse","updateClusteredNode","clusteredNodeId","updateEdge","startEdgeId","allEdgeIds","getClusteredEdges","getBaseEdge","clusteredEdgeId","getBaseEdges","IdsToHandle","doneIds","foundIds","nextId","nextEdge","replacingIds","replacingId","average","averageSquared","hubCounter","largestHub","variance","standardDeviation","hubThreshold","baseEdge","extraOptions","childNodes","childEdges","_getClusterNodeForNode","clusteredNode","_filter","arr","deletedNodeIds","deletedEdgeIds","eachClusterNode","isValid","replacedIds","numValid","containedEdgeId","containedEdge","deletedEdgeId","shouldBeClustered","_isClusteredNode","_isClusteredEdge","clusterFrom","clusterTo","changed","continueLoop","clustersToOpen","numNodes","allowSingle","CanvasRenderer","func","window","requestAnimationFrame","mozRequestAnimationFrame","webkitRequestAnimationFrame","msRequestAnimationFrame","_initRequestAnimationFrame","redrawRequested","renderingActive","renderRequests","allowRedraw","dragging","zooming","hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag","_determineBrowserMethod","clearTimeout","zoomTimeoutId","_requestRedraw","_resizeNodes","_redraw","_startRendering","cancelAnimationFrame","_requestNextFrame","delay","timer","myWindow","_renderStep","redraw","drawExternalLabels","frame","setSize","setTransform","clientWidth","clientHeight","clearRect","translation","_drawEdges","_drawNodes","_drawArrows","_drawSelectionBox","alwaysShow","hovered","topLeft","DOMtoCanvas","bottomRight","viewableArea","selectedLength","hoveredLength","browserType","navigator","userAgent","selectionBox","show","end","start","onTouch","hammer","inputHandler","isFirst","onRelease","isFinal","Canvas","pixelRatio","cameraState","canvasViewCenter","_cleanupCallbacks","autoResize","once","hammerFrame","destroy","_cleanUp","ResizeObserver","observer","observe","unobserve","resizeTimer","setInterval","clearInterval","resizeFunction","_onResize","addEventListener","removeEventListener","_getCameraState","previousWidth","previousHeight","_setCameraState","widthRatio","heightRatio","newScale","currentViewCenter","distanceFromCenter","_prepareValue","_create","container","hasChildNodes","firstChild","className","overflow","tabIndex","_setPixelRatio","noCanvas","fontWeight","padding","innerText","_bindHammer","drag","pinch","Hammer","enable","threshold","DIRECTION_ALL","eventListeners","onTap","onDoubleTap","onHold","onDragStart","onDrag","onDragEnd","onPinch","onMouseWheel","onMouseMove","onContext","emitEvent","oldWidth","oldHeight","previousRatio","newWidth","newHeight","_determinePixelRatio","numerator","devicePixelRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","_XconvertDOMtoCanvas","_XconvertCanvasToDOM","_YconvertDOMtoCanvas","_YconvertCanvasToDOM","canvasToDOM","View","animationSpeed","renderRefreshRate","animationEasingFunction","easingTime","sourceScale","targetScale","sourceTranslation","targetTranslation","lockedOnNodeId","lockedOnNodeOffset","touchTime","releaseNode","initialZoom","rawOptions","allNodeIds","minZoomLevel","MIN_VALUE","maxZoomLevel","normalizeFitOptions","canvasWidth","canvasHeight","zoomLevel","positionDefined","xZoomLevel","yZoomLevel","animationOptions","animation","focus","nodePosition","lockedOnNode","getViewPosition","duration","easingFunction","animateView","locked","_transitionRedraw","viewCenter","_lockedRedraw","finished","progress","easingFunctions","getScale","NavigationHandler","iconsCreated","navigationHammers","boundFunctions","activated","configureKeyboardBindings","keycharm","navigationButtons","loadNavigationElements","cleanNavigation","navigationDOM","parentNode","navigationDivs","navigationDivActions","_fit","bindToRedraw","_stopMovement","action","unbindFromRedraw","valueOf","boundAction","_moveUp","keyboard","speed","_moveDown","_moveLeft","_moveRight","_zoomIn","scaleOld","zoom","scaleFrac","tx","ty","pointer","_zoomOut","bindToWindow","preventDefault","reset","InteractionHandler","selectionHandler","navigationHandler","popup","popupObj","popupTimer","getPointer","dragNodes","dragView","autoFocus","tooltipDelay","zoomView","zoomSpeed","touch","getAbsoluteLeft","getAbsoluteTop","center","pinched","multiselect","changedPointers","ctrlKey","metaKey","checkSelectionChanges","commitAndEmit","generateClickEvent","clientX","clientY","selectAdditionalOnPoint","selectOnPoint","_determineDifference","firstSet","secondSet","arrayDiff","firstArr","secondArr","getNodeAt","selection","srcEvent","shiftKey","unselectAll","selectObject","getSelectedNodes","xFixed","yFixed","deltaX","deltaY","diffX","diffY","selectionBoxPosition","selectionBoxPositionMinMax","preScaleDragPointer","postScaleDragPointer","popupVisible","_checkHidePopup","setPosition","_checkShowPopup","hoverObject","pointerObj","previousPopupObjId","nodeUnderCursor","popupType","overlappingNodes","overlappingEdges","Popup","popupTargetType","popupTargetId","setText","hide","_pointerToPositionObject","stillOnObj","overNode","diffSets","prev","diff","Set","SingleTypeSelectionAccumulator","_SingleTypeSelectionAccumulator_previousSelection","_SingleTypeSelectionAccumulator_selection","__classPrivateFieldGet","delete","getSelection","getChanges","added","deleted","previous","commit","changes","__classPrivateFieldSet","SelectionAccumulator","commitHandler","_SelectionAccumulator_nodes","_SelectionAccumulator_edges","_SelectionAccumulator_commitHandler","sizeNodes","sizeEdges","getNodes","getEdges","addNodes","addEdges","deleteNodes","deleteEdges","rest","summary","SelectionHandler","_selectionAccumulator","hoverObj","selectable","selectConnectedEdges","hoverConnectedEdges","updateSelection","getEdgeAt","selectionChanged","deselectObject","_initBaseEvent","DOM","eventType","oldSelection","emptySelection","getClickedItems","controlEdge","highlightEdges","_removeFromSelection","_getAllNodesOverlappingWith","canvasPos","returnNode","positionObject","_getEdgesOverlappingWith","_getAllEdgesOverlappingWith","returnEdge","mindist","overlappingEdge","dist","_addToHover","getSelectedNodeCount","getSelectedEdgeCount","_hoverConnectedEdges","emitBlurEvent","emitHoverEvent","hoverChanged","hoveredEdgesCount","hoveredNodesCount","newOnlyHoveredEdge","newOnlyHoveredNode","commitWithoutEmitting","selectionChanges","previousSelection","getSelectedNodeIds","getSelectedEdgeIds","getSelectedEdges","setSelection","RangeError","selectNodes","selectEdges","apply","DirectionInterface","abstract","fake_use","curveType","getTreeSize","sort","nodeArray","fix","VerticalStrategy","layout","hierarchical","addToOrdering","res","min_x","max_x","timsort","levelSeparation","HorizontalStrategy","min_y","max_y","fillLevelsByDirectionCyclic","levels","fillLevelsByDirection","isEntryNode","shouldLevelBeReplaced","limit","reduce","acc","edgeIdProp","newLevelDiff","entryNodeId","entryNode","done","newLevel","targetNodeId","oldLevel","HierarchicalStatus","childrenReference","parentReference","trees","distributionOrdering","distributionIndex","isTree","treeIndex","addRelation","checkIfTree","numTrees","setTreeIndex","treeId","ensureLevel","getMaxLevel","accumulator","_getMaxLevel","levelDownstream","nodeA","nodeB","setMinLevelToZero","minLevel","hasSameParent","parents1","parents2","inSameSubNetwork","getLevels","isPresent","curLevel","LayoutEngine","_resetRNG","random","setPhysics","optionsBackup","randomSeed","improvedLayout","clusterThreshold","nodeSpacing","treeSpacing","blockShifting","edgeMinimization","parentCentralization","sortMethod","setupHierarchicalLayout","layoutNetwork","allOptions","prevHierarchicalState","setDirectionStrategy","adaptAllOptionsForHierarchicalLayout","seed","initialRandomSeed","backupPhysics","indices","MAX_LEVELS","clusterOptions","startLength","before","modules","clustering","_declusterAll","info","kamadaKawai","_shiftToCenter","clustersPresent","getSeed","definedLevel","undefinedLevel","lastNodeOnLevel","_determineLevelsByHubsize","_determineLevelsDirected","_determineLevelsCustomCallback","distribution","_getDistribution","_generateMap","_placeNodesByHierarchy","_condenseHierarchy","stillShifting","branches","shiftTree","getTreeSizes","treeWidths","getBranchNodes","getBranchBoundary","branchMap","maxLevel","minSpace","maxSpace","branchNode","minSpaceNode","maxSpaceNode","_getSpaceAroundNode","getCollisionLevel","maxLevel1","maxLevel2","shiftElementsCloser","centerParents","hier","levelNodes","branchShiftCallback","centerParent","pos1","pos2","diffAbs","branchNodes1","branchNodes2","branchNodeBoundary1","branchNodeBoundary2","max1","min2","minSpace2","_shiftBlock","_centerParent","minimizeEdgeLength","allEdges","nodeLevel","C2","referenceNodes","aboveEdges","getFx","sum","getDFx","getGuess","guess","guessMap","dfx","branchNodes","branchBoundary","minSpaceBranch","maxSpaceBranch","branchOffset","moveBranch","newPosition","minimizeEdgeLengthBottomUp","shiftBranchesCloserBottomUp","centerAllParents","centerAllParentsBottomUp","treeSizes","shiftBy","shiftTrees","useMap","ordering","prevNode","nextNode","nextPos","parents","parentId","_getCenterPosition","positionedNodes","_indexArrayToNodes","handledNodeCount","_validatePositionAndContinue","_placeBranchNodes","parentLevel","childRef","childNodeLevel","previousPos","sharedParent","_findCommonParent","withChild","idArray","array","_getActiveEdges","_getHubSizes","hubSizes","hubSize","TimSort","_crawlNetwork","levelA","shakeTowards","every","fillLevelsByDirectionRoots","fillLevelsByDirectionLeaves","startingNodeId","crawler","tree","shifter","childA","childB","iterateParents","child","parentRef","findParent","foundParent","isVertical","minPos","maxPos","ManipulationSystem","interactionHandler","editMode","manipulationDiv","editModeDiv","closeDiv","_domEventListenerCleanupQueue","temporaryUIFunctions","temporaryEventFunctions","temporaryIds","guiEnabled","inMode","selectedControlNode","initiallyActive","deleteNode","deleteEdge","controlNodeStyle","_clean","_restore","enableEditMode","disableEditMode","locale","locales","_setup","toggleEditMode","display","showManipulatorToolbar","_createEditButton","manipulationDOM","selectedNodeCount","selectedEdgeCount","selectedTotalCount","needSeperator","_createAddNodeButton","_createSeperator","_createAddEdgeButton","_createEditNodeButton","_createEditEdgeButton","_createDeleteButton","_bindElementEvents","_temporaryBindEvent","addNodeMode","_createBackButton","_createDescription","_performAddNode","finalizedData","alert","addEdgeMode","_temporaryBindUI","_handleConnect","_finishConnect","_dragControlNode","_dragStartEdge","editEdgeMode","editWithoutDrag","edgeBeingEditedId","controlNodeFrom","_getNewTargetNode","controlNodeTo","_controlNodeTouch","_controlNodeDragStart","_controlNodeDrag","_controlNodeDragEnd","_performEditEdge","deleteSelected","selectedNodes","selectedEdges","deleteFunction","_createWrappers","_removeManipulationDOM","setAttribute","recursiveDOMDelete","button","_createButton","_cleanupDOMEventListeners","_cleanupTemporaryNodesAndEdges","_unbindTemporaryUIs","_unbindTemporaryEvents","deleteBtnClass","rtl","labelClassName","newFunction","boundFunction","UIfunctionName","functionName","eventName","domElement","keyupListener","keyCode","indexTempEdge","indexTempNode","lastTouch","fromSelect","toSelect","overlappingNodeIds","targetNode","connectionEdge","connectFromId","_performAddEdge","clickData","defaultData","sourceNodeId","eeFunct","string","bool","number","endPoints","nodeOptions","boolean","function","__type__","minimum","dom","maximum","configure","showButton","__any__","interaction","manipulation","clickToUse","any","configureOptions","configuratorHideOption","parentPath","optionName","FloydWarshall","getDistances","edgesArray","D_matrix","cell","knode","kcolm","inode","icolm","jnode","jcolm","val","KamadaKawai","edgeStrength","distanceSolver","ignoreClusters","_createL_matrix","_createK_matrix","_createE_matrix","maxIterations","maxEnergy","highE_nodeId","dE_dx","dE_dy","delta_m","subIterations","_getHighestEnergyNode","_moveNode","_getEnergy","maxEnergyNodeId","dE_dx_max","dE_dy_max","nodeIdx","E_sums","d2E_dx2","d2E_dxdy","d2E_dy2","x_m","y_m","km","K_matrix","lm","L_matrix","iIdx","x_i","y_i","kmat","lmat","denominator","_updateE_matrix","E_matrix","mIdx","colm","lcolm","oldDx","oldDy","Network","renderer","nodesHandler","edgesHandler","Emitter","Validator","validate","rawCode","rawLanguage","rawCountry","language","country","toUpperCase","normalizeLanguageCode","configurator","Configurator","networkOptions","global","setModuleOptions","activator","Activator","_updateVisibleIndices","edgeNodesPresent","_updateValueRange","gephi","gephiData","valueMin","valueMax","valueTotal","isActive","active","arguments","editNodeMode","objectId","getOptionsFromConfigurator","getOptions","parseDOTNetwork","dotparser.DOTToGraph"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;4wBAQgBA,EACdC,EACAC,EACAC,EACAC,GAEAH,EAAII,YACJJ,EAAIK,IAAIJ,EAAGC,EAAGC,EAAG,EAAG,EAAIG,KAAKC,IAAI,GACjCP,EAAIQ,qBAoKUC,EACdT,EACAC,EACAC,EACAQ,EACAC,EACAR,GAEA,MAAMS,EAAMN,KAAKC,GAAK,IAClBG,EAAI,EAAIP,EAAI,IACdA,EAAIO,EAAI,GAENC,EAAI,EAAIR,EAAI,IACdA,EAAIQ,EAAI,GAEVX,EAAII,YACJJ,EAAIa,OAAOZ,EAAIE,EAAGD,GAClBF,EAAIc,OAAOb,EAAIS,EAAIP,EAAGD,GACtBF,EAAIK,IAAIJ,EAAIS,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