From 404db549991efe0ae3def4ad65b08a8e980df80c Mon Sep 17 00:00:00 2001 From: enricobono99 Date: Thu, 18 Jun 2026 12:50:37 +0200 Subject: [PATCH] feat(graph): add unweighted shortest-path between two selected nodes Add a "Shortest Path" action that, given exactly two selected nodes, adds the fewest-hops path connecting them - its nodes and the edges between them - to the current selection. Computed on the visible subgraph so it honours active filters. - New pure, node-safe module graph/shortest_path.js (mirrors communities.js / visible_graph.js): buildVisibleGraph(cache) + graphology bidirectional BFS, returning {found, nodes, edges, hops}; edge ids derived from consecutive node pairs via graph.edges(u, v) on the undirected multigraph. - Promote graphology-shortest-path to a direct dependency, export bidirectional from the graphology vendor entry, add it to the bundle pkgs list, and rebundle (graphology.bundle.mjs). - selectShortestPathBetweenSelected() on GraphSelectionManager reuses the existing updateSelectedState selection machinery. - "Shortest Path" button in the Select Elements card, below Expand/Reduce Neighbors, gated via toggleStyleElementsThatRequireExactlyTwoSelectedNodes (enabled only when exactly two nodes are selected). - tests/shortest-path.test.js covers direct/multi-hop, shorter-of-two, undirected reverse, disconnected, source==target, non-visible endpoint, hidden edge, and parallel edges. --- package-lock.json | 1 + package.json | 1 + src/graph/selection.js | 35 +++++ src/graph/shortest_path.js | 47 +++++++ src/lib/graphology.bundle.mjs | 8 +- src/managers/ui.js | 4 + src/managers/ui_style_div.js | 5 + src/package/vendor_entry_graphology.mjs | 3 + src/package/vendor_libs.js | 2 +- tests/selection-group-button-sync.test.js | 1 + tests/shortest-path.test.js | 154 ++++++++++++++++++++++ 11 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 src/graph/shortest_path.js create mode 100644 tests/shortest-path.test.js diff --git a/package-lock.json b/package-lock.json index a8e3ada..ccb531c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "graphology-layout-forceatlas2": "^0.10.1", "graphology-layout-noverlap": "^0.4.2", "graphology-metrics": "^2.4.0", + "graphology-shortest-path": "^2.1.0", "marked": "^18.0.2", "polygon-clipping": "^0.15.7", "sigma": "^3.0.3" diff --git a/package.json b/package.json index 402215a..1517b55 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "graphology-layout-forceatlas2": "^0.10.1", "graphology-layout-noverlap": "^0.4.2", "graphology-metrics": "^2.4.0", + "graphology-shortest-path": "^2.1.0", "marked": "^18.0.2", "polygon-clipping": "^0.15.7", "sigma": "^3.0.3" diff --git a/src/graph/selection.js b/src/graph/selection.js index 5580823..5cd674e 100644 --- a/src/graph/selection.js +++ b/src/graph/selection.js @@ -1,4 +1,5 @@ import { StaticUtilities } from '../utilities/static.js'; +import { findShortestPath } from './shortest_path.js'; class GraphSelectionManager { constructor(cache) { @@ -291,6 +292,38 @@ class GraphSelectionManager { await update(); } + /** + * Adds the unweighted shortest path between the two currently selected + * nodes — its nodes and the edges between them — to the selection. Computed + * on the visible subgraph so it honours active filters. Requires exactly two + * selected nodes (warns otherwise); reuses updateSelectedState so the path + * lights up through the existing selection machinery. + */ + async selectShortestPathBetweenSelected() { + if (!this.cache.graph) return; + + const selected = this.cache.selectedNodes; + if (selected.length !== 2) { + this.cache.ui.warning('Select exactly two nodes to find the shortest path between them.'); + return; + } + + const [source, target] = selected; + const { found, nodes, edges } = findShortestPath(this.cache, source, target); + + if (!found) { + this.cache.ui.warning('No path connects the two selected nodes in the visible graph.'); + return; + } + + const elemData = [ + ...nodes.map((id) => this.cache.nodeRef.get(id)), + ...edges.map((id) => this.cache.edgeRef.get(id)), + ].filter(Boolean); + + await this.updateSelectedState(elemData, true); + } + updateSelectionCache() { const { selectedNodes, selectedEdges, selectionMemory, selectedMemoryIndex } = this.cache; @@ -383,6 +416,7 @@ class GraphSelectionManager { } } const moreThanOneNodeSelected = selectedNodesCount > 1; + const exactlyTwoNodesSelected = selectedNodesCount === 2; this.cache.ui.toggleStyleElementsThatRequireAtLeastOneSelectedNode(atLeastOneNodeSelected); this.cache.ui.toggleStyleElementsThatRequireAtLeastOneSelectedEdge(atLeastOneEdgeSelected); @@ -390,6 +424,7 @@ class GraphSelectionManager { atLeastOneNodeOrEdgeSelected ); this.cache.ui.toggleStyleElementsThatRequireMoreThanOneSelectedNode(moreThanOneNodeSelected); + this.cache.ui.toggleStyleElementsThatRequireExactlyTwoSelectedNodes(exactlyTwoNodesSelected); this.updateSelectionCache(); this.updateEnabledStateUndoRedoSelectionButtons(); diff --git a/src/graph/shortest_path.js b/src/graph/shortest_path.js new file mode 100644 index 0000000..3b935c7 --- /dev/null +++ b/src/graph/shortest_path.js @@ -0,0 +1,47 @@ +// Node-safe (no DOM): unweighted (BFS) shortest path over the visible +// subgraph. The pure algorithm lives here so it can be unit-tested; the +// DOM-bound application path (adding the path to the selection) lives in +// graph/selection.js. Mirrors graph/communities.js and visible_graph.js. +import {bidirectional} from "../lib/graphology.bundle.mjs"; +import {buildVisibleGraph} from "./visible_graph.js"; + +/** + * Finds the unweighted (fewest-hops) shortest path between two nodes on the + * currently visible subgraph, so it honours the active filters. The visible + * graph is an undirected multigraph keyed by edge id. + * + * @param {{nodeIDsToBeShown: Set, edgeIDsToBeShown: Set, edgeRef: Map}} cache + * @param {string} source source node id + * @param {string} target target node id + * @returns {{found: boolean, nodes: string[], edges: string[], hops: number}} + * found: whether a path exists in the visible graph. nodes: the path's node + * ids in order (source → target). edges: one edge id per consecutive node + * pair (the first of any parallel edges). hops: number of edges on the path. + * When no path exists — disconnected, or an endpoint is not visible — found + * is false and nodes/edges are empty. + */ +function findShortestPath(cache, source, target) { + const graph = buildVisibleGraph(cache); + + // Both endpoints must be in the visible subgraph; bidirectional throws on a + // missing node, so guard here and treat it as "no path". + if (!graph.hasNode(source) || !graph.hasNode(target)) { + return {found: false, nodes: [], edges: [], hops: 0}; + } + + const nodes = bidirectional(graph, source, target); + if (!nodes) return {found: false, nodes: [], edges: [], hops: 0}; + + // Derive one edge id per consecutive node pair. graph.edges(u, v) returns + // every parallel edge between u and v on the undirected multigraph; the + // first keeps the result deterministic (any of them is a valid hop). + const edges = []; + for (let i = 0; i < nodes.length - 1; i++) { + const between = graph.edges(nodes[i], nodes[i + 1]); + if (between.length) edges.push(between[0]); + } + + return {found: true, nodes, edges, hops: nodes.length - 1}; +} + +export {findShortestPath}; diff --git a/src/lib/graphology.bundle.mjs b/src/lib/graphology.bundle.mjs index c4c2fbd..2abc16b 100644 --- a/src/lib/graphology.bundle.mjs +++ b/src/lib/graphology.bundle.mjs @@ -1,13 +1,13 @@ -var ox=Object.create;var zn=Object.defineProperty;var sx=Object.getOwnPropertyDescriptor;var ax=Object.getOwnPropertyNames;var ux=Object.getPrototypeOf,fx=Object.prototype.hasOwnProperty;var hd=r=>{throw TypeError(r)};var hx=(r,e,t)=>e in r?zn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var De=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),$s=(r,e)=>{for(var t in e)zn(r,t,{get:e[t],enumerable:!0})},cx=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ax(e))!fx.call(r,n)&&n!==t&&zn(r,n,{get:()=>e[n],enumerable:!(i=sx(e,n))||i.enumerable});return r};var et=(r,e,t)=>(t=r!=null?ox(ux(r)):{},cx(e||!r||!r.__esModule?zn(t,"default",{value:r,enumerable:!0}):t,r));var cd=(r,e,t)=>hx(r,typeof e!="symbol"?e+"":e,t),Us=(r,e,t)=>e.has(r)||hd("Cannot "+t);var At=(r,e,t)=>(Us(r,e,"read from private field"),t?t.call(r):e.get(r)),Ws=(r,e,t)=>e.has(r)?hd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$n=(r,e,t,i)=>(Us(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Bs=(r,e,t)=>(Us(r,e,"access private method"),t);var bd=De((lC,Vs)=>{"use strict";var Li=typeof Reflect=="object"?Reflect:null,ld=Li&&typeof Li.apply=="function"?Li.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Un;Li&&typeof Li.ownKeys=="function"?Un=Li.ownKeys:Object.getOwnPropertySymbols?Un=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Un=function(e){return Object.getOwnPropertyNames(e)};function lx(r){console&&console.warn&&console.warn(r)}var pd=Number.isNaN||function(e){return e!==e};function or(){or.init.call(this)}Vs.exports=or;Vs.exports.once=mx;or.EventEmitter=or;or.prototype._events=void 0;or.prototype._eventsCount=0;or.prototype._maxListeners=void 0;var dd=10;function Wn(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(or,"defaultMaxListeners",{enumerable:!0,get:function(){return dd},set:function(r){if(typeof r!="number"||r<0||pd(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");dd=r}});or.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};or.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||pd(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function gd(r){return r._maxListeners===void 0?or.defaultMaxListeners:r._maxListeners}or.prototype.getMaxListeners=function(){return gd(this)};or.prototype.emit=function(e){for(var t=[],i=1;i0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var h=o[e];if(h===void 0)return!1;if(typeof h=="function")ld(h,this,t);else for(var f=h.length,l=wd(h,f),i=0;i0&&s.length>n&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=s.length,lx(a)}return r}or.prototype.addListener=function(e,t){return md(this,e,t,!1)};or.prototype.on=or.prototype.addListener;or.prototype.prependListener=function(e,t){return md(this,e,t,!0)};function dx(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function yd(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=dx.bind(i);return n.listener=t,i.wrapFn=n,n}or.prototype.once=function(e,t){return Wn(t),this.on(e,yd(this,e,t)),this};or.prototype.prependOnceListener=function(e,t){return Wn(t),this.prependListener(e,yd(this,e,t)),this};or.prototype.removeListener=function(e,t){var i,n,o,s,a;if(Wn(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():px(i,o),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};or.prototype.off=or.prototype.removeListener;or.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function _d(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?gx(n):wd(n,n.length)}or.prototype.listeners=function(e){return _d(this,e,!0)};or.prototype.rawListeners=function(e){return _d(this,e,!1)};or.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):vd.call(r,e)};or.prototype.listenerCount=vd;function vd(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}or.prototype.eventNames=function(){return this._eventsCount>0?Un(this._events):[]};function wd(r,e){for(var t=new Array(e),i=0;i{function ES(r){return!r||typeof r!="object"||typeof r=="function"||Array.isArray(r)||r instanceof Set||r instanceof Map||r instanceof RegExp||r instanceof Date}function jd(r,e){r=r||{};var t={};for(var i in e){var n=r[i],o=e[i];if(!ES(o)){t[i]=jd(n,o);continue}n===void 0?t[i]=o:t[i]=n}return t}Pd.exports=jd});var Or=De((gC,Gd)=>{Gd.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var $d=De((mC,zd)=>{function Nd(r){return function(e,t){return e+Math.floor(r()*(t-e+1))}}var Fd=Nd(Math.random);Fd.createRandom=Nd;zd.exports=Fd});var Vd=De((yC,Bd)=>{var xS=$d().createRandom;function Ud(r){var e=xS(r);return function(t){for(var i=t.length,n=i-1,o=-1;++o{var SS=_t(),IS=Or(),AS=Vd(),RS={attributes:{x:"x",y:"y"},center:0,hierarchyAttributes:[],rng:Math.random,scale:1};function nt(r,e,t,i,n){this.wrappedCircle=n||null,this.children={},this.countChildren=0,this.id=r||null,this.next=null,this.previous=null,this.x=e||null,this.y=t||null,n?this.r=1010101:this.r=i||999}nt.prototype.hasChildren=function(){return this.countChildren>0};nt.prototype.addChild=function(r,e){this.children[r]=e,++this.countChildren};nt.prototype.getChild=function(r){if(!this.children.hasOwnProperty(r)){var e=new nt;this.children[r]=e,++this.countChildren}return this.children[r]};nt.prototype.applyPositionToChildren=function(){if(this.hasChildren()){var r=this;for(var e in r.children){var t=r.children[e];t.x+=r.x,t.y+=r.y,t.applyPositionToChildren()}}};function Qd(r,e,t){for(var i in e.children){var n=e.children[i];n.hasChildren()?Qd(r,n,t):t[n.id]={x:n.x,y:n.y}}}function Jn(r,e){var t=r.r-e.r,i=e.x-r.x,n=e.y-r.y;return t<0||t*t0&&t*t>i*i+n*n}function Js(r,e){for(var t=0;th?(n=(f+h-o)/(2*f),a=Math.sqrt(Math.max(0,h/f-n*n)),t.x=r.x-n*i-a*s,t.y=r.y-n*s+a*i):(n=(f+o-h)/(2*f),a=Math.sqrt(Math.max(0,o/f-n*n)),t.x=e.x+n*i-a*s,t.y=e.y+n*s+a*i)):(t.x=e.x+t.r,t.y=e.y)}function Xd(r,e){var t=r.r+e.r-1e-6,i=e.x-r.x,n=e.y-r.y;return t>0&&t*t>i*i+n*n}function LS(r,e){var t=r.length;if(t===0)return 0;var i,n,o,s,a,h,f,l,g,m;if(i=r[0],i.x=0,i.y=0,t<=1)return i.r;if(n=r[1],i.x=-n.r,n.x=i.r,n.y=0,t<=2)return i.r+n.r;o=r[2],Yd(n,i,o),i=new nt(null,null,null,null,i),n=new nt(null,null,null,null,n),o=new nt(null,null,null,null,o),i.next=o.previous=n,n.next=i.previous=o,o.next=n.previous=i;e:for(h=3;h{var DS=_t(),jS=Or(),PS={dimensions:["x","y"],center:.5,scale:1};function np(r,e,t){if(!jS(e))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");t=DS(t,PS);var i=t.dimensions;if(!Array.isArray(i)||i.length!==2)throw new Error("graphology-layout/random: given dimensions are invalid.");var n=t.center,o=t.scale,s=Math.PI*2,a=(n-.5)*o,h=e.order,f=i[0],l=i[1];function g(E,q){return q[f]=o*Math.cos(E*s/h)+a,q[l]=o*Math.sin(E*s/h)+a,q}var m=0;if(!r){var _={};return e.forEachNode(function(E){_[E]=g(m++,{})}),_}e.updateEachNodeAttributes(function(E,q){return g(m++,q),q},{attributes:i})}var op=np.bind(null,!1);op.assign=np.bind(null,!0);sp.exports=op});var cp=De((wC,hp)=>{var GS=_t(),NS=Or(),FS={dimensions:["x","y"],center:.5,rng:Math.random,scale:1};function up(r,e,t){if(!NS(e))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");t=GS(t,FS);var i=t.dimensions;if(!Array.isArray(i)||i.length<1)throw new Error("graphology-layout/random: given dimensions are invalid.");var n=i.length,o=t.center,s=t.rng,a=t.scale,h=(o-.5)*a;function f(g){for(var m=0;m{var zS=_t(),$S=Or(),US=Math.PI/180,WS={dimensions:["x","y"],centeredOnZero:!1,degrees:!1};function lp(r,e,t,i){if(!$S(e))throw new Error("graphology-layout/rotation: the given graph is not a valid graphology instance.");i=zS(i,WS),i.degrees&&(t*=US);var n=i.dimensions;if(!Array.isArray(n)||n.length!==2)throw new Error("graphology-layout/random: given dimensions are invalid.");if(e.order===0)return r?void 0:{};var o=n[0],s=n[1],a=0,h=0;if(!i.centeredOnZero){var f=1/0,l=-1/0,g=1/0,m=-1/0;e.forEachNode(function(A,S){var I=S[o],M=S[s];Il&&(l=I),Mm&&(m=M)}),a=(f+l)/2,h=(g+m)/2}var _=Math.cos(t),E=Math.sin(t);function q(A){var S=A[o],I=A[s];return A[o]=a+(S-a)*_-(I-h)*E,A[s]=h+(S-a)*E+(I-h)*_,A}if(!r){var x={};return e.forEachNode(function(A,S){var I={};I[o]=S[o],I[s]=S[s],x[A]=q(I)}),x}e.updateEachNodeAttributes(function(A,S){return q(S),S},{attributes:n})}var dp=lp.bind(null,!1);dp.assign=lp.bind(null,!0);pp.exports=dp});var mp=De(qn=>{qn.circlepack=ip();qn.circular=ap();qn.random=cp();qn.rotation=gp()});var Gi=De(Hn=>{function BS(r){return typeof r!="number"||isNaN(r)?1:r}function VS(r,e){var t={},i=function(s){return typeof s>"u"?e:s};typeof e=="function"&&(i=e);var n=function(s){return i(s[r])},o=function(){return i(void 0)};return typeof r=="string"?(t.fromAttributes=n,t.fromGraph=function(s,a){return n(s.getNodeAttributes(a))},t.fromEntry=function(s,a){return n(a)}):typeof r=="function"?(t.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},t.fromGraph=function(s,a){return i(r(a,s.getNodeAttributes(a)))},t.fromEntry=function(s,a){return i(r(s,a))}):(t.fromAttributes=o,t.fromGraph=o,t.fromEntry=o),t}function yp(r,e){var t={},i=function(s){return typeof s>"u"?e:s};typeof e=="function"&&(i=e);var n=function(s){return i(s[r])},o=function(){return i(void 0)};return typeof r=="string"?(t.fromAttributes=n,t.fromGraph=function(s,a){return n(s.getEdgeAttributes(a))},t.fromEntry=function(s,a){return n(a)},t.fromPartialEntry=t.fromEntry,t.fromMinimalEntry=t.fromEntry):typeof r=="function"?(t.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},t.fromGraph=function(s,a){var h=s.extremities(a);return i(r(a,s.getEdgeAttributes(a),h[0],h[1],s.getNodeAttributes(h[0]),s.getNodeAttributes(h[1]),s.isUndirected(a)))},t.fromEntry=function(s,a,h,f,l,g,m){return i(r(s,a,h,f,l,g,m))},t.fromPartialEntry=function(s,a,h,f){return i(r(s,a,h,f))},t.fromMinimalEntry=function(s,a){return i(r(s,a))}):(t.fromAttributes=o,t.fromGraph=o,t.fromEntry=o,t.fromMinimalEntry=o),t}Hn.createNodeValueGetter=VS;Hn.createEdgeValueGetter=yp;Hn.createEdgeWeightGetter=function(r){return yp(r,BS)}});var bp=De((xC,qp)=>{var Dr=0,br=1,Je=2,He=3,Yt=4,Xt=5,rr=6,_p=7,eo=8,vp=9,KS=0,YS=1,XS=2,Ur=0,vt=1,rt=2,Ai=3,Jt=4,xr=5,ot=6,Lt=7,Mt=8,wp=3,Ct=10,QS=3,Qr=9,Hs=10;qp.exports=function(e,t,i){var n,o,s,a,h,f,l,g,m,_,E=t.length,q=i.length,x=e.adjustSizes,A=e.barnesHutTheta*e.barnesHutTheta,S,I,M,D,z,O,N,j=[];for(s=0;sB?(oe-=(Oe-B)/2,me=oe+Oe):(X-=(B-Oe)/2,re=X+B),j[0+Ur]=-1,j[0+vt]=(X+re)/2,j[0+rt]=(oe+me)/2,j[0+Ai]=Math.max(re-X,me-oe),j[0+Jt]=-1,j[0+xr]=-1,j[0+ot]=0,j[0+Lt]=0,j[0+Mt]=0,n=1,s=0;s=0){t[s+Dr]=0)if(O=Math.pow(t[s+Dr]-j[o+Lt],2)+Math.pow(t[s+br]-j[o+Mt],2),_=j[o+Ai],4*_*_/O0?(N=I*t[s+rr]*j[o+ot]/O,t[s+Je]+=M*N,t[s+He]+=D*N):O<0&&(N=-I*t[s+rr]*j[o+ot]/Math.sqrt(O),t[s+Je]+=M*N,t[s+He]+=D*N):O>0&&(N=I*t[s+rr]*j[o+ot]/O,t[s+Je]+=M*N,t[s+He]+=D*N),o=j[o+Jt],o<0)break;continue}else{o=j[o+xr];continue}else{if(f=j[o+Ur],f>=0&&f!==s&&(M=t[s+Dr]-t[f+Dr],D=t[s+br]-t[f+br],O=M*M+D*D,x===!0?O>0?(N=I*t[s+rr]*t[f+rr]/O,t[s+Je]+=M*N,t[s+He]+=D*N):O<0&&(N=-I*t[s+rr]*t[f+rr]/Math.sqrt(O),t[s+Je]+=M*N,t[s+He]+=D*N):O>0&&(N=I*t[s+rr]*t[f+rr]/O,t[s+Je]+=M*N,t[s+He]+=D*N)),o=j[o+Jt],o<0)break;continue}else for(I=e.scalingRatio,a=0;a0?(N=I*t[a+rr]*t[h+rr]/O/O,t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N):O<0&&(N=100*I*t[a+rr]*t[h+rr],t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N)):(O=Math.sqrt(M*M+D*D),O>0&&(N=I*t[a+rr]*t[h+rr]/O/O,t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N));for(m=e.gravity/e.scalingRatio,I=e.scalingRatio,s=0;s0&&(N=I*t[s+rr]*m):O>0&&(N=I*t[s+rr]*m/O),t[s+Je]-=M*N,t[s+He]-=D*N;for(I=1*(e.outboundAttractionDistribution?S:1),l=0;l0&&(N=-I*z*Math.log(1+O)/O/t[a+rr]):O>0&&(N=-I*z*Math.log(1+O)/O):e.outboundAttractionDistribution?O>0&&(N=-I*z/t[a+rr]):O>0&&(N=-I*z)):(O=Math.sqrt(Math.pow(M,2)+Math.pow(D,2)),e.linLogMode?e.outboundAttractionDistribution?O>0&&(N=-I*z*Math.log(1+O)/O/t[a+rr]):O>0&&(N=-I*z*Math.log(1+O)/O):e.outboundAttractionDistribution?(O=1,N=-I*z/t[a+rr]):(O=1,N=-I*z)),O>0&&(t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N);var pr,Ze,ge,U,Ge,Z;if(x===!0)for(s=0;sHs&&(t[s+Je]=t[s+Je]*Hs/pr,t[s+He]=t[s+He]*Hs/pr),Ze=t[s+rr]*Math.sqrt((t[s+Yt]-t[s+Je])*(t[s+Yt]-t[s+Je])+(t[s+Xt]-t[s+He])*(t[s+Xt]-t[s+He])),ge=Math.sqrt((t[s+Yt]+t[s+Je])*(t[s+Yt]+t[s+Je])+(t[s+Xt]+t[s+He])*(t[s+Xt]+t[s+He]))/2,U=.1*Math.log(1+ge)/(1+Math.sqrt(Ze)),Ge=t[s+Dr]+t[s+Je]*(U/e.slowDown),t[s+Dr]=Ge,Z=t[s+br]+t[s+He]*(U/e.slowDown),t[s+br]=Z);else for(s=0;s{var bn=10,Ep=3;Ht.assign=function(r){r=r||{};var e=Array.prototype.slice.call(arguments).slice(1),t,i,n;for(t=0,n=e.length;t=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};Ht.graphToByteArrays=function(r,e){var t=r.order,i=r.size,n={},o,s=new Float32Array(t*bn),a=new Float32Array(i*Ep);return o=0,r.forEachNode(function(h,f){n[h]=o,s[o]=f.x,s[o+1]=f.y,s[o+2]=0,s[o+3]=0,s[o+4]=0,s[o+5]=0,s[o+6]=1,s[o+7]=1,s[o+8]=f.size||1,s[o+9]=f.fixed?1:0,o+=bn}),o=0,r.forEachEdge(function(h,f,l,g,m,_,E){var q=n[l],x=n[g],A=e(h,f,l,g,m,_,E);s[q+6]+=A,s[x+6]+=A,a[o]=q,a[o+1]=x,a[o+2]=A,o+=Ep}),{nodes:s,edges:a}};Ht.assignLayoutChanges=function(r,e,t){var i=0;r.updateEachNodeAttributes(function(n,o){return o.x=e[i],o.y=e[i+1],i+=bn,t?t(n,o):o})};Ht.readGraphPositions=function(r,e){var t=0;r.forEachNode(function(i,n){e[t]=n.x,e[t+1]=n.y,t+=bn})};Ht.collectLayoutChanges=function(r,e,t){for(var i=r.nodes(),n={},o=0,s=0,a=e.length;o{xp.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}});var Ap=De((AC,Ip)=>{var ZS=Or(),JS=Gi().createEdgeWeightGetter,HS=bp(),En=ea(),eI=ra();function Sp(r,e,t){if(!ZS(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof t=="number"&&(t={iterations:t});var i=t.iterations;if(typeof i!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(i<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var n=JS("getEdgeWeight"in t?t.getEdgeWeight:"weight").fromEntry,o=typeof t.outputReducer=="function"?t.outputReducer:null,s=En.assign({},eI,t.settings),a=En.validateSettings(s);if(a)throw new Error("graphology-layout-forceatlas2: "+a.message);var h=En.graphToByteArrays(e,n),f;for(f=0;f2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}}var ta=Sp.bind(null,!1);ta.assign=Sp.bind(null,!0);ta.inferSettings=rI;Ip.exports=ta});var Cp=De((RC,Rp)=>{Rp.exports=function(){var e,t,i={};(function(){var o=0,s=1,a=2,h=3,f=4,l=5,g=6,m=7,_=8,E=9,q=0,x=1,A=2,S=0,I=1,M=2,D=3,z=4,O=5,N=6,j=7,X=8,re=3,oe=10,me=3,_e=9,Te=10;i.exports=function(Oe,B,pr){var Ze,ge,U,Ge,Z,W,ue,le,de,Ye,Be=B.length,wr=pr.length,er=Oe.adjustSizes,qr=Oe.barnesHutTheta*Oe.barnesHutTheta,Xe,Ae,ze,be,sr,Se,Le,ie=[];for(U=0;USt?(Tr-=(Ot-St)/2,cr=Tr+Ot):(tr-=(St-Ot)/2,ar=tr+St),ie[0+S]=-1,ie[0+I]=(tr+ar)/2,ie[0+M]=(Tr+cr)/2,ie[0+D]=Math.max(ar-tr,cr-Tr),ie[0+z]=-1,ie[0+O]=-1,ie[0+N]=0,ie[0+j]=0,ie[0+X]=0,Ze=1,U=0;U=0){B[U+o]=0)if(Se=Math.pow(B[U+o]-ie[ge+j],2)+Math.pow(B[U+s]-ie[ge+X],2),Ye=ie[ge+D],4*Ye*Ye/Se0?(Le=Ae*B[U+g]*ie[ge+N]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le):Se<0&&(Le=-Ae*B[U+g]*ie[ge+N]/Math.sqrt(Se),B[U+a]+=ze*Le,B[U+h]+=be*Le):Se>0&&(Le=Ae*B[U+g]*ie[ge+N]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le),ge=ie[ge+z],ge<0)break;continue}else{ge=ie[ge+O];continue}else{if(W=ie[ge+S],W>=0&&W!==U&&(ze=B[U+o]-B[W+o],be=B[U+s]-B[W+s],Se=ze*ze+be*be,er===!0?Se>0?(Le=Ae*B[U+g]*B[W+g]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le):Se<0&&(Le=-Ae*B[U+g]*B[W+g]/Math.sqrt(Se),B[U+a]+=ze*Le,B[U+h]+=be*Le):Se>0&&(Le=Ae*B[U+g]*B[W+g]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le)),ge=ie[ge+z],ge<0)break;continue}else for(Ae=Oe.scalingRatio,Ge=0;Ge0?(Le=Ae*B[Ge+g]*B[Z+g]/Se/Se,B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le):Se<0&&(Le=100*Ae*B[Ge+g]*B[Z+g],B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le)):(Se=Math.sqrt(ze*ze+be*be),Se>0&&(Le=Ae*B[Ge+g]*B[Z+g]/Se/Se,B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le));for(de=Oe.gravity/Oe.scalingRatio,Ae=Oe.scalingRatio,U=0;U0&&(Le=Ae*B[U+g]*de):Se>0&&(Le=Ae*B[U+g]*de/Se),B[U+a]-=ze*Le,B[U+h]-=be*Le;for(Ae=1*(Oe.outboundAttractionDistribution?Xe:1),ue=0;ue0&&(Le=-Ae*sr*Math.log(1+Se)/Se/B[Ge+g]):Se>0&&(Le=-Ae*sr*Math.log(1+Se)/Se):Oe.outboundAttractionDistribution?Se>0&&(Le=-Ae*sr/B[Ge+g]):Se>0&&(Le=-Ae*sr)):(Se=Math.sqrt(Math.pow(ze,2)+Math.pow(be,2)),Oe.linLogMode?Oe.outboundAttractionDistribution?Se>0&&(Le=-Ae*sr*Math.log(1+Se)/Se/B[Ge+g]):Se>0&&(Le=-Ae*sr*Math.log(1+Se)/Se):Oe.outboundAttractionDistribution?(Se=1,Le=-Ae*sr/B[Ge+g]):(Se=1,Le=-Ae*sr)),Se>0&&(B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le);var K,v,b,k,G,P;if(er===!0)for(U=0;UTe&&(B[U+a]=B[U+a]*Te/K,B[U+h]=B[U+h]*Te/K),v=B[U+g]*Math.sqrt((B[U+f]-B[U+a])*(B[U+f]-B[U+a])+(B[U+l]-B[U+h])*(B[U+l]-B[U+h])),b=Math.sqrt((B[U+f]+B[U+a])*(B[U+f]+B[U+a])+(B[U+l]+B[U+h])*(B[U+l]+B[U+h]))/2,k=.1*Math.log(1+b)/(1+Math.sqrt(v)),G=B[U+o]+B[U+a]*(k/Oe.slowDown),B[U+o]=G,P=B[U+s]+B[U+h]*(k/Oe.slowDown),B[U+s]=P);else for(U=0;U{var tI=Cp(),iI=Or(),nI=Gi().createEdgeWeightGetter,Ni=ea(),oI=ra();function ei(r,e){if(e=e||{},!iI(r))throw new Error("graphology-layout-forceatlas2/worker: the given graph is not a valid graphology instance.");var t=nI("getEdgeWeight"in e?e.getEdgeWeight:"weight").fromEntry,i=Ni.assign({},oI,e.settings),n=Ni.validateSettings(i);if(n)throw new Error("graphology-layout-forceatlas2/worker: "+n.message);this.worker=null,this.graph=r,this.settings=i,this.getEdgeWeight=t,this.matrices=null,this.running=!1,this.killed=!1,this.outputReducer=typeof e.outputReducer=="function"?e.outputReducer:null,this.handleMessage=this.handleMessage.bind(this);var o=void 0,s=this;this.handleGraphUpdate=function(){s.worker&&s.worker.terminate(),o&&clearTimeout(o),o=setTimeout(function(){o=void 0,s.spawnWorker()},0)},r.on("nodeAdded",this.handleGraphUpdate),r.on("edgeAdded",this.handleGraphUpdate),r.on("nodeDropped",this.handleGraphUpdate),r.on("edgeDropped",this.handleGraphUpdate),this.spawnWorker()}ei.prototype.isRunning=function(){return this.running};ei.prototype.spawnWorker=function(){this.worker&&this.worker.terminate(),this.worker=Ni.createWorker(tI),this.worker.addEventListener("message",this.handleMessage),this.running&&(this.running=!1,this.start())};ei.prototype.handleMessage=function(r){if(this.running){var e=new Float32Array(r.data.nodes);Ni.assignLayoutChanges(this.graph,e,this.outputReducer),this.outputReducer&&Ni.readGraphPositions(this.graph,e),this.matrices.nodes=e,this.askForIterations()}};ei.prototype.askForIterations=function(r){var e=this.matrices,t={settings:this.settings,nodes:e.nodes.buffer},i=[e.nodes.buffer];return r&&(t.edges=e.edges.buffer,i.push(e.edges.buffer)),this.worker.postMessage(t,i),this};ei.prototype.start=function(){if(this.killed)throw new Error("graphology-layout-forceatlas2/worker.start: layout was killed.");return this.running?this:(this.matrices=Ni.graphToByteArrays(this.graph,this.getEdgeWeight),this.running=!0,this.askForIterations(!0),this)};ei.prototype.stop=function(){return this.running=!1,this};ei.prototype.kill=function(){if(this.killed)return this;this.running=!1,this.killed=!0,this.matrices=null,this.worker.terminate(),this.graph.removeListener("nodeAdded",this.handleGraphUpdate),this.graph.removeListener("edgeAdded",this.handleGraphUpdate),this.graph.removeListener("nodeDropped",this.handleGraphUpdate),this.graph.removeListener("edgeDropped",this.handleGraphUpdate)};Tp.exports=ei});var Mp=De((TC,Lp)=>{var xn=0,Sn=1,ro=2,In=3;function sI(r,e){return r+"\xA7"+e}function kp(){return .01*(.5-Math.random())}Lp.exports=function(e,t){var i=e.margin,n=e.ratio,o=e.expansion,s=e.gridSize,a=e.speed,h,f,l,g,m,_,E=!0,q=t.length,x=q/In|0,A=new Float32Array(x),S=new Float32Array(x),I=1/0,M=1/0,D=-1/0,z=-1/0;for(h=0;h1&&W.has(Xe))&&(oe>1&&W.add(Xe),Ye=t[le+xn],wr=t[le+Sn],qr=t[le+ro],Ae=Ye-de,ze=wr-Be,be=Math.sqrt(Ae*Ae+ze*ze),sr=be0?(A[le]+=Ae/be*(1+er),S[le]+=ze/be*(1+er)):(A[le]+=O*kp(),S[le]+=N*kp())));for(h=0,f=0;h{var to=3;Fi.validateSettings=function(r){return"gridSize"in r&&typeof r.gridSize!="number"||r.gridSize<=0?{message:"the `gridSize` setting should be a positive number."}:"margin"in r&&typeof r.margin!="number"||r.margin<0?{message:"the `margin` setting should be 0 or a positive number."}:"expansion"in r&&typeof r.expansion!="number"||r.expansion<=0?{message:"the `expansion` setting should be a positive number."}:"ratio"in r&&typeof r.ratio!="number"||r.ratio<=0?{message:"the `ratio` setting should be a positive number."}:"speed"in r&&typeof r.speed!="number"||r.speed<=0?{message:"the `speed` setting should be a positive number."}:null};Fi.graphToByteArray=function(r,e){var t=r.order,i=new Float32Array(t*to),n=0;return r.forEachNode(function(o,s){typeof e=="function"&&(s=e(o,s)),i[n]=s.x,i[n+1]=s.y,i[n+2]=s.size||1,n+=to}),i};Fi.assignLayoutChanges=function(r,e,t){var i=0;r.forEachNode(function(n){var o={x:e[i],y:e[i+1]};typeof t=="function"&&(o=t(n,o)),r.mergeNodeAttributes(n,o),i+=to})};Fi.collectLayoutChanges=function(r,e,t){var i={},n=0;return r.forEachNode(function(o){var s={x:e[n],y:e[n+1]};typeof t=="function"&&(s=t(o,s)),i[o]=s,n+=to}),i};Fi.createWorker=function(e){var t=window.URL||window.webkitURL,i=e.toString(),n=t.createObjectURL(new Blob(["("+i+").call(this);"],{type:"text/javascript"})),o=new Worker(n);return t.revokeObjectURL(n),o}});var Pp=De((kC,jp)=>{jp.exports={gridSize:20,margin:5,expansion:1.1,ratio:1,speed:3}});var zp=De((LC,Fp)=>{var aI=Or(),uI=Mp(),io=Dp(),fI=Pp(),hI=500;function Gp(r,e,t){if(!aI(e))throw new Error("graphology-layout-noverlap: the given graph is not a valid graphology instance.");typeof t=="number"?t={maxIterations:t}:t=t||{};var i=t.maxIterations||hI;if(typeof i!="number"||i<=0)throw new Error("graphology-layout-force: you should provide a positive number of maximum iterations.");var n=Object.assign({},fI,t.settings),o=io.validateSettings(n);if(o)throw new Error("graphology-layout-noverlap: "+o.message);var s=io.graphToByteArray(e,t.inputReducer),a=!1,h;for(h=0;h{(function(r,e){typeof Vl=="object"&&typeof Kl<"u"?Kl.exports=e():typeof define=="function"&&define.amd?define(e):(r=typeof globalThis<"u"?globalThis:r||self,r.polygonClipping=e())})(Vl,(function(){"use strict";function r(K,v){var b={label:0,sent:function(){if(P[0]&1)throw P[1];return P[1]},trys:[],ops:[]},k,G,P,te;return te={next:J(0),throw:J(1),return:J(2)},typeof Symbol=="function"&&(te[Symbol.iterator]=function(){return this}),te;function J(ne){return function(Ee){return ae([ne,Ee])}}function ae(ne){if(k)throw new TypeError("Generator is already executing.");for(;b;)try{if(k=1,G&&(P=ne[0]&2?G.return:ne[0]?G.throw||((P=G.return)&&P.call(G),0):G.next)&&!(P=P.call(G,ne[1])).done)return P;switch(G=0,P&&(ne=[ne[0]&2,P.value]),ne[0]){case 0:case 1:P=ne;break;case 4:return b.label++,{value:ne[1],done:!1};case 5:b.label++,G=ne[1],ne=[0];continue;case 7:ne=b.ops.pop(),b.trys.pop();continue;default:if(P=b.trys,!(P=P.length>0&&P[P.length-1])&&(ne[0]===6||ne[0]===2)){b=0;continue}if(ne[0]===3&&(!P||ne[1]>P[0]&&ne[1]v?1:K0){if(v.right===null)break;if(b(K,v.right.key)>0){var J=v.right;if(v.right=J.left,J.left=v,v=J,v.right===null)break}G.right=v,G=v,v=v.right}else break}return G.right=v.left,P.left=v.right,v.left=k.right,v.right=k.left,v}function n(K,v,b,k){var G=new e(K,v);if(b===null)return G.left=G.right=null,G;b=i(K,b,k);var P=k(K,b.key);return P<0?(G.left=b.left,G.right=b,b.left=null):P>=0&&(G.right=b.right,G.left=b,b.right=null),G}function o(K,v,b){var k=null,G=null;if(v){v=i(K,v,b);var P=b(v.key,K);P===0?(k=v.left,G=v.right):P<0?(G=v.right,v.right=null,k=v):(k=v.left,v.left=null,G=v)}return{left:k,right:G}}function s(K,v,b){return v===null?K:(K===null||(v=i(K.key,v,b),v.left=K),v)}function a(K,v,b,k,G){if(K){k(""+v+(b?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+G(K)+` -`);var P=v+(b?" ":"\u2502 ");K.left&&a(K.left,P,!1,k,G),K.right&&a(K.right,P,!0,k,G)}}var h=(function(){function K(v){v===void 0&&(v=t),this._root=null,this._size=0,this._comparator=v}return K.prototype.insert=function(v,b){return this._size++,this._root=n(v,b,this._root,this._comparator)},K.prototype.add=function(v,b){var k=new e(v,b);this._root===null&&(k.left=k.right=null,this._size++,this._root=k);var G=this._comparator,P=i(v,this._root,G),te=G(v,P.key);return te===0?this._root=P:(te<0?(k.left=P.left,k.right=P,P.left=null):te>0&&(k.right=P.right,k.left=P,P.right=null),this._size++,this._root=k),this._root},K.prototype.remove=function(v){this._root=this._remove(v,this._root,this._comparator)},K.prototype._remove=function(v,b,k){var G;if(b===null)return null;b=i(v,b,k);var P=k(v,b.key);return P===0?(b.left===null?G=b.right:(G=i(v,b.left,k),G.right=b.right),this._size--,G):b},K.prototype.pop=function(){var v=this._root;if(v){for(;v.left;)v=v.left;return this._root=i(v.key,this._root,this._comparator),this._root=this._remove(v.key,this._root,this._comparator),{key:v.key,data:v.data}}return null},K.prototype.findStatic=function(v){for(var b=this._root,k=this._comparator;b;){var G=k(v,b.key);if(G===0)return b;G<0?b=b.left:b=b.right}return null},K.prototype.find=function(v){return this._root&&(this._root=i(v,this._root,this._comparator),this._comparator(v,this._root.key)!==0)?null:this._root},K.prototype.contains=function(v){for(var b=this._root,k=this._comparator;b;){var G=k(v,b.key);if(G===0)return!0;G<0?b=b.left:b=b.right}return!1},K.prototype.forEach=function(v,b){for(var k=this._root,G=[],P=!1;!P;)k!==null?(G.push(k),k=k.left):G.length!==0?(k=G.pop(),v.call(b,k),k=k.right):P=!0;return this},K.prototype.range=function(v,b,k,G){for(var P=[],te=this._comparator,J=this._root,ae;P.length!==0||J;)if(J)P.push(J),J=J.left;else{if(J=P.pop(),ae=te(J.key,b),ae>0)break;if(te(J.key,v)>=0&&k.call(G,J))return this;J=J.right}return this},K.prototype.keys=function(){var v=[];return this.forEach(function(b){var k=b.key;return v.push(k)}),v},K.prototype.values=function(){var v=[];return this.forEach(function(b){var k=b.data;return v.push(k)}),v},K.prototype.min=function(){return this._root?this.minNode(this._root).key:null},K.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},K.prototype.minNode=function(v){if(v===void 0&&(v=this._root),v)for(;v.left;)v=v.left;return v},K.prototype.maxNode=function(v){if(v===void 0&&(v=this._root),v)for(;v.right;)v=v.right;return v},K.prototype.at=function(v){for(var b=this._root,k=!1,G=0,P=[];!k;)if(b)P.push(b),b=b.left;else if(P.length>0){if(b=P.pop(),G===v)return b;G++,b=b.right}else k=!0;return null},K.prototype.next=function(v){var b=this._root,k=null;if(v.right){for(k=v.right;k.left;)k=k.left;return k}for(var G=this._comparator;b;){var P=G(v.key,b.key);if(P===0)break;P<0?(k=b,b=b.left):b=b.right}return k},K.prototype.prev=function(v){var b=this._root,k=null;if(v.left!==null){for(k=v.left;k.right;)k=k.right;return k}for(var G=this._comparator;b;){var P=G(v.key,b.key);if(P===0)break;P<0?b=b.left:(k=b,b=b.right)}return k},K.prototype.clear=function(){return this._root=null,this._size=0,this},K.prototype.toList=function(){return g(this._root)},K.prototype.load=function(v,b,k){b===void 0&&(b=[]),k===void 0&&(k=!1);var G=v.length,P=this._comparator;if(k&&E(v,b,0,G-1,P),this._root===null)this._root=f(v,b,0,G),this._size=G;else{var te=_(this.toList(),l(v,b),P);G=this._size+G,this._root=m({head:te},0,G)}return this},K.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(K.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(K.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),K.prototype.toString=function(v){v===void 0&&(v=function(k){return String(k.key)});var b=[];return a(this._root,"",!0,function(k){return b.push(k)},v),b.join("")},K.prototype.update=function(v,b,k){var G=this._comparator,P=o(v,this._root,G),te=P.left,J=P.right;G(v,b)<0?J=n(b,k,J,G):te=n(b,k,te,G),this._root=s(te,J,G)},K.prototype.split=function(v){return o(v,this._root,this._comparator)},K.prototype[Symbol.iterator]=function(){var v,b,k;return r(this,function(G){switch(G.label){case 0:v=this._root,b=[],k=!1,G.label=1;case 1:return k?[3,6]:v===null?[3,2]:(b.push(v),v=v.left,[3,5]);case 2:return b.length===0?[3,4]:(v=b.pop(),[4,v]);case 3:return G.sent(),v=v.right,[3,5];case 4:k=!0,G.label=5;case 5:return[3,1];case 6:return[2]}})},K})();function f(K,v,b,k){var G=k-b;if(G>0){var P=b+Math.floor(G/2),te=K[P],J=v[P],ae=new e(te,J);return ae.left=f(K,v,b,P),ae.right=f(K,v,P+1,k),ae}return null}function l(K,v){for(var b=new e(null,null),k=b,G=0;G0?(v=P=P.next=b.pop(),v=v.right):k=!0;return P.next=null,G.next}function m(K,v,b){var k=b-v;if(k>0){var G=v+Math.floor(k/2),P=m(K,v,G),te=K.head;return te.left=P,K.head=K.head.next,te.right=m(K,G+1,b),te}return null}function _(K,v,b){for(var k=new e(null,null),G=k,P=K,te=v;P!==null&&te!==null;)b(P.key,te.key)<0?(G.next=P,P=P.next):(G.next=te,te=te.next),G=G.next;return P!==null?G.next=P:te!==null&&(G.next=te),k.next}function E(K,v,b,k,G){if(!(b>=k)){for(var P=K[b+k>>1],te=b-1,J=k+1;;){do te++;while(G(K[te],P)<0);do J--;while(G(K[J],P)>0);if(te>=J)break;var ae=K[te];K[te]=K[J],K[J]=ae,ae=v[te],v[te]=v[J],v[J]=ae}E(K,v,b,J,G),E(K,v,J+1,k,G)}}let q=(K,v)=>K.ll.x<=v.x&&v.x<=K.ur.x&&K.ll.y<=v.y&&v.y<=K.ur.y,x=(K,v)=>{if(v.ur.x{if(-Ane==Ee>-ne?(P=ne,ne=v[++Q]):(P=Ee,Ee=k[++fe]);let ve=0;if(Qne==Ee>-ne?(te=ne+P,J=P-(te-ne),ne=v[++Q]):(te=Ee+P,J=P-(te-Ee),Ee=k[++fe]),P=te,J!==0&&(G[ve++]=J);Qne==Ee>-ne?(te=P+ne,ae=te-P,J=P-(te-ae)+(ne-ae),ne=v[++Q]):(te=P+Ee,ae=te-P,J=P-(te-ae)+(Ee-ae),Ee=k[++fe]),P=te,J!==0&&(G[ve++]=J);for(;Q=H||-ce>=H||(Q=K-L,J=K-(L+Q)+(Q-G),Q=b-V,ne=b-(V+Q)+(Q-G),Q=v-F,ae=v-(F+Q)+(Q-P),Q=k-ee,Ee=k-(ee+Q)+(Q-P),J===0&&ae===0&&ne===0&&Ee===0)||(H=Te*te+j*Math.abs(ce),ce+=L*Ee+ee*J-(F*ne+V*ae),ce>=H||-ce>=H))return ce;d=J*ee,fe=N*J,ve=fe-(fe-J),Ce=J-ve,fe=N*ee,Me=fe-(fe-ee),w=ee-Me,y=Ce*w-(d-ve*Me-Ce*Me-ve*w),R=ae*V,fe=N*ae,ve=fe-(fe-ae),Ce=ae-ve,fe=N*V,Me=fe-(fe-V),w=V-Me,C=Ce*w-(R-ve*Me-Ce*Me-ve*w),p=y-C,Q=y-p,Ze[0]=y-(p+Q)+(Q-C),c=d+p,Q=c-d,u=d-(c-Q)+(p-Q),p=u-R,Q=u-p,Ze[1]=u-(p+Q)+(Q-R),T=c+p,Q=T-c,Ze[2]=c-(T-Q)+(p-Q),Ze[3]=T;let se=X(4,Ne,4,Ze,Oe);d=L*Ee,fe=N*L,ve=fe-(fe-L),Ce=L-ve,fe=N*Ee,Me=fe-(fe-Ee),w=Ee-Me,y=Ce*w-(d-ve*Me-Ce*Me-ve*w),R=F*ne,fe=N*F,ve=fe-(fe-F),Ce=F-ve,fe=N*ne,Me=fe-(fe-ne),w=ne-Me,C=Ce*w-(R-ve*Me-Ce*Me-ve*w),p=y-C,Q=y-p,Ze[0]=y-(p+Q)+(Q-C),c=d+p,Q=c-d,u=d-(c-Q)+(p-Q),p=u-R,Q=u-p,Ze[1]=u-(p+Q)+(Q-R),T=c+p,Q=T-c,Ze[2]=c-(T-Q)+(p-Q),Ze[3]=T;let qe=X(se,Oe,4,Ze,B);d=J*Ee,fe=N*J,ve=fe-(fe-J),Ce=J-ve,fe=N*Ee,Me=fe-(fe-Ee),w=Ee-Me,y=Ce*w-(d-ve*Me-Ce*Me-ve*w),R=ae*ne,fe=N*ae,ve=fe-(fe-ae),Ce=ae-ve,fe=N*ne,Me=fe-(fe-ne),w=ne-Me,C=Ce*w-(R-ve*Me-Ce*Me-ve*w),p=y-C,Q=y-p,Ze[0]=y-(p+Q)+(Q-C),c=d+p,Q=c-d,u=d-(c-Q)+(p-Q),p=u-R,Q=u-p,Ze[1]=u-(p+Q)+(Q-R),T=c+p,Q=T-c,Ze[2]=c-(T-Q)+(p-Q),Ze[3]=T;let $=X(qe,B,4,Ze,pr);return pr[$-1]}function U(K,v,b,k,G,P){let te=(v-P)*(b-G),J=(K-G)*(k-P),ae=te-J,ne=Math.abs(te+J);return Math.abs(ae)>=me*ne?ae:-ge(K,v,b,k,G,P,ne)}let Ge=(K,v)=>K.x*v.y-K.y*v.x,Z=(K,v)=>K.x*v.x+K.y*v.y,W=(K,v,b)=>{let k=U(K.x,K.y,v.x,v.y,b.x,b.y);return k>0?-1:k<0?1:0},ue=K=>Math.sqrt(Z(K,K)),le=(K,v,b)=>{let k={x:v.x-K.x,y:v.y-K.y},G={x:b.x-K.x,y:b.y-K.y};return Ge(G,k)/ue(G)/ue(k)},de=(K,v,b)=>{let k={x:v.x-K.x,y:v.y-K.y},G={x:b.x-K.x,y:b.y-K.y};return Z(G,k)/ue(G)/ue(k)},Ye=(K,v,b)=>v.y===0?null:{x:K.x+v.x/v.y*(b-K.y),y:b},Be=(K,v,b)=>v.x===0?null:{x:b,y:K.y+v.y/v.x*(b-K.x)},wr=(K,v,b,k)=>{if(v.x===0)return Be(b,k,K.x);if(k.x===0)return Be(K,v,b.x);if(v.y===0)return Ye(b,k,K.y);if(k.y===0)return Ye(K,v,b.y);let G=Ge(v,k);if(G==0)return null;let P={x:b.x-K.x,y:b.y-K.y},te=Ge(P,v)/G,J=Ge(P,k)/G,ae=K.x+J*v.x,ne=b.x+te*k.x,Ee=K.y+J*v.y,Q=b.y+te*k.y,fe=(ae+ne)/2,ve=(Ee+Q)/2;return{x:fe,y:ve}};class er{static compare(v,b){let k=er.comparePoints(v.point,b.point);return k!==0?k:(v.point!==b.point&&v.link(b),v.isLeft!==b.isLeft?v.isLeft?1:-1:Xe.compare(v.segment,b.segment))}static comparePoints(v,b){return v.xb.x?1:v.yb.y?1:0}constructor(v,b){v.events===void 0?v.events=[this]:v.events.push(this),this.point=v,this.isLeft=b}link(v){if(v.point===this.point)throw new Error("Tried to link already linked events");let b=v.point.events;for(let k=0,G=b.length;k{let P=G.otherSE;b.set(G,{sine:le(this.point,v.point,P.point),cosine:de(this.point,v.point,P.point)})};return(G,P)=>{b.has(G)||k(G),b.has(P)||k(P);let{sine:te,cosine:J}=b.get(G),{sine:ae,cosine:ne}=b.get(P);return te>=0&&ae>=0?Jne?-1:0:te<0&&ae<0?Jne?1:0:aete?1:0}}}let qr=0;class Xe{static compare(v,b){let k=v.leftSE.point.x,G=b.leftSE.point.x,P=v.rightSE.point.x,te=b.rightSE.point.x;if(teJ&&ae>ne)return-1;let Q=v.comparePoint(b.leftSE.point);if(Q<0)return 1;if(Q>0)return-1;let fe=b.comparePoint(v.rightSE.point);return fe!==0?fe:-1}if(k>G){if(Jae&&J>Ee)return 1;let Q=b.comparePoint(v.leftSE.point);if(Q!==0)return Q;let fe=v.comparePoint(b.rightSE.point);return fe<0?1:fe>0?-1:1}if(Jae)return 1;if(Pte){let Q=v.comparePoint(b.rightSE.point);if(Q<0)return 1;if(Q>0)return-1}if(P!==te){let Q=ne-J,fe=P-k,ve=Ee-ae,Ce=te-G;if(Q>fe&&veCe)return-1}return P>te?1:PEe?1:v.idb.id?1:0}constructor(v,b,k,G){this.id=++qr,this.leftSE=v,v.segment=this,v.otherSE=b,this.rightSE=b,b.segment=this,b.otherSE=v,this.rings=k,this.windings=G}static fromRing(v,b,k){let G,P,te,J=er.comparePoints(v,b);if(J<0)G=v,P=b,te=1;else if(J>0)G=b,P=v,te=-1;else throw new Error(`Tried to create degenerate segment at [${v.x}, ${v.y}]`);let ae=new er(G,!0),ne=new er(P,!1);return new Xe(ae,ne,[k],[te])}replaceRightSE(v){this.rightSE=v,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let v=this.leftSE.point.y,b=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:vb?v:b}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(v){return v.x===this.leftSE.point.x&&v.y===this.leftSE.point.y||v.x===this.rightSE.point.x&&v.y===this.rightSE.point.y}comparePoint(v){if(this.isAnEndpoint(v))return 0;let b=this.leftSE.point,k=this.rightSE.point,G=this.vector();if(b.x===k.x)return v.x===b.x?0:v.x0&&J.swapEvents(),er.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),k&&(G.checkForConsuming(),P.checkForConsuming()),b}swapEvents(){let v=this.rightSE;this.rightSE=this.leftSE,this.leftSE=v,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let b=0,k=this.windings.length;b0){let P=b;b=k,k=P}if(b.prev===k){let P=b;b=k,k=P}for(let P=0,te=k.rings.length;PG.length===1&&G[0].isSubject;this._isInResult=k(v)!==k(b);break}default:throw new Error(`Unrecognized operation type found ${cr.type}`)}return this._isInResult}}class Ae{constructor(v,b,k){if(!Array.isArray(v)||v.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=b,this.isExterior=k,this.segments=[],typeof v[0][0]!="number"||typeof v[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let G=z.round(v[0][0],v[0][1]);this.bbox={ll:{x:G.x,y:G.y},ur:{x:G.x,y:G.y}};let P=G;for(let te=1,J=v.length;tethis.bbox.ur.x&&(this.bbox.ur.x=ae.x),ae.y>this.bbox.ur.y&&(this.bbox.ur.y=ae.y),P=ae)}(G.x!==P.x||G.y!==P.y)&&this.segments.push(Xe.fromRing(P,G,this))}getSweepEvents(){let v=[];for(let b=0,k=this.segments.length;bthis.bbox.ur.x&&(this.bbox.ur.x=P.bbox.ur.x),P.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=P.bbox.ur.y),this.interiorRings.push(P)}this.multiPoly=b}getSweepEvents(){let v=this.exteriorRing.getSweepEvents();for(let b=0,k=this.interiorRings.length;bthis.bbox.ur.x&&(this.bbox.ur.x=P.bbox.ur.x),P.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=P.bbox.ur.y),this.polys.push(P)}this.isSubject=b}getSweepEvents(){let v=[];for(let b=0,k=this.polys.length;b0&&(v=te)}let b=v.segment.prevInResult(),k=b?b.prevInResult():null;for(;;){if(!b)return null;if(!k)return b.ringOut;if(k.ringOut!==b.ringOut)return k.ringOut.enclosingRing()!==b.ringOut?b.ringOut:b.ringOut.enclosingRing();b=k.prevInResult(),k=b?b.prevInResult():null}}}class Se{constructor(v){this.exteriorRing=v,v.poly=this,this.interiorRings=[]}addInterior(v){this.interiorRings.push(v),v.poly=this}getGeom(){let v=[this.exteriorRing.getGeom()];if(v[0]===null)return null;for(let b=0,k=this.interiorRings.length;b1&&arguments[1]!==void 0?arguments[1]:Xe.compare;this.queue=v,this.tree=new h(b),this.segments=[]}process(v){let b=v.segment,k=[];if(v.consumedBy)return v.isLeft?this.queue.remove(v.otherSE):this.tree.remove(b),k;let G=v.isLeft?this.tree.add(b):this.tree.find(b);if(!G)throw new Error(`Unable to find segment #${b.id} [${b.leftSE.point.x}, ${b.leftSE.point.y}] -> [${b.rightSE.point.x}, ${b.rightSE.point.y}] in SweepLine tree.`);let P=G,te=G,J,ae;for(;J===void 0;)P=this.tree.prev(P),P===null?J=null:P.key.consumedBy===void 0&&(J=P.key);for(;ae===void 0;)te=this.tree.next(te),te===null?ae=null:te.key.consumedBy===void 0&&(ae=te.key);if(v.isLeft){let ne=null;if(J){let Q=J.getIntersection(b);if(Q!==null&&(b.isAnEndpoint(Q)||(ne=Q),!J.isAnEndpoint(Q))){let fe=this._splitSafely(J,Q);for(let ve=0,Ce=fe.length;ve0?(this.tree.remove(b),k.push(v)):(this.segments.push(b),b.prev=J)}else{if(J&&ae){let ne=J.getIntersection(ae);if(ne!==null){if(!J.isAnEndpoint(ne)){let Ee=this._splitSafely(J,ne);for(let Q=0,fe=Ee.length;Qtr)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let te=new ie(P),J=P.size,ae=P.pop();for(;ae;){let Q=ae.key;if(P.size===J){let ve=Q.segment;throw new Error(`Unable to pop() ${Q.isLeft?"left":"right"} SweepEvent [${Q.point.x}, ${Q.point.y}] from segment #${ve.id} [${ve.leftSE.point.x}, ${ve.leftSE.point.y}] -> [${ve.rightSE.point.x}, ${ve.rightSE.point.y}] from queue.`)}if(P.size>tr)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(te.segments.length>ar)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");let fe=te.process(Q);for(let ve=0,Ce=fe.length;ve1?v-1:0),k=1;k1?v-1:0),k=1;k1?v-1:0),k=1;k1?v-1:0),k=1;k{var _A=Or();function pn(r,e,t,i){var n=e+"Centrality";if(!_A(t))throw new Error("graphology-centrality/"+n+": the given graph is not a valid graphology instance.");if(e!=="degree"&&t.type==="undirected")throw new Error("graphology-centrality/"+n+": cannot compute "+e+" centrality on an undirected graph.");i=i||{};var o=i.nodeCentralityAttribute||n,s=t.order-1,a=t[e].bind(t);if(r){t.updateEachNodeAttributes(function(f,l){return l[o]=a(f)/s,l},{attributes:[o]});return}var h={};return t.forEachNode(function(f){h[f]=a(f)/s}),h}var m1=pn.bind(null,!1,"degree"),y1=pn.bind(null,!1,"inDegree"),_1=pn.bind(null,!1,"outDegree");m1.assign=pn.bind(null,!0,"degree");y1.assign=pn.bind(null,!0,"inDegree");_1.assign=pn.bind(null,!0,"outDegree");Os.degreeCentrality=m1;Os.inDegreeCentrality=y1;Os.outDegreeCentrality=_1});var w1=De(Yl=>{Yl.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u";Yl.SYMBOL_SUPPORT=typeof Symbol<"u"});var ks=De((YV,b1)=>{var q1=w1(),vA=q1.ARRAY_BUFFER_SUPPORT,wA=q1.SYMBOL_SUPPORT;b1.exports=function(e,t){var i,n,o,s,a;if(!e)throw new Error("obliterator/forEach: invalid iterable.");if(typeof t!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(e)||vA&&ArrayBuffer.isView(e)||typeof e=="string"||e.toString()==="[object Arguments]"){for(o=0,s=e.length;o{var qA=Math.pow(2,8)-1,bA=Math.pow(2,16)-1,EA=Math.pow(2,32)-1,xA=Math.pow(2,7)-1,SA=Math.pow(2,15)-1,IA=Math.pow(2,31)-1;$t.getPointerArray=function(r){var e=r-1;if(e<=qA)return Uint8Array;if(e<=bA)return Uint16Array;if(e<=EA)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")};$t.getSignedPointerArray=function(r){var e=r-1;return e<=xA?Int8Array:e<=SA?Int16Array:e<=IA?Int32Array:Float64Array};$t.getNumberType=function(r){return r===(r|0)?Math.sign(r)===-1?r<=127&&r>=-128?Int8Array:r<=32767&&r>=-32768?Int16Array:Int32Array:r<=255?Uint8Array:r<=65535?Uint16Array:Uint32Array:Float64Array};var AA={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};$t.getMinimalRepresentation=function(r,e){var t=null,i=0,n,o,s,a,h;for(a=0,h=r.length;ai&&(i=n,t=o);return t};$t.isTypedArray=function(r){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(r)};$t.concat=function(){var r=0,e,t,i;for(e=0,i=arguments.length;e{var E1=ks(),x1=Ei();function RA(r){return Array.isArray(r)||x1.isTypedArray(r)}function Xl(r){if(typeof r.length=="number")return r.length;if(typeof r.size=="number")return r.size}function CA(r){var e=Xl(r),t=typeof e=="number"?new Array(e):[],i=0;return E1(r,function(n){t[i++]=n}),t}function TA(r){var e=Xl(r),t=typeof e=="number"?x1.getPointerArray(e):Array,i=typeof e=="number"?new Array(e):[],n=typeof e=="number"?new t(e):[],o=0;return E1(r,function(s){i[o]=s,n[o]=o++}),[i,n]}Dn.isArrayLike=RA;Dn.guessLength=Xl;Dn.toArray=CA;Dn.toArrayWithIndices=TA});var Oi=De((ZV,S1)=>{function Ut(r){if(typeof r!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=r}typeof Symbol<"u"&&(Ut.prototype[Symbol.iterator]=function(){return this});Ut.of=function(){var r=arguments,e=r.length,t=0;return new Ut(function(){return t>=e?{done:!0}:{done:!1,value:r[t++]}})};Ut.empty=function(){var r=new Ut(function(){return{done:!0}});return r};Ut.fromSequence=function(r){var e=0,t=r.length;return new Ut(function(){return e>=t?{done:!0}:{done:!1,value:r[e++]}})};Ut.is=function(r){return r instanceof Ut?!0:typeof r=="object"&&r!==null&&typeof r.next=="function"};S1.exports=Ut});var Zl=De((JV,A1)=>{var Ql=Ls(),I1=Oi();function Lr(r,e){if(arguments.length<2)throw new Error("mnemonist/fixed-deque: expecting an Array class and a capacity.");if(typeof e!="number"||e<=0)throw new Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=r,this.capacity=e,this.items=new r(this.capacity),this.clear()}Lr.prototype.clear=function(){this.start=0,this.size=0};Lr.prototype.push=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.push: deque capacity ("+this.capacity+") exceeded!");var e=this.start+this.size;return e>=this.capacity&&(e-=this.capacity),this.items[e]=r,++this.size};Lr.prototype.unshift=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var e=this.start-1;return this.start===0&&(e=this.capacity-1),this.items[e]=r,this.start=e,++this.size};Lr.prototype.pop=function(){if(this.size!==0){this.size--;var r=this.start+this.size;return r>=this.capacity&&(r-=this.capacity),this.items[r]}};Lr.prototype.shift=function(){if(this.size!==0){var r=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[r]}};Lr.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]};Lr.prototype.peekLast=function(){if(this.size!==0){var r=this.start+this.size-1;return r>=this.capacity&&(r-=this.capacity),this.items[r]}};Lr.prototype.get=function(r){if(!(this.size===0||r>=this.capacity))return r=this.start+r,r>=this.capacity&&(r-=this.capacity),this.items[r]};Lr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=this.capacity,i=this.size,n=this.start,o=0;o=t)return{done:!0};var o=r[i];return i++,n++,i===e&&(i=0),{value:o,done:!1}})};Lr.prototype.entries=function(){var r=this.items,e=this.capacity,t=this.size,i=this.start,n=0;return new I1(function(){if(n>=t)return{done:!0};var o=r[i];return i++,i===e&&(i=0),{value:[n++,o],done:!1}})};typeof Symbol<"u"&&(Lr.prototype[Symbol.iterator]=Lr.prototype.values);Lr.prototype.inspect=function(){var r=this.toArray();return r.type=this.ArrayClass.name,r.capacity=this.capacity,Object.defineProperty(r,"constructor",{value:Lr,enumerable:!1}),r};typeof Symbol<"u"&&(Lr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Lr.prototype.inspect);Lr.from=function(r,e,t){if(arguments.length<3&&(t=Ql.guessLength(r),typeof t!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var i=new Lr(e,t);if(Ql.isArrayLike(r)){var n,o;for(n=0,o=r.length;n{var R1=Oi(),Jl=Ls();function zr(r,e){if(arguments.length<2)throw new Error("mnemonist/fixed-stack: expecting an Array class and a capacity.");if(typeof e!="number"||e<=0)throw new Error("mnemonist/fixed-stack: `capacity` should be a positive number.");this.capacity=e,this.ArrayClass=r,this.items=new this.ArrayClass(this.capacity),this.clear()}zr.prototype.clear=function(){this.size=0};zr.prototype.push=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-stack.push: stack capacity ("+this.capacity+") exceeded!");return this.items[this.size++]=r,this.size};zr.prototype.pop=function(){if(this.size!==0)return this.items[--this.size]};zr.prototype.peek=function(){return this.items[this.size-1]};zr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=0,i=this.items.length;t=e)return{done:!0};var i=r[e-t-1];return t++,{value:i,done:!1}})};zr.prototype.entries=function(){var r=this.items,e=this.size,t=0;return new R1(function(){if(t>=e)return{done:!0};var i=r[e-t-1];return{value:[t++,i],done:!1}})};typeof Symbol<"u"&&(zr.prototype[Symbol.iterator]=zr.prototype.values);zr.prototype.toString=function(){return this.toArray().join(",")};zr.prototype.toJSON=function(){return this.toArray()};zr.prototype.inspect=function(){var r=this.toArray();return r.type=this.ArrayClass.name,r.capacity=this.capacity,Object.defineProperty(r,"constructor",{value:zr,enumerable:!1}),r};typeof Symbol<"u"&&(zr.prototype[Symbol.for("nodejs.util.inspect.custom")]=zr.prototype.inspect);zr.from=function(r,e,t){if(arguments.length<3&&(t=Jl.guessLength(r),typeof t!="number"))throw new Error("mnemonist/fixed-stack.from: could not guess iterable length. Please provide desired capacity as last argument.");var i=new zr(e,t);if(Jl.isArrayLike(r)){var n,o;for(n=0,o=r.length;n{var OA=function(r,e){return re?1:0},kA=function(r,e){return re?-1:0};function LA(r){return function(e,t){return r(t,e)}}function MA(r){return r===2?function(e,t){return e[0]t[0]?1:e[1]t[1]?1:0}:function(e,t){for(var i=0;it[i])return 1;i++}return 0}}jn.DEFAULT_COMPARATOR=OA;jn.DEFAULT_REVERSE_COMPARATOR=kA;jn.reverseComparator=LA;jn.createTupleComparator=MA});var j1=De((rK,D1)=>{var Ms=ks(),k1=O1(),Wt=Ls(),js=k1.DEFAULT_COMPARATOR,Hl=k1.reverseComparator;function ed(r,e,t,i){for(var n=e[i],o,s;i>t;){if(o=i-1>>1,s=e[o],r(n,s)<0){e[i]=s,i=o;continue}break}e[i]=n}function Pn(r,e,t){for(var i=e.length,n=t,o=e[t],s=2*t+1,a;s=0&&(s=a),e[t]=e[s],t=s,s=2*t+1;e[t]=o,ed(r,e,n,t)}function L1(r,e,t){e.push(t),ed(r,e,0,e.length-1)}function rd(r,e){var t=e.pop();if(e.length!==0){var i=e[0];return e[0]=t,Pn(r,e,0),i}return t}function gn(r,e,t){if(e.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var i=e[0];return e[0]=t,Pn(r,e,0),i}function M1(r,e,t){var i;return e.length!==0&&r(e[0],t)<0&&(i=e[0],e[0]=t,t=i,Pn(r,e,0)),t}function ki(r,e){for(var t=e.length,i=t>>1,n=i;--n>=0;)Pn(r,e,n)}function td(r,e){for(var t=e.length,i=0,n=new Array(t);i=t.length)return t.slice().sort(r);for(h=t.slice(0,e),ki(i,h),n=e,o=t.length;n0&&gn(i,h,t[n]);return h.sort(r)}var f=Wt.guessLength(t);return f!==null&&f0&&gn(i,h,l)),n++}),h.length>n&&(h.length=n),h.sort(r)}function jA(r,e,t){arguments.length===2&&(t=e,e=r,r=js);var i=Hl(r),n,o,s,a=-1/0,h;if(e===1){if(Wt.isArrayLike(t)){for(n=0,o=t.length;n0)&&(a=s);return h=new t.constructor(1),h[0]=a,h}return Ms(t,function(l){(a===-1/0||r(l,a)>0)&&(a=l)}),[a]}if(Wt.isArrayLike(t)){if(e>=t.length)return t.slice().sort(i);for(h=t.slice(0,e),ki(r,h),n=e,o=t.length;n0&&gn(r,h,t[n]);return h.sort(i)}var f=Wt.guessLength(t);return f!==null&&f0&&gn(r,h,l)),n++}),h.length>n&&(h.length=n),h.sort(i)}function nr(r){if(this.clear(),this.comparator=r||js,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}nr.prototype.clear=function(){this.items=[],this.size=0};nr.prototype.push=function(r){return L1(this.comparator,this.items,r),++this.size};nr.prototype.peek=function(){return this.items[0]};nr.prototype.pop=function(){return this.size!==0&&this.size--,rd(this.comparator,this.items)};nr.prototype.replace=function(r){return gn(this.comparator,this.items,r)};nr.prototype.pushpop=function(r){return M1(this.comparator,this.items,r)};nr.prototype.consume=function(){return this.size=0,td(this.comparator,this.items)};nr.prototype.toArray=function(){return td(this.comparator,this.items.slice())};nr.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:nr,enumerable:!1}),r};typeof Symbol<"u"&&(nr.prototype[Symbol.for("nodejs.util.inspect.custom")]=nr.prototype.inspect);function Ds(r){if(this.clear(),this.comparator=r||js,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=Hl(this.comparator)}Ds.prototype=nr.prototype;nr.from=function(r,e){var t=new nr(e),i;return Wt.isArrayLike(r)?i=r.slice():i=Wt.toArray(r),ki(t.comparator,i),t.items=i,t.size=i.length,t};Ds.from=function(r,e){var t=new Ds(e),i;return Wt.isArrayLike(r)?i=r.slice():i=Wt.toArray(r),ki(t.comparator,i),t.items=i,t.size=i.length,t};nr.siftUp=Pn;nr.siftDown=ed;nr.push=L1;nr.pop=rd;nr.replace=gn;nr.pushpop=M1;nr.heapify=ki;nr.consume=td;nr.nsmallest=DA;nr.nlargest=jA;nr.MinHeap=nr;nr.MaxHeap=Ds;D1.exports=nr});var Nn=De(id=>{var Ps=Ei(),PA=Gi().createEdgeWeightGetter;function P1(r,e){return r==="outbound"||r==="inbound"?e.directedSize+e.undirectedSize*2:r==="in"||r==="out"||r==="directed"?e.directedSize:e.undirectedSize*2}function Qt(r,e){e=e||"outbound";var t=r[e+"Neighbors"].bind(r),i=P1(e,r),n=Ps.getPointerArray(i),o=Ps.getPointerArray(r.order);this.graph=r,this.neighborhood=new o(i),this.starts=new n(r.order+1),this.nodes=r.nodes();var s={},a,h,f,l,g,m,_=0;for(a=0,h=r.order;a{var GA=Zl(),G1=T1(),NA=j1(),N1=Ei(),F1=Nn(),FA=F1.NeighborhoodIndex,zA=F1.WeightedNeighborhoodIndex;nd.createUnweightedIndexedBrandes=function(e){var t=new FA(e),i=t.neighborhood,n=t.starts,o=e.order,s=new G1(N1.getPointerArray(o),o),a=new Uint32Array(o),h=new Array(o),f=new Int32Array(o),l=new GA(Uint32Array,o),g=function(m){var _,E,q,x,A,S,I;for(S=0;Se[0]?1:r[0]e[1]?1:r[1]e[2]?1:r[2]e[3]?1:r[3]{var UA=Or(),$1=z1(),WA=_t(),BA=$1.createUnweightedIndexedBrandes,VA=$1.createDijkstraIndexedBrandes,KA={nodeCentralityAttribute:"betweennessCentrality",getEdgeWeight:"weight",normalized:!0};function U1(r,e,t){if(!UA(e))throw new Error("graphology-centrality/beetweenness-centrality: the given graph is not a valid graphology instance.");t=WA(t,KA);var i=t.nodeCentralityAttribute,n=t.normalized,o=t.getEdgeWeight?VA(e,t.getEdgeWeight):BA(e),s=e.order,a,h,f,l,g,m,_,E,q,x,A=new Float64Array(s),S=new Float64Array(s);for(m=0;m{var YA=Oi(),XA=Ei().getPointerArray;function pt(r){var e=XA(r);this.size=0,this.length=r,this.dense=new e(r),this.sparse=new e(r)}pt.prototype.clear=function(){this.size=0};pt.prototype.has=function(r){var e=this.sparse[r];return e=this.size||this.dense[e]!==r?!1:(e=this.dense[this.size-1],this.dense[this.sparse[r]]=e,this.sparse[e]=this.sparse[r],this.size--,!0)};pt.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t,i=0;i{var QA=Or(),ZA=_t(),JA=Zl(),HA=Y1(),eR=Nn().NeighborhoodIndex,rR={nodeCentralityAttribute:"closenessCentrality",wassermanFaust:!1};function X1(r){this.index=new eR(r,"inbound"),this.queue=new JA(Array,r.order),this.seen=new HA(r.order)}X1.prototype.fromNode=function(r){var e=this.index,t=this.queue,i=this.seen;i.clear(),t.clear(),i.add(r),t.push([r,0]);for(var n,o,s,a,h,f,l=0,g=0;t.size!==0;)for(n=t.shift(),o=n[0],s=n[1],s!==0&&(l+=s,g+=1),h=e.starts[o+1],a=e.starts[o];a0&&o>1&&(l=h/f,i&&(l*=h/(o-1))),g[s]=l;return r?n.index.assign(t.nodeCentralityAttribute,g):n.index.collect(g)}var Z1=Q1.bind(null,!1);Z1.assign=Q1.bind(null,!0);J1.exports=Z1});var iE=De((aK,tE)=>{var tR=Or(),iR=_t(),nR=Nn().WeightedNeighborhoodIndex,oR={nodeCentralityAttribute:"eigenvectorCentrality",getEdgeWeight:"weight",maxIterations:100,tolerance:1e-6};function sR(r){for(var e=0,t=0,i=0,n=r.length;ie&&(t*=e/o*(e/o),e=o),t+=o===0&&e===0?0:o/e*(o/e)}return e===1/0?1:e*Math.sqrt(t)}function eE(r,e,t){if(!tR(e))throw new Error("graphology-metrics/centrality/eigenvector: the given graph is not a valid graphology instance.");t=iR(t,oR);var i=t.maxIterations,n=t.tolerance,o=e.order,s=new nR(e,t.getEdgeWeight),a,h,f,l,g=new Float64Array(e.order);for(a=0;a{var aR=Or(),uR=_t(),fR=Nn().WeightedNeighborhoodIndex,hR={nodePagerankAttribute:"pagerank",getEdgeWeight:"weight",alpha:.85,maxIterations:100,tolerance:1e-6};function nE(r,e,t){if(!aR(e))throw new Error("graphology-metrics/centrality/pagerank: the given graph is not a valid graphology instance.");t=uR(t,hR);var i=t.alpha,n=t.maxIterations,o=t.tolerance,s=t.nodePagerankAttribute,a=e.order,h=1/a,f=new fR(e,t.getEdgeWeight),l,g,m,_,E=new Float64Array(e.order),q=new Float64Array(f.weights.length),x=[];for(l=0;l{var cR=Or();uE.exports=function(e){if(!cR(e))throw new Error("graphology-metrics/simple-size: the given graph is not a valid graphology instance.");if(!e.multi)return e.size;var t=0,i=0;function n(){t++}function o(){i++}return e.forEachNode(function(s){e.type!=="directed"&&e.forEachUndirectedNeighbor(s,n),e.type!=="undirected"&&e.forEachOutNeighbor(s,o)}),t/2+i}});var hE=De(Zt=>{var lR=Or(),dR=fE();function pR(r,e){return 2*e/(r*(r-1))}function gR(r,e){return e/(r*(r-1))}function mR(r,e){var t=r*(r-1);return e/(t+t/2)}function xi(r,e,t){var i,n;if(arguments.length>3){if(i=t,n=arguments[3],typeof i!="number"||i<0)throw new Error("graphology-metrics/density: given order is not a valid number.");if(typeof n!="number"||n<0)throw new Error("graphology-metrics/density: given size is not a valid number.")}else{if(!lR(t))throw new Error("graphology-metrics/density: given graph is not a valid graphology instance.");i=t.order,n=t.size,t.multi&&e===!1&&(n=dR(t))}if(i<2)return 0;r===null&&(r=t.type),e===null&&(e=t.multi);var o;return r==="undirected"?o=pR:r==="directed"?o=gR:o=mR,o(i,n)}Zt.abstractDensity=xi;Zt.density=xi.bind(null,null,null);Zt.directedDensity=xi.bind(null,"directed",!1);Zt.undirectedDensity=xi.bind(null,"undirected",!1);Zt.mixedDensity=xi.bind(null,"mixed",!1);Zt.multiDirectedDensity=xi.bind(null,"directed",!0);Zt.multiUndirectedDensity=xi.bind(null,"undirected",!0);Zt.multiMixedDensity=xi.bind(null,"mixed",!0)});var dE=De((cK,lE)=>{var cE=Oi(),yR=ks();function Mr(){this.clear()}Mr.prototype.clear=function(){this.items=[],this.offset=0,this.size=0};Mr.prototype.enqueue=function(r){return this.items.push(r),++this.size};Mr.prototype.dequeue=function(){if(this.size){var r=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,r}};Mr.prototype.peek=function(){if(this.size)return this.items[this.offset]};Mr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=this.offset,i=0,n=this.items.length;t=r.length)return{done:!0};var t=r[e];return e++,{value:t,done:!1}})};Mr.prototype.entries=function(){var r=this.items,e=this.offset,t=0;return new cE(function(){if(e>=r.length)return{done:!0};var i=r[e];return e++,{value:[t++,i],done:!1}})};typeof Symbol<"u"&&(Mr.prototype[Symbol.iterator]=Mr.prototype.values);Mr.prototype.toString=function(){return this.toArray().join(",")};Mr.prototype.toJSON=function(){return this.toArray()};Mr.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:Mr,enumerable:!1}),r};typeof Symbol<"u"&&(Mr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Mr.prototype.inspect);Mr.from=function(r){var e=new Mr;return yR(r,function(t){e.enqueue(t)}),e};Mr.of=function(){return Mr.from(arguments)};lE.exports=Mr});var gE=De((lK,pE)=>{pE.exports=function(e,t){var i=t.length;if(i!==0){var n=e.length;e.length+=i;for(var o=0;o{var od=Or(),_R=dE(),vR=gE();function wR(r,e,t){if(!od(r))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(!r.hasNode(e))throw new Error('graphology-shortest-path: the "'+e+'" source node does not exist in the given graph.');if(!r.hasNode(t))throw new Error('graphology-shortest-path: the "'+t+'" target node does not exist in the given graph.');if(e=""+e,t=""+t,e===t)return[e];var i=r.inboundNeighbors.bind(r),n=r.outboundNeighbors.bind(r),o={},s={};o[e]=null,s[t]=null;var a=[e],h=[t],f,l,g,m,_,E,q,x,A=!1;e:for(;a.length&&h.length;)if(a.length<=h.length){for(f=a,a=[],_=0,q=f.length;_{var SR=Or(),IR=yE().singleSourceLength;_E.exports=function(e,t){if(!SR(e))throw new Error("graphology-metrics/eccentricity: given graph is not a valid graphology instance.");if(e.size===0)return 1/0;var i=-1/0,n=IR(e,t),o,s,a=0;for(o in n)s=n[o],s>i&&(i=s),a++;return a{var AR=Or(),RR=vE();wE.exports=function(e){if(!AR(e))throw new Error("graphology-metrics/diameter: given graph is not a valid graphology instance.");if(e.size===0)return 1/0;var t=-1/0;return e.someNode(function(i){var n=RR(e,i);return n>t&&(t=n),t===1/0}),t}});var sd=De((mK,bE)=>{var CR=Or();bE.exports=function(e){if(!CR(e))throw new Error("graphology-utils/infer-type: expecting a valid graphology instance.");var t=e.type;return t!=="mixed"?t:e.directedSize===0&&e.undirectedSize===0||e.directedSize>0&&e.undirectedSize>0?"mixed":e.directedSize>0?"directed":"undirected"}});var CE=De((yK,RE)=>{var EE=_t(),xE=Or(),SE=sd(),Si=Gi(),IE={getNodeCommunity:"community",getEdgeWeight:"weight",resolution:1};function TR(r,e){var t=new Array(r.order),i=new Float64Array(r.order),n={},o=0,s=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry,a=Si.createNodeValueGetter(e.getNodeCommunity).fromEntry,h=0,f={};return r.forEachNode(function(l,g){f[l]=h,t[h++]=a(l,g)}),r.forEachUndirectedEdge(function(l,g,m,_,E,q,x){var A=s(l,g,m,_,E,q,x);o+=A,n[l]=A,i[f[m]]+=A,m!==_&&(i[f[_]]+=A)}),{weights:n,communities:t,weightedDegrees:i,M:o}}function OR(r,e){var t=new Array(r.order),i=new Float64Array(r.order),n=new Float64Array(r.order),o={},s=0,a=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry,h=Si.createNodeValueGetter(e.getNodeCommunity).fromEntry,f=0,l={};return r.forEachNode(function(g,m){l[g]=f,t[f++]=h(g,m)}),r.forEachDirectedEdge(function(g,m,_,E,q,x,A){var S=a(g,m,_,E,q,x,A);s+=S,o[g]=S,n[l[_]]+=S,i[l[E]]+=S}),{weights:o,communities:t,weightedInDegrees:i,weightedOutDegrees:n,M:s}}function kR(r,e){var t=e.resolution,i=TR(r,e),n=i.communities,o=i.weightedDegrees,s=i.M,a=r.nodes(),h,f,l,g,m,_,E=0,q=s*2;for(h=0,l=r.order;h"u")throw new Error('graphology-metrics/modularity: the "'+s+'" node is not in the partition.');i[h]=0,n[h]=0}),{communities:t,totalWeights:i,internalWeights:n}}function DR(r,e){var t={},i={},n={},o={},s=Si.createNodeValueGetter(e.getNodeCommunity).fromEntry;return r.forEachNode(function(a,h){var f=s(a,h);if(t[a]=f,typeof f>"u")throw new Error('graphology-metrics/modularity: the "'+a+'" node is not in the partition.');i[f]=0,n[f]=0,o[f]=0}),{communities:t,totalInWeights:i,totalOutWeights:n,internalWeights:o}}function jR(r,e){var t=e.resolution,i=MR(r,e),n=0,o=i.totalWeights,s=i.internalWeights,a=i.communities,h=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry;r.forEachUndirectedEdge(function(m,_,E,q,x,A,S){var I=h(m,_,E,q,x,A,S);n+=I;var M=a[E],D=a[q];o[M]+=I,o[D]+=I,M===D&&(s[M]+=I*2)});var f=0,l=n*2;for(var g in s)f+=s[g]/l-Math.pow(o[g]/l,2)*t;return f}function PR(r,e){var t=e.resolution,i=DR(r,e),n=0,o=i.totalInWeights,s=i.totalOutWeights,a=i.internalWeights,h=i.communities,f=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry;r.forEachDirectedEdge(function(m,_,E,q,x,A,S){var I=f(m,_,E,q,x,A,S);n+=I;var M=h[E],D=h[q];s[M]+=I,o[D]+=I,M===D&&(a[M]+=I)});var l=0;for(var g in a)l+=a[g]/n-o[g]*s[g]/Math.pow(n,2)*t;return l}function GR(r,e,t,i){return i/(2*r)-e*t/(2*(r*r))}function NR(r,e,t,i,n,o){return o/r-(n*e+i*t)/(r*r)}function FR(r,e){if(!xE(r))throw new Error("graphology-metrics/modularity: given graph is not a valid graphology instance.");if(r.size===0)throw new Error("graphology-metrics/modularity: cannot compute modularity of an empty graph.");if(r.multi)throw new Error("graphology-metrics/modularity: cannot compute modularity of a multi graph. Cast it to a simple one beforehand.");var t=SE(r);if(t==="mixed")throw new Error("graphology-metrics/modularity: cannot compute modularity of a mixed graph.");return e=EE(e,IE),t==="directed"?LR(r,e):kR(r,e)}function AE(r,e){if(!xE(r))throw new Error("graphology-metrics/modularity: given graph is not a valid graphology instance.");if(r.size===0)throw new Error("graphology-metrics/modularity: cannot compute modularity of an empty graph.");if(r.multi)throw new Error("graphology-metrics/modularity: cannot compute modularity of a multi graph. Cast it to a simple one beforehand.");var t=SE(r);if(t==="mixed")throw new Error("graphology-metrics/modularity: cannot compute modularity of a mixed graph.");return e=EE(e,IE),t==="directed"?PR(r,e):jR(r,e)}var Fn=AE;Fn.sparse=AE;Fn.dense=FR;Fn.undirectedDelta=GR;Fn.directedDelta=NR;RE.exports=Fn});var OE=De((_K,TE)=>{var ad=Oi(),zR=Ei().getPointerArray;function Jr(r,e){arguments.length<2&&(e=r,r=Array);var t=zR(e);this.size=0,this.length=e,this.dense=new t(e),this.sparse=new t(e),this.vals=new r(e)}Jr.prototype.clear=function(){this.size=0};Jr.prototype.has=function(r){var e=this.sparse[r];return e=this.size||this.dense[e]!==r?!1:(e=this.dense[this.size-1],this.dense[this.sparse[r]]=e,this.sparse[e]=this.sparse[r],this.size--,!0)};Jr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=0;t{var $R=Oi(),UR=Ei().getPointerArray;function gt(r){var e=UR(r);this.start=0,this.size=0,this.capacity=r,this.dense=new e(r),this.sparse=new e(r)}gt.prototype.clear=function(){this.start=0,this.size=0};gt.prototype.has=function(r){if(this.size===0)return!1;var e=this.sparse[r],t=e=this.start&&e=this.start&&e1?e:this;for(var t=this.capacity,i=this.size,n=this.start,o=0;o=t)return{done:!0};var o=r[i];return i++,n++,i===e&&(i=0),{value:o,done:!1}})};typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=gt.prototype.values);gt.prototype.inspect=function(){var r=[];return this.forEach(function(e){r.push(e)}),Object.defineProperty(r,"constructor",{value:gt,enumerable:!1}),r.capacity=this.capacity,r};typeof Symbol<"u"&&(gt.prototype[Symbol.for("nodejs.util.inspect.custom")]=gt.prototype.inspect);kE.exports=gt});var PE=De((wK,jE)=>{function ME(r){return function(e){return typeof e!="number"&&(e=e.length),Math.floor(r()*e)}}var DE=ME(Math.random);DE.createRandomIndex=ME;jE.exports=DE});var $E=De(ud=>{var Ii=Ei(),GE=_t(),NE=Gi().createEdgeWeightGetter,FE=Symbol.for("nodejs.util.inspect.custom"),zE={getEdgeWeight:"weight",keepDendrogram:!1,resolution:1};function Cr(r,e){e=GE(e,zE);var t=e.resolution,i=NE(e.getEdgeWeight).fromEntry,n=(r.size-r.selfLoopCount)*2,o=Ii.getPointerArray(n),s=Ii.getPointerArray(r.order+1),a=e.getEdgeWeight?Float64Array:Ii.getPointerArray(r.size*2);this.C=r.order,this.M=0,this.E=n,this.U=0,this.resolution=t,this.level=0,this.graph=r,this.nodes=new Array(r.order),this.keepDendrogram=e.keepDendrogram,this.neighborhood=new s(n),this.weights=new a(n),this.loops=new a(r.order),this.starts=new o(r.order+1),this.belongings=new s(r.order),this.dendrogram=[],this.mapping=null,this.counts=new s(r.order),this.unused=new s(r.order),this.totalWeights=new a(r.order);var h={},f,l=0,g=0,m=this;r.forEachNode(function(_){m.nodes[l]=_,h[_]=l,g+=r.undirectedDegreeWithoutSelfLoops(_),m.starts[l]=g,m.belongings[l]=l,m.counts[l]=1,l++}),r.forEachEdge(function(_,E,q,x,A,S,I){if(f=i(_,E,q,x,A,S,I),q=h[q],x=h[x],m.M+=f,q===x)m.totalWeights[q]+=f*2,m.loops[q]=f*2;else{m.totalWeights[q]+=f,m.totalWeights[x]+=f;var M=--m.starts[q],D=--m.starts[x];m.neighborhood[M]=x,m.neighborhood[D]=q,m.weights[M]=f,m.weights[D]=f}}),this.starts[l]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}Cr.prototype.isolate=function(r,e){var t=this.belongings[r];if(this.counts[t]===1)return t;var i=this.unused[--this.U],n=this.loops[r];return this.totalWeights[t]-=e+n,this.totalWeights[i]+=e+n,this.belongings[r]=i,this.counts[t]--,this.counts[i]++,i};Cr.prototype.move=function(r,e,t){var i=this.belongings[r],n=this.loops[r];this.totalWeights[i]-=e+n,this.totalWeights[t]+=e+n,this.belongings[r]=t;var o=this.counts[i]--===1;this.counts[t]++,o&&(this.unused[this.U++]=i)};Cr.prototype.computeNodeDegree=function(r){var e,t,i,n=0;for(e=this.starts[r],t=this.starts[r+1];e{var WR=_t(),BR=Or(),VR=sd(),UE=OE(),WE=LE(),BE=PE().createRandomIndex,VE=$E(),KR=VE.UndirectedLouvainIndex,YR=VE.DirectedLouvainIndex,KE={nodeCommunityAttribute:"community",getEdgeWeight:"weight",fastLocalMoves:!0,randomWalk:!0,resolution:1,rng:Math.random};function Gs(r,e,t){var i=r.get(e);typeof i>"u"&&(i=0),i+=t,r.set(e,i)}var XR=1e-10;function Ns(r,e,t,i,n){return Math.abs(i-n)r:i>n}function QR(r,e,t){var i=new KR(e,{getEdgeWeight:t.getEdgeWeight,keepDendrogram:r,resolution:t.resolution}),n=BE(t.rng),o=!0,s=!0,a,h,f=new UE(Float64Array,i.C),l,g,m,_,E,q,x,A,S,I,M,D,z,O,N,j,X=0,re=0,oe=[],me,_e;for(t.fastLocalMoves&&(l=new WE(i.C));o;){if(I=i.C,o=!1,s=!0,t.fastLocalMoves){for(_e=0,q=t.randomWalk?n(I):0,x=0;xr++}function Vt(){let r=arguments,e=null,t=-1;return{[Symbol.iterator](){return this},next(){let i=null;do{if(e===null){if(t++,t>=r.length)return{done:!0};e=r[t][Symbol.iterator]()}if(i=e.next(),i.done){e=null;continue}break}while(!0);return i}}}function Di(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var vn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},Ie=class r extends vn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r.prototype.constructor)}},we=class r extends vn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r.prototype.constructor)}},Pe=class r extends vn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r.prototype.constructor)}};function Rd(r,e){this.key=r,this.attributes=e,this.clear()}Rd.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Cd(r,e){this.key=r,this.attributes=e,this.clear()}Cd.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Td(r,e){this.key=r,this.attributes=e,this.clear()}Td.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ji(r,e,t,i,n){this.key=e,this.attributes=n,this.undirected=r,this.source=t,this.target=i}ji.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");let t=this.source.key,i=this.target.key;this.source[r][i]=this,!(this.undirected&&t===i)&&(this.target[e][t]=this)};ji.prototype.attachMulti=function(){let r="out",e="in",t=this.source.key,i=this.target.key;this.undirected&&(r=e="undirected");let n=this.source[r],o=n[i];if(typeof o>"u"){n[i]=this,this.undirected&&t===i||(this.target[e][t]=this);return}o.previous=this,this.next=o,n[i]=this,this.target[e][t]=this};ji.prototype.detach=function(){let r=this.source.key,e=this.target.key,t="out",i="in";this.undirected&&(t=i="undirected"),delete this.source[t][e],delete this.target[i][r]};ji.prototype.detachMulti=function(){let r=this.source.key,e=this.target.key,t="out",i="in";this.undirected&&(t=i="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[i][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[i][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Od=0,kd=1,wx=2,Ld=3;function Kt(r,e,t,i,n,o,s){let a,h,f,l;if(i=""+i,t===Od){if(a=r._nodes.get(i),!a)throw new we(`Graph.${e}: could not find the "${i}" node in the graph.`);f=n,l=o}else if(t===Ld){if(n=""+n,h=r._edges.get(n),!h)throw new we(`Graph.${e}: could not find the "${n}" edge in the graph.`);let g=h.source.key,m=h.target.key;if(i===g)a=h.target;else if(i===m)a=h.source;else throw new we(`Graph.${e}: the "${i}" node is not attached to the "${n}" edge (${g}, ${m}).`);f=o,l=s}else{if(h=r._edges.get(i),!h)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`);t===kd?a=h.source:a=h.target,f=n,l=o}return[a,f,l]}function qx(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);return s.attributes[a]}}function bx(r,e,t){r.prototype[e]=function(i,n){let[o]=Kt(this,e,t,i,n);return o.attributes}}function Ex(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);return s.attributes.hasOwnProperty(a)}}function xx(r,e,t){r.prototype[e]=function(i,n,o,s){let[a,h,f]=Kt(this,e,t,i,n,o,s);return a.attributes[h]=f,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:h}),this}}function Sx(r,e,t){r.prototype[e]=function(i,n,o,s){let[a,h,f]=Kt(this,e,t,i,n,o,s);if(typeof f!="function")throw new Ie(`Graph.${e}: updater should be a function.`);let l=a.attributes,g=f(l[h]);return l[h]=g,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:h}),this}}function Ix(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function Ax(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);if(!Xr(a))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Rx(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);if(!Xr(a))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return Fr(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function Cx(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);if(typeof a!="function")throw new Ie(`Graph.${e}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}var Tx=[{name:r=>`get${r}Attribute`,attacher:qx},{name:r=>`get${r}Attributes`,attacher:bx},{name:r=>`has${r}Attribute`,attacher:Ex},{name:r=>`set${r}Attribute`,attacher:xx},{name:r=>`update${r}Attribute`,attacher:Sx},{name:r=>`remove${r}Attribute`,attacher:Ix},{name:r=>`replace${r}Attributes`,attacher:Ax},{name:r=>`merge${r}Attributes`,attacher:Rx},{name:r=>`update${r}Attributes`,attacher:Cx}];function Ox(r){Tx.forEach(function({name:e,attacher:t}){t(r,e("Node"),Od),t(r,e("Source"),kd),t(r,e("Target"),wx),t(r,e("Opposite"),Ld)})}function kx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return o.attributes[n]}}function Lx(r,e,t){r.prototype[e]=function(i){let n;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let o=""+i,s=""+arguments[1];if(n=yt(this,o,s,t),!n)throw new we(`Graph.${e}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,n=this._edges.get(i),!n)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return n.attributes}}function Mx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return o.attributes.hasOwnProperty(n)}}function Dx(r,e,t){r.prototype[e]=function(i,n,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let a=""+i,h=""+n;if(n=arguments[2],o=arguments[3],s=yt(this,a,h,t),!s)throw new we(`Graph.${e}: could not find an edge for the given path ("${a}" - "${h}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,s=this._edges.get(i),!s)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return s.attributes[n]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:n}),this}}function jx(r,e,t){r.prototype[e]=function(i,n,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let a=""+i,h=""+n;if(n=arguments[2],o=arguments[3],s=yt(this,a,h,t),!s)throw new we(`Graph.${e}: could not find an edge for the given path ("${a}" - "${h}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,s=this._edges.get(i),!s)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof o!="function")throw new Ie(`Graph.${e}: updater should be a function.`);return s.attributes[n]=o(s.attributes[n]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:n}),this}}function Px(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return delete o.attributes[n],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:n}),this}}function Gx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!Xr(n))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=n,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Nx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!Xr(n))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return Fr(o.attributes,n),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:n}),this}}function Fx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof n!="function")throw new Ie(`Graph.${e}: provided updater is not a function.`);return o.attributes=n(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var zx=[{name:r=>`get${r}Attribute`,attacher:kx},{name:r=>`get${r}Attributes`,attacher:Lx},{name:r=>`has${r}Attribute`,attacher:Mx},{name:r=>`set${r}Attribute`,attacher:Dx},{name:r=>`update${r}Attribute`,attacher:jx},{name:r=>`remove${r}Attribute`,attacher:Px},{name:r=>`replace${r}Attributes`,attacher:Gx},{name:r=>`merge${r}Attributes`,attacher:Nx},{name:r=>`update${r}Attributes`,attacher:Fx}];function $x(r){zx.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}var Ux=[{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 Wx(r,e,t,i){let n=!1;for(let o in e){if(o===i)continue;let s=e[o];if(n=t(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),r&&n)return s.key}}function Bx(r,e,t,i){let n,o,s,a=!1;for(let h in e)if(h!==i){n=e[h];do{if(o=n.source,s=n.target,a=t(n.key,n.attributes,o.key,s.key,o.attributes,s.attributes,n.undirected),r&&a)return n.key;n=n.next}while(n!==void 0)}}function Ks(r,e){let t=Object.keys(r),i=t.length,n,o=0;return{[Symbol.iterator](){return this},next(){do if(n)n=n.next;else{if(o>=i)return{done:!0};let s=t[o++];if(s===e){n=void 0;continue}n=r[s]}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}}}function Vx(r,e,t,i){let n=e[t];if(!n)return;let o=n.source,s=n.target;if(i(n.key,n.attributes,o.key,s.key,o.attributes,s.attributes,n.undirected)&&r)return n.key}function Kx(r,e,t,i){let n=e[t];if(!n)return;let o=!1;do{if(o=i(n.key,n.attributes,n.source.key,n.target.key,n.source.attributes,n.target.attributes,n.undirected),r&&o)return n.key;n=n.next}while(n!==void 0)}function Ys(r,e){let t=r[e];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};let n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}};let i=!1;return{[Symbol.iterator](){return this},next(){return i===!0?{done:!0}:(i=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function Yx(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return Array.from(r._edges.keys());let t=e==="undirected"?r.undirectedSize:r.directedSize,i=new Array(t),n=e==="undirected",o=r._edges.values(),s=0,a,h;for(;a=o.next(),a.done!==!0;)h=a.value,h.undirected===n&&(i[s++]=h.key);return i}function Md(r,e,t,i){if(e.size===0)return;let n=t!=="mixed"&&t!==e.type,o=t==="undirected",s,a,h=!1,f=e._edges.values();for(;s=f.next(),s.done!==!0;){if(a=s.value,n&&a.undirected!==o)continue;let{key:l,attributes:g,source:m,target:_}=a;if(h=i(l,g,m.key,_.key,m.attributes,_.attributes,a.undirected),r&&h)return l}}function Xx(r,e){if(r.size===0)return Di();let t=e!=="mixed"&&e!==r.type,i=e==="undirected",n=r._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=n.next(),o.done)return o;if(s=o.value,!(t&&s.undirected!==i))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Xs(r,e,t,i,n,o){let s=e?Bx:Wx,a;if(t!=="undirected"&&(i!=="out"&&(a=s(r,n.in,o),r&&a)||i!=="in"&&(a=s(r,n.out,o,i?void 0:n.key),r&&a))||t!=="directed"&&(a=s(r,n.undirected,o),r&&a))return a}function Qx(r,e,t,i){let n=[];return Xs(!1,r,e,t,i,function(o){n.push(o)}),n}function Zx(r,e,t){let i=Di();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(i=Vt(i,Ks(t.in))),e!=="in"&&typeof t.out<"u"&&(i=Vt(i,Ks(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(i=Vt(i,Ks(t.undirected))),i}function Qs(r,e,t,i,n,o,s){let a=t?Kx:Vx,h;if(e!=="undirected"&&(typeof n.in<"u"&&i!=="out"&&(h=a(r,n.in,o,s),r&&h)||typeof n.out<"u"&&i!=="in"&&(i||n.key!==o)&&(h=a(r,n.out,o,s),r&&h))||e!=="directed"&&typeof n.undirected<"u"&&(h=a(r,n.undirected,o,s),r&&h))return h}function Jx(r,e,t,i,n){let o=[];return Qs(!1,r,e,t,i,n,function(s){o.push(s)}),o}function Hx(r,e,t,i){let n=Di();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&i in t.in&&(n=Vt(n,Ys(t.in,i))),typeof t.out<"u"&&e!=="in"&&i in t.out&&(e||t.key!==i)&&(n=Vt(n,Ys(t.out,i)))),r!=="directed"&&typeof t.undirected<"u"&&i in t.undirected&&(n=Vt(n,Ys(t.undirected,i))),n}function eS(r,e){let{name:t,type:i,direction:n}=e;r.prototype[t]=function(o,s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];if(!arguments.length)return Yx(this,i);if(arguments.length===1){o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new we(`Graph.${t}: could not find the "${o}" node in the graph.`);return Qx(this.multi,i==="mixed"?this.type:i,n,a)}if(arguments.length===2){o=""+o,s=""+s;let a=this._nodes.get(o);if(!a)throw new we(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new we(`Graph.${t}: could not find the "${s}" target node in the graph.`);return Jx(i,this.multi,n,a,s)}throw new Ie(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function rS(r,e){let{name:t,type:i,direction:n}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(f,l,g){if(!(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)){if(arguments.length===1)return g=f,Md(!1,this,i,g);if(arguments.length===2){f=""+f,g=l;let m=this._nodes.get(f);if(typeof m>"u")throw new we(`Graph.${o}: could not find the "${f}" node in the graph.`);return Xs(!1,this.multi,i==="mixed"?this.type:i,n,m,g)}if(arguments.length===3){f=""+f,l=""+l;let m=this._nodes.get(f);if(!m)throw new we(`Graph.${o}: could not find the "${f}" source node in the graph.`);if(!this._nodes.has(l))throw new we(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Qs(!1,i,this.multi,n,m,l,g)}throw new Ie(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){let f=Array.prototype.slice.call(arguments),l=f.pop(),g;if(f.length===0){let m=0;i!=="directed"&&(m+=this.undirectedSize),i!=="undirected"&&(m+=this.directedSize),g=new Array(m);let _=0;f.push((E,q,x,A,S,I,M)=>{g[_++]=l(E,q,x,A,S,I,M)})}else g=[],f.push((m,_,E,q,x,A,S)=>{g.push(l(m,_,E,q,x,A,S))});return this[o].apply(this,f),g};let a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){let f=Array.prototype.slice.call(arguments),l=f.pop(),g=[];return f.push((m,_,E,q,x,A,S)=>{l(m,_,E,q,x,A,S)&&g.push(m)}),this[o].apply(this,f),g};let h="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[h]=function(){let f=Array.prototype.slice.call(arguments);if(f.length<2||f.length>4)throw new Ie(`Graph.${h}: invalid number of arguments (expecting 2, 3 or 4 and got ${f.length}).`);if(typeof f[f.length-1]=="function"&&typeof f[f.length-2]!="function")throw new Ie(`Graph.${h}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l,g;f.length===2?(l=f[0],g=f[1],f=[]):f.length===3?(l=f[1],g=f[2],f=[f[0]]):f.length===4&&(l=f[2],g=f[3],f=[f[0],f[1]]);let m=g;return f.push((_,E,q,x,A,S,I)=>{m=l(m,_,E,q,x,A,S,I)}),this[o].apply(this,f),m}}function tS(r,e){let{name:t,type:i,direction:n}=e,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,f,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return!1;if(arguments.length===1)return l=h,Md(!0,this,i,l);if(arguments.length===2){h=""+h,l=f;let g=this._nodes.get(h);if(typeof g>"u")throw new we(`Graph.${o}: could not find the "${h}" node in the graph.`);return Xs(!0,this.multi,i==="mixed"?this.type:i,n,g,l)}if(arguments.length===3){h=""+h,f=""+f;let g=this._nodes.get(h);if(!g)throw new we(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(f))throw new we(`Graph.${o}: could not find the "${f}" target node in the graph.`);return Qs(!0,i,this.multi,n,g,f,l)}throw new Ie(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let s="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){let h=Array.prototype.slice.call(arguments),f=h.pop();return h.push((g,m,_,E,q,x,A)=>f(g,m,_,E,q,x,A)),!!this[o].apply(this,h)};let a="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){let h=Array.prototype.slice.call(arguments),f=h.pop();return h.push((g,m,_,E,q,x,A)=>!f(g,m,_,E,q,x,A)),!this[o].apply(this,h)}}function iS(r,e){let{name:t,type:i,direction:n}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s,a){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return Di();if(!arguments.length)return Xx(this,i);if(arguments.length===1){s=""+s;let h=this._nodes.get(s);if(!h)throw new we(`Graph.${o}: could not find the "${s}" node in the graph.`);return Zx(i,n,h)}if(arguments.length===2){s=""+s,a=""+a;let h=this._nodes.get(s);if(!h)throw new we(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new we(`Graph.${o}: could not find the "${a}" target node in the graph.`);return Hx(i,n,h,a)}throw new Ie(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function nS(r){Ux.forEach(e=>{eS(r,e),rS(r,e),tS(r,e),iS(r,e)})}var oS=[{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 Zn(){this.A=null,this.B=null}Zn.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Zn.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function yn(r,e,t,i,n){for(let o in i){let s=i[o],a=s.source,h=s.target,f=a===t?h:a;if(e&&e.has(f.key))continue;let l=n(f.key,f.attributes);if(r&&l)return f.key}}function Zs(r,e,t,i,n){if(e!=="mixed"){if(e==="undirected")return yn(r,null,i,i.undirected,n);if(typeof t=="string")return yn(r,null,i,i[t],n)}let o=new Zn,s;if(e!=="undirected"){if(t!=="out"){if(s=yn(r,null,i,i.in,n),r&&s)return s;o.wrap(i.in)}if(t!=="in"){if(s=yn(r,o,i,i.out,n),r&&s)return s;o.wrap(i.out)}}if(e!=="directed"&&(s=yn(r,o,i,i.undirected,n),r&&s))return s}function sS(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}let i=[];return Zs(!1,r,e,t,function(n){i.push(n)}),i}function _n(r,e,t){let i=Object.keys(t),n=i.length,o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=n)return r&&r.wrap(t),{done:!0};let a=t[i[o++]],h=a.source,f=a.target;if(s=h===e?f:h,r&&r.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function aS(r,e,t){if(r!=="mixed"){if(r==="undirected")return _n(null,t,t.undirected);if(typeof e=="string")return _n(null,t,t[e])}let i=Di(),n=new Zn;return r!=="undirected"&&(e!=="out"&&(i=Vt(i,_n(n,t,t.in))),e!=="in"&&(i=Vt(i,_n(n,t,t.out)))),r!=="directed"&&(i=Vt(i,_n(n,t,t.undirected))),i}function uS(r,e){let{name:t,type:i,direction:n}=e;r.prototype[t]=function(o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new we(`Graph.${t}: could not find the "${o}" node in the graph.`);return sS(i==="mixed"?this.type:i,n,s)}}function fS(r,e){let{name:t,type:i,direction:n}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(f,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;f=""+f;let g=this._nodes.get(f);if(typeof g>"u")throw new we(`Graph.${o}: could not find the "${f}" node in the graph.`);Zs(!1,i==="mixed"?this.type:i,n,g,l)};let s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(f,l){let g=[];return this[o](f,(m,_)=>{g.push(l(m,_))}),g};let a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(f,l){let g=[];return this[o](f,(m,_)=>{l(m,_)&&g.push(m)}),g};let h="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[h]=function(f,l,g){if(arguments.length<3)throw new Ie(`Graph.${h}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let m=g;return this[o](f,(_,E)=>{m=l(m,_,E)}),m}}function hS(r,e){let{name:t,type:i,direction:n}=e,o=t[0].toUpperCase()+t.slice(1,-1),s="find"+o;r.prototype[s]=function(f,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;f=""+f;let g=this._nodes.get(f);if(typeof g>"u")throw new we(`Graph.${s}: could not find the "${f}" node in the graph.`);return Zs(!0,i==="mixed"?this.type:i,n,g,l)};let a="some"+o;r.prototype[a]=function(f,l){return!!this[s](f,l)};let h="every"+o;r.prototype[h]=function(f,l){return!this[s](f,(m,_)=>!l(m,_))}}function cS(r,e){let{name:t,type:i,direction:n}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return Di();s=""+s;let a=this._nodes.get(s);if(typeof a>"u")throw new we(`Graph.${o}: could not find the "${s}" node in the graph.`);return aS(i==="mixed"?this.type:i,n,a)}}function lS(r){oS.forEach(e=>{uS(r,e),fS(r,e),hS(r,e),cS(r,e)})}function Bn(r,e,t,i,n){let o=i._nodes.values(),s=i.type,a,h,f,l,g,m,_;for(;a=o.next(),a.done!==!0;){let E=!1;if(h=a.value,s!=="undirected"){l=h.out;for(f in l){g=l[f];do{if(m=g.target,E=!0,_=n(h.key,m.key,h.attributes,m.attributes,g.key,g.attributes,g.undirected),r&&_)return g;g=g.next}while(g)}}if(s!=="directed"){l=h.undirected;for(f in l)if(!(e&&h.key>f)){g=l[f];do{if(m=g.target,m.key!==f&&(m=g.source),E=!0,_=n(h.key,m.key,h.attributes,m.attributes,g.key,g.attributes,g.undirected),r&&_)return g;g=g.next}while(g)}}if(t&&!E&&(_=n(h.key,null,h.attributes,null,null,null,null),r&&_))return null}}function dS(r,e){let t={key:r};return Ad(e.attributes)||(t.attributes=Fr({},e.attributes)),t}function pS(r,e,t){let i={key:e,source:t.source.key,target:t.target.key};return Ad(t.attributes)||(i.attributes=Fr({},t.attributes)),r==="mixed"&&t.undirected&&(i.undirected=!0),i}function gS(r){if(!Xr(r))throw new Ie('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new Ie("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!Xr(r.attributes)||r.attributes===null))throw new Ie("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function mS(r){if(!Xr(r))throw new Ie('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new Ie("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new Ie("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!Xr(r.attributes)||r.attributes===null))throw new Ie("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new Ie("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var yS=vx(),_S=new Set(["directed","undirected","mixed"]),xd=new Set(["domain","_events","_eventsCount","_maxListeners"]),vS=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],wS={allowSelfLoops:!0,multi:!1,type:"mixed"};function qS(r,e,t){if(t&&!Xr(t))throw new Ie(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new Pe(`Graph.addNode: the "${e}" node already exist in the graph.`);let i=new r.NodeDataClass(e,t);return r._nodes.set(e,i),r.emit("nodeAdded",{key:e,attributes:t}),i}function Sd(r,e,t){let i=new r.NodeDataClass(e,t);return r._nodes.set(e,i),r.emit("nodeAdded",{key:e,attributes:t}),i}function Dd(r,e,t,i,n,o,s,a){if(!i&&r.type==="undirected")throw new Pe(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(i&&r.type==="directed")throw new Pe(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!Xr(a))throw new Ie(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!r.allowSelfLoops&&o===s)throw new Pe(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=r._nodes.get(o),f=r._nodes.get(s);if(!h)throw new we(`Graph.${e}: source node "${o}" not found.`);if(!f)throw new we(`Graph.${e}: target node "${s}" not found.`);let l={key:null,undirected:i,source:o,target:s,attributes:a};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new Pe(`Graph.${e}: the "${n}" edge already exists in the graph.`);if(!r.multi&&(i?typeof h.undirected[s]<"u":typeof h.out[s]<"u"))throw new Pe(`Graph.${e}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let g=new ji(i,n,h,f,a);r._edges.set(n,g);let m=o===s;return i?(h.undirectedDegree++,f.undirectedDegree++,m&&(h.undirectedLoops++,r._undirectedSelfLoopCount++)):(h.outDegree++,f.inDegree++,m&&(h.directedLoops++,r._directedSelfLoopCount++)),r.multi?g.attachMulti():g.attach(),i?r._undirectedSize++:r._directedSize++,l.key=n,r.emit("edgeAdded",l),n}function bS(r,e,t,i,n,o,s,a,h){if(!i&&r.type==="undirected")throw new Pe(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&r.type==="directed")throw new Pe(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(h){if(typeof a!="function")throw new Ie(`Graph.${e}: invalid updater function. Expecting a function but got "${a}"`)}else if(!Xr(a))throw new Ie(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let f;if(h&&(f=a,a=void 0),!r.allowSelfLoops&&o===s)throw new Pe(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=r._nodes.get(o),g=r._nodes.get(s),m,_;if(!t&&(m=r._edges.get(n),m)){if((m.source.key!==o||m.target.key!==s)&&(!i||m.source.key!==s||m.target.key!==o))throw new Pe(`Graph.${e}: inconsistency detected when attempting to merge the "${n}" edge with "${o}" source & "${s}" target vs. ("${m.source.key}", "${m.target.key}").`);_=m}if(!_&&!r.multi&&l&&(_=i?l.undirected[s]:l.out[s]),_){let S=[_.key,!1,!1,!1];if(h?!f:!a)return S;if(h){let I=_.attributes;_.attributes=f(I),r.emit("edgeAttributesUpdated",{type:"replace",key:_.key,attributes:_.attributes})}else Fr(_.attributes,a),r.emit("edgeAttributesUpdated",{type:"merge",key:_.key,attributes:_.attributes,data:a});return S}a=a||{},h&&f&&(a=f(a));let E={key:null,undirected:i,source:o,target:s,attributes:a};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new Pe(`Graph.${e}: the "${n}" edge already exists in the graph.`);let q=!1,x=!1;l||(l=Sd(r,o,{}),q=!0,o===s&&(g=l,x=!0)),g||(g=Sd(r,s,{}),x=!0),m=new ji(i,n,l,g,a),r._edges.set(n,m);let A=o===s;return i?(l.undirectedDegree++,g.undirectedDegree++,A&&(l.undirectedLoops++,r._undirectedSelfLoopCount++)):(l.outDegree++,g.inDegree++,A&&(l.directedLoops++,r._directedSelfLoopCount++)),r.multi?m.attachMulti():m.attach(),i?r._undirectedSize++:r._directedSize++,E.key=n,r.emit("edgeAdded",E),[n,!0,q,x]}function Mi(r,e){r._edges.delete(e.key);let{source:t,target:i,attributes:n}=e,o=e.undirected,s=t===i;o?(t.undirectedDegree--,i.undirectedDegree--,s&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,i.inDegree--,s&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:n,source:t.key,target:i.key,undirected:o})}var fr=class r extends Id.EventEmitter{constructor(e){if(super(),e=Fr({},wS,e),typeof e.multi!="boolean")throw new Ie(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!_S.has(e.type))throw new Ie(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new Ie(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type==="mixed"?Rd:e.type==="directed"?Cd:Td;mt(this,"NodeDataClass",t);let i="geid_"+yS()+"_",n=0,o=()=>{let s;do s=i+n++;while(this._edges.has(s));return s};mt(this,"_attributes",{}),mt(this,"_nodes",new Map),mt(this,"_edges",new Map),mt(this,"_directedSize",0),mt(this,"_undirectedSize",0),mt(this,"_directedSelfLoopCount",0),mt(this,"_undirectedSelfLoopCount",0),mt(this,"_edgeKeyGenerator",o),mt(this,"_options",e),xd.forEach(s=>mt(this,s,this[s])),Rt(this,"order",()=>this._nodes.size),Rt(this,"size",()=>this._edges.size),Rt(this,"directedSize",()=>this._directedSize),Rt(this,"undirectedSize",()=>this._undirectedSize),Rt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Rt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Rt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Rt(this,"multi",this._options.multi),Rt(this,"type",this._options.type),Rt(this,"allowSelfLoops",this._options.allowSelfLoops),Rt(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){let i=""+e,n=this._edges.get(i);return!!n&&!n.undirected}else if(arguments.length===2){e=""+e,t=""+t;let i=this._nodes.get(e);return i?i.out.hasOwnProperty(t):!1}throw new Ie(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){let i=""+e,n=this._edges.get(i);return!!n&&n.undirected}else if(arguments.length===2){e=""+e,t=""+t;let i=this._nodes.get(e);return i?i.undirected.hasOwnProperty(t):!1}throw new Ie(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasEdge(e,t){if(arguments.length===1){let i=""+e;return this._edges.has(i)}else if(arguments.length===2){e=""+e,t=""+t;let i=this._nodes.get(e);return i?typeof i.out<"u"&&i.out.hasOwnProperty(t)||typeof i.undirected<"u"&&i.undirected.hasOwnProperty(t):!1}throw new Ie(`Graph.hasEdge: invalid arity (${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.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new Pe("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let i=this._nodes.get(e);if(!i)throw new we(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new we(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let n=i.out&&i.out[t]||void 0;if(n)return n.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new Pe("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let i=this._nodes.get(e);if(!i)throw new we(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new we(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let n=i.undirected&&i.undirected[t]||void 0;if(n)return n.key}edge(e,t){if(this.multi)throw new Pe("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new we(`Graph.edge: could not find the "${t}" target node in the graph.`);let n=i.out&&i.out[t]||i.undirected&&i.undirected[t]||void 0;if(n)return n.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in||t in i.out}areOutNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.out}areInNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in i.undirected}areNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in i.in||t in i.out)||this.type!=="directed"&&t in i.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.in||this.type!=="directed"&&t in i.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.out||this.type!=="directed"&&t in i.undirected}inDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree),i}outboundDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.outDegree),i}degree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.degree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree),i}inDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,n=0;return this.type!=="directed"&&(i+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree,n+=t.directedLoops),i-n}outboundDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,n=0;return this.type!=="directed"&&(i+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.outDegree,n+=t.directedLoops),i-n}degreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,n=0;return this.type!=="directed"&&(i+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree,n+=t.directedLoops*2),i-n}source(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;let i=this._edges.get(t);if(!i)throw new we(`Graph.opposite: could not find the "${t}" edge in the graph.`);let n=i.source.key,o=i.target.key;if(e===n)return o;if(e===o)return n;throw new we(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${n}, ${o}).`)}hasExtremity(e,t){e=""+e,t=""+t;let i=this._edges.get(e);if(!i)throw new we(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return i.source.key===t||i.target.key===t}isUndirected(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return qS(this,e,t).key}mergeNode(e,t){if(t&&!Xr(t))throw new Ie(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let i=this._nodes.get(e);return i?(t&&(Fr(i.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:i.attributes,data:t})),[e,!1]):(i=new this.NodeDataClass(e,t),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new Ie(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let i=this._nodes.get(e);if(i){if(t){let o=i.attributes;i.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:i.attributes})}return[e,!1]}let n=t?t({}):{};return i=new this.NodeDataClass(e,n),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0]}dropNode(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.dropNode: could not find the "${e}" node in the graph.`);let i;if(this.type!=="undirected"){for(let n in t.out){i=t.out[n];do Mi(this,i),i=i.next;while(i)}for(let n in t.in){i=t.in[n];do Mi(this,i),i=i.next;while(i)}}if(this.type!=="directed")for(let n in t.undirected){i=t.undirected[n];do Mi(this,i),i=i.next;while(i)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let i=""+arguments[0],n=""+arguments[1];if(t=yt(this,i,n,this.type),!t)throw new we(`Graph.dropEdge: could not find the "${i}" -> "${n}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new we(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Mi(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new Pe("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Pe("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;let i=yt(this,e,t,"directed");if(!i)throw new we(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Mi(this,i),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new Pe("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Pe("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");let i=yt(this,e,t,"undirected");if(!i)throw new we(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Mi(this,i),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new Ie("Graph.updateAttribute: updater should be a function.");let i=this._attributes[e];return this._attributes[e]=t(i),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!Xr(e))throw new Ie("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!Xr(e))throw new Ie("Graph.mergeAttributes: provided attributes are not a plain object.");return Fr(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new Ie("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new Ie("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Ed(t))throw new Ie("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let i=this._nodes.values(),n,o;for(;n=i.next(),n.done!==!0;)o=n.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new Ie("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Ed(t))throw new Ie("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let i=this._edges.values(),n,o,s,a;for(;n=i.next(),n.done!==!0;)o=n.value,s=o.source,a=o.target,o.attributes=e(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new Ie("Graph.forEachAdjacencyEntry: expecting a callback.");Bn(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new Ie("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Bn(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new Ie("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Bn(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new Ie("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Bn(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new Ie("Graph.forEachNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)n=i.value,e(n.key,n.attributes)}findNode(e){if(typeof e!="function")throw new Ie("Graph.findNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)if(n=i.value,e(n.key,n.attributes))return n.key}mapNodes(e){if(typeof e!="function")throw new Ie("Graph.mapNode: expecting a callback.");let t=this._nodes.values(),i,n,o=new Array(this.order),s=0;for(;i=t.next(),i.done!==!0;)n=i.value,o[s++]=e(n.key,n.attributes);return o}someNode(e){if(typeof e!="function")throw new Ie("Graph.someNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)if(n=i.value,e(n.key,n.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new Ie("Graph.everyNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)if(n=i.value,!e(n.key,n.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new Ie("Graph.filterNodes: expecting a callback.");let t=this._nodes.values(),i,n,o=[];for(;i=t.next(),i.done!==!0;)n=i.value,e(n.key,n.attributes)&&o.push(n.key);return o}reduceNodes(e,t){if(typeof e!="function")throw new Ie("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new Ie("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let i=t,n=this._nodes.values(),o,s;for(;o=n.next(),o.done!==!0;)s=o.value,i=e(i,s.key,s.attributes);return i}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let i=t.value;return{value:{node:i.key,attributes:i.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),t=0;this._nodes.forEach((n,o)=>{e[t++]=dS(o,n)});let i=new Array(this._edges.size);return t=0,this._edges.forEach((n,o)=>{i[t++]=pS(this.type,o,n)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:i}}import(e,t=!1){if(e instanceof r)return e.forEachNode((h,f)=>{t?this.mergeNode(h,f):this.addNode(h,f)}),e.forEachEdge((h,f,l,g,m,_,E)=>{t?E?this.mergeUndirectedEdgeWithKey(h,l,g,f):this.mergeDirectedEdgeWithKey(h,l,g,f):E?this.addUndirectedEdgeWithKey(h,l,g,f):this.addDirectedEdgeWithKey(h,l,g,f)}),this;if(!Xr(e))throw new Ie("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!Xr(e.attributes))throw new Ie("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let i,n,o,s,a;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new Ie("Graph.import: invalid nodes. Expecting an array.");for(i=0,n=o.length;i{let o=Fr({},i.attributes);i=new t.NodeDataClass(n,o),t._nodes.set(n,i)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new Pe(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new Pe("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new Pe("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");let t=this.emptyCopy(e),i=this._edges.values(),n,o;for(;n=i.next(),n.done!==!0;)o=n.value,Dd(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Fr({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,s)=>{e[s]=o.attributes});let t={},i={};this._edges.forEach((o,s)=>{let a=o.undirected?"--":"->",h="",f=o.source.key,l=o.target.key,g;o.undirected&&f>l&&(g=f,f=l,l=g);let m=`(${f})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof i[m]>"u"?i[m]=0:i[m]++,h+=`${i[m]}. `):h+=`[${s}]: `,h+=m,t[h]=o.attributes});let n={};for(let o in this)this.hasOwnProperty(o)&&!xd.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(n[o]=this[o]);return n.attributes=this._attributes,n.nodes=e,n.edges=t,mt(n,"constructor",this.constructor),n}};typeof Symbol<"u"&&(fr.prototype[Symbol.for("nodejs.util.inspect.custom")]=fr.prototype.inspect);vS.forEach(r=>{["add","merge","update"].forEach(e=>{let t=r.name(e),i=e==="add"?Dd:bS;r.generateKey?fr.prototype[t]=function(n,o,s){return i(this,t,!0,(r.type||this.type)==="undirected",null,n,o,s,e==="update")}:fr.prototype[t]=function(n,o,s,a){return i(this,t,!1,(r.type||this.type)==="undirected",n,o,s,a,e==="update")}})});Ox(fr);$x(fr);nS(fr);lS(fr);var Vn=class extends fr{constructor(e){let t=Fr({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new Ie("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new Ie('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}},Kn=class extends fr{constructor(e){let t=Fr({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new Ie("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new Ie('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}},Yn=class extends fr{constructor(e){let t=Fr({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Ie("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}},Xn=class extends fr{constructor(e){let t=Fr({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Ie("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new Ie('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}},Qn=class extends fr{constructor(e){let t=Fr({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Ie("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new Ie('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}};function Pi(r){r.from=function(e,t){let i=Fr({},e.options,t),n=new r(i);return n.import(e),n}}Pi(fr);Pi(Vn);Pi(Kn);Pi(Yn);Pi(Xn);Pi(Qn);fr.Graph=fr;fr.DirectedGraph=Vn;fr.UndirectedGraph=Kn;fr.MultiGraph=Yn;fr.MultiDirectedGraph=Xn;fr.MultiUndirectedGraph=Qn;fr.InvalidArgumentsGraphError=Ie;fr.NotFoundGraphError=we;fr.UsageGraphError=Pe;var zs=et(mp(),1),JR=et(Ap(),1),HR=et(Op(),1),eC=et(zp(),1);function st(r,e,t,i){function n(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(l){try{f(i.next(l))}catch(g){s(g)}}function h(l){try{f(i.throw(l))}catch(g){s(g)}}function f(l){l.done?o(l.value):n(l.value).then(a,h)}f((i=i.apply(r,e||[])).next())})}var cI={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow},Sr=class extends Error{constructor(e,t,i){super(e),this.position=t,this.token=i,this.name="ExpressionError"}},We;(function(r){r[r.STRING=0]="STRING",r[r.NUMBER=1]="NUMBER",r[r.BOOLEAN=2]="BOOLEAN",r[r.NULL=3]="NULL",r[r.IDENTIFIER=4]="IDENTIFIER",r[r.OPERATOR=5]="OPERATOR",r[r.FUNCTION=6]="FUNCTION",r[r.DOT=7]="DOT",r[r.BRACKET_LEFT=8]="BRACKET_LEFT",r[r.BRACKET_RIGHT=9]="BRACKET_RIGHT",r[r.PAREN_LEFT=10]="PAREN_LEFT",r[r.PAREN_RIGHT=11]="PAREN_RIGHT",r[r.COMMA=12]="COMMA",r[r.QUESTION=13]="QUESTION",r[r.COLON=14]="COLON",r[r.DOLLAR=15]="DOLLAR"})(We||(We={}));var lI=new Set([32,9,10,13]),dI=new Set([43,45,42,47,37,33,38,124,61,60,62]),pI=new Map([["true",We.BOOLEAN],["false",We.BOOLEAN],["null",We.NULL]]),ia=new Map([["===",!0],["!==",!0],["<=",!0],[">=",!0],["&&",!0],["||",!0],["+",!0],["-",!0],["*",!0],["/",!0],["%",!0],["!",!0],["<",!0],[">",!0]]),gI=new Map([[46,We.DOT],[91,We.BRACKET_LEFT],[93,We.BRACKET_RIGHT],[40,We.PAREN_LEFT],[41,We.PAREN_RIGHT],[44,We.COMMA],[63,We.QUESTION],[58,We.COLON],[36,We.DOLLAR]]),Up=new Map;for(let[r,e]of gI.entries())Up.set(r,{type:e,value:String.fromCharCode(r)});function An(r){return r>=48&&r<=57}function na(r){return r>=97&&r<=122||r>=65&&r<=90||r===95}function $p(r){return na(r)||An(r)}function mI(r){return dI.has(r)}var Er;(function(r){r[r.Program=0]="Program",r[r.Literal=1]="Literal",r[r.Identifier=2]="Identifier",r[r.MemberExpression=3]="MemberExpression",r[r.CallExpression=4]="CallExpression",r[r.BinaryExpression=5]="BinaryExpression",r[r.UnaryExpression=6]="UnaryExpression",r[r.ConditionalExpression=7]="ConditionalExpression"})(Er||(Er={}));var yI=new Map([["||",2],["&&",3],["===",4],["!==",4],[">",5],[">=",5],["<",5],["<=",5],["+",6],["-",6],["*",7],["/",7],["%",7],["!",8]]),_I={type:Er.Literal,value:null},vI={type:Er.Literal,value:!0},wI={type:Er.Literal,value:!1},qI=r=>{let e=0,t=r.length,i=()=>e>=t?null:r[e],n=()=>r[e++],o=g=>{let m=i();return m!==null&&m.type===g},s=g=>g.type===We.OPERATOR?yI.get(g.value)||-1:g.type===We.DOT||g.type===We.BRACKET_LEFT?9:g.type===We.QUESTION?1:-1,a=g=>{let m,_;if(n().type===We.DOT){if(!o(We.IDENTIFIER)){let q=i();throw new Sr("Expected property name",e,q?q.value:"")}let E=n();m={type:Er.Identifier,name:E.value},_=!1}else{if(m=f(0),!o(We.BRACKET_RIGHT)){let E=i();throw new Sr("Expected closing bracket",e,E?E.value:"")}n(),_=!0}return{type:Er.MemberExpression,object:g,property:m,computed:_}},h=()=>{let g=i();if(!g)throw new Sr("Unexpected end of input",e,"");if(g.type===We.OPERATOR&&(g.value==="!"||g.value==="-")){n();let m=h();return{type:Er.UnaryExpression,operator:g.value,argument:m,prefix:!0}}switch(g.type){case We.NUMBER:return n(),{type:Er.Literal,value:Number(g.value)};case We.STRING:return n(),{type:Er.Literal,value:g.value};case We.BOOLEAN:return n(),g.value==="true"?vI:wI;case We.NULL:return n(),_I;case We.IDENTIFIER:return n(),{type:Er.Identifier,name:g.value};case We.FUNCTION:return(()=>{let m=n(),_=[];if(!o(We.PAREN_LEFT)){let E=i();throw new Sr("Expected opening parenthesis after function name",e,E?E.value:"")}for(n();;){if(o(We.PAREN_RIGHT)){n();break}if(!i()){let q=i();throw new Sr("Expected closing parenthesis",e,q?q.value:"")}if(_.length>0){if(!o(We.COMMA)){let q=i();throw new Sr("Expected comma between function arguments",e,q?q.value:"")}n()}let E=f(0);_.push(E)}return{type:Er.CallExpression,callee:{type:Er.Identifier,name:m.value},arguments:_}})();case We.PAREN_LEFT:{n();let m=f(0);if(!o(We.PAREN_RIGHT)){let _=i();throw new Sr("Expected closing parenthesis",e,_?_.value:"")}return n(),m}default:throw new Sr(`Unexpected token: ${g.type}`,e,g.value)}},f=(g=0)=>{let m=h();for(;e")}n();let x=f(0);m={type:Er.ConditionalExpression,test:m,consequent:q,alternate:x}}}return m},l=f();return{type:Er.Program,body:l}},bI=(r,e,t)=>{let i=e;t&&(i={...e,context:{...e.context,...t}});let n=o=>{switch(o.type){case Er.Literal:return(s=>s.value)(o);case Er.Identifier:return(s=>{if(!(s.name in i.context))throw new Sr(`Undefined variable: ${s.name}`);return i.context[s.name]})(o);case Er.MemberExpression:return(s=>{let a=n(s.object);if(a==null)throw new Sr("Cannot access property of null or undefined");return a[s.computed?n(s.property):s.property.name]})(o);case Er.CallExpression:return(s=>{let a=i.functions[s.callee.name];if(!a)throw new Sr(`Undefined function: ${s.callee.name}`);return a(...s.arguments.map((h=>n(h))))})(o);case Er.BinaryExpression:return(s=>{if(s.operator==="&&"){let f=n(s.left);return f&&n(s.right)}if(s.operator==="||")return n(s.left)||n(s.right);let a=n(s.left),h=n(s.right);switch(s.operator){case"+":return a+h;case"-":return a-h;case"*":return a*h;case"/":return a/h;case"%":return a%h;case"===":return a===h;case"!==":return a!==h;case">":return a>h;case">=":return a>=h;case"<":return a{let a=n(s.argument);if(s.prefix)switch(s.operator){case"!":return!a;case"-":if(typeof a!="number")throw new Sr(`Cannot apply unary - to non-number: ${a}`);return-a;default:throw new Sr(`Unknown operator: ${s.operator}`)}throw new Sr(`Postfix operators are not supported: ${s.operator}`)})(o);case Er.ConditionalExpression:return(s=>{let a=n(s.test);return n(a?s.consequent:s.alternate)})(o);default:throw new Sr(`Evaluation error: Unsupported node type: ${o.type}`)}};return n(r.body)};function oa(r){let e=(n=>{let o=n,s=o.length,a=new Array(Math.ceil(s/3)),h=0,f=0;function l(x){let A=f+1;f++;let S="",I=!1;for(;f({context:n,functions:o}))({},cI);return(n={})=>bI(t,i,n)}function Wp(r,e={}){return oa(r)(e)}function Bp(r,e){if(typeof r!="string")return;let t=r.trim();if(t)try{return oa(t),Wp(t,e)}catch{return}}function ri(r){return typeof r=="number"}function zi(r){if(!r)return[0,0,0];if(ri(r))return[r,r,r];if(Array.isArray(r)&&r.length===0)return[0,0,0];let[e,t=e,i=e]=r;return[e,t,i]}function Vp(r){return ri(r)?!0:Array.isArray(r)?r.every(e=>ri(e)):!1}function tt(r){return r==null}function sa(r){return typeof r=="string"}function aa(r){return typeof r=="function"}function ti(r,e){if(typeof r=="function")return r;if(typeof r=="string"){let t=r;return(...i)=>{let n={};for(let o=0;or}function no(r,e,t="node"){if(tt(r))return()=>e;if(sa(r)){let i=ti(r,[t]);return n=>{let o=i(n);return ri(o)?o:e}}return aa(r)?r:ri(r)?()=>r:()=>e}function Rn(r,e=10,t="node"){if(tt(r))return()=>e;if(sa(r)){let i=ti(r,[t]);return n=>{let o=i(n);return Vp(o)?o:e}}return aa(r)?r:ri(r)?()=>r:Array.isArray(r)?()=>r:()=>e}var oo=(r,e,t=10,i=0)=>{let n=Rn(e,i),o=Rn(r,t);return s=>{let[a,h,f]=zi(o(s)),[l,g,m]=zi(n(s));return[a+l,h+g,f+m]}};function Kp(r){var e;return[r.x,r.y,(e=r.z)!==null&&e!==void 0?e:0]}var so=class{constructor(e,t={}){this.edgeIdCounter=new Map,this.nodeMap=SI(e.nodes,t.node),this.edgeMap=II(e.edges||[],t.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(e){this.nodeMap=e.nodes,this.edgeMap=e.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(e){return this.nodeMap.get(e)}nodeAt(e){this.indexNodeCache||this.buildNodeIndexCache();let t=this.indexNodeCache.get(e);return t?this.nodeMap.get(t):void 0}nodeIndexOf(e){var t;return this.nodeIndexCache||this.buildNodeIndexCache(),(t=this.nodeIndexCache.get(e))!==null&&t!==void 0?t:-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(e){let t=0;this.nodeMap.forEach(i=>e(i,t++))}originalNode(e){let t=this.nodeMap.get(e);return t?._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(e){return this.edgeMap.get(e)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(e){let t=0;this.edgeMap.forEach(i=>e(i,t++))}originalEdge(e){let t=this.edgeMap.get(e);return t?._original}edgeCount(){return this.edgeMap.size}getEdgeId(e){if(e.id)return e.id;let t=`${e.source}-${e.target}`,i=this.edgeIdCounter.get(t)||0,n=i===0?t:`${t}-${i}`;return this.edgeIdCounter.set(t,i+1),n}degree(e,t="both"){this.degreeCache||this.buildDegreeCache();let i=this.degreeCache.get(e);return i?i[t]:0}neighbors(e,t="both"){if((!this.outAdjacencyCache||!this.inAdjacencyCache)&&this.buildAdjacencyCache(),t==="out")return Array.from(this.outAdjacencyCache.get(e)||[]);if(t==="in")return Array.from(this.inAdjacencyCache.get(e)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(e)||[]);let i=this.inAdjacencyCache.get(e),n=this.outAdjacencyCache.get(e);if(!i&&!n)return[];if(!i)return Array.from(n);if(!n)return Array.from(i);let o=new Set;return i.forEach(s=>o.add(s)),n.forEach(s=>o.add(s)),Array.from(o)}successors(e){return this.neighbors(e,"out")}predecessors(e){return this.neighbors(e,"in")}setNodeOrder(e){let t=new Map;for(let i of e)t.set(i.id,i);this.nodeMap=t,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(let e of this.edges()){let{source:t,target:i}=e;if(e.source===e.target)continue;this.degreeCache.has(t)||this.degreeCache.set(t,{in:0,out:0,both:0});let n=this.degreeCache.get(e.source);n&&(n.out++,n.both++),this.degreeCache.has(i)||this.degreeCache.set(i,{in:0,out:0,both:0});let o=this.degreeCache.get(e.target);o&&(o.in++,o.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(let e of this.edges())!this.nodeMap.has(e.source)||!this.nodeMap.has(e.target)||(this.outAdjacencyCache.has(e.source)||this.outAdjacencyCache.set(e.source,new Set),this.outAdjacencyCache.get(e.source).add(e.target),this.inAdjacencyCache.has(e.target)||this.inAdjacencyCache.set(e.target,new Set),this.inAdjacencyCache.get(e.target).add(e.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let e=0;this.nodeMap.forEach((t,i)=>{this.nodeIndexCache.set(i,e),this.indexNodeCache.set(e,i),e++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}},EI=["id","x","y","z","vx","vy","vz","fx","fy","fz","parentId"],xI=["id","source","target","points"];function SI(r,e){if(!r)throw new Error("Data.nodes is required");let t=new Map;for(let i of r){let n={_original:i};for(let o of EI){let s=i[o];tt(s)||(n[o]=s)}if(e){let o=e(i);for(let s in o){let a=o[s];tt(a)||(n[s]=a)}}if(tt(n.id))throw new Error("Node is missing id field");t.set(n.id,n)}return t}function II(r,e,t){let i=new Map;for(let n of r){let o={_original:n};for(let s of xI){let a=n[s];tt(a)||(o[s]=a)}if(e){let s=e(n);for(let a in s){let h=s[a];tt(h)||(o[a]=h)}}if(tt(o.source)||tt(o.target))throw new Error("Edge is missing source or target field");tt(o.id)&&(o.id=t?.(n)),i.set(o.id,o)}return i}var ao=class{constructor(e,t={}){this.graph=new so(e,t)}export(){return this.graph.data()}replace(e){this.graph.replace(e)}forEachNode(e){this.graph.forEachNode(e)}forEachEdge(e){this.graph.forEachEdge((t,i)=>{t.sourceNode=this.graph.node(t.source),t.targetNode=this.graph.node(t.target),e(t,i)})}destroy(){this.graph.destroy()}};var Xp=Symbol("Comlink.proxy"),AI=Symbol("Comlink.endpoint"),RI=Symbol("Comlink.releaseProxy"),ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),Qp=r=>typeof r=="object"&&r!==null||typeof r=="function",CI={canHandle:r=>Qp(r)&&r[Xp],serialize(r){let{port1:e,port2:t}=new MessageChannel;return Jp(r,e),[t,[t]]},deserialize(r){return r.start(),ha(r)}},TI={canHandle:r=>Qp(r)&&fo in r,serialize({value:r}){let e;return r instanceof Error?e={isError:!0,value:{message:r.message,name:r.name,stack:r.stack}}:e={isError:!1,value:r},[e,[]]},deserialize(r){throw r.isError?Object.assign(new Error(r.value.message),r.value):r.value}},Zp=new Map([["proxy",CI],["throw",TI]]);function OI(r,e){for(let t of r)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Jp(r,e=globalThis,t=["*"]){e.addEventListener("message",function i(n){if(!n||!n.data)return;if(!OI(t,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}let{id:o,type:s,path:a}=Object.assign({path:[]},n.data),h=(n.data.argumentList||[]).map(Ri),f;try{let l=a.slice(0,-1).reduce((m,_)=>m[_],r),g=a.reduce((m,_)=>m[_],r);switch(s){case"GET":f=g;break;case"SET":l[a.slice(-1)[0]]=Ri(n.data.value),f=!0;break;case"APPLY":f=g.apply(l,h);break;case"CONSTRUCT":{let m=new g(...h);f=PI(m)}break;case"ENDPOINT":{let{port1:m,port2:_}=new MessageChannel;Jp(r,_),f=jI(m,[m])}break;case"RELEASE":f=void 0;break;default:return}}catch(l){f={value:l,[fo]:0}}Promise.resolve(f).catch(l=>({value:l,[fo]:0})).then(l=>{let[g,m]=lo(l);e.postMessage(Object.assign(Object.assign({},g),{id:o}),m),s==="RELEASE"&&(e.removeEventListener("message",i),Hp(e),ua in r&&typeof r[ua]=="function"&&r[ua]())}).catch(l=>{let[g,m]=lo({value:new TypeError("Unserializable return value"),[fo]:0});e.postMessage(Object.assign(Object.assign({},g),{id:o}),m)})}),e.start&&e.start()}function kI(r){return r.constructor.name==="MessagePort"}function Hp(r){kI(r)&&r.close()}function ha(r,e){let t=new Map;return r.addEventListener("message",function(n){let{data:o}=n;if(!o||!o.id)return;let s=t.get(o.id);if(s)try{s(o)}finally{t.delete(o.id)}}),fa(r,t,[],e)}function uo(r){if(r)throw new Error("Proxy has been released and is not useable")}function eg(r){return $i(r,new Map,{type:"RELEASE"}).then(()=>{Hp(r)})}var ho=new WeakMap,co="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let e=(ho.get(r)||0)-1;ho.set(r,e),e===0&&eg(r)});function LI(r,e){let t=(ho.get(e)||0)+1;ho.set(e,t),co&&co.register(r,e,r)}function MI(r){co&&co.unregister(r)}function fa(r,e,t=[],i=function(){}){let n=!1,o=new Proxy(i,{get(s,a){if(uo(n),a===RI)return()=>{MI(o),eg(r),e.clear(),n=!0};if(a==="then"){if(t.length===0)return{then:()=>o};let h=$i(r,e,{type:"GET",path:t.map(f=>f.toString())}).then(Ri);return h.then.bind(h)}return fa(r,e,[...t,a])},set(s,a,h){uo(n);let[f,l]=lo(h);return $i(r,e,{type:"SET",path:[...t,a].map(g=>g.toString()),value:f},l).then(Ri)},apply(s,a,h){uo(n);let f=t[t.length-1];if(f===AI)return $i(r,e,{type:"ENDPOINT"}).then(Ri);if(f==="bind")return fa(r,e,t.slice(0,-1));let[l,g]=Yp(h);return $i(r,e,{type:"APPLY",path:t.map(m=>m.toString()),argumentList:l},g).then(Ri)},construct(s,a){uo(n);let[h,f]=Yp(a);return $i(r,e,{type:"CONSTRUCT",path:t.map(l=>l.toString()),argumentList:h},f).then(Ri)}});return LI(o,r),o}function DI(r){return Array.prototype.concat.apply([],r)}function Yp(r){let e=r.map(lo);return[e.map(t=>t[0]),DI(e.map(t=>t[1]))]}var rg=new WeakMap;function jI(r,e){return rg.set(r,e),r}function PI(r){return Object.assign(r,{[Xp]:!0})}function lo(r){for(let[e,t]of Zp)if(t.canHandle(r)){let[i,n]=t.serialize(r);return[{type:"HANDLER",name:e,value:i},n]}return[{type:"RAW",value:r},rg.get(r)||[]]}function Ri(r){switch(r.type){case"HANDLER":return Zp.get(r.name).deserialize(r.value);case"RAW":return r.value}}function $i(r,e,t,i){return new Promise(n=>{let o=GI();e.set(o,n),r.start&&r.start(),r.postMessage(Object.assign({id:o},t),i)})}function GI(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var po=class{constructor(){this.worker=null,this.workerApi=null}execute(e,t,i){return st(this,void 0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw new Error("Worker API not initialized");return yield this.workerApi.execute(e,t,i)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return st(this,void 0,void 0,function*(){let e=this.resolveWorkerPath(),i=e.includes("/lib/")||e.endsWith(".mjs")?"module":"classic";this.worker=new Worker(e,{type:i}),this.workerApi=ha(this.worker)})}resolveWorkerPath(){let e=(()=>{if(typeof document>"u")return null;let t=document.currentScript;if(t?.src)return t.src;let i=document.getElementsByTagName("script");for(let n=i.length-1;n>=0;n--){let o=i[n].src;if(o&&(o.includes("index.js")||o.includes("index.min.js")))return o}return null})();if(e){if(e.includes("index.js")||e.includes("index.min.js")){let n=e.replace(/index(\.min)?\.(m?js)(\?.*)?$/,"worker.js");if(n!==e)return n}let t=e.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(t!==e)return t;let i=e.replace(/\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(i!==e)return i}return"./worker.js"}};var Dt=class{constructor(e){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),e)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(e,t){return Object.assign({},e,t||{})}execute(e,t){return st(this,void 0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,t);let{node:i,edge:n,enableWorker:o}=this.runtimeOptions;this.context=new ao(e,{node:i,edge:n}),this.model=this.context.graph,o&&typeof Worker<"u"?yield this.layoutInWorker(e,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(e,t){var i;return st(this,void 0,void 0,function*(){try{this.supervisor||(this.supervisor=new po);let n=yield this.supervisor.execute(this.id,e,t);(i=this.context)===null||i===void 0||i.replace(n)}catch(n){console.error("Layout in worker failed, fallback to main thread layout.",n),yield this.layout(t)}})}forEachNode(e){this.context.forEachNode(e)}forEachEdge(e){this.context.forEachEdge(e)}destroy(){var e;(e=this.context)===null||e===void 0||e.destroy(),this.model=null,this.context=null,this.supervisor&&(this.supervisor.destroy(),this.supervisor=null)}};function tg(r){return Array.isArray(r)}function Ui(r,e,t=2){if(r.nodeCount()===1){let n=r.firstNode();n.x=e[0],n.y=e[1],t===3&&(n.z=e[2]||0)}}function ig(r,e){let t=r.nodes();return t.sort(e),r.setNodeOrder(t),r}function ng(r,e="desc"){return ig(r,(t,i)=>{let n=r.degree(t.id),o=r.degree(i.id);return e==="asc"?n-o:o-n})}function og(r,e){return ig(r,(t,i)=>{let n=r.originalNode(t.id),o=r.originalNode(i.id);return e(n,o)})}var Wi=r=>{let{width:e,height:t,center:i}=r,n=e??(typeof window<"u"?window.innerWidth:0),o=t??(typeof window<"u"?window.innerHeight:0),s=i??[n/2,o/2];return{width:n,height:o,center:s}};var go={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},mo=class extends Dt{constructor(){super(...arguments),this.id="concentric"}getDefaultOptions(){return go}layout(){return st(this,void 0,void 0,function*(){let{width:e,height:t,center:i}=Wi(this.options),n=this.model.nodeCount();if(!n||n===1){Ui(this.model,i);return}let{sortBy:o,maxLevelDiff:s,sweep:a,clockwise:h,equidistant:f,preventOverlap:l,startAngle:g=go.startAngle,nodeSize:m,nodeSpacing:_}=this.options,E=!o||o==="degree"?"degree":ti(o,["node"]);if(E==="degree")ng(this.model);else{let O=(N,j)=>{let X=E(N),re=E(j);return X===re?0:X>re?-1:1};og(this.model,O)}let q=this.model.nodes(),x=new Map;for(let O of q){let N=E==="degree"?this.model.degree(O.id):E(O._original);x.set(O.id,N)}let A=this.model.firstNode(),S=s||x.get(A.id)/4,I=oo(m,_,go.nodeSize,go.nodeSpacing),M=new Map;for(let O of q)M.set(O.id,Math.max(...I(O._original)));let D=[{nodes:[]}],z=D[0];for(let O=0;O0){let j=z.nodes[0],X=Math.abs(x.get(j.id)-x.get(N.id));S&&X>=S&&(z={nodes:[]},D.push(z))}z.nodes.push(N)}for(let O of D){let N=O.nodes.map(j=>M.get(j.id));O.nodeSizes=N,O.maxNodeSize=Math.max(...N)}if(D.forEach(O=>{let N=a===void 0?2*Math.PI-2*Math.PI/O.nodes.length:a;O.dTheta=N/Math.max(1,O.nodes.length-1)}),l){let O=0;for(let N=0;N1){let X=j.nodeSizes||[],re=0;for(let Ne=0;Ne0?re/_e:0;O=Math.max(Te,O)}if(j.r=O,N{X===0&&(N=j.r||0),j.r=N,N+=O})}D.forEach(O=>{let N=O.dTheta||0,j=O.r||0;O.nodes.forEach((X,re)=>{let oe=g+(h?1:-1)*N*re;X.x=i[0]+j*Math.cos(oe),X.y=i[1]+j*Math.sin(oe)})})})}};var sg=(function(r){var e=typeof r;return r!==null&&e==="object"||e==="function"});var ag=function(r){return typeof r=="object"&&r!==null};var NI={}.toString,yo=function(r,e){return NI.call(r)==="[object "+e+"]"};var ug=function(r){if(!ag(r)||!yo(r,"Object"))return!1;if(Object.getPrototypeOf(r)===null)return!0;for(var e=r;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e};var Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _o(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function vo(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var e=r.default;if(typeof e=="function"){var t=function i(){var n=!1;try{n=this instanceof i}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}function Bi(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ca,fg;function hg(){if(fg)return ca;fg=1;function r(){this.__data__=[],this.size=0}return ca=r,ca}var la,cg;function wt(){if(cg)return la;cg=1;function r(e,t){return e===t||e!==e&&t!==t}return la=r,la}var da,lg;function ii(){if(lg)return da;lg=1;var r=wt();function e(t,i){for(var n=t.length;n--;)if(r(t[n][0],i))return n;return-1}return da=e,da}var pa,dg;function pg(){if(dg)return pa;dg=1;var r=ii(),e=Array.prototype,t=e.splice;function i(n){var o=this.__data__,s=r(o,n);if(s<0)return!1;var a=o.length-1;return s==a?o.pop():t.call(o,s,1),--this.size,!0}return pa=i,pa}var ga,gg;function mg(){if(gg)return ga;gg=1;var r=ii();function e(t){var i=this.__data__,n=r(i,t);return n<0?void 0:i[n][1]}return ga=e,ga}var ma,yg;function _g(){if(yg)return ma;yg=1;var r=ii();function e(t){return r(this.__data__,t)>-1}return ma=e,ma}var ya,vg;function wg(){if(vg)return ya;vg=1;var r=ii();function e(t,i){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,i])):n[o][1]=i,this}return ya=e,ya}var _a,qg;function ni(){if(qg)return _a;qg=1;var r=hg(),e=pg(),t=mg(),i=_g(),n=wg();function o(s){var a=-1,h=s==null?0:s.length;for(this.clear();++a-1&&i%1==0&&i-1&&t%1==0&&t<=r}return du=e,du}var pu,Wm;function Bm(){if(Wm)return pu;Wm=1;var r=at(),e=Qi(),t=jr(),i="[object Arguments]",n="[object Array]",o="[object Boolean]",s="[object Date]",a="[object Error]",h="[object Function]",f="[object Map]",l="[object Number]",g="[object Object]",m="[object RegExp]",_="[object Set]",E="[object String]",q="[object WeakMap]",x="[object ArrayBuffer]",A="[object DataView]",S="[object Float32Array]",I="[object Float64Array]",M="[object Int8Array]",D="[object Int16Array]",z="[object Int32Array]",O="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",X="[object Uint32Array]",re={};re[S]=re[I]=re[M]=re[D]=re[z]=re[O]=re[N]=re[j]=re[X]=!0,re[i]=re[n]=re[x]=re[o]=re[A]=re[s]=re[a]=re[h]=re[f]=re[l]=re[g]=re[m]=re[_]=re[E]=re[q]=!1;function oe(me){return t(me)&&e(me.length)&&!!re[r(me)]}return pu=oe,pu}var gu,Vm;function ci(){if(Vm)return gu;Vm=1;function r(e){return function(t){return e(t)}}return gu=r,gu}var Zi={exports:{}};Zi.exports;var Km;function Ji(){return Km?Zi.exports:(Km=1,(function(r,e){var t=wo(),i=e&&!e.nodeType&&e,n=i&&!0&&r&&!r.nodeType&&r,o=n&&n.exports===i,s=o&&t.process,a=(function(){try{var h=n&&n.require&&n.require("util").types;return h||s&&s.binding&&s.binding("util")}catch{}})();r.exports=a})(Zi,Zi.exports),Zi.exports)}var mu,Ym;function Nt(){if(Ym)return mu;Ym=1;var r=Bm(),e=ci(),t=Ji(),i=t&&t.isTypedArray,n=i?e(i):r;return mu=n,mu}var yu,Xm;function Eo(){if(Xm)return yu;Xm=1;var r=Lm(),e=Gt(),t=Ve(),i=bt(),n=hi(),o=Nt(),s=Object.prototype,a=s.hasOwnProperty;function h(f,l){var g=t(f),m=!g&&e(f),_=!g&&!m&&i(f),E=!g&&!m&&!_&&o(f),q=g||m||_||E,x=q?r(f.length,String):[],A=x.length;for(var S in f)(l||a.call(f,S))&&!(q&&(S=="length"||_&&(S=="offset"||S=="parent")||E&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||n(S,A)))&&x.push(S);return x}return yu=h,yu}var _u,Qm;function li(){if(Qm)return _u;Qm=1;var r=Object.prototype;function e(t){var i=t&&t.constructor,n=typeof i=="function"&&i.prototype||r;return t===n}return _u=e,_u}var vu,Zm;function xo(){if(Zm)return vu;Zm=1;function r(e,t){return function(i){return e(t(i))}}return vu=r,vu}var wu,Jm;function Hm(){if(Jm)return wu;Jm=1;var r=xo(),e=r(Object.keys,Object);return wu=e,wu}var qu,ey;function Hi(){if(ey)return qu;ey=1;var r=li(),e=Hm(),t=Object.prototype,i=t.hasOwnProperty;function n(o){if(!r(o))return e(o);var s=[];for(var a in Object(o))i.call(o,a)&&a!="constructor"&&s.push(a);return s}return qu=n,qu}var bu,ry;function Wr(){if(ry)return bu;ry=1;var r=jt(),e=Qi();function t(i){return i!=null&&e(i.length)&&!r(i)}return bu=t,bu}var Eu,ty;function Zr(){if(ty)return Eu;ty=1;var r=Eo(),e=Hi(),t=Wr();function i(n){return t(n)?r(n):e(n)}return Eu=i,Eu}var xu,iy;function ny(){if(iy)return xu;iy=1;var r=Pt(),e=Zr();function t(i,n){return i&&r(n,e(n),i)}return xu=t,xu}var Su,oy;function sy(){if(oy)return Su;oy=1;function r(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}return Su=r,Su}var Iu,ay;function uy(){if(ay)return Iu;ay=1;var r=_r(),e=li(),t=sy(),i=Object.prototype,n=i.hasOwnProperty;function o(s){if(!r(s))return t(s);var a=e(s),h=[];for(var f in s)f=="constructor"&&(a||!n.call(s,f))||h.push(f);return h}return Iu=o,Iu}var Au,fy;function ft(){if(fy)return Au;fy=1;var r=Eo(),e=uy(),t=Wr();function i(n){return t(n)?r(n,!0):e(n)}return Au=i,Au}var Ru,hy;function cy(){if(hy)return Ru;hy=1;var r=Pt(),e=ft();function t(i,n){return i&&r(n,e(n),i)}return Ru=t,Ru}var en={exports:{}};en.exports;var ly;function So(){return ly?en.exports:(ly=1,(function(r,e){var t=Ir(),i=e&&!e.nodeType&&e,n=i&&!0&&r&&!r.nodeType&&r,o=n&&n.exports===i,s=o?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function h(f,l){if(l)return f.slice();var g=f.length,m=a?a(g):new f.constructor(g);return f.copy(m),m}r.exports=h})(en,en.exports),en.exports)}var Cu,dy;function Io(){if(dy)return Cu;dy=1;function r(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i_))return!1;var q=g.get(s),x=g.get(a);if(q&&x)return q==a&&x==s;var A=-1,S=!0,I=h&n?new r:void 0;for(g.set(s,a),g.set(a,s);++A<_;){var M=s[A],D=a[A];if(f)var z=m?f(D,M,A,a,s,g):f(M,D,A,s,a,g);if(z!==void 0){if(z)continue;S=!1;break}if(I){if(!e(a,function(O,N){if(!t(I,N)&&(M===O||l(M,O,h,f,g)))return I.push(N)})){S=!1;break}}else if(!(M===D||l(M,D,h,f,g))){S=!1;break}}return g.delete(s),g.delete(a),S}return Sf=o,Sf}var If,O_;function k_(){if(O_)return If;O_=1;function r(e){var t=-1,i=Array(e.size);return e.forEach(function(n,o){i[++t]=[o,n]}),i}return If=r,If}var Af,L_;function un(){if(L_)return Af;L_=1;function r(e){var t=-1,i=Array(e.size);return e.forEach(function(n){i[++t]=n}),i}return Af=r,Af}var Rf,M_;function D_(){if(M_)return Rf;M_=1;var r=qt(),e=Lo(),t=wt(),i=Uo(),n=k_(),o=un(),s=1,a=2,h="[object Boolean]",f="[object Date]",l="[object Error]",g="[object Map]",m="[object Number]",_="[object RegExp]",E="[object Set]",q="[object String]",x="[object Symbol]",A="[object ArrayBuffer]",S="[object DataView]",I=r?r.prototype:void 0,M=I?I.valueOf:void 0;function D(z,O,N,j,X,re,oe){switch(N){case S:if(z.byteLength!=O.byteLength||z.byteOffset!=O.byteOffset)return!1;z=z.buffer,O=O.buffer;case A:return!(z.byteLength!=O.byteLength||!re(new e(z),new e(O)));case h:case f:case m:return t(+z,+O);case l:return z.name==O.name&&z.message==O.message;case _:case q:return z==O+"";case g:var me=n;case E:var _e=j&s;if(me||(me=o),z.size!=O.size&&!_e)return!1;var Te=oe.get(z);if(Te)return Te==O;j|=a,oe.set(z,O);var Ne=i(me(z),me(O),j,X,re,oe);return oe.delete(z),Ne;case x:if(M)return M.call(z)==M.call(O)}return!1}return Rf=D,Rf}var Cf,j_;function P_(){if(j_)return Cf;j_=1;var r=Oo(),e=1,t=Object.prototype,i=t.hasOwnProperty;function n(o,s,a,h,f,l){var g=a&e,m=r(o),_=m.length,E=r(s),q=E.length;if(_!=q&&!g)return!1;for(var x=_;x--;){var A=m[x];if(!(g?A in s:i.call(s,A)))return!1}var S=l.get(o),I=l.get(s);if(S&&I)return S==s&&I==o;var M=!0;l.set(o,s),l.set(s,o);for(var D=g;++x<_;){A=m[x];var z=o[A],O=s[A];if(h)var N=g?h(O,z,A,s,o,l):h(z,O,A,o,s,l);if(!(N===void 0?z===O||f(z,O,a,h,l):N)){M=!1;break}D||(D=A=="constructor")}if(M&&!D){var j=o.constructor,X=s.constructor;j!=X&&"constructor"in o&&"constructor"in s&&!(typeof j=="function"&&j instanceof j&&typeof X=="function"&&X instanceof X)&&(M=!1)}return l.delete(o),l.delete(s),M}return Cf=n,Cf}var Tf,G_;function N_(){if(G_)return Tf;G_=1;var r=ai(),e=Uo(),t=D_(),i=P_(),n=Et(),o=Ve(),s=bt(),a=Nt(),h=1,f="[object Arguments]",l="[object Array]",g="[object Object]",m=Object.prototype,_=m.hasOwnProperty;function E(q,x,A,S,I,M){var D=o(q),z=o(x),O=D?l:n(q),N=z?l:n(x);O=O==f?g:O,N=N==f?g:N;var j=O==g,X=N==g,re=O==N;if(re&&s(q)){if(!s(x))return!1;D=!0,j=!1}if(re&&!j)return M||(M=new r),D||a(q)?e(q,x,A,S,I,M):t(q,x,O,A,S,I,M);if(!(A&h)){var oe=j&&_.call(q,"__wrapped__"),me=X&&_.call(x,"__wrapped__");if(oe||me){var _e=oe?q.value():q,Te=me?x.value():x;return M||(M=new r),I(_e,Te,A,S,M)}}return re?(M||(M=new r),i(q,x,A,S,I,M)):!1}return Tf=E,Tf}var Of,F_;function Wo(){if(F_)return Of;F_=1;var r=N_(),e=jr();function t(i,n,o,s,a){return i===n?!0:i==null||n==null||!e(i)&&!e(n)?i!==i&&n!==n:r(i,n,o,s,t,a)}return Of=t,Of}var kf,z_;function $_(){if(z_)return kf;z_=1;var r=ai(),e=Wo(),t=1,i=2;function n(o,s,a,h){var f=a.length,l=f,g=!h;if(o==null)return!l;for(o=Object(o);f--;){var m=a[f];if(g&&m[2]?m[1]!==o[m[0]]:!(m[0]in o))return!1}for(;++f0&&o(l)?n>1?t(l,n-1,o,s,a):r(a,l):s||(a[a.length]=l)}return a}return qh=t,qh}var bh,rw;function tw(){if(rw)return bh;rw=1;function r(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}return bh=r,bh}var Eh,iw;function is(){if(iw)return Eh;iw=1;var r=tw(),e=Math.max;function t(i,n,o){return n=e(n===void 0?i.length-1:n,0),function(){for(var s=arguments,a=-1,h=e(s.length-n,0),f=Array(h);++a0){if(++o>=r)return arguments[0]}else o=0;return n.apply(void 0,arguments)}}return Sh=i,Sh}var Ih,uw;function ns(){if(uw)return Ih;uw=1;var r=ow(),e=aw(),t=e(r);return Ih=t,Ih}var Ah,fw;function _i(){if(fw)return Ah;fw=1;var r=ht(),e=is(),t=ns();function i(n,o){return t(e(n,o,r),n+"")}return Ah=i,Ah}var Rh,hw;function os(){if(hw)return Rh;hw=1;function r(e,t,i,n){for(var o=e.length,s=i+(n?1:-1);n?s--:++s-1}return kh=e,kh}var Lh,vw;function ww(){if(vw)return Lh;vw=1;function r(e,t,i){for(var n=-1,o=e==null?0:e.length;++n=s){var A=f?null:n(h);if(A)return o(A);E=!1,m=i,x=new r}else x=f?[]:q;e:for(;++g<_;){var S=h[g],I=f?f(S):S;if(S=l||S!==0?S:0,E&&I===I){for(var M=x.length;M--;)if(x[M]===I)continue e;f&&x.push(I),q.push(S)}else m(x,I,l)||(x!==q&&x.push(I),q.push(S))}return q}return jh=a,jh}var Ph,Aw;function ss(){if(Aw)return Ph;Aw=1;var r=Wr(),e=jr();function t(i){return e(i)&&r(i)}return Ph=t,Ph}var Gh,Rw;function Cw(){if(Rw)return Gh;Rw=1;var r=hn(),e=_i(),t=Iw(),i=ss(),n=e(function(o){return t(r(o,1,i,!0))});return Gh=n,Gh}var Nh,Tw;function Ow(){if(Tw)return Nh;Tw=1;var r=gi();function e(t,i){return r(i,function(n){return t[n]})}return Nh=e,Nh}var Fh,kw;function as(){if(kw)return Fh;kw=1;var r=Ow(),e=Zr();function t(i){return i==null?[]:r(i,e(i))}return Fh=t,Fh}var zh,Lw;function vr(){if(Lw)return zh;Lw=1;var r;if(typeof Bi=="function")try{r={clone:a_(),constant:on(),each:Fo(),filter:Zo(),has:Jo(),isArray:Ve(),isEmpty:Cv(),isFunction:jt(),isUndefined:Ho(),keys:Zr(),map:rs(),reduce:ts(),size:Xv(),transform:Zv(),union:Cw(),values:as()}}catch{}return r||(r=window._),zh=r,zh}var $h,Mw;function cn(){if(Mw)return $h;Mw=1;var r=vr();$h=n;var e="\0",t="\0",i="";function n(l){this._isDirected=r.has(l,"directed")?l.directed:!0,this._isMultigraph=r.has(l,"multigraph")?l.multigraph:!1,this._isCompound=r.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=r.constant(void 0),this._defaultEdgeLabelFn=r.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(l){return this._label=l,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(l){return r.isFunction(l)||(l=r.constant(l)),this._defaultNodeLabelFn=l,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return r.keys(this._nodes)},n.prototype.sources=function(){var l=this;return r.filter(this.nodes(),function(g){return r.isEmpty(l._in[g])})},n.prototype.sinks=function(){var l=this;return r.filter(this.nodes(),function(g){return r.isEmpty(l._out[g])})},n.prototype.setNodes=function(l,g){var m=arguments,_=this;return r.each(l,function(E){m.length>1?_.setNode(E,g):_.setNode(E)}),this},n.prototype.setNode=function(l,g){return r.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=g),this):(this._nodes[l]=arguments.length>1?g:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=t,this._children[l]={},this._children[t][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},n.prototype.node=function(l){return this._nodes[l]},n.prototype.hasNode=function(l){return r.has(this._nodes,l)},n.prototype.removeNode=function(l){var g=this;if(r.has(this._nodes,l)){var m=function(_){g.removeEdge(g._edgeObjs[_])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],r.each(this.children(l),function(_){g.setParent(_)}),delete this._children[l]),r.each(r.keys(this._in[l]),m),delete this._in[l],delete this._preds[l],r.each(r.keys(this._out[l]),m),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},n.prototype.setParent=function(l,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(r.isUndefined(g))g=t;else{g+="";for(var m=g;!r.isUndefined(m);m=this.parent(m))if(m===l)throw new Error("Setting "+g+" as parent of "+l+" would create a cycle");this.setNode(g)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=g,this._children[g][l]=!0,this},n.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},n.prototype.parent=function(l){if(this._isCompound){var g=this._parent[l];if(g!==t)return g}},n.prototype.children=function(l){if(r.isUndefined(l)&&(l=t),this._isCompound){var g=this._children[l];if(g)return r.keys(g)}else{if(l===t)return this.nodes();if(this.hasNode(l))return[]}},n.prototype.predecessors=function(l){var g=this._preds[l];if(g)return r.keys(g)},n.prototype.successors=function(l){var g=this._sucs[l];if(g)return r.keys(g)},n.prototype.neighbors=function(l){var g=this.predecessors(l);if(g)return r.union(g,this.successors(l))},n.prototype.isLeaf=function(l){var g;return this.isDirected()?g=this.successors(l):g=this.neighbors(l),g.length===0},n.prototype.filterNodes=function(l){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var m=this;r.each(this._nodes,function(q,x){l(x)&&g.setNode(x,q)}),r.each(this._edgeObjs,function(q){g.hasNode(q.v)&&g.hasNode(q.w)&&g.setEdge(q,m.edge(q))});var _={};function E(q){var x=m.parent(q);return x===void 0||g.hasNode(x)?(_[q]=x,x):x in _?_[x]:E(x)}return this._isCompound&&r.each(g.nodes(),function(q){g.setParent(q,E(q))}),g},n.prototype.setDefaultEdgeLabel=function(l){return r.isFunction(l)||(l=r.constant(l)),this._defaultEdgeLabelFn=l,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return r.values(this._edgeObjs)},n.prototype.setPath=function(l,g){var m=this,_=arguments;return r.reduce(l,function(E,q){return _.length>1?m.setEdge(E,q,g):m.setEdge(E,q),q}),this},n.prototype.setEdge=function(){var l,g,m,_,E=!1,q=arguments[0];typeof q=="object"&&q!==null&&"v"in q?(l=q.v,g=q.w,m=q.name,arguments.length===2&&(_=arguments[1],E=!0)):(l=q,g=arguments[1],m=arguments[3],arguments.length>2&&(_=arguments[2],E=!0)),l=""+l,g=""+g,r.isUndefined(m)||(m=""+m);var x=a(this._isDirected,l,g,m);if(r.has(this._edgeLabels,x))return E&&(this._edgeLabels[x]=_),this;if(!r.isUndefined(m)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(g),this._edgeLabels[x]=E?_:this._defaultEdgeLabelFn(l,g,m);var A=h(this._isDirected,l,g,m);return l=A.v,g=A.w,Object.freeze(A),this._edgeObjs[x]=A,o(this._preds[g],l),o(this._sucs[l],g),this._in[g][x]=A,this._out[l][x]=A,this._edgeCount++,this},n.prototype.edge=function(l,g,m){var _=arguments.length===1?f(this._isDirected,arguments[0]):a(this._isDirected,l,g,m);return this._edgeLabels[_]},n.prototype.hasEdge=function(l,g,m){var _=arguments.length===1?f(this._isDirected,arguments[0]):a(this._isDirected,l,g,m);return r.has(this._edgeLabels,_)},n.prototype.removeEdge=function(l,g,m){var _=arguments.length===1?f(this._isDirected,arguments[0]):a(this._isDirected,l,g,m),E=this._edgeObjs[_];return E&&(l=E.v,g=E.w,delete this._edgeLabels[_],delete this._edgeObjs[_],s(this._preds[g],l),s(this._sucs[l],g),delete this._in[g][_],delete this._out[l][_],this._edgeCount--),this},n.prototype.inEdges=function(l,g){var m=this._in[l];if(m){var _=r.values(m);return g?r.filter(_,function(E){return E.v===g}):_}},n.prototype.outEdges=function(l,g){var m=this._out[l];if(m){var _=r.values(m);return g?r.filter(_,function(E){return E.w===g}):_}},n.prototype.nodeEdges=function(l,g){var m=this.inEdges(l,g);if(m)return m.concat(this.outEdges(l,g))};function o(l,g){l[g]?l[g]++:l[g]=1}function s(l,g){--l[g]||delete l[g]}function a(l,g,m,_){var E=""+g,q=""+m;if(!l&&E>q){var x=E;E=q,q=x}return E+i+q+i+(r.isUndefined(_)?e:_)}function h(l,g,m,_){var E=""+g,q=""+m;if(!l&&E>q){var x=E;E=q,q=x}var A={v:E,w:q};return _&&(A.name=_),A}function f(l,g){return a(l,g.v,g.w,g.name)}return $h}var Uh,Dw;function jw(){return Dw||(Dw=1,Uh="2.1.8"),Uh}var Wh,Pw;function Gw(){return Pw||(Pw=1,Wh={Graph:cn(),version:jw()}),Wh}var Bh,Nw;function Fw(){if(Nw)return Bh;Nw=1;var r=vr(),e=cn();Bh={write:t,read:o};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:i(s),edges:n(s)};return r.isUndefined(s.graph())||(a.value=r.clone(s.graph())),a}function i(s){return r.map(s.nodes(),function(a){var h=s.node(a),f=s.parent(a),l={v:a};return r.isUndefined(h)||(l.value=h),r.isUndefined(f)||(l.parent=f),l})}function n(s){return r.map(s.edges(),function(a){var h=s.edge(a),f={v:a.v,w:a.w};return r.isUndefined(a.name)||(f.name=a.name),r.isUndefined(h)||(f.value=h),f})}function o(s){var a=new e(s.options).setGraph(s.value);return r.each(s.nodes,function(h){a.setNode(h.v,h.value),h.parent&&a.setParent(h.v,h.parent)}),r.each(s.edges,function(h){a.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),a}return Bh}var Vh,zw;function $w(){if(zw)return Vh;zw=1;var r=vr();Vh=e;function e(t){var i={},n=[],o;function s(a){r.has(i,a)||(i[a]=!0,o.push(a),r.each(t.successors(a),s),r.each(t.predecessors(a),s))}return r.each(t.nodes(),function(a){o=[],s(a),o.length&&n.push(o)}),n}return Vh}var Kh,Uw;function us(){if(Uw)return Kh;Uw=1;var r=vr();Kh=e;function e(){this._arr=[],this._keyIndices={}}return e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(t){return r.has(this._keyIndices,t)},e.prototype.priority=function(t){var i=this._keyIndices[t];if(i!==void 0)return this._arr[i].priority},e.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(t,i){var n=this._keyIndices;if(t=String(t),!r.has(n,t)){var o=this._arr,s=o.length;return n[t]=s,o.push({key:t,priority:i}),this._decrease(s),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,i){var n=this._keyIndices[t];if(i>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+i);this._arr[n].priority=i,this._decrease(n)},e.prototype._heapify=function(t){var i=this._arr,n=2*t,o=n+1,s=t;n>1,!(i[o].priority0&&(g=l.removeMin(),m=f[g],m.distance!==Number.POSITIVE_INFINITY);)h(g).forEach(_);return f}return Yh}var Xh,Bw;function Vw(){if(Bw)return Xh;Bw=1;var r=fs(),e=vr();Xh=t;function t(i,n,o){return e.transform(i.nodes(),function(s,a){s[a]=r(i,a,n,o)},{})}return Xh}var Qh,Kw;function hs(){if(Kw)return Qh;Kw=1;var r=vr();Qh=e;function e(t){var i=0,n=[],o={},s=[];function a(h){var f=o[h]={onStack:!0,lowlink:i,index:i++};if(n.push(h),t.successors(h).forEach(function(m){r.has(o,m)?o[m].onStack&&(f.lowlink=Math.min(f.lowlink,o[m].index)):(a(m),f.lowlink=Math.min(f.lowlink,o[m].lowlink))}),f.lowlink===f.index){var l=[],g;do g=n.pop(),o[g].onStack=!1,l.push(g);while(h!==g);s.push(l)}}return t.nodes().forEach(function(h){r.has(o,h)||a(h)}),s}return Qh}var Zh,Yw;function Xw(){if(Yw)return Zh;Yw=1;var r=vr(),e=hs();Zh=t;function t(i){return r.filter(e(i),function(n){return n.length>1||n.length===1&&i.hasEdge(n[0],n[0])})}return Zh}var Jh,Qw;function Zw(){if(Qw)return Jh;Qw=1;var r=vr();Jh=t;var e=r.constant(1);function t(n,o,s){return i(n,o||e,s||function(a){return n.outEdges(a)})}function i(n,o,s){var a={},h=n.nodes();return h.forEach(function(f){a[f]={},a[f][f]={distance:0},h.forEach(function(l){f!==l&&(a[f][l]={distance:Number.POSITIVE_INFINITY})}),s(f).forEach(function(l){var g=l.v===f?l.w:l.v,m=o(l);a[f][g]={distance:m,predecessor:f}})}),h.forEach(function(f){var l=a[f];h.forEach(function(g){var m=a[g];h.forEach(function(_){var E=m[f],q=l[_],x=m[_],A=E.distance+q.distance;A0;){if(f=h.removeMin(),r.has(a,f))s.setEdge(f,a[f]);else{if(g)throw new Error("Input graph is not connected: "+n);g=!0}n.nodeEdges(f).forEach(l)}return s}return nc}var oc,u0;function f0(){return u0||(u0=1,oc={components:$w(),dijkstra:fs(),dijkstraAll:Vw(),findCycles:Xw(),floydWarshall:Zw(),isAcyclic:e0(),postorder:i0(),preorder:o0(),prim:a0(),tarjan:hs(),topsort:cs()}),oc}var sc,h0;function c0(){if(h0)return sc;h0=1;var r=Gw();return sc={Graph:r.Graph,json:Fw(),alg:f0(),version:r.version},sc}var ac,l0;function kr(){if(l0)return ac;l0=1;var r;if(typeof Bi=="function")try{r=c0()}catch{}return r||(r=window.graphlib),ac=r,ac}var uc,d0;function p0(){if(d0)return uc;d0=1;var r=Po(),e=1,t=4;function i(n){return r(n,e|t)}return uc=i,uc}var fc,g0;function vi(){if(g0)return fc;g0=1;var r=wt(),e=Wr(),t=hi(),i=_r();function n(o,s,a){if(!i(a))return!1;var h=typeof s;return(h=="number"?e(a)&&t(s,a.length):h=="string"&&s in a)?r(a[s],o):!1}return fc=n,fc}var hc,m0;function y0(){if(m0)return hc;m0=1;var r=_i(),e=wt(),t=vi(),i=ft(),n=Object.prototype,o=n.hasOwnProperty,s=r(function(a,h){a=Object(a);var f=-1,l=h.length,g=l>2?h[2]:void 0;for(g&&t(h[0],h[1],g)&&(l=1);++f-1?h[f?o[l]:l]:void 0}}return cc=i,cc}var lc,w0;function q0(){if(w0)return lc;w0=1;var r=/\s/;function e(t){for(var i=t.length;i--&&r.test(t.charAt(i)););return i}return lc=e,lc}var dc,b0;function E0(){if(b0)return dc;b0=1;var r=q0(),e=/^\s+/;function t(i){return i&&i.slice(0,r(i)+1).replace(e,"")}return dc=t,dc}var pc,x0;function S0(){if(x0)return pc;x0=1;var r=E0(),e=_r(),t=xt(),i=NaN,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function h(f){if(typeof f=="number")return f;if(t(f))return i;if(e(f)){var l=typeof f.valueOf=="function"?f.valueOf():f;f=e(l)?l+"":l}if(typeof f!="string")return f===0?f:+f;f=r(f);var g=o.test(f);return g||s.test(f)?a(f.slice(2),g?2:8):n.test(f)?i:+f}return pc=h,pc}var gc,I0;function ds(){if(I0)return gc;I0=1;var r=S0(),e=1/0,t=17976931348623157e292;function i(n){if(!n)return n===0?n:0;if(n=r(n),n===e||n===-e){var o=n<0?-1:1;return o*t}return n===n?n:0}return gc=i,gc}var mc,A0;function R0(){if(A0)return mc;A0=1;var r=ds();function e(t){var i=r(t),n=i%1;return i===i?n?i-n:i:0}return mc=e,mc}var yc,C0;function T0(){if(C0)return yc;C0=1;var r=os(),e=Br(),t=R0(),i=Math.max;function n(o,s,a){var h=o==null?0:o.length;if(!h)return-1;var f=a==null?0:t(a);return f<0&&(f=i(h+f,0)),r(o,e(s,3),f)}return yc=n,yc}var _c,O0;function k0(){if(O0)return _c;O0=1;var r=v0(),e=T0(),t=r(e);return _c=t,_c}var vc,L0;function ps(){if(L0)return vc;L0=1;var r=hn();function e(t){var i=t==null?0:t.length;return i?r(t,1):[]}return vc=e,vc}var wc,M0;function D0(){if(M0)return wc;M0=1;var r=sn(),e=Go(),t=ft();function i(n,o){return n==null?n:r(n,e(o),t)}return wc=i,wc}var qc,j0;function P0(){if(j0)return qc;j0=1;function r(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}return qc=r,qc}var bc,G0;function N0(){if(G0)return bc;G0=1;var r=ui(),e=an(),t=Br();function i(n,o){var s={};return o=t(o,3),e(n,function(a,h,f){r(s,h,o(a,h,f))}),s}return bc=i,bc}var Ec,F0;function ln(){if(F0)return Ec;F0=1;var r=xt();function e(t,i,n){for(var o=-1,s=t.length;++ot}return xc=r,xc}var Sc,U0;function W0(){if(U0)return Sc;U0=1;var r=ln(),e=$0(),t=ht();function i(n){return n&&n.length?r(n,t,e):void 0}return Sc=i,Sc}var Ic,B0;function gs(){if(B0)return Ic;B0=1;var r=ui(),e=wt();function t(i,n,o){(o!==void 0&&!e(i[n],o)||o===void 0&&!(n in i))&&r(i,n,o)}return Ic=t,Ic}var Ac,V0;function K0(){if(V0)return Ac;V0=1;var r=at(),e=di(),t=jr(),i="[object Object]",n=Function.prototype,o=Object.prototype,s=n.toString,a=o.hasOwnProperty,h=s.call(Object);function f(l){if(!t(l)||r(l)!=i)return!1;var g=e(l);if(g===null)return!0;var m=a.call(g,"constructor")&&g.constructor;return typeof m=="function"&&m instanceof m&&s.call(m)==h}return Ac=f,Ac}var Rc,Y0;function ms(){if(Y0)return Rc;Y0=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return Rc=r,Rc}var Cc,X0;function Q0(){if(X0)return Cc;X0=1;var r=Pt(),e=ft();function t(i){return r(i,e(i))}return Cc=t,Cc}var Tc,Z0;function J0(){if(Z0)return Tc;Z0=1;var r=gs(),e=So(),t=Mo(),i=Io(),n=jo(),o=Gt(),s=Ve(),a=ss(),h=bt(),f=jt(),l=_r(),g=K0(),m=Nt(),_=ms(),E=Q0();function q(x,A,S,I,M,D,z){var O=_(x,S),N=_(A,S),j=z.get(N);if(j){r(x,S,j);return}var X=D?D(O,N,S+"",x,A,z):void 0,re=X===void 0;if(re){var oe=s(N),me=!oe&&h(N),_e=!oe&&!me&&m(N);X=N,oe||me||_e?s(O)?X=O:a(O)?X=i(O):me?(re=!1,X=e(N,!0)):_e?(re=!1,X=t(N,!0)):X=[]:g(N)||o(N)?(X=O,o(O)?X=E(O):(!l(O)||f(O))&&(X=n(N))):re=!1}re&&(z.set(N,X),M(X,N,I,D,z),z.delete(N)),r(x,S,X)}return Tc=q,Tc}var Oc,H0;function eq(){if(H0)return Oc;H0=1;var r=ai(),e=gs(),t=sn(),i=J0(),n=_r(),o=ft(),s=ms();function a(h,f,l,g,m){h!==f&&t(f,function(_,E){if(m||(m=new r),n(_))i(h,f,E,l,a,g,m);else{var q=g?g(s(h,E),_,E+"",h,f,m):void 0;q===void 0&&(q=_),e(h,E,q)}},o)}return Oc=a,Oc}var kc,rq;function tq(){if(rq)return kc;rq=1;var r=_i(),e=vi();function t(i){return r(function(n,o){var s=-1,a=o.length,h=a>1?o[a-1]:void 0,f=a>2?o[2]:void 0;for(h=i.length>3&&typeof h=="function"?(a--,h):void 0,f&&e(o[0],o[1],f)&&(h=a<3?void 0:h,a=1),n=Object(n);++si||a&&h&&l&&!f&&!g||o&&h&&l||!n&&l||!s)return 1;if(!o&&!a&&!g&&t=f)return l;var g=n[o];return l*(g=="desc"?-1:1)}}return t.index-i.index}return Yc=e,Yc}var Xc,Mq;function Dq(){if(Mq)return Xc;Mq=1;var r=gi(),e=yi(),t=Br(),i=es(),n=Cq(),o=ci(),s=Lq(),a=ht(),h=Ve();function f(l,g,m){g.length?g=r(g,function(q){return h(q)?function(x){return e(x,q.length===1?q[0]:q)}:q}):g=[a];var _=-1;g=r(g,o(t));var E=i(l,function(q,x,A){var S=r(g,function(I){return I(q)});return{criteria:S,index:++_,value:q}});return n(E,function(q,x){return s(q,x,m)})}return Xc=f,Xc}var Qc,jq;function Pq(){if(jq)return Qc;jq=1;var r=hn(),e=Dq(),t=_i(),i=vi(),n=t(function(o,s){if(o==null)return[];var a=s.length;return a>1&&i(o,s[0],s[1])?s=[]:a>2&&i(s[0],s[1],s[2])&&(s=[s[0]]),e(o,r(s,1),[])});return Qc=n,Qc}var Zc,Gq;function Nq(){if(Gq)return Zc;Gq=1;var r=Ko(),e=0;function t(i){var n=++e;return r(i)+n}return Zc=t,Zc}var Jc,Fq;function zq(){if(Fq)return Jc;Fq=1;function r(e,t,i){for(var n=-1,o=e.length,s=t.length,a={};++n0;--x)if(q=l[x].dequeue(),q){m=m.concat(s(f,l,g,q,!0));break}}}return m}function s(f,l,g,m,_){var E=_?[]:void 0;return r.forEach(f.inEdges(m.v),function(q){var x=f.edge(q),A=f.node(q.v);_&&E.push({v:q.v,w:q.w}),A.out-=x,h(l,g,A)}),r.forEach(f.outEdges(m.v),function(q){var x=f.edge(q),A=q.w,S=f.node(A);S.in-=x,h(l,g,S)}),f.removeNode(m.v),E}function a(f,l){var g=new e,m=0,_=0;r.forEach(f.nodes(),function(x){g.setNode(x,{v:x,in:0,out:0})}),r.forEach(f.edges(),function(x){var A=g.edge(x.v,x.w)||0,S=l(x),I=A+S;g.setEdge(x.v,x.w,I),_=Math.max(_,g.node(x.v).out+=S),m=Math.max(m,g.node(x.w).in+=S)});var E=r.range(_+m+3).map(function(){return new t}),q=m+1;return r.forEach(g.nodes(),function(x){h(E,q,g.node(x))}),{graph:g,buckets:E,zeroIdx:q}}function h(f,l,g){g.out?g.in?f[g.out-g.in+l].enqueue(g):f[f.length-1].enqueue(g):f[0].enqueue(g)}return tl}var il,Xq;function Qq(){if(Xq)return il;Xq=1;var r=Fe(),e=Yq();il={run:t,undo:n};function t(o){var s=o.graph().acyclicer==="greedy"?e(o,a(o)):i(o);r.forEach(s,function(h){var f=o.edge(h);o.removeEdge(h),f.forwardName=h.name,f.reversed=!0,o.setEdge(h.w,h.v,f,r.uniqueId("rev"))});function a(h){return function(f){return h.edge(f).weight}}}function i(o){var s=[],a={},h={};function f(l){r.has(h,l)||(h[l]=!0,a[l]=!0,r.forEach(o.outEdges(l),function(g){r.has(a,g.w)?s.push(g):f(g.w)}),delete a[l])}return r.forEach(o.nodes(),f),s}function n(o){r.forEach(o.edges(),function(s){var a=o.edge(s);if(a.reversed){o.removeEdge(s);var h=a.forwardName;delete a.reversed,delete a.forwardName,o.setEdge(s.w,s.v,a,h)}})}return il}var nl,Zq;function dr(){if(Zq)return nl;Zq=1;var r=Fe(),e=kr().Graph;nl={addDummyNode:t,simplify:i,asNonCompoundGraph:n,successorWeights:o,predecessorWeights:s,intersectRect:a,buildLayerMatrix:h,normalizeRanks:f,removeEmptyRanks:l,addBorderNode:g,maxRank:m,partition:_,time:E,notime:q};function t(x,A,S,I){var M;do M=r.uniqueId(I);while(x.hasNode(M));return S.dummy=A,x.setNode(M,S),M}function i(x){var A=new e().setGraph(x.graph());return r.forEach(x.nodes(),function(S){A.setNode(S,x.node(S))}),r.forEach(x.edges(),function(S){var I=A.edge(S.v,S.w)||{weight:0,minlen:1},M=x.edge(S);A.setEdge(S.v,S.w,{weight:I.weight+M.weight,minlen:Math.max(I.minlen,M.minlen)})}),A}function n(x){var A=new e({multigraph:x.isMultigraph()}).setGraph(x.graph());return r.forEach(x.nodes(),function(S){x.children(S).length||A.setNode(S,x.node(S))}),r.forEach(x.edges(),function(S){A.setEdge(S,x.edge(S))}),A}function o(x){var A=r.map(x.nodes(),function(S){var I={};return r.forEach(x.outEdges(S),function(M){I[M.w]=(I[M.w]||0)+x.edge(M).weight}),I});return r.zipObject(x.nodes(),A)}function s(x){var A=r.map(x.nodes(),function(S){var I={};return r.forEach(x.inEdges(S),function(M){I[M.v]=(I[M.v]||0)+x.edge(M).weight}),I});return r.zipObject(x.nodes(),A)}function a(x,A){var S=x.x,I=x.y,M=A.x-S,D=A.y-I,z=x.width/2,O=x.height/2;if(!M&&!D)throw new Error("Not possible to find intersection inside of the rectangle");var N,j;return Math.abs(D)*z>Math.abs(M)*O?(D<0&&(O=-O),N=O*M/D,j=O):(M<0&&(z=-z),N=z,j=z*D/M),{x:S+N,y:I+j}}function h(x){var A=r.map(r.range(m(x)+1),function(){return[]});return r.forEach(x.nodes(),function(S){var I=x.node(S),M=I.rank;r.isUndefined(M)||(A[M][I.order]=S)}),A}function f(x){var A=r.min(r.map(x.nodes(),function(S){return x.node(S).rank}));r.forEach(x.nodes(),function(S){var I=x.node(S);r.has(I,"rank")&&(I.rank-=A)})}function l(x){var A=r.min(r.map(x.nodes(),function(D){return x.node(D).rank})),S=[];r.forEach(x.nodes(),function(D){var z=x.node(D).rank-A;S[z]||(S[z]=[]),S[z].push(D)});var I=0,M=x.graph().nodeRankFactor;r.forEach(S,function(D,z){r.isUndefined(D)&&z%M!==0?--I:I&&r.forEach(D,function(O){x.node(O).rank+=I})})}function g(x,A,S,I){var M={width:0,height:0};return arguments.length>=4&&(M.rank=S,M.order=I),t(x,"border",M,A)}function m(x){return r.max(r.map(x.nodes(),function(A){var S=x.node(A).rank;if(!r.isUndefined(S))return S}))}function _(x,A){var S={lhs:[],rhs:[]};return r.forEach(x,function(I){A(I)?S.lhs.push(I):S.rhs.push(I)}),S}function E(x,A){var S=r.now();try{return A()}finally{console.log(x+" time: "+(r.now()-S)+"ms")}}function q(x,A){return A()}return nl}var ol,Jq;function Hq(){if(Jq)return ol;Jq=1;var r=Fe(),e=dr();ol={run:t,undo:n};function t(o){o.graph().dummyChains=[],r.forEach(o.edges(),function(s){i(o,s)})}function i(o,s){var a=s.v,h=o.node(a).rank,f=s.w,l=o.node(f).rank,g=s.name,m=o.edge(s),_=m.labelRank;if(l!==h+1){o.removeEdge(s);var E,q,x;for(x=0,++h;hj.lim&&(X=j,re=!0);var oe=r.filter(M.edges(),function(me){return re===S(I,I.node(me.v),X)&&re!==S(I,I.node(me.w),X)});return r.minBy(oe,function(me){return t(M,me)})}function q(I,M,D,z){var O=D.v,N=D.w;I.removeEdge(O,N),I.setEdge(z.v,z.w,{}),g(I),h(I,M),x(I,M)}function x(I,M){var D=r.find(I.nodes(),function(O){return!M.node(O).parent}),z=n(I,D);z=z.slice(1),r.forEach(z,function(O){var N=I.node(O).parent,j=M.edge(O,N),X=!1;j||(j=M.edge(N,O),X=!0),M.node(O).rank=M.node(N).rank+(X?j.minlen:-j.minlen)})}function A(I,M,D){return I.hasEdge(M,D)}function S(I,M,D){return D.low<=M.lim&&M.lim<=D.lim}return ul}var fl,nb;function ob(){if(nb)return fl;nb=1;var r=Ci(),e=r.longestPath,t=_s(),i=ib();fl=n;function n(h){switch(h.graph().ranker){case"network-simplex":a(h);break;case"tight-tree":s(h);break;case"longest-path":o(h);break;default:a(h)}}var o=e;function s(h){e(h),t(h)}function a(h){i(h)}return fl}var hl,sb;function ab(){if(sb)return hl;sb=1;var r=Fe();hl=e;function e(n){var o=i(n);r.forEach(n.graph().dummyChains,function(s){for(var a=n.node(s),h=a.edgeObj,f=t(n,o,h.v,h.w),l=f.path,g=f.lca,m=0,_=l[m],E=!0;s!==h.w;){if(a=n.node(s),E){for(;(_=l[m])!==g&&n.node(_).maxRankl||g>o[m].lim));for(_=m,m=a;(m=n.parent(m))!==_;)f.push(m);return{path:h.concat(f.reverse()),lca:_}}function i(n){var o={},s=0;function a(h){var f=s;r.forEach(n.children(h),a),o[h]={low:f,lim:s++}}return r.forEach(n.children(),a),o}return hl}var cl,ub;function fb(){if(ub)return cl;ub=1;var r=Fe(),e=dr();cl={run:t,cleanup:s};function t(a){var h=e.addDummyNode(a,"root",{},"_root"),f=n(a),l=r.max(r.values(f))-1,g=2*l+1;a.graph().nestingRoot=h,r.forEach(a.edges(),function(_){a.edge(_).minlen*=g});var m=o(a)+1;r.forEach(a.children(),function(_){i(a,h,g,m,l,f,_)}),a.graph().nodeRankFactor=g}function i(a,h,f,l,g,m,_){var E=a.children(_);if(!E.length){_!==h&&a.setEdge(h,_,{weight:0,minlen:f});return}var q=e.addBorderNode(a,"_bt"),x=e.addBorderNode(a,"_bb"),A=a.node(_);a.setParent(q,_),A.borderTop=q,a.setParent(x,_),A.borderBottom=x,r.forEach(E,function(S){i(a,h,f,l,g,m,S);var I=a.node(S),M=I.borderTop?I.borderTop:S,D=I.borderBottom?I.borderBottom:S,z=I.borderTop?l:2*l,O=M!==D?1:g-m[_]+1;a.setEdge(q,M,{weight:z,minlen:O,nestingEdge:!0}),a.setEdge(D,x,{weight:z,minlen:O,nestingEdge:!0})}),a.parent(_)||a.setEdge(h,q,{weight:0,minlen:g+m[_]})}function n(a){var h={};function f(l,g){var m=a.children(l);m&&m.length&&r.forEach(m,function(_){f(_,g+1)}),h[l]=g}return r.forEach(a.children(),function(l){f(l,1)}),h}function o(a){return r.reduce(a.edges(),function(h,f){return h+a.edge(f).weight},0)}function s(a){var h=a.graph();a.removeNode(h.nestingRoot),delete h.nestingRoot,r.forEach(a.edges(),function(f){var l=a.edge(f);l.nestingEdge&&a.removeEdge(f)})}return cl}var ll,hb;function cb(){if(hb)return ll;hb=1;var r=Fe(),e=dr();ll=t;function t(n){function o(s){var a=n.children(s),h=n.node(s);if(a.length&&r.forEach(a,o),r.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var f=h.minRank,l=h.maxRank+1;f0;)_%2&&(E+=l[_+1]),_=_-1>>1,l[_]+=m.weight;g+=m.weight*E})),g}return gl}var ml,_b;function vb(){if(_b)return ml;_b=1;var r=Fe();ml=e;function e(t,i){return r.map(i,function(n){var o=t.inEdges(n);if(o.length){var s=r.reduce(o,function(a,h){var f=t.edge(h),l=t.node(h.v);return{sum:a.sum+f.weight*l.order,weight:a.weight+f.weight}},{sum:0,weight:0});return{v:n,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:n}})}return ml}var yl,wb;function qb(){if(wb)return yl;wb=1;var r=Fe();yl=e;function e(n,o){var s={};r.forEach(n,function(h,f){var l=s[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:f};r.isUndefined(h.barycenter)||(l.barycenter=h.barycenter,l.weight=h.weight)}),r.forEach(o.edges(),function(h){var f=s[h.v],l=s[h.w];!r.isUndefined(f)&&!r.isUndefined(l)&&(l.indegree++,f.out.push(s[h.w]))});var a=r.filter(s,function(h){return!h.indegree});return t(a)}function t(n){var o=[];function s(f){return function(l){l.merged||(r.isUndefined(l.barycenter)||r.isUndefined(f.barycenter)||l.barycenter>=f.barycenter)&&i(f,l)}}function a(f){return function(l){l.in.push(f),--l.indegree===0&&n.push(l)}}for(;n.length;){var h=n.pop();o.push(h),r.forEach(h.in.reverse(),s(h)),r.forEach(h.out,a(h))}return r.map(r.filter(o,function(f){return!f.merged}),function(f){return r.pick(f,["vs","i","barycenter","weight"])})}function i(n,o){var s=0,a=0;n.weight&&(s+=n.barycenter*n.weight,a+=n.weight),o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),n.vs=o.vs.concat(n.vs),n.barycenter=s/a,n.weight=a,n.i=Math.min(o.i,n.i),o.merged=!0}return yl}var _l,bb;function Eb(){if(bb)return _l;bb=1;var r=Fe(),e=dr();_l=t;function t(o,s){var a=e.partition(o,function(q){return r.has(q,"barycenter")}),h=a.lhs,f=r.sortBy(a.rhs,function(q){return-q.i}),l=[],g=0,m=0,_=0;h.sort(n(!!s)),_=i(l,f,_),r.forEach(h,function(q){_+=q.vs.length,l.push(q.vs),g+=q.barycenter*q.weight,m+=q.weight,_=i(l,f,_)});var E={vs:r.flatten(l,!0)};return m&&(E.barycenter=g/m,E.weight=m),E}function i(o,s,a){for(var h;s.length&&(h=r.last(s)).i<=a;)s.pop(),o.push(h.vs),a++;return a}function n(o){return function(s,a){return s.barycentera.barycenter?1:o?a.i-s.i:s.i-a.i}}return _l}var vl,xb;function Sb(){if(xb)return vl;xb=1;var r=Fe(),e=vb(),t=qb(),i=Eb();vl=n;function n(a,h,f,l){var g=a.children(h),m=a.node(h),_=m?m.borderLeft:void 0,E=m?m.borderRight:void 0,q={};_&&(g=r.filter(g,function(D){return D!==_&&D!==E}));var x=e(a,g);r.forEach(x,function(D){if(a.children(D.v).length){var z=n(a,D.v,f,l);q[D.v]=z,r.has(z,"barycenter")&&s(D,z)}});var A=t(x,f);o(A,q);var S=i(A,l);if(_&&(S.vs=r.flatten([_,S.vs,E],!0),a.predecessors(_).length)){var I=a.node(a.predecessors(_)[0]),M=a.node(a.predecessors(E)[0]);r.has(S,"barycenter")||(S.barycenter=0,S.weight=0),S.barycenter=(S.barycenter*S.weight+I.order+M.order)/(S.weight+2),S.weight+=2}return S}function o(a,h){r.forEach(a,function(f){f.vs=r.flatten(f.vs.map(function(l){return h[l]?h[l].vs:l}),!0)})}function s(a,h){r.isUndefined(a.barycenter)?(a.barycenter=h.barycenter,a.weight=h.weight):(a.barycenter=(a.barycenter*a.weight+h.barycenter*h.weight)/(a.weight+h.weight),a.weight+=h.weight)}return vl}var wl,Ib;function Ab(){if(Ib)return wl;Ib=1;var r=Fe(),e=kr().Graph;wl=t;function t(n,o,s){var a=i(n),h=new e({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(f){return n.node(f)});return r.forEach(n.nodes(),function(f){var l=n.node(f),g=n.parent(f);(l.rank===o||l.minRank<=o&&o<=l.maxRank)&&(h.setNode(f),h.setParent(f,g||a),r.forEach(n[s](f),function(m){var _=m.v===f?m.w:m.v,E=h.edge(_,f),q=r.isUndefined(E)?0:E.weight;h.setEdge(_,f,{weight:n.edge(m).weight+q})}),r.has(l,"minRank")&&h.setNode(f,{borderLeft:l.borderLeft[o],borderRight:l.borderRight[o]}))}),h}function i(n){for(var o;n.hasNode(o=r.uniqueId("_root")););return o}return wl}var ql,Rb;function Cb(){if(Rb)return ql;Rb=1;var r=Fe();ql=e;function e(t,i,n){var o={},s;r.forEach(n,function(a){for(var h=t.parent(a),f,l;h;){if(f=t.parent(h),f?(l=o[f],o[f]=h):(l=s,s=h),l&&l!==h){i.setEdge(l,h);return}h=f}})}return ql}var bl,Tb;function Ob(){if(Tb)return bl;Tb=1;var r=Fe(),e=gb(),t=yb(),i=Sb(),n=Ab(),o=Cb(),s=kr().Graph,a=dr();bl=h;function h(m){var _=a.maxRank(m),E=f(m,r.range(1,_+1),"inEdges"),q=f(m,r.range(_-1,-1,-1),"outEdges"),x=e(m);g(m,x);for(var A=Number.POSITIVE_INFINITY,S,I=0,M=0;M<4;++I,++M){l(I%2?E:q,I%4>=2),x=a.buildLayerMatrix(m);var D=t(m,x);DX)&&s(I,me,re)})})}function D(z,O){var N=-1,j,X=0;return r.forEach(O,function(re,oe){if(A.node(re).dummy==="border"){var me=A.predecessors(re);me.length&&(j=A.node(me[0]).order,M(O,X,oe,N,j),X=oe,N=j)}M(O,X,O.length,j,z.length)}),O}return r.reduce(S,D),I}function o(A,S){if(A.node(S).dummy)return r.find(A.predecessors(S),function(I){return A.node(I).dummy})}function s(A,S,I){if(S>I){var M=S;S=I,I=M}var D=A[S];D||(A[S]=D={}),D[I]=!0}function a(A,S,I){if(S>I){var M=S;S=I,I=M}return r.has(A[S],I)}function h(A,S,I,M){var D={},z={},O={};return r.forEach(S,function(N){r.forEach(N,function(j,X){D[j]=j,z[j]=j,O[j]=X})}),r.forEach(S,function(N){var j=-1;r.forEach(N,function(X){var re=M(X);if(re.length){re=r.sortBy(re,function(Ne){return O[Ne]});for(var oe=(re.length-1)/2,me=Math.floor(oe),_e=Math.ceil(oe);me<=_e;++me){var Te=re[me];z[X]===X&&j({}));let t=Rn(this.options.nodeSize,0);this.model.forEachNode(_=>{let E=_._original,[q,x]=zi(t(E)),A={width:q,height:x};if(e.setNode(String(_.id),A),this.isCompound()){if(tt(_.parentId))return;e.setParent(String(_.id),String(_.parentId))}});let{edgeLabelSize:i,edgeLabelOffset:n,edgeLabelPos:o,edgeMinLen:s,edgeWeight:a}=this.options,h=Rn(i,0,"edge"),f=no(n,10,"edge"),l=typeof o=="string"?()=>o:ti(o,["edge"]),g=no(s,1,"edge"),m=no(a,1,"edge");this.model.forEachEdge(_=>{let E=_._original,[q,x]=zi(h(E)),A={width:q,height:x,labelpos:l(E),labeloffset:f(E),minlen:g(E),weight:m(E)};e.setEdge(String(_.source),String(_.target),A,String(_.id))}),Wb.layout(e),this.model.forEachNode(_=>{let E=e.node(String(_.id));E&&(_.x=E.x,_.y=E.y,_.size=[E.width,E.height])}),this.model.forEachEdge(_=>{let E=e.edge(String(_.source),String(_.target),String(_.id));if(!E)return;let{width:q,height:x,weight:A,minlen:S,labelpos:I,labeloffset:M,points:D}=E;_.labelSize=[q,x],_.weight=A,_.minLen=S,_.labelPos=I,_.labelOffset=M,_.points=D.map(Kp)})})}isCompound(){return this.isCompoundGraph!==null?this.isCompoundGraph:Bb(this.options.compound)?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(e=>!tt(e.parentId)),this.isCompoundGraph)}};var Ke={};var Tl={};$s(Tl,{isAnyArray:()=>wi});var zI=Object.prototype.toString;function wi(r){let e=zI.call(r);return e.endsWith("Array]")&&!e.includes("Big")}var Yb=vo(Tl);var Ol={};$s(Ol,{default:()=>$I});function Xb(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!wi(r))throw new TypeError("input must be an array");if(r.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,i=t===void 0?0:t,n=e.toIndex,o=n===void 0?r.length:n;if(i<0||i>=r.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>r.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=r[i],a=i+1;as&&(s=r[a]);return s}function Qb(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!wi(r))throw new TypeError("input must be an array");if(r.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,i=t===void 0?0:t,n=e.toIndex,o=n===void 0?r.length:n;if(i<0||i>=r.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>r.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=r[i],a=i+1;a1&&arguments[1]!==void 0?arguments[1]:{};if(wi(r)){if(r.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(e.output!==void 0){if(!wi(e.output))throw new TypeError("output option must be an array if specified");t=e.output}else t=new Array(r.length);var i=Qb(r),n=Xb(r);if(i===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=e.min,s=o===void 0?e.autoMinMax?i:0:o,a=e.max,h=a===void 0?e.autoMinMax?n:1:a;if(s>=h)throw new RangeError("min option must be smaller than max option");for(var f=(h-s)/(n-i),l=0;l{throw TypeError(r)};var hx=(r,e,t)=>e in r?zn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var De=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),$s=(r,e)=>{for(var t in e)zn(r,t,{get:e[t],enumerable:!0})},cx=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ax(e))!fx.call(r,n)&&n!==t&&zn(r,n,{get:()=>e[n],enumerable:!(i=sx(e,n))||i.enumerable});return r};var Qr=(r,e,t)=>(t=r!=null?ox(ux(r)):{},cx(e||!r||!r.__esModule?zn(t,"default",{value:r,enumerable:!0}):t,r));var ld=(r,e,t)=>hx(r,typeof e!="symbol"?e+"":e,t),Us=(r,e,t)=>e.has(r)||cd("Cannot "+t);var At=(r,e,t)=>(Us(r,e,"read from private field"),t?t.call(r):e.get(r)),Ws=(r,e,t)=>e.has(r)?cd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$n=(r,e,t,i)=>(Us(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Bs=(r,e,t)=>(Us(r,e,"access private method"),t);var Ed=De((dC,Vs)=>{"use strict";var Li=typeof Reflect=="object"?Reflect:null,dd=Li&&typeof Li.apply=="function"?Li.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Un;Li&&typeof Li.ownKeys=="function"?Un=Li.ownKeys:Object.getOwnPropertySymbols?Un=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Un=function(e){return Object.getOwnPropertyNames(e)};function lx(r){console&&console.warn&&console.warn(r)}var gd=Number.isNaN||function(e){return e!==e};function or(){or.init.call(this)}Vs.exports=or;Vs.exports.once=mx;or.EventEmitter=or;or.prototype._events=void 0;or.prototype._eventsCount=0;or.prototype._maxListeners=void 0;var pd=10;function Wn(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(or,"defaultMaxListeners",{enumerable:!0,get:function(){return pd},set:function(r){if(typeof r!="number"||r<0||gd(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");pd=r}});or.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};or.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||gd(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function md(r){return r._maxListeners===void 0?or.defaultMaxListeners:r._maxListeners}or.prototype.getMaxListeners=function(){return md(this)};or.prototype.emit=function(e){for(var t=[],i=1;i0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var h=o[e];if(h===void 0)return!1;if(typeof h=="function")dd(h,this,t);else for(var f=h.length,l=qd(h,f),i=0;i0&&s.length>n&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=s.length,lx(a)}return r}or.prototype.addListener=function(e,t){return yd(this,e,t,!1)};or.prototype.on=or.prototype.addListener;or.prototype.prependListener=function(e,t){return yd(this,e,t,!0)};function dx(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _d(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=dx.bind(i);return n.listener=t,i.wrapFn=n,n}or.prototype.once=function(e,t){return Wn(t),this.on(e,_d(this,e,t)),this};or.prototype.prependOnceListener=function(e,t){return Wn(t),this.prependListener(e,_d(this,e,t)),this};or.prototype.removeListener=function(e,t){var i,n,o,s,a;if(Wn(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():px(i,o),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};or.prototype.off=or.prototype.removeListener;or.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function vd(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?gx(n):qd(n,n.length)}or.prototype.listeners=function(e){return vd(this,e,!0)};or.prototype.rawListeners=function(e){return vd(this,e,!1)};or.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):wd.call(r,e)};or.prototype.listenerCount=wd;function wd(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}or.prototype.eventNames=function(){return this._eventsCount>0?Un(this._events):[]};function qd(r,e){for(var t=new Array(e),i=0;i{function ES(r){return!r||typeof r!="object"||typeof r=="function"||Array.isArray(r)||r instanceof Set||r instanceof Map||r instanceof RegExp||r instanceof Date}function Pd(r,e){r=r||{};var t={};for(var i in e){var n=r[i],o=e[i];if(!ES(o)){t[i]=Pd(n,o);continue}n===void 0?t[i]=o:t[i]=n}return t}Gd.exports=Pd});var Or=De((mC,Nd)=>{Nd.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var Ud=De((yC,$d)=>{function Fd(r){return function(e,t){return e+Math.floor(r()*(t-e+1))}}var zd=Fd(Math.random);zd.createRandom=Fd;$d.exports=zd});var Kd=De((_C,Vd)=>{var xS=Ud().createRandom;function Wd(r){var e=xS(r);return function(t){for(var i=t.length,n=i-1,o=-1;++o{var SS=_t(),IS=Or(),AS=Kd(),RS={attributes:{x:"x",y:"y"},center:0,hierarchyAttributes:[],rng:Math.random,scale:1};function nt(r,e,t,i,n){this.wrappedCircle=n||null,this.children={},this.countChildren=0,this.id=r||null,this.next=null,this.previous=null,this.x=e||null,this.y=t||null,n?this.r=1010101:this.r=i||999}nt.prototype.hasChildren=function(){return this.countChildren>0};nt.prototype.addChild=function(r,e){this.children[r]=e,++this.countChildren};nt.prototype.getChild=function(r){if(!this.children.hasOwnProperty(r)){var e=new nt;this.children[r]=e,++this.countChildren}return this.children[r]};nt.prototype.applyPositionToChildren=function(){if(this.hasChildren()){var r=this;for(var e in r.children){var t=r.children[e];t.x+=r.x,t.y+=r.y,t.applyPositionToChildren()}}};function Zd(r,e,t){for(var i in e.children){var n=e.children[i];n.hasChildren()?Zd(r,n,t):t[n.id]={x:n.x,y:n.y}}}function Jn(r,e){var t=r.r-e.r,i=e.x-r.x,n=e.y-r.y;return t<0||t*t0&&t*t>i*i+n*n}function Js(r,e){for(var t=0;th?(n=(f+h-o)/(2*f),a=Math.sqrt(Math.max(0,h/f-n*n)),t.x=r.x-n*i-a*s,t.y=r.y-n*s+a*i):(n=(f+o-h)/(2*f),a=Math.sqrt(Math.max(0,o/f-n*n)),t.x=e.x+n*i-a*s,t.y=e.y+n*s+a*i)):(t.x=e.x+t.r,t.y=e.y)}function Qd(r,e){var t=r.r+e.r-1e-6,i=e.x-r.x,n=e.y-r.y;return t>0&&t*t>i*i+n*n}function LS(r,e){var t=r.length;if(t===0)return 0;var i,n,o,s,a,h,f,l,g,m;if(i=r[0],i.x=0,i.y=0,t<=1)return i.r;if(n=r[1],i.x=-n.r,n.x=i.r,n.y=0,t<=2)return i.r+n.r;o=r[2],Xd(n,i,o),i=new nt(null,null,null,null,i),n=new nt(null,null,null,null,n),o=new nt(null,null,null,null,o),i.next=o.previous=n,n.next=i.previous=o,o.next=n.previous=i;e:for(h=3;h{var DS=_t(),jS=Or(),PS={dimensions:["x","y"],center:.5,scale:1};function op(r,e,t){if(!jS(e))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");t=DS(t,PS);var i=t.dimensions;if(!Array.isArray(i)||i.length!==2)throw new Error("graphology-layout/random: given dimensions are invalid.");var n=t.center,o=t.scale,s=Math.PI*2,a=(n-.5)*o,h=e.order,f=i[0],l=i[1];function g(E,q){return q[f]=o*Math.cos(E*s/h)+a,q[l]=o*Math.sin(E*s/h)+a,q}var m=0;if(!r){var _={};return e.forEachNode(function(E){_[E]=g(m++,{})}),_}e.updateEachNodeAttributes(function(E,q){return g(m++,q),q},{attributes:i})}var sp=op.bind(null,!1);sp.assign=op.bind(null,!0);ap.exports=sp});var lp=De((qC,cp)=>{var GS=_t(),NS=Or(),FS={dimensions:["x","y"],center:.5,rng:Math.random,scale:1};function fp(r,e,t){if(!NS(e))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");t=GS(t,FS);var i=t.dimensions;if(!Array.isArray(i)||i.length<1)throw new Error("graphology-layout/random: given dimensions are invalid.");var n=i.length,o=t.center,s=t.rng,a=t.scale,h=(o-.5)*a;function f(g){for(var m=0;m{var zS=_t(),$S=Or(),US=Math.PI/180,WS={dimensions:["x","y"],centeredOnZero:!1,degrees:!1};function dp(r,e,t,i){if(!$S(e))throw new Error("graphology-layout/rotation: the given graph is not a valid graphology instance.");i=zS(i,WS),i.degrees&&(t*=US);var n=i.dimensions;if(!Array.isArray(n)||n.length!==2)throw new Error("graphology-layout/random: given dimensions are invalid.");if(e.order===0)return r?void 0:{};var o=n[0],s=n[1],a=0,h=0;if(!i.centeredOnZero){var f=1/0,l=-1/0,g=1/0,m=-1/0;e.forEachNode(function(A,S){var I=S[o],M=S[s];Il&&(l=I),Mm&&(m=M)}),a=(f+l)/2,h=(g+m)/2}var _=Math.cos(t),E=Math.sin(t);function q(A){var S=A[o],I=A[s];return A[o]=a+(S-a)*_-(I-h)*E,A[s]=h+(S-a)*E+(I-h)*_,A}if(!r){var x={};return e.forEachNode(function(A,S){var I={};I[o]=S[o],I[s]=S[s],x[A]=q(I)}),x}e.updateEachNodeAttributes(function(A,S){return q(S),S},{attributes:n})}var pp=dp.bind(null,!1);pp.assign=dp.bind(null,!0);gp.exports=pp});var yp=De(qn=>{qn.circlepack=np();qn.circular=up();qn.random=lp();qn.rotation=mp()});var Gi=De(Hn=>{function BS(r){return typeof r!="number"||isNaN(r)?1:r}function VS(r,e){var t={},i=function(s){return typeof s>"u"?e:s};typeof e=="function"&&(i=e);var n=function(s){return i(s[r])},o=function(){return i(void 0)};return typeof r=="string"?(t.fromAttributes=n,t.fromGraph=function(s,a){return n(s.getNodeAttributes(a))},t.fromEntry=function(s,a){return n(a)}):typeof r=="function"?(t.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},t.fromGraph=function(s,a){return i(r(a,s.getNodeAttributes(a)))},t.fromEntry=function(s,a){return i(r(s,a))}):(t.fromAttributes=o,t.fromGraph=o,t.fromEntry=o),t}function _p(r,e){var t={},i=function(s){return typeof s>"u"?e:s};typeof e=="function"&&(i=e);var n=function(s){return i(s[r])},o=function(){return i(void 0)};return typeof r=="string"?(t.fromAttributes=n,t.fromGraph=function(s,a){return n(s.getEdgeAttributes(a))},t.fromEntry=function(s,a){return n(a)},t.fromPartialEntry=t.fromEntry,t.fromMinimalEntry=t.fromEntry):typeof r=="function"?(t.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},t.fromGraph=function(s,a){var h=s.extremities(a);return i(r(a,s.getEdgeAttributes(a),h[0],h[1],s.getNodeAttributes(h[0]),s.getNodeAttributes(h[1]),s.isUndirected(a)))},t.fromEntry=function(s,a,h,f,l,g,m){return i(r(s,a,h,f,l,g,m))},t.fromPartialEntry=function(s,a,h,f){return i(r(s,a,h,f))},t.fromMinimalEntry=function(s,a){return i(r(s,a))}):(t.fromAttributes=o,t.fromGraph=o,t.fromEntry=o,t.fromMinimalEntry=o),t}Hn.createNodeValueGetter=VS;Hn.createEdgeValueGetter=_p;Hn.createEdgeWeightGetter=function(r){return _p(r,BS)}});var Ep=De((SC,bp)=>{var Dr=0,br=1,Je=2,He=3,Yt=4,Xt=5,rr=6,vp=7,eo=8,wp=9,KS=0,YS=1,XS=2,Ur=0,vt=1,rt=2,Ai=3,Jt=4,xr=5,ot=6,Lt=7,Mt=8,qp=3,Ct=10,QS=3,Zr=9,Hs=10;bp.exports=function(e,t,i){var n,o,s,a,h,f,l,g,m,_,E=t.length,q=i.length,x=e.adjustSizes,A=e.barnesHutTheta*e.barnesHutTheta,S,I,M,D,z,O,N,j=[];for(s=0;sB?(oe-=(Oe-B)/2,me=oe+Oe):(X-=(B-Oe)/2,re=X+B),j[0+Ur]=-1,j[0+vt]=(X+re)/2,j[0+rt]=(oe+me)/2,j[0+Ai]=Math.max(re-X,me-oe),j[0+Jt]=-1,j[0+xr]=-1,j[0+ot]=0,j[0+Lt]=0,j[0+Mt]=0,n=1,s=0;s=0){t[s+Dr]=0)if(O=Math.pow(t[s+Dr]-j[o+Lt],2)+Math.pow(t[s+br]-j[o+Mt],2),_=j[o+Ai],4*_*_/O0?(N=I*t[s+rr]*j[o+ot]/O,t[s+Je]+=M*N,t[s+He]+=D*N):O<0&&(N=-I*t[s+rr]*j[o+ot]/Math.sqrt(O),t[s+Je]+=M*N,t[s+He]+=D*N):O>0&&(N=I*t[s+rr]*j[o+ot]/O,t[s+Je]+=M*N,t[s+He]+=D*N),o=j[o+Jt],o<0)break;continue}else{o=j[o+xr];continue}else{if(f=j[o+Ur],f>=0&&f!==s&&(M=t[s+Dr]-t[f+Dr],D=t[s+br]-t[f+br],O=M*M+D*D,x===!0?O>0?(N=I*t[s+rr]*t[f+rr]/O,t[s+Je]+=M*N,t[s+He]+=D*N):O<0&&(N=-I*t[s+rr]*t[f+rr]/Math.sqrt(O),t[s+Je]+=M*N,t[s+He]+=D*N):O>0&&(N=I*t[s+rr]*t[f+rr]/O,t[s+Je]+=M*N,t[s+He]+=D*N)),o=j[o+Jt],o<0)break;continue}else for(I=e.scalingRatio,a=0;a0?(N=I*t[a+rr]*t[h+rr]/O/O,t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N):O<0&&(N=100*I*t[a+rr]*t[h+rr],t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N)):(O=Math.sqrt(M*M+D*D),O>0&&(N=I*t[a+rr]*t[h+rr]/O/O,t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N));for(m=e.gravity/e.scalingRatio,I=e.scalingRatio,s=0;s0&&(N=I*t[s+rr]*m):O>0&&(N=I*t[s+rr]*m/O),t[s+Je]-=M*N,t[s+He]-=D*N;for(I=1*(e.outboundAttractionDistribution?S:1),l=0;l0&&(N=-I*z*Math.log(1+O)/O/t[a+rr]):O>0&&(N=-I*z*Math.log(1+O)/O):e.outboundAttractionDistribution?O>0&&(N=-I*z/t[a+rr]):O>0&&(N=-I*z)):(O=Math.sqrt(Math.pow(M,2)+Math.pow(D,2)),e.linLogMode?e.outboundAttractionDistribution?O>0&&(N=-I*z*Math.log(1+O)/O/t[a+rr]):O>0&&(N=-I*z*Math.log(1+O)/O):e.outboundAttractionDistribution?(O=1,N=-I*z/t[a+rr]):(O=1,N=-I*z)),O>0&&(t[a+Je]+=M*N,t[a+He]+=D*N,t[h+Je]-=M*N,t[h+He]-=D*N);var pr,Ze,ge,U,Ge,Z;if(x===!0)for(s=0;sHs&&(t[s+Je]=t[s+Je]*Hs/pr,t[s+He]=t[s+He]*Hs/pr),Ze=t[s+rr]*Math.sqrt((t[s+Yt]-t[s+Je])*(t[s+Yt]-t[s+Je])+(t[s+Xt]-t[s+He])*(t[s+Xt]-t[s+He])),ge=Math.sqrt((t[s+Yt]+t[s+Je])*(t[s+Yt]+t[s+Je])+(t[s+Xt]+t[s+He])*(t[s+Xt]+t[s+He]))/2,U=.1*Math.log(1+ge)/(1+Math.sqrt(Ze)),Ge=t[s+Dr]+t[s+Je]*(U/e.slowDown),t[s+Dr]=Ge,Z=t[s+br]+t[s+He]*(U/e.slowDown),t[s+br]=Z);else for(s=0;s{var bn=10,xp=3;Ht.assign=function(r){r=r||{};var e=Array.prototype.slice.call(arguments).slice(1),t,i,n;for(t=0,n=e.length;t=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};Ht.graphToByteArrays=function(r,e){var t=r.order,i=r.size,n={},o,s=new Float32Array(t*bn),a=new Float32Array(i*xp);return o=0,r.forEachNode(function(h,f){n[h]=o,s[o]=f.x,s[o+1]=f.y,s[o+2]=0,s[o+3]=0,s[o+4]=0,s[o+5]=0,s[o+6]=1,s[o+7]=1,s[o+8]=f.size||1,s[o+9]=f.fixed?1:0,o+=bn}),o=0,r.forEachEdge(function(h,f,l,g,m,_,E){var q=n[l],x=n[g],A=e(h,f,l,g,m,_,E);s[q+6]+=A,s[x+6]+=A,a[o]=q,a[o+1]=x,a[o+2]=A,o+=xp}),{nodes:s,edges:a}};Ht.assignLayoutChanges=function(r,e,t){var i=0;r.updateEachNodeAttributes(function(n,o){return o.x=e[i],o.y=e[i+1],i+=bn,t?t(n,o):o})};Ht.readGraphPositions=function(r,e){var t=0;r.forEachNode(function(i,n){e[t]=n.x,e[t+1]=n.y,t+=bn})};Ht.collectLayoutChanges=function(r,e,t){for(var i=r.nodes(),n={},o=0,s=0,a=e.length;o{Sp.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}});var Rp=De((RC,Ap)=>{var ZS=Or(),JS=Gi().createEdgeWeightGetter,HS=Ep(),En=ea(),eI=ra();function Ip(r,e,t){if(!ZS(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof t=="number"&&(t={iterations:t});var i=t.iterations;if(typeof i!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(i<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var n=JS("getEdgeWeight"in t?t.getEdgeWeight:"weight").fromEntry,o=typeof t.outputReducer=="function"?t.outputReducer:null,s=En.assign({},eI,t.settings),a=En.validateSettings(s);if(a)throw new Error("graphology-layout-forceatlas2: "+a.message);var h=En.graphToByteArrays(e,n),f;for(f=0;f2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}}var ta=Ip.bind(null,!1);ta.assign=Ip.bind(null,!0);ta.inferSettings=rI;Ap.exports=ta});var Tp=De((CC,Cp)=>{Cp.exports=function(){var e,t,i={};(function(){var o=0,s=1,a=2,h=3,f=4,l=5,g=6,m=7,_=8,E=9,q=0,x=1,A=2,S=0,I=1,M=2,D=3,z=4,O=5,N=6,j=7,X=8,re=3,oe=10,me=3,_e=9,Te=10;i.exports=function(Oe,B,pr){var Ze,ge,U,Ge,Z,W,ue,le,de,Ye,Be=B.length,wr=pr.length,er=Oe.adjustSizes,qr=Oe.barnesHutTheta*Oe.barnesHutTheta,Xe,Ae,ze,be,sr,Se,Le,ie=[];for(U=0;USt?(Tr-=(Ot-St)/2,cr=Tr+Ot):(tr-=(St-Ot)/2,ar=tr+St),ie[0+S]=-1,ie[0+I]=(tr+ar)/2,ie[0+M]=(Tr+cr)/2,ie[0+D]=Math.max(ar-tr,cr-Tr),ie[0+z]=-1,ie[0+O]=-1,ie[0+N]=0,ie[0+j]=0,ie[0+X]=0,Ze=1,U=0;U=0){B[U+o]=0)if(Se=Math.pow(B[U+o]-ie[ge+j],2)+Math.pow(B[U+s]-ie[ge+X],2),Ye=ie[ge+D],4*Ye*Ye/Se0?(Le=Ae*B[U+g]*ie[ge+N]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le):Se<0&&(Le=-Ae*B[U+g]*ie[ge+N]/Math.sqrt(Se),B[U+a]+=ze*Le,B[U+h]+=be*Le):Se>0&&(Le=Ae*B[U+g]*ie[ge+N]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le),ge=ie[ge+z],ge<0)break;continue}else{ge=ie[ge+O];continue}else{if(W=ie[ge+S],W>=0&&W!==U&&(ze=B[U+o]-B[W+o],be=B[U+s]-B[W+s],Se=ze*ze+be*be,er===!0?Se>0?(Le=Ae*B[U+g]*B[W+g]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le):Se<0&&(Le=-Ae*B[U+g]*B[W+g]/Math.sqrt(Se),B[U+a]+=ze*Le,B[U+h]+=be*Le):Se>0&&(Le=Ae*B[U+g]*B[W+g]/Se,B[U+a]+=ze*Le,B[U+h]+=be*Le)),ge=ie[ge+z],ge<0)break;continue}else for(Ae=Oe.scalingRatio,Ge=0;Ge0?(Le=Ae*B[Ge+g]*B[Z+g]/Se/Se,B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le):Se<0&&(Le=100*Ae*B[Ge+g]*B[Z+g],B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le)):(Se=Math.sqrt(ze*ze+be*be),Se>0&&(Le=Ae*B[Ge+g]*B[Z+g]/Se/Se,B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le));for(de=Oe.gravity/Oe.scalingRatio,Ae=Oe.scalingRatio,U=0;U0&&(Le=Ae*B[U+g]*de):Se>0&&(Le=Ae*B[U+g]*de/Se),B[U+a]-=ze*Le,B[U+h]-=be*Le;for(Ae=1*(Oe.outboundAttractionDistribution?Xe:1),ue=0;ue0&&(Le=-Ae*sr*Math.log(1+Se)/Se/B[Ge+g]):Se>0&&(Le=-Ae*sr*Math.log(1+Se)/Se):Oe.outboundAttractionDistribution?Se>0&&(Le=-Ae*sr/B[Ge+g]):Se>0&&(Le=-Ae*sr)):(Se=Math.sqrt(Math.pow(ze,2)+Math.pow(be,2)),Oe.linLogMode?Oe.outboundAttractionDistribution?Se>0&&(Le=-Ae*sr*Math.log(1+Se)/Se/B[Ge+g]):Se>0&&(Le=-Ae*sr*Math.log(1+Se)/Se):Oe.outboundAttractionDistribution?(Se=1,Le=-Ae*sr/B[Ge+g]):(Se=1,Le=-Ae*sr)),Se>0&&(B[Ge+a]+=ze*Le,B[Ge+h]+=be*Le,B[Z+a]-=ze*Le,B[Z+h]-=be*Le);var K,v,b,k,G,P;if(er===!0)for(U=0;UTe&&(B[U+a]=B[U+a]*Te/K,B[U+h]=B[U+h]*Te/K),v=B[U+g]*Math.sqrt((B[U+f]-B[U+a])*(B[U+f]-B[U+a])+(B[U+l]-B[U+h])*(B[U+l]-B[U+h])),b=Math.sqrt((B[U+f]+B[U+a])*(B[U+f]+B[U+a])+(B[U+l]+B[U+h])*(B[U+l]+B[U+h]))/2,k=.1*Math.log(1+b)/(1+Math.sqrt(v)),G=B[U+o]+B[U+a]*(k/Oe.slowDown),B[U+o]=G,P=B[U+s]+B[U+h]*(k/Oe.slowDown),B[U+s]=P);else for(U=0;U{var tI=Tp(),iI=Or(),nI=Gi().createEdgeWeightGetter,Ni=ea(),oI=ra();function ei(r,e){if(e=e||{},!iI(r))throw new Error("graphology-layout-forceatlas2/worker: the given graph is not a valid graphology instance.");var t=nI("getEdgeWeight"in e?e.getEdgeWeight:"weight").fromEntry,i=Ni.assign({},oI,e.settings),n=Ni.validateSettings(i);if(n)throw new Error("graphology-layout-forceatlas2/worker: "+n.message);this.worker=null,this.graph=r,this.settings=i,this.getEdgeWeight=t,this.matrices=null,this.running=!1,this.killed=!1,this.outputReducer=typeof e.outputReducer=="function"?e.outputReducer:null,this.handleMessage=this.handleMessage.bind(this);var o=void 0,s=this;this.handleGraphUpdate=function(){s.worker&&s.worker.terminate(),o&&clearTimeout(o),o=setTimeout(function(){o=void 0,s.spawnWorker()},0)},r.on("nodeAdded",this.handleGraphUpdate),r.on("edgeAdded",this.handleGraphUpdate),r.on("nodeDropped",this.handleGraphUpdate),r.on("edgeDropped",this.handleGraphUpdate),this.spawnWorker()}ei.prototype.isRunning=function(){return this.running};ei.prototype.spawnWorker=function(){this.worker&&this.worker.terminate(),this.worker=Ni.createWorker(tI),this.worker.addEventListener("message",this.handleMessage),this.running&&(this.running=!1,this.start())};ei.prototype.handleMessage=function(r){if(this.running){var e=new Float32Array(r.data.nodes);Ni.assignLayoutChanges(this.graph,e,this.outputReducer),this.outputReducer&&Ni.readGraphPositions(this.graph,e),this.matrices.nodes=e,this.askForIterations()}};ei.prototype.askForIterations=function(r){var e=this.matrices,t={settings:this.settings,nodes:e.nodes.buffer},i=[e.nodes.buffer];return r&&(t.edges=e.edges.buffer,i.push(e.edges.buffer)),this.worker.postMessage(t,i),this};ei.prototype.start=function(){if(this.killed)throw new Error("graphology-layout-forceatlas2/worker.start: layout was killed.");return this.running?this:(this.matrices=Ni.graphToByteArrays(this.graph,this.getEdgeWeight),this.running=!0,this.askForIterations(!0),this)};ei.prototype.stop=function(){return this.running=!1,this};ei.prototype.kill=function(){if(this.killed)return this;this.running=!1,this.killed=!0,this.matrices=null,this.worker.terminate(),this.graph.removeListener("nodeAdded",this.handleGraphUpdate),this.graph.removeListener("edgeAdded",this.handleGraphUpdate),this.graph.removeListener("nodeDropped",this.handleGraphUpdate),this.graph.removeListener("edgeDropped",this.handleGraphUpdate)};Op.exports=ei});var Dp=De((OC,Mp)=>{var xn=0,Sn=1,ro=2,In=3;function sI(r,e){return r+"\xA7"+e}function Lp(){return .01*(.5-Math.random())}Mp.exports=function(e,t){var i=e.margin,n=e.ratio,o=e.expansion,s=e.gridSize,a=e.speed,h,f,l,g,m,_,E=!0,q=t.length,x=q/In|0,A=new Float32Array(x),S=new Float32Array(x),I=1/0,M=1/0,D=-1/0,z=-1/0;for(h=0;h1&&W.has(Xe))&&(oe>1&&W.add(Xe),Ye=t[le+xn],wr=t[le+Sn],qr=t[le+ro],Ae=Ye-de,ze=wr-Be,be=Math.sqrt(Ae*Ae+ze*ze),sr=be0?(A[le]+=Ae/be*(1+er),S[le]+=ze/be*(1+er)):(A[le]+=O*Lp(),S[le]+=N*Lp())));for(h=0,f=0;h{var to=3;Fi.validateSettings=function(r){return"gridSize"in r&&typeof r.gridSize!="number"||r.gridSize<=0?{message:"the `gridSize` setting should be a positive number."}:"margin"in r&&typeof r.margin!="number"||r.margin<0?{message:"the `margin` setting should be 0 or a positive number."}:"expansion"in r&&typeof r.expansion!="number"||r.expansion<=0?{message:"the `expansion` setting should be a positive number."}:"ratio"in r&&typeof r.ratio!="number"||r.ratio<=0?{message:"the `ratio` setting should be a positive number."}:"speed"in r&&typeof r.speed!="number"||r.speed<=0?{message:"the `speed` setting should be a positive number."}:null};Fi.graphToByteArray=function(r,e){var t=r.order,i=new Float32Array(t*to),n=0;return r.forEachNode(function(o,s){typeof e=="function"&&(s=e(o,s)),i[n]=s.x,i[n+1]=s.y,i[n+2]=s.size||1,n+=to}),i};Fi.assignLayoutChanges=function(r,e,t){var i=0;r.forEachNode(function(n){var o={x:e[i],y:e[i+1]};typeof t=="function"&&(o=t(n,o)),r.mergeNodeAttributes(n,o),i+=to})};Fi.collectLayoutChanges=function(r,e,t){var i={},n=0;return r.forEachNode(function(o){var s={x:e[n],y:e[n+1]};typeof t=="function"&&(s=t(o,s)),i[o]=s,n+=to}),i};Fi.createWorker=function(e){var t=window.URL||window.webkitURL,i=e.toString(),n=t.createObjectURL(new Blob(["("+i+").call(this);"],{type:"text/javascript"})),o=new Worker(n);return t.revokeObjectURL(n),o}});var Gp=De((LC,Pp)=>{Pp.exports={gridSize:20,margin:5,expansion:1.1,ratio:1,speed:3}});var $p=De((MC,zp)=>{var aI=Or(),uI=Dp(),io=jp(),fI=Gp(),hI=500;function Np(r,e,t){if(!aI(e))throw new Error("graphology-layout-noverlap: the given graph is not a valid graphology instance.");typeof t=="number"?t={maxIterations:t}:t=t||{};var i=t.maxIterations||hI;if(typeof i!="number"||i<=0)throw new Error("graphology-layout-force: you should provide a positive number of maximum iterations.");var n=Object.assign({},fI,t.settings),o=io.validateSettings(n);if(o)throw new Error("graphology-layout-noverlap: "+o.message);var s=io.graphToByteArray(e,t.inputReducer),a=!1,h;for(h=0;h{(function(r,e){typeof Vl=="object"&&typeof Kl<"u"?Kl.exports=e():typeof define=="function"&&define.amd?define(e):(r=typeof globalThis<"u"?globalThis:r||self,r.polygonClipping=e())})(Vl,(function(){"use strict";function r(K,v){var b={label:0,sent:function(){if(P[0]&1)throw P[1];return P[1]},trys:[],ops:[]},k,G,P,te;return te={next:J(0),throw:J(1),return:J(2)},typeof Symbol=="function"&&(te[Symbol.iterator]=function(){return this}),te;function J(ne){return function(Ee){return ae([ne,Ee])}}function ae(ne){if(k)throw new TypeError("Generator is already executing.");for(;b;)try{if(k=1,G&&(P=ne[0]&2?G.return:ne[0]?G.throw||((P=G.return)&&P.call(G),0):G.next)&&!(P=P.call(G,ne[1])).done)return P;switch(G=0,P&&(ne=[ne[0]&2,P.value]),ne[0]){case 0:case 1:P=ne;break;case 4:return b.label++,{value:ne[1],done:!1};case 5:b.label++,G=ne[1],ne=[0];continue;case 7:ne=b.ops.pop(),b.trys.pop();continue;default:if(P=b.trys,!(P=P.length>0&&P[P.length-1])&&(ne[0]===6||ne[0]===2)){b=0;continue}if(ne[0]===3&&(!P||ne[1]>P[0]&&ne[1]v?1:K0){if(v.right===null)break;if(b(K,v.right.key)>0){var J=v.right;if(v.right=J.left,J.left=v,v=J,v.right===null)break}G.right=v,G=v,v=v.right}else break}return G.right=v.left,P.left=v.right,v.left=k.right,v.right=k.left,v}function n(K,v,b,k){var G=new e(K,v);if(b===null)return G.left=G.right=null,G;b=i(K,b,k);var P=k(K,b.key);return P<0?(G.left=b.left,G.right=b,b.left=null):P>=0&&(G.right=b.right,G.left=b,b.right=null),G}function o(K,v,b){var k=null,G=null;if(v){v=i(K,v,b);var P=b(v.key,K);P===0?(k=v.left,G=v.right):P<0?(G=v.right,v.right=null,k=v):(k=v.left,v.left=null,G=v)}return{left:k,right:G}}function s(K,v,b){return v===null?K:(K===null||(v=i(K.key,v,b),v.left=K),v)}function a(K,v,b,k,G){if(K){k(""+v+(b?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+G(K)+` +`);var P=v+(b?" ":"\u2502 ");K.left&&a(K.left,P,!1,k,G),K.right&&a(K.right,P,!0,k,G)}}var h=(function(){function K(v){v===void 0&&(v=t),this._root=null,this._size=0,this._comparator=v}return K.prototype.insert=function(v,b){return this._size++,this._root=n(v,b,this._root,this._comparator)},K.prototype.add=function(v,b){var k=new e(v,b);this._root===null&&(k.left=k.right=null,this._size++,this._root=k);var G=this._comparator,P=i(v,this._root,G),te=G(v,P.key);return te===0?this._root=P:(te<0?(k.left=P.left,k.right=P,P.left=null):te>0&&(k.right=P.right,k.left=P,P.right=null),this._size++,this._root=k),this._root},K.prototype.remove=function(v){this._root=this._remove(v,this._root,this._comparator)},K.prototype._remove=function(v,b,k){var G;if(b===null)return null;b=i(v,b,k);var P=k(v,b.key);return P===0?(b.left===null?G=b.right:(G=i(v,b.left,k),G.right=b.right),this._size--,G):b},K.prototype.pop=function(){var v=this._root;if(v){for(;v.left;)v=v.left;return this._root=i(v.key,this._root,this._comparator),this._root=this._remove(v.key,this._root,this._comparator),{key:v.key,data:v.data}}return null},K.prototype.findStatic=function(v){for(var b=this._root,k=this._comparator;b;){var G=k(v,b.key);if(G===0)return b;G<0?b=b.left:b=b.right}return null},K.prototype.find=function(v){return this._root&&(this._root=i(v,this._root,this._comparator),this._comparator(v,this._root.key)!==0)?null:this._root},K.prototype.contains=function(v){for(var b=this._root,k=this._comparator;b;){var G=k(v,b.key);if(G===0)return!0;G<0?b=b.left:b=b.right}return!1},K.prototype.forEach=function(v,b){for(var k=this._root,G=[],P=!1;!P;)k!==null?(G.push(k),k=k.left):G.length!==0?(k=G.pop(),v.call(b,k),k=k.right):P=!0;return this},K.prototype.range=function(v,b,k,G){for(var P=[],te=this._comparator,J=this._root,ae;P.length!==0||J;)if(J)P.push(J),J=J.left;else{if(J=P.pop(),ae=te(J.key,b),ae>0)break;if(te(J.key,v)>=0&&k.call(G,J))return this;J=J.right}return this},K.prototype.keys=function(){var v=[];return this.forEach(function(b){var k=b.key;return v.push(k)}),v},K.prototype.values=function(){var v=[];return this.forEach(function(b){var k=b.data;return v.push(k)}),v},K.prototype.min=function(){return this._root?this.minNode(this._root).key:null},K.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},K.prototype.minNode=function(v){if(v===void 0&&(v=this._root),v)for(;v.left;)v=v.left;return v},K.prototype.maxNode=function(v){if(v===void 0&&(v=this._root),v)for(;v.right;)v=v.right;return v},K.prototype.at=function(v){for(var b=this._root,k=!1,G=0,P=[];!k;)if(b)P.push(b),b=b.left;else if(P.length>0){if(b=P.pop(),G===v)return b;G++,b=b.right}else k=!0;return null},K.prototype.next=function(v){var b=this._root,k=null;if(v.right){for(k=v.right;k.left;)k=k.left;return k}for(var G=this._comparator;b;){var P=G(v.key,b.key);if(P===0)break;P<0?(k=b,b=b.left):b=b.right}return k},K.prototype.prev=function(v){var b=this._root,k=null;if(v.left!==null){for(k=v.left;k.right;)k=k.right;return k}for(var G=this._comparator;b;){var P=G(v.key,b.key);if(P===0)break;P<0?b=b.left:(k=b,b=b.right)}return k},K.prototype.clear=function(){return this._root=null,this._size=0,this},K.prototype.toList=function(){return g(this._root)},K.prototype.load=function(v,b,k){b===void 0&&(b=[]),k===void 0&&(k=!1);var G=v.length,P=this._comparator;if(k&&E(v,b,0,G-1,P),this._root===null)this._root=f(v,b,0,G),this._size=G;else{var te=_(this.toList(),l(v,b),P);G=this._size+G,this._root=m({head:te},0,G)}return this},K.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(K.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(K.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),K.prototype.toString=function(v){v===void 0&&(v=function(k){return String(k.key)});var b=[];return a(this._root,"",!0,function(k){return b.push(k)},v),b.join("")},K.prototype.update=function(v,b,k){var G=this._comparator,P=o(v,this._root,G),te=P.left,J=P.right;G(v,b)<0?J=n(b,k,J,G):te=n(b,k,te,G),this._root=s(te,J,G)},K.prototype.split=function(v){return o(v,this._root,this._comparator)},K.prototype[Symbol.iterator]=function(){var v,b,k;return r(this,function(G){switch(G.label){case 0:v=this._root,b=[],k=!1,G.label=1;case 1:return k?[3,6]:v===null?[3,2]:(b.push(v),v=v.left,[3,5]);case 2:return b.length===0?[3,4]:(v=b.pop(),[4,v]);case 3:return G.sent(),v=v.right,[3,5];case 4:k=!0,G.label=5;case 5:return[3,1];case 6:return[2]}})},K})();function f(K,v,b,k){var G=k-b;if(G>0){var P=b+Math.floor(G/2),te=K[P],J=v[P],ae=new e(te,J);return ae.left=f(K,v,b,P),ae.right=f(K,v,P+1,k),ae}return null}function l(K,v){for(var b=new e(null,null),k=b,G=0;G0?(v=P=P.next=b.pop(),v=v.right):k=!0;return P.next=null,G.next}function m(K,v,b){var k=b-v;if(k>0){var G=v+Math.floor(k/2),P=m(K,v,G),te=K.head;return te.left=P,K.head=K.head.next,te.right=m(K,G+1,b),te}return null}function _(K,v,b){for(var k=new e(null,null),G=k,P=K,te=v;P!==null&&te!==null;)b(P.key,te.key)<0?(G.next=P,P=P.next):(G.next=te,te=te.next),G=G.next;return P!==null?G.next=P:te!==null&&(G.next=te),k.next}function E(K,v,b,k,G){if(!(b>=k)){for(var P=K[b+k>>1],te=b-1,J=k+1;;){do te++;while(G(K[te],P)<0);do J--;while(G(K[J],P)>0);if(te>=J)break;var ae=K[te];K[te]=K[J],K[J]=ae,ae=v[te],v[te]=v[J],v[J]=ae}E(K,v,b,J,G),E(K,v,J+1,k,G)}}let q=(K,v)=>K.ll.x<=v.x&&v.x<=K.ur.x&&K.ll.y<=v.y&&v.y<=K.ur.y,x=(K,v)=>{if(v.ur.x{if(-Ane==Ee>-ne?(P=ne,ne=v[++Q]):(P=Ee,Ee=k[++fe]);let ve=0;if(Qne==Ee>-ne?(te=ne+P,J=P-(te-ne),ne=v[++Q]):(te=Ee+P,J=P-(te-Ee),Ee=k[++fe]),P=te,J!==0&&(G[ve++]=J);Qne==Ee>-ne?(te=P+ne,ae=te-P,J=P-(te-ae)+(ne-ae),ne=v[++Q]):(te=P+Ee,ae=te-P,J=P-(te-ae)+(Ee-ae),Ee=k[++fe]),P=te,J!==0&&(G[ve++]=J);for(;Q=H||-ce>=H||(Q=K-L,J=K-(L+Q)+(Q-G),Q=b-V,ne=b-(V+Q)+(Q-G),Q=v-F,ae=v-(F+Q)+(Q-P),Q=k-ee,Ee=k-(ee+Q)+(Q-P),J===0&&ae===0&&ne===0&&Ee===0)||(H=Te*te+j*Math.abs(ce),ce+=L*Ee+ee*J-(F*ne+V*ae),ce>=H||-ce>=H))return ce;d=J*ee,fe=N*J,ve=fe-(fe-J),Ce=J-ve,fe=N*ee,Me=fe-(fe-ee),w=ee-Me,y=Ce*w-(d-ve*Me-Ce*Me-ve*w),R=ae*V,fe=N*ae,ve=fe-(fe-ae),Ce=ae-ve,fe=N*V,Me=fe-(fe-V),w=V-Me,C=Ce*w-(R-ve*Me-Ce*Me-ve*w),p=y-C,Q=y-p,Ze[0]=y-(p+Q)+(Q-C),c=d+p,Q=c-d,u=d-(c-Q)+(p-Q),p=u-R,Q=u-p,Ze[1]=u-(p+Q)+(Q-R),T=c+p,Q=T-c,Ze[2]=c-(T-Q)+(p-Q),Ze[3]=T;let se=X(4,Ne,4,Ze,Oe);d=L*Ee,fe=N*L,ve=fe-(fe-L),Ce=L-ve,fe=N*Ee,Me=fe-(fe-Ee),w=Ee-Me,y=Ce*w-(d-ve*Me-Ce*Me-ve*w),R=F*ne,fe=N*F,ve=fe-(fe-F),Ce=F-ve,fe=N*ne,Me=fe-(fe-ne),w=ne-Me,C=Ce*w-(R-ve*Me-Ce*Me-ve*w),p=y-C,Q=y-p,Ze[0]=y-(p+Q)+(Q-C),c=d+p,Q=c-d,u=d-(c-Q)+(p-Q),p=u-R,Q=u-p,Ze[1]=u-(p+Q)+(Q-R),T=c+p,Q=T-c,Ze[2]=c-(T-Q)+(p-Q),Ze[3]=T;let qe=X(se,Oe,4,Ze,B);d=J*Ee,fe=N*J,ve=fe-(fe-J),Ce=J-ve,fe=N*Ee,Me=fe-(fe-Ee),w=Ee-Me,y=Ce*w-(d-ve*Me-Ce*Me-ve*w),R=ae*ne,fe=N*ae,ve=fe-(fe-ae),Ce=ae-ve,fe=N*ne,Me=fe-(fe-ne),w=ne-Me,C=Ce*w-(R-ve*Me-Ce*Me-ve*w),p=y-C,Q=y-p,Ze[0]=y-(p+Q)+(Q-C),c=d+p,Q=c-d,u=d-(c-Q)+(p-Q),p=u-R,Q=u-p,Ze[1]=u-(p+Q)+(Q-R),T=c+p,Q=T-c,Ze[2]=c-(T-Q)+(p-Q),Ze[3]=T;let $=X(qe,B,4,Ze,pr);return pr[$-1]}function U(K,v,b,k,G,P){let te=(v-P)*(b-G),J=(K-G)*(k-P),ae=te-J,ne=Math.abs(te+J);return Math.abs(ae)>=me*ne?ae:-ge(K,v,b,k,G,P,ne)}let Ge=(K,v)=>K.x*v.y-K.y*v.x,Z=(K,v)=>K.x*v.x+K.y*v.y,W=(K,v,b)=>{let k=U(K.x,K.y,v.x,v.y,b.x,b.y);return k>0?-1:k<0?1:0},ue=K=>Math.sqrt(Z(K,K)),le=(K,v,b)=>{let k={x:v.x-K.x,y:v.y-K.y},G={x:b.x-K.x,y:b.y-K.y};return Ge(G,k)/ue(G)/ue(k)},de=(K,v,b)=>{let k={x:v.x-K.x,y:v.y-K.y},G={x:b.x-K.x,y:b.y-K.y};return Z(G,k)/ue(G)/ue(k)},Ye=(K,v,b)=>v.y===0?null:{x:K.x+v.x/v.y*(b-K.y),y:b},Be=(K,v,b)=>v.x===0?null:{x:b,y:K.y+v.y/v.x*(b-K.x)},wr=(K,v,b,k)=>{if(v.x===0)return Be(b,k,K.x);if(k.x===0)return Be(K,v,b.x);if(v.y===0)return Ye(b,k,K.y);if(k.y===0)return Ye(K,v,b.y);let G=Ge(v,k);if(G==0)return null;let P={x:b.x-K.x,y:b.y-K.y},te=Ge(P,v)/G,J=Ge(P,k)/G,ae=K.x+J*v.x,ne=b.x+te*k.x,Ee=K.y+J*v.y,Q=b.y+te*k.y,fe=(ae+ne)/2,ve=(Ee+Q)/2;return{x:fe,y:ve}};class er{static compare(v,b){let k=er.comparePoints(v.point,b.point);return k!==0?k:(v.point!==b.point&&v.link(b),v.isLeft!==b.isLeft?v.isLeft?1:-1:Xe.compare(v.segment,b.segment))}static comparePoints(v,b){return v.xb.x?1:v.yb.y?1:0}constructor(v,b){v.events===void 0?v.events=[this]:v.events.push(this),this.point=v,this.isLeft=b}link(v){if(v.point===this.point)throw new Error("Tried to link already linked events");let b=v.point.events;for(let k=0,G=b.length;k{let P=G.otherSE;b.set(G,{sine:le(this.point,v.point,P.point),cosine:de(this.point,v.point,P.point)})};return(G,P)=>{b.has(G)||k(G),b.has(P)||k(P);let{sine:te,cosine:J}=b.get(G),{sine:ae,cosine:ne}=b.get(P);return te>=0&&ae>=0?Jne?-1:0:te<0&&ae<0?Jne?1:0:aete?1:0}}}let qr=0;class Xe{static compare(v,b){let k=v.leftSE.point.x,G=b.leftSE.point.x,P=v.rightSE.point.x,te=b.rightSE.point.x;if(teJ&&ae>ne)return-1;let Q=v.comparePoint(b.leftSE.point);if(Q<0)return 1;if(Q>0)return-1;let fe=b.comparePoint(v.rightSE.point);return fe!==0?fe:-1}if(k>G){if(Jae&&J>Ee)return 1;let Q=b.comparePoint(v.leftSE.point);if(Q!==0)return Q;let fe=v.comparePoint(b.rightSE.point);return fe<0?1:fe>0?-1:1}if(Jae)return 1;if(Pte){let Q=v.comparePoint(b.rightSE.point);if(Q<0)return 1;if(Q>0)return-1}if(P!==te){let Q=ne-J,fe=P-k,ve=Ee-ae,Ce=te-G;if(Q>fe&&veCe)return-1}return P>te?1:PEe?1:v.idb.id?1:0}constructor(v,b,k,G){this.id=++qr,this.leftSE=v,v.segment=this,v.otherSE=b,this.rightSE=b,b.segment=this,b.otherSE=v,this.rings=k,this.windings=G}static fromRing(v,b,k){let G,P,te,J=er.comparePoints(v,b);if(J<0)G=v,P=b,te=1;else if(J>0)G=b,P=v,te=-1;else throw new Error(`Tried to create degenerate segment at [${v.x}, ${v.y}]`);let ae=new er(G,!0),ne=new er(P,!1);return new Xe(ae,ne,[k],[te])}replaceRightSE(v){this.rightSE=v,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let v=this.leftSE.point.y,b=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:vb?v:b}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(v){return v.x===this.leftSE.point.x&&v.y===this.leftSE.point.y||v.x===this.rightSE.point.x&&v.y===this.rightSE.point.y}comparePoint(v){if(this.isAnEndpoint(v))return 0;let b=this.leftSE.point,k=this.rightSE.point,G=this.vector();if(b.x===k.x)return v.x===b.x?0:v.x0&&J.swapEvents(),er.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),k&&(G.checkForConsuming(),P.checkForConsuming()),b}swapEvents(){let v=this.rightSE;this.rightSE=this.leftSE,this.leftSE=v,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let b=0,k=this.windings.length;b0){let P=b;b=k,k=P}if(b.prev===k){let P=b;b=k,k=P}for(let P=0,te=k.rings.length;PG.length===1&&G[0].isSubject;this._isInResult=k(v)!==k(b);break}default:throw new Error(`Unrecognized operation type found ${cr.type}`)}return this._isInResult}}class Ae{constructor(v,b,k){if(!Array.isArray(v)||v.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=b,this.isExterior=k,this.segments=[],typeof v[0][0]!="number"||typeof v[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let G=z.round(v[0][0],v[0][1]);this.bbox={ll:{x:G.x,y:G.y},ur:{x:G.x,y:G.y}};let P=G;for(let te=1,J=v.length;tethis.bbox.ur.x&&(this.bbox.ur.x=ae.x),ae.y>this.bbox.ur.y&&(this.bbox.ur.y=ae.y),P=ae)}(G.x!==P.x||G.y!==P.y)&&this.segments.push(Xe.fromRing(P,G,this))}getSweepEvents(){let v=[];for(let b=0,k=this.segments.length;bthis.bbox.ur.x&&(this.bbox.ur.x=P.bbox.ur.x),P.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=P.bbox.ur.y),this.interiorRings.push(P)}this.multiPoly=b}getSweepEvents(){let v=this.exteriorRing.getSweepEvents();for(let b=0,k=this.interiorRings.length;bthis.bbox.ur.x&&(this.bbox.ur.x=P.bbox.ur.x),P.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=P.bbox.ur.y),this.polys.push(P)}this.isSubject=b}getSweepEvents(){let v=[];for(let b=0,k=this.polys.length;b0&&(v=te)}let b=v.segment.prevInResult(),k=b?b.prevInResult():null;for(;;){if(!b)return null;if(!k)return b.ringOut;if(k.ringOut!==b.ringOut)return k.ringOut.enclosingRing()!==b.ringOut?b.ringOut:b.ringOut.enclosingRing();b=k.prevInResult(),k=b?b.prevInResult():null}}}class Se{constructor(v){this.exteriorRing=v,v.poly=this,this.interiorRings=[]}addInterior(v){this.interiorRings.push(v),v.poly=this}getGeom(){let v=[this.exteriorRing.getGeom()];if(v[0]===null)return null;for(let b=0,k=this.interiorRings.length;b1&&arguments[1]!==void 0?arguments[1]:Xe.compare;this.queue=v,this.tree=new h(b),this.segments=[]}process(v){let b=v.segment,k=[];if(v.consumedBy)return v.isLeft?this.queue.remove(v.otherSE):this.tree.remove(b),k;let G=v.isLeft?this.tree.add(b):this.tree.find(b);if(!G)throw new Error(`Unable to find segment #${b.id} [${b.leftSE.point.x}, ${b.leftSE.point.y}] -> [${b.rightSE.point.x}, ${b.rightSE.point.y}] in SweepLine tree.`);let P=G,te=G,J,ae;for(;J===void 0;)P=this.tree.prev(P),P===null?J=null:P.key.consumedBy===void 0&&(J=P.key);for(;ae===void 0;)te=this.tree.next(te),te===null?ae=null:te.key.consumedBy===void 0&&(ae=te.key);if(v.isLeft){let ne=null;if(J){let Q=J.getIntersection(b);if(Q!==null&&(b.isAnEndpoint(Q)||(ne=Q),!J.isAnEndpoint(Q))){let fe=this._splitSafely(J,Q);for(let ve=0,Ce=fe.length;ve0?(this.tree.remove(b),k.push(v)):(this.segments.push(b),b.prev=J)}else{if(J&&ae){let ne=J.getIntersection(ae);if(ne!==null){if(!J.isAnEndpoint(ne)){let Ee=this._splitSafely(J,ne);for(let Q=0,fe=Ee.length;Qtr)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let te=new ie(P),J=P.size,ae=P.pop();for(;ae;){let Q=ae.key;if(P.size===J){let ve=Q.segment;throw new Error(`Unable to pop() ${Q.isLeft?"left":"right"} SweepEvent [${Q.point.x}, ${Q.point.y}] from segment #${ve.id} [${ve.leftSE.point.x}, ${ve.leftSE.point.y}] -> [${ve.rightSE.point.x}, ${ve.rightSE.point.y}] from queue.`)}if(P.size>tr)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(te.segments.length>ar)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");let fe=te.process(Q);for(let ve=0,Ce=fe.length;ve1?v-1:0),k=1;k1?v-1:0),k=1;k1?v-1:0),k=1;k1?v-1:0),k=1;k{var _A=Or();function pn(r,e,t,i){var n=e+"Centrality";if(!_A(t))throw new Error("graphology-centrality/"+n+": the given graph is not a valid graphology instance.");if(e!=="degree"&&t.type==="undirected")throw new Error("graphology-centrality/"+n+": cannot compute "+e+" centrality on an undirected graph.");i=i||{};var o=i.nodeCentralityAttribute||n,s=t.order-1,a=t[e].bind(t);if(r){t.updateEachNodeAttributes(function(f,l){return l[o]=a(f)/s,l},{attributes:[o]});return}var h={};return t.forEachNode(function(f){h[f]=a(f)/s}),h}var y1=pn.bind(null,!1,"degree"),_1=pn.bind(null,!1,"inDegree"),v1=pn.bind(null,!1,"outDegree");y1.assign=pn.bind(null,!0,"degree");_1.assign=pn.bind(null,!0,"inDegree");v1.assign=pn.bind(null,!0,"outDegree");Os.degreeCentrality=y1;Os.inDegreeCentrality=_1;Os.outDegreeCentrality=v1});var q1=De(Yl=>{Yl.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u";Yl.SYMBOL_SUPPORT=typeof Symbol<"u"});var ks=De((XV,E1)=>{var b1=q1(),vA=b1.ARRAY_BUFFER_SUPPORT,wA=b1.SYMBOL_SUPPORT;E1.exports=function(e,t){var i,n,o,s,a;if(!e)throw new Error("obliterator/forEach: invalid iterable.");if(typeof t!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(e)||vA&&ArrayBuffer.isView(e)||typeof e=="string"||e.toString()==="[object Arguments]"){for(o=0,s=e.length;o{var qA=Math.pow(2,8)-1,bA=Math.pow(2,16)-1,EA=Math.pow(2,32)-1,xA=Math.pow(2,7)-1,SA=Math.pow(2,15)-1,IA=Math.pow(2,31)-1;$t.getPointerArray=function(r){var e=r-1;if(e<=qA)return Uint8Array;if(e<=bA)return Uint16Array;if(e<=EA)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")};$t.getSignedPointerArray=function(r){var e=r-1;return e<=xA?Int8Array:e<=SA?Int16Array:e<=IA?Int32Array:Float64Array};$t.getNumberType=function(r){return r===(r|0)?Math.sign(r)===-1?r<=127&&r>=-128?Int8Array:r<=32767&&r>=-32768?Int16Array:Int32Array:r<=255?Uint8Array:r<=65535?Uint16Array:Uint32Array:Float64Array};var AA={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};$t.getMinimalRepresentation=function(r,e){var t=null,i=0,n,o,s,a,h;for(a=0,h=r.length;ai&&(i=n,t=o);return t};$t.isTypedArray=function(r){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(r)};$t.concat=function(){var r=0,e,t,i;for(e=0,i=arguments.length;e{var x1=ks(),S1=Ei();function RA(r){return Array.isArray(r)||S1.isTypedArray(r)}function Xl(r){if(typeof r.length=="number")return r.length;if(typeof r.size=="number")return r.size}function CA(r){var e=Xl(r),t=typeof e=="number"?new Array(e):[],i=0;return x1(r,function(n){t[i++]=n}),t}function TA(r){var e=Xl(r),t=typeof e=="number"?S1.getPointerArray(e):Array,i=typeof e=="number"?new Array(e):[],n=typeof e=="number"?new t(e):[],o=0;return x1(r,function(s){i[o]=s,n[o]=o++}),[i,n]}Dn.isArrayLike=RA;Dn.guessLength=Xl;Dn.toArray=CA;Dn.toArrayWithIndices=TA});var Oi=De((JV,I1)=>{function Ut(r){if(typeof r!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=r}typeof Symbol<"u"&&(Ut.prototype[Symbol.iterator]=function(){return this});Ut.of=function(){var r=arguments,e=r.length,t=0;return new Ut(function(){return t>=e?{done:!0}:{done:!1,value:r[t++]}})};Ut.empty=function(){var r=new Ut(function(){return{done:!0}});return r};Ut.fromSequence=function(r){var e=0,t=r.length;return new Ut(function(){return e>=t?{done:!0}:{done:!1,value:r[e++]}})};Ut.is=function(r){return r instanceof Ut?!0:typeof r=="object"&&r!==null&&typeof r.next=="function"};I1.exports=Ut});var Zl=De((HV,R1)=>{var Ql=Ls(),A1=Oi();function Lr(r,e){if(arguments.length<2)throw new Error("mnemonist/fixed-deque: expecting an Array class and a capacity.");if(typeof e!="number"||e<=0)throw new Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=r,this.capacity=e,this.items=new r(this.capacity),this.clear()}Lr.prototype.clear=function(){this.start=0,this.size=0};Lr.prototype.push=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.push: deque capacity ("+this.capacity+") exceeded!");var e=this.start+this.size;return e>=this.capacity&&(e-=this.capacity),this.items[e]=r,++this.size};Lr.prototype.unshift=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var e=this.start-1;return this.start===0&&(e=this.capacity-1),this.items[e]=r,this.start=e,++this.size};Lr.prototype.pop=function(){if(this.size!==0){this.size--;var r=this.start+this.size;return r>=this.capacity&&(r-=this.capacity),this.items[r]}};Lr.prototype.shift=function(){if(this.size!==0){var r=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[r]}};Lr.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]};Lr.prototype.peekLast=function(){if(this.size!==0){var r=this.start+this.size-1;return r>=this.capacity&&(r-=this.capacity),this.items[r]}};Lr.prototype.get=function(r){if(!(this.size===0||r>=this.capacity))return r=this.start+r,r>=this.capacity&&(r-=this.capacity),this.items[r]};Lr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=this.capacity,i=this.size,n=this.start,o=0;o=t)return{done:!0};var o=r[i];return i++,n++,i===e&&(i=0),{value:o,done:!1}})};Lr.prototype.entries=function(){var r=this.items,e=this.capacity,t=this.size,i=this.start,n=0;return new A1(function(){if(n>=t)return{done:!0};var o=r[i];return i++,i===e&&(i=0),{value:[n++,o],done:!1}})};typeof Symbol<"u"&&(Lr.prototype[Symbol.iterator]=Lr.prototype.values);Lr.prototype.inspect=function(){var r=this.toArray();return r.type=this.ArrayClass.name,r.capacity=this.capacity,Object.defineProperty(r,"constructor",{value:Lr,enumerable:!1}),r};typeof Symbol<"u"&&(Lr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Lr.prototype.inspect);Lr.from=function(r,e,t){if(arguments.length<3&&(t=Ql.guessLength(r),typeof t!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var i=new Lr(e,t);if(Ql.isArrayLike(r)){var n,o;for(n=0,o=r.length;n{var C1=Oi(),Jl=Ls();function zr(r,e){if(arguments.length<2)throw new Error("mnemonist/fixed-stack: expecting an Array class and a capacity.");if(typeof e!="number"||e<=0)throw new Error("mnemonist/fixed-stack: `capacity` should be a positive number.");this.capacity=e,this.ArrayClass=r,this.items=new this.ArrayClass(this.capacity),this.clear()}zr.prototype.clear=function(){this.size=0};zr.prototype.push=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-stack.push: stack capacity ("+this.capacity+") exceeded!");return this.items[this.size++]=r,this.size};zr.prototype.pop=function(){if(this.size!==0)return this.items[--this.size]};zr.prototype.peek=function(){return this.items[this.size-1]};zr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=0,i=this.items.length;t=e)return{done:!0};var i=r[e-t-1];return t++,{value:i,done:!1}})};zr.prototype.entries=function(){var r=this.items,e=this.size,t=0;return new C1(function(){if(t>=e)return{done:!0};var i=r[e-t-1];return{value:[t++,i],done:!1}})};typeof Symbol<"u"&&(zr.prototype[Symbol.iterator]=zr.prototype.values);zr.prototype.toString=function(){return this.toArray().join(",")};zr.prototype.toJSON=function(){return this.toArray()};zr.prototype.inspect=function(){var r=this.toArray();return r.type=this.ArrayClass.name,r.capacity=this.capacity,Object.defineProperty(r,"constructor",{value:zr,enumerable:!1}),r};typeof Symbol<"u"&&(zr.prototype[Symbol.for("nodejs.util.inspect.custom")]=zr.prototype.inspect);zr.from=function(r,e,t){if(arguments.length<3&&(t=Jl.guessLength(r),typeof t!="number"))throw new Error("mnemonist/fixed-stack.from: could not guess iterable length. Please provide desired capacity as last argument.");var i=new zr(e,t);if(Jl.isArrayLike(r)){var n,o;for(n=0,o=r.length;n{var OA=function(r,e){return re?1:0},kA=function(r,e){return re?-1:0};function LA(r){return function(e,t){return r(t,e)}}function MA(r){return r===2?function(e,t){return e[0]t[0]?1:e[1]t[1]?1:0}:function(e,t){for(var i=0;it[i])return 1;i++}return 0}}jn.DEFAULT_COMPARATOR=OA;jn.DEFAULT_REVERSE_COMPARATOR=kA;jn.reverseComparator=LA;jn.createTupleComparator=MA});var P1=De((tK,j1)=>{var Ms=ks(),L1=k1(),Wt=Ls(),js=L1.DEFAULT_COMPARATOR,Hl=L1.reverseComparator;function ed(r,e,t,i){for(var n=e[i],o,s;i>t;){if(o=i-1>>1,s=e[o],r(n,s)<0){e[i]=s,i=o;continue}break}e[i]=n}function Pn(r,e,t){for(var i=e.length,n=t,o=e[t],s=2*t+1,a;s=0&&(s=a),e[t]=e[s],t=s,s=2*t+1;e[t]=o,ed(r,e,n,t)}function M1(r,e,t){e.push(t),ed(r,e,0,e.length-1)}function rd(r,e){var t=e.pop();if(e.length!==0){var i=e[0];return e[0]=t,Pn(r,e,0),i}return t}function gn(r,e,t){if(e.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var i=e[0];return e[0]=t,Pn(r,e,0),i}function D1(r,e,t){var i;return e.length!==0&&r(e[0],t)<0&&(i=e[0],e[0]=t,t=i,Pn(r,e,0)),t}function ki(r,e){for(var t=e.length,i=t>>1,n=i;--n>=0;)Pn(r,e,n)}function td(r,e){for(var t=e.length,i=0,n=new Array(t);i=t.length)return t.slice().sort(r);for(h=t.slice(0,e),ki(i,h),n=e,o=t.length;n0&&gn(i,h,t[n]);return h.sort(r)}var f=Wt.guessLength(t);return f!==null&&f0&&gn(i,h,l)),n++}),h.length>n&&(h.length=n),h.sort(r)}function jA(r,e,t){arguments.length===2&&(t=e,e=r,r=js);var i=Hl(r),n,o,s,a=-1/0,h;if(e===1){if(Wt.isArrayLike(t)){for(n=0,o=t.length;n0)&&(a=s);return h=new t.constructor(1),h[0]=a,h}return Ms(t,function(l){(a===-1/0||r(l,a)>0)&&(a=l)}),[a]}if(Wt.isArrayLike(t)){if(e>=t.length)return t.slice().sort(i);for(h=t.slice(0,e),ki(r,h),n=e,o=t.length;n0&&gn(r,h,t[n]);return h.sort(i)}var f=Wt.guessLength(t);return f!==null&&f0&&gn(r,h,l)),n++}),h.length>n&&(h.length=n),h.sort(i)}function nr(r){if(this.clear(),this.comparator=r||js,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}nr.prototype.clear=function(){this.items=[],this.size=0};nr.prototype.push=function(r){return M1(this.comparator,this.items,r),++this.size};nr.prototype.peek=function(){return this.items[0]};nr.prototype.pop=function(){return this.size!==0&&this.size--,rd(this.comparator,this.items)};nr.prototype.replace=function(r){return gn(this.comparator,this.items,r)};nr.prototype.pushpop=function(r){return D1(this.comparator,this.items,r)};nr.prototype.consume=function(){return this.size=0,td(this.comparator,this.items)};nr.prototype.toArray=function(){return td(this.comparator,this.items.slice())};nr.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:nr,enumerable:!1}),r};typeof Symbol<"u"&&(nr.prototype[Symbol.for("nodejs.util.inspect.custom")]=nr.prototype.inspect);function Ds(r){if(this.clear(),this.comparator=r||js,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=Hl(this.comparator)}Ds.prototype=nr.prototype;nr.from=function(r,e){var t=new nr(e),i;return Wt.isArrayLike(r)?i=r.slice():i=Wt.toArray(r),ki(t.comparator,i),t.items=i,t.size=i.length,t};Ds.from=function(r,e){var t=new Ds(e),i;return Wt.isArrayLike(r)?i=r.slice():i=Wt.toArray(r),ki(t.comparator,i),t.items=i,t.size=i.length,t};nr.siftUp=Pn;nr.siftDown=ed;nr.push=M1;nr.pop=rd;nr.replace=gn;nr.pushpop=D1;nr.heapify=ki;nr.consume=td;nr.nsmallest=DA;nr.nlargest=jA;nr.MinHeap=nr;nr.MaxHeap=Ds;j1.exports=nr});var Nn=De(id=>{var Ps=Ei(),PA=Gi().createEdgeWeightGetter;function G1(r,e){return r==="outbound"||r==="inbound"?e.directedSize+e.undirectedSize*2:r==="in"||r==="out"||r==="directed"?e.directedSize:e.undirectedSize*2}function Qt(r,e){e=e||"outbound";var t=r[e+"Neighbors"].bind(r),i=G1(e,r),n=Ps.getPointerArray(i),o=Ps.getPointerArray(r.order);this.graph=r,this.neighborhood=new o(i),this.starts=new n(r.order+1),this.nodes=r.nodes();var s={},a,h,f,l,g,m,_=0;for(a=0,h=r.order;a{var GA=Zl(),N1=O1(),NA=P1(),F1=Ei(),z1=Nn(),FA=z1.NeighborhoodIndex,zA=z1.WeightedNeighborhoodIndex;nd.createUnweightedIndexedBrandes=function(e){var t=new FA(e),i=t.neighborhood,n=t.starts,o=e.order,s=new N1(F1.getPointerArray(o),o),a=new Uint32Array(o),h=new Array(o),f=new Int32Array(o),l=new GA(Uint32Array,o),g=function(m){var _,E,q,x,A,S,I;for(S=0;Se[0]?1:r[0]e[1]?1:r[1]e[2]?1:r[2]e[3]?1:r[3]{var UA=Or(),U1=$1(),WA=_t(),BA=U1.createUnweightedIndexedBrandes,VA=U1.createDijkstraIndexedBrandes,KA={nodeCentralityAttribute:"betweennessCentrality",getEdgeWeight:"weight",normalized:!0};function W1(r,e,t){if(!UA(e))throw new Error("graphology-centrality/beetweenness-centrality: the given graph is not a valid graphology instance.");t=WA(t,KA);var i=t.nodeCentralityAttribute,n=t.normalized,o=t.getEdgeWeight?VA(e,t.getEdgeWeight):BA(e),s=e.order,a,h,f,l,g,m,_,E,q,x,A=new Float64Array(s),S=new Float64Array(s);for(m=0;m{var YA=Oi(),XA=Ei().getPointerArray;function pt(r){var e=XA(r);this.size=0,this.length=r,this.dense=new e(r),this.sparse=new e(r)}pt.prototype.clear=function(){this.size=0};pt.prototype.has=function(r){var e=this.sparse[r];return e=this.size||this.dense[e]!==r?!1:(e=this.dense[this.size-1],this.dense[this.sparse[r]]=e,this.sparse[e]=this.sparse[r],this.size--,!0)};pt.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t,i=0;i{var QA=Or(),ZA=_t(),JA=Zl(),HA=X1(),eR=Nn().NeighborhoodIndex,rR={nodeCentralityAttribute:"closenessCentrality",wassermanFaust:!1};function Q1(r){this.index=new eR(r,"inbound"),this.queue=new JA(Array,r.order),this.seen=new HA(r.order)}Q1.prototype.fromNode=function(r){var e=this.index,t=this.queue,i=this.seen;i.clear(),t.clear(),i.add(r),t.push([r,0]);for(var n,o,s,a,h,f,l=0,g=0;t.size!==0;)for(n=t.shift(),o=n[0],s=n[1],s!==0&&(l+=s,g+=1),h=e.starts[o+1],a=e.starts[o];a0&&o>1&&(l=h/f,i&&(l*=h/(o-1))),g[s]=l;return r?n.index.assign(t.nodeCentralityAttribute,g):n.index.collect(g)}var J1=Z1.bind(null,!1);J1.assign=Z1.bind(null,!0);H1.exports=J1});var nE=De((uK,iE)=>{var tR=Or(),iR=_t(),nR=Nn().WeightedNeighborhoodIndex,oR={nodeCentralityAttribute:"eigenvectorCentrality",getEdgeWeight:"weight",maxIterations:100,tolerance:1e-6};function sR(r){for(var e=0,t=0,i=0,n=r.length;ie&&(t*=e/o*(e/o),e=o),t+=o===0&&e===0?0:o/e*(o/e)}return e===1/0?1:e*Math.sqrt(t)}function rE(r,e,t){if(!tR(e))throw new Error("graphology-metrics/centrality/eigenvector: the given graph is not a valid graphology instance.");t=iR(t,oR);var i=t.maxIterations,n=t.tolerance,o=e.order,s=new nR(e,t.getEdgeWeight),a,h,f,l,g=new Float64Array(e.order);for(a=0;a{var aR=Or(),uR=_t(),fR=Nn().WeightedNeighborhoodIndex,hR={nodePagerankAttribute:"pagerank",getEdgeWeight:"weight",alpha:.85,maxIterations:100,tolerance:1e-6};function oE(r,e,t){if(!aR(e))throw new Error("graphology-metrics/centrality/pagerank: the given graph is not a valid graphology instance.");t=uR(t,hR);var i=t.alpha,n=t.maxIterations,o=t.tolerance,s=t.nodePagerankAttribute,a=e.order,h=1/a,f=new fR(e,t.getEdgeWeight),l,g,m,_,E=new Float64Array(e.order),q=new Float64Array(f.weights.length),x=[];for(l=0;l{var cR=Or();fE.exports=function(e){if(!cR(e))throw new Error("graphology-metrics/simple-size: the given graph is not a valid graphology instance.");if(!e.multi)return e.size;var t=0,i=0;function n(){t++}function o(){i++}return e.forEachNode(function(s){e.type!=="directed"&&e.forEachUndirectedNeighbor(s,n),e.type!=="undirected"&&e.forEachOutNeighbor(s,o)}),t/2+i}});var cE=De(Zt=>{var lR=Or(),dR=hE();function pR(r,e){return 2*e/(r*(r-1))}function gR(r,e){return e/(r*(r-1))}function mR(r,e){var t=r*(r-1);return e/(t+t/2)}function xi(r,e,t){var i,n;if(arguments.length>3){if(i=t,n=arguments[3],typeof i!="number"||i<0)throw new Error("graphology-metrics/density: given order is not a valid number.");if(typeof n!="number"||n<0)throw new Error("graphology-metrics/density: given size is not a valid number.")}else{if(!lR(t))throw new Error("graphology-metrics/density: given graph is not a valid graphology instance.");i=t.order,n=t.size,t.multi&&e===!1&&(n=dR(t))}if(i<2)return 0;r===null&&(r=t.type),e===null&&(e=t.multi);var o;return r==="undirected"?o=pR:r==="directed"?o=gR:o=mR,o(i,n)}Zt.abstractDensity=xi;Zt.density=xi.bind(null,null,null);Zt.directedDensity=xi.bind(null,"directed",!1);Zt.undirectedDensity=xi.bind(null,"undirected",!1);Zt.mixedDensity=xi.bind(null,"mixed",!1);Zt.multiDirectedDensity=xi.bind(null,"directed",!0);Zt.multiUndirectedDensity=xi.bind(null,"undirected",!0);Zt.multiMixedDensity=xi.bind(null,"mixed",!0)});var pE=De((lK,dE)=>{var lE=Oi(),yR=ks();function Mr(){this.clear()}Mr.prototype.clear=function(){this.items=[],this.offset=0,this.size=0};Mr.prototype.enqueue=function(r){return this.items.push(r),++this.size};Mr.prototype.dequeue=function(){if(this.size){var r=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,r}};Mr.prototype.peek=function(){if(this.size)return this.items[this.offset]};Mr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=this.offset,i=0,n=this.items.length;t=r.length)return{done:!0};var t=r[e];return e++,{value:t,done:!1}})};Mr.prototype.entries=function(){var r=this.items,e=this.offset,t=0;return new lE(function(){if(e>=r.length)return{done:!0};var i=r[e];return e++,{value:[t++,i],done:!1}})};typeof Symbol<"u"&&(Mr.prototype[Symbol.iterator]=Mr.prototype.values);Mr.prototype.toString=function(){return this.toArray().join(",")};Mr.prototype.toJSON=function(){return this.toArray()};Mr.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:Mr,enumerable:!1}),r};typeof Symbol<"u"&&(Mr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Mr.prototype.inspect);Mr.from=function(r){var e=new Mr;return yR(r,function(t){e.enqueue(t)}),e};Mr.of=function(){return Mr.from(arguments)};dE.exports=Mr});var mE=De((dK,gE)=>{gE.exports=function(e,t){var i=t.length;if(i!==0){var n=e.length;e.length+=i;for(var o=0;o{var od=Or(),_R=pE(),vR=mE();function wR(r,e,t){if(!od(r))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(!r.hasNode(e))throw new Error('graphology-shortest-path: the "'+e+'" source node does not exist in the given graph.');if(!r.hasNode(t))throw new Error('graphology-shortest-path: the "'+t+'" target node does not exist in the given graph.');if(e=""+e,t=""+t,e===t)return[e];var i=r.inboundNeighbors.bind(r),n=r.outboundNeighbors.bind(r),o={},s={};o[e]=null,s[t]=null;var a=[e],h=[t],f,l,g,m,_,E,q,x,A=!1;e:for(;a.length&&h.length;)if(a.length<=h.length){for(f=a,a=[],_=0,q=f.length;_{var SR=Or(),IR=sd().singleSourceLength;_E.exports=function(e,t){if(!SR(e))throw new Error("graphology-metrics/eccentricity: given graph is not a valid graphology instance.");if(e.size===0)return 1/0;var i=-1/0,n=IR(e,t),o,s,a=0;for(o in n)s=n[o],s>i&&(i=s),a++;return a{var AR=Or(),RR=vE();wE.exports=function(e){if(!AR(e))throw new Error("graphology-metrics/diameter: given graph is not a valid graphology instance.");if(e.size===0)return 1/0;var t=-1/0;return e.someNode(function(i){var n=RR(e,i);return n>t&&(t=n),t===1/0}),t}});var ad=De((yK,bE)=>{var CR=Or();bE.exports=function(e){if(!CR(e))throw new Error("graphology-utils/infer-type: expecting a valid graphology instance.");var t=e.type;return t!=="mixed"?t:e.directedSize===0&&e.undirectedSize===0||e.directedSize>0&&e.undirectedSize>0?"mixed":e.directedSize>0?"directed":"undirected"}});var CE=De((_K,RE)=>{var EE=_t(),xE=Or(),SE=ad(),Si=Gi(),IE={getNodeCommunity:"community",getEdgeWeight:"weight",resolution:1};function TR(r,e){var t=new Array(r.order),i=new Float64Array(r.order),n={},o=0,s=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry,a=Si.createNodeValueGetter(e.getNodeCommunity).fromEntry,h=0,f={};return r.forEachNode(function(l,g){f[l]=h,t[h++]=a(l,g)}),r.forEachUndirectedEdge(function(l,g,m,_,E,q,x){var A=s(l,g,m,_,E,q,x);o+=A,n[l]=A,i[f[m]]+=A,m!==_&&(i[f[_]]+=A)}),{weights:n,communities:t,weightedDegrees:i,M:o}}function OR(r,e){var t=new Array(r.order),i=new Float64Array(r.order),n=new Float64Array(r.order),o={},s=0,a=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry,h=Si.createNodeValueGetter(e.getNodeCommunity).fromEntry,f=0,l={};return r.forEachNode(function(g,m){l[g]=f,t[f++]=h(g,m)}),r.forEachDirectedEdge(function(g,m,_,E,q,x,A){var S=a(g,m,_,E,q,x,A);s+=S,o[g]=S,n[l[_]]+=S,i[l[E]]+=S}),{weights:o,communities:t,weightedInDegrees:i,weightedOutDegrees:n,M:s}}function kR(r,e){var t=e.resolution,i=TR(r,e),n=i.communities,o=i.weightedDegrees,s=i.M,a=r.nodes(),h,f,l,g,m,_,E=0,q=s*2;for(h=0,l=r.order;h"u")throw new Error('graphology-metrics/modularity: the "'+s+'" node is not in the partition.');i[h]=0,n[h]=0}),{communities:t,totalWeights:i,internalWeights:n}}function DR(r,e){var t={},i={},n={},o={},s=Si.createNodeValueGetter(e.getNodeCommunity).fromEntry;return r.forEachNode(function(a,h){var f=s(a,h);if(t[a]=f,typeof f>"u")throw new Error('graphology-metrics/modularity: the "'+a+'" node is not in the partition.');i[f]=0,n[f]=0,o[f]=0}),{communities:t,totalInWeights:i,totalOutWeights:n,internalWeights:o}}function jR(r,e){var t=e.resolution,i=MR(r,e),n=0,o=i.totalWeights,s=i.internalWeights,a=i.communities,h=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry;r.forEachUndirectedEdge(function(m,_,E,q,x,A,S){var I=h(m,_,E,q,x,A,S);n+=I;var M=a[E],D=a[q];o[M]+=I,o[D]+=I,M===D&&(s[M]+=I*2)});var f=0,l=n*2;for(var g in s)f+=s[g]/l-Math.pow(o[g]/l,2)*t;return f}function PR(r,e){var t=e.resolution,i=DR(r,e),n=0,o=i.totalInWeights,s=i.totalOutWeights,a=i.internalWeights,h=i.communities,f=Si.createEdgeWeightGetter(e.getEdgeWeight).fromEntry;r.forEachDirectedEdge(function(m,_,E,q,x,A,S){var I=f(m,_,E,q,x,A,S);n+=I;var M=h[E],D=h[q];s[M]+=I,o[D]+=I,M===D&&(a[M]+=I)});var l=0;for(var g in a)l+=a[g]/n-o[g]*s[g]/Math.pow(n,2)*t;return l}function GR(r,e,t,i){return i/(2*r)-e*t/(2*(r*r))}function NR(r,e,t,i,n,o){return o/r-(n*e+i*t)/(r*r)}function FR(r,e){if(!xE(r))throw new Error("graphology-metrics/modularity: given graph is not a valid graphology instance.");if(r.size===0)throw new Error("graphology-metrics/modularity: cannot compute modularity of an empty graph.");if(r.multi)throw new Error("graphology-metrics/modularity: cannot compute modularity of a multi graph. Cast it to a simple one beforehand.");var t=SE(r);if(t==="mixed")throw new Error("graphology-metrics/modularity: cannot compute modularity of a mixed graph.");return e=EE(e,IE),t==="directed"?LR(r,e):kR(r,e)}function AE(r,e){if(!xE(r))throw new Error("graphology-metrics/modularity: given graph is not a valid graphology instance.");if(r.size===0)throw new Error("graphology-metrics/modularity: cannot compute modularity of an empty graph.");if(r.multi)throw new Error("graphology-metrics/modularity: cannot compute modularity of a multi graph. Cast it to a simple one beforehand.");var t=SE(r);if(t==="mixed")throw new Error("graphology-metrics/modularity: cannot compute modularity of a mixed graph.");return e=EE(e,IE),t==="directed"?PR(r,e):jR(r,e)}var Fn=AE;Fn.sparse=AE;Fn.dense=FR;Fn.undirectedDelta=GR;Fn.directedDelta=NR;RE.exports=Fn});var OE=De((vK,TE)=>{var ud=Oi(),zR=Ei().getPointerArray;function Hr(r,e){arguments.length<2&&(e=r,r=Array);var t=zR(e);this.size=0,this.length=e,this.dense=new t(e),this.sparse=new t(e),this.vals=new r(e)}Hr.prototype.clear=function(){this.size=0};Hr.prototype.has=function(r){var e=this.sparse[r];return e=this.size||this.dense[e]!==r?!1:(e=this.dense[this.size-1],this.dense[this.sparse[r]]=e,this.sparse[e]=this.sparse[r],this.size--,!0)};Hr.prototype.forEach=function(r,e){e=arguments.length>1?e:this;for(var t=0;t{var $R=Oi(),UR=Ei().getPointerArray;function gt(r){var e=UR(r);this.start=0,this.size=0,this.capacity=r,this.dense=new e(r),this.sparse=new e(r)}gt.prototype.clear=function(){this.start=0,this.size=0};gt.prototype.has=function(r){if(this.size===0)return!1;var e=this.sparse[r],t=e=this.start&&e=this.start&&e1?e:this;for(var t=this.capacity,i=this.size,n=this.start,o=0;o=t)return{done:!0};var o=r[i];return i++,n++,i===e&&(i=0),{value:o,done:!1}})};typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=gt.prototype.values);gt.prototype.inspect=function(){var r=[];return this.forEach(function(e){r.push(e)}),Object.defineProperty(r,"constructor",{value:gt,enumerable:!1}),r.capacity=this.capacity,r};typeof Symbol<"u"&&(gt.prototype[Symbol.for("nodejs.util.inspect.custom")]=gt.prototype.inspect);kE.exports=gt});var PE=De((qK,jE)=>{function ME(r){return function(e){return typeof e!="number"&&(e=e.length),Math.floor(r()*e)}}var DE=ME(Math.random);DE.createRandomIndex=ME;jE.exports=DE});var $E=De(fd=>{var Ii=Ei(),GE=_t(),NE=Gi().createEdgeWeightGetter,FE=Symbol.for("nodejs.util.inspect.custom"),zE={getEdgeWeight:"weight",keepDendrogram:!1,resolution:1};function Cr(r,e){e=GE(e,zE);var t=e.resolution,i=NE(e.getEdgeWeight).fromEntry,n=(r.size-r.selfLoopCount)*2,o=Ii.getPointerArray(n),s=Ii.getPointerArray(r.order+1),a=e.getEdgeWeight?Float64Array:Ii.getPointerArray(r.size*2);this.C=r.order,this.M=0,this.E=n,this.U=0,this.resolution=t,this.level=0,this.graph=r,this.nodes=new Array(r.order),this.keepDendrogram=e.keepDendrogram,this.neighborhood=new s(n),this.weights=new a(n),this.loops=new a(r.order),this.starts=new o(r.order+1),this.belongings=new s(r.order),this.dendrogram=[],this.mapping=null,this.counts=new s(r.order),this.unused=new s(r.order),this.totalWeights=new a(r.order);var h={},f,l=0,g=0,m=this;r.forEachNode(function(_){m.nodes[l]=_,h[_]=l,g+=r.undirectedDegreeWithoutSelfLoops(_),m.starts[l]=g,m.belongings[l]=l,m.counts[l]=1,l++}),r.forEachEdge(function(_,E,q,x,A,S,I){if(f=i(_,E,q,x,A,S,I),q=h[q],x=h[x],m.M+=f,q===x)m.totalWeights[q]+=f*2,m.loops[q]=f*2;else{m.totalWeights[q]+=f,m.totalWeights[x]+=f;var M=--m.starts[q],D=--m.starts[x];m.neighborhood[M]=x,m.neighborhood[D]=q,m.weights[M]=f,m.weights[D]=f}}),this.starts[l]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}Cr.prototype.isolate=function(r,e){var t=this.belongings[r];if(this.counts[t]===1)return t;var i=this.unused[--this.U],n=this.loops[r];return this.totalWeights[t]-=e+n,this.totalWeights[i]+=e+n,this.belongings[r]=i,this.counts[t]--,this.counts[i]++,i};Cr.prototype.move=function(r,e,t){var i=this.belongings[r],n=this.loops[r];this.totalWeights[i]-=e+n,this.totalWeights[t]+=e+n,this.belongings[r]=t;var o=this.counts[i]--===1;this.counts[t]++,o&&(this.unused[this.U++]=i)};Cr.prototype.computeNodeDegree=function(r){var e,t,i,n=0;for(e=this.starts[r],t=this.starts[r+1];e{var WR=_t(),BR=Or(),VR=ad(),UE=OE(),WE=LE(),BE=PE().createRandomIndex,VE=$E(),KR=VE.UndirectedLouvainIndex,YR=VE.DirectedLouvainIndex,KE={nodeCommunityAttribute:"community",getEdgeWeight:"weight",fastLocalMoves:!0,randomWalk:!0,resolution:1,rng:Math.random};function Gs(r,e,t){var i=r.get(e);typeof i>"u"&&(i=0),i+=t,r.set(e,i)}var XR=1e-10;function Ns(r,e,t,i,n){return Math.abs(i-n)r:i>n}function QR(r,e,t){var i=new KR(e,{getEdgeWeight:t.getEdgeWeight,keepDendrogram:r,resolution:t.resolution}),n=BE(t.rng),o=!0,s=!0,a,h,f=new UE(Float64Array,i.C),l,g,m,_,E,q,x,A,S,I,M,D,z,O,N,j,X=0,re=0,oe=[],me,_e;for(t.fastLocalMoves&&(l=new WE(i.C));o;){if(I=i.C,o=!1,s=!0,t.fastLocalMoves){for(_e=0,q=t.randomWalk?n(I):0,x=0;xr++}function Vt(){let r=arguments,e=null,t=-1;return{[Symbol.iterator](){return this},next(){let i=null;do{if(e===null){if(t++,t>=r.length)return{done:!0};e=r[t][Symbol.iterator]()}if(i=e.next(),i.done){e=null;continue}break}while(!0);return i}}}function Di(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var vn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},Ie=class r extends vn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r.prototype.constructor)}},we=class r extends vn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r.prototype.constructor)}},Pe=class r extends vn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r.prototype.constructor)}};function Cd(r,e){this.key=r,this.attributes=e,this.clear()}Cd.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Td(r,e){this.key=r,this.attributes=e,this.clear()}Td.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Od(r,e){this.key=r,this.attributes=e,this.clear()}Od.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ji(r,e,t,i,n){this.key=e,this.attributes=n,this.undirected=r,this.source=t,this.target=i}ji.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");let t=this.source.key,i=this.target.key;this.source[r][i]=this,!(this.undirected&&t===i)&&(this.target[e][t]=this)};ji.prototype.attachMulti=function(){let r="out",e="in",t=this.source.key,i=this.target.key;this.undirected&&(r=e="undirected");let n=this.source[r],o=n[i];if(typeof o>"u"){n[i]=this,this.undirected&&t===i||(this.target[e][t]=this);return}o.previous=this,this.next=o,n[i]=this,this.target[e][t]=this};ji.prototype.detach=function(){let r=this.source.key,e=this.target.key,t="out",i="in";this.undirected&&(t=i="undirected"),delete this.source[t][e],delete this.target[i][r]};ji.prototype.detachMulti=function(){let r=this.source.key,e=this.target.key,t="out",i="in";this.undirected&&(t=i="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[i][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[i][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var kd=0,Ld=1,wx=2,Md=3;function Kt(r,e,t,i,n,o,s){let a,h,f,l;if(i=""+i,t===kd){if(a=r._nodes.get(i),!a)throw new we(`Graph.${e}: could not find the "${i}" node in the graph.`);f=n,l=o}else if(t===Md){if(n=""+n,h=r._edges.get(n),!h)throw new we(`Graph.${e}: could not find the "${n}" edge in the graph.`);let g=h.source.key,m=h.target.key;if(i===g)a=h.target;else if(i===m)a=h.source;else throw new we(`Graph.${e}: the "${i}" node is not attached to the "${n}" edge (${g}, ${m}).`);f=o,l=s}else{if(h=r._edges.get(i),!h)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`);t===Ld?a=h.source:a=h.target,f=n,l=o}return[a,f,l]}function qx(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);return s.attributes[a]}}function bx(r,e,t){r.prototype[e]=function(i,n){let[o]=Kt(this,e,t,i,n);return o.attributes}}function Ex(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);return s.attributes.hasOwnProperty(a)}}function xx(r,e,t){r.prototype[e]=function(i,n,o,s){let[a,h,f]=Kt(this,e,t,i,n,o,s);return a.attributes[h]=f,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:h}),this}}function Sx(r,e,t){r.prototype[e]=function(i,n,o,s){let[a,h,f]=Kt(this,e,t,i,n,o,s);if(typeof f!="function")throw new Ie(`Graph.${e}: updater should be a function.`);let l=a.attributes,g=f(l[h]);return l[h]=g,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:h}),this}}function Ix(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function Ax(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);if(!Xr(a))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Rx(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);if(!Xr(a))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return Fr(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function Cx(r,e,t){r.prototype[e]=function(i,n,o){let[s,a]=Kt(this,e,t,i,n,o);if(typeof a!="function")throw new Ie(`Graph.${e}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}var Tx=[{name:r=>`get${r}Attribute`,attacher:qx},{name:r=>`get${r}Attributes`,attacher:bx},{name:r=>`has${r}Attribute`,attacher:Ex},{name:r=>`set${r}Attribute`,attacher:xx},{name:r=>`update${r}Attribute`,attacher:Sx},{name:r=>`remove${r}Attribute`,attacher:Ix},{name:r=>`replace${r}Attributes`,attacher:Ax},{name:r=>`merge${r}Attributes`,attacher:Rx},{name:r=>`update${r}Attributes`,attacher:Cx}];function Ox(r){Tx.forEach(function({name:e,attacher:t}){t(r,e("Node"),kd),t(r,e("Source"),Ld),t(r,e("Target"),wx),t(r,e("Opposite"),Md)})}function kx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return o.attributes[n]}}function Lx(r,e,t){r.prototype[e]=function(i){let n;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let o=""+i,s=""+arguments[1];if(n=yt(this,o,s,t),!n)throw new we(`Graph.${e}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,n=this._edges.get(i),!n)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return n.attributes}}function Mx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return o.attributes.hasOwnProperty(n)}}function Dx(r,e,t){r.prototype[e]=function(i,n,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let a=""+i,h=""+n;if(n=arguments[2],o=arguments[3],s=yt(this,a,h,t),!s)throw new we(`Graph.${e}: could not find an edge for the given path ("${a}" - "${h}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,s=this._edges.get(i),!s)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return s.attributes[n]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:n}),this}}function jx(r,e,t){r.prototype[e]=function(i,n,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let a=""+i,h=""+n;if(n=arguments[2],o=arguments[3],s=yt(this,a,h,t),!s)throw new we(`Graph.${e}: could not find an edge for the given path ("${a}" - "${h}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,s=this._edges.get(i),!s)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof o!="function")throw new Ie(`Graph.${e}: updater should be a function.`);return s.attributes[n]=o(s.attributes[n]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:n}),this}}function Px(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return delete o.attributes[n],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:n}),this}}function Gx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!Xr(n))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=n,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Nx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!Xr(n))throw new Ie(`Graph.${e}: provided attributes are not a plain object.`);return Fr(o.attributes,n),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:n}),this}}function Fx(r,e,t){r.prototype[e]=function(i,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Pe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Pe(`Graph.${e}: 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.`);let s=""+i,a=""+n;if(n=arguments[2],o=yt(this,s,a,t),!o)throw new we(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new Pe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new we(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof n!="function")throw new Ie(`Graph.${e}: provided updater is not a function.`);return o.attributes=n(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var zx=[{name:r=>`get${r}Attribute`,attacher:kx},{name:r=>`get${r}Attributes`,attacher:Lx},{name:r=>`has${r}Attribute`,attacher:Mx},{name:r=>`set${r}Attribute`,attacher:Dx},{name:r=>`update${r}Attribute`,attacher:jx},{name:r=>`remove${r}Attribute`,attacher:Px},{name:r=>`replace${r}Attributes`,attacher:Gx},{name:r=>`merge${r}Attributes`,attacher:Nx},{name:r=>`update${r}Attributes`,attacher:Fx}];function $x(r){zx.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}var Ux=[{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 Wx(r,e,t,i){let n=!1;for(let o in e){if(o===i)continue;let s=e[o];if(n=t(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),r&&n)return s.key}}function Bx(r,e,t,i){let n,o,s,a=!1;for(let h in e)if(h!==i){n=e[h];do{if(o=n.source,s=n.target,a=t(n.key,n.attributes,o.key,s.key,o.attributes,s.attributes,n.undirected),r&&a)return n.key;n=n.next}while(n!==void 0)}}function Ks(r,e){let t=Object.keys(r),i=t.length,n,o=0;return{[Symbol.iterator](){return this},next(){do if(n)n=n.next;else{if(o>=i)return{done:!0};let s=t[o++];if(s===e){n=void 0;continue}n=r[s]}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}}}function Vx(r,e,t,i){let n=e[t];if(!n)return;let o=n.source,s=n.target;if(i(n.key,n.attributes,o.key,s.key,o.attributes,s.attributes,n.undirected)&&r)return n.key}function Kx(r,e,t,i){let n=e[t];if(!n)return;let o=!1;do{if(o=i(n.key,n.attributes,n.source.key,n.target.key,n.source.attributes,n.target.attributes,n.undirected),r&&o)return n.key;n=n.next}while(n!==void 0)}function Ys(r,e){let t=r[e];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};let n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}};let i=!1;return{[Symbol.iterator](){return this},next(){return i===!0?{done:!0}:(i=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function Yx(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return Array.from(r._edges.keys());let t=e==="undirected"?r.undirectedSize:r.directedSize,i=new Array(t),n=e==="undirected",o=r._edges.values(),s=0,a,h;for(;a=o.next(),a.done!==!0;)h=a.value,h.undirected===n&&(i[s++]=h.key);return i}function Dd(r,e,t,i){if(e.size===0)return;let n=t!=="mixed"&&t!==e.type,o=t==="undirected",s,a,h=!1,f=e._edges.values();for(;s=f.next(),s.done!==!0;){if(a=s.value,n&&a.undirected!==o)continue;let{key:l,attributes:g,source:m,target:_}=a;if(h=i(l,g,m.key,_.key,m.attributes,_.attributes,a.undirected),r&&h)return l}}function Xx(r,e){if(r.size===0)return Di();let t=e!=="mixed"&&e!==r.type,i=e==="undirected",n=r._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=n.next(),o.done)return o;if(s=o.value,!(t&&s.undirected!==i))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Xs(r,e,t,i,n,o){let s=e?Bx:Wx,a;if(t!=="undirected"&&(i!=="out"&&(a=s(r,n.in,o),r&&a)||i!=="in"&&(a=s(r,n.out,o,i?void 0:n.key),r&&a))||t!=="directed"&&(a=s(r,n.undirected,o),r&&a))return a}function Qx(r,e,t,i){let n=[];return Xs(!1,r,e,t,i,function(o){n.push(o)}),n}function Zx(r,e,t){let i=Di();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(i=Vt(i,Ks(t.in))),e!=="in"&&typeof t.out<"u"&&(i=Vt(i,Ks(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(i=Vt(i,Ks(t.undirected))),i}function Qs(r,e,t,i,n,o,s){let a=t?Kx:Vx,h;if(e!=="undirected"&&(typeof n.in<"u"&&i!=="out"&&(h=a(r,n.in,o,s),r&&h)||typeof n.out<"u"&&i!=="in"&&(i||n.key!==o)&&(h=a(r,n.out,o,s),r&&h))||e!=="directed"&&typeof n.undirected<"u"&&(h=a(r,n.undirected,o,s),r&&h))return h}function Jx(r,e,t,i,n){let o=[];return Qs(!1,r,e,t,i,n,function(s){o.push(s)}),o}function Hx(r,e,t,i){let n=Di();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&i in t.in&&(n=Vt(n,Ys(t.in,i))),typeof t.out<"u"&&e!=="in"&&i in t.out&&(e||t.key!==i)&&(n=Vt(n,Ys(t.out,i)))),r!=="directed"&&typeof t.undirected<"u"&&i in t.undirected&&(n=Vt(n,Ys(t.undirected,i))),n}function eS(r,e){let{name:t,type:i,direction:n}=e;r.prototype[t]=function(o,s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];if(!arguments.length)return Yx(this,i);if(arguments.length===1){o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new we(`Graph.${t}: could not find the "${o}" node in the graph.`);return Qx(this.multi,i==="mixed"?this.type:i,n,a)}if(arguments.length===2){o=""+o,s=""+s;let a=this._nodes.get(o);if(!a)throw new we(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new we(`Graph.${t}: could not find the "${s}" target node in the graph.`);return Jx(i,this.multi,n,a,s)}throw new Ie(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function rS(r,e){let{name:t,type:i,direction:n}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(f,l,g){if(!(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)){if(arguments.length===1)return g=f,Dd(!1,this,i,g);if(arguments.length===2){f=""+f,g=l;let m=this._nodes.get(f);if(typeof m>"u")throw new we(`Graph.${o}: could not find the "${f}" node in the graph.`);return Xs(!1,this.multi,i==="mixed"?this.type:i,n,m,g)}if(arguments.length===3){f=""+f,l=""+l;let m=this._nodes.get(f);if(!m)throw new we(`Graph.${o}: could not find the "${f}" source node in the graph.`);if(!this._nodes.has(l))throw new we(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Qs(!1,i,this.multi,n,m,l,g)}throw new Ie(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){let f=Array.prototype.slice.call(arguments),l=f.pop(),g;if(f.length===0){let m=0;i!=="directed"&&(m+=this.undirectedSize),i!=="undirected"&&(m+=this.directedSize),g=new Array(m);let _=0;f.push((E,q,x,A,S,I,M)=>{g[_++]=l(E,q,x,A,S,I,M)})}else g=[],f.push((m,_,E,q,x,A,S)=>{g.push(l(m,_,E,q,x,A,S))});return this[o].apply(this,f),g};let a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){let f=Array.prototype.slice.call(arguments),l=f.pop(),g=[];return f.push((m,_,E,q,x,A,S)=>{l(m,_,E,q,x,A,S)&&g.push(m)}),this[o].apply(this,f),g};let h="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[h]=function(){let f=Array.prototype.slice.call(arguments);if(f.length<2||f.length>4)throw new Ie(`Graph.${h}: invalid number of arguments (expecting 2, 3 or 4 and got ${f.length}).`);if(typeof f[f.length-1]=="function"&&typeof f[f.length-2]!="function")throw new Ie(`Graph.${h}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l,g;f.length===2?(l=f[0],g=f[1],f=[]):f.length===3?(l=f[1],g=f[2],f=[f[0]]):f.length===4&&(l=f[2],g=f[3],f=[f[0],f[1]]);let m=g;return f.push((_,E,q,x,A,S,I)=>{m=l(m,_,E,q,x,A,S,I)}),this[o].apply(this,f),m}}function tS(r,e){let{name:t,type:i,direction:n}=e,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,f,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return!1;if(arguments.length===1)return l=h,Dd(!0,this,i,l);if(arguments.length===2){h=""+h,l=f;let g=this._nodes.get(h);if(typeof g>"u")throw new we(`Graph.${o}: could not find the "${h}" node in the graph.`);return Xs(!0,this.multi,i==="mixed"?this.type:i,n,g,l)}if(arguments.length===3){h=""+h,f=""+f;let g=this._nodes.get(h);if(!g)throw new we(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(f))throw new we(`Graph.${o}: could not find the "${f}" target node in the graph.`);return Qs(!0,i,this.multi,n,g,f,l)}throw new Ie(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let s="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){let h=Array.prototype.slice.call(arguments),f=h.pop();return h.push((g,m,_,E,q,x,A)=>f(g,m,_,E,q,x,A)),!!this[o].apply(this,h)};let a="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){let h=Array.prototype.slice.call(arguments),f=h.pop();return h.push((g,m,_,E,q,x,A)=>!f(g,m,_,E,q,x,A)),!this[o].apply(this,h)}}function iS(r,e){let{name:t,type:i,direction:n}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s,a){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return Di();if(!arguments.length)return Xx(this,i);if(arguments.length===1){s=""+s;let h=this._nodes.get(s);if(!h)throw new we(`Graph.${o}: could not find the "${s}" node in the graph.`);return Zx(i,n,h)}if(arguments.length===2){s=""+s,a=""+a;let h=this._nodes.get(s);if(!h)throw new we(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new we(`Graph.${o}: could not find the "${a}" target node in the graph.`);return Hx(i,n,h,a)}throw new Ie(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function nS(r){Ux.forEach(e=>{eS(r,e),rS(r,e),tS(r,e),iS(r,e)})}var oS=[{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 Zn(){this.A=null,this.B=null}Zn.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Zn.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function yn(r,e,t,i,n){for(let o in i){let s=i[o],a=s.source,h=s.target,f=a===t?h:a;if(e&&e.has(f.key))continue;let l=n(f.key,f.attributes);if(r&&l)return f.key}}function Zs(r,e,t,i,n){if(e!=="mixed"){if(e==="undirected")return yn(r,null,i,i.undirected,n);if(typeof t=="string")return yn(r,null,i,i[t],n)}let o=new Zn,s;if(e!=="undirected"){if(t!=="out"){if(s=yn(r,null,i,i.in,n),r&&s)return s;o.wrap(i.in)}if(t!=="in"){if(s=yn(r,o,i,i.out,n),r&&s)return s;o.wrap(i.out)}}if(e!=="directed"&&(s=yn(r,o,i,i.undirected,n),r&&s))return s}function sS(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}let i=[];return Zs(!1,r,e,t,function(n){i.push(n)}),i}function _n(r,e,t){let i=Object.keys(t),n=i.length,o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=n)return r&&r.wrap(t),{done:!0};let a=t[i[o++]],h=a.source,f=a.target;if(s=h===e?f:h,r&&r.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function aS(r,e,t){if(r!=="mixed"){if(r==="undirected")return _n(null,t,t.undirected);if(typeof e=="string")return _n(null,t,t[e])}let i=Di(),n=new Zn;return r!=="undirected"&&(e!=="out"&&(i=Vt(i,_n(n,t,t.in))),e!=="in"&&(i=Vt(i,_n(n,t,t.out)))),r!=="directed"&&(i=Vt(i,_n(n,t,t.undirected))),i}function uS(r,e){let{name:t,type:i,direction:n}=e;r.prototype[t]=function(o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new we(`Graph.${t}: could not find the "${o}" node in the graph.`);return sS(i==="mixed"?this.type:i,n,s)}}function fS(r,e){let{name:t,type:i,direction:n}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(f,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;f=""+f;let g=this._nodes.get(f);if(typeof g>"u")throw new we(`Graph.${o}: could not find the "${f}" node in the graph.`);Zs(!1,i==="mixed"?this.type:i,n,g,l)};let s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(f,l){let g=[];return this[o](f,(m,_)=>{g.push(l(m,_))}),g};let a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(f,l){let g=[];return this[o](f,(m,_)=>{l(m,_)&&g.push(m)}),g};let h="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[h]=function(f,l,g){if(arguments.length<3)throw new Ie(`Graph.${h}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let m=g;return this[o](f,(_,E)=>{m=l(m,_,E)}),m}}function hS(r,e){let{name:t,type:i,direction:n}=e,o=t[0].toUpperCase()+t.slice(1,-1),s="find"+o;r.prototype[s]=function(f,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;f=""+f;let g=this._nodes.get(f);if(typeof g>"u")throw new we(`Graph.${s}: could not find the "${f}" node in the graph.`);return Zs(!0,i==="mixed"?this.type:i,n,g,l)};let a="some"+o;r.prototype[a]=function(f,l){return!!this[s](f,l)};let h="every"+o;r.prototype[h]=function(f,l){return!this[s](f,(m,_)=>!l(m,_))}}function cS(r,e){let{name:t,type:i,direction:n}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return Di();s=""+s;let a=this._nodes.get(s);if(typeof a>"u")throw new we(`Graph.${o}: could not find the "${s}" node in the graph.`);return aS(i==="mixed"?this.type:i,n,a)}}function lS(r){oS.forEach(e=>{uS(r,e),fS(r,e),hS(r,e),cS(r,e)})}function Bn(r,e,t,i,n){let o=i._nodes.values(),s=i.type,a,h,f,l,g,m,_;for(;a=o.next(),a.done!==!0;){let E=!1;if(h=a.value,s!=="undirected"){l=h.out;for(f in l){g=l[f];do{if(m=g.target,E=!0,_=n(h.key,m.key,h.attributes,m.attributes,g.key,g.attributes,g.undirected),r&&_)return g;g=g.next}while(g)}}if(s!=="directed"){l=h.undirected;for(f in l)if(!(e&&h.key>f)){g=l[f];do{if(m=g.target,m.key!==f&&(m=g.source),E=!0,_=n(h.key,m.key,h.attributes,m.attributes,g.key,g.attributes,g.undirected),r&&_)return g;g=g.next}while(g)}}if(t&&!E&&(_=n(h.key,null,h.attributes,null,null,null,null),r&&_))return null}}function dS(r,e){let t={key:r};return Rd(e.attributes)||(t.attributes=Fr({},e.attributes)),t}function pS(r,e,t){let i={key:e,source:t.source.key,target:t.target.key};return Rd(t.attributes)||(i.attributes=Fr({},t.attributes)),r==="mixed"&&t.undirected&&(i.undirected=!0),i}function gS(r){if(!Xr(r))throw new Ie('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new Ie("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!Xr(r.attributes)||r.attributes===null))throw new Ie("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function mS(r){if(!Xr(r))throw new Ie('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new Ie("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new Ie("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!Xr(r.attributes)||r.attributes===null))throw new Ie("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new Ie("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var yS=vx(),_S=new Set(["directed","undirected","mixed"]),Sd=new Set(["domain","_events","_eventsCount","_maxListeners"]),vS=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],wS={allowSelfLoops:!0,multi:!1,type:"mixed"};function qS(r,e,t){if(t&&!Xr(t))throw new Ie(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new Pe(`Graph.addNode: the "${e}" node already exist in the graph.`);let i=new r.NodeDataClass(e,t);return r._nodes.set(e,i),r.emit("nodeAdded",{key:e,attributes:t}),i}function Id(r,e,t){let i=new r.NodeDataClass(e,t);return r._nodes.set(e,i),r.emit("nodeAdded",{key:e,attributes:t}),i}function jd(r,e,t,i,n,o,s,a){if(!i&&r.type==="undirected")throw new Pe(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(i&&r.type==="directed")throw new Pe(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!Xr(a))throw new Ie(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!r.allowSelfLoops&&o===s)throw new Pe(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=r._nodes.get(o),f=r._nodes.get(s);if(!h)throw new we(`Graph.${e}: source node "${o}" not found.`);if(!f)throw new we(`Graph.${e}: target node "${s}" not found.`);let l={key:null,undirected:i,source:o,target:s,attributes:a};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new Pe(`Graph.${e}: the "${n}" edge already exists in the graph.`);if(!r.multi&&(i?typeof h.undirected[s]<"u":typeof h.out[s]<"u"))throw new Pe(`Graph.${e}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let g=new ji(i,n,h,f,a);r._edges.set(n,g);let m=o===s;return i?(h.undirectedDegree++,f.undirectedDegree++,m&&(h.undirectedLoops++,r._undirectedSelfLoopCount++)):(h.outDegree++,f.inDegree++,m&&(h.directedLoops++,r._directedSelfLoopCount++)),r.multi?g.attachMulti():g.attach(),i?r._undirectedSize++:r._directedSize++,l.key=n,r.emit("edgeAdded",l),n}function bS(r,e,t,i,n,o,s,a,h){if(!i&&r.type==="undirected")throw new Pe(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&r.type==="directed")throw new Pe(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(h){if(typeof a!="function")throw new Ie(`Graph.${e}: invalid updater function. Expecting a function but got "${a}"`)}else if(!Xr(a))throw new Ie(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let f;if(h&&(f=a,a=void 0),!r.allowSelfLoops&&o===s)throw new Pe(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=r._nodes.get(o),g=r._nodes.get(s),m,_;if(!t&&(m=r._edges.get(n),m)){if((m.source.key!==o||m.target.key!==s)&&(!i||m.source.key!==s||m.target.key!==o))throw new Pe(`Graph.${e}: inconsistency detected when attempting to merge the "${n}" edge with "${o}" source & "${s}" target vs. ("${m.source.key}", "${m.target.key}").`);_=m}if(!_&&!r.multi&&l&&(_=i?l.undirected[s]:l.out[s]),_){let S=[_.key,!1,!1,!1];if(h?!f:!a)return S;if(h){let I=_.attributes;_.attributes=f(I),r.emit("edgeAttributesUpdated",{type:"replace",key:_.key,attributes:_.attributes})}else Fr(_.attributes,a),r.emit("edgeAttributesUpdated",{type:"merge",key:_.key,attributes:_.attributes,data:a});return S}a=a||{},h&&f&&(a=f(a));let E={key:null,undirected:i,source:o,target:s,attributes:a};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new Pe(`Graph.${e}: the "${n}" edge already exists in the graph.`);let q=!1,x=!1;l||(l=Id(r,o,{}),q=!0,o===s&&(g=l,x=!0)),g||(g=Id(r,s,{}),x=!0),m=new ji(i,n,l,g,a),r._edges.set(n,m);let A=o===s;return i?(l.undirectedDegree++,g.undirectedDegree++,A&&(l.undirectedLoops++,r._undirectedSelfLoopCount++)):(l.outDegree++,g.inDegree++,A&&(l.directedLoops++,r._directedSelfLoopCount++)),r.multi?m.attachMulti():m.attach(),i?r._undirectedSize++:r._directedSize++,E.key=n,r.emit("edgeAdded",E),[n,!0,q,x]}function Mi(r,e){r._edges.delete(e.key);let{source:t,target:i,attributes:n}=e,o=e.undirected,s=t===i;o?(t.undirectedDegree--,i.undirectedDegree--,s&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,i.inDegree--,s&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:n,source:t.key,target:i.key,undirected:o})}var fr=class r extends Ad.EventEmitter{constructor(e){if(super(),e=Fr({},wS,e),typeof e.multi!="boolean")throw new Ie(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!_S.has(e.type))throw new Ie(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new Ie(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type==="mixed"?Cd:e.type==="directed"?Td:Od;mt(this,"NodeDataClass",t);let i="geid_"+yS()+"_",n=0,o=()=>{let s;do s=i+n++;while(this._edges.has(s));return s};mt(this,"_attributes",{}),mt(this,"_nodes",new Map),mt(this,"_edges",new Map),mt(this,"_directedSize",0),mt(this,"_undirectedSize",0),mt(this,"_directedSelfLoopCount",0),mt(this,"_undirectedSelfLoopCount",0),mt(this,"_edgeKeyGenerator",o),mt(this,"_options",e),Sd.forEach(s=>mt(this,s,this[s])),Rt(this,"order",()=>this._nodes.size),Rt(this,"size",()=>this._edges.size),Rt(this,"directedSize",()=>this._directedSize),Rt(this,"undirectedSize",()=>this._undirectedSize),Rt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Rt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Rt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Rt(this,"multi",this._options.multi),Rt(this,"type",this._options.type),Rt(this,"allowSelfLoops",this._options.allowSelfLoops),Rt(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){let i=""+e,n=this._edges.get(i);return!!n&&!n.undirected}else if(arguments.length===2){e=""+e,t=""+t;let i=this._nodes.get(e);return i?i.out.hasOwnProperty(t):!1}throw new Ie(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){let i=""+e,n=this._edges.get(i);return!!n&&n.undirected}else if(arguments.length===2){e=""+e,t=""+t;let i=this._nodes.get(e);return i?i.undirected.hasOwnProperty(t):!1}throw new Ie(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasEdge(e,t){if(arguments.length===1){let i=""+e;return this._edges.has(i)}else if(arguments.length===2){e=""+e,t=""+t;let i=this._nodes.get(e);return i?typeof i.out<"u"&&i.out.hasOwnProperty(t)||typeof i.undirected<"u"&&i.undirected.hasOwnProperty(t):!1}throw new Ie(`Graph.hasEdge: invalid arity (${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.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new Pe("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let i=this._nodes.get(e);if(!i)throw new we(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new we(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let n=i.out&&i.out[t]||void 0;if(n)return n.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new Pe("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let i=this._nodes.get(e);if(!i)throw new we(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new we(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let n=i.undirected&&i.undirected[t]||void 0;if(n)return n.key}edge(e,t){if(this.multi)throw new Pe("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new we(`Graph.edge: could not find the "${t}" target node in the graph.`);let n=i.out&&i.out[t]||i.undirected&&i.undirected[t]||void 0;if(n)return n.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in||t in i.out}areOutNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.out}areInNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in i.undirected}areNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in i.in||t in i.out)||this.type!=="directed"&&t in i.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.in||this.type!=="directed"&&t in i.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;let i=this._nodes.get(e);if(!i)throw new we(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.out||this.type!=="directed"&&t in i.undirected}inDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree),i}outboundDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.outDegree),i}degree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.degree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree),i}inDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,n=0;return this.type!=="directed"&&(i+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree,n+=t.directedLoops),i-n}outboundDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,n=0;return this.type!=="directed"&&(i+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.outDegree,n+=t.directedLoops),i-n}degreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,n=0;return this.type!=="directed"&&(i+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree,n+=t.directedLoops*2),i-n}source(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;let i=this._edges.get(t);if(!i)throw new we(`Graph.opposite: could not find the "${t}" edge in the graph.`);let n=i.source.key,o=i.target.key;if(e===n)return o;if(e===o)return n;throw new we(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${n}, ${o}).`)}hasExtremity(e,t){e=""+e,t=""+t;let i=this._edges.get(e);if(!i)throw new we(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return i.source.key===t||i.target.key===t}isUndirected(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;let t=this._edges.get(e);if(!t)throw new we(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return qS(this,e,t).key}mergeNode(e,t){if(t&&!Xr(t))throw new Ie(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let i=this._nodes.get(e);return i?(t&&(Fr(i.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:i.attributes,data:t})),[e,!1]):(i=new this.NodeDataClass(e,t),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new Ie(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let i=this._nodes.get(e);if(i){if(t){let o=i.attributes;i.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:i.attributes})}return[e,!1]}let n=t?t({}):{};return i=new this.NodeDataClass(e,n),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0]}dropNode(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new we(`Graph.dropNode: could not find the "${e}" node in the graph.`);let i;if(this.type!=="undirected"){for(let n in t.out){i=t.out[n];do Mi(this,i),i=i.next;while(i)}for(let n in t.in){i=t.in[n];do Mi(this,i),i=i.next;while(i)}}if(this.type!=="directed")for(let n in t.undirected){i=t.undirected[n];do Mi(this,i),i=i.next;while(i)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let i=""+arguments[0],n=""+arguments[1];if(t=yt(this,i,n,this.type),!t)throw new we(`Graph.dropEdge: could not find the "${i}" -> "${n}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new we(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Mi(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new Pe("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Pe("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;let i=yt(this,e,t,"directed");if(!i)throw new we(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Mi(this,i),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new Pe("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Pe("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");let i=yt(this,e,t,"undirected");if(!i)throw new we(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Mi(this,i),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new Ie("Graph.updateAttribute: updater should be a function.");let i=this._attributes[e];return this._attributes[e]=t(i),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!Xr(e))throw new Ie("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!Xr(e))throw new Ie("Graph.mergeAttributes: provided attributes are not a plain object.");return Fr(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new Ie("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new Ie("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!xd(t))throw new Ie("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let i=this._nodes.values(),n,o;for(;n=i.next(),n.done!==!0;)o=n.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new Ie("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!xd(t))throw new Ie("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let i=this._edges.values(),n,o,s,a;for(;n=i.next(),n.done!==!0;)o=n.value,s=o.source,a=o.target,o.attributes=e(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new Ie("Graph.forEachAdjacencyEntry: expecting a callback.");Bn(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new Ie("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Bn(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new Ie("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Bn(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new Ie("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Bn(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new Ie("Graph.forEachNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)n=i.value,e(n.key,n.attributes)}findNode(e){if(typeof e!="function")throw new Ie("Graph.findNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)if(n=i.value,e(n.key,n.attributes))return n.key}mapNodes(e){if(typeof e!="function")throw new Ie("Graph.mapNode: expecting a callback.");let t=this._nodes.values(),i,n,o=new Array(this.order),s=0;for(;i=t.next(),i.done!==!0;)n=i.value,o[s++]=e(n.key,n.attributes);return o}someNode(e){if(typeof e!="function")throw new Ie("Graph.someNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)if(n=i.value,e(n.key,n.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new Ie("Graph.everyNode: expecting a callback.");let t=this._nodes.values(),i,n;for(;i=t.next(),i.done!==!0;)if(n=i.value,!e(n.key,n.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new Ie("Graph.filterNodes: expecting a callback.");let t=this._nodes.values(),i,n,o=[];for(;i=t.next(),i.done!==!0;)n=i.value,e(n.key,n.attributes)&&o.push(n.key);return o}reduceNodes(e,t){if(typeof e!="function")throw new Ie("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new Ie("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let i=t,n=this._nodes.values(),o,s;for(;o=n.next(),o.done!==!0;)s=o.value,i=e(i,s.key,s.attributes);return i}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let i=t.value;return{value:{node:i.key,attributes:i.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),t=0;this._nodes.forEach((n,o)=>{e[t++]=dS(o,n)});let i=new Array(this._edges.size);return t=0,this._edges.forEach((n,o)=>{i[t++]=pS(this.type,o,n)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:i}}import(e,t=!1){if(e instanceof r)return e.forEachNode((h,f)=>{t?this.mergeNode(h,f):this.addNode(h,f)}),e.forEachEdge((h,f,l,g,m,_,E)=>{t?E?this.mergeUndirectedEdgeWithKey(h,l,g,f):this.mergeDirectedEdgeWithKey(h,l,g,f):E?this.addUndirectedEdgeWithKey(h,l,g,f):this.addDirectedEdgeWithKey(h,l,g,f)}),this;if(!Xr(e))throw new Ie("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!Xr(e.attributes))throw new Ie("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let i,n,o,s,a;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new Ie("Graph.import: invalid nodes. Expecting an array.");for(i=0,n=o.length;i{let o=Fr({},i.attributes);i=new t.NodeDataClass(n,o),t._nodes.set(n,i)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new Pe(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new Pe("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new Pe("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");let t=this.emptyCopy(e),i=this._edges.values(),n,o;for(;n=i.next(),n.done!==!0;)o=n.value,jd(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Fr({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,s)=>{e[s]=o.attributes});let t={},i={};this._edges.forEach((o,s)=>{let a=o.undirected?"--":"->",h="",f=o.source.key,l=o.target.key,g;o.undirected&&f>l&&(g=f,f=l,l=g);let m=`(${f})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof i[m]>"u"?i[m]=0:i[m]++,h+=`${i[m]}. `):h+=`[${s}]: `,h+=m,t[h]=o.attributes});let n={};for(let o in this)this.hasOwnProperty(o)&&!Sd.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(n[o]=this[o]);return n.attributes=this._attributes,n.nodes=e,n.edges=t,mt(n,"constructor",this.constructor),n}};typeof Symbol<"u"&&(fr.prototype[Symbol.for("nodejs.util.inspect.custom")]=fr.prototype.inspect);vS.forEach(r=>{["add","merge","update"].forEach(e=>{let t=r.name(e),i=e==="add"?jd:bS;r.generateKey?fr.prototype[t]=function(n,o,s){return i(this,t,!0,(r.type||this.type)==="undirected",null,n,o,s,e==="update")}:fr.prototype[t]=function(n,o,s,a){return i(this,t,!1,(r.type||this.type)==="undirected",n,o,s,a,e==="update")}})});Ox(fr);$x(fr);nS(fr);lS(fr);var Vn=class extends fr{constructor(e){let t=Fr({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new Ie("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new Ie('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}},Kn=class extends fr{constructor(e){let t=Fr({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new Ie("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new Ie('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}},Yn=class extends fr{constructor(e){let t=Fr({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Ie("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}},Xn=class extends fr{constructor(e){let t=Fr({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Ie("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new Ie('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}},Qn=class extends fr{constructor(e){let t=Fr({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Ie("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new Ie('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}};function Pi(r){r.from=function(e,t){let i=Fr({},e.options,t),n=new r(i);return n.import(e),n}}Pi(fr);Pi(Vn);Pi(Kn);Pi(Yn);Pi(Xn);Pi(Qn);fr.Graph=fr;fr.DirectedGraph=Vn;fr.UndirectedGraph=Kn;fr.MultiGraph=Yn;fr.MultiDirectedGraph=Xn;fr.MultiUndirectedGraph=Qn;fr.InvalidArgumentsGraphError=Ie;fr.NotFoundGraphError=we;fr.UsageGraphError=Pe;var zs=Qr(yp(),1),JR=Qr(Rp(),1),HR=Qr(kp(),1),eC=Qr($p(),1);function st(r,e,t,i){function n(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(l){try{f(i.next(l))}catch(g){s(g)}}function h(l){try{f(i.throw(l))}catch(g){s(g)}}function f(l){l.done?o(l.value):n(l.value).then(a,h)}f((i=i.apply(r,e||[])).next())})}var cI={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow},Sr=class extends Error{constructor(e,t,i){super(e),this.position=t,this.token=i,this.name="ExpressionError"}},We;(function(r){r[r.STRING=0]="STRING",r[r.NUMBER=1]="NUMBER",r[r.BOOLEAN=2]="BOOLEAN",r[r.NULL=3]="NULL",r[r.IDENTIFIER=4]="IDENTIFIER",r[r.OPERATOR=5]="OPERATOR",r[r.FUNCTION=6]="FUNCTION",r[r.DOT=7]="DOT",r[r.BRACKET_LEFT=8]="BRACKET_LEFT",r[r.BRACKET_RIGHT=9]="BRACKET_RIGHT",r[r.PAREN_LEFT=10]="PAREN_LEFT",r[r.PAREN_RIGHT=11]="PAREN_RIGHT",r[r.COMMA=12]="COMMA",r[r.QUESTION=13]="QUESTION",r[r.COLON=14]="COLON",r[r.DOLLAR=15]="DOLLAR"})(We||(We={}));var lI=new Set([32,9,10,13]),dI=new Set([43,45,42,47,37,33,38,124,61,60,62]),pI=new Map([["true",We.BOOLEAN],["false",We.BOOLEAN],["null",We.NULL]]),ia=new Map([["===",!0],["!==",!0],["<=",!0],[">=",!0],["&&",!0],["||",!0],["+",!0],["-",!0],["*",!0],["/",!0],["%",!0],["!",!0],["<",!0],[">",!0]]),gI=new Map([[46,We.DOT],[91,We.BRACKET_LEFT],[93,We.BRACKET_RIGHT],[40,We.PAREN_LEFT],[41,We.PAREN_RIGHT],[44,We.COMMA],[63,We.QUESTION],[58,We.COLON],[36,We.DOLLAR]]),Wp=new Map;for(let[r,e]of gI.entries())Wp.set(r,{type:e,value:String.fromCharCode(r)});function An(r){return r>=48&&r<=57}function na(r){return r>=97&&r<=122||r>=65&&r<=90||r===95}function Up(r){return na(r)||An(r)}function mI(r){return dI.has(r)}var Er;(function(r){r[r.Program=0]="Program",r[r.Literal=1]="Literal",r[r.Identifier=2]="Identifier",r[r.MemberExpression=3]="MemberExpression",r[r.CallExpression=4]="CallExpression",r[r.BinaryExpression=5]="BinaryExpression",r[r.UnaryExpression=6]="UnaryExpression",r[r.ConditionalExpression=7]="ConditionalExpression"})(Er||(Er={}));var yI=new Map([["||",2],["&&",3],["===",4],["!==",4],[">",5],[">=",5],["<",5],["<=",5],["+",6],["-",6],["*",7],["/",7],["%",7],["!",8]]),_I={type:Er.Literal,value:null},vI={type:Er.Literal,value:!0},wI={type:Er.Literal,value:!1},qI=r=>{let e=0,t=r.length,i=()=>e>=t?null:r[e],n=()=>r[e++],o=g=>{let m=i();return m!==null&&m.type===g},s=g=>g.type===We.OPERATOR?yI.get(g.value)||-1:g.type===We.DOT||g.type===We.BRACKET_LEFT?9:g.type===We.QUESTION?1:-1,a=g=>{let m,_;if(n().type===We.DOT){if(!o(We.IDENTIFIER)){let q=i();throw new Sr("Expected property name",e,q?q.value:"")}let E=n();m={type:Er.Identifier,name:E.value},_=!1}else{if(m=f(0),!o(We.BRACKET_RIGHT)){let E=i();throw new Sr("Expected closing bracket",e,E?E.value:"")}n(),_=!0}return{type:Er.MemberExpression,object:g,property:m,computed:_}},h=()=>{let g=i();if(!g)throw new Sr("Unexpected end of input",e,"");if(g.type===We.OPERATOR&&(g.value==="!"||g.value==="-")){n();let m=h();return{type:Er.UnaryExpression,operator:g.value,argument:m,prefix:!0}}switch(g.type){case We.NUMBER:return n(),{type:Er.Literal,value:Number(g.value)};case We.STRING:return n(),{type:Er.Literal,value:g.value};case We.BOOLEAN:return n(),g.value==="true"?vI:wI;case We.NULL:return n(),_I;case We.IDENTIFIER:return n(),{type:Er.Identifier,name:g.value};case We.FUNCTION:return(()=>{let m=n(),_=[];if(!o(We.PAREN_LEFT)){let E=i();throw new Sr("Expected opening parenthesis after function name",e,E?E.value:"")}for(n();;){if(o(We.PAREN_RIGHT)){n();break}if(!i()){let q=i();throw new Sr("Expected closing parenthesis",e,q?q.value:"")}if(_.length>0){if(!o(We.COMMA)){let q=i();throw new Sr("Expected comma between function arguments",e,q?q.value:"")}n()}let E=f(0);_.push(E)}return{type:Er.CallExpression,callee:{type:Er.Identifier,name:m.value},arguments:_}})();case We.PAREN_LEFT:{n();let m=f(0);if(!o(We.PAREN_RIGHT)){let _=i();throw new Sr("Expected closing parenthesis",e,_?_.value:"")}return n(),m}default:throw new Sr(`Unexpected token: ${g.type}`,e,g.value)}},f=(g=0)=>{let m=h();for(;e")}n();let x=f(0);m={type:Er.ConditionalExpression,test:m,consequent:q,alternate:x}}}return m},l=f();return{type:Er.Program,body:l}},bI=(r,e,t)=>{let i=e;t&&(i={...e,context:{...e.context,...t}});let n=o=>{switch(o.type){case Er.Literal:return(s=>s.value)(o);case Er.Identifier:return(s=>{if(!(s.name in i.context))throw new Sr(`Undefined variable: ${s.name}`);return i.context[s.name]})(o);case Er.MemberExpression:return(s=>{let a=n(s.object);if(a==null)throw new Sr("Cannot access property of null or undefined");return a[s.computed?n(s.property):s.property.name]})(o);case Er.CallExpression:return(s=>{let a=i.functions[s.callee.name];if(!a)throw new Sr(`Undefined function: ${s.callee.name}`);return a(...s.arguments.map((h=>n(h))))})(o);case Er.BinaryExpression:return(s=>{if(s.operator==="&&"){let f=n(s.left);return f&&n(s.right)}if(s.operator==="||")return n(s.left)||n(s.right);let a=n(s.left),h=n(s.right);switch(s.operator){case"+":return a+h;case"-":return a-h;case"*":return a*h;case"/":return a/h;case"%":return a%h;case"===":return a===h;case"!==":return a!==h;case">":return a>h;case">=":return a>=h;case"<":return a{let a=n(s.argument);if(s.prefix)switch(s.operator){case"!":return!a;case"-":if(typeof a!="number")throw new Sr(`Cannot apply unary - to non-number: ${a}`);return-a;default:throw new Sr(`Unknown operator: ${s.operator}`)}throw new Sr(`Postfix operators are not supported: ${s.operator}`)})(o);case Er.ConditionalExpression:return(s=>{let a=n(s.test);return n(a?s.consequent:s.alternate)})(o);default:throw new Sr(`Evaluation error: Unsupported node type: ${o.type}`)}};return n(r.body)};function oa(r){let e=(n=>{let o=n,s=o.length,a=new Array(Math.ceil(s/3)),h=0,f=0;function l(x){let A=f+1;f++;let S="",I=!1;for(;f({context:n,functions:o}))({},cI);return(n={})=>bI(t,i,n)}function Bp(r,e={}){return oa(r)(e)}function Vp(r,e){if(typeof r!="string")return;let t=r.trim();if(t)try{return oa(t),Bp(t,e)}catch{return}}function ri(r){return typeof r=="number"}function zi(r){if(!r)return[0,0,0];if(ri(r))return[r,r,r];if(Array.isArray(r)&&r.length===0)return[0,0,0];let[e,t=e,i=e]=r;return[e,t,i]}function Kp(r){return ri(r)?!0:Array.isArray(r)?r.every(e=>ri(e)):!1}function tt(r){return r==null}function sa(r){return typeof r=="string"}function aa(r){return typeof r=="function"}function ti(r,e){if(typeof r=="function")return r;if(typeof r=="string"){let t=r;return(...i)=>{let n={};for(let o=0;or}function no(r,e,t="node"){if(tt(r))return()=>e;if(sa(r)){let i=ti(r,[t]);return n=>{let o=i(n);return ri(o)?o:e}}return aa(r)?r:ri(r)?()=>r:()=>e}function Rn(r,e=10,t="node"){if(tt(r))return()=>e;if(sa(r)){let i=ti(r,[t]);return n=>{let o=i(n);return Kp(o)?o:e}}return aa(r)?r:ri(r)?()=>r:Array.isArray(r)?()=>r:()=>e}var oo=(r,e,t=10,i=0)=>{let n=Rn(e,i),o=Rn(r,t);return s=>{let[a,h,f]=zi(o(s)),[l,g,m]=zi(n(s));return[a+l,h+g,f+m]}};function Yp(r){var e;return[r.x,r.y,(e=r.z)!==null&&e!==void 0?e:0]}var so=class{constructor(e,t={}){this.edgeIdCounter=new Map,this.nodeMap=SI(e.nodes,t.node),this.edgeMap=II(e.edges||[],t.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(e){this.nodeMap=e.nodes,this.edgeMap=e.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(e){return this.nodeMap.get(e)}nodeAt(e){this.indexNodeCache||this.buildNodeIndexCache();let t=this.indexNodeCache.get(e);return t?this.nodeMap.get(t):void 0}nodeIndexOf(e){var t;return this.nodeIndexCache||this.buildNodeIndexCache(),(t=this.nodeIndexCache.get(e))!==null&&t!==void 0?t:-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(e){let t=0;this.nodeMap.forEach(i=>e(i,t++))}originalNode(e){let t=this.nodeMap.get(e);return t?._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(e){return this.edgeMap.get(e)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(e){let t=0;this.edgeMap.forEach(i=>e(i,t++))}originalEdge(e){let t=this.edgeMap.get(e);return t?._original}edgeCount(){return this.edgeMap.size}getEdgeId(e){if(e.id)return e.id;let t=`${e.source}-${e.target}`,i=this.edgeIdCounter.get(t)||0,n=i===0?t:`${t}-${i}`;return this.edgeIdCounter.set(t,i+1),n}degree(e,t="both"){this.degreeCache||this.buildDegreeCache();let i=this.degreeCache.get(e);return i?i[t]:0}neighbors(e,t="both"){if((!this.outAdjacencyCache||!this.inAdjacencyCache)&&this.buildAdjacencyCache(),t==="out")return Array.from(this.outAdjacencyCache.get(e)||[]);if(t==="in")return Array.from(this.inAdjacencyCache.get(e)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(e)||[]);let i=this.inAdjacencyCache.get(e),n=this.outAdjacencyCache.get(e);if(!i&&!n)return[];if(!i)return Array.from(n);if(!n)return Array.from(i);let o=new Set;return i.forEach(s=>o.add(s)),n.forEach(s=>o.add(s)),Array.from(o)}successors(e){return this.neighbors(e,"out")}predecessors(e){return this.neighbors(e,"in")}setNodeOrder(e){let t=new Map;for(let i of e)t.set(i.id,i);this.nodeMap=t,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(let e of this.edges()){let{source:t,target:i}=e;if(e.source===e.target)continue;this.degreeCache.has(t)||this.degreeCache.set(t,{in:0,out:0,both:0});let n=this.degreeCache.get(e.source);n&&(n.out++,n.both++),this.degreeCache.has(i)||this.degreeCache.set(i,{in:0,out:0,both:0});let o=this.degreeCache.get(e.target);o&&(o.in++,o.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(let e of this.edges())!this.nodeMap.has(e.source)||!this.nodeMap.has(e.target)||(this.outAdjacencyCache.has(e.source)||this.outAdjacencyCache.set(e.source,new Set),this.outAdjacencyCache.get(e.source).add(e.target),this.inAdjacencyCache.has(e.target)||this.inAdjacencyCache.set(e.target,new Set),this.inAdjacencyCache.get(e.target).add(e.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let e=0;this.nodeMap.forEach((t,i)=>{this.nodeIndexCache.set(i,e),this.indexNodeCache.set(e,i),e++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}},EI=["id","x","y","z","vx","vy","vz","fx","fy","fz","parentId"],xI=["id","source","target","points"];function SI(r,e){if(!r)throw new Error("Data.nodes is required");let t=new Map;for(let i of r){let n={_original:i};for(let o of EI){let s=i[o];tt(s)||(n[o]=s)}if(e){let o=e(i);for(let s in o){let a=o[s];tt(a)||(n[s]=a)}}if(tt(n.id))throw new Error("Node is missing id field");t.set(n.id,n)}return t}function II(r,e,t){let i=new Map;for(let n of r){let o={_original:n};for(let s of xI){let a=n[s];tt(a)||(o[s]=a)}if(e){let s=e(n);for(let a in s){let h=s[a];tt(h)||(o[a]=h)}}if(tt(o.source)||tt(o.target))throw new Error("Edge is missing source or target field");tt(o.id)&&(o.id=t?.(n)),i.set(o.id,o)}return i}var ao=class{constructor(e,t={}){this.graph=new so(e,t)}export(){return this.graph.data()}replace(e){this.graph.replace(e)}forEachNode(e){this.graph.forEachNode(e)}forEachEdge(e){this.graph.forEachEdge((t,i)=>{t.sourceNode=this.graph.node(t.source),t.targetNode=this.graph.node(t.target),e(t,i)})}destroy(){this.graph.destroy()}};var Qp=Symbol("Comlink.proxy"),AI=Symbol("Comlink.endpoint"),RI=Symbol("Comlink.releaseProxy"),ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),Zp=r=>typeof r=="object"&&r!==null||typeof r=="function",CI={canHandle:r=>Zp(r)&&r[Qp],serialize(r){let{port1:e,port2:t}=new MessageChannel;return Hp(r,e),[t,[t]]},deserialize(r){return r.start(),ha(r)}},TI={canHandle:r=>Zp(r)&&fo in r,serialize({value:r}){let e;return r instanceof Error?e={isError:!0,value:{message:r.message,name:r.name,stack:r.stack}}:e={isError:!1,value:r},[e,[]]},deserialize(r){throw r.isError?Object.assign(new Error(r.value.message),r.value):r.value}},Jp=new Map([["proxy",CI],["throw",TI]]);function OI(r,e){for(let t of r)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Hp(r,e=globalThis,t=["*"]){e.addEventListener("message",function i(n){if(!n||!n.data)return;if(!OI(t,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}let{id:o,type:s,path:a}=Object.assign({path:[]},n.data),h=(n.data.argumentList||[]).map(Ri),f;try{let l=a.slice(0,-1).reduce((m,_)=>m[_],r),g=a.reduce((m,_)=>m[_],r);switch(s){case"GET":f=g;break;case"SET":l[a.slice(-1)[0]]=Ri(n.data.value),f=!0;break;case"APPLY":f=g.apply(l,h);break;case"CONSTRUCT":{let m=new g(...h);f=PI(m)}break;case"ENDPOINT":{let{port1:m,port2:_}=new MessageChannel;Hp(r,_),f=jI(m,[m])}break;case"RELEASE":f=void 0;break;default:return}}catch(l){f={value:l,[fo]:0}}Promise.resolve(f).catch(l=>({value:l,[fo]:0})).then(l=>{let[g,m]=lo(l);e.postMessage(Object.assign(Object.assign({},g),{id:o}),m),s==="RELEASE"&&(e.removeEventListener("message",i),eg(e),ua in r&&typeof r[ua]=="function"&&r[ua]())}).catch(l=>{let[g,m]=lo({value:new TypeError("Unserializable return value"),[fo]:0});e.postMessage(Object.assign(Object.assign({},g),{id:o}),m)})}),e.start&&e.start()}function kI(r){return r.constructor.name==="MessagePort"}function eg(r){kI(r)&&r.close()}function ha(r,e){let t=new Map;return r.addEventListener("message",function(n){let{data:o}=n;if(!o||!o.id)return;let s=t.get(o.id);if(s)try{s(o)}finally{t.delete(o.id)}}),fa(r,t,[],e)}function uo(r){if(r)throw new Error("Proxy has been released and is not useable")}function rg(r){return $i(r,new Map,{type:"RELEASE"}).then(()=>{eg(r)})}var ho=new WeakMap,co="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let e=(ho.get(r)||0)-1;ho.set(r,e),e===0&&rg(r)});function LI(r,e){let t=(ho.get(e)||0)+1;ho.set(e,t),co&&co.register(r,e,r)}function MI(r){co&&co.unregister(r)}function fa(r,e,t=[],i=function(){}){let n=!1,o=new Proxy(i,{get(s,a){if(uo(n),a===RI)return()=>{MI(o),rg(r),e.clear(),n=!0};if(a==="then"){if(t.length===0)return{then:()=>o};let h=$i(r,e,{type:"GET",path:t.map(f=>f.toString())}).then(Ri);return h.then.bind(h)}return fa(r,e,[...t,a])},set(s,a,h){uo(n);let[f,l]=lo(h);return $i(r,e,{type:"SET",path:[...t,a].map(g=>g.toString()),value:f},l).then(Ri)},apply(s,a,h){uo(n);let f=t[t.length-1];if(f===AI)return $i(r,e,{type:"ENDPOINT"}).then(Ri);if(f==="bind")return fa(r,e,t.slice(0,-1));let[l,g]=Xp(h);return $i(r,e,{type:"APPLY",path:t.map(m=>m.toString()),argumentList:l},g).then(Ri)},construct(s,a){uo(n);let[h,f]=Xp(a);return $i(r,e,{type:"CONSTRUCT",path:t.map(l=>l.toString()),argumentList:h},f).then(Ri)}});return LI(o,r),o}function DI(r){return Array.prototype.concat.apply([],r)}function Xp(r){let e=r.map(lo);return[e.map(t=>t[0]),DI(e.map(t=>t[1]))]}var tg=new WeakMap;function jI(r,e){return tg.set(r,e),r}function PI(r){return Object.assign(r,{[Qp]:!0})}function lo(r){for(let[e,t]of Jp)if(t.canHandle(r)){let[i,n]=t.serialize(r);return[{type:"HANDLER",name:e,value:i},n]}return[{type:"RAW",value:r},tg.get(r)||[]]}function Ri(r){switch(r.type){case"HANDLER":return Jp.get(r.name).deserialize(r.value);case"RAW":return r.value}}function $i(r,e,t,i){return new Promise(n=>{let o=GI();e.set(o,n),r.start&&r.start(),r.postMessage(Object.assign({id:o},t),i)})}function GI(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var po=class{constructor(){this.worker=null,this.workerApi=null}execute(e,t,i){return st(this,void 0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw new Error("Worker API not initialized");return yield this.workerApi.execute(e,t,i)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return st(this,void 0,void 0,function*(){let e=this.resolveWorkerPath(),i=e.includes("/lib/")||e.endsWith(".mjs")?"module":"classic";this.worker=new Worker(e,{type:i}),this.workerApi=ha(this.worker)})}resolveWorkerPath(){let e=(()=>{if(typeof document>"u")return null;let t=document.currentScript;if(t?.src)return t.src;let i=document.getElementsByTagName("script");for(let n=i.length-1;n>=0;n--){let o=i[n].src;if(o&&(o.includes("index.js")||o.includes("index.min.js")))return o}return null})();if(e){if(e.includes("index.js")||e.includes("index.min.js")){let n=e.replace(/index(\.min)?\.(m?js)(\?.*)?$/,"worker.js");if(n!==e)return n}let t=e.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(t!==e)return t;let i=e.replace(/\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(i!==e)return i}return"./worker.js"}};var Dt=class{constructor(e){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),e)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(e,t){return Object.assign({},e,t||{})}execute(e,t){return st(this,void 0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,t);let{node:i,edge:n,enableWorker:o}=this.runtimeOptions;this.context=new ao(e,{node:i,edge:n}),this.model=this.context.graph,o&&typeof Worker<"u"?yield this.layoutInWorker(e,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(e,t){var i;return st(this,void 0,void 0,function*(){try{this.supervisor||(this.supervisor=new po);let n=yield this.supervisor.execute(this.id,e,t);(i=this.context)===null||i===void 0||i.replace(n)}catch(n){console.error("Layout in worker failed, fallback to main thread layout.",n),yield this.layout(t)}})}forEachNode(e){this.context.forEachNode(e)}forEachEdge(e){this.context.forEachEdge(e)}destroy(){var e;(e=this.context)===null||e===void 0||e.destroy(),this.model=null,this.context=null,this.supervisor&&(this.supervisor.destroy(),this.supervisor=null)}};function ig(r){return Array.isArray(r)}function Ui(r,e,t=2){if(r.nodeCount()===1){let n=r.firstNode();n.x=e[0],n.y=e[1],t===3&&(n.z=e[2]||0)}}function ng(r,e){let t=r.nodes();return t.sort(e),r.setNodeOrder(t),r}function og(r,e="desc"){return ng(r,(t,i)=>{let n=r.degree(t.id),o=r.degree(i.id);return e==="asc"?n-o:o-n})}function sg(r,e){return ng(r,(t,i)=>{let n=r.originalNode(t.id),o=r.originalNode(i.id);return e(n,o)})}var Wi=r=>{let{width:e,height:t,center:i}=r,n=e??(typeof window<"u"?window.innerWidth:0),o=t??(typeof window<"u"?window.innerHeight:0),s=i??[n/2,o/2];return{width:n,height:o,center:s}};var go={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},mo=class extends Dt{constructor(){super(...arguments),this.id="concentric"}getDefaultOptions(){return go}layout(){return st(this,void 0,void 0,function*(){let{width:e,height:t,center:i}=Wi(this.options),n=this.model.nodeCount();if(!n||n===1){Ui(this.model,i);return}let{sortBy:o,maxLevelDiff:s,sweep:a,clockwise:h,equidistant:f,preventOverlap:l,startAngle:g=go.startAngle,nodeSize:m,nodeSpacing:_}=this.options,E=!o||o==="degree"?"degree":ti(o,["node"]);if(E==="degree")og(this.model);else{let O=(N,j)=>{let X=E(N),re=E(j);return X===re?0:X>re?-1:1};sg(this.model,O)}let q=this.model.nodes(),x=new Map;for(let O of q){let N=E==="degree"?this.model.degree(O.id):E(O._original);x.set(O.id,N)}let A=this.model.firstNode(),S=s||x.get(A.id)/4,I=oo(m,_,go.nodeSize,go.nodeSpacing),M=new Map;for(let O of q)M.set(O.id,Math.max(...I(O._original)));let D=[{nodes:[]}],z=D[0];for(let O=0;O0){let j=z.nodes[0],X=Math.abs(x.get(j.id)-x.get(N.id));S&&X>=S&&(z={nodes:[]},D.push(z))}z.nodes.push(N)}for(let O of D){let N=O.nodes.map(j=>M.get(j.id));O.nodeSizes=N,O.maxNodeSize=Math.max(...N)}if(D.forEach(O=>{let N=a===void 0?2*Math.PI-2*Math.PI/O.nodes.length:a;O.dTheta=N/Math.max(1,O.nodes.length-1)}),l){let O=0;for(let N=0;N1){let X=j.nodeSizes||[],re=0;for(let Ne=0;Ne0?re/_e:0;O=Math.max(Te,O)}if(j.r=O,N{X===0&&(N=j.r||0),j.r=N,N+=O})}D.forEach(O=>{let N=O.dTheta||0,j=O.r||0;O.nodes.forEach((X,re)=>{let oe=g+(h?1:-1)*N*re;X.x=i[0]+j*Math.cos(oe),X.y=i[1]+j*Math.sin(oe)})})})}};var ag=(function(r){var e=typeof r;return r!==null&&e==="object"||e==="function"});var ug=function(r){return typeof r=="object"&&r!==null};var NI={}.toString,yo=function(r,e){return NI.call(r)==="[object "+e+"]"};var fg=function(r){if(!ug(r)||!yo(r,"Object"))return!1;if(Object.getPrototypeOf(r)===null)return!0;for(var e=r;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e};var Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _o(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function vo(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var e=r.default;if(typeof e=="function"){var t=function i(){var n=!1;try{n=this instanceof i}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}function Bi(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ca,hg;function cg(){if(hg)return ca;hg=1;function r(){this.__data__=[],this.size=0}return ca=r,ca}var la,lg;function wt(){if(lg)return la;lg=1;function r(e,t){return e===t||e!==e&&t!==t}return la=r,la}var da,dg;function ii(){if(dg)return da;dg=1;var r=wt();function e(t,i){for(var n=t.length;n--;)if(r(t[n][0],i))return n;return-1}return da=e,da}var pa,pg;function gg(){if(pg)return pa;pg=1;var r=ii(),e=Array.prototype,t=e.splice;function i(n){var o=this.__data__,s=r(o,n);if(s<0)return!1;var a=o.length-1;return s==a?o.pop():t.call(o,s,1),--this.size,!0}return pa=i,pa}var ga,mg;function yg(){if(mg)return ga;mg=1;var r=ii();function e(t){var i=this.__data__,n=r(i,t);return n<0?void 0:i[n][1]}return ga=e,ga}var ma,_g;function vg(){if(_g)return ma;_g=1;var r=ii();function e(t){return r(this.__data__,t)>-1}return ma=e,ma}var ya,wg;function qg(){if(wg)return ya;wg=1;var r=ii();function e(t,i){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,i])):n[o][1]=i,this}return ya=e,ya}var _a,bg;function ni(){if(bg)return _a;bg=1;var r=cg(),e=gg(),t=yg(),i=vg(),n=qg();function o(s){var a=-1,h=s==null?0:s.length;for(this.clear();++a-1&&i%1==0&&i-1&&t%1==0&&t<=r}return du=e,du}var pu,Bm;function Vm(){if(Bm)return pu;Bm=1;var r=at(),e=Qi(),t=jr(),i="[object Arguments]",n="[object Array]",o="[object Boolean]",s="[object Date]",a="[object Error]",h="[object Function]",f="[object Map]",l="[object Number]",g="[object Object]",m="[object RegExp]",_="[object Set]",E="[object String]",q="[object WeakMap]",x="[object ArrayBuffer]",A="[object DataView]",S="[object Float32Array]",I="[object Float64Array]",M="[object Int8Array]",D="[object Int16Array]",z="[object Int32Array]",O="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",X="[object Uint32Array]",re={};re[S]=re[I]=re[M]=re[D]=re[z]=re[O]=re[N]=re[j]=re[X]=!0,re[i]=re[n]=re[x]=re[o]=re[A]=re[s]=re[a]=re[h]=re[f]=re[l]=re[g]=re[m]=re[_]=re[E]=re[q]=!1;function oe(me){return t(me)&&e(me.length)&&!!re[r(me)]}return pu=oe,pu}var gu,Km;function ci(){if(Km)return gu;Km=1;function r(e){return function(t){return e(t)}}return gu=r,gu}var Zi={exports:{}};Zi.exports;var Ym;function Ji(){return Ym?Zi.exports:(Ym=1,(function(r,e){var t=wo(),i=e&&!e.nodeType&&e,n=i&&!0&&r&&!r.nodeType&&r,o=n&&n.exports===i,s=o&&t.process,a=(function(){try{var h=n&&n.require&&n.require("util").types;return h||s&&s.binding&&s.binding("util")}catch{}})();r.exports=a})(Zi,Zi.exports),Zi.exports)}var mu,Xm;function Nt(){if(Xm)return mu;Xm=1;var r=Vm(),e=ci(),t=Ji(),i=t&&t.isTypedArray,n=i?e(i):r;return mu=n,mu}var yu,Qm;function Eo(){if(Qm)return yu;Qm=1;var r=Mm(),e=Gt(),t=Ve(),i=bt(),n=hi(),o=Nt(),s=Object.prototype,a=s.hasOwnProperty;function h(f,l){var g=t(f),m=!g&&e(f),_=!g&&!m&&i(f),E=!g&&!m&&!_&&o(f),q=g||m||_||E,x=q?r(f.length,String):[],A=x.length;for(var S in f)(l||a.call(f,S))&&!(q&&(S=="length"||_&&(S=="offset"||S=="parent")||E&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||n(S,A)))&&x.push(S);return x}return yu=h,yu}var _u,Zm;function li(){if(Zm)return _u;Zm=1;var r=Object.prototype;function e(t){var i=t&&t.constructor,n=typeof i=="function"&&i.prototype||r;return t===n}return _u=e,_u}var vu,Jm;function xo(){if(Jm)return vu;Jm=1;function r(e,t){return function(i){return e(t(i))}}return vu=r,vu}var wu,Hm;function ey(){if(Hm)return wu;Hm=1;var r=xo(),e=r(Object.keys,Object);return wu=e,wu}var qu,ry;function Hi(){if(ry)return qu;ry=1;var r=li(),e=ey(),t=Object.prototype,i=t.hasOwnProperty;function n(o){if(!r(o))return e(o);var s=[];for(var a in Object(o))i.call(o,a)&&a!="constructor"&&s.push(a);return s}return qu=n,qu}var bu,ty;function Wr(){if(ty)return bu;ty=1;var r=jt(),e=Qi();function t(i){return i!=null&&e(i.length)&&!r(i)}return bu=t,bu}var Eu,iy;function Jr(){if(iy)return Eu;iy=1;var r=Eo(),e=Hi(),t=Wr();function i(n){return t(n)?r(n):e(n)}return Eu=i,Eu}var xu,ny;function oy(){if(ny)return xu;ny=1;var r=Pt(),e=Jr();function t(i,n){return i&&r(n,e(n),i)}return xu=t,xu}var Su,sy;function ay(){if(sy)return Su;sy=1;function r(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}return Su=r,Su}var Iu,uy;function fy(){if(uy)return Iu;uy=1;var r=_r(),e=li(),t=ay(),i=Object.prototype,n=i.hasOwnProperty;function o(s){if(!r(s))return t(s);var a=e(s),h=[];for(var f in s)f=="constructor"&&(a||!n.call(s,f))||h.push(f);return h}return Iu=o,Iu}var Au,hy;function ft(){if(hy)return Au;hy=1;var r=Eo(),e=fy(),t=Wr();function i(n){return t(n)?r(n,!0):e(n)}return Au=i,Au}var Ru,cy;function ly(){if(cy)return Ru;cy=1;var r=Pt(),e=ft();function t(i,n){return i&&r(n,e(n),i)}return Ru=t,Ru}var en={exports:{}};en.exports;var dy;function So(){return dy?en.exports:(dy=1,(function(r,e){var t=Ir(),i=e&&!e.nodeType&&e,n=i&&!0&&r&&!r.nodeType&&r,o=n&&n.exports===i,s=o?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function h(f,l){if(l)return f.slice();var g=f.length,m=a?a(g):new f.constructor(g);return f.copy(m),m}r.exports=h})(en,en.exports),en.exports)}var Cu,py;function Io(){if(py)return Cu;py=1;function r(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i_))return!1;var q=g.get(s),x=g.get(a);if(q&&x)return q==a&&x==s;var A=-1,S=!0,I=h&n?new r:void 0;for(g.set(s,a),g.set(a,s);++A<_;){var M=s[A],D=a[A];if(f)var z=m?f(D,M,A,a,s,g):f(M,D,A,s,a,g);if(z!==void 0){if(z)continue;S=!1;break}if(I){if(!e(a,function(O,N){if(!t(I,N)&&(M===O||l(M,O,h,f,g)))return I.push(N)})){S=!1;break}}else if(!(M===D||l(M,D,h,f,g))){S=!1;break}}return g.delete(s),g.delete(a),S}return Sf=o,Sf}var If,k_;function L_(){if(k_)return If;k_=1;function r(e){var t=-1,i=Array(e.size);return e.forEach(function(n,o){i[++t]=[o,n]}),i}return If=r,If}var Af,M_;function un(){if(M_)return Af;M_=1;function r(e){var t=-1,i=Array(e.size);return e.forEach(function(n){i[++t]=n}),i}return Af=r,Af}var Rf,D_;function j_(){if(D_)return Rf;D_=1;var r=qt(),e=Lo(),t=wt(),i=Uo(),n=L_(),o=un(),s=1,a=2,h="[object Boolean]",f="[object Date]",l="[object Error]",g="[object Map]",m="[object Number]",_="[object RegExp]",E="[object Set]",q="[object String]",x="[object Symbol]",A="[object ArrayBuffer]",S="[object DataView]",I=r?r.prototype:void 0,M=I?I.valueOf:void 0;function D(z,O,N,j,X,re,oe){switch(N){case S:if(z.byteLength!=O.byteLength||z.byteOffset!=O.byteOffset)return!1;z=z.buffer,O=O.buffer;case A:return!(z.byteLength!=O.byteLength||!re(new e(z),new e(O)));case h:case f:case m:return t(+z,+O);case l:return z.name==O.name&&z.message==O.message;case _:case q:return z==O+"";case g:var me=n;case E:var _e=j&s;if(me||(me=o),z.size!=O.size&&!_e)return!1;var Te=oe.get(z);if(Te)return Te==O;j|=a,oe.set(z,O);var Ne=i(me(z),me(O),j,X,re,oe);return oe.delete(z),Ne;case x:if(M)return M.call(z)==M.call(O)}return!1}return Rf=D,Rf}var Cf,P_;function G_(){if(P_)return Cf;P_=1;var r=Oo(),e=1,t=Object.prototype,i=t.hasOwnProperty;function n(o,s,a,h,f,l){var g=a&e,m=r(o),_=m.length,E=r(s),q=E.length;if(_!=q&&!g)return!1;for(var x=_;x--;){var A=m[x];if(!(g?A in s:i.call(s,A)))return!1}var S=l.get(o),I=l.get(s);if(S&&I)return S==s&&I==o;var M=!0;l.set(o,s),l.set(s,o);for(var D=g;++x<_;){A=m[x];var z=o[A],O=s[A];if(h)var N=g?h(O,z,A,s,o,l):h(z,O,A,o,s,l);if(!(N===void 0?z===O||f(z,O,a,h,l):N)){M=!1;break}D||(D=A=="constructor")}if(M&&!D){var j=o.constructor,X=s.constructor;j!=X&&"constructor"in o&&"constructor"in s&&!(typeof j=="function"&&j instanceof j&&typeof X=="function"&&X instanceof X)&&(M=!1)}return l.delete(o),l.delete(s),M}return Cf=n,Cf}var Tf,N_;function F_(){if(N_)return Tf;N_=1;var r=ai(),e=Uo(),t=j_(),i=G_(),n=Et(),o=Ve(),s=bt(),a=Nt(),h=1,f="[object Arguments]",l="[object Array]",g="[object Object]",m=Object.prototype,_=m.hasOwnProperty;function E(q,x,A,S,I,M){var D=o(q),z=o(x),O=D?l:n(q),N=z?l:n(x);O=O==f?g:O,N=N==f?g:N;var j=O==g,X=N==g,re=O==N;if(re&&s(q)){if(!s(x))return!1;D=!0,j=!1}if(re&&!j)return M||(M=new r),D||a(q)?e(q,x,A,S,I,M):t(q,x,O,A,S,I,M);if(!(A&h)){var oe=j&&_.call(q,"__wrapped__"),me=X&&_.call(x,"__wrapped__");if(oe||me){var _e=oe?q.value():q,Te=me?x.value():x;return M||(M=new r),I(_e,Te,A,S,M)}}return re?(M||(M=new r),i(q,x,A,S,I,M)):!1}return Tf=E,Tf}var Of,z_;function Wo(){if(z_)return Of;z_=1;var r=F_(),e=jr();function t(i,n,o,s,a){return i===n?!0:i==null||n==null||!e(i)&&!e(n)?i!==i&&n!==n:r(i,n,o,s,t,a)}return Of=t,Of}var kf,$_;function U_(){if($_)return kf;$_=1;var r=ai(),e=Wo(),t=1,i=2;function n(o,s,a,h){var f=a.length,l=f,g=!h;if(o==null)return!l;for(o=Object(o);f--;){var m=a[f];if(g&&m[2]?m[1]!==o[m[0]]:!(m[0]in o))return!1}for(;++f0&&o(l)?n>1?t(l,n-1,o,s,a):r(a,l):s||(a[a.length]=l)}return a}return qh=t,qh}var bh,tw;function iw(){if(tw)return bh;tw=1;function r(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}return bh=r,bh}var Eh,nw;function is(){if(nw)return Eh;nw=1;var r=iw(),e=Math.max;function t(i,n,o){return n=e(n===void 0?i.length-1:n,0),function(){for(var s=arguments,a=-1,h=e(s.length-n,0),f=Array(h);++a0){if(++o>=r)return arguments[0]}else o=0;return n.apply(void 0,arguments)}}return Sh=i,Sh}var Ih,fw;function ns(){if(fw)return Ih;fw=1;var r=sw(),e=uw(),t=e(r);return Ih=t,Ih}var Ah,hw;function _i(){if(hw)return Ah;hw=1;var r=ht(),e=is(),t=ns();function i(n,o){return t(e(n,o,r),n+"")}return Ah=i,Ah}var Rh,cw;function os(){if(cw)return Rh;cw=1;function r(e,t,i,n){for(var o=e.length,s=i+(n?1:-1);n?s--:++s-1}return kh=e,kh}var Lh,ww;function qw(){if(ww)return Lh;ww=1;function r(e,t,i){for(var n=-1,o=e==null?0:e.length;++n=s){var A=f?null:n(h);if(A)return o(A);E=!1,m=i,x=new r}else x=f?[]:q;e:for(;++g<_;){var S=h[g],I=f?f(S):S;if(S=l||S!==0?S:0,E&&I===I){for(var M=x.length;M--;)if(x[M]===I)continue e;f&&x.push(I),q.push(S)}else m(x,I,l)||(x!==q&&x.push(I),q.push(S))}return q}return jh=a,jh}var Ph,Rw;function ss(){if(Rw)return Ph;Rw=1;var r=Wr(),e=jr();function t(i){return e(i)&&r(i)}return Ph=t,Ph}var Gh,Cw;function Tw(){if(Cw)return Gh;Cw=1;var r=hn(),e=_i(),t=Aw(),i=ss(),n=e(function(o){return t(r(o,1,i,!0))});return Gh=n,Gh}var Nh,Ow;function kw(){if(Ow)return Nh;Ow=1;var r=gi();function e(t,i){return r(i,function(n){return t[n]})}return Nh=e,Nh}var Fh,Lw;function as(){if(Lw)return Fh;Lw=1;var r=kw(),e=Jr();function t(i){return i==null?[]:r(i,e(i))}return Fh=t,Fh}var zh,Mw;function vr(){if(Mw)return zh;Mw=1;var r;if(typeof Bi=="function")try{r={clone:u_(),constant:on(),each:Fo(),filter:Zo(),has:Jo(),isArray:Ve(),isEmpty:Tv(),isFunction:jt(),isUndefined:Ho(),keys:Jr(),map:rs(),reduce:ts(),size:Qv(),transform:Jv(),union:Tw(),values:as()}}catch{}return r||(r=window._),zh=r,zh}var $h,Dw;function cn(){if(Dw)return $h;Dw=1;var r=vr();$h=n;var e="\0",t="\0",i="";function n(l){this._isDirected=r.has(l,"directed")?l.directed:!0,this._isMultigraph=r.has(l,"multigraph")?l.multigraph:!1,this._isCompound=r.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=r.constant(void 0),this._defaultEdgeLabelFn=r.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(l){return this._label=l,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(l){return r.isFunction(l)||(l=r.constant(l)),this._defaultNodeLabelFn=l,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return r.keys(this._nodes)},n.prototype.sources=function(){var l=this;return r.filter(this.nodes(),function(g){return r.isEmpty(l._in[g])})},n.prototype.sinks=function(){var l=this;return r.filter(this.nodes(),function(g){return r.isEmpty(l._out[g])})},n.prototype.setNodes=function(l,g){var m=arguments,_=this;return r.each(l,function(E){m.length>1?_.setNode(E,g):_.setNode(E)}),this},n.prototype.setNode=function(l,g){return r.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=g),this):(this._nodes[l]=arguments.length>1?g:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=t,this._children[l]={},this._children[t][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},n.prototype.node=function(l){return this._nodes[l]},n.prototype.hasNode=function(l){return r.has(this._nodes,l)},n.prototype.removeNode=function(l){var g=this;if(r.has(this._nodes,l)){var m=function(_){g.removeEdge(g._edgeObjs[_])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],r.each(this.children(l),function(_){g.setParent(_)}),delete this._children[l]),r.each(r.keys(this._in[l]),m),delete this._in[l],delete this._preds[l],r.each(r.keys(this._out[l]),m),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},n.prototype.setParent=function(l,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(r.isUndefined(g))g=t;else{g+="";for(var m=g;!r.isUndefined(m);m=this.parent(m))if(m===l)throw new Error("Setting "+g+" as parent of "+l+" would create a cycle");this.setNode(g)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=g,this._children[g][l]=!0,this},n.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},n.prototype.parent=function(l){if(this._isCompound){var g=this._parent[l];if(g!==t)return g}},n.prototype.children=function(l){if(r.isUndefined(l)&&(l=t),this._isCompound){var g=this._children[l];if(g)return r.keys(g)}else{if(l===t)return this.nodes();if(this.hasNode(l))return[]}},n.prototype.predecessors=function(l){var g=this._preds[l];if(g)return r.keys(g)},n.prototype.successors=function(l){var g=this._sucs[l];if(g)return r.keys(g)},n.prototype.neighbors=function(l){var g=this.predecessors(l);if(g)return r.union(g,this.successors(l))},n.prototype.isLeaf=function(l){var g;return this.isDirected()?g=this.successors(l):g=this.neighbors(l),g.length===0},n.prototype.filterNodes=function(l){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var m=this;r.each(this._nodes,function(q,x){l(x)&&g.setNode(x,q)}),r.each(this._edgeObjs,function(q){g.hasNode(q.v)&&g.hasNode(q.w)&&g.setEdge(q,m.edge(q))});var _={};function E(q){var x=m.parent(q);return x===void 0||g.hasNode(x)?(_[q]=x,x):x in _?_[x]:E(x)}return this._isCompound&&r.each(g.nodes(),function(q){g.setParent(q,E(q))}),g},n.prototype.setDefaultEdgeLabel=function(l){return r.isFunction(l)||(l=r.constant(l)),this._defaultEdgeLabelFn=l,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return r.values(this._edgeObjs)},n.prototype.setPath=function(l,g){var m=this,_=arguments;return r.reduce(l,function(E,q){return _.length>1?m.setEdge(E,q,g):m.setEdge(E,q),q}),this},n.prototype.setEdge=function(){var l,g,m,_,E=!1,q=arguments[0];typeof q=="object"&&q!==null&&"v"in q?(l=q.v,g=q.w,m=q.name,arguments.length===2&&(_=arguments[1],E=!0)):(l=q,g=arguments[1],m=arguments[3],arguments.length>2&&(_=arguments[2],E=!0)),l=""+l,g=""+g,r.isUndefined(m)||(m=""+m);var x=a(this._isDirected,l,g,m);if(r.has(this._edgeLabels,x))return E&&(this._edgeLabels[x]=_),this;if(!r.isUndefined(m)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(g),this._edgeLabels[x]=E?_:this._defaultEdgeLabelFn(l,g,m);var A=h(this._isDirected,l,g,m);return l=A.v,g=A.w,Object.freeze(A),this._edgeObjs[x]=A,o(this._preds[g],l),o(this._sucs[l],g),this._in[g][x]=A,this._out[l][x]=A,this._edgeCount++,this},n.prototype.edge=function(l,g,m){var _=arguments.length===1?f(this._isDirected,arguments[0]):a(this._isDirected,l,g,m);return this._edgeLabels[_]},n.prototype.hasEdge=function(l,g,m){var _=arguments.length===1?f(this._isDirected,arguments[0]):a(this._isDirected,l,g,m);return r.has(this._edgeLabels,_)},n.prototype.removeEdge=function(l,g,m){var _=arguments.length===1?f(this._isDirected,arguments[0]):a(this._isDirected,l,g,m),E=this._edgeObjs[_];return E&&(l=E.v,g=E.w,delete this._edgeLabels[_],delete this._edgeObjs[_],s(this._preds[g],l),s(this._sucs[l],g),delete this._in[g][_],delete this._out[l][_],this._edgeCount--),this},n.prototype.inEdges=function(l,g){var m=this._in[l];if(m){var _=r.values(m);return g?r.filter(_,function(E){return E.v===g}):_}},n.prototype.outEdges=function(l,g){var m=this._out[l];if(m){var _=r.values(m);return g?r.filter(_,function(E){return E.w===g}):_}},n.prototype.nodeEdges=function(l,g){var m=this.inEdges(l,g);if(m)return m.concat(this.outEdges(l,g))};function o(l,g){l[g]?l[g]++:l[g]=1}function s(l,g){--l[g]||delete l[g]}function a(l,g,m,_){var E=""+g,q=""+m;if(!l&&E>q){var x=E;E=q,q=x}return E+i+q+i+(r.isUndefined(_)?e:_)}function h(l,g,m,_){var E=""+g,q=""+m;if(!l&&E>q){var x=E;E=q,q=x}var A={v:E,w:q};return _&&(A.name=_),A}function f(l,g){return a(l,g.v,g.w,g.name)}return $h}var Uh,jw;function Pw(){return jw||(jw=1,Uh="2.1.8"),Uh}var Wh,Gw;function Nw(){return Gw||(Gw=1,Wh={Graph:cn(),version:Pw()}),Wh}var Bh,Fw;function zw(){if(Fw)return Bh;Fw=1;var r=vr(),e=cn();Bh={write:t,read:o};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:i(s),edges:n(s)};return r.isUndefined(s.graph())||(a.value=r.clone(s.graph())),a}function i(s){return r.map(s.nodes(),function(a){var h=s.node(a),f=s.parent(a),l={v:a};return r.isUndefined(h)||(l.value=h),r.isUndefined(f)||(l.parent=f),l})}function n(s){return r.map(s.edges(),function(a){var h=s.edge(a),f={v:a.v,w:a.w};return r.isUndefined(a.name)||(f.name=a.name),r.isUndefined(h)||(f.value=h),f})}function o(s){var a=new e(s.options).setGraph(s.value);return r.each(s.nodes,function(h){a.setNode(h.v,h.value),h.parent&&a.setParent(h.v,h.parent)}),r.each(s.edges,function(h){a.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),a}return Bh}var Vh,$w;function Uw(){if($w)return Vh;$w=1;var r=vr();Vh=e;function e(t){var i={},n=[],o;function s(a){r.has(i,a)||(i[a]=!0,o.push(a),r.each(t.successors(a),s),r.each(t.predecessors(a),s))}return r.each(t.nodes(),function(a){o=[],s(a),o.length&&n.push(o)}),n}return Vh}var Kh,Ww;function us(){if(Ww)return Kh;Ww=1;var r=vr();Kh=e;function e(){this._arr=[],this._keyIndices={}}return e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(t){return r.has(this._keyIndices,t)},e.prototype.priority=function(t){var i=this._keyIndices[t];if(i!==void 0)return this._arr[i].priority},e.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(t,i){var n=this._keyIndices;if(t=String(t),!r.has(n,t)){var o=this._arr,s=o.length;return n[t]=s,o.push({key:t,priority:i}),this._decrease(s),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,i){var n=this._keyIndices[t];if(i>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+i);this._arr[n].priority=i,this._decrease(n)},e.prototype._heapify=function(t){var i=this._arr,n=2*t,o=n+1,s=t;n>1,!(i[o].priority0&&(g=l.removeMin(),m=f[g],m.distance!==Number.POSITIVE_INFINITY);)h(g).forEach(_);return f}return Yh}var Xh,Vw;function Kw(){if(Vw)return Xh;Vw=1;var r=fs(),e=vr();Xh=t;function t(i,n,o){return e.transform(i.nodes(),function(s,a){s[a]=r(i,a,n,o)},{})}return Xh}var Qh,Yw;function hs(){if(Yw)return Qh;Yw=1;var r=vr();Qh=e;function e(t){var i=0,n=[],o={},s=[];function a(h){var f=o[h]={onStack:!0,lowlink:i,index:i++};if(n.push(h),t.successors(h).forEach(function(m){r.has(o,m)?o[m].onStack&&(f.lowlink=Math.min(f.lowlink,o[m].index)):(a(m),f.lowlink=Math.min(f.lowlink,o[m].lowlink))}),f.lowlink===f.index){var l=[],g;do g=n.pop(),o[g].onStack=!1,l.push(g);while(h!==g);s.push(l)}}return t.nodes().forEach(function(h){r.has(o,h)||a(h)}),s}return Qh}var Zh,Xw;function Qw(){if(Xw)return Zh;Xw=1;var r=vr(),e=hs();Zh=t;function t(i){return r.filter(e(i),function(n){return n.length>1||n.length===1&&i.hasEdge(n[0],n[0])})}return Zh}var Jh,Zw;function Jw(){if(Zw)return Jh;Zw=1;var r=vr();Jh=t;var e=r.constant(1);function t(n,o,s){return i(n,o||e,s||function(a){return n.outEdges(a)})}function i(n,o,s){var a={},h=n.nodes();return h.forEach(function(f){a[f]={},a[f][f]={distance:0},h.forEach(function(l){f!==l&&(a[f][l]={distance:Number.POSITIVE_INFINITY})}),s(f).forEach(function(l){var g=l.v===f?l.w:l.v,m=o(l);a[f][g]={distance:m,predecessor:f}})}),h.forEach(function(f){var l=a[f];h.forEach(function(g){var m=a[g];h.forEach(function(_){var E=m[f],q=l[_],x=m[_],A=E.distance+q.distance;A0;){if(f=h.removeMin(),r.has(a,f))s.setEdge(f,a[f]);else{if(g)throw new Error("Input graph is not connected: "+n);g=!0}n.nodeEdges(f).forEach(l)}return s}return nc}var oc,f0;function h0(){return f0||(f0=1,oc={components:Uw(),dijkstra:fs(),dijkstraAll:Kw(),findCycles:Qw(),floydWarshall:Jw(),isAcyclic:r0(),postorder:n0(),preorder:s0(),prim:u0(),tarjan:hs(),topsort:cs()}),oc}var sc,c0;function l0(){if(c0)return sc;c0=1;var r=Nw();return sc={Graph:r.Graph,json:zw(),alg:h0(),version:r.version},sc}var ac,d0;function kr(){if(d0)return ac;d0=1;var r;if(typeof Bi=="function")try{r=l0()}catch{}return r||(r=window.graphlib),ac=r,ac}var uc,p0;function g0(){if(p0)return uc;p0=1;var r=Po(),e=1,t=4;function i(n){return r(n,e|t)}return uc=i,uc}var fc,m0;function vi(){if(m0)return fc;m0=1;var r=wt(),e=Wr(),t=hi(),i=_r();function n(o,s,a){if(!i(a))return!1;var h=typeof s;return(h=="number"?e(a)&&t(s,a.length):h=="string"&&s in a)?r(a[s],o):!1}return fc=n,fc}var hc,y0;function _0(){if(y0)return hc;y0=1;var r=_i(),e=wt(),t=vi(),i=ft(),n=Object.prototype,o=n.hasOwnProperty,s=r(function(a,h){a=Object(a);var f=-1,l=h.length,g=l>2?h[2]:void 0;for(g&&t(h[0],h[1],g)&&(l=1);++f-1?h[f?o[l]:l]:void 0}}return cc=i,cc}var lc,q0;function b0(){if(q0)return lc;q0=1;var r=/\s/;function e(t){for(var i=t.length;i--&&r.test(t.charAt(i)););return i}return lc=e,lc}var dc,E0;function x0(){if(E0)return dc;E0=1;var r=b0(),e=/^\s+/;function t(i){return i&&i.slice(0,r(i)+1).replace(e,"")}return dc=t,dc}var pc,S0;function I0(){if(S0)return pc;S0=1;var r=x0(),e=_r(),t=xt(),i=NaN,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function h(f){if(typeof f=="number")return f;if(t(f))return i;if(e(f)){var l=typeof f.valueOf=="function"?f.valueOf():f;f=e(l)?l+"":l}if(typeof f!="string")return f===0?f:+f;f=r(f);var g=o.test(f);return g||s.test(f)?a(f.slice(2),g?2:8):n.test(f)?i:+f}return pc=h,pc}var gc,A0;function ds(){if(A0)return gc;A0=1;var r=I0(),e=1/0,t=17976931348623157e292;function i(n){if(!n)return n===0?n:0;if(n=r(n),n===e||n===-e){var o=n<0?-1:1;return o*t}return n===n?n:0}return gc=i,gc}var mc,R0;function C0(){if(R0)return mc;R0=1;var r=ds();function e(t){var i=r(t),n=i%1;return i===i?n?i-n:i:0}return mc=e,mc}var yc,T0;function O0(){if(T0)return yc;T0=1;var r=os(),e=Br(),t=C0(),i=Math.max;function n(o,s,a){var h=o==null?0:o.length;if(!h)return-1;var f=a==null?0:t(a);return f<0&&(f=i(h+f,0)),r(o,e(s,3),f)}return yc=n,yc}var _c,k0;function L0(){if(k0)return _c;k0=1;var r=w0(),e=O0(),t=r(e);return _c=t,_c}var vc,M0;function ps(){if(M0)return vc;M0=1;var r=hn();function e(t){var i=t==null?0:t.length;return i?r(t,1):[]}return vc=e,vc}var wc,D0;function j0(){if(D0)return wc;D0=1;var r=sn(),e=Go(),t=ft();function i(n,o){return n==null?n:r(n,e(o),t)}return wc=i,wc}var qc,P0;function G0(){if(P0)return qc;P0=1;function r(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}return qc=r,qc}var bc,N0;function F0(){if(N0)return bc;N0=1;var r=ui(),e=an(),t=Br();function i(n,o){var s={};return o=t(o,3),e(n,function(a,h,f){r(s,h,o(a,h,f))}),s}return bc=i,bc}var Ec,z0;function ln(){if(z0)return Ec;z0=1;var r=xt();function e(t,i,n){for(var o=-1,s=t.length;++ot}return xc=r,xc}var Sc,W0;function B0(){if(W0)return Sc;W0=1;var r=ln(),e=U0(),t=ht();function i(n){return n&&n.length?r(n,t,e):void 0}return Sc=i,Sc}var Ic,V0;function gs(){if(V0)return Ic;V0=1;var r=ui(),e=wt();function t(i,n,o){(o!==void 0&&!e(i[n],o)||o===void 0&&!(n in i))&&r(i,n,o)}return Ic=t,Ic}var Ac,K0;function Y0(){if(K0)return Ac;K0=1;var r=at(),e=di(),t=jr(),i="[object Object]",n=Function.prototype,o=Object.prototype,s=n.toString,a=o.hasOwnProperty,h=s.call(Object);function f(l){if(!t(l)||r(l)!=i)return!1;var g=e(l);if(g===null)return!0;var m=a.call(g,"constructor")&&g.constructor;return typeof m=="function"&&m instanceof m&&s.call(m)==h}return Ac=f,Ac}var Rc,X0;function ms(){if(X0)return Rc;X0=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return Rc=r,Rc}var Cc,Q0;function Z0(){if(Q0)return Cc;Q0=1;var r=Pt(),e=ft();function t(i){return r(i,e(i))}return Cc=t,Cc}var Tc,J0;function H0(){if(J0)return Tc;J0=1;var r=gs(),e=So(),t=Mo(),i=Io(),n=jo(),o=Gt(),s=Ve(),a=ss(),h=bt(),f=jt(),l=_r(),g=Y0(),m=Nt(),_=ms(),E=Z0();function q(x,A,S,I,M,D,z){var O=_(x,S),N=_(A,S),j=z.get(N);if(j){r(x,S,j);return}var X=D?D(O,N,S+"",x,A,z):void 0,re=X===void 0;if(re){var oe=s(N),me=!oe&&h(N),_e=!oe&&!me&&m(N);X=N,oe||me||_e?s(O)?X=O:a(O)?X=i(O):me?(re=!1,X=e(N,!0)):_e?(re=!1,X=t(N,!0)):X=[]:g(N)||o(N)?(X=O,o(O)?X=E(O):(!l(O)||f(O))&&(X=n(N))):re=!1}re&&(z.set(N,X),M(X,N,I,D,z),z.delete(N)),r(x,S,X)}return Tc=q,Tc}var Oc,eq;function rq(){if(eq)return Oc;eq=1;var r=ai(),e=gs(),t=sn(),i=H0(),n=_r(),o=ft(),s=ms();function a(h,f,l,g,m){h!==f&&t(f,function(_,E){if(m||(m=new r),n(_))i(h,f,E,l,a,g,m);else{var q=g?g(s(h,E),_,E+"",h,f,m):void 0;q===void 0&&(q=_),e(h,E,q)}},o)}return Oc=a,Oc}var kc,tq;function iq(){if(tq)return kc;tq=1;var r=_i(),e=vi();function t(i){return r(function(n,o){var s=-1,a=o.length,h=a>1?o[a-1]:void 0,f=a>2?o[2]:void 0;for(h=i.length>3&&typeof h=="function"?(a--,h):void 0,f&&e(o[0],o[1],f)&&(h=a<3?void 0:h,a=1),n=Object(n);++si||a&&h&&l&&!f&&!g||o&&h&&l||!n&&l||!s)return 1;if(!o&&!a&&!g&&t=f)return l;var g=n[o];return l*(g=="desc"?-1:1)}}return t.index-i.index}return Yc=e,Yc}var Xc,Dq;function jq(){if(Dq)return Xc;Dq=1;var r=gi(),e=yi(),t=Br(),i=es(),n=Tq(),o=ci(),s=Mq(),a=ht(),h=Ve();function f(l,g,m){g.length?g=r(g,function(q){return h(q)?function(x){return e(x,q.length===1?q[0]:q)}:q}):g=[a];var _=-1;g=r(g,o(t));var E=i(l,function(q,x,A){var S=r(g,function(I){return I(q)});return{criteria:S,index:++_,value:q}});return n(E,function(q,x){return s(q,x,m)})}return Xc=f,Xc}var Qc,Pq;function Gq(){if(Pq)return Qc;Pq=1;var r=hn(),e=jq(),t=_i(),i=vi(),n=t(function(o,s){if(o==null)return[];var a=s.length;return a>1&&i(o,s[0],s[1])?s=[]:a>2&&i(s[0],s[1],s[2])&&(s=[s[0]]),e(o,r(s,1),[])});return Qc=n,Qc}var Zc,Nq;function Fq(){if(Nq)return Zc;Nq=1;var r=Ko(),e=0;function t(i){var n=++e;return r(i)+n}return Zc=t,Zc}var Jc,zq;function $q(){if(zq)return Jc;zq=1;function r(e,t,i){for(var n=-1,o=e.length,s=t.length,a={};++n0;--x)if(q=l[x].dequeue(),q){m=m.concat(s(f,l,g,q,!0));break}}}return m}function s(f,l,g,m,_){var E=_?[]:void 0;return r.forEach(f.inEdges(m.v),function(q){var x=f.edge(q),A=f.node(q.v);_&&E.push({v:q.v,w:q.w}),A.out-=x,h(l,g,A)}),r.forEach(f.outEdges(m.v),function(q){var x=f.edge(q),A=q.w,S=f.node(A);S.in-=x,h(l,g,S)}),f.removeNode(m.v),E}function a(f,l){var g=new e,m=0,_=0;r.forEach(f.nodes(),function(x){g.setNode(x,{v:x,in:0,out:0})}),r.forEach(f.edges(),function(x){var A=g.edge(x.v,x.w)||0,S=l(x),I=A+S;g.setEdge(x.v,x.w,I),_=Math.max(_,g.node(x.v).out+=S),m=Math.max(m,g.node(x.w).in+=S)});var E=r.range(_+m+3).map(function(){return new t}),q=m+1;return r.forEach(g.nodes(),function(x){h(E,q,g.node(x))}),{graph:g,buckets:E,zeroIdx:q}}function h(f,l,g){g.out?g.in?f[g.out-g.in+l].enqueue(g):f[f.length-1].enqueue(g):f[0].enqueue(g)}return tl}var il,Qq;function Zq(){if(Qq)return il;Qq=1;var r=Fe(),e=Xq();il={run:t,undo:n};function t(o){var s=o.graph().acyclicer==="greedy"?e(o,a(o)):i(o);r.forEach(s,function(h){var f=o.edge(h);o.removeEdge(h),f.forwardName=h.name,f.reversed=!0,o.setEdge(h.w,h.v,f,r.uniqueId("rev"))});function a(h){return function(f){return h.edge(f).weight}}}function i(o){var s=[],a={},h={};function f(l){r.has(h,l)||(h[l]=!0,a[l]=!0,r.forEach(o.outEdges(l),function(g){r.has(a,g.w)?s.push(g):f(g.w)}),delete a[l])}return r.forEach(o.nodes(),f),s}function n(o){r.forEach(o.edges(),function(s){var a=o.edge(s);if(a.reversed){o.removeEdge(s);var h=a.forwardName;delete a.reversed,delete a.forwardName,o.setEdge(s.w,s.v,a,h)}})}return il}var nl,Jq;function dr(){if(Jq)return nl;Jq=1;var r=Fe(),e=kr().Graph;nl={addDummyNode:t,simplify:i,asNonCompoundGraph:n,successorWeights:o,predecessorWeights:s,intersectRect:a,buildLayerMatrix:h,normalizeRanks:f,removeEmptyRanks:l,addBorderNode:g,maxRank:m,partition:_,time:E,notime:q};function t(x,A,S,I){var M;do M=r.uniqueId(I);while(x.hasNode(M));return S.dummy=A,x.setNode(M,S),M}function i(x){var A=new e().setGraph(x.graph());return r.forEach(x.nodes(),function(S){A.setNode(S,x.node(S))}),r.forEach(x.edges(),function(S){var I=A.edge(S.v,S.w)||{weight:0,minlen:1},M=x.edge(S);A.setEdge(S.v,S.w,{weight:I.weight+M.weight,minlen:Math.max(I.minlen,M.minlen)})}),A}function n(x){var A=new e({multigraph:x.isMultigraph()}).setGraph(x.graph());return r.forEach(x.nodes(),function(S){x.children(S).length||A.setNode(S,x.node(S))}),r.forEach(x.edges(),function(S){A.setEdge(S,x.edge(S))}),A}function o(x){var A=r.map(x.nodes(),function(S){var I={};return r.forEach(x.outEdges(S),function(M){I[M.w]=(I[M.w]||0)+x.edge(M).weight}),I});return r.zipObject(x.nodes(),A)}function s(x){var A=r.map(x.nodes(),function(S){var I={};return r.forEach(x.inEdges(S),function(M){I[M.v]=(I[M.v]||0)+x.edge(M).weight}),I});return r.zipObject(x.nodes(),A)}function a(x,A){var S=x.x,I=x.y,M=A.x-S,D=A.y-I,z=x.width/2,O=x.height/2;if(!M&&!D)throw new Error("Not possible to find intersection inside of the rectangle");var N,j;return Math.abs(D)*z>Math.abs(M)*O?(D<0&&(O=-O),N=O*M/D,j=O):(M<0&&(z=-z),N=z,j=z*D/M),{x:S+N,y:I+j}}function h(x){var A=r.map(r.range(m(x)+1),function(){return[]});return r.forEach(x.nodes(),function(S){var I=x.node(S),M=I.rank;r.isUndefined(M)||(A[M][I.order]=S)}),A}function f(x){var A=r.min(r.map(x.nodes(),function(S){return x.node(S).rank}));r.forEach(x.nodes(),function(S){var I=x.node(S);r.has(I,"rank")&&(I.rank-=A)})}function l(x){var A=r.min(r.map(x.nodes(),function(D){return x.node(D).rank})),S=[];r.forEach(x.nodes(),function(D){var z=x.node(D).rank-A;S[z]||(S[z]=[]),S[z].push(D)});var I=0,M=x.graph().nodeRankFactor;r.forEach(S,function(D,z){r.isUndefined(D)&&z%M!==0?--I:I&&r.forEach(D,function(O){x.node(O).rank+=I})})}function g(x,A,S,I){var M={width:0,height:0};return arguments.length>=4&&(M.rank=S,M.order=I),t(x,"border",M,A)}function m(x){return r.max(r.map(x.nodes(),function(A){var S=x.node(A).rank;if(!r.isUndefined(S))return S}))}function _(x,A){var S={lhs:[],rhs:[]};return r.forEach(x,function(I){A(I)?S.lhs.push(I):S.rhs.push(I)}),S}function E(x,A){var S=r.now();try{return A()}finally{console.log(x+" time: "+(r.now()-S)+"ms")}}function q(x,A){return A()}return nl}var ol,Hq;function eb(){if(Hq)return ol;Hq=1;var r=Fe(),e=dr();ol={run:t,undo:n};function t(o){o.graph().dummyChains=[],r.forEach(o.edges(),function(s){i(o,s)})}function i(o,s){var a=s.v,h=o.node(a).rank,f=s.w,l=o.node(f).rank,g=s.name,m=o.edge(s),_=m.labelRank;if(l!==h+1){o.removeEdge(s);var E,q,x;for(x=0,++h;hj.lim&&(X=j,re=!0);var oe=r.filter(M.edges(),function(me){return re===S(I,I.node(me.v),X)&&re!==S(I,I.node(me.w),X)});return r.minBy(oe,function(me){return t(M,me)})}function q(I,M,D,z){var O=D.v,N=D.w;I.removeEdge(O,N),I.setEdge(z.v,z.w,{}),g(I),h(I,M),x(I,M)}function x(I,M){var D=r.find(I.nodes(),function(O){return!M.node(O).parent}),z=n(I,D);z=z.slice(1),r.forEach(z,function(O){var N=I.node(O).parent,j=M.edge(O,N),X=!1;j||(j=M.edge(N,O),X=!0),M.node(O).rank=M.node(N).rank+(X?j.minlen:-j.minlen)})}function A(I,M,D){return I.hasEdge(M,D)}function S(I,M,D){return D.low<=M.lim&&M.lim<=D.lim}return ul}var fl,ob;function sb(){if(ob)return fl;ob=1;var r=Ci(),e=r.longestPath,t=_s(),i=nb();fl=n;function n(h){switch(h.graph().ranker){case"network-simplex":a(h);break;case"tight-tree":s(h);break;case"longest-path":o(h);break;default:a(h)}}var o=e;function s(h){e(h),t(h)}function a(h){i(h)}return fl}var hl,ab;function ub(){if(ab)return hl;ab=1;var r=Fe();hl=e;function e(n){var o=i(n);r.forEach(n.graph().dummyChains,function(s){for(var a=n.node(s),h=a.edgeObj,f=t(n,o,h.v,h.w),l=f.path,g=f.lca,m=0,_=l[m],E=!0;s!==h.w;){if(a=n.node(s),E){for(;(_=l[m])!==g&&n.node(_).maxRankl||g>o[m].lim));for(_=m,m=a;(m=n.parent(m))!==_;)f.push(m);return{path:h.concat(f.reverse()),lca:_}}function i(n){var o={},s=0;function a(h){var f=s;r.forEach(n.children(h),a),o[h]={low:f,lim:s++}}return r.forEach(n.children(),a),o}return hl}var cl,fb;function hb(){if(fb)return cl;fb=1;var r=Fe(),e=dr();cl={run:t,cleanup:s};function t(a){var h=e.addDummyNode(a,"root",{},"_root"),f=n(a),l=r.max(r.values(f))-1,g=2*l+1;a.graph().nestingRoot=h,r.forEach(a.edges(),function(_){a.edge(_).minlen*=g});var m=o(a)+1;r.forEach(a.children(),function(_){i(a,h,g,m,l,f,_)}),a.graph().nodeRankFactor=g}function i(a,h,f,l,g,m,_){var E=a.children(_);if(!E.length){_!==h&&a.setEdge(h,_,{weight:0,minlen:f});return}var q=e.addBorderNode(a,"_bt"),x=e.addBorderNode(a,"_bb"),A=a.node(_);a.setParent(q,_),A.borderTop=q,a.setParent(x,_),A.borderBottom=x,r.forEach(E,function(S){i(a,h,f,l,g,m,S);var I=a.node(S),M=I.borderTop?I.borderTop:S,D=I.borderBottom?I.borderBottom:S,z=I.borderTop?l:2*l,O=M!==D?1:g-m[_]+1;a.setEdge(q,M,{weight:z,minlen:O,nestingEdge:!0}),a.setEdge(D,x,{weight:z,minlen:O,nestingEdge:!0})}),a.parent(_)||a.setEdge(h,q,{weight:0,minlen:g+m[_]})}function n(a){var h={};function f(l,g){var m=a.children(l);m&&m.length&&r.forEach(m,function(_){f(_,g+1)}),h[l]=g}return r.forEach(a.children(),function(l){f(l,1)}),h}function o(a){return r.reduce(a.edges(),function(h,f){return h+a.edge(f).weight},0)}function s(a){var h=a.graph();a.removeNode(h.nestingRoot),delete h.nestingRoot,r.forEach(a.edges(),function(f){var l=a.edge(f);l.nestingEdge&&a.removeEdge(f)})}return cl}var ll,cb;function lb(){if(cb)return ll;cb=1;var r=Fe(),e=dr();ll=t;function t(n){function o(s){var a=n.children(s),h=n.node(s);if(a.length&&r.forEach(a,o),r.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var f=h.minRank,l=h.maxRank+1;f0;)_%2&&(E+=l[_+1]),_=_-1>>1,l[_]+=m.weight;g+=m.weight*E})),g}return gl}var ml,vb;function wb(){if(vb)return ml;vb=1;var r=Fe();ml=e;function e(t,i){return r.map(i,function(n){var o=t.inEdges(n);if(o.length){var s=r.reduce(o,function(a,h){var f=t.edge(h),l=t.node(h.v);return{sum:a.sum+f.weight*l.order,weight:a.weight+f.weight}},{sum:0,weight:0});return{v:n,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:n}})}return ml}var yl,qb;function bb(){if(qb)return yl;qb=1;var r=Fe();yl=e;function e(n,o){var s={};r.forEach(n,function(h,f){var l=s[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:f};r.isUndefined(h.barycenter)||(l.barycenter=h.barycenter,l.weight=h.weight)}),r.forEach(o.edges(),function(h){var f=s[h.v],l=s[h.w];!r.isUndefined(f)&&!r.isUndefined(l)&&(l.indegree++,f.out.push(s[h.w]))});var a=r.filter(s,function(h){return!h.indegree});return t(a)}function t(n){var o=[];function s(f){return function(l){l.merged||(r.isUndefined(l.barycenter)||r.isUndefined(f.barycenter)||l.barycenter>=f.barycenter)&&i(f,l)}}function a(f){return function(l){l.in.push(f),--l.indegree===0&&n.push(l)}}for(;n.length;){var h=n.pop();o.push(h),r.forEach(h.in.reverse(),s(h)),r.forEach(h.out,a(h))}return r.map(r.filter(o,function(f){return!f.merged}),function(f){return r.pick(f,["vs","i","barycenter","weight"])})}function i(n,o){var s=0,a=0;n.weight&&(s+=n.barycenter*n.weight,a+=n.weight),o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),n.vs=o.vs.concat(n.vs),n.barycenter=s/a,n.weight=a,n.i=Math.min(o.i,n.i),o.merged=!0}return yl}var _l,Eb;function xb(){if(Eb)return _l;Eb=1;var r=Fe(),e=dr();_l=t;function t(o,s){var a=e.partition(o,function(q){return r.has(q,"barycenter")}),h=a.lhs,f=r.sortBy(a.rhs,function(q){return-q.i}),l=[],g=0,m=0,_=0;h.sort(n(!!s)),_=i(l,f,_),r.forEach(h,function(q){_+=q.vs.length,l.push(q.vs),g+=q.barycenter*q.weight,m+=q.weight,_=i(l,f,_)});var E={vs:r.flatten(l,!0)};return m&&(E.barycenter=g/m,E.weight=m),E}function i(o,s,a){for(var h;s.length&&(h=r.last(s)).i<=a;)s.pop(),o.push(h.vs),a++;return a}function n(o){return function(s,a){return s.barycentera.barycenter?1:o?a.i-s.i:s.i-a.i}}return _l}var vl,Sb;function Ib(){if(Sb)return vl;Sb=1;var r=Fe(),e=wb(),t=bb(),i=xb();vl=n;function n(a,h,f,l){var g=a.children(h),m=a.node(h),_=m?m.borderLeft:void 0,E=m?m.borderRight:void 0,q={};_&&(g=r.filter(g,function(D){return D!==_&&D!==E}));var x=e(a,g);r.forEach(x,function(D){if(a.children(D.v).length){var z=n(a,D.v,f,l);q[D.v]=z,r.has(z,"barycenter")&&s(D,z)}});var A=t(x,f);o(A,q);var S=i(A,l);if(_&&(S.vs=r.flatten([_,S.vs,E],!0),a.predecessors(_).length)){var I=a.node(a.predecessors(_)[0]),M=a.node(a.predecessors(E)[0]);r.has(S,"barycenter")||(S.barycenter=0,S.weight=0),S.barycenter=(S.barycenter*S.weight+I.order+M.order)/(S.weight+2),S.weight+=2}return S}function o(a,h){r.forEach(a,function(f){f.vs=r.flatten(f.vs.map(function(l){return h[l]?h[l].vs:l}),!0)})}function s(a,h){r.isUndefined(a.barycenter)?(a.barycenter=h.barycenter,a.weight=h.weight):(a.barycenter=(a.barycenter*a.weight+h.barycenter*h.weight)/(a.weight+h.weight),a.weight+=h.weight)}return vl}var wl,Ab;function Rb(){if(Ab)return wl;Ab=1;var r=Fe(),e=kr().Graph;wl=t;function t(n,o,s){var a=i(n),h=new e({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(f){return n.node(f)});return r.forEach(n.nodes(),function(f){var l=n.node(f),g=n.parent(f);(l.rank===o||l.minRank<=o&&o<=l.maxRank)&&(h.setNode(f),h.setParent(f,g||a),r.forEach(n[s](f),function(m){var _=m.v===f?m.w:m.v,E=h.edge(_,f),q=r.isUndefined(E)?0:E.weight;h.setEdge(_,f,{weight:n.edge(m).weight+q})}),r.has(l,"minRank")&&h.setNode(f,{borderLeft:l.borderLeft[o],borderRight:l.borderRight[o]}))}),h}function i(n){for(var o;n.hasNode(o=r.uniqueId("_root")););return o}return wl}var ql,Cb;function Tb(){if(Cb)return ql;Cb=1;var r=Fe();ql=e;function e(t,i,n){var o={},s;r.forEach(n,function(a){for(var h=t.parent(a),f,l;h;){if(f=t.parent(h),f?(l=o[f],o[f]=h):(l=s,s=h),l&&l!==h){i.setEdge(l,h);return}h=f}})}return ql}var bl,Ob;function kb(){if(Ob)return bl;Ob=1;var r=Fe(),e=mb(),t=_b(),i=Ib(),n=Rb(),o=Tb(),s=kr().Graph,a=dr();bl=h;function h(m){var _=a.maxRank(m),E=f(m,r.range(1,_+1),"inEdges"),q=f(m,r.range(_-1,-1,-1),"outEdges"),x=e(m);g(m,x);for(var A=Number.POSITIVE_INFINITY,S,I=0,M=0;M<4;++I,++M){l(I%2?E:q,I%4>=2),x=a.buildLayerMatrix(m);var D=t(m,x);DX)&&s(I,me,re)})})}function D(z,O){var N=-1,j,X=0;return r.forEach(O,function(re,oe){if(A.node(re).dummy==="border"){var me=A.predecessors(re);me.length&&(j=A.node(me[0]).order,M(O,X,oe,N,j),X=oe,N=j)}M(O,X,O.length,j,z.length)}),O}return r.reduce(S,D),I}function o(A,S){if(A.node(S).dummy)return r.find(A.predecessors(S),function(I){return A.node(I).dummy})}function s(A,S,I){if(S>I){var M=S;S=I,I=M}var D=A[S];D||(A[S]=D={}),D[I]=!0}function a(A,S,I){if(S>I){var M=S;S=I,I=M}return r.has(A[S],I)}function h(A,S,I,M){var D={},z={},O={};return r.forEach(S,function(N){r.forEach(N,function(j,X){D[j]=j,z[j]=j,O[j]=X})}),r.forEach(S,function(N){var j=-1;r.forEach(N,function(X){var re=M(X);if(re.length){re=r.sortBy(re,function(Ne){return O[Ne]});for(var oe=(re.length-1)/2,me=Math.floor(oe),_e=Math.ceil(oe);me<=_e;++me){var Te=re[me];z[X]===X&&j({}));let t=Rn(this.options.nodeSize,0);this.model.forEachNode(_=>{let E=_._original,[q,x]=zi(t(E)),A={width:q,height:x};if(e.setNode(String(_.id),A),this.isCompound()){if(tt(_.parentId))return;e.setParent(String(_.id),String(_.parentId))}});let{edgeLabelSize:i,edgeLabelOffset:n,edgeLabelPos:o,edgeMinLen:s,edgeWeight:a}=this.options,h=Rn(i,0,"edge"),f=no(n,10,"edge"),l=typeof o=="string"?()=>o:ti(o,["edge"]),g=no(s,1,"edge"),m=no(a,1,"edge");this.model.forEachEdge(_=>{let E=_._original,[q,x]=zi(h(E)),A={width:q,height:x,labelpos:l(E),labeloffset:f(E),minlen:g(E),weight:m(E)};e.setEdge(String(_.source),String(_.target),A,String(_.id))}),Bb.layout(e),this.model.forEachNode(_=>{let E=e.node(String(_.id));E&&(_.x=E.x,_.y=E.y,_.size=[E.width,E.height])}),this.model.forEachEdge(_=>{let E=e.edge(String(_.source),String(_.target),String(_.id));if(!E)return;let{width:q,height:x,weight:A,minlen:S,labelpos:I,labeloffset:M,points:D}=E;_.labelSize=[q,x],_.weight=A,_.minLen=S,_.labelPos=I,_.labelOffset=M,_.points=D.map(Yp)})})}isCompound(){return this.isCompoundGraph!==null?this.isCompoundGraph:Vb(this.options.compound)?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(e=>!tt(e.parentId)),this.isCompoundGraph)}};var Ke={};var Tl={};$s(Tl,{isAnyArray:()=>wi});var zI=Object.prototype.toString;function wi(r){let e=zI.call(r);return e.endsWith("Array]")&&!e.includes("Big")}var Xb=vo(Tl);var Ol={};$s(Ol,{default:()=>$I});function Qb(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!wi(r))throw new TypeError("input must be an array");if(r.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,i=t===void 0?0:t,n=e.toIndex,o=n===void 0?r.length:n;if(i<0||i>=r.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>r.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=r[i],a=i+1;as&&(s=r[a]);return s}function Zb(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!wi(r))throw new TypeError("input must be an array");if(r.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,i=t===void 0?0:t,n=e.toIndex,o=n===void 0?r.length:n;if(i<0||i>=r.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>r.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=r[i],a=i+1;a1&&arguments[1]!==void 0?arguments[1]:{};if(wi(r)){if(r.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(e.output!==void 0){if(!wi(e.output))throw new TypeError("output option must be an array if specified");t=e.output}else t=new Array(r.length);var i=Zb(r),n=Qb(r);if(i===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=e.min,s=o===void 0?e.autoMinMax?i:0:o,a=e.max,h=a===void 0?e.autoMinMax?n:1:a;if(s>=h)throw new RangeError("min option must be smaller than max option");for(var f=(h-s)/(n-i),l=0;l=0&&c?` ${h(w,p-1)}`:h(w,p)).padEnd(p)}function h(w,p){let c=w.toString();if(c.length<=p)return c;let u=w.toFixed(p);if(u.length>p&&(u=w.toFixed(Math.max(0,p-(u.length-p)))),u.length<=p&&!u.startsWith("0.000")&&!u.startsWith("-0.000"))return u;let d=w.toExponential(p);return d.length>p&&(d=w.toExponential(Math.max(0,p-(d.length-p)))),d.slice(0)}function f(w,p){w.prototype.add=function(u){return typeof u=="number"?this.addS(u):this.addM(u)},w.prototype.addS=function(u){for(let d=0;d>u);return this},w.prototype.signPropagatingRightShiftM=function(u){if(u=p.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let d=0;d>u.get(d,y));return this},w.signPropagatingRightShift=function(u,d){return new p(u).signPropagatingRightShift(d)},w.prototype.rightShift=function(u){return typeof u=="number"?this.rightShiftS(u):this.rightShiftM(u)},w.prototype.rightShiftS=function(u){for(let d=0;d>>u);return this},w.prototype.rightShiftM=function(u){if(u=p.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let d=0;d>>u.get(d,y));return this},w.rightShift=function(u,d){return new p(u).rightShift(d)},w.prototype.zeroFillRightShift=w.prototype.rightShift,w.prototype.zeroFillRightShiftS=w.prototype.rightShiftS,w.prototype.zeroFillRightShiftM=w.prototype.rightShiftM,w.zeroFillRightShift=w.rightShift,w.prototype.not=function(){for(let u=0;uu)throw new RangeError("Row index out of range")}function g(w,p,c){let u=c?w.columns:w.columns-1;if(p<0||p>u)throw new RangeError("Column index out of range")}function m(w,p){if(p.to1DArray&&(p=p.to1DArray()),p.length!==w.columns)throw new RangeError("vector size must be the same as the number of columns");return p}function _(w,p){if(p.to1DArray&&(p=p.to1DArray()),p.length!==w.rows)throw new RangeError("vector size must be the same as the number of rows");return p}function E(w,p){if(!r.isAnyArray(p))throw new TypeError("row indices must be an array");for(let c=0;c=w.rows)throw new RangeError("row indices are out of range")}function q(w,p){if(!r.isAnyArray(p))throw new TypeError("column indices must be an array");for(let c=0;c=w.columns)throw new RangeError("column indices are out of range")}function x(w,p,c,u,d){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(S("startRow",p),S("endRow",c),S("startColumn",u),S("endColumn",d),p>c||u>d||p<0||p>=w.rows||c<0||c>=w.rows||u<0||u>=w.columns||d<0||d>=w.columns)throw new RangeError("Submatrix indices are out of range")}function A(w,p=0){let c=[];for(let u=0;u=y)throw new RangeError("min must be smaller than max");let C=y-d,T=new W(p,c);for(let L=0;Lu?(y=!0,u=c):(d=!1,y=!0);p++}return d}isReducedEchelonForm(){let p=0,c=0,u=-1,d=!0,y=!1;for(;pu?(y=!0,u=c):(d=!1,y=!0);for(let R=c+1;Rp.get(d,u)&&(d=y);if(p.get(d,u)===0)u++;else{p.swapRows(c,d);let y=p.get(c,u);for(let R=u;R=0;)if(p.maxRow(d)===0)d--;else{let y=0,R=!1;for(;yc[u]&&(c[u]=this.get(u,d));return c}case"column":{let c=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let u=0;uc[d]&&(c[d]=this.get(u,d));return c}case void 0:{let c=this.get(0,0);for(let u=0;uc&&(c=this.get(u,d));return c}default:throw new Error(`invalid option: ${p}`)}}maxIndex(){I(this);let p=this.get(0,0),c=[0,0];for(let u=0;up&&(p=this.get(u,d),c[0]=u,c[1]=d);return c}min(p){if(this.isEmpty())return NaN;switch(p){case"row":{let c=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let u=0;uc&&(c=this.get(p,u));return c}maxRowIndex(p){l(this,p),I(this);let c=this.get(p,0),u=[p,0];for(let d=1;dc&&(c=this.get(p,d),u[1]=d);return u}minRow(p){if(l(this,p),this.isEmpty())return NaN;let c=this.get(p,0);for(let u=1;uc&&(c=this.get(u,p));return c}maxColumnIndex(p){g(this,p),I(this);let c=this.get(0,p),u=[0,p];for(let d=1;dc&&(c=this.get(d,p),u[0]=d);return u}minColumn(p){if(g(this,p),this.isEmpty())return NaN;let c=this.get(0,p);for(let u=1;u=1;d/=2)(d&1)!==0&&(c=c.mmul(u)),u=u.mmul(u);return c}strassen2x2(p){p=W.checkMatrix(p);let c=new W(2,2),u=this.get(0,0),d=p.get(0,0),y=this.get(0,1),R=p.get(0,1),C=this.get(1,0),T=p.get(1,0),L=this.get(1,1),V=p.get(1,1),F=(u+L)*(d+V),ee=(C+L)*d,ce=u*(R-V),H=L*(T-d),se=(u+y)*V,qe=(C-u)*(d+R),$=(y-L)*(T+V),ye=F+H-se+$,Re=ce+se,$e=ee+H,Ue=F-ee+ce+qe;return c.set(0,0,ye),c.set(0,1,Re),c.set(1,0,$e),c.set(1,1,Ue),c}strassen3x3(p){p=W.checkMatrix(p);let c=new W(3,3),u=this.get(0,0),d=this.get(0,1),y=this.get(0,2),R=this.get(1,0),C=this.get(1,1),T=this.get(1,2),L=this.get(2,0),V=this.get(2,1),F=this.get(2,2),ee=p.get(0,0),ce=p.get(0,1),H=p.get(0,2),se=p.get(1,0),qe=p.get(1,1),$=p.get(1,2),ye=p.get(2,0),Re=p.get(2,1),$e=p.get(2,2),Ue=(u+d+y-R-C-V-F)*qe,gr=(u-R)*(-ce+qe),ke=C*(-ee+ce+se-qe-$-ye+$e),je=(-u+R+C)*(ee-ce+qe),ur=(R+C)*(-ee+ce),Y=u*ee,he=(-u+L+V)*(ee-H+$),xe=(-u+L)*(H-$),pe=(L+V)*(-ee+H),mr=(u+d+y-C-T-L-V)*$,ir=V*(-ee+H+se-qe-$-ye+Re),lr=(-y+V+F)*(qe+ye-Re),yr=(y-F)*(qe-Re),Kr=y*ye,It=(V+F)*(-ye+Re),Gr=(-y+C+T)*($+ye-$e),kt=(y-T)*($-$e),Bt=(C+T)*(-ye+$e),Qe=d*se,Yr=T*Re,lt=R*H,dt=L*ce,Nr=F*$e,QE=Y+Kr+Qe,ZE=Ue+je+ur+Y+lr+Kr+It,JE=Y+he+pe+mr+Kr+Gr+Bt,HE=gr+ke+je+Y+Kr+Gr+kt,ex=gr+je+ur+Y+Yr,rx=Kr+Gr+kt+Bt+lt,tx=Y+he+xe+ir+lr+yr+Kr,ix=lr+yr+Kr+It+dt,nx=Y+he+xe+pe+Nr;return c.set(0,0,QE),c.set(0,1,ZE),c.set(0,2,JE),c.set(1,0,HE),c.set(1,1,ex),c.set(1,2,rx),c.set(2,0,tx),c.set(2,1,ix),c.set(2,2,nx),c}mmulStrassen(p){p=W.checkMatrix(p);let c=this.clone(),u=c.rows,d=c.columns,y=p.rows,R=p.columns;d!==y&&console.warn(`Multiplying ${u} x ${d} and ${y} x ${R} matrix: dimensions do not match.`);function C(F,ee,ce){let H=F.rows,se=F.columns;if(H===ee&&se===ce)return F;{let qe=U.zeros(ee,ce);return qe=qe.setSubMatrix(F,0,0),qe}}let T=Math.max(u,y),L=Math.max(d,R);c=C(c,T,L),p=C(p,T,L);function V(F,ee,ce,H){if(ce<=512||H<=512)return F.mmul(ee);ce%2===1&&H%2===1?(F=C(F,ce+1,H+1),ee=C(ee,ce+1,H+1)):ce%2===1?(F=C(F,ce+1,H),ee=C(ee,ce+1,H)):H%2===1&&(F=C(F,ce,H+1),ee=C(ee,ce,H+1));let se=parseInt(F.rows/2,10),qe=parseInt(F.columns/2,10),$=F.subMatrix(0,se-1,0,qe-1),ye=ee.subMatrix(0,se-1,0,qe-1),Re=F.subMatrix(0,se-1,qe,F.columns-1),$e=ee.subMatrix(0,se-1,qe,ee.columns-1),Ue=F.subMatrix(se,F.rows-1,0,qe-1),gr=ee.subMatrix(se,ee.rows-1,0,qe-1),ke=F.subMatrix(se,F.rows-1,qe,F.columns-1),je=ee.subMatrix(se,ee.rows-1,qe,ee.columns-1),ur=V(U.add($,ke),U.add(ye,je),se,qe),Y=V(U.add(Ue,ke),ye,se,qe),he=V($,U.sub($e,je),se,qe),xe=V(ke,U.sub(gr,ye),se,qe),pe=V(U.add($,Re),je,se,qe),mr=V(U.sub(Ue,$),U.add(ye,$e),se,qe),ir=V(U.sub(Re,ke),U.add(gr,je),se,qe),lr=U.add(ur,xe);lr.sub(pe),lr.add(ir);let yr=U.add(he,pe),Kr=U.add(Y,xe),It=U.sub(ur,Y);It.add(he),It.add(mr);let Gr=U.zeros(2*lr.rows,2*lr.columns);return Gr=Gr.setSubMatrix(lr,0,0),Gr=Gr.setSubMatrix(yr,lr.rows,0),Gr=Gr.setSubMatrix(Kr,0,lr.columns),Gr=Gr.setSubMatrix(It,lr.rows,lr.columns),Gr.subMatrix(0,ce-1,0,H-1)}return V(c,p,T,L)}scaleRows(p={}){if(typeof p!="object")throw new TypeError("options must be an object");let{min:c=0,max:u=1}=p;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(c>=u)throw new RangeError("min must be smaller than max");let d=new W(this.rows,this.columns);for(let y=0;y0&&e(R,{min:c,max:u,output:R}),d.setRow(y,R)}return d}scaleColumns(p={}){if(typeof p!="object")throw new TypeError("options must be an object");let{min:c=0,max:u=1}=p;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(c>=u)throw new RangeError("min must be smaller than max");let d=new W(this.rows,this.columns);for(let y=0;yu||c<0||c>=this.columns||u<0||u>=this.columns)throw new RangeError("Argument out of range");let d=new W(p.length,u-c+1);for(let y=0;y=this.rows)throw new RangeError(`Row index out of range: ${p[y]}`);d.set(y,R-c,this.get(p[y],R))}return d}subMatrixColumn(p,c,u){if(c===void 0&&(c=0),u===void 0&&(u=this.rows-1),c>u||c<0||c>=this.rows||u<0||u>=this.rows)throw new RangeError("Argument out of range");let d=new W(u-c+1,p.length);for(let y=0;y=this.columns)throw new RangeError(`Column index out of range: ${p[y]}`);d.set(R-c,y,this.get(R,p[y]))}return d}setSubMatrix(p,c,u){if(p=W.checkMatrix(p),p.isEmpty())return this;let d=c+p.rows-1,y=u+p.columns-1;x(this,c,d,u,y);for(let R=0;Rtypeof p=="number")}U.random=U.rand,U.randomInt=U.randInt,U.diagonal=U.diag,U.prototype.diagonal=U.prototype.diag,U.identity=U.eye,U.prototype.negate=U.prototype.neg,U.prototype.tensorProduct=U.prototype.kroneckerProduct;let ve=class ve extends U{constructor(c,u){super();Ws(this,Q);cd(this,"data");if(ve.isMatrix(c))Bs(this,Q,kl).call(this,c.rows,c.columns),ve.copy(c,this);else if(Number.isInteger(c)&&c>=0)Bs(this,Q,kl).call(this,c,u);else if(r.isAnyArray(c)){let d=c;if(c=d.length,u=c?d[0].length:0,typeof u!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let y=0;y"u"&&(u=c,c=this.columns),g(this,c,!0),u=_(this,u);for(let d=0;d=0)for(let d=0;d=0)$n(this,Ce,new W(c,c));else if($n(this,Ce,new W(c)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return At(this,Ce).size}get rows(){return At(this,Ce).rows}get columns(){return At(this,Ce).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(c){return W.isMatrix(c)&&c.klassType==="SymmetricMatrix"}static zeros(c){return new this(c)}static ones(c){return new this(c).fill(1)}clone(){let c=new Me(this.diagonalSize);for(let[u,d,y]of this.upperRightEntries())c.set(u,d,y);return c}toMatrix(){return new W(this)}get(c,u){return At(this,Ce).get(c,u)}set(c,u,d){return At(this,Ce).set(c,u,d),At(this,Ce).set(u,c,d),this}removeCross(c){return At(this,Ce).removeRow(c),At(this,Ce).removeColumn(c),this}addCross(c,u){u===void 0&&(u=c,c=this.diagonalSize);let d=u.slice();return d.splice(c,1),At(this,Ce).addRow(c,d),At(this,Ce).addColumn(c,u),this}applyMask(c){if(c.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");let u=[];for(let[d,y]of c.entries())y||u.push(d);u.reverse();for(let d of u)this.removeCross(d);return this}toCompact(){let{diagonalSize:c}=this,u=new Array(c*(c+1)/2);for(let d=0,y=0,R=0;R=c&&(d=++y);return u}static fromCompact(c){let u=c.length,d=(Math.sqrt(8*u+1)-1)/2;if(!Number.isInteger(d))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(c)}`);let y=new Me(d);for(let R=0,C=0,T=0;T=d&&(R=++C);return y}*upperRightEntries(){for(let c=0,u=0;c=this.diagonalSize&&(u=++c)}}*upperRightValues(){for(let c=0,u=0;c=this.diagonalSize&&(u=++c)}};Ce=new WeakMap;let ue=Me;ue.prototype.klassType="SymmetricMatrix";class le extends ue{static isDistanceMatrix(p){return ue.isSymmetricMatrix(p)&&p.klassSubType==="DistanceMatrix"}constructor(p){if(super(p),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(p,c,u){return p===c&&(u=0),super.set(p,c,u)}addCross(p,c){return c===void 0&&(c=p,p=this.diagonalSize),c=c.slice(),c[p]=0,super.addCross(p,c)}toSymmetricMatrix(){return new ue(this)}clone(){let p=new le(this.diagonalSize);for(let[c,u,d]of this.upperRightEntries())c!==u&&p.set(c,u,d);return p}toCompact(){let{diagonalSize:p}=this,c=(p-1)*p/2,u=new Array(c);for(let d=1,y=0,R=0;R=p&&(d=++y+1);return u}static fromCompact(p){let c=p.length;if(c===0)return new this(0);let u=(Math.sqrt(8*c+1)+1)/2;if(!Number.isInteger(u))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(p)}`);let d=new this(u);for(let y=1,R=0,C=0;C=u&&(y=++R+1);return d}}le.prototype.klassSubType="DistanceMatrix";class de extends U{constructor(p,c,u){super(),this.matrix=p,this.rows=c,this.columns=u}}class Ye extends de{constructor(p,c){g(p,c),super(p,p.rows,1),this.column=c}set(p,c,u){return this.matrix.set(p,this.column,u),this}get(p){return this.matrix.get(p,this.column)}}class Be extends de{constructor(p,c){q(p,c),super(p,p.rows,c.length),this.columnIndices=c}set(p,c,u){return this.matrix.set(p,this.columnIndices[c],u),this}get(p,c){return this.matrix.get(p,this.columnIndices[c])}}class wr extends de{constructor(p){super(p,p.rows,p.columns)}set(p,c,u){return this.matrix.set(p,this.columns-c-1,u),this}get(p,c){return this.matrix.get(p,this.columns-c-1)}}class er extends de{constructor(p){super(p,p.rows,p.columns)}set(p,c,u){return this.matrix.set(this.rows-p-1,c,u),this}get(p,c){return this.matrix.get(this.rows-p-1,c)}}class qr extends de{constructor(p,c){l(p,c),super(p,1,p.columns),this.row=c}set(p,c,u){return this.matrix.set(this.row,c,u),this}get(p,c){return this.matrix.get(this.row,c)}}class Xe extends de{constructor(p,c){E(p,c),super(p,c.length,p.columns),this.rowIndices=c}set(p,c,u){return this.matrix.set(this.rowIndices[p],c,u),this}get(p,c){return this.matrix.get(this.rowIndices[p],c)}}class Ae extends de{constructor(p,c,u){E(p,c),q(p,u),super(p,c.length,u.length),this.rowIndices=c,this.columnIndices=u}set(p,c,u){return this.matrix.set(this.rowIndices[p],this.columnIndices[c],u),this}get(p,c){return this.matrix.get(this.rowIndices[p],this.columnIndices[c])}}class ze extends de{constructor(p,c,u,d,y){x(p,c,u,d,y),super(p,u-c+1,y-d+1),this.startRow=c,this.startColumn=d}set(p,c,u){return this.matrix.set(this.startRow+p,this.startColumn+c,u),this}get(p,c){return this.matrix.get(this.startRow+p,this.startColumn+c)}}class be extends de{constructor(p){super(p,p.columns,p.rows)}set(p,c,u){return this.matrix.set(c,p,u),this}get(p,c){return this.matrix.get(c,p)}}class sr extends U{constructor(p,c={}){let{rows:u=1}=c;if(p.length%u!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=u,this.columns=p.length/u,this.data=p}set(p,c,u){let d=this._calculateIndex(p,c);return this.data[d]=u,this}get(p,c){let u=this._calculateIndex(p,c);return this.data[u]}_calculateIndex(p,c){return p*this.columns+c}}class Se extends U{constructor(p){super(),this.data=p,this.rows=p.length,this.columns=p[0].length}set(p,c,u){return this.data[p][c]=u,this}get(p,c){return this.data[p][c]}}function Le(w,p){if(r.isAnyArray(w))return w[0]&&r.isAnyArray(w[0])?new Se(w):new sr(w,p);throw new Error("the argument is not an array")}class ie{constructor(p){p=Se.checkMatrix(p);let c=p.clone(),u=c.rows,d=c.columns,y=new Float64Array(u),R=1,C,T,L,V,F,ee,ce,H,se;for(C=0;CMath.abs(H[V])&&(V=C);if(V!==T){for(L=0;L=0;L--){for(T=0;TR?d.set(y,R,p.get(y,R)):y===R?d.set(y,R,1):d.set(y,R,0);return d}get upperTriangularMatrix(){let p=this.LU,c=p.rows,u=p.columns,d=new W(c,u);for(let y=0;yMath.abs(p)?(c=p/w,Math.abs(w)*Math.sqrt(1+c*c)):p!==0?(c=w/p,Math.abs(p)*Math.sqrt(1+c*c)):0}class ar{constructor(p){p=Se.checkMatrix(p);let c=p.clone(),u=p.rows,d=p.columns,y=new Float64Array(d),R,C,T,L;for(T=0;T=0;L--){for(T=0;T=0;C--){for(y=0;y=0;Y--)if(H[Y]!==0){for(let he=Y+1;he=0;Y--){if(Y0;){let Y,he;for(Y=ke-2;Y>=-1&&Y!==-1;Y--){let xe=Number.MIN_VALUE+ur*Math.abs(H[Y]+Math.abs(H[Y+1]));if(Math.abs($[Y])<=xe||Number.isNaN($[Y])){$[Y]=0;break}}if(Y===ke-2)he=4;else{let xe;for(xe=ke-1;xe>=Y&&xe!==Y;xe--){let pe=(xe!==ke?Math.abs($[xe]):0)+(xe!==Y+1?Math.abs($[xe-1]):0);if(Math.abs(H[xe])<=ur*pe){H[xe]=0;break}}xe===Y?he=3:xe===ke-1?he=1:(he=2,Y=xe)}switch(Y++,he){case 1:{let xe=$[ke-2];$[ke-2]=0;for(let pe=ke-2;pe>=Y;pe--){let mr=tr(H[pe],xe),ir=H[pe]/mr,lr=xe/mr;if(H[pe]=mr,pe!==Y&&(xe=-lr*$[pe-1],$[pe-1]=ir*$[pe-1]),L)for(let yr=0;yr=H[Y+1]);){let xe=H[Y];if(H[Y]=H[Y+1],H[Y+1]=xe,L&&Yc&&y.set(V,F,p.get(V,F)/this.s[F]);let R=this.U,C=R.rows,T=R.columns,L=new W(u,C);for(let V=0;Vp&&c++;return c}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return W.diag(this.s)}}function cr(w,p=!1){return w=Se.checkMatrix(w),p?new Tr(w).inverse():$r(w,W.eye(w.rows))}function $r(w,p,c=!1){return w=Se.checkMatrix(w),p=Se.checkMatrix(p),c?new Tr(w).solve(p):w.isSquare()?new ie(w).solve(p):new ar(w).solve(p)}function Hr(w){if(w=W.checkMatrix(w),w.isSquare()){if(w.columns===0)return 1;let p,c,u,d;if(w.columns===2)return p=w.get(0,0),c=w.get(0,1),u=w.get(1,0),d=w.get(1,1),p*d-c*u;if(w.columns===3){let y,R,C;return y=new Ae(w,[1,2],[1,2]),R=new Ae(w,[1,2],[0,2]),C=new Ae(w,[1,2],[0,1]),p=w.get(0,0),c=w.get(0,1),u=w.get(0,2),p*Hr(y)-c*Hr(R)+u*Hr(C)}else return new ie(w).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ct(w,p){let c=[];for(let u=0;ud)return new Array(p.rows+1).fill(0);{let y=p.addRow(c,[0]);for(let R=0;Rp?y[R]=1/y[R]:y[R]=0;return d.mmul(W.diag(y).mmul(u.transpose()))}function v(w,p=w,c={}){w=new W(w);let u=!1;if(typeof p=="object"&&!W.isMatrix(p)&&!r.isAnyArray(p)?(c=p,p=w,u=!0):p=new W(p),w.rows!==p.rows)throw new TypeError("Both matrices must have the same number of rows");let{center:d=!0}=c;d&&(w=w.center("column"),u||(p=p.center("column")));let y=w.transpose().mmul(p);for(let R=0;R0?d.set(y,y+1,c[y]):c[y]<0&&d.set(y,y-1,c[y])}return d}}function G(w,p,c,u){let d,y,R,C,T,L,V,F;for(T=0;T0;C--){for(F=0,R=0,L=0;L0&&(y=-y),p[C]=F*y,R=R-d*y,c[C-1]=d-y,T=0;TL)do{for(d=c[L],F=(c[L+1]-d)/(2*p[L]),ee=tr(F,1),F<0&&(ee=-ee),c[L]=p[L]/(F+ee),c[L+1]=p[L]*(F+ee),ce=c[L+1],y=d-c[L],R=L+2;R=L;R--)for(qe=se,se=H,Re=ye,d=H*p[R],y=H*F,ee=tr(F,p[R]),p[R+1]=ye*ee,ye=p[R]/ee,H=F/ee,F=H*c[R]-ye*d,c[R+1]=y+ye*(H*d+ye*c[R]),T=0;Tgr*Ue);c[L]=c[L]+$e,p[L]=0}for(R=0;R=F;L--)c[L]=p.get(L,F-1)/ee,T+=c[L]*c[L];for(C=Math.sqrt(T),c[F]>0&&(C=-C),T=T-c[F]*C,c[F]=c[F]-C,V=F;V=F;L--)R+=c[L]*p.get(L,V);for(R=R/T,L=F;L<=y;L++)p.set(L,V,p.get(L,V)-R*c[L])}for(L=0;L<=y;L++){for(R=0,V=y;V>=F;V--)R+=c[V]*p.get(L,V);for(R=R/T,V=F;V<=y;V++)p.set(L,V,p.get(L,V)-R*c[V])}c[F]=ee*c[F],p.set(F,F-1,ee*C)}}for(L=0;L=d+1;F--)if(p.get(F,F-1)!==0){for(L=F+1;L<=y;L++)c[L]=p.get(L,F-1);for(V=F;V<=y;V++){for(C=0,L=F;L<=y;L++)C+=c[L]*u.get(L,V);for(C=C/c[F]/p.get(F,F-1),L=F;L<=y;L++)u.set(L,V,u.get(L,V)+C*c[L])}}}function J(w,p,c,u,d){let y=w-1,R=0,C=w-1,T=Number.EPSILON,L=0,V=0,F=0,ee=0,ce=0,H=0,se=0,qe=0,$,ye,Re,$e,Ue,gr,ke,je,ur,Y,he,xe,pe,mr,ir;for($=0;$C)&&(c[$]=d.get($,$),p[$]=0),ye=Math.max($-1,0);ye=R;){for($e=y;$e>R&&(H=Math.abs(d.get($e-1,$e-1))+Math.abs(d.get($e,$e)),H===0&&(H=V),!(Math.abs(d.get($e,$e-1))=0){for(se=F>=0?F+se:F-se,c[y-1]=je+se,c[y]=c[y-1],se!==0&&(c[y]=je-ke/se),p[y-1]=0,p[y]=0,je=d.get(y,y-1),H=Math.abs(je)+Math.abs(se),F=je/H,ee=se/H,ce=Math.sqrt(F*F+ee*ee),F=F/ce,ee=ee/ce,ye=y-1;ye0)){for(H=Math.sqrt(H),ur=$e&&(se=d.get(Ue,Ue),ce=je-se,H=ur-se,F=(ce*H-ke)/d.get(Ue+1,Ue)+d.get(Ue,Ue+1),ee=d.get(Ue+1,Ue+1)-se-ce-H,ce=d.get(Ue+2,Ue+1),H=Math.abs(F)+Math.abs(ee)+Math.abs(ce),F=F/H,ee=ee/H,ce=ce/H,!(Ue===$e||Math.abs(d.get(Ue,Ue-1))*(Math.abs(ee)+Math.abs(ce))Ue+2&&d.set($,$-3,0);for(Re=Ue;Re<=y-1&&(mr=Re!==y-1,Re!==Ue&&(F=d.get(Re,Re-1),ee=d.get(Re+1,Re-1),ce=mr?d.get(Re+2,Re-1):0,je=Math.abs(F)+Math.abs(ee)+Math.abs(ce),je!==0&&(F=F/je,ee=ee/je,ce=ce/je)),je!==0);Re++)if(H=Math.sqrt(F*F+ee*ee+ce*ce),F<0&&(H=-H),H!==0){for(Re!==Ue?d.set(Re,Re-1,-H*je):$e!==Ue&&d.set(Re,Re-1,-d.get(Re,Re-1)),F=F+H,je=F/H,ur=ee/H,se=ce/H,ee=ee/F,ce=ce/F,ye=Re;ye=0;y--)if(F=c[y],ee=p[y],ee===0)for($e=y,d.set(y,y,1),$=y-1;$>=0;$--){for(ke=d.get($,$)-F,ce=0,ye=$e;ye<=y;ye++)ce=ce+d.get($,ye)*d.get(ye,y);if(p[$]<0)se=ke,H=ce;else if($e=$,p[$]===0?d.set($,y,ke!==0?-ce/ke:-ce/(T*V)):(je=d.get($,$+1),ur=d.get($+1,$),ee=(c[$]-F)*(c[$]-F)+p[$]*p[$],gr=(je*H-se*ce)/ee,d.set($,y,gr),d.set($+1,y,Math.abs(je)>Math.abs(se)?(-ce-ke*gr)/je:(-H-ur*gr)/se)),gr=Math.abs(d.get($,y)),T*gr*gr>1)for(ye=$;ye<=y;ye++)d.set(ye,y,d.get(ye,y)/gr)}else if(ee<0)for($e=y-1,Math.abs(d.get(y,y-1))>Math.abs(d.get(y-1,y))?(d.set(y-1,y-1,ee/d.get(y,y-1)),d.set(y-1,y,-(d.get(y,y)-F)/d.get(y,y-1))):(ir=ae(0,-d.get(y-1,y),d.get(y-1,y-1)-F,ee),d.set(y-1,y-1,ir[0]),d.set(y-1,y,ir[1])),d.set(y,y-1,0),d.set(y,y,1),$=y-2;$>=0;$--){for(Y=0,he=0,ye=$e;ye<=y;ye++)Y=Y+d.get($,ye)*d.get(ye,y-1),he=he+d.get($,ye)*d.get(ye,y);if(ke=d.get($,$)-F,p[$]<0)se=ke,ce=Y,H=he;else if($e=$,p[$]===0?(ir=ae(-Y,-he,ke,ee),d.set($,y-1,ir[0]),d.set($,y,ir[1])):(je=d.get($,$+1),ur=d.get($+1,$),xe=(c[$]-F)*(c[$]-F)+p[$]*p[$]-ee*ee,pe=(c[$]-F)*2*ee,xe===0&&pe===0&&(xe=T*V*(Math.abs(ke)+Math.abs(ee)+Math.abs(je)+Math.abs(ur)+Math.abs(se))),ir=ae(je*ce-se*Y+ee*he,je*H-se*he-ee*Y,xe,pe),d.set($,y-1,ir[0]),d.set($,y,ir[1]),Math.abs(je)>Math.abs(se)+Math.abs(ee)?(d.set($+1,y-1,(-Y-ke*d.get($,y-1)+ee*d.get($,y))/je),d.set($+1,y,(-he-ke*d.get($,y)-ee*d.get($,y-1))/je)):(ir=ae(-ce-ur*d.get($,y-1),-H-ur*d.get($,y),se,ee),d.set($+1,y-1,ir[0]),d.set($+1,y,ir[1]))),gr=Math.max(Math.abs(d.get($,y-1)),Math.abs(d.get($,y))),T*gr*gr>1)for(ye=$;ye<=y;ye++)d.set(ye,y-1,d.get(ye,y-1)/gr),d.set(ye,y,d.get(ye,y)/gr)}for($=0;$C)for(ye=$;ye=R;ye--)for($=R;$<=C;$++){for(se=0,Re=R;Re<=Math.min(ye,C);Re++)se=se+u.get($,Re)*d.get(Re,ye);u.set($,ye,se)}}}function ae(w,p,c,u){let d,y;return Math.abs(c)>Math.abs(u)?(d=u/c,y=c+d*u,[(w+d*p)/y,(p-d*w)/y]):(d=c/u,y=u+d*c,[(d*w+p)/y,(d*p-w)/y])}class ne{constructor(p){if(p=Se.checkMatrix(p),!p.isSymmetric())throw new Error("Matrix is not symmetric");let c=p,u=c.rows,d=new W(u,u),y=!0,R,C,T;for(C=0;C0),d.set(C,C,Math.sqrt(Math.max(L,0))),T=C+1;T=0;T--)for(C=0;CR;ce++)F=p.transpose().mmul(C).div(C.transpose().mmul(C).get(0,0)),F=F.div(F.norm()),L=p.mmul(F).div(F.transpose().mmul(F).get(0,0)),ce>0&&(T=L.clone().sub(ee).pow(2).sum()),ee=L.clone(),u?(V=u.transpose().mmul(L).div(L.transpose().mmul(L).get(0,0)),V=V.div(V.norm()),C=u.mmul(V).div(V.transpose().mmul(V).get(0,0))):C=L;if(u){let ce=p.transpose().mmul(L).div(L.transpose().mmul(L).get(0,0));ce=ce.div(ce.norm());let H=p.clone().sub(L.clone().mmul(ce.transpose())),se=C.transpose().mmul(L).div(L.transpose().mmul(L).get(0,0)),qe=u.clone().sub(L.clone().mulS(se.get(0,0)).mmul(V.transpose()));this.t=L,this.p=ce.transpose(),this.w=F.transpose(),this.q=V,this.u=C,this.s=L.transpose().mmul(L),this.xResidual=H,this.yResidual=qe,this.betas=se}else this.w=F.transpose(),this.s=L.transpose().mmul(L).sqrt(),d?this.t=L.clone().div(this.s.get(0,0)):this.t=L,this.xResidual=p.sub(L.mmul(F.transpose()))}}return Ke.AbstractMatrix=U,Ke.CHO=ne,Ke.CholeskyDecomposition=ne,Ke.DistanceMatrix=le,Ke.EVD=k,Ke.EigenvalueDecomposition=k,Ke.LU=ie,Ke.LuDecomposition=ie,Ke.Matrix=W,Ke.MatrixColumnSelectionView=Be,Ke.MatrixColumnView=Ye,Ke.MatrixFlipColumnView=wr,Ke.MatrixFlipRowView=er,Ke.MatrixRowSelectionView=Xe,Ke.MatrixRowView=qr,Ke.MatrixSelectionView=Ae,Ke.MatrixSubView=ze,Ke.MatrixTransposeView=be,Ke.NIPALS=Ee,Ke.Nipals=Ee,Ke.QR=ar,Ke.QrDecomposition=ar,Ke.SVD=Tr,Ke.SingularValueDecomposition=Tr,Ke.SymmetricMatrix=ue,Ke.WrapperMatrix1D=sr,Ke.WrapperMatrix2D=Se,Ke.correlation=b,Ke.covariance=v,Ke.default=W,Ke.determinant=Hr,Ke.inverse=cr,Ke.linearDependencies=St,Ke.pseudoInverse=K,Ke.solve=$r,Ke.wrap=Le,Ke}var Tn=Hb(),Ll=_o(Tn);var Ml=Tn.Matrix,e1=Tn.SingularValueDecomposition;Ll.Matrix?Ll.Matrix:Tn.Matrix;var ws=(r,e)=>{let t=r.nodeCount(),i=Array.from({length:t},()=>[]),n={},o=0;return r.forEachNode(s=>{n[s.id]=o++}),r.forEachEdge(s=>{let a=n[s.source],h=n[s.target];a==null||h==null||(i[a].push(h),e||i[h].push(a))}),i},r1=(r,e)=>{let t=r.length,i=new Array(t);for(let n=0;nnew Array(e).fill(1/0));for(let i=0;i0&&(this.data[0]=t,this.bubbleDown(0)),e}empty(){return this.data.length===0}bubbleUp(e){let t=this.data;for(;e>0;){let i=e-1>>1;if(t[i][0]<=t[e][0])break;[t[i],t[e]]=[t[e],t[i]],e=i}}bubbleDown(e){let t=this.data,i=t.length;for(;;){let n=e*2+1,o=e*2+2,s=e;if(n{let l=a[h++];f.x=l[0]+t[0],f.y=l[1]+t[1]})})}},WI=r=>{let e=Number.NEGATIVE_INFINITY,t=[],i=r.length;for(let n=0;n{try{let i=r.length,n=new Ml(i,i);for(let _=0;_{let t=Object.assign(Object.assign({},t1),e),{maxIteration:i,width:n,k:o,speed:s=t1.speed,strictRadial:a,focusNode:h,radiiMap:f,nodeSizeFunc:l}=t,g=o*.002,m=new Map,_=n/10;for(let E=0;E{m.set(x.id,{x:0,y:0})}),BI(r,m,o,f,l),!(VI(r,m,s,a,h,_,f){let o=0;r.forEachNode(s=>{let a=0;r.forEachNode(h=>{if(a<=o){a++;return}if(s.id===h.id||i.get(s.id)!==i.get(h.id))return;let f=s.x-h.x,l=s.y-h.y,g=Math.sqrt(f*f+l*l);if(g===0){g=1;let E=o>a?1:-1;f=.01*E,l=.01*E}let m=Math.max(...n(s._original)),_=Math.max(...n(h._original));if(g<_/2+m/2){let E=t*t/g,q=e.get(s.id),x=e.get(h.id),A=f/g*E,S=l/g*E;e.set(s.id,{x:q.x+A,y:q.y+S}),e.set(h.id,{x:x.x-A,y:x.y-S})}a++}),o++})},VI=(r,e,t,i,n,o,s)=>{i&&r.forEachNode(f=>{let l=f.x-n.x,g=f.y-n.y,m=Math.sqrt(l*l+g*g),_=g/m,E=-l/m,q=e.get(f.id),x=Math.sqrt(q.x*q.x+q.y*q.y),A=Math.acos((_*q.x+E*q.y)/x);A>Math.PI/2&&(A-=Math.PI/2,_*=-1,E*=-1);let S=Math.cos(A)*x;e.set(f.id,{x:_*S,y:E*S})});let a=0,h=0;return r.forEachNode(f=>{if(f.id===n.id)return;let l=e.get(f.id),g=Math.sqrt(l.x*l.x+l.y*l.y);if(g>0){let m=Math.min(o*(t/800),g);if(f.x+=l.x/g*m,f.y+=l.y/g*m,i){let _=f.x-n.x,E=f.y-n.y,q=Math.sqrt(_*_+E*E);_=_/q*s.get(f.id),E=E/q*s.get(f.id),f.x=n.x+_,f.y=n.y+E}a+=m,h++}}),h>0?a/h:0};var Ti={focusNode:null,linkDistance:50,maxIteration:1e3,maxPreventOverlapIteration:200,preventOverlap:!1,sortStrength:10,strictRadial:!0,unitRadius:null,nodeSize:10,nodeSpacing:0},Es=class extends Dt{constructor(){super(...arguments),this.id="radial"}getDefaultOptions(){return Ti}layout(){return st(this,void 0,void 0,function*(){let{width:e,height:t,center:i}=Wi(this.options),n=this.model.nodeCount();if(!n||n===1)return Ui(this.model,i);let{focusNode:o,linkDistance:s=Ti.linkDistance,maxIteration:a=Ti.maxIteration,maxPreventOverlapIteration:h=Ti.maxPreventOverlapIteration,nodeSize:f,nodeSpacing:l,preventOverlap:g,sortBy:m,sortStrength:_=Ti.sortStrength,strictRadial:E,unitRadius:q}=this.options,x=o&&this.model.node(o)||this.model.firstNode(),A=this.model.nodeIndexOf(x.id),S=ws(this.model,!1),I=qs(S),M=QI(I,A);XI(I,A,M+1);let D=I[A],z=(e-i[0]>i[0]?i[0]:e-i[0])||e/2,O=(t-i[1]>i[1]?i[1]:t-i[1])||t/2,N=Math.min(z,O),j=Math.max(...D),X=[],re=new Map,oe=q??N/j;D.forEach((Oe,B)=>{let pr=Oe*oe;X.push(pr),re.set(this.model.nodeAt(B).id,pr)});let me=KI(this.model,I,s,X,oe,m,_),_e=Pl(me,2,s),Te=_e[A],Ne=0;if(this.model.forEachNode(Oe=>{let B=_e[Ne];Oe.x=B[0]-Te[0],Oe.y=B[1]-Te[1],Ne++}),this.run(a,me,X,A),this.model.forEachNode(Oe=>{Oe.x+=i[0],Oe.y+=i[1]}),g){let B={nodeSizeFunc:oo(f,l,Ti.nodeSize,Ti.nodeSpacing),radiiMap:re,width:e,strictRadial:!!E,focusNode:x,maxIteration:h,k:n/4.5};i1(this.model,B)}})}run(e,t,i,n){let o=YI(t),s=this.model.nodeCount(),a=this.model.nodes(),h=new Float64Array(s),f=new Float64Array(s);for(let l=0;l{let a=e.length,h=new Array(a),f=new Array(a);for(let E=0;E{let e=r.length,t=r[0].length,i=[];for(let n=0;n{let i=r.length;for(let n=0;n{let t=r[e],i=0;for(let n=0;ndn,BubbleSets:()=>Ts,Circle:()=>Mn,Line:()=>Vr,PointPath:()=>zt,Rectangle:()=>it,addPadding:()=>Ul,boundingBox:()=>u1,calculatePotentialOutline:()=>l1,calculateVirtualEdges:()=>h1,circle:()=>iA,createGenericInfluenceArea:()=>Wl,createLineInfluenceArea:()=>Nl,createOutline:()=>yA,createRectangleInfluenceArea:()=>f1,default:()=>Ts,defaultOptions:()=>Bl,line:()=>nA,lineBoundingBox:()=>$l,point:()=>hr,rect:()=>tA,unionBoundingBox:()=>d1});function zl(r,e,t,i,n,o){let s=r,a=e,h=t-s,f=i-a,l=n-s,g=o-a,m=l*h+g*f,_=0;m<=0?_=0:(l=h-l,g=f-g,m=l*h+g*f,m<=0?_=0:_=m*m/(h*h+f*f));let E=l*l+g*g-_;return E<0?0:E}function bi(r,e,t,i){return(r-t)*(r-t)+(e-i)*(e-i)}function n1(r,e,t,i,n){return bi(r,e,t,i)t;if(r===0)return Math.round;let e=Math.pow(10,r);return t=>Math.round(t*e)/e}function $l(r){let e=Math.min(r.x1,r.x2),t=Math.max(r.x1,r.x2),i=Math.min(r.y1,r.y2),n=Math.max(r.y1,r.y2);return{x:e,y:i,x2:t,y2:n,width:t-e,height:n-i}}var Vr=class r{constructor(e,t,i,n){this.x1=e,this.y1=t,this.x2=i,this.y2=n}equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2}draw(e){e.moveTo(this.x1,this.y1),e.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(e){return new r(e.x1,e.y1,e.x2,e.y2)}cuts(e,t){if(this.y1===this.y2||tthis.y1&&t>=this.y2||e>this.x1&&e>=this.x2)return!1;if(ethis.x2+i)return!1}else if(ethis.x1+i)return!1;if(this.y1this.y2+i)return!1}else if(tthis.y1+i)return!1;return!0}},Ar;(function(r){r[r.POINT=1]="POINT",r[r.PARALLEL=2]="PARALLEL",r[r.COINCIDENT=3]="COINCIDENT",r[r.NONE=4]="NONE"})(Ar||(Ar={}));var kn=class{constructor(e,t=0,i=0){this.state=e,this.x=t,this.y=i}};function xs(r,e){let t=(e.x2-e.x1)*(r.y1-e.y1)-(e.y2-e.y1)*(r.x1-e.x1),i=(r.x2-r.x1)*(r.y1-e.y1)-(r.y2-r.y1)*(r.x1-e.x1),n=(e.y2-e.y1)*(r.x2-r.x1)-(e.x2-e.x1)*(r.y2-r.y1);if(n){let o=t/n,s=i/n;return 0<=o&&o<=1&&0<=s&&s<=1?new kn(Ar.POINT,r.x1+o*(r.x2-r.x1),r.y1+o*(r.y2-r.y1)):new kn(Ar.NONE)}return new kn(t===0||i===0?Ar.COINCIDENT:Ar.PARALLEL)}function s1(r,e){let t=(e.x2-e.x1)*(r.y1-e.y1)-(e.y2-e.y1)*(r.x1-e.x1),i=(r.x2-r.x1)*(r.y1-e.y1)-(r.y2-r.y1)*(r.x1-e.x1),n=(e.y2-e.y1)*(r.x2-r.x1)-(e.x2-e.x1)*(r.y2-r.y1);if(n){let o=t/n,s=i/n;if(0<=o&&o<=1&&0<=s&&s<=1)return o}return Number.POSITIVE_INFINITY}function JI(r,e){function t(n,o,s,a){let h=s1(e,new Vr(n,o,s,a));return h=Math.abs(h-.5),h>=0&&h<=1?1:0}let i=t(r.x,r.y,r.x2,r.y);return i+=t(r.x,r.y,r.x,r.y2),i>1||(i+=t(r.x,r.y2,r.x2,r.y2),i>1)?!0:(i+=t(r.x2,r.y,r.x2,r.y2),i>0)}var Rr;(function(r){r[r.LEFT=0]="LEFT",r[r.TOP=1]="TOP",r[r.RIGHT=2]="RIGHT",r[r.BOTTOM=3]="BOTTOM"})(Rr||(Rr={}));function Cs(r,e,t){let i=new Set;return r.width<=0?(i.add(Rr.LEFT),i.add(Rr.RIGHT)):er.x+r.width&&i.add(Rr.RIGHT),r.height<=0?(i.add(Rr.TOP),i.add(Rr.BOTTOM)):tr.y+r.height&&i.add(Rr.BOTTOM),i}function a1(r,e){let t=e.x1,i=e.y1,n=e.x2,o=e.y2,s=Array.from(Cs(r,n,o));if(s.length===0)return!0;let a=Cs(r,t,i);for(;a.size!==0;){for(let h of s)if(a.has(h))return!1;if(a.has(Rr.RIGHT)||a.has(Rr.LEFT)){let h=r.x;a.has(Rr.RIGHT)&&(h+=r.width),i=i+(h-t)*(o-i)/(n-t),t=h}else{let h=r.y;a.has(Rr.BOTTOM)&&(h+=r.height),t=t+(h-i)*(n-t)/(o-i),i=h}a=Cs(r,t,i)}return!0}function HI(r,e){let t=Number.POSITIVE_INFINITY,i=0;function n(o,s,a,h){let f=s1(e,new Vr(o,s,a,h));f=Math.abs(f-.5),f>=0&&f<=1&&(i++,f1||(n(r.x,r.y2,r.x2,r.y2),i>1)?t:(n(r.x2,r.y,r.x2,r.y2),i===0?-1:t)}function eA(r,e){let t=0,i=xs(r,new Vr(e.x,e.y,e.x2,e.y));t+=i.state===Ar.POINT?1:0;let n=xs(r,new Vr(e.x,e.y,e.x,e.y2));t+=n.state===Ar.POINT?1:0;let o=xs(r,new Vr(e.x,e.y2,e.x2,e.y2));t+=o.state===Ar.POINT?1:0;let s=xs(r,new Vr(e.x2,e.y,e.x2,e.y2));return t+=s.state===Ar.POINT?1:0,{top:i,left:n,bottom:o,right:s,count:t}}var it=class r{constructor(e,t,i,n){this.x=e,this.y=t,this.width=i,this.height=n}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(e){return new r(e.x,e.y,e.width,e.height)}equals(e){return this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height}clone(){return new r(this.x,this.y,this.width,this.height)}add(e){let t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x2,e.x+e.width),o=Math.max(this.y2,e.y+e.height);this.x=t,this.y=i,this.width=n-t,this.height=o-i}addPoint(e){let t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x2,e.x),o=Math.max(this.y2,e.y);this.x=t,this.y=i,this.width=n-t,this.height=o-i}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(e){e.rect(this.x,this.y,this.width,this.height)}containsPt(e,t){return e>=this.x&&e<=this.x2&&t>=this.y&&t<=this.y2}get area(){return this.width*this.height}intersects(e){return this.area<=0||e.width<=0||e.height<=0?!1:e.x+e.width>this.x&&e.y+e.height>this.y&&e.x=this.width?this.width-1:e}boundY(e){return e=this.height?this.height-1:e}scaleX(e){return this.boundX(Math.floor((e-this.pixelX)/this.pixelGroup))}scaleY(e){return this.boundY(Math.floor((e-this.pixelY)/this.pixelGroup))}scale(e){let t=this.scaleX(e.x),i=this.scaleY(e.y),n=this.boundX(Math.ceil((e.x+e.width-this.pixelX)/this.pixelGroup)),o=this.boundY(Math.ceil((e.y+e.height-this.pixelY)/this.pixelGroup)),s=n-t,a=o-i;return new it(t,i,s,a)}invertScaleX(e){return Math.round(e*this.pixelGroup+this.pixelX)}invertScaleY(e){return Math.round(e*this.pixelGroup+this.pixelY)}addPadding(e,t){let i=Math.ceil(t/this.pixelGroup),n=this.boundX(e.x-i),o=this.boundY(e.y-i),s=this.boundX(e.x2+i),a=this.boundY(e.y2+i),h=s-n,f=a-o;return new it(n,o,h,f)}get(e,t){return e<0||t<0||e>=this.width||t>=this.height?Number.NaN:this.area[e+t*this.width]}inc(e,t,i){e<0||t<0||e>=this.width||t>=this.height||(this.area[e+t*this.width]+=i)}set(e,t,i){e<0||t<0||e>=this.width||t>=this.height||(this.area[e+t*this.width]=i)}incArea(e,t){if(e.width<=0||e.height<=0||t===0)return;let i=this.width,n=e.width,o=Math.max(0,e.i),s=Math.max(0,e.j),a=Math.min(e.i+e.width,i),h=Math.min(e.j+e.height,this.height);if(!(h<=0||a<=0||o>=i||h>=this.height))for(let f=s;fMath.min(s,a),Number.POSITIVE_INFINITY),n=this.area.reduce((s,a)=>Math.max(s,a),Number.NEGATIVE_INFINITY),o=s=>(s-i)/(n-i);e.scale(this.pixelGroup,this.pixelGroup);for(let s=0;st?"black":"white",e.fillRect(n,o,1,1)}e.restore()}}};function Ul(r,e){let t=i=>({x:i.x-e,y:i.y-e,width:i.width+2*e,height:i.height+2*e});return Array.isArray(r)?r.map(t):t(r)}function Nl(r,e,t){return Wl(Object.assign($l(r),{distSquare:(i,n)=>zl(r.x1,r.y1,r.x2,r.y2,i,n)}),e,t)}function Wl(r,e,t){let i=Ul(r,t),n=e.scale(i),o=e.createSub(n,i);return rA(o,e,t,(s,a)=>r.distSquare(s,a)),o}function rA(r,e,t,i){let n=t*t;for(let o=0;o{let a=n.slice(0,s);return oA(e,o,a,t,i)}).flat()}function oA(r,e,t,i,n){let o=hr(e.cx,e.cy),s=uA(o,t,r);if(s==null)return[];let a=new Vr(o.x,o.y,s.cx,s.cy),h=sA(a,r,i,n);return aA(h,r)}function sA(r,e,t,i){let n=[],o=[];o.push(r);let s=!0;for(let a=0;a0;){let h=o.pop(),f=c1(e,h),l=f?eA(h,f):null;if(!f||!l||l.count!==2){s||n.push(h);continue}let g=i,m=Is(f,g,l,!0),_=qi(m,o)||qi(m,n),E=Ss(m,e);for(;!_&&E&&g>=1;)g/=1.5,m=Is(f,g,l,!0),_=qi(m,o)||qi(m,n),E=Ss(m,e);if(m&&!_&&!E&&(o.push(new Vr(h.x1,h.y1,m.x,m.y)),o.push(new Vr(m.x,m.y,h.x2,h.y2)),s=!0),s)continue;g=i,m=Is(f,g,l,!1);let q=qi(m,o)||qi(m,n);for(E=Ss(m,e);!q&&E&&g>=1;)g/=1.5,m=Is(f,g,l,!1),q=qi(m,o)||qi(m,n),E=Ss(m,e);m&&!q&&(o.push(new Vr(h.x1,h.y1,m.x,m.y)),o.push(new Vr(m.x,m.y,h.x2,h.y2)),s=!0),s||n.push(h)}for(;o.length>0;)n.push(o.pop());return n}function aA(r,e){let t=[];for(;r.length>0;){let i=r.pop();if(r.length===0){t.push(i);break}let n=r.pop(),o=new Vr(i.x1,i.y1,n.x2,n.y2);c1(e,o)?(t.push(i),r.push(n)):r.push(o)}return t}function uA(r,e,t){let i=Number.POSITIVE_INFINITY;return e.reduce((n,o)=>{let s=bi(r.x,r.y,o.cx,o.cy);if(s>i)return n;let a=new Vr(r.x,r.y,o.cx,o.cy),h=hA(t,a);return s*(h+1)*(h+1){e+=i.cx,t+=i.cy}),e/=r.length,t/=r.length,r.map(i=>{let n=e-i.cx,o=t-i.cy,s=n*n+o*o;return[i,s]}).sort((i,n)=>i[1]-n[1]).map(i=>i[0])}function Ss(r,e){return e.some(t=>t.containsPt(r.x,r.y))}function qi(r,e){return e.some(t=>!!(n1(t.x1,t.y1,r.x,r.y,.001)||n1(t.x2,t.y2,r.x,r.y,.001)))}function c1(r,e){let t=Number.POSITIVE_INFINITY,i=null;for(let n of r){if(!a1(n,e))continue;let o=HI(n,e);o>=0&&oa1(i,e)&&JI(i,e)?t+1:t,0)}function Is(r,e,t,i){let n=t.top,o=t.left,s=t.bottom,a=t.right;if(i){if(o.state===Ar.POINT){if(n.state===Ar.POINT)return hr(r.x-e,r.y-e);if(s.state===Ar.POINT)return hr(r.x-e,r.y2+e);let m=r.width*r.height;return r.width*((o.y-r.y+(a.y-r.y))*.5)a.y?hr(r.x-e,r.y-e):hr(r.x2+e,r.y-e):o.ys.x?hr(r.x-e,r.y-e):hr(r.x-e,r.y2+e):n.xa.y?hr(r.x2+e,r.y2+e):hr(r.x-e,r.y2+e):o.ys.x?hr(r.x2+e,r.y2+e):hr(r.x2+e,r.y-e):n.xi)return!1}return!0}function lA(r=0){return e=>{if(r<0||e.length<3)return e;let t=[],i=0,n=r*r;for(;i{if(s.length<3)return s;let a=[],h=s.closed,f=s.length+3-1+(h?0:2);a.push(o(s,2-(h?0:2),0));for(let l=2-(h?0:2);l{let t=r,i=e.length;if(t>1)for(i=Math.floor(e.length/t);i<3&&t>1;)t-=1,i=Math.floor(e.length/t);let n=[];for(let o=0,s=0;s=i?this.closed?this.get(e-i):this.points[i-1]:this.points[t]}get length(){return this.points.length}toString(e=1/0){let t=this.points;if(t.length===0)return"";let i=typeof e=="function"?e:ZI(e),n="M";for(let o of t)n+=`${i(o.x)},${i(o.y)} L`;return n=n.slice(0,-1),this.closed&&(n+=" Z"),n}draw(e){let t=this.points;if(t.length!==0){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i of t)e.lineTo(i.x,i.y);this.closed&&e.closePath()}}sample(e){return gA(e)(this)}simplify(e){return lA(e)(this)}bSplines(e){return pA(e)(this)}apply(e){return e(this)}containsElements(e){let t=u1(this.points);return t?e.every(i=>t.containsPt(i.cx,i.cy)&&this.withinArea(i.cx,i.cy)):!1}withinArea(e,t){if(this.length===0)return!1;let i=0,n=this.points[0],o=new Vr(n.x,n.y,n.x,n.y);for(let s=1;se?l+g:l}function o(h,f){let l=On;return l=n(h,f,l,1),l=n(h+1,f,l,2),l=n(h,f+1,l,4),l=n(h+1,f+1,l,8),Number.isNaN(l)?-1:l}let s=As;function a(h,f){let l=h,g=f,m=r.invertScaleX(l),_=r.invertScaleY(g);for(let E=0;Eo1(i.raw,e));return t<0?!1:(this.members.splice(t,1),this.dirty.add(Tt.MEMBERS),!0)}removeNonMember(e){let t=this.nonMembers.findIndex(i=>o1(i.raw,e));return t<0?!1:(this.nonMembers.splice(t,1),this.dirty.add(Tt.NON_MEMBERS),!0)}removeEdge(e){let t=this.edges.findIndex(i=>i.obj.equals(e));return t<0?!1:(this.edges.splice(t,1),this.dirty.add(Tt.NON_MEMBERS),!0)}pushNonMember(...e){if(e.length!==0){this.dirty.add(Tt.NON_MEMBERS);for(let t of e)this.nonMembers.push({raw:t,obj:Ln(t)?Mn.from(t):it.from(t),area:null})}}pushEdge(...e){if(e.length!==0){this.dirty.add(Tt.EDGES);for(let t of e)this.edges.push({raw:t,obj:Vr.from(t),area:null})}}update(){let e=this.dirty.has(Tt.MEMBERS),t=this.dirty.has(Tt.NON_MEMBERS),i=this.dirty.has(Tt.EDGES);this.dirty.clear();let n=this.members.map(f=>f.obj);if(this.o.virtualEdges&&(e||t)){let f=this.nonMembers.map(m=>m.obj),l=h1(n,f,this.o.maxRoutingIterations,this.o.morphBuffer),g=new Map(this.virtualEdges.map(m=>[m.obj.toString(),m.area]));this.virtualEdges=l.map(m=>{var _;return{raw:m,obj:m,area:(_=g.get(m.toString()))!==null&&_!==void 0?_:null}}),i=!0}let o=!1;if(e||i){let f=this.virtualEdges.concat(this.edges).map(_=>_.obj),l=d1(n,f),g=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,m=it.from(Ul(l,g));m.equals(this.activeRegion)||(o=!0,this.activeRegion=m)}if(o){let f=Math.ceil(this.activeRegion.width/this.o.pixelGroup),l=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=dn.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach(g=>g.area=null),this.nonMembers.forEach(g=>g.area=null),this.edges.forEach(g=>g.area=null),this.virtualEdges.forEach(g=>g.area=null)):(f!==this.potentialArea.width||l!==this.potentialArea.height)&&(this.potentialArea=dn.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}let s=new Map,a=f=>{if(f.area){let l=`${f.obj.width}x${f.obj.height}x${f.obj instanceof it?"R":"C"}`;s.set(l,f.area)}},h=f=>{if(f.area)return;let l=`${f.obj.width}x${f.obj.height}x${f.obj instanceof it?"R":"C"}`;if(s.has(l)){let m=s.get(l);f.area=this.potentialArea.copy(m,{x:f.obj.x-this.o.nodeR1,y:f.obj.y-this.o.nodeR1});return}let g=f.obj instanceof it?f1(f.obj,this.potentialArea,this.o.nodeR1):Wl(f.obj,this.potentialArea,this.o.nodeR1);f.area=g,s.set(l,g)};this.members.forEach(a),this.nonMembers.forEach(a),this.members.forEach(h),this.nonMembers.forEach(f=>{this.activeRegion.intersects(f.obj)?h(f):f.area=null}),this.edges.forEach(f=>{f.area||(f.area=Nl(f.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(f=>{f.area||(f.area=Nl(f.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(e){for(let t of this.members)t.obj.draw(e)}drawNonMembers(e){for(let t of this.nonMembers)t.obj.draw(e)}drawEdges(e){for(let t of this.edges)t.obj.draw(e)}drawPotentialArea(e,t=!0){this.potentialArea.draw(e,t)}compute(){if(this.members.length===0)return new zt([]);this.dirty.size>0&&this.update();let{o:e,potentialArea:t}=this,i=this.members.map(a=>a.area),n=this.virtualEdges.concat(this.edges).map(a=>a.area),o=this.nonMembers.filter(a=>a.area!=null).map(a=>a.area),s=this.members.map(a=>a.obj);return l1(t,i,n,o,a=>a.containsElements(s),e)}};function l1(r,e,t,i,n,o={}){let s=Object.assign({},Bl,o),a=s.threshold,h=s.memberInfluenceFactor,f=s.edgeInfluenceFactor,l=s.nonMemberInfluenceFactor,g=(s.nodeR0-s.nodeR1)*(s.nodeR0-s.nodeR1),m=(s.edgeR0-s.edgeR1)*(s.edgeR0-s.edgeR1);for(let _=0;_0)l*=.8;else break}return new zt([])}function d1(r,e){if(r.length===0)return new it(0,0,0,0);let t=it.from(r[0]);for(let i of r)t.add(i);for(let i of e)t.add($l(i));return t}function yA(r,e=[],t=[],i={}){if(r.length===0)return new zt([]);let n=new Ts(i);return n.pushMember(...r),n.pushNonMember(...e),n.pushEdge(...t),n.compute()}var rC=et(g1(),1),tC=et(v1(),1),iC=et(V1(),1),nC=et(H1(),1),oC=et(iE(),1),sC=et(aE(),1),aC=et(hE(),1),uC=et(qE(),1),fC=et(CE(),1),hC=et(XE(),1);var export_FA2Layout=HR.default;var export_betweennessCentrality=iC.default;var export_circlepack=zs.circlepack;var export_circular=zs.circular;var export_closenessCentrality=nC.default;var export_degreeCentrality=tC.degreeCentrality;var export_density=aC.density;var export_diameter=uC.default;var export_eigenvectorCentrality=oC.default;var export_forceAtlas2=JR.default;var export_louvain=hC.default;var export_modularity=fC.default;var export_noverlap=eC.default;var export_pagerank=sC.default;var export_polygonClipping=rC.default;var export_random=zs.random;var export_rotation=zs.rotation;export{mo as ConcentricLayout,vs as DagreLayout,export_FA2Layout as FA2Layout,fr as Graph,bs as MDSLayout,Es as RadialLayout,export_betweennessCentrality as betweennessCentrality,p1 as bubblesets,export_circlepack as circlepack,export_circular as circular,export_closenessCentrality as closenessCentrality,export_degreeCentrality as degreeCentrality,export_density as density,export_diameter as diameter,export_eigenvectorCentrality as eigenvectorCentrality,export_forceAtlas2 as forceAtlas2,export_louvain as louvain,export_modularity as modularity,export_noverlap as noverlap,export_pagerank as pagerank,export_polygonClipping as polygonClipping,export_random as random,export_rotation as rotation}; +${i}`)}function a(w,p,c){return(w>=0&&c?` ${h(w,p-1)}`:h(w,p)).padEnd(p)}function h(w,p){let c=w.toString();if(c.length<=p)return c;let u=w.toFixed(p);if(u.length>p&&(u=w.toFixed(Math.max(0,p-(u.length-p)))),u.length<=p&&!u.startsWith("0.000")&&!u.startsWith("-0.000"))return u;let d=w.toExponential(p);return d.length>p&&(d=w.toExponential(Math.max(0,p-(d.length-p)))),d.slice(0)}function f(w,p){w.prototype.add=function(u){return typeof u=="number"?this.addS(u):this.addM(u)},w.prototype.addS=function(u){for(let d=0;d>u);return this},w.prototype.signPropagatingRightShiftM=function(u){if(u=p.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let d=0;d>u.get(d,y));return this},w.signPropagatingRightShift=function(u,d){return new p(u).signPropagatingRightShift(d)},w.prototype.rightShift=function(u){return typeof u=="number"?this.rightShiftS(u):this.rightShiftM(u)},w.prototype.rightShiftS=function(u){for(let d=0;d>>u);return this},w.prototype.rightShiftM=function(u){if(u=p.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let d=0;d>>u.get(d,y));return this},w.rightShift=function(u,d){return new p(u).rightShift(d)},w.prototype.zeroFillRightShift=w.prototype.rightShift,w.prototype.zeroFillRightShiftS=w.prototype.rightShiftS,w.prototype.zeroFillRightShiftM=w.prototype.rightShiftM,w.zeroFillRightShift=w.rightShift,w.prototype.not=function(){for(let u=0;uu)throw new RangeError("Row index out of range")}function g(w,p,c){let u=c?w.columns:w.columns-1;if(p<0||p>u)throw new RangeError("Column index out of range")}function m(w,p){if(p.to1DArray&&(p=p.to1DArray()),p.length!==w.columns)throw new RangeError("vector size must be the same as the number of columns");return p}function _(w,p){if(p.to1DArray&&(p=p.to1DArray()),p.length!==w.rows)throw new RangeError("vector size must be the same as the number of rows");return p}function E(w,p){if(!r.isAnyArray(p))throw new TypeError("row indices must be an array");for(let c=0;c=w.rows)throw new RangeError("row indices are out of range")}function q(w,p){if(!r.isAnyArray(p))throw new TypeError("column indices must be an array");for(let c=0;c=w.columns)throw new RangeError("column indices are out of range")}function x(w,p,c,u,d){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(S("startRow",p),S("endRow",c),S("startColumn",u),S("endColumn",d),p>c||u>d||p<0||p>=w.rows||c<0||c>=w.rows||u<0||u>=w.columns||d<0||d>=w.columns)throw new RangeError("Submatrix indices are out of range")}function A(w,p=0){let c=[];for(let u=0;u=y)throw new RangeError("min must be smaller than max");let C=y-d,T=new W(p,c);for(let L=0;Lu?(y=!0,u=c):(d=!1,y=!0);p++}return d}isReducedEchelonForm(){let p=0,c=0,u=-1,d=!0,y=!1;for(;pu?(y=!0,u=c):(d=!1,y=!0);for(let R=c+1;Rp.get(d,u)&&(d=y);if(p.get(d,u)===0)u++;else{p.swapRows(c,d);let y=p.get(c,u);for(let R=u;R=0;)if(p.maxRow(d)===0)d--;else{let y=0,R=!1;for(;yc[u]&&(c[u]=this.get(u,d));return c}case"column":{let c=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let u=0;uc[d]&&(c[d]=this.get(u,d));return c}case void 0:{let c=this.get(0,0);for(let u=0;uc&&(c=this.get(u,d));return c}default:throw new Error(`invalid option: ${p}`)}}maxIndex(){I(this);let p=this.get(0,0),c=[0,0];for(let u=0;up&&(p=this.get(u,d),c[0]=u,c[1]=d);return c}min(p){if(this.isEmpty())return NaN;switch(p){case"row":{let c=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let u=0;uc&&(c=this.get(p,u));return c}maxRowIndex(p){l(this,p),I(this);let c=this.get(p,0),u=[p,0];for(let d=1;dc&&(c=this.get(p,d),u[1]=d);return u}minRow(p){if(l(this,p),this.isEmpty())return NaN;let c=this.get(p,0);for(let u=1;uc&&(c=this.get(u,p));return c}maxColumnIndex(p){g(this,p),I(this);let c=this.get(0,p),u=[0,p];for(let d=1;dc&&(c=this.get(d,p),u[0]=d);return u}minColumn(p){if(g(this,p),this.isEmpty())return NaN;let c=this.get(0,p);for(let u=1;u=1;d/=2)(d&1)!==0&&(c=c.mmul(u)),u=u.mmul(u);return c}strassen2x2(p){p=W.checkMatrix(p);let c=new W(2,2),u=this.get(0,0),d=p.get(0,0),y=this.get(0,1),R=p.get(0,1),C=this.get(1,0),T=p.get(1,0),L=this.get(1,1),V=p.get(1,1),F=(u+L)*(d+V),ee=(C+L)*d,ce=u*(R-V),H=L*(T-d),se=(u+y)*V,qe=(C-u)*(d+R),$=(y-L)*(T+V),ye=F+H-se+$,Re=ce+se,$e=ee+H,Ue=F-ee+ce+qe;return c.set(0,0,ye),c.set(0,1,Re),c.set(1,0,$e),c.set(1,1,Ue),c}strassen3x3(p){p=W.checkMatrix(p);let c=new W(3,3),u=this.get(0,0),d=this.get(0,1),y=this.get(0,2),R=this.get(1,0),C=this.get(1,1),T=this.get(1,2),L=this.get(2,0),V=this.get(2,1),F=this.get(2,2),ee=p.get(0,0),ce=p.get(0,1),H=p.get(0,2),se=p.get(1,0),qe=p.get(1,1),$=p.get(1,2),ye=p.get(2,0),Re=p.get(2,1),$e=p.get(2,2),Ue=(u+d+y-R-C-V-F)*qe,gr=(u-R)*(-ce+qe),ke=C*(-ee+ce+se-qe-$-ye+$e),je=(-u+R+C)*(ee-ce+qe),ur=(R+C)*(-ee+ce),Y=u*ee,he=(-u+L+V)*(ee-H+$),xe=(-u+L)*(H-$),pe=(L+V)*(-ee+H),mr=(u+d+y-C-T-L-V)*$,ir=V*(-ee+H+se-qe-$-ye+Re),lr=(-y+V+F)*(qe+ye-Re),yr=(y-F)*(qe-Re),Kr=y*ye,It=(V+F)*(-ye+Re),Gr=(-y+C+T)*($+ye-$e),kt=(y-T)*($-$e),Bt=(C+T)*(-ye+$e),Qe=d*se,Yr=T*Re,lt=R*H,dt=L*ce,Nr=F*$e,QE=Y+Kr+Qe,ZE=Ue+je+ur+Y+lr+Kr+It,JE=Y+he+pe+mr+Kr+Gr+Bt,HE=gr+ke+je+Y+Kr+Gr+kt,ex=gr+je+ur+Y+Yr,rx=Kr+Gr+kt+Bt+lt,tx=Y+he+xe+ir+lr+yr+Kr,ix=lr+yr+Kr+It+dt,nx=Y+he+xe+pe+Nr;return c.set(0,0,QE),c.set(0,1,ZE),c.set(0,2,JE),c.set(1,0,HE),c.set(1,1,ex),c.set(1,2,rx),c.set(2,0,tx),c.set(2,1,ix),c.set(2,2,nx),c}mmulStrassen(p){p=W.checkMatrix(p);let c=this.clone(),u=c.rows,d=c.columns,y=p.rows,R=p.columns;d!==y&&console.warn(`Multiplying ${u} x ${d} and ${y} x ${R} matrix: dimensions do not match.`);function C(F,ee,ce){let H=F.rows,se=F.columns;if(H===ee&&se===ce)return F;{let qe=U.zeros(ee,ce);return qe=qe.setSubMatrix(F,0,0),qe}}let T=Math.max(u,y),L=Math.max(d,R);c=C(c,T,L),p=C(p,T,L);function V(F,ee,ce,H){if(ce<=512||H<=512)return F.mmul(ee);ce%2===1&&H%2===1?(F=C(F,ce+1,H+1),ee=C(ee,ce+1,H+1)):ce%2===1?(F=C(F,ce+1,H),ee=C(ee,ce+1,H)):H%2===1&&(F=C(F,ce,H+1),ee=C(ee,ce,H+1));let se=parseInt(F.rows/2,10),qe=parseInt(F.columns/2,10),$=F.subMatrix(0,se-1,0,qe-1),ye=ee.subMatrix(0,se-1,0,qe-1),Re=F.subMatrix(0,se-1,qe,F.columns-1),$e=ee.subMatrix(0,se-1,qe,ee.columns-1),Ue=F.subMatrix(se,F.rows-1,0,qe-1),gr=ee.subMatrix(se,ee.rows-1,0,qe-1),ke=F.subMatrix(se,F.rows-1,qe,F.columns-1),je=ee.subMatrix(se,ee.rows-1,qe,ee.columns-1),ur=V(U.add($,ke),U.add(ye,je),se,qe),Y=V(U.add(Ue,ke),ye,se,qe),he=V($,U.sub($e,je),se,qe),xe=V(ke,U.sub(gr,ye),se,qe),pe=V(U.add($,Re),je,se,qe),mr=V(U.sub(Ue,$),U.add(ye,$e),se,qe),ir=V(U.sub(Re,ke),U.add(gr,je),se,qe),lr=U.add(ur,xe);lr.sub(pe),lr.add(ir);let yr=U.add(he,pe),Kr=U.add(Y,xe),It=U.sub(ur,Y);It.add(he),It.add(mr);let Gr=U.zeros(2*lr.rows,2*lr.columns);return Gr=Gr.setSubMatrix(lr,0,0),Gr=Gr.setSubMatrix(yr,lr.rows,0),Gr=Gr.setSubMatrix(Kr,0,lr.columns),Gr=Gr.setSubMatrix(It,lr.rows,lr.columns),Gr.subMatrix(0,ce-1,0,H-1)}return V(c,p,T,L)}scaleRows(p={}){if(typeof p!="object")throw new TypeError("options must be an object");let{min:c=0,max:u=1}=p;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(c>=u)throw new RangeError("min must be smaller than max");let d=new W(this.rows,this.columns);for(let y=0;y0&&e(R,{min:c,max:u,output:R}),d.setRow(y,R)}return d}scaleColumns(p={}){if(typeof p!="object")throw new TypeError("options must be an object");let{min:c=0,max:u=1}=p;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(c>=u)throw new RangeError("min must be smaller than max");let d=new W(this.rows,this.columns);for(let y=0;yu||c<0||c>=this.columns||u<0||u>=this.columns)throw new RangeError("Argument out of range");let d=new W(p.length,u-c+1);for(let y=0;y=this.rows)throw new RangeError(`Row index out of range: ${p[y]}`);d.set(y,R-c,this.get(p[y],R))}return d}subMatrixColumn(p,c,u){if(c===void 0&&(c=0),u===void 0&&(u=this.rows-1),c>u||c<0||c>=this.rows||u<0||u>=this.rows)throw new RangeError("Argument out of range");let d=new W(u-c+1,p.length);for(let y=0;y=this.columns)throw new RangeError(`Column index out of range: ${p[y]}`);d.set(R-c,y,this.get(R,p[y]))}return d}setSubMatrix(p,c,u){if(p=W.checkMatrix(p),p.isEmpty())return this;let d=c+p.rows-1,y=u+p.columns-1;x(this,c,d,u,y);for(let R=0;Rtypeof p=="number")}U.random=U.rand,U.randomInt=U.randInt,U.diagonal=U.diag,U.prototype.diagonal=U.prototype.diag,U.identity=U.eye,U.prototype.negate=U.prototype.neg,U.prototype.tensorProduct=U.prototype.kroneckerProduct;let ve=class ve extends U{constructor(c,u){super();Ws(this,Q);ld(this,"data");if(ve.isMatrix(c))Bs(this,Q,kl).call(this,c.rows,c.columns),ve.copy(c,this);else if(Number.isInteger(c)&&c>=0)Bs(this,Q,kl).call(this,c,u);else if(r.isAnyArray(c)){let d=c;if(c=d.length,u=c?d[0].length:0,typeof u!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let y=0;y"u"&&(u=c,c=this.columns),g(this,c,!0),u=_(this,u);for(let d=0;d=0)for(let d=0;d=0)$n(this,Ce,new W(c,c));else if($n(this,Ce,new W(c)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return At(this,Ce).size}get rows(){return At(this,Ce).rows}get columns(){return At(this,Ce).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(c){return W.isMatrix(c)&&c.klassType==="SymmetricMatrix"}static zeros(c){return new this(c)}static ones(c){return new this(c).fill(1)}clone(){let c=new Me(this.diagonalSize);for(let[u,d,y]of this.upperRightEntries())c.set(u,d,y);return c}toMatrix(){return new W(this)}get(c,u){return At(this,Ce).get(c,u)}set(c,u,d){return At(this,Ce).set(c,u,d),At(this,Ce).set(u,c,d),this}removeCross(c){return At(this,Ce).removeRow(c),At(this,Ce).removeColumn(c),this}addCross(c,u){u===void 0&&(u=c,c=this.diagonalSize);let d=u.slice();return d.splice(c,1),At(this,Ce).addRow(c,d),At(this,Ce).addColumn(c,u),this}applyMask(c){if(c.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");let u=[];for(let[d,y]of c.entries())y||u.push(d);u.reverse();for(let d of u)this.removeCross(d);return this}toCompact(){let{diagonalSize:c}=this,u=new Array(c*(c+1)/2);for(let d=0,y=0,R=0;R=c&&(d=++y);return u}static fromCompact(c){let u=c.length,d=(Math.sqrt(8*u+1)-1)/2;if(!Number.isInteger(d))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(c)}`);let y=new Me(d);for(let R=0,C=0,T=0;T=d&&(R=++C);return y}*upperRightEntries(){for(let c=0,u=0;c=this.diagonalSize&&(u=++c)}}*upperRightValues(){for(let c=0,u=0;c=this.diagonalSize&&(u=++c)}};Ce=new WeakMap;let ue=Me;ue.prototype.klassType="SymmetricMatrix";class le extends ue{static isDistanceMatrix(p){return ue.isSymmetricMatrix(p)&&p.klassSubType==="DistanceMatrix"}constructor(p){if(super(p),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(p,c,u){return p===c&&(u=0),super.set(p,c,u)}addCross(p,c){return c===void 0&&(c=p,p=this.diagonalSize),c=c.slice(),c[p]=0,super.addCross(p,c)}toSymmetricMatrix(){return new ue(this)}clone(){let p=new le(this.diagonalSize);for(let[c,u,d]of this.upperRightEntries())c!==u&&p.set(c,u,d);return p}toCompact(){let{diagonalSize:p}=this,c=(p-1)*p/2,u=new Array(c);for(let d=1,y=0,R=0;R=p&&(d=++y+1);return u}static fromCompact(p){let c=p.length;if(c===0)return new this(0);let u=(Math.sqrt(8*c+1)+1)/2;if(!Number.isInteger(u))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(p)}`);let d=new this(u);for(let y=1,R=0,C=0;C=u&&(y=++R+1);return d}}le.prototype.klassSubType="DistanceMatrix";class de extends U{constructor(p,c,u){super(),this.matrix=p,this.rows=c,this.columns=u}}class Ye extends de{constructor(p,c){g(p,c),super(p,p.rows,1),this.column=c}set(p,c,u){return this.matrix.set(p,this.column,u),this}get(p){return this.matrix.get(p,this.column)}}class Be extends de{constructor(p,c){q(p,c),super(p,p.rows,c.length),this.columnIndices=c}set(p,c,u){return this.matrix.set(p,this.columnIndices[c],u),this}get(p,c){return this.matrix.get(p,this.columnIndices[c])}}class wr extends de{constructor(p){super(p,p.rows,p.columns)}set(p,c,u){return this.matrix.set(p,this.columns-c-1,u),this}get(p,c){return this.matrix.get(p,this.columns-c-1)}}class er extends de{constructor(p){super(p,p.rows,p.columns)}set(p,c,u){return this.matrix.set(this.rows-p-1,c,u),this}get(p,c){return this.matrix.get(this.rows-p-1,c)}}class qr extends de{constructor(p,c){l(p,c),super(p,1,p.columns),this.row=c}set(p,c,u){return this.matrix.set(this.row,c,u),this}get(p,c){return this.matrix.get(this.row,c)}}class Xe extends de{constructor(p,c){E(p,c),super(p,c.length,p.columns),this.rowIndices=c}set(p,c,u){return this.matrix.set(this.rowIndices[p],c,u),this}get(p,c){return this.matrix.get(this.rowIndices[p],c)}}class Ae extends de{constructor(p,c,u){E(p,c),q(p,u),super(p,c.length,u.length),this.rowIndices=c,this.columnIndices=u}set(p,c,u){return this.matrix.set(this.rowIndices[p],this.columnIndices[c],u),this}get(p,c){return this.matrix.get(this.rowIndices[p],this.columnIndices[c])}}class ze extends de{constructor(p,c,u,d,y){x(p,c,u,d,y),super(p,u-c+1,y-d+1),this.startRow=c,this.startColumn=d}set(p,c,u){return this.matrix.set(this.startRow+p,this.startColumn+c,u),this}get(p,c){return this.matrix.get(this.startRow+p,this.startColumn+c)}}class be extends de{constructor(p){super(p,p.columns,p.rows)}set(p,c,u){return this.matrix.set(c,p,u),this}get(p,c){return this.matrix.get(c,p)}}class sr extends U{constructor(p,c={}){let{rows:u=1}=c;if(p.length%u!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=u,this.columns=p.length/u,this.data=p}set(p,c,u){let d=this._calculateIndex(p,c);return this.data[d]=u,this}get(p,c){let u=this._calculateIndex(p,c);return this.data[u]}_calculateIndex(p,c){return p*this.columns+c}}class Se extends U{constructor(p){super(),this.data=p,this.rows=p.length,this.columns=p[0].length}set(p,c,u){return this.data[p][c]=u,this}get(p,c){return this.data[p][c]}}function Le(w,p){if(r.isAnyArray(w))return w[0]&&r.isAnyArray(w[0])?new Se(w):new sr(w,p);throw new Error("the argument is not an array")}class ie{constructor(p){p=Se.checkMatrix(p);let c=p.clone(),u=c.rows,d=c.columns,y=new Float64Array(u),R=1,C,T,L,V,F,ee,ce,H,se;for(C=0;CMath.abs(H[V])&&(V=C);if(V!==T){for(L=0;L=0;L--){for(T=0;TR?d.set(y,R,p.get(y,R)):y===R?d.set(y,R,1):d.set(y,R,0);return d}get upperTriangularMatrix(){let p=this.LU,c=p.rows,u=p.columns,d=new W(c,u);for(let y=0;yMath.abs(p)?(c=p/w,Math.abs(w)*Math.sqrt(1+c*c)):p!==0?(c=w/p,Math.abs(p)*Math.sqrt(1+c*c)):0}class ar{constructor(p){p=Se.checkMatrix(p);let c=p.clone(),u=p.rows,d=p.columns,y=new Float64Array(d),R,C,T,L;for(T=0;T=0;L--){for(T=0;T=0;C--){for(y=0;y=0;Y--)if(H[Y]!==0){for(let he=Y+1;he=0;Y--){if(Y0;){let Y,he;for(Y=ke-2;Y>=-1&&Y!==-1;Y--){let xe=Number.MIN_VALUE+ur*Math.abs(H[Y]+Math.abs(H[Y+1]));if(Math.abs($[Y])<=xe||Number.isNaN($[Y])){$[Y]=0;break}}if(Y===ke-2)he=4;else{let xe;for(xe=ke-1;xe>=Y&&xe!==Y;xe--){let pe=(xe!==ke?Math.abs($[xe]):0)+(xe!==Y+1?Math.abs($[xe-1]):0);if(Math.abs(H[xe])<=ur*pe){H[xe]=0;break}}xe===Y?he=3:xe===ke-1?he=1:(he=2,Y=xe)}switch(Y++,he){case 1:{let xe=$[ke-2];$[ke-2]=0;for(let pe=ke-2;pe>=Y;pe--){let mr=tr(H[pe],xe),ir=H[pe]/mr,lr=xe/mr;if(H[pe]=mr,pe!==Y&&(xe=-lr*$[pe-1],$[pe-1]=ir*$[pe-1]),L)for(let yr=0;yr=H[Y+1]);){let xe=H[Y];if(H[Y]=H[Y+1],H[Y+1]=xe,L&&Yc&&y.set(V,F,p.get(V,F)/this.s[F]);let R=this.U,C=R.rows,T=R.columns,L=new W(u,C);for(let V=0;Vp&&c++;return c}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return W.diag(this.s)}}function cr(w,p=!1){return w=Se.checkMatrix(w),p?new Tr(w).inverse():$r(w,W.eye(w.rows))}function $r(w,p,c=!1){return w=Se.checkMatrix(w),p=Se.checkMatrix(p),c?new Tr(w).solve(p):w.isSquare()?new ie(w).solve(p):new ar(w).solve(p)}function et(w){if(w=W.checkMatrix(w),w.isSquare()){if(w.columns===0)return 1;let p,c,u,d;if(w.columns===2)return p=w.get(0,0),c=w.get(0,1),u=w.get(1,0),d=w.get(1,1),p*d-c*u;if(w.columns===3){let y,R,C;return y=new Ae(w,[1,2],[1,2]),R=new Ae(w,[1,2],[0,2]),C=new Ae(w,[1,2],[0,1]),p=w.get(0,0),c=w.get(0,1),u=w.get(0,2),p*et(y)-c*et(R)+u*et(C)}else return new ie(w).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ct(w,p){let c=[];for(let u=0;ud)return new Array(p.rows+1).fill(0);{let y=p.addRow(c,[0]);for(let R=0;Rp?y[R]=1/y[R]:y[R]=0;return d.mmul(W.diag(y).mmul(u.transpose()))}function v(w,p=w,c={}){w=new W(w);let u=!1;if(typeof p=="object"&&!W.isMatrix(p)&&!r.isAnyArray(p)?(c=p,p=w,u=!0):p=new W(p),w.rows!==p.rows)throw new TypeError("Both matrices must have the same number of rows");let{center:d=!0}=c;d&&(w=w.center("column"),u||(p=p.center("column")));let y=w.transpose().mmul(p);for(let R=0;R0?d.set(y,y+1,c[y]):c[y]<0&&d.set(y,y-1,c[y])}return d}}function G(w,p,c,u){let d,y,R,C,T,L,V,F;for(T=0;T0;C--){for(F=0,R=0,L=0;L0&&(y=-y),p[C]=F*y,R=R-d*y,c[C-1]=d-y,T=0;TL)do{for(d=c[L],F=(c[L+1]-d)/(2*p[L]),ee=tr(F,1),F<0&&(ee=-ee),c[L]=p[L]/(F+ee),c[L+1]=p[L]*(F+ee),ce=c[L+1],y=d-c[L],R=L+2;R=L;R--)for(qe=se,se=H,Re=ye,d=H*p[R],y=H*F,ee=tr(F,p[R]),p[R+1]=ye*ee,ye=p[R]/ee,H=F/ee,F=H*c[R]-ye*d,c[R+1]=y+ye*(H*d+ye*c[R]),T=0;Tgr*Ue);c[L]=c[L]+$e,p[L]=0}for(R=0;R=F;L--)c[L]=p.get(L,F-1)/ee,T+=c[L]*c[L];for(C=Math.sqrt(T),c[F]>0&&(C=-C),T=T-c[F]*C,c[F]=c[F]-C,V=F;V=F;L--)R+=c[L]*p.get(L,V);for(R=R/T,L=F;L<=y;L++)p.set(L,V,p.get(L,V)-R*c[L])}for(L=0;L<=y;L++){for(R=0,V=y;V>=F;V--)R+=c[V]*p.get(L,V);for(R=R/T,V=F;V<=y;V++)p.set(L,V,p.get(L,V)-R*c[V])}c[F]=ee*c[F],p.set(F,F-1,ee*C)}}for(L=0;L=d+1;F--)if(p.get(F,F-1)!==0){for(L=F+1;L<=y;L++)c[L]=p.get(L,F-1);for(V=F;V<=y;V++){for(C=0,L=F;L<=y;L++)C+=c[L]*u.get(L,V);for(C=C/c[F]/p.get(F,F-1),L=F;L<=y;L++)u.set(L,V,u.get(L,V)+C*c[L])}}}function J(w,p,c,u,d){let y=w-1,R=0,C=w-1,T=Number.EPSILON,L=0,V=0,F=0,ee=0,ce=0,H=0,se=0,qe=0,$,ye,Re,$e,Ue,gr,ke,je,ur,Y,he,xe,pe,mr,ir;for($=0;$C)&&(c[$]=d.get($,$),p[$]=0),ye=Math.max($-1,0);ye=R;){for($e=y;$e>R&&(H=Math.abs(d.get($e-1,$e-1))+Math.abs(d.get($e,$e)),H===0&&(H=V),!(Math.abs(d.get($e,$e-1))=0){for(se=F>=0?F+se:F-se,c[y-1]=je+se,c[y]=c[y-1],se!==0&&(c[y]=je-ke/se),p[y-1]=0,p[y]=0,je=d.get(y,y-1),H=Math.abs(je)+Math.abs(se),F=je/H,ee=se/H,ce=Math.sqrt(F*F+ee*ee),F=F/ce,ee=ee/ce,ye=y-1;ye0)){for(H=Math.sqrt(H),ur=$e&&(se=d.get(Ue,Ue),ce=je-se,H=ur-se,F=(ce*H-ke)/d.get(Ue+1,Ue)+d.get(Ue,Ue+1),ee=d.get(Ue+1,Ue+1)-se-ce-H,ce=d.get(Ue+2,Ue+1),H=Math.abs(F)+Math.abs(ee)+Math.abs(ce),F=F/H,ee=ee/H,ce=ce/H,!(Ue===$e||Math.abs(d.get(Ue,Ue-1))*(Math.abs(ee)+Math.abs(ce))Ue+2&&d.set($,$-3,0);for(Re=Ue;Re<=y-1&&(mr=Re!==y-1,Re!==Ue&&(F=d.get(Re,Re-1),ee=d.get(Re+1,Re-1),ce=mr?d.get(Re+2,Re-1):0,je=Math.abs(F)+Math.abs(ee)+Math.abs(ce),je!==0&&(F=F/je,ee=ee/je,ce=ce/je)),je!==0);Re++)if(H=Math.sqrt(F*F+ee*ee+ce*ce),F<0&&(H=-H),H!==0){for(Re!==Ue?d.set(Re,Re-1,-H*je):$e!==Ue&&d.set(Re,Re-1,-d.get(Re,Re-1)),F=F+H,je=F/H,ur=ee/H,se=ce/H,ee=ee/F,ce=ce/F,ye=Re;ye=0;y--)if(F=c[y],ee=p[y],ee===0)for($e=y,d.set(y,y,1),$=y-1;$>=0;$--){for(ke=d.get($,$)-F,ce=0,ye=$e;ye<=y;ye++)ce=ce+d.get($,ye)*d.get(ye,y);if(p[$]<0)se=ke,H=ce;else if($e=$,p[$]===0?d.set($,y,ke!==0?-ce/ke:-ce/(T*V)):(je=d.get($,$+1),ur=d.get($+1,$),ee=(c[$]-F)*(c[$]-F)+p[$]*p[$],gr=(je*H-se*ce)/ee,d.set($,y,gr),d.set($+1,y,Math.abs(je)>Math.abs(se)?(-ce-ke*gr)/je:(-H-ur*gr)/se)),gr=Math.abs(d.get($,y)),T*gr*gr>1)for(ye=$;ye<=y;ye++)d.set(ye,y,d.get(ye,y)/gr)}else if(ee<0)for($e=y-1,Math.abs(d.get(y,y-1))>Math.abs(d.get(y-1,y))?(d.set(y-1,y-1,ee/d.get(y,y-1)),d.set(y-1,y,-(d.get(y,y)-F)/d.get(y,y-1))):(ir=ae(0,-d.get(y-1,y),d.get(y-1,y-1)-F,ee),d.set(y-1,y-1,ir[0]),d.set(y-1,y,ir[1])),d.set(y,y-1,0),d.set(y,y,1),$=y-2;$>=0;$--){for(Y=0,he=0,ye=$e;ye<=y;ye++)Y=Y+d.get($,ye)*d.get(ye,y-1),he=he+d.get($,ye)*d.get(ye,y);if(ke=d.get($,$)-F,p[$]<0)se=ke,ce=Y,H=he;else if($e=$,p[$]===0?(ir=ae(-Y,-he,ke,ee),d.set($,y-1,ir[0]),d.set($,y,ir[1])):(je=d.get($,$+1),ur=d.get($+1,$),xe=(c[$]-F)*(c[$]-F)+p[$]*p[$]-ee*ee,pe=(c[$]-F)*2*ee,xe===0&&pe===0&&(xe=T*V*(Math.abs(ke)+Math.abs(ee)+Math.abs(je)+Math.abs(ur)+Math.abs(se))),ir=ae(je*ce-se*Y+ee*he,je*H-se*he-ee*Y,xe,pe),d.set($,y-1,ir[0]),d.set($,y,ir[1]),Math.abs(je)>Math.abs(se)+Math.abs(ee)?(d.set($+1,y-1,(-Y-ke*d.get($,y-1)+ee*d.get($,y))/je),d.set($+1,y,(-he-ke*d.get($,y)-ee*d.get($,y-1))/je)):(ir=ae(-ce-ur*d.get($,y-1),-H-ur*d.get($,y),se,ee),d.set($+1,y-1,ir[0]),d.set($+1,y,ir[1]))),gr=Math.max(Math.abs(d.get($,y-1)),Math.abs(d.get($,y))),T*gr*gr>1)for(ye=$;ye<=y;ye++)d.set(ye,y-1,d.get(ye,y-1)/gr),d.set(ye,y,d.get(ye,y)/gr)}for($=0;$C)for(ye=$;ye=R;ye--)for($=R;$<=C;$++){for(se=0,Re=R;Re<=Math.min(ye,C);Re++)se=se+u.get($,Re)*d.get(Re,ye);u.set($,ye,se)}}}function ae(w,p,c,u){let d,y;return Math.abs(c)>Math.abs(u)?(d=u/c,y=c+d*u,[(w+d*p)/y,(p-d*w)/y]):(d=c/u,y=u+d*c,[(d*w+p)/y,(d*p-w)/y])}class ne{constructor(p){if(p=Se.checkMatrix(p),!p.isSymmetric())throw new Error("Matrix is not symmetric");let c=p,u=c.rows,d=new W(u,u),y=!0,R,C,T;for(C=0;C0),d.set(C,C,Math.sqrt(Math.max(L,0))),T=C+1;T=0;T--)for(C=0;CR;ce++)F=p.transpose().mmul(C).div(C.transpose().mmul(C).get(0,0)),F=F.div(F.norm()),L=p.mmul(F).div(F.transpose().mmul(F).get(0,0)),ce>0&&(T=L.clone().sub(ee).pow(2).sum()),ee=L.clone(),u?(V=u.transpose().mmul(L).div(L.transpose().mmul(L).get(0,0)),V=V.div(V.norm()),C=u.mmul(V).div(V.transpose().mmul(V).get(0,0))):C=L;if(u){let ce=p.transpose().mmul(L).div(L.transpose().mmul(L).get(0,0));ce=ce.div(ce.norm());let H=p.clone().sub(L.clone().mmul(ce.transpose())),se=C.transpose().mmul(L).div(L.transpose().mmul(L).get(0,0)),qe=u.clone().sub(L.clone().mulS(se.get(0,0)).mmul(V.transpose()));this.t=L,this.p=ce.transpose(),this.w=F.transpose(),this.q=V,this.u=C,this.s=L.transpose().mmul(L),this.xResidual=H,this.yResidual=qe,this.betas=se}else this.w=F.transpose(),this.s=L.transpose().mmul(L).sqrt(),d?this.t=L.clone().div(this.s.get(0,0)):this.t=L,this.xResidual=p.sub(L.mmul(F.transpose()))}}return Ke.AbstractMatrix=U,Ke.CHO=ne,Ke.CholeskyDecomposition=ne,Ke.DistanceMatrix=le,Ke.EVD=k,Ke.EigenvalueDecomposition=k,Ke.LU=ie,Ke.LuDecomposition=ie,Ke.Matrix=W,Ke.MatrixColumnSelectionView=Be,Ke.MatrixColumnView=Ye,Ke.MatrixFlipColumnView=wr,Ke.MatrixFlipRowView=er,Ke.MatrixRowSelectionView=Xe,Ke.MatrixRowView=qr,Ke.MatrixSelectionView=Ae,Ke.MatrixSubView=ze,Ke.MatrixTransposeView=be,Ke.NIPALS=Ee,Ke.Nipals=Ee,Ke.QR=ar,Ke.QrDecomposition=ar,Ke.SVD=Tr,Ke.SingularValueDecomposition=Tr,Ke.SymmetricMatrix=ue,Ke.WrapperMatrix1D=sr,Ke.WrapperMatrix2D=Se,Ke.correlation=b,Ke.covariance=v,Ke.default=W,Ke.determinant=et,Ke.inverse=cr,Ke.linearDependencies=St,Ke.pseudoInverse=K,Ke.solve=$r,Ke.wrap=Le,Ke}var Tn=e1(),Ll=_o(Tn);var Ml=Tn.Matrix,r1=Tn.SingularValueDecomposition;Ll.Matrix?Ll.Matrix:Tn.Matrix;var ws=(r,e)=>{let t=r.nodeCount(),i=Array.from({length:t},()=>[]),n={},o=0;return r.forEachNode(s=>{n[s.id]=o++}),r.forEachEdge(s=>{let a=n[s.source],h=n[s.target];a==null||h==null||(i[a].push(h),e||i[h].push(a))}),i},t1=(r,e)=>{let t=r.length,i=new Array(t);for(let n=0;nnew Array(e).fill(1/0));for(let i=0;i0&&(this.data[0]=t,this.bubbleDown(0)),e}empty(){return this.data.length===0}bubbleUp(e){let t=this.data;for(;e>0;){let i=e-1>>1;if(t[i][0]<=t[e][0])break;[t[i],t[e]]=[t[e],t[i]],e=i}}bubbleDown(e){let t=this.data,i=t.length;for(;;){let n=e*2+1,o=e*2+2,s=e;if(n{let l=a[h++];f.x=l[0]+t[0],f.y=l[1]+t[1]})})}},WI=r=>{let e=Number.NEGATIVE_INFINITY,t=[],i=r.length;for(let n=0;n{try{let i=r.length,n=new Ml(i,i);for(let _=0;_{let t=Object.assign(Object.assign({},i1),e),{maxIteration:i,width:n,k:o,speed:s=i1.speed,strictRadial:a,focusNode:h,radiiMap:f,nodeSizeFunc:l}=t,g=o*.002,m=new Map,_=n/10;for(let E=0;E{m.set(x.id,{x:0,y:0})}),BI(r,m,o,f,l),!(VI(r,m,s,a,h,_,f){let o=0;r.forEachNode(s=>{let a=0;r.forEachNode(h=>{if(a<=o){a++;return}if(s.id===h.id||i.get(s.id)!==i.get(h.id))return;let f=s.x-h.x,l=s.y-h.y,g=Math.sqrt(f*f+l*l);if(g===0){g=1;let E=o>a?1:-1;f=.01*E,l=.01*E}let m=Math.max(...n(s._original)),_=Math.max(...n(h._original));if(g<_/2+m/2){let E=t*t/g,q=e.get(s.id),x=e.get(h.id),A=f/g*E,S=l/g*E;e.set(s.id,{x:q.x+A,y:q.y+S}),e.set(h.id,{x:x.x-A,y:x.y-S})}a++}),o++})},VI=(r,e,t,i,n,o,s)=>{i&&r.forEachNode(f=>{let l=f.x-n.x,g=f.y-n.y,m=Math.sqrt(l*l+g*g),_=g/m,E=-l/m,q=e.get(f.id),x=Math.sqrt(q.x*q.x+q.y*q.y),A=Math.acos((_*q.x+E*q.y)/x);A>Math.PI/2&&(A-=Math.PI/2,_*=-1,E*=-1);let S=Math.cos(A)*x;e.set(f.id,{x:_*S,y:E*S})});let a=0,h=0;return r.forEachNode(f=>{if(f.id===n.id)return;let l=e.get(f.id),g=Math.sqrt(l.x*l.x+l.y*l.y);if(g>0){let m=Math.min(o*(t/800),g);if(f.x+=l.x/g*m,f.y+=l.y/g*m,i){let _=f.x-n.x,E=f.y-n.y,q=Math.sqrt(_*_+E*E);_=_/q*s.get(f.id),E=E/q*s.get(f.id),f.x=n.x+_,f.y=n.y+E}a+=m,h++}}),h>0?a/h:0};var Ti={focusNode:null,linkDistance:50,maxIteration:1e3,maxPreventOverlapIteration:200,preventOverlap:!1,sortStrength:10,strictRadial:!0,unitRadius:null,nodeSize:10,nodeSpacing:0},Es=class extends Dt{constructor(){super(...arguments),this.id="radial"}getDefaultOptions(){return Ti}layout(){return st(this,void 0,void 0,function*(){let{width:e,height:t,center:i}=Wi(this.options),n=this.model.nodeCount();if(!n||n===1)return Ui(this.model,i);let{focusNode:o,linkDistance:s=Ti.linkDistance,maxIteration:a=Ti.maxIteration,maxPreventOverlapIteration:h=Ti.maxPreventOverlapIteration,nodeSize:f,nodeSpacing:l,preventOverlap:g,sortBy:m,sortStrength:_=Ti.sortStrength,strictRadial:E,unitRadius:q}=this.options,x=o&&this.model.node(o)||this.model.firstNode(),A=this.model.nodeIndexOf(x.id),S=ws(this.model,!1),I=qs(S),M=QI(I,A);XI(I,A,M+1);let D=I[A],z=(e-i[0]>i[0]?i[0]:e-i[0])||e/2,O=(t-i[1]>i[1]?i[1]:t-i[1])||t/2,N=Math.min(z,O),j=Math.max(...D),X=[],re=new Map,oe=q??N/j;D.forEach((Oe,B)=>{let pr=Oe*oe;X.push(pr),re.set(this.model.nodeAt(B).id,pr)});let me=KI(this.model,I,s,X,oe,m,_),_e=Pl(me,2,s),Te=_e[A],Ne=0;if(this.model.forEachNode(Oe=>{let B=_e[Ne];Oe.x=B[0]-Te[0],Oe.y=B[1]-Te[1],Ne++}),this.run(a,me,X,A),this.model.forEachNode(Oe=>{Oe.x+=i[0],Oe.y+=i[1]}),g){let B={nodeSizeFunc:oo(f,l,Ti.nodeSize,Ti.nodeSpacing),radiiMap:re,width:e,strictRadial:!!E,focusNode:x,maxIteration:h,k:n/4.5};n1(this.model,B)}})}run(e,t,i,n){let o=YI(t),s=this.model.nodeCount(),a=this.model.nodes(),h=new Float64Array(s),f=new Float64Array(s);for(let l=0;l{let a=e.length,h=new Array(a),f=new Array(a);for(let E=0;E{let e=r.length,t=r[0].length,i=[];for(let n=0;n{let i=r.length;for(let n=0;n{let t=r[e],i=0;for(let n=0;ndn,BubbleSets:()=>Ts,Circle:()=>Mn,Line:()=>Vr,PointPath:()=>zt,Rectangle:()=>it,addPadding:()=>Ul,boundingBox:()=>f1,calculatePotentialOutline:()=>d1,calculateVirtualEdges:()=>c1,circle:()=>iA,createGenericInfluenceArea:()=>Wl,createLineInfluenceArea:()=>Nl,createOutline:()=>yA,createRectangleInfluenceArea:()=>h1,default:()=>Ts,defaultOptions:()=>Bl,line:()=>nA,lineBoundingBox:()=>$l,point:()=>hr,rect:()=>tA,unionBoundingBox:()=>p1});function zl(r,e,t,i,n,o){let s=r,a=e,h=t-s,f=i-a,l=n-s,g=o-a,m=l*h+g*f,_=0;m<=0?_=0:(l=h-l,g=f-g,m=l*h+g*f,m<=0?_=0:_=m*m/(h*h+f*f));let E=l*l+g*g-_;return E<0?0:E}function bi(r,e,t,i){return(r-t)*(r-t)+(e-i)*(e-i)}function o1(r,e,t,i,n){return bi(r,e,t,i)t;if(r===0)return Math.round;let e=Math.pow(10,r);return t=>Math.round(t*e)/e}function $l(r){let e=Math.min(r.x1,r.x2),t=Math.max(r.x1,r.x2),i=Math.min(r.y1,r.y2),n=Math.max(r.y1,r.y2);return{x:e,y:i,x2:t,y2:n,width:t-e,height:n-i}}var Vr=class r{constructor(e,t,i,n){this.x1=e,this.y1=t,this.x2=i,this.y2=n}equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2}draw(e){e.moveTo(this.x1,this.y1),e.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(e){return new r(e.x1,e.y1,e.x2,e.y2)}cuts(e,t){if(this.y1===this.y2||tthis.y1&&t>=this.y2||e>this.x1&&e>=this.x2)return!1;if(ethis.x2+i)return!1}else if(ethis.x1+i)return!1;if(this.y1this.y2+i)return!1}else if(tthis.y1+i)return!1;return!0}},Ar;(function(r){r[r.POINT=1]="POINT",r[r.PARALLEL=2]="PARALLEL",r[r.COINCIDENT=3]="COINCIDENT",r[r.NONE=4]="NONE"})(Ar||(Ar={}));var kn=class{constructor(e,t=0,i=0){this.state=e,this.x=t,this.y=i}};function xs(r,e){let t=(e.x2-e.x1)*(r.y1-e.y1)-(e.y2-e.y1)*(r.x1-e.x1),i=(r.x2-r.x1)*(r.y1-e.y1)-(r.y2-r.y1)*(r.x1-e.x1),n=(e.y2-e.y1)*(r.x2-r.x1)-(e.x2-e.x1)*(r.y2-r.y1);if(n){let o=t/n,s=i/n;return 0<=o&&o<=1&&0<=s&&s<=1?new kn(Ar.POINT,r.x1+o*(r.x2-r.x1),r.y1+o*(r.y2-r.y1)):new kn(Ar.NONE)}return new kn(t===0||i===0?Ar.COINCIDENT:Ar.PARALLEL)}function a1(r,e){let t=(e.x2-e.x1)*(r.y1-e.y1)-(e.y2-e.y1)*(r.x1-e.x1),i=(r.x2-r.x1)*(r.y1-e.y1)-(r.y2-r.y1)*(r.x1-e.x1),n=(e.y2-e.y1)*(r.x2-r.x1)-(e.x2-e.x1)*(r.y2-r.y1);if(n){let o=t/n,s=i/n;if(0<=o&&o<=1&&0<=s&&s<=1)return o}return Number.POSITIVE_INFINITY}function JI(r,e){function t(n,o,s,a){let h=a1(e,new Vr(n,o,s,a));return h=Math.abs(h-.5),h>=0&&h<=1?1:0}let i=t(r.x,r.y,r.x2,r.y);return i+=t(r.x,r.y,r.x,r.y2),i>1||(i+=t(r.x,r.y2,r.x2,r.y2),i>1)?!0:(i+=t(r.x2,r.y,r.x2,r.y2),i>0)}var Rr;(function(r){r[r.LEFT=0]="LEFT",r[r.TOP=1]="TOP",r[r.RIGHT=2]="RIGHT",r[r.BOTTOM=3]="BOTTOM"})(Rr||(Rr={}));function Cs(r,e,t){let i=new Set;return r.width<=0?(i.add(Rr.LEFT),i.add(Rr.RIGHT)):er.x+r.width&&i.add(Rr.RIGHT),r.height<=0?(i.add(Rr.TOP),i.add(Rr.BOTTOM)):tr.y+r.height&&i.add(Rr.BOTTOM),i}function u1(r,e){let t=e.x1,i=e.y1,n=e.x2,o=e.y2,s=Array.from(Cs(r,n,o));if(s.length===0)return!0;let a=Cs(r,t,i);for(;a.size!==0;){for(let h of s)if(a.has(h))return!1;if(a.has(Rr.RIGHT)||a.has(Rr.LEFT)){let h=r.x;a.has(Rr.RIGHT)&&(h+=r.width),i=i+(h-t)*(o-i)/(n-t),t=h}else{let h=r.y;a.has(Rr.BOTTOM)&&(h+=r.height),t=t+(h-i)*(n-t)/(o-i),i=h}a=Cs(r,t,i)}return!0}function HI(r,e){let t=Number.POSITIVE_INFINITY,i=0;function n(o,s,a,h){let f=a1(e,new Vr(o,s,a,h));f=Math.abs(f-.5),f>=0&&f<=1&&(i++,f1||(n(r.x,r.y2,r.x2,r.y2),i>1)?t:(n(r.x2,r.y,r.x2,r.y2),i===0?-1:t)}function eA(r,e){let t=0,i=xs(r,new Vr(e.x,e.y,e.x2,e.y));t+=i.state===Ar.POINT?1:0;let n=xs(r,new Vr(e.x,e.y,e.x,e.y2));t+=n.state===Ar.POINT?1:0;let o=xs(r,new Vr(e.x,e.y2,e.x2,e.y2));t+=o.state===Ar.POINT?1:0;let s=xs(r,new Vr(e.x2,e.y,e.x2,e.y2));return t+=s.state===Ar.POINT?1:0,{top:i,left:n,bottom:o,right:s,count:t}}var it=class r{constructor(e,t,i,n){this.x=e,this.y=t,this.width=i,this.height=n}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(e){return new r(e.x,e.y,e.width,e.height)}equals(e){return this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height}clone(){return new r(this.x,this.y,this.width,this.height)}add(e){let t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x2,e.x+e.width),o=Math.max(this.y2,e.y+e.height);this.x=t,this.y=i,this.width=n-t,this.height=o-i}addPoint(e){let t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x2,e.x),o=Math.max(this.y2,e.y);this.x=t,this.y=i,this.width=n-t,this.height=o-i}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(e){e.rect(this.x,this.y,this.width,this.height)}containsPt(e,t){return e>=this.x&&e<=this.x2&&t>=this.y&&t<=this.y2}get area(){return this.width*this.height}intersects(e){return this.area<=0||e.width<=0||e.height<=0?!1:e.x+e.width>this.x&&e.y+e.height>this.y&&e.x=this.width?this.width-1:e}boundY(e){return e=this.height?this.height-1:e}scaleX(e){return this.boundX(Math.floor((e-this.pixelX)/this.pixelGroup))}scaleY(e){return this.boundY(Math.floor((e-this.pixelY)/this.pixelGroup))}scale(e){let t=this.scaleX(e.x),i=this.scaleY(e.y),n=this.boundX(Math.ceil((e.x+e.width-this.pixelX)/this.pixelGroup)),o=this.boundY(Math.ceil((e.y+e.height-this.pixelY)/this.pixelGroup)),s=n-t,a=o-i;return new it(t,i,s,a)}invertScaleX(e){return Math.round(e*this.pixelGroup+this.pixelX)}invertScaleY(e){return Math.round(e*this.pixelGroup+this.pixelY)}addPadding(e,t){let i=Math.ceil(t/this.pixelGroup),n=this.boundX(e.x-i),o=this.boundY(e.y-i),s=this.boundX(e.x2+i),a=this.boundY(e.y2+i),h=s-n,f=a-o;return new it(n,o,h,f)}get(e,t){return e<0||t<0||e>=this.width||t>=this.height?Number.NaN:this.area[e+t*this.width]}inc(e,t,i){e<0||t<0||e>=this.width||t>=this.height||(this.area[e+t*this.width]+=i)}set(e,t,i){e<0||t<0||e>=this.width||t>=this.height||(this.area[e+t*this.width]=i)}incArea(e,t){if(e.width<=0||e.height<=0||t===0)return;let i=this.width,n=e.width,o=Math.max(0,e.i),s=Math.max(0,e.j),a=Math.min(e.i+e.width,i),h=Math.min(e.j+e.height,this.height);if(!(h<=0||a<=0||o>=i||h>=this.height))for(let f=s;fMath.min(s,a),Number.POSITIVE_INFINITY),n=this.area.reduce((s,a)=>Math.max(s,a),Number.NEGATIVE_INFINITY),o=s=>(s-i)/(n-i);e.scale(this.pixelGroup,this.pixelGroup);for(let s=0;st?"black":"white",e.fillRect(n,o,1,1)}e.restore()}}};function Ul(r,e){let t=i=>({x:i.x-e,y:i.y-e,width:i.width+2*e,height:i.height+2*e});return Array.isArray(r)?r.map(t):t(r)}function Nl(r,e,t){return Wl(Object.assign($l(r),{distSquare:(i,n)=>zl(r.x1,r.y1,r.x2,r.y2,i,n)}),e,t)}function Wl(r,e,t){let i=Ul(r,t),n=e.scale(i),o=e.createSub(n,i);return rA(o,e,t,(s,a)=>r.distSquare(s,a)),o}function rA(r,e,t,i){let n=t*t;for(let o=0;o{let a=n.slice(0,s);return oA(e,o,a,t,i)}).flat()}function oA(r,e,t,i,n){let o=hr(e.cx,e.cy),s=uA(o,t,r);if(s==null)return[];let a=new Vr(o.x,o.y,s.cx,s.cy),h=sA(a,r,i,n);return aA(h,r)}function sA(r,e,t,i){let n=[],o=[];o.push(r);let s=!0;for(let a=0;a0;){let h=o.pop(),f=l1(e,h),l=f?eA(h,f):null;if(!f||!l||l.count!==2){s||n.push(h);continue}let g=i,m=Is(f,g,l,!0),_=qi(m,o)||qi(m,n),E=Ss(m,e);for(;!_&&E&&g>=1;)g/=1.5,m=Is(f,g,l,!0),_=qi(m,o)||qi(m,n),E=Ss(m,e);if(m&&!_&&!E&&(o.push(new Vr(h.x1,h.y1,m.x,m.y)),o.push(new Vr(m.x,m.y,h.x2,h.y2)),s=!0),s)continue;g=i,m=Is(f,g,l,!1);let q=qi(m,o)||qi(m,n);for(E=Ss(m,e);!q&&E&&g>=1;)g/=1.5,m=Is(f,g,l,!1),q=qi(m,o)||qi(m,n),E=Ss(m,e);m&&!q&&(o.push(new Vr(h.x1,h.y1,m.x,m.y)),o.push(new Vr(m.x,m.y,h.x2,h.y2)),s=!0),s||n.push(h)}for(;o.length>0;)n.push(o.pop());return n}function aA(r,e){let t=[];for(;r.length>0;){let i=r.pop();if(r.length===0){t.push(i);break}let n=r.pop(),o=new Vr(i.x1,i.y1,n.x2,n.y2);l1(e,o)?(t.push(i),r.push(n)):r.push(o)}return t}function uA(r,e,t){let i=Number.POSITIVE_INFINITY;return e.reduce((n,o)=>{let s=bi(r.x,r.y,o.cx,o.cy);if(s>i)return n;let a=new Vr(r.x,r.y,o.cx,o.cy),h=hA(t,a);return s*(h+1)*(h+1){e+=i.cx,t+=i.cy}),e/=r.length,t/=r.length,r.map(i=>{let n=e-i.cx,o=t-i.cy,s=n*n+o*o;return[i,s]}).sort((i,n)=>i[1]-n[1]).map(i=>i[0])}function Ss(r,e){return e.some(t=>t.containsPt(r.x,r.y))}function qi(r,e){return e.some(t=>!!(o1(t.x1,t.y1,r.x,r.y,.001)||o1(t.x2,t.y2,r.x,r.y,.001)))}function l1(r,e){let t=Number.POSITIVE_INFINITY,i=null;for(let n of r){if(!u1(n,e))continue;let o=HI(n,e);o>=0&&ou1(i,e)&&JI(i,e)?t+1:t,0)}function Is(r,e,t,i){let n=t.top,o=t.left,s=t.bottom,a=t.right;if(i){if(o.state===Ar.POINT){if(n.state===Ar.POINT)return hr(r.x-e,r.y-e);if(s.state===Ar.POINT)return hr(r.x-e,r.y2+e);let m=r.width*r.height;return r.width*((o.y-r.y+(a.y-r.y))*.5)a.y?hr(r.x-e,r.y-e):hr(r.x2+e,r.y-e):o.ys.x?hr(r.x-e,r.y-e):hr(r.x-e,r.y2+e):n.xa.y?hr(r.x2+e,r.y2+e):hr(r.x-e,r.y2+e):o.ys.x?hr(r.x2+e,r.y2+e):hr(r.x2+e,r.y-e):n.xi)return!1}return!0}function lA(r=0){return e=>{if(r<0||e.length<3)return e;let t=[],i=0,n=r*r;for(;i{if(s.length<3)return s;let a=[],h=s.closed,f=s.length+3-1+(h?0:2);a.push(o(s,2-(h?0:2),0));for(let l=2-(h?0:2);l{let t=r,i=e.length;if(t>1)for(i=Math.floor(e.length/t);i<3&&t>1;)t-=1,i=Math.floor(e.length/t);let n=[];for(let o=0,s=0;s=i?this.closed?this.get(e-i):this.points[i-1]:this.points[t]}get length(){return this.points.length}toString(e=1/0){let t=this.points;if(t.length===0)return"";let i=typeof e=="function"?e:ZI(e),n="M";for(let o of t)n+=`${i(o.x)},${i(o.y)} L`;return n=n.slice(0,-1),this.closed&&(n+=" Z"),n}draw(e){let t=this.points;if(t.length!==0){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i of t)e.lineTo(i.x,i.y);this.closed&&e.closePath()}}sample(e){return gA(e)(this)}simplify(e){return lA(e)(this)}bSplines(e){return pA(e)(this)}apply(e){return e(this)}containsElements(e){let t=f1(this.points);return t?e.every(i=>t.containsPt(i.cx,i.cy)&&this.withinArea(i.cx,i.cy)):!1}withinArea(e,t){if(this.length===0)return!1;let i=0,n=this.points[0],o=new Vr(n.x,n.y,n.x,n.y);for(let s=1;se?l+g:l}function o(h,f){let l=On;return l=n(h,f,l,1),l=n(h+1,f,l,2),l=n(h,f+1,l,4),l=n(h+1,f+1,l,8),Number.isNaN(l)?-1:l}let s=As;function a(h,f){let l=h,g=f,m=r.invertScaleX(l),_=r.invertScaleY(g);for(let E=0;Es1(i.raw,e));return t<0?!1:(this.members.splice(t,1),this.dirty.add(Tt.MEMBERS),!0)}removeNonMember(e){let t=this.nonMembers.findIndex(i=>s1(i.raw,e));return t<0?!1:(this.nonMembers.splice(t,1),this.dirty.add(Tt.NON_MEMBERS),!0)}removeEdge(e){let t=this.edges.findIndex(i=>i.obj.equals(e));return t<0?!1:(this.edges.splice(t,1),this.dirty.add(Tt.NON_MEMBERS),!0)}pushNonMember(...e){if(e.length!==0){this.dirty.add(Tt.NON_MEMBERS);for(let t of e)this.nonMembers.push({raw:t,obj:Ln(t)?Mn.from(t):it.from(t),area:null})}}pushEdge(...e){if(e.length!==0){this.dirty.add(Tt.EDGES);for(let t of e)this.edges.push({raw:t,obj:Vr.from(t),area:null})}}update(){let e=this.dirty.has(Tt.MEMBERS),t=this.dirty.has(Tt.NON_MEMBERS),i=this.dirty.has(Tt.EDGES);this.dirty.clear();let n=this.members.map(f=>f.obj);if(this.o.virtualEdges&&(e||t)){let f=this.nonMembers.map(m=>m.obj),l=c1(n,f,this.o.maxRoutingIterations,this.o.morphBuffer),g=new Map(this.virtualEdges.map(m=>[m.obj.toString(),m.area]));this.virtualEdges=l.map(m=>{var _;return{raw:m,obj:m,area:(_=g.get(m.toString()))!==null&&_!==void 0?_:null}}),i=!0}let o=!1;if(e||i){let f=this.virtualEdges.concat(this.edges).map(_=>_.obj),l=p1(n,f),g=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,m=it.from(Ul(l,g));m.equals(this.activeRegion)||(o=!0,this.activeRegion=m)}if(o){let f=Math.ceil(this.activeRegion.width/this.o.pixelGroup),l=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=dn.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach(g=>g.area=null),this.nonMembers.forEach(g=>g.area=null),this.edges.forEach(g=>g.area=null),this.virtualEdges.forEach(g=>g.area=null)):(f!==this.potentialArea.width||l!==this.potentialArea.height)&&(this.potentialArea=dn.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}let s=new Map,a=f=>{if(f.area){let l=`${f.obj.width}x${f.obj.height}x${f.obj instanceof it?"R":"C"}`;s.set(l,f.area)}},h=f=>{if(f.area)return;let l=`${f.obj.width}x${f.obj.height}x${f.obj instanceof it?"R":"C"}`;if(s.has(l)){let m=s.get(l);f.area=this.potentialArea.copy(m,{x:f.obj.x-this.o.nodeR1,y:f.obj.y-this.o.nodeR1});return}let g=f.obj instanceof it?h1(f.obj,this.potentialArea,this.o.nodeR1):Wl(f.obj,this.potentialArea,this.o.nodeR1);f.area=g,s.set(l,g)};this.members.forEach(a),this.nonMembers.forEach(a),this.members.forEach(h),this.nonMembers.forEach(f=>{this.activeRegion.intersects(f.obj)?h(f):f.area=null}),this.edges.forEach(f=>{f.area||(f.area=Nl(f.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(f=>{f.area||(f.area=Nl(f.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(e){for(let t of this.members)t.obj.draw(e)}drawNonMembers(e){for(let t of this.nonMembers)t.obj.draw(e)}drawEdges(e){for(let t of this.edges)t.obj.draw(e)}drawPotentialArea(e,t=!0){this.potentialArea.draw(e,t)}compute(){if(this.members.length===0)return new zt([]);this.dirty.size>0&&this.update();let{o:e,potentialArea:t}=this,i=this.members.map(a=>a.area),n=this.virtualEdges.concat(this.edges).map(a=>a.area),o=this.nonMembers.filter(a=>a.area!=null).map(a=>a.area),s=this.members.map(a=>a.obj);return d1(t,i,n,o,a=>a.containsElements(s),e)}};function d1(r,e,t,i,n,o={}){let s=Object.assign({},Bl,o),a=s.threshold,h=s.memberInfluenceFactor,f=s.edgeInfluenceFactor,l=s.nonMemberInfluenceFactor,g=(s.nodeR0-s.nodeR1)*(s.nodeR0-s.nodeR1),m=(s.edgeR0-s.edgeR1)*(s.edgeR0-s.edgeR1);for(let _=0;_0)l*=.8;else break}return new zt([])}function p1(r,e){if(r.length===0)return new it(0,0,0,0);let t=it.from(r[0]);for(let i of r)t.add(i);for(let i of e)t.add($l(i));return t}function yA(r,e=[],t=[],i={}){if(r.length===0)return new zt([]);let n=new Ts(i);return n.pushMember(...r),n.pushNonMember(...e),n.pushEdge(...t),n.compute()}var rC=Qr(m1(),1),tC=Qr(w1(),1),iC=Qr(K1(),1),nC=Qr(eE(),1),oC=Qr(nE(),1),sC=Qr(uE(),1),aC=Qr(cE(),1),uC=Qr(qE(),1),fC=Qr(CE(),1),hC=Qr(XE(),1),cC=Qr(sd(),1);var export_FA2Layout=HR.default;var export_betweennessCentrality=iC.default;var export_bidirectional=cC.bidirectional;var export_circlepack=zs.circlepack;var export_circular=zs.circular;var export_closenessCentrality=nC.default;var export_degreeCentrality=tC.degreeCentrality;var export_density=aC.density;var export_diameter=uC.default;var export_eigenvectorCentrality=oC.default;var export_forceAtlas2=JR.default;var export_louvain=hC.default;var export_modularity=fC.default;var export_noverlap=eC.default;var export_pagerank=sC.default;var export_polygonClipping=rC.default;var export_random=zs.random;var export_rotation=zs.rotation;export{mo as ConcentricLayout,vs as DagreLayout,export_FA2Layout as FA2Layout,fr as Graph,bs as MDSLayout,Es as RadialLayout,export_betweennessCentrality as betweennessCentrality,export_bidirectional as bidirectional,g1 as bubblesets,export_circlepack as circlepack,export_circular as circular,export_closenessCentrality as closenessCentrality,export_degreeCentrality as degreeCentrality,export_density as density,export_diameter as diameter,export_eigenvectorCentrality as eigenvectorCentrality,export_forceAtlas2 as forceAtlas2,export_louvain as louvain,export_modularity as modularity,export_noverlap as noverlap,export_pagerank as pagerank,export_polygonClipping as polygonClipping,export_random as random,export_rotation as rotation}; /*! Bundled license information: polygon-clipping/dist/polygon-clipping.umd.js: diff --git a/src/managers/ui.js b/src/managers/ui.js index 26642a4..4a6fa6c 100644 --- a/src/managers/ui.js +++ b/src/managers/ui.js @@ -150,6 +150,10 @@ class UIManager { this.toggleDisabledElements(["Arrange Selection"], enable); } + toggleStyleElementsThatRequireExactlyTwoSelectedNodes(enable) { + this.toggleDisabledElements(["Shortest Path"], enable); + } + toggleDisabledElements(headingLabels, enable) { for (let elemID of headingLabels) { const elem = document.getElementById(elemID); diff --git a/src/managers/ui_style_div.js b/src/managers/ui_style_div.js index fd67b15..4b32e53 100644 --- a/src/managers/ui_style_div.js +++ b/src/managers/ui_style_div.js @@ -684,6 +684,11 @@ function createStyleDiv(cache) { "Remove the outermost layer of selected neighbor nodes (and their edges) from the ", async () => await cache.sm.toggleSelectionByNeighbors("reduce-neighbors")); + const rowShortestPath = createNewRow(selDiv); + appendButton(rowShortestPath, "Shortest Path", + "Add the shortest path connecting the two selected nodes — its nodes and the edges between them — to the selection.\nComputed on the visible graph, so it honours active filters.\nRequires exactly two selected nodes.", + async () => await cache.sm.selectShortestPathBetweenSelected()); + appendHorizontalRule(selDiv); const rowFour = createNewRow(selDiv); diff --git a/src/package/vendor_entry_graphology.mjs b/src/package/vendor_entry_graphology.mjs index 65d9b7d..fa11c72 100644 --- a/src/package/vendor_entry_graphology.mjs +++ b/src/package/vendor_entry_graphology.mjs @@ -29,3 +29,6 @@ export {default as diameter} from 'graphology-metrics/graph/diameter.js'; export {default as modularity} from 'graphology-metrics/graph/modularity.js'; // Louvain community detection (pure JS, node-safe). export {default as louvain} from 'graphology-communities-louvain'; +// Unweighted (BFS) shortest path (pure JS, node-safe). bidirectional finds the +// shortest hop-count path between two nodes — used by graph/shortest_path.js. +export {bidirectional} from 'graphology-shortest-path/unweighted'; diff --git a/src/package/vendor_libs.js b/src/package/vendor_libs.js index 9008307..25d8e59 100644 --- a/src/package/vendor_libs.js +++ b/src/package/vendor_libs.js @@ -58,7 +58,7 @@ const bundles = [ { entry: path.join(__dirname, 'vendor_entry_graphology.mjs'), out: path.join(libDir, 'graphology.bundle.mjs'), - pkgs: ['graphology', 'graphology-layout', 'graphology-layout-forceatlas2', 'graphology-layout-noverlap', 'graphology-metrics', 'graphology-communities-louvain', '@antv/layout', 'bubblesets-js', 'polygon-clipping'], + pkgs: ['graphology', 'graphology-layout', 'graphology-layout-forceatlas2', 'graphology-layout-noverlap', 'graphology-metrics', 'graphology-communities-louvain', 'graphology-shortest-path', '@antv/layout', 'bubblesets-js', 'polygon-clipping'], }, { entry: path.join(__dirname, 'vendor_entry_sigma.mjs'), diff --git a/tests/selection-group-button-sync.test.js b/tests/selection-group-button-sync.test.js index af4e03d..ef65c39 100644 --- a/tests/selection-group-button-sync.test.js +++ b/tests/selection-group-button-sync.test.js @@ -39,6 +39,7 @@ function makeCache() { toggleStyleElementsThatRequireAtLeastOneSelectedEdge: vi.fn(), toggleStyleElementsThatRequireAtLeastOneSelectedNodeOrEdge: vi.fn(), toggleStyleElementsThatRequireMoreThanOneSelectedNode: vi.fn(), + toggleStyleElementsThatRequireExactlyTwoSelectedNodes: vi.fn(), }, }; } diff --git a/tests/shortest-path.test.js b/tests/shortest-path.test.js new file mode 100644 index 0000000..17a4ba3 --- /dev/null +++ b/tests/shortest-path.test.js @@ -0,0 +1,154 @@ +import { describe, it, expect } from 'vitest' +import { findShortestPath } from '../src/graph/shortest_path.js' + +// ========================================================================== +// Unweighted (BFS) shortest path over the visible subgraph (pure, node-safe). +// The DOM-bound application path (adding the path to the selection) lives in +// graph/selection.js and is exercised through GraphSelectionManager. +// ========================================================================== + +// Helper: build a minimal cache-like object (same shape as metrics.test.js). +// Edge ids carry an index suffix so parallel (multi) edges stay distinct. +// A third tuple element { hidden: true } keeps the edge out of the visible +// subgraph (in edgeRef but not edgeIDsToBeShown), mirroring an active filter. +function makeCache(nodeIds, edges) { + const nodeIDsToBeShown = new Set(nodeIds) + const edgeRef = new Map() + const edgeIDsToBeShown = new Set() + + edges.forEach(([source, target, opts = {}], i) => { + const id = `${source}::${target}::${i}` + edgeRef.set(id, { source, target }) + if (!opts.hidden) edgeIDsToBeShown.add(id) + }) + + return { nodeIDsToBeShown, edgeIDsToBeShown, edgeRef } +} + +const edgeId = (source, target, i) => `${source}::${target}::${i}` + +describe('findShortestPath', () => { + it('finds a direct one-hop path', () => { + const cache = makeCache(['A', 'B'], [['A', 'B']]) + const result = findShortestPath(cache, 'A', 'B') + + expect(result.found).toBe(true) + expect(result.nodes).toEqual(['A', 'B']) + expect(result.edges).toEqual([edgeId('A', 'B', 0)]) + expect(result.hops).toBe(1) + }) + + it('finds a multi-hop path along a chain', () => { + // A -- B -- C -- D -- E + const cache = makeCache( + ['A', 'B', 'C', 'D', 'E'], + [['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'E']] + ) + const result = findShortestPath(cache, 'A', 'E') + + expect(result.found).toBe(true) + expect(result.nodes).toEqual(['A', 'B', 'C', 'D', 'E']) + expect(result.edges).toEqual([ + edgeId('A', 'B', 0), + edgeId('B', 'C', 1), + edgeId('C', 'D', 2), + edgeId('D', 'E', 3), + ]) + expect(result.hops).toBe(4) + }) + + it('picks the shorter of two routes', () => { + // Short: A-B-D (2 hops). Long: A-C-E-D (3 hops). + const cache = makeCache( + ['A', 'B', 'C', 'D', 'E'], + [['A', 'B'], ['B', 'D'], ['A', 'C'], ['C', 'E'], ['E', 'D']] + ) + const result = findShortestPath(cache, 'A', 'D') + + expect(result.found).toBe(true) + expect(result.nodes).toEqual(['A', 'B', 'D']) + expect(result.hops).toBe(2) + }) + + it('treats the graph as undirected (reverse direction)', () => { + // Edges stored A->B, B->C; a C->A query must still find the path. + const cache = makeCache(['A', 'B', 'C'], [['A', 'B'], ['B', 'C']]) + const result = findShortestPath(cache, 'C', 'A') + + expect(result.found).toBe(true) + expect(result.nodes).toEqual(['C', 'B', 'A']) + expect(result.hops).toBe(2) + // Edge ids are derived regardless of stored endpoint order. + expect(result.edges).toEqual([edgeId('B', 'C', 1), edgeId('A', 'B', 0)]) + }) + + it('returns found=false for disconnected components', () => { + // A--B and C--D are separate components. + const cache = makeCache(['A', 'B', 'C', 'D'], [['A', 'B'], ['C', 'D']]) + const result = findShortestPath(cache, 'A', 'D') + + expect(result.found).toBe(false) + expect(result.nodes).toEqual([]) + expect(result.edges).toEqual([]) + expect(result.hops).toBe(0) + }) + + it('returns a single-node, zero-hop path when source equals target', () => { + const cache = makeCache(['A', 'B'], [['A', 'B']]) + const result = findShortestPath(cache, 'A', 'A') + + expect(result.found).toBe(true) + expect(result.nodes).toEqual(['A']) + expect(result.edges).toEqual([]) + expect(result.hops).toBe(0) + }) + + it('returns found=false when an endpoint is not visible', () => { + // C exists as an edge endpoint but is filtered out of the visible nodes. + const cache = makeCache(['A', 'B'], [['A', 'B'], ['B', 'C']]) + const result = findShortestPath(cache, 'A', 'C') + + expect(result.found).toBe(false) + expect(result.nodes).toEqual([]) + expect(result.hops).toBe(0) + }) + + it('ignores a hidden/filtered edge and routes around it', () => { + // Direct A-B edge is hidden, but A-C-B is visible → 2-hop detour. + const cache = makeCache( + ['A', 'B', 'C'], + [['A', 'B', { hidden: true }], ['A', 'C'], ['C', 'B']] + ) + const result = findShortestPath(cache, 'A', 'B') + + expect(result.found).toBe(true) + expect(result.nodes).toEqual(['A', 'C', 'B']) + expect(result.hops).toBe(2) + expect(result.edges).toEqual([edgeId('A', 'C', 1), edgeId('C', 'B', 2)]) + }) + + it('returns found=false when the only connecting edge is hidden', () => { + const cache = makeCache(['A', 'B'], [['A', 'B', { hidden: true }]]) + const result = findShortestPath(cache, 'A', 'B') + + expect(result.found).toBe(false) + expect(result.hops).toBe(0) + }) + + it('handles parallel edges, emitting one edge id per hop', () => { + // A == B (two parallel edges), B -- C. + const cache = makeCache( + ['A', 'B', 'C'], + [['A', 'B'], ['A', 'B'], ['B', 'C']] + ) + const result = findShortestPath(cache, 'A', 'C') + + expect(result.found).toBe(true) + expect(result.nodes).toEqual(['A', 'B', 'C']) + expect(result.hops).toBe(2) + expect(result.edges).toHaveLength(2) + // First hop is one of the two parallel A--B edges; second is the B--C edge. + expect([edgeId('A', 'B', 0), edgeId('A', 'B', 1)]).toContain(result.edges[0]) + expect(result.edges[1]).toBe(edgeId('B', 'C', 2)) + }) +})