diff --git a/ImportGraph/Cli.lean b/ImportGraph/Cli.lean index b4ab70d..763f8f7 100644 --- a/ImportGraph/Cli.lean +++ b/ImportGraph/Cli.lean @@ -8,6 +8,7 @@ import Batteries.Lean.IO.Process import ImportGraph.CurrentModule import ImportGraph.Imports import ImportGraph.Lean.Name +import ImportGraph.Gexf open Cli @@ -62,6 +63,18 @@ open Lean Core System open IO.FS IO.Process Name in /-- Implementation of the import graph command line program. -/ def importGraphCLI (args : Cli.Parsed) : IO UInt32 := do + -- file extensions that should be created + let extensions : Std.HashSet String := match args.variableArgsAs! String with + | #[] => Std.HashSet.empty.insert "dot" + | outputs => outputs.foldl (fun acc (o : String) => + match FilePath.extension o with + | none => acc.insert "dot" + | some "gexf" => acc.insert "gexf" + | some "html" => acc.insert "gexf" + -- currently all other formats are handled by passing the `.dot` file to + -- graphviz + | some _ => acc.insert "dot" ) {} + let to ← match args.flag? "to" with | some to => pure <| to.as! ModuleName | none => getCurrentModule @@ -69,7 +82,8 @@ def importGraphCLI (args : Cli.Parsed) : IO UInt32 := do | some fr => some <| fr.as! ModuleName | none => none searchPathRef.set compile_time_search_path% - let dotFile ← try unsafe withImportModules #[{module := to}] {} (trustLevel := 1024) fun env => do + + let outFiles ← try unsafe withImportModules #[{module := to}] {} (trustLevel := 1024) fun env => do let p := ImportGraph.getModule to let mut graph := env.importGraph let unused ← @@ -130,7 +144,20 @@ def importGraphCLI (args : Cli.Parsed) : IO UInt32 := do let markedModule : Option Name := if args.hasFlag "mark-module" then p else none - return asDotGraph graph (unused := unused) (markedModule := markedModule) (directDeps := directDeps) + -- Create all output files that are requested + let mut outFiles : Std.HashMap String String := {} + if extensions.contains "dot" then + let dotFile := asDotGraph graph (unused := unused) (markedModule := markedModule) (directDeps := directDeps) + outFiles := outFiles.insert "dot" dotFile + if extensions.contains "gexf" then + -- filter out the top node as it makes the graph less pretty + let graph₂ := match args.flag? "to" with + | none => graph.filter (fun n _ => n != to) + | some _ => graph + let gexfFile := Graph.toGexf graph₂ p env + outFiles := outFiles.insert "gexf" gexfFile + return outFiles + catch err => -- TODO: try to build `to` first, so this doesn't happen throw <| IO.userError <| s!"{err}\nIf the error above says `unknown package`, " ++ @@ -138,14 +165,35 @@ def importGraphCLI (args : Cli.Parsed) : IO UInt32 := do throw err match args.variableArgsAs! String with - | #[] => writeFile "import_graph.dot" dotFile + | #[] => writeFile "import_graph.dot" (outFiles["dot"]!) | outputs => for o in outputs do let fp : FilePath := o match fp.extension with | none - | "dot" => writeFile fp dotFile + | "dot" => writeFile fp (outFiles["dot"]!) + | "gexf" => IO.FS.writeFile fp (outFiles["gexf"]!) + | "html" => + let gexfFile := (outFiles["gexf"]!) + -- use `html-template/index.html` and insert any dependencies to make it + -- a stand-alone HTML file. + -- note: changes in `index.html` might need to be reflected here! + let exeDir := (FilePath.parent (← IO.appPath) |>.get!) / ".." / ".." / ".." + let mut html ← IO.FS.readFile <| ← IO.FS.realPath ( exeDir / "html-template" / "index.html") + for dep in (#[ + "vendor" / "sigma.min.js", + "vendor" / "graphology.min.js", + "vendor" / "graphology-library.min.js" ] : Array FilePath) do + let depContent ← IO.FS.readFile <| ← IO.FS.realPath (exeDir / "html-template" / dep) + html := html.replace s!"" s!"" + -- inline the graph data + -- note: changes in `index.html` might need to be reflected here! + let escapedFile := gexfFile.replace "\n" "" |>.replace "\"" "\\\"" + html := html + |>.replace "fetch(\"imports.gexf\").then((res) => res.text()).then(render_gexf)" s!"render_gexf(\"{escapedFile}\")" + |>.replace "

Import Graph

" s!"

Import Graph for {to}

" + IO.FS.writeFile fp html | some ext => try - _ ← runCmdWithInput "dot" #["-T" ++ ext, "-o", o] dotFile + _ ← runCmdWithInput "dot" #["-T" ++ ext, "-o", o] (outFiles["dot"]!) catch ex => IO.eprintln s!"Error occurred while writing out {fp}." IO.eprintln s!"Make sure you have `graphviz` installed and the file is writable." diff --git a/ImportGraph/Gexf.lean b/ImportGraph/Gexf.lean new file mode 100644 index 0000000..b1d6c0c --- /dev/null +++ b/ImportGraph/Gexf.lean @@ -0,0 +1,70 @@ +/- +Copyright (c) 2024 Jon Eugster. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Jon Eugster +-/ + +import Lean +import Batteries.Lean.NameMap +import Batteries.Tactic.OpenPrivate + +open Lean + +namespace ImportGraph + +open Elab Meta in +/-- Filter Lean internal declarations -/ +def isBlackListed (env : Environment) (declName : Name) : Bool := + declName == ``sorryAx + || declName matches .str _ "inj" + || declName matches .str _ "noConfusionType" + || declName.isInternalDetail + || isAuxRecursor env declName + || isNoConfusion env declName + || isRecCore env declName + || isMatcherCore env declName + +/-- Get number of non-blacklisted declarations per file. -/ +def getNumberOfDeclsPerFile (env: Environment) : NameMap Nat := + env.const2ModIdx.fold (fun acc n (idx : ModuleIdx) => + let mod := env.allImportedModuleNames.get! idx + if isBlackListed env n then acc else acc.insert mod ((acc.findD mod 0) + 1) + ) {} + +/-- Gexf template for a node in th graph. -/ +def Gexf.nodeTemplate (n module : Name) (size : Nat) := s!"\n " + +/-- Gexf template for an edge in the graph -/ +def Gexf.edgeTemplate (source target : Name) := s!"\n " + +open Gexf in +/-- Creates a `.gexf` file of the graph, see https://gexf.net/ + +Metadata can be stored in forms of attributes, currently we record the following: +* `decl_count` (Nat): number of declarations in the file +* `in_module` (Bool): whether the file belongs to the main module + (used to strip the first part of the name when displaying). +-/ +def Graph.toGexf (graph : NameMap (Array Name)) (module : Name) (env : Environment) : String := + let sizes : NameMap Nat := getNumberOfDeclsPerFile env + let nodes : String := graph.fold (fun acc n _ => acc ++ nodeTemplate n module (sizes.findD n 0)) "" + let edges : String := graph.fold (fun acc n i => acc ++ (i.foldl (fun b j => b ++ edgeTemplate j n) "")) "" + s!" + + + Lean ImportGraph + + + + + + + + {nodes.trim} + + + {edges.trim} + + + + " diff --git a/Main.lean b/Main.lean index 2104d4f..80b5ee6 100644 --- a/Main.lean +++ b/Main.lean @@ -30,7 +30,7 @@ def graph : Cmd := `[Cli| ...outputs : String; "Filename(s) for the output. \ If none are specified, generates `import_graph.dot`. \ Automatically chooses the format based on the file extension. \ - Currently `.dot` is supported, \ + Currently supported formats are `.dot`, `.gexf`, `.html`, \ and if you have `graphviz` installed then any supported output format is allowed." ] diff --git a/README.md b/README.md index 9c81dd1..5c11ce8 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ lake exe graph --to MyModule my_graph.pdf ``` where `MyModule` follows the same module naming you would use to `import` it in lean. See `lake exe graph --help` for more options. +### Troubleshoot + +* make sure to `lake build` your project (or the specified `--to` module) before using `lake exe graph`! + ### Json To create a Json file, you can use `.xdot_json` as output type: @@ -32,6 +36,24 @@ To create a Json file, you can use `.xdot_json` as output type: lake exe graph my_graph.xdot_json ``` +### HTML + +``` +lake exe graph my_graph.html +``` + +creates a stand-alone HTML file visualising the import structure. + +## Commands + +There are a few commands implemented, which help you analysing the imports of a file. These are accessible by adding `import ImportGraph.Imports` to your lean file. + +* `#redundant_imports`: lists any transitively redundant imports in the current module. +* `#min_imports`: attempts to construct a minimal set of imports for the declarations + in the current file. + (Must be run at the end of the file. Tactics and macros may result in incorrect output.) +* `#find_home decl`: suggests files higher up the import hierarchy to which `decl` could be moved. + ## Installation The installation works exactly like for any [Lake package](https://reservoir.lean-lang.org/). @@ -55,20 +77,18 @@ rev = "main" Then, you might need to call `lake update -R importGraph` in your project. -## Commands +## Contribution -There are a few commands implemented, which help you analysing the imports of a file. These are accessible by adding `import ImportGraph.Imports` to your lean file. - -* `#redundant_imports`: lists any transitively redundant imports in the current module. -* `#min_imports`: attempts to construct a minimal set of imports for the declarations - in the current file. - (Must be run at the end of the file. Tactics and macros may result in incorrect output.) -* `#find_home decl`: suggests files higher up the import hierarchy to which `decl` could be moved. +Please open PRs/Issues if you have troubles or would like to contribute new features! ## Credits -This code has been extracted from [mathlib](https://github.com/leanprover-community/mathlib4) and has mainly been written by Kim Morrison and a few other mathlib contributors. +The main tool has been extracted from [mathlib](https://github.com/leanprover-community/mathlib4), +originally written by Kim Morrison and other mathlib contributors. + +The HTML visualisation has been incorporated from +[a project by Eric Wieser](https://github.com/eric-wieser/mathlib-import-graph). ### Maintainers -For issues, questions, or feature requests, please reach out to [Jon Eugster](https://leanprover.zulipchat.com/#narrow/dm/385895-Jon-Eugster). +Primarily maintained by [Jon Eugster](https://leanprover.zulipchat.com/#narrow/dm/385895-Jon-Eugster), Kim Morrison, and the wider leanprover community. diff --git a/html-template/.gitignore b/html-template/.gitignore new file mode 100644 index 0000000..f029659 --- /dev/null +++ b/html-template/.gitignore @@ -0,0 +1 @@ +imports.gexf diff --git a/html-template/README.md b/html-template/README.md new file mode 100644 index 0000000..6648c0a --- /dev/null +++ b/html-template/README.md @@ -0,0 +1,26 @@ +# Visualised import graph + +## Instructions + +To test this, place a file `imports.gexf` inside this directory. You can create such a file with + +``` +lake exe graph html-template/imports.gexf +``` + +Then open `index.html` in any browser and you should see the graph. + +## Development + +Currently `lake exe graph output.html` will use the files here to create a stand-alone +HTML file. It does so by search-replacing the JS-scripts, the `fetch('imports.gexf')` +statement, and the `

` header. + +Therefore any modifications to these lines need to be reflected in `ImportGraph/Cli.lean`! + +# Credits + +This tool has been adapted from it's [Lean 3 version](https://github.com/eric-wieser/mathlib-import-graph) written by Eric Wieser, which was published under the [MIT License](./LICENSE_source) +included here. + +Adaptation by Jon Eugster. diff --git a/html-template/index.html b/html-template/index.html new file mode 100644 index 0000000..c5b70f5 --- /dev/null +++ b/html-template/index.html @@ -0,0 +1,516 @@ + + + + + + + Mathlib import graph + + + + + + + + + + +
+
+ +

Import Graph

+

Built with Sigma.js. + Node sizes indicate the number of declarations in the file.

+ +
+
+
    +
    +

    Hover over a node to show only the files importing it. Hover over a directory name to highlight only the files in that directory

    +
    +
    +
    + + + + + diff --git a/html-template/vendor/graphology-library.min.js b/html-template/vendor/graphology-library.min.js new file mode 100644 index 0000000..6fc8588 --- /dev/null +++ b/html-template/vendor/graphology-library.min.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).graphologyLibrary={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={},n={};var i=function(){this.__data__=[],this.size=0};var o=function(t,e){return t===e||t!=t&&e!=e},a=o;var s=function(t,e){for(var r=t.length;r--;)if(a(t[r][0],e))return r;return-1},u=s,h=Array.prototype.splice;var c=s;var l=s;var d=s;var f=i,g=function(t){var e=this.__data__,r=u(e,t);return!(r<0)&&(r==e.length-1?e.pop():h.call(e,r,1),--this.size,!0)},p=function(t){var e=this.__data__,r=c(e,t);return r<0?void 0:e[r][1]},y=function(t){return l(this.__data__,t)>-1},v=function(t,e){var r=this.__data__,n=d(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function m(t){var e=-1,r=null==t?0:t.length;for(this.clear();++es))return!1;var h=o.get(t),c=o.get(e);if(h&&c)return h==e&&c==t;var l=-1,d=!0,f=2&r?new ie:void 0;for(o.set(t,e),o.set(e,t);++l-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991},Ge=F,He=Be,Ke=ke,Ve={};Ve["[object Float32Array]"]=Ve["[object Float64Array]"]=Ve["[object Int8Array]"]=Ve["[object Int16Array]"]=Ve["[object Int32Array]"]=Ve["[object Uint8Array]"]=Ve["[object Uint8ClampedArray]"]=Ve["[object Uint16Array]"]=Ve["[object Uint32Array]"]=!0,Ve["[object Arguments]"]=Ve["[object Array]"]=Ve["[object ArrayBuffer]"]=Ve["[object Boolean]"]=Ve["[object DataView]"]=Ve["[object Date]"]=Ve["[object Error]"]=Ve["[object Function]"]=Ve["[object Map]"]=Ve["[object Number]"]=Ve["[object Object]"]=Ve["[object RegExp]"]=Ve["[object Set]"]=Ve["[object String]"]=Ve["[object WeakMap]"]=!1;var $e=function(t){return Ke(t)&&He(t.length)&&!!Ve[Ge(t)]};var Je=function(t){return function(e){return t(e)}},Qe={exports:{}};!function(t,e){var r=M,n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n&&r.process,a=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=a}(Qe,Qe.exports);var Xe=$e,Ye=Je,Ze=Qe.exports,tr=Ze&&Ze.isTypedArray,er=tr?Ye(tr):Xe,rr=je,nr=Te,ir=be,or=Le.exports,ar=Re,sr=er,ur=Object.prototype.hasOwnProperty;var hr=function(t,e){var r=ir(t),n=!r&&nr(t),i=!r&&!n&&or(t),o=!r&&!n&&!i&&sr(t),a=r||n||i||o,s=a?rr(t.length,String):[],u=s.length;for(var h in t)!e&&!ur.call(t,h)||a&&("length"==h||i&&("offset"==h||"parent"==h)||o&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ar(h,u))||s.push(h);return s},cr=Object.prototype;var lr=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||cr)};var dr=function(t,e){return function(r){return t(e(r))}},fr=dr(Object.keys,Object),gr=lr,pr=fr,yr=Object.prototype.hasOwnProperty;var vr=H,mr=Be;var br=function(t){return null!=t&&mr(t.length)&&!vr(t)},wr=hr,Er=function(t){if(!gr(t))return pr(t);var e=[];for(var r in Object(t))yr.call(t,r)&&"constructor"!=r&&e.push(r);return e},Ar=br;var xr=Ae,zr=Ne,Mr=function(t){return Ar(t)?wr(t):Er(t)};var Sr=function(t){return xr(t,Mr,zr)},Nr=Object.prototype.hasOwnProperty;var jr=function(t,e,r,n,i,o){var a=1&r,s=Sr(t),u=s.length;if(u!=Sr(e).length&&!a)return!1;for(var h=u;h--;){var c=s[h];if(!(a?c in e:Nr.call(e,c)))return!1}var l=o.get(t),d=o.get(e);if(l&&d)return l==e&&d==t;var f=!0;o.set(t,e),o.set(e,t);for(var g=a;++h0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}},Mn=zn(An),Sn=fn,Nn=yn,jn=Mn;var kn=function(t,e){return jn(Nn(t,e,Sn),t+"")},Dn=bn;var On=function(t,e,r){"__proto__"==e&&Dn?Dn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r},_n=On,Cn=o;var Wn=function(t,e,r){(void 0!==r&&!Cn(t[e],r)||void 0===r&&!(e in t))&&_n(t,e,r)};var Pn=function(t){return function(e,r,n){for(var i=-1,o=Object(e),a=n(e),s=a.length;s--;){var u=a[t?s:++i];if(!1===r(o[u],u,o))break}return e}}(),In={exports:{}};!function(t,e){var r=j,n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n?r.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=a?a(r):new t.constructor(r);return t.copy(n),n}}(In,In.exports);var Un=ue;var Tn=function(t){var e=new t.constructor(t.byteLength);return new Un(e).set(new Un(t)),e};var Ln=function(t,e){var r=e?Tn(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};var Fn=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(o=t.length>3&&"function"==typeof o?(i--,o):void 0,a&&ro(r[0],r[1],a)&&(o=i<3?void 0:o,i=1),e=Object(e);++n0&&t.undirectedSize>0?"mixed":t.directedSize>0?"directed":"undirected"};function fo(t){Object.defineProperty(this,"_next",{writable:!1,enumerable:!1,value:t}),this.done=!1}fo.prototype.next=function(){if(this.done)return{done:!0};var t=this._next();return t.done&&(this.done=!0),t},"undefined"!=typeof Symbol&&(fo.prototype[Symbol.iterator]=function(){return this}),fo.of=function(){var t=arguments,e=t.length,r=0;return new fo((function(){return r>=e?{done:!0}:{done:!1,value:t[r++]}}))},fo.empty=function(){var t=new fo(null);return t.done=!0,t},fo.is=function(t){return t instanceof fo||"object"==typeof t&&null!==t&&"function"==typeof t.next};var go=fo,po={};!function(t){var e=Math.pow(2,8)-1,r=Math.pow(2,16)-1,n=Math.pow(2,32)-1,i=Math.pow(2,7)-1,o=Math.pow(2,15)-1,a=Math.pow(2,31)-1;t.getPointerArray=function(t){var i=t-1;if(i<=e)return Uint8Array;if(i<=r)return Uint16Array;if(i<=n)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},t.getSignedPointerArray=function(t){var e=t-1;return e<=i?Int8Array:e<=o?Int16Array:e<=a?Int32Array:Float64Array},t.getNumberType=function(t){return t===(0|t)?-1===Math.sign(t)?t<=127&&t>=-128?Int8Array:t<=32767&&t>=-32768?Int16Array:Int32Array:t<=255?Uint8Array:t<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};t.getMinimalRepresentation=function(e,r){var n,i,o,a,u,h=null,c=0;for(a=0,u=e.length;ac&&(c=n,h=i);return h},t.isTypedArray=function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView(t)},t.concat=function(){var t,e,r,n=0;for(t=0,r=arguments.length;t=this.size||this.dense[e]!==t)&&(e=this.dense[this.size-1],this.dense[this.sparse[t]]=e,this.sparse[e]=this.sparse[t],this.size--,!0)},mo.prototype.forEach=function(t,e){e=arguments.length>1?e:this;for(var r=0;r=this.start&&e=this.start&&e1?e:this;for(var r=this.capacity,n=this.size,i=this.start,o=0;o=r)return{done:!0};var o=t[n];return n++,i++,n===e&&(n=0),{value:o,done:!1}}))},"undefined"!=typeof Symbol&&(Ao.prototype[Symbol.iterator]=Ao.prototype.values),Ao.prototype.inspect=function(){var t=[];return this.forEach((function(e){t.push(e)})),Object.defineProperty(t,"constructor",{value:Ao,enumerable:!1}),t.capacity=this.capacity,t},"undefined"!=typeof Symbol&&(Ao.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ao.prototype.inspect);var xo=Ao;function zo(t){return function(e,r){return e+Math.floor(t()*(r-e+1))}}var Mo=zo(Math.random);Mo.createRandom=zo;var So=Mo.createRandom;function No(t){var e=So(t);return function(t){return"number"!=typeof t&&(t=t.length),e(0,t-1)}}var jo=No(Math.random);jo.createRandomIndex=No;var ko=jo,Do={},Oo=po,_o=Symbol.for("nodejs.util.inspect.custom"),Co={weight:"weight"},Wo=1;function Po(t,e){var r=(e=e||{}).attributes||{},n=!0===e.keepDendrogram,i="number"==typeof e.resolution?e.resolution:Wo,o=!0===e.weighted,a=r.weight||Co.weight,s=2*(t.size-t.selfLoopCount),u=Oo.getPointerArray(s),h=Oo.getPointerArray(t.order+1),c=o?Float64Array:Oo.getPointerArray(2*t.size);this.C=t.order,this.M=0,this.E=s,this.U=0,this.resolution=i,this.level=0,this.graph=t,this.nodes=new Array(t.order),this.keepDendrogram=n,this.neighborhood=new h(s),this.weights=new c(s),this.loops=new c(t.order),this.starts=new u(t.order+1),this.belongings=new h(t.order),this.dendrogram=[],this.mapping=null,this.counts=new h(t.order),this.unused=new h(t.order),this.totalWeights=new c(t.order);var l,d={},f=0,g=0,p=this;t.forEachNode((function(e){p.nodes[f]=e,d[e]=f,g+=t.undirectedDegree(e,!1),p.starts[f]=g,p.belongings[f]=f,p.counts[f]=1,f++})),t.forEachEdge((function(t,e,r,n){if(l=function(t){if(!o)return 1;var e=t[a];return"number"!=typeof e||isNaN(e)?1:e}(e),r=d[r],n=d[n],p.M+=l,r===n)p.totalWeights[r]+=2*l,p.loops[r]=2*l;else{p.totalWeights[r]+=l,p.totalWeights[n]+=l;var i=--p.starts[r],s=--p.starts[n];p.neighborhood[i]=n,p.neighborhood[s]=r,p.weights[i]=l,p.weights[s]=l}})),this.starts[f]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}function Io(t,e){var r=(e=e||{}).attributes||{},n=!0===e.keepDendrogram,i="number"==typeof e.resolution?e.resolution:Wo,o=!0===e.weighted,a=r.weight||Co.weight,s=2*(t.size-t.selfLoopCount),u=Oo.getPointerArray(s),h=Oo.getPointerArray(t.order+1),c=o?Float64Array:Oo.getPointerArray(2*t.size);this.C=t.order,this.M=0,this.E=s,this.U=0,this.resolution=i,this.level=0,this.graph=t,this.nodes=new Array(t.order),this.keepDendrogram=n,this.neighborhood=new h(s),this.weights=new c(s),this.loops=new c(t.order),this.starts=new u(t.order+1),this.offsets=new u(t.order),this.belongings=new h(t.order),this.dendrogram=[],this.counts=new h(t.order),this.unused=new h(t.order),this.totalInWeights=new c(t.order),this.totalOutWeights=new c(t.order);var l,d={},f=0,g=0,p=this;t.forEachNode((function(e){p.nodes[f]=e,d[e]=f,g+=t.outDegree(e,!1),p.starts[f]=g,g+=t.inDegree(e,!1),p.offsets[f]=g,p.belongings[f]=f,p.counts[f]=1,f++})),t.forEachEdge((function(t,e,r,n){if(l=function(t){if(!o)return 1;var e=t[a];return"number"!=typeof e||isNaN(e)?1:e}(e),r=d[r],n=d[n],p.M+=l,r===n)p.loops[r]+=l,p.totalInWeights[r]+=l,p.totalOutWeights[r]+=l;else{p.totalOutWeights[r]+=l,p.totalInWeights[n]+=l;var i=--p.starts[r],s=--p.offsets[n];p.neighborhood[i]=n,p.neighborhood[s]=r,p.weights[i]=l,p.weights[s]=l}})),this.starts[f]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}Po.prototype.isolate=function(t,e){var r=this.belongings[t];if(1===this.counts[r])return r;var n=this.unused[--this.U],i=this.loops[t];return this.totalWeights[r]-=e+i,this.totalWeights[n]+=e+i,this.belongings[t]=n,this.counts[r]--,this.counts[n]++,n},Po.prototype.move=function(t,e,r){var n=this.belongings[t],i=this.loops[t];this.totalWeights[n]-=e+i,this.totalWeights[r]+=e+i,this.belongings[t]=r;var o=1==this.counts[n]--;this.counts[r]++,o&&(this.unused[this.U++]=n)},Po.prototype.computeNodeDegree=function(t){var e,r,n=0;for(e=this.starts[t],r=this.starts[t+1];et:n>i}function Jo(t,e,r){var n,i,o,a,s,u,h,c,l,d,f,g,p,y,v,m,b,w,E,A=new Go(e,{attributes:{weight:r.attributes.weight},keepDendrogram:t,resolution:r.resolution,weighted:r.weighted}),x=Ro(r.rng),z=!0,M=!0,S=new Fo(Float64Array,A.C),N=0,j=0,k=[];for(r.fastLocalMoves&&(o=new qo(A.C));z;){if(g=A.C,z=!1,M=!0,r.fastLocalMoves){for(E=0,c=r.randomWalk?x(g):0,l=0;lh.length&&(h=r),e=s-u.size,h.length>e)return h}return h},ta.stronglyConnectedComponents=function(t){if(!ra(t))throw new Error("graphology-components: the given graph is not a valid graphology instance.");if(!t.order)return[];if("undirected"===t.type)throw new Error("graphology-components: the given graph is undirected");var e,r,n=t.nodes(),i=[];if(!t.size){for(e=0,r=n.length;en;)h.pop()}else f(r);if(l.get(h[h.length-1])===l.get(e)){o=[];do{a=c.pop(),o.push(a),d.add(a)}while(a!==e);i.push(o),h.pop()}};for(e=0,r=n.length;e0&&s.addEdge(n,(n-1)%a)}return s.addEdge(0,a-1),s};var Ba={},Ga=sa,Ha=ho;function Ka(t,e){return 2*e/(t*(t-1))}function Va(t,e){return e/(t*(t-1))}function $a(t,e){var r=t*(t-1);return e/(r+r/2)}function Ja(t){var e,r,n=t.nodes(),i=0;for(e=0,r=n.length;e3){if(i=arguments[3],"number"!=typeof(n=r))throw new Error("graphology-metrics/density: given order is not a number.");if("number"!=typeof i)throw new Error("graphology-metrics/density: given size is not a number.")}else{if(!Ha(r))throw new Error("graphology-metrics/density: given graph is not a valid graphology instance.");n=r.order,i=r.size,r.multi&&!1===e&&(i=Ja(r))}return n<2?0:(null===t&&(t=r.type),null===e&&(e=r.multi),("undirected"===t?Ka:"directed"===t?Va:$a)(n,i))}var Xa=Qa.bind(null,null,null);Xa.directedDensity=Qa.bind(null,"directed",!1),Xa.undirectedDensity=Qa.bind(null,"undirected",!1),Xa.mixedDensity=Qa.bind(null,"mixed",!1),Xa.multiDirectedDensity=Qa.bind(null,"directed",!0),Xa.multiUndirectedDensity=Qa.bind(null,"undirected",!0),Xa.multiMixedDensity=Qa.bind(null,"mixed",!0);var Ya=Xa,Za=sa,ts=Ya;function es(t,e){if(!Za(t))throw new Error("graphology-generators/random/erdos-renyi: invalid Graph constructor.");var r,n,i=e.order,o=e.probability,a=e.rng||Math.random,s=new t;"number"==typeof e.approximateSize&&(o=(0,ts[s.type+"Density"])(i,e.approximateSize));if("number"!=typeof i||i<=0)throw new Error("graphology-generators/random/erdos-renyi: invalid `order`. Should be a positive number.");if("number"!=typeof o||o<0||o>1)throw new Error("graphology-generators/random/erdos-renyi: invalid `probability`. Should be a number between 0 and 1. Or maybe you gave an `approximateSize` exceeding the graph's density.");if("function"!=typeof a)throw new Error("graphology-generators/random/erdos-renyi: invalid `rng`. Should be a function.");for(r=0;r1)throw new Error("graphology-generators/random/erdos-renyi: invalid `probability`. Should be a number between 0 and 1. Or maybe you gave an `approximateSize` exceeding the graph's density.");if("function"!=typeof i)throw new Error("graphology-generators/random/erdos-renyi: invalid `rng`. Should be a function.");for(var a=0;a=s&&s1||r<0)throw new Error("graphology-generators/random/clusters: `clusterDensity` option should be a number between 0 and 1.");if("function"!=typeof n)throw new Error("graphology-generators/random/clusters: `rng` option should be a function.");if("number"!=typeof i||i<=0)throw new Error("graphology-generators/random/clusters: `order` option should be a positive number.");if("number"!=typeof o||o<=0)throw new Error("graphology-generators/random/clusters: `size` option should be a positive number.");if("number"!=typeof a||a<=0)throw new Error("graphology-generators/random/clusters: `clusters` option should be a positive number.");var s=new t;if(!i)return s;var u,h,c,l,d,f,g=new Array(a);for(c=0;c"+i,n,i);return s},oa.classic=aa,oa.community=Ta,oa.random=Ba,oa.small=is,oa.social=us;var gs=oa,ps=uo,ys=ho,vs={attributes:{authority:"authority",hub:"hub",weight:"weight"},maxIterations:100,normalize:!0,tolerance:1e-8};function ms(t,e){var r,n,i=Object.create(null);for(r=0,n=t.length;rh&&(h=i[a]);for(f=0;fc&&(c=w[a]);for(o in d=1/c,w)w[o]*=d;for(o in d=1/h,i)i[o]*=d;for(o in l=0,w)l+=Math.abs(w[o]-n[o]);if(l0&&r*r>n*n+i*i}function Ts(t,e){for(var r=0;r(a*=a)?(n=(h+a-i)/(2*h),o=Math.sqrt(Math.max(0,a/h-n*n)),r.x=t.x-n*s-o*u,r.y=t.y-n*u+o*s):(n=(h+i-a)/(2*h),o=Math.sqrt(Math.max(0,i/h-n*n)),r.x=e.x+n*s-o*u,r.y=e.y+n*u+o*s)):(r.x=e.x+r.r,r.y=e.y)}function Hs(t,e){var r=t.r+e.r-1e-6,n=e.x-t.x,i=e.y-t.y;return r>0&&r*r>n*n+i*i}function Ks(t,e){var r,n,i,o,a,s,u,h,c,l,d=t.length;if(0===d)return 0;if((r=t[0]).x=0,r.y=0,d<=1)return r.r;if(n=t[1],r.x=-n.r,n.x=r.r,n.y=0,d<=2)return r.r+n.r;Gs(n,r,i=t[2]),r=new Ws(null,null,null,null,r),n=new Ws(null,null,null,null,n),i=new Ws(null,null,null,null,i),r.next=i.previous=n,n.next=r.previous=i,i.next=n.previous=r;t:for(s=3;s0},Ws.prototype.addChild=function(t,e){this.children[t]=e,++this.countChildren},Ws.prototype.getChild=function(t){if(!this.children.hasOwnProperty(t)){var e=new Ws;this.children[t]=e,++this.countChildren}return this.children[t]},Ws.prototype.applyPositionToChildren=function(){if(this.hasChildren()){var t=this;for(var e in t.children){var r=t.children[e];r.x+=t.x,r.y+=t.y,r.applyPositionToChildren()}}};var Qs=Js.bind(null,!1);Qs.assign=Js.bind(null,!0);var Xs=Qs,Ys=uo,Zs=zs,tu={attributes:{x:"x",y:"y"},center:.5,scale:1};function eu(t,e,r){if(!Zs(e))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");r=Ys(r,tu);var n,i,o,a,s={},u=e.nodes(),h=r.center,c=r.scale,l=2*Math.PI,d=u.length;for(a=0;a= 0."}:"scalingRatio"in t&&"number"!=typeof t.scalingRatio&&t.scalingRatio<0?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&"number"!=typeof t.gravity&&t.gravity<0?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&"number"!=typeof t.slowDown&&t.slowDown<0?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&"number"!=typeof t.barnesHutTheta&&t.barnesHutTheta<0?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},gu.graphToByteArrays=function(t){var e,r=t.order,n=t.size,i={},o=new Float32Array(10*r),a=new Float32Array(3*n);return e=0,t.forEachNode((function(r,n){i[r]=e,o[e]=n.x,o[e+1]=n.y,o[e+2]=0,o[e+3]=0,o[e+4]=0,o[e+5]=0,o[e+6]=1+t.degree(r),o[e+7]=1,o[e+8]=n.size||1,o[e+9]=n.fixed?1:0,e+=10})),e=0,t.forEachEdge((function(t,r,n,o){a[e]=i[n],a[e+1]=i[o],a[e+2]=r.weight||0,e+=3})),{nodes:o,edges:a}},gu.assignLayoutChanges=function(t,e){var r=0;t.updateEachNodeAttributes((function(t,n){return n.x=e[r],n.y=e[r+1],r+=10,n}),{attributes:["x","y"]})},gu.collectLayoutChanges=function(t,e){for(var r=t.nodes(),n={},i=0,o=0,a=e.length;iL?U=(I-=(T-L)/2)+T:P=(W-=(L-T)/2)+L,D[0]=-1,D[1]=(W+P)/2,D[2]=(I+U)/2,D[3]=Math.max(P-W,U-I),D[4]=-1,D[5]=-1,D[6]=0,D[7]=0,D[8]=0,n=1,o=0;o=0)){if(D[i+0]<0){D[i+0]=o;break}if(D[i+5]=9*n,c=D[i+3]/2,D[(l=D[i+5])+0]=-1,D[l+1]=D[i+1]-c,D[l+2]=D[i+2]-c,D[l+3]=c,D[l+4]=l+9,D[l+5]=-1,D[l+6]=0,D[l+7]=0,D[l+8]=0,D[(l+=9)+0]=-1,D[l+1]=D[i+1]-c,D[l+2]=D[i+2]+c,D[l+3]=c,D[l+4]=l+9,D[l+5]=-1,D[l+6]=0,D[l+7]=0,D[l+8]=0,D[(l+=9)+0]=-1,D[l+1]=D[i+1]+c,D[l+2]=D[i+2]-c,D[l+3]=c,D[l+4]=l+9,D[l+5]=-1,D[l+6]=0,D[l+7]=0,D[l+8]=0,D[(l+=9)+0]=-1,D[l+1]=D[i+1]+c,D[l+2]=D[i+2]+c,D[l+3]=c,D[l+4]=D[i+4],D[l+5]=-1,D[l+6]=0,D[l+7]=0,D[l+8]=0,n+=4,O=e[D[i+0]+0]=0){if(m=Math.pow(e[o+0]-D[i+7],2)+Math.pow(e[o+1]-D[i+8],2),4*(d=D[i+3])*d/m0?(b=g*e[o+6]*D[i+6]/m,e[o+2]+=p*b,e[o+3]+=y*b):m<0&&(b=-g*e[o+6]*D[i+6]/Math.sqrt(m),e[o+2]+=p*b,e[o+3]+=y*b):m>0&&(b=g*e[o+6]*D[i+6]/m,e[o+2]+=p*b,e[o+3]+=y*b),(i=D[i+4])<0)break;continue}i=D[i+5]}else if((u=D[i+0])>=0&&u!==o&&(m=(p=e[o+0]-e[u+0])*p+(y=e[o+1]-e[u+1])*y,!0===j?m>0?(b=g*e[o+6]*e[u+6]/m,e[o+2]+=p*b,e[o+3]+=y*b):m<0&&(b=-g*e[o+6]*e[u+6]/Math.sqrt(m),e[o+2]+=p*b,e[o+3]+=y*b):m>0&&(b=g*e[o+6]*e[u+6]/m,e[o+2]+=p*b,e[o+3]+=y*b)),(i=D[i+4])<0)break}else for(g=t.scalingRatio,a=0;a0?(b=g*e[a+6]*e[s+6]/m/m,e[a+2]+=p*b,e[a+3]+=y*b,e[s+2]+=p*b,e[s+3]+=y*b):m<0&&(b=100*g*e[a+6]*e[s+6],e[a+2]+=p*b,e[a+3]+=y*b,e[s+2]-=p*b,e[s+3]-=y*b):(m=Math.sqrt(p*p+y*y))>0&&(b=g*e[a+6]*e[s+6]/m/m,e[a+2]+=p*b,e[a+3]+=y*b,e[s+2]-=p*b,e[s+3]-=y*b);for(l=t.gravity/t.scalingRatio,g=t.scalingRatio,o=0;o0&&(b=g*e[o+6]*l):m>0&&(b=g*e[o+6]*l/m),e[o+2]-=p*b,e[o+3]-=y*b;for(g=1*(t.outboundAttractionDistribution?f:1),h=0;h0&&(b=-g*v*Math.log(1+m)/m/e[a+6]):m>0&&(b=-g*v*Math.log(1+m)/m):t.outboundAttractionDistribution?m>0&&(b=-g*v/e[a+6]):m>0&&(b=-g*v)):(m=Math.sqrt(Math.pow(p,2)+Math.pow(y,2)),t.linLogMode?t.outboundAttractionDistribution?m>0&&(b=-g*v*Math.log(1+m)/m/e[a+6]):m>0&&(b=-g*v*Math.log(1+m)/m):t.outboundAttractionDistribution?(m=1,b=-g*v/e[a+6]):(m=1,b=-g*v)),m>0&&(e[a+2]+=p*b,e[a+3]+=y*b,e[s+2]-=p*b,e[s+3]-=y*b);if(!0===j)for(o=0;o10&&(e[o+2]=10*e[o+2]/w,e[o+3]=10*e[o+3]/w),E=e[o+6]*Math.sqrt((e[o+4]-e[o+2])*(e[o+4]-e[o+2])+(e[o+5]-e[o+3])*(e[o+5]-e[o+3])),A=Math.sqrt((e[o+4]+e[o+2])*(e[o+4]+e[o+2])+(e[o+5]+e[o+3])*(e[o+5]+e[o+3]))/2,x=.1*Math.log(1+A)/(1+Math.sqrt(E)),z=e[o+0]+e[o+2]*(x/t.slowDown),e[o+0]=z,M=e[o+1]+e[o+3]*(x/t.slowDown),e[o+1]=M);else for(o=0;o2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}};var Au=Eu;function xu(){return.01*(.5-Math.random())}var zu={};zu.validateSettings=function(t){return"gridSize"in t&&"number"!=typeof t.gridSize||t.gridSize<=0?{message:"the `gridSize` setting should be a positive number."}:"margin"in t&&"number"!=typeof t.margin||t.margin<0?{message:"the `margin` setting should be 0 or a positive number."}:"expansion"in t&&"number"!=typeof t.expansion||t.expansion<=0?{message:"the `expansion` setting should be a positive number."}:"ratio"in t&&"number"!=typeof t.ratio||t.ratio<=0?{message:"the `ratio` setting should be a positive number."}:"speed"in t&&"number"!=typeof t.speed||t.speed<=0?{message:"the `speed` setting should be a positive number."}:null},zu.graphToByteArray=function(t,e){var r=t.order,n=new Float32Array(3*r),i=0;return t.forEachNode((function(t,r){"function"==typeof e&&(r=e(t,r)),n[i]=r.x,n[i+1]=r.y,n[i+2]=r.size||1,i+=3})),n},zu.assignLayoutChanges=function(t,e,r){var n=0;t.forEachNode((function(i){var o={x:e[n],y:e[n+1]};"function"==typeof r&&(o=r(i,o)),t.mergeNodeAttributes(i,o),n+=3}))},zu.collectLayoutChanges=function(t,e,r){var n={},i=0;return t.forEachNode((function(t){var o={x:e[i],y:e[i+1]};"function"==typeof r&&(o=r(t,o)),n[t]=o,i+=3})),n},zu.createWorker=function(t){var e=window.URL||window.webkitURL,r=t.toString(),n=e.createObjectURL(new Blob(["("+r+").call(this);"],{type:"text/javascript"})),i=new Worker(n);return e.revokeObjectURL(n),i};var Mu=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi},Su=function(t,e){var r,n,i,o,a,s,u=t.margin,h=t.ratio,c=t.expansion,l=t.gridSize,d=t.speed,f=!0,g=e.length,p=g/3|0,y=new Float32Array(p),v=new Float32Array(p),m=1/0,b=1/0,w=-1/0,E=-1/0;for(r=0;r1&&Y.has($)||(L>1&&Y.add($),B=e[q+0],H=e[q+1],V=e[q+2],J=B-R,Q=H-G,(X=Math.sqrt(J*J+Q*Q))0?(y[q]+=J/X*(1+K),v[q]+=Q/X*(1+K)):(y[q]+=A*xu(),v[q]+=x*xu())));for(r=0,n=0;rthis.capacity&&(t-=this.capacity),this.items[t]}},Hu.prototype.get=function(t){if(0!==this.size)return(t=this.start+t)>this.capacity&&(t-=this.capacity),this.items[t]},Hu.prototype.forEach=function(t,e){e=arguments.length>1?e:this;for(var r=this.capacity,n=this.size,i=this.start,o=0;o=r)return{done:!0};var o=t[n];return n++,i++,n===e&&(n=0),{value:o,done:!1}}))},Hu.prototype.entries=function(){var t=this.items,e=this.capacity,r=this.size,n=this.start,i=0;return new Gu((function(){if(i>=r)return{done:!0};var o=t[n];return++n===e&&(n=0),{value:[i++,o],done:!1}}))},"undefined"!=typeof Symbol&&(Hu.prototype[Symbol.iterator]=Hu.prototype.values),Hu.prototype.inspect=function(){var t=this.toArray();return t.type=this.ArrayClass.name,t.capacity=this.capacity,Object.defineProperty(t,"constructor",{value:Hu,enumerable:!1}),t},"undefined"!=typeof Symbol&&(Hu.prototype[Symbol.for("nodejs.util.inspect.custom")]=Hu.prototype.inspect),Hu.from=function(t,e,r){if(arguments.length<3&&"number"!=typeof(r=Bu.guessLength(t)))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var n=new Hu(e,r);if(Bu.isArrayLike(t)){var i,o;for(i=0,o=t.length;i1?e:this;for(var r=0,n=this.items.length;r=e)return{done:!0};var n=t[e-r-1];return r++,{value:n,done:!1}}))},Ju.prototype.entries=function(){var t=this.items,e=this.size,r=0;return new Vu((function(){if(r>=e)return{done:!0};var n=t[e-r-1];return{value:[r++,n],done:!1}}))},"undefined"!=typeof Symbol&&(Ju.prototype[Symbol.iterator]=Ju.prototype.values),Ju.prototype.toString=function(){return this.toArray().join(",")},Ju.prototype.toJSON=function(){return this.toArray()},Ju.prototype.inspect=function(){var t=this.toArray();return t.type=this.ArrayClass.name,t.capacity=this.capacity,Object.defineProperty(t,"constructor",{value:Ju,enumerable:!1}),t},"undefined"!=typeof Symbol&&(Ju.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ju.prototype.inspect),Ju.from=function(t,e,r){if(arguments.length<3&&"number"!=typeof(r=$u.guessLength(t)))throw new Error("mnemonist/fixed-stack.from: could not guess iterable length. Please provide desired capacity as last argument.");var n=new Ju(e,r);if($u.isArrayLike(t)){var i,o;for(i=0,o=t.length;ie?1:0},Xu.DEFAULT_REVERSE_COMPARATOR=function(t,e){return te?-1:0},Xu.reverseComparator=function(t){return function(e,r){return t(r,e)}},Xu.createTupleComparator=function(t){return 2===t?function(t,e){return t[0]e[0]?1:t[1]e[1]?1:0}:function(e,r){for(var n=0;nr[n])return 1;n++}return 0}};var Yu=Lu,Zu=Xu,th=Pu,eh=Zu.DEFAULT_COMPARATOR,rh=Zu.reverseComparator;function nh(t,e,r,n){for(var i,o,a=e[n];n>r&&t(a,o=e[i=n-1>>1])<0;)e[n]=o,n=i;e[n]=a}function ih(t,e,r){for(var n,i=e.length,o=r,a=e[r],s=2*r+1;s=0&&(s=n),e[r]=e[s],s=2*(r=s)+1;e[r]=a,nh(t,e,o,r)}function oh(t,e,r){e.push(r),nh(t,e,0,e.length-1)}function ah(t,e){var r=e.pop();if(0!==e.length){var n=e[0];return e[0]=r,ih(t,e,0),n}return r}function sh(t,e,r){if(0===e.length)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var n=e[0];return e[0]=r,ih(t,e,0),n}function uh(t,e,r){var n;return 0!==e.length&&t(e[0],r)<0&&(n=e[0],e[0]=r,r=n,ih(t,e,0)),r}function hh(t,e){for(var r=e.length>>1;--r>=0;)ih(t,e,r)}function ch(t,e){for(var r=e.length,n=0,i=new Array(r);n=r.length)return r.slice().sort(t);for(a=r.slice(0,e),hh(s,a),n=e,i=r.length;n0&&sh(s,a,r[n]);return a.sort(t)}var h=th.guessLength(r);return null!==h&&h0&&sh(s,a,t)),n++})),a.length>n&&(a.length=n),a.sort(t)},lh.nlargest=function(t,e,r){2===arguments.length&&(r=e,e=t,t=eh);var n,i,o,a,s=rh(t),u=-1/0;if(1===e){if(th.isArrayLike(r)){for(n=0,i=r.length;n0)&&(u=o);return(a=new r.constructor(1))[0]=u,a}return Yu(r,(function(e){(u===-1/0||t(e,u)>0)&&(u=e)})),[u]}if(th.isArrayLike(r)){if(e>=r.length)return r.slice().sort(s);for(a=r.slice(0,e),hh(t,a),n=e,i=r.length;n0&&sh(t,a,r[n]);return a.sort(s)}var h=th.guessLength(r);return null!==h&&h0&&sh(t,a,r)),n++})),a.length>n&&(a.length=n),a.sort(s)},lh.MinHeap=lh,lh.MaxHeap=dh;var fh=lh,gh={},ph=po;function yh(t){var e=t.directedSize+2*t.undirectedSize,r=ph.getPointerArray(e),n=ph.getPointerArray(t.order);this.graph=t,this.neighborhood=new n(e),this.starts=new r(t.order+1),this.nodes=t.nodes();var i,o,a,s,u,h,c={},l=0;for(i=0,o=t.order;ie[0]?1:t[0]e[1]?1:t[1]e[2]?1:t[2]e[3]?1:t[3]2?e[2]:void 0;for(i&&jh(e[0],e[1],i)&&(n=1);++r=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,t}},Qh.prototype.peek=function(){if(this.size)return this.items[this.offset]},Qh.prototype.forEach=function(t,e){e=arguments.length>1?e:this;for(var r=this.offset,n=0,i=this.items.length;r=t.length)return{done:!0};var r=t[e];return e++,{value:r,done:!1}}))},Qh.prototype.entries=function(){var t=this.items,e=this.offset,r=0;return new $h((function(){if(e>=t.length)return{done:!0};var n=t[e];return e++,{value:[r++,n],done:!1}}))},"undefined"!=typeof Symbol&&(Qh.prototype[Symbol.iterator]=Qh.prototype.values),Qh.prototype.toString=function(){return this.toArray().join(",")},Qh.prototype.toJSON=function(){return this.toArray()},Qh.prototype.inspect=function(){var t=this.toArray();return Object.defineProperty(t,"constructor",{value:Qh,enumerable:!1}),t},"undefined"!=typeof Symbol&&(Qh.prototype[Symbol.for("nodejs.util.inspect.custom")]=Qh.prototype.inspect),Qh.from=function(t){var e=new Qh;return Jh(t,(function(t){e.enqueue(t)})),e},Qh.of=function(){return Qh.from(arguments)};var Xh=ho,Yh=Qh,Zh=ea;function tc(t,e,r){if(!Xh(t))throw new Error("graphology-shortest-path: invalid graphology instance.");if(arguments.length<3)throw new Error("graphology-shortest-path: invalid number of arguments. Expecting at least 3.");if(!t.hasNode(e))throw new Error('graphology-shortest-path: the "'+e+'" source node does not exist in the given graph.');if(!t.hasNode(r))throw new Error('graphology-shortest-path: the "'+r+'" target node does not exist in the given graph.');if((e=""+e)===(r=""+r))return[e];var n=t.inboundNeighbors.bind(t),i=t.outboundNeighbors.bind(t),o={},a={};o[e]=null,a[r]=null;var s,u,h,c,l,d,f,g,p=[e],y=[r],v=!1;t:for(;p.length&&y.length;)if(p.length<=y.length){for(s=p,p=[],l=0,f=s.length;li&&(i=n),a++;return aa[n][1]&&(a[n][1]=r)})),"string"==typeof e?a[e]:a}var gc=fc;gc.nodeExtent=fc,gc.edgeExtent=function(t,e){if(!dc(t))throw new Error("graphology-metrics/extent: the given graph is not a valid graphology instance.");var r,n,i,o=[].concat(e),a={};for(i=0;ia[n][1]&&(a[n][1]=r)})),"string"==typeof e?a[e]:a};var pc=gc,yc={},vc=ho;var mc=Xu,bc=fh,wc=mc.DEFAULT_COMPARATOR,Ec=mc.reverseComparator;function Ac(t,e,r,n){for(var i,o=r,a=n,s=e[n],u=2*n+1;u=0&&(u=i),e[n]=e[u],u=2*(n=u)+1;e[n]=s,bc.siftDown(t,e,a,n)}function xc(t,e,r,n){for(var i,o,a=n,s=new t(n);a>0;)i=r[--a],0!==a&&(o=r[0],r[0]=i,Ac(e,r,--n,0),i=o),s[a]=i;return s}function zc(t,e,r){if(2===arguments.length&&(r=e,e=null),this.ArrayClass=t,this.capacity=r,this.items=new t(r),this.clear(),this.comparator=e||wc,"number"!=typeof r&&r<=0)throw new Error("mnemonist/FixedReverseHeap.constructor: capacity should be a number > 0.");if("function"!=typeof this.comparator)throw new Error("mnemonist/FixedReverseHeap.constructor: given comparator should be a function.");this.comparator=Ec(this.comparator)}zc.prototype.clear=function(){this.size=0},zc.prototype.push=function(t){return this.size0&&bc.replace(this.comparator,this.items,t),this.size},zc.prototype.peek=function(){return this.items[0]},zc.prototype.consume=function(){var t=xc(this.ArrayClass,this.comparator,this.items,this.size);return this.size=0,t},zc.prototype.toArray=function(){return xc(this.ArrayClass,this.comparator,this.items.slice(0,this.size),this.size)},zc.prototype.inspect=function(){var t=this.toArray();return Object.defineProperty(t,"constructor",{value:zc,enumerable:!1}),t},"undefined"!=typeof Symbol&&(zc.prototype[Symbol.for("nodejs.util.inspect.custom")]=zc.prototype.inspect);var Mc=zc,Sc={},Nc=new Float64Array(64),jc=new Float64Array(64);Sc.inplaceQuickSort=function(t,e,r){var n,i,o,a,s;for(Nc[0]=e,jc[0]=r,i=0;i>=0;)if((o=Nc[i])<(a=jc[i]-1)){for(n=t[o];o=n&&ojc[i-1]-Nc[i-1]&&(s=Nc[i],Nc[i]=Nc[i-1],Nc[i-1]=s,s=jc[i],jc[i]=jc[i-1],jc[i-1]=s)}else i--;return t},Sc.inplaceQuickSortIndices=function(t,e,r,n){var i,o,a,s,u,h;for(Nc[0]=r,jc[0]=n,o=0;o>=0;)if((a=Nc[o])<(s=jc[o]-1)){for(i=t[u=e[a]];a=i&&ajc[o-1]-Nc[o-1]&&(h=Nc[o],Nc[o]=Nc[o-1],Nc[o-1]=h,h=jc[o],jc[o]=jc[o-1],jc[o-1]=h)}else o--;return e};var kc=Pu,Dc=po,Oc=Xu.createTupleComparator,_c=Mc,Cc=Sc.inplaceQuickSortIndices;function Wc(t,e,r,n){var i,o,a=0;for(i=0;i>>1)],g[m]=u,o>-1&&(0===a?p[o]=m+1:y[o]=m+1),l=(l+1)%t,s!==h&&s!==c-1&&v.push([l,s+1,c,m,1]),s!==h&&v.push([l,h,s,m,0]),m++;return{axes:e,labels:n,pivots:g,lefts:p,rights:y}}function Ic(t,e){this.dimensions=t,this.visited=0,this.axes=e.axes,this.labels=e.labels,this.pivots=e.pivots,this.lefts=e.lefts,this.rights=e.rights,this.size=this.labels.length}Ic.prototype.nearestNeighbor=function(t){var e=1/0,r=null,n=this.dimensions,i=this.axes,o=this.pivots,a=this.lefts,s=this.rights,u=0;return function h(c,l){u++;var d=a[l],f=s[l],g=o[l],p=Wc(n,i,g,t);if(!(p0?0!==d&&h(c,d-1):0!==f&&h(c,f-1),y*y0?0!==f&&h(c,f-1):0!==d&&h(c,d-1))}}(0,0),this.visited=u,this.labels[r]};var Uc=Oc(3),Tc=Oc(2);Ic.prototype.kNearestNeighbors=function(t,e){if(t<=0)throw new Error("mnemonist/kd-tree.kNearestNeighbors: k should be a positive number.");if(1===(t=Math.min(t,this.size)))return[this.nearestNeighbor(e)];var r=new _c(Array,Uc,t),n=this.dimensions,i=this.axes,o=this.pivots,a=this.lefts,s=this.rights,u=0;!function h(c,l){var d=a[l],f=s[l],g=o[l],p=Wc(n,i,g,e);r.push([p,u++,g]);var y=e[c],v=i[c][g],m=y-v;c=(c+1)%n,ye.size)return!1;for(;!(r=n.next()).done;)if(!e.has(r.value))return!1;return!0},t.isSuperset=function(e,r){return t.isSubset(r,e)},t.add=function(t,e){for(var r,n=e.values();!(r=n.next()).done;)t.add(r.value)},t.subtract=function(t,e){for(var r,n=e.values();!(r=n.next()).done;)t.delete(r.value)},t.intersect=function(t,e){for(var r,n=t.values();!(r=n.next()).done;)e.has(r.value)||t.delete(r.value)},t.disjunct=function(t,e){for(var r,n=t.values(),i=[];!(r=n.next()).done;)e.has(r.value)&&i.push(r.value);for(n=e.values();!(r=n.next()).done;)t.has(r.value)||t.add(r.value);for(var o=0,a=i.length;oe.size&&(r=t,t=e,e=r),0===t.size)return 0;if(t===e)return t.size;for(var n,i=t.values(),o=0;!(n=i.next()).done;)e.has(n.value)&&o++;return o},t.unionSize=function(e,r){var n=t.intersectionSize(e,r);return e.size+r.size-n},t.jaccard=function(e,r){var n=t.intersectionSize(e,r);return 0===n?0:n/(e.size+r.size-n)},t.overlap=function(e,r){var n=t.intersectionSize(e,r);return 0===n?0:n/Math.min(e.size,r.size)}}(Fc);var qc=ho,Rc=Lc,Bc=Fc.intersectionSize,Gc=ho,Hc=ac.undirectedSingleSourceLength;yc.edgeUniformity=function(t){if(!vc(t))throw new Error("graphology-metrics/layout-quality/edge-uniformity: given graph is not a valid graphology instance.");if(0===t.size)return 0;var e,r=0,n=0,i=new Float64Array(t.size);t.forEachEdge((function(t,e,o,a,s,u){var h,c,l=(h=s,c=u,Math.sqrt(Math.pow(h.x-c.x,2)+Math.pow(h.y-c.y,2)));i[n++]=l,r+=l}));var o=r/t.size,a=0;for(n=0,e=t.size;ne&&(e=r),e!==1/0);i++);return e},_u.eccentricity=hc,_u.extent=pc,_u.layoutQuality=yc,_u.modularity=nl,_u.weightedDegree=cl,_u.weightedSize=function(t,e){if(!ll(t))throw new Error("graphology-metrics/weighted-size: the given graph is not a valid graphology instance.");e=e||"weight";var r,n,i,o=t.edges(),a=0;for(n=0,i=o.length;ne[0]?1:t[0]e[1]?1:t[1]e[2]?1:t[2]e[0]?1:t[0]e[1]?1:t[1]e[2]?1:t[2]e[3]?1:t[3]l)&&(w=l,b=o[0][f].concat(o[1][f].slice(0,-1).reverse()))))}}return[1/0,null]}(t,e,r,n)[1]},singleSource:function(t,e,r){var n={};return function(t,e,r,n,i,o){if(!_l(t))throw new Error("graphology-shortest-path/dijkstra: invalid graphology instance.");if(i&&!t.hasNode(i))throw new Error('graphology-shortest-path/dijkstra: the "'+i+'" target node does not exist in the given graph.');r=r||Wl;var a,s,u,h,c,l,d,f,g,p,y,v,m,b={},w={},E=new Cl(Pl),A=0;for(f=0,p=e.length;fn)){if(c in b&&uF?T=(U-=(L-F)/2)+L:I=(P-=(F-L)/2)+F,O[0]=-1,O[1]=(P+I)/2,O[2]=(U+T)/2,O[3]=Math.max(I-P,T-U),O[4]=-1,O[5]=-1,O[6]=0,O[7]=0,O[8]=0,i=1,a=0;a=0)){if(O[o+0]<0){O[o+0]=a;break}if(O[o+5]=9*i,l=O[o+3]/2,O[(d=O[o+5])+0]=-1,O[d+1]=O[o+1]-l,O[d+2]=O[o+2]-l,O[d+3]=l,O[d+4]=d+9,O[d+5]=-1,O[d+6]=0,O[d+7]=0,O[d+8]=0,O[(d+=9)+0]=-1,O[d+1]=O[o+1]-l,O[d+2]=O[o+2]+l,O[d+3]=l,O[d+4]=d+9,O[d+5]=-1,O[d+6]=0,O[d+7]=0,O[d+8]=0,O[(d+=9)+0]=-1,O[d+1]=O[o+1]+l,O[d+2]=O[o+2]-l,O[d+3]=l,O[d+4]=d+9,O[d+5]=-1,O[d+6]=0,O[d+7]=0,O[d+8]=0,O[(d+=9)+0]=-1,O[d+1]=O[o+1]+l,O[d+2]=O[o+2]+l,O[d+3]=l,O[d+4]=O[o+4],O[d+5]=-1,O[d+6]=0,O[d+7]=0,O[d+8]=0,i+=4,_=r[O[o+0]+0]=0){if(b=Math.pow(r[a+0]-O[o+7],2)+Math.pow(r[a+1]-O[o+8],2),4*(f=O[o+3])*f/b0?(w=p*r[a+6]*O[o+6]/b,r[a+2]+=y*w,r[a+3]+=v*w):b<0&&(w=-p*r[a+6]*O[o+6]/Math.sqrt(b),r[a+2]+=y*w,r[a+3]+=v*w):b>0&&(w=p*r[a+6]*O[o+6]/b,r[a+2]+=y*w,r[a+3]+=v*w),(o=O[o+4])<0)break;continue}o=O[o+5]}else if((h=O[o+0])>=0&&h!==a&&(b=(y=r[a+0]-r[h+0])*y+(v=r[a+1]-r[h+1])*v,!0===k?b>0?(w=p*r[a+6]*r[h+6]/b,r[a+2]+=y*w,r[a+3]+=v*w):b<0&&(w=-p*r[a+6]*r[h+6]/Math.sqrt(b),r[a+2]+=y*w,r[a+3]+=v*w):b>0&&(w=p*r[a+6]*r[h+6]/b,r[a+2]+=y*w,r[a+3]+=v*w)),(o=O[o+4])<0)break}else for(p=e.scalingRatio,s=0;s0?(w=p*r[s+6]*r[u+6]/b/b,r[s+2]+=y*w,r[s+3]+=v*w,r[u+2]+=y*w,r[u+3]+=v*w):b<0&&(w=100*p*r[s+6]*r[u+6],r[s+2]+=y*w,r[s+3]+=v*w,r[u+2]-=y*w,r[u+3]-=v*w):(b=Math.sqrt(y*y+v*v))>0&&(w=p*r[s+6]*r[u+6]/b/b,r[s+2]+=y*w,r[s+3]+=v*w,r[u+2]-=y*w,r[u+3]-=v*w);for(d=e.gravity/e.scalingRatio,p=e.scalingRatio,a=0;a0&&(w=p*r[a+6]*d):b>0&&(w=p*r[a+6]*d/b),r[a+2]-=y*w,r[a+3]-=v*w;for(p=1*(e.outboundAttractionDistribution?g:1),c=0;c0&&(w=-p*m*Math.log(1+b)/b/r[s+6]):b>0&&(w=-p*m*Math.log(1+b)/b):e.outboundAttractionDistribution?b>0&&(w=-p*m/r[s+6]):b>0&&(w=-p*m)):(b=Math.sqrt(Math.pow(y,2)+Math.pow(v,2)),e.linLogMode?e.outboundAttractionDistribution?b>0&&(w=-p*m*Math.log(1+b)/b/r[s+6]):b>0&&(w=-p*m*Math.log(1+b)/b):e.outboundAttractionDistribution?(b=1,w=-p*m/r[s+6]):(b=1,w=-p*m)),b>0&&(r[s+2]+=y*w,r[s+3]+=v*w,r[u+2]-=y*w,r[u+3]-=v*w);if(!0===k)for(a=0;a10&&(r[a+2]=10*r[a+2]/E,r[a+3]=10*r[a+3]/E),A=r[a+6]*Math.sqrt((r[a+4]-r[a+2])*(r[a+4]-r[a+2])+(r[a+5]-r[a+3])*(r[a+5]-r[a+3])),x=Math.sqrt((r[a+4]+r[a+2])*(r[a+4]+r[a+2])+(r[a+5]+r[a+3])*(r[a+5]+r[a+3]))/2,z=.1*Math.log(1+x)/(1+Math.sqrt(A)),M=r[a+0]+r[a+2]*(z/e.slowDown),r[a+0]=M,S=r[a+1]+r[a+3]*(z/e.slowDown),r[a+1]=S);else for(a=0;a&\s]/g;md.sanitizeTagName=function(t){return t.replace(bd,"").trim()};var wd=id,Ed=gl.mergeEdge,Ad=md.cast;function xd(t,e){var r=t.getElementsByTagName("viz:"+e)[0];return r||(r=t.getElementsByTagNameNS("viz",e)[0]),r||(r=t.getElementsByTagName(e)[0]),r}function zd(t){for(var e,r,n,i,o={},a={},s=0,u=t.length;s0;t--)this.endElement();this.tags=0},startDocument:function(t,e,r){return this.tags||this.attributes||(this.startPI("xml"),this.startAttribute("version"),this.text("string"==typeof t?t:"1.0"),this.endAttribute(),"string"==typeof e&&(this.startAttribute("encoding"),this.text(e),this.endAttribute(),this.writer_encoding=e),r&&(this.startAttribute("standalone"),this.text("yes"),this.endAttribute()),this.endPI(),this.indent||this.write("\n")),this},endDocument:function(){return this.attributes&&this.endAttributes(),this},writeElement:function(t,e){return this.startElement(t).text(e).endElement()},writeElementNS:function(t,e,r,n){return n||(n=r),this.startElementNS(t,e,r).text(n).endElement()},startElement:function(t){if(!(t=jd(t)).match(this.name_regex))throw Error("Invalid Parameter");if(0===this.tags&&this.root&&this.root!==t)throw Error("Invalid Parameter");return this.attributes&&this.endAttributes(),++this.tags,this.texts=0,this.stack.length>0&&(this.stack[this.stack.length-1].containsTag=!0),this.stack.push({name:t,tags:this.tags}),this.started_write&&this.indenter(),this.write("<",t),this.startAttributes(),this.started_write=!0,this},startElementNS:function(t,e,r){if(t=jd(t),e=jd(e),!t.match(this.name_regex))throw Error("Invalid Parameter");if(!e.match(this.name_regex))throw Error("Invalid Parameter");return this.attributes&&this.endAttributes(),++this.tags,this.texts=0,this.stack.length>0&&(this.stack[this.stack.length-1].containsTag=!0),this.stack.push({name:t+":"+e,tags:this.tags}),this.started_write&&this.indenter(),this.write("<",t+":"+e),this.startAttributes(),this.started_write=!0,this},endElement:function(){if(!this.tags)return this;var t=this.stack.pop();return this.attributes>0?(this.attribute&&(this.texts&&this.endAttribute(),this.endAttribute()),this.write("/"),this.endAttributes()):(t.containsTag&&this.indenter(),this.write("")),--this.tags,this.texts=0,this},writeAttribute:function(t,e){return"function"==typeof e&&(e=e()),Nd(e)?this:this.startAttribute(t).text(e).endAttribute()},writeAttributeNS:function(t,e,r,n){return n||(n=r),"function"==typeof n&&(n=n()),Nd(n)?this:this.startAttributeNS(t,e,r).text(n).endAttribute()},startAttributes:function(){return this.attributes=1,this},endAttributes:function(){return this.attributes?(this.attribute&&this.endAttribute(),this.attributes=0,this.attribute=0,this.texts=0,this.write(">"),this):this},startAttribute:function(t){if(!(t=jd(t)).match(this.name_regex))throw Error("Invalid Parameter");return this.attributes||this.pi?(this.attribute||(this.attribute=1,this.write(" ",t,'="')),this):this},startAttributeNS:function(t,e,r){if(t=jd(t),e=jd(e),!t.match(this.name_regex))throw Error("Invalid Parameter");if(!e.match(this.name_regex))throw Error("Invalid Parameter");return this.attributes||this.pi?(this.attribute||(this.attribute=1,this.write(" ",t+":"+e,'="')),this):this},endAttribute:function(){return this.attribute?(this.attribute=0,this.texts=0,this.write('"'),this):this},text:function(t){return t=jd(t),this.tags||this.comment||this.pi||this.cdata?this.attributes&&this.attribute?(++this.texts,this.write(t.replace(/&/g,"&").replace(//g,">")),++this.texts,this.started_write=!0,this):this},writeComment:function(t){return this.startComment().text(t).endComment()},startComment:function(){return this.comment||(this.attributes&&this.endAttributes(),this.indenter(),this.write("\x3c!--"),this.comment=1,this.started_write=!0),this},endComment:function(){return this.comment?(this.write("--\x3e"),this.comment=0,this):this},writeDocType:function(t,e,r,n){return this.startDocType(t,e,r,n).endDocType()},startDocType:function(t,e,r,n){if(this.dtd||this.tags)return this;if(t=jd(t),e=e?jd(e):e,r=r?jd(r):r,n=n?jd(n):n,!t.match(this.name_regex))throw Error("Invalid Parameter");if(e&&!e.match(/^[\w\-][\w\s\-\/\+\:\.]*/))throw Error("Invalid Parameter");if(r&&!r.match(/^[\w\.][\w\-\/\\\:\.]*/))throw Error("Invalid Parameter");if(n&&!n.match(/[\w\s\<\>\+\.\!\#\-\?\*\,\(\)\|]*/))throw Error("Invalid Parameter");return e=e?' PUBLIC "'+e+'"':r?" SYSTEM":"",r=r?' "'+r+'"':"",n=n?" ["+n+"]":"",this.started_write&&this.indenter(),this.write(""),this):this},writePI:function(t,e){return this.startPI(t).text(e).endPI()},startPI:function(t){if(!(t=jd(t)).match(this.name_regex))throw Error("Invalid Parameter");return this.pi||(this.attributes&&this.endAttributes(),this.started_write&&this.indenter(),this.write(""),this.pi=0,this):this},writeCData:function(t){return this.startCData().text(t).endCData()},startCData:function(){return this.cdata||(this.attributes&&this.endAttributes(),this.indenter(),this.write(""),this.cdata=0,this):this},writeRaw:function(t){return t=jd(t),this.tags||this.comment||this.pi||this.cdata?this.attributes&&this.attribute?(++this.texts,this.write(t.replace("&","&").replace('"',""")),this):(this.attributes&&!this.attribute&&this.endAttributes(),++this.texts,this.write(t),this.started_write=!0,this):this}};var Dd=ho,Od=lo,_d=kd,Cd=md.sanitizeTagName,Wd=new Set(["color","size","x","y","z","shape","thickness"]),Pd=/^\s*rgba?\s*\(/i,Id=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)\s*(?:,\s*([.0-9]*))?\)\s*$/;function Ud(t){if(!t||"string"!=typeof t)return{};if("#"===t[0])return 3===(t=t.slice(1)).length?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16)}:{r:parseInt(t[0]+t[1],16),g:parseInt(t[2]+t[3],16),b:parseInt(t[4]+t[5],16)};if(Pd.test(t)){var e={};return t=t.match(Id),e.r=+t[1],e.g=+t[2],e.b=+t[3],t[4]&&(e.a=+t[4]),e}return{}}function Td(t,e,r){var n,i={};for(n in r)"label"===n?i.label=r.label:"edge"===t&&"weight"===n?i.weight=r.weight:Wd.has(n)?(i.viz=i.viz||{},i.viz[n]=r[n]):(i.attributes=i.attributes||{},i.attributes[n]=r[n]);return i}function Ld(t){return null==t||""===t||t!=t}function Fd(t,e){return"liststring"===t&&Array.isArray(e)?e.join("|"):""+e}function qd(t){for(var e,r,n,i,o,a={},s=0,u=t.length;s=-2147483647?"integer":"long":"double":"string")&&(a[n]?"integer"===a[n]&&"long"===r?a[n]=r:a[n]!==r&&(a[n]="string"):a[n]=r);return a}function Rd(t,e,r){var n;if(Object.keys(e).length){for(n in t.startElement("attributes"),t.writeAttribute("class",r),e)t.startElement("attribute"),t.writeAttribute("id",n),t.writeAttribute("title",n),t.writeAttribute("type",e[n]),t.endElement();t.endElement()}}function Bd(t,e,r,n){var i,o,a,s,u,h,c,l,d,f,g,p=!Object.keys(r).length;for(t.startElement(e+"s"),f=0,g=n.length;f0&&a.length>i&&!a.warned){a.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=a.length,u=d,console&&console.warn&&console.warn(u)}return e}function S(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function A(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=S.bind(r);return i.listener=n,r.wrapFn=i,i}function L(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)w(u,this,t);else{var d=u.length,c=D(u,d);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},_.prototype.listeners=function(e){return L(this,e,!0)},_.prototype.rawListeners=function(e){return L(this,e,!1)},_.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):N.call(e,t)},_.prototype.listenerCount=N,_.prototype.eventNames=function(){return this._eventsCount>0?y(this._events):[]},U.prototype.next=function(){if(this.done)return{done:!0};var e=this._next();return e.done&&(this.done=!0),e},"undefined"!=typeof Symbol&&(U.prototype[Symbol.iterator]=function(){return this}),U.of=function(){var e=arguments,t=e.length,n=0;return new U((function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}}))},U.empty=function(){var e=new U(null);return e.done=!0,e},U.is=function(e){return e instanceof U||"object"==typeof e&&null!==e&&"function"==typeof e.next};var O=U,C=function(e,t){for(var n,r=arguments.length>1?t:1/0,i=r!==1/0?new Array(r):[],o=0;;){if(o===r)return i;if((n=e.next()).done)return o!==t?i.slice(0,o):i;i[o++]=n.value}},K=function(e){function n(t,n){var r;return(r=e.call(this)||this).name="GraphError",r.message=t||"",r.data=n||{},r}return t(n,e),n}(a(Error)),z=function(e){function n(t,r){var i;return(i=e.call(this,t,r)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(u(i),n.prototype.constructor),i}return t(n,e),n}(K),M=function(e){function n(t,r){var i;return(i=e.call(this,t,r)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(u(i),n.prototype.constructor),i}return t(n,e),n}(K),P=function(e){function n(t,r){var i;return(i=e.call(this,t,r)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(u(i),n.prototype.constructor),i}return t(n,e),n}(K);function T(e,t){this.key=e,this.attributes=t,this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.directedSelfLoops=0,this.undirectedSelfLoops=0,this.in={},this.out={},this.undirected={}}function R(e,t){this.key=e,this.attributes=t,this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}}function F(e,t){this.key=e,this.attributes=t,this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}}function I(e,t,n,r,i,o){this.key=t,this.attributes=o,this.undirected=e,this.source=r,this.target=i,this.generatedKey=n}function W(e,t,n,r,i,o,a){var u,d,c="out",s="in";if(t&&(c=s="undirected"),e.multi){if(void 0===(d=(u=o[c])[i])&&(d=new Set,u[i]=d),d.add(n),r===i&&t)return;void 0===(u=a[s])[r]&&(u[r]=d)}else{if(o[c][i]=n,r===i&&t)return;a[s][r]=n}}function Y(e,t,n){var r=e.multi,i=n.source,o=n.target,a=i.key,u=o.key,d=i[t?"undirected":"out"],c=t?"undirected":"in";if(u in d)if(r){var s=d[u];1===s.size?(delete d[u],delete o[c][a]):s.delete(n)}else delete d[u];r||delete o[c][a]}R.prototype.upgradeToMixed=function(){this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}},F.prototype.upgradeToMixed=function(){this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}};var B=[{name:function(e){return"get".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,a=""+r;if(r=arguments[2],!(i=c(this,o,a,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else if(e=""+e,!(i=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if("mixed"!==n&&i.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return i.attributes[r]}}},{name:function(e){return"get".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var i=""+e,o=""+arguments[1];if(!(r=c(this,i,o,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(i,'" - "').concat(o,'").'))}else if(e=""+e,!(r=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if("mixed"!==n&&r.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return r.attributes}}},{name:function(e){return"has".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,a=""+r;if(r=arguments[2],!(i=c(this,o,a,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else if(e=""+e,!(i=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if("mixed"!==n&&i.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return i.attributes.hasOwnProperty(r)}}},{name:function(e){return"set".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+e,u=""+r;if(r=arguments[2],i=arguments[3],!(o=c(this,a,u,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(u,'").'))}else if(e=""+e,!(o=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if("mixed"!==n&&o.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return o.attributes[r]=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(e){return"update".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+e,u=""+r;if(r=arguments[2],i=arguments[3],!(o=c(this,a,u,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(u,'").'))}else if(e=""+e,!(o=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if("function"!=typeof i)throw new z("Graph.".concat(t,": updater should be a function."));if("mixed"!==n&&o.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return o.attributes[r]=i(o.attributes[r]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(e){return"remove".concat(e,"Attribute")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,a=""+r;if(r=arguments[2],!(i=c(this,o,a,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else if(e=""+e,!(i=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if("mixed"!==n&&i.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return delete i.attributes[r],this.emit("edgeAttributesUpdated",{key:i.key,type:"remove",attributes:i.attributes,name:r}),this}}},{name:function(e){return"replace".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,a=""+r;if(r=arguments[2],!(i=c(this,o,a,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else if(e=""+e,!(i=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if(!h(r))throw new z("Graph.".concat(t,": provided attributes are not a plain object."));if("mixed"!==n&&i.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return i.attributes=r,this.emit("edgeAttributesUpdated",{key:i.key,type:"replace",attributes:i.attributes}),this}}},{name:function(e){return"merge".concat(e,"Attributes")},attacher:function(e,t,n){e.prototype[t]=function(e,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new P("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new P("Graph.".concat(t,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+e,a=""+r;if(r=arguments[2],!(i=c(this,o,a,n)))throw new M("Graph.".concat(t,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else if(e=""+e,!(i=this._edges.get(e)))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" edge in the graph.'));if(!h(r))throw new z("Graph.".concat(t,": provided attributes are not a plain object."));if("mixed"!==n&&i.undirected!==("undirected"===n))throw new M("Graph.".concat(t,': could not find the "').concat(e,'" ').concat(n," edge in the graph."));return d(i.attributes,r),this.emit("edgeAttributesUpdated",{key:i.key,type:"merge",attributes:i.attributes,data:r}),this}}}];var J=O,q=function(){var e,t=arguments,n=-1;return new J((function r(){if(!e){if(++n>=t.length)return{done:!0};e=t[n]}var i=e.next();return i.done?(e=null,r()):i}))},H=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function Q(e,t){for(var n in t)e.push(t[n].key)}function V(e,t){for(var n in t)t[n].forEach((function(t){return e.push(t.key)}))}function X(e,t,n){for(var r in e)if(r!==n){var i=e[r];t(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected,i.generatedKey)}}function Z(e,t,n){for(var r in e)r!==n&&e[r].forEach((function(e){return t(e.key,e.attributes,e.source.key,e.target.key,e.source.attributes,e.target.attributes,e.undirected,e.generatedKey)}))}function $(e,t,n){for(var r in e)if(r!==n){var i=e[r];if(t(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected,i.generatedKey))return!0}return!1}function ee(e,t,n){var r,i,o,a,u;for(var d in e)if(d!==n)for(r=e[d].values();!0!==(i=r.next()).done;)if(a=(o=i.value).source,u=o.target,t(o.key,o.attributes,a.key,u.key,a.attributes,u.attributes,o.undirected,o.generatedKey))return!0;return!1}function te(e,t){var n=Object.keys(e),r=n.length,i=null,o=0;return new O((function a(){var u;if(i){var d=i.next();if(d.done)return i=null,o++,a();u=d.value}else{if(o>=r)return{done:!0};var c=n[o];if(c===t)return o++,a();if((u=e[c])instanceof Set)return i=u.values(),a();o++}return{done:!1,value:[u.key,u.attributes,u.source.key,u.target.key,u.source.attributes,u.target.attributes]}}))}function ne(e,t,n){var r=t[n];r&&e.push(r.key)}function re(e,t,n){var r=t[n];r&&r.forEach((function(t){return e.push(t.key)}))}function ie(e,t,n){var r=e[t];if(r){var i=r.source,o=r.target;n(r.key,r.attributes,i.key,o.key,i.attributes,o.attributes,r.undirected,r.generatedKey)}}function oe(e,t,n){var r=e[t];r&&r.forEach((function(e){return n(e.key,e.attributes,e.source.key,e.target.key,e.source.attributes,e.target.attributes,e.undirected,e.generatedKey)}))}function ae(e,t,n){var r=e[t];if(!r)return!1;var i=r.source,o=r.target;return n(r.key,r.attributes,i.key,o.key,i.attributes,o.attributes,r.undirected,r.generatedKey)}function ue(e,t,n){var r=e[t];if(!r)return!1;for(var i,o,a=r.values();!0!==(i=a.next()).done;)if(n((o=i.value).key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected,o.generatedKey))return!0;return!1}function de(e,t){var n=e[t];if(n instanceof Set){var r=n.values();return new O((function(){var e=r.next();if(e.done)return e;var t=e.value;return{done:!1,value:[t.key,t.attributes,t.source.key,t.target.key,t.source.attributes,t.target.attributes]}}))}return O.of([n.key,n.attributes,n.source.key,n.target.key,n.source.attributes,n.target.attributes])}function ce(e,t){if(0===e.size)return[];if("mixed"===t||t===e.type)return"function"==typeof Array.from?Array.from(e._edges.keys()):C(e._edges.keys(),e._edges.size);for(var n,r,i="undirected"===t?e.undirectedSize:e.directedSize,o=new Array(i),a="undirected"===t,u=e._edges.values(),d=0;!0!==(n=u.next()).done;)(r=n.value).undirected===a&&(o[d++]=r.key);return o}function se(e,t,n){if(0!==e.size)for(var r,i,o="mixed"!==t&&t!==e.type,a="undirected"===t,u=e._edges.values();!0!==(r=u.next()).done;)if(i=r.value,!o||i.undirected===a){var d=i,c=d.key,s=d.attributes,h=d.source,f=d.target;n(c,s,h.key,f.key,h.attributes,f.attributes,i.undirected,i.generatedKey)}}function he(e,t,n){if(0===e.size)return!1;for(var r,i,o="mixed"!==t&&t!==e.type,a="undirected"===t,u=e._edges.values();!0!==(r=u.next()).done;)if(i=r.value,!o||i.undirected===a){var d=i,c=d.key,s=d.attributes,h=d.source,f=d.target;if(n(c,s,h.key,f.key,h.attributes,f.attributes,i.undirected,i.generatedKey))return!0}return!1}function fe(e,t){if(0===e.size)return O.empty();var n="mixed"!==t&&t!==e.type,r="undirected"===t,i=e._edges.values();return new O((function(){for(var e,t;;){if((e=i.next()).done)return e;if(t=e.value,!n||t.undirected===r)break}return{value:[t.key,t.attributes,t.source.key,t.target.key,t.source.attributes,t.target.attributes],done:!1}}))}function pe(e,t,n,r){var i=[],o=e?V:Q;return"undirected"!==t&&("out"!==n&&o(i,r.in),"in"!==n&&o(i,r.out),!n&&r.directedSelfLoops>0&&i.splice(i.lastIndexOf(r.key),1)),"directed"!==t&&o(i,r.undirected),i}function ge(e,t,n,r,i){var o=e?Z:X;"undirected"!==t&&("out"!==n&&o(r.in,i),"in"!==n&&o(r.out,i,n?null:r.key)),"directed"!==t&&o(r.undirected,i)}function le(e,t,n,r,i){var o=e?ee:$;if("undirected"!==t){if("out"!==n&&o(r.in,i))return!0;if("in"!==n&&o(r.out,i,n?null:r.key))return!0}return!("directed"===t||!o(r.undirected,i))}function ye(e,t,n){var r=O.empty();return"undirected"!==e&&("out"!==t&&void 0!==n.in&&(r=q(r,te(n.in))),"in"!==t&&void 0!==n.out&&(r=q(r,te(n.out,t?null:n.key)))),"directed"!==e&&void 0!==n.undirected&&(r=q(r,te(n.undirected))),r}function ve(e,t,n,r,i){var o=t?re:ne,a=[];return"undirected"!==e&&(void 0!==r.in&&"out"!==n&&o(a,r.in,i),void 0!==r.out&&"in"!==n&&o(a,r.out,i),!n&&r.directedSelfLoops>0&&a.splice(a.lastIndexOf(r.key),1)),"directed"!==e&&void 0!==r.undirected&&o(a,r.undirected,i),a}function be(e,t,n,r,i,o){var a=t?oe:ie;"undirected"!==e&&(void 0!==r.in&&"out"!==n&&a(r.in,i,o),r.key!==i&&void 0!==r.out&&"in"!==n&&a(r.out,i,o)),"directed"!==e&&void 0!==r.undirected&&a(r.undirected,i,o)}function we(e,t,n,r,i,o){var a=t?ue:ae;if("undirected"!==e){if(void 0!==r.in&&"out"!==n&&a(r.in,i,o))return!0;if(r.key!==i&&void 0!==r.out&&"in"!==n&&a(r.out,i,o,n?null:r.key))return!0}return!("directed"===e||void 0===r.undirected||!a(r.undirected,i,o))}function me(e,t,n,r){var i=O.empty();return"undirected"!==e&&(void 0!==n.in&&"out"!==t&&r in n.in&&(i=q(i,de(n.in,r))),void 0!==n.out&&"in"!==t&&r in n.out&&(i=q(i,de(n.out,r)))),"directed"!==e&&void 0!==n.undirected&&r in n.undirected&&(i=q(i,de(n.undirected,r))),i}var _e=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function ke(e,t){if(void 0!==t)for(var n in t)e.add(n)}function Ge(e,t,n){if("mixed"!==e){if("undirected"===e)return Object.keys(n.undirected);if("string"==typeof t)return Object.keys(n[t])}var r=new Set;return"undirected"!==e&&("out"!==t&&ke(r,n.in),"in"!==t&&ke(r,n.out)),"directed"!==e&&ke(r,n.undirected),C(r.values(),r.size)}function xe(e,t,n){for(var r in t){var i=t[r];i instanceof Set&&(i=i.values().next().value);var o=i.source,a=i.target,u=o===e?a:o;n(u.key,u.attributes)}}function Ee(e,t,n,r){for(var i in n){var o=n[i];o instanceof Set&&(o=o.values().next().value);var a=o.source,u=o.target,d=a===t?u:a;e.has(d.key)||(e.add(d.key),r(d.key,d.attributes))}}function Se(e,t,n){for(var r in t){var i=t[r];i instanceof Set&&(i=i.values().next().value);var o=i.source,a=i.target,u=o===e?a:o;if(n(u.key,u.attributes))return!0}return!1}function Ae(e,t,n,r){for(var i in n){var o=n[i];o instanceof Set&&(o=o.values().next().value);var a=o.source,u=o.target,d=a===t?u:a;if(!e.has(d.key))if(e.add(d.key),r(d.key,d.attributes))return!0}return!1}function Le(e,t){var n=Object.keys(t),r=n.length,i=0;return new O((function(){if(i>=r)return{done:!0};var o=t[n[i++]];o instanceof Set&&(o=o.values().next().value);var a=o.source,u=o.target,d=a===e?u:a;return{done:!1,value:[d.key,d.attributes]}}))}function Ne(e,t,n){var r=Object.keys(n),i=r.length,o=0;return new O((function a(){if(o>=i)return{done:!0};var u=n[r[o++]];u instanceof Set&&(u=u.values().next().value);var d=u.source,c=u.target,s=d===t?c:d;return e.has(s.key)?a():(e.add(s.key),{done:!1,value:[s.key,s.attributes]})}))}function De(e,t,n,r,i){var o=e._nodes.get(r);if("undirected"!==t){if("out"!==n&&void 0!==o.in)for(var a in o.in)if(a===i)return!0;if("in"!==n&&void 0!==o.out)for(var u in o.out)if(u===i)return!0}if("directed"!==t&&void 0!==o.undirected)for(var d in o.undirected)if(d===i)return!0;return!1}function je(e,t){var n=t.name,r=t.type,i=t.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(e,t){if("mixed"===r||"mixed"===this.type||r===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" node in the graph.'));!function(e,t,n,r){if("mixed"!==e){if("undirected"===e)return xe(n,n.undirected,r);if("string"==typeof t)return xe(n,n[t],r)}var i=new Set;"undirected"!==e&&("out"!==t&&Ee(i,n,n.in,r),"in"!==t&&Ee(i,n,n.out,r)),"directed"!==e&&Ee(i,n,n.undirected,r)}("mixed"===r?this.type:r,i,n,t)}}}function Ue(e,t){var n=t.name,r=t.type,i=t.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1)+"Until";e.prototype[o]=function(e,t){if("mixed"===r||"mixed"===this.type||r===this.type){e=""+e;var n=this._nodes.get(e);if(void 0===n)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n,r){if("mixed"!==e){if("undirected"===e)return Se(n,n.undirected,r);if("string"==typeof t)return Se(n,n[t],r)}var i=new Set;if("undirected"!==e){if("out"!==t&&Ae(i,n,n.in,r))return!0;if("in"!==t&&Ae(i,n,n.out,r))return!0}return!("directed"===e||!Ae(i,n,n.undirected,r))}("mixed"===r?this.type:r,i,n,t)}}}function Oe(e,t){var n=t.name,r=t.type,i=t.direction,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return O.empty();e=""+e;var t=this._nodes.get(e);if(void 0===t)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" node in the graph.'));return function(e,t,n){if("mixed"!==e){if("undirected"===e)return Le(n,n.undirected);if("string"==typeof t)return Le(n,n[t])}var r=O.empty(),i=new Set;return"undirected"!==e&&("out"!==t&&(r=q(r,Ne(i,n,n.in))),"in"!==t&&(r=q(r,Ne(i,n,n.out)))),"directed"!==e&&(r=q(r,Ne(i,n,n.undirected))),r}("mixed"===r?this.type:r,i,t)}}function Ce(e,t,n){for(var r,i,o,a,u,d,c,s=t._nodes.values(),h=t.type;!0!==(r=s.next()).done;){if(i=r.value,"undirected"!==h)for(o in a=i.out)if(d=(u=a[o]).target,c=n(i.key,d.key,i.attributes,d.attributes,u.key,u.attributes,u.undirected,u.generatedKey),e&&c)return!0;if("directed"!==h)for(o in a=i.undirected)if((d=(u=a[o]).target).key!==o&&(d=u.source),c=n(i.key,d.key,i.attributes,d.attributes,u.key,u.attributes,u.undirected,u.generatedKey),e&&c)return!0}return!1}function Ke(e,t,n){for(var r,i,o,a,u,d,c,s,h,f=t._nodes.values(),p=t.type;!0!==(r=f.next()).done;){if(i=r.value,"undirected"!==p)for(o in d=i.out)for(a=d[o].values();!0!==(u=a.next()).done;)if(s=(c=u.value).target,h=n(i.key,s.key,i.attributes,s.attributes,c.key,c.attributes,c.undirected,c.generatedKey),e&&h)return!0;if("directed"!==p)for(o in d=i.undirected)for(a=d[o].values();!0!==(u=a.next()).done;)if((s=(c=u.value).target).key!==o&&(s=c.source),h=n(i.key,s.key,i.attributes,s.attributes,c.key,c.attributes,c.undirected,c.generatedKey),e&&h)return!0}return!1}function ze(e,t){var n={key:e};return f(t.attributes)||(n.attributes=d({},t.attributes)),n}function Me(e,t){var n={source:t.source.key,target:t.target.key};return t.generatedKey||(n.key=e),f(t.attributes)||(n.attributes=d({},t.attributes)),t.undirected&&(n.undirected=!0),n}function Pe(e){return h(e)?"key"in e?!("attributes"in e)||h(e.attributes)&&null!==e.attributes?null:"invalid-attributes":"no-key":"not-object"}function Te(e){return h(e)?"source"in e?"target"in e?!("attributes"in e)||h(e.attributes)&&null!==e.attributes?"undirected"in e&&"boolean"!=typeof e.undirected?"invalid-undirected":null:"invalid-attributes":"no-target":"no-source":"not-object"}var Re=new Set(["directed","undirected","mixed"]),Fe=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ie={allowSelfLoops:!0,edgeKeyGenerator:null,multi:!1,type:"mixed"};function We(e,t,n){var r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function Ye(e,t,n,r,i,o,a,u){if(!r&&"undirected"===e.type)throw new P("Graph.".concat(t,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(r&&"directed"===e.type)throw new P("Graph.".concat(t,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(u&&!h(u))throw new z("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(u,'"'));if(o=""+o,a=""+a,u=u||{},!e.allowSelfLoops&&o===a)throw new P("Graph.".concat(t,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d=e._nodes.get(o),c=e._nodes.get(a);if(!d)throw new M("Graph.".concat(t,': source node "').concat(o,'" not found.'));if(!c)throw new M("Graph.".concat(t,': target node "').concat(a,'" not found.'));var s={key:null,undirected:r,source:o,target:a,attributes:u};if(n&&(i=e._edgeKeyGenerator(s)),i=""+i,e._edges.has(i))throw new P("Graph.".concat(t,': the "').concat(i,'" edge already exists in the graph.'));if(!e.multi&&(r?void 0!==d.undirected[a]:void 0!==d.out[a]))throw new P("Graph.".concat(t,': an edge linking "').concat(o,'" to "').concat(a,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var f=new I(r,i,n,d,c,u);return e._edges.set(i,f),o===a?r?(d.undirectedSelfLoops++,e._undirectedSelfLoopCount++):(d.directedSelfLoops++,e._directedSelfLoopCount++):r?(d.undirectedDegree++,c.undirectedDegree++):(d.outDegree++,c.inDegree++),W(e,r,f,o,a,d,c),r?e._undirectedSize++:e._directedSize++,s.key=i,e.emit("edgeAdded",s),i}function Be(e,t,n,r,i,o,a,u,c){if(!r&&"undirected"===e.type)throw new P("Graph.".concat(t,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(r&&"directed"===e.type)throw new P("Graph.".concat(t,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(u)if(c){if("function"!=typeof u)throw new z("Graph.".concat(t,': invalid updater function. Expecting a function but got "').concat(u,'"'))}else if(!h(u))throw new z("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(u,'"'));var s;if(o=""+o,a=""+a,c&&(s=u,u=void 0),!e.allowSelfLoops&&o===a)throw new P("Graph.".concat(t,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var f,p,g=e._nodes.get(o),l=e._nodes.get(a);if(!n&&(f=e._edges.get(i))){if(f.source.key!==o||f.target.key!==a||r&&(f.source.key!==a||f.target.key!==o))throw new P("Graph.".concat(t,': inconsistency detected when attempting to merge the "').concat(i,'" edge with "').concat(o,'" source & "').concat(a,'" target vs. ("').concat(f.source.key,'", "').concat(f.target.key,'").'));p=f}if(p||e.multi||!g||(p=r?g.undirected[a]:g.out[a]),p){if(c?!s:!u)return p.key;if(c){var y=p.attributes;p.attributes=s(y),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else d(p.attributes,u),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:u});return p.key}u=u||{},c&&s&&(u=s(u));var v={key:null,undirected:r,source:o,target:a,attributes:u};if(n&&(i=e._edgeKeyGenerator(v)),i=""+i,e._edges.has(i))throw new P("Graph.".concat(t,': the "').concat(i,'" edge already exists in the graph.'));return g||(g=We(e,o,{}),o===a&&(l=g)),l||(l=We(e,a,{})),f=new I(r,i,n,g,l,u),e._edges.set(i,f),o===a?r?(g.undirectedSelfLoops++,e._undirectedSelfLoopCount++):(g.directedSelfLoops++,e._directedSelfLoopCount++):r?(g.undirectedDegree++,l.undirectedDegree++):(g.outDegree++,l.inDegree++),W(e,r,f,o,a,g,l),r?e._undirectedSize++:e._directedSize++,v.key=i,e.emit("edgeAdded",v),i}var Je=function(e){function n(t){var n;if(n=e.call(this)||this,(t=d({},Ie,t)).edgeKeyGenerator&&"function"!=typeof t.edgeKeyGenerator)throw new z("Graph.constructor: invalid 'edgeKeyGenerator' option. Expecting a function but got \"".concat(t.edgeKeyGenerator,'".'));if("boolean"!=typeof t.multi)throw new z("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!Re.has(t.type))throw new z('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(t.type,'".'));if("boolean"!=typeof t.allowSelfLoops)throw new z("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var r,i="mixed"===t.type?T:"directed"===t.type?R:F;return p(u(n),"NodeDataClass",i),p(u(n),"_attributes",{}),p(u(n),"_nodes",new Map),p(u(n),"_edges",new Map),p(u(n),"_directedSize",0),p(u(n),"_undirectedSize",0),p(u(n),"_directedSelfLoopCount",0),p(u(n),"_undirectedSelfLoopCount",0),p(u(n),"_edgeKeyGenerator",t.edgeKeyGenerator||(r=0,function(){return r++})),p(u(n),"_options",t),Fe.forEach((function(e){return p(u(n),e,n[e])})),g(u(n),"order",(function(){return n._nodes.size})),g(u(n),"size",(function(){return n._edges.size})),g(u(n),"directedSize",(function(){return n._directedSize})),g(u(n),"undirectedSize",(function(){return n._undirectedSize})),g(u(n),"selfLoopCount",(function(){return n._directedSelfLoopCount+n._undirectedSelfLoopCount})),g(u(n),"directedSelfLoopCount",(function(){return n._directedSelfLoopCount})),g(u(n),"undirectedSelfLoopCount",(function(){return n._undirectedSelfLoopCount})),g(u(n),"multi",n._options.multi),g(u(n),"type",n._options.type),g(u(n),"allowSelfLoops",n._options.allowSelfLoops),g(u(n),"implementation",(function(){return"graphology"})),n}t(n,e);var r=n.prototype;return r.hasNode=function(e){return this._nodes.has(""+e)},r.hasDirectedEdge=function(e,t){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+e,r=this._edges.get(n);return!!r&&!r.undirected}if(2===arguments.length){e=""+e,t=""+t;var i=this._nodes.get(e);if(!i)return!1;var o=i.out[t];return!!o&&(!this.multi||!!o.size)}throw new z("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},r.hasUndirectedEdge=function(e,t){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+e,r=this._edges.get(n);return!!r&&r.undirected}if(2===arguments.length){e=""+e,t=""+t;var i=this._nodes.get(e);if(!i)return!1;var o=i.undirected[t];return!!o&&(!this.multi||!!o.size)}throw new z("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},r.hasEdge=function(e,t){if(1===arguments.length){var n=""+e;return this._edges.has(n)}if(2===arguments.length){e=""+e,t=""+t;var r=this._nodes.get(e);if(!r)return!1;var i=void 0!==r.out&&r.out[t];return i||(i=void 0!==r.undirected&&r.undirected[t]),!!i&&(!this.multi||!!i.size)}throw new z("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},r.directedEdge=function(e,t){if("undirected"!==this.type){if(e=""+e,t=""+t,this.multi)throw new P("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(e);if(!n)throw new M('Graph.directedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new M('Graph.directedEdge: could not find the "'.concat(t,'" target node in the graph.'));var r=n.out&&n.out[t]||void 0;return r?r.key:void 0}},r.undirectedEdge=function(e,t){if("directed"!==this.type){if(e=""+e,t=""+t,this.multi)throw new P("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(e);if(!n)throw new M('Graph.undirectedEdge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new M('Graph.undirectedEdge: could not find the "'.concat(t,'" target node in the graph.'));var r=n.undirected&&n.undirected[t]||void 0;return r?r.key:void 0}},r.edge=function(e,t){if(this.multi)throw new P("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;var n=this._nodes.get(e);if(!n)throw new M('Graph.edge: could not find the "'.concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new M('Graph.edge: could not find the "'.concat(t,'" target node in the graph.'));var r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key},r.inDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new z('Graph.inDegree: Expecting a boolean but got "'.concat(t,'" for the second parameter (allowing self-loops to be counted).'));e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.inDegree: could not find the "'.concat(e,'" node in the graph.'));if("undirected"===this.type)return 0;var r=t?n.directedSelfLoops:0;return n.inDegree+r},r.outDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new z('Graph.outDegree: Expecting a boolean but got "'.concat(t,'" for the second parameter (allowing self-loops to be counted).'));e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.outDegree: could not find the "'.concat(e,'" node in the graph.'));if("undirected"===this.type)return 0;var r=t?n.directedSelfLoops:0;return n.outDegree+r},r.directedDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new z('Graph.directedDegree: Expecting a boolean but got "'.concat(t,'" for the second parameter (allowing self-loops to be counted).'));e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.directedDegree: could not find the "'.concat(e,'" node in the graph.'));if("undirected"===this.type)return 0;var r=t?n.directedSelfLoops:0,i=n.inDegree+r,o=n.outDegree+r;return i+o},r.undirectedDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new z('Graph.undirectedDegree: Expecting a boolean but got "'.concat(t,'" for the second parameter (allowing self-loops to be counted).'));e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.undirectedDegree: could not find the "'.concat(e,'" node in the graph.'));if("directed"===this.type)return 0;var r=t?n.undirectedSelfLoops:0;return n.undirectedDegree+2*r},r.degree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new z('Graph.degree: Expecting a boolean but got "'.concat(t,'" for the second parameter (allowing self-loops to be counted).'));e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.degree: could not find the "'.concat(e,'" node in the graph.'));var r=0,i=0;return"directed"!==this.type&&(t&&(i=n.undirectedSelfLoops),r+=n.undirectedDegree+2*i),"undirected"!==this.type&&(t&&(i=n.directedSelfLoops),r+=n.inDegree+n.outDegree+2*i),r},r.source=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.source: could not find the "'.concat(e,'" edge in the graph.'));return t.source.key},r.target=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.target: could not find the "'.concat(e,'" edge in the graph.'));return t.target.key},r.extremities=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.extremities: could not find the "'.concat(e,'" edge in the graph.'));return[t.source.key,t.target.key]},r.opposite=function(e,t){e=""+e,t=""+t;var n=this._edges.get(t);if(!n)throw new M('Graph.opposite: could not find the "'.concat(t,'" edge in the graph.'));var r=n.source.key,i=n.target.key;if(e!==r&&e!==i)throw new M('Graph.opposite: the "'.concat(e,'" node is not attached to the "').concat(t,'" edge (').concat(r,", ").concat(i,")."));return e===r?i:r},r.hasExtremity=function(e,t){e=""+e,t=""+t;var n=this._edges.get(e);if(!n)throw new M('Graph.hasExtremity: could not find the "'.concat(e,'" edge in the graph.'));return n.source.key===t||n.target.key===t},r.isUndirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.isUndirected: could not find the "'.concat(e,'" edge in the graph.'));return t.undirected},r.isDirected=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.isDirected: could not find the "'.concat(e,'" edge in the graph.'));return!t.undirected},r.isSelfLoop=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.isSelfLoop: could not find the "'.concat(e,'" edge in the graph.'));return t.source===t.target},r.hasGeneratedKey=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.hasGeneratedKey: could not find the "'.concat(e,'" edge in the graph.'));return t.generatedKey},r.addNode=function(e,t){var n=function(e,t,n){if(n&&!h(n))throw new z('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(t=""+t,n=n||{},e._nodes.has(t))throw new P('Graph.addNode: the "'.concat(t,'" node already exist in the graph.'));var r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}(this,e,t);return n.key},r.mergeNode=function(e,t){if(t&&!h(t))throw new z('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(t,'"'));e=""+e,t=t||{};var n=this._nodes.get(e);return n?(t&&(d(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),e):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),e)},r.updateNode=function(e,t){if(t&&"function"!=typeof t)throw new z('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(t,'"'));e=""+e;var n=this._nodes.get(e);if(n){if(t){var r=n.attributes;n.attributes=t(r),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return e}var i=t?t({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),e},r.dropNode=function(e){var t=this;e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.dropNode: could not find the "'.concat(e,'" node in the graph.'));this.forEachEdge(e,(function(e){t.dropEdge(e)})),this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})},r.dropEdge=function(e){var t;if(arguments.length>1){var n=""+arguments[0],r=""+arguments[1];if(!(t=c(this,n,r,this.type)))throw new M('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(r,'" edge in the graph.'))}else if(e=""+e,!(t=this._edges.get(e)))throw new M('Graph.dropEdge: could not find the "'.concat(e,'" edge in the graph.'));this._edges.delete(t.key);var i=t,o=i.source,a=i.target,u=i.attributes,d=t.undirected;return o===a?d?(o.undirectedSelfLoops--,this._undirectedSelfLoopCount--):(o.directedSelfLoops--,this._directedSelfLoopCount--):d?(o.undirectedDegree--,a.undirectedDegree--):(o.outDegree--,a.inDegree--),Y(this,d,t),d?this._undirectedSize--:this._directedSize--,this.emit("edgeDropped",{key:e,attributes:u,source:o.key,target:a.key,undirected:d}),this},r.clear=function(){this._edges.clear(),this._nodes.clear(),this.emit("cleared")},r.clearEdges=function(){this._edges.clear(),this.clearIndex(),this.emit("edgesCleared")},r.getAttribute=function(e){return this._attributes[e]},r.getAttributes=function(){return this._attributes},r.hasAttribute=function(e){return this._attributes.hasOwnProperty(e)},r.setAttribute=function(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},r.updateAttribute=function(e,t){if("function"!=typeof t)throw new z("Graph.updateAttribute: updater should be a function.");var n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this},r.removeAttribute=function(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this},r.replaceAttributes=function(e){if(!h(e))throw new z("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},r.mergeAttributes=function(e){if(!h(e))throw new z("Graph.mergeAttributes: provided attributes are not a plain object.");return d(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this},r.getNodeAttribute=function(e,t){e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.getNodeAttribute: could not find the "'.concat(e,'" node in the graph.'));return n.attributes[t]},r.getNodeAttributes=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new M('Graph.getNodeAttributes: could not find the "'.concat(e,'" node in the graph.'));return t.attributes},r.hasNodeAttribute=function(e,t){e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.hasNodeAttribute: could not find the "'.concat(e,'" node in the graph.'));return n.attributes.hasOwnProperty(t)},r.setNodeAttribute=function(e,t,n){e=""+e;var r=this._nodes.get(e);if(!r)throw new M('Graph.setNodeAttribute: could not find the "'.concat(e,'" node in the graph.'));if(arguments.length<3)throw new z("Graph.setNodeAttribute: not enough arguments. Either you forgot to pass the attribute's name or value, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.");return r.attributes[t]=n,this.emit("nodeAttributesUpdated",{key:e,type:"set",attributes:r.attributes,name:t}),this},r.updateNodeAttribute=function(e,t,n){e=""+e;var r=this._nodes.get(e);if(!r)throw new M('Graph.updateNodeAttribute: could not find the "'.concat(e,'" node in the graph.'));if(arguments.length<3)throw new z("Graph.updateNodeAttribute: not enough arguments. Either you forgot to pass the attribute's name or updater, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.");if("function"!=typeof n)throw new z("Graph.updateAttribute: updater should be a function.");var i=r.attributes,o=n(i[t]);return i[t]=o,this.emit("nodeAttributesUpdated",{key:e,type:"set",attributes:r.attributes,name:t}),this},r.removeNodeAttribute=function(e,t){e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.removeNodeAttribute: could not find the "'.concat(e,'" node in the graph.'));return delete n.attributes[t],this.emit("nodeAttributesUpdated",{key:e,type:"remove",attributes:n.attributes,name:t}),this},r.replaceNodeAttributes=function(e,t){e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.replaceNodeAttributes: could not find the "'.concat(e,'" node in the graph.'));if(!h(t))throw new z("Graph.replaceNodeAttributes: provided attributes are not a plain object.");return n.attributes=t,this.emit("nodeAttributesUpdated",{key:e,type:"replace",attributes:n.attributes}),this},r.mergeNodeAttributes=function(e,t){e=""+e;var n=this._nodes.get(e);if(!n)throw new M('Graph.mergeNodeAttributes: could not find the "'.concat(e,'" node in the graph.'));if(!h(t))throw new z("Graph.mergeNodeAttributes: provided attributes are not a plain object.");return d(n.attributes,t),this.emit("nodeAttributesUpdated",{key:e,type:"merge",attributes:n.attributes,data:t}),this},r.updateEachNodeAttributes=function(e,t){if("function"!=typeof e)throw new z("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!l(t))throw new z("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i=this._nodes.values();!0!==(n=i.next()).done;)(r=n.value).attributes=e(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})},r.updateEachEdgeAttributes=function(e,t){if("function"!=typeof e)throw new z("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!l(t))throw new z("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i=this._edges.values();!0!==(n=i.next()).done;)(r=n.value).attributes=e(r.key,r.attributes);this.emit("eachEdgeAttributesUpdated",{hints:t||null})},r.forEach=function(e){if("function"!=typeof e)throw new z("Graph.forEach: expecting a callback.");this.multi?Ke(!1,this,e):Ce(!1,this,e)},r.forEachUntil=function(e){if("function"!=typeof e)throw new z("Graph.forEach: expecting a callback.");return this.multi?Ke(!0,this,e):Ce(!0,this,e)},r.adjacency=function(){return this.multi?(o=(e=this)._nodes.values(),a=e.type,u="outer",d=null,new O((function e(){var c;if("outer"===u)return!0===(c=o.next()).done?c:(t=c.value,u="directed",e());if("directed"===u)return"undirected"===a?(u="undirected",e()):(r=t.out,n=Object.keys(t.out),i=0,u="inner-directed",e());if("undirected"===u){if("directed"===a)return u="outer",e();r=t.undirected,n=Object.keys(t.undirected),i=0,u="inner-undirected"}if(!d&&i>=n.length)return u="inner-undirected"===u?"outer":"undirected",e();if(!d){var s=n[i++];return d=r[s].values(),e()}if((c=d.next()).done)return d=null,e();var h=c.value,f=h.target;return"inner-undirected"===u&&f.key===t.key&&(f=h.source),{done:!1,value:[t.key,f.key,t.attributes,f.attributes,h.key,h.attributes]}}))):function(e){var t,n,r,i,o=e._nodes.values(),a=e.type,u="outer";return new O((function e(){var d;if("outer"===u)return!0===(d=o.next()).done?d:(t=d.value,u="directed",e());if("directed"===u)return"undirected"===a?(u="undirected",e()):(r=t.out,n=Object.keys(t.out),i=0,u="inner-directed",e());if("undirected"===u){if("directed"===a)return u="outer",e();r=t.undirected,n=Object.keys(t.undirected),i=0,u="inner-undirected"}if(i>=n.length)return u="inner-undirected"===u?"outer":"undirected",e();var c=n[i++],s=r[c],h=s.target;return"inner-undirected"===u&&h.key===t.key&&(h=s.source),{done:!1,value:[t.key,h.key,t.attributes,h.attributes,s.key,s.attributes]}}))}(this);var e,t,n,r,i,o,a,u,d},r.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):C(this._nodes.keys(),this._nodes.size)},r.forEachNode=function(e){if("function"!=typeof e)throw new z("Graph.forEachNode: expecting a callback.");this._nodes.forEach((function(t,n){e(n,t.attributes)}))},r.forEachNodeUntil=function(e){if("function"!=typeof e)throw new z("Graph.forEachNode: expecting a callback.");for(var t,n,r=this._nodes.values();!0!==(t=r.next()).done;)if(e((n=t.value).key,n.attributes))return!0;return!1},r.nodeEntries=function(){var e=this._nodes.values();return new O((function(){var t=e.next();if(t.done)return t;var n=t.value;return{value:[n.key,n.attributes],done:!1}}))},r.exportNode=function(e){e=""+e;var t=this._nodes.get(e);if(!t)throw new M('Graph.exportNode: could not find the "'.concat(e,'" node in the graph.'));return ze(e,t)},r.exportEdge=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new M('Graph.exportEdge: could not find the "'.concat(e,'" edge in the graph.'));return Me(e,t)},r.export=function(){var e=new Array(this._nodes.size),t=0;this._nodes.forEach((function(n,r){e[t++]=ze(r,n)}));var n=new Array(this._edges.size);return t=0,this._edges.forEach((function(e,r){n[t++]=Me(r,e)})),{attributes:this.getAttributes(),nodes:e,edges:n,options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops}}},r.importNode=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Pe(e);if(n){if("not-object"===n)throw new z('Graph.importNode: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if("no-key"===n)throw new z("Graph.importNode: no key provided.");if("invalid-attributes"===n)throw new z("Graph.importNode: invalid attributes. Attributes should be a plain object, null or omitted.")}var r=e.key,i=e.attributes,o=void 0===i?{}:i;return t?this.mergeNode(r,o):this.addNode(r,o),this},r.importEdge=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Te(e);if(n){if("not-object"===n)throw new z('Graph.importEdge: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if("no-source"===n)throw new z("Graph.importEdge: missing souce.");if("no-target"===n)throw new z("Graph.importEdge: missing target.");if("invalid-attributes"===n)throw new z("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if("invalid-undirected"===n)throw new z("Graph.importEdge: invalid undirected. Undirected should be boolean or omitted.")}var r=e.source,i=e.target,o=e.attributes,a=void 0===o?{}:o,u=e.undirected,d=void 0!==u&&u;return"key"in e?(t?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,e.key,r,i,a):(t?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge).call(this,r,i,a),this},r.import=function(e){var t,n,r,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(s(e))return this.import(e.export(),i),this;if(!h(e))throw new z("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!h(e.attributes))throw new z("Graph.import: invalid attributes. Expecting a plain object.");i?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}if(e.nodes){if(r=e.nodes,!Array.isArray(r))throw new z("Graph.import: invalid nodes. Expecting an array.");for(t=0,n=r.length;tn)){var a=new Set;a.add(t.undirected[o]),t.undirected[o]=a,e._nodes.get(o).undirected[n]=a}}))),this;var e},r.clearIndex=function(){return this._nodes.forEach((function(e){void 0!==e.in&&(e.in={},e.out={}),void 0!==e.undirected&&(e.undirected={})})),this},r.toJSON=function(){return this.export()},r.toString=function(){return"[object Graph]"},r.inspect=function(){var e=this,t={};this._nodes.forEach((function(e,n){t[n]=e.attributes}));var n={},r={};this._edges.forEach((function(t,i){var o=t.undirected?"--":"->",a="",u="(".concat(t.source.key,")").concat(o,"(").concat(t.target.key,")");t.generatedKey?e.multi&&(void 0===r[u]?r[u]=0:r[u]++,a+="".concat(r[u],". ")):a+="[".concat(i,"]: "),n[a+=u]=t.attributes}));var i={};for(var o in this)this.hasOwnProperty(o)&&!Fe.has(o)&&"function"!=typeof this[o]&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,p(i,"constructor",this.constructor),i},n}(v.exports.EventEmitter);"undefined"!=typeof Symbol&&(Je.prototype[Symbol.for("nodejs.util.inspect.custom")]=Je.prototype.inspect),[{name:function(e){return"".concat(e,"Edge")},generateKey:!0},{name:function(e){return"".concat(e,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(e){return"".concat(e,"EdgeWithKey")}},{name:function(e){return"".concat(e,"DirectedEdgeWithKey")},type:"directed"},{name:function(e){return"".concat(e,"UndirectedEdgeWithKey")},type:"undirected"}].forEach((function(e){["add","merge","update"].forEach((function(t){var n=e.name(t),r="add"===t?Ye:Be;e.generateKey?Je.prototype[n]=function(i,o,a){return r(this,n,!0,"undirected"===(e.type||this.type),null,i,o,a,"update"===t)}:Je.prototype[n]=function(i,o,a,u){return r(this,n,!1,"undirected"===(e.type||this.type),i,o,a,u,"update"===t)}}))})),"undefined"!=typeof Symbol&&(Je.prototype[Symbol.iterator]=Je.prototype.adjacency),function(e){B.forEach((function(t){var n=t.name,r=t.attacher;r(e,n("Edge"),"mixed"),r(e,n("DirectedEdge"),"directed"),r(e,n("UndirectedEdge"),"undirected")}))}(Je),function(e){H.forEach((function(t){!function(e,t){var n=t.name,r=t.type,i=t.direction;e.prototype[n]=function(e,t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];if(!arguments.length)return ce(this,r);if(1===arguments.length){e=""+e;var o=this._nodes.get(e);if(void 0===o)throw new M("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return pe(this.multi,"mixed"===r?this.type:r,i,o)}if(2===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new M("Graph.".concat(n,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new M("Graph.".concat(n,': could not find the "').concat(t,'" target node in the graph.'));return ve(r,this.multi,i,a,t)}throw new z("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t),function(e,t){var n=t.name,r=t.type,i=t.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(e,t,n){if("mixed"===r||"mixed"===this.type||r===this.type){if(1===arguments.length)return se(this,r,n=e);if(2===arguments.length){e=""+e,n=t;var a=this._nodes.get(e);if(void 0===a)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" node in the graph.'));return ge(this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){e=""+e,t=""+t;var u=this._nodes.get(e);if(!u)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new M("Graph.".concat(o,': could not find the "').concat(t,'" target node in the graph.'));return be(r,this.multi,i,u,t,n)}throw new z("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}}}(e,t),function(e,t){var n=t.name,r=t.type,i=t.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1)+"Until";e.prototype[o]=function(e,t,n){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return!1;if(1===arguments.length)return he(this,r,n=e);if(2===arguments.length){e=""+e,n=t;var a=this._nodes.get(e);if(void 0===a)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" node in the graph.'));return le(this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){e=""+e,t=""+t;var u=this._nodes.get(e);if(!u)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new M("Graph.".concat(o,': could not find the "').concat(t,'" target node in the graph.'));return we(r,this.multi,i,u,t,n)}throw new z("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}}(e,t),function(e,t){var n=t.name,r=t.type,i=t.direction,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(e,t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return O.empty();if(!arguments.length)return fe(this,r);if(1===arguments.length){e=""+e;var n=this._nodes.get(e);if(!n)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" node in the graph.'));return ye(r,i,n)}if(2===arguments.length){e=""+e,t=""+t;var a=this._nodes.get(e);if(!a)throw new M("Graph.".concat(o,': could not find the "').concat(e,'" source node in the graph.'));if(!this._nodes.has(t))throw new M("Graph.".concat(o,': could not find the "').concat(t,'" target node in the graph.'));return me(r,i,a,t)}throw new z("Graph.".concat(o,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(e,t)}))}(Je),function(e){_e.forEach((function(t){!function(e,t){var n=t.name,r=t.type,i=t.direction;e.prototype[n]=function(e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];if(2===arguments.length){var t=""+arguments[0],o=""+arguments[1];if(!this._nodes.has(t))throw new M("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));if(!this._nodes.has(o))throw new M("Graph.".concat(n,': could not find the "').concat(o,'" node in the graph.'));return De(this,r,i,t,o)}if(1===arguments.length){e=""+e;var a=this._nodes.get(e);if(void 0===a)throw new M("Graph.".concat(n,': could not find the "').concat(e,'" node in the graph.'));return Ge("mixed"===r?this.type:r,i,a)}throw new z("Graph.".concat(n,": invalid number of arguments (expecting 1 or 2 and got ").concat(arguments.length,")."))}}(e,t),je(e,t),Ue(e,t),Oe(e,t)}))}(Je);var qe=function(e){function n(t){var n=d({type:"directed"},t);if("multi"in n&&!1!==n.multi)throw new z("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new z('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Je),He=function(e){function n(t){var n=d({type:"undirected"},t);if("multi"in n&&!1!==n.multi)throw new z("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new z('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Je),Qe=function(e){function n(t){var n=d({multi:!0},t);if("multi"in n&&!0!==n.multi)throw new z("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return e.call(this,n)||this}return t(n,e),n}(Je),Ve=function(e){function n(t){var n=d({type:"directed",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new z("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new z('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Je),Xe=function(e){function n(t){var n=d({type:"undirected",multi:!0},t);if("multi"in n&&!0!==n.multi)throw new z("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new z('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return e.call(this,n)||this}return t(n,e),n}(Je);function Ze(e){e.from=function(t,n){var r=d({},t.options,n),i=new e(r);return i.import(t),i}}return Ze(Je),Ze(qe),Ze(He),Ze(Qe),Ze(Ve),Ze(Xe),Je.Graph=Je,Je.DirectedGraph=qe,Je.UndirectedGraph=He,Je.MultiGraph=Qe,Je.MultiDirectedGraph=Ve,Je.MultiUndirectedGraph=Xe,Je.InvalidArgumentsGraphError=z,Je.NotFoundGraphError=M,Je.UsageGraphError=P,Je})); +//# sourceMappingURL=graphology.umd.min.js.map diff --git a/html-template/vendor/sigma.min.js b/html-template/vendor/sigma.min.js new file mode 100644 index 0000000..3e6579f --- /dev/null +++ b/html-template/vendor/sigma.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Sigma=e():t.Sigma=e()}(self,(function(){return(()=>{var t={796:t=>{t.exports=function(t,e){var r=e.length;if(0!==r){var i=t.length;t.length+=r;for(var o=0;o{"use strict";var e,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function n(){n.init.call(this)}t.exports=n,t.exports.once=function(t,e){return new Promise((function(r,i){function o(r){t.removeListener(e,n),i(r)}function n(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}g(t,e,n,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&g(t,"error",e,{once:!0})}(t,o)}))},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var a=10;function s(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?n.defaultMaxListeners:t._maxListeners}function c(t,e,r,i){var o,n,a,c;if(s(r),void 0===(n=t._events)?(n=t._events=Object.create(null),t._eventsCount=0):(void 0!==n.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),n=t._events),a=n[e]),void 0===a)a=n[e]=r,++t._eventsCount;else if("function"==typeof a?a=n[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),(o=h(t))>0&&a.length>o&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,c=l,console&&console.warn&&console.warn(c)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=l.bind(i);return o.listener=r,i.wrapFn=o,o}function d(t,e,r){var i=t._events;if(void 0===i)return[];var o=i[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var h=n[t];if(void 0===h)return!1;if("function"==typeof h)i(h,this,e);else{var c=h.length,l=p(h,c);for(r=0;r=0;n--)if(r[n]===e||r[n].listener===e){a=r[n].listener,o=n;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},n.prototype.listeners=function(t){return d(this,t,!0)},n.prototype.rawListeners=function(t){return d(this,t,!1)},n.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},n.prototype.listenerCount=f,n.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},886:(t,e,r)=>{var i=r(186);function o(t,e){if(!i(t))throw new Error("graphology-metrics/extent: the given graph is not a valid graphology instance.");var r,o,n,a=[].concat(e),s={};for(n=0;ns[o][1]&&(s[o][1]=r)})),"string"==typeof e?s[e]:s}var n=o;n.nodeExtent=o,n.edgeExtent=function(t,e){if(!i(t))throw new Error("graphology-metrics/extent: the given graph is not a valid graphology instance.");var r,o,n,a=[].concat(e),s={};for(n=0;ns[o][1]&&(s[o][1]=r)})),"string"==typeof e?s[e]:s},t.exports=n},186:t=>{t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi}},973:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="precision mediump float;\n\nvarying vec4 v_color;\n\nvoid main(void) {\n gl_FragColor = v_color;\n}\n"},912:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="attribute vec2 a_position;\nattribute vec2 a_normal;\nattribute float a_thickness;\nattribute float a_radius;\nattribute vec4 a_color;\nattribute vec3 a_barycentric;\n\nuniform mat3 u_matrix;\nuniform float u_scale;\nuniform float u_cameraRatio;\nuniform float u_viewportRatio;\nuniform float u_thicknessRatio;\n\nvarying vec4 v_color;\n\nconst float arrowHeadLengthThicknessRatio = 2.5;\nconst float arrowHeadWidthLengthRatio = 0.66;\nconst float minThickness = 0.8;\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n // Computing thickness in screen space:\n float thickness = a_thickness * u_thicknessRatio * u_scale * u_viewportRatio / 2.0;\n thickness = max(thickness, minThickness * u_viewportRatio);\n\n float nodeRadius = a_radius * u_thicknessRatio * u_viewportRatio * u_cameraRatio;\n float arrowHeadLength = thickness * 2.0 * arrowHeadLengthThicknessRatio * u_cameraRatio;\n float arrowHeadHalfWidth = arrowHeadWidthLengthRatio * arrowHeadLength / 2.0;\n\n float da = a_barycentric.x;\n float db = a_barycentric.y;\n float dc = a_barycentric.z;\n\n vec2 delta = vec2(\n da * ((nodeRadius) * a_normal.y)\n + db * ((nodeRadius + arrowHeadLength) * a_normal.y + arrowHeadHalfWidth * a_normal.x)\n + dc * ((nodeRadius + arrowHeadLength) * a_normal.y - arrowHeadHalfWidth * a_normal.x),\n\n da * (-(nodeRadius) * a_normal.x)\n + db * (-(nodeRadius + arrowHeadLength) * a_normal.x + arrowHeadHalfWidth * a_normal.y)\n + dc * (-(nodeRadius + arrowHeadLength) * a_normal.x - arrowHeadHalfWidth * a_normal.y)\n );\n\n vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;\n\n gl_Position = vec4(position, 0, 1);\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},620:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="attribute vec2 a_position;\nattribute vec2 a_normal;\nattribute float a_thickness;\nattribute vec4 a_color;\nattribute float a_radius;\n\nuniform mat3 u_matrix;\nuniform float u_scale;\nuniform float u_cameraRatio;\nuniform float u_viewportRatio;\nuniform float u_thicknessRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_thickness;\n\nconst float arrowHeadLengthThicknessRatio = 2.5;\nconst float minThickness = 0.8;\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n // Computing thickness in screen space:\n float thickness = a_thickness * u_thicknessRatio * u_scale * u_viewportRatio / 2.0;\n thickness = max(thickness, minThickness * u_viewportRatio);\n\n float direction = sign(a_radius);\n float nodeRadius = direction * a_radius * u_thicknessRatio * u_viewportRatio;\n float arrowHeadLength = thickness * 2.0 * arrowHeadLengthThicknessRatio;\n\n vec2 arrowHeadVector = vec2(-direction * a_normal.y, direction * a_normal.x);\n\n // Add normal vector to the position in screen space, but correct thickness first:\n vec2 position = a_position + a_normal * thickness * u_cameraRatio;\n // Add vector that corrects the arrow head length:\n position = position + arrowHeadVector * (arrowHeadLength + nodeRadius) * u_cameraRatio;\n // Apply camera\n position = (u_matrix * vec3(position, 1)).xy;\n\n gl_Position = vec4(position, 0, 1);\n\n v_normal = a_normal;\n v_thickness = thickness;\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},498:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="precision mediump float;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_thickness;\n\nconst float feather = 0.001;\nconst vec4 color0 = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main(void) {\n float dist = length(v_normal) * v_thickness;\n\n float t = smoothstep(\n v_thickness - feather,\n v_thickness,\n dist\n );\n\n gl_FragColor = mix(v_color, color0, t);\n}\n"},223:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="attribute vec2 a_position;\nattribute vec2 a_normal;\nattribute float a_thickness;\nattribute vec4 a_color;\n\nuniform mat3 u_matrix;\nuniform float u_scale;\nuniform float u_cameraRatio;\nuniform float u_viewportRatio;\nuniform float u_thicknessRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_thickness;\n\nconst float minThickness = 0.8;\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n // Computing thickness in screen space:\n float thickness = a_thickness * u_thicknessRatio * u_scale * u_viewportRatio / 2.0;\n thickness = max(thickness, minThickness * u_viewportRatio);\n\n // Add normal vector to the position in screen space, but correct thickness first:\n vec2 position = (u_matrix * vec3(a_position + a_normal * thickness * u_cameraRatio, 1)).xy;\n\n gl_Position = vec4(position, 0, 1);\n\n v_normal = a_normal;\n v_thickness = thickness;\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},262:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="precision mediump float;\n\nvarying vec4 v_color;\nvarying float v_border;\n\nconst float radius = 0.5;\n\nvoid main(void) {\n vec4 color0 = vec4(0.0, 0.0, 0.0, 0.0);\n vec2 m = gl_PointCoord - vec2(0.5, 0.5);\n float dist = radius - length(m);\n\n float t = 0.0;\n if (dist > v_border)\n t = 1.0;\n else if (dist > 0.0)\n t = dist / v_border;\n\n gl_FragColor = mix(color0, v_color, t);\n}\n"},106:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="attribute vec2 a_position;\nattribute float a_size;\nattribute vec4 a_color;\n\nuniform float u_ratio;\nuniform float u_scale;\nuniform mat3 u_matrix;\n\nvarying vec4 v_color;\nvarying float v_border;\n\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n gl_Position = vec4(\n (u_matrix * vec3(a_position, 1)).xy,\n 0,\n 1\n );\n\n // Multiply the point size twice:\n // - x SCALING_RATIO to correct the canvas scaling\n // - x 2 to correct the formulae\n gl_PointSize = a_size * u_ratio * u_scale * 2.0;\n\n v_border = (1.0 / u_ratio) * (0.5 / a_size);\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},764:function(t,e,r){"use strict";var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var a=r(187),s=r(751),h=n(r(358)),c=r(928),l=1.5,u=function(t){function e(){var e=t.call(this)||this;return e.x=.5,e.y=.5,e.angle=0,e.ratio=1,e.nextFrame=null,e.previousState=null,e.enabled=!0,e.previousState=e.getState(),e}return o(e,t),e.from=function(t){return(new e).setState(t)},e.prototype.enable=function(){return this.enabled=!0,this},e.prototype.disable=function(){return this.enabled=!1,this},e.prototype.getState=function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}},e.prototype.hasState=function(t){return this.x===t.x&&this.y===t.y&&this.ratio===t.ratio&&this.angle===t.angle},e.prototype.getPreviousState=function(){var t=this.previousState;return t?{x:t.x,y:t.y,angle:t.angle,ratio:t.ratio}:null},e.prototype.isAnimated=function(){return!!this.nextFrame},e.prototype.setState=function(t){return this.enabled?(this.previousState=this.getState(),"number"==typeof t.x&&(this.x=t.x),"number"==typeof t.y&&(this.y=t.y),"number"==typeof t.angle&&(this.angle=t.angle),"number"==typeof t.ratio&&(this.ratio=t.ratio),this.hasState(this.previousState)||this.emit("updated",this.getState()),this):this},e.prototype.animate=function(t,e,r){var i=this;if(this.enabled){var o=Object.assign({},s.ANIMATE_DEFAULTS,e),n="function"==typeof o.easing?o.easing:h.default[o.easing],a=Date.now(),l=this.getState(),u=function(){var e=(Date.now()-a)/o.duration;if(e>=1)return i.nextFrame=null,i.setState(t),void(i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0));var r=n(e),s={};t.x&&(s.x=l.x+(t.x-l.x)*r),t.y&&(s.y=l.y+(t.y-l.y)*r),t.angle&&(s.angle=l.angle+(t.angle-l.angle)*r),t.ratio&&(s.ratio=l.ratio+(t.ratio-l.ratio)*r),i.setState(s),i.nextFrame=(0,c.requestFrame)(u)};this.nextFrame?((0,c.cancelFrame)(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=(0,c.requestFrame)(u)):u(),this.animationCallback=r}},e.prototype.animatedZoom=function(t){if(t){if("number"==typeof t)return this.animate({ratio:this.ratio/t});this.animate({ratio:this.ratio/(t.factor||l)},t)}else this.animate({ratio:this.ratio/l})},e.prototype.animatedUnzoom=function(t){if(t){if("number"==typeof t)return this.animate({ratio:this.ratio*t});this.animate({ratio:this.ratio*(t.factor||l)},t)}else this.animate({ratio:this.ratio*l})},e.prototype.animatedReset=function(t){this.animate({x:.5,y:.5,ratio:1,angle:0},t)},e.prototype.copy=function(){return e.from(this.getState())},e}(a.EventEmitter);e.default=u},291:function(t,e,r){"use strict";var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.getWheelDelta=e.getTouchCoords=e.getTouchesArray=e.getMouseCoords=e.getPosition=e.getY=e.getX=void 0;var n=r(187);function a(t){if(void 0!==t.offsetX)return t.offsetX;if(void 0!==t.clientX)return t.clientX;throw new Error("Captor: could not extract x from event.")}function s(t){if(void 0!==t.offsetY)return t.offsetY;if(void 0!==t.clientY)return t.clientY;throw new Error("Captor: could not extract y from event.")}function h(t){return{x:a(t),y:s(t)}}function c(t){for(var e=[],r=0,i=Math.min(t.length,2);r0?1/1.7:1.7,o=this.renderer.getCamera(),n=o.getState().ratio*i,a=r>0?1:-1,s=Date.now();return this.currentWheelDirection===a&&this.lastWheelTriggerTime&&s-this.lastWheelTriggerTime<50||(o.animate(this.renderer.getViewportZoomedState({x:(0,h.getX)(t),y:(0,h.getY)(t)},n),{easing:"quadraticOut",duration:250},(function(){e.currentWheelDirection=0})),this.currentWheelDirection=a,this.lastWheelTriggerTime=s),!1},e.prototype.handleOut=function(){},e}(h.default);e.default=c},508:function(t,e,r){"use strict";var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),n=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r),Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&n(e,t,r);return a(e,t),e},h=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,o,n=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a};Object.defineProperty(e,"__esModule",{value:!0});var c=s(r(291)),l=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.enabled=!0,i.isMoving=!1,i.touchMode=0,i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),e.addEventListener("touchstart",i.handleStart,!1),e.addEventListener("touchend",i.handleLeave,!1),e.addEventListener("touchcancel",i.handleLeave,!1),e.addEventListener("touchmove",i.handleMove,!1),i}return o(e,t),e.prototype.kill=function(){var t=this.container;t.removeEventListener("touchstart",this.handleStart),t.removeEventListener("touchend",this.handleLeave),t.removeEventListener("touchcancel",this.handleLeave),t.removeEventListener("touchmove",this.handleMove)},e.prototype.getDimensions=function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}},e.prototype.dispatchRelatedMouseEvent=function(t,e,r,i){var o=r||(0,c.getPosition)(e.touches[0]),n=new MouseEvent(t,{clientX:o.x,clientY:o.y,altKey:e.altKey,ctrlKey:e.ctrlKey});(i||this.container).dispatchEvent(n)},e.prototype.handleStart=function(t){if(this.enabled){t.preventDefault(),1===t.touches.length&&this.dispatchRelatedMouseEvent("mousedown",t);var e=(0,c.getTouchesArray)(t.touches);if(this.isMoving=!0,this.touchMode=e.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=e.map(c.getPosition),this.lastTouchesPositions=this.startTouchesPositions,2===this.touchMode){var r=h(this.startTouchesPositions,2),i=r[0],o=i.x,n=i.y,a=r[1],s=a.x,l=a.y;this.startTouchesAngle=Math.atan2(l-n,s-o),this.startTouchesDistance=Math.sqrt(Math.pow(s-o,2)+Math.pow(l-n,2))}this.emit("touchdown",(0,c.getTouchCoords)(t))}},e.prototype.handleLeave=function(t){if(this.enabled){switch(t.preventDefault(),0===t.touches.length&&this.lastTouchesPositions&&this.lastTouchesPositions.length&&(this.dispatchRelatedMouseEvent("mouseup",t,this.lastTouchesPositions[0],document),this.dispatchRelatedMouseEvent("click",t,this.lastTouchesPositions[0])),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(1===t.touches.length){this.handleStart(t),t.preventDefault();break}case 1:if(this.isMoving){var e=this.renderer.getCamera(),r=e.getState(),i=e.getPreviousState()||{x:0,y:0};e.animate({x:r.x+3*(r.x-i.x),y:r.y+3*(r.y-i.y)},{duration:200,easing:"quadraticOut"})}this.isMoving=!1,this.touchMode=0}this.emit("touchup",(0,c.getTouchCoords)(t))}},e.prototype.handleMove=function(t){var e,r=this;if(this.enabled){t.preventDefault(),1===t.touches.length&&this.dispatchRelatedMouseEvent("mousemove",t);var i=this.startCameraState,o=(0,c.getTouchesArray)(t.touches).map(c.getPosition);switch(this.lastTouchesPositions=o,this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout((function(){r.isMoving=!1}),200),this.touchMode){case 1:var n=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),a=n.x,s=n.y,l=this.renderer.viewportToFramedGraph(o[0]),u=l.x,d=l.y;this.renderer.getCamera().setState({x:i.x+a-u,y:i.y+s-d});break;case 2:var f={},p=o[0],g=p.x,v=p.y,m=o[1],y=m.x,_=m.y,b=Math.atan2(_-v,y-g)-this.startTouchesAngle,x=Math.hypot(_-v,y-g)/this.startTouchesDistance;f.ratio=i.ratio/x,f.angle=i.angle+b;var w=this.getDimensions(),L=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:i}),E=Math.min(w.width,w.height),A=E/w.width,P=E/w.height,T=f.ratio/E;d=v-E/2/P,u=(e=h([(u=g-E/2/A)*Math.cos(-f.angle)-d*Math.sin(-f.angle),d*Math.cos(-f.angle)+u*Math.sin(-f.angle)],2))[0],d=e[1],f.x=L.x-u*T,f.y=L.y+d*T,this.renderer.getCamera().setState(f)}this.emit("touchmove",(0,c.getTouchCoords)(t))}},e}(c.default);e.default=l},730:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.edgeLabelsToDisplayFromNodes=e.LabelGrid=void 0;var r=function(){function t(t,e){this.key=t,this.size=e}return t.compare=function(t,e){return t.size>e.size?-1:t.sizee.key?1:-1},t}(),i=function(){function t(){this.width=0,this.height=0,this.cellSize=0,this.columns=0,this.rows=0,this.cells={}}return t.prototype.resizeAndClear=function(t,e){this.width=t.width,this.height=t.height,this.cellSize=e,this.columns=Math.ceil(t.width/e),this.rows=Math.ceil(t.height/e),this.cells={}},t.prototype.getIndex=function(t){var e=Math.floor(t.x/this.cellSize),r=Math.floor(t.y/this.cellSize);return e*this.columns+r},t.prototype.add=function(t,e,i){var o=new r(t,e),n=this.getIndex(i),a=this.cells[n];a||(a=[],this.cells[n]=a),a.push(o)},t.prototype.organize=function(){for(var t in this.cells)this.cells[t].sort(r.compare)},t.prototype.getLabelsToDisplay=function(t,e){var r=this.cellSize*this.cellSize,i=r/t/t*e/r,o=Math.ceil(i),n=[];for(var a in this.cells)for(var s=this.cells[a],h=0;h0)&&!(i=n.next()).done;)a.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var i,o=0,n=e.length;oi&&eo}function u(t,e,r,i,o,n,a,s){return to&&en}function d(t,e,r,i,o,n){var a=t=5)return r[f]=r[f]||[],void r[f].push(i);var p=4*f+4,g=4*f+8,v=4*f+12,m=4*f+16,y=l(h,c,u,e[p+0],e[p+1],e[p+2],e[p+3]),_=l(h,c,u,e[g+0],e[g+1],e[g+2],e[g+3]),b=l(h,c,u,e[v+0],e[v+1],e[v+2],e[v+3]),x=l(h,c,u,e[m+0],e[m+1],e[m+2],e[m+3]),w=[y,_,b,x].reduce((function(t,e){return e?t+1:t}),0);if(0===w&&0===d)return r.outside.push(i),void(!s&&r.outside.length>=5&&(s=!0,console.warn("sigma/quadtree.insertNode: At least 5 nodes are outside the global quadtree zone. You might have a problem with the normalization function or the custom bounding box.")));if(0===w)throw new Error("sigma/quadtree.insertNode: no collision (level: "+d+", key: "+i+", x: "+o+", y: "+n+", size: "+a+").");if(3===w)throw new Error("sigma/quadtree.insertNode: 3 impossible collisions (level: "+d+", key: "+i+", x: "+o+", y: "+n+", size: "+a+").");if(w>1)return r[f]=r[f]||[],void r[f].push(i);d++,y&&(f=p),_&&(f=g),b&&(f=v),x&&(f=m)}}(0,this.data,this.containers,t,e,r,i),this},t.prototype.resize=function(t){this.clear(),this.data[0]=t.x,this.data[1]=t.y,this.data[2]=t.width,this.data[3]=t.height,function(t,e){for(var r=[0,0];r.length;){var i=r.pop(),o=r.pop(),n=4*o+4,a=4*o+8,s=4*o+12,h=4*o+16,c=e[o+0],l=e[o+1],u=e[o+2]/2,d=e[o+3]/2;e[n+0]=c,e[n+1]=l,e[n+2]=u,e[n+3]=d,e[a+0]=c+u,e[a+1]=l,e[a+2]=u,e[a+3]=d,e[s+0]=c,e[s+1]=l+d,e[s+2]=u,e[s+3]=d,e[h+0]=c+u,e[h+1]=l+d,e[h+2]=u,e[h+3]=d,i<4&&(r.push(h,i+1),r.push(s,i+1),r.push(a,i+1),r.push(n,i+1))}}(0,this.data)},t.prototype.clear=function(){var t;return this.containers=((t={}).outside=[],t),this},t.prototype.point=function(t,e){var r=this.containers.outside,n=0,a=0;do{this.containers[n]&&r.push.apply(r,o([],i(this.containers[n]),!1)),n=4*n+4*d(t,e,this.data[n+0],this.data[n+1],this.data[n+2],this.data[n+3]),a++}while(a<=5);return r},t.prototype.rectangle=function(t,e,r,n,s){var l,d=this.lastRectangle;return d&&t===d.x1&&r===d.x2&&e===d.y1&&n===d.y2&&s===d.height||(this.lastRectangle={x1:t,y1:e,x2:r,y2:n,height:s},h(this.lastRectangle)||(this.lastRectangle=c(this.lastRectangle)),this.cache=function(t,e,r,i,o,n,s){for(var h,c=[0,0],l=[];c.length;){var d=c.pop(),f=c.pop();if((h=r[f])&&(0,a.default)(l,h),!(d>=5)){var p=4*f+4,g=4*f+8,v=4*f+12,m=4*f+16,y=u(i,o,n,s,e[p+0],e[p+1],e[p+2],e[p+3]),_=u(i,o,n,s,e[g+0],e[g+1],e[g+2],e[g+3]),b=u(i,o,n,s,e[v+0],e[v+1],e[v+2],e[v+3]),x=u(i,o,n,s,e[m+0],e[m+1],e[m+2],e[m+3]);y&&c.push(p,d+1),_&&c.push(g,d+1),b&&c.push(v,d+1),x&&c.push(m,d+1)}}return l}(0,this.data,this.containers,t,e,Math.abs(t-r)||Math.abs(e-n),s),(l=this.cache).push.apply(l,o([],i(this.containers.outside),!1))),this.cache},t}();e.default=f},607:function(t,e,r){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Sigma=e.MouseCaptor=e.QuadTree=e.Camera=void 0;var o=i(r(159));e.Sigma=o.default;var n=i(r(764));e.Camera=n.default;var a=i(r(134));e.QuadTree=a.default;var s=i(r(269));e.MouseCaptor=s.default,e.default=o.default},942:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r,i,o){var n=o.edgeLabelSize,a=o.edgeLabelFont,s=o.edgeLabelWeight,h=e.label;if(h){t.fillStyle=e.color,t.font=s+" "+n+"px "+a;var c,l=t.measureText(h).width,u=(r.x+i.x)/2,d=(r.y+i.y)/2,f=i.x-r.x,p=i.y-r.y,g=Math.sqrt(f*f+p*p);c=f>0?p>0?Math.acos(f/g):Math.asin(p/g):p>0?Math.acos(f/g)+Math.PI:Math.asin(f/g)+Math.PI/2,t.save(),t.translate(u,d),t.rotate(c),t.fillText(h,-l/2,e.size/2+n),t.restore()}}},61:function(t,e,r){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=i(r(622));e.default=function(t,e,r){var i=r.labelSize,n=r.labelFont,a=r.labelWeight;if(t.font=a+" "+i+"px "+n,t.fillStyle="#FFF",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=8,t.shadowColor="#000","string"==typeof e.label){var s=t.measureText(e.label).width,h=Math.round(s+5),c=Math.round(i+4),l=Math.max(e.size,i/2)+2,u=Math.asin(c/2/l),d=Math.sqrt(Math.abs(Math.pow(l,2)-Math.pow(c/2,2)));t.beginPath(),t.moveTo(e.x+d,e.y+c/2),t.lineTo(e.x+l+h,e.y+c/2),t.lineTo(e.x+l+h,e.y-c/2),t.lineTo(e.x+d,e.y-c/2),t.arc(e.x,e.y,l,u,-u),t.closePath(),t.fill()}else t.beginPath(),t.arc(e.x,e.y,e.size+2,0,2*Math.PI),t.closePath(),t.fill();t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,(0,o.default)(t,e,r)}},622:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r){if(e.label){var i=r.labelSize,o=r.labelFont,n=r.labelWeight;t.fillStyle="#000",t.font=n+" "+i+"px "+o,t.fillText(e.label,e.x+e.size+3,e.y+i/3)}}},195:function(t,e,r){"use strict";var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.createEdgeCompoundProgram=e.AbstractEdgeProgram=void 0;var n=function(t){function e(e,r,i,o,n){return t.call(this,e,r,i,o,n)||this}return o(e,t),e}(r(171).AbstractProgram);e.AbstractEdgeProgram=n,e.createEdgeCompoundProgram=function(t){return function(){function e(e,r){this.programs=t.map((function(t){return new t(e,r)}))}return e.prototype.bufferData=function(){this.programs.forEach((function(t){return t.bufferData()}))},e.prototype.allocate=function(t){this.programs.forEach((function(e){return e.allocate(t)}))},e.prototype.bind=function(){},e.prototype.computeIndices=function(){this.programs.forEach((function(t){return t.computeIndices()}))},e.prototype.render=function(t){this.programs.forEach((function(e){e.bind(),e.bufferData(),e.render(t)}))},e.prototype.process=function(t,e,r,i,o){this.programs.forEach((function(n){return n.process(t,e,r,i,o)}))},e}()}},909:function(t,e,r){"use strict";var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.createNodeCompoundProgram=e.AbstractNodeProgram=void 0;var n=function(t){function e(e,r,i,o,n){var a=t.call(this,e,r,i,o,n)||this;a.positionLocation=e.getAttribLocation(a.program,"a_position"),a.sizeLocation=e.getAttribLocation(a.program,"a_size"),a.colorLocation=e.getAttribLocation(a.program,"a_color");var s=e.getUniformLocation(a.program,"u_matrix");if(null===s)throw new Error("AbstractNodeProgram: error while getting matrixLocation");a.matrixLocation=s;var h=e.getUniformLocation(a.program,"u_ratio");if(null===h)throw new Error("AbstractNodeProgram: error while getting ratioLocation");a.ratioLocation=h;var c=e.getUniformLocation(a.program,"u_scale");if(null===c)throw new Error("AbstractNodeProgram: error while getting scaleLocation");return a.scaleLocation=c,a}return o(e,t),e.prototype.bind=function(){var t=this.gl;t.enableVertexAttribArray(this.positionLocation),t.enableVertexAttribArray(this.sizeLocation),t.enableVertexAttribArray(this.colorLocation),t.vertexAttribPointer(this.positionLocation,2,t.FLOAT,!1,this.attributes*Float32Array.BYTES_PER_ELEMENT,0),t.vertexAttribPointer(this.sizeLocation,1,t.FLOAT,!1,this.attributes*Float32Array.BYTES_PER_ELEMENT,8),t.vertexAttribPointer(this.colorLocation,4,t.UNSIGNED_BYTE,!0,this.attributes*Float32Array.BYTES_PER_ELEMENT,12)},e}(r(171).AbstractProgram);e.AbstractNodeProgram=n,e.createNodeCompoundProgram=function(t){return function(){function e(e,r){this.programs=t.map((function(t){return new t(e,r)}))}return e.prototype.bufferData=function(){this.programs.forEach((function(t){return t.bufferData()}))},e.prototype.allocate=function(t){this.programs.forEach((function(e){return e.allocate(t)}))},e.prototype.bind=function(){},e.prototype.render=function(t){this.programs.forEach((function(e){return e.render(t)}))},e.prototype.process=function(t,e,r){this.programs.forEach((function(i){return i.process(t,e,r)}))},e}()}},171:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractProgram=void 0;var i=r(706),o=function(){function t(t,e,r,o,n){this.array=new Float32Array,this.points=o,this.attributes=n,this.gl=t,this.vertexShaderSource=e,this.fragmentShaderSource=r;var a=t.createBuffer();if(null===a)throw new Error("AbstractProgram: error while creating the buffer");this.buffer=a,t.bindBuffer(t.ARRAY_BUFFER,this.buffer),this.vertexShader=(0,i.loadVertexShader)(t,this.vertexShaderSource),this.fragmentShader=(0,i.loadFragmentShader)(t,this.fragmentShaderSource),this.program=(0,i.loadProgram)(t,[this.vertexShader,this.fragmentShader])}return t.prototype.bufferData=function(){var t=this.gl;t.bufferData(t.ARRAY_BUFFER,this.array,t.DYNAMIC_DRAW)},t.prototype.allocate=function(t){this.array=new Float32Array(this.points*this.attributes*t)},t}();e.AbstractProgram=o},569:function(t,e,r){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(195),n=i(r(805)),a=i(r(483)),s=(0,o.createEdgeCompoundProgram)([a.default,n.default]);e.default=s},805:function(t,e,r){"use strict";var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var a=r(928),s=n(r(912)),h=n(r(973)),c=r(195),l=10,u=function(t){function e(e){var r=t.call(this,e,s.default,h.default,3,l)||this;r.positionLocation=e.getAttribLocation(r.program,"a_position"),r.colorLocation=e.getAttribLocation(r.program,"a_color"),r.normalLocation=e.getAttribLocation(r.program,"a_normal"),r.thicknessLocation=e.getAttribLocation(r.program,"a_thickness"),r.radiusLocation=e.getAttribLocation(r.program,"a_radius"),r.barycentricLocation=e.getAttribLocation(r.program,"a_barycentric");var i=e.getUniformLocation(r.program,"u_scale");if(null===i)throw new Error("EdgeArrowHeadProgram: error while getting scaleLocation");r.scaleLocation=i;var o=e.getUniformLocation(r.program,"u_matrix");if(null===o)throw new Error("EdgeArrowHeadProgram: error while getting matrixLocation");r.matrixLocation=o;var n=e.getUniformLocation(r.program,"u_cameraRatio");if(null===n)throw new Error("EdgeArrowHeadProgram: error while getting cameraRatioLocation");r.cameraRatioLocation=n;var a=e.getUniformLocation(r.program,"u_viewportRatio");if(null===a)throw new Error("EdgeArrowHeadProgram: error while getting viewportRatioLocation");r.viewportRatioLocation=a;var c=e.getUniformLocation(r.program,"u_thicknessRatio");if(null===c)throw new Error("EdgeArrowHeadProgram: error while getting thicknessRatioLocation");return r.thicknessRatioLocation=c,r.bind(),r}return o(e,t),e.prototype.bind=function(){var t=this.gl;t.enableVertexAttribArray(this.positionLocation),t.enableVertexAttribArray(this.normalLocation),t.enableVertexAttribArray(this.thicknessLocation),t.enableVertexAttribArray(this.radiusLocation),t.enableVertexAttribArray(this.colorLocation),t.enableVertexAttribArray(this.barycentricLocation),t.vertexAttribPointer(this.positionLocation,2,t.FLOAT,!1,l*Float32Array.BYTES_PER_ELEMENT,0),t.vertexAttribPointer(this.normalLocation,2,t.FLOAT,!1,l*Float32Array.BYTES_PER_ELEMENT,8),t.vertexAttribPointer(this.thicknessLocation,1,t.FLOAT,!1,l*Float32Array.BYTES_PER_ELEMENT,16),t.vertexAttribPointer(this.radiusLocation,1,t.FLOAT,!1,l*Float32Array.BYTES_PER_ELEMENT,20),t.vertexAttribPointer(this.colorLocation,4,t.UNSIGNED_BYTE,!0,l*Float32Array.BYTES_PER_ELEMENT,24),t.vertexAttribPointer(this.barycentricLocation,3,t.FLOAT,!1,l*Float32Array.BYTES_PER_ELEMENT,28)},e.prototype.computeIndices=function(){},e.prototype.process=function(t,e,r,i,o){if(i)for(var n=30*o,s=n+30;n{"use strict";function r(t,e,r){var i="VERTEX"===t?e.VERTEX_SHADER:e.FRAGMENT_SHADER,o=e.createShader(i);if(null===o)throw new Error("loadShader: error while creating the shader");if(e.shaderSource(o,r),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS)){var n=e.getShaderInfoLog(o);throw e.deleteShader(o),new Error("loadShader: error while compiling the shader:\n"+n+"\n"+r)}return o}Object.defineProperty(e,"__esModule",{value:!0}),e.loadProgram=e.loadFragmentShader=e.loadVertexShader=void 0,e.loadVertexShader=function(t,e){return r("VERTEX",t,e)},e.loadFragmentShader=function(t,e){return r("FRAGMENT",t,e)},e.loadProgram=function(t,e){var r,i,o=t.createProgram();if(null===o)throw new Error("loadProgram: error while creating the program.");for(r=0,i=e.length;rr-o&&ti-o&&en[1]&&(n[1]=x.zIndex))}for(var y in l){if(!this.nodePrograms.hasOwnProperty(y))throw new Error('Sigma: could not find a suitable program for node type "'+y+'"!');t||this.nodePrograms[y].allocate(l[y]),l[y]=0}for(this.settings.zIndex&&n[0]!==n[1]&&(d=(0,u.zIndexOrdering)(n,(function(t){return e.nodeDataCache[t].zIndex}),d)),f=0,p=d.length;fa[1]&&(a[1]=x.zIndex))}for(var y in w){if(!this.edgePrograms.hasOwnProperty(y))throw new Error('Sigma: could not find a suitable program for edge type "'+y+'"!');t||this.edgePrograms[y].allocate(w[y]),w[y]=0}for(this.settings.zIndex&&a[0]!==a[1]&&(L=(0,u.zIndexOrdering)(a,(function(t){return e.edgeDataCache[t].zIndex}),L)),f=0,p=L.length;f=1)t=new Set(this.graph.nodes());else{var r=this.viewRectangle();t=new Set(this.quadtree.rectangle(r.x1,1-r.y1,r.x2,1-r.y2,r.height))}var i=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);this.displayedLabels=new Set;for(var o=this.canvasContexts.labels,n=0,a=i.length;n=1){for(var i in r){var n=r[i];for(var u in n)t.setNodeAttribute(i,u,n[u])}"function"==typeof a&&a()}else{for(var i in e=h(e),r){n=r[i];var d=l[i];for(var u in n)t.setNodeAttribute(i,u,n[u]*e+d[u]*(1-e))}p=(0,o.requestFrame)(g)}};return g(),function(){p&&(0,o.cancelFrame)(p)}}},358:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.cubicInOut=e.cubicOut=e.cubicIn=e.quadraticInOut=e.quadraticOut=e.quadraticIn=e.linear=void 0,e.linear=function(t){return t},e.quadraticIn=function(t){return t*t},e.quadraticOut=function(t){return t*(2-t)},e.quadraticInOut=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},e.cubicIn=function(t){return t*t*t},e.cubicOut=function(t){return--t*t*t+1},e.cubicInOut=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)};var r={linear:e.linear,quadraticIn:e.quadraticIn,quadraticOut:e.quadraticOut,quadraticInOut:e.quadraticInOut,cubicIn:e.cubicIn,cubicOut:e.cubicOut,cubicInOut:e.cubicInOut};e.default=r},928:function(t,e,r){"use strict";var i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,o,n=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.validateGraph=e.canUse32BitsIndices=e.extractPixel=e.matrixFromCamera=e.getCorrectionRatio=e.floatColor=e.zIndexOrdering=e.createNormalizationFunction=e.getPixelRatio=e.createElement=e.cancelFrame=e.requestFrame=e.assignDeep=e.isPlainObject=void 0;var n=o(r(186)),a=r(700);function s(t){return"object"==typeof t&&null!==t&&t.constructor===Object}e.isPlainObject=s,e.assignDeep=function t(e){for(var r=[],i=1;io?1:0}))};var h={},c=new Int8Array(4),l=new Int32Array(c.buffer,0,1),u=new Float32Array(c.buffer,0,1),d=/^\s*rgba?\s*\(/,f=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function p(t,e){var r=t.height/t.width,i=e.height/e.width;return r<1&&i>1||r>1&&i<1?1:Math.min(Math.max(i,1/i),Math.max(1/r,r))}e.floatColor=function(t){if(void 0!==h[t])return h[t];var e=0,r=0,i=0,o=1;if("#"===t[0])4===t.length?(e=parseInt(t.charAt(1)+t.charAt(1),16),r=parseInt(t.charAt(2)+t.charAt(2),16),i=parseInt(t.charAt(3)+t.charAt(3),16)):(e=parseInt(t.charAt(1)+t.charAt(2),16),r=parseInt(t.charAt(3)+t.charAt(4),16),i=parseInt(t.charAt(5)+t.charAt(6),16));else if(d.test(t)){var n=t.match(f);n&&(e=+n[1],r=+n[2],i=+n[3],n[4]&&(o=+n[4]))}o=255*o|0,l[0]=4278190079&(o<<24|i<<16|r<<8|e);var a=u[0];return h[t]=a,a},e.getCorrectionRatio=p,e.matrixFromCamera=function(t,e,r,i,o){var n=t.angle,s=t.ratio,h=t.x,c=t.y,l=e.width,u=e.height,d=(0,a.identity)(),f=Math.min(l,u)-2*i,g=p(e,r);return o?((0,a.multiply)(d,(0,a.translate)((0,a.identity)(),h,c)),(0,a.multiply)(d,(0,a.scale)((0,a.identity)(),s)),(0,a.multiply)(d,(0,a.rotate)((0,a.identity)(),n)),(0,a.multiply)(d,(0,a.scale)((0,a.identity)(),l/f/2/g,u/f/2/g))):((0,a.multiply)(d,(0,a.scale)((0,a.identity)(),f/l*2*g,f/u*2*g)),(0,a.multiply)(d,(0,a.rotate)((0,a.identity)(),-n)),(0,a.multiply)(d,(0,a.scale)((0,a.identity)(),1/s)),(0,a.multiply)(d,(0,a.translate)((0,a.identity)(),-h,-c))),d},e.extractPixel=function(t,e,r,i){var o=i||new Uint8Array(4);return t.readPixels(e,r,1,1,t.RGBA,t.UNSIGNED_BYTE,o),o},e.canUse32BitsIndices=function(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||!!t.getExtension("OES_element_index_uint")},e.validateGraph=function(t){if(!(0,n.default)(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode((function(t,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error("Sigma: Coordinates of node "+t+" are invalid. A node must have a numeric 'x' and 'y' attribute.")}))}},700:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.multiplyVec=e.multiply=e.translate=e.rotate=e.scale=e.identity=void 0,e.identity=function(){return Float32Array.of(1,0,0,0,1,0,0,0,1)},e.scale=function(t,e,r){return t[0]=e,t[4]="number"==typeof r?r:e,t},e.rotate=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[3]=-r,t[4]=i,t},e.translate=function(t,e,r){return t[6]=e,t[7]=r,t},e.multiply=function(t,e){var r=t[0],i=t[1],o=t[2],n=t[3],a=t[4],s=t[5],h=t[6],c=t[7],l=t[8],u=e[0],d=e[1],f=e[2],p=e[3],g=e[4],v=e[5],m=e[6],y=e[7],_=e[8];return t[0]=u*r+d*n+f*h,t[1]=u*i+d*a+f*c,t[2]=u*o+d*s+f*l,t[3]=p*r+g*n+v*h,t[4]=p*i+g*a+v*c,t[5]=p*o+g*s+v*l,t[6]=m*r+y*n+_*h,t[7]=m*i+y*a+_*c,t[8]=m*o+y*s+_*l,t},e.multiplyVec=function(t,e){var r=t[0],i=t[1],o=t[2],n=t[3],a=t[4],s=t[5],h=t[6],c=t[7],l=t[8],u=e[0],d=e[1],f=e[2],p=Array.isArray(e)?[0,0,0]:Float32Array.of(0,0,0);return p[0]=u*r+d*n+f*h,p[1]=u*i+d*a+f*c,p[2]=u*o+d*s+f*l,p}}},e={};function r(i){var o=e[i];if(void 0!==o)return o.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(607)})()})); \ No newline at end of file