dash-contextnet 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dash_contextnet/ContextNet.py +215 -0
- dash_contextnet/THIRD_PARTY_LICENSES.txt +305 -0
- dash_contextnet/__init__.py +30 -0
- dash_contextnet/_imports_.py +5 -0
- dash_contextnet/_version.py +1 -0
- dash_contextnet/dash_contextnet.min.js +11 -0
- dash_contextnet/dash_contextnet.min.js.map +1 -0
- dash_contextnet/metadata.json +1 -0
- dash_contextnet-0.2.0.dist-info/METADATA +159 -0
- dash_contextnet-0.2.0.dist-info/RECORD +13 -0
- dash_contextnet-0.2.0.dist-info/WHEEL +4 -0
- dash_contextnet-0.2.0.dist-info/licenses/LICENSE +21 -0
- dash_contextnet-0.2.0.dist-info/licenses/dash_contextnet/THIRD_PARTY_LICENSES.txt +305 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
(()=>{var e={799(e,t,n){var r;r=function(e){return(()=>{"use strict";var t={45:(e,t,n)=>{var r={};r.layoutBase=n(551),r.CoSEConstants=n(806),r.CoSEEdge=n(767),r.CoSEGraph=n(880),r.CoSEGraphManager=n(578),r.CoSELayout=n(765),r.CoSENode=n(991),r.ConstraintHandler=n(902),e.exports=r},806:(e,t,n)=>{var r=n(551).FDLayoutConstants;function i(){}for(var o in r)i[o]=r[o];i.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,i.DEFAULT_RADIAL_SEPARATION=r.DEFAULT_EDGE_LENGTH,i.DEFAULT_COMPONENT_SEPERATION=60,i.TILE=!0,i.TILING_PADDING_VERTICAL=10,i.TILING_PADDING_HORIZONTAL=10,i.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,i.ENFORCE_CONSTRAINTS=!0,i.APPLY_LAYOUT=!0,i.RELAX_MOVEMENT_ON_CONSTRAINTS=!0,i.TREE_REDUCTION_ON_INCREMENTAL=!0,i.PURE_INCREMENTAL=i.DEFAULT_INCREMENTAL,e.exports=i},767:(e,t,n)=>{var r=n(551).FDLayoutEdge;function i(e,t,n){r.call(this,e,t,n)}for(var o in i.prototype=Object.create(r.prototype),r)i[o]=r[o];e.exports=i},880:(e,t,n)=>{var r=n(551).LGraph;function i(e,t,n){r.call(this,e,t,n)}for(var o in i.prototype=Object.create(r.prototype),r)i[o]=r[o];e.exports=i},578:(e,t,n)=>{var r=n(551).LGraphManager;function i(e){r.call(this,e)}for(var o in i.prototype=Object.create(r.prototype),r)i[o]=r[o];e.exports=i},765:(e,t,n)=>{var r=n(551).FDLayout,i=n(578),o=n(880),a=n(991),s=n(767),l=n(806),u=n(902),c=n(551).FDLayoutConstants,h=n(551).LayoutConstants,d=n(551).Point,f=n(551).PointD,p=n(551).DimensionD,g=n(551).Layout,v=n(551).Integer,y=n(551).IGeometry,m=n(551).LGraph,b=n(551).Transform,x=n(551).LinkedList;function w(){r.call(this),this.toBeTiled={},this.constraints={}}for(var E in w.prototype=Object.create(r.prototype),r)w[E]=r[E];w.prototype.newGraphManager=function(){var e=new i(this);return this.graphManager=e,e},w.prototype.newGraph=function(e){return new o(null,this.graphManager,e)},w.prototype.newNode=function(e){return new a(this.graphManager,e)},w.prototype.newEdge=function(e){return new s(null,null,e)},w.prototype.initParameters=function(){r.prototype.initParameters.call(this,arguments),this.isSubLayout||(l.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=l.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=l.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=c.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=c.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=c.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=c.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1)},w.prototype.initSpringEmbedder=function(){r.prototype.initSpringEmbedder.call(this),this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/c.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=.04,this.coolingAdjuster=1},w.prototype.layout=function(){return h.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},w.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)l.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)}),this.graphManager.setAllNodesToApplyGravitation(n));else{var e=this.getFlatForest();if(e.length>0)this.positionNodesRadially(e);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)});this.graphManager.setAllNodesToApplyGravitation(n),this.positionNodesRandomly()}}return Object.keys(this.constraints).length>0&&(u.handleConstraints(this),this.initConstraintVariables()),this.initSpringEmbedder(),l.APPLY_LAYOUT&&this.runSpringEmbedder(),!0},w.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%c.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/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))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),t=this.nodesWithGravity.filter(function(t){return e.has(t)});this.graphManager.setAllNodesToApplyGravitation(t),this.graphManager.updateBounds(),this.updateGrid(),l.PURE_INCREMENTAL?this.coolingFactor=c.DEFAULT_COOLING_FACTOR_INCREMENTAL/2:this.coolingFactor=c.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),l.PURE_INCREMENTAL?this.coolingFactor=c.DEFAULT_COOLING_FACTOR_INCREMENTAL/2*((100-this.afterGrowthIterations)/100):this.coolingFactor=c.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var n=!this.isTreeGrowing&&!this.isGrowthFinished,r=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(n,r),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},w.prototype.getPositionsData=function(){for(var e=this.graphManager.getAllNodes(),t={},n=0;n<e.length;n++){var r=e[n].rect,i=e[n].id;t[i]={id:i,x:r.getCenterX(),y:r.getCenterY(),w:r.width,h:r.height}}return t},w.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var e=!1;if("during"===c.ANIMATE)this.emit("layoutstarted");else{for(;!e;)e=this.tick();this.graphManager.updateBounds()}},w.prototype.moveNodes=function(){for(var e=this.getAllNodes(),t=0;t<e.length;t++)e[t].calculateDisplacement();for(Object.keys(this.constraints).length>0&&this.updateDisplacements(),t=0;t<e.length;t++)e[t].move()},w.prototype.initConstraintVariables=function(){var e=this;this.idToNodeMap=new Map,this.fixedNodeSet=new Set;for(var t=this.graphManager.getAllNodes(),n=0;n<t.length;n++){var r=t[n];this.idToNodeMap.set(r.id,r)}var i=function t(n){for(var r,i=n.getChild().getNodes(),o=0,a=0;a<i.length;a++)null==(r=i[a]).getChild()?e.fixedNodeSet.has(r.id)&&(o+=100):o+=t(r);return o};if(this.constraints.fixedNodeConstraint)for(this.constraints.fixedNodeConstraint.forEach(function(t){e.fixedNodeSet.add(t.nodeId)}),t=this.graphManager.getAllNodes(),n=0;n<t.length;n++)if(null!=(r=t[n]).getChild()){var o=i(r);o>0&&(r.fixedNodeWeight=o)}if(this.constraints.relativePlacementConstraint){var a=new Map,s=new Map;if(this.dummyToNodeForVerticalAlignment=new Map,this.dummyToNodeForHorizontalAlignment=new Map,this.fixedNodesOnHorizontal=new Set,this.fixedNodesOnVertical=new Set,this.fixedNodeSet.forEach(function(t){e.fixedNodesOnHorizontal.add(t),e.fixedNodesOnVertical.add(t)}),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical){var u=this.constraints.alignmentConstraint.vertical;for(n=0;n<u.length;n++)this.dummyToNodeForVerticalAlignment.set("dummy"+n,[]),u[n].forEach(function(t){a.set(t,"dummy"+n),e.dummyToNodeForVerticalAlignment.get("dummy"+n).push(t),e.fixedNodeSet.has(t)&&e.fixedNodesOnHorizontal.add("dummy"+n)})}if(this.constraints.alignmentConstraint.horizontal){var c=this.constraints.alignmentConstraint.horizontal;for(n=0;n<c.length;n++)this.dummyToNodeForHorizontalAlignment.set("dummy"+n,[]),c[n].forEach(function(t){s.set(t,"dummy"+n),e.dummyToNodeForHorizontalAlignment.get("dummy"+n).push(t),e.fixedNodeSet.has(t)&&e.fixedNodesOnVertical.add("dummy"+n)})}}if(l.RELAX_MOVEMENT_ON_CONSTRAINTS)this.shuffle=function(e){var t,n,r;for(r=e.length-1;r>=2*e.length/3;r--)t=Math.floor(Math.random()*(r+1)),n=e[r],e[r]=e[t],e[t]=n;return e},this.nodesInRelativeHorizontal=[],this.nodesInRelativeVertical=[],this.nodeToRelativeConstraintMapHorizontal=new Map,this.nodeToRelativeConstraintMapVertical=new Map,this.nodeToTempPositionMapHorizontal=new Map,this.nodeToTempPositionMapVertical=new Map,this.constraints.relativePlacementConstraint.forEach(function(t){if(t.left){var n=a.has(t.left)?a.get(t.left):t.left,r=a.has(t.right)?a.get(t.right):t.right;e.nodesInRelativeHorizontal.includes(n)||(e.nodesInRelativeHorizontal.push(n),e.nodeToRelativeConstraintMapHorizontal.set(n,[]),e.dummyToNodeForVerticalAlignment.has(n)?e.nodeToTempPositionMapHorizontal.set(n,e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(n)[0]).getCenterX()):e.nodeToTempPositionMapHorizontal.set(n,e.idToNodeMap.get(n).getCenterX())),e.nodesInRelativeHorizontal.includes(r)||(e.nodesInRelativeHorizontal.push(r),e.nodeToRelativeConstraintMapHorizontal.set(r,[]),e.dummyToNodeForVerticalAlignment.has(r)?e.nodeToTempPositionMapHorizontal.set(r,e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(r)[0]).getCenterX()):e.nodeToTempPositionMapHorizontal.set(r,e.idToNodeMap.get(r).getCenterX())),e.nodeToRelativeConstraintMapHorizontal.get(n).push({right:r,gap:t.gap}),e.nodeToRelativeConstraintMapHorizontal.get(r).push({left:n,gap:t.gap})}else{var i=s.has(t.top)?s.get(t.top):t.top,o=s.has(t.bottom)?s.get(t.bottom):t.bottom;e.nodesInRelativeVertical.includes(i)||(e.nodesInRelativeVertical.push(i),e.nodeToRelativeConstraintMapVertical.set(i,[]),e.dummyToNodeForHorizontalAlignment.has(i)?e.nodeToTempPositionMapVertical.set(i,e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(i)[0]).getCenterY()):e.nodeToTempPositionMapVertical.set(i,e.idToNodeMap.get(i).getCenterY())),e.nodesInRelativeVertical.includes(o)||(e.nodesInRelativeVertical.push(o),e.nodeToRelativeConstraintMapVertical.set(o,[]),e.dummyToNodeForHorizontalAlignment.has(o)?e.nodeToTempPositionMapVertical.set(o,e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(o)[0]).getCenterY()):e.nodeToTempPositionMapVertical.set(o,e.idToNodeMap.get(o).getCenterY())),e.nodeToRelativeConstraintMapVertical.get(i).push({bottom:o,gap:t.gap}),e.nodeToRelativeConstraintMapVertical.get(o).push({top:i,gap:t.gap})}});else{var h=new Map,d=new Map;this.constraints.relativePlacementConstraint.forEach(function(e){if(e.left){var t=a.has(e.left)?a.get(e.left):e.left,n=a.has(e.right)?a.get(e.right):e.right;h.has(t)?h.get(t).push(n):h.set(t,[n]),h.has(n)?h.get(n).push(t):h.set(n,[t])}else{var r=s.has(e.top)?s.get(e.top):e.top,i=s.has(e.bottom)?s.get(e.bottom):e.bottom;d.has(r)?d.get(r).push(i):d.set(r,[i]),d.has(i)?d.get(i).push(r):d.set(i,[r])}});var f=function(e,t){var n=[],r=[],i=new x,o=new Set,a=0;return e.forEach(function(s,l){if(!o.has(l)){n[a]=[],r[a]=!1;var u=l;for(i.push(u),o.add(u),n[a].push(u);0!=i.length;)u=i.shift(),t.has(u)&&(r[a]=!0),e.get(u).forEach(function(e){o.has(e)||(i.push(e),o.add(e),n[a].push(e))});a++}}),{components:n,isFixed:r}},p=f(h,e.fixedNodesOnHorizontal);this.componentsOnHorizontal=p.components,this.fixedComponentsOnHorizontal=p.isFixed;var g=f(d,e.fixedNodesOnVertical);this.componentsOnVertical=g.components,this.fixedComponentsOnVertical=g.isFixed}}},w.prototype.updateDisplacements=function(){var e=this;if(this.constraints.fixedNodeConstraint&&this.constraints.fixedNodeConstraint.forEach(function(t){var n=e.idToNodeMap.get(t.nodeId);n.displacementX=0,n.displacementY=0}),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical)for(var t=this.constraints.alignmentConstraint.vertical,n=0;n<t.length;n++){for(var r=0,i=0;i<t[n].length;i++){if(this.fixedNodeSet.has(t[n][i])){r=0;break}r+=this.idToNodeMap.get(t[n][i]).displacementX}var o=r/t[n].length;for(i=0;i<t[n].length;i++)this.idToNodeMap.get(t[n][i]).displacementX=o}if(this.constraints.alignmentConstraint.horizontal){var a=this.constraints.alignmentConstraint.horizontal;for(n=0;n<a.length;n++){var s=0;for(i=0;i<a[n].length;i++){if(this.fixedNodeSet.has(a[n][i])){s=0;break}s+=this.idToNodeMap.get(a[n][i]).displacementY}var u=s/a[n].length;for(i=0;i<a[n].length;i++)this.idToNodeMap.get(a[n][i]).displacementY=u}}}if(this.constraints.relativePlacementConstraint)if(l.RELAX_MOVEMENT_ON_CONSTRAINTS)this.totalIterations%10==0&&(this.shuffle(this.nodesInRelativeHorizontal),this.shuffle(this.nodesInRelativeVertical)),this.nodesInRelativeHorizontal.forEach(function(t){if(!e.fixedNodesOnHorizontal.has(t)){var n=0;n=e.dummyToNodeForVerticalAlignment.has(t)?e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(t)[0]).displacementX:e.idToNodeMap.get(t).displacementX,e.nodeToRelativeConstraintMapHorizontal.get(t).forEach(function(r){var i;r.right?(i=e.nodeToTempPositionMapHorizontal.get(r.right)-e.nodeToTempPositionMapHorizontal.get(t)-n)<r.gap&&(n-=r.gap-i):(i=e.nodeToTempPositionMapHorizontal.get(t)-e.nodeToTempPositionMapHorizontal.get(r.left)+n)<r.gap&&(n+=r.gap-i)}),e.nodeToTempPositionMapHorizontal.set(t,e.nodeToTempPositionMapHorizontal.get(t)+n),e.dummyToNodeForVerticalAlignment.has(t)?e.dummyToNodeForVerticalAlignment.get(t).forEach(function(t){e.idToNodeMap.get(t).displacementX=n}):e.idToNodeMap.get(t).displacementX=n}}),this.nodesInRelativeVertical.forEach(function(t){if(!e.fixedNodesOnHorizontal.has(t)){var n=0;n=e.dummyToNodeForHorizontalAlignment.has(t)?e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(t)[0]).displacementY:e.idToNodeMap.get(t).displacementY,e.nodeToRelativeConstraintMapVertical.get(t).forEach(function(r){var i;r.bottom?(i=e.nodeToTempPositionMapVertical.get(r.bottom)-e.nodeToTempPositionMapVertical.get(t)-n)<r.gap&&(n-=r.gap-i):(i=e.nodeToTempPositionMapVertical.get(t)-e.nodeToTempPositionMapVertical.get(r.top)+n)<r.gap&&(n+=r.gap-i)}),e.nodeToTempPositionMapVertical.set(t,e.nodeToTempPositionMapVertical.get(t)+n),e.dummyToNodeForHorizontalAlignment.has(t)?e.dummyToNodeForHorizontalAlignment.get(t).forEach(function(t){e.idToNodeMap.get(t).displacementY=n}):e.idToNodeMap.get(t).displacementY=n}});else{for(n=0;n<this.componentsOnHorizontal.length;n++){var c=this.componentsOnHorizontal[n];if(this.fixedComponentsOnHorizontal[n])for(i=0;i<c.length;i++)this.dummyToNodeForVerticalAlignment.has(c[i])?this.dummyToNodeForVerticalAlignment.get(c[i]).forEach(function(t){e.idToNodeMap.get(t).displacementX=0}):this.idToNodeMap.get(c[i]).displacementX=0;else{var h=0,d=0;for(i=0;i<c.length;i++)this.dummyToNodeForVerticalAlignment.has(c[i])?(h+=(p=this.dummyToNodeForVerticalAlignment.get(c[i])).length*this.idToNodeMap.get(p[0]).displacementX,d+=p.length):(h+=this.idToNodeMap.get(c[i]).displacementX,d++);var f=h/d;for(i=0;i<c.length;i++)this.dummyToNodeForVerticalAlignment.has(c[i])?this.dummyToNodeForVerticalAlignment.get(c[i]).forEach(function(t){e.idToNodeMap.get(t).displacementX=f}):this.idToNodeMap.get(c[i]).displacementX=f}}for(n=0;n<this.componentsOnVertical.length;n++)if(c=this.componentsOnVertical[n],this.fixedComponentsOnVertical[n])for(i=0;i<c.length;i++)this.dummyToNodeForHorizontalAlignment.has(c[i])?this.dummyToNodeForHorizontalAlignment.get(c[i]).forEach(function(t){e.idToNodeMap.get(t).displacementY=0}):this.idToNodeMap.get(c[i]).displacementY=0;else{for(h=0,d=0,i=0;i<c.length;i++){var p;this.dummyToNodeForHorizontalAlignment.has(c[i])?(h+=(p=this.dummyToNodeForHorizontalAlignment.get(c[i])).length*this.idToNodeMap.get(p[0]).displacementY,d+=p.length):(h+=this.idToNodeMap.get(c[i]).displacementY,d++)}for(f=h/d,i=0;i<c.length;i++)this.dummyToNodeForHorizontalAlignment.has(c[i])?this.dummyToNodeForHorizontalAlignment.get(c[i]).forEach(function(t){e.idToNodeMap.get(t).displacementY=f}):this.idToNodeMap.get(c[i]).displacementY=f}}},w.prototype.calculateNodesToApplyGravitationTo=function(){var e,t,n=[],r=this.graphManager.getGraphs(),i=r.length;for(t=0;t<i;t++)(e=r[t]).updateConnected(),e.isConnected||(n=n.concat(e.getNodes()));return n},w.prototype.createBendpoints=function(){var e=[];e=e.concat(this.graphManager.getAllEdges());var t,n=new Set;for(t=0;t<e.length;t++){var r=e[t];if(!n.has(r)){var i=r.getSource(),o=r.getTarget();if(i==o)r.getBendpoints().push(new f),r.getBendpoints().push(new f),this.createDummyNodesForBendpoints(r),n.add(r);else{var a=[];if(a=(a=a.concat(i.getEdgeListToNode(o))).concat(o.getEdgeListToNode(i)),!n.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var l=a[s];l.getBendpoints().push(new f),this.createDummyNodesForBendpoints(l)}a.forEach(function(e){n.add(e)})}}}if(n.size==e.length)break}},w.prototype.positionNodesRadially=function(e){for(var t=new d(0,0),n=Math.ceil(Math.sqrt(e.length)),r=0,i=0,o=0,a=new f(0,0),s=0;s<e.length;s++){s%n==0&&(o=0,i=r,0!=s&&(i+=l.DEFAULT_COMPONENT_SEPERATION),r=0);var u=e[s],c=g.findCenterOfTree(u);t.x=o,t.y=i,(a=w.radialLayout(u,c,t)).y>r&&(r=Math.floor(a.y)),o=Math.floor(a.x+l.DEFAULT_COMPONENT_SEPERATION)}this.transform(new f(h.WORLD_CENTER_X-a.x/2,h.WORLD_CENTER_Y-a.y/2))},w.radialLayout=function(e,t,n){var r=Math.max(this.maxDiagonalInTree(e),l.DEFAULT_RADIAL_SEPARATION);w.branchRadialLayout(t,null,0,359,0,r);var i=m.calculateBounds(e),o=new b;o.setDeviceOrgX(i.getMinX()),o.setDeviceOrgY(i.getMinY()),o.setWorldOrgX(n.x),o.setWorldOrgY(n.y);for(var a=0;a<e.length;a++)e[a].transform(o);var s=new f(i.getMaxX(),i.getMaxY());return o.inverseTransformPoint(s)},w.branchRadialLayout=function(e,t,n,r,i,o){var a=(r-n+1)/2;a<0&&(a+=180);var s=(a+n)%360*y.TWO_PI/360,l=(Math.cos(s),i*Math.cos(s)),u=i*Math.sin(s);e.setCenter(l,u);var c=[],h=(c=c.concat(e.getEdges())).length;null!=t&&h--;for(var d,f=0,p=c.length,g=e.getEdgesBetween(t);g.length>1;){var v=g[0];g.splice(0,1);var m=c.indexOf(v);m>=0&&c.splice(m,1),p--,h--}d=null!=t?(c.indexOf(g[0])+1)%p:0;for(var b=Math.abs(r-n)/h,x=d;f!=h;x=++x%p){var E=c[x].getOtherEnd(e);if(E!=t){var T=(n+f*b)%360,C=(T+b)%360;w.branchRadialLayout(E,e,T,C,i+o,o),f++}}},w.maxDiagonalInTree=function(e){for(var t=v.MIN_VALUE,n=0;n<e.length;n++){var r=e[n].getDiagonal();r>t&&(t=r)}return t},w.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},w.prototype.groupZeroDegreeMembers=function(){var e=this,t={};this.memberGroups={},this.idToDummyNode={};for(var n=[],r=this.graphManager.getAllNodes(),i=0;i<r.length;i++){var o=(s=r[i]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=o.id&&this.getToBeTiled(o)||n.push(s)}for(i=0;i<n.length;i++){var s,l=(s=n[i]).getParent().id;void 0===t[l]&&(t[l]=[]),t[l]=t[l].concat(s)}Object.keys(t).forEach(function(n){if(t[n].length>1){var r="DummyCompound_"+n;e.memberGroups[r]=t[n];var i=t[n][0].getParent(),o=new a(e.graphManager);o.id=r,o.paddingLeft=i.paddingLeft||0,o.paddingRight=i.paddingRight||0,o.paddingBottom=i.paddingBottom||0,o.paddingTop=i.paddingTop||0,e.idToDummyNode[r]=o;var s=e.getGraphManager().add(e.newGraph(),o),l=i.getChild();l.add(o);for(var u=0;u<t[n].length;u++){var c=t[n][u];l.remove(c),s.add(c)}}})},w.prototype.clearCompounds=function(){var e={},t={};this.performDFSOnCompounds();for(var n=0;n<this.compoundOrder.length;n++)t[this.compoundOrder[n].id]=this.compoundOrder[n],e[this.compoundOrder[n].id]=[].concat(this.compoundOrder[n].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[n].getChild()),this.compoundOrder[n].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(e,t)},w.prototype.clearZeroDegreeMembers=function(){var e=this,t=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach(function(n){var r=e.idToDummyNode[n];if(t[n]=e.tileNodes(e.memberGroups[n],r.paddingLeft+r.paddingRight),r.rect.width=t[n].width,r.rect.height=t[n].height,r.setCenter(t[n].centerX,t[n].centerY),r.labelMarginLeft=0,r.labelMarginTop=0,l.NODE_DIMENSIONS_INCLUDE_LABELS){var i=r.rect.width,o=r.rect.height;r.labelWidth&&("left"==r.labelPosHorizontal?(r.rect.x-=r.labelWidth,r.setWidth(i+r.labelWidth),r.labelMarginLeft=r.labelWidth):"center"==r.labelPosHorizontal&&r.labelWidth>i?(r.rect.x-=(r.labelWidth-i)/2,r.setWidth(r.labelWidth),r.labelMarginLeft=(r.labelWidth-i)/2):"right"==r.labelPosHorizontal&&r.setWidth(i+r.labelWidth)),r.labelHeight&&("top"==r.labelPosVertical?(r.rect.y-=r.labelHeight,r.setHeight(o+r.labelHeight),r.labelMarginTop=r.labelHeight):"center"==r.labelPosVertical&&r.labelHeight>o?(r.rect.y-=(r.labelHeight-o)/2,r.setHeight(r.labelHeight),r.labelMarginTop=(r.labelHeight-o)/2):"bottom"==r.labelPosVertical&&r.setHeight(o+r.labelHeight))}})},w.prototype.repopulateCompounds=function(){for(var e=this.compoundOrder.length-1;e>=0;e--){var t=this.compoundOrder[e],n=t.id,r=t.paddingLeft,i=t.paddingTop,o=t.labelMarginLeft,a=t.labelMarginTop;this.adjustLocations(this.tiledMemberPack[n],t.rect.x,t.rect.y,r,i,o,a)}},w.prototype.repopulateZeroDegreeMembers=function(){var e=this,t=this.tiledZeroDegreePack;Object.keys(t).forEach(function(n){var r=e.idToDummyNode[n],i=r.paddingLeft,o=r.paddingTop,a=r.labelMarginLeft,s=r.labelMarginTop;e.adjustLocations(t[n],r.rect.x,r.rect.y,i,o,a,s)})},w.prototype.getToBeTiled=function(e){var t=e.id;if(null!=this.toBeTiled[t])return this.toBeTiled[t];var n=e.getChild();if(null==n)return this.toBeTiled[t]=!1,!1;for(var r=n.getNodes(),i=0;i<r.length;i++){var o=r[i];if(this.getNodeDegree(o)>0)return this.toBeTiled[t]=!1,!1;if(null!=o.getChild()){if(!this.getToBeTiled(o))return this.toBeTiled[t]=!1,!1}else this.toBeTiled[o.id]=!1}return this.toBeTiled[t]=!0,!0},w.prototype.getNodeDegree=function(e){e.id;for(var t=e.getEdges(),n=0,r=0;r<t.length;r++){var i=t[r];i.getSource().id!==i.getTarget().id&&(n+=1)}return n},w.prototype.getNodeDegreeWithChildren=function(e){var t=this.getNodeDegree(e);if(null==e.getChild())return t;for(var n=e.getChild().getNodes(),r=0;r<n.length;r++){var i=n[r];t+=this.getNodeDegreeWithChildren(i)}return t},w.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},w.prototype.fillCompexOrderByDFS=function(e){for(var t=0;t<e.length;t++){var n=e[t];null!=n.getChild()&&this.fillCompexOrderByDFS(n.getChild().getNodes()),this.getToBeTiled(n)&&this.compoundOrder.push(n)}},w.prototype.adjustLocations=function(e,t,n,r,i,o,a){n+=i+a;for(var s=t+=r+o,l=0;l<e.rows.length;l++){var u=e.rows[l];t=s;for(var c=0,h=0;h<u.length;h++){var d=u[h];d.rect.x=t,d.rect.y=n,t+=d.rect.width+e.horizontalPadding,d.rect.height>c&&(c=d.rect.height)}n+=c+e.verticalPadding}},w.prototype.tileCompoundMembers=function(e,t){var n=this;this.tiledMemberPack=[],Object.keys(e).forEach(function(r){var i=t[r];if(n.tiledMemberPack[r]=n.tileNodes(e[r],i.paddingLeft+i.paddingRight),i.rect.width=n.tiledMemberPack[r].width,i.rect.height=n.tiledMemberPack[r].height,i.setCenter(n.tiledMemberPack[r].centerX,n.tiledMemberPack[r].centerY),i.labelMarginLeft=0,i.labelMarginTop=0,l.NODE_DIMENSIONS_INCLUDE_LABELS){var o=i.rect.width,a=i.rect.height;i.labelWidth&&("left"==i.labelPosHorizontal?(i.rect.x-=i.labelWidth,i.setWidth(o+i.labelWidth),i.labelMarginLeft=i.labelWidth):"center"==i.labelPosHorizontal&&i.labelWidth>o?(i.rect.x-=(i.labelWidth-o)/2,i.setWidth(i.labelWidth),i.labelMarginLeft=(i.labelWidth-o)/2):"right"==i.labelPosHorizontal&&i.setWidth(o+i.labelWidth)),i.labelHeight&&("top"==i.labelPosVertical?(i.rect.y-=i.labelHeight,i.setHeight(a+i.labelHeight),i.labelMarginTop=i.labelHeight):"center"==i.labelPosVertical&&i.labelHeight>a?(i.rect.y-=(i.labelHeight-a)/2,i.setHeight(i.labelHeight),i.labelMarginTop=(i.labelHeight-a)/2):"bottom"==i.labelPosVertical&&i.setHeight(a+i.labelHeight))}})},w.prototype.tileNodes=function(e,t){var n=this.tileNodesByFavoringDim(e,t,!0),r=this.tileNodesByFavoringDim(e,t,!1),i=this.getOrgRatio(n);return this.getOrgRatio(r)<i?r:n},w.prototype.getOrgRatio=function(e){var t=e.width/e.height;return t<1&&(t=1/t),t},w.prototype.calcIdealRowWidth=function(e,t){var n=l.TILING_PADDING_VERTICAL,r=l.TILING_PADDING_HORIZONTAL,i=e.length,o=0,a=0,s=0;e.forEach(function(e){o+=e.getWidth(),a+=e.getHeight(),e.getWidth()>s&&(s=e.getWidth())});var u,c=o/i,h=a/i,d=Math.pow(n-r,2)+4*(c+r)*(h+n)*i,f=(r-n+Math.sqrt(d))/(2*(c+r));t?(u=Math.ceil(f))==f&&u++:u=Math.floor(f);var p=u*(c+r)-r;return s>p&&(p=s),p+=2*r},w.prototype.tileNodesByFavoringDim=function(e,t,n){var r=l.TILING_PADDING_VERTICAL,i=l.TILING_PADDING_HORIZONTAL,o=l.TILING_COMPARE_BY,a={rows:[],rowWidth:[],rowHeight:[],width:0,height:t,verticalPadding:r,horizontalPadding:i,centerX:0,centerY:0};o&&(a.idealRowWidth=this.calcIdealRowWidth(e,n));var s=function(e){return e.rect.width*e.rect.height},u=function(e,t){return s(t)-s(e)};e.sort(function(e,t){var n=u;return a.idealRowWidth?(n=o)(e.id,t.id):n(e,t)});for(var c=0,h=0,d=0;d<e.length;d++)c+=(f=e[d]).getCenterX(),h+=f.getCenterY();for(a.centerX=c/e.length,a.centerY=h/e.length,d=0;d<e.length;d++){var f=e[d];if(0==a.rows.length)this.insertNodeToRow(a,f,0,t);else if(this.canAddHorizontal(a,f.rect.width,f.rect.height)){var p=a.rows.length-1;a.idealRowWidth||(p=this.getShortestRowIndex(a)),this.insertNodeToRow(a,f,p,t)}else this.insertNodeToRow(a,f,a.rows.length,t);this.shiftToLastRow(a)}return a},w.prototype.insertNodeToRow=function(e,t,n,r){var i=r;n==e.rows.length&&(e.rows.push([]),e.rowWidth.push(i),e.rowHeight.push(0));var o=e.rowWidth[n]+t.rect.width;e.rows[n].length>0&&(o+=e.horizontalPadding),e.rowWidth[n]=o,e.width<o&&(e.width=o);var a=t.rect.height;n>0&&(a+=e.verticalPadding);var s=0;a>e.rowHeight[n]&&(s=e.rowHeight[n],e.rowHeight[n]=a,s=e.rowHeight[n]-s),e.height+=s,e.rows[n].push(t)},w.prototype.getShortestRowIndex=function(e){for(var t=-1,n=Number.MAX_VALUE,r=0;r<e.rows.length;r++)e.rowWidth[r]<n&&(t=r,n=e.rowWidth[r]);return t},w.prototype.getLongestRowIndex=function(e){for(var t=-1,n=Number.MIN_VALUE,r=0;r<e.rows.length;r++)e.rowWidth[r]>n&&(t=r,n=e.rowWidth[r]);return t},w.prototype.canAddHorizontal=function(e,t,n){if(e.idealRowWidth){var r=e.rows.length-1;return e.rowWidth[r]+t+e.horizontalPadding<=e.idealRowWidth}var i=this.getShortestRowIndex(e);if(i<0)return!0;var o=e.rowWidth[i];if(o+e.horizontalPadding+t<=e.width)return!0;var a,s,l=0;return e.rowHeight[i]<n&&i>0&&(l=n+e.verticalPadding-e.rowHeight[i]),a=e.width-o>=t+e.horizontalPadding?(e.height+l)/(o+t+e.horizontalPadding):(e.height+l)/e.width,l=n+e.verticalPadding,(s=e.width<t?(e.height+l)/t:(e.height+l)/e.width)<1&&(s=1/s),a<1&&(a=1/a),a<s},w.prototype.shiftToLastRow=function(e){var t=this.getLongestRowIndex(e),n=e.rowWidth.length-1,r=e.rows[t],i=r[r.length-1],o=i.width+e.horizontalPadding;if(e.width-e.rowWidth[n]>o&&t!=n){r.splice(-1,1),e.rows[n].push(i),e.rowWidth[t]=e.rowWidth[t]-o,e.rowWidth[n]=e.rowWidth[n]+o,e.width=e.rowWidth[instance.getLongestRowIndex(e)];for(var a=Number.MIN_VALUE,s=0;s<r.length;s++)r[s].height>a&&(a=r[s].height);t>0&&(a+=e.verticalPadding);var l=e.rowHeight[t]+e.rowHeight[n];e.rowHeight[t]=a,e.rowHeight[n]<i.height+e.verticalPadding&&(e.rowHeight[n]=i.height+e.verticalPadding);var u=e.rowHeight[t]+e.rowHeight[n];e.height+=u-l,this.shiftToLastRow(e)}},w.prototype.tilingPreLayout=function(){l.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},w.prototype.tilingPostLayout=function(){l.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},w.prototype.reduceTrees=function(){for(var e,t=[],n=!0;n;){var r=this.graphManager.getAllNodes(),i=[];n=!1;for(var o=0;o<r.length;o++)if(1==(e=r[o]).getEdges().length&&!e.getEdges()[0].isInterGraph&&null==e.getChild()){if(l.PURE_INCREMENTAL){var a=e.getEdges()[0].getOtherEnd(e),s=new p(e.getCenterX()-a.getCenterX(),e.getCenterY()-a.getCenterY());i.push([e,e.getEdges()[0],e.getOwner(),s])}else i.push([e,e.getEdges()[0],e.getOwner()]);n=!0}if(1==n){for(var u=[],c=0;c<i.length;c++)1==i[c][0].getEdges().length&&(u.push(i[c]),i[c][0].getOwner().remove(i[c][0]));t.push(u),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=t},w.prototype.growTree=function(e){for(var t,n=e[e.length-1],r=0;r<n.length;r++)t=n[r],this.findPlaceforPrunedNode(t),t[2].add(t[0]),t[2].add(t[1],t[1].source,t[1].target);e.splice(e.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},w.prototype.findPlaceforPrunedNode=function(e){var t,n,r=e[0];if(n=r==e[1].source?e[1].target:e[1].source,l.PURE_INCREMENTAL)r.setCenter(n.getCenterX()+e[3].getWidth(),n.getCenterY()+e[3].getHeight());else{var i=n.startX,o=n.finishX,a=n.startY,s=n.finishY,u=[0,0,0,0];if(a>0)for(var h=i;h<=o;h++)u[0]+=this.grid[h][a-1].length+this.grid[h][a].length-1;if(o<this.grid.length-1)for(h=a;h<=s;h++)u[1]+=this.grid[o+1][h].length+this.grid[o][h].length-1;if(s<this.grid[0].length-1)for(h=i;h<=o;h++)u[2]+=this.grid[h][s+1].length+this.grid[h][s].length-1;if(i>0)for(h=a;h<=s;h++)u[3]+=this.grid[i-1][h].length+this.grid[i][h].length-1;for(var d,f,p=v.MAX_VALUE,g=0;g<u.length;g++)u[g]<p?(p=u[g],d=1,f=g):u[g]==p&&d++;if(3==d&&0==p)0==u[0]&&0==u[1]&&0==u[2]?t=1:0==u[0]&&0==u[1]&&0==u[3]?t=0:0==u[0]&&0==u[2]&&0==u[3]?t=3:0==u[1]&&0==u[2]&&0==u[3]&&(t=2);else if(2==d&&0==p){var y=Math.floor(2*Math.random());t=0==u[0]&&0==u[1]?0==y?0:1:0==u[0]&&0==u[2]?0==y?0:2:0==u[0]&&0==u[3]?0==y?0:3:0==u[1]&&0==u[2]?0==y?1:2:0==u[1]&&0==u[3]?0==y?1:3:0==y?2:3}else t=4==d&&0==p?y=Math.floor(4*Math.random()):f;0==t?r.setCenter(n.getCenterX(),n.getCenterY()-n.getHeight()/2-c.DEFAULT_EDGE_LENGTH-r.getHeight()/2):1==t?r.setCenter(n.getCenterX()+n.getWidth()/2+c.DEFAULT_EDGE_LENGTH+r.getWidth()/2,n.getCenterY()):2==t?r.setCenter(n.getCenterX(),n.getCenterY()+n.getHeight()/2+c.DEFAULT_EDGE_LENGTH+r.getHeight()/2):r.setCenter(n.getCenterX()-n.getWidth()/2-c.DEFAULT_EDGE_LENGTH-r.getWidth()/2,n.getCenterY())}},e.exports=w},991:(e,t,n)=>{var r=n(551).FDLayoutNode,i=n(551).IMath;function o(e,t,n,i){r.call(this,e,t,n,i)}for(var a in o.prototype=Object.create(r.prototype),r)o[a]=r[a];o.prototype.calculateDisplacement=function(){var e=this.graphManager.getLayout();null!=this.getChild()&&this.fixedNodeWeight?(this.displacementX+=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.fixedNodeWeight,this.displacementY+=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.fixedNodeWeight):(this.displacementX+=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY+=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren),Math.abs(this.displacementX)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementX=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementX)),Math.abs(this.displacementY)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementY=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementY)),this.child&&this.child.getNodes().length>0&&this.propogateDisplacementToChildren(this.displacementX,this.displacementY)},o.prototype.propogateDisplacementToChildren=function(e,t){for(var n,r=this.getChild().getNodes(),i=0;i<r.length;i++)null==(n=r[i]).getChild()?(n.displacementX+=e,n.displacementY+=t):n.propogateDisplacementToChildren(e,t)},o.prototype.move=function(){var e=this.graphManager.getLayout();null!=this.child&&0!=this.child.getNodes().length||(this.moveBy(this.displacementX,this.displacementY),e.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},o.prototype.setPred1=function(e){this.pred1=e},o.prototype.getPred1=function(){return pred1},o.prototype.getPred2=function(){return pred2},o.prototype.setNext=function(e){this.next=e},o.prototype.getNext=function(){return next},o.prototype.setProcessed=function(e){this.processed=e},o.prototype.isProcessed=function(){return processed},e.exports=o},902:(e,t,n)=>{function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var i=n(806),o=n(551).LinkedList,a=n(551).Matrix,s=n(551).SVD;function l(){}l.handleConstraints=function(e){var t={};t.fixedNodeConstraint=e.constraints.fixedNodeConstraint,t.alignmentConstraint=e.constraints.alignmentConstraint,t.relativePlacementConstraint=e.constraints.relativePlacementConstraint;for(var n=new Map,l=new Map,u=[],c=[],h=e.getAllNodes(),d=0,f=0;f<h.length;f++){var p=h[f];null==p.getChild()&&(l.set(p.id,d++),u.push(p.getCenterX()),c.push(p.getCenterY()),n.set(p.id,p))}t.relativePlacementConstraint&&t.relativePlacementConstraint.forEach(function(e){e.gap||0==e.gap||(e.left?e.gap=i.DEFAULT_EDGE_LENGTH+n.get(e.left).getWidth()/2+n.get(e.right).getWidth()/2:e.gap=i.DEFAULT_EDGE_LENGTH+n.get(e.top).getHeight()/2+n.get(e.bottom).getHeight()/2)});var g=function(e){var t=0,n=0;return e.forEach(function(e){t+=u[l.get(e)],n+=c[l.get(e)]}),{x:t/e.size,y:n/e.size}},v=function(e,t,n,i,a){var s=new Map;e.forEach(function(e,t){s.set(t,0)}),e.forEach(function(e,t){e.forEach(function(e){s.set(e.id,s.get(e.id)+1)})});var h=new Map,d=new Map,f=new o;s.forEach(function(e,r){0==e?(f.push(r),n||("horizontal"==t?h.set(r,l.has(r)?u[l.get(r)]:i.get(r)):h.set(r,l.has(r)?c[l.get(r)]:i.get(r)))):h.set(r,Number.NEGATIVE_INFINITY),n&&d.set(r,new Set([r]))}),n&&a.forEach(function(e){var r=[];if(e.forEach(function(e){n.has(e)&&r.push(e)}),r.length>0){var o=0;r.forEach(function(e){"horizontal"==t?(h.set(e,l.has(e)?u[l.get(e)]:i.get(e)),o+=h.get(e)):(h.set(e,l.has(e)?c[l.get(e)]:i.get(e)),o+=h.get(e))}),o/=r.length,e.forEach(function(e){n.has(e)||h.set(e,o)})}else{var a=0;e.forEach(function(e){a+="horizontal"==t?l.has(e)?u[l.get(e)]:i.get(e):l.has(e)?c[l.get(e)]:i.get(e)}),a/=e.length,e.forEach(function(e){h.set(e,a)})}});for(var p=function(){var r=f.shift();e.get(r).forEach(function(e){if(h.get(e.id)<h.get(r)+e.gap)if(n&&n.has(e.id)){var o=void 0;if(o="horizontal"==t?l.has(e.id)?u[l.get(e.id)]:i.get(e.id):l.has(e.id)?c[l.get(e.id)]:i.get(e.id),h.set(e.id,o),o<h.get(r)+e.gap){var a=h.get(r)+e.gap-o;d.get(r).forEach(function(e){h.set(e,h.get(e)-a)})}}else h.set(e.id,h.get(r)+e.gap);s.set(e.id,s.get(e.id)-1),0==s.get(e.id)&&f.push(e.id),n&&d.set(e.id,function(e,t){var n=new Set(e),r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var l=a.value;n.add(l)}}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(d.get(r),d.get(e.id)))})};0!=f.length;)p();if(n){var g=new Set;e.forEach(function(e,t){0==e.length&&g.add(t)});var v=[];d.forEach(function(e,t){if(g.has(t)){var i=!1,o=!0,a=!1,s=void 0;try{for(var l,u=e[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){var c=l.value;n.has(c)&&(i=!0)}}catch(e){a=!0,s=e}finally{try{!o&&u.return&&u.return()}finally{if(a)throw s}}if(!i){var h=!1,d=void 0;v.forEach(function(t,n){t.has([].concat(r(e))[0])&&(h=!0,d=n)}),h?e.forEach(function(e){v[d].add(e)}):v.push(new Set(e))}}}),v.forEach(function(e,n){var r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,d=!0,f=!1,p=void 0;try{for(var g,v=e[Symbol.iterator]();!(d=(g=v.next()).done);d=!0){var y=g.value,m=void 0;m="horizontal"==t?l.has(y)?u[l.get(y)]:i.get(y):l.has(y)?c[l.get(y)]:i.get(y);var b=h.get(y);m<r&&(r=m),m>a&&(a=m),b<o&&(o=b),b>s&&(s=b)}}catch(e){f=!0,p=e}finally{try{!d&&v.return&&v.return()}finally{if(f)throw p}}var x=(r+a)/2-(o+s)/2,w=!0,E=!1,T=void 0;try{for(var C,M=e[Symbol.iterator]();!(w=(C=M.next()).done);w=!0){var A=C.value;h.set(A,h.get(A)+x)}}catch(e){E=!0,T=e}finally{try{!w&&M.return&&M.return()}finally{if(E)throw T}}})}return h},y=function(e){var t=0,n=0,r=0,i=0;if(e.forEach(function(e){e.left?u[l.get(e.left)]-u[l.get(e.right)]>=0?t++:n++:c[l.get(e.top)]-c[l.get(e.bottom)]>=0?r++:i++}),t>n&&r>i)for(var o=0;o<l.size;o++)u[o]=-1*u[o],c[o]=-1*c[o];else if(t>n)for(var a=0;a<l.size;a++)u[a]=-1*u[a];else if(r>i)for(var s=0;s<l.size;s++)c[s]=-1*c[s]},m=function(e){var t=[],n=new o,r=new Set,i=0;return e.forEach(function(o,a){if(!r.has(a)){t[i]=[];var s=a;for(n.push(s),r.add(s),t[i].push(s);0!=n.length;)s=n.shift(),e.get(s).forEach(function(e){r.has(e.id)||(n.push(e.id),r.add(e.id),t[i].push(e.id))});i++}}),t},b=function(e){var t=new Map;return e.forEach(function(e,n){t.set(n,[])}),e.forEach(function(e,n){e.forEach(function(e){t.get(n).push(e),t.get(e.id).push({id:n,gap:e.gap,direction:e.direction})})}),t},x=function(e){var t=new Map;return e.forEach(function(e,n){t.set(n,[])}),e.forEach(function(e,n){e.forEach(function(e){t.get(e.id).push({id:n,gap:e.gap,direction:e.direction})})}),t},w=[],E=[],T=!1,C=!1,M=new Set,A=new Map,N=new Map,_=[];if(t.fixedNodeConstraint&&t.fixedNodeConstraint.forEach(function(e){M.add(e.nodeId)}),t.relativePlacementConstraint&&(t.relativePlacementConstraint.forEach(function(e){e.left?(A.has(e.left)?A.get(e.left).push({id:e.right,gap:e.gap,direction:"horizontal"}):A.set(e.left,[{id:e.right,gap:e.gap,direction:"horizontal"}]),A.has(e.right)||A.set(e.right,[])):(A.has(e.top)?A.get(e.top).push({id:e.bottom,gap:e.gap,direction:"vertical"}):A.set(e.top,[{id:e.bottom,gap:e.gap,direction:"vertical"}]),A.has(e.bottom)||A.set(e.bottom,[]))}),N=b(A),_=m(N)),i.TRANSFORM_ON_CONSTRAINT_HANDLING){if(t.fixedNodeConstraint&&t.fixedNodeConstraint.length>1)t.fixedNodeConstraint.forEach(function(e,t){w[t]=[e.position.x,e.position.y],E[t]=[u[l.get(e.nodeId)],c[l.get(e.nodeId)]]}),T=!0;else if(t.alignmentConstraint)!function(){var e=0;if(t.alignmentConstraint.vertical){for(var n=t.alignmentConstraint.vertical,i=function(t){var i=new Set;n[t].forEach(function(e){i.add(e)});var o=new Set([].concat(r(i)).filter(function(e){return M.has(e)})),a=void 0;a=o.size>0?u[l.get(o.values().next().value)]:g(i).x,n[t].forEach(function(t){w[e]=[a,c[l.get(t)]],E[e]=[u[l.get(t)],c[l.get(t)]],e++})},o=0;o<n.length;o++)i(o);T=!0}if(t.alignmentConstraint.horizontal){for(var a=t.alignmentConstraint.horizontal,s=function(t){var n=new Set;a[t].forEach(function(e){n.add(e)});var i=new Set([].concat(r(n)).filter(function(e){return M.has(e)})),o=void 0;o=i.size>0?u[l.get(i.values().next().value)]:g(n).y,a[t].forEach(function(t){w[e]=[u[l.get(t)],o],E[e]=[u[l.get(t)],c[l.get(t)]],e++})},h=0;h<a.length;h++)s(h);T=!0}t.relativePlacementConstraint&&(C=!0)}();else if(t.relativePlacementConstraint){for(var S=0,k=0,P=0;P<_.length;P++)_[P].length>S&&(S=_[P].length,k=P);if(S<N.size/2)y(t.relativePlacementConstraint),T=!1,C=!1;else{var I=new Map,O=new Map,D=[];_[k].forEach(function(e){A.get(e).forEach(function(t){"horizontal"==t.direction?(I.has(e)?I.get(e).push(t):I.set(e,[t]),I.has(t.id)||I.set(t.id,[]),D.push({left:e,right:t.id})):(O.has(e)?O.get(e).push(t):O.set(e,[t]),O.has(t.id)||O.set(t.id,[]),D.push({top:e,bottom:t.id}))})}),y(D),C=!1;var L=v(I,"horizontal"),R=v(O,"vertical");_[k].forEach(function(e,t){E[t]=[u[l.get(e)],c[l.get(e)]],w[t]=[],L.has(e)?w[t][0]=L.get(e):w[t][0]=u[l.get(e)],R.has(e)?w[t][1]=R.get(e):w[t][1]=c[l.get(e)]}),T=!0}}if(T){for(var B,z=a.transpose(w),F=a.transpose(E),V=0;V<z.length;V++)z[V]=a.multGamma(z[V]),F[V]=a.multGamma(F[V]);var G=a.multMat(z,a.transpose(F)),Y=s.svd(G);B=a.multMat(Y.V,a.transpose(Y.U));for(var X=0;X<l.size;X++){var $=[u[X],c[X]],U=[B[0][0],B[1][0]],j=[B[0][1],B[1][1]];u[X]=a.dotProduct($,U),c[X]=a.dotProduct($,j)}C&&y(t.relativePlacementConstraint)}}if(i.ENFORCE_CONSTRAINTS){if(t.fixedNodeConstraint&&t.fixedNodeConstraint.length>0){var H={x:0,y:0};t.fixedNodeConstraint.forEach(function(e,t){var n,r,i={x:u[l.get(e.nodeId)],y:c[l.get(e.nodeId)]},o=e.position,a=(r=i,{x:(n=o).x-r.x,y:n.y-r.y});H.x+=a.x,H.y+=a.y}),H.x/=t.fixedNodeConstraint.length,H.y/=t.fixedNodeConstraint.length,u.forEach(function(e,t){u[t]+=H.x}),c.forEach(function(e,t){c[t]+=H.y}),t.fixedNodeConstraint.forEach(function(e){u[l.get(e.nodeId)]=e.position.x,c[l.get(e.nodeId)]=e.position.y})}if(t.alignmentConstraint){if(t.alignmentConstraint.vertical)for(var W=t.alignmentConstraint.vertical,q=function(e){var t=new Set;W[e].forEach(function(e){t.add(e)});var n=new Set([].concat(r(t)).filter(function(e){return M.has(e)})),i=void 0;i=n.size>0?u[l.get(n.values().next().value)]:g(t).x,t.forEach(function(e){M.has(e)||(u[l.get(e)]=i)})},K=0;K<W.length;K++)q(K);if(t.alignmentConstraint.horizontal)for(var Z=t.alignmentConstraint.horizontal,Q=function(e){var t=new Set;Z[e].forEach(function(e){t.add(e)});var n=new Set([].concat(r(t)).filter(function(e){return M.has(e)})),i=void 0;i=n.size>0?c[l.get(n.values().next().value)]:g(t).y,t.forEach(function(e){M.has(e)||(c[l.get(e)]=i)})},J=0;J<Z.length;J++)Q(J)}t.relativePlacementConstraint&&function(){var e=new Map,n=new Map,r=new Map,i=new Map,o=new Map,a=new Map,s=new Set,h=new Set;if(M.forEach(function(e){s.add(e),h.add(e)}),t.alignmentConstraint){if(t.alignmentConstraint.vertical)for(var d=t.alignmentConstraint.vertical,f=function(t){r.set("dummy"+t,[]),d[t].forEach(function(n){e.set(n,"dummy"+t),r.get("dummy"+t).push(n),M.has(n)&&s.add("dummy"+t)}),o.set("dummy"+t,u[l.get(d[t][0])])},p=0;p<d.length;p++)f(p);if(t.alignmentConstraint.horizontal)for(var g=t.alignmentConstraint.horizontal,y=function(e){i.set("dummy"+e,[]),g[e].forEach(function(t){n.set(t,"dummy"+e),i.get("dummy"+e).push(t),M.has(t)&&h.add("dummy"+e)}),a.set("dummy"+e,c[l.get(g[e][0])])},w=0;w<g.length;w++)y(w)}var E=new Map,T=new Map,C=function(t){A.get(t).forEach(function(r){var i=void 0,o=void 0;"horizontal"==r.direction?(i=e.get(t)?e.get(t):t,o=e.get(r.id)?{id:e.get(r.id),gap:r.gap,direction:r.direction}:r,E.has(i)?E.get(i).push(o):E.set(i,[o]),E.has(o.id)||E.set(o.id,[])):(i=n.get(t)?n.get(t):t,o=n.get(r.id)?{id:n.get(r.id),gap:r.gap,direction:r.direction}:r,T.has(i)?T.get(i).push(o):T.set(i,[o]),T.has(o.id)||T.set(o.id,[]))})},N=!0,_=!1,S=void 0;try{for(var k,P=A.keys()[Symbol.iterator]();!(N=(k=P.next()).done);N=!0)C(k.value)}catch(e){_=!0,S=e}finally{try{!N&&P.return&&P.return()}finally{if(_)throw S}}var I=b(E),O=b(T),D=m(I),L=m(O),R=x(E),B=x(T),z=[],F=[];D.forEach(function(e,t){z[t]=[],e.forEach(function(e){0==R.get(e).length&&z[t].push(e)})}),L.forEach(function(e,t){F[t]=[],e.forEach(function(e){0==B.get(e).length&&F[t].push(e)})});var V=v(E,"horizontal",s,o,z),G=v(T,"vertical",h,a,F),Y=function(e){r.get(e)?r.get(e).forEach(function(t){u[l.get(t)]=V.get(e)}):u[l.get(e)]=V.get(e)},X=!0,$=!1,U=void 0;try{for(var j,H=V.keys()[Symbol.iterator]();!(X=(j=H.next()).done);X=!0)Y(j.value)}catch(e){$=!0,U=e}finally{try{!X&&H.return&&H.return()}finally{if($)throw U}}var W=function(e){i.get(e)?i.get(e).forEach(function(t){c[l.get(t)]=G.get(e)}):c[l.get(e)]=G.get(e)},q=!0,K=!1,Z=void 0;try{for(var Q,J=G.keys()[Symbol.iterator]();!(q=(Q=J.next()).done);q=!0)W(Q.value)}catch(e){K=!0,Z=e}finally{try{!q&&J.return&&J.return()}finally{if(K)throw Z}}}()}for(var ee=0;ee<h.length;ee++){var te=h[ee];null==te.getChild()&&te.setCenter(u[l.get(te.id)],c[l.get(te.id)])}},e.exports=l},551:t=>{t.exports=e}},n={},r=function e(r){var i=n[r];if(void 0!==i)return i.exports;var o=n[r]={exports:{}};return t[r](o,o.exports,e),o.exports}(45);return r})()},e.exports=r(n(143))},527(e,t,n){var r;r=function(e){return(()=>{"use strict";var t={658:e=>{e.exports=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.forEach(function(t){Object.keys(t).forEach(function(n){return e[n]=t[n]})}),e}},548:(e,t,n)=>{var r=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=n(140).layoutBase.LinkedList,o={getTopMostNodes:function(e){for(var t={},n=0;n<e.length;n++)t[e[n].id()]=!0;var r=e.filter(function(e,n){"number"==typeof e&&(e=n);for(var r=e.parent()[0];null!=r;){if(t[r.id()])return!1;r=r.parent()[0]}return!0});return r},connectComponents:function(e,t,n,r){var o=new i,a=new Set,s=[],l=void 0,u=void 0,c=void 0,h=!1,d=1,f=[],p=[],g=function(){var r=e.collection();p.push(r);var i=n[0],g=e.collection();g.merge(i).merge(i.descendants().intersection(t)),s.push(i),g.forEach(function(e){o.push(e),a.add(e),r.merge(e)});for(var v=function(){i=o.shift();var u=e.collection();i.neighborhood().nodes().forEach(function(e){t.intersection(i.edgesWith(e)).length>0&&u.merge(e)});for(var c=0;c<u.length;c++){var h=u[c];null==(l=n.intersection(h.union(h.ancestors())))||a.has(l[0])||l.union(l.descendants()).forEach(function(e){o.push(e),a.add(e),r.merge(e),n.has(e)&&s.push(e)})}};0!=o.length;)v();if(r.forEach(function(e){t.intersection(e.connectedEdges()).forEach(function(e){r.has(e.source())&&r.has(e.target())&&r.merge(e)})}),s.length==n.length&&(h=!0),!h||h&&d>1){u=s[0],c=u.connectedEdges().length,s.forEach(function(e){e.connectedEdges().length<c&&(c=e.connectedEdges().length,u=e)}),f.push(u.id());var y=e.collection();y.merge(s[0]),s.forEach(function(e){y.merge(e)}),s=[],n=n.difference(y),d++}};do{g()}while(!h);return r&&f.length>0&&r.set("dummy"+(r.size+1),f),p},relocateComponent:function(e,t,n){if(!n.fixedNodeConstraint){var i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;if("draft"==n.quality){var l=!0,u=!1,c=void 0;try{for(var h,d=t.nodeIndexes[Symbol.iterator]();!(l=(h=d.next()).done);l=!0){var f=h.value,p=r(f,2),g=p[0],v=p[1],y=n.cy.getElementById(g);if(y){var m=y.boundingBox(),b=t.xCoords[v]-m.w/2,x=t.xCoords[v]+m.w/2,w=t.yCoords[v]-m.h/2,E=t.yCoords[v]+m.h/2;b<i&&(i=b),x>o&&(o=x),w<a&&(a=w),E>s&&(s=E)}}}catch(e){u=!0,c=e}finally{try{!l&&d.return&&d.return()}finally{if(u)throw c}}var T=e.x-(o+i)/2,C=e.y-(s+a)/2;t.xCoords=t.xCoords.map(function(e){return e+T}),t.yCoords=t.yCoords.map(function(e){return e+C})}else{Object.keys(t).forEach(function(e){var n=t[e],r=n.getRect().x,l=n.getRect().x+n.getRect().width,u=n.getRect().y,c=n.getRect().y+n.getRect().height;r<i&&(i=r),l>o&&(o=l),u<a&&(a=u),c>s&&(s=c)});var M=e.x-(o+i)/2,A=e.y-(s+a)/2;Object.keys(t).forEach(function(e){var n=t[e];n.setCenter(n.getCenterX()+M,n.getCenterY()+A)})}}},calcBoundingBox:function(e,t,n,r){for(var i=Number.MAX_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,l=void 0,u=void 0,c=void 0,h=void 0,d=e.descendants().not(":parent"),f=d.length,p=0;p<f;p++){var g=d[p];i>(l=t[r.get(g.id())]-g.width()/2)&&(i=l),o<(u=t[r.get(g.id())]+g.width()/2)&&(o=u),a>(c=n[r.get(g.id())]-g.height()/2)&&(a=c),s<(h=n[r.get(g.id())]+g.height()/2)&&(s=h)}var v={};return v.topLeftX=i,v.topLeftY=a,v.width=o-i,v.height=s-a,v},calcParentsWithoutChildren:function(e,t){var n=e.collection();return t.nodes(":parent").forEach(function(e){var t=!1;e.children().forEach(function(e){"none"!=e.css("display")&&(t=!0)}),t||n.merge(e)}),n}};e.exports=o},816:(e,t,n)=>{var r=n(548),i=n(140).CoSELayout,o=n(140).CoSENode,a=n(140).layoutBase.PointD,s=n(140).layoutBase.DimensionD,l=n(140).layoutBase.LayoutConstants,u=n(140).layoutBase.FDLayoutConstants,c=n(140).CoSEConstants;e.exports={coseLayout:function(e,t){var n=e.cy,h=e.eles,d=h.nodes(),f=h.edges(),p=void 0,g=void 0,v=void 0,y={};e.randomize&&(p=t.nodeIndexes,g=t.xCoords,v=t.yCoords);var m=function(e){return"function"==typeof e},b=function(e,t){return m(e)?e(t):e},x=r.calcParentsWithoutChildren(n,h);null!=e.nestingFactor&&(c.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=u.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=e.nestingFactor),null!=e.gravity&&(c.DEFAULT_GRAVITY_STRENGTH=u.DEFAULT_GRAVITY_STRENGTH=e.gravity),null!=e.numIter&&(c.MAX_ITERATIONS=u.MAX_ITERATIONS=e.numIter),null!=e.gravityRange&&(c.DEFAULT_GRAVITY_RANGE_FACTOR=u.DEFAULT_GRAVITY_RANGE_FACTOR=e.gravityRange),null!=e.gravityCompound&&(c.DEFAULT_COMPOUND_GRAVITY_STRENGTH=u.DEFAULT_COMPOUND_GRAVITY_STRENGTH=e.gravityCompound),null!=e.gravityRangeCompound&&(c.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=e.gravityRangeCompound),null!=e.initialEnergyOnIncremental&&(c.DEFAULT_COOLING_FACTOR_INCREMENTAL=u.DEFAULT_COOLING_FACTOR_INCREMENTAL=e.initialEnergyOnIncremental),null!=e.tilingCompareBy&&(c.TILING_COMPARE_BY=e.tilingCompareBy),"proof"==e.quality?l.QUALITY=2:l.QUALITY=0,c.NODE_DIMENSIONS_INCLUDE_LABELS=u.NODE_DIMENSIONS_INCLUDE_LABELS=l.NODE_DIMENSIONS_INCLUDE_LABELS=e.nodeDimensionsIncludeLabels,c.DEFAULT_INCREMENTAL=u.DEFAULT_INCREMENTAL=l.DEFAULT_INCREMENTAL=!e.randomize,c.ANIMATE=u.ANIMATE=l.ANIMATE=e.animate,c.TILE=e.tile,c.TILING_PADDING_VERTICAL="function"==typeof e.tilingPaddingVertical?e.tilingPaddingVertical.call():e.tilingPaddingVertical,c.TILING_PADDING_HORIZONTAL="function"==typeof e.tilingPaddingHorizontal?e.tilingPaddingHorizontal.call():e.tilingPaddingHorizontal,c.DEFAULT_INCREMENTAL=u.DEFAULT_INCREMENTAL=l.DEFAULT_INCREMENTAL=!0,c.PURE_INCREMENTAL=!e.randomize,l.DEFAULT_UNIFORM_LEAF_NODE_SIZES=e.uniformNodeDimensions,"transformed"==e.step&&(c.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,c.ENFORCE_CONSTRAINTS=!1,c.APPLY_LAYOUT=!1),"enforced"==e.step&&(c.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,c.ENFORCE_CONSTRAINTS=!0,c.APPLY_LAYOUT=!1),"cose"==e.step&&(c.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,c.ENFORCE_CONSTRAINTS=!1,c.APPLY_LAYOUT=!0),"all"==e.step&&(e.randomize?c.TRANSFORM_ON_CONSTRAINT_HANDLING=!0:c.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,c.ENFORCE_CONSTRAINTS=!0,c.APPLY_LAYOUT=!0),e.fixedNodeConstraint||e.alignmentConstraint||e.relativePlacementConstraint?c.TREE_REDUCTION_ON_INCREMENTAL=!1:c.TREE_REDUCTION_ON_INCREMENTAL=!0;var w=new i,E=w.newGraphManager();return function e(t,n,i,l){for(var u=n.length,c=0;c<u;c++){var h=n[c],d=null;0==h.intersection(x).length&&(d=h.children());var f=void 0,m=h.layoutDimensions({nodeDimensionsIncludeLabels:l.nodeDimensionsIncludeLabels});if(null!=h.outerWidth()&&null!=h.outerHeight())if(l.randomize)if(h.isParent()){var w=r.calcBoundingBox(h,g,v,p);f=0==h.intersection(x).length?t.add(new o(i.graphManager,new a(w.topLeftX,w.topLeftY),new s(w.width,w.height))):t.add(new o(i.graphManager,new a(w.topLeftX,w.topLeftY),new s(parseFloat(m.w),parseFloat(m.h))))}else f=t.add(new o(i.graphManager,new a(g[p.get(h.id())]-m.w/2,v[p.get(h.id())]-m.h/2),new s(parseFloat(m.w),parseFloat(m.h))));else f=t.add(new o(i.graphManager,new a(h.position("x")-m.w/2,h.position("y")-m.h/2),new s(parseFloat(m.w),parseFloat(m.h))));else f=t.add(new o(this.graphManager));f.id=h.data("id"),f.nodeRepulsion=b(l.nodeRepulsion,h),f.paddingLeft=parseInt(h.css("padding")),f.paddingTop=parseInt(h.css("padding")),f.paddingRight=parseInt(h.css("padding")),f.paddingBottom=parseInt(h.css("padding")),l.nodeDimensionsIncludeLabels&&(f.labelWidth=h.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).w,f.labelHeight=h.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).h,f.labelPosVertical=h.css("text-valign"),f.labelPosHorizontal=h.css("text-halign")),y[h.data("id")]=f,isNaN(f.rect.x)&&(f.rect.x=0),isNaN(f.rect.y)&&(f.rect.y=0),null!=d&&d.length>0&&e(i.getGraphManager().add(i.newGraph(),f),d,i,l)}}(E.addRoot(),r.getTopMostNodes(d),w,e),function(t,n,r){for(var i=0,o=0,a=0;a<r.length;a++){var s=r[a],l=y[s.data("source")],h=y[s.data("target")];if(l&&h&&l!==h&&0==l.getEdgesBetween(h).length){var d=n.add(t.newEdge(),l,h);d.id=s.id(),d.idealLength=b(e.idealEdgeLength,s),d.edgeElasticity=b(e.edgeElasticity,s),i+=d.idealLength,o++}}null!=e.idealEdgeLength&&(o>0?c.DEFAULT_EDGE_LENGTH=u.DEFAULT_EDGE_LENGTH=i/o:m(e.idealEdgeLength)?c.DEFAULT_EDGE_LENGTH=u.DEFAULT_EDGE_LENGTH=50:c.DEFAULT_EDGE_LENGTH=u.DEFAULT_EDGE_LENGTH=e.idealEdgeLength,c.MIN_REPULSION_DIST=u.MIN_REPULSION_DIST=u.DEFAULT_EDGE_LENGTH/10,c.DEFAULT_RADIAL_SEPARATION=u.DEFAULT_EDGE_LENGTH)}(w,E,f),function(e,t){t.fixedNodeConstraint&&(e.constraints.fixedNodeConstraint=t.fixedNodeConstraint),t.alignmentConstraint&&(e.constraints.alignmentConstraint=t.alignmentConstraint),t.relativePlacementConstraint&&(e.constraints.relativePlacementConstraint=t.relativePlacementConstraint)}(w,e),w.runLayout(),y}}},212:(e,t,n)=>{var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(658),o=n(548),a=n(657).spectralLayout,s=n(816).coseLayout,l=Object.freeze({quality:"default",randomize:!0,animate:!0,animationDuration:1e3,animationEasing:void 0,fit:!0,padding:30,nodeDimensionsIncludeLabels:!1,uniformNodeDimensions:!1,packComponents:!0,step:"all",samplingType:!0,sampleSize:25,nodeSeparation:75,piTol:1e-7,nodeRepulsion:function(e){return 4500},idealEdgeLength:function(e){return 50},edgeElasticity:function(e){return.45},nestingFactor:.1,gravity:.25,numIter:2500,tile:!0,tilingCompareBy:void 0,tilingPaddingVertical:10,tilingPaddingHorizontal:10,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:3.8,initialEnergyOnIncremental:.3,fixedNodeConstraint:void 0,alignmentConstraint:void 0,relativePlacementConstraint:void 0,ready:function(){},stop:function(){}}),u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.options=i({},l,t)}return r(e,[{key:"run",value:function(){var e=this.options,t=e.cy,n=e.eles,r=[],i=[],l=void 0,u=[];!e.fixedNodeConstraint||Array.isArray(e.fixedNodeConstraint)&&0!=e.fixedNodeConstraint.length||(e.fixedNodeConstraint=void 0),e.alignmentConstraint&&(!e.alignmentConstraint.vertical||Array.isArray(e.alignmentConstraint.vertical)&&0!=e.alignmentConstraint.vertical.length||(e.alignmentConstraint.vertical=void 0),!e.alignmentConstraint.horizontal||Array.isArray(e.alignmentConstraint.horizontal)&&0!=e.alignmentConstraint.horizontal.length||(e.alignmentConstraint.horizontal=void 0)),!e.relativePlacementConstraint||Array.isArray(e.relativePlacementConstraint)&&0!=e.relativePlacementConstraint.length||(e.relativePlacementConstraint=void 0),(e.fixedNodeConstraint||e.alignmentConstraint||e.relativePlacementConstraint)&&(e.tile=!1,e.packComponents=!1);var c=void 0,h=!1;if(t.layoutUtilities&&e.packComponents&&((c=t.layoutUtilities("get"))||(c=t.layoutUtilities()),h=!0),n.nodes().length>0)if(h){var d=o.getTopMostNodes(e.eles.nodes());if((l=o.connectComponents(t,e.eles,d)).forEach(function(e){var t=e.boundingBox();u.push({x:t.x1+t.w/2,y:t.y1+t.h/2})}),e.randomize&&l.forEach(function(t){e.eles=t,r.push(a(e))}),"default"==e.quality||"proof"==e.quality){var f=t.collection();if(e.tile){var p=new Map,g=0,v={nodeIndexes:p,xCoords:[],yCoords:[]},y=[];if(l.forEach(function(e,t){0==e.edges().length&&(e.nodes().forEach(function(t,n){f.merge(e.nodes()[n]),t.isParent()||(v.nodeIndexes.set(e.nodes()[n].id(),g++),v.xCoords.push(e.nodes()[0].position().x),v.yCoords.push(e.nodes()[0].position().y))}),y.push(t))}),f.length>1){var m=f.boundingBox();u.push({x:m.x1+m.w/2,y:m.y1+m.h/2}),l.push(f),r.push(v);for(var b=y.length-1;b>=0;b--)l.splice(y[b],1),r.splice(y[b],1),u.splice(y[b],1)}}l.forEach(function(t,n){e.eles=t,i.push(s(e,r[n])),o.relocateComponent(u[n],i[n],e)})}else l.forEach(function(t,n){o.relocateComponent(u[n],r[n],e)});var x=new Set;if(l.length>1){var w=[],E=n.filter(function(e){return"none"==e.css("display")});l.forEach(function(t,n){var a=void 0;if("draft"==e.quality&&(a=r[n].nodeIndexes),t.nodes().not(E).length>0){var s={edges:[],nodes:[]},l=void 0;t.nodes().not(E).forEach(function(t){if("draft"==e.quality)if(t.isParent()){var u=o.calcBoundingBox(t,r[n].xCoords,r[n].yCoords,a);s.nodes.push({x:u.topLeftX,y:u.topLeftY,width:u.width,height:u.height})}else l=a.get(t.id()),s.nodes.push({x:r[n].xCoords[l]-t.boundingbox().w/2,y:r[n].yCoords[l]-t.boundingbox().h/2,width:t.boundingbox().w,height:t.boundingbox().h});else i[n][t.id()]&&s.nodes.push({x:i[n][t.id()].getLeft(),y:i[n][t.id()].getTop(),width:i[n][t.id()].getWidth(),height:i[n][t.id()].getHeight()})}),t.edges().forEach(function(t){var l=t.source(),u=t.target();if("none"!=l.css("display")&&"none"!=u.css("display"))if("draft"==e.quality){var c=a.get(l.id()),h=a.get(u.id()),d=[],f=[];if(l.isParent()){var p=o.calcBoundingBox(l,r[n].xCoords,r[n].yCoords,a);d.push(p.topLeftX+p.width/2),d.push(p.topLeftY+p.height/2)}else d.push(r[n].xCoords[c]),d.push(r[n].yCoords[c]);if(u.isParent()){var g=o.calcBoundingBox(u,r[n].xCoords,r[n].yCoords,a);f.push(g.topLeftX+g.width/2),f.push(g.topLeftY+g.height/2)}else f.push(r[n].xCoords[h]),f.push(r[n].yCoords[h]);s.edges.push({startX:d[0],startY:d[1],endX:f[0],endY:f[1]})}else i[n][l.id()]&&i[n][u.id()]&&s.edges.push({startX:i[n][l.id()].getCenterX(),startY:i[n][l.id()].getCenterY(),endX:i[n][u.id()].getCenterX(),endY:i[n][u.id()].getCenterY()})}),s.nodes.length>0&&(w.push(s),x.add(n))}});var T=c.packComponents(w,e.randomize).shifts;if("draft"==e.quality)r.forEach(function(e,t){var n=e.xCoords.map(function(e){return e+T[t].dx}),r=e.yCoords.map(function(e){return e+T[t].dy});e.xCoords=n,e.yCoords=r});else{var C=0;x.forEach(function(e){Object.keys(i[e]).forEach(function(t){var n=i[e][t];n.setCenter(n.getCenterX()+T[C].dx,n.getCenterY()+T[C].dy)}),C++})}}}else{var M=e.eles.boundingBox();if(u.push({x:M.x1+M.w/2,y:M.y1+M.h/2}),e.randomize){var A=a(e);r.push(A)}"default"==e.quality||"proof"==e.quality?(i.push(s(e,r[0])),o.relocateComponent(u[0],i[0],e)):o.relocateComponent(u[0],r[0],e)}var N=function(t,n){if("default"==e.quality||"proof"==e.quality){"number"==typeof t&&(t=n);var o=void 0,a=void 0,s=t.data("id");return i.forEach(function(e){s in e&&(o={x:e[s].getRect().getCenterX(),y:e[s].getRect().getCenterY()},a=e[s])}),e.nodeDimensionsIncludeLabels&&(a.labelWidth&&("left"==a.labelPosHorizontal?o.x+=a.labelWidth/2:"right"==a.labelPosHorizontal&&(o.x-=a.labelWidth/2)),a.labelHeight&&("top"==a.labelPosVertical?o.y+=a.labelHeight/2:"bottom"==a.labelPosVertical&&(o.y-=a.labelHeight/2))),null==o&&(o={x:t.position("x"),y:t.position("y")}),{x:o.x,y:o.y}}var l=void 0;return r.forEach(function(e){var n=e.nodeIndexes.get(t.id());null!=n&&(l={x:e.xCoords[n],y:e.yCoords[n]})}),null==l&&(l={x:t.position("x"),y:t.position("y")}),{x:l.x,y:l.y}};if("default"==e.quality||"proof"==e.quality||e.randomize){var _=o.calcParentsWithoutChildren(t,n),S=n.filter(function(e){return"none"==e.css("display")});e.eles=n.not(S),n.nodes().not(":parent").not(S).layoutPositions(this,e,N),_.length>0&&_.forEach(function(e){e.position(N(e))})}else console.log("If randomize option is set to false, then quality option must be 'default' or 'proof'.")}}]),e}();e.exports=u},657:(e,t,n)=>{var r=n(548),i=n(140).layoutBase.Matrix,o=n(140).layoutBase.SVD;e.exports={spectralLayout:function(e){var t=e.cy,n=e.eles,a=n.nodes(),s=n.nodes(":parent"),l=new Map,u=new Map,c=new Map,h=[],d=[],f=[],p=[],g=[],v=[],y=[],m=[],b=void 0,x=1e8,w=1e-9,E=e.piTol,T=e.samplingType,C=e.nodeSeparation,M=void 0,A=function(e,t,n){for(var r=[],i=0,o=0,a=0,s=void 0,l=[],c=0,d=1,f=0;f<b;f++)l[f]=x;for(r[o]=e,l[e]=0;o>=i;){a=r[i++];for(var p=h[a],y=0;y<p.length;y++)l[s=u.get(p[y])]==x&&(l[s]=l[a]+1,r[++o]=s);v[a][t]=l[a]*C}if(n){for(var m=0;m<b;m++)v[m][t]<g[m]&&(g[m]=v[m][t]);for(var w=0;w<b;w++)g[w]>c&&(c=g[w],d=w)}return d};r.connectComponents(t,n,r.getTopMostNodes(a),l),s.forEach(function(e){r.connectComponents(t,n,r.getTopMostNodes(e.descendants().intersection(n)),l)});for(var N=0,_=0;_<a.length;_++)a[_].isParent()||u.set(a[_].id(),N++);var S=!0,k=!1,P=void 0;try{for(var I,O=l.keys()[Symbol.iterator]();!(S=(I=O.next()).done);S=!0){var D=I.value;u.set(D,N++)}}catch(e){k=!0,P=e}finally{try{!S&&O.return&&O.return()}finally{if(k)throw P}}for(var L=0;L<u.size;L++)h[L]=[];s.forEach(function(e){for(var t=e.children().intersection(n);0==t.nodes(":childless").length;)t=t.nodes()[0].children().intersection(n);var r=0,i=t.nodes(":childless")[0].connectedEdges().length;t.nodes(":childless").forEach(function(e,t){e.connectedEdges().length<i&&(i=e.connectedEdges().length,r=t)}),c.set(e.id(),t.nodes(":childless")[r].id())}),a.forEach(function(e){var t=void 0;t=e.isParent()?u.get(c.get(e.id())):u.get(e.id()),e.neighborhood().nodes().forEach(function(r){n.intersection(e.edgesWith(r)).length>0&&(r.isParent()?h[t].push(c.get(r.id())):h[t].push(r.id()))})});var R=function(e){var n=u.get(e),r=void 0;l.get(e).forEach(function(i){r=t.getElementById(i).isParent()?c.get(i):i,h[n].push(r),h[u.get(r)].push(e)})},B=!0,z=!1,F=void 0;try{for(var V,G=l.keys()[Symbol.iterator]();!(B=(V=G.next()).done);B=!0)R(V.value)}catch(e){z=!0,F=e}finally{try{!B&&G.return&&G.return()}finally{if(z)throw F}}var Y=void 0;if((b=u.size)>2){M=b<e.sampleSize?b:e.sampleSize;for(var X=0;X<b;X++)v[X]=[];for(var $=0;$<M;$++)m[$]=[];return"draft"==e.quality||"all"==e.step?(function(e){var t=void 0;if(e){t=Math.floor(Math.random()*b);for(var n=0;n<b;n++)g[n]=x;for(var r=0;r<M;r++)p[r]=t,t=A(t,r,e)}else{!function(){for(var e=0,t=0,n=!1;t<M;){e=Math.floor(Math.random()*b),n=!1;for(var r=0;r<t;r++)if(p[r]==e){n=!0;break}n||(p[t]=e,t++)}}();for(var i=0;i<M;i++)A(p[i],i,e)}for(var o=0;o<b;o++)for(var a=0;a<M;a++)v[o][a]*=v[o][a];for(var s=0;s<M;s++)y[s]=[];for(var l=0;l<M;l++)for(var u=0;u<M;u++)y[l][u]=v[p[u]][l]}(T),function(){for(var e=o.svd(y),t=e.S,n=e.U,r=e.V,a=t[0]*t[0]*t[0],s=[],l=0;l<M;l++){s[l]=[];for(var u=0;u<M;u++)s[l][u]=0,l==u&&(s[l][u]=t[l]/(t[l]*t[l]+a/(t[l]*t[l])))}m=i.multMat(i.multMat(r,s),i.transpose(n))}(),function(){for(var e=void 0,t=void 0,n=[],r=[],o=[],a=[],s=0;s<b;s++)n[s]=Math.random(),r[s]=Math.random();n=i.normalize(n),r=i.normalize(r);for(var l=w,u=w,c=void 0;;){for(var h=0;h<b;h++)o[h]=n[h];if(n=i.multGamma(i.multL(i.multGamma(o),v,m)),e=i.dotProduct(o,n),n=i.normalize(n),l=i.dotProduct(o,n),(c=Math.abs(l/u))<=1+E&&c>=1)break;u=l}for(var p=0;p<b;p++)o[p]=n[p];for(u=w;;){for(var g=0;g<b;g++)a[g]=r[g];if(a=i.minusOp(a,i.multCons(o,i.dotProduct(o,a))),r=i.multGamma(i.multL(i.multGamma(a),v,m)),t=i.dotProduct(a,r),r=i.normalize(r),l=i.dotProduct(a,r),(c=Math.abs(l/u))<=1+E&&c>=1)break;u=l}for(var y=0;y<b;y++)a[y]=r[y];d=i.multCons(o,Math.sqrt(Math.abs(e))),f=i.multCons(a,Math.sqrt(Math.abs(t)))}(),Y={nodeIndexes:u,xCoords:d,yCoords:f}):(u.forEach(function(e,n){d.push(t.getElementById(n).position("x")),f.push(t.getElementById(n).position("y"))}),Y={nodeIndexes:u,xCoords:d,yCoords:f}),Y}var U=u.keys(),j=t.getElementById(U.next().value),H=j.position(),W=j.outerWidth();if(d.push(H.x),f.push(H.y),2==b){var q=t.getElementById(U.next().value).outerWidth();d.push(H.x+W/2+q/2+e.idealEdgeLength),f.push(H.y)}return Y={nodeIndexes:u,xCoords:d,yCoords:f}}}},579:(e,t,n)=>{var r=n(212),i=function(e){e&&e("layout","fcose",r)};"undefined"!=typeof cytoscape&&i(cytoscape),e.exports=i},140:t=>{t.exports=e}},n={},r=function e(r){var i=n[r];if(void 0!==i)return i.exports;var o=n[r]={exports:{}};return t[r](o,o.exports,e),o.exports}(579);return r})()},e.exports=r(n(799))},143(e){var t;t=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=28)}([function(e,t,n){"use strict";function r(){}r.QUALITY=1,r.DEFAULT_CREATE_BENDS_AS_NEEDED=!1,r.DEFAULT_INCREMENTAL=!1,r.DEFAULT_ANIMATION_ON_LAYOUT=!0,r.DEFAULT_ANIMATION_DURING_LAYOUT=!1,r.DEFAULT_ANIMATION_PERIOD=50,r.DEFAULT_UNIFORM_LEAF_NODE_SIZES=!1,r.DEFAULT_GRAPH_MARGIN=15,r.NODE_DIMENSIONS_INCLUDE_LABELS=!1,r.SIMPLE_NODE_SIZE=40,r.SIMPLE_NODE_HALF_SIZE=r.SIMPLE_NODE_SIZE/2,r.EMPTY_COMPOUND_NODE_SIZE=40,r.MIN_EDGE_LENGTH=1,r.WORLD_BOUNDARY=1e6,r.INITIAL_WORLD_BOUNDARY=r.WORLD_BOUNDARY/1e3,r.WORLD_CENTER_X=1200,r.WORLD_CENTER_Y=900,e.exports=r},function(e,t,n){"use strict";var r=n(2),i=n(8),o=n(9);function a(e,t,n){r.call(this,n),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=n,this.bendpoints=[],this.source=e,this.target=t}for(var s in a.prototype=Object.create(r.prototype),r)a[s]=r[s];a.prototype.getSource=function(){return this.source},a.prototype.getTarget=function(){return this.target},a.prototype.isInterGraph=function(){return this.isInterGraph},a.prototype.getLength=function(){return this.length},a.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},a.prototype.getBendpoints=function(){return this.bendpoints},a.prototype.getLca=function(){return this.lca},a.prototype.getSourceInLca=function(){return this.sourceInLca},a.prototype.getTargetInLca=function(){return this.targetInLca},a.prototype.getOtherEnd=function(e){if(this.source===e)return this.target;if(this.target===e)return this.source;throw"Node is not incident with this edge"},a.prototype.getOtherEndInGraph=function(e,t){for(var n=this.getOtherEnd(e),r=t.getGraphManager().getRoot();;){if(n.getOwner()==t)return n;if(n.getOwner()==r)break;n=n.getOwner().getParent()}return null},a.prototype.updateLength=function(){var e=new Array(4);this.isOverlapingSourceAndTarget=i.getIntersection(this.target.getRect(),this.source.getRect(),e),this.isOverlapingSourceAndTarget||(this.lengthX=e[0]-e[2],this.lengthY=e[1]-e[3],Math.abs(this.lengthX)<1&&(this.lengthX=o.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=o.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},a.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=o.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=o.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},e.exports=a},function(e,t,n){"use strict";e.exports=function(e){this.vGraphObject=e}},function(e,t,n){"use strict";var r=n(2),i=n(10),o=n(13),a=n(0),s=n(16),l=n(5);function u(e,t,n,a){null==n&&null==a&&(a=t),r.call(this,a),null!=e.graphManager&&(e=e.graphManager),this.estimatedSize=i.MIN_VALUE,this.inclusionTreeDepth=i.MAX_VALUE,this.vGraphObject=a,this.edges=[],this.graphManager=e,this.rect=null!=n&&null!=t?new o(t.x,t.y,n.width,n.height):new o}for(var c in u.prototype=Object.create(r.prototype),r)u[c]=r[c];u.prototype.getEdges=function(){return this.edges},u.prototype.getChild=function(){return this.child},u.prototype.getOwner=function(){return this.owner},u.prototype.getWidth=function(){return this.rect.width},u.prototype.setWidth=function(e){this.rect.width=e},u.prototype.getHeight=function(){return this.rect.height},u.prototype.setHeight=function(e){this.rect.height=e},u.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},u.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},u.prototype.getCenter=function(){return new l(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},u.prototype.getLocation=function(){return new l(this.rect.x,this.rect.y)},u.prototype.getRect=function(){return this.rect},u.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},u.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},u.prototype.setRect=function(e,t){this.rect.x=e.x,this.rect.y=e.y,this.rect.width=t.width,this.rect.height=t.height},u.prototype.setCenter=function(e,t){this.rect.x=e-this.rect.width/2,this.rect.y=t-this.rect.height/2},u.prototype.setLocation=function(e,t){this.rect.x=e,this.rect.y=t},u.prototype.moveBy=function(e,t){this.rect.x+=e,this.rect.y+=t},u.prototype.getEdgeListToNode=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.target==e){if(r.source!=n)throw"Incorrect edge source!";t.push(r)}}),t},u.prototype.getEdgesBetween=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.source!=n&&r.target!=n)throw"Incorrect edge source and/or target";r.target!=e&&r.source!=e||t.push(r)}),t},u.prototype.getNeighborsList=function(){var e=new Set,t=this;return t.edges.forEach(function(n){if(n.source==t)e.add(n.target);else{if(n.target!=t)throw"Incorrect incidency!";e.add(n.source)}}),e},u.prototype.withChildren=function(){var e=new Set;if(e.add(this),null!=this.child)for(var t=this.child.getNodes(),n=0;n<t.length;n++)t[n].withChildren().forEach(function(t){e.add(t)});return e},u.prototype.getNoOfChildren=function(){var e=0;if(null==this.child)e=1;else for(var t=this.child.getNodes(),n=0;n<t.length;n++)e+=t[n].getNoOfChildren();return 0==e&&(e=1),e},u.prototype.getEstimatedSize=function(){if(this.estimatedSize==i.MIN_VALUE)throw"assert failed";return this.estimatedSize},u.prototype.calcEstimatedSize=function(){return null==this.child?this.estimatedSize=(this.rect.width+this.rect.height)/2:(this.estimatedSize=this.child.calcEstimatedSize(),this.rect.width=this.estimatedSize,this.rect.height=this.estimatedSize,this.estimatedSize)},u.prototype.scatter=function(){var e,t,n=-a.INITIAL_WORLD_BOUNDARY,r=a.INITIAL_WORLD_BOUNDARY;e=a.WORLD_CENTER_X+s.nextDouble()*(r-n)+n;var i=-a.INITIAL_WORLD_BOUNDARY,o=a.INITIAL_WORLD_BOUNDARY;t=a.WORLD_CENTER_Y+s.nextDouble()*(o-i)+i,this.rect.x=e,this.rect.y=t},u.prototype.updateBounds=function(){if(null==this.getChild())throw"assert failed";if(0!=this.getChild().getNodes().length){var e=this.getChild();if(e.updateBounds(!0),this.rect.x=e.getLeft(),this.rect.y=e.getTop(),this.setWidth(e.getRight()-e.getLeft()),this.setHeight(e.getBottom()-e.getTop()),a.NODE_DIMENSIONS_INCLUDE_LABELS){var t=e.getRight()-e.getLeft(),n=e.getBottom()-e.getTop();this.labelWidth&&("left"==this.labelPosHorizontal?(this.rect.x-=this.labelWidth,this.setWidth(t+this.labelWidth)):"center"==this.labelPosHorizontal&&this.labelWidth>t?(this.rect.x-=(this.labelWidth-t)/2,this.setWidth(this.labelWidth)):"right"==this.labelPosHorizontal&&this.setWidth(t+this.labelWidth)),this.labelHeight&&("top"==this.labelPosVertical?(this.rect.y-=this.labelHeight,this.setHeight(n+this.labelHeight)):"center"==this.labelPosVertical&&this.labelHeight>n?(this.rect.y-=(this.labelHeight-n)/2,this.setHeight(this.labelHeight)):"bottom"==this.labelPosVertical&&this.setHeight(n+this.labelHeight))}}},u.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==i.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},u.prototype.transform=function(e){var t=this.rect.x;t>a.WORLD_BOUNDARY?t=a.WORLD_BOUNDARY:t<-a.WORLD_BOUNDARY&&(t=-a.WORLD_BOUNDARY);var n=this.rect.y;n>a.WORLD_BOUNDARY?n=a.WORLD_BOUNDARY:n<-a.WORLD_BOUNDARY&&(n=-a.WORLD_BOUNDARY);var r=new l(t,n),i=e.inverseTransformPoint(r);this.setLocation(i.x,i.y)},u.prototype.getLeft=function(){return this.rect.x},u.prototype.getRight=function(){return this.rect.x+this.rect.width},u.prototype.getTop=function(){return this.rect.y},u.prototype.getBottom=function(){return this.rect.y+this.rect.height},u.prototype.getParent=function(){return null==this.owner?null:this.owner.getParent()},e.exports=u},function(e,t,n){"use strict";var r=n(0);function i(){}for(var o in r)i[o]=r[o];i.MAX_ITERATIONS=2500,i.DEFAULT_EDGE_LENGTH=50,i.DEFAULT_SPRING_STRENGTH=.45,i.DEFAULT_REPULSION_STRENGTH=4500,i.DEFAULT_GRAVITY_STRENGTH=.4,i.DEFAULT_COMPOUND_GRAVITY_STRENGTH=1,i.DEFAULT_GRAVITY_RANGE_FACTOR=3.8,i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=1.5,i.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION=!0,i.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION=!0,i.DEFAULT_COOLING_FACTOR_INCREMENTAL=.3,i.COOLING_ADAPTATION_FACTOR=.33,i.ADAPTATION_LOWER_NODE_LIMIT=1e3,i.ADAPTATION_UPPER_NODE_LIMIT=5e3,i.MAX_NODE_DISPLACEMENT_INCREMENTAL=100,i.MAX_NODE_DISPLACEMENT=3*i.MAX_NODE_DISPLACEMENT_INCREMENTAL,i.MIN_REPULSION_DIST=i.DEFAULT_EDGE_LENGTH/10,i.CONVERGENCE_CHECK_PERIOD=100,i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=.1,i.MIN_EDGE_LENGTH=1,i.GRID_CALCULATION_CHECK_PERIOD=10,e.exports=i},function(e,t,n){"use strict";function r(e,t){null==e&&null==t?(this.x=0,this.y=0):(this.x=e,this.y=t)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(e){this.x=e},r.prototype.setY=function(e){this.y=e},r.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},e.exports=r},function(e,t,n){"use strict";var r=n(2),i=n(10),o=n(0),a=n(7),s=n(3),l=n(1),u=n(13),c=n(12),h=n(11);function d(e,t,n){r.call(this,n),this.estimatedSize=i.MIN_VALUE,this.margin=o.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=e,null!=t&&t instanceof a?this.graphManager=t:null!=t&&t instanceof Layout&&(this.graphManager=t.graphManager)}for(var f in d.prototype=Object.create(r.prototype),r)d[f]=r[f];d.prototype.getNodes=function(){return this.nodes},d.prototype.getEdges=function(){return this.edges},d.prototype.getGraphManager=function(){return this.graphManager},d.prototype.getParent=function(){return this.parent},d.prototype.getLeft=function(){return this.left},d.prototype.getRight=function(){return this.right},d.prototype.getTop=function(){return this.top},d.prototype.getBottom=function(){return this.bottom},d.prototype.isConnected=function(){return this.isConnected},d.prototype.add=function(e,t,n){if(null==t&&null==n){var r=e;if(null==this.graphManager)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(r)>-1)throw"Node already in graph!";return r.owner=this,this.getNodes().push(r),r}var i=e;if(!(this.getNodes().indexOf(t)>-1&&this.getNodes().indexOf(n)>-1))throw"Source or target not in graph!";if(t.owner!=n.owner||t.owner!=this)throw"Both owners must be this graph!";return t.owner!=n.owner?null:(i.source=t,i.target=n,i.isInterGraph=!1,this.getEdges().push(i),t.edges.push(i),n!=t&&n.edges.push(i),i)},d.prototype.remove=function(e){var t=e;if(e instanceof s){if(null==t)throw"Node is null!";if(null==t.owner||t.owner!=this)throw"Owner graph is invalid!";if(null==this.graphManager)throw"Owner graph manager is invalid!";for(var n=t.edges.slice(),r=n.length,i=0;i<r;i++)(o=n[i]).isInterGraph?this.graphManager.remove(o):o.source.owner.remove(o);if(-1==(a=this.nodes.indexOf(t)))throw"Node not in owner node list!";this.nodes.splice(a,1)}else if(e instanceof l){var o;if(null==(o=e))throw"Edge is null!";if(null==o.source||null==o.target)throw"Source and/or target is null!";if(null==o.source.owner||null==o.target.owner||o.source.owner!=this||o.target.owner!=this)throw"Source and/or target owner is invalid!";var a,u=o.source.edges.indexOf(o),c=o.target.edges.indexOf(o);if(!(u>-1&&c>-1))throw"Source and/or target doesn't know this edge!";if(o.source.edges.splice(u,1),o.target!=o.source&&o.target.edges.splice(c,1),-1==(a=o.source.owner.getEdges().indexOf(o)))throw"Not in owner's edge list!";o.source.owner.getEdges().splice(a,1)}},d.prototype.updateLeftTop=function(){for(var e,t,n,r=i.MAX_VALUE,o=i.MAX_VALUE,a=this.getNodes(),s=a.length,l=0;l<s;l++){var u=a[l];r>(e=u.getTop())&&(r=e),o>(t=u.getLeft())&&(o=t)}return r==i.MAX_VALUE?null:(n=null!=a[0].getParent().paddingLeft?a[0].getParent().paddingLeft:this.margin,this.left=o-n,this.top=r-n,new c(this.left,this.top))},d.prototype.updateBounds=function(e){for(var t,n,r,o,a,s=i.MAX_VALUE,l=-i.MAX_VALUE,c=i.MAX_VALUE,h=-i.MAX_VALUE,d=this.nodes,f=d.length,p=0;p<f;p++){var g=d[p];e&&null!=g.child&&g.updateBounds(),s>(t=g.getLeft())&&(s=t),l<(n=g.getRight())&&(l=n),c>(r=g.getTop())&&(c=r),h<(o=g.getBottom())&&(h=o)}var v=new u(s,c,l-s,h-c);s==i.MAX_VALUE&&(this.left=this.parent.getLeft(),this.right=this.parent.getRight(),this.top=this.parent.getTop(),this.bottom=this.parent.getBottom()),a=null!=d[0].getParent().paddingLeft?d[0].getParent().paddingLeft:this.margin,this.left=v.x-a,this.right=v.x+v.width+a,this.top=v.y-a,this.bottom=v.y+v.height+a},d.calculateBounds=function(e){for(var t,n,r,o,a=i.MAX_VALUE,s=-i.MAX_VALUE,l=i.MAX_VALUE,c=-i.MAX_VALUE,h=e.length,d=0;d<h;d++){var f=e[d];a>(t=f.getLeft())&&(a=t),s<(n=f.getRight())&&(s=n),l>(r=f.getTop())&&(l=r),c<(o=f.getBottom())&&(c=o)}return new u(a,l,s-a,c-l)},d.prototype.getInclusionTreeDepth=function(){return this==this.graphManager.getRoot()?1:this.parent.getInclusionTreeDepth()},d.prototype.getEstimatedSize=function(){if(this.estimatedSize==i.MIN_VALUE)throw"assert failed";return this.estimatedSize},d.prototype.calcEstimatedSize=function(){for(var e=0,t=this.nodes,n=t.length,r=0;r<n;r++)e+=t[r].calcEstimatedSize();return this.estimatedSize=0==e?o.EMPTY_COMPOUND_NODE_SIZE:e/Math.sqrt(this.nodes.length),this.estimatedSize},d.prototype.updateConnected=function(){var e=this;if(0!=this.nodes.length){var t,n,r=new h,i=new Set,o=this.nodes[0];for(o.withChildren().forEach(function(e){r.push(e),i.add(e)});0!==r.length;)for(var a=(t=(o=r.shift()).getEdges()).length,s=0;s<a;s++)null==(n=t[s].getOtherEndInGraph(o,this))||i.has(n)||n.withChildren().forEach(function(e){r.push(e),i.add(e)});if(this.isConnected=!1,i.size>=this.nodes.length){var l=0;i.forEach(function(t){t.owner==e&&l++}),l==this.nodes.length&&(this.isConnected=!0)}}else this.isConnected=!0},e.exports=d},function(e,t,n){"use strict";var r,i=n(1);function o(e){r=n(6),this.layout=e,this.graphs=[],this.edges=[]}o.prototype.addRoot=function(){var e=this.layout.newGraph(),t=this.layout.newNode(null),n=this.add(e,t);return this.setRootGraph(n),this.rootGraph},o.prototype.add=function(e,t,n,r,i){if(null==n&&null==r&&null==i){if(null==e)throw"Graph is null!";if(null==t)throw"Parent node is null!";if(this.graphs.indexOf(e)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(e),null!=e.parent)throw"Already has a parent!";if(null!=t.child)throw"Already has a child!";return e.parent=t,t.child=e,e}i=n,n=e;var o=(r=t).getOwner(),a=i.getOwner();if(null==o||o.getGraphManager()!=this)throw"Source not in this graph mgr!";if(null==a||a.getGraphManager()!=this)throw"Target not in this graph mgr!";if(o==a)return n.isInterGraph=!1,o.add(n,r,i);if(n.isInterGraph=!0,n.source=r,n.target=i,this.edges.indexOf(n)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(n),null==n.source||null==n.target)throw"Edge source and/or target is null!";if(-1!=n.source.edges.indexOf(n)||-1!=n.target.edges.indexOf(n))throw"Edge already in source and/or target incidency list!";return n.source.edges.push(n),n.target.edges.push(n),n},o.prototype.remove=function(e){if(e instanceof r){var t=e;if(t.getGraphManager()!=this)throw"Graph not in this graph mgr";if(t!=this.rootGraph&&(null==t.parent||t.parent.graphManager!=this))throw"Invalid parent node!";for(var n,o=[],a=(o=o.concat(t.getEdges())).length,s=0;s<a;s++)n=o[s],t.remove(n);var l,u=[];for(a=(u=u.concat(t.getNodes())).length,s=0;s<a;s++)l=u[s],t.remove(l);t==this.rootGraph&&this.setRootGraph(null);var c=this.graphs.indexOf(t);this.graphs.splice(c,1),t.parent=null}else if(e instanceof i){if(null==(n=e))throw"Edge is null!";if(!n.isInterGraph)throw"Not an inter-graph edge!";if(null==n.source||null==n.target)throw"Source and/or target is null!";if(-1==n.source.edges.indexOf(n)||-1==n.target.edges.indexOf(n))throw"Source and/or target doesn't know this edge!";if(c=n.source.edges.indexOf(n),n.source.edges.splice(c,1),c=n.target.edges.indexOf(n),n.target.edges.splice(c,1),null==n.source.owner||null==n.source.owner.getGraphManager())throw"Edge owner graph or owner graph manager is null!";if(-1==n.source.owner.getGraphManager().edges.indexOf(n))throw"Not in owner graph manager's edge list!";c=n.source.owner.getGraphManager().edges.indexOf(n),n.source.owner.getGraphManager().edges.splice(c,1)}},o.prototype.updateBounds=function(){this.rootGraph.updateBounds(!0)},o.prototype.getGraphs=function(){return this.graphs},o.prototype.getAllNodes=function(){if(null==this.allNodes){for(var e=[],t=this.getGraphs(),n=t.length,r=0;r<n;r++)e=e.concat(t[r].getNodes());this.allNodes=e}return this.allNodes},o.prototype.resetAllNodes=function(){this.allNodes=null},o.prototype.resetAllEdges=function(){this.allEdges=null},o.prototype.resetAllNodesToApplyGravitation=function(){this.allNodesToApplyGravitation=null},o.prototype.getAllEdges=function(){if(null==this.allEdges){for(var e=[],t=this.getGraphs(),n=(t.length,0);n<t.length;n++)e=e.concat(t[n].getEdges());e=e.concat(this.edges),this.allEdges=e}return this.allEdges},o.prototype.getAllNodesToApplyGravitation=function(){return this.allNodesToApplyGravitation},o.prototype.setAllNodesToApplyGravitation=function(e){if(null!=this.allNodesToApplyGravitation)throw"assert failed";this.allNodesToApplyGravitation=e},o.prototype.getRoot=function(){return this.rootGraph},o.prototype.setRootGraph=function(e){if(e.getGraphManager()!=this)throw"Root not in this graph mgr!";this.rootGraph=e,null==e.parent&&(e.parent=this.layout.newNode("Root node"))},o.prototype.getLayout=function(){return this.layout},o.prototype.isOneAncestorOfOther=function(e,t){if(null==e||null==t)throw"assert failed";if(e==t)return!0;for(var n,r=e.getOwner();null!=(n=r.getParent());){if(n==t)return!0;if(null==(r=n.getOwner()))break}for(r=t.getOwner();null!=(n=r.getParent());){if(n==e)return!0;if(null==(r=n.getOwner()))break}return!1},o.prototype.calcLowestCommonAncestors=function(){for(var e,t,n,r,i,o=this.getAllEdges(),a=o.length,s=0;s<a;s++)if(t=(e=o[s]).source,n=e.target,e.lca=null,e.sourceInLca=t,e.targetInLca=n,t!=n){for(r=t.getOwner();null==e.lca;){for(e.targetInLca=n,i=n.getOwner();null==e.lca;){if(i==r){e.lca=i;break}if(i==this.rootGraph)break;if(null!=e.lca)throw"assert failed";e.targetInLca=i.getParent(),i=e.targetInLca.getOwner()}if(r==this.rootGraph)break;null==e.lca&&(e.sourceInLca=r.getParent(),r=e.sourceInLca.getOwner())}if(null==e.lca)throw"assert failed"}else e.lca=t.getOwner()},o.prototype.calcLowestCommonAncestor=function(e,t){if(e==t)return e.getOwner();for(var n=e.getOwner();null!=n;){for(var r=t.getOwner();null!=r;){if(r==n)return r;r=r.getParent().getOwner()}n=n.getParent().getOwner()}return n},o.prototype.calcInclusionTreeDepths=function(e,t){var n;null==e&&null==t&&(e=this.rootGraph,t=1);for(var r=e.getNodes(),i=r.length,o=0;o<i;o++)(n=r[o]).inclusionTreeDepth=t,null!=n.child&&this.calcInclusionTreeDepths(n.child,t+1)},o.prototype.includesInvalidEdge=function(){for(var e,t=[],n=this.edges.length,r=0;r<n;r++)e=this.edges[r],this.isOneAncestorOfOther(e.source,e.target)&&t.push(e);for(r=0;r<t.length;r++)this.remove(t[r]);return!1},e.exports=o},function(e,t,n){"use strict";var r=n(12);function i(){}i.calcSeparationAmount=function(e,t,n,r){if(!e.intersects(t))throw"assert failed";var i=new Array(2);this.decideDirectionsForOverlappingNodes(e,t,i),n[0]=Math.min(e.getRight(),t.getRight())-Math.max(e.x,t.x),n[1]=Math.min(e.getBottom(),t.getBottom())-Math.max(e.y,t.y),e.getX()<=t.getX()&&e.getRight()>=t.getRight()?n[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight()):t.getX()<=e.getX()&&t.getRight()>=e.getRight()&&(n[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight())),e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()?n[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()):t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()&&(n[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()));var o=Math.abs((t.getCenterY()-e.getCenterY())/(t.getCenterX()-e.getCenterX()));t.getCenterY()===e.getCenterY()&&t.getCenterX()===e.getCenterX()&&(o=1);var a=o*n[0],s=n[1]/o;n[0]<s?s=n[0]:a=n[1],n[0]=-1*i[0]*(s/2+r),n[1]=-1*i[1]*(a/2+r)},i.decideDirectionsForOverlappingNodes=function(e,t,n){e.getCenterX()<t.getCenterX()?n[0]=-1:n[0]=1,e.getCenterY()<t.getCenterY()?n[1]=-1:n[1]=1},i.getIntersection2=function(e,t,n){var r=e.getCenterX(),i=e.getCenterY(),o=t.getCenterX(),a=t.getCenterY();if(e.intersects(t))return n[0]=r,n[1]=i,n[2]=o,n[3]=a,!0;var s=e.getX(),l=e.getY(),u=e.getRight(),c=e.getX(),h=e.getBottom(),d=e.getRight(),f=e.getWidthHalf(),p=e.getHeightHalf(),g=t.getX(),v=t.getY(),y=t.getRight(),m=t.getX(),b=t.getBottom(),x=t.getRight(),w=t.getWidthHalf(),E=t.getHeightHalf(),T=!1,C=!1;if(r===o){if(i>a)return n[0]=r,n[1]=l,n[2]=o,n[3]=b,!1;if(i<a)return n[0]=r,n[1]=h,n[2]=o,n[3]=v,!1}else if(i===a){if(r>o)return n[0]=s,n[1]=i,n[2]=y,n[3]=a,!1;if(r<o)return n[0]=u,n[1]=i,n[2]=g,n[3]=a,!1}else{var M=e.height/e.width,A=t.height/t.width,N=(a-i)/(o-r),_=void 0,S=void 0,k=void 0,P=void 0,I=void 0,O=void 0;if(-M===N?r>o?(n[0]=c,n[1]=h,T=!0):(n[0]=u,n[1]=l,T=!0):M===N&&(r>o?(n[0]=s,n[1]=l,T=!0):(n[0]=d,n[1]=h,T=!0)),-A===N?o>r?(n[2]=m,n[3]=b,C=!0):(n[2]=y,n[3]=v,C=!0):A===N&&(o>r?(n[2]=g,n[3]=v,C=!0):(n[2]=x,n[3]=b,C=!0)),T&&C)return!1;if(r>o?i>a?(_=this.getCardinalDirection(M,N,4),S=this.getCardinalDirection(A,N,2)):(_=this.getCardinalDirection(-M,N,3),S=this.getCardinalDirection(-A,N,1)):i>a?(_=this.getCardinalDirection(-M,N,1),S=this.getCardinalDirection(-A,N,3)):(_=this.getCardinalDirection(M,N,2),S=this.getCardinalDirection(A,N,4)),!T)switch(_){case 1:P=l,k=r+-p/N,n[0]=k,n[1]=P;break;case 2:k=d,P=i+f*N,n[0]=k,n[1]=P;break;case 3:P=h,k=r+p/N,n[0]=k,n[1]=P;break;case 4:k=c,P=i+-f*N,n[0]=k,n[1]=P}if(!C)switch(S){case 1:O=v,I=o+-E/N,n[2]=I,n[3]=O;break;case 2:I=x,O=a+w*N,n[2]=I,n[3]=O;break;case 3:O=b,I=o+E/N,n[2]=I,n[3]=O;break;case 4:I=m,O=a+-w*N,n[2]=I,n[3]=O}}return!1},i.getCardinalDirection=function(e,t,n){return e>t?n:1+n%4},i.getIntersection=function(e,t,n,i){if(null==i)return this.getIntersection2(e,t,n);var o,a,s,l,u,c,h,d=e.x,f=e.y,p=t.x,g=t.y,v=n.x,y=n.y,m=i.x,b=i.y;return 0===(h=(o=g-f)*(l=v-m)-(a=b-y)*(s=d-p))?null:new r((s*(c=m*y-v*b)-l*(u=p*f-d*g))/h,(a*u-o*c)/h)},i.angleOfVector=function(e,t,n,r){var i=void 0;return e!==n?(i=Math.atan((r-t)/(n-e)),n<e?i+=Math.PI:r<t&&(i+=this.TWO_PI)):i=r<t?this.ONE_AND_HALF_PI:this.HALF_PI,i},i.doIntersect=function(e,t,n,r){var i=e.x,o=e.y,a=t.x,s=t.y,l=n.x,u=n.y,c=r.x,h=r.y,d=(a-i)*(h-u)-(c-l)*(s-o);if(0===d)return!1;var f=((h-u)*(c-i)+(l-c)*(h-o))/d,p=((o-s)*(c-i)+(a-i)*(h-o))/d;return 0<f&&f<1&&0<p&&p<1},i.findCircleLineIntersections=function(e,t,n,r,i,o,a){var s=(n-e)*(n-e)+(r-t)*(r-t),l=2*((e-i)*(n-e)+(t-o)*(r-t)),u=(e-i)*(e-i)+(t-o)*(t-o)-a*a;if(l*l-4*s*u>=0){var c=(-l+Math.sqrt(l*l-4*s*u))/(2*s),h=(-l-Math.sqrt(l*l-4*s*u))/(2*s);return c>=0&&c<=1?[c]:h>=0&&h<=1?[h]:null}return null},i.HALF_PI=.5*Math.PI,i.ONE_AND_HALF_PI=1.5*Math.PI,i.TWO_PI=2*Math.PI,i.THREE_PI=3*Math.PI,e.exports=i},function(e,t,n){"use strict";function r(){}r.sign=function(e){return e>0?1:e<0?-1:0},r.floor=function(e){return e<0?Math.ceil(e):Math.floor(e)},r.ceil=function(e){return e<0?Math.floor(e):Math.ceil(e)},e.exports=r},function(e,t,n){"use strict";function r(){}r.MAX_VALUE=2147483647,r.MIN_VALUE=-2147483648,e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(e){return{value:e,next:null,prev:null}},o=function(e,t,n,r){return null!==e?e.next=t:r.head=t,null!==n?n.prev=t:r.tail=t,t.prev=e,t.next=n,r.length++,t},a=function(e,t){var n=e.prev,r=e.next;return null!==n?n.next=r:t.head=r,null!==r?r.prev=n:t.tail=n,e.prev=e.next=null,t.length--,e},s=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.length=0,this.head=null,this.tail=null,null!=t&&t.forEach(function(e){return n.push(e)})}return r(e,[{key:"size",value:function(){return this.length}},{key:"insertBefore",value:function(e,t){return o(t.prev,i(e),t,this)}},{key:"insertAfter",value:function(e,t){return o(t,i(e),t.next,this)}},{key:"insertNodeBefore",value:function(e,t){return o(t.prev,e,t,this)}},{key:"insertNodeAfter",value:function(e,t){return o(t,e,t.next,this)}},{key:"push",value:function(e){return o(this.tail,i(e),null,this)}},{key:"unshift",value:function(e){return o(null,i(e),this.head,this)}},{key:"remove",value:function(e){return a(e,this)}},{key:"pop",value:function(){return a(this.tail,this).value}},{key:"popNode",value:function(){return a(this.tail,this)}},{key:"shift",value:function(){return a(this.head,this).value}},{key:"shiftNode",value:function(){return a(this.head,this)}},{key:"get_object_at",value:function(e){if(e<=this.length()){for(var t=1,n=this.head;t<e;)n=n.next,t++;return n.value}}},{key:"set_object_at",value:function(e,t){if(e<=this.length()){for(var n=1,r=this.head;n<e;)r=r.next,n++;r.value=t}}}]),e}();e.exports=s},function(e,t,n){"use strict";function r(e,t,n){this.x=null,this.y=null,null==e&&null==t&&null==n?(this.x=0,this.y=0):"number"==typeof e&&"number"==typeof t&&null==n?(this.x=e,this.y=t):"Point"==e.constructor.name&&null==t&&null==n&&(n=e,this.x=n.x,this.y=n.y)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.getLocation=function(){return new r(this.x,this.y)},r.prototype.setLocation=function(e,t,n){"Point"==e.constructor.name&&null==t&&null==n?(n=e,this.setLocation(n.x,n.y)):"number"==typeof e&&"number"==typeof t&&null==n&&(parseInt(e)==e&&parseInt(t)==t?this.move(e,t):(this.x=Math.floor(e+.5),this.y=Math.floor(t+.5)))},r.prototype.move=function(e,t){this.x=e,this.y=t},r.prototype.translate=function(e,t){this.x+=e,this.y+=t},r.prototype.equals=function(e){if("Point"==e.constructor.name){var t=e;return this.x==t.x&&this.y==t.y}return this==e},r.prototype.toString=function(){return(new r).constructor.name+"[x="+this.x+",y="+this.y+"]"},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r){this.x=0,this.y=0,this.width=0,this.height=0,null!=e&&null!=t&&null!=n&&null!=r&&(this.x=e,this.y=t,this.width=n,this.height=r)}r.prototype.getX=function(){return this.x},r.prototype.setX=function(e){this.x=e},r.prototype.getY=function(){return this.y},r.prototype.setY=function(e){this.y=e},r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(e){this.width=e},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(e){this.height=e},r.prototype.getRight=function(){return this.x+this.width},r.prototype.getBottom=function(){return this.y+this.height},r.prototype.intersects=function(e){return!(this.getRight()<e.x||this.getBottom()<e.y||e.getRight()<this.x||e.getBottom()<this.y)},r.prototype.getCenterX=function(){return this.x+this.width/2},r.prototype.getMinX=function(){return this.getX()},r.prototype.getMaxX=function(){return this.getX()+this.width},r.prototype.getCenterY=function(){return this.y+this.height/2},r.prototype.getMinY=function(){return this.getY()},r.prototype.getMaxY=function(){return this.getY()+this.height},r.prototype.getWidthHalf=function(){return this.width/2},r.prototype.getHeightHalf=function(){return this.height/2},e.exports=r},function(e,t,n){"use strict";var r="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};function i(){}i.lastID=0,i.createID=function(e){return i.isPrimitive(e)?e:(null!=e.uniqueID||(e.uniqueID=i.getString(),i.lastID++),e.uniqueID)},i.getString=function(e){return null==e&&(e=i.lastID),"Object#"+e},i.isPrimitive=function(e){var t=void 0===e?"undefined":r(e);return null==e||"object"!=t&&"function"!=t},e.exports=i},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var i=n(0),o=n(7),a=n(3),s=n(1),l=n(6),u=n(5),c=n(17),h=n(29);function d(e){h.call(this),this.layoutQuality=i.QUALITY,this.createBendsAsNeeded=i.DEFAULT_CREATE_BENDS_AS_NEEDED,this.incremental=i.DEFAULT_INCREMENTAL,this.animationOnLayout=i.DEFAULT_ANIMATION_ON_LAYOUT,this.animationDuringLayout=i.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=i.DEFAULT_ANIMATION_PERIOD,this.uniformLeafNodeSizes=i.DEFAULT_UNIFORM_LEAF_NODE_SIZES,this.edgeToDummyNodes=new Map,this.graphManager=new o(this),this.isLayoutFinished=!1,this.isSubLayout=!1,this.isRemoteUse=!1,null!=e&&(this.isRemoteUse=e)}d.RANDOM_SEED=1,d.prototype=Object.create(h.prototype),d.prototype.getGraphManager=function(){return this.graphManager},d.prototype.getAllNodes=function(){return this.graphManager.getAllNodes()},d.prototype.getAllEdges=function(){return this.graphManager.getAllEdges()},d.prototype.getAllNodesToApplyGravitation=function(){return this.graphManager.getAllNodesToApplyGravitation()},d.prototype.newGraphManager=function(){var e=new o(this);return this.graphManager=e,e},d.prototype.newGraph=function(e){return new l(null,this.graphManager,e)},d.prototype.newNode=function(e){return new a(this.graphManager,e)},d.prototype.newEdge=function(e){return new s(null,null,e)},d.prototype.checkLayoutSuccess=function(){return null==this.graphManager.getRoot()||0==this.graphManager.getRoot().getNodes().length||this.graphManager.includesInvalidEdge()},d.prototype.runLayout=function(){var e;return this.isLayoutFinished=!1,this.tilingPreLayout&&this.tilingPreLayout(),this.initParameters(),e=!this.checkLayoutSuccess()&&this.layout(),"during"!==i.ANIMATE&&(e&&(this.isSubLayout||this.doPostLayout()),this.tilingPostLayout&&this.tilingPostLayout(),this.isLayoutFinished=!0,e)},d.prototype.doPostLayout=function(){this.incremental||this.transform(),this.update()},d.prototype.update2=function(){if(this.createBendsAsNeeded&&(this.createBendpointsFromDummyNodes(),this.graphManager.resetAllEdges()),!this.isRemoteUse){for(var e=this.graphManager.getAllEdges(),t=0;t<e.length;t++)e[t];var n=this.graphManager.getRoot().getNodes();for(t=0;t<n.length;t++)n[t];this.update(this.graphManager.getRoot())}},d.prototype.update=function(e){if(null==e)this.update2();else if(e instanceof a){var t=e;if(null!=t.getChild())for(var n=t.getChild().getNodes(),r=0;r<n.length;r++)update(n[r]);null!=t.vGraphObject&&t.vGraphObject.update(t)}else if(e instanceof s){var i=e;null!=i.vGraphObject&&i.vGraphObject.update(i)}else if(e instanceof l){var o=e;null!=o.vGraphObject&&o.vGraphObject.update(o)}},d.prototype.initParameters=function(){this.isSubLayout||(this.layoutQuality=i.QUALITY,this.animationDuringLayout=i.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=i.DEFAULT_ANIMATION_PERIOD,this.animationOnLayout=i.DEFAULT_ANIMATION_ON_LAYOUT,this.incremental=i.DEFAULT_INCREMENTAL,this.createBendsAsNeeded=i.DEFAULT_CREATE_BENDS_AS_NEEDED,this.uniformLeafNodeSizes=i.DEFAULT_UNIFORM_LEAF_NODE_SIZES),this.animationDuringLayout&&(this.animationOnLayout=!1)},d.prototype.transform=function(e){if(null==e)this.transform(new u(0,0));else{var t=new c,n=this.graphManager.getRoot().updateLeftTop();if(null!=n){t.setWorldOrgX(e.x),t.setWorldOrgY(e.y),t.setDeviceOrgX(n.x),t.setDeviceOrgY(n.y);for(var r=this.getAllNodes(),i=0;i<r.length;i++)r[i].transform(t)}}},d.prototype.positionNodesRandomly=function(e){if(null==e)this.positionNodesRandomly(this.getGraphManager().getRoot()),this.getGraphManager().getRoot().updateBounds(!0);else for(var t,n,r=e.getNodes(),i=0;i<r.length;i++)null==(n=(t=r[i]).getChild())||0==n.getNodes().length?t.scatter():(this.positionNodesRandomly(n),t.updateBounds())},d.prototype.getFlatForest=function(){for(var e=[],t=!0,n=this.graphManager.getRoot().getNodes(),i=!0,o=0;o<n.length;o++)null!=n[o].getChild()&&(i=!1);if(!i)return e;var a=new Set,s=[],l=new Map,u=[];for(u=u.concat(n);u.length>0&&t;){for(s.push(u[0]);s.length>0&&t;){var c=s[0];s.splice(0,1),a.add(c);var h=c.getEdges();for(o=0;o<h.length;o++){var d=h[o].getOtherEnd(c);if(l.get(c)!=d){if(a.has(d)){t=!1;break}s.push(d),l.set(d,c)}}}if(t){var f=[].concat(r(a));for(e.push(f),o=0;o<f.length;o++){var p=f[o],g=u.indexOf(p);g>-1&&u.splice(g,1)}a=new Set,l=new Map}else e=[]}return e},d.prototype.createDummyNodesForBendpoints=function(e){for(var t=[],n=e.source,r=this.graphManager.calcLowestCommonAncestor(e.source,e.target),i=0;i<e.bendpoints.length;i++){var o=this.newNode(null);o.setRect(new Point(0,0),new Dimension(1,1)),r.add(o);var a=this.newEdge(null);this.graphManager.add(a,n,o),t.add(o),n=o}return a=this.newEdge(null),this.graphManager.add(a,n,e.target),this.edgeToDummyNodes.set(e,t),e.isInterGraph()?this.graphManager.remove(e):r.remove(e),t},d.prototype.createBendpointsFromDummyNodes=function(){var e=[];e=e.concat(this.graphManager.getAllEdges()),e=[].concat(r(this.edgeToDummyNodes.keys())).concat(e);for(var t=0;t<e.length;t++){var n=e[t];if(n.bendpoints.length>0){for(var i=this.edgeToDummyNodes.get(n),o=0;o<i.length;o++){var a=i[o],s=new u(a.getCenterX(),a.getCenterY()),l=n.bendpoints.get(o);l.x=s.x,l.y=s.y,a.getOwner().remove(a)}this.graphManager.add(n,n.source,n.target)}}},d.transform=function(e,t,n,r){if(null!=n&&null!=r){var i=t;return e<=50?i-=(t-t/n)/50*(50-e):i+=(t*r-t)/50*(e-50),i}var o,a;return e<=50?(o=9*t/500,a=t/10):(o=9*t/50,a=-8*t),o*e+a},d.findCenterOfTree=function(e){var t=[];t=t.concat(e);var n=[],r=new Map,i=!1,o=null;1!=t.length&&2!=t.length||(i=!0,o=t[0]);for(var a=0;a<t.length;a++){var s=(c=t[a]).getNeighborsList().size;r.set(c,c.getNeighborsList().size),1==s&&n.push(c)}var l=[];for(l=l.concat(n);!i;){var u=[];for(u=u.concat(l),l=[],a=0;a<t.length;a++){var c=t[a],h=t.indexOf(c);h>=0&&t.splice(h,1),c.getNeighborsList().forEach(function(e){if(n.indexOf(e)<0){var t=r.get(e)-1;1==t&&l.push(e),r.set(e,t)}})}n=n.concat(l),1!=t.length&&2!=t.length||(i=!0,o=t[0])}return o},d.prototype.setGraphManager=function(e){this.graphManager=e},e.exports=d},function(e,t,n){"use strict";function r(){}r.seed=1,r.x=0,r.nextDouble=function(){return r.x=1e4*Math.sin(r.seed++),r.x-Math.floor(r.x)},e.exports=r},function(e,t,n){"use strict";var r=n(5);function i(e,t){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}i.prototype.getWorldOrgX=function(){return this.lworldOrgX},i.prototype.setWorldOrgX=function(e){this.lworldOrgX=e},i.prototype.getWorldOrgY=function(){return this.lworldOrgY},i.prototype.setWorldOrgY=function(e){this.lworldOrgY=e},i.prototype.getWorldExtX=function(){return this.lworldExtX},i.prototype.setWorldExtX=function(e){this.lworldExtX=e},i.prototype.getWorldExtY=function(){return this.lworldExtY},i.prototype.setWorldExtY=function(e){this.lworldExtY=e},i.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},i.prototype.setDeviceOrgX=function(e){this.ldeviceOrgX=e},i.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},i.prototype.setDeviceOrgY=function(e){this.ldeviceOrgY=e},i.prototype.getDeviceExtX=function(){return this.ldeviceExtX},i.prototype.setDeviceExtX=function(e){this.ldeviceExtX=e},i.prototype.getDeviceExtY=function(){return this.ldeviceExtY},i.prototype.setDeviceExtY=function(e){this.ldeviceExtY=e},i.prototype.transformX=function(e){var t=0,n=this.lworldExtX;return 0!=n&&(t=this.ldeviceOrgX+(e-this.lworldOrgX)*this.ldeviceExtX/n),t},i.prototype.transformY=function(e){var t=0,n=this.lworldExtY;return 0!=n&&(t=this.ldeviceOrgY+(e-this.lworldOrgY)*this.ldeviceExtY/n),t},i.prototype.inverseTransformX=function(e){var t=0,n=this.ldeviceExtX;return 0!=n&&(t=this.lworldOrgX+(e-this.ldeviceOrgX)*this.lworldExtX/n),t},i.prototype.inverseTransformY=function(e){var t=0,n=this.ldeviceExtY;return 0!=n&&(t=this.lworldOrgY+(e-this.ldeviceOrgY)*this.lworldExtY/n),t},i.prototype.inverseTransformPoint=function(e){return new r(this.inverseTransformX(e.x),this.inverseTransformY(e.y))},e.exports=i},function(e,t,n){"use strict";var r=n(15),i=n(4),o=n(0),a=n(8),s=n(9);function l(){r.call(this),this.useSmartIdealEdgeLengthCalculation=i.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=i.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=i.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=i.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.displacementThresholdPerNode=3*i.DEFAULT_EDGE_LENGTH/100,this.coolingFactor=i.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.initialCoolingFactor=i.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.totalDisplacement=0,this.oldTotalDisplacement=0,this.maxIterations=i.MAX_ITERATIONS}for(var u in l.prototype=Object.create(r.prototype),r)l[u]=r[u];l.prototype.initParameters=function(){r.prototype.initParameters.call(this,arguments),this.totalIterations=0,this.notAnimatedIterations=0,this.useFRGridVariant=i.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION,this.grid=[]},l.prototype.calcIdealEdgeLengths=function(){for(var e,t,n,r,a,s,l,u=this.getGraphManager().getAllEdges(),c=0;c<u.length;c++)t=(e=u[c]).idealLength,e.isInterGraph&&(r=e.getSource(),a=e.getTarget(),s=e.getSourceInLca().getEstimatedSize(),l=e.getTargetInLca().getEstimatedSize(),this.useSmartIdealEdgeLengthCalculation&&(e.idealLength+=s+l-2*o.SIMPLE_NODE_SIZE),n=e.getLca().getInclusionTreeDepth(),e.idealLength+=t*i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR*(r.getInclusionTreeDepth()+a.getInclusionTreeDepth()-2*n))},l.prototype.initSpringEmbedder=function(){var e=this.getAllNodes().length;this.incremental?(e>i.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*i.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(e-i.ADAPTATION_LOWER_NODE_LIMIT)/(i.ADAPTATION_UPPER_NODE_LIMIT-i.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-i.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=i.MAX_NODE_DISPLACEMENT_INCREMENTAL):(e>i.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(i.COOLING_ADAPTATION_FACTOR,1-(e-i.ADAPTATION_LOWER_NODE_LIMIT)/(i.ADAPTATION_UPPER_NODE_LIMIT-i.ADAPTATION_LOWER_NODE_LIMIT)*(1-i.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=i.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(5*this.getAllNodes().length,this.maxIterations),this.displacementThresholdPerNode=3*i.DEFAULT_EDGE_LENGTH/100,this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},l.prototype.calcSpringForces=function(){for(var e,t=this.getAllEdges(),n=0;n<t.length;n++)e=t[n],this.calcSpringForce(e,e.idealLength)},l.prototype.calcRepulsionForces=function(){var e,t,n,r,o,a=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=this.getAllNodes();if(this.useFRGridVariant)for(this.totalIterations%i.GRID_CALCULATION_CHECK_PERIOD==1&&a&&this.updateGrid(),o=new Set,e=0;e<l.length;e++)n=l[e],this.calculateRepulsionForceOfANode(n,o,a,s),o.add(n);else for(e=0;e<l.length;e++)for(n=l[e],t=e+1;t<l.length;t++)r=l[t],n.getOwner()==r.getOwner()&&this.calcRepulsionForce(n,r)},l.prototype.calcGravitationalForces=function(){for(var e,t=this.getAllNodesToApplyGravitation(),n=0;n<t.length;n++)e=t[n],this.calcGravitationalForce(e)},l.prototype.moveNodes=function(){for(var e=this.getAllNodes(),t=0;t<e.length;t++)e[t].move()},l.prototype.calcSpringForce=function(e,t){var n,r,i,o,a=e.getSource(),s=e.getTarget();if(this.uniformLeafNodeSizes&&null==a.getChild()&&null==s.getChild())e.updateLengthSimple();else if(e.updateLength(),e.isOverlapingSourceAndTarget)return;0!=(n=e.getLength())&&(i=(r=e.edgeElasticity*(n-t))*(e.lengthX/n),o=r*(e.lengthY/n),a.springForceX+=i,a.springForceY+=o,s.springForceX-=i,s.springForceY-=o)},l.prototype.calcRepulsionForce=function(e,t){var n,r,o,l,u,c,h,d=e.getRect(),f=t.getRect(),p=new Array(2),g=new Array(4);if(d.intersects(f)){a.calcSeparationAmount(d,f,p,i.DEFAULT_EDGE_LENGTH/2),c=2*p[0],h=2*p[1];var v=e.noOfChildren*t.noOfChildren/(e.noOfChildren+t.noOfChildren);e.repulsionForceX-=v*c,e.repulsionForceY-=v*h,t.repulsionForceX+=v*c,t.repulsionForceY+=v*h}else this.uniformLeafNodeSizes&&null==e.getChild()&&null==t.getChild()?(n=f.getCenterX()-d.getCenterX(),r=f.getCenterY()-d.getCenterY()):(a.getIntersection(d,f,g),n=g[2]-g[0],r=g[3]-g[1]),Math.abs(n)<i.MIN_REPULSION_DIST&&(n=s.sign(n)*i.MIN_REPULSION_DIST),Math.abs(r)<i.MIN_REPULSION_DIST&&(r=s.sign(r)*i.MIN_REPULSION_DIST),o=n*n+r*r,l=Math.sqrt(o),c=(u=(e.nodeRepulsion/2+t.nodeRepulsion/2)*e.noOfChildren*t.noOfChildren/o)*n/l,h=u*r/l,e.repulsionForceX-=c,e.repulsionForceY-=h,t.repulsionForceX+=c,t.repulsionForceY+=h},l.prototype.calcGravitationalForce=function(e){var t,n,r,i,o,a,s,l;n=((t=e.getOwner()).getRight()+t.getLeft())/2,r=(t.getTop()+t.getBottom())/2,i=e.getCenterX()-n,o=e.getCenterY()-r,a=Math.abs(i)+e.getWidth()/2,s=Math.abs(o)+e.getHeight()/2,e.getOwner()==this.graphManager.getRoot()?(a>(l=t.getEstimatedSize()*this.gravityRangeFactor)||s>l)&&(e.gravitationForceX=-this.gravityConstant*i,e.gravitationForceY=-this.gravityConstant*o):(a>(l=t.getEstimatedSize()*this.compoundGravityRangeFactor)||s>l)&&(e.gravitationForceX=-this.gravityConstant*i*this.compoundGravityConstant,e.gravitationForceY=-this.gravityConstant*o*this.compoundGravityConstant)},l.prototype.isConverged=function(){var e,t=!1;return this.totalIterations>this.maxIterations/3&&(t=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),e=this.totalDisplacement<this.totalDisplacementThreshold,this.oldTotalDisplacement=this.totalDisplacement,e||t},l.prototype.animate=function(){this.animationDuringLayout&&!this.isSubLayout&&(this.notAnimatedIterations==this.animationPeriod?(this.update(),this.notAnimatedIterations=0):this.notAnimatedIterations++)},l.prototype.calcNoOfChildrenForAllNodes=function(){for(var e,t=this.graphManager.getAllNodes(),n=0;n<t.length;n++)(e=t[n]).noOfChildren=e.getNoOfChildren()},l.prototype.calcGrid=function(e){var t,n;t=parseInt(Math.ceil((e.getRight()-e.getLeft())/this.repulsionRange)),n=parseInt(Math.ceil((e.getBottom()-e.getTop())/this.repulsionRange));for(var r=new Array(t),i=0;i<t;i++)r[i]=new Array(n);for(i=0;i<t;i++)for(var o=0;o<n;o++)r[i][o]=new Array;return r},l.prototype.addNodeToGrid=function(e,t,n){var r,i,o,a;r=parseInt(Math.floor((e.getRect().x-t)/this.repulsionRange)),i=parseInt(Math.floor((e.getRect().width+e.getRect().x-t)/this.repulsionRange)),o=parseInt(Math.floor((e.getRect().y-n)/this.repulsionRange)),a=parseInt(Math.floor((e.getRect().height+e.getRect().y-n)/this.repulsionRange));for(var s=r;s<=i;s++)for(var l=o;l<=a;l++)this.grid[s][l].push(e),e.setGridCoordinates(r,i,o,a)},l.prototype.updateGrid=function(){var e,t,n=this.getAllNodes();for(this.grid=this.calcGrid(this.graphManager.getRoot()),e=0;e<n.length;e++)t=n[e],this.addNodeToGrid(t,this.graphManager.getRoot().getLeft(),this.graphManager.getRoot().getTop())},l.prototype.calculateRepulsionForceOfANode=function(e,t,n,r){if(this.totalIterations%i.GRID_CALCULATION_CHECK_PERIOD==1&&n||r){var o,a=new Set;e.surrounding=new Array;for(var s=this.grid,l=e.startX-1;l<e.finishX+2;l++)for(var u=e.startY-1;u<e.finishY+2;u++)if(!(l<0||u<0||l>=s.length||u>=s[0].length))for(var c=0;c<s[l][u].length;c++)if(o=s[l][u][c],e.getOwner()==o.getOwner()&&e!=o&&!t.has(o)&&!a.has(o)){var h=Math.abs(e.getCenterX()-o.getCenterX())-(e.getWidth()/2+o.getWidth()/2),d=Math.abs(e.getCenterY()-o.getCenterY())-(e.getHeight()/2+o.getHeight()/2);h<=this.repulsionRange&&d<=this.repulsionRange&&a.add(o)}e.surrounding=[].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(a))}for(l=0;l<e.surrounding.length;l++)this.calcRepulsionForce(e,e.surrounding[l])},l.prototype.calcRepulsionRange=function(){return 0},e.exports=l},function(e,t,n){"use strict";var r=n(1),i=n(4);function o(e,t,n){r.call(this,e,t,n),this.idealLength=i.DEFAULT_EDGE_LENGTH,this.edgeElasticity=i.DEFAULT_SPRING_STRENGTH}for(var a in o.prototype=Object.create(r.prototype),r)o[a]=r[a];e.exports=o},function(e,t,n){"use strict";var r=n(3),i=n(4);function o(e,t,n,o){r.call(this,e,t,n,o),this.nodeRepulsion=i.DEFAULT_REPULSION_STRENGTH,this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0,this.startX=0,this.finishX=0,this.startY=0,this.finishY=0,this.surrounding=[]}for(var a in o.prototype=Object.create(r.prototype),r)o[a]=r[a];o.prototype.setGridCoordinates=function(e,t,n,r){this.startX=e,this.finishX=t,this.startY=n,this.finishY=r},e.exports=o},function(e,t,n){"use strict";function r(e,t){this.width=0,this.height=0,null!==e&&null!==t&&(this.height=t,this.width=e)}r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(e){this.width=e},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(e){this.height=e},e.exports=r},function(e,t,n){"use strict";var r=n(14);function i(){this.map={},this.keys=[]}i.prototype.put=function(e,t){var n=r.createID(e);this.contains(n)||(this.map[n]=t,this.keys.push(e))},i.prototype.contains=function(e){return r.createID(e),null!=this.map[e]},i.prototype.get=function(e){var t=r.createID(e);return this.map[t]},i.prototype.keySet=function(){return this.keys},e.exports=i},function(e,t,n){"use strict";var r=n(14);function i(){this.set={}}i.prototype.add=function(e){var t=r.createID(e);this.contains(t)||(this.set[t]=e)},i.prototype.remove=function(e){delete this.set[r.createID(e)]},i.prototype.clear=function(){this.set={}},i.prototype.contains=function(e){return this.set[r.createID(e)]==e},i.prototype.isEmpty=function(){return 0===this.size()},i.prototype.size=function(){return Object.keys(this.set).length},i.prototype.addAllTo=function(e){for(var t=Object.keys(this.set),n=t.length,r=0;r<n;r++)e.push(this.set[t[r]])},i.prototype.size=function(){return Object.keys(this.set).length},i.prototype.addAll=function(e){for(var t=e.length,n=0;n<t;n++){var r=e[n];this.add(r)}},e.exports=i},function(e,t,n){"use strict";function r(){}r.multMat=function(e,t){for(var n=[],r=0;r<e.length;r++){n[r]=[];for(var i=0;i<t[0].length;i++){n[r][i]=0;for(var o=0;o<e[0].length;o++)n[r][i]+=e[r][o]*t[o][i]}}return n},r.transpose=function(e){for(var t=[],n=0;n<e[0].length;n++){t[n]=[];for(var r=0;r<e.length;r++)t[n][r]=e[r][n]}return t},r.multCons=function(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=e[r]*t;return n},r.minusOp=function(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=e[r]-t[r];return n},r.dotProduct=function(e,t){for(var n=0,r=0;r<e.length;r++)n+=e[r]*t[r];return n},r.mag=function(e){return Math.sqrt(this.dotProduct(e,e))},r.normalize=function(e){for(var t=[],n=this.mag(e),r=0;r<e.length;r++)t[r]=e[r]/n;return t},r.multGamma=function(e){for(var t=[],n=0,r=0;r<e.length;r++)n+=e[r];n*=-1/e.length;for(var i=0;i<e.length;i++)t[i]=n+e[i];return t},r.multL=function(e,t,n){for(var r=[],i=[],o=[],a=0;a<t[0].length;a++){for(var s=0,l=0;l<t.length;l++)s+=-.5*t[l][a]*e[l];i[a]=s}for(var u=0;u<n.length;u++){for(var c=0,h=0;h<n.length;h++)c+=n[u][h]*i[h];o[u]=c}for(var d=0;d<t.length;d++){for(var f=0,p=0;p<t[0].length;p++)f+=t[d][p]*o[p];r[d]=f}return r},e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(11),o=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),null===n&&void 0===n||(this.compareFunction=this._defaultCompareFunction);var r=void 0;r=t instanceof i?t.size():t.length,this._quicksort(t,0,r-1)}return r(e,[{key:"_quicksort",value:function(e,t,n){if(t<n){var r=this._partition(e,t,n);this._quicksort(e,t,r),this._quicksort(e,r+1,n)}}},{key:"_partition",value:function(e,t,n){for(var r=this._get(e,t),i=t,o=n;;){for(;this.compareFunction(r,this._get(e,o));)o--;for(;this.compareFunction(this._get(e,i),r);)i++;if(!(i<o))return o;this._swap(e,i,o),i++,o--}}},{key:"_get",value:function(e,t){return e instanceof i?e.get_object_at(t):e[t]}},{key:"_set",value:function(e,t,n){e instanceof i?e.set_object_at(t,n):e[t]=n}},{key:"_swap",value:function(e,t,n){var r=this._get(e,t);this._set(e,t,this._get(e,n)),this._set(e,n,r)}},{key:"_defaultCompareFunction",value:function(e,t){return t>e}}]),e}();e.exports=o},function(e,t,n){"use strict";function r(){}r.svd=function(e){this.U=null,this.V=null,this.s=null,this.m=0,this.n=0,this.m=e.length,this.n=e[0].length;var t=Math.min(this.m,this.n);this.s=function(e){for(var t=[];e-- >0;)t.push(0);return t}(Math.min(this.m+1,this.n)),this.U=function e(t){if(0==t.length)return 0;for(var n=[],r=0;r<t[0];r++)n.push(e(t.slice(1)));return n}([this.m,t]),this.V=function(e){return function e(t){if(0==t.length)return 0;for(var n=[],r=0;r<t[0];r++)n.push(e(t.slice(1)));return n}(e)}([this.n,this.n]);for(var n=function(e){for(var t=[];e-- >0;)t.push(0);return t}(this.n),i=function(e){for(var t=[];e-- >0;)t.push(0);return t}(this.m),o=Math.min(this.m-1,this.n),a=Math.max(0,Math.min(this.n-2,this.m)),s=0;s<Math.max(o,a);s++){if(s<o){this.s[s]=0;for(var l=s;l<this.m;l++)this.s[s]=r.hypot(this.s[s],e[l][s]);if(0!==this.s[s]){e[s][s]<0&&(this.s[s]=-this.s[s]);for(var u=s;u<this.m;u++)e[u][s]/=this.s[s];e[s][s]+=1}this.s[s]=-this.s[s]}for(var c=s+1;c<this.n;c++){if(function(e,t){return e&&t}(s<o,0!==this.s[s])){for(var h=0,d=s;d<this.m;d++)h+=e[d][s]*e[d][c];h=-h/e[s][s];for(var f=s;f<this.m;f++)e[f][c]+=h*e[f][s]}n[c]=e[s][c]}if(function(e,t){return t}(0,s<o))for(var p=s;p<this.m;p++)this.U[p][s]=e[p][s];if(s<a){n[s]=0;for(var g=s+1;g<this.n;g++)n[s]=r.hypot(n[s],n[g]);if(0!==n[s]){n[s+1]<0&&(n[s]=-n[s]);for(var v=s+1;v<this.n;v++)n[v]/=n[s];n[s+1]+=1}if(n[s]=-n[s],function(e,t){return e&&t}(s+1<this.m,0!==n[s])){for(var y=s+1;y<this.m;y++)i[y]=0;for(var m=s+1;m<this.n;m++)for(var b=s+1;b<this.m;b++)i[b]+=n[m]*e[b][m];for(var x=s+1;x<this.n;x++)for(var w=-n[x]/n[s+1],E=s+1;E<this.m;E++)e[E][x]+=w*i[E]}for(var T=s+1;T<this.n;T++)this.V[T][s]=n[T]}}var C=Math.min(this.n,this.m+1);o<this.n&&(this.s[o]=e[o][o]),this.m<C&&(this.s[C-1]=0),a+1<C&&(n[a]=e[a][C-1]),n[C-1]=0;for(var M=o;M<t;M++){for(var A=0;A<this.m;A++)this.U[A][M]=0;this.U[M][M]=1}for(var N=o-1;N>=0;N--)if(0!==this.s[N]){for(var _=N+1;_<t;_++){for(var S=0,k=N;k<this.m;k++)S+=this.U[k][N]*this.U[k][_];S=-S/this.U[N][N];for(var P=N;P<this.m;P++)this.U[P][_]+=S*this.U[P][N]}for(var I=N;I<this.m;I++)this.U[I][N]=-this.U[I][N];this.U[N][N]=1+this.U[N][N];for(var O=0;O<N-1;O++)this.U[O][N]=0}else{for(var D=0;D<this.m;D++)this.U[D][N]=0;this.U[N][N]=1}for(var L=this.n-1;L>=0;L--){if(function(e,t){return e&&t}(L<a,0!==n[L]))for(var R=L+1;R<t;R++){for(var B=0,z=L+1;z<this.n;z++)B+=this.V[z][L]*this.V[z][R];B=-B/this.V[L+1][L];for(var F=L+1;F<this.n;F++)this.V[F][R]+=B*this.V[F][L]}for(var V=0;V<this.n;V++)this.V[V][L]=0;this.V[L][L]=1}for(var G=C-1,Y=Math.pow(2,-52),X=Math.pow(2,-966);C>0;){var $=void 0,U=void 0;for($=C-2;$>=-1&&-1!==$;$--)if(Math.abs(n[$])<=X+Y*(Math.abs(this.s[$])+Math.abs(this.s[$+1]))){n[$]=0;break}if($===C-2)U=4;else{var j=void 0;for(j=C-1;j>=$&&j!==$;j--){var H=(j!==C?Math.abs(n[j]):0)+(j!==$+1?Math.abs(n[j-1]):0);if(Math.abs(this.s[j])<=X+Y*H){this.s[j]=0;break}}j===$?U=3:j===C-1?U=1:(U=2,$=j)}switch($++,U){case 1:var W=n[C-2];n[C-2]=0;for(var q=C-2;q>=$;q--){var K=r.hypot(this.s[q],W),Z=this.s[q]/K,Q=W/K;this.s[q]=K,q!==$&&(W=-Q*n[q-1],n[q-1]=Z*n[q-1]);for(var J=0;J<this.n;J++)K=Z*this.V[J][q]+Q*this.V[J][C-1],this.V[J][C-1]=-Q*this.V[J][q]+Z*this.V[J][C-1],this.V[J][q]=K}break;case 2:var ee=n[$-1];n[$-1]=0;for(var te=$;te<C;te++){var ne=r.hypot(this.s[te],ee),re=this.s[te]/ne,ie=ee/ne;this.s[te]=ne,ee=-ie*n[te],n[te]=re*n[te];for(var oe=0;oe<this.m;oe++)ne=re*this.U[oe][te]+ie*this.U[oe][$-1],this.U[oe][$-1]=-ie*this.U[oe][te]+re*this.U[oe][$-1],this.U[oe][te]=ne}break;case 3:var ae=Math.max(Math.max(Math.max(Math.max(Math.abs(this.s[C-1]),Math.abs(this.s[C-2])),Math.abs(n[C-2])),Math.abs(this.s[$])),Math.abs(n[$])),se=this.s[C-1]/ae,le=this.s[C-2]/ae,ue=n[C-2]/ae,ce=this.s[$]/ae,he=n[$]/ae,de=((le+se)*(le-se)+ue*ue)/2,fe=se*ue*(se*ue),pe=0;(function(e,t){return e||t})(0!==de,0!==fe)&&(pe=Math.sqrt(de*de+fe),de<0&&(pe=-pe),pe=fe/(de+pe));for(var ge=(ce+se)*(ce-se)+pe,ve=ce*he,ye=$;ye<C-1;ye++){var me=r.hypot(ge,ve),be=ge/me,xe=ve/me;ye!==$&&(n[ye-1]=me),ge=be*this.s[ye]+xe*n[ye],n[ye]=be*n[ye]-xe*this.s[ye],ve=xe*this.s[ye+1],this.s[ye+1]=be*this.s[ye+1];for(var we=0;we<this.n;we++)me=be*this.V[we][ye]+xe*this.V[we][ye+1],this.V[we][ye+1]=-xe*this.V[we][ye]+be*this.V[we][ye+1],this.V[we][ye]=me;if(be=ge/(me=r.hypot(ge,ve)),xe=ve/me,this.s[ye]=me,ge=be*n[ye]+xe*this.s[ye+1],this.s[ye+1]=-xe*n[ye]+be*this.s[ye+1],ve=xe*n[ye+1],n[ye+1]=be*n[ye+1],ye<this.m-1)for(var Ee=0;Ee<this.m;Ee++)me=be*this.U[Ee][ye]+xe*this.U[Ee][ye+1],this.U[Ee][ye+1]=-xe*this.U[Ee][ye]+be*this.U[Ee][ye+1],this.U[Ee][ye]=me}n[C-2]=ge;break;case 4:if(this.s[$]<=0){this.s[$]=this.s[$]<0?-this.s[$]:0;for(var Te=0;Te<=G;Te++)this.V[Te][$]=-this.V[Te][$]}for(;$<G&&!(this.s[$]>=this.s[$+1]);){var Ce=this.s[$];if(this.s[$]=this.s[$+1],this.s[$+1]=Ce,$<this.n-1)for(var Me=0;Me<this.n;Me++)Ce=this.V[Me][$+1],this.V[Me][$+1]=this.V[Me][$],this.V[Me][$]=Ce;if($<this.m-1)for(var Ae=0;Ae<this.m;Ae++)Ce=this.U[Ae][$+1],this.U[Ae][$+1]=this.U[Ae][$],this.U[Ae][$]=Ce;$++}C--}}return{U:this.U,V:this.V,S:this.s}},r.hypot=function(e,t){var n=void 0;return Math.abs(e)>Math.abs(t)?(n=t/e,n=Math.abs(e)*Math.sqrt(1+n*n)):0!=t?(n=e/t,n=Math.abs(t)*Math.sqrt(1+n*n)):n=0,n},e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.sequence1=t,this.sequence2=n,this.match_score=r,this.mismatch_penalty=i,this.gap_penalty=o,this.iMax=t.length+1,this.jMax=n.length+1,this.grid=new Array(this.iMax);for(var a=0;a<this.iMax;a++){this.grid[a]=new Array(this.jMax);for(var s=0;s<this.jMax;s++)this.grid[a][s]=0}this.tracebackGrid=new Array(this.iMax);for(var l=0;l<this.iMax;l++){this.tracebackGrid[l]=new Array(this.jMax);for(var u=0;u<this.jMax;u++)this.tracebackGrid[l][u]=[null,null,null]}this.alignments=[],this.score=-1,this.computeGrids()}return r(e,[{key:"getScore",value:function(){return this.score}},{key:"getAlignments",value:function(){return this.alignments}},{key:"computeGrids",value:function(){for(var e=1;e<this.jMax;e++)this.grid[0][e]=this.grid[0][e-1]+this.gap_penalty,this.tracebackGrid[0][e]=[!1,!1,!0];for(var t=1;t<this.iMax;t++)this.grid[t][0]=this.grid[t-1][0]+this.gap_penalty,this.tracebackGrid[t][0]=[!1,!0,!1];for(var n=1;n<this.iMax;n++)for(var r=1;r<this.jMax;r++){var i=[this.sequence1[n-1]===this.sequence2[r-1]?this.grid[n-1][r-1]+this.match_score:this.grid[n-1][r-1]+this.mismatch_penalty,this.grid[n-1][r]+this.gap_penalty,this.grid[n][r-1]+this.gap_penalty],o=this.arrayAllMaxIndexes(i);this.grid[n][r]=i[o[0]],this.tracebackGrid[n][r]=[o.includes(0),o.includes(1),o.includes(2)]}this.score=this.grid[this.iMax-1][this.jMax-1]}},{key:"alignmentTraceback",value:function(){var e=[];for(e.push({pos:[this.sequence1.length,this.sequence2.length],seq1:"",seq2:""});e[0];){var t=e[0],n=this.tracebackGrid[t.pos[0]][t.pos[1]];n[0]&&e.push({pos:[t.pos[0]-1,t.pos[1]-1],seq1:this.sequence1[t.pos[0]-1]+t.seq1,seq2:this.sequence2[t.pos[1]-1]+t.seq2}),n[1]&&e.push({pos:[t.pos[0]-1,t.pos[1]],seq1:this.sequence1[t.pos[0]-1]+t.seq1,seq2:"-"+t.seq2}),n[2]&&e.push({pos:[t.pos[0],t.pos[1]-1],seq1:"-"+t.seq1,seq2:this.sequence2[t.pos[1]-1]+t.seq2}),0===t.pos[0]&&0===t.pos[1]&&this.alignments.push({sequence1:t.seq1,sequence2:t.seq2}),e.shift()}return this.alignments}},{key:"getAllIndexes",value:function(e,t){for(var n=[],r=-1;-1!==(r=e.indexOf(t,r+1));)n.push(r);return n}},{key:"arrayAllMaxIndexes",value:function(e){return this.getAllIndexes(e,Math.max.apply(null,e))}}]),e}();e.exports=i},function(e,t,n){"use strict";var r=function(){};r.FDLayout=n(18),r.FDLayoutConstants=n(4),r.FDLayoutEdge=n(19),r.FDLayoutNode=n(20),r.DimensionD=n(21),r.HashMap=n(22),r.HashSet=n(23),r.IGeometry=n(8),r.IMath=n(9),r.Integer=n(10),r.Point=n(12),r.PointD=n(5),r.RandomSeed=n(16),r.RectangleD=n(13),r.Transform=n(17),r.UniqueIDGeneretor=n(14),r.Quicksort=n(25),r.LinkedList=n(11),r.LGraphObject=n(2),r.LGraph=n(6),r.LEdge=n(1),r.LGraphManager=n(7),r.LNode=n(3),r.Layout=n(15),r.LayoutConstants=n(0),r.NeedlemanWunsch=n(27),r.Matrix=n(24),r.SVD=n(26),e.exports=r},function(e,t,n){"use strict";function r(){this.listeners=[]}var i=r.prototype;i.addListener=function(e,t){this.listeners.push({event:e,callback:t})},i.removeListener=function(e,t){for(var n=this.listeners.length;n>=0;n--){var r=this.listeners[n];r.event===e&&r.callback===t&&this.listeners.splice(n,1)}},i.emit=function(e,t){for(var n=0;n<this.listeners.length;n++){var r=this.listeners[n];e===r.event&&r.callback(t)}},e.exports=r}])},e.exports=t()},858(e,t,n){var r="Expected a function",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,u="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,c="object"==typeof self&&self&&self.Object===Object&&self,h=u||c||Function("return this")(),d=Object.prototype.toString,f=Math.max,p=Math.min,g=function(){return h.Date.now()};function v(e,t,n){var i,o,a,s,l,u,c=0,h=!1,d=!1,v=!0;if("function"!=typeof e)throw new TypeError(r);function b(t){var n=i,r=o;return i=o=void 0,c=t,s=e.apply(r,n)}function x(e){var n=e-u;return void 0===u||n>=t||n<0||d&&e-c>=a}function w(){var e=g();if(x(e))return E(e);l=setTimeout(w,function(e){var n=t-(e-u);return d?p(n,a-(e-c)):n}(e))}function E(e){return l=void 0,v&&i?b(e):(i=o=void 0,s)}function T(){var e=g(),n=x(e);if(i=arguments,o=this,u=e,n){if(void 0===l)return function(e){return c=e,l=setTimeout(w,t),h?b(e):s}(u);if(d)return l=setTimeout(w,t),b(u)}return void 0===l&&(l=setTimeout(w,t)),s}return t=m(t)||0,y(n)&&(h=!!n.leading,a=(d="maxWait"in n)?f(m(n.maxWait)||0,t):a,v="trailing"in n?!!n.trailing:v),T.cancel=function(){void 0!==l&&clearTimeout(l),c=0,i=u=o=l=void 0},T.flush=function(){return void 0===l?s:E(g())},T}function y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function m(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==d.call(e)}(e))return NaN;if(y(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=y(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var n=a.test(e);return n||s.test(e)?l(e.slice(2),n?2:8):o.test(e)?NaN:+e}e.exports=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError(r);return y(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),v(e,t,{leading:i,maxWait:t,trailing:o})}},694(e,t,n){"use strict";var r=n(925);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,o,a){if(a!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},556(e,t,n){e.exports=n(694)()},925(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{Object.defineProperties(e,{[Symbol.toStringTag]:{value:"Module"},__esModule:{value:!0}})};let r={};(()=>{"use strict";n.r(r),n.d(r,{ContextNet:()=>Fv});const e=window.React;var t=n.n(e),i=n(556),o=n.n(i);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=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 o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function c(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function p(e){return p="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},p(e)}function g(e,t){if(e){if("string"==typeof e)return a(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}var v="undefined"==typeof window?null:window,y=v?v.navigator:null;v&&v.document;var m,b,x,w,E,T,C,M,A,N,_,S,k,P,I,O,D,L,R,B,z,F,V,G,Y,X,$,U,j=p(""),H=p({}),W=p(function(){}),q="undefined"==typeof HTMLElement?"undefined":p(HTMLElement),K=function(e){return e&&e.instanceString&&Q(e.instanceString)?e.instanceString():null},Z=function(e){return null!=e&&p(e)==j},Q=function(e){return null!=e&&p(e)===W},J=function(e){return!ie(e)&&(Array.isArray?Array.isArray(e):null!=e&&e instanceof Array)},ee=function(e){return null!=e&&p(e)===H&&!J(e)&&e.constructor===Object},te=function(e){return null!=e&&p(e)===p(1)&&!isNaN(e)},ne=function(e){return te(e)&&Math.floor(e)===e},re=function(e){return"undefined"===q?void 0:null!=e&&e instanceof HTMLElement},ie=function(e){return oe(e)||ae(e)},oe=function(e){return"collection"===K(e)&&e._private.single},ae=function(e){return"collection"===K(e)&&!e._private.single},se=function(e){return"core"===K(e)},le=function(e){return"stylesheet"===K(e)},ue=function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},ce=function(e){return function(e){return null!=e&&p(e)===H}(e)&&Q(e.then)},he=function(e,t){t||(t=function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);return e.join("$")});var n=function(){var r,i=arguments,o=t.apply(this,i),a=n.cache;return(r=a[o])||(r=a[o]=e.apply(this,i)),r};return n.cache={},n},de=he(function(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),fe=he(function(e){return e.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),pe=he(function(e,t){return e+t[0].toUpperCase()+t.substring(1)},function(e,t){return e+"$"+t}),ge=function(e){return ue(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},ve=function(e,t){return e.slice(-1*t.length)===t},ye="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",me="rgb[a]?\\(("+ye+"[%]?)\\s*,\\s*("+ye+"[%]?)\\s*,\\s*("+ye+"[%]?)(?:\\s*,\\s*("+ye+"))?\\)",be="rgb[a]?\\((?:"+ye+"[%]?)\\s*,\\s*(?:"+ye+"[%]?)\\s*,\\s*(?:"+ye+"[%]?)(?:\\s*,\\s*(?:"+ye+"))?\\)",xe="hsl[a]?\\(("+ye+")\\s*,\\s*("+ye+"[%])\\s*,\\s*("+ye+"[%])(?:\\s*,\\s*("+ye+"))?\\)",we="hsl[a]?\\((?:"+ye+")\\s*,\\s*(?:"+ye+"[%])\\s*,\\s*(?:"+ye+"[%])(?:\\s*,\\s*(?:"+ye+"))?\\)",Ee=function(e,t){return e<t?-1:e>t?1:0},Te=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n<t.length;n++){var r=t[n];if(null!=r)for(var i=Object.keys(r),o=0;o<i.length;o++){var a=i[o];e[a]=r[a]}}return e},Ce=function(e){return(J(e)?e:null)||function(e){return Me[e.toLowerCase()]}(e)||function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,n,r,i=16;return 4===e.length?(t=parseInt(e[1]+e[1],i),n=parseInt(e[2]+e[2],i),r=parseInt(e[3]+e[3],i)):(t=parseInt(e[1]+e[2],i),n=parseInt(e[3]+e[4],i),r=parseInt(e[5]+e[6],i)),[t,n,r]}}(e)||function(e){var t,n=new RegExp("^"+me+"$").exec(e);if(n){t=[];for(var r=[],i=1;i<=3;i++){var o=n[i];if("%"===o[o.length-1]&&(r[i]=!0),o=parseFloat(o),r[i]&&(o=o/100*255),o<0||o>255)return;t.push(Math.floor(o))}var a=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(a&&!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,o,a,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("^"+xe+"$").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!==(o=c[4])&&((o=parseFloat(o))<0||o>1))return;if(0===r)a=s=l=Math.round(255*i);else{var h=i<.5?i*(1+r):i+r-i*r,d=2*i-h;a=Math.round(255*u(d,h,n+1/3)),s=Math.round(255*u(d,h,n)),l=Math.round(255*u(d,h,n-1/3))}t=[a,s,l,o]}return t}(e)},Me={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]},Ae=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var o=n[i];if(ee(o))throw Error("Tried to set map with object key");i<n.length-1?(null==t[o]&&(t[o]={}),t=t[o]):t[o]=e.value}},Ne=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var o=n[i];if(ee(o))throw Error("Tried to get map with object key");if(null==(t=t[o]))return t}return t},_e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function Se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ke(){if(b)return m;return b=1,m=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Pe(){if(T)return E;T=1;var e=function(){if(w)return x;w=1;var e="object"==typeof _e&&_e&&_e.Object===Object&&_e;return x=e}(),t="object"==typeof self&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return E=n}function Ie(){if(S)return _;S=1;var e=function(){if(N)return A;N=1;var e=/\s/;return A=function(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n},A}(),t=/^\s+/;return _=function(n){return n?n.slice(0,e(n)+1).replace(t,""):n},_}function Oe(){if(P)return k;P=1;var e=Pe().Symbol;return k=e}function De(){if(B)return R;B=1;var e=Oe(),t=function(){if(O)return I;O=1;var e=Oe(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;return I=function(e){var t=n.call(e,i),o=e[i];try{e[i]=void 0;var a=!0}catch(e){}var s=r.call(e);return a&&(t?e[i]=o:delete e[i]),s}}(),n=function(){if(L)return D;L=1;var e=Object.prototype.toString;return D=function(t){return e.call(t)}}(),r=e?e.toStringTag:void 0;return R=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":r&&r in Object(e)?t(e):n(e)}}function Le(){if(G)return V;G=1;var e=De(),t=F?z:(F=1,z=function(e){return null!=e&&"object"==typeof e});return V=function(n){return"symbol"==typeof n||t(n)&&"[object Symbol]"==e(n)}}var Re=Se(function(){if(U)return $;U=1;var e=ke(),t=function(){if(M)return C;M=1;var e=Pe();return C=function(){return e.Date.now()}}(),n=function(){if(X)return Y;X=1;var e=Ie(),t=ke(),n=Le(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return Y=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(t(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=t(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=e(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),r=Math.max,i=Math.min;return $=function(o,a,s){var l,u,c,h,d,f,p=0,g=!1,v=!1,y=!0;if("function"!=typeof o)throw new TypeError("Expected a function");function m(e){var t=l,n=u;return l=u=void 0,p=e,h=o.apply(n,t)}function b(e){var t=e-f;return void 0===f||t>=a||t<0||v&&e-p>=c}function x(){var e=t();if(b(e))return w(e);d=setTimeout(x,function(e){var t=a-(e-f);return v?i(t,c-(e-p)):t}(e))}function w(e){return d=void 0,y&&l?m(e):(l=u=void 0,h)}function E(){var e=t(),n=b(e);if(l=arguments,u=this,f=e,n){if(void 0===d)return function(e){return p=e,d=setTimeout(x,a),g?m(e):h}(f);if(v)return clearTimeout(d),d=setTimeout(x,a),m(f)}return void 0===d&&(d=setTimeout(x,a)),h}return a=n(a)||0,e(s)&&(g=!!s.leading,c=(v="maxWait"in s)?r(n(s.maxWait)||0,a):c,y="trailing"in s?!!s.trailing:y),E.cancel=function(){void 0!==d&&clearTimeout(d),p=0,l=f=u=d=void 0},E.flush=function(){return void 0===d?h:w(t())},E}}()),Be=v?v.performance:null,ze=Be&&Be.now?function(){return Be.now()}:function(){return Date.now()},Fe=function(){if(v){if(v.requestAnimationFrame)return function(e){v.requestAnimationFrame(e)};if(v.mozRequestAnimationFrame)return function(e){v.mozRequestAnimationFrame(e)};if(v.webkitRequestAnimationFrame)return function(e){v.webkitRequestAnimationFrame(e)};if(v.msRequestAnimationFrame)return function(e){v.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(ze())},1e3/60)}}(),Ve=function(e){return Fe(e)},Ge=ze,Ye=9261,Xe=5381,$e=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ye;!(t=e.next()).done;)n=65599*n+t.value|0;return n},Ue=function(e){return 65599*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ye)+e|0},je=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe;return(t<<5)+t+e|0},He=function(e){return 2097152*e[0]+e[1]},We=function(e,t){return[Ue(e[0],t[0]),je(e[1],t[1])]},qe=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return $e({next:function(){return r<i?n.value=e[r++]:n.done=!0,n}},t)},Ke=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return $e({next:function(){return r<i?n.value=e.charCodeAt(r++):n.done=!0,n}},t)},Ze=function(){return Qe(arguments)},Qe=function(e){for(var t,n=0;n<e.length;n++){var r=e[n];t=0===n?Ke(r):Ke(r,t)}return t};function Je(e,t,n){if(0===n)return e;var r=(t.x1+t.x2)/2,i=(t.y1+t.y2)/2,o=t.w/t.h,a=1/o,s=function(e,t,n,r,i){var o=i*Math.PI/180;return{x:Math.cos(o)*(e-n)-Math.sin(o)*(t-r)+n,y:Math.sin(o)*(e-n)+Math.cos(o)*(t-r)+r}}(e.x,e.y,r,i,n),l=function(e,t,n,r,i,o){return{x:(e-n)*i+n,y:(t-r)*o+r}}(s.x,s.y,r,i,o,a);return{x:l.x,y:l.y}}var et=!0,tt=null!=console.warn,nt=null!=console.trace,rt=Number.MAX_SAFE_INTEGER||9007199254740991,it=function(){return!0},ot=function(){return!1},at=function(){return 0},st=function(){},lt=function(e){throw new Error(e)},ut=function(e){if(void 0===e)return et;et=!!e},ct=function(e){ut()&&(tt?console.warn(e):(console.log(e),nt&&console.trace()))},ht=function(e){return null==e?e:J(e)?e.slice():ee(e)?function(e){return Te({},e)}(e):e},dt=function(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"-");return t},ft={},pt=function(){return ft},gt=function(e){var t=Object.keys(e);return function(n){for(var r={},i=0;i<t.length;i++){var o=t[i],a=null==n?void 0:n[o];r[o]=void 0===a?e[o]:a}return r}},vt=function(e,t,n){for(var r=e.length-1;r>=0;r--)e[r]===t&&e.splice(r,1)},yt=function(e){e.splice(0,e.length)},mt=function(e,t,n){return n&&(t=pe(n,t)),e[t]},bt=function(e,t,n,r){n&&(t=pe(n,t)),e[t]=r},xt=function(){return l(function e(){s(this,e),this._obj={}},[{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]}}])}(),wt="undefined"!=typeof Map?Map:xt,Et=function(){return l(function e(t){if(s(this,e),this._obj=Object.create(null),this.size=0,null!=t){var n;n=null!=t.instanceString&&t.instanceString()===this.instanceString()?t.toArray():t;for(var r=0;r<n.length;r++)this.add(n[r])}},[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(e){var t=this._obj;1!==t[e]&&(t[e]=1,this.size++)}},{key:"delete",value:function(e){var t=this._obj;1===t[e]&&(t[e]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(e){return 1===this._obj[e]}},{key:"toArray",value:function(){var e=this;return Object.keys(this._obj).filter(function(t){return e.has(t)})}},{key:"forEach",value:function(e,t){return this.toArray().forEach(e,t)}}])}(),Tt="undefined"!==("undefined"==typeof Set?"undefined":p(Set))?Set:Et,Ct=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&se(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 Tt,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 o=t.renderedPosition,a=e.pan(),s=e.zoom();i.position={x:(o.x-a.x)/s,y:(o.y-a.y)/s}}var l=[];J(t.classes)?l=t.classes:Z(t.classes)&&(l=t.classes.split(/\s+/));for(var u=0,c=l.length;u<c;u++){var h=l[u];h&&""!==h&&i.classes.add(h)}this.createEmitter(),(void 0===n||n)&&this.restore();var d=t.style||t.css;d&&(ct("Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead."),this.style(d))}else lt("An element must be of type `nodes` or `edges`; you specified `"+r+"`")}else lt("An element must have a core reference and parameters set")},Mt=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(t,n,r){var i;ee(t)&&!ie(t)&&(t=(i=t).roots||i.root,n=i.visit,r=i.directed),r=2!==arguments.length||Q(n)?r:n,n=Q(n)?n:function(){};for(var o,a=this._private.cy,s=t=Z(t)?this.filter(t):t,l=[],u=[],c={},h={},d={},f=0,p=this.byGroup(),g=p.nodes,v=p.edges,y=0;y<s.length;y++){var m=s[y],b=m.id();m.isNode()&&(l.unshift(m),e.bfs&&(d[b]=!0,u.push(m)),h[b]=0)}for(var x,w=function(){var t=e.bfs?l.shift():l.pop(),i=t.id();if(e.dfs){if(d[i])return 0;d[i]=!0,u.push(t)}var a,s=h[i],p=c[i],y=null!=p?p.source():null,m=null!=p?p.target():null,b=null==p?void 0:t.same(y)?m[0]:y[0];if(!0===(a=n(t,p,b,f++,s)))return o=t,1;if(!1===a)return 1;for(var x=t.connectedEdges().filter(function(e){return(!r||e.source().same(t))&&v.has(e)}),w=0;w<x.length;w++){var E=x[w],T=E.connectedNodes().filter(function(e){return!e.same(t)&&g.has(e)}),C=T.id();0===T.length||d[C]||(T=T[0],l.push(T),e.bfs&&(d[C]=!0,u.push(T)),c[C]=E,h[C]=h[i]+1)}};0!==l.length&&(0===(x=w())||1!==x););for(var E=a.collection(),T=0;T<u.length;T++){var C=u[T],M=c[C.id()];null!=M&&E.push(M),E.push(C)}return{path:a.collection(E),found:a.collection(o)}}},At={breadthFirstSearch:Mt({bfs:!0}),depthFirstSearch:Mt({dfs:!0})};At.bfs=At.breadthFirstSearch,At.dfs=At.depthFirstSearch;var Nt,_t,St,kt={exports:{}},Pt=kt.exports;function It(){return Nt||(Nt=1,e=kt,function(){var t,n,r,i,o,a,s,l,u,c,h,d,f,p,g;r=Math.floor,c=Math.min,n=function(e,t){return e<t?-1:e>t?1:0},u=function(e,t,i,o,a){var s;if(null==i&&(i=0),null==a&&(a=n),i<0)throw new Error("lo must be non-negative");for(null==o&&(o=e.length);i<o;)a(t,e[s=r((i+o)/2)])<0?o=s:i=s+1;return[].splice.apply(e,[i,i-i].concat(t)),t},a=function(e,t,r){return null==r&&(r=n),e.push(t),p(e,0,e.length-1,r)},o=function(e,t){var r,i;return null==t&&(t=n),r=e.pop(),e.length?(i=e[0],e[0]=r,g(e,0,t)):i=r,i},l=function(e,t,r){var i;return null==r&&(r=n),i=e[0],e[0]=t,g(e,0,r),i},s=function(e,t,r){var i;return null==r&&(r=n),e.length&&r(e[0],t)<0&&(t=(i=[e[0],t])[0],e[0]=i[1],g(e,0,r)),t},i=function(e,t){var i,o,a,s,l,u;for(null==t&&(t=n),l=[],o=0,a=(s=function(){u=[];for(var t=0,n=r(e.length/2);0<=n?t<n:t>n;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse()).length;o<a;o++)i=s[o],l.push(g(e,i,t));return l},f=function(e,t,r){var i;if(null==r&&(r=n),-1!==(i=e.indexOf(t)))return p(e,0,i,r),g(e,i,r)},h=function(e,t,r){var o,a,l,u,c;if(null==r&&(r=n),!(a=e.slice(0,t)).length)return a;for(i(a,r),l=0,u=(c=e.slice(t)).length;l<u;l++)o=c[l],s(a,o,r);return a.sort(r).reverse()},d=function(e,t,r){var a,s,l,h,d,f,p,g,v;if(null==r&&(r=n),10*t<=e.length){if(!(l=e.slice(0,t).sort(r)).length)return l;for(s=l[l.length-1],h=0,f=(p=e.slice(t)).length;h<f;h++)r(a=p[h],s)<0&&(u(l,a,0,null,r),l.pop(),s=l[l.length-1]);return l}for(i(e,r),v=[],d=0,g=c(t,e.length);0<=g?d<g:d>g;0<=g?++d:--d)v.push(o(e,r));return v},p=function(e,t,r,i){var o,a,s;for(null==i&&(i=n),o=e[r];r>t&&i(o,a=e[s=r-1>>1])<0;)e[r]=a,r=s;return e[r]=o},g=function(e,t,r){var i,o,a,s,l;for(null==r&&(r=n),o=e.length,l=t,a=e[t],i=2*t+1;i<o;)(s=i+1)<o&&!(r(e[i],e[s])<0)&&(i=s),e[t]=e[i],i=2*(t=i)+1;return e[t]=a,p(e,l,t,r)},t=function(){function e(e){this.cmp=null!=e?e:n,this.nodes=[]}return e.push=a,e.pop=o,e.replace=l,e.pushpop=s,e.heapify=i,e.updateItem=f,e.nlargest=h,e.nsmallest=d,e.prototype.push=function(e){return a(this.nodes,e,this.cmp)},e.prototype.pop=function(){return o(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return l(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return s(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return i(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return f(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return(t=new e).nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),e.exports=t}.call(Pt)),kt.exports;var e}var Ot,Dt=Se(St?_t:(St=1,_t=It())),Lt=gt({root:null,weight:function(e){return 1},directed:!1}),Rt={dijkstra:function(e){if(!ee(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=Lt(e),r=n.root,i=n.weight,o=n.directed,a=this,s=i,l=Z(r)?this.filter(r)[0]:r[0],u={},c={},h={},d=this.byGroup(),f=d.nodes,p=d.edges;p.unmergeBy(function(e){return e.isLoop()});for(var g=function(e){return u[e.id()]},v=function(e,t){u[e.id()]=t,y.updateItem(e)},y=new Dt(function(e,t){return g(e)-g(t)}),m=0;m<f.length;m++){var b=f[m];u[b.id()]=b.same(l)?0:1/0,y.push(b)}for(var x=function(e,t){for(var n,r=(o?e.edgesTo(t):e.edgesWith(t)).intersect(p),i=1/0,a=0;a<r.length;a++){var l=r[a],u=s(l);(u<i||!n)&&(i=u,n=l)}return{edge:n,dist:i}};y.size()>0;){var w=y.pop(),E=g(w),T=w.id();if(h[T]=E,E!==1/0)for(var C=w.neighborhood().intersect(f),M=0;M<C.length;M++){var A=C[M],N=A.id(),_=x(w,A),S=E+_.dist;S<g(A)&&(v(A,S),c[N]={node:w,edge:_.edge})}}return{distanceTo:function(e){var t=Z(e)?f.filter(e)[0]:e[0];return h[t.id()]},pathTo:function(e){var t=Z(e)?f.filter(e)[0]:e[0],n=[],r=t,i=r.id();if(t.length>0)for(n.unshift(t);c[i];){var o=c[i];n.unshift(o.edge),n.unshift(o.node),i=(r=o.node).id()}return a.spawn(n)}}}},Bt={kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,i=n.length,o=new Array(i),a=n,s=function(e){for(var t=0;t<o.length;t++){if(o[t].has(e))return t}},l=0;l<i;l++)o[l]=this.spawn(n[l]);for(var u=r.sort(function(t,n){return e(t)-e(n)}),c=0;c<u.length;c++){var h=u[c],d=h.source()[0],f=h.target()[0],p=s(d),g=s(f),v=o[p],y=o[g];p!==g&&(a.merge(h),v.merge(y),o.splice(g,1))}return a}},zt=gt({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),Ft={aStar:function(e){var t=this.cy(),n=zt(e),r=n.root,i=n.goal,o=n.heuristic,a=n.directed,s=n.weight;r=t.collection(r)[0],i=t.collection(i)[0];var l,u,c=r.id(),h=i.id(),d={},f={},p={},g=new Dt(function(e,t){return f[e.id()]-f[t.id()]}),v=new Tt,y={},m={},b=function(e,t){g.push(e),v.add(t)},x=function(){l=g.pop(),u=l.id(),v.delete(u)},w=function(e){return v.has(e)};b(r,c),d[c]=0,f[c]=o(r);for(var E=0;g.size()>0;){if(x(),E++,u===h){for(var T=[],C=i,M=h,A=m[M];T.unshift(C),null!=A&&T.unshift(A),null!=(C=y[M]);)A=m[M=C.id()];return{found:!0,distance:d[u],path:this.spawn(T),steps:E}}p[u]=!0;for(var N=l._private.edges,_=0;_<N.length;_++){var S=N[_];if(this.hasElementWithId(S.id())&&(!a||S.data("source")===u)){var k=S.source(),P=S.target(),I=k.id()!==u?k:P,O=I.id();if(this.hasElementWithId(O)&&!p[O]){var D=d[u]+s(S);w(O)?D<d[O]&&(d[O]=D,f[O]=D+o(I),g.updateItem(I),y[O]=l,m[O]=S):(d[O]=D,f[O]=D+o(I),b(I,O),y[O]=l,m[O]=S)}}}}return{found:!1,distance:void 0,path:void 0,steps:E}}},Vt=gt({weight:function(e){return 1},directed:!1}),Gt={floydWarshall:function(e){for(var t=this.cy(),n=Vt(e),r=n.weight,i=n.directed,o=r,a=this.byGroup(),s=a.nodes,l=a.edges,u=s.length,c=u*u,h=function(e){return s.indexOf(e)},d=function(e){return s[e]},f=new Array(c),p=0;p<c;p++){var g=p%u,v=(p-g)/u;f[p]=v===g?0:1/0}for(var y=new Array(c),m=new Array(c),b=0;b<l.length;b++){var x=l[b],w=x.source()[0],E=x.target()[0];if(w!==E){var T=h(w),C=h(E),M=T*u+C,A=o(x);if(f[M]>A&&(f[M]=A,y[M]=C,m[M]=x),!i){var N=C*u+T;!i&&f[N]>A&&(f[N]=A,y[N]=T,m[N]=x)}}}for(var _=0;_<u;_++)for(var S=0;S<u;S++)for(var k=S*u+_,P=0;P<u;P++){var I=S*u+P,O=_*u+P;f[k]+f[O]<f[I]&&(f[I]=f[k]+f[O],y[I]=y[k])}var D=function(e){return h(function(e){return(Z(e)?t.filter(e):e)[0]}(e))},L={distance:function(e,t){var n=D(e),r=D(t);return f[n*u+r]},path:function(e,n){var r=D(e),i=D(n),o=d(r);if(r===i)return o.collection();if(null==y[r*u+i])return t.collection();var a,s=t.collection(),l=r;for(s.merge(o);r!==i;)l=r,r=y[r*u+i],a=m[l*u+r],s.merge(a),s.merge(d(r));return s}};return L}},Yt=gt({weight:function(e){return 1},directed:!1,root:null}),Xt={bellmanFord:function(e){var t=this,n=Yt(e),r=n.weight,i=n.directed,o=n.root,a=r,s=this,l=this.cy(),u=this.byGroup(),c=u.edges,h=u.nodes,d=h.length,f=new wt,p=!1,g=[];o=l.collection(o)[0],c.unmergeBy(function(e){return e.isLoop()});for(var v=c.length,y=function(e){var t=f.get(e.id());return t||(t={},f.set(e.id(),t)),t},m=function(e){return(Z(e)?l.$(e):e)[0]},b=0;b<d;b++){var x=h[b],w=y(x);x.same(o)?w.dist=0:w.dist=1/0,w.pred=null,w.edge=null}for(var E=!1,T=function(e,t,n,r,i,o){var a=r.dist+o;a<i.dist&&!n.same(r.edge)&&(i.dist=a,i.pred=e,i.edge=n,E=!0)},C=1;C<d;C++){E=!1;for(var M=0;M<v;M++){var A=c[M],N=A.source(),_=A.target(),S=a(A),k=y(N),P=y(_);T(N,0,A,k,P,S),i||T(_,0,A,P,k,S)}if(!E)break}if(E)for(var I=[],O=0;O<v;O++){var D=c[O],L=D.source(),R=D.target(),B=a(D),z=y(L).dist,F=y(R).dist;if(z+B<F||!i&&F+B<z){if(p||(ct("Graph contains a negative weight cycle for Bellman-Ford"),p=!0),!1===e.findNegativeWeightCycles)break;var V=[];z+B<F&&V.push(L),!i&&F+B<z&&V.push(R);for(var G=V.length,Y=0;Y<G;Y++){var X=V[Y],$=[X];$.push(y(X).edge);for(var U=y(X).pred;-1===$.indexOf(U);)$.push(U),$.push(y(U).edge),U=y(U).pred;for(var j=($=$.slice($.indexOf(U)))[0].id(),H=0,W=2;W<$.length;W+=2)$[W].id()<j&&(j=$[W].id(),H=W);($=$.slice(H).concat($.slice(0,H))).push($[0]);var q=$.map(function(e){return e.id()}).join(",");-1===I.indexOf(q)&&(g.push(s.spawn($)),I.push(q))}}}return{distanceTo:function(e){return y(m(e)).dist},pathTo:function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,r=[],i=m(e);;){if(null==i)return t.spawn();var a=y(i),l=a.edge,u=a.pred;if(r.unshift(i[0]),i.same(n)&&r.length>0)break;null!=l&&r.unshift(l),i=u}return s.spawn(r)},hasNegativeWeightCycle:p,negativeWeightCycles:g}}},$t=Math.sqrt(2),Ut=function(e,t,n){0===n.length&<("Karger-Stein must be run on a connected (sub)graph");for(var r=n[e],i=r[1],o=r[2],a=t[i],s=t[o],l=n,u=l.length-1;u>=0;u--){var c=l[u],h=c[1],d=c[2];(t[h]===a&&t[d]===s||t[h]===s&&t[d]===a)&&l.splice(u,1)}for(var f=0;f<l.length;f++){var p=l[f];p[1]===s?(l[f]=p.slice(),l[f][1]=a):p[2]===s&&(l[f]=p.slice(),l[f][2]=a)}for(var g=0;g<t.length;g++)t[g]===s&&(t[g]=a);return l},jt=function(e,t,n,r){for(;n>r;){var i=Math.floor(Math.random()*t.length);t=Ut(i,e,t),n--}return t},Ht={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,o=r.length,a=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),s=Math.floor(i/$t);if(!(i<2)){for(var l=[],u=0;u<o;u++){var c=r[u];l.push([u,n.indexOf(c.source()),n.indexOf(c.target())])}for(var h=1/0,d=[],f=new Array(i),p=new Array(i),g=new Array(i),v=function(e,t){for(var n=0;n<i;n++)t[n]=e[n]},y=0;y<=a;y++){for(var m=0;m<i;m++)p[m]=m;var b=jt(p,l.slice(),i,s),x=b.slice();v(p,g);var w=jt(p,b,s,2),E=jt(g,x,s,2);w.length<=E.length&&w.length<h?(h=w.length,d=w,v(p,f)):E.length<=w.length&&E.length<h&&(h=E.length,d=E,v(g,f))}for(var T=this.spawn(d.map(function(e){return r[e[0]]})),C=this.spawn(),M=this.spawn(),A=f[0],N=0;N<f.length;N++){var _=f[N],S=n[N];_===A?C.merge(S):M.merge(S)}var k=function(t){var n=e.spawn();return t.forEach(function(t){n.merge(t),t.connectedEdges().forEach(function(t){e.contains(t)&&!T.contains(t)&&n.merge(t)})}),n},P=[k(C),k(M)];return{cut:T,components:P,partition1:C,partition2:M}}lt("At least 2 nodes are required for Karger-Stein algorithm")}},Wt=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},qt=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},Kt=function(e){return{x:e[0],y:e[1]}},Zt=function(e,t){return 0===t?e:Zt(t,e%t)},Qt=function(e){for(var t=e[0],n=0;n<e.length;n++){if(!ne(e[n]))return 0;n>0&&(t=Zt(t,e[n]))}return t},Jt=function(e,t){var n=e/t,r=Math.round(n);return r>=1&&Math.abs(n-r)<1e-6},en=function(e,t){return Math.atan2(t,e)-Math.PI/2},tn=Math.log2||function(e){return Math.log(e)/Math.log(2)},nn=function(e){return e>0?1:e<0?-1:0},rn=function(e,t){return Math.sqrt(on(e,t))},on=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},an=function(e){for(var t=e.length,n=0,r=0;r<t;r++)n+=e[r];for(var i=0;i<t;i++)e[i]=e[i]/n;return e},sn=function(e,t,n,r){return(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n},ln=function(e,t,n,r){return{x:sn(e.x,t.x,n.x,r),y:sn(e.y,t.y,n.y,r)}},un=function(e,t,n){return Math.max(e,Math.min(n,t))},cn=function(e){if(null==e)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(null!=e.x1&&null!=e.y1){if(null!=e.x2&&null!=e.y2&&e.x2>=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}}},hn=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},dn=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},fn=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},pn=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 a=h(o,4);t=a[0],n=a[1],r=a[2],i=a[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},gn=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},vn=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2<t.x1)&&(!(t.x2<e.x1)&&(!(e.y2<t.y1)&&(!(t.y2<e.y1)&&(!(e.y1>t.y2)&&!(t.y1>e.y2)))))))},yn=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},mn=function(e,t){return yn(e,t.x,t.y)},bn=function(e,t){return yn(e,t.x1,t.y1)&&yn(e,t.x2,t.y2)},xn=null!==(Ot=Math.hypot)&&void 0!==Ot?Ot:function(e,t){return Math.sqrt(e*e+t*t)};function wn(e,t,n,r,i,o){var a=function(e,t){if(e.length<3)throw new Error("Need at least 3 vertices");var n=function(e,t){return{x:e.x+t.x,y:e.y+t.y}},r=function(e,t){return{x:e.x-t.x,y:e.y-t.y}},i=function(e,t){return{x:e.x*t,y:e.y*t}},o=function(e,t){return e.x*t.y-e.y*t.x},a=function(e){var t=xn(e.x,e.y);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},s=function(e,t,a,s){var l=r(t,e),u=r(s,a),c=o(l,u);if(Math.abs(c)<1e-9)return n(e,i(l,.5));var h=o(r(a,e),u)/c;return n(e,i(l,h))},l=e.map(function(e){return{x:e.x,y:e.y}});(function(e){for(var t=0,n=0;n<e.length;n++){var r=e[n],i=e[(n+1)%e.length];t+=r.x*i.y-i.x*r.y}return t/2})(l)<0&&l.reverse();for(var u=l.length,c=[],h=0;h<u;h++){var d=l[h],f=l[(h+1)%u],p=r(f,d),g=a({x:p.y,y:-p.x});c.push(g)}for(var v=c.map(function(e,r){return{p1:n(l[r],i(e,t)),p2:n(l[(r+1)%u],i(e,t))}}),y=[],m=0;m<u;m++){var b=v[(m-1+u)%u],x=v[m],w=s(b.p1,b.p2,x.p1,x.p2);y.push(w)}return y}(Ln(e,t,n,r,i),o),s=cn();return a.forEach(function(e){return dn(s,e.x,e.y)}),s}var En=function(e,t,n,r,i,o,a){var s,l,u=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"auto",c="auto"===u?Gn(i,o):u,h=i/2,d=o/2,f=(c=Math.min(c,h,d))!==h,p=c!==d;if(f){var g=r-d-a;if((s=Dn(e,t,n,r,n-h+c-a,g,n+h-c+a,g,!1)).length>0)return s}if(p){var v=n+h+a;if((s=Dn(e,t,n,r,v,r-d+c-a,v,r+d-c+a,!1)).length>0)return s}if(f){var y=r+d+a;if((s=Dn(e,t,n,r,n-h+c-a,y,n+h-c+a,y,!1)).length>0)return s}if(p){var m=n-h-a;if((s=Dn(e,t,n,r,m,r-d+c-a,m,r+d-c+a,!1)).length>0)return s}var b=n-h+c,x=r-d+c;if((l=In(e,t,n,r,b,x,c+a)).length>0&&l[0]<=b&&l[1]<=x)return[l[0],l[1]];var w=n+h-c,E=r-d+c;if((l=In(e,t,n,r,w,E,c+a)).length>0&&l[0]>=w&&l[1]<=E)return[l[0],l[1]];var T=n+h-c,C=r+d-c;if((l=In(e,t,n,r,T,C,c+a)).length>0&&l[0]>=T&&l[1]>=C)return[l[0],l[1]];var M=n-h+c,A=r+d-c;return(l=In(e,t,n,r,M,A,c+a)).length>0&&l[0]<=M&&l[1]>=A?[l[0],l[1]]:[]},Tn=function(e,t,n,r,i,o,a){var s=a,l=Math.min(n,i),u=Math.max(n,i),c=Math.min(r,o),h=Math.max(r,o);return l-s<=e&&e<=u+s&&c-s<=t&&t<=h+s},Cn=function(e,t,n,r,i,o,a,s,l){var u=Math.min(n,a,i)-l,c=Math.max(n,a,i)+l,h=Math.min(r,s,o)-l,d=Math.max(r,s,o)+l;return!(e<u||e>c||t<h||t>d)},Mn=function(e,t,n,r,i,o,a,s){var l=[];!function(e,t,n,r,i){var o,a,s,l,u,c,h,d;0===e&&(e=1e-5),s=-27*(r/=e)+(t/=e)*(9*(n/=e)-t*t*2),o=(a=(3*n-t*t)/9)*a*a+(s/=54)*s,i[1]=0,h=t/3,o>0?(u=(u=s+Math.sqrt(o))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),c=(c=s-Math.sqrt(o))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),i[0]=-h+u+c,h+=(u+c)/2,i[4]=i[2]=-h,h=Math.sqrt(3)*(-c+u)/2,i[3]=h,i[5]=-h):(i[5]=i[3]=0,0===o?(d=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=2*d-h,i[4]=i[2]=-(d+h)):(l=(a=-a)*a*a,l=Math.acos(s/Math.sqrt(l)),d=2*Math.sqrt(a),i[0]=-h+d*Math.cos(l/3),i[2]=-h+d*Math.cos((l+2*Math.PI)/3),i[4]=-h+d*Math.cos((l+4*Math.PI)/3)))}(1*n*n-4*n*i+2*n*a+4*i*i-4*i*a+a*a+r*r-4*r*o+2*r*s+4*o*o-4*o*s+s*s,9*n*i-3*n*n-3*n*a-6*i*i+3*i*a+9*r*o-3*r*r-3*r*s-6*o*o+3*o*s,3*n*n-6*n*i+n*a-n*e+2*i*i+2*i*e-a*e+3*r*r-6*r*o+r*s-r*t+2*o*o+2*o*t-s*t,1*n*i-n*n+n*e-i*e+r*o-r*r+r*t-o*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 h,d,f,p=-1,g=0;g<u.length;g++)h=Math.pow(1-u[g],2)*n+2*(1-u[g])*u[g]*i+u[g]*u[g]*a,d=Math.pow(1-u[g],2)*r+2*(1-u[g])*u[g]*o+u[g]*u[g]*s,f=Math.pow(h-e,2)+Math.pow(d-t,2),p>=0?f<p&&(p=f):p=f;return p},An=function(e,t,n,r,i,o){var a=[e-n,t-r],s=[i-n,o-r],l=s[0]*s[0]+s[1]*s[1],u=a[0]*a[0]+a[1]*a[1],c=a[0]*s[0]+a[1]*s[1],h=c*c/l;return c<0?u:h>l?(e-i)*(e-i)+(t-o)*(t-o):u-h},Nn=function(e,t,n){for(var r,i,o,a,s=0,l=0;l<n.length/2;l++)if(r=n[2*l],i=n[2*l+1],l+1<n.length/2?(o=n[2*(l+1)],a=n[2*(l+1)+1]):(o=n[2*(l+1-n.length/2)],a=n[2*(l+1-n.length/2)+1]),r==e&&o==e);else{if(!(r>=e&&e>=o||r<=e&&e<=o))continue;(e-r)/(o-r)*(a-i)+i>t&&s++}return s%2!=0},_n=function(e,t,n,r,i,o,a,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 h,d=Math.cos(-u),f=Math.sin(-u),p=0;p<c.length/2;p++)c[2*p]=o/2*(n[2*p]*d-n[2*p+1]*f),c[2*p+1]=a/2*(n[2*p+1]*d+n[2*p]*f),c[2*p]+=r,c[2*p+1]+=i;if(l>0){var g=kn(c,-l);h=Sn(g)}else h=c;return Nn(e,t,h)},Sn=function(e){for(var t,n,r,i,o,a,s,l,u=new Array(e.length/2),c=0;c<e.length/4;c++){t=e[4*c],n=e[4*c+1],r=e[4*c+2],i=e[4*c+3],c<e.length/4-1?(o=e[4*(c+1)],a=e[4*(c+1)+1],s=e[4*(c+1)+2],l=e[4*(c+1)+3]):(o=e[0],a=e[1],s=e[2],l=e[3]);var h=Dn(t,n,r,i,o,a,s,l,!0);u[2*c]=h[0],u[2*c+1]=h[1]}return u},kn=function(e,t){for(var n,r,i,o,a=new Array(2*e.length),s=0;s<e.length/2;s++){n=e[2*s],r=e[2*s+1],s<e.length/2-1?(i=e[2*(s+1)],o=e[2*(s+1)+1]):(i=e[0],o=e[1]);var l=o-r,u=-(i-n),c=Math.sqrt(l*l+u*u),h=l/c,d=u/c;a[4*s]=n+h*t,a[4*s+1]=r+d*t,a[4*s+2]=i+h*t,a[4*s+3]=o+d*t}return a},Pn=function(e,t,n,r,i,o,a){return e-=i,t-=o,(e/=n/2+a)*e+(t/=r/2+a)*t<=1},In=function(e,t,n,r,i,o,a){var s=[n-e,r-t],l=[e-i,t-o],u=s[0]*s[0]+s[1]*s[1],c=2*(l[0]*s[0]+l[1]*s[1]),h=c*c-4*u*(l[0]*l[0]+l[1]*l[1]-a*a);if(h<0)return[];var d=(-c+Math.sqrt(h))/(2*u),f=(-c-Math.sqrt(h))/(2*u),p=Math.min(d,f),g=Math.max(d,f),v=[];if(p>=0&&p<=1&&v.push(p),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]},On=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},Dn=function(e,t,n,r,i,o,a,s,l){var u=e-i,c=n-e,h=a-i,d=t-o,f=r-t,p=s-o,g=h*d-p*u,v=c*d-f*u,y=p*c-h*f;if(0!==y){var m=g/y,b=v/y,x=-.001;return x<=m&&m<=1.001&&x<=b&&b<=1.001||l?[e+m*c,t+m*f]:[]}return 0===g||0===v?On(e,n,a)===a?[a,s]:On(e,n,i)===i?[i,o]:On(i,a,n)===n?[n,r]:[]:[]},Ln=function(e,t,n,r,i){var o=[],a=r/2,s=i/2,l=t,u=n;o.push({x:l+a*e[0],y:u+s*e[1]});for(var c=1;c<e.length/2;c++)o.push({x:l+a*e[2*c],y:u+s*e[2*c+1]});return o},Rn=function(e,t,n,r,i,o,a,s){var l,u,c,h,d,f,p=[],g=new Array(n.length),v=!0;if(null==o&&(v=!1),v){for(var y=0;y<g.length/2;y++)g[2*y]=n[2*y]*o+r,g[2*y+1]=n[2*y+1]*a+i;if(s>0){var m=kn(g,-s);u=Sn(m)}else u=g}else u=n;for(var b=0;b<u.length/2;b++)c=u[2*b],h=u[2*b+1],b<u.length/2-1?(d=u[2*(b+1)],f=u[2*(b+1)+1]):(d=u[0],f=u[1]),0!==(l=Dn(e,t,r,i,c,h,d,f)).length&&p.push(l[0],l[1]);return p},Bn=function(e,t,n){var r=[e[0]-t[0],e[1]-t[1]],i=Math.sqrt(r[0]*r[0]+r[1]*r[1]),o=(i-n)/i;return o<0&&(o=1e-5),[t[0]+o*r[0],t[1]+o*r[1]]},zn=function(e,t){var n=Vn(e,t);return n=Fn(n)},Fn=function(e){for(var t,n,r=e.length/2,i=1/0,o=1/0,a=-1/0,s=-1/0,l=0;l<r;l++)t=e[2*l],n=e[2*l+1],i=Math.min(i,t),a=Math.max(a,t),o=Math.min(o,n),s=Math.max(s,n);for(var u=2/(a-i),c=2/(s-o),h=0;h<r;h++)t=e[2*h]=e[2*h]*u,n=e[2*h+1]=e[2*h+1]*c,i=Math.min(i,t),a=Math.max(a,t),o=Math.min(o,n),s=Math.max(s,n);if(o<-1)for(var d=0;d<r;d++)n=e[2*d+1]=e[2*d+1]+(-1-o);return e},Vn=function(e,t){var n=1/e*2*Math.PI,r=e%2==0?Math.PI/2+n/2:Math.PI/2;r+=t;for(var i,o=new Array(2*e),a=0;a<e;a++)i=a*n+r,o[2*a]=Math.cos(i),o[2*a+1]=Math.sin(-i);return o},Gn=function(e,t){return Math.min(e/4,t/4,8)},Yn=function(e,t){return Math.min(e/10,t/10,8)},Xn=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}},$n=function(e,t,n,r,i,o,a){var s=e.x1-a-i,l=e.x2+a-i,u=e.y1-a-o,c=e.y2+a-o;if(r){var h=Math.cos(r),d=Math.sin(r),f=function(e,r){return{x:(e-=t)*h-(r-=n)*d+t+i,y:e*d+r*h+n+o}};return[f(s,u),f(l,u),f(l,c),f(s,c)]}return[{x:s+i,y:u+o},{x:l+i,y:u+o},{x:l+i,y:c+o},{x:s+i,y:c+o}]};function Un(e,t){function n(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],i=e[(n+1)%e.length],o={x:i.x-r.x,y:i.y-r.y},a={x:-o.y,y:o.x},s=Math.sqrt(a.x*a.x+a.y*a.y);t.push({x:a.x/s,y:a.y/s})}return t}function r(e,t){var n,r=1/0,i=-1/0,o=u(e);try{for(o.s();!(n=o.n()).done;){var a=n.value,s=a.x*t.x+a.y*t.y;r=Math.min(r,s),i=Math.max(i,s)}}catch(e){o.e(e)}finally{o.f()}return{min:r,max:i}}function i(e,t){return!(e.max<t.min||t.max<e.min)}var o,a=u([].concat(d(n(e)),d(n(t))));try{for(a.s();!(o=a.n()).done;){var s=o.value;if(!i(r(e,s),r(t,s)))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function jn(e,t,n,r){function i(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return i(e,n,r)!==i(t,n,r)&&i(e,t,n)!==i(e,t,r)}function Hn(e,t,n){if(function(e,t){for(var n=!1,r=0,i=t.length-1;r<t.length;i=r++){var o=t[r],a=t[i];o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}(e,n))return!0;for(var r=0;r<n.length;r++){if(jn(e,t,n[r],n[(r+1)%n.length]))return!0}return!1}var Wn=gt({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),qn={pageRank:function(e){for(var t=Wn(e),n=t.dampingFactor,r=t.precision,i=t.iterations,o=t.weight,a=this._private.cy,s=this.byGroup(),l=s.nodes,u=s.edges,c=l.length,h=c*c,d=u.length,f=new Array(h),p=new Array(c),g=(1-n)/c,v=0;v<c;v++){for(var y=0;y<c;y++){f[v*c+y]=0}p[v]=0}for(var m=0;m<d;m++){var b=u[m],x=b.data("source"),w=b.data("target");if(x!==w){var E=l.indexOfId(x),T=l.indexOfId(w),C=o(b);f[T*c+E]+=C,p[E]+=C}}for(var M=n/c+g,A=0;A<c;A++)if(0===p[A])for(var N=0;N<c;N++){f[N*c+A]=M}else for(var _=0;_<c;_++){var S=_*c+A;f[S]=n*f[S]/p[A]+g}for(var k,P=new Array(c),I=new Array(c),O=0;O<c;O++)P[O]=1;for(var D=0;D<i;D++){for(var L=0;L<c;L++)I[L]=0;for(var R=0;R<c;R++)for(var B=0;B<c;B++){var z=R*c+B;I[R]+=f[z]*P[B]}an(I),k=P,P=I,I=k;for(var F=0,V=0;V<c;V++){var G=k[V]-P[V];F+=G*G}if(F<r)break}return{rank:function(e){return e=a.collection(e)[0],P[l.indexOf(e)]}}}},Kn=gt({root:null,weight:function(e){return 1},directed:!1,alpha:0}),Zn={degreeCentralityNormalized:function(e){e=Kn(e);var t=this.cy(),n=this.nodes(),r=n.length;if(e.directed){for(var i={},o={},a=0,s=0,l=0;l<r;l++){var u=n[l],c=u.id();e.root=u;var h=this.degreeCentrality(e);a<h.indegree&&(a=h.indegree),s<h.outdegree&&(s=h.outdegree),i[c]=h.indegree,o[c]=h.outdegree}return{indegree:function(e){return 0==a?0:(Z(e)&&(e=t.filter(e)),i[e.id()]/a)},outdegree:function(e){return 0===s?0:(Z(e)&&(e=t.filter(e)),o[e.id()]/s)}}}for(var d={},f=0,p=0;p<r;p++){var g=n[p];e.root=g;var v=this.degreeCentrality(e);f<v.degree&&(f=v.degree),d[g.id()]=v.degree}return{degree:function(e){return 0===f?0:(Z(e)&&(e=t.filter(e)),d[e.id()]/f)}}},degreeCentrality:function(e){e=Kn(e);var t=this.cy(),n=this,r=e,i=r.root,o=r.weight,a=r.directed,s=r.alpha;if(i=t.collection(i)[0],a){for(var l=i.connectedEdges(),u=l.filter(function(e){return e.target().same(i)&&n.has(e)}),c=l.filter(function(e){return e.source().same(i)&&n.has(e)}),h=u.length,d=c.length,f=0,p=0,g=0;g<u.length;g++)f+=o(u[g]);for(var v=0;v<c.length;v++)p+=o(c[v]);return{indegree:Math.pow(h,1-s)*Math.pow(f,s),outdegree:Math.pow(d,1-s)*Math.pow(p,s)}}for(var y=i.connectedEdges().intersection(n),m=y.length,b=0,x=0;x<y.length;x++)b+=o(y[x]);return{degree:Math.pow(m,1-s)*Math.pow(b,s)}}};Zn.dc=Zn.degreeCentrality,Zn.dcn=Zn.degreeCentralityNormalised=Zn.degreeCentralityNormalized;var Qn=gt({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),Jn={closenessCentralityNormalized:function(e){for(var t=Qn(e),n=t.harmonic,r=t.weight,i=t.directed,o=this.cy(),a={},s=0,l=this.nodes(),u=this.floydWarshall({weight:r,directed:i}),c=0;c<l.length;c++){for(var h=0,d=l[c],f=0;f<l.length;f++)if(c!==f){var p=u.distance(d,l[f]);h+=n?1/p:p}n||(h=1/h),s<h&&(s=h),a[d.id()]=h}return{closeness:function(e){return 0==s?0:(e=Z(e)?o.filter(e)[0].id():e.id(),a[e]/s)}}},closenessCentrality:function(e){var t=Qn(e),n=t.root,r=t.weight,i=t.directed,o=t.harmonic;n=this.filter(n)[0];for(var a=this.dijkstra({root:n,weight:r,directed:i}),s=0,l=this.nodes(),u=0;u<l.length;u++){var c=l[u];if(!c.same(n)){var h=a.distanceTo(c);s+=o?1/h:h}}return o?s:1/s}};Jn.cc=Jn.closenessCentrality,Jn.ccn=Jn.closenessCentralityNormalised=Jn.closenessCentralityNormalized;var er=gt({weight:null,directed:!1}),tr={betweennessCentrality:function(e){for(var t=er(e),n=t.directed,r=t.weight,i=null!=r,o=this.cy(),a=this.nodes(),s={},l={},u=0,c=function(e,t){l[e]=t,t>u&&(u=t)},h=function(e){return l[e]},d=0;d<a.length;d++){var f=a[d],p=f.id();s[p]=n?f.outgoers().nodes():f.openNeighborhood().nodes(),c(p,0)}for(var g=function(){for(var e=a[v].id(),t=[],n={},l={},u={},d=new Dt(function(e,t){return u[e]-u[t]}),f=0;f<a.length;f++){var p=a[f].id();n[p]=[],l[p]=0,u[p]=1/0}for(l[e]=1,u[e]=0,d.push(e);!d.empty();){var g=d.pop();if(t.push(g),i)for(var y=0;y<s[g].length;y++){var m=s[g][y],b=o.getElementById(g),x=void 0;x=b.edgesTo(m).length>0?b.edgesTo(m)[0]:m.edgesTo(b)[0];var w=r(x);m=m.id(),u[m]>u[g]+w&&(u[m]=u[g]+w,d.nodes.indexOf(m)<0?d.push(m):d.updateItem(m),l[m]=0,n[m]=[]),u[m]==u[g]+w&&(l[m]=l[m]+l[g],n[m].push(g))}else for(var E=0;E<s[g].length;E++){var T=s[g][E].id();u[T]==1/0&&(d.push(T),u[T]=u[g]+1),u[T]==u[g]+1&&(l[T]=l[T]+l[g],n[T].push(g))}}for(var C={},M=0;M<a.length;M++)C[a[M].id()]=0;for(;t.length>0;){for(var A=t.pop(),N=0;N<n[A].length;N++){var _=n[A][N];C[_]=C[_]+l[_]/l[A]*(1+C[A])}A!=a[v].id()&&c(A,h(A)+C[A])}},v=0;v<a.length;v++)g();var y={betweenness:function(e){var t=o.collection(e).id();return h(t)},betweennessNormalized:function(e){if(0==u)return 0;var t=o.collection(e).id();return h(t)/u}};return y.betweennessNormalised=y.betweennessNormalized,y}};tr.bc=tr.betweennessCentrality;var nr=gt({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(e){return 1}]}),rr=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r](e);return n},ir=function(e,t){for(var n,r=0;r<t;r++){n=0;for(var i=0;i<t;i++)n+=e[i*t+r];for(var o=0;o<t;o++)e[o*t+r]=e[o*t+r]/n}},or=function(e,t,n){for(var r=new Array(n*n),i=0;i<n;i++){for(var o=0;o<n;o++)r[i*n+o]=0;for(var a=0;a<n;a++)for(var s=0;s<n;s++)r[i*n+s]+=e[i*n+a]*t[a*n+s]}return r},ar=function(e,t,n){for(var r=e.slice(0),i=1;i<n;i++)e=or(e,r,t);return e},sr=function(e,t,n){for(var r=new Array(t*t),i=0;i<t*t;i++)r[i]=Math.pow(e[i],n);return ir(r,t),r},lr=function(e,t,n,r){for(var i=0;i<n;i++){if(Math.round(e[i]*Math.pow(10,r))/Math.pow(10,r)!==Math.round(t[i]*Math.pow(10,r))/Math.pow(10,r))return!1}return!0},ur=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},cr=function(e){for(var t=this.nodes(),n=this.edges(),r=this.cy(),i=function(e){return nr(e)}(e),o={},a=0;a<t.length;a++)o[t[a].id()]=a;for(var s,l=t.length,u=l*l,c=new Array(u),h=0;h<u;h++)c[h]=0;for(var d=0;d<n.length;d++){var f=n[d],p=o[f.source().id()],g=o[f.target().id()],v=rr(f,i.attributes);c[p*l+g]+=v,c[g*l+p]+=v}!function(e,t,n){for(var r=0;r<t;r++)e[r*t+r]=n}(c,l,i.multFactor),ir(c,l);for(var y=!0,m=0;y&&m<i.maxIterations;)y=!1,s=ar(c,l,i.expandFactor),c=sr(s,l,i.inflateFactor),lr(c,s,u,4)||(y=!0),m++;var b=function(e,t,n,r){for(var i=[],o=0;o<t;o++){for(var a=[],s=0;s<t;s++)Math.round(1e3*e[o*t+s])/1e3>0&&a.push(n[s]);0!==a.length&&i.push(r.collection(a))}return i}(c,l,t,r);return b=function(e){for(var t=0;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&ur(e[t],e[n])&&e.splice(n,1);return e}(b),b},hr={markovClustering:cr,mcl:cr},dr=function(e){return e},fr=function(e,t){return Math.abs(t-e)},pr=function(e,t,n){return e+fr(t,n)},gr=function(e,t,n){return e+Math.pow(n-t,2)},vr=function(e){return Math.sqrt(e)},yr=function(e,t,n){return Math.max(e,fr(t,n))},mr=function(e,t,n,r,i){for(var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:dr,a=r,s=0;s<e;s++)a=i(a,t(s),n(s));return o(a)},br={euclidean:function(e,t,n){return e>=2?mr(e,t,n,0,gr,vr):mr(e,t,n,0,pr)},squaredEuclidean:function(e,t,n){return mr(e,t,n,0,gr)},manhattan:function(e,t,n){return mr(e,t,n,0,pr)},max:function(e,t,n){return mr(e,t,n,-1/0,yr)}};function xr(e,t,n,r,i,o){var a;return a=Q(e)?e:br[e]||br.euclidean,0===t&&Q(e)?a(i,o):a(t,n,r,i,o)}br["squared-euclidean"]=br.squaredEuclidean,br.squaredeuclidean=br.squaredEuclidean;var wr=gt({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),Er=function(e){return wr(e)},Tr=function(e,t,n,r,i){var o="kMedoids"!==i?function(e){return n[e]}:function(e){return r[e](n)},a=n,s=t;return xr(e,r.length,o,function(e){return r[e](t)},a,s)},Cr=function(e,t,n){for(var r=n.length,i=new Array(r),o=new Array(r),a=new Array(t),s=null,l=0;l<r;l++)i[l]=e.min(n[l]).value,o[l]=e.max(n[l]).value;for(var u=0;u<t;u++){s=[];for(var c=0;c<r;c++)s[c]=Math.random()*(o[c]-i[c])+i[c];a[u]=s}return a},Mr=function(e,t,n,r,i){for(var o=1/0,a=0,s=0;s<t.length;s++){var l=Tr(n,e,t[s],r,i);l<o&&(o=l,a=s)}return a},Ar=function(e,t,n){for(var r=[],i=null,o=0;o<t.length;o++)n[(i=t[o]).id()]===e&&r.push(i);return r},Nr=function(e,t,n){return Math.abs(t-e)<=n},_r=function(e,t,n){for(var r=0;r<e.length;r++)for(var i=0;i<e[r].length;i++){if(Math.abs(e[r][i]-t[r][i])>n)return!1}return!0},Sr=function(e,t,n){for(var r=0;r<n;r++)if(e===t[r])return!0;return!1},kr=function(e,t){var n=new Array(t);if(e.length<50)for(var r=0;r<t;r++){for(var i=e[Math.floor(Math.random()*e.length)];Sr(i,n,r);)i=e[Math.floor(Math.random()*e.length)];n[r]=i}else for(var o=0;o<t;o++)n[o]=e[Math.floor(Math.random()*e.length)];return n},Pr=function(e,t,n){for(var r=0,i=0;i<t.length;i++)r+=Tr("manhattan",t[i],e,n,"kMedoids");return r},Ir=function(e,t,n,r,i){for(var o,a,s=0;s<t.length;s++)for(var l=0;l<e.length;l++)r[s][l]=Math.pow(n[s][l],i.m);for(var u=0;u<e.length;u++)for(var c=0;c<i.attributes.length;c++){o=0,a=0;for(var h=0;h<t.length;h++)o+=r[h][u]*i.attributes[c](t[h]),a+=r[h][u];e[u][c]=o/a}},Or=function(e,t,n,r,i){for(var o=0;o<e.length;o++)t[o]=e[o].slice();for(var a,s,l,u=2/(i.m-1),c=0;c<n.length;c++)for(var h=0;h<r.length;h++){a=0;for(var d=0;d<n.length;d++)s=Tr(i.distance,r[h],n[c],i.attributes,"cmeans"),l=Tr(i.distance,r[h],n[d],i.attributes,"cmeans"),a+=Math.pow(s/l,u);e[h][c]=1/a}},Dr=function(e){var t,n,r,i,o,a=this.cy(),s=this.nodes(),l=Er(e);i=new Array(s.length);for(var u=0;u<s.length;u++)i[u]=new Array(l.k);r=new Array(s.length);for(var c=0;c<s.length;c++)r[c]=new Array(l.k);for(var h=0;h<s.length;h++){for(var d=0,f=0;f<l.k;f++)r[h][f]=Math.random(),d+=r[h][f];for(var p=0;p<l.k;p++)r[h][p]=r[h][p]/d}n=new Array(l.k);for(var g=0;g<l.k;g++)n[g]=new Array(l.attributes.length);o=new Array(s.length);for(var v=0;v<s.length;v++)o[v]=new Array(l.k);for(var y=!0,m=0;y&&m<l.maxIterations;)y=!1,Ir(n,s,r,o,l),Or(r,i,n,s,l),_r(r,i,l.sensitivityThreshold)||(y=!0),m++;return t=function(e,t,n,r){for(var i,o,a=new Array(n.k),s=0;s<a.length;s++)a[s]=[];for(var l=0;l<t.length;l++){i=-1/0,o=-1;for(var u=0;u<t[0].length;u++)t[l][u]>i&&(i=t[l][u],o=u);a[o].push(e[l])}for(var c=0;c<a.length;c++)a[c]=r.collection(a[c]);return a}(s,r,l,a),{clusters:t,degreeOfMembership:r}},Lr={kMeans:function(e){var t,n=this.cy(),r=this.nodes(),i=null,o=Er(e),a=new Array(o.k),s={};o.testMode?"number"==typeof o.testCentroids?(o.testCentroids,t=Cr(r,o.k,o.attributes)):t="object"===p(o.testCentroids)?o.testCentroids:Cr(r,o.k,o.attributes):t=Cr(r,o.k,o.attributes);for(var l=!0,u=0;l&&u<o.maxIterations;){for(var c=0;c<r.length;c++)s[(i=r[c]).id()]=Mr(i,t,o.distance,o.attributes,"kMeans");l=!1;for(var h=0;h<o.k;h++){var d=Ar(h,r,s);if(0!==d.length){for(var f=o.attributes.length,g=t[h],v=new Array(f),y=new Array(f),m=0;m<f;m++){y[m]=0;for(var b=0;b<d.length;b++)i=d[b],y[m]+=o.attributes[m](i);v[m]=y[m]/d.length,Nr(v[m],g[m],o.sensitivityThreshold)||(l=!0)}t[h]=v,a[h]=n.collection(d)}}u++}return a},kMedoids:function(e){var t=this.cy(),n=this.nodes(),r=null,i=Er(e);i.k>n.length&<("kMedoids: k (".concat(i.k,") cannot exceed the number of nodes (").concat(n.length,")."));var o,a,s=new Array(i.k),l={},u=new Array(i.k);i.testMode?"number"==typeof i.testCentroids||(o="object"===p(i.testCentroids)?i.testCentroids:kr(n,i.k)):o=kr(n,i.k);for(var c=!0,h=0;c&&h<i.maxIterations;){for(var d=0;d<n.length;d++)l[(r=n[d]).id()]=Mr(r,o,i.distance,i.attributes,"kMedoids");c=!1;for(var f=0;f<o.length;f++){var g=Ar(f,n,l);if(0!==g.length){u[f]=Pr(o[f],g,i.attributes);for(var v=0;v<g.length;v++)(a=Pr(g[v],g,i.attributes))<u[f]&&(u[f]=a,o[f]=g[v],c=!0);s[f]=t.collection(g)}}h++}return s},fuzzyCMeans:Dr,fcm:Dr},Rr=gt({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),Br={single:"min",complete:"max"},zr=function(e,t,n,r,i){for(var o,a=0,s=1/0,l=i.attributes,u=function(e,t){return xr(i.distance,l.length,function(t){return l[t](e)},function(e){return l[e](t)},e,t)},c=0;c<e.length;c++){var h=e[c].key,d=n[h][r[h]];d<s&&(a=h,s=d)}if("threshold"===i.mode&&s>=i.threshold||"dendrogram"===i.mode&&1===e.length)return!1;var f,p=t[a],g=t[r[a]];f="dendrogram"===i.mode?{left:p,right:g,key:p.key,size:p.size+g.size}:{value:p.value.concat(g.value),key:p.key,size:p.size+g.size},e[p.index]=f,e.splice(g.index,1),t[p.key]=f;for(var v=0;v<e.length;v++){var y=e[v];p.key===y.key?o=1/0:"min"===i.linkage?(o=n[p.key][y.key],n[p.key][y.key]>n[g.key][y.key]&&(o=n[g.key][y.key])):"max"===i.linkage?(o=n[p.key][y.key],n[p.key][y.key]<n[g.key][y.key]&&(o=n[g.key][y.key])):o="mean"===i.linkage?(n[p.key][y.key]*p.size+n[g.key][y.key]*g.size)/(p.size+g.size):"dendrogram"===i.mode?u(y.value,p.value):u(y.value[0],p.value[0]),n[p.key][y.key]=n[y.key][p.key]=o}for(var m=0;m<e.length;m++){var b=e[m].key;if(r[b]===p.key||r[b]===g.key){for(var x=b,w=0;w<e.length;w++){var E=e[w].key;n[b][E]<n[b][x]&&(x=E)}r[b]=x}e[m].index=m}return p.key=g.key=p.index=g.index=null,!0},Fr=function(e,t,n){e&&(e.value?t.push(e.value):(e.left&&Fr(e.left,t),e.right&&Fr(e.right,t)))},Vr=function(e,t){if(!e)return"";if(e.left&&e.right){var n=Vr(e.left,t),r=Vr(e.right,t),i=t.add({group:"nodes",data:{id:n+","+r}});return t.add({group:"edges",data:{source:n,target:i.id()}}),t.add({group:"edges",data:{source:r,target:i.id()}}),i.id()}return e.value?e.value.id():void 0},Gr=function(e,t,n){if(!e)return[];var r=[],i=[],o=[];return 0===t?(e.left&&Fr(e.left,r),e.right&&Fr(e.right,i),o=r.concat(i),[n.collection(o)]):1===t?e.value?[n.collection(e.value)]:(e.left&&Fr(e.left,r),e.right&&Fr(e.right,i),[n.collection(r),n.collection(i)]):e.value?[n.collection(e.value)]:(e.left&&(r=Gr(e.left,t-1,n)),e.right&&(i=Gr(e.right,t-1,n)),r.concat(i))},Yr=function(e){var t=this.cy(),n=this.nodes();if(0===n.length)return[];for(var r=function(e){var t=Rr(e),n=Br[t.linkage];return null!=n&&(t.linkage=n),t}(e),i=r.attributes,o=function(e,t){return xr(r.distance,i.length,function(t){return i[t](e)},function(e){return i[e](t)},e,t)},a=[],s=[],l=[],u=[],c=0;c<n.length;c++){var h={value:"dendrogram"===r.mode?n[c]:[n[c]],key:c,index:c,size:1};a[c]=h,u[c]=h,s[c]=[],l[c]=0}for(var d=0;d<a.length;d++)for(var f=0;f<=d;f++){var p=void 0;p="dendrogram"===r.mode?d===f?1/0:o(a[d].value,a[f].value):d===f?1/0:o(a[d].value[0],a[f].value[0]),s[d][f]=p,s[f][d]=p,p<s[d][l[d]]&&(l[d]=f)}for(var g,v=zr(a,u,s,l,r);v;)v=zr(a,u,s,l,r);return"dendrogram"===r.mode?(g=Gr(a[0],r.dendrogramDepth,t),r.addDendrogram&&Vr(a[0],t)):(g=new Array(a.length),a.forEach(function(e,n){e.key=e.index=null,g[n]=t.collection(e.value)})),g},Xr={hierarchicalClustering:Yr,hca:Yr},$r=gt({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),Ur=function(e,t,n,r){var i=function(e,t){return r[t](e)};return-xr(e,r.length,function(e){return i(t,e)},function(e){return i(n,e)},t,n)},jr=function(e,t){var n=null;return n="median"===t?function(e){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=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];arguments.length>3&&void 0!==arguments[3]&&!arguments[3]?(n<e.length&&e.splice(n,e.length-n),t>0&&e.splice(0,t)):e=e.slice(t,n);for(var o=0,a=e.length-1;a>=0;a--){var s=e[a];i?isFinite(s)||(e[a]=-1/0,o++):e.splice(a,1)}r&&e.sort(function(e,t){return e-t});var l=e.length,u=Math.floor(l/2);return l%2!=0?e[u+1+o]:(e[u-1+o]+e[u+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,o=t;o<n;o++){var a=e[o];isFinite(a)&&(r+=a,i++)}return r/i}(e):"min"===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=1/0,i=t;i<n;i++){var o=e[i];isFinite(o)&&(r=Math.min(o,r))}return r}(e):"max"===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=-1/0,i=t;i<n;i++){var o=e[i];isFinite(o)&&(r=Math.max(o,r))}return r}(e):t,n},Hr=function(e,t,n){for(var r=[],i=0;i<e;i++){for(var o=-1,a=-1/0,s=0;s<n.length;s++){var l=n[s];t[i*e+l]>a&&(o=l,a=t[i*e+l])}o>0&&r.push(o)}for(var u=0;u<n.length;u++)r[n[u]]=n[u];return r},Wr=function(e){for(var t,n,r,i,o,a,s=this.cy(),l=this.nodes(),u=function(e){var t=e.damping,n=e.preference;.5<=t&&t<1||lt("Damping must range on [0.5, 1). Got: ".concat(t));var r=["median","mean","min","max"];return r.some(function(e){return e===n})||te(n)||lt("Preference must be one of [".concat(r.map(function(e){return"'".concat(e,"'")}).join(", "),"] or a number. Got: ").concat(n)),$r(e)}(e),c={},h=0;h<l.length;h++)c[l[h].id()]=h;n=(t=l.length)*t,r=new Array(n);for(var d=0;d<n;d++)r[d]=-1/0;for(var f=0;f<t;f++)for(var p=0;p<t;p++)f!==p&&(r[f*t+p]=Ur(u.distance,l[f],l[p],u.attributes));i=jr(r,u.preference);for(var g=0;g<t;g++)r[g*t+g]=i;o=new Array(n);for(var v=0;v<n;v++)o[v]=0;a=new Array(n);for(var y=0;y<n;y++)a[y]=0;for(var m=new Array(t),b=new Array(t),x=new Array(t),w=0;w<t;w++)m[w]=0,b[w]=0,x[w]=0;for(var E,T=new Array(t*u.minIterations),C=0;C<T.length;C++)T[C]=0;for(E=0;E<u.maxIterations;E++){for(var M=0;M<t;M++){for(var A=-1/0,N=-1/0,_=-1,S=0,k=0;k<t;k++)m[k]=o[M*t+k],(S=a[M*t+k]+r[M*t+k])>=A?(N=A,A=S,_=k):S>N&&(N=S);for(var P=0;P<t;P++)o[M*t+P]=(1-u.damping)*(r[M*t+P]-A)+u.damping*m[P];o[M*t+_]=(1-u.damping)*(r[M*t+_]-N)+u.damping*m[_]}for(var I=0;I<t;I++){for(var O=0,D=0;D<t;D++)m[D]=a[D*t+I],b[D]=Math.max(0,o[D*t+I]),O+=b[D];O-=b[I],b[I]=o[I*t+I],O+=b[I];for(var L=0;L<t;L++)a[L*t+I]=(1-u.damping)*Math.min(0,O-b[L])+u.damping*m[L];a[I*t+I]=(1-u.damping)*(O-b[I])+u.damping*m[I]}for(var R=0,B=0;B<t;B++){var z=a[B*t+B]+o[B*t+B]>0?1:0;T[E%u.minIterations*t+B]=z,R+=z}if(R>0&&(E>=u.minIterations-1||E==u.maxIterations-1)){for(var F=0,V=0;V<t;V++){x[V]=0;for(var G=0;G<u.minIterations;G++)x[V]+=T[G*t+V];0!==x[V]&&x[V]!==u.minIterations||F++}if(F===t)break}}for(var Y=function(e,t,n){for(var r=[],i=0;i<e;i++)t[i*e+i]+n[i*e+i]>0&&r.push(i);return r}(t,o,a),X=function(e,t,n){for(var r=Hr(e,t,n),i=0;i<n.length;i++){for(var o=[],a=0;a<r.length;a++)r[a]===n[i]&&o.push(a);for(var s=-1,l=-1/0,u=0;u<o.length;u++){for(var c=0,h=0;h<o.length;h++)c+=t[o[h]*e+o[u]];c>l&&(s=u,l=c)}n[i]=o[s]}return Hr(e,t,n)}(t,r,Y),$={},U=0;U<Y.length;U++)$[Y[U]]=[];for(var j=0;j<l.length;j++){var H=X[c[l[j].id()]];null!=H&&$[H].push(l[j])}for(var W=new Array(Y.length),q=0;q<Y.length;q++)W[q]=s.collection($[Y[q]]);return W},qr={affinityPropagation:Wr,ap:Wr},Kr=gt({root:void 0,directed:!1}),Zr={hierholzer:function(e){if(!ee(e)){var t=arguments;e={root:t[0],directed:t[1]}}var n,r,i,o=Kr(e),a=o.root,s=o.directed,l=this,u=!1;a&&(i=Z(a)?this.filter(a)[0].id():a[0].id());var c={},h={},d=l.edges().filter(function(e){return l.has(e.source())&&l.has(e.target())});s?l.forEach(function(e){var t=e.id();if(e.isNode()){var i=e.incomers().edges().intersection(d),o=e.outgoers().edges().intersection(d),a=i.length,s=o.length,l=a-s,f=s-a;1==l?n?u=!0:n=t:1==f?r?u=!0:r=t:(f>1||l>1)&&(u=!0),c[t]=[],o.forEach(function(e){return c[t].push(e.id())})}else h[t]=[void 0,e.target().id()]}):l.forEach(function(e){var t=e.id();if(e.isNode()){var i=e.connectedEdges().intersection(d),o=i.length+i.filter(function(e){return e.isLoop()}).length;o%2&&(n?r?u=!0:r=t:n=t),c[t]=[],i.forEach(function(e){return c[t].push(e.id())})}else h[t]=[e.source().id(),e.target().id()]});var f={found:!1,trail:void 0};if(u)return f;if(r&&n)if(s){if(i&&r!=i)return f;i=r}else{if(i&&r!=i&&n!=i)return f;i||(i=r)}else i||(i=l[0].id());var p=function(e){for(var t,n,r,i=e,o=[e];c[i].length;)t=c[i].shift(),n=h[t][0],i!=(r=h[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),o.unshift(t),o.unshift(i);return o},g=[],v=[];for(v=p(i);1!=v.length;)0==c[v[0]].length?(g.unshift(l.getElementById(v.shift())),g.unshift(l.getElementById(v.shift()))):v=p(v.shift()).concat(v);for(var y in g.unshift(l.getElementById(v.shift())),c)if(c[y].length)return f;return f.found=!0,f.trail=this.spawn(g,!0),f}},Qr=function(){var e=this,t={},n=0,r=0,i=[],o=[],a={},s=function(l,u,c){l===c&&(r+=1),t[u]={id:n,low:n++,cutVertex:!1};var h,d,f,p,g=e.getElementById(u).connectedEdges().intersection(e);0===g.size()?i.push(e.spawn(e.getElementById(u))):g.forEach(function(n){h=n.source().id(),d=n.target().id(),(f=h===u?d:h)!==c&&(p=n.id(),a[p]||(a[p]=!0,o.push({x:u,y:f,edge:n})),f in t?t[u].low=Math.min(t[u].low,t[f].id):(s(l,f,u),t[u].low=Math.min(t[u].low,t[f].low),t[u].id<=t[f].low&&(t[u].cutVertex=!0,function(n,r){for(var a=o.length-1,s=[],l=e.spawn();o[a].x!=n||o[a].y!=r;)s.push(o.pop().edge),a--;s.push(o.pop().edge),s.forEach(function(n){var r=n.connectedNodes().intersection(e);l.merge(n),r.forEach(function(n){var r=n.id(),i=n.connectedEdges().intersection(e);l.merge(n),t[r].cutVertex?l.merge(i.filter(function(e){return e.isLoop()})):l.merge(i)})}),i.push(l)}(u,f))))})};e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||(r=0,s(n,n),t[n].cutVertex=r>1)}});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}},Jr=function(){var e=this,t={},n=0,r=[],i=[],o=e.spawn(e),a=function(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||a(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),h=l.merge(c);r.push(h),o=o.difference(h)}};return e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||a(n)}}),{cut:o,components:r}},ei={};[At,Rt,Bt,Ft,Gt,Xt,Ht,qn,Zn,Jn,tr,hr,Lr,Xr,qr,Zr,{hopcroftTarjanBiconnected:Qr,htbc:Qr,htb:Qr,hopcroftTarjanBiconnectedComponents:Qr},{tarjanStronglyConnected:Jr,tsc:Jr,tscc:Jr,tarjanStronglyConnectedComponents:Jr}].forEach(function(e){Te(ei,e)});
|
|
2
|
+
/*!
|
|
3
|
+
Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
|
|
4
|
+
Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
|
|
5
|
+
Licensed under The MIT License (http://opensource.org/licenses/MIT)
|
|
6
|
+
*/
|
|
7
|
+
var ti=function(e){if(!(this instanceof ti))return new ti(e);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 e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};ti.prototype={fulfill:function(e){return ni(this,1,"fulfillValue",e)},reject:function(e){return ni(this,2,"rejectReason",e)},then:function(e,t){var n=this,r=new ti;return n.onFulfilled.push(oi(e,r,"fulfill")),n.onRejected.push(oi(t,r,"reject")),ri(n),r.proxy}};var ni=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,ri(e)),e},ri=function(e){1===e.state?ii(e,"onFulfilled",e.fulfillValue):2===e.state&&ii(e,"onRejected",e.rejectReason)},ii=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var i=function(){for(var e=0;e<r.length;e++)r[e](n)};"function"==typeof setImmediate?setImmediate(i):setTimeout(i,0)}},oi=function(e,t,n){return function(r){if("function"!=typeof e)t[n].call(t,r);else{var i;try{i=e(r)}catch(e){return void t.reject(e)}ai(t,i)}}},ai=function(e,t){if(e!==t&&e.proxy!==t){var n;if("object"===p(t)&&null!==t||"function"==typeof t)try{n=t.then}catch(t){return void e.reject(t)}if("function"!=typeof n)e.fulfill(t);else{var r=!1;try{n.call(t,function(n){r||(r=!0,n===t?e.reject(new TypeError("circular thenable chain")):ai(e,n))},function(t){r||(r=!0,e.reject(t))})}catch(t){r||e.reject(t)}}}else e.reject(new TypeError("cannot resolve promise with itself"))};ti.all=function(e){return new ti(function(t,n){for(var r=new Array(e.length),i=0,o=function(n,o){r[n]=o,++i===e.length&&t(r)},a=0;a<e.length;a++)(function(t){var r=e[t];null!=r&&null!=r.then?r.then(function(e){o(t,e)},function(e){n(e)}):o(t,r)})(a)})},ti.resolve=function(e){return new ti(function(t,n){t(e)})},ti.reject=function(e){return new ti(function(t,n){n(e)})};var si="undefined"!=typeof Promise?Promise:ti,li=function(e,t,n){var r=se(e),i=!r,o=this._private=Te({duration:1e3},t,n);if(o.target=e,o.style=o.style||o.css,o.started=!1,o.playing=!1,o.hooked=!1,o.applying=!1,o.progress=0,o.completes=[],o.frames=[],o.complete&&Q(o.complete)&&o.completes.push(o.complete),i){var a=e.position();o.startPosition=o.startPosition||{x:a.x,y:a.y},o.startStyle=o.startStyle||e.cy().style().getAnimationStartStyle(e,o.style)}if(r){var s=e.pan();o.startPan={x:s.x,y:s.y},o.startZoom=e.zoom()}this.length=1,this[0]=this},ui=li.prototype;Te(ui,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var t=e.target._private.animation;(e.queue?t.queue:t.current).push(this),ie(e.target)&&e.target.cy().addToAnimationPool(e.target),e.hooked=!0}return this},play:function(){var e=this._private;return 1===e.progress&&(e.progress=0),e.playing=!0,e.started=!1,e.stopped=!1,this.hook(),this},playing:function(){return this._private.playing},apply:function(){var e=this._private;return e.applying=!0,e.started=!1,e.stopped=!1,this.hook(),this},applying:function(){return this._private.applying},pause:function(){var e=this._private;return e.playing=!1,e.started=!1,this},stop:function(){var e=this._private;return e.playing=!1,e.started=!1,e.stopped=!0,this},rewind:function(){return this.progress(0)},fastforward:function(){return this.progress(1)},time:function(e){var t=this._private;return void 0===e?t.progress*t.duration:this.progress(e/t.duration)},progress:function(e){var t=this._private,n=t.playing;return void 0===e?t.progress:(n&&this.pause(),t.progress=e,t.started=!1,n&&this.play(),this)},completed:function(){return 1===this._private.progress},reverse:function(){var e=this._private,t=e.playing;t&&this.pause(),e.progress=1-e.progress,e.started=!1;var n=function(t,n){var r=e[t];null!=r&&(e[t]=e[n],e[n]=r)};if(n("zoom","startZoom"),n("pan","startPan"),n("position","startPosition"),e.style)for(var r=0;r<e.style.length;r++){var i=e.style[r],o=i.name,a=e.startStyle[o];e.startStyle[o]=i,e.style[r]=a}return t&&this.play(),this},promise:function(e){var t,n=this._private;if("frame"===e)t=n.frames;else t=n.completes;return new si(function(e,n){t.push(function(){e()})})}}),ui.complete=ui.completed,ui.run=ui.play,ui.running=ui.playing;var ci,hi,di,fi,pi,gi,vi,yi,mi,bi,xi,wi,Ei,Ti,Ci,Mi,Ai,Ni,_i,Si,ki,Pi,Ii,Oi,Di,Li,Ri,Bi,zi,Fi,Vi,Gi,Yi,Xi,$i,Ui,ji,Hi,Wi,qi,Ki,Zi,Qi,Ji,eo,to,no,ro,io,oo,ao,so,lo,uo,co,ho,fo,po,go,vo,yo,mo,bo,xo,wo,Eo,To,Co,Mo,Ao,No,_o,So,ko,Po,Io,Oo,Do,Lo,Ro,Bo,zo,Fo,Vo,Go,Yo,Xo={animated:function(){return function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return!1;var n=t[0];return n?n._private.animation.current.length>0:void 0}},clearQueue:function(){return function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return this;for(var n=0;n<t.length;n++){t[n]._private.animation.queue=[]}return this}},delay:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animate({delay:e,duration:e,complete:t}):this}},delayAnimation:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animation({delay:e,duration:e,complete:t}):this}},animation:function(){return function(e,t){var n=this,r=void 0!==n.length,i=r?n:[n],o=this._private.cy||this,a=!r,s=!a;if(!o.styleEnabled())return this;var l=o.style();if(e=Te({},e,t),0===Object.keys(e).length)return new li(i[0],e);switch(void 0===e.duration&&(e.duration=400),e.duration){case"slow":e.duration=600;break;case"fast":e.duration=200}if(s&&(e.style=l.getPropsList(e.style||e.css),e.css=void 0),s&&null!=e.renderedPosition){var u=e.renderedPosition,c=o.pan(),h=o.zoom();e.position=qt(u,h,c)}if(a&&null!=e.panBy){var d=e.panBy,f=o.pan();e.pan={x:f.x+d.x,y:f.y+d.y}}var p=e.center||e.centre;if(a&&null!=p){var g=o.getCenterPan(p.eles,e.zoom);null!=g&&(e.pan=g)}if(a&&null!=e.fit){var v=e.fit,y=o.getFitViewport(v.eles||v.boundingBox,v.padding);null!=y&&(e.pan=y.pan,e.zoom=y.zoom)}if(a&&ee(e.zoom)){var m=o.getZoomedViewport(e.zoom);null!=m?(m.zoomed&&(e.zoom=m.zoom),m.panned&&(e.pan=m.pan)):e.zoom=null}return new li(i[0],e)}},animate:function(){return function(e,t){var n=this,r=void 0!==n.length?n:[n];if(!(this._private.cy||this).styleEnabled())return this;t&&(e=Te({},e,t));for(var i=0;i<r.length;i++){var o=r[i],a=o.animated()&&(void 0===e.queue||e.queue);o.animation(e,a?{queue:!0}:void 0).play()}return this}},stop:function(){return function(e,t){var n=this,r=void 0!==n.length?n:[n],i=this._private.cy||this;if(!i.styleEnabled())return this;for(var o=0;o<r.length;o++){for(var a=r[o]._private,s=a.animation.current,l=0;l<s.length;l++){var u=s[l]._private;t&&(u.duration=0)}e&&(a.animation.queue=[]),t||(a.animation.current=[])}return i.notify("draw"),this}}};function $o(){if(hi)return ci;hi=1;var e=Array.isArray;return ci=e}function Uo(){if(bi)return mi;bi=1;var e,t=function(){if(yi)return vi;yi=1;var e=Pe()["__core-js_shared__"];return vi=e}(),n=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return mi=function(e){return!!n&&n in e}}function jo(){if(Ti)return Ei;Ti=1;var e=function(){if(gi)return pi;gi=1;var e=De(),t=ke();return pi=function(n){if(!t(n))return!1;var r=e(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}(),t=Uo(),n=ke(),r=function(){if(wi)return xi;wi=1;var e=Function.prototype.toString;return xi=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return Ei=function(o){return!(!n(o)||t(o))&&(e(o)?u:i).test(r(o))}}function Ho(){if(Ni)return Ai;Ni=1;var e=jo(),t=(Mi||(Mi=1,Ci=function(e,t){return null==e?void 0:e[t]}),Ci);return Ai=function(n,r){var i=t(n,r);return e(i)?i:void 0},Ai}function Wo(){if(Si)return _i;Si=1;var e=Ho()(Object,"create");return _i=e}function qo(){if(Gi)return Vi;Gi=1;var e=function(){if(Pi)return ki;Pi=1;var e=Wo();return ki=function(){this.__data__=e?e(null):{},this.size=0}}(),t=(Oi||(Oi=1,Ii=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}),Ii),n=function(){if(Li)return Di;Li=1;var e=Wo(),t=Object.prototype.hasOwnProperty;return Di=function(n){var r=this.__data__;if(e){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(r,n)?r[n]:void 0},Di}(),r=function(){if(Bi)return Ri;Bi=1;var e=Wo(),t=Object.prototype.hasOwnProperty;return Ri=function(n){var r=this.__data__;return e?void 0!==r[n]:t.call(r,n)},Ri}(),i=function(){if(Fi)return zi;Fi=1;var e=Wo();return zi=function(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=e&&void 0===n?"__lodash_hash_undefined__":n,this},zi}();function o(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,Vi=o}function Ko(){if(Ui)return $i;return Ui=1,$i=function(e,t){return e===t||e!=e&&t!=t}}function Zo(){if(Hi)return ji;Hi=1;var e=Ko();return ji=function(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1},ji}function Qo(){if(ro)return no;ro=1;var e=Xi?Yi:(Xi=1,Yi=function(){this.__data__=[],this.size=0}),t=function(){if(qi)return Wi;qi=1;var e=Zo(),t=Array.prototype.splice;return Wi=function(n){var r=this.__data__,i=e(r,n);return!(i<0||(i==r.length-1?r.pop():t.call(r,i,1),--this.size,0))},Wi}(),n=function(){if(Zi)return Ki;Zi=1;var e=Zo();return Ki=function(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]},Ki}(),r=function(){if(Ji)return Qi;Ji=1;var e=Zo();return Qi=function(t){return e(this.__data__,t)>-1},Qi}(),i=function(){if(to)return eo;to=1;var e=Zo();return eo=function(t,n){var r=this.__data__,i=e(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this},eo}();function o(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,no=o}function Jo(){if(so)return ao;so=1;var e=qo(),t=Qo(),n=function(){if(oo)return io;oo=1;var e=Ho()(Pe(),"Map");return io=e}();return ao=function(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}}function ea(){if(ho)return co;ho=1;var e=uo?lo:(uo=1,lo=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return co=function(t,n){var r=t.__data__;return e(n)?r["string"==typeof n?"string":"hash"]:r.map},co}function ta(){if(Eo)return wo;Eo=1;var e=Jo(),t=function(){if(po)return fo;po=1;var e=ea();return fo=function(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n},fo}(),n=function(){if(vo)return go;vo=1;var e=ea();return go=function(t){return e(this,t).get(t)},go}(),r=function(){if(mo)return yo;mo=1;var e=ea();return yo=function(t){return e(this,t).has(t)},yo}(),i=function(){if(xo)return bo;xo=1;var e=ea();return bo=function(t,n){var r=e(this,t),i=r.size;return r.set(t,n),this.size+=r.size==i?0:1,this},bo}();function o(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,wo=o}function na(){if(Ao)return Mo;Ao=1;var e=function(){if(Co)return To;Co=1;var e=ta();function t(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var e=arguments,t=r?r.apply(this,e):e[0],o=i.cache;if(o.has(t))return o.get(t);var a=n.apply(this,e);return i.cache=o.set(t,a)||o,a};return i.cache=new(t.Cache||e),i}return t.Cache=e,To=t}();return Mo=function(t){var n=e(t,function(e){return 500===r.size&&r.clear(),e}),r=n.cache;return n},Mo}function ra(){if(_o)return No;_o=1;var e=na(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(e){var r=[];return 46===e.charCodeAt(0)&&r.push(""),e.replace(t,function(e,t,i,o){r.push(i?o.replace(n,"$1"):t||e)}),r});return No=r}function ia(){if(ko)return So;return ko=1,So=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},So}function oa(){if(Do)return Oo;Do=1;var e=function(){if(Io)return Po;Io=1;var e=Oe(),t=ia(),n=$o(),r=Le(),i=e?e.prototype:void 0,o=i?i.toString:void 0;return Po=function e(i){if("string"==typeof i)return i;if(n(i))return t(i,e)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},Po}();return Oo=function(t){return null==t?"":e(t)}}function aa(){if(Ro)return Lo;Ro=1;var e=$o(),t=function(){if(fi)return di;fi=1;var e=$o(),t=Le(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return di=function(i,o){if(e(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!t(i))||r.test(i)||!n.test(i)||null!=o&&i in Object(o)},di}(),n=ra(),r=oa();return Lo=function(i,o){return e(i)?i:t(i,o)?[i]:n(r(i))},Lo}function sa(){if(zo)return Bo;zo=1;var e=Le();return Bo=function(t){if("string"==typeof t||e(t))return t;var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}}var la,ua,ca,ha,da,fa,pa,ga,va,ya,ma,ba,xa=function(){if(Yo)return Go;Yo=1;var e=function(){if(Vo)return Fo;Vo=1;var e=aa(),t=sa();return Fo=function(n,r){for(var i=0,o=(r=e(r,n)).length;null!=n&&i<o;)n=n[t(r[i++])];return i&&i==o?n:void 0},Fo}();return Go=function(t,n,r){var i=null==t?void 0:e(t,n);return void 0===i?r:i},Go}(),wa=Se(xa);function Ea(){if(ha)return ca;ha=1;var e=function(){if(ua)return la;ua=1;var e=Ho(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return la=t}();return ca=function(t,n,r){"__proto__"==n&&e?e(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r},ca}function Ta(){if(ya)return va;ya=1;var e=function(){if(fa)return da;fa=1;var e=Ea(),t=Ko(),n=Object.prototype.hasOwnProperty;return da=function(r,i,o){var a=r[i];n.call(r,i)&&t(a,o)&&(void 0!==o||i in r)||e(r,i,o)},da}(),t=aa(),n=function(){if(ga)return pa;ga=1;var e=/^(?:0|[1-9]\d*)$/;return pa=function(t,n){var r=typeof t;return!!(n=n??9007199254740991)&&("number"==r||"symbol"!=r&&e.test(t))&&t>-1&&t%1==0&&t<n}}(),r=ke(),i=sa();return va=function(o,a,s,l){if(!r(o))return o;for(var u=-1,c=(a=t(a,o)).length,h=c-1,d=o;null!=d&&++u<c;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=l?l(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}e(d,f,p),d=d[f]}return o},va}var Ca,Ma,Aa,Na,_a=function(){if(ba)return ma;ba=1;var e=Ta();return ma=function(t,n,r){return null==t?t:e(t,n,r)},ma}(),Sa=Se(_a);var ka=function(){if(Na)return Aa;Na=1;var e=ia(),t=(Ma||(Ma=1,Ca=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}),Ca),n=$o(),r=Le(),i=ra(),o=sa(),a=oa();return Aa=function(s){return n(s)?e(s,o):r(s)?[s]:t(i(a(s)))}}(),Pa=Se(ka),Ia={data:function(e){return e=Te({},{field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,beforeGet:function(e){},beforeSet:function(e,t){},onSet:function(e){},canSet:function(e){return!0}},e),function(t,n){var r=e,i=this,o=void 0!==i.length,a=o?i:[i],s=o?i[0]:i;if(Z(t)){var l,u=-1!==t.indexOf(".")&&Pa(t);if(r.allowGetting&&void 0===n)return s&&(r.beforeGet(s),l=u&&void 0===s._private[r.field][t]?wa(s._private[r.field],u):s._private[r.field][t]),l;if(r.allowSetting&&void 0!==n&&!r.immutableKeys[t]){var h=c({},t,n);r.beforeSet(i,h);for(var d=0,f=a.length;d<f;d++){var p=a[d];r.canSet(p)&&(u&&void 0===s._private[r.field][t]?Sa(p._private[r.field],u,n):p._private[r.field][t]=n)}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}}else if(r.allowSetting&&ee(t)){var g,v,y=t,m=Object.keys(y);r.beforeSet(i,y);for(var b=0;b<m.length;b++){if(v=y[g=m[b]],!r.immutableKeys[g])for(var x=0;x<a.length;x++){var w=a[x];r.canSet(w)&&(w._private[r.field][g]=v)}}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}else if(r.allowBinding&&Q(t)){var E=t;i.on(r.bindingEvent,E)}else if(r.allowGetting&&void 0===t){var T;return s&&(r.beforeGet(s),T=s._private[r.field]),T}return i}},removeData:function(e){return e=Te({},{field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}},e),function(t){var n=e,r=this,i=void 0!==r.length?r:[r];if(Z(t)){for(var o=t.split(/\s+/),a=o.length,s=0;s<a;s++){var l=o[s];if(!ue(l))if(!n.immutableKeys[l])for(var u=0,c=i.length;u<c;u++)i[u]._private[n.field][l]=void 0}n.triggerEvent&&r[n.triggerFnName](n.event)}else if(void 0===t){for(var h=0,d=i.length;h<d;h++)for(var f=i[h]._private[n.field],p=Object.keys(f),g=0;g<p.length;g++){var v=p[g];!n.immutableKeys[v]&&(f[v]=void 0)}n.triggerEvent&&r[n.triggerFnName](n.event)}return r}}},Oa={eventAliasesOn:function(e){var t=e;t.addListener=t.listen=t.bind=t.on,t.unlisten=t.unbind=t.off=t.removeListener,t.trigger=t.emit,t.pon=t.promiseOn=function(e,t){var n=this,r=Array.prototype.slice.call(arguments,0);return new si(function(e,t){var i=r.concat([function(t){n.off.apply(n,o),e(t)}]),o=i.concat([]);n.on.apply(n,i)})}}},Da={};[Xo,Ia,Oa].forEach(function(e){Te(Da,e)});var La={animate:Da.animate(),animation:Da.animation(),animated:Da.animated(),clearQueue:Da.clearQueue(),delay:Da.delay(),delayAnimation:Da.delayAnimation(),stop:Da.stop()},Ra={classes:function(e){var t=this;if(void 0===e){var n=[];return t[0]._private.classes.forEach(function(e){return n.push(e)}),n}J(e)||(e=(e||"").match(/\S+/g)||[]);for(var r=[],i=new Tt(e),o=0;o<t.length;o++){for(var a=t[o],s=a._private,l=s.classes,u=!1,c=0;c<e.length;c++){var h=e[c];if(!l.has(h)){u=!0;break}}u||(u=l.size!==e.length),u&&(s.classes=i,r.push(a))}return r.length>0&&this.spawn(r).updateStyle().emit("class"),t},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){J(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=void 0===t,i=[],o=0,a=n.length;o<a;o++)for(var s=n[o],l=s._private.classes,u=!1,c=0;c<e.length;c++){var h=e[c],d=l.has(h),f=!1;t||r&&!d?(l.add(h),f=!0):(!t||r&&d)&&(l.delete(h),f=!0),!u&&f&&(i.push(s),u=!0)}return i.length>0&&this.spawn(i).updateStyle().emit("class"),n},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}};Ra.className=Ra.classNames=Ra.classes;var Ba={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:ye,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Ba.variable="(?:[\\w-.]|(?:\\\\"+Ba.metaChar+"))+",Ba.className="(?:[\\w-]|(?:\\\\"+Ba.metaChar+"))+",Ba.value=Ba.string+"|"+Ba.number,Ba.id=Ba.variable,function(){var e,t,n;for(e=Ba.comparatorOp.split("|"),n=0;n<e.length;n++)t=e[n],Ba.comparatorOp+="|@"+t;for(e=Ba.comparatorOp.split("|"),n=0;n<e.length;n++)(t=e[n]).indexOf("!")>=0||"="!==t&&(Ba.comparatorOp+="|\\!"+t)}();var za=0,Fa=1,Va=2,Ga=3,Ya=4,Xa=5,$a=6,Ua=7,ja=8,Ha=9,Wa=10,qa=11,Ka=12,Za=13,Qa=14,Ja=15,es=16,ts=17,ns=18,rs=19,is=20,os=[{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*Ee(e,t)}(e.selector,t.selector)}),as=function(){for(var e,t={},n=0;n<os.length;n++)t[(e=os[n]).selector]=e.matches;return t}(),ss="("+os.map(function(e){return e.selector}).join("|")+")",ls=function(e){return e.replace(new RegExp("\\\\("+Ba.metaChar+")","g"),function(e,t){return t})},us=function(e,t,n){e[e.length-1]=n},cs=[{name:"group",query:!0,regex:"("+Ba.group+")",populate:function(e,t,n){var r=h(n,1)[0];t.checks.push({type:za,value:"*"===r?r:r+"s"})}},{name:"state",query:!0,regex:ss,populate:function(e,t,n){var r=h(n,1)[0];t.checks.push({type:Ua,value:r})}},{name:"id",query:!0,regex:"\\#("+Ba.id+")",populate:function(e,t,n){var r=h(n,1)[0];t.checks.push({type:ja,value:ls(r)})}},{name:"className",query:!0,regex:"\\.("+Ba.className+")",populate:function(e,t,n){var r=h(n,1)[0];t.checks.push({type:Ha,value:ls(r)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+Ba.variable+")\\s*\\]",populate:function(e,t,n){var r=h(n,1)[0];t.checks.push({type:Ya,field:ls(r)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+Ba.variable+")\\s*("+Ba.comparatorOp+")\\s*("+Ba.value+")\\s*\\]",populate:function(e,t,n){var r=h(n,3),i=r[0],o=r[1],a=r[2];a=null!=new RegExp("^"+Ba.string+"$").exec(a)?a.substring(1,a.length-1):parseFloat(a),t.checks.push({type:Ga,field:ls(i),operator:o,value:a})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+Ba.boolOp+")\\s*("+Ba.variable+")\\s*\\]",populate:function(e,t,n){var r=h(n,2),i=r[0],o=r[1];t.checks.push({type:Xa,field:ls(o),operator:i})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+Ba.meta+")\\s*("+Ba.comparatorOp+")\\s*("+Ba.number+")\\s*\\]\\]",populate:function(e,t,n){var r=h(n,3),i=r[0],o=r[1],a=r[2];t.checks.push({type:$a,field:ls(i),operator:o,value:parseFloat(a)})}},{name:"nextQuery",separator:!0,regex:Ba.separator,populate:function(e,t){var n=e.currentSubject,r=e.edgeCount,i=e.compoundCount,o=e[e.length-1];return null!=n&&(o.subject=n,e.currentSubject=null),o.edgeCount=r,o.compoundCount=i,e.edgeCount=0,e.compoundCount=0,e[e.length++]={checks:[]}}},{name:"directedEdge",separator:!0,regex:Ba.directedEdge,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r=t,i={checks:[]};return n.checks.push({type:qa,source:r,target:i}),us(e,0,n),e.edgeCount++,i}var o={checks:[]},a=t,s={checks:[]};return o.checks.push({type:Ka,source:a,target:s}),us(e,0,o),e.edgeCount++,s}},{name:"undirectedEdge",separator:!0,regex:Ba.undirectedEdge,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r=t,i={checks:[]};return n.checks.push({type:Wa,nodes:[r,i]}),us(e,0,n),e.edgeCount++,i}var o={checks:[]},a=t,s={checks:[]};return o.checks.push({type:Qa,node:a,neighbor:s}),us(e,0,o),s}},{name:"child",separator:!0,regex:Ba.child,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r={checks:[]},i=e[e.length-1];return n.checks.push({type:Ja,parent:i,child:r}),us(e,0,n),e.compoundCount++,r}if(e.currentSubject===t){var o={checks:[]},a=e[e.length-1],s={checks:[]},l={checks:[]},u={checks:[]},c={checks:[]};return o.checks.push({type:rs,left:a,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:is}],c.checks.push({type:is}),s.checks.push({type:ts,parent:c,child:u}),us(e,0,o),e.currentSubject=l,e.compoundCount++,u}var h={checks:[]},d={checks:[]},f=[{type:ts,parent:h,child:d}];return h.checks=t.checks,t.checks=f,e.compoundCount++,d}},{name:"descendant",separator:!0,regex:Ba.descendant,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r={checks:[]},i=e[e.length-1];return n.checks.push({type:es,ancestor:i,descendant:r}),us(e,0,n),e.compoundCount++,r}if(e.currentSubject===t){var o={checks:[]},a=e[e.length-1],s={checks:[]},l={checks:[]},u={checks:[]},c={checks:[]};return o.checks.push({type:rs,left:a,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:is}],c.checks.push({type:is}),s.checks.push({type:ns,ancestor:c,descendant:u}),us(e,0,o),e.currentSubject=l,e.compoundCount++,u}var h={checks:[]},d={checks:[]},f=[{type:ns,ancestor:h,descendant:d}];return h.checks=t.checks,t.checks=f,e.compoundCount++,d}},{name:"subject",modifier:!0,regex:Ba.subject,populate:function(e,t){if(null!=e.currentSubject&&e.currentSubject!==t)return ct("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var n=e[e.length-1].checks[0],r=null==n?null:n.type;r===qa?n.type=Za:r===Wa&&(n.type=Qa,n.node=n.nodes[1],n.neighbor=n.nodes[0],n.nodes=null)}}];cs.forEach(function(e){return e.regexObj=new RegExp("^"+e.regex)});var hs=function(e){for(var t,n,r,i=0;i<cs.length;i++){var o=cs[i],a=o.name,s=e.match(o.regexObj);if(null!=s){n=s,t=o,r=a;var l=s[0];e=e.substring(l.length);break}}return{expr:t,match:n,name:r,remaining:e}},ds={parse:function(e){var t=this,n=t.inputText=e,r=t[0]={checks:[]};for(t.length=1,n=function(e){var t=e.match(/^\s+/);if(t){var n=t[0];e=e.substring(n.length)}return e}(n);;){var i=hs(n);if(null==i.expr)return ct("The selector `"+e+"`is invalid"),!1;var o=i.match.slice(1),a=i.expr.populate(t,r,o);if(!1===a)return!1;if(null!=a&&(r=a),(n=i.remaining).match(/^\s*$/))break}var s=t[t.length-1];null!=t.currentSubject&&(s.subject=t.currentSubject),s.edgeCount=t.edgeCount,s.compoundCount=t.compoundCount;for(var l=0;l<t.length;l++){var u=t[l];if(u.compoundCount>0&&u.edgeCount>0)return ct("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(u.edgeCount>1)return ct("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===u.edgeCount&&ct("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 e??""},t=function(t){return Z(t)?'"'+t+'"':e(t)},n=function(e){return" "+e+" "},r=function(r,o){var a=r.type,s=r.value;switch(a){case za:var l=e(s);return l.substring(0,l.length-1);case Ga:var u=r.field,c=r.operator;return"["+u+n(e(c))+t(s)+"]";case Xa:var h=r.operator,d=r.field;return"["+e(h)+d+"]";case Ya:return"["+r.field+"]";case $a:var f=r.operator;return"[["+r.field+n(e(f))+t(s)+"]]";case Ua:return s;case ja:return"#"+s;case Ha:return"."+s;case ts:case Ja:return i(r.parent,o)+n(">")+i(r.child,o);case ns:case es:return i(r.ancestor,o)+" "+i(r.descendant,o);case rs:var p=i(r.left,o),g=i(r.subject,o),v=i(r.right,o);return p+(p.length>0?" ":"")+g+v;case is:return""}},i=function(e,t){return e.checks.reduce(function(n,i,o){return n+(t===e&&0===o?"$":"")+r(i,t)},"")},o="",a=0;a<this.length;a++){var s=this[a];o+=i(s,s.subject),this.length>1&&a<this.length-1&&(o+=", ")}return this.toStringCache=o,o}},fs=function(e,t,n){var r,i,o,a=Z(e),s=te(e),l=Z(n),u=!1,c=!1,h=!1;switch(t.indexOf("!")>=0&&(t=t.replace("!",""),c=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),u=!0),(a||l||u||("*="===t||"^="===t||"$="===t))&&(i=a||s?""+e:"",o=""+n),u&&(e=i=i.toLowerCase(),n=o=o.toLowerCase()),t){case"*=":r=i.indexOf(o)>=0;break;case"$=":r=i.indexOf(o,i.length-o.length)>=0;break;case"^=":r=0===i.indexOf(o);break;case"=":r=e===n;break;case">":h=!0,r=e>n;break;case">=":h=!0,r=e>=n;break;case"<":h=!0,r=e<n;break;case"<=":h=!0,r=e<=n;break;default:r=!1}return!c||null==e&&h||(r=!r),r},ps=function(e,t){return e.data(t)},gs=[],vs=function(e,t){return e.checks.every(function(e){return gs[e.type](e,t)})};gs[za]=function(e,t){var n=e.value;return"*"===n||n===t.group()},gs[Ua]=function(e,t){return function(e,t){return as[e](t)}(e.value,t)},gs[ja]=function(e,t){var n=e.value;return t.id()===n},gs[Ha]=function(e,t){var n=e.value;return t.hasClass(n)},gs[$a]=function(e,t){var n=e.field,r=e.operator,i=e.value;return fs(function(e,t){return e[t]()}(t,n),r,i)},gs[Ga]=function(e,t){var n=e.field,r=e.operator,i=e.value;return fs(ps(t,n),r,i)},gs[Xa]=function(e,t){var n=e.field,r=e.operator;return function(e,t){switch(t){case"?":return!!e;case"!":return!e;case"^":return void 0===e}}(ps(t,n),r)},gs[Ya]=function(e,t){var n=e.field;return e.operator,void 0!==ps(t,n)},gs[Wa]=function(e,t){var n=e.nodes[0],r=e.nodes[1],i=t.source(),o=t.target();return vs(n,i)&&vs(r,o)||vs(r,i)&&vs(n,o)},gs[Qa]=function(e,t){return vs(e.node,t)&&t.neighborhood().some(function(t){return t.isNode()&&vs(e.neighbor,t)})},gs[qa]=function(e,t){return vs(e.source,t.source())&&vs(e.target,t.target())},gs[Ka]=function(e,t){return vs(e.source,t)&&t.outgoers().some(function(t){return t.isNode()&&vs(e.target,t)})},gs[Za]=function(e,t){return vs(e.target,t)&&t.incomers().some(function(t){return t.isNode()&&vs(e.source,t)})},gs[Ja]=function(e,t){return vs(e.child,t)&&vs(e.parent,t.parent())},gs[ts]=function(e,t){return vs(e.parent,t)&&t.children().some(function(t){return vs(e.child,t)})},gs[es]=function(e,t){return vs(e.descendant,t)&&t.ancestors().some(function(t){return vs(e.ancestor,t)})},gs[ns]=function(e,t){return vs(e.ancestor,t)&&t.descendants().some(function(t){return vs(e.descendant,t)})},gs[rs]=function(e,t){return vs(e.subject,t)&&vs(e.left,t)&&vs(e.right,t)},gs[is]=function(){return!0},gs[Fa]=function(e,t){return e.value.has(t)},gs[Va]=function(e,t){return(0,e.value)(t)};var ys={matches:function(e){for(var t=0;t<this.length;t++){var n=this[t];if(vs(n,e))return!0}return!1},filter:function(e){var t=this;if(1===t.length&&1===t[0].checks.length&&t[0].checks[0].type===ja)return e.getElementById(t[0].checks[0].value).collection();var n=function(e){for(var n=0;n<t.length;n++){var r=t[n];if(vs(r,e))return!0}return!1};return null==t.text()&&(n=function(){return!0}),e.filter(n)}},ms=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,null==e||Z(e)&&e.match(/^\s*$/)||(ie(e)?this.addQuery({checks:[{type:Fa,value:e.collection()}]}):Q(e)?this.addQuery({checks:[{type:Va,value:e}]}):Z(e)?this.parse(e)||(this.invalid=!0):lt("A selector must be created from a string; found "))},bs=ms.prototype;[ds,ys].forEach(function(e){return Te(bs,e)}),bs.text=function(){return this.inputText},bs.size=function(){return this.length},bs.eq=function(e){return this[e]},bs.sameText=function(e){return!this.invalid&&!e.invalid&&this.text()===e.text()},bs.addQuery=function(e){this[this.length++]=e},bs.selector=bs.toString;var xs={allAre:function(e){var t=new ms(e);return this.every(function(e){return t.matches(e)})},is:function(e){var t=new ms(e);return this.some(function(e){return t.matches(e)})},some:function(e,t){for(var n=0;n<this.length;n++){if(t?e.apply(t,[this[n],n,this]):e(this[n],n,this))return!0}return!1},every:function(e,t){for(var n=0;n<this.length;n++){if(!(t?e.apply(t,[this[n],n,this]):e(this[n],n,this)))return!1}return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var t=this.length;return t===e.length&&(1===t?this[0]===e[0]:this.every(function(t){return e.hasElementWithId(t.id())}))},anySame:function(e){return e=this.cy().collection(e),this.some(function(t){return e.hasElementWithId(t.id())})},allAreNeighbors:function(e){e=this.cy().collection(e);var t=this.neighborhood();return e.every(function(e){return t.hasElementWithId(e.id())})},contains:function(e){e=this.cy().collection(e);var t=this;return e.every(function(e){return t.hasElementWithId(e.id())})}};xs.allAreNeighbours=xs.allAreNeighbors,xs.has=xs.contains,xs.equal=xs.equals=xs.same;var ws,Es,Ts=function(e,t){return function(n,r,i,o){var a,s=n,l=this;if(null==s?a="":ie(s)&&1===s.length&&(a=s.id()),1===l.length&&a){var u=l[0]._private,c=u.traversalCache=u.traversalCache||{},h=c[t]=c[t]||[],d=Ke(a),f=h[d];return f||(h[d]=e.call(l,n,r,i,o))}return e.call(l,n,r,i,o)}},Cs={parent:function(e){var t=[];if(1===this.length){var n=this[0]._private.parent;if(n)return n}for(var r=0;r<this.length;r++){var i=this[r]._private.parent;i&&t.push(i)}return this.spawn(t,!0).filter(e)},parents:function(e){for(var t=[],n=this.parent();n.nonempty();){for(var r=0;r<n.length;r++){var i=n[r];t.push(i)}n=n.parent()}return this.spawn(t,!0).filter(e)},commonAncestors:function(e){for(var t,n=0;n<this.length;n++){var r=this[n].parents();t=(t=t||r).intersect(r)}return t.filter(e)},orphans:function(e){return this.stdFilter(function(e){return e.isOrphan()}).filter(e)},nonorphans:function(e){return this.stdFilter(function(e){return e.isChild()}).filter(e)},children:Ts(function(e){for(var t=[],n=0;n<this.length;n++)for(var r=this[n]._private.children,i=0;i<r.length;i++)t.push(r[i]);return this.spawn(t,!0).filter(e)},"children"),siblings:function(e){return this.parent().children().not(this).filter(e)},isParent:function(){var e=this[0];if(e)return e.isNode()&&0!==e._private.children.length},isChildless:function(){var e=this[0];if(e)return e.isNode()&&0===e._private.children.length},isChild:function(){var e=this[0];if(e)return e.isNode()&&null!=e._private.parent},isOrphan:function(){var e=this[0];if(e)return e.isNode()&&null==e._private.parent},descendants:function(e){var t=[];return function e(n){for(var r=0;r<n.length;r++){var i=n[r];t.push(i),i.children().nonempty()&&e(i.children())}}(this.children()),this.spawn(t,!0).filter(e)}};function Ms(e,t,n,r){for(var i=[],o=new Tt,a=e.cy().hasCompoundNodes(),s=0;s<e.length;s++){var l=e[s];n?i.push(l):a&&r(i,o,l)}for(;i.length>0;){var u=i.shift();t(u),o.add(u.id()),a&&r(i,o,u)}return e}function As(e,t,n){if(n.isParent())for(var r=n._private.children,i=0;i<r.length;i++){var o=r[i];t.has(o.id())||e.push(o)}}function Ns(e,t,n){if(n.isChild()){var r=n._private.parent;t.has(r.id())||e.push(r)}}function _s(e,t,n){Ns(e,t,n),As(e,t,n)}Cs.forEachDown=function(e){return Ms(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],As)},Cs.forEachUp=function(e){return Ms(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],Ns)},Cs.forEachUpAndDown=function(e){return Ms(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],_s)},Cs.ancestors=Cs.parents,(ws=Es={data:Da.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:Da.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Da.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Da.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Da.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Da.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=ws.data,ws.removeAttr=ws.removeData;var Ss,ks,Ps=Es,Is={};function Os(e){return function(t){var n=this;if(void 0===t&&(t=!0),0!==n.length&&n.isNode()&&!n.removed()){for(var r=0,i=n[0],o=i._private.edges,a=0;a<o.length;a++){var s=o[a];!t&&s.isLoop()||(r+=e(i,s))}return r}}}function Ds(e,t){return function(n){for(var r,i=this.nodes(),o=0;o<i.length;o++){var a=i[o][e](n);void 0===a||void 0!==r&&!t(a,r)||(r=a)}return r}}Te(Is,{degree:Os(function(e,t){return t.source().same(t.target())?2:1}),indegree:Os(function(e,t){return t.target().same(e)?1:0}),outdegree:Os(function(e,t){return t.source().same(e)?1:0})}),Te(Is,{minDegree:Ds("degree",function(e,t){return e<t}),maxDegree:Ds("degree",function(e,t){return e>t}),minIndegree:Ds("indegree",function(e,t){return e<t}),maxIndegree:Ds("indegree",function(e,t){return e>t}),minOutdegree:Ds("outdegree",function(e,t){return e<t}),maxOutdegree:Ds("outdegree",function(e,t){return e>t})}),Te(Is,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r<n.length;r++)t+=n[r].degree(e);return t}});var Ls=function(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(!i.locked()){var o=i._private.position,a={x:null!=t.x?t.x-o.x:0,y:null!=t.y?t.y-o.y:0};!i.isParent()||0===a.x&&0===a.y||i.children().shift(a,n),i.dirtyBoundingBoxCache(),i.isNode()&&i.connectedEdges().dirtyBoundingBoxCache()}}},Rs={field:"position",bindingEvent:"position",allowBinding:!0,allowSetting:!0,settingEvent:"position",settingTriggersEvent:!0,triggerFnName:"emitAndNotify",allowGetting:!0,validKeys:["x","y"],beforeGet:function(e){e.updateCompoundBounds()},beforeSet:function(e,t){Ls(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};Ss=ks={position:Da.data(Rs),silentPosition:Da.data(Te({},Rs,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){Ls(e,t,!0)},onSet:function(e){e.dirtyCompoundBoundsCache()}})),positions:function(e,t){if(ee(e))t?this.silentPosition(e):this.position(e);else if(Q(e)){var n=e,r=this.cy();r.startBatch();for(var i=0;i<this.length;i++){var o,a=this[i];(o=n(a,i))&&(t?a.silentPosition(o):a.position(o))}r.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,n){var r;if(ee(e)?(r={x:te(e.x)?e.x:0,y:te(e.y)?e.y:0},n=t):Z(e)&&te(t)&&((r={x:0,y:0})[e]=t),null!=r){var i=this.cy();i.startBatch();for(var o=0;o<this.length;o++){var a=this[o];if(!(i.hasCompoundNodes()&&a.isChild()&&a.ancestors().anySame(this))){var s=a.position(),l={x:s.x+r.x,y:s.y+r.y};n?a.silentPosition(l):a.position(l)}}i.endBatch()}return this},silentShift:function(e,t){return ee(e)?this.shift(e,!0):Z(e)&&te(t)&&this.shift(e,t,!0),this},renderedPosition:function(e,t){var n=this[0],r=this.cy(),i=r.zoom(),o=r.pan(),a=ee(e)?e:void 0,s=void 0!==a||void 0!==t&&Z(e);if(n&&n.isNode()){if(!s){var l=n.position();return a=Wt(l,i,o),void 0===e?a:a[e]}for(var u=0;u<this.length;u++){var c=this[u];void 0!==t?c.position(e,(t-o[e])/i):void 0!==a&&c.position(qt(a,i,o))}}else if(!s)return;return this},relativePosition:function(e,t){var n=this[0],r=this.cy(),i=ee(e)?e:void 0,o=void 0!==i||void 0!==t&&Z(e),a=r.hasCompoundNodes();if(n&&n.isNode()){if(!o){var s=n.position(),l=a?n.parent():null,u=l&&l.length>0,c=u;u&&(l=l[0]);var h=c?l.position():{x:0,y:0};return i={x:s.x-h.x,y:s.y-h.y},void 0===e?i:i[e]}for(var d=0;d<this.length;d++){var f=this[d],p=a?f.parent():null,g=p&&p.length>0,v=g;g&&(p=p[0]);var y=v?p.position():{x:0,y:0};void 0!==t?f.position(e,t+y[e]):void 0!==i&&f.position({x:i.x+y.x,y:i.y+y.y})}}else if(!o)return;return this}},Ss.modelPosition=Ss.point=Ss.position,Ss.modelPositions=Ss.points=Ss.positions,Ss.renderedPoint=Ss.renderedPosition,Ss.relativePoint=Ss.relativePosition;var Bs,zs,Fs=ks,Vs=function(e){switch(e){case"left":case"right-inside":return"left";case"right":case"left-inside":return"right";default:return"center"}},Gs=function(e){switch(e){case"top":case"bottom-inside":return"top";case"bottom":case"top-inside":return"bottom";default:return"center"}};Bs=zs={},zs.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),i=n.pan(),o=t.x1*r+i.x,a=t.x2*r+i.x,s=t.y1*r+i.y,l=t.y2*r+i.y;return{x1:o,x2:a,y1:s,y2:l,w:a-o,h:l-s}};var Ys=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"main";if(!e||!e.cy().styleEnabled())return null;var n="main"===t?void 0:t,r=e._private,i=r.labelPolygonCache,o=nl(e);if(!(null==i||null==i[t]||r.styleDirty||r.labelPolygonPosKey!==o))return i[t];e.recalculateRenderedStyle(),o=nl(e),null!=r.labelPolygonCache&&r.labelPolygonPosKey===o||(r.labelPolygonCache={},r.labelPolygonPosKey=o);var a=Hs(e,n);return r.labelPolygonCache[t]=a,a};zs.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},zs.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")}},o=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),a=t.position;0!==o.w&&0!==o.h||((o={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=a.x-o.w/2,o.x2=a.x+o.w/2,o.y1=a.y-o.h/2,o.y2=a.y+o.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 h=y(i.width.val-o.w,s,l),d=h.biasDiff,f=h.biasComplementDiff,p=y(i.height.val-o.h,u,c),g=p.biasDiff,v=p.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}}(o.w,o.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(o.w,i.width.val),a.x=(-d+o.x1+o.x2+f)/2,t.autoHeight=Math.max(o.h,i.height.val),a.y=(-g+o.y1+o.y2+v)/2}function y(e,t,n){var r=0,i=0,o=t+n;return e>0&&o>0&&(r=t/o*e,i=n/o*e),{biasDiff:r,biasComplementDiff:i}}}for(var r=0;r<this.length;r++){var i=this[r],o=i._private;o.compoundBoundsClean&&!e||(n(i),t.batching()||(o.compoundBoundsClean=!0))}return this};var Xs=function(e){return e===1/0||e===-1/0?0:e},$s=function(e,t,n,r,i){r-t!==0&&i-n!==0&&null!=t&&null!=n&&null!=r&&null!=i&&(e.x1=t<e.x1?t:e.x1,e.x2=r>e.x2?r:e.x2,e.y1=n<e.y1?n:e.y1,e.y2=i>e.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Us=function(e,t){return null==t?e:$s(e,t.x1,t.y1,t.x2,t.y2)},js=function(e,t,n){return mt(e,t,n)},Hs=function(e,t){if(!e.cy().headless()){var n=e._private,r=t?t+"-":"";if(!e.pstyle(r+"label").strValue)return null;e.boundingBox({includeLabels:!0});var i=t||"main",o=n.labelBounds[i];if(!o)return null;var a=js(n.rscratch,"labelX",t),s=js(n.rscratch,"labelY",t),l=js(n.rscratch,"labelAngle",t),u=e.pstyle(r+"text-margin-x").pfValue,c=e.pstyle(r+"text-margin-y").pfValue;return $n(o,a,s,l,u,c,0)}},Ws=function(e,t,n){if(!t.cy().headless()){var r,i,o=t._private,a=o.rstyle,s=(null!=a.arrowWidths&&null!=a.arrowWidths[n]?a.arrowWidths[n]:a.arrowWidth)/2;if("none"!==t.pstyle(n+"-arrow-shape").value){"source"===n?(r=a.srcX,i=a.srcY):"target"===n?(r=a.tgtX,i=a.tgtY):(r=a.midX,i=a.midY);var l=o.arrowBounds=o.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,fn(u,1),$s(e,u.x1,u.y1,u.x2,u.y2)}}},qs=function(e,t,n){if(!t.cy().headless()){var r;r=n?n+"-":"";var i=t._private,o=i.rstyle;if(t.pstyle(r+"label").strValue){var a,s,l,u,c=t.pstyle("text-halign"),h=t.pstyle("text-valign"),d=js(o,"labelWidth",n),f=js(o,"labelHeight",n),p=js(o,"labelX",n),g=js(o,"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,T=f,C=d,M=C/2,A=T/2;if(m)a=p-M,s=p+M,l=g-A,u=g+A;else{switch(Vs(c.value)){case"left":a=p-C,s=p;break;case"center":a=p-M,s=p+M;break;case"right":a=p,s=p+C}switch(Gs(h.value)){case"top":l=g-T,u=g;break;case"center":l=g-A,u=g+A;break;case"bottom":l=g,u=g+T}}var N=v-Math.max(x,w)-E-2,_=v+Math.max(x,w)+E+2,S=y-Math.max(x,w)-E-2,k=y+Math.max(x,w)+E+2;a+=N,s+=_,l+=S,u+=k;var P=n||"main",I=i.labelBounds,O=I[P]=I[P]||{};O.x1=a,O.y1=l,O.x2=s,O.y2=u,O.w=s-a,O.h=u-l,O.leftPad=N,O.rightPad=_,O.topPad=S,O.botPad=k;var D=m&&"autorotate"===b.strValue,L=null!=b.pfValue&&0!==b.pfValue;if(D||L){var R=D?js(i.rstyle,"labelAngle",n):b.pfValue,B=Math.cos(R),z=Math.sin(R),F=(a+s)/2,V=(l+u)/2;if(!m){switch(Vs(c.value)){case"left":F=s;break;case"right":F=a}switch(Gs(h.value)){case"top":V=u;break;case"bottom":V=l}}var G=function(e,t){return{x:(e-=F)*B-(t-=V)*z+F,y:e*z+t*B+V}},Y=G(a,l),X=G(a,u),$=G(s,l),U=G(s,u);a=Math.min(Y.x,X.x,$.x,U.x),s=Math.max(Y.x,X.x,$.x,U.x),l=Math.min(Y.y,X.y,$.y,U.y),u=Math.max(Y.y,X.y,$.y,U.y)}var j=P+"Rot",H=I[j]=I[j]||{};H.x1=a,H.y1=l,H.x2=s,H.y2=u,H.w=s-a,H.h=u-l,$s(e,a,l,s,u),$s(i.labelBounds.all,a,l,s,u)}return e}},Ks=function(e,t){if(!t.cy().headless()){var n=t.pstyle("outline-opacity").value,r=t.pstyle("outline-width").value+t.pstyle("outline-offset").value;Zs(e,t,n,r,"outside",r/2)}},Zs=function(e,t,n,r,i,o){if(!(0===n||r<=0||"inside"===i)){var a=t.cy().renderer(),s=a.nodeShapes[a.getNodeShape(t)];if(s){var l=t.position(),u=l.x,c=l.y,h=t.width(),d=t.height();if(s.hasMiterBounds){"center"===i&&(r/=2);var f=s.miterBounds(u,c,h,d,r);Us(e,f)}else null!=o&&o>0&&pn(e,[o,o,o,o])}}},Qs=function(e,t){var n,r,i,o,a,s,l,u=e._private.cy,c=u.styleEnabled(),h=u.headless(),d=cn(),f=e._private,p=e.isNode(),g=e.isEdge(),v=f.rstyle,y=p&&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),T=0;if(c&&(T=e.pstyle("width").pfValue/2),p&&t.includeNodes){var C=e.position();a=C.x,s=C.y;var M=e.outerWidth()/2,A=e.outerHeight()/2;$s(d,n=a-M,i=s-A,r=a+M,o=s+A),c&&Ks(d,e),c&&t.includeOutlines&&!h&&Ks(d,e),c&&function(e,t){if(!t.cy().headless()){var n=t.pstyle("border-opacity").value,r=t.pstyle("border-width").pfValue,i=t.pstyle("border-position").value;Zs(e,t,n,r,i)}}(d,e)}else if(g&&t.includeEdges)if(c&&!h){var N=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),o=Math.max(v.srcY,v.midY,v.tgtY),$s(d,n-=T,i-=T,r+=T,o+=T),"haystack"===N){var _=v.haystackPts;if(_&&2===_.length){if(n=_[0].x,i=_[0].y,n>(r=_[1].x)){var S=n;n=r,r=S}if(i>(o=_[1].y)){var k=i;i=o,o=k}$s(d,n-T,i-T,r+T,o+T)}}else if("bezier"===N||"unbundled-bezier"===N||ve(N,"segments")||ve(N,"taxi")){var P;switch(N){case"bezier":case"unbundled-bezier":P=v.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":P=v.linePts}if(null!=P)for(var I=0;I<P.length;I++){var O=P[I];n=O.x-T,r=O.x+T,i=O.y-T,o=O.y+T,$s(d,n,i,r,o)}}}else{var D=e.source().position(),L=e.target().position();if((n=D.x)>(r=L.x)){var R=n;n=r,r=R}if((i=D.y)>(o=L.y)){var B=i;i=o,o=B}$s(d,n-=T,i-=T,r+=T,o+=T)}if(c&&t.includeEdges&&g&&(Ws(d,e,"mid-source"),Ws(d,e,"mid-target"),Ws(d,e,"source"),Ws(d,e,"target")),c)if("yes"===e.pstyle("ghost").value){var z=e.pstyle("ghost-offset-x").pfValue,F=e.pstyle("ghost-offset-y").pfValue;$s(d,d.x1+z,d.y1+F,d.x2+z,d.y2+F)}var V=f.bodyBounds=f.bodyBounds||{};gn(V,d),pn(V,y),fn(V,1),c&&(n=d.x1,r=d.x2,i=d.y1,o=d.y2,$s(d,n-E,i-E,r+E,o+E));var G=f.overlayBounds=f.overlayBounds||{};gn(G,d),pn(G,y),fn(G,1);var Y=f.labelBounds=f.labelBounds||{};null!=Y.all?((l=Y.all).x1=1/0,l.y1=1/0,l.x2=-1/0,l.y2=-1/0,l.w=0,l.h=0):Y.all=cn(),c&&t.includeLabels&&(t.includeMainLabels&&qs(d,e,null),g&&(t.includeSourceLabels&&qs(d,e,"source"),t.includeTargetLabels&&qs(d,e,"target")))}return d.x1=Xs(d.x1),d.y1=Xs(d.y1),d.x2=Xs(d.x2),d.y2=Xs(d.y2),d.w=Xs(d.x2-d.x1),d.h=Xs(d.y2-d.y1),d.w>0&&d.h>0&&b&&(pn(d,y),fn(d,1)),d},Js=function(e){var t=0,n=function(e){return(e?1:0)<<t++},r=0;return r+=n(e.incudeNodes),r+=n(e.includeEdges),r+=n(e.includeLabels),r+=n(e.includeMainLabels),r+=n(e.includeSourceLabels),r+=n(e.includeTargetLabels),r+=n(e.includeOverlays),r+=n(e.includeOutlines)},el=function(e){var t=function(e){return Math.round(e)};if(e.isEdge()){var n=e.source().position(),r=e.target().position();return qe([t(n.x),t(n.y),t(r.x),t(r.y)])}var i=e.position();return qe([t(i.x),t(i.y)])},tl=function(e,t){var n,r=e._private,i=e.isEdge(),o=(null==t?il:Js(t))===il;if(null==r.bbCache?(n=Qs(e,rl),r.bbCache=n,r.bbCachePosKey=el(e)):n=r.bbCache,!o){var a=e.isNode();n=cn(),(t.includeNodes&&a||t.includeEdges&&!a)&&(t.includeOverlays?Us(n,r.overlayBounds):Us(n,r.bodyBounds)),t.includeLabels&&(t.includeMainLabels&&(!i||t.includeSourceLabels&&t.includeTargetLabels)?Us(n,r.labelBounds.all):(t.includeMainLabels&&Us(n,r.labelBounds.mainRot),t.includeSourceLabels&&Us(n,r.labelBounds.sourceRot),t.includeTargetLabels&&Us(n,r.labelBounds.targetRot))),n.w=n.x2-n.x1,n.h=n.y2-n.y1}return n},nl=function(e){var t=e.pstyle("text-rotation").pfValue||0;if(e.isEdge()){var n=e.source().position(),r=e.target().position();return qe([Math.round(n.x),Math.round(n.y),Math.round(r.x),Math.round(r.y),Math.round(1e3*t)])}var i=e.position();return qe([Math.round(i.x),Math.round(i.y),Math.round(1e3*t)])},rl={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,includeOutlines:!0,useCache:!0},il=Js(rl),ol=gt(rl);zs.boundingBox=function(e){var t,n=void 0===e||void 0===e.useCache||!0===e.useCache,r=he(function(e){var t=e._private;return null==t.bbCache||t.styleDirty||t.bbCachePosKey!==el(e)},function(e){return e.id()});if(n&&1===this.length&&!r(this[0]))e=void 0===e?rl:ol(e),t=tl(this[0],e);else{t=cn();var i=ol(e=e||rl),o=this,a=o.cy().styleEnabled();this.edges().forEach(r),this.nodes().forEach(r),a&&this.recalculateRenderedStyle(n),this.updateCompoundBounds(!n);for(var s=0;s<o.length;s++){var l=o[s];r(l)&&l.dirtyBoundingBoxCache(),Us(t,tl(l,i))}}return t.x1=Xs(t.x1),t.y1=Xs(t.y1),t.x2=Xs(t.x2),t.y2=Xs(t.y2),t.w=Xs(t.x2-t.x1),t.h=Xs(t.y2-t.y1),t},zs.dirtyBoundingBoxCache=function(){for(var e=0;e<this.length;e++){var t=this[e]._private;t.bbCache=null,t.bbCachePosKey=null,t.bodyBounds=null,t.overlayBounds=null,t.labelBounds.all=null,t.labelBounds.source=null,t.labelBounds.target=null,t.labelBounds.main=null,t.labelBounds.sourceRot=null,t.labelBounds.targetRot=null,t.labelBounds.mainRot=null,t.arrowBounds.source=null,t.arrowBounds.target=null,t.arrowBounds["mid-source"]=null,t.arrowBounds["mid-target"]=null,t.labelPolygonCache={},t.labelPolygonPosKey=null}return this.emitAndNotify("bounds"),this},zs.boundingBoxAt=function(e){var t=this.nodes(),n=this.cy(),r=n.hasCompoundNodes(),i=n.collection();if(r&&(i=t.filter(function(e){return e.isParent()}),t=t.not(i)),ee(e)){var o=e;e=function(){return o}}n.startBatch(),t.forEach(function(t,n){return t._private.bbAtOldPos=e(t,n)}).silentPositions(e),r&&(i.dirtyCompoundBoundsCache(),i.dirtyBoundingBoxCache(),i.updateCompoundBounds(!0));var a=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}}(this.boundingBox({useCache:!1}));return t.silentPositions(function(e){return e._private.bbAtOldPos}),r&&(i.dirtyCompoundBoundsCache(),i.dirtyBoundingBoxCache(),i.updateCompoundBounds(!0)),n.endBatch(),a},Bs.boundingbox=Bs.bb=Bs.boundingBox,Bs.renderedBoundingbox=Bs.renderedBoundingBox;var al,sl,ll=zs;al=sl={};var ul=function(e){e.uppercaseName=ge(e.name),e.autoName="auto"+e.uppercaseName,e.labelName="label"+e.uppercaseName,e.outerName="outer"+e.uppercaseName,e.uppercaseOuterName=ge(e.outerName),al[e.name]=function(){var t=this[0],n=t._private,r=n.cy._private.styleEnabled;if(t){if(r){if(t.isParent())return t.updateCompoundBounds(),n[e.autoName]||0;var i=t.pstyle(e.name);return"label"===i.strValue?(t.recalculateRenderedStyle(),n.rstyle[e.labelName]||0):i.pfValue}return 1}},al["outer"+e.uppercaseName]=function(){var t=this[0],n=t._private.cy._private.styleEnabled;if(t){if(n){var r=t[e.name](),i=t.pstyle("border-position").value;return r+("center"===i?t.pstyle("border-width").pfValue:"outside"===i?2*t.pstyle("border-width").pfValue:0)+2*t.padding()}return 1}},al["rendered"+e.uppercaseName]=function(){var t=this[0];if(t)return t[e.name]()*this.cy().zoom()},al["rendered"+e.uppercaseOuterName]=function(){var t=this[0];if(t)return t[e.outerName]()*this.cy().zoom()}};ul({name:"width"}),ul({name:"height"}),sl.padding=function(){var e=this[0],t=e._private;return e.isParent()?(e.updateCompoundBounds(),void 0!==t.autoPadding?t.autoPadding:e.pstyle("padding").pfValue):e.pstyle("padding").pfValue},sl.paddedHeight=function(){var e=this[0];return e.height()+2*e.padding()},sl.paddedWidth=function(){var e=this[0];return e.width()+2*e.padding()};var cl=sl,hl={controlPoints:{get:function(e){return e.renderer().getControlPoints(e)},mult:!0},segmentPoints:{get:function(e){return e.renderer().getSegmentPoints(e)},mult:!0},sourceEndpoint:{get:function(e){return e.renderer().getSourceEndpoint(e)}},targetEndpoint:{get:function(e){return e.renderer().getTargetEndpoint(e)}},midpoint:{get:function(e){return e.renderer().getEdgeMidpoint(e)}}},dl=Object.keys(hl).reduce(function(e,t){var n=hl[t],r=function(e){return"rendered"+e[0].toUpperCase()+e.substr(1)}(t);return e[t]=function(){return function(e,t){if(e.isEdge()&&e.takesUpSpace())return t(e)}(this,n.get)},n.mult?e[r]=function(){return function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy(),r=n.pan(),i=n.zoom();return t(e).map(function(e){return Wt(e,i,r)})}}(this,n.get)}:e[r]=function(){return function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy();return Wt(t(e),n.zoom(),n.pan())}}(this,n.get)},e},{}),fl=Te({},Fs,ll,cl,dl),pl=function(e,t){this.recycle(e,t)};function gl(){return!1}function vl(){return!0}pl.prototype={instanceString:function(){return"event"},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=gl,null!=e&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?vl:gl):null!=e&&e.type?t=e:this.type=e,null!=t&&(this.originalEvent=t.originalEvent,this.type=null!=t.type?t.type:this.type,this.cy=t.cy,this.target=t.target,this.position=t.position,this.renderedPosition=t.renderedPosition,this.namespace=t.namespace,this.layout=t.layout),null!=this.cy&&null!=this.position&&null==this.renderedPosition){var n=this.position,r=this.cy.zoom(),i=this.cy.pan();this.renderedPosition={x:n.x*r+i.x,y:n.y*r+i.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=vl;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=vl;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=vl,this.stopPropagation()},isDefaultPrevented:gl,isPropagationStopped:gl,isImmediatePropagationStopped:gl};var yl=/^([^.]+)(\.(?:[^.]+))?$/,ml={qualifierCompare:function(e,t){return e===t},eventMatches:function(){return!0},addEventFields:function(){},callbackContext:function(e){return e},beforeEmit:function(){},afterEmit:function(){},bubble:function(){return!1},parent:function(){return null},context:null},bl=Object.keys(ml),xl={};function wl(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xl,t=arguments.length>1?arguments[1]:void 0,n=0;n<bl.length;n++){var r=bl[n];this[r]=e[r]||ml[r]}this.context=t||this.context,this.listeners=[],this.emitting=0}var El=wl.prototype,Tl=function(e,t,n,r,i,o,a){Q(r)&&(i=r,r=null),a&&(o=null==o?a:Te({},o,a));for(var s=J(n)?n:n.split(/\s+/),l=0;l<s.length;l++){var u=s[l];if(!ue(u)){var c=u.match(yl);if(c)if(!1===t(e,u,c[1],c[2]?c[2]:null,r,i,o))break}}},Cl=function(e,t){return e.addEventFields(e.context,t),new pl(t.type,t)},Ml=function(e,t,n){if("event"!==K(n))if(ee(n))t(e,Cl(e,n));else for(var r=J(n)?n:n.split(/\s+/),i=0;i<r.length;i++){var o=r[i];if(!ue(o)){var a=o.match(yl);if(a){var s=a[1],l=a[2]?a[2]:null;t(e,Cl(e,{type:s,namespace:l,target:e.context}))}}}else t(e,n)};El.on=El.addListener=function(e,t,n,r,i){return Tl(this,function(e,t,n,r,i,o,a){Q(o)&&e.listeners.push({event:t,callback:o,type:n,namespace:r,qualifier:i,conf:a})},e,t,n,r,i),this},El.one=function(e,t,n,r){return this.on(e,t,n,r,{one:!0})},El.removeListener=El.off=function(e,t,n,r){var i=this;0!==this.emitting&&(this.listeners=this.listeners.slice());for(var o=this.listeners,a=function(a){var s=o[a];Tl(i,function(t,n,r,i,l,u){if((s.type===r||"*"===e)&&(!i&&".*"!==s.namespace||s.namespace===i)&&(!l||t.qualifierCompare(s.qualifier,l))&&(!u||s.callback===u))return o.splice(a,1),!1},e,t,n,r)},s=o.length-1;s>=0;s--)a(s);return this},El.removeAllListeners=function(){return this.removeListener("*")},El.emit=El.trigger=function(e,t,n){var r=this.listeners,i=r.length;return this.emitting++,J(t)||(t=[t]),Ml(this,function(e,o){null!=n&&(r=[{event:o.event,type:o.type,namespace:o.namespace,callback:n}],i=r.length);for(var a=function(){var n=r[s];if(n.type===o.type&&(!n.namespace||n.namespace===o.namespace||".*"===n.namespace)&&e.eventMatches(e.context,n,o)){var i=[o];null!=t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.push(r)}}(i,t),e.beforeEmit(e.context,n,o),n.conf&&n.conf.one&&(e.listeners=e.listeners.filter(function(e){return e!==n}));var a=e.callbackContext(e.context,n,o),l=n.callback.apply(a,i);e.afterEmit(e.context,n,o),!1===l&&(o.stopPropagation(),o.preventDefault())}},s=0;s<i;s++)a();e.bubble(e.context)&&!o.isPropagationStopped()&&e.parent(e.context).emit(o,t)},e),this.emitting--,this};var Al={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&&oe(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e.cy(),t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e},beforeEmit:function(e,t){t.conf&&t.conf.once&&t.conf.onceCollection.removeListener(t.event,t.qualifier,t.callback)},bubble:function(){return!0},parent:function(e){return e.isChild()?e.parent():e.cy()}},Nl=function(e){return Z(e)?new ms(e):e},_l={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],n=t._private;n.emitter||(n.emitter=new wl(Al,t))}return this},emitter:function(){return this._private.emitter},on:function(e,t,n){for(var r=Nl(t),i=0;i<this.length;i++){this[i].emitter().on(e,r,n)}return this},removeListener:function(e,t,n){for(var r=Nl(t),i=0;i<this.length;i++){this[i].emitter().removeListener(e,r,n)}return this},removeAllListeners:function(){for(var e=0;e<this.length;e++){this[e].emitter().removeAllListeners()}return this},one:function(e,t,n){for(var r=Nl(t),i=0;i<this.length;i++){this[i].emitter().one(e,r,n)}return this},once:function(e,t,n){for(var r=Nl(t),i=0;i<this.length;i++){this[i].emitter().on(e,r,n,{once:!0,onceCollection:this})}},emit:function(e,t){for(var n=0;n<this.length;n++){this[n].emitter().emit(e,t)}return this},emitAndNotify:function(e,t){if(0!==this.length)return this.cy().notify(e,this),this.emit(e,t),this}};Da.eventAliasesOn(_l);var Sl={nodes:function(e){return this.filter(function(e){return e.isNode()}).filter(e)},edges:function(e){return this.filter(function(e){return e.isEdge()}).filter(e)},byGroup:function(){for(var e=this.spawn(),t=this.spawn(),n=0;n<this.length;n++){var r=this[n];r.isNode()?e.push(r):t.push(r)}return{nodes:e,edges:t}},filter:function(e,t){if(void 0===e)return this;if(Z(e)||ie(e))return new ms(e).filter(this);if(Q(e)){for(var n=this.spawn(),r=this,i=0;i<r.length;i++){var o=r[i];(t?e.apply(t,[o,i,r]):e(o,i,r))&&n.push(o)}return n}return this.spawn()},not:function(e){if(e){Z(e)&&(e=this.filter(e));for(var t=this.spawn(),n=0;n<this.length;n++){var r=this[n];e.has(r)||t.push(r)}return t}return this},absoluteComplement:function(){return this.cy().mutableElements().not(this)},intersect:function(e){if(Z(e)){var t=e;return this.filter(t)}for(var n=this.spawn(),r=e,i=this.length<e.length,o=i?this:r,a=i?r:this,s=0;s<o.length;s++){var l=o[s];a.has(l)&&n.push(l)}return n},xor:function(e){var t=this._private.cy;Z(e)&&(e=t.$(e));var n=this.spawn(),r=e,i=function(e,t){for(var r=0;r<e.length;r++){var i=e[r],o=i._private.data.id;t.hasElementWithId(o)||n.push(i)}};return i(this,r),i(r,this),n},diff:function(e){var t=this._private.cy;Z(e)&&(e=t.$(e));var n=this.spawn(),r=this.spawn(),i=this.spawn(),o=e,a=function(e,t,n){for(var r=0;r<e.length;r++){var o=e[r],a=o._private.data.id;t.hasElementWithId(a)?i.merge(o):n.push(o)}};return a(this,o,n),a(o,this,r),{left:n,right:r,both:i}},add:function(e){var t=this._private.cy;if(!e)return this;if(Z(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=this.spawnSelf(),i=0;i<e.length;i++){var o=e[i],a=!this.has(o);a&&r.push(o)}return r},merge:function(e){var t=this._private,n=t.cy;if(!e)return this;if(e&&Z(e)){var r=e;e=n.mutableElements().filter(r)}for(var i=t.map,o=0;o<e.length;o++){var a=e[o],s=a._private.data.id;if(!i.has(s)){var l=this.length++;this[l]=a,i.set(s,{ele:a,index:l})}}return this},unmergeAt:function(e){var t=this[e].id(),n=this._private.map;this[e]=void 0,n.delete(t);var r=e===this.length-1;if(this.length>1&&!r){var i=this.length-1,o=this[i],a=o._private.data.id;this[i]=void 0,this[e]=o,n.set(a,{ele:o,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&&Z(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r<e.length;r++)this.unmergeOne(e[r]);return this},unmergeBy:function(e){for(var t=this.length-1;t>=0;t--){e(this[t])&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],r=this,i=0;i<r.length;i++){var o=r[i],a=t?e.apply(t,[o,i,r]):e(o,i,r);n.push(a)}return n},reduce:function(e,t){for(var n=t,r=this,i=0;i<r.length;i++)n=e(n,r[i],i,r);return n},max:function(e,t){for(var n,r=-1/0,i=this,o=0;o<i.length;o++){var a=i[o],s=t?e.apply(t,[a,o,i]):e(a,o,i);s>r&&(r=s,n=a)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,i=this,o=0;o<i.length;o++){var a=i[o],s=t?e.apply(t,[a,o,i]):e(a,o,i);s<r&&(r=s,n=a)}return{value:r,ele:n}},withinBox:function(e){var t=this.cy(),n=t.renderer();t.styleEnabled()&&this.recalculateRenderedStyle();var r=null!=e.x2?e.x2:e.x1+e.w,i=null!=e.y2?e.y2:e.y1+e.h,o=cn({x1:Math.min(e.x1,r),x2:Math.max(e.x1,r),y1:Math.min(e.y1,i),y2:Math.max(e.y1,i)}),a=n.getAllInBox(o.x1,o.y1,o.x2,o.y2),s=this;return this.spawn(a.filter(function(e){return s.has(e)}))},hit:function(e,t){var n=this.cy(),r=n.renderer();return n.styleEnabled()&&this.recalculateRenderedStyle(),this.spawn(r.hitTestAt(e.x,e.y,this,t))},polygonIntersection:function(e){var t=this;t.cy().styleEnabled()&&this.recalculateRenderedStyle();for(var n=[],r=0;r<t.length;r++){var i=t[r];if(i.boundingBox(),i.isEdge()){var o=i._private.rscratch,a=i._private.rstyle,s=a.bezierPts||a.linePts||a.haystackPts;if(a.bezierPts&&o.allpts&&o.allpts.length>=6){var l=(o.allpts.length-2)/4,u=a.bezierPts.length/l;s=[{x:o.allpts[0],y:o.allpts[1]}];for(var c=0;c<l;c++){for(var h=0;h<u;h++)s.push(a.bezierPts[c*u+h]);s.push({x:o.allpts[4*c+4],y:o.allpts[4*c+5]})}}if((!s||s.length<2)&&null!=o.startX&&null!=o.startY&&null!=o.endX&&null!=o.endY&&(s=[{x:o.startX,y:o.startY},{x:o.endX,y:o.endY}]),s&&s.length>1){for(var d=!1,f=0;f<s.length-1&&!d;f++)Hn(s[f],s[f+1],e)&&(n.push(i),d=!0);if(d)continue}}else{var p=i._private.bodyBounds;if(p)if(Un([{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}],e)){n.push(i);continue}}for(var g=i.isEdge()?["main","source","target"]:["main"],v=!1,y=0;y<g.length&&!v;y++){var m=Ys(i,g[y]);m&&m.length&&Un(m,e)&&(n.push(i),v=!0)}}return this.spawn(n)}},kl=Sl;kl.u=kl["|"]=kl["+"]=kl.union=kl.or=kl.add,kl["\\"]=kl["!"]=kl["-"]=kl.difference=kl.relativeComplement=kl.subtract=kl.not,kl.n=kl["&"]=kl["."]=kl.and=kl.intersection=kl.intersect,kl["^"]=kl["(+)"]=kl["(-)"]=kl.symmetricDifference=kl.symdiff=kl.xor,kl.fnFilter=kl.filterFn=kl.stdFilter=kl.filter,kl.complement=kl.abscomp=kl.absoluteComplement;var Pl=function(e,t){var n=e.cy().hasCompoundNodes();function r(e){var t=e.pstyle("z-compound-depth");return"auto"===t.value?n?e.zDepth():0:"bottom"===t.value?-1:"top"===t.value?rt:0}var i=r(e)-r(t);if(0!==i)return i;function o(e){return"auto"===e.pstyle("z-index-compare").value&&e.isNode()?1:0}var a=o(e)-o(t);if(0!==a)return a;var s=e.pstyle("z-index").value-t.pstyle("z-index").value;return 0!==s?s:e.poolIndex()-t.poolIndex()},Il={forEach:function(e,t){if(Q(e))for(var n=this.length,r=0;r<n;r++){var i=this[r];if(!1===(t?e.apply(t,[i,r,this]):e(i,r,this)))break}return this},toArray:function(){for(var e=[],t=0;t<this.length;t++)e.push(this[t]);return e},slice:function(e,t){var n=[],r=this.length;null==t&&(t=r),null==e&&(e=0),e<0&&(e=r+e),t<0&&(t=r+t);for(var i=e;i>=0&&i<t&&i<r;i++)n.push(this[i]);return this.spawn(n)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return 0===this.length},nonempty:function(){return!this.empty()},sort:function(e){if(!Q(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(Pl)},zDepth:function(){var e=this[0];if(e){var t=e._private;if("nodes"===t.group){var n=t.data.parent?e.parents().size():0;return e.isParent()?n:rt-1}var r=t.source,i=t.target,o=r.zDepth(),a=i.zDepth();return Math.max(o,a,0)}}};Il.each=Il.forEach;var Ol;Ol="undefined",("undefined"==typeof Symbol?"undefined":p(Symbol))!=Ol&&p(Symbol.iterator)!=Ol&&(Il[Symbol.iterator]=function(){var e=this,t={value:void 0,done:!1},n=0,r=this.length;return c({next:function(){return n<r?t.value=e[n++]:(t.value=void 0,t.done=!0),t}},Symbol.iterator,function(){return this})});var Dl=gt({nodeDimensionsIncludeLabels:!1}),Ll={layoutDimensions:function(e){var t;if(e=Dl(e),this.takesUpSpace())if(e.nodeDimensionsIncludeLabels){var n=this.boundingBox();t={w:n.w,h:n.h}}else t={w:this.outerWidth(),h:this.outerHeight()};else t={w:0,h:0};return 0!==t.w&&0!==t.h||(t.w=t.h=1),t},layoutPositions:function(e,t,n){var r=this.nodes().filter(function(e){return!e.isParent()}),i=this.cy(),o=t.eles,a=function(e){return e.id()},s=he(n,a);e.emit({type:"layoutstart",layout:e}),e.animations=[];var l=t.spacingFactor&&1!==t.spacingFactor,u=function(){if(!l)return null;for(var e=cn(),t=0;t<r.length;t++){var n=r[t],i=s(n,t);dn(e,i.x,i.y)}return e}(),c=he(function(e,n){var r=s(e,n);l&&(r=function(e,t,n){var r=t.x1+t.w/2,i=t.y1+t.h/2;return{x:r+(n.x-r)*e,y:i+(n.y-i)*e}}(Math.abs(t.spacingFactor),u,r));return null!=t.transform&&(r=t.transform(e,r)),r},a);if(t.animate){for(var h=0;h<r.length;h++){var d=r[h],f=c(d,h);if(null==t.animateFilter||t.animateFilter(d,h)){var p=d.animation({position:f,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(p)}else d.position(f)}if(t.fit){var g=i.animation({fit:{boundingBox:o.boundingBoxAt(c),padding:t.padding},duration:t.animationDuration,easing:t.animationEasing});e.animations.push(g)}else if(void 0!==t.zoom&&void 0!==t.pan){var v=i.animation({zoom:t.zoom,pan:t.pan,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(v)}e.animations.forEach(function(e){return e.play()}),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),si.all(e.animations.map(function(e){return e.promise()})).then(function(){e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e})})}else r.positions(c),t.fit&&i.fit(t.eles,t.padding),null!=t.zoom&&i.zoom(t.zoom),t.pan&&i.pan(t.pan),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){return this.cy().makeLayout(Te({},e,{eles:this}))}};function Rl(e,t,n){var r,i=n._private,o=i.styleCache=i.styleCache||[];return null!=(r=o[e])?r:r=o[e]=t(n)}function Bl(e,t){return e=Ke(e),function(n){return Rl(e,t,n)}}function zl(e,t){e=Ke(e);var n=function(e){return t.call(e)};return function(){var t=this[0];if(t)return Rl(e,n,t)}}Ll.createLayout=Ll.makeLayout=Ll.layout;var Fl={recalculateRenderedStyle:function(e){var t=this.cy(),n=t.renderer(),r=t.styleEnabled();return n&&r&&n.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e,t=this.cy(),n=function(e){return e._private.styleCache=null};t.hasCompoundNodes()?((e=this.spawnSelf().merge(this.descendants()).merge(this.parents())).merge(e.connectedEdges()),e.forEach(n)):this.forEach(function(e){n(e),e.connectedEdges().forEach(n)});return this},updateStyle:function(e){var t=this._private.cy;if(!t.styleEnabled())return this;if(t.batching())return t._private.batchStyleEles.merge(this),this;var n=this;e=!(!e&&void 0!==e),t.hasCompoundNodes()&&(n=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var r=n;return e?r.emitAndNotify("style"):r.emit("style"),n.forEach(function(e){return e._private.styleDirty=!0}),this},cleanStyle:function(){var e=this.cy();if(e.styleEnabled())for(var t=0;t<this.length;t++){var n=this[t];n._private.styleDirty&&(n._private.styleDirty=!1,e.style().apply(n))}},parsedStyle:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n){n._private.styleDirty&&(n._private.styleDirty=!1,r.style().apply(n));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=!1,i=n.style();if(ee(e)){var o=e;i.applyBypass(this,o,r),this.emitAndNotify("style")}else if(Z(e)){if(void 0===t){var a=this[0];return a?i.getStylePropertyValue(a,e):void 0}i.applyBypass(this,e,t,r),this.emitAndNotify("style")}else if(void 0===e){var s=this[0];return s?i.getRawStyle(s):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,r=t.style(),i=this;if(void 0===e)for(var o=0;o<i.length;o++){var a=i[o];r.removeAllBypasses(a,n)}else{e=e.split(/\s+/);for(var s=0;s<i.length;s++){var l=i[s];r.removeBypasses(l,e,n)}}return this.emitAndNotify("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},effectiveOpacity:function(){var e=this.cy();if(!e.styleEnabled())return 1;var t=e.hasCompoundNodes(),n=this[0];if(n){var r=n._private,i=n.pstyle("opacity").value;if(!t)return i;var o=r.data.parent?n.parents():null;if(o)for(var a=0;a<o.length;a++){i*=o[a].pstyle("opacity").value}return i}},transparent:function(){if(!this.cy().styleEnabled())return!1;var e=this[0],t=e.cy().hasCompoundNodes();return e?t?0===e.effectiveOpacity():0===e.pstyle("opacity").value:void 0},backgrounding:function(){return!!this.cy().styleEnabled()&&!!this[0]._private.backgrounding}};function Vl(e,t){var n=e._private.data.parent?e.parents():null;if(n)for(var r=0;r<n.length;r++){if(!t(n[r]))return!1}return!0}function Gl(e){var t=e.ok,n=e.edgeOkViaNode||e.ok,r=e.parentOk||e.ok;return function(){var e=this.cy();if(!e.styleEnabled())return!0;var i=this[0],o=e.hasCompoundNodes();if(i){var a=i._private;if(!t(i))return!1;if(i.isNode())return!o||Vl(i,r);var s=a.source,l=a.target;return n(s)&&(!o||Vl(s,n))&&(s===l||n(l)&&(!o||Vl(l,n)))}}}var Yl=Bl("eleTakesUpSpace",function(e){return"element"===e.pstyle("display").value&&0!==e.width()&&(!e.isNode()||0!==e.height())});Fl.takesUpSpace=zl("takesUpSpace",Gl({ok:Yl}));var Xl=Bl("eleInteractive",function(e){return"yes"===e.pstyle("events").value&&"visible"===e.pstyle("visibility").value&&Yl(e)}),$l=Bl("parentInteractive",function(e){return"visible"===e.pstyle("visibility").value&&Yl(e)});Fl.interactive=zl("interactive",Gl({ok:Xl,parentOk:$l,edgeOkViaNode:Yl})),Fl.noninteractive=function(){var e=this[0];if(e)return!e.interactive()};var Ul=Bl("eleVisible",function(e){return"visible"===e.pstyle("visibility").value&&0!==e.pstyle("opacity").pfValue&&Yl(e)}),jl=Yl;Fl.visible=zl("visible",Gl({ok:Ul,edgeOkViaNode:jl})),Fl.hidden=function(){var e=this[0];if(e)return!e.visible()},Fl.isBundledBezier=zl("isBundledBezier",function(){return!!this.cy().styleEnabled()&&(!this.removed()&&"bezier"===this.pstyle("curve-style").value&&this.takesUpSpace())}),Fl.bypass=Fl.css=Fl.style,Fl.renderedCss=Fl.renderedStyle,Fl.removeBypass=Fl.removeCss=Fl.removeStyle,Fl.pstyle=Fl.parsedStyle;var Hl={};function Wl(e){return function(){var t=arguments,n=[];if(2===t.length){var r=t[0],i=t[1];this.on(e.event,r,i)}else if(1===t.length&&Q(t[0])){var o=t[0];this.on(e.event,o)}else if(0===t.length||1===t.length&&J(t[0])){for(var a=1===t.length?t[0]:null,s=0;s<this.length;s++){var l=this[s],u=!e.ableField||l._private[e.ableField],c=l._private[e.field]!=e.value;if(e.overrideAble){var h=e.overrideAble(l);if(void 0!==h&&(u=h,!h))return this}u&&(l._private[e.field]=e.value,c&&n.push(l))}var d=this.spawn(n);d.updateStyle(),d.emit(e.event),a&&d.emit(a)}return this}}function ql(e){Hl[e.field]=function(){var t=this[0];if(t){if(e.overrideField){var n=e.overrideField(t);if(void 0!==n)return n}return t._private[e.field]}},Hl[e.on]=Wl({event:e.on,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!0}),Hl[e.off]=Wl({event:e.off,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!1})}ql({field:"locked",overrideField:function(e){return!!e.cy().autolock()||void 0},on:"lock",off:"unlock"}),ql({field:"grabbable",overrideField:function(e){return!e.cy().autoungrabify()&&!e.pannable()&&void 0},on:"grabify",off:"ungrabify"}),ql({field:"selected",ableField:"selectable",overrideAble:function(e){return!e.cy().autounselectify()&&void 0},on:"select",off:"unselect"}),ql({field:"selectable",overrideField:function(e){return!e.cy().autounselectify()&&void 0},on:"selectify",off:"unselectify"}),Hl.deselect=Hl.unselect,Hl.grabbed=function(){var e=this[0];if(e)return e._private.grabbed},ql({field:"active",on:"activate",off:"unactivate"}),ql({field:"pannable",on:"panify",off:"unpanify"}),Hl.inactive=function(){var e=this[0];if(e)return!e._private.active};var Kl={},Zl=function(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r];if(i.isNode()){for(var o=!1,a=i.connectedEdges(),s=0;s<a.length;s++){var l=a[s],u=l.source(),c=l.target();if(e.noIncomingEdges&&c===i&&u!==i||e.noOutgoingEdges&&u===i&&c!==i){o=!0;break}}o||n.push(i)}}return this.spawn(n,!0).filter(t)}},Ql=function(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r];if(i.isNode())for(var o=i.connectedEdges(),a=0;a<o.length;a++){var s=o[a],l=s.source(),u=s.target();e.outgoing&&l===i?(n.push(s),n.push(u)):e.incoming&&u===i&&(n.push(s),n.push(l))}}return this.spawn(n,!0).filter(t)}},Jl=function(e){return function(t){for(var n=this,r=[],i={};;){var o=e.outgoing?n.outgoers():n.incomers();if(0===o.length)break;for(var a=!1,s=0;s<o.length;s++){var l=o[s],u=l.id();i[u]||(i[u]=!0,r.push(l),a=!0)}if(!a)break;n=o}return this.spawn(r,!0).filter(t)}};function eu(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r]._private[e.attr];i&&n.push(i)}return this.spawn(n,!0).filter(t)}}function tu(e){return function(t){var n=[],r=this._private.cy,i=e||{};Z(t)&&(t=r.$(t));for(var o=0;o<t.length;o++)for(var a=t[o]._private.edges,s=0;s<a.length;s++){var l=a[s],u=l._private.data,c=this.hasElementWithId(u.source)&&t.hasElementWithId(u.target),h=t.hasElementWithId(u.source)&&this.hasElementWithId(u.target);if(c||h){if(i.thisIsSrc||i.thisIsTgt){if(i.thisIsSrc&&!c)continue;if(i.thisIsTgt&&!h)continue}n.push(l)}}return this.spawn(n,!0)}}function nu(e){return e=Te({},{codirected:!1},e),function(t){for(var n=[],r=this.edges(),i=e,o=0;o<r.length;o++)for(var a=r[o]._private,s=a.source,l=s._private.data.id,u=a.data.target,c=s._private.edges,h=0;h<c.length;h++){var d=c[h],f=d._private.data,p=f.target,g=f.source,v=p===u&&g===l,y=l===p&&u===g;(i.codirected&&v||!i.codirected&&(v||y))&&n.push(d)}return this.spawn(n,!0).filter(t)}}Kl.clearTraversalCache=function(){for(var e=0;e<this.length;e++)this[e]._private.traversalCache=null},Te(Kl,{roots:Zl({noIncomingEdges:!0}),leaves:Zl({noOutgoingEdges:!0}),outgoers:Ts(Ql({outgoing:!0}),"outgoers"),successors:Jl({outgoing:!0}),incomers:Ts(Ql({incoming:!0}),"incomers"),predecessors:Jl({})}),Te(Kl,{neighborhood:Ts(function(e){for(var t=[],n=this.nodes(),r=0;r<n.length;r++)for(var i=n[r],o=i.connectedEdges(),a=0;a<o.length;a++){var s=o[a],l=s.source(),u=s.target(),c=i===l?u:l;c.length>0&&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)}}),Kl.neighbourhood=Kl.neighborhood,Kl.closedNeighbourhood=Kl.closedNeighborhood,Kl.openNeighbourhood=Kl.openNeighborhood,Te(Kl,{source:Ts(function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t},"source"),target:Ts(function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t},"target"),sources:eu({attr:"source"}),targets:eu({attr:"target"})}),Te(Kl,{edgesWith:Ts(tu(),"edgesWith"),edgesTo:Ts(tu({thisIsSrc:!0}),"edgesTo")}),Te(Kl,{connectedEdges:Ts(function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];if(r.isNode())for(var i=r._private.edges,o=0;o<i.length;o++){var a=i[o];t.push(a)}}return this.spawn(t,!0).filter(e)},"connectedEdges"),connectedNodes:Ts(function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];r.isEdge()&&(t.push(r.source()[0]),t.push(r.target()[0]))}return this.spawn(t,!0).filter(e)},"connectedNodes"),parallelEdges:Ts(nu(),"parallelEdges"),codirectedEdges:Ts(nu({codirected:!0}),"codirectedEdges")}),Te(Kl,{components:function(e){var t=this,n=t.cy(),r=n.collection(),i=null==e?t.nodes():e.nodes(),o=[];null!=e&&i.empty()&&(i=e.sources());var a=function(e,t){r.merge(e),i.unmerge(e),t.merge(e)};if(i.empty())return t.spawn();var s=function(){var e=n.collection();o.push(e);var r=i[0];a(r,e),t.bfs({directed:!1,roots:r,visit:function(t){return a(t,e)}}),e.forEach(function(n){n.connectedEdges().forEach(function(n){t.has(n)&&e.has(n.source())&&e.has(n.target())&&e.merge(n)})})};do{s()}while(i.length>0);return o},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),Kl.componentsOf=Kl.components;var ru=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 wt,o=!1;if(t){if(t.length>0&&ee(t[0])&&!oe(t[0])){o=!0;for(var a=[],s=new Tt,l=0,u=t.length;l<u;l++){var c=t[l];null==c.data&&(c.data={});var h=c.data;if(null==h.id)h.id=dt();else if(e.hasElementWithId(h.id)||s.has(h.id))continue;var d=new Ct(e,c,!1);a.push(d),s.add(h.id)}t=a}}else t=[];this.length=0;for(var f=0,p=t.length;f<p;f++){var g=t[f][0];if(null!=g){var v=g._private.data.id;n&&i.has(v)||(n&&i.set(v,{index:this.length,ele:g}),this[this.length]=g,this.length++)}}this._private={eles:this,cy:e,get map(){return null==this.lazyMap&&this.rebuildMap(),this.lazyMap},set map(e){this.lazyMap=e},rebuildMap:function(){for(var e=this.lazyMap=new wt,t=this.eles,n=0;n<t.length;n++){var r=t[n];e.set(r.id(),{index:n,ele:r})}}},n&&(this._private.map=i),o&&!r&&this.restore()}else lt("A collection must have a reference to the core")},iu=Ct.prototype=ru.prototype=Object.create(Array.prototype);iu.instanceString=function(){return"collection"},iu.spawn=function(e,t){return new ru(this.cy(),e,t)},iu.spawnSelf=function(){return this.spawn(this)},iu.cy=function(){return this._private.cy},iu.renderer=function(){return this._private.cy.renderer()},iu.element=function(){return this[0]},iu.collection=function(){return ae(this)?this:new ru(this._private.cy,[this])},iu.unique=function(){return new ru(this._private.cy,this,!0)},iu.hasElementWithId=function(e){return e=""+e,this._private.map.has(e)},iu.getElementById=function(e){e=""+e;var t=this._private.cy,n=this._private.map.get(e);return n?n.ele:new ru(t)},iu.$id=iu.getElementById,iu.poolIndex=function(){var e=this._private.cy._private.elements,t=this[0]._private.data.id;return e._private.map.get(t).index},iu.indexOf=function(e){var t=e[0]._private.data.id;return this._private.map.get(t).index},iu.indexOfId=function(e){return e=""+e,this._private.map.get(e).index},iu.json=function(e){var t=this.element(),n=this.cy();if(null==t&&e)return this;if(null!=t){var r=t._private;if(ee(e)){if(n.startBatch(),e.data){t.data(e.data);var i=r.data;if(t.isEdge()){var o=!1,a={},s=e.data.source,l=e.data.target;null!=s&&s!=i.source&&(a.source=""+s,o=!0),null!=l&&l!=i.target&&(a.target=""+l,o=!0),o&&(t=t.move(a))}else{var u="parent"in e.data,c=e.data.parent;!u||null==c&&null==i.parent||c==i.parent||(void 0===c&&(c=null),null!=c&&(c=""+c),t=t.move({parent:c}))}}e.position&&t.position(e.position);var h=function(n,i,o){var a=e[n];null!=a&&a!==r[n]&&(a?t[i]():t[o]())};return h("removed","remove","restore"),h("selected","select","unselect"),h("selectable","selectify","unselectify"),h("locked","lock","unlock"),h("grabbable","grabify","ungrabify"),h("pannable","panify","unpanify"),null!=e.classes&&t.classes(e.classes),n.endBatch(),this}if(void 0===e){var d={data:ht(r.data),position:ht(r.position),group:r.group,removed:r.removed,selected:r.selected,selectable:r.selectable,locked:r.locked,grabbable:r.grabbable,pannable:r.pannable,classes:(null,"")},f=0;return r.classes.forEach(function(e){return d.classes+=0===f++?e:" "+e}),d}}},iu.jsons=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t].json();e.push(n)}return e},iu.clone=function(){for(var e=this.cy(),t=[],n=0;n<this.length;n++){var r=this[n].json(),i=new Ct(e,r,!1);t.push(i)}return new ru(e,t)},iu.copy=iu.clone,iu.restore=function(){for(var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this,o=i.cy(),a=o._private,s=[],l=[],u=0,c=i.length;u<c;u++){var h=i[u];r&&!h.removed()||(h.isNode()?s.push(h):l.push(h))}e=s.concat(l);var d=function(){e.splice(t,1),t--};for(t=0;t<e.length;t++){var f=e[t],p=f._private,g=p.data;if(f.clearTraversalCache(),r||p.removed)if(void 0===g.id)g.id=dt();else if(te(g.id))g.id=""+g.id;else{if(ue(g.id)||!Z(g.id)){lt("Can not create element with invalid string ID `"+g.id+"`"),d();continue}if(o.hasElementWithId(g.id)){lt("Can not create second element with ID `"+g.id+"`"),d();continue}}else;var v=g.id;if(f.isNode()){var y=p.position;null==y.x&&(y.x=0),null==y.y&&(y.y=0)}if(f.isEdge()){for(var m=f,b=["source","target"],x=b.length,w=!1,E=0;E<x;E++){var T=b[E],C=g[T];te(C)&&(C=g[T]=""+g[T]),null==C||""===C?(lt("Can not create edge `"+v+"` with unspecified "+T),w=!0):o.hasElementWithId(C)||(lt("Can not create edge `"+v+"` with nonexistent "+T+" `"+C+"`"),w=!0)}if(w){d();continue}var M=o.getElementById(g.source),A=o.getElementById(g.target);M.same(A)?M._private.edges.push(m):(M._private.edges.push(m),A._private.edges.push(m)),m._private.source=M,m._private.target=A}p.map=new wt,p.map.set(v,{ele:f,index:0}),p.removed=!1,r&&o.addToPool(f)}for(var N=0;N<s.length;N++){var _=s[N],S=_._private.data;te(S.parent)&&(S.parent=""+S.parent);var k=S.parent;if(null!=k||_._private.parent){var P=_._private.parent?o.collection().merge(_._private.parent):o.getElementById(k);if(P.empty())S.parent=void 0;else if(P[0].removed())ct("Node added with missing parent, reference to parent removed"),S.parent=void 0,_._private.parent=null;else{for(var I=!1,O=P;!O.empty();){if(_.same(O)){I=!0,S.parent=void 0;break}O=O.parent()}I||(P[0]._private.children.push(_),_._private.parent=P[0],a.hasCompoundNodes=!0)}}}if(e.length>0){for(var D=e.length===i.length?i:new ru(o,e),L=0;L<D.length;L++){var R=D[L];R.isNode()||(R.parallelEdges().clearTraversalCache(),R.source().clearTraversalCache(),R.target().clearTraversalCache())}(a.hasCompoundNodes?o.collection().merge(D).merge(D.connectedNodes()).merge(D.parent()):D).dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(n),n?D.emitAndNotify("add"):r&&D.emit("add")}return i},iu.removed=function(){var e=this[0];return e&&e._private.removed},iu.inside=function(){var e=this[0];return e&&!e._private.removed},iu.remove=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this,r=[],i=new Tt,o=n._private.cy;function a(e){var n=i.has(e.id());t&&e.removed()||n||(i.add(e.id()),e.isNode()?(r.push(e),function(e){for(var t=e._private.edges,n=0;n<t.length;n++)a(t[n])}(e),function(e){for(var t=e._private.children,n=0;n<t.length;n++)a(t[n])}(e)):r.unshift(e))}for(var s=0,l=n.length;s<l;s++){a(n[s])}function u(e,t){var n=e._private.edges;vt(n,t),e.clearTraversalCache()}function c(e){e.clearTraversalCache()}var h=[];function d(e,t){t=t[0];var n=(e=e[0])._private.children,r=e.id();vt(n,t),t._private.parent=null,h.ids.has(r)||(h.ids.add(r),h.push(e))}h.ids=new Tt,n.dirtyCompoundBoundsCache(),t&&o.removeFromPool(r);for(var f=0;f<r.length;f++){var p=r[f];if(p.isEdge()){var g=p.source()[0],v=p.target()[0];u(g,p),u(v,p);for(var y=p.parallelEdges(),m=0;m<y.length;m++){var b=y[m];c(b),b.isBundledBezier()&&b.dirtyBoundingBoxCache()}}else{var x=p.parent();0!==x.length&&d(x,p)}t&&(p._private.removed=!0)}var w=o._private.elements;o._private.hasCompoundNodes=!1;for(var E=0;E<w.length;E++){if(w[E].isParent()){o._private.hasCompoundNodes=!0;break}}var T=new ru(this.cy(),r);T.size()>0&&(e?T.emitAndNotify("remove"):t&&T.emit("remove"));for(var C=0;C<h.length;C++){var M=h[C];t&&M.removed()||M.updateStyle()}return T},iu.move=function(e){var t=this._private.cy,n=this,r=!1,i=!1,o=function(e){return null==e?e:""+e};if(void 0!==e.source||void 0!==e.target){var a=o(e.source),s=o(e.target),l=null!=a&&t.hasElementWithId(a),u=null!=s&&t.hasElementWithId(s);(l||u)&&(t.batch(function(){n.remove(r,i),n.emitAndNotify("moveout");for(var e=0;e<n.length;e++){var t=n[e],o=t._private.data;t.isEdge()&&(l&&(o.source=a),u&&(o.target=s))}n.restore(r,i)}),n.emitAndNotify("move"))}else if(void 0!==e.parent){var c=o(e.parent);if(null===c||t.hasElementWithId(c)){var h=null===c?void 0:c;t.batch(function(){var e=n.remove(r,i);e.emitAndNotify("moveout");for(var t=0;t<n.length;t++){var o=n[t],a=o._private.data;o.isNode()&&(a.parent=h)}e.restore(r,i)}),n.emitAndNotify("move")}}return this},[ei,La,Ra,xs,Cs,Ps,Is,fl,_l,Sl,{isNode:function(){return"nodes"===this.group()},isEdge:function(){return"edges"===this.group()},isLoop:function(){return this.isEdge()&&this.source()[0]===this.target()[0]},isSimple:function(){return this.isEdge()&&this.source()[0]!==this.target()[0]},group:function(){var e=this[0];if(e)return e._private.group}},Il,Ll,Fl,Hl,Kl].forEach(function(e){Te(iu,e)});var ou={add:function(e){var t,n=this;if(ie(e)){var r=e;if(r._private.cy===n)t=r.restore();else{for(var i=[],o=0;o<r.length;o++){var a=r[o];i.push(a.json())}t=new ru(n,i)}}else if(J(e)){t=new ru(n,e)}else if(ee(e)&&(J(e.nodes)||J(e.edges))){for(var s=e,l=[],u=["nodes","edges"],c=0,h=u.length;c<h;c++){var d=u[c],f=s[d];if(J(f))for(var p=0,g=f.length;p<g;p++){var v=Te({group:d},f[p]);l.push(v)}}t=new ru(n,l)}else{t=new Ct(n,e).collection()}return t},remove:function(e){if(ie(e));else if(Z(e)){var t=e;e=this.$(t)}return e.remove()}},au=Math.cbrt||function(e){return e<0?-Math.pow(-e,1/3):Math.pow(e,1/3)};
|
|
8
|
+
/*! Bezier curve function generator. Copyright 2014-2026 Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License
|
|
9
|
+
* https://github.com/gre/bezier-easing */function su(e,t,n,r){if(4!==arguments.length)return!1;for(var i=0;i<4;++i)if("number"!=typeof arguments[i]||isNaN(arguments[i])||!isFinite(arguments[i]))return!1;e=Math.min(e,1),n=Math.min(n,1),e=Math.max(e,0),n=Math.max(n,0);var o=e===t&&n===r,a=(3*e-3*n+1)/2,s=n-2*e,l=e,u=3*t-3*r+1,c=3*(r-2*t),h=3*t,d=function(e){if(o)return e;if(e<=0)return 0;if(e>=1)return 1;var t=function(e,t,n,r){var i,o=1/Math.max(r,Math.sqrt(e)),a=e*o,s=a*o,l=r*o,u=n*s,c=l*l+u,h=-l*(l*l+1.5*u)-t*a*s,d=h*h-c*c*c;if(0===c||d>1e-12*h*h){var f=-au(h<0?h-Math.sqrt(d):h+Math.sqrt(d));i=f+c/f||0}else{var p=Math.sqrt(c);i=2*p*Math.cos(Math.acos(Math.max(-1,Math.min(1,-h/(c*p))))/3)}return Math.min(1,a/(i+l))}(e,a,s,l);return((u*t+c)*t+h)*t};d.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var f="generateBezier("+[e,t,n,r]+")";return d.toString=function(){return f},d}
|
|
10
|
+
/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var lu=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,n,r){var i={x:t.x+r.dx*n,v:t.v+r.dv*n,tension:t.tension,friction:t.friction};return{dx:i.v,dv:e(i)}}function n(n,r){var i={dx:n.v,dv:e(n)},o=t(n,.5*r,i),a=t(n,.5*r,o),s=t(n,r,a),l=1/6*(i.dx+2*(o.dx+a.dx)+s.dx),u=1/6*(i.dv+2*(o.dv+a.dv)+s.dv);return n.x=n.x+l*r,n.v=n.v+u*r,n}return function e(t,r,i){var o,a,s,l={x:-1,v:0,tension:null,friction:null},u=[0],c=0,h=1e-4;for(t=parseFloat(t)||500,r=parseFloat(r)||20,i=i||null,l.tension=t,l.friction=r,a=(o=null!==i)?(c=e(t,r))/i*.016:.016;s=n(s||l,a),u.push(1+s.x),c+=16,Math.abs(s.x)>h&&Math.abs(s.v)>h;);return o?function(e){return u[e*(u.length-1)|0]}:c}}(),uu=function(e,t,n,r){var i=su(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},cu={linear:function(e,t,n){return e+(t-e)*n},ease:uu(.25,.1,.25,1),"ease-in":uu(.42,0,1,1),"ease-out":uu(0,0,.58,1),"ease-in-out":uu(.42,0,.58,1),"ease-in-sine":uu(.47,0,.745,.715),"ease-out-sine":uu(.39,.575,.565,1),"ease-in-out-sine":uu(.445,.05,.55,.95),"ease-in-quad":uu(.55,.085,.68,.53),"ease-out-quad":uu(.25,.46,.45,.94),"ease-in-out-quad":uu(.455,.03,.515,.955),"ease-in-cubic":uu(.55,.055,.675,.19),"ease-out-cubic":uu(.215,.61,.355,1),"ease-in-out-cubic":uu(.645,.045,.355,1),"ease-in-quart":uu(.895,.03,.685,.22),"ease-out-quart":uu(.165,.84,.44,1),"ease-in-out-quart":uu(.77,0,.175,1),"ease-in-quint":uu(.755,.05,.855,.06),"ease-out-quint":uu(.23,1,.32,1),"ease-in-out-quint":uu(.86,0,.07,1),"ease-in-expo":uu(.95,.05,.795,.035),"ease-out-expo":uu(.19,1,.22,1),"ease-in-out-expo":uu(1,0,0,1),"ease-in-circ":uu(.6,.04,.98,.335),"ease-out-circ":uu(.075,.82,.165,1),"ease-in-out-circ":uu(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return cu.linear;var r=lu(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":uu};function hu(e,t,n,r,i){if(1===r)return n;if(t===n)return n;var o=i(t,n,r);return null==e||((e.roundValue||e.color)&&(o=Math.round(o)),void 0!==e.min&&(o=Math.max(o,e.min)),void 0!==e.max&&(o=Math.min(o,e.max))),o}function du(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function fu(e,t,n,r,i){var o=null!=i?i.type:null;n<0?n=0:n>1&&(n=1);var a=du(e,i),s=du(t,i);if(te(a)&&te(s))return hu(o,a,s,n,r);if(J(a)&&J(s)){for(var l=[],u=0;u<s.length;u++){var c=a[u],h=s[u];if(null!=c&&null!=h){var d=hu(o,c,h,n,r);l.push(d)}else l.push(h)}return l}}function pu(e,t,n,r){var i=!r,o=e._private,a=t._private,s=a.easing,l=a.startTime,u=(r?e:e.cy()).style();if(!a.easingImpl)if(null==s)a.easingImpl=cu.linear;else{var c,h,d;if(Z(s))c=u.parse("transition-timing-function",s).value;else c=s;Z(c)?(h=c,d=[]):(h=c[1],d=c.slice(2).map(function(e){return+e})),d.length>0?("spring"===h&&d.push(a.duration),a.easingImpl=cu[h].apply(null,d)):a.easingImpl=cu[h]}var f,p=a.easingImpl;if(f=0===a.duration?1:(n-l)/a.duration,a.applying&&(f=a.progress),f<0?f=0:f>1&&(f=1),null==a.delay){var g=a.startPosition,v=a.position;if(v&&i&&!e.locked()){var y={};gu(g.x,v.x)&&(y.x=fu(g.x,v.x,f,p)),gu(g.y,v.y)&&(y.y=fu(g.y,v.y,f,p)),e.position(y)}var m=a.startPan,b=a.pan,x=o.pan,w=null!=b&&r;w&&(gu(m.x,b.x)&&(x.x=fu(m.x,b.x,f,p)),gu(m.y,b.y)&&(x.y=fu(m.y,b.y,f,p)),e.emit("pan"));var E=a.startZoom,T=a.zoom,C=null!=T&&r;C&&(gu(E,T)&&(o.zoom=un(o.minZoom,fu(E,T,f,p),o.maxZoom)),e.emit("zoom")),(w||C)&&e.emit("viewport");var M=a.style;if(M&&M.length>0&&i){for(var A=0;A<M.length;A++){var N=M[A],_=N.name,S=N,k=a.startStyle[_],P=fu(k,S,f,p,u.properties[k.name]);u.overrideBypass(e,_,P)}e.emit("style")}}return a.progress=f,f}function gu(e,t){return null!=e&&null!=t&&(!(!te(e)||!te(t))||!(!e||!t))}function vu(e,t,n,r){var i=t._private;i.started=!0,i.startTime=n-i.progress*i.duration}function yu(e,t){var n=t._private.aniEles,r=[];function i(t,n){var i=t._private,o=i.animation.current,a=i.animation.queue,s=!1;if(0===o.length){var l=a.shift();l&&o.push(l)}for(var u=function(e){for(var t=e.length-1;t>=0;t--){(0,e[t])()}e.splice(0,e.length)},c=o.length-1;c>=0;c--){var h=o[c],d=h._private;d.stopped?(o.splice(c,1),d.hooked=!1,d.playing=!1,d.started=!1,u(d.frames)):(d.playing||d.applying)&&(d.playing&&d.applying&&(d.applying=!1),d.started||vu(0,h,e),pu(t,h,e,n),d.applying&&(d.applying=!1),u(d.frames),null!=d.step&&d.step(e),h.completed()&&(o.splice(c,1),d.hooked=!1,d.playing=!1,d.started=!1,u(d.completes)),s=!0)}return n||0!==o.length||0!==a.length||r.push(t),s}for(var o=!1,a=0;a<n.length;a++){var s=i(n[a]);o=o||s}var l=i(t,!0);(o||l)&&(n.length>0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var mu={animate:Da.animate(),animation:Da.animation(),animated:Da.animated(),clearQueue:Da.clearQueue(),delay:Da.delay(),delayAnimation:Da.delayAnimation(),stop:Da.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){yu(n,e)},t.beforeRenderPriorities.animations):function t(){e._private.animationsRunning&&Ve(function(n){yu(n,e),t()})}()}}},bu={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&&oe(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}},xu=function(e){return Z(e)?new ms(e):e},wu={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new wl(bu,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,xu(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,xu(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,xu(t),n),this},once:function(e,t,n){return this.emitter().one(e,xu(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}};Da.eventAliasesOn(wu);var Eu={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)}};Eu.jpeg=Eu.jpg;var Tu={layout:function(e){var t=this;if(null!=e)if(null!=e.name){var n=e.name,r=t.extension("layout",n);if(null!=r){var i;i=Z(e.eles)?t.$(e.eles):null!=e.eles?e.eles:t.$();var o=new r(Te({},e,{cy:t,eles:i}));return o}lt("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?")}else lt("A `name` must be specified to make a layout");else lt("Layout options must be specified to make a layout")}};Tu.createLayout=Tu.makeLayout=Tu.layout;var Cu={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;r<n.length;r++){var i=n[r],o=e[i];t.getElementById(i).data(o)}})}},Mu=gt({hideEdgesOnViewport:!1,textureOnViewport:!1,motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1,debug:!1,showFps:!1,webgl:!1,webglDebug:!1,webglDebugShowAtlases:!1,webglTexSize:2048,webglTexRows:36,webglTexRowsNodes:18,webglBatchSize:2048,webglTexPerBatch:14,webglBgColor:[255,255,255]}),Au={renderTo:function(e,t,n,r){return this._private.renderer.renderTo(e,t,n,r),this},renderer:function(){return this._private.renderer},forceRender:function(){return this.notify("draw"),this},resize:function(){return this.invalidateSize(),this.emitAndNotify("resize"),this},initRenderer:function(e){var t=this,n=t.extension("renderer",e.name);if(null!=n){void 0!==e.wheelSensitivity&&ct("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");var r=Mu(e);r.cy=t,t._private.renderer=new n(r),this.notify("init")}else lt("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"))},destroyRenderer:function(){var e=this;e.notify("destroy");var t=e.container();if(t)for(t._cyreg=null;t.childNodes.length>0;)t.removeChild(t.childNodes[0]);e._private.renderer=null,e.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)}};Au.invalidateDimensions=Au.resize;var Nu={collection:function(e,t){return Z(e)?this.$(e):ie(e)?e.collection():J(e)?(t||(t={}),new ru(this,e,t.unique,t.removed)):new ru(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}};Nu.elements=Nu.filter=Nu.$;var _u={},Su="t";_u.apply=function(e){for(var t=this,n=t._private.cy.collection(),r=0;r<e.length;r++){var i=e[r],o=t.getContextMeta(i);if(!o.empty){var a=t.getContextStyle(o),s=t.applyContextStyle(o,a,i);i._private.appliedInitStyle?t.updateTransitions(i,s.diffProps):i._private.appliedInitStyle=!0,t.updateStyleHints(i)&&n.push(i)}}return n},_u.getPropertiesDiff=function(e,t){var n=this,r=n._private.propDiffs=n._private.propDiffs||{},i=e+"-"+t,o=r[i];if(o)return o;for(var a=[],s={},l=0;l<n.length;l++){var u=n[l],c=e[l]===Su,h=t[l]===Su,d=c!==h,f=u.mappedProperties.length>0;if(d||h&&f){var p=void 0;d&&f||d?p=u.properties:f&&(p=u.mappedProperties);for(var g=0;g<p.length;g++){for(var v=p[g],y=v.name,m=!1,b=l+1;b<n.length;b++){var x=n[b];if(t[b]===Su&&(m=null!=x.properties[v.name]))break}s[y]||m||(s[y]=!0,a.push(y))}}}return r[i]=a,a},_u.getContextMeta=function(e){for(var t,n=this,r="",i=e._private.styleCxtKey||"",o=0;o<n.length;o++){var a=n[o];r+=a.selector&&a.selector.matches(e)?Su:"f"}return t=n.getPropertiesDiff(i,r),e._private.styleCxtKey=r,{key:r,diffPropNames:t,empty:0===t.length}},_u.getContextStyle=function(e){var t=e.key,n=this._private.contextStyles=this._private.contextStyles||{};if(n[t])return n[t];for(var r={_private:{key:t}},i=0;i<this.length;i++){var o=this[i];if(t[i]===Su)for(var a=0;a<o.properties.length;a++){var s=o.properties[a];r[s.name]=s}}return n[t]=r,r},_u.applyContextStyle=function(e,t,n){for(var r=e.diffPropNames,i={},o=this.types,a=0;a<r.length;a++){var s=r[a],l=t[s],u=n.pstyle(s);if(!l){if(!u)continue;l=u.bypass?{name:s,deleteBypassed:!0}:{name:s,delete:!0}}if(u!==l){if(l.mapped===o.fn&&null!=u&&null!=u.mapping&&u.mapping.value===l.value){var c=u.mapping;if((c.fnValue=l.value(n))===c.prevFnValue)continue}var h=i[s]={prev:u};this.applyParsedProperty(n,l),h.next=n.pstyle(s),h.next&&h.next.bypass&&(h.next=h.next.bypassed)}}return{diffProps:i}},_u.updateStyleHints=function(e){var t=e._private,n=this,r=n.propertyGroupNames,i=n.propertyGroupKeys,o=function(e,t,r){return n.getPropertiesHash(e,t,r)},a=t.styleKey;if(e.removed())return!1;var s="nodes"===t.group,l=e._private.style;r=Object.keys(l);for(var u=0;u<i.length;u++){var c=i[u];t.styleKeys[c]=[Ye,Xe]}for(var h=function(e,n){return t.styleKeys[n][0]=Ue(e,t.styleKeys[n][0])},d=function(e,n){return t.styleKeys[n][1]=je(e,t.styleKeys[n][1])},f=function(e,t){h(e,t),d(e,t)},p=function(e,t){for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);h(r,t),d(r,t)}},g=function(e){return-128<e&&e<128&&Math.floor(e)!==e?2e9-(1024*e|0):e},v=0;v<r.length;v++){var y=r[v],m=l[y];if(null!=m){var b=this.properties[y],x=b.type,w=b.groupKey,E=void 0;null!=b.hashOverride?E=b.hashOverride(e,m):null!=m.pfValue&&(E=m.pfValue);var T=null==b.enums?m.value:null,C=null!=E,M=C||null!=T,A=m.units;if(x.number&&M&&!x.multiple)f(g(C?E:T),w),C||null==A||p(A,w);else p(m.strValue,w)}}for(var N,_,S=[Ye,Xe],k=0;k<i.length;k++){var P=i[k],I=t.styleKeys[P];S[0]=Ue(I[0],S[0]),S[1]=je(I[1],S[1])}t.styleKey=(N=S[0],_=S[1],2097152*N+_);var O=t.styleKeys;t.labelDimsKey=He(O.labelDimensions);var D=o(e,["label"],O.labelDimensions);if(t.labelKey=He(D),t.labelStyleKey=He(We(O.commonLabel,D)),!s){var L=o(e,["source-label"],O.labelDimensions);t.sourceLabelKey=He(L),t.sourceLabelStyleKey=He(We(O.commonLabel,L));var R=o(e,["target-label"],O.labelDimensions);t.targetLabelKey=He(R),t.targetLabelStyleKey=He(We(O.commonLabel,R))}if(s){var B=t.styleKeys,z=B.nodeBody,F=B.nodeBorder,V=B.nodeOutline,G=B.backgroundImage,Y=B.compound,X=B.pie,$=B.stripe,U=[z,F,V,G,Y,X,$].filter(function(e){return null!=e}).reduce(We,[Ye,Xe]);t.nodeKey=He(U),t.hasPie=null!=X&&X[0]!==Ye&&X[1]!==Xe,t.hasStripe=null!=$&&$[0]!==Ye&&$[1]!==Xe}return a!==t.styleKey},_u.clearStyleHints=function(e){var t=e._private;t.styleCxtKey="",t.styleKeys={},t.styleKey=null,t.labelKey=null,t.labelStyleKey=null,t.sourceLabelKey=null,t.sourceLabelStyleKey=null,t.targetLabelKey=null,t.targetLabelStyleKey=null,t.nodeKey=null,t.hasPie=null,t.hasStripe=null},_u.applyParsedProperty=function(e,t){var n,r=this,i=t,o=e._private.style,a=r.types,s=r.properties[i.name].type,l=i.bypass,u=o[i.name],c=u&&u.bypass,h=e._private,d="mapping",f=function(e){return null==e?null:null!=e.pfValue?e.pfValue:e.value},p=function(){var t=f(u),n=f(i);r.checkTriggers(e,i.name,t,n)};if("curve-style"===t.name&&e.isEdge()&&("bezier"!==t.value&&e.isLoop()||"haystack"===t.value&&(e.source().isParent()||e.target().isParent()))&&(i=t=this.parse(t.name,"bezier",l)),i.delete)return o[i.name]=void 0,p(),!0;if(i.deleteBypassed)return u?!!u.bypass&&(u.bypassed=void 0,p(),!0):(p(),!0);if(i.deleteBypass)return u?!!u.bypass&&(o[i.name]=u.bypassed,p(),!0):(p(),!0);var g=function(){ct("Do not assign mappings to elements without corresponding data (i.e. ele `"+e.id()+"` has no mapping for property `"+i.name+"` with data field `"+i.field+"`); try a `["+i.field+"]` selector to limit scope to elements with `"+i.field+"` defined")};switch(i.mapped){case a.mapData:for(var v,y=i.field.split("."),m=h.data,b=0;b<y.length&&m;b++){m=m[y[b]]}if(null==m)return g(),!1;if(!te(m))return ct("Do not use continuous mappers without specifying numeric data (i.e. `"+i.field+": "+m+"` for `"+e.id()+"` is non-numeric)"),!1;var x=i.fieldMax-i.fieldMin;if((v=0===x?0:(m-i.fieldMin)/x)<0?v=0:v>1&&(v=1),s.color){var w=i.valueMin[0],E=i.valueMax[0],T=i.valueMin[1],C=i.valueMax[1],M=i.valueMin[2],A=i.valueMax[2],N=null==i.valueMin[3]?1:i.valueMin[3],_=null==i.valueMax[3]?1:i.valueMax[3],S=[Math.round(w+(E-w)*v),Math.round(T+(C-T)*v),Math.round(M+(A-M)*v),N+(_-N)*v];n={bypass:i.bypass,name:i.name,value:S,strValue:"rgba("+S[0]+", "+S[1]+", "+S[2]+", "+S[3]+")"}}else{if(!s.number)return!1;var k=i.valueMin+(i.valueMax-i.valueMin)*v;n=this.parse(i.name,k,i.bypass,d)}if(!n)return g(),!1;n.mapping=i,i=n;break;case a.data:for(var P=i.field.split("."),I=h.data,O=0;O<P.length&&I;O++){I=I[P[O]]}if(null!=I&&(n=this.parse(i.name,I,i.bypass,d)),!n)return g(),!1;n.mapping=i,i=n;break;case a.fn:var D=i.value,L=null!=i.fnValue?i.fnValue:D(e);if(i.prevFnValue=L,null==L)return ct("Custom function mappers may not return null (i.e. `"+i.name+"` for ele `"+e.id()+"` is null)"),!1;if(!(n=this.parse(i.name,L,i.bypass,d)))return ct("Custom function mappers may not return invalid values for the property type (i.e. `"+i.name+"` for ele `"+e.id()+"` is invalid)"),!1;n.mapping=ht(i),i=n;break;case void 0:break;default:return!1}return l?(i.bypassed=c?u.bypassed:u,o[i.name]=i):c?u.bypassed=i:o[i.name]=i,p(),!0},_u.cleanElements=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(this.clearStyleHints(r),r.dirtyCompoundBoundsCache(),r.dirtyBoundingBoxCache(),t)for(var i=r._private.style,o=Object.keys(i),a=0;a<o.length;a++){var s=o[a],l=i[s];null!=l&&(l.bypass?l.bypassed=null:i[s]=null)}else r._private.style={}}},_u.update=function(){this._private.cy.mutableElements().updateStyle()},_u.updateTransitions=function(e,t){var n=this,r=e._private,i=e.pstyle("transition-property").value,o=e.pstyle("transition-duration").pfValue,a=e.pstyle("transition-delay").pfValue;if(i.length>0&&o>0){for(var s={},l=!1,u=0;u<i.length;u++){var c=i[u],h=e.pstyle(c),d=t[c];if(d){var f=d.prev,p=null!=d.next?d.next:h,g=!1,v=void 0,y=1e-6;f&&(te(f.pfValue)&&te(p.pfValue)?(g=p.pfValue-f.pfValue,v=f.pfValue+y*g):te(f.value)&&te(p.value)?(g=p.value-f.value,v=f.value+y*g):J(f.value)&&J(p.value)&&(g=f.value[0]!==p.value[0]||f.value[1]!==p.value[1]||f.value[2]!==p.value[2],v=f.strValue),g&&(s[c]=p.strValue,this.applyBypass(e,c,v),l=!0))}}if(!l)return;r.transitioning=!0,new si(function(t){a>0?e.delayAnimation(a).play().promise().then(t):t()}).then(function(){return e.animation({style:s,duration:o,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)},_u.checkTrigger=function(e,t,n,r,i,o){var a=this.properties[t],s=i(a);e.removed()||null!=s&&s(n,r,e)&&o(a)},_u.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)})},_u.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()})},_u.checkConnectedEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfConnectedEdges},function(t){e.connectedEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},_u.checkParallelEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfParallelEdges},function(t){e.parallelEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},_u.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r),this.checkConnectedEdgesBoundsTrigger(e,t,n,r),this.checkParallelEdgesBoundsTrigger(e,t,n,r)};var ku={applyBypass:function(e,t,n,r){var i=[];if("*"===t||"**"===t){if(void 0!==n)for(var o=0;o<this.properties.length;o++){var a=this.properties[o].name,s=this.parse(a,n,!0);s&&i.push(s)}}else if(Z(t)){var l=this.parse(t,n,!0);l&&i.push(l)}else{if(!ee(t))return!1;var u=t;r=n;for(var c=Object.keys(u),h=0;h<c.length;h++){var d=c[h],f=u[d];if(void 0===f&&(f=u[fe(d)]),void 0!==f){var p=this.parse(d,f,!0);p&&i.push(p)}}}if(0===i.length)return!1;for(var g=!1,v=0;v<e.length;v++){for(var y=e[v],m={},b=void 0,x=0;x<i.length;x++){var w=i[x];if(r){var E=y.pstyle(w.name);b=m[w.name]={prev:E}}g=this.applyParsedProperty(y,ht(w))||g,r&&(b.next=y.pstyle(w.name))}g&&this.updateStyleHints(y),r&&this.updateTransitions(y,m,true)}return g},overrideBypass:function(e,t,n){t=de(t);for(var r=0;r<e.length;r++){var i=e[r],o=i._private.style[t],a=this.properties[t].type,s=a.color,l=a.mutiple,u=o?null!=o.pfValue?o.pfValue:o.value:null;o&&o.bypass?(o.value=n,null!=o.pfValue&&(o.pfValue=n),o.strValue=s?null==n[3]?"rgb("+n[0]+","+n[1]+","+n[2]+")":"rgba("+n[0]+","+n[1]+","+n[2]+","+n[3]+")":l?n.join(" "):""+n,this.updateStyleHints(i)):this.applyBypass(i,t,n),this.checkTriggers(i,t,u,n)}},removeAllBypasses:function(e,t){return this.removeBypasses(e,this.propertyNames,t)},removeBypasses:function(e,t,n){for(var r=0;r<e.length;r++){for(var i=e[r],o={},a=0;a<t.length;a++){var s=t[a],l=this.properties[s],u=i.pstyle(l.name);if(u&&u.bypass){var c=this.parse(s,"",!0),h=o[l.name]={prev:u};this.applyParsedProperty(i,c),h.next=i.pstyle(l.name)}}this.updateStyleHints(i),n&&this.updateTransitions(i,o,true)}}},Pu={getEmSizeInPixels:function(){var e=this.containerCss("font-size");return null!=e?parseFloat(e):1},containerCss:function(e){var t=this._private.cy,n=t.container(),r=t.window();if(r&&n&&r.getComputedStyle)return r.getComputedStyle(n).getPropertyValue(e)}},Iu={getRenderedStyle:function(e,t){return t?this.getStylePropertyValue(e,t,!0):this.getRawStyle(e,!0)},getRawStyle:function(e,t){var n=this;if(e=e[0]){for(var r={},i=0;i<n.properties.length;i++){var o=n.properties[i],a=n.getStylePropertyValue(e,o.name,t);null!=a&&(r[o.name]=a,r[fe(o.name)]=a)}return r}},getIndexedStyle:function(e,t,n,r){var i=e.pstyle(t)[n][r];return null!=i?i:e.cy().style().getDefaultProperty(t)[n][0]},getStylePropertyValue:function(e,t,n){if(e=e[0]){var r=this.properties[t];r.alias&&(r=r.pointsTo);var i=r.type,o=e.pstyle(r.name);if(o){var a=o.value,s=o.units,l=o.strValue;if(n&&i.number&&null!=a&&te(a)){var u=e.cy().zoom(),c=function(e){return e*u},h=function(e,t){return c(e)+t},d=J(a),f=d?s.every(function(e){return null!=e}):null!=s;return f?d?a.map(function(e,t){return h(e,s[t])}).join(" "):h(a,s):d?a.map(function(e){return Z(e)?e:""+c(e)}).join(" "):""+c(a)}if(null!=l)return l}return null}},getAnimationStartStyle:function(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r].name,o=e.pstyle(i);void 0!==o&&(o=ee(o)?this.parse(i,o.strValue):this.parse(i,o)),o&&(n[i]=o)}return n},getPropsList:function(e){var t=[],n=e,r=this.properties;if(n)for(var i=Object.keys(n),o=0;o<i.length;o++){var a=i[o],s=n[a],l=r[a]||r[de(a)],u=this.parse(l.name,s);u&&t.push(u)}return t},getNonDefaultPropertiesHash:function(e,t,n){var r,i,o,a,s,l,u=n.slice();for(s=0;s<t.length;s++)if(r=t[s],null!=(i=e.pstyle(r,!1)))if(null!=i.pfValue)u[0]=Ue(a,u[0]),u[1]=je(a,u[1]);else for(o=i.strValue,l=0;l<o.length;l++)a=o.charCodeAt(l),u[0]=Ue(a,u[0]),u[1]=je(a,u[1]);return u}};Iu.getPropertiesHash=Iu.getNonDefaultPropertiesHash;var Ou={appendFromJson:function(e){for(var t=this,n=0;n<e.length;n++){var r=e[n],i=r.selector,o=r.style||r.css,a=Object.keys(o);t.selector(i);for(var s=0;s<a.length;s++){var l=a[s],u=o[l];t.css(l,u)}}return t},fromJson:function(e){var t=this;return t.resetToDefault(),t.appendFromJson(e),t},json:function(){for(var e=[],t=this.defaultLength;t<this.length;t++){for(var n=this[t],r=n.selector,i=n.properties,o={},a=0;a<i.length;a++){var s=i[a];o[s.name]=s.strValue}e.push({selector:r?r.toString():"core",style:o})}return e}},Du={appendFromString:function(e){var t,n,r,i=this,o=""+e;function a(){o=o.length>t.length?o.substr(t.length):""}function s(){n=n.length>r.length?n.substr(r.length):""}for(o=o.replace(/[/][*](\s|.)+?[*][/]/g,"");;){if(o.match(/^\s*$/))break;var l=o.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!l){ct("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+o);break}t=l[0];var u=l[1];if("core"!==u)if(new ms(u).invalid){ct("Skipping parsing of block: Invalid selector found in string stylesheet: "+u),a();continue}var c=l[2],h=!1;n=c;for(var d=[];;){if(n.match(/^\s*$/))break;var f=n.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!f){ct("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+c),h=!0;break}r=f[0];var p=f[1],g=f[2];if(this.properties[p])i.parse(p,g)?(d.push({name:p,val:g}),s()):(ct("Skipping property: Invalid property definition in: "+r),s());else ct("Skipping property: Invalid property name in: "+r),s()}if(h){a();break}i.selector(u);for(var v=0;v<d.length;v++){var y=d[v];i.css(y.name,y.val)}a()}return i},fromString:function(e){var t=this;return t.resetToDefault(),t.appendFromString(e),t}},Lu=["source","mid-source","target","mid-target"],Ru=function(e,t){if(null!=t){var n=e.pstyle(t+"-arrow-scale");if(null!=n&&"inherit"!==n.value)return n.value}return e.pstyle("arrow-scale").value},Bu={};!function(){var e=ye,t=be,n=we,r=function(e){return"^"+e+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},i=function(r){var i=e+"|\\w+|"+t+"|"+n+"|\\#[0-9a-fA-F]{3}|\\#[0-9a-fA-F]{6}";return"^"+r+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+e+")\\s*\\,\\s*("+e+")\\s*,\\s*("+i+")\\s*\\,\\s*("+i+")\\)$"},o=["^url\\s*\\(\\s*['\"]?(.+?)['\"]?\\s*\\)$","^(none)$","^(.+)$"];Bu.types={time:{number:!0,min:0,units:"s|ms",implicitUnits:"ms"},percent:{number:!0,min:0,max:100,units:"%",implicitUnits:"%"},percentages:{number:!0,min:0,max:100,units:"%",implicitUnits:"%",multiple:!0},zeroOneNumber:{number:!0,min:0,max:1,unitless:!0},zeroOneNumbers:{number:!0,min:0,max:1,unitless:!0,multiple:!0},nOneOneNumber:{number:!0,min:-1,max:1,unitless:!0},nonNegativeInt:{number:!0,min:0,integer:!0,unitless:!0},nonNegativeNumber:{number:!0,min:0,unitless:!0},position:{enums:["parent","origin"]},nodeSize:{number:!0,min:0,enums:["label"]},number:{number:!0,unitless:!0},numbers:{number:!0,unitless:!0,multiple:!0},positiveNumber:{number:!0,unitless:!0,min:0,strictMin:!0},arrowScale:{number:!0,unitless:!0,min:0,strictMin:!0,enums:["inherit"]},size:{number:!0,min:0},bidirectionalSize:{number:!0},bidirectionalSizeMaybePercent:{number:!0,allowPercent:!0},bidirectionalSizes:{number:!0,multiple:!0},sizeMaybePercent:{number:!0,min:0,allowPercent:!0},axisDirection:{enums:["horizontal","leftward","rightward","vertical","upward","downward","auto"]},axisDirectionExplicit:{enums:["leftward","rightward","upward","downward"]},axisDirectionPrimary:{enums:["horizontal","vertical"]},paddingRelativeTo:{enums:["width","height","average","min","max"]},bgWH:{number:!0,min:0,allowPercent:!0,enums:["auto"],multiple:!0},bgPos:{number:!0,allowPercent:!0,multiple:!0},bgRelativeTo:{enums:["inner","include-padding"],multiple:!0},bgRepeat:{enums:["repeat","repeat-x","repeat-y","no-repeat"],multiple:!0},bgFit:{enums:["none","contain","cover"],multiple:!0},bgCrossOrigin:{enums:["anonymous","use-credentials","null"],multiple:!0},bgClip:{enums:["none","node"],multiple:!0},bgContainment:{enums:["inside","over"],multiple:!0},boxSelection:{enums:["contain","overlap","none"]},color:{color:!0},colors:{color:!0,multiple:!0},fill:{enums:["solid","linear-gradient","radial-gradient"]},bool:{enums:["yes","no"]},bools:{enums:["yes","no"],multiple:!0},lineStyle:{enums:["solid","dotted","dashed"]},lineCap:{enums:["butt","round","square"]},linePosition:{enums:["center","inside","outside"]},lineJoin:{enums:["round","bevel","miter"]},borderStyle:{enums:["solid","dotted","dashed","double"]},curveStyle:{enums:["bezier","unbundled-bezier","haystack","segments","straight","straight-triangle","taxi","round-segments","round-taxi"]},radiusType:{enums:["arc-radius","influence-radius"],multiple:!0},fontFamily:{regex:'^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'},fontStyle:{enums:["italic","normal","oblique"]},fontWeight:{enums:["normal","bold","bolder","lighter","100","200","300","400","500","600","800","900",100,200,300,400,500,600,700,800,900]},textDecoration:{enums:["none","underline","overline","line-through"]},textTransform:{enums:["none","uppercase","lowercase"]},textWrap:{enums:["none","wrap","ellipsis"]},textOverflowWrap:{enums:["whitespace","anywhere"]},textBackgroundShape:{enums:["rectangle","roundrectangle","round-rectangle","circle"]},nodeShape:{enums:["rectangle","roundrectangle","round-rectangle","cutrectangle","cut-rectangle","bottomroundrectangle","bottom-round-rectangle","barrel","ellipse","triangle","round-triangle","square","pentagon","round-pentagon","hexagon","round-hexagon","concavehexagon","concave-hexagon","heptagon","round-heptagon","octagon","round-octagon","tag","round-tag","star","diamond","round-diamond","vee","rhomboid","right-rhomboid","polygon"]},overlayShape:{enums:["roundrectangle","round-rectangle","ellipse"]},cornerRadius:{number:!0,min:0,units:"px|em",implicitUnits:"px",enums:["auto"]},compoundIncludeLabels:{enums:["include","exclude"]},arrowShape:{enums:["tee","triangle","triangle-tee","circle-triangle","triangle-cross","triangle-backcurve","vee","square","circle","diamond","chevron","none"]},arrowFill:{enums:["filled","hollow"]},arrowWidth:{number:!0,units:"%|px|em",implicitUnits:"px",enums:["match-line"]},display:{enums:["element","none"]},visibility:{enums:["hidden","visible"]},zCompoundDepth:{enums:["bottom","orphan","auto","top"]},zIndexCompare:{enums:["auto","manual"]},valign:{enums:["top","top-inside","center","bottom","bottom-inside"]},halign:{enums:["left","left-inside","center","right","right-inside"]},justification:{enums:["left","center","right","auto"]},textMetrics:{enums:["font","glyph"]},text:{string:!0},data:{mapping:!0,regex:r("data")},layoutData:{mapping:!0,regex:r("layoutData")},scratch:{mapping:!0,regex:r("scratch")},mapData:{mapping:!0,regex:i("mapData")},mapLayoutData:{mapping:!0,regex:i("mapLayoutData")},mapScratch:{mapping:!0,regex:i("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:o,singleRegexMatchValue:!0},urls:{regexes:o,singleRegexMatchValue:!0,multiple:!0},propList:{propList:!0},angle:{number:!0,units:"deg|rad",implicitUnits:"rad"},textRotation:{number:!0,units:"deg|rad",implicitUnits:"rad",enums:["none","autorotate"]},polygonPointList:{number:!0,multiple:!0,evenMultiple:!0,min:-1,max:1,unitless:!0},edgeDistances:{enums:["intersection","node-position","endpoints"]},edgeEndpoint:{number:!0,multiple:!0,units:"%|px|em|deg|rad",implicitUnits:"px",enums:["inside-to-node","outside-to-node","outside-to-node-or-label","outside-to-line","outside-to-line-or-label"],singleEnum:!0,validate:function(e,t){switch(e.length){case 2:return"deg"!==t[0]&&"rad"!==t[0]&&"deg"!==t[1]&&"rad"!==t[1];case 1:return Z(e[0])||"deg"===t[0]||"rad"===t[0];default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+e+")\\s*,\\s*("+e+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")\\s*\\)$"],enums:["linear","ease","ease-in","ease-out","ease-in-out","ease-in-sine","ease-out-sine","ease-in-out-sine","ease-in-quad","ease-out-quad","ease-in-out-quad","ease-in-cubic","ease-out-cubic","ease-in-out-cubic","ease-in-quart","ease-out-quart","ease-in-out-quart","ease-in-quint","ease-out-quint","ease-in-out-quint","ease-in-expo","ease-out-expo","ease-in-out-expo","ease-in-circ","ease-out-circ","ease-in-out-circ"]},gradientDirection:{enums:["to-bottom","to-top","to-left","to-right","to-bottom-right","to-bottom-left","to-top-right","to-top-left","to-right-bottom","to-left-bottom","to-right-top","to-left-top"]},boundsExpansion:{number:!0,multiple:!0,min:0,validate:function(e){var t=e.length;return 1===t||2===t||4===t}}};var a={zeroNonZero:function(e,t){return(null==e||null==t)&&e!==t||(0==e&&0!=t||0!=e&&0==t)},any:function(e,t){return e!=t},emptyNonEmpty:function(e,t){var n=ue(e),r=ue(t);return n&&!r||!n&&r}},s=Bu.types,l=[{name:"label",type:s.text,triggersBounds:a.any,triggersZOrder:a.emptyNonEmpty},{name:"text-rotation",type:s.textRotation,triggersBounds:a.any},{name:"text-margin-x",type:s.bidirectionalSize,triggersBounds:a.any},{name:"text-margin-y",type:s.bidirectionalSize,triggersBounds:a.any}],u=[{name:"source-label",type:s.text,triggersBounds:a.any},{name:"source-text-rotation",type:s.textRotation,triggersBounds:a.any},{name:"source-text-margin-x",type:s.bidirectionalSize,triggersBounds:a.any},{name:"source-text-margin-y",type:s.bidirectionalSize,triggersBounds:a.any},{name:"source-text-offset",type:s.size,triggersBounds:a.any}],c=[{name:"target-label",type:s.text,triggersBounds:a.any},{name:"target-text-rotation",type:s.textRotation,triggersBounds:a.any},{name:"target-text-margin-x",type:s.bidirectionalSize,triggersBounds:a.any},{name:"target-text-margin-y",type:s.bidirectionalSize,triggersBounds:a.any},{name:"target-text-offset",type:s.size,triggersBounds:a.any}],h=[{name:"font-family",type:s.fontFamily,triggersBounds:a.any},{name:"font-style",type:s.fontStyle,triggersBounds:a.any},{name:"font-weight",type:s.fontWeight,triggersBounds:a.any},{name:"font-size",type:s.size,triggersBounds:a.any},{name:"text-transform",type:s.textTransform,triggersBounds:a.any},{name:"text-wrap",type:s.textWrap,triggersBounds:a.any},{name:"text-overflow-wrap",type:s.textOverflowWrap,triggersBounds:a.any},{name:"text-max-width",type:s.size,triggersBounds:a.any},{name:"text-outline-width",type:s.size,triggersBounds:a.any},{name:"line-height",type:s.positiveNumber,triggersBounds:a.any}],d=[{name:"text-valign",type:s.valign,triggersBounds:a.any},{name:"text-halign",type:s.halign,triggersBounds:a.any},{name:"color",type:s.color},{name:"text-outline-color",type:s.color},{name:"text-outline-opacity",type:s.zeroOneNumber},{name:"text-background-color",type:s.color},{name:"text-background-opacity",type:s.zeroOneNumber},{name:"text-background-padding",type:s.size,triggersBounds:a.any},{name:"text-border-opacity",type:s.zeroOneNumber},{name:"text-border-color",type:s.color},{name:"text-border-width",type:s.size,triggersBounds:a.any},{name:"text-border-style",type:s.borderStyle,triggersBounds:a.any},{name:"text-background-shape",type:s.textBackgroundShape,triggersBounds:a.any},{name:"text-justification",type:s.justification},{name:"text-metrics",type:s.textMetrics},{name:"box-select-labels",type:s.bool,triggersBounds:a.any}],f=[{name:"events",type:s.bool,triggersZOrder:a.any},{name:"text-events",type:s.bool,triggersZOrder:a.any},{name:"box-selection",type:s.boxSelection,triggersZOrder:a.any}],p=[{name:"display",type:s.display,triggersZOrder:a.any,triggersBounds:a.any,triggersBoundsOfConnectedEdges:a.any,triggersBoundsOfParallelEdges:function(e,t,n){return e!==t&&"bezier"===n.pstyle("curve-style").value}},{name:"visibility",type:s.visibility,triggersZOrder:a.any},{name:"opacity",type:s.zeroOneNumber,triggersZOrder:a.zeroNonZero},{name:"text-opacity",type:s.zeroOneNumber},{name:"min-zoomed-font-size",type:s.size},{name:"z-compound-depth",type:s.zCompoundDepth,triggersZOrder:a.any},{name:"z-index-compare",type:s.zIndexCompare,triggersZOrder:a.any},{name:"z-index",type:s.number,triggersZOrder:a.any}],g=[{name:"overlay-padding",type:s.size,triggersBounds:a.any},{name:"overlay-color",type:s.color},{name:"overlay-fill",type:s.fill},{name:"overlay-gradient-stop-colors",type:s.colors},{name:"overlay-gradient-stop-positions",type:s.percentages},{name:"overlay-gradient-direction",type:s.gradientDirection},{name:"overlay-opacity",type:s.zeroOneNumber,triggersBounds:a.zeroNonZero},{name:"overlay-shape",type:s.overlayShape,triggersBounds:a.any},{name:"overlay-corner-radius",type:s.cornerRadius}],v=[{name:"underlay-padding",type:s.size,triggersBounds:a.any},{name:"underlay-color",type:s.color},{name:"underlay-fill",type:s.fill},{name:"underlay-gradient-stop-colors",type:s.colors},{name:"underlay-gradient-stop-positions",type:s.percentages},{name:"underlay-gradient-direction",type:s.gradientDirection},{name:"underlay-opacity",type:s.zeroOneNumber,triggersBounds:a.zeroNonZero},{name:"underlay-shape",type:s.overlayShape,triggersBounds:a.any},{name:"underlay-corner-radius",type:s.cornerRadius}],y=[{name:"transition-property",type:s.propList},{name:"transition-duration",type:s.time},{name:"transition-delay",type:s.time},{name:"transition-timing-function",type:s.easing}],m=function(e,t){return"label"===t.value?-e.poolIndex():t.pfValue},b=[{name:"height",type:s.nodeSize,triggersBounds:a.any,hashOverride:m},{name:"width",type:s.nodeSize,triggersBounds:a.any,hashOverride:m},{name:"shape",type:s.nodeShape,triggersBounds:a.any},{name:"shape-polygon-points",type:s.polygonPointList,triggersBounds:a.any},{name:"corner-radius",type:s.cornerRadius},{name:"background-color",type:s.color},{name:"background-fill",type:s.fill},{name:"background-opacity",type:s.zeroOneNumber},{name:"background-blacken",type:s.nOneOneNumber},{name:"background-gradient-stop-colors",type:s.colors},{name:"background-gradient-stop-positions",type:s.percentages},{name:"background-gradient-direction",type:s.gradientDirection},{name:"padding",type:s.sizeMaybePercent,triggersBounds:a.any},{name:"padding-relative-to",type:s.paddingRelativeTo,triggersBounds:a.any},{name:"bounds-expansion",type:s.boundsExpansion,triggersBounds:a.any}],x=[{name:"border-color",type:s.color},{name:"border-opacity",type:s.zeroOneNumber},{name:"border-width",type:s.size,triggersBounds:a.any},{name:"border-style",type:s.borderStyle},{name:"border-cap",type:s.lineCap},{name:"border-join",type:s.lineJoin},{name:"border-dash-pattern",type:s.numbers},{name:"border-dash-offset",type:s.number},{name:"border-position",type:s.linePosition}],w=[{name:"outline-color",type:s.color},{name:"outline-opacity",type:s.zeroOneNumber},{name:"outline-width",type:s.size,triggersBounds:a.any},{name:"outline-style",type:s.borderStyle},{name:"outline-offset",type:s.size,triggersBounds:a.any}],E=[{name:"background-image",type:s.urls},{name:"background-image-crossorigin",type:s.bgCrossOrigin},{name:"background-image-opacity",type:s.zeroOneNumbers},{name:"background-image-containment",type:s.bgContainment},{name:"background-image-smoothing",type:s.bools},{name:"background-position-x",type:s.bgPos},{name:"background-position-y",type:s.bgPos},{name:"background-width-relative-to",type:s.bgRelativeTo},{name:"background-height-relative-to",type:s.bgRelativeTo},{name:"background-repeat",type:s.bgRepeat},{name:"background-fit",type:s.bgFit},{name:"background-clip",type:s.bgClip},{name:"background-width",type:s.bgWH},{name:"background-height",type:s.bgWH},{name:"background-offset-x",type:s.bgPos},{name:"background-offset-y",type:s.bgPos}],T=[{name:"position",type:s.position,triggersBounds:a.any},{name:"compound-sizing-wrt-labels",type:s.compoundIncludeLabels,triggersBounds:a.any},{name:"min-width",type:s.size,triggersBounds:a.any},{name:"min-width-bias-left",type:s.sizeMaybePercent,triggersBounds:a.any},{name:"min-width-bias-right",type:s.sizeMaybePercent,triggersBounds:a.any},{name:"min-height",type:s.size,triggersBounds:a.any},{name:"min-height-bias-top",type:s.sizeMaybePercent,triggersBounds:a.any},{name:"min-height-bias-bottom",type:s.sizeMaybePercent,triggersBounds:a.any}],C=[{name:"line-style",type:s.lineStyle},{name:"line-color",type:s.color},{name:"line-fill",type:s.fill},{name:"line-cap",type:s.lineCap},{name:"line-opacity",type:s.zeroOneNumber},{name:"line-dash-pattern",type:s.numbers},{name:"line-dash-offset",type:s.number},{name:"line-outline-width",type:s.size},{name:"line-outline-color",type:s.color},{name:"line-gradient-stop-colors",type:s.colors},{name:"line-gradient-stop-positions",type:s.percentages},{name:"curve-style",type:s.curveStyle,triggersBounds:a.any,triggersBoundsOfParallelEdges:function(e,t){return e!==t&&("bezier"===e||"bezier"===t)}},{name:"haystack-radius",type:s.zeroOneNumber,triggersBounds:a.any},{name:"source-endpoint",type:s.edgeEndpoint,triggersBounds:a.any},{name:"target-endpoint",type:s.edgeEndpoint,triggersBounds:a.any},{name:"control-point-step-size",type:s.size,triggersBounds:a.any},{name:"control-point-distances",type:s.bidirectionalSizes,triggersBounds:a.any},{name:"control-point-weights",type:s.numbers,triggersBounds:a.any},{name:"segment-distances",type:s.bidirectionalSizes,triggersBounds:a.any},{name:"segment-weights",type:s.numbers,triggersBounds:a.any},{name:"segment-radii",type:s.numbers,triggersBounds:a.any},{name:"radius-type",type:s.radiusType,triggersBounds:a.any},{name:"taxi-turn",type:s.bidirectionalSizeMaybePercent,triggersBounds:a.any},{name:"taxi-turn-min-distance",type:s.size,triggersBounds:a.any},{name:"taxi-direction",type:s.axisDirection,triggersBounds:a.any},{name:"taxi-radius",type:s.number,triggersBounds:a.any},{name:"edge-distances",type:s.edgeDistances,triggersBounds:a.any},{name:"arrow-scale",type:s.positiveNumber,triggersBounds:a.any},{name:"loop-direction",type:s.angle,triggersBounds:a.any},{name:"loop-sweep",type:s.angle,triggersBounds:a.any},{name:"source-distance-from-node",type:s.size,triggersBounds:a.any},{name:"target-distance-from-node",type:s.size,triggersBounds:a.any}],M=[{name:"ghost",type:s.bool,triggersBounds:a.any},{name:"ghost-offset-x",type:s.bidirectionalSize,triggersBounds:a.any},{name:"ghost-offset-y",type:s.bidirectionalSize,triggersBounds:a.any},{name:"ghost-opacity",type:s.zeroOneNumber}],A=[{name:"selection-box-color",type:s.color},{name:"selection-box-opacity",type:s.zeroOneNumber},{name:"selection-box-border-color",type:s.color},{name:"selection-box-border-width",type:s.size},{name:"active-bg-color",type:s.color},{name:"active-bg-opacity",type:s.zeroOneNumber},{name:"active-bg-size",type:s.size},{name:"outside-texture-bg-color",type:s.color},{name:"outside-texture-bg-opacity",type:s.zeroOneNumber}],N=[];Bu.pieBackgroundN=16,N.push({name:"pie-size",type:s.sizeMaybePercent}),N.push({name:"pie-hole",type:s.sizeMaybePercent}),N.push({name:"pie-start-angle",type:s.angle});for(var _=1;_<=Bu.pieBackgroundN;_++)N.push({name:"pie-"+_+"-background-color",type:s.color}),N.push({name:"pie-"+_+"-background-size",type:s.percent}),N.push({name:"pie-"+_+"-background-opacity",type:s.zeroOneNumber});var S=[];Bu.stripeBackgroundN=16,S.push({name:"stripe-size",type:s.sizeMaybePercent}),S.push({name:"stripe-direction",type:s.axisDirectionPrimary});for(var k=1;k<=Bu.stripeBackgroundN;k++)S.push({name:"stripe-"+k+"-background-color",type:s.color}),S.push({name:"stripe-"+k+"-background-size",type:s.percent}),S.push({name:"stripe-"+k+"-background-opacity",type:s.zeroOneNumber});var P=[];Bu.arrowPrefixes=Lu,[{name:"arrow-shape",type:s.arrowShape,triggersBounds:a.any},{name:"arrow-color",type:s.color},{name:"arrow-fill",type:s.arrowFill},{name:"arrow-width",type:s.arrowWidth},{name:"arrow-scale",type:s.arrowScale,triggersBounds:a.any}].forEach(function(e){Lu.forEach(function(t){var n=t+"-"+e.name,r=e.type,i=e.triggersBounds;P.push({name:n,type:r,triggersBounds:i})})},{});var I=Bu.properties=[].concat(f,y,p,g,v,M,d,h,l,u,c,b,x,w,E,N,S,T,C,P,A),O=Bu.propertyGroups={behavior:f,transition:y,visibility:p,overlay:g,underlay:v,ghost:M,commonLabel:d,labelDimensions:h,mainLabel:l,sourceLabel:u,targetLabel:c,nodeBody:b,nodeBorder:x,nodeOutline:w,backgroundImage:E,pie:N,stripe:S,compound:T,edgeLine:C,edgeArrow:P,core:A},D=Bu.propertyGroupNames={};(Bu.propertyGroupKeys=Object.keys(O)).forEach(function(e){D[e]=O[e].map(function(e){return e.name}),O[e].forEach(function(t){return t.groupKey=e})});var L=Bu.aliases=[{name:"content",pointsTo:"label"},{name:"control-point-distance",pointsTo:"control-point-distances"},{name:"control-point-weight",pointsTo:"control-point-weights"},{name:"segment-distance",pointsTo:"segment-distances"},{name:"segment-weight",pointsTo:"segment-weights"},{name:"segment-radius",pointsTo:"segment-radii"},{name:"edge-text-rotation",pointsTo:"text-rotation"},{name:"padding-left",pointsTo:"padding"},{name:"padding-right",pointsTo:"padding"},{name:"padding-top",pointsTo:"padding"},{name:"padding-bottom",pointsTo:"padding"}];Bu.propertyNames=I.map(function(e){return e.name});for(var R=0;R<I.length;R++){var B=I[R];I[B.name]=B}for(var z=0;z<L.length;z++){var F=L[z],V=I[F.pointsTo],G={name:F.name,alias:!0,pointsTo:V};I.push(G),I[F.name]=G}}(),Bu.getDefaultProperty=function(e){return this.getDefaultProperties()[e]},Bu.getDefaultProperties=function(){var e=this._private;if(null!=e.defaultProperties)return e.defaultProperties;for(var t=Te({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125,events:"yes","text-events":"no","text-valign":"top","text-halign":"center","text-justification":"auto","line-height":1,color:"#000","box-selection":"contain","text-outline-color":"#000","text-outline-width":0,"text-outline-opacity":1,"text-opacity":1,"text-decoration":"none","text-transform":"none","text-wrap":"none","text-overflow-wrap":"whitespace","text-max-width":9999,"text-background-color":"#000","text-background-opacity":0,"text-background-shape":"rectangle","text-background-padding":0,"text-border-opacity":0,"text-border-width":0,"text-border-style":"solid","text-border-color":"#000","font-family":"Helvetica Neue, Helvetica, sans-serif","font-style":"normal","font-weight":"normal","font-size":16,"min-zoomed-font-size":0,"text-rotation":"none","source-text-rotation":"none","target-text-rotation":"none",visibility:"visible",display:"element",opacity:1,"z-compound-depth":"auto","z-index-compare":"auto","z-index":0,label:"","text-margin-x":0,"text-margin-y":0,"source-label":"","source-text-offset":0,"source-text-margin-x":0,"source-text-margin-y":0,"target-label":"","target-text-offset":0,"target-text-margin-x":0,"target-text-margin-y":0,"overlay-opacity":0,"overlay-color":"#000","overlay-fill":"solid","overlay-gradient-stop-colors":"#999","overlay-gradient-stop-positions":"0%","overlay-gradient-direction":"to-bottom","overlay-padding":10,"overlay-shape":"round-rectangle","overlay-corner-radius":"auto","underlay-opacity":0,"underlay-color":"#000","underlay-fill":"solid","underlay-gradient-stop-colors":"#999","underlay-gradient-stop-positions":"0%","underlay-gradient-direction":"to-bottom","underlay-padding":10,"underlay-shape":"round-rectangle","underlay-corner-radius":"auto","text-metrics":"font","transition-property":"none","transition-duration":0,"transition-delay":0,"transition-timing-function":"linear","box-select-labels":"no","background-blacken":0,"background-color":"#999","background-fill":"solid","background-opacity":1,"background-image":"none","background-image-crossorigin":"anonymous","background-image-opacity":1,"background-image-containment":"inside","background-image-smoothing":"yes","background-position-x":"50%","background-position-y":"50%","background-offset-x":0,"background-offset-y":0,"background-width-relative-to":"include-padding","background-height-relative-to":"include-padding","background-repeat":"no-repeat","background-fit":"none","background-clip":"node","background-width":"auto","background-height":"auto","border-color":"#000","border-opacity":1,"border-width":0,"border-style":"solid","border-dash-pattern":[4,2],"border-dash-offset":0,"border-cap":"butt","border-join":"miter","border-position":"center","outline-color":"#999","outline-opacity":1,"outline-width":0,"outline-offset":0,"outline-style":"solid",height:30,width:30,shape:"ellipse","shape-polygon-points":"-1, -1, 1, -1, 1, 1, -1, 1","corner-radius":"auto","bounds-expansion":0,"background-gradient-direction":"to-bottom","background-gradient-stop-colors":"#999","background-gradient-stop-positions":"0%",ghost:"no","ghost-offset-y":0,"ghost-offset-x":0,"ghost-opacity":0,padding:0,"padding-relative-to":"width",position:"origin","compound-sizing-wrt-labels":"include","min-width":0,"min-width-bias-left":0,"min-width-bias-right":0,"min-height":0,"min-height-bias-top":0,"min-height-bias-bottom":0},{"pie-size":"100%","pie-hole":0,"pie-start-angle":"0deg"},[{name:"pie-{{i}}-background-color",value:"black"},{name:"pie-{{i}}-background-size",value:"0%"},{name:"pie-{{i}}-background-opacity",value:1}].reduce(function(e,t){for(var n=1;n<=Bu.pieBackgroundN;n++){var r=t.name.replace("{{i}}",n),i=t.value;e[r]=i}return e},{}),{"stripe-size":"100%","stripe-direction":"horizontal"},[{name:"stripe-{{i}}-background-color",value:"black"},{name:"stripe-{{i}}-background-size",value:"0%"},{name:"stripe-{{i}}-background-opacity",value:1}].reduce(function(e,t){for(var n=1;n<=Bu.stripeBackgroundN;n++){var r=t.name.replace("{{i}}",n),i=t.value;e[r]=i}return e},{}),{"line-style":"solid","line-color":"#999","line-fill":"solid","line-cap":"butt","line-opacity":1,"line-outline-width":0,"line-outline-color":"#000","line-gradient-stop-colors":"#999","line-gradient-stop-positions":"0%","control-point-step-size":40,"control-point-weights":.5,"segment-weights":.5,"segment-distances":20,"segment-radii":15,"radius-type":"arc-radius","taxi-turn":"50%","taxi-radius":15,"taxi-turn-min-distance":10,"taxi-direction":"auto","edge-distances":"intersection","curve-style":"haystack","haystack-radius":0,"arrow-scale":1,"loop-direction":"-45deg","loop-sweep":"-90deg","source-distance-from-node":0,"target-distance-from-node":0,"source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","line-dash-pattern":[6,3],"line-dash-offset":0},[{name:"arrow-shape",value:"none"},{name:"arrow-color",value:"#999"},{name:"arrow-fill",value:"filled"},{name:"arrow-width",value:1},{name:"arrow-scale",value:"inherit"}].reduce(function(e,t){return Bu.arrowPrefixes.forEach(function(n){var r=n+"-"+t.name,i=t.value;e[r]=i}),e},{})),n={},r=0;r<this.properties.length;r++){var i=this.properties[r];if(!i.pointsTo){var o=i.name,a=t[o],s=this.parse(o,a);n[o]=s}}return e.defaultProperties=n,e.defaultProperties},Bu.addDefaultStylesheet=function(){this.selector(":parent").css({shape:"rectangle",padding:10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3}).selector(":loop").css({"curve-style":"bezier"}).selector("edge:compound").css({"curve-style":"bezier","source-endpoint":"outside-to-line","target-endpoint":"outside-to-line"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector(":parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}),this.defaultLength=this.length};var zu={parse:function(e,t,n,r){var i=this;if(Q(t))return i.parseImplWarn(e,t,n,r);var o,a=Ze(e,""+t,n?"t":"f","mapping"===r||!0===r||!1===r||null==r?"dontcare":r),s=i.propCache=i.propCache||[];return(o=s[a])||(o=s[a]=i.parseImplWarn(e,t,n,r)),(n||"mapping"===r)&&(o=ht(o))&&(o.value=ht(o.value)),o},parseImplWarn:function(e,t,n,r){var i=this.parseImpl(e,t,n,r);return i||null==t||ct("The style property `".concat(e,": ").concat(t,"` is invalid")),!i||"width"!==i.name&&"height"!==i.name||"label"!==t||ct("The style value of `label` is deprecated for `"+i.name+"`"),i}};zu.parseImpl=function(e,t,n,r){var i=this;e=de(e);var o=i.properties[e],a=t,s=i.types;if(!o)return null;if(void 0===t)return null;o.alias&&(o=o.pointsTo,e=o.name);var l=Z(t);l&&(t=t.trim());var u,c,h=o.type;if(!h)return null;if(n&&(""===t||null===t))return{name:e,value:t,bypass:!0,deleteBypass:!0};if(Q(t))return{name:e,value:t,strValue:"fn",mapped:s.fn,bypass:n};if(!l||r||t.length<7||"a"!==t[1]);else{if(t.length>=7&&"d"===t[0]&&(u=new RegExp(s.data.regex).exec(t))){if(n)return!1;var d=s.data;return{name:e,value:u,strValue:""+t,mapped:d,field:u[1],bypass:n}}if(t.length>=10&&"m"===t[0]&&(c=new RegExp(s.mapData.regex).exec(t))){if(n)return!1;if(h.multiple)return!1;var f=s.mapData;if(!h.color&&!h.number)return!1;var p=this.parse(e,c[4]);if(!p||p.mapped)return!1;var g=this.parse(e,c[5]);if(!g||g.mapped)return!1;if(p.pfValue===g.pfValue||p.strValue===g.strValue)return ct("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+p.strValue+"`"),this.parse(e,p.strValue);if(h.color){var v=p.value,y=g.value;if(!(v[0]!==y[0]||v[1]!==y[1]||v[2]!==y[2]||v[3]!==y[3]&&(null!=v[3]&&1!==v[3]||null!=y[3]&&1!==y[3])))return!1}return{name:e,value:c,strValue:""+t,mapped:f,field:c[1],fieldMin:parseFloat(c[2]),fieldMax:parseFloat(c[3]),valueMin:p.value,valueMax:g.value,bypass:n}}}if(h.multiple&&"multiple"!==r){var m;if(m=l?t.split(/\s+/):J(t)?t:[t],h.evenMultiple&&m.length%2!=0)return null;for(var b=[],x=[],w=[],E="",T=!1,C=0;C<m.length;C++){var M=i.parse(e,m[C],n,"multiple");T=T||Z(M.value),b.push(M.value),w.push(null!=M.pfValue?M.pfValue:M.value),x.push(M.units),E+=(C>0?" ":"")+M.strValue}return h.validate&&!h.validate(b,x)?null:h.singleEnum&&T?1===b.length&&Z(b[0])?{name:e,value:b[0],strValue:b[0],bypass:n}:null:{name:e,value:b,pfValue:w,strValue:E,bypass:n,units:x}}var A,N=function(){for(var r=0;r<h.enums.length;r++){if(h.enums[r]===t)return{name:e,value:t,strValue:""+t,bypass:n}}return null};if(h.number){var _,S="px";if(h.units&&(_=h.units),h.implicitUnits&&(S=h.implicitUnits),!h.unitless)if(l){var k="px|em"+(h.allowPercent?"|\\%":"");_&&(k=_);var P=t.match("^("+ye+")("+k+")?$");P&&(t=P[1],_=P[2]||S)}else _&&!h.implicitUnits||(_=S);if(t=parseFloat(t),isNaN(t)&&void 0===h.enums)return null;if(isNaN(t)&&void 0!==h.enums)return t=a,N();if(h.integer&&!ne(t))return null;if(void 0!==h.min&&(t<h.min||h.strictMin&&t===h.min)||void 0!==h.max&&(t>h.max||h.strictMax&&t===h.max))return null;var I={name:e,value:t,strValue:""+t+(_||""),units:_,bypass:n};return h.unitless||"px"!==_&&"em"!==_?I.pfValue=t:I.pfValue="px"!==_&&_?this.getEmSizeInPixels()*t:t,"ms"!==_&&"s"!==_||(I.pfValue="ms"===_?t:1e3*t),"deg"!==_&&"rad"!==_||(I.pfValue="rad"===_?t:(A=t,Math.PI*A/180)),"%"===_&&(I.pfValue=t/100),I}if(h.propList){var O=[],D=""+t;if("none"===D);else{for(var L=D.split(/\s*,\s*|\s+/),R=0;R<L.length;R++){var B=L[R].trim();i.properties[B]?O.push(B):ct("`"+B+"` is not a valid property name")}if(0===O.length)return null}return{name:e,value:O,strValue:0===O.length?"none":O.join(" "),bypass:n}}if(h.color){var z=Ce(t);return z?{name:e,value:z,pfValue:z,strValue:null==z[3]?"rgb("+z[0]+","+z[1]+","+z[2]+")":"rgba("+z[0]+","+z[1]+","+z[2]+","+z[3]+")",bypass:n}:null}if(h.regex||h.regexes){if(h.enums){var F=N();if(F)return F}for(var V=h.regexes?h.regexes:[h.regex],G=0;G<V.length;G++){var Y=new RegExp(V[G]).exec(t);if(Y)return{name:e,value:h.singleRegexMatchValue?Y[1]:Y,strValue:""+t,bypass:n}}return null}return h.string?{name:e,value:""+t,strValue:""+t,bypass:n}:h.enums?N():null};var Fu=function(e){if(!(this instanceof Fu))return new Fu(e);se(e)?(this._private={cy:e,coreStyle:{}},this.length=0,this.resetToDefault()):lt("A style must have a core reference")},Vu=Fu.prototype;Vu.instanceString=function(){return"style"},Vu.clear=function(){for(var e=this._private,t=e.cy.elements(),n=0;n<this.length;n++)this[n]=void 0;return this.length=0,e.contextStyles={},e.propDiffs={},this.cleanElements(t,!0),t.forEach(function(e){var t=e[0]._private;t.styleDirty=!0,t.appliedInitStyle=!1}),this},Vu.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this},Vu.core=function(e){return this._private.coreStyle[e]||this.getDefaultProperty(e)},Vu.selector=function(e){var t="core"===e?null:new ms(e),n=this.length++;return this[n]={selector:t,properties:[],mappedProperties:[],index:n},this},Vu.css=function(){var e=arguments;if(1===e.length)for(var t=e[0],n=0;n<this.properties.length;n++){var r=this.properties[n],i=t[r.name];void 0===i&&(i=t[fe(r.name)]),void 0!==i&&this.cssRule(r.name,i)}else 2===e.length&&this.cssRule(e[0],e[1]);return this},Vu.style=Vu.css,Vu.cssRule=function(e,t){var n=this.parse(e,t);if(n){var r=this.length-1;this[r].properties.push(n),this[r].properties[n.name]=n,n.name.match(/pie-(\d+)-background-size/)&&n.value&&(this._private.hasPie=!0),n.name.match(/stripe-(\d+)-background-size/)&&n.value&&(this._private.hasStripe=!0),n.mapped&&this[r].mappedProperties.push(n),!this[r].selector&&(this._private.coreStyle[n.name]=n)}return this},Vu.append=function(e){return le(e)?e.appendToStyle(this):J(e)?this.appendFromJson(e):Z(e)&&this.appendFromString(e),this},Fu.fromJson=function(e,t){var n=new Fu(e);return n.fromJson(t),n},Fu.fromString=function(e,t){return new Fu(e).fromString(t)},[_u,ku,Pu,Iu,Ou,Du,Bu,zu].forEach(function(e){Te(Vu,e)}),Fu.types=Vu.types,Fu.properties=Vu.properties,Fu.propertyGroups=Vu.propertyGroups,Fu.propertyGroupNames=Vu.propertyGroupNames,Fu.propertyGroupKeys=Vu.propertyGroupKeys;var Gu={style:function(e){e&&this.setStyle(e).update();return this._private.style},setStyle:function(e){var t=this._private;return le(e)?t.style=e.generateStyle(this):J(e)?t.style=Fu.fromJson(this,e):Z(e)?t.style=Fu.fromString(this,e):t.style=Fu(this),t.style},updateStyle:function(){this.mutableElements().updateStyle()}},Yu={autolock:function(e){return void 0===e?this._private.autolock:(this._private.autolock=!!e,this)},autoungrabify:function(e){return void 0===e?this._private.autoungrabify:(this._private.autoungrabify=!!e,this)},autounselectify:function(e){return void 0===e?this._private.autounselectify:(this._private.autounselectify=!!e,this)},selectionType:function(e){var t=this._private;return null==t.selectionType&&(t.selectionType="single"),void 0===e?t.selectionType:("additive"!==e&&"single"!==e||(t.selectionType=e),this)},panningEnabled:function(e){return void 0===e?this._private.panningEnabled:(this._private.panningEnabled=!!e,this)},userPanningEnabled:function(e){return void 0===e?this._private.userPanningEnabled:(this._private.userPanningEnabled=!!e,this)},zoomingEnabled:function(e){return void 0===e?this._private.zoomingEnabled:(this._private.zoomingEnabled=!!e,this)},userZoomingEnabled:function(e){return void 0===e?this._private.userZoomingEnabled:(this._private.userZoomingEnabled=!!e,this)},boxSelectionEnabled:function(e){return void 0===e?this._private.boxSelectionEnabled:(this._private.boxSelectionEnabled=!!e,this)},pan:function(){var e,t,n,r,i,o=arguments,a=this._private.pan;switch(o.length){case 0:return a;case 1:if(Z(o[0]))return a[e=o[0]];if(ee(o[0])){if(!this._private.panningEnabled)return this;r=(n=o[0]).x,i=n.y,te(r)&&(a.x=r),te(i)&&(a.y=i),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;t=o[1],"x"!==(e=o[0])&&"y"!==e||!te(t)||(a[e]=t),this.emit("pan viewport")}return this.notify("viewport"),this},panBy:function(e,t){var n,r,i,o,a,s=arguments,l=this._private.pan;if(!this._private.panningEnabled)return this;switch(s.length){case 1:ee(e)&&(o=(i=s[0]).x,a=i.y,te(o)&&(l.x+=o),te(a)&&(l.y+=a),this.emit("pan viewport"));break;case 2:r=t,"x"!==(n=e)&&"y"!==n||!te(r)||(l[n]+=r),this.emit("pan viewport")}return this.notify("viewport"),this},gc:function(){this.notify("gc")},fit:function(e,t){var n=this.getFitViewport(e,t);if(n){var r=this._private;r.zoom=n.zoom,r.pan=n.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,t){if(te(e)&&void 0===t&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){var n,r;if(Z(e)){var i=e;e=this.$(i)}else if(ee(r=e)&&te(r.x1)&&te(r.x2)&&te(r.y1)&&te(r.y2)){var o=e;(n={x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2}).w=n.x2-n.x1,n.h=n.y2-n.y1}else ie(e)||(e=this.mutableElements());if(!ie(e)||!e.empty()){n=n||e.boundingBox();var a,s=this.width(),l=this.height();if(t=te(t)?t:0,!isNaN(s)&&!isNaN(l)&&s>0&&l>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0)return{zoom:a=(a=(a=Math.min((s-2*t)/n.w,(l-2*t)/n.h))>this._private.maxZoom?this._private.maxZoom:a)<this._private.minZoom?this._private.minZoom:a,pan:{x:(s-a*(n.x1+n.x2))/2,y:(l-a*(n.y1+n.y2))/2}}}}},zoomRange:function(e,t){var n=this._private;if(null==t){var r=e;e=r.min,t=r.max}return te(e)&&te(t)&&e<=t?(n.minZoom=e,n.maxZoom=t):te(e)&&void 0===t&&e<=n.maxZoom?n.minZoom=e:te(t)&&void 0===e&&t>=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,o=r.zoom,a=!1;if(r.zoomingEnabled||(a=!0),te(e)?n=e:ee(e)&&(n=e.level,null!=e.position?t=Wt(e.position,o,i):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(a=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)<r.minZoom?r.minZoom:n,a||!te(n)||n===o||null!=t&&(!te(t.x)||!te(t.y)))return null;if(null!=t){var s=i,l=o,u=n;return{zoomed:!0,panned:!0,zoom:u,pan:{x:-u/l*(t.x-s.x)+t.x,y:-u/l*(t.y-s.y)+t.y}}}return{zoomed:!0,panned:!1,zoom:n,pan:i}},zoom:function(e){if(void 0===e)return this._private.zoom;var t=this.getZoomedViewport(e),n=this._private;return null!=t&&t.zoomed?(n.zoom=t.zoom,t.panned&&(n.pan.x=t.pan.x,n.pan.y=t.pan.y),this.emit("zoom"+(t.panned?" pan":"")+" viewport"),this.notify("viewport"),this):this},viewport:function(e){var t=this._private,n=!0,r=!0,i=[],o=!1,a=!1;if(!e)return this;if(te(e.zoom)||(n=!1),ee(e.pan)||(r=!1),!n&&!r)return this;if(n){var s=e.zoom;s<t.minZoom||s>t.maxZoom||!t.zoomingEnabled?o=!0:(t.zoom=s,i.push("zoom"))}if(r&&(!o||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;te(l.x)&&(t.pan.x=l.x,a=!1),te(l.y)&&(t.pan.y=l.y,a=!1),a||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(Z(e)){var n=e;e=this.mutableElements().filter(n)}else ie(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),i=this.width(),o=this.height();return{x:(i-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(o-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}};Yu.centre=Yu.center,Yu.autolockNodes=Yu.autolock,Yu.autoungrabifyNodes=Yu.autoungrabify;var Xu={data:Da.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Da.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Da.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Da.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Xu.attr=Xu.data,Xu.removeAttr=Xu.removeData;var $u=function(e){var t=this,n=(e=Te({},e)).container;n&&!re(n)&&re(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 o=void 0!==v&&void 0!==n&&!e.headless,a=e;a.layout=Te({name:o?"grid":"null"},a.layout),a.renderer=Te({name:o?"canvas":"null"},a.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:a,elements:new ru(this),listeners:[],aniEles:new ru(this),data:a.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,a.zoomingEnabled),userZoomingEnabled:s(!0,a.userZoomingEnabled),panningEnabled:s(!0,a.panningEnabled),userPanningEnabled:s(!0,a.userPanningEnabled),boxSelectionEnabled:s(!0,a.boxSelectionEnabled),autolock:s(!1,a.autolock,a.autolockNodes),autoungrabify:s(!1,a.autoungrabify,a.autoungrabifyNodes),autounselectify:s(!1,a.autounselectify),styleEnabled:void 0===a.styleEnabled?o:a.styleEnabled,zoom:te(a.zoom)?a.zoom:1,pan:{x:ee(a.pan)&&te(a.pan.x)?a.pan.x:0,y:ee(a.pan)&&te(a.pan.y)?a.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:s(250,a.multiClickDebounceTime)};this.createEmitter(),this.selectionType(a.selectionType),this.zoomRange({min:a.minZoom,max:a.maxZoom});l.styleEnabled&&t.setStyle([]);var u=Te({},a,a.renderer);t.initRenderer(u);!function(e,t){if(e.some(ce))return si.all(e).then(t);t(e)}([a.style,a.elements],function(e){var n=e[0],o=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&&(ee(e)||J(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 o=Te({},t._private.options.layout);o.eles=t.elements(),t.layout(o).run()}(o,function(){t.startAnimationLoop(),l.ready=!0,Q(a.ready)&&t.on("ready",a.ready);for(var e=0;e<i.length;e++){var n=i[e];t.on("ready",n)}r&&(r.readies=[]),t.emit("ready")},a.done)})},Uu=$u.prototype;Te(Uu,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},destroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){var e=this;if(!e.destroyed())return e.stopAnimationLoop(),e.destroyRenderer(),this.emit("destroy"),e._private.destroyed=!0,e},hasElementWithId:function(e){return this._private.elements.hasElementWithId(e)},getElementById:function(e){return this._private.elements.getElementById(e)},hasCompoundNodes:function(){return this._private.hasCompoundNodes},headless:function(){return this._private.renderer.isHeadless()},styleEnabled:function(){return this._private.styleEnabled},addToPool:function(e){return this._private.elements.merge(e),this},removeFromPool:function(e){return this._private.elements.unmerge(e),this},container:function(){return this._private.container||null},window:function(){if(null==this._private.container)return v;var e=this._private.container.ownerDocument;return void 0===e||null==e?v:e.defaultView||v},mount:function(e){if(null!=e){var t=this,n=t._private,r=n.options;return!re(e)&&re(e[0])&&(e=e[0]),t.stopAnimationLoop(),t.destroyRenderer(),n.container=e,n.styleEnabled=!0,t.invalidateSize(),t.initRenderer(Te({},r,r.renderer,{name:"null"===r.renderer.name?"canvas":r.renderer.name})),t.startAnimationLoop(),t.style(r.style),t.emit("mount"),t}},unmount:function(){var e=this;return e.stopAnimationLoop(),e.destroyRenderer(),e.initRenderer({name:"null"}),e.emit("unmount"),e},options:function(){return ht(this._private.options)},json:function(e){var t=this,n=t._private,r=t.mutableElements();if(ee(e)){if(t.startBatch(),e.elements){var i={},o=function(e,n){for(var r=[],o=[],a=0;a<e.length;a++){var s=e[a];if(s.data.id){var l=""+s.data.id,u=t.getElementById(l);i[l]=!0,0!==u.length?o.push({ele:u,json:s}):n?(s.group=n,r.push(s)):r.push(s)}else ct("cy.json() cannot handle elements without an ID attribute")}t.add(r);for(var c=0;c<o.length;c++){var h=o[c],d=h.ele,f=h.json;d.json(f)}};if(J(e.elements))o(e.elements);else for(var a=["nodes","edges"],s=0;s<a.length;s++){var l=a[s],u=e.elements[l];J(u)&&o(u,l)}var c=t.collection();r.filter(function(e){return!i[e.id()]}).forEach(function(e){e.isParent()?c.merge(e):e.remove()}),c.forEach(function(e){return e.children().move({parent:null})}),c.forEach(function(e){return function(e){return t.getElementById(e.id())}(e).remove()})}e.style&&t.style(e.style),null!=e.zoom&&e.zoom!==n.zoom&&t.zoom(e.zoom),e.pan&&(e.pan.x===n.pan.x&&e.pan.y===n.pan.y||t.pan(e.pan)),e.data&&t.data(e.data);for(var h=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify","multiClickDebounceTime"],d=0;d<h.length;d++){var f=h[d];null!=e[f]&&t[f](e[f])}return t.endBatch(),this}var p={};!!e?p.elements=this.elements().map(function(e){return e.json()}):(p.elements={},r.forEach(function(e){var t=e.group();p.elements[t]||(p.elements[t]=[]),p.elements[t].push(e.json())})),this._private.styleEnabled&&(p.style=t.style().json()),p.data=ht(t.data());var g=n.options;return p.zoomingEnabled=n.zoomingEnabled,p.userZoomingEnabled=n.userZoomingEnabled,p.zoom=n.zoom,p.minZoom=n.minZoom,p.maxZoom=n.maxZoom,p.panningEnabled=n.panningEnabled,p.userPanningEnabled=n.userPanningEnabled,p.pan=ht(n.pan),p.boxSelectionEnabled=n.boxSelectionEnabled,p.renderer=ht(g.renderer),p.hideEdgesOnViewport=g.hideEdgesOnViewport,p.textureOnViewport=g.textureOnViewport,p.wheelSensitivity=g.wheelSensitivity,p.motionBlur=g.motionBlur,p.multiClickDebounceTime=g.multiClickDebounceTime,p}}),Uu.$id=Uu.getElementById,[ou,mu,wu,Eu,Tu,Cu,Au,Nu,Gu,Yu,Xu].forEach(function(e){Te(Uu,e)});var ju={fit:!0,directed:!1,direction:"downward",padding:30,circle:!1,grid:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,depthSort: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}},Hu={maximal:!1,acyclic:!1},Wu=function(e){return e.scratch("breadthfirst")},qu=function(e,t){return e.scratch("breadthfirst",t)};function Ku(e){this.options=Te({},ju,Hu,e)}Ku.prototype.run=function(){var e,t=this.options,n=t.cy,r=t.eles,i=r.nodes().filter(function(e){return e.isChildless()}),o=r,a=t.directed,s=t.acyclic||t.maximal||t.maximalAdjustments>0,l=!!t.boundingBox,u=cn(l?t.boundingBox:structuredClone(n.extent()));if(ie(t.roots))e=t.roots;else if(J(t.roots)){for(var c=[],h=0;h<t.roots.length;h++){var d=t.roots[h],f=n.getElementById(d);c.push(f)}e=n.collection(c)}else if(Z(t.roots))e=n.$(t.roots);else if(a)e=i.roots();else{var p=r.components();e=n.collection();for(var g=function(){var t=p[v],n=t.maxDegree(!1),r=t.filter(function(e){return e.degree(!1)===n});e=e.add(r)},v=0;v<p.length;v++)g()}var y=[],m={},b=function(e,t){null==y[t]&&(y[t]=[]);var n=y[t].length;y[t].push(e),qu(e,{index:n,depth:t})};o.bfs({roots:e,directed:t.directed,visit:function(e,t,n,r,i){var o=e[0],a=o.id();o.isChildless()&&b(o,i),m[a]=!0}});for(var x=[],w=0;w<i.length;w++){var E=i[w];m[E.id()]||x.push(E)}var T=function(e){for(var t=y[e],n=0;n<t.length;n++){var r=t[n];null!=r?qu(r,{depth:e,index:n}):(t.splice(n,1),n--)}},C=function(e,n){for(var i=Wu(e),o=e.incomers().filter(function(e){return e.isNode()&&r.has(e)}),a=-1,s=e.id(),l=0;l<o.length;l++){var u=o[l],c=Wu(u);a=Math.max(a,c.depth)}if(i.depth<=a){if(!t.acyclic&&n[s])return null;var h=a+1;return function(e,t){var n=Wu(e),r=n.depth,i=n.index;y[r][i]=null,e.isChildless()&&b(e,t)}(e,h),n[s]=h,!0}return!1};if(a&&s){var M=[],A={},N=function(e){return M.push(e)},_=function(){return M.shift()};for(i.forEach(function(e){return M.push(e)});M.length>0;){var S=_(),k=C(S,A);if(k)S.outgoers().filter(function(e){return e.isNode()&&r.has(e)}).forEach(N);else if(null===k){ct("Detected double maximal shift for node `"+S.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var P=0;if(t.avoidOverlap)for(var I=0;I<i.length;I++){var O=i[I].layoutDimensions(t),D=O.w,L=O.h;P=Math.max(P,D,L)}var R={},B=function(e){if(R[e.id()])return R[e.id()];for(var t=Wu(e).depth,n=e.neighborhood(),r=0,o=0,a=0;a<n.length;a++){var s=n[a];if(!s.isEdge()&&!s.isParent()&&i.has(s)){var l=Wu(s);if(null!=l){var u=l.index,c=l.depth;if(null!=u&&null!=c){var h=y[c].length;c<t&&(r+=u/h,o++)}}}}return r/=o=Math.max(1,o),0===o&&(r=0),R[e.id()]=r,r},z=function(e,t){var n=B(e)-B(t);return 0===n?Ee(e.id(),t.id()):n};void 0!==t.depthSort&&(z=t.depthSort);for(var F=y.length,V=0;V<F;V++)y[V].sort(z),T(V);for(var G=[],Y=0;Y<x.length;Y++)G.push(x[Y]);G.length&&(y.unshift(G),F=y.length,function(){for(var e=0;e<F;e++)T(e)}());for(var X=0,$=0;$<F;$++)X=Math.max(y[$].length,X);var U=u.x1+u.w/2,j=u.y1+u.h/2,H=i.reduce(function(e,n){return r=n.boundingBox({includeLabels:t.nodeDimensionsIncludeLabels}),{w:-1===e.w?r.w:(e.w+r.w)/2,h:-1===e.h?r.h:(e.h+r.h)/2};var r},{w:-1,h:-1}),W=Math.max(1===F?0:l?(u.h-2*t.padding-H.h)/(F-1):(u.h-2*t.padding-H.h)/(F+1),P),q=y.reduce(function(e,t){return Math.max(e,t.length)},0),K={downward:0,leftward:90,upward:180,rightward:-90};-1===Object.keys(K).indexOf(t.direction)&<("Invalid direction '".concat(t.direction,"' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(K).join(", ")));return r.nodes().layoutPositions(this,t,function(e){return Je(function(e){var n=Wu(e),r=n.depth,i=n.index;if(t.circle){var o=Math.min(u.w/2/F,u.h/2/F),a=(o=Math.max(o,P))*r+o-(F>0&&y[0].length<=3?o/2:0),s=2*Math.PI/y[r].length*i;return 0===r&&1===y[0].length&&(a=1),{x:U+a*Math.cos(s),y:j+a*Math.sin(s)}}var c=y[r].length,h=Math.max(1===c?0:l?(u.w-2*t.padding-H.w)/((t.grid?q:c)-1):(u.w-2*t.padding-H.w)/((t.grid?q:c)+1),P);return{x:U+(i+1-(c+1)/2)*h,y:j+(r+1-(F+1)/2)*W}}(e),u,K[t.direction])}),this};var Zu={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 Qu(e){this.options=Te({},Zu,e)}Qu.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,o=r.nodes().not(":parent");t.sort&&(o=o.sort(t.sort));for(var a,s=cn(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/o.length:t.sweep)/Math.max(1,o.length-1),h=0,d=0;d<o.length;d++){var f=o[d].layoutDimensions(t),p=f.w,g=f.h;h=Math.max(h,p,g)}if(a=te(t.radius)?t.radius:o.length<=1?0:Math.min(s.h,s.w)/2-h,o.length>1&&t.avoidOverlap){h*=1.75;var v=Math.cos(c)-Math.cos(0),y=Math.sin(c)-Math.sin(0),m=Math.sqrt(h*h/(v*v+y*y));a=Math.max(m,a)}return r.nodes().layoutPositions(this,t,function(e,n){var r=t.startAngle+n*c*(i?1:-1),o=a*Math.cos(r),s=a*Math.sin(r);return{x:l+o,y:u+s}}),this};var Ju,ec={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 tc(e){this.options=Te({},ec,e)}tc.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,o=i.nodes().not(":parent"),a=cn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s=a.x1+a.w/2,l=a.y1+a.h/2,u=[],c=0,h=0;h<o.length;h++){var d,f=o[h];d=t.concentric(f),u.push({value:d,node:f}),f._private.scratch.concentric=d}o.updateStyle();for(var p=0;p<o.length;p++){var g=o[p].layoutDimensions(t);c=Math.max(c,g.w,g.h)}u.sort(function(e,t){return t.value-e.value});for(var v=t.levelWidth(o),y=[[]],m=y[0],b=0;b<u.length;b++){var x=u[b];if(m.length>0)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,T=(Math.min(a.w,a.h)/2-w)/(y.length+E?1:0);w=Math.min(w,T)}for(var C=0,M=0;M<y.length;M++){var A=y[M],N=void 0===t.sweep?2*Math.PI-2*Math.PI/A.length:t.sweep,_=A.dTheta=N/Math.max(1,A.length-1);if(A.length>1&&t.avoidOverlap){var S=Math.cos(_)-Math.cos(0),k=Math.sin(_)-Math.sin(0),P=Math.sqrt(w*w/(S*S+k*k));C=Math.max(P,C)}A.r=C,C+=w}if(t.equidistant){for(var I=0,O=0,D=0;D<y.length;D++){var L=y[D].r-O;I=Math.max(I,L)}O=0;for(var R=0;R<y.length;R++){var B=y[R];0===R&&(O=B.r),B.r=O,O+=I}}for(var z={},F=0;F<y.length;F++)for(var V=y[F],G=V.dTheta,Y=V.r,X=0;X<V.length;X++){var $=V[X],U=t.startAngle+(n?1:-1)*G*X,j={x:s+Y*Math.cos(U),y:l+Y*Math.sin(U)};z[$.node.id()]=j}return i.nodes().layoutPositions(this,t,function(e){var t=e.id();return z[t]}),this};var nc={ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,t){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!1,randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:1e3,initialTemp:1e3,coolingFactor:.99,minTemp:1};function rc(e){this.options=Te({},nc,e),this.options.layout=this;var t=this.options.eles.nodes(),n=this.options.eles.edges().filter(function(e){var n=e.source().data("id"),r=e.target().data("id"),i=t.hasElementWithId(n),o=t.hasElementWithId(r);return!i||!o});this.options.eles=this.options.eles.not(n)}rc.prototype.run=function(){var e=this.options,t=e.cy,n=this;n.stopped=!1,!0!==e.animate&&!1!==e.animate||n.emit({type:"layoutstart",layout:n}),Ju=!0===e.debug;var r=ic(t,n,e);Ju&&(void 0)(r),e.randomize&&sc(r);var i=Ge(),o=function(){uc(r,t,e),!0===e.fit&&t.fit(e.padding)},a=function(t){return!(n.stopped||t>=e.numIter)&&(cc(r,e),r.temperature=r.temperature*e.coolingFactor,!(r.temperature<e.minTemp))},s=function(){if(!0===e.animate||!1===e.animate)o(),n.one("layoutstop",e.stop),n.emit({type:"layoutstop",layout:n});else{var t=e.eles.nodes(),i=lc(r,e,t);t.layoutPositions(n,e,i)}},l=0,u=!0;if(!0===e.animate){var c=function(){for(var t=0;u&&t<e.refresh;)u=a(l),l++,t++;u?(Ge()-i>=e.animationThreshold&&o(),Ve(c)):(Ec(r,e),s())};c()}else{for(;u;)u=a(l),l++;Ec(r,e),s()}return this},rc.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},rc.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var ic=function(e,t,n){for(var r=n.eles.edges(),i=n.eles.nodes(),o=cn(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),a={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:o.w,clientHeight:o.h,boundingBox:o},s=n.eles.components(),l={},u=0;u<s.length;u++)for(var c=s[u],h=0;h<c.length;h++){l[c[h].id()]=u}for(u=0;u<a.nodeSize;u++){var d=(y=i[u]).layoutDimensions(n);(O={}).isLocked=y.locked(),O.id=y.data("id"),O.parentId=y.data("parent"),O.cmptId=l[y.id()],O.children=[],O.positionX=y.position("x"),O.positionY=y.position("y"),O.offsetX=0,O.offsetY=0,O.height=d.w,O.width=d.h,O.maxX=O.positionX+O.width/2,O.minX=O.positionX-O.width/2,O.maxY=O.positionY+O.height/2,O.minY=O.positionY-O.height/2,O.padLeft=parseFloat(y.style("padding")),O.padRight=parseFloat(y.style("padding")),O.padTop=parseFloat(y.style("padding")),O.padBottom=parseFloat(y.style("padding")),O.nodeRepulsion=Q(n.nodeRepulsion)?n.nodeRepulsion(y):n.nodeRepulsion,a.layoutNodes.push(O),a.idToIndex[O.id]=u}var f=[],p=0,g=-1,v=[];for(u=0;u<a.nodeSize;u++){var y,m=(y=a.layoutNodes[u]).parentId;null!=m?a.layoutNodes[a.idToIndex[m]].children.push(y.id):(f[++g]=y.id,v.push(y.id))}for(a.graphSet.push(v);p<=g;){var b=f[p++],x=a.idToIndex[b],w=a.layoutNodes[x].children;if(w.length>0){a.graphSet.push(w);for(u=0;u<w.length;u++)f[++g]=w[u]}}for(u=0;u<a.graphSet.length;u++){var E=a.graphSet[u];for(h=0;h<E.length;h++){var T=a.idToIndex[E[h]];a.indexToGraph[T]=u}}for(u=0;u<a.edgeSize;u++){var C=r[u],M={};M.id=C.data("id"),M.sourceId=C.data("source"),M.targetId=C.data("target");var A=Q(n.idealEdgeLength)?n.idealEdgeLength(C):n.idealEdgeLength,N=Q(n.edgeElasticity)?n.edgeElasticity(C):n.edgeElasticity,_=a.idToIndex[M.sourceId],S=a.idToIndex[M.targetId];if(a.indexToGraph[_]!=a.indexToGraph[S]){for(var k=oc(M.sourceId,M.targetId,a),P=a.graphSet[k],I=0,O=a.layoutNodes[_];-1===P.indexOf(O.id);)O=a.layoutNodes[a.idToIndex[O.parentId]],I++;for(O=a.layoutNodes[S];-1===P.indexOf(O.id);)O=a.layoutNodes[a.idToIndex[O.parentId]],I++;A*=I*n.nestingFactor}M.idealLength=A,M.elasticity=N,a.layoutEdges.push(M)}return a},oc=function(e,t,n){var r=ac(e,t,0,n);return 2>r.count?0:r.graph},ac=function(e,t,n,r){var i=r.graphSet[n];if(-1<i.indexOf(e)&&-1<i.indexOf(t))return{count:2,graph:n};for(var o=0,a=0;a<i.length;a++){var s=i[a],l=r.idToIndex[s],u=r.layoutNodes[l].children;if(0!==u.length){var c=r.indexToGraph[r.idToIndex[u[0]]],h=ac(e,t,c,r);if(0!==h.count){if(1!==h.count)return h;if(2===++o)break}}}return{count:o,graph:n}},sc=function(e,t){for(var n=e.clientWidth,r=e.clientHeight,i=0;i<e.nodeSize;i++){var o=e.layoutNodes[i];0!==o.children.length||o.isLocked||(o.positionX=Math.random()*n,o.positionY=Math.random()*r)}},lc=function(e,t,n){var r=e.boundingBox,i={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return t.boundingBox&&(n.forEach(function(t){var n=e.layoutNodes[e.idToIndex[t.data("id")]];i.x1=Math.min(i.x1,n.positionX),i.x2=Math.max(i.x2,n.positionX),i.y1=Math.min(i.y1,n.positionY),i.y2=Math.max(i.y2,n.positionY)}),i.w=i.x2-i.x1,i.h=i.y2-i.y1),function(n,o){var a=e.layoutNodes[e.idToIndex[n.data("id")]];if(t.boundingBox){var s=0===i.w?.5:(a.positionX-i.x1)/i.w,l=0===i.h?.5:(a.positionY-i.y1)/i.h;return{x:r.x1+s*r.w,y:r.y1+l*r.h}}return{x:a.positionX,y:a.positionY}}},uc=function(e,t,n){var r=n.layout,i=n.eles.nodes(),o=lc(e,n,i);i.positions(o),!0!==e.ready&&(e.ready=!0,r.one("layoutready",n.ready),r.emit({type:"layoutready",layout:this}))},cc=function(e,t,n){hc(e,t),vc(e),yc(e,t),mc(e),bc(e)},hc=function(e,t){for(var n=0;n<e.graphSet.length;n++)for(var r=e.graphSet[n],i=r.length,o=0;o<i;o++)for(var a=e.layoutNodes[e.idToIndex[r[o]]],s=o+1;s<i;s++){var l=e.layoutNodes[e.idToIndex[r[s]]];fc(a,l,e,t)}},dc=function(e){return-e+2*e*Math.random()},fc=function(e,t,n,r){if(e.cmptId===t.cmptId||n.isCompound){var i=t.positionX-e.positionX,o=t.positionY-e.positionY;0===i&&0===o&&(i=dc(1),o=dc(1));var a=pc(e,t,i,o);if(a>0)var s=(u=r.nodeOverlap*a)*i/(g=Math.sqrt(i*i+o*o)),l=u*o/g;else{var u,c=gc(e,i,o),h=gc(t,-1*i,-1*o),d=h.x-c.x,f=h.y-c.y,p=d*d+f*f,g=Math.sqrt(p);s=(u=(e.nodeRepulsion+t.nodeRepulsion)/p)*d/g,l=u*f/g}e.isLocked||(e.offsetX-=s,e.offsetY-=l),t.isLocked||(t.offsetX+=s,t.offsetY+=l)}},pc=function(e,t,n,r){if(n>0)var i=e.maxX-t.minX;else i=t.maxX-e.minX;if(r>0)var o=e.maxY-t.minY;else o=t.maxY-e.minY;return i>=0&&o>=0?Math.sqrt(i*i+o*o):0},gc=function(e,t,n){var r=e.positionX,i=e.positionY,o=e.height||1,a=e.width||1,s=n/t,l=o/a,u={};return 0===t&&0<n||0===t&&0>n?(u.x=r,u.y=i+o/2,u):0<t&&-1*l<=s&&s<=l?(u.x=r+a/2,u.y=i+a*n/2/t,u):0>t&&-1*l<=s&&s<=l?(u.x=r-a/2,u.y=i-a*n/2/t,u):0<n&&(s<=-1*l||s>=l)?(u.x=r+o*t/2/n,u.y=i+o/2,u):0>n&&(s<=-1*l||s>=l)?(u.x=r-o*t/2/n,u.y=i-o/2,u):u},vc=function(e,t){for(var n=0;n<e.edgeSize;n++){var r=e.layoutEdges[n],i=e.idToIndex[r.sourceId],o=e.layoutNodes[i],a=e.idToIndex[r.targetId],s=e.layoutNodes[a],l=s.positionX-o.positionX,u=s.positionY-o.positionY;if(0!==l||0!==u){var c=gc(o,l,u),h=gc(s,-1*l,-1*u),d=h.x-c.x,f=h.y-c.y,p=Math.sqrt(d*d+f*f),g=Math.pow(r.idealLength-p,2)/r.elasticity;if(0!==p)var v=g*d/p,y=g*f/p;else v=0,y=0;o.isLocked||(o.offsetX+=v,o.offsetY+=y),s.isLocked||(s.offsetX-=v,s.offsetY-=y)}}},yc=function(e,t){if(0!==t.gravity)for(var n=0;n<e.graphSet.length;n++){var r=e.graphSet[n],i=r.length;if(0===n)var o=e.clientHeight/2,a=e.clientWidth/2;else{var s=e.layoutNodes[e.idToIndex[r[0]]],l=e.layoutNodes[e.idToIndex[s.parentId]];o=l.positionX,a=l.positionY}for(var u=0;u<i;u++){var c=e.layoutNodes[e.idToIndex[r[u]]];if(!c.isLocked){var h=o-c.positionX,d=a-c.positionY,f=Math.sqrt(h*h+d*d);if(f>1){var p=t.gravity*h/f,g=t.gravity*d/f;c.offsetX+=p,c.offsetY+=g}}}}},mc=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 o=n[r++],a=e.idToIndex[o],s=e.layoutNodes[a],l=s.children;if(0<l.length&&!s.isLocked){for(var u=s.offsetX,c=s.offsetY,h=0;h<l.length;h++){var d=e.layoutNodes[e.idToIndex[l[h]]];d.offsetX+=u,d.offsetY+=c,n[++i]=l[h]}s.offsetX=0,s.offsetY=0}}},bc=function(e,t){for(var n=0;n<e.nodeSize;n++){0<(i=e.layoutNodes[n]).children.length&&(i.maxX=void 0,i.minX=void 0,i.maxY=void 0,i.minY=void 0)}for(n=0;n<e.nodeSize;n++){if(!(0<(i=e.layoutNodes[n]).children.length||i.isLocked)){var r=xc(i.offsetX,i.offsetY,e.temperature);i.positionX+=r.x,i.positionY+=r.y,i.offsetX=0,i.offsetY=0,i.minX=i.positionX-i.width,i.maxX=i.positionX+i.width,i.minY=i.positionY-i.height,i.maxY=i.positionY+i.height,wc(i,e)}}for(n=0;n<e.nodeSize;n++){var i;0<(i=e.layoutNodes[n]).children.length&&!i.isLocked&&(i.positionX=(i.maxX+i.minX)/2,i.positionY=(i.maxY+i.minY)/2,i.width=i.maxX-i.minX,i.height=i.maxY-i.minY)}},xc=function(e,t,n){var r=Math.sqrt(e*e+t*t);if(r>n)var i={x:n*e/r,y:n*t/r};else i={x:e,y:t};return i},wc=function(e,t){var n=e.parentId;if(null!=n){var r=t.layoutNodes[t.idToIndex[n]],i=!1;return(null==r.maxX||e.maxX+r.padRight>r.maxX)&&(r.maxX=e.maxX+r.padRight,i=!0),(null==r.minX||e.minX-r.padLeft<r.minX)&&(r.minX=e.minX-r.padLeft,i=!0),(null==r.maxY||e.maxY+r.padBottom>r.maxY)&&(r.maxY=e.maxY+r.padBottom,i=!0),(null==r.minY||e.minY-r.padTop<r.minY)&&(r.minY=e.minY-r.padTop,i=!0),i?wc(r,t):void 0}},Ec=function(e,t){for(var n=e.layoutNodes,r=[],i=0;i<n.length;i++){var o=n[i],a=o.cmptId;(r[a]=r[a]||[]).push(o)}var s=0;for(i=0;i<r.length;i++){if(g=r[i]){g.x1=1/0,g.x2=-1/0,g.y1=1/0,g.y2=-1/0;for(var l=0;l<g.length;l++){var u=g[l];g.x1=Math.min(g.x1,u.positionX-u.width/2),g.x2=Math.max(g.x2,u.positionX+u.width/2),g.y1=Math.min(g.y1,u.positionY-u.height/2),g.y2=Math.max(g.y2,u.positionY+u.height/2)}g.w=g.x2-g.x1,g.h=g.y2-g.y1,s+=g.w*g.h}}r.sort(function(e,t){return t.w*t.h-e.w*e.h});var c=0,h=0,d=0,f=0,p=Math.sqrt(s)*e.clientWidth/e.clientHeight;for(i=0;i<r.length;i++){var g;if(g=r[i]){for(l=0;l<g.length;l++){(u=g[l]).isLocked||(u.positionX+=c-g.x1,u.positionY+=h-g.y1)}c+=g.w+t.componentSpacing,d+=g.w+t.componentSpacing,f=Math.max(f,g.h),d>p&&(h+=f+t.componentSpacing,c=0,d=0,f=0)}}},Tc={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 Cc(e){this.options=Te({},Tc,e)}Cc.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 o=cn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(0===o.h||0===o.w)r.nodes().layoutPositions(this,t,function(e){return{x:o.x1,y:o.y1}});else{var a=i.size(),s=Math.sqrt(a*o.h/o.w),l=Math.round(s),u=Math.round(o.w/o.h*s),c=function(e){if(null==e)return Math.min(l,u);Math.min(l,u)==l?l=e:u=e},h=function(e){if(null==e)return Math.max(l,u);Math.max(l,u)==l?l=e:u=e},d=t.rows,f=null!=t.cols?t.cols:t.columns;if(null!=d&&null!=f)l=d,u=f;else if(null!=d&&null==f)l=d,u=Math.ceil(a/l);else if(null==d&&null!=f)u=f,l=Math.ceil(a/u);else if(u*l>a){var p=c(),g=h();(p-1)*g>=a?c(p-1):(g-1)*p>=a&&h(g-1)}else for(;u*l<a;){var v=c(),y=h();(y+1)*v>=a?h(y+1):c(v+1)}var m=o.w/u,b=o.h/l;if(t.condense&&(m=0,b=0),t.avoidOverlap)for(var x=0;x<i.length;x++){var w=i[x],E=w._private.position;null!=E.x&&null!=E.y||(E.x=0,E.y=0);var T=w.layoutDimensions(t),C=t.avoidOverlapPadding,M=T.w+C,A=T.h+C;m=Math.max(m,M),b=Math.max(b,A)}for(var N={},_=function(e,t){return!!N["c-"+e+"-"+t]},S=function(e,t){N["c-"+e+"-"+t]=!0},k=0,P=0,I=function(){++P>=u&&(P=0,k++)},O={},D=0;D<i.length;D++){var L=i[D],R=t.position(L);if(R&&(void 0!==R.row||void 0!==R.col)){var B={row:R.row,col:R.col};if(void 0===B.col)for(B.col=0;_(B.row,B.col);)B.col++;else if(void 0===B.row)for(B.row=0;_(B.row,B.col);)B.row++;O[L.id()]=B,S(B.row,B.col)}}i.layoutPositions(this,t,function(e,t){var n,r;if(e.locked()||e.isParent())return!1;var i=O[e.id()];if(i)n=i.col*m+m/2+o.x1,r=i.row*b+b/2+o.y1;else{for(;_(k,P);)I();n=P*m+m/2+o.x1,r=k*b+b/2+o.y1,S(k,P),I()}return{x:n,y:r}})}return this};var Mc={ready:function(){},stop:function(){}};function Ac(e){this.options=Te({},Mc,e)}Ac.prototype.run=function(){var e=this.options,t=e.eles,n=this;return e.cy,n.emit("layoutstart"),t.nodes().positions(function(){return{x:0,y:0}}),n.one("layoutready",e.ready),n.emit("layoutready"),n.one("layoutstop",e.stop),n.emit("layoutstop"),this},Ac.prototype.stop=function(){return this};var Nc={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,spacingFactor: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 _c(e){this.options=Te({},Nc,e)}_c.prototype.run=function(){var e=this.options,t=e.eles.nodes(),n=Q(e.positions);return t.layoutPositions(this,e,function(t,r){var i=function(t){if(null==e.positions)return function(e){return{x:e.x,y:e.y}}(t.position());if(n)return e.positions(t);var r=e.positions[t._private.data.id];return r??null}(t);return!t.locked()&&null!=i&&i}),this};var Sc={fit:!0,padding:30,boundingBox: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 kc(e){this.options=Te({},Sc,e)}kc.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=cn(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});return n.nodes().layoutPositions(this,e,function(e,t){return{x:r.x1+Math.round(Math.random()*r.w),y:r.y1+Math.round(Math.random()*r.h)}}),this};var Pc=[{name:"breadthfirst",impl:Ku},{name:"circle",impl:Qu},{name:"concentric",impl:tc},{name:"cose",impl:rc},{name:"grid",impl:Cc},{name:"null",impl:Ac},{name:"preset",impl:_c},{name:"random",impl:kc}];function Ic(e){this.options=e,this.notifications=0}var Oc=function(){},Dc=function(){throw new Error("A headless instance can not render images")};Ic.prototype={recalculateRenderedStyle:Oc,notify:function(){this.notifications++},init:Oc,isHeadless:function(){return!0},getAllInBox:function(){return[]},hitTestAt:function(){return[]},png:Dc,jpg:Dc};var Lc={arrowShapeWidth:.3,registerArrowShapes:function(){var e=this.arrowShapes={},t=this,n=function(e,t,n,r,i,o,a){var s=i.x-n/2-a,l=i.x+n/2+a,u=i.y-n/2-a,c=i.y+n/2+a;return s<=e&&e<=l&&u<=t&&t<=c},r=function(e,t,n,r,i){var o=e*Math.cos(r)-t*Math.sin(r),a=(e*Math.sin(r)+t*Math.cos(r))*n;return{x:o*n+i.x,y:a+i.y}},i=function(e,t,n,i){for(var o=[],a=0;a<e.length;a+=2){var s=e[a],l=e[a+1];o.push(r(s,l,t,n,i))}return o},o=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r.x,r.y)}return t},a=function(e,t){return e.pstyle("width").pfValue*Ru(e,t)*2},s=function(r,s){Z(s)&&(s=e[s]),e[r]=Te({name:r,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(e,t,n,r,a,s){var l=o(i(this.points,n+2*s,r,a));return Nn(e,t,l)},roughCollide:n,draw:function(e,n,r,o){var a=i(this.points,n,r,o);t.arrowShapeImpl("polygon")(e,a)},spacing:function(e,t){return 0},gap:a},s)};s("none",{collide:ot,roughCollide:ot,draw:st,spacing:at,gap:at}),s("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),s("arrow","triangle"),s("triangle-backcurve",{points:e.triangle.points,controlPoint:[0,-.15],roughCollide:n,draw:function(e,n,o,a,s){var l=i(this.points,n,o,a),u=this.controlPoint,c=r(u[0],u[1],n,o,a);t.arrowShapeImpl(this.name)(e,l,c)},gap:function(e,t){return.8*a(e,t)}}),s("triangle-tee",{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(e,t,n,r,a,s,l){var u=o(i(this.points,n+2*l,r,a)),c=o(i(this.pointsTee,n+2*l,r,a));return Nn(e,t,u)||Nn(e,t,c)},draw:function(e,n,r,o,a){var s=i(this.points,n,r,o),l=i(this.pointsTee,n,r,o);t.arrowShapeImpl(this.name)(e,s,l)}}),s("circle-triangle",{radius:.15,pointsTr:[0,-.15,.15,-.45,-.15,-.45,0,-.15],collide:function(e,t,n,r,a,s,l){var u=a,c=Math.pow(u.x-e,2)+Math.pow(u.y-t,2)<=Math.pow((n+2*l)*this.radius,2),h=o(i(this.points,n+2*l,r,a));return Nn(e,t,h)||c},draw:function(e,n,r,o,a){var s=i(this.pointsTr,n,r,o);t.arrowShapeImpl(this.name)(e,s,o.x,o.y,this.radius*n)},spacing:function(e,n){return t.getArrowWidth(e.pstyle("width").pfValue,Ru(e,n))*this.radius}}),s("triangle-cross",{points:[0,0,.15,-.3,-.15,-.3,0,0],baseCrossLinePts:[-.15,-.4,-.15,-.4,.15,-.4,.15,-.4],crossLinePts:function(e,t){var n=this.baseCrossLinePts.slice(),r=t/e;return n[3]=n[3]-r,n[5]=n[5]-r,n},collide:function(e,t,n,r,a,s,l){var u=o(i(this.points,n+2*l,r,a)),c=o(i(this.crossLinePts(n,s),n+2*l,r,a));return Nn(e,t,u)||Nn(e,t,c)},draw:function(e,n,r,o,a){var s=i(this.points,n,r,o),l=i(this.crossLinePts(n,a),n,r,o);t.arrowShapeImpl(this.name)(e,s,l)}}),s("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(e,t){return.525*a(e,t)}}),s("circle",{radius:.15,collide:function(e,t,n,r,i,o,a){var s=i;return Math.pow(s.x-e,2)+Math.pow(s.y-t,2)<=Math.pow((n+2*a)*this.radius,2)},draw:function(e,n,r,i,o){t.arrowShapeImpl(this.name)(e,i.x,i.y,this.radius*n)},spacing:function(e,n){return t.getArrowWidth(e.pstyle("width").pfValue,Ru(e,n))*this.radius}}),s("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(e,t){return 1},gap:function(e,t){return 1}}),s("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),s("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(e,t){return e.pstyle("width").pfValue*Ru(e,t)}}),s("chevron",{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(e,t){return.95*e.pstyle("width").pfValue*Ru(e,t)}})}},Rc={projectIntoViewport:function(e,t){var n=this.cy,r=this.findContainerClientCoords(),i=r[0],o=r[1],a=r[4],s=n.pan(),l=n.zoom();return[((e-i)/a-s.x)/l,((t-o)/a-s.y)/l]},findContainerClientCoords:function(){if(this.containerBB)return this.containerBB;var e=this.container,t=e.getBoundingClientRect(),n=this.cy.window().getComputedStyle(e),r=function(e){return parseFloat(n.getPropertyValue(e))},i=r("padding-left"),o=r("padding-right"),a=r("padding-top"),s=r("padding-bottom"),l=r("border-left-width"),u=r("border-right-width"),c=r("border-top-width"),h=(r("border-bottom-width"),e.clientWidth),d=e.clientHeight,f=i+o,p=a+s,g=l+u,v=t.width/(h+g),y=h-f,m=d-p,b=t.left+i+l,x=t.top+a+c;return this.containerBB=[b,x,y,m,v]},invalidateContainerClientCoordsCache:function(){this.containerBB=null},getLabelHitPolygon:function(e,t,n){var r=e._private,i=t?t+"-":"";e.boundingBox();var o=r.labelBounds[t||"main"];if(!o)return null;var a=mt(r.rscratch,"labelX",t),s=mt(r.rscratch,"labelY",t),l=mt(r.rscratch,"labelAngle",t),u=e.pstyle(i+"text-margin-x").pfValue,c=e.pstyle(i+"text-margin-y").pfValue;return $n(o,a,s,l,u,c,n)},checkLabelHitAt:function(e,t,n,r,i){var o=r?r+"-":"",a=e.pstyle(o+"label").value;if(!("yes"===e.pstyle("text-events").strValue)||!a)return!1;var s=this.getLabelHitPolygon(e,r,i);if(!s)return!1;for(var l=[],u=0;u<s.length;u++)l.push(s[u].x,s[u].y);return Nn(t,n,l)},checkNodeHitAt:function(e,t,n,r){var i=e.outerWidth()+2*r,o=e.outerHeight()+2*r,a=e.position();if(a.x-i/2<=t&&t<=a.x+i/2&&a.y-o/2<=n&&n<=a.y+o/2){var s="auto"===e.pstyle("corner-radius").value?"auto":e.pstyle("corner-radius").pfValue;return this.nodeShapes[this.getNodeShape(e)].checkPoint(t,n,0,i,o,a.x,a.y,s,e._private.rscratch)}return!1},checkEdgeHitAt:function(e,t,n,r){var i,o=e._private.rscratch,a=e.pstyle("width").pfValue,s=a/2+r,l=s*s,u=2*s;if("segments"===o.edgeType||"straight"===o.edgeType||"haystack"===o.edgeType){for(var c=o.allpts,h=0;h+3<c.length;h+=2)if(Tn(t,n,c[h],c[h+1],c[h+2],c[h+3],u)&&l>(i=An(t,n,c[h],c[h+1],c[h+2],c[h+3])))return{sqDist:i}}else if("bezier"===o.edgeType||"multibezier"===o.edgeType||"self"===o.edgeType||"compound"===o.edgeType)for(var d=o.allpts,f=0;f+5<d.length;f+=4)if(Cn(t,n,d[f],d[f+1],d[f+2],d[f+3],d[f+4],d[f+5],u)&&l>(i=Mn(t,n,d[f],d[f+1],d[f+2],d[f+3],d[f+4],d[f+5])))return{sqDist:i};for(var p=[{name:"source",x:o.arrowStartX,y:o.arrowStartY,angle:o.srcArrowAngle},{name:"target",x:o.arrowEndX,y:o.arrowEndY,angle:o.tgtArrowAngle},{name:"mid-source",x:o.midX,y:o.midY,angle:o.midsrcArrowAngle},{name:"mid-target",x:o.midX,y:o.midY,angle:o.midtgtArrowAngle}],g=0;g<p.length;g++){var v=p[g],y=this.arrowShapes[e.pstyle(v.name+"-arrow-shape").value],m=a,b=this.getArrowWidth(a,Ru(e,v.name));if(y.roughCollide(t,n,b,v.angle,{x:v.x,y:v.y},m,r)&&y.collide(t,n,b,v.angle,{x:v.x,y:v.y},m,r))return{sqDist:null}}return null},hitTestAt:function(e,t,n,r){for(var i=this,o=i.cy.zoom(),a=r||{},s=a.isTouch,l=!1!==a.includeBody,u=!1!==a.includeMainLabels,c=!1!==a.includeSourceLabels,h=!1!==a.includeTargetLabels,d=(s?8:2)/o,f=(s?8:2)/o,p=(s?24:8)/o,g=new Set,v=0;v<n.length;v++)g.add(n[v]._private.data.id);for(var y=i.getCachedZSortedEles().interactive,m=[],b=y.length-1;b>=0;b--){var x=y[b];if(g.has(x._private.data.id)){var w=!1;x.isNode()?(l&&(w=i.checkNodeHitAt(x,e,t,d)),!w&&u&&(w=i.checkLabelHitAt(x,e,t,null,f))):(l&&(w=null!=i.checkEdgeHitAt(x,e,t,p)),!w&&u&&(w=i.checkLabelHitAt(x,e,t,null,f)),!w&&c&&(w=i.checkLabelHitAt(x,e,t,"source",f)),!w&&h&&(w=i.checkLabelHitAt(x,e,t,"target",f))),w&&m.push(x)}}return m},findNearestElement:function(e,t,n,r){return this.findNearestElements(e,t,n,r)[0]},findNearestElements:function(e,t,n,r){var i,o,a=this,s=this,l=s.getCachedZSortedEles(),u=[],c=s.cy.zoom(),h=s.cy.hasCompoundNodes(),d=(r?24:8)/c,f=(r?8:2)/c,p=(r?8:2)/c,g=1/0;function v(e,t){if(e.isNode()){if(o)return;o=e,u.push(e)}if(e.isEdge()&&(null==t||t<g))if(i){if(i.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value&&i.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value)for(var n=0;n<u.length;n++)if(u[n].isEdge()){u[n]=e,i=e,g=null!=t?t:g;break}}else u.push(e),i=e,g=null!=t?t:g}function y(n){if(s.checkNodeHitAt(n,e,t,f))return v(n,0),!0}function m(n){var r,i=n._private,o=i.rscratch,l=n.pstyle("width").pfValue,c=l/2+d,f=c*c,p=2*c,g=i.source,m=i.target;if("segments"===o.edgeType||"straight"===o.edgeType||"haystack"===o.edgeType){for(var b=o.allpts,x=0;x+3<b.length;x+=2)if(Tn(e,t,b[x],b[x+1],b[x+2],b[x+3],p)&&f>(r=An(e,t,b[x],b[x+1],b[x+2],b[x+3])))return v(n,r),!0}else if("bezier"===o.edgeType||"multibezier"===o.edgeType||"self"===o.edgeType||"compound"===o.edgeType)for(b=o.allpts,x=0;x+5<o.allpts.length;x+=4)if(Cn(e,t,b[x],b[x+1],b[x+2],b[x+3],b[x+4],b[x+5],p)&&f>(r=Mn(e,t,b[x],b[x+1],b[x+2],b[x+3],b[x+4],b[x+5])))return v(n,r),!0;g=g||i.source,m=m||i.target;var w=[{name:"source",x:o.arrowStartX,y:o.arrowStartY,angle:o.srcArrowAngle},{name:"target",x:o.arrowEndX,y:o.arrowEndY,angle:o.tgtArrowAngle},{name:"mid-source",x:o.midX,y:o.midY,angle:o.midsrcArrowAngle},{name:"mid-target",x:o.midX,y:o.midY,angle:o.midtgtArrowAngle}];for(x=0;x<w.length;x++){var E=w[x],T=s.arrowShapes[n.pstyle(E.name+"-arrow-shape").value],C=n.pstyle("width").pfValue,M=a.getArrowWidth(l,Ru(n,E.name));if(T.roughCollide(e,t,M,E.angle,{x:E.x,y:E.y},C,d)&&T.collide(e,t,M,E.angle,{x:E.x,y:E.y},C,d))return v(n),!0}h&&u.length>0&&(y(g),y(m))}function b(n,r){if(a.checkLabelHitAt(n,e,t,r,p))return v(n),!0}n&&(l=l.interactive);for(var x=l.length-1;x>=0;x--){var w=l[x];w.isNode()?y(w)||b(w):m(w)||b(w)||b(w,"source")||b(w,"target")}return u},getAllInBox:function(e,t,n,r){var i=this,o=this.getCachedZSortedEles().interactive,a=2/this.cy.zoom(),s=[],l=Math.min(e,n),u=Math.max(e,n),c=Math.min(t,r),d=Math.max(t,r),f=cn({x1:e=l,y1:t=c,x2:n=u,y2:r=d}),p=[{x:f.x1,y:f.y1},{x:f.x2,y:f.y1},{x:f.x2,y:f.y2},{x:f.x1,y:f.y2}],g=[[p[0],p[1]],[p[1],p[2]],[p[2],p[3]],[p[3],p[0]]];function v(e,t){return i.getLabelHitPolygon(e,t,a)}function y(e,t,n,r){function i(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return i(e,n,r)!==i(t,n,r)&&i(e,t,n)!==i(e,t,r)}for(var m=0;m<o.length;m++){var b=o[m];if(b.isNode()){var x=b,w="yes"===x.pstyle("text-events").strValue,E=x.pstyle("box-selection").strValue,T="yes"===x.pstyle("box-select-labels").strValue;if("none"===E)continue;var C=("overlap"===E||T)&&w,M=x.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:C});if("contain"===E){var A=!1;if(T&&w){var N=v(x);N&&Un(N,p)&&(s.push(x),A=!0)}!A&&bn(f,M)&&s.push(x)}else if("overlap"===E&&vn(f,M)){var _=x.boundingBox({includeNodes:!0,includeEdges:!0,includeLabels:!1,includeMainLabels:!1,includeSourceLabels:!1,includeTargetLabels:!1});if(Un([{x:_.x1,y:_.y1},{x:_.x2,y:_.y1},{x:_.x2,y:_.y2},{x:_.x1,y:_.y2}],p))s.push(x);else{var S=v(x);S&&Un(S,p)&&s.push(x)}}}else{var k=b,P=k._private,I=P.rscratch,O=k.pstyle("box-selection").strValue;if("none"===O)continue;if("contain"===O){if(null!=I.startX&&null!=I.startY&&!yn(f,I.startX,I.startY))continue;if(null!=I.endX&&null!=I.endY&&!yn(f,I.endX,I.endY))continue;if("bezier"===I.edgeType||"multibezier"===I.edgeType||"self"===I.edgeType||"compound"===I.edgeType||"segments"===I.edgeType||"haystack"===I.edgeType){for(var D=P.rstyle.bezierPts||P.rstyle.linePts||P.rstyle.haystackPts,L=!0,R=0;R<D.length;R++)if(!mn(f,D[R])){L=!1;break}L&&s.push(k)}else"straight"===I.edgeType&&s.push(k)}else if("overlap"===O){var B=!1;if(null!=I.startX&&null!=I.startY&&null!=I.endX&&null!=I.endY&&(yn(f,I.startX,I.startY)||yn(f,I.endX,I.endY)))s.push(k),B=!0;else if(!B&&"haystack"===I.edgeType)for(var z=P.rstyle.haystackPts,F=0;F<z.length;F++)if(mn(f,z[F])){s.push(k),B=!0;break}if(!B){var V=P.rstyle.bezierPts||P.rstyle.linePts||P.rstyle.haystackPts;if((!V||V.length<2)&&"straight"===I.edgeType&&null!=I.startX&&null!=I.startY&&null!=I.endX&&null!=I.endY&&(V=[{x:I.startX,y:I.startY},{x:I.endX,y:I.endY}]),!V||V.length<2)continue;for(var G=0;G<V.length-1;G++){for(var Y=V[G],X=V[G+1],$=0;$<g.length;$++){var U=h(g[$],2);if(y(Y,X,U[0],U[1])){s.push(k),B=!0;break}}if(B)break}}}}}return s}},Bc={calculateArrowAngles:function(e){var t,n,r,i,o,a,s=e._private.rscratch,l="haystack"===s.edgeType,u="bezier"===s.edgeType,c="multibezier"===s.edgeType,h="segments"===s.edgeType,d="compound"===s.edgeType,f="self"===s.edgeType;if(l?(r=s.haystackPts[0],i=s.haystackPts[1],o=s.haystackPts[2],a=s.haystackPts[3]):(r=s.arrowStartX,i=s.arrowStartY,o=s.arrowEndX,a=s.arrowEndY),g=s.midX,v=s.midY,h)t=r-s.segpts[0],n=i-s.segpts[1];else if(c||d||f||u){var p=s.allpts;t=r-sn(p[0],p[2],p[4],.1),n=i-sn(p[1],p[3],p[5],.1)}else t=r-g,n=i-v;s.srcArrowAngle=en(t,n);var g=s.midX,v=s.midY;if(l&&(g=(r+o)/2,v=(i+a)/2),t=o-r,n=a-i,h)if((p=s.allpts).length/2%2==0){var y=(M=p.length/2)-2;t=p[M]-p[y],n=p[M+1]-p[y+1]}else if(s.isRound)t=s.midVector[1],n=-s.midVector[0];else{y=(M=p.length/2-1)-2;t=p[M]-p[y],n=p[M+1]-p[y+1]}else if(c||d||f){var m,b,x,w,p=s.allpts;if(s.ctrlpts.length/2%2==0){var E=(T=(C=p.length/2-1)+2)+2;m=sn(p[C],p[T],p[E],0),b=sn(p[C+1],p[T+1],p[E+1],0),x=sn(p[C],p[T],p[E],1e-4),w=sn(p[C+1],p[T+1],p[E+1],1e-4)}else{var T,C;E=(T=p.length/2-1)+2;m=sn(p[C=T-2],p[T],p[E],.4999),b=sn(p[C+1],p[T+1],p[E+1],.4999),x=sn(p[C],p[T],p[E],.5),w=sn(p[C+1],p[T+1],p[E+1],.5)}t=x-m,n=w-b}if(s.midtgtArrowAngle=en(t,n),s.midDispX=t,s.midDispY=n,t*=-1,n*=-1,h)if((p=s.allpts).length/2%2==0);else if(!s.isRound){var M,A=(M=p.length/2-1)+2;t=-(p[A]-p[M]),n=-(p[A+1]-p[M+1])}if(s.midsrcArrowAngle=en(t,n),h)t=o-s.segpts[s.segpts.length-2],n=a-s.segpts[s.segpts.length-1];else if(c||d||f||u){var N=(p=s.allpts).length;t=o-sn(p[N-6],p[N-4],p[N-2],.9),n=a-sn(p[N-5],p[N-3],p[N-1],.9)}else t=o-g,n=a-v;s.tgtArrowAngle=en(t,n)}};Bc.getArrowWidth=Bc.getArrowHeight=function(e,t){var n=this.arrowWidthCache=this.arrowWidthCache||{},r=n[e+", "+t];return r||(r=Math.max(Math.pow(13.37*e,.9),29)*t,n[e+", "+t]=r,r)};var zc,Fc,Vc,Gc,Yc,Xc,$c,Uc,jc,Hc,Wc,qc,Kc,Zc,Qc,Jc,eh,th={},nh={},rh=function(e,t,n){n.x=t.x-e.x,n.y=t.y-e.y,n.len=Math.sqrt(n.x*n.x+n.y*n.y),n.nx=n.x/n.len,n.ny=n.y/n.len,n.ang=Math.atan2(n.ny,n.nx)},ih=function(e,t,n,r,i){var o,a;if(e!==eh?rh(t,e,th):((a=th).x=-1*(o=nh).x,a.y=-1*o.y,a.nx=-1*o.nx,a.ny=-1*o.ny,a.ang=o.ang>0?-(Math.PI-o.ang):Math.PI+o.ang),rh(t,n,nh),Vc=th.nx*nh.ny-th.ny*nh.nx,Gc=th.nx*nh.nx-th.ny*-nh.ny,$c=Math.asin(Math.max(-1,Math.min(1,Vc))),Math.abs($c)<1e-6)return zc=t.x,Fc=t.y,void(jc=Wc=0);Yc=1,Xc=!1,Gc<0?$c<0?$c=Math.PI+$c:($c=Math.PI-$c,Yc=-1,Xc=!0):$c>0&&(Yc=-1,Xc=!0),Wc=void 0!==t.radius?t.radius:r,Uc=$c/2,qc=Math.min(th.len/2,nh.len/2),i?(Hc=Math.abs(Math.cos(Uc)*Wc/Math.sin(Uc)))>qc?(Hc=qc,jc=Math.abs(Hc*Math.sin(Uc)/Math.cos(Uc))):jc=Wc:(Hc=Math.min(qc,Wc),jc=Math.abs(Hc*Math.sin(Uc)/Math.cos(Uc))),Qc=t.x+nh.nx*Hc,Jc=t.y+nh.ny*Hc,zc=Qc-nh.ny*jc*Yc,Fc=Jc+nh.nx*jc*Yc,Kc=t.x+th.nx*Hc,Zc=t.y+th.ny*Hc,eh=t};function oh(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 ah(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}:(ih(e,t,n,r,i),{cx:zc,cy:Fc,radius:jc,startX:Kc,startY:Zc,stopX:Qc,stopY:Jc,startAngle:th.ang+Math.PI/2*Yc,endAngle:nh.ang-Math.PI/2*Yc,counterClockwise:Xc})}var sh=.01,lh=Math.sqrt(.02),uh={};function ch(e){var t=[];if(null!=e){for(var n=0;n<e.length;n+=2){var r=e[n],i=e[n+1];t.push({x:r,y:i})}return t}}uh.findMidptPtsEtc=function(e,t){var n,r=t.posPts,i=t.intersectionPts,o=t.vectorNormInverse,a=e.pstyle("source-endpoint"),s=e.pstyle("target-endpoint"),l=null!=a.units&&null!=s.units;switch(e.pstyle("edge-distances").value){case"node-position":n=r;break;case"intersection":n=i;break;case"endpoints":if(l){var u=h(this.manualEndptToPx(e.source()[0],a),2),c=u[0],d=u[1],f=h(this.manualEndptToPx(e.target()[0],s),2),p=f[0],g=f[1],v={x1:c,y1:d,x2:p,y2:g};o=function(e,t,n,r){var i=r-t,o=n-e,a=Math.sqrt(o*o+i*i);return{x:-i/a,y:o/a}}(c,d,p,g),n=v}else ct("Edge ".concat(e.id()," has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")),n=i}return{midptPts:n,vectorNormInverse:o}},uh.findHaystackPoints=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n._private,i=r.rscratch;if(!i.haystack){var o=2*Math.random()*Math.PI;i.source={x:Math.cos(o),y:Math.sin(o)},o=2*Math.random()*Math.PI,i.target={x:Math.cos(o),y:Math.sin(o)}}var a=r.source,s=r.target,l=a.position(),u=s.position(),c=a.width(),h=s.width(),d=a.height(),f=s.height(),p=n.pstyle("haystack-radius").value/2;i.haystackPts=i.allpts=[i.source.x*c*p+l.x,i.source.y*d*p+l.y,i.target.x*h*p+u.x,i.target.y*f*p+u.y],i.midX=(i.allpts[0]+i.allpts[2])/2,i.midY=(i.allpts[1]+i.allpts[3])/2,i.edgeType="haystack",i.haystack=!0,this.storeEdgeProjections(n),this.calculateArrowAngles(n),this.recalculateEdgeLabelProjections(n),this.calculateLabelAngles(n)}},uh.findSegmentsPoints=function(e,t){var n=e._private.rscratch,r=e.pstyle("segment-weights"),i=e.pstyle("segment-distances"),o=e.pstyle("segment-radii"),a=e.pstyle("radius-type"),s=Math.min(r.pfValue.length,i.pfValue.length),l=o.pfValue[o.pfValue.length-1],u=a.pfValue[a.pfValue.length-1];n.edgeType="segments",n.segpts=[],n.radii=[],n.isArcRadius=[];for(var c=0;c<s;c++){var h=r.pfValue[c],d=i.pfValue[c],f=1-h,p=h,g=this.findMidptPtsEtc(e,t),v=g.midptPts,y=g.vectorNormInverse,m={x:v.x1*f+v.x2*p,y:v.y1*f+v.y2*p};n.segpts.push(m.x+y.x*d,m.y+y.y*d),n.radii.push(void 0!==o.pfValue[c]?o.pfValue[c]:l),n.isArcRadius.push("arc-radius"===(void 0!==a.pfValue[c]?a.pfValue[c]:u))}},uh.findLoopPoints=function(e,t,n,r){var i=e._private.rscratch,o=t.dirCounts,a=t.srcPos,s=e.pstyle("control-point-distances"),l=s?s.pfValue[0]:void 0,u=e.pstyle("loop-direction").pfValue,c=e.pstyle("loop-sweep").pfValue,h=e.pstyle("control-point-step-size").pfValue;i.edgeType="self";var d=n,f=h;r&&(d=0,f=l);var p=u-Math.PI/2,g=p-c/2,v=p+c/2,y=String(u+"_"+c);d=void 0===o[y]?o[y]=0:++o[y],i.ctrlpts=[a.x+1.4*Math.cos(g)*f*(d/3+1),a.y+1.4*Math.sin(g)*f*(d/3+1),a.x+1.4*Math.cos(v)*f*(d/3+1),a.y+1.4*Math.sin(v)*f*(d/3+1)]},uh.findCompoundLoopPoints=function(e,t,n,r){var i=e._private.rscratch;i.edgeType="compound";var o=t.srcPos,a=t.tgtPos,s=t.srcW,l=t.srcH,u=t.tgtW,c=t.tgtH,h=e.pstyle("control-point-step-size").pfValue,d=e.pstyle("control-point-distances"),f=d?d.pfValue[0]:void 0,p=n,g=h;r&&(p=0,g=f);var v={x:o.x-s/2,y:o.y-l/2},y={x:a.x-u/2,y:a.y-c/2},m={x:Math.min(v.x,y.x),y:Math.min(v.y,y.y)},b=Math.max(.5,Math.log(s*sh)),x=Math.max(.5,Math.log(u*sh));i.ctrlpts=[m.x,m.y-(1+Math.pow(50,1.12)/100)*g*(p/3+1)*b,m.x-(1+Math.pow(50,1.12)/100)*g*(p/3+1)*x,m.y]},uh.findStraightEdgePoints=function(e){e._private.rscratch.edgeType="straight"},uh.findBezierPoints=function(e,t,n,r,i){var o=e._private.rscratch,a=e.pstyle("control-point-step-size").pfValue,s=e.pstyle("control-point-distances"),l=e.pstyle("control-point-weights"),u=s&&l?Math.min(s.value.length,l.value.length):1,c=s?s.pfValue[0]:void 0,h=l.value[0],d=r;o.edgeType=d?"multibezier":"bezier",o.ctrlpts=[];for(var f=0;f<u;f++){var p=(.5-t.eles.length/2+n)*a*(i?-1:1),g=void 0,v=nn(p);d&&(c=s?s.pfValue[f]:a,h=l.value[f]);var y=void 0!==(g=r?c:void 0!==c?v*c:void 0)?g:p,m=1-h,b=h,x=this.findMidptPtsEtc(e,t),w=x.midptPts,E=x.vectorNormInverse,T={x:w.x1*m+w.x2*b,y:w.y1*m+w.y2*b};o.ctrlpts.push(T.x+E.x*y,T.y+E.y*y)}},uh.findTaxiPoints=function(e,t){var n=e._private.rscratch;n.edgeType="segments";var r="vertical",i="horizontal",o="leftward",a="rightward",s="downward",l="upward",u=t.posPts,c=t.srcW,h=t.srcH,d=t.tgtW,f=t.tgtH,p="node-position"!==e.pstyle("edge-distances").value,g=e.pstyle("taxi-direction").value,v=g,y=e.pstyle("taxi-turn"),m="%"===y.units,b=y.pfValue,x=b<0,w=e.pstyle("taxi-turn-min-distance").pfValue,E=p?(c+d)/2:0,T=p?(h+f)/2:0,C=u.x2-u.x1,M=u.y2-u.y1,A=function(e,t){return e>0?Math.max(e-t,0):Math.min(e+t,0)},N=A(C,E),_=A(M,T),S=function(e,t,n,r){if(!p)return(e+t)/2;var i=nn(t-e),o=e+i*n/2,a=t-i*r/2;return i*(a-o)>=0?(o+a)/2:(e+t)/2},k=!1;"auto"===v?g=Math.abs(N)>Math.abs(_)?i:r:v===l||v===s?(g=r,k=!0):v!==o&&v!==a||(g=i,k=!0);var P,I=g===r,O=I?_:N,D=I?M:C,L=nn(D),R=!1;(k&&(m||x)||!(v===s&&D<0||v===l&&D>0||v===o&&D>0||v===a&&D<0)||(O=(L*=-1)*Math.abs(O),R=!0),m)?P=(b<0?1+b:b)*O:P=(b<0?O:0)+b*L;var B=function(e){return Math.abs(e)<w||Math.abs(e)>=Math.abs(O)},z=B(P),F=B(Math.abs(O)-Math.abs(P));if((z||F)&&!R)if(I){var V=Math.abs(D)<=h/2,G=Math.abs(C)<=d/2;if(V){var Y=S(u.x1,u.x2,c,d),X=u.y1,$=u.y2;n.segpts=[Y,X,Y,$]}else if(G){var U=S(u.y1,u.y2,h,f),j=u.x1,H=u.x2;n.segpts=[j,U,H,U]}else n.segpts=[u.x1,u.y2]}else{var W=Math.abs(D)<=c/2,q=Math.abs(M)<=f/2;if(W){var K=S(u.y1,u.y2,h,f),Z=u.x1,Q=u.x2;n.segpts=[Z,K,Q,K]}else if(q){var J=S(u.x1,u.x2,c,d),ee=u.y1,te=u.y2;n.segpts=[J,ee,J,te]}else n.segpts=[u.x2,u.y1]}else if(I){var ne=u.y1+P+(p?h/2*L:0),re=u.x1,ie=u.x2;n.segpts=[re,ne,ie,ne]}else{var oe=u.x1+P+(p?c/2*L:0),ae=u.y1,se=u.y2;n.segpts=[oe,ae,oe,se]}if(n.isRound){var le=e.pstyle("taxi-radius").value,ue="arc-radius"===e.pstyle("radius-type").value[0];n.radii=new Array(n.segpts.length/2).fill(le),n.isArcRadius=new Array(n.segpts.length/2).fill(ue)}},uh.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if("bezier"===n.edgeType){var r=t.srcPos,i=t.tgtPos,o=t.srcW,a=t.srcH,s=t.tgtW,l=t.tgtH,u=t.srcShape,c=t.tgtShape,h=t.srcCornerRadius,d=t.tgtCornerRadius,f=t.srcRs,p=t.tgtRs,g=!te(n.startX)||!te(n.startY),v=!te(n.arrowStartX)||!te(n.arrowStartY),y=!te(n.endX)||!te(n.endY),m=!te(n.arrowEndX)||!te(n.arrowEndY),b=e.pstyle("width").pfValue,x=3*this.getArrowWidth(b,Ru(e,"source"))*this.arrowShapeWidth,w=3*this.getArrowWidth(b,Ru(e,"target"))*this.arrowShapeWidth,E=rn({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),T=E<x,C=!1;if(g||v||T){C=!0;var M={x:n.ctrlpts[0]-r.x,y:n.ctrlpts[1]-r.y},A=Math.sqrt(M.x*M.x+M.y*M.y),N={x:M.x/A,y:M.y/A},_=Math.max(o,a),S={x:n.ctrlpts[0]+2*N.x*_,y:n.ctrlpts[1]+2*N.y*_},k=u.intersectLine(r.x,r.y,o,a,S.x,S.y,0,h,f);T?(n.ctrlpts[0]=n.ctrlpts[0]+N.x*(x-E),n.ctrlpts[1]=n.ctrlpts[1]+N.y*(x-E)):(n.ctrlpts[0]=k[0]+N.x*x,n.ctrlpts[1]=k[1]+N.y*x)}var P=rn({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.endX,y:n.endY}),I=P<w;if(y||m||I){C=!0;var O={x:n.ctrlpts[0]-i.x,y:n.ctrlpts[1]-i.y},D=Math.sqrt(O.x*O.x+O.y*O.y),L={x:O.x/D,y:O.y/D},R=Math.max(o,a),B={x:n.ctrlpts[0]+2*L.x*R,y:n.ctrlpts[1]+2*L.y*R},z=c.intersectLine(i.x,i.y,s,l,B.x,B.y,0,d,p);I?(n.ctrlpts[0]=n.ctrlpts[0]+L.x*(w-P),n.ctrlpts[1]=n.ctrlpts[1]+L.y*(w-P)):(n.ctrlpts[0]=z[0]+L.x*w,n.ctrlpts[1]=z[1]+L.y*w)}C&&this.findEndpoints(e)}},uh.storeAllpts=function(e){var t=e._private.rscratch;if("multibezier"===t.edgeType||"bezier"===t.edgeType||"self"===t.edgeType||"compound"===t.edgeType){t.allpts=[],t.allpts.push(t.startX,t.startY);for(var n=0;n+1<t.ctrlpts.length;n+=2)t.allpts.push(t.ctrlpts[n],t.ctrlpts[n+1]),n+3<t.ctrlpts.length&&t.allpts.push((t.ctrlpts[n]+t.ctrlpts[n+2])/2,(t.ctrlpts[n+1]+t.ctrlpts[n+3])/2);var r;t.allpts.push(t.endX,t.endY),t.ctrlpts.length/2%2==0?(r=t.allpts.length/2-1,t.midX=t.allpts[r],t.midY=t.allpts[r+1]):(r=t.allpts.length/2-3,t.midX=sn(t.allpts[r],t.allpts[r+2],t.allpts[r+4],.5),t.midY=sn(t.allpts[r+1],t.allpts[r+3],t.allpts[r+5],.5))}else if("straight"===t.edgeType)t.allpts=[t.startX,t.startY,t.endX,t.endY],t.midX=(t.startX+t.endX+t.arrowStartX+t.arrowEndX)/4,t.midY=(t.startY+t.endY+t.arrowStartY+t.arrowEndY)/4;else if("segments"===t.edgeType){if(t.allpts=[],t.allpts.push(t.startX,t.startY),t.allpts.push.apply(t.allpts,t.segpts),t.allpts.push(t.endX,t.endY),t.isRound){t.roundCorners=[];for(var i=2;i+3<t.allpts.length;i+=2){var o=t.radii[i/2-1],a=t.isArcRadius[i/2-1];t.roundCorners.push(ah({x:t.allpts[i-2],y:t.allpts[i-1]},{x:t.allpts[i],y:t.allpts[i+1],radius:o},{x:t.allpts[i+2],y:t.allpts[i+3]},o,a))}}if(t.segpts.length%4==0){var s=t.segpts.length/2,l=s-2;t.midX=(t.segpts[l]+t.segpts[s])/2,t.midY=(t.segpts[l+1]+t.segpts[s+1])/2}else{var u=t.segpts.length/2-1;if(t.isRound){var c={x:t.segpts[u],y:t.segpts[u+1]},h=t.roundCorners[u/2];if(0===h.radius){var d={x:t.segpts[u+2],y:t.segpts[u+3]};t.midX=c.x,t.midY=c.y,t.midVector=[c.y-d.y,d.x-c.x]}else{var f=[c.x-h.cx,c.y-h.cy],p=h.radius/Math.sqrt(Math.pow(f[0],2)+Math.pow(f[1],2));f=f.map(function(e){return e*p}),t.midX=h.cx+f[0],t.midY=h.cy+f[1],t.midVector=f}}else t.midX=t.segpts[u],t.midY=t.segpts[u+1]}}},uh.checkForInvalidEdgeWarning=function(e){var t=e[0]._private.rscratch;t.nodesOverlap||te(t.startX)&&te(t.startY)&&te(t.endX)&&te(t.endY)?t.loggedErr=!1:t.loggedErr||(t.loggedErr=!0,ct("Edge `"+e.id()+"` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap."))},uh.findEdgeControlPoints=function(e){var t=this;if(e&&0!==e.length){for(var n=this,r=n.cy.hasCompoundNodes(),i=new wt,o=function(e,t){return[].concat(d(e),[t?1:0]).join("-")},a=[],s=[],l=0;l<e.length;l++){var u=e[l],c=u._private,h=u.pstyle("curve-style").value;if(!u.removed()&&u.takesUpSpace())if("haystack"!==h){var f="unbundled-bezier"===h||ve(h,"segments")||"straight"===h||"straight-triangle"===h||ve(h,"taxi"),p="unbundled-bezier"===h||"bezier"===h,g=c.source,v=c.target,y=[g.poolIndex(),v.poolIndex()].sort(),m=o(y,f),b=i.get(m);null==b&&(b={eles:[]},a.push({pairId:y,edgeIsUnbundled:f}),i.set(m,b)),b.eles.push(u),f&&(b.hasUnbundled=!0),p&&(b.hasBezier=!0)}else s.push(u)}for(var x=function(){var e,s=a[w],l=s.pairId,u=s.edgeIsUnbundled,c=o(l,u),h=i.get(c);if(!h.hasUnbundled){var d=h.eles[0].parallelEdges().filter(function(e){return e.isBundledBezier()});yt(h.eles),d.forEach(function(e){return h.eles.push(e)}),h.eles.sort(function(e,t){return e.poolIndex()-t.poolIndex()})}var f=h.eles[0],p=f.source(),g=f.target();if(p.poolIndex()>g.poolIndex()){var v=p;p=g,g=v}var y=h.srcPos=p.position(),m=h.tgtPos=g.position(),b=h.srcW=p.outerWidth(),x=h.srcH=p.outerHeight(),E=h.tgtW=g.outerWidth(),T=h.tgtH=g.outerHeight(),C=h.srcShape=n.nodeShapes[t.getNodeShape(p)],M=h.tgtShape=n.nodeShapes[t.getNodeShape(g)],A=h.srcCornerRadius="auto"===p.pstyle("corner-radius").value?"auto":p.pstyle("corner-radius").pfValue,N=h.tgtCornerRadius="auto"===g.pstyle("corner-radius").value?"auto":g.pstyle("corner-radius").pfValue,_=h.tgtRs=g._private.rscratch,S=h.srcRs=p._private.rscratch;h.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var k=0;k<h.eles.length;k++){var P=h.eles[k],I=P[0]._private.rscratch,O=P.pstyle("curve-style").value,D="unbundled-bezier"===O||ve(O,"segments")||ve(O,"taxi"),L=!p.same(P.source());if(!h.calculatedIntersection&&p!==g&&(h.hasBezier||h.hasUnbundled)){h.calculatedIntersection=!0;var R=C.intersectLine(y.x,y.y,b,x,m.x,m.y,0,A,S),B=h.srcIntn=R,z=M.intersectLine(m.x,m.y,E,T,y.x,y.y,0,N,_),F=h.tgtIntn=z,V=h.intersectionPts={x1:R[0],x2:z[0],y1:R[1],y2:z[1]},G=h.posPts={x1:y.x,x2:m.x,y1:y.y,y2:m.y},Y=z[1]-R[1],X=z[0]-R[0],$=Math.sqrt(X*X+Y*Y);te($)&&$>=lh||($=Math.sqrt(Math.max(X*X,sh)+Math.max(Y*Y,sh)));var U=h.vector={x:X,y:Y},j=h.vectorNorm={x:U.x/$,y:U.y/$},H={x:-j.y,y:j.x};h.nodesOverlap=!te($)||M.checkPoint(R[0],R[1],0,E,T,m.x,m.y,N,_)||C.checkPoint(z[0],z[1],0,b,x,y.x,y.y,A,S),h.vectorNormInverse=H,e={nodesOverlap:h.nodesOverlap,dirCounts:h.dirCounts,calculatedIntersection:!0,hasBezier:h.hasBezier,hasUnbundled:h.hasUnbundled,eles:h.eles,srcPos:m,srcRs:_,tgtPos:y,tgtRs:S,srcW:E,srcH:T,tgtW:b,tgtH:x,srcIntn:F,tgtIntn:B,srcShape:M,tgtShape:C,posPts:{x1:G.x2,y1:G.y2,x2:G.x1,y2:G.y1},intersectionPts:{x1:V.x2,y1:V.y2,x2:V.x1,y2:V.y1},vector:{x:-U.x,y:-U.y},vectorNorm:{x:-j.x,y:-j.y},vectorNormInverse:{x:-H.x,y:-H.y}}}var W=L?e:h;I.nodesOverlap=W.nodesOverlap,I.srcIntn=W.srcIntn,I.tgtIntn=W.tgtIntn,I.isRound=O.startsWith("round"),r&&(p.isParent()||p.isChild()||g.isParent()||g.isChild())&&(p.parents().anySame(g)||g.parents().anySame(p)||p.same(g)&&p.isParent())?t.findCompoundLoopPoints(P,W,k,D):p===g?t.findLoopPoints(P,W,k,D):O.endsWith("segments")?t.findSegmentsPoints(P,W):O.endsWith("taxi")?t.findTaxiPoints(P,W):"straight"===O||!D&&h.eles.length%2==1&&k===Math.floor(h.eles.length/2)?t.findStraightEdgePoints(P):t.findBezierPoints(P,W,k,D,L),t.findEndpoints(P),t.tryToCorrectInvalidPoints(P,W),t.checkForInvalidEdgeWarning(P),t.storeAllpts(P),t.storeEdgeProjections(P),t.calculateArrowAngles(P),t.recalculateEdgeLabelProjections(P),t.calculateLabelAngles(P)}},w=0;w<a.length;w++)x();this.findHaystackPoints(s)}},uh.getSegmentPoints=function(e){var t=e[0]._private.rscratch;if(this.recalculateRenderedStyle(e),"segments"===t.edgeType)return ch(t.segpts)},uh.getControlPoints=function(e){var t=e[0]._private.rscratch;this.recalculateRenderedStyle(e);var n=t.edgeType;if("bezier"===n||"multibezier"===n||"self"===n||"compound"===n)return ch(t.ctrlpts)},uh.getEdgeMidpoint=function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),{x:t.midX,y:t.midY}};var hh={manualEndptToPx:function(e,t){var n=e.position(),r=e.outerWidth(),i=e.outerHeight(),o=e._private.rscratch;if(2===t.value.length){var a=[t.pfValue[0],t.pfValue[1]];return"%"===t.units[0]&&(a[0]=a[0]*r),"%"===t.units[1]&&(a[1]=a[1]*i),a[0]+=n.x,a[1]+=n.y,a}var s=t.pfValue[0];s=-Math.PI/2+s;var l=2*Math.max(r,i),u=[n.x+Math.cos(s)*l,n.y+Math.sin(s)*l];return this.nodeShapes[this.getNodeShape(e)].intersectLine(n.x,n.y,r,i,u[0],u[1],0,"auto"===e.pstyle("corner-radius").value?"auto":e.pstyle("corner-radius").pfValue,o)},findEndpoints:function(e){var t,n,r,i,o,a,s,l,u,c=this,h=e.source()[0],d=e.target()[0],f=h.position(),p=d.position(),g=e.pstyle("target-arrow-shape").value,v=e.pstyle("source-arrow-shape").value,y=e.pstyle("target-distance-from-node").pfValue,m=e.pstyle("source-distance-from-node").pfValue,b=h._private.rscratch,x=d._private.rscratch,w=e.pstyle("curve-style").value,E=e._private.rscratch,T=E.edgeType,C=ve(w,"taxi"),M="self"===T||"compound"===T,A="bezier"===T||"multibezier"===T||M,N="bezier"!==T,_="straight"===T||"segments"===T,S="segments"===T,k=A||N||_,P=M||C,I=e.pstyle("source-endpoint"),O=P?"outside-to-node":I.value,D="auto"===h.pstyle("corner-radius").value?"auto":h.pstyle("corner-radius").pfValue,L=e.pstyle("target-endpoint"),R=P?"outside-to-node":L.value,B="auto"===d.pstyle("corner-radius").value?"auto":d.pstyle("corner-radius").pfValue;E.srcManEndpt=I,E.tgtManEndpt=L;var z=null!==(t=2===(null==L||null===(n=L.pfValue)||void 0===n?void 0:n.length)?L.pfValue:null)&&void 0!==t?t:[0,0],F=null!==(r=2===(null==I||null===(i=I.pfValue)||void 0===i?void 0:i.length)?I.pfValue:null)&&void 0!==r?r:[0,0];if(A){var V=[E.ctrlpts[0],E.ctrlpts[1]];a=N?[E.ctrlpts[E.ctrlpts.length-2],E.ctrlpts[E.ctrlpts.length-1]]:V,s=V}else if(_){var G=S?E.segpts.slice(0,2):[p.x+z[0],p.y+z[1]];a=S?E.segpts.slice(E.segpts.length-2):[f.x+F[0],f.y+F[1]],s=G}if("inside-to-node"===R)o=[p.x,p.y];else if(L.units)o=this.manualEndptToPx(d,L);else if("outside-to-line"===R)o=E.tgtIntn;else if("outside-to-node"===R||"outside-to-node-or-label"===R?l=a:"outside-to-line"!==R&&"outside-to-line-or-label"!==R||(l=[f.x,f.y]),o=c.nodeShapes[this.getNodeShape(d)].intersectLine(p.x,p.y,d.outerWidth(),d.outerHeight(),l[0],l[1],0,B,x),"outside-to-node-or-label"===R||"outside-to-line-or-label"===R){var Y=d._private.rscratch,X=Y.labelWidth,$=Y.labelHeight,U=Y.labelX,j=Y.labelY,H=X/2,W=$/2,q=d.pstyle("text-valign").value;"top"===(q=Gs(q))?j-=W:"bottom"===q&&(j+=W);var K=d.pstyle("text-halign").value;"left"===(K=Vs(K))?U-=H:"right"===K&&(U+=H);var Z=Rn(l[0],l[1],[U-H,j-W,U+H,j-W,U+H,j+W,U-H,j+W],p.x,p.y);if(Z.length>0){var Q=f,J=on(Q,Kt(o)),ee=on(Q,Kt(Z)),ne=J;if(ee<J&&(o=Z,ne=ee),Z.length>2)on(Q,{x:Z[2],y:Z[3]})<ne&&(o=[Z[2],Z[3]])}}var re=Bn(o,a,c.arrowShapes[g].spacing(e,"target")+y),ie=Bn(o,a,c.arrowShapes[g].gap(e,"target")+y);if(E.endX=ie[0],E.endY=ie[1],E.arrowEndX=re[0],E.arrowEndY=re[1],"inside-to-node"===O)o=[f.x,f.y];else if(I.units)o=this.manualEndptToPx(h,I);else if("outside-to-line"===O)o=E.srcIntn;else if("outside-to-node"===O||"outside-to-node-or-label"===O?u=s:"outside-to-line"!==O&&"outside-to-line-or-label"!==O||(u=[p.x,p.y]),o=c.nodeShapes[this.getNodeShape(h)].intersectLine(f.x,f.y,h.outerWidth(),h.outerHeight(),u[0],u[1],0,D,b),"outside-to-node-or-label"===O||"outside-to-line-or-label"===O){var oe=h._private.rscratch,ae=oe.labelWidth,se=oe.labelHeight,le=oe.labelX,ue=oe.labelY,ce=ae/2,he=se/2,de=h.pstyle("text-valign").value;"top"===(de=Gs(de))?ue-=he:"bottom"===de&&(ue+=he);var fe=h.pstyle("text-halign").value;"left"===(fe=Vs(fe))?le-=ce:"right"===fe&&(le+=ce);var pe=Rn(u[0],u[1],[le-ce,ue-he,le+ce,ue-he,le+ce,ue+he,le-ce,ue+he],f.x,f.y);if(pe.length>0){var ge=p,ye=on(ge,Kt(o)),me=on(ge,Kt(pe)),be=ye;if(me<ye&&(o=[pe[0],pe[1]],be=me),pe.length>2)on(ge,{x:pe[2],y:pe[3]})<be&&(o=[pe[2],pe[3]])}}var xe=Bn(o,s,c.arrowShapes[v].spacing(e,"source")+m),we=Bn(o,s,c.arrowShapes[v].gap(e,"source")+m);E.startX=we[0],E.startY=we[1],E.arrowStartX=xe[0],E.arrowStartY=xe[1],k&&(te(E.startX)&&te(E.startY)&&te(E.endX)&&te(E.endY)?E.badLine=!1:E.badLine=!0)},getSourceEndpoint:function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),"haystack"===t.edgeType?{x:t.haystackPts[0],y:t.haystackPts[1]}:{x:t.arrowStartX,y:t.arrowStartY}},getTargetEndpoint:function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),"haystack"===t.edgeType?{x:t.haystackPts[2],y:t.haystackPts[3]}:{x:t.arrowEndX,y:t.arrowEndY}}},dh={};function fh(e,t,n){for(var r=function(e,t,n,r){return sn(e,t,n,r)},i=t._private.rstyle.bezierPts,o=0;o<e.bezierProjPcts.length;o++){var a=e.bezierProjPcts[o];i.push({x:r(n[0],n[2],n[4],a),y:r(n[1],n[3],n[5],a)})}}dh.storeEdgeProjections=function(e){var t=e._private,n=t.rscratch,r=n.edgeType;if(t.rstyle.bezierPts=null,t.rstyle.linePts=null,t.rstyle.haystackPts=null,"multibezier"===r||"bezier"===r||"self"===r||"compound"===r){t.rstyle.bezierPts=[];for(var i=0;i+5<n.allpts.length;i+=4)fh(this,e,n.allpts.slice(i,i+6))}else if("segments"===r){var o=t.rstyle.linePts=[];for(i=0;i+1<n.allpts.length;i+=2)o.push({x:n.allpts[i],y:n.allpts[i+1]})}else if("haystack"===r){var a=n.haystackPts;t.rstyle.haystackPts=[{x:a[0],y:a[1]},{x:a[2],y:a[3]}]}for(var s=e.pstyle("width").pfValue,l=t.rstyle.arrowWidths=t.rstyle.arrowWidths||{},u=0,c=0;c<Lu.length;c++){var h=Lu[c],d=Ru(e,h);l[h]=this.getArrowWidth(s,d)*this.arrowShapeWidth,d>u&&(u=d)}t.rstyle.arrowWidth=this.getArrowWidth(s,u)*this.arrowShapeWidth},dh.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)};var ph={recalculateNodeLabelProjection:function(e){var t=e.pstyle("label").strValue;if(!ue(t)){var n,r,i=e._private,o=e.width(),a=e.height(),s=e.padding(),l=e.position(),u=e.pstyle("text-halign").strValue,c=e.pstyle("text-valign").strValue,h=i.rscratch,d=i.rstyle;switch(u){case"left":n=l.x-o/2-s;break;case"left-inside":n=l.x-o/2+s;break;case"right":n=l.x+o/2+s;break;case"right-inside":n=l.x+o/2-s;break;default:n=l.x}switch(c){case"top":r=l.y-a/2-s;break;case"top-inside":r=l.y-a/2+s;break;case"bottom":r=l.y+a/2+s;break;case"bottom-inside":r=l.y+a/2-s;break;default:r=l.y}h.labelX=n,h.labelY=r,d.labelX=n,d.labelY=r,this.calculateLabelAngles(e),this.applyLabelDimensions(e)}}},gh=function(e,t){var n=Math.atan(t/e);return 0===e&&n<0&&(n*=-1),n},vh=function(e,t){var n=t.x-e.x,r=t.y-e.y;return gh(n,r)};ph.recalculateEdgeLabelProjections=function(e){var t,n=e._private,r=n.rscratch,i=this,o={mid:e.pstyle("label").strValue,source:e.pstyle("source-label").strValue,target:e.pstyle("target-label").strValue};if(o.mid||o.source||o.target){t={x:r.midX,y:r.midY};var a=function(e,t,r){bt(n.rscratch,e,t,r),bt(n.rstyle,e,t,r)};a("labelX",null,t.x),a("labelY",null,t.y);var s=gh(r.midDispX,r.midDispY);a("labelAutoAngle",null,s);var l=function(){if(l.cache)return l.cache;for(var e=[],t=0;t+5<r.allpts.length;t+=4){var o={x:r.allpts[t],y:r.allpts[t+1]},a={x:r.allpts[t+2],y:r.allpts[t+3]},s={x:r.allpts[t+4],y:r.allpts[t+5]};e.push({p0:o,p1:a,p2:s,startDist:0,length:0,segments:[]})}var u=n.rstyle.bezierPts,c=i.bezierProjPcts.length;function h(e,t,n,r,i){var o=rn(t,n),a=e.segments[e.segments.length-1],s={p0:t,p1:n,t0:r,t1:i,startDist:a?a.startDist+a.length:0,length:o};e.segments.push(s),e.length+=o}for(var d=0;d<e.length;d++){var f=e[d],p=e[d-1];p&&(f.startDist=p.startDist+p.length),h(f,f.p0,u[d*c],0,i.bezierProjPcts[0]);for(var g=0;g<c-1;g++)h(f,u[d*c+g],u[d*c+g+1],i.bezierProjPcts[g],i.bezierProjPcts[g+1]);h(f,u[d*c+c-1],f.p2,i.bezierProjPcts[c-1],1)}return l.cache=e},u=function(n){var i,s="source"===n;if(o[n]){var u=e.pstyle(n+"-text-offset").pfValue;switch(r.edgeType){case"self":case"compound":case"bezier":case"multibezier":for(var c,h=l(),d=0,f=0,p=0;p<h.length;p++){for(var g=h[s?p:h.length-1-p],v=0;v<g.segments.length;v++){var y=g.segments[s?v:g.segments.length-1-v],m=p===h.length-1&&v===g.segments.length-1;if(d=f,(f+=y.length)>=u||m){c={cp:g,segment:y};break}}if(c)break}var b=c.cp,x=c.segment,w=(u-d)/x.length,E=x.t1-x.t0,T=s?x.t0+E*w:x.t1-E*w;T=un(0,T,1),t=ln(b.p0,b.p1,b.p2,T),i=function(e,t,n,r){var i=un(0,r-.001,1),o=un(0,r+.001,1),a=ln(e,t,n,i),s=ln(e,t,n,o);return vh(a,s)}(b.p0,b.p1,b.p2,T);break;case"straight":case"segments":case"haystack":for(var C,M,A,N,_=0,S=r.allpts.length,k=0;k+3<S&&(s?(A={x:r.allpts[k],y:r.allpts[k+1]},N={x:r.allpts[k+2],y:r.allpts[k+3]}):(A={x:r.allpts[S-2-k],y:r.allpts[S-1-k]},N={x:r.allpts[S-4-k],y:r.allpts[S-3-k]}),M=_,!((_+=C=rn(A,N))>=u));k+=2);var P=(u-M)/C;P=un(0,P,1),t=function(e,t,n,r){var i=t.x-e.x,o=t.y-e.y,a=rn(e,t),s=i/a,l=o/a;return n=n??0,r=null!=r?r:n*a,{x:e.x+s*r,y:e.y+l*r}}(A,N,P),i=vh(A,N)}a("labelX",n,t.x),a("labelY",n,t.y),a("labelAutoAngle",n,i)}};u("source"),u("target"),this.applyLabelDimensions(e)}},ph.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},ph.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=Ke(r,e._private.labelDimsKey);if(mt(n.rscratch,"prefixedLabelDimsKey",t)!==i){bt(n.rscratch,"prefixedLabelDimsKey",t,i);var o=this.calculateLabelDimensions(e,r),a=e.pstyle("line-height").pfValue,s=e.pstyle("font-size").pfValue,l=e.pstyle("text-wrap").strValue,u=mt(n.rscratch,"labelWrapCachedLines",t)||[],c="wrap"!==l?1:Math.max(u.length,1),h=s*a,d=o.width,f=o.height+(c-1)*(a-1)*s;bt(n.rstyle,"labelWidth",t,d),bt(n.rscratch,"labelWidth",t,d),bt(n.rstyle,"labelHeight",t,f),bt(n.rscratch,"labelHeight",t,f),bt(n.rscratch,"labelLineHeight",t,h),bt(n.rscratch,"labelActualDescent",t,o.labelActualDescent)}},ph.getLabelText=function(e,t){var n=e._private,r=t?t+"-":"",i=e.pstyle(r+"label").strValue,o=e.pstyle("text-transform").value,a=function(e,r){return r?(bt(n.rscratch,e,t,r),r):mt(n.rscratch,e,t)};if(!i)return"";"none"==o||("uppercase"==o?i=i.toUpperCase():"lowercase"==o&&(i=i.toLowerCase()));var s=e.pstyle("text-wrap").value;if("wrap"===s){var l=a("labelKey");if(null!=l&&a("labelWrapKey")===l)return a("labelWrapCachedText");for(var c=i.split("\n"),h=e.pstyle("text-max-width").pfValue,d="anywhere"===e.pstyle("text-overflow-wrap").value,f=[],p=/[\s\u200b]+|$/g,g=0;g<c.length;g++){var v=c[g],y=this.calculateLabelDimensions(e,v).width;if(d){var m=v.split("").join("");v=m}if(y>h){var b,x="",w=0,E=u(v.matchAll(p));try{for(E.s();!(b=E.n()).done;){var T=b.value,C=T[0],M=v.substring(w,T.index);w=T.index+C.length;var A=0===x.length?M:x+M+C;this.calculateLabelDimensions(e,A).width<=h?x+=M+C:(x&&f.push(x),x=M+C)}}catch(e){E.e(e)}finally{E.f()}x.match(/^[\s\u200b]+$/)||f.push(x)}else f.push(v)}a("labelWrapCachedLines",f),i=a("labelWrapCachedText",f.join("\n")),a("labelWrapKey",l)}else if("ellipsis"===s){var N=e.pstyle("text-max-width").pfValue,_="",S=!1;if(this.calculateLabelDimensions(e,i).width<N)return i;for(var k=0;k<i.length;k++){if(this.calculateLabelDimensions(e,_+i[k]+"…").width>N)break;_+=i[k],k===i.length-1&&(S=!0)}return S||(_+="…"),_}return i},ph.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;return"auto"===t?e.isNode()?function(e){switch(e){case"left":case"right-inside":return"right";case"right":case"left-inside":return"left";default:return"center"}}(n):"center":t},ph.calculateLabelDimensions=function(e,t){var n=this.cy.window().document,r=e.pstyle("font-style").strValue,i=e.pstyle("font-size").pfValue,o=e.pstyle("font-family").strValue,a=e.pstyle("font-weight").strValue,s=e.pstyle("text-metrics").strValue||"font",l=this.labelCalcCanvas,u=this.labelCalcCanvasContext;if(!l){l=this.labelCalcCanvas=n.createElement("canvas"),u=this.labelCalcCanvasContext=l.getContext("2d");var c=l.style;c.position="absolute",c.left="-9999px",c.top="-9999px",c.zIndex="-1",c.visibility="hidden",c.pointerEvents="none"}u.font="".concat(r," ").concat(a," ").concat(i,"px ").concat(o);for(var h=0,d=0,f=t.split("\n"),p=f.length,g=0,v=0,y=0;y<p;y++){var m=f[y],b=u.measureText(m),x=Math.ceil(b.width),w=i;"glyph"===s&&(0===y&&(v=b.actualBoundingBoxAscent),y===p-1&&(g=b.actualBoundingBoxDescent)),h=Math.max(x,h),d+=w}return"glyph"===s&&(d-=i-v-g),{width:h+=0,height:d+=0,labelActualAscent:v,labelActualDescent:g}},ph.calculateLabelAngle=function(e,t){var n=e._private.rscratch,r=e.isEdge(),i=t?t+"-":"",o=e.pstyle(i+"text-rotation"),a=o.strValue;return"none"===a?0:r&&"autorotate"===a?n.labelAutoAngle:"autorotate"===a?0:o.pfValue},ph.calculateLabelAngles=function(e){var t=this,n=e.isEdge(),r=e._private.rscratch;r.labelAngle=t.calculateLabelAngle(e),n&&(r.sourceLabelAngle=t.calculateLabelAngle(e,"source"),r.targetLabelAngle=t.calculateLabelAngle(e,"target"))};var yh={},mh=!1;yh.getNodeShape=function(e){var t=e.pstyle("shape").value;if("cutrectangle"===t&&(e.width()<28||e.height()<28))return mh||(ct("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),mh=!0),"rectangle";if(e.isParent())return"rectangle"===t||"roundrectangle"===t||"round-rectangle"===t||"cutrectangle"===t||"cut-rectangle"===t||"barrel"===t?t:"rectangle";if("polygon"===t){var n=e.pstyle("shape-polygon-points").value;return this.nodeShapes.makePolygon(n).name}return t};var bh={registerCalculationListeners:function(){var e=this.cy,t=e.collection(),n=this,r=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.merge(e),n)for(var r=0;r<e.length;r++){var i=e[r]._private.rstyle;i.clean=!1,i.cleanConnected=!1}};n.binder(e).on("bounds.* dirty.*",function(e){var t=e.target;r(t)}).on("style.* background.*",function(e){var t=e.target;r(t,!1)});var i=function(i){if(i){var o=n.onUpdateEleCalcsFns;t.cleanStyle();for(var a=0;a<t.length;a++){var s=t[a],l=s._private.rstyle;s.isNode()&&!l.cleanConnected&&(r(s.connectedEdges()),l.cleanConnected=!0)}if(o)for(var u=0;u<o.length;u++){(0,o[u])(i,t)}n.recalculateRenderedStyle(t),t=e.collection()}};n.flushRenderedStyleQueue=function(){i(!0)},n.beforeRender(i,n.beforeRenderPriorities.eleCalcs)},onUpdateEleCalcs:function(e){(this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[]).push(e)},recalculateRenderedStyle:function(e,t){var n=function(e){return e._private.rstyle.cleanConnected};if(0!==e.length){var r=[],i=[];if(!this.destroyed){void 0===t&&(t=!0);for(var o=0;o<e.length;o++){var a=e[o],s=a._private,l=s.rstyle;!a.isEdge()||n(a.source())&&n(a.target())||(l.clean=!1),a.isEdge()&&a.isBundledBezier()&&a.parallelEdges().some(function(e){return!e._private.rstyle.clean&&e.isBundledBezier()})&&(l.clean=!1),t&&l.clean||a.removed()||"none"!==a.pstyle("display").value&&("nodes"===s.group?i.push(a):r.push(a),l.clean=!0)}for(var u=0;u<i.length;u++){var c=i[u],h=c._private.rstyle,d=c.position();this.recalculateNodeLabelProjection(c),h.nodeX=d.x,h.nodeY=d.y,h.nodeW=c.pstyle("width").pfValue,h.nodeH=c.pstyle("height").pfValue}this.recalculateEdgeProjections(r);for(var f=0;f<r.length;f++){var p=r[f]._private,g=p.rstyle,v=p.rscratch;g.srcX=v.arrowStartX,g.srcY=v.arrowStartY,g.tgtX=v.arrowEndX,g.tgtY=v.arrowEndY,g.midX=v.midX,g.midY=v.midY,g.labelAngle=v.labelAngle,g.sourceLabelAngle=v.sourceLabelAngle,g.targetLabelAngle=v.targetLabelAngle}}}}},xh={updateCachedGrabbedEles:function(){var e=this.cachedZSortedEles;if(e){e.drag=[],e.nondrag=[];for(var t=[],n=0;n<e.length;n++){var r=(i=e[n])._private.rscratch;i.grabbed()&&!i.isParent()?t.push(i):r.inDragLayer?e.drag.push(i):e.nondrag.push(i)}for(n=0;n<t.length;n++){var i=t[n];e.drag.push(i)}}},invalidateCachedZSortedEles:function(){this.cachedZSortedEles=null},getCachedZSortedEles:function(e){if(e||!this.cachedZSortedEles){var t=this.cy.mutableElements().toArray();t.sort(Pl),t.interactive=t.filter(function(e){return e.interactive()}),this.cachedZSortedEles=t,this.updateCachedGrabbedEles()}else t=this.cachedZSortedEles;return t}},wh={};[Rc,Bc,uh,hh,dh,ph,yh,bh,xh].forEach(function(e){Te(wh,e)});var Eh={getCachedImage:function(e,t,n){var r=this.imageCache=this.imageCache||{},i=r[e];if(i)return i.image.complete||i.image.addEventListener("load",n),i.image;var o=(i=r[e]=r[e]||{}).image=new Image;o.addEventListener("load",n),o.addEventListener("error",function(){o.error=!0});var a="data:";return e.substring(0,5).toLowerCase()===a||(t="null"===t?null:t,o.crossOrigin=t),o.src=e,o}},Th=function(e,t){var n=e[0];n&&n._private.grabbed!==t&&(n._private.grabbed=t,e.updateStyle(!1))},Ch={registerBinding:function(e,t,n,r){var i=Array.prototype.slice.apply(arguments,[1]);if(Array.isArray(e)){for(var o=[],a=0;a<e.length;a++){var s=e[a];if(void 0!==s){var l=this.binder(s);o.push(l.on.apply(l,i))}}return o}return(l=this.binder(e)).on.apply(l,i)}};Ch.binder=function(e){var t,n=this,r=n.cy.window(),i=e===r||e===r.document||e===r.document.body||(t=e,"undefined"!=typeof HTMLElement&&t instanceof HTMLElement);if(null==n.supportsPassiveEvents){var o=!1;try{var a=Object.defineProperty({},"passive",{get:function(){return o=!0,!0}});r.addEventListener("test",null,a)}catch(e){}n.supportsPassiveEvents=o}var s=function(t,r,o){var a=Array.prototype.slice.call(arguments);return i&&n.supportsPassiveEvents&&(a[2]={capture:null!=o&&o,passive:!1,once:!1}),n.bindings.push({target:e,args:a}),(e.addEventListener||e.on).apply(e,a),this};return{on:s,addEventListener:s,addListener:s,bind:s}},Ch.nodeIsDraggable=function(e){return e&&e.isNode()&&!e.locked()&&e.grabbable()},Ch.nodeIsGrabbable=function(e){return this.nodeIsDraggable(e)&&e.interactive()},Ch.load=function(){var e=this,t=e.cy.window(),n=function(e){return e.selected()},r=function(t,n,r,i){null==t&&(t=e.cy);for(var o=0;o<n.length;o++){var a=n[o];t.emit({originalEvent:r,type:a,position:i})}},i=function(e){return e.shiftKey||e.metaKey||e.ctrlKey},o=function(t,n){var r=!0;if(e.cy.hasCompoundNodes()&&t&&t.pannable())for(var i=0;n&&i<n.length;i++){if((t=n[i]).isNode()&&t.isParent()&&!t.pannable()){r=!1;break}}else r=!0;return r},a=function(e){e[0]._private.rscratch.inDragLayer=!0},s=function(e){e[0]._private.rscratch.isGrabTarget=!0},l=function(e,t){var n=t.addToList;n.has(e)||!e.grabbable()||e.locked()||(n.merge(e),function(e){Th(e,!0)}(e))},u=function(t,n){n=n||{};var r=t.cy().hasCompoundNodes();n.inDragLayer&&(t.forEach(a),t.neighborhood().stdFilter(function(e){return!r||e.isEdge()}).forEach(a)),n.addToList&&t.forEach(function(e){l(e,n)}),function(e,t){if(e.cy().hasCompoundNodes()&&(null!=t.inDragLayer||null!=t.addToList)){var n=e.descendants();t.inDragLayer&&(n.forEach(a),n.connectedEdges().forEach(a)),t.addToList&&l(n,t)}}(t,n),d(t,{inDragLayer:n.inDragLayer}),e.updateCachedGrabbedEles()},c=u,h=function(t){t&&(e.getCachedZSortedEles().forEach(function(e){!function(e){Th(e,!1)}(e),function(e){e[0]._private.rscratch.inDragLayer=!1}(e),function(e){e[0]._private.rscratch.isGrabTarget=!1}(e)}),e.updateCachedGrabbedEles())},d=function(e,t){if((null!=t.inDragLayer||null!=t.addToList)&&e.cy().hasCompoundNodes()){var n=e.ancestors().orphans();if(!n.same(e)){var r=n.descendants().spawnSelf().merge(n).unmerge(e).unmerge(e.descendants()),i=r.connectedEdges();t.inDragLayer&&(i.forEach(a),r.forEach(a)),t.addToList&&r.forEach(function(e){l(e,t)})}}},f=function(){null!=document.activeElement&&null!=document.activeElement.blur&&document.activeElement.blur()},p="undefined"!=typeof MutationObserver,g="undefined"!=typeof ResizeObserver;p?(e.removeObserver=new MutationObserver(function(t){for(var n=0;n<t.length;n++){var r=t[n].removedNodes;if(r)for(var i=0;i<r.length;i++){if(r[i]===e.container){e.destroy();break}}}}),e.container.parentNode&&e.removeObserver.observe(e.container.parentNode,{childList:!0})):e.registerBinding(e.container,"DOMNodeRemoved",function(t){e.destroy()});var v=Re(function(){e.cy.resize()},100);p&&(e.styleObserver=new MutationObserver(v),e.styleObserver.observe(e.container,{attributes:!0})),e.registerBinding(t,"resize",v),g&&(e.resizeObserver=new ResizeObserver(v),e.resizeObserver.observe(e.container));var y=function(){e.invalidateContainerClientCoordsCache()};!function(e,t){for(;null!=e;)t(e),e=e.parentNode}(e.container,function(t){e.registerBinding(t,"transitionend",y),e.registerBinding(t,"animationend",y),e.registerBinding(t,"scroll",y)}),e.registerBinding(e.container,"contextmenu",function(e){e.preventDefault()});var m=function(t){for(var n=e.findContainerClientCoords(),r=n[0],i=n[1],o=n[2],a=n[3],s=t.touches?t.touches:[t],l=!1,u=0;u<s.length;u++){var c=s[u];if(r<=c.clientX&&c.clientX<=r+o&&i<=c.clientY&&c.clientY<=i+a){l=!0;break}}if(!l)return!1;for(var h=e.container,d=t.target.parentNode,f=!1;d;){if(d===h){f=!0;break}d=d.parentNode}return!!f};e.registerBinding(e.container,"mousedown",function(t){if(m(t)&&(1!==e.hoverData.which||1===t.which)){t.preventDefault(),f(),e.hoverData.capture=!0,e.hoverData.which=t.which;var n=e.cy,i=[t.clientX,t.clientY],o=e.projectIntoViewport(i[0],i[1]),a=e.selection,l=e.findNearestElements(o[0],o[1],!0,!1),h=l[0],d=e.dragData.possibleDragElements;e.hoverData.mdownPos=o,e.hoverData.mdownGPos=i;var p=function(e){return{originalEvent:t,type:e,position:{x:o[0],y:o[1]}}};if(3==t.which){e.hoverData.cxtStarted=!0;var g={originalEvent:t,type:"cxttapstart",position:{x:o[0],y:o[1]}};h?(h.activate(),h.emit(g),e.hoverData.down=h):n.emit(g),e.hoverData.downTime=(new Date).getTime(),e.hoverData.cxtDragged=!1}else if(1==t.which){if(h&&h.activate(),null!=h&&e.nodeIsGrabbable(h)){if(s(h),h.selected()){d=e.dragData.possibleDragElements=n.collection();var v=n.$(function(t){return t.isNode()&&t.selected()&&e.nodeIsGrabbable(t)});u(v,{addToList:d}),h.emit(p("grabon")),v.forEach(function(e){e.emit(p("grab"))})}else d=e.dragData.possibleDragElements=n.collection(),c(h,{addToList:d}),h.emit(p("grabon")).emit(p("grab"));e.redrawHint("eles",!0),e.redrawHint("drag",!0)}e.hoverData.down=h,e.hoverData.downs=l,e.hoverData.downTime=(new Date).getTime(),r(h,["mousedown","tapstart","vmousedown"],t,{x:o[0],y:o[1]}),null==h?(a[4]=1,e.data.bgActivePosistion={x:o[0],y:o[1]},e.redrawHint("select",!0),e.redraw()):h.pannable()&&(a[4]=1),e.hoverData.tapholdCancelled=!1,clearTimeout(e.hoverData.tapholdTimeout),e.hoverData.tapholdTimeout=setTimeout(function(){if(!e.hoverData.tapholdCancelled){var t=e.hoverData.down;t?t.emit(p("taphold")):n.emit(p("taphold"))}},e.tapholdDuration)}a[0]=a[2]=o[0],a[1]=a[3]=o[1]}},!1);var b,x,w,E=function(e){var t=e.getRootNode();if(t&&11===t.nodeType&&void 0!==t.host)return t}(e.container);e.registerBinding([t,E],"mousemove",function(t){if(e.hoverData.capture||m(t)){var n=!1,a=e.cy,s=a.zoom(),l=[t.clientX,t.clientY],c=e.projectIntoViewport(l[0],l[1]),d=e.hoverData.mdownPos,f=e.hoverData.mdownGPos,p=e.selection,g=null;e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.selecting||(g=e.findNearestElement(c[0],c[1],!0,!1));var v,y=e.hoverData.last,b=e.hoverData.down,x=[c[0]-p[2],c[1]-p[3]],w=e.dragData.possibleDragElements;if(f){var E=l[0]-f[0],T=E*E,C=l[1]-f[1],M=T+C*C;e.hoverData.isOverThresholdDrag=v=M>=e.desktopTapThreshold2}var A=i(t);v&&(e.hoverData.tapholdCancelled=!0);n=!0,r(g,["mousemove","vmousemove","tapdrag"],t,{x:c[0],y:c[1]});var N=function(e){return{originalEvent:t,type:e,position:{x:c[0],y:c[1]}}},_=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||a.emit(N("boxstart")),p[4]=1,e.hoverData.selecting=!0,e.redrawHint("select",!0),e.redraw()};if(3===e.hoverData.which){if(v){var S=N("cxtdrag");b?b.emit(S):a.emit(S),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&g===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit(N("cxtdragout")),e.hoverData.cxtOver=g,g&&g.emit(N("cxtdragover")))}}else if(e.hoverData.dragging){if(n=!0,a.panningEnabled()&&a.userPanningEnabled()){var k;if(e.hoverData.justStartedPan){var P=e.hoverData.mdownPos;k={x:(c[0]-P[0])*s,y:(c[1]-P[1])*s},e.hoverData.justStartedPan=!1}else k={x:x[0]*s,y:x[1]*s};a.panBy(k),a.emit(N("dragpan")),e.hoverData.dragged=!0}c=e.projectIntoViewport(t.clientX,t.clientY)}else if(1!=p[4]||null!=b&&!b.pannable()){if(b&&b.pannable()&&b.active()&&b.unactivate(),b&&b.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),b)if(v){if(a.boxSelectionEnabled()&&A)b&&b.grabbed()&&(h(w),b.emit(N("freeon")),w.emit(N("free")),e.dragData.didDrag&&(b.emit(N("dragfreeon")),w.emit(N("dragfree")))),_();else if(b&&b.grabbed()&&e.nodeIsDraggable(b)){var I=!e.dragData.didDrag;I&&e.redrawHint("eles",!0),e.dragData.didDrag=!0,e.hoverData.draggingEles||u(w,{inDragLayer:!0});var O={x:0,y:0};if(te(x[0])&&te(x[1])&&(O.x+=x[0],O.y+=x[1],I)){var D=e.hoverData.dragDelta;D&&te(D[0])&&te(D[1])&&(O.x+=D[0],O.y+=D[1])}e.hoverData.draggingEles=!0,w.silentShift(O).emit(N("position")).emit(N("drag")),e.redrawHint("drag",!0),e.redraw()}}else!function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];0===t.length?(t.push(x[0]),t.push(x[1])):(t[0]+=x[0],t[1]+=x[1])}();n=!0}else if(v){if(e.hoverData.dragging||!a.boxSelectionEnabled()||!A&&a.panningEnabled()&&a.userPanningEnabled()){if(!e.hoverData.selecting&&a.panningEnabled()&&a.userPanningEnabled()){o(b,e.hoverData.downs)&&(e.hoverData.dragging=!0,e.hoverData.justStartedPan=!0,p[4]=0,e.data.bgActivePosistion=Kt(d),e.redrawHint("select",!0),e.redraw())}}else _();b&&b.pannable()&&b.active()&&b.unactivate()}return p[2]=c[0],p[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 o=e.cy,a=e.projectIntoViewport(t.clientX,t.clientY),s=e.selection,l=e.findNearestElement(a[0],a[1],!0,!1),u=e.dragData.possibleDragElements,c=e.hoverData.down,d=i(t);e.data.bgActivePosistion&&(e.redrawHint("select",!0),e.redraw()),e.hoverData.tapholdCancelled=!0,e.data.bgActivePosistion=void 0,c&&c.unactivate();var f=function(e){return{originalEvent:t,type:e,position:{x:a[0],y:a[1]}}};if(3===e.hoverData.which){var p=f("cxttapend");if(c?c.emit(p):o.emit(p),!e.hoverData.cxtDragged){var g=f("cxttap");c?c.emit(g):o.emit(g)}e.hoverData.cxtDragged=!1,e.hoverData.which=null}else if(1===e.hoverData.which){if(r(l,["mouseup","tapend","vmouseup"],t,{x:a[0],y:a[1]}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||e.hoverData.isOverThresholdDrag||(r(c,["click","tap","vclick"],t,{x:a[0],y:a[1]}),x=!1,t.timeStamp-w<=o.multiClickDebounceTime()?(b&&clearTimeout(b),x=!0,w=null,r(c,["dblclick","dbltap","vdblclick"],t,{x:a[0],y:a[1]})):(b=setTimeout(function(){x||r(c,["oneclick","onetap","voneclick"],t,{x:a[0],y:a[1]})},o.multiClickDebounceTime()),w=t.timeStamp)),null!=c||e.dragData.didDrag||e.hoverData.selecting||e.hoverData.dragged||i(t)||(o.$(n).unselect(["tapunselect"]),u.length>0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=u=o.collection()),l!=c||e.dragData.didDrag||e.hoverData.selecting||null!=l&&l._private.selectable&&(e.hoverData.dragging||("additive"===o.selectionType()||d?l.selected()?l.unselect(["tapunselect"]):l.select(["tapselect"]):d||(o.$(n).unmerge(l).unselect(["tapunselect"]),l.select(["tapselect"]))),e.redrawHint("eles",!0)),e.hoverData.selecting){var v=o.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint("select",!0),v.length>0&&e.redrawHint("eles",!0),o.emit(f("boxend"));var y=function(e){return e.selectable()&&!e.selected()};"additive"===o.selectionType()||d||o.$(n).unmerge(v).unselect(),v.emit(f("box")).stdFilter(y).select().emit(f("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 m=c&&c.grabbed();h(u),m&&(c.emit(f("freeon")),u.emit(f("free")),e.dragData.didDrag&&(c.emit(f("dragfreeon")),u.emit(f("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 T,C,M,A,N,_,S,k,P,I,O,D,L,R,B,z=[],F=1e5,V=null,G=function(t){var n=!1,r=t.deltaY;if(null==r&&(null!=t.wheelDeltaY?r=t.wheelDeltaY/4:null!=t.wheelDelta&&(r=t.wheelDelta/4)),0!==r){if(null==T)if(z.length>=4){T=!1;var i,o=z;if(o[0]>=5)i=function(e){for(var t=Math.abs(e[0]),n=1;n<e.length;n++)if(Math.abs(e[n])!==t)return!1;return!0}(o)?o[0]:Qt(o),i>1&&(T=!0,F=i,C=i)}else z.push(Math.abs(r)),n=!0;var a=!1;if(T){var s=Math.abs(r);if(a=Jt(s,F));else if(s<Math.min(C/8,15))V=null;else if(!ne(s)&&Jt(F,s))F=s,V=null,a=!0;else if(s===V){var l=Qt([F,s]);F=4*l>=C?l:s,V=null,a=!0}else V=s,n=ne(s)||s>F}if(!e.scrollingPage){var u=e.cy,c=u.zoom(),h=u.pan(),d=e.projectIntoViewport(t.clientX,t.clientY),f=[d[0]*c+h.x,d[1]*c+h.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||0!==e.selection[4])t.preventDefault();else if(u.panningEnabled()&&u.userPanningEnabled()&&u.zoomingEnabled()&&u.userZoomingEnabled()){var p;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),n&&Math.abs(r)>5&&(r=5*nn(r)),p=r/-250,a&&(p/=F,p*=3),p*=e.wheelSensitivity,1===t.deltaMode&&(p*=33);var g=u.zoom()*Math.pow(10,p);"gesturechange"===t.type&&(g=e.gestureStartZoom*t.scale),u.zoom({level:g,renderedPosition:{x:f[0],y:f[1]}}),u.emit({type:"gesturechange"===t.type?"pinchzoom":"scrollzoom",originalEvent:t,position:{x:d[0],y:d[1]}})}}}};e.registerBinding(e.container,"wheel",G,!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||G(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 Y,X,$,U,j,H,W,q=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},K=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(e.registerBinding(e.container,"touchstart",Y=function(t){if(e.hasTouchStarted=!0,m(t)){f(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var n=e.cy,i=e.touchData.now,o=e.touchData.earlier;if(t.touches[0]){var a=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);i[0]=a[0],i[1]=a[1]}if(t.touches[1]){a=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);i[2]=a[0],i[3]=a[1]}if(t.touches[2]){a=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);i[4]=a[0],i[5]=a[1]}var l=function(e){return{originalEvent:t,type:e,position:{x:i[0],y:i[1]}}};if(t.touches[1]){e.touchData.singleTouchMoved=!0,h(e.dragData.touchDragEles);var d=e.findContainerClientCoords();O=d[0],D=d[1],L=d[2],R=d[3],M=t.touches[0].clientX-O,A=t.touches[0].clientY-D,N=t.touches[1].clientX-O,_=t.touches[1].clientY-D,B=0<=M&&M<=L&&0<=N&&N<=L&&0<=A&&A<=R&&0<=_&&_<=R;var p=n.pan(),g=n.zoom();S=q(M,A,N,_),k=K(M,A,N,_),I=[((P=[(M+N)/2,(A+_)/2])[0]-p.x)/g,(P[1]-p.y)/g];if(k<4e4&&!t.touches[2]){var v=e.findNearestElement(i[0],i[1],!0,!0),y=e.findNearestElement(i[2],i[3],!0,!0);return v&&v.isNode()?(v.activate().emit(l("cxttapstart")),e.touchData.start=v):y&&y.isNode()?(y.activate().emit(l("cxttapstart")),e.touchData.start=y):n.emit(l("cxttapstart")),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 b=e.findNearestElements(i[0],i[1],!0,!0),x=b[0];if(null!=x&&(x.activate(),e.touchData.start=x,e.touchData.starts=b,e.nodeIsGrabbable(x))){var w=e.dragData.touchDragEles=n.collection(),E=null;e.redrawHint("eles",!0),e.redrawHint("drag",!0),x.selected()?(E=n.$(function(t){return t.selected()&&e.nodeIsGrabbable(t)}),u(E,{addToList:w})):c(x,{addToList:w}),s(x),x.emit(l("grabon")),E?E.forEach(function(e){e.emit(l("grab"))}):x.emit(l("grab"))}r(x,["touchstart","tapstart","vmousedown"],t,{x:i[0],y:i[1]}),null==x&&(e.data.bgActivePosistion={x:a[0],y:a[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 T=e.touchData.startPosition=[null,null,null,null,null,null],C=0;C<i.length;C++)T[C]=o[C]=i[C];var z=t.touches[0];e.touchData.startGPosition=[z.clientX,z.clientY]}}},!1),e.registerBinding(t,"touchmove",X=function(t){var n=e.touchData.capture;if(n||m(t)){var i=e.selection,a=e.cy,s=e.touchData.now,l=e.touchData.earlier,c=a.zoom();if(t.touches[0]){var d=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=d[0],s[1]=d[1]}if(t.touches[1]){d=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=d[0],s[3]=d[1]}if(t.touches[2]){d=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=d[0],s[5]=d[1]}var f,p=function(e){return{originalEvent:t,type:e,position:{x:s[0],y:s[1]}}},g=e.touchData.startGPosition;if(n&&t.touches[0]&&g){for(var v=[],y=0;y<s.length;y++)v[y]=s[y]-l[y];var b=t.touches[0].clientX-g[0],x=b*b,w=t.touches[0].clientY-g[1];f=x+w*w>=e.touchTapThreshold2}if(n&&e.touchData.cxt){t.preventDefault();var E=t.touches[0].clientX-O,T=t.touches[0].clientY-D,C=t.touches[1].clientX-O,P=t.touches[1].clientY-D,L=K(E,T,C,P);if(L/k>=2.25||L>=22500){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var R=p("cxttapend");e.touchData.start?(e.touchData.start.unactivate().emit(R),e.touchData.start=null):a.emit(R)}}if(n&&e.touchData.cxt){R=p("cxtdrag");e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.touchData.start?e.touchData.start.emit(R):a.emit(R),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var z=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&z===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit(p("cxtdragout")),e.touchData.cxtOver=z,z&&z.emit(p("cxtdragover")))}else if(n&&t.touches[2]&&a.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||a.emit(p("boxstart")),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&&a.zoomingEnabled()&&a.panningEnabled()&&a.userZoomingEnabled()&&a.userPanningEnabled()){if(t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),ee=e.dragData.touchDragEles){e.redrawHint("drag",!0);for(var F=0;F<ee.length;F++){var V=ee[F]._private;V.grabbed=!1,V.rscratch.inDragLayer=!1}}var G=e.touchData.start,Y=(E=t.touches[0].clientX-O,T=t.touches[0].clientY-D,C=t.touches[1].clientX-O,P=t.touches[1].clientY-D,q(E,T,C,P)),X=Y/S;if(B){var $=(E-M+(C-N))/2,U=(T-A+(P-_))/2,j=a.zoom(),H=j*X,W=a.pan(),Z=I[0]*j+W.x,Q=I[1]*j+W.y,J={x:-H/j*(Z-W.x-$)+Z,y:-H/j*(Q-W.y-U)+Q};if(G&&G.active()){var ee=e.dragData.touchDragEles;h(ee),e.redrawHint("drag",!0),e.redrawHint("eles",!0),G.unactivate().emit(p("freeon")),ee&&ee.emit(p("free")),e.dragData.didDrag&&(G.emit(p("dragfreeon")),ee&&ee.emit(p("dragfree")))}a.viewport({zoom:H,pan:J,cancelOnFailedZoom:!0}),a.emit(p("pinchzoom")),S=Y,M=E,A=T,N=C,_=P,e.pinching=!0}if(t.touches[0]){d=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=d[0],s[1]=d[1]}if(t.touches[1]){d=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=d[0],s[3]=d[1]}if(t.touches[2]){d=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=d[0],s[5]=d[1]}}else if(t.touches[0]&&!e.touchData.didSelect){var ne=e.touchData.start,re=e.touchData.last;if(e.hoverData.draggingEles||e.swipePanning||(z=e.findNearestElement(s[0],s[1],!0,!0)),n&&null!=ne&&t.preventDefault(),n&&null!=ne&&e.nodeIsDraggable(ne))if(f){ee=e.dragData.touchDragEles;var ie=!e.dragData.didDrag;ie&&u(ee,{inDragLayer:!0}),e.dragData.didDrag=!0;var oe={x:0,y:0};if(te(v[0])&&te(v[1]))if(oe.x+=v[0],oe.y+=v[1],ie)e.redrawHint("eles",!0),(ae=e.touchData.dragDelta)&&te(ae[0])&&te(ae[1])&&(oe.x+=ae[0],oe.y+=ae[1]);e.hoverData.draggingEles=!0,ee.silentShift(oe).emit(p("position")).emit(p("drag")),e.redrawHint("drag",!0),e.touchData.startPosition[0]==l[0]&&e.touchData.startPosition[1]==l[1]&&e.redrawHint("eles",!0),e.redraw()}else{var ae;0===(ae=e.touchData.dragDelta=e.touchData.dragDelta||[]).length?(ae.push(v[0]),ae.push(v[1])):(ae[0]+=v[0],ae[1]+=v[1])}if(r(ne||z,["touchmove","tapdrag","vmousemove"],t,{x:s[0],y:s[1]}),ne&&ne.grabbed()||z==re||(re&&re.emit(p("tapdragout")),z&&z.emit(p("tapdragover"))),e.touchData.last=z,n)for(F=0;F<s.length;F++)s[F]&&e.touchData.startPosition[F]&&f&&(e.touchData.singleTouchMoved=!0);if(n&&(null==ne||ne.pannable())&&a.panningEnabled()&&a.userPanningEnabled()){o(ne,e.touchData.starts)&&(t.preventDefault(),e.data.bgActivePosistion||(e.data.bgActivePosistion=Kt(e.touchData.startPosition)),e.swipePanning?(a.panBy({x:v[0]*c,y:v[1]*c}),a.emit(p("dragpan"))):f&&(e.swipePanning=!0,a.panBy({x:b*c,y:w*c}),a.emit(p("dragpan")),ne&&(ne.unactivate(),e.redrawHint("select",!0),e.touchData.start=null)));d=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=d[0],s[1]=d[1]}}for(y=0;y<s.length;y++)l[y]=s[y];n&&t.touches.length>0&&!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",$=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()}),e.registerBinding(t,"touchend",U=function(t){var i=e.touchData.start;if(e.touchData.capture){0===t.touches.length&&(e.touchData.capture=!1),t.preventDefault();var o=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var a=e.cy,s=a.zoom(),l=e.touchData.now,u=e.touchData.earlier;if(t.touches[0]){var c=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);l[0]=c[0],l[1]=c[1]}if(t.touches[1]){c=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);l[2]=c[0],l[3]=c[1]}if(t.touches[2]){c=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);l[4]=c[0],l[5]=c[1]}var d,f=function(e){return{originalEvent:t,type:e,position:{x:l[0],y:l[1]}}};if(i&&i.unactivate(),e.touchData.cxt){if(d=f("cxttapend"),i?i.emit(d):a.emit(d),!e.touchData.cxtDragged){var p=f("cxttap");i?i.emit(p):a.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]&&a.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var g=a.collection(e.getAllInBox(o[0],o[1],o[2],o[3]));o[0]=void 0,o[1]=void 0,o[2]=void 0,o[3]=void 0,o[4]=0,e.redrawHint("select",!0),a.emit(f("boxend"));g.emit(f("box")).stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit(f("boxselect")),g.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 v=e.dragData.touchDragEles;if(null!=i){var y=i._private.grabbed;h(v),e.redrawHint("drag",!0),e.redrawHint("eles",!0),y&&(i.emit(f("freeon")),v.emit(f("free")),e.dragData.didDrag&&(i.emit(f("dragfreeon")),v.emit(f("dragfree")))),r(i,["touchend","tapend","vmouseup","tapdragout"],t,{x:l[0],y:l[1]}),i.unactivate(),e.touchData.start=null}else{var m=e.findNearestElement(l[0],l[1],!0,!0);r(m,["touchend","tapend","vmouseup","tapdragout"],t,{x:l[0],y:l[1]})}var b=e.touchData.startPosition[0]-l[0],x=b*b,w=e.touchData.startPosition[1]-l[1],E=(x+w*w)*s*s;e.touchData.singleTouchMoved||(i||a.$(":selected").unselect(["tapunselect"]),r(i,["tap","vclick"],t,{x:l[0],y:l[1]}),j=!1,t.timeStamp-W<=a.multiClickDebounceTime()?(H&&clearTimeout(H),j=!0,W=null,r(i,["dbltap","vdblclick"],t,{x:l[0],y:l[1]})):(H=setTimeout(function(){j||r(i,["onetap","voneclick"],t,{x:l[0],y:l[1]})},a.multiClickDebounceTime()),W=t.timeStamp)),null!=i&&!e.dragData.didDrag&&i._private.selectable&&E<e.touchTapThreshold2&&!e.pinching&&("single"===a.selectionType()?(a.$(n).unmerge(i).unselect(["tapunselect"]),i.select(["tapselect"])):i.selected()?i.unselect(["tapunselect"]):i.select(["tapselect"]),e.redrawHint("eles",!0)),e.touchData.singleTouchMoved=!0}for(var T=0;T<l.length;T++)u[T]=l[T];e.dragData.didDrag=!1,0===t.touches.length&&(e.touchData.dragDelta=[],e.touchData.startPosition=[null,null,null,null,null,null],e.touchData.startGPosition=null,e.touchData.didSelect=!1),t.touches.length<2&&(1===t.touches.length&&(e.touchData.startGPosition=[t.touches[0].clientX,t.touches[0].clientY]),e.pinching=!1,e.redrawHint("eles",!0),e.redraw())}},!1),"undefined"==typeof TouchEvent){var Z=[],Q=function(e){return{clientX:e.clientX,clientY:e.clientY,force:1,identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,radiusX:e.width/2,radiusY:e.height/2,screenX:e.screenX,screenY:e.screenY,target:e.target}},J=function(e){Z.push(function(e){return{event:e,touch:Q(e)}}(e))},ee=function(e){for(var t=0;t<Z.length;t++){if(Z[t].event.pointerId===e.pointerId)return void Z.splice(t,1)}},re=function(e){e.touches=Z.map(function(e){return e.touch})},ie=function(e){return"mouse"===e.pointerType||4===e.pointerType};e.registerBinding(e.container,"pointerdown",function(e){ie(e)||(e.preventDefault(),J(e),re(e),Y(e))}),e.registerBinding(e.container,"pointerup",function(e){ie(e)||(ee(e),re(e),U(e))}),e.registerBinding(e.container,"pointercancel",function(e){ie(e)||(ee(e),re(e),$())}),e.registerBinding(e.container,"pointermove",function(e){ie(e)||(e.preventDefault(),function(e){var t=Z.filter(function(t){return t.event.pointerId===e.pointerId})[0];t.event=e,t.touch=Q(e)}(e),re(e),X(e))})}};var Mh={generatePolygon:function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,draw:function(e,t,n,r,i,o){this.renderer.nodeShapeImpl("polygon",e,t,n,r,i,this.points)},intersectLine:function(e,t,n,r,i,o,a,s){return Rn(i,o,this.points,e,t,n/2,r/2,a)},checkPoint:function(e,t,n,r,i,o,a,s){return _n(e,t,this.points,o,a,r,i,[0,-1],n)},hasMiterBounds:"rectangle"!==e,miterBounds:function(e,t,n,r,i,o){return wn(this.points,e,t,n,r,i)}}}};Mh.generateEllipse=function(){return this.nodeShapes.ellipse={renderer:this,name:"ellipse",draw:function(e,t,n,r,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,o,a,s){return function(e,t,n,r,i,o){var a=n-e,s=r-t;a/=i,s/=o;var l=Math.sqrt(a*a+s*s),u=l-1;if(u<0)return[];var c=u/l;return[(n-e)*c+e,(r-t)*c+t]}(i,o,e,t,n/2+a,r/2+a)},checkPoint:function(e,t,n,r,i,o,a,s){return Pn(e,t,r,i,o,a,n)}}},Mh.generateRoundPolygon=function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,getOrCreateCorners:function(e,n,r,i,o,a,s){if(void 0!==a[s]&&a[s+"-cx"]===e&&a[s+"-cy"]===n&&a[s+"-w"]===r&&a[s+"-h"]===i&&a[s+"-corner-radius"]===o)return a[s];a[s]=new Array(t.length/2),a[s+"-cx"]=e,a[s+"-cy"]=n,a[s+"-w"]=r,a[s+"-h"]=i,a[s+"-corner-radius"]=o;var l=r/2,u=i/2;o="auto"===o?Yn(r,i):o;for(var c=new Array(t.length/2),h=0;h<t.length/2;h++)c[h]={x:e+l*t[2*h],y:n+u*t[2*h+1]};var d,f,p,g,v=c.length;for(f=c[v-1],d=0;d<v;d++)p=c[d%v],g=c[(d+1)%v],a[s][d]=ah(f,p,g,o),f=p,p=g;return a[s]},draw:function(e,t,n,r,i,o,a){this.renderer.nodeShapeImpl("round-polygon",e,t,n,r,i,this.points,this.getOrCreateCorners(t,n,r,i,o,a,"drawCorners"))},intersectLine:function(e,t,n,r,i,o,a,s,l){return function(e,t,n,r,i,o,a,s,l){var u,c=[],h=new Array(2*n.length);l.forEach(function(n,o){0===o?(h[h.length-2]=n.startX,h[h.length-1]=n.startY):(h[4*o-2]=n.startX,h[4*o-1]=n.startY),h[4*o]=n.stopX,h[4*o+1]=n.stopY,0!==(u=In(e,t,r,i,n.cx,n.cy,n.radius)).length&&c.push(u[0],u[1])});for(var d=0;d<h.length/4;d++)0!==(u=Dn(e,t,r,i,h[4*d],h[4*d+1],h[4*d+2],h[4*d+3],!1)).length&&c.push(u[0],u[1]);if(c.length>2){for(var f=[c[0],c[1]],p=Math.pow(f[0]-e,2)+Math.pow(f[1]-t,2),g=1;g<c.length/2;g++){var v=Math.pow(c[2*g]-e,2)+Math.pow(c[2*g+1]-t,2);v<=p&&(f[0]=c[2*g],f[1]=c[2*g+1],p=v)}return f}return c}(i,o,this.points,e,t,0,0,0,this.getOrCreateCorners(e,t,n,r,s,l,"corners"))},checkPoint:function(e,t,n,r,i,o,a,s,l){return function(e,t,n,r,i,o,a,s){for(var l=new Array(2*n.length),u=0;u<s.length;u++){var c=s[u];if(l[4*u+0]=c.startX,l[4*u+1]=c.startY,l[4*u+2]=c.stopX,l[4*u+3]=c.stopY,Math.pow(c.cx-e,2)+Math.pow(c.cy-t,2)<=Math.pow(c.radius,2))return!0}return Nn(e,t,l)}(e,t,this.points,0,0,0,0,this.getOrCreateCorners(o,a,r,i,s,l,"corners"))}}},Mh.generateRoundRectangle=function(){return this.nodeShapes["round-rectangle"]=this.nodeShapes.roundrectangle={renderer:this,name:"round-rectangle",points:zn(4,0),draw:function(e,t,n,r,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,this.points,o)},intersectLine:function(e,t,n,r,i,o,a,s){return En(i,o,e,t,n,r,a,s)},checkPoint:function(e,t,n,r,i,o,a,s){var l=r/2,u=i/2;s="auto"===s?Gn(r,i):s;var c=2*(s=Math.min(l,u,s));return!!_n(e,t,this.points,o,a,r,i-c,[0,-1],n)||(!!_n(e,t,this.points,o,a,r-c,i,[0,-1],n)||(!!Pn(e,t,c,c,o-l+s,a-u+s,n)||(!!Pn(e,t,c,c,o+l-s,a-u+s,n)||(!!Pn(e,t,c,c,o+l-s,a+u-s,n)||!!Pn(e,t,c,c,o-l+s,a+u-s,n)))))}}},Mh.generateCutRectangle=function(){return this.nodeShapes["cut-rectangle"]=this.nodeShapes.cutrectangle={renderer:this,name:"cut-rectangle",cornerLength:8,points:zn(4,0),draw:function(e,t,n,r,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,null,o)},generateCutTrianglePts:function(e,t,n,r,i){var o="auto"===i?this.cornerLength:i,a=t/2,s=e/2,l=n-s,u=n+s,c=r-a,h=r+a;return{topLeft:[l,c+o,l+o,c,l+o,c+o],topRight:[u-o,c,u,c+o,u-o,c+o],bottomRight:[u,h-o,u-o,h,u-o,h-o],bottomLeft:[l+o,h,l,h-o,l+o,h-o]}},intersectLine:function(e,t,n,r,i,o,a,s){var l=this.generateCutTrianglePts(n+2*a,r+2*a,e,t,s),u=[].concat.apply([],[l.topLeft.splice(0,4),l.topRight.splice(0,4),l.bottomRight.splice(0,4),l.bottomLeft.splice(0,4)]);return Rn(i,o,u,e,t)},checkPoint:function(e,t,n,r,i,o,a,s){var l="auto"===s?this.cornerLength:s;if(_n(e,t,this.points,o,a,r,i-2*l,[0,-1],n))return!0;if(_n(e,t,this.points,o,a,r-2*l,i,[0,-1],n))return!0;var u=this.generateCutTrianglePts(r,i,o,a);return Nn(e,t,u.topLeft)||Nn(e,t,u.topRight)||Nn(e,t,u.bottomRight)||Nn(e,t,u.bottomLeft)}}},Mh.generateBarrel=function(){return this.nodeShapes.barrel={renderer:this,name:"barrel",points:zn(4,0),draw:function(e,t,n,r,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,o,a,s){var l=this.generateBarrelBezierPts(n+2*a,r+2*a,e,t),u=function(e){var t=ln({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.15),n=ln({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.5),r=ln({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.85);return[e[0],e[1],t.x,t.y,n.x,n.y,r.x,r.y,e[4],e[5]]},c=[].concat(u(l.topLeft),u(l.topRight),u(l.bottomRight),u(l.bottomLeft));return Rn(i,o,c,e,t)},generateBarrelBezierPts:function(e,t,n,r){var i=t/2,o=e/2,a=n-o,s=n+o,l=r-i,u=r+i,c=Xn(e,t),h=c.heightOffset,d=c.widthOffset,f=c.ctrlPtOffsetPct*e,p={topLeft:[a,l+h,a+f,l,a+d,l],topRight:[s-d,l,s-f,l,s,l+h],bottomRight:[s,u-h,s-f,u,s-d,u],bottomLeft:[a+d,u,a+f,u,a,u-h]};return p.topLeft.isTop=!0,p.topRight.isTop=!0,p.bottomLeft.isBottom=!0,p.bottomRight.isBottom=!0,p},checkPoint:function(e,t,n,r,i,o,a,s){var l=Xn(r,i),u=l.heightOffset,c=l.widthOffset;if(_n(e,t,this.points,o,a,r,i-2*u,[0,-1],n))return!0;if(_n(e,t,this.points,o,a,r-2*c,i,[0,-1],n))return!0;for(var h=this.generateBarrelBezierPts(r,i,o,a),d=function(e,t,n){var r,i,o=n[4],a=n[2],s=n[0],l=n[5],u=n[1],c=Math.min(o,s),h=Math.max(o,s),d=Math.min(l,u),f=Math.max(l,u);if(c<=e&&e<=h&&d<=t&&t<=f){var p=[(r=o)-2*(i=a)+s,2*(i-r),r],g=function(e,t,n,r){var i=t*t-4*e*(n-=r);if(i<0)return[];var o=Math.sqrt(i),a=2*e;return[(-t+o)/a,(-t-o)/a]}(p[0],p[1],p[2],e),v=g.filter(function(e){return 0<=e&&e<=1});if(v.length>0)return v[0]}return null},f=Object.keys(h),p=0;p<f.length;p++){var g=h[f[p]],v=d(e,t,g);if(null!=v){var y=g[5],m=g[3],b=g[1],x=sn(y,m,b,v);if(g.isTop&&x<=t)return!0;if(g.isBottom&&t<=x)return!0}}return!1}}},Mh.generateBottomRoundrectangle=function(){return this.nodeShapes["bottom-round-rectangle"]=this.nodeShapes.bottomroundrectangle={renderer:this,name:"bottom-round-rectangle",points:zn(4,0),draw:function(e,t,n,r,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,this.points,o)},intersectLine:function(e,t,n,r,i,o,a,s){var l=t-(r/2+a),u=Dn(i,o,e,t,e-(n/2+a),l,e+(n/2+a),l,!1);return u.length>0?u:En(i,o,e,t,n,r,a,s)},checkPoint:function(e,t,n,r,i,o,a,s){var l=2*(s="auto"===s?Gn(r,i):s);if(_n(e,t,this.points,o,a,r,i-l,[0,-1],n))return!0;if(_n(e,t,this.points,o,a,r-l,i,[0,-1],n))return!0;var u=r/2+2*n,c=i/2+2*n;return!!Nn(e,t,[o-u,a-c,o-u,a,o+u,a,o+u,a-c])||(!!Pn(e,t,l,l,o+r/2-s,a+i/2-s,n)||!!Pn(e,t,l,l,o-r/2+s,a+i/2-s,n))}}},Mh.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",zn(3,0)),this.generateRoundPolygon("round-triangle",zn(3,0)),this.generatePolygon("rectangle",zn(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",zn(5,0)),this.generateRoundPolygon("round-pentagon",zn(5,0)),this.generatePolygon("hexagon",zn(6,0)),this.generateRoundPolygon("round-hexagon",zn(6,0)),this.generatePolygon("heptagon",zn(7,0)),this.generateRoundPolygon("round-heptagon",zn(7,0)),this.generatePolygon("octagon",zn(8,0)),this.generateRoundPolygon("round-octagon",zn(8,0));var r=new Array(20),i=Vn(5,0),o=Vn(5,Math.PI/5),a=.5*(3-Math.sqrt(5));a*=1.57;for(var s=0;s<o.length/2;s++)o[2*s]*=a,o[2*s+1]*=a;for(s=0;s<5;s++)r[4*s]=i[2*s],r[4*s+1]=i[2*s+1],r[4*s+2]=o[2*s],r[4*s+3]=o[2*s+1];r=Fn(r),this.generatePolygon("star",r),this.generatePolygon("vee",[-1,-1,0,-.333,1,-1,0,1]),this.generatePolygon("rhomboid",[-1,-1,.333,-1,1,1,-.333,1]),this.generatePolygon("right-rhomboid",[-.333,-1,1,-1,.333,1,-1,1]),this.nodeShapes.concavehexagon=this.generatePolygon("concave-hexagon",[-1,-.95,-.75,0,-1,.95,1,.95,.75,0,1,-.95]);var l=[-1,-1,.25,-1,1,0,.25,1,-1,1];this.generatePolygon("tag",l),this.generateRoundPolygon("round-tag",l),e.makePolygon=function(e){var n,r="polygon-"+e.join("$");return(n=this[r])?n:t.generatePolygon(r,e)}};var Ah={timeToRender:function(){return this.redrawTotalTime/this.redrawCount},redraw:function(e){e=e||pt();var t=this;void 0===t.averageRedrawTime&&(t.averageRedrawTime=0),void 0===t.lastRedrawTime&&(t.lastRedrawTime=0),void 0===t.lastDrawTime&&(t.lastDrawTime=0),t.requestedFrame=!0,t.renderOptions=e},beforeRender:function(e,t){if(!this.destroyed){null==t&<("Priority is not optional for beforeRender");var n=this.beforeRenderCallbacks;n.push({fn:e,priority:t}),n.sort(function(e,t){return t.priority-e.priority})}}},Nh=function(e,t,n){for(var r=e.beforeRenderCallbacks,i=0;i<r.length;i++)r[i].fn(t,n)};Ah.startRenderLoop=function(){var e=this,t=e.cy;if(!e.renderLoopStarted){e.renderLoopStarted=!0;var n=function(r){if(!e.destroyed){if(t.batching());else if(e.requestedFrame&&!e.skipFrame){e.requestedFrame=!1,Nh(e,!0,r);var i=Ge();e.render(e.renderOptions);var o=e.lastDrawTime=Ge();void 0===e.averageRedrawTime&&(e.averageRedrawTime=o-i),void 0===e.redrawCount&&(e.redrawCount=0),e.redrawCount++,void 0===e.redrawTotalTime&&(e.redrawTotalTime=0);var a=o-i;e.redrawTotalTime+=a,e.lastRedrawTime=a,e.averageRedrawTime=e.averageRedrawTime/2+a/2}else Nh(e,!1,r);e.skipFrame=!1,Ve(n)}};Ve(n)}};var _h=function(e){this.init(e)},Sh=_h.prototype;Sh.clientFunctions=["redrawHint","render","renderTo","matchCanvasSize","nodeShapeImpl","arrowShapeImpl"],Sh.init=function(e){var t=this;t.options=e,t.cy=e.cy;var n=t.container=e.cy.container(),r=t.cy.window();if(r){var i=r.document,o=i.head,a="__________cytoscape_stylesheet",s="__________cytoscape_container",l=null!=i.getElementById(a);if(n.className.indexOf(s)<0&&(n.className=(n.className||"")+" "+s),!l){var u=i.createElement("style");u.id=a,u.textContent="."+s+" { position: relative; }",o.insertBefore(u,o.children[0])}"static"===r.getComputedStyle(n).getPropertyValue("position")&&ct("A Cytoscape container has style position:static and so can not use UI extensions properly")}t.selection=[void 0,void 0,void 0,void 0,0],t.bezierProjPcts=[.05,.225,.4,.5,.6,.775,.95],t.hoverData={down:null,last:null,downTime:null,triggerMode:null,dragging:!1,initialPan:[null,null],capture:!1},t.dragData={possibleDragElements:[]},t.touchData={start:null,capture:!1,startPosition:[null,null,null,null,null,null],singleTouchStartTime:null,singleTouchMoved:!0,now:[null,null,null,null,null,null],earlier:[null,null,null,null,null,null]},t.redraws=0,t.showFps=e.showFps,t.debug=e.debug,t.webgl=e.webgl,t.hideEdgesOnViewport=e.hideEdgesOnViewport,t.textureOnViewport=e.textureOnViewport,t.wheelSensitivity=e.wheelSensitivity,t.motionBlurEnabled=e.motionBlur,t.forcedPixelRatio=te(e.pixelRatio)?e.pixelRatio:null,t.motionBlur=e.motionBlur,t.motionBlurOpacity=e.motionBlurOpacity,t.motionBlurTransparency=1-t.motionBlurOpacity,t.motionBlurPxRatio=1,t.mbPxRBlurry=1,t.minMbLowQualFrames=4,t.fullQualityMb=!1,t.clearedForMotionBlur=[],t.desktopTapThreshold=e.desktopTapThreshold,t.desktopTapThreshold2=e.desktopTapThreshold*e.desktopTapThreshold,t.touchTapThreshold=e.touchTapThreshold,t.touchTapThreshold2=e.touchTapThreshold*e.touchTapThreshold,t.tapholdDuration=500,t.bindings=[],t.beforeRenderCallbacks=[],t.beforeRenderPriorities={animations:400,eleCalcs:300,eleTxrDeq:200,lyrTxrDeq:150,lyrTxrSkip:100},t.registerNodeShapes(),t.registerArrowShapes(),t.registerCalculationListeners()},Sh.notify=function(e,t){var n=this,r=n.cy;this.destroyed||("init"!==e?"destroy"!==e?(("add"===e||"remove"===e||"move"===e&&r.hasCompoundNodes()||"load"===e||"zorder"===e||"mount"===e)&&n.invalidateCachedZSortedEles(),"viewport"===e&&n.redrawHint("select",!0),"gc"===e&&n.redrawHint("gc",!0),"load"!==e&&"resize"!==e&&"mount"!==e||(n.invalidateContainerClientCoordsCache(),n.matchCanvasSize(n.container)),n.redrawHint("eles",!0),n.redrawHint("drag",!0),this.startRenderLoop(),this.redraw()):n.destroy():n.load())},Sh.destroy=function(){var e=this;e.destroyed=!0,e.cy.stopAnimationLoop();for(var t=0;t<e.bindings.length;t++){var n=e.bindings[t],r=n.target;(r.off||r.removeEventListener).apply(r,n.args)}if(e.bindings=[],e.beforeRenderCallbacks=[],e.onUpdateEleCalcsFns=[],e.removeObserver&&e.removeObserver.disconnect(),e.styleObserver&&e.styleObserver.disconnect(),e.resizeObserver&&e.resizeObserver.disconnect(),e.labelCalcDiv)try{document.body.removeChild(e.labelCalcDiv)}catch(e){}},Sh.isHeadless=function(){return!1},[Lc,wh,Eh,Ch,Mh,Ah].forEach(function(e){Te(Sh,e)});var kh=1e3/60,Ph=function(e){return function(){var t=this,n=this.renderer;if(!t.dequeueingSetup){t.dequeueingSetup=!0;var r=Re(function(){n.redrawHint("eles",!0),n.redrawHint("drag",!0),n.redraw()},e.deqRedrawThreshold),i=e.priority||st;n.beforeRender(function(i,o){var a=Ge(),s=n.averageRedrawTime,l=n.lastRedrawTime,u=[],c=n.cy.extent(),h=n.getPixelRatio();for(i||n.flushRenderedStyleQueue();;){var d=Ge(),f=d-a,p=d-o;if(l<kh){var g=kh-(i?s:0);if(p>=e.deqFastCost*g)break}else if(i){if(f>=e.deqCost*l||f>=e.deqAvgCost*s)break}else if(p>=e.deqNoDrawCost*kh)break;var v=e.deq(t,h,c);if(!(v.length>0))break;for(var y=0;y<v.length;y++)u.push(v[y])}u.length>0&&(e.onDeqd(t,u),!i&&e.shouldRedraw(t,u,h,c)&&r())},i(t))}}},Ih=function(){return l(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ot;s(this,e),this.idsByKey=new wt,this.keyForId=new wt,this.cachesByLvl=new wt,this.lvls=[],this.getKey=t,this.doesEleInvalidateKey=n},[{key:"getIdsFor",value:function(e){null==e&<("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new Tt,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 wt,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)}}])}(),Oh=7.99,Dh={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},Lh=gt({getKey:null,doesEleInvalidateKey:ot,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:it,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Rh=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=Lh(t);Te(n,r),n.lookup=new Ih(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},Bh=Rh.prototype;Bh.reasons=Dh,Bh.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},Bh.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},Bh.getElementQueue=function(){var e=this.eleCacheQueue=this.eleCacheQueue||new Dt(function(e,t){return t.reqs-e.reqs});return e},Bh.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},Bh.getElement=function(e,t,n,r,i){var o=this,a=this.renderer,s=a.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(!o.allowEdgeTxrCaching&&e.isEdge()||!o.allowParentTxrCaching&&e.isParent())return null;if(null==r&&(r=Math.ceil(tn(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,h=t.w*u,d=a.eleTextBiggerThanMin(e,u);if(!this.isVisible(e,d))return null;var f,p=l.get(e,r);if(p&&p.invalidated&&(p.invalidated=!1,p.texture.invalidatedWidth-=p.width),p)return p;if(f=c<=25?25:c<=50?50:50*Math.ceil(c/50),c>1024||h>1024)return null;var g=o.getTextureQueue(f),v=g[g.length-2],y=function(){return o.recycleTexture(f,h)||o.addTexture(f,h)};v||(v=g[g.length-1]),v||(v=y()),v.width-v.usedWidth<h&&(v=y());for(var m,b=function(e){return e&&e.scaledLabelShown===d},x=i&&i===Dh.dequeue,w=i&&i===Dh.highQuality,E=i&&i===Dh.downscale,T=r+1;T<=3;T++){var C=l.get(e,T);if(C){m=C;break}}var M=m&&m.level===r+1?m:null,A=function(){v.context.drawImage(M.texture.canvas,M.x,0,M.width,M.height,v.usedWidth,0,h,c)};if(v.context.setTransform(1,0,0,1,0,0),v.context.clearRect(v.usedWidth,0,h,f),b(M))A();else if(b(m)){if(!w)return o.queueElement(e,m.level-1),m;for(var N=m.level;N>r;N--)M=o.getElement(e,t,n,N,Dh.downscale);A()}else{var _;if(!x&&!w&&!E)for(var S=r-1;S>=-4;S--){var k=l.get(e,S);if(k){_=k;break}}if(b(_))return o.queueElement(e,r),_;v.context.translate(v.usedWidth,0),v.context.scale(u,u),this.drawElement(v.context,e,t,d,!1),v.context.scale(1/u,1/u),v.context.translate(-v.usedWidth,0)}return p={x:v.usedWidth,texture:v,level:r,scale:u,width:h,height:c,scaledLabelShown:d},v.usedWidth+=Math.ceil(h+8),v.eleCaches.push(p),l.set(e,r,p),o.checkTextureFullness(v),p},Bh.invalidateElements=function(e){for(var t=0;t<e.length;t++)this.invalidateElement(e[t])},Bh.invalidateElement=function(e){var t=this,n=t.lookup,r=[];if(n.isInvalid(e)){for(var i=-4;i<=3;i++){var o=n.getForCachedKey(e,i);o&&r.push(o)}if(n.invalidate(e))for(var a=0;a<r.length;a++){var s=r[a],l=s.texture;l.invalidatedWidth+=s.width,s.invalidated=!0,t.checkTextureUtility(l)}t.removeFromQueue(e)}},Bh.checkTextureUtility=function(e){e.invalidatedWidth>=.2*e.width&&this.retireTexture(e)},Bh.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?vt(t,e):e.fullnessChecks++},Bh.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;vt(n,e),e.retired=!0;for(var i=e.eleCaches,o=0;o<i.length;o++){var a=i[o];r.deleteCache(a.key,a.level)}yt(i),this.getRetiredTextureQueue(t).push(e)},Bh.addTexture=function(e,t){var n={};return this.getTextureQueue(e).push(n),n.eleCaches=[],n.height=e,n.width=Math.max(1024,t),n.usedWidth=0,n.invalidatedWidth=0,n.fullnessChecks=0,n.canvas=this.renderer.makeOffscreenCanvas(n.width,n.height),n.context=n.canvas.getContext("2d"),n},Bh.recycleTexture=function(e,t){for(var n=this.getTextureQueue(e),r=this.getRetiredTextureQueue(e),i=0;i<r.length;i++){var o=r[i];if(o.width>=t)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,yt(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),vt(r,o),n.push(o),o}},Bh.queueElement=function(e,t){var n=this.getElementQueue(),r=this.getElementKeyToQueue(),i=this.getKey(e),o=r[i];if(o)o.level=Math.max(o.level,t),o.eles.merge(e),o.reqs++,n.updateItem(o);else{var a={eles:e.spawn().merge(e),level:t,reqs:1,key:i};n.push(a),r[i]=a}},Bh.dequeue=function(e){for(var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),i=[],o=t.lookup,a=0;a<1&&n.size()>0;a++){var s=n.pop(),l=s.key,u=s.eles[0],c=o.hasCache(u,s.level);if(r[l]=null,!c){i.push(s);var h=t.getBoundingBox(u);t.getElement(u,h,e,s.level,Dh.dequeue)}}return i},Bh.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=rt,t.updateItem(i),t.pop(),n[r]=null):i.eles.unmerge(e))},Bh.onDequeue=function(e){this.onDequeues.push(e)},Bh.offDequeue=function(e){vt(this.onDequeues,e)},Bh.setupDequeueing=Ph({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<e.onDequeues.length;n++){(0,e.onDequeues[n])(t)}},shouldRedraw:function(e,t,n,r){for(var i=0;i<t.length;i++)for(var o=t[i].eles,a=0;a<o.length;a++){var s=o[a].boundingBox();if(vn(s,r))return!0}return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var zh=function(e){var t=this,n=t.renderer=e,r=n.cy;t.layersByLevel={},t.firstGet=!0,t.lastInvalidationTime=Ge()-500,t.skipping=!1,t.eleTxrDeqs=r.collection(),t.scheduleElementRefinement=Re(function(){t.refineElementTextures(t.eleTxrDeqs),t.eleTxrDeqs.unmerge(t.eleTxrDeqs)},50),n.beforeRender(function(e,n){n-t.lastInvalidationTime<=250?t.skipping=!0:t.skipping=!1},n.beforeRenderPriorities.lyrTxrSkip);t.layersQueue=new Dt(function(e,t){return t.reqs-e.reqs}),t.setupDequeueing()},Fh=zh.prototype,Vh=0,Gh=Math.pow(2,53)-1;Fh.makeLayer=function(e,t){var n=Math.pow(2,t),r=Math.ceil(e.w*n),i=Math.ceil(e.h*n),o=this.renderer.makeOffscreenCanvas(r,i),a={id:Vh=++Vh%Gh,bb:e,level:t,width:r,height:i,canvas:o,context:o.getContext("2d"),eles:[],elesQueue:[],reqs:0},s=a.context,l=-a.bb.x1,u=-a.bb.y1;return s.scale(n,n),s.translate(l,u),a},Fh.getLayers=function(e,t,n){var r=this,i=r.renderer.cy.zoom(),o=r.firstGet;if(r.firstGet=!1,null==n)if((n=Math.ceil(tn(i*t)))<-4)n=-4;else if(i>=3.99||n>2)return null;r.validateLayersElesOrdering(n,e);var a,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 o=c.length-1;o>=0;o--){var a=c[o];a.invalid&&vt(c,a)}}();var h=function(t){var i=(t=t||{}).after;!function(){if(!a){a=cn();for(var t=0;t<e.length;t++)hn(a,e[t].boundingBox())}}();var o=Math.ceil(a.w*u),s=Math.ceil(a.h*u);if(o>32767||s>32767)return null;if(o*s>16e6)return null;var l=r.makeLayer(a,n);if(null!=i){var h=c.indexOf(i)+1;c.splice(h,0,l)}else(void 0===t.insert||t.insert)&&c.unshift(l);return l};if(r.skipping&&!o)return null;for(var d=null,f=e.length/1,p=!o,g=0;g<e.length;g++){var v=e[g],y=v._private.rscratch,m=y.imgLayerCaches=y.imgLayerCaches||{},b=m[n];if(b)d=b;else{if((!d||d.eles.length>=f||!bn(d.bb,v.boundingBox()))&&!(d=h({insert:!0,after:d})))return null;s||p?r.queueLayer(d,v):r.drawEleInLayer(d,v,n,t),d.eles.push(v),m[n]=d}}return s||(p?null:c)},Fh.getEleLevelForLayerLevel=function(e,t){return e},Fh.drawEleInLayer=function(e,t,n,r){var i=this.renderer,o=e.context,a=t.boundingBox();0!==a.w&&0!==a.h&&t.visible()&&(n=this.getEleLevelForLayerLevel(n,r),i.setImgSmoothing(o,!1),i.drawCachedElement(o,t,null,null,n,true),i.setImgSmoothing(o,!0))},Fh.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,i=0;i<n.length;i++){var o=n[i];if(o.reqs>0)return!1;if(o.invalid)return!1;r+=o.eles.length}return r===t.length},Fh.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=-1,a=0;a<t.length;a++)if(i.eles[0]===t[a]){o=a;break}if(o<0)this.invalidateLayer(i);else{var s=o;for(a=0;a<i.eles.length;a++)if(i.eles[a]!==t[s+a]){this.invalidateLayer(i);break}}}},Fh.updateElementsInLayers=function(e,t){for(var n=oe(e[0]),r=0;r<e.length;r++)for(var i=n?null:e[r],o=n?e[r]:e[r].ele,a=o._private.rscratch,s=a.imgLayerCaches=a.imgLayerCaches||{},l=-4;l<=2;l++){var u=s[l];u&&(i&&this.getEleLevelForLayerLevel(u.level)!==i.level||t(u,o,i))}},Fh.haveLayers=function(){for(var e=!1,t=-4;t<=2;t++){var n=this.layersByLevel[t];if(n&&n.length>0){e=!0;break}}return e},Fh.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=Ge(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,function(e,n,r){t.invalidateLayer(e)}))},Fh.invalidateLayer=function(e){if(this.lastInvalidationTime=Ge(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];vt(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var i=0;i<n.length;i++){var o=n[i]._private.rscratch.imgLayerCaches;o&&(o[t]=null)}}},Fh.refineElementTextures=function(e){var t=this;t.updateElementsInLayers(e,function(e,n,r){var i=e.replacement;if(i||((i=e.replacement=t.makeLayer(e.bb,e.level)).replaces=e,i.eles=e.eles),!i.reqs)for(var o=0;o<i.eles.length;o++)t.queueLayer(i,i.eles[o])})},Fh.enqueueElementRefinement=function(e){this.eleTxrDeqs.merge(e),this.scheduleElementRefinement()},Fh.queueLayer=function(e,t){var n=this.layersQueue,r=e.elesQueue,i=r.hasId=r.hasId||{};if(!e.replacement){if(t){if(i[t.id()])return;r.push(t),i[t.id()]=!0}e.reqs?(e.reqs++,n.updateItem(e)):(e.reqs=1,n.push(e))}},Fh.dequeue=function(e){for(var t=this,n=t.layersQueue,r=[],i=0;i<1&&0!==n.size();){var o=n.peek();if(o.replacement)n.pop();else if(o.replaces&&o!==o.replaces.replacement)n.pop();else if(o.invalid)n.pop();else{var a=o.elesQueue.shift();a&&(t.drawEleInLayer(o,a,o.level,e),i++),0===r.length&&r.push(!0),0===o.elesQueue.length&&(n.pop(),o.reqs=0,o.replaces&&t.applyLayerReplacement(o),t.requestRedraw())}}return r},Fh.applyLayerReplacement=function(e){var t=this.layersByLevel[e.level],n=e.replaces,r=t.indexOf(n);if(!(r<0||n.invalid)){t[r]=e;for(var i=0;i<e.eles.length;i++){var o=e.eles[i]._private,a=o.imgLayerCaches=o.imgLayerCaches||{};a&&(a[e.level]=e)}this.requestRedraw()}},Fh.requestRedraw=Re(function(){var e=this.renderer;e.redrawHint("eles",!0),e.redrawHint("drag",!0),e.redraw()},100),Fh.setupDequeueing=Ph({deqRedrawThreshold:50,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t){return e.dequeue(t)},onDeqd:st,shouldRedraw:it,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var Yh,Xh={};function $h(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.lineTo(r.x,r.y)}}function Uh(e,t,n){for(var r,i=0;i<t.length;i++){var o=t[i];0===i&&(r=o),e.lineTo(o.x,o.y)}e.quadraticCurveTo(n.x,n.y,r.x,r.y)}function jh(e,t,n){e.beginPath&&e.beginPath();for(var r=t,i=0;i<r.length;i++){var o=r[i];e.lineTo(o.x,o.y)}var a=n,s=n[0];e.moveTo(s.x,s.y);for(i=1;i<a.length;i++){o=a[i];e.lineTo(o.x,o.y)}e.closePath&&e.closePath()}function Hh(e,t,n,r,i){e.beginPath&&e.beginPath(),e.arc(n,r,i,0,2*Math.PI,!1);var o=t,a=o[0];e.moveTo(a.x,a.y);for(var s=0;s<o.length;s++){var l=o[s];e.lineTo(l.x,l.y)}e.closePath&&e.closePath()}function Wh(e,t,n,r){e.arc(t,n,r,0,2*Math.PI,!1)}Xh.arrowShapeImpl=function(e){return(Yh||(Yh={polygon:$h,"triangle-backcurve":Uh,"triangle-tee":jh,"circle-triangle":Hh,"triangle-cross":jh,circle:Wh}))[e]};var qh={drawElement:function(e,t,n,r,i,o){t.isNode()?this.drawNode(e,t,n,r,i,o):this.drawEdge(e,t,n,r,i,o)},drawElementOverlay:function(e,t){t.isNode()?this.drawNodeOverlay(e,t):this.drawEdgeOverlay(e,t)},drawElementUnderlay:function(e,t){t.isNode()?this.drawNodeUnderlay(e,t):this.drawEdgeUnderlay(e,t)},drawCachedElementPortion:function(e,t,n,r,i,o,a,s){var l=this,u=n.getBoundingBox(t);if(0!==u.w&&0!==u.h){var c=n.getElement(t,u,r,i,o);if(null!=c){var h=s(l,t);if(0===h)return;var d,f,p,g,v,y,m=a(l,t),b=u.x1,x=u.y1,w=u.w,E=u.h;if(0!==m){var T=n.getRotationPoint(t);p=T.x,g=T.y,e.translate(p,g),e.rotate(m),(v=l.getImgSmoothing(e))||l.setImgSmoothing(e,!0);var C=n.getRotationOffset(t);d=C.x,f=C.y}else d=b,f=x;1!==h&&(y=e.globalAlpha,e.globalAlpha=y*h),e.drawImage(c.texture.canvas,c.x,0,c.width,c.height,d,f,w,E),1!==h&&(e.globalAlpha=y),0!==m&&(e.rotate(-m),e.translate(-p,-g),v||l.setImgSmoothing(e,!1))}else n.drawElement(e,t)}}},Kh=function(){return 0},Zh=function(e,t){return e.getTextAngle(t,null)},Qh=function(e,t){return e.getTextAngle(t,"source")},Jh=function(e,t){return e.getTextAngle(t,"target")},ed=function(e,t){return t.effectiveOpacity()},td=function(e,t){return t.pstyle("text-opacity").pfValue*t.effectiveOpacity()};qh.drawCachedElement=function(e,t,n,r,i,o){var a=this,s=a.data,l=s.eleTxrCache,u=s.lblTxrCache,c=s.slbTxrCache,h=s.tlbTxrCache,d=t.boundingBox(),f=!0===o?l.reasons.highQuality:null;if(0!==d.w&&0!==d.h&&t.visible()&&(!r||vn(d,r))){var p=t.isEdge(),g=t.element()._private.rscratch.badLine;a.drawElementUnderlay(e,t),a.drawCachedElementPortion(e,t,l,n,i,f,Kh,ed),p&&g||a.drawCachedElementPortion(e,t,u,n,i,f,Zh,td),p&&!g&&(a.drawCachedElementPortion(e,t,c,n,i,f,Qh,td),a.drawCachedElementPortion(e,t,h,n,i,f,Jh,td)),a.drawElementOverlay(e,t)}},qh.drawElements=function(e,t){for(var n=0;n<t.length;n++){var r=t[n];this.drawElement(e,r)}},qh.drawCachedElements=function(e,t,n,r){for(var i=0;i<t.length;i++){var o=t[i];this.drawCachedElement(e,o,n,r)}},qh.drawCachedNodes=function(e,t,n,r){for(var i=0;i<t.length;i++){var o=t[i];o.isNode()&&this.drawCachedElement(e,o,n,r)}},qh.drawLayeredElements=function(e,t,n,r){var i=this.data.lyrTxrCache.getLayers(t,n);if(i)for(var o=0;o<i.length;o++){var a=i[o],s=a.bb;0!==s.w&&0!==s.h&&e.drawImage(a.canvas,s.x1,s.y1,s.w,s.h)}else this.drawCachedElements(e,t,n,r)};var nd={drawEdge: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],o=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],a=this,s=t._private.rscratch;if((!o||t.visible())&&!s.badLine&&null!=s.allpts&&!isNaN(s.allpts[0])){var l;n&&(l=n,e.translate(-l.x1,-l.y1));var u=o?t.pstyle("opacity").value:1,c=o?t.pstyle("line-opacity").value:1,h=t.pstyle("curve-style").value,d=t.pstyle("line-style").value,f=t.pstyle("width").pfValue,p=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"===h?(a.eleStrokeStyle(e,t,n),a.drawEdgeTrianglePath(t,e,s.allpts)):(e.lineWidth=f,e.lineCap=p,a.eleStrokeStyle(e,t,n),a.drawEdgePath(t,e,s.allpts,d),e.lineCap="butt")},x=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;a.drawArrowheads(e,t,n)};if(e.lineJoin="round","yes"===t.pstyle("ghost").value){var w=t.pstyle("ghost-offset-x").pfValue,E=t.pstyle("ghost-offset-y").pfValue,T=t.pstyle("ghost-opacity").value,C=y*T;e.translate(w,E),b(C),x(C),e.translate(-w,-E)}else!function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;e.lineWidth=f+g,e.lineCap=p,g>0?(a.colorStrokeStyle(e,v,n),"straight-triangle"===h?a.drawEdgeTrianglePath(t,e,s.allpts):(a.drawEdgePath(t,e,s.allpts,d),e.lineCap="butt")):e.lineCap="butt"}();i&&a.drawEdgeUnderlay(e,t),b(),x(),i&&a.drawEdgeOverlay(e,t),a.drawElementText(e,t,null,r),n&&e.translate(l.x1,l.y1)}}},rd=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n){var r;if(n.visible()){var i=n.pstyle("".concat(e,"-opacity")).value;if(0!==i){var o=this,a=o.usePaths(),s=n._private.rscratch,l=2*n.pstyle("".concat(e,"-padding")).pfValue;t.lineWidth=l,"self"!==s.edgeType||a?t.lineCap="round":t.lineCap="butt";var u=null===(r=n.pstyle("".concat(e,"-fill")))||void 0===r?void 0:r.value;if("linear-gradient"===u||"radial-gradient"===u){var c=o.createGradientStyleFor(t,e,n,u,i);if(c)t.strokeStyle=c;else{var h=n.pstyle("".concat(e,"-color")).value;o.colorStrokeStyle(t,h,i)}}else{var d=n.pstyle("".concat(e,"-color")).value;o.colorStrokeStyle(t,d,i)}o.drawEdgePath(n,t,s.allpts,"solid")}}}};nd.drawEdgeOverlay=rd("overlay"),nd.drawEdgeUnderlay=rd("underlay"),nd.drawEdgePath=function(e,t,n,r){var i,o=e._private.rscratch,a=t,s=!1,l=this.usePaths(),c=e.pstyle("line-dash-pattern").pfValue,h=e.pstyle("line-dash-offset").pfValue;if(l){var d=n.join("$");o.pathCacheKey&&o.pathCacheKey===d?(i=t=o.pathCache,s=!0):(i=t=new Path2D,o.pathCacheKey=d,o.pathCache=i)}if(a.setLineDash)switch(r){case"dotted":a.setLineDash([1,1]);break;case"dashed":a.setLineDash(c),a.lineDashOffset=h;break;case"solid":a.setLineDash([])}if(!s&&!o.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),o.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var f=2;f+3<n.length;f+=4)t.quadraticCurveTo(n[f],n[f+1],n[f+2],n[f+3]);break;case"straight":case"haystack":for(var p=2;p+1<n.length;p+=2)t.lineTo(n[p],n[p+1]);break;case"segments":if(o.isRound){var g,v=u(o.roundCorners);try{for(v.s();!(g=v.n()).done;){oh(t,g.value)}}catch(e){v.e(e)}finally{v.f()}t.lineTo(n[n.length-2],n[n.length-1])}else for(var y=2;y+1<n.length;y+=2)t.lineTo(n[y],n[y+1])}t=a,l?t.stroke(i):t.stroke(),t.setLineDash&&t.setLineDash([])},nd.drawEdgeTrianglePath=function(e,t,n){t.fillStyle=t.strokeStyle;for(var r=e.pstyle("width").pfValue,i=0;i+1<n.length;i+=2){var o=[n[i+2]-n[i],n[i+3]-n[i+1]],a=Math.sqrt(o[0]*o[0]+o[1]*o[1]),s=[o[1]/a,-o[0]/a],l=[s[0]*r/2,s[1]*r/2];t.beginPath(),t.moveTo(n[i]-l[0],n[i+1]-l[1]),t.lineTo(n[i]+l[0],n[i+1]+l[1]),t.lineTo(n[i+2],n[i+3]),t.closePath(),t.fill()}},nd.drawArrowheads=function(e,t,n){var r=t._private.rscratch,i="haystack"===r.edgeType;i||this.drawArrowhead(e,t,"source",r.arrowStartX,r.arrowStartY,r.srcArrowAngle,n),this.drawArrowhead(e,t,"mid-target",r.midX,r.midY,r.midtgtArrowAngle,n),this.drawArrowhead(e,t,"mid-source",r.midX,r.midY,r.midsrcArrowAngle,n),i||this.drawArrowhead(e,t,"target",r.arrowEndX,r.arrowEndY,r.tgtArrowAngle,n)},nd.drawArrowhead=function(e,t,n,r,i,o,a){if(!(isNaN(r)||null==r||isNaN(i)||null==i||isNaN(o)||null==o)){var s=this,l=t.pstyle(n+"-arrow-shape").value;if("none"!==l){var u="hollow"===t.pstyle(n+"-arrow-fill").value?"both":"filled",c=t.pstyle(n+"-arrow-fill").value,h=t.pstyle("width").pfValue,d=t.pstyle(n+"-arrow-width"),f="match-line"===d.value?h:d.pfValue;"%"===d.units&&(f*=h);var p=t.pstyle("opacity").value;void 0===a&&(a=p);var g=e.globalCompositeOperation;1===a&&"hollow"!==c||(e.globalCompositeOperation="destination-out",s.colorFillStyle(e,[255,255,255],1),s.colorStrokeStyle(e,[255,255,255],1),s.drawArrowShape(t,e,u,h,l,f,r,i,o,n),e.globalCompositeOperation=g);var v=t.pstyle(n+"-arrow-color").value;s.colorFillStyle(e,v,a),s.colorStrokeStyle(e,v,a),s.drawArrowShape(t,e,c,h,l,f,r,i,o,n)}}},nd.drawArrowShape=function(e,t,n,r,i,o,a,s,l,u){var c,h=this,d=this.usePaths()&&"triangle-cross"!==i,f=!1,p=t,g={x:a,y:s},v=h.arrowShapes[i],y=Ru(e,u),m=this.getArrowWidth(r,y);if(d){var b=h.arrowPathCache=h.arrowPathCache||[],x=Ke(i),w=b[x];null!=w?(c=t=w,f=!0):(c=t=new Path2D,b[x]=c)}f||(t.beginPath&&t.beginPath(),d?v.draw(t,1,0,{x:0,y:0},1):v.draw(t,m,l,g,r),t.closePath&&t.closePath()),t=p,d&&(t.translate(a,s),t.rotate(l),t.scale(m,m)),"filled"!==n&&"both"!==n||(d?t.fill(c):t.fill()),"hollow"!==n&&"both"!==n||(t.lineWidth=o/(d?m:1),t.lineJoin="miter",d?t.stroke(c):t.stroke()),d&&(t.scale(1/m,1/m),t.rotate(-l),t.translate(-a,-s))};var id={safeDrawImage:function(e,t,n,r,i,o,a,s,l,u){if(!(i<=0||o<=0||l<=0||u<=0))try{e.drawImage(t,n,r,i,o,a,s,l,u)}catch(e){ct(e)}},drawInscribedImage:function(e,t,n,r,i){var o=this,a=n.position(),s=a.x,l=a.y,u=n.cy().style(),c=u.getIndexedStyle.bind(u),h=c(n,"background-fit","value",r),d=c(n,"background-repeat","value",r),f=n.width(),p=n.height(),g=2*n.padding(),v=f+("inner"===c(n,"background-width-relative-to","value",r)?0:g),y=p+("inner"===c(n,"background-height-relative-to","value",r)?0:g),m=n._private.rscratch,b="node"===c(n,"background-clip","value",r),x=c(n,"background-image-opacity","value",r)*i,w=c(n,"background-image-smoothing","value",r),E=n.pstyle("corner-radius").value;"auto"!==E&&(E=n.pstyle("corner-radius").pfValue);var T=t.width||t.cachedW,C=t.height||t.cachedH;null!=T&&null!=C||(document.body.appendChild(t),T=t.cachedW=t.width||t.offsetWidth,C=t.cachedH=t.height||t.offsetHeight,document.body.removeChild(t));var M=T,A=C;if("auto"!==c(n,"background-width","value",r)&&(M="%"===c(n,"background-width","units",r)?c(n,"background-width","pfValue",r)*v:c(n,"background-width","pfValue",r)),"auto"!==c(n,"background-height","value",r)&&(A="%"===c(n,"background-height","units",r)?c(n,"background-height","pfValue",r)*y:c(n,"background-height","pfValue",r)),0!==M&&0!==A){if("contain"===h)M*=N=Math.min(v/M,y/A),A*=N;else if("cover"===h){var N;M*=N=Math.max(v/M,y/A),A*=N}var _=s-v/2,S=c(n,"background-position-x","units",r),k=c(n,"background-position-x","pfValue",r);_+="%"===S?(v-M)*k:k;var P=c(n,"background-offset-x","units",r),I=c(n,"background-offset-x","pfValue",r);_+="%"===P?(v-M)*I:I;var O=l-y/2,D=c(n,"background-position-y","units",r),L=c(n,"background-position-y","pfValue",r);O+="%"===D?(y-A)*L:L;var R=c(n,"background-offset-y","units",r),B=c(n,"background-offset-y","pfValue",r);O+="%"===R?(y-A)*B:B,m.pathCache&&(_-=s,O-=l,s=0,l=0);var z=e.globalAlpha;e.globalAlpha=x;var F=o.getImgSmoothing(e),V=!1;if("no"===w&&F?(o.setImgSmoothing(e,!1),V=!0):"yes"!==w||F||(o.setImgSmoothing(e,!0),V=!0),"no-repeat"===d)b&&(e.save(),m.pathCache?e.clip(m.pathCache):(o.nodeShapes[o.getNodeShape(n)].draw(e,s,l,v,y,E,m),e.clip())),o.safeDrawImage(e,t,0,0,T,C,_,O,M,A),b&&e.restore();else{var G=e.createPattern(t,d);e.fillStyle=G,o.nodeShapes[o.getNodeShape(n)].draw(e,s,l,v,y,E,m),e.translate(_,O),e.fill(),e.translate(-_,-O)}e.globalAlpha=z,V&&o.setImgSmoothing(e,F)}}},od={};function ad(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:5,a=Math.min(o,r/2,i/2);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()}od.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),i=Math.ceil(tn(n*r));t=Math.pow(2,i)}return!(e.pstyle("font-size").pfValue*t<e.pstyle("min-zoomed-font-size").pfValue)},od.drawElementText=function(e,t,n,r,i){var o=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],a=this;if(null==r){if(o&&!a.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){var s=t.pstyle("label");if(!s||!s.value)return;var l=a.getLabelJustification(t),u="glyph"===t.pstyle("text-metrics").strValue;e.textAlign=l,e.textBaseline=u?"alphabetic":"bottom"}else{var c=t.element()._private.rscratch.badLine,h=t.pstyle("label"),d=t.pstyle("source-label"),f=t.pstyle("target-label");if(c||(!h||!h.value)&&(!d||!d.value)&&(!f||!f.value))return;e.textAlign="center",e.textBaseline="bottom"}var p,g=!n;n&&(p=n,e.translate(-p.x1,-p.y1)),null==i?(a.drawText(e,t,null,g,o),t.isEdge()&&(a.drawText(e,t,"source",g,o),a.drawText(e,t,"target",g,o))):a.drawText(e,t,i,g,o),n&&e.translate(p.x1,p.y1)},od.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n<this.fontCaches.length;n++)if((t=this.fontCaches[n]).context===e)return t;return t={context:e},this.fontCaches.push(t),t},od.setupTextStyle=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=t.pstyle("font-style").strValue,i=t.pstyle("font-size").pfValue+"px",o=t.pstyle("font-family").strValue,a=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+" "+a+" "+i+" "+o,e.lineJoin="round",this.colorFillStyle(e,u,s),this.colorStrokeStyle(e,c,l)},od.getTextAngle=function(e,t){var n,r=e._private.rscratch,i=t?t+"-":"",o=e.pstyle(i+"text-rotation");if("autorotate"===o.strValue){var a=mt(r,"labelAngle",t);n=e.isEdge()?a:0}else n="none"===o.strValue?0:o.pfValue;return n},od.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],o=t._private.rscratch,a=i?t.effectiveOpacity():1;if(!i||0!==a&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var s,l,u=mt(o,"labelX",n),c=mt(o,"labelY",n),h=this.getLabelText(t,n);if(null!=h&&""!==h&&!isNaN(u)&&!isNaN(c)){this.setupTextStyle(e,t,i);var d,f=n?n+"-":"",p=mt(o,"labelWidth",n),g=mt(o,"labelHeight",n),v=mt(o,"labelActualDescent",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;b&&(x="center",w="center"),u+=y,c+=m,0!==(d=r?this.getTextAngle(t,n):0)&&(s=u,l=c,e.translate(s,l),e.rotate(d),u=0,c=0);var E=Vs(x),T=Gs(w);switch(T){case"top":break;case"center":c+=g/2;break;case"bottom":c+=g}var C=t.pstyle("text-background-opacity").value,M=t.pstyle("text-border-opacity").value,A=t.pstyle("text-border-width").pfValue,N=t.pstyle("text-background-padding").pfValue,_=t.pstyle("text-background-shape").strValue,S="round-rectangle"===_||"roundrectangle"===_,k="circle"===_;if(C>0||A>0&&M>0){var P=e.fillStyle,I=e.strokeStyle,O=e.lineWidth,D=t.pstyle("text-background-color").value,L=t.pstyle("text-border-color").value,R=t.pstyle("text-border-style").value,B=C>0,z=A>0&&M>0,F=u-N;switch(E){case"left":F-=p;break;case"center":F-=p/2}var V=c-g-N,G=p+2*N,Y=g+2*N;if(B&&this.colorFillStyle(e,D,C*a),z&&(this.colorStrokeStyle(e,L,M*a),e.lineWidth=A,e.setLineDash))switch(R){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=A/4,e.setLineDash([]);break;default:e.setLineDash([])}if(S?(e.beginPath(),ad(e,F,V,G,Y,2)):k?(e.beginPath(),function(e,t,n,r,i){var o=Math.min(r,i)/2,a=t+r/2,s=n+i/2;e.beginPath(),e.arc(a,s,o,0,2*Math.PI),e.closePath()}(e,F,V,G,Y)):(e.beginPath(),e.rect(F,V,G,Y)),B&&e.fill(),z&&e.stroke(),z&&"double"===R){var X=A/2;e.beginPath(),S?ad(e,F+X,V+X,G-2*X,Y-2*X,2):e.rect(F+X,V+X,G-2*X,Y-2*X),e.stroke()}e.fillStyle=P,e.strokeStyle=I,e.lineWidth=O,e.setLineDash&&e.setLineDash([])}var $=2*t.pstyle("text-outline-width").pfValue;if($>0&&(e.lineWidth=$),c-=v,"wrap"===t.pstyle("text-wrap").value){var U=mt(o,"labelWrapCachedLines",n),j=mt(o,"labelLineHeight",n),H=p/2,W=this.getLabelJustification(t);switch("auto"===W||("left"===E?"left"===W?u+=-p:"center"===W&&(u+=-H):"center"===E?"left"===W?u+=-H:"right"===W&&(u+=H):"right"===E&&("center"===W?u+=H:"right"===W&&(u+=p))),T){case"top":case"center":case"bottom":c-=(U.length-1)*j}for(var q=0;q<U.length;q++)$>0&&e.strokeText(U[q],u,c),e.fillText(U[q],u,c),c+=j}else $>0&&e.strokeText(h,u,c),e.fillText(h,u,c);0!==d&&(e.rotate(-d),e.translate(-s,-l))}}};var sd={drawNode:function(e,t,n){var r,i,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=!(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,h=t.position();if(te(h.x)&&te(h.y)&&(!s||t.visible())){var d,f,p=s?t.effectiveOpacity():1,g=l.usePaths(),v=!1,y=t.padding();r=t.width()+2*y,i=t.height()+2*y,n&&(f=n,e.translate(-f.x1,-f.y1));for(var m=t.pstyle("background-image").value,b=new Array(m.length),x=new Array(m.length),w=0,E=0;E<m.length;E++){var T=m[E];if(b[E]=null!=T&&"none"!==T){var C=t.cy().style().getIndexedStyle(t,"background-image-crossorigin","value",E);w++,x[E]=l.getCachedImage(T,C,function(){u.backgroundTimestamp=Date.now(),t.emitAndNotify("background")})}}var M=t.pstyle("background-blacken").value,A=t.pstyle("border-width").pfValue,N=t.pstyle("background-opacity").value*p,_=t.pstyle("border-color").value,S=t.pstyle("border-style").value,k=t.pstyle("border-join").value,P=t.pstyle("border-cap").value,I=t.pstyle("border-position").value,O=t.pstyle("border-dash-pattern").pfValue,D=t.pstyle("border-dash-offset").pfValue,L=t.pstyle("border-opacity").value*p,R=t.pstyle("outline-width").pfValue,B=t.pstyle("outline-color").value,z=t.pstyle("outline-style").value,F=t.pstyle("outline-opacity").value*p,V=t.pstyle("outline-offset").value,G=t.pstyle("corner-radius").value;"auto"!==G&&(G=t.pstyle("corner-radius").pfValue);var Y=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N;l.eleFillStyle(e,t,n)},X=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:L;l.colorStrokeStyle(e,_,t)},$=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:F;l.colorStrokeStyle(e,B,t)},U=function(e,t,n,r){var i,o=l.nodePathCache=l.nodePathCache||[],a=Ze("polygon"===n?n+","+r.join(","):n,""+t,""+e,""+G),s=o[a],u=!1;return null!=s?(i=s,u=!0,c.pathCache=i):(i=new Path2D,o[a]=c.pathCache=i),{path:i,cacheHit:u}},j=t.pstyle("shape").strValue,H=t.pstyle("shape-polygon-points").pfValue;if(g){e.translate(h.x,h.y);var W=U(r,i,j,H);d=W.path,v=W.cacheHit}var q=function(){if(!v){var n=h;g&&(n={x:0,y:0}),l.nodeShapes[l.getNodeShape(t)].draw(d||e,n.x,n.y,r,i,G,c)}g?e.fill(d):e.fill()},K=function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=u.backgrounding,o=0,a=0;a<x.length;a++)if(b[a]){var s=t.cy().style().getIndexedStyle(t,"background-image-containment","value",a);r&&"over"===s||!r&&"inside"===s?o++:b[a]&&x[a].complete&&!x[a].error&&(o++,l.drawInscribedImage(e,x[a],t,a,n))}u.backgrounding=!(o===w),i!==u.backgrounding&&t.updateStyle(!1)},Z=function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;l.hasPie(t)&&(l.drawPie(e,t,o),n&&(g||l.nodeShapes[l.getNodeShape(t)].draw(e,h.x,h.y,r,i,G,c)))},Q=function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;l.hasStripe(t)&&(e.save(),g?e.clip(c.pathCache):(l.nodeShapes[l.getNodeShape(t)].draw(e,h.x,h.y,r,i,G,c),e.clip()),l.drawStripe(e,t,o),e.restore(),n&&(g||l.nodeShapes[l.getNodeShape(t)].draw(e,h.x,h.y,r,i,G,c)))},J=function(){var t=(M>0?M:-M)*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:p),n=M>0?0:255;0!==M&&(l.colorFillStyle(e,[n,n,n],t),g?e.fill(d):e.fill())},ee=function(){if(A>0){if(e.lineWidth=A,e.lineCap=P,e.lineJoin=k,e.setLineDash)switch(S){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash(O),e.lineDashOffset=D;break;case"solid":case"double":e.setLineDash([])}if("center"!==I){if(e.save(),e.lineWidth*=2,"inside"===I)g?e.clip(d):e.clip();else{var t=new Path2D;t.rect(-r/2-A,-i/2-A,r+2*A,i+2*A),t.addPath(d),e.clip(t,"evenodd")}g?e.stroke(d):e.stroke(),e.restore()}else g?e.stroke(d):e.stroke();if("double"===S){e.lineWidth=A/3;var n=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(d):e.stroke(),e.globalCompositeOperation=n}e.setLineDash&&e.setLineDash([])}},ne=function(){if(R>0){if(e.lineWidth=R,e.lineCap="butt",e.setLineDash)switch(z){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}var n=h;g&&(n={x:0,y:0});var o=l.getNodeShape(t),a=A;"inside"===I&&(a=0),"outside"===I&&(a*=2);var s,u=(r+a+(R+V))/r,c=(i+a+(R+V))/i,d=r*u,f=i*c,p=l.nodeShapes[o].points;if(g)s=U(d,f,o,p).path;if("ellipse"===o)l.drawEllipsePath(s||e,n.x,n.y,d,f);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(o)){var v=0,y=0,m=0;"round-diamond"===o?v=1.4*(a+V+R):"round-heptagon"===o?(v=1.075*(a+V+R),m=-(a/2+V+R)/35):"round-hexagon"===o?v=1.12*(a+V+R):"round-pentagon"===o?(v=1.13*(a+V+R),m=-(a/2+V+R)/15):"round-tag"===o?(v=1.12*(a+V+R),y=.07*(a/2+R+V)):"round-triangle"===o&&(v=(a+V+R)*(Math.PI/2),m=-(a+V/2+R)/Math.PI),0!==v&&(d=r*(u=(r+v)/r),["round-hexagon","round-tag"].includes(o)||(f=i*(c=(i+v)/i)));for(var b=d/2,x=f/2,w=(G="auto"===G?Yn(d,f):G)+(a+R+V)/2,E=new Array(p.length/2),T=new Array(p.length/2),C=0;C<p.length/2;C++)E[C]={x:n.x+y+b*p[2*C],y:n.y+m+x*p[2*C+1]};var M,N,_,S,k=E.length;for(N=E[k-1],M=0;M<k;M++)_=E[M%k],S=E[(M+1)%k],T[M]=ah(N,_,S,w),N=_,_=S;l.drawRoundPolygonPath(s||e,n.x+y,n.y+m,r*u,i*c,p,T)}else if(["roundrectangle","round-rectangle"].includes(o))G="auto"===G?Gn(d,f):G,l.drawRoundRectanglePath(s||e,n.x,n.y,d,f,G+(a+R+V)/2);else if(["cutrectangle","cut-rectangle"].includes(o))G="auto"===G?8:G,l.drawCutRectanglePath(s||e,n.x,n.y,d,f,null,G+(a+R+V)/4);else if(["bottomroundrectangle","bottom-round-rectangle"].includes(o))G="auto"===G?Gn(d,f):G,l.drawBottomRoundRectanglePath(s||e,n.x,n.y,d,f,G+(a+R+V)/2);else if("barrel"===o)l.drawBarrelPath(s||e,n.x,n.y,d,f);else if(o.startsWith("polygon")||["rhomboid","right-rhomboid","round-tag","tag","vee"].includes(o)){p=Sn(kn(p,(a+R+V)/r)),l.drawPolygonPath(s||e,n.x,n.y,r,i,p)}else{p=Sn(kn(p,-((a+R+V)/r))),l.drawPolygonPath(s||e,n.x,n.y,r,i,p)}if(g?e.stroke(s):e.stroke(),"double"===z){e.lineWidth=a/3;var P=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(s):e.stroke(),e.globalCompositeOperation=P}e.setLineDash&&e.setLineDash([])}};if("yes"===t.pstyle("ghost").value){var re=t.pstyle("ghost-offset-x").pfValue,ie=t.pstyle("ghost-offset-y").pfValue,oe=t.pstyle("ghost-opacity").value,ae=oe*p;e.translate(re,ie),$(),ne(),Y(oe*N),q(),K(ae,!0),X(oe*L),ee(),Z(0!==M||0!==A),Q(0!==M||0!==A),K(ae,!1),J(ae),e.translate(-re,-ie)}g&&e.translate(-h.x,-h.y),a&&l.drawNodeUnderlay(e,t,h,r,i),g&&e.translate(h.x,h.y),$(),ne(),Y(),q(),K(p,!0),X(),ee(),Z(0!==M||0!==A),Q(0!==M||0!==A),K(p,!1),J(),g&&e.translate(-h.x,-h.y),l.drawElementText(e,t,null,o),a&&l.drawNodeOverlay(e,t,h,r,i),n&&e.translate(f.x1,f.y1)}}},ld=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n,r,i,o){var a=this;if(n.visible()){var s=n.pstyle("".concat(e,"-padding")).pfValue,l=n.pstyle("".concat(e,"-opacity")).value,u=n.pstyle("".concat(e,"-shape")).value,c=n.pstyle("".concat(e,"-corner-radius")).value;if(l>0){var h;if(r=r||n.position(),null==i||null==o){var d=n.padding();i=n.width()+2*d,o=n.height()+2*d}var f=null===(h=n.pstyle("".concat(e,"-fill")))||void 0===h?void 0:h.value;if("linear-gradient"===f||"radial-gradient"===f){var p=a.createGradientStyleFor(t,e,n,f,l);if(p)t.fillStyle=p;else{var g=n.pstyle("".concat(e,"-color")).value;a.colorFillStyle(t,g,l)}}else{var v=n.pstyle("".concat(e,"-color")).value;a.colorFillStyle(t,v,l)}a.nodeShapes[u].draw(t,r.x,r.y,i+2*s,o+2*s,c),t.fill()}}}};sd.drawNodeOverlay=ld("overlay"),sd.drawNodeUnderlay=ld("underlay"),sd.hasPie=function(e){return(e=e[0])._private.hasPie},sd.hasStripe=function(e){return(e=e[0])._private.hasStripe},sd.drawPie=function(e,t,n,r){t=t[0],r=r||t.position();var i,o=t.cy().style(),a=t.pstyle("pie-size"),s=t.pstyle("pie-hole"),l=t.pstyle("pie-start-angle").pfValue,u=r.x,c=r.y,h=t.width(),d=t.height(),f=Math.min(h,d)/2,p=0;if(this.usePaths()&&(u=0,c=0),"%"===a.units?f*=a.pfValue:void 0!==a.pfValue&&(f=a.pfValue/2),"%"===s.units?i=f*s.pfValue:void 0!==s.pfValue&&(i=s.pfValue/2),!(i>=f))for(var g=1;g<=o.pieBackgroundN;g++){var v=t.pstyle("pie-"+g+"-background-size").value,y=t.pstyle("pie-"+g+"-background-color").value,m=t.pstyle("pie-"+g+"-background-opacity").value*n,b=v/100;b+p>1&&(b=1-p);var x=1.5*Math.PI+2*Math.PI*p,w=(x+=l)+2*Math.PI*b;0===v||p>=1||p+b>1||(0===i?(e.beginPath(),e.moveTo(u,c),e.arc(u,c,f,x,w),e.closePath()):(e.beginPath(),e.arc(u,c,f,x,w),e.arc(u,c,i,w,x,!0),e.closePath()),this.colorFillStyle(e,y,m),e.fill(),p+=b)}},sd.drawStripe=function(e,t,n,r){t=t[0],r=r||t.position();var i=t.cy().style(),o=r.x,a=r.y,s=t.width(),l=t.height(),u=0,c=this.usePaths();e.save();var h=t.pstyle("stripe-direction").value,d=t.pstyle("stripe-size");switch(h){case"vertical":break;case"righward":e.rotate(-Math.PI/2)}var f=s,p=l;"%"===d.units?(f*=d.pfValue,p*=d.pfValue):void 0!==d.pfValue&&(f=d.pfValue,p=d.pfValue),c&&(o=0,a=0),a-=f/2,o-=p/2;for(var g=1;g<=i.stripeBackgroundN;g++){var v=t.pstyle("stripe-"+g+"-background-size").value,y=t.pstyle("stripe-"+g+"-background-color").value,m=t.pstyle("stripe-"+g+"-background-opacity").value*n,b=v/100;b+u>1&&(b=1-u),0===v||u>=1||u+b>1||(e.beginPath(),e.rect(o,a+p*u,f,p*b),e.closePath(),this.colorFillStyle(e,y,m),e.fill(),u+=b)}e.restore()};var ud,cd={},hd=function(e,t){return function(e){return null==e[3]?1:e[3]}(e)*t};function dd(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(r));return r}function fd(e,t,n){void 0===n&&(n=t);var r=e.makeOffscreenCanvas(t,n),i=r.context=r.getContext("2d");return r.clear=function(){return i.clearRect(0,0,r.width,r.height)},r.clear(),r}function pd(e){var t=e.pixelRatio,n=e.cy.zoom(),r=e.cy.pan();return{zoom:n*t,pan:{x:r.x*t,y:r.y*t}}}function gd(e,t){return!!t.picking||"solid"===e.pstyle("background-fill").value&&("none"===e.pstyle("background-image").strValue&&(0===e.pstyle("border-width").value||(0===e.pstyle("border-opacity").value||"solid"===e.pstyle("border-style").value)))}function vd(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function yd(e,t,n){var r=e[0]/255,i=e[1]/255,o=e[2]/255,a=(null==e[3]?1:e[3])*t,s=n||new Array(4);return s[0]=r*a,s[1]=i*a,s[2]=o*a,s[3]=a,s}function md(e,t){var n=t||new Array(4);return n[0]=(255&e)/255,n[1]=(e>>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function bd(e){return e[0]+(e[1]<<8)+(e[2]<<16)+(e[3]<<24)}function xd(e,t){switch(t){case"float":return[1,e.FLOAT,4];case"vec2":return[2,e.FLOAT,4];case"vec3":return[3,e.FLOAT,4];case"vec4":return[4,e.FLOAT,4];case"int":return[1,e.INT,4];case"ivec2":return[2,e.INT,4]}}function wd(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function Ed(e,t,n,r,i,o){switch(t){case e.FLOAT:return new Float32Array(n.buffer,o*r,i);case e.INT:return new Int32Array(n.buffer,o*r,i)}}function Td(e,t,n,r){var i=h(xd(e,n),3),o=i[0],a=i[1],s=i[2],l=wd(e,a,t*o),u=o*s,c=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,t*u,e.DYNAMIC_DRAW),e.enableVertexAttribArray(r),a===e.FLOAT?e.vertexAttribPointer(r,o,a,!1,u,0):a===e.INT&&e.vertexAttribIPointer(r,o,a,u,0),e.vertexAttribDivisor(r,1),e.bindBuffer(e.ARRAY_BUFFER,null);for(var d=new Array(t),f=0;f<t;f++)d[f]=Ed(e,a,l,u,o,f);return c.dataArray=l,c.stride=u,c.size=o,c.getView=function(e){return d[e]},c.setPoint=function(e,t,n){var r=d[e];r[0]=t,r[1]=n},c.bufferSubData=function(t){e.bindBuffer(e.ARRAY_BUFFER,c),t?e.bufferSubData(e.ARRAY_BUFFER,0,l,0,t*o):e.bufferSubData(e.ARRAY_BUFFER,0,l)},c}cd.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},cd.paintCache=function(e){for(var t,n=this.paintCaches=this.paintCaches||[],r=!0,i=0;i<n.length;i++)if((t=n[i]).context===e){r=!1;break}return r&&(t={context:e},n.push(t)),t},cd.createGradientStyleFor=function(e,t,n,r,i){var o,a=this.usePaths(),s=n.pstyle(t+"-gradient-stop-colors").value,l=n.pstyle(t+"-gradient-stop-positions").pfValue;if("radial-gradient"===r)if(n.isEdge()){var u=n.sourceEndpoint(),c=n.targetEndpoint(),h=n.midpoint(),d=rn(u,h),f=rn(c,h);o=e.createRadialGradient(h.x,h.y,0,h.x,h.y,Math.max(d,f))}else{var p=a&&"background"===t?{x:0,y:0}:n.position(),g=n.paddedWidth(),v=n.paddedHeight();o=e.createRadialGradient(p.x,p.y,0,p.x,p.y,Math.max(g,v))}else if(n.isEdge()){var y=n.sourceEndpoint(),m=n.targetEndpoint();o=e.createLinearGradient(y.x,y.y,m.x,m.y)}else{var b=a&&"background"===t?{x:0,y:0}:n.position(),x=n.paddedWidth()/2,w=n.paddedHeight()/2;switch(n.pstyle(t+"-gradient-direction").value){case"to-bottom":o=e.createLinearGradient(b.x,b.y-w,b.x,b.y+w);break;case"to-top":o=e.createLinearGradient(b.x,b.y+w,b.x,b.y-w);break;case"to-left":o=e.createLinearGradient(b.x+x,b.y,b.x-x,b.y);break;case"to-right":o=e.createLinearGradient(b.x-x,b.y,b.x+x,b.y);break;case"to-bottom-right":case"to-right-bottom":o=e.createLinearGradient(b.x-x,b.y-w,b.x+x,b.y+w);break;case"to-top-right":case"to-right-top":o=e.createLinearGradient(b.x-x,b.y+w,b.x+x,b.y-w);break;case"to-bottom-left":case"to-left-bottom":o=e.createLinearGradient(b.x+x,b.y-w,b.x-x,b.y+w);break;case"to-top-left":case"to-left-top":o=e.createLinearGradient(b.x+x,b.y+w,b.x-x,b.y-w)}}if(!o)return null;for(var E=l.length===s.length,T=s.length,C=0;C<T;C++){var M=hd(s[C],i);o.addColorStop(E?l[C]:C/(T-1),"rgba("+s[C][0]+","+s[C][1]+","+s[C][2]+","+M+")")}return o},cd.gradientFillStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"background",t,n,r);if(!i)return null;e.fillStyle=i},cd.colorFillStyle=function(e,t,n){e.fillStyle="rgba("+t[0]+","+t[1]+","+t[2]+","+hd(t,n)+")"},cd.eleFillStyle=function(e,t,n){var r=t.pstyle("background-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientFillStyle(e,t,r,n);else{var i=t.pstyle("background-color").value;this.colorFillStyle(e,i,n)}},cd.gradientStrokeStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"line",t,n,r);if(!i)return null;e.strokeStyle=i},cd.colorStrokeStyle=function(e,t,n){e.strokeStyle="rgba("+t[0]+","+t[1]+","+t[2]+","+hd(t,n)+")"},cd.eleStrokeStyle=function(e,t,n){var r=t.pstyle("line-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientStrokeStyle(e,t,r,n);else{var i=t.pstyle("line-color").value;this.colorStrokeStyle(e,i,n)}},cd.matchCanvasSize=function(e){var t=this,n=t.data,r=t.findContainerClientCoords(),i=r[2],o=r[3],a=t.getPixelRatio(),s=t.motionBlurPxRatio;e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE]&&e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG]||(a=s);var l,u=i*a,c=o*a;if(u!==t.canvasWidth||c!==t.canvasHeight){t.fontCaches=null;var h=n.canvasContainer;h.style.width=i+"px",h.style.height=o+"px";for(var d=0;d<t.CANVAS_LAYERS;d++)(l=n.canvases[d]).width=u,l.height=c,l.style.width=i+"px",l.style.height=o+"px";for(d=0;d<t.BUFFER_COUNT;d++)(l=n.bufferCanvases[d]).width=u,l.height=c,l.style.width=i+"px",l.style.height=o+"px";t.textureMult=1,a<=1&&(l=n.bufferCanvases[t.TEXTURE_BUFFER],t.textureMult=2,l.width=u*t.textureMult,l.height=c*t.textureMult),t.canvasWidth=u,t.canvasHeight=c,t.pixelRatio=a}},cd.renderTo=function(e,t,n,r){this.render({forcedContext:e,forcedZoom:t,forcedPan:n,drawAllLayers:!0,forcedPxRatio:r})},cd.clearCanvas=function(){var e=this,t=e.data;function n(t){t.clearRect(0,0,e.canvasWidth,e.canvasHeight)}n(t.contexts[e.NODE]),n(t.contexts[e.DRAG])},cd.render=function(e){var t=this;e=e||pt();var n=t.cy,r=e.forcedContext,i=e.drawAllLayers,o=e.drawOnlyNodeLayer,a=e.forcedZoom,s=e.forcedPan,l=void 0===e.forcedPxRatio?this.getPixelRatio():e.forcedPxRatio,u=t.data,c=u.canvasNeedsRedraw,h=t.textureOnViewport&&!r&&(t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming),d=void 0!==e.motionBlur?e.motionBlur:t.motionBlur,f=t.motionBlurPxRatio,p=n.hasCompoundNodes(),g=t.hoverData.draggingEles,v=!(!t.hoverData.selecting&&!t.touchData.selecting),y=d=d&&!r&&t.motionBlurEnabled&&!v;r||(t.prevPxRatio!==l&&(t.invalidateContainerClientCoordsCache(),t.matchCanvasSize(t.container),t.redrawHint("eles",!0),t.redrawHint("drag",!0)),t.prevPxRatio=l),!r&&t.motionBlurTimeout&&clearTimeout(t.motionBlurTimeout),d&&(null==t.mbFrames&&(t.mbFrames=0),t.mbFrames++,t.mbFrames<3&&(y=!1),t.mbFrames>t.minMbLowQualFrames&&(t.motionBlurPxRatio=t.mbPxRBlurry)),t.clearingMotionBlur&&(t.motionBlurPxRatio=1),t.textureDrawLastFrame&&!h&&(c[t.NODE]=!0,c[t.SELECT_BOX]=!0);var m=n.style(),b=n.zoom(),x=void 0!==a?a:b,w=n.pan(),E={x:w.x,y:w.y},T={zoom:b,pan:{x:w.x,y:w.y}},C=t.prevViewport;void 0===C||T.zoom!==C.zoom||T.pan.x!==C.pan.x||T.pan.y!==C.pan.y||g&&!p||(t.motionBlurPxRatio=1),s&&(E=s),x*=l,E.x*=l,E.y*=l;var M=t.getCachedZSortedEles();function A(e,n,r,i,o){var a=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",t.colorFillStyle(e,[255,255,255],t.motionBlurTransparency),e.fillRect(n,r,i,o),e.globalCompositeOperation=a}function N(e,n){var o,l,c,h;t.clearingMotionBlur||e!==u.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]&&e!==u.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]?(o=E,l=x,c=t.canvasWidth,h=t.canvasHeight):(o={x:w.x*f,y:w.y*f},l=b*f,c=t.canvasWidth*f,h=t.canvasHeight*f),e.setTransform(1,0,0,1,0,0),"motionBlur"===n?A(e,0,0,c,h):r||void 0!==n&&!n||e.clearRect(0,0,c,h),i||(e.translate(o.x,o.y),e.scale(l,l)),s&&e.translate(s.x,s.y),a&&e.scale(a,a)}if(h||(t.textureDrawLastFrame=!1),h){if(t.textureDrawLastFrame=!0,!t.textureCache){t.textureCache={},t.textureCache.bb=n.mutableElements().boundingBox(),t.textureCache.texture=t.data.bufferCanvases[t.TEXTURE_BUFFER];var _=t.data.bufferContexts[t.TEXTURE_BUFFER];_.setTransform(1,0,0,1,0,0),_.clearRect(0,0,t.canvasWidth*t.textureMult,t.canvasHeight*t.textureMult),t.render({forcedContext:_,drawOnlyNodeLayer:!0,forcedPxRatio:l*t.textureMult}),(T=t.textureCache.viewport={zoom:n.zoom(),pan:n.pan(),width:t.canvasWidth,height:t.canvasHeight}).mpan={x:(0-T.pan.x)/T.zoom,y:(0-T.pan.y)/T.zoom}}c[t.DRAG]=!1,c[t.NODE]=!1;var S=u.contexts[t.NODE],k=t.textureCache.texture;T=t.textureCache.viewport;S.setTransform(1,0,0,1,0,0),d?A(S,0,0,T.width,T.height):S.clearRect(0,0,T.width,T.height);var P=m.core("outside-texture-bg-color").value,I=m.core("outside-texture-bg-opacity").value;t.colorFillStyle(S,P,I),S.fillRect(0,0,T.width,T.height);b=n.zoom();N(S,!1),S.clearRect(T.mpan.x,T.mpan.y,T.width/T.zoom/l,T.height/T.zoom/l),S.drawImage(k,T.mpan.x,T.mpan.y,T.width/T.zoom/l,T.height/T.zoom/l)}else t.textureOnViewport&&!r&&(t.textureCache=null);var O=n.extent(),D=t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming||t.hoverData.draggingEles||t.cy.animated(),L=t.hideEdgesOnViewport&&D,R=[];if(R[t.NODE]=!c[t.NODE]&&d&&!t.clearedForMotionBlur[t.NODE]||t.clearingMotionBlur,R[t.NODE]&&(t.clearedForMotionBlur[t.NODE]=!0),R[t.DRAG]=!c[t.DRAG]&&d&&!t.clearedForMotionBlur[t.DRAG]||t.clearingMotionBlur,R[t.DRAG]&&(t.clearedForMotionBlur[t.DRAG]=!0),c[t.NODE]||i||o||R[t.NODE]){var B=d&&!R[t.NODE]&&1!==f;N(S=r||(B?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]:u.contexts[t.NODE]),d&&!B?"motionBlur":void 0),L?t.drawCachedNodes(S,M.nondrag,l,O):t.drawLayeredElements(S,M.nondrag,l,O),t.debug&&t.drawDebugPoints(S,M.nondrag),i||d||(c[t.NODE]=!1)}if(!o&&(c[t.DRAG]||i||R[t.DRAG])){B=d&&!R[t.DRAG]&&1!==f;N(S=r||(B?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]:u.contexts[t.DRAG]),d&&!B?"motionBlur":void 0),L?t.drawCachedNodes(S,M.drag,l,O):t.drawCachedElements(S,M.drag,l,O),t.debug&&t.drawDebugPoints(S,M.drag),i||d||(c[t.DRAG]=!1)}if(this.drawSelectionRectangle(e,N),d&&1!==f){var z=u.contexts[t.NODE],F=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE],V=u.contexts[t.DRAG],G=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG],Y=function(e,n,r){e.setTransform(1,0,0,1,0,0),r||!y?e.clearRect(0,0,t.canvasWidth,t.canvasHeight):A(e,0,0,t.canvasWidth,t.canvasHeight);var i=f;e.drawImage(n,0,0,t.canvasWidth*i,t.canvasHeight*i,0,0,t.canvasWidth,t.canvasHeight)};(c[t.NODE]||R[t.NODE])&&(Y(z,F,R[t.NODE]),c[t.NODE]=!1),(c[t.DRAG]||R[t.DRAG])&&(Y(V,G,R[t.DRAG]),c[t.DRAG]=!1)}t.prevViewport=T,t.clearingMotionBlur&&(t.clearingMotionBlur=!1,t.motionBlurCleared=!0,t.motionBlur=!0),d&&(t.motionBlurTimeout=setTimeout(function(){t.motionBlurTimeout=null,t.clearedForMotionBlur[t.NODE]=!1,t.clearedForMotionBlur[t.DRAG]=!1,t.motionBlur=!1,t.clearingMotionBlur=!h,t.mbFrames=0,c[t.NODE]=!0,c[t.DRAG]=!0,t.redraw()},100)),r||n.emit("render")},cd.drawSelectionRectangle=function(e,t){var n=this,r=n.cy,i=n.data,o=r.style(),a=e.drawOnlyNodeLayer,s=e.drawAllLayers,l=i.canvasNeedsRedraw,u=e.forcedContext;if(n.showFps||!a&&l[n.SELECT_BOX]&&!s){var c=u||i.contexts[n.SELECT_BOX];if(t(c),1==n.selection[4]&&(n.hoverData.selecting||n.touchData.selecting)){var h=n.cy.zoom(),d=o.core("selection-box-border-width").value/h;c.lineWidth=d,c.fillStyle="rgba("+o.core("selection-box-color").value[0]+","+o.core("selection-box-color").value[1]+","+o.core("selection-box-color").value[2]+","+o.core("selection-box-opacity").value+")",c.fillRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]),d>0&&(c.strokeStyle="rgba("+o.core("selection-box-border-color").value[0]+","+o.core("selection-box-border-color").value[1]+","+o.core("selection-box-border-color").value[2]+","+o.core("selection-box-opacity").value+")",c.strokeRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]))}if(i.bgActivePosistion&&!n.hoverData.selecting){h=n.cy.zoom();var f=i.bgActivePosistion;c.fillStyle="rgba("+o.core("active-bg-color").value[0]+","+o.core("active-bg-color").value[1]+","+o.core("active-bg-color").value[2]+","+o.core("active-bg-opacity").value+")",c.beginPath(),c.arc(f.x,f.y,o.core("active-bg-size").pfValue/h,0,2*Math.PI),c.fill()}var p=n.lastRedrawTime;if(n.showFps&&p){p=Math.round(p);var g=Math.round(1e3/p),v="1 frame = "+p+" ms = "+g+" fps";if(c.setTransform(1,0,0,1,0,0),c.fillStyle="rgba(255, 0, 0, 0.75)",c.strokeStyle="rgba(255, 0, 0, 0.75)",c.font="30px Arial",!ud){var y=c.measureText(v);ud=y.actualBoundingBoxAscent}c.fillText(v,0,ud);c.strokeRect(0,ud+10,250,20),c.fillRect(0,ud+10,250*Math.min(g/60,1),20)}s||(l[n.SELECT_BOX]=!1)}};var Cd="undefined"!=typeof Float32Array?Float32Array:Array;function Md(){var e=new Cd(9);return Cd!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Ad(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Nd(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],f=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=d*r+f*a+u,e[7]=d*i+f*s+c,e[8]=d*o+f*l+h,e}function _d(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=Math.sin(n),f=Math.cos(n);return e[0]=f*r+d*a,e[1]=f*i+d*s,e[2]=f*o+d*l,e[3]=f*a-d*r,e[4]=f*s-d*i,e[5]=f*l-d*o,e[6]=u,e[7]=c,e[8]=h,e}function Sd(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var kd=function(){return l(function e(t,n,r,i){s(this,e),this.debugID=Math.floor(1e4*Math.random()),this.r=t,this.texSize=n,this.texRows=r,this.texHeight=Math.floor(n/r),this.enableWrapping=!0,this.locked=!1,this.texture=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=i(t,n,n),this.scratch=i(t,n,this.texHeight,"scratch")},[{key:"lock",value:function(){this.locked=!0}},{key:"getKeys",value:function(){return new Set(this.keyToLocation.keys())}},{key:"getScale",value:function(e){var t=e.w,n=e.h,r=this.texHeight,i=this.texSize,o=r/n,a=t*o,s=n*o;return a>i&&(a=t*(o=i/t),s=n*o),{scale:o,texW:a,texH:s}}},{key:"draw",value:function(e,t,n){var r=this;if(this.locked)throw new Error("can't draw, atlas is locked");var i=this.texSize,o=this.texRows,a=this.texHeight,s=this.getScale(t),l=s.scale,u=s.texW,c=s.texH,h=function(e,r){if(n&&r){var i=r.context,o=e.x,s=e.row,u=o,c=a*s;i.save(),i.translate(u,c),i.scale(l,l),n(i,t),i.restore()}},d=[null,null],f=function(){h(r.freePointer,r.canvas),d[0]={x:r.freePointer.x,y:r.freePointer.row*a,w:u,h:c},d[1]={x:r.freePointer.x+u,y:r.freePointer.row*a,w:0,h:c},r.freePointer.x+=u,r.freePointer.x==i&&(r.freePointer.x=0,r.freePointer.row++)},p=function(){r.freePointer.x=0,r.freePointer.row++};if(this.freePointer.x+u<=i)f();else{if(this.freePointer.row>=o-1)return!1;this.freePointer.x===i?(p(),f()):this.enableWrapping?function(){var e=r.scratch,t=r.canvas;e.clear(),h({x:0,row:0},e);var n=i-r.freePointer.x,o=u-n,s=a,l=r.freePointer.x,f=r.freePointer.row*a,p=n;t.context.drawImage(e,0,0,p,s,l,f,p,s),d[0]={x:l,y:f,w:p,h:c};var g=n,v=(r.freePointer.row+1)*a,y=o;t&&t.context.drawImage(e,g,0,y,s,0,v,y,s),d[1]={x:0,y:v,w:y,h:c},r.freePointer.x=o,r.freePointer.row++}():(p(),f())}return this.keyToLocation.set(e,d),this.needsBuffer=!0,d}},{key:"getOffsets",value:function(e){return this.keyToLocation.get(e)}},{key:"isEmpty",value:function(){return 0===this.freePointer.x&&0===this.freePointer.row}},{key:"canFit",value:function(e){if(this.locked)return!1;var t=this.texSize,n=this.texRows,r=this.getScale(e).texW;return!(this.freePointer.x+r>t)||this.freePointer.row<n-1}},{key:"bufferIfNeeded",value:function(e){this.texture||(this.texture=function(e){var t=e.createTexture();return t.buffer=function(n){e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)},t.deleteTexture=function(){e.deleteTexture(t)},t}(e,this.debugID)),this.needsBuffer&&(this.texture.buffer(this.canvas),this.needsBuffer=!1,this.locked&&(this.canvas=null,this.scratch=null))}},{key:"dispose",value:function(){this.texture&&(this.texture.deleteTexture(),this.texture=null),this.canvas=null,this.scratch=null,this.locked=!0}}])}(),Pd=function(){return l(function e(t,n,r,i){s(this,e),this.r=t,this.texSize=n,this.texRows=r,this.createTextureCanvas=i,this.atlases=[],this.styleKeyToAtlas=new Map,this.markedKeys=new Set},[{key:"getKeys",value:function(){return new Set(this.styleKeyToAtlas.keys())}},{key:"_createAtlas",value:function(){var e=this.r,t=this.texSize,n=this.texRows,r=this.createTextureCanvas;return new kd(e,t,n,r)}},{key:"_getScratchCanvas",value:function(){if(!this.scratch){var e=this.r,t=this.texSize,n=this.texRows,r=this.createTextureCanvas,i=Math.floor(t/n);this.scratch=r(e,t,i,"scratch")}return this.scratch}},{key:"draw",value:function(e,t,n){var r=this.styleKeyToAtlas.get(e);return r||((r=this.atlases[this.atlases.length-1])&&r.canFit(t)||(r&&r.lock(),r=this._createAtlas(),this.atlases.push(r)),r.draw(e,t,n),this.styleKeyToAtlas.set(e,r)),r}},{key:"getAtlas",value:function(e){return this.styleKeyToAtlas.get(e)}},{key:"hasAtlas",value:function(e){return this.styleKeyToAtlas.has(e)}},{key:"markKeyForGC",value:function(e){this.markedKeys.add(e)}},{key:"gc",value:function(){var e=this,t=this.markedKeys;if(0!==t.size){var n,r=[],i=new Map,o=null,a=u(this.atlases);try{var s=function(){var a,s,l=n.value,c=l.getKeys(),f=(s=c,(a=t).intersection?a.intersection(s):new Set(d(a).filter(function(e){return s.has(e)})));if(0===f.size)return r.push(l),c.forEach(function(e){return i.set(e,l)}),1;o||(o=e._createAtlas(),r.push(o));var p,g=u(c);try{for(g.s();!(p=g.n()).done;){var v=p.value;if(!f.has(v)){var y=h(l.getOffsets(v),2),m=y[0],b=y[1];o.canFit({w:m.w+b.w,h:m.h})||(o.lock(),o=e._createAtlas(),r.push(o)),l.canvas&&(e._copyTextureToNewAtlas(v,l,o),i.set(v,o))}}}catch(e){g.e(e)}finally{g.f()}l.dispose()};for(a.s();!(n=a.n()).done;)s()}catch(e){a.e(e)}finally{a.f()}this.atlases=r,this.styleKeyToAtlas=i,this.markedKeys=new Set}else console.log("nothing to garbage collect")}},{key:"_copyTextureToNewAtlas",value:function(e,t,n){var r=h(t.getOffsets(e),2),i=r[0],o=r[1];if(0===o.w)n.draw(e,i,function(e){e.drawImage(t.canvas,i.x,i.y,i.w,i.h,0,0,i.w,i.h)});else{var a=this._getScratchCanvas();a.clear(),a.context.drawImage(t.canvas,i.x,i.y,i.w,i.h,0,0,i.w,i.h),a.context.drawImage(t.canvas,o.x,o.y,o.w,o.h,i.w,0,o.w,o.h);var s=i.w+o.w,l=i.h;n.draw(e,{w:s,h:l},function(e){e.drawImage(a,0,0,s,l,0,0,s,l)})}}},{key:"getCounts",value:function(){return{keyCount:this.styleKeyToAtlas.size,atlasCount:new Set(this.styleKeyToAtlas.values()).size}}}])}();var Id=function(){return l(function e(t,n){s(this,e),this.r=t,this.globalOptions=n,this.atlasSize=n.webglTexSize,this.maxAtlasesPerBatch=n.webglTexPerBatch,this.renderTypes=new Map,this.collections=new Map,this.typeAndIdToKey=new Map},[{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"addAtlasCollection",value:function(e,t){var n=this.globalOptions,r=n.webglTexSize,i=n.createTextureCanvas,o=t.texRows,a=this._cacheScratchCanvas(i),s=new Pd(this.r,r,o,a);this.collections.set(e,s)}},{key:"addRenderType",value:function(e,t){var n=t.collection;if(!this.collections.has(n))throw new Error("invalid atlas collection name '".concat(n,"'"));var r=this.collections.get(n),i=Te({type:e,atlasCollection:r},t);this.renderTypes.set(e,i)}},{key:"getRenderTypeOpts",value:function(e){return this.renderTypes.get(e)}},{key:"getAtlasCollection",value:function(e){return this.collections.get(e)}},{key:"_cacheScratchCanvas",value:function(e){var t=-1,n=-1,r=null;return function(i,o,a,s){return s?(r&&o==t&&a==n||(t=o,n=a,r=e(i,o,a)),r):e(i,o,a)}}},{key:"_key",value:function(e,t){return"".concat(e,"-").concat(t)}},{key:"invalidate",value:function(e){var t,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.forceRedraw,o=void 0!==i&&i,a=r.filterEle,s=void 0===a?function(){return!0}:a,l=r.filterType,c=void 0===l?function(){return!0}:l,h=!1,d=!1,f=u(e);try{for(f.s();!(t=f.n()).done;){var p=t.value;if(s(p)){var g,v=u(this.renderTypes.values());try{var y=function(){var e=g.value,t=e.type;if(c(t)){var r=n.collections.get(e.collection),i=e.getKey(p),a=Array.isArray(i)?i:[i];if(o)a.forEach(function(e){return r.markKeyForGC(e)}),d=!0;else{var s=e.getID?e.getID(p):p.id(),l=n._key(t,s),u=n.typeAndIdToKey.get(l);void 0===u||vd(a,u)||(h=!0,n.typeAndIdToKey.delete(l),u.forEach(function(e){return r.markKeyForGC(e)}))}}};for(v.s();!(g=v.n()).done;)y()}catch(e){v.e(e)}finally{v.f()}}}}catch(e){f.e(e)}finally{f.f()}return d&&(this.gc(),h=!1),h}},{key:"gc",value:function(){var e,t=u(this.collections.values());try{for(t.s();!(e=t.n()).done;){e.value.gc()}}catch(e){t.e(e)}finally{t.f()}}},{key:"getOrCreateAtlas",value:function(e,t,n,r){var i=this.renderTypes.get(t),o=this.collections.get(i.collection),a=!1,s=o.draw(r,n,function(t){i.drawClipped?(t.save(),t.beginPath(),t.rect(0,0,n.w,n.h),t.clip(),i.drawElement(t,e,n,!0,!0),t.restore()):i.drawElement(t,e,n,!0,!0),a=!0});if(a){var l=i.getID?i.getID(e):e.id(),u=this._key(t,l);this.typeAndIdToKey.has(u)?this.typeAndIdToKey.get(u).push(r):this.typeAndIdToKey.set(u,[r])}return s}},{key:"getAtlasInfo",value:function(e,t){var n=this,r=this.renderTypes.get(t),i=r.getKey(e);return(Array.isArray(i)?i:[i]).map(function(i){var o=r.getBoundingBox(e,i),a=n.getOrCreateAtlas(e,t,o,i),s=h(a.getOffsets(i),2),l=s[0];return{atlas:a,tex:l,tex1:l,tex2:s[1],bb:o}})}},{key:"getDebugInfo",value:function(){var e,t=[],n=u(this.collections);try{for(n.s();!(e=n.n()).done;){var r=h(e.value,2),i=r[0],o=r[1].getCounts(),a=o.keyCount,s=o.atlasCount;t.push({type:i,keyCount:a,atlasCount:s})}}catch(e){n.e(e)}finally{n.f()}return t}}])}(),Od=function(){return l(function e(t){s(this,e),this.globalOptions=t,this.atlasSize=t.webglTexSize,this.maxAtlasesPerBatch=t.webglTexPerBatch,this.batchAtlases=[]},[{key:"getMaxAtlasesPerBatch",value:function(){return this.maxAtlasesPerBatch}},{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"getIndexArray",value:function(){return Array.from({length:this.maxAtlasesPerBatch},function(e,t){return t})}},{key:"startBatch",value:function(){this.batchAtlases=[]}},{key:"getAtlasCount",value:function(){return this.batchAtlases.length}},{key:"getAtlases",value:function(){return this.batchAtlases}},{key:"canAddToCurrentBatch",value:function(e){return this.batchAtlases.length!==this.maxAtlasesPerBatch||this.batchAtlases.includes(e)}},{key:"getAtlasIndexForBatch",value:function(e){var t=this.batchAtlases.indexOf(e);if(t<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw new Error("cannot add more atlases to batch");this.batchAtlases.push(e),t=this.batchAtlases.length-1}return t}}])}(),Dd={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},Ld=1,Rd=2,Bd=function(){return l(function e(t,n,r){s(this,e),this.r=t,this.gl=n,this.maxInstances=r.webglBatchSize,this.atlasSize=r.webglTexSize,this.bgColor=r.bgColor,this.debug=r.webglDebug,this.batchDebugInfo=[],r.enableWrapping=!0,r.createTextureCanvas=fd,this.atlasManager=new Id(t,r),this.batchManager=new Od(r),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(Dd.SCREEN),this.pickingProgram=this._createShaderProgram(Dd.PICKING),this.vao=this._createVAO()},[{key:"addAtlasCollection",value:function(e,t){this.atlasManager.addAtlasCollection(e,t)}},{key:"addTextureAtlasRenderType",value:function(e,t){this.atlasManager.addRenderType(e,t)}},{key:"addSimpleShapeRenderType",value:function(e,t){this.simpleShapeOptions.set(e,t)}},{key:"invalidate",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).type,n=this.atlasManager;return t?n.invalidate(e,{filterType:function(e){return e===t},forceRedraw:!0}):n.invalidate(e)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"_createShaderProgram",value:function(e){var t=this.gl,n="#version 300 es\n precision highp float;\n\n uniform mat3 uPanZoomMatrix;\n uniform int uAtlasSize;\n \n // instanced\n in vec2 aPosition; // a vertex from the unit square\n \n in mat3 aTransform; // used to transform verticies, eg into a bounding box\n in int aVertType; // the type of thing we are rendering\n\n // the z-index that is output when using picking mode\n in vec4 aIndex;\n \n // For textures\n in int aAtlasId; // which shader unit/atlas to use\n in vec4 aTex; // x/y/w/h of texture in atlas\n\n // for edges\n in vec4 aPointAPointB;\n in vec4 aPointCPointD;\n in vec2 aLineWidth; // also used for node border width\n\n // simple shapes\n in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]\n in vec4 aColor; // also used for edges\n in vec4 aBorderColor; // aLineWidth is used for border width\n\n // output values passed to the fragment shader\n out vec2 vTexCoord;\n out vec4 vColor;\n out vec2 vPosition;\n // flat values are not interpolated\n flat out int vAtlasId; \n flat out int vVertType;\n flat out vec2 vTopRight;\n flat out vec2 vBotLeft;\n flat out vec4 vCornerRadius;\n flat out vec4 vBorderColor;\n flat out vec2 vBorderWidth;\n flat out vec4 vIndex;\n \n void main(void) {\n int vid = gl_VertexID;\n vec2 position = aPosition; // TODO make this a vec3, simplifies some code below\n\n if(aVertType == ".concat(0,") {\n float texX = aTex.x; // texture coordinates\n float texY = aTex.y;\n float texW = aTex.z;\n float texH = aTex.w;\n\n if(vid == 1 || vid == 2 || vid == 4) {\n texX += texW;\n }\n if(vid == 2 || vid == 4 || vid == 5) {\n texY += texH;\n }\n\n float d = float(uAtlasSize);\n vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(4," || aVertType == ").concat(7," \n || aVertType == ").concat(5," || aVertType == ").concat(6,") { // simple shapes\n\n // the bounding box is needed by the fragment shader\n vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat\n vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat\n vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated\n\n // calculations are done in the fragment shader, just pass these along\n vColor = aColor;\n vCornerRadius = aCornerRadius;\n vBorderColor = aBorderColor;\n vBorderWidth = aLineWidth;\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(1,") {\n vec2 source = aPointAPointB.xy;\n vec2 target = aPointAPointB.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n // stretch the unit square into a long skinny rectangle\n vec2 xBasis = target - source;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;\n\n gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);\n vColor = aColor;\n } \n else if(aVertType == ").concat(2,") {\n vec2 pointA = aPointAPointB.xy;\n vec2 pointB = aPointAPointB.zw;\n vec2 pointC = aPointCPointD.xy;\n vec2 pointD = aPointCPointD.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n vec2 p0, p1, p2, pos;\n if(position.x == 0.0) { // The left side of the unit square\n p0 = pointA;\n p1 = pointB;\n p2 = pointC;\n pos = position;\n } else { // The right side of the unit square, use same approach but flip the geometry upside down\n p0 = pointD;\n p1 = pointC;\n p2 = pointB;\n pos = vec2(0.0, -position.y);\n }\n\n vec2 p01 = p1 - p0;\n vec2 p12 = p2 - p1;\n vec2 p21 = p1 - p2;\n\n // Find the normal vector.\n vec2 tangent = normalize(normalize(p12) + normalize(p01));\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n // Find the vector perpendicular to p0 -> p1.\n vec2 p01Norm = normalize(vec2(-p01.y, p01.x));\n\n // Determine the bend direction.\n float sigma = sign(dot(p01 + p21, normal));\n float width = aLineWidth[0];\n\n if(sign(pos.y) == -sigma) {\n // This is an intersecting vertex. Adjust the position so that there's no overlap.\n vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n } else {\n // This is a non-intersecting vertex. Treat it like a mitre join.\n vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n }\n\n vColor = aColor;\n } \n else if(aVertType == ").concat(3," && vid < 3) {\n // massage the first triangle into an edge arrow\n if(vid == 0)\n position = vec2(-0.15, -0.3);\n if(vid == 1)\n position = vec2( 0.0, 0.0);\n if(vid == 2)\n position = vec2( 0.15, -0.3);\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n vColor = aColor;\n }\n else {\n gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space\n }\n\n vAtlasId = aAtlasId;\n vVertType = aVertType;\n vIndex = aIndex;\n }\n "),r=this.batchManager.getIndexArray(),i="#version 300 es\n precision highp float;\n\n // declare texture unit for each texture atlas in the batch\n ".concat(r.map(function(e){return"uniform sampler2D uTexture".concat(e,";")}).join("\n\t"),"\n\n uniform vec4 uBGColor;\n uniform float uZoom;\n\n in vec2 vTexCoord;\n in vec4 vColor;\n in vec2 vPosition; // model coordinates\n\n flat in int vAtlasId;\n flat in vec4 vIndex;\n flat in int vVertType;\n flat in vec2 vTopRight;\n flat in vec2 vBotLeft;\n flat in vec4 vCornerRadius;\n flat in vec4 vBorderColor;\n flat in vec2 vBorderWidth;\n\n out vec4 outColor;\n\n ").concat("\n float circleSD(vec2 p, float r) {\n return distance(vec2(0), p) - r; // signed distance\n }\n","\n ").concat("\n float rectangleSD(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);\n }\n","\n ").concat("\n float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {\n cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;\n cr.x = (p.y > 0.0) ? cr.x : cr.y;\n vec2 q = abs(p) - b + cr.x;\n return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;\n }\n","\n ").concat("\n float ellipseSD(vec2 p, vec2 ab) {\n p = abs( p ); // symmetry\n\n // find root with Newton solver\n vec2 q = ab*(p-ab);\n float w = (q.x<q.y)? 1.570796327 : 0.0;\n for( int i=0; i<5; i++ ) {\n vec2 cs = vec2(cos(w),sin(w));\n vec2 u = ab*vec2( cs.x,cs.y);\n vec2 v = ab*vec2(-cs.y,cs.x);\n w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));\n }\n \n // compute final point and distance\n float d = length(p-ab*vec2(cos(w),sin(w)));\n \n // return signed distance\n return (dot(p/ab,p/ab)>1.0) ? d : -d;\n }\n","\n\n vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha\n return vec4( \n top.rgb + (bot.rgb * (1.0 - top.a)),\n top.a + (bot.a * (1.0 - top.a)) \n );\n }\n\n vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance\n // scale to the zoom level so that borders don't look blurry when zoomed in\n // note 1.5 is an aribitrary value chosen because it looks good\n return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d))); \n }\n\n void main(void) {\n if(vVertType == ").concat(0,") {\n // look up the texel from the texture unit\n ").concat(r.map(function(e){return"if(vAtlasId == ".concat(e,") outColor = texture(uTexture").concat(e,", vTexCoord);")}).join("\n\telse "),"\n } \n else if(vVertType == ").concat(3,") {\n // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';\n outColor = blend(vColor, uBGColor);\n outColor.a = 1.0; // make opaque, masks out line under arrow\n }\n else if(vVertType == ").concat(4," && vBorderWidth == vec2(0.0)) { // simple rectangle with no border\n outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done\n }\n else if(vVertType == ").concat(4," || vVertType == ").concat(7," \n || vVertType == ").concat(5," || vVertType == ").concat(6,") { // use SDF\n\n float outerBorder = vBorderWidth[0];\n float innerBorder = vBorderWidth[1];\n float borderPadding = outerBorder * 2.0;\n float w = vTopRight.x - vBotLeft.x - borderPadding;\n float h = vTopRight.y - vBotLeft.y - borderPadding;\n vec2 b = vec2(w/2.0, h/2.0); // half width, half height\n vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center\n\n float d; // signed distance\n if(vVertType == ").concat(4,") {\n d = rectangleSD(p, b);\n } else if(vVertType == ").concat(7," && w == h) {\n d = circleSD(p, b.x); // faster than ellipse\n } else if(vVertType == ").concat(7,") {\n d = ellipseSD(p, b);\n } else {\n d = roundRectangleSD(p, b, vCornerRadius.wzyx);\n }\n\n // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling\n // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box\n if(d > 0.0) {\n if(d > outerBorder) {\n discard;\n } else {\n outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);\n }\n } else {\n if(d > innerBorder) {\n vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;\n vec4 innerBorderColor = blend(vBorderColor, vColor);\n outColor = distInterp(innerBorderColor, outerColor, d);\n } \n else {\n vec4 outerColor;\n if(innerBorder == 0.0 && outerBorder == 0.0) {\n outerColor = vec4(0);\n } else if(innerBorder == 0.0) {\n outerColor = vBorderColor;\n } else {\n outerColor = blend(vBorderColor, vColor);\n }\n outColor = distInterp(vColor, outerColor, d - innerBorder);\n }\n }\n }\n else {\n outColor = vColor;\n }\n\n ").concat(e.picking?"if(outColor.a == 0.0) discard;\n else outColor = vIndex;":"","\n }\n "),o=function(e,t,n){var r=dd(e,e.VERTEX_SHADER,t),i=dd(e,e.FRAGMENT_SHADER,n),o=e.createProgram();if(e.attachShader(o,r),e.attachShader(o,i),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Error("Could not initialize shaders");return o}(t,n,i);o.aPosition=t.getAttribLocation(o,"aPosition"),o.aIndex=t.getAttribLocation(o,"aIndex"),o.aVertType=t.getAttribLocation(o,"aVertType"),o.aTransform=t.getAttribLocation(o,"aTransform"),o.aAtlasId=t.getAttribLocation(o,"aAtlasId"),o.aTex=t.getAttribLocation(o,"aTex"),o.aPointAPointB=t.getAttribLocation(o,"aPointAPointB"),o.aPointCPointD=t.getAttribLocation(o,"aPointCPointD"),o.aLineWidth=t.getAttribLocation(o,"aLineWidth"),o.aColor=t.getAttribLocation(o,"aColor"),o.aCornerRadius=t.getAttribLocation(o,"aCornerRadius"),o.aBorderColor=t.getAttribLocation(o,"aBorderColor"),o.uPanZoomMatrix=t.getUniformLocation(o,"uPanZoomMatrix"),o.uAtlasSize=t.getUniformLocation(o,"uAtlasSize"),o.uBGColor=t.getUniformLocation(o,"uBGColor"),o.uZoom=t.getUniformLocation(o,"uZoom"),o.uTextures=[];for(var a=0;a<this.batchManager.getMaxAtlasesPerBatch();a++)o.uTextures.push(t.getUniformLocation(o,"uTexture".concat(a)));return o}},{key:"_createVAO",value:function(){var e=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=e.length/2;var t=this.maxInstances,n=this.gl,r=this.program,i=n.createVertexArray();return n.bindVertexArray(i),function(e,t,n,r){var i=h(xd(e,t),2),o=i[0],a=i[1],s=wd(e,a,r),l=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,s,e.STATIC_DRAW),a===e.FLOAT?e.vertexAttribPointer(n,o,a,!1,0,0):a===e.INT&&e.vertexAttribIPointer(n,o,a,0,0),e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,null)}(n,"vec2",r.aPosition,e),this.transformBuffer=function(e,t,n){for(var r=new Float32Array(9*t),i=new Array(t),o=0;o<t;o++){var a=9*o*4;i[o]=new Float32Array(r.buffer,a,9)}var s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,r.byteLength,e.DYNAMIC_DRAW);for(var l=0;l<3;l++){var u=n+l;e.enableVertexAttribArray(u),e.vertexAttribPointer(u,3,e.FLOAT,!1,36,12*l),e.vertexAttribDivisor(u,1)}return e.bindBuffer(e.ARRAY_BUFFER,null),s.getMatrixView=function(e){return i[e]},s.setData=function(e,t){i[t].set(e,0)},s.bufferSubData=function(){e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferSubData(e.ARRAY_BUFFER,0,r)},s}(n,t,r.aTransform),this.indexBuffer=Td(n,t,"vec4",r.aIndex),this.vertTypeBuffer=Td(n,t,"int",r.aVertType),this.atlasIdBuffer=Td(n,t,"int",r.aAtlasId),this.texBuffer=Td(n,t,"vec4",r.aTex),this.pointAPointBBuffer=Td(n,t,"vec4",r.aPointAPointB),this.pointCPointDBuffer=Td(n,t,"vec4",r.aPointCPointD),this.lineWidthBuffer=Td(n,t,"vec2",r.aLineWidth),this.colorBuffer=Td(n,t,"vec4",r.aColor),this.cornerRadiusBuffer=Td(n,t,"vec4",r.aCornerRadius),this.borderColorBuffer=Td(n,t,"vec4",r.aBorderColor),n.bindVertexArray(null),i}},{key:"buffers",get:function(){var e=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(e){return ve(e,"Buffer")}).map(function(t){return e[t]})),this._buffers}},{key:"startFrame",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Dd.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"_isVisible",value:function(e,t){return!!e.visible()&&(!t||!t.isVisible||t.isVisible(e))}},{key:"drawTexture",value:function(e,t,n){var r=this.atlasManager,i=this.batchManager,o=r.getRenderTypeOpts(n);if(this._isVisible(e,o)&&(!e.isEdge()||this._isValidEdge(e))){if(this.renderTarget.picking&&o.getTexPickingMode){var a=o.getTexPickingMode(e);if(a===Ld)return;if(a==Rd)return void this.drawPickingRectangle(e,t,n)}var s,l=u(r.getAtlasInfo(e,n));try{for(l.s();!(s=l.n()).done;){var c=s.value,d=c.atlas,f=c.tex1,p=c.tex2;i.canAddToCurrentBatch(d)||this.endBatch();for(var g=i.getAtlasIndexForBatch(d),v=0,y=[[f,!0],[p,!1]];v<y.length;v++){var m=h(y[v],2),b=m[0],x=m[1];if(0!=b.w){var w=this.instanceCount;this.vertTypeBuffer.getView(w)[0]=0,md(t,this.indexBuffer.getView(w)),this.atlasIdBuffer.getView(w)[0]=g;var E=this.texBuffer.getView(w);E[0]=b.x,E[1]=b.y,E[2]=b.w,E[3]=b.h;var T=this.transformBuffer.getMatrixView(w);this.setTransformMatrix(e,T,o,c,x),this.instanceCount++,x||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(e){l.e(e)}finally{l.f()}}}},{key:"setTransformMatrix",value:function(e,t,n,r){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=0;if(n.shapeProps&&n.shapeProps.padding&&(o=e.pstyle(n.shapeProps.padding).pfValue),r){var a=r.bb,s=r.tex1,l=r.tex2,u=s.w/(s.w+l.w);i||(u=1-u);var c=this._getAdjustedBB(a,o,i,u);this._applyTransformMatrix(t,c,n,e)}else{var h=n.getBoundingBox(e),d=this._getAdjustedBB(h,o,!0,1);this._applyTransformMatrix(t,d,n,e)}}},{key:"_applyTransformMatrix",value:function(e,t,n,r){var i,o;Ad(e);var a=n.getRotation?n.getRotation(r):0;if(0!==a){var s=n.getRotationPoint(r);Nd(e,e,[s.x,s.y]),_d(e,e,a);var l=n.getRotationOffset(r);i=l.x+(t.xOffset||0),o=l.y+(t.yOffset||0)}else i=t.x1,o=t.y1;Nd(e,e,[i,o]),Sd(e,e,[t.w,t.h])}},{key:"_getAdjustedBB",value:function(e,t,n,r){var i=e.x1,o=e.y1,a=e.w,s=e.h;t&&(i-=t,o-=t,a+=2*t,s+=2*t);var l=0,u=a*r;return n&&r<1?a=u:!n&&r<1&&(i+=l=a-u,a=u),{x1:i,y1:o,w:a,h:s,xOffset:l,yOffset:e.yOffset}}},{key:"drawPickingRectangle",value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),i=this.instanceCount;this.vertTypeBuffer.getView(i)[0]=4,md(t,this.indexBuffer.getView(i)),yd([0,0,0],1,this.colorBuffer.getView(i));var o=this.transformBuffer.getMatrixView(i);this.setTransformMatrix(e,o,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:"drawNode",value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var i=r.shapeProps,o=this._getVertTypeForShape(e,i.shape);if(void 0===o||r.isSimple&&!r.isSimple(e,this.renderTarget))this.drawTexture(e,t,n);else{var a=this.instanceCount;if(this.vertTypeBuffer.getView(a)[0]=o,5===o||6===o){var s=r.getBoundingBox(e),l=this._getCornerRadius(e,i.radius,s),u=this.cornerRadiusBuffer.getView(a);u[0]=l,u[1]=l,u[2]=l,u[3]=l,6===o&&(u[0]=0,u[2]=0)}md(t,this.indexBuffer.getView(a));var c=this.renderTarget.picking?1:"node-body"===n?e.effectiveOpacity():1,h=this.renderTarget.picking?1:e.pstyle(i.opacity).value*c;yd(e.pstyle(i.color).value,h,this.colorBuffer.getView(a));var d=this.lineWidthBuffer.getView(a);if(d[0]=0,d[1]=0,i.border){var f=e.pstyle("border-width").value;if(f>0){yd(e.pstyle("border-color").value,c*e.pstyle("border-opacity").value,this.borderColorBuffer.getView(a));var p=e.pstyle("border-position").value;if("inside"===p)d[0]=0,d[1]=-f;else if("outside"===p)d[0]=f,d[1]=0;else{var g=f/2;d[0]=g,d[1]=-g}}}var v=this.transformBuffer.getMatrixView(a);this.setTransformMatrix(e,v,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:"_getVertTypeForShape",value:function(e,t){switch(e.pstyle(t).value){case"rectangle":return 4;case"ellipse":return 7;case"roundrectangle":case"round-rectangle":return 5;case"bottom-round-rectangle":return 6;default:return}}},{key:"_getCornerRadius",value:function(e,t,n){var r=n.w,i=n.h;if("auto"===e.pstyle(t).value)return Gn(r,i);var o=e.pstyle(t).pfValue,a=r/2,s=i/2;return Math.min(o,s,a)}},{key:"drawEdgeArrow",value:function(e,t,n){if(e.visible()){var r,i,o,a=e._private.rscratch;if("source"===n?(r=a.arrowStartX,i=a.arrowStartY,o=a.srcArrowAngle):(r=a.arrowEndX,i=a.arrowEndY,o=a.tgtArrowAngle),!(isNaN(r)||null==r||isNaN(i)||null==i||isNaN(o)||null==o))if("none"!==e.pstyle(n+"-arrow-shape").value){var s=e.pstyle(n+"-arrow-color").value,l=e.pstyle("opacity").value*e.pstyle("line-opacity").value,u=e.pstyle("width").pfValue,c=Ru(e,n),h=this.r.getArrowWidth(u,c),d=this.instanceCount,f=this.transformBuffer.getMatrixView(d);Ad(f),Nd(f,f,[r,i]),Sd(f,f,[h,h]),_d(f,f,o),this.vertTypeBuffer.getView(d)[0]=3,md(t,this.indexBuffer.getView(d)),yd(s,l,this.colorBuffer.getView(d)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:"drawEdgeLine",value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle("opacity").value,i=e.pstyle("line-opacity").value,o=e.pstyle("width").pfValue,a=e.pstyle("line-color").value,s=r*i;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),4==n.length){var l=this.instanceCount;this.vertTypeBuffer.getView(l)[0]=1,md(t,this.indexBuffer.getView(l)),yd(a,s,this.colorBuffer.getView(l)),this.lineWidthBuffer.getView(l)[0]=o;var u=this.pointAPointBBuffer.getView(l);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var c=0;c<n.length-2;c+=2){var h=this.instanceCount;this.vertTypeBuffer.getView(h)[0]=2,md(t,this.indexBuffer.getView(h)),yd(a,s,this.colorBuffer.getView(h)),this.lineWidthBuffer.getView(h)[0]=o;var d=n[c-2],f=n[c-1],p=n[c],g=n[c+1],v=n[c+2],y=n[c+3],m=n[c+4],b=n[c+5];0==c&&(d=2*p-v+.001,f=2*g-y+.001),c==n.length-4&&(m=2*v-p+.001,b=2*y-g+.001);var x=this.pointAPointBBuffer.getView(h);x[0]=d,x[1]=f,x[2]=p,x[3]=g;var w=this.pointCPointDBuffer.getView(h);w[0]=v,w[1]=y,w[2]=m,w[3]=b,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"_isValidEdge",value:function(e){var t=e._private.rscratch;return!t.badLine&&null!=t.allpts&&!isNaN(t.allpts[0])}},{key:"_getEdgePoints",value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(4==n.length)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:"_getNumSegments",value:function(e){return Math.min(Math.max(15,5),this.maxInstances)}},{key:"_getCurveSegmentPoints",value:function(e,t){if(4==e.length)return e;for(var n=Array(2*(t+1)),r=0;r<=t;r++)if(0==r)n[0]=e[0],n[1]=e[1];else if(r==t)n[2*r]=e[e.length-2],n[2*r+1]=e[e.length-1];else{var i=r/t;this._setCurvePoint(e,i,n,2*r)}return n}},{key:"_setCurvePoint",value:function(e,t,n,r){if(!(e.length<=2)){for(var i=Array(e.length-2),o=0;o<i.length;o+=2){var a=(1-t)*e[o]+t*e[o+2],s=(1-t)*e[o+1]+t*e[o+3];i[o]=a,i[o+1]=s}return this._setCurvePoint(i,t,n,r)}n[r]=e[0],n[r+1]=e[1]}},{key:"endBatch",value:function(){var e=this.gl,t=this.vao,n=this.vertexCount,r=this.instanceCount;if(0!==r){var i=this.renderTarget.picking?this.pickingProgram:this.program;e.useProgram(i),e.bindVertexArray(t);var o,a=u(this.buffers);try{for(a.s();!(o=a.n()).done;){o.value.bufferSubData(r)}}catch(e){a.e(e)}finally{a.f()}for(var s=this.batchManager.getAtlases(),l=0;l<s.length;l++)s[l].bufferIfNeeded(e);for(var c=0;c<s.length;c++)e.activeTexture(e.TEXTURE0+c),e.bindTexture(e.TEXTURE_2D,s[c].texture),e.uniform1i(i.uTextures[c],c);e.uniform1f(i.uZoom,function(e){var t=e.pixelRatio;return e.cy.zoom()*t}(this.r)),e.uniformMatrix3fv(i.uPanZoomMatrix,!1,this.panZoomMatrix),e.uniform1i(i.uAtlasSize,this.batchManager.getAtlasSize());var h=yd(this.bgColor,1);e.uniform4fv(i.uBGColor,h),e.drawArraysInstanced(e.TRIANGLES,0,n,r),e.bindVertexArray(null),e.bindTexture(e.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:r,atlasCount:s.length}),this.startBatch()}}},{key:"getDebugInfo",value:function(){var e=this.atlasManager.getDebugInfo(),t=e.reduce(function(e,t){return e+t.atlasCount},0),n=this.batchDebugInfo,r=n.reduce(function(e,t){return e+t.count},0);return{atlasInfo:e,totalAtlases:t,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:r}}}])}(),zd={};function Fd(e,t){var n=e._private.rscratch;return mt(n,"labelWrapCachedLines",t)||[]}zd.initWebgl=function(e,t){var n=this,r=n.data.contexts[n.WEBGL];e.bgColor=function(e){var t=e.cy.container(),n=t&&t.style&&t.style.backgroundColor||"white";return Ce(n)}(n),e.webglTexSize=Math.min(e.webglTexSize,r.getParameter(r.MAX_TEXTURE_SIZE)),e.webglTexRows=Math.min(e.webglTexRows,54),e.webglTexRowsNodes=Math.min(e.webglTexRowsNodes,54),e.webglBatchSize=Math.min(e.webglBatchSize,16384),e.webglTexPerBatch=Math.min(e.webglTexPerBatch,r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS)),n.webglDebug=e.webglDebug,n.webglDebugShowAtlases=e.webglDebugShowAtlases,n.pickingFrameBuffer=function(e){var t=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);var n=e.createTexture();return e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.bindFramebuffer(e.FRAMEBUFFER,null),t.setFramebufferAttachmentSizes=function(t,r){e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,null)},t}(r),n.pickingFrameBuffer.needsDraw=!0,n.drawing=new Bd(n,r,e);var i=function(e){return function(t){return n.getTextAngle(t,e)}},o=function(e){return function(t){var n=t.pstyle(e);return n&&n.value}},a=function(e){return function(t){return t.pstyle("".concat(e,"-opacity")).value>0}},s=function(e){return"yes"===e.pstyle("text-events").strValue?Rd:Ld},l=function(e){var t=e.position(),n=t.x,r=t.y,i=e.outerWidth(),o=e.outerHeight();return{w:i,h:o,x1:n-i/2,y1:r-o/2}};n.drawing.addAtlasCollection("node",{texRows:e.webglTexRowsNodes}),n.drawing.addAtlasCollection("label",{texRows:e.webglTexRows}),n.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),n.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:l,isSimple:gd,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),n.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:l,isVisible:a("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),n.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:l,isVisible:a("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),n.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:s,getKey:Vd(t.getLabelKey,null),getBoundingBox:Gd(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:i(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:o("label")}),n.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:s,getKey:Vd(t.getSourceLabelKey,"source"),getBoundingBox:Gd(t.getSourceLabelBox,"source"),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:i("source"),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:o("source-label")}),n.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:s,getKey:Vd(t.getTargetLabelKey,"target"),getBoundingBox:Gd(t.getTargetLabelBox,"target"),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:i("target"),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:o("target-label")});var c=Re(function(){console.log("garbage collect flag set"),n.data.gc=!0},1e4);n.onUpdateEleCalcs(function(e,t){var r=!1;t&&t.length>0&&(r|=n.drawing.invalidate(t)),r&&c()}),function(e){var t=e.render;e.render=function(n){n=n||{};var r=e.cy;e.webgl&&(r.zoom()>Oh?(!function(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}(e),t.call(e,n)):(!function(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}(e),$d(e,n,Dd.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,i){return function(e,t,n){var r,i,o,a=function(e,t,n){var r,i,o,a,s=pd(e),l=s.pan,u=s.zoom,c=function(e,t,n,r,i){var o=r*n+t.x,a=i*n+t.y;return[o,a=Math.round(e.canvasHeight-a)]}(e,l,u,t,n),d=h(c,2),f=d[0],p=d[1],g=6;if(r=f-g/2,i=p-g/2,o=g,a=g,0===o||0===a)return[];var v=e.data.contexts[e.WEBGL];v.bindFramebuffer(v.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(v.viewport(0,0,v.canvas.width,v.canvas.height),$d(e,null,Dd.PICKING),e.pickingFrameBuffer.needsDraw=!1);var y=o*a,m=new Uint8Array(4*y);v.readPixels(r,i,o,a,v.RGBA,v.UNSIGNED_BYTE,m),v.bindFramebuffer(v.FRAMEBUFFER,null);for(var b=new Set,x=0;x<y;x++){var w=bd(m.slice(4*x,4*x+4))-1;w>=0&&b.add(w)}return b}(e,t,n),s=e.getCachedZSortedEles(),l=u(a);try{for(l.s();!(o=l.n()).done;){var c=s[o.value];if(!r&&c.isNode()&&(r=c),!i&&c.isEdge()&&(i=c),r&&i)break}}catch(e){l.e(e)}finally{l.f()}return[r,i].filter(Boolean)}(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var i=e.notify;e.notify=function(t,n){i.call(e,t,n),"viewport"===t||"bounds"===t?e.pickingFrameBuffer.needsDraw=!0:"background"===t&&e.drawing.invalidate(n,{type:"node-body"})}}(n)};var Vd=function(e,t){return function(n){var r=e(n),i=Fd(n,t);return i.length>1?i.map(function(e,t){return"".concat(r,"_").concat(t)}):r}},Gd=function(e,t){return function(n,r){var i=e(n);if("string"==typeof r){var o=r.indexOf("_");if(o>0){var a=Number(r.substring(o+1)),s=Fd(n,t),l=i.h/s.length,u=l*a,c=i.y1+u;return{x1:i.x1,w:i.w,y1:c,h:l,yOffset:u}}}return i}};function Yd(e,t){var n=e.canvasWidth,r=e.canvasHeight,i=pd(e),o=i.pan,a=i.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(o.x,o.y),t.scale(a,a)}function Xd(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,"node-underlay"),r.drawNode(n,t,"node-body"),r.drawTexture(n,t,"label"),r.drawNode(n,t,"node-overlay")):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,"source"),r.drawEdgeArrow(n,t,"target"),r.drawTexture(n,t,"label"),r.drawTexture(n,t,"edge-source-label"),r.drawTexture(n,t,"edge-target-label"))}function $d(e,t,n){var r;e.webglDebug&&(r=performance.now());var i=e.drawing,o=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&function(e,t){e.drawSelectionRectangle(t,function(t){return Yd(e,t)})}(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var a=e.data.contexts[e.WEBGL];n.screen?(a.clearColor(0,0,0,0),a.enable(a.BLEND),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA)):a.disable(a.BLEND),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),a.viewport(0,0,a.canvas.width,a.canvas.height);var s=function(e){var t=e.canvasWidth,n=e.canvasHeight,r=pd(e),i=r.pan,o=r.zoom,a=Md();Nd(a,a,[i.x,i.y]),Sd(a,a,[o,o]);var s=Md();!function(e,t,n){e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1}(s,t,n);var l=Md();return function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],f=n[1],p=n[2],g=n[3],v=n[4],y=n[5],m=n[6],b=n[7],x=n[8];e[0]=d*r+f*a+p*u,e[1]=d*i+f*s+p*c,e[2]=d*o+f*l+p*h,e[3]=g*r+v*a+y*u,e[4]=g*i+v*s+y*c,e[5]=g*o+v*l+y*h,e[6]=m*r+b*a+x*u,e[7]=m*i+b*s+x*c,e[8]=m*o+b*l+x*h}(l,s,a),l}(e),l=e.getCachedZSortedEles();if(o=l.length,i.startFrame(s,n),n.screen){for(var c=0;c<l.nondrag.length;c++)Xd(e,c,l.nondrag[c]);for(var h=0;h<l.drag.length;h++)Xd(e,h,l.drag[h])}else if(n.picking)for(var d=0;d<l.length;d++)Xd(e,d,l[d]);i.endFrame(),n.screen&&e.webglDebugShowAtlases&&(function(e){var t=e.data.contexts[e.NODE];t.save(),Yd(e,t),t.strokeStyle="rgba(0, 0, 0, 0.3)",t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}(e),function(e){var t=function(t,n,r){for(var i=t.atlasManager.getAtlasCollection(n),o=e.data.contexts[e.NODE],a=i.atlases,s=0;s<a.length;s++){var l=a[s].canvas;if(l){var u=l.width,c=l.height,h=u*s,d=l.height*r;o.save(),o.scale(.4,.4),o.drawImage(l,h,d),o.strokeStyle="black",o.rect(h,d,u,c),o.stroke(),o.restore()}}},n=0;t(e.drawing,"node",n++),t(e.drawing,"label",n++)}(e)),n.screen&&(e.data.canvasNeedsRedraw[e.NODE]=!1,e.data.canvasNeedsRedraw[e.DRAG]=!1)}if(e.webglDebug){var f=performance.now(),p=Math.ceil(f-r),g=i.getDebugInfo(),v=["".concat(o," elements"),"".concat(g.totalInstances," instances"),"".concat(g.batchCount," batches"),"".concat(g.totalAtlases," atlases"),"".concat(g.wrappedCount," wrapped textures"),"".concat(g.simpleCount," simple shapes")].join(", ");console.log("WebGL (".concat(n.name,") - frame time ").concat(p,"ms")),console.log("Totals:"),console.log(" ".concat(v)),console.log("Texture Atlases Used:");var y,m=u(g.atlasInfo);try{for(m.s();!(y=m.n()).done;){var b=y.value;console.log(" ".concat(b.type,": ").concat(b.keyCount," keys, ").concat(b.atlasCount," atlases"))}}catch(e){m.e(e)}finally{m.f()}console.log("")}e.data.gc&&(console.log("Garbage Collect!"),e.data.gc=!1,i.gc())}for(var Ud={drawPolygonPath:function(e,t,n,r,i,o){var a=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+a*o[0],n+s*o[1]);for(var l=1;l<o.length/2;l++)e.lineTo(t+a*o[2*l],n+s*o[2*l+1]);e.closePath()},drawRoundPolygonPath:function(e,t,n,r,i,o,a){a.forEach(function(t){return oh(e,t)}),e.closePath()},drawRoundRectanglePath:function(e,t,n,r,i,o){var a=r/2,s=i/2,l="auto"===o?Gn(r,i):Math.min(o,s,a);e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.arcTo(t+a,n-s,t+a,n,l),e.arcTo(t+a,n+s,t,n+s,l),e.arcTo(t-a,n+s,t-a,n,l),e.arcTo(t-a,n-s,t,n-s,l),e.lineTo(t,n-s),e.closePath()},drawBottomRoundRectanglePath:function(e,t,n,r,i,o){var a=r/2,s=i/2,l="auto"===o?Gn(r,i):o;e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.lineTo(t+a,n-s),e.lineTo(t+a,n),e.arcTo(t+a,n+s,t,n+s,l),e.arcTo(t-a,n+s,t-a,n,l),e.lineTo(t-a,n-s),e.lineTo(t,n-s),e.closePath()},drawCutRectanglePath:function(e,t,n,r,i,o,a){var s=r/2,l=i/2,u="auto"===a?8:a;e.beginPath&&e.beginPath(),e.moveTo(t-s+u,n-l),e.lineTo(t+s-u,n-l),e.lineTo(t+s,n-l+u),e.lineTo(t+s,n+l-u),e.lineTo(t+s-u,n+l),e.lineTo(t-s+u,n+l),e.lineTo(t-s,n+l-u),e.lineTo(t-s,n-l+u),e.closePath()},drawBarrelPath:function(e,t,n,r,i){var o=r/2,a=i/2,s=t-o,l=t+o,u=n-a,c=n+a,h=Xn(r,i),d=h.widthOffset,f=h.heightOffset,p=h.ctrlPtOffsetPct*d;e.beginPath&&e.beginPath(),e.moveTo(s,u+f),e.lineTo(s,c-f),e.quadraticCurveTo(s+p,c,s+d,c),e.lineTo(l-d,c),e.quadraticCurveTo(l-p,c,l,c-f),e.lineTo(l,u+f),e.quadraticCurveTo(l-p,u,l-d,u),e.lineTo(s+d,u),e.quadraticCurveTo(s+p,u,s,u+f),e.closePath()}},jd=Math.sin(0),Hd=Math.cos(0),Wd={},qd={},Kd=Math.PI/40,Zd=0*Math.PI;Zd<2*Math.PI;Zd+=Kd)Wd[Zd]=Math.sin(Zd),qd[Zd]=Math.cos(Zd);Ud.drawEllipsePath=function(e,t,n,r,i){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,i/2,0,0,2*Math.PI);else for(var o,a,s=r/2,l=i/2,u=0*Math.PI;u<2*Math.PI;u+=Kd)o=t-s*Wd[u]*jd+s*qd[u]*Hd,a=n+l*qd[u]*jd+l*Wd[u]*Hd,0===u?e.moveTo(o,a):e.lineTo(o,a);e.closePath()};var Qd={};function Jd(e){var t=e.indexOf(",");return e.substr(t+1)}function ef(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case"blob-promise":return new si(function(r,i){try{t.toBlob(function(e){null!=e?r(e):i(new Error("`canvas.toBlob()` sent a null value in its callback"))},n,e.quality)}catch(e){i(e)}});case"blob":return function(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),o=0;o<n.length;o++)i[o]=n.charCodeAt(o);return new Blob([r],{type:t})}(Jd(r()),n);case"base64":return Jd(r());default:return r()}}Qd.createBuffer=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,[n,n.getContext("2d")]},Qd.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),i=e.full?Math.ceil(n.w):r[2],o=e.full?Math.ceil(n.h):r[3],a=te(e.maxWidth)||te(e.maxHeight),s=this.getPixelRatio(),l=1;if(void 0!==e.scale)i*=e.scale,o*=e.scale,l=e.scale;else if(a){var u=1/0,c=1/0;te(e.maxWidth)&&(u=l*e.maxWidth/i),te(e.maxHeight)&&(c=l*e.maxHeight/o),i*=l=Math.min(u,c),o*=l}a||(i*=s,o*=s,l*=s);var h=document.createElement("canvas");h.width=i,h.height=o,h.style.width=i+"px",h.style.height=o+"px";var d=h.getContext("2d");if(i>0&&o>0){d.clearRect(0,0,i,o),d.globalCompositeOperation="source-over";var f=this.getCachedZSortedEles();if(e.full)d.translate(-n.x1*l,-n.y1*l),d.scale(l,l),this.drawElements(d,f);else{var p=t.pan(),g={x:p.x*l,y:p.y*l};l*=t.zoom(),d.translate(g.x,g.y),d.scale(l,l),this.drawElements(d,f)}d.setTransform(1,0,0,1,0,0),e.bg&&(d.globalCompositeOperation="destination-over",d.fillStyle=e.bg,d.fillRect(0,0,i,o))}return h},Qd.png=function(e){return ef(e,this.bufferCanvasImage(e),"image/png")},Qd.jpg=function(e){return ef(e,this.bufferCanvasImage(e),"image/jpeg")};var tf={nodeShapeImpl:function(e,t,n,r,i,o,a,s){switch(e){case"ellipse":return this.drawEllipsePath(t,n,r,i,o);case"polygon":return this.drawPolygonPath(t,n,r,i,o,a);case"round-polygon":return this.drawRoundPolygonPath(t,n,r,i,o,a,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,n,r,i,o,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,n,r,i,o,a,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,n,r,i,o,s);case"barrel":return this.drawBarrelPath(t,n,r,i,o)}}},nf=of,rf=of.prototype;function of(e){var t=this,n=t.cy.window().document;e.webgl&&(rf.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),t.data={canvases:new Array(rf.CANVAS_LAYERS),contexts:new Array(rf.CANVAS_LAYERS),canvasNeedsRedraw:new Array(rf.CANVAS_LAYERS),bufferCanvases:new Array(rf.BUFFER_COUNT),bufferContexts:new Array(rf.CANVAS_LAYERS)};var r="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";t.data.canvasContainer=n.createElement("div");var o=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=i,o.position="relative",o.zIndex="0",o.overflow="hidden";var a=e.cy.container();a.appendChild(t.data.canvasContainer),a.style[r]=i;var s={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};y&&y.userAgent.match(/msie|trident|edge/i)&&(s["-ms-touch-action"]="none",s["touch-action"]="none");for(var l=0;l<rf.CANVAS_LAYERS;l++){var u=t.data.canvases[l]=n.createElement("canvas"),c=rf.CANVAS_TYPES[l];t.data.contexts[l]=u.getContext(c),t.data.contexts[l]||lt("Could not create canvas of type "+c),Object.keys(s).forEach(function(e){u.style[e]=s[e]}),u.style.position="absolute",u.setAttribute("data-id","layer"+l),u.style.zIndex=String(rf.CANVAS_LAYERS-l),t.data.canvasContainer.appendChild(u),t.data.canvasNeedsRedraw[l]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[rf.NODE].setAttribute("data-id","layer"+rf.NODE+"-node"),t.data.canvases[rf.SELECT_BOX].setAttribute("data-id","layer"+rf.SELECT_BOX+"-selectbox"),t.data.canvases[rf.DRAG].setAttribute("data-id","layer"+rf.DRAG+"-drag"),t.data.canvases[rf.WEBGL]&&t.data.canvases[rf.WEBGL].setAttribute("data-id","layer"+rf.WEBGL+"-webgl");for(l=0;l<rf.BUFFER_COUNT;l++)t.data.bufferCanvases[l]=n.createElement("canvas"),t.data.bufferContexts[l]=t.data.bufferCanvases[l].getContext("2d"),t.data.bufferCanvases[l].style.position="absolute",t.data.bufferCanvases[l].setAttribute("data-id","buffer"+l),t.data.bufferCanvases[l].style.zIndex=String(-l-1),t.data.bufferCanvases[l].style.visibility="hidden";t.pathsEnabled=!0;var h=cn(),d=function(e){return{x:-e.w/2,y:-e.h/2}},f=function(e){return e[0]._private.nodeKey},p=function(e){return e[0]._private.labelStyleKey},g=function(e){return e[0]._private.sourceLabelStyleKey},v=function(e){return e[0]._private.targetLabelStyleKey},m=function(e,n,r,i,o){return t.drawElement(e,n,r,!1,!1,o)},b=function(e,n,r,i,o){return t.drawElementText(e,n,r,i,"main",o)},x=function(e,n,r,i,o){return t.drawElementText(e,n,r,i,"source",o)},w=function(e,n,r,i,o){return t.drawElementText(e,n,r,i,"target",o)},E=function(e){return e.boundingBox(),e[0]._private.bodyBounds},T=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||h},C=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||h},M=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||h},A=function(e,t){return t},N=function(e){return{x:((t=E(e)).x1+t.x2)/2,y:(t.y1+t.y2)/2};var t},_=function(e,t,n){var r=e?e+"-":"";return{x:t.x+n.pstyle(r+"text-margin-x").pfValue,y:t.y+n.pstyle(r+"text-margin-y").pfValue}},S=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},k=function(e){return _("",S(e,"labelX","labelY"),e)},P=function(e){return _("source",S(e,"sourceLabelX","sourceLabelY"),e)},I=function(e){return _("target",S(e,"targetLabelX","targetLabelY"),e)},O=function(e){return d(E(e))},D=function(e){return d(C(e))},L=function(e){return d(M(e))},R=function(e){var t=T(e),n=d(T(e));if(e.isNode()){switch(Vs(e.pstyle("text-halign").value)){case"left":n.x=-t.w-(t.leftPad||0);break;case"right":n.x=-(t.rightPad||0)}switch(Gs(e.pstyle("text-valign").value)){case"top":n.y=-t.h-(t.topPad||0);break;case"bottom":n.y=-(t.botPad||0)}}return n},B=t.data.eleTxrCache=new Rh(t,{getKey:f,doesEleInvalidateKey:function(e){var t=e[0]._private;return!(t.oldBackgroundTimestamp===t.backgroundTimestamp)},drawElement:m,getBoundingBox:E,getRotationPoint:N,getRotationOffset:O,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),z=t.data.lblTxrCache=new Rh(t,{getKey:p,drawElement:b,getBoundingBox:T,getRotationPoint:k,getRotationOffset:R,isVisible:A}),F=t.data.slbTxrCache=new Rh(t,{getKey:g,drawElement:x,getBoundingBox:C,getRotationPoint:P,getRotationOffset:D,isVisible:A}),V=t.data.tlbTxrCache=new Rh(t,{getKey:v,drawElement:w,getBoundingBox:M,getRotationPoint:I,getRotationOffset:L,isVisible:A}),G=t.data.lyrTxrCache=new zh(t);t.onUpdateEleCalcs(function(e,t){B.invalidateElements(t),z.invalidateElements(t),F.invalidateElements(t),V.invalidateElements(t),G.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var Y=function(e){for(var t=0;t<e.length;t++)G.enqueueElementRefinement(e[t].ele)};B.onDequeue(Y),z.onDequeue(Y),F.onDequeue(Y),V.onDequeue(Y),e.webgl&&t.initWebgl(e,{getStyleKey:f,getLabelKey:p,getSourceLabelKey:g,getTargetLabelKey:v,drawElement:m,drawLabel:b,drawSourceLabel:x,drawTargetLabel:w,getElementBox:E,getLabelBox:T,getSourceLabelBox:C,getTargetLabelBox:M,getElementRotationPoint:N,getElementRotationOffset:O,getLabelRotationPoint:k,getSourceLabelRotationPoint:P,getTargetLabelRotationPoint:I,getLabelRotationOffset:R,getSourceLabelRotationOffset:D,getTargetLabelRotationOffset:L})}rf.CANVAS_LAYERS=3,rf.SELECT_BOX=0,rf.DRAG=1,rf.NODE=2,rf.WEBGL=3,rf.CANVAS_TYPES=["2d","2d","2d","webgl2"],rf.BUFFER_COUNT=3,rf.TEXTURE_BUFFER=0,rf.MOTIONBLUR_BUFFER_NODE=1,rf.MOTIONBLUR_BUFFER_DRAG=2,rf.redrawHint=function(e,t){var n=this;switch(e){case"eles":n.data.canvasNeedsRedraw[rf.NODE]=t;break;case"drag":n.data.canvasNeedsRedraw[rf.DRAG]=t;break;case"select":n.data.canvasNeedsRedraw[rf.SELECT_BOX]=t;break;case"gc":n.data.gc=!0}};var af="undefined"!=typeof Path2D;rf.path2dEnabled=function(e){if(void 0===e)return this.pathsEnabled;this.pathsEnabled=!!e},rf.usePaths=function(){return af&&this.pathsEnabled},rf.setImgSmoothing=function(e,t){null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled=t:(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t)},rf.getImgSmoothing=function(e){return null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled:e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled},rf.makeOffscreenCanvas=function(e,t){var n;"undefined"!==("undefined"==typeof OffscreenCanvas?"undefined":p(OffscreenCanvas))?n=new OffscreenCanvas(e,t):((n=this.cy.window().document.createElement("canvas")).width=e,n.height=t);return n},[Xh,qh,nd,id,od,sd,cd,zd,Ud,Qd,tf].forEach(function(e){Te(rf,e)});var sf=[{type:"layout",extensions:Pc},{type:"renderer",extensions:[{name:"null",impl:Ic},{name:"base",impl:_h},{name:"canvas",impl:nf}]}],lf={},uf={};function cf(e,t,n){var r=n,i=function(n){ct("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if("core"===e){if($u.prototype[t])return i(t);$u.prototype[t]=n}else if("collection"===e){if(ru.prototype[t])return i(t);ru.prototype[t]=n}else if("layout"===e){for(var o=function(e){this.options=e,n.call(this,e),ee(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},a=o.prototype=Object.create(n.prototype),s=[],l=0;l<s.length;l++){var u=s[l];a[u]=a[u]||function(){return this}}a.start&&!a.run?a.run=function(){return this.start(),this}:!a.start&&a.run&&(a.start=function(){return this.run(),this});var c=n.prototype.stop;a.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return c?c.call(this):this.emit("layoutstop"),this},a.destroy||(a.destroy=function(){return this}),a.cy=function(){return this._private.cy};var h=function(e){return e._private.cy},d={addEventFields:function(e,t){t.layout=e,t.cy=h(e),t.target=e},bubble:function(){return!0},parent:function(e){return h(e)}};Te(a,{createEmitter:function(){return this._private.emitter=new wl(d,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),Da.eventAliasesOn(a),r=o}else if("renderer"===e&&"null"!==t&&"base"!==t){var f=hf("renderer","base"),p=f.prototype,g=n,v=n.prototype,y=function(){f.apply(this,arguments),g.apply(this,arguments)},m=y.prototype;for(var b in p){var x=p[b];if(null!=v[b])return i(b);m[b]=x}for(var w in v)m[w]=v[w];p.clientFunctions.forEach(function(e){m[e]=m[e]||function(){lt("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=y}else if("__proto__"===e||"constructor"===e||"prototype"===e)return lt(e+" is an illegal type to be registered, possibly lead to prototype pollutions");return Ae({map:lf,keys:[e,t],value:r})}function hf(e,t){return Ne({map:lf,keys:[e,t]})}function df(e,t,n,r,i){return Ae({map:uf,keys:[e,t,n,r],value:i})}function ff(e,t,n,r){return Ne({map:uf,keys:[e,t,n,r]})}var pf=function(){return 2===arguments.length?hf.apply(null,arguments):3===arguments.length?cf.apply(null,arguments):4===arguments.length?ff.apply(null,arguments):5===arguments.length?df.apply(null,arguments):void lt("Invalid extension access syntax")};$u.prototype.extension=pf,sf.forEach(function(e){e.extensions.forEach(function(t){cf(e.type,t.name,t.impl)})});var gf=function(){if(!(this instanceof gf))return new gf;this.length=0},vf=gf.prototype;vf.instanceString=function(){return"stylesheet"},vf.selector=function(e){return this[this.length++]={selector:e,properties:[]},this},vf.css=function(e,t){var n=this.length-1;if(Z(e))this[n].properties.push({name:e,value:t});else if(ee(e))for(var r=e,i=Object.keys(r),o=0;o<i.length;o++){var a=i[o],s=r[a];if(null!=s){var l=Fu.properties[a]||Fu.properties[fe(a)];if(null!=l){var u=l.name,c=s;this[n].properties.push({name:u,value:c})}}}return this},vf.style=vf.css,vf.generateStyle=function(e){var t=new Fu(e);return this.appendToStyle(t)},vf.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,i=n.properties;e.selector(r);for(var o=0;o<i.length;o++){var a=i[o];e.css(a.name,a.value)}}return e};var yf=function(e){return void 0===e&&(e={}),ee(e)?new $u(e):Z(e)?pf.apply(pf,arguments):void 0};yf.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(yf),e.apply(null,t),this},yf.warnings=function(e){return ut(e)},yf.version="3.35.0",yf.stylesheet=yf.Stylesheet=gf;var mf=n(527),bf=n.n(mf);const xf={position:"absolute",left:"0",top:"0",userSelect:"none",outlineStyle:"none",width:"100%",height:"100%"};function wf(e){e.stopPropagation()}function Ef(e){e.addEventListener("click",wf),e.addEventListener("mousedown",wf),e.addEventListener("mouseup",wf),e.addEventListener("mousemove",wf)}class Tf{constructor(e){this.adapter=e,this.updateOnRenderEnabled=!1,this.updateOnRenderOnceEnabled=!1,this.updateOnRenderOnce=()=>{this.updateOnRenderOnceEnabled||(this.updateOnRenderOnceEnabled=!0,this.cy.one("render",()=>{this.updateOnRenderOnceEnabled=!1,this.update()}))}}inVisibleBounds(e){return this.adapter.inVisibleBounds(e)}supportsRender(){return!1}renderInto(e){}get updateOnRender(){return this.updateOnRenderEnabled}set updateOnRender(e){this.updateOnRenderEnabled!==e&&(this.updateOnRenderEnabled=e,e?this.cy.on("render",this.update):this.cy.off("render",this.update))}get cy(){return this.adapter.cy}moveUp(){this.adapter.move(this,-1)}moveDown(){this.adapter.move(this,1)}moveBack(){this.adapter.move(this,Number.NEGATIVE_INFINITY)}moveFront(){this.adapter.move(this,Number.POSITIVE_INFINITY)}insertBefore(e,t){return this.adapter.insert("before",this,e,t)}insertAfter(e,t){return this.adapter.insert("after",this,e,t)}}class Cf extends Tf{constructor(e,t){super(e),this.callbacks=[],this.update=()=>{for(const e of this.callbacks)e(this.node)},this.root=t,Object.assign(this.root.style,xf)}get visible(){return"none"!==this.root.style.display}set visible(e){this.visible!==e&&(this.root.style.display=e?"":"none")}show(){this.visible=!0}hide(){this.visible=!1}callback(e){return this.callbacks.push(e),this.update(),this}resize(){}remove(){this.root.remove()}}const Mf="http://www.w3.org/2000/svg";class Af extends Cf{constructor(e,t,n={}){super(e,t.createElementNS(Mf,"svg")),this.type="svg",this.updateOnTransform=!1,this.root.__cy_layer=this,this.node=t.createElementNS(Mf,"g"),this.node.__cy_layer=this,this.root.appendChild(this.node),n.stopClicks&&Ef(this.node)}setViewport(e,t,n){this.node.setAttribute("transform",`translate(${e},${t})scale(${n})`),this.updateOnTransform&&this.update()}supportsRender(){return 0===this.node.childElementCount}}class Nf extends Cf{constructor(e,t,n={}){super(e,t.createElementNS(Mf,"svg")),this.type="svg-static",this.root.__cy_layer=this,this.node=t.createElementNS(Mf,"g"),this.node.__cy_layer=this,this.root.appendChild(this.node),n.stopClicks&&Ef(this.node)}setViewport(){}}class _f extends Tf{constructor(e,t,n={}){var r,i;super(e),this.callbacks=[],this.transform={tx:0,ty:0,zoom:1},this.update=()=>this.draw(),this.node=t.createElement("canvas"),Object.assign(this.node.style,xf),n.stopClicks&&Ef(this.node),this.pixelRatio=null!==(i=null!==(r=n.pixelRatio)&&void 0!==r?r:(null!==window&&void 0!==window?window:{}).devicePixelRatio)&&void 0!==i?i:1,this.ctx=this.node.getContext("2d",n),this.ctx.resetTransform()}get visible(){return"none"!==this.node.style.display}set visible(e){this.node.style.display=e?"":"none"}show(){this.visible=!0}hide(){this.visible=!1}get root(){return this.node}callback(e){return this.callbacks.push(e),this.update(),this}clear(){const e=this.ctx,t=e.getTransform();e.resetTransform(),e.clearRect(0,0,e.canvas.width,e.canvas.height),e.setTransform(t)}draw(){this.clear(),this.drawImpl(this.ctx)}drawImpl(e,t=1){e.save(),e.resetTransform(),e.scale(this.pixelRatio,this.pixelRatio),e.translate(this.transform.tx*t,this.transform.ty*t),e.scale(this.transform.zoom*t,this.transform.zoom*t);for(const t of this.callbacks)t(e,{});e.restore()}supportsRender(){return!0}renderInto(e){for(const t of this.callbacks)t(e,{forExport:!0})}resize(e,t){this.node.width=e*this.pixelRatio,this.node.height=t*this.pixelRatio,this.update()}setViewport(e,t,n){}remove(){this.node.remove()}}class Sf extends _f{constructor(e,t,n={}){super(e,t,n),this.type="canvas",this.node.__cy_layer=this}setViewport(e,t,n){this.transform.tx=e,this.transform.ty=t,this.transform.zoom=n,this.update()}}class kf extends _f{constructor(e,t,n={}){super(e,t,n),this.type="canvas-static",this.node.__cy_layer=this}}class Pf extends Cf{constructor(e,t,n={}){super(e,t.createElement("div")),this.type="html",this.updateOnTransform=!1,this.root.__cy_layer=this,this.node=t.createElement("div"),this.node.__cy_layer=this,this.node.style.position="absolute",this.node.style.left="0px",this.node.style.top="0px",this.root.appendChild(this.node),n.stopClicks&&Ef(this.node)}setViewport(e,t,n){this.node.style.transform=`translate(${e}px,${t}px)scale(${n})`,this.updateOnTransform&&this.update()}supportsRender(){return 0===this.node.childElementCount}}class If extends Cf{constructor(e,t,n={}){super(e,t.createElement("div")),this.type="html-static",this.node.__cy_layer=this,n.stopClicks&&Ef(this.node)}get node(){return this.root}setViewport(){}}class Of extends Tf{constructor(e,t){super(e),this.update=()=>{},this.node=t}get root(){return this.node}resize(){}setViewport(){}remove(){}supportsRender(){return!0}}class Df extends Of{constructor(e,t){super(e,t),this.type="node",this.node.__cy_layer=this}}class Lf extends Of{constructor(e,t){super(e,t),this.type="drag",this.node.__cy_layer=this}}class Rf extends Of{constructor(e,t){super(e,t),this.type="select-box",this.node.__cy_layer=this}}function Bf(e,t,n){const r=Array.from(e.children);if(!n.uniqueElements){t.forEach(t=>{if(t.removed())return;const i=n.bb(t);if(n.isVisible(i))if(r.length>0)n.update(r.shift(),t,i);else{const r=n.enter(t,i);e.appendChild(r),n.update(r,t,i)}});for(const e of r)e.remove();return}const i=new Map(r.map(e=>[e.dataset.id,e]));let o=-1;t.forEach(t=>{if(t.removed())return;const a=n.bb(t);if(!n.isVisible(a))return;o++;const s=t.id(),l=r[o],u=i.get(s);let c;if(u){if(n.update(u,t,a),i.delete(s),l===u)return;c=u}else c=n.enter(t,a),c.dataset.id=s,n.update(c,t,a);0===o?e.insertAdjacentElement("afterbegin",c):r[o-1].insertAdjacentElement("afterend",c),r.splice(o,0,c)}),i.forEach(e=>e.remove())}function zf(e,t){return e.callback(t),{remove:()=>{e.callbacks.splice(e.callbacks.indexOf(t),1)}}}function Ff(e){return{selector:":visible",updateOn:null!=e&&e.queryEachTime?"render":"position",queryEachTime:!1,checkBounds:!0}}function Vf(e,t,n){const r=Object.assign({checkBoundsPointCount:5,initCollection:()=>{}},Ff(n),n);let i=e.cy.collection(),o=!1;const a=()=>{o||(o=!0,e.cy.one("render",()=>{o=!1,i=s(i),e.update()}))},s=t=>{"none"!==r.updateOn&&"render"!==r.updateOn&&(t.off(r.updateOn,void 0,e.updateOnRenderOnce),t.sources().off(r.updateOn,void 0,e.updateOnRenderOnce),t.targets().off(r.updateOn,void 0,e.updateOnRenderOnce));const n=e.cy.edges(r.selector);return r.initCollection(n),"none"!==r.updateOn&&"render"!==r.updateOn&&(n.on(r.updateOn,e.updateOnRenderOnce),n.sources().on(r.updateOn,e.updateOnRenderOnce),n.targets().on(r.updateOn,e.updateOnRenderOnce)),e.updateOnRenderOnce(),n};"render"===r.updateOn&&(e.updateOnRender=!0),r.queryEachTime||(i=s(i),e.cy.on("add remove",r.selector,a));const l=zf(e,(n,o)=>{r.queryEachTime&&(i=s(i)),i.forEach(i=>{if(i.removed())return;const a=i._private.rscratch,s=a&&null!=a.startX&&null!=a.startY?{x:a.startX,y:a.startY}:i.sourceEndpoint(),l=a&&null!=a.endX&&null!=a.endY?{x:a.endX,y:a.endY}:i.targetEndpoint();if(!o.forExport&&r.checkBounds&&r.checkBoundsPointCount>0&&!function(e,t,n,r){const i=e=>({x:t.x*e+n.x*(1-e),y:t.y*e+n.y*(1-e)});if(1===r)return e.inVisibleBounds(i(.5));const o=1/r;for(let t=0;t<=r;t++)if(e.inVisibleBounds(i(t*o)))return!0;return!1}(e,s,l,r.checkBoundsPointCount))return;if(a&&a.pathCache)return void t(n,i,a.pathCache,s,l);const u=new Path2D;u.moveTo(s.x,s.y),u.lineTo(l.x,l.y),t(n,i,u,s,l)})});return{layer:e,edges:i,remove:()=>{"none"!==r.updateOn&&"render"!==r.updateOn&&(i.off(r.updateOn,void 0,e.updateOnRenderOnce),i.sources().off(r.updateOn,void 0,e.updateOnRenderOnce),i.targets().off(r.updateOn,void 0,e.updateOnRenderOnce)),e.cy.off("add remove",r.selector,a),l.remove()}}}function Gf(e,t,n={}){const r=Object.assign({transform:"",position:"top-left",boundingBox:{includeLabels:!1,includeOverlays:!1},uniqueElements:!1,initCollection:()=>{}},Ff(n),n);let i=e.cy.collection(),o=!1;const a=()=>{o||(o=!0,e.cy.one("render",()=>{o=!1,i=s(i),e.update()}))},s=t=>{"none"!==r.updateOn&&"render"!==r.updateOn&&t.off(r.updateOn,void 0,e.updateOnRenderOnce);const n=e.cy.nodes(r.selector);return r.initCollection(n),"none"!==r.updateOn&&"render"!==r.updateOn&&n.on(r.updateOn,e.updateOnRenderOnce),e.updateOnRenderOnce(),n};"render"===r.updateOn&&(e.updateOnRender=!0),r.queryEachTime||(i=s(i),e.cy.on("add remove",r.selector,a));const l=t=>({layer:e,nodes:i,remove:()=>{"none"!==r.updateOn&&"render"!==r.updateOn&&i.off(r.updateOn,void 0,e.updateOnRenderOnce),e.cy.off("add remove",r.selector,a),t.remove()}});if("canvas"===e.type){const n=r,o=(o,a)=>{const l=o.getTransform();r.queryEachTime&&(i=s(i)),i.forEach(i=>{if(i.removed())return;const s=i.boundingBox(r.boundingBox);if(a.forExport||!n.checkBounds||e.inVisibleBounds(s)){if("top-left"===n.position)o.translate(s.x1,s.y1);else if("center"===n.position){const e=i.position();o.translate(e.x,e.y)}t(o,i,s),"none"!==n.position&&o.setTransform(l)}})};return l(zf(e,o))}const u=r,c={bb:e=>e.boundingBox(u.boundingBox),isVisible:u.checkBounds?t=>e.inVisibleBounds(t):()=>!0,uniqueElements:!0===u.uniqueElements};if(u.checkBounds&&(e.updateOnTransform=!0),"html"===e.type){const n={...c,enter:(t,n)=>{const r=e.node.ownerDocument.createElement("div");return r.style.position="absolute",u.init&&u.init(r,t,n),r},update:(e,n,r)=>{if("top-left"===u.position)e.style.transform=`${u.transform}translate3d(${r.x1}px,${r.y1}px,0)`;else if("center"===u.position){const t=n.position();e.style.transform=`${u.transform}translate3d(${t.x}px,${t.y}px,0)`}t(e,n,r)}};return l(zf(e,e=>{r.queryEachTime&&(i=s(i)),Bf(e,i,n)}))}const h={...c,enter:(t,n)=>{const r=e.node.ownerDocument.createElementNS(Mf,"g");return u.init&&u.init(r,t,n),r},update:(e,n,r)=>{if("top-left"===u.position)e.setAttribute("transform",`${u.transform}translate3d(${r.x1},${r.y1},0)`);else if("center"===u.position){const t=n.position();e.setAttribute("transform",`${u.transform}translate3d(${t.x},${t.y},0)`)}t(e,n,r)}};return l(zf(e,e=>{r.queryEachTime&&(i=s(i)),Bf(e,i,h)}))}function Yf(e){const t=e.indexOf(",");return e.substring(t+1)}function Xf(e,t,n){const r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case"blob-promise":return new Promise((r,i)=>{try{t.toBlob(function(e){null!=e?r(e):i(new Error("`canvas.toBlob()` sent a null value in its callback"))},n,e.quality)}catch(e){i(e)}});case"blob":return function(e,t){const n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return new Blob([r],{type:t})}(Yf(r()),n);case"base64":return Yf(r());default:return r()}}class $f extends Error{}class Uf{constructor(e){this.bak={},this.resize=()=>{const e=this.cy.width(),t=this.cy.height();this.viewport.width=e,this.viewport.height=t;for(const n of this.layers)n.resize(e,t)},this.destroy=()=>{for(const e of this.layers)e.remove();this.cy.off("destroy",this.destroy),this.cy.off("viewport",this.zoomed),this.cy.off("resize",this.resize),this.cy.scratch("_layers",void 0),this.cy.png=this.bak.png,this.cy.jpg=this.bak.jpg,this.cy.jpeg=this.bak.jpeg,this.bak={}},this.zoomed=()=>{const e=this.cy.pan(),t=this.cy.zoom();this.viewport.tx=e.x,this.viewport.ty=e.y,this.viewport.zoom=t;for(const n of this.layers)n.setViewport(e.x,e.y,t)},this.renderPerEdge=Vf,this.renderPerNode=Gf,this.cy=e,this.adapter={cy:this.cy,insert:(e,t,n)=>this.insert(e,t,n),move:(e,t)=>this.move(e,t),inVisibleBounds:e=>{const t=this.viewport,n=e=>{const n=e*t.zoom+t.tx;return n>=0&&n<=t.width},r=e=>{const n=e*t.zoom+t.ty;return n>=0&&n<=t.height};return function(e){return null!=e.x}(e)?n(e.x)&&r(e.y):n(e.x1)&&r(e.y1)||n(e.x2)&&r(e.y1)||n(e.x2)&&r(e.y2)||n(e.x1)&&r(e.y2)||n((e.x1+e.x2)/2)&&r((e.y1+e.y2)/2)}};const t=e.container(),n=new Df(this.adapter,t.querySelector('[data-id="layer2-node"]'));this.nodeLayer=n;const r=new Lf(this.adapter,t.querySelector('[data-id="layer1-drag"]'));this.dragLayer=r;const i=new Rf(this.adapter,t.querySelector('[data-id="layer0-selectbox"]'));this.selectBoxLayer=i,n.root.style.zIndex="",r.root.style.zIndex="",i.root.style.zIndex="",n.root.insertAdjacentElement("afterend",r.root),r.root.insertAdjacentElement("afterend",i.root),e.on("viewport",this.zoomed),e.on("resize",this.resize),e.on("destroy",this.destroy),this.bak={png:e.png,jpg:e.jpg,jpeg:e.jpeg},e.png=this.png.bind(this),e.jpg=this.jpg.bind(this),e.jpeg=this.jpeg.bind(this),this.viewport={width:this.cy.width(),height:this.cy.height(),tx:this.cy.pan().x,ty:this.cy.pan().y,zoom:this.cy.zoom()}}move(e,t){const n=this.layers,r=n.indexOf(e),i=Math.max(Math.min(r+t,n.length,0));i!==r&&(r>=n.length-1?this.root.appendChild(e.root):this.root.insertBefore(e.root,n[i].root))}get document(){return this.cy.container().ownerDocument}get root(){return this.nodeLayer.node.parentElement}get layers(){return Array.from(this.root.children).map(e=>e.__cy_layer).filter(e=>null!=e)}getLayers(){return this.layers}init(e){return e.resize(this.viewport.width,this.viewport.height),e.setViewport(this.viewport.tx,this.viewport.ty,this.viewport.zoom),e}update(){this.zoomed();for(const e of this.layers)e instanceof Sf&&e.draw()}createLayer(e,t){switch(e){case"svg":return this.init(new Af(this.adapter,this.document,t));case"html":return this.init(new Pf(this.adapter,this.document,t));case"canvas":return this.init(new Sf(this.adapter,this.document,t));case"html-static":return this.init(new If(this.adapter,this.document,t));case"svg-static":return this.init(new Nf(this.adapter,this.document,t));case"canvas-static":return this.init(new kf(this.adapter,this.document,t))}}append(e,t){const n=this.createLayer(e,t);return this.root.appendChild(n.root),n}insert(e,t,n,r){const i=this.createLayer(n,r);return t.root.insertAdjacentElement("before"===e?"beforebegin":"afterend",i.root),i}getLast(){var e;const t=this.layers;return null!==(e=t[t.length-1])&&void 0!==e?e:null}getFirst(){var e;return null!==(e=this.layers[0])&&void 0!==e?e:null}hasCustomLayer(){return this.layers.some(e=>!(e instanceof Of))}toCanvas(e){const t=this.layers;if(t.some(e=>!e.supportsRender)&&!e.ignoreUnsupportedLayers)throw new $f("some layer doesn't support exporting, use {ignoreUnsupportedLayers: true} option to ignore");const n=t.indexOf(this.nodeLayer),r=t.indexOf(this.dragLayer),i=t.indexOf(this.selectBoxLayer);if((n!==r-1||r!==i-1)&&!e.ignoreUnsupportedLayerOrder)throw new $f("cytoscape layers are not in order, use {ignoreUnsupportedLayerOrder: true} option to ignore");const o=t.slice(0,n).reverse().filter(e=>e.supportsRender()&&e!==this.dragLayer&&e!==this.selectBoxLayer),a=t.slice(n+1).filter(e=>e.supportsRender()&&e!==this.dragLayer&&e!==this.selectBoxLayer),s=this.cy.renderer(),l=s.drawElements;s.drawElements=function(e,t){for(const t of o)t.renderInto(e);l.call(this,e,t);for(const t of a)t.renderInto(e)};const u=s.bufferCanvasImage(e);return s.drawElements=l,u}png(e){return this.hasCustomLayer()?Xf(null!=e?e:{},this.toCanvas(null!=e?e:{}),"image/png"):this.bak.png.call(this.cy,e)}jpg(e){if(!this.hasCustomLayer())return this.bak.jpg.call(this.cy,e);const t={bg:"#fff",...null!=e?e:{}};return Xf(t,this.toCanvas(t),"image/png")}jpeg(e){return this.hasCustomLayer()?this.jpg(e):this.bak.jpeg.call(this.cy,e)}}function jf(e=this){if(!e.container())throw new Error("layers plugin does not work in headless environments");const t=e.scratch("_layers");if(t)return t;const n=new Uf(e);return e.scratch("_layers",n),n}function Hf(e,t,n,r,i,o){const a=n-e,s=r-t;let l=i-e,u=o-t,c=l*a+u*s,h=0;c<=0?h=0:(l=a-l,u=s-u,c=l*a+u*s,h=c<=0?0:c*c/(a*a+s*s));const d=l*l+u*u-h;return d<0?0:d}function Wf(e,t,n,r){return(e-n)*(e-n)+(t-r)*(t-r)}function qf(e,t,n,r,i){return Wf(e,t,n,r)<i*i}function Kf(e){const t=Math.min(e.x1,e.x2),n=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),i=Math.max(e.y1,e.y2);return{x:t,y:r,x2:n,y2:i,width:n-t,height:i-r}}void 0!==window.cytoscape&&function(e){e("core","layers",jf)}(window.cytoscape);class Zf{constructor(e,t,n,r){this.x1=e,this.y1=t,this.x2=n,this.y2=r}equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2}draw(e){e.moveTo(this.x1,this.y1),e.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(e){return new Zf(e.x1,e.y1,e.x2,e.y2)}cuts(e,t){if(this.y1===this.y2)return!1;if(t<this.y1&&t<=this.y2||t>this.y1&&t>=this.y2)return!1;if(e>this.x1&&e>=this.x2)return!1;if(e<this.x1&&e<=this.x2)return!0;return e<=this.x1+(t-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(e,t){return Hf(this.x1,this.y1,this.x2,this.y2,e,t)}ptClose(e,t,n){if(this.x1<this.x2){if(e<this.x1-n||e>this.x2+n)return!1}else if(e<this.x2-n||e>this.x1+n)return!1;if(this.y1<this.y2){if(t<this.y1-n||t>this.y2+n)return!1}else if(t<this.y2-n||t>this.y1+n)return!1;return!0}}var Qf,Jf;!function(e){e[e.POINT=1]="POINT",e[e.PARALLEL=2]="PARALLEL",e[e.COINCIDENT=3]="COINCIDENT",e[e.NONE=4]="NONE"}(Qf||(Qf={}));class ep{constructor(e,t=0,n=0){this.state=e,this.x=t,this.y=n}}function tp(e,t){const n=(t.x2-t.x1)*(e.y1-t.y1)-(t.y2-t.y1)*(e.x1-t.x1),r=(e.x2-e.x1)*(e.y1-t.y1)-(e.y2-e.y1)*(e.x1-t.x1),i=(t.y2-t.y1)*(e.x2-e.x1)-(t.x2-t.x1)*(e.y2-e.y1);if(i){const t=n/i,o=r/i;return 0<=t&&t<=1&&0<=o&&o<=1?new ep(Qf.POINT,e.x1+t*(e.x2-e.x1),e.y1+t*(e.y2-e.y1)):new ep(Qf.NONE)}return new ep(0===n||0===r?Qf.COINCIDENT:Qf.PARALLEL)}function np(e,t){const n=(t.x2-t.x1)*(e.y1-t.y1)-(t.y2-t.y1)*(e.x1-t.x1),r=(e.x2-e.x1)*(e.y1-t.y1)-(e.y2-e.y1)*(e.x1-t.x1),i=(t.y2-t.y1)*(e.x2-e.x1)-(t.x2-t.x1)*(e.y2-e.y1);if(i){const e=n/i,t=r/i;if(0<=e&&e<=1&&0<=t&&t<=1)return e}return Number.POSITIVE_INFINITY}function rp(e,t,n){const r=new Set;return e.width<=0?(r.add(Jf.LEFT),r.add(Jf.RIGHT)):t<e.x?r.add(Jf.LEFT):t>e.x+e.width&&r.add(Jf.RIGHT),e.height<=0?(r.add(Jf.TOP),r.add(Jf.BOTTOM)):n<e.y?r.add(Jf.TOP):n>e.y+e.height&&r.add(Jf.BOTTOM),r}function ip(e,t){let n=t.x1,r=t.y1;const i=t.x2,o=t.y2,a=Array.from(rp(e,i,o));if(0===a.length)return!0;let s=rp(e,n,r);for(;0!==s.size;){for(const e of a)if(s.has(e))return!1;if(s.has(Jf.RIGHT)||s.has(Jf.LEFT)){let t=e.x;s.has(Jf.RIGHT)&&(t+=e.width),r+=(t-n)*(o-r)/(i-n),n=t}else{let t=e.y;s.has(Jf.BOTTOM)&&(t+=e.height),n+=(t-r)*(i-n)/(o-r),r=t}s=rp(e,n,r)}return!0}function op(e,t){let n=Number.POSITIVE_INFINITY,r=0;function i(e,i,o,a){let s=np(t,new Zf(e,i,o,a));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(e.x,e.y,e.x2,e.y),i(e.x,e.y,e.x,e.y2),r>1?n:(i(e.x,e.y2,e.x2,e.y2),r>1?n:(i(e.x2,e.y,e.x2,e.y2),0===r?-1:n))}function ap(e,t){let n=0;const r=tp(e,new Zf(t.x,t.y,t.x2,t.y));n+=r.state===Qf.POINT?1:0;const i=tp(e,new Zf(t.x,t.y,t.x,t.y2));n+=i.state===Qf.POINT?1:0;const o=tp(e,new Zf(t.x,t.y2,t.x2,t.y2));n+=o.state===Qf.POINT?1:0;const a=tp(e,new Zf(t.x2,t.y,t.x2,t.y2));return n+=a.state===Qf.POINT?1:0,{top:r,left:i,bottom:o,right:a,count:n}}!function(e){e[e.LEFT=0]="LEFT",e[e.TOP=1]="TOP",e[e.RIGHT=2]="RIGHT",e[e.BOTTOM=3]="BOTTOM"}(Jf||(Jf={}));class sp{constructor(e,t,n,r){this.x=e,this.y=t,this.width=n,this.height=r}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(e){return new sp(e.x,e.y,e.width,e.height)}equals(e){return this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height}clone(){return new sp(this.x,this.y,this.width,this.height)}add(e){const t=Math.min(this.x,e.x),n=Math.min(this.y,e.y),r=Math.max(this.x2,e.x+e.width),i=Math.max(this.y2,e.y+e.height);this.x=t,this.y=n,this.width=r-t,this.height=i-n}addPoint(e){const t=Math.min(this.x,e.x),n=Math.min(this.y,e.y),r=Math.max(this.x2,e.x),i=Math.max(this.y2,e.y);this.x=t,this.y=n,this.width=r-t,this.height=i-n}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(e){e.rect(this.x,this.y,this.width,this.height)}containsPt(e,t){return e>=this.x&&e<=this.x2&&t>=this.y&&t<=this.y2}get area(){return this.width*this.height}intersects(e){return!(this.area<=0||e.width<=0||e.height<=0)&&(e.x+e.width>this.x&&e.y+e.height>this.y&&e.x<this.x2&&e.y<this.y2)}distSquare(e,t){if(this.containsPt(e,t))return 0;const n=rp(this,e,t);return n.has(Jf.TOP)?n.has(Jf.LEFT)?Wf(e,t,this.x,this.y):n.has(Jf.RIGHT)?Wf(e,t,this.x2,this.y):(this.y-t)*(this.y-t):n.has(Jf.BOTTOM)?n.has(Jf.LEFT)?Wf(e,t,this.x,this.y2):n.has(Jf.RIGHT)?Wf(e,t,this.x2,this.y2):(t-this.y2)*(t-this.y2):n.has(Jf.LEFT)?(this.x-e)*(this.x-e):n.has(Jf.RIGHT)?(e-this.x2)*(e-this.x2):0}}class lp{constructor(e,t,n){this.cx=e,this.cy=t,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(e){return new lp(e.cx,e.cy,e.radius)}containsPt(e,t){return Wf(this.cx,this.cy,e,t)<this.radius*this.radius}distSquare(e,t){const n=Wf(this.cx,this.cy,e,t);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(e){e.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class up{constructor(e,t=0,n=0,r=0,i=0,o=10,a=10,s=new Float32Array(Math.max(0,o*a)).fill(0)){this.pixelGroup=e,this.i=t,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=a,this.area=s}createSub(e,t){return new up(this.pixelGroup,e.x,e.y,t.x,t.y,e.width,e.height)}static fromPixelRegion(e,t){return new up(t,0,0,e.x,e.y,Math.ceil(e.width/t),Math.ceil(e.height/t))}copy(e,t){return new up(this.pixelGroup,this.scaleX(t.x),this.scaleY(t.y),t.x,t.y,e.width,e.height,e.area)}boundX(e){return e<this.i?this.i:e>=this.width?this.width-1:e}boundY(e){return e<this.j?this.j:e>=this.height?this.height-1:e}scaleX(e){return this.boundX(Math.floor((e-this.pixelX)/this.pixelGroup))}scaleY(e){return this.boundY(Math.floor((e-this.pixelY)/this.pixelGroup))}scale(e){const t=this.scaleX(e.x),n=this.scaleY(e.y),r=this.boundX(Math.ceil((e.x+e.width-this.pixelX)/this.pixelGroup)),i=this.boundY(Math.ceil((e.y+e.height-this.pixelY)/this.pixelGroup));return new sp(t,n,r-t,i-n)}invertScaleX(e){return Math.round(e*this.pixelGroup+this.pixelX)}invertScaleY(e){return Math.round(e*this.pixelGroup+this.pixelY)}addPadding(e,t){const n=Math.ceil(t/this.pixelGroup),r=this.boundX(e.x-n),i=this.boundY(e.y-n),o=this.boundX(e.x2+n),a=this.boundY(e.y2+n);return new sp(r,i,o-r,a-i)}get(e,t){return e<0||t<0||e>=this.width||t>=this.height?Number.NaN:this.area[e+t*this.width]}inc(e,t,n){e<0||t<0||e>=this.width||t>=this.height||(this.area[e+t*this.width]+=n)}set(e,t,n){e<0||t<0||e>=this.width||t>=this.height||(this.area[e+t*this.width]=n)}incArea(e,t){if(e.width<=0||e.height<=0||0===t)return;const n=this.width,r=e.width,i=Math.max(0,e.i),o=Math.max(0,e.j),a=Math.min(e.i+e.width,n),s=Math.min(e.j+e.height,this.height);if(!(s<=0||a<=0||i>=n||s>=this.height))for(let l=o;l<s;l++){const o=(l-e.j)*r,s=l*n;for(let n=i;n<a;n++){const r=e.area[n-e.i+o];0!==r&&(this.area[n+s]+=t*r)}}}fill(e){this.area.fill(e)}fillArea(e,t){const n=e.x+e.y*this.width;for(let r=0;r<e.height;r++){const i=n+r*this.width;this.area.fill(t,i,i+e.width)}}fillHorizontalLine(e,t,n,r){const i=e+t*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(e,t,n,r){const i=e+t*this.width;for(let e=0;e<n;e++)this.area[i+e*this.width]=r}clear(){this.area.fill(0)}toString(){let e="";for(let t=0;t<this.height;t++){const n=t*this.width;for(let t=0;t<this.width;t++){e+=this.area[n+t].toFixed(1).padStart(6),e+=" "}e+="\n"}return e}draw(e,t=!0){if(this.width<=0||this.height<=0)return;e.save(),t&&e.translate(this.pixelX,this.pixelY);const n=this.area.reduce((e,t)=>Math.min(e,t),Number.POSITIVE_INFINITY),r=this.area.reduce((e,t)=>Math.max(e,t),Number.NEGATIVE_INFINITY),i=e=>(e-n)/(r-n);e.scale(this.pixelGroup,this.pixelGroup);for(let t=0;t<this.width;t++)for(let n=0;n<this.height;n++){const r=this.area[t+n*this.width];e.fillStyle=`rgba(0, 0, 0, ${i(r)})`,e.fillRect(t,n,1,1)}e.restore()}drawThreshold(e,t,n=!0){if(!(this.width<=0||this.height<=0)){e.save(),n&&e.translate(this.pixelX,this.pixelY),e.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];e.fillStyle=i>t?"black":"white",e.fillRect(n,r,1,1)}e.restore()}}}function cp(e,t){const n=e=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t});return Array.isArray(e)?e.map(n):n(e)}function hp(e,t,n){return dp(Object.assign(Kf(e),{distSquare:(t,n)=>Hf(e.x1,e.y1,e.x2,e.y2,t,n)}),t,n)}function dp(e,t,n){const r=cp(e,n),i=t.scale(r),o=t.createSub(i,r);return function(e,t,n,r){const i=n*n;for(let o=0;o<e.height;o++)for(let a=0;a<e.width;a++){const s=r(t.invertScaleX(e.i+a),t.invertScaleY(e.j+o));if(0!==s){if(s<i){const t=n-Math.sqrt(s);e.set(a,o,t*t)}}else e.set(a,o,i)}}(o,t,n,(t,n)=>e.distSquare(t,n)),o}function fp(e,t,n){const r=t.scale(e),i=t.addPadding(r,n),o=t.createSub(i,{x:e.x-n,y:e.y-n}),a=r.x-i.x,s=r.y-i.y,l=i.x2-r.x2,u=i.y2-r.y2,c=i.width-a-l,h=i.height-s-u,d=n*n;o.fillArea({x:a,y:s,width:c+1,height:h+1},d);const f=[0],p=Math.max(s,a,l,u);{const i=t.invertScaleX(r.x+r.width/2);for(let o=1;o<p;o++){const a=t.invertScaleY(r.y-o),s=e.distSquare(i,a);if(!(s<d))break;{const e=n-Math.sqrt(s);f.push(e*e)}}}const g=[],v=Math.max(a,l),y=Math.max(s,l);for(let i=1;i<v;i++){const o=t.invertScaleX(r.x-i),a=[];for(let i=1;i<y;i++){const s=t.invertScaleY(r.y-i),l=e.distSquare(o,s);if(l<d){const e=n-Math.sqrt(l);a.push(e*e)}else a.push(0)}g.push(a)}for(let e=1;e<Math.min(s,f.length);e++){const t=f[e];o.fillHorizontalLine(a,s-e,c+1,t)}for(let e=1;e<Math.min(u,f.length);e++){const t=f[e];o.fillHorizontalLine(a,s+h+e,c+1,t)}for(let e=1;e<Math.min(a,f.length);e++){const t=f[e];o.fillVerticalLine(a-e,s,h+1,t)}for(let e=1;e<Math.min(u,f.length);e++){const t=f[e];o.fillVerticalLine(a+c+e,s,h+1,t)}for(let e=1;e<a;e++){const t=g[e-1],n=a-e;for(let e=1;e<s;e++)o.set(n,s-e,t[e-1]);for(let e=1;e<u;e++)o.set(n,s+h+e,t[e-1])}for(let e=1;e<l;e++){const t=g[e-1],n=a+c+e;for(let e=1;e<s;e++)o.set(n,s-e,t[e-1]);for(let e=1;e<u;e++)o.set(n,s+h+e,t[e-1])}return o}function pp(e,t){return{x:e,y:t}}function gp(e,t,n,r){if(0===e.length)return[];const i=function(e){if(e.length<2)return e;let t=0,n=0;return e.forEach(e=>{t+=e.cx,n+=e.cy}),t/=e.length,n/=e.length,e.map(e=>{const r=t-e.cx,i=n-e.cy;return[e,r*r+i*i]}).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}(e);return i.map((e,o)=>{const a=i.slice(0,o);return function(e,t,n,r,i){const o=pp(t.cx,t.cy),a=function(e,t,n){let r=Number.POSITIVE_INFINITY;return t.reduce((t,i)=>{const o=Wf(e.x,e.y,i.cx,i.cy);if(o>r)return t;const a=new Zf(e.x,e.y,i.cx,i.cy),s=function(e,t){return e.reduce((e,n)=>ip(n,t)&&function(e,t){function n(e,n,r,i){let o=np(t,new Zf(e,n,r,i));return o=Math.abs(o-.5),o>=0&&o<=1?1:0}let r=n(e.x,e.y,e.x2,e.y);return r+=n(e.x,e.y,e.x,e.y2),r>1||(r+=n(e.x,e.y2,e.x2,e.y2),r>1||(r+=n(e.x2,e.y,e.x2,e.y2),r>0))}(n,t)?e+1:e,0)}(n,a);return o*(s+1)*(s+1)<r&&(t=i,r=o*(s+1)*(s+1)),t},null)}(o,n,e);if(null==a)return[];const s=function(e,t,n,r){const i=[],o=[];o.push(e);let a=!0;for(let e=0;e<n&&a;e++)for(a=!1;!a&&o.length>0;){const e=o.pop(),n=mp(t,e),s=n?ap(e,n):null;if(!n||!s||2!==s.count){a||i.push(e);continue}let l=r,u=bp(n,l,s,!0),c=yp(u,o)||yp(u,i),h=vp(u,t);for(;!c&&h&&l>=1;)l/=1.5,u=bp(n,l,s,!0),c=yp(u,o)||yp(u,i),h=vp(u,t);if(!u||c||h||(o.push(new Zf(e.x1,e.y1,u.x,u.y)),o.push(new Zf(u.x,u.y,e.x2,e.y2)),a=!0),a)continue;l=r,u=bp(n,l,s,!1);let d=yp(u,o)||yp(u,i);for(h=vp(u,t);!d&&h&&l>=1;)l/=1.5,u=bp(n,l,s,!1),d=yp(u,o)||yp(u,i),h=vp(u,t);u&&!d&&(o.push(new Zf(e.x1,e.y1,u.x,u.y)),o.push(new Zf(u.x,u.y,e.x2,e.y2)),a=!0),a||i.push(e)}for(;o.length>0;)i.push(o.pop());return i}(new Zf(o.x,o.y,a.cx,a.cy),e,r,i);return function(e,t){const n=[];for(;e.length>0;){const r=e.pop();if(0===e.length){n.push(r);break}const i=e.pop(),o=new Zf(r.x1,r.y1,i.x2,i.y2);mp(t,o)?(n.push(r),e.push(i)):e.push(o)}return n}(s,e)}(t,e,a,n,r)}).flat()}function vp(e,t){return t.some(t=>t.containsPt(e.x,e.y))}function yp(e,t){return t.some(t=>!!qf(t.x1,t.y1,e.x,e.y,.001)||!!qf(t.x2,t.y2,e.x,e.y,.001))}function mp(e,t){let n=Number.POSITIVE_INFINITY,r=null;for(const i of e){if(!ip(i,t))continue;const e=op(i,t);e>=0&&e<n&&(r=i,n=e)}return r}function bp(e,t,n,r){const i=n.top,o=n.left,a=n.bottom,s=n.right;if(r){if(o.state===Qf.POINT){if(i.state===Qf.POINT)return pp(e.x-t,e.y-t);if(a.state===Qf.POINT)return pp(e.x-t,e.y2+t);const n=e.width*e.height;return e.width*(.5*(o.y-e.y+(s.y-e.y)))<.5*n?o.y>s.y?pp(e.x-t,e.y-t):pp(e.x2+t,e.y-t):o.y<s.y?pp(e.x-t,e.y2+t):pp(e.x2+t,e.y2+t)}if(s.state===Qf.POINT){if(i.state===Qf.POINT)return pp(e.x2+t,e.y-t);if(a.state===Qf.POINT)return pp(e.x2+t,e.y2+t)}const n=e.height*e.width;return e.height*(.5*(i.x-e.x+(a.x-e.x)))<.5*n?i.x>a.x?pp(e.x-t,e.y-t):pp(e.x-t,e.y2+t):i.x<a.x?pp(e.x2+t,e.y-t):pp(e.x2+t,e.y2+t)}if(o.state===Qf.POINT){if(i.state===Qf.POINT)return pp(e.x2+t,e.y2+t);if(a.state===Qf.POINT)return pp(e.x2+t,e.y-t);const n=e.height*e.width;return e.width*(.5*(o.y-e.y+(s.y-e.y)))<.5*n?o.y>s.y?pp(e.x2+t,e.y2+t):pp(e.x-t,e.y2+t):o.y<s.y?pp(e.x2+t,e.y-t):pp(e.x-t,e.y-t)}if(s.state===Qf.POINT){if(i.state===Qf.POINT)return pp(e.x-t,e.y2+t);if(a.state===Qf.POINT)return pp(e.x-t,e.y-t)}const l=e.height*e.width;return e.height*(.5*(i.x-e.x+(a.x-e.x)))<.5*l?i.x>a.x?pp(e.x2+t,e.y2+t):pp(e.x2+t,e.y-t):i.x<a.x?pp(e.x-t,e.y2+t):pp(e.x-t,e.y-t)}function xp(e,t,n,r){if(!(e.closed?n<e.length:n<e.length-1))return!1;const i=e.get(t),o=e.get(n+1);for(let a=t+1;a<=n;a++){const t=e.get(a);if(Hf(i.x,i.y,o.x,o.y,t.x,t.y)>r)return!1}return!0}function wp(e,t){switch(e){case-2:return(((3-t)*t-3)*t+1)/6;case-1:return((3*t-6)*t*t+4)/6;case 0:return(((-3*t+3)*t+3)*t+1)/6;case 1:return t*t*t/6;default:throw new Error("unknown error")}}class Ep{constructor(e=[],t=!0){this.points=e,this.closed=t}get(e){const t=e,n=this.points.length;return e<0?this.closed?this.get(e+n):this.points[0]:e>=n?this.closed?this.get(e-n):this.points[n-1]:this.points[t]}get length(){return this.points.length}toString(e=1/0){const t=this.points;if(0===t.length)return"";const n="function"==typeof e?e:function(e){if(!Number.isFinite(e))return e=>e;if(0===e)return Math.round;const t=Math.pow(10,e);return e=>Math.round(e*t)/t}(e);let r="M";for(const e of t)r+=`${n(e.x)},${n(e.y)} L`;return r=r.slice(0,-1),this.closed&&(r+=" Z"),r}draw(e){const t=this.points;if(0!==t.length){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const n of t)e.lineTo(n.x,n.y);this.closed&&e.closePath()}}sample(e){return function(e=8){return t=>{let n=e,r=t.length;if(n>1)for(r=Math.floor(t.length/n);r<3&&n>1;)n-=1,r=Math.floor(t.length/n);const i=[];for(let e=0,o=0;o<r;o++,e+=n)i.push(t.get(e));return new Ep(i)}}(e)(this)}simplify(e){return function(e=0){return t=>{if(e<0||t.length<3)return t;const n=[];let r=0;const i=e*e;for(;r<t.length;){let e=r+1;for(;xp(t,r,e,i);)e++;n.push(t.get(r)),r=e}return new Ep(n)}}(e)(this)}bSplines(e){return function(e=6){function t(e,t,n){let r=0,i=0;for(let o=-2;o<=1;o++){const a=e.get(t+o),s=wp(o,n);r+=s*a.x,i+=s*a.y}return{x:r,y:i}}return n=>{if(n.length<3)return n;const r=[],i=n.closed,o=n.length+3-1+(i?0:2);r.push(t(n,2-(i?0:2),0));for(let a=2-(i?0:2);a<o;a++)for(let i=1;i<=e;i++)r.push(t(n,a,i/e));return new Ep(r)}}(e)(this)}apply(e){return e(this)}containsElements(e){const t=function(e){if(0===e.length)return null;const t=e[0],n=new sp(t.x,t.y,0,0);for(const t of e)n.addPoint(t);return n}(this.points);return!!t&&e.every(e=>t.containsPt(e.cx,e.cy)&&this.withinArea(e.cx,e.cy))}withinArea(e,t){if(0===this.length)return!1;let n=0;const r=this.points[0],i=new Zf(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(e,t)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(e,t)&&n++,n%2==1}}class Tp{constructor(e=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=e}add(e){this.set.add(`${e.x}x${e.y}`),this.arr[this.count++]=e}contains(e){return this.set.has(`${e.x}x${e.y}`)}isFirst(e){if(0===this.count)return!1;const t=this.arr[0];return null!=t&&t.x===e.x&&t.y===e.y}path(){return new Ep(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(e){return this.arr[e]}get length(){return this.count}}function Cp(e,t){const n=2*(Math.floor(e.width)+Math.floor(e.height)),r=new Tp(n);function i(n,r,i,o){const a=e.get(n,r);return Number.isNaN(a)?Number.NaN:a>t?i+o:i}function o(e,t){let n=0;return n=i(e,t,n,1),n=i(e+1,t,n,2),n=i(e,t+1,n,4),n=i(e+1,t+1,n,8),Number.isNaN(n)?-1:n}let a=1;function s(t,n){let i=t,s=n,l=e.invertScaleX(i),u=e.invertScaleY(s);for(let t=0;t<e.width*e.height;t++){const t={x:l,y:u};if(r.contains(t)){if(r.isFirst(t))return!0}else r.add(t);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:a=2;break;case 12:case 14:case 4:a=3;break;case 6:a=0===a?3:2;break;case 1:case 13:case 5:a=0;break;case 9:a=2===a?0:1;break;case 10:case 8:case 11:a=1;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(a){case 0:s--,u-=e.pixelGroup;break;case 1:s++,u+=e.pixelGroup;break;case 3:i--,l-=e.pixelGroup;break;case 2:i++,l+=e.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<e.width;n++)for(let i=0;i<e.height;i++){if(e.get(n,i)<=t)continue;const a=o(n,i);if(!(a<0||15===a)&&s(n,i))return r.path()}return null}const Mp={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};var Ap;!function(e){e[e.MEMBERS=0]="MEMBERS",e[e.NON_MEMBERS=1]="NON_MEMBERS",e[e.EDGES=2]="EDGES"}(Ap||(Ap={}));function Np(e,t,n,r,i,o={}){const a=Object.assign({},Mp,o);let s=a.threshold,l=a.memberInfluenceFactor,u=a.edgeInfluenceFactor,c=a.nonMemberInfluenceFactor;const h=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),d=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1);for(let o=0;o<a.maxMarchingIterations;o++){if(e.clear(),0!==l){const n=l/h;for(const r of t)e.incArea(r,n)}if(0!==u){const t=u/d;for(const r of n)e.incArea(r,t)}if(0!==c){const t=c/h;for(const n of r)e.incArea(n,t)}const f=Cp(e,s);if(f&&i(f))return f;if(s*=.95,o<=.5*a.maxMarchingIterations)l*=1.2,u*=1.2;else{if(!(0!==c&&r.length>0))break;c*=.8}}return new Ep([])}var _p,Sp,kp,Pp,Ip,Op,Dp,Lp,Rp=n(858);function Bp(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function zp(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function Fp(e){return Math.round(100*e)/100}"function"==typeof SuppressedError&&SuppressedError;const Vp="bubbleSets",Gp=["ellipse","diamond","diamond","pentagon","diamond","hexagon","heptagon","octagon","star"],Yp=new Set(Gp.concat(Gp.map(e=>`round-${e}`)));function Xp(e){return`${Fp(e.shape.width)}x${Fp(e.shape.height)}x${e.isCircle}`}function $p(e){return`${Fp(e.x1)}x${Fp(e.y1)}x${Fp(e.x2)}x${Fp(e.y2)}`}function Up(e,t){return e?new lp(t.x1+t.w/2,t.y1+t.h/2,Math.max(t.w,t.h)/2):new sp(t.x1,t.y1,t.w,t.h)}class jp{constructor(e,t,n,r,i,o={}){this.node=t,this.nodes=n,this.edges=r,this.avoidNodes=i,_p.set(this,{x:0,y:0,width:0,height:0}),Sp.set(this,new up(4,0,0,0,0,0,0)),kp.set(this,void 0),Pp.set(this,new Map),Ip.set(this,void 0),Op.set(this,void 0),Dp.set(this,void 0),Lp.set(this,void 0),this.update=(e=!1)=>{const t=this.nodes.union(this.edges).boundingBox(Bp(this,kp,"f"));let n=!1;const r=Math.max(Bp(this,kp,"f").edgeR1,Bp(this,kp,"f").nodeR1)+Bp(this,kp,"f").morphBuffer,i={x:t.x1-r,y:t.y1-r,width:t.w+2*r,height:t.h+2*r};e||Bp(this,_p,"f").x!==i.x||Bp(this,_p,"f").y!==i.y?(n=!0,zp(this,Sp,up.fromPixelRegion(i,Bp(this,kp,"f").pixelGroup),"f")):Bp(this,_p,"f").width===i.width&&Bp(this,_p,"f").height===i.height||zp(this,Sp,up.fromPixelRegion(i,Bp(this,kp,"f").pixelGroup),"f"),zp(this,_p,i,"f");const o=Bp(this,Sp,"f"),a=new Map;n||this.nodes.forEach(e=>{var t;const n=null!==(t=e.scratch(Vp))&&void 0!==t?t:null;n&&n.area&&a.set(Xp(n),n.area)});let s=!1;const l=e=>{var t;const r=e.boundingBox(Bp(this,kp,"f"));let i=null!==(t=e.scratch(Vp))&&void 0!==t?t:null;const l=(u=e.style("shape"),Yp.has(u));var u;if(i&&!n&&i.area&&i.isCircle===l&&i.shape.width===r.w&&i.shape.height===r.h)i.shape.x===r.x1&&i.shape.y===r.y1||(s=!0,i.shape=Up(l,r),i.area=Bp(this,Sp,"f").copy(i.area,{x:r.x1-Bp(this,kp,"f").nodeR1,y:r.y1-Bp(this,kp,"f").nodeR1}));else{s=!0,i={isCircle:l,shape:Up(l,r)};const t=Xp(i),n=a.get(t);null!=n?i.area=Bp(this,Sp,"f").copy(n,{x:r.x1-Bp(this,kp,"f").nodeR1,y:r.y1-Bp(this,kp,"f").nodeR1}):(i.area=i.isCircle?dp(i.shape,o,Bp(this,kp,"f").nodeR1):fp(i.shape,o,Bp(this,kp,"f").nodeR1),a.set(t,i.area)),e.scratch(Vp,i)}return i},u=this.nodes.map(l),c=this.avoidNodes.map(l),h=new Map;n||(Bp(this,Pp,"f").forEach((e,t)=>h.set(t,e)),this.edges.forEach(e=>{var t;const n=null!==(t=e.scratch(Vp))&&void 0!==t?t:null;n&&n.lines&&n.lines.forEach((e,t)=>{const r=n.areas[t];r&&a.set($p(e),r)})}));const d=e=>{const t=$p(e),n=h.get(t);if(null!=n)return n;const r=hp(e,Bp(this,Sp,"f"),Bp(this,kp,"f").edgeR1);return h.set(t,r),r},f=[];this.edges.forEach(e=>{var t,r;const i=(null!==(t=e.segmentPoints())&&void 0!==t?t:[e.sourceEndpoint(),e.targetEndpoint()]).map(e=>({...e}));if(0===i.length)return;const o=i.slice(1).map((e,t)=>{const n=i[t];return Zf.from({x1:n.x,y1:n.y,x2:e.x,y2:e.y})});let a=null!==(r=e.scratch(Vp))&&void 0!==r?r:null;a&&!n&&function(e,t){return e.length===t.length&&e.every((e,n)=>$p(e)===$p(t[n]))}(a.lines,o)||(a={lines:o,areas:o.map(d)},e.scratch(Vp,a)),f.push(...a.areas)});const p=u.map(e=>e.shape);if(Bp(this,kp,"f").virtualEdges)if(s){const e=c.map(e=>e.shape),t=gp(p,e,Bp(this,kp,"f").maxRoutingIterations,Bp(this,kp,"f").morphBuffer);Bp(this,Pp,"f").clear(),t.forEach(e=>{const t=d(e),n=$p(e);Bp(this,Pp,"f").set(n,t),f.push(t)})}else Bp(this,Pp,"f").forEach(e=>f.push(e));const g=u.filter(e=>null!=e.area).map(e=>e.area),v=c.filter(e=>null!=e.area).map(e=>e.area),y=Np(o,g,f,v,e=>e.containsElements(p),Bp(this,kp,"f"));this.node.setAttribute("d",y.sample(8).simplify(0).bSplines().simplify(0).toString(2))},zp(this,Lp,e,"f"),zp(this,kp,{...Mp,style:{stroke:"black",fill:"black",fillOpacity:"0.25"},className:"",throttle:100,virtualEdges:!1,interactive:!1,includeLabels:!1,includeMainLabels:!1,includeOverlays:!1,includeSourceLabels:!1,includeTargetLabels:!1,...o},"f"),Object.assign(this.node.style,Bp(this,kp,"f").style),Bp(this,kp,"f").className&&this.node.classList.add(Bp(this,kp,"f").className),Bp(this,kp,"f").interactive&&this.node.addEventListener("dblclick",()=>{this.nodes.select()}),zp(this,Ip,Rp(()=>{this.update()},Bp(this,kp,"f").throttle),"f"),zp(this,Op,e=>{e.target.on("add",Bp(this,Op,"f")),e.target.on("remove",Bp(this,Dp,"f")),Bp(this,Ip,"f").call(this)},"f"),zp(this,Dp,e=>{e.target.off("add",void 0,Bp(this,Op,"f")),e.target.off("remove",void 0,Bp(this,Dp,"f")),Bp(this,Ip,"f").call(this)},"f"),n.on("position",Bp(this,Ip,"f")),n.on("add",Bp(this,Op,"f")),n.on("remove",Bp(this,Dp,"f")),i.on("position",Bp(this,Ip,"f")),i.on("add",Bp(this,Op,"f")),i.on("remove",Bp(this,Dp,"f")),r.on("move position",Bp(this,Ip,"f")),r.on("add",Bp(this,Op,"f")),r.on("remove",Bp(this,Dp,"f"))}remove(){for(const e of[this.nodes,this.edges,this.avoidNodes])e.off("move position",void 0,Bp(this,Ip,"f")),e.off("add",void 0,Bp(this,Op,"f")),e.off("remove",void 0,Bp(this,Dp,"f")),e.forEach(e=>{e.scratch(Vp,{})});return this.node.remove(),Bp(this,Lp,"f").remove(this)}}var Hp,Wp,qp,Kp;_p=new WeakMap,Sp=new WeakMap,kp=new WeakMap,Pp=new WeakMap,Ip=new WeakMap,Op=new WeakMap,Dp=new WeakMap,Lp=new WeakMap;class Zp{constructor(e,t={}){var n;Hp.set(this,[]),Wp.set(this,{remove:e=>{const t=Bp(this,Hp,"f").indexOf(e);return!(t<0)&&(Bp(this,Hp,"f").splice(t,1),!0)}}),qp.set(this,void 0),Kp.set(this,void 0),zp(this,qp,e,"f"),zp(this,Kp,t,"f"),this.layer=null!==(n=t.layer)&&void 0!==n?n:jf(e).nodeLayer.insertBefore("svg")}destroy(){for(const e of Bp(this,Hp,"f"))e.remove();this.layer.remove()}addPath(e,t=Bp(this,qp,"f").collection(),n=Bp(this,qp,"f").collection(),r={}){const i=this.layer.node.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");this.layer.node.appendChild(i);const o=new jp(Bp(this,Wp,"f"),i,e,null!=t?t:Bp(this,qp,"f").collection(),null!=n?n:Bp(this,qp,"f").collection(),{...Bp(this,Kp,"f"),...r});return Bp(this,Hp,"f").push(o),o.update(),o}getPaths(){return Bp(this,Hp,"f").slice()}removePath(e){return!(Bp(this,Hp,"f").indexOf(e)<0)&&e.remove()}update(e=!1){Bp(this,Hp,"f").forEach(t=>t.update(e))}}function Qp(e={}){return new Zp(this,e)}function Jp(e){e("core","bubbleSets",Qp)}Hp=new WeakMap,Wp=new WeakMap,qp=new WeakMap,Kp=new WeakMap,"function"==typeof window.cytoscape&&Jp(window.cytoscape);var eg=[33,102,172],tg=[247,247,247],ng=[178,24,43],rg=[254,237,222],ig=[166,54,3];function og(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function ag(e){return"#"+e.map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,"0")).join("")}var sg=e=>Number.isFinite(e)?Math.min(1,Math.max(0,e)):0;function lg(e,t){if(!(t>0))return ag(tg);let n=Math.max(-1,Math.min(1,e/t));return ag(n>=0?og(tg,ng,n):og(tg,eg,-n))}function ug(e,t){return ag(t>0?og(rg,ig,sg(e/t)):rg)}function cg(e,t,n=20,r=44){return t>0?Math.round(n+(r-n)*sg(Math.abs(e)/t)):n}var hg=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function dg(e){if(e<hg.length)return hg[e];let t=e-hg.length;return function(e,t,n){let r=t=>(t+e/30)%12,i=t*Math.min(n,1-n),o=e=>n-i*Math.max(-1,Math.min(r(e)-3,Math.min(9-r(e),1)));return ag([255*o(0),255*o(8),255*o(4)])}((137.508*t+20)%360,.55,t%2?.42:.58)}function fg(e,t){let n=Math.round(255*sg(t)).toString(16).padStart(2,"0");return/^#[0-9a-f]{6}$/i.test(e)?e+n:e}var pg=class extends Error{constructor(e){super(e),this.name="ContextError"}};function gg(e,t){let n=function(e,t){if(!e.expression)throw new pg("No expression data was provided in NetworkData.expression.");if(!e.expression.conditions.includes(t.condition))throw new pg(`Unknown condition "${t.condition}". Available: ${e.expression.conditions.join(", ")}`);if(!Number.isFinite(t.threshold))throw new pg("threshold must be a finite number.");if(void 0!==t.maxP&&!(t.maxP>=0&&t.maxP<=1))throw new pg("maxP must be a number between 0 and 1.");if(void 0!==t.maxP&&!Object.keys(e.expression.pValues).length)throw new pg("maxP needs p-values in NetworkData.expression.pValues.");if("abundance"===e.expression.metric&&void 0!==t.direction&&"both"!==t.direction)throw new pg(`direction "${t.direction}" only applies to log2fc data; abundance is always filtered as value >= threshold.`);return{condition:t.condition,threshold:t.threshold,direction:t.direction??"both",maxP:t.maxP??1/0,unmeasured:t.unmeasured??"inactive",keepLinkers:t.keepLinkers??!1,minActiveNeighbors:Math.max(1,t.minActiveNeighbors??2),minEdgeWeight:t.minEdgeWeight??0,hideIsolated:t.hideIsolated??!1,display:t.display??"hide"}}(e,t),r=e.expression,i=new Map,o=0;for(let t of e.nodes){let e=r.values[t.id]?.[n.condition];"number"==typeof e&&Number.isFinite(e)&&(i.set(t.id,e),o=Math.max(o,"log2fc"===r.metric?Math.abs(e):e))}let a=e=>"abundance"===r.metric||"up"===n.direction?e>=n.threshold:"down"===n.direction?e<=-n.threshold:Math.abs(e)>=n.threshold,s=new Set,l=e=>{if(n.maxP===1/0)return!0;let t=r.pValues[e]?.[n.condition];return"number"==typeof t&&t<=n.maxP};for(let[e,t]of i)a(t)&&l(e)&&s.add(e);let u=e.edges.filter(e=>e.weight>=n.minEdgeWeight),c=new Set;if(n.keepLinkers){let e=new Map,t=(t,r)=>{if(s.has(t)||!s.has(r)||"keep"===n.unmeasured&&!i.has(t))return;let o=e.get(t);o||e.set(t,o=new Set),o.add(r)};for(let e of u)t(e.source,e.target),t(e.target,e.source);for(let[t,r]of e)r.size>=n.minActiveNeighbors&&c.add(t)}let h=new Set;if("keep"===n.unmeasured)for(let t of e.nodes)i.has(t.id)||h.add(t.id);let d=new Set([...s,...c,...h]),f=new Set;for(let e of u)d.has(e.source)&&d.has(e.target)&&(s.has(e.source)||s.has(e.target)||h.has(e.source)&&h.has(e.target))&&f.add(e.index);if(n.hideIsolated){let t=new Set;for(let n of e.edges)f.has(n.index)&&(t.add(n.source),t.add(n.target));d=new Set([...d].filter(e=>t.has(e)));for(let e of[...s])d.has(e)||s.delete(e);for(let e of[...c])d.has(e)||c.delete(e);for(let e of[...h])d.has(e)||h.delete(e)}return{options:n,metric:r.metric,values:i,scaleMax:o,active:s,linkers:c,unmeasured:h,visibleNodes:d,visibleEdges:f,stats:{totalNodes:e.nodes.length,totalEdges:e.edges.length,activeNodes:s.size,linkerNodes:c.size,unmeasuredNodes:h.size,visibleNodes:d.size,visibleEdges:f.size}}}function vg(e){return e?[e.condition,e.threshold,e.direction,e.keepLinkers,e.minActiveNeighbors,e.unmeasured,e.minEdgeWeight,e.hideIsolated,e.display,e.maxP].join("|"):"none"}var yg=[{key:"compartments"}],mg=(e,t)=>`${e}:${t}`;function bg(e,t={}){let n=t.features?.length?t.features:yg,r=t.maxFraction??.8,i=t.maxTerms??400,o=e.nodes.length,a=new Map;for(let t of e.nodes){let e=new Map;for(let r of n){let n=r.weight??1;if("compartments"===r.key)for(let r of t.compartments)xg(e,mg("compartments",r.id),n*r.fraction);else{let i=t.annotations[r.key]??[];for(let t of i)xg(e,mg(r.key,t),n/i.length)}}e.size&&a.set(t.id,e)}let s=wg(a.values()),l=new Map;for(let[e,t]of a){let n=[...t].filter(([e])=>(s.get(e)??0)/o<=r);l.set(e,new Map(n.length?n:t))}let u=wg(l.values()),c=[...u.keys()].sort((e,t)=>u.get(t)-u.get(e)||e.localeCompare(t)).slice(0,i),h=new Set(c),d=new Map;for(let[e,t]of l){let n=new Map([...t].filter(([e])=>h.has(e)));n.size&&d.set(e,n)}let f=wg(d.values()),p=new Map;for(let[e,t]of d){let n=new Map,r=0;for(let[e,i]of t){let t=i*Math.log(1+o/f.get(e));n.set(e,t),r+=t}if(!(r<=0)){for(let[e,t]of n)n.set(e,t/r);p.set(e,n)}}let g=function(e,t){let n=e.length,r=new Map;if(0===n)return{coords:r,stress:0};if(1===n)return{coords:r.set(e[0],[0,0]),stress:0};let i=new Map(e.map((e,t)=>[e,t])),o=new Float64Array(n),a=Array.from({length:n},()=>new Float64Array(n));for(let e of t.values()){let t=[...e].filter(([e])=>i.has(e)).map(([e,t])=>[i.get(e),t]);for(let[e,n]of t)o[e]+=n;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=Math.min(t[e][1],t[n][1]);a[t[e][0]][t[n][0]]+=r,a[t[n][0]][t[e][0]]+=r}}let s=Array.from({length:n},()=>new Float64Array(n)),l=Array.from({length:n},()=>new Float64Array(n));for(let e=0;e<n;e++)for(let t=0;t<n;t++){if(e===t)continue;let n=o[e]+o[t]-a[e][t],r=1-(n>0?a[e][t]/n:0);s[e][t]=r,l[e][t]=r*r}let u=l.map(e=>e.reduce((e,t)=>e+t,0)/n),c=u.reduce((e,t)=>e+t,0)/n,h=l.map((e,t)=>Float64Array.from(e,(e,n)=>-.5*(e-u[t]-u[n]+c))),d=[];for(let e=0;e<2;e++){let{vector:t,value:r}=Mg(h,d,Array.from({length:n},(t,n)=>Math.sin(12.9898*n+4.1414*e)+1.1));d.push(t.map(e=>e*Math.sqrt(Math.max(r,0))))}let f=e.map((e,t)=>[d[0][t],d[1][t]]);Tg(f)<1e-9&&(f=e.map((e,t)=>[Math.cos(2*Math.PI*t/n),Math.sin(2*Math.PI*t/n)]));let p=n>=3?function(e,t,n){let r=t.length,i=0,o=0;for(let n=0;n<r;n++)for(let a=n+1;a<r;a++){let r=Math.hypot(t[n][0]-t[a][0],t[n][1]-t[a][1]);i+=e[n][a]*r,o+=r*r}let a=o>0?i/o:1;for(let e of t)e[0]*=a,e[1]*=a;let s=Cg(e,t);for(let i=0;i<n;i++){let n=t.map(()=>[0,0]);for(let i=0;i<r;i++){let o=0,a=0,s=0;for(let n=0;n<r;n++){if(i===n)continue;let r=Math.hypot(t[i][0]-t[n][0],t[i][1]-t[n][1]),l=r>1e-12?-e[i][n]/r:0;o+=l*t[n][0],a+=l*t[n][1],s-=l}n[i]=[(s*t[i][0]+o)/r,(s*t[i][1]+a)/r]}for(let e=0;e<r;e++)t[e]=n[e];let i=Cg(e,t);if(s-i<1e-7){s=i;break}s=i}return s}(s,f,Eg):0,g=Tg(f);return e.forEach((e,t)=>r.set(e,g<1e-9?[0,0]:[f[t][0]/g,f[t][1]/g])),{coords:r,stress:p}}(c,d);return{vectors:p,terms:c,coords:g.coords,mapStress:g.stress}}function xg(e,t,n){e.set(t,(e.get(t)??0)+n)}function wg(e){let t=new Map;for(let n of e)for(let e of n.keys())t.set(e,(t.get(e)??0)+1);return t}var Eg=100;function Tg(e){let t=0;for(let[n,r]of e)t+=n*n+r*r;return Math.sqrt(t/Math.max(1,e.length))}function Cg(e,t){let n=0,r=0;for(let i=0;i<t.length;i++)for(let o=i+1;o<t.length;o++){let a=Math.hypot(t[i][0]-t[o][0],t[i][1]-t[o][1]);n+=(e[i][o]-a)**2,r+=e[i][o]**2}return r>0?Math.sqrt(n/r):0}function Mg(e,t,n,r=300){let i=e.length,o=(n,r)=>{let o=Array(i).fill(0);for(let t=0;t<i;t++){let a=r*n[t],s=e[t];for(let e=0;e<i;e++)a+=s[e]*n[e];o[t]=a}for(let e of t)o=Ag(o,e);return o},a=(e,r,a)=>{let s=n;for(let e of t)s=Ag(s,e);let l=0;for(let t=0;t<r;t++){let t=o(s,e);if(l=Math.hypot(...t),l<1e-12)return{v:s,norm:0,zero:!0};let n=t.map(e=>e/l),r=0;for(let e=0;e<i;e++)r+=(n[e]-s[e])**2;if(s=n,a>0&&r<a*a)break}return{v:s,norm:l,zero:!1}},s=a(0,r,0);if(s.zero)return{vector:s.v,value:0};if(o(s.v,0).reduce((e,t,n)=>e+t*s.v[n],0)>=.999*s.norm)return{vector:s.v,value:s.norm};let l=a(1.05*s.norm+1e-9,Math.max(r,2e3),1e-10),u=o(l.v,0).reduce((e,t,n)=>e+t*l.v[n],0);return{vector:l.v,value:u}}function Ag(e,t){let n=0,r=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i],r+=t[i]*t[i];return r<1e-12?e:e.map((e,i)=>e-n/r*t[i])}function*Ng(e,t,n,r={}){let i=e.length,o=r.idealEdgeLength??75,a=r.strength??.3,s=r.iterations??300,l="emergent"===(r.centres??"fixed"),u=r.freezeAfter??1/0,c=function(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(r.seed??1),h=(r.scale??1)*o*Math.sqrt(Math.max(i,4))*.55,d=e.map(()=>[0,0]),f=new Map(e.map((e,t)=>[e.id,t])),p=n.terms.filter(e=>n.coords.has(e)),g=new Map(p.map(e=>[e,[n.coords.get(e)[0]*h,n.coords.get(e)[1]*h]])),v=t=>{let n=e[t].vec;if(!n)return null;let r=0,i=0,o=0;for(let[e,t]of n){let n=g.get(e);n&&(r+=t*n[0],i+=t*n[1],o+=t)}return o>0?[r/o,i/o]:null},y=e.map(()=>[]);for(let e of t){let t=f.get(e.source),n=f.get(e.target);void 0!==t&&void 0!==n&&t!==n&&(y[t].push(n),y[n].push(t))}let m=Array(i).fill(!1);for(let e=0;e<i;e++){let t=v(e);t&&(d[e]=[t[0]+(c()-.5)*o,t[1]+(c()-.5)*o],m[e]=!0)}for(let e=0;e<3;e++)for(let e=0;e<i;e++){if(m[e])continue;let t=y[e].filter(e=>m[e]);t.length&&(d[e]=[t.reduce((e,t)=>e+d[t][0],0)/t.length+(c()-.5)*o,t.reduce((e,t)=>e+d[t][1],0)/t.length+(c()-.5)*o],m[e]=!0)}for(let e=0;e<i;e++)m[e]||(d[e]=[(c()-.5)*h,(c()-.5)*h]);for(let t=0;t<i;t++){let n=e[t].start;n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&(d[t]=[n.x,n.y])}let b=new Map;l&&e.forEach((e,t)=>{if(e.vec)for(let[n,r]of e.vec)g.has(n)&&(b.has(n)||b.set(n,[]),b.get(n).push([t,r]))});let x=_g([...g.values()]),w=3*o,E=t.map(e=>({a:f.get(e.source),b:f.get(e.target),e})).filter(e=>void 0!==e.a&&void 0!==e.b&&e.a!==e.b),T=new Float64Array(i),C=new Float64Array(i);for(let t=0;t<s;t++){let n=1-t/s,r=Math.max(.5*o*n,.5);T.fill(0),C.fill(0);let f=new Map,p=(e,t)=>73856093*e+19349663*t;for(let e=0;e<i;e++){let t=p(Math.floor(d[e][0]/w),Math.floor(d[e][1]/w)),n=f.get(t);n?n.push(e):f.set(t,[e])}for(let t=0;t<i;t++){let n=Math.floor(d[t][0]/w),r=Math.floor(d[t][1]/w);for(let i=-1;i<=1;i++)for(let a=-1;a<=1;a++){let s=f.get(p(n+i,r+a));if(s)for(let n of s){if(n<=t)continue;let r=d[t][0]-d[n][0],i=d[t][1]-d[n][1],a=Math.hypot(r,i);if(a<1e-6&&(r=c()-.5,i=c()-.5,a=Math.hypot(r,i)),a>w)continue;let s=e[t].radius+e[n].radius+8,l=.5*o*o/a;a<s&&(l+=2*(s-a)),T[t]+=r/a*l,C[t]+=i/a*l,T[n]-=r/a*l,C[n]-=i/a*l}}}for(let{a:e,b:t,e:n}of E){let r=d[t][0]-d[e][0],i=d[t][1]-d[e][1],o=Math.hypot(r,i)||1e-6,a=n.elasticity*(o-n.length);T[e]+=r/o*a,C[e]+=i/o*a,T[t]-=r/o*a,C[t]-=i/o*a}for(let e=0;e<i;e++){let t=v(e);t&&a>0&&(T[e]+=a*(t[0]-d[e][0]),C[e]+=a*(t[1]-d[e][1])),T[e]-=.01*d[e][0],C[e]-=.01*d[e][1]}for(let e=0;e<i;e++){let t=Math.hypot(T[e],C[e]),n=t>r?r/t:1;d[e][0]+=T[e]*n,d[e][1]+=C[e]*n}if(l&&t<u){for(let[e,t]of b){let n=0,r=0,i=0;for(let[e,o]of t)n+=o*d[e][0],r+=o*d[e][1],i+=o;let o=g.get(e);o[0]+=.25*(n/i-o[0]),o[1]+=.25*(r/i-o[1])}Sg(g,x,.15*h)}yield t}let M=new Map;e.forEach((e,t)=>M.set(e.id,{x:d[t][0],y:d[t][1]}));let A=new Map;for(let[e,t]of g)A.set(e,{x:t[0],y:t[1]});return{positions:M,termCentres:A}}function _g(e){if(!e.length)return 0;let t=e.reduce((e,t)=>e+t[0],0)/e.length,n=e.reduce((e,t)=>e+t[1],0)/e.length;return Math.sqrt(e.reduce((e,r)=>e+(r[0]-t)**2+(r[1]-n)**2,0)/e.length)}function Sg(e,t,n){let r=[...e.values()];if(r.length<2||t<=0)return;for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let i=r[e][0]-r[t][0],o=r[e][1]-r[t][1],a=Math.hypot(i,o)||1e-6;if(a<n){let s=(n-a)/2;r[e][0]+=i/a*s,r[e][1]+=o/a*s,r[t][0]-=i/a*s,r[t][1]-=o/a*s}}let i=_g(r);if(i<1e-9)return;let o=r.reduce((e,t)=>e+t[0],0)/r.length,a=r.reduce((e,t)=>e+t[1],0)/r.length,s=t/i;for(let e of r)e[0]=o+(e[0]-o)*s,e[1]=a+(e[1]-a)*s}var kg=["cmp:","og:","hub:","solo:","clone:","edge:","oge:","hubedge:","identity:"],Pg=e=>`cmp:${e}`,Ig=e=>`og:${e}`,Og=e=>`hub:${e}`,Dg=(e,t)=>`clone:${e}@${t}`,Lg=(e,t="")=>`edge:${e}${t}`,Rg=e=>`solo:${e}`;function Bg(e){let t=e;if(t.length>16){let e=t.slice(0,15),n=t.slice(15).reduce((e,t)=>e+t.pct,0);t=[...e,{color:"#cccccc",pct:n}]}let n={};for(let e=0;e<16;e++)n[`pc${e+1}`]=t[e]?.color??"#ffffff",n[`pf${e+1}`]=t[e]?.pct??0;return n}function zg(e,t){let n=new Map;for(let r of t){let t=e.nodeIndex.get(r)?.species??"";n.set(t,(n.get(t)??0)+1)}let r=t.length||1;return[...n].sort((e,t)=>t[1]-e[1]).map(([t,n])=>({color:e.species.get(t)?.color??"#cccccc",pct:n/r*100}))}function Fg(e,t,n={}){if("orthogroup-nodes"===t)return function(e,t={}){let n="merged"===t.style,r=[],i=new Map,o=new Map,a=(t,n,a,s)=>{for(let e of a)o.set(e,t),i.set(e,[t]);r.push({group:"nodes",data:{id:t,label:n,members:a,nMembers:a.length,size:22+7*Math.sqrt(a.length),color:"#6b6f76",...Bg(zg(e,a))},classes:s})};for(let t of e.orthogroups)a(Ig(t.id),t.label,t.members,"ogroup pie");for(let t of e.nodes)o.has(t.id)||a(Rg(t.id),t.label,[t.id],"ogroup pie singleton");let s=new Map;for(let t of e.edges){let r=e.nodeIndex.get(t.source),i=e.nodeIndex.get(t.target),a=o.get(r.id),l=o.get(i.id),u=n?"":r.species===i.species?r.species??"":"",[c,h]=a<=l?[a,l]:[l,a],d=`${c}|${h}|${u}`,f=s.get(d)??{source:c,target:h,species:u,indices:[],weight:0};f.indices.push(t.index),f.weight+=t.weight??1,s.set(d,f)}let l=0;for(let t of s.values()){let i=t.indices.length;r.push({group:"edges",data:{id:"oge:"+l++,source:t.source,target:t.target,species:t.species,indices:t.indices,count:i,weight:t.weight/i,color:e.species.get(t.species)?.color??"#7a7f85",width:1.5+1.2*Math.log2(1+i)},classes:n?"interaction ogedge ogmerged":"interaction ogedge"})}return{elements:r,proteinNodes:i}}(e,n);let r=[],i=new Map,o=t=>e.compartments.get(t).color,a="orthogroups"===t,s=new Set;for(let n of e.nodes)if(!a)if("pie"===t)s.add(n.primary);else for(let e of n.compartments)s.add(e.id);let l=new Set;if("bubbles"===t)for(let t of e.nodes)for(let e of t.compartments)l.add(e.id);if(a)for(let t of e.orthogroups)r.push({group:"nodes",data:{id:Ig(t.id),label:t.label,orthogroup:t.id,color:"#6b6f76"},classes:"compartment orthogroup",selectable:!1});for(let n of"bubbles"===t?l:s){let i=e.compartments.get(n);"bubbles"===t?r.push({group:"nodes",data:{id:Og(n),compartment:n,color:i.color},classes:"hub",selectable:!1,grabbable:!1}):r.push({group:"nodes",data:{id:Pg(n),label:i.label,compartment:n,color:i.color},classes:"compartment",selectable:!1})}let u=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let n of e.nodes){let i=n.species?e.species.get(n.species):void 0,s={protein:n.id,label:n.label,primary:n.primary};if(i&&(s.species=i.id,s.speciesColor=i.color),"clones"===t)for(let e of n.compartments){let t=Dg(n.id,e.id);r.push({group:"nodes",data:{...s,id:t,parent:Pg(e.id),compartment:e.id,color:o(e.id),fraction:e.fraction},classes:e.id===n.primary?"protein clone primary":"protein clone"}),u(n.id,t)}else{let i={...s,id:n.id,color:o(n.primary)};if("pie"===t||a){let t=e.orthogroupOf.get(n.id);a?t&&(i.parent=Ig(t),i.orthogroup=t):i.parent=Pg(n.primary),Object.assign(i,Bg(n.compartments.map(e=>({color:o(e.id),pct:100*e.fraction}))))}if(r.push({group:"nodes",data:i,classes:"pie"===t||a?"protein pie":"protein"}),u(n.id,n.id),"bubbles"===t)for(let e of n.compartments)r.push({group:"edges",data:{id:`hubedge:${n.id}:${e.id}`,source:Og(e.id),target:n.id,protein:n.id,compartment:e.id},classes:"hubedge",selectable:!1})}}if("clones"===t)for(let t of e.nodes){let[e,...n]=t.compartments;for(let i of n)r.push({group:"edges",data:{id:`identity:${t.id}:${i.id}`,source:Dg(t.id,e.id),target:Dg(t.id,i.id),protein:t.id},classes:"identity",selectable:!1})}for(let n of e.edges){let i=e.nodeIndex.get(n.source),o=e.nodeIndex.get(n.target),a={index:n.index,weight:n.weight,layer:n.layer,sourceProtein:i.id,targetProtein:o.id};if("clones"!==t){r.push({group:"edges",data:{...a,id:Lg(n.index),source:i.id,target:o.id},classes:"interaction"});continue}let s=new Set(o.compartments.map(e=>e.id)),l=i.compartments.map(e=>e.id).filter(e=>s.has(e)),u=l.length?l.map(e=>[e,e]):[[i.primary,o.primary]];for(let[e,t]of u)r.push({group:"edges",data:{...a,id:Lg(n.index,`:${e}:${t}`),source:Dg(i.id,e),target:Dg(o.id,t)},classes:l.length?"interaction":"interaction cross"})}return{elements:r,proteinNodes:i}}function Vg(e){let t=new Float64Array(e+1);for(let n=2;n<=e;n++)t[n]=t[n-1]+Math.log(n);return t}function Gg(e,t,n,r,i){if(e<=0)return 1;let o=Math.min(t,n);if(e>o||r<=0)return 0;let a=i??Vg(r),s=(e,t)=>a[e]-a[t]-a[e-t],l=s(r,t),u=0;for(let i=e;i<=o;i++)t-i>r-n||(u+=Math.exp(s(n,i)+s(r-n,t-i)-l));return Math.min(1,u)}function Yg(e,t,n,r=2){let i=e.filter(e=>n(e).length>0),o=new Set(i),a=[...new Set(t)].filter(e=>o.has(e)),s=i.length,l=a.length;if(!s||!l)return[];let u=new Map;for(let e of i)for(let t of new Set(n(e)))u.set(t,(u.get(t)??0)+1);let c=new Map;for(let e of a)for(let t of new Set(n(e)))c.set(t,(c.get(t)??0)+1);let h=Vg(s),d=[];for(let[e,t]of c){if(t<r)continue;let n=u.get(e);d.push({value:e,inSet:t,setSize:l,inUniverse:n,universeSize:s,fold:t/l/(n/s),pValue:Gg(t,l,n,s,h),qValue:1})}let f=function(e){let t=e.map((e,t)=>[e,t]).sort((e,t)=>e[0]-t[0]),n=Array(e.length),r=1;for(let e=t.length-1;e>=0;e--)r=Math.min(r,t[e][0]*t.length/(e+1)),n[t[e][1]]=Math.min(1,r);return n}(d.map(e=>e.pValue));return d.forEach((e,t)=>e.qValue=f[t]),d.sort((e,t)=>e.pValue-t.pValue||t.fold-e.fold||e.value.localeCompare(t.value))}var Xg=(e,t,n)=>e<t?e*n+t:t*n+e;function $g(e,t=2){let n=new Map;for(let t of e)for(let e of t)n.set(e,(n.get(e)??0)+1);let r=0;for(let e of n.values())e>=t&&r++;return r}function Ug(e,t,n,r){let i=e.map(([e,t])=>[e,t]),o=new Set(i.map(([e,n])=>Xg(e,n,t)));for(let e=0;e<n;e++){let e=Math.floor(r()*i.length),n=Math.floor(r()*i.length);if(e===n)continue;let[a,s]=i[e],[l,u]=i[n];if(r()<.5&&([l,u]=[u,l]),a===u||l===s||a===s||l===u)continue;let c=Xg(a,u,t),h=Xg(l,s,t);c===h||o.has(c)||o.has(h)||(o.delete(Xg(a,s,t)),o.delete(Xg(l,u,t)),o.add(c),o.add(h),i[e]=[a,u],i[n]=[l,s])}return o}function jg(e,t,n={}){let r=Object.keys(e).filter(t=>e[t].length>=2),i=Math.max(1,Math.floor(n.permutations??1e3)),o=Math.max(1,n.swapsPerEdge??5),a=function(e){let t=e>>>0||1;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(n.seed??1),s="Paralog self-loops and cross-species interactions are not part of the test; degrees are preserved within each unit.",l=Object.fromEntries(Object.keys(e).map(t=>[t,e[t].length]));if(r.length<2)return{units:r,edgesPerUnit:l,observed:0,expected:0,sd:0,z:0,pValue:1,permutations:0,note:s};let u=Math.max(2,Math.min(r.length,n.minUnits??2)),c=$g(r.map(n=>new Set(e[n].map(([e,n])=>Xg(e,n,t)))),u),h=0,d=0,f=0;for(let n=0;n<i;n++){let n=$g(r.map(n=>Ug(e[n],t,o*e[n].length,a)),u);h+=n,d+=n*n,n>=c&&f++}let p=h/i,g=Math.sqrt(Math.max(0,d/i-p*p));return{units:r,edgesPerUnit:l,observed:c,expected:p,sd:g,z:g>0?(c-p)/g:0,pValue:(1+f)/(1+i),permutations:i,note:s}}var Hg="recorded in all",Wg="recorded in some",qg="recorded in one",Kg="not comparable",Zg="cross-species only",Qg={conserved:"#2a9d8f",partial:"#e9a23b",untestable:"#9aa0a6",cross:"#7a7f85"},Jg=(e,t)=>e<=t?`${e}|${t}`:`${t}|${e}`;function ev(e,t,n=()=>!0,r=()=>!0){let i=new Map;for(let[n,o]of t){let t=e.nodeIndex.get(n)?.species;if(!t||!e.unitOf.has(t)||!r(n))continue;let a=i.get(o)??new Map;a.set(t,(a.get(t)??0)+1),i.set(o,a)}let o=(t,n)=>{let r=i.get(t)??new Map,o=i.get(n)??new Map,a=e=>t===n?(r.get(e)??0)>=2:(r.get(e)??0)>=1&&(o.get(e)??0)>=1;return e.units.filter(e=>e.species.some(a)).map(e=>e.id)},a=new Map;for(let r of e.edges){if(!n(r.index))continue;let i=e.nodeIndex.get(r.source),s=e.nodeIndex.get(r.target),l=t.get(i.id),u=t.get(s.id),c=Jg(l,u),h=a.get(c);if(!h){let[e,t]=l<=u?[l,u]:[u,l];h={a:e,b:t,present:new Set,testable:o(e,t),cross:0,indices:[]},a.set(c,h)}h.indices.push(r.index),i.species&&i.species===s.species?h.present.add(e.unitOf.get(i.species)):h.cross++}return a}function tv(e){return 0===e.present.size?"cross":e.testable.length<2?"untestable":e.present.size>=e.testable.length?"conserved":1===e.present.size?"specific":"partial"}function nv(e){return e.testable.length<2?null:e.present.size/e.testable.length}var rv=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x);function iv(e,t){let n=rv(t.a,t.b,e.a),r=rv(t.a,t.b,e.b),i=rv(e.a,e.b,t.a),o=rv(e.a,e.b,t.b);return n*r<0&&i*o<0}function ov(e){let t=e.map(e=>({x0:Math.min(e.a.x,e.b.x),x1:Math.max(e.a.x,e.b.x),y0:Math.min(e.a.y,e.b.y),y1:Math.max(e.a.y,e.b.y)})),n=0,r=new Set;for(let i=0;i<e.length;i++){let o=e[i],a=t[i];for(let s=i+1;s<e.length;s++){let i=e[s];if(o.u===i.u||o.u===i.v||o.v===i.u||o.v===i.v)continue;let l=t[s];if(a.x1<l.x0||l.x1<a.x0||a.y1<l.y0||l.y1<a.y0||!iv(o,i))continue;if(void 0===o.key||void 0===i.key){n++;continue}if(o.key===i.key)continue;let u=String(o.key)<String(i.key)?`${o.key}|${i.key}`:`${i.key}|${o.key}`;r.has(u)||(r.add(u),n++)}}return n}var av="compartment",sv="__unassigned__";var lv=class extends Error{constructor(e){super(e),this.name="NetworkDataError"}};function uv(){let e={"pie-size":"92%"},t=Array.from({length:16},(e,t)=>{let n=t+1;return{selector:`node.protein.pie[pf${n} > 0], node.ogroup[pf${n} > 0]`,style:{[`pie-${n}-background-color`]:`data(pc${n})`,[`pie-${n}-background-size`]:`data(pf${n})`}}});return[{selector:"node.protein",style:{label:"data(label)","font-size":9,"text-valign":"bottom","text-margin-y":3,"text-wrap":"ellipsis","text-max-width":"70px",width:22,height:22,"background-color":"data(color)","border-width":0,"min-zoomed-font-size":7}},{selector:"node.protein[ctxSize]",style:{width:"data(ctxSize)",height:"data(ctxSize)"}},{selector:"node.protein[ctxColor]",style:{"border-width":5,"border-color":"data(ctxColor)"}},{selector:"node.protein[speciesColor]",style:{"underlay-color":"data(speciesColor)","underlay-opacity":.55,"underlay-padding":4,"underlay-shape":"ellipse"}},{selector:"node.protein.linker",style:{"border-style":"dashed"}},{selector:"node.protein.pie",style:e},{selector:"node.compartment",style:{label:"data(label)","text-valign":"top","text-halign":"center","font-size":14,"font-weight":"bold",color:"#333",shape:"round-rectangle","background-color":"data(color)","background-opacity":.12,"border-width":1.5,"border-color":"data(color)","border-opacity":.8,padding:"18px"}},{selector:"node.compartment.box-off",style:{"background-opacity":0,"border-width":0,label:""}},{selector:"node.orthogroup",style:{"background-opacity":.06,"border-style":"dashed","font-size":11,"font-weight":"normal",padding:"12px"}},{selector:"node.ogroup",style:{...e,label:"data(label)","font-size":9,"text-valign":"bottom","text-margin-y":3,width:"data(size)",height:"data(size)","background-color":"#ffffff","border-width":1,"border-color":"#6b6f76","min-zoomed-font-size":7}},{selector:"node.ogroup.singleton",style:{"border-style":"dotted"}},...t,{selector:"node.ogroup.og-open",style:{...Object.fromEntries(Array.from({length:16},(e,t)=>[`pie-${t+1}-background-size`,0])),shape:"round-rectangle","background-color":"#6b6f76","background-opacity":.07,"border-width":1,"border-style":"dashed","border-color":"#6b6f76","text-valign":"top","text-margin-y":-4,"font-size":11,padding:"14px"}},{selector:"node.ogroup[ctxColor]",style:{"border-width":5,"border-color":"data(ctxColor)"}},{selector:"node.ogroup.linker",style:{"border-style":"dashed"}},{selector:"node.ogroup[?exprMixed]",style:{"border-style":"double","border-width":7}},{selector:"node.hub",style:{width:1,height:1,opacity:0,events:"no",label:""}},{selector:"edge.interaction",style:{width:1.2,"line-color":"#9aa0a6",opacity:.6,"curve-style":"bezier"}},{selector:"edge.interaction.cross",style:{"line-color":"#7a7f85","line-style":"solid",width:1.6}},{selector:"edge.ogedge",style:{"line-color":"data(color)",width:"data(width)",opacity:.85,"curve-style":"bezier"}},{selector:'edge.ogmerged[category = "specific"]',style:{"line-style":"dashed"}},{selector:'edge.ogmerged[category = "untestable"]',style:{"line-style":"dotted"}},{selector:"edge.identity",style:{width:1.2,"line-style":"dashed","line-color":"#c0392b",opacity:.7,"curve-style":"straight"}},{selector:"edge.hubedge",style:{opacity:0,events:"no",width:.1}},{selector:"node.protein.unmeasured, node.ogroup.unmeasured",style:{opacity:.55,"border-width":2,"border-style":"dotted","border-color":"#8a8f96"}},{selector:".ctx-hidden, .ef-off, .ex-off",style:{display:"none"}},{selector:".ctx-dim",style:{opacity:.08,"text-opacity":0}},{selector:"node:selected",style:{"overlay-color":"#000","overlay-opacity":.12}}]}var cv={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:"0"},hv={ArrowRight:[1,0],ArrowLeft:[-1,0],ArrowDown:[0,1],ArrowUp:[0,-1]};function dv(e,t){let n=e.container();if(!n||typeof document>"u")return()=>{};let r={tabindex:n.getAttribute("tabindex"),role:n.getAttribute("role"),label:n.getAttribute("aria-label"),roledescription:n.getAttribute("aria-roledescription")};null===r.tabindex&&n.setAttribute("tabindex","0"),n.setAttribute("role","application"),n.setAttribute("aria-roledescription","network graph"),n.setAttribute("aria-label","Protein interaction network. Arrow keys move between nodes, Enter expands or collapses an orthogroup, D describes the network, Escape clears the selection.");let i=document.createElement("div");i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),Object.assign(i.style,cv),(n.parentElement??document.body).appendChild(i);let o=e=>{i.textContent="",setTimeout(()=>i.textContent=e,20)},a=()=>{let t=e.nodes(":selected").filter(e=>e.hasClass("protein")||e.hasClass("ogroup"));return t.nonempty()?t[0]:null},s=n=>{t.select([n.id()]);let r=e.extent(),i=n.position();r.w>0&&(i.x<r.x1||i.x>r.x2||i.y<r.y1||i.y>r.y2)&&e.center(n);let a=t.info(n.id());o(a?a.summary:n.data("label"))},l=t=>{let n=a(),r=e.nodes().filter(e=>"none"!==e.style("display")&&(e.hasClass("protein")||e.hasClass("ogroup"))&&!e.hasClass("og-open"));if(r.empty())return;if(!n){let t=e.extent(),n=t.w>0?(t.x1+t.x2)/2:r.boundingBox().x1+r.boundingBox().w/2,i=t.w>0?(t.y1+t.y2)/2:r.boundingBox().y1+r.boundingBox().h/2,o=null,a=1/0;return r.forEach(e=>{let t=Math.hypot(e.position().x-n,e.position().y-i);t<a&&(a=t,o=e)}),void(o&&s(o))}let i=n.position(),l=null,u=1/0;r.forEach(e=>{if(e.id()===n.id())return;let r=e.position().x-i.x,o=e.position().y-i.y,a=Math.hypot(r,o);if(0===a)return;let s=(r*t[0]+o*t[1])/a;if(s<.5)return;let c=a*(1+2*(1-s));c<u&&(u=c,l=e)}),l?s(l):o("No further node in that direction.")},u=n=>{if(n.altKey||n.ctrlKey||n.metaKey)return;let r=hv[n.key];if(r)n.preventDefault(),l(r);else if("Enter"===n.key||" "===n.key){let e=a();if(!e)return;n.preventDefault(),t.toggle(e.id()),o(`${e.hasClass("og-open")?"Collapsed":"Expanded"} ${e.data("label")}.`)}else if("Escape"===n.key)t.select([]),o("Selection cleared.");else if("+"===n.key||"="===n.key)e.zoom({level:1.25*e.zoom(),renderedPosition:{x:e.width()/2,y:e.height()/2}});else if("-"===n.key||"_"===n.key)e.zoom({level:e.zoom()/1.25,renderedPosition:{x:e.width()/2,y:e.height()/2}});else if("d"===n.key||"D"===n.key)o(t.describe());else if("i"===n.key||"I"===n.key){let e=a(),n=e?t.info(e.id()):null;o(n?n.summary:"Nothing selected.")}};return n.addEventListener("keydown",u),()=>{n.removeEventListener("keydown",u),i.remove();let e=(e,t)=>null===t?n.removeAttribute(e):n.setAttribute(e,t);e("tabindex",r.tabindex),e("role",r.role),e("aria-label",r.label),e("aria-roledescription",r.roledescription)}}var fv=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),pv=e=>Number.isFinite(e)?Math.round(100*e)/100:0,gv=(e,t,n="#888888")=>{let r=e.style(t);return r&&"undefined"!==r?r:n};var vv=(e,t)=>"dashed"===e?` stroke-dasharray="${pv(4*t)} ${pv(3*t)}"`:"dotted"===e?` stroke-dasharray="${pv(t)} ${pv(2*t)}"`:"";function yv(e,t,n={}){let r=n.padding??40,i=n.fontSize??12,o=n.background??"#ffffff",a=n.labels??!0,s=e.nodes().filter(e=>"none"!==e.style("display")&&!e.hasClass("hub")),l=e.edges().filter(e=>"none"!==e.style("display")&&!e.hasClass("hubedge")&&"none"!==e.source().style("display")&&"none"!==e.target().style("display")),u=1/0,c=1/0,h=-1/0,d=-1/0;s.forEach(e=>{let t=e.boundingBox({includeLabels:a,includeOverlays:!1});((e,t,n,r)=>{u=Math.min(u,e),c=Math.min(c,t),h=Math.max(h,n),d=Math.max(d,r)})(t.x1,t.y1,t.x2,t.y2)}),Number.isFinite(u)||(u=c=0,h=d=100),u-=r,c-=r,h+=r,d+=r;let f=h-u,p=d-c,g=n.legend??!0?t.legend.filter(e=>e.entries.length):[],v=1.5*i,y="";if(g.length){let e=Math.max(...g.flatMap(e=>e.entries.map(e=>e.label.length))),t=Math.max(120,2.6*i+e*i*.58),n=Math.max(1,Math.floor((f-2*r)/t)),o=d+i;for(let e of g)e.title&&(y+=`<text x="${pv(u+r)}" y="${pv(o)}" font-size="${i}" font-weight="600" fill="#444">${fv(e.title)}</text>`,o+=v),e.entries.forEach((a,s)=>{let l=u+r+s%n*t,c=o+Math.floor(s/n)*v;y+="dot"===e.kind?`<circle cx="${pv(l+.45*i)}" cy="${pv(c-.3*i)}" r="${pv(.42*i)}" fill="${fv(a.color)}" stroke="#333" stroke-width="0.5"/>`:`<rect x="${pv(l)}" y="${pv(c-.8*i)}" width="${pv(.9*i)}" height="${pv(.9*i)}" fill="${fv(a.color)}" fill-opacity="0.45" stroke="${fv(a.color)}" stroke-width="1"/>`,y+=`<text x="${pv(l+1.4*i)}" y="${pv(c)}" font-size="${i}" fill="#222">${fv(a.label)}</text>`}),o+=Math.ceil(e.entries.length/n)*v+.4*i;p+=o-d}let m=[];if("transparent"!==o&&m.push(`<rect x="${pv(u)}" y="${pv(c)}" width="${pv(f)}" height="${pv(p)}" fill="${fv(o)}"/>`),s.filter(e=>e.isParent()).forEach(e=>{let t=e.boundingBox({includeLabels:!1,includeOverlays:!1}),n=gv(e,"background-color"),r=e.numericStyle("background-opacity"),o=e.numericStyle("border-width"),s=o>0?` stroke="${fv(gv(e,"border-color"))}" stroke-opacity="${e.numericStyle("border-opacity")}" stroke-width="${pv(o)}"${vv(e.style("border-style"),o)}`:"";m.push(`<rect x="${pv(t.x1)}" y="${pv(t.y1)}" width="${pv(t.w)}" height="${pv(t.h)}" rx="8" fill="${fv(n)}" fill-opacity="${r}"${s}/>`);let l=e.style("label");a&&l&&m.push(`<text x="${pv((t.x1+t.x2)/2)}" y="${pv(t.y1-4)}" text-anchor="middle" font-size="${pv(1.15*i)}" font-weight="bold" fill="#333">${fv(l)}</text>`)}),t.territory){let e=t.territory;m.push(`<image x="${pv(e.x)}" y="${pv(e.y)}" width="${pv(e.width)}" height="${pv(e.height)}" href="${e.dataUrl}" preserveAspectRatio="none"/>`);for(let e of t.territory.labels)m.push(`<text x="${pv(e.x)}" y="${pv(e.y)}" text-anchor="middle" dominant-baseline="middle" font-size="${pv(1.1*i)}" font-weight="600" fill="${fv(e.color)}" fill-opacity="0.9">${fv(e.text)}</text>`)}for(let e of t.bubbles)m.push(`<path d="${e.d}" fill="${fv(e.fill)}" stroke="${fv(e.stroke)}" stroke-width="${fv(e.strokeWidth)}"/>`);let b=new Map;l.forEach(e=>{let n=e.source().position(),r=e.target().position(),i=e.numericStyle("width"),o=e.numericStyle("opacity"),a=gv(e,"line-color","#9aa0a6"),s=[e.source().id(),e.target().id()].sort().join("|"),l=b.get(s)??0;b.set(s,l+1);let u=`fill="none" stroke="${fv(a)}" stroke-width="${pv(i)}" stroke-opacity="${o}"${vv(e.style("line-style"),i)}`,c=t.edgeTitle?.(e),h=(e,t)=>c?`<${e} ${t} ${u}><title>${fv(c)}</title></${e}>`:`<${e} ${t} ${u}/>`;if(e.source().id()===e.target().id()){let e=14+5*l;m.push(h("circle",`cx="${pv(n.x)}" cy="${pv(n.y-e)}" r="${e}"`))}else if(0===l)m.push(h("line",`x1="${pv(n.x)}" y1="${pv(n.y)}" x2="${pv(r.x)}" y2="${pv(r.y)}"`));else{let e=(n.x+r.x)/2,t=(n.y+r.y)/2,i=r.x-n.x,o=r.y-n.y,a=Math.hypot(i,o)||1,s=14*Math.ceil(l/2)*(l%2?1:-1);m.push(h("path",`d="M${pv(n.x)} ${pv(n.y)} Q${pv(e-o/a*s)} ${pv(t+i/a*s)} ${pv(r.x)} ${pv(r.y)}"`))}}),s.filter(e=>!e.isParent()).forEach(e=>{let{x:n,y:r}=e.position(),o=e.numericStyle("width")/2,s=e.numericStyle("opacity"),l=[],u=e.data("speciesColor");u&&l.push(`<circle cx="${pv(n)}" cy="${pv(r)}" r="${pv(o+4)}" fill="${fv(String(u))}" fill-opacity="0.55"/>`),l.push(`<circle cx="${pv(n)}" cy="${pv(r)}" r="${pv(o)}" fill="${fv(gv(e,"background-color"))}"/>`),e.hasClass("pie")&&l.push(function(e,t,n,r){let i=[];for(let t=1;t<=16;t++){let n=Number(e.data(`pf${t}`)),r=e.data(`pc${t}`);n>0&&r&&i.push({color:String(r),frac:n/100})}let o=i.reduce((e,t)=>e+t.frac,0);if(!i.length||o<=0)return"";if(1===i.length)return`<circle cx="${pv(t)}" cy="${pv(n)}" r="${pv(r)}" fill="${fv(i[0].color)}"/>`;let a=-Math.PI/2,s="";for(let e of i){let i=a+e.frac/o*Math.PI*2,l=+(i-a>Math.PI);s+=`<path d="M${pv(t)} ${pv(n)} L${pv(t+r*Math.cos(a))} ${pv(n+r*Math.sin(a))} A${pv(r)} ${pv(r)} 0 ${l} 1 ${pv(t+r*Math.cos(i))} ${pv(n+r*Math.sin(i))} Z" fill="${fv(e.color)}"/>`,a=i}return s}(e,n,r,.92*o));let c=e.numericStyle("border-width");c>0?l.push(`<circle cx="${pv(n)}" cy="${pv(r)}" r="${pv(o-c/2)}" fill="none" stroke="${fv(gv(e,"border-color"))}" stroke-width="${pv(c)}"${vv(e.style("border-style"),c)}/>`):l.push(`<circle cx="${pv(n)}" cy="${pv(r)}" r="${pv(o)}" fill="none" stroke="#333" stroke-opacity="0.35" stroke-width="0.6"/>`);let h=t.nodeTitle?.(e);m.push(`<g opacity="${s}">${h?`<title>${fv(h)}</title>`:""}${l.join("")}</g>`);let d=e.style("label");a&&d&&e.numericStyle("text-opacity")>0&&m.push(`<text x="${pv(n)}" y="${pv(r+o+.9*i)}" text-anchor="middle" font-size="${pv(.75*i)}" fill="#333" opacity="${s}">${fv(d.length>22?d.slice(0,21)+"…":d)}</text>`)}),m.push(y);let x=n.title??"ContextNet network",w=n.description??t.description??"";return{svg:`<svg xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="cn-title${w?" cn-desc":""}" viewBox="${pv(u)} ${pv(c)} ${pv(f)} ${pv(p)}" width="${pv(f)}" height="${pv(p)}" font-family="system-ui, Helvetica, Arial, sans-serif"><title id="cn-title">${fv(x)}</title>`+(w?`<desc id="cn-desc">${fv(w)}</desc>`:"")+m.join("")+"</svg>",width:f,height:p}}var mv=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function bv(e,t,n={}){let r=e.filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(!r.length||!t.length)return null;let i=n.bandwidth&&n.bandwidth>0?n.bandwidth:function(e){let t=e.length;if(t<2)return 60;let n=0,r=0;for(let t of e)n+=t.x,r+=t.y;n/=t,r/=t;let i=0;for(let t of e)i+=(t.x-n)**2+(t.y-r)**2;let o=Math.sqrt(i/(2*t));return Math.max(30,.6*o*t**(-1/6))}(r),o=Math.max(100,n.maxCells??4e4),a=1/0,s=1/0,l=-1/0,u=-1/0;for(let e of r)e.x<a&&(a=e.x),e.x>l&&(l=e.x),e.y<s&&(s=e.y),e.y>u&&(u=e.y);let c=3*i,h=l-a+2*c,d=u-s+2*c,f=Math.max(i*(n.minCellFraction??1/3),Math.sqrt(h*d/o)),p=Math.max(1,Math.ceil(h/f)),g=Math.max(1,Math.ceil(d/f)),v=a-c,y=s-c,m=new Map(t.map((e,t)=>[e,t])),b=t.map(()=>new Float32Array(p*g)),x=Math.ceil(c/f),w=1/(2*i*i),E=new Uint8Array(p*g);for(let e of r){let t=[];for(let[n,r]of e.shares){let e=m.get(n);void 0!==e&&r>0&&t.push([b[e],r])}if(!t.length)continue;let n=Math.floor((e.x-v)/f),r=Math.floor((e.y-y)/f);for(let i=Math.max(0,r-x);i<=Math.min(g-1,r+x);i++){let r=y+(i+.5)*f-e.y;for(let o=Math.max(0,n-x);o<=Math.min(p-1,n+x);o++){let n=v+(o+.5)*f-e.x,a=n*n+r*r;a<1444&&(E[i*p+o]=1);let s=Math.exp(-a*w);if(!(s<.01))for(let[e,n]of t)e[i*p+o]+=n*s}}}let T=new Int16Array(p*g).fill(-1),C=new Float32Array(p*g),M=Array(t.length).fill(0),A=Array(t.length).fill(0),N=Array(t.length).fill(-1),_=Array(t.length).fill(0),S=Array(t.length).fill(-1);for(let e=0;e<p*g;e++){let n=-1,r=.1;for(let i=0;i<t.length;i++){let t=b[i][e];t>r&&(r=t,n=i)}n<0||(T[e]=n,C[e]=mv(.1,.35,r),M[n]++,r>A[n]&&(A[n]=r,N[n]=e),!E[e]&&r>=.35&&r>_[n]&&(_[n]=r,S[n]=e))}let k=[];for(let e=0;e<t.length;e++){if(!M[e])continue;let n=S[e]>=0?S[e]:N[e];k.push({id:t[e],cells:M[e],labelX:v+(n%p+.5)*f,labelY:y+(Math.floor(n/p)+.5)*f})}return{x0:v,y0:y,cell:f,cols:p,rows:g,bandwidth:i,ids:[...t],owner:T,strength:C,regions:k}}function xv(e){let t=/^#?([0-9a-f]{6})/i.exec(e)??/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);if(!t)return[128,128,128];let n=2===t.length?t[1]:t[1]+t[1]+t[2]+t[2]+t[3]+t[3],r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]}function wv(e,t,n){e.width=t.cols,e.height=t.rows;let r=e.getContext("2d"),i=r.createImageData(t.cols,t.rows),o=t.ids.map(e=>xv(n.defs.get(e)?.color??"#888888"));for(let e=0;e<t.owner.length;e++){let r=t.owner[e];r<0||(i.data[4*e]=o[r][0],i.data[4*e+1]=o[r][1],i.data[4*e+2]=o[r][2],i.data[4*e+3]=Math.round(255*n.opacity*t.strength[e]))}r.putImageData(i,0,0)}var Ev=class e{cy;container;canvas;raster;field=null;style=null;frame=0;redraw=()=>this.schedule();static create(t){let n=t.container();if(typeof document>"u"||!n||"function"!=typeof n.insertBefore)return null;let r=document.createElement("canvas");return r.getContext?.("2d")?new e(t,n,r):null}constructor(e,t,n){this.cy=e,this.container=t,this.canvas=n,this.raster=document.createElement("canvas"),Object.assign(n.style,{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"0"}),n.setAttribute("data-contextnet","territories"),t.insertBefore(n,t.firstChild),e.on("viewport resize",this.redraw)}update(e,t){this.field=e,this.style=t,e&&wv(this.raster,e,t),this.schedule()}rasterOf(e,t){if(e===this.field)return this.raster;let n=document.createElement("canvas");return wv(n,e,t),n}snapshot(e){let{style:t}=this,n=e??this.field;if(!n||!t)return null;let r=t.labels?n.regions.flatMap(e=>{let n=t.defs.get(e.id);if(!n)return[];let[r,i,o]=xv(n.color);return[{x:e.labelX,y:e.labelY,text:n.label,color:`rgb(${Math.round(.55*r)}, ${Math.round(.55*i)}, ${Math.round(.55*o)})`}]}):[];return{dataUrl:this.rasterOf(n,t).toDataURL("image/png"),x:n.x0,y:n.y0,width:n.cols*n.cell,height:n.rows*n.cell,labels:r}}destroy(){this.cy.off("viewport resize",this.redraw),this.frame&&"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this.frame),this.canvas.remove()}schedule(){this.frame||("function"==typeof requestAnimationFrame?this.frame=requestAnimationFrame(()=>{this.frame=0,this.draw()}):this.draw())}draw(){let e=typeof window<"u"&&window.devicePixelRatio||1,t=Math.round(this.container.clientWidth*e),n=Math.round(this.container.clientHeight*e);this.canvas.width!==t&&(this.canvas.width=t),this.canvas.height!==n&&(this.canvas.height=n);let r=this.canvas.getContext("2d");if(!r)return;r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,t,n);let{field:i,style:o}=this;if(!i||!o)return;let a=this.cy.zoom(),s=this.cy.pan();if(r.setTransform(e*a,0,0,e*a,e*s.x,e*s.y),r.imageSmoothingEnabled=!0,r.imageSmoothingQuality="high",r.drawImage(this.raster,i.x0,i.y0,i.cols*i.cell,i.rows*i.cell),o.labels){r.setTransform(e,0,0,e,0,0),r.font="600 12px system-ui, sans-serif",r.textAlign="center",r.textBaseline="middle";for(let e of i.regions){let t=o.defs.get(e.id);if(!t)continue;let[n,i,l]=xv(t.color);r.fillStyle=`rgba(${Math.round(.55*n)}, ${Math.round(.55*i)}, ${Math.round(.55*l)}, 0.85)`,r.fillText(t.label,e.labelX*a+s.x,e.labelY*a+s.y)}}}},Tv=".ctx-hidden, .ctx-dim, .ef-off",Cv=".ex-off",Mv="contextnet:";var Av=(e,t)=>e.active.has(t)?"active":e.unmeasured.has(t)?"unmeasured":"linker";function Nv(e){if("function"==typeof e)return`fn:${e.toString()}`;if(void 0===e)return"undefined";if("object"!=typeof e||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Nv).join(",")}]`;let t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${Nv(t[e])}`).join(",")}}`}var _v=class{cy;net;fullNet;shownLayers=null;ctxOptions=null;mode;ctx=null;proteinNodes=new Map;positionCache=new Map;bubblePlugin=null;bubblePaths=[];bubbleKey=null;bubbleMinSpecies=1;bubbleAvoid="auto";hints=null;territoryLayer=null;territoryFrame=0;onNodeMoved=()=>{this.territoryFrame||"function"!=typeof requestAnimationFrame||(this.territoryFrame=requestAnimationFrame(()=>{this.territoryFrame=0,this.destroyed||this.refreshTerritories()}))};edgeView={};destroyed=!1;warnedMapStress=!1;groupOf=new Map;baseProteinNodes=new Map;expanded=new Set;autoExpanded=new Set;memberPos=new Map;zoomOptions=null;zoomFrame=0;onViewport=()=>{this.zoomFrame||"function"!=typeof requestAnimationFrame||(this.zoomFrame=requestAnimationFrame(()=>{this.zoomFrame=0,this.destroyed||this.updateSemanticZoom()}))};bubbleMeta=[];lastField=null;layoutRun=0;constructor(e,t){this.cy=e,this.mode=t.compartmentMode??"pie",!1!==t.applyDefaultStyle&&this.styleEnabled&&this.cy.style().fromJson([...uv(),...t.style??[]]).update(),this.setData(t.data)}get compartmentMode(){return this.mode}get warnings(){return this.net.warnings}get conditions(){return this.net.expression?.conditions??[]}get metric(){return this.net.expression?.metric}get compartments(){return[...this.net.compartments.values()]}get species(){return[...this.net.species.values()]}get orthogroups(){return this.net.orthogroups}get annotationKeys(){return this.net.annotationKeys}get overlayKeys(){return this.net.compartments.size?[av,...this.net.annotationKeys]:this.net.annotationKeys}get bubbleBy(){return this.bubbleKey}getContext(){return this.ctx}getProteinNodeIds(e){return this.proteinNodes.get(e)??[]}stylesheet(){return uv()}on(e,t){let n=(e,n)=>t(n);return this.cy.on(Mv+e,n),()=>this.cy.off(Mv+e,n)}emit(e,t){this.destroyed||this.cy.emit(Mv+e,[t])}setData(e){this.assertAlive(),this.fullNet=function(e){if(!e||!Array.isArray(e.nodes)||!Array.isArray(e.edges))throw new lv('NetworkData requires "nodes" and "edges" arrays.');let t=[],n=new Map,r=0,i=()=>dg(r++),o=(e,t,r)=>{n.has(e)||n.set(e,{id:e,label:t??e,color:r??i()})};for(let t of e.compartments??[]){if(!t||"string"!=typeof t.id||""===t.id)throw new lv("Every compartment needs a non-empty string id.");if(n.has(t.id))throw new lv(`Duplicate compartment id "${t.id}".`);o(t.id,t.label,t.color)}let a=new Map,s=0,l=(e,t,n)=>{a.has(e)||a.set(e,{id:e,label:t??e,color:n??dg(s++)})};for(let t of e.species??[]){if(!t||"string"!=typeof t.id||""===t.id)throw new lv("Every species needs a non-empty string id.");if(a.has(t.id))throw new lv(`Duplicate species id "${t.id}".`);l(t.id,t.label,t.color)}let u=new Set,c=[],h=new Map;for(let n of e.nodes){if(!n||"string"!=typeof n.id||""===n.id)throw new lv("Every node needs a non-empty string id.");if(h.has(n.id))throw new lv(`Duplicate node id "${n.id}".`);let e=kg.find(e=>n.id.startsWith(e));if(e)throw new lv(`Node id "${n.id}" starts with the reserved prefix "${e}"; rename the protein.`);let r=new Map;for(let e of n.compartments??[]){let i="string"==typeof e?e:e?.id,o="string"==typeof e?1:e?.score??1;"string"!=typeof i||""===i?t.push(`Node "${n.id}": ignoring compartment assignment without id.`):!Number.isFinite(o)||o<=0?t.push(`Node "${n.id}": ignoring compartment "${i}" with non-positive score.`):r.set(i,(r.get(i)??0)+o)}0===r.size&&(r.set(sv,1),o(sv,"Unassigned","#bab0ac"));let i=0;for(let e of r.values())i+=e;let a,s=[...r.entries()].map(([e,t])=>(o(e),{id:e,fraction:t/i})).sort((e,t)=>t.fraction-e.fraction);"string"==typeof n.species&&""!==n.species&&(a=n.species,l(a));let d={};for(let[e,r]of Object.entries(n.annotations??{})){let i=[...new Set((Array.isArray(r)?r:[r]).filter(e=>"string"==typeof e&&""!==e))];0===i.length?t.push(`Node "${n.id}": annotation "${e}" has no usable string values.`):(d[e]=i,u.add(e))}let f={id:n.id,label:n.label??n.id,compartments:s,primary:s[0].id,species:a,annotations:d};c.push(f),h.set(f.id,f)}let d=[],f=new Map,p=0,g=[],v=new Set;e.edges.forEach((e,n)=>{if(!e||!h.has(e.source)||!h.has(e.target))return void t.push(`Edge #${n} references an unknown node ("${e?.source}" -> "${e?.target}"); ignored.`);if(e.source===e.target)return void t.push(`Edge #${n}: self-loop on "${e.source}" ignored.`);let r=e.weight??1;Number.isFinite(r)||(t.push(`Edge #${n}: non-finite weight, using 1.`),r=1);let i="string"==typeof e.layer&&""!==e.layer?e.layer:"default",o=(e.source<e.target?`${e.source}\0${e.target}`:`${e.target}\0${e.source}`)+`\0${i}`,a=void 0===e.evidence?[]:(Array.isArray(e.evidence)?e.evidence:[e.evidence]).map(String).filter(Boolean),s={};for(let[t,n]of Object.entries(e.scores??{}))"number"==typeof n&&Number.isFinite(n)&&(s[t]=n);let l=f.get(o);if(l){l.weight=Math.max(l.weight,r);for(let e of a)l.evidence.includes(e)||l.evidence.push(e);for(let[e,t]of Object.entries(s))l.scores[e]=Math.max(l.scores[e]??-1/0,t);return void p++}let u={index:d.length,source:e.source,target:e.target,weight:r,evidence:[...new Set(a)],layer:i,scores:{...s}};v.has(i)||(v.add(i),g.push(i)),f.set(o,u),d.push(u)}),p&&t.push(`${p} duplicate interaction(s) (same pair and layer, either direction) merged; the highest weight is kept.`);let y=[],m=new Map;{let n=new Set(c.map(e=>e.species).filter(e=>!!e)),r=new Set,i=0;for(let o of e.speciesGroups??[]){if(!o||"string"!=typeof o.id||""===o.id||!Array.isArray(o.species))throw new lv('Every species group needs a non-empty string id and a "species" array.');if(r.has(o.id))throw new lv(`Duplicate species group id "${o.id}".`);let e=[];for(let r of new Set(o.species)){if(m.has(r))throw new lv(`Species "${r}" is in several species groups.`);a.has(r)?n.has(r)&&(e.push(r),m.set(r,o.id)):t.push(`Species group "${o.id}": unknown species "${r}" ignored.`)}0===e.length?t.push(`Species group "${o.id}" has no species on any node; ignored.`):(r.add(o.id),y.push({id:o.id,label:o.label??o.id,color:o.color??dg(a.size+i++),species:e}))}for(let[e,t]of a)if(n.has(e)&&!m.has(e)){if(r.has(e))throw new lv(`Species group id "${e}" clashes with a species id.`);m.set(e,e),y.push({id:e,label:t.label,color:t.color,species:[e]})}y.length>3&&t.push(`${y.length} species/groups found: per-species edge analysis supports at most 3. Define "speciesGroups" to merge species into <= 3 groups.`)}let b,x=[],w=new Map,E=new Set;for(let n of e.orthogroups??[]){if(!n||"string"!=typeof n.id||""===n.id||!Array.isArray(n.members))throw new lv('Every orthogroup needs a non-empty string id and a "members" array.');if(E.has(n.id))throw new lv(`Duplicate orthogroup id "${n.id}".`);E.add(n.id);let e=[];for(let r of new Set(n.members))h.has(r)?w.has(r)?t.push(`Protein "${r}" is in several orthogroups; keeping "${w.get(r)}".`):e.push(r):t.push(`Orthogroup "${n.id}": unknown member "${r}" ignored.`);if(e.length<2)continue;for(let t of e)w.set(t,n.id);let r=[...new Set(e.map(e=>h.get(e).species).filter(e=>!!e))];x.push({id:n.id,label:n.label??n.id,members:e,species:r})}if(e.expression){let{metric:n,values:r}=e.expression;if("abundance"!==n&&"log2fc"!==n)throw new lv('expression.metric must be "abundance" or "log2fc".');let i=new Set(e.expression.conditions??[]),o={};for(let[n,a]of Object.entries(r??{})){if(!h.has(n)){t.push(`Expression for unknown protein "${n}" ignored.`);continue}let r={};for(let[t,n]of Object.entries(a??{}))e.expression.conditions||i.add(t),"number"==typeof n&&Number.isFinite(n)&&(r[t]=n);o[n]=r}let a={};for(let[t,n]of Object.entries(e.expression.pValues??{})){if(!h.has(t))continue;let e={};for(let[t,r]of Object.entries(n??{}))"number"==typeof r&&r>=0&&r<=1&&(e[t]=r);a[t]=e}b={metric:n,conditions:[...i],values:o,pValues:a}}return{compartments:n,species:a,units:y,unitOf:m,orthogroups:x,orthogroupOf:w,annotationKeys:[...u].sort(),nodes:c,nodeIndex:h,edges:d,layers:g,expression:b,warnings:t}}(e),this.shownLayers=null,this.net=this.fullNet,this.ctx=null,this.ctxOptions=null,this.expanded.clear(),this.autoExpanded.clear(),this.memberPos.clear(),null!==this.bubbleKey&&!this.net.annotationKeys.includes(this.bubbleKey)&&(this.bubbleKey=null),this.rebuild(),this.emit("data",{proteins:this.net.nodes.length,interactions:this.net.edges.length})}setCompartmentMode(e){this.assertAlive(),e!==this.mode&&(this.mode=e,this.expanded.clear(),this.autoExpanded.clear(),this.memberPos.clear(),this.rebuild(),this.emit("mode",{mode:e}))}setEdgeView(e){if(this.assertAlive(),("merged"===e.style||e.filter)&&this.net.units.length>3)throw Error(`Edge analysis supports at most 3 species/groups, found ${this.net.units.length}; define "speciesGroups".`);for(let t of[...e.filter?.include??[],...e.filter?.absent??[]])if(!this.net.units.some(e=>e.id===t))throw Error(`Unknown species/group "${t}" in edge filter.`);let t=(e.style??"split")!==(this.edgeView.style??"split");this.edgeView={style:e.style??"split",filter:e.filter??null},"orthogroup-nodes"===this.mode&&(t?this.rebuild():this.applyContext()),this.emit("edgeview",{style:this.edgeView.style??"split",filter:this.edgeView.filter??null})}get layers(){return this.fullNet.layers}get shownEdgeLayers(){return this.shownLayers}setEdgeLayers(e){if(this.assertAlive(),e){let t=e.filter(e=>!this.fullNet.layers.includes(e));if(t.length)throw Error(`Unknown edge layer(s) ${t.join(", ")}. Available: ${this.fullNet.layers.join(", ")}`)}let t=e&&e.length<this.fullNet.layers.length?[...e]:null;Nv(t)!==Nv(this.shownLayers)&&(this.shownLayers=t,this.net=function(e,t){if(!t)return e;let n=new Set(t),r=e.edges.filter(e=>n.has(e.layer)).map((e,t)=>({...e,index:t}));return{...e,edges:r}}(this.fullNet,t),this.ctx=this.ctxOptions?gg(this.net,this.ctxOptions):null,this.rebuild(),this.emit("layers",{layers:t,interactions:this.net.edges.length}))}get units(){return this.net.units}edgeAnalysis(){if(this.assertAlive(),"orthogroup-nodes"!==this.mode)throw Error("edgeAnalysis() needs the 'orthogroup-nodes' mode.");let e=new Set,t=[],n=this.ctx,r=ev(this.net,this.groupOf,e=>!n||n.visibleEdges.has(e),e=>!n||n.visibleNodes.has(e));return this.cy.edges(".ogedge").not(".mEdge").not(Tv).forEach(n=>{let i=Jg(n.data("source"),n.data("target")),o=r.get(i);o&&!e.has(i)&&(e.add(i),t.push(o))}),function(e,t){let n={units:t,pairs:e.length,conserved:0,partial:0,specific:0,untestable:0,crossOnly:0,perUnit:Object.fromEntries(t.map(e=>[e,0]))};for(let t of e){let e=tv(t);"cross"===e?n.crossOnly++:n[e]++;for(let e of t.present)n.perUnit[e]++}return n}(t,this.net.units.map(e=>e.id))}contextualize(e){return this.assertAlive(),this.ctx=gg(this.net,e),this.ctxOptions=e,this.applyContext(),this.emit("context",{context:this.ctx}),this.ctx}setBubbleBy(e,t={}){this.assertAlive(),null!==e&&this.assertOverlayKey(e),this.bubbleKey=e,this.bubbleMinSpecies=Math.max(1,t.minSpecies??1),this.bubbleAvoid=t.avoid??"auto",this.refreshBubbles(),this.emitOverlay()}emitOverlay(){this.emit("overlay",{bubbleBy:this.bubbleKey,hints:this.hints?{style:this.hints.style,by:this.hints.by}:null})}setCompartmentHints(e=!0){this.assertAlive();let t="object"==typeof e&&e?e:{},n=t.style??"bubbles";void 0!==t.by&&this.assertOverlayKey(t.by),this.hints=null===e||!1===e?null:{minFraction:Math.max(0,t.minFraction??.2),opacity:Math.min(1,Math.max(0,t.opacity??("territories"===n?.28:.09))),style:n,by:t.by??"compartment",bandwidth:Math.max(0,t.bandwidth??0),labels:t.labels??!0},this.refreshBubbles(),this.emitOverlay()}getAnnotationGroups(e=this.bubbleKey){if(this.assertAlive(),null===e)return[];if(this.assertOverlayKey(e),"compartment"===e)return this.compartmentGroups();let t=new Set;for(let n of this.net.nodes)for(let r of n.annotations[e]??[])t.add(r);let n=[...t].sort(),r=new Map(n.map((e,t)=>[e,{value:e,color:dg(t),proteins:[],nodeIds:[],species:[]}]));for(let[t,n]of this.proteinNodes){let i=this.net.nodeIndex.get(t)?.annotations[e];if(!i||this.ctx&&!this.ctx.visibleNodes.has(t))continue;let o=n.filter(e=>!this.cy.getElementById(e).is(Tv));if(0===o.length)continue;let a=this.net.nodeIndex.get(t)?.species;for(let e of i){let n=r.get(e);n.proteins.push(t);for(let e of o)n.nodeIds.includes(e)||n.nodeIds.push(e);a&&!n.species.includes(a)&&n.species.push(a)}}return[...r.values()].filter(e=>e.proteins.length>0)}exportSvg(e={}){return this.assertAlive(),yv(this.cy,this.sceneOverlays(),e).svg}async exportPng(e={}){this.assertAlive();let{svg:t,width:n,height:r}=yv(this.cy,this.sceneOverlays(),e);return async function(e,t,n,r){if(typeof document>"u")throw Error("exportPng needs a browser (DOM canvas).");let i=new Image,o=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"}));try{await new Promise((e,t)=>{i.onload=()=>e(),i.onerror=()=>t(Error("Could not rasterise the SVG.")),i.src=o});let e=document.createElement("canvas");e.width=Math.max(1,Math.round(t*r)),e.height=Math.max(1,Math.round(n*r));let a=e.getContext("2d");if(!a)throw Error("No 2D canvas available.");return a.drawImage(i,0,0,e.width,e.height),await new Promise((t,n)=>e.toBlob(e=>e?t(e):n(Error("PNG encoding failed.")),"image/png"))}finally{URL.revokeObjectURL(o)}}(t,n,r,e.scale??2)}fineTerritoryField(){if(!this.wantsTerritories||!this.hints)return null;let{minFraction:e,bandwidth:t,by:n}=this.hints;return bv(this.territoryPoints(n,e),[...this.overlayDefs(n).keys()],{bandwidth:t,maxCells:25e4,minCellFraction:.08})}sceneOverlays(){let e=this.territoryLayer?.snapshot(this.fineTerritoryField()??void 0)??null,t=[],n=this.cy.container();n&&this.bubblePaths.length&&n.querySelectorAll("svg path").forEach(e=>{let n=e,r=n.getAttribute("d");r&&t.push({d:r,fill:n.style.fill||n.getAttribute("fill")||"none",stroke:n.style.stroke||n.getAttribute("stroke")||"none",strokeWidth:n.style.strokeWidth||n.getAttribute("stroke-width")||"1"})});let r=[];if(this.net.species.size&&r.push({kind:"dot",entries:[...this.net.species.values()].map(e=>({color:e.color,label:e.label}))}),"orthogroup-nodes"!==this.mode&&this.net.compartments.size&&!(e&&"compartment"===this.hints?.by)&&r.push({kind:"swatch",title:"Compartment",entries:[...this.net.compartments.values()].map(e=>({color:e.color,label:e.label}))}),e&&this.hints){let t=this.overlayDefs(this.hints.by),n=new Set(e.labels.map(e=>e.text));r.push({kind:"swatch",title:`Background: ${"compartment"===this.hints.by?"compartment":this.hints.by}`,entries:[...t.values()].filter(e=>!n.size||n.has(e.label)).map(e=>({color:e.color,label:e.label}))})}null!==this.bubbleKey&&t.length&&r.push({kind:"swatch",title:`Bubbles: ${"compartment"===this.bubbleKey?"compartment":this.bubbleKey}`,entries:this.getAnnotationGroups().filter(e=>e.nodeIds.length>=2&&(this.bubbleMinSpecies<=1||e.species.length>=this.bubbleMinSpecies)).map(e=>({color:e.color,label:`${e.value} (${e.proteins.length})`}))});let i=e=>this.info(e)?.summary;return{territory:e,bubbles:t,legend:r,nodeTitle:e=>i(e.id())??e.data("label")??e.id(),edgeTitle:e=>i(e.id())??"",description:this.describe().text}}clearContext(){this.assertAlive(),this.ctx=null,this.ctxOptions=null,this.applyContext(),this.emit("context",{context:null})}async layout(e={}){this.assertAlive();let t=Date.now(),n=await this.runLayout(e);n&&this.emit("layout",{...n,mode:this.mode,milliseconds:Date.now()-t})}runLayout(e){let t=++this.layoutRun,n=e.scope??"visible",r=e.incremental??!1,i=(e.cache??!0)&&!r,o=e.fit??!0,a=e.algorithm??"fcose",s="anchored"===a;this.cy.nodes(".compartment").not(".orthogroup").toggleClass("box-off",s);let l=[this.mode,n,vg(this.ctx?.options??null),Nv(this.edgeView),this.shownLayers?this.shownLayers.join(","):"*",[...this.expanded].sort().join(","),s?`anchored${Nv(e.anchored??{})}`:`fcose${Nv(e.fcose??{})}`].join("#"),u=("visible"===n?this.cy.elements().not(Tv):this.cy.elements()).not(Cv);if(u.nodes().empty())return Promise.resolve(null);let c=e=>({algorithm:a,nodes:u.nodes().length,cached:e}),h=i?this.positionCache.get(l):void 0;return h?(this.cy.batch(()=>{u.nodes().forEach(e=>{let t=h.get(e.id());t&&!e.isParent()&&e.position({...t})})}),o&&this.cy.fit(u,30),this.refreshBubbles(),Promise.resolve(c(!0))):s?this.runAnchoredLayout(u,e.anchored??{},t,r).then(e=>{if(!e)return null;if(i){let e=new Map;u.nodes().forEach(t=>{e.set(t.id(),{...t.position()})}),this.positionCache.set(l,e)}return o&&this.cy.fit(u,30),this.refreshBubbles(),c(!1)}):new Promise((n,a)=>{let s;try{s=u.layout({name:"fcose",animate:!1,randomize:!r,quality:"default",packComponents:!0,nodeDimensionsIncludeLabels:!0,tile:this.styleEnabled,nodeSeparation:80,nodeRepulsion:()=>9e3,idealEdgeLength:e=>e.hasClass("hubedge")?45:e.hasClass("identity")?220:75,edgeElasticity:e=>e.hasClass("hubedge")?.9:e.hasClass("identity")?.05:.45,gravityRangeCompound:1.5,gravityCompound:1,fit:o,padding:30,...e.fcose??{}})}catch(e){return void a(Error(`[ContextNet] the default layout needs cytoscape-fcose: install it and call cytoscape.use(fcose), or use layout({ algorithm: 'anchored' }). (${e.message})`))}s.one("layoutstop",()=>{if(i&&t===this.layoutRun){let e=new Map;u.nodes().forEach(t=>{t.isParent()||e.set(t.id(),{...t.position()})}),this.positionCache.set(l,e)}this.refreshBubbles(),n(c(!1))}),s.run()})}anchorDiagnostics(e={}){this.assertAlive();let t=bg(this.net,e),n=function(e,t){let n=[...e.coords],r=0,i=0,o=[];for(let a of t??e.vectors.keys()){let t=e.vectors.get(a);if(!t||!n.length)continue;let s=0,l=0;for(let[n,r]of t){let t=e.coords.get(n);t&&(s+=r*t[0],l+=r*t[1])}let u="",c=1/0;for(let[e,[t,r]]of n){let n=Math.hypot(t-s,r-l);n<c&&(c=n,u=e)}i++,t.has(u)?r++:o.push(a)}return{purity:i?r/i:1,proteins:i,offTerm:o}}(t);return{terms:[...t.coords].map(([e,[t,n]])=>({term:e,x:t,y:n})),stress:t.mapStress,anchorPurity:n.purity,proteins:n.proteins,offTerm:n.offTerm}}async runAnchoredLayout(e,t,n,r=!1){let i=bg(this.net,t);i.mapStress>.35&&!this.warnedMapStress&&(this.warnedMapStress=!0,console.warn(`[ContextNet] the anchored layout's term map fits the term relations poorly (stress ${i.mapStress.toFixed(2)}); anchors may land near terms a protein does not carry. See anchorDiagnostics().`));let o=[],a=this.ctx,s="species"===t.orthogroupPooling?e=>this.net.nodeIndex.get(e)?.species:void 0;e.nodes().forEach(e=>{if(e.hasClass("hub")||e.isParent())return;let t=e.hasClass("ogroup")?e.data("members"):void 0;if(t&&a){let e=t.filter(e=>a.visibleNodes.has(e));e.length&&(t=e)}let n=e.data("protein"),l=t?function(e,t,n){let r=t=>{let n=new Map,r=0;for(let i of t){let t=e.vectors.get(i);if(t){for(let[e,r]of t)xg(n,e,r);r+=1}}if(r){for(let[e,t]of n)n.set(e,t/r);return n}};if(!n)return r(t);let i=new Map;for(let e of t){let t=n(e)??"",r=i.get(t);r?r.push(e):i.set(t,[e])}let o=new Map,a=0;for(let e of i.values()){let t=r(e);if(t){for(let[e,n]of t)xg(o,e,n);a+=1}}if(a){for(let[e,t]of o)o.set(e,t/a);return o}}(i,t,s):n?i.vectors.get(n):void 0;l&&e.hasClass("clone")&&(l=function(e,t){let n=new Map,r=0;for(let[t,i]of e)t.startsWith("compartments:")?r+=i:n.set(t,i);return r>0&&n.set(`compartments:${t}`,r),n}(l,e.data("compartment"))),o.push({id:e.id(),radius:this.styleEnabled?Math.max(e.outerWidth(),10)/2:15,vec:l,...r?{start:{...e.position()}}:{}})});let l=new Set(o.map(e=>e.id)),u=[],c=t.idealEdgeLength??75;if(e.edges().forEach(e=>{if(e.hasClass("hubedge")||!l.has(e.source().id())||!l.has(e.target().id()))return;let t=e.hasClass("identity");u.push({source:e.source().id(),target:e.target().id(),length:t?3*c:c,elasticity:t?.05:.45})}),"orthogroups"===this.mode){let e=new Map;for(let t of o){let n=this.cy.getElementById(t.id).data("orthogroup");if(!n)continue;let r=e.get(n);void 0===r?e.set(n,t.id):u.push({source:r,target:t.id,length:.8*c,elasticity:.7})}}let h=await async function(e,t,n,r={},i={}){let o=i.budgetMs??12,a=Math.max(1,r.iterations??300),s=Ng(e,t,n,r),l=()=>typeof performance<"u"?performance.now():Date.now(),u=l();for(;;){let e=s.next();if(e.done)return e.value;if(l()-u>=o){if(i.onProgress?.((e.value+1)/a),await new Promise(e=>setTimeout(e,0)),i.cancelled?.())return null;u=l()}}}(o,u,i,t,{cancelled:()=>this.destroyed||n!==this.layoutRun,onProgress:e=>this.cy.emit("layoutprogress",[e])});return!(!h||this.destroyed||n!==this.layoutRun)&&(this.cy.batch(()=>{for(let[e,t]of h.positions)this.cy.getElementById(e).position({...t});e.nodes(".hub").forEach(e=>{let t=h.termCentres.get(`compartments:${e.data("compartment")}`);t&&e.position({...t})})}),!0)}metrics(){this.assertAlive();let e=this.cy.elements().not(Tv).not(Cv),t="orthogroup-nodes"===this.mode,n=new Set;if(t){let t=this.ctx;e.nodes(".ogroup").forEach(e=>{for(let r of e.data("members"))(!t||t.visibleNodes.has(r))&&n.add(r)})}else e.nodes(".protein").forEach(e=>{n.add(e.data("protein"))});let r=new Map,i=new Map,o=(e,t)=>e.set(t,(e.get(t)??0)+1);for(let e of n){let t=this.net.nodeIndex.get(e);if(t){for(let e of t.compartments)o(r,e.id);o(i,t.primary)}}let a,s,l=e=>Object.fromEntries([...e].sort((e,t)=>e[0]<t[0]?-1:1)),u=e=>Math.max(0,...e.values()),c=[],h=(e,t)=>{c.push({key:t,a:{...e.source().position()},b:{...e.target().position()},u:e.source().id(),v:e.target().id()})};if(t){let t=e.edges(".ogedge");t.forEach(h),a=e.nodes(".ogroup").length,s=t.length}else{let t=new Set;e.edges(".interaction").forEach(e=>{t.add(e.data("index")),h(e,e.data("index"))}),a=n.size,s=t.size}return{visibleNodes:a,visibleEdges:s,edgeCrossings:ov(c),nodesPerCompartment:l(r),maxNodesPerCompartment:u(r),nodesPerPrimaryCompartment:l(i),maxNodesPerPrimaryCompartment:u(i),...this.territoryMetrics()}}get expandedOrthogroups(){return[...this.expanded]}expandOrthogroup(e){return this.setExpanded(e,!0,!1)}collapseOrthogroup(e){return this.setExpanded(e,!1,!1)}expandAll(e={}){this.assertGrouped("expandAll");let t=e.maxMembers??150,n=this.cy.nodes(".ogroup").not(Tv).filter(e=>!this.expanded.has(e.id())&&this.shownMembers(e)>=2).sort((e,t)=>this.shownMembers(e)-this.shownMembers(t)),r=[];return n.forEach(e=>{let n=this.shownMembers(e);n>t||(t-=n,r.push(e.id()))}),this.setExpanded(r,!0,!1)}collapseAll(){return this.setExpanded([...this.expanded],!1,!1)}setSemanticZoom(e=!0){if(this.assertAlive(),this.cy.off("viewport",this.onViewport),null===e||!1===e)return this.zoomOptions=null,void(this.autoExpanded.size&&this.setExpanded([...this.autoExpanded],!1,!0));let t="object"==typeof e?e:{};this.zoomOptions={zoom:t.zoom??1.5,maxMembers:t.maxMembers??150},this.cy.on("viewport",this.onViewport),this.updateSemanticZoom()}assertGrouped(e){if(this.assertAlive(),"orthogroup-nodes"!==this.mode)throw Error(`${e}() needs the 'orthogroup-nodes' mode.`)}shownMembers(e){return e.data("nShown")??e.data("members").length}resolveGroup(e){for(let t of[e,Ig(e)]){let e=this.cy.getElementById(t);if(e.nonempty()&&e.hasClass("ogroup"))return t}return this.groupOf.get(e)??null}setExpanded(e,t,n){this.assertGrouped(t?"expandOrthogroup":"collapseOrthogroup");let r=[];for(let i of Array.isArray(e)?e:[e]){let e=this.resolveGroup(i);if(e){if(t){if(this.cy.getElementById(e).data("members").length<2||this.expanded.has(e))continue;this.expanded.add(e),n?this.autoExpanded.add(e):this.autoExpanded.delete(e)}else{if(!this.expanded.delete(e))continue;this.autoExpanded.delete(e)}r.push(e)}}if(!r.length)return r;this.applyContext();for(let e of r)t?this.emit("expand",{orthogroup:e,members:this.cy.getElementById(e).data("members"),auto:n}):this.emit("collapse",{orthogroup:e,auto:n});return r}updateSemanticZoom(){let e=this.zoomOptions;if(!e||"orthogroup-nodes"!==this.mode)return;if(this.cy.zoom()<e.zoom)return void(this.autoExpanded.size&&this.setExpanded([...this.autoExpanded],!1,!0));let t=this.cy.extent(),n=!(t.w>0&&t.h>0),r=e=>n||e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,i=[...this.autoExpanded].filter(e=>{let t=this.cy.getElementById(e);return t.empty()||!r(t.position())}),o=0;for(let e of this.expanded)i.includes(e)||(o+=this.shownMembers(this.cy.getElementById(e)));let a=n?0:(t.x1+t.x2)/2,s=n?0:(t.y1+t.y2)/2,l=this.cy.nodes(".ogroup").not(Tv).filter(e=>!this.expanded.has(e.id())&&this.shownMembers(e)>=2&&r(e.position())).sort((e,t)=>Math.hypot(e.position().x-a,e.position().y-s)-Math.hypot(t.position().x-a,t.position().y-s)),u=[];l.forEach(t=>{let n=this.shownMembers(t);o+n>e.maxMembers||(o+=n,u.push(t.id()))}),i.length&&this.setExpanded(i,!1,!0),u.length&&this.setExpanded(u,!0,!0)}dropMembers(){let e=new Map,{cy:t}=this;return t.nodes(".member").empty()&&t.nodes(".og-open").empty()||(t.nodes(".og-open").forEach(t=>{e.set(t.id(),{...t.position()})}),t.nodes(".member").forEach(e=>{this.memberPos.set(e.id(),{...e.position()})}),t.batch(()=>{t.edges(".mEdge").remove(),t.nodes(".member").remove(),t.nodes(".og-open").removeClass("og-open"),t.edges(Cv).removeClass("ex-off")})),e}applyExpansion(e){let{cy:t}=this,n=this.ctx;this.proteinNodes=new Map(this.baseProteinNodes);let r=[...this.expanded].map(e=>t.getElementById(e)).filter(e=>e.nonempty()&&e.hasClass("ogroup")&&!e.is(".ctx-hidden, .ctx-dim")),i=new Set(r.map(e=>e.id()));for(let[n,r]of e)i.has(n)||t.getElementById(n).position(r);if(!r.length)return;let o=n?"hide"===n.options.display?"ctx-hidden":"ctx-dim":"",a=2.399963229728653;t.batch(()=>{for(let i of r){let r=i.data("members"),s=e.get(i.id())??{...i.position()};i.addClass("og-open"),r.forEach((e,r)=>{let l=this.net.nodeIndex.get(e),u=l.species?this.net.species.get(l.species):void 0,c=22*Math.sqrt(r+.5),h=this.memberPos.get(e)??{x:s.x+c*Math.cos(r*a),y:s.y+c*Math.sin(r*a)},d=e=>this.net.compartments.get(e).color,f=t.add({group:"nodes",data:{id:e,protein:e,label:l.label,primary:l.primary,color:d(l.primary),parent:i.id(),...u?{species:u.id,speciesColor:u.color}:{},...Bg(l.compartments.map(e=>({color:d(e.id),pct:100*e.fraction})))},classes:"protein pie member",position:h});if(this.proteinNodes.set(e,[e]),!n)return;f.addClass(n.visibleNodes.has(e)?Av(n,e):o);let p=n.values.get(e);void 0!==p&&(f.data("expr",p),f.data("ctxColor","log2fc"===n.metric?lg(p,n.scaleMax):ug(p,n.scaleMax)),f.data("ctxSize",cg(p,n.scaleMax)))})}let s=e=>i.has(this.groupOf.get(e)??"")?e:this.groupOf.get(e);t.edges(".ogedge").filter(e=>i.has(e.data("source"))||i.has(e.data("target"))).forEach(e=>{e.addClass("ex-off");let r=t=>this.groupOf.get(t.source)===e.data("source");for(let i of e.data("indices")){let a=this.net.edges[i],[l,u]=r(a)?[a.source,a.target]:[a.target,a.source],c=["interaction","ogedge","mEdge"];e.hasClass("ogmerged")&&c.push("ogmerged"),e.hasClass("ef-off")&&c.push("ef-off"),n&&!n.visibleEdges.has(i)&&c.push(o),t.add({group:"edges",data:{...e.data(),id:`mx:${i}`,source:s(l),target:s(u),indices:[i],index:i,count:1,width:2,weight:a.weight,evidence:a.evidence,parentEdge:e.id()},classes:c.join(" ")})}})})}shownNodes(){return this.cy.nodes(".protein, .ogroup").not(Tv).not(".og-open")}degreeOf(e){return e.connectedEdges(".interaction").not(Tv).not(Cv).length}labelOfProtein(e){return this.net.nodeIndex.get(e)?.label??e}info(e){this.assertAlive();let t=this.cy.getElementById(e);return t.empty()?null:t.isEdge()?this.edgeInfo(t):this.nodeInfo(t)}nodeInfo(e){let t=e.hasClass("ogroup"),n=e.data("protein");if(!t&&!n)return null;let r=t?e.data("members"):[n],i=this.membersOfNode(e),o=[...this.compartmentSharesOfNode(e)].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({id:e,label:this.net.compartments.get(e)?.label??e,fraction:t})),a={};for(let e of i)for(let[t,n]of Object.entries(this.net.nodeIndex.get(e)?.annotations??{})){let e=a[t]??=[];for(let t of n)e.includes(t)||e.push(t)}let s=e.data("expr"),l=this.ctx&&void 0!==s?{condition:this.ctx.options.condition,metric:this.ctx.metric,value:s}:null,u=e.hasClass("active")?"active":e.hasClass("linker")?"linker":e.hasClass("unmeasured")?"unmeasured":"plain",c=this.degreeOf(e),h=e.data("label")??e.id(),d=t?void 0:this.net.nodeIndex.get(n)?.species,f=o.slice(0,3).map(e=>`${e.label} ${Math.round(100*e.fraction)}%`).join(", "),p=[];if(t){let e=new Map;for(let t of i){let n=this.net.nodeIndex.get(t)?.species??"unknown";e.set(n,(e.get(n)??0)+1)}let t=[...e].map(([e,t])=>`${t} ${this.net.species.get(e)?.label??e}`).join(", ");p.push(`Orthogroup ${h}: ${i.length} protein${1===i.length?"":"s"}${t?` (${t})`:""}`)}else p.push(`Protein ${h}${d?` (${this.net.species.get(d)?.label??d})`:""}`);f&&p.push(`compartments: ${f}`),p.push(`${c} visible interaction${1===c?"":"s"}`),l&&p.push(`${"log2fc"===l.metric?"log2FC":"abundance"} ${l.value.toFixed(2)} in ${l.condition}`),"linker"===u&&p.push("shown as a linker"),"unmeasured"===u&&p.push(`not measured in ${this.ctx?.options.condition??"this condition"}`);let g=Object.entries(a).map(([e,t])=>`${e}: ${t.slice(0,3).join(", ")}${t.length>3?", ...":""}`).join("; ");g&&p.push(g);let v=t?void 0:this.net.orthogroupOf.get(n);return{kind:t?"orthogroup":"protein",id:e.id(),label:h,species:d,compartments:o,annotations:a,expression:l,degree:c,orthogroup:v?this.net.orthogroups.find(e=>e.id===v)?.label??v:void 0,members:t?r.map(e=>({id:e,label:this.labelOfProtein(e),species:this.net.nodeIndex.get(e)?.species,visible:i.includes(e)})):void 0,state:u,summary:`${p.join("; ")}.`}}edgeInfo(e){if(!e.hasClass("interaction"))return null;let t=e.hasClass("ogedge"),n=(t?e.data("indices"):[e.data("index")]).map(e=>{let t=this.net.edges[e];return{source:t.source,target:t.target,weight:t.weight,evidence:[...t.evidence],layer:t.layer,scores:{...t.scores}}}),r=[...new Set(n.flatMap(e=>e.evidence))],i=[...new Set(n.map(e=>e.layer))],o=e.data("species")||null,a=n=>t?e.cy().getElementById(n).data("label")??n:this.labelOfProtein(n),s=a(e.data("source")),l=a(e.data("target")),u=e.data("category"),c=e.data("present"),h=e.data("testable"),d=e.data("conservation"),f=[`Interaction ${s} – ${l}`];if(t?f.push(`${n.length} underlying interaction${1===n.length?"":"s"}`):f.push(`weight ${n[0].weight}`),o&&f.push(this.net.species.get(o)?.label??o),u&&"merged"===this.edgeView.style&&f.push("conserved"===u?`${Hg} comparable units`:"specific"===u?`${qg} unit: ${(c??[]).join(", ")}`:"partial"===u?`${Wg} units: ${(c??[]).join(", ")} of ${(h??[]).join(", ")}`:"untestable"===u?`${Kg} (fewer than two comparable units)`:Zg),this.fullNet.layers.length>1&&f.push(`layer ${i.join(", ")}`),!t){let e=Object.entries(n[0].scores);e.length&&f.push(e.map(([e,t])=>`${e} ${Number.isInteger(t)?t:t.toFixed(2)}`).join(", "))}return f.push(r.length?`evidence: ${r.slice(0,4).join(", ")}${r.length>4?", ...":""}`:"no evidence recorded"),{kind:"interaction",id:e.id(),source:e.data("source"),target:e.data("target"),interactions:n,species:o,category:u,conservation:d,presentIn:c,testableIn:h,evidence:r,summary:`${f.join("; ")}.`}}search(e,t={}){this.assertAlive();let n=e.trim().toLowerCase();if(!n)return[];let r=e=>e===n?0:e.startsWith(n)?1:e.includes(n)?2:-1,i=[],o=e=>{let t=this.cy.getElementById(e);return t.nonempty()&&!t.is(Tv)};for(let e of this.net.nodes){let t=this.proteinNodes.get(e.id)?.find(o);if(!t)continue;let a=Math.min(...[r(e.id.toLowerCase()),r(e.label.toLowerCase())].map(e=>e<0?9:e)),s=r(e.id.toLowerCase())>=0&&r(e.id.toLowerCase())<=r(e.label.toLowerCase())?"id":"label";if(9===a)for(let[t,r]of Object.entries(e.annotations))if(r.some(e=>e.toLowerCase().includes(n))){a=3,s=`annotation:${t}`;break}a<9&&i.push({kind:"protein",nodeId:t,id:e.id,label:e.label,matched:s,r:a})}for(let e of this.net.orthogroups){let t="orthogroup-nodes"===this.mode||"orthogroups"===this.mode?Ig(e.id):null;if(!t||!o(t))continue;let n=Math.min(...[r(e.id.toLowerCase()),r(e.label.toLowerCase())].map(e=>e<0?9:e));n<9&&i.push({kind:"orthogroup",nodeId:t,id:e.id,label:e.label,matched:"label",r:n})}return i.sort((e,t)=>e.r-t.r||e.label.localeCompare(t.label)).slice(0,t.limit??20).map(({r:e,...t})=>t)}getSelection(){this.assertAlive();let e=this.cy.nodes(":selected"),t=new Set;return e.forEach(e=>{if(e.hasClass("ogroup")||e.data("protein"))for(let n of this.membersOfNode(e))t.add(n)}),{proteins:[...t],nodeIds:e.map(e=>e.id())}}select(e,t="api"){this.assertAlive();let n=null===e?{}:Array.isArray(e)?{proteins:e}:e,r=new Set;for(let e of n.proteins??[])for(let t of this.proteinNodes.get(e)??[])r.add(t);for(let e of n.nodeIds??[])r.add(e);if(n.group){let e=this.getAnnotationGroups(n.group.key).find(e=>e.value===n.group.value);if(!e)throw Error(`No visible group "${n.group.value}" for key "${n.group.key}".`);for(let t of e.nodeIds)r.add(t)}this.selecting=!0;try{this.cy.batch(()=>{this.cy.nodes(":selected").unselect();for(let e of r){let t=this.cy.getElementById(e);t.nonempty()&&!t.is(Tv)&&t.select()}})}finally{this.selecting=!1}let i=this.getSelection();return this.emit("select",{...i,source:t}),i}clearSelection(){this.select(null)}selecting=!1;onNativeSelect=()=>{this.selecting||this.nativeSelectQueued||(this.nativeSelectQueued=!0,queueMicrotask(()=>{this.nativeSelectQueued=!1,this.destroyed||this.emit("select",{...this.getSelection(),source:"click"})}))};nativeSelectQueued=!1;focus(e){let t=this.search(e,{limit:1})[0]??null;if(!t)return null;this.select({nodeIds:[t.nodeId]},"search");let n=this.cy.getElementById(t.nodeId);return this.cy.container()&&this.cy.animate({center:{eles:n},zoom:Math.max(this.cy.zoom(),1.2)},{duration:250}),t}hitTest(e){this.assertAlive();let t=[],n=e=>{let t=new Set;for(let n of e){let e=this.cy.getElementById(n);if(e.nonempty())for(let n of this.membersOfNode(e))t.add(n)}return[...t]},r=this.cy.container()?.querySelectorAll("svg path"),i=r&&r.length===this.bubbleMeta.length,o=[];this.bubbleMeta.forEach((t,n)=>{if(i){let i=r[n];if("function"==typeof i.isPointInFill&&i.isPointInFill(new DOMPoint(e.x,e.y))){let e=i.getBBox();o.push({meta:t,area:e.width*e.height})}return}let a=this.cy.nodes().filter(e=>t.nodeIds.includes(e.id())).boundingBox({includeLabels:!1});e.x>=a.x1-12&&e.x<=a.x2+12&&e.y>=a.y1-12&&e.y<=a.y2+12&&o.push({meta:t,area:(a.w+24)*(a.h+24)})}),o.sort((e,t)=>e.area-t.area);for(let{meta:e}of o)t.push({overlay:"bubble",key:e.key,value:e.value,color:e.color,proteins:n(e.nodeIds),nodeIds:e.nodeIds});let a=this.lastField;if(a&&this.wantsTerritories){let n=a.field,r=Math.floor((e.x-n.x0)/n.cell),i=Math.floor((e.y-n.y0)/n.cell);if(r>=0&&i>=0&&r<n.cols&&i<n.rows){let e=n.owner[i*n.cols+r];if(e>=0){let r=this.overlayDefs(a.by).get(n.ids[e]),i=r?this.getAnnotationGroups(a.by).find(e=>e.value===r.label):void 0;r&&i&&t.push({overlay:"territory",key:a.by,value:r.label,color:r.color,proteins:i.proteins,nodeIds:i.nodeIds})}}}return t}enableOverlayClick(){this.assertAlive();let e=e=>{if(e.target!==this.cy)return;let t=this.hitTest(e.position)[0];t?this.select({nodeIds:t.nodeIds},"click"):this.select(null,"click")};return this.cy.on("tap",e),this.cy.on("select unselect","node",this.onNativeSelect),()=>{this.cy.off("tap",e),this.cy.off("select unselect","node",this.onNativeSelect)}}enableKeyboard(){return this.assertAlive(),dv(this.cy,{info:e=>this.info(e),describe:()=>this.describe().text,select:e=>this.select({nodeIds:e},"keyboard"),toggle:e=>{if("orthogroup-nodes"!==this.mode)return;let t=this.cy.getElementById(e),n=t.hasClass("member")?t.data("parent"):e;this.expanded.has(n)?this.collapseOrthogroup(n):this.expandOrthogroup(n)}})}describe(e={}){this.assertAlive();let t=this.ctx,n=this.net.nodes.map(e=>e.id).filter(e=>!t||t.visibleNodes.has(e)),r=new Set(n),i=e=>{let t=new Map;for(let r of n)for(let n of e(r))t.set(n,(t.get(n)??0)+1);return t},o=[...i(e=>[this.net.nodeIndex.get(e)?.species??""]).entries()].filter(([e])=>e).map(([e,t])=>({id:e,label:this.net.species.get(e)?.label??e,proteins:t})),a=[...i(e=>{let t=this.net.nodeIndex.get(e);return t.compartments.filter(e=>e.fraction>=.2||e.id===t.primary).map(e=>e.id)})].map(([e,t])=>({id:e,label:this.net.compartments.get(e)?.label??e,proteins:t})).sort((e,t)=>t.proteins-e.proteins),s=t?t.visibleEdges.size:this.net.edges.length,l=e.maxGroups??6,u=this.bubbleKey?this.getAnnotationGroups().filter(e=>e.nodeIds.length>=2&&(this.bubbleMinSpecies<=1||e.species.length>=this.bubbleMinSpecies)).sort((e,t)=>t.proteins.length-e.proteins.length).slice(0,l).map(e=>({value:e.value,proteins:e.proteins.length,species:e.species.length})):[],c="orthogroup-nodes"===this.mode&&this.net.units.length<=3?this.edgeAnalysis():null,h=this.findCandidates({limit:e.maxCandidates??5}),d=e=>"compartment"===e?"compartment":e,f=[];if(f.push(`Protein interaction network in ${{pie:"pie view (one node per protein, compartments as pie slices)",clones:"clone view (one node per protein and compartment)",bubbles:"bubble view (compartments as overlays)",orthogroups:"orthogroup box view","orthogroup-nodes":"collapsed orthogroup view (one node per orthogroup, pie = species)"}[this.mode]}: ${r.size} of ${this.net.nodes.length} proteins and ${s} of ${this.net.edges.length} interactions are shown.`),o.length&&f.push(`Species: ${o.map(e=>`${e.label} (${e.proteins})`).join(", ")}.`),a.length&&f.push(`Compartments (proteins with at least 20% share): ${a.slice(0,6).map(e=>`${e.label} (${e.proteins})`).join(", ")}.`),t){let e=t.options;f.push(`Expression context: condition "${e.condition}", ${"log2fc"===t.metric?`|log2FC| >= ${e.threshold} (${e.direction})`:`abundance >= ${e.threshold}`}${e.maxP===1/0?"":`, p <= ${e.maxP}`}; ${t.stats.activeNodes} active proteins and ${t.stats.linkerNodes} linkers${t.stats.unmeasuredNodes?`, ${t.stats.unmeasuredNodes} shown without a measurement`:""}.`)}return this.bubbleKey&&f.push(u.length?`Bubbles group proteins by ${d(this.bubbleKey)}: ${u.map(e=>`${e.value} (${e.proteins} proteins, ${e.species} species)`).join("; ")}.`:`Bubbles by ${d(this.bubbleKey)}: no group with two or more visible nodes.`),this.hints&&f.push(`The background shows ${this.hints.style} by ${d(this.hints.by)}.`),c&&f.push(`Orthogroup pairs: ${c.pairs}; ${Hg} comparable units ${c.conserved}, ${Wg} ${c.partial}, ${qg} ${c.specific}, ${Kg} ${c.untestable}, ${Zg} ${c.crossOnly} (recorded = present in the input at the analysis cut-off; comparable = both orthogroups have members in the unit).`),this.expanded.size&&f.push(`Expanded orthogroups: ${[...this.expanded].map(e=>this.cy.getElementById(e).data("label")??e).join(", ")}.`),h.nodes.length&&f.push(`Most notable ${h.nodes[0].kind}s: ${h.nodes.map(e=>`${e.label} (${e.reasons.slice(0,2).join("; ")})`).join("; ")}.`),h.interactions.length&&f.push(`Most notable interactions: ${h.interactions.map(e=>`${e.label} (${e.reasons.slice(0,2).join("; ")})`).join("; ")}.`),this.net.warnings.length&&f.push(`${this.net.warnings.length} data warning${1===this.net.warnings.length?"":"s"}.`),{text:f.join(" "),mode:this.mode,proteins:{total:this.net.nodes.length,shown:r.size},interactions:{total:this.net.edges.length,shown:s},species:o,compartments:a,context:t?{condition:t.options.condition,metric:t.metric,threshold:t.options.threshold,direction:t.options.direction,active:t.stats.activeNodes,linkers:t.stats.linkerNodes}:null,overlays:{bubbleBy:this.bubbleKey,hints:this.hints?`${this.hints.style} by ${d(this.hints.by)}`:null,groups:u},edgeAnalysis:c,expanded:[...this.expanded],candidates:h,warnings:[...this.net.warnings]}}findCandidates(e={}){this.assertAlive();let t=e.limit??10,n=this.ctx,r=this.shownNodes().filter(e=>!e.hasClass("clone")||e.hasClass("primary")),i=r.map(e=>this.degreeOf(e)),o=Math.max(1,...i),a=this.net.species.size,s=[];r.forEach((e,t)=>{let r=e.hasClass("ogroup"),l=this.membersOfNode(e),u=e.data("label")??e.id(),c=[],h=i[t],d=h/o*.4;h>0&&c.push(`${h} visible interaction${1===h?"":"s"}`);let f=e.data("expr");if(n&&void 0!==f&&n.scaleMax>0&&(d+=.3*Math.min(1,Math.abs(f)/n.scaleMax),c.push(`${"log2fc"===n.metric?"log2FC":"abundance"} ${f.toFixed(2)} in ${n.options.condition}`)),r&&a>1){let e=new Set(l.map(e=>this.net.nodeIndex.get(e)?.species).filter(Boolean));d+=e.size/a*.2,e.size>1&&c.push(`members in ${e.size} of ${a} species`)}let p=[...this.compartmentSharesOfNode(e)].filter(([,e])=>e>=.2).length;p>1&&(d+=.1,c.push(`localised in ${p} compartments`)),d>0&&s.push({kind:r?"orthogroup":"protein",id:r?e.id():e.data("protein"),label:u,score:Math.round(1e3*d)/1e3,reasons:c})}),s.sort((e,t)=>t.score-e.score||e.label.localeCompare(t.label));let l=[];if("orthogroup-nodes"===this.mode&&this.net.units.length>=2){let e=new Set,t=e=>this.cy.getElementById(e).data("label")??e,n={conserved:1,specific:.7,partial:.6,cross:.3,untestable:.2};this.cy.edges(".ogedge").not(".mEdge").not(Tv).forEach(r=>{let i=r.data("source"),o=r.data("target"),a=Jg(i,o),s=r.data("category");if(!s||e.has(a)||i===o)return;e.add(a);let u=r.data("indices").length,c=r.data("present")??[],h=r.data("testable")??[],d=[];"conserved"===s?d.push(`recorded in all ${h.length} comparable units`):"specific"===s?d.push(`recorded only in ${c.join(", ")} although comparable in ${h.length} units`):"partial"===s?d.push(`recorded in ${c.length} of ${h.length} comparable units`):"untestable"===s?d.push(`${Kg} (fewer than two comparable units)`):d.push(Zg),d.push(`${u} underlying interaction${1===u?"":"s"}`),l.push({kind:"interaction",id:a,label:`${t(i)} – ${t(o)}`,score:Math.round(1e3*(.7*(n[s]??0)+.3*Math.min(1,Math.log2(1+u)/4)))/1e3,reasons:d})}),l.sort((e,t)=>t.score-e.score||e.label.localeCompare(t.label))}return{nodes:s.slice(0,t),interactions:l.slice(0,t)}}conservationTest(e={}){this.assertAlive();let t=this.ctx,n=new Map,r=e=>{let t=n.get(e);return void 0===t&&n.set(e,t=n.size),t},i=e=>{let t=this.net.orthogroupOf.get(e);return t?Ig(t):`solo:${e}`},o=Object.fromEntries(this.net.units.map(e=>[e.id,[]])),a=new Set;for(let e of this.net.edges){if(t&&!t.visibleEdges.has(e.index))continue;let n=this.net.nodeIndex.get(e.source),s=this.net.nodeIndex.get(e.target);if(!n.species||n.species!==s.species)continue;let l=this.net.unitOf.get(n.species),u=i(n.id),c=i(s.id);if(!l||u===c)continue;let h=`${l}|${Jg(u,c)}`;a.has(h)||(a.add(h),o[l].push([r(u),r(c)]))}return jg(o,n.size,e)}enrichment(e){this.assertAlive(),this.assertOverlayKey(e.key);let t,n=this.ctx,r=e.set??(n?"active":void 0);if(void 0===r)throw Error("enrichment() needs a set: pass `set`, or activate an expression context for 'active'.");if("active"===r||"visible"===r)if(n)t=[..."active"===r?n.active:n.visibleNodes];else{if("active"===r)throw Error("enrichment(): the 'active' set needs an expression context.");t=this.net.nodes.map(e=>e.id)}else if(Array.isArray(r))t=r;else{let e=this.getAnnotationGroups(r.key).find(e=>e.value===r.value);if(!e)throw Error(`No visible group "${r.value}" for key "${r.key}".`);t=e.proteins}let i=e=>this.net.compartments.get(e)?.label??e;return Yg(this.net.nodes.map(e=>e.id),t,t=>{let n=this.net.nodeIndex.get(t);return n?"compartment"===e.key?n.compartments.filter(e=>e.fraction>=.2||e.id===n.primary).map(e=>i(e.id)):n.annotations[e.key]??[]:[]},e.minCount??2)}clearLayoutCache(){this.positionCache.clear()}destroy(){this.destroyed||=(this.cy.off("viewport",this.onViewport),this.cy.off("select unselect","node",this.onNativeSelect),this.clearBubbles(),this.dropTerritories(),this.bubblePlugin?.destroy?.(),this.bubblePlugin=null,this.cy.elements().remove(),this.positionCache.clear(),!0)}get styleEnabled(){return this.cy.styleEnabled()}assertAlive(){if(this.destroyed)throw Error("ContextNet was destroyed.")}rebuild(){this.clearBubbles(),this.positionCache.clear();let{elements:e,proteinNodes:t}=Fg(this.net,this.mode,this.edgeView);if(this.baseProteinNodes=t,this.proteinNodes=new Map(t),this.groupOf=new Map,"orthogroup-nodes"===this.mode)for(let[e,n]of t)this.groupOf.set(e,n[0]);this.cy.batch(()=>{this.cy.elements().remove(),this.cy.add(e)}),this.ctx||"orthogroup-nodes"===this.mode?this.applyContext():this.refreshBubbles()}applyContextGrouped(){let{cy:e}=this,t=this.ctx,n=this.dropMembers();e.batch(()=>{e.elements().removeClass("ctx-hidden ctx-dim active linker unmeasured"),e.nodes(".ogroup").removeData("ctxColor expr exprMixed");let n=t?"hide"===t.options.display?"ctx-hidden":"ctx-dim":"";e.nodes(".ogroup").forEach(e=>{let r=e.data("members"),i=t?r.filter(e=>t.visibleNodes.has(e)):r;if(e.data("nShown",i.length),Object.assign(e.data(),Bg(zg(this.net,i.length?i:r))),e.data("size",22+7*Math.sqrt(i.length||r.length)),!t)return;if(0===i.length)return void e.addClass(n);e.addClass(i.some(e=>t.active.has(e))?"active":i.every(e=>t.unmeasured.has(e))?"unmeasured":"linker");let o=i.map(e=>t.values.get(e)).filter(e=>void 0!==e);if(o.length)if("log2fc"===t.metric){let n=o.reduce((e,t)=>Math.abs(t)>Math.abs(e)?t:e);e.data("expr",n),e.data("ctxColor",lg(n,t.scaleMax));let r=i.filter(e=>t.active.has(e)).map(e=>t.values.get(e)??0);e.data("exprMixed",r.some(e=>e>0)&&r.some(e=>e<0))}else{let n=o.reduce((e,t)=>e+t,0)/o.length;e.data("expr",n),e.data("ctxColor",ug(n,t.scaleMax))}}),e.edges(".ogedge").removeClass("ef-off");let r=ev(this.net,this.groupOf,e=>!t||t.visibleEdges.has(e),e=>!t||t.visibleNodes.has(e)),i="merged"===this.edgeView.style,o=new Map(this.net.units.map(e=>[e.id,e]));e.edges(".ogedge").forEach(e=>{let a=e.data("indices"),s=t?a.filter(e=>t.visibleEdges.has(e)):a;e.data("count",s.length),e.data("width",1.5+1.2*Math.log2(1+(s.length||a.length))),t&&0===s.length&&e.addClass(n);let l=r.get(Jg(e.data("source"),e.data("target")));if(!l)return;let u=tv(l);e.data("category",u),e.data("conservation",nv(l)),e.data("present",[...l.present]),e.data("testable",l.testable),e.data("crossCount",l.cross),i&&(e.data("count",l.indices.length),e.data("width",1.5+1.2*Math.log2(1+l.indices.length)),e.data("color","specific"===u?o.get([...l.present][0]).color:Qg[u])),function(e,t){if(!t)return!0;if(!1===t.selfLoops&&e.a===e.b||t.include?.some(t=>!e.present.has(t))||t.absent?.some(t=>e.present.has(t)||!e.testable.includes(t))||void 0!==t.minUnits&&e.present.size<t.minUnits)return!1;if(void 0!==t.minConservation){let n=nv(e);if(null===n||n<t.minConservation)return!1}return!0}(l,this.edgeView.filter)||e.addClass("ef-off")})}),this.applyExpansion(n),e.emit("contextualize",[t]),this.refreshBubbles()}applyContext(){if("orthogroup-nodes"===this.mode)return this.applyContextGrouped();let{cy:e}=this,t=this.ctx;e.batch(()=>{if(e.elements().removeClass("ctx-hidden ctx-dim active linker unmeasured"),e.nodes(".protein").removeData("expr ctxColor ctxSize"),!t)return;let n="hide"===t.options.display?"ctx-hidden":"ctx-dim",r=e=>t.visibleNodes.has(e);for(let[i,o]of this.proteinNodes){let a=r(i)?Av(t,i):n,s=t.values.get(i);for(let n of o){let r=e.getElementById(n);r.addClass(a),void 0!==s&&(r.data("expr",s),r.data("ctxColor","log2fc"===t.metric?lg(s,t.scaleMax):ug(s,t.scaleMax)),r.data("ctxSize",cg(s,t.scaleMax)))}}e.edges().forEach(e=>{e.hasClass("interaction")?t.visibleEdges.has(e.data("index"))||e.addClass(n):(e.hasClass("identity")||e.hasClass("hubedge"))&&(r(e.data("protein"))||e.addClass(n))}),e.nodes(".compartment").forEach(e=>{e.children(".protein").not(Tv).empty()&&e.addClass(n)}),e.nodes(".hub").forEach(e=>{e.connectedEdges(".hubedge").not(Tv).empty()&&(e.addClass(n),e.connectedEdges(".hubedge").addClass(n))})}),e.emit("contextualize",[t]),this.refreshBubbles()}clearBubbles(){for(let e of this.bubblePaths)try{e.remove()}catch{}this.bubblePaths=[],this.bubbleMeta=[]}get wantsTerritories(){return"territories"===this.hints?.style&&"bubbles"!==this.mode}dropTerritories(){this.lastField=null,this.territoryLayer&&=(this.cy.off("position","node",this.onNodeMoved),this.territoryLayer.destroy(),null)}territoryMetrics(){let e=this.territoryPoints(av,.2),t=bv(e,[...this.overlayDefs(av).keys()]);if(!t)return{territoryPurity:null,territoryStrayArea:null};let n=function(e,t,n=.2,r=2){let i=new Map(e.ids.map((e,t)=>[e,t])),o=e.cols*e.rows,a=e.ids.map(()=>new Uint8Array(o)),s=r*e.bandwidth,l=Math.ceil(s/e.cell),u=0,c=0;for(let r of t){if(!Number.isFinite(r.x)||!Number.isFinite(r.y))continue;let t=[...r.shares].filter(([e,t])=>i.has(e)&&t>0);if(!t.length)continue;let o=Math.max(...t.map(([,e])=>e)),h=new Set(t.filter(([,e])=>e>=n||e===o).map(([e])=>i.get(e))),d=Math.floor((r.x-e.x0)/e.cell),f=Math.floor((r.y-e.y0)/e.cell);u++,d>=0&&f>=0&&d<e.cols&&f<e.rows&&h.has(e.owner[f*e.cols+d])&&c++;for(let t=Math.max(0,f-l);t<=Math.min(e.rows-1,f+l);t++){let n=e.y0+(t+.5)*e.cell-r.y;for(let i=Math.max(0,d-l);i<=Math.min(e.cols-1,d+l);i++){let o=e.x0+(i+.5)*e.cell-r.x;if(!(o*o+n*n>s*s))for(let n of h)a[n][t*e.cols+i]=1}}}let h=0,d=0;for(let t=0;t<o;t++){let n=e.owner[t];n<0||(h++,a[n][t]||d++)}return{purity:u?c/u:1,strayArea:h?d/h:0,points:u,cells:h}}(t,e,.2);return{territoryPurity:n.purity,territoryStrayArea:n.strayArea}}territoryPoints(e,t){let n=[];return this.shownNodes().forEach(r=>{let i=this.sharesOfNode(e,r),o=new Map([...i].filter(([,e])=>e>=t)),{x:a,y:s}=r.position();n.push({x:a,y:s,shares:o.size?o:i})}),n}refreshTerritories(){if(!this.wantsTerritories||!this.cy.container())return void this.dropTerritories();if(!this.territoryLayer){if(this.territoryLayer=Ev.create(this.cy),!this.territoryLayer)return;this.cy.on("position","node",this.onNodeMoved)}let{minFraction:e,opacity:t,bandwidth:n,labels:r,by:i}=this.hints,o=this.overlayDefs(i),a=bv(this.territoryPoints(i,e),[...o.keys()],{bandwidth:n});this.lastField=a?{field:a,by:i}:null,this.territoryLayer.update(a,{defs:o,opacity:t,labels:r})}assertOverlayKey(e){if(!("compartment"===e?this.net.compartments.size>0:this.net.annotationKeys.includes(e)))throw Error(`Unknown annotation key "${e}". Available: ${this.overlayKeys.join(", ")||"(none)"}.`)}overlayDefs(e){if("compartment"===e)return new Map([...this.net.compartments].map(([e,t])=>[e,{color:t.color,label:t.label}]));let t=new Set;for(let n of this.net.nodes)for(let r of n.annotations[e]??[])t.add(r);return new Map([...t].sort().map((e,t)=>[e,{color:dg(t),label:e}]))}membersOfNode(e){let t=e.hasClass("ogroup")?e.data("members"):[e.data("protein")],n=this.ctx;if(n&&t.length>1){let e=t.filter(e=>n.visibleNodes.has(e));e.length&&(t=e)}return t}sharesOfNode(e,t){if("compartment"===e)return this.compartmentSharesOfNode(t);let n=this.membersOfNode(t),r=new Map;for(let t of n){let i=this.net.nodeIndex.get(t)?.annotations[e]??[];for(let e of i)r.set(e,(r.get(e)??0)+1/(n.length*i.length))}return r}compartmentGroups(){let e=this.overlayDefs(av),t=new Map([...e].map(([e,t])=>[e,{value:t.label,color:t.color,proteins:[],nodeIds:[],species:[]}]));return this.shownNodes().forEach(e=>{let n=this.membersOfNode(e);for(let r of this.compartmentsOfNode(e,.2)){let i=t.get(r);if(i){i.nodeIds.push(e.id());for(let e of n){i.proteins.includes(e)||i.proteins.push(e);let t=this.net.nodeIndex.get(e)?.species;t&&!i.species.includes(t)&&i.species.push(t)}}}}),[...t.values()].filter(e=>e.proteins.length>0)}compartmentSharesOfNode(e){if(e.hasClass("clone"))return new Map([[e.data("compartment"),1]]);let t=e.hasClass("ogroup")?e.data("members"):[e.data("protein")],n=this.ctx;if(n&&t.length>1){let e=t.filter(e=>n.visibleNodes.has(e));e.length&&(t=e)}let r=new Map;for(let e of t)for(let n of this.net.nodeIndex.get(e)?.compartments??[])r.set(n.id,(r.get(n.id)??0)+n.fraction/t.length);return r}compartmentsOfNode(e,t){if(e.hasClass("clone"))return[e.data("compartment")];let n=e.hasClass("ogroup")?e.data("members"):[e.data("protein")],r=this.ctx;if(r&&n.length>1){let e=n.filter(e=>r.visibleNodes.has(e));e.length&&(n=e)}let i=new Map;for(let e of n)for(let t of this.net.nodeIndex.get(e)?.compartments??[])i.set(t.id,(i.get(t.id)??0)+t.fraction);let o=[...i].filter(([,e])=>e/n.length>=t).map(([e])=>e);if(o.length)return o;let a=[...i].sort((e,t)=>t[1]-e[1])[0];return a?[a[0]]:[]}refreshBubbles(){this.clearBubbles(),this.refreshTerritories();let e="bubbles"===this.mode,t=null!==this.hints&&!e&&!this.wantsTerritories;if(!e&&!t&&null===this.bubbleKey||!this.cy.container())return;let n=this.cy;if("function"!=typeof n.bubbleSets)return void console.warn("[ContextNet] bubble overlays need cytoscape-bubblesets: cytoscape.use(bubbleSets).");this.bubblePlugin??=n.bubbleSets();let r=this.bubblePlugin,i=(e,t,n,i,o=null)=>{e.empty()||(this.bubbleMeta.push({...i,color:t,nodeIds:e.map(e=>e.id())}),this.bubblePaths.push(r.addPath(e,null,o,{virtualEdges:!0,style:{fill:fg(t,n?this.hints.opacity:.18),stroke:n?fg(t,Math.min(1,2.5*this.hints.opacity)):t,strokeWidth:n?"1":"1.5"}})))};if(t){let{minFraction:e,by:t}=this.hints,n=new Map;this.shownNodes().forEach(r=>{let i=this.sharesOfNode(t,r),o="compartment"===t?this.compartmentsOfNode(r,e):[...i].filter(([,t])=>t>=e).map(([e])=>e);for(let e of o){let t=n.get(e);t?t.add(r.id()):n.set(e,new Set([r.id()]))}});for(let[e,r]of this.overlayDefs(t)){let o=n.get(e);o&&o.size>1&&i(this.cy.nodes().filter(e=>o.has(e.id())),r.color,!0,{key:t,value:r.label})}}if(e)for(let e of this.net.compartments.values()){let t=this.cy.getElementById(Og(e.id));t.empty()||t.hasClass("ctx-hidden")||t.hasClass("ctx-dim")||i(t.connectedEdges(".hubedge").not(Tv).connectedNodes().filter(e=>e.hasClass("protein")),e.color,!1,{key:av,value:e.label})}if(null!==this.bubbleKey)for(let e of this.getAnnotationGroups(this.bubbleKey)){if(e.nodeIds.length<2||this.bubbleMinSpecies>1&&e.species.length<this.bubbleMinSpecies)continue;let t=new Set(e.nodeIds),n=this.cy.nodes().filter(e=>t.has(e.id())),r=null;if(!0===this.bubbleAvoid||"auto"===this.bubbleAvoid&&this.shownNodes().length<=200){let e=n.boundingBox({includeLabels:!1});r=this.shownNodes().filter(n=>{if(t.has(n.id()))return!1;let{x:r,y:i}=n.position();return r>=e.x1-40&&r<=e.x2+40&&i>=e.y1-40&&i<=e.y2+40})}i(n,e.color,!1,{key:this.bubbleKey,value:e.value},r)}}},Sv="_contextnet";function kv(e){let t=this.scratch(Sv);if(!e){if(!t)throw Error("cy.contextnet(options) has not been initialised for this instance.");return t}t?.destroy();let n=new _v(this,e);return this.scratch(Sv,n),n}function Pv(e){e("core","contextnet",kv)}typeof window<"u"&&window.cytoscape?.use?.(Pv);let Iv=!1;const Ov=["data","mode","context","layout","overlay","edgeview","layers","select","expand","collapse"],Dv={wheelSensitivity:.25,minZoom:.05,maxZoom:4},Lv=e=>JSON.stringify(void 0===e?null:e),Rv=(e,t)=>Lv([...e&&e.proteins||[]].sort())===Lv([...t&&t.proteins||[]].sort())&&Lv([...e&&e.nodeIds||[]].sort())===Lv([...t&&t.nodeIds||[]].sort());function Bv(e,t){if("context"===e){const e=t.context;return e?{condition:e.options.condition,metric:e.metric,stats:e.stats}:{condition:null}}return t}class zv{constructor(e,t){Iv||(yf.use(bf()),yf.use(Jp),yf.use(Pv),Iv=!0),this.container=e,this.setProps=t,this.cy=null,this.net=null,this.data=null,this.applied={selection:Lv(null)},this.sent={},this.props=null,this.running=!1,this.dirty=!1,this.destroyed=!1,this.disposers=[],"function"==typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(()=>this.cy&&this.cy.resize()),this.resizeObserver.observe(e))}update(e){this.props=e,this.running?this.dirty=!0:(this.running=!0,(async()=>{try{do{this.dirty=!1;try{await this.apply(this.props)}catch(e){console.error("[dash-contextnet]",e),this.send({error:`update: ${e&&e.message||e}`})}}while(this.dirty&&!this.destroyed)}finally{this.running=!1}})())}destroy(){this.destroyed=!0,this.resizeObserver&&this.resizeObserver.disconnect();for(const e of this.disposers)e();delete this.container.contextnet,delete this.container.cy,this.net&&this.net.destroy(),this.cy&&this.cy.destroy(),this.net=this.cy=null}send(e){const t={};for(const[n,r]of Object.entries(e)){const e=Lv(r);this.sent[n]!==e&&(this.sent[n]=e,t[n]=r)}!this.destroyed&&Object.keys(t).length&&this.setProps(t)}create(e){this.cy=yf({container:this.container,...Dv,...e.cytoscape_options||{}}),this.net=this.cy.contextnet({data:e.data,compartmentMode:e.compartment_mode||"pie",style:e.stylesheet||void 0});const t=this.net;this.container.contextnet=t,this.container.cy=this.cy;for(const e of Ov)t.on(e,t=>{if("select"===e){const e={proteins:t.proteins,nodeIds:t.nodeIds,source:t.source};this.applied.selection=Lv(e),this.send({selection:e})}this.setProps({last_event:{type:e,time:Date.now(),...Bv(e,t)}})});this.cy.on("tap","node, edge",e=>{const n=e.target.id();this.setProps({last_event:{type:"tap",time:Date.now(),id:n,info:t.info(n)}})})}async apply(e){if(this.destroyed||!e.data)return;const t=[];let n=!1;const r=(e,r)=>{n=!0;try{return r()}catch(n){return void t.push(`${e}: ${n&&n.message||n}`)}},i=t=>Lv(e[t])!==this.applied[t],o=t=>this.applied[t]=Lv(e[t]);let a=!1;if(this.net)e.data!==this.data&&(r("data",()=>this.net.setData(e.data)),a=!0);else{if(void 0===r("data",()=>this.create(e))&&!this.net)return void this.send({error:t.join("\n")});a=!0,o("compartment_mode")}this.data=e.data;const s=this.net;let l=a;const u=(e,t,n=!0)=>{(a||i(e))&&(o(e),r(e,t),n&&(l=!0))};u("compartment_mode",()=>s.setCompartmentMode(e.compartment_mode||"pie")),u("edge_layers",()=>s.setEdgeLayers(e.edge_layers&&e.edge_layers.length?e.edge_layers:null)),u("edge_view",()=>s.setEdgeView(e.edge_view||{style:"split",filter:null})),u("context",()=>e.context&&e.context.condition?s.contextualize(e.context):s.clearContext());const c={key:e.bubble_by,minSpecies:e.bubble_min_species,avoid:e.bubble_avoid};if((a||Lv(c)!==this.applied.bubbles)&&(this.applied.bubbles=Lv(c),r("bubble_by",()=>s.setBubbleBy(e.bubble_by||null,{minSpecies:null===e.bubble_min_species?void 0:e.bubble_min_species,avoid:null===e.bubble_avoid?void 0:e.bubble_avoid}))),u("hints",()=>{return s.setCompartmentHints(null==(t=e.hints)||!1===t||""===t?null:!0===t||("string"==typeof t?{style:t}:t));var t},!1),u("semantic_zoom",()=>s.setSemanticZoom(e.semantic_zoom||null),!1),a||i("keyboard")||i("overlay_click")){o("keyboard"),o("overlay_click");for(const e of this.disposers)e();this.disposers=[],!1!==e.keyboard&&r("keyboard",()=>this.disposers.push(s.enableKeyboard())),!1!==e.overlay_click&&r("overlay_click",()=>this.disposers.push(s.enableOverlayClick()))}if(l||i("layout")){o("layout");try{await s.layout(e.layout||{})}catch(e){t.push(`layout: ${e&&e.message||e}`)}if(this.destroyed)return}if(i("selection")){o("selection");const t=e.selection||{proteins:[],nodeIds:[]};Rv(t,s.getSelection())||r("selection",()=>s.select({proteins:t.proteins||[],nodeIds:t.nodeIds||[]}))}const h=s.getSelection(),d=this.sent.selection?JSON.parse(this.sent.selection):null;Rv(h,e.selection)||Rv(h,d)||this.send({selection:{...h,source:"api"}}),e.compute_metrics&&(l||i("compute_metrics"))&&r("metrics",()=>this.send({metrics:s.metrics()})),o("compute_metrics");const f=s.getContext();if(this.send({network_info:{mode:s.compartmentMode,conditions:[...s.conditions],metric:s.metric||null,overlayKeys:[...s.overlayKeys],annotationKeys:[...s.annotationKeys],layers:[...s.layers],shownLayers:s.shownEdgeLayers?[...s.shownEdgeLayers]:null,units:s.units.map(e=>({id:e.id,label:e.label,species:e.species})),warnings:[...s.warnings],context:f?f.stats:null,visible:{nodes:this.cy.nodes(":visible:childless").length,edges:this.cy.edges(":visible").length}}}),e.export_request){if(Lv(e.export_request)!==this.handledExport){this.handledExport=Lv(e.export_request);const n=e.export_request,r="svg"===n.format?"svg":"png";try{const e="svg"===r?{content:s.exportSvg(n.options||{}),base64:!1,type:"image/svg+xml"}:{content:await(p=await s.exportPng(n.options||{}),new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(String(n.result).replace(/^data:[^,]*,/,"")),n.onerror=()=>t(n.error),n.readAsDataURL(p)})),base64:!0,type:"image/png"};e.filename=n.filename||`contextnet.${r}`,e.request=n,this.destroyed||this.setProps({export_result:e,export_request:null})}catch(e){t.push(`export: ${e&&e.message||e}`)}}}else this.handledExport=null;var p;(n||t.length)&&this.send({error:t.length?t.join("\n"):null})}}function Fv({id:n,className:r,style:i={width:"100%",height:"600px"},setProps:o,...a}){const s=(0,e.useRef)(null),l=(0,e.useRef)(null),u=(0,e.useRef)(o);return u.current=o,(0,e.useEffect)(()=>(l.current=new zv(s.current,e=>{u.current&&u.current(e)}),()=>{l.current.destroy(),l.current=null}),[]),(0,e.useEffect)(()=>{l.current&&l.current.update(a)}),t().createElement("div",{id:n,className:r,style:i,ref:s})}Fv.propTypes={id:o().string,className:o().string,style:o().object,data:o().object,compartment_mode:o().oneOf(["pie","clones","bubbles","orthogroups","orthogroup-nodes"]),context:o().object,layout:o().object,edge_layers:o().arrayOf(o().string),edge_view:o().object,bubble_by:o().string,bubble_min_species:o().number,bubble_avoid:o().oneOfType([o().bool,o().oneOf(["auto"])]),hints:o().oneOfType([o().bool,o().string,o().object]),semantic_zoom:o().oneOfType([o().bool,o().object]),keyboard:o().bool,overlay_click:o().bool,stylesheet:o().arrayOf(o().object),cytoscape_options:o().object,selection:o().shape({proteins:o().arrayOf(o().string),nodeIds:o().arrayOf(o().string),source:o().string}),compute_metrics:o().bool,metrics:o().object,last_event:o().object,network_info:o().object,error:o().string,export_request:o().object,export_result:o().object,setProps:o().func}})(),window.dash_contextnet=r})();
|
|
11
|
+
//# sourceMappingURL=dash_contextnet.min.js.map
|