2 lines
90 KiB
JavaScript
2 lines
90 KiB
JavaScript
import{g as vt}from"./react-vendor-BVoutfaX.js";var gt={exports:{}},Pt;function $e(){if(Pt)return gt.exports;Pt=1;var o=typeof Reflect=="object"?Reflect:null,t=o&&typeof o.apply=="function"?o.apply:function(g,p,v){return Function.prototype.apply.call(g,p,v)},e;o&&typeof o.ownKeys=="function"?e=o.ownKeys:Object.getOwnPropertySymbols?e=function(g){return Object.getOwnPropertyNames(g).concat(Object.getOwnPropertySymbols(g))}:e=function(g){return Object.getOwnPropertyNames(g)};function i(l){console&&console.warn&&console.warn(l)}var r=Number.isNaN||function(g){return g!==g};function n(){n.init.call(this)}gt.exports=n,gt.exports.once=y,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var u=10;function s(l){if(typeof l!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof l)}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(l){if(typeof l!="number"||l<0||r(l))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+l+".");u=l}}),n.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},n.prototype.setMaxListeners=function(g){if(typeof g!="number"||g<0||r(g))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+g+".");return this._maxListeners=g,this};function h(l){return l._maxListeners===void 0?n.defaultMaxListeners:l._maxListeners}n.prototype.getMaxListeners=function(){return h(this)},n.prototype.emit=function(g){for(var p=[],v=1;v<arguments.length;v++)p.push(arguments[v]);var b=g==="error",G=this._events;if(G!==void 0)b=b&&G.error===void 0;else if(!b)return!1;if(b){var A;if(p.length>0&&(A=p[0]),A instanceof Error)throw A;var S=new Error("Unhandled error."+(A?" ("+A.message+")":""));throw S.context=A,S}var L=G[g];if(L===void 0)return!1;if(typeof L=="function")t(L,this,p);else for(var R=L.length,K=x(L,R),v=0;v<R;++v)t(K[v],this,p);return!0};function a(l,g,p,v){var b,G,A;if(s(p),G=l._events,G===void 0?(G=l._events=Object.create(null),l._eventsCount=0):(G.newListener!==void 0&&(l.emit("newListener",g,p.listener?p.listener:p),G=l._events),A=G[g]),A===void 0)A=G[g]=p,++l._eventsCount;else if(typeof A=="function"?A=G[g]=v?[p,A]:[A,p]:v?A.unshift(p):A.push(p),b=h(l),b>0&&A.length>b&&!A.warned){A.warned=!0;var S=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+String(g)+" listeners added. Use emitter.setMaxListeners() to increase limit");S.name="MaxListenersExceededWarning",S.emitter=l,S.type=g,S.count=A.length,i(S)}return l}n.prototype.addListener=function(g,p){return a(this,g,p,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(g,p){return a(this,g,p,!0)};function d(){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 f(l,g,p){var v={fired:!1,wrapFn:void 0,target:l,type:g,listener:p},b=d.bind(v);return b.listener=p,v.wrapFn=b,b}n.prototype.once=function(g,p){return s(p),this.on(g,f(this,g,p)),this},n.prototype.prependOnceListener=function(g,p){return s(p),this.prependListener(g,f(this,g,p)),this},n.prototype.removeListener=function(g,p){var v,b,G,A,S;if(s(p),b=this._events,b===void 0)return this;if(v=b[g],v===void 0)return this;if(v===p||v.listener===p)--this._eventsCount===0?this._events=Object.create(null):(delete b[g],b.removeListener&&this.emit("removeListener",g,v.listener||p));else if(typeof v!="function"){for(G=-1,A=v.length-1;A>=0;A--)if(v[A]===p||v[A].listener===p){S=v[A].listener,G=A;break}if(G<0)return this;G===0?v.shift():N(v,G),v.length===1&&(b[g]=v[0]),b.removeListener!==void 0&&this.emit("removeListener",g,S||p)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(g){var p,v,b;if(v=this._events,v===void 0)return this;if(v.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):v[g]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete v[g]),this;if(arguments.length===0){var G=Object.keys(v),A;for(b=0;b<G.length;++b)A=G[b],A!=="removeListener"&&this.removeAllListeners(A);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(p=v[g],typeof p=="function")this.removeListener(g,p);else if(p!==void 0)for(b=p.length-1;b>=0;b--)this.removeListener(g,p[b]);return this};function c(l,g,p){var v=l._events;if(v===void 0)return[];var b=v[g];return b===void 0?[]:typeof b=="function"?p?[b.listener||b]:[b]:p?$(b):x(b,b.length)}n.prototype.listeners=function(g){return c(this,g,!0)},n.prototype.rawListeners=function(g){return c(this,g,!1)},n.listenerCount=function(l,g){return typeof l.listenerCount=="function"?l.listenerCount(g):w.call(l,g)},n.prototype.listenerCount=w;function w(l){var g=this._events;if(g!==void 0){var p=g[l];if(typeof p=="function")return 1;if(p!==void 0)return p.length}return 0}n.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]};function x(l,g){for(var p=new Array(g),v=0;v<g;++v)p[v]=l[v];return p}function N(l,g){for(;g+1<l.length;g++)l[g]=l[g+1];l.pop()}function $(l){for(var g=new Array(l.length),p=0;p<g.length;++p)g[p]=l[p].listener||l[p];return g}function y(l,g){return new Promise(function(p,v){function b(A){l.removeListener(g,G),v(A)}function G(){typeof l.removeListener=="function"&&l.removeListener("error",b),p([].slice.call(arguments))}m(l,g,G,{once:!0}),g!=="error"&&k(l,b,{once:!0})})}function k(l,g,p){typeof l.on=="function"&&m(l,"error",g,p)}function m(l,g,p,v){if(typeof l.on=="function")v.once?l.once(g,p):l.on(g,p);else if(typeof l.addEventListener=="function")l.addEventListener(g,function b(G){v.once&&l.removeEventListener(g,b),p(G)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof l)}return gt.exports}var xe=$e(),At,Rt;function pt(){if(Rt)return At;Rt=1;function o(t){if(typeof t!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=t}return typeof Symbol<"u"&&(o.prototype[Symbol.iterator]=function(){return this}),o.of=function(){var t=arguments,e=t.length,i=0;return new o(function(){return i>=e?{done:!0}:{done:!1,value:t[i++]}})},o.empty=function(){var t=new o(function(){return{done:!0}});return t},o.fromSequence=function(t){var e=0,i=t.length;return new o(function(){return e>=i?{done:!0}:{done:!1,value:t[e++]}})},o.is=function(t){return t instanceof o?!0:typeof t=="object"&&t!==null&&typeof t.next=="function"},At=o,At}var ke=pt();const X=vt(ke);var yt={},qt;function De(){return qt||(qt=1,yt.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",yt.SYMBOL_SUPPORT=typeof Symbol<"u"),yt}var Gt,Bt;function se(){if(Bt)return Gt;Bt=1;var o=pt(),t=De(),e=t.ARRAY_BUFFER_SUPPORT,i=t.SYMBOL_SUPPORT;function r(n){return typeof n=="string"||Array.isArray(n)||e&&ArrayBuffer.isView(n)?o.fromSequence(n):typeof n!="object"||n===null?null:i&&typeof n[Symbol.iterator]=="function"?n[Symbol.iterator]():typeof n.next=="function"?n:null}return Gt=function(u){var s=r(u);if(!s)throw new Error("obliterator: target is not iterable nor a valid iterator.");return s},Gt}var _t,Ft;function Ne(){if(Ft)return _t;Ft=1;var o=se();return _t=function(e,i){for(var r=arguments.length>1?i:1/0,n=r!==1/0?new Array(r):[],u,s=0,h=o(e);;){if(s===r)return n;if(u=h.next(),u.done)return s!==i&&(n.length=s),n;n[s++]=u.value}},_t}var Le=Ne();const ae=vt(Le);var $t,Kt;function Se(){if(Kt)return $t;Kt=1;var o=pt(),t=se();return $t=function(){var i=arguments,r=null,n=-1;return new o(function(){var s=null;do{if(r===null){if(n++,n>=i.length)return{done:!0};r=t(i[n])}if(s=r.next(),s.done===!0){r=null;continue}break}while(!0);return s})},$t}var We=Se();const it=vt(We);function Ce(){const o=arguments[0];for(let t=1,e=arguments.length;t<e;t++)if(arguments[t])for(const i in arguments[t])o[i]=arguments[t][i];return o}let j=Ce;typeof Object.assign=="function"&&(j=Object.assign);function H(o,t,e,i){const r=o._nodes.get(t);let n=null;return r&&(i==="mixed"?n=r.out&&r.out[e]||r.undirected&&r.undirected[e]:i==="directed"?n=r.out&&r.out[e]:n=r.undirected&&r.undirected[e]),n}function P(o){return typeof o=="object"&&o!==null}function ue(o){let t;for(t in o)return!1;return!0}function Q(o,t,e){Object.defineProperty(o,t,{enumerable:!1,configurable:!1,writable:!0,value:e})}function J(o,t,e){const i={enumerable:!0,configurable:!0};typeof e=="function"?i.get=e:(i.value=e,i.writable=!1),Object.defineProperty(o,t,i)}function Yt(o){return!(!P(o)||o.attributes&&!Array.isArray(o.attributes))}function Me(){let o=Math.floor(Math.random()*256)&255;return()=>o++}class Ut extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class _ extends Ut{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,_.prototype.constructor)}}class E extends Ut{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,E.prototype.constructor)}}class D extends Ut{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}function he(o,t){this.key=o,this.attributes=t,this.clear()}he.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 de(o,t){this.key=o,this.attributes=t,this.clear()}de.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function fe(o,t){this.key=o,this.attributes=t,this.clear()}fe.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ut(o,t,e,i,r){this.key=t,this.attributes=r,this.undirected=o,this.source=e,this.target=i}ut.prototype.attach=function(){let o="out",t="in";this.undirected&&(o=t="undirected");const e=this.source.key,i=this.target.key;this.source[o][i]=this,!(this.undirected&&e===i)&&(this.target[t][e]=this)};ut.prototype.attachMulti=function(){let o="out",t="in";const e=this.source.key,i=this.target.key;this.undirected&&(o=t="undirected");const r=this.source[o],n=r[i];if(typeof n>"u"){r[i]=this,this.undirected&&e===i||(this.target[t][e]=this);return}n.previous=this,this.next=n,r[i]=this,this.target[t][e]=this};ut.prototype.detach=function(){const o=this.source.key,t=this.target.key;let e="out",i="in";this.undirected&&(e=i="undirected"),delete this.source[e][t],delete this.target[i][o]};ut.prototype.detachMulti=function(){const o=this.source.key,t=this.target.key;let e="out",i="in";this.undirected&&(e=i="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[e][t],delete this.target[i][o]):(this.next.previous=void 0,this.source[e][t]=this.next,this.target[i][o]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const ce=0,le=1,Ie=2,pe=3;function rt(o,t,e,i,r,n,u){let s,h,a,d;if(i=""+i,e===ce){if(s=o._nodes.get(i),!s)throw new E(`Graph.${t}: could not find the "${i}" node in the graph.`);a=r,d=n}else if(e===pe){if(r=""+r,h=o._edges.get(r),!h)throw new E(`Graph.${t}: could not find the "${r}" edge in the graph.`);const f=h.source.key,c=h.target.key;if(i===f)s=h.target;else if(i===c)s=h.source;else throw new E(`Graph.${t}: the "${i}" node is not attached to the "${r}" edge (${f}, ${c}).`);a=n,d=u}else{if(h=o._edges.get(i),!h)throw new E(`Graph.${t}: could not find the "${i}" edge in the graph.`);e===le?s=h.source:s=h.target,a=r,d=n}return[s,a,d]}function Ue(o,t,e){o.prototype[t]=function(i,r,n){const[u,s]=rt(this,t,e,i,r,n);return u.attributes[s]}}function ze(o,t,e){o.prototype[t]=function(i,r){const[n]=rt(this,t,e,i,r);return n.attributes}}function Oe(o,t,e){o.prototype[t]=function(i,r,n){const[u,s]=rt(this,t,e,i,r,n);return u.attributes.hasOwnProperty(s)}}function je(o,t,e){o.prototype[t]=function(i,r,n,u){const[s,h,a]=rt(this,t,e,i,r,n,u);return s.attributes[h]=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:h}),this}}function Te(o,t,e){o.prototype[t]=function(i,r,n,u){const[s,h,a]=rt(this,t,e,i,r,n,u);if(typeof a!="function")throw new _(`Graph.${t}: updater should be a function.`);const d=s.attributes,f=a(d[h]);return d[h]=f,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:h}),this}}function Pe(o,t,e){o.prototype[t]=function(i,r,n){const[u,s]=rt(this,t,e,i,r,n);return delete u.attributes[s],this.emit("nodeAttributesUpdated",{key:u.key,type:"remove",attributes:u.attributes,name:s}),this}}function Re(o,t,e){o.prototype[t]=function(i,r,n){const[u,s]=rt(this,t,e,i,r,n);if(!P(s))throw new _(`Graph.${t}: provided attributes are not a plain object.`);return u.attributes=s,this.emit("nodeAttributesUpdated",{key:u.key,type:"replace",attributes:u.attributes}),this}}function qe(o,t,e){o.prototype[t]=function(i,r,n){const[u,s]=rt(this,t,e,i,r,n);if(!P(s))throw new _(`Graph.${t}: provided attributes are not a plain object.`);return j(u.attributes,s),this.emit("nodeAttributesUpdated",{key:u.key,type:"merge",attributes:u.attributes,data:s}),this}}function Be(o,t,e){o.prototype[t]=function(i,r,n){const[u,s]=rt(this,t,e,i,r,n);if(typeof s!="function")throw new _(`Graph.${t}: provided updater is not a function.`);return u.attributes=s(u.attributes),this.emit("nodeAttributesUpdated",{key:u.key,type:"update",attributes:u.attributes}),this}}const Fe=[{name:o=>`get${o}Attribute`,attacher:Ue},{name:o=>`get${o}Attributes`,attacher:ze},{name:o=>`has${o}Attribute`,attacher:Oe},{name:o=>`set${o}Attribute`,attacher:je},{name:o=>`update${o}Attribute`,attacher:Te},{name:o=>`remove${o}Attribute`,attacher:Pe},{name:o=>`replace${o}Attributes`,attacher:Re},{name:o=>`merge${o}Attributes`,attacher:qe},{name:o=>`update${o}Attributes`,attacher:Be}];function Ke(o){Fe.forEach(function({name:t,attacher:e}){e(o,t("Node"),ce),e(o,t("Source"),le),e(o,t("Target"),Ie),e(o,t("Opposite"),pe)})}function Ye(o,t,e){o.prototype[t]=function(i,r){let n;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+i,s=""+r;if(r=arguments[2],n=H(this,u,s,e),!n)throw new E(`Graph.${t}: could not find an edge for the given path ("${u}" - "${s}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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 E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return n.attributes[r]}}function Ve(o,t,e){o.prototype[t]=function(i){let r;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const n=""+i,u=""+arguments[1];if(r=H(this,n,u,e),!r)throw new E(`Graph.${t}: could not find an edge for the given path ("${n}" - "${u}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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,r=this._edges.get(i),!r)throw new E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return r.attributes}}function Qe(o,t,e){o.prototype[t]=function(i,r){let n;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+i,s=""+r;if(r=arguments[2],n=H(this,u,s,e),!n)throw new E(`Graph.${t}: could not find an edge for the given path ("${u}" - "${s}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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 E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return n.attributes.hasOwnProperty(r)}}function He(o,t,e){o.prototype[t]=function(i,r,n){let u;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+i,h=""+r;if(r=arguments[2],n=arguments[3],u=H(this,s,h,e),!u)throw new E(`Graph.${t}: could not find an edge for the given path ("${s}" - "${h}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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,u=this._edges.get(i),!u)throw new E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return u.attributes[r]=n,this.emit("edgeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:r}),this}}function Xe(o,t,e){o.prototype[t]=function(i,r,n){let u;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+i,h=""+r;if(r=arguments[2],n=arguments[3],u=H(this,s,h,e),!u)throw new E(`Graph.${t}: could not find an edge for the given path ("${s}" - "${h}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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,u=this._edges.get(i),!u)throw new E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(typeof n!="function")throw new _(`Graph.${t}: updater should be a function.`);return u.attributes[r]=n(u.attributes[r]),this.emit("edgeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:r}),this}}function Je(o,t,e){o.prototype[t]=function(i,r){let n;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+i,s=""+r;if(r=arguments[2],n=H(this,u,s,e),!n)throw new E(`Graph.${t}: could not find an edge for the given path ("${u}" - "${s}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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 E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return delete n.attributes[r],this.emit("edgeAttributesUpdated",{key:n.key,type:"remove",attributes:n.attributes,name:r}),this}}function Ze(o,t,e){o.prototype[t]=function(i,r){let n;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+i,s=""+r;if(r=arguments[2],n=H(this,u,s,e),!n)throw new E(`Graph.${t}: could not find an edge for the given path ("${u}" - "${s}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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 E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(!P(r))throw new _(`Graph.${t}: provided attributes are not a plain object.`);return n.attributes=r,this.emit("edgeAttributesUpdated",{key:n.key,type:"replace",attributes:n.attributes}),this}}function ti(o,t,e){o.prototype[t]=function(i,r){let n;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+i,s=""+r;if(r=arguments[2],n=H(this,u,s,e),!n)throw new E(`Graph.${t}: could not find an edge for the given path ("${u}" - "${s}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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 E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(!P(r))throw new _(`Graph.${t}: provided attributes are not a plain object.`);return j(n.attributes,r),this.emit("edgeAttributesUpdated",{key:n.key,type:"merge",attributes:n.attributes,data:r}),this}}function ei(o,t,e){o.prototype[t]=function(i,r){let n;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+i,s=""+r;if(r=arguments[2],n=H(this,u,s,e),!n)throw new E(`Graph.${t}: could not find an edge for the given path ("${u}" - "${s}").`)}else{if(e!=="mixed")throw new D(`Graph.${t}: 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 E(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(typeof r!="function")throw new _(`Graph.${t}: provided updater is not a function.`);return n.attributes=r(n.attributes),this.emit("edgeAttributesUpdated",{key:n.key,type:"update",attributes:n.attributes}),this}}const ii=[{name:o=>`get${o}Attribute`,attacher:Ye},{name:o=>`get${o}Attributes`,attacher:Ve},{name:o=>`has${o}Attribute`,attacher:Qe},{name:o=>`set${o}Attribute`,attacher:He},{name:o=>`update${o}Attribute`,attacher:Xe},{name:o=>`remove${o}Attribute`,attacher:Je},{name:o=>`replace${o}Attributes`,attacher:Ze},{name:o=>`merge${o}Attributes`,attacher:ti},{name:o=>`update${o}Attributes`,attacher:ei}];function ri(o){ii.forEach(function({name:t,attacher:e}){e(o,t("Edge"),"mixed"),e(o,t("DirectedEdge"),"directed"),e(o,t("UndirectedEdge"),"undirected")})}const ni=[{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 oi(o,t,e,i){let r=!1;for(const n in t){if(n===i)continue;const u=t[n];if(r=e(u.key,u.attributes,u.source.key,u.target.key,u.source.attributes,u.target.attributes,u.undirected),o&&r)return u.key}}function si(o,t,e,i){let r,n,u,s=!1;for(const h in t)if(h!==i){r=t[h];do{if(n=r.source,u=r.target,s=e(r.key,r.attributes,n.key,u.key,n.attributes,u.attributes,r.undirected),o&&s)return r.key;r=r.next}while(r!==void 0)}}function xt(o,t){const e=Object.keys(o),i=e.length;let r,n=0;return new X(function(){do if(r)r=r.next;else{if(n>=i)return{done:!0};const s=e[n++];if(s===t){r=void 0;continue}r=o[s]}while(!r);return{done:!1,value:{edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected}}})}function ai(o,t,e,i){const r=t[e];if(!r)return;const n=r.source,u=r.target;if(i(r.key,r.attributes,n.key,u.key,n.attributes,u.attributes,r.undirected)&&o)return r.key}function ui(o,t,e,i){let r=t[e];if(!r)return;let n=!1;do{if(n=i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),o&&n)return r.key;r=r.next}while(r!==void 0)}function kt(o,t){let e=o[t];return e.next!==void 0?new X(function(){if(!e)return{done:!0};const i={edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected};return e=e.next,{done:!1,value:i}}):X.of({edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected})}function hi(o,t){if(o.size===0)return[];if(t==="mixed"||t===o.type)return typeof Array.from=="function"?Array.from(o._edges.keys()):ae(o._edges.keys(),o._edges.size);const e=t==="undirected"?o.undirectedSize:o.directedSize,i=new Array(e),r=t==="undirected",n=o._edges.values();let u=0,s,h;for(;s=n.next(),s.done!==!0;)h=s.value,h.undirected===r&&(i[u++]=h.key);return i}function ge(o,t,e,i){if(t.size===0)return;const r=e!=="mixed"&&e!==t.type,n=e==="undirected";let u,s,h=!1;const a=t._edges.values();for(;u=a.next(),u.done!==!0;){if(s=u.value,r&&s.undirected!==n)continue;const{key:d,attributes:f,source:c,target:w}=s;if(h=i(d,f,c.key,w.key,c.attributes,w.attributes,s.undirected),o&&h)return d}}function di(o,t){if(o.size===0)return X.empty();const e=t!=="mixed"&&t!==o.type,i=t==="undirected",r=o._edges.values();return new X(function(){let u,s;for(;;){if(u=r.next(),u.done)return u;if(s=u.value,!(e&&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 zt(o,t,e,i,r,n){const u=t?si:oi;let s;if(e!=="undirected"&&(i!=="out"&&(s=u(o,r.in,n),o&&s)||i!=="in"&&(s=u(o,r.out,n,i?void 0:r.key),o&&s))||e!=="directed"&&(s=u(o,r.undirected,n),o&&s))return s}function fi(o,t,e,i){const r=[];return zt(!1,o,t,e,i,function(n){r.push(n)}),r}function ci(o,t,e){let i=X.empty();return o!=="undirected"&&(t!=="out"&&typeof e.in<"u"&&(i=it(i,xt(e.in))),t!=="in"&&typeof e.out<"u"&&(i=it(i,xt(e.out,t?void 0:e.key)))),o!=="directed"&&typeof e.undirected<"u"&&(i=it(i,xt(e.undirected))),i}function Ot(o,t,e,i,r,n,u){const s=e?ui:ai;let h;if(t!=="undirected"&&(typeof r.in<"u"&&i!=="out"&&(h=s(o,r.in,n,u),o&&h)||typeof r.out<"u"&&i!=="in"&&(i||r.key!==n)&&(h=s(o,r.out,n,u),o&&h))||t!=="directed"&&typeof r.undirected<"u"&&(h=s(o,r.undirected,n,u),o&&h))return h}function li(o,t,e,i,r){const n=[];return Ot(!1,o,t,e,i,r,function(u){n.push(u)}),n}function pi(o,t,e,i){let r=X.empty();return o!=="undirected"&&(typeof e.in<"u"&&t!=="out"&&i in e.in&&(r=it(r,kt(e.in,i))),typeof e.out<"u"&&t!=="in"&&i in e.out&&(t||e.key!==i)&&(r=it(r,kt(e.out,i)))),o!=="directed"&&typeof e.undirected<"u"&&i in e.undirected&&(r=it(r,kt(e.undirected,i))),r}function gi(o,t){const{name:e,type:i,direction:r}=t;o.prototype[e]=function(n,u){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];if(!arguments.length)return hi(this,i);if(arguments.length===1){n=""+n;const s=this._nodes.get(n);if(typeof s>"u")throw new E(`Graph.${e}: could not find the "${n}" node in the graph.`);return fi(this.multi,i==="mixed"?this.type:i,r,s)}if(arguments.length===2){n=""+n,u=""+u;const s=this._nodes.get(n);if(!s)throw new E(`Graph.${e}: could not find the "${n}" source node in the graph.`);if(!this._nodes.has(u))throw new E(`Graph.${e}: could not find the "${u}" target node in the graph.`);return li(i,this.multi,r,s,u)}throw new _(`Graph.${e}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function yi(o,t){const{name:e,type:i,direction:r}=t,n="forEach"+e[0].toUpperCase()+e.slice(1,-1);o.prototype[n]=function(a,d,f){if(!(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)){if(arguments.length===1)return f=a,ge(!1,this,i,f);if(arguments.length===2){a=""+a,f=d;const c=this._nodes.get(a);if(typeof c>"u")throw new E(`Graph.${n}: could not find the "${a}" node in the graph.`);return zt(!1,this.multi,i==="mixed"?this.type:i,r,c,f)}if(arguments.length===3){a=""+a,d=""+d;const c=this._nodes.get(a);if(!c)throw new E(`Graph.${n}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(d))throw new E(`Graph.${n}: could not find the "${d}" target node in the graph.`);return Ot(!1,i,this.multi,r,c,d,f)}throw new _(`Graph.${n}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const u="map"+e[0].toUpperCase()+e.slice(1);o.prototype[u]=function(){const a=Array.prototype.slice.call(arguments),d=a.pop();let f;if(a.length===0){let c=0;i!=="directed"&&(c+=this.undirectedSize),i!=="undirected"&&(c+=this.directedSize),f=new Array(c);let w=0;a.push((x,N,$,y,k,m,l)=>{f[w++]=d(x,N,$,y,k,m,l)})}else f=[],a.push((c,w,x,N,$,y,k)=>{f.push(d(c,w,x,N,$,y,k))});return this[n].apply(this,a),f};const s="filter"+e[0].toUpperCase()+e.slice(1);o.prototype[s]=function(){const a=Array.prototype.slice.call(arguments),d=a.pop(),f=[];return a.push((c,w,x,N,$,y,k)=>{d(c,w,x,N,$,y,k)&&f.push(c)}),this[n].apply(this,a),f};const h="reduce"+e[0].toUpperCase()+e.slice(1);o.prototype[h]=function(){let a=Array.prototype.slice.call(arguments);if(a.length<2||a.length>4)throw new _(`Graph.${h}: invalid number of arguments (expecting 2, 3 or 4 and got ${a.length}).`);if(typeof a[a.length-1]=="function"&&typeof a[a.length-2]!="function")throw new _(`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 d,f;a.length===2?(d=a[0],f=a[1],a=[]):a.length===3?(d=a[1],f=a[2],a=[a[0]]):a.length===4&&(d=a[2],f=a[3],a=[a[0],a[1]]);let c=f;return a.push((w,x,N,$,y,k,m)=>{c=d(c,w,x,N,$,y,k,m)}),this[n].apply(this,a),c}}function wi(o,t){const{name:e,type:i,direction:r}=t,n="find"+e[0].toUpperCase()+e.slice(1,-1);o.prototype[n]=function(h,a,d){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return!1;if(arguments.length===1)return d=h,ge(!0,this,i,d);if(arguments.length===2){h=""+h,d=a;const f=this._nodes.get(h);if(typeof f>"u")throw new E(`Graph.${n}: could not find the "${h}" node in the graph.`);return zt(!0,this.multi,i==="mixed"?this.type:i,r,f,d)}if(arguments.length===3){h=""+h,a=""+a;const f=this._nodes.get(h);if(!f)throw new E(`Graph.${n}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(a))throw new E(`Graph.${n}: could not find the "${a}" target node in the graph.`);return Ot(!0,i,this.multi,r,f,a,d)}throw new _(`Graph.${n}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const u="some"+e[0].toUpperCase()+e.slice(1,-1);o.prototype[u]=function(){const h=Array.prototype.slice.call(arguments),a=h.pop();return h.push((f,c,w,x,N,$,y)=>a(f,c,w,x,N,$,y)),!!this[n].apply(this,h)};const s="every"+e[0].toUpperCase()+e.slice(1,-1);o.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),a=h.pop();return h.push((f,c,w,x,N,$,y)=>!a(f,c,w,x,N,$,y)),!this[n].apply(this,h)}}function mi(o,t){const{name:e,type:i,direction:r}=t,n=e.slice(0,-1)+"Entries";o.prototype[n]=function(u,s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return X.empty();if(!arguments.length)return di(this,i);if(arguments.length===1){u=""+u;const h=this._nodes.get(u);if(!h)throw new E(`Graph.${n}: could not find the "${u}" node in the graph.`);return ci(i,r,h)}if(arguments.length===2){u=""+u,s=""+s;const h=this._nodes.get(u);if(!h)throw new E(`Graph.${n}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(s))throw new E(`Graph.${n}: could not find the "${s}" target node in the graph.`);return pi(i,r,h,s)}throw new _(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function vi(o){ni.forEach(t=>{gi(o,t),yi(o,t),wi(o,t),mi(o,t)})}const bi=[{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 bt(){this.A=null,this.B=null}bt.prototype.wrap=function(o){this.A===null?this.A=o:this.B===null&&(this.B=o)};bt.prototype.has=function(o){return this.A!==null&&o in this.A||this.B!==null&&o in this.B};function ft(o,t,e,i,r){for(const n in i){const u=i[n],s=u.source,h=u.target,a=s===e?h:s;if(t&&t.has(a.key))continue;const d=r(a.key,a.attributes);if(o&&d)return a.key}}function jt(o,t,e,i,r){if(t!=="mixed"){if(t==="undirected")return ft(o,null,i,i.undirected,r);if(typeof e=="string")return ft(o,null,i,i[e],r)}const n=new bt;let u;if(t!=="undirected"){if(e!=="out"){if(u=ft(o,null,i,i.in,r),o&&u)return u;n.wrap(i.in)}if(e!=="in"){if(u=ft(o,n,i,i.out,r),o&&u)return u;n.wrap(i.out)}}if(t!=="directed"&&(u=ft(o,n,i,i.undirected,r),o&&u))return u}function Ei(o,t,e){if(o!=="mixed"){if(o==="undirected")return Object.keys(e.undirected);if(typeof t=="string")return Object.keys(e[t])}const i=[];return jt(!1,o,t,e,function(r){i.push(r)}),i}function ct(o,t,e){const i=Object.keys(e),r=i.length;let n=0;return new X(function(){let s=null;do{if(n>=r)return o&&o.wrap(e),{done:!0};const h=e[i[n++]],a=h.source,d=h.target;if(s=a===t?d:a,o&&o.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}})}function Ai(o,t,e){if(o!=="mixed"){if(o==="undirected")return ct(null,e,e.undirected);if(typeof t=="string")return ct(null,e,e[t])}let i=X.empty();const r=new bt;return o!=="undirected"&&(t!=="out"&&(i=it(i,ct(r,e,e.in))),t!=="in"&&(i=it(i,ct(r,e,e.out)))),o!=="directed"&&(i=it(i,ct(r,e,e.undirected))),i}function Gi(o,t){const{name:e,type:i,direction:r}=t;o.prototype[e]=function(n){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];n=""+n;const u=this._nodes.get(n);if(typeof u>"u")throw new E(`Graph.${e}: could not find the "${n}" node in the graph.`);return Ei(i==="mixed"?this.type:i,r,u)}}function _i(o,t){const{name:e,type:i,direction:r}=t,n="forEach"+e[0].toUpperCase()+e.slice(1,-1);o.prototype[n]=function(a,d){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;a=""+a;const f=this._nodes.get(a);if(typeof f>"u")throw new E(`Graph.${n}: could not find the "${a}" node in the graph.`);jt(!1,i==="mixed"?this.type:i,r,f,d)};const u="map"+e[0].toUpperCase()+e.slice(1);o.prototype[u]=function(a,d){const f=[];return this[n](a,(c,w)=>{f.push(d(c,w))}),f};const s="filter"+e[0].toUpperCase()+e.slice(1);o.prototype[s]=function(a,d){const f=[];return this[n](a,(c,w)=>{d(c,w)&&f.push(c)}),f};const h="reduce"+e[0].toUpperCase()+e.slice(1);o.prototype[h]=function(a,d,f){if(arguments.length<3)throw new _(`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 c=f;return this[n](a,(w,x)=>{c=d(c,w,x)}),c}}function $i(o,t){const{name:e,type:i,direction:r}=t,n=e[0].toUpperCase()+e.slice(1,-1),u="find"+n;o.prototype[u]=function(a,d){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;a=""+a;const f=this._nodes.get(a);if(typeof f>"u")throw new E(`Graph.${u}: could not find the "${a}" node in the graph.`);return jt(!0,i==="mixed"?this.type:i,r,f,d)};const s="some"+n;o.prototype[s]=function(a,d){return!!this[u](a,d)};const h="every"+n;o.prototype[h]=function(a,d){return!this[u](a,(c,w)=>!d(c,w))}}function xi(o,t){const{name:e,type:i,direction:r}=t,n=e.slice(0,-1)+"Entries";o.prototype[n]=function(u){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return X.empty();u=""+u;const s=this._nodes.get(u);if(typeof s>"u")throw new E(`Graph.${n}: could not find the "${u}" node in the graph.`);return Ai(i==="mixed"?this.type:i,r,s)}}function ki(o){bi.forEach(t=>{Gi(o,t),_i(o,t),$i(o,t),xi(o,t)})}function wt(o,t,e,i,r){const n=i._nodes.values(),u=i.type;let s,h,a,d,f,c;for(;s=n.next(),s.done!==!0;){let w=!1;if(h=s.value,u!=="undirected"){d=h.out;for(a in d){f=d[a];do c=f.target,w=!0,r(h.key,c.key,h.attributes,c.attributes,f.key,f.attributes,f.undirected),f=f.next;while(f)}}if(u!=="directed"){d=h.undirected;for(a in d)if(!(t&&h.key>a)){f=d[a];do c=f.target,c.key!==a&&(c=f.source),w=!0,r(h.key,c.key,h.attributes,c.attributes,f.key,f.attributes,f.undirected),f=f.next;while(f)}}e&&!w&&r(h.key,null,h.attributes,null,null,null,null)}}function Di(o,t){const e={key:o};return ue(t.attributes)||(e.attributes=j({},t.attributes)),e}function Ni(o,t,e){const i={key:t,source:e.source.key,target:e.target.key};return ue(e.attributes)||(i.attributes=j({},e.attributes)),o==="mixed"&&e.undirected&&(i.undirected=!0),i}function Li(o){if(!P(o))throw new _('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in o))throw new _("Graph.import: serialized node is missing its key.");if("attributes"in o&&(!P(o.attributes)||o.attributes===null))throw new _("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Si(o){if(!P(o))throw new _('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in o))throw new _("Graph.import: serialized edge is missing its source.");if(!("target"in o))throw new _("Graph.import: serialized edge is missing its target.");if("attributes"in o&&(!P(o.attributes)||o.attributes===null))throw new _("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in o&&typeof o.undirected!="boolean")throw new _("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Wi=Me(),Ci=new Set(["directed","undirected","mixed"]),Vt=new Set(["domain","_events","_eventsCount","_maxListeners"]),Mi=[{name:o=>`${o}Edge`,generateKey:!0},{name:o=>`${o}DirectedEdge`,generateKey:!0,type:"directed"},{name:o=>`${o}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:o=>`${o}EdgeWithKey`},{name:o=>`${o}DirectedEdgeWithKey`,type:"directed"},{name:o=>`${o}UndirectedEdgeWithKey`,type:"undirected"}],Ii={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ui(o,t,e){if(e&&!P(e))throw new _(`Graph.addNode: invalid attributes. Expecting an object but got "${e}"`);if(t=""+t,e=e||{},o._nodes.has(t))throw new D(`Graph.addNode: the "${t}" node already exist in the graph.`);const i=new o.NodeDataClass(t,e);return o._nodes.set(t,i),o.emit("nodeAdded",{key:t,attributes:e}),i}function Qt(o,t,e){const i=new o.NodeDataClass(t,e);return o._nodes.set(t,i),o.emit("nodeAdded",{key:t,attributes:e}),i}function ye(o,t,e,i,r,n,u,s){if(!i&&o.type==="undirected")throw new D(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(i&&o.type==="directed")throw new D(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!P(s))throw new _(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(n=""+n,u=""+u,s=s||{},!o.allowSelfLoops&&n===u)throw new D(`Graph.${t}: source & target are the same ("${n}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const h=o._nodes.get(n),a=o._nodes.get(u);if(!h)throw new E(`Graph.${t}: source node "${n}" not found.`);if(!a)throw new E(`Graph.${t}: target node "${u}" not found.`);const d={key:null,undirected:i,source:n,target:u,attributes:s};if(e)r=o._edgeKeyGenerator();else if(r=""+r,o._edges.has(r))throw new D(`Graph.${t}: the "${r}" edge already exists in the graph.`);if(!o.multi&&(i?typeof h.undirected[u]<"u":typeof h.out[u]<"u"))throw new D(`Graph.${t}: an edge linking "${n}" to "${u}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const f=new ut(i,r,h,a,s);o._edges.set(r,f);const c=n===u;return i?(h.undirectedDegree++,a.undirectedDegree++,c&&(h.undirectedLoops++,o._undirectedSelfLoopCount++)):(h.outDegree++,a.inDegree++,c&&(h.directedLoops++,o._directedSelfLoopCount++)),o.multi?f.attachMulti():f.attach(),i?o._undirectedSize++:o._directedSize++,d.key=r,o.emit("edgeAdded",d),r}function zi(o,t,e,i,r,n,u,s,h){if(!i&&o.type==="undirected")throw new D(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&o.type==="directed")throw new D(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(h){if(typeof s!="function")throw new _(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!P(s))throw new _(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}n=""+n,u=""+u;let a;if(h&&(a=s,s=void 0),!o.allowSelfLoops&&n===u)throw new D(`Graph.${t}: source & target are the same ("${n}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=o._nodes.get(n),f=o._nodes.get(u),c,w;if(!e&&(c=o._edges.get(r),c)){if((c.source.key!==n||c.target.key!==u)&&(!i||c.source.key!==u||c.target.key!==n))throw new D(`Graph.${t}: inconsistency detected when attempting to merge the "${r}" edge with "${n}" source & "${u}" target vs. ("${c.source.key}", "${c.target.key}").`);w=c}if(!w&&!o.multi&&d&&(w=i?d.undirected[u]:d.out[u]),w){const k=[w.key,!1,!1,!1];if(h?!a:!s)return k;if(h){const m=w.attributes;w.attributes=a(m),o.emit("edgeAttributesUpdated",{type:"replace",key:w.key,attributes:w.attributes})}else j(w.attributes,s),o.emit("edgeAttributesUpdated",{type:"merge",key:w.key,attributes:w.attributes,data:s});return k}s=s||{},h&&a&&(s=a(s));const x={key:null,undirected:i,source:n,target:u,attributes:s};if(e)r=o._edgeKeyGenerator();else if(r=""+r,o._edges.has(r))throw new D(`Graph.${t}: the "${r}" edge already exists in the graph.`);let N=!1,$=!1;d||(d=Qt(o,n,{}),N=!0,n===u&&(f=d,$=!0)),f||(f=Qt(o,u,{}),$=!0),c=new ut(i,r,d,f,s),o._edges.set(r,c);const y=n===u;return i?(d.undirectedDegree++,f.undirectedDegree++,y&&(d.undirectedLoops++,o._undirectedSelfLoopCount++)):(d.outDegree++,f.inDegree++,y&&(d.directedLoops++,o._directedSelfLoopCount++)),o.multi?c.attachMulti():c.attach(),i?o._undirectedSize++:o._directedSize++,x.key=r,o.emit("edgeAdded",x),[r,!0,N,$]}function at(o,t){o._edges.delete(t.key);const{source:e,target:i,attributes:r}=t,n=t.undirected,u=e===i;n?(e.undirectedDegree--,i.undirectedDegree--,u&&(e.undirectedLoops--,o._undirectedSelfLoopCount--)):(e.outDegree--,i.inDegree--,u&&(e.directedLoops--,o._directedSelfLoopCount--)),o.multi?t.detachMulti():t.detach(),n?o._undirectedSize--:o._directedSize--,o.emit("edgeDropped",{key:t.key,attributes:r,source:e.key,target:i.key,undirected:n})}class I extends xe.EventEmitter{constructor(t){if(super(),t=j({},Ii,t),typeof t.multi!="boolean")throw new _(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!Ci.has(t.type))throw new _(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new _(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const e=t.type==="mixed"?he:t.type==="directed"?de:fe;Q(this,"NodeDataClass",e);const i="geid_"+Wi()+"_";let r=0;const n=()=>{let u;do u=i+r++;while(this._edges.has(u));return u};Q(this,"_attributes",{}),Q(this,"_nodes",new Map),Q(this,"_edges",new Map),Q(this,"_directedSize",0),Q(this,"_undirectedSize",0),Q(this,"_directedSelfLoopCount",0),Q(this,"_undirectedSelfLoopCount",0),Q(this,"_edgeKeyGenerator",n),Q(this,"_options",t),Vt.forEach(u=>Q(this,u,this[u])),J(this,"order",()=>this._nodes.size),J(this,"size",()=>this._edges.size),J(this,"directedSize",()=>this._directedSize),J(this,"undirectedSize",()=>this._undirectedSize),J(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),J(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),J(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),J(this,"multi",this._options.multi),J(this,"type",this._options.type),J(this,"allowSelfLoops",this._options.allowSelfLoops),J(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,e){if(this.type==="undirected")return!1;if(arguments.length===1){const i=""+t,r=this._edges.get(i);return!!r&&!r.undirected}else if(arguments.length===2){t=""+t,e=""+e;const i=this._nodes.get(t);return i?i.out.hasOwnProperty(e):!1}throw new _(`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(t,e){if(this.type==="directed")return!1;if(arguments.length===1){const i=""+t,r=this._edges.get(i);return!!r&&r.undirected}else if(arguments.length===2){t=""+t,e=""+e;const i=this._nodes.get(t);return i?i.undirected.hasOwnProperty(e):!1}throw new _(`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(t,e){if(arguments.length===1){const i=""+t;return this._edges.has(i)}else if(arguments.length===2){t=""+t,e=""+e;const i=this._nodes.get(t);return i?typeof i.out<"u"&&i.out.hasOwnProperty(e)||typeof i.undirected<"u"&&i.undirected.hasOwnProperty(e):!1}throw new _(`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(t,e){if(this.type==="undirected")return;if(t=""+t,e=""+e,this.multi)throw new D("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const i=this._nodes.get(t);if(!i)throw new E(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(e))throw new E(`Graph.directedEdge: could not find the "${e}" target node in the graph.`);const r=i.out&&i.out[e]||void 0;if(r)return r.key}undirectedEdge(t,e){if(this.type==="directed")return;if(t=""+t,e=""+e,this.multi)throw new D("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const i=this._nodes.get(t);if(!i)throw new E(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(e))throw new E(`Graph.undirectedEdge: could not find the "${e}" target node in the graph.`);const r=i.undirected&&i.undirected[e]||void 0;if(r)return r.key}edge(t,e){if(this.multi)throw new D("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(e))throw new E(`Graph.edge: could not find the "${e}" target node in the graph.`);const r=i.out&&i.out[e]||i.undirected&&i.undirected[e]||void 0;if(r)return r.key}areDirectedNeighbors(t,e){t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:e in i.in||e in i.out}areOutNeighbors(t,e){t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:e in i.out}areInNeighbors(t,e){t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:e in i.in}areUndirectedNeighbors(t,e){t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:e in i.undirected}areNeighbors(t,e){t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(e in i.in||e in i.out)||this.type!=="directed"&&e in i.undirected}areInboundNeighbors(t,e){t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&e in i.in||this.type!=="directed"&&e in i.undirected}areOutboundNeighbors(t,e){t=""+t,e=""+e;const i=this._nodes.get(t);if(!i)throw new E(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&e in i.out||this.type!=="directed"&&e in i.undirected}inDegree(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:e.inDegree}outDegree(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:e.outDegree}directedDegree(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.outDegree}undirectedDegree(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:e.undirectedDegree}inboundDegree(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=e.undirectedDegree),this.type!=="undirected"&&(i+=e.inDegree),i}outboundDegree(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=e.undirectedDegree),this.type!=="undirected"&&(i+=e.outDegree),i}degree(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.degree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=e.undirectedDegree),this.type!=="undirected"&&(i+=e.inDegree+e.outDegree),i}inDegreeWithoutSelfLoops(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:e.inDegree-e.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:e.outDegree-e.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.outDegree-e.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:e.undirectedDegree-e.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=e.undirectedDegree,r+=e.undirectedLoops*2),this.type!=="undirected"&&(i+=e.inDegree,r+=e.directedLoops),i-r}outboundDegreeWithoutSelfLoops(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=e.undirectedDegree,r+=e.undirectedLoops*2),this.type!=="undirected"&&(i+=e.outDegree,r+=e.directedLoops),i-r}degreeWithoutSelfLoops(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=e.undirectedDegree,r+=e.undirectedLoops*2),this.type!=="undirected"&&(i+=e.inDegree+e.outDegree,r+=e.directedLoops*2),i-r}source(t){t=""+t;const e=this._edges.get(t);if(!e)throw new E(`Graph.source: could not find the "${t}" edge in the graph.`);return e.source.key}target(t){t=""+t;const e=this._edges.get(t);if(!e)throw new E(`Graph.target: could not find the "${t}" edge in the graph.`);return e.target.key}extremities(t){t=""+t;const e=this._edges.get(t);if(!e)throw new E(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[e.source.key,e.target.key]}opposite(t,e){t=""+t,e=""+e;const i=this._edges.get(e);if(!i)throw new E(`Graph.opposite: could not find the "${e}" edge in the graph.`);const r=i.source.key,n=i.target.key;if(t===r)return n;if(t===n)return r;throw new E(`Graph.opposite: the "${t}" node is not attached to the "${e}" edge (${r}, ${n}).`)}hasExtremity(t,e){t=""+t,e=""+e;const i=this._edges.get(t);if(!i)throw new E(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return i.source.key===e||i.target.key===e}isUndirected(t){t=""+t;const e=this._edges.get(t);if(!e)throw new E(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return e.undirected}isDirected(t){t=""+t;const e=this._edges.get(t);if(!e)throw new E(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!e.undirected}isSelfLoop(t){t=""+t;const e=this._edges.get(t);if(!e)throw new E(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return e.source===e.target}addNode(t,e){return Ui(this,t,e).key}mergeNode(t,e){if(e&&!P(e))throw new _(`Graph.mergeNode: invalid attributes. Expecting an object but got "${e}"`);t=""+t,e=e||{};let i=this._nodes.get(t);return i?(e&&(j(i.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:i.attributes,data:e})),[t,!1]):(i=new this.NodeDataClass(t,e),this._nodes.set(t,i),this.emit("nodeAdded",{key:t,attributes:e}),[t,!0])}updateNode(t,e){if(e&&typeof e!="function")throw new _(`Graph.updateNode: invalid updater function. Expecting a function but got "${e}"`);t=""+t;let i=this._nodes.get(t);if(i){if(e){const n=i.attributes;i.attributes=e(n),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:i.attributes})}return[t,!1]}const r=e?e({}):{};return i=new this.NodeDataClass(t,r),this._nodes.set(t,i),this.emit("nodeAdded",{key:t,attributes:r}),[t,!0]}dropNode(t){t=""+t;const e=this._nodes.get(t);if(!e)throw new E(`Graph.dropNode: could not find the "${t}" node in the graph.`);let i;if(this.type!=="undirected"){for(const r in e.out){i=e.out[r];do at(this,i),i=i.next;while(i)}for(const r in e.in){i=e.in[r];do at(this,i),i=i.next;while(i)}}if(this.type!=="directed")for(const r in e.undirected){i=e.undirected[r];do at(this,i),i=i.next;while(i)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:e.attributes})}dropEdge(t){let e;if(arguments.length>1){const i=""+arguments[0],r=""+arguments[1];if(e=H(this,i,r,this.type),!e)throw new E(`Graph.dropEdge: could not find the "${i}" -> "${r}" edge in the graph.`)}else if(t=""+t,e=this._edges.get(t),!e)throw new E(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return at(this,e),this}dropDirectedEdge(t,e){if(arguments.length<2)throw new D("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 D("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.");t=""+t,e=""+e;const i=H(this,t,e,"directed");if(!i)throw new E(`Graph.dropDirectedEdge: could not find a "${t}" -> "${e}" edge in the graph.`);return at(this,i),this}dropUndirectedEdge(t,e){if(arguments.length<2)throw new D("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 D("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.");const i=H(this,t,e,"undirected");if(!i)throw new E(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${e}" edge in the graph.`);return at(this,i),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let e;for(;e=t.next(),e.done!==!0;)e.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,e){if(typeof e!="function")throw new _("Graph.updateAttribute: updater should be a function.");const i=this._attributes[t];return this._attributes[t]=e(i),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!P(t))throw new _("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!P(t))throw new _("Graph.mergeAttributes: provided attributes are not a plain object.");return j(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new _("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,e){if(typeof t!="function")throw new _("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!Yt(e))throw new _("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._nodes.values();let r,n;for(;r=i.next(),r.done!==!0;)n=r.value,n.attributes=t(n.key,n.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})}updateEachEdgeAttributes(t,e){if(typeof t!="function")throw new _("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!Yt(e))throw new _("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._edges.values();let r,n,u,s;for(;r=i.next(),r.done!==!0;)n=r.value,u=n.source,s=n.target,n.attributes=t(n.key,n.attributes,u.key,s.key,u.attributes,s.attributes,n.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new _("Graph.forEachAdjacencyEntry: expecting a callback.");wt(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new _("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");wt(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new _("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");wt(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new _("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");wt(!1,!0,!0,this,t)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):ae(this._nodes.keys(),this._nodes.size)}forEachNode(t){if(typeof t!="function")throw new _("Graph.forEachNode: expecting a callback.");const e=this._nodes.values();let i,r;for(;i=e.next(),i.done!==!0;)r=i.value,t(r.key,r.attributes)}findNode(t){if(typeof t!="function")throw new _("Graph.findNode: expecting a callback.");const e=this._nodes.values();let i,r;for(;i=e.next(),i.done!==!0;)if(r=i.value,t(r.key,r.attributes))return r.key}mapNodes(t){if(typeof t!="function")throw new _("Graph.mapNode: expecting a callback.");const e=this._nodes.values();let i,r;const n=new Array(this.order);let u=0;for(;i=e.next(),i.done!==!0;)r=i.value,n[u++]=t(r.key,r.attributes);return n}someNode(t){if(typeof t!="function")throw new _("Graph.someNode: expecting a callback.");const e=this._nodes.values();let i,r;for(;i=e.next(),i.done!==!0;)if(r=i.value,t(r.key,r.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new _("Graph.everyNode: expecting a callback.");const e=this._nodes.values();let i,r;for(;i=e.next(),i.done!==!0;)if(r=i.value,!t(r.key,r.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new _("Graph.filterNodes: expecting a callback.");const e=this._nodes.values();let i,r;const n=[];for(;i=e.next(),i.done!==!0;)r=i.value,t(r.key,r.attributes)&&n.push(r.key);return n}reduceNodes(t,e){if(typeof t!="function")throw new _("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new _("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=e;const r=this._nodes.values();let n,u;for(;n=r.next(),n.done!==!0;)u=n.value,i=t(i,u.key,u.attributes);return i}nodeEntries(){const t=this._nodes.values();return new X(()=>{const e=t.next();if(e.done)return e;const i=e.value;return{value:{node:i.key,attributes:i.attributes},done:!1}})}export(){const t=new Array(this._nodes.size);let e=0;this._nodes.forEach((r,n)=>{t[e++]=Di(n,r)});const i=new Array(this._edges.size);return e=0,this._edges.forEach((r,n)=>{i[e++]=Ni(this.type,n,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:i}}import(t,e=!1){if(t instanceof I)return t.forEachNode((h,a)=>{e?this.mergeNode(h,a):this.addNode(h,a)}),t.forEachEdge((h,a,d,f,c,w,x)=>{e?x?this.mergeUndirectedEdgeWithKey(h,d,f,a):this.mergeDirectedEdgeWithKey(h,d,f,a):x?this.addUndirectedEdgeWithKey(h,d,f,a):this.addDirectedEdgeWithKey(h,d,f,a)}),this;if(!P(t))throw new _("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!P(t.attributes))throw new _("Graph.import: invalid attributes. Expecting a plain object.");e?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let i,r,n,u,s;if(t.nodes){if(n=t.nodes,!Array.isArray(n))throw new _("Graph.import: invalid nodes. Expecting an array.");for(i=0,r=n.length;i<r;i++){u=n[i],Li(u);const{key:h,attributes:a}=u;e?this.mergeNode(h,a):this.addNode(h,a)}}if(t.edges){let h=!1;if(this.type==="undirected"&&(h=!0),n=t.edges,!Array.isArray(n))throw new _("Graph.import: invalid edges. Expecting an array.");for(i=0,r=n.length;i<r;i++){s=n[i],Si(s);const{source:a,target:d,attributes:f,undirected:c=h}=s;let w;"key"in s?(w=e?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,w.call(this,s.key,a,d,f)):(w=e?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,w.call(this,a,d,f))}}return this}nullCopy(t){const e=new I(j({},this._options,t));return e.replaceAttributes(j({},this.getAttributes())),e}emptyCopy(t){const e=this.nullCopy(t);return this._nodes.forEach((i,r)=>{const n=j({},i.attributes);i=new e.NodeDataClass(r,n),e._nodes.set(r,i)}),e}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new D(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new D("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 t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new D("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.");const e=this.emptyCopy(t),i=this._edges.values();let r,n;for(;r=i.next(),r.done!==!0;)n=r.value,ye(e,"copy",!1,n.undirected,n.key,n.source.key,n.target.key,j({},n.attributes));return e}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((n,u)=>{t[u]=n.attributes});const e={},i={};this._edges.forEach((n,u)=>{const s=n.undirected?"--":"->";let h="",a=n.source.key,d=n.target.key,f;n.undirected&&a>d&&(f=a,a=d,d=f);const c=`(${a})${s}(${d})`;u.startsWith("geid_")?this.multi&&(typeof i[c]>"u"?i[c]=0:i[c]++,h+=`${i[c]}. `):h+=`[${u}]: `,h+=c,e[h]=n.attributes});const r={};for(const n in this)this.hasOwnProperty(n)&&!Vt.has(n)&&typeof this[n]!="function"&&typeof n!="symbol"&&(r[n]=this[n]);return r.attributes=this._attributes,r.nodes=t,r.edges=e,Q(r,"constructor",this.constructor),r}}typeof Symbol<"u"&&(I.prototype[Symbol.for("nodejs.util.inspect.custom")]=I.prototype.inspect);Mi.forEach(o=>{["add","merge","update"].forEach(t=>{const e=o.name(t),i=t==="add"?ye:zi;o.generateKey?I.prototype[e]=function(r,n,u){return i(this,e,!0,(o.type||this.type)==="undirected",null,r,n,u,t==="update")}:I.prototype[e]=function(r,n,u,s){return i(this,e,!1,(o.type||this.type)==="undirected",r,n,u,s,t==="update")}})});Ke(I);ri(I);vi(I);ki(I);class we extends I{constructor(t){const e=j({type:"directed"},t);if("multi"in e&&e.multi!==!1)throw new _("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="directed")throw new _('DirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class me extends I{constructor(t){const e=j({type:"undirected"},t);if("multi"in e&&e.multi!==!1)throw new _("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="undirected")throw new _('UndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class ve extends I{constructor(t){const e=j({multi:!0},t);if("multi"in e&&e.multi!==!0)throw new _("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(e)}}class be extends I{constructor(t){const e=j({type:"directed",multi:!0},t);if("multi"in e&&e.multi!==!0)throw new _("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="directed")throw new _('MultiDirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Ee extends I{constructor(t){const e=j({type:"undirected",multi:!0},t);if("multi"in e&&e.multi!==!0)throw new _("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="undirected")throw new _('MultiUndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}function ht(o){o.from=function(t,e){const i=j({},t.options,e),r=new o(i);return r.import(t),r}}ht(I);ht(we);ht(me);ht(ve);ht(be);ht(Ee);I.Graph=I;I.DirectedGraph=we;I.UndirectedGraph=me;I.MultiGraph=ve;I.MultiDirectedGraph=be;I.MultiUndirectedGraph=Ee;I.InvalidArgumentsGraphError=_;I.NotFoundGraphError=E;I.UsageGraphError=D;var Dt,Ht;function Ae(){if(Ht)return Dt;Ht=1;function o(e){return!e||typeof e!="object"||typeof e=="function"||Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof RegExp||e instanceof Date}function t(e,i){e=e||{};var r={};for(var n in i){var u=e[n],s=i[n];if(!o(s)){r[n]=t(u,s);continue}u===void 0?r[n]=s:r[n]=u}return r}return Dt=t,Dt}var Nt,Xt;function Ge(){return Xt||(Xt=1,Nt=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),Nt}var Lt,Jt;function Oi(){if(Jt)return Lt;Jt=1;var o=Ge();return Lt=function(e){if(!o(e))throw new Error("graphology-utils/infer-type: expecting a valid graphology instance.");var i=e.type;return i!=="mixed"?i:e.directedSize===0&&e.undirectedSize===0||e.directedSize>0&&e.undirectedSize>0?"mixed":e.directedSize>0?"directed":"undirected"},Lt}var St={},Zt;function Tt(){return Zt||(Zt=1,(function(o){var t=Math.pow(2,8)-1,e=Math.pow(2,16)-1,i=Math.pow(2,32)-1,r=Math.pow(2,7)-1,n=Math.pow(2,15)-1,u=Math.pow(2,31)-1;o.getPointerArray=function(h){var a=h-1;if(a<=t)return Uint8Array;if(a<=e)return Uint16Array;if(a<=i)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},o.getSignedPointerArray=function(h){var a=h-1;return a<=r?Int8Array:a<=n?Int16Array:a<=u?Int32Array:Float64Array},o.getNumberType=function(h){return h===(h|0)?Math.sign(h)===-1?h<=127&&h>=-128?Int8Array:h<=32767&&h>=-32768?Int16Array:Int32Array:h<=255?Uint8Array:h<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};o.getMinimalRepresentation=function(h,a){var d=null,f=0,c,w,x,N,$;for(N=0,$=h.length;N<$;N++)x=a?a(h[N]):h[N],w=o.getNumberType(x),c=s[w.name],c>f&&(f=c,d=w);return d},o.isTypedArray=function(h){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(h)},o.concat=function(){var h=0,a,d,f;for(a=0,f=arguments.length;a<f;a++)h+=arguments[a].length;var c=new arguments[0].constructor(h);for(a=0,d=0;a<f;a++)c.set(arguments[a],d),d+=arguments[a].length;return c},o.indices=function(h){for(var a=o.getPointerArray(h),d=new a(h),f=0;f<h;f++)d[f]=f;return d}})(St)),St}var Wt,te;function ji(){if(te)return Wt;te=1;var o=pt(),t=Tt().getPointerArray;function e(i,r){arguments.length<2&&(r=i,i=Array);var n=t(r);this.size=0,this.length=r,this.dense=new n(r),this.sparse=new n(r),this.vals=new i(r)}return e.prototype.clear=function(){this.size=0},e.prototype.has=function(i){var r=this.sparse[i];return r<this.size&&this.dense[r]===i},e.prototype.get=function(i){var r=this.sparse[i];if(r<this.size&&this.dense[r]===i)return this.vals[r]},e.prototype.set=function(i,r){var n=this.sparse[i];return n<this.size&&this.dense[n]===i?(this.vals[n]=r,this):(this.dense[this.size]=i,this.sparse[i]=this.size,this.vals[this.size]=r,this.size++,this)},e.prototype.delete=function(i){var r=this.sparse[i];return r>=this.size||this.dense[r]!==i?!1:(r=this.dense[this.size-1],this.dense[this.sparse[i]]=r,this.sparse[r]=this.sparse[i],this.size--,!0)},e.prototype.forEach=function(i,r){r=arguments.length>1?r:this;for(var n=0;n<this.size;n++)i.call(r,this.vals[n],this.dense[n])},e.prototype.keys=function(){var i=this.size,r=this.dense,n=0;return new o(function(){if(n<i){var u=r[n];return n++,{value:u}}return{done:!0}})},e.prototype.values=function(){var i=this.size,r=this.vals,n=0;return new o(function(){if(n<i){var u=r[n];return n++,{value:u}}return{done:!0}})},e.prototype.entries=function(){var i=this.size,r=this.dense,n=this.vals,u=0;return new o(function(){if(u<i){var s=[r[u],n[u]];return u++,{value:s}}return{done:!0}})},typeof Symbol<"u"&&(e.prototype[Symbol.iterator]=e.prototype.entries),e.prototype.inspect=function(){for(var i=new Map,r=0;r<this.size;r++)i.set(this.dense[r],this.vals[r]);return Object.defineProperty(i,"constructor",{value:e,enumerable:!1}),i.length=this.length,this.vals.constructor!==Array&&(i.type=this.vals.constructor.name),i},typeof Symbol<"u"&&(e.prototype[Symbol.for("nodejs.util.inspect.custom")]=e.prototype.inspect),Wt=e,Wt}var Ct,ee;function Ti(){if(ee)return Ct;ee=1;var o=pt(),t=Tt().getPointerArray;function e(i){var r=t(i);this.start=0,this.size=0,this.capacity=i,this.dense=new r(i),this.sparse=new r(i)}return e.prototype.clear=function(){this.start=0,this.size=0},e.prototype.has=function(i){if(this.size===0)return!1;var r=this.sparse[i],n=r<this.capacity&&r>=this.start&&r<this.start+this.size||r<(this.start+this.size)%this.capacity;return n&&this.dense[r]===i},e.prototype.enqueue=function(i){var r=this.sparse[i];if(this.size!==0){var n=r<this.capacity&&r>=this.start&&r<this.start+this.size||r<(this.start+this.size)%this.capacity;if(n&&this.dense[r]===i)return this}return r=(this.start+this.size)%this.capacity,this.dense[r]=i,this.sparse[i]=r,this.size++,this},e.prototype.dequeue=function(){if(this.size!==0){var i=this.start;this.size--,this.start++,this.start===this.capacity&&(this.start=0);var r=this.dense[i];return this.sparse[r]=this.capacity,r}},e.prototype.forEach=function(i,r){r=arguments.length>1?r:this;for(var n=this.capacity,u=this.size,s=this.start,h=0;h<u;)i.call(r,this.dense[s],h,this),s++,h++,s===n&&(s=0)},e.prototype.values=function(){var i=this.dense,r=this.capacity,n=this.size,u=this.start,s=0;return new o(function(){if(s>=n)return{done:!0};var h=i[u];return u++,s++,u===r&&(u=0),{value:h,done:!1}})},typeof Symbol<"u"&&(e.prototype[Symbol.iterator]=e.prototype.values),e.prototype.inspect=function(){var i=[];return this.forEach(function(r){i.push(r)}),Object.defineProperty(i,"constructor",{value:e,enumerable:!1}),i.capacity=this.capacity,i},typeof Symbol<"u"&&(e.prototype[Symbol.for("nodejs.util.inspect.custom")]=e.prototype.inspect),Ct=e,Ct}var Mt,ie;function Pi(){if(ie)return Mt;ie=1;function o(e){return function(i){return typeof i!="number"&&(i=i.length),Math.floor(e()*i)}}var t=o(Math.random);return t.createRandomIndex=o,Mt=t,Mt}var mt={},lt={},re;function Ri(){if(re)return lt;re=1;function o(i){return typeof i!="number"||isNaN(i)?1:i}function t(i,r){var n={},u=function(a){return typeof a>"u"?r:a};typeof r=="function"&&(u=r);var s=function(a){return u(a[i])},h=function(){return u(void 0)};return typeof i=="string"?(n.fromAttributes=s,n.fromGraph=function(a,d){return s(a.getNodeAttributes(d))},n.fromEntry=function(a,d){return s(d)}):typeof i=="function"?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},n.fromGraph=function(a,d){return u(i(d,a.getNodeAttributes(d)))},n.fromEntry=function(a,d){return u(i(a,d))}):(n.fromAttributes=h,n.fromGraph=h,n.fromEntry=h),n}function e(i,r){var n={},u=function(a){return typeof a>"u"?r:a};typeof r=="function"&&(u=r);var s=function(a){return u(a[i])},h=function(){return u(void 0)};return typeof i=="string"?(n.fromAttributes=s,n.fromGraph=function(a,d){return s(a.getEdgeAttributes(d))},n.fromEntry=function(a,d){return s(d)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):typeof i=="function"?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(a,d){var f=a.extremities(d);return u(i(d,a.getEdgeAttributes(d),f[0],f[1],a.getNodeAttributes(f[0]),a.getNodeAttributes(f[1]),a.isUndirected(d)))},n.fromEntry=function(a,d,f,c,w,x,N){return u(i(a,d,f,c,w,x,N))},n.fromPartialEntry=function(a,d,f,c){return u(i(a,d,f,c))},n.fromMinimalEntry=function(a,d){return u(i(a,d))}):(n.fromAttributes=h,n.fromGraph=h,n.fromEntry=h,n.fromMinimalEntry=h),n}return lt.createNodeValueGetter=t,lt.createEdgeValueGetter=e,lt.createEdgeWeightGetter=function(i){return e(i,o)},lt}var ne;function qi(){if(ne)return mt;ne=1;var o=Tt(),t=Ae(),e=Ri().createEdgeWeightGetter,i=Symbol.for("nodejs.util.inspect.custom"),r={getEdgeWeight:"weight",keepDendrogram:!1,resolution:1};function n(s,h){h=t(h,r);var a=h.resolution,d=e(h.getEdgeWeight).fromEntry,f=(s.size-s.selfLoopCount)*2,c=o.getPointerArray(f),w=o.getPointerArray(s.order+1),x=h.getEdgeWeight?Float64Array:o.getPointerArray(s.size*2);this.C=s.order,this.M=0,this.E=f,this.U=0,this.resolution=a,this.level=0,this.graph=s,this.nodes=new Array(s.order),this.keepDendrogram=h.keepDendrogram,this.neighborhood=new w(f),this.weights=new x(f),this.loops=new x(s.order),this.starts=new c(s.order+1),this.belongings=new w(s.order),this.dendrogram=[],this.mapping=null,this.counts=new w(s.order),this.unused=new w(s.order),this.totalWeights=new x(s.order);var N={},$,y=0,k=0,m=this;s.forEachNode(function(l){m.nodes[y]=l,N[l]=y,k+=s.undirectedDegreeWithoutSelfLoops(l),m.starts[y]=k,m.belongings[y]=y,m.counts[y]=1,y++}),s.forEachEdge(function(l,g,p,v,b,G,A){if($=d(l,g,p,v,b,G,A),p=N[p],v=N[v],m.M+=$,p===v)m.totalWeights[p]+=$*2,m.loops[p]=$*2;else{m.totalWeights[p]+=$,m.totalWeights[v]+=$;var S=--m.starts[p],L=--m.starts[v];m.neighborhood[S]=v,m.neighborhood[L]=p,m.weights[S]=$,m.weights[L]=$}}),this.starts[y]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}n.prototype.isolate=function(s,h){var a=this.belongings[s];if(this.counts[a]===1)return a;var d=this.unused[--this.U],f=this.loops[s];return this.totalWeights[a]-=h+f,this.totalWeights[d]+=h+f,this.belongings[s]=d,this.counts[a]--,this.counts[d]++,d},n.prototype.move=function(s,h,a){var d=this.belongings[s],f=this.loops[s];this.totalWeights[d]-=h+f,this.totalWeights[a]+=h+f,this.belongings[s]=a;var c=this.counts[d]--===1;this.counts[a]++,c&&(this.unused[this.U++]=d)},n.prototype.computeNodeDegree=function(s){var h,a,d,f=0;for(h=this.starts[s],a=this.starts[s+1];h<a;h++)d=this.weights[h],f+=d;return f},n.prototype.expensiveIsolate=function(s){var h=this.computeNodeDegree(s);return this.isolate(s,h)},n.prototype.expensiveMove=function(s,h){var a=this.computeNodeDegree(s);this.move(s,a,h)},n.prototype.zoomOut=function(){var s=new Array(this.C-this.U),h={},a=this.nodes.length,d=0,f=0,c,w,x,N,$,y,k,m,l;for(c=0,x=this.C;c<x;c++)y=this.belongings[c],y in h||(h[y]=d,s[d]={adj:{},totalWeights:this.totalWeights[y],internalWeights:0},d++),this.belongings[c]=h[y];var g,p;if(this.keepDendrogram){for(g=this.dendrogram[this.level],p=new(o.getPointerArray(d))(a),c=0;c<a;c++)p[c]=this.belongings[g[c]];this.dendrogram.push(p)}else for(c=0;c<a;c++)this.mapping[c]=this.belongings[this.mapping[c]];for(c=0,x=this.C;c<x;c++)for(y=this.belongings[c],m=s[y],l=m.adj,m.internalWeights+=this.loops[c],w=this.starts[c],N=this.starts[c+1];w<N;w++){if($=this.neighborhood[w],k=this.belongings[$],y===k){m.internalWeights+=this.weights[w];continue}k in l||(l[k]=0),l[k]+=this.weights[w]}for(this.C=d,$=0,y=0;y<d;y++){m=s[y],l=m.adj,y=+y,this.totalWeights[y]=m.totalWeights,this.loops[y]=m.internalWeights,this.counts[y]=1,this.starts[y]=$,this.belongings[y]=y;for(k in l)this.neighborhood[$]=+k,this.weights[$]=l[k],f++,$++}return this.starts[d]=f,this.E=f,this.U=0,this.level++,h},n.prototype.modularity=function(){var s,h,a,d,f,c=0,w=this.M*2,x=new Float64Array(this.C);for(a=0;a<this.C;a++)for(s=this.belongings[a],x[s]+=this.loops[a],d=this.starts[a],f=this.starts[a+1];d<f;d++)h=this.belongings[this.neighborhood[d]],s===h&&(x[s]+=this.weights[d]);for(a=0;a<this.C;a++)c+=x[a]/w-Math.pow(this.totalWeights[a]/w,2)*this.resolution;return c},n.prototype.delta=function(s,h,a,d){var f=this.M,c=this.totalWeights[d];return h+=this.loops[s],a/f-c*h*this.resolution/(2*f*f)},n.prototype.deltaWithOwnCommunity=function(s,h,a,d){var f=this.M,c=this.totalWeights[d];return h+=this.loops[s],a/f-(c-h)*h*this.resolution/(2*f*f)},n.prototype.fastDelta=function(s,h,a,d){var f=this.M,c=this.totalWeights[d];return h+=this.loops[s],a-h*c*this.resolution/(2*f)},n.prototype.fastDeltaWithOwnCommunity=function(s,h,a,d){var f=this.M,c=this.totalWeights[d];return h+=this.loops[s],a-h*(c-h)*this.resolution/(2*f)},n.prototype.bounds=function(s){return[this.starts[s],this.starts[s+1]]},n.prototype.project=function(){var s=this,h={};return s.nodes.slice(0,this.C).forEach(function(a,d){h[a]=Array.from(s.neighborhood.slice(s.starts[d],s.starts[d+1])).map(function(f){return s.nodes[f]})}),h},n.prototype.collect=function(s){arguments.length<1&&(s=this.level);var h={},a=this.keepDendrogram?this.dendrogram[s]:this.mapping,d,f;for(d=0,f=a.length;d<f;d++)h[this.nodes[d]]=a[d];return h},n.prototype.assign=function(s,h){arguments.length<2&&(h=this.level);var a=this.keepDendrogram?this.dendrogram[h]:this.mapping,d,f;for(d=0,f=a.length;d<f;d++)this.graph.setNodeAttribute(this.nodes[d],s,a[d])},n.prototype[i]=function(){var s={};Object.defineProperty(s,"constructor",{value:n,enumerable:!1}),s.C=this.C,s.M=this.M,s.E=this.E,s.U=this.U,s.resolution=this.resolution,s.level=this.level,s.nodes=this.nodes,s.starts=this.starts.slice(0,s.C+1);var h=["neighborhood","weights"],a=["counts","loops","belongings","totalWeights"],d=this;return h.forEach(function(f){s[f]=d[f].slice(0,s.E)}),a.forEach(function(f){s[f]=d[f].slice(0,s.C)}),s.unused=this.unused.slice(0,this.U),this.keepDendrogram?s.dendrogram=this.dendrogram:s.mapping=this.mapping,s};function u(s,h){h=t(h,r);var a=h.resolution,d=e(h.getEdgeWeight).fromEntry,f=(s.size-s.selfLoopCount)*2,c=o.getPointerArray(f),w=o.getPointerArray(s.order+1),x=h.getEdgeWeight?Float64Array:o.getPointerArray(s.size*2);this.C=s.order,this.M=0,this.E=f,this.U=0,this.resolution=a,this.level=0,this.graph=s,this.nodes=new Array(s.order),this.keepDendrogram=h.keepDendrogram,this.neighborhood=new w(f),this.weights=new x(f),this.loops=new x(s.order),this.starts=new c(s.order+1),this.offsets=new c(s.order),this.belongings=new w(s.order),this.dendrogram=[],this.counts=new w(s.order),this.unused=new w(s.order),this.totalInWeights=new x(s.order),this.totalOutWeights=new x(s.order);var N={},$,y=0,k=0,m=this;s.forEachNode(function(l){m.nodes[y]=l,N[l]=y,k+=s.outDegreeWithoutSelfLoops(l),m.starts[y]=k,k+=s.inDegreeWithoutSelfLoops(l),m.offsets[y]=k,m.belongings[y]=y,m.counts[y]=1,y++}),s.forEachEdge(function(l,g,p,v,b,G,A){if($=d(l,g,p,v,b,G,A),p=N[p],v=N[v],m.M+=$,p===v)m.loops[p]+=$,m.totalInWeights[p]+=$,m.totalOutWeights[p]+=$;else{m.totalOutWeights[p]+=$,m.totalInWeights[v]+=$;var S=--m.starts[p],L=--m.offsets[v];m.neighborhood[S]=v,m.neighborhood[L]=p,m.weights[S]=$,m.weights[L]=$}}),this.starts[y]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}return u.prototype.bounds=n.prototype.bounds,u.prototype.inBounds=function(s){return[this.offsets[s],this.starts[s+1]]},u.prototype.outBounds=function(s){return[this.starts[s],this.offsets[s]]},u.prototype.project=n.prototype.project,u.prototype.projectIn=function(){var s=this,h={};return s.nodes.slice(0,this.C).forEach(function(a,d){h[a]=Array.from(s.neighborhood.slice(s.offsets[d],s.starts[d+1])).map(function(f){return s.nodes[f]})}),h},u.prototype.projectOut=function(){var s=this,h={};return s.nodes.slice(0,this.C).forEach(function(a,d){h[a]=Array.from(s.neighborhood.slice(s.starts[d],s.offsets[d])).map(function(f){return s.nodes[f]})}),h},u.prototype.isolate=function(s,h,a){var d=this.belongings[s];if(this.counts[d]===1)return d;var f=this.unused[--this.U],c=this.loops[s];return this.totalInWeights[d]-=h+c,this.totalInWeights[f]+=h+c,this.totalOutWeights[d]-=a+c,this.totalOutWeights[f]+=a+c,this.belongings[s]=f,this.counts[d]--,this.counts[f]++,f},u.prototype.move=function(s,h,a,d){var f=this.belongings[s],c=this.loops[s];this.totalInWeights[f]-=h+c,this.totalInWeights[d]+=h+c,this.totalOutWeights[f]-=a+c,this.totalOutWeights[d]+=a+c,this.belongings[s]=d;var w=this.counts[f]--===1;this.counts[d]++,w&&(this.unused[this.U++]=f)},u.prototype.computeNodeInDegree=function(s){var h,a,d,f=0;for(h=this.offsets[s],a=this.starts[s+1];h<a;h++)d=this.weights[h],f+=d;return f},u.prototype.computeNodeOutDegree=function(s){var h,a,d,f=0;for(h=this.starts[s],a=this.offsets[s];h<a;h++)d=this.weights[h],f+=d;return f},u.prototype.expensiveMove=function(s,h){var a=this.computeNodeInDegree(s),d=this.computeNodeOutDegree(s);this.move(s,a,d,h)},u.prototype.zoomOut=function(){var s=new Array(this.C-this.U),h={},a=this.nodes.length,d=0,f=0,c,w,x,N,$,y,k,m,l,g,p,v,b;for(c=0,x=this.C;c<x;c++)y=this.belongings[c],y in h||(h[y]=d,s[d]={inAdj:{},outAdj:{},totalInWeights:this.totalInWeights[y],totalOutWeights:this.totalOutWeights[y],internalWeights:0},d++),this.belongings[c]=h[y];var G,A;if(this.keepDendrogram){for(G=this.dendrogram[this.level],A=new(o.getPointerArray(d))(a),c=0;c<a;c++)A[c]=this.belongings[G[c]];this.dendrogram.push(A)}else for(c=0;c<a;c++)this.mapping[c]=this.belongings[this.mapping[c]];for(c=0,x=this.C;c<x;c++)for(y=this.belongings[c],l=this.offsets[c],m=s[y],v=m.inAdj,b=m.outAdj,m.internalWeights+=this.loops[c],w=this.starts[c],N=this.starts[c+1];w<N;w++){if($=this.neighborhood[w],k=this.belongings[$],g=w<l,p=g?b:v,y===k){g&&(m.internalWeights+=this.weights[w]);continue}k in p||(p[k]=0),p[k]+=this.weights[w]}for(this.C=d,$=0,y=0;y<d;y++){m=s[y],v=m.inAdj,b=m.outAdj,y=+y,this.totalInWeights[y]=m.totalInWeights,this.totalOutWeights[y]=m.totalOutWeights,this.loops[y]=m.internalWeights,this.counts[y]=1,this.starts[y]=$,this.belongings[y]=y;for(k in b)this.neighborhood[$]=+k,this.weights[$]=b[k],f++,$++;this.offsets[y]=$;for(k in v)this.neighborhood[$]=+k,this.weights[$]=v[k],f++,$++}return this.starts[d]=f,this.E=f,this.U=0,this.level++,h},u.prototype.modularity=function(){var s,h,a,d,f,c=0,w=this.M,x=new Float64Array(this.C);for(a=0;a<this.C;a++)for(s=this.belongings[a],x[s]+=this.loops[a],d=this.starts[a],f=this.offsets[a];d<f;d++)h=this.belongings[this.neighborhood[d]],s===h&&(x[s]+=this.weights[d]);for(a=0;a<this.C;a++)c+=x[a]/w-this.totalInWeights[a]*this.totalOutWeights[a]/Math.pow(w,2)*this.resolution;return c},u.prototype.delta=function(s,h,a,d,f){var c=this.M,w=this.totalInWeights[f],x=this.totalOutWeights[f],N=this.loops[s];return h+=N,a+=N,d/c-(a*w+h*x)*this.resolution/(c*c)},u.prototype.deltaWithOwnCommunity=function(s,h,a,d,f){var c=this.M,w=this.totalInWeights[f],x=this.totalOutWeights[f],N=this.loops[s];return h+=N,a+=N,d/c-(a*(w-h)+h*(x-a))*this.resolution/(c*c)},u.prototype.collect=n.prototype.collect,u.prototype.assign=n.prototype.assign,u.prototype[i]=function(){var s={};Object.defineProperty(s,"constructor",{value:u,enumerable:!1}),s.C=this.C,s.M=this.M,s.E=this.E,s.U=this.U,s.resolution=this.resolution,s.level=this.level,s.nodes=this.nodes,s.starts=this.starts.slice(0,s.C+1);var h=["neighborhood","weights"],a=["counts","offsets","loops","belongings","totalInWeights","totalOutWeights"],d=this;return h.forEach(function(f){s[f]=d[f].slice(0,s.E)}),a.forEach(function(f){s[f]=d[f].slice(0,s.C)}),s.unused=this.unused.slice(0,this.U),this.keepDendrogram?s.dendrogram=this.dendrogram:s.mapping=this.mapping,s},mt.UndirectedLouvainIndex=n,mt.DirectedLouvainIndex=u,mt}var It,oe;function Bi(){if(oe)return It;oe=1;var o=Ae(),t=Ge(),e=Oi(),i=ji(),r=Ti(),n=Pi().createRandomIndex,u=qi(),s=u.UndirectedLouvainIndex,h=u.DirectedLouvainIndex,a={nodeCommunityAttribute:"community",getEdgeWeight:"weight",fastLocalMoves:!0,randomWalk:!0,resolution:1,rng:Math.random};function d(y,k,m){var l=y.get(k);typeof l>"u"&&(l=0),l+=m,y.set(k,l)}var f=1e-10;function c(y,k,m,l,g){return Math.abs(l-g)<f?y===k?!1:m>y:l>g}function w(y,k,m){var l=new s(k,{getEdgeWeight:m.getEdgeWeight,keepDendrogram:y,resolution:m.resolution}),g=n(m.rng),p=!0,v=!0,b,G,A=new i(Float64Array,l.C),S,L,R,K,q,B,T,M,F,W,O,Y,C,z,et,U,V=0,nt=0,Z=[],ot,tt;for(m.fastLocalMoves&&(S=new r(l.C));p;){if(W=l.C,p=!1,v=!0,m.fastLocalMoves){for(tt=0,B=m.randomWalk?g(W):0,T=0;T<W;T++,B++)M=B%W,S.enqueue(M);for(;S.size!==0;){for(M=S.dequeue(),nt++,O=0,A.clear(),b=l.belongings[M],L=l.starts[M],R=l.starts[M+1];L<R;L++)F=l.neighborhood[L],K=l.weights[L],G=l.belongings[F],O+=K,d(A,G,K);for(z=l.fastDeltaWithOwnCommunity(M,O,A.get(b)||0,b),C=b,q=0;q<A.size;q++)G=A.dense[q],G!==b&&(Y=A.vals[q],V++,U=l.fastDelta(M,O,Y,G),et=c(C,b,G,U,z),et&&(z=U,C=G));if(z<0){if(C=l.isolate(M,O),C===b)continue}else{if(C===b)continue;l.move(M,O,C)}for(p=!0,tt++,L=l.starts[M],R=l.starts[M+1];L<R;L++)F=l.neighborhood[L],G=l.belongings[F],G!==C&&S.enqueue(F)}Z.push(tt)}else for(ot=[],Z.push(ot);v;){for(v=!1,tt=0,B=m.randomWalk?g(W):0,T=0;T<W;T++,B++){for(M=B%W,nt++,O=0,A.clear(),b=l.belongings[M],L=l.starts[M],R=l.starts[M+1];L<R;L++)F=l.neighborhood[L],K=l.weights[L],G=l.belongings[F],O+=K,d(A,G,K);for(z=l.fastDeltaWithOwnCommunity(M,O,A.get(b)||0,b),C=b,q=0;q<A.size;q++)G=A.dense[q],G!==b&&(Y=A.vals[q],V++,U=l.fastDelta(M,O,Y,G),et=c(C,b,G,U,z),et&&(z=U,C=G));if(z<0){if(C=l.isolate(M,O),C===b)continue}else{if(C===b)continue;l.move(M,O,C)}v=!0,tt++}ot.push(tt),p=v||p}p&&l.zoomOut()}var dt={index:l,deltaComputations:V,nodesVisited:nt,moves:Z};return dt}function x(y,k,m){var l=new h(k,{getEdgeWeight:m.getEdgeWeight,keepDendrogram:y,resolution:m.resolution}),g=n(m.rng),p=!0,v=!0,b,G,A=new i(Float64Array,l.C),S,L,R,K,q,B,T,M,F,W,O,Y,C,z,et,U,V,nt,Z,ot=0,tt=0,dt=[],Et,st;for(m.fastLocalMoves&&(S=new r(l.C));p;){if(Y=l.C,p=!1,v=!0,m.fastLocalMoves){for(st=0,M=m.randomWalk?g(Y):0,F=0;F<Y;F++,M++)W=M%Y,S.enqueue(W);for(;S.size!==0;){for(W=S.dequeue(),tt++,C=0,z=0,A.clear(),b=l.belongings[W],L=l.starts[W],R=l.starts[W+1],K=l.offsets[W];L<R;L++)q=L<K,O=l.neighborhood[L],B=l.weights[L],G=l.belongings[O],q?z+=B:C+=B,d(A,G,B);for(V=l.deltaWithOwnCommunity(W,C,z,A.get(b)||0,b),U=b,T=0;T<A.size;T++)G=A.dense[T],G!==b&&(et=A.vals[T],ot++,Z=l.delta(W,C,z,et,G),nt=c(U,b,G,Z,V),nt&&(V=Z,U=G));if(V<0){if(U=l.isolate(W,C,z),U===b)continue}else{if(U===b)continue;l.move(W,C,z,U)}for(p=!0,st++,L=l.starts[W],R=l.starts[W+1];L<R;L++)O=l.neighborhood[L],G=l.belongings[O],G!==U&&S.enqueue(O)}dt.push(st)}else for(Et=[],dt.push(Et);v;){for(v=!1,st=0,M=m.randomWalk?g(Y):0,F=0;F<Y;F++,M++){for(W=M%Y,tt++,C=0,z=0,A.clear(),b=l.belongings[W],L=l.starts[W],R=l.starts[W+1],K=l.offsets[W];L<R;L++)q=L<K,O=l.neighborhood[L],B=l.weights[L],G=l.belongings[O],q?z+=B:C+=B,d(A,G,B);for(V=l.deltaWithOwnCommunity(W,C,z,A.get(b)||0,b),U=b,T=0;T<A.size;T++)G=A.dense[T],G!==b&&(et=A.vals[T],ot++,Z=l.delta(W,C,z,et,G),nt=c(U,b,G,Z,V),nt&&(V=Z,U=G));if(V<0){if(U=l.isolate(W,C,z),U===b)continue}else{if(U===b)continue;l.move(W,C,z,U)}v=!0,st++}Et.push(st),p=v||p}p&&l.zoomOut()}var _e={index:l,deltaComputations:ot,nodesVisited:tt,moves:dt};return _e}function N(y,k,m,l){if(!t(m))throw new Error("graphology-communities-louvain: the given graph is not a valid graphology instance.");var g=e(m);if(g==="mixed")throw new Error("graphology-communities-louvain: cannot run the algorithm on a true mixed graph.");l=o(l,a);var p=0;if(m.size===0){if(y){m.forEachNode(function(L){m.setNodeAttribute(L,l.nodeCommunityAttribute,p++)});return}var v={};return m.forEachNode(function(L){v[L]=p++}),k?{communities:v,count:m.order,deltaComputations:0,dendrogram:null,level:0,modularity:NaN,moves:null,nodesVisited:0,resolution:l.resolution}:v}var b=g==="undirected"?w:x,G=b(k,m,l),A=G.index;if(!k){if(y){A.assign(l.nodeCommunityAttribute);return}return A.collect()}var S={count:A.C,deltaComputations:G.deltaComputations,dendrogram:A.dendrogram,level:A.level,modularity:A.modularity(),moves:G.moves,nodesVisited:G.nodesVisited,resolution:l.resolution};return y?(A.assign(l.nodeCommunityAttribute),S):(S.communities=A.collect(),S)}var $=N.bind(null,!1,!1);return $.assign=N.bind(null,!0,!1),$.detailed=N.bind(null,!1,!0),$.defaults=a,It=$,It}var Fi=Bi();const Yi=vt(Fi);export{I as G,Yi as l};
|