From ac3699d619c357bfb2a7f12320be4f4bdd94b0e0 Mon Sep 17 00:00:00 2001 From: Rafael Matias Date: Thu, 8 Aug 2024 14:05:23 +0200 Subject: [PATCH] client pages: use cytoscape instead of visJS for the network rendering due to performance issues --- .gitattributes | 1 + static/css/clients.css | 11 + static/js/cytoscape-network-aux.js | 175 + static/js/vendor/cytoscape-cose-base.js | 3214 +++++++++++++ static/js/vendor/cytoscape-fcose.js | 1549 ++++++ static/js/vendor/cytoscape-layout-base.js | 5230 +++++++++++++++++++++ static/js/vendor/cytoscape.min.js | 32 + static/js/vis-network-aux.js | 130 - static/js/vis-network.min.js | 34 - templates/clients/clients_cl.html | 49 +- templates/clients/clients_el.html | 50 +- 11 files changed, 10248 insertions(+), 227 deletions(-) create mode 100644 .gitattributes create mode 100644 static/js/cytoscape-network-aux.js create mode 100644 static/js/vendor/cytoscape-cose-base.js create mode 100644 static/js/vendor/cytoscape-fcose.js create mode 100644 static/js/vendor/cytoscape-layout-base.js create mode 100644 static/js/vendor/cytoscape.min.js delete mode 100644 static/js/vis-network-aux.js delete mode 100644 static/js/vis-network.min.js diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..197d2b7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +static/js/vendor/** linguist-vendored=true diff --git a/static/css/clients.css b/static/css/clients.css index deda005..db31b18 100644 --- a/static/css/clients.css +++ b/static/css/clients.css @@ -82,3 +82,14 @@ Client peers table display: inline-block; vertical-align: middle; } + +#nodemap-loading { + position: absolute; + top: 50%; + left: 50%; + z-index: 1000; + width: 100px; + height: 100px; + margin-left: -50px; + margin-top: -50px; +} diff --git a/static/js/cytoscape-network-aux.js b/static/js/cytoscape-network-aux.js new file mode 100644 index 0000000..6406198 --- /dev/null +++ b/static/js/cytoscape-network-aux.js @@ -0,0 +1,175 @@ +$_network = {}; + +// Select a node and its neighborhood edges +$_network.selectNode = function (cy, nodeId) { + elem = cy.getElementById(nodeId) + cy.elements().unselect(); + elem.select(); + console.log(elem.neighborhood()); + elem.neighborhood().edges().select(); +} + +// Isolate a node and only show it and its neighborhood +$_network.isolateNode = function (cy, nodeId) { + elem = cy.getElementById(nodeId) + cy.elements().hide().unselect(); + elem.show().select(); + edges = elem.neighborhood().edges(); + edges.show(); + edges.select(); + elem.neighborhood().nodes().show(); +} + +// Show all nodes and edges +$_network.showAll = function (cy) { + cy.elements().show().unselect(); +} + +// Available Layouts +$_network.layouts = { + fcose : function(nodeCount){ + return { + name: 'fcose', + idealEdgeLength: 5 * nodeCount, + nestingFactor: 1.2, + animate: false, + stop: function() { + $("#nodemap-loading").hide(); + } + } + }, + circle : function() { + return { + name: 'circle', + animate: false, + } + }, + grid : function() { + return { + name: 'grid', + animate: false, + } + }, +} + +// Default layout +$_network.defaultLayout = $_network.layouts.fcose; + + +// Default stylesheet +$_network.defaultStylesheet = cytoscape.stylesheet() + .selector('node') + .css({ + 'height': 20, + 'width': 20, + 'background-fit': 'cover', + 'border-color': '#0077B6', + 'border-width': 1, + 'border-opacity': 1, + }) + .selector('edge') + .css({ + 'curve-style': 'bezier', + 'width': 0.5, + 'target-arrow-shape': 'vee', + 'line-color': '#0077B6', + 'target-arrow-color': '#0077B6', + 'arrow-scale': 0.5, + }) + .selector('node[label]') + .css({ + 'label': 'data(label)', + }) + .selector('.bottom-center') + .css({ + "text-valign": "bottom", + "text-halign": "center", + "color": "#ffffff", + "font-size": 4, + }) + .selector('node:selected, edge:selected') + .css({ + 'border-color': '#FFA500', + 'background-color': '#FFA500', + 'line-color': '#FFA500', + 'target-arrow-color': '#FFA500', + 'source-arrow-color': '#FFA500', + 'opacity': 1 +}); + + +$_network.fitAnimated = function (cy, layout) { + cy.animate({ + fit: { eles: cy.$() }, + duration: 500, + complete: function () { + setTimeout(function () { + layout.animate = true; + layout.animationDuration = 2000; + layout.fit = true; + layout.directed = true; + cy.layout(layout).run(); + }, 500); + }, + }); +} + + +// Create a cytoscape network +$_network.create = function (container, data){ + var stylesheet = $_network.defaultStylesheet; + var cytoElements = []; + for (var i = 0; i < data.nodes.length; i++) { + // Create nodes + data.nodes[i].title = data.nodes[i].id; + if (data.nodes[i].id != "") { + cytoElements.push( + { + data: data.nodes[i], + classes: "bottom-center", + } + ); + // Add style to nodes + stylesheet.selector('#' + data.nodes[i].id).css({ + 'background-image': '/identicon?key=' + data.nodes[i].id + }); + } + } + for (var i = 0; i < data.edges.length; i++) { + // Create edges + cytoElements.push({ + data: { + id: data.edges[i].from + "-" + data.edges[i].to, + source: data.edges[i].from, + target: data.edges[i].to + } + }); + } + + var cy = window.cy = cytoscape({ + container: container, + style: stylesheet, + layout: $_network.defaultLayout(data.nodes.length), + elements: cytoElements, + wheelSensitivity: 0.1, + }); + + cy.on('tap', 'node', function(evt){ + evt.preventDefault(); + console.log(evt.target.id()); + $_network.isolateNode(cy, evt.target.id()); + $(".collapse.peerInfo").collapse("hide"); + $("#peerInfo-" + evt.target.id()).collapse("show"); + }); + + cy.on('tap', function(event){ + var evtTarget = event.target; + if( evtTarget === cy ){ // tap on background + $_network.showAll(cy); + window.location.hash = ""; + $(".collapse.peerInfo").collapse("hide"); + } + }); + + return cy; +} diff --git a/static/js/vendor/cytoscape-cose-base.js b/static/js/vendor/cytoscape-cose-base.js new file mode 100644 index 0000000..49ccc66 --- /dev/null +++ b/static/js/vendor/cytoscape-cose-base.js @@ -0,0 +1,3214 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("layout-base")); + else if(typeof define === 'function' && define.amd) + define(["layout-base"], factory); + else if(typeof exports === 'object') + exports["coseBase"] = factory(require("layout-base")); + else + root["coseBase"] = factory(root["layoutBase"]); +})(this, function(__WEBPACK_EXTERNAL_MODULE__551__) { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 45: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var coseBase = {}; + +coseBase.layoutBase = __webpack_require__(551); +coseBase.CoSEConstants = __webpack_require__(806); +coseBase.CoSEEdge = __webpack_require__(767); +coseBase.CoSEGraph = __webpack_require__(880); +coseBase.CoSEGraphManager = __webpack_require__(578); +coseBase.CoSELayout = __webpack_require__(765); +coseBase.CoSENode = __webpack_require__(991); +coseBase.ConstraintHandler = __webpack_require__(902); + +module.exports = coseBase; + +/***/ }), + +/***/ 806: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var FDLayoutConstants = __webpack_require__(551).FDLayoutConstants; + +function CoSEConstants() {} + +//CoSEConstants inherits static props in FDLayoutConstants +for (var prop in FDLayoutConstants) { + CoSEConstants[prop] = FDLayoutConstants[prop]; +} + +CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false; +CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH; +CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60; +CoSEConstants.TILE = true; +CoSEConstants.TILING_PADDING_VERTICAL = 10; +CoSEConstants.TILING_PADDING_HORIZONTAL = 10; +CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = true; +CoSEConstants.ENFORCE_CONSTRAINTS = true; +CoSEConstants.APPLY_LAYOUT = true; +CoSEConstants.RELAX_MOVEMENT_ON_CONSTRAINTS = true; +CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = true; // this should be set to false if there will be a constraint +// This constant is for differentiating whether actual layout algorithm that uses cose-base wants to apply only incremental layout or +// an incremental layout on top of a randomized layout. If it is only incremental layout, then this constant should be true. +CoSEConstants.PURE_INCREMENTAL = CoSEConstants.DEFAULT_INCREMENTAL; + +module.exports = CoSEConstants; + +/***/ }), + +/***/ 767: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var FDLayoutEdge = __webpack_require__(551).FDLayoutEdge; + +function CoSEEdge(source, target, vEdge) { + FDLayoutEdge.call(this, source, target, vEdge); +} + +CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype); +for (var prop in FDLayoutEdge) { + CoSEEdge[prop] = FDLayoutEdge[prop]; +} + +module.exports = CoSEEdge; + +/***/ }), + +/***/ 880: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var LGraph = __webpack_require__(551).LGraph; + +function CoSEGraph(parent, graphMgr, vGraph) { + LGraph.call(this, parent, graphMgr, vGraph); +} + +CoSEGraph.prototype = Object.create(LGraph.prototype); +for (var prop in LGraph) { + CoSEGraph[prop] = LGraph[prop]; +} + +module.exports = CoSEGraph; + +/***/ }), + +/***/ 578: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var LGraphManager = __webpack_require__(551).LGraphManager; + +function CoSEGraphManager(layout) { + LGraphManager.call(this, layout); +} + +CoSEGraphManager.prototype = Object.create(LGraphManager.prototype); +for (var prop in LGraphManager) { + CoSEGraphManager[prop] = LGraphManager[prop]; +} + +module.exports = CoSEGraphManager; + +/***/ }), + +/***/ 765: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var FDLayout = __webpack_require__(551).FDLayout; +var CoSEGraphManager = __webpack_require__(578); +var CoSEGraph = __webpack_require__(880); +var CoSENode = __webpack_require__(991); +var CoSEEdge = __webpack_require__(767); +var CoSEConstants = __webpack_require__(806); +var ConstraintHandler = __webpack_require__(902); +var FDLayoutConstants = __webpack_require__(551).FDLayoutConstants; +var LayoutConstants = __webpack_require__(551).LayoutConstants; +var Point = __webpack_require__(551).Point; +var PointD = __webpack_require__(551).PointD; +var DimensionD = __webpack_require__(551).DimensionD; +var Layout = __webpack_require__(551).Layout; +var Integer = __webpack_require__(551).Integer; +var IGeometry = __webpack_require__(551).IGeometry; +var LGraph = __webpack_require__(551).LGraph; +var Transform = __webpack_require__(551).Transform; +var LinkedList = __webpack_require__(551).LinkedList; + +function CoSELayout() { + FDLayout.call(this); + + this.toBeTiled = {}; // Memorize if a node is to be tiled or is tiled + this.constraints = {}; // keep layout constraints +} + +CoSELayout.prototype = Object.create(FDLayout.prototype); + +for (var prop in FDLayout) { + CoSELayout[prop] = FDLayout[prop]; +} + +CoSELayout.prototype.newGraphManager = function () { + var gm = new CoSEGraphManager(this); + this.graphManager = gm; + return gm; +}; + +CoSELayout.prototype.newGraph = function (vGraph) { + return new CoSEGraph(null, this.graphManager, vGraph); +}; + +CoSELayout.prototype.newNode = function (vNode) { + return new CoSENode(this.graphManager, vNode); +}; + +CoSELayout.prototype.newEdge = function (vEdge) { + return new CoSEEdge(null, null, vEdge); +}; + +CoSELayout.prototype.initParameters = function () { + FDLayout.prototype.initParameters.call(this, arguments); + if (!this.isSubLayout) { + if (CoSEConstants.DEFAULT_EDGE_LENGTH < 10) { + this.idealEdgeLength = 10; + } else { + this.idealEdgeLength = CoSEConstants.DEFAULT_EDGE_LENGTH; + } + + this.useSmartIdealEdgeLengthCalculation = CoSEConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + + // variables for tree reduction support + this.prunedNodesAll = []; + this.growTreeIterations = 0; + this.afterGrowthIterations = 0; + this.isTreeGrowing = false; + this.isGrowthFinished = false; + } +}; + +// This method is used to set CoSE related parameters used by spring embedder. +CoSELayout.prototype.initSpringEmbedder = function () { + FDLayout.prototype.initSpringEmbedder.call(this); + + // variables for cooling + this.coolingCycle = 0; + this.maxCoolingCycle = this.maxIterations / FDLayoutConstants.CONVERGENCE_CHECK_PERIOD; + this.finalTemperature = 0.04; + this.coolingAdjuster = 1; +}; + +CoSELayout.prototype.layout = function () { + var createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + if (createBendsAsNeeded) { + this.createBendpoints(); + this.graphManager.resetAllEdges(); + } + + this.level = 0; + return this.classicLayout(); +}; + +CoSELayout.prototype.classicLayout = function () { + this.nodesWithGravity = this.calculateNodesToApplyGravitationTo(); + this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity); + this.calcNoOfChildrenForAllNodes(); + this.graphManager.calcLowestCommonAncestors(); + this.graphManager.calcInclusionTreeDepths(); + this.graphManager.getRoot().calcEstimatedSize(); + this.calcIdealEdgeLengths(); + + if (!this.incremental) { + var forest = this.getFlatForest(); + + // The graph associated with this layout is flat and a forest + if (forest.length > 0) { + this.positionNodesRadially(forest); + } + // The graph associated with this layout is not flat or a forest + else { + // Reduce the trees when incremental mode is not enabled and graph is not a forest + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.positionNodesRandomly(); + } + } else { + if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) { + // Reduce the trees in incremental mode if only this constant is set to true + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + } + } + + if (Object.keys(this.constraints).length > 0) { + ConstraintHandler.handleConstraints(this); + this.initConstraintVariables(); + } + + this.initSpringEmbedder(); + if (CoSEConstants.APPLY_LAYOUT) { + this.runSpringEmbedder(); + } + + return true; +}; + +CoSELayout.prototype.tick = function () { + this.totalIterations++; + + if (this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + if (this.totalIterations % FDLayoutConstants.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.isConverged()) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + this.coolingCycle++; + + if (this.layoutQuality == 0) { + // quality - "draft" + this.coolingAdjuster = this.coolingCycle; + } else if (this.layoutQuality == 1) { + // quality - "default" + this.coolingAdjuster = this.coolingCycle / 3; + } + + // cooling schedule is based on http://www.btluke.com/simanf1.html -> cooling schedule 3 + this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature); + this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor)); + } + // Operations while tree is growing again + if (this.isTreeGrowing) { + if (this.growTreeIterations % 10 == 0) { + if (this.prunedNodesAll.length > 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + this.growTree(this.prunedNodesAll); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.graphManager.updateBounds(); + this.updateGrid(); + if (CoSEConstants.PURE_INCREMENTAL) this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL / 2;else this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + } else { + this.isTreeGrowing = false; + this.isGrowthFinished = true; + } + } + this.growTreeIterations++; + } + // Operations after growth is finished + if (this.isGrowthFinished) { + if (this.isConverged()) { + return true; + } + if (this.afterGrowthIterations % 10 == 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + } + if (CoSEConstants.PURE_INCREMENTAL) this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL / 2 * ((100 - this.afterGrowthIterations) / 100);else this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100); + this.afterGrowthIterations++; + } + + var gridUpdateAllowed = !this.isTreeGrowing && !this.isGrowthFinished; + var forceToNodeSurroundingUpdate = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished; + + this.totalDisplacement = 0; + this.graphManager.updateBounds(); + this.calcSpringForces(); + this.calcRepulsionForces(gridUpdateAllowed, forceToNodeSurroundingUpdate); + this.calcGravitationalForces(); + this.moveNodes(); + this.animate(); + + return false; // Layout is not ended yet return false +}; + +CoSELayout.prototype.getPositionsData = function () { + var allNodes = this.graphManager.getAllNodes(); + var pData = {}; + for (var i = 0; i < allNodes.length; i++) { + var rect = allNodes[i].rect; + var id = allNodes[i].id; + pData[id] = { + id: id, + x: rect.getCenterX(), + y: rect.getCenterY(), + w: rect.width, + h: rect.height + }; + } + + return pData; +}; + +CoSELayout.prototype.runSpringEmbedder = function () { + this.initialAnimationPeriod = 25; + this.animationPeriod = this.initialAnimationPeriod; + var layoutEnded = false; + + // If aminate option is 'during' signal that layout is supposed to start iterating + if (FDLayoutConstants.ANIMATE === 'during') { + this.emit('layoutstarted'); + } else { + // If aminate option is 'during' tick() function will be called on index.js + while (!layoutEnded) { + layoutEnded = this.tick(); + } + + this.graphManager.updateBounds(); + } +}; + +// overrides moveNodes method in FDLayout +CoSELayout.prototype.moveNodes = function () { + var lNodes = this.getAllNodes(); + var node; + + // calculate displacement for each node + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + node.calculateDisplacement(); + } + + if (Object.keys(this.constraints).length > 0) { + this.updateDisplacements(); + } + + // move each node + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + node.move(); + } +}; + +// constraint related methods: initConstraintVariables and updateDisplacements + +// initialize constraint related variables +CoSELayout.prototype.initConstraintVariables = function () { + var self = this; + this.idToNodeMap = new Map(); + this.fixedNodeSet = new Set(); + + var allNodes = this.graphManager.getAllNodes(); + + // fill idToNodeMap + for (var i = 0; i < allNodes.length; i++) { + var node = allNodes[i]; + this.idToNodeMap.set(node.id, node); + } + + // calculate fixed node weight for given compound node + var calculateCompoundWeight = function calculateCompoundWeight(compoundNode) { + var nodes = compoundNode.getChild().getNodes(); + var node; + var fixedNodeWeight = 0; + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + if (node.getChild() == null) { + if (self.fixedNodeSet.has(node.id)) { + fixedNodeWeight += 100; + } + } else { + fixedNodeWeight += calculateCompoundWeight(node); + } + } + return fixedNodeWeight; + }; + + if (this.constraints.fixedNodeConstraint) { + // fill fixedNodeSet + this.constraints.fixedNodeConstraint.forEach(function (nodeData) { + self.fixedNodeSet.add(nodeData.nodeId); + }); + + // assign fixed node weights to compounds if they contain fixed nodes + var allNodes = this.graphManager.getAllNodes(); + var node; + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + if (node.getChild() != null) { + var fixedNodeWeight = calculateCompoundWeight(node); + if (fixedNodeWeight > 0) { + node.fixedNodeWeight = fixedNodeWeight; + } + } + } + } + + if (this.constraints.relativePlacementConstraint) { + var nodeToDummyForVerticalAlignment = new Map(); + var nodeToDummyForHorizontalAlignment = new Map(); + this.dummyToNodeForVerticalAlignment = new Map(); + this.dummyToNodeForHorizontalAlignment = new Map(); + this.fixedNodesOnHorizontal = new Set(); + this.fixedNodesOnVertical = new Set(); + + // fill maps and sets + this.fixedNodeSet.forEach(function (nodeId) { + self.fixedNodesOnHorizontal.add(nodeId); + self.fixedNodesOnVertical.add(nodeId); + }); + + if (this.constraints.alignmentConstraint) { + if (this.constraints.alignmentConstraint.vertical) { + var verticalAlignment = this.constraints.alignmentConstraint.vertical; + for (var i = 0; i < verticalAlignment.length; i++) { + this.dummyToNodeForVerticalAlignment.set("dummy" + i, []); + verticalAlignment[i].forEach(function (nodeId) { + nodeToDummyForVerticalAlignment.set(nodeId, "dummy" + i); + self.dummyToNodeForVerticalAlignment.get("dummy" + i).push(nodeId); + if (self.fixedNodeSet.has(nodeId)) { + self.fixedNodesOnHorizontal.add("dummy" + i); + } + }); + } + } + if (this.constraints.alignmentConstraint.horizontal) { + var horizontalAlignment = this.constraints.alignmentConstraint.horizontal; + for (var i = 0; i < horizontalAlignment.length; i++) { + this.dummyToNodeForHorizontalAlignment.set("dummy" + i, []); + horizontalAlignment[i].forEach(function (nodeId) { + nodeToDummyForHorizontalAlignment.set(nodeId, "dummy" + i); + self.dummyToNodeForHorizontalAlignment.get("dummy" + i).push(nodeId); + if (self.fixedNodeSet.has(nodeId)) { + self.fixedNodesOnVertical.add("dummy" + i); + } + }); + } + } + } + + if (CoSEConstants.RELAX_MOVEMENT_ON_CONSTRAINTS) { + + this.shuffle = function (array) { + var j, x, i; + for (i = array.length - 1; i >= 2 * array.length / 3; i--) { + j = Math.floor(Math.random() * (i + 1)); + x = array[i]; + array[i] = array[j]; + array[j] = x; + } + return array; + }; + + this.nodesInRelativeHorizontal = []; + this.nodesInRelativeVertical = []; + this.nodeToRelativeConstraintMapHorizontal = new Map(); + this.nodeToRelativeConstraintMapVertical = new Map(); + this.nodeToTempPositionMapHorizontal = new Map(); + this.nodeToTempPositionMapVertical = new Map(); + + // fill arrays and maps + this.constraints.relativePlacementConstraint.forEach(function (constraint) { + if (constraint.left) { + var nodeIdLeft = nodeToDummyForVerticalAlignment.has(constraint.left) ? nodeToDummyForVerticalAlignment.get(constraint.left) : constraint.left; + var nodeIdRight = nodeToDummyForVerticalAlignment.has(constraint.right) ? nodeToDummyForVerticalAlignment.get(constraint.right) : constraint.right; + + if (!self.nodesInRelativeHorizontal.includes(nodeIdLeft)) { + self.nodesInRelativeHorizontal.push(nodeIdLeft); + self.nodeToRelativeConstraintMapHorizontal.set(nodeIdLeft, []); + if (self.dummyToNodeForVerticalAlignment.has(nodeIdLeft)) { + self.nodeToTempPositionMapHorizontal.set(nodeIdLeft, self.idToNodeMap.get(self.dummyToNodeForVerticalAlignment.get(nodeIdLeft)[0]).getCenterX()); + } else { + self.nodeToTempPositionMapHorizontal.set(nodeIdLeft, self.idToNodeMap.get(nodeIdLeft).getCenterX()); + } + } + if (!self.nodesInRelativeHorizontal.includes(nodeIdRight)) { + self.nodesInRelativeHorizontal.push(nodeIdRight); + self.nodeToRelativeConstraintMapHorizontal.set(nodeIdRight, []); + if (self.dummyToNodeForVerticalAlignment.has(nodeIdRight)) { + self.nodeToTempPositionMapHorizontal.set(nodeIdRight, self.idToNodeMap.get(self.dummyToNodeForVerticalAlignment.get(nodeIdRight)[0]).getCenterX()); + } else { + self.nodeToTempPositionMapHorizontal.set(nodeIdRight, self.idToNodeMap.get(nodeIdRight).getCenterX()); + } + } + + self.nodeToRelativeConstraintMapHorizontal.get(nodeIdLeft).push({ right: nodeIdRight, gap: constraint.gap }); + self.nodeToRelativeConstraintMapHorizontal.get(nodeIdRight).push({ left: nodeIdLeft, gap: constraint.gap }); + } else { + var nodeIdTop = nodeToDummyForHorizontalAlignment.has(constraint.top) ? nodeToDummyForHorizontalAlignment.get(constraint.top) : constraint.top; + var nodeIdBottom = nodeToDummyForHorizontalAlignment.has(constraint.bottom) ? nodeToDummyForHorizontalAlignment.get(constraint.bottom) : constraint.bottom; + + if (!self.nodesInRelativeVertical.includes(nodeIdTop)) { + self.nodesInRelativeVertical.push(nodeIdTop); + self.nodeToRelativeConstraintMapVertical.set(nodeIdTop, []); + if (self.dummyToNodeForHorizontalAlignment.has(nodeIdTop)) { + self.nodeToTempPositionMapVertical.set(nodeIdTop, self.idToNodeMap.get(self.dummyToNodeForHorizontalAlignment.get(nodeIdTop)[0]).getCenterY()); + } else { + self.nodeToTempPositionMapVertical.set(nodeIdTop, self.idToNodeMap.get(nodeIdTop).getCenterY()); + } + } + if (!self.nodesInRelativeVertical.includes(nodeIdBottom)) { + self.nodesInRelativeVertical.push(nodeIdBottom); + self.nodeToRelativeConstraintMapVertical.set(nodeIdBottom, []); + if (self.dummyToNodeForHorizontalAlignment.has(nodeIdBottom)) { + self.nodeToTempPositionMapVertical.set(nodeIdBottom, self.idToNodeMap.get(self.dummyToNodeForHorizontalAlignment.get(nodeIdBottom)[0]).getCenterY()); + } else { + self.nodeToTempPositionMapVertical.set(nodeIdBottom, self.idToNodeMap.get(nodeIdBottom).getCenterY()); + } + } + self.nodeToRelativeConstraintMapVertical.get(nodeIdTop).push({ bottom: nodeIdBottom, gap: constraint.gap }); + self.nodeToRelativeConstraintMapVertical.get(nodeIdBottom).push({ top: nodeIdTop, gap: constraint.gap }); + } + }); + } else { + var subGraphOnHorizontal = new Map(); // subgraph from vertical RP constraints + var subGraphOnVertical = new Map(); // subgraph from vertical RP constraints + + // construct subgraphs from relative placement constraints + this.constraints.relativePlacementConstraint.forEach(function (constraint) { + if (constraint.left) { + var left = nodeToDummyForVerticalAlignment.has(constraint.left) ? nodeToDummyForVerticalAlignment.get(constraint.left) : constraint.left; + var right = nodeToDummyForVerticalAlignment.has(constraint.right) ? nodeToDummyForVerticalAlignment.get(constraint.right) : constraint.right; + if (subGraphOnHorizontal.has(left)) { + subGraphOnHorizontal.get(left).push(right); + } else { + subGraphOnHorizontal.set(left, [right]); + } + if (subGraphOnHorizontal.has(right)) { + subGraphOnHorizontal.get(right).push(left); + } else { + subGraphOnHorizontal.set(right, [left]); + } + } else { + var top = nodeToDummyForHorizontalAlignment.has(constraint.top) ? nodeToDummyForHorizontalAlignment.get(constraint.top) : constraint.top; + var bottom = nodeToDummyForHorizontalAlignment.has(constraint.bottom) ? nodeToDummyForHorizontalAlignment.get(constraint.bottom) : constraint.bottom; + if (subGraphOnVertical.has(top)) { + subGraphOnVertical.get(top).push(bottom); + } else { + subGraphOnVertical.set(top, [bottom]); + } + if (subGraphOnVertical.has(bottom)) { + subGraphOnVertical.get(bottom).push(top); + } else { + subGraphOnVertical.set(bottom, [top]); + } + } + }); + + // function to construct components from a given graph + // also returns an array that keeps whether each component contains fixed node + var constructComponents = function constructComponents(graph, fixedNodes) { + var components = []; + var isFixed = []; + var queue = new LinkedList(); + var visited = new Set(); + var count = 0; + + graph.forEach(function (value, key) { + if (!visited.has(key)) { + components[count] = []; + isFixed[count] = false; + var currentNode = key; + queue.push(currentNode); + visited.add(currentNode); + components[count].push(currentNode); + + while (queue.length != 0) { + currentNode = queue.shift(); + if (fixedNodes.has(currentNode)) { + isFixed[count] = true; + } + var neighbors = graph.get(currentNode); + neighbors.forEach(function (neighbor) { + if (!visited.has(neighbor)) { + queue.push(neighbor); + visited.add(neighbor); + components[count].push(neighbor); + } + }); + } + count++; + } + }); + + return { components: components, isFixed: isFixed }; + }; + + var resultOnHorizontal = constructComponents(subGraphOnHorizontal, self.fixedNodesOnHorizontal); + this.componentsOnHorizontal = resultOnHorizontal.components; + this.fixedComponentsOnHorizontal = resultOnHorizontal.isFixed; + var resultOnVertical = constructComponents(subGraphOnVertical, self.fixedNodesOnVertical); + this.componentsOnVertical = resultOnVertical.components; + this.fixedComponentsOnVertical = resultOnVertical.isFixed; + } + } +}; + +// updates node displacements based on constraints +CoSELayout.prototype.updateDisplacements = function () { + var self = this; + if (this.constraints.fixedNodeConstraint) { + this.constraints.fixedNodeConstraint.forEach(function (nodeData) { + var fixedNode = self.idToNodeMap.get(nodeData.nodeId); + fixedNode.displacementX = 0; + fixedNode.displacementY = 0; + }); + } + + if (this.constraints.alignmentConstraint) { + if (this.constraints.alignmentConstraint.vertical) { + var allVerticalAlignments = this.constraints.alignmentConstraint.vertical; + for (var i = 0; i < allVerticalAlignments.length; i++) { + var totalDisplacementX = 0; + for (var j = 0; j < allVerticalAlignments[i].length; j++) { + if (this.fixedNodeSet.has(allVerticalAlignments[i][j])) { + totalDisplacementX = 0; + break; + } + totalDisplacementX += this.idToNodeMap.get(allVerticalAlignments[i][j]).displacementX; + } + var averageDisplacementX = totalDisplacementX / allVerticalAlignments[i].length; + for (var j = 0; j < allVerticalAlignments[i].length; j++) { + this.idToNodeMap.get(allVerticalAlignments[i][j]).displacementX = averageDisplacementX; + } + } + } + if (this.constraints.alignmentConstraint.horizontal) { + var allHorizontalAlignments = this.constraints.alignmentConstraint.horizontal; + for (var i = 0; i < allHorizontalAlignments.length; i++) { + var totalDisplacementY = 0; + for (var j = 0; j < allHorizontalAlignments[i].length; j++) { + if (this.fixedNodeSet.has(allHorizontalAlignments[i][j])) { + totalDisplacementY = 0; + break; + } + totalDisplacementY += this.idToNodeMap.get(allHorizontalAlignments[i][j]).displacementY; + } + var averageDisplacementY = totalDisplacementY / allHorizontalAlignments[i].length; + for (var j = 0; j < allHorizontalAlignments[i].length; j++) { + this.idToNodeMap.get(allHorizontalAlignments[i][j]).displacementY = averageDisplacementY; + } + } + } + } + + if (this.constraints.relativePlacementConstraint) { + + if (CoSEConstants.RELAX_MOVEMENT_ON_CONSTRAINTS) { + // shuffle array to randomize node processing order + if (this.totalIterations % 10 == 0) { + this.shuffle(this.nodesInRelativeHorizontal); + this.shuffle(this.nodesInRelativeVertical); + } + + this.nodesInRelativeHorizontal.forEach(function (nodeId) { + if (!self.fixedNodesOnHorizontal.has(nodeId)) { + var displacement = 0; + if (self.dummyToNodeForVerticalAlignment.has(nodeId)) { + displacement = self.idToNodeMap.get(self.dummyToNodeForVerticalAlignment.get(nodeId)[0]).displacementX; + } else { + displacement = self.idToNodeMap.get(nodeId).displacementX; + } + self.nodeToRelativeConstraintMapHorizontal.get(nodeId).forEach(function (constraint) { + if (constraint.right) { + var diff = self.nodeToTempPositionMapHorizontal.get(constraint.right) - self.nodeToTempPositionMapHorizontal.get(nodeId) - displacement; + if (diff < constraint.gap) { + displacement -= constraint.gap - diff; + } + } else { + var diff = self.nodeToTempPositionMapHorizontal.get(nodeId) - self.nodeToTempPositionMapHorizontal.get(constraint.left) + displacement; + if (diff < constraint.gap) { + displacement += constraint.gap - diff; + } + } + }); + self.nodeToTempPositionMapHorizontal.set(nodeId, self.nodeToTempPositionMapHorizontal.get(nodeId) + displacement); + if (self.dummyToNodeForVerticalAlignment.has(nodeId)) { + self.dummyToNodeForVerticalAlignment.get(nodeId).forEach(function (nodeId) { + self.idToNodeMap.get(nodeId).displacementX = displacement; + }); + } else { + self.idToNodeMap.get(nodeId).displacementX = displacement; + } + } + }); + + this.nodesInRelativeVertical.forEach(function (nodeId) { + if (!self.fixedNodesOnHorizontal.has(nodeId)) { + var displacement = 0; + if (self.dummyToNodeForHorizontalAlignment.has(nodeId)) { + displacement = self.idToNodeMap.get(self.dummyToNodeForHorizontalAlignment.get(nodeId)[0]).displacementY; + } else { + displacement = self.idToNodeMap.get(nodeId).displacementY; + } + self.nodeToRelativeConstraintMapVertical.get(nodeId).forEach(function (constraint) { + if (constraint.bottom) { + var diff = self.nodeToTempPositionMapVertical.get(constraint.bottom) - self.nodeToTempPositionMapVertical.get(nodeId) - displacement; + if (diff < constraint.gap) { + displacement -= constraint.gap - diff; + } + } else { + var diff = self.nodeToTempPositionMapVertical.get(nodeId) - self.nodeToTempPositionMapVertical.get(constraint.top) + displacement; + if (diff < constraint.gap) { + displacement += constraint.gap - diff; + } + } + }); + self.nodeToTempPositionMapVertical.set(nodeId, self.nodeToTempPositionMapVertical.get(nodeId) + displacement); + if (self.dummyToNodeForHorizontalAlignment.has(nodeId)) { + self.dummyToNodeForHorizontalAlignment.get(nodeId).forEach(function (nodeId) { + self.idToNodeMap.get(nodeId).displacementY = displacement; + }); + } else { + self.idToNodeMap.get(nodeId).displacementY = displacement; + } + } + }); + } else { + for (var i = 0; i < this.componentsOnHorizontal.length; i++) { + var component = this.componentsOnHorizontal[i]; + if (this.fixedComponentsOnHorizontal[i]) { + for (var j = 0; j < component.length; j++) { + if (this.dummyToNodeForVerticalAlignment.has(component[j])) { + this.dummyToNodeForVerticalAlignment.get(component[j]).forEach(function (nodeId) { + self.idToNodeMap.get(nodeId).displacementX = 0; + }); + } else { + this.idToNodeMap.get(component[j]).displacementX = 0; + } + } + } else { + var sum = 0; + var count = 0; + for (var j = 0; j < component.length; j++) { + if (this.dummyToNodeForVerticalAlignment.has(component[j])) { + var actualNodes = this.dummyToNodeForVerticalAlignment.get(component[j]); + sum += actualNodes.length * this.idToNodeMap.get(actualNodes[0]).displacementX; + count += actualNodes.length; + } else { + sum += this.idToNodeMap.get(component[j]).displacementX; + count++; + } + } + var averageDisplacement = sum / count; + for (var j = 0; j < component.length; j++) { + if (this.dummyToNodeForVerticalAlignment.has(component[j])) { + this.dummyToNodeForVerticalAlignment.get(component[j]).forEach(function (nodeId) { + self.idToNodeMap.get(nodeId).displacementX = averageDisplacement; + }); + } else { + this.idToNodeMap.get(component[j]).displacementX = averageDisplacement; + } + } + } + } + + for (var i = 0; i < this.componentsOnVertical.length; i++) { + var component = this.componentsOnVertical[i]; + if (this.fixedComponentsOnVertical[i]) { + for (var j = 0; j < component.length; j++) { + if (this.dummyToNodeForHorizontalAlignment.has(component[j])) { + this.dummyToNodeForHorizontalAlignment.get(component[j]).forEach(function (nodeId) { + self.idToNodeMap.get(nodeId).displacementY = 0; + }); + } else { + this.idToNodeMap.get(component[j]).displacementY = 0; + } + } + } else { + var sum = 0; + var count = 0; + for (var j = 0; j < component.length; j++) { + if (this.dummyToNodeForHorizontalAlignment.has(component[j])) { + var actualNodes = this.dummyToNodeForHorizontalAlignment.get(component[j]); + sum += actualNodes.length * this.idToNodeMap.get(actualNodes[0]).displacementY; + count += actualNodes.length; + } else { + sum += this.idToNodeMap.get(component[j]).displacementY; + count++; + } + } + var averageDisplacement = sum / count; + for (var j = 0; j < component.length; j++) { + if (this.dummyToNodeForHorizontalAlignment.has(component[j])) { + this.dummyToNodeForHorizontalAlignment.get(component[j]).forEach(function (nodeId) { + self.idToNodeMap.get(nodeId).displacementY = averageDisplacement; + }); + } else { + this.idToNodeMap.get(component[j]).displacementY = averageDisplacement; + } + } + } + } + } + } +}; + +CoSELayout.prototype.calculateNodesToApplyGravitationTo = function () { + var nodeList = []; + var graph; + + var graphs = this.graphManager.getGraphs(); + var size = graphs.length; + var i; + for (i = 0; i < size; i++) { + graph = graphs[i]; + + graph.updateConnected(); + + if (!graph.isConnected) { + nodeList = nodeList.concat(graph.getNodes()); + } + } + + return nodeList; +}; + +CoSELayout.prototype.createBendpoints = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + var visited = new Set(); + var i; + for (i = 0; i < edges.length; i++) { + var edge = edges[i]; + + if (!visited.has(edge)) { + var source = edge.getSource(); + var target = edge.getTarget(); + + if (source == target) { + edge.getBendpoints().push(new PointD()); + edge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(edge); + visited.add(edge); + } else { + var edgeList = []; + + edgeList = edgeList.concat(source.getEdgeListToNode(target)); + edgeList = edgeList.concat(target.getEdgeListToNode(source)); + + if (!visited.has(edgeList[0])) { + if (edgeList.length > 1) { + var k; + for (k = 0; k < edgeList.length; k++) { + var multiEdge = edgeList[k]; + multiEdge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(multiEdge); + } + } + edgeList.forEach(function (edge) { + visited.add(edge); + }); + } + } + } + + if (visited.size == edges.length) { + break; + } + } +}; + +CoSELayout.prototype.positionNodesRadially = function (forest) { + // We tile the trees to a grid row by row; first tree starts at (0,0) + var currentStartingPoint = new Point(0, 0); + var numberOfColumns = Math.ceil(Math.sqrt(forest.length)); + var height = 0; + var currentY = 0; + var currentX = 0; + var point = new PointD(0, 0); + + for (var i = 0; i < forest.length; i++) { + if (i % numberOfColumns == 0) { + // Start of a new row, make the x coordinate 0, increment the + // y coordinate with the max height of the previous row + currentX = 0; + currentY = height; + + if (i != 0) { + currentY += CoSEConstants.DEFAULT_COMPONENT_SEPERATION; + } + + height = 0; + } + + var tree = forest[i]; + + // Find the center of the tree + var centerNode = Layout.findCenterOfTree(tree); + + // Set the staring point of the next tree + currentStartingPoint.x = currentX; + currentStartingPoint.y = currentY; + + // Do a radial layout starting with the center + point = CoSELayout.radialLayout(tree, centerNode, currentStartingPoint); + + if (point.y > height) { + height = Math.floor(point.y); + } + + currentX = Math.floor(point.x + CoSEConstants.DEFAULT_COMPONENT_SEPERATION); + } + + this.transform(new PointD(LayoutConstants.WORLD_CENTER_X - point.x / 2, LayoutConstants.WORLD_CENTER_Y - point.y / 2)); +}; + +CoSELayout.radialLayout = function (tree, centerNode, startingPoint) { + var radialSep = Math.max(this.maxDiagonalInTree(tree), CoSEConstants.DEFAULT_RADIAL_SEPARATION); + CoSELayout.branchRadialLayout(centerNode, null, 0, 359, 0, radialSep); + var bounds = LGraph.calculateBounds(tree); + + var transform = new Transform(); + transform.setDeviceOrgX(bounds.getMinX()); + transform.setDeviceOrgY(bounds.getMinY()); + transform.setWorldOrgX(startingPoint.x); + transform.setWorldOrgY(startingPoint.y); + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + node.transform(transform); + } + + var bottomRight = new PointD(bounds.getMaxX(), bounds.getMaxY()); + + return transform.inverseTransformPoint(bottomRight); +}; + +CoSELayout.branchRadialLayout = function (node, parentOfNode, startAngle, endAngle, distance, radialSeparation) { + // First, position this node by finding its angle. + var halfInterval = (endAngle - startAngle + 1) / 2; + + if (halfInterval < 0) { + halfInterval += 180; + } + + var nodeAngle = (halfInterval + startAngle) % 360; + var teta = nodeAngle * IGeometry.TWO_PI / 360; + + // Make polar to java cordinate conversion. + var cos_teta = Math.cos(teta); + var x_ = distance * Math.cos(teta); + var y_ = distance * Math.sin(teta); + + node.setCenter(x_, y_); + + // Traverse all neighbors of this node and recursively call this + // function. + var neighborEdges = []; + neighborEdges = neighborEdges.concat(node.getEdges()); + var childCount = neighborEdges.length; + + if (parentOfNode != null) { + childCount--; + } + + var branchCount = 0; + + var incEdgesCount = neighborEdges.length; + var startIndex; + + var edges = node.getEdgesBetween(parentOfNode); + + // If there are multiple edges, prune them until there remains only one + // edge. + while (edges.length > 1) { + //neighborEdges.remove(edges.remove(0)); + var temp = edges[0]; + edges.splice(0, 1); + var index = neighborEdges.indexOf(temp); + if (index >= 0) { + neighborEdges.splice(index, 1); + } + incEdgesCount--; + childCount--; + } + + if (parentOfNode != null) { + //assert edges.length == 1; + startIndex = (neighborEdges.indexOf(edges[0]) + 1) % incEdgesCount; + } else { + startIndex = 0; + } + + var stepAngle = Math.abs(endAngle - startAngle) / childCount; + + for (var i = startIndex; branchCount != childCount; i = ++i % incEdgesCount) { + var currentNeighbor = neighborEdges[i].getOtherEnd(node); + + // Don't back traverse to root node in current tree. + if (currentNeighbor == parentOfNode) { + continue; + } + + var childStartAngle = (startAngle + branchCount * stepAngle) % 360; + var childEndAngle = (childStartAngle + stepAngle) % 360; + + CoSELayout.branchRadialLayout(currentNeighbor, node, childStartAngle, childEndAngle, distance + radialSeparation, radialSeparation); + + branchCount++; + } +}; + +CoSELayout.maxDiagonalInTree = function (tree) { + var maxDiagonal = Integer.MIN_VALUE; + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + var diagonal = node.getDiagonal(); + + if (diagonal > maxDiagonal) { + maxDiagonal = diagonal; + } + } + + return maxDiagonal; +}; + +CoSELayout.prototype.calcRepulsionRange = function () { + // formula is 2 x (level + 1) x idealEdgeLength + return 2 * (this.level + 1) * this.idealEdgeLength; +}; + +// Tiling methods + +// Group zero degree members whose parents are not to be tiled, create dummy parents where needed and fill memberGroups by their dummp parent id's +CoSELayout.prototype.groupZeroDegreeMembers = function () { + var self = this; + // array of [parent_id x oneDegreeNode_id] + var tempMemberGroups = {}; // A temporary map of parent node and its zero degree members + this.memberGroups = {}; // A map of dummy parent node and its zero degree members whose parents are not to be tiled + this.idToDummyNode = {}; // A map of id to dummy node + + var zeroDegree = []; // List of zero degree nodes whose parents are not to be tiled + var allNodes = this.graphManager.getAllNodes(); + + // Fill zero degree list + for (var i = 0; i < allNodes.length; i++) { + var node = allNodes[i]; + var parent = node.getParent(); + // If a node has zero degree and its parent is not to be tiled if exists add that node to zeroDegres list + if (this.getNodeDegreeWithChildren(node) === 0 && (parent.id == undefined || !this.getToBeTiled(parent))) { + zeroDegree.push(node); + } + } + + // Create a map of parent node and its zero degree members + for (var i = 0; i < zeroDegree.length; i++) { + var node = zeroDegree[i]; // Zero degree node itself + var p_id = node.getParent().id; // Parent id + + if (typeof tempMemberGroups[p_id] === "undefined") tempMemberGroups[p_id] = []; + + tempMemberGroups[p_id] = tempMemberGroups[p_id].concat(node); // Push node to the list belongs to its parent in tempMemberGroups + } + + // If there are at least two nodes at a level, create a dummy compound for them + Object.keys(tempMemberGroups).forEach(function (p_id) { + if (tempMemberGroups[p_id].length > 1) { + var dummyCompoundId = "DummyCompound_" + p_id; // The id of dummy compound which will be created soon + self.memberGroups[dummyCompoundId] = tempMemberGroups[p_id]; // Add dummy compound to memberGroups + + var parent = tempMemberGroups[p_id][0].getParent(); // The parent of zero degree nodes will be the parent of new dummy compound + + // Create a dummy compound with calculated id + var dummyCompound = new CoSENode(self.graphManager); + dummyCompound.id = dummyCompoundId; + dummyCompound.paddingLeft = parent.paddingLeft || 0; + dummyCompound.paddingRight = parent.paddingRight || 0; + dummyCompound.paddingBottom = parent.paddingBottom || 0; + dummyCompound.paddingTop = parent.paddingTop || 0; + + self.idToDummyNode[dummyCompoundId] = dummyCompound; + + var dummyParentGraph = self.getGraphManager().add(self.newGraph(), dummyCompound); + var parentGraph = parent.getChild(); + + // Add dummy compound to parent the graph + parentGraph.add(dummyCompound); + + // For each zero degree node in this level remove it from its parent graph and add it to the graph of dummy parent + for (var i = 0; i < tempMemberGroups[p_id].length; i++) { + var node = tempMemberGroups[p_id][i]; + + parentGraph.remove(node); + dummyParentGraph.add(node); + } + } + }); +}; + +CoSELayout.prototype.clearCompounds = function () { + var childGraphMap = {}; + var idToNode = {}; + + // Get compound ordering by finding the inner one first + this.performDFSOnCompounds(); + + for (var i = 0; i < this.compoundOrder.length; i++) { + + idToNode[this.compoundOrder[i].id] = this.compoundOrder[i]; + childGraphMap[this.compoundOrder[i].id] = [].concat(this.compoundOrder[i].getChild().getNodes()); + + // Remove children of compounds + this.graphManager.remove(this.compoundOrder[i].getChild()); + this.compoundOrder[i].child = null; + } + + this.graphManager.resetAllNodes(); + + // Tile the removed children + this.tileCompoundMembers(childGraphMap, idToNode); +}; + +CoSELayout.prototype.clearZeroDegreeMembers = function () { + var self = this; + var tiledZeroDegreePack = this.tiledZeroDegreePack = []; + + Object.keys(this.memberGroups).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound + + tiledZeroDegreePack[id] = self.tileNodes(self.memberGroups[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + // Set the width and height of the dummy compound as calculated + compoundNode.rect.width = tiledZeroDegreePack[id].width; + compoundNode.rect.height = tiledZeroDegreePack[id].height; + compoundNode.setCenter(tiledZeroDegreePack[id].centerX, tiledZeroDegreePack[id].centerY); + + // compound left and top margings for labels + // when node labels are included, these values may be set to different values below and are used in tilingPostLayout, + // otherwise they stay as zero + compoundNode.labelMarginLeft = 0; + compoundNode.labelMarginTop = 0; + + // Update compound bounds considering its label properties and set label margins for left and top + if (CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { + + var width = compoundNode.rect.width; + var height = compoundNode.rect.height; + + if (compoundNode.labelWidth) { + if (compoundNode.labelPosHorizontal == "left") { + compoundNode.rect.x -= compoundNode.labelWidth; + compoundNode.setWidth(width + compoundNode.labelWidth); + compoundNode.labelMarginLeft = compoundNode.labelWidth; + } else if (compoundNode.labelPosHorizontal == "center" && compoundNode.labelWidth > width) { + compoundNode.rect.x -= (compoundNode.labelWidth - width) / 2; + compoundNode.setWidth(compoundNode.labelWidth); + compoundNode.labelMarginLeft = (compoundNode.labelWidth - width) / 2; + } else if (compoundNode.labelPosHorizontal == "right") { + compoundNode.setWidth(width + compoundNode.labelWidth); + } + } + + if (compoundNode.labelHeight) { + if (compoundNode.labelPosVertical == "top") { + compoundNode.rect.y -= compoundNode.labelHeight; + compoundNode.setHeight(height + compoundNode.labelHeight); + compoundNode.labelMarginTop = compoundNode.labelHeight; + } else if (compoundNode.labelPosVertical == "center" && compoundNode.labelHeight > height) { + compoundNode.rect.y -= (compoundNode.labelHeight - height) / 2; + compoundNode.setHeight(compoundNode.labelHeight); + compoundNode.labelMarginTop = (compoundNode.labelHeight - height) / 2; + } else if (compoundNode.labelPosVertical == "bottom") { + compoundNode.setHeight(height + compoundNode.labelHeight); + } + } + } + }); +}; + +CoSELayout.prototype.repopulateCompounds = function () { + for (var i = this.compoundOrder.length - 1; i >= 0; i--) { + var lCompoundNode = this.compoundOrder[i]; + var id = lCompoundNode.id; + var horizontalMargin = lCompoundNode.paddingLeft; + var verticalMargin = lCompoundNode.paddingTop; + var labelMarginLeft = lCompoundNode.labelMarginLeft; + var labelMarginTop = lCompoundNode.labelMarginTop; + + this.adjustLocations(this.tiledMemberPack[id], lCompoundNode.rect.x, lCompoundNode.rect.y, horizontalMargin, verticalMargin, labelMarginLeft, labelMarginTop); + } +}; + +CoSELayout.prototype.repopulateZeroDegreeMembers = function () { + var self = this; + var tiledPack = this.tiledZeroDegreePack; + + Object.keys(tiledPack).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound by its id + var horizontalMargin = compoundNode.paddingLeft; + var verticalMargin = compoundNode.paddingTop; + var labelMarginLeft = compoundNode.labelMarginLeft; + var labelMarginTop = compoundNode.labelMarginTop; + + // Adjust the positions of nodes wrt its compound + self.adjustLocations(tiledPack[id], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin, labelMarginLeft, labelMarginTop); + }); +}; + +CoSELayout.prototype.getToBeTiled = function (node) { + var id = node.id; + //firstly check the previous results + if (this.toBeTiled[id] != null) { + return this.toBeTiled[id]; + } + + //only compound nodes are to be tiled + var childGraph = node.getChild(); + if (childGraph == null) { + this.toBeTiled[id] = false; + return false; + } + + var children = childGraph.getNodes(); // Get the children nodes + + //a compound node is not to be tiled if all of its compound children are not to be tiled + for (var i = 0; i < children.length; i++) { + var theChild = children[i]; + + if (this.getNodeDegree(theChild) > 0) { + this.toBeTiled[id] = false; + return false; + } + + //pass the children not having the compound structure + if (theChild.getChild() == null) { + this.toBeTiled[theChild.id] = false; + continue; + } + + if (!this.getToBeTiled(theChild)) { + this.toBeTiled[id] = false; + return false; + } + } + this.toBeTiled[id] = true; + return true; +}; + +// Get degree of a node depending of its edges and independent of its children +CoSELayout.prototype.getNodeDegree = function (node) { + var id = node.id; + var edges = node.getEdges(); + var degree = 0; + + // For the edges connected + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + if (edge.getSource().id !== edge.getTarget().id) { + degree = degree + 1; + } + } + return degree; +}; + +// Get degree of a node with its children +CoSELayout.prototype.getNodeDegreeWithChildren = function (node) { + var degree = this.getNodeDegree(node); + if (node.getChild() == null) { + return degree; + } + var children = node.getChild().getNodes(); + for (var i = 0; i < children.length; i++) { + var child = children[i]; + degree += this.getNodeDegreeWithChildren(child); + } + return degree; +}; + +CoSELayout.prototype.performDFSOnCompounds = function () { + this.compoundOrder = []; + this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes()); +}; + +CoSELayout.prototype.fillCompexOrderByDFS = function (children) { + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.getChild() != null) { + this.fillCompexOrderByDFS(child.getChild().getNodes()); + } + if (this.getToBeTiled(child)) { + this.compoundOrder.push(child); + } + } +}; + +/** +* This method places each zero degree member wrt given (x,y) coordinates (top left). +*/ +CoSELayout.prototype.adjustLocations = function (organization, x, y, compoundHorizontalMargin, compoundVerticalMargin, compoundLabelMarginLeft, compoundLabelMarginTop) { + x += compoundHorizontalMargin + compoundLabelMarginLeft; + y += compoundVerticalMargin + compoundLabelMarginTop; + + var left = x; + + for (var i = 0; i < organization.rows.length; i++) { + var row = organization.rows[i]; + x = left; + var maxHeight = 0; + + for (var j = 0; j < row.length; j++) { + var lnode = row[j]; + + lnode.rect.x = x; // + lnode.rect.width / 2; + lnode.rect.y = y; // + lnode.rect.height / 2; + + x += lnode.rect.width + organization.horizontalPadding; + + if (lnode.rect.height > maxHeight) maxHeight = lnode.rect.height; + } + + y += maxHeight + organization.verticalPadding; + } +}; + +CoSELayout.prototype.tileCompoundMembers = function (childGraphMap, idToNode) { + var self = this; + this.tiledMemberPack = []; + + Object.keys(childGraphMap).forEach(function (id) { + // Get the compound node + var compoundNode = idToNode[id]; + + self.tiledMemberPack[id] = self.tileNodes(childGraphMap[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + compoundNode.rect.width = self.tiledMemberPack[id].width; + compoundNode.rect.height = self.tiledMemberPack[id].height; + compoundNode.setCenter(self.tiledMemberPack[id].centerX, self.tiledMemberPack[id].centerY); + + // compound left and top margings for labels + // when node labels are included, these values may be set to different values below and are used in tilingPostLayout, + // otherwise they stay as zero + compoundNode.labelMarginLeft = 0; + compoundNode.labelMarginTop = 0; + + // Update compound bounds considering its label properties and set label margins for left and top + if (CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { + + var width = compoundNode.rect.width; + var height = compoundNode.rect.height; + + if (compoundNode.labelWidth) { + if (compoundNode.labelPosHorizontal == "left") { + compoundNode.rect.x -= compoundNode.labelWidth; + compoundNode.setWidth(width + compoundNode.labelWidth); + compoundNode.labelMarginLeft = compoundNode.labelWidth; + } else if (compoundNode.labelPosHorizontal == "center" && compoundNode.labelWidth > width) { + compoundNode.rect.x -= (compoundNode.labelWidth - width) / 2; + compoundNode.setWidth(compoundNode.labelWidth); + compoundNode.labelMarginLeft = (compoundNode.labelWidth - width) / 2; + } else if (compoundNode.labelPosHorizontal == "right") { + compoundNode.setWidth(width + compoundNode.labelWidth); + } + } + + if (compoundNode.labelHeight) { + if (compoundNode.labelPosVertical == "top") { + compoundNode.rect.y -= compoundNode.labelHeight; + compoundNode.setHeight(height + compoundNode.labelHeight); + compoundNode.labelMarginTop = compoundNode.labelHeight; + } else if (compoundNode.labelPosVertical == "center" && compoundNode.labelHeight > height) { + compoundNode.rect.y -= (compoundNode.labelHeight - height) / 2; + compoundNode.setHeight(compoundNode.labelHeight); + compoundNode.labelMarginTop = (compoundNode.labelHeight - height) / 2; + } else if (compoundNode.labelPosVertical == "bottom") { + compoundNode.setHeight(height + compoundNode.labelHeight); + } + } + } + }); +}; + +CoSELayout.prototype.tileNodes = function (nodes, minWidth) { + var horizontalOrg = this.tileNodesByFavoringDim(nodes, minWidth, true); + var verticalOrg = this.tileNodesByFavoringDim(nodes, minWidth, false); + + var horizontalRatio = this.getOrgRatio(horizontalOrg); + var verticalRatio = this.getOrgRatio(verticalOrg); + var bestOrg; + + // the best ratio is the one that is closer to 1 since the ratios are already normalized + // and the best organization is the one that has the best ratio + if (verticalRatio < horizontalRatio) { + bestOrg = verticalOrg; + } else { + bestOrg = horizontalOrg; + } + + return bestOrg; +}; + +// get the width/height ratio of the organization that is normalized so that it will not be less than 1 +CoSELayout.prototype.getOrgRatio = function (organization) { + // get dimensions and calculate the initial ratio + var width = organization.width; + var height = organization.height; + var ratio = width / height; + + // if the initial ratio is less then 1 then inverse it + if (ratio < 1) { + ratio = 1 / ratio; + } + + // return the normalized ratio + return ratio; +}; + +/* + * Calculates the ideal width for the rows. This method assumes that + * each node has the same sizes and calculates the ideal row width that + * approximates a square shaped complex accordingly. However, since nodes would + * have different sizes some rows would have different sizes and the resulting + * shape would not be an exact square. + */ +CoSELayout.prototype.calcIdealRowWidth = function (members, favorHorizontalDim) { + // To approximate a square shaped complex we need to make complex width equal to complex height. + // To achieve this we need to solve the following equation system for hc: + // (x + bx) * hc - bx = (y + by) * vc - by, hc * vc = n + // where x is the avarage width of the nodes, y is the avarage height of nodes + // bx and by are the buffer sizes in horizontal and vertical dimensions accordingly, + // hc and vc are the number of rows in horizontal and vertical dimensions + // n is number of members. + + var verticalPadding = CoSEConstants.TILING_PADDING_VERTICAL; + var horizontalPadding = CoSEConstants.TILING_PADDING_HORIZONTAL; + + // number of members + var membersSize = members.length; + + // sum of the width of all members + var totalWidth = 0; + + // sum of the height of all members + var totalHeight = 0; + + var maxWidth = 0; + + // traverse all members to calculate total width and total height and get the maximum members width + members.forEach(function (node) { + totalWidth += node.getWidth(); + totalHeight += node.getHeight(); + + if (node.getWidth() > maxWidth) { + maxWidth = node.getWidth(); + } + }); + + // average width of the members + var averageWidth = totalWidth / membersSize; + + // average height of the members + var averageHeight = totalHeight / membersSize; + + // solving the initial equation system for the hc yields the following second degree equation: + // hc^2 * (x+bx) + hc * (by - bx) - n * (y + by) = 0 + + // the delta value to solve the equation above for hc + var delta = Math.pow(verticalPadding - horizontalPadding, 2) + 4 * (averageWidth + horizontalPadding) * (averageHeight + verticalPadding) * membersSize; + + // solve the equation using delta value to calculate the horizontal count + // that represents the number of nodes in an ideal row + var horizontalCountDouble = (horizontalPadding - verticalPadding + Math.sqrt(delta)) / (2 * (averageWidth + horizontalPadding)); + // round the calculated horizontal count up or down according to the favored dimension + var horizontalCount; + + if (favorHorizontalDim) { + horizontalCount = Math.ceil(horizontalCountDouble); + // if horizontalCount count is not a float value then both of rounding to floor and ceil + // will yield the same values. Instead of repeating the same calculation try going up + // while favoring horizontal dimension in such cases + if (horizontalCount == horizontalCountDouble) { + horizontalCount++; + } + } else { + horizontalCount = Math.floor(horizontalCountDouble); + } + + // ideal width to be calculated + var idealWidth = horizontalCount * (averageWidth + horizontalPadding) - horizontalPadding; + + // if max width is bigger than calculated ideal width reset ideal width to it + if (maxWidth > idealWidth) { + idealWidth = maxWidth; + } + + // add the left-right margins to the ideal row width + idealWidth += horizontalPadding * 2; + + // return the ideal row width1 + return idealWidth; +}; + +CoSELayout.prototype.tileNodesByFavoringDim = function (nodes, minWidth, favorHorizontalDim) { + var verticalPadding = CoSEConstants.TILING_PADDING_VERTICAL; + var horizontalPadding = CoSEConstants.TILING_PADDING_HORIZONTAL; + var tilingCompareBy = CoSEConstants.TILING_COMPARE_BY; + var organization = { + rows: [], + rowWidth: [], + rowHeight: [], + width: 0, + height: minWidth, // assume minHeight equals to minWidth + verticalPadding: verticalPadding, + horizontalPadding: horizontalPadding, + centerX: 0, + centerY: 0 + }; + + if (tilingCompareBy) { + organization.idealRowWidth = this.calcIdealRowWidth(nodes, favorHorizontalDim); + } + + var getNodeArea = function getNodeArea(n) { + return n.rect.width * n.rect.height; + }; + + var areaCompareFcn = function areaCompareFcn(n1, n2) { + return getNodeArea(n2) - getNodeArea(n1); + }; + + // Sort the nodes in descending order of their areas + nodes.sort(function (n1, n2) { + var cmpBy = areaCompareFcn; + if (organization.idealRowWidth) { + cmpBy = tilingCompareBy; + return cmpBy(n1.id, n2.id); + } + return cmpBy(n1, n2); + }); + + // Create the organization -> calculate compound center + var sumCenterX = 0; + var sumCenterY = 0; + for (var i = 0; i < nodes.length; i++) { + var lNode = nodes[i]; + + sumCenterX += lNode.getCenterX(); + sumCenterY += lNode.getCenterY(); + } + + organization.centerX = sumCenterX / nodes.length; + organization.centerY = sumCenterY / nodes.length; + + // Create the organization -> tile members + for (var i = 0; i < nodes.length; i++) { + var lNode = nodes[i]; + + if (organization.rows.length == 0) { + this.insertNodeToRow(organization, lNode, 0, minWidth); + } else if (this.canAddHorizontal(organization, lNode.rect.width, lNode.rect.height)) { + var rowIndex = organization.rows.length - 1; + if (!organization.idealRowWidth) { + rowIndex = this.getShortestRowIndex(organization); + } + this.insertNodeToRow(organization, lNode, rowIndex, minWidth); + } else { + this.insertNodeToRow(organization, lNode, organization.rows.length, minWidth); + } + + this.shiftToLastRow(organization); + } + + return organization; +}; + +CoSELayout.prototype.insertNodeToRow = function (organization, node, rowIndex, minWidth) { + var minCompoundSize = minWidth; + + // Add new row if needed + if (rowIndex == organization.rows.length) { + var secondDimension = []; + + organization.rows.push(secondDimension); + organization.rowWidth.push(minCompoundSize); + organization.rowHeight.push(0); + } + + // Update row width + var w = organization.rowWidth[rowIndex] + node.rect.width; + + if (organization.rows[rowIndex].length > 0) { + w += organization.horizontalPadding; + } + + organization.rowWidth[rowIndex] = w; + // Update compound width + if (organization.width < w) { + organization.width = w; + } + + // Update height + var h = node.rect.height; + if (rowIndex > 0) h += organization.verticalPadding; + + var extraHeight = 0; + if (h > organization.rowHeight[rowIndex]) { + extraHeight = organization.rowHeight[rowIndex]; + organization.rowHeight[rowIndex] = h; + extraHeight = organization.rowHeight[rowIndex] - extraHeight; + } + + organization.height += extraHeight; + + // Insert node + organization.rows[rowIndex].push(node); +}; + +//Scans the rows of an organization and returns the one with the min width +CoSELayout.prototype.getShortestRowIndex = function (organization) { + var r = -1; + var min = Number.MAX_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + if (organization.rowWidth[i] < min) { + r = i; + min = organization.rowWidth[i]; + } + } + return r; +}; + +//Scans the rows of an organization and returns the one with the max width +CoSELayout.prototype.getLongestRowIndex = function (organization) { + var r = -1; + var max = Number.MIN_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + + if (organization.rowWidth[i] > max) { + r = i; + max = organization.rowWidth[i]; + } + } + + return r; +}; + +/** +* This method checks whether adding extra width to the organization violates +* the aspect ratio(1) or not. +*/ +CoSELayout.prototype.canAddHorizontal = function (organization, extraWidth, extraHeight) { + + // if there is an ideal row width specified use it instead of checking the aspect ratio + if (organization.idealRowWidth) { + var lastRowIndex = organization.rows.length - 1; + var lastRowWidth = organization.rowWidth[lastRowIndex]; + + // check and return if ideal row width will be exceed if the node is added to the row + return lastRowWidth + extraWidth + organization.horizontalPadding <= organization.idealRowWidth; + } + + var sri = this.getShortestRowIndex(organization); + + if (sri < 0) { + return true; + } + + var min = organization.rowWidth[sri]; + + if (min + organization.horizontalPadding + extraWidth <= organization.width) return true; + + var hDiff = 0; + + // Adding to an existing row + if (organization.rowHeight[sri] < extraHeight) { + if (sri > 0) hDiff = extraHeight + organization.verticalPadding - organization.rowHeight[sri]; + } + + var add_to_row_ratio; + if (organization.width - min >= extraWidth + organization.horizontalPadding) { + add_to_row_ratio = (organization.height + hDiff) / (min + extraWidth + organization.horizontalPadding); + } else { + add_to_row_ratio = (organization.height + hDiff) / organization.width; + } + + // Adding a new row for this node + hDiff = extraHeight + organization.verticalPadding; + var add_new_row_ratio; + if (organization.width < extraWidth) { + add_new_row_ratio = (organization.height + hDiff) / extraWidth; + } else { + add_new_row_ratio = (organization.height + hDiff) / organization.width; + } + + if (add_new_row_ratio < 1) add_new_row_ratio = 1 / add_new_row_ratio; + + if (add_to_row_ratio < 1) add_to_row_ratio = 1 / add_to_row_ratio; + + return add_to_row_ratio < add_new_row_ratio; +}; + +//If moving the last node from the longest row and adding it to the last +//row makes the bounding box smaller, do it. +CoSELayout.prototype.shiftToLastRow = function (organization) { + var longest = this.getLongestRowIndex(organization); + var last = organization.rowWidth.length - 1; + var row = organization.rows[longest]; + var node = row[row.length - 1]; + + var diff = node.width + organization.horizontalPadding; + + // Check if there is enough space on the last row + if (organization.width - organization.rowWidth[last] > diff && longest != last) { + // Remove the last element of the longest row + row.splice(-1, 1); + + // Push it to the last row + organization.rows[last].push(node); + + organization.rowWidth[longest] = organization.rowWidth[longest] - diff; + organization.rowWidth[last] = organization.rowWidth[last] + diff; + organization.width = organization.rowWidth[instance.getLongestRowIndex(organization)]; + + // Update heights of the organization + var maxHeight = Number.MIN_VALUE; + for (var i = 0; i < row.length; i++) { + if (row[i].height > maxHeight) maxHeight = row[i].height; + } + if (longest > 0) maxHeight += organization.verticalPadding; + + var prevTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + + organization.rowHeight[longest] = maxHeight; + if (organization.rowHeight[last] < node.height + organization.verticalPadding) organization.rowHeight[last] = node.height + organization.verticalPadding; + + var finalTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + organization.height += finalTotal - prevTotal; + + this.shiftToLastRow(organization); + } +}; + +CoSELayout.prototype.tilingPreLayout = function () { + if (CoSEConstants.TILE) { + // Find zero degree nodes and create a compound for each level + this.groupZeroDegreeMembers(); + // Tile and clear children of each compound + this.clearCompounds(); + // Separately tile and clear zero degree nodes for each level + this.clearZeroDegreeMembers(); + } +}; + +CoSELayout.prototype.tilingPostLayout = function () { + if (CoSEConstants.TILE) { + this.repopulateZeroDegreeMembers(); + this.repopulateCompounds(); + } +}; + +// ----------------------------------------------------------------------------- +// Section: Tree Reduction methods +// ----------------------------------------------------------------------------- +// Reduce trees +CoSELayout.prototype.reduceTrees = function () { + var prunedNodesAll = []; + var containsLeaf = true; + var node; + + while (containsLeaf) { + var allNodes = this.graphManager.getAllNodes(); + var prunedNodesInStepTemp = []; + containsLeaf = false; + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + if (node.getEdges().length == 1 && !node.getEdges()[0].isInterGraph && node.getChild() == null) { + if (CoSEConstants.PURE_INCREMENTAL) { + var otherEnd = node.getEdges()[0].getOtherEnd(node); + var relativePosition = new DimensionD(node.getCenterX() - otherEnd.getCenterX(), node.getCenterY() - otherEnd.getCenterY()); + prunedNodesInStepTemp.push([node, node.getEdges()[0], node.getOwner(), relativePosition]); + } else { + prunedNodesInStepTemp.push([node, node.getEdges()[0], node.getOwner()]); + } + containsLeaf = true; + } + } + if (containsLeaf == true) { + var prunedNodesInStep = []; + for (var j = 0; j < prunedNodesInStepTemp.length; j++) { + if (prunedNodesInStepTemp[j][0].getEdges().length == 1) { + prunedNodesInStep.push(prunedNodesInStepTemp[j]); + prunedNodesInStepTemp[j][0].getOwner().remove(prunedNodesInStepTemp[j][0]); + } + } + prunedNodesAll.push(prunedNodesInStep); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); + } + } + this.prunedNodesAll = prunedNodesAll; +}; + +// Grow tree one step +CoSELayout.prototype.growTree = function (prunedNodesAll) { + var lengthOfPrunedNodesInStep = prunedNodesAll.length; + var prunedNodesInStep = prunedNodesAll[lengthOfPrunedNodesInStep - 1]; + + var nodeData; + for (var i = 0; i < prunedNodesInStep.length; i++) { + nodeData = prunedNodesInStep[i]; + + this.findPlaceforPrunedNode(nodeData); + + nodeData[2].add(nodeData[0]); + nodeData[2].add(nodeData[1], nodeData[1].source, nodeData[1].target); + } + + prunedNodesAll.splice(prunedNodesAll.length - 1, 1); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); +}; + +// Find an appropriate position to replace pruned node, this method can be improved +CoSELayout.prototype.findPlaceforPrunedNode = function (nodeData) { + + var gridForPrunedNode; + var nodeToConnect; + var prunedNode = nodeData[0]; + if (prunedNode == nodeData[1].source) { + nodeToConnect = nodeData[1].target; + } else { + nodeToConnect = nodeData[1].source; + } + + if (CoSEConstants.PURE_INCREMENTAL) { + prunedNode.setCenter(nodeToConnect.getCenterX() + nodeData[3].getWidth(), nodeToConnect.getCenterY() + nodeData[3].getHeight()); + } else { + var startGridX = nodeToConnect.startX; + var finishGridX = nodeToConnect.finishX; + var startGridY = nodeToConnect.startY; + var finishGridY = nodeToConnect.finishY; + + var upNodeCount = 0; + var downNodeCount = 0; + var rightNodeCount = 0; + var leftNodeCount = 0; + var controlRegions = [upNodeCount, rightNodeCount, downNodeCount, leftNodeCount]; + + if (startGridY > 0) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[0] += this.grid[i][startGridY - 1].length + this.grid[i][startGridY].length - 1; + } + } + if (finishGridX < this.grid.length - 1) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[1] += this.grid[finishGridX + 1][i].length + this.grid[finishGridX][i].length - 1; + } + } + if (finishGridY < this.grid[0].length - 1) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[2] += this.grid[i][finishGridY + 1].length + this.grid[i][finishGridY].length - 1; + } + } + if (startGridX > 0) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[3] += this.grid[startGridX - 1][i].length + this.grid[startGridX][i].length - 1; + } + } + var min = Integer.MAX_VALUE; + var minCount; + var minIndex; + for (var j = 0; j < controlRegions.length; j++) { + if (controlRegions[j] < min) { + min = controlRegions[j]; + minCount = 1; + minIndex = j; + } else if (controlRegions[j] == min) { + minCount++; + } + } + + if (minCount == 3 && min == 0) { + if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[2] == 0) { + gridForPrunedNode = 1; + } else if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 0; + } else if (controlRegions[0] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 3; + } else if (controlRegions[1] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 2; + } + } else if (minCount == 2 && min == 0) { + var random = Math.floor(Math.random() * 2); + if (controlRegions[0] == 0 && controlRegions[1] == 0) { + ; + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 1; + } + } else if (controlRegions[0] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[0] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 3; + } + } else if (controlRegions[1] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[1] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 3; + } + } else { + if (random == 0) { + gridForPrunedNode = 2; + } else { + gridForPrunedNode = 3; + } + } + } else if (minCount == 4 && min == 0) { + var random = Math.floor(Math.random() * 4); + gridForPrunedNode = random; + } else { + gridForPrunedNode = minIndex; + } + + if (gridForPrunedNode == 0) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() - nodeToConnect.getHeight() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getHeight() / 2); + } else if (gridForPrunedNode == 1) { + prunedNode.setCenter(nodeToConnect.getCenterX() + nodeToConnect.getWidth() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } else if (gridForPrunedNode == 2) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() + nodeToConnect.getHeight() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getHeight() / 2); + } else { + prunedNode.setCenter(nodeToConnect.getCenterX() - nodeToConnect.getWidth() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } + } +}; + +module.exports = CoSELayout; + +/***/ }), + +/***/ 991: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var FDLayoutNode = __webpack_require__(551).FDLayoutNode; +var IMath = __webpack_require__(551).IMath; + +function CoSENode(gm, loc, size, vNode) { + FDLayoutNode.call(this, gm, loc, size, vNode); +} + +CoSENode.prototype = Object.create(FDLayoutNode.prototype); +for (var prop in FDLayoutNode) { + CoSENode[prop] = FDLayoutNode[prop]; +} + +CoSENode.prototype.calculateDisplacement = function () { + var layout = this.graphManager.getLayout(); + // this check is for compound nodes that contain fixed nodes + if (this.getChild() != null && this.fixedNodeWeight) { + this.displacementX += layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.fixedNodeWeight; + this.displacementY += layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.fixedNodeWeight; + } else { + this.displacementX += layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren; + this.displacementY += layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren; + } + + if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementX); + } + + if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementY); + } + + // non-empty compound node, propogate movement to children as well + if (this.child && this.child.getNodes().length > 0) { + this.propogateDisplacementToChildren(this.displacementX, this.displacementY); + } +}; + +CoSENode.prototype.propogateDisplacementToChildren = function (dX, dY) { + var nodes = this.getChild().getNodes(); + var node; + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + if (node.getChild() == null) { + node.displacementX += dX; + node.displacementY += dY; + } else { + node.propogateDisplacementToChildren(dX, dY); + } + } +}; + +CoSENode.prototype.move = function () { + var layout = this.graphManager.getLayout(); + + // a simple node or an empty compound node, move it + if (this.child == null || this.child.getNodes().length == 0) { + this.moveBy(this.displacementX, this.displacementY); + + layout.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY); + } + + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + this.displacementX = 0; + this.displacementY = 0; +}; + +CoSENode.prototype.setPred1 = function (pred1) { + this.pred1 = pred1; +}; + +CoSENode.prototype.getPred1 = function () { + return pred1; +}; + +CoSENode.prototype.getPred2 = function () { + return pred2; +}; + +CoSENode.prototype.setNext = function (next) { + this.next = next; +}; + +CoSENode.prototype.getNext = function () { + return next; +}; + +CoSENode.prototype.setProcessed = function (processed) { + this.processed = processed; +}; + +CoSENode.prototype.isProcessed = function () { + return processed; +}; + +module.exports = CoSENode; + +/***/ }), + +/***/ 902: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var CoSEConstants = __webpack_require__(806); +var LinkedList = __webpack_require__(551).LinkedList; +var Matrix = __webpack_require__(551).Matrix; +var SVD = __webpack_require__(551).SVD; + +function ConstraintHandler() {} + +ConstraintHandler.handleConstraints = function (layout) { + // let layout = this.graphManager.getLayout(); + + // get constraints from layout + var constraints = {}; + constraints.fixedNodeConstraint = layout.constraints.fixedNodeConstraint; + constraints.alignmentConstraint = layout.constraints.alignmentConstraint; + constraints.relativePlacementConstraint = layout.constraints.relativePlacementConstraint; + + var idToNodeMap = new Map(); + var nodeIndexes = new Map(); + var xCoords = []; + var yCoords = []; + + var allNodes = layout.getAllNodes(); + var index = 0; + // fill index map and coordinates + for (var i = 0; i < allNodes.length; i++) { + var node = allNodes[i]; + if (node.getChild() == null) { + nodeIndexes.set(node.id, index++); + xCoords.push(node.getCenterX()); + yCoords.push(node.getCenterY()); + idToNodeMap.set(node.id, node); + } + } + + // if there exists relative placement constraint without gap value, set it to default + if (constraints.relativePlacementConstraint) { + constraints.relativePlacementConstraint.forEach(function (constraint) { + if (!constraint.gap && constraint.gap != 0) { + if (constraint.left) { + constraint.gap = CoSEConstants.DEFAULT_EDGE_LENGTH + idToNodeMap.get(constraint.left).getWidth() / 2 + idToNodeMap.get(constraint.right).getWidth() / 2; + } else { + constraint.gap = CoSEConstants.DEFAULT_EDGE_LENGTH + idToNodeMap.get(constraint.top).getHeight() / 2 + idToNodeMap.get(constraint.bottom).getHeight() / 2; + } + } + }); + } + + /* auxiliary functions */ + + // calculate difference between two position objects + var calculatePositionDiff = function calculatePositionDiff(pos1, pos2) { + return { x: pos1.x - pos2.x, y: pos1.y - pos2.y }; + }; + + // calculate average position of the nodes + var calculateAvgPosition = function calculateAvgPosition(nodeIdSet) { + var xPosSum = 0; + var yPosSum = 0; + nodeIdSet.forEach(function (nodeId) { + xPosSum += xCoords[nodeIndexes.get(nodeId)]; + yPosSum += yCoords[nodeIndexes.get(nodeId)]; + }); + + return { x: xPosSum / nodeIdSet.size, y: yPosSum / nodeIdSet.size }; + }; + + // find an appropriate positioning for the nodes in a given graph according to relative placement constraints + // this function also takes the fixed nodes and alignment constraints into account + // graph: dag to be evaluated, direction: "horizontal" or "vertical", + // fixedNodes: set of fixed nodes to consider during evaluation, dummyPositions: appropriate coordinates of the dummy nodes + var findAppropriatePositionForRelativePlacement = function findAppropriatePositionForRelativePlacement(graph, direction, fixedNodes, dummyPositions, componentSources) { + + // find union of two sets + function setUnion(setA, setB) { + var union = new Set(setA); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = setB[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var elem = _step.value; + + union.add(elem); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return union; + } + + // find indegree count for each node + var inDegrees = new Map(); + + graph.forEach(function (value, key) { + inDegrees.set(key, 0); + }); + graph.forEach(function (value, key) { + value.forEach(function (adjacent) { + inDegrees.set(adjacent.id, inDegrees.get(adjacent.id) + 1); + }); + }); + + var positionMap = new Map(); // keeps the position for each node + var pastMap = new Map(); // keeps the predecessors(past) of a node + var queue = new LinkedList(); + inDegrees.forEach(function (value, key) { + if (value == 0) { + queue.push(key); + if (!fixedNodes) { + if (direction == "horizontal") { + positionMap.set(key, nodeIndexes.has(key) ? xCoords[nodeIndexes.get(key)] : dummyPositions.get(key)); + } else { + positionMap.set(key, nodeIndexes.has(key) ? yCoords[nodeIndexes.get(key)] : dummyPositions.get(key)); + } + } + } else { + positionMap.set(key, Number.NEGATIVE_INFINITY); + } + if (fixedNodes) { + pastMap.set(key, new Set([key])); + } + }); + + // align sources of each component in enforcement phase + if (fixedNodes) { + componentSources.forEach(function (component) { + var fixedIds = []; + component.forEach(function (nodeId) { + if (fixedNodes.has(nodeId)) { + fixedIds.push(nodeId); + } + }); + if (fixedIds.length > 0) { + var position = 0; + fixedIds.forEach(function (fixedId) { + if (direction == "horizontal") { + positionMap.set(fixedId, nodeIndexes.has(fixedId) ? xCoords[nodeIndexes.get(fixedId)] : dummyPositions.get(fixedId)); + position += positionMap.get(fixedId); + } else { + positionMap.set(fixedId, nodeIndexes.has(fixedId) ? yCoords[nodeIndexes.get(fixedId)] : dummyPositions.get(fixedId)); + position += positionMap.get(fixedId); + } + }); + position = position / fixedIds.length; + component.forEach(function (nodeId) { + if (!fixedNodes.has(nodeId)) { + positionMap.set(nodeId, position); + } + }); + } else { + var _position = 0; + component.forEach(function (nodeId) { + if (direction == "horizontal") { + _position += nodeIndexes.has(nodeId) ? xCoords[nodeIndexes.get(nodeId)] : dummyPositions.get(nodeId); + } else { + _position += nodeIndexes.has(nodeId) ? yCoords[nodeIndexes.get(nodeId)] : dummyPositions.get(nodeId); + } + }); + _position = _position / component.length; + component.forEach(function (nodeId) { + positionMap.set(nodeId, _position); + }); + } + }); + } + + // calculate positions of the nodes + + var _loop = function _loop() { + var currentNode = queue.shift(); + var neighbors = graph.get(currentNode); + neighbors.forEach(function (neighbor) { + if (positionMap.get(neighbor.id) < positionMap.get(currentNode) + neighbor.gap) { + if (fixedNodes && fixedNodes.has(neighbor.id)) { + var fixedPosition = void 0; + if (direction == "horizontal") { + fixedPosition = nodeIndexes.has(neighbor.id) ? xCoords[nodeIndexes.get(neighbor.id)] : dummyPositions.get(neighbor.id); + } else { + fixedPosition = nodeIndexes.has(neighbor.id) ? yCoords[nodeIndexes.get(neighbor.id)] : dummyPositions.get(neighbor.id); + } + positionMap.set(neighbor.id, fixedPosition); // TODO: may do unnecessary work + if (fixedPosition < positionMap.get(currentNode) + neighbor.gap) { + var diff = positionMap.get(currentNode) + neighbor.gap - fixedPosition; + pastMap.get(currentNode).forEach(function (nodeId) { + positionMap.set(nodeId, positionMap.get(nodeId) - diff); + }); + } + } else { + positionMap.set(neighbor.id, positionMap.get(currentNode) + neighbor.gap); + } + } + inDegrees.set(neighbor.id, inDegrees.get(neighbor.id) - 1); + if (inDegrees.get(neighbor.id) == 0) { + queue.push(neighbor.id); + } + if (fixedNodes) { + pastMap.set(neighbor.id, setUnion(pastMap.get(currentNode), pastMap.get(neighbor.id))); + } + }); + }; + + while (queue.length != 0) { + _loop(); + } + + // readjust position of the nodes after enforcement + if (fixedNodes) { + // find indegree count for each node + var sinkNodes = new Set(); + + graph.forEach(function (value, key) { + if (value.length == 0) { + sinkNodes.add(key); + } + }); + + var _components = []; + pastMap.forEach(function (value, key) { + if (sinkNodes.has(key)) { + var isFixedComponent = false; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var nodeId = _step2.value; + + if (fixedNodes.has(nodeId)) { + isFixedComponent = true; + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + if (!isFixedComponent) { + var isExist = false; + var existAt = void 0; + _components.forEach(function (component, index) { + if (component.has([].concat(_toConsumableArray(value))[0])) { + isExist = true; + existAt = index; + } + }); + if (!isExist) { + _components.push(new Set(value)); + } else { + value.forEach(function (ele) { + _components[existAt].add(ele); + }); + } + } + } + }); + + _components.forEach(function (component, index) { + var minBefore = Number.POSITIVE_INFINITY; + var minAfter = Number.POSITIVE_INFINITY; + var maxBefore = Number.NEGATIVE_INFINITY; + var maxAfter = Number.NEGATIVE_INFINITY; + + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = component[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var nodeId = _step3.value; + + var posBefore = void 0; + if (direction == "horizontal") { + posBefore = nodeIndexes.has(nodeId) ? xCoords[nodeIndexes.get(nodeId)] : dummyPositions.get(nodeId); + } else { + posBefore = nodeIndexes.has(nodeId) ? yCoords[nodeIndexes.get(nodeId)] : dummyPositions.get(nodeId); + } + var posAfter = positionMap.get(nodeId); + if (posBefore < minBefore) { + minBefore = posBefore; + } + if (posBefore > maxBefore) { + maxBefore = posBefore; + } + if (posAfter < minAfter) { + minAfter = posAfter; + } + if (posAfter > maxAfter) { + maxAfter = posAfter; + } + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + + var diff = (minBefore + maxBefore) / 2 - (minAfter + maxAfter) / 2; + + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + + try { + for (var _iterator4 = component[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var _nodeId = _step4.value; + + positionMap.set(_nodeId, positionMap.get(_nodeId) + diff); + } + } catch (err) { + _didIteratorError4 = true; + _iteratorError4 = err; + } finally { + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } + } + } + }); + } + + return positionMap; + }; + + // find transformation based on rel. placement constraints if there are both alignment and rel. placement constraints + // or if there are only rel. placement contraints where the largest component isn't sufficiently large + var applyReflectionForRelativePlacement = function applyReflectionForRelativePlacement(relativePlacementConstraints) { + // variables to count votes + var reflectOnY = 0, + notReflectOnY = 0; + var reflectOnX = 0, + notReflectOnX = 0; + + relativePlacementConstraints.forEach(function (constraint) { + if (constraint.left) { + xCoords[nodeIndexes.get(constraint.left)] - xCoords[nodeIndexes.get(constraint.right)] >= 0 ? reflectOnY++ : notReflectOnY++; + } else { + yCoords[nodeIndexes.get(constraint.top)] - yCoords[nodeIndexes.get(constraint.bottom)] >= 0 ? reflectOnX++ : notReflectOnX++; + } + }); + + if (reflectOnY > notReflectOnY && reflectOnX > notReflectOnX) { + for (var _i = 0; _i < nodeIndexes.size; _i++) { + xCoords[_i] = -1 * xCoords[_i]; + yCoords[_i] = -1 * yCoords[_i]; + } + } else if (reflectOnY > notReflectOnY) { + for (var _i2 = 0; _i2 < nodeIndexes.size; _i2++) { + xCoords[_i2] = -1 * xCoords[_i2]; + } + } else if (reflectOnX > notReflectOnX) { + for (var _i3 = 0; _i3 < nodeIndexes.size; _i3++) { + yCoords[_i3] = -1 * yCoords[_i3]; + } + } + }; + + // find weakly connected components in undirected graph + var findComponents = function findComponents(graph) { + // find weakly connected components in dag + var components = []; + var queue = new LinkedList(); + var visited = new Set(); + var count = 0; + + graph.forEach(function (value, key) { + if (!visited.has(key)) { + components[count] = []; + var _currentNode = key; + queue.push(_currentNode); + visited.add(_currentNode); + components[count].push(_currentNode); + + while (queue.length != 0) { + _currentNode = queue.shift(); + var neighbors = graph.get(_currentNode); + neighbors.forEach(function (neighbor) { + if (!visited.has(neighbor.id)) { + queue.push(neighbor.id); + visited.add(neighbor.id); + components[count].push(neighbor.id); + } + }); + } + count++; + } + }); + return components; + }; + + // return undirected version of given dag + var dagToUndirected = function dagToUndirected(dag) { + var undirected = new Map(); + + dag.forEach(function (value, key) { + undirected.set(key, []); + }); + + dag.forEach(function (value, key) { + value.forEach(function (adjacent) { + undirected.get(key).push(adjacent); + undirected.get(adjacent.id).push({ id: key, gap: adjacent.gap, direction: adjacent.direction }); + }); + }); + + return undirected; + }; + + // return reversed (directions inverted) version of given dag + var dagToReversed = function dagToReversed(dag) { + var reversed = new Map(); + + dag.forEach(function (value, key) { + reversed.set(key, []); + }); + + dag.forEach(function (value, key) { + value.forEach(function (adjacent) { + reversed.get(adjacent.id).push({ id: key, gap: adjacent.gap, direction: adjacent.direction }); + }); + }); + + return reversed; + }; + + /**** apply transformation to the initial draft layout to better align with constrained nodes ****/ + // solve the Orthogonal Procrustean Problem to rotate and/or reflect initial draft layout + // here we follow the solution in Chapter 20.2 of Borg, I. & Groenen, P. (2005) Modern Multidimensional Scaling: Theory and Applications + + /* construct source and target configurations */ + + var targetMatrix = []; // A - target configuration + var sourceMatrix = []; // B - source configuration + var standardTransformation = false; // false for no transformation, true for standart (Procrustes) transformation (rotation and/or reflection) + var reflectionType = false; // false/true for reflection check, 'reflectOnX', 'reflectOnY' or 'reflectOnBoth' for reflection type if necessary + var fixedNodes = new Set(); + var dag = new Map(); // adjacency list to keep directed acyclic graph (dag) that consists of relative placement constraints + var dagUndirected = new Map(); // undirected version of the dag + var components = []; // weakly connected components + + // fill fixedNodes collection to use later + if (constraints.fixedNodeConstraint) { + constraints.fixedNodeConstraint.forEach(function (nodeData) { + fixedNodes.add(nodeData.nodeId); + }); + } + + // construct dag from relative placement constraints + if (constraints.relativePlacementConstraint) { + // construct both directed and undirected version of the dag + constraints.relativePlacementConstraint.forEach(function (constraint) { + if (constraint.left) { + if (dag.has(constraint.left)) { + dag.get(constraint.left).push({ id: constraint.right, gap: constraint.gap, direction: "horizontal" }); + } else { + dag.set(constraint.left, [{ id: constraint.right, gap: constraint.gap, direction: "horizontal" }]); + } + if (!dag.has(constraint.right)) { + dag.set(constraint.right, []); + } + } else { + if (dag.has(constraint.top)) { + dag.get(constraint.top).push({ id: constraint.bottom, gap: constraint.gap, direction: "vertical" }); + } else { + dag.set(constraint.top, [{ id: constraint.bottom, gap: constraint.gap, direction: "vertical" }]); + } + if (!dag.has(constraint.bottom)) { + dag.set(constraint.bottom, []); + } + } + }); + + dagUndirected = dagToUndirected(dag); + components = findComponents(dagUndirected); + } + + if (CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING) { + // first check fixed node constraint + if (constraints.fixedNodeConstraint && constraints.fixedNodeConstraint.length > 1) { + constraints.fixedNodeConstraint.forEach(function (nodeData, i) { + targetMatrix[i] = [nodeData.position.x, nodeData.position.y]; + sourceMatrix[i] = [xCoords[nodeIndexes.get(nodeData.nodeId)], yCoords[nodeIndexes.get(nodeData.nodeId)]]; + }); + standardTransformation = true; + } else if (constraints.alignmentConstraint) { + (function () { + // then check alignment constraint + var count = 0; + if (constraints.alignmentConstraint.vertical) { + var verticalAlign = constraints.alignmentConstraint.vertical; + + var _loop2 = function _loop2(_i4) { + var alignmentSet = new Set(); + verticalAlign[_i4].forEach(function (nodeId) { + alignmentSet.add(nodeId); + }); + var intersection = new Set([].concat(_toConsumableArray(alignmentSet)).filter(function (x) { + return fixedNodes.has(x); + })); + var xPos = void 0; + if (intersection.size > 0) xPos = xCoords[nodeIndexes.get(intersection.values().next().value)];else xPos = calculateAvgPosition(alignmentSet).x; + + verticalAlign[_i4].forEach(function (nodeId) { + targetMatrix[count] = [xPos, yCoords[nodeIndexes.get(nodeId)]]; + sourceMatrix[count] = [xCoords[nodeIndexes.get(nodeId)], yCoords[nodeIndexes.get(nodeId)]]; + count++; + }); + }; + + for (var _i4 = 0; _i4 < verticalAlign.length; _i4++) { + _loop2(_i4); + } + standardTransformation = true; + } + if (constraints.alignmentConstraint.horizontal) { + var horizontalAlign = constraints.alignmentConstraint.horizontal; + + var _loop3 = function _loop3(_i5) { + var alignmentSet = new Set(); + horizontalAlign[_i5].forEach(function (nodeId) { + alignmentSet.add(nodeId); + }); + var intersection = new Set([].concat(_toConsumableArray(alignmentSet)).filter(function (x) { + return fixedNodes.has(x); + })); + var yPos = void 0; + if (intersection.size > 0) yPos = xCoords[nodeIndexes.get(intersection.values().next().value)];else yPos = calculateAvgPosition(alignmentSet).y; + + horizontalAlign[_i5].forEach(function (nodeId) { + targetMatrix[count] = [xCoords[nodeIndexes.get(nodeId)], yPos]; + sourceMatrix[count] = [xCoords[nodeIndexes.get(nodeId)], yCoords[nodeIndexes.get(nodeId)]]; + count++; + }); + }; + + for (var _i5 = 0; _i5 < horizontalAlign.length; _i5++) { + _loop3(_i5); + } + standardTransformation = true; + } + if (constraints.relativePlacementConstraint) { + reflectionType = true; + } + })(); + } else if (constraints.relativePlacementConstraint) { + // finally check relative placement constraint + // find largest component in dag + var largestComponentSize = 0; + var largestComponentIndex = 0; + for (var _i6 = 0; _i6 < components.length; _i6++) { + if (components[_i6].length > largestComponentSize) { + largestComponentSize = components[_i6].length; + largestComponentIndex = _i6; + } + } + // if largest component isn't dominant, then take the votes for reflection + if (largestComponentSize < dagUndirected.size / 2) { + applyReflectionForRelativePlacement(constraints.relativePlacementConstraint); + standardTransformation = false; + reflectionType = false; + } else { + // use largest component for transformation + // construct horizontal and vertical subgraphs in the largest component + var subGraphOnHorizontal = new Map(); + var subGraphOnVertical = new Map(); + var constraintsInlargestComponent = []; + + components[largestComponentIndex].forEach(function (nodeId) { + dag.get(nodeId).forEach(function (adjacent) { + if (adjacent.direction == "horizontal") { + if (subGraphOnHorizontal.has(nodeId)) { + subGraphOnHorizontal.get(nodeId).push(adjacent); + } else { + subGraphOnHorizontal.set(nodeId, [adjacent]); + } + if (!subGraphOnHorizontal.has(adjacent.id)) { + subGraphOnHorizontal.set(adjacent.id, []); + } + constraintsInlargestComponent.push({ left: nodeId, right: adjacent.id }); + } else { + if (subGraphOnVertical.has(nodeId)) { + subGraphOnVertical.get(nodeId).push(adjacent); + } else { + subGraphOnVertical.set(nodeId, [adjacent]); + } + if (!subGraphOnVertical.has(adjacent.id)) { + subGraphOnVertical.set(adjacent.id, []); + } + constraintsInlargestComponent.push({ top: nodeId, bottom: adjacent.id }); + } + }); + }); + + applyReflectionForRelativePlacement(constraintsInlargestComponent); + reflectionType = false; + + // calculate appropriate positioning for subgraphs + var positionMapHorizontal = findAppropriatePositionForRelativePlacement(subGraphOnHorizontal, "horizontal"); + var positionMapVertical = findAppropriatePositionForRelativePlacement(subGraphOnVertical, "vertical"); + + // construct source and target configuration + components[largestComponentIndex].forEach(function (nodeId, i) { + sourceMatrix[i] = [xCoords[nodeIndexes.get(nodeId)], yCoords[nodeIndexes.get(nodeId)]]; + targetMatrix[i] = []; + if (positionMapHorizontal.has(nodeId)) { + targetMatrix[i][0] = positionMapHorizontal.get(nodeId); + } else { + targetMatrix[i][0] = xCoords[nodeIndexes.get(nodeId)]; + } + if (positionMapVertical.has(nodeId)) { + targetMatrix[i][1] = positionMapVertical.get(nodeId); + } else { + targetMatrix[i][1] = yCoords[nodeIndexes.get(nodeId)]; + } + }); + + standardTransformation = true; + } + } + + // if transformation is required, then calculate and apply transformation matrix + if (standardTransformation) { + /* calculate transformation matrix */ + var transformationMatrix = void 0; + var targetMatrixTranspose = Matrix.transpose(targetMatrix); // A' + var sourceMatrixTranspose = Matrix.transpose(sourceMatrix); // B' + + // centralize transpose matrices + for (var _i7 = 0; _i7 < targetMatrixTranspose.length; _i7++) { + targetMatrixTranspose[_i7] = Matrix.multGamma(targetMatrixTranspose[_i7]); + sourceMatrixTranspose[_i7] = Matrix.multGamma(sourceMatrixTranspose[_i7]); + } + + // do actual calculation for transformation matrix + var tempMatrix = Matrix.multMat(targetMatrixTranspose, Matrix.transpose(sourceMatrixTranspose)); // tempMatrix = A'B + var SVDResult = SVD.svd(tempMatrix); // SVD(A'B) = USV', svd function returns U, S and V + transformationMatrix = Matrix.multMat(SVDResult.V, Matrix.transpose(SVDResult.U)); // transformationMatrix = T = VU' + + /* apply found transformation matrix to obtain final draft layout */ + for (var _i8 = 0; _i8 < nodeIndexes.size; _i8++) { + var temp1 = [xCoords[_i8], yCoords[_i8]]; + var temp2 = [transformationMatrix[0][0], transformationMatrix[1][0]]; + var temp3 = [transformationMatrix[0][1], transformationMatrix[1][1]]; + xCoords[_i8] = Matrix.dotProduct(temp1, temp2); + yCoords[_i8] = Matrix.dotProduct(temp1, temp3); + } + + // applied only both alignment and rel. placement constraints exist + if (reflectionType) { + applyReflectionForRelativePlacement(constraints.relativePlacementConstraint); + } + } + } + + if (CoSEConstants.ENFORCE_CONSTRAINTS) { + /**** enforce constraints on the transformed draft layout ****/ + + /* first enforce fixed node constraint */ + + if (constraints.fixedNodeConstraint && constraints.fixedNodeConstraint.length > 0) { + var translationAmount = { x: 0, y: 0 }; + constraints.fixedNodeConstraint.forEach(function (nodeData, i) { + var posInTheory = { x: xCoords[nodeIndexes.get(nodeData.nodeId)], y: yCoords[nodeIndexes.get(nodeData.nodeId)] }; + var posDesired = nodeData.position; + var posDiff = calculatePositionDiff(posDesired, posInTheory); + translationAmount.x += posDiff.x; + translationAmount.y += posDiff.y; + }); + translationAmount.x /= constraints.fixedNodeConstraint.length; + translationAmount.y /= constraints.fixedNodeConstraint.length; + + xCoords.forEach(function (value, i) { + xCoords[i] += translationAmount.x; + }); + + yCoords.forEach(function (value, i) { + yCoords[i] += translationAmount.y; + }); + + constraints.fixedNodeConstraint.forEach(function (nodeData) { + xCoords[nodeIndexes.get(nodeData.nodeId)] = nodeData.position.x; + yCoords[nodeIndexes.get(nodeData.nodeId)] = nodeData.position.y; + }); + } + + /* then enforce alignment constraint */ + + if (constraints.alignmentConstraint) { + if (constraints.alignmentConstraint.vertical) { + var xAlign = constraints.alignmentConstraint.vertical; + + var _loop4 = function _loop4(_i9) { + var alignmentSet = new Set(); + xAlign[_i9].forEach(function (nodeId) { + alignmentSet.add(nodeId); + }); + var intersection = new Set([].concat(_toConsumableArray(alignmentSet)).filter(function (x) { + return fixedNodes.has(x); + })); + var xPos = void 0; + if (intersection.size > 0) xPos = xCoords[nodeIndexes.get(intersection.values().next().value)];else xPos = calculateAvgPosition(alignmentSet).x; + + alignmentSet.forEach(function (nodeId) { + if (!fixedNodes.has(nodeId)) xCoords[nodeIndexes.get(nodeId)] = xPos; + }); + }; + + for (var _i9 = 0; _i9 < xAlign.length; _i9++) { + _loop4(_i9); + } + } + if (constraints.alignmentConstraint.horizontal) { + var yAlign = constraints.alignmentConstraint.horizontal; + + var _loop5 = function _loop5(_i10) { + var alignmentSet = new Set(); + yAlign[_i10].forEach(function (nodeId) { + alignmentSet.add(nodeId); + }); + var intersection = new Set([].concat(_toConsumableArray(alignmentSet)).filter(function (x) { + return fixedNodes.has(x); + })); + var yPos = void 0; + if (intersection.size > 0) yPos = yCoords[nodeIndexes.get(intersection.values().next().value)];else yPos = calculateAvgPosition(alignmentSet).y; + + alignmentSet.forEach(function (nodeId) { + if (!fixedNodes.has(nodeId)) yCoords[nodeIndexes.get(nodeId)] = yPos; + }); + }; + + for (var _i10 = 0; _i10 < yAlign.length; _i10++) { + _loop5(_i10); + } + } + } + + /* finally enforce relative placement constraint */ + + if (constraints.relativePlacementConstraint) { + (function () { + var nodeToDummyForVerticalAlignment = new Map(); + var nodeToDummyForHorizontalAlignment = new Map(); + var dummyToNodeForVerticalAlignment = new Map(); + var dummyToNodeForHorizontalAlignment = new Map(); + var dummyPositionsForVerticalAlignment = new Map(); + var dummyPositionsForHorizontalAlignment = new Map(); + var fixedNodesOnHorizontal = new Set(); + var fixedNodesOnVertical = new Set(); + + // fill maps and sets + fixedNodes.forEach(function (nodeId) { + fixedNodesOnHorizontal.add(nodeId); + fixedNodesOnVertical.add(nodeId); + }); + + if (constraints.alignmentConstraint) { + if (constraints.alignmentConstraint.vertical) { + var verticalAlignment = constraints.alignmentConstraint.vertical; + + var _loop6 = function _loop6(_i11) { + dummyToNodeForVerticalAlignment.set("dummy" + _i11, []); + verticalAlignment[_i11].forEach(function (nodeId) { + nodeToDummyForVerticalAlignment.set(nodeId, "dummy" + _i11); + dummyToNodeForVerticalAlignment.get("dummy" + _i11).push(nodeId); + if (fixedNodes.has(nodeId)) { + fixedNodesOnHorizontal.add("dummy" + _i11); + } + }); + dummyPositionsForVerticalAlignment.set("dummy" + _i11, xCoords[nodeIndexes.get(verticalAlignment[_i11][0])]); + }; + + for (var _i11 = 0; _i11 < verticalAlignment.length; _i11++) { + _loop6(_i11); + } + } + if (constraints.alignmentConstraint.horizontal) { + var horizontalAlignment = constraints.alignmentConstraint.horizontal; + + var _loop7 = function _loop7(_i12) { + dummyToNodeForHorizontalAlignment.set("dummy" + _i12, []); + horizontalAlignment[_i12].forEach(function (nodeId) { + nodeToDummyForHorizontalAlignment.set(nodeId, "dummy" + _i12); + dummyToNodeForHorizontalAlignment.get("dummy" + _i12).push(nodeId); + if (fixedNodes.has(nodeId)) { + fixedNodesOnVertical.add("dummy" + _i12); + } + }); + dummyPositionsForHorizontalAlignment.set("dummy" + _i12, yCoords[nodeIndexes.get(horizontalAlignment[_i12][0])]); + }; + + for (var _i12 = 0; _i12 < horizontalAlignment.length; _i12++) { + _loop7(_i12); + } + } + } + + // construct horizontal and vertical dags (subgraphs) from overall dag + var dagOnHorizontal = new Map(); + var dagOnVertical = new Map(); + + var _loop8 = function _loop8(nodeId) { + dag.get(nodeId).forEach(function (adjacent) { + var sourceId = void 0; + var targetNode = void 0; + if (adjacent["direction"] == "horizontal") { + sourceId = nodeToDummyForVerticalAlignment.get(nodeId) ? nodeToDummyForVerticalAlignment.get(nodeId) : nodeId; + if (nodeToDummyForVerticalAlignment.get(adjacent.id)) { + targetNode = { id: nodeToDummyForVerticalAlignment.get(adjacent.id), gap: adjacent.gap, direction: adjacent.direction }; + } else { + targetNode = adjacent; + } + if (dagOnHorizontal.has(sourceId)) { + dagOnHorizontal.get(sourceId).push(targetNode); + } else { + dagOnHorizontal.set(sourceId, [targetNode]); + } + if (!dagOnHorizontal.has(targetNode.id)) { + dagOnHorizontal.set(targetNode.id, []); + } + } else { + sourceId = nodeToDummyForHorizontalAlignment.get(nodeId) ? nodeToDummyForHorizontalAlignment.get(nodeId) : nodeId; + if (nodeToDummyForHorizontalAlignment.get(adjacent.id)) { + targetNode = { id: nodeToDummyForHorizontalAlignment.get(adjacent.id), gap: adjacent.gap, direction: adjacent.direction }; + } else { + targetNode = adjacent; + } + if (dagOnVertical.has(sourceId)) { + dagOnVertical.get(sourceId).push(targetNode); + } else { + dagOnVertical.set(sourceId, [targetNode]); + } + if (!dagOnVertical.has(targetNode.id)) { + dagOnVertical.set(targetNode.id, []); + } + } + }); + }; + + var _iteratorNormalCompletion5 = true; + var _didIteratorError5 = false; + var _iteratorError5 = undefined; + + try { + for (var _iterator5 = dag.keys()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { + var nodeId = _step5.value; + + _loop8(nodeId); + } + + // find source nodes of each component in horizontal and vertical dags + } catch (err) { + _didIteratorError5 = true; + _iteratorError5 = err; + } finally { + try { + if (!_iteratorNormalCompletion5 && _iterator5.return) { + _iterator5.return(); + } + } finally { + if (_didIteratorError5) { + throw _iteratorError5; + } + } + } + + var undirectedOnHorizontal = dagToUndirected(dagOnHorizontal); + var undirectedOnVertical = dagToUndirected(dagOnVertical); + var componentsOnHorizontal = findComponents(undirectedOnHorizontal); + var componentsOnVertical = findComponents(undirectedOnVertical); + var reversedDagOnHorizontal = dagToReversed(dagOnHorizontal); + var reversedDagOnVertical = dagToReversed(dagOnVertical); + var componentSourcesOnHorizontal = []; + var componentSourcesOnVertical = []; + + componentsOnHorizontal.forEach(function (component, index) { + componentSourcesOnHorizontal[index] = []; + component.forEach(function (nodeId) { + if (reversedDagOnHorizontal.get(nodeId).length == 0) { + componentSourcesOnHorizontal[index].push(nodeId); + } + }); + }); + + componentsOnVertical.forEach(function (component, index) { + componentSourcesOnVertical[index] = []; + component.forEach(function (nodeId) { + if (reversedDagOnVertical.get(nodeId).length == 0) { + componentSourcesOnVertical[index].push(nodeId); + } + }); + }); + + // calculate appropriate positioning for subgraphs + var positionMapHorizontal = findAppropriatePositionForRelativePlacement(dagOnHorizontal, "horizontal", fixedNodesOnHorizontal, dummyPositionsForVerticalAlignment, componentSourcesOnHorizontal); + var positionMapVertical = findAppropriatePositionForRelativePlacement(dagOnVertical, "vertical", fixedNodesOnVertical, dummyPositionsForHorizontalAlignment, componentSourcesOnVertical); + + // update positions of the nodes based on relative placement constraints + + var _loop9 = function _loop9(key) { + if (dummyToNodeForVerticalAlignment.get(key)) { + dummyToNodeForVerticalAlignment.get(key).forEach(function (nodeId) { + xCoords[nodeIndexes.get(nodeId)] = positionMapHorizontal.get(key); + }); + } else { + xCoords[nodeIndexes.get(key)] = positionMapHorizontal.get(key); + } + }; + + var _iteratorNormalCompletion6 = true; + var _didIteratorError6 = false; + var _iteratorError6 = undefined; + + try { + for (var _iterator6 = positionMapHorizontal.keys()[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { + var key = _step6.value; + + _loop9(key); + } + } catch (err) { + _didIteratorError6 = true; + _iteratorError6 = err; + } finally { + try { + if (!_iteratorNormalCompletion6 && _iterator6.return) { + _iterator6.return(); + } + } finally { + if (_didIteratorError6) { + throw _iteratorError6; + } + } + } + + var _loop10 = function _loop10(key) { + if (dummyToNodeForHorizontalAlignment.get(key)) { + dummyToNodeForHorizontalAlignment.get(key).forEach(function (nodeId) { + yCoords[nodeIndexes.get(nodeId)] = positionMapVertical.get(key); + }); + } else { + yCoords[nodeIndexes.get(key)] = positionMapVertical.get(key); + } + }; + + var _iteratorNormalCompletion7 = true; + var _didIteratorError7 = false; + var _iteratorError7 = undefined; + + try { + for (var _iterator7 = positionMapVertical.keys()[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { + var key = _step7.value; + + _loop10(key); + } + } catch (err) { + _didIteratorError7 = true; + _iteratorError7 = err; + } finally { + try { + if (!_iteratorNormalCompletion7 && _iterator7.return) { + _iterator7.return(); + } + } finally { + if (_didIteratorError7) { + throw _iteratorError7; + } + } + } + })(); + } + } + + // assign new coordinates to nodes after constraint handling + for (var _i13 = 0; _i13 < allNodes.length; _i13++) { + var _node = allNodes[_i13]; + if (_node.getChild() == null) { + _node.setCenter(xCoords[nodeIndexes.get(_node.id)], yCoords[nodeIndexes.get(_node.id)]); + } + } +}; + +module.exports = ConstraintHandler; + +/***/ }), + +/***/ 551: +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE__551__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module is referenced by other modules so it can't be inlined +/******/ var __webpack_exports__ = __webpack_require__(45); +/******/ +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/static/js/vendor/cytoscape-fcose.js b/static/js/vendor/cytoscape-fcose.js new file mode 100644 index 0000000..9ad4f6e --- /dev/null +++ b/static/js/vendor/cytoscape-fcose.js @@ -0,0 +1,1549 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("cose-base")); + else if(typeof define === 'function' && define.amd) + define(["cose-base"], factory); + else if(typeof exports === 'object') + exports["cytoscapeFcose"] = factory(require("cose-base")); + else + root["cytoscapeFcose"] = factory(root["coseBase"]); +})(this, function(__WEBPACK_EXTERNAL_MODULE__140__) { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 658: +/***/ ((module) => { + + + +// Simple, internal Object.assign() polyfill for options objects etc. + +module.exports = Object.assign != null ? Object.assign.bind(Object) : function (tgt) { + for (var _len = arguments.length, srcs = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + srcs[_key - 1] = arguments[_key]; + } + + srcs.forEach(function (src) { + Object.keys(src).forEach(function (k) { + return tgt[k] = src[k]; + }); + }); + + return tgt; +}; + +/***/ }), + +/***/ 548: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +/* + * Auxiliary functions + */ + +var LinkedList = __webpack_require__(140).layoutBase.LinkedList; + +var auxiliary = {}; + +// get the top most nodes +auxiliary.getTopMostNodes = function (nodes) { + var nodesMap = {}; + for (var i = 0; i < nodes.length; i++) { + nodesMap[nodes[i].id()] = true; + } + var roots = nodes.filter(function (ele, i) { + if (typeof ele === "number") { + ele = i; + } + var parent = ele.parent()[0]; + while (parent != null) { + if (nodesMap[parent.id()]) { + return false; + } + parent = parent.parent()[0]; + } + return true; + }); + + return roots; +}; + +// find disconnected components and create dummy nodes that connect them +auxiliary.connectComponents = function (cy, eles, topMostNodes, dummyNodes) { + var queue = new LinkedList(); + var visited = new Set(); + var visitedTopMostNodes = []; + var currentNeighbor = void 0; + var minDegreeNode = void 0; + var minDegree = void 0; + + var isConnected = false; + var count = 1; + var nodesConnectedToDummy = []; + var components = []; + + var _loop = function _loop() { + var cmpt = cy.collection(); + components.push(cmpt); + + var currentNode = topMostNodes[0]; + var childrenOfCurrentNode = cy.collection(); + childrenOfCurrentNode.merge(currentNode).merge(currentNode.descendants().intersection(eles)); + visitedTopMostNodes.push(currentNode); + + childrenOfCurrentNode.forEach(function (node) { + queue.push(node); + visited.add(node); + cmpt.merge(node); + }); + + var _loop2 = function _loop2() { + currentNode = queue.shift(); + + // Traverse all neighbors of this node + var neighborNodes = cy.collection(); + currentNode.neighborhood().nodes().forEach(function (node) { + if (eles.intersection(currentNode.edgesWith(node)).length > 0) { + neighborNodes.merge(node); + } + }); + + for (var i = 0; i < neighborNodes.length; i++) { + var neighborNode = neighborNodes[i]; + currentNeighbor = topMostNodes.intersection(neighborNode.union(neighborNode.ancestors())); + if (currentNeighbor != null && !visited.has(currentNeighbor[0])) { + var childrenOfNeighbor = currentNeighbor.union(currentNeighbor.descendants()); + + childrenOfNeighbor.forEach(function (node) { + queue.push(node); + visited.add(node); + cmpt.merge(node); + if (topMostNodes.has(node)) { + visitedTopMostNodes.push(node); + } + }); + } + } + }; + + while (queue.length != 0) { + _loop2(); + } + + cmpt.forEach(function (node) { + eles.intersection(node.connectedEdges()).forEach(function (e) { + // connectedEdges() usually cached + if (cmpt.has(e.source()) && cmpt.has(e.target())) { + // has() is cheap + cmpt.merge(e); + } + }); + }); + + if (visitedTopMostNodes.length == topMostNodes.length) { + isConnected = true; + } + + if (!isConnected || isConnected && count > 1) { + minDegreeNode = visitedTopMostNodes[0]; + minDegree = minDegreeNode.connectedEdges().length; + visitedTopMostNodes.forEach(function (node) { + if (node.connectedEdges().length < minDegree) { + minDegree = node.connectedEdges().length; + minDegreeNode = node; + } + }); + nodesConnectedToDummy.push(minDegreeNode.id()); + // TO DO: Check efficiency of this part + var temp = cy.collection(); + temp.merge(visitedTopMostNodes[0]); + visitedTopMostNodes.forEach(function (node) { + temp.merge(node); + }); + visitedTopMostNodes = []; + topMostNodes = topMostNodes.difference(temp); + count++; + } + }; + + do { + _loop(); + } while (!isConnected); + + if (dummyNodes) { + if (nodesConnectedToDummy.length > 0) { + dummyNodes.set('dummy' + (dummyNodes.size + 1), nodesConnectedToDummy); + } + } + return components; +}; + +// relocates componentResult to originalCenter if there is no fixedNodeConstraint +auxiliary.relocateComponent = function (originalCenter, componentResult, options) { + if (!options.fixedNodeConstraint) { + var minXCoord = Number.POSITIVE_INFINITY; + var maxXCoord = Number.NEGATIVE_INFINITY; + var minYCoord = Number.POSITIVE_INFINITY; + var maxYCoord = Number.NEGATIVE_INFINITY; + if (options.quality == "draft") { + // calculate current bounding box + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = componentResult.nodeIndexes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var _ref = _step.value; + + var _ref2 = _slicedToArray(_ref, 2); + + var key = _ref2[0]; + var value = _ref2[1]; + + var cyNode = options.cy.getElementById(key); + if (cyNode) { + var nodeBB = cyNode.boundingBox(); + var leftX = componentResult.xCoords[value] - nodeBB.w / 2; + var rightX = componentResult.xCoords[value] + nodeBB.w / 2; + var topY = componentResult.yCoords[value] - nodeBB.h / 2; + var bottomY = componentResult.yCoords[value] + nodeBB.h / 2; + + if (leftX < minXCoord) minXCoord = leftX; + if (rightX > maxXCoord) maxXCoord = rightX; + if (topY < minYCoord) minYCoord = topY; + if (bottomY > maxYCoord) maxYCoord = bottomY; + } + } + // find difference between current and original center + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + var diffOnX = originalCenter.x - (maxXCoord + minXCoord) / 2; + var diffOnY = originalCenter.y - (maxYCoord + minYCoord) / 2; + // move component to original center + componentResult.xCoords = componentResult.xCoords.map(function (x) { + return x + diffOnX; + }); + componentResult.yCoords = componentResult.yCoords.map(function (y) { + return y + diffOnY; + }); + } else { + // calculate current bounding box + Object.keys(componentResult).forEach(function (item) { + var node = componentResult[item]; + var leftX = node.getRect().x; + var rightX = node.getRect().x + node.getRect().width; + var topY = node.getRect().y; + var bottomY = node.getRect().y + node.getRect().height; + + if (leftX < minXCoord) minXCoord = leftX; + if (rightX > maxXCoord) maxXCoord = rightX; + if (topY < minYCoord) minYCoord = topY; + if (bottomY > maxYCoord) maxYCoord = bottomY; + }); + // find difference between current and original center + var _diffOnX = originalCenter.x - (maxXCoord + minXCoord) / 2; + var _diffOnY = originalCenter.y - (maxYCoord + minYCoord) / 2; + // move component to original center + Object.keys(componentResult).forEach(function (item) { + var node = componentResult[item]; + node.setCenter(node.getCenterX() + _diffOnX, node.getCenterY() + _diffOnY); + }); + } + } +}; + +auxiliary.calcBoundingBox = function (parentNode, xCoords, yCoords, nodeIndexes) { + // calculate bounds + var left = Number.MAX_SAFE_INTEGER; + var right = Number.MIN_SAFE_INTEGER; + var top = Number.MAX_SAFE_INTEGER; + var bottom = Number.MIN_SAFE_INTEGER; + var nodeLeft = void 0; + var nodeRight = void 0; + var nodeTop = void 0; + var nodeBottom = void 0; + + var nodes = parentNode.descendants().not(":parent"); + var s = nodes.length; + for (var i = 0; i < s; i++) { + var node = nodes[i]; + + nodeLeft = xCoords[nodeIndexes.get(node.id())] - node.width() / 2; + nodeRight = xCoords[nodeIndexes.get(node.id())] + node.width() / 2; + nodeTop = yCoords[nodeIndexes.get(node.id())] - node.height() / 2; + nodeBottom = yCoords[nodeIndexes.get(node.id())] + node.height() / 2; + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingBox = {}; + boundingBox.topLeftX = left; + boundingBox.topLeftY = top; + boundingBox.width = right - left; + boundingBox.height = bottom - top; + return boundingBox; +}; + +// This function finds and returns parent nodes whose all children are hidden +auxiliary.calcParentsWithoutChildren = function (cy, eles) { + var parentsWithoutChildren = cy.collection(); + eles.nodes(':parent').forEach(function (parent) { + var check = false; + parent.children().forEach(function (child) { + if (child.css('display') != 'none') { + check = true; + } + }); + if (!check) { + parentsWithoutChildren.merge(parent); + } + }); + + return parentsWithoutChildren; +}; + +module.exports = auxiliary; + +/***/ }), + +/***/ 816: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +/** + The implementation of the postprocessing part that applies CoSE layout over the spectral layout +*/ + +var aux = __webpack_require__(548); +var CoSELayout = __webpack_require__(140).CoSELayout; +var CoSENode = __webpack_require__(140).CoSENode; +var PointD = __webpack_require__(140).layoutBase.PointD; +var DimensionD = __webpack_require__(140).layoutBase.DimensionD; +var LayoutConstants = __webpack_require__(140).layoutBase.LayoutConstants; +var FDLayoutConstants = __webpack_require__(140).layoutBase.FDLayoutConstants; +var CoSEConstants = __webpack_require__(140).CoSEConstants; + +// main function that cose layout is processed +var coseLayout = function coseLayout(options, spectralResult) { + + var cy = options.cy; + var eles = options.eles; + var nodes = eles.nodes(); + var edges = eles.edges(); + + var nodeIndexes = void 0; + var xCoords = void 0; + var yCoords = void 0; + var idToLNode = {}; + + if (options.randomize) { + nodeIndexes = spectralResult["nodeIndexes"]; + xCoords = spectralResult["xCoords"]; + yCoords = spectralResult["yCoords"]; + } + + var isFn = function isFn(fn) { + return typeof fn === 'function'; + }; + + var optFn = function optFn(opt, ele) { + if (isFn(opt)) { + return opt(ele); + } else { + return opt; + } + }; + + /**** Postprocessing functions ****/ + + var parentsWithoutChildren = aux.calcParentsWithoutChildren(cy, eles); + + // transfer cytoscape nodes to cose nodes + var processChildrenList = function processChildrenList(parent, children, layout, options) { + var size = children.length; + for (var i = 0; i < size; i++) { + var theChild = children[i]; + var children_of_children = null; + if (theChild.intersection(parentsWithoutChildren).length == 0) { + children_of_children = theChild.children(); + } + var theNode = void 0; + + var dimensions = theChild.layoutDimensions({ + nodeDimensionsIncludeLabels: options.nodeDimensionsIncludeLabels + }); + + if (theChild.outerWidth() != null && theChild.outerHeight() != null) { + if (options.randomize) { + if (!theChild.isParent()) { + theNode = parent.add(new CoSENode(layout.graphManager, new PointD(xCoords[nodeIndexes.get(theChild.id())] - dimensions.w / 2, yCoords[nodeIndexes.get(theChild.id())] - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h)))); + } else { + var parentInfo = aux.calcBoundingBox(theChild, xCoords, yCoords, nodeIndexes); + if (theChild.intersection(parentsWithoutChildren).length == 0) { + theNode = parent.add(new CoSENode(layout.graphManager, new PointD(parentInfo.topLeftX, parentInfo.topLeftY), new DimensionD(parentInfo.width, parentInfo.height))); + } else { + // for the parentsWithoutChildren + theNode = parent.add(new CoSENode(layout.graphManager, new PointD(parentInfo.topLeftX, parentInfo.topLeftY), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h)))); + } + } + } else { + theNode = parent.add(new CoSENode(layout.graphManager, new PointD(theChild.position('x') - dimensions.w / 2, theChild.position('y') - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h)))); + } + } else { + theNode = parent.add(new CoSENode(this.graphManager)); + } + // Attach id to the layout node and repulsion value + theNode.id = theChild.data("id"); + theNode.nodeRepulsion = optFn(options.nodeRepulsion, theChild); + // Attach the paddings of cy node to layout node + theNode.paddingLeft = parseInt(theChild.css('padding')); + theNode.paddingTop = parseInt(theChild.css('padding')); + theNode.paddingRight = parseInt(theChild.css('padding')); + theNode.paddingBottom = parseInt(theChild.css('padding')); + + //Attach the label properties to both compound and simple nodes if labels will be included in node dimensions + //These properties will be used while updating bounds of compounds during iterations or tiling + //and will be used for simple nodes while transferring final positions to cytoscape + if (options.nodeDimensionsIncludeLabels) { + theNode.labelWidth = theChild.boundingBox({ includeLabels: true, includeNodes: false, includeOverlays: false }).w; + theNode.labelHeight = theChild.boundingBox({ includeLabels: true, includeNodes: false, includeOverlays: false }).h; + theNode.labelPosVertical = theChild.css("text-valign"); + theNode.labelPosHorizontal = theChild.css("text-halign"); + } + + // Map the layout node + idToLNode[theChild.data("id")] = theNode; + + if (isNaN(theNode.rect.x)) { + theNode.rect.x = 0; + } + + if (isNaN(theNode.rect.y)) { + theNode.rect.y = 0; + } + + if (children_of_children != null && children_of_children.length > 0) { + var theNewGraph = void 0; + theNewGraph = layout.getGraphManager().add(layout.newGraph(), theNode); + processChildrenList(theNewGraph, children_of_children, layout, options); + } + } + }; + + // transfer cytoscape edges to cose edges + var processEdges = function processEdges(layout, gm, edges) { + var idealLengthTotal = 0; + var edgeCount = 0; + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var sourceNode = idToLNode[edge.data("source")]; + var targetNode = idToLNode[edge.data("target")]; + if (sourceNode && targetNode && sourceNode !== targetNode && sourceNode.getEdgesBetween(targetNode).length == 0) { + var e1 = gm.add(layout.newEdge(), sourceNode, targetNode); + e1.id = edge.id(); + e1.idealLength = optFn(options.idealEdgeLength, edge); + e1.edgeElasticity = optFn(options.edgeElasticity, edge); + idealLengthTotal += e1.idealLength; + edgeCount++; + } + } + // we need to update the ideal edge length constant with the avg. ideal length value after processing edges + // in case there is no edge, use other options + if (options.idealEdgeLength != null) { + if (edgeCount > 0) CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = idealLengthTotal / edgeCount;else if (!isFn(options.idealEdgeLength)) // in case there is no edge, but option gives a value to use + CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = options.idealEdgeLength;else // in case there is no edge and we cannot get a value from option (because it's a function) + CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50; + // we need to update these constant values based on the ideal edge length constant + CoSEConstants.MIN_REPULSION_DIST = FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0; + CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + } + }; + + // transfer cytoscape constraints to cose layout + var processConstraints = function processConstraints(layout, options) { + // get nodes to be fixed + if (options.fixedNodeConstraint) { + layout.constraints["fixedNodeConstraint"] = options.fixedNodeConstraint; + } + // get nodes to be aligned + if (options.alignmentConstraint) { + layout.constraints["alignmentConstraint"] = options.alignmentConstraint; + } + // get nodes to be relatively placed + if (options.relativePlacementConstraint) { + layout.constraints["relativePlacementConstraint"] = options.relativePlacementConstraint; + } + }; + + /**** Apply postprocessing ****/ + if (options.nestingFactor != null) CoSEConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = options.nestingFactor; + if (options.gravity != null) CoSEConstants.DEFAULT_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = options.gravity; + if (options.numIter != null) CoSEConstants.MAX_ITERATIONS = FDLayoutConstants.MAX_ITERATIONS = options.numIter; + if (options.gravityRange != null) CoSEConstants.DEFAULT_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = options.gravityRange; + if (options.gravityCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = options.gravityCompound; + if (options.gravityRangeCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound; + if (options.initialEnergyOnIncremental != null) CoSEConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = options.initialEnergyOnIncremental; + + if (options.tilingCompareBy != null) CoSEConstants.TILING_COMPARE_BY = options.tilingCompareBy; + + if (options.quality == 'proof') LayoutConstants.QUALITY = 2;else LayoutConstants.QUALITY = 0; + + CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS = FDLayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = options.nodeDimensionsIncludeLabels; + CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = !options.randomize; + CoSEConstants.ANIMATE = FDLayoutConstants.ANIMATE = LayoutConstants.ANIMATE = options.animate; + CoSEConstants.TILE = options.tile; + CoSEConstants.TILING_PADDING_VERTICAL = typeof options.tilingPaddingVertical === 'function' ? options.tilingPaddingVertical.call() : options.tilingPaddingVertical; + CoSEConstants.TILING_PADDING_HORIZONTAL = typeof options.tilingPaddingHorizontal === 'function' ? options.tilingPaddingHorizontal.call() : options.tilingPaddingHorizontal; + + CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = true; + CoSEConstants.PURE_INCREMENTAL = !options.randomize; + LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = options.uniformNodeDimensions; + + // This part is for debug/demo purpose + if (options.step == "transformed") { + CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = true; + CoSEConstants.ENFORCE_CONSTRAINTS = false; + CoSEConstants.APPLY_LAYOUT = false; + } + if (options.step == "enforced") { + CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = false; + CoSEConstants.ENFORCE_CONSTRAINTS = true; + CoSEConstants.APPLY_LAYOUT = false; + } + if (options.step == "cose") { + CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = false; + CoSEConstants.ENFORCE_CONSTRAINTS = false; + CoSEConstants.APPLY_LAYOUT = true; + } + if (options.step == "all") { + if (options.randomize) CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = true;else CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = false; + CoSEConstants.ENFORCE_CONSTRAINTS = true; + CoSEConstants.APPLY_LAYOUT = true; + } + + if (options.fixedNodeConstraint || options.alignmentConstraint || options.relativePlacementConstraint) { + CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; + } else { + CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = true; + } + + var coseLayout = new CoSELayout(); + var gm = coseLayout.newGraphManager(); + + processChildrenList(gm.addRoot(), aux.getTopMostNodes(nodes), coseLayout, options); + processEdges(coseLayout, gm, edges); + processConstraints(coseLayout, options); + + coseLayout.runLayout(); + + return idToLNode; +}; + +module.exports = { coseLayout: coseLayout }; + +/***/ }), + +/***/ 212: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + The implementation of the fcose layout algorithm +*/ + +var assign = __webpack_require__(658); +var aux = __webpack_require__(548); + +var _require = __webpack_require__(657), + spectralLayout = _require.spectralLayout; + +var _require2 = __webpack_require__(816), + coseLayout = _require2.coseLayout; + +var defaults = Object.freeze({ + + // 'draft', 'default' or 'proof' + // - 'draft' only applies spectral layout + // - 'default' improves the quality with subsequent CoSE layout (fast cooling rate) + // - 'proof' improves the quality with subsequent CoSE layout (slow cooling rate) + quality: "default", + // Use random node positions at beginning of layout + // if this is set to false, then quality option must be "proof" + randomize: true, + // Whether or not to animate the layout + animate: true, + // Duration of animation in ms, if enabled + animationDuration: 1000, + // Easing of animation, if enabled + animationEasing: undefined, + // Fit the viewport to the repositioned nodes + fit: true, + // Padding around layout + padding: 30, + // Whether to include labels in node dimensions. Valid in "proof" quality + nodeDimensionsIncludeLabels: false, + // Whether or not simple nodes (non-compound nodes) are of uniform dimensions + uniformNodeDimensions: false, + // Whether to pack disconnected components - valid only if randomize: true + packComponents: true, + // Layout step - all, transformed, enforced, cose - for debug purpose only + step: "all", + + /* spectral layout options */ + + // False for random, true for greedy + samplingType: true, + // Sample size to construct distance matrix + sampleSize: 25, + // Separation amount between nodes + nodeSeparation: 75, + // Power iteration tolerance + piTol: 0.0000001, + + /* CoSE layout options */ + + // Node repulsion (non overlapping) multiplier + nodeRepulsion: function nodeRepulsion(node) { + return 4500; + }, + // Ideal edge (non nested) length + idealEdgeLength: function idealEdgeLength(edge) { + return 50; + }, + // Divisor to compute edge forces + edgeElasticity: function edgeElasticity(edge) { + return 0.45; + }, + // Nesting factor (multiplier) to compute ideal edge length for nested edges + nestingFactor: 0.1, + // Gravity force (constant) + gravity: 0.25, + // Maximum number of iterations to perform + numIter: 2500, + // For enabling tiling + tile: true, + // The function that specifies the criteria for comparing nodes while sorting them during tiling operation. + // Takes the node id as a parameter and the default tiling operation is perfomed when this option is not set. + tilingCompareBy: undefined, + // Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingVertical: 10, + // Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingHorizontal: 10, + // Gravity range (constant) for compounds + gravityRangeCompound: 1.5, + // Gravity force (constant) for compounds + gravityCompound: 1.0, + // Gravity range (constant) + gravityRange: 3.8, + // Initial cooling factor for incremental layout + initialEnergyOnIncremental: 0.3, + + /* constraint options */ + + // Fix required nodes to predefined positions + // [{nodeId: 'n1', position: {x: 100, y: 200}, {...}] + fixedNodeConstraint: undefined, + // Align required nodes in vertical/horizontal direction + // {vertical: [['n1', 'n2')], ['n3', 'n4']], horizontal: ['n2', 'n4']} + alignmentConstraint: undefined, + // Place two nodes relatively in vertical/horizontal direction + // [{top: 'n1', bottom: 'n2', gap: 100}, {left: 'n3', right: 'n4', gap: 75}] + relativePlacementConstraint: undefined, + + /* layout event callbacks */ + ready: function ready() {}, // on layoutready + stop: function stop() {} // on layoutstop +}); + +var Layout = function () { + function Layout(options) { + _classCallCheck(this, Layout); + + this.options = assign({}, defaults, options); + } + + _createClass(Layout, [{ + key: 'run', + value: function run() { + var layout = this; + var options = this.options; + var cy = options.cy; + var eles = options.eles; + + var spectralResult = []; + var xCoords = void 0; + var yCoords = void 0; + var coseResult = []; + var components = void 0; + var componentCenters = []; + + // basic validity check for constraint inputs + if (options.fixedNodeConstraint && (!Array.isArray(options.fixedNodeConstraint) || options.fixedNodeConstraint.length == 0)) { + options.fixedNodeConstraint = undefined; + } + + if (options.alignmentConstraint) { + if (options.alignmentConstraint.vertical && (!Array.isArray(options.alignmentConstraint.vertical) || options.alignmentConstraint.vertical.length == 0)) { + options.alignmentConstraint.vertical = undefined; + } + if (options.alignmentConstraint.horizontal && (!Array.isArray(options.alignmentConstraint.horizontal) || options.alignmentConstraint.horizontal.length == 0)) { + options.alignmentConstraint.horizontal = undefined; + } + } + + if (options.relativePlacementConstraint && (!Array.isArray(options.relativePlacementConstraint) || options.relativePlacementConstraint.length == 0)) { + options.relativePlacementConstraint = undefined; + } + + // if any constraint exists, set some options + var constraintExist = options.fixedNodeConstraint || options.alignmentConstraint || options.relativePlacementConstraint; + if (constraintExist) { + // constraints work with these options + options.tile = false; + options.packComponents = false; + } + + // decide component packing is enabled or not + var layUtil = void 0; + var packingEnabled = false; + if (cy.layoutUtilities && options.packComponents) { + layUtil = cy.layoutUtilities("get"); + if (!layUtil) layUtil = cy.layoutUtilities(); + packingEnabled = true; + } + + if (eles.nodes().length > 0) { + // if packing is not enabled, perform layout on the whole graph + if (!packingEnabled) { + // store component center + var boundingBox = options.eles.boundingBox(); + componentCenters.push({ x: boundingBox.x1 + boundingBox.w / 2, y: boundingBox.y1 + boundingBox.h / 2 }); + // apply spectral layout + if (options.randomize) { + var result = spectralLayout(options); + spectralResult.push(result); + } + // apply cose layout as postprocessing + if (options.quality == "default" || options.quality == "proof") { + coseResult.push(coseLayout(options, spectralResult[0])); + aux.relocateComponent(componentCenters[0], coseResult[0], options); // relocate center to original position + } else { + aux.relocateComponent(componentCenters[0], spectralResult[0], options); // relocate center to original position + } + } else { + // packing is enabled + var topMostNodes = aux.getTopMostNodes(options.eles.nodes()); + components = aux.connectComponents(cy, options.eles, topMostNodes); + // store component centers + components.forEach(function (component) { + var boundingBox = component.boundingBox(); + componentCenters.push({ x: boundingBox.x1 + boundingBox.w / 2, y: boundingBox.y1 + boundingBox.h / 2 }); + }); + + //send each component to spectral layout if randomized + if (options.randomize) { + components.forEach(function (component) { + options.eles = component; + spectralResult.push(spectralLayout(options)); + }); + } + + if (options.quality == "default" || options.quality == "proof") { + var toBeTiledNodes = cy.collection(); + if (options.tile) { + // behave nodes to be tiled as one component + var nodeIndexes = new Map(); + var _xCoords = []; + var _yCoords = []; + var count = 0; + var tempSpectralResult = { nodeIndexes: nodeIndexes, xCoords: _xCoords, yCoords: _yCoords }; + var indexesToBeDeleted = []; + components.forEach(function (component, index) { + if (component.edges().length == 0) { + component.nodes().forEach(function (node, i) { + toBeTiledNodes.merge(component.nodes()[i]); + if (!node.isParent()) { + tempSpectralResult.nodeIndexes.set(component.nodes()[i].id(), count++); + tempSpectralResult.xCoords.push(component.nodes()[0].position().x); + tempSpectralResult.yCoords.push(component.nodes()[0].position().y); + } + }); + indexesToBeDeleted.push(index); + } + }); + if (toBeTiledNodes.length > 1) { + var _boundingBox = toBeTiledNodes.boundingBox(); + componentCenters.push({ x: _boundingBox.x1 + _boundingBox.w / 2, y: _boundingBox.y1 + _boundingBox.h / 2 }); + components.push(toBeTiledNodes); + spectralResult.push(tempSpectralResult); + for (var i = indexesToBeDeleted.length - 1; i >= 0; i--) { + components.splice(indexesToBeDeleted[i], 1); + spectralResult.splice(indexesToBeDeleted[i], 1); + componentCenters.splice(indexesToBeDeleted[i], 1); + }; + } + } + components.forEach(function (component, index) { + // send each component to cose layout + options.eles = component; + coseResult.push(coseLayout(options, spectralResult[index])); + aux.relocateComponent(componentCenters[index], coseResult[index], options); // relocate center to original position + }); + } else { + components.forEach(function (component, index) { + aux.relocateComponent(componentCenters[index], spectralResult[index], options); // relocate center to original position + }); + } + + // packing + var componentsEvaluated = new Set(); + if (components.length > 1) { + var subgraphs = []; + var hiddenEles = eles.filter(function (ele) { + return ele.css('display') == 'none'; + }); + components.forEach(function (component, index) { + var nodeIndexes = void 0; + if (options.quality == "draft") { + nodeIndexes = spectralResult[index].nodeIndexes; + } + + if (component.nodes().not(hiddenEles).length > 0) { + var subgraph = {}; + subgraph.edges = []; + subgraph.nodes = []; + var nodeIndex = void 0; + component.nodes().not(hiddenEles).forEach(function (node) { + if (options.quality == "draft") { + if (!node.isParent()) { + nodeIndex = nodeIndexes.get(node.id()); + subgraph.nodes.push({ x: spectralResult[index].xCoords[nodeIndex] - node.boundingbox().w / 2, y: spectralResult[index].yCoords[nodeIndex] - node.boundingbox().h / 2, width: node.boundingbox().w, height: node.boundingbox().h }); + } else { + var parentInfo = aux.calcBoundingBox(node, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes); + subgraph.nodes.push({ x: parentInfo.topLeftX, y: parentInfo.topLeftY, width: parentInfo.width, height: parentInfo.height }); + } + } else { + if (coseResult[index][node.id()]) { + subgraph.nodes.push({ x: coseResult[index][node.id()].getLeft(), y: coseResult[index][node.id()].getTop(), width: coseResult[index][node.id()].getWidth(), height: coseResult[index][node.id()].getHeight() }); + } + } + }); + component.edges().forEach(function (edge) { + var source = edge.source(); + var target = edge.target(); + if (source.css("display") != "none" && target.css("display") != "none") { + if (options.quality == "draft") { + var sourceNodeIndex = nodeIndexes.get(source.id()); + var targetNodeIndex = nodeIndexes.get(target.id()); + var sourceCenter = []; + var targetCenter = []; + if (source.isParent()) { + var parentInfo = aux.calcBoundingBox(source, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes); + sourceCenter.push(parentInfo.topLeftX + parentInfo.width / 2); + sourceCenter.push(parentInfo.topLeftY + parentInfo.height / 2); + } else { + sourceCenter.push(spectralResult[index].xCoords[sourceNodeIndex]); + sourceCenter.push(spectralResult[index].yCoords[sourceNodeIndex]); + } + if (target.isParent()) { + var _parentInfo = aux.calcBoundingBox(target, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes); + targetCenter.push(_parentInfo.topLeftX + _parentInfo.width / 2); + targetCenter.push(_parentInfo.topLeftY + _parentInfo.height / 2); + } else { + targetCenter.push(spectralResult[index].xCoords[targetNodeIndex]); + targetCenter.push(spectralResult[index].yCoords[targetNodeIndex]); + } + subgraph.edges.push({ startX: sourceCenter[0], startY: sourceCenter[1], endX: targetCenter[0], endY: targetCenter[1] }); + } else { + if (coseResult[index][source.id()] && coseResult[index][target.id()]) { + subgraph.edges.push({ startX: coseResult[index][source.id()].getCenterX(), startY: coseResult[index][source.id()].getCenterY(), endX: coseResult[index][target.id()].getCenterX(), endY: coseResult[index][target.id()].getCenterY() }); + } + } + } + }); + if (subgraph.nodes.length > 0) { + subgraphs.push(subgraph); + componentsEvaluated.add(index); + } + } + }); + var shiftResult = layUtil.packComponents(subgraphs, options.randomize).shifts; + if (options.quality == "draft") { + spectralResult.forEach(function (result, index) { + var newXCoords = result.xCoords.map(function (x) { + return x + shiftResult[index].dx; + }); + var newYCoords = result.yCoords.map(function (y) { + return y + shiftResult[index].dy; + }); + result.xCoords = newXCoords; + result.yCoords = newYCoords; + }); + } else { + var _count = 0; + componentsEvaluated.forEach(function (index) { + Object.keys(coseResult[index]).forEach(function (item) { + var nodeRectangle = coseResult[index][item]; + nodeRectangle.setCenter(nodeRectangle.getCenterX() + shiftResult[_count].dx, nodeRectangle.getCenterY() + shiftResult[_count].dy); + }); + _count++; + }); + } + } + } + } + + // get each element's calculated position + var getPositions = function getPositions(ele, i) { + if (options.quality == "default" || options.quality == "proof") { + if (typeof ele === "number") { + ele = i; + } + var pos = void 0; + var node = void 0; + var theId = ele.data('id'); + coseResult.forEach(function (result) { + if (theId in result) { + pos = { x: result[theId].getRect().getCenterX(), y: result[theId].getRect().getCenterY() }; + node = result[theId]; + } + }); + if (options.nodeDimensionsIncludeLabels) { + if (node.labelWidth) { + if (node.labelPosHorizontal == "left") { + pos.x += node.labelWidth / 2; + } else if (node.labelPosHorizontal == "right") { + pos.x -= node.labelWidth / 2; + } + } + if (node.labelHeight) { + if (node.labelPosVertical == "top") { + pos.y += node.labelHeight / 2; + } else if (node.labelPosVertical == "bottom") { + pos.y -= node.labelHeight / 2; + } + } + } + if (pos == undefined) pos = { x: ele.position("x"), y: ele.position("y") }; + return { + x: pos.x, + y: pos.y + }; + } else { + var _pos = void 0; + spectralResult.forEach(function (result) { + var index = result.nodeIndexes.get(ele.id()); + if (index != undefined) { + _pos = { x: result.xCoords[index], y: result.yCoords[index] }; + } + }); + if (_pos == undefined) _pos = { x: ele.position("x"), y: ele.position("y") }; + return { + x: _pos.x, + y: _pos.y + }; + } + }; + + // quality = "draft" and randomize = false are contradictive so in that case positions don't change + if (options.quality == "default" || options.quality == "proof" || options.randomize) { + // transfer calculated positions to nodes (positions of only simple nodes are evaluated, compounds are positioned automatically) + var parentsWithoutChildren = aux.calcParentsWithoutChildren(cy, eles); + var _hiddenEles = eles.filter(function (ele) { + return ele.css('display') == 'none'; + }); + options.eles = eles.not(_hiddenEles); + + eles.nodes().not(":parent").not(_hiddenEles).layoutPositions(layout, options, getPositions); + + if (parentsWithoutChildren.length > 0) { + parentsWithoutChildren.forEach(function (ele) { + ele.position(getPositions(ele)); + }); + } + } else { + console.log("If randomize option is set to false, then quality option must be 'default' or 'proof'."); + } + } + }]); + + return Layout; +}(); + +module.exports = Layout; + +/***/ }), + +/***/ 657: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +/** + The implementation of the spectral layout that is the first part of the fcose layout algorithm +*/ + +var aux = __webpack_require__(548); +var Matrix = __webpack_require__(140).layoutBase.Matrix; +var SVD = __webpack_require__(140).layoutBase.SVD; + +// main function that spectral layout is processed +var spectralLayout = function spectralLayout(options) { + + var cy = options.cy; + var eles = options.eles; + var nodes = eles.nodes(); + var parentNodes = eles.nodes(":parent"); + + var dummyNodes = new Map(); // map to keep dummy nodes and their neighbors + var nodeIndexes = new Map(); // map to keep indexes to nodes + var parentChildMap = new Map(); // mapping btw. compound and its representative node + var allNodesNeighborhood = []; // array to keep neighborhood of all nodes + var xCoords = []; + var yCoords = []; + + var samplesColumn = []; // sampled vertices + var minDistancesColumn = []; + var C = []; // column sampling matrix + var PHI = []; // intersection of column and row sampling matrices + var INV = []; // inverse of PHI + + var firstSample = void 0; // the first sampled node + var nodeSize = void 0; + + var infinity = 100000000; + var small = 0.000000001; + + var piTol = options.piTol; + var samplingType = options.samplingType; // false for random, true for greedy + var nodeSeparation = options.nodeSeparation; + var sampleSize = void 0; + + /**** Spectral-preprocessing functions ****/ + + /**** Spectral layout functions ****/ + + // determine which columns to be sampled + var randomSampleCR = function randomSampleCR() { + var sample = 0; + var count = 0; + var flag = false; + + while (count < sampleSize) { + sample = Math.floor(Math.random() * nodeSize); + + flag = false; + for (var i = 0; i < count; i++) { + if (samplesColumn[i] == sample) { + flag = true; + break; + } + } + + if (!flag) { + samplesColumn[count] = sample; + count++; + } else { + continue; + } + } + }; + + // takes the index of the node(pivot) to initiate BFS as a parameter + var BFS = function BFS(pivot, index, samplingMethod) { + var path = []; // the front of the path + var front = 0; // the back of the path + var back = 0; + var current = 0; + var temp = void 0; + var distance = []; + + var max_dist = 0; // the furthest node to be returned + var max_ind = 1; + + for (var i = 0; i < nodeSize; i++) { + distance[i] = infinity; + } + + path[back] = pivot; + distance[pivot] = 0; + + while (back >= front) { + current = path[front++]; + var neighbors = allNodesNeighborhood[current]; + for (var _i = 0; _i < neighbors.length; _i++) { + temp = nodeIndexes.get(neighbors[_i]); + if (distance[temp] == infinity) { + distance[temp] = distance[current] + 1; + path[++back] = temp; + } + } + C[current][index] = distance[current] * nodeSeparation; + } + + if (samplingMethod) { + for (var _i2 = 0; _i2 < nodeSize; _i2++) { + if (C[_i2][index] < minDistancesColumn[_i2]) minDistancesColumn[_i2] = C[_i2][index]; + } + + for (var _i3 = 0; _i3 < nodeSize; _i3++) { + if (minDistancesColumn[_i3] > max_dist) { + max_dist = minDistancesColumn[_i3]; + max_ind = _i3; + } + } + } + return max_ind; + }; + + // apply BFS to all nodes or selected samples + var allBFS = function allBFS(samplingMethod) { + + var sample = void 0; + + if (!samplingMethod) { + randomSampleCR(); + + // call BFS + for (var i = 0; i < sampleSize; i++) { + BFS(samplesColumn[i], i, samplingMethod, false); + } + } else { + sample = Math.floor(Math.random() * nodeSize); + firstSample = sample; + + for (var _i4 = 0; _i4 < nodeSize; _i4++) { + minDistancesColumn[_i4] = infinity; + } + + for (var _i5 = 0; _i5 < sampleSize; _i5++) { + samplesColumn[_i5] = sample; + sample = BFS(sample, _i5, samplingMethod); + } + } + + // form the squared distances for C + for (var _i6 = 0; _i6 < nodeSize; _i6++) { + for (var j = 0; j < sampleSize; j++) { + C[_i6][j] *= C[_i6][j]; + } + } + + // form PHI + for (var _i7 = 0; _i7 < sampleSize; _i7++) { + PHI[_i7] = []; + } + + for (var _i8 = 0; _i8 < sampleSize; _i8++) { + for (var _j = 0; _j < sampleSize; _j++) { + PHI[_i8][_j] = C[samplesColumn[_j]][_i8]; + } + } + }; + + // perform the SVD algorithm and apply a regularization step + var sample = function sample() { + + var SVDResult = SVD.svd(PHI); + + var a_q = SVDResult.S; + var a_u = SVDResult.U; + var a_v = SVDResult.V; + + var max_s = a_q[0] * a_q[0] * a_q[0]; + + var a_Sig = []; + + // regularization + for (var i = 0; i < sampleSize; i++) { + a_Sig[i] = []; + for (var j = 0; j < sampleSize; j++) { + a_Sig[i][j] = 0; + if (i == j) { + a_Sig[i][j] = a_q[i] / (a_q[i] * a_q[i] + max_s / (a_q[i] * a_q[i])); + } + } + } + + INV = Matrix.multMat(Matrix.multMat(a_v, a_Sig), Matrix.transpose(a_u)); + }; + + // calculate final coordinates + var powerIteration = function powerIteration() { + // two largest eigenvalues + var theta1 = void 0; + var theta2 = void 0; + + // initial guesses for eigenvectors + var Y1 = []; + var Y2 = []; + + var V1 = []; + var V2 = []; + + for (var i = 0; i < nodeSize; i++) { + Y1[i] = Math.random(); + Y2[i] = Math.random(); + } + + Y1 = Matrix.normalize(Y1); + Y2 = Matrix.normalize(Y2); + + var count = 0; + // to keep track of the improvement ratio in power iteration + var current = small; + var previous = small; + + var temp = void 0; + + while (true) { + count++; + + for (var _i9 = 0; _i9 < nodeSize; _i9++) { + V1[_i9] = Y1[_i9]; + } + + Y1 = Matrix.multGamma(Matrix.multL(Matrix.multGamma(V1), C, INV)); + theta1 = Matrix.dotProduct(V1, Y1); + Y1 = Matrix.normalize(Y1); + + current = Matrix.dotProduct(V1, Y1); + + temp = Math.abs(current / previous); + + if (temp <= 1 + piTol && temp >= 1) { + break; + } + + previous = current; + } + + for (var _i10 = 0; _i10 < nodeSize; _i10++) { + V1[_i10] = Y1[_i10]; + } + + count = 0; + previous = small; + while (true) { + count++; + + for (var _i11 = 0; _i11 < nodeSize; _i11++) { + V2[_i11] = Y2[_i11]; + } + + V2 = Matrix.minusOp(V2, Matrix.multCons(V1, Matrix.dotProduct(V1, V2))); + Y2 = Matrix.multGamma(Matrix.multL(Matrix.multGamma(V2), C, INV)); + theta2 = Matrix.dotProduct(V2, Y2); + Y2 = Matrix.normalize(Y2); + + current = Matrix.dotProduct(V2, Y2); + + temp = Math.abs(current / previous); + + if (temp <= 1 + piTol && temp >= 1) { + break; + } + + previous = current; + } + + for (var _i12 = 0; _i12 < nodeSize; _i12++) { + V2[_i12] = Y2[_i12]; + } + + // theta1 now contains dominant eigenvalue + // theta2 now contains the second-largest eigenvalue + // V1 now contains theta1's eigenvector + // V2 now contains theta2's eigenvector + + //populate the two vectors + xCoords = Matrix.multCons(V1, Math.sqrt(Math.abs(theta1))); + yCoords = Matrix.multCons(V2, Math.sqrt(Math.abs(theta2))); + }; + + /**** Preparation for spectral layout (Preprocessing) ****/ + + // connect disconnected components (first top level, then inside of each compound node) + aux.connectComponents(cy, eles, aux.getTopMostNodes(nodes), dummyNodes); + + parentNodes.forEach(function (ele) { + aux.connectComponents(cy, eles, aux.getTopMostNodes(ele.descendants().intersection(eles)), dummyNodes); + }); + + // assign indexes to nodes (first real, then dummy nodes) + var index = 0; + for (var i = 0; i < nodes.length; i++) { + if (!nodes[i].isParent()) { + nodeIndexes.set(nodes[i].id(), index++); + } + } + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = dummyNodes.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var key = _step.value; + + nodeIndexes.set(key, index++); + } + + // instantiate the neighborhood matrix + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + for (var _i13 = 0; _i13 < nodeIndexes.size; _i13++) { + allNodesNeighborhood[_i13] = []; + } + + // form a parent-child map to keep representative node of each compound node + parentNodes.forEach(function (ele) { + var children = ele.children().intersection(eles); + + // let random = 0; + while (children.nodes(":childless").length == 0) { + // random = Math.floor(Math.random() * children.nodes().length); // if all children are compound then proceed randomly + children = children.nodes()[0].children().intersection(eles); + } + // select the representative node - we can apply different methods here + // random = Math.floor(Math.random() * children.nodes(":childless").length); + var index = 0; + var min = children.nodes(":childless")[0].connectedEdges().length; + children.nodes(":childless").forEach(function (ele2, i) { + if (ele2.connectedEdges().length < min) { + min = ele2.connectedEdges().length; + index = i; + } + }); + parentChildMap.set(ele.id(), children.nodes(":childless")[index].id()); + }); + + // add neighborhood relations (first real, then dummy nodes) + nodes.forEach(function (ele) { + var eleIndex = void 0; + + if (ele.isParent()) eleIndex = nodeIndexes.get(parentChildMap.get(ele.id()));else eleIndex = nodeIndexes.get(ele.id()); + + ele.neighborhood().nodes().forEach(function (node) { + if (eles.intersection(ele.edgesWith(node)).length > 0) { + if (node.isParent()) allNodesNeighborhood[eleIndex].push(parentChildMap.get(node.id()));else allNodesNeighborhood[eleIndex].push(node.id()); + } + }); + }); + + var _loop = function _loop(_key) { + var eleIndex = nodeIndexes.get(_key); + var disconnectedId = void 0; + dummyNodes.get(_key).forEach(function (id) { + if (cy.getElementById(id).isParent()) disconnectedId = parentChildMap.get(id);else disconnectedId = id; + + allNodesNeighborhood[eleIndex].push(disconnectedId); + allNodesNeighborhood[nodeIndexes.get(disconnectedId)].push(_key); + }); + }; + + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = dummyNodes.keys()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var _key = _step2.value; + + _loop(_key); + } + + // nodeSize now only considers the size of transformed graph + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + nodeSize = nodeIndexes.size; + + var spectralResult = void 0; + + // If number of nodes in transformed graph is 1 or 2, either SVD or powerIteration causes problem + // So skip spectral and layout the graph with cose + if (nodeSize > 2) { + // if # of nodes in transformed graph is smaller than sample size, + // then use # of nodes as sample size + sampleSize = nodeSize < options.sampleSize ? nodeSize : options.sampleSize; + + // instantiates the partial matrices that will be used in spectral layout + for (var _i14 = 0; _i14 < nodeSize; _i14++) { + C[_i14] = []; + } + for (var _i15 = 0; _i15 < sampleSize; _i15++) { + INV[_i15] = []; + } + + /**** Apply spectral layout ****/ + + if (options.quality == "draft" || options.step == "all") { + allBFS(samplingType); + sample(); + powerIteration(); + + spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords }; + } else { + nodeIndexes.forEach(function (value, key) { + xCoords.push(cy.getElementById(key).position("x")); + yCoords.push(cy.getElementById(key).position("y")); + }); + spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords }; + } + return spectralResult; + } else { + var iterator = nodeIndexes.keys(); + var firstNode = cy.getElementById(iterator.next().value); + var firstNodePos = firstNode.position(); + var firstNodeWidth = firstNode.outerWidth(); + xCoords.push(firstNodePos.x); + yCoords.push(firstNodePos.y); + if (nodeSize == 2) { + var secondNode = cy.getElementById(iterator.next().value); + var secondNodeWidth = secondNode.outerWidth(); + xCoords.push(firstNodePos.x + firstNodeWidth / 2 + secondNodeWidth / 2 + options.idealEdgeLength); + yCoords.push(firstNodePos.y); + } + + spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords }; + return spectralResult; + } +}; + +module.exports = { spectralLayout: spectralLayout }; + +/***/ }), + +/***/ 579: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + + +var impl = __webpack_require__(212); + +// registers the extension on a cytoscape lib ref +var register = function register(cytoscape) { + if (!cytoscape) { + return; + } // can't register if cytoscape unspecified + + cytoscape('layout', 'fcose', impl); // register with cytoscape.js +}; + +if (typeof cytoscape !== 'undefined') { + // expose to global cytoscape (i.e. window.cytoscape) + register(cytoscape); +} + +module.exports = register; + +/***/ }), + +/***/ 140: +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE__140__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module is referenced by other modules so it can't be inlined +/******/ var __webpack_exports__ = __webpack_require__(579); +/******/ +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/static/js/vendor/cytoscape-layout-base.js b/static/js/vendor/cytoscape-layout-base.js new file mode 100644 index 0000000..dc77057 --- /dev/null +++ b/static/js/vendor/cytoscape-layout-base.js @@ -0,0 +1,5230 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["layoutBase"] = factory(); + else + root["layoutBase"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 28); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function LayoutConstants() {} + +/** + * Layout Quality: 0:draft, 1:default, 2:proof + */ +LayoutConstants.QUALITY = 1; + +/** + * Default parameters + */ +LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false; +LayoutConstants.DEFAULT_INCREMENTAL = false; +LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true; +LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false; +LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50; +LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false; + +// ----------------------------------------------------------------------------- +// Section: General other constants +// ----------------------------------------------------------------------------- +/* + * Margins of a graph to be applied on bouding rectangle of its contents. We + * assume margins on all four sides to be uniform. + */ +LayoutConstants.DEFAULT_GRAPH_MARGIN = 15; + +/* + * Whether to consider labels in node dimensions or not + */ +LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false; + +/* + * Default dimension of a non-compound node. + */ +LayoutConstants.SIMPLE_NODE_SIZE = 40; + +/* + * Default dimension of a non-compound node. + */ +LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2; + +/* + * Empty compound node size. When a compound node is empty, its both + * dimensions should be of this value. + */ +LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40; + +/* + * Minimum length that an edge should take during layout + */ +LayoutConstants.MIN_EDGE_LENGTH = 1; + +/* + * World boundaries that layout operates on + */ +LayoutConstants.WORLD_BOUNDARY = 1000000; + +/* + * World boundaries that random positioning can be performed with + */ +LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000; + +/* + * Coordinates of the world center + */ +LayoutConstants.WORLD_CENTER_X = 1200; +LayoutConstants.WORLD_CENTER_Y = 900; + +module.exports = LayoutConstants; + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraphObject = __webpack_require__(2); +var IGeometry = __webpack_require__(8); +var IMath = __webpack_require__(9); + +function LEdge(source, target, vEdge) { + LGraphObject.call(this, vEdge); + + this.isOverlapingSourceAndTarget = false; + this.vGraphObject = vEdge; + this.bendpoints = []; + this.source = source; + this.target = target; +} + +LEdge.prototype = Object.create(LGraphObject.prototype); + +for (var prop in LGraphObject) { + LEdge[prop] = LGraphObject[prop]; +} + +LEdge.prototype.getSource = function () { + return this.source; +}; + +LEdge.prototype.getTarget = function () { + return this.target; +}; + +LEdge.prototype.isInterGraph = function () { + return this.isInterGraph; +}; + +LEdge.prototype.getLength = function () { + return this.length; +}; + +LEdge.prototype.isOverlapingSourceAndTarget = function () { + return this.isOverlapingSourceAndTarget; +}; + +LEdge.prototype.getBendpoints = function () { + return this.bendpoints; +}; + +LEdge.prototype.getLca = function () { + return this.lca; +}; + +LEdge.prototype.getSourceInLca = function () { + return this.sourceInLca; +}; + +LEdge.prototype.getTargetInLca = function () { + return this.targetInLca; +}; + +LEdge.prototype.getOtherEnd = function (node) { + if (this.source === node) { + return this.target; + } else if (this.target === node) { + return this.source; + } else { + throw "Node is not incident with this edge"; + } +}; + +LEdge.prototype.getOtherEndInGraph = function (node, graph) { + var otherEnd = this.getOtherEnd(node); + var root = graph.getGraphManager().getRoot(); + + while (true) { + if (otherEnd.getOwner() == graph) { + return otherEnd; + } + + if (otherEnd.getOwner() == root) { + break; + } + + otherEnd = otherEnd.getOwner().getParent(); + } + + return null; +}; + +LEdge.prototype.updateLength = function () { + var clipPointCoordinates = new Array(4); + + this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates); + + if (!this.isOverlapingSourceAndTarget) { + this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2]; + this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3]; + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + } +}; + +LEdge.prototype.updateLengthSimple = function () { + this.lengthX = this.target.getCenterX() - this.source.getCenterX(); + this.lengthY = this.target.getCenterY() - this.source.getCenterY(); + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); +}; + +module.exports = LEdge; + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function LGraphObject(vGraphObject) { + this.vGraphObject = vGraphObject; +} + +module.exports = LGraphObject; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraphObject = __webpack_require__(2); +var Integer = __webpack_require__(10); +var RectangleD = __webpack_require__(13); +var LayoutConstants = __webpack_require__(0); +var RandomSeed = __webpack_require__(16); +var PointD = __webpack_require__(5); + +function LNode(gm, loc, size, vNode) { + //Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode) + if (size == null && vNode == null) { + vNode = loc; + } + + LGraphObject.call(this, vNode); + + //Alternative constructor 2 : LNode(Layout layout, Object vNode) + if (gm.graphManager != null) gm = gm.graphManager; + + this.estimatedSize = Integer.MIN_VALUE; + this.inclusionTreeDepth = Integer.MAX_VALUE; + this.vGraphObject = vNode; + this.edges = []; + this.graphManager = gm; + + if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);else this.rect = new RectangleD(); +} + +LNode.prototype = Object.create(LGraphObject.prototype); +for (var prop in LGraphObject) { + LNode[prop] = LGraphObject[prop]; +} + +LNode.prototype.getEdges = function () { + return this.edges; +}; + +LNode.prototype.getChild = function () { + return this.child; +}; + +LNode.prototype.getOwner = function () { + // if (this.owner != null) { + // if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) { + // throw "assert failed"; + // } + // } + + return this.owner; +}; + +LNode.prototype.getWidth = function () { + return this.rect.width; +}; + +LNode.prototype.setWidth = function (width) { + this.rect.width = width; +}; + +LNode.prototype.getHeight = function () { + return this.rect.height; +}; + +LNode.prototype.setHeight = function (height) { + this.rect.height = height; +}; + +LNode.prototype.getCenterX = function () { + return this.rect.x + this.rect.width / 2; +}; + +LNode.prototype.getCenterY = function () { + return this.rect.y + this.rect.height / 2; +}; + +LNode.prototype.getCenter = function () { + return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2); +}; + +LNode.prototype.getLocation = function () { + return new PointD(this.rect.x, this.rect.y); +}; + +LNode.prototype.getRect = function () { + return this.rect; +}; + +LNode.prototype.getDiagonal = function () { + return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height); +}; + +/** + * This method returns half the diagonal length of this node. + */ +LNode.prototype.getHalfTheDiagonal = function () { + return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2; +}; + +LNode.prototype.setRect = function (upperLeft, dimension) { + this.rect.x = upperLeft.x; + this.rect.y = upperLeft.y; + this.rect.width = dimension.width; + this.rect.height = dimension.height; +}; + +LNode.prototype.setCenter = function (cx, cy) { + this.rect.x = cx - this.rect.width / 2; + this.rect.y = cy - this.rect.height / 2; +}; + +LNode.prototype.setLocation = function (x, y) { + this.rect.x = x; + this.rect.y = y; +}; + +LNode.prototype.moveBy = function (dx, dy) { + this.rect.x += dx; + this.rect.y += dy; +}; + +LNode.prototype.getEdgeListToNode = function (to) { + var edgeList = []; + var edge; + var self = this; + + self.edges.forEach(function (edge) { + + if (edge.target == to) { + if (edge.source != self) throw "Incorrect edge source!"; + + edgeList.push(edge); + } + }); + + return edgeList; +}; + +LNode.prototype.getEdgesBetween = function (other) { + var edgeList = []; + var edge; + + var self = this; + self.edges.forEach(function (edge) { + + if (!(edge.source == self || edge.target == self)) throw "Incorrect edge source and/or target"; + + if (edge.target == other || edge.source == other) { + edgeList.push(edge); + } + }); + + return edgeList; +}; + +LNode.prototype.getNeighborsList = function () { + var neighbors = new Set(); + + var self = this; + self.edges.forEach(function (edge) { + + if (edge.source == self) { + neighbors.add(edge.target); + } else { + if (edge.target != self) { + throw "Incorrect incidency!"; + } + + neighbors.add(edge.source); + } + }); + + return neighbors; +}; + +LNode.prototype.withChildren = function () { + var withNeighborsList = new Set(); + var childNode; + var children; + + withNeighborsList.add(this); + + if (this.child != null) { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + children = childNode.withChildren(); + children.forEach(function (node) { + withNeighborsList.add(node); + }); + } + } + + return withNeighborsList; +}; + +LNode.prototype.getNoOfChildren = function () { + var noOfChildren = 0; + var childNode; + + if (this.child == null) { + noOfChildren = 1; + } else { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + + noOfChildren += childNode.getNoOfChildren(); + } + } + + if (noOfChildren == 0) { + noOfChildren = 1; + } + return noOfChildren; +}; + +LNode.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; +}; + +LNode.prototype.calcEstimatedSize = function () { + if (this.child == null) { + return this.estimatedSize = (this.rect.width + this.rect.height) / 2; + } else { + this.estimatedSize = this.child.calcEstimatedSize(); + this.rect.width = this.estimatedSize; + this.rect.height = this.estimatedSize; + + return this.estimatedSize; + } +}; + +LNode.prototype.scatter = function () { + var randomCenterX; + var randomCenterY; + + var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX; + + var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY; + + this.rect.x = randomCenterX; + this.rect.y = randomCenterY; +}; + +LNode.prototype.updateBounds = function () { + if (this.getChild() == null) { + throw "assert failed"; + } + if (this.getChild().getNodes().length != 0) { + // wrap the children nodes by re-arranging the boundaries + var childGraph = this.getChild(); + childGraph.updateBounds(true); + + this.rect.x = childGraph.getLeft(); + this.rect.y = childGraph.getTop(); + + this.setWidth(childGraph.getRight() - childGraph.getLeft()); + this.setHeight(childGraph.getBottom() - childGraph.getTop()); + + // Update compound bounds considering its label properties + if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { + + var width = childGraph.getRight() - childGraph.getLeft(); + var height = childGraph.getBottom() - childGraph.getTop(); + + if (this.labelWidth) { + if (this.labelPosHorizontal == "left") { + this.rect.x -= this.labelWidth; + this.setWidth(width + this.labelWidth); + } else if (this.labelPosHorizontal == "center" && this.labelWidth > width) { + this.rect.x -= (this.labelWidth - width) / 2; + this.setWidth(this.labelWidth); + } else if (this.labelPosHorizontal == "right") { + this.setWidth(width + this.labelWidth); + } + } + + if (this.labelHeight) { + if (this.labelPosVertical == "top") { + this.rect.y -= this.labelHeight; + this.setHeight(height + this.labelHeight); + } else if (this.labelPosVertical == "center" && this.labelHeight > height) { + this.rect.y -= (this.labelHeight - height) / 2; + this.setHeight(this.labelHeight); + } else if (this.labelPosVertical == "bottom") { + this.setHeight(height + this.labelHeight); + } + } + } + } +}; + +LNode.prototype.getInclusionTreeDepth = function () { + if (this.inclusionTreeDepth == Integer.MAX_VALUE) { + throw "assert failed"; + } + return this.inclusionTreeDepth; +}; + +LNode.prototype.transform = function (trans) { + var left = this.rect.x; + + if (left > LayoutConstants.WORLD_BOUNDARY) { + left = LayoutConstants.WORLD_BOUNDARY; + } else if (left < -LayoutConstants.WORLD_BOUNDARY) { + left = -LayoutConstants.WORLD_BOUNDARY; + } + + var top = this.rect.y; + + if (top > LayoutConstants.WORLD_BOUNDARY) { + top = LayoutConstants.WORLD_BOUNDARY; + } else if (top < -LayoutConstants.WORLD_BOUNDARY) { + top = -LayoutConstants.WORLD_BOUNDARY; + } + + var leftTop = new PointD(left, top); + var vLeftTop = trans.inverseTransformPoint(leftTop); + + this.setLocation(vLeftTop.x, vLeftTop.y); +}; + +LNode.prototype.getLeft = function () { + return this.rect.x; +}; + +LNode.prototype.getRight = function () { + return this.rect.x + this.rect.width; +}; + +LNode.prototype.getTop = function () { + return this.rect.y; +}; + +LNode.prototype.getBottom = function () { + return this.rect.y + this.rect.height; +}; + +LNode.prototype.getParent = function () { + if (this.owner == null) { + return null; + } + + return this.owner.getParent(); +}; + +module.exports = LNode; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LayoutConstants = __webpack_require__(0); + +function FDLayoutConstants() {} + +//FDLayoutConstants inherits static props in LayoutConstants +for (var prop in LayoutConstants) { + FDLayoutConstants[prop] = LayoutConstants[prop]; +} + +FDLayoutConstants.MAX_ITERATIONS = 2500; + +FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50; +FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45; +FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0; +FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4; +FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0; +FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8; +FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5; +FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true; +FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true; +FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3; +FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33; +FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000; +FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000; +FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0; +FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3; +FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0; +FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100; +FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1; +FDLayoutConstants.MIN_EDGE_LENGTH = 1; +FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10; + +module.exports = FDLayoutConstants; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function PointD(x, y) { + if (x == null && y == null) { + this.x = 0; + this.y = 0; + } else { + this.x = x; + this.y = y; + } +} + +PointD.prototype.getX = function () { + return this.x; +}; + +PointD.prototype.getY = function () { + return this.y; +}; + +PointD.prototype.setX = function (x) { + this.x = x; +}; + +PointD.prototype.setY = function (y) { + this.y = y; +}; + +PointD.prototype.getDifference = function (pt) { + return new DimensionD(this.x - pt.x, this.y - pt.y); +}; + +PointD.prototype.getCopy = function () { + return new PointD(this.x, this.y); +}; + +PointD.prototype.translate = function (dim) { + this.x += dim.width; + this.y += dim.height; + return this; +}; + +module.exports = PointD; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraphObject = __webpack_require__(2); +var Integer = __webpack_require__(10); +var LayoutConstants = __webpack_require__(0); +var LGraphManager = __webpack_require__(7); +var LNode = __webpack_require__(3); +var LEdge = __webpack_require__(1); +var RectangleD = __webpack_require__(13); +var Point = __webpack_require__(12); +var LinkedList = __webpack_require__(11); + +function LGraph(parent, obj2, vGraph) { + LGraphObject.call(this, vGraph); + this.estimatedSize = Integer.MIN_VALUE; + this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN; + this.edges = []; + this.nodes = []; + this.isConnected = false; + this.parent = parent; + + if (obj2 != null && obj2 instanceof LGraphManager) { + this.graphManager = obj2; + } else if (obj2 != null && obj2 instanceof Layout) { + this.graphManager = obj2.graphManager; + } +} + +LGraph.prototype = Object.create(LGraphObject.prototype); +for (var prop in LGraphObject) { + LGraph[prop] = LGraphObject[prop]; +} + +LGraph.prototype.getNodes = function () { + return this.nodes; +}; + +LGraph.prototype.getEdges = function () { + return this.edges; +}; + +LGraph.prototype.getGraphManager = function () { + return this.graphManager; +}; + +LGraph.prototype.getParent = function () { + return this.parent; +}; + +LGraph.prototype.getLeft = function () { + return this.left; +}; + +LGraph.prototype.getRight = function () { + return this.right; +}; + +LGraph.prototype.getTop = function () { + return this.top; +}; + +LGraph.prototype.getBottom = function () { + return this.bottom; +}; + +LGraph.prototype.isConnected = function () { + return this.isConnected; +}; + +LGraph.prototype.add = function (obj1, sourceNode, targetNode) { + if (sourceNode == null && targetNode == null) { + var newNode = obj1; + if (this.graphManager == null) { + throw "Graph has no graph mgr!"; + } + if (this.getNodes().indexOf(newNode) > -1) { + throw "Node already in graph!"; + } + newNode.owner = this; + this.getNodes().push(newNode); + + return newNode; + } else { + var newEdge = obj1; + if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) { + throw "Source or target not in graph!"; + } + + if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) { + throw "Both owners must be this graph!"; + } + + if (sourceNode.owner != targetNode.owner) { + return null; + } + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // set as intra-graph edge + newEdge.isInterGraph = false; + + // add to graph edge list + this.getEdges().push(newEdge); + + // add to incidency lists + sourceNode.edges.push(newEdge); + + if (targetNode != sourceNode) { + targetNode.edges.push(newEdge); + } + + return newEdge; + } +}; + +LGraph.prototype.remove = function (obj) { + var node = obj; + if (obj instanceof LNode) { + if (node == null) { + throw "Node is null!"; + } + if (!(node.owner != null && node.owner == this)) { + throw "Owner graph is invalid!"; + } + if (this.graphManager == null) { + throw "Owner graph manager is invalid!"; + } + // remove incident edges first (make a copy to do it safely) + var edgesToBeRemoved = node.edges.slice(); + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + + if (edge.isInterGraph) { + this.graphManager.remove(edge); + } else { + edge.source.owner.remove(edge); + } + } + + // now the node itself + var index = this.nodes.indexOf(node); + if (index == -1) { + throw "Node not in owner node list!"; + } + + this.nodes.splice(index, 1); + } else if (obj instanceof LEdge) { + var edge = obj; + if (edge == null) { + throw "Edge is null!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) { + throw "Source and/or target owner is invalid!"; + } + + var sourceIndex = edge.source.edges.indexOf(edge); + var targetIndex = edge.target.edges.indexOf(edge); + if (!(sourceIndex > -1 && targetIndex > -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + edge.source.edges.splice(sourceIndex, 1); + + if (edge.target != edge.source) { + edge.target.edges.splice(targetIndex, 1); + } + + var index = edge.source.owner.getEdges().indexOf(edge); + if (index == -1) { + throw "Not in owner's edge list!"; + } + + edge.source.owner.getEdges().splice(index, 1); + } +}; + +LGraph.prototype.updateLeftTop = function () { + var top = Integer.MAX_VALUE; + var left = Integer.MAX_VALUE; + var nodeTop; + var nodeLeft; + var margin; + + var nodes = this.getNodes(); + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeTop = lNode.getTop(); + nodeLeft = lNode.getLeft(); + + if (top > nodeTop) { + top = nodeTop; + } + + if (left > nodeLeft) { + left = nodeLeft; + } + } + + // Do we have any nodes in this graph? + if (top == Integer.MAX_VALUE) { + return null; + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = left - margin; + this.top = top - margin; + + // Apply the margins and return the result + return new Point(this.left, this.top); +}; + +LGraph.prototype.updateBounds = function (recursive) { + // calculate bounds + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + var margin; + + var nodes = this.nodes; + var s = nodes.length; + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + + if (recursive && lNode.child != null) { + lNode.updateBounds(); + } + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + if (left == Integer.MAX_VALUE) { + this.left = this.parent.getLeft(); + this.right = this.parent.getRight(); + this.top = this.parent.getTop(); + this.bottom = this.parent.getBottom(); + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = boundingRect.x - margin; + this.right = boundingRect.x + boundingRect.width + margin; + this.top = boundingRect.y - margin; + this.bottom = boundingRect.y + boundingRect.height + margin; +}; + +LGraph.calculateBounds = function (nodes) { + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + + return boundingRect; +}; + +LGraph.prototype.getInclusionTreeDepth = function () { + if (this == this.graphManager.getRoot()) { + return 1; + } else { + return this.parent.getInclusionTreeDepth(); + } +}; + +LGraph.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; +}; + +LGraph.prototype.calcEstimatedSize = function () { + var size = 0; + var nodes = this.nodes; + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + size += lNode.calcEstimatedSize(); + } + + if (size == 0) { + this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE; + } else { + this.estimatedSize = size / Math.sqrt(this.nodes.length); + } + + return this.estimatedSize; +}; + +LGraph.prototype.updateConnected = function () { + var self = this; + if (this.nodes.length == 0) { + this.isConnected = true; + return; + } + + var queue = new LinkedList(); + var visited = new Set(); + var currentNode = this.nodes[0]; + var neighborEdges; + var currentNeighbor; + var childrenOfNode = currentNode.withChildren(); + childrenOfNode.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + + while (queue.length !== 0) { + currentNode = queue.shift(); + + // Traverse all neighbors of this node + neighborEdges = currentNode.getEdges(); + var size = neighborEdges.length; + for (var i = 0; i < size; i++) { + var neighborEdge = neighborEdges[i]; + currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this); + + // Add unvisited neighbors to the list to visit + if (currentNeighbor != null && !visited.has(currentNeighbor)) { + var childrenOfNeighbor = currentNeighbor.withChildren(); + + childrenOfNeighbor.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + } + } + } + + this.isConnected = false; + + if (visited.size >= this.nodes.length) { + var noOfVisitedInThisGraph = 0; + + visited.forEach(function (visitedNode) { + if (visitedNode.owner == self) { + noOfVisitedInThisGraph++; + } + }); + + if (noOfVisitedInThisGraph == this.nodes.length) { + this.isConnected = true; + } + } +}; + +module.exports = LGraph; + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraph; +var LEdge = __webpack_require__(1); + +function LGraphManager(layout) { + LGraph = __webpack_require__(6); // It may be better to initilize this out of this function but it gives an error (Right-hand side of 'instanceof' is not callable) now. + this.layout = layout; + + this.graphs = []; + this.edges = []; +} + +LGraphManager.prototype.addRoot = function () { + var ngraph = this.layout.newGraph(); + var nnode = this.layout.newNode(null); + var root = this.add(ngraph, nnode); + this.setRootGraph(root); + return this.rootGraph; +}; + +LGraphManager.prototype.add = function (newGraph, parentNode, newEdge, sourceNode, targetNode) { + //there are just 2 parameters are passed then it adds an LGraph else it adds an LEdge + if (newEdge == null && sourceNode == null && targetNode == null) { + if (newGraph == null) { + throw "Graph is null!"; + } + if (parentNode == null) { + throw "Parent node is null!"; + } + if (this.graphs.indexOf(newGraph) > -1) { + throw "Graph already in this graph mgr!"; + } + + this.graphs.push(newGraph); + + if (newGraph.parent != null) { + throw "Already has a parent!"; + } + if (parentNode.child != null) { + throw "Already has a child!"; + } + + newGraph.parent = parentNode; + parentNode.child = newGraph; + + return newGraph; + } else { + //change the order of the parameters + targetNode = newEdge; + sourceNode = parentNode; + newEdge = newGraph; + var sourceGraph = sourceNode.getOwner(); + var targetGraph = targetNode.getOwner(); + + if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) { + throw "Source not in this graph mgr!"; + } + if (!(targetGraph != null && targetGraph.getGraphManager() == this)) { + throw "Target not in this graph mgr!"; + } + + if (sourceGraph == targetGraph) { + newEdge.isInterGraph = false; + return sourceGraph.add(newEdge, sourceNode, targetNode); + } else { + newEdge.isInterGraph = true; + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // add edge to inter-graph edge list + if (this.edges.indexOf(newEdge) > -1) { + throw "Edge already in inter-graph edge list!"; + } + + this.edges.push(newEdge); + + // add edge to source and target incidency lists + if (!(newEdge.source != null && newEdge.target != null)) { + throw "Edge source and/or target is null!"; + } + + if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) { + throw "Edge already in source and/or target incidency list!"; + } + + newEdge.source.edges.push(newEdge); + newEdge.target.edges.push(newEdge); + + return newEdge; + } + } +}; + +LGraphManager.prototype.remove = function (lObj) { + if (lObj instanceof LGraph) { + var graph = lObj; + if (graph.getGraphManager() != this) { + throw "Graph not in this graph mgr"; + } + if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) { + throw "Invalid parent node!"; + } + + // first the edges (make a copy to do it safely) + var edgesToBeRemoved = []; + + edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges()); + + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + graph.remove(edge); + } + + // then the nodes (make a copy to do it safely) + var nodesToBeRemoved = []; + + nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes()); + + var node; + s = nodesToBeRemoved.length; + for (var i = 0; i < s; i++) { + node = nodesToBeRemoved[i]; + graph.remove(node); + } + + // check if graph is the root + if (graph == this.rootGraph) { + this.setRootGraph(null); + } + + // now remove the graph itself + var index = this.graphs.indexOf(graph); + this.graphs.splice(index, 1); + + // also reset the parent of the graph + graph.parent = null; + } else if (lObj instanceof LEdge) { + edge = lObj; + if (edge == null) { + throw "Edge is null!"; + } + if (!edge.isInterGraph) { + throw "Not an inter-graph edge!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + + // remove edge from source and target nodes' incidency lists + + if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + var index = edge.source.edges.indexOf(edge); + edge.source.edges.splice(index, 1); + index = edge.target.edges.indexOf(edge); + edge.target.edges.splice(index, 1); + + // remove edge from owner graph manager's inter-graph edge list + + if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) { + throw "Edge owner graph or owner graph manager is null!"; + } + if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) { + throw "Not in owner graph manager's edge list!"; + } + + var index = edge.source.owner.getGraphManager().edges.indexOf(edge); + edge.source.owner.getGraphManager().edges.splice(index, 1); + } +}; + +LGraphManager.prototype.updateBounds = function () { + this.rootGraph.updateBounds(true); +}; + +LGraphManager.prototype.getGraphs = function () { + return this.graphs; +}; + +LGraphManager.prototype.getAllNodes = function () { + if (this.allNodes == null) { + var nodeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < s; i++) { + nodeList = nodeList.concat(graphs[i].getNodes()); + } + this.allNodes = nodeList; + } + return this.allNodes; +}; + +LGraphManager.prototype.resetAllNodes = function () { + this.allNodes = null; +}; + +LGraphManager.prototype.resetAllEdges = function () { + this.allEdges = null; +}; + +LGraphManager.prototype.resetAllNodesToApplyGravitation = function () { + this.allNodesToApplyGravitation = null; +}; + +LGraphManager.prototype.getAllEdges = function () { + if (this.allEdges == null) { + var edgeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < graphs.length; i++) { + edgeList = edgeList.concat(graphs[i].getEdges()); + } + + edgeList = edgeList.concat(this.edges); + + this.allEdges = edgeList; + } + return this.allEdges; +}; + +LGraphManager.prototype.getAllNodesToApplyGravitation = function () { + return this.allNodesToApplyGravitation; +}; + +LGraphManager.prototype.setAllNodesToApplyGravitation = function (nodeList) { + if (this.allNodesToApplyGravitation != null) { + throw "assert failed"; + } + + this.allNodesToApplyGravitation = nodeList; +}; + +LGraphManager.prototype.getRoot = function () { + return this.rootGraph; +}; + +LGraphManager.prototype.setRootGraph = function (graph) { + if (graph.getGraphManager() != this) { + throw "Root not in this graph mgr!"; + } + + this.rootGraph = graph; + // root graph must have a root node associated with it for convenience + if (graph.parent == null) { + graph.parent = this.layout.newNode("Root node"); + } +}; + +LGraphManager.prototype.getLayout = function () { + return this.layout; +}; + +LGraphManager.prototype.isOneAncestorOfOther = function (firstNode, secondNode) { + if (!(firstNode != null && secondNode != null)) { + throw "assert failed"; + } + + if (firstNode == secondNode) { + return true; + } + // Is second node an ancestor of the first one? + var ownerGraph = firstNode.getOwner(); + var parentNode; + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == secondNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + // Is first node an ancestor of the second one? + ownerGraph = secondNode.getOwner(); + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == firstNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + + return false; +}; + +LGraphManager.prototype.calcLowestCommonAncestors = function () { + var edge; + var sourceNode; + var targetNode; + var sourceAncestorGraph; + var targetAncestorGraph; + + var edges = this.getAllEdges(); + var s = edges.length; + for (var i = 0; i < s; i++) { + edge = edges[i]; + + sourceNode = edge.source; + targetNode = edge.target; + edge.lca = null; + edge.sourceInLca = sourceNode; + edge.targetInLca = targetNode; + + if (sourceNode == targetNode) { + edge.lca = sourceNode.getOwner(); + continue; + } + + sourceAncestorGraph = sourceNode.getOwner(); + + while (edge.lca == null) { + edge.targetInLca = targetNode; + targetAncestorGraph = targetNode.getOwner(); + + while (edge.lca == null) { + if (targetAncestorGraph == sourceAncestorGraph) { + edge.lca = targetAncestorGraph; + break; + } + + if (targetAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca != null) { + throw "assert failed"; + } + edge.targetInLca = targetAncestorGraph.getParent(); + targetAncestorGraph = edge.targetInLca.getOwner(); + } + + if (sourceAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca == null) { + edge.sourceInLca = sourceAncestorGraph.getParent(); + sourceAncestorGraph = edge.sourceInLca.getOwner(); + } + } + + if (edge.lca == null) { + throw "assert failed"; + } + } +}; + +LGraphManager.prototype.calcLowestCommonAncestor = function (firstNode, secondNode) { + if (firstNode == secondNode) { + return firstNode.getOwner(); + } + var firstOwnerGraph = firstNode.getOwner(); + + do { + if (firstOwnerGraph == null) { + break; + } + var secondOwnerGraph = secondNode.getOwner(); + + do { + if (secondOwnerGraph == null) { + break; + } + + if (secondOwnerGraph == firstOwnerGraph) { + return secondOwnerGraph; + } + secondOwnerGraph = secondOwnerGraph.getParent().getOwner(); + } while (true); + + firstOwnerGraph = firstOwnerGraph.getParent().getOwner(); + } while (true); + + return firstOwnerGraph; +}; + +LGraphManager.prototype.calcInclusionTreeDepths = function (graph, depth) { + if (graph == null && depth == null) { + graph = this.rootGraph; + depth = 1; + } + var node; + + var nodes = graph.getNodes(); + var s = nodes.length; + for (var i = 0; i < s; i++) { + node = nodes[i]; + node.inclusionTreeDepth = depth; + + if (node.child != null) { + this.calcInclusionTreeDepths(node.child, depth + 1); + } + } +}; + +LGraphManager.prototype.includesInvalidEdge = function () { + var edge; + var edgesToRemove = []; + + var s = this.edges.length; + for (var i = 0; i < s; i++) { + edge = this.edges[i]; + + if (this.isOneAncestorOfOther(edge.source, edge.target)) { + edgesToRemove.push(edge); + } + } + + // Remove invalid edges from graph manager + for (var i = 0; i < edgesToRemove.length; i++) { + this.remove(edgesToRemove[i]); + } + + // Invalid edges are cleared, so return false + return false; +}; + +module.exports = LGraphManager; + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/** + * This class maintains a list of static geometry related utility methods. + * + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + +var Point = __webpack_require__(12); + +function IGeometry() {} + +/** + * This method calculates *half* the amount in x and y directions of the two + * input rectangles needed to separate them keeping their respective + * positioning, and returns the result in the input array. An input + * separation buffer added to the amount in both directions. We assume that + * the two rectangles do intersect. + */ +IGeometry.calcSeparationAmount = function (rectA, rectB, overlapAmount, separationBuffer) { + if (!rectA.intersects(rectB)) { + throw "assert failed"; + } + + var directions = new Array(2); + + this.decideDirectionsForOverlappingNodes(rectA, rectB, directions); + + overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x); + overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y); + + // update the overlapping amounts for the following cases: + if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) { + /* Case x.1: + * + * rectA + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectB + */ + overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight()); + } else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) { + /* Case x.2: + * + * rectB + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectA + */ + overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight()); + } + if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) { + /* Case y.1: + * ________ rectA + * | + * | + * ______|____ rectB + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom()); + } else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) { + /* Case y.2: + * ________ rectB + * | + * | + * ______|____ rectA + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom()); + } + + // find slope of the line passes two centers + var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX())); + // if centers are overlapped + if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) { + // assume the slope is 1 (45 degree) + slope = 1.0; + } + + var moveByY = slope * overlapAmount[0]; + var moveByX = overlapAmount[1] / slope; + if (overlapAmount[0] < moveByX) { + moveByX = overlapAmount[0]; + } else { + moveByY = overlapAmount[1]; + } + // return half the amount so that if each rectangle is moved by these + // amounts in opposite directions, overlap will be resolved + overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer); + overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer); +}; + +/** + * This method decides the separation direction of overlapping nodes + * + * if directions[0] = -1, then rectA goes left + * if directions[0] = 1, then rectA goes right + * if directions[1] = -1, then rectA goes up + * if directions[1] = 1, then rectA goes down + */ +IGeometry.decideDirectionsForOverlappingNodes = function (rectA, rectB, directions) { + if (rectA.getCenterX() < rectB.getCenterX()) { + directions[0] = -1; + } else { + directions[0] = 1; + } + + if (rectA.getCenterY() < rectB.getCenterY()) { + directions[1] = -1; + } else { + directions[1] = 1; + } +}; + +/** + * This method calculates the intersection (clipping) points of the two + * input rectangles with line segment defined by the centers of these two + * rectangles. The clipping points are saved in the input double array and + * whether or not the two rectangles overlap is returned. + */ +IGeometry.getIntersection2 = function (rectA, rectB, result) { + //result[0-1] will contain clipPoint of rectA, result[2-3] will contain clipPoint of rectB + var p1x = rectA.getCenterX(); + var p1y = rectA.getCenterY(); + var p2x = rectB.getCenterX(); + var p2y = rectB.getCenterY(); + + //if two rectangles intersect, then clipping points are centers + if (rectA.intersects(rectB)) { + result[0] = p1x; + result[1] = p1y; + result[2] = p2x; + result[3] = p2y; + return true; + } + //variables for rectA + var topLeftAx = rectA.getX(); + var topLeftAy = rectA.getY(); + var topRightAx = rectA.getRight(); + var bottomLeftAx = rectA.getX(); + var bottomLeftAy = rectA.getBottom(); + var bottomRightAx = rectA.getRight(); + var halfWidthA = rectA.getWidthHalf(); + var halfHeightA = rectA.getHeightHalf(); + //variables for rectB + var topLeftBx = rectB.getX(); + var topLeftBy = rectB.getY(); + var topRightBx = rectB.getRight(); + var bottomLeftBx = rectB.getX(); + var bottomLeftBy = rectB.getBottom(); + var bottomRightBx = rectB.getRight(); + var halfWidthB = rectB.getWidthHalf(); + var halfHeightB = rectB.getHeightHalf(); + + //flag whether clipping points are found + var clipPointAFound = false; + var clipPointBFound = false; + + // line is vertical + if (p1x === p2x) { + if (p1y > p2y) { + result[0] = p1x; + result[1] = topLeftAy; + result[2] = p2x; + result[3] = bottomLeftBy; + return false; + } else if (p1y < p2y) { + result[0] = p1x; + result[1] = bottomLeftAy; + result[2] = p2x; + result[3] = topLeftBy; + return false; + } else { + //not line, return null; + } + } + // line is horizontal + else if (p1y === p2y) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = p1y; + result[2] = topRightBx; + result[3] = p2y; + return false; + } else if (p1x < p2x) { + result[0] = topRightAx; + result[1] = p1y; + result[2] = topLeftBx; + result[3] = p2y; + return false; + } else { + //not valid line, return null; + } + } else { + //slopes of rectA's and rectB's diagonals + var slopeA = rectA.height / rectA.width; + var slopeB = rectB.height / rectB.width; + + //slope of line between center of rectA and center of rectB + var slopePrime = (p2y - p1y) / (p2x - p1x); + var cardinalDirectionA = void 0; + var cardinalDirectionB = void 0; + var tempPointAx = void 0; + var tempPointAy = void 0; + var tempPointBx = void 0; + var tempPointBy = void 0; + + //determine whether clipping point is the corner of nodeA + if (-slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = bottomLeftAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } else { + result[0] = topRightAx; + result[1] = topLeftAy; + clipPointAFound = true; + } + } else if (slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = topLeftAy; + clipPointAFound = true; + } else { + result[0] = bottomRightAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } + } + + //determine whether clipping point is the corner of nodeB + if (-slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = bottomLeftBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } else { + result[2] = topRightBx; + result[3] = topLeftBy; + clipPointBFound = true; + } + } else if (slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = topLeftBx; + result[3] = topLeftBy; + clipPointBFound = true; + } else { + result[2] = bottomRightBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } + } + + //if both clipping points are corners + if (clipPointAFound && clipPointBFound) { + return false; + } + + //determine Cardinal Direction of rectangles + if (p1x > p2x) { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2); + } else { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1); + } + } else { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3); + } else { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4); + } + } + //calculate clipping Point if it is not found before + if (!clipPointAFound) { + switch (cardinalDirectionA) { + case 1: + tempPointAy = topLeftAy; + tempPointAx = p1x + -halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 2: + tempPointAx = bottomRightAx; + tempPointAy = p1y + halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 3: + tempPointAy = bottomLeftAy; + tempPointAx = p1x + halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 4: + tempPointAx = bottomLeftAx; + tempPointAy = p1y + -halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + } + } + if (!clipPointBFound) { + switch (cardinalDirectionB) { + case 1: + tempPointBy = topLeftBy; + tempPointBx = p2x + -halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 2: + tempPointBx = bottomRightBx; + tempPointBy = p2y + halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 3: + tempPointBy = bottomLeftBy; + tempPointBx = p2x + halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 4: + tempPointBx = bottomLeftBx; + tempPointBy = p2y + -halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + } + } + } + return false; +}; + +/** + * This method returns in which cardinal direction does input point stays + * 1: North + * 2: East + * 3: South + * 4: West + */ +IGeometry.getCardinalDirection = function (slope, slopePrime, line) { + if (slope > slopePrime) { + return line; + } else { + return 1 + line % 4; + } +}; + +/** + * This method calculates the intersection of the two lines defined by + * point pairs (s1,s2) and (f1,f2). + */ +IGeometry.getIntersection = function (s1, s2, f1, f2) { + if (f2 == null) { + return this.getIntersection2(s1, s2, f1); + } + + var x1 = s1.x; + var y1 = s1.y; + var x2 = s2.x; + var y2 = s2.y; + var x3 = f1.x; + var y3 = f1.y; + var x4 = f2.x; + var y4 = f2.y; + var x = void 0, + y = void 0; // intersection point + var a1 = void 0, + a2 = void 0, + b1 = void 0, + b2 = void 0, + c1 = void 0, + c2 = void 0; // coefficients of line eqns. + var denom = void 0; + + a1 = y2 - y1; + b1 = x1 - x2; + c1 = x2 * y1 - x1 * y2; // { a1*x + b1*y + c1 = 0 is line 1 } + + a2 = y4 - y3; + b2 = x3 - x4; + c2 = x4 * y3 - x3 * y4; // { a2*x + b2*y + c2 = 0 is line 2 } + + denom = a1 * b2 - a2 * b1; + + if (denom === 0) { + return null; + } + + x = (b1 * c2 - b2 * c1) / denom; + y = (a2 * c1 - a1 * c2) / denom; + + return new Point(x, y); +}; + +/** + * This method finds and returns the angle of the vector from the + x-axis + * in clockwise direction (compatible w/ Java coordinate system!). + */ +IGeometry.angleOfVector = function (Cx, Cy, Nx, Ny) { + var C_angle = void 0; + + if (Cx !== Nx) { + C_angle = Math.atan((Ny - Cy) / (Nx - Cx)); + + if (Nx < Cx) { + C_angle += Math.PI; + } else if (Ny < Cy) { + C_angle += this.TWO_PI; + } + } else if (Ny < Cy) { + C_angle = this.ONE_AND_HALF_PI; // 270 degrees + } else { + C_angle = this.HALF_PI; // 90 degrees + } + + return C_angle; +}; + +/** + * This method checks whether the given two line segments (one with point + * p1 and p2, the other with point p3 and p4) intersect at a point other + * than these points. + */ +IGeometry.doIntersect = function (p1, p2, p3, p4) { + var a = p1.x; + var b = p1.y; + var c = p2.x; + var d = p2.y; + var p = p3.x; + var q = p3.y; + var r = p4.x; + var s = p4.y; + var det = (c - a) * (s - q) - (r - p) * (d - b); + + if (det === 0) { + return false; + } else { + var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det; + var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det; + return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1; + } +}; + +/** + * This method checks and calculates the intersection of + * a line segment and a circle. + */ +IGeometry.findCircleLineIntersections = function (Ex, Ey, Lx, Ly, Cx, Cy, r) { + + // E is the starting point of the ray, + // L is the end point of the ray, + // C is the center of sphere you're testing against + // r is the radius of that sphere + + // Compute: + // d = L - E ( Direction vector of ray, from start to end ) + // f = E - C ( Vector from center sphere to ray start ) + + // Then the intersection is found by.. + // P = E + t * d + // This is a parametric equation: + // Px = Ex + tdx + // Py = Ey + tdy + + // get a, b, c values + var a = (Lx - Ex) * (Lx - Ex) + (Ly - Ey) * (Ly - Ey); + var b = 2 * ((Ex - Cx) * (Lx - Ex) + (Ey - Cy) * (Ly - Ey)); + var c = (Ex - Cx) * (Ex - Cx) + (Ey - Cy) * (Ey - Cy) - r * r; + + // get discriminant + var disc = b * b - 4 * a * c; + if (disc >= 0) { + // insert into quadratic formula + var t1 = (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a); + var t2 = (-b - Math.sqrt(b * b - 4 * a * c)) / (2 * a); + var intersections = null; + if (t1 >= 0 && t1 <= 1) { + // t1 is the intersection, and it's closer than t2 + // (since t1 uses -b - discriminant) + // Impale, Poke + return [t1]; + } + + // here t1 didn't intersect so we are either started + // inside the sphere or completely past it + if (t2 >= 0 && t2 <= 1) { + // ExitWound + return [t2]; + } + + return intersections; + } else return null; +}; + +// ----------------------------------------------------------------------------- +// Section: Class Constants +// ----------------------------------------------------------------------------- +/** + * Some useful pre-calculated constants + */ +IGeometry.HALF_PI = 0.5 * Math.PI; +IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI; +IGeometry.TWO_PI = 2.0 * Math.PI; +IGeometry.THREE_PI = 3.0 * Math.PI; + +module.exports = IGeometry; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function IMath() {} + +/** + * This method returns the sign of the input value. + */ +IMath.sign = function (value) { + if (value > 0) { + return 1; + } else if (value < 0) { + return -1; + } else { + return 0; + } +}; + +IMath.floor = function (value) { + return value < 0 ? Math.ceil(value) : Math.floor(value); +}; + +IMath.ceil = function (value) { + return value < 0 ? Math.floor(value) : Math.ceil(value); +}; + +module.exports = IMath; + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function Integer() {} + +Integer.MAX_VALUE = 2147483647; +Integer.MIN_VALUE = -2147483648; + +module.exports = Integer; + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var nodeFrom = function nodeFrom(value) { + return { value: value, next: null, prev: null }; +}; + +var add = function add(prev, node, next, list) { + if (prev !== null) { + prev.next = node; + } else { + list.head = node; + } + + if (next !== null) { + next.prev = node; + } else { + list.tail = node; + } + + node.prev = prev; + node.next = next; + + list.length++; + + return node; +}; + +var _remove = function _remove(node, list) { + var prev = node.prev, + next = node.next; + + + if (prev !== null) { + prev.next = next; + } else { + list.head = next; + } + + if (next !== null) { + next.prev = prev; + } else { + list.tail = prev; + } + + node.prev = node.next = null; + + list.length--; + + return node; +}; + +var LinkedList = function () { + function LinkedList(vals) { + var _this = this; + + _classCallCheck(this, LinkedList); + + this.length = 0; + this.head = null; + this.tail = null; + + if (vals != null) { + vals.forEach(function (v) { + return _this.push(v); + }); + } + } + + _createClass(LinkedList, [{ + key: "size", + value: function size() { + return this.length; + } + }, { + key: "insertBefore", + value: function insertBefore(val, otherNode) { + return add(otherNode.prev, nodeFrom(val), otherNode, this); + } + }, { + key: "insertAfter", + value: function insertAfter(val, otherNode) { + return add(otherNode, nodeFrom(val), otherNode.next, this); + } + }, { + key: "insertNodeBefore", + value: function insertNodeBefore(newNode, otherNode) { + return add(otherNode.prev, newNode, otherNode, this); + } + }, { + key: "insertNodeAfter", + value: function insertNodeAfter(newNode, otherNode) { + return add(otherNode, newNode, otherNode.next, this); + } + }, { + key: "push", + value: function push(val) { + return add(this.tail, nodeFrom(val), null, this); + } + }, { + key: "unshift", + value: function unshift(val) { + return add(null, nodeFrom(val), this.head, this); + } + }, { + key: "remove", + value: function remove(node) { + return _remove(node, this); + } + }, { + key: "pop", + value: function pop() { + return _remove(this.tail, this).value; + } + }, { + key: "popNode", + value: function popNode() { + return _remove(this.tail, this); + } + }, { + key: "shift", + value: function shift() { + return _remove(this.head, this).value; + } + }, { + key: "shiftNode", + value: function shiftNode() { + return _remove(this.head, this); + } + }, { + key: "get_object_at", + value: function get_object_at(index) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + return current.value; + } + } + }, { + key: "set_object_at", + value: function set_object_at(index, value) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + current.value = value; + } + } + }]); + + return LinkedList; +}(); + +module.exports = LinkedList; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/* + *This class is the javascript implementation of the Point.java class in jdk + */ +function Point(x, y, p) { + this.x = null; + this.y = null; + if (x == null && y == null && p == null) { + this.x = 0; + this.y = 0; + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + this.x = x; + this.y = y; + } else if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.x = p.x; + this.y = p.y; + } +} + +Point.prototype.getX = function () { + return this.x; +}; + +Point.prototype.getY = function () { + return this.y; +}; + +Point.prototype.getLocation = function () { + return new Point(this.x, this.y); +}; + +Point.prototype.setLocation = function (x, y, p) { + if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.setLocation(p.x, p.y); + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + //if both parameters are integer just move (x,y) location + if (parseInt(x) == x && parseInt(y) == y) { + this.move(x, y); + } else { + this.x = Math.floor(x + 0.5); + this.y = Math.floor(y + 0.5); + } + } +}; + +Point.prototype.move = function (x, y) { + this.x = x; + this.y = y; +}; + +Point.prototype.translate = function (dx, dy) { + this.x += dx; + this.y += dy; +}; + +Point.prototype.equals = function (obj) { + if (obj.constructor.name == "Point") { + var pt = obj; + return this.x == pt.x && this.y == pt.y; + } + return this == obj; +}; + +Point.prototype.toString = function () { + return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]"; +}; + +module.exports = Point; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function RectangleD(x, y, width, height) { + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + + if (x != null && y != null && width != null && height != null) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } +} + +RectangleD.prototype.getX = function () { + return this.x; +}; + +RectangleD.prototype.setX = function (x) { + this.x = x; +}; + +RectangleD.prototype.getY = function () { + return this.y; +}; + +RectangleD.prototype.setY = function (y) { + this.y = y; +}; + +RectangleD.prototype.getWidth = function () { + return this.width; +}; + +RectangleD.prototype.setWidth = function (width) { + this.width = width; +}; + +RectangleD.prototype.getHeight = function () { + return this.height; +}; + +RectangleD.prototype.setHeight = function (height) { + this.height = height; +}; + +RectangleD.prototype.getRight = function () { + return this.x + this.width; +}; + +RectangleD.prototype.getBottom = function () { + return this.y + this.height; +}; + +RectangleD.prototype.intersects = function (a) { + if (this.getRight() < a.x) { + return false; + } + + if (this.getBottom() < a.y) { + return false; + } + + if (a.getRight() < this.x) { + return false; + } + + if (a.getBottom() < this.y) { + return false; + } + + return true; +}; + +RectangleD.prototype.getCenterX = function () { + return this.x + this.width / 2; +}; + +RectangleD.prototype.getMinX = function () { + return this.getX(); +}; + +RectangleD.prototype.getMaxX = function () { + return this.getX() + this.width; +}; + +RectangleD.prototype.getCenterY = function () { + return this.y + this.height / 2; +}; + +RectangleD.prototype.getMinY = function () { + return this.getY(); +}; + +RectangleD.prototype.getMaxY = function () { + return this.getY() + this.height; +}; + +RectangleD.prototype.getWidthHalf = function () { + return this.width / 2; +}; + +RectangleD.prototype.getHeightHalf = function () { + return this.height / 2; +}; + +module.exports = RectangleD; + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +function UniqueIDGeneretor() {} + +UniqueIDGeneretor.lastID = 0; + +UniqueIDGeneretor.createID = function (obj) { + if (UniqueIDGeneretor.isPrimitive(obj)) { + return obj; + } + if (obj.uniqueID != null) { + return obj.uniqueID; + } + obj.uniqueID = UniqueIDGeneretor.getString(); + UniqueIDGeneretor.lastID++; + return obj.uniqueID; +}; + +UniqueIDGeneretor.getString = function (id) { + if (id == null) id = UniqueIDGeneretor.lastID; + return "Object#" + id + ""; +}; + +UniqueIDGeneretor.isPrimitive = function (arg) { + var type = typeof arg === "undefined" ? "undefined" : _typeof(arg); + return arg == null || type != "object" && type != "function"; +}; + +module.exports = UniqueIDGeneretor; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var LayoutConstants = __webpack_require__(0); +var LGraphManager = __webpack_require__(7); +var LNode = __webpack_require__(3); +var LEdge = __webpack_require__(1); +var LGraph = __webpack_require__(6); +var PointD = __webpack_require__(5); +var Transform = __webpack_require__(17); +var Emitter = __webpack_require__(29); + +function Layout(isRemoteUse) { + Emitter.call(this); + + //Layout Quality: 0:draft, 1:default, 2:proof + this.layoutQuality = LayoutConstants.QUALITY; + //Whether layout should create bendpoints as needed or not + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + //Whether layout should be incremental or not + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + //Whether we animate from before to after layout node positions + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + //Whether we animate the layout process or not + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + //Number iterations that should be done between two successive animations + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + /** + * Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When + * they are, both spring and repulsion forces between two leaf nodes can be + * calculated without the expensive clipping point calculations, resulting + * in major speed-up. + */ + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + /** + * This is used for creation of bendpoints by using dummy nodes and edges. + * Maps an LEdge to its dummy bendpoint path. + */ + this.edgeToDummyNodes = new Map(); + this.graphManager = new LGraphManager(this); + this.isLayoutFinished = false; + this.isSubLayout = false; + this.isRemoteUse = false; + + if (isRemoteUse != null) { + this.isRemoteUse = isRemoteUse; + } +} + +Layout.RANDOM_SEED = 1; + +Layout.prototype = Object.create(Emitter.prototype); + +Layout.prototype.getGraphManager = function () { + return this.graphManager; +}; + +Layout.prototype.getAllNodes = function () { + return this.graphManager.getAllNodes(); +}; + +Layout.prototype.getAllEdges = function () { + return this.graphManager.getAllEdges(); +}; + +Layout.prototype.getAllNodesToApplyGravitation = function () { + return this.graphManager.getAllNodesToApplyGravitation(); +}; + +Layout.prototype.newGraphManager = function () { + var gm = new LGraphManager(this); + this.graphManager = gm; + return gm; +}; + +Layout.prototype.newGraph = function (vGraph) { + return new LGraph(null, this.graphManager, vGraph); +}; + +Layout.prototype.newNode = function (vNode) { + return new LNode(this.graphManager, vNode); +}; + +Layout.prototype.newEdge = function (vEdge) { + return new LEdge(null, null, vEdge); +}; + +Layout.prototype.checkLayoutSuccess = function () { + return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge(); +}; + +Layout.prototype.runLayout = function () { + this.isLayoutFinished = false; + + if (this.tilingPreLayout) { + this.tilingPreLayout(); + } + + this.initParameters(); + var isLayoutSuccessfull; + + if (this.checkLayoutSuccess()) { + isLayoutSuccessfull = false; + } else { + isLayoutSuccessfull = this.layout(); + } + + if (LayoutConstants.ANIMATE === 'during') { + // If this is a 'during' layout animation. Layout is not finished yet. + // We need to perform these in index.js when layout is really finished. + return false; + } + + if (isLayoutSuccessfull) { + if (!this.isSubLayout) { + this.doPostLayout(); + } + } + + if (this.tilingPostLayout) { + this.tilingPostLayout(); + } + + this.isLayoutFinished = true; + + return isLayoutSuccessfull; +}; + +/** + * This method performs the operations required after layout. + */ +Layout.prototype.doPostLayout = function () { + //assert !isSubLayout : "Should not be called on sub-layout!"; + // Propagate geometric changes to v-level objects + if (!this.incremental) { + this.transform(); + } + this.update(); +}; + +/** + * This method updates the geometry of the target graph according to + * calculated layout. + */ +Layout.prototype.update2 = function () { + // update bend points + if (this.createBendsAsNeeded) { + this.createBendpointsFromDummyNodes(); + + // reset all edges, since the topology has changed + this.graphManager.resetAllEdges(); + } + + // perform edge, node and root updates if layout is not called + // remotely + if (!this.isRemoteUse) { + // update all edges + var edge; + var allEdges = this.graphManager.getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + edge = allEdges[i]; + // this.update(edge); + } + + // recursively update nodes + var node; + var nodes = this.graphManager.getRoot().getNodes(); + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + // this.update(node); + } + + // update root graph + this.update(this.graphManager.getRoot()); + } +}; + +Layout.prototype.update = function (obj) { + if (obj == null) { + this.update2(); + } else if (obj instanceof LNode) { + var node = obj; + if (node.getChild() != null) { + // since node is compound, recursively update child nodes + var nodes = node.getChild().getNodes(); + for (var i = 0; i < nodes.length; i++) { + update(nodes[i]); + } + } + + // if the l-level node is associated with a v-level graph object, + // then it is assumed that the v-level node implements the + // interface Updatable. + if (node.vGraphObject != null) { + // cast to Updatable without any type check + var vNode = node.vGraphObject; + + // call the update method of the interface + vNode.update(node); + } + } else if (obj instanceof LEdge) { + var edge = obj; + // if the l-level edge is associated with a v-level graph object, + // then it is assumed that the v-level edge implements the + // interface Updatable. + + if (edge.vGraphObject != null) { + // cast to Updatable without any type check + var vEdge = edge.vGraphObject; + + // call the update method of the interface + vEdge.update(edge); + } + } else if (obj instanceof LGraph) { + var graph = obj; + // if the l-level graph is associated with a v-level graph object, + // then it is assumed that the v-level object implements the + // interface Updatable. + + if (graph.vGraphObject != null) { + // cast to Updatable without any type check + var vGraph = graph.vGraphObject; + + // call the update method of the interface + vGraph.update(graph); + } + } +}; + +/** + * This method is used to set all layout parameters to default values + * determined at compile time. + */ +Layout.prototype.initParameters = function () { + if (!this.isSubLayout) { + this.layoutQuality = LayoutConstants.QUALITY; + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + } + + if (this.animationDuringLayout) { + this.animationOnLayout = false; + } +}; + +Layout.prototype.transform = function (newLeftTop) { + if (newLeftTop == undefined) { + this.transform(new PointD(0, 0)); + } else { + // create a transformation object (from Eclipse to layout). When an + // inverse transform is applied, we get upper-left coordinate of the + // drawing or the root graph at given input coordinate (some margins + // already included in calculation of left-top). + + var trans = new Transform(); + var leftTop = this.graphManager.getRoot().updateLeftTop(); + + if (leftTop != null) { + trans.setWorldOrgX(newLeftTop.x); + trans.setWorldOrgY(newLeftTop.y); + + trans.setDeviceOrgX(leftTop.x); + trans.setDeviceOrgY(leftTop.y); + + var nodes = this.getAllNodes(); + var node; + + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + node.transform(trans); + } + } + } +}; + +Layout.prototype.positionNodesRandomly = function (graph) { + + if (graph == undefined) { + //assert !this.incremental; + this.positionNodesRandomly(this.getGraphManager().getRoot()); + this.getGraphManager().getRoot().updateBounds(true); + } else { + var lNode; + var childGraph; + + var nodes = graph.getNodes(); + for (var i = 0; i < nodes.length; i++) { + lNode = nodes[i]; + childGraph = lNode.getChild(); + + if (childGraph == null) { + lNode.scatter(); + } else if (childGraph.getNodes().length == 0) { + lNode.scatter(); + } else { + this.positionNodesRandomly(childGraph); + lNode.updateBounds(); + } + } + } +}; + +/** + * This method returns a list of trees where each tree is represented as a + * list of l-nodes. The method returns a list of size 0 when: + * - The graph is not flat or + * - One of the component(s) of the graph is not a tree. + */ +Layout.prototype.getFlatForest = function () { + var flatForest = []; + var isForest = true; + + // Quick reference for all nodes in the graph manager associated with + // this layout. The list should not be changed. + var allNodes = this.graphManager.getRoot().getNodes(); + + // First be sure that the graph is flat + var isFlat = true; + + for (var i = 0; i < allNodes.length; i++) { + if (allNodes[i].getChild() != null) { + isFlat = false; + } + } + + // Return empty forest if the graph is not flat. + if (!isFlat) { + return flatForest; + } + + // Run BFS for each component of the graph. + + var visited = new Set(); + var toBeVisited = []; + var parents = new Map(); + var unProcessedNodes = []; + + unProcessedNodes = unProcessedNodes.concat(allNodes); + + // Each iteration of this loop finds a component of the graph and + // decides whether it is a tree or not. If it is a tree, adds it to the + // forest and continued with the next component. + + while (unProcessedNodes.length > 0 && isForest) { + toBeVisited.push(unProcessedNodes[0]); + + // Start the BFS. Each iteration of this loop visits a node in a + // BFS manner. + while (toBeVisited.length > 0 && isForest) { + //pool operation + var currentNode = toBeVisited[0]; + toBeVisited.splice(0, 1); + visited.add(currentNode); + + // Traverse all neighbors of this node + var neighborEdges = currentNode.getEdges(); + + for (var i = 0; i < neighborEdges.length; i++) { + var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode); + + // If BFS is not growing from this neighbor. + if (parents.get(currentNode) != currentNeighbor) { + // We haven't previously visited this neighbor. + if (!visited.has(currentNeighbor)) { + toBeVisited.push(currentNeighbor); + parents.set(currentNeighbor, currentNode); + } + // Since we have previously visited this neighbor and + // this neighbor is not parent of currentNode, given + // graph contains a component that is not tree, hence + // it is not a forest. + else { + isForest = false; + break; + } + } + } + } + + // The graph contains a component that is not a tree. Empty + // previously found trees. The method will end. + if (!isForest) { + flatForest = []; + } + // Save currently visited nodes as a tree in our forest. Reset + // visited and parents lists. Continue with the next component of + // the graph, if any. + else { + var temp = [].concat(_toConsumableArray(visited)); + flatForest.push(temp); + //flatForest = flatForest.concat(temp); + //unProcessedNodes.removeAll(visited); + for (var i = 0; i < temp.length; i++) { + var value = temp[i]; + var index = unProcessedNodes.indexOf(value); + if (index > -1) { + unProcessedNodes.splice(index, 1); + } + } + visited = new Set(); + parents = new Map(); + } + } + + return flatForest; +}; + +/** + * This method creates dummy nodes (an l-level node with minimal dimensions) + * for the given edge (one per bendpoint). The existing l-level structure + * is updated accordingly. + */ +Layout.prototype.createDummyNodesForBendpoints = function (edge) { + var dummyNodes = []; + var prev = edge.source; + + var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target); + + for (var i = 0; i < edge.bendpoints.length; i++) { + // create new dummy node + var dummyNode = this.newNode(null); + dummyNode.setRect(new Point(0, 0), new Dimension(1, 1)); + + graph.add(dummyNode); + + // create new dummy edge between prev and dummy node + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, dummyNode); + + dummyNodes.add(dummyNode); + prev = dummyNode; + } + + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, edge.target); + + this.edgeToDummyNodes.set(edge, dummyNodes); + + // remove real edge from graph manager if it is inter-graph + if (edge.isInterGraph()) { + this.graphManager.remove(edge); + } + // else, remove the edge from the current graph + else { + graph.remove(edge); + } + + return dummyNodes; +}; + +/** + * This method creates bendpoints for edges from the dummy nodes + * at l-level. + */ +Layout.prototype.createBendpointsFromDummyNodes = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges); + + for (var k = 0; k < edges.length; k++) { + var lEdge = edges[k]; + + if (lEdge.bendpoints.length > 0) { + var path = this.edgeToDummyNodes.get(lEdge); + + for (var i = 0; i < path.length; i++) { + var dummyNode = path[i]; + var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY()); + + // update bendpoint's location according to dummy node + var ebp = lEdge.bendpoints.get(i); + ebp.x = p.x; + ebp.y = p.y; + + // remove the dummy node, dummy edges incident with this + // dummy node is also removed (within the remove method) + dummyNode.getOwner().remove(dummyNode); + } + + // add the real edge to graph + this.graphManager.add(lEdge, lEdge.source, lEdge.target); + } + } +}; + +Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) { + if (minDiv != undefined && maxMul != undefined) { + var value = defaultValue; + + if (sliderValue <= 50) { + var minValue = defaultValue / minDiv; + value -= (defaultValue - minValue) / 50 * (50 - sliderValue); + } else { + var maxValue = defaultValue * maxMul; + value += (maxValue - defaultValue) / 50 * (sliderValue - 50); + } + + return value; + } else { + var a, b; + + if (sliderValue <= 50) { + a = 9.0 * defaultValue / 500.0; + b = defaultValue / 10.0; + } else { + a = 9.0 * defaultValue / 50.0; + b = -8 * defaultValue; + } + + return a * sliderValue + b; + } +}; + +/** + * This method finds and returns the center of the given nodes, assuming + * that the given nodes form a tree in themselves. + */ +Layout.findCenterOfTree = function (nodes) { + var list = []; + list = list.concat(nodes); + + var removedNodes = []; + var remainingDegrees = new Map(); + var foundCenter = false; + var centerNode = null; + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + var degree = node.getNeighborsList().size; + remainingDegrees.set(node, node.getNeighborsList().size); + + if (degree == 1) { + removedNodes.push(node); + } + } + + var tempList = []; + tempList = tempList.concat(removedNodes); + + while (!foundCenter) { + var tempList2 = []; + tempList2 = tempList2.concat(tempList); + tempList = []; + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + + var index = list.indexOf(node); + if (index >= 0) { + list.splice(index, 1); + } + + var neighbours = node.getNeighborsList(); + + neighbours.forEach(function (neighbour) { + if (removedNodes.indexOf(neighbour) < 0) { + var otherDegree = remainingDegrees.get(neighbour); + var newDegree = otherDegree - 1; + + if (newDegree == 1) { + tempList.push(neighbour); + } + + remainingDegrees.set(neighbour, newDegree); + } + }); + } + + removedNodes = removedNodes.concat(tempList); + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + } + + return centerNode; +}; + +/** + * During the coarsening process, this layout may be referenced by two graph managers + * this setter function grants access to change the currently being used graph manager + */ +Layout.prototype.setGraphManager = function (gm) { + this.graphManager = gm; +}; + +module.exports = Layout; + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function RandomSeed() {} +// adapted from: https://stackoverflow.com/a/19303725 +RandomSeed.seed = 1; +RandomSeed.x = 0; + +RandomSeed.nextDouble = function () { + RandomSeed.x = Math.sin(RandomSeed.seed++) * 10000; + return RandomSeed.x - Math.floor(RandomSeed.x); +}; + +module.exports = RandomSeed; + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var PointD = __webpack_require__(5); + +function Transform(x, y) { + this.lworldOrgX = 0.0; + this.lworldOrgY = 0.0; + this.ldeviceOrgX = 0.0; + this.ldeviceOrgY = 0.0; + this.lworldExtX = 1.0; + this.lworldExtY = 1.0; + this.ldeviceExtX = 1.0; + this.ldeviceExtY = 1.0; +} + +Transform.prototype.getWorldOrgX = function () { + return this.lworldOrgX; +}; + +Transform.prototype.setWorldOrgX = function (wox) { + this.lworldOrgX = wox; +}; + +Transform.prototype.getWorldOrgY = function () { + return this.lworldOrgY; +}; + +Transform.prototype.setWorldOrgY = function (woy) { + this.lworldOrgY = woy; +}; + +Transform.prototype.getWorldExtX = function () { + return this.lworldExtX; +}; + +Transform.prototype.setWorldExtX = function (wex) { + this.lworldExtX = wex; +}; + +Transform.prototype.getWorldExtY = function () { + return this.lworldExtY; +}; + +Transform.prototype.setWorldExtY = function (wey) { + this.lworldExtY = wey; +}; + +/* Device related */ + +Transform.prototype.getDeviceOrgX = function () { + return this.ldeviceOrgX; +}; + +Transform.prototype.setDeviceOrgX = function (dox) { + this.ldeviceOrgX = dox; +}; + +Transform.prototype.getDeviceOrgY = function () { + return this.ldeviceOrgY; +}; + +Transform.prototype.setDeviceOrgY = function (doy) { + this.ldeviceOrgY = doy; +}; + +Transform.prototype.getDeviceExtX = function () { + return this.ldeviceExtX; +}; + +Transform.prototype.setDeviceExtX = function (dex) { + this.ldeviceExtX = dex; +}; + +Transform.prototype.getDeviceExtY = function () { + return this.ldeviceExtY; +}; + +Transform.prototype.setDeviceExtY = function (dey) { + this.ldeviceExtY = dey; +}; + +Transform.prototype.transformX = function (x) { + var xDevice = 0.0; + var worldExtX = this.lworldExtX; + if (worldExtX != 0.0) { + xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX; + } + + return xDevice; +}; + +Transform.prototype.transformY = function (y) { + var yDevice = 0.0; + var worldExtY = this.lworldExtY; + if (worldExtY != 0.0) { + yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY; + } + + return yDevice; +}; + +Transform.prototype.inverseTransformX = function (x) { + var xWorld = 0.0; + var deviceExtX = this.ldeviceExtX; + if (deviceExtX != 0.0) { + xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX; + } + + return xWorld; +}; + +Transform.prototype.inverseTransformY = function (y) { + var yWorld = 0.0; + var deviceExtY = this.ldeviceExtY; + if (deviceExtY != 0.0) { + yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY; + } + return yWorld; +}; + +Transform.prototype.inverseTransformPoint = function (inPoint) { + var outPoint = new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y)); + return outPoint; +}; + +module.exports = Transform; + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var Layout = __webpack_require__(15); +var FDLayoutConstants = __webpack_require__(4); +var LayoutConstants = __webpack_require__(0); +var IGeometry = __webpack_require__(8); +var IMath = __webpack_require__(9); + +function FDLayout() { + Layout.call(this); + + this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + this.displacementThresholdPerNode = 3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100; + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.totalDisplacement = 0.0; + this.oldTotalDisplacement = 0.0; + this.maxIterations = FDLayoutConstants.MAX_ITERATIONS; +} + +FDLayout.prototype = Object.create(Layout.prototype); + +for (var prop in Layout) { + FDLayout[prop] = Layout[prop]; +} + +FDLayout.prototype.initParameters = function () { + Layout.prototype.initParameters.call(this, arguments); + + this.totalIterations = 0; + this.notAnimatedIterations = 0; + + this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION; + + this.grid = []; +}; + +FDLayout.prototype.calcIdealEdgeLengths = function () { + var edge; + var originalIdealLength; + var lcaDepth; + var source; + var target; + var sizeOfSourceInLca; + var sizeOfTargetInLca; + + var allEdges = this.getGraphManager().getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + edge = allEdges[i]; + + originalIdealLength = edge.idealLength; + + if (edge.isInterGraph) { + source = edge.getSource(); + target = edge.getTarget(); + + sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize(); + sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize(); + + if (this.useSmartIdealEdgeLengthCalculation) { + edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE; + } + + lcaDepth = edge.getLca().getInclusionTreeDepth(); + + edge.idealLength += originalIdealLength * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth); + } + } +}; + +FDLayout.prototype.initSpringEmbedder = function () { + + var s = this.getAllNodes().length; + if (this.incremental) { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL; + } else { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1.0 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } else { + this.coolingFactor = 1.0; + } + this.initialCoolingFactor = this.coolingFactor; + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT; + } + + this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations); + + // Reassign this attribute by using new constant value + this.displacementThresholdPerNode = 3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100; + this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length; + + this.repulsionRange = this.calcRepulsionRange(); +}; + +FDLayout.prototype.calcSpringForces = function () { + var lEdges = this.getAllEdges(); + var edge; + + for (var i = 0; i < lEdges.length; i++) { + edge = lEdges[i]; + + this.calcSpringForce(edge, edge.idealLength); + } +}; + +FDLayout.prototype.calcRepulsionForces = function () { + var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + var i, j; + var nodeA, nodeB; + var lNodes = this.getAllNodes(); + var processedNodeSet; + + if (this.useFRGridVariant) { + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) { + this.updateGrid(); + } + + processedNodeSet = new Set(); + + // calculate repulsion forces between each nodes and its surrounding + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate); + processedNodeSet.add(nodeA); + } + } else { + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + + for (j = i + 1; j < lNodes.length; j++) { + nodeB = lNodes[j]; + + // If both nodes are not members of the same graph, skip. + if (nodeA.getOwner() != nodeB.getOwner()) { + continue; + } + + this.calcRepulsionForce(nodeA, nodeB); + } + } + } +}; + +FDLayout.prototype.calcGravitationalForces = function () { + var node; + var lNodes = this.getAllNodesToApplyGravitation(); + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + this.calcGravitationalForce(node); + } +}; + +FDLayout.prototype.moveNodes = function () { + var lNodes = this.getAllNodes(); + var node; + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + node.move(); + } +}; + +FDLayout.prototype.calcSpringForce = function (edge, idealLength) { + var sourceNode = edge.getSource(); + var targetNode = edge.getTarget(); + + var length; + var springForce; + var springForceX; + var springForceY; + + // Update edge length + if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) { + edge.updateLengthSimple(); + } else { + edge.updateLength(); + + if (edge.isOverlapingSourceAndTarget) { + return; + } + } + + length = edge.getLength(); + + if (length == 0) return; + + // Calculate spring forces + springForce = edge.edgeElasticity * (length - idealLength); + + // Project force onto x and y axes + springForceX = springForce * (edge.lengthX / length); + springForceY = springForce * (edge.lengthY / length); + + // Apply forces on the end nodes + sourceNode.springForceX += springForceX; + sourceNode.springForceY += springForceY; + targetNode.springForceX -= springForceX; + targetNode.springForceY -= springForceY; +}; + +FDLayout.prototype.calcRepulsionForce = function (nodeA, nodeB) { + var rectA = nodeA.getRect(); + var rectB = nodeB.getRect(); + var overlapAmount = new Array(2); + var clipPoints = new Array(4); + var distanceX; + var distanceY; + var distanceSquared; + var distance; + var repulsionForce; + var repulsionForceX; + var repulsionForceY; + + if (rectA.intersects(rectB)) // two nodes overlap + { + // calculate separation amount in x and y directions + IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2.0); + + repulsionForceX = 2 * overlapAmount[0]; + repulsionForceY = 2 * overlapAmount[1]; + + var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren); + + // Apply forces on the two nodes + nodeA.repulsionForceX -= childrenConstant * repulsionForceX; + nodeA.repulsionForceY -= childrenConstant * repulsionForceY; + nodeB.repulsionForceX += childrenConstant * repulsionForceX; + nodeB.repulsionForceY += childrenConstant * repulsionForceY; + } else // no overlap + { + // calculate distance + + if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) // simply base repulsion on distance of node centers + { + distanceX = rectB.getCenterX() - rectA.getCenterX(); + distanceY = rectB.getCenterY() - rectA.getCenterY(); + } else // use clipping points + { + IGeometry.getIntersection(rectA, rectB, clipPoints); + + distanceX = clipPoints[2] - clipPoints[0]; + distanceY = clipPoints[3] - clipPoints[1]; + } + + // No repulsion range. FR grid variant should take care of this. + if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + distanceSquared = distanceX * distanceX + distanceY * distanceY; + distance = Math.sqrt(distanceSquared); + + // Here we use half of the nodes' repulsion values for backward compatibility + repulsionForce = (nodeA.nodeRepulsion / 2 + nodeB.nodeRepulsion / 2) * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared; + + // Project force onto x and y axes + repulsionForceX = repulsionForce * distanceX / distance; + repulsionForceY = repulsionForce * distanceY / distance; + + // Apply forces on the two nodes + nodeA.repulsionForceX -= repulsionForceX; + nodeA.repulsionForceY -= repulsionForceY; + nodeB.repulsionForceX += repulsionForceX; + nodeB.repulsionForceY += repulsionForceY; + } +}; + +FDLayout.prototype.calcGravitationalForce = function (node) { + var ownerGraph; + var ownerCenterX; + var ownerCenterY; + var distanceX; + var distanceY; + var absDistanceX; + var absDistanceY; + var estimatedSize; + ownerGraph = node.getOwner(); + + ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2; + ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2; + distanceX = node.getCenterX() - ownerCenterX; + distanceY = node.getCenterY() - ownerCenterY; + absDistanceX = Math.abs(distanceX) + node.getWidth() / 2; + absDistanceY = Math.abs(distanceY) + node.getHeight() / 2; + + if (node.getOwner() == this.graphManager.getRoot()) // in the root graph + { + estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX; + node.gravitationForceY = -this.gravityConstant * distanceY; + } + } else // inside a compound + { + estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant; + node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant; + } + } +}; + +FDLayout.prototype.isConverged = function () { + var converged; + var oscilating = false; + + if (this.totalIterations > this.maxIterations / 3) { + oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2; + } + + converged = this.totalDisplacement < this.totalDisplacementThreshold; + + this.oldTotalDisplacement = this.totalDisplacement; + + return converged || oscilating; +}; + +FDLayout.prototype.animate = function () { + if (this.animationDuringLayout && !this.isSubLayout) { + if (this.notAnimatedIterations == this.animationPeriod) { + this.update(); + this.notAnimatedIterations = 0; + } else { + this.notAnimatedIterations++; + } + } +}; + +//This method calculates the number of children (weight) for all nodes +FDLayout.prototype.calcNoOfChildrenForAllNodes = function () { + var node; + var allNodes = this.graphManager.getAllNodes(); + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + node.noOfChildren = node.getNoOfChildren(); + } +}; + +// ----------------------------------------------------------------------------- +// Section: FR-Grid Variant Repulsion Force Calculation +// ----------------------------------------------------------------------------- + +FDLayout.prototype.calcGrid = function (graph) { + + var sizeX = 0; + var sizeY = 0; + + sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange)); + sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange)); + + var grid = new Array(sizeX); + + for (var i = 0; i < sizeX; i++) { + grid[i] = new Array(sizeY); + } + + for (var i = 0; i < sizeX; i++) { + for (var j = 0; j < sizeY; j++) { + grid[i][j] = new Array(); + } + } + + return grid; +}; + +FDLayout.prototype.addNodeToGrid = function (v, left, top) { + + var startX = 0; + var finishX = 0; + var startY = 0; + var finishY = 0; + + startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange)); + finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange)); + startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange)); + finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange)); + + for (var i = startX; i <= finishX; i++) { + for (var j = startY; j <= finishY; j++) { + this.grid[i][j].push(v); + v.setGridCoordinates(startX, finishX, startY, finishY); + } + } +}; + +FDLayout.prototype.updateGrid = function () { + var i; + var nodeA; + var lNodes = this.getAllNodes(); + + this.grid = this.calcGrid(this.graphManager.getRoot()); + + // put all nodes to proper grid cells + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop()); + } +}; + +FDLayout.prototype.calculateRepulsionForceOfANode = function (nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) { + + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) { + var surrounding = new Set(); + nodeA.surrounding = new Array(); + var nodeB; + var grid = this.grid; + + for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) { + for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) { + if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) { + for (var k = 0; k < grid[i][j].length; k++) { + nodeB = grid[i][j][k]; + + // If both nodes are not members of the same graph, + // or both nodes are the same, skip. + if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) { + continue; + } + + // check if the repulsion force between + // nodeA and nodeB has already been calculated + if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) { + var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2); + var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2); + + // if the distance between nodeA and nodeB + // is less then calculation range + if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) { + //then add nodeB to surrounding of nodeA + surrounding.add(nodeB); + } + } + } + } + } + } + + nodeA.surrounding = [].concat(_toConsumableArray(surrounding)); + } + for (i = 0; i < nodeA.surrounding.length; i++) { + this.calcRepulsionForce(nodeA, nodeA.surrounding[i]); + } +}; + +FDLayout.prototype.calcRepulsionRange = function () { + return 0.0; +}; + +module.exports = FDLayout; + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LEdge = __webpack_require__(1); +var FDLayoutConstants = __webpack_require__(4); + +function FDLayoutEdge(source, target, vEdge) { + LEdge.call(this, source, target, vEdge); + + // Ideal length and elasticity value for this edge + this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + this.edgeElasticity = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; +} + +FDLayoutEdge.prototype = Object.create(LEdge.prototype); + +for (var prop in LEdge) { + FDLayoutEdge[prop] = LEdge[prop]; +} + +module.exports = FDLayoutEdge; + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LNode = __webpack_require__(3); +var FDLayoutConstants = __webpack_require__(4); + +function FDLayoutNode(gm, loc, size, vNode) { + // alternative constructor is handled inside LNode + LNode.call(this, gm, loc, size, vNode); + + // Repulsion value of this node + this.nodeRepulsion = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + + //Spring, repulsion and gravitational forces acting on this node + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + //Amount by which this node is to be moved in this iteration + this.displacementX = 0; + this.displacementY = 0; + + //Start and finish grid coordinates that this node is fallen into + this.startX = 0; + this.finishX = 0; + this.startY = 0; + this.finishY = 0; + + //Geometric neighbors of this node + this.surrounding = []; +} + +FDLayoutNode.prototype = Object.create(LNode.prototype); + +for (var prop in LNode) { + FDLayoutNode[prop] = LNode[prop]; +} + +FDLayoutNode.prototype.setGridCoordinates = function (_startX, _finishX, _startY, _finishY) { + this.startX = _startX; + this.finishX = _finishX; + this.startY = _startY; + this.finishY = _finishY; +}; + +module.exports = FDLayoutNode; + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function DimensionD(width, height) { + this.width = 0; + this.height = 0; + if (width !== null && height !== null) { + this.height = height; + this.width = width; + } +} + +DimensionD.prototype.getWidth = function () { + return this.width; +}; + +DimensionD.prototype.setWidth = function (width) { + this.width = width; +}; + +DimensionD.prototype.getHeight = function () { + return this.height; +}; + +DimensionD.prototype.setHeight = function (height) { + this.height = height; +}; + +module.exports = DimensionD; + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var UniqueIDGeneretor = __webpack_require__(14); + +function HashMap() { + this.map = {}; + this.keys = []; +} + +HashMap.prototype.put = function (key, value) { + var theId = UniqueIDGeneretor.createID(key); + if (!this.contains(theId)) { + this.map[theId] = value; + this.keys.push(key); + } +}; + +HashMap.prototype.contains = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[key] != null; +}; + +HashMap.prototype.get = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[theId]; +}; + +HashMap.prototype.keySet = function () { + return this.keys; +}; + +module.exports = HashMap; + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var UniqueIDGeneretor = __webpack_require__(14); + +function HashSet() { + this.set = {}; +} +; + +HashSet.prototype.add = function (obj) { + var theId = UniqueIDGeneretor.createID(obj); + if (!this.contains(theId)) this.set[theId] = obj; +}; + +HashSet.prototype.remove = function (obj) { + delete this.set[UniqueIDGeneretor.createID(obj)]; +}; + +HashSet.prototype.clear = function () { + this.set = {}; +}; + +HashSet.prototype.contains = function (obj) { + return this.set[UniqueIDGeneretor.createID(obj)] == obj; +}; + +HashSet.prototype.isEmpty = function () { + return this.size() === 0; +}; + +HashSet.prototype.size = function () { + return Object.keys(this.set).length; +}; + +//concats this.set to the given list +HashSet.prototype.addAllTo = function (list) { + var keys = Object.keys(this.set); + var length = keys.length; + for (var i = 0; i < length; i++) { + list.push(this.set[keys[i]]); + } +}; + +HashSet.prototype.size = function () { + return Object.keys(this.set).length; +}; + +HashSet.prototype.addAll = function (list) { + var s = list.length; + for (var i = 0; i < s; i++) { + var v = list[i]; + this.add(v); + } +}; + +module.exports = HashSet; + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +// Some matrix (1d and 2d array) operations +function Matrix() {} + +/** + * matrix multiplication + * array1, array2 and result are 2d arrays + */ +Matrix.multMat = function (array1, array2) { + var result = []; + + for (var i = 0; i < array1.length; i++) { + result[i] = []; + for (var j = 0; j < array2[0].length; j++) { + result[i][j] = 0; + for (var k = 0; k < array1[0].length; k++) { + result[i][j] += array1[i][k] * array2[k][j]; + } + } + } + return result; +}; + +/** + * matrix transpose + * array and result are 2d arrays + */ +Matrix.transpose = function (array) { + var result = []; + + for (var i = 0; i < array[0].length; i++) { + result[i] = []; + for (var j = 0; j < array.length; j++) { + result[i][j] = array[j][i]; + } + } + + return result; +}; + +/** + * multiply array with constant + * array and result are 1d arrays + */ +Matrix.multCons = function (array, constant) { + var result = []; + + for (var i = 0; i < array.length; i++) { + result[i] = array[i] * constant; + } + + return result; +}; + +/** + * substract two arrays + * array1, array2 and result are 1d arrays + */ +Matrix.minusOp = function (array1, array2) { + var result = []; + + for (var i = 0; i < array1.length; i++) { + result[i] = array1[i] - array2[i]; + } + + return result; +}; + +/** + * dot product of two arrays with same size + * array1 and array2 are 1d arrays + */ +Matrix.dotProduct = function (array1, array2) { + var product = 0; + + for (var i = 0; i < array1.length; i++) { + product += array1[i] * array2[i]; + } + + return product; +}; + +/** + * magnitude of an array + * array is 1d array + */ +Matrix.mag = function (array) { + return Math.sqrt(this.dotProduct(array, array)); +}; + +/** + * normalization of an array + * array and result are 1d array + */ +Matrix.normalize = function (array) { + var result = []; + var magnitude = this.mag(array); + + for (var i = 0; i < array.length; i++) { + result[i] = array[i] / magnitude; + } + + return result; +}; + +/** + * multiply an array with centering matrix + * array and result are 1d array + */ +Matrix.multGamma = function (array) { + var result = []; + var sum = 0; + + for (var i = 0; i < array.length; i++) { + sum += array[i]; + } + + sum *= -1 / array.length; + + for (var _i = 0; _i < array.length; _i++) { + result[_i] = sum + array[_i]; + } + return result; +}; + +/** + * a special matrix multiplication + * result = 0.5 * C * INV * C^T * array + * array and result are 1d, C and INV are 2d arrays + */ +Matrix.multL = function (array, C, INV) { + var result = []; + var temp1 = []; + var temp2 = []; + + // multiply by C^T + for (var i = 0; i < C[0].length; i++) { + var sum = 0; + for (var j = 0; j < C.length; j++) { + sum += -0.5 * C[j][i] * array[j]; + } + temp1[i] = sum; + } + // multiply the result by INV + for (var _i2 = 0; _i2 < INV.length; _i2++) { + var _sum = 0; + for (var _j = 0; _j < INV.length; _j++) { + _sum += INV[_i2][_j] * temp1[_j]; + } + temp2[_i2] = _sum; + } + // multiply the result by C + for (var _i3 = 0; _i3 < C.length; _i3++) { + var _sum2 = 0; + for (var _j2 = 0; _j2 < C[0].length; _j2++) { + _sum2 += C[_i3][_j2] * temp2[_j2]; + } + result[_i3] = _sum2; + } + + return result; +}; + +module.exports = Matrix; + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * A classic Quicksort algorithm with Hoare's partition + * - Works also on LinkedList objects + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + +var LinkedList = __webpack_require__(11); + +var Quicksort = function () { + function Quicksort(A, compareFunction) { + _classCallCheck(this, Quicksort); + + if (compareFunction !== null || compareFunction !== undefined) this.compareFunction = this._defaultCompareFunction; + + var length = void 0; + if (A instanceof LinkedList) length = A.size();else length = A.length; + + this._quicksort(A, 0, length - 1); + } + + _createClass(Quicksort, [{ + key: '_quicksort', + value: function _quicksort(A, p, r) { + if (p < r) { + var q = this._partition(A, p, r); + this._quicksort(A, p, q); + this._quicksort(A, q + 1, r); + } + } + }, { + key: '_partition', + value: function _partition(A, p, r) { + var x = this._get(A, p); + var i = p; + var j = r; + while (true) { + while (this.compareFunction(x, this._get(A, j))) { + j--; + }while (this.compareFunction(this._get(A, i), x)) { + i++; + }if (i < j) { + this._swap(A, i, j); + i++; + j--; + } else return j; + } + } + }, { + key: '_get', + value: function _get(object, index) { + if (object instanceof LinkedList) return object.get_object_at(index);else return object[index]; + } + }, { + key: '_set', + value: function _set(object, index, value) { + if (object instanceof LinkedList) object.set_object_at(index, value);else object[index] = value; + } + }, { + key: '_swap', + value: function _swap(A, i, j) { + var temp = this._get(A, i); + this._set(A, i, this._get(A, j)); + this._set(A, j, temp); + } + }, { + key: '_defaultCompareFunction', + value: function _defaultCompareFunction(a, b) { + return b > a; + } + }]); + + return Quicksort; +}(); + +module.exports = Quicksort; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +// Singular Value Decomposition implementation +function SVD() {}; + +/* Below singular value decomposition (svd) code including hypot function is adopted from https://github.com/dragonfly-ai/JamaJS + Some changes are applied to make the code compatible with the fcose code and to make it independent from Jama. + Input matrix is changed to a 2D array instead of Jama matrix. Matrix dimensions are taken according to 2D array instead of using Jama functions. + An object that includes singular value components is created for return. + The types of input parameters of the hypot function are removed. + let is used instead of var for the variable initialization. +*/ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +SVD.svd = function (A) { + this.U = null; + this.V = null; + this.s = null; + this.m = 0; + this.n = 0; + this.m = A.length; + this.n = A[0].length; + var nu = Math.min(this.m, this.n); + this.s = function (s) { + var a = []; + while (s-- > 0) { + a.push(0); + }return a; + }(Math.min(this.m + 1, this.n)); + this.U = function (dims) { + var allocate = function allocate(dims) { + if (dims.length == 0) { + return 0; + } else { + var array = []; + for (var i = 0; i < dims[0]; i++) { + array.push(allocate(dims.slice(1))); + } + return array; + } + }; + return allocate(dims); + }([this.m, nu]); + this.V = function (dims) { + var allocate = function allocate(dims) { + if (dims.length == 0) { + return 0; + } else { + var array = []; + for (var i = 0; i < dims[0]; i++) { + array.push(allocate(dims.slice(1))); + } + return array; + } + }; + return allocate(dims); + }([this.n, this.n]); + var e = function (s) { + var a = []; + while (s-- > 0) { + a.push(0); + }return a; + }(this.n); + var work = function (s) { + var a = []; + while (s-- > 0) { + a.push(0); + }return a; + }(this.m); + var wantu = true; + var wantv = true; + var nct = Math.min(this.m - 1, this.n); + var nrt = Math.max(0, Math.min(this.n - 2, this.m)); + for (var k = 0; k < Math.max(nct, nrt); k++) { + if (k < nct) { + this.s[k] = 0; + for (var i = k; i < this.m; i++) { + this.s[k] = SVD.hypot(this.s[k], A[i][k]); + } + ; + if (this.s[k] !== 0.0) { + if (A[k][k] < 0.0) { + this.s[k] = -this.s[k]; + } + for (var _i = k; _i < this.m; _i++) { + A[_i][k] /= this.s[k]; + } + ; + A[k][k] += 1.0; + } + this.s[k] = -this.s[k]; + } + for (var j = k + 1; j < this.n; j++) { + if (function (lhs, rhs) { + return lhs && rhs; + }(k < nct, this.s[k] !== 0.0)) { + var t = 0; + for (var _i2 = k; _i2 < this.m; _i2++) { + t += A[_i2][k] * A[_i2][j]; + } + ; + t = -t / A[k][k]; + for (var _i3 = k; _i3 < this.m; _i3++) { + A[_i3][j] += t * A[_i3][k]; + } + ; + } + e[j] = A[k][j]; + } + ; + if (function (lhs, rhs) { + return lhs && rhs; + }(wantu, k < nct)) { + for (var _i4 = k; _i4 < this.m; _i4++) { + this.U[_i4][k] = A[_i4][k]; + } + ; + } + if (k < nrt) { + e[k] = 0; + for (var _i5 = k + 1; _i5 < this.n; _i5++) { + e[k] = SVD.hypot(e[k], e[_i5]); + } + ; + if (e[k] !== 0.0) { + if (e[k + 1] < 0.0) { + e[k] = -e[k]; + } + for (var _i6 = k + 1; _i6 < this.n; _i6++) { + e[_i6] /= e[k]; + } + ; + e[k + 1] += 1.0; + } + e[k] = -e[k]; + if (function (lhs, rhs) { + return lhs && rhs; + }(k + 1 < this.m, e[k] !== 0.0)) { + for (var _i7 = k + 1; _i7 < this.m; _i7++) { + work[_i7] = 0.0; + } + ; + for (var _j = k + 1; _j < this.n; _j++) { + for (var _i8 = k + 1; _i8 < this.m; _i8++) { + work[_i8] += e[_j] * A[_i8][_j]; + } + ; + } + ; + for (var _j2 = k + 1; _j2 < this.n; _j2++) { + var _t = -e[_j2] / e[k + 1]; + for (var _i9 = k + 1; _i9 < this.m; _i9++) { + A[_i9][_j2] += _t * work[_i9]; + } + ; + } + ; + } + if (wantv) { + for (var _i10 = k + 1; _i10 < this.n; _i10++) { + this.V[_i10][k] = e[_i10]; + }; + } + } + }; + var p = Math.min(this.n, this.m + 1); + if (nct < this.n) { + this.s[nct] = A[nct][nct]; + } + if (this.m < p) { + this.s[p - 1] = 0.0; + } + if (nrt + 1 < p) { + e[nrt] = A[nrt][p - 1]; + } + e[p - 1] = 0.0; + if (wantu) { + for (var _j3 = nct; _j3 < nu; _j3++) { + for (var _i11 = 0; _i11 < this.m; _i11++) { + this.U[_i11][_j3] = 0.0; + } + ; + this.U[_j3][_j3] = 1.0; + }; + for (var _k = nct - 1; _k >= 0; _k--) { + if (this.s[_k] !== 0.0) { + for (var _j4 = _k + 1; _j4 < nu; _j4++) { + var _t2 = 0; + for (var _i12 = _k; _i12 < this.m; _i12++) { + _t2 += this.U[_i12][_k] * this.U[_i12][_j4]; + }; + _t2 = -_t2 / this.U[_k][_k]; + for (var _i13 = _k; _i13 < this.m; _i13++) { + this.U[_i13][_j4] += _t2 * this.U[_i13][_k]; + }; + }; + for (var _i14 = _k; _i14 < this.m; _i14++) { + this.U[_i14][_k] = -this.U[_i14][_k]; + }; + this.U[_k][_k] = 1.0 + this.U[_k][_k]; + for (var _i15 = 0; _i15 < _k - 1; _i15++) { + this.U[_i15][_k] = 0.0; + }; + } else { + for (var _i16 = 0; _i16 < this.m; _i16++) { + this.U[_i16][_k] = 0.0; + }; + this.U[_k][_k] = 1.0; + } + }; + } + if (wantv) { + for (var _k2 = this.n - 1; _k2 >= 0; _k2--) { + if (function (lhs, rhs) { + return lhs && rhs; + }(_k2 < nrt, e[_k2] !== 0.0)) { + for (var _j5 = _k2 + 1; _j5 < nu; _j5++) { + var _t3 = 0; + for (var _i17 = _k2 + 1; _i17 < this.n; _i17++) { + _t3 += this.V[_i17][_k2] * this.V[_i17][_j5]; + }; + _t3 = -_t3 / this.V[_k2 + 1][_k2]; + for (var _i18 = _k2 + 1; _i18 < this.n; _i18++) { + this.V[_i18][_j5] += _t3 * this.V[_i18][_k2]; + }; + }; + } + for (var _i19 = 0; _i19 < this.n; _i19++) { + this.V[_i19][_k2] = 0.0; + }; + this.V[_k2][_k2] = 1.0; + }; + } + var pp = p - 1; + var iter = 0; + var eps = Math.pow(2.0, -52.0); + var tiny = Math.pow(2.0, -966.0); + while (p > 0) { + var _k3 = void 0; + var kase = void 0; + for (_k3 = p - 2; _k3 >= -1; _k3--) { + if (_k3 === -1) { + break; + } + if (Math.abs(e[_k3]) <= tiny + eps * (Math.abs(this.s[_k3]) + Math.abs(this.s[_k3 + 1]))) { + e[_k3] = 0.0; + break; + } + }; + if (_k3 === p - 2) { + kase = 4; + } else { + var ks = void 0; + for (ks = p - 1; ks >= _k3; ks--) { + if (ks === _k3) { + break; + } + var _t4 = (ks !== p ? Math.abs(e[ks]) : 0.0) + (ks !== _k3 + 1 ? Math.abs(e[ks - 1]) : 0.0); + if (Math.abs(this.s[ks]) <= tiny + eps * _t4) { + this.s[ks] = 0.0; + break; + } + }; + if (ks === _k3) { + kase = 3; + } else if (ks === p - 1) { + kase = 1; + } else { + kase = 2; + _k3 = ks; + } + } + _k3++; + switch (kase) { + case 1: + { + var f = e[p - 2]; + e[p - 2] = 0.0; + for (var _j6 = p - 2; _j6 >= _k3; _j6--) { + var _t5 = SVD.hypot(this.s[_j6], f); + var cs = this.s[_j6] / _t5; + var sn = f / _t5; + this.s[_j6] = _t5; + if (_j6 !== _k3) { + f = -sn * e[_j6 - 1]; + e[_j6 - 1] = cs * e[_j6 - 1]; + } + if (wantv) { + for (var _i20 = 0; _i20 < this.n; _i20++) { + _t5 = cs * this.V[_i20][_j6] + sn * this.V[_i20][p - 1]; + this.V[_i20][p - 1] = -sn * this.V[_i20][_j6] + cs * this.V[_i20][p - 1]; + this.V[_i20][_j6] = _t5; + }; + } + }; + }; + break; + case 2: + { + var _f = e[_k3 - 1]; + e[_k3 - 1] = 0.0; + for (var _j7 = _k3; _j7 < p; _j7++) { + var _t6 = SVD.hypot(this.s[_j7], _f); + var _cs = this.s[_j7] / _t6; + var _sn = _f / _t6; + this.s[_j7] = _t6; + _f = -_sn * e[_j7]; + e[_j7] = _cs * e[_j7]; + if (wantu) { + for (var _i21 = 0; _i21 < this.m; _i21++) { + _t6 = _cs * this.U[_i21][_j7] + _sn * this.U[_i21][_k3 - 1]; + this.U[_i21][_k3 - 1] = -_sn * this.U[_i21][_j7] + _cs * this.U[_i21][_k3 - 1]; + this.U[_i21][_j7] = _t6; + }; + } + }; + }; + break; + case 3: + { + var scale = Math.max(Math.max(Math.max(Math.max(Math.abs(this.s[p - 1]), Math.abs(this.s[p - 2])), Math.abs(e[p - 2])), Math.abs(this.s[_k3])), Math.abs(e[_k3])); + var sp = this.s[p - 1] / scale; + var spm1 = this.s[p - 2] / scale; + var epm1 = e[p - 2] / scale; + var sk = this.s[_k3] / scale; + var ek = e[_k3] / scale; + var b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2.0; + var c = sp * epm1 * (sp * epm1); + var shift = 0.0; + if (function (lhs, rhs) { + return lhs || rhs; + }(b !== 0.0, c !== 0.0)) { + shift = Math.sqrt(b * b + c); + if (b < 0.0) { + shift = -shift; + } + shift = c / (b + shift); + } + var _f2 = (sk + sp) * (sk - sp) + shift; + var g = sk * ek; + for (var _j8 = _k3; _j8 < p - 1; _j8++) { + var _t7 = SVD.hypot(_f2, g); + var _cs2 = _f2 / _t7; + var _sn2 = g / _t7; + if (_j8 !== _k3) { + e[_j8 - 1] = _t7; + } + _f2 = _cs2 * this.s[_j8] + _sn2 * e[_j8]; + e[_j8] = _cs2 * e[_j8] - _sn2 * this.s[_j8]; + g = _sn2 * this.s[_j8 + 1]; + this.s[_j8 + 1] = _cs2 * this.s[_j8 + 1]; + if (wantv) { + for (var _i22 = 0; _i22 < this.n; _i22++) { + _t7 = _cs2 * this.V[_i22][_j8] + _sn2 * this.V[_i22][_j8 + 1]; + this.V[_i22][_j8 + 1] = -_sn2 * this.V[_i22][_j8] + _cs2 * this.V[_i22][_j8 + 1]; + this.V[_i22][_j8] = _t7; + }; + } + _t7 = SVD.hypot(_f2, g); + _cs2 = _f2 / _t7; + _sn2 = g / _t7; + this.s[_j8] = _t7; + _f2 = _cs2 * e[_j8] + _sn2 * this.s[_j8 + 1]; + this.s[_j8 + 1] = -_sn2 * e[_j8] + _cs2 * this.s[_j8 + 1]; + g = _sn2 * e[_j8 + 1]; + e[_j8 + 1] = _cs2 * e[_j8 + 1]; + if (wantu && _j8 < this.m - 1) { + for (var _i23 = 0; _i23 < this.m; _i23++) { + _t7 = _cs2 * this.U[_i23][_j8] + _sn2 * this.U[_i23][_j8 + 1]; + this.U[_i23][_j8 + 1] = -_sn2 * this.U[_i23][_j8] + _cs2 * this.U[_i23][_j8 + 1]; + this.U[_i23][_j8] = _t7; + }; + } + }; + e[p - 2] = _f2; + iter = iter + 1; + }; + break; + case 4: + { + if (this.s[_k3] <= 0.0) { + this.s[_k3] = this.s[_k3] < 0.0 ? -this.s[_k3] : 0.0; + if (wantv) { + for (var _i24 = 0; _i24 <= pp; _i24++) { + this.V[_i24][_k3] = -this.V[_i24][_k3]; + }; + } + } + while (_k3 < pp) { + if (this.s[_k3] >= this.s[_k3 + 1]) { + break; + } + var _t8 = this.s[_k3]; + this.s[_k3] = this.s[_k3 + 1]; + this.s[_k3 + 1] = _t8; + if (wantv && _k3 < this.n - 1) { + for (var _i25 = 0; _i25 < this.n; _i25++) { + _t8 = this.V[_i25][_k3 + 1]; + this.V[_i25][_k3 + 1] = this.V[_i25][_k3]; + this.V[_i25][_k3] = _t8; + }; + } + if (wantu && _k3 < this.m - 1) { + for (var _i26 = 0; _i26 < this.m; _i26++) { + _t8 = this.U[_i26][_k3 + 1]; + this.U[_i26][_k3 + 1] = this.U[_i26][_k3]; + this.U[_i26][_k3] = _t8; + }; + } + _k3++; + }; + iter = 0; + p--; + }; + break; + } + }; + var result = { U: this.U, V: this.V, S: this.s }; + return result; +}; + +// sqrt(a^2 + b^2) without under/overflow. +SVD.hypot = function (a, b) { + var r = void 0; + if (Math.abs(a) > Math.abs(b)) { + r = b / a; + r = Math.abs(a) * Math.sqrt(1 + r * r); + } else if (b != 0) { + r = a / b; + r = Math.abs(b) * Math.sqrt(1 + r * r); + } else { + r = 0.0; + } + return r; +}; + +module.exports = SVD; + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Needleman-Wunsch algorithm is an procedure to compute the optimal global alignment of two string + * sequences by S.B.Needleman and C.D.Wunsch (1970). + * + * Aside from the inputs, you can assign the scores for, + * - Match: The two characters at the current index are same. + * - Mismatch: The two characters at the current index are different. + * - Insertion/Deletion(gaps): The best alignment involves one letter aligning to a gap in the other string. + */ + +var NeedlemanWunsch = function () { + function NeedlemanWunsch(sequence1, sequence2) { + var match_score = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + var mismatch_penalty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1; + var gap_penalty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; + + _classCallCheck(this, NeedlemanWunsch); + + this.sequence1 = sequence1; + this.sequence2 = sequence2; + this.match_score = match_score; + this.mismatch_penalty = mismatch_penalty; + this.gap_penalty = gap_penalty; + + // Just the remove redundancy + this.iMax = sequence1.length + 1; + this.jMax = sequence2.length + 1; + + // Grid matrix of scores + this.grid = new Array(this.iMax); + for (var i = 0; i < this.iMax; i++) { + this.grid[i] = new Array(this.jMax); + + for (var j = 0; j < this.jMax; j++) { + this.grid[i][j] = 0; + } + } + + // Traceback matrix (2D array, each cell is an array of boolean values for [`Diag`, `Up`, `Left`] positions) + this.tracebackGrid = new Array(this.iMax); + for (var _i = 0; _i < this.iMax; _i++) { + this.tracebackGrid[_i] = new Array(this.jMax); + + for (var _j = 0; _j < this.jMax; _j++) { + this.tracebackGrid[_i][_j] = [null, null, null]; + } + } + + // The aligned sequences (return multiple possibilities) + this.alignments = []; + + // Final alignment score + this.score = -1; + + // Calculate scores and tracebacks + this.computeGrids(); + } + + _createClass(NeedlemanWunsch, [{ + key: "getScore", + value: function getScore() { + return this.score; + } + }, { + key: "getAlignments", + value: function getAlignments() { + return this.alignments; + } + + // Main dynamic programming procedure + + }, { + key: "computeGrids", + value: function computeGrids() { + // Fill in the first row + for (var j = 1; j < this.jMax; j++) { + this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty; + this.tracebackGrid[0][j] = [false, false, true]; + } + + // Fill in the first column + for (var i = 1; i < this.iMax; i++) { + this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty; + this.tracebackGrid[i][0] = [false, true, false]; + } + + // Fill the rest of the grid + for (var _i2 = 1; _i2 < this.iMax; _i2++) { + for (var _j2 = 1; _j2 < this.jMax; _j2++) { + // Find the max score(s) among [`Diag`, `Up`, `Left`] + var diag = void 0; + if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty; + + var up = this.grid[_i2 - 1][_j2] + this.gap_penalty; + var left = this.grid[_i2][_j2 - 1] + this.gap_penalty; + + // If there exists multiple max values, capture them for multiple paths + var maxOf = [diag, up, left]; + var indices = this.arrayAllMaxIndexes(maxOf); + + // Update Grids + this.grid[_i2][_j2] = maxOf[indices[0]]; + this.tracebackGrid[_i2][_j2] = [indices.includes(0), indices.includes(1), indices.includes(2)]; + } + } + + // Update alignment score + this.score = this.grid[this.iMax - 1][this.jMax - 1]; + } + + // Gets all possible valid sequence combinations + + }, { + key: "alignmentTraceback", + value: function alignmentTraceback() { + var inProcessAlignments = []; + + inProcessAlignments.push({ pos: [this.sequence1.length, this.sequence2.length], + seq1: "", + seq2: "" + }); + + while (inProcessAlignments[0]) { + var current = inProcessAlignments[0]; + var directions = this.tracebackGrid[current.pos[0]][current.pos[1]]; + + if (directions[0]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1] - 1], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + if (directions[1]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1]], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: '-' + current.seq2 + }); + } + if (directions[2]) { + inProcessAlignments.push({ pos: [current.pos[0], current.pos[1] - 1], + seq1: '-' + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + + if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({ sequence1: current.seq1, + sequence2: current.seq2 + }); + + inProcessAlignments.shift(); + } + + return this.alignments; + } + + // Helper Functions + + }, { + key: "getAllIndexes", + value: function getAllIndexes(arr, val) { + var indexes = [], + i = -1; + while ((i = arr.indexOf(val, i + 1)) !== -1) { + indexes.push(i); + } + return indexes; + } + }, { + key: "arrayAllMaxIndexes", + value: function arrayAllMaxIndexes(array) { + return this.getAllIndexes(array, Math.max.apply(null, array)); + } + }]); + + return NeedlemanWunsch; +}(); + +module.exports = NeedlemanWunsch; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var layoutBase = function layoutBase() { + return; +}; + +layoutBase.FDLayout = __webpack_require__(18); +layoutBase.FDLayoutConstants = __webpack_require__(4); +layoutBase.FDLayoutEdge = __webpack_require__(19); +layoutBase.FDLayoutNode = __webpack_require__(20); +layoutBase.DimensionD = __webpack_require__(21); +layoutBase.HashMap = __webpack_require__(22); +layoutBase.HashSet = __webpack_require__(23); +layoutBase.IGeometry = __webpack_require__(8); +layoutBase.IMath = __webpack_require__(9); +layoutBase.Integer = __webpack_require__(10); +layoutBase.Point = __webpack_require__(12); +layoutBase.PointD = __webpack_require__(5); +layoutBase.RandomSeed = __webpack_require__(16); +layoutBase.RectangleD = __webpack_require__(13); +layoutBase.Transform = __webpack_require__(17); +layoutBase.UniqueIDGeneretor = __webpack_require__(14); +layoutBase.Quicksort = __webpack_require__(25); +layoutBase.LinkedList = __webpack_require__(11); +layoutBase.LGraphObject = __webpack_require__(2); +layoutBase.LGraph = __webpack_require__(6); +layoutBase.LEdge = __webpack_require__(1); +layoutBase.LGraphManager = __webpack_require__(7); +layoutBase.LNode = __webpack_require__(3); +layoutBase.Layout = __webpack_require__(15); +layoutBase.LayoutConstants = __webpack_require__(0); +layoutBase.NeedlemanWunsch = __webpack_require__(27); +layoutBase.Matrix = __webpack_require__(24); +layoutBase.SVD = __webpack_require__(26); + +module.exports = layoutBase; + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function Emitter() { + this.listeners = []; +} + +var p = Emitter.prototype; + +p.addListener = function (event, callback) { + this.listeners.push({ + event: event, + callback: callback + }); +}; + +p.removeListener = function (event, callback) { + for (var i = this.listeners.length; i >= 0; i--) { + var l = this.listeners[i]; + + if (l.event === event && l.callback === callback) { + this.listeners.splice(i, 1); + } + } +}; + +p.emit = function (event, data) { + for (var i = 0; i < this.listeners.length; i++) { + var l = this.listeners[i]; + + if (event === l.event) { + l.callback(data); + } + } +}; + +module.exports = Emitter; + +/***/ }) +/******/ ]); +}); \ No newline at end of file diff --git a/static/js/vendor/cytoscape.min.js b/static/js/vendor/cytoscape.min.js new file mode 100644 index 0000000..ff0d7c1 --- /dev/null +++ b/static/js/vendor/cytoscape.min.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016-2024, The Cytoscape Consortium. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the “Software”), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).cytoscape=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){l=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw a}}}}var u="undefined"==typeof window?null:window,c=u?u.navigator:null;u&&u.document;var d=e(""),h=e({}),p=e((function(){})),f="undefined"==typeof HTMLElement?"undefined":e(HTMLElement),g=function(e){return e&&e.instanceString&&y(e.instanceString)?e.instanceString():null},v=function(t){return null!=t&&e(t)==d},y=function(t){return null!=t&&e(t)===p},m=function(e){return!E(e)&&(Array.isArray?Array.isArray(e):null!=e&&e instanceof Array)},b=function(t){return null!=t&&e(t)===h&&!m(t)&&t.constructor===Object},x=function(t){return null!=t&&e(t)===e(1)&&!isNaN(t)},w=function(e){return"undefined"===f?void 0:null!=e&&e instanceof HTMLElement},E=function(e){return k(e)||C(e)},k=function(e){return"collection"===g(e)&&e._private.single},C=function(e){return"collection"===g(e)&&!e._private.single},S=function(e){return"core"===g(e)},P=function(e){return"stylesheet"===g(e)},D=function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},T=function(t){return function(t){return null!=t&&e(t)===h}(t)&&y(t.then)},_=function(e,t){t||(t=function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;tt?1:0},L=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n255)return;t.push(Math.floor(a))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var l=n[4];if(void 0!==l){if((l=parseFloat(l))<0||l>1)return;t.push(l)}}return t}(e)||function(e){var t,n,r,i,a,o,s,l;function u(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var c=new RegExp("^hsl[a]?\\(((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?)))\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])(?:\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)$").exec(e);if(c){if((n=parseInt(c[1]))<0?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,(r=parseFloat(c[2]))<0||r>100)return;if(r/=100,(i=parseFloat(c[3]))<0||i>100)return;if(i/=100,void 0!==(a=c[4])&&((a=parseFloat(a))<0||a>1))return;if(0===r)o=s=l=Math.round(255*i);else{var d=i<.5?i*(1+r):i+r-i*r,h=2*i-d;o=Math.round(255*u(h,d,n+1/3)),s=Math.round(255*u(h,d,n)),l=Math.round(255*u(h,d,n-1/3))}t=[o,s,l,a]}return t}(e)},R={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},V=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i=t||n<0||d&&e-u>=a}function v(){var e=H();if(g(e))return y(e);s=setTimeout(v,function(e){var n=t-(e-l);return d?ge(n,a-(e-u)):n}(e))}function y(e){return s=void 0,h&&r?p(e):(r=i=void 0,o)}function m(){var e=H(),n=g(e);if(r=arguments,i=this,l=e,n){if(void 0===s)return f(l);if(d)return clearTimeout(s),s=setTimeout(v,t),p(l)}return void 0===s&&(s=setTimeout(v,t)),o}return t=pe(t)||0,j(n)&&(c=!!n.leading,a=(d="maxWait"in n)?fe(pe(n.maxWait)||0,t):a,h="trailing"in n?!!n.trailing:h),m.cancel=function(){void 0!==s&&clearTimeout(s),u=0,r=l=i=s=void 0},m.flush=function(){return void 0===s?o:y(H())},m},ye=u?u.performance:null,me=ye&&ye.now?function(){return ye.now()}:function(){return Date.now()},be=function(){if(u){if(u.requestAnimationFrame)return function(e){u.requestAnimationFrame(e)};if(u.mozRequestAnimationFrame)return function(e){u.mozRequestAnimationFrame(e)};if(u.webkitRequestAnimationFrame)return function(e){u.webkitRequestAnimationFrame(e)};if(u.msRequestAnimationFrame)return function(e){u.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout((function(){e(me())}),1e3/60)}}(),xe=function(e){return be(e)},we=me,Ee=65599,ke=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9261,r=n;!(t=e.next()).done;)r=r*Ee+t.value|0;return r},Ce=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9261;return t*Ee+e|0},Se=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381;return(t<<5)+t+e|0},Pe=function(e){return 2097152*e[0]+e[1]},De=function(e,t){return[Ce(e[0],t[0]),Se(e[1],t[1])]},Te=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return ke({next:function(){return r=0&&(e[r]!==t||(e.splice(r,1),!n));r--);},Ge=function(e){e.splice(0,e.length)},Ue=function(e,t,n){return n&&(t=N(n,t)),e[t]},Ze=function(e,t,n,r){n&&(t=N(n,t)),e[t]=r},$e="undefined"!=typeof Map?Map:function(){function e(){t(this,e),this._obj={}}return r(e,[{key:"set",value:function(e,t){return this._obj[e]=t,this}},{key:"delete",value:function(e){return this._obj[e]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(e){return void 0!==this._obj[e]}},{key:"get",value:function(e){return this._obj[e]}}]),e}(),Qe=function(){function e(n){if(t(this,e),this._obj=Object.create(null),this.size=0,null!=n){var r;r=null!=n.instanceString&&n.instanceString()===this.instanceString()?n.toArray():n;for(var i=0;i2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&S(e)){var r=t.group;if(null==r&&(r=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"===r||"edges"===r){this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:void 0===t.selectable||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:void 0===t.grabbable||!!t.grabbable,pannable:void 0===t.pannable?"edges"===r:!!t.pannable,active:!1,classes:new Je,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(null==i.position.x&&(i.position.x=0),null==i.position.y&&(i.position.y=0),t.renderedPosition){var a=t.renderedPosition,o=e.pan(),s=e.zoom();i.position={x:(a.x-o.x)/s,y:(a.y-o.y)/s}}var l=[];m(t.classes)?l=t.classes:v(t.classes)&&(l=t.classes.split(/\s+/));for(var u=0,c=l.length;ut?1:0},u=function(e,t,i,a,o){var s;if(null==i&&(i=0),null==o&&(o=n),i<0)throw new Error("lo must be non-negative");for(null==a&&(a=e.length);in;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse()).length;ag;0<=g?++h:--h)v.push(a(e,r));return v},f=function(e,t,r,i){var a,o,s;for(null==i&&(i=n),a=e[r];r>t&&i(a,o=e[s=r-1>>1])<0;)e[r]=o,r=s;return e[r]=a},g=function(e,t,r){var i,a,o,s,l;for(null==r&&(r=n),a=e.length,l=t,o=e[t],i=2*t+1;i0;){var k=m.pop(),C=g(k),S=k.id();if(d[S]=C,C!==1/0)for(var P=k.neighborhood().intersect(p),D=0;D0)for(n.unshift(t);c[i];){var a=c[i];n.unshift(a.edge),n.unshift(a.node),i=(r=a.node).id()}return o.spawn(n)}}}},ot={kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,i=n.length,a=new Array(i),o=n,s=function(e){for(var t=0;t0;){if(l=g.pop(),u=l.id(),v.delete(u),w++,u===d){for(var E=[],k=i,C=d,S=m[C];E.unshift(k),null!=S&&E.unshift(S),null!=(k=y[C]);)S=m[C=k.id()];return{found:!0,distance:h[u],path:this.spawn(E),steps:w}}f[u]=!0;for(var P=l._private.edges,D=0;DD&&(p[P]=D,m[P]=S,b[P]=w),!i){var T=S*u+C;!i&&p[T]>D&&(p[T]=D,m[T]=C,b[T]=w)}}}for(var _=0;_1&&void 0!==arguments[1]?arguments[1]:a,r=b(e),i=[],o=r;;){if(null==o)return t.spawn();var l=m(o),u=l.edge,c=l.pred;if(i.unshift(o[0]),o.same(n)&&i.length>0)break;null!=u&&i.unshift(u),o=c}return s.spawn(i)},hasNegativeWeightCycle:f,negativeWeightCycles:g}}},pt=Math.sqrt(2),ft=function(e,t,n){0===n.length&&Ve("Karger-Stein must be run on a connected (sub)graph");for(var r=n[e],i=r[1],a=r[2],o=t[i],s=t[a],l=n,u=l.length-1;u>=0;u--){var c=l[u],d=c[1],h=c[2];(t[d]===o&&t[h]===s||t[d]===s&&t[h]===o)&&l.splice(u,1)}for(var p=0;pr;){var i=Math.floor(Math.random()*t.length);t=ft(i,e,t),n--}return t},vt={kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,r=t.edges;r.unmergeBy((function(e){return e.isLoop()}));var i=n.length,a=r.length,o=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),s=Math.floor(i/pt);if(!(i<2)){for(var l=[],u=0;u0?1:e<0?-1:0},kt=function(e,t){return Math.sqrt(Ct(e,t))},Ct=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},St=function(e){for(var t=e.length,n=0,r=0;r=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(null!=e.w&&null!=e.h&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},Mt=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},Bt=function(e,t,n){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},Nt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},zt=function(e){var t,n,r,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===o.length)t=n=r=i=o[0];else if(2===o.length)t=r=o[0],i=n=o[1];else if(4===o.length){var s=a(o,4);t=s[0],n=s[1],r=s[2],i=s[3]}return e.x1-=i,e.x2+=n,e.y1-=t,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},It=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},At=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2t.y2)&&!(t.y1>e.y2)))))))},Lt=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},Ot=function(e,t){return Lt(e,t.x1,t.y1)&&Lt(e,t.x2,t.y2)},Rt=function(e,t,n,r,i,a,o){var s,l,u=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"auto",c="auto"===u?nn(i,a):u,d=i/2,h=a/2,p=(c=Math.min(c,d,h))!==d,f=c!==h;if(p){var g=n-d+c-o,v=r-h-o,y=n+d-c+o,m=v;if((s=Zt(e,t,n,r,g,v,y,m,!1)).length>0)return s}if(f){var b=n+d+o,x=r-h+c-o,w=b,E=r+h-c+o;if((s=Zt(e,t,n,r,b,x,w,E,!1)).length>0)return s}if(p){var k=n-d+c-o,C=r+h+o,S=n+d-c+o,P=C;if((s=Zt(e,t,n,r,k,C,S,P,!1)).length>0)return s}if(f){var D=n-d-o,T=r-h+c-o,_=D,M=r+h-c+o;if((s=Zt(e,t,n,r,D,T,_,M,!1)).length>0)return s}var B=n-d+c,N=r-h+c;if((l=Gt(e,t,n,r,B,N,c+o)).length>0&&l[0]<=B&&l[1]<=N)return[l[0],l[1]];var z=n+d-c,I=r-h+c;if((l=Gt(e,t,n,r,z,I,c+o)).length>0&&l[0]>=z&&l[1]<=I)return[l[0],l[1]];var A=n+d-c,L=r+h-c;if((l=Gt(e,t,n,r,A,L,c+o)).length>0&&l[0]>=A&&l[1]>=L)return[l[0],l[1]];var O=n-d+c,R=r+h-c;return(l=Gt(e,t,n,r,O,R,c+o)).length>0&&l[0]<=O&&l[1]>=R?[l[0],l[1]]:[]},Vt=function(e,t,n,r,i,a,o){var s=o,l=Math.min(n,i),u=Math.max(n,i),c=Math.min(r,a),d=Math.max(r,a);return l-s<=e&&e<=u+s&&c-s<=t&&t<=d+s},Ft=function(e,t,n,r,i,a,o,s,l){var u=Math.min(n,o,i)-l,c=Math.max(n,o,i)+l,d=Math.min(r,s,a)-l,h=Math.max(r,s,a)+l;return!(ec||th)},jt=function(e,t,n,r,i,a,o,s){var l=[];!function(e,t,n,r,i){var a,o,s,l,u,c,d,h;0===e&&(e=1e-5),s=-27*(r/=e)+(t/=e)*(9*(n/=e)-t*t*2),a=(o=(3*n-t*t)/9)*o*o+(s/=54)*s,i[1]=0,d=t/3,a>0?(u=(u=s+Math.sqrt(a))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),c=(c=s-Math.sqrt(a))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),i[0]=-d+u+c,d+=(u+c)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-c+u)/2,i[3]=d,i[5]=-d):(i[5]=i[3]=0,0===a?(h=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=2*h-d,i[4]=i[2]=-(h+d)):(l=(o=-o)*o*o,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(o),i[0]=-d+h*Math.cos(l/3),i[2]=-d+h*Math.cos((l+2*Math.PI)/3),i[4]=-d+h*Math.cos((l+4*Math.PI)/3)))}(1*n*n-4*n*i+2*n*o+4*i*i-4*i*o+o*o+r*r-4*r*a+2*r*s+4*a*a-4*a*s+s*s,9*n*i-3*n*n-3*n*o-6*i*i+3*i*o+9*r*a-3*r*r-3*r*s-6*a*a+3*a*s,3*n*n-6*n*i+n*o-n*e+2*i*i+2*i*e-o*e+3*r*r-6*r*a+r*s-r*t+2*a*a+2*a*t-s*t,1*n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,l);for(var u=[],c=0;c<6;c+=2)Math.abs(l[c+1])<1e-7&&l[c]>=0&&l[c]<=1&&u.push(l[c]);u.push(1),u.push(0);for(var d,h,p,f=-1,g=0;g=0?pl?(e-i)*(e-i)+(t-a)*(t-a):u-d},Yt=function(e,t,n){for(var r,i,a,o,s=0,l=0;l=e&&e>=a||r<=e&&e<=a))continue;(e-r)/(a-r)*(o-i)+i>t&&s++}return s%2!=0},Xt=function(e,t,n,r,i,a,o,s,l){var u,c=new Array(n.length);null!=s[0]?(u=Math.atan(s[1]/s[0]),s[0]<0?u+=Math.PI/2:u=-u-Math.PI/2):u=s;for(var d,h=Math.cos(-u),p=Math.sin(-u),f=0;f0){var g=Ht(c,-l);d=Wt(g)}else d=c;return Yt(e,t,d)},Wt=function(e){for(var t,n,r,i,a,o,s,l,u=new Array(e.length/2),c=0;c=0&&f<=1&&v.push(f),g>=0&&g<=1&&v.push(g),0===v.length)return[];var y=v[0]*s[0]+e,m=v[0]*s[1]+t;return v.length>1?v[0]==v[1]?[y,m]:[y,m,v[1]*s[0]+e,v[1]*s[1]+t]:[y,m]},Ut=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},Zt=function(e,t,n,r,i,a,o,s,l){var u=e-i,c=n-e,d=o-i,h=t-a,p=r-t,f=s-a,g=d*h-f*u,v=c*h-p*u,y=f*c-d*p;if(0!==y){var m=g/y,b=v/y;return-.001<=m&&m<=1.001&&-.001<=b&&b<=1.001||l?[e+m*c,t+m*p]:[]}return 0===g||0===v?Ut(e,n,o)===o?[o,s]:Ut(e,n,i)===i?[i,a]:Ut(i,o,n)===n?[n,r]:[]:[]},$t=function(e,t,n,r,i,a,o,s){var l,u,c,d,h,p,f=[],g=new Array(n.length),v=!0;if(null==a&&(v=!1),v){for(var y=0;y0){var m=Ht(g,-s);u=Wt(m)}else u=g}else u=n;for(var b=0;bu&&(u=t)},d=function(e){return l[e]},h=0;h0?b.edgesTo(m)[0]:m.edgesTo(b)[0];var w=r(x);m=m.id(),h[m]>h[v]+w&&(h[m]=h[v]+w,p.nodes.indexOf(m)<0?p.push(m):p.updateItem(m),u[m]=0,l[m]=[]),h[m]==h[v]+w&&(u[m]=u[m]+u[v],l[m].push(v))}else for(var E=0;E0;){for(var P=n.pop(),D=0;D0&&o.push(n[s]);0!==o.length&&i.push(r.collection(o))}return i}(c,l,t,r);return b=function(e){for(var t=0;t5&&void 0!==arguments[5]?arguments[5]:Cn,o=r,s=0;s=2?Mn(e,t,n,0,Dn,Tn):Mn(e,t,n,0,Pn)},squaredEuclidean:function(e,t,n){return Mn(e,t,n,0,Dn)},manhattan:function(e,t,n){return Mn(e,t,n,0,Pn)},max:function(e,t,n){return Mn(e,t,n,-1/0,_n)}};function Nn(e,t,n,r,i,a){var o;return o=y(e)?e:Bn[e]||Bn.euclidean,0===t&&y(e)?o(i,a):o(t,n,r,i,a)}Bn["squared-euclidean"]=Bn.squaredEuclidean,Bn.squaredeuclidean=Bn.squaredEuclidean;var zn=He({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),In=function(e){return zn(e)},An=function(e,t,n,r,i){var a="kMedoids"!==i?function(e){return n[e]}:function(e){return r[e](n)},o=n,s=t;return Nn(e,r.length,a,(function(e){return r[e](t)}),o,s)},Ln=function(e,t,n){for(var r=n.length,i=new Array(r),a=new Array(r),o=new Array(t),s=null,l=0;ln)return!1}return!0},jn=function(e,t,n){for(var r=0;ri&&(i=t[l][u],a=u);o[a].push(e[l])}for(var c=0;c=i.threshold||"dendrogram"===i.mode&&1===e.length)return!1;var p,f=t[o],g=t[r[o]];p="dendrogram"===i.mode?{left:f,right:g,key:f.key}:{value:f.value.concat(g.value),key:f.key},e[f.index]=p,e.splice(g.index,1),t[f.key]=p;for(var v=0;vn[g.key][y.key]&&(a=n[g.key][y.key])):"max"===i.linkage?(a=n[f.key][y.key],n[f.key][y.key]1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];r?e=e.slice(t,n):(n0&&e.splice(0,t));for(var o=0,s=e.length-1;s>=0;s--){var l=e[s];a?isFinite(l)||(e[s]=-1/0,o++):e.splice(s,1)}i&&e.sort((function(e,t){return e-t}));var u=e.length,c=Math.floor(u/2);return u%2!=0?e[c+1+o]:(e[c-1+o]+e[c+o])/2}(e):"mean"===t?function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,i=0,a=t;a1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=1/0,i=t;i1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=-1/0,i=t;io&&(a=l,o=t[i*e+l])}a>0&&r.push(a)}for(var u=0;u=D?(T=D,D=M,_=B):M>T&&(T=M);for(var N=0;N0?1:0;C[k%u.minIterations*t+R]=V,O+=V}if(O>0&&(k>=u.minIterations-1||k==u.maxIterations-1)){for(var F=0,j=0;j0&&r.push(i);return r}(t,a,o),X=function(e,t,n){for(var r=rr(e,t,n),i=0;il&&(s=u,l=c)}n[i]=a[s]}return r=rr(e,t,n)}(t,r,Y),W={},H=0;H1)}}));var l=Object.keys(t).filter((function(e){return t[e].cutVertex})).map((function(t){return e.getElementById(t)}));return{cut:e.spawn(l),components:i}},lr=function(){var e=this,t={},n=0,r=[],i=[],a=e.spawn(e);return e.forEach((function(o){if(o.isNode()){var s=o.id();s in t||function o(s){if(i.push(s),t[s]={index:n,low:n++,explored:!1},e.getElementById(s).connectedEdges().intersection(e).forEach((function(e){var n=e.target().id();n!==s&&(n in t||o(n),t[n].explored||(t[s].low=Math.min(t[s].low,t[n].low)))})),t[s].index===t[s].low){for(var l=e.spawn();;){var u=i.pop();if(l.merge(e.getElementById(u)),t[u].low=t[s].index,t[u].explored=!0,u===s)break}var c=l.edgesWith(l),d=l.merge(c);r.push(d),a=a.difference(d)}}(s)}})),{cut:a,components:r}},ur={};[nt,at,ot,lt,ct,ht,vt,sn,un,dn,pn,kn,Kn,Jn,ar,{hierholzer:function(e){if(!b(e)){var t=arguments;e={root:t[0],directed:t[1]}}var n,r,i,a=or(e),o=a.root,s=a.directed,l=this,u=!1;o&&(i=v(o)?this.filter(o)[0].id():o[0].id());var c={},d={};s?l.forEach((function(e){var t=e.id();if(e.isNode()){var i=e.indegree(!0),a=e.outdegree(!0),o=i-a,s=a-i;1==o?n?u=!0:n=t:1==s?r?u=!0:r=t:(s>1||o>1)&&(u=!0),c[t]=[],e.outgoers().forEach((function(e){e.isEdge()&&c[t].push(e.id())}))}else d[t]=[void 0,e.target().id()]})):l.forEach((function(e){var t=e.id();e.isNode()?(e.degree(!0)%2&&(n?r?u=!0:r=t:n=t),c[t]=[],e.connectedEdges().forEach((function(e){return c[t].push(e.id())}))):d[t]=[e.source().id(),e.target().id()]}));var h={found:!1,trail:void 0};if(u)return h;if(r&&n)if(s){if(i&&r!=i)return h;i=r}else{if(i&&r!=i&&n!=i)return h;i||(i=r)}else i||(i=l[0].id());var p=function(e){for(var t,n,r,i=e,a=[e];c[i].length;)t=c[i].shift(),n=d[t][0],i!=(r=d[t][1])?(c[r]=c[r].filter((function(e){return e!=t})),i=r):s||i==n||(c[n]=c[n].filter((function(e){return e!=t})),i=n),a.unshift(t),a.unshift(i);return a},f=[],g=[];for(g=p(i);1!=g.length;)0==c[g[0]].length?(f.unshift(l.getElementById(g.shift())),f.unshift(l.getElementById(g.shift()))):g=p(g.shift()).concat(g);for(var y in f.unshift(l.getElementById(g.shift())),c)if(c[y].length)return h;return h.found=!0,h.trail=this.spawn(f,!0),h}},{hopcroftTarjanBiconnected:sr,htbc:sr,htb:sr,hopcroftTarjanBiconnectedComponents:sr},{tarjanStronglyConnected:lr,tsc:lr,tscc:lr,tarjanStronglyConnectedComponents:lr}].forEach((function(e){L(ur,e)})); +/*! + Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable + Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) + Licensed under The MIT License (http://opensource.org/licenses/MIT) + */ +var cr=function e(t){if(!(this instanceof e))return new e(t);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof t&&t.call(this,this.fulfill.bind(this),this.reject.bind(this))};cr.prototype={fulfill:function(e){return dr(this,1,"fulfillValue",e)},reject:function(e){return dr(this,2,"rejectReason",e)},then:function(e,t){var n=new cr;return this.onFulfilled.push(fr(e,n,"fulfill")),this.onRejected.push(fr(t,n,"reject")),hr(this),n.proxy}};var dr=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,hr(e)),e},hr=function(e){1===e.state?pr(e,"onFulfilled",e.fulfillValue):2===e.state&&pr(e,"onRejected",e.rejectReason)},pr=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var i=function(){for(var e=0;e0:void 0}},clearQueue:function(){return function(){var e=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return this;for(var t=0;t-1};var ri=function(e,t){var n=this.__data__,r=Qr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function ii(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e0&&this.spawn(n).updateStyle().emit("class"),this},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){m(e)||(e=e.match(/\S+/g)||[]);for(var n=void 0===t,r=[],i=0,a=this.length;i0&&this.spawn(r).updateStyle().emit("class"),this},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(null==t)t=250;else if(0===t)return n;return n.addClass(e),setTimeout((function(){n.removeClass(e)}),t),n}};qi.className=qi.classNames=qi.classes;var Yi={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:I,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Yi.variable="(?:[\\w-.]|(?:\\\\"+Yi.metaChar+"))+",Yi.className="(?:[\\w-]|(?:\\\\"+Yi.metaChar+"))+",Yi.value=Yi.string+"|"+Yi.number,Yi.id=Yi.variable,function(){var e,t,n;for(e=Yi.comparatorOp.split("|"),n=0;n=0||"="!==t&&(Yi.comparatorOp+="|\\!"+t)}();var Xi=0,Wi=1,Hi=2,Ki=3,Gi=4,Ui=5,Zi=6,$i=7,Qi=8,Ji=9,ea=10,ta=11,na=12,ra=13,ia=14,aa=15,oa=16,sa=17,la=18,ua=19,ca=20,da=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort((function(e,t){return function(e,t){return-1*A(e,t)}(e.selector,t.selector)})),ha=function(){for(var e,t={},n=0;n0&&l.edgeCount>0)return je("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(l.edgeCount>1)return je("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===l.edgeCount&&je("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var e=function(e){return null==e?"":e},t=function(t){return v(t)?'"'+t+'"':e(t)},n=function(e){return" "+e+" "},r=function(r,a){var o=r.type,s=r.value;switch(o){case Xi:var l=e(s);return l.substring(0,l.length-1);case Ki:var u=r.field,c=r.operator;return"["+u+n(e(c))+t(s)+"]";case Ui:var d=r.operator,h=r.field;return"["+e(d)+h+"]";case Gi:return"["+r.field+"]";case Zi:var p=r.operator;return"[["+r.field+n(e(p))+t(s)+"]]";case $i:return s;case Qi:return"#"+s;case Ji:return"."+s;case sa:case aa:return i(r.parent,a)+n(">")+i(r.child,a);case la:case oa:return i(r.ancestor,a)+" "+i(r.descendant,a);case ua:var f=i(r.left,a),g=i(r.subject,a),v=i(r.right,a);return f+(f.length>0?" ":"")+g+v;case ca:return""}},i=function(e,t){return e.checks.reduce((function(n,i,a){return n+(t===e&&0===a?"$":"")+r(i,t)}),"")},a="",o=0;o1&&o=0&&(t=t.replace("!",""),c=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),u=!0),(o||l||u)&&(i=o||s?""+e:"",a=""+n),u&&(e=i=i.toLowerCase(),n=a=a.toLowerCase()),t){case"*=":r=i.indexOf(a)>=0;break;case"$=":r=i.indexOf(a,i.length-a.length)>=0;break;case"^=":r=0===i.indexOf(a);break;case"=":r=e===n;break;case">":d=!0,r=e>n;break;case">=":d=!0,r=e>=n;break;case"<":d=!0,r=e0;){var u=i.shift();t(u),a.add(u.id()),o&&r(i,a,u)}return e}function Ba(e,t,n){if(n.isParent())for(var r=n._private.children,i=0;i1&&void 0!==arguments[1])||arguments[1];return Ma(this,e,t,Ba)},_a.forEachUp=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Ma(this,e,t,Na)},_a.forEachUpAndDown=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Ma(this,e,t,za)},_a.ancestors=_a.parents,(Pa=Da={data:Fi.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:Fi.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Fi.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Fi.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Fi.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Fi.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=Pa.data,Pa.removeAttr=Pa.removeData;var Ia,Aa,La=Da,Oa={};function Ra(e){return function(t){if(void 0===t&&(t=!0),0!==this.length&&this.isNode()&&!this.removed()){for(var n=0,r=this[0],i=r._private.edges,a=0;at})),minIndegree:Va("indegree",(function(e,t){return et})),minOutdegree:Va("outdegree",(function(e,t){return et}))}),L(Oa,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r0,c=u;u&&(l=l[0]);var d=c?l.position():{x:0,y:0};return i={x:s.x-d.x,y:s.y-d.y},void 0===e?i:i[e]}for(var h=0;h0,y=g;g&&(f=f[0]);var m=y?f.position():{x:0,y:0};void 0!==t?p.position(e,t+m[e]):void 0!==i&&p.position({x:i.x+m.x,y:i.y+m.y})}}else if(!a)return;return this}}).modelPosition=Ia.point=Ia.position,Ia.modelPositions=Ia.points=Ia.positions,Ia.renderedPoint=Ia.renderedPosition,Ia.relativePoint=Ia.relativePosition;var qa,Ya,Xa=Aa;qa=Ya={},Ya.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),i=n.pan(),a=t.x1*r+i.x,o=t.x2*r+i.x,s=t.y1*r+i.y,l=t.y2*r+i.y;return{x1:a,x2:o,y1:s,y2:l,w:o-a,h:l-s}},Ya.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();return t.styleEnabled()&&t.hasCompoundNodes()?(this.forEachUp((function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,e||t.emitAndNotify("bounds")}})),this):this},Ya.updateCompoundBounds=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes())return this;if(!e&&t.batching())return this;function n(e){if(e.isParent()){var t=e._private,n=e.children(),r="include"===e.pstyle("compound-sizing-wrt-labels").value,i={width:{val:e.pstyle("min-width").pfValue,left:e.pstyle("min-width-bias-left"),right:e.pstyle("min-width-bias-right")},height:{val:e.pstyle("min-height").pfValue,top:e.pstyle("min-height-bias-top"),bottom:e.pstyle("min-height-bias-bottom")}},a=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),o=t.position;0!==a.w&&0!==a.h||((a={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=o.x-a.w/2,a.x2=o.x+a.w/2,a.y1=o.y-a.h/2,a.y2=o.y+a.h/2);var s=i.width.left.value;"px"===i.width.left.units&&i.width.val>0&&(s=100*s/i.width.val);var l=i.width.right.value;"px"===i.width.right.units&&i.width.val>0&&(l=100*l/i.width.val);var u=i.height.top.value;"px"===i.height.top.units&&i.height.val>0&&(u=100*u/i.height.val);var c=i.height.bottom.value;"px"===i.height.bottom.units&&i.height.val>0&&(c=100*c/i.height.val);var d=y(i.width.val-a.w,s,l),h=d.biasDiff,p=d.biasComplementDiff,f=y(i.height.val-a.h,u,c),g=f.biasDiff,v=f.biasComplementDiff;t.autoPadding=function(e,t,n,r){if("%"!==n.units)return"px"===n.units?n.pfValue:0;switch(r){case"width":return e>0?n.pfValue*e:0;case"height":return t>0?n.pfValue*t:0;case"average":return e>0&&t>0?n.pfValue*(e+t)/2:0;case"min":return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case"max":return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}}(a.w,a.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(a.w,i.width.val),o.x=(-h+a.x1+a.x2+p)/2,t.autoHeight=Math.max(a.h,i.height.val),o.y=(-g+a.y1+a.y2+v)/2}function y(e,t,n){var r=0,i=0,a=t+n;return e>0&&a>0&&(r=t/a*e,i=n/a*e),{biasDiff:r,biasComplementDiff:i}}}for(var r=0;re.x2?r:e.x2,e.y1=ne.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Ka=function(e,t){return null==t?e:Ha(e,t.x1,t.y1,t.x2,t.y2)},Ga=function(e,t,n){return Ue(e,t,n)},Ua=function(e,t,n){if(!t.cy().headless()){var r,i,a=t._private,o=a.rstyle,s=o.arrowWidth/2;if("none"!==t.pstyle(n+"-arrow-shape").value){"source"===n?(r=o.srcX,i=o.srcY):"target"===n?(r=o.tgtX,i=o.tgtY):(r=o.midX,i=o.midY);var l=a.arrowBounds=a.arrowBounds||{},u=l[n]=l[n]||{};u.x1=r-s,u.y1=i-s,u.x2=r+s,u.y2=i+s,u.w=u.x2-u.x1,u.h=u.y2-u.y1,Nt(u,1),Ha(e,u.x1,u.y1,u.x2,u.y2)}}},Za=function(e,t,n){if(!t.cy().headless()){var r;r=n?n+"-":"";var i=t._private,a=i.rstyle;if(t.pstyle(r+"label").strValue){var o,s,l,u,c=t.pstyle("text-halign"),d=t.pstyle("text-valign"),h=Ga(a,"labelWidth",n),p=Ga(a,"labelHeight",n),f=Ga(a,"labelX",n),g=Ga(a,"labelY",n),v=t.pstyle(r+"text-margin-x").pfValue,y=t.pstyle(r+"text-margin-y").pfValue,m=t.isEdge(),b=t.pstyle(r+"text-rotation"),x=t.pstyle("text-outline-width").pfValue,w=t.pstyle("text-border-width").pfValue/2,E=t.pstyle("text-background-padding").pfValue,k=p,C=h,S=C/2,P=k/2;if(m)o=f-S,s=f+S,l=g-P,u=g+P;else{switch(c.value){case"left":o=f-C,s=f;break;case"center":o=f-S,s=f+S;break;case"right":o=f,s=f+C}switch(d.value){case"top":l=g-k,u=g;break;case"center":l=g-P,u=g+P;break;case"bottom":l=g,u=g+k}}o+=v-Math.max(x,w)-E-2,s+=v+Math.max(x,w)+E+2,l+=y-Math.max(x,w)-E-2,u+=y+Math.max(x,w)+E+2;var D=n||"main",T=i.labelBounds,_=T[D]=T[D]||{};_.x1=o,_.y1=l,_.x2=s,_.y2=u,_.w=s-o,_.h=u-l;var M=m&&"autorotate"===b.strValue,B=null!=b.pfValue&&0!==b.pfValue;if(M||B){var N=M?Ga(i.rstyle,"labelAngle",n):b.pfValue,z=Math.cos(N),I=Math.sin(N),A=(o+s)/2,L=(l+u)/2;if(!m){switch(c.value){case"left":A=s;break;case"right":A=o}switch(d.value){case"top":L=u;break;case"bottom":L=l}}var O=function(e,t){return{x:(e-=A)*z-(t-=L)*I+A,y:e*I+t*z+L}},R=O(o,l),V=O(o,u),F=O(s,l),j=O(s,u);o=Math.min(R.x,V.x,F.x,j.x),s=Math.max(R.x,V.x,F.x,j.x),l=Math.min(R.y,V.y,F.y,j.y),u=Math.max(R.y,V.y,F.y,j.y)}var q=D+"Rot",Y=T[q]=T[q]||{};Y.x1=o,Y.y1=l,Y.x2=s,Y.y2=u,Y.w=s-o,Y.h=u-l,Ha(e,o,l,s,u),Ha(i.labelBounds.all,o,l,s,u)}return e}},$a=function(e,t){var n,r,i,a,o,s,l,u=e._private.cy,c=u.styleEnabled(),d=u.headless(),h=_t(),p=e._private,f=e.isNode(),g=e.isEdge(),v=p.rstyle,y=f&&c?e.pstyle("bounds-expansion").pfValue:[0],m=function(e){return"none"!==e.pstyle("display").value},b=!c||m(e)&&(!g||m(e.source())&&m(e.target()));if(b){var x=0;c&&t.includeOverlays&&0!==e.pstyle("overlay-opacity").value&&(x=e.pstyle("overlay-padding").value);var w=0;c&&t.includeUnderlays&&0!==e.pstyle("underlay-opacity").value&&(w=e.pstyle("underlay-padding").value);var E=Math.max(x,w),k=0;if(c&&(k=e.pstyle("width").pfValue/2),f&&t.includeNodes){var C=e.position();o=C.x,s=C.y;var S=e.outerWidth()/2,P=e.outerHeight()/2;Ha(h,n=o-S,i=s-P,r=o+S,a=s+P),c&&t.includeOutlines&&function(e,t){if(!t.cy().headless()){var n,r,i,a=t.pstyle("outline-opacity").value,o=t.pstyle("outline-width").value;if(a>0&&o>0){var s=t.pstyle("outline-offset").value,l=t.pstyle("shape").value,u=o+s,c=(e.w+2*u)/e.w,d=(e.h+2*u)/e.h,h=0;["diamond","pentagon","round-triangle"].includes(l)?(c=(e.w+2.4*u)/e.w,h=-u/3.6):["concave-hexagon","rhomboid","right-rhomboid"].includes(l)?c=(e.w+2.4*u)/e.w:"star"===l?(c=(e.w+2.8*u)/e.w,d=(e.h+2.6*u)/e.h,h=-u/3.8):"triangle"===l?(c=(e.w+2.8*u)/e.w,d=(e.h+2.4*u)/e.h,h=-u/1.4):"vee"===l&&(c=(e.w+4.4*u)/e.w,d=(e.h+3.8*u)/e.h,h=.5*-u);var p=e.h*d-e.h,f=e.w*c-e.w;if(zt(e,[Math.ceil(p/2),Math.ceil(f/2)]),0!==h){var g=(r=0,i=h,{x1:(n=e).x1+r,x2:n.x2+r,y1:n.y1+i,y2:n.y2+i,w:n.w,h:n.h});Mt(e,g)}}}}(h,e)}else if(g&&t.includeEdges)if(c&&!d){var D=e.pstyle("curve-style").strValue;if(n=Math.min(v.srcX,v.midX,v.tgtX),r=Math.max(v.srcX,v.midX,v.tgtX),i=Math.min(v.srcY,v.midY,v.tgtY),a=Math.max(v.srcY,v.midY,v.tgtY),Ha(h,n-=k,i-=k,r+=k,a+=k),"haystack"===D){var T=v.haystackPts;if(T&&2===T.length){if(n=T[0].x,i=T[0].y,n>(r=T[1].x)){var _=n;n=r,r=_}if(i>(a=T[1].y)){var M=i;i=a,a=M}Ha(h,n-k,i-k,r+k,a+k)}}else if("bezier"===D||"unbundled-bezier"===D||D.endsWith("segments")||D.endsWith("taxi")){var B;switch(D){case"bezier":case"unbundled-bezier":B=v.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":B=v.linePts}if(null!=B)for(var N=0;N(r=A.x)){var L=n;n=r,r=L}if((i=I.y)>(a=A.y)){var O=i;i=a,a=O}Ha(h,n-=k,i-=k,r+=k,a+=k)}if(c&&t.includeEdges&&g&&(Ua(h,e,"mid-source"),Ua(h,e,"mid-target"),Ua(h,e,"source"),Ua(h,e,"target")),c)if("yes"===e.pstyle("ghost").value){var R=e.pstyle("ghost-offset-x").pfValue,V=e.pstyle("ghost-offset-y").pfValue;Ha(h,h.x1+R,h.y1+V,h.x2+R,h.y2+V)}var F=p.bodyBounds=p.bodyBounds||{};It(F,h),zt(F,y),Nt(F,1),c&&(n=h.x1,r=h.x2,i=h.y1,a=h.y2,Ha(h,n-E,i-E,r+E,a+E));var j=p.overlayBounds=p.overlayBounds||{};It(j,h),zt(j,y),Nt(j,1);var q=p.labelBounds=p.labelBounds||{};null!=q.all?((l=q.all).x1=1/0,l.y1=1/0,l.x2=-1/0,l.y2=-1/0,l.w=0,l.h=0):q.all=_t(),c&&t.includeLabels&&(t.includeMainLabels&&Za(h,e,null),g&&(t.includeSourceLabels&&Za(h,e,"source"),t.includeTargetLabels&&Za(h,e,"target")))}return h.x1=Wa(h.x1),h.y1=Wa(h.y1),h.x2=Wa(h.x2),h.y2=Wa(h.y2),h.w=Wa(h.x2-h.x1),h.h=Wa(h.y2-h.y1),h.w>0&&h.h>0&&b&&(zt(h,y),Nt(h,1)),h},Qa=function(e){var t=0,n=function(e){return(e?1:0)<0&&void 0!==arguments[0]?arguments[0]:bo,t=arguments.length>1?arguments[1]:void 0,n=0;n=0;s--)o(s);return this},wo.removeAllListeners=function(){return this.removeListener("*")},wo.emit=wo.trigger=function(e,t,n){var r=this.listeners,i=r.length;return this.emitting++,m(t)||(t=[t]),Co(this,(function(e,a){null!=n&&(r=[{event:a.event,type:a.type,namespace:a.namespace,callback:n}],i=r.length);for(var o=function(n){var i=r[n];if(i.type===a.type&&(!i.namespace||i.namespace===a.namespace||".*"===i.namespace)&&e.eventMatches(e.context,i,a)){var o=[a];null!=t&&function(e,t){for(var n=0;n1&&!r){var i=this.length-1,a=this[i],o=a._private.data.id;this[i]=void 0,this[e]=a,n.set(o,{ele:a,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var i=r.index;return this.unmergeAt(i),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&v(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r=0;t--){e(this[t])&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],r=0;rr&&(r=o,n=a)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,i=0;i=0&&i1&&void 0!==arguments[1])||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n){this.cleanStyle();var i=n._private.style[e];return null!=i?i:t?r.style().getDefaultProperty(e):null}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return void 0!==n.pfValue?n.pfValue:n.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled())return t?t.pstyle(e).units:void 0},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];return n?t.style().getRenderedStyle(n,e):void 0},style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=n.style();if(b(e)){var i=e;r.applyBypass(this,i,!1),this.emitAndNotify("style")}else if(v(e)){if(void 0===t){var a=this[0];return a?r.getStylePropertyValue(a,e):void 0}r.applyBypass(this,e,t,!1),this.emitAndNotify("style")}else if(void 0===e){var o=this[0];return o?r.getRawStyle(o):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=t.style();if(void 0===e)for(var r=0;r0&&t.push(c[0]),t.push(s[0])}return this.spawn(t,!0).filter(e)}),"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),Go.neighbourhood=Go.neighborhood,Go.closedNeighbourhood=Go.closedNeighborhood,Go.openNeighbourhood=Go.openNeighborhood,L(Go,{source:Ta((function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t}),"source"),target:Ta((function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t}),"target"),sources:Qo({attr:"source"}),targets:Qo({attr:"target"})}),L(Go,{edgesWith:Ta(Jo(),"edgesWith"),edgesTo:Ta(Jo({thisIsSrc:!0}),"edgesTo")}),L(Go,{connectedEdges:Ta((function(e){for(var t=[],n=0;n0);return a},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),Go.componentsOf=Go.components;var ts=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(void 0!==e){var i=new $e,a=!1;if(t){if(t.length>0&&b(t[0])&&!k(t[0])){a=!0;for(var o=[],s=new Je,l=0,u=t.length;l0&&void 0!==arguments[0])||arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this,a=i.cy(),o=a._private,s=[],l=[],u=0,c=i.length;u0){for(var R=e.length===i.length?i:new ts(a,e),V=0;V0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this,r=[],i={},a=n._private.cy;function o(e){for(var t=e._private.edges,n=0;n0&&(e?D.emitAndNotify("remove"):t&&D.emit("remove"));for(var T=0;T1e-4&&Math.abs(s.v)>1e-4;);return a?function(e){return u[e*(u.length-1)|0]}:c}}(),as=function(e,t,n,r){var i=function(e,t,n,r){var i=4,a=.001,o=1e-7,s=10,l=11,u=1/(l-1),c="undefined"!=typeof Float32Array;if(4!==arguments.length)return!1;for(var d=0;d<4;++d)if("number"!=typeof arguments[d]||isNaN(arguments[d])||!isFinite(arguments[d]))return!1;e=Math.min(e,1),n=Math.min(n,1),e=Math.max(e,0),n=Math.max(n,0);var h=c?new Float32Array(l):new Array(l);function p(e,t){return 1-3*t+3*e}function f(e,t){return 3*t-6*e}function g(e){return 3*e}function v(e,t,n){return((p(t,n)*e+f(t,n))*e+g(t))*e}function y(e,t,n){return 3*p(t,n)*e*e+2*f(t,n)*e+g(t)}function m(t,r){for(var a=0;a0?i=l:r=l}while(Math.abs(a)>o&&++u=a?m(t,s):0===c?s:x(t,r,r+u)}var E=!1;function k(){E=!0,e===t&&n===r||b()}var C=function(i){return E||k(),e===t&&n===r?i:0===i?0:1===i?1:v(w(i),t,r)};C.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var S="generateBezier("+[e,t,n,r]+")";return C.toString=function(){return S},C}(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},os={linear:function(e,t,n){return e+(t-e)*n},ease:as(.25,.1,.25,1),"ease-in":as(.42,0,1,1),"ease-out":as(0,0,.58,1),"ease-in-out":as(.42,0,.58,1),"ease-in-sine":as(.47,0,.745,.715),"ease-out-sine":as(.39,.575,.565,1),"ease-in-out-sine":as(.445,.05,.55,.95),"ease-in-quad":as(.55,.085,.68,.53),"ease-out-quad":as(.25,.46,.45,.94),"ease-in-out-quad":as(.455,.03,.515,.955),"ease-in-cubic":as(.55,.055,.675,.19),"ease-out-cubic":as(.215,.61,.355,1),"ease-in-out-cubic":as(.645,.045,.355,1),"ease-in-quart":as(.895,.03,.685,.22),"ease-out-quart":as(.165,.84,.44,1),"ease-in-out-quart":as(.77,0,.175,1),"ease-in-quint":as(.755,.05,.855,.06),"ease-out-quint":as(.23,1,.32,1),"ease-in-out-quint":as(.86,0,.07,1),"ease-in-expo":as(.95,.05,.795,.035),"ease-out-expo":as(.19,1,.22,1),"ease-in-out-expo":as(1,0,0,1),"ease-in-circ":as(.6,.04,.98,.335),"ease-out-circ":as(.075,.82,.165,1),"ease-in-out-circ":as(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return os.linear;var r=is(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":as};function ss(e,t,n,r,i){if(1===r)return n;if(t===n)return n;var a=i(t,n,r);return null==e||((e.roundValue||e.color)&&(a=Math.round(a)),void 0!==e.min&&(a=Math.max(a,e.min)),void 0!==e.max&&(a=Math.min(a,e.max))),a}function ls(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function us(e,t,n,r,i){var a=null!=i?i.type:null;n<0?n=0:n>1&&(n=1);var o=ls(e,i),s=ls(t,i);if(x(o)&&x(s))return ss(a,o,s,n,r);if(m(o)&&m(s)){for(var l=[],u=0;u0?("spring"===d&&h.push(o.duration),o.easingImpl=os[d].apply(null,h)):o.easingImpl=os[d]}var p,f=o.easingImpl;if(p=0===o.duration?1:(n-l)/o.duration,o.applying&&(p=o.progress),p<0?p=0:p>1&&(p=1),null==o.delay){var g=o.startPosition,y=o.position;if(y&&i&&!e.locked()){var m={};ds(g.x,y.x)&&(m.x=us(g.x,y.x,p,f)),ds(g.y,y.y)&&(m.y=us(g.y,y.y,p,f)),e.position(m)}var b=o.startPan,x=o.pan,w=a.pan,E=null!=x&&r;E&&(ds(b.x,x.x)&&(w.x=us(b.x,x.x,p,f)),ds(b.y,x.y)&&(w.y=us(b.y,x.y,p,f)),e.emit("pan"));var k=o.startZoom,C=o.zoom,S=null!=C&&r;S&&(ds(k,C)&&(a.zoom=Tt(a.minZoom,us(k,C,p,f),a.maxZoom)),e.emit("zoom")),(E||S)&&e.emit("viewport");var P=o.style;if(P&&P.length>0&&i){for(var D=0;D=0;t--){(0,e[t])()}e.splice(0,e.length)},c=a.length-1;c>=0;c--){var d=a[c],h=d._private;h.stopped?(a.splice(c,1),h.hooked=!1,h.playing=!1,h.started=!1,u(h.frames)):(h.playing||h.applying)&&(h.playing&&h.applying&&(h.applying=!1),h.started||hs(0,d,e),cs(t,d,e,n),h.applying&&(h.applying=!1),u(h.frames),null!=h.step&&h.step(e),d.completed()&&(a.splice(c,1),h.hooked=!1,h.playing=!1,h.started=!1,u(h.completes)),s=!0)}return n||0!==a.length||0!==o.length||r.push(t),s}for(var a=!1,o=0;o0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var fs={animate:Fi.animate(),animation:Fi.animation(),animated:Fi.animated(),clearQueue:Fi.clearQueue(),delay:Fi.delay(),delayAnimation:Fi.delayAnimation(),stop:Fi.stop(),addToAnimationPool:function(e){this.styleEnabled()&&this._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,e.styleEnabled()){var t=e.renderer();t&&t.beforeRender?t.beforeRender((function(t,n){ps(n,e)}),t.beforeRenderPriorities.animations):function t(){e._private.animationsRunning&&xe((function(n){ps(n,e),t()}))}()}}},gs={qualifierCompare:function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return null==r||e!==n.target&&k(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e}},vs=function(e){return v(e)?new ka(e):e},ys={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new xo(gs,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,vs(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,vs(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,vs(t),n),this},once:function(e,t,n){return this.emitter().one(e,vs(t),n),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};Fi.eventAliasesOn(ys);var ms={png:function(e){return e=e||{},this._private.renderer.png(e)},jpg:function(e){var t=this._private.renderer;return(e=e||{}).bg=e.bg||"#fff",t.jpg(e)}};ms.jpeg=ms.jpg;var bs={layout:function(e){if(null!=e)if(null!=e.name){var t=e.name,n=this.extension("layout",t);if(null!=n){var r;r=v(e.eles)?this.$(e.eles):null!=e.eles?e.eles:this.$();var i=new n(L({},e,{cy:this,eles:r}));return i}Ve("No such layout `"+t+"` found. Did you forget to import it and `cytoscape.use()` it?")}else Ve("A `name` must be specified to make a layout");else Ve("Layout options must be specified to make a layout")}};bs.createLayout=bs.makeLayout=bs.layout;var xs={notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();null!=t&&r.merge(t)}else if(n.notificationsEnabled){var i=this.renderer();!this.destroyed()&&i&&i.notify(e,t)}},notifications:function(e){var t=this._private;return void 0===e?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return null==e.batchCount&&(e.batchCount=0),0===e.batchCount&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(0===e.batchCount)return this;if(e.batchCount--,0===e.batchCount){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach((function(n){var r=e.batchNotifications[n];r.empty()?t.notify(n):t.notify(n,r)}))}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch((function(){for(var n=Object.keys(e),r=0;r0;)e.removeChild(e.childNodes[0]);this._private.renderer=null,this.mutableElements().forEach((function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]}))},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};Es.invalidateDimensions=Es.resize;var ks={collection:function(e,t){return v(e)?this.$(e):E(e)?e.collection():m(e)?(t||(t={}),new ts(this,e,t.unique,t.removed)):new ts(this)},nodes:function(e){var t=this.$((function(e){return e.isNode()}));return e?t.filter(e):t},edges:function(e){var t=this.$((function(e){return e.isEdge()}));return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};ks.elements=ks.filter=ks.$;var Cs={};Cs.apply=function(e){for(var t=this._private.cy.collection(),n=0;n0;if(d||c&&h){var p=void 0;d&&h||d?p=l.properties:h&&(p=l.mappedProperties);for(var f=0;f1&&(g=1),s.color){var w=i.valueMin[0],E=i.valueMax[0],k=i.valueMin[1],C=i.valueMax[1],S=i.valueMin[2],P=i.valueMax[2],D=null==i.valueMin[3]?1:i.valueMin[3],T=null==i.valueMax[3]?1:i.valueMax[3],_=[Math.round(w+(E-w)*g),Math.round(k+(C-k)*g),Math.round(S+(P-S)*g),Math.round(D+(T-D)*g)];n={bypass:i.bypass,name:i.name,value:_,strValue:"rgb("+_[0]+", "+_[1]+", "+_[2]+")"}}else{if(!s.number)return!1;var M=i.valueMin+(i.valueMax-i.valueMin)*g;n=this.parse(i.name,M,i.bypass,"mapping")}if(!n)return f(),!1;n.mapping=i,i=n;break;case o.data:for(var B=i.field.split("."),N=d.data,z=0;z0&&a>0){for(var s={},l=!1,u=0;u0?e.delayAnimation(o).play().promise().then(t):t()})).then((function(){return e.animation({style:s,duration:a,easing:e.pstyle("transition-timing-function").value,queue:!1}).play().promise()})).then((function(){n.removeBypasses(e,i),e.emitAndNotify("style"),r.transitioning=!1}))}else r.transitioning&&(this.removeBypasses(e,i),e.emitAndNotify("style"),r.transitioning=!1)},Cs.checkTrigger=function(e,t,n,r,i,a){var o=this.properties[t],s=i(o);null!=s&&s(n,r)&&a(o)},Cs.checkZOrderTrigger=function(e,t,n,r){var i=this;this.checkTrigger(e,t,n,r,(function(e){return e.triggersZOrder}),(function(){i._private.cy.notify("zorder",e)}))},Cs.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBounds}),(function(i){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache(),!i.triggersBoundsOfParallelBeziers||"curve-style"!==t||"bezier"!==n&&"bezier"!==r||e.parallelEdges().forEach((function(e){e.isBundledBezier()&&e.dirtyBoundingBoxCache()})),!i.triggersBoundsOfConnectedEdges||"display"!==t||"none"!==n&&"none"!==r||e.connectedEdges().forEach((function(e){e.dirtyBoundingBoxCache()}))}))},Cs.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r)};var Ss={applyBypass:function(e,t,n,r){var i=[];if("*"===t||"**"===t){if(void 0!==n)for(var a=0;at.length?i.substr(t.length):""}function o(){n=n.length>r.length?n.substr(r.length):""}for(i=i.replace(/[/][*](\s|.)+?[*][/]/g,"");;){if(i.match(/^\s*$/))break;var s=i.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!s){je("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+i);break}t=s[0];var l=s[1];if("core"!==l)if(new ka(l).invalid){je("Skipping parsing of block: Invalid selector found in string stylesheet: "+l),a();continue}var u=s[2],c=!1;n=u;for(var d=[];;){if(n.match(/^\s*$/))break;var h=n.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!h){je("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+u),c=!0;break}r=h[0];var p=h[1],f=h[2];if(this.properties[p])this.parse(p,f)?(d.push({name:p,val:f}),o()):(je("Skipping property: Invalid property definition in: "+r),o());else je("Skipping property: Invalid property name in: "+r),o()}if(c){a();break}this.selector(l);for(var g=0;g=7&&"d"===t[0]&&(l=new RegExp(o.data.regex).exec(t))){if(n)return!1;var d=o.data;return{name:e,value:l,strValue:""+t,mapped:d,field:l[1],bypass:n}}if(t.length>=10&&"m"===t[0]&&(u=new RegExp(o.mapData.regex).exec(t))){if(n)return!1;if(c.multiple)return!1;var h=o.mapData;if(!c.color&&!c.number)return!1;var p=this.parse(e,u[4]);if(!p||p.mapped)return!1;var f=this.parse(e,u[5]);if(!f||f.mapped)return!1;if(p.pfValue===f.pfValue||p.strValue===f.strValue)return je("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+p.strValue+"`"),this.parse(e,p.strValue);if(c.color){var g=p.value,b=f.value;if(!(g[0]!==b[0]||g[1]!==b[1]||g[2]!==b[2]||g[3]!==b[3]&&(null!=g[3]&&1!==g[3]||null!=b[3]&&1!==b[3])))return!1}return{name:e,value:u,strValue:""+t,mapped:h,field:u[1],fieldMin:parseFloat(u[2]),fieldMax:parseFloat(u[3]),valueMin:p.value,valueMax:f.value,bypass:n}}}if(c.multiple&&"multiple"!==r){var w;if(w=s?t.split(/\s+/):m(t)?t:[t],c.evenMultiple&&w.length%2!=0)return null;for(var E=[],k=[],C=[],S="",P=!1,D=0;D0?" ":"")+T.strValue}return c.validate&&!c.validate(E,k)?null:c.singleEnum&&P?1===E.length&&v(E[0])?{name:e,value:E[0],strValue:E[0],bypass:n}:null:{name:e,value:E,pfValue:C,strValue:S,bypass:n,units:k}}var _,B,N=function(){for(var r=0;rc.max||c.strictMax&&t===c.max))return null;var V={name:e,value:t,strValue:""+t+(z||""),units:z,bypass:n};return c.unitless||"px"!==z&&"em"!==z?V.pfValue=t:V.pfValue="px"!==z&&z?this.getEmSizeInPixels()*t:t,"ms"!==z&&"s"!==z||(V.pfValue="ms"===z?t:1e3*t),"deg"!==z&&"rad"!==z||(V.pfValue="rad"===z?t:(_=t,Math.PI*_/180)),"%"===z&&(V.pfValue=t/100),V}if(c.propList){var F=[],j=""+t;if("none"===j);else{for(var q=j.split(/\s*,\s*|\s+/),Y=0;Y0&&l>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0)return{zoom:o=(o=(o=Math.min((s-2*t)/n.w,(l-2*t)/n.h))>this._private.maxZoom?this._private.maxZoom:o)=n.minZoom&&(n.maxZoom=t),this},minZoom:function(e){return void 0===e?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return void 0===e?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var t,n,r=this._private,i=r.pan,a=r.zoom,o=!1;if(r.zoomingEnabled||(o=!0),x(e)?n=e:b(e)&&(n=e.level,null!=e.position?t=yt(e.position,a,i):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)t.maxZoom||!t.zoomingEnabled?a=!0:(t.zoom=s,i.push("zoom"))}if(r&&(!a||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;x(l.x)&&(t.pan.x=l.x,o=!1),x(l.y)&&(t.pan.y=l.y,o=!1),o||i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(v(e)){var n=e;e=this.mutableElements().filter(n)}else E(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),i=this.width(),a=this.height();return{x:(i-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(a-t*(r.y1+r.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e,t,n=this._private,r=n.container,i=this;return n.sizeCache=n.sizeCache||(r?(e=i.window().getComputedStyle(r),t=function(t){return parseFloat(e.getPropertyValue(t))},{width:r.clientWidth-t("padding-left")-t("padding-right"),height:r.clientHeight-t("padding-top")-t("padding-bottom")}):{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,n=this.renderedExtent(),r={x1:(n.x1-e.x)/t,x2:(n.x2-e.x)/t,y1:(n.y1-e.y)/t,y2:(n.y2-e.y)/t};return r.w=r.x2-r.x1,r.h=r.y2-r.y1,r},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},multiClickDebounceTime:function(e){return e?(this._private.multiClickDebounceTime=e,this):this._private.multiClickDebounceTime}};As.centre=As.center,As.autolockNodes=As.autolock,As.autoungrabifyNodes=As.autoungrabify;var Ls={data:Fi.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Fi.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Fi.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Fi.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Ls.attr=Ls.data,Ls.removeAttr=Ls.removeData;var Os=function(e){var t=this,n=(e=L({},e)).container;n&&!w(n)&&w(n[0])&&(n=n[0]);var r=n?n._cyreg:null;(r=r||{})&&r.cy&&(r.cy.destroy(),r={});var i=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var a=void 0!==u&&void 0!==n&&!e.headless,o=e;o.layout=L({name:a?"grid":"null"},o.layout),o.renderer=L({name:a?"canvas":"null"},o.renderer);var s=function(e,t,n){return void 0!==t?t:void 0!==n?n:e},l=this._private={container:n,ready:!1,options:o,elements:new ts(this),listeners:[],aniEles:new ts(this),data:o.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:void 0===o.styleEnabled?a:o.styleEnabled,zoom:x(o.zoom)?o.zoom:1,pan:{x:b(o.pan)&&x(o.pan.x)?o.pan.x:0,y:b(o.pan)&&x(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:s(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});l.styleEnabled&&t.setStyle([]);var c=L({},o,o.renderer);t.initRenderer(c);!function(e,t){if(e.some(T))return vr.all(e).then(t);t(e)}([o.style,o.elements],(function(e){var n=e[0],a=e[1];l.styleEnabled&&t.style().append(n),function(e,n,r){t.notifications(!1);var i=t.mutableElements();i.length>0&&i.remove(),null!=e&&(b(e)||m(e))&&t.add(e),t.one("layoutready",(function(e){t.notifications(!0),t.emit(e),t.one("load",n),t.emitAndNotify("load")})).one("layoutstop",(function(){t.one("done",r),t.emit("done")}));var a=L({},t._private.options.layout);a.eles=t.elements(),t.layout(a).run()}(a,(function(){t.startAnimationLoop(),l.ready=!0,y(o.ready)&&t.on("ready",o.ready);for(var e=0;e0,u=_t(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(E(n.roots))e=n.roots;else if(m(n.roots)){for(var c=[],d=0;d0;){var N=_.shift(),z=T(N,M);if(z)N.outgoers().filter((function(e){return e.isNode()&&i.has(e)})).forEach(B);else if(null===z){je("Detected double maximal shift for node `"+N.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}D();var I=0;if(n.avoidOverlap)for(var L=0;L0&&b[0].length<=3?l/2:0),d=2*Math.PI/b[r].length*i;return 0===r&&1===b[0].length&&(c=1),{x:G+c*Math.cos(d),y:U+c*Math.sin(d)}}return{x:G+(i+1-(a+1)/2)*o,y:(r+1)*s}})),this};var Xs={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function Ws(e){this.options=L({},Xs,e)}Ws.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,a=r.nodes().not(":parent");t.sort&&(a=a.sort(t.sort));for(var o,s=_t(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),l=s.x1+s.w/2,u=s.y1+s.h/2,c=(void 0===t.sweep?2*Math.PI-2*Math.PI/a.length:t.sweep)/Math.max(1,a.length-1),d=0,h=0;h1&&t.avoidOverlap){d*=1.75;var v=Math.cos(c)-Math.cos(0),y=Math.sin(c)-Math.sin(0),m=Math.sqrt(d*d/(v*v+y*y));o=Math.max(m,o)}return r.nodes().layoutPositions(this,t,(function(e,n){var r=t.startAngle+n*c*(i?1:-1),a=o*Math.cos(r),s=o*Math.sin(r);return{x:l+a,y:u+s}})),this};var Hs,Ks={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function Gs(e){this.options=L({},Ks,e)}Gs.prototype.run=function(){for(var e=this.options,t=e,n=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,r=e.cy,i=t.eles,a=i.nodes().not(":parent"),o=_t(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s=o.x1+o.w/2,l=o.y1+o.h/2,u=[],c=0,d=0;d0)Math.abs(m[0].value-x.value)>=v&&(m=[],y.push(m));m.push(x)}var w=c+t.minNodeSpacing;if(!t.avoidOverlap){var E=y.length>0&&y[0].length>1,k=(Math.min(o.w,o.h)/2-w)/(y.length+E?1:0);w=Math.min(w,k)}for(var C=0,S=0;S1&&t.avoidOverlap){var _=Math.cos(T)-Math.cos(0),M=Math.sin(T)-Math.sin(0),B=Math.sqrt(w*w/(_*_+M*M));C=Math.max(B,C)}P.r=C,C+=w}if(t.equidistant){for(var N=0,z=0,I=0;I=e.numIter)&&(rl(r,e),r.temperature=r.temperature*e.coolingFactor,!(r.temperature=e.animationThreshold&&a(),xe(t)):(gl(r,e),s())}()}else{for(;u;)u=o(l),l++;gl(r,e),s()}return this},Zs.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},Zs.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var $s=function(e,t,n){for(var r=n.eles.edges(),i=n.eles.nodes(),a=_t(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:a.w,clientHeight:a.h,boundingBox:a},s=n.eles.components(),l={},u=0;u0){o.graphSet.push(E);for(u=0;ur.count?0:r.graph},Js=function e(t,n,r,i){var a=i.graphSet[r];if(-10)var s=(u=r.nodeOverlap*o)*i/(g=Math.sqrt(i*i+a*a)),l=u*a/g;else{var u,c=ll(e,i,a),d=ll(t,-1*i,-1*a),h=d.x-c.x,p=d.y-c.y,f=h*h+p*p,g=Math.sqrt(f);s=(u=(e.nodeRepulsion+t.nodeRepulsion)/f)*h/g,l=u*p/g}e.isLocked||(e.offsetX-=s,e.offsetY-=l),t.isLocked||(t.offsetX+=s,t.offsetY+=l)}},sl=function(e,t,n,r){if(n>0)var i=e.maxX-t.minX;else i=t.maxX-e.minX;if(r>0)var a=e.maxY-t.minY;else a=t.maxY-e.minY;return i>=0&&a>=0?Math.sqrt(i*i+a*a):0},ll=function(e,t,n){var r=e.positionX,i=e.positionY,a=e.height||1,o=e.width||1,s=n/t,l=a/o,u={};return 0===t&&0n?(u.x=r,u.y=i+a/2,u):0t&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=i-o*n/2/t,u):0=l)?(u.x=r+a*t/2/n,u.y=i+a/2,u):0>n&&(s<=-1*l||s>=l)?(u.x=r-a*t/2/n,u.y=i-a/2,u):u},ul=function(e,t){for(var n=0;n1){var f=t.gravity*d/p,g=t.gravity*h/p;c.offsetX+=f,c.offsetY+=g}}}}},dl=function(e,t){var n=[],r=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;r<=i;){var a=n[r++],o=e.idToIndex[a],s=e.layoutNodes[o],l=s.children;if(0n)var i={x:n*e/r,y:n*t/r};else i={x:e,y:t};return i},fl=function e(t,n){var r=t.parentId;if(null!=r){var i=n.layoutNodes[n.idToIndex[r]],a=!1;return(null==i.maxX||t.maxX+i.padRight>i.maxX)&&(i.maxX=t.maxX+i.padRight,a=!0),(null==i.minX||t.minX-i.padLefti.maxY)&&(i.maxY=t.maxY+i.padBottom,a=!0),(null==i.minY||t.minY-i.padTopf&&(d+=p+t.componentSpacing,c=0,h=0,p=0)}}},vl={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function yl(e){this.options=L({},vl,e)}yl.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=r.nodes().not(":parent");t.sort&&(i=i.sort(t.sort));var a=_t(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(0===a.h||0===a.w)r.nodes().layoutPositions(this,t,(function(e){return{x:a.x1,y:a.y1}}));else{var o=i.size(),s=Math.sqrt(o*a.h/a.w),l=Math.round(s),u=Math.round(a.w/a.h*s),c=function(e){if(null==e)return Math.min(l,u);Math.min(l,u)==l?l=e:u=e},d=function(e){if(null==e)return Math.max(l,u);Math.max(l,u)==l?l=e:u=e},h=t.rows,p=null!=t.cols?t.cols:t.columns;if(null!=h&&null!=p)l=h,u=p;else if(null!=h&&null==p)l=h,u=Math.ceil(o/l);else if(null==h&&null!=p)u=p,l=Math.ceil(o/u);else if(u*l>o){var f=c(),g=d();(f-1)*g>=o?c(f-1):(g-1)*f>=o&&d(g-1)}else for(;u*l=o?d(y+1):c(v+1)}var m=a.w/u,b=a.h/l;if(t.condense&&(m=0,b=0),t.avoidOverlap)for(var x=0;x=u&&(B=0,M++)},z={},I=0;I(r=qt(e,t,x[w],x[w+1],x[w+2],x[w+3])))return v(n,r),!0}else if("bezier"===a.edgeType||"multibezier"===a.edgeType||"self"===a.edgeType||"compound"===a.edgeType)for(x=a.allpts,w=0;w+5(r=jt(e,t,x[w],x[w+1],x[w+2],x[w+3],x[w+4],x[w+5])))return v(n,r),!0;m=m||i.source,b=b||i.target;var E=o.getArrowWidth(l,c),k=[{name:"source",x:a.arrowStartX,y:a.arrowStartY,angle:a.srcArrowAngle},{name:"target",x:a.arrowEndX,y:a.arrowEndY,angle:a.tgtArrowAngle},{name:"mid-source",x:a.midX,y:a.midY,angle:a.midsrcArrowAngle},{name:"mid-target",x:a.midX,y:a.midY,angle:a.midtgtArrowAngle}];for(w=0;w0&&(y(m),y(b))}function b(e,t,n){return Ue(e,t,n)}function x(n,r){var i,a=n._private,o=f;i=r?r+"-":"",n.boundingBox();var s=a.labelBounds[r||"main"],l=n.pstyle(i+"label").value;if("yes"===n.pstyle("text-events").strValue&&l){var u=b(a.rscratch,"labelX",r),c=b(a.rscratch,"labelY",r),d=b(a.rscratch,"labelAngle",r),h=n.pstyle(i+"text-margin-x").pfValue,p=n.pstyle(i+"text-margin-y").pfValue,g=s.x1-o-h,y=s.x2+o-h,m=s.y1-o-p,x=s.y2+o-p;if(d){var w=Math.cos(d),E=Math.sin(d),k=function(e,t){return{x:(e-=u)*w-(t-=c)*E+u,y:e*E+t*w+c}},C=k(g,m),S=k(g,x),P=k(y,m),D=k(y,x),T=[C.x+h,C.y+p,P.x+h,P.y+p,D.x+h,D.y+p,S.x+h,S.y+p];if(Yt(e,t,T))return v(n),!0}else if(Lt(s,e,t))return v(n),!0}}n&&(l=l.interactive);for(var w=l.length-1;w>=0;w--){var E=l[w];E.isNode()?y(E)||x(E):m(E)||x(E)||x(E,"source")||x(E,"target")}return u},getAllInBox:function(e,t,n,r){for(var i,a,o=this.getCachedZSortedEles().interactive,s=[],l=Math.min(e,n),u=Math.max(e,n),c=Math.min(t,r),d=Math.max(t,r),h=_t({x1:e=l,y1:t=c,x2:n=u,y2:r=d}),p=0;p0?-(Math.PI-a.ang):Math.PI+a.ang),Zl(t,n,Ul),zl=Gl.nx*Ul.ny-Gl.ny*Ul.nx,Il=Gl.nx*Ul.nx-Gl.ny*-Ul.ny,Ol=Math.asin(Math.max(-1,Math.min(1,zl))),Math.abs(Ol)<1e-6)return Bl=t.x,Nl=t.y,void(Vl=jl=0);Al=1,Ll=!1,Il<0?Ol<0?Ol=Math.PI+Ol:(Ol=Math.PI-Ol,Al=-1,Ll=!0):Ol>0&&(Al=-1,Ll=!0),jl=void 0!==t.radius?t.radius:r,Rl=Ol/2,ql=Math.min(Gl.len/2,Ul.len/2),i?(Fl=Math.abs(Math.cos(Rl)*jl/Math.sin(Rl)))>ql?(Fl=ql,Vl=Math.abs(Fl*Math.sin(Rl)/Math.cos(Rl))):Vl=jl:(Fl=Math.min(ql,jl),Vl=Math.abs(Fl*Math.sin(Rl)/Math.cos(Rl))),Wl=t.x+Ul.nx*Fl,Hl=t.y+Ul.ny*Fl,Bl=Wl-Ul.ny*Vl*Al,Nl=Hl+Ul.nx*Vl*Al,Yl=t.x+Gl.nx*Fl,Xl=t.y+Gl.ny*Fl,Kl=t};function Ql(e,t){0===t.radius?e.lineTo(t.cx,t.cy):e.arc(t.cx,t.cy,t.radius,t.startAngle,t.endAngle,t.counterClockwise)}function Jl(e,t,n,r){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return 0===r||0===t.radius?{cx:t.x,cy:t.y,radius:0,startX:t.x,startY:t.y,stopX:t.x,stopY:t.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:($l(e,t,n,r,i),{cx:Bl,cy:Nl,radius:Vl,startX:Yl,startY:Xl,stopX:Wl,stopY:Hl,startAngle:Gl.ang+Math.PI/2*Al,endAngle:Ul.ang-Math.PI/2*Al,counterClockwise:Ll})}var eu={};function tu(e){var t=[];if(null!=e){for(var n=0;n0?Math.max(e-t,0):Math.min(e+t,0)},w=x(m,v),E=x(b,y),k=!1;"auto"===c?u=Math.abs(w)>Math.abs(E)?"horizontal":"vertical":"upward"===c||"downward"===c?(u="vertical",k=!0):"leftward"!==c&&"rightward"!==c||(u="horizontal",k=!0);var C,S="vertical"===u,P=S?E:w,D=S?b:m,T=Et(D),_=!1;(k&&(h||f)||!("downward"===c&&D<0||"upward"===c&&D>0||"leftward"===c&&D>0||"rightward"===c&&D<0)||(P=(T*=-1)*Math.abs(P),_=!0),h)?C=(p<0?1+p:p)*P:C=(p<0?P:0)+p*T;var M=function(e){return Math.abs(e)=Math.abs(P)},B=M(C),N=M(Math.abs(P)-Math.abs(C));if((B||N)&&!_)if(S){var z=Math.abs(D)<=a/2,I=Math.abs(m)<=o/2;if(z){var A=(r.x1+r.x2)/2,L=r.y1,O=r.y2;n.segpts=[A,L,A,O]}else if(I){var R=(r.y1+r.y2)/2,V=r.x1,F=r.x2;n.segpts=[V,R,F,R]}else n.segpts=[r.x1,r.y2]}else{var j=Math.abs(D)<=i/2,q=Math.abs(b)<=s/2;if(j){var Y=(r.y1+r.y2)/2,X=r.x1,W=r.x2;n.segpts=[X,Y,W,Y]}else if(q){var H=(r.x1+r.x2)/2,K=r.y1,G=r.y2;n.segpts=[H,K,H,G]}else n.segpts=[r.x2,r.y1]}else if(S){var U=r.y1+C+(l?a/2*T:0),Z=r.x1,$=r.x2;n.segpts=[Z,U,$,U]}else{var Q=r.x1+C+(l?i/2*T:0),J=r.y1,ee=r.y2;n.segpts=[Q,J,Q,ee]}if(n.isRound){var te=e.pstyle("taxi-radius").value,ne="arc-radius"===e.pstyle("radius-type").value[0];n.radii=new Array(n.segpts.length/2).fill(te),n.isArcRadius=new Array(n.segpts.length/2).fill(ne)}},eu.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if("bezier"===n.edgeType){var r=t.srcPos,i=t.tgtPos,a=t.srcW,o=t.srcH,s=t.tgtW,l=t.tgtH,u=t.srcShape,c=t.tgtShape,d=t.srcCornerRadius,h=t.tgtCornerRadius,p=t.srcRs,f=t.tgtRs,g=!x(n.startX)||!x(n.startY),v=!x(n.arrowStartX)||!x(n.arrowStartY),y=!x(n.endX)||!x(n.endY),m=!x(n.arrowEndX)||!x(n.arrowEndY),b=3*(this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth),w=kt({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),E=wh.poolIndex()){var p=d;d=h,h=p}var f=s.srcPos=d.position(),g=s.tgtPos=h.position(),v=s.srcW=d.outerWidth(),y=s.srcH=d.outerHeight(),m=s.tgtW=h.outerWidth(),b=s.tgtH=h.outerHeight(),w=s.srcShape=n.nodeShapes[t.getNodeShape(d)],E=s.tgtShape=n.nodeShapes[t.getNodeShape(h)],k=s.srcCornerRadius="auto"===d.pstyle("corner-radius").value?"auto":d.pstyle("corner-radius").pfValue,C=s.tgtCornerRadius="auto"===h.pstyle("corner-radius").value?"auto":h.pstyle("corner-radius").pfValue,S=s.tgtRs=h._private.rscratch,P=s.srcRs=d._private.rscratch;s.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var D=0;D0){var H=u,K=Ct(H,bt(t)),G=Ct(H,bt(W)),U=K;if(G2)Ct(H,{x:W[2],y:W[3]})0){var le=c,ue=Ct(le,bt(t)),ce=Ct(le,bt(se)),de=ue;if(ce2)Ct(le,{x:se[2],y:se[3]})=c||b){d={cp:v,segment:m};break}}if(d)break}var x=d.cp,w=d.segment,E=(c-p)/w.length,k=w.t1-w.t0,C=u?w.t0+k*E:w.t1-k*E;C=Tt(0,C,1),t=Dt(x.p0,x.p1,x.p2,C),l=function(e,t,n,r){var i=Tt(0,r-.001,1),a=Tt(0,r+.001,1),o=Dt(e,t,n,i),s=Dt(e,t,n,a);return su(o,s)}(x.p0,x.p1,x.p2,C);break;case"straight":case"segments":case"haystack":for(var S,P,D,T,_=0,M=r.allpts.length,B=0;B+3=c));B+=2);var N=(c-P)/S;N=Tt(0,N,1),t=function(e,t,n,r){var i=t.x-e.x,a=t.y-e.y,o=kt(e,t),s=i/o,l=a/o;return n=null==n?0:n,r=null!=r?r:n*o,{x:e.x+s*r,y:e.y+l*r}}(D,T,N),l=su(D,T)}o("labelX",s,t.x),o("labelY",s,t.y),o("labelAutoAngle",s,l)}};l("source"),l("target"),this.applyLabelDimensions(e)}},au.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},au.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=this.calculateLabelDimensions(e,r),a=e.pstyle("line-height").pfValue,o=e.pstyle("text-wrap").strValue,s=Ue(n.rscratch,"labelWrapCachedLines",t)||[],l="wrap"!==o?1:Math.max(s.length,1),u=i.height/l,c=u*a,d=i.width,h=i.height+(l-1)*(a-1)*u;Ze(n.rstyle,"labelWidth",t,d),Ze(n.rscratch,"labelWidth",t,d),Ze(n.rstyle,"labelHeight",t,h),Ze(n.rscratch,"labelHeight",t,h),Ze(n.rscratch,"labelLineHeight",t,c)},au.getLabelText=function(e,t){var n=e._private,r=t?t+"-":"",i=e.pstyle(r+"label").strValue,a=e.pstyle("text-transform").value,o=function(e,r){return r?(Ze(n.rscratch,e,t,r),r):Ue(n.rscratch,e,t)};if(!i)return"";"none"==a||("uppercase"==a?i=i.toUpperCase():"lowercase"==a&&(i=i.toLowerCase()));var s=e.pstyle("text-wrap").value;if("wrap"===s){var u=o("labelKey");if(null!=u&&o("labelWrapKey")===u)return o("labelWrapCachedText");for(var c=i.split("\n"),d=e.pstyle("text-max-width").pfValue,h="anywhere"===e.pstyle("text-overflow-wrap").value,p=[],f=/[\s\u200b]+|$/g,g=0;gd){var b,x="",w=0,E=l(v.matchAll(f));try{for(E.s();!(b=E.n()).done;){var k=b.value,C=k[0],S=v.substring(w,k.index);w=k.index+C.length;var P=0===x.length?S:x+S+C;this.calculateLabelDimensions(e,P).width<=d?x+=S+C:(x&&p.push(x),x=S+C)}}catch(e){E.e(e)}finally{E.f()}x.match(/^[\s\u200b]+$/)||p.push(x)}else p.push(v)}o("labelWrapCachedLines",p),i=o("labelWrapCachedText",p.join("\n")),o("labelWrapKey",u)}else if("ellipsis"===s){var D=e.pstyle("text-max-width").pfValue,T="",_=!1;if(this.calculateLabelDimensions(e,i).widthD)break;T+=i[M],M===i.length-1&&(_=!0)}return _||(T+="…"),T}return i},au.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;if("auto"!==t)return t;if(!e.isNode())return"center";switch(n){case"left":return"right";case"right":return"left";default:return"center"}},au.calculateLabelDimensions=function(e,t){var n=this,r=n.cy.window().document,i=Te(t,e._private.labelDimsKey),a=n.labelDimCache||(n.labelDimCache=[]),o=a[i];if(null!=o)return o;var s=e.pstyle("font-style").strValue,l=e.pstyle("font-size").pfValue,u=e.pstyle("font-family").strValue,c=e.pstyle("font-weight").strValue,d=this.labelCalcCanvas,h=this.labelCalcCanvasContext;if(!d){d=this.labelCalcCanvas=r.createElement("canvas"),h=this.labelCalcCanvasContext=d.getContext("2d");var p=d.style;p.position="absolute",p.left="-9999px",p.top="-9999px",p.zIndex="-1",p.visibility="hidden",p.pointerEvents="none"}h.font="".concat(s," ").concat(c," ").concat(l,"px ").concat(u);for(var f=0,g=0,v=t.split("\n"),y=0;y1&&void 0!==arguments[1])||arguments[1];if(t.merge(e),n)for(var r=0;r=e.desktopTapThreshold2}var D=i(t);v&&(e.hoverData.tapholdCancelled=!0);n=!0,r(g,["mousemove","vmousemove","tapdrag"],t,{x:c[0],y:c[1]});var T=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||o.emit({originalEvent:t,type:"boxstart",position:{x:c[0],y:c[1]}}),f[4]=1,e.hoverData.selecting=!0,e.redrawHint("select",!0),e.redraw()};if(3===e.hoverData.which){if(v){var _={originalEvent:t,type:"cxtdrag",position:{x:c[0],y:c[1]}};m?m.emit(_):o.emit(_),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&g===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:c[0],y:c[1]}}),e.hoverData.cxtOver=g,g&&g.emit({originalEvent:t,type:"cxtdragover",position:{x:c[0],y:c[1]}}))}}else if(e.hoverData.dragging){if(n=!0,o.panningEnabled()&&o.userPanningEnabled()){var M;if(e.hoverData.justStartedPan){var B=e.hoverData.mdownPos;M={x:(c[0]-B[0])*s,y:(c[1]-B[1])*s},e.hoverData.justStartedPan=!1}else M={x:b[0]*s,y:b[1]*s};o.panBy(M),o.emit("dragpan"),e.hoverData.dragged=!0}c=e.projectIntoViewport(t.clientX,t.clientY)}else if(1!=f[4]||null!=m&&!m.pannable()){if(m&&m.pannable()&&m.active()&&m.unactivate(),m&&m.grabbed()||g==y||(y&&r(y,["mouseout","tapdragout"],t,{x:c[0],y:c[1]}),g&&r(g,["mouseover","tapdragover"],t,{x:c[0],y:c[1]}),e.hoverData.last=g),m)if(v){if(o.boxSelectionEnabled()&&D)m&&m.grabbed()&&(d(w),m.emit("freeon"),w.emit("free"),e.dragData.didDrag&&(m.emit("dragfreeon"),w.emit("dragfree"))),T();else if(m&&m.grabbed()&&e.nodeIsDraggable(m)){var N=!e.dragData.didDrag;N&&e.redrawHint("eles",!0),e.dragData.didDrag=!0,e.hoverData.draggingEles||u(w,{inDragLayer:!0});var z={x:0,y:0};if(x(b[0])&&x(b[1])&&(z.x+=b[0],z.y+=b[1],N)){var I=e.hoverData.dragDelta;I&&x(I[0])&&x(I[1])&&(z.x+=I[0],z.y+=I[1])}e.hoverData.draggingEles=!0,w.silentShift(z).emit("position drag"),e.redrawHint("drag",!0),e.redraw()}}else!function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];0===t.length?(t.push(b[0]),t.push(b[1])):(t[0]+=b[0],t[1]+=b[1])}();n=!0}else if(v){if(e.hoverData.dragging||!o.boxSelectionEnabled()||!D&&o.panningEnabled()&&o.userPanningEnabled()){if(!e.hoverData.selecting&&o.panningEnabled()&&o.userPanningEnabled()){a(m,e.hoverData.downs)&&(e.hoverData.dragging=!0,e.hoverData.justStartedPan=!0,f[4]=0,e.data.bgActivePosistion=bt(h),e.redrawHint("select",!0),e.redraw())}}else T();m&&m.pannable()&&m.active()&&m.unactivate()}return f[2]=c[0],f[3]=c[1],n?(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),!1):void 0}}),!1),e.registerBinding(t,"mouseup",(function(t){if((1!==e.hoverData.which||1===t.which||!e.hoverData.capture)&&e.hoverData.capture){e.hoverData.capture=!1;var a=e.cy,o=e.projectIntoViewport(t.clientX,t.clientY),s=e.selection,l=e.findNearestElement(o[0],o[1],!0,!1),u=e.dragData.possibleDragElements,c=e.hoverData.down,h=i(t);if(e.data.bgActivePosistion&&(e.redrawHint("select",!0),e.redraw()),e.hoverData.tapholdCancelled=!0,e.data.bgActivePosistion=void 0,c&&c.unactivate(),3===e.hoverData.which){var p={originalEvent:t,type:"cxttapend",position:{x:o[0],y:o[1]}};if(c?c.emit(p):a.emit(p),!e.hoverData.cxtDragged){var f={originalEvent:t,type:"cxttap",position:{x:o[0],y:o[1]}};c?c.emit(f):a.emit(f)}e.hoverData.cxtDragged=!1,e.hoverData.which=null}else if(1===e.hoverData.which){if(r(l,["mouseup","tapend","vmouseup"],t,{x:o[0],y:o[1]}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||e.hoverData.isOverThresholdDrag||(r(c,["click","tap","vclick"],t,{x:o[0],y:o[1]}),b=!1,t.timeStamp-w<=a.multiClickDebounceTime()?(m&&clearTimeout(m),b=!0,w=null,r(c,["dblclick","dbltap","vdblclick"],t,{x:o[0],y:o[1]})):(m=setTimeout((function(){b||r(c,["oneclick","onetap","voneclick"],t,{x:o[0],y:o[1]})}),a.multiClickDebounceTime()),w=t.timeStamp)),null!=c||e.dragData.didDrag||e.hoverData.selecting||e.hoverData.dragged||i(t)||(a.$(n).unselect(["tapunselect"]),u.length>0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=u=a.collection()),l!=c||e.dragData.didDrag||e.hoverData.selecting||null!=l&&l._private.selectable&&(e.hoverData.dragging||("additive"===a.selectionType()||h?l.selected()?l.unselect(["tapunselect"]):l.select(["tapselect"]):h||(a.$(n).unmerge(l).unselect(["tapunselect"]),l.select(["tapselect"]))),e.redrawHint("eles",!0)),e.hoverData.selecting){var g=a.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint("select",!0),g.length>0&&e.redrawHint("eles",!0),a.emit({type:"boxend",originalEvent:t,position:{x:o[0],y:o[1]}});var v=function(e){return e.selectable()&&!e.selected()};"additive"===a.selectionType()||h||a.$(n).unmerge(g).unselect(),g.emit("box").stdFilter(v).select().emit("boxselect"),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint("select",!0),e.redrawHint("eles",!0),e.redraw()),!s[4]){e.redrawHint("drag",!0),e.redrawHint("eles",!0);var y=c&&c.grabbed();d(u),y&&(c.emit("freeon"),u.emit("free"),e.dragData.didDrag&&(c.emit("dragfreeon"),u.emit("dragfree")))}}s[4]=0,e.hoverData.down=null,e.hoverData.cxtStarted=!1,e.hoverData.draggingEles=!1,e.hoverData.selecting=!1,e.hoverData.isOverThresholdDrag=!1,e.dragData.didDrag=!1,e.hoverData.dragged=!1,e.hoverData.dragDelta=[],e.hoverData.mdownPos=null,e.hoverData.mdownGPos=null,e.hoverData.which=null}}),!1);var k,C,S,P,D,T,_,M,B,N,z,I,A,L=function(t){if(!e.scrollingPage){var n=e.cy,r=n.zoom(),i=n.pan(),a=e.projectIntoViewport(t.clientX,t.clientY),o=[a[0]*r+i.x,a[1]*r+i.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||0!==e.selection[4])t.preventDefault();else if(n.panningEnabled()&&n.userPanningEnabled()&&n.zoomingEnabled()&&n.userZoomingEnabled()){var s;t.preventDefault(),e.data.wheelZooming=!0,clearTimeout(e.data.wheelTimeout),e.data.wheelTimeout=setTimeout((function(){e.data.wheelZooming=!1,e.redrawHint("eles",!0),e.redraw()}),150),s=null!=t.deltaY?t.deltaY/-250:null!=t.wheelDeltaY?t.wheelDeltaY/1e3:t.wheelDelta/1e3,s*=e.wheelSensitivity,1===t.deltaMode&&(s*=33);var l=n.zoom()*Math.pow(10,s);"gesturechange"===t.type&&(l=e.gestureStartZoom*t.scale),n.zoom({level:l,renderedPosition:{x:o[0],y:o[1]}}),n.emit("gesturechange"===t.type?"pinchzoom":"scrollzoom")}}};e.registerBinding(e.container,"wheel",L,!0),e.registerBinding(t,"scroll",(function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout((function(){e.scrollingPage=!1}),250)}),!0),e.registerBinding(e.container,"gesturestart",(function(t){e.gestureStartZoom=e.cy.zoom(),e.hasTouchStarted||t.preventDefault()}),!0),e.registerBinding(e.container,"gesturechange",(function(t){e.hasTouchStarted||L(t)}),!0),e.registerBinding(e.container,"mouseout",(function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseout",position:{x:n[0],y:n[1]}})}),!1),e.registerBinding(e.container,"mouseover",(function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseover",position:{x:n[0],y:n[1]}})}),!1);var O,R,V,F,j,q,Y,X=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},W=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(e.registerBinding(e.container,"touchstart",O=function(t){if(e.hasTouchStarted=!0,E(t)){p(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var n=e.cy,i=e.touchData.now,a=e.touchData.earlier;if(t.touches[0]){var o=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);i[0]=o[0],i[1]=o[1]}if(t.touches[1]){o=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);i[2]=o[0],i[3]=o[1]}if(t.touches[2]){o=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);i[4]=o[0],i[5]=o[1]}if(t.touches[1]){e.touchData.singleTouchMoved=!0,d(e.dragData.touchDragEles);var l=e.findContainerClientCoords();B=l[0],N=l[1],z=l[2],I=l[3],k=t.touches[0].clientX-B,C=t.touches[0].clientY-N,S=t.touches[1].clientX-B,P=t.touches[1].clientY-N,A=0<=k&&k<=z&&0<=S&&S<=z&&0<=C&&C<=I&&0<=P&&P<=I;var h=n.pan(),f=n.zoom();D=X(k,C,S,P),T=W(k,C,S,P),M=[((_=[(k+S)/2,(C+P)/2])[0]-h.x)/f,(_[1]-h.y)/f];if(T<4e4&&!t.touches[2]){var g=e.findNearestElement(i[0],i[1],!0,!0),v=e.findNearestElement(i[2],i[3],!0,!0);return g&&g.isNode()?(g.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start=g):v&&v.isNode()?(v.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start=v):n.emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!0,e.touchData.cxtDragged=!1,e.data.bgActivePosistion=void 0,void e.redraw()}}if(t.touches[2])n.boxSelectionEnabled()&&t.preventDefault();else if(t.touches[1]);else if(t.touches[0]){var y=e.findNearestElements(i[0],i[1],!0,!0),m=y[0];if(null!=m&&(m.activate(),e.touchData.start=m,e.touchData.starts=y,e.nodeIsGrabbable(m))){var b=e.dragData.touchDragEles=n.collection(),x=null;e.redrawHint("eles",!0),e.redrawHint("drag",!0),m.selected()?(x=n.$((function(t){return t.selected()&&e.nodeIsGrabbable(t)})),u(x,{addToList:b})):c(m,{addToList:b}),s(m);var w=function(e){return{originalEvent:t,type:e,position:{x:i[0],y:i[1]}}};m.emit(w("grabon")),x?x.forEach((function(e){e.emit(w("grab"))})):m.emit(w("grab"))}r(m,["touchstart","tapstart","vmousedown"],t,{x:i[0],y:i[1]}),null==m&&(e.data.bgActivePosistion={x:o[0],y:o[1]},e.redrawHint("select",!0),e.redraw()),e.touchData.singleTouchMoved=!1,e.touchData.singleTouchStartTime=+new Date,clearTimeout(e.touchData.tapholdTimeout),e.touchData.tapholdTimeout=setTimeout((function(){!1!==e.touchData.singleTouchMoved||e.pinching||e.touchData.selecting||r(e.touchData.start,["taphold"],t,{x:i[0],y:i[1]})}),e.tapholdDuration)}if(t.touches.length>=1){for(var L=e.touchData.startPosition=[null,null,null,null,null,null],O=0;O=e.touchTapThreshold2}if(n&&e.touchData.cxt){t.preventDefault();var w=t.touches[0].clientX-B,_=t.touches[0].clientY-N,z=t.touches[1].clientX-B,I=t.touches[1].clientY-N,L=W(w,_,z,I);if(L/T>=2.25||L>=22500){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var O={originalEvent:t,type:"cxttapend",position:{x:s[0],y:s[1]}};e.touchData.start?(e.touchData.start.unactivate().emit(O),e.touchData.start=null):o.emit(O)}}if(n&&e.touchData.cxt){O={originalEvent:t,type:"cxtdrag",position:{x:s[0],y:s[1]}};e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.touchData.start?e.touchData.start.emit(O):o.emit(O),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var R=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&R===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:s[0],y:s[1]}}),e.touchData.cxtOver=R,R&&R.emit({originalEvent:t,type:"cxtdragover",position:{x:s[0],y:s[1]}}))}else if(n&&t.touches[2]&&o.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||o.emit({originalEvent:t,type:"boxstart",position:{x:s[0],y:s[1]}}),e.touchData.selecting=!0,e.touchData.didSelect=!0,i[4]=1,i&&0!==i.length&&void 0!==i[0]?(i[2]=(s[0]+s[2]+s[4])/3,i[3]=(s[1]+s[3]+s[5])/3):(i[0]=(s[0]+s[2]+s[4])/3,i[1]=(s[1]+s[3]+s[5])/3,i[2]=(s[0]+s[2]+s[4])/3+1,i[3]=(s[1]+s[3]+s[5])/3+1),e.redrawHint("select",!0),e.redraw();else if(n&&t.touches[1]&&!e.touchData.didSelect&&o.zoomingEnabled()&&o.panningEnabled()&&o.userZoomingEnabled()&&o.userPanningEnabled()){if(t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),ee=e.dragData.touchDragEles){e.redrawHint("drag",!0);for(var V=0;V0&&!e.hoverData.draggingEles&&!e.swipePanning&&null!=e.data.bgActivePosistion&&(e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.redraw())}},!1),e.registerBinding(t,"touchcancel",V=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()}),e.registerBinding(t,"touchend",F=function(t){var i=e.touchData.start;if(e.touchData.capture){0===t.touches.length&&(e.touchData.capture=!1),t.preventDefault();var a=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var o,s=e.cy,l=s.zoom(),u=e.touchData.now,c=e.touchData.earlier;if(t.touches[0]){var h=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);u[0]=h[0],u[1]=h[1]}if(t.touches[1]){h=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);u[2]=h[0],u[3]=h[1]}if(t.touches[2]){h=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);u[4]=h[0],u[5]=h[1]}if(i&&i.unactivate(),e.touchData.cxt){if(o={originalEvent:t,type:"cxttapend",position:{x:u[0],y:u[1]}},i?i.emit(o):s.emit(o),!e.touchData.cxtDragged){var p={originalEvent:t,type:"cxttap",position:{x:u[0],y:u[1]}};i?i.emit(p):s.emit(p)}return e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!1,e.touchData.start=null,void e.redraw()}if(!t.touches[2]&&s.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var f=s.collection(e.getAllInBox(a[0],a[1],a[2],a[3]));a[0]=void 0,a[1]=void 0,a[2]=void 0,a[3]=void 0,a[4]=0,e.redrawHint("select",!0),s.emit({type:"boxend",originalEvent:t,position:{x:u[0],y:u[1]}});f.emit("box").stdFilter((function(e){return e.selectable()&&!e.selected()})).select().emit("boxselect"),f.nonempty()&&e.redrawHint("eles",!0),e.redraw()}if(null!=i&&i.unactivate(),t.touches[2])e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);else if(t.touches[1]);else if(t.touches[0]);else if(!t.touches[0]){e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var g=e.dragData.touchDragEles;if(null!=i){var v=i._private.grabbed;d(g),e.redrawHint("drag",!0),e.redrawHint("eles",!0),v&&(i.emit("freeon"),g.emit("free"),e.dragData.didDrag&&(i.emit("dragfreeon"),g.emit("dragfree"))),r(i,["touchend","tapend","vmouseup","tapdragout"],t,{x:u[0],y:u[1]}),i.unactivate(),e.touchData.start=null}else{var y=e.findNearestElement(u[0],u[1],!0,!0);r(y,["touchend","tapend","vmouseup","tapdragout"],t,{x:u[0],y:u[1]})}var m=e.touchData.startPosition[0]-u[0],b=m*m,x=e.touchData.startPosition[1]-u[1],w=(b+x*x)*l*l;e.touchData.singleTouchMoved||(i||s.$(":selected").unselect(["tapunselect"]),r(i,["tap","vclick"],t,{x:u[0],y:u[1]}),j=!1,t.timeStamp-Y<=s.multiClickDebounceTime()?(q&&clearTimeout(q),j=!0,Y=null,r(i,["dbltap","vdblclick"],t,{x:u[0],y:u[1]})):(q=setTimeout((function(){j||r(i,["onetap","voneclick"],t,{x:u[0],y:u[1]})}),s.multiClickDebounceTime()),Y=t.timeStamp)),null!=i&&!e.dragData.didDrag&&i._private.selectable&&w2){for(var p=[c[0],c[1]],f=Math.pow(p[0]-e,2)+Math.pow(p[1]-t,2),g=1;g0)return g[0]}return null},p=Object.keys(d),f=0;f0?u:Rt(i,a,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,i,a,o,s){var l=2*(s="auto"===s?nn(r,i):s);if(Xt(e,t,this.points,a,o,r,i-l,[0,-1],n))return!0;if(Xt(e,t,this.points,a,o,r-l,i,[0,-1],n))return!0;var u=r/2+2*n,c=i/2+2*n;return!!Yt(e,t,[a-u,o-c,a-u,o,a+u,o,a+u,o-c])||(!!Kt(e,t,l,l,a+r/2-s,o+i/2-s,n)||!!Kt(e,t,l,l,a-r/2+s,o+i/2-s,n))}}},gu.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",Jt(3,0)),this.generateRoundPolygon("round-triangle",Jt(3,0)),this.generatePolygon("rectangle",Jt(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var n=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",n),this.generateRoundPolygon("round-diamond",n),this.generatePolygon("pentagon",Jt(5,0)),this.generateRoundPolygon("round-pentagon",Jt(5,0)),this.generatePolygon("hexagon",Jt(6,0)),this.generateRoundPolygon("round-hexagon",Jt(6,0)),this.generatePolygon("heptagon",Jt(7,0)),this.generateRoundPolygon("round-heptagon",Jt(7,0)),this.generatePolygon("octagon",Jt(8,0)),this.generateRoundPolygon("round-octagon",Jt(8,0));var r=new Array(20),i=tn(5,0),a=tn(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=e.deqFastCost*g)break}else if(i){if(p>=e.deqCost*l||p>=e.deqAvgCost*s)break}else if(f>=e.deqNoDrawCost*(1e3/60))break;var v=e.deq(t,d,c);if(!(v.length>0))break;for(var y=0;y0&&(e.onDeqd(t,u),!i&&e.shouldRedraw(t,u,d,c)&&r())}),i(t))}}},wu=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Le;t(this,e),this.idsByKey=new $e,this.keyForId=new $e,this.cachesByLvl=new $e,this.lvls=[],this.getKey=n,this.doesEleInvalidateKey=r}return r(e,[{key:"getIdsFor",value:function(e){null==e&&Ve("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new Je,t.set(e,n)),n}},{key:"addIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).add(t)}},{key:"deleteIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).delete(t)}},{key:"getNumberOfIdsForKey",value:function(e){return null==e?0:this.getIdsFor(e).size}},{key:"updateKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)}},{key:"deleteKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)}},{key:"keyHasChangedFor",value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:"isInvalid",value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:"getCachesAt",value:function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new $e,t.set(e,r),n.push(e)),r}},{key:"getCache",value:function(e,t){return this.getCachesAt(t).get(e)}},{key:"get",value:function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return null!=r&&this.updateKeyMappingFor(e),r}},{key:"getForCachedKey",value:function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)}},{key:"hasCache",value:function(e,t){return this.getCachesAt(t).has(e)}},{key:"has",value:function(e,t){var n=this.getKey(e);return this.hasCache(n,t)}},{key:"setCache",value:function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)}},{key:"set",value:function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)}},{key:"deleteCache",value:function(e,t){this.getCachesAt(t).delete(e)}},{key:"delete",value:function(e,t){var n=this.getKey(e);this.deleteCache(n,t)}},{key:"invalidateKey",value:function(e){var t=this;this.lvls.forEach((function(n){return t.deleteCache(e,n)}))}},{key:"invalidate",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteKeyMappingFor(e);var r=this.doesEleInvalidateKey(e);return r&&this.invalidateKey(n),r||0===this.getNumberOfIdsForKey(n)}}]),e}(),Eu={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},ku=He({getKey:null,doesEleInvalidateKey:Le,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Ae,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Cu=function(e,t){this.renderer=e,this.onDequeues=[];var n=ku(t);L(this,n),this.lookup=new wu(n.getKey,n.doesEleInvalidateKey),this.setupDequeueing()},Su=Cu.prototype;Su.reasons=Eu,Su.getTextureQueue=function(e){return this.eleImgCaches=this.eleImgCaches||{},this.eleImgCaches[e]=this.eleImgCaches[e]||[]},Su.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},Su.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new rt((function(e,t){return t.reqs-e.reqs}))},Su.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},Su.getElement=function(e,t,n,r,i){var a=this,o=this.renderer,s=o.cy.zoom(),l=this.lookup;if(!t||0===t.w||0===t.h||isNaN(t.w)||isNaN(t.h)||!e.visible()||e.removed())return null;if(!a.allowEdgeTxrCaching&&e.isEdge()||!a.allowParentTxrCaching&&e.isParent())return null;if(null==r&&(r=Math.ceil(wt(s*n))),r<-4)r=-4;else if(s>=7.99||r>3)return null;var u=Math.pow(2,r),c=t.h*u,d=t.w*u,h=o.eleTextBiggerThanMin(e,u);if(!this.isVisible(e,h))return null;var p,f=l.get(e,r);if(f&&f.invalidated&&(f.invalidated=!1,f.texture.invalidatedWidth-=f.width),f)return f;if(p=c<=25?25:c<=50?50:50*Math.ceil(c/50),c>1024||d>1024)return null;var g=a.getTextureQueue(p),v=g[g.length-2],y=function(){return a.recycleTexture(p,d)||a.addTexture(p,d)};v||(v=g[g.length-1]),v||(v=y()),v.width-v.usedWidthr;D--)S=a.getElement(e,t,n,D,Eu.downscale);P()}else{var T;if(!x&&!w&&!E)for(var _=r-1;_>=-4;_--){var M=l.get(e,_);if(M){T=M;break}}if(b(T))return a.queueElement(e,r),T;v.context.translate(v.usedWidth,0),v.context.scale(u,u),this.drawElement(v.context,e,t,h,!1),v.context.scale(1/u,1/u),v.context.translate(-v.usedWidth,0)}return f={x:v.usedWidth,texture:v,level:r,scale:u,width:d,height:c,scaledLabelShown:h},v.usedWidth+=Math.ceil(d+8),v.eleCaches.push(f),l.set(e,r,f),a.checkTextureFullness(v),f},Su.invalidateElements=function(e){for(var t=0;t=.2*e.width&&this.retireTexture(e)},Su.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?Ke(t,e):e.fullnessChecks++},Su.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;Ke(n,e),e.retired=!0;for(var i=e.eleCaches,a=0;a=t)return a.retired=!1,a.usedWidth=0,a.invalidatedWidth=0,a.fullnessChecks=0,Ge(a.eleCaches),a.context.setTransform(1,0,0,1,0,0),a.context.clearRect(0,0,a.width,a.height),Ke(r,a),n.push(a),a}},Su.queueElement=function(e,t){var n=this.getElementQueue(),r=this.getElementKeyToQueue(),i=this.getKey(e),a=r[i];if(a)a.level=Math.max(a.level,t),a.eles.merge(e),a.reqs++,n.updateItem(a);else{var o={eles:e.spawn().merge(e),level:t,reqs:1,key:i};n.push(o),r[i]=o}},Su.dequeue=function(e){for(var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=[],i=this.lookup,a=0;a<1&&t.size()>0;a++){var o=t.pop(),s=o.key,l=o.eles[0],u=i.hasCache(l,o.level);if(n[s]=null,!u){r.push(o);var c=this.getBoundingBox(l);this.getElement(l,c,e,o.level,Eu.dequeue)}}return r},Su.removeFromQueue=function(e){var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=this.getKey(e),i=n[r];null!=i&&(1===i.eles.length?(i.reqs=Ie,t.updateItem(i),t.pop(),n[r]=null):i.eles.unmerge(e))},Su.onDequeue=function(e){this.onDequeues.push(e)},Su.offDequeue=function(e){Ke(this.onDequeues,e)},Su.setupDequeueing=xu({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n=3.99||n>2)return null;r.validateLayersElesOrdering(n,e);var o,s,l=r.layersByLevel,u=Math.pow(2,n),c=l[n]=l[n]||[];if(r.levelIsComplete(n,e))return c;!function(){var t=function(t){if(r.validateLayersElesOrdering(t,e),r.levelIsComplete(t,e))return s=l[t],!0},i=function(e){if(!s)for(var r=n+e;-4<=r&&r<=2&&!t(r);r+=e);};i(1),i(-1);for(var a=c.length-1;a>=0;a--){var o=c[a];o.invalid&&Ke(c,o)}}();var d=function(t){var i=(t=t||{}).after;if(function(){if(!o){o=_t();for(var t=0;t16e6)return null;var a=r.makeLayer(o,n);if(null!=i){var s=c.indexOf(i)+1;c.splice(s,0,a)}else(void 0===t.insert||t.insert)&&c.unshift(a);return a};if(r.skipping&&!a)return null;for(var h=null,p=e.length/1,f=!a,g=0;g=p||!Ot(h.bb,v.boundingBox()))&&!(h=d({insert:!0,after:h})))return null;s||f?r.queueLayer(h,v):r.drawEleInLayer(h,v,n,t),h.eles.push(v),m[n]=h}}return s||(f?null:c)},Du.getEleLevelForLayerLevel=function(e,t){return e},Du.drawEleInLayer=function(e,t,n,r){var i=this.renderer,a=e.context,o=t.boundingBox();0!==o.w&&0!==o.h&&t.visible()&&(n=this.getEleLevelForLayerLevel(n,r),i.setImgSmoothing(a,!1),i.drawCachedElement(a,t,null,null,n,!0),i.setImgSmoothing(a,!0))},Du.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,i=0;i0)return!1;if(a.invalid)return!1;r+=a.eles.length}return r===t.length},Du.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r0){e=!0;break}}return e},Du.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=we(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,(function(e,n,r){t.invalidateLayer(e)})))},Du.invalidateLayer=function(e){if(this.lastInvalidationTime=we(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];Ke(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var i=0;i3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],o=this,s=t._private.rscratch;if((!a||t.visible())&&!s.badLine&&null!=s.allpts&&!isNaN(s.allpts[0])){var l;n&&(l=n,e.translate(-l.x1,-l.y1));var u=a?t.pstyle("opacity").value:1,c=a?t.pstyle("line-opacity").value:1,d=t.pstyle("curve-style").value,h=t.pstyle("line-style").value,p=t.pstyle("width").pfValue,f=t.pstyle("line-cap").value,g=t.pstyle("line-outline-width").value,v=t.pstyle("line-outline-color").value,y=u*c,m=u*c,b=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;"straight-triangle"===d?(o.eleStrokeStyle(e,t,n),o.drawEdgeTrianglePath(t,e,s.allpts)):(e.lineWidth=p,e.lineCap=f,o.eleStrokeStyle(e,t,n),o.drawEdgePath(t,e,s.allpts,h),e.lineCap="butt")},x=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;e.lineWidth=p+g,e.lineCap=f,g>0?(o.colorStrokeStyle(e,v[0],v[1],v[2],n),"straight-triangle"===d?o.drawEdgeTrianglePath(t,e,s.allpts):(o.drawEdgePath(t,e,s.allpts,h),e.lineCap="butt")):e.lineCap="butt"},w=function(){i&&o.drawEdgeOverlay(e,t)},E=function(){i&&o.drawEdgeUnderlay(e,t)},k=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;o.drawArrowheads(e,t,n)},C=function(){o.drawElementText(e,t,null,r)};e.lineJoin="round";var S="yes"===t.pstyle("ghost").value;if(S){var P=t.pstyle("ghost-offset-x").pfValue,D=t.pstyle("ghost-offset-y").pfValue,T=t.pstyle("ghost-opacity").value,_=y*T;e.translate(P,D),b(_),k(_),e.translate(-P,-D)}else x();E(),b(),k(),w(),C(),n&&e.translate(l.x1,l.y1)}}},Wu=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n){if(n.visible()){var r=n.pstyle("".concat(e,"-opacity")).value;if(0!==r){var i=this,a=i.usePaths(),o=n._private.rscratch,s=2*n.pstyle("".concat(e,"-padding")).pfValue,l=n.pstyle("".concat(e,"-color")).value;t.lineWidth=s,"self"!==o.edgeType||a?t.lineCap="round":t.lineCap="butt",i.colorStrokeStyle(t,l[0],l[1],l[2],r),i.drawEdgePath(n,t,o.allpts,"solid")}}}};Xu.drawEdgeOverlay=Wu("overlay"),Xu.drawEdgeUnderlay=Wu("underlay"),Xu.drawEdgePath=function(e,t,n,r){var i,a=e._private.rscratch,o=t,s=!1,u=this.usePaths(),c=e.pstyle("line-dash-pattern").pfValue,d=e.pstyle("line-dash-offset").pfValue;if(u){var h=n.join("$");a.pathCacheKey&&a.pathCacheKey===h?(i=t=a.pathCache,s=!0):(i=t=new Path2D,a.pathCacheKey=h,a.pathCache=i)}if(o.setLineDash)switch(r){case"dotted":o.setLineDash([1,1]);break;case"dashed":o.setLineDash(c),o.lineDashOffset=d;break;case"solid":o.setLineDash([])}if(!s&&!a.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),a.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var p=2;p+35&&void 0!==arguments[5]?arguments[5]:5,o=arguments.length>6?arguments[6]:void 0;e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath(),o?e.stroke():e.fill()}Ku.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),i=Math.ceil(wt(n*r));t=Math.pow(2,i)}return!(e.pstyle("font-size").pfValue*t5&&void 0!==arguments[5])||arguments[5],o=this;if(null==r){if(a&&!o.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){var s=t.pstyle("label");if(!s||!s.value)return;var l=o.getLabelJustification(t);e.textAlign=l,e.textBaseline="bottom"}else{var u=t.element()._private.rscratch.badLine,c=t.pstyle("label"),d=t.pstyle("source-label"),h=t.pstyle("target-label");if(u||(!c||!c.value)&&(!d||!d.value)&&(!h||!h.value))return;e.textAlign="center",e.textBaseline="bottom"}var p,f=!n;n&&(p=n,e.translate(-p.x1,-p.y1)),null==i?(o.drawText(e,t,null,f,a),t.isEdge()&&(o.drawText(e,t,"source",f,a),o.drawText(e,t,"target",f,a))):o.drawText(e,t,i,f,a),n&&e.translate(p.x1,p.y1)},Ku.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n2&&void 0!==arguments[2])||arguments[2],r=t.pstyle("font-style").strValue,i=t.pstyle("font-size").pfValue+"px",a=t.pstyle("font-family").strValue,o=t.pstyle("font-weight").strValue,s=n?t.effectiveOpacity()*t.pstyle("text-opacity").value:1,l=t.pstyle("text-outline-opacity").value*s,u=t.pstyle("color").value,c=t.pstyle("text-outline-color").value;e.font=r+" "+o+" "+i+" "+a,e.lineJoin="round",this.colorFillStyle(e,u[0],u[1],u[2],s),this.colorStrokeStyle(e,c[0],c[1],c[2],l)},Ku.getTextAngle=function(e,t){var n=e._private.rscratch,r=t?t+"-":"",i=e.pstyle(r+"text-rotation"),a=Ue(n,"labelAngle",t);return"autorotate"===i.strValue?e.isEdge()?a:0:"none"===i.strValue?0:i.pfValue},Ku.drawText=function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=t._private,o=a.rscratch,s=i?t.effectiveOpacity():1;if(!i||0!==s&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var l,u,c=Ue(o,"labelX",n),d=Ue(o,"labelY",n),h=this.getLabelText(t,n);if(null!=h&&""!==h&&!isNaN(c)&&!isNaN(d)){this.setupTextStyle(e,t,i);var p,f=n?n+"-":"",g=Ue(o,"labelWidth",n),v=Ue(o,"labelHeight",n),y=t.pstyle(f+"text-margin-x").pfValue,m=t.pstyle(f+"text-margin-y").pfValue,b=t.isEdge(),x=t.pstyle("text-halign").value,w=t.pstyle("text-valign").value;switch(b&&(x="center",w="center"),c+=y,d+=m,0!==(p=r?this.getTextAngle(t,n):0)&&(l=c,u=d,e.translate(l,u),e.rotate(p),c=0,d=0),w){case"top":break;case"center":d+=v/2;break;case"bottom":d+=v}var E=t.pstyle("text-background-opacity").value,k=t.pstyle("text-border-opacity").value,C=t.pstyle("text-border-width").pfValue,S=t.pstyle("text-background-padding").pfValue,P=t.pstyle("text-background-shape").strValue,D=0===P.indexOf("round"),T=2;if(E>0||C>0&&k>0){var _=c-S;switch(x){case"left":_-=g;break;case"center":_-=g/2}var M=d-v-S,B=g+2*S,N=v+2*S;if(E>0){var z=e.fillStyle,I=t.pstyle("text-background-color").value;e.fillStyle="rgba("+I[0]+","+I[1]+","+I[2]+","+E*s+")",D?Gu(e,_,M,B,N,T):e.fillRect(_,M,B,N),e.fillStyle=z}if(C>0&&k>0){var A=e.strokeStyle,L=e.lineWidth,O=t.pstyle("text-border-color").value,R=t.pstyle("text-border-style").value;if(e.strokeStyle="rgba("+O[0]+","+O[1]+","+O[2]+","+k*s+")",e.lineWidth=C,e.setLineDash)switch(R){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=C/4,e.setLineDash([]);break;case"solid":e.setLineDash([])}if(D?Gu(e,_,M,B,N,T,"stroke"):e.strokeRect(_,M,B,N),"double"===R){var V=C/2;D?Gu(e,_+V,M+V,B-2*V,N-2*V,T,"stroke"):e.strokeRect(_+V,M+V,B-2*V,N-2*V)}e.setLineDash&&e.setLineDash([]),e.lineWidth=L,e.strokeStyle=A}}var F=2*t.pstyle("text-outline-width").pfValue;if(F>0&&(e.lineWidth=F),"wrap"===t.pstyle("text-wrap").value){var j=Ue(o,"labelWrapCachedLines",n),q=Ue(o,"labelLineHeight",n),Y=g/2,X=this.getLabelJustification(t);switch("auto"===X||("left"===x?"left"===X?c+=-g:"center"===X&&(c+=-Y):"center"===x?"left"===X?c+=-Y:"right"===X&&(c+=Y):"right"===x&&("center"===X?c+=Y:"right"===X&&(c+=g))),w){case"top":d-=(j.length-1)*q;break;case"center":case"bottom":d-=(j.length-1)*q}for(var W=0;W0&&e.strokeText(j[W],c,d),e.fillText(j[W],c,d),d+=q}else F>0&&e.strokeText(h,c,d),e.fillText(h,c,d);0!==p&&(e.rotate(-p),e.translate(-l,-u))}}};var Uu={drawNode:function(e,t,n){var r,i,a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],l=this,u=t._private,c=u.rscratch,d=t.position();if(x(d.x)&&x(d.y)&&(!s||t.visible())){var h,p,f=s?t.effectiveOpacity():1,g=l.usePaths(),v=!1,y=t.padding();r=t.width()+2*y,i=t.height()+2*y,n&&(p=n,e.translate(-p.x1,-p.y1));for(var m=t.pstyle("background-image"),b=m.value,w=new Array(b.length),E=new Array(b.length),k=0,C=0;C0&&void 0!==arguments[0]?arguments[0]:M;l.eleFillStyle(e,t,n)},H=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:R;l.colorStrokeStyle(e,B[0],B[1],B[2],t)},K=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:q;l.colorStrokeStyle(e,F[0],F[1],F[2],t)},G=function(e,t,n,r){var i,a=l.nodePathCache=l.nodePathCache||[],o=_e("polygon"===n?n+","+r.join(","):n,""+t,""+e,""+X),s=a[o],u=!1;return null!=s?(i=s,u=!0,c.pathCache=i):(i=new Path2D,a[o]=c.pathCache=i),{path:i,cacheHit:u}},U=t.pstyle("shape").strValue,Z=t.pstyle("shape-polygon-points").pfValue;if(g){e.translate(d.x,d.y);var $=G(r,i,U,Z);h=$.path,v=$.cacheHit}var Q=function(){if(!v){var n=d;g&&(n={x:0,y:0}),l.nodeShapes[l.getNodeShape(t)].draw(h||e,n.x,n.y,r,i,X,c)}g?e.fill(h):e.fill()},J=function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=u.backgrounding,a=0,o=0;o0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f;l.hasPie(t)&&(l.drawPie(e,t,a),n&&(g||l.nodeShapes[l.getNodeShape(t)].draw(e,d.x,d.y,r,i,X,c)))},te=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f,n=(T>0?T:-T)*t,r=T>0?0:255;0!==T&&(l.colorFillStyle(e,r,r,r,n),g?e.fill(h):e.fill())},ne=function(){if(_>0){if(e.lineWidth=_,e.lineCap=I,e.lineJoin=z,e.setLineDash)switch(N){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash(L),e.lineDashOffset=O;break;case"solid":case"double":e.setLineDash([])}if("center"!==A){if(e.save(),e.lineWidth*=2,"inside"===A)g?e.clip(h):e.clip();else{var t=new Path2D;t.rect(-r/2-_,-i/2-_,r+2*_,i+2*_),t.addPath(h),e.clip(t,"evenodd")}g?e.stroke(h):e.stroke(),e.restore()}else g?e.stroke(h):e.stroke();if("double"===N){e.lineWidth=_/3;var n=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(h):e.stroke(),e.globalCompositeOperation=n}e.setLineDash&&e.setLineDash([])}},re=function(){if(V>0){if(e.lineWidth=V,e.lineCap="butt",e.setLineDash)switch(j){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}var n=d;g&&(n={x:0,y:0});var a=l.getNodeShape(t),o=_;"inside"===A&&(o=0),"outside"===A&&(o*=2);var s,u=(r+o+(V+Y))/r,c=(i+o+(V+Y))/i,h=r*u,p=i*c,f=l.nodeShapes[a].points;if(g)s=G(h,p,a,f).path;if("ellipse"===a)l.drawEllipsePath(s||e,n.x,n.y,h,p);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(a)){var v=0,y=0,m=0;"round-diamond"===a?v=1.4*(o+Y+V):"round-heptagon"===a?(v=1.075*(o+Y+V),m=-(o/2+Y+V)/35):"round-hexagon"===a?v=1.12*(o+Y+V):"round-pentagon"===a?(v=1.13*(o+Y+V),m=-(o/2+Y+V)/15):"round-tag"===a?(v=1.12*(o+Y+V),y=.07*(o/2+V+Y)):"round-triangle"===a&&(v=(o+Y+V)*(Math.PI/2),m=-(o+Y/2+V)/Math.PI),0!==v&&(h=r*(u=(r+v)/r),["round-hexagon","round-tag"].includes(a)||(p=i*(c=(i+v)/i)));for(var b=h/2,x=p/2,w=(X="auto"===X?rn(h,p):X)+(o+V+Y)/2,E=new Array(f.length/2),k=new Array(f.length/2),C=0;C0){if(r=r||n.position(),null==i||null==a){var d=n.padding();i=n.width()+2*d,a=n.height()+2*d}this.colorFillStyle(t,l[0],l[1],l[2],s),this.nodeShapes[u].draw(t,r.x,r.y,i+2*o,a+2*o,c),t.fill()}}}};Uu.drawNodeOverlay=Zu("overlay"),Uu.drawNodeUnderlay=Zu("underlay"),Uu.hasPie=function(e){return(e=e[0])._private.hasPie},Uu.drawPie=function(e,t,n,r){t=t[0],r=r||t.position();var i=t.cy().style(),a=t.pstyle("pie-size"),o=r.x,s=r.y,l=t.width(),u=t.height(),c=Math.min(l,u)/2,d=0;this.usePaths()&&(o=0,s=0),"%"===a.units?c*=a.pfValue:void 0!==a.pfValue&&(c=a.pfValue/2);for(var h=1;h<=i.pieBackgroundN;h++){var p=t.pstyle("pie-"+h+"-background-size").value,f=t.pstyle("pie-"+h+"-background-color").value,g=t.pstyle("pie-"+h+"-background-opacity").value*n,v=p/100;v+d>1&&(v=1-d);var y=1.5*Math.PI+2*Math.PI*d,m=y+2*Math.PI*v;0===p||d>=1||d+v>1||(e.beginPath(),e.moveTo(o,s),e.arc(o,s,c,y,m),e.closePath(),this.colorFillStyle(e,f[0],f[1],f[2],g),e.fill(),d+=v)}};var $u={};$u.getPixelRatio=function(){var e=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var t=this.cy.window(),n=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(t.devicePixelRatio||1)/n},$u.paintCache=function(e){for(var t,n=this.paintCaches=this.paintCaches||[],r=!0,i=0;io.minMbLowQualFrames&&(o.motionBlurPxRatio=o.mbPxRBlurry)),o.clearingMotionBlur&&(o.motionBlurPxRatio=1),o.textureDrawLastFrame&&!d&&(c[o.NODE]=!0,c[o.SELECT_BOX]=!0);var m=l.style(),b=l.zoom(),x=void 0!==i?i:b,w=l.pan(),E={x:w.x,y:w.y},k={zoom:b,pan:{x:w.x,y:w.y}},C=o.prevViewport;void 0===C||k.zoom!==C.zoom||k.pan.x!==C.pan.x||k.pan.y!==C.pan.y||g&&!f||(o.motionBlurPxRatio=1),a&&(E=a),x*=s,E.x*=s,E.y*=s;var S=o.getCachedZSortedEles();function P(e,t,n,r,i){var a=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",o.colorFillStyle(e,255,255,255,o.motionBlurTransparency),e.fillRect(t,n,r,i),e.globalCompositeOperation=a}function D(e,r){var s,l,c,d;o.clearingMotionBlur||e!==u.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]&&e!==u.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]?(s=E,l=x,c=o.canvasWidth,d=o.canvasHeight):(s={x:w.x*p,y:w.y*p},l=b*p,c=o.canvasWidth*p,d=o.canvasHeight*p),e.setTransform(1,0,0,1,0,0),"motionBlur"===r?P(e,0,0,c,d):t||void 0!==r&&!r||e.clearRect(0,0,c,d),n||(e.translate(s.x,s.y),e.scale(l,l)),a&&e.translate(a.x,a.y),i&&e.scale(i,i)}if(d||(o.textureDrawLastFrame=!1),d){if(o.textureDrawLastFrame=!0,!o.textureCache){o.textureCache={},o.textureCache.bb=l.mutableElements().boundingBox(),o.textureCache.texture=o.data.bufferCanvases[o.TEXTURE_BUFFER];var T=o.data.bufferContexts[o.TEXTURE_BUFFER];T.setTransform(1,0,0,1,0,0),T.clearRect(0,0,o.canvasWidth*o.textureMult,o.canvasHeight*o.textureMult),o.render({forcedContext:T,drawOnlyNodeLayer:!0,forcedPxRatio:s*o.textureMult}),(k=o.textureCache.viewport={zoom:l.zoom(),pan:l.pan(),width:o.canvasWidth,height:o.canvasHeight}).mpan={x:(0-k.pan.x)/k.zoom,y:(0-k.pan.y)/k.zoom}}c[o.DRAG]=!1,c[o.NODE]=!1;var _=u.contexts[o.NODE],M=o.textureCache.texture;k=o.textureCache.viewport;_.setTransform(1,0,0,1,0,0),h?P(_,0,0,k.width,k.height):_.clearRect(0,0,k.width,k.height);var B=m.core("outside-texture-bg-color").value,N=m.core("outside-texture-bg-opacity").value;o.colorFillStyle(_,B[0],B[1],B[2],N),_.fillRect(0,0,k.width,k.height);b=l.zoom();D(_,!1),_.clearRect(k.mpan.x,k.mpan.y,k.width/k.zoom/s,k.height/k.zoom/s),_.drawImage(M,k.mpan.x,k.mpan.y,k.width/k.zoom/s,k.height/k.zoom/s)}else o.textureOnViewport&&!t&&(o.textureCache=null);var z=l.extent(),I=o.pinching||o.hoverData.dragging||o.swipePanning||o.data.wheelZooming||o.hoverData.draggingEles||o.cy.animated(),A=o.hideEdgesOnViewport&&I,L=[];if(L[o.NODE]=!c[o.NODE]&&h&&!o.clearedForMotionBlur[o.NODE]||o.clearingMotionBlur,L[o.NODE]&&(o.clearedForMotionBlur[o.NODE]=!0),L[o.DRAG]=!c[o.DRAG]&&h&&!o.clearedForMotionBlur[o.DRAG]||o.clearingMotionBlur,L[o.DRAG]&&(o.clearedForMotionBlur[o.DRAG]=!0),c[o.NODE]||n||r||L[o.NODE]){var O=h&&!L[o.NODE]&&1!==p;D(_=t||(O?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]:u.contexts[o.NODE]),h&&!O?"motionBlur":void 0),A?o.drawCachedNodes(_,S.nondrag,s,z):o.drawLayeredElements(_,S.nondrag,s,z),o.debug&&o.drawDebugPoints(_,S.nondrag),n||h||(c[o.NODE]=!1)}if(!r&&(c[o.DRAG]||n||L[o.DRAG])){O=h&&!L[o.DRAG]&&1!==p;D(_=t||(O?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]:u.contexts[o.DRAG]),h&&!O?"motionBlur":void 0),A?o.drawCachedNodes(_,S.drag,s,z):o.drawCachedElements(_,S.drag,s,z),o.debug&&o.drawDebugPoints(_,S.drag),n||h||(c[o.DRAG]=!1)}if(o.showFps||!r&&c[o.SELECT_BOX]&&!n){if(D(_=t||u.contexts[o.SELECT_BOX]),1==o.selection[4]&&(o.hoverData.selecting||o.touchData.selecting)){b=o.cy.zoom();var R=m.core("selection-box-border-width").value/b;_.lineWidth=R,_.fillStyle="rgba("+m.core("selection-box-color").value[0]+","+m.core("selection-box-color").value[1]+","+m.core("selection-box-color").value[2]+","+m.core("selection-box-opacity").value+")",_.fillRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]),R>0&&(_.strokeStyle="rgba("+m.core("selection-box-border-color").value[0]+","+m.core("selection-box-border-color").value[1]+","+m.core("selection-box-border-color").value[2]+","+m.core("selection-box-opacity").value+")",_.strokeRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]))}if(u.bgActivePosistion&&!o.hoverData.selecting){b=o.cy.zoom();var V=u.bgActivePosistion;_.fillStyle="rgba("+m.core("active-bg-color").value[0]+","+m.core("active-bg-color").value[1]+","+m.core("active-bg-color").value[2]+","+m.core("active-bg-opacity").value+")",_.beginPath(),_.arc(V.x,V.y,m.core("active-bg-size").pfValue/b,0,2*Math.PI),_.fill()}var F=o.lastRedrawTime;if(o.showFps&&F){F=Math.round(F);var j=Math.round(1e3/F);_.setTransform(1,0,0,1,0,0),_.fillStyle="rgba(255, 0, 0, 0.75)",_.strokeStyle="rgba(255, 0, 0, 0.75)",_.lineWidth=1,_.fillText("1 frame = "+F+" ms = "+j+" fps",0,20);_.strokeRect(0,30,250,20),_.fillRect(0,30,250*Math.min(j/60,1),20)}n||(c[o.SELECT_BOX]=!1)}if(h&&1!==p){var q=u.contexts[o.NODE],Y=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_NODE],X=u.contexts[o.DRAG],W=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_DRAG],H=function(e,t,n){e.setTransform(1,0,0,1,0,0),n||!y?e.clearRect(0,0,o.canvasWidth,o.canvasHeight):P(e,0,0,o.canvasWidth,o.canvasHeight);var r=p;e.drawImage(t,0,0,o.canvasWidth*r,o.canvasHeight*r,0,0,o.canvasWidth,o.canvasHeight)};(c[o.NODE]||L[o.NODE])&&(H(q,Y,L[o.NODE]),c[o.NODE]=!1),(c[o.DRAG]||L[o.DRAG])&&(H(X,W,L[o.DRAG]),c[o.DRAG]=!1)}o.prevViewport=k,o.clearingMotionBlur&&(o.clearingMotionBlur=!1,o.motionBlurCleared=!0,o.motionBlur=!0),h&&(o.motionBlurTimeout=setTimeout((function(){o.motionBlurTimeout=null,o.clearedForMotionBlur[o.NODE]=!1,o.clearedForMotionBlur[o.DRAG]=!1,o.motionBlur=!1,o.clearingMotionBlur=!d,o.mbFrames=0,c[o.NODE]=!0,c[o.DRAG]=!0,o.redraw()}),100)),t||l.emit("render")};for(var Qu={drawPolygonPath:function(e,t,n,r,i,a){var o=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],n+s*a[1]);for(var l=1;l0&&a>0){h.clearRect(0,0,i,a),h.globalCompositeOperation="source-over";var p=this.getCachedZSortedEles();if(e.full)h.translate(-n.x1*l,-n.y1*l),h.scale(l,l),this.drawElements(h,p),h.scale(1/l,1/l),h.translate(n.x1*l,n.y1*l);else{var f=t.pan(),g={x:f.x*l,y:f.y*l};l*=t.zoom(),h.translate(g.x,g.y),h.scale(l,l),this.drawElements(h,p),h.scale(1/l,1/l),h.translate(-g.x,-g.y)}e.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=e.bg,h.rect(0,0,i,a),h.fill())}return d},ac.png=function(e){return sc(e,this.bufferCanvasImage(e),"image/png")},ac.jpg=function(e){return sc(e,this.bufferCanvasImage(e),"image/jpeg")};var lc={nodeShapeImpl:function(e,t,n,r,i,a,o,s){switch(e){case"ellipse":return this.drawEllipsePath(t,n,r,i,a);case"polygon":return this.drawPolygonPath(t,n,r,i,a,o);case"round-polygon":return this.drawRoundPolygonPath(t,n,r,i,a,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,n,r,i,a,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,n,r,i,a,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,n,r,i,a,s);case"barrel":return this.drawBarrelPath(t,n,r,i,a)}}},uc=dc,cc=dc.prototype;function dc(e){var t=this,n=t.cy.window().document;t.data={canvases:new Array(cc.CANVAS_LAYERS),contexts:new Array(cc.CANVAS_LAYERS),canvasNeedsRedraw:new Array(cc.CANVAS_LAYERS),bufferCanvases:new Array(cc.BUFFER_COUNT),bufferContexts:new Array(cc.CANVAS_LAYERS)};t.data.canvasContainer=n.createElement("div");var r=t.data.canvasContainer.style;t.data.canvasContainer.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)",r.position="relative",r.zIndex="0",r.overflow="hidden";var i=e.cy.container();i.appendChild(t.data.canvasContainer),i.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)";var a={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};c&&c.userAgent.match(/msie|trident|edge/i)&&(a["-ms-touch-action"]="none",a["touch-action"]="none");for(var o=0;o setTimeout(resolve, ms)); -} - -$_network = {}; - -// Auxiliar function to fit a network to the screen -$_network.fitToScreen = function (network) { - var options = { - offset: { x: 0, y: 0 }, - duration: 1000, - easingFunction: "easeInOutQuad", - }; - network.fit({ animation: options }); -} - -// Default options for a network -$_network.defaultOptions = { - layout: { - randomSeed: 1 - }, - interaction: { - hover: true - }, - manipulation: { - enabled: false, - }, - groups: { - internal: { - shape: "dot", - size: 30, - font: { - size: 16, - face: "Tahoma", - color: "#ffffff", - }, - borderWidth: 3, - shadow: true, - color:{ - border: "#0077B6", - background: "#fafafa", - highlight: { - border: "#E77D22", - background: "#fafafa", - }, - hover: { - border: "#0077B6", - background: "#fefefe", - }, - } - }, - external: { - shape: "dot", - shapeProperties: { - borderDashes: [5, 5], - }, - size: 20, - font: { - size: 14, - face: "Tahoma", - color: "#ffffff", - }, - borderWidth: 2, - shadow: true, - color:{ - border: "#809FFF", - background: "#fafafa", - highlight: { - border: "#E77D22", - background: "#fafafa", - }, - hover: { - border: "#809FFF", - background: "#fefefe", - }, - } - }, - }, - nodes: { - shapeProperties: { - interpolation: false // 'true' for intensive zooming - }, - shape: "dot", - size: 30, - font: { - size: 16, - face: "Tahoma", - color: "#ffffff", - }, - borderWidth: 2, - shadow: true, - color:{ - border: "#222222", - background: "#666666", - highlight: { - border: "#E77D22", - background: "#E77D22", - }, - hover: { - border: "#222222", - background: "#666666", - }, - } - }, - edges: { - arrows: { - to: { enabled: true, scaleFactor: 1, type: "arrow" }, - }, - width: 2, - shadow: true, - color: { - color: "#0077B6", - highlight: "#E77D22", - hover: "#0077B6", - opacity: 0.7, - }, - smooth: { - type: "dynamic", // might need to change to "continuous" when there are too many nodes - //type: "continuous", - }, - }, - physics: { - stabilization: false, - barnesHut: { - gravitationalConstant: -5000, - springConstant: 0.001, - springLength: 200, - }, - }, -}; diff --git a/static/js/vis-network.min.js b/static/js/vis-network.min.js deleted file mode 100644 index 533db8f..0000000 --- a/static/js/vis-network.min.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * vis-network - * https://visjs.github.io/vis-network/ - * - * A dynamic, browser-based visualization library. - * - * @version 0.0.0-no-version - * @date 2024-05-22T15:26:44.472Z - * - * @copyright (c) 2011-2017 Almende B.V, http://almende.com - * @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs - * - * @license - * vis.js is dual licensed under both - * - * 1. The Apache 2.0 License - * http://www.apache.org/licenses/LICENSE-2.0 - * - * and - * - * 2. The MIT License - * http://opensource.org/licenses/MIT - * - * vis.js may be distributed under either license. - */ -!function(g,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((g="undefined"!=typeof globalThis?globalThis:g||self).vis=g.vis||{})}(this,(function(g){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}var e=function(g){return g&&g.Math===Math&&g},C=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof t&&t)||function(){return this}()||t||Function("return this")(),I=function(g){try{return!!g()}catch(g){return!0}},i=!I((function(){var g=function(){}.bind();return"function"!=typeof g||g.hasOwnProperty("prototype")})),o=i,n=Function.prototype,r=n.apply,s=n.call,a="object"==typeof Reflect&&Reflect.apply||(o?s.bind(r):function(){return s.apply(r,arguments)}),d=i,h=Function.prototype,l=h.call,c=d&&h.bind.bind(l,l),u=d?c:function(g){return function(){return l.apply(g,arguments)}},p=u,f=p({}.toString),v=p("".slice),y=function(g){return v(f(g),8,-1)},m=y,b=u,w=function(g){if("Function"===m(g))return b(g)},k="object"==typeof document&&document.all,x={all:k,IS_HTMLDDA:void 0===k&&void 0!==k},E=x.all,O=x.IS_HTMLDDA?function(g){return"function"==typeof g||g===E}:function(g){return"function"==typeof g},T={},D=!I((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),N=i,R=Function.prototype.call,P=N?R.bind(R):function(){return R.apply(R,arguments)},M={},B={}.propertyIsEnumerable,z=Object.getOwnPropertyDescriptor,S=z&&!B.call({1:2},1);M.f=S?function(g){var t=z(this,g);return!!t&&t.enumerable}:B;var Z,F,G=function(g,t){return{enumerable:!(1&g),configurable:!(2&g),writable:!(4&g),value:t}},j=I,L=y,V=Object,Y=u("".split),W=j((function(){return!V("z").propertyIsEnumerable(0)}))?function(g){return"String"===L(g)?Y(g,""):V(g)}:V,Q=function(g){return null==g},U=Q,_=TypeError,K=function(g){if(U(g))throw new _("Can't call method on "+g);return g},H=W,X=K,J=function(g){return H(X(g))},q=O,$=x.all,gg=x.IS_HTMLDDA?function(g){return"object"==typeof g?null!==g:q(g)||g===$}:function(g){return"object"==typeof g?null!==g:q(g)},tg={},Ag=tg,eg=C,Cg=O,Ig=function(g){return Cg(g)?g:void 0},ig=function(g,t){return arguments.length<2?Ig(Ag[g])||Ig(eg[g]):Ag[g]&&Ag[g][t]||eg[g]&&eg[g][t]},og=u({}.isPrototypeOf),ng="undefined"!=typeof navigator&&String(navigator.userAgent)||"",rg=C,sg=ng,ag=rg.process,dg=rg.Deno,hg=ag&&ag.versions||dg&&dg.version,lg=hg&&hg.v8;lg&&(F=(Z=lg.split("."))[0]>0&&Z[0]<4?1:+(Z[0]+Z[1])),!F&&sg&&(!(Z=sg.match(/Edge\/(\d+)/))||Z[1]>=74)&&(Z=sg.match(/Chrome\/(\d+)/))&&(F=+Z[1]);var cg=F,ug=cg,pg=I,fg=C.String,vg=!!Object.getOwnPropertySymbols&&!pg((function(){var g=Symbol("symbol detection");return!fg(g)||!(Object(g)instanceof Symbol)||!Symbol.sham&&ug&&ug<41})),yg=vg&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,mg=ig,bg=O,wg=og,kg=Object,xg=yg?function(g){return"symbol"==typeof g}:function(g){var t=mg("Symbol");return bg(t)&&wg(t.prototype,kg(g))},Eg=String,Og=function(g){try{return Eg(g)}catch(g){return"Object"}},Tg=O,Dg=Og,Ng=TypeError,Rg=function(g){if(Tg(g))return g;throw new Ng(Dg(g)+" is not a function")},Pg=Rg,Mg=Q,Bg=function(g,t){var A=g[t];return Mg(A)?void 0:Pg(A)},zg=P,Sg=O,Zg=gg,Fg=TypeError,Gg={exports:{}},jg=C,Lg=Object.defineProperty,Vg=function(g,t){try{Lg(jg,g,{value:t,configurable:!0,writable:!0})}catch(A){jg[g]=t}return t},Yg="__core-js_shared__",Wg=C[Yg]||Vg(Yg,{}),Qg=Wg;(Gg.exports=function(g,t){return Qg[g]||(Qg[g]=void 0!==t?t:{})})("versions",[]).push({version:"3.33.0",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.33.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Ug=Gg.exports,_g=K,Kg=Object,Hg=function(g){return Kg(_g(g))},Xg=Hg,Jg=u({}.hasOwnProperty),qg=Object.hasOwn||function(g,t){return Jg(Xg(g),t)},$g=u,gt=0,tt=Math.random(),At=$g(1..toString),et=function(g){return"Symbol("+(void 0===g?"":g)+")_"+At(++gt+tt,36)},Ct=Ug,It=qg,it=et,ot=vg,nt=yg,rt=C.Symbol,st=Ct("wks"),at=nt?rt.for||rt:rt&&rt.withoutSetter||it,dt=function(g){return It(st,g)||(st[g]=ot&&It(rt,g)?rt[g]:at("Symbol."+g)),st[g]},ht=P,lt=gg,ct=xg,ut=Bg,pt=function(g,t){var A,e;if("string"===t&&Sg(A=g.toString)&&!Zg(e=zg(A,g)))return e;if(Sg(A=g.valueOf)&&!Zg(e=zg(A,g)))return e;if("string"!==t&&Sg(A=g.toString)&&!Zg(e=zg(A,g)))return e;throw new Fg("Can't convert object to primitive value")},ft=TypeError,vt=dt("toPrimitive"),yt=function(g,t){if(!lt(g)||ct(g))return g;var A,e=ut(g,vt);if(e){if(void 0===t&&(t="default"),A=ht(e,g,t),!lt(A)||ct(A))return A;throw new ft("Can't convert object to primitive value")}return void 0===t&&(t="number"),pt(g,t)},mt=xg,bt=function(g){var t=yt(g,"string");return mt(t)?t:t+""},wt=gg,kt=C.document,xt=wt(kt)&&wt(kt.createElement),Et=function(g){return xt?kt.createElement(g):{}},Ot=Et,Tt=!D&&!I((function(){return 7!==Object.defineProperty(Ot("div"),"a",{get:function(){return 7}}).a})),Dt=D,Nt=P,Rt=M,Pt=G,Mt=J,Bt=bt,zt=qg,St=Tt,Zt=Object.getOwnPropertyDescriptor;T.f=Dt?Zt:function(g,t){if(g=Mt(g),t=Bt(t),St)try{return Zt(g,t)}catch(g){}if(zt(g,t))return Pt(!Nt(Rt.f,g,t),g[t])};var Ft=I,Gt=O,jt=/#|\.prototype\./,Lt=function(g,t){var A=Yt[Vt(g)];return A===Qt||A!==Wt&&(Gt(t)?Ft(t):!!t)},Vt=Lt.normalize=function(g){return String(g).replace(jt,".").toLowerCase()},Yt=Lt.data={},Wt=Lt.NATIVE="N",Qt=Lt.POLYFILL="P",Ut=Lt,_t=Rg,Kt=i,Ht=w(w.bind),Xt=function(g,t){return _t(g),void 0===t?g:Kt?Ht(g,t):function(){return g.apply(t,arguments)}},Jt={},qt=D&&I((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),$t=gg,gA=String,tA=TypeError,AA=function(g){if($t(g))return g;throw new tA(gA(g)+" is not an object")},eA=D,CA=Tt,IA=qt,iA=AA,oA=bt,nA=TypeError,rA=Object.defineProperty,sA=Object.getOwnPropertyDescriptor,aA="enumerable",dA="configurable",hA="writable";Jt.f=eA?IA?function(g,t,A){if(iA(g),t=oA(t),iA(A),"function"==typeof g&&"prototype"===t&&"value"in A&&hA in A&&!A[hA]){var e=sA(g,t);e&&e[hA]&&(g[t]=A.value,A={configurable:dA in A?A[dA]:e[dA],enumerable:aA in A?A[aA]:e[aA],writable:!1})}return rA(g,t,A)}:rA:function(g,t,A){if(iA(g),t=oA(t),iA(A),CA)try{return rA(g,t,A)}catch(g){}if("get"in A||"set"in A)throw new nA("Accessors not supported");return"value"in A&&(g[t]=A.value),g};var lA=Jt,cA=G,uA=D?function(g,t,A){return lA.f(g,t,cA(1,A))}:function(g,t,A){return g[t]=A,g},pA=C,fA=a,vA=w,yA=O,mA=T.f,bA=Ut,wA=tg,kA=Xt,xA=uA,EA=qg,OA=function(g){var t=function(A,e,C){if(this instanceof t){switch(arguments.length){case 0:return new g;case 1:return new g(A);case 2:return new g(A,e)}return new g(A,e,C)}return fA(g,this,arguments)};return t.prototype=g.prototype,t},TA=function(g,t){var A,e,C,I,i,o,n,r,s,a=g.target,d=g.global,h=g.stat,l=g.proto,c=d?pA:h?pA[a]:(pA[a]||{}).prototype,u=d?wA:wA[a]||xA(wA,a,{})[a],p=u.prototype;for(I in t)e=!(A=bA(d?I:a+(h?".":"#")+I,g.forced))&&c&&EA(c,I),o=u[I],e&&(n=g.dontCallGetSet?(s=mA(c,I))&&s.value:c[I]),i=e&&n?n:t[I],e&&typeof o==typeof i||(r=g.bind&&e?kA(i,pA):g.wrap&&e?OA(i):l&&yA(i)?vA(i):i,(g.sham||i&&i.sham||o&&o.sham)&&xA(r,"sham",!0),xA(u,I,r),l&&(EA(wA,C=a+"Prototype")||xA(wA,C,{}),xA(wA[C],I,i),g.real&&p&&(A||!p[I])&&xA(p,I,i)))},DA=Math.ceil,NA=Math.floor,RA=Math.trunc||function(g){var t=+g;return(t>0?NA:DA)(t)},PA=function(g){var t=+g;return t!=t||0===t?0:RA(t)},MA=PA,BA=Math.max,zA=Math.min,SA=function(g,t){var A=MA(g);return A<0?BA(A+t,0):zA(A,t)},ZA=PA,FA=Math.min,GA=function(g){return g>0?FA(ZA(g),9007199254740991):0},jA=function(g){return GA(g.length)},LA=J,VA=SA,YA=jA,WA=function(g){return function(t,A,e){var C,I=LA(t),i=YA(I),o=VA(e,i);if(g&&A!=A){for(;i>o;)if((C=I[o++])!=C)return!0}else for(;i>o;o++)if((g||o in I)&&I[o]===A)return g||o||0;return!g&&-1}},QA={includes:WA(!0),indexOf:WA(!1)},UA={},_A=qg,KA=J,HA=QA.indexOf,XA=UA,JA=u([].push),qA=function(g,t){var A,e=KA(g),C=0,I=[];for(A in e)!_A(XA,A)&&_A(e,A)&&JA(I,A);for(;t.length>C;)_A(e,A=t[C++])&&(~HA(I,A)||JA(I,A));return I},$A=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ge=qA,te=$A,Ae=Object.keys||function(g){return ge(g,te)},ee={};ee.f=Object.getOwnPropertySymbols;var Ce=D,Ie=u,ie=P,oe=I,ne=Ae,re=ee,se=M,ae=Hg,de=W,he=Object.assign,le=Object.defineProperty,ce=Ie([].concat),ue=!he||oe((function(){if(Ce&&1!==he({b:1},he(le({},"a",{enumerable:!0,get:function(){le(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var g={},t={},A=Symbol("assign detection"),e="abcdefghijklmnopqrst";return g[A]=7,e.split("").forEach((function(g){t[g]=g})),7!==he({},g)[A]||ne(he({},t)).join("")!==e}))?function(g,t){for(var A=ae(g),e=arguments.length,C=1,I=re.f,i=se.f;e>C;)for(var o,n=de(arguments[C++]),r=I?ce(ne(n),I(n)):ne(n),s=r.length,a=0;s>a;)o=r[a++],Ce&&!ie(i,n,o)||(A[o]=n[o]);return A}:he,pe=ue;TA({target:"Object",stat:!0,arity:2,forced:Object.assign!==pe},{assign:pe});var fe=A(tg.Object.assign),ve=u([].slice),ye=u,me=Rg,be=gg,we=qg,ke=ve,xe=i,Ee=Function,Oe=ye([].concat),Te=ye([].join),De={},Ne=xe?Ee.bind:function(g){var t=me(this),A=t.prototype,e=ke(arguments,1),C=function(){var A=Oe(e,ke(arguments));return this instanceof C?function(g,t,A){if(!we(De,t)){for(var e=[],C=0;C=.1;)(l=+I[a++%i])>s&&(l=s),h=Math.sqrt(l*l/(1+r*r)),t+=h=o<0?-h:h,A+=r*h,!0===d?g.lineTo(t,A):g.moveTo(t,A),s-=l,d=!d}var Ue={circle:Le,dashedLine:Qe,database:We,diamond:function(g,t,A,e){g.beginPath(),g.lineTo(t,A+e),g.lineTo(t+e,A),g.lineTo(t,A-e),g.lineTo(t-e,A),g.closePath()},ellipse:Ye,ellipse_vis:Ye,hexagon:function(g,t,A,e){g.beginPath();var C=2*Math.PI/6;g.moveTo(t+e,A);for(var I=1;I<6;I++)g.lineTo(t+e*Math.cos(C*I),A+e*Math.sin(C*I));g.closePath()},roundRect:Ve,square:function(g,t,A,e){g.beginPath(),g.rect(t-e,A-e,2*e,2*e),g.closePath()},star:function(g,t,A,e){g.beginPath(),A+=.1*(e*=.82);for(var C=0;C<10;C++){var I=C%2==0?1.3*e:.5*e;g.lineTo(t+I*Math.sin(2*C*Math.PI/10),A-I*Math.cos(2*C*Math.PI/10))}g.closePath()},triangle:function(g,t,A,e){g.beginPath(),A+=.275*(e*=1.15);var C=2*e,I=C/2,i=Math.sqrt(3)/6*C,o=Math.sqrt(C*C-I*I);g.moveTo(t,A-(o-i)),g.lineTo(t+I,A+i),g.lineTo(t-I,A+i),g.lineTo(t,A-(o-i)),g.closePath()},triangleDown:function(g,t,A,e){g.beginPath(),A-=.275*(e*=1.15);var C=2*e,I=C/2,i=Math.sqrt(3)/6*C,o=Math.sqrt(C*C-I*I);g.moveTo(t,A+(o-i)),g.lineTo(t+I,A-i),g.lineTo(t-I,A-i),g.lineTo(t,A+(o-i)),g.closePath()}};function _e(g,t){void 0===t&&(t={});var A=t.insertAt;if(g&&"undefined"!=typeof document){var e=document.head||document.getElementsByTagName("head")[0],C=document.createElement("style");C.type="text/css","top"===A&&e.firstChild?e.insertBefore(C,e.firstChild):e.appendChild(C),C.styleSheet?C.styleSheet.cssText=g:C.appendChild(document.createTextNode(g))}}_e(".vis-overlay{bottom:0;left:0;position:absolute;right:0;top:0;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}");_e(".vis [class*=span]{min-height:0;width:auto}");_e('div.vis-color-picker{background-color:#fff;border-radius:15px;box-shadow:0 0 10px 0 rgba(0,0,0,.5);display:none;height:444px;left:30px;margin-left:30px;margin-top:-140px;padding:10px;position:absolute;top:0;width:310px;z-index:1}div.vis-color-picker div.vis-arrow{left:5px;position:absolute;top:147px}div.vis-color-picker div.vis-arrow:after,div.vis-color-picker div.vis-arrow:before{border:solid transparent;content:" ";height:0;pointer-events:none;position:absolute;right:100%;top:50%;width:0}div.vis-color-picker div.vis-arrow:after{border-color:hsla(0,0%,100%,0) #fff hsla(0,0%,100%,0) hsla(0,0%,100%,0);border-width:30px;margin-top:-30px}div.vis-color-picker div.vis-color{cursor:pointer;height:289px;position:absolute;width:289px}div.vis-color-picker div.vis-brightness{position:absolute;top:313px}div.vis-color-picker div.vis-opacity{position:absolute;top:350px}div.vis-color-picker div.vis-selector{background:#4c4c4c;background:-moz-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4c4c4c),color-stop(12%,#595959),color-stop(25%,#666),color-stop(39%,#474747),color-stop(50%,#2c2c2c),color-stop(51%,#000),color-stop(60%,#111),color-stop(76%,#2b2b2b),color-stop(91%,#1c1c1c),color-stop(100%,#131313));background:-webkit-linear-gradient(top,#4c4c4c,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313);background:-o-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-ms-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:linear-gradient(180deg,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313);border:1px solid #fff;border-radius:15px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#4c4c4c",endColorstr="#131313",GradientType=0);height:15px;left:137px;position:absolute;top:137px;width:15px}div.vis-color-picker div.vis-new-color{left:159px;padding-right:2px;text-align:right}div.vis-color-picker div.vis-initial-color,div.vis-color-picker div.vis-new-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;color:rgba(0,0,0,.4);font-size:10px;height:20px;line-height:20px;position:absolute;top:380px;vertical-align:middle;width:140px}div.vis-color-picker div.vis-initial-color{left:10px;padding-left:2px;text-align:left}div.vis-color-picker div.vis-label{left:10px;position:absolute;width:300px}div.vis-color-picker div.vis-label.vis-brightness{top:300px}div.vis-color-picker div.vis-label.vis-opacity{top:338px}div.vis-color-picker div.vis-button{background-color:#f7f7f7;border:2px solid #d9d9d9;border-radius:10px;cursor:pointer;height:25px;line-height:25px;position:absolute;text-align:center;top:410px;vertical-align:middle;width:68px}div.vis-color-picker div.vis-button.vis-cancel{left:5px}div.vis-color-picker div.vis-button.vis-load{left:82px}div.vis-color-picker div.vis-button.vis-apply{left:159px}div.vis-color-picker div.vis-button.vis-save{left:236px}div.vis-color-picker input.vis-range{height:20px;width:290px}');_e('div.vis-configuration{display:block;float:left;font-size:12px;position:relative}div.vis-configuration-wrapper{display:block;width:700px}div.vis-configuration-wrapper:after{clear:both;content:"";display:block}div.vis-configuration.vis-config-option-container{background-color:#fff;border:2px solid #f7f8fa;border-radius:4px;display:block;left:10px;margin-top:20px;padding-left:5px;width:495px}div.vis-configuration.vis-config-button{background-color:#f7f8fa;border:2px solid #ceced0;border-radius:4px;cursor:pointer;display:block;height:25px;left:10px;line-height:25px;margin-bottom:30px;margin-top:20px;padding-left:5px;vertical-align:middle;width:495px}div.vis-configuration.vis-config-button.hover{background-color:#4588e6;border:2px solid #214373;color:#fff}div.vis-configuration.vis-config-item{display:block;float:left;height:25px;line-height:25px;vertical-align:middle;width:495px}div.vis-configuration.vis-config-item.vis-config-s2{background-color:#f7f8fa;border-radius:3px;left:10px;padding-left:5px}div.vis-configuration.vis-config-item.vis-config-s3{background-color:#e4e9f0;border-radius:3px;left:20px;padding-left:5px}div.vis-configuration.vis-config-item.vis-config-s4{background-color:#cfd8e6;border-radius:3px;left:30px;padding-left:5px}div.vis-configuration.vis-config-header{font-size:18px;font-weight:700}div.vis-configuration.vis-config-label{height:25px;line-height:25px;width:120px}div.vis-configuration.vis-config-label.vis-config-s3{width:110px}div.vis-configuration.vis-config-label.vis-config-s4{width:100px}div.vis-configuration.vis-config-colorBlock{border:1px solid #444;border-radius:2px;cursor:pointer;height:19px;margin:0;padding:0;top:1px;width:30px}input.vis-configuration.vis-config-checkbox{left:-5px}input.vis-configuration.vis-config-rangeinput{margin:0;padding:1px;pointer-events:none;position:relative;top:-5px;width:60px}input.vis-configuration.vis-config-range{-webkit-appearance:none;background-color:transparent;border:0 solid #fff;height:20px;width:300px}input.vis-configuration.vis-config-range::-webkit-slider-runnable-track{background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(180deg,#dedede 0,#c8c8c8 99%);border:1px solid #999;border-radius:3px;box-shadow:0 0 3px 0 #aaa;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#dedede",endColorstr="#c8c8c8",GradientType=0);height:5px;width:300px}input.vis-configuration.vis-config-range::-webkit-slider-thumb{-webkit-appearance:none;background:#3876c2;background:-moz-linear-gradient(top,#3876c2 0,#385380 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#3876c2),color-stop(100%,#385380));background:-webkit-linear-gradient(top,#3876c2,#385380);background:-o-linear-gradient(top,#3876c2 0,#385380 100%);background:-ms-linear-gradient(top,#3876c2 0,#385380 100%);background:linear-gradient(180deg,#3876c2 0,#385380);border:1px solid #14334b;border-radius:50%;box-shadow:0 0 1px 0 #111927;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#3876c2",endColorstr="#385380",GradientType=0);height:17px;margin-top:-7px;width:17px}input.vis-configuration.vis-config-range:focus{outline:none}input.vis-configuration.vis-config-range:focus::-webkit-slider-runnable-track{background:#9d9d9d;background:-moz-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#9d9d9d),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#9d9d9d,#c8c8c8 99%);background:-o-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:linear-gradient(180deg,#9d9d9d 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#9d9d9d",endColorstr="#c8c8c8",GradientType=0)}input.vis-configuration.vis-config-range::-moz-range-track{background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(180deg,#dedede 0,#c8c8c8 99%);border:1px solid #999;border-radius:3px;box-shadow:0 0 3px 0 #aaa;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#dedede",endColorstr="#c8c8c8",GradientType=0);height:10px;width:300px}input.vis-configuration.vis-config-range::-moz-range-thumb{background:#385380;border:none;border-radius:50%;height:16px;width:16px}input.vis-configuration.vis-config-range:-moz-focusring{outline:1px solid #fff;outline-offset:-1px}input.vis-configuration.vis-config-range::-ms-track{background:transparent;border-color:transparent;border-width:6px 0;color:transparent;height:5px;width:300px}input.vis-configuration.vis-config-range::-ms-fill-lower{background:#777;border-radius:10px}input.vis-configuration.vis-config-range::-ms-fill-upper{background:#ddd;border-radius:10px}input.vis-configuration.vis-config-range::-ms-thumb{background:#385380;border:none;border-radius:50%;height:16px;width:16px}input.vis-configuration.vis-config-range:focus::-ms-fill-lower{background:#888}input.vis-configuration.vis-config-range:focus::-ms-fill-upper{background:#ccc}.vis-configuration-popup{background:rgba(57,76,89,.85);border:2px solid #f2faff;border-radius:4px;color:#fff;font-size:14px;height:30px;line-height:30px;position:absolute;text-align:center;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out;width:150px}.vis-configuration-popup:after,.vis-configuration-popup:before{border:solid transparent;content:" ";height:0;left:100%;pointer-events:none;position:absolute;top:50%;width:0}.vis-configuration-popup:after{border-color:rgba(136,183,213,0) rgba(136,183,213,0) rgba(136,183,213,0) rgba(57,76,89,.85);border-width:8px;margin-top:-8px}.vis-configuration-popup:before{border-color:rgba(194,225,245,0) rgba(194,225,245,0) rgba(194,225,245,0) #f2faff;border-width:12px;margin-top:-12px}');_e("div.vis-tooltip{background-color:#f5f4ed;border:1px solid #808074;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;box-shadow:3px 3px 10px rgba(0,0,0,.2);color:#000;font-family:verdana;font-size:14px;padding:5px;pointer-events:none;position:absolute;visibility:hidden;white-space:nowrap;z-index:5}");var Ke={exports:{}};!function(g){function t(g){if(g)return function(g){for(var A in t.prototype)g[A]=t.prototype[A];return g}(g)}g.exports=t,t.prototype.on=t.prototype.addEventListener=function(g,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+g]=this._callbacks["$"+g]||[]).push(t),this},t.prototype.once=function(g,t){function A(){this.off(g,A),t.apply(this,arguments)}return A.fn=t,this.on(g,A),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(g,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var A,e=this._callbacks["$"+g];if(!e)return this;if(1==arguments.length)return delete this._callbacks["$"+g],this;for(var C=0;C=o?g?"":void 0:(e=uC(I,i))<55296||e>56319||i+1===o||(C=uC(I,i+1))<56320||C>57343?g?cC(I,i):e:g?pC(I,i,i+2):C-56320+(e-55296<<10)+65536}},vC={codeAt:fC(!1),charAt:fC(!0)},yC=O,mC=C.WeakMap,bC=yC(mC)&&/native code/.test(String(mC)),wC=et,kC=Ug("keys"),xC=function(g){return kC[g]||(kC[g]=wC(g))},EC=bC,OC=C,TC=gg,DC=uA,NC=qg,RC=Wg,PC=xC,MC=UA,BC="Object already initialized",zC=OC.TypeError,SC=OC.WeakMap;if(EC||RC.state){var ZC=RC.state||(RC.state=new SC);ZC.get=ZC.get,ZC.has=ZC.has,ZC.set=ZC.set,Je=function(g,t){if(ZC.has(g))throw new zC(BC);return t.facade=g,ZC.set(g,t),t},qe=function(g){return ZC.get(g)||{}},$e=function(g){return ZC.has(g)}}else{var FC=PC("state");MC[FC]=!0,Je=function(g,t){if(NC(g,FC))throw new zC(BC);return t.facade=g,DC(g,FC,t),t},qe=function(g){return NC(g,FC)?g[FC]:{}},$e=function(g){return NC(g,FC)}}var GC={set:Je,get:qe,has:$e,enforce:function(g){return $e(g)?qe(g):Je(g,{})},getterFor:function(g){return function(t){var A;if(!TC(t)||(A=qe(t)).type!==g)throw new zC("Incompatible receiver, "+g+" required");return A}}},jC=D,LC=qg,VC=Function.prototype,YC=jC&&Object.getOwnPropertyDescriptor,WC=LC(VC,"name"),QC={EXISTS:WC,PROPER:WC&&"something"===function(){}.name,CONFIGURABLE:WC&&(!jC||jC&&YC(VC,"name").configurable)},UC={},_C=D,KC=qt,HC=Jt,XC=AA,JC=J,qC=Ae;UC.f=_C&&!KC?Object.defineProperties:function(g,t){XC(g);for(var A,e=JC(t),C=qC(t),I=C.length,i=0;I>i;)HC.f(g,A=C[i++],e[A]);return g};var $C,gI=ig("document","documentElement"),tI=AA,AI=UC,eI=$A,CI=UA,II=gI,iI=Et,oI="prototype",nI="script",rI=xC("IE_PROTO"),sI=function(){},aI=function(g){return"<"+nI+">"+g+""},dI=function(g){g.write(aI("")),g.close();var t=g.parentWindow.Object;return g=null,t},hI=function(){try{$C=new ActiveXObject("htmlfile")}catch(g){}var g,t,A;hI="undefined"!=typeof document?document.domain&&$C?dI($C):(t=iI("iframe"),A="java"+nI+":",t.style.display="none",II.appendChild(t),t.src=String(A),(g=t.contentWindow.document).open(),g.write(aI("document.F=Object")),g.close(),g.F):dI($C);for(var e=eI.length;e--;)delete hI[oI][eI[e]];return hI()};CI[rI]=!0;var lI,cI,uI,pI=Object.create||function(g,t){var A;return null!==g?(sI[oI]=tI(g),A=new sI,sI[oI]=null,A[rI]=g):A=hI(),void 0===t?A:AI.f(A,t)},fI=!I((function(){function g(){}return g.prototype.constructor=null,Object.getPrototypeOf(new g)!==g.prototype})),vI=qg,yI=O,mI=Hg,bI=fI,wI=xC("IE_PROTO"),kI=Object,xI=kI.prototype,EI=bI?kI.getPrototypeOf:function(g){var t=mI(g);if(vI(t,wI))return t[wI];var A=t.constructor;return yI(A)&&t instanceof A?A.prototype:t instanceof kI?xI:null},OI=uA,TI=function(g,t,A,e){return e&&e.enumerable?g[t]=A:OI(g,t,A),g},DI=I,NI=O,RI=gg,PI=pI,MI=EI,BI=TI,zI=dt("iterator"),SI=!1;[].keys&&("next"in(uI=[].keys())?(cI=MI(MI(uI)))!==Object.prototype&&(lI=cI):SI=!0);var ZI=!RI(lI)||DI((function(){var g={};return lI[zI].call(g)!==g}));NI((lI=ZI?{}:PI(lI))[zI])||BI(lI,zI,(function(){return this}));var FI={IteratorPrototype:lI,BUGGY_SAFARI_ITERATORS:SI},GI=oC,jI=gC?{}.toString:function(){return"[object "+GI(this)+"]"},LI=gC,VI=Jt.f,YI=uA,WI=qg,QI=jI,UI=dt("toStringTag"),_I=function(g,t,A,e){if(g){var C=A?g:g.prototype;WI(C,UI)||VI(C,UI,{configurable:!0,value:t}),e&&!LI&&YI(C,"toString",QI)}},KI={},HI=FI.IteratorPrototype,XI=pI,JI=G,qI=_I,$I=KI,gi=function(){return this},ti=u,Ai=Rg,ei=O,Ci=String,Ii=TypeError,ii=function(g,t,A){try{return ti(Ai(Object.getOwnPropertyDescriptor(g,t)[A]))}catch(g){}},oi=AA,ni=function(g){if("object"==typeof g||ei(g))return g;throw new Ii("Can't set "+Ci(g)+" as a prototype")},ri=Object.setPrototypeOf||("__proto__"in{}?function(){var g,t=!1,A={};try{(g=ii(Object.prototype,"__proto__","set"))(A,[]),t=A instanceof Array}catch(g){}return function(A,e){return oi(A),ni(e),t?g(A,e):A.__proto__=e,A}}():void 0),si=TA,ai=P,di=QC,hi=function(g,t,A,e){var C=t+" Iterator";return g.prototype=XI(HI,{next:JI(+!e,A)}),qI(g,C,!1,!0),$I[C]=gi,g},li=EI,ci=_I,ui=TI,pi=KI,fi=FI,vi=di.PROPER,yi=fi.BUGGY_SAFARI_ITERATORS,mi=dt("iterator"),bi="keys",wi="values",ki="entries",xi=function(){return this},Ei=function(g,t,A,e,C,I,i){hi(A,t,e);var o,n,r,s=function(g){if(g===C&&c)return c;if(!yi&&g&&g in h)return h[g];switch(g){case bi:case wi:case ki:return function(){return new A(this,g)}}return function(){return new A(this)}},a=t+" Iterator",d=!1,h=g.prototype,l=h[mi]||h["@@iterator"]||C&&h[C],c=!yi&&l||s(C),u="Array"===t&&h.entries||l;if(u&&(o=li(u.call(new g)))!==Object.prototype&&o.next&&(ci(o,a,!0,!0),pi[a]=xi),vi&&C===wi&&l&&l.name!==wi&&(d=!0,c=function(){return ai(l,this)}),C)if(n={values:s(wi),keys:I?c:s(bi),entries:s(ki)},i)for(r in n)(yi||d||!(r in h))&&ui(h,r,n[r]);else si({target:t,proto:!0,forced:yi||d},n);return i&&h[mi]!==c&&ui(h,mi,c,{name:C}),pi[t]=c,n},Oi=function(g,t){return{value:g,done:t}},Ti=vC.charAt,Di=sC,Ni=GC,Ri=Ei,Pi=Oi,Mi="String Iterator",Bi=Ni.set,zi=Ni.getterFor(Mi);Ri(String,"String",(function(g){Bi(this,{type:Mi,string:Di(g),index:0})}),(function(){var g,t=zi(this),A=t.string,e=t.index;return e>=A.length?Pi(void 0,!0):(g=Ti(A,e),t.index+=g.length,Pi(g,!1))}));var Si=P,Zi=AA,Fi=Bg,Gi=function(g,t,A){var e,C;Zi(g);try{if(!(e=Fi(g,"return"))){if("throw"===t)throw A;return A}e=Si(e,g)}catch(g){C=!0,e=g}if("throw"===t)throw A;if(C)throw e;return Zi(e),A},ji=AA,Li=Gi,Vi=KI,Yi=dt("iterator"),Wi=Array.prototype,Qi=function(g){return void 0!==g&&(Vi.Array===g||Wi[Yi]===g)},Ui=O,_i=Wg,Ki=u(Function.toString);Ui(_i.inspectSource)||(_i.inspectSource=function(g){return Ki(g)});var Hi=_i.inspectSource,Xi=u,Ji=I,qi=O,$i=oC,go=Hi,to=function(){},Ao=[],eo=ig("Reflect","construct"),Co=/^\s*(?:class|function)\b/,Io=Xi(Co.exec),io=!Co.test(to),oo=function(g){if(!qi(g))return!1;try{return eo(to,Ao,g),!0}catch(g){return!1}},no=function(g){if(!qi(g))return!1;switch($i(g)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return io||!!Io(Co,go(g))}catch(g){return!0}};no.sham=!0;var ro=!eo||Ji((function(){var g;return oo(oo.call)||!oo(Object)||!oo((function(){g=!0}))||g}))?no:oo,so=bt,ao=Jt,ho=G,lo=function(g,t,A){var e=so(t);e in g?ao.f(g,e,ho(0,A)):g[e]=A},co=oC,uo=Bg,po=Q,fo=KI,vo=dt("iterator"),yo=function(g){if(!po(g))return uo(g,vo)||uo(g,"@@iterator")||fo[co(g)]},mo=P,bo=Rg,wo=AA,ko=Og,xo=yo,Eo=TypeError,Oo=function(g,t){var A=arguments.length<2?xo(g):t;if(bo(A))return wo(mo(A,g));throw new Eo(ko(g)+" is not iterable")},To=Xt,Do=P,No=Hg,Ro=function(g,t,A,e){try{return e?t(ji(A)[0],A[1]):t(A)}catch(t){Li(g,"throw",t)}},Po=Qi,Mo=ro,Bo=jA,zo=lo,So=Oo,Zo=yo,Fo=Array,Go=dt("iterator"),jo=!1;try{var Lo=0,Vo={next:function(){return{done:!!Lo++}},return:function(){jo=!0}};Vo[Go]=function(){return this},Array.from(Vo,(function(){throw 2}))}catch(g){}var Yo=function(g,t){try{if(!t&&!jo)return!1}catch(g){return!1}var A=!1;try{var e={};e[Go]=function(){return{next:function(){return{done:A=!0}}}},g(e)}catch(g){}return A},Wo=function(g){var t=No(g),A=Mo(this),e=arguments.length,C=e>1?arguments[1]:void 0,I=void 0!==C;I&&(C=To(C,e>2?arguments[2]:void 0));var i,o,n,r,s,a,d=Zo(t),h=0;if(!d||this===Fo&&Po(d))for(i=Bo(t),o=A?new this(i):Fo(i);i>h;h++)a=I?C(t[h],h):t[h],zo(o,h,a);else for(s=(r=So(t,d)).next,o=A?new this:[];!(n=Do(s,r)).done;h++)a=I?Ro(r,C,[n.value,h],!0):n.value,zo(o,h,a);return o.length=h,o};TA({target:"Array",stat:!0,forced:!Yo((function(g){Array.from(g)}))},{from:Wo});var Qo=tg.Array.from,Uo=A(Qo),_o=J,Ko=KI,Ho=GC;Jt.f;var Xo=Ei,Jo=Oi,qo="Array Iterator",$o=Ho.set,gn=Ho.getterFor(qo);Xo(Array,"Array",(function(g,t){$o(this,{type:qo,target:_o(g),index:0,kind:t})}),(function(){var g=gn(this),t=g.target,A=g.kind,e=g.index++;if(!t||e>=t.length)return g.target=void 0,Jo(void 0,!0);switch(A){case"keys":return Jo(e,!1);case"values":return Jo(t[e],!1)}return Jo([e,t[e]],!1)}),"values"),Ko.Arguments=Ko.Array;var tn=yo,An={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},en=C,Cn=oC,In=uA,on=KI,nn=dt("toStringTag");for(var rn in An){var sn=en[rn],an=sn&&sn.prototype;an&&Cn(an)!==nn&&In(an,nn,rn),on[rn]=on.Array}var dn=tn,hn=A(dn),ln=A(dn);function cn(g,t){if(!(g instanceof t))throw new TypeError("Cannot call a class as a function")}var un={exports:{}},pn=TA,fn=D,vn=Jt.f;pn({target:"Object",stat:!0,forced:Object.defineProperty!==vn,sham:!fn},{defineProperty:vn});var yn=tg.Object,mn=un.exports=function(g,t,A){return yn.defineProperty(g,t,A)};yn.defineProperty.sham&&(mn.sham=!0);var bn=un.exports,wn=bn,kn=A(wn),xn=y,En=Array.isArray||function(g){return"Array"===xn(g)},On=TypeError,Tn=function(g){if(g>9007199254740991)throw On("Maximum allowed index exceeded");return g},Dn=En,Nn=ro,Rn=gg,Pn=dt("species"),Mn=Array,Bn=function(g){var t;return Dn(g)&&(t=g.constructor,(Nn(t)&&(t===Mn||Dn(t.prototype))||Rn(t)&&null===(t=t[Pn]))&&(t=void 0)),void 0===t?Mn:t},zn=function(g,t){return new(Bn(g))(0===t?0:t)},Sn=I,Zn=cg,Fn=dt("species"),Gn=function(g){return Zn>=51||!Sn((function(){var t=[];return(t.constructor={})[Fn]=function(){return{foo:1}},1!==t[g](Boolean).foo}))},jn=TA,Ln=I,Vn=En,Yn=gg,Wn=Hg,Qn=jA,Un=Tn,_n=lo,Kn=zn,Hn=Gn,Xn=cg,Jn=dt("isConcatSpreadable"),qn=Xn>=51||!Ln((function(){var g=[];return g[Jn]=!1,g.concat()[0]!==g})),$n=function(g){if(!Yn(g))return!1;var t=g[Jn];return void 0!==t?!!t:Vn(g)};jn({target:"Array",proto:!0,arity:1,forced:!qn||!Hn("concat")},{concat:function(g){var t,A,e,C,I,i=Wn(this),o=Kn(i,0),n=0;for(t=-1,e=arguments.length;tf;f++)if((o||f in c)&&(h=u(d=c[f],f,l),g))if(t)y[f]=h;else if(h)switch(g){case 3:return!0;case 5:return d;case 6:return f;case 2:Br(y,d)}else switch(g){case 4:return!1;case 7:Br(y,d)}return I?-1:e||C?C:y}},Sr={forEach:zr(0),map:zr(1),filter:zr(2),some:zr(3),every:zr(4),find:zr(5),findIndex:zr(6),filterReject:zr(7)},Zr=TA,Fr=C,Gr=P,jr=u,Lr=D,Vr=vg,Yr=I,Wr=qg,Qr=og,Ur=AA,_r=J,Kr=bt,Hr=sC,Xr=G,Jr=pI,qr=Ae,$r=gr,gs=er,ts=ee,As=T,es=Jt,Cs=UC,Is=M,is=TI,os=ur,ns=Ug,rs=UA,ss=et,as=dt,ds=pr,hs=wr,ls=Tr,cs=_I,us=GC,ps=Sr.forEach,fs=xC("hidden"),vs="Symbol",ys="prototype",ms=us.set,bs=us.getterFor(vs),ws=Object[ys],ks=Fr.Symbol,xs=ks&&ks[ys],Es=Fr.RangeError,Os=Fr.TypeError,Ts=Fr.QObject,Ds=As.f,Ns=es.f,Rs=gs.f,Ps=Is.f,Ms=jr([].push),Bs=ns("symbols"),zs=ns("op-symbols"),Ss=ns("wks"),Zs=!Ts||!Ts[ys]||!Ts[ys].findChild,Fs=function(g,t,A){var e=Ds(ws,t);e&&delete ws[t],Ns(g,t,A),e&&g!==ws&&Ns(ws,t,e)},Gs=Lr&&Yr((function(){return 7!==Jr(Ns({},"a",{get:function(){return Ns(this,"a",{value:7}).a}})).a}))?Fs:Ns,js=function(g,t){var A=Bs[g]=Jr(xs);return ms(A,{type:vs,tag:g,description:t}),Lr||(A.description=t),A},Ls=function(g,t,A){g===ws&&Ls(zs,t,A),Ur(g);var e=Kr(t);return Ur(A),Wr(Bs,e)?(A.enumerable?(Wr(g,fs)&&g[fs][e]&&(g[fs][e]=!1),A=Jr(A,{enumerable:Xr(0,!1)})):(Wr(g,fs)||Ns(g,fs,Xr(1,{})),g[fs][e]=!0),Gs(g,e,A)):Ns(g,e,A)},Vs=function(g,t){Ur(g);var A=_r(t),e=qr(A).concat(Us(A));return ps(e,(function(t){Lr&&!Gr(Ys,A,t)||Ls(g,t,A[t])})),g},Ys=function(g){var t=Kr(g),A=Gr(Ps,this,t);return!(this===ws&&Wr(Bs,t)&&!Wr(zs,t))&&(!(A||!Wr(this,t)||!Wr(Bs,t)||Wr(this,fs)&&this[fs][t])||A)},Ws=function(g,t){var A=_r(g),e=Kr(t);if(A!==ws||!Wr(Bs,e)||Wr(zs,e)){var C=Ds(A,e);return!C||!Wr(Bs,e)||Wr(A,fs)&&A[fs][e]||(C.enumerable=!0),C}},Qs=function(g){var t=Rs(_r(g)),A=[];return ps(t,(function(g){Wr(Bs,g)||Wr(rs,g)||Ms(A,g)})),A},Us=function(g){var t=g===ws,A=Rs(t?zs:_r(g)),e=[];return ps(A,(function(g){!Wr(Bs,g)||t&&!Wr(ws,g)||Ms(e,Bs[g])})),e};Vr||(ks=function(){if(Qr(xs,this))throw new Os("Symbol is not a constructor");var g=arguments.length&&void 0!==arguments[0]?Hr(arguments[0]):void 0,t=ss(g),A=function(g){this===ws&&Gr(A,zs,g),Wr(this,fs)&&Wr(this[fs],t)&&(this[fs][t]=!1);var e=Xr(1,g);try{Gs(this,t,e)}catch(g){if(!(g instanceof Es))throw g;Fs(this,t,e)}};return Lr&&Zs&&Gs(ws,t,{configurable:!0,set:A}),js(t,g)},is(xs=ks[ys],"toString",(function(){return bs(this).tag})),is(ks,"withoutSetter",(function(g){return js(ss(g),g)})),Is.f=Ys,es.f=Ls,Cs.f=Vs,As.f=Ws,$r.f=gs.f=Qs,ts.f=Us,ds.f=function(g){return js(as(g),g)},Lr&&os(xs,"description",{configurable:!0,get:function(){return bs(this).description}})),Zr({global:!0,constructor:!0,wrap:!0,forced:!Vr,sham:!Vr},{Symbol:ks}),ps(qr(Ss),(function(g){hs(g)})),Zr({target:vs,stat:!0,forced:!Vr},{useSetter:function(){Zs=!0},useSimple:function(){Zs=!1}}),Zr({target:"Object",stat:!0,forced:!Vr,sham:!Lr},{create:function(g,t){return void 0===t?Jr(g):Vs(Jr(g),t)},defineProperty:Ls,defineProperties:Vs,getOwnPropertyDescriptor:Ws}),Zr({target:"Object",stat:!0,forced:!Vr},{getOwnPropertyNames:Qs}),ls(),cs(ks,vs),rs[fs]=!0;var _s=vg&&!!Symbol.for&&!!Symbol.keyFor,Ks=TA,Hs=ig,Xs=qg,Js=sC,qs=Ug,$s=_s,ga=qs("string-to-symbol-registry"),ta=qs("symbol-to-string-registry");Ks({target:"Symbol",stat:!0,forced:!$s},{for:function(g){var t=Js(g);if(Xs(ga,t))return ga[t];var A=Hs("Symbol")(t);return ga[t]=A,ta[A]=t,A}});var Aa=TA,ea=qg,Ca=xg,Ia=Og,ia=_s,oa=Ug("symbol-to-string-registry");Aa({target:"Symbol",stat:!0,forced:!ia},{keyFor:function(g){if(!Ca(g))throw new TypeError(Ia(g)+" is not a symbol");if(ea(oa,g))return oa[g]}});var na=En,ra=O,sa=y,aa=sC,da=u([].push),ha=TA,la=ig,ca=a,ua=P,pa=u,fa=I,va=O,ya=xg,ma=ve,ba=function(g){if(ra(g))return g;if(na(g)){for(var t=g.length,A=[],e=0;eg.length)&&(t=g.length);for(var A=0,e=new Array(t);A1?arguments[1]:void 0)}});var Mh=Me("Array").map,Bh=og,zh=Mh,Sh=Array.prototype,Zh=function(g){var t=g.map;return g===Sh||Bh(Sh,g)&&t===Sh.map?zh:t},Fh=A(Zh),Gh=Hg,jh=Ae;TA({target:"Object",stat:!0,forced:I((function(){jh(1)}))},{keys:function(g){return jh(Gh(g))}});var Lh=A(tg.Object.keys),Vh=TA,Yh=Date,Wh=u(Yh.prototype.getTime);Vh({target:"Date",stat:!0},{now:function(){return Wh(new Yh)}});var Qh=A(tg.Date.now),Uh=I,_h=function(g,t){var A=[][g];return!!A&&Uh((function(){A.call(null,t||function(){return 1},1)}))},Kh=Sr.forEach,Hh=_h("forEach")?[].forEach:function(g){return Kh(this,g,arguments.length>1?arguments[1]:void 0)};TA({target:"Array",proto:!0,forced:[].forEach!==Hh},{forEach:Hh});var Xh=Me("Array").forEach,Jh=oC,qh=qg,$h=og,gl=Xh,tl=Array.prototype,Al={DOMTokenList:!0,NodeList:!0},el=function(g){var t=g.forEach;return g===tl||$h(tl,g)&&t===tl.forEach||qh(Al,Jh(g))?gl:t},Cl=A(el),Il=TA,il=En,ol=u([].reverse),nl=[1,2];Il({target:"Array",proto:!0,forced:String(nl)===String(nl.reverse())},{reverse:function(){return il(this)&&(this.length=this.length),ol(this)}});var rl=Me("Array").reverse,sl=og,al=rl,dl=Array.prototype,hl=function(g){var t=g.reverse;return g===dl||sl(dl,g)&&t===dl.reverse?al:t},ll=hl,cl=A(ll),ul=Og,pl=TypeError,fl=function(g,t){if(!delete g[t])throw new pl("Cannot delete property "+ul(t)+" of "+ul(g))},vl=TA,yl=Hg,ml=SA,bl=PA,wl=jA,kl=Rd,xl=Tn,El=zn,Ol=lo,Tl=fl,Dl=Gn("splice"),Nl=Math.max,Rl=Math.min;vl({target:"Array",proto:!0,forced:!Dl},{splice:function(g,t){var A,e,C,I,i,o,n=yl(this),r=wl(n),s=ml(g,r),a=arguments.length;for(0===a?A=e=0:1===a?(A=0,e=r-s):(A=a-2,e=Rl(Nl(bl(t),0),r-s)),xl(r+A-e),C=El(n,e),I=0;Ir-e+A;I--)Tl(n,I-1)}else if(A>e)for(I=r-e;I>s;I--)o=I+A-1,(i=I+e-1)in n?n[o]=n[i]:Tl(n,o);for(I=0;I1?arguments[1]:void 0)}});var Gl=Me("Array").includes,jl=gg,Ll=y,Vl=dt("match"),Yl=function(g){var t;return jl(g)&&(void 0!==(t=g[Vl])?!!t:"RegExp"===Ll(g))},Wl=TypeError,Ql=dt("match"),Ul=TA,_l=function(g){if(Yl(g))throw new Wl("The method doesn't accept regular expressions");return g},Kl=K,Hl=sC,Xl=function(g){var t=/./;try{"/./"[g](t)}catch(A){try{return t[Ql]=!1,"/./"[g](t)}catch(g){}}return!1},Jl=u("".indexOf);Ul({target:"String",proto:!0,forced:!Xl("includes")},{includes:function(g){return!!~Jl(Hl(Kl(this)),Hl(_l(g)),arguments.length>1?arguments[1]:void 0)}});var ql=Me("String").includes,$l=og,gc=Gl,tc=ql,Ac=Array.prototype,ec=String.prototype,Cc=function(g){var t=g.includes;return g===Ac||$l(Ac,g)&&t===Ac.includes?gc:"string"==typeof g||g===ec||$l(ec,g)&&t===ec.includes?tc:t},Ic=A(Cc),ic=Hg,oc=EI,nc=fI;TA({target:"Object",stat:!0,forced:I((function(){oc(1)})),sham:!nc},{getPrototypeOf:function(g){return oc(ic(g))}});var rc=tg.Object.getPrototypeOf,sc=A(rc),ac=Sr.filter;TA({target:"Array",proto:!0,forced:!Gn("filter")},{filter:function(g){return ac(this,g,arguments.length>1?arguments[1]:void 0)}});var dc=Me("Array").filter,hc=og,lc=dc,cc=Array.prototype,uc=function(g){var t=g.filter;return g===cc||hc(cc,g)&&t===cc.filter?lc:t},pc=A(uc),fc="\t\n\v\f\r                \u2028\u2029\ufeff",vc=K,yc=sC,mc=fc,bc=u("".replace),wc=RegExp("^["+mc+"]+"),kc=RegExp("(^|[^"+mc+"])["+mc+"]+$"),xc=function(g){return function(t){var A=yc(vc(t));return 1&g&&(A=bc(A,wc,"")),2&g&&(A=bc(A,kc,"$1")),A}},Ec={start:xc(1),end:xc(2),trim:xc(3)},Oc=C,Tc=I,Dc=u,Nc=sC,Rc=Ec.trim,Pc=fc,Mc=Oc.parseInt,Bc=Oc.Symbol,zc=Bc&&Bc.iterator,Sc=/^[+-]?0x/i,Zc=Dc(Sc.exec),Fc=8!==Mc(Pc+"08")||22!==Mc(Pc+"0x16")||zc&&!Tc((function(){Mc(Object(zc))}))?function(g,t){var A=Rc(Nc(g));return Mc(A,t>>>0||(Zc(Sc,A)?16:10))}:Mc;TA({global:!0,forced:parseInt!==Fc},{parseInt:Fc});var Gc=A(tg.parseInt),jc=TA,Lc=QA.indexOf,Vc=_h,Yc=w([].indexOf),Wc=!!Yc&&1/Yc([1],1,-0)<0;jc({target:"Array",proto:!0,forced:Wc||!Vc("indexOf")},{indexOf:function(g){var t=arguments.length>1?arguments[1]:void 0;return Wc?Yc(this,g,t)||0:Lc(this,g,t)}});var Qc=Me("Array").indexOf,Uc=og,_c=Qc,Kc=Array.prototype,Hc=function(g){var t=g.indexOf;return g===Kc||Uc(Kc,g)&&t===Kc.indexOf?_c:t},Xc=A(Hc);TA({target:"Object",stat:!0,sham:!D},{create:pI});var Jc=tg.Object,qc=function(g,t){return Jc.create(g,t)},$c=A(qc),gu=tg,tu=a;gu.JSON||(gu.JSON={stringify:JSON.stringify});var Au=function(g,t,A){return tu(gu.JSON.stringify,null,arguments)},eu=A(Au),Cu="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,Iu=TypeError,iu=function(g,t){if(gA,i=ru(e)?e:lu(e),o=I?du(arguments,A):[],n=I?function(){nu(i,this,o)}:i;return t?g(n,C):g(n)}:g},pu=TA,fu=C,vu=uu(fu.setInterval,!0);pu({global:!0,bind:!0,forced:fu.setInterval!==vu},{setInterval:vu});var yu=TA,mu=C,bu=uu(mu.setTimeout,!0);yu({global:!0,bind:!0,forced:mu.setTimeout!==bu},{setTimeout:bu});var wu=A(tg.setTimeout),ku=Hg,xu=SA,Eu=jA,Ou=function(g){for(var t=ku(this),A=Eu(t),e=arguments.length,C=xu(e>1?arguments[1]:void 0,A),I=e>2?arguments[2]:void 0,i=void 0===I?A:xu(I,A);i>C;)t[C++]=g;return t};TA({target:"Array",proto:!0},{fill:Ou});var Tu,Du=Me("Array").fill,Nu=og,Ru=Du,Pu=Array.prototype,Mu=function(g){var t=g.fill;return g===Pu||Nu(Pu,g)&&t===Pu.fill?Ru:t},Bu=A(Mu); -/*! Hammer.JS - v2.0.17-rc - 2019-12-16 - * http://naver.github.io/egjs - * - * Forked By Naver egjs - * Copyright (c) hammerjs - * Licensed under the MIT license */ -function zu(){return zu=Object.assign||function(g){for(var t=1;t-1}var wp=function(){function g(g,t){this.manager=g,this.set(t)}var t=g.prototype;return t.set=function(g){g===Ku&&(g=this.compute()),_u&&this.manager.element.style&&gp[g]&&(this.manager.element.style[Uu]=g),this.actions=g.toLowerCase().trim()},t.update=function(){this.set(this.manager.options.touchAction)},t.compute=function(){var g=[];return yp(this.manager.recognizers,(function(t){mp(t.options.enable,[t])&&(g=g.concat(t.getTouchAction()))})),function(g){if(bp(g,Ju))return Ju;var t=bp(g,qu),A=bp(g,$u);return t&&A?Ju:t||A?t?qu:$u:bp(g,Xu)?Xu:Hu}(g.join(" "))},t.preventDefaults=function(g){var t=g.srcEvent,A=g.offsetDirection;if(this.manager.session.prevented)t.preventDefault();else{var e=this.actions,C=bp(e,Ju)&&!gp[Ju],I=bp(e,$u)&&!gp[$u],i=bp(e,qu)&&!gp[qu];if(C){var o=1===g.pointers.length,n=g.distance<2,r=g.deltaTime<250;if(o&&n&&r)return}if(!i||!I)return C||I&&A&cp||i&&A&up?this.preventSrc(t):void 0}},t.preventSrc=function(g){this.manager.session.prevented=!0,g.preventDefault()},g}();function kp(g,t){for(;g;){if(g===t)return!0;g=g.parentNode}return!1}function xp(g){var t=g.length;if(1===t)return{x:Vu(g[0].clientX),y:Vu(g[0].clientY)};for(var A=0,e=0,C=0;C=Yu(t)?g<0?ap:dp:t<0?hp:lp}function Np(g,t,A){return{x:t/g||0,y:A/g||0}}function Rp(g,t){var A=g.session,e=t.pointers,C=e.length;A.firstInput||(A.firstInput=Ep(t)),C>1&&!A.firstMultiple?A.firstMultiple=Ep(t):1===C&&(A.firstMultiple=!1);var I=A.firstInput,i=A.firstMultiple,o=i?i.center:I.center,n=t.center=xp(e);t.timeStamp=Wu(),t.deltaTime=t.timeStamp-I.timeStamp,t.angle=Tp(o,n),t.distance=Op(o,n),function(g,t){var A=t.center,e=g.offsetDelta||{},C=g.prevDelta||{},I=g.prevInput||{};t.eventType!==op&&I.eventType!==np||(C=g.prevDelta={x:I.deltaX||0,y:I.deltaY||0},e=g.offsetDelta={x:A.x,y:A.y}),t.deltaX=C.x+(A.x-e.x),t.deltaY=C.y+(A.y-e.y)}(A,t),t.offsetDirection=Dp(t.deltaX,t.deltaY);var r,s,a=Np(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=a.x,t.overallVelocityY=a.y,t.overallVelocity=Yu(a.x)>Yu(a.y)?a.x:a.y,t.scale=i?(r=i.pointers,Op((s=e)[0],s[1],vp)/Op(r[0],r[1],vp)):1,t.rotation=i?function(g,t){return Tp(t[1],t[0],vp)+Tp(g[1],g[0],vp)}(i.pointers,e):0,t.maxPointers=A.prevInput?t.pointers.length>A.prevInput.maxPointers?t.pointers.length:A.prevInput.maxPointers:t.pointers.length,function(g,t){var A,e,C,I,i=g.lastInterval||t,o=t.timeStamp-i.timeStamp;if(t.eventType!==rp&&(o>ip||void 0===i.velocity)){var n=t.deltaX-i.deltaX,r=t.deltaY-i.deltaY,s=Np(o,n,r);e=s.x,C=s.y,A=Yu(s.x)>Yu(s.y)?s.x:s.y,I=Dp(n,r),g.lastInterval=t}else A=i.velocity,e=i.velocityX,C=i.velocityY,I=i.direction;t.velocity=A,t.velocityX=e,t.velocityY=C,t.direction=I}(A,t);var d,h=g.element,l=t.srcEvent;kp(d=l.composedPath?l.composedPath()[0]:l.path?l.path[0]:l.target,h)&&(h=d),t.target=h}function Pp(g,t,A){var e=A.pointers.length,C=A.changedPointers.length,I=t&op&&e-C==0,i=t&(np|rp)&&e-C==0;A.isFirst=!!I,A.isFinal=!!i,I&&(g.session={}),A.eventType=t,Rp(g,A),g.emit("hammer.input",A),g.recognize(A),g.session.prevInput=A}function Mp(g){return g.trim().split(/\s+/g)}function Bp(g,t,A){yp(Mp(t),(function(t){g.addEventListener(t,A,!1)}))}function zp(g,t,A){yp(Mp(t),(function(t){g.removeEventListener(t,A,!1)}))}function Sp(g){var t=g.ownerDocument||g;return t.defaultView||t.parentWindow||window}var Zp=function(){function g(g,t){var A=this;this.manager=g,this.callback=t,this.element=g.element,this.target=g.options.inputTarget,this.domHandler=function(t){mp(g.options.enable,[g])&&A.handler(t)},this.init()}var t=g.prototype;return t.handler=function(){},t.init=function(){this.evEl&&Bp(this.element,this.evEl,this.domHandler),this.evTarget&&Bp(this.target,this.evTarget,this.domHandler),this.evWin&&Bp(Sp(this.element),this.evWin,this.domHandler)},t.destroy=function(){this.evEl&&zp(this.element,this.evEl,this.domHandler),this.evTarget&&zp(this.target,this.evTarget,this.domHandler),this.evWin&&zp(Sp(this.element),this.evWin,this.domHandler)},g}();function Fp(g,t,A){if(g.indexOf&&!A)return g.indexOf(t);for(var e=0;eA[t]})):e.sort()),e}var Up={touchstart:op,touchmove:2,touchend:np,touchcancel:rp},_p=function(g){function t(){var A;return t.prototype.evTarget="touchstart touchmove touchend touchcancel",(A=g.apply(this,arguments)||this).targetIds={},A}return Su(t,g),t.prototype.handler=function(g){var t=Up[g.type],A=Kp.call(this,g,t);A&&this.callback(this.manager,t,{pointers:A[0],changedPointers:A[1],pointerType:Cp,srcEvent:g})},t}(Zp);function Kp(g,t){var A,e,C=Wp(g.touches),I=this.targetIds;if(t&(2|op)&&1===C.length)return I[C[0].identifier]=!0,[C,C];var i=Wp(g.changedTouches),o=[],n=this.target;if(e=C.filter((function(g){return kp(g.target,n)})),t===op)for(A=0;A-1&&e.splice(g,1)}),Jp)}}function $p(g,t){g&op?(this.primaryTouch=t.changedPointers[0].identifier,qp.call(this,t)):g&(np|rp)&&qp.call(this,t)}function gf(g){for(var t=g.srcEvent.clientX,A=g.srcEvent.clientY,e=0;e-1&&this.requireFail.splice(t,1),this},t.hasRequireFailures=function(){return this.requireFail.length>0},t.canRecognizeWith=function(g){return!!this.simultaneous[g.id]},t.emit=function(g){var t=this,A=this.state;function e(A){t.manager.emit(A,g)}A<8&&e(t.options.event+of(A)),e(t.options.event),g.additionalEvent&&e(g.additionalEvent),A>=8&&e(t.options.event+of(A))},t.tryEmit=function(g){if(this.canEmit())return this.emit(g);this.state=ef},t.canEmit=function(){for(var g=0;gt.threshold&&C&t.direction},A.attrTest=function(g){return sf.prototype.attrTest.call(this,g)&&(2&this.state||!(2&this.state)&&this.directionTest(g))},A.emit=function(t){this.pX=t.deltaX,this.pY=t.deltaY;var A=af(t.direction);A&&(t.additionalEvent=this.options.event+A),g.prototype.emit.call(this,t)},t}(sf),hf=function(g){function t(t){return void 0===t&&(t={}),g.call(this,zu({event:"swipe",threshold:10,velocity:.3,direction:cp|up,pointers:1},t))||this}Su(t,g);var A=t.prototype;return A.getTouchAction=function(){return df.prototype.getTouchAction.call(this)},A.attrTest=function(t){var A,e=this.options.direction;return e&(cp|up)?A=t.overallVelocity:e&cp?A=t.overallVelocityX:e&up&&(A=t.overallVelocityY),g.prototype.attrTest.call(this,t)&&e&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers===this.options.pointers&&Yu(A)>this.options.velocity&&t.eventType&np},A.emit=function(g){var t=af(g.offsetDirection);t&&this.manager.emit(this.options.event+t,g),this.manager.emit(this.options.event,g)},t}(sf),lf=function(g){function t(t){return void 0===t&&(t={}),g.call(this,zu({event:"pinch",threshold:0,pointers:2},t))||this}Su(t,g);var A=t.prototype;return A.getTouchAction=function(){return[Ju]},A.attrTest=function(t){return g.prototype.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},A.emit=function(t){if(1!==t.scale){var A=t.scale<1?"in":"out";t.additionalEvent=this.options.event+A}g.prototype.emit.call(this,t)},t}(sf),cf=function(g){function t(t){return void 0===t&&(t={}),g.call(this,zu({event:"rotate",threshold:0,pointers:2},t))||this}Su(t,g);var A=t.prototype;return A.getTouchAction=function(){return[Ju]},A.attrTest=function(t){return g.prototype.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)},t}(sf),uf=function(g){function t(t){var A;return void 0===t&&(t={}),(A=g.call(this,zu({event:"press",pointers:1,time:251,threshold:9},t))||this)._timer=null,A._input=null,A}Su(t,g);var A=t.prototype;return A.getTouchAction=function(){return[Hu]},A.process=function(g){var t=this,A=this.options,e=g.pointers.length===A.pointers,C=g.distanceA.time;if(this._input=g,!C||!e||g.eventType&(np|rp)&&!I)this.reset();else if(g.eventType&op)this.reset(),this._timer=setTimeout((function(){t.state=8,t.tryEmit()}),A.time);else if(g.eventType&np)return 8;return ef},A.reset=function(){clearTimeout(this._timer)},A.emit=function(g){8===this.state&&(g&&g.eventType&np?this.manager.emit(this.options.event+"up",g):(this._input.timeStamp=Wu(),this.manager.emit(this.options.event,this._input)))},t}(nf),pf={domEvents:!1,touchAction:Ku,enable:!0,inputTarget:null,inputClass:null,cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},ff=[[cf,{enable:!1}],[lf,{enable:!1},["rotate"]],[hf,{direction:cp}],[df,{direction:cp},["swipe"]],[rf],[rf,{event:"doubletap",taps:2},["tap"]],[uf]];function vf(g,t){var A,e=g.element;e.style&&(yp(g.options.cssProps,(function(C,I){A=Qu(e.style,I),t?(g.oldCssProps[A]=e.style[A],e.style[A]=C):e.style[A]=g.oldCssProps[A]||""})),t||(g.oldCssProps={}))}var yf=function(){function g(g,t){var A,e=this;this.options=Gu({},pf,t||{}),this.options.inputTarget=this.options.inputTarget||g,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=g,this.input=new((A=this).options.inputClass||(Ap?Yp:ep?_p:tp?tf:Xp))(A,Pp),this.touchAction=new wp(this,this.options.touchAction),vf(this,!0),yp(this.options.recognizers,(function(g){var t=e.add(new g[0](g[1]));g[2]&&t.recognizeWith(g[2]),g[3]&&t.requireFailure(g[3])}),this)}var t=g.prototype;return t.set=function(g){return Gu(this.options,g),g.touchAction&&this.touchAction.update(),g.inputTarget&&(this.input.destroy(),this.input.target=g.inputTarget,this.input.init()),this},t.stop=function(g){this.session.stopped=g?2:1},t.recognize=function(g){var t=this.session;if(!t.stopped){var A;this.touchAction.preventDefaults(g);var e=this.recognizers,C=t.curRecognizer;(!C||C&&8&C.state)&&(t.curRecognizer=null,C=null);for(var I=0;I\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",C=window.console&&(window.console.warn||window.console.log);return C&&C.call(window.console,e,A),g.apply(this,arguments)}}var xf=kf((function(g,t,A){for(var e=Object.keys(t),C=0;C=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function Pf(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);A2)return zf.apply(void 0,bh(e=[Bf(t[0],t[1])]).call(e,ch(wh(t).call(t,2))));var C=t[0],I=t[1];if(C instanceof Date&&I instanceof Date)return C.setTime(I.getTime()),C;var i,o=Rf(Nh(I));try{for(o.s();!(i=o.n()).done;){var n=i.value;Object.prototype.propertyIsEnumerable.call(I,n)&&(I[n]===Mf?delete C[n]:null===C[n]||null===I[n]||"object"!==yd(C[n])||"object"!==yd(I[n])||Rh(C[n])||Rh(I[n])?C[n]=Sf(I[n]):C[n]=zf(C[n],I[n]))}}catch(g){o.e(g)}finally{o.f()}return C}function Sf(g){return Rh(g)?Fh(g).call(g,(function(g){return Sf(g)})):"object"===yd(g)&&null!==g?g instanceof Date?new Date(g.getTime()):zf({},g):g}function Zf(g){for(var t=0,A=Lh(g);t>>0,g=(C*=g)>>>0,g+=4294967296*(C-=g)}return 2.3283064365386963e-10*(g>>>0)}}(),t=g(" "),A=g(" "),e=g(" "),C=0;C2&&void 0!==arguments[2]&&arguments[2];for(var e in g)if(void 0!==t[e])if(null===t[e]||"object"!==yd(t[e]))Kf(g,t,e,A);else{var C=g[e],I=t[e];_f(C)&&_f(I)&&Hf(C,I,A)}}function Xf(g,t,A){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Rh(A))throw new TypeError("Arrays are not supported by deepExtend");for(var C=0;C3&&void 0!==arguments[3]&&arguments[3];if(Rh(A))throw new TypeError("Arrays are not supported by deepExtend");for(var C in A)if(Object.prototype.hasOwnProperty.call(A,C)&&!Ic(g).call(g,C))if(A[C]&&A[C].constructor===Object)void 0===t[C]&&(t[C]={}),t[C].constructor===Object?qf(t[C],A[C]):Kf(t,A,C,e);else if(Rh(A[C])){t[C]=[];for(var I=0;I2&&void 0!==arguments[2]&&arguments[2],e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];for(var C in t)if(Object.prototype.hasOwnProperty.call(t,C)||!0===A)if("object"===yd(t[C])&&null!==t[C]&&sc(t[C])===Object.prototype)void 0===g[C]?g[C]=qf({},t[C],A):"object"===yd(g[C])&&null!==g[C]&&sc(g[C])===Object.prototype?qf(g[C],t[C],A):Kf(g,t,C,e);else if(Rh(t[C])){var I;g[C]=wh(I=t[C]).call(I)}else Kf(g,t,C,e);return g}function $f(g,t){var A;return bh(A=[]).call(A,ch(g),[t])}function gv(g){return g.getBoundingClientRect().top}function tv(g,t){if(Rh(g))for(var A=g.length,e=0;e3&&void 0!==arguments[3]?arguments[3]:{},C=function(g){return null!=g},I=function(g){return null!==g&&"object"===yd(g)};if(!I(g))throw new Error("Parameter mergeTarget must be an object");if(!I(t))throw new Error("Parameter options must be an object");if(!C(A))throw new Error("Parameter option must have a value");if(!I(e))throw new Error("Parameter globalOptions must be an object");var i=t[A],o=I(e)&&!function(g){for(var t in g)if(Object.prototype.hasOwnProperty.call(g,t))return!1;return!0}(e)?e[A]:void 0,n=o?o.enabled:void 0;if(void 0!==i){if("boolean"==typeof i)return I(g[A])||(g[A]={}),void(g[A].enabled=i);if(null===i&&!I(g[A])){if(!C(o))return;g[A]=$c(o)}if(I(i)){var r=!0;void 0!==i.enabled?r=i.enabled:void 0!==n&&(r=o.enabled),function(g,t,A){I(g[A])||(g[A]={});var e=t[A],C=g[A];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(C[i]=e[i])}(g,t,A),g[A].enabled=r}}}var hv={linear:function(g){return g},easeInQuad:function(g){return g*g},easeOutQuad:function(g){return g*(2-g)},easeInOutQuad:function(g){return g<.5?2*g*g:(4-2*g)*g-1},easeInCubic:function(g){return g*g*g},easeOutCubic:function(g){return--g*g*g+1},easeInOutCubic:function(g){return g<.5?4*g*g*g:(g-1)*(2*g-2)*(2*g-2)+1},easeInQuart:function(g){return g*g*g*g},easeOutQuart:function(g){return 1- --g*g*g*g},easeInOutQuart:function(g){return g<.5?8*g*g*g*g:1-8*--g*g*g*g},easeInQuint:function(g){return g*g*g*g*g},easeOutQuint:function(g){return 1+--g*g*g*g*g},easeInOutQuint:function(g){return g<.5?16*g*g*g*g*g:1+16*--g*g*g*g*g}};function lv(g,t){var A;Rh(t)||(t=[t]);var e,C=Rf(g);try{for(C.s();!(e=C.n()).done;){var I=e.value;if(I){A=I[t[0]];for(var i=1;i0&&void 0!==arguments[0]?arguments[0]:1;cn(this,g),this.pixelRatio=t,this.generated=!1,this.centerCoordinates={x:144.5,y:144.5},this.r=289*.49,this.color={r:255,g:255,b:255,a:1},this.hueCircle=void 0,this.initialColor={r:255,g:255,b:255,a:1},this.previousColor=void 0,this.applied=!1,this.updateCallback=function(){},this.closeCallback=function(){},this._create()}return kd(g,[{key:"insertTo",value:function(g){void 0!==this.hammer&&(this.hammer.destroy(),this.hammer=void 0),this.container=g,this.container.appendChild(this.frame),this._bindHammer(),this._setSize()}},{key:"setUpdateCallback",value:function(g){if("function"!=typeof g)throw new Error("Function attempted to set as colorPicker update callback is not a function.");this.updateCallback=g}},{key:"setCloseCallback",value:function(g){if("function"!=typeof g)throw new Error("Function attempted to set as colorPicker closing callback is not a function.");this.closeCallback=g}},{key:"_isColorString",value:function(g){if("string"==typeof g)return cv[g]}},{key:"setColor",value:function(g){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("none"!==g){var A,e=this._isColorString(g);if(void 0!==e&&(g=e),!0===Uf(g)){if(!0===sv(g)){var C=g.substr(4).substr(0,g.length-5).split(",");A={r:C[0],g:C[1],b:C[2],a:1}}else if(!0===function(g){return Wf.test(g)}(g)){var I=g.substr(5).substr(0,g.length-6).split(",");A={r:I[0],g:I[1],b:I[2],a:I[3]}}else if(!0===rv(g)){var i=Av(g);A={r:i.r,g:i.g,b:i.b,a:1}}}else if(g instanceof Object&&void 0!==g.r&&void 0!==g.g&&void 0!==g.b){var o=void 0!==g.a?g.a:"1.0";A={r:g.r,g:g.g,b:g.b,a:o}}if(void 0===A)throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: "+eu(g));this._setColor(A,t)}}},{key:"show",value:function(){void 0!==this.closeCallback&&(this.closeCallback(),this.closeCallback=void 0),this.applied=!1,this.frame.style.display="block",this._generateHueCircle()}},{key:"_hide",value:function(){var g=this;!0===(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(this.previousColor=fe({},this.color)),!0===this.applied&&this.updateCallback(this.initialColor),this.frame.style.display="none",wu((function(){void 0!==g.closeCallback&&(g.closeCallback(),g.closeCallback=void 0)}),0)}},{key:"_save",value:function(){this.updateCallback(this.color),this.applied=!1,this._hide()}},{key:"_apply",value:function(){this.applied=!0,this.updateCallback(this.color),this._updatePicker(this.color)}},{key:"_loadLast",value:function(){void 0!==this.previousColor?this.setColor(this.previousColor,!1):alert("There is no last color to load...")}},{key:"_setColor",value:function(g){!0===(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&(this.initialColor=fe({},g)),this.color=g;var t=iv(g.r,g.g,g.b),A=2*Math.PI,e=this.r*t.s,C=this.centerCoordinates.x+e*Math.sin(A*t.h),I=this.centerCoordinates.y+e*Math.cos(A*t.h);this.colorPickerSelector.style.left=C-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=I-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(g)}},{key:"_setOpacity",value:function(g){this.color.a=g/100,this._updatePicker(this.color)}},{key:"_setBrightness",value:function(g){var t=iv(this.color.r,this.color.g,this.color.b);t.v=g/100;var A=ov(t.h,t.s,t.v);A.a=this.color.a,this.color=A,this._updatePicker()}},{key:"_updatePicker",value:function(){var g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.color,t=iv(g.r,g.g,g.b),A=this.colorPickerCanvas.getContext("2d");void 0===this.pixelRation&&(this.pixelRatio=(window.devicePixelRatio||1)/(A.webkitBackingStorePixelRatio||A.mozBackingStorePixelRatio||A.msBackingStorePixelRatio||A.oBackingStorePixelRatio||A.backingStorePixelRatio||1)),A.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var e=this.colorPickerCanvas.clientWidth,C=this.colorPickerCanvas.clientHeight;A.clearRect(0,0,e,C),A.putImageData(this.hueCircle,0,0),A.fillStyle="rgba(0,0,0,"+(1-t.v)+")",A.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),Bu(A).call(A),this.brightnessRange.value=100*t.v,this.opacityRange.value=100*g.a,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}},{key:"_setSize",value:function(){this.colorPickerCanvas.style.width="100%",this.colorPickerCanvas.style.height="100%",this.colorPickerCanvas.width=289*this.pixelRatio,this.colorPickerCanvas.height=289*this.pixelRatio}},{key:"_create",value:function(){var g,t,A,e;if(this.frame=document.createElement("div"),this.frame.className="vis-color-picker",this.colorPickerDiv=document.createElement("div"),this.colorPickerSelector=document.createElement("div"),this.colorPickerSelector.className="vis-selector",this.colorPickerDiv.appendChild(this.colorPickerSelector),this.colorPickerCanvas=document.createElement("canvas"),this.colorPickerDiv.appendChild(this.colorPickerCanvas),this.colorPickerCanvas.getContext){var C=this.colorPickerCanvas.getContext("2d");this.pixelRatio=(window.devicePixelRatio||1)/(C.webkitBackingStorePixelRatio||C.mozBackingStorePixelRatio||C.msBackingStorePixelRatio||C.oBackingStorePixelRatio||C.backingStorePixelRatio||1),this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{var I=document.createElement("DIV");I.style.color="red",I.style.fontWeight="bold",I.style.padding="10px",I.innerText="Error: your browser does not support HTML canvas",this.colorPickerCanvas.appendChild(I)}this.colorPickerDiv.className="vis-color",this.opacityDiv=document.createElement("div"),this.opacityDiv.className="vis-opacity",this.brightnessDiv=document.createElement("div"),this.brightnessDiv.className="vis-brightness",this.arrowDiv=document.createElement("div"),this.arrowDiv.className="vis-arrow",this.opacityRange=document.createElement("input");try{this.opacityRange.type="range",this.opacityRange.min="0",this.opacityRange.max="100"}catch(g){}this.opacityRange.value="100",this.opacityRange.className="vis-range",this.brightnessRange=document.createElement("input");try{this.brightnessRange.type="range",this.brightnessRange.min="0",this.brightnessRange.max="100"}catch(g){}this.brightnessRange.value="100",this.brightnessRange.className="vis-range",this.opacityDiv.appendChild(this.opacityRange),this.brightnessDiv.appendChild(this.brightnessRange);var i=this;this.opacityRange.onchange=function(){i._setOpacity(this.value)},this.opacityRange.oninput=function(){i._setOpacity(this.value)},this.brightnessRange.onchange=function(){i._setBrightness(this.value)},this.brightnessRange.oninput=function(){i._setBrightness(this.value)},this.brightnessLabel=document.createElement("div"),this.brightnessLabel.className="vis-label vis-brightness",this.brightnessLabel.innerText="brightness:",this.opacityLabel=document.createElement("div"),this.opacityLabel.className="vis-label vis-opacity",this.opacityLabel.innerText="opacity:",this.newColorDiv=document.createElement("div"),this.newColorDiv.className="vis-new-color",this.newColorDiv.innerText="new",this.initialColorDiv=document.createElement("div"),this.initialColorDiv.className="vis-initial-color",this.initialColorDiv.innerText="initial",this.cancelButton=document.createElement("div"),this.cancelButton.className="vis-button vis-cancel",this.cancelButton.innerText="cancel",this.cancelButton.onclick=je(g=this._hide).call(g,this,!1),this.applyButton=document.createElement("div"),this.applyButton.className="vis-button vis-apply",this.applyButton.innerText="apply",this.applyButton.onclick=je(t=this._apply).call(t,this),this.saveButton=document.createElement("div"),this.saveButton.className="vis-button vis-save",this.saveButton.innerText="save",this.saveButton.onclick=je(A=this._save).call(A,this),this.loadButton=document.createElement("div"),this.loadButton.className="vis-button vis-load",this.loadButton.innerText="load last",this.loadButton.onclick=je(e=this._loadLast).call(e,this),this.frame.appendChild(this.colorPickerDiv),this.frame.appendChild(this.arrowDiv),this.frame.appendChild(this.brightnessLabel),this.frame.appendChild(this.brightnessDiv),this.frame.appendChild(this.opacityLabel),this.frame.appendChild(this.opacityDiv),this.frame.appendChild(this.newColorDiv),this.frame.appendChild(this.initialColorDiv),this.frame.appendChild(this.cancelButton),this.frame.appendChild(this.applyButton),this.frame.appendChild(this.saveButton),this.frame.appendChild(this.loadButton)}},{key:"_bindHammer",value:function(){var g=this;this.drag={},this.pinch={},this.hammer=new Gf(this.colorPickerCanvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.on("hammer.input",(function(t){t.isFirst&&g._moveSelector(t)})),this.hammer.on("tap",(function(t){g._moveSelector(t)})),this.hammer.on("panstart",(function(t){g._moveSelector(t)})),this.hammer.on("panmove",(function(t){g._moveSelector(t)})),this.hammer.on("panend",(function(t){g._moveSelector(t)}))}},{key:"_generateHueCircle",value:function(){if(!1===this.generated){var g=this.colorPickerCanvas.getContext("2d");void 0===this.pixelRation&&(this.pixelRatio=(window.devicePixelRatio||1)/(g.webkitBackingStorePixelRatio||g.mozBackingStorePixelRatio||g.msBackingStorePixelRatio||g.oBackingStorePixelRatio||g.backingStorePixelRatio||1)),g.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var t,A,e,C,I=this.colorPickerCanvas.clientWidth,i=this.colorPickerCanvas.clientHeight;g.clearRect(0,0,I,i),this.centerCoordinates={x:.5*I,y:.5*i},this.r=.49*I;var o,n=2*Math.PI/360,r=1/this.r;for(e=0;e<360;e++)for(C=0;C3&&void 0!==arguments[3]?arguments[3]:1,I=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){return!1};cn(this,g),this.parent=t,this.changedOptions=[],this.container=A,this.allowCreation=!1,this.hideOption=I,this.options={},this.initialized=!1,this.popupCounter=0,this.defaultOptions={enabled:!1,filter:!0,container:void 0,showButton:!0},fe(this.options,this.defaultOptions),this.configureOptions=e,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new uv(C),this.wrapper=void 0}return kd(g,[{key:"setOptions",value:function(g){if(void 0!==g){this.popupHistory={},this._removePopup();var t=!0;if("string"==typeof g)this.options.filter=g;else if(Rh(g))this.options.filter=g.join();else if("object"===yd(g)){if(null==g)throw new TypeError("options cannot be null");void 0!==g.container&&(this.options.container=g.container),void 0!==pc(g)&&(this.options.filter=pc(g)),void 0!==g.showButton&&(this.options.showButton=g.showButton),void 0!==g.enabled&&(t=g.enabled)}else"boolean"==typeof g?(this.options.filter=!0,t=g):"function"==typeof g&&(this.options.filter=g,t=!0);!1===pc(this.options)&&(t=!1),this.options.enabled=t}this._clean()}},{key:"setModuleOptions",value:function(g){this.moduleOptions=g,!0===this.options.enabled&&(this._clean(),void 0!==this.options.container&&(this.container=this.options.container),this._create())}},{key:"_create",value:function(){this._clean(),this.changedOptions=[];var g=pc(this.options),t=0,A=!1;for(var e in this.configureOptions)Object.prototype.hasOwnProperty.call(this.configureOptions,e)&&(this.allowCreation=!1,A=!1,"function"==typeof g?A=(A=g(e,[]))||this._handleObject(this.configureOptions[e],[e],!0):!0!==g&&-1===Xc(g).call(g,e)||(A=!0),!1!==A&&(this.allowCreation=!0,t>0&&this._makeItem([]),this._makeHeader(e),this._handleObject(this.configureOptions[e],[e])),t++);this._makeButton(),this._push()}},{key:"_push",value:function(){this.wrapper=document.createElement("div"),this.wrapper.className="vis-configuration-wrapper",this.container.appendChild(this.wrapper);for(var g=0;g1?A-1:0),C=1;C2&&void 0!==arguments[2]&&arguments[2],e=document.createElement("div");if(e.className="vis-configuration vis-config-label vis-config-s"+t.length,!0===A){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(pv("i","b",g))}else e.innerText=g+":";return e}},{key:"_makeDropdown",value:function(g,t,A){var e=document.createElement("select");e.className="vis-configuration vis-config-select";var C=0;void 0!==t&&-1!==Xc(g).call(g,t)&&(C=Xc(g).call(g,t));for(var I=0;II&&1!==I&&(o.max=Math.ceil(t*s),r=o.max,n="range increased"),o.value=t}else o.value=e;var a=document.createElement("input");a.className="vis-configuration vis-config-rangeinput",a.value=o.value;var d=this;o.onchange=function(){a.value=this.value,d._update(Number(this.value),A)},o.oninput=function(){a.value=this.value};var h=this._makeLabel(A[A.length-1],A),l=this._makeItem(A,h,o,a);""!==n&&this.popupHistory[l]!==r&&(this.popupHistory[l]=r,this._setupPopup(n,l))}},{key:"_makeButton",value:function(){var g=this;if(!0===this.options.showButton){var t=document.createElement("div");t.className="vis-configuration vis-config-button",t.innerText="generate options",t.onclick=function(){g._printOptions()},t.onmouseover=function(){t.className="vis-configuration vis-config-button hover"},t.onmouseout=function(){t.className="vis-configuration vis-config-button"},this.optionsContainer=document.createElement("div"),this.optionsContainer.className="vis-configuration vis-config-option-container",this.domElements.push(this.optionsContainer),this.domElements.push(t)}}},{key:"_setupPopup",value:function(g,t){var A=this;if(!0===this.initialized&&!0===this.allowCreation&&this.popupCounter1&&void 0!==arguments[1]?arguments[1]:[],A=arguments.length>2&&void 0!==arguments[2]&&arguments[2],e=!1,C=pc(this.options),I=!1;for(var i in g)if(Object.prototype.hasOwnProperty.call(g,i)){e=!0;var o=g[i],n=$f(t,i);if("function"==typeof C&&!1===(e=C(i,t))&&!Rh(o)&&"string"!=typeof o&&"boolean"!=typeof o&&o instanceof Object&&(this.allowCreation=!1,e=this._handleObject(o,n,!0),this.allowCreation=!1===A),!1!==e){I=!0;var r=this._getValue(n);if(Rh(o))this._handleArray(o,r,n);else if("string"==typeof o)this._makeTextInput(o,r,n);else if("boolean"==typeof o)this._makeCheckbox(o,r,n);else if(o instanceof Object){if(!this.hideOption(t,i,this.moduleOptions))if(void 0!==o.enabled){var s=$f(n,"enabled"),a=this._getValue(s);if(!0===a){var d=this._makeLabel(i,n,!0);this._makeItem(n,d),I=this._handleObject(o,n)||I}else this._makeCheckbox(o,a,n)}else{var h=this._makeLabel(i,n,!0);this._makeItem(n,h),I=this._handleObject(o,n)||I}}else console.error("dont know how to handle",o,i,n)}}return I}},{key:"_handleArray",value:function(g,t,A){"string"==typeof g[0]&&"color"===g[0]?(this._makeColorField(g,t,A),g[1]!==t&&this.changedOptions.push({path:A,value:t})):"string"==typeof g[0]?(this._makeDropdown(g,t,A),g[0]!==t&&this.changedOptions.push({path:A,value:t})):"number"==typeof g[0]&&(this._makeRange(g,t,A),g[0]!==t&&this.changedOptions.push({path:A,value:Number(t)}))}},{key:"_update",value:function(g,t){var A=this._constructOptions(g,t);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",A),this.initialized=!0,this.parent.setOptions(A)}},{key:"_constructOptions",value:function(g,t){var A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=A;g="false"!==(g="true"===g||g)&&g;for(var C=0;CC-this.padding&&(o=!0),I=o?this.x-A:this.x,i=n?this.y-t:this.y}else(i=this.y-t)+t+this.padding>e&&(i=e-t-this.padding),iC&&(I=C-A-this.padding),Ii.distance?" in "+g.printLocation(I.path,t,"")+"Perhaps it was misplaced? Matching option found at: "+g.printLocation(i.path,i.closestMatch,""):I.distance<=8?'. Did you mean "'+I.closestMatch+'"?'+g.printLocation(I.path,t):". Did you mean one of these: "+g.print(Lh(A))+g.printLocation(e,t),console.error('%cUnknown option detected: "'+t+'"'+C,bv),mv=!0}},{key:"findInOptions",value:function(t,A,e){var C,I=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=1e9,o="",n=[],r=t.toLowerCase(),s=void 0;for(var a in A){var d=void 0;if(void 0!==A[a].__type__&&!0===I){var h=g.findInOptions(t,A[a],$f(e,a));i>h.distance&&(o=h.closestMatch,n=h.path,i=h.distance,s=h.indexMatch)}else{var l;-1!==Xc(l=a.toLowerCase()).call(l,r)&&(s=a),i>(d=g.levenshteinDistance(t,a))&&(o=a,n=wh(C=e).call(C),i=d)}}return{closestMatch:o,path:n,distance:i,indexMatch:s}}},{key:"printLocation",value:function(g,t){for(var A="\n\n"+(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Problem value found at: \n")+"options = {\n",e=0;e":!0,"--":!0},zv="",Sv=0,Zv="",Fv="",Gv=Mv.NULL;function jv(){Sv++,Zv=zv.charAt(Sv)}function Lv(){return zv.charAt(Sv+1)}function Vv(g){var t=g.charCodeAt(0);return t<47?35===t||46===t:t<59?t>47:t<91?t>64:t<96?95===t:t<123&&t>96}function Yv(g,t){if(g||(g={}),t)for(var A in t)t.hasOwnProperty(A)&&(g[A]=t[A]);return g}function Wv(g,t,A){for(var e=t.split("."),C=g;e.length;){var I=e.shift();e.length?(C[I]||(C[I]={}),C=C[I]):C[I]=A}}function Qv(g,t){for(var A,e,C=null,I=[g],i=g;i.parent;)I.push(i.parent),i=i.parent;if(i.nodes)for(A=0,e=i.nodes.length;A=0;A--){var o,n=I[A];n.nodes||(n.nodes=[]),-1===Xc(o=n.nodes).call(o,C)&&n.nodes.push(C)}t.attr&&(C.attr=Yv(C.attr,t.attr))}function Uv(g,t){if(g.edges||(g.edges=[]),g.edges.push(t),g.edge){var A=Yv({},g.edge);t.attr=Yv(A,t.attr)}}function _v(g,t,A,e,C){var I={from:t,to:A,type:e};return g.edge&&(I.attr=Yv({},g.edge)),I.attr=Yv(I.attr||{},C),null!=C&&C.hasOwnProperty("arrows")&&null!=C.arrows&&(I.arrows={to:{enabled:!0,type:C.arrows.type}},C.arrows=null),I}function Kv(){for(Gv=Mv.NULL,Fv="";" "===Zv||"\t"===Zv||"\n"===Zv||"\r"===Zv;)jv();do{var g=!1;if("#"===Zv){for(var t=Sv-1;" "===zv.charAt(t)||"\t"===zv.charAt(t);)t--;if("\n"===zv.charAt(t)||""===zv.charAt(t)){for(;""!=Zv&&"\n"!=Zv;)jv();g=!0}}if("/"===Zv&&"/"===Lv()){for(;""!=Zv&&"\n"!=Zv;)jv();g=!0}if("/"===Zv&&"*"===Lv()){for(;""!=Zv;){if("*"===Zv&&"/"===Lv()){jv(),jv();break}jv()}g=!0}for(;" "===Zv||"\t"===Zv||"\n"===Zv||"\r"===Zv;)jv()}while(g);if(""!==Zv){var A=Zv+Lv();if(Bv[A])return Gv=Mv.DELIMITER,Fv=A,jv(),void jv();if(Bv[Zv])return Gv=Mv.DELIMITER,Fv=Zv,void jv();if(Vv(Zv)||"-"===Zv){for(Fv+=Zv,jv();Vv(Zv);)Fv+=Zv,jv();return"false"===Fv?Fv=!1:"true"===Fv?Fv=!0:isNaN(Number(Fv))||(Fv=Number(Fv)),void(Gv=Mv.IDENTIFIER)}if('"'===Zv){for(jv();""!=Zv&&('"'!=Zv||'"'===Zv&&'"'===Lv());)'"'===Zv?(Fv+=Zv,jv()):"\\"===Zv&&"n"===Lv()?(Fv+="\n",jv()):Fv+=Zv,jv();if('"'!=Zv)throw gy('End of string " expected');return jv(),void(Gv=Mv.IDENTIFIER)}for(Gv=Mv.UNKNOWN;""!=Zv;)Fv+=Zv,jv();throw new SyntaxError('Syntax error in part "'+ty(Fv,30)+'"')}Gv=Mv.DELIMITER}function Hv(g){for(;""!==Fv&&"}"!=Fv;)Xv(g),";"===Fv&&Kv()}function Xv(g){var t=Jv(g);if(t)qv(g,t);else{var A=function(g){if("node"===Fv)return Kv(),g.node=$v(),"node";if("edge"===Fv)return Kv(),g.edge=$v(),"edge";if("graph"===Fv)return Kv(),g.graph=$v(),"graph";return null}(g);if(!A){if(Gv!=Mv.IDENTIFIER)throw gy("Identifier expected");var e=Fv;if(Kv(),"="===Fv){if(Kv(),Gv!=Mv.IDENTIFIER)throw gy("Identifier expected");g[e]=Fv,Kv()}else!function(g,t){var A={id:t},e=$v();e&&(A.attr=e);Qv(g,A),qv(g,t)}(g,e)}}}function Jv(g){var t=null;if("subgraph"===Fv&&((t={}).type="subgraph",Kv(),Gv===Mv.IDENTIFIER&&(t.id=Fv,Kv())),"{"===Fv){if(Kv(),t||(t={}),t.parent=g,t.node=g.node,t.edge=g.edge,t.graph=g.graph,Hv(t),"}"!=Fv)throw gy("Angle bracket } expected");Kv(),delete t.node,delete t.edge,delete t.graph,delete t.parent,g.subgraphs||(g.subgraphs=[]),g.subgraphs.push(t)}return t}function qv(g,t){for(;"->"===Fv||"--"===Fv;){var A,e=Fv;Kv();var C=Jv(g);if(C)A=C;else{if(Gv!=Mv.IDENTIFIER)throw gy("Identifier or subgraph expected");Qv(g,{id:A=Fv}),Kv()}Uv(g,_v(g,t,A,e,$v())),t=A}}function $v(){for(var g,t,A=null,e={dashed:!0,solid:!1,dotted:[1,5]},C={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},I=new Array,i=new Array;"["===Fv;){for(Kv(),A={};""!==Fv&&"]"!=Fv;){if(Gv!=Mv.IDENTIFIER)throw gy("Attribute name expected");var o=Fv;if(Kv(),"="!=Fv)throw gy("Equal sign = expected");if(Kv(),Gv!=Mv.IDENTIFIER)throw gy("Attribute value expected");var n=Fv;"style"===o&&(n=e[n]),"arrowhead"===o&&(o="arrows",n={to:{enabled:!0,type:C[n]}}),"arrowtail"===o&&(o="arrows",n={from:{enabled:!0,type:C[n]}}),I.push({attr:A,name:o,value:n}),i.push(o),Kv(),","==Fv&&Kv()}if("]"!=Fv)throw gy("Bracket ] expected");Kv()}if(Ic(i).call(i,"dir")){var r={arrows:{}};for(g=0;g"===g.type&&(t.arrows="to"),t};Cl(C=A.edges).call(C,(function(g){var t,A,C,i,o,n,r;(t=g.from instanceof Object?g.from.nodes:{id:g.from},A=g.to instanceof Object?g.to.nodes:{id:g.to},g.from instanceof Object&&g.from.edges)&&Cl(C=g.from.edges).call(C,(function(g){var t=I(g);e.edges.push(t)}));(o=A,n=function(t,A){var C=_v(e,t.id,A.id,g.type,g.attr),i=I(C);e.edges.push(i)},Rh(i=t)?Cl(i).call(i,(function(g){Rh(o)?Cl(o).call(o,(function(t){n(g,t)})):n(g,o)})):Rh(o)?Cl(o).call(o,(function(g){n(i,g)})):n(i,o),g.to instanceof Object&&g.to.edges)&&Cl(r=g.to.edges).call(r,(function(g){var t=I(g);e.edges.push(t)}))}))}return A.attr&&(e.options=A.attr),e}var Iy=Object.freeze({__proto__:null,DOTToGraph:Cy,parseDOT:Nv});function iy(g,t){var A,e={edges:{inheritColor:!1},nodes:{fixed:!1,parseColor:!1}};null!=t&&(null!=t.fixed&&(e.nodes.fixed=t.fixed),null!=t.parseColor&&(e.nodes.parseColor=t.parseColor),null!=t.inheritColor&&(e.edges.inheritColor=t.inheritColor));var C=g.edges,I=Fh(C).call(C,(function(g){var t={from:g.source,id:g.id,to:g.target};return null!=g.attributes&&(t.attributes=g.attributes),null!=g.label&&(t.label=g.label),null!=g.attributes&&null!=g.attributes.title&&(t.title=g.attributes.title),"Directed"===g.type&&(t.arrows="to"),g.color&&!1===e.edges.inheritColor&&(t.color=g.color),t}));return{nodes:Fh(A=g.nodes).call(A,(function(g){var t={id:g.id,fixed:e.nodes.fixed&&null!=g.x&&null!=g.y};return null!=g.attributes&&(t.attributes=g.attributes),null!=g.label&&(t.label=g.label),null!=g.size&&(t.size=g.size),null!=g.attributes&&null!=g.attributes.title&&(t.title=g.attributes.title),null!=g.title&&(t.title=g.title),null!=g.x&&(t.x=g.x),null!=g.y&&(t.y=g.y),null!=g.color&&(!0===e.nodes.parseColor?t.color=g.color:t.color={background:g.color,border:g.color,highlight:{background:g.color,border:g.color},hover:{background:g.color,border:g.color}}),t})),edges:I}}var oy=Object.freeze({__proto__:null,parseGephi:iy}),ny=Object.freeze({__proto__:null,cn:{addDescription:"单击空白处放置新节点。",addEdge:"添加连接线",addNode:"添加节点",back:"返回",close:"關閉",createEdgeError:"无法将连接线连接到群集。",del:"删除选定",deleteClusterError:"无法删除群集。",edgeDescription:"单击某个节点并将该连接线拖动到另一个节点以连接它们。",edit:"编辑",editClusterError:"无法编辑群集。",editEdge:"编辑连接线",editEdgeDescription:"单击控制节点并将它们拖到节点上连接。",editNode:"编辑节点"},cs:{addDescription:"Kluknutím do prázdného prostoru můžete přidat nový vrchol.",addEdge:"Přidat hranu",addNode:"Přidat vrchol",back:"Zpět",close:"Zavřít",createEdgeError:"Nelze připojit hranu ke shluku.",del:"Smazat výběr",deleteClusterError:"Nelze mazat shluky.",edgeDescription:"Přetažením z jednoho vrcholu do druhého můžete spojit tyto vrcholy novou hranou.",edit:"Upravit",editClusterError:"Nelze upravovat shluky.",editEdge:"Upravit hranu",editEdgeDescription:"Přetažením kontrolního vrcholu hrany ji můžete připojit k jinému vrcholu.",editNode:"Upravit vrchol"},de:{addDescription:"Klicke auf eine freie Stelle, um einen neuen Knoten zu plazieren.",addEdge:"Kante hinzufügen",addNode:"Knoten hinzufügen",back:"Zurück",close:"Schließen",createEdgeError:"Es ist nicht möglich, Kanten mit Clustern zu verbinden.",del:"Lösche Auswahl",deleteClusterError:"Cluster können nicht gelöscht werden.",edgeDescription:"Klicke auf einen Knoten und ziehe die Kante zu einem anderen Knoten, um diese zu verbinden.",edit:"Editieren",editClusterError:"Cluster können nicht editiert werden.",editEdge:"Kante editieren",editEdgeDescription:"Klicke auf die Verbindungspunkte und ziehe diese auf einen Knoten, um sie zu verbinden.",editNode:"Knoten editieren"},en:{addDescription:"Click in an empty space to place a new node.",addEdge:"Add Edge",addNode:"Add Node",back:"Back",close:"Close",createEdgeError:"Cannot link edges to a cluster.",del:"Delete selected",deleteClusterError:"Clusters cannot be deleted.",edgeDescription:"Click on a node and drag the edge to another node to connect them.",edit:"Edit",editClusterError:"Clusters cannot be edited.",editEdge:"Edit Edge",editEdgeDescription:"Click on the control points and drag them to a node to connect to it.",editNode:"Edit Node"},es:{addDescription:"Haga clic en un lugar vacío para colocar un nuevo nodo.",addEdge:"Añadir arista",addNode:"Añadir nodo",back:"Atrás",close:"Cerrar",createEdgeError:"No se puede conectar una arista a un grupo.",del:"Eliminar selección",deleteClusterError:"No es posible eliminar grupos.",edgeDescription:"Haga clic en un nodo y arrastre la arista hacia otro nodo para conectarlos.",edit:"Editar",editClusterError:"No es posible editar grupos.",editEdge:"Editar arista",editEdgeDescription:"Haga clic en un punto de control y arrastrelo a un nodo para conectarlo.",editNode:"Editar nodo"},fr:{addDescription:"Cliquez dans un endroit vide pour placer un nœud.",addEdge:"Ajouter un lien",addNode:"Ajouter un nœud",back:"Retour",close:"Fermer",createEdgeError:"Impossible de créer un lien vers un cluster.",del:"Effacer la sélection",deleteClusterError:"Les clusters ne peuvent pas être effacés.",edgeDescription:"Cliquez sur un nœud et glissez le lien vers un autre nœud pour les connecter.",edit:"Éditer",editClusterError:"Les clusters ne peuvent pas être édités.",editEdge:"Éditer le lien",editEdgeDescription:"Cliquez sur les points de contrôle et glissez-les pour connecter un nœud.",editNode:"Éditer le nœud"},it:{addDescription:"Clicca per aggiungere un nuovo nodo",addEdge:"Aggiungi un vertice",addNode:"Aggiungi un nodo",back:"Indietro",close:"Chiudere",createEdgeError:"Non si possono collegare vertici ad un cluster",del:"Cancella la selezione",deleteClusterError:"I cluster non possono essere cancellati",edgeDescription:"Clicca su un nodo e trascinalo ad un altro nodo per connetterli.",edit:"Modifica",editClusterError:"I clusters non possono essere modificati.",editEdge:"Modifica il vertice",editEdgeDescription:"Clicca sui Punti di controllo e trascinali ad un nodo per connetterli.",editNode:"Modifica il nodo"},nl:{addDescription:"Klik op een leeg gebied om een nieuwe node te maken.",addEdge:"Link toevoegen",addNode:"Node toevoegen",back:"Terug",close:"Sluiten",createEdgeError:"Kan geen link maken naar een cluster.",del:"Selectie verwijderen",deleteClusterError:"Clusters kunnen niet worden verwijderd.",edgeDescription:"Klik op een node en sleep de link naar een andere node om ze te verbinden.",edit:"Wijzigen",editClusterError:"Clusters kunnen niet worden aangepast.",editEdge:"Link wijzigen",editEdgeDescription:"Klik op de verbindingspunten en sleep ze naar een node om daarmee te verbinden.",editNode:"Node wijzigen"},pt:{addDescription:"Clique em um espaço em branco para adicionar um novo nó",addEdge:"Adicionar aresta",addNode:"Adicionar nó",back:"Voltar",close:"Fechar",createEdgeError:"Não foi possível linkar arestas a um cluster.",del:"Remover selecionado",deleteClusterError:"Clusters não puderam ser removidos.",edgeDescription:"Clique em um nó e arraste a aresta até outro nó para conectá-los",edit:"Editar",editClusterError:"Clusters não puderam ser editados.",editEdge:"Editar aresta",editEdgeDescription:"Clique nos pontos de controle e os arraste para um nó para conectá-los",editNode:"Editar nó"},ru:{addDescription:"Кликните в свободное место, чтобы добавить новый узел.",addEdge:"Добавить ребро",addNode:"Добавить узел",back:"Назад",close:"Закрывать",createEdgeError:"Невозможно соединить ребра в кластер.",del:"Удалить выбранное",deleteClusterError:"Кластеры не могут быть удалены",edgeDescription:"Кликните на узел и протяните ребро к другому узлу, чтобы соединить их.",edit:"Редактировать",editClusterError:"Кластеры недоступны для редактирования.",editEdge:"Редактировать ребро",editEdgeDescription:"Кликните на контрольные точки и перетащите их в узел, чтобы подключиться к нему.",editNode:"Редактировать узел"},uk:{addDescription:"Kлікніть на вільне місце, щоб додати новий вузол.",addEdge:"Додати край",addNode:"Додати вузол",back:"Назад",close:"Закрити",createEdgeError:"Не можливо об'єднати краї в групу.",del:"Видалити обране",deleteClusterError:"Групи не можуть бути видалені.",edgeDescription:"Клікніть на вузол і перетягніть край до іншого вузла, щоб їх з'єднати.",edit:"Редагувати",editClusterError:"Групи недоступні для редагування.",editEdge:"Редагувати край",editEdgeDescription:"Клікніть на контрольні точки і перетягніть їх у вузол, щоб підключитися до нього.",editNode:"Редагувати вузол"}});var ry=function(){function g(){cn(this,g),this.NUM_ITERATIONS=4,this.image=new Image,this.canvas=document.createElement("canvas")}return kd(g,[{key:"init",value:function(){if(!this.initialized()){this.src=this.image.src;var g=this.image.width,t=this.image.height;this.width=g,this.height=t;var A=Math.floor(t/2),e=Math.floor(t/4),C=Math.floor(t/8),I=Math.floor(t/16),i=Math.floor(g/2),o=Math.floor(g/4),n=Math.floor(g/8),r=Math.floor(g/16);this.canvas.width=3*o,this.canvas.height=A,this.coordinates=[[0,0,i,A],[i,0,o,e],[i,e,n,C],[5*n,e,r,I]],this._fillMipMap()}}},{key:"initialized",value:function(){return void 0!==this.coordinates}},{key:"_fillMipMap",value:function(){var g=this.canvas.getContext("2d"),t=this.coordinates[0];g.drawImage(this.image,t[0],t[1],t[2],t[3]);for(var A=1;A2){t*=.5;for(var i=0;t>2&&i=this.NUM_ITERATIONS&&(i=this.NUM_ITERATIONS-1);var o=this.coordinates[i];g.drawImage(this.canvas,o[0],o[1],o[2],o[3],A,e,C,I)}else g.drawImage(this.image,A,e,C,I)}}]),g}(),sy=function(){function g(t){cn(this,g),this.images={},this.imageBroken={},this.callback=t}return kd(g,[{key:"_tryloadBrokenUrl",value:function(g,t,A){void 0!==g&&void 0!==A&&(void 0!==t?(A.image.onerror=function(){console.error("Could not load brokenImage:",t)},A.image.src=t):console.warn("No broken url image defined"))}},{key:"_redrawWithImage",value:function(g){this.callback&&this.callback(g)}},{key:"load",value:function(g,t){var A=this,e=this.images[g];if(e)return e;var C=new ry;return this.images[g]=C,C.image.onload=function(){A._fixImageCoordinates(C.image),C.init(),A._redrawWithImage(C)},C.image.onerror=function(){console.error("Could not load image:",g),A._tryloadBrokenUrl(g,t,C)},C.image.src=g,C}},{key:"_fixImageCoordinates",value:function(g){0===g.width&&(document.body.appendChild(g),g.width=g.offsetWidth,g.height=g.offsetHeight,document.body.removeChild(g))}}]),g}(),ay={exports:{}},dy=I((function(){if("function"==typeof ArrayBuffer){var g=new ArrayBuffer(8);Object.isExtensible(g)&&Object.defineProperty(g,"a",{value:8})}})),hy=I,ly=gg,cy=y,uy=dy,py=Object.isExtensible,fy=hy((function(){py(1)}))||uy?function(g){return!!ly(g)&&((!uy||"ArrayBuffer"!==cy(g))&&(!py||py(g)))}:py,vy=!I((function(){return Object.isExtensible(Object.preventExtensions({}))})),yy=TA,my=u,by=UA,wy=gg,ky=qg,xy=Jt.f,Ey=gr,Oy=er,Ty=fy,Dy=vy,Ny=!1,Ry=et("meta"),Py=0,My=function(g){xy(g,Ry,{value:{objectID:"O"+Py++,weakData:{}}})},By=ay.exports={enable:function(){By.enable=function(){},Ny=!0;var g=Ey.f,t=my([].splice),A={};A[Ry]=1,g(A).length&&(Ey.f=function(A){for(var e=g(A),C=0,I=e.length;CI;I++)if((o=p(g[I]))&&Vy(Ky,o))return o;return new _y(!1)}e=Yy(g,C)}for(n=d?g.next:e.next;!(r=Zy(n,e)).done;){try{o=p(r.value)}catch(g){Qy(e,"throw",g)}if("object"==typeof o&&o&&Vy(Ky,o))return o}return new _y(!1)},Xy=og,Jy=TypeError,qy=function(g,t){if(Xy(t,g))return g;throw new Jy("Incorrect invocation")},$y=TA,gm=C,tm=zy,Am=I,em=uA,Cm=Hy,Im=qy,im=O,om=gg,nm=Q,rm=_I,sm=Jt.f,am=Sr.forEach,dm=D,hm=GC.set,lm=GC.getterFor,cm=function(g,t,A){var e,C=-1!==g.indexOf("Map"),I=-1!==g.indexOf("Weak"),i=C?"set":"add",o=gm[g],n=o&&o.prototype,r={};if(dm&&im(o)&&(I||n.forEach&&!Am((function(){(new o).entries().next()})))){var s=(e=t((function(t,A){hm(Im(t,s),{type:g,collection:new o}),nm(A)||Cm(A,t[i],{that:t,AS_ENTRIES:C})}))).prototype,a=lm(g);am(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(g){var t="add"===g||"set"===g;!(g in n)||I&&"clear"===g||em(s,g,(function(A,e){var C=a(this).collection;if(!t&&I&&!om(A))return"get"===g&&void 0;var i=C[g](0===A?0:A,e);return t?this:i}))})),I||sm(s,"size",{configurable:!0,get:function(){return a(this).collection.size}})}else e=A.getConstructor(t,g,C,i),tm.enable();return rm(e,g,!1,!0),r[g]=e,$y({global:!0,forced:!0},r),I||A.setStrong(e,g,C),e},um=TI,pm=function(g,t,A){for(var e in t)A&&A.unsafe&&g[e]?g[e]=t[e]:um(g,e,t[e],A);return g},fm=ig,vm=ur,ym=D,mm=dt("species"),bm=function(g){var t=fm(g);ym&&t&&!t[mm]&&vm(t,mm,{configurable:!0,get:function(){return this}})},wm=pI,km=ur,xm=pm,Em=Xt,Om=qy,Tm=Q,Dm=Hy,Nm=Ei,Rm=Oi,Pm=bm,Mm=D,Bm=zy.fastKey,zm=GC.set,Sm=GC.getterFor,Zm={getConstructor:function(g,t,A,e){var C=g((function(g,C){Om(g,I),zm(g,{type:t,index:wm(null),first:void 0,last:void 0,size:0}),Mm||(g.size=0),Tm(C)||Dm(C,g[e],{that:g,AS_ENTRIES:A})})),I=C.prototype,i=Sm(t),o=function(g,t,A){var e,C,I=i(g),o=n(g,t);return o?o.value=A:(I.last=o={index:C=Bm(t,!0),key:t,value:A,previous:e=I.last,next:void 0,removed:!1},I.first||(I.first=o),e&&(e.next=o),Mm?I.size++:g.size++,"F"!==C&&(I.index[C]=o)),g},n=function(g,t){var A,e=i(g),C=Bm(t);if("F"!==C)return e.index[C];for(A=e.first;A;A=A.next)if(A.key===t)return A};return xm(I,{clear:function(){for(var g=i(this),t=g.index,A=g.first;A;)A.removed=!0,A.previous&&(A.previous=A.previous.next=void 0),delete t[A.index],A=A.next;g.first=g.last=void 0,Mm?g.size=0:this.size=0},delete:function(g){var t=this,A=i(t),e=n(t,g);if(e){var C=e.next,I=e.previous;delete A.index[e.index],e.removed=!0,I&&(I.next=C),C&&(C.previous=I),A.first===e&&(A.first=C),A.last===e&&(A.last=I),Mm?A.size--:t.size--}return!!e},forEach:function(g){for(var t,A=i(this),e=Em(g,arguments.length>1?arguments[1]:void 0);t=t?t.next:A.first;)for(e(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(g){return!!n(this,g)}}),xm(I,A?{get:function(g){var t=n(this,g);return t&&t.value},set:function(g,t){return o(this,0===g?0:g,t)}}:{add:function(g){return o(this,g=0===g?0:g,g)}}),Mm&&km(I,"size",{configurable:!0,get:function(){return i(this).size}}),C},setStrong:function(g,t,A){var e=t+" Iterator",C=Sm(t),I=Sm(e);Nm(g,t,(function(g,t){zm(this,{type:e,target:g,state:C(g),kind:t,last:void 0})}),(function(){for(var g=I(this),t=g.kind,A=g.last;A&&A.removed;)A=A.previous;return g.target&&(g.last=A=A?A.next:g.state.first)?Rm("keys"===t?A.key:"values"===t?A.value:[A.key,A.value],!1):(g.target=void 0,Rm(void 0,!0))}),A?"entries":"values",!A,!0),Pm(t)}};cm("Map",(function(g){return function(){return g(this,arguments.length?arguments[0]:void 0)}}),Zm);var Fm=A(tg.Map),Gm=function(){function g(){cn(this,g),this.clear(),this._defaultIndex=0,this._groupIndex=0,this._defaultGroups=[{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},{border:"#FFA500",background:"#FFFF00",highlight:{border:"#FFA500",background:"#FFFFA3"},hover:{border:"#FFA500",background:"#FFFFA3"}},{border:"#FA0A10",background:"#FB7E81",highlight:{border:"#FA0A10",background:"#FFAFB1"},hover:{border:"#FA0A10",background:"#FFAFB1"}},{border:"#41A906",background:"#7BE141",highlight:{border:"#41A906",background:"#A1EC76"},hover:{border:"#41A906",background:"#A1EC76"}},{border:"#E129F0",background:"#EB7DF4",highlight:{border:"#E129F0",background:"#F0B3F5"},hover:{border:"#E129F0",background:"#F0B3F5"}},{border:"#7C29F0",background:"#AD85E4",highlight:{border:"#7C29F0",background:"#D3BDF0"},hover:{border:"#7C29F0",background:"#D3BDF0"}},{border:"#C37F00",background:"#FFA807",highlight:{border:"#C37F00",background:"#FFCA66"},hover:{border:"#C37F00",background:"#FFCA66"}},{border:"#4220FB",background:"#6E6EFD",highlight:{border:"#4220FB",background:"#9B9BFD"},hover:{border:"#4220FB",background:"#9B9BFD"}},{border:"#FD5A77",background:"#FFC0CB",highlight:{border:"#FD5A77",background:"#FFD1D9"},hover:{border:"#FD5A77",background:"#FFD1D9"}},{border:"#4AD63A",background:"#C2FABC",highlight:{border:"#4AD63A",background:"#E6FFE3"},hover:{border:"#4AD63A",background:"#E6FFE3"}},{border:"#990000",background:"#EE0000",highlight:{border:"#BB0000",background:"#FF3333"},hover:{border:"#BB0000",background:"#FF3333"}},{border:"#FF6000",background:"#FF6000",highlight:{border:"#FF6000",background:"#FF6000"},hover:{border:"#FF6000",background:"#FF6000"}},{border:"#97C2FC",background:"#2B7CE9",highlight:{border:"#D2E5FF",background:"#2B7CE9"},hover:{border:"#D2E5FF",background:"#2B7CE9"}},{border:"#399605",background:"#255C03",highlight:{border:"#399605",background:"#255C03"},hover:{border:"#399605",background:"#255C03"}},{border:"#B70054",background:"#FF007E",highlight:{border:"#B70054",background:"#FF007E"},hover:{border:"#B70054",background:"#FF007E"}},{border:"#AD85E4",background:"#7C29F0",highlight:{border:"#D3BDF0",background:"#7C29F0"},hover:{border:"#D3BDF0",background:"#7C29F0"}},{border:"#4557FA",background:"#000EA1",highlight:{border:"#6E6EFD",background:"#000EA1"},hover:{border:"#6E6EFD",background:"#000EA1"}},{border:"#FFC0CB",background:"#FD5A77",highlight:{border:"#FFD1D9",background:"#FD5A77"},hover:{border:"#FFD1D9",background:"#FD5A77"}},{border:"#C2FABC",background:"#74D66A",highlight:{border:"#E6FFE3",background:"#74D66A"},hover:{border:"#E6FFE3",background:"#74D66A"}},{border:"#EE0000",background:"#990000",highlight:{border:"#FF3333",background:"#BB0000"},hover:{border:"#FF3333",background:"#BB0000"}}],this.options={},this.defaultOptions={useDefaultGroups:!0},fe(this.options,this.defaultOptions)}return kd(g,[{key:"setOptions",value:function(g){var t=["useDefaultGroups"];if(void 0!==g)for(var A in g)if(Object.prototype.hasOwnProperty.call(g,A)&&-1===Xc(t).call(t,A)){var e=g[A];this.add(A,e)}}},{key:"clear",value:function(){this._groups=new Fm,this._groupNames=[]}},{key:"get",value:function(g){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],A=this._groups.get(g);if(void 0===A&&t)if(!1===this.options.useDefaultGroups&&this._groupNames.length>0){var e=this._groupIndex%this._groupNames.length;++this._groupIndex,(A={}).color=this._groups.get(this._groupNames[e]),this._groups.set(g,A)}else{var C=this._defaultIndex%this._defaultGroups.length;this._defaultIndex++,(A={}).color=this._defaultGroups[C],this._groups.set(g,A)}return A}},{key:"add",value:function(g,t){return this._groups.has(g)||this._groupNames.push(g),this._groups.set(g,t),t}}]),g}();TA({target:"Number",stat:!0},{isNaN:function(g){return g!=g}});var jm=A(tg.Number.isNaN),Lm=C.isFinite,Vm=Number.isFinite||function(g){return"number"==typeof g&&Lm(g)};TA({target:"Number",stat:!0},{isFinite:Vm});var Ym=A(tg.Number.isFinite),Wm=Sr.some;TA({target:"Array",proto:!0,forced:!_h("some")},{some:function(g){return Wm(this,g,arguments.length>1?arguments[1]:void 0)}});var Qm=Me("Array").some,Um=og,_m=Qm,Km=Array.prototype,Hm=function(g){var t=g.some;return g===Km||Um(Km,g)&&t===Km.some?_m:t},Xm=A(Hm);function Jm(g){if(void 0===g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}var qm=qc,$m=A(qm);TA({target:"Object",stat:!0},{setPrototypeOf:ri});var gb=tg.Object.setPrototypeOf,tb=A(gb),Ab=A(Ge);function eb(g,t){var A;return eb=tb?Ab(A=tb).call(A):function(g,t){return g.__proto__=t,g},eb(g,t)}function Cb(g,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");g.prototype=$m(t&&t.prototype,{constructor:{value:g,writable:!0,configurable:!0}}),kn(g,"prototype",{writable:!1}),t&&eb(g,t)}function Ib(g,t){if(t&&("object"===yd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Jm(g)}var ib=rc,ob=A(ib);function nb(g){var t;return nb=tb?Ab(t=ob).call(t):function(g){return g.__proto__||ob(g)},nb(g)}function rb(g,t,A){return(t=bd(t))in g?kn(g,t,{value:A,enumerable:!0,configurable:!0,writable:!0}):g[t]=A,g}var sb={exports:{}},ab={exports:{}};!function(g){var t=cd,A=fd;function e(C){return g.exports=e="function"==typeof t&&"symbol"==typeof A?function(g){return typeof g}:function(g){return g&&"function"==typeof t&&g.constructor===t&&g!==t.prototype?"symbol":typeof g},g.exports.__esModule=!0,g.exports.default=g.exports,e(C)}g.exports=e,g.exports.__esModule=!0,g.exports.default=g.exports}(ab);var db=ab.exports,hb=el,lb=qg,cb=Dh,ub=T,pb=Jt,fb=gg,vb=uA,yb=Error,mb=u("".replace),bb=String(new yb("zxcasd").stack),wb=/\n\s*at [^:]*:[^\n]*/,kb=wb.test(bb),xb=G,Eb=!I((function(){var g=new Error("a");return!("stack"in g)||(Object.defineProperty(g,"stack",xb(1,7)),7!==g.stack)})),Ob=uA,Tb=function(g,t){if(kb&&"string"==typeof g&&!yb.prepareStackTrace)for(;t--;)g=mb(g,wb,"");return g},Db=Eb,Nb=Error.captureStackTrace,Rb=sC,Pb=TA,Mb=og,Bb=EI,zb=ri,Sb=function(g,t,A){for(var e=cb(t),C=pb.f,I=ub.f,i=0;i2&&jb(A,arguments[2]);var C=[];return Vb(g,Ub,{that:C}),Fb(A,"errors",C),A};zb?zb(_b,Qb):Sb(_b,Qb,{name:!0});var Kb=_b.prototype=Zb(Qb.prototype,{constructor:Gb(1,_b),message:Gb(1,""),name:Gb(1,"AggregateError")});Pb({global:!0,constructor:!0,arity:2},{AggregateError:_b});var Hb,Xb,Jb,qb,$b="process"===y(C.process),gw=ro,tw=Og,Aw=TypeError,ew=function(g){if(gw(g))return g;throw new Aw(tw(g)+" is not a constructor")},Cw=AA,Iw=ew,iw=Q,ow=dt("species"),nw=function(g,t){var A,e=Cw(g).constructor;return void 0===e||iw(A=Cw(e)[ow])?t:Iw(A)},rw=/(?:ipad|iphone|ipod).*applewebkit/i.test(ng),sw=C,aw=a,dw=Xt,hw=O,lw=qg,cw=I,uw=gI,pw=ve,fw=Et,vw=iu,yw=rw,mw=$b,bw=sw.setImmediate,ww=sw.clearImmediate,kw=sw.process,xw=sw.Dispatch,Ew=sw.Function,Ow=sw.MessageChannel,Tw=sw.String,Dw=0,Nw={},Rw="onreadystatechange";cw((function(){Hb=sw.location}));var Pw=function(g){if(lw(Nw,g)){var t=Nw[g];delete Nw[g],t()}},Mw=function(g){return function(){Pw(g)}},Bw=function(g){Pw(g.data)},zw=function(g){sw.postMessage(Tw(g),Hb.protocol+"//"+Hb.host)};bw&&ww||(bw=function(g){vw(arguments.length,1);var t=hw(g)?g:Ew(g),A=pw(arguments,1);return Nw[++Dw]=function(){aw(t,void 0,A)},Xb(Dw),Dw},ww=function(g){delete Nw[g]},mw?Xb=function(g){kw.nextTick(Mw(g))}:xw&&xw.now?Xb=function(g){xw.now(Mw(g))}:Ow&&!yw?(qb=(Jb=new Ow).port2,Jb.port1.onmessage=Bw,Xb=dw(qb.postMessage,qb)):sw.addEventListener&&hw(sw.postMessage)&&!sw.importScripts&&Hb&&"file:"!==Hb.protocol&&!cw(zw)?(Xb=zw,sw.addEventListener("message",Bw,!1)):Xb=Rw in fw("script")?function(g){uw.appendChild(fw("script"))[Rw]=function(){uw.removeChild(this),Pw(g)}}:function(g){setTimeout(Mw(g),0)});var Sw={set:bw,clear:ww},Zw=function(){this.head=null,this.tail=null};Zw.prototype={add:function(g){var t={item:g,next:null},A=this.tail;A?A.next=t:this.head=t,this.tail=t},get:function(){var g=this.head;if(g)return null===(this.head=g.next)&&(this.tail=null),g.item}};var Fw,Gw,jw,Lw,Vw,Yw=Zw,Ww=/ipad|iphone|ipod/i.test(ng)&&"undefined"!=typeof Pebble,Qw=/web0s(?!.*chrome)/i.test(ng),Uw=C,_w=Xt,Kw=T.f,Hw=Sw.set,Xw=Yw,Jw=rw,qw=Ww,$w=Qw,gk=$b,tk=Uw.MutationObserver||Uw.WebKitMutationObserver,Ak=Uw.document,ek=Uw.process,Ck=Uw.Promise,Ik=Kw(Uw,"queueMicrotask"),ik=Ik&&Ik.value;if(!ik){var ok=new Xw,nk=function(){var g,t;for(gk&&(g=ek.domain)&&g.exit();t=ok.get();)try{t()}catch(g){throw ok.head&&Fw(),g}g&&g.enter()};Jw||gk||$w||!tk||!Ak?!qw&&Ck&&Ck.resolve?((Lw=Ck.resolve(void 0)).constructor=Ck,Vw=_w(Lw.then,Lw),Fw=function(){Vw(nk)}):gk?Fw=function(){ek.nextTick(nk)}:(Hw=_w(Hw,Uw),Fw=function(){Hw(nk)}):(Gw=!0,jw=Ak.createTextNode(""),new tk(nk).observe(jw,{characterData:!0}),Fw=function(){jw.data=Gw=!Gw}),ik=function(g){ok.head||Fw(),ok.add(g)}}var rk=ik,sk=function(g){try{return{error:!1,value:g()}}catch(g){return{error:!0,value:g}}},ak=C.Promise,dk="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,hk=!dk&&!$b&&"object"==typeof window&&"object"==typeof document,lk=C,ck=ak,uk=O,pk=Ut,fk=Hi,vk=dt,yk=hk,mk=dk,bk=cg,wk=ck&&ck.prototype,kk=vk("species"),xk=!1,Ek=uk(lk.PromiseRejectionEvent),Ok=pk("Promise",(function(){var g=fk(ck),t=g!==String(ck);if(!t&&66===bk)return!0;if(!wk.catch||!wk.finally)return!0;if(!bk||bk<51||!/native code/.test(g)){var A=new ck((function(g){g(1)})),e=function(g){g((function(){}),(function(){}))};if((A.constructor={})[kk]=e,!(xk=A.then((function(){}))instanceof e))return!0}return!t&&(yk||mk)&&!Ek})),Tk={CONSTRUCTOR:Ok,REJECTION_EVENT:Ek,SUBCLASSING:xk},Dk={},Nk=Rg,Rk=TypeError,Pk=function(g){var t,A;this.promise=new g((function(g,e){if(void 0!==t||void 0!==A)throw new Rk("Bad Promise constructor");t=g,A=e})),this.resolve=Nk(t),this.reject=Nk(A)};Dk.f=function(g){return new Pk(g)};var Mk,Bk,zk=TA,Sk=$b,Zk=C,Fk=P,Gk=TI,jk=_I,Lk=bm,Vk=Rg,Yk=O,Wk=gg,Qk=qy,Uk=nw,_k=Sw.set,Kk=rk,Hk=function(g,t){try{1===arguments.length?console.error(g):console.error(g,t)}catch(g){}},Xk=sk,Jk=Yw,qk=GC,$k=ak,gx=Tk,tx=Dk,Ax="Promise",ex=gx.CONSTRUCTOR,Cx=gx.REJECTION_EVENT,Ix=qk.getterFor(Ax),ix=qk.set,ox=$k&&$k.prototype,nx=$k,rx=ox,sx=Zk.TypeError,ax=Zk.document,dx=Zk.process,hx=tx.f,lx=hx,cx=!!(ax&&ax.createEvent&&Zk.dispatchEvent),ux="unhandledrejection",px=function(g){var t;return!(!Wk(g)||!Yk(t=g.then))&&t},fx=function(g,t){var A,e,C,I=t.value,i=1===t.state,o=i?g.ok:g.fail,n=g.resolve,r=g.reject,s=g.domain;try{o?(i||(2===t.rejection&&wx(t),t.rejection=1),!0===o?A=I:(s&&s.enter(),A=o(I),s&&(s.exit(),C=!0)),A===g.promise?r(new sx("Promise-chain cycle")):(e=px(A))?Fk(e,A,n,r):n(A)):r(I)}catch(g){s&&!C&&s.exit(),r(g)}},vx=function(g,t){g.notified||(g.notified=!0,Kk((function(){for(var A,e=g.reactions;A=e.get();)fx(A,g);g.notified=!1,t&&!g.rejection&&mx(g)})))},yx=function(g,t,A){var e,C;cx?((e=ax.createEvent("Event")).promise=t,e.reason=A,e.initEvent(g,!1,!0),Zk.dispatchEvent(e)):e={promise:t,reason:A},!Cx&&(C=Zk["on"+g])?C(e):g===ux&&Hk("Unhandled promise rejection",A)},mx=function(g){Fk(_k,Zk,(function(){var t,A=g.facade,e=g.value;if(bx(g)&&(t=Xk((function(){Sk?dx.emit("unhandledRejection",e,A):yx(ux,A,e)})),g.rejection=Sk||bx(g)?2:1,t.error))throw t.value}))},bx=function(g){return 1!==g.rejection&&!g.parent},wx=function(g){Fk(_k,Zk,(function(){var t=g.facade;Sk?dx.emit("rejectionHandled",t):yx("rejectionhandled",t,g.value)}))},kx=function(g,t,A){return function(e){g(t,e,A)}},xx=function(g,t,A){g.done||(g.done=!0,A&&(g=A),g.value=t,g.state=2,vx(g,!0))},Ex=function(g,t,A){if(!g.done){g.done=!0,A&&(g=A);try{if(g.facade===t)throw new sx("Promise can't be resolved itself");var e=px(t);e?Kk((function(){var A={done:!1};try{Fk(e,t,kx(Ex,A,g),kx(xx,A,g))}catch(t){xx(A,t,g)}})):(g.value=t,g.state=1,vx(g,!1))}catch(t){xx({done:!1},t,g)}}};ex&&(rx=(nx=function(g){Qk(this,rx),Vk(g),Fk(Mk,this);var t=Ix(this);try{g(kx(Ex,t),kx(xx,t))}catch(g){xx(t,g)}}).prototype,(Mk=function(g){ix(this,{type:Ax,done:!1,notified:!1,parent:!1,reactions:new Jk,rejection:!1,state:0,value:void 0})}).prototype=Gk(rx,"then",(function(g,t){var A=Ix(this),e=hx(Uk(this,nx));return A.parent=!0,e.ok=!Yk(g)||g,e.fail=Yk(t)&&t,e.domain=Sk?dx.domain:void 0,0===A.state?A.reactions.add(e):Kk((function(){fx(e,A)})),e.promise})),Bk=function(){var g=new Mk,t=Ix(g);this.promise=g,this.resolve=kx(Ex,t),this.reject=kx(xx,t)},tx.f=hx=function(g){return g===nx||undefined===g?new Bk(g):lx(g)}),zk({global:!0,constructor:!0,wrap:!0,forced:ex},{Promise:nx}),jk(nx,Ax,!1,!0),Lk(Ax);var Ox=ak,Tx=Tk.CONSTRUCTOR||!Yo((function(g){Ox.all(g).then(void 0,(function(){}))})),Dx=P,Nx=Rg,Rx=Dk,Px=sk,Mx=Hy;TA({target:"Promise",stat:!0,forced:Tx},{all:function(g){var t=this,A=Rx.f(t),e=A.resolve,C=A.reject,I=Px((function(){var A=Nx(t.resolve),I=[],i=0,o=1;Mx(g,(function(g){var n=i++,r=!1;o++,Dx(A,t,g).then((function(g){r||(r=!0,I[n]=g,--o||e(I))}),C)})),--o||e(I)}));return I.error&&C(I.value),A.promise}});var Bx=TA,zx=Tk.CONSTRUCTOR;ak&&ak.prototype,Bx({target:"Promise",proto:!0,forced:zx,real:!0},{catch:function(g){return this.then(void 0,g)}});var Sx=P,Zx=Rg,Fx=Dk,Gx=sk,jx=Hy;TA({target:"Promise",stat:!0,forced:Tx},{race:function(g){var t=this,A=Fx.f(t),e=A.reject,C=Gx((function(){var C=Zx(t.resolve);jx(g,(function(g){Sx(C,t,g).then(A.resolve,e)}))}));return C.error&&e(C.value),A.promise}});var Lx=P,Vx=Dk;TA({target:"Promise",stat:!0,forced:Tk.CONSTRUCTOR},{reject:function(g){var t=Vx.f(this);return Lx(t.reject,void 0,g),t.promise}});var Yx=AA,Wx=gg,Qx=Dk,Ux=function(g,t){if(Yx(g),Wx(t)&&t.constructor===g)return t;var A=Qx.f(g);return(0,A.resolve)(t),A.promise},_x=TA,Kx=ak,Hx=Tk.CONSTRUCTOR,Xx=Ux,Jx=ig("Promise"),qx=!Hx;_x({target:"Promise",stat:!0,forced:true},{resolve:function(g){return Xx(qx&&this===Jx?Kx:this,g)}});var $x=P,gE=Rg,tE=Dk,AE=sk,eE=Hy;TA({target:"Promise",stat:!0,forced:Tx},{allSettled:function(g){var t=this,A=tE.f(t),e=A.resolve,C=A.reject,I=AE((function(){var A=gE(t.resolve),C=[],I=0,i=1;eE(g,(function(g){var o=I++,n=!1;i++,$x(A,t,g).then((function(g){n||(n=!0,C[o]={status:"fulfilled",value:g},--i||e(C))}),(function(g){n||(n=!0,C[o]={status:"rejected",reason:g},--i||e(C))}))})),--i||e(C)}));return I.error&&C(I.value),A.promise}});var CE=P,IE=Rg,iE=ig,oE=Dk,nE=sk,rE=Hy,sE="No one promise resolved";TA({target:"Promise",stat:!0,forced:Tx},{any:function(g){var t=this,A=iE("AggregateError"),e=oE.f(t),C=e.resolve,I=e.reject,i=nE((function(){var e=IE(t.resolve),i=[],o=0,n=1,r=!1;rE(g,(function(g){var s=o++,a=!1;n++,CE(e,t,g).then((function(g){a||r||(r=!0,C(g))}),(function(g){a||r||(a=!0,i[s]=g,--n||I(new A(i,sE)))}))})),--n||I(new A(i,sE))}));return i.error&&I(i.value),e.promise}});var aE=TA,dE=ak,hE=I,lE=ig,cE=O,uE=nw,pE=Ux,fE=dE&&dE.prototype;aE({target:"Promise",proto:!0,real:!0,forced:!!dE&&hE((function(){fE.finally.call({then:function(){}},(function(){}))}))},{finally:function(g){var t=uE(this,lE("Promise")),A=cE(g);return this.then(A?function(A){return pE(t,g()).then((function(){return A}))}:g,A?function(A){return pE(t,g()).then((function(){throw A}))}:g)}});var vE=tg.Promise,yE=Dk;TA({target:"Promise",stat:!0},{withResolvers:function(){var g=yE.f(this);return{promise:g.promise,resolve:g.resolve,reject:g.reject}}});var mE=vE,bE=Dk,wE=sk;TA({target:"Promise",stat:!0,forced:!0},{try:function(g){var t=bE.f(this),A=wE(g);return(A.error?t.reject:t.resolve)(A.value),t.promise}});var kE=mE,xE=ll;!function(g){var t=db.default,A=wn,e=cd,C=qm,I=ib,i=hb,o=Ld,n=gb,r=kE,s=xE,a=rh;function d(){g.exports=d=function(){return l},g.exports.__esModule=!0,g.exports.default=g.exports;var h,l={},c=Object.prototype,u=c.hasOwnProperty,p=A||function(g,t,A){g[t]=A.value},f="function"==typeof e?e:{},v=f.iterator||"@@iterator",y=f.asyncIterator||"@@asyncIterator",m=f.toStringTag||"@@toStringTag";function b(g,t,e){return A(g,t,{value:e,enumerable:!0,configurable:!0,writable:!0}),g[t]}try{b({},"")}catch(h){b=function(g,t,A){return g[t]=A}}function w(g,t,A,e){var I=t&&t.prototype instanceof N?t:N,i=C(I.prototype),o=new V(e||[]);return p(i,"_invoke",{value:F(g,A,o)}),i}function k(g,t,A){try{return{type:"normal",arg:g.call(t,A)}}catch(g){return{type:"throw",arg:g}}}l.wrap=w;var x="suspendedStart",E="suspendedYield",O="executing",T="completed",D={};function N(){}function R(){}function P(){}var M={};b(M,v,(function(){return this}));var B=I&&I(I(Y([])));B&&B!==c&&u.call(B,v)&&(M=B);var z=P.prototype=N.prototype=C(M);function S(g){var t;i(t=["next","throw","return"]).call(t,(function(t){b(g,t,(function(g){return this._invoke(t,g)}))}))}function Z(g,A){function e(C,I,i,o){var n=k(g[C],g,I);if("throw"!==n.type){var r=n.arg,s=r.value;return s&&"object"==t(s)&&u.call(s,"__await")?A.resolve(s.__await).then((function(g){e("next",g,i,o)}),(function(g){e("throw",g,i,o)})):A.resolve(s).then((function(g){r.value=g,i(r)}),(function(g){return e("throw",g,i,o)}))}o(n.arg)}var C;p(this,"_invoke",{value:function(g,t){function I(){return new A((function(A,C){e(g,t,A,C)}))}return C=C?C.then(I,I):I()}})}function F(g,t,A){var e=x;return function(C,I){if(e===O)throw new Error("Generator is already running");if(e===T){if("throw"===C)throw I;return{value:h,done:!0}}for(A.method=C,A.arg=I;;){var i=A.delegate;if(i){var o=G(i,A);if(o){if(o===D)continue;return o}}if("next"===A.method)A.sent=A._sent=A.arg;else if("throw"===A.method){if(e===x)throw e=T,A.arg;A.dispatchException(A.arg)}else"return"===A.method&&A.abrupt("return",A.arg);e=O;var n=k(g,t,A);if("normal"===n.type){if(e=A.done?T:E,n.arg===D)continue;return{value:n.arg,done:A.done}}"throw"===n.type&&(e=T,A.method="throw",A.arg=n.arg)}}}function G(g,t){var A=t.method,e=g.iterator[A];if(e===h)return t.delegate=null,"throw"===A&&g.iterator.return&&(t.method="return",t.arg=h,G(g,t),"throw"===t.method)||"return"!==A&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+A+"' method")),D;var C=k(e,g.iterator,t.arg);if("throw"===C.type)return t.method="throw",t.arg=C.arg,t.delegate=null,D;var I=C.arg;return I?I.done?(t[g.resultName]=I.value,t.next=g.nextLoc,"return"!==t.method&&(t.method="next",t.arg=h),t.delegate=null,D):I:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,D)}function j(g){var t,A={tryLoc:g[0]};1 in g&&(A.catchLoc=g[1]),2 in g&&(A.finallyLoc=g[2],A.afterLoc=g[3]),o(t=this.tryEntries).call(t,A)}function L(g){var t=g.completion||{};t.type="normal",delete t.arg,g.completion=t}function V(g){this.tryEntries=[{tryLoc:"root"}],i(g).call(g,j,this),this.reset(!0)}function Y(g){if(g||""===g){var A=g[v];if(A)return A.call(g);if("function"==typeof g.next)return g;if(!isNaN(g.length)){var e=-1,C=function t(){for(;++e=0;--e){var C=this.tryEntries[e],I=C.completion;if("root"===C.tryLoc)return A("end");if(C.tryLoc<=this.prev){var i=u.call(C,"catchLoc"),o=u.call(C,"finallyLoc");if(i&&o){if(this.prev=0;--A){var e=this.tryEntries[A];if(e.tryLoc<=this.prev&&u.call(e,"finallyLoc")&&this.prev=0;--t){var A=this.tryEntries[t];if(A.finallyLoc===g)return this.complete(A.completion,A.afterLoc),L(A),D}},catch:function(g){for(var t=this.tryEntries.length-1;t>=0;--t){var A=this.tryEntries[t];if(A.tryLoc===g){var e=A.completion;if("throw"===e.type){var C=e.arg;L(A)}return C}}throw new Error("illegal catch attempt")},delegateYield:function(g,t,A){return this.delegate={iterator:Y(g),resultName:t,nextLoc:A},"next"===this.method&&(this.arg=h),D}},l}g.exports=d,g.exports.__esModule=!0,g.exports.default=g.exports}(sb);var EE=(0,sb.exports)(),OE=EE;try{regeneratorRuntime=EE}catch(g){"object"==typeof globalThis?globalThis.regeneratorRuntime=EE:Function("r","regeneratorRuntime = r")(EE)}var TE=A(OE),DE=Rg,NE=Hg,RE=W,PE=jA,ME=TypeError,BE=function(g){return function(t,A,e,C){DE(A);var I=NE(t),i=RE(I),o=PE(I),n=g?o-1:0,r=g?-1:1;if(e<2)for(;;){if(n in i){C=i[n],n+=r;break}if(n+=r,g?n<0:o<=n)throw new ME("Reduce of empty array with no initial value")}for(;g?n>=0:o>n;n+=r)n in i&&(C=A(C,i[n],n,I));return C}},zE={left:BE(!1),right:BE(!0)}.left;TA({target:"Array",proto:!0,forced:!$b&&cg>79&&cg<83||!_h("reduce")},{reduce:function(g){var t=arguments.length;return zE(this,g,t,t>1?arguments[1]:void 0)}});var SE=Me("Array").reduce,ZE=og,FE=SE,GE=Array.prototype,jE=function(g){var t=g.reduce;return g===GE||ZE(GE,g)&&t===GE.reduce?FE:t},LE=A(jE),VE=En,YE=jA,WE=Tn,QE=Xt,UE=function(g,t,A,e,C,I,i,o){for(var n,r,s=C,a=0,d=!!i&&QE(i,o);a0&&VE(n)?(r=YE(n),s=UE(g,t,n,r,s,I-1)-1):(WE(s+1),g[s]=n),s++),a++;return s},_E=UE,KE=Rg,HE=Hg,XE=jA,JE=zn;TA({target:"Array",proto:!0},{flatMap:function(g){var t,A=HE(this),e=XE(A);return KE(g),(t=JE(A,0)).length=_E(t,A,A,e,0,1,g,arguments.length>1?arguments[1]:void 0),t}});var qE=Me("Array").flatMap,$E=og,gO=qE,tO=Array.prototype,AO=function(g){var t=g.flatMap;return g===tO||$E(tO,g)&&t===tO.flatMap?gO:t},eO=A(AO);cm("Set",(function(g){return function(){return g(this,arguments.length?arguments[0]:void 0)}}),Zm);var CO=A(tg.Set),IO=A(pd),iO=A(Oo),oO=rr,nO=Math.floor,rO=function(g,t){var A=g.length,e=nO(A/2);return A<8?sO(g,t):aO(g,rO(oO(g,0,e),t),rO(oO(g,e),t),t)},sO=function(g,t){for(var A,e,C=g.length,I=1;I0;)g[e]=g[--e];e!==I++&&(g[e]=A)}return g},aO=function(g,t,A,e){for(var C=t.length,I=A.length,i=0,o=0;i3)){if(DO)return!0;if(RO)return RO<603;var g,t,A,e,C="";for(g=65;g<76;g++){switch(t=String.fromCharCode(g),g){case 66:case 69:case 70:case 72:A=3;break;case 68:case 71:A=4;break;default:A=2}for(e=0;e<47;e++)PO.push({k:t+e,v:A})}for(PO.sort((function(g,t){return t.v-g.v})),e=0;ekO(A)?1:-1}}(g)),A=bO(C),e=0;eo;)void 0!==(A=C(e,t=I[o++]))&&KT(i,t,A);return i}});var HT=A(tg.Object.getOwnPropertyDescriptors),XT={exports:{}},JT=TA,qT=D,$T=UC.f;JT({target:"Object",stat:!0,forced:Object.defineProperties!==$T,sham:!qT},{defineProperties:$T});var gD=tg.Object,tD=XT.exports=function(g,t){return gD.defineProperties(g,t)};gD.defineProperties.sham&&(tD.sham=!0);var AD=A(XT.exports);let eD;const CD=new Uint8Array(16);function ID(){if(!eD&&(eD="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!eD))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return eD(CD)}const iD=[];for(let g=0;g<256;++g)iD.push((g+256).toString(16).slice(1));var oD,nD={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function rD(g,t,A){if(nD.randomUUID&&!t&&!g)return nD.randomUUID();const e=(g=g||{}).random||(g.rng||ID)();if(e[6]=15&e[6]|64,e[8]=63&e[8]|128,t){A=A||0;for(let g=0;g<16;++g)t[A+g]=e[g];return t}return function(g,t=0){return iD[g[t+0]]+iD[g[t+1]]+iD[g[t+2]]+iD[g[t+3]]+"-"+iD[g[t+4]]+iD[g[t+5]]+"-"+iD[g[t+6]]+iD[g[t+7]]+"-"+iD[g[t+8]]+iD[g[t+9]]+"-"+iD[g[t+10]]+iD[g[t+11]]+iD[g[t+12]]+iD[g[t+13]]+iD[g[t+14]]+iD[g[t+15]]}(e)}function sD(g,t){var A=Lh(g);if(BT){var e=BT(g);t&&(e=pc(e).call(e,(function(t){return WT(g,t).enumerable}))),A.push.apply(A,e)}return A}function aD(g){for(var t=1;t=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function lD(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);Athis.max&&this.flush(),null!=this._timeout&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&"number"==typeof this.delay&&(this._timeout=wu((function(){g.flush()}),this.delay))}},{key:"flush",value:function(){var g,t;Cl(g=Zl(t=this._queue).call(t,0)).call(g,(function(g){g.fn.apply(g.context||g.fn,g.args||[])}))}}],[{key:"extend",value:function(t,A){var e=new g(A);if(void 0!==t.flush)throw new Error("Target object already has a property flush");t.flush=function(){e.flush()};var C=[{name:"flush",original:void 0}];if(A&&A.replace)for(var I=0;IC&&(C=n,e=o)}return e}},{key:"min",value:function(g){var t=iO(this._pairs),A=t.next();if(A.done)return null;for(var e=A.value[1],C=g(A.value[1],A.value[0]);!(A=t.next()).done;){var I=lh(A.value,2),i=I[0],o=I[1],n=g(o,i);n1?A-1:0),C=1;CC?1:eC)&&(e=i,C=o)}}catch(g){I.e(g)}finally{I.f()}return e||null}},{key:"min",value:function(g){var t,A,e=null,C=null,I=hD(nT(t=this._data).call(t));try{for(I.s();!(A=I.n()).done;){var i=A.value,o=i[g];"number"==typeof o&&(null==C||ot.x&&g.topt.y}function QD(g){return"string"==typeof g&&""!==g}function UD(g,t,A,e){var C=e.x,I=e.y;if("function"==typeof e.distanceToBorder){var i=e.distanceToBorder(g,t),o=Math.sin(t)*i,n=Math.cos(t)*i;n===i?(C+=i,I=e.y):o===i?(C=e.x,I-=i):(C+=n,I-=o)}else e.shape.width>e.shape.height?(C=e.x+.5*e.shape.width,I=e.y-A):(C=e.x+A,I=e.y-.5*e.shape.height);return{x:C,y:I}}var _D=function(){function g(t){cn(this,g),this.measureText=t,this.current=0,this.width=0,this.height=0,this.lines=[]}return kd(g,[{key:"_add",value:function(g,t){var A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"normal";void 0===this.lines[g]&&(this.lines[g]={width:0,height:0,blocks:[]});var e=t;void 0!==t&&""!==t||(e=" ");var C=this.measureText(e,A),I=fe({},nT(C));I.text=t,I.width=C.width,I.mod=A,void 0!==t&&""!==t||(I.width=0),this.lines[g].blocks.push(I),this.lines[g].width+=I.width}},{key:"curWidth",value:function(){var g=this.lines[this.current];return void 0===g?0:g.width}},{key:"append",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"normal";this._add(this.current,g,t)}},{key:"newLine",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"normal";this._add(this.current,g,t),this.current++}},{key:"determineLineHeights",value:function(){for(var g=0;gg&&(g=e.width),t+=e.height}this.width=g,this.height=t}},{key:"removeEmptyBlocks",value:function(){for(var g=[],t=0;t"://,""://,""://,"":/<\/b>/,"":/<\/i>/,"":/<\/code>/,"*":/\*/,_:/_/,"`":/`/,afterBold:/[^*]/,afterItal:/[^_]/,afterMono:/[^`]/},HD=function(){function g(t){cn(this,g),this.text=t,this.bold=!1,this.ital=!1,this.mono=!1,this.spacing=!1,this.position=0,this.buffer="",this.modStack=[],this.blocks=[]}return kd(g,[{key:"mod",value:function(){return 0===this.modStack.length?"normal":this.modStack[0]}},{key:"modName",value:function(){return 0===this.modStack.length?"normal":"mono"===this.modStack[0]?"mono":this.bold&&this.ital?"boldital":this.bold?"bold":this.ital?"ital":void 0}},{key:"emitBlock",value:function(){this.spacing&&(this.add(" "),this.spacing=!1),this.buffer.length>0&&(this.blocks.push({text:this.buffer,mod:this.modName()}),this.buffer="")}},{key:"add",value:function(g){" "===g&&(this.spacing=!0),this.spacing&&(this.buffer+=" ",this.spacing=!1)," "!=g&&(this.buffer+=g)}},{key:"parseWS",value:function(g){return!!/[ \t]/.test(g)&&(this.mono?this.add(g):this.spacing=!0,!0)}},{key:"setTag",value:function(g){this.emitBlock(),this[g]=!0,this.modStack.unshift(g)}},{key:"unsetTag",value:function(g){this.emitBlock(),this[g]=!1,this.modStack.shift()}},{key:"parseStartTag",value:function(g,t){return!(this.mono||this[g]||!this.match(t))&&(this.setTag(g),!0)}},{key:"match",value:function(g){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],A=lh(this.prepareRegExp(g),2),e=A[0],C=A[1],I=e.test(this.text.substr(this.position,C));return I&&t&&(this.position+=C-1),I}},{key:"parseEndTag",value:function(g,t,A){var e=this.mod()===g;return!(!(e="mono"===g?e&&this.mono:e&&!this.mono)||!this.match(t))&&(void 0!==A?(this.position===this.text.length-1||this.match(A,!1))&&this.unsetTag(g):this.unsetTag(g),!0)}},{key:"replace",value:function(g,t){return!!this.match(g)&&(this.add(t),this.position+=length-1,!0)}},{key:"prepareRegExp",value:function(g){var t,A;if(g instanceof RegExp)A=g,t=1;else{var e=KD[g];A=void 0!==e?e:new RegExp(g),t=g.length}return[A,t]}}]),g}(),XD=function(){function g(t,A,e,C){var I=this;cn(this,g),this.ctx=t,this.parent=A,this.selected=e,this.hover=C;this.lines=new _D((function(g,A){if(void 0===g)return 0;var i=I.parent.getFormattingValues(t,e,C,A),o=0;""!==g&&(o=I.ctx.measureText(g).width);return{width:o,values:i}}))}return kd(g,[{key:"process",value:function(g){if(!QD(g))return this.lines.finalize();var t=this.parent.fontOptions;g=(g=g.replace(/\r\n/g,"\n")).replace(/\r/g,"\n");var A=String(g).split("\n"),e=A.length;if(t.multi)for(var C=0;C0)for(var i=0;i0)for(var d=0;d")||t.parseStartTag("ital","")||t.parseStartTag("mono","")||t.parseEndTag("bold","")||t.parseEndTag("ital","")||t.parseEndTag("mono",""))||A(e)||t.add(e),t.position++}return t.emitBlock(),t.blocks}},{key:"splitMarkdownBlocks",value:function(g){for(var t=this,A=new HD(g),e=!0,C=function(g){return!!/\\/.test(g)&&(A.positionthis.parent.fontOptions.maxWdt}},{key:"getLongestFit",value:function(g){for(var t="",A=0;A1&&void 0!==arguments[1]?arguments[1]:"normal",A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.parent.getFormattingValues(this.ctx,this.selected,this.hover,t);for(var e=(g=(g=g.replace(/^( +)/g,"$1\r")).replace(/([^\r][^ ]*)( +)/g,"$1\r$2\r")).split("\r");e.length>0;){var C=this.getLongestFit(e);if(0===C){var I=e[0],i=this.getLongestFitWord(I);this.lines.newLine(wh(I).call(I,0,i),t),e[0]=wh(I).call(I,i)}else{var o=C;" "===e[C-1]?C--:" "===e[o]&&o++;var n=wh(e).call(e,0,C).join("");C==e.length&&A?this.lines.append(n,t):this.lines.newLine(n,t),e=wh(e).call(e,o)}}}}]),g}(),JD=["bold","ital","boldital","mono"],qD=function(){function g(t,A){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2];cn(this,g),this.body=t,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(A),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=e}return kd(g,[{key:"setOptions",value:function(g){if(this.elementOptions=g,this.initFontOptions(g.font),QD(g.label)?this.labelDirty=!0:g.label=void 0,void 0!==g.font&&null!==g.font)if("string"==typeof g.font)this.baseSize=this.fontOptions.size;else if("object"===yd(g.font)){var t=g.font.size;void 0!==t&&(this.baseSize=t)}}},{key:"initFontOptions",value:function(t){var A=this;tv(JD,(function(g){A.fontOptions[g]={}})),g.parseFontString(this.fontOptions,t)?this.fontOptions.vadjust=0:tv(t,(function(g,t){null!=g&&"object"!==yd(g)&&(A.fontOptions[t]=g)}))}},{key:"constrain",value:function(g){var t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},A=lv(g,"widthConstraint");if("number"==typeof A)t.maxWdt=Number(A),t.minWdt=Number(A);else if("object"===yd(A)){var e=lv(g,["widthConstraint","maximum"]);"number"==typeof e&&(t.maxWdt=Number(e));var C=lv(g,["widthConstraint","minimum"]);"number"==typeof C&&(t.minWdt=Number(C))}var I=lv(g,"heightConstraint");if("number"==typeof I)t.minHgt=Number(I);else if("object"===yd(I)){var i=lv(g,["heightConstraint","minimum"]);"number"==typeof i&&(t.minHgt=Number(i));var o=lv(g,["heightConstraint","valign"]);"string"==typeof o&&("top"!==o&&"bottom"!==o||(t.valign=o))}return t}},{key:"update",value:function(g,t){this.setOptions(g,!0),this.propagateFonts(t),qf(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=YD("label",t)}},{key:"adjustSizes",value:function(g){var t=g?g.right+g.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);var A=g?g.top+g.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=A)}},{key:"addFontOptionsToPile",value:function(g,t){for(var A=0;A5&&void 0!==arguments[5]?arguments[5]:"middle";if(void 0!==this.elementOptions.label){var i=this.fontOptions.size*this.body.view.scale;this.elementOptions.label&&i=this.elementOptions.scaling.label.maxVisible&&(i=Number(this.elementOptions.scaling.label.maxVisible)/this.body.view.scale),this.calculateLabelSize(g,e,C,t,A,I),this._drawBackground(g),this._drawText(g,t,this.size.yLine,I,i))}}},{key:"_drawBackground",value:function(g){if(void 0!==this.fontOptions.background&&"none"!==this.fontOptions.background){g.fillStyle=this.fontOptions.background;var t=this.getSize();g.fillRect(t.left,t.top,t.width,t.height)}}},{key:"_drawText",value:function(g,t,A){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"middle",C=arguments.length>4?arguments[4]:void 0,I=lh(this._setAlignment(g,t,A,e),2);t=I[0],A=I[1],g.textAlign="left",t-=this.size.width/2,this.fontOptions.valign&&this.size.height>this.size.labelHeight&&("top"===this.fontOptions.valign&&(A-=(this.size.height-this.size.labelHeight)/2),"bottom"===this.fontOptions.valign&&(A+=(this.size.height-this.size.labelHeight)/2));for(var i=0;i0&&(g.lineWidth=s.strokeWidth,g.strokeStyle=h,g.lineJoin="round"),g.fillStyle=d,s.strokeWidth>0&&g.strokeText(s.text,t+n,A+s.vadjust),g.fillText(s.text,t+n,A+s.vadjust),n+=s.width}A+=o.height}}}},{key:"_setAlignment",value:function(g,t,A,e){if(this.isEdgeLabel&&"horizontal"!==this.fontOptions.align&&!1===this.pointToSelf){t=0,A=0;"top"===this.fontOptions.align?(g.textBaseline="alphabetic",A-=4):"bottom"===this.fontOptions.align?(g.textBaseline="hanging",A+=4):g.textBaseline="middle"}else g.textBaseline=e;return[t,A]}},{key:"_getColor",value:function(g,t,A){var e=g||"#000000",C=A||"#ffffff";if(t<=this.elementOptions.scaling.label.drawThreshold){var I=Math.max(0,Math.min(1,1-(this.elementOptions.scaling.label.drawThreshold-t)));e=ev(e,I),C=ev(C,I)}return[e,C]}},{key:"getTextSize",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this._processLabel(g,t,A),{width:this.size.width,height:this.size.height,lineCount:this.lineCount}}},{key:"getSize",value:function(){var g=this.size.left,t=this.size.top-1;if(this.isEdgeLabel){var A=.5*-this.size.width;switch(this.fontOptions.align){case"middle":g=A,t=.5*-this.size.height;break;case"top":g=A,t=-(this.size.height+2);break;case"bottom":g=A,t=2}}return{left:g,top:t,width:this.size.width,height:this.size.height}}},{key:"calculateLabelSize",value:function(g,t,A){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,C=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,I=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"middle";this._processLabel(g,t,A),this.size.left=e-.5*this.size.width,this.size.top=C-.5*this.size.height,this.size.yLine=C+.5*(1-this.lineCount)*this.fontOptions.size,"hanging"===I&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4)}},{key:"getFormattingValues",value:function(g,t,A,e){var C=function(g,t,A){return"normal"===t?"mod"===A?"":g[A]:void 0!==g[t][A]?g[t][A]:g[A]},I={color:C(this.fontOptions,e,"color"),size:C(this.fontOptions,e,"size"),face:C(this.fontOptions,e,"face"),mod:C(this.fontOptions,e,"mod"),vadjust:C(this.fontOptions,e,"vadjust"),strokeWidth:this.fontOptions.strokeWidth,strokeColor:this.fontOptions.strokeColor};(t||A)&&("normal"===e&&!0===this.fontOptions.chooser&&this.elementOptions.labelHighlightBold?I.mod="bold":"function"==typeof this.fontOptions.chooser&&this.fontOptions.chooser(I,this.elementOptions.id,t,A));var i="";return void 0!==I.mod&&""!==I.mod&&(i+=I.mod+" "),i+=I.size+"px "+I.face,g.font=i.replace(/"/g,""),I.font=g.font,I.height=I.size,I}},{key:"differentState",value:function(g,t){return g!==this.selectedState||t!==this.hoverState}},{key:"_processLabelText",value:function(g,t,A,e){return new XD(g,this,t,A).process(e)}},{key:"_processLabel",value:function(g,t,A){if(!1!==this.labelDirty||this.differentState(t,A)){var e=this._processLabelText(g,t,A,this.elementOptions.label);this.fontOptions.minWdt>0&&e.width0&&e.height0&&(this.enableBorderDashes(g,t),g.stroke(),this.disableBorderDashes(g,t)),g.restore()}},{key:"performFill",value:function(g,t){g.save(),g.fillStyle=t.color,this.enableShadow(g,t),Bu(g).call(g),this.disableShadow(g,t),g.restore(),this.performStroke(g,t)}},{key:"_addBoundingBoxMargin",value:function(g){this.boundingBox.left-=g,this.boundingBox.top-=g,this.boundingBox.bottom+=g,this.boundingBox.right+=g}},{key:"_updateBoundingBox",value:function(g,t,A,e,C){void 0!==A&&this.resize(A,e,C),this.left=g-this.width/2,this.top=t-this.height/2,this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width}},{key:"updateBoundingBox",value:function(g,t,A,e,C){this._updateBoundingBox(g,t,A,e,C)}},{key:"getDimensionsFromLabel",value:function(g,t,A){this.textSize=this.labelModule.getTextSize(g,t,A);var e=this.textSize.width,C=this.textSize.height;return 0===e&&(e=14,C=14),{width:e,height:C}}}]),g}();function gN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var tN=function(g){Cb(A,g);var t=gN(A);function A(g,e,C){var I;return cn(this,A),(I=t.call(this,g,e,C))._setMargins(C),I}return kd(A,[{key:"resize",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(this.needsRefresh(t,A)){var e=this.getDimensionsFromLabel(g,t,A);this.width=e.width+this.margin.right+this.margin.left,this.height=e.height+this.margin.top+this.margin.bottom,this.radius=this.width/2}}},{key:"draw",value:function(g,t,A,e,C,I){this.resize(g,e,C),this.left=t-this.width/2,this.top=A-this.height/2,this.initContextForDraw(g,I),Ve(g,this.left,this.top,this.width,this.height,I.borderRadius),this.performFill(g,I),this.updateBoundingBox(t,A,g,e,C),this.labelModule.draw(g,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,e,C)}},{key:"updateBoundingBox",value:function(g,t,A,e,C){this._updateBoundingBox(g,t,A,e,C);var I=this.options.shapeProperties.borderRadius;this._addBoundingBoxMargin(I)}},{key:"distanceToBorder",value:function(g,t){g&&this.resize(g);var A=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(t)),Math.abs(this.height/2/Math.sin(t)))+A}}]),A}($D);function AN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var eN=function(g){Cb(A,g);var t=AN(A);function A(g,e,C){var I;return cn(this,A),(I=t.call(this,g,e,C)).labelOffset=0,I.selected=!1,I}return kd(A,[{key:"setOptions",value:function(g,t,A){this.options=g,void 0===t&&void 0===A||this.setImages(t,A)}},{key:"setImages",value:function(g,t){t&&this.selected?(this.imageObj=t,this.imageObjAlt=g):(this.imageObj=g,this.imageObjAlt=t)}},{key:"switchImages",value:function(g){var t=g&&!this.selected||!g&&this.selected;if(this.selected=g,void 0!==this.imageObjAlt&&t){var A=this.imageObj;this.imageObj=this.imageObjAlt,this.imageObjAlt=A}}},{key:"_getImagePadding",value:function(){var g={top:0,right:0,bottom:0,left:0};if(this.options.imagePadding){var t=this.options.imagePadding;"object"==yd(t)?(g.top=t.top,g.right=t.right,g.bottom=t.bottom,g.left=t.left):(g.top=t,g.right=t,g.bottom=t,g.left=t)}return g}},{key:"_resizeImage",value:function(){var g,t;if(!1===this.options.shapeProperties.useImageSize){var A=1,e=1;this.imageObj.width&&this.imageObj.height&&(this.imageObj.width>this.imageObj.height?A=this.imageObj.width/this.imageObj.height:e=this.imageObj.height/this.imageObj.width),g=2*this.options.size*A,t=2*this.options.size*e}else{var C=this._getImagePadding();g=this.imageObj.width+C.left+C.right,t=this.imageObj.height+C.top+C.bottom}this.width=g,this.height=t,this.radius=.5*this.width}},{key:"_drawRawCircle",value:function(g,t,A,e){this.initContextForDraw(g,e),Le(g,t,A,e.size),this.performFill(g,e)}},{key:"_drawImageAtPosition",value:function(g,t){if(0!=this.imageObj.width){g.globalAlpha=void 0!==t.opacity?t.opacity:1,this.enableShadow(g,t);var A=1;!0===this.options.shapeProperties.interpolation&&(A=this.imageObj.width/this.width/this.body.view.scale);var e=this._getImagePadding(),C=this.left+e.left,I=this.top+e.top,i=this.width-e.left-e.right,o=this.height-e.top-e.bottom;this.imageObj.drawImageAtPosition(g,A,C,I,i,o),this.disableShadow(g,t)}}},{key:"_drawImageLabel",value:function(g,t,A,e,C){var I=0;if(void 0!==this.height){I=.5*this.height;var i=this.labelModule.getTextSize(g,e,C);i.lineCount>=1&&(I+=i.height/2)}var o=A+I;this.options.label&&(this.labelOffset=I),this.labelModule.draw(g,t,o,e,C,"hanging")}}]),A}($D);function CN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var IN=function(g){Cb(A,g);var t=CN(A);function A(g,e,C){var I;return cn(this,A),(I=t.call(this,g,e,C))._setMargins(C),I}return kd(A,[{key:"resize",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(this.needsRefresh(t,A)){var e=this.getDimensionsFromLabel(g,t,A),C=Math.max(e.width+this.margin.right+this.margin.left,e.height+this.margin.top+this.margin.bottom);this.options.size=C/2,this.width=C,this.height=C,this.radius=this.width/2}}},{key:"draw",value:function(g,t,A,e,C,I){this.resize(g,e,C),this.left=t-this.width/2,this.top=A-this.height/2,this._drawRawCircle(g,t,A,I),this.updateBoundingBox(t,A),this.labelModule.draw(g,this.left+this.textSize.width/2+this.margin.left,A,e,C)}},{key:"updateBoundingBox",value:function(g,t){this.boundingBox.top=t-this.options.size,this.boundingBox.left=g-this.options.size,this.boundingBox.right=g+this.options.size,this.boundingBox.bottom=t+this.options.size}},{key:"distanceToBorder",value:function(g){return g&&this.resize(g),.5*this.width}}]),A}(eN);function iN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var oN=function(g){Cb(A,g);var t=iN(A);function A(g,e,C,I,i){var o;return cn(this,A),(o=t.call(this,g,e,C)).setImages(I,i),o}return kd(A,[{key:"resize",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(void 0===this.imageObj.src||void 0===this.imageObj.width||void 0===this.imageObj.height){var e=2*this.options.size;return this.width=e,this.height=e,void(this.radius=.5*this.width)}this.needsRefresh(t,A)&&this._resizeImage()}},{key:"draw",value:function(g,t,A,e,C,I){this.switchImages(e),this.resize();var i=t,o=A;"top-left"===this.options.shapeProperties.coordinateOrigin?(this.left=t,this.top=A,i+=this.width/2,o+=this.height/2):(this.left=t-this.width/2,this.top=A-this.height/2),this._drawRawCircle(g,i,o,I),g.save(),g.clip(),this._drawImageAtPosition(g,I),g.restore(),this._drawImageLabel(g,i,o,e,C),this.updateBoundingBox(t,A)}},{key:"updateBoundingBox",value:function(g,t){"top-left"===this.options.shapeProperties.coordinateOrigin?(this.boundingBox.top=t,this.boundingBox.left=g,this.boundingBox.right=g+2*this.options.size,this.boundingBox.bottom=t+2*this.options.size):(this.boundingBox.top=t-this.options.size,this.boundingBox.left=g-this.options.size,this.boundingBox.right=g+this.options.size,this.boundingBox.bottom=t+this.options.size),this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset)}},{key:"distanceToBorder",value:function(g){return g&&this.resize(g),.5*this.width}}]),A}(eN);function nN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var rN=function(g){Cb(A,g);var t=nN(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"resize",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover,e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{size:this.options.size};if(this.needsRefresh(t,A)){var C,I;this.labelModule.getTextSize(g,t,A);var i=2*e.size;this.width=null!==(C=this.customSizeWidth)&&void 0!==C?C:i,this.height=null!==(I=this.customSizeHeight)&&void 0!==I?I:i,this.radius=.5*this.width}}},{key:"_drawShape",value:function(g,t,A,e,C,I,i,o){var n,r=this;return this.resize(g,I,i,o),this.left=e-this.width/2,this.top=C-this.height/2,this.initContextForDraw(g,o),(n=t,Object.prototype.hasOwnProperty.call(Ue,n)?Ue[n]:function(g){for(var t=arguments.length,A=new Array(t>1?t-1:0),e=1;e0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height))}}]),A}($D);function sN(g,t){var A=Lh(g);if(BT){var e=BT(g);t&&(e=pc(e).call(e,(function(t){return WT(g,t).enumerable}))),A.push.apply(A,e)}return A}function aN(g){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:this.selected,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(this.needsRefresh(t,A)){var e=this.getDimensionsFromLabel(g,t,A);this.height=2*e.height,this.width=e.width+e.height,this.radius=.5*this.width}}},{key:"draw",value:function(g,t,A,e,C,I){this.resize(g,e,C),this.left=t-.5*this.width,this.top=A-.5*this.height,this.initContextForDraw(g,I),Ye(g,this.left,this.top,this.width,this.height),this.performFill(g,I),this.updateBoundingBox(t,A,g,e,C),this.labelModule.draw(g,t,A,e,C)}},{key:"distanceToBorder",value:function(g,t){g&&this.resize(g);var A=.5*this.width,e=.5*this.height,C=Math.sin(t)*A,I=Math.cos(t)*e;return A*e/Math.sqrt(C*C+I*I)}}]),A}($D);function bN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var wN=function(g){Cb(A,g);var t=bN(A);function A(g,e,C){var I;return cn(this,A),(I=t.call(this,g,e,C))._setMargins(C),I}return kd(A,[{key:"resize",value:function(g,t,A){this.needsRefresh(t,A)&&(this.iconSize={width:Number(this.options.icon.size),height:Number(this.options.icon.size)},this.width=this.iconSize.width+this.margin.right+this.margin.left,this.height=this.iconSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}},{key:"draw",value:function(g,t,A,e,C,I){var i=this;return this.resize(g,e,C),this.options.icon.size=this.options.icon.size||50,this.left=t-this.width/2,this.top=A-this.height/2,this._icon(g,t,A,e,C,I),{drawExternalLabel:function(){if(void 0!==i.options.label){i.labelModule.draw(g,i.left+i.iconSize.width/2+i.margin.left,A+i.height/2+5,e)}i.updateBoundingBox(t,A)}}}},{key:"updateBoundingBox",value:function(g,t){if(this.boundingBox.top=t-.5*this.options.icon.size,this.boundingBox.left=g-.5*this.options.icon.size,this.boundingBox.right=g+.5*this.options.icon.size,this.boundingBox.bottom=t+.5*this.options.icon.size,void 0!==this.options.label&&this.labelModule.size.width>0){this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+5)}}},{key:"_icon",value:function(g,t,A,e,C,I){var i=Number(this.options.icon.size);void 0!==this.options.icon.code?(g.font=[null!=this.options.icon.weight?this.options.icon.weight:e?"bold":"",(null!=this.options.icon.weight&&e?5:0)+i+"px",this.options.icon.face].join(" "),g.fillStyle=this.options.icon.color||"black",g.textAlign="center",g.textBaseline="middle",this.enableShadow(g,I),g.fillText(this.options.icon.code,t,A),this.disableShadow(g,I)):console.error("When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.")}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}($D);function kN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var xN=function(g){Cb(A,g);var t=kN(A);function A(g,e,C,I,i){var o;return cn(this,A),(o=t.call(this,g,e,C)).setImages(I,i),o}return kd(A,[{key:"resize",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selected,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.hover;if(void 0===this.imageObj.src||void 0===this.imageObj.width||void 0===this.imageObj.height){var e=2*this.options.size;return this.width=e,void(this.height=e)}this.needsRefresh(t,A)&&this._resizeImage()}},{key:"draw",value:function(g,t,A,e,C,I){g.save(),this.switchImages(e),this.resize();var i=t,o=A;if("top-left"===this.options.shapeProperties.coordinateOrigin?(this.left=t,this.top=A,i+=this.width/2,o+=this.height/2):(this.left=t-this.width/2,this.top=A-this.height/2),!0===this.options.shapeProperties.useBorderWithImage){var n=this.options.borderWidth,r=this.options.borderWidthSelected||2*this.options.borderWidth,s=(e?r:n)/this.body.view.scale;g.lineWidth=Math.min(this.width,s),g.beginPath();var a=e?this.options.color.highlight.border:C?this.options.color.hover.border:this.options.color.border,d=e?this.options.color.highlight.background:C?this.options.color.hover.background:this.options.color.background;void 0!==I.opacity&&(a=ev(a,I.opacity),d=ev(d,I.opacity)),g.strokeStyle=a,g.fillStyle=d,g.rect(this.left-.5*g.lineWidth,this.top-.5*g.lineWidth,this.width+g.lineWidth,this.height+g.lineWidth),Bu(g).call(g),this.performStroke(g,I),g.closePath()}this._drawImageAtPosition(g,I),this._drawImageLabel(g,i,o,e,C),this.updateBoundingBox(t,A),g.restore()}},{key:"updateBoundingBox",value:function(g,t){this.resize(),"top-left"===this.options.shapeProperties.coordinateOrigin?(this.left=g,this.top=t):(this.left=g-this.width/2,this.top=t-this.height/2),this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width,void 0!==this.options.label&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset))}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}(eN);function EN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var ON=function(g){Cb(A,g);var t=EN(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"draw",value:function(g,t,A,e,C,I){return this._drawShape(g,"square",2,t,A,e,C,I)}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}(rN);function TN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var DN=function(g){Cb(A,g);var t=TN(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"draw",value:function(g,t,A,e,C,I){return this._drawShape(g,"hexagon",4,t,A,e,C,I)}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}(rN);function NN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var RN=function(g){Cb(A,g);var t=NN(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"draw",value:function(g,t,A,e,C,I){return this._drawShape(g,"star",4,t,A,e,C,I)}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}(rN);function PN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var MN=function(g){Cb(A,g);var t=PN(A);function A(g,e,C){var I;return cn(this,A),(I=t.call(this,g,e,C))._setMargins(C),I}return kd(A,[{key:"resize",value:function(g,t,A){this.needsRefresh(t,A)&&(this.textSize=this.labelModule.getTextSize(g,t,A),this.width=this.textSize.width+this.margin.right+this.margin.left,this.height=this.textSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}},{key:"draw",value:function(g,t,A,e,C,I){this.resize(g,e,C),this.left=t-this.width/2,this.top=A-this.height/2,this.enableShadow(g,I),this.labelModule.draw(g,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,e,C),this.disableShadow(g,I),this.updateBoundingBox(t,A,g,e,C)}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}($D);function BN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var zN=function(g){Cb(A,g);var t=BN(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"draw",value:function(g,t,A,e,C,I){return this._drawShape(g,"triangle",3,t,A,e,C,I)}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}(rN);function SN(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var ZN=function(g){Cb(A,g);var t=SN(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"draw",value:function(g,t,A,e,C,I){return this._drawShape(g,"triangleDown",3,t,A,e,C,I)}},{key:"distanceToBorder",value:function(g,t){return this._distanceToBorder(g,t)}}]),A}(rN);function FN(g,t){var A=Lh(g);if(BT){var e=BT(g);t&&(e=pc(e).call(e,(function(t){return WT(g,t).enumerable}))),A.push.apply(A,e)}return A}function GN(g){for(var t=1;tg.left&&this.shape.topg.top}},{key:"isBoundingBoxOverlappingWith",value:function(g){return this.shape.boundingBox.leftg.left&&this.shape.boundingBox.topg.top}}],[{key:"checkOpacity",value:function(g){return 0<=g&&g<=1}},{key:"checkCoordinateOrigin",value:function(g){return void 0===g||"center"===g||"top-left"===g}},{key:"updateGroupOptions",value:function(t,A,e){var C;if(void 0!==e){var I=t.group;if(void 0!==A&&void 0!==A.group&&I!==A.group)throw new Error("updateGroupOptions: group values in options don't match.");if("number"==typeof I||"string"==typeof I&&""!=I){var i=e.get(I);void 0!==i.opacity&&void 0===A.opacity&&(g.checkOpacity(i.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+i.opacity),i.opacity=void 0));var o=pc(C=VD(A)).call(C,(function(g){return null!=A[g]}));o.push("font"),Jf(o,t,i),t.color=Iv(t.color)}}}},{key:"parseOptions",value:function(t,A){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],C=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},I=arguments.length>4?arguments[4]:void 0;if(Jf(["color","fixed","shadow"],t,A,e),g.checkMass(A),void 0!==t.opacity&&(g.checkOpacity(t.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+t.opacity),t.opacity=void 0)),void 0!==A.opacity&&(g.checkOpacity(A.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+A.opacity),A.opacity=void 0)),A.shapeProperties&&!g.checkCoordinateOrigin(A.shapeProperties.coordinateOrigin)&&console.error("Invalid option for node coordinateOrigin, found: "+A.shapeProperties.coordinateOrigin),dv(t,A,"shadow",C),void 0!==A.color&&null!==A.color){var i=Iv(A.color);Hf(t.color,i)}else!0===e&&null===A.color&&(t.color=av(C.color));void 0!==A.fixed&&null!==A.fixed&&("boolean"==typeof A.fixed?(t.fixed.x=A.fixed,t.fixed.y=A.fixed):(void 0!==A.fixed.x&&"boolean"==typeof A.fixed.x&&(t.fixed.x=A.fixed.x),void 0!==A.fixed.y&&"boolean"==typeof A.fixed.y&&(t.fixed.y=A.fixed.y))),!0===e&&null===A.font&&(t.font=av(C.font)),g.updateGroupOptions(t,A,I),void 0!==A.scaling&&dv(t.scaling,A.scaling,"label",C.scaling)}},{key:"checkMass",value:function(g,t){if(void 0!==g.mass&&g.mass<=0){var A="";void 0!==t&&(A=" in node id: "+t),console.error("%cNegative or zero mass disallowed"+A+", setting mass to 1.",Tv),g.mass=1}}}]),g}();function LN(g,t){var A=void 0!==uh&&ln(g)||g["@@iterator"];if(!A){if(Rh(g)||(A=function(g,t){var A;if(!g)return;if("string"==typeof g)return VN(g,t);var e=wh(A=Object.prototype.toString.call(g)).call(A,8,-1);"Object"===e&&g.constructor&&(e=g.constructor.name);if("Map"===e||"Set"===e)return Uo(g);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return VN(g,t)}(g))||t&&g&&"number"==typeof g.length){A&&(g=A);var e=0,C=function(){};return{s:C,n:function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function VN(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);A1?console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+g.opacity):this.options.opacity=g.opacity),void 0!==g.shape)for(var t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&this.body.nodes[t].updateShape();if(void 0!==g.font||void 0!==g.widthConstraint||void 0!==g.heightConstraint)for(var A=0,e=Lh(this.body.nodes);A1&&void 0!==arguments[1]&&arguments[1],A=this.body.data.nodes;if(kD("id",g))this.body.data.nodes=g;else if(Rh(g))this.body.data.nodes=new mD,this.body.data.nodes.add(g);else{if(g)throw new TypeError("Array or DataSet expected");this.body.data.nodes=new mD}if(A&&tv(this.nodesListeners,(function(g,t){A.off(t,g)})),this.body.nodes={},this.body.data.nodes){var e=this;tv(this.nodesListeners,(function(g,t){e.body.data.nodes.on(t,g)}));var C=this.body.data.nodes.getIds();this.add(C,!0)}!1===t&&this.body.emitter.emit("_dataChanged")}},{key:"add",value:function(g){for(var t,A=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=[],C=0;C1&&void 0!==arguments[1]?arguments[1]:jN)(g,this.body,this.images,this.groups,this.options,this.defaultOptions)}},{key:"refresh",value:function(){var g=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];tv(this.body.nodes,(function(A,e){var C=g.body.data.nodes.get(e);void 0!==C&&(!0===t&&A.setOptions({x:null,y:null}),A.setOptions({fixed:!1}),A.setOptions(C))}))}},{key:"getPositions",value:function(g){var t={};if(void 0!==g){if(!0===Rh(g)){for(var A=0;A0?(e=A/o)*e:A;return o===1/0?1/0:o*eR(C)}});var CR=A(tg.Math.hypot);function IR(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var iR=function(){function g(){cn(this,g)}return kd(g,null,[{key:"transform",value:function(g,t){Rh(g)||(g=[g]);for(var A=t.point.x,e=t.point.y,C=t.angle,I=t.length,i=0;i4&&void 0!==arguments[4]?arguments[4]:this.getViaNode();g.strokeStyle=this.getColor(g,t),g.lineWidth=t.width,!1!==t.dashes?this._drawDashedLine(g,t,C):this._drawLine(g,t,C)}},{key:"_drawLine",value:function(g,t,A,e,C){if(this.from!=this.to)this._line(g,t,A,e,C);else{var I=lh(this._getCircleData(g),3),i=I[0],o=I[1],n=I[2];this._circle(g,t,i,o,n)}}},{key:"_drawDashedLine",value:function(g,t,A,e,C){g.lineCap="round";var I=Rh(t.dashes)?t.dashes:[5,5];if(void 0!==g.setLineDash){if(g.save(),g.setLineDash(I),g.lineDashOffset=0,this.from!=this.to)this._line(g,t,A);else{var i=lh(this._getCircleData(g),3),o=i[0],n=i[1],r=i[2];this._circle(g,t,o,n,r)}g.setLineDash([0]),g.lineDashOffset=0,g.restore()}else{if(this.from!=this.to)Qe(g,this.from.x,this.from.y,this.to.x,this.to.y,I);else{var s=lh(this._getCircleData(g),3),a=s[0],d=s[1],h=s[2];this._circle(g,t,a,d,h)}this.enableShadow(g,t),g.stroke(),this.disableShadow(g,t)}}},{key:"findBorderPosition",value:function(g,t,A){return this.from!=this.to?this._findBorderPosition(g,t,A):this._findBorderPositionCircle(g,t,A)}},{key:"findBorderPositions",value:function(g){if(this.from!=this.to)return{from:this._findBorderPosition(this.from,g),to:this._findBorderPosition(this.to,g)};var t,A=lh(wh(t=this._getCircleData(g)).call(t,0,2),2),e=A[0],C=A[1];return{from:this._findBorderPositionCircle(this.from,g,{x:e,y:C,low:.25,high:.6,direction:-1}),to:this._findBorderPositionCircle(this.from,g,{x:e,y:C,low:.6,high:.8,direction:1})}}},{key:"_getCircleData",value:function(g){var t=this.options.selfReference.size;void 0!==g&&void 0===this.from.shape.width&&this.from.shape.resize(g);var A=UD(g,this.options.selfReference.angle,t,this.from);return[A.x,A.y,t]}},{key:"_pointOnCircle",value:function(g,t,A,e){var C=2*e*Math.PI;return{x:g+A*Math.cos(C),y:t-A*Math.sin(C)}}},{key:"_findBorderPositionCircle",value:function(g,t,A){var e,C=A.x,I=A.y,i=A.low,o=A.high,n=A.direction,r=this.options.selfReference.size,s=.5*(i+o),a=0;!0===this.options.arrowStrikethrough&&(-1===n?a=this.options.endPointOffset.from:1===n&&(a=this.options.endPointOffset.to));var d=0;do{s=.5*(i+o),e=this._pointOnCircle(C,I,r,s);var h=Math.atan2(g.y-e.y,g.x-e.x),l=g.distanceToBorder(t,h)+a-Math.sqrt(Math.pow(e.x-g.x,2)+Math.pow(e.y-g.y,2));if(Math.abs(l)<.05)break;l>0?n>0?i=s:o=s:n>0?o=s:i=s,++d}while(i<=o&&d<10);return mR(mR({},e),{},{t:s})}},{key:"getLineWidth",value:function(g,t){return!0===g?Math.max(this.selectionWidth,.3/this._body.view.scale):!0===t?Math.max(this.hoverWidth,.3/this._body.view.scale):Math.max(this.options.width,.3/this._body.view.scale)}},{key:"getColor",value:function(g,t){if(!1!==t.inheritsColor){if("both"===t.inheritsColor&&this.from.id!==this.to.id){var A=g.createLinearGradient(this.from.x,this.from.y,this.to.x,this.to.y),e=this.from.options.color.highlight.border,C=this.to.options.color.highlight.border;return!1===this.from.selected&&!1===this.to.selected?(e=ev(this.from.options.color.border,t.opacity),C=ev(this.to.options.color.border,t.opacity)):!0===this.from.selected&&!1===this.to.selected?C=this.to.options.color.border:!1===this.from.selected&&!0===this.to.selected&&(e=this.from.options.color.border),A.addColorStop(0,e),A.addColorStop(1,C),A}return"to"===t.inheritsColor?ev(this.to.options.color.border,t.opacity):ev(this.from.options.color.border,t.opacity)}return ev(t.color,t.opacity)}},{key:"_circle",value:function(g,t,A,e,C){this.enableShadow(g,t);var I=0,i=2*Math.PI;if(!this.options.selfReference.renderBehindTheNode){var o=this.options.selfReference.angle,n=this.options.selfReference.angle+Math.PI,r=this._findBorderPositionCircle(this.from,g,{x:A,y:e,low:o,high:n,direction:-1}),s=this._findBorderPositionCircle(this.from,g,{x:A,y:e,low:o,high:n,direction:1});I=Math.atan2(r.y-e,r.x-A),i=Math.atan2(s.y-e,s.x-A)}g.beginPath(),g.arc(A,e,C,I,i,!1),g.stroke(),this.disableShadow(g,t)}},{key:"getDistanceToEdge",value:function(g,t,A,e,C,I){if(this.from!=this.to)return this._getDistanceToEdge(g,t,A,e,C,I);var i=lh(this._getCircleData(void 0),3),o=i[0],n=i[1],r=i[2],s=o-C,a=n-I;return Math.abs(Math.sqrt(s*s+a*a)-r)}},{key:"_getDistanceToLine",value:function(g,t,A,e,C,I){var i=A-g,o=e-t,n=((C-g)*i+(I-t)*o)/(i*i+o*o);n>1?n=1:n<0&&(n=0);var r=g+n*i-C,s=t+n*o-I;return Math.sqrt(r*r+s*s)}},{key:"getArrowData",value:function(g,t,A,e,C,I){var i,o,n,r,s,a,d,h=I.width;"from"===t?(n=this.from,r=this.to,s=I.fromArrowScale<0,a=Math.abs(I.fromArrowScale),d=I.fromArrowType):"to"===t?(n=this.to,r=this.from,s=I.toArrowScale<0,a=Math.abs(I.toArrowScale),d=I.toArrowType):(n=this.to,r=this.from,s=I.middleArrowScale<0,a=Math.abs(I.middleArrowScale),d=I.middleArrowType);var l=15*a+3*h;if(n!=r){var c=l/CR(n.x-r.x,n.y-r.y);if("middle"!==t)if(!0===this.options.smooth.enabled){var u=this._findBorderPosition(n,g,{via:A}),p=this.getPoint(u.t+c*("from"===t?1:-1),A);i=Math.atan2(u.y-p.y,u.x-p.x),o=u}else i=Math.atan2(n.y-r.y,n.x-r.x),o=this._findBorderPosition(n,g);else{var f=(s?-c:c)/2,v=this.getPoint(.5+f,A),y=this.getPoint(.5-f,A);i=Math.atan2(v.y-y.y,v.x-y.x),o=this.getPoint(.5,A)}}else{var m=lh(this._getCircleData(g),3),b=m[0],w=m[1],k=m[2];if("from"===t){var x=this.options.selfReference.angle,E=this.options.selfReference.angle+Math.PI,O=this._findBorderPositionCircle(this.from,g,{x:b,y:w,low:x,high:E,direction:-1});i=-2*O.t*Math.PI+1.5*Math.PI+.1*Math.PI,o=O}else if("to"===t){var T=this.options.selfReference.angle,D=this.options.selfReference.angle+Math.PI,N=this._findBorderPositionCircle(this.from,g,{x:b,y:w,low:T,high:D,direction:1});i=-2*N.t*Math.PI+1.5*Math.PI-1.1*Math.PI,o=N}else{var R=this.options.selfReference.angle/(2*Math.PI);o=this._pointOnCircle(b,w,k,R),i=-2*R*Math.PI+1.5*Math.PI+.1*Math.PI}}return{point:o,core:{x:o.x-.9*l*Math.cos(i),y:o.y-.9*l*Math.sin(i)},angle:i,length:l,type:d}}},{key:"drawArrowHead",value:function(g,t,A,e,C){g.strokeStyle=this.getColor(g,t),g.fillStyle=g.strokeStyle,g.lineWidth=t.width,vR.draw(g,C)&&(this.enableShadow(g,t),Bu(g).call(g),this.disableShadow(g,t))}},{key:"enableShadow",value:function(g,t){!0===t.shadow&&(g.shadowColor=t.shadowColor,g.shadowBlur=t.shadowSize,g.shadowOffsetX=t.shadowX,g.shadowOffsetY=t.shadowY)}},{key:"disableShadow",value:function(g,t){!0===t.shadow&&(g.shadowColor="rgba(0,0,0,0)",g.shadowBlur=0,g.shadowOffsetX=0,g.shadowOffsetY=0)}},{key:"drawBackground",value:function(g,t){if(!1!==t.background){var A={strokeStyle:g.strokeStyle,lineWidth:g.lineWidth,dashes:g.dashes};g.strokeStyle=t.backgroundColor,g.lineWidth=t.backgroundSize,this.setStrokeDashed(g,t.backgroundDashes),g.stroke(),g.strokeStyle=A.strokeStyle,g.lineWidth=A.lineWidth,g.dashes=A.dashes,this.setStrokeDashed(g,t.dashes)}}},{key:"setStrokeDashed",value:function(g,t){if(!1!==t)if(void 0!==g.setLineDash){var A=Rh(t)?t:[5,5];g.setLineDash(A)}else console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.");else void 0!==g.setLineDash?g.setLineDash([]):console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.")}}]),g}();function wR(g,t){var A=Lh(g);if(BT){var e=BT(g);t&&(e=pc(e).call(e,(function(t){return WT(g,t).enumerable}))),A.push.apply(A,e)}return A}function kR(g){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:this._getViaCoordinates(),I=!1,i=1,o=0,n=this.to,r=this.options.endPointOffset?this.options.endPointOffset.to:0;g.id===this.from.id&&(n=this.from,I=!0,r=this.options.endPointOffset?this.options.endPointOffset.from:0),!1===this.options.arrowStrikethrough&&(r=0);var s=0;do{e=.5*(o+i),A=this.getPoint(e,C);var a=Math.atan2(n.y-A.y,n.x-A.x),d=n.distanceToBorder(t,a)+r-Math.sqrt(Math.pow(A.x-n.x,2)+Math.pow(A.y-n.y,2));if(Math.abs(d)<.2)break;d<0?!1===I?o=e:i=e:!1===I?i=e:o=e,++s}while(o<=i&&s<10);return kR(kR({},A),{},{t:e})}},{key:"_getDistanceToBezierEdge",value:function(g,t,A,e,C,I,i){var o,n,r,s,a,d=1e9,h=g,l=t;for(n=1;n<10;n++)r=.1*n,s=Math.pow(1-r,2)*g+2*r*(1-r)*i.x+Math.pow(r,2)*A,a=Math.pow(1-r,2)*t+2*r*(1-r)*i.y+Math.pow(r,2)*e,n>0&&(d=(o=this._getDistanceToLine(h,l,s,a,C,I))1&&void 0!==arguments[1]?arguments[1]:this.via;if(this.from===this.to){var A=lh(this._getCircleData(),3),e=A[0],C=A[1],I=A[2],i=2*Math.PI*(1-g);return{x:e+I*Math.sin(i),y:C+I-I*(1-Math.cos(i))}}return{x:Math.pow(1-g,2)*this.fromPoint.x+2*g*(1-g)*t.x+Math.pow(g,2)*this.toPoint.x,y:Math.pow(1-g,2)*this.fromPoint.y+2*g*(1-g)*t.y+Math.pow(g,2)*this.toPoint.y}}},{key:"_findBorderPosition",value:function(g,t){return this._findBorderPositionBezier(g,t,this.via)}},{key:"_getDistanceToEdge",value:function(g,t,A,e,C,I){return this._getDistanceToBezierEdge(g,t,A,e,C,I,this.via)}}]),A}(ER);function DR(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var NR=function(g){Cb(A,g);var t=DR(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"_line",value:function(g,t,A){this._bezierCurve(g,t,A)}},{key:"getViaNode",value:function(){return this._getViaCoordinates()}},{key:"_getViaCoordinates",value:function(){var g,t,A=this.options.smooth.roundness,e=this.options.smooth.type,C=Math.abs(this.from.x-this.to.x),I=Math.abs(this.from.y-this.to.y);if("discrete"===e||"diagonalCross"===e){var i,o;i=o=C<=I?A*I:A*C,this.from.x>this.to.x&&(i=-i),this.from.y>=this.to.y&&(o=-o);var n=this.from.x+i,r=this.from.y+o;return"discrete"===e&&(C<=I?n=Cthis.to.x&&(g=-g),this.from.y>=this.to.y&&(t=-t);var y=this.from.x+g,m=this.from.y+t;return C<=I?y=this.from.x<=this.to.x?this.to.xy?this.to.x:y:m=this.from.y>=this.to.y?this.to.y>m?this.to.y:m:this.to.y2&&void 0!==arguments[2]?arguments[2]:{};return this._findBorderPositionBezier(g,t,A.via)}},{key:"_getDistanceToEdge",value:function(g,t,A,e,C,I){var i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this._getViaCoordinates();return this._getDistanceToBezierEdge(g,t,A,e,C,I,i)}},{key:"getPoint",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getViaCoordinates(),A=g;return{x:Math.pow(1-A,2)*this.fromPoint.x+2*A*(1-A)*t.x+Math.pow(A,2)*this.toPoint.x,y:Math.pow(1-A,2)*this.fromPoint.y+2*A*(1-A)*t.y+Math.pow(A,2)*this.toPoint.y}}}]),A}(ER);function RR(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var PR=function(g){Cb(A,g);var t=RR(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"_getDistanceToBezierEdge2",value:function(g,t,A,e,C,I,i,o){for(var n=1e9,r=g,s=t,a=[0,0,0,0],d=1;d<10;d++){var h=.1*d;a[0]=Math.pow(1-h,3),a[1]=3*h*Math.pow(1-h,2),a[2]=3*Math.pow(h,2)*(1-h),a[3]=Math.pow(h,3);var l=a[0]*g+a[1]*i.x+a[2]*o.x+a[3]*A,c=a[0]*t+a[1]*i.y+a[2]*o.y+a[3]*e;if(d>0){var u=this._getDistanceToLine(r,s,l,c,C,I);n=uMath.abs(I)||!0===this.options.smooth.forceDirection||"horizontal"===this.options.smooth.forceDirection)&&"vertical"!==this.options.smooth.forceDirection?(t=this.from.y,e=this.to.y,g=this.from.x-i*C,A=this.to.x+i*C):(t=this.from.y-i*I,e=this.to.y+i*I,g=this.from.x,A=this.to.x),[{x:g,y:t},{x:A,y:e}]}},{key:"getViaNode",value:function(){return this._getViaCoordinates()}},{key:"_findBorderPosition",value:function(g,t){return this._findBorderPositionBezier(g,t)}},{key:"_getDistanceToEdge",value:function(g,t,A,e,C,I){var i=lh(arguments.length>6&&void 0!==arguments[6]?arguments[6]:this._getViaCoordinates(),2),o=i[0],n=i[1];return this._getDistanceToBezierEdge2(g,t,A,e,C,I,o,n)}},{key:"getPoint",value:function(g){var t=lh(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getViaCoordinates(),2),A=t[0],e=t[1],C=g,I=[Math.pow(1-C,3),3*C*Math.pow(1-C,2),3*Math.pow(C,2)*(1-C),Math.pow(C,3)];return{x:I[0]*this.fromPoint.x+I[1]*A.x+I[2]*e.x+I[3]*this.toPoint.x,y:I[0]*this.fromPoint.y+I[1]*A.y+I[2]*e.y+I[3]*this.toPoint.y}}}]),A}(PR);function zR(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var SR=function(g){Cb(A,g);var t=zR(A);function A(g,e,C){return cn(this,A),t.call(this,g,e,C)}return kd(A,[{key:"_line",value:function(g,t){g.beginPath(),g.moveTo(this.fromPoint.x,this.fromPoint.y),g.lineTo(this.toPoint.x,this.toPoint.y),this.enableShadow(g,t),g.stroke(),this.disableShadow(g,t)}},{key:"getViaNode",value:function(){}},{key:"getPoint",value:function(g){return{x:(1-g)*this.fromPoint.x+g*this.toPoint.x,y:(1-g)*this.fromPoint.y+g*this.toPoint.y}}},{key:"_findBorderPosition",value:function(g,t){var A=this.to,e=this.from;g.id===this.from.id&&(A=this.from,e=this.to);var C=Math.atan2(A.y-e.y,A.x-e.x),I=A.x-e.x,i=A.y-e.y,o=Math.sqrt(I*I+i*i),n=(o-g.distanceToBorder(t,C))/o;return{x:(1-n)*e.x+n*A.x,y:(1-n)*e.y+n*A.y,t:0}}},{key:"_getDistanceToEdge",value:function(g,t,A,e,C,I){return this._getDistanceToLine(g,t,A,e,C,I)}}]),A}(bR),ZR=function(){function g(t,A,e,C,I){if(cn(this,g),void 0===A)throw new Error("No body provided");this.options=av(C),this.globalOptions=C,this.defaultOptions=I,this.body=A,this.imagelist=e,this.id=void 0,this.fromId=void 0,this.toId=void 0,this.selected=!1,this.hover=!1,this.labelDirty=!0,this.baseWidth=this.options.width,this.baseFontSize=this.options.font.size,this.from=void 0,this.to=void 0,this.edgeType=void 0,this.connected=!1,this.labelModule=new qD(this.body,this.options,!0),this.setOptions(t)}return kd(g,[{key:"setOptions",value:function(t){if(t){var A=void 0!==t.physics&&this.options.physics!==t.physics||void 0!==t.hidden&&(this.options.hidden||!1)!==(t.hidden||!1)||void 0!==t.from&&this.options.from!==t.from||void 0!==t.to&&this.options.to!==t.to;g.parseOptions(this.options,t,!0,this.globalOptions),void 0!==t.id&&(this.id=t.id),void 0!==t.from&&(this.fromId=t.from),void 0!==t.to&&(this.toId=t.to),void 0!==t.title&&(this.title=t.title),void 0!==t.value&&(t.value=SD(t.value));var e=[t,this.options,this.defaultOptions];return this.chooser=YD("edge",e),this.updateLabelModule(t),A=this.updateEdgeType()||A,this._setInteractionWidths(),this.connect(),A}}},{key:"getFormattingValues",value:function(){var g=!0===this.options.arrows.to||!0===this.options.arrows.to.enabled,t=!0===this.options.arrows.from||!0===this.options.arrows.from.enabled,A=!0===this.options.arrows.middle||!0===this.options.arrows.middle.enabled,e=this.options.color.inherit,C={toArrow:g,toArrowScale:this.options.arrows.to.scaleFactor,toArrowType:this.options.arrows.to.type,toArrowSrc:this.options.arrows.to.src,toArrowImageWidth:this.options.arrows.to.imageWidth,toArrowImageHeight:this.options.arrows.to.imageHeight,middleArrow:A,middleArrowScale:this.options.arrows.middle.scaleFactor,middleArrowType:this.options.arrows.middle.type,middleArrowSrc:this.options.arrows.middle.src,middleArrowImageWidth:this.options.arrows.middle.imageWidth,middleArrowImageHeight:this.options.arrows.middle.imageHeight,fromArrow:t,fromArrowScale:this.options.arrows.from.scaleFactor,fromArrowType:this.options.arrows.from.type,fromArrowSrc:this.options.arrows.from.src,fromArrowImageWidth:this.options.arrows.from.imageWidth,fromArrowImageHeight:this.options.arrows.from.imageHeight,arrowStrikethrough:this.options.arrowStrikethrough,color:e?void 0:this.options.color.color,inheritsColor:e,opacity:this.options.color.opacity,hidden:this.options.hidden,length:this.options.length,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y,dashes:this.options.dashes,width:this.options.width,background:this.options.background.enabled,backgroundColor:this.options.background.color,backgroundSize:this.options.background.size,backgroundDashes:this.options.background.dashes};if(this.selected||this.hover)if(!0===this.chooser){if(this.selected){var I=this.options.selectionWidth;"function"==typeof I?C.width=I(C.width):"number"==typeof I&&(C.width+=I),C.width=Math.max(C.width,.3/this.body.view.scale),C.color=this.options.color.highlight,C.shadow=this.options.shadow.enabled}else if(this.hover){var i=this.options.hoverWidth;"function"==typeof i?C.width=i(C.width):"number"==typeof i&&(C.width+=i),C.width=Math.max(C.width,.3/this.body.view.scale),C.color=this.options.color.hover,C.shadow=this.options.shadow.enabled}}else"function"==typeof this.chooser&&(this.chooser(C,this.options.id,this.selected,this.hover),void 0!==C.color&&(C.inheritsColor=!1),!1===C.shadow&&(C.shadowColor===this.options.shadow.color&&C.shadowSize===this.options.shadow.size&&C.shadowX===this.options.shadow.x&&C.shadowY===this.options.shadow.y||(C.shadow=!0)));else C.shadow=this.options.shadow.enabled,C.width=Math.max(C.width,.3/this.body.view.scale);return C}},{key:"updateLabelModule",value:function(g){var t=[g,this.options,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,t),void 0!==this.labelModule.baseSize&&(this.baseFontSize=this.labelModule.baseSize)}},{key:"updateEdgeType",value:function(){var g=this.options.smooth,t=!1,A=!0;return void 0!==this.edgeType&&((this.edgeType instanceof TR&&!0===g.enabled&&"dynamic"===g.type||this.edgeType instanceof BR&&!0===g.enabled&&"cubicBezier"===g.type||this.edgeType instanceof NR&&!0===g.enabled&&"dynamic"!==g.type&&"cubicBezier"!==g.type||this.edgeType instanceof SR&&!1===g.type.enabled)&&(A=!1),!0===A&&(t=this.cleanup())),!0===A?!0===g.enabled?"dynamic"===g.type?(t=!0,this.edgeType=new TR(this.options,this.body,this.labelModule)):"cubicBezier"===g.type?this.edgeType=new BR(this.options,this.body,this.labelModule):this.edgeType=new NR(this.options,this.body,this.labelModule):this.edgeType=new SR(this.options,this.body,this.labelModule):this.edgeType.setOptions(this.options),t}},{key:"connect",value:function(){this.disconnect(),this.from=this.body.nodes[this.fromId]||void 0,this.to=this.body.nodes[this.toId]||void 0,this.connected=void 0!==this.from&&void 0!==this.to,!0===this.connected?(this.from.attachEdge(this),this.to.attachEdge(this)):(this.from&&this.from.detachEdge(this),this.to&&this.to.detachEdge(this)),this.edgeType.connect()}},{key:"disconnect",value:function(){this.from&&(this.from.detachEdge(this),this.from=void 0),this.to&&(this.to.detachEdge(this),this.to=void 0),this.connected=!1}},{key:"getTitle",value:function(){return this.title}},{key:"isSelected",value:function(){return this.selected}},{key:"getValue",value:function(){return this.options.value}},{key:"setValueRange",value:function(g,t,A){if(void 0!==this.options.value){var e=this.options.scaling.customScalingFunction(g,t,A,this.options.value),C=this.options.scaling.max-this.options.scaling.min;if(!0===this.options.scaling.label.enabled){var I=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+e*I}this.options.width=this.options.scaling.min+e*C}else this.options.width=this.baseWidth,this.options.font.size=this.baseFontSize;this._setInteractionWidths(),this.updateLabelModule()}},{key:"_setInteractionWidths",value:function(){"function"==typeof this.options.hoverWidth?this.edgeType.hoverWidth=this.options.hoverWidth(this.options.width):this.edgeType.hoverWidth=this.options.hoverWidth+this.options.width,"function"==typeof this.options.selectionWidth?this.edgeType.selectionWidth=this.options.selectionWidth(this.options.width):this.edgeType.selectionWidth=this.options.selectionWidth+this.options.width}},{key:"draw",value:function(g){var t=this.getFormattingValues();if(!t.hidden){var A=this.edgeType.getViaNode();this.edgeType.drawLine(g,t,this.selected,this.hover,A),this.drawLabel(g,A)}}},{key:"drawArrows",value:function(g){var t=this.getFormattingValues();if(!t.hidden){var A=this.edgeType.getViaNode(),e={};this.edgeType.fromPoint=this.edgeType.from,this.edgeType.toPoint=this.edgeType.to,t.fromArrow&&(e.from=this.edgeType.getArrowData(g,"from",A,this.selected,this.hover,t),!1===t.arrowStrikethrough&&(this.edgeType.fromPoint=e.from.core),t.fromArrowSrc&&(e.from.image=this.imagelist.load(t.fromArrowSrc)),t.fromArrowImageWidth&&(e.from.imageWidth=t.fromArrowImageWidth),t.fromArrowImageHeight&&(e.from.imageHeight=t.fromArrowImageHeight)),t.toArrow&&(e.to=this.edgeType.getArrowData(g,"to",A,this.selected,this.hover,t),!1===t.arrowStrikethrough&&(this.edgeType.toPoint=e.to.core),t.toArrowSrc&&(e.to.image=this.imagelist.load(t.toArrowSrc)),t.toArrowImageWidth&&(e.to.imageWidth=t.toArrowImageWidth),t.toArrowImageHeight&&(e.to.imageHeight=t.toArrowImageHeight)),t.middleArrow&&(e.middle=this.edgeType.getArrowData(g,"middle",A,this.selected,this.hover,t),t.middleArrowSrc&&(e.middle.image=this.imagelist.load(t.middleArrowSrc)),t.middleArrowImageWidth&&(e.middle.imageWidth=t.middleArrowImageWidth),t.middleArrowImageHeight&&(e.middle.imageHeight=t.middleArrowImageHeight)),t.fromArrow&&this.edgeType.drawArrowHead(g,t,this.selected,this.hover,e.from),t.middleArrow&&this.edgeType.drawArrowHead(g,t,this.selected,this.hover,e.middle),t.toArrow&&this.edgeType.drawArrowHead(g,t,this.selected,this.hover,e.to)}}},{key:"drawLabel",value:function(g,t){if(void 0!==this.options.label){var A,e=this.from,C=this.to;if(this.labelModule.differentState(this.selected,this.hover)&&this.labelModule.getTextSize(g,this.selected,this.hover),e.id!=C.id){this.labelModule.pointToSelf=!1,A=this.edgeType.getPoint(.5,t),g.save();var I=this._getRotation(g);0!=I.angle&&(g.translate(I.x,I.y),g.rotate(I.angle)),this.labelModule.draw(g,A.x,A.y,this.selected,this.hover),g.restore()}else{this.labelModule.pointToSelf=!0;var i=UD(g,this.options.selfReference.angle,this.options.selfReference.size,e);A=this._pointOnCircle(i.x,i.y,this.options.selfReference.size,this.options.selfReference.angle),this.labelModule.draw(g,A.x,A.y,this.selected,this.hover)}}}},{key:"getItemsOnPoint",value:function(g){var t=[];if(this.labelModule.visible()){var A=this._getRotation();WD(this.labelModule.getSize(),g,A)&&t.push({edgeId:this.id,labelId:0})}var e={left:g.x,top:g.y};return this.isOverlappingWith(e)&&t.push({edgeId:this.id}),t}},{key:"isOverlappingWith",value:function(g){if(this.connected){var t=this.from.x,A=this.from.y,e=this.to.x,C=this.to.y,I=g.left,i=g.top;return this.edgeType.getDistanceToEdge(t,A,e,C,I,i)<10}return!1}},{key:"_getRotation",value:function(g){var t=this.edgeType.getViaNode(),A=this.edgeType.getPoint(.5,t);void 0!==g&&this.labelModule.calculateLabelSize(g,this.selected,this.hover,A.x,A.y);var e={x:A.x,y:this.labelModule.size.yLine,angle:0};if(!this.labelModule.visible())return e;if("horizontal"===this.options.font.align)return e;var C=this.from.y-this.to.y,I=this.from.x-this.to.x,i=Math.atan2(C,I);return(i<-1&&I<0||i>0&&I<0)&&(i+=Math.PI),e.angle=i,e}},{key:"_pointOnCircle",value:function(g,t,A,e){return{x:g+A*Math.cos(e),y:t-A*Math.sin(e)}}},{key:"select",value:function(){this.selected=!0}},{key:"unselect",value:function(){this.selected=!1}},{key:"cleanup",value:function(){return this.edgeType.cleanup()}},{key:"remove",value:function(){this.cleanup(),this.disconnect(),delete this.body.edges[this.id]}},{key:"endPointsValid",value:function(){return void 0!==this.body.nodes[this.fromId]&&void 0!==this.body.nodes[this.toId]}}],[{key:"parseOptions",value:function(g,t){var A=arguments.length>2&&void 0!==arguments[2]&&arguments[2],e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},C=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Xf(["endPointOffset","arrowStrikethrough","id","from","hidden","hoverWidth","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","selfReference","to","title","value","width","font","chosen","widthConstraint"],g,t,A),void 0!==t.endPointOffset&&void 0!==t.endPointOffset.from&&(Ym(t.endPointOffset.from)?g.endPointOffset.from=t.endPointOffset.from:(g.endPointOffset.from=void 0!==e.endPointOffset.from?e.endPointOffset.from:0,console.error("endPointOffset.from is not a valid number"))),void 0!==t.endPointOffset&&void 0!==t.endPointOffset.to&&(Ym(t.endPointOffset.to)?g.endPointOffset.to=t.endPointOffset.to:(g.endPointOffset.to=void 0!==e.endPointOffset.to?e.endPointOffset.to:0,console.error("endPointOffset.to is not a valid number"))),QD(t.label)?g.label=t.label:QD(g.label)||(g.label=void 0),dv(g,t,"smooth",e),dv(g,t,"shadow",e),dv(g,t,"background",e),void 0!==t.dashes&&null!==t.dashes?g.dashes=t.dashes:!0===A&&null===t.dashes&&(g.dashes=$c(e.dashes)),void 0!==t.scaling&&null!==t.scaling?(void 0!==t.scaling.min&&(g.scaling.min=t.scaling.min),void 0!==t.scaling.max&&(g.scaling.max=t.scaling.max),dv(g.scaling,t.scaling,"label",e.scaling)):!0===A&&null===t.scaling&&(g.scaling=$c(e.scaling)),void 0!==t.arrows&&null!==t.arrows)if("string"==typeof t.arrows){var I=t.arrows.toLowerCase();g.arrows.to.enabled=-1!=Xc(I).call(I,"to"),g.arrows.middle.enabled=-1!=Xc(I).call(I,"middle"),g.arrows.from.enabled=-1!=Xc(I).call(I,"from")}else{if("object"!==yd(t.arrows))throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:"+eu(t.arrows));dv(g.arrows,t.arrows,"to",e.arrows),dv(g.arrows,t.arrows,"middle",e.arrows),dv(g.arrows,t.arrows,"from",e.arrows)}else!0===A&&null===t.arrows&&(g.arrows=$c(e.arrows));if(void 0!==t.color&&null!==t.color){var i=Uf(t.color)?{color:t.color,highlight:t.color,hover:t.color,inherit:!1,opacity:1}:t.color,o=g.color;if(C)qf(o,e.color,!1,A);else for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&delete o[n];if(Uf(o))o.color=o,o.highlight=o,o.hover=o,o.inherit=!1,void 0===i.opacity&&(o.opacity=1);else{var r=!1;void 0!==i.color&&(o.color=i.color,r=!0),void 0!==i.highlight&&(o.highlight=i.highlight,r=!0),void 0!==i.hover&&(o.hover=i.hover,r=!0),void 0!==i.inherit&&(o.inherit=i.inherit),void 0!==i.opacity&&(o.opacity=Math.min(1,Math.max(0,i.opacity))),!0===r?o.inherit=!1:void 0===o.inherit&&(o.inherit="from")}}else!0===A&&null===t.color&&(g.color=av(e.color));!0===A&&null===t.font&&(g.font=av(e.font)),Object.prototype.hasOwnProperty.call(t,"selfReferenceSize")&&(console.warn("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}"),g.selfReference.size=t.selfReferenceSize)}}]),g}(),FR=function(){function g(t,A,e){var C,I=this;cn(this,g),this.body=t,this.images=A,this.groups=e,this.body.functions.createEdge=je(C=this.create).call(C,this),this.edgesListeners={add:function(g,t){I.add(t.items)},update:function(g,t){I.update(t.items)},remove:function(g,t){I.remove(t.items)}},this.options={},this.defaultOptions={arrows:{to:{enabled:!1,scaleFactor:1,type:"arrow"},middle:{enabled:!1,scaleFactor:1,type:"arrow"},from:{enabled:!1,scaleFactor:1,type:"arrow"}},endPointOffset:{from:0,to:0},arrowStrikethrough:!0,color:{color:"#848484",highlight:"#848484",hover:"#848484",inherit:"from",opacity:1},dashes:!1,font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:2,strokeColor:"#ffffff",align:"horizontal",multi:!1,vadjust:0,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"courier new",vadjust:2}},hidden:!1,hoverWidth:1.5,label:void 0,labelHighlightBold:!0,length:void 0,physics:!0,scaling:{min:1,max:15,label:{enabled:!0,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(g,t,A,e){if(t===g)return.5;var C=1/(t-g);return Math.max(0,(e-g)*C)}},selectionWidth:1.5,selfReference:{size:20,angle:Math.PI/4,renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},background:{enabled:!1,color:"rgba(111,111,111,1)",size:10,dashes:!1},smooth:{enabled:!0,type:"dynamic",forceDirection:"none",roundness:.5},title:void 0,width:1,value:void 0},qf(this.options,this.defaultOptions),this.bindEventListeners()}return kd(g,[{key:"bindEventListeners",value:function(){var g,t,A=this;this.body.emitter.on("_forceDisableDynamicCurves",(function(g){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"dynamic"===g&&(g="continuous");var e=!1;for(var C in A.body.edges)if(Object.prototype.hasOwnProperty.call(A.body.edges,C)){var I=A.body.edges[C],i=A.body.data.edges.get(C);if(null!=i){var o=i.smooth;void 0!==o&&!0===o.enabled&&"dynamic"===o.type&&(void 0===g?I.setOptions({smooth:!1}):I.setOptions({smooth:{type:g}}),e=!0)}}!0===t&&!0===e&&A.body.emitter.emit("_dataChanged")})),this.body.emitter.on("_dataUpdated",(function(){A.reconnectEdges()})),this.body.emitter.on("refreshEdges",je(g=this.refresh).call(g,this)),this.body.emitter.on("refresh",je(t=this.refresh).call(t,this)),this.body.emitter.on("destroy",(function(){tv(A.edgesListeners,(function(g,t){A.body.data.edges&&A.body.data.edges.off(t,g)})),delete A.body.functions.createEdge,delete A.edgesListeners.add,delete A.edgesListeners.update,delete A.edgesListeners.remove,delete A.edgesListeners}))}},{key:"setOptions",value:function(g){if(void 0!==g){ZR.parseOptions(this.options,g,!0,this.defaultOptions,!0);var t=!1;if(void 0!==g.smooth)for(var A in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,A)&&(t=this.body.edges[A].updateEdgeType()||t);if(void 0!==g.font)for(var e in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,e)&&this.body.edges[e].updateLabelModule();void 0===g.hidden&&void 0===g.physics&&!0!==t||this.body.emitter.emit("_dataChanged")}}},{key:"setData",value:function(g){var t=this,A=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.body.data.edges;if(kD("id",g))this.body.data.edges=g;else if(Rh(g))this.body.data.edges=new mD,this.body.data.edges.add(g);else{if(g)throw new TypeError("Array or DataSet expected");this.body.data.edges=new mD}if(e&&tv(this.edgesListeners,(function(g,t){e.off(t,g)})),this.body.edges={},this.body.data.edges){tv(this.edgesListeners,(function(g,A){t.body.data.edges.on(A,g)}));var C=this.body.data.edges.getIds();this.add(C,!0)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),!1===A&&this.body.emitter.emit("_dataChanged")}},{key:"add",value:function(g){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],A=this.body.edges,e=this.body.data.edges,C=0;C1&&void 0!==arguments[1])||arguments[1];if(0!==g.length){var A=this.body.edges;tv(g,(function(g){var t=A[g];void 0!==t&&t.remove()})),t&&this.body.emitter.emit("_dataChanged")}}},{key:"refresh",value:function(){var g=this;tv(this.body.edges,(function(t,A){var e=g.body.data.edges.get(A);void 0!==e&&t.setOptions(e)}))}},{key:"create",value:function(g){return new ZR(g,this.body,this.images,this.options,this.defaultOptions)}},{key:"reconnectEdges",value:function(){var g,t=this.body.nodes,A=this.body.edges;for(g in t)Object.prototype.hasOwnProperty.call(t,g)&&(t[g].edges=[]);for(g in A)if(Object.prototype.hasOwnProperty.call(A,g)){var e=A[g];e.from=null,e.to=null,e.connect()}}},{key:"getConnectedNodes",value:function(g){var t=[];if(void 0!==this.body.edges[g]){var A=this.body.edges[g];void 0!==A.fromId&&t.push(A.fromId),void 0!==A.toId&&t.push(A.toId)}return t}},{key:"_updateState",value:function(){this._addMissingEdges(),this._removeInvalidEdges()}},{key:"_removeInvalidEdges",value:function(){var g=this,t=[];tv(this.body.edges,(function(A,e){var C=g.body.nodes[A.toId],I=g.body.nodes[A.fromId];void 0!==C&&!0===C.isCluster||void 0!==I&&!0===I.isCluster||void 0!==C&&void 0!==I||t.push(e)})),this.remove(t,!1)}},{key:"_addMissingEdges",value:function(){var g=this.body.data.edges;if(null!=g){var t=this.body.edges,A=[];Cl(g).call(g,(function(g,e){void 0===t[e]&&A.push(e)})),this.add(A,!0)}}}]),g}(),GR=function(){function g(t,A,e){cn(this,g),this.body=t,this.physicsBody=A,this.barnesHutTree,this.setOptions(e),this._rng=Ff("BARNES HUT SOLVER")}return kd(g,[{key:"setOptions",value:function(g){this.options=g,this.thetaInversed=1/this.options.theta,this.overlapAvoidanceFactor=1-Math.max(0,Math.min(1,this.options.avoidOverlap))}},{key:"solve",value:function(){if(0!==this.options.gravitationalConstant&&this.physicsBody.physicsNodeIndices.length>0){var g,t=this.body.nodes,A=this.physicsBody.physicsNodeIndices,e=A.length,C=this._formBarnesHutTree(t,A);this.barnesHutTree=C;for(var I=0;I0&&this._getForceContributions(C.root,g)}}},{key:"_getForceContributions",value:function(g,t){this._getForceContribution(g.children.NW,t),this._getForceContribution(g.children.NE,t),this._getForceContribution(g.children.SW,t),this._getForceContribution(g.children.SE,t)}},{key:"_getForceContribution",value:function(g,t){if(g.childrenCount>0){var A=g.centerOfMass.x-t.x,e=g.centerOfMass.y-t.y,C=Math.sqrt(A*A+e*e);C*g.calcSize>this.thetaInversed?this._calculateForces(C,A,e,t,g):4===g.childrenCount?this._getForceContributions(g,t):g.children.data.id!=t.id&&this._calculateForces(C,A,e,t,g)}}},{key:"_calculateForces",value:function(g,t,A,e,C){0===g&&(t=g=.1),this.overlapAvoidanceFactor<1&&e.shape.radius&&(g=Math.max(.1+this.overlapAvoidanceFactor*e.shape.radius,g-e.shape.radius));var I=this.options.gravitationalConstant*C.mass*e.options.mass/Math.pow(g,3),i=t*I,o=A*I;this.physicsBody.forces[e.id].x+=i,this.physicsBody.forces[e.id].y+=o}},{key:"_formBarnesHutTree",value:function(g,t){for(var A,e=t.length,C=g[t[0]].x,I=g[t[0]].y,i=g[t[0]].x,o=g[t[0]].y,n=1;n0&&(si&&(i=s),ao&&(o=a))}var d=Math.abs(i-C)-Math.abs(o-I);d>0?(I-=.5*d,o+=.5*d):(C+=.5*d,i-=.5*d);var h=Math.max(1e-5,Math.abs(i-C)),l=.5*h,c=.5*(C+i),u=.5*(I+o),p={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:c-l,maxX:c+l,minY:u-l,maxY:u+l},size:h,calcSize:1/h,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(p.root);for(var f=0;f0&&this._placeInTree(p.root,A);return p}},{key:"_updateBranchMass",value:function(g,t){var A=g.centerOfMass,e=g.mass+t.options.mass,C=1/e;A.x=A.x*g.mass+t.x*t.options.mass,A.x*=C,A.y=A.y*g.mass+t.y*t.options.mass,A.y*=C,g.mass=e;var I=Math.max(Math.max(t.height,t.radius),t.width);g.maxWidth=g.maxWidtht.x?C.maxY>t.y?"NW":"SW":C.maxY>t.y?"NE":"SE",this._placeInRegion(g,t,e)}},{key:"_placeInRegion",value:function(g,t,A){var e=g.children[A];switch(e.childrenCount){case 0:e.children.data=t,e.childrenCount=1,this._updateBranchMass(e,t);break;case 1:e.children.data.x===t.x&&e.children.data.y===t.y?(t.x+=this._rng(),t.y+=this._rng()):(this._splitBranch(e),this._placeInTree(e,t));break;case 4:this._placeInTree(e,t)}}},{key:"_splitBranch",value:function(g){var t=null;1===g.childrenCount&&(t=g.children.data,g.mass=0,g.centerOfMass.x=0,g.centerOfMass.y=0),g.childrenCount=4,g.children.data=null,this._insertRegion(g,"NW"),this._insertRegion(g,"NE"),this._insertRegion(g,"SW"),this._insertRegion(g,"SE"),null!=t&&this._placeInTree(g,t)}},{key:"_insertRegion",value:function(g,t){var A,e,C,I,i=.5*g.size;switch(t){case"NW":A=g.range.minX,e=g.range.minX+i,C=g.range.minY,I=g.range.minY+i;break;case"NE":A=g.range.minX+i,e=g.range.maxX,C=g.range.minY,I=g.range.minY+i;break;case"SW":A=g.range.minX,e=g.range.minX+i,C=g.range.minY+i,I=g.range.maxY;break;case"SE":A=g.range.minX+i,e=g.range.maxX,C=g.range.minY+i,I=g.range.maxY}g.children[t]={centerOfMass:{x:0,y:0},mass:0,range:{minX:A,maxX:e,minY:C,maxY:I},size:.5*g.size,calcSize:2*g.calcSize,children:{data:null},maxWidth:0,level:g.level+1,childrenCount:0}}},{key:"_debug",value:function(g,t){void 0!==this.barnesHutTree&&(g.lineWidth=1,this._drawBranch(this.barnesHutTree.root,g,t))}},{key:"_drawBranch",value:function(g,t,A){void 0===A&&(A="#FF0000"),4===g.childrenCount&&(this._drawBranch(g.children.NW,t),this._drawBranch(g.children.NE,t),this._drawBranch(g.children.SE,t),this._drawBranch(g.children.SW,t)),t.strokeStyle=A,t.beginPath(),t.moveTo(g.range.minX,g.range.minY),t.lineTo(g.range.maxX,g.range.minY),t.stroke(),t.beginPath(),t.moveTo(g.range.maxX,g.range.minY),t.lineTo(g.range.maxX,g.range.maxY),t.stroke(),t.beginPath(),t.moveTo(g.range.maxX,g.range.maxY),t.lineTo(g.range.minX,g.range.maxY),t.stroke(),t.beginPath(),t.moveTo(g.range.minX,g.range.maxY),t.lineTo(g.range.minX,g.range.minY),t.stroke()}}]),g}(),jR=function(){function g(t,A,e){cn(this,g),this._rng=Ff("REPULSION SOLVER"),this.body=t,this.physicsBody=A,this.setOptions(e)}return kd(g,[{key:"setOptions",value:function(g){this.options=g}},{key:"solve",value:function(){for(var g,t,A,e,C,I,i,o,n=this.body.nodes,r=this.physicsBody.physicsNodeIndices,s=this.physicsBody.forces,a=this.options.nodeDistance,d=-2/3/a,h=0;h0){var I=C.edges.length+1,i=this.options.centralGravity*I*C.options.mass;e[C.id].x=t*i,e[C.id].y=A*i}}}]),A}(WR),HR=function(){function g(t){cn(this,g),this.body=t,this.physicsBody={physicsNodeIndices:[],physicsEdgeIndices:[],forces:{},velocities:{}},this.physicsEnabled=!0,this.simulationInterval=1e3/60,this.requiresTimeout=!0,this.previousStates={},this.referenceState={},this.freezeCache={},this.renderTimer=void 0,this.adaptiveTimestep=!1,this.adaptiveTimestepEnabled=!1,this.adaptiveCounter=0,this.adaptiveInterval=3,this.stabilized=!1,this.startedStabilization=!1,this.stabilizationIterations=0,this.ready=!1,this.options={},this.defaultOptions={enabled:!0,barnesHut:{theta:.5,gravitationalConstant:-2e3,centralGravity:.3,springLength:95,springConstant:.04,damping:.09,avoidOverlap:0},forceAtlas2Based:{theta:.5,gravitationalConstant:-50,centralGravity:.01,springConstant:.08,springLength:100,damping:.4,avoidOverlap:0},repulsion:{centralGravity:.2,springLength:200,springConstant:.05,nodeDistance:100,damping:.09,avoidOverlap:0},hierarchicalRepulsion:{centralGravity:0,springLength:100,springConstant:.01,nodeDistance:120,damping:.09},maxVelocity:50,minVelocity:.75,solver:"barnesHut",stabilization:{enabled:!0,iterations:1e3,updateInterval:50,onlyDynamicEdges:!1,fit:!0},timestep:.5,adaptiveTimestep:!0,wind:{x:0,y:0}},fe(this.options,this.defaultOptions),this.timestep=.5,this.layoutFailed=!1,this.bindEventListeners()}return kd(g,[{key:"bindEventListeners",value:function(){var g=this;this.body.emitter.on("initPhysics",(function(){g.initPhysics()})),this.body.emitter.on("_layoutFailed",(function(){g.layoutFailed=!0})),this.body.emitter.on("resetPhysics",(function(){g.stopSimulation(),g.ready=!1})),this.body.emitter.on("disablePhysics",(function(){g.physicsEnabled=!1,g.stopSimulation()})),this.body.emitter.on("restorePhysics",(function(){g.setOptions(g.options),!0===g.ready&&g.startSimulation()})),this.body.emitter.on("startSimulation",(function(){!0===g.ready&&g.startSimulation()})),this.body.emitter.on("stopSimulation",(function(){g.stopSimulation()})),this.body.emitter.on("destroy",(function(){g.stopSimulation(!1),g.body.emitter.off()})),this.body.emitter.on("_dataChanged",(function(){g.updatePhysicsData()}))}},{key:"setOptions",value:function(g){if(void 0!==g)if(!1===g)this.options.enabled=!1,this.physicsEnabled=!1,this.stopSimulation();else if(!0===g)this.options.enabled=!0,this.physicsEnabled=!0,this.startSimulation();else{this.physicsEnabled=!0,Jf(["stabilization"],this.options,g),dv(this.options,g,"stabilization"),void 0===g.enabled&&(this.options.enabled=!0),!1===this.options.enabled&&(this.physicsEnabled=!1,this.stopSimulation());var t=this.options.wind;t&&(("number"!=typeof t.x||jm(t.x))&&(t.x=0),("number"!=typeof t.y||jm(t.y))&&(t.y=0)),this.timestep=this.options.timestep}this.init()}},{key:"init",value:function(){var g;"forceAtlas2Based"===this.options.solver?(g=this.options.forceAtlas2Based,this.nodesSolver=new UR(this.body,this.physicsBody,g),this.edgesSolver=new VR(this.body,this.physicsBody,g),this.gravitySolver=new KR(this.body,this.physicsBody,g)):"repulsion"===this.options.solver?(g=this.options.repulsion,this.nodesSolver=new jR(this.body,this.physicsBody,g),this.edgesSolver=new VR(this.body,this.physicsBody,g),this.gravitySolver=new WR(this.body,this.physicsBody,g)):"hierarchicalRepulsion"===this.options.solver?(g=this.options.hierarchicalRepulsion,this.nodesSolver=new LR(this.body,this.physicsBody,g),this.edgesSolver=new YR(this.body,this.physicsBody,g),this.gravitySolver=new WR(this.body,this.physicsBody,g)):(g=this.options.barnesHut,this.nodesSolver=new GR(this.body,this.physicsBody,g),this.edgesSolver=new VR(this.body,this.physicsBody,g),this.gravitySolver=new WR(this.body,this.physicsBody,g)),this.modelOptions=g}},{key:"initPhysics",value:function(){!0===this.physicsEnabled&&!0===this.options.enabled?!0===this.options.stabilization.enabled?this.stabilize():(this.stabilized=!1,this.ready=!0,this.body.emitter.emit("fit",{},this.layoutFailed),this.startSimulation()):(this.ready=!0,this.body.emitter.emit("fit"))}},{key:"startSimulation",value:function(){var g;!0===this.physicsEnabled&&!0===this.options.enabled?(this.stabilized=!1,this.adaptiveTimestep=!1,this.body.emitter.emit("_resizeNodes"),void 0===this.viewFunction&&(this.viewFunction=je(g=this.simulationStep).call(g,this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))):this.body.emitter.emit("_redraw")}},{key:"stopSimulation",value:function(){var g=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.stabilized=!0,!0===g&&this._emitStabilized(),void 0!==this.viewFunction&&(this.body.emitter.off("initRedraw",this.viewFunction),this.viewFunction=void 0,!0===g&&this.body.emitter.emit("_stopRendering"))}},{key:"simulationStep",value:function(){var g=Qh();this.physicsTick(),(Qh()-g<.4*this.simulationInterval||!0===this.runDoubleSpeed)&&!1===this.stabilized&&(this.physicsTick(),this.runDoubleSpeed=!0),!0===this.stabilized&&this.stopSimulation()}},{key:"_emitStabilized",value:function(){var g=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.stabilizationIterations;(this.stabilizationIterations>1||!0===this.startedStabilization)&&wu((function(){g.body.emitter.emit("stabilized",{iterations:t}),g.startedStabilization=!1,g.stabilizationIterations=0}),0)}},{key:"physicsStep",value:function(){this.gravitySolver.solve(),this.nodesSolver.solve(),this.edgesSolver.solve(),this.moveNodes()}},{key:"adjustTimeStep",value:function(){!0===this._evaluateStepQuality()?this.timestep=1.2*this.timestep:this.timestep/1.2.3))return!1;return!0}},{key:"moveNodes",value:function(){for(var g=this.physicsBody.physicsNodeIndices,t=0,A=0,e=0;ee&&(g=g>0?e:-e),g}},{key:"_performStep",value:function(g){var t=this.body.nodes[g],A=this.physicsBody.forces[g];this.options.wind&&(A.x+=this.options.wind.x,A.y+=this.options.wind.y);var e=this.physicsBody.velocities[g];return this.previousStates[g]={x:t.x,y:t.y,vx:e.x,vy:e.y},!1===t.options.fixed.x?(e.x=this.calculateComponentVelocity(e.x,A.x,t.options.mass),t.x+=e.x*this.timestep):(A.x=0,e.x=0),!1===t.options.fixed.y?(e.y=this.calculateComponentVelocity(e.y,A.y,t.options.mass),t.y+=e.y*this.timestep):(A.y=0,e.y=0),Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}},{key:"_freezeNodes",value:function(){var g=this.body.nodes;for(var t in g)if(Object.prototype.hasOwnProperty.call(g,t)&&g[t].x&&g[t].y){var A=g[t].options.fixed;this.freezeCache[t]={x:A.x,y:A.y},A.x=!0,A.y=!0}}},{key:"_restoreFrozenNodes",value:function(){var g=this.body.nodes;for(var t in g)Object.prototype.hasOwnProperty.call(g,t)&&void 0!==this.freezeCache[t]&&(g[t].options.fixed.x=this.freezeCache[t].x,g[t].options.fixed.y=this.freezeCache[t].y);this.freezeCache={}}},{key:"stabilize",value:function(){var g=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.stabilization.iterations;"number"!=typeof t&&(t=this.options.stabilization.iterations,console.error("The stabilize method needs a numeric amount of iterations. Switching to default: ",t)),0!==this.physicsBody.physicsNodeIndices.length?(this.adaptiveTimestep=this.options.adaptiveTimestep,this.body.emitter.emit("_resizeNodes"),this.stopSimulation(),this.stabilized=!1,this.body.emitter.emit("_blockRedraw"),this.targetIterations=t,!0===this.options.stabilization.onlyDynamicEdges&&this._freezeNodes(),this.stabilizationIterations=0,wu((function(){return g._stabilizationBatch()}),0)):this.ready=!0}},{key:"_startStabilizing",value:function(){return!0!==this.startedStabilization&&(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0,!0)}},{key:"_stabilizationBatch",value:function(){var g=this,t=function(){return!1===g.stabilized&&g.stabilizationIterations1&&void 0!==arguments[1]?arguments[1]:[],e=1e9,C=-1e9,I=1e9,i=-1e9;if(A.length>0)for(var o=0;o(t=g[A[o]]).shape.boundingBox.left&&(I=t.shape.boundingBox.left),it.shape.boundingBox.top&&(e=t.shape.boundingBox.top),C1&&void 0!==arguments[1]?arguments[1]:[],e=1e9,C=-1e9,I=1e9,i=-1e9;if(A.length>0)for(var o=0;o(t=g[A[o]]).x&&(I=t.x),it.y&&(e=t.y),C=g&&A.push(C.id)}for(var I=0;I0&&void 0!==arguments[0]?arguments[0]:{},A=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(void 0===t.joinCondition)throw new Error("Cannot call clusterByNodeData without a joinCondition function in the options.");t=this._checkOptions(t);var e={},C={};tv(this.body.nodes,(function(A,I){A.options&&!0===t.joinCondition(A.options)&&(e[I]=A,tv(A.edges,(function(t){void 0===g.clusteredEdges[t.id]&&(C[t.id]=t)})))})),this._cluster(e,C,t,A)}},{key:"clusterByEdgeCount",value:function(g,t){var A=this,e=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=this._checkOptions(t);for(var C,I,i,o=[],n={},r=function(){var e={},r={},a=A.body.nodeIndices[s],d=A.body.nodes[a];if(void 0===n[a]){i=0,I=[];for(var h=0;h0&&Lh(r).length>0&&!0===c){var f=function(){for(var g=0;g1&&void 0!==arguments[1])||arguments[1];this.clusterByEdgeCount(1,g,t)}},{key:"clusterBridges",value:function(g){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.clusterByEdgeCount(2,g,t)}},{key:"clusterByConnection",value:function(g,t){var A,e=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===g)throw new Error("No nodeId supplied to clusterByConnection!");if(void 0===this.body.nodes[g])throw new Error("The nodeId given to clusterByConnection does not exist!");var C=this.body.nodes[g];void 0===(t=this._checkOptions(t,C)).clusterNodeProperties.x&&(t.clusterNodeProperties.x=C.x),void 0===t.clusterNodeProperties.y&&(t.clusterNodeProperties.y=C.y),void 0===t.clusterNodeProperties.fixed&&(t.clusterNodeProperties.fixed={},t.clusterNodeProperties.fixed.x=C.options.fixed.x,t.clusterNodeProperties.fixed.y=C.options.fixed.y);var I={},i={},o=C.id,n=XR.cloneOptions(C);I[o]=C;for(var r=0;r-1&&(i[p.id]=p)}this._cluster(I,i,t,e)}},{key:"_createClusterEdges",value:function(g,t,A,e){for(var C,I,i,o,n,r,s=Lh(g),a=[],d=0;d0&&void 0!==arguments[0]?arguments[0]:{};return void 0===g.clusterEdgeProperties&&(g.clusterEdgeProperties={}),void 0===g.clusterNodeProperties&&(g.clusterNodeProperties={}),g}},{key:"_cluster",value:function(g,t,A){var e=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],C=[];for(var I in g)Object.prototype.hasOwnProperty.call(g,I)&&void 0!==this.clusteredNodes[I]&&C.push(I);for(var i=0;iC?t.x:C,I=t.yi?t.y:i;return{x:.5*(e+C),y:.5*(I+i)}}},{key:"openCluster",value:function(g,t){var A=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===g)throw new Error("No clusterNodeId supplied to openCluster.");var e=this.body.nodes[g];if(void 0===e)throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(!0!==e.isCluster||void 0===e.containedNodes||void 0===e.containedEdges)throw new Error("The node:"+g+" is not a valid cluster.");var C=this.findNode(g),I=Xc(C).call(C,g)-1;if(I>=0){var i=C[I];return this.body.nodes[i]._openChildCluster(g),delete this.body.nodes[g],void(!0===A&&this.body.emitter.emit("_dataChanged"))}var o=e.containedNodes,n=e.containedEdges;if(void 0!==t&&void 0!==t.releaseFunction&&"function"==typeof t.releaseFunction){var r={},s={x:e.x,y:e.y};for(var a in o)if(Object.prototype.hasOwnProperty.call(o,a)){var d=this.body.nodes[a];r[a]={x:d.x,y:d.y}}var h=t.releaseFunction(s,r);for(var l in o)if(Object.prototype.hasOwnProperty.call(o,l)){var c=this.body.nodes[l];void 0!==h[l]&&(c.x=void 0===h[l].x?e.x:h[l].x,c.y=void 0===h[l].y?e.y:h[l].y)}}else tv(o,(function(g){!1===g.options.fixed.x&&(g.x=e.x),!1===g.options.fixed.y&&(g.y=e.y)}));for(var u in o)if(Object.prototype.hasOwnProperty.call(o,u)){var p=this.body.nodes[u];p.vx=e.vx,p.vy=e.vy,p.setOptions({physics:!0}),delete this.clusteredNodes[u]}for(var f=[],v=0;v0&&C<100;){var I=t.pop();if(void 0!==I){var i=this.body.edges[I];if(void 0!==i){C++;var o=i.clusteringEdgeReplacingIds;if(void 0===o)e.push(I);else for(var n=0;ne&&(e=I.edges.length),g+=I.edges.length,t+=Math.pow(I.edges.length,2),A+=1}g/=A;var i=(t/=A)-Math.pow(g,2),o=Math.sqrt(i),n=Math.floor(g+2*o);return n>e&&(n=e),n}},{key:"_createClusteredEdge",value:function(g,t,A,e,C){var I=XR.cloneOptions(A,"edge");qf(I,e),I.from=g,I.to=t,I.id="clusterEdge:"+rD(),void 0!==C&&qf(I,C);var i=this.body.functions.createEdge(I);return i.clusteringEdgeReplacingIds=[A.id],i.connect(),this.body.edges[i.id]=i,i}},{key:"_clusterEdges",value:function(g,t,A,e){if(t instanceof ZR){var C=t,I={};I[C.id]=C,t=I}if(g instanceof jN){var i=g,o={};o[i.id]=i,g=o}if(null==A)throw new Error("_clusterEdges: parameter clusterNode required");for(var n in void 0===e&&(e=A.clusterEdgeProperties),this._createClusterEdges(g,t,A,e),t)if(Object.prototype.hasOwnProperty.call(t,n)&&void 0!==this.body.edges[n]){var r=this.body.edges[n];this._backupEdgeOptions(r),r.setOptions({physics:!1})}for(var s in g)Object.prototype.hasOwnProperty.call(g,s)&&(this.clusteredNodes[s]={clusterId:A.id,node:this.body.nodes[s]},this.body.nodes[s].setOptions({physics:!1}))}},{key:"_getClusterNodeForNode",value:function(g){if(void 0!==g){var t=this.clusteredNodes[g];if(void 0!==t){var A=t.clusterId;if(void 0!==A)return this.body.nodes[A]}}}},{key:"_filter",value:function(g,t){var A=[];return tv(g,(function(g){t(g)&&A.push(g)})),A}},{key:"_updateState",value:function(){var g,t=this,A=[],e={},C=function(g){tv(t.body.nodes,(function(t){!0===t.isCluster&&g(t)}))};for(g in this.clusteredNodes){if(Object.prototype.hasOwnProperty.call(this.clusteredNodes,g))void 0===this.body.nodes[g]&&A.push(g)}C((function(g){for(var t=0;t0}g.endPointsValid()&&C||(e[A]=A)})),C((function(g){tv(e,(function(A){delete g.containedEdges[A],tv(g.edges,(function(C,I){C.id!==A?C.clusteringEdgeReplacingIds=t._filter(C.clusteringEdgeReplacingIds,(function(g){return!e[g]})):g.edges[I]=null})),g.edges=t._filter(g.edges,(function(g){return null!==g}))}))})),tv(e,(function(g){delete t.clusteredEdges[g]})),tv(e,(function(g){delete t.body.edges[g]})),tv(Lh(this.body.edges),(function(g){var A=t.body.edges[g],e=t._isClusteredNode(A.fromId)||t._isClusteredNode(A.toId);if(e!==t._isClusteredEdge(A.id))if(e){var C=t._getClusterNodeForNode(A.fromId);void 0!==C&&t._clusterEdges(t.body.nodes[A.fromId],A,C);var I=t._getClusterNodeForNode(A.toId);void 0!==I&&t._clusterEdges(t.body.nodes[A.toId],A,I)}else delete t._clusterEdges[g],t._restoreEdge(A)}));for(var i=!1,o=!0,n=function(){var g=[];C((function(t){var A=Lh(t.containedNodes).length,e=!0===t.options.allowSingleNodeCluster;(e&&A<1||!e&&A<2)&&g.push(t.id)}));for(var A=0;A0,i=i||o};o;)n();i&&this._updateState()}},{key:"_isClusteredNode",value:function(g){return void 0!==this.clusteredNodes[g]}},{key:"_isClusteredEdge",value:function(g){return void 0!==this.clusteredEdges[g]}}]),g}();var gP=function(){function g(t,A){var e;cn(this,g),void 0!==window&&(e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),window.requestAnimationFrame=void 0===e?function(g){g()}:e,this.body=t,this.canvas=A,this.redrawRequested=!1,this.renderTimer=void 0,this.requiresTimeout=!0,this.renderingActive=!1,this.renderRequests=0,this.allowRedraw=!0,this.dragging=!1,this.zooming=!1,this.options={},this.defaultOptions={hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1},fe(this.options,this.defaultOptions),this._determineBrowserMethod(),this.bindEventListeners()}return kd(g,[{key:"bindEventListeners",value:function(){var g,t=this;this.body.emitter.on("dragStart",(function(){t.dragging=!0})),this.body.emitter.on("dragEnd",(function(){t.dragging=!1})),this.body.emitter.on("zoom",(function(){t.zooming=!0,window.clearTimeout(t.zoomTimeoutId),t.zoomTimeoutId=wu((function(){var g;t.zooming=!1,je(g=t._requestRedraw).call(g,t)()}),250)})),this.body.emitter.on("_resizeNodes",(function(){t._resizeNodes()})),this.body.emitter.on("_redraw",(function(){!1===t.renderingActive&&t._redraw()})),this.body.emitter.on("_blockRedraw",(function(){t.allowRedraw=!1})),this.body.emitter.on("_allowRedraw",(function(){t.allowRedraw=!0,t.redrawRequested=!1})),this.body.emitter.on("_requestRedraw",je(g=this._requestRedraw).call(g,this)),this.body.emitter.on("_startRendering",(function(){t.renderRequests+=1,t.renderingActive=!0,t._startRendering()})),this.body.emitter.on("_stopRendering",(function(){t.renderRequests-=1,t.renderingActive=t.renderRequests>0,t.renderTimer=void 0})),this.body.emitter.on("destroy",(function(){t.renderRequests=0,t.allowRedraw=!1,t.renderingActive=!1,!0===t.requiresTimeout?clearTimeout(t.renderTimer):window.cancelAnimationFrame(t.renderTimer),t.body.emitter.off()}))}},{key:"setOptions",value:function(g){if(void 0!==g){Xf(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag"],this.options,g)}}},{key:"_requestNextFrame",value:function(g,t){if("undefined"!=typeof window){var A,e=window;return!0===this.requiresTimeout?A=wu(g,t):e.requestAnimationFrame&&(A=e.requestAnimationFrame(g)),A}}},{key:"_startRendering",value:function(){var g;!0===this.renderingActive&&(void 0===this.renderTimer&&(this.renderTimer=this._requestNextFrame(je(g=this._renderStep).call(g,this),this.simulationInterval)))}},{key:"_renderStep",value:function(){!0===this.renderingActive&&(this.renderTimer=void 0,!0===this.requiresTimeout&&this._startRendering(),this._redraw(),!1===this.requiresTimeout&&this._startRendering())}},{key:"redraw",value:function(){this.body.emitter.emit("setSize"),this._redraw()}},{key:"_requestRedraw",value:function(){var g=this;!0!==this.redrawRequested&&!1===this.renderingActive&&!0===this.allowRedraw&&(this.redrawRequested=!0,this._requestNextFrame((function(){g._redraw(!1)}),0))}},{key:"_redraw",value:function(){var g=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!0===this.allowRedraw){this.body.emitter.emit("initRedraw"),this.redrawRequested=!1;var t={drawExternalLabels:null};0!==this.canvas.frame.canvas.width&&0!==this.canvas.frame.canvas.height||this.canvas.setSize(),this.canvas.setTransform();var A=this.canvas.getContext(),e=this.canvas.frame.canvas.clientWidth,C=this.canvas.frame.canvas.clientHeight;if(A.clearRect(0,0,e,C),0===this.canvas.frame.clientWidth)return;if(A.save(),A.translate(this.body.view.translation.x,this.body.view.translation.y),A.scale(this.body.view.scale,this.body.view.scale),A.beginPath(),this.body.emitter.emit("beforeDrawing",A),A.closePath(),!1===g&&(!1===this.dragging||!0===this.dragging&&!1===this.options.hideEdgesOnDrag)&&(!1===this.zooming||!0===this.zooming&&!1===this.options.hideEdgesOnZoom)&&this._drawEdges(A),!1===this.dragging||!0===this.dragging&&!1===this.options.hideNodesOnDrag){var I=this._drawNodes(A,g).drawExternalLabels;t.drawExternalLabels=I}!1===g&&(!1===this.dragging||!0===this.dragging&&!1===this.options.hideEdgesOnDrag)&&(!1===this.zooming||!0===this.zooming&&!1===this.options.hideEdgesOnZoom)&&this._drawArrows(A),null!=t.drawExternalLabels&&t.drawExternalLabels(),!1===g&&this._drawSelectionBox(A),A.beginPath(),this.body.emitter.emit("afterDrawing",A),A.closePath(),A.restore(),!0===g&&A.clearRect(0,0,e,C)}}},{key:"_resizeNodes",value:function(){this.canvas.setTransform();var g=this.canvas.getContext();g.save(),g.translate(this.body.view.translation.x,this.body.view.translation.y),g.scale(this.body.view.scale,this.body.view.scale);var t,A=this.body.nodes;for(var e in A)Object.prototype.hasOwnProperty.call(A,e)&&((t=A[e]).resize(g),t.updateBoundingBox(g,t.selected));g.restore()}},{key:"_drawNodes",value:function(g){for(var t,A,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],C=this.body.nodes,I=this.body.nodeIndices,i=[],o=[],n=this.canvas.DOMtoCanvas({x:-20,y:-20}),r=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+20,y:this.canvas.frame.canvas.clientHeight+20}),s={top:n.y,left:n.x,bottom:r.y,right:r.x},a=[],d=0;d0&&void 0!==arguments[0]?arguments[0]:this.pixelRatio;!0===this.initialized&&(this.cameraState.previousWidth=this.frame.canvas.width/g,this.cameraState.previousHeight=this.frame.canvas.height/g,this.cameraState.scale=this.body.view.scale,this.cameraState.position=this.DOMtoCanvas({x:.5*this.frame.canvas.width/g,y:.5*this.frame.canvas.height/g}))}},{key:"_setCameraState",value:function(){if(void 0!==this.cameraState.scale&&0!==this.frame.canvas.clientWidth&&0!==this.frame.canvas.clientHeight&&0!==this.pixelRatio&&this.cameraState.previousWidth>0&&this.cameraState.previousHeight>0){var g=this.frame.canvas.width/this.pixelRatio/this.cameraState.previousWidth,t=this.frame.canvas.height/this.pixelRatio/this.cameraState.previousHeight,A=this.cameraState.scale;1!=g&&1!=t?A=.5*this.cameraState.scale*(g+t):1!=g?A=this.cameraState.scale*g:1!=t&&(A=this.cameraState.scale*t),this.body.view.scale=A;var e=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),C={x:e.x-this.cameraState.position.x,y:e.y-this.cameraState.position.y};this.body.view.translation.x+=C.x*this.body.view.scale,this.body.view.translation.y+=C.y*this.body.view.scale}}},{key:"_prepareValue",value:function(g){if("number"==typeof g)return g+"px";if("string"==typeof g){if(-1!==Xc(g).call(g,"%")||-1!==Xc(g).call(g,"px"))return g;if(-1===Xc(g).call(g,"%"))return g+"px"}throw new Error("Could not use the value supplied for width or height:"+g)}},{key:"_create",value:function(){for(;this.body.container.hasChildNodes();)this.body.container.removeChild(this.body.container.firstChild);if(this.frame=document.createElement("div"),this.frame.className="vis-network",this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.tabIndex=0,this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas),this.frame.canvas.getContext)this._setPixelRatio(),this.setTransform();else{var g=document.createElement("DIV");g.style.color="red",g.style.fontWeight="bold",g.style.padding="10px",g.innerText="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(g)}this.body.container.appendChild(this.frame),this.body.view.scale=1,this.body.view.translation={x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight},this._bindHammer()}},{key:"_bindHammer",value:function(){var g=this;void 0!==this.hammer&&this.hammer.destroy(),this.drag={},this.pinch={},this.hammer=new Ev(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:Ev.DIRECTION_ALL}),AP(this.hammer,(function(t){g.body.eventListeners.onTouch(t)})),this.hammer.on("tap",(function(t){g.body.eventListeners.onTap(t)})),this.hammer.on("doubletap",(function(t){g.body.eventListeners.onDoubleTap(t)})),this.hammer.on("press",(function(t){g.body.eventListeners.onHold(t)})),this.hammer.on("panstart",(function(t){g.body.eventListeners.onDragStart(t)})),this.hammer.on("panmove",(function(t){g.body.eventListeners.onDrag(t)})),this.hammer.on("panend",(function(t){g.body.eventListeners.onDragEnd(t)})),this.hammer.on("pinch",(function(t){g.body.eventListeners.onPinch(t)})),this.frame.canvas.addEventListener("wheel",(function(t){g.body.eventListeners.onMouseWheel(t)})),this.frame.canvas.addEventListener("mousemove",(function(t){g.body.eventListeners.onMouseMove(t)})),this.frame.canvas.addEventListener("contextmenu",(function(t){g.body.eventListeners.onContext(t)})),this.hammerFrame=new Ev(this.frame),eP(this.hammerFrame,(function(t){g.body.eventListeners.onRelease(t)}))}},{key:"setSize",value:function(){var g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.width,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.height;g=this._prepareValue(g),t=this._prepareValue(t);var A=!1,e=this.frame.canvas.width,C=this.frame.canvas.height,I=this.pixelRatio;if(this._setPixelRatio(),g!=this.options.width||t!=this.options.height||this.frame.style.width!=g||this.frame.style.height!=t)this._getCameraState(I),this.frame.style.width=g,this.frame.style.height=t,this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),this.options.width=g,this.options.height=t,this.canvasViewCenter={x:.5*this.frame.clientWidth,y:.5*this.frame.clientHeight},A=!0;else{var i=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),o=Math.round(this.frame.canvas.clientHeight*this.pixelRatio);this.frame.canvas.width===i&&this.frame.canvas.height===o||this._getCameraState(I),this.frame.canvas.width!==i&&(this.frame.canvas.width=i,A=!0),this.frame.canvas.height!==o&&(this.frame.canvas.height=o,A=!0)}return!0===A&&(this.body.emitter.emit("resize",{width:Math.round(this.frame.canvas.width/this.pixelRatio),height:Math.round(this.frame.canvas.height/this.pixelRatio),oldWidth:Math.round(e/this.pixelRatio),oldHeight:Math.round(C/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,A}},{key:"getContext",value:function(){return this.frame.canvas.getContext("2d")}},{key:"_determinePixelRatio",value:function(){var g=this.getContext();if(void 0===g)throw new Error("Could not get canvax context");var t=1;return"undefined"!=typeof window&&(t=window.devicePixelRatio||1),t/(g.webkitBackingStorePixelRatio||g.mozBackingStorePixelRatio||g.msBackingStorePixelRatio||g.oBackingStorePixelRatio||g.backingStorePixelRatio||1)}},{key:"_setPixelRatio",value:function(){this.pixelRatio=this._determinePixelRatio()}},{key:"setTransform",value:function(){var g=this.getContext();if(void 0===g)throw new Error("Could not get canvax context");g.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}},{key:"_XconvertDOMtoCanvas",value:function(g){return(g-this.body.view.translation.x)/this.body.view.scale}},{key:"_XconvertCanvasToDOM",value:function(g){return g*this.body.view.scale+this.body.view.translation.x}},{key:"_YconvertDOMtoCanvas",value:function(g){return(g-this.body.view.translation.y)/this.body.view.scale}},{key:"_YconvertCanvasToDOM",value:function(g){return g*this.body.view.scale+this.body.view.translation.y}},{key:"canvasToDOM",value:function(g){return{x:this._XconvertCanvasToDOM(g.x),y:this._YconvertCanvasToDOM(g.y)}}},{key:"DOMtoCanvas",value:function(g){return{x:this._XconvertDOMtoCanvas(g.x),y:this._YconvertDOMtoCanvas(g.y)}}}]),g}();var IP=function(){function g(t,A){var e,C,I=this;cn(this,g),this.body=t,this.canvas=A,this.animationSpeed=1/this.renderRefreshRate,this.animationEasingFunction="easeInOutQuint",this.easingTime=0,this.sourceScale=0,this.targetScale=0,this.sourceTranslation=0,this.targetTranslation=0,this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0,this.touchTime=0,this.viewFunction=void 0,this.body.emitter.on("fit",je(e=this.fit).call(e,this)),this.body.emitter.on("animationFinished",(function(){I.body.emitter.emit("_stopRendering")})),this.body.emitter.on("unlockNode",je(C=this.releaseNode).call(C,this))}return kd(g,[{key:"setOptions",value:function(){var g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=g}},{key:"fit",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];g=function(g,t){var A=fe({nodes:t,minZoomLevel:Number.MIN_VALUE,maxZoomLevel:1},null!=g?g:{});if(!Rh(A.nodes))throw new TypeError("Nodes has to be an array of ids.");if(0===A.nodes.length&&(A.nodes=t),!("number"==typeof A.minZoomLevel&&A.minZoomLevel>0))throw new TypeError("Min zoom level has to be a number higher than zero.");if(!("number"==typeof A.maxZoomLevel&&A.minZoomLevel<=A.maxZoomLevel))throw new TypeError("Max zoom level has to be a number higher than min zoom level.");return A}(g,this.body.nodeIndices);var A,e,C=this.canvas.frame.canvas.clientWidth,I=this.canvas.frame.canvas.clientHeight;if(0===C||0===I)e=1,A=XR.getRange(this.body.nodes,g.nodes);else if(!0===t){var i=0;for(var o in this.body.nodes){if(Object.prototype.hasOwnProperty.call(this.body.nodes,o))!0===this.body.nodes[o].predefinedPosition&&(i+=1)}if(i>.5*this.body.nodeIndices.length)return void this.fit(g,!1);A=XR.getRange(this.body.nodes,g.nodes),e=12.662/(this.body.nodeIndices.length+7.4147)+.0964822,e*=Math.min(C/600,I/600)}else{this.body.emitter.emit("_resizeNodes"),A=XR.getRange(this.body.nodes,g.nodes);var n=C/(1.1*Math.abs(A.maxX-A.minX)),r=I/(1.1*Math.abs(A.maxY-A.minY));e=n<=r?n:r}e>g.maxZoomLevel?e=g.maxZoomLevel:e1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==this.body.nodes[g]){var A={x:this.body.nodes[g].x,y:this.body.nodes[g].y};t.position=A,t.lockedOnNode=g,this.moveTo(t)}else console.error("Node: "+g+" cannot be found.")}},{key:"moveTo",value:function(g){if(void 0!==g){if(null!=g.offset){if(null!=g.offset.x){if(g.offset.x=+g.offset.x,!Ym(g.offset.x))throw new TypeError('The option "offset.x" has to be a finite number.')}else g.offset.x=0;if(null!=g.offset.y){if(g.offset.y=+g.offset.y,!Ym(g.offset.y))throw new TypeError('The option "offset.y" has to be a finite number.')}else g.offset.x=0}else g.offset={x:0,y:0};if(null!=g.position){if(null!=g.position.x){if(g.position.x=+g.position.x,!Ym(g.position.x))throw new TypeError('The option "position.x" has to be a finite number.')}else g.position.x=0;if(null!=g.position.y){if(g.position.y=+g.position.y,!Ym(g.position.y))throw new TypeError('The option "position.y" has to be a finite number.')}else g.position.x=0}else g.position=this.getViewPosition();if(null!=g.scale){if(g.scale=+g.scale,!(g.scale>0))throw new TypeError('The option "scale" has to be a number greater than zero.')}else g.scale=this.body.view.scale;void 0===g.animation&&(g.animation={duration:0}),!1===g.animation&&(g.animation={duration:0}),!0===g.animation&&(g.animation={}),void 0===g.animation.duration&&(g.animation.duration=1e3),void 0===g.animation.easingFunction&&(g.animation.easingFunction="easeInOutQuad"),this.animateView(g)}else g={}}},{key:"animateView",value:function(g){if(void 0!==g){this.animationEasingFunction=g.animation.easingFunction,this.releaseNode(),!0===g.locked&&(this.lockedOnNodeId=g.lockedOnNode,this.lockedOnNodeOffset=g.offset),0!=this.easingTime&&this._transitionRedraw(!0),this.sourceScale=this.body.view.scale,this.sourceTranslation=this.body.view.translation,this.targetScale=g.scale,this.body.view.scale=this.targetScale;var t,A,e=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),C=e.x-g.position.x,I=e.y-g.position.y;if(this.targetTranslation={x:this.sourceTranslation.x+C*this.targetScale+g.offset.x,y:this.sourceTranslation.y+I*this.targetScale+g.offset.y},0===g.animation.duration)if(null!=this.lockedOnNodeId)this.viewFunction=je(t=this._lockedRedraw).call(t,this),this.body.emitter.on("initRedraw",this.viewFunction);else this.body.view.scale=this.targetScale,this.body.view.translation=this.targetTranslation,this.body.emitter.emit("_requestRedraw");else this.animationSpeed=1/(60*g.animation.duration*.001)||1/60,this.animationEasingFunction=g.animation.easingFunction,this.viewFunction=je(A=this._transitionRedraw).call(A,this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering")}}},{key:"_lockedRedraw",value:function(){var g=this.body.nodes[this.lockedOnNodeId].x,t=this.body.nodes[this.lockedOnNodeId].y,A=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),e=A.x-g,C=A.y-t,I=this.body.view.translation,i={x:I.x+e*this.body.view.scale+this.lockedOnNodeOffset.x,y:I.y+C*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=i}},{key:"releaseNode",value:function(){void 0!==this.lockedOnNodeId&&void 0!==this.viewFunction&&(this.body.emitter.off("initRedraw",this.viewFunction),this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0)}},{key:"_transitionRedraw",value:function(){var g=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.easingTime+=this.animationSpeed,this.easingTime=!0===g?1:this.easingTime;var t=hv[this.animationEasingFunction](this.easingTime);if(this.body.view.scale=this.sourceScale+(this.targetScale-this.sourceScale)*t,this.body.view.translation={x:this.sourceTranslation.x+(this.targetTranslation.x-this.sourceTranslation.x)*t,y:this.sourceTranslation.y+(this.targetTranslation.y-this.sourceTranslation.y)*t},this.easingTime>=1){var A;if(this.body.emitter.off("initRedraw",this.viewFunction),this.easingTime=0,null!=this.lockedOnNodeId)this.viewFunction=je(A=this._lockedRedraw).call(A,this),this.body.emitter.on("initRedraw",this.viewFunction);this.body.emitter.emit("animationFinished")}}},{key:"getScale",value:function(){return this.body.view.scale}},{key:"getViewPosition",value:function(){return this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight})}}]),g}();function iP(g){var t,A=g&&g.preventDefault||!1,e=g&&g.container||window,C={},I={keydown:{},keyup:{}},i={};for(t=97;t<=122;t++)i[String.fromCharCode(t)]={code:t-97+65,shift:!1};for(t=65;t<=90;t++)i[String.fromCharCode(t)]={code:t,shift:!0};for(t=0;t<=9;t++)i[""+t]={code:48+t,shift:!1};for(t=1;t<=12;t++)i["F"+t]={code:111+t,shift:!1};for(t=0;t<=9;t++)i["num"+t]={code:96+t,shift:!1};i["num*"]={code:106,shift:!1},i["num+"]={code:107,shift:!1},i["num-"]={code:109,shift:!1},i["num/"]={code:111,shift:!1},i["num."]={code:110,shift:!1},i.left={code:37,shift:!1},i.up={code:38,shift:!1},i.right={code:39,shift:!1},i.down={code:40,shift:!1},i.space={code:32,shift:!1},i.enter={code:13,shift:!1},i.shift={code:16,shift:void 0},i.esc={code:27,shift:!1},i.backspace={code:8,shift:!1},i.tab={code:9,shift:!1},i.ctrl={code:17,shift:!1},i.alt={code:18,shift:!1},i.delete={code:46,shift:!1},i.pageup={code:33,shift:!1},i.pagedown={code:34,shift:!1},i["="]={code:187,shift:!1},i["-"]={code:189,shift:!1},i["]"]={code:221,shift:!1},i["["]={code:219,shift:!1};var o=function(g){r(g,"keydown")},n=function(g){r(g,"keyup")},r=function(g,t){if(void 0!==I[t][g.keyCode]){for(var e=I[t][g.keyCode],C=0;C700&&(this.body.emitter.emit("fit",{duration:700}),this.touchTime=(new Date).valueOf())}},{key:"_stopMovement",value:function(){for(var g in this.boundFunctions)Object.prototype.hasOwnProperty.call(this.boundFunctions,g)&&(this.body.emitter.off("initRedraw",this.boundFunctions[g]),this.body.emitter.emit("_stopRendering"));this.boundFunctions={}}},{key:"_moveUp",value:function(){this.body.view.translation.y+=this.options.keyboard.speed.y}},{key:"_moveDown",value:function(){this.body.view.translation.y-=this.options.keyboard.speed.y}},{key:"_moveLeft",value:function(){this.body.view.translation.x+=this.options.keyboard.speed.x}},{key:"_moveRight",value:function(){this.body.view.translation.x-=this.options.keyboard.speed.x}},{key:"_zoomIn",value:function(){var g=this.body.view.scale,t=this.body.view.scale*(1+this.options.keyboard.speed.zoom),A=this.body.view.translation,e=t/g,C=(1-e)*this.canvas.canvasViewCenter.x+A.x*e,I=(1-e)*this.canvas.canvasViewCenter.y+A.y*e;this.body.view.scale=t,this.body.view.translation={x:C,y:I},this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale,pointer:null})}},{key:"_zoomOut",value:function(){var g=this.body.view.scale,t=this.body.view.scale/(1+this.options.keyboard.speed.zoom),A=this.body.view.translation,e=t/g,C=(1-e)*this.canvas.canvasViewCenter.x+A.x*e,I=(1-e)*this.canvas.canvasViewCenter.y+A.y*e;this.body.view.scale=t,this.body.view.translation={x:C,y:I},this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale,pointer:null})}},{key:"configureKeyboardBindings",value:function(){var g,t,A,e,C,I,i,o,n,r,s,a,d,h,l,c,u,p,f,v,y,m,b,w,k=this;(void 0!==this.keycharm&&this.keycharm.destroy(),!0===this.options.keyboard.enabled)&&(!0===this.options.keyboard.bindToWindow?this.keycharm=iP({container:window,preventDefault:!0}):this.keycharm=iP({container:this.canvas.frame,preventDefault:!0}),this.keycharm.reset(),!0===this.activated&&(je(g=this.keycharm).call(g,"up",(function(){k.bindToRedraw("_moveUp")}),"keydown"),je(t=this.keycharm).call(t,"down",(function(){k.bindToRedraw("_moveDown")}),"keydown"),je(A=this.keycharm).call(A,"left",(function(){k.bindToRedraw("_moveLeft")}),"keydown"),je(e=this.keycharm).call(e,"right",(function(){k.bindToRedraw("_moveRight")}),"keydown"),je(C=this.keycharm).call(C,"=",(function(){k.bindToRedraw("_zoomIn")}),"keydown"),je(I=this.keycharm).call(I,"num+",(function(){k.bindToRedraw("_zoomIn")}),"keydown"),je(i=this.keycharm).call(i,"num-",(function(){k.bindToRedraw("_zoomOut")}),"keydown"),je(o=this.keycharm).call(o,"-",(function(){k.bindToRedraw("_zoomOut")}),"keydown"),je(n=this.keycharm).call(n,"[",(function(){k.bindToRedraw("_zoomOut")}),"keydown"),je(r=this.keycharm).call(r,"]",(function(){k.bindToRedraw("_zoomIn")}),"keydown"),je(s=this.keycharm).call(s,"pageup",(function(){k.bindToRedraw("_zoomIn")}),"keydown"),je(a=this.keycharm).call(a,"pagedown",(function(){k.bindToRedraw("_zoomOut")}),"keydown"),je(d=this.keycharm).call(d,"up",(function(){k.unbindFromRedraw("_moveUp")}),"keyup"),je(h=this.keycharm).call(h,"down",(function(){k.unbindFromRedraw("_moveDown")}),"keyup"),je(l=this.keycharm).call(l,"left",(function(){k.unbindFromRedraw("_moveLeft")}),"keyup"),je(c=this.keycharm).call(c,"right",(function(){k.unbindFromRedraw("_moveRight")}),"keyup"),je(u=this.keycharm).call(u,"=",(function(){k.unbindFromRedraw("_zoomIn")}),"keyup"),je(p=this.keycharm).call(p,"num+",(function(){k.unbindFromRedraw("_zoomIn")}),"keyup"),je(f=this.keycharm).call(f,"num-",(function(){k.unbindFromRedraw("_zoomOut")}),"keyup"),je(v=this.keycharm).call(v,"-",(function(){k.unbindFromRedraw("_zoomOut")}),"keyup"),je(y=this.keycharm).call(y,"[",(function(){k.unbindFromRedraw("_zoomOut")}),"keyup"),je(m=this.keycharm).call(m,"]",(function(){k.unbindFromRedraw("_zoomIn")}),"keyup"),je(b=this.keycharm).call(b,"pageup",(function(){k.unbindFromRedraw("_zoomIn")}),"keyup"),je(w=this.keycharm).call(w,"pagedown",(function(){k.unbindFromRedraw("_zoomOut")}),"keyup")))}}]),g}();function nP(g,t){var A=void 0!==uh&&ln(g)||g["@@iterator"];if(!A){if(Rh(g)||(A=function(g,t){var A;if(!g)return;if("string"==typeof g)return rP(g,t);var e=wh(A=Object.prototype.toString.call(g)).call(A,8,-1);"Object"===e&&g.constructor&&(e=g.constructor.name);if("Map"===e||"Set"===e)return Uo(g);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return rP(g,t)}(g))||t&&g&&"number"==typeof g.length){A&&(g=A);var e=0,C=function(){};return{s:C,n:function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function rP(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);A50&&(this.drag.pointer=this.getPointer(g.center),this.drag.pinched=!1,this.pinch.scale=this.body.view.scale,this.touchTime=(new Date).valueOf())}},{key:"onTap",value:function(g){var t=this.getPointer(g.center),A=this.selectionHandler.options.multiselect&&(g.changedPointers[0].ctrlKey||g.changedPointers[0].metaKey);this.checkSelectionChanges(t,A),this.selectionHandler.commitAndEmit(t,g),this.selectionHandler.generateClickEvent("click",g,t)}},{key:"onDoubleTap",value:function(g){var t=this.getPointer(g.center);this.selectionHandler.generateClickEvent("doubleClick",g,t)}},{key:"onHold",value:function(g){var t=this.getPointer(g.center),A=this.selectionHandler.options.multiselect;this.checkSelectionChanges(t,A),this.selectionHandler.commitAndEmit(t,g),this.selectionHandler.generateClickEvent("click",g,t),this.selectionHandler.generateClickEvent("hold",g,t)}},{key:"onRelease",value:function(g){if((new Date).valueOf()-this.touchTime>10){var t=this.getPointer(g.center);this.selectionHandler.generateClickEvent("release",g,t),this.touchTime=(new Date).valueOf()}}},{key:"onContext",value:function(g){var t=this.getPointer({x:g.clientX,y:g.clientY});this.selectionHandler.generateClickEvent("oncontext",g,t)}},{key:"checkSelectionChanges",value:function(g){!0===(arguments.length>1&&void 0!==arguments[1]&&arguments[1])?this.selectionHandler.selectAdditionalOnPoint(g):this.selectionHandler.selectOnPoint(g)}},{key:"_determineDifference",value:function(g,t){var A=function(g,t){for(var A=[],e=0;e=C.minX&&A.x<=C.maxX&&A.y>=C.minY&&A.y<=C.maxY}));Cl(I).call(I,(function(g){return t.selectionHandler.selectObject(t.body.nodes[g])}));var i=this.getPointer(g.center);this.selectionHandler.commitAndEmit(i,g),this.selectionHandler.generateClickEvent("dragEnd",g,this.getPointer(g.center),void 0,!0),this.body.emitter.emit("_requestRedraw")}else{var o=this.drag.selection;o&&o.length?(Cl(o).call(o,(function(g){g.node.options.fixed.x=g.xFixed,g.node.options.fixed.y=g.yFixed})),this.selectionHandler.generateClickEvent("dragEnd",g,this.getPointer(g.center)),this.body.emitter.emit("startSimulation")):(this.selectionHandler.generateClickEvent("dragEnd",g,this.getPointer(g.center),void 0,!0),this.body.emitter.emit("_requestRedraw"))}}},{key:"onPinch",value:function(g){var t=this.getPointer(g.center);this.drag.pinched=!0,void 0===this.pinch.scale&&(this.pinch.scale=1);var A=this.pinch.scale*g.scale;this.zoom(A,t)}},{key:"zoom",value:function(g,t){if(!0===this.options.zoomView){var A=this.body.view.scale;g<1e-5&&(g=1e-5),g>10&&(g=10);var e=void 0;void 0!==this.drag&&!0===this.drag.dragging&&(e=this.canvas.DOMtoCanvas(this.drag.pointer));var C=this.body.view.translation,I=g/A,i=(1-I)*t.x+C.x*I,o=(1-I)*t.y+C.y*I;if(this.body.view.scale=g,this.body.view.translation={x:i,y:o},null!=e){var n=this.canvas.canvasToDOM(e);this.drag.pointer.x=n.x,this.drag.pointer.y=n.y}this.body.emitter.emit("_requestRedraw"),A0&&(this.popupObj=r[s[s.length-1]],I=!0)}if(void 0===this.popupObj&&!1===I){for(var d,h=this.body.edgeIndices,l=this.body.edges,c=[],u=0;u0&&(this.popupObj=l[c[c.length-1]],i="edge")}void 0!==this.popupObj?this.popupObj.id!==C&&(void 0===this.popup&&(this.popup=new Ov(this.canvas.frame)),this.popup.popupTargetType=i,this.popup.popupTargetId=this.popupObj.id,this.popup.setPosition(g.x+3,g.y-5),this.popup.setText(this.popupObj.getTitle()),this.popup.show(),this.body.emitter.emit("showPopup",this.popupObj.id)):void 0!==this.popup&&(this.popup.hide(),this.body.emitter.emit("hidePopup"))}},{key:"_checkHidePopup",value:function(g){var t=this.selectionHandler._pointerToPositionObject(g),A=!1;if("node"===this.popup.popupTargetType){if(void 0!==this.body.nodes[this.popup.popupTargetId]&&!0===(A=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(t))){var e=this.selectionHandler.getNodeAt(g);A=void 0!==e&&e.id===this.popup.popupTargetId}}else void 0===this.selectionHandler.getNodeAt(g)&&void 0!==this.body.edges[this.popup.popupTargetId]&&(A=this.body.edges[this.popup.popupTargetId].isOverlappingWith(t));!1===A&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}}]),g}(),aP=u,dP=pm,hP=zy.getWeakData,lP=qy,cP=AA,uP=Q,pP=gg,fP=Hy,vP=qg,yP=GC.set,mP=GC.getterFor,bP=Sr.find,wP=Sr.findIndex,kP=aP([].splice),xP=0,EP=function(g){return g.frozen||(g.frozen=new OP)},OP=function(){this.entries=[]},TP=function(g,t){return bP(g.entries,(function(g){return g[0]===t}))};OP.prototype={get:function(g){var t=TP(this,g);if(t)return t[1]},has:function(g){return!!TP(this,g)},set:function(g,t){var A=TP(this,g);A?A[1]=t:this.entries.push([g,t])},delete:function(g){var t=wP(this.entries,(function(t){return t[0]===g}));return~t&&kP(this.entries,t,1),!!~t}};var DP,NP={getConstructor:function(g,t,A,e){var C=g((function(g,C){lP(g,I),yP(g,{type:t,id:xP++,frozen:void 0}),uP(C)||fP(C,g[e],{that:g,AS_ENTRIES:A})})),I=C.prototype,i=mP(t),o=function(g,t,A){var e=i(g),C=hP(cP(t),!0);return!0===C?EP(e).set(t,A):C[e.id]=A,g};return dP(I,{delete:function(g){var t=i(this);if(!pP(g))return!1;var A=hP(g);return!0===A?EP(t).delete(g):A&&vP(A,t.id)&&delete A[t.id]},has:function(g){var t=i(this);if(!pP(g))return!1;var A=hP(g);return!0===A?EP(t).has(g):A&&vP(A,t.id)}}),dP(I,A?{get:function(g){var t=i(this);if(pP(g)){var A=hP(g);return!0===A?EP(t).get(g):A?A[t.id]:void 0}},set:function(g,t){return o(this,g,t)}}:{add:function(g){return o(this,g,!0)}}),C}},RP=vy,PP=C,MP=u,BP=pm,zP=zy,SP=cm,ZP=NP,FP=gg,GP=GC.enforce,jP=I,LP=bC,VP=Object,YP=Array.isArray,WP=VP.isExtensible,QP=VP.isFrozen,UP=VP.isSealed,_P=VP.freeze,KP=VP.seal,HP={},XP={},JP=!PP.ActiveXObject&&"ActiveXObject"in PP,qP=function(g){return function(){return g(this,arguments.length?arguments[0]:void 0)}},$P=SP("WeakMap",qP,ZP),gM=$P.prototype,tM=MP(gM.set);if(LP)if(JP){DP=ZP.getConstructor(qP,"WeakMap",!0),zP.enable();var AM=MP(gM.delete),eM=MP(gM.has),CM=MP(gM.get);BP(gM,{delete:function(g){if(FP(g)&&!WP(g)){var t=GP(this);return t.frozen||(t.frozen=new DP),AM(this,g)||t.frozen.delete(g)}return AM(this,g)},has:function(g){if(FP(g)&&!WP(g)){var t=GP(this);return t.frozen||(t.frozen=new DP),eM(this,g)||t.frozen.has(g)}return eM(this,g)},get:function(g){if(FP(g)&&!WP(g)){var t=GP(this);return t.frozen||(t.frozen=new DP),eM(this,g)?CM(this,g):t.frozen.get(g)}return CM(this,g)},set:function(g,t){if(FP(g)&&!WP(g)){var A=GP(this);A.frozen||(A.frozen=new DP),eM(this,g)?tM(this,g,t):A.frozen.set(g,t)}else tM(this,g,t);return this}})}else RP&&jP((function(){var g=_P([]);return tM(new $P,g,1),!QP(g)}))&&BP(gM,{set:function(g,t){var A;return YP(g)&&(QP(g)?A=HP:UP(g)&&(A=XP)),tM(this,g,t),A===HP&&_P(g),A===XP&&KP(g),this}});var IM,iM,oM,nM,rM,sM=A(tg.WeakMap);function aM(g,t,A,e){if("a"===A&&!e)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?g!==t||!e:!t.has(g))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===A?e:"a"===A?e.call(g):e?e.value:t.get(g)}function dM(g,t,A,e,C){if("m"===e)throw new TypeError("Private method is not writable");if("a"===e&&!C)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?g!==t||!C:!t.has(g))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===e?C.call(g,A):C?C.value=A:t.set(g,A),A}function hM(g,t){var A=void 0!==uh&&ln(g)||g["@@iterator"];if(!A){if(Rh(g)||(A=function(g,t){var A;if(!g)return;if("string"==typeof g)return lM(g,t);var e=wh(A=Object.prototype.toString.call(g)).call(A,8,-1);"Object"===e&&g.constructor&&(e=g.constructor.name);if("Map"===e||"Set"===e)return Uo(g);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return lM(g,t)}(g))||t&&g&&"number"==typeof g.length){A&&(g=A);var e=0,C=function(){};return{s:C,n:function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function lM(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);A0&&void 0!==arguments[0]?arguments[0]:function(){};cn(this,g),oM.set(this,new uM),nM.set(this,new uM),rM.set(this,void 0),dM(this,rM,t,"f")}return kd(g,[{key:"sizeNodes",get:function(){return aM(this,oM,"f").size}},{key:"sizeEdges",get:function(){return aM(this,nM,"f").size}},{key:"getNodes",value:function(){return aM(this,oM,"f").getSelection()}},{key:"getEdges",value:function(){return aM(this,nM,"f").getSelection()}},{key:"addNodes",value:function(){var g;(g=aM(this,oM,"f")).add.apply(g,arguments)}},{key:"addEdges",value:function(){var g;(g=aM(this,nM,"f")).add.apply(g,arguments)}},{key:"deleteNodes",value:function(g){aM(this,oM,"f").delete(g)}},{key:"deleteEdges",value:function(g){aM(this,nM,"f").delete(g)}},{key:"clear",value:function(){aM(this,oM,"f").clear(),aM(this,nM,"f").clear()}},{key:"commit",value:function(){for(var g,t,A={nodes:aM(this,oM,"f").commit(),edges:aM(this,nM,"f").commit()},e=arguments.length,C=new Array(e),I=0;I=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function vM(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);A4&&void 0!==arguments[4]&&arguments[4],I=this._initBaseEvent(t,A);if(!0===C)I.nodes=[],I.edges=[];else{var i=this.getSelection();I.nodes=i.nodes,I.edges=i.edges}void 0!==e&&(I.previousSelection=e),"click"==g&&(I.items=this.getClickedItems(A)),void 0!==t.controlEdge&&(I.controlEdge=t.controlEdge),this.body.emitter.emit(g,I)}},{key:"selectObject",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.selectConnectedEdges;if(void 0!==g){if(g instanceof jN){var A;if(!0===t)(A=this._selectionAccumulator).addEdges.apply(A,ch(g.edges));this._selectionAccumulator.addNodes(g)}else this._selectionAccumulator.addEdges(g);return!0}return!1}},{key:"deselectObject",value:function(g){!0===g.isSelected()&&(g.selected=!1,this._removeFromSelection(g))}},{key:"_getAllNodesOverlappingWith",value:function(g){for(var t=[],A=this.body.nodes,e=0;e1&&void 0!==arguments[1])||arguments[1],A=this._pointerToPositionObject(g),e=this._getAllNodesOverlappingWith(A);return e.length>0?!0===t?this.body.nodes[e[e.length-1]]:e[e.length-1]:void 0}},{key:"_getEdgesOverlappingWith",value:function(g,t){for(var A=this.body.edges,e=0;e1&&void 0!==arguments[1])||arguments[1],A=this.canvas.DOMtoCanvas(g),e=10,C=null,I=this.body.edges,i=0;i0&&(this.generateClickEvent("deselectEdge",t,g,C),A=!0),e.nodes.deleted.length>0&&(this.generateClickEvent("deselectNode",t,g,C),A=!0),e.nodes.added.length>0&&(this.generateClickEvent("selectNode",t,g),A=!0),e.edges.added.length>0&&(this.generateClickEvent("selectEdge",t,g),A=!0),!0===A&&this.generateClickEvent("select",t,g)}},{key:"getSelection",value:function(){return{nodes:this.getSelectedNodeIds(),edges:this.getSelectedEdgeIds()}}},{key:"getSelectedNodes",value:function(){return this._selectionAccumulator.getNodes()}},{key:"getSelectedEdges",value:function(){return this._selectionAccumulator.getEdges()}},{key:"getSelectedNodeIds",value:function(){var g;return Fh(g=this._selectionAccumulator.getNodes()).call(g,(function(g){return g.id}))}},{key:"getSelectedEdgeIds",value:function(){var g;return Fh(g=this._selectionAccumulator.getEdges()).call(g,(function(g){return g.id}))}},{key:"setSelection",value:function(g){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!g||!g.nodes&&!g.edges)throw new TypeError("Selection must be an object with nodes and/or edges properties");if((t.unselectAll||void 0===t.unselectAll)&&this.unselectAll(),g.nodes){var A,e=fM(g.nodes);try{for(e.s();!(A=e.n()).done;){var C=A.value,I=this.body.nodes[C];if(!I)throw new RangeError('Node with id "'+C+'" not found');this.selectObject(I,t.highlightEdges)}}catch(g){e.e(g)}finally{e.f()}}if(g.edges){var i,o=fM(g.edges);try{for(o.s();!(i=o.n()).done;){var n=i.value,r=this.body.edges[n];if(!r)throw new RangeError('Edge with id "'+n+'" not found');this.selectObject(r)}}catch(g){o.e(g)}finally{o.f()}}this.body.emitter.emit("_requestRedraw"),this._selectionAccumulator.commit()}},{key:"selectNodes",value:function(g){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!g||void 0===g.length)throw"Selection must be an array with ids";this.setSelection({nodes:g},{highlightEdges:t})}},{key:"selectEdges",value:function(g){if(!g||void 0===g.length)throw"Selection must be an array with ids";this.setSelection({edges:g})}},{key:"updateSelection",value:function(){for(var g in this._selectionAccumulator.getNodes())Object.prototype.hasOwnProperty.call(this.body.nodes,g.id)||this._selectionAccumulator.deleteNodes(g);for(var t in this._selectionAccumulator.getEdges())Object.prototype.hasOwnProperty.call(this.body.edges,t.id)||this._selectionAccumulator.deleteEdges(t)}},{key:"getClickedItems",value:function(g){for(var t=this.canvas.DOMtoCanvas(g),A=[],e=this.body.nodeIndices,C=this.body.nodes,I=e.length-1;I>=0;I--){var i=C[e[I]].getItemsOnPoint(t);A.push.apply(A,i)}for(var o=this.body.edgeIndices,n=this.body.edges,r=o.length-1;r>=0;r--){var s=n[o[r]].getItemsOnPoint(t);A.push.apply(A,s)}return A}}]),g}();function mM(g){var t=function(){if("undefined"==typeof Reflect||!MT)return!1;if(MT.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(MT(Boolean,[],(function(){}))),!0}catch(g){return!1}}();return function(){var A,e=nb(g);if(t){var C=nb(this).constructor;A=MT(e,arguments,C)}else A=e.apply(this,arguments);return Ib(this,A)}}var bM=function(){function g(){cn(this,g)}return kd(g,[{key:"abstract",value:function(){throw new Error("Can't instantiate abstract class!")}},{key:"fake_use",value:function(){}},{key:"curveType",value:function(){return this.abstract()}},{key:"getPosition",value:function(g){return this.fake_use(g),this.abstract()}},{key:"setPosition",value:function(g,t){var A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this.fake_use(g,t,A),this.abstract()}},{key:"getTreeSize",value:function(g){return this.fake_use(g),this.abstract()}},{key:"sort",value:function(g){this.fake_use(g),this.abstract()}},{key:"fix",value:function(g,t){this.fake_use(g,t),this.abstract()}},{key:"shift",value:function(g,t){this.fake_use(g,t),this.abstract()}}]),g}(),wM=function(g){Cb(A,g);var t=mM(A);function A(g){var e;return cn(this,A),(e=t.call(this)).layout=g,e}return kd(A,[{key:"curveType",value:function(){return"horizontal"}},{key:"getPosition",value:function(g){return g.x}},{key:"setPosition",value:function(g,t){var A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;void 0!==A&&this.layout.hierarchical.addToOrdering(g,A),g.x=t}},{key:"getTreeSize",value:function(g){var t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,g);return{min:t.min_x,max:t.max_x}}},{key:"sort",value:function(g){WO(g).call(g,(function(g,t){return g.x-t.x}))}},{key:"fix",value:function(g,t){g.y=this.layout.options.hierarchical.levelSeparation*t,g.options.fixed.y=!0}},{key:"shift",value:function(g,t){this.layout.body.nodes[g].x+=t}}]),A}(bM),kM=function(g){Cb(A,g);var t=mM(A);function A(g){var e;return cn(this,A),(e=t.call(this)).layout=g,e}return kd(A,[{key:"curveType",value:function(){return"vertical"}},{key:"getPosition",value:function(g){return g.y}},{key:"setPosition",value:function(g,t){var A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;void 0!==A&&this.layout.hierarchical.addToOrdering(g,A),g.y=t}},{key:"getTreeSize",value:function(g){var t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,g);return{min:t.min_y,max:t.max_y}}},{key:"sort",value:function(g){WO(g).call(g,(function(g,t){return g.y-t.y}))}},{key:"fix",value:function(g,t){g.x=this.layout.options.hierarchical.levelSeparation*t,g.options.fixed.x=!0}},{key:"shift",value:function(g,t){this.layout.body.nodes[g].y+=t}}]),A}(bM),xM=Sr.every;TA({target:"Array",proto:!0,forced:!_h("every")},{every:function(g){return xM(this,g,arguments.length>1?arguments[1]:void 0)}});var EM=Me("Array").every,OM=og,TM=EM,DM=Array.prototype,NM=function(g){var t=g.every;return g===DM||OM(DM,g)&&t===DM.every?TM:t},RM=A(NM);function PM(g,t){var A=void 0!==uh&&ln(g)||g["@@iterator"];if(!A){if(Rh(g)||(A=function(g,t){var A;if(!g)return;if("string"==typeof g)return MM(g,t);var e=wh(A=Object.prototype.toString.call(g)).call(A,8,-1);"Object"===e&&g.constructor&&(e=g.constructor.name);if("Map"===e||"Set"===e)return Uo(g);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return MM(g,t)}(g))||t&&g&&"number"==typeof g.length){A&&(g=A);var e=0,C=function(){};return{s:C,n:function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function MM(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);A=t[e])&&(t[e]=t[A]+1)})),t}function zM(g,t,A,e){var C,I,i=$c(null),o=LE(C=ch(nT(e).call(e))).call(C,(function(g,t){return g+1+t.edges.length}),0),n=A+"Id",r="to"===A?1:-1,s=PM(e);try{var a,d=function(){var C=lh(I.value,2),s=C[0],a=C[1];if(!e.has(s)||!g(a))return 0;i[s]=0;for(var d,h,l=[a],c=0,u=function(){var g,C;if(!e.has(s))return 0;var I=i[d.id]+r;if(Cl(g=pc(C=d.edges).call(C,(function(g){return g.connected&&g.to!==g.from&&g[A]!==d&&e.has(g.toId)&&e.has(g.fromId)}))).call(g,(function(g){var e=g[n],C=i[e];(null==C||t(I,C))&&(i[e]=I,l.push(g[A]))})),c>o)return{v:{v:BM(e,i)}};++c};d=l.pop();)if(0!==(h=u())&&h)return h.v};for(s.s();!(I=s.n()).done;)if(0!==(a=d())&&a)return a.v}catch(g){s.e(g)}finally{s.f()}return i}var SM=function(){function g(){cn(this,g),this.childrenReference={},this.parentReference={},this.trees={},this.distributionOrdering={},this.levels={},this.distributionIndex={},this.isTree=!1,this.treeIndex=-1}return kd(g,[{key:"addRelation",value:function(g,t){void 0===this.childrenReference[g]&&(this.childrenReference[g]=[]),this.childrenReference[g].push(t),void 0===this.parentReference[t]&&(this.parentReference[t]=[]),this.parentReference[t].push(g)}},{key:"checkIfTree",value:function(){for(var g in this.parentReference)if(this.parentReference[g].length>1)return void(this.isTree=!1);this.isTree=!0}},{key:"numTrees",value:function(){return this.treeIndex+1}},{key:"setTreeIndex",value:function(g,t){void 0!==t&&void 0===this.trees[g.id]&&(this.trees[g.id]=t,this.treeIndex=Math.max(t,this.treeIndex))}},{key:"ensureLevel",value:function(g){void 0===this.levels[g]&&(this.levels[g]=0)}},{key:"getMaxLevel",value:function(g){var t=this,A={};return function g(e){if(void 0!==A[e])return A[e];var C=t.levels[e];if(t.childrenReference[e]){var I=t.childrenReference[e];if(I.length>0)for(var i=0;i0&&(A.levelSeparation*=-1):A.levelSeparation<0&&(A.levelSeparation*=-1),this.setDirectionStrategy(),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(t);if(!0===e)return this.body.emitter.emit("refresh"),qf(t,this.optionsBackup)}return t}},{key:"_resetRNG",value:function(g){this.initialRandomSeed=g,this._rng=Ff(this.initialRandomSeed)}},{key:"adaptAllOptionsForHierarchicalLayout",value:function(g){if(!0===this.options.hierarchical.enabled){var t=this.optionsBackup.physics;void 0===g.physics||!0===g.physics?(g.physics={enabled:void 0===t.enabled||t.enabled,solver:"hierarchicalRepulsion"},t.enabled=void 0===t.enabled||t.enabled,t.solver=t.solver||"barnesHut"):"object"===yd(g.physics)?(t.enabled=void 0===g.physics.enabled||g.physics.enabled,t.solver=g.physics.solver||"barnesHut",g.physics.solver="hierarchicalRepulsion"):!1!==g.physics&&(t.solver="barnesHut",g.physics={solver:"hierarchicalRepulsion"});var A=this.direction.curveType();if(void 0===g.edges)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},g.edges={smooth:!1};else if(void 0===g.edges.smooth)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},g.edges.smooth=!1;else if("boolean"==typeof g.edges.smooth)this.optionsBackup.edges={smooth:g.edges.smooth},g.edges.smooth={enabled:g.edges.smooth,type:A};else{var e=g.edges.smooth;void 0!==e.type&&"dynamic"!==e.type&&(A=e.type),this.optionsBackup.edges={smooth:{enabled:void 0===e.enabled||e.enabled,type:void 0===e.type?"dynamic":e.type,roundness:void 0===e.roundness?.5:e.roundness,forceDirection:void 0!==e.forceDirection&&e.forceDirection}},g.edges.smooth={enabled:void 0===e.enabled||e.enabled,type:A,roundness:void 0===e.roundness?.5:e.roundness,forceDirection:void 0!==e.forceDirection&&e.forceDirection}}this.body.emitter.emit("_forceDisableDynamicCurves",A)}return g}},{key:"positionInitially",value:function(g){if(!0!==this.options.hierarchical.enabled){this._resetRNG(this.initialRandomSeed);for(var t=g.length+50,A=0;AC){for(var i=g.length;g.length>C&&e<=10;){e+=1;var o=g.length;if(e%3==0?this.body.modules.clustering.clusterBridges(I):this.body.modules.clustering.clusterOutliers(I),o==g.length&&e%3!=0)return this._declusterAll(),this.body.emitter.emit("_layoutFailed"),void console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance.")}this.body.modules.kamadaKawai.setOptions({springLength:Math.max(150,2*i)})}e>10&&console.info("The clustering didn't succeed within the amount of interations allowed, progressing with partial result."),this.body.modules.kamadaKawai.solve(g,this.body.edgeIndices,!0),this._shiftToCenter();for(var n=0;n0){var g,t,A=!1,e=!1;for(t in this.lastNodeOnLevel={},this.hierarchical=new SM,this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&(void 0!==(g=this.body.nodes[t]).options.level?(A=!0,this.hierarchical.levels[t]=g.options.level):e=!0);if(!0===e&&!0===A)throw new Error("To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.");if(!0===e){var C=this.options.hierarchical.sortMethod;"hubsize"===C?this._determineLevelsByHubsize():"directed"===C?this._determineLevelsDirected():"custom"===C&&this._determineLevelsCustomCallback()}for(var I in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,I)&&this.hierarchical.ensureLevel(I);var i=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(i),this._condenseHierarchy(),this._shiftToCenter()}}},{key:"_condenseHierarchy",value:function(){var g=this,t=!1,A={},e=function(t,A){var e=g.hierarchical.trees;for(var C in e)Object.prototype.hasOwnProperty.call(e,C)&&e[C]===t&&g.direction.shift(C,A)},C=function(){for(var t=[],A=0;A0)for(var I=0;I1&&void 0!==arguments[1]?arguments[1]:1e9,e=1e9,C=1e9,I=1e9,i=-1e9;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var n=g.body.nodes[o],r=g.hierarchical.levels[n.id],s=g.direction.getPosition(n),a=lh(g._getSpaceAroundNode(n,t),2),d=a[0],h=a[1];e=Math.min(d,e),C=Math.min(h,C),r<=A&&(I=Math.min(s,I),i=Math.max(s,i))}return[I,i,e,C]},o=function(t,A,e){for(var C=g.hierarchical,I=0;I1)for(var n=0;n2&&void 0!==arguments[2]&&arguments[2],o=g.direction.getPosition(A),n=g.direction.getPosition(e),r=Math.abs(n-o),s=g.options.hierarchical.nodeSpacing;if(r>s){var a={},d={};I(A,a),I(e,d);var h=function(t,A){var e=g.hierarchical.getMaxLevel(t.id),C=g.hierarchical.getMaxLevel(A.id);return Math.min(e,C)}(A,e),l=i(a,h),c=i(d,h),u=l[1],p=c[0],f=c[2];if(Math.abs(u-p)>s){var v=u-p+s;v<-f+s&&(v=-f+s),v<0&&(g._shiftBlock(e.id,v),t=!0,!0===C&&g._centerParent(e))}}},r=function(e,C){for(var o=C.id,n=C.edges,r=g.hierarchical.levels[C.id],s=g.options.hierarchical.levelSeparation*g.options.hierarchical.levelSeparation,a={},d=[],h=0;h0?h=Math.min(d,a-g.options.hierarchical.nodeSpacing):d<0&&(h=-Math.min(-d,s-g.options.hierarchical.nodeSpacing)),0!=h&&(g._shiftBlock(C.id,h),t=!0)}(v),function(A){var e=g.direction.getPosition(C),I=lh(g._getSpaceAroundNode(C),2),i=I[0],o=I[1],n=A-e,r=e;n>0?r=Math.min(e+(o-g.options.hierarchical.nodeSpacing),A):n<0&&(r=Math.max(e-(i-g.options.hierarchical.nodeSpacing),A)),r!==e&&(g.direction.setPosition(C,r),t=!0)}(v=f(e,n))};!0===this.options.hierarchical.blockShifting&&(function(A){var e=g.hierarchical.getLevels();e=cl(e).call(e);for(var C=0;C0&&Math.abs(a)0&&(n=this.direction.getPosition(e[I-1])+o),this.direction.setPosition(i,n,t),this._validatePositionAndContinue(i,t,n),C++}}}}},{key:"_placeBranchNodes",value:function(g,t){var A,e=this.hierarchical.childrenReference[g];if(void 0!==e){for(var C=[],I=0;It&&void 0===this.positionedNodes[o.id]))return;var r=this.options.hierarchical.nodeSpacing,s=void 0;s=0===i?this.direction.getPosition(this.body.nodes[g]):this.direction.getPosition(C[i-1])+r,this.direction.setPosition(o,s,n),this._validatePositionAndContinue(o,n,s)}var a=this._getCenterPosition(C);this.direction.setPosition(this.body.nodes[g],a,t)}}},{key:"_validatePositionAndContinue",value:function(g,t,A){if(this.hierarchical.isTree){if(void 0!==this.lastNodeOnLevel[t]){var e=this.direction.getPosition(this.body.nodes[this.lastNodeOnLevel[t]]);if(A-eg}),"from",g)}(A),this.hierarchical.setMinLevelToZero(this.body.nodes)}},{key:"_generateMap",value:function(){var g=this;this._crawlNetwork((function(t,A){g.hierarchical.levels[A.id]>g.hierarchical.levels[t.id]&&g.hierarchical.addRelation(t.id,A.id)})),this.hierarchical.checkIfTree()}},{key:"_crawlNetwork",value:function(){var g=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},A=arguments.length>1?arguments[1]:void 0,e={},C=function A(C,I){if(void 0===e[C.id]){var i;g.hierarchical.setTreeIndex(C,I),e[C.id]=!0;for(var o=g._getActiveEdges(C),n=0;n=g.length?{done:!0}:{done:!1,value:g[e++]}},e:function(g){throw g},f:C}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I,i=!0,o=!1;return{s:function(){A=A.call(g)},n:function(){var g=A.next();return i=g.done,g},e:function(g){o=!0,I=g},f:function(){try{i||null==A.return||A.return()}finally{if(o)throw I}}}}function GM(g,t){(null==t||t>g.length)&&(t=g.length);for(var A=0,e=new Array(t);A0&&!1!==this.options.deleteNode||0===A&&!1!==this.options.deleteEdge)&&(!0===i&&this._createSeperator(4),this._createDeleteButton(I)),this._bindElementEvents(this.closeDiv,je(g=this.toggleEditMode).call(g,this)),this._temporaryBindEvent("select",je(t=this.showManipulatorToolbar).call(t,this))}this.body.emitter.emit("_redraw")}},{key:"addNodeMode",value:function(){var g;if(!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="addNode",!0===this.guiEnabled){var t,A=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(A),this._createSeperator(),this._createDescription(A.addDescription||this.options.locales.en.addDescription),this._bindElementEvents(this.closeDiv,je(t=this.toggleEditMode).call(t,this))}this._temporaryBindEvent("click",je(g=this._performAddNode).call(g,this))}},{key:"editNode",value:function(){var g=this;!0!==this.editMode&&this.enableEditMode(),this._clean();var t=this.selectionHandler.getSelectedNodes()[0];if(void 0!==t){if(this.inMode="editNode","function"!=typeof this.options.editNode)throw new Error("No function has been configured to handle the editing of nodes.");if(!0!==t.isCluster){var A=qf({},t.options,!1);if(A.x=t.x,A.y=t.y,2!==this.options.editNode.length)throw new Error("The function for edit does not support two arguments (data, callback)");this.options.editNode(A,(function(t){null!=t&&"editNode"===g.inMode&&g.body.data.nodes.getDataSet().update(t),g.showManipulatorToolbar()}))}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError)}else this.showManipulatorToolbar()}},{key:"addEdgeMode",value:function(){var g,t,A,e,C;if(!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="addEdge",!0===this.guiEnabled){var I,i=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(i),this._createSeperator(),this._createDescription(i.edgeDescription||this.options.locales.en.edgeDescription),this._bindElementEvents(this.closeDiv,je(I=this.toggleEditMode).call(I,this))}this._temporaryBindUI("onTouch",je(g=this._handleConnect).call(g,this)),this._temporaryBindUI("onDragEnd",je(t=this._finishConnect).call(t,this)),this._temporaryBindUI("onDrag",je(A=this._dragControlNode).call(A,this)),this._temporaryBindUI("onRelease",je(e=this._finishConnect).call(e,this)),this._temporaryBindUI("onDragStart",je(C=this._dragStartEdge).call(C,this)),this._temporaryBindUI("onHold",(function(){}))}},{key:"editEdgeMode",value:function(){if(!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="editEdge","object"!==yd(this.options.editEdge)||"function"!=typeof this.options.editEdge.editWithoutDrag||(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],void 0===this.edgeBeingEditedId)){if(!0===this.guiEnabled){var g,t=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(t),this._createSeperator(),this._createDescription(t.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindElementEvents(this.closeDiv,je(g=this.toggleEditMode).call(g,this))}if(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],void 0!==this.edgeBeingEditedId){var A,e,C,I,i=this.body.edges[this.edgeBeingEditedId],o=this._getNewTargetNode(i.from.x,i.from.y),n=this._getNewTargetNode(i.to.x,i.to.y);this.temporaryIds.nodes.push(o.id),this.temporaryIds.nodes.push(n.id),this.body.nodes[o.id]=o,this.body.nodeIndices.push(o.id),this.body.nodes[n.id]=n,this.body.nodeIndices.push(n.id),this._temporaryBindUI("onTouch",je(A=this._controlNodeTouch).call(A,this)),this._temporaryBindUI("onTap",(function(){})),this._temporaryBindUI("onHold",(function(){})),this._temporaryBindUI("onDragStart",je(e=this._controlNodeDragStart).call(e,this)),this._temporaryBindUI("onDrag",je(C=this._controlNodeDrag).call(C,this)),this._temporaryBindUI("onDragEnd",je(I=this._controlNodeDragEnd).call(I,this)),this._temporaryBindUI("onMouseMove",(function(){})),this._temporaryBindEvent("beforeDrawing",(function(g){var t=i.edgeType.findBorderPositions(g);!1===o.selected&&(o.x=t.from.x,o.y=t.from.y),!1===n.selected&&(n.x=t.to.x,n.y=t.to.y)})),this.body.emitter.emit("_redraw")}else this.showManipulatorToolbar()}else{var r=this.body.edges[this.edgeBeingEditedId];this._performEditEdge(r.from.id,r.to.id)}}},{key:"deleteSelected",value:function(){var g=this;!0!==this.editMode&&this.enableEditMode(),this._clean(),this.inMode="delete";var t=this.selectionHandler.getSelectedNodeIds(),A=this.selectionHandler.getSelectedEdgeIds(),e=void 0;if(t.length>0){for(var C=0;C0&&"function"==typeof this.options.deleteEdge&&(e=this.options.deleteEdge);if("function"==typeof e){var I={nodes:t,edges:A};if(2!==e.length)throw new Error("The function for delete does not support two arguments (data, callback)");e(I,(function(t){null!=t&&"delete"===g.inMode?(g.body.data.edges.getDataSet().remove(t.edges),g.body.data.nodes.getDataSet().remove(t.nodes),g.body.emitter.emit("startSimulation"),g.showManipulatorToolbar()):(g.body.emitter.emit("startSimulation"),g.showManipulatorToolbar())}))}else this.body.data.edges.getDataSet().remove(A),this.body.data.nodes.getDataSet().remove(t),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}},{key:"_setup",value:function(){!0===this.options.enabled?(this.guiEnabled=!0,this._createWrappers(),!1===this.editMode?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}},{key:"_createWrappers",value:function(){var g,t;(void 0===this.manipulationDiv&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",!0===this.editMode?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),void 0===this.editModeDiv&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",!0===this.editMode?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),void 0===this.closeDiv)&&(this.closeDiv=document.createElement("button"),this.closeDiv.className="vis-close",this.closeDiv.setAttribute("aria-label",null!==(g=null===(t=this.options.locales[this.options.locale])||void 0===t?void 0:t.close)&&void 0!==g?g:this.options.locales.en.close),this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv))}},{key:"_getNewTargetNode",value:function(g,t){var A=qf({},this.options.controlNodeStyle);A.id="targetNode"+rD(),A.hidden=!1,A.physics=!1,A.x=g,A.y=t;var e=this.body.functions.createNode(A);return e.shape.boundingBox={left:g,right:g,top:t,bottom:t},e}},{key:"_createEditButton",value:function(){var g;this._clean(),this.manipulationDOM={},Qf(this.editModeDiv);var t=this.options.locales[this.options.locale],A=this._createButton("editMode","vis-edit vis-edit-mode",t.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(A),this._bindElementEvents(A,je(g=this.toggleEditMode).call(g,this))}},{key:"_clean",value:function(){this.inMode=!1,!0===this.guiEnabled&&(Qf(this.editModeDiv),Qf(this.manipulationDiv),this._cleanupDOMEventListeners()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}},{key:"_cleanupDOMEventListeners",value:function(){var g,t,A=FM(Zl(g=this._domEventListenerCleanupQueue).call(g,0));try{for(A.s();!(t=A.n()).done;){(0,t.value)()}}catch(g){A.e(g)}finally{A.f()}}},{key:"_removeManipulationDOM",value:function(){this._clean(),Qf(this.manipulationDiv),Qf(this.editModeDiv),Qf(this.closeDiv),this.manipulationDiv&&this.canvas.frame.removeChild(this.manipulationDiv),this.editModeDiv&&this.canvas.frame.removeChild(this.editModeDiv),this.closeDiv&&this.canvas.frame.removeChild(this.closeDiv),this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0}},{key:"_createSeperator",value:function(){var g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.manipulationDOM["seperatorLineDiv"+g]=document.createElement("div"),this.manipulationDOM["seperatorLineDiv"+g].className="vis-separator-line",this.manipulationDiv.appendChild(this.manipulationDOM["seperatorLineDiv"+g])}},{key:"_createAddNodeButton",value:function(g){var t,A=this._createButton("addNode","vis-add",g.addNode||this.options.locales.en.addNode);this.manipulationDiv.appendChild(A),this._bindElementEvents(A,je(t=this.addNodeMode).call(t,this))}},{key:"_createAddEdgeButton",value:function(g){var t,A=this._createButton("addEdge","vis-connect",g.addEdge||this.options.locales.en.addEdge);this.manipulationDiv.appendChild(A),this._bindElementEvents(A,je(t=this.addEdgeMode).call(t,this))}},{key:"_createEditNodeButton",value:function(g){var t,A=this._createButton("editNode","vis-edit",g.editNode||this.options.locales.en.editNode);this.manipulationDiv.appendChild(A),this._bindElementEvents(A,je(t=this.editNode).call(t,this))}},{key:"_createEditEdgeButton",value:function(g){var t,A=this._createButton("editEdge","vis-edit",g.editEdge||this.options.locales.en.editEdge);this.manipulationDiv.appendChild(A),this._bindElementEvents(A,je(t=this.editEdgeMode).call(t,this))}},{key:"_createDeleteButton",value:function(g){var t,A;A=this.options.rtl?"vis-delete-rtl":"vis-delete";var e=this._createButton("delete",A,g.del||this.options.locales.en.del);this.manipulationDiv.appendChild(e),this._bindElementEvents(e,je(t=this.deleteSelected).call(t,this))}},{key:"_createBackButton",value:function(g){var t,A=this._createButton("back","vis-back",g.back||this.options.locales.en.back);this.manipulationDiv.appendChild(A),this._bindElementEvents(A,je(t=this.showManipulatorToolbar).call(t,this))}},{key:"_createButton",value:function(g,t,A){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"vis-label";return this.manipulationDOM[g+"Div"]=document.createElement("button"),this.manipulationDOM[g+"Div"].className="vis-button "+t,this.manipulationDOM[g+"Label"]=document.createElement("div"),this.manipulationDOM[g+"Label"].className=e,this.manipulationDOM[g+"Label"].innerText=A,this.manipulationDOM[g+"Div"].appendChild(this.manipulationDOM[g+"Label"]),this.manipulationDOM[g+"Div"]}},{key:"_createDescription",value:function(g){this.manipulationDOM.descriptionLabel=document.createElement("div"),this.manipulationDOM.descriptionLabel.className="vis-none",this.manipulationDOM.descriptionLabel.innerText=g,this.manipulationDiv.appendChild(this.manipulationDOM.descriptionLabel)}},{key:"_temporaryBindEvent",value:function(g,t){this.temporaryEventFunctions.push({event:g,boundFunction:t}),this.body.emitter.on(g,t)}},{key:"_temporaryBindUI",value:function(g,t){if(void 0===this.body.eventListeners[g])throw new Error("This UI function does not exist. Typo? You tried: "+g+" possible are: "+eu(Lh(this.body.eventListeners)));this.temporaryUIFunctions[g]=this.body.eventListeners[g],this.body.eventListeners[g]=t}},{key:"_unbindTemporaryUIs",value:function(){for(var g in this.temporaryUIFunctions)Object.prototype.hasOwnProperty.call(this.temporaryUIFunctions,g)&&(this.body.eventListeners[g]=this.temporaryUIFunctions[g],delete this.temporaryUIFunctions[g]);this.temporaryUIFunctions={}}},{key:"_unbindTemporaryEvents",value:function(){for(var g=0;g=0;i--)if(C[i]!==this.selectedControlNode.id){I=this.body.nodes[C[i]];break}if(void 0!==I&&void 0!==this.selectedControlNode)if(!0===I.isCluster)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var o=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===o.id?this._performEditEdge(I.id,e.to.id):this._performEditEdge(e.from.id,I.id)}else e.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}}},{key:"_handleConnect",value:function(g){if((new Date).valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(g.center),this.lastTouch.translation=fe({},this.body.view.translation),this.interactionHandler.drag.pointer=this.lastTouch,this.interactionHandler.drag.translation=this.lastTouch.translation;var t=this.lastTouch,A=this.selectionHandler.getNodeAt(t);if(void 0!==A)if(!0===A.isCluster)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var e=this._getNewTargetNode(A.x,A.y);this.body.nodes[e.id]=e,this.body.nodeIndices.push(e.id);var C=this.body.functions.createEdge({id:"connectionEdge"+rD(),from:A.id,to:e.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[C.id]=C,this.body.edgeIndices.push(C.id),this.temporaryIds.nodes.push(e.id),this.temporaryIds.edges.push(C.id)}this.touchTime=(new Date).valueOf()}}},{key:"_dragControlNode",value:function(g){var t=this.body.functions.getPointer(g.center),A=this.selectionHandler._pointerToPositionObject(t),e=void 0;void 0!==this.temporaryIds.edges[0]&&(e=this.body.edges[this.temporaryIds.edges[0]].fromId);for(var C=this.selectionHandler._getAllNodesOverlappingWith(A),I=void 0,i=C.length-1;i>=0;i--){var o;if(-1===Xc(o=this.temporaryIds.nodes).call(o,C[i])){I=this.body.nodes[C[i]];break}}if(g.controlEdge={from:e,to:I?I.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragging",g,t),void 0!==this.temporaryIds.nodes[0]){var n=this.body.nodes[this.temporaryIds.nodes[0]];n.x=this.canvas._XconvertDOMtoCanvas(t.x),n.y=this.canvas._YconvertDOMtoCanvas(t.y),this.body.emitter.emit("_redraw")}else this.interactionHandler.onDrag(g)}},{key:"_finishConnect",value:function(g){var t=this.body.functions.getPointer(g.center),A=this.selectionHandler._pointerToPositionObject(t),e=void 0;void 0!==this.temporaryIds.edges[0]&&(e=this.body.edges[this.temporaryIds.edges[0]].fromId);for(var C=this.selectionHandler._getAllNodesOverlappingWith(A),I=void 0,i=C.length-1;i>=0;i--){var o;if(-1===Xc(o=this.temporaryIds.nodes).call(o,C[i])){I=this.body.nodes[C[i]];break}}this._cleanupTemporaryNodesAndEdges(),void 0!==I&&(!0===I.isCluster?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):void 0!==this.body.nodes[e]&&void 0!==this.body.nodes[I.id]&&this._performAddEdge(e,I.id)),g.controlEdge={from:e,to:I?I.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragEnd",g,t),this.body.emitter.emit("_redraw")}},{key:"_dragStartEdge",value:function(g){var t=this.lastTouch;this.selectionHandler.generateClickEvent("dragStart",g,t,void 0,!0)}},{key:"_performAddNode",value:function(g){var t=this,A={id:rD(),x:g.pointer.canvas.x,y:g.pointer.canvas.y,label:"new"};if("function"==typeof this.options.addNode){if(2!==this.options.addNode.length)throw this.showManipulatorToolbar(),new Error("The function for add does not support two arguments (data,callback)");this.options.addNode(A,(function(g){null!=g&&"addNode"===t.inMode&&t.body.data.nodes.getDataSet().add(g),t.showManipulatorToolbar()}))}else this.body.data.nodes.getDataSet().add(A),this.showManipulatorToolbar()}},{key:"_performAddEdge",value:function(g,t){var A=this,e={from:g,to:t};if("function"==typeof this.options.addEdge){if(2!==this.options.addEdge.length)throw new Error("The function for connect does not support two arguments (data,callback)");this.options.addEdge(e,(function(g){null!=g&&"addEdge"===A.inMode&&(A.body.data.edges.getDataSet().add(g),A.selectionHandler.unselectAll(),A.showManipulatorToolbar())}))}else this.body.data.edges.getDataSet().add(e),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},{key:"_performEditEdge",value:function(g,t){var A=this,e={id:this.edgeBeingEditedId,from:g,to:t,label:this.body.data.edges.get(this.edgeBeingEditedId).label},C=this.options.editEdge;if("object"===yd(C)&&(C=C.editWithoutDrag),"function"==typeof C){if(2!==C.length)throw new Error("The function for edit does not support two arguments (data, callback)");C(e,(function(g){null==g||"editEdge"!==A.inMode?(A.body.edges[e.id].updateEdgeType(),A.body.emitter.emit("_redraw"),A.showManipulatorToolbar()):(A.body.data.edges.getDataSet().update(g),A.selectionHandler.unselectAll(),A.showManipulatorToolbar())}))}else this.body.data.edges.getDataSet().update(e),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}}]),g}(),LM="string",VM="boolean",YM="number",WM="array",QM="object",UM=["arrow","bar","box","circle","crow","curve","diamond","image","inv_curve","inv_triangle","triangle","vee"],_M={borderWidth:{number:YM},borderWidthSelected:{number:YM,undefined:"undefined"},brokenImage:{string:LM,undefined:"undefined"},chosen:{label:{boolean:VM,function:"function"},node:{boolean:VM,function:"function"},__type__:{object:QM,boolean:VM}},color:{border:{string:LM},background:{string:LM},highlight:{border:{string:LM},background:{string:LM},__type__:{object:QM,string:LM}},hover:{border:{string:LM},background:{string:LM},__type__:{object:QM,string:LM}},__type__:{object:QM,string:LM}},opacity:{number:YM,undefined:"undefined"},fixed:{x:{boolean:VM},y:{boolean:VM},__type__:{object:QM,boolean:VM}},font:{align:{string:LM},color:{string:LM},size:{number:YM},face:{string:LM},background:{string:LM},strokeWidth:{number:YM},strokeColor:{string:LM},vadjust:{number:YM},multi:{boolean:VM,string:LM},bold:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},boldital:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},ital:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},mono:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},__type__:{object:QM,string:LM}},group:{string:LM,number:YM,undefined:"undefined"},heightConstraint:{minimum:{number:YM},valign:{string:LM},__type__:{object:QM,boolean:VM,number:YM}},hidden:{boolean:VM},icon:{face:{string:LM},code:{string:LM},size:{number:YM},color:{string:LM},weight:{string:LM,number:YM},__type__:{object:QM}},id:{string:LM,number:YM},image:{selected:{string:LM,undefined:"undefined"},unselected:{string:LM,undefined:"undefined"},__type__:{object:QM,string:LM}},imagePadding:{top:{number:YM},right:{number:YM},bottom:{number:YM},left:{number:YM},__type__:{object:QM,number:YM}},label:{string:LM,undefined:"undefined"},labelHighlightBold:{boolean:VM},level:{number:YM,undefined:"undefined"},margin:{top:{number:YM},right:{number:YM},bottom:{number:YM},left:{number:YM},__type__:{object:QM,number:YM}},mass:{number:YM},physics:{boolean:VM},scaling:{min:{number:YM},max:{number:YM},label:{enabled:{boolean:VM},min:{number:YM},max:{number:YM},maxVisible:{number:YM},drawThreshold:{number:YM},__type__:{object:QM,boolean:VM}},customScalingFunction:{function:"function"},__type__:{object:QM}},shadow:{enabled:{boolean:VM},color:{string:LM},size:{number:YM},x:{number:YM},y:{number:YM},__type__:{object:QM,boolean:VM}},shape:{string:["custom","ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},ctxRenderer:{function:"function"},shapeProperties:{borderDashes:{boolean:VM,array:WM},borderRadius:{number:YM},interpolation:{boolean:VM},useImageSize:{boolean:VM},useBorderWithImage:{boolean:VM},coordinateOrigin:{string:["center","top-left"]},__type__:{object:QM}},size:{number:YM},title:{string:LM,dom:"dom",undefined:"undefined"},value:{number:YM,undefined:"undefined"},widthConstraint:{minimum:{number:YM},maximum:{number:YM},__type__:{object:QM,boolean:VM,number:YM}},x:{number:YM},y:{number:YM},__type__:{object:QM}},KM={configure:{enabled:{boolean:VM},filter:{boolean:VM,string:LM,array:WM,function:"function"},container:{dom:"dom"},showButton:{boolean:VM},__type__:{object:QM,boolean:VM,string:LM,array:WM,function:"function"}},edges:{arrows:{to:{enabled:{boolean:VM},scaleFactor:{number:YM},type:{string:UM},imageHeight:{number:YM},imageWidth:{number:YM},src:{string:LM},__type__:{object:QM,boolean:VM}},middle:{enabled:{boolean:VM},scaleFactor:{number:YM},type:{string:UM},imageWidth:{number:YM},imageHeight:{number:YM},src:{string:LM},__type__:{object:QM,boolean:VM}},from:{enabled:{boolean:VM},scaleFactor:{number:YM},type:{string:UM},imageWidth:{number:YM},imageHeight:{number:YM},src:{string:LM},__type__:{object:QM,boolean:VM}},__type__:{string:["from","to","middle"],object:QM}},endPointOffset:{from:{number:YM},to:{number:YM},__type__:{object:QM,number:YM}},arrowStrikethrough:{boolean:VM},background:{enabled:{boolean:VM},color:{string:LM},size:{number:YM},dashes:{boolean:VM,array:WM},__type__:{object:QM,boolean:VM}},chosen:{label:{boolean:VM,function:"function"},edge:{boolean:VM,function:"function"},__type__:{object:QM,boolean:VM}},color:{color:{string:LM},highlight:{string:LM},hover:{string:LM},inherit:{string:["from","to","both"],boolean:VM},opacity:{number:YM},__type__:{object:QM,string:LM}},dashes:{boolean:VM,array:WM},font:{color:{string:LM},size:{number:YM},face:{string:LM},background:{string:LM},strokeWidth:{number:YM},strokeColor:{string:LM},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:YM},multi:{boolean:VM,string:LM},bold:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},boldital:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},ital:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},mono:{color:{string:LM},size:{number:YM},face:{string:LM},mod:{string:LM},vadjust:{number:YM},__type__:{object:QM,string:LM}},__type__:{object:QM,string:LM}},hidden:{boolean:VM},hoverWidth:{function:"function",number:YM},label:{string:LM,undefined:"undefined"},labelHighlightBold:{boolean:VM},length:{number:YM,undefined:"undefined"},physics:{boolean:VM},scaling:{min:{number:YM},max:{number:YM},label:{enabled:{boolean:VM},min:{number:YM},max:{number:YM},maxVisible:{number:YM},drawThreshold:{number:YM},__type__:{object:QM,boolean:VM}},customScalingFunction:{function:"function"},__type__:{object:QM}},selectionWidth:{function:"function",number:YM},selfReferenceSize:{number:YM},selfReference:{size:{number:YM},angle:{number:YM},renderBehindTheNode:{boolean:VM},__type__:{object:QM}},shadow:{enabled:{boolean:VM},color:{string:LM},size:{number:YM},x:{number:YM},y:{number:YM},__type__:{object:QM,boolean:VM}},smooth:{enabled:{boolean:VM},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:YM},forceDirection:{string:["horizontal","vertical","none"],boolean:VM},__type__:{object:QM,boolean:VM}},title:{string:LM,undefined:"undefined"},width:{number:YM},widthConstraint:{maximum:{number:YM},__type__:{object:QM,boolean:VM,number:YM}},value:{number:YM,undefined:"undefined"},__type__:{object:QM}},groups:{useDefaultGroups:{boolean:VM},__any__:_M,__type__:{object:QM}},interaction:{dragNodes:{boolean:VM},dragView:{boolean:VM},hideEdgesOnDrag:{boolean:VM},hideEdgesOnZoom:{boolean:VM},hideNodesOnDrag:{boolean:VM},hover:{boolean:VM},keyboard:{enabled:{boolean:VM},speed:{x:{number:YM},y:{number:YM},zoom:{number:YM},__type__:{object:QM}},bindToWindow:{boolean:VM},autoFocus:{boolean:VM},__type__:{object:QM,boolean:VM}},multiselect:{boolean:VM},navigationButtons:{boolean:VM},selectable:{boolean:VM},selectConnectedEdges:{boolean:VM},hoverConnectedEdges:{boolean:VM},tooltipDelay:{number:YM},zoomView:{boolean:VM},zoomSpeed:{number:YM},__type__:{object:QM}},layout:{randomSeed:{undefined:"undefined",number:YM,string:LM},improvedLayout:{boolean:VM},clusterThreshold:{number:YM},hierarchical:{enabled:{boolean:VM},levelSeparation:{number:YM},nodeSpacing:{number:YM},treeSpacing:{number:YM},blockShifting:{boolean:VM},edgeMinimization:{boolean:VM},parentCentralization:{boolean:VM},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},shakeTowards:{string:["leaves","roots"]},__type__:{object:QM,boolean:VM}},__type__:{object:QM}},manipulation:{enabled:{boolean:VM},initiallyActive:{boolean:VM},addNode:{boolean:VM,function:"function"},addEdge:{boolean:VM,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:QM,boolean:VM,function:"function"}},deleteNode:{boolean:VM,function:"function"},deleteEdge:{boolean:VM,function:"function"},controlNodeStyle:_M,__type__:{object:QM,boolean:VM}},nodes:_M,physics:{enabled:{boolean:VM},barnesHut:{theta:{number:YM},gravitationalConstant:{number:YM},centralGravity:{number:YM},springLength:{number:YM},springConstant:{number:YM},damping:{number:YM},avoidOverlap:{number:YM},__type__:{object:QM}},forceAtlas2Based:{theta:{number:YM},gravitationalConstant:{number:YM},centralGravity:{number:YM},springLength:{number:YM},springConstant:{number:YM},damping:{number:YM},avoidOverlap:{number:YM},__type__:{object:QM}},repulsion:{centralGravity:{number:YM},springLength:{number:YM},springConstant:{number:YM},nodeDistance:{number:YM},damping:{number:YM},__type__:{object:QM}},hierarchicalRepulsion:{centralGravity:{number:YM},springLength:{number:YM},springConstant:{number:YM},nodeDistance:{number:YM},damping:{number:YM},avoidOverlap:{number:YM},__type__:{object:QM}},maxVelocity:{number:YM},minVelocity:{number:YM},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:VM},iterations:{number:YM},updateInterval:{number:YM},onlyDynamicEdges:{boolean:VM},fit:{boolean:VM},__type__:{object:QM,boolean:VM}},timestep:{number:YM},adaptiveTimestep:{boolean:VM},wind:{x:{number:YM},y:{number:YM},__type__:{object:QM}},__type__:{object:QM,boolean:VM}},autoResize:{boolean:VM},clickToUse:{boolean:VM},locale:{string:LM},locales:{__any__:{any:"any"},__type__:{object:QM}},height:{string:LM},width:{string:LM},__type__:{object:QM}},HM={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},opacity:[0,0,1,.1],fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown","hexagon"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],interpolation:!0,useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},middle:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},from:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"}},endPointOffset:{from:[0,-10,10,1],to:[0,-10,10,1]},arrowStrikethrough:!0,color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],selfReference:{size:[20,0,200,1],angle:[Math.PI/2,-6*Math.PI,6*Math.PI,Math.PI/8],renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],nodeSpacing:[100,20,500,5],treeSpacing:[200,20,500,5],blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"],shakeTowards:["leaves","roots"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0,autoFocus:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0,zoomSpeed:[1,.1,2,.1]},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{theta:[.5,.1,1,.05],gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{theta:[.5,.1,1,.05],gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01],wind:{x:[0,-10,10,.1],y:[0,-10,10,.1]}}},XM=function(g,t,A){var e;return!(!Ic(g).call(g,"physics")||!Ic(e=HM.physics.solver).call(e,t)||A.physics.solver===t||"wind"===t)},JM=Object.freeze({__proto__:null,allOptions:KM,configuratorHideOption:XM,configureOptions:HM}),qM=function(){function g(){cn(this,g)}return kd(g,[{key:"getDistances",value:function(g,t,A){for(var e={},C=g.edges,I=0;I2&&void 0!==arguments[2]&&arguments[2],e=this.distanceSolver.getDistances(this.body,g,t);this._createL_matrix(e),this._createK_matrix(e),this._createE_matrix();for(var C=0,I=Math.max(1e3,Math.min(10*this.body.nodeIndices.length,6e3)),i=1e9,o=0,n=0,r=0,s=0,a=0;i>.01&&C1&&a<5;){a+=1,this._moveNode(o,n,r);var h=lh(this._getEnergy(o),3);s=h[0],n=h[1],r=h[2]}}}},{key:"_getHighestEnergyNode",value:function(g){for(var t=this.body.nodeIndices,A=this.body.nodes,e=0,C=t[0],I=0,i=0,o=0;o
-
+
+
+ Loading... +
+
+ + + +
+
@@ -58,7 +67,7 @@

@@ -170,37 +179,15 @@

{{ end }} {{ define "js" }} - - + + + + + {{ end }} {{ define "css" }} diff --git a/templates/clients/clients_el.html b/templates/clients/clients_el.html index daeb06c..82e17b7 100644 --- a/templates/clients/clients_el.html +++ b/templates/clients/clients_el.html @@ -19,7 +19,16 @@

-
+
+
+ Loading... +
+
+ + + +
+
@@ -58,7 +67,7 @@

@@ -200,38 +209,15 @@

{{ end }} {{ define "js" }} - - + + + + + {{ end }} {{ define "css" }}